remote-codex 0.11.42 → 0.11.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/relay-server/dist/index.js +25 -4
- package/apps/supervisor-api/dist/index.js +71 -10
- package/apps/supervisor-web/dist/assets/frontend-DNAQzqc-.js +1704 -0
- package/apps/supervisor-web/dist/assets/{index-BvxWpPKW.js → index-CO8cU7a0.js} +7 -7
- package/apps/supervisor-web/dist/assets/styles-BEieA99i.css +1 -0
- package/apps/supervisor-web/dist/assets/{thread-ui-BLThton-.js → thread-ui-Dmrigdek.js} +28 -26
- package/apps/supervisor-web/dist/index.html +2 -2
- package/package.json +1 -1
- package/packages/claude/src/runtimeAdapter.test.ts +41 -6
- package/packages/claude/src/runtimeAdapter.ts +81 -10
|
@@ -0,0 +1,1704 @@
|
|
|
1
|
+
var Vs=Object.defineProperty;var js=(k,w,c)=>w in k?Vs(k,w,{enumerable:!0,configurable:!0,writable:!0,value:c}):k[w]=c;var Pt=(k,w,c)=>js(k,typeof w!="symbol"?w+"":w,c);import{r as reactExports,j as jsxRuntimeExports}from"./react-vendor-Dfg_6BLf.js";import{l as lucideReactExports}from"./ui-vendor-CuR8GHb0.js";var _3Dmol$1={exports:{}};/*!
|
|
2
|
+
* 3dmol v2.5.5
|
|
3
|
+
* JavaScript/TypeScript molecular visualization library
|
|
4
|
+
* Author: David Koes and contributors
|
|
5
|
+
*/var _3Dmol=_3Dmol$1.exports,hasRequired_3Dmol;function require_3Dmol(){return hasRequired_3Dmol||(hasRequired_3Dmol=1,(function(module,exports){(function(w,c){module.exports=c()})(_3Dmol,()=>(()=>{var __webpack_modules__={"./node_modules/iobuffer/lib-esm/IOBuffer.js"(k,w,c){c.r(w),c.d(w,{IOBuffer:()=>v});var b=c("./node_modules/iobuffer/lib-esm/text.js");const O=1024*8,C=(()=>{const y=new Uint8Array(4),M=new Uint32Array(y.buffer);return!((M[0]=1)&y[0])})(),R={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 v{constructor(M=O,g={}){Pt(this,"buffer");Pt(this,"byteLength");Pt(this,"byteOffset");Pt(this,"length");Pt(this,"offset");Pt(this,"lastWrittenByte");Pt(this,"littleEndian");Pt(this,"_data");Pt(this,"_mark");Pt(this,"_marks");let x=!1;typeof M=="number"?M=new ArrayBuffer(M):(x=!0,this.lastWrittenByte=M.byteLength);const _=g.offset?g.offset>>>0:0,p=M.byteLength-_;let m=_;(ArrayBuffer.isView(M)||M instanceof v)&&(M.byteLength!==M.buffer.byteLength&&(m=M.byteOffset+_),M=M.buffer),x?this.lastWrittenByte=p:this.lastWrittenByte=0,this.buffer=M,this.length=p,this.byteLength=p,this.byteOffset=m,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,m,p),this._mark=0,this._marks=[]}available(M=1){return this.offset+M<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(M=1){return this.offset+=M,this}back(M=1){return this.offset-=M,this}seek(M){return this.offset=M,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 M=this._marks.pop();if(M===void 0)throw new Error("Mark stack empty");return this.seek(M),this}rewind(){return this.offset=0,this}ensureAvailable(M=1){if(!this.available(M)){const x=(this.offset+M)*2,_=new Uint8Array(x);_.set(new Uint8Array(this.buffer)),this.buffer=_.buffer,this.length=x,this.byteLength=x,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(M=1){return this.readArray(M,"uint8")}readArray(M,g){const x=R[g].BYTES_PER_ELEMENT*M,_=this.byteOffset+this.offset,p=this.buffer.slice(_,_+x);if(this.littleEndian===C&&g!=="uint8"&&g!=="int8"){const r=new Uint8Array(this.buffer.slice(_,_+x));r.reverse();const e=new R[g](r.buffer);return this.offset+=x,e.reverse(),e}const m=new R[g](p);return this.offset+=x,m}readInt16(){const M=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,M}readUint16(){const M=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,M}readInt32(){const M=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,M}readUint32(){const M=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,M}readFloat32(){const M=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,M}readFloat64(){const M=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,M}readBigInt64(){const M=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,M}readBigUint64(){const M=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,M}readChar(){return String.fromCharCode(this.readInt8())}readChars(M=1){let g="";for(let x=0;x<M;x++)g+=this.readChar();return g}readUtf8(M=1){return(0,b.decode)(this.readBytes(M))}decodeText(M=1,g="utf8"){return(0,b.decode)(this.readBytes(M),g)}writeBoolean(M){return this.writeUint8(M?255:0),this}writeInt8(M){return this.ensureAvailable(1),this._data.setInt8(this.offset++,M),this._updateLastWrittenByte(),this}writeUint8(M){return this.ensureAvailable(1),this._data.setUint8(this.offset++,M),this._updateLastWrittenByte(),this}writeByte(M){return this.writeUint8(M)}writeBytes(M){this.ensureAvailable(M.length);for(let g=0;g<M.length;g++)this._data.setUint8(this.offset++,M[g]);return this._updateLastWrittenByte(),this}writeInt16(M){return this.ensureAvailable(2),this._data.setInt16(this.offset,M,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(M){return this.ensureAvailable(2),this._data.setUint16(this.offset,M,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(M){return this.ensureAvailable(4),this._data.setInt32(this.offset,M,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(M){return this.ensureAvailable(4),this._data.setUint32(this.offset,M,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(M){return this.ensureAvailable(4),this._data.setFloat32(this.offset,M,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(M){return this.ensureAvailable(8),this._data.setFloat64(this.offset,M,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(M){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,M,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(M){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,M,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(M){return this.writeUint8(M.charCodeAt(0))}writeChars(M){for(let g=0;g<M.length;g++)this.writeUint8(M.charCodeAt(g));return this}writeUtf8(M){return this.writeBytes((0,b.encode)(M))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}},"./node_modules/iobuffer/lib-esm/text.js"(k,w,c){c.r(w),c.d(w,{decode:()=>b,encode:()=>C});function b(R,v="utf8"){return new TextDecoder(v).decode(R)}const O=new TextEncoder;function C(R){return O.encode(R)}},"./node_modules/netcdfjs/lib-esm/data.js"(k,w,c){c.r(w),c.d(w,{nonRecord:()=>O,record:()=>C});var b=c("./node_modules/netcdfjs/lib-esm/types.js");function O(R,v){const y=(0,b.str2num)(v.type),M=v.size/(0,b.num2bytes)(y),g=new Array(M);for(let x=0;x<M;x++)g[x]=(0,b.readType)(R,y,1);return g}function C(R,v,y){const M=(0,b.str2num)(v.type),g=v.size?v.size/(0,b.num2bytes)(M):1,x=y.length,_=new Array(x),p=y.recordStep;if(p)for(let m=0;m<x;m++){const r=R.offset;_[m]=(0,b.readType)(R,M,g),R.seek(r+p)}else throw new Error("recordDimension.recordStep is undefined");return _}},"./node_modules/netcdfjs/lib-esm/header.js"(k,w,c){c.r(w),c.d(w,{header:()=>g});var b=c("./node_modules/netcdfjs/lib-esm/types.js"),O=c("./node_modules/netcdfjs/lib-esm/utils.js");const C=0,R=10,v=11,y=12,M=0;function g(m,r){const e={version:r},t={length:m.readUint32()},s=x(m);Array.isArray(s)||(t.id=s.recordId,t.name=s.recordName,e.dimensions=s.dimensions),e.globalAttributes=_(m);const o=p(m,t==null?void 0:t.id,r);return Array.isArray(o)||(e.variables=o.variables,t.recordStep=o.recordStep),e.recordDimension=t,e}function x(m){const r={};let e,t;const s=m.readUint32();let o;if(s===C)return(0,O.notNetcdf)(m.readUint32()!==C,"wrong empty tag for list of dimensions"),[];{(0,O.notNetcdf)(s!==R,"wrong tag for list of dimensions");const l=m.readUint32();o=new Array(l);for(let d=0;d<l;d++){const i=(0,O.readName)(m),n=m.readUint32();n===M&&(e=d,t=i),o[d]={name:i,size:n}}}return e!==void 0&&(r.recordId=e),t!==void 0&&(r.recordName=t),r.dimensions=o,r}function _(m){const r=m.readUint32();let e;if(r===C)return(0,O.notNetcdf)(m.readUint32()!==C,"wrong empty tag for list of attributes"),[];{(0,O.notNetcdf)(r!==y,"wrong tag for list of attributes");const t=m.readUint32();e=new Array(t);for(let s=0;s<t;s++){const o=(0,O.readName)(m),l=m.readUint32();(0,O.notNetcdf)(l<1||l>6,`non valid type ${l}`);const d=m.readUint32(),i=(0,b.readType)(m,l,d);(0,O.padding)(m),e[s]={name:o,type:(0,b.num2str)(l),value:i}}}return e}function p(m,r,e){const t=m.readUint32();let s=0,o;if(t===C)return(0,O.notNetcdf)(m.readUint32()!==C,"wrong empty tag for list of variables"),[];{(0,O.notNetcdf)(t!==v,"wrong tag for list of variables");const l=m.readUint32();o=new Array(l);for(let d=0;d<l;d++){const i=(0,O.readName)(m),n=m.readUint32(),a=new Array(n);for(let S=0;S<n;S++)a[S]=m.readUint32();const h=_(m),u=m.readUint32();(0,O.notNetcdf)(u<1&&u>6,`non valid type ${u}`);const A=m.readUint32();let D=m.readUint32();e===2&&((0,O.notNetcdf)(D>0,"offsets larger than 4GB not supported"),D=m.readUint32());let T=!1;typeof r<"u"&&a[0]===r&&(s+=A,T=!0),o[d]={name:i,dimensions:a,attributes:h,type:(0,b.num2str)(u),size:A,offset:D,record:T}}}return{variables:o,recordStep:s}}},"./node_modules/netcdfjs/lib-esm/index.js"(k,w,c){c.r(w),c.d(w,{NetCDFReader:()=>b.NetCDFReader});var b=c("./node_modules/netcdfjs/lib-esm/parser.js")},"./node_modules/netcdfjs/lib-esm/parser.js"(k,w,c){c.r(w),c.d(w,{NetCDFReader:()=>y});var b=c("./node_modules/iobuffer/lib-esm/IOBuffer.js"),O=c("./node_modules/netcdfjs/lib-esm/data.js"),C=c("./node_modules/netcdfjs/lib-esm/header.js"),R=c("./node_modules/netcdfjs/lib-esm/toString.js"),v=c("./node_modules/netcdfjs/lib-esm/utils.js");class y{constructor(g){this.toString=R.toString;const x=new b.IOBuffer(g);x.setBigEndian(),(0,v.notNetcdf)(x.readChars(3)!=="CDF","should start with CDF");const _=x.readByte();(0,v.notNetcdf)(_>2,"unknown version"),this.header=(0,C.header)(x,_),this.buffer=x}get version(){return this.header.version===1?"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(g){const x=this.globalAttributes.find(_=>_.name===g);return x?x.value:null}getDataVariableAsString(g){const x=this.getDataVariable(g);return x?x.join(""):null}get variables(){return this.header.variables}getDataVariable(g){let x;if(typeof g=="string"?x=this.header.variables.find(_=>_.name===g):x=g,x===void 0)throw new Error("Not a valid NetCDF v3.x file: variable not found");return this.buffer.seek(x.offset),x.record?(0,O.record)(this.buffer,x,this.header.recordDimension):(0,O.nonRecord)(this.buffer,x)}dataVariableExists(g){return this.header.variables.find(_=>_.name===g)!==void 0}attributeExists(g){return this.globalAttributes.find(_=>_.name===g)!==void 0}}},"./node_modules/netcdfjs/lib-esm/toString.js"(k,w,c){c.r(w),c.d(w,{toString:()=>b});function b(){const O=[];O.push("DIMENSIONS");for(const R of this.dimensions)O.push(` ${R.name.padEnd(30)} = size: ${R.size}`);O.push(""),O.push("GLOBAL ATTRIBUTES");for(const R of this.globalAttributes)O.push(` ${R.name.padEnd(30)} = ${R.value}`);const C=JSON.parse(JSON.stringify(this.variables));O.push(""),O.push("VARIABLES:");for(const R of C){R.value=this.getDataVariable(R);let v=JSON.stringify(R.value);v.length>50&&(v=v.substring(0,50)),isNaN(R.value.length)||(v+=` (length: ${R.value.length})`),O.push(` ${R.name.padEnd(30)} = ${v}`)}return O.join(`
|
|
6
|
+
`)}},"./node_modules/netcdfjs/lib-esm/types.js"(k,w,c){c.r(w),c.d(w,{num2bytes:()=>C,num2str:()=>O,readType:()=>y,str2num:()=>R});const b={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function O(g){switch(Number(g)){case b.BYTE:return"byte";case b.CHAR:return"char";case b.SHORT:return"short";case b.INT:return"int";case b.FLOAT:return"float";case b.DOUBLE:return"double";default:return"undefined"}}function C(g){switch(Number(g)){case b.BYTE:return 1;case b.CHAR:return 1;case b.SHORT:return 2;case b.INT:return 4;case b.FLOAT:return 4;case b.DOUBLE:return 8;default:return-1}}function R(g){switch(String(g)){case"byte":return b.BYTE;case"char":return b.CHAR;case"short":return b.SHORT;case"int":return b.INT;case"float":return b.FLOAT;case"double":return b.DOUBLE;default:return-1}}function v(g,x){if(g!==1){const _=new Array(g);for(let p=0;p<g;p++)_[p]=x();return _}else return x()}function y(g,x,_){switch(x){case b.BYTE:return Array.from(g.readBytes(_));case b.CHAR:return M(g.readChars(_));case b.SHORT:return v(_,g.readInt16.bind(g));case b.INT:return v(_,g.readInt32.bind(g));case b.FLOAT:return v(_,g.readFloat32.bind(g));case b.DOUBLE:return v(_,g.readFloat64.bind(g));default:throw new Error(`non valid type ${x}`)}}function M(g){return g.charCodeAt(g.length-1)===0?g.substring(0,g.length-1):g}},"./node_modules/netcdfjs/lib-esm/utils.js"(k,w,c){c.r(w),c.d(w,{notNetcdf:()=>b,padding:()=>O,readName:()=>C});function b(R,v){if(R)throw new TypeError(`Not a valid NetCDF v3.x file: ${v}`)}function O(R){R.offset%4!==0&&R.skip(4-R.offset%4)}function C(R){const v=R.readUint32(),y=R.readChars(v);return O(R),y}},"./node_modules/pako/dist/pako.esm.mjs"(k,w,c){c.r(w),c.d(w,{Deflate:()=>Gr,Inflate:()=>kr,constants:()=>Xr,default:()=>Ns,deflate:()=>Nr,deflateRaw:()=>Vr,gzip:()=>jr,inflate:()=>Hr,inflateRaw:()=>Kr,ungzip:()=>Zr});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const b=4,O=0,C=1,R=2;function v(f){let N=f.length;for(;--N>=0;)f[N]=0}const y=0,M=1,g=2,x=3,_=258,p=29,m=256,r=m+1+p,e=30,t=19,s=2*r+1,o=15,l=16,d=7,i=256,n=16,a=17,h=18,u=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]),A=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]),D=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),S=512,P=new Array((r+2)*2);v(P);const z=new Array(e*2);v(z);const F=new Array(S);v(F);const B=new Array(_-x+1);v(B);const W=new Array(p);v(W);const U=new Array(e);v(U);function I(f,N,E,X,q){this.static_tree=f,this.extra_bits=N,this.extra_base=E,this.elems=X,this.max_length=q,this.has_stree=f&&f.length}let G,Y,J;function te(f,N){this.dyn_tree=f,this.max_code=0,this.stat_desc=N}const ne=f=>f<256?F[f]:F[256+(f>>>7)],le=(f,N)=>{f.pending_buf[f.pending++]=N&255,f.pending_buf[f.pending++]=N>>>8&255},ie=(f,N,E)=>{f.bi_valid>l-E?(f.bi_buf|=N<<f.bi_valid&65535,le(f,f.bi_buf),f.bi_buf=N>>l-f.bi_valid,f.bi_valid+=E-l):(f.bi_buf|=N<<f.bi_valid&65535,f.bi_valid+=E)},oe=(f,N,E)=>{ie(f,E[N*2],E[N*2+1])},xe=(f,N)=>{let E=0;do E|=f&1,f>>>=1,E<<=1;while(--N>0);return E>>>1},_e=f=>{f.bi_valid===16?(le(f,f.bi_buf),f.bi_buf=0,f.bi_valid=0):f.bi_valid>=8&&(f.pending_buf[f.pending++]=f.bi_buf&255,f.bi_buf>>=8,f.bi_valid-=8)},Oe=(f,N)=>{const E=N.dyn_tree,X=N.max_code,q=N.stat_desc.static_tree,Q=N.stat_desc.has_stree,Ee=N.stat_desc.extra_bits,ue=N.stat_desc.extra_base,Xe=N.stat_desc.max_length;let de,Ae,ct,Ze,Ue,Qe,Et=0;for(Ze=0;Ze<=o;Ze++)f.bl_count[Ze]=0;for(E[f.heap[f.heap_max]*2+1]=0,de=f.heap_max+1;de<s;de++)Ae=f.heap[de],Ze=E[E[Ae*2+1]*2+1]+1,Ze>Xe&&(Ze=Xe,Et++),E[Ae*2+1]=Ze,!(Ae>X)&&(f.bl_count[Ze]++,Ue=0,Ae>=ue&&(Ue=Ee[Ae-ue]),Qe=E[Ae*2],f.opt_len+=Qe*(Ze+Ue),Q&&(f.static_len+=Qe*(q[Ae*2+1]+Ue)));if(Et!==0){do{for(Ze=Xe-1;f.bl_count[Ze]===0;)Ze--;f.bl_count[Ze]--,f.bl_count[Ze+1]+=2,f.bl_count[Xe]--,Et-=2}while(Et>0);for(Ze=Xe;Ze!==0;Ze--)for(Ae=f.bl_count[Ze];Ae!==0;)ct=f.heap[--de],!(ct>X)&&(E[ct*2+1]!==Ze&&(f.opt_len+=(Ze-E[ct*2+1])*E[ct*2],E[ct*2+1]=Ze),Ae--)}},ye=(f,N,E)=>{const X=new Array(o+1);let q=0,Q,Ee;for(Q=1;Q<=o;Q++)q=q+E[Q-1]<<1,X[Q]=q;for(Ee=0;Ee<=N;Ee++){let ue=f[Ee*2+1];ue!==0&&(f[Ee*2]=xe(X[ue]++,ue))}},ee=()=>{let f,N,E,X,q;const Q=new Array(o+1);for(E=0,X=0;X<p-1;X++)for(W[X]=E,f=0;f<1<<u[X];f++)B[E++]=X;for(B[E-1]=X,q=0,X=0;X<16;X++)for(U[X]=q,f=0;f<1<<A[X];f++)F[q++]=X;for(q>>=7;X<e;X++)for(U[X]=q<<7,f=0;f<1<<A[X]-7;f++)F[256+q++]=X;for(N=0;N<=o;N++)Q[N]=0;for(f=0;f<=143;)P[f*2+1]=8,f++,Q[8]++;for(;f<=255;)P[f*2+1]=9,f++,Q[9]++;for(;f<=279;)P[f*2+1]=7,f++,Q[7]++;for(;f<=287;)P[f*2+1]=8,f++,Q[8]++;for(ye(P,r+1,Q),f=0;f<e;f++)z[f*2+1]=5,z[f*2]=xe(f,5);G=new I(P,u,m+1,r,o),Y=new I(z,A,0,e,o),J=new I(new Array(0),D,0,t,d)},pe=f=>{let N;for(N=0;N<r;N++)f.dyn_ltree[N*2]=0;for(N=0;N<e;N++)f.dyn_dtree[N*2]=0;for(N=0;N<t;N++)f.bl_tree[N*2]=0;f.dyn_ltree[i*2]=1,f.opt_len=f.static_len=0,f.sym_next=f.matches=0},Ce=f=>{f.bi_valid>8?le(f,f.bi_buf):f.bi_valid>0&&(f.pending_buf[f.pending++]=f.bi_buf),f.bi_buf=0,f.bi_valid=0},Te=(f,N,E,X)=>{const q=N*2,Q=E*2;return f[q]<f[Q]||f[q]===f[Q]&&X[N]<=X[E]},We=(f,N,E)=>{const X=f.heap[E];let q=E<<1;for(;q<=f.heap_len&&(q<f.heap_len&&Te(N,f.heap[q+1],f.heap[q],f.depth)&&q++,!Te(N,X,f.heap[q],f.depth));)f.heap[E]=f.heap[q],E=q,q<<=1;f.heap[E]=X},Ie=(f,N,E)=>{let X,q,Q=0,Ee,ue;if(f.sym_next!==0)do X=f.pending_buf[f.sym_buf+Q++]&255,X+=(f.pending_buf[f.sym_buf+Q++]&255)<<8,q=f.pending_buf[f.sym_buf+Q++],X===0?oe(f,q,N):(Ee=B[q],oe(f,Ee+m+1,N),ue=u[Ee],ue!==0&&(q-=W[Ee],ie(f,q,ue)),X--,Ee=ne(X),oe(f,Ee,E),ue=A[Ee],ue!==0&&(X-=U[Ee],ie(f,X,ue)));while(Q<f.sym_next);oe(f,i,N)},Be=(f,N)=>{const E=N.dyn_tree,X=N.stat_desc.static_tree,q=N.stat_desc.has_stree,Q=N.stat_desc.elems;let Ee,ue,Xe=-1,de;for(f.heap_len=0,f.heap_max=s,Ee=0;Ee<Q;Ee++)E[Ee*2]!==0?(f.heap[++f.heap_len]=Xe=Ee,f.depth[Ee]=0):E[Ee*2+1]=0;for(;f.heap_len<2;)de=f.heap[++f.heap_len]=Xe<2?++Xe:0,E[de*2]=1,f.depth[de]=0,f.opt_len--,q&&(f.static_len-=X[de*2+1]);for(N.max_code=Xe,Ee=f.heap_len>>1;Ee>=1;Ee--)We(f,E,Ee);de=Q;do Ee=f.heap[1],f.heap[1]=f.heap[f.heap_len--],We(f,E,1),ue=f.heap[1],f.heap[--f.heap_max]=Ee,f.heap[--f.heap_max]=ue,E[de*2]=E[Ee*2]+E[ue*2],f.depth[de]=(f.depth[Ee]>=f.depth[ue]?f.depth[Ee]:f.depth[ue])+1,E[Ee*2+1]=E[ue*2+1]=de,f.heap[1]=de++,We(f,E,1);while(f.heap_len>=2);f.heap[--f.heap_max]=f.heap[1],Oe(f,N),ye(E,Xe,f.bl_count)},Fe=(f,N,E)=>{let X,q=-1,Q,Ee=N[1],ue=0,Xe=7,de=4;for(Ee===0&&(Xe=138,de=3),N[(E+1)*2+1]=65535,X=0;X<=E;X++)Q=Ee,Ee=N[(X+1)*2+1],!(++ue<Xe&&Q===Ee)&&(ue<de?f.bl_tree[Q*2]+=ue:Q!==0?(Q!==q&&f.bl_tree[Q*2]++,f.bl_tree[n*2]++):ue<=10?f.bl_tree[a*2]++:f.bl_tree[h*2]++,ue=0,q=Q,Ee===0?(Xe=138,de=3):Q===Ee?(Xe=6,de=3):(Xe=7,de=4))},ze=(f,N,E)=>{let X,q=-1,Q,Ee=N[1],ue=0,Xe=7,de=4;for(Ee===0&&(Xe=138,de=3),X=0;X<=E;X++)if(Q=Ee,Ee=N[(X+1)*2+1],!(++ue<Xe&&Q===Ee)){if(ue<de)do oe(f,Q,f.bl_tree);while(--ue!==0);else Q!==0?(Q!==q&&(oe(f,Q,f.bl_tree),ue--),oe(f,n,f.bl_tree),ie(f,ue-3,2)):ue<=10?(oe(f,a,f.bl_tree),ie(f,ue-3,3)):(oe(f,h,f.bl_tree),ie(f,ue-11,7));ue=0,q=Q,Ee===0?(Xe=138,de=3):Q===Ee?(Xe=6,de=3):(Xe=7,de=4)}},Pe=f=>{let N;for(Fe(f,f.dyn_ltree,f.l_desc.max_code),Fe(f,f.dyn_dtree,f.d_desc.max_code),Be(f,f.bl_desc),N=t-1;N>=3&&f.bl_tree[T[N]*2+1]===0;N--);return f.opt_len+=3*(N+1)+5+5+4,N},Re=(f,N,E,X)=>{let q;for(ie(f,N-257,5),ie(f,E-1,5),ie(f,X-4,4),q=0;q<X;q++)ie(f,f.bl_tree[T[q]*2+1],3);ze(f,f.dyn_ltree,N-1),ze(f,f.dyn_dtree,E-1)},je=f=>{let N=4093624447,E;for(E=0;E<=31;E++,N>>>=1)if(N&1&&f.dyn_ltree[E*2]!==0)return O;if(f.dyn_ltree[18]!==0||f.dyn_ltree[20]!==0||f.dyn_ltree[26]!==0)return C;for(E=32;E<m;E++)if(f.dyn_ltree[E*2]!==0)return C;return O};let ke=!1;const K=f=>{ke||(ee(),ke=!0),f.l_desc=new te(f.dyn_ltree,G),f.d_desc=new te(f.dyn_dtree,Y),f.bl_desc=new te(f.bl_tree,J),f.bi_buf=0,f.bi_valid=0,pe(f)},Z=(f,N,E,X)=>{ie(f,(y<<1)+(X?1:0),3),Ce(f),le(f,E),le(f,~E),E&&f.pending_buf.set(f.window.subarray(N,N+E),f.pending),f.pending+=E},$=f=>{ie(f,M<<1,3),oe(f,i,P),_e(f)},me=(f,N,E,X)=>{let q,Q,Ee=0;f.level>0?(f.strm.data_type===R&&(f.strm.data_type=je(f)),Be(f,f.l_desc),Be(f,f.d_desc),Ee=Pe(f),q=f.opt_len+3+7>>>3,Q=f.static_len+3+7>>>3,Q<=q&&(q=Q)):q=Q=E+5,E+4<=q&&N!==-1?Z(f,N,E,X):f.strategy===b||Q===q?(ie(f,(M<<1)+(X?1:0),3),Ie(f,P,z)):(ie(f,(g<<1)+(X?1:0),3),Re(f,f.l_desc.max_code+1,f.d_desc.max_code+1,Ee+1),Ie(f,f.dyn_ltree,f.dyn_dtree)),pe(f),X&&Ce(f)},ce=(f,N,E)=>(f.pending_buf[f.sym_buf+f.sym_next++]=N,f.pending_buf[f.sym_buf+f.sym_next++]=N>>8,f.pending_buf[f.sym_buf+f.sym_next++]=E,N===0?f.dyn_ltree[E*2]++:(f.matches++,N--,f.dyn_ltree[(B[E]+m+1)*2]++,f.dyn_dtree[ne(N)*2]++),f.sym_next===f.sym_end);var Me=K,we=Z,j=me,se=ce,ge=$,Se={_tr_init:Me,_tr_stored_block:we,_tr_flush_block:j,_tr_tally:se,_tr_align:ge},be=(f,N,E,X)=>{let q=f&65535|0,Q=f>>>16&65535|0,Ee=0;for(;E!==0;){Ee=E>2e3?2e3:E,E-=Ee;do q=q+N[X++]|0,Q=Q+q|0;while(--Ee);q%=65521,Q%=65521}return q|Q<<16|0};const V=()=>{let f,N=[];for(var E=0;E<256;E++){f=E;for(var X=0;X<8;X++)f=f&1?3988292384^f>>>1:f>>>1;N[E]=f}return N},De=new Uint32Array(V());var L=(f,N,E,X)=>{const q=De,Q=X+E;f^=-1;for(let Ee=X;Ee<Q;Ee++)f=f>>>8^q[(f^N[Ee])&255];return f^-1},he={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"},fe={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:H,_tr_stored_block:ae,_tr_flush_block:ve,_tr_tally:Ve,_tr_align:Ne}=Se,{Z_NO_FLUSH:Ge,Z_PARTIAL_FLUSH:qe,Z_FULL_FLUSH:_t,Z_FINISH:Ye,Z_BLOCK:He,Z_OK:$e,Z_STREAM_END:tt,Z_STREAM_ERROR:et,Z_DATA_ERROR:bt,Z_BUF_ERROR:xt,Z_DEFAULT_COMPRESSION:st,Z_FILTERED:lt,Z_HUFFMAN_ONLY:dt,Z_RLE:vt,Z_FIXED:Mt,Z_DEFAULT_STRATEGY:At,Z_UNKNOWN:Lt,Z_DEFLATED:Ct}=fe,Tt=9,It=15,Bt=8,mi=256+1+29,ri=30,$r=19,Qr=2*mi+1,Jr=15,at=3,Vt=258,zt=Vt+at+1,qr=32,Qt=42,Ci=57,Li=69,Di=73,Ti=91,Si=103,Ht=113,ni=666,Dt=1,Jt=2,Kt=3,qt=4,en=3,Zt=(f,N)=>(f.msg=he[N],N),ji=f=>f*2-(f>4?9:0),jt=f=>{let N=f.length;for(;--N>=0;)f[N]=0},tn=f=>{let N,E,X,q=f.w_size;N=f.hash_size,X=N;do E=f.head[--X],f.head[X]=E>=q?E-q:0;while(--N);N=q,X=N;do E=f.prev[--X],f.prev[X]=E>=q?E-q:0;while(--N)};let kt=(f,N,E)=>(N<<f.hash_shift^E)&f.hash_mask;const St=f=>{const N=f.state;let E=N.pending;E>f.avail_out&&(E=f.avail_out),E!==0&&(f.output.set(N.pending_buf.subarray(N.pending_out,N.pending_out+E),f.next_out),f.next_out+=E,N.pending_out+=E,f.total_out+=E,f.avail_out-=E,N.pending-=E,N.pending===0&&(N.pending_out=0))},Ot=(f,N)=>{ve(f,f.block_start>=0?f.block_start:-1,f.strstart-f.block_start,N),f.block_start=f.strstart,St(f.strm)},ut=(f,N)=>{f.pending_buf[f.pending++]=N},si=(f,N)=>{f.pending_buf[f.pending++]=N>>>8&255,f.pending_buf[f.pending++]=N&255},Oi=(f,N,E,X)=>{let q=f.avail_in;return q>X&&(q=X),q===0?0:(f.avail_in-=q,N.set(f.input.subarray(f.next_in,f.next_in+q),E),f.state.wrap===1?f.adler=be(f.adler,N,q,E):f.state.wrap===2&&(f.adler=L(f.adler,N,q,E)),f.next_in+=q,f.total_in+=q,q)},ki=(f,N)=>{let E=f.max_chain_length,X=f.strstart,q,Q,Ee=f.prev_length,ue=f.nice_match;const Xe=f.strstart>f.w_size-zt?f.strstart-(f.w_size-zt):0,de=f.window,Ae=f.w_mask,ct=f.prev,Ze=f.strstart+Vt;let Ue=de[X+Ee-1],Qe=de[X+Ee];f.prev_length>=f.good_match&&(E>>=2),ue>f.lookahead&&(ue=f.lookahead);do if(q=N,!(de[q+Ee]!==Qe||de[q+Ee-1]!==Ue||de[q]!==de[X]||de[++q]!==de[X+1])){X+=2,q++;do;while(de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&de[++X]===de[++q]&&X<Ze);if(Q=Vt-(Ze-X),X=Ze-Vt,Q>Ee){if(f.match_start=N,Ee=Q,Q>=ue)break;Ue=de[X+Ee-1],Qe=de[X+Ee]}}while((N=ct[N&Ae])>Xe&&--E!==0);return Ee<=f.lookahead?Ee:f.lookahead},ei=f=>{const N=f.w_size;let E,X,q;do{if(X=f.window_size-f.lookahead-f.strstart,f.strstart>=N+(N-zt)&&(f.window.set(f.window.subarray(N,N+N-X),0),f.match_start-=N,f.strstart-=N,f.block_start-=N,f.insert>f.strstart&&(f.insert=f.strstart),tn(f),X+=N),f.strm.avail_in===0)break;if(E=Oi(f.strm,f.window,f.strstart+f.lookahead,X),f.lookahead+=E,f.lookahead+f.insert>=at)for(q=f.strstart-f.insert,f.ins_h=f.window[q],f.ins_h=kt(f,f.ins_h,f.window[q+1]);f.insert&&(f.ins_h=kt(f,f.ins_h,f.window[q+at-1]),f.prev[q&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=q,q++,f.insert--,!(f.lookahead+f.insert<at)););}while(f.lookahead<zt&&f.strm.avail_in!==0)},Hi=(f,N)=>{let E=f.pending_buf_size-5>f.w_size?f.w_size:f.pending_buf_size-5,X,q,Q,Ee=0,ue=f.strm.avail_in;do{if(X=65535,Q=f.bi_valid+42>>3,f.strm.avail_out<Q||(Q=f.strm.avail_out-Q,q=f.strstart-f.block_start,X>q+f.strm.avail_in&&(X=q+f.strm.avail_in),X>Q&&(X=Q),X<E&&(X===0&&N!==Ye||N===Ge||X!==q+f.strm.avail_in)))break;Ee=N===Ye&&X===q+f.strm.avail_in?1:0,ae(f,0,0,Ee),f.pending_buf[f.pending-4]=X,f.pending_buf[f.pending-3]=X>>8,f.pending_buf[f.pending-2]=~X,f.pending_buf[f.pending-1]=~X>>8,St(f.strm),q&&(q>X&&(q=X),f.strm.output.set(f.window.subarray(f.block_start,f.block_start+q),f.strm.next_out),f.strm.next_out+=q,f.strm.avail_out-=q,f.strm.total_out+=q,f.block_start+=q,X-=q),X&&(Oi(f.strm,f.strm.output,f.strm.next_out,X),f.strm.next_out+=X,f.strm.avail_out-=X,f.strm.total_out+=X)}while(Ee===0);return ue-=f.strm.avail_in,ue&&(ue>=f.w_size?(f.matches=2,f.window.set(f.strm.input.subarray(f.strm.next_in-f.w_size,f.strm.next_in),0),f.strstart=f.w_size,f.insert=f.strstart):(f.window_size-f.strstart<=ue&&(f.strstart-=f.w_size,f.window.set(f.window.subarray(f.w_size,f.w_size+f.strstart),0),f.matches<2&&f.matches++,f.insert>f.strstart&&(f.insert=f.strstart)),f.window.set(f.strm.input.subarray(f.strm.next_in-ue,f.strm.next_in),f.strstart),f.strstart+=ue,f.insert+=ue>f.w_size-f.insert?f.w_size-f.insert:ue),f.block_start=f.strstart),f.high_water<f.strstart&&(f.high_water=f.strstart),Ee?qt:N!==Ge&&N!==Ye&&f.strm.avail_in===0&&f.strstart===f.block_start?Jt:(Q=f.window_size-f.strstart,f.strm.avail_in>Q&&f.block_start>=f.w_size&&(f.block_start-=f.w_size,f.strstart-=f.w_size,f.window.set(f.window.subarray(f.w_size,f.w_size+f.strstart),0),f.matches<2&&f.matches++,Q+=f.w_size,f.insert>f.strstart&&(f.insert=f.strstart)),Q>f.strm.avail_in&&(Q=f.strm.avail_in),Q&&(Oi(f.strm,f.window,f.strstart,Q),f.strstart+=Q,f.insert+=Q>f.w_size-f.insert?f.w_size-f.insert:Q),f.high_water<f.strstart&&(f.high_water=f.strstart),Q=f.bi_valid+42>>3,Q=f.pending_buf_size-Q>65535?65535:f.pending_buf_size-Q,E=Q>f.w_size?f.w_size:Q,q=f.strstart-f.block_start,(q>=E||(q||N===Ye)&&N!==Ge&&f.strm.avail_in===0&&q<=Q)&&(X=q>Q?Q:q,Ee=N===Ye&&f.strm.avail_in===0&&X===q?1:0,ae(f,f.block_start,X,Ee),f.block_start+=X,St(f.strm)),Ee?Kt:Dt)},Ri=(f,N)=>{let E,X;for(;;){if(f.lookahead<zt){if(ei(f),f.lookahead<zt&&N===Ge)return Dt;if(f.lookahead===0)break}if(E=0,f.lookahead>=at&&(f.ins_h=kt(f,f.ins_h,f.window[f.strstart+at-1]),E=f.prev[f.strstart&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=f.strstart),E!==0&&f.strstart-E<=f.w_size-zt&&(f.match_length=ki(f,E)),f.match_length>=at)if(X=Ve(f,f.strstart-f.match_start,f.match_length-at),f.lookahead-=f.match_length,f.match_length<=f.max_lazy_match&&f.lookahead>=at){f.match_length--;do f.strstart++,f.ins_h=kt(f,f.ins_h,f.window[f.strstart+at-1]),E=f.prev[f.strstart&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=f.strstart;while(--f.match_length!==0);f.strstart++}else f.strstart+=f.match_length,f.match_length=0,f.ins_h=f.window[f.strstart],f.ins_h=kt(f,f.ins_h,f.window[f.strstart+1]);else X=Ve(f,0,f.window[f.strstart]),f.lookahead--,f.strstart++;if(X&&(Ot(f,!1),f.strm.avail_out===0))return Dt}return f.insert=f.strstart<at-1?f.strstart:at-1,N===Ye?(Ot(f,!0),f.strm.avail_out===0?Kt:qt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Dt:Jt},ti=(f,N)=>{let E,X,q;for(;;){if(f.lookahead<zt){if(ei(f),f.lookahead<zt&&N===Ge)return Dt;if(f.lookahead===0)break}if(E=0,f.lookahead>=at&&(f.ins_h=kt(f,f.ins_h,f.window[f.strstart+at-1]),E=f.prev[f.strstart&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=f.strstart),f.prev_length=f.match_length,f.prev_match=f.match_start,f.match_length=at-1,E!==0&&f.prev_length<f.max_lazy_match&&f.strstart-E<=f.w_size-zt&&(f.match_length=ki(f,E),f.match_length<=5&&(f.strategy===lt||f.match_length===at&&f.strstart-f.match_start>4096)&&(f.match_length=at-1)),f.prev_length>=at&&f.match_length<=f.prev_length){q=f.strstart+f.lookahead-at,X=Ve(f,f.strstart-1-f.prev_match,f.prev_length-at),f.lookahead-=f.prev_length-1,f.prev_length-=2;do++f.strstart<=q&&(f.ins_h=kt(f,f.ins_h,f.window[f.strstart+at-1]),E=f.prev[f.strstart&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=f.strstart);while(--f.prev_length!==0);if(f.match_available=0,f.match_length=at-1,f.strstart++,X&&(Ot(f,!1),f.strm.avail_out===0))return Dt}else if(f.match_available){if(X=Ve(f,0,f.window[f.strstart-1]),X&&Ot(f,!1),f.strstart++,f.lookahead--,f.strm.avail_out===0)return Dt}else f.match_available=1,f.strstart++,f.lookahead--}return f.match_available&&(X=Ve(f,0,f.window[f.strstart-1]),f.match_available=0),f.insert=f.strstart<at-1?f.strstart:at-1,N===Ye?(Ot(f,!0),f.strm.avail_out===0?Kt:qt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Dt:Jt},rn=(f,N)=>{let E,X,q,Q;const Ee=f.window;for(;;){if(f.lookahead<=Vt){if(ei(f),f.lookahead<=Vt&&N===Ge)return Dt;if(f.lookahead===0)break}if(f.match_length=0,f.lookahead>=at&&f.strstart>0&&(q=f.strstart-1,X=Ee[q],X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q])){Q=f.strstart+Vt;do;while(X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&X===Ee[++q]&&q<Q);f.match_length=Vt-(Q-q),f.match_length>f.lookahead&&(f.match_length=f.lookahead)}if(f.match_length>=at?(E=Ve(f,1,f.match_length-at),f.lookahead-=f.match_length,f.strstart+=f.match_length,f.match_length=0):(E=Ve(f,0,f.window[f.strstart]),f.lookahead--,f.strstart++),E&&(Ot(f,!1),f.strm.avail_out===0))return Dt}return f.insert=0,N===Ye?(Ot(f,!0),f.strm.avail_out===0?Kt:qt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Dt:Jt},nn=(f,N)=>{let E;for(;;){if(f.lookahead===0&&(ei(f),f.lookahead===0)){if(N===Ge)return Dt;break}if(f.match_length=0,E=Ve(f,0,f.window[f.strstart]),f.lookahead--,f.strstart++,E&&(Ot(f,!1),f.strm.avail_out===0))return Dt}return f.insert=0,N===Ye?(Ot(f,!0),f.strm.avail_out===0?Kt:qt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Dt:Jt};function Ft(f,N,E,X,q){this.good_length=f,this.max_lazy=N,this.nice_length=E,this.max_chain=X,this.func=q}const ai=[new Ft(0,0,0,0,Hi),new Ft(4,4,8,4,Ri),new Ft(4,5,16,8,Ri),new Ft(4,6,32,32,Ri),new Ft(4,4,16,16,ti),new Ft(8,16,32,32,ti),new Ft(8,16,128,128,ti),new Ft(8,32,128,256,ti),new Ft(32,128,258,1024,ti),new Ft(32,258,258,4096,ti)],sn=f=>{f.window_size=2*f.w_size,jt(f.head),f.max_lazy_match=ai[f.level].max_lazy,f.good_match=ai[f.level].good_length,f.nice_match=ai[f.level].nice_length,f.max_chain_length=ai[f.level].max_chain,f.strstart=0,f.block_start=0,f.lookahead=0,f.insert=0,f.match_length=f.prev_length=at-1,f.match_available=0,f.ins_h=0};function an(){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=Ct,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(Qr*2),this.dyn_dtree=new Uint16Array((2*ri+1)*2),this.bl_tree=new Uint16Array((2*$r+1)*2),jt(this.dyn_ltree),jt(this.dyn_dtree),jt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Jr+1),this.heap=new Uint16Array(2*mi+1),jt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*mi+1),jt(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 oi=f=>{if(!f)return 1;const N=f.state;return!N||N.strm!==f||N.status!==Qt&&N.status!==Ci&&N.status!==Li&&N.status!==Di&&N.status!==Ti&&N.status!==Si&&N.status!==Ht&&N.status!==ni?1:0},Ki=f=>{if(oi(f))return Zt(f,et);f.total_in=f.total_out=0,f.data_type=Lt;const N=f.state;return N.pending=0,N.pending_out=0,N.wrap<0&&(N.wrap=-N.wrap),N.status=N.wrap===2?Ci:N.wrap?Qt:Ht,f.adler=N.wrap===2?0:1,N.last_flush=-2,H(N),$e},Zi=f=>{const N=Ki(f);return N===$e&&sn(f.state),N},on=(f,N)=>oi(f)||f.state.wrap!==2?et:(f.state.gzhead=N,$e),Xi=(f,N,E,X,q,Q)=>{if(!f)return et;let Ee=1;if(N===st&&(N=6),X<0?(Ee=0,X=-X):X>15&&(Ee=2,X-=16),q<1||q>Tt||E!==Ct||X<8||X>15||N<0||N>9||Q<0||Q>Mt||X===8&&Ee!==1)return Zt(f,et);X===8&&(X=9);const ue=new an;return f.state=ue,ue.strm=f,ue.status=Qt,ue.wrap=Ee,ue.gzhead=null,ue.w_bits=X,ue.w_size=1<<ue.w_bits,ue.w_mask=ue.w_size-1,ue.hash_bits=q+7,ue.hash_size=1<<ue.hash_bits,ue.hash_mask=ue.hash_size-1,ue.hash_shift=~~((ue.hash_bits+at-1)/at),ue.window=new Uint8Array(ue.w_size*2),ue.head=new Uint16Array(ue.hash_size),ue.prev=new Uint16Array(ue.w_size),ue.lit_bufsize=1<<q+6,ue.pending_buf_size=ue.lit_bufsize*4,ue.pending_buf=new Uint8Array(ue.pending_buf_size),ue.sym_buf=ue.lit_bufsize,ue.sym_end=(ue.lit_bufsize-1)*3,ue.level=N,ue.strategy=Q,ue.method=E,Zi(f)},ln=(f,N)=>Xi(f,N,Ct,It,Bt,At),hn=(f,N)=>{if(oi(f)||N>He||N<0)return f?Zt(f,et):et;const E=f.state;if(!f.output||f.avail_in!==0&&!f.input||E.status===ni&&N!==Ye)return Zt(f,f.avail_out===0?xt:et);const X=E.last_flush;if(E.last_flush=N,E.pending!==0){if(St(f),f.avail_out===0)return E.last_flush=-1,$e}else if(f.avail_in===0&&ji(N)<=ji(X)&&N!==Ye)return Zt(f,xt);if(E.status===ni&&f.avail_in!==0)return Zt(f,xt);if(E.status===Qt&&E.wrap===0&&(E.status=Ht),E.status===Qt){let q=Ct+(E.w_bits-8<<4)<<8,Q=-1;if(E.strategy>=dt||E.level<2?Q=0:E.level<6?Q=1:E.level===6?Q=2:Q=3,q|=Q<<6,E.strstart!==0&&(q|=qr),q+=31-q%31,si(E,q),E.strstart!==0&&(si(E,f.adler>>>16),si(E,f.adler&65535)),f.adler=1,E.status=Ht,St(f),E.pending!==0)return E.last_flush=-1,$e}if(E.status===Ci){if(f.adler=0,ut(E,31),ut(E,139),ut(E,8),E.gzhead)ut(E,(E.gzhead.text?1:0)+(E.gzhead.hcrc?2:0)+(E.gzhead.extra?4:0)+(E.gzhead.name?8:0)+(E.gzhead.comment?16:0)),ut(E,E.gzhead.time&255),ut(E,E.gzhead.time>>8&255),ut(E,E.gzhead.time>>16&255),ut(E,E.gzhead.time>>24&255),ut(E,E.level===9?2:E.strategy>=dt||E.level<2?4:0),ut(E,E.gzhead.os&255),E.gzhead.extra&&E.gzhead.extra.length&&(ut(E,E.gzhead.extra.length&255),ut(E,E.gzhead.extra.length>>8&255)),E.gzhead.hcrc&&(f.adler=L(f.adler,E.pending_buf,E.pending,0)),E.gzindex=0,E.status=Li;else if(ut(E,0),ut(E,0),ut(E,0),ut(E,0),ut(E,0),ut(E,E.level===9?2:E.strategy>=dt||E.level<2?4:0),ut(E,en),E.status=Ht,St(f),E.pending!==0)return E.last_flush=-1,$e}if(E.status===Li){if(E.gzhead.extra){let q=E.pending,Q=(E.gzhead.extra.length&65535)-E.gzindex;for(;E.pending+Q>E.pending_buf_size;){let ue=E.pending_buf_size-E.pending;if(E.pending_buf.set(E.gzhead.extra.subarray(E.gzindex,E.gzindex+ue),E.pending),E.pending=E.pending_buf_size,E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q)),E.gzindex+=ue,St(f),E.pending!==0)return E.last_flush=-1,$e;q=0,Q-=ue}let Ee=new Uint8Array(E.gzhead.extra);E.pending_buf.set(Ee.subarray(E.gzindex,E.gzindex+Q),E.pending),E.pending+=Q,E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q)),E.gzindex=0}E.status=Di}if(E.status===Di){if(E.gzhead.name){let q=E.pending,Q;do{if(E.pending===E.pending_buf_size){if(E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q)),St(f),E.pending!==0)return E.last_flush=-1,$e;q=0}E.gzindex<E.gzhead.name.length?Q=E.gzhead.name.charCodeAt(E.gzindex++)&255:Q=0,ut(E,Q)}while(Q!==0);E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q)),E.gzindex=0}E.status=Ti}if(E.status===Ti){if(E.gzhead.comment){let q=E.pending,Q;do{if(E.pending===E.pending_buf_size){if(E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q)),St(f),E.pending!==0)return E.last_flush=-1,$e;q=0}E.gzindex<E.gzhead.comment.length?Q=E.gzhead.comment.charCodeAt(E.gzindex++)&255:Q=0,ut(E,Q)}while(Q!==0);E.gzhead.hcrc&&E.pending>q&&(f.adler=L(f.adler,E.pending_buf,E.pending-q,q))}E.status=Si}if(E.status===Si){if(E.gzhead.hcrc){if(E.pending+2>E.pending_buf_size&&(St(f),E.pending!==0))return E.last_flush=-1,$e;ut(E,f.adler&255),ut(E,f.adler>>8&255),f.adler=0}if(E.status=Ht,St(f),E.pending!==0)return E.last_flush=-1,$e}if(f.avail_in!==0||E.lookahead!==0||N!==Ge&&E.status!==ni){let q=E.level===0?Hi(E,N):E.strategy===dt?nn(E,N):E.strategy===vt?rn(E,N):ai[E.level].func(E,N);if((q===Kt||q===qt)&&(E.status=ni),q===Dt||q===Kt)return f.avail_out===0&&(E.last_flush=-1),$e;if(q===Jt&&(N===qe?Ne(E):N!==He&&(ae(E,0,0,!1),N===_t&&(jt(E.head),E.lookahead===0&&(E.strstart=0,E.block_start=0,E.insert=0))),St(f),f.avail_out===0))return E.last_flush=-1,$e}return N!==Ye?$e:E.wrap<=0?tt:(E.wrap===2?(ut(E,f.adler&255),ut(E,f.adler>>8&255),ut(E,f.adler>>16&255),ut(E,f.adler>>24&255),ut(E,f.total_in&255),ut(E,f.total_in>>8&255),ut(E,f.total_in>>16&255),ut(E,f.total_in>>24&255)):(si(E,f.adler>>>16),si(E,f.adler&65535)),St(f),E.wrap>0&&(E.wrap=-E.wrap),E.pending!==0?$e:tt)},fn=f=>{if(oi(f))return et;const N=f.state.status;return f.state=null,N===Ht?Zt(f,bt):$e},dn=(f,N)=>{let E=N.length;if(oi(f))return et;const X=f.state,q=X.wrap;if(q===2||q===1&&X.status!==Qt||X.lookahead)return et;if(q===1&&(f.adler=be(f.adler,N,E,0)),X.wrap=0,E>=X.w_size){q===0&&(jt(X.head),X.strstart=0,X.block_start=0,X.insert=0);let Xe=new Uint8Array(X.w_size);Xe.set(N.subarray(E-X.w_size,E),0),N=Xe,E=X.w_size}const Q=f.avail_in,Ee=f.next_in,ue=f.input;for(f.avail_in=E,f.next_in=0,f.input=N,ei(X);X.lookahead>=at;){let Xe=X.strstart,de=X.lookahead-(at-1);do X.ins_h=kt(X,X.ins_h,X.window[Xe+at-1]),X.prev[Xe&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=Xe,Xe++;while(--de);X.strstart=Xe,X.lookahead=at-1,ei(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=at-1,X.match_available=0,f.next_in=Ee,f.input=ue,f.avail_in=Q,X.wrap=q,$e};var cn=ln,un=Xi,gn=Zi,mn=Ki,pn=on,vn=hn,_n=fn,xn=dn,bn="pako deflate (from Nodeca project)",li={deflateInit:cn,deflateInit2:un,deflateReset:gn,deflateResetKeep:mn,deflateSetHeader:pn,deflate:vn,deflateEnd:_n,deflateSetDictionary:xn,deflateInfo:bn};const yn=(f,N)=>Object.prototype.hasOwnProperty.call(f,N);var En=function(f){const N=Array.prototype.slice.call(arguments,1);for(;N.length;){const E=N.shift();if(E){if(typeof E!="object")throw new TypeError(E+"must be non-object");for(const X in E)yn(E,X)&&(f[X]=E[X])}}return f},An=f=>{let N=0;for(let X=0,q=f.length;X<q;X++)N+=f[X].length;const E=new Uint8Array(N);for(let X=0,q=0,Q=f.length;X<Q;X++){let Ee=f[X];E.set(Ee,q),q+=Ee.length}return E},pi={assign:En,flattenChunks:An};let Yi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Yi=!1}const hi=new Uint8Array(256);for(let f=0;f<256;f++)hi[f]=f>=252?6:f>=248?5:f>=240?4:f>=224?3:f>=192?2:1;hi[254]=hi[254]=1;var Mn=f=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(f);let N,E,X,q,Q,Ee=f.length,ue=0;for(q=0;q<Ee;q++)E=f.charCodeAt(q),(E&64512)===55296&&q+1<Ee&&(X=f.charCodeAt(q+1),(X&64512)===56320&&(E=65536+(E-55296<<10)+(X-56320),q++)),ue+=E<128?1:E<2048?2:E<65536?3:4;for(N=new Uint8Array(ue),Q=0,q=0;Q<ue;q++)E=f.charCodeAt(q),(E&64512)===55296&&q+1<Ee&&(X=f.charCodeAt(q+1),(X&64512)===56320&&(E=65536+(E-55296<<10)+(X-56320),q++)),E<128?N[Q++]=E:E<2048?(N[Q++]=192|E>>>6,N[Q++]=128|E&63):E<65536?(N[Q++]=224|E>>>12,N[Q++]=128|E>>>6&63,N[Q++]=128|E&63):(N[Q++]=240|E>>>18,N[Q++]=128|E>>>12&63,N[Q++]=128|E>>>6&63,N[Q++]=128|E&63);return N};const wn=(f,N)=>{if(N<65534&&f.subarray&&Yi)return String.fromCharCode.apply(null,f.length===N?f:f.subarray(0,N));let E="";for(let X=0;X<N;X++)E+=String.fromCharCode(f[X]);return E};var Cn=(f,N)=>{const E=N||f.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(f.subarray(0,N));let X,q;const Q=new Array(E*2);for(q=0,X=0;X<E;){let Ee=f[X++];if(Ee<128){Q[q++]=Ee;continue}let ue=hi[Ee];if(ue>4){Q[q++]=65533,X+=ue-1;continue}for(Ee&=ue===2?31:ue===3?15:7;ue>1&&X<E;)Ee=Ee<<6|f[X++]&63,ue--;if(ue>1){Q[q++]=65533;continue}Ee<65536?Q[q++]=Ee:(Ee-=65536,Q[q++]=55296|Ee>>10&1023,Q[q++]=56320|Ee&1023)}return wn(Q,q)},Ln=(f,N)=>{N=N||f.length,N>f.length&&(N=f.length);let E=N-1;for(;E>=0&&(f[E]&192)===128;)E--;return E<0||E===0?N:E+hi[f[E]]>N?E:N},fi={string2buf:Mn,buf2string:Cn,utf8border:Ln};function Dn(){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}var $i=Dn;const Qi=Object.prototype.toString,{Z_NO_FLUSH:Tn,Z_SYNC_FLUSH:Sn,Z_FULL_FLUSH:On,Z_FINISH:Rn,Z_OK:vi,Z_STREAM_END:Pn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:zn,Z_DEFLATED:Fn}=fe;function di(f){this.options=pi.assign({level:In,method:Fn,chunkSize:16384,windowBits:15,memLevel:8,strategy:zn},f||{});let N=this.options;N.raw&&N.windowBits>0?N.windowBits=-N.windowBits:N.gzip&&N.windowBits>0&&N.windowBits<16&&(N.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $i,this.strm.avail_out=0;let E=li.deflateInit2(this.strm,N.level,N.method,N.windowBits,N.memLevel,N.strategy);if(E!==vi)throw new Error(he[E]);if(N.header&&li.deflateSetHeader(this.strm,N.header),N.dictionary){let X;if(typeof N.dictionary=="string"?X=fi.string2buf(N.dictionary):Qi.call(N.dictionary)==="[object ArrayBuffer]"?X=new Uint8Array(N.dictionary):X=N.dictionary,E=li.deflateSetDictionary(this.strm,X),E!==vi)throw new Error(he[E]);this._dict_set=!0}}di.prototype.push=function(f,N){const E=this.strm,X=this.options.chunkSize;let q,Q;if(this.ended)return!1;for(N===~~N?Q=N:Q=N===!0?Rn:Tn,typeof f=="string"?E.input=fi.string2buf(f):Qi.call(f)==="[object ArrayBuffer]"?E.input=new Uint8Array(f):E.input=f,E.next_in=0,E.avail_in=E.input.length;;){if(E.avail_out===0&&(E.output=new Uint8Array(X),E.next_out=0,E.avail_out=X),(Q===Sn||Q===On)&&E.avail_out<=6){this.onData(E.output.subarray(0,E.next_out)),E.avail_out=0;continue}if(q=li.deflate(E,Q),q===Pn)return E.next_out>0&&this.onData(E.output.subarray(0,E.next_out)),q=li.deflateEnd(this.strm),this.onEnd(q),this.ended=!0,q===vi;if(E.avail_out===0){this.onData(E.output);continue}if(Q>0&&E.next_out>0){this.onData(E.output.subarray(0,E.next_out)),E.avail_out=0;continue}if(E.avail_in===0)break}return!0},di.prototype.onData=function(f){this.chunks.push(f)},di.prototype.onEnd=function(f){f===vi&&(this.result=pi.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function Pi(f,N){const E=new di(N);if(E.push(f,!0),E.err)throw E.msg||he[E.err];return E.result}function Bn(f,N){return N=N||{},N.raw=!0,Pi(f,N)}function Un(f,N){return N=N||{},N.gzip=!0,Pi(f,N)}var Wn=di,Gn=Pi,Nn=Bn,Vn=Un,jn={Deflate:Wn,deflate:Gn,deflateRaw:Nn,gzip:Vn};const _i=16209,kn=16191;var Hn=function(N,E){let X,q,Q,Ee,ue,Xe,de,Ae,ct,Ze,Ue,Qe,Et,ht,rt,mt,nt,Ke,gt,wt,Je,pt,ft,it;const ot=N.state;X=N.next_in,ft=N.input,q=X+(N.avail_in-5),Q=N.next_out,it=N.output,Ee=Q-(E-N.avail_out),ue=Q+(N.avail_out-257),Xe=ot.dmax,de=ot.wsize,Ae=ot.whave,ct=ot.wnext,Ze=ot.window,Ue=ot.hold,Qe=ot.bits,Et=ot.lencode,ht=ot.distcode,rt=(1<<ot.lenbits)-1,mt=(1<<ot.distbits)-1;e:do{Qe<15&&(Ue+=ft[X++]<<Qe,Qe+=8,Ue+=ft[X++]<<Qe,Qe+=8),nt=Et[Ue&rt];t:for(;;){if(Ke=nt>>>24,Ue>>>=Ke,Qe-=Ke,Ke=nt>>>16&255,Ke===0)it[Q++]=nt&65535;else if(Ke&16){gt=nt&65535,Ke&=15,Ke&&(Qe<Ke&&(Ue+=ft[X++]<<Qe,Qe+=8),gt+=Ue&(1<<Ke)-1,Ue>>>=Ke,Qe-=Ke),Qe<15&&(Ue+=ft[X++]<<Qe,Qe+=8,Ue+=ft[X++]<<Qe,Qe+=8),nt=ht[Ue&mt];i:for(;;){if(Ke=nt>>>24,Ue>>>=Ke,Qe-=Ke,Ke=nt>>>16&255,Ke&16){if(wt=nt&65535,Ke&=15,Qe<Ke&&(Ue+=ft[X++]<<Qe,Qe+=8,Qe<Ke&&(Ue+=ft[X++]<<Qe,Qe+=8)),wt+=Ue&(1<<Ke)-1,wt>Xe){N.msg="invalid distance too far back",ot.mode=_i;break e}if(Ue>>>=Ke,Qe-=Ke,Ke=Q-Ee,wt>Ke){if(Ke=wt-Ke,Ke>Ae&&ot.sane){N.msg="invalid distance too far back",ot.mode=_i;break e}if(Je=0,pt=Ze,ct===0){if(Je+=de-Ke,Ke<gt){gt-=Ke;do it[Q++]=Ze[Je++];while(--Ke);Je=Q-wt,pt=it}}else if(ct<Ke){if(Je+=de+ct-Ke,Ke-=ct,Ke<gt){gt-=Ke;do it[Q++]=Ze[Je++];while(--Ke);if(Je=0,ct<gt){Ke=ct,gt-=Ke;do it[Q++]=Ze[Je++];while(--Ke);Je=Q-wt,pt=it}}}else if(Je+=ct-Ke,Ke<gt){gt-=Ke;do it[Q++]=Ze[Je++];while(--Ke);Je=Q-wt,pt=it}for(;gt>2;)it[Q++]=pt[Je++],it[Q++]=pt[Je++],it[Q++]=pt[Je++],gt-=3;gt&&(it[Q++]=pt[Je++],gt>1&&(it[Q++]=pt[Je++]))}else{Je=Q-wt;do it[Q++]=it[Je++],it[Q++]=it[Je++],it[Q++]=it[Je++],gt-=3;while(gt>2);gt&&(it[Q++]=it[Je++],gt>1&&(it[Q++]=it[Je++]))}}else if((Ke&64)===0){nt=ht[(nt&65535)+(Ue&(1<<Ke)-1)];continue i}else{N.msg="invalid distance code",ot.mode=_i;break e}break}}else if((Ke&64)===0){nt=Et[(nt&65535)+(Ue&(1<<Ke)-1)];continue t}else if(Ke&32){ot.mode=kn;break e}else{N.msg="invalid literal/length code",ot.mode=_i;break e}break}}while(X<q&&Q<ue);gt=Qe>>3,X-=gt,Qe-=gt<<3,Ue&=(1<<Qe)-1,N.next_in=X,N.next_out=Q,N.avail_in=X<q?5+(q-X):5-(X-q),N.avail_out=Q<ue?257+(ue-Q):257-(Q-ue),ot.hold=Ue,ot.bits=Qe};const ii=15,Ji=852,qi=592,er=0,Ii=1,tr=2,Kn=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]),Zn=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]),Xn=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]),Yn=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 ci=(f,N,E,X,q,Q,Ee,ue)=>{const Xe=ue.bits;let de=0,Ae=0,ct=0,Ze=0,Ue=0,Qe=0,Et=0,ht=0,rt=0,mt=0,nt,Ke,gt,wt,Je,pt=null,ft;const it=new Uint16Array(ii+1),ot=new Uint16Array(ii+1);let $t=null,Yr,Mi,wi;for(de=0;de<=ii;de++)it[de]=0;for(Ae=0;Ae<X;Ae++)it[N[E+Ae]]++;for(Ue=Xe,Ze=ii;Ze>=1&&it[Ze]===0;Ze--);if(Ue>Ze&&(Ue=Ze),Ze===0)return q[Q++]=1<<24|64<<16|0,q[Q++]=1<<24|64<<16|0,ue.bits=1,0;for(ct=1;ct<Ze&&it[ct]===0;ct++);for(Ue<ct&&(Ue=ct),ht=1,de=1;de<=ii;de++)if(ht<<=1,ht-=it[de],ht<0)return-1;if(ht>0&&(f===er||Ze!==1))return-1;for(ot[1]=0,de=1;de<ii;de++)ot[de+1]=ot[de]+it[de];for(Ae=0;Ae<X;Ae++)N[E+Ae]!==0&&(Ee[ot[N[E+Ae]]++]=Ae);if(f===er?(pt=$t=Ee,ft=20):f===Ii?(pt=Kn,$t=Zn,ft=257):(pt=Xn,$t=Yn,ft=0),mt=0,Ae=0,de=ct,Je=Q,Qe=Ue,Et=0,gt=-1,rt=1<<Ue,wt=rt-1,f===Ii&&rt>Ji||f===tr&&rt>qi)return 1;for(;;){Yr=de-Et,Ee[Ae]+1<ft?(Mi=0,wi=Ee[Ae]):Ee[Ae]>=ft?(Mi=$t[Ee[Ae]-ft],wi=pt[Ee[Ae]-ft]):(Mi=96,wi=0),nt=1<<de-Et,Ke=1<<Qe,ct=Ke;do Ke-=nt,q[Je+(mt>>Et)+Ke]=Yr<<24|Mi<<16|wi|0;while(Ke!==0);for(nt=1<<de-1;mt&nt;)nt>>=1;if(nt!==0?(mt&=nt-1,mt+=nt):mt=0,Ae++,--it[de]===0){if(de===Ze)break;de=N[E+Ee[Ae]]}if(de>Ue&&(mt&wt)!==gt){for(Et===0&&(Et=Ue),Je+=ct,Qe=de-Et,ht=1<<Qe;Qe+Et<Ze&&(ht-=it[Qe+Et],!(ht<=0));)Qe++,ht<<=1;if(rt+=1<<Qe,f===Ii&&rt>Ji||f===tr&&rt>qi)return 1;gt=mt&wt,q[gt]=Ue<<24|Qe<<16|Je-Q|0}}return mt!==0&&(q[Je+mt]=de-Et<<24|64<<16|0),ue.bits=Ue,0};const $n=0,ir=1,rr=2,{Z_FINISH:nr,Z_BLOCK:Qn,Z_TREES:xi,Z_OK:Xt,Z_STREAM_END:Jn,Z_NEED_DICT:qn,Z_STREAM_ERROR:Rt,Z_DATA_ERROR:sr,Z_MEM_ERROR:ar,Z_BUF_ERROR:es,Z_DEFLATED:or}=fe,bi=16180,lr=16181,hr=16182,fr=16183,dr=16184,cr=16185,ur=16186,gr=16187,mr=16188,pr=16189,yi=16190,Gt=16191,zi=16192,vr=16193,Fi=16194,_r=16195,xr=16196,br=16197,yr=16198,Ei=16199,Ai=16200,Er=16201,Ar=16202,Mr=16203,wr=16204,Cr=16205,Bi=16206,Lr=16207,Dr=16208,yt=16209,Tr=16210,Sr=16211,ts=852,is=592,rs=15,Or=f=>(f>>>24&255)+(f>>>8&65280)+((f&65280)<<8)+((f&255)<<24);function ns(){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 Yt=f=>{if(!f)return 1;const N=f.state;return!N||N.strm!==f||N.mode<bi||N.mode>Sr?1:0},Rr=f=>{if(Yt(f))return Rt;const N=f.state;return f.total_in=f.total_out=N.total=0,f.msg="",N.wrap&&(f.adler=N.wrap&1),N.mode=bi,N.last=0,N.havedict=0,N.flags=-1,N.dmax=32768,N.head=null,N.hold=0,N.bits=0,N.lencode=N.lendyn=new Int32Array(ts),N.distcode=N.distdyn=new Int32Array(is),N.sane=1,N.back=-1,Xt},Pr=f=>{if(Yt(f))return Rt;const N=f.state;return N.wsize=0,N.whave=0,N.wnext=0,Rr(f)},Ir=(f,N)=>{let E;if(Yt(f))return Rt;const X=f.state;return N<0?(E=0,N=-N):(E=(N>>4)+5,N<48&&(N&=15)),N&&(N<8||N>15)?Rt:(X.window!==null&&X.wbits!==N&&(X.window=null),X.wrap=E,X.wbits=N,Pr(f))},zr=(f,N)=>{if(!f)return Rt;const E=new ns;f.state=E,E.strm=f,E.window=null,E.mode=bi;const X=Ir(f,N);return X!==Xt&&(f.state=null),X},ss=f=>zr(f,rs);let Fr=!0,Ui,Wi;const as=f=>{if(Fr){Ui=new Int32Array(512),Wi=new Int32Array(32);let N=0;for(;N<144;)f.lens[N++]=8;for(;N<256;)f.lens[N++]=9;for(;N<280;)f.lens[N++]=7;for(;N<288;)f.lens[N++]=8;for(ci(ir,f.lens,0,288,Ui,0,f.work,{bits:9}),N=0;N<32;)f.lens[N++]=5;ci(rr,f.lens,0,32,Wi,0,f.work,{bits:5}),Fr=!1}f.lencode=Ui,f.lenbits=9,f.distcode=Wi,f.distbits=5},Br=(f,N,E,X)=>{let q;const Q=f.state;return Q.window===null&&(Q.wsize=1<<Q.wbits,Q.wnext=0,Q.whave=0,Q.window=new Uint8Array(Q.wsize)),X>=Q.wsize?(Q.window.set(N.subarray(E-Q.wsize,E),0),Q.wnext=0,Q.whave=Q.wsize):(q=Q.wsize-Q.wnext,q>X&&(q=X),Q.window.set(N.subarray(E-X,E-X+q),Q.wnext),X-=q,X?(Q.window.set(N.subarray(E-X,E),0),Q.wnext=X,Q.whave=Q.wsize):(Q.wnext+=q,Q.wnext===Q.wsize&&(Q.wnext=0),Q.whave<Q.wsize&&(Q.whave+=q))),0},os=(f,N)=>{let E,X,q,Q,Ee,ue,Xe,de,Ae,ct,Ze,Ue,Qe,Et,ht=0,rt,mt,nt,Ke,gt,wt,Je,pt;const ft=new Uint8Array(4);let it,ot;const $t=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Yt(f)||!f.output||!f.input&&f.avail_in!==0)return Rt;E=f.state,E.mode===Gt&&(E.mode=zi),Ee=f.next_out,q=f.output,Xe=f.avail_out,Q=f.next_in,X=f.input,ue=f.avail_in,de=E.hold,Ae=E.bits,ct=ue,Ze=Xe,pt=Xt;e:for(;;)switch(E.mode){case bi:if(E.wrap===0){E.mode=zi;break}for(;Ae<16;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(E.wrap&2&&de===35615){E.wbits===0&&(E.wbits=15),E.check=0,ft[0]=de&255,ft[1]=de>>>8&255,E.check=L(E.check,ft,2,0),de=0,Ae=0,E.mode=lr;break}if(E.head&&(E.head.done=!1),!(E.wrap&1)||(((de&255)<<8)+(de>>8))%31){f.msg="incorrect header check",E.mode=yt;break}if((de&15)!==or){f.msg="unknown compression method",E.mode=yt;break}if(de>>>=4,Ae-=4,Je=(de&15)+8,E.wbits===0&&(E.wbits=Je),Je>15||Je>E.wbits){f.msg="invalid window size",E.mode=yt;break}E.dmax=1<<E.wbits,E.flags=0,f.adler=E.check=1,E.mode=de&512?pr:Gt,de=0,Ae=0;break;case lr:for(;Ae<16;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(E.flags=de,(E.flags&255)!==or){f.msg="unknown compression method",E.mode=yt;break}if(E.flags&57344){f.msg="unknown header flags set",E.mode=yt;break}E.head&&(E.head.text=de>>8&1),E.flags&512&&E.wrap&4&&(ft[0]=de&255,ft[1]=de>>>8&255,E.check=L(E.check,ft,2,0)),de=0,Ae=0,E.mode=hr;case hr:for(;Ae<32;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.head&&(E.head.time=de),E.flags&512&&E.wrap&4&&(ft[0]=de&255,ft[1]=de>>>8&255,ft[2]=de>>>16&255,ft[3]=de>>>24&255,E.check=L(E.check,ft,4,0)),de=0,Ae=0,E.mode=fr;case fr:for(;Ae<16;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.head&&(E.head.xflags=de&255,E.head.os=de>>8),E.flags&512&&E.wrap&4&&(ft[0]=de&255,ft[1]=de>>>8&255,E.check=L(E.check,ft,2,0)),de=0,Ae=0,E.mode=dr;case dr:if(E.flags&1024){for(;Ae<16;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.length=de,E.head&&(E.head.extra_len=de),E.flags&512&&E.wrap&4&&(ft[0]=de&255,ft[1]=de>>>8&255,E.check=L(E.check,ft,2,0)),de=0,Ae=0}else E.head&&(E.head.extra=null);E.mode=cr;case cr:if(E.flags&1024&&(Ue=E.length,Ue>ue&&(Ue=ue),Ue&&(E.head&&(Je=E.head.extra_len-E.length,E.head.extra||(E.head.extra=new Uint8Array(E.head.extra_len)),E.head.extra.set(X.subarray(Q,Q+Ue),Je)),E.flags&512&&E.wrap&4&&(E.check=L(E.check,X,Ue,Q)),ue-=Ue,Q+=Ue,E.length-=Ue),E.length))break e;E.length=0,E.mode=ur;case ur:if(E.flags&2048){if(ue===0)break e;Ue=0;do Je=X[Q+Ue++],E.head&&Je&&E.length<65536&&(E.head.name+=String.fromCharCode(Je));while(Je&&Ue<ue);if(E.flags&512&&E.wrap&4&&(E.check=L(E.check,X,Ue,Q)),ue-=Ue,Q+=Ue,Je)break e}else E.head&&(E.head.name=null);E.length=0,E.mode=gr;case gr:if(E.flags&4096){if(ue===0)break e;Ue=0;do Je=X[Q+Ue++],E.head&&Je&&E.length<65536&&(E.head.comment+=String.fromCharCode(Je));while(Je&&Ue<ue);if(E.flags&512&&E.wrap&4&&(E.check=L(E.check,X,Ue,Q)),ue-=Ue,Q+=Ue,Je)break e}else E.head&&(E.head.comment=null);E.mode=mr;case mr:if(E.flags&512){for(;Ae<16;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(E.wrap&4&&de!==(E.check&65535)){f.msg="header crc mismatch",E.mode=yt;break}de=0,Ae=0}E.head&&(E.head.hcrc=E.flags>>9&1,E.head.done=!0),f.adler=E.check=0,E.mode=Gt;break;case pr:for(;Ae<32;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}f.adler=E.check=Or(de),de=0,Ae=0,E.mode=yi;case yi:if(E.havedict===0)return f.next_out=Ee,f.avail_out=Xe,f.next_in=Q,f.avail_in=ue,E.hold=de,E.bits=Ae,qn;f.adler=E.check=1,E.mode=Gt;case Gt:if(N===Qn||N===xi)break e;case zi:if(E.last){de>>>=Ae&7,Ae-=Ae&7,E.mode=Bi;break}for(;Ae<3;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}switch(E.last=de&1,de>>>=1,Ae-=1,de&3){case 0:E.mode=vr;break;case 1:if(as(E),E.mode=Ei,N===xi){de>>>=2,Ae-=2;break e}break;case 2:E.mode=xr;break;case 3:f.msg="invalid block type",E.mode=yt}de>>>=2,Ae-=2;break;case vr:for(de>>>=Ae&7,Ae-=Ae&7;Ae<32;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if((de&65535)!==(de>>>16^65535)){f.msg="invalid stored block lengths",E.mode=yt;break}if(E.length=de&65535,de=0,Ae=0,E.mode=Fi,N===xi)break e;case Fi:E.mode=_r;case _r:if(Ue=E.length,Ue){if(Ue>ue&&(Ue=ue),Ue>Xe&&(Ue=Xe),Ue===0)break e;q.set(X.subarray(Q,Q+Ue),Ee),ue-=Ue,Q+=Ue,Xe-=Ue,Ee+=Ue,E.length-=Ue;break}E.mode=Gt;break;case xr:for(;Ae<14;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(E.nlen=(de&31)+257,de>>>=5,Ae-=5,E.ndist=(de&31)+1,de>>>=5,Ae-=5,E.ncode=(de&15)+4,de>>>=4,Ae-=4,E.nlen>286||E.ndist>30){f.msg="too many length or distance symbols",E.mode=yt;break}E.have=0,E.mode=br;case br:for(;E.have<E.ncode;){for(;Ae<3;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.lens[$t[E.have++]]=de&7,de>>>=3,Ae-=3}for(;E.have<19;)E.lens[$t[E.have++]]=0;if(E.lencode=E.lendyn,E.lenbits=7,it={bits:E.lenbits},pt=ci($n,E.lens,0,19,E.lencode,0,E.work,it),E.lenbits=it.bits,pt){f.msg="invalid code lengths set",E.mode=yt;break}E.have=0,E.mode=yr;case yr:for(;E.have<E.nlen+E.ndist;){for(;ht=E.lencode[de&(1<<E.lenbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ae);){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(nt<16)de>>>=rt,Ae-=rt,E.lens[E.have++]=nt;else{if(nt===16){for(ot=rt+2;Ae<ot;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(de>>>=rt,Ae-=rt,E.have===0){f.msg="invalid bit length repeat",E.mode=yt;break}Je=E.lens[E.have-1],Ue=3+(de&3),de>>>=2,Ae-=2}else if(nt===17){for(ot=rt+3;Ae<ot;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}de>>>=rt,Ae-=rt,Je=0,Ue=3+(de&7),de>>>=3,Ae-=3}else{for(ot=rt+7;Ae<ot;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}de>>>=rt,Ae-=rt,Je=0,Ue=11+(de&127),de>>>=7,Ae-=7}if(E.have+Ue>E.nlen+E.ndist){f.msg="invalid bit length repeat",E.mode=yt;break}for(;Ue--;)E.lens[E.have++]=Je}}if(E.mode===yt)break;if(E.lens[256]===0){f.msg="invalid code -- missing end-of-block",E.mode=yt;break}if(E.lenbits=9,it={bits:E.lenbits},pt=ci(ir,E.lens,0,E.nlen,E.lencode,0,E.work,it),E.lenbits=it.bits,pt){f.msg="invalid literal/lengths set",E.mode=yt;break}if(E.distbits=6,E.distcode=E.distdyn,it={bits:E.distbits},pt=ci(rr,E.lens,E.nlen,E.ndist,E.distcode,0,E.work,it),E.distbits=it.bits,pt){f.msg="invalid distances set",E.mode=yt;break}if(E.mode=Ei,N===xi)break e;case Ei:E.mode=Ai;case Ai:if(ue>=6&&Xe>=258){f.next_out=Ee,f.avail_out=Xe,f.next_in=Q,f.avail_in=ue,E.hold=de,E.bits=Ae,Hn(f,Ze),Ee=f.next_out,q=f.output,Xe=f.avail_out,Q=f.next_in,X=f.input,ue=f.avail_in,de=E.hold,Ae=E.bits,E.mode===Gt&&(E.back=-1);break}for(E.back=0;ht=E.lencode[de&(1<<E.lenbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ae);){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(mt&&(mt&240)===0){for(Ke=rt,gt=mt,wt=nt;ht=E.lencode[wt+((de&(1<<Ke+gt)-1)>>Ke)],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(Ke+rt<=Ae);){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}de>>>=Ke,Ae-=Ke,E.back+=Ke}if(de>>>=rt,Ae-=rt,E.back+=rt,E.length=nt,mt===0){E.mode=Cr;break}if(mt&32){E.back=-1,E.mode=Gt;break}if(mt&64){f.msg="invalid literal/length code",E.mode=yt;break}E.extra=mt&15,E.mode=Er;case Er:if(E.extra){for(ot=E.extra;Ae<ot;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.length+=de&(1<<E.extra)-1,de>>>=E.extra,Ae-=E.extra,E.back+=E.extra}E.was=E.length,E.mode=Ar;case Ar:for(;ht=E.distcode[de&(1<<E.distbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ae);){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if((mt&240)===0){for(Ke=rt,gt=mt,wt=nt;ht=E.distcode[wt+((de&(1<<Ke+gt)-1)>>Ke)],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(Ke+rt<=Ae);){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}de>>>=Ke,Ae-=Ke,E.back+=Ke}if(de>>>=rt,Ae-=rt,E.back+=rt,mt&64){f.msg="invalid distance code",E.mode=yt;break}E.offset=nt,E.extra=mt&15,E.mode=Mr;case Mr:if(E.extra){for(ot=E.extra;Ae<ot;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}E.offset+=de&(1<<E.extra)-1,de>>>=E.extra,Ae-=E.extra,E.back+=E.extra}if(E.offset>E.dmax){f.msg="invalid distance too far back",E.mode=yt;break}E.mode=wr;case wr:if(Xe===0)break e;if(Ue=Ze-Xe,E.offset>Ue){if(Ue=E.offset-Ue,Ue>E.whave&&E.sane){f.msg="invalid distance too far back",E.mode=yt;break}Ue>E.wnext?(Ue-=E.wnext,Qe=E.wsize-Ue):Qe=E.wnext-Ue,Ue>E.length&&(Ue=E.length),Et=E.window}else Et=q,Qe=Ee-E.offset,Ue=E.length;Ue>Xe&&(Ue=Xe),Xe-=Ue,E.length-=Ue;do q[Ee++]=Et[Qe++];while(--Ue);E.length===0&&(E.mode=Ai);break;case Cr:if(Xe===0)break e;q[Ee++]=E.length,Xe--,E.mode=Ai;break;case Bi:if(E.wrap){for(;Ae<32;){if(ue===0)break e;ue--,de|=X[Q++]<<Ae,Ae+=8}if(Ze-=Xe,f.total_out+=Ze,E.total+=Ze,E.wrap&4&&Ze&&(f.adler=E.check=E.flags?L(E.check,q,Ze,Ee-Ze):be(E.check,q,Ze,Ee-Ze)),Ze=Xe,E.wrap&4&&(E.flags?de:Or(de))!==E.check){f.msg="incorrect data check",E.mode=yt;break}de=0,Ae=0}E.mode=Lr;case Lr:if(E.wrap&&E.flags){for(;Ae<32;){if(ue===0)break e;ue--,de+=X[Q++]<<Ae,Ae+=8}if(E.wrap&4&&de!==(E.total&4294967295)){f.msg="incorrect length check",E.mode=yt;break}de=0,Ae=0}E.mode=Dr;case Dr:pt=Jn;break e;case yt:pt=sr;break e;case Tr:return ar;case Sr:default:return Rt}return f.next_out=Ee,f.avail_out=Xe,f.next_in=Q,f.avail_in=ue,E.hold=de,E.bits=Ae,(E.wsize||Ze!==f.avail_out&&E.mode<yt&&(E.mode<Bi||N!==nr))&&Br(f,f.output,f.next_out,Ze-f.avail_out),ct-=f.avail_in,Ze-=f.avail_out,f.total_in+=ct,f.total_out+=Ze,E.total+=Ze,E.wrap&4&&Ze&&(f.adler=E.check=E.flags?L(E.check,q,Ze,f.next_out-Ze):be(E.check,q,Ze,f.next_out-Ze)),f.data_type=E.bits+(E.last?64:0)+(E.mode===Gt?128:0)+(E.mode===Ei||E.mode===Fi?256:0),(ct===0&&Ze===0||N===nr)&&pt===Xt&&(pt=es),pt},ls=f=>{if(Yt(f))return Rt;let N=f.state;return N.window&&(N.window=null),f.state=null,Xt},hs=(f,N)=>{if(Yt(f))return Rt;const E=f.state;return(E.wrap&2)===0?Rt:(E.head=N,N.done=!1,Xt)},fs=(f,N)=>{const E=N.length;let X,q,Q;return Yt(f)||(X=f.state,X.wrap!==0&&X.mode!==yi)?Rt:X.mode===yi&&(q=1,q=be(q,N,E,0),q!==X.check)?sr:(Q=Br(f,N,E,E),Q?(X.mode=Tr,ar):(X.havedict=1,Xt))};var ds=Pr,cs=Ir,us=Rr,gs=ss,ms=zr,ps=os,vs=ls,_s=hs,xs=fs,bs="pako inflate (from Nodeca project)",Nt={inflateReset:ds,inflateReset2:cs,inflateResetKeep:us,inflateInit:gs,inflateInit2:ms,inflate:ps,inflateEnd:vs,inflateGetHeader:_s,inflateSetDictionary:xs,inflateInfo:bs};function ys(){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}var Es=ys;const Ur=Object.prototype.toString,{Z_NO_FLUSH:As,Z_FINISH:Ms,Z_OK:ui,Z_STREAM_END:Gi,Z_NEED_DICT:Ni,Z_STREAM_ERROR:ws,Z_DATA_ERROR:Wr,Z_MEM_ERROR:Cs}=fe;function gi(f){this.options=pi.assign({chunkSize:65536,windowBits:15,to:""},f||{});const N=this.options;N.raw&&N.windowBits>=0&&N.windowBits<16&&(N.windowBits=-N.windowBits,N.windowBits===0&&(N.windowBits=-15)),N.windowBits>=0&&N.windowBits<16&&!(f&&f.windowBits)&&(N.windowBits+=32),N.windowBits>15&&N.windowBits<48&&(N.windowBits&15)===0&&(N.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $i,this.strm.avail_out=0;let E=Nt.inflateInit2(this.strm,N.windowBits);if(E!==ui)throw new Error(he[E]);if(this.header=new Es,Nt.inflateGetHeader(this.strm,this.header),N.dictionary&&(typeof N.dictionary=="string"?N.dictionary=fi.string2buf(N.dictionary):Ur.call(N.dictionary)==="[object ArrayBuffer]"&&(N.dictionary=new Uint8Array(N.dictionary)),N.raw&&(E=Nt.inflateSetDictionary(this.strm,N.dictionary),E!==ui)))throw new Error(he[E])}gi.prototype.push=function(f,N){const E=this.strm,X=this.options.chunkSize,q=this.options.dictionary;let Q,Ee,ue;if(this.ended)return!1;for(N===~~N?Ee=N:Ee=N===!0?Ms:As,Ur.call(f)==="[object ArrayBuffer]"?E.input=new Uint8Array(f):E.input=f,E.next_in=0,E.avail_in=E.input.length;;){for(E.avail_out===0&&(E.output=new Uint8Array(X),E.next_out=0,E.avail_out=X),Q=Nt.inflate(E,Ee),Q===Ni&&q&&(Q=Nt.inflateSetDictionary(E,q),Q===ui?Q=Nt.inflate(E,Ee):Q===Wr&&(Q=Ni));E.avail_in>0&&Q===Gi&&E.state.wrap>0&&f[E.next_in]!==0;)Nt.inflateReset(E),Q=Nt.inflate(E,Ee);switch(Q){case ws:case Wr:case Ni:case Cs:return this.onEnd(Q),this.ended=!0,!1}if(ue=E.avail_out,E.next_out&&(E.avail_out===0||Q===Gi))if(this.options.to==="string"){let Xe=fi.utf8border(E.output,E.next_out),de=E.next_out-Xe,Ae=fi.buf2string(E.output,Xe);E.next_out=de,E.avail_out=X-de,de&&E.output.set(E.output.subarray(Xe,Xe+de),0),this.onData(Ae)}else this.onData(E.output.length===E.next_out?E.output:E.output.subarray(0,E.next_out));if(!(Q===ui&&ue===0)){if(Q===Gi)return Q=Nt.inflateEnd(this.strm),this.onEnd(Q),this.ended=!0,!0;if(E.avail_in===0)break}}return!0},gi.prototype.onData=function(f){this.chunks.push(f)},gi.prototype.onEnd=function(f){f===ui&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=pi.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function Vi(f,N){const E=new gi(N);if(E.push(f),E.err)throw E.msg||he[E.err];return E.result}function Ls(f,N){return N=N||{},N.raw=!0,Vi(f,N)}var Ds=gi,Ts=Vi,Ss=Ls,Os=Vi,Rs={Inflate:Ds,inflate:Ts,inflateRaw:Ss,ungzip:Os};const{Deflate:Ps,deflate:Is,deflateRaw:zs,gzip:Fs}=jn,{Inflate:Bs,inflate:Us,inflateRaw:Ws,ungzip:Gs}=Rs;var Gr=Ps,Nr=Is,Vr=zs,jr=Fs,kr=Bs,Hr=Us,Kr=Ws,Zr=Gs,Xr=fe,Ns={Deflate:Gr,deflate:Nr,deflateRaw:Vr,gzip:jr,Inflate:kr,inflate:Hr,inflateRaw:Kr,ungzip:Zr,constants:Xr}},"./node_modules/upng-js/UPNG.js"(k,w,c){(function(){var b={},O;k.exports=b,O=c("./node_modules/upng-js/node_modules/pako/index.js"),(function(C,R){C.toRGBA8=function(v){var y=v.width,M=v.height;if(v.tabs.acTL==null)return[C.toRGBA8.decodeImage(v.data,y,M,v).buffer];var g=[];v.frames[0].data==null&&(v.frames[0].data=v.data);for(var x,_=new Uint8Array(y*M*4),p=0;p<v.frames.length;p++){var m=v.frames[p],r=m.rect.x,e=m.rect.y,t=m.rect.width,s=m.rect.height,o=C.toRGBA8.decodeImage(m.data,t,s,v);if(p==0?x=o:m.blend==0?C._copyTile(o,t,s,x,y,M,r,e,0):m.blend==1&&C._copyTile(o,t,s,x,y,M,r,e,1),g.push(x.buffer),x=x.slice(0),m.dispose!=0){if(m.dispose==1)C._copyTile(_,t,s,x,y,M,r,e,0);else if(m.dispose==2){for(var l=p-1;v.frames[l].dispose==2;)l--;x=new Uint8Array(g[l]).slice(0)}}}return g},C.toRGBA8.decodeImage=function(v,y,M,g){var x=y*M,_=C.decode._getBPP(g),p=Math.ceil(y*_/8),m=new Uint8Array(x*4),r=new Uint32Array(m.buffer),e=g.ctype,t=g.depth,s=C._bin.readUshort;if(e==6){var o=x<<2;if(t==8)for(var l=0;l<o;l++)m[l]=v[l];if(t==16)for(var l=0;l<o;l++)m[l]=v[l<<1]}else if(e==2){var d=g.tabs.tRNS,i=-1,n=-1,a=-1;if(d&&(i=d[0],n=d[1],a=d[2]),t==8)for(var l=0;l<x;l++){var h=l<<2,u=l*3;m[h]=v[u],m[h+1]=v[u+1],m[h+2]=v[u+2],m[h+3]=255,i!=-1&&v[u]==i&&v[u+1]==n&&v[u+2]==a&&(m[h+3]=0)}if(t==16)for(var l=0;l<x;l++){var h=l<<2,u=l*6;m[h]=v[u],m[h+1]=v[u+2],m[h+2]=v[u+4],m[h+3]=255,i!=-1&&s(v,u)==i&&s(v,u+2)==n&&s(v,u+4)==a&&(m[h+3]=0)}}else if(e==3){var A=g.tabs.PLTE,D=g.tabs.tRNS,T=D?D.length:0;if(t==1)for(var S=0;S<M;S++)for(var P=S*p,z=S*y,l=0;l<y;l++){var h=z+l<<2,F=v[P+(l>>3)]>>7-((l&7)<<0)&1,B=3*F;m[h]=A[B],m[h+1]=A[B+1],m[h+2]=A[B+2],m[h+3]=F<T?D[F]:255}if(t==2)for(var S=0;S<M;S++)for(var P=S*p,z=S*y,l=0;l<y;l++){var h=z+l<<2,F=v[P+(l>>2)]>>6-((l&3)<<1)&3,B=3*F;m[h]=A[B],m[h+1]=A[B+1],m[h+2]=A[B+2],m[h+3]=F<T?D[F]:255}if(t==4)for(var S=0;S<M;S++)for(var P=S*p,z=S*y,l=0;l<y;l++){var h=z+l<<2,F=v[P+(l>>1)]>>4-((l&1)<<2)&15,B=3*F;m[h]=A[B],m[h+1]=A[B+1],m[h+2]=A[B+2],m[h+3]=F<T?D[F]:255}if(t==8)for(var l=0;l<x;l++){var h=l<<2,F=v[l],B=3*F;m[h]=A[B],m[h+1]=A[B+1],m[h+2]=A[B+2],m[h+3]=F<T?D[F]:255}}else if(e==4){if(t==8)for(var l=0;l<x;l++){var h=l<<2,W=l<<1,U=v[W];m[h]=U,m[h+1]=U,m[h+2]=U,m[h+3]=v[W+1]}if(t==16)for(var l=0;l<x;l++){var h=l<<2,W=l<<2,U=v[W];m[h]=U,m[h+1]=U,m[h+2]=U,m[h+3]=v[W+2]}}else if(e==0){var i=g.tabs.tRNS?g.tabs.tRNS:-1;if(t==1)for(var l=0;l<x;l++){var U=255*(v[l>>3]>>7-(l&7)&1),I=U==i*255?0:255;r[l]=I<<24|U<<16|U<<8|U}if(t==2)for(var l=0;l<x;l++){var U=85*(v[l>>2]>>6-((l&3)<<1)&3),I=U==i*85?0:255;r[l]=I<<24|U<<16|U<<8|U}if(t==4)for(var l=0;l<x;l++){var U=17*(v[l>>1]>>4-((l&1)<<2)&15),I=U==i*17?0:255;r[l]=I<<24|U<<16|U<<8|U}if(t==8)for(var l=0;l<x;l++){var U=v[l],I=U==i?0:255;r[l]=I<<24|U<<16|U<<8|U}if(t==16)for(var l=0;l<x;l++){var U=v[l<<1],I=s(v,l<<1)==i?0:255;r[l]=I<<24|U<<16|U<<8|U}}return m},C.decode=function(v){for(var y=new Uint8Array(v),M=8,g=C._bin,x=g.readUshort,_=g.readUint,p={tabs:{},frames:[]},m=new Uint8Array(y.length),r=0,e,t=0,s=[137,80,78,71,13,10,26,10],o=0;o<8;o++)if(y[o]!=s[o])throw"The input is not a PNG file!";for(;M<y.length;){var l=g.readUint(y,M);M+=4;var d=g.readASCII(y,M,4);if(M+=4,d=="IHDR")C.decode._IHDR(y,M,p);else if(d=="IDAT"){for(var o=0;o<l;o++)m[r+o]=y[M+o];r+=l}else if(d=="acTL")p.tabs[d]={num_frames:_(y,M),num_plays:_(y,M+4)},e=new Uint8Array(y.length);else if(d=="fcTL"){if(t!=0){var i=p.frames[p.frames.length-1];i.data=C.decode._decompress(p,e.slice(0,t),i.rect.width,i.rect.height),t=0}var n={x:_(y,M+12),y:_(y,M+16),width:_(y,M+4),height:_(y,M+8)},a=x(y,M+22);a=x(y,M+20)/(a==0?100:a);var h={rect:n,delay:Math.round(a*1e3),dispose:y[M+24],blend:y[M+25]};p.frames.push(h)}else if(d=="fdAT"){for(var o=0;o<l-4;o++)e[t+o]=y[M+o+4];t+=l-4}else if(d=="pHYs")p.tabs[d]=[g.readUint(y,M),g.readUint(y,M+4),y[M+8]];else if(d=="cHRM"){p.tabs[d]=[];for(var o=0;o<8;o++)p.tabs[d].push(g.readUint(y,M+o*4))}else if(d=="tEXt"){p.tabs[d]==null&&(p.tabs[d]={});var u=g.nextZero(y,M),A=g.readASCII(y,M,u-M),D=g.readASCII(y,u+1,M+l-u-1);p.tabs[d][A]=D}else if(d=="iTXt"){p.tabs[d]==null&&(p.tabs[d]={});var u=0,T=M;u=g.nextZero(y,T);var A=g.readASCII(y,T,u-T);T=u+1,y[T],y[T+1],T+=2,u=g.nextZero(y,T),g.readASCII(y,T,u-T),T=u+1,u=g.nextZero(y,T),g.readUTF8(y,T,u-T),T=u+1;var D=g.readUTF8(y,T,l-(T-M));p.tabs[d][A]=D}else if(d=="PLTE")p.tabs[d]=g.readBytes(y,M,l);else if(d=="hIST"){var S=p.tabs.PLTE.length/3;p.tabs[d]=[];for(var o=0;o<S;o++)p.tabs[d].push(x(y,M+o*2))}else if(d=="tRNS")p.ctype==3?p.tabs[d]=g.readBytes(y,M,l):p.ctype==0?p.tabs[d]=x(y,M):p.ctype==2&&(p.tabs[d]=[x(y,M),x(y,M+2),x(y,M+4)]);else if(d=="gAMA")p.tabs[d]=g.readUint(y,M)/1e5;else if(d=="sRGB")p.tabs[d]=y[M];else if(d=="bKGD")p.ctype==0||p.ctype==4?p.tabs[d]=[x(y,M)]:p.ctype==2||p.ctype==6?p.tabs[d]=[x(y,M),x(y,M+2),x(y,M+4)]:p.ctype==3&&(p.tabs[d]=y[M]);else if(d=="IEND"){if(t!=0){var i=p.frames[p.frames.length-1];i.data=C.decode._decompress(p,e.slice(0,t),i.rect.width,i.rect.height),t=0}p.data=C.decode._decompress(p,m,p.width,p.height);break}M+=l,g.readUint(y,M),M+=4}return delete p.compress,delete p.interlace,delete p.filter,p},C.decode._decompress=function(v,y,M,g){return v.compress==0&&(y=C.decode._inflate(y)),v.interlace==0?y=C.decode._filterZero(y,v,0,M,g):v.interlace==1&&(y=C.decode._readInterlace(y,v)),y},C.decode._inflate=function(v){return R.inflate(v)},C.decode._readInterlace=function(v,y){for(var M=y.width,g=y.height,x=C.decode._getBPP(y),_=x>>3,p=Math.ceil(M*x/8),m=new Uint8Array(g*p),r=0,e=[0,0,4,0,2,0,1],t=[0,4,0,2,0,1,0],s=[8,8,8,4,4,2,2],o=[8,8,4,4,2,2,1],l=0;l<7;){for(var d=s[l],i=o[l],n=0,a=0,h=e[l];h<g;)h+=d,a++;for(var u=t[l];u<M;)u+=i,n++;var A=Math.ceil(n*x/8);C.decode._filterZero(v,y,r,n,a);for(var D=0,T=e[l];T<g;){for(var S=t[l],P=r+D*A<<3;S<M;){if(x==1){var z=v[P>>3];z=z>>7-(P&7)&1,m[T*p+(S>>3)]|=z<<7-((S&3)<<0)}if(x==2){var z=v[P>>3];z=z>>6-(P&7)&3,m[T*p+(S>>2)]|=z<<6-((S&3)<<1)}if(x==4){var z=v[P>>3];z=z>>4-(P&7)&15,m[T*p+(S>>1)]|=z<<4-((S&1)<<2)}if(x>=8)for(var F=T*p+S*_,B=0;B<_;B++)m[F+B]=v[(P>>3)+B];P+=x,S+=i}D++,T+=d}n*a!=0&&(r+=a*(1+A)),l=l+1}return m},C.decode._getBPP=function(v){var y=[1,null,3,1,2,null,4][v.ctype];return y*v.depth},C.decode._filterZero=function(v,y,M,g,x){var _=C.decode._getBPP(y),p=Math.ceil(g*_/8),m=C.decode._paeth;_=Math.ceil(_/8);for(var r=0;r<x;r++){var e=M+r*p,t=e+r+1,s=v[t-1];if(s==0)for(var o=0;o<p;o++)v[e+o]=v[t+o];else if(s==1){for(var o=0;o<_;o++)v[e+o]=v[t+o];for(var o=_;o<p;o++)v[e+o]=v[t+o]+v[e+o-_]&255}else if(r==0){for(var o=0;o<_;o++)v[e+o]=v[t+o];if(s==2)for(var o=_;o<p;o++)v[e+o]=v[t+o]&255;if(s==3)for(var o=_;o<p;o++)v[e+o]=v[t+o]+(v[e+o-_]>>1)&255;if(s==4)for(var o=_;o<p;o++)v[e+o]=v[t+o]+m(v[e+o-_],0,0)&255}else{if(s==2)for(var o=0;o<p;o++)v[e+o]=v[t+o]+v[e+o-p]&255;if(s==3){for(var o=0;o<_;o++)v[e+o]=v[t+o]+(v[e+o-p]>>1)&255;for(var o=_;o<p;o++)v[e+o]=v[t+o]+(v[e+o-p]+v[e+o-_]>>1)&255}if(s==4){for(var o=0;o<_;o++)v[e+o]=v[t+o]+m(0,v[e+o-p],0)&255;for(var o=_;o<p;o++)v[e+o]=v[t+o]+m(v[e+o-_],v[e+o-p],v[e+o-_-p])&255}}}return v},C.decode._paeth=function(v,y,M){var g=v+y-M,x=Math.abs(g-v),_=Math.abs(g-y),p=Math.abs(g-M);return x<=_&&x<=p?v:_<=p?y:M},C.decode._IHDR=function(v,y,M){var g=C._bin;M.width=g.readUint(v,y),y+=4,M.height=g.readUint(v,y),y+=4,M.depth=v[y],y++,M.ctype=v[y],y++,M.compress=v[y],y++,M.filter=v[y],y++,M.interlace=v[y],y++},C._bin={nextZero:function(v,y){for(;v[y]!=0;)y++;return y},readUshort:function(v,y){return v[y]<<8|v[y+1]},writeUshort:function(v,y,M){v[y]=M>>8&255,v[y+1]=M&255},readUint:function(v,y){return v[y]*16777216+(v[y+1]<<16|v[y+2]<<8|v[y+3])},writeUint:function(v,y,M){v[y]=M>>24&255,v[y+1]=M>>16&255,v[y+2]=M>>8&255,v[y+3]=M&255},readASCII:function(v,y,M){for(var g="",x=0;x<M;x++)g+=String.fromCharCode(v[y+x]);return g},writeASCII:function(v,y,M){for(var g=0;g<M.length;g++)v[y+g]=M.charCodeAt(g)},readBytes:function(v,y,M){for(var g=[],x=0;x<M;x++)g.push(v[y+x]);return g},pad:function(v){return v.length<2?"0"+v:v},readUTF8:function(v,y,M){for(var g="",x,_=0;_<M;_++)g+="%"+C._bin.pad(v[y+_].toString(16));try{x=decodeURIComponent(g)}catch{return C._bin.readASCII(v,y,M)}return x}},C._copyTile=function(v,y,M,g,x,_,p,m,r){for(var e=Math.min(y,x),t=Math.min(M,_),s=0,o=0,l=0;l<t;l++)for(var d=0;d<e;d++)if(p>=0&&m>=0?(s=l*y+d<<2,o=(m+l)*x+p+d<<2):(s=(-m+l)*y-p+d<<2,o=l*x+d<<2),r==0)g[o]=v[s],g[o+1]=v[s+1],g[o+2]=v[s+2],g[o+3]=v[s+3];else if(r==1){var i=v[s+3]*.00392156862745098,n=v[s]*i,a=v[s+1]*i,h=v[s+2]*i,u=g[o+3]*(1/255),A=g[o]*u,D=g[o+1]*u,T=g[o+2]*u,S=1-i,P=i+u*S,z=P==0?0:1/P;g[o+3]=255*P,g[o+0]=(n+A*S)*z,g[o+1]=(a+D*S)*z,g[o+2]=(h+T*S)*z}else if(r==2){var i=v[s+3],n=v[s],a=v[s+1],h=v[s+2],u=g[o+3],A=g[o],D=g[o+1],T=g[o+2];i==u&&n==A&&a==D&&h==T?(g[o]=0,g[o+1]=0,g[o+2]=0,g[o+3]=0):(g[o]=n,g[o+1]=a,g[o+2]=h,g[o+3]=i)}else if(r==3){var i=v[s+3],n=v[s],a=v[s+1],h=v[s+2],u=g[o+3],A=g[o],D=g[o+1],T=g[o+2];if(i==u&&n==A&&a==D&&h==T)continue;if(i<220&&u>20)return!1}return!0},C.encode=function(v,y,M,g,x,_){g==null&&(g=0),_==null&&(_=!1);for(var p=new Uint8Array(v[0].byteLength*v.length+100),m=[137,80,78,71,13,10,26,10],r=0;r<8;r++)p[r]=m[r];var e=8,t=C._bin,s=C.crc.crc,o=t.writeUint,l=t.writeUshort,d=t.writeASCII,i=C.encode.compressPNG(v,y,M,g,_);o(p,e,13),e+=4,d(p,e,"IHDR"),e+=4,o(p,e,y),e+=4,o(p,e,M),e+=4,p[e]=i.depth,e++,p[e]=i.ctype,e++,p[e]=0,e++,p[e]=0,e++,p[e]=0,e++,o(p,e,s(p,e-17,17)),e+=4,o(p,e,1),e+=4,d(p,e,"sRGB"),e+=4,p[e]=1,e++,o(p,e,s(p,e-5,5)),e+=4;var n=v.length>1;if(n&&(o(p,e,8),e+=4,d(p,e,"acTL"),e+=4,o(p,e,v.length),e+=4,o(p,e,0),e+=4,o(p,e,s(p,e-12,12)),e+=4),i.ctype==3){var a=i.plte.length;o(p,e,a*3),e+=4,d(p,e,"PLTE"),e+=4;for(var r=0;r<a;r++){var h=r*3,u=i.plte[r],A=u&255,D=u>>8&255,T=u>>16&255;p[e+h+0]=A,p[e+h+1]=D,p[e+h+2]=T}if(e+=a*3,o(p,e,s(p,e-a*3-4,a*3+4)),e+=4,i.gotAlpha){o(p,e,a),e+=4,d(p,e,"tRNS"),e+=4;for(var r=0;r<a;r++)p[e+r]=i.plte[r]>>24&255;e+=a,o(p,e,s(p,e-a-4,a+4)),e+=4}}for(var S=0,P=0;P<i.frames.length;P++){var z=i.frames[P];n&&(o(p,e,26),e+=4,d(p,e,"fcTL"),e+=4,o(p,e,S++),e+=4,o(p,e,z.rect.width),e+=4,o(p,e,z.rect.height),e+=4,o(p,e,z.rect.x),e+=4,o(p,e,z.rect.y),e+=4,l(p,e,x[P]),e+=2,l(p,e,1e3),e+=2,p[e]=z.dispose,e++,p[e]=z.blend,e++,o(p,e,s(p,e-30,30)),e+=4);var F=z.cimg,a=F.length;o(p,e,a+(P==0?0:4)),e+=4;var B=e;d(p,e,P==0?"IDAT":"fdAT"),e+=4,P!=0&&(o(p,e,S++),e+=4);for(var r=0;r<a;r++)p[e+r]=F[r];e+=a,o(p,e,s(p,B,e-B)),e+=4}return o(p,e,0),e+=4,d(p,e,"IEND"),e+=4,o(p,e,s(p,e-4,4)),e+=4,p.buffer.slice(0,e)},C.encode.compressPNG=function(v,y,M,g,x){for(var _=C.encode.compress(v,y,M,g,!1,x),p=0;p<v.length;p++){var m=_.frames[p];m.rect.width;var r=m.rect.height,e=m.bpl,t=m.bpp,s=new Uint8Array(r*e+r);m.cimg=C.encode._filterZero(m.img,r,t,e,s)}return _},C.encode.compress=function(v,y,M,g,x,_){_==null&&(_=!1);for(var p=6,m=8,r=4,e=255,t=0;t<v.length;t++)for(var s=new Uint8Array(v[t]),o=s.length,l=0;l<o;l+=4)e&=s[l+3];var d=e!=255,i={},n=[];if(v.length!=0&&(i[0]=0,n.push(0),g!=0&&g--),g!=0){var a=C.quantize(v,g,x);v=a.bufs;for(var l=0;l<a.plte.length;l++){var h=a.plte[l].est.rgba;i[h]==null&&(i[h]=n.length,n.push(h))}}else for(var t=0;t<v.length;t++)for(var u=new Uint32Array(v[t]),o=u.length,l=0;l<o;l++){var h=u[l];if((l<y||h!=u[l-1]&&h!=u[l-y])&&i[h]==null&&(i[h]=n.length,n.push(h),n.length>=300))break}var A=d?x:!1,D=n.length;D<=256&&_==!1&&(D<=2?m=1:D<=4?m=2:D<=16?m=4:m=8,x&&(m=8),d=!0);for(var T=[],t=0;t<v.length;t++){var S=new Uint8Array(v[t]),P=new Uint32Array(S.buffer),z=0,F=0,B=y,W=M,U=0;if(t!=0&&!A){for(var I=x||t==1||T[T.length-2].dispose==2?1:2,G=0,Y=1e9,J=0;J<I;J++){for(var ye=new Uint8Array(v[t-1-J]),te=new Uint32Array(v[t-1-J]),ne=y,le=M,ie=-1,oe=-1,xe=0;xe<M;xe++)for(var _e=0;_e<y;_e++){var l=xe*y+_e;P[l]!=te[l]&&(_e<ne&&(ne=_e),_e>ie&&(ie=_e),xe<le&&(le=xe),xe>oe&&(oe=xe))}var Oe=ie==-1?1:(ie-ne+1)*(oe-le+1);Oe<Y&&(Y=Oe,G=J,ie==-1?(z=F=0,B=W=1):(z=ne,F=le,B=ie-ne+1,W=oe-le+1))}var ye=new Uint8Array(v[t-1-G]);G==1&&(T[T.length-1].dispose=2);var ee=new Uint8Array(B*W*4);new Uint32Array(ee.buffer),C._copyTile(ye,y,M,ee,B,W,-z,-F,0),C._copyTile(S,y,M,ee,B,W,-z,-F,3)?(C._copyTile(S,y,M,ee,B,W,-z,-F,2),U=1):(C._copyTile(S,y,M,ee,B,W,-z,-F,0),U=0),S=ee,P=new Uint32Array(S.buffer)}var pe=4*B;if(D<=256&&_==!1){pe=Math.ceil(m*B/8);for(var ee=new Uint8Array(pe*W),xe=0;xe<W;xe++){var l=xe*pe,Ce=xe*B;if(m==8)for(var _e=0;_e<B;_e++)ee[l+_e]=i[P[Ce+_e]];else if(m==4)for(var _e=0;_e<B;_e++)ee[l+(_e>>1)]|=i[P[Ce+_e]]<<4-(_e&1)*4;else if(m==2)for(var _e=0;_e<B;_e++)ee[l+(_e>>2)]|=i[P[Ce+_e]]<<6-(_e&3)*2;else if(m==1)for(var _e=0;_e<B;_e++)ee[l+(_e>>3)]|=i[P[Ce+_e]]<<7-(_e&7)*1}S=ee,p=3,r=1}else if(d==!1&&v.length==1){for(var ee=new Uint8Array(B*W*3),Te=B*W,l=0;l<Te;l++){var We=l*3,Ie=l*4;ee[We]=S[Ie],ee[We+1]=S[Ie+1],ee[We+2]=S[Ie+2]}S=ee,p=2,r=3,pe=3*B}T.push({rect:{x:z,y:F,width:B,height:W},img:S,bpl:pe,bpp:r,blend:U,dispose:A?1:0})}return{ctype:p,depth:m,plte:n,gotAlpha:d,frames:T}},C.encode._filterZero=function(v,y,M,g,x){for(var _=[],p=0;p<5;p++)if(!(y*g>5e5&&(p==2||p==3||p==4))){for(var m=0;m<y;m++)C.encode._filterLine(x,v,m,g,M,p);if(_.push(R.deflate(x)),M==1)break}for(var r,e=1e9,t=0;t<_.length;t++)_[t].length<e&&(r=t,e=_[t].length);return _[r]},C.encode._filterLine=function(v,y,M,g,x,_){var p=M*g,m=p+M,r=C.decode._paeth;if(v[m]=_,m++,_==0)for(var e=0;e<g;e++)v[m+e]=y[p+e];else if(_==1){for(var e=0;e<x;e++)v[m+e]=y[p+e];for(var e=x;e<g;e++)v[m+e]=y[p+e]-y[p+e-x]+256&255}else if(M==0){for(var e=0;e<x;e++)v[m+e]=y[p+e];if(_==2)for(var e=x;e<g;e++)v[m+e]=y[p+e];if(_==3)for(var e=x;e<g;e++)v[m+e]=y[p+e]-(y[p+e-x]>>1)+256&255;if(_==4)for(var e=x;e<g;e++)v[m+e]=y[p+e]-r(y[p+e-x],0,0)+256&255}else{if(_==2)for(var e=0;e<g;e++)v[m+e]=y[p+e]+256-y[p+e-g]&255;if(_==3){for(var e=0;e<x;e++)v[m+e]=y[p+e]+256-(y[p+e-g]>>1)&255;for(var e=x;e<g;e++)v[m+e]=y[p+e]+256-(y[p+e-g]+y[p+e-x]>>1)&255}if(_==4){for(var e=0;e<x;e++)v[m+e]=y[p+e]+256-r(0,y[p+e-g],0)&255;for(var e=x;e<g;e++)v[m+e]=y[p+e]+256-r(y[p+e-x],y[p+e-g],y[p+e-x-g])&255}}},C.crc={table:(function(){for(var v=new Uint32Array(256),y=0;y<256;y++){for(var M=y,g=0;g<8;g++)M&1?M=3988292384^M>>>1:M=M>>>1;v[y]=M}return v})(),update:function(v,y,M,g){for(var x=0;x<g;x++)v=C.crc.table[(v^y[M+x])&255]^v>>>8;return v},crc:function(v,y,M){return C.crc.update(4294967295,v,y,M)^4294967295}},C.quantize=function(v,y,M){for(var g=[],x=0,_=0;_<v.length;_++)g.push(C.encode.alphaMul(new Uint8Array(v[_]),M)),x+=v[_].byteLength;for(var p=new Uint8Array(x),m=new Uint32Array(p.buffer),r=0,_=0;_<g.length;_++){for(var e=g[_],t=e.length,s=0;s<t;s++)p[r+s]=e[s];r+=t}var o={i0:0,i1:p.length,bst:null,est:null,tdst:0,left:null,right:null};o.bst=C.quantize.stats(p,o.i0,o.i1),o.est=C.quantize.estats(o.bst);for(var l=[o];l.length<y;){for(var d=0,i=0,_=0;_<l.length;_++)l[_].est.L>d&&(d=l[_].est.L,i=_);if(d<.001)break;var n=l[i],a=C.quantize.splitPixels(p,m,n.i0,n.i1,n.est.e,n.est.eMq255),h={i0:n.i0,i1:a,bst:null,est:null,tdst:0,left:null,right:null};h.bst=C.quantize.stats(p,h.i0,h.i1),h.est=C.quantize.estats(h.bst);var u={i0:a,i1:n.i1,bst:null,est:null,tdst:0,left:null,right:null};u.bst={R:[],m:[],N:n.bst.N-h.bst.N};for(var _=0;_<16;_++)u.bst.R[_]=n.bst.R[_]-h.bst.R[_];for(var _=0;_<4;_++)u.bst.m[_]=n.bst.m[_]-h.bst.m[_];u.est=C.quantize.estats(u.bst),n.left=h,n.right=u,l[i]=h,l.push(u)}l.sort(function(I,G){return G.bst.N-I.bst.N});for(var A=0;A<g.length;A++){for(var D=C.quantize.planeDst,T=new Uint8Array(g[A].buffer),S=new Uint32Array(g[A].buffer),P=T.length,_=0;_<P;_+=4){for(var z=T[_]*.00392156862745098,F=T[_+1]*(1/255),B=T[_+2]*(1/255),W=T[_+3]*(1/255),U=o;U.left;)U=D(U.est,z,F,B,W)<=0?U.left:U.right;S[_>>2]=U.est.rgba}g[A]=S.buffer}return{bufs:g,plte:l}},C.quantize.getNearest=function(v,y,M,g,x){if(v.left==null)return v.tdst=C.quantize.dist(v.est.q,y,M,g,x),v;var _=C.quantize.planeDst(v.est,y,M,g,x),p=v.left,m=v.right;_>0&&(p=v.right,m=v.left);var r=C.quantize.getNearest(p,y,M,g,x);if(r.tdst<=_*_)return r;var e=C.quantize.getNearest(m,y,M,g,x);return e.tdst<r.tdst?e:r},C.quantize.planeDst=function(v,y,M,g,x){var _=v.e;return _[0]*y+_[1]*M+_[2]*g+_[3]*x-v.eMq},C.quantize.dist=function(v,y,M,g,x){var _=y-v[0],p=M-v[1],m=g-v[2],r=x-v[3];return _*_+p*p+m*m+r*r},C.quantize.splitPixels=function(v,y,M,g,x,_){var p=C.quantize.vecDot;for(g-=4;M<g;){for(;p(v,M,x)<=_;)M+=4;for(;p(v,g,x)>_;)g-=4;if(M>=g)break;var m=y[M>>2];y[M>>2]=y[g>>2],y[g>>2]=m,M+=4,g-=4}for(;p(v,M,x)>_;)M-=4;return M+4},C.quantize.vecDot=function(v,y,M){return v[y]*M[0]+v[y+1]*M[1]+v[y+2]*M[2]+v[y+3]*M[3]},C.quantize.stats=function(v,y,M){for(var g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=[0,0,0,0],_=M-y>>2,p=y;p<M;p+=4){var m=v[p]*.00392156862745098,r=v[p+1]*(1/255),e=v[p+2]*(1/255),t=v[p+3]*(1/255);x[0]+=m,x[1]+=r,x[2]+=e,x[3]+=t,g[0]+=m*m,g[1]+=m*r,g[2]+=m*e,g[3]+=m*t,g[5]+=r*r,g[6]+=r*e,g[7]+=r*t,g[10]+=e*e,g[11]+=e*t,g[15]+=t*t}return g[4]=g[1],g[8]=g[2],g[12]=g[3],g[9]=g[6],g[13]=g[7],g[14]=g[11],{R:g,m:x,N:_}},C.quantize.estats=function(v){var y=v.R,M=v.m,g=v.N,x=M[0],_=M[1],p=M[2],m=M[3],r=g==0?0:1/g,e=[y[0]-x*x*r,y[1]-x*_*r,y[2]-x*p*r,y[3]-x*m*r,y[4]-_*x*r,y[5]-_*_*r,y[6]-_*p*r,y[7]-_*m*r,y[8]-p*x*r,y[9]-p*_*r,y[10]-p*p*r,y[11]-p*m*r,y[12]-m*x*r,y[13]-m*_*r,y[14]-m*p*r,y[15]-m*m*r],t=e,s=C.M4,o=[.5,.5,.5,.5],l=0,d=0;if(g!=0)for(var i=0;i<10&&(o=s.multVec(t,o),d=Math.sqrt(s.dot(o,o)),o=s.sml(1/d,o),!(Math.abs(d-l)<1e-9));i++)l=d;var n=[x*r,_*r,p*r,m*r],a=s.dot(s.sml(255,n),o),h=n[3]<.001?0:1/n[3];return{Cov:e,q:n,e:o,L:l,eMq255:a,eMq:s.dot(o,n),rgba:(Math.round(255*n[3])<<24|Math.round(255*n[2]*h)<<16|Math.round(255*n[1]*h)<<8|Math.round(255*n[0]*h)<<0)>>>0}},C.M4={multVec:function(v,y){return[v[0]*y[0]+v[1]*y[1]+v[2]*y[2]+v[3]*y[3],v[4]*y[0]+v[5]*y[1]+v[6]*y[2]+v[7]*y[3],v[8]*y[0]+v[9]*y[1]+v[10]*y[2]+v[11]*y[3],v[12]*y[0]+v[13]*y[1]+v[14]*y[2]+v[15]*y[3]]},dot:function(v,y){return v[0]*y[0]+v[1]*y[1]+v[2]*y[2]+v[3]*y[3]},sml:function(v,y){return[v*y[0],v*y[1],v*y[2],v*y[3]]}},C.encode.alphaMul=function(v,y){for(var M=new Uint8Array(v.length),g=v.length>>2,x=0;x<g;x++){var _=x<<2,p=v[_+3];y&&(p=p<128?0:255);var m=p*(1/255);M[_+0]=v[_+0]*m,M[_+1]=v[_+1]*m,M[_+2]=v[_+2]*m,M[_+3]=p}return M}})(b,O)})()},"./node_modules/upng-js/node_modules/pako/index.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js").assign,O=c("./node_modules/upng-js/node_modules/pako/lib/deflate.js"),C=c("./node_modules/upng-js/node_modules/pako/lib/inflate.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js"),v={};b(v,O,C,R),k.exports=v},"./node_modules/upng-js/node_modules/pako/lib/deflate.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js"),O=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),C=c("./node_modules/upng-js/node_modules/pako/lib/utils/strings.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"),v=c("./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js"),y=Object.prototype.toString,M=0,g=4,x=0,_=1,p=2,m=-1,r=0,e=8;function t(d){if(!(this instanceof t))return new t(d);this.options=O.assign({level:m,method:e,chunkSize:16384,windowBits:15,memLevel:8,strategy:r,to:""},d||{});var i=this.options;i.raw&&i.windowBits>0?i.windowBits=-i.windowBits:i.gzip&&i.windowBits>0&&i.windowBits<16&&(i.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new v,this.strm.avail_out=0;var n=b.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(n!==x)throw new Error(R[n]);if(i.header&&b.deflateSetHeader(this.strm,i.header),i.dictionary){var a;if(typeof i.dictionary=="string"?a=C.string2buf(i.dictionary):y.call(i.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(i.dictionary):a=i.dictionary,n=b.deflateSetDictionary(this.strm,a),n!==x)throw new Error(R[n]);this._dict_set=!0}}t.prototype.push=function(d,i){var n=this.strm,a=this.options.chunkSize,h,u;if(this.ended)return!1;u=i===~~i?i:i===!0?g:M,typeof d=="string"?n.input=C.string2buf(d):y.call(d)==="[object ArrayBuffer]"?n.input=new Uint8Array(d):n.input=d,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new O.Buf8(a),n.next_out=0,n.avail_out=a),h=b.deflate(n,u),h!==_&&h!==x)return this.onEnd(h),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(u===g||u===p))&&(this.options.to==="string"?this.onData(C.buf2binstring(O.shrinkBuf(n.output,n.next_out))):this.onData(O.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&h!==_);return u===g?(h=b.deflateEnd(this.strm),this.onEnd(h),this.ended=!0,h===x):(u===p&&(this.onEnd(x),n.avail_out=0),!0)},t.prototype.onData=function(d){this.chunks.push(d)},t.prototype.onEnd=function(d){d===x&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=O.flattenChunks(this.chunks)),this.chunks=[],this.err=d,this.msg=this.strm.msg};function s(d,i){var n=new t(i);if(n.push(d,!0),n.err)throw n.msg||R[n.err];return n.result}function o(d,i){return i=i||{},i.raw=!0,s(d,i)}function l(d,i){return i=i||{},i.gzip=!0,s(d,i)}w.Deflate=t,w.deflate=s,w.deflateRaw=o,w.gzip=l},"./node_modules/upng-js/node_modules/pako/lib/inflate.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js"),O=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),C=c("./node_modules/upng-js/node_modules/pako/lib/utils/strings.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js"),v=c("./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"),y=c("./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js"),M=c("./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js"),g=Object.prototype.toString;function x(m){if(!(this instanceof x))return new x(m);this.options=O.assign({chunkSize:16384,windowBits:0,to:""},m||{});var r=this.options;r.raw&&r.windowBits>=0&&r.windowBits<16&&(r.windowBits=-r.windowBits,r.windowBits===0&&(r.windowBits=-15)),r.windowBits>=0&&r.windowBits<16&&!(m&&m.windowBits)&&(r.windowBits+=32),r.windowBits>15&&r.windowBits<48&&(r.windowBits&15)===0&&(r.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new y,this.strm.avail_out=0;var e=b.inflateInit2(this.strm,r.windowBits);if(e!==R.Z_OK)throw new Error(v[e]);if(this.header=new M,b.inflateGetHeader(this.strm,this.header),r.dictionary&&(typeof r.dictionary=="string"?r.dictionary=C.string2buf(r.dictionary):g.call(r.dictionary)==="[object ArrayBuffer]"&&(r.dictionary=new Uint8Array(r.dictionary)),r.raw&&(e=b.inflateSetDictionary(this.strm,r.dictionary),e!==R.Z_OK)))throw new Error(v[e])}x.prototype.push=function(m,r){var e=this.strm,t=this.options.chunkSize,s=this.options.dictionary,o,l,d,i,n,a=!1;if(this.ended)return!1;l=r===~~r?r:r===!0?R.Z_FINISH:R.Z_NO_FLUSH,typeof m=="string"?e.input=C.binstring2buf(m):g.call(m)==="[object ArrayBuffer]"?e.input=new Uint8Array(m):e.input=m,e.next_in=0,e.avail_in=e.input.length;do{if(e.avail_out===0&&(e.output=new O.Buf8(t),e.next_out=0,e.avail_out=t),o=b.inflate(e,R.Z_NO_FLUSH),o===R.Z_NEED_DICT&&s&&(o=b.inflateSetDictionary(this.strm,s)),o===R.Z_BUF_ERROR&&a===!0&&(o=R.Z_OK,a=!1),o!==R.Z_STREAM_END&&o!==R.Z_OK)return this.onEnd(o),this.ended=!0,!1;e.next_out&&(e.avail_out===0||o===R.Z_STREAM_END||e.avail_in===0&&(l===R.Z_FINISH||l===R.Z_SYNC_FLUSH))&&(this.options.to==="string"?(d=C.utf8border(e.output,e.next_out),i=e.next_out-d,n=C.buf2string(e.output,d),e.next_out=i,e.avail_out=t-i,i&&O.arraySet(e.output,e.output,d,i,0),this.onData(n)):this.onData(O.shrinkBuf(e.output,e.next_out))),e.avail_in===0&&e.avail_out===0&&(a=!0)}while((e.avail_in>0||e.avail_out===0)&&o!==R.Z_STREAM_END);return o===R.Z_STREAM_END&&(l=R.Z_FINISH),l===R.Z_FINISH?(o=b.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===R.Z_OK):(l===R.Z_SYNC_FLUSH&&(this.onEnd(R.Z_OK),e.avail_out=0),!0)},x.prototype.onData=function(m){this.chunks.push(m)},x.prototype.onEnd=function(m){m===R.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=O.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg};function _(m,r){var e=new x(r);if(e.push(m,!0),e.err)throw e.msg||v[e.err];return e.result}function p(m,r){return r=r||{},r.raw=!0,_(m,r)}w.Inflate=x,w.inflate=_,w.inflateRaw=p,w.ungzip=_},"./node_modules/upng-js/node_modules/pako/lib/utils/common.js"(k,w){var c=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function b(R,v){return Object.prototype.hasOwnProperty.call(R,v)}w.assign=function(R){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var y=v.shift();if(y){if(typeof y!="object")throw new TypeError(y+"must be non-object");for(var M in y)b(y,M)&&(R[M]=y[M])}}return R},w.shrinkBuf=function(R,v){return R.length===v?R:R.subarray?R.subarray(0,v):(R.length=v,R)};var O={arraySet:function(R,v,y,M,g){if(v.subarray&&R.subarray){R.set(v.subarray(y,y+M),g);return}for(var x=0;x<M;x++)R[g+x]=v[y+x]},flattenChunks:function(R){var v,y,M,g,x,_;for(M=0,v=0,y=R.length;v<y;v++)M+=R[v].length;for(_=new Uint8Array(M),g=0,v=0,y=R.length;v<y;v++)x=R[v],_.set(x,g),g+=x.length;return _}},C={arraySet:function(R,v,y,M,g){for(var x=0;x<M;x++)R[g+x]=v[y+x]},flattenChunks:function(R){return[].concat.apply([],R)}};w.setTyped=function(R){R?(w.Buf8=Uint8Array,w.Buf16=Uint16Array,w.Buf32=Int32Array,w.assign(w,O)):(w.Buf8=Array,w.Buf16=Array,w.Buf32=Array,w.assign(w,C))},w.setTyped(c)},"./node_modules/upng-js/node_modules/pako/lib/utils/strings.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=!0,C=!0;try{String.fromCharCode.apply(null,[0])}catch{O=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{C=!1}for(var R=new b.Buf8(256),v=0;v<256;v++)R[v]=v>=252?6:v>=248?5:v>=240?4:v>=224?3:v>=192?2:1;R[254]=R[254]=1,w.string2buf=function(M){var g,x,_,p,m,r=M.length,e=0;for(p=0;p<r;p++)x=M.charCodeAt(p),(x&64512)===55296&&p+1<r&&(_=M.charCodeAt(p+1),(_&64512)===56320&&(x=65536+(x-55296<<10)+(_-56320),p++)),e+=x<128?1:x<2048?2:x<65536?3:4;for(g=new b.Buf8(e),m=0,p=0;m<e;p++)x=M.charCodeAt(p),(x&64512)===55296&&p+1<r&&(_=M.charCodeAt(p+1),(_&64512)===56320&&(x=65536+(x-55296<<10)+(_-56320),p++)),x<128?g[m++]=x:x<2048?(g[m++]=192|x>>>6,g[m++]=128|x&63):x<65536?(g[m++]=224|x>>>12,g[m++]=128|x>>>6&63,g[m++]=128|x&63):(g[m++]=240|x>>>18,g[m++]=128|x>>>12&63,g[m++]=128|x>>>6&63,g[m++]=128|x&63);return g};function y(M,g){if(g<65534&&(M.subarray&&C||!M.subarray&&O))return String.fromCharCode.apply(null,b.shrinkBuf(M,g));for(var x="",_=0;_<g;_++)x+=String.fromCharCode(M[_]);return x}w.buf2binstring=function(M){return y(M,M.length)},w.binstring2buf=function(M){for(var g=new b.Buf8(M.length),x=0,_=g.length;x<_;x++)g[x]=M.charCodeAt(x);return g},w.buf2string=function(M,g){var x,_,p,m,r=g||M.length,e=new Array(r*2);for(_=0,x=0;x<r;){if(p=M[x++],p<128){e[_++]=p;continue}if(m=R[p],m>4){e[_++]=65533,x+=m-1;continue}for(p&=m===2?31:m===3?15:7;m>1&&x<r;)p=p<<6|M[x++]&63,m--;if(m>1){e[_++]=65533;continue}p<65536?e[_++]=p:(p-=65536,e[_++]=55296|p>>10&1023,e[_++]=56320|p&1023)}return y(e,_)},w.utf8border=function(M,g){var x;for(g=g||M.length,g>M.length&&(g=M.length),x=g-1;x>=0&&(M[x]&192)===128;)x--;return x<0||x===0?g:x+R[M[x]]>g?x:g}},"./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js"(k){function w(c,b,O,C){for(var R=c&65535|0,v=c>>>16&65535|0,y=0;O!==0;){y=O>2e3?2e3:O,O-=y;do R=R+b[C++]|0,v=v+R|0;while(--y);R%=65521,v%=65521}return R|v<<16|0}k.exports=w},"./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js"(k){k.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}},"./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js"(k){function w(){for(var O,C=[],R=0;R<256;R++){O=R;for(var v=0;v<8;v++)O=O&1?3988292384^O>>>1:O>>>1;C[R]=O}return C}var c=w();function b(O,C,R,v){var y=c,M=v+R;O^=-1;for(var g=v;g<M;g++)O=O>>>8^y[(O^C[g])&255];return O^-1}k.exports=b},"./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=c("./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js"),C=c("./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js"),v=c("./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"),y=0,M=1,g=3,x=4,_=5,p=0,m=1,r=-2,e=-3,t=-5,s=-1,o=1,l=2,d=3,i=4,n=0,a=2,h=8,u=9,A=15,D=8,T=29,S=256,P=S+1+T,z=30,F=19,B=2*P+1,W=15,U=3,I=258,G=I+U+1,Y=32,J=42,te=69,ne=73,le=91,ie=103,oe=113,xe=666,_e=1,Oe=2,ye=3,ee=4,pe=3;function Ce(L,he){return L.msg=v[he],he}function Te(L){return(L<<1)-(L>4?9:0)}function We(L){for(var he=L.length;--he>=0;)L[he]=0}function Ie(L){var he=L.state,fe=he.pending;fe>L.avail_out&&(fe=L.avail_out),fe!==0&&(b.arraySet(L.output,he.pending_buf,he.pending_out,fe,L.next_out),L.next_out+=fe,he.pending_out+=fe,L.total_out+=fe,L.avail_out-=fe,he.pending-=fe,he.pending===0&&(he.pending_out=0))}function Be(L,he){O._tr_flush_block(L,L.block_start>=0?L.block_start:-1,L.strstart-L.block_start,he),L.block_start=L.strstart,Ie(L.strm)}function Fe(L,he){L.pending_buf[L.pending++]=he}function ze(L,he){L.pending_buf[L.pending++]=he>>>8&255,L.pending_buf[L.pending++]=he&255}function Pe(L,he,fe,H){var ae=L.avail_in;return ae>H&&(ae=H),ae===0?0:(L.avail_in-=ae,b.arraySet(he,L.input,L.next_in,ae,fe),L.state.wrap===1?L.adler=C(L.adler,he,ae,fe):L.state.wrap===2&&(L.adler=R(L.adler,he,ae,fe)),L.next_in+=ae,L.total_in+=ae,ae)}function Re(L,he){var fe=L.max_chain_length,H=L.strstart,ae,ve,Ve=L.prev_length,Ne=L.nice_match,Ge=L.strstart>L.w_size-G?L.strstart-(L.w_size-G):0,qe=L.window,_t=L.w_mask,Ye=L.prev,He=L.strstart+I,$e=qe[H+Ve-1],tt=qe[H+Ve];L.prev_length>=L.good_match&&(fe>>=2),Ne>L.lookahead&&(Ne=L.lookahead);do if(ae=he,!(qe[ae+Ve]!==tt||qe[ae+Ve-1]!==$e||qe[ae]!==qe[H]||qe[++ae]!==qe[H+1])){H+=2,ae++;do;while(qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&qe[++H]===qe[++ae]&&H<He);if(ve=I-(He-H),H=He-I,ve>Ve){if(L.match_start=he,Ve=ve,ve>=Ne)break;$e=qe[H+Ve-1],tt=qe[H+Ve]}}while((he=Ye[he&_t])>Ge&&--fe!==0);return Ve<=L.lookahead?Ve:L.lookahead}function je(L){var he=L.w_size,fe,H,ae,ve,Ve;do{if(ve=L.window_size-L.lookahead-L.strstart,L.strstart>=he+(he-G)){b.arraySet(L.window,L.window,he,he,0),L.match_start-=he,L.strstart-=he,L.block_start-=he,H=L.hash_size,fe=H;do ae=L.head[--fe],L.head[fe]=ae>=he?ae-he:0;while(--H);H=he,fe=H;do ae=L.prev[--fe],L.prev[fe]=ae>=he?ae-he:0;while(--H);ve+=he}if(L.strm.avail_in===0)break;if(H=Pe(L.strm,L.window,L.strstart+L.lookahead,ve),L.lookahead+=H,L.lookahead+L.insert>=U)for(Ve=L.strstart-L.insert,L.ins_h=L.window[Ve],L.ins_h=(L.ins_h<<L.hash_shift^L.window[Ve+1])&L.hash_mask;L.insert&&(L.ins_h=(L.ins_h<<L.hash_shift^L.window[Ve+U-1])&L.hash_mask,L.prev[Ve&L.w_mask]=L.head[L.ins_h],L.head[L.ins_h]=Ve,Ve++,L.insert--,!(L.lookahead+L.insert<U)););}while(L.lookahead<G&&L.strm.avail_in!==0)}function ke(L,he){var fe=65535;for(fe>L.pending_buf_size-5&&(fe=L.pending_buf_size-5);;){if(L.lookahead<=1){if(je(L),L.lookahead===0&&he===y)return _e;if(L.lookahead===0)break}L.strstart+=L.lookahead,L.lookahead=0;var H=L.block_start+fe;if((L.strstart===0||L.strstart>=H)&&(L.lookahead=L.strstart-H,L.strstart=H,Be(L,!1),L.strm.avail_out===0)||L.strstart-L.block_start>=L.w_size-G&&(Be(L,!1),L.strm.avail_out===0))return _e}return L.insert=0,he===x?(Be(L,!0),L.strm.avail_out===0?ye:ee):(L.strstart>L.block_start&&(Be(L,!1),L.strm.avail_out===0),_e)}function K(L,he){for(var fe,H;;){if(L.lookahead<G){if(je(L),L.lookahead<G&&he===y)return _e;if(L.lookahead===0)break}if(fe=0,L.lookahead>=U&&(L.ins_h=(L.ins_h<<L.hash_shift^L.window[L.strstart+U-1])&L.hash_mask,fe=L.prev[L.strstart&L.w_mask]=L.head[L.ins_h],L.head[L.ins_h]=L.strstart),fe!==0&&L.strstart-fe<=L.w_size-G&&(L.match_length=Re(L,fe)),L.match_length>=U)if(H=O._tr_tally(L,L.strstart-L.match_start,L.match_length-U),L.lookahead-=L.match_length,L.match_length<=L.max_lazy_match&&L.lookahead>=U){L.match_length--;do L.strstart++,L.ins_h=(L.ins_h<<L.hash_shift^L.window[L.strstart+U-1])&L.hash_mask,fe=L.prev[L.strstart&L.w_mask]=L.head[L.ins_h],L.head[L.ins_h]=L.strstart;while(--L.match_length!==0);L.strstart++}else L.strstart+=L.match_length,L.match_length=0,L.ins_h=L.window[L.strstart],L.ins_h=(L.ins_h<<L.hash_shift^L.window[L.strstart+1])&L.hash_mask;else H=O._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++;if(H&&(Be(L,!1),L.strm.avail_out===0))return _e}return L.insert=L.strstart<U-1?L.strstart:U-1,he===x?(Be(L,!0),L.strm.avail_out===0?ye:ee):L.last_lit&&(Be(L,!1),L.strm.avail_out===0)?_e:Oe}function Z(L,he){for(var fe,H,ae;;){if(L.lookahead<G){if(je(L),L.lookahead<G&&he===y)return _e;if(L.lookahead===0)break}if(fe=0,L.lookahead>=U&&(L.ins_h=(L.ins_h<<L.hash_shift^L.window[L.strstart+U-1])&L.hash_mask,fe=L.prev[L.strstart&L.w_mask]=L.head[L.ins_h],L.head[L.ins_h]=L.strstart),L.prev_length=L.match_length,L.prev_match=L.match_start,L.match_length=U-1,fe!==0&&L.prev_length<L.max_lazy_match&&L.strstart-fe<=L.w_size-G&&(L.match_length=Re(L,fe),L.match_length<=5&&(L.strategy===o||L.match_length===U&&L.strstart-L.match_start>4096)&&(L.match_length=U-1)),L.prev_length>=U&&L.match_length<=L.prev_length){ae=L.strstart+L.lookahead-U,H=O._tr_tally(L,L.strstart-1-L.prev_match,L.prev_length-U),L.lookahead-=L.prev_length-1,L.prev_length-=2;do++L.strstart<=ae&&(L.ins_h=(L.ins_h<<L.hash_shift^L.window[L.strstart+U-1])&L.hash_mask,fe=L.prev[L.strstart&L.w_mask]=L.head[L.ins_h],L.head[L.ins_h]=L.strstart);while(--L.prev_length!==0);if(L.match_available=0,L.match_length=U-1,L.strstart++,H&&(Be(L,!1),L.strm.avail_out===0))return _e}else if(L.match_available){if(H=O._tr_tally(L,0,L.window[L.strstart-1]),H&&Be(L,!1),L.strstart++,L.lookahead--,L.strm.avail_out===0)return _e}else L.match_available=1,L.strstart++,L.lookahead--}return L.match_available&&(H=O._tr_tally(L,0,L.window[L.strstart-1]),L.match_available=0),L.insert=L.strstart<U-1?L.strstart:U-1,he===x?(Be(L,!0),L.strm.avail_out===0?ye:ee):L.last_lit&&(Be(L,!1),L.strm.avail_out===0)?_e:Oe}function $(L,he){for(var fe,H,ae,ve,Ve=L.window;;){if(L.lookahead<=I){if(je(L),L.lookahead<=I&&he===y)return _e;if(L.lookahead===0)break}if(L.match_length=0,L.lookahead>=U&&L.strstart>0&&(ae=L.strstart-1,H=Ve[ae],H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae])){ve=L.strstart+I;do;while(H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&H===Ve[++ae]&&ae<ve);L.match_length=I-(ve-ae),L.match_length>L.lookahead&&(L.match_length=L.lookahead)}if(L.match_length>=U?(fe=O._tr_tally(L,1,L.match_length-U),L.lookahead-=L.match_length,L.strstart+=L.match_length,L.match_length=0):(fe=O._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++),fe&&(Be(L,!1),L.strm.avail_out===0))return _e}return L.insert=0,he===x?(Be(L,!0),L.strm.avail_out===0?ye:ee):L.last_lit&&(Be(L,!1),L.strm.avail_out===0)?_e:Oe}function me(L,he){for(var fe;;){if(L.lookahead===0&&(je(L),L.lookahead===0)){if(he===y)return _e;break}if(L.match_length=0,fe=O._tr_tally(L,0,L.window[L.strstart]),L.lookahead--,L.strstart++,fe&&(Be(L,!1),L.strm.avail_out===0))return _e}return L.insert=0,he===x?(Be(L,!0),L.strm.avail_out===0?ye:ee):L.last_lit&&(Be(L,!1),L.strm.avail_out===0)?_e:Oe}function ce(L,he,fe,H,ae){this.good_length=L,this.max_lazy=he,this.nice_length=fe,this.max_chain=H,this.func=ae}var Me;Me=[new ce(0,0,0,0,ke),new ce(4,4,8,4,K),new ce(4,5,16,8,K),new ce(4,6,32,32,K),new ce(4,4,16,16,Z),new ce(8,16,32,32,Z),new ce(8,16,128,128,Z),new ce(8,32,128,256,Z),new ce(32,128,258,1024,Z),new ce(32,258,258,4096,Z)];function we(L){L.window_size=2*L.w_size,We(L.head),L.max_lazy_match=Me[L.level].max_lazy,L.good_match=Me[L.level].good_length,L.nice_match=Me[L.level].nice_length,L.max_chain_length=Me[L.level].max_chain,L.strstart=0,L.block_start=0,L.lookahead=0,L.insert=0,L.match_length=L.prev_length=U-1,L.match_available=0,L.ins_h=0}function j(){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=h,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 b.Buf16(B*2),this.dyn_dtree=new b.Buf16((2*z+1)*2),this.bl_tree=new b.Buf16((2*F+1)*2),We(this.dyn_ltree),We(this.dyn_dtree),We(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new b.Buf16(W+1),this.heap=new b.Buf16(2*P+1),We(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new b.Buf16(2*P+1),We(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 se(L){var he;return!L||!L.state?Ce(L,r):(L.total_in=L.total_out=0,L.data_type=a,he=L.state,he.pending=0,he.pending_out=0,he.wrap<0&&(he.wrap=-he.wrap),he.status=he.wrap?J:oe,L.adler=he.wrap===2?0:1,he.last_flush=y,O._tr_init(he),p)}function ge(L){var he=se(L);return he===p&&we(L.state),he}function Se(L,he){return!L||!L.state||L.state.wrap!==2?r:(L.state.gzhead=he,p)}function re(L,he,fe,H,ae,ve){if(!L)return r;var Ve=1;if(he===s&&(he=6),H<0?(Ve=0,H=-H):H>15&&(Ve=2,H-=16),ae<1||ae>u||fe!==h||H<8||H>15||he<0||he>9||ve<0||ve>i)return Ce(L,r);H===8&&(H=9);var Ne=new j;return L.state=Ne,Ne.strm=L,Ne.wrap=Ve,Ne.gzhead=null,Ne.w_bits=H,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=ae+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+U-1)/U),Ne.window=new b.Buf8(Ne.w_size*2),Ne.head=new b.Buf16(Ne.hash_size),Ne.prev=new b.Buf16(Ne.w_size),Ne.lit_bufsize=1<<ae+6,Ne.pending_buf_size=Ne.lit_bufsize*4,Ne.pending_buf=new b.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=he,Ne.strategy=ve,Ne.method=fe,ge(L)}function be(L,he){return re(L,he,h,A,D,n)}function V(L,he){var fe,H,ae,ve;if(!L||!L.state||he>_||he<0)return L?Ce(L,r):r;if(H=L.state,!L.output||!L.input&&L.avail_in!==0||H.status===xe&&he!==x)return Ce(L,L.avail_out===0?t:r);if(H.strm=L,fe=H.last_flush,H.last_flush=he,H.status===J)if(H.wrap===2)L.adler=0,Fe(H,31),Fe(H,139),Fe(H,8),H.gzhead?(Fe(H,(H.gzhead.text?1:0)+(H.gzhead.hcrc?2:0)+(H.gzhead.extra?4:0)+(H.gzhead.name?8:0)+(H.gzhead.comment?16:0)),Fe(H,H.gzhead.time&255),Fe(H,H.gzhead.time>>8&255),Fe(H,H.gzhead.time>>16&255),Fe(H,H.gzhead.time>>24&255),Fe(H,H.level===9?2:H.strategy>=l||H.level<2?4:0),Fe(H,H.gzhead.os&255),H.gzhead.extra&&H.gzhead.extra.length&&(Fe(H,H.gzhead.extra.length&255),Fe(H,H.gzhead.extra.length>>8&255)),H.gzhead.hcrc&&(L.adler=R(L.adler,H.pending_buf,H.pending,0)),H.gzindex=0,H.status=te):(Fe(H,0),Fe(H,0),Fe(H,0),Fe(H,0),Fe(H,0),Fe(H,H.level===9?2:H.strategy>=l||H.level<2?4:0),Fe(H,pe),H.status=oe);else{var Ve=h+(H.w_bits-8<<4)<<8,Ne=-1;H.strategy>=l||H.level<2?Ne=0:H.level<6?Ne=1:H.level===6?Ne=2:Ne=3,Ve|=Ne<<6,H.strstart!==0&&(Ve|=Y),Ve+=31-Ve%31,H.status=oe,ze(H,Ve),H.strstart!==0&&(ze(H,L.adler>>>16),ze(H,L.adler&65535)),L.adler=1}if(H.status===te)if(H.gzhead.extra){for(ae=H.pending;H.gzindex<(H.gzhead.extra.length&65535)&&!(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),Ie(L),ae=H.pending,H.pending===H.pending_buf_size));)Fe(H,H.gzhead.extra[H.gzindex]&255),H.gzindex++;H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),H.gzindex===H.gzhead.extra.length&&(H.gzindex=0,H.status=ne)}else H.status=ne;if(H.status===ne)if(H.gzhead.name){ae=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),Ie(L),ae=H.pending,H.pending===H.pending_buf_size)){ve=1;break}H.gzindex<H.gzhead.name.length?ve=H.gzhead.name.charCodeAt(H.gzindex++)&255:ve=0,Fe(H,ve)}while(ve!==0);H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),ve===0&&(H.gzindex=0,H.status=le)}else H.status=le;if(H.status===le)if(H.gzhead.comment){ae=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),Ie(L),ae=H.pending,H.pending===H.pending_buf_size)){ve=1;break}H.gzindex<H.gzhead.comment.length?ve=H.gzhead.comment.charCodeAt(H.gzindex++)&255:ve=0,Fe(H,ve)}while(ve!==0);H.gzhead.hcrc&&H.pending>ae&&(L.adler=R(L.adler,H.pending_buf,H.pending-ae,ae)),ve===0&&(H.status=ie)}else H.status=ie;if(H.status===ie&&(H.gzhead.hcrc?(H.pending+2>H.pending_buf_size&&Ie(L),H.pending+2<=H.pending_buf_size&&(Fe(H,L.adler&255),Fe(H,L.adler>>8&255),L.adler=0,H.status=oe)):H.status=oe),H.pending!==0){if(Ie(L),L.avail_out===0)return H.last_flush=-1,p}else if(L.avail_in===0&&Te(he)<=Te(fe)&&he!==x)return Ce(L,t);if(H.status===xe&&L.avail_in!==0)return Ce(L,t);if(L.avail_in!==0||H.lookahead!==0||he!==y&&H.status!==xe){var Ge=H.strategy===l?me(H,he):H.strategy===d?$(H,he):Me[H.level].func(H,he);if((Ge===ye||Ge===ee)&&(H.status=xe),Ge===_e||Ge===ye)return L.avail_out===0&&(H.last_flush=-1),p;if(Ge===Oe&&(he===M?O._tr_align(H):he!==_&&(O._tr_stored_block(H,0,0,!1),he===g&&(We(H.head),H.lookahead===0&&(H.strstart=0,H.block_start=0,H.insert=0))),Ie(L),L.avail_out===0))return H.last_flush=-1,p}return he!==x?p:H.wrap<=0?m:(H.wrap===2?(Fe(H,L.adler&255),Fe(H,L.adler>>8&255),Fe(H,L.adler>>16&255),Fe(H,L.adler>>24&255),Fe(H,L.total_in&255),Fe(H,L.total_in>>8&255),Fe(H,L.total_in>>16&255),Fe(H,L.total_in>>24&255)):(ze(H,L.adler>>>16),ze(H,L.adler&65535)),Ie(L),H.wrap>0&&(H.wrap=-H.wrap),H.pending!==0?p:m)}function De(L){var he;return!L||!L.state?r:(he=L.state.status,he!==J&&he!==te&&he!==ne&&he!==le&&he!==ie&&he!==oe&&he!==xe?Ce(L,r):(L.state=null,he===oe?Ce(L,e):p))}function Le(L,he){var fe=he.length,H,ae,ve,Ve,Ne,Ge,qe,_t;if(!L||!L.state||(H=L.state,Ve=H.wrap,Ve===2||Ve===1&&H.status!==J||H.lookahead))return r;for(Ve===1&&(L.adler=C(L.adler,he,fe,0)),H.wrap=0,fe>=H.w_size&&(Ve===0&&(We(H.head),H.strstart=0,H.block_start=0,H.insert=0),_t=new b.Buf8(H.w_size),b.arraySet(_t,he,fe-H.w_size,H.w_size,0),he=_t,fe=H.w_size),Ne=L.avail_in,Ge=L.next_in,qe=L.input,L.avail_in=fe,L.next_in=0,L.input=he,je(H);H.lookahead>=U;){ae=H.strstart,ve=H.lookahead-(U-1);do H.ins_h=(H.ins_h<<H.hash_shift^H.window[ae+U-1])&H.hash_mask,H.prev[ae&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=ae,ae++;while(--ve);H.strstart=ae,H.lookahead=U-1,je(H)}return H.strstart+=H.lookahead,H.block_start=H.strstart,H.insert=H.lookahead,H.lookahead=0,H.match_length=H.prev_length=U-1,H.match_available=0,L.next_in=Ge,L.input=qe,L.avail_in=Ne,H.wrap=Ve,p}w.deflateInit=be,w.deflateInit2=re,w.deflateReset=ge,w.deflateResetKeep=se,w.deflateSetHeader=Se,w.deflate=V,w.deflateEnd=De,w.deflateSetDictionary=Le,w.deflateInfo="pako deflate (from Nodeca project)"},"./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js"(k){function w(){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}k.exports=w},"./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js"(k){var w=30,c=12;k.exports=function(O,C){var R,v,y,M,g,x,_,p,m,r,e,t,s,o,l,d,i,n,a,h,u,A,D,T,S;R=O.state,v=O.next_in,T=O.input,y=v+(O.avail_in-5),M=O.next_out,S=O.output,g=M-(C-O.avail_out),x=M+(O.avail_out-257),_=R.dmax,p=R.wsize,m=R.whave,r=R.wnext,e=R.window,t=R.hold,s=R.bits,o=R.lencode,l=R.distcode,d=(1<<R.lenbits)-1,i=(1<<R.distbits)-1;e:do{s<15&&(t+=T[v++]<<s,s+=8,t+=T[v++]<<s,s+=8),n=o[t&d];t:for(;;){if(a=n>>>24,t>>>=a,s-=a,a=n>>>16&255,a===0)S[M++]=n&65535;else if(a&16){h=n&65535,a&=15,a&&(s<a&&(t+=T[v++]<<s,s+=8),h+=t&(1<<a)-1,t>>>=a,s-=a),s<15&&(t+=T[v++]<<s,s+=8,t+=T[v++]<<s,s+=8),n=l[t&i];i:for(;;){if(a=n>>>24,t>>>=a,s-=a,a=n>>>16&255,a&16){if(u=n&65535,a&=15,s<a&&(t+=T[v++]<<s,s+=8,s<a&&(t+=T[v++]<<s,s+=8)),u+=t&(1<<a)-1,u>_){O.msg="invalid distance too far back",R.mode=w;break e}if(t>>>=a,s-=a,a=M-g,u>a){if(a=u-a,a>m&&R.sane){O.msg="invalid distance too far back",R.mode=w;break e}if(A=0,D=e,r===0){if(A+=p-a,a<h){h-=a;do S[M++]=e[A++];while(--a);A=M-u,D=S}}else if(r<a){if(A+=p+r-a,a-=r,a<h){h-=a;do S[M++]=e[A++];while(--a);if(A=0,r<h){a=r,h-=a;do S[M++]=e[A++];while(--a);A=M-u,D=S}}}else if(A+=r-a,a<h){h-=a;do S[M++]=e[A++];while(--a);A=M-u,D=S}for(;h>2;)S[M++]=D[A++],S[M++]=D[A++],S[M++]=D[A++],h-=3;h&&(S[M++]=D[A++],h>1&&(S[M++]=D[A++]))}else{A=M-u;do S[M++]=S[A++],S[M++]=S[A++],S[M++]=S[A++],h-=3;while(h>2);h&&(S[M++]=S[A++],h>1&&(S[M++]=S[A++]))}}else if((a&64)===0){n=l[(n&65535)+(t&(1<<a)-1)];continue i}else{O.msg="invalid distance code",R.mode=w;break e}break}}else if((a&64)===0){n=o[(n&65535)+(t&(1<<a)-1)];continue t}else if(a&32){R.mode=c;break e}else{O.msg="invalid literal/length code",R.mode=w;break e}break}}while(v<y&&M<x);h=s>>3,v-=h,s-=h<<3,t&=(1<<s)-1,O.next_in=v,O.next_out=M,O.avail_in=v<y?5+(y-v):5-(v-y),O.avail_out=M<x?257+(x-M):257-(M-x),R.hold=t,R.bits=s}},"./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=c("./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js"),C=c("./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js"),v=c("./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js"),y=0,M=1,g=2,x=4,_=5,p=6,m=0,r=1,e=2,t=-2,s=-3,o=-4,l=-5,d=8,i=1,n=2,a=3,h=4,u=5,A=6,D=7,T=8,S=9,P=10,z=11,F=12,B=13,W=14,U=15,I=16,G=17,Y=18,J=19,te=20,ne=21,le=22,ie=23,oe=24,xe=25,_e=26,Oe=27,ye=28,ee=29,pe=30,Ce=31,Te=32,We=852,Ie=592,Be=15,Fe=Be;function ze(re){return(re>>>24&255)+(re>>>8&65280)+((re&65280)<<8)+((re&255)<<24)}function Pe(){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 b.Buf16(320),this.work=new b.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Re(re){var be;return!re||!re.state?t:(be=re.state,re.total_in=re.total_out=be.total=0,re.msg="",be.wrap&&(re.adler=be.wrap&1),be.mode=i,be.last=0,be.havedict=0,be.dmax=32768,be.head=null,be.hold=0,be.bits=0,be.lencode=be.lendyn=new b.Buf32(We),be.distcode=be.distdyn=new b.Buf32(Ie),be.sane=1,be.back=-1,m)}function je(re){var be;return!re||!re.state?t:(be=re.state,be.wsize=0,be.whave=0,be.wnext=0,Re(re))}function ke(re,be){var V,De;return!re||!re.state||(De=re.state,be<0?(V=0,be=-be):(V=(be>>4)+1,be<48&&(be&=15)),be&&(be<8||be>15))?t:(De.window!==null&&De.wbits!==be&&(De.window=null),De.wrap=V,De.wbits=be,je(re))}function K(re,be){var V,De;return re?(De=new Pe,re.state=De,De.window=null,V=ke(re,be),V!==m&&(re.state=null),V):t}function Z(re){return K(re,Fe)}var $=!0,me,ce;function Me(re){if($){var be;for(me=new b.Buf32(512),ce=new b.Buf32(32),be=0;be<144;)re.lens[be++]=8;for(;be<256;)re.lens[be++]=9;for(;be<280;)re.lens[be++]=7;for(;be<288;)re.lens[be++]=8;for(v(M,re.lens,0,288,me,0,re.work,{bits:9}),be=0;be<32;)re.lens[be++]=5;v(g,re.lens,0,32,ce,0,re.work,{bits:5}),$=!1}re.lencode=me,re.lenbits=9,re.distcode=ce,re.distbits=5}function we(re,be,V,De){var Le,L=re.state;return L.window===null&&(L.wsize=1<<L.wbits,L.wnext=0,L.whave=0,L.window=new b.Buf8(L.wsize)),De>=L.wsize?(b.arraySet(L.window,be,V-L.wsize,L.wsize,0),L.wnext=0,L.whave=L.wsize):(Le=L.wsize-L.wnext,Le>De&&(Le=De),b.arraySet(L.window,be,V-De,Le,L.wnext),De-=Le,De?(b.arraySet(L.window,be,V-De,De,0),L.wnext=De,L.whave=L.wsize):(L.wnext+=Le,L.wnext===L.wsize&&(L.wnext=0),L.whave<L.wsize&&(L.whave+=Le))),0}function j(re,be){var V,De,Le,L,he,fe,H,ae,ve,Ve,Ne,Ge,qe,_t,Ye=0,He,$e,tt,et,bt,xt,st,lt,dt=new b.Buf8(4),vt,Mt,At=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!re||!re.state||!re.output||!re.input&&re.avail_in!==0)return t;V=re.state,V.mode===F&&(V.mode=B),he=re.next_out,Le=re.output,H=re.avail_out,L=re.next_in,De=re.input,fe=re.avail_in,ae=V.hold,ve=V.bits,Ve=fe,Ne=H,lt=m;e:for(;;)switch(V.mode){case i:if(V.wrap===0){V.mode=B;break}for(;ve<16;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(V.wrap&2&&ae===35615){V.check=0,dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=C(V.check,dt,2,0),ae=0,ve=0,V.mode=n;break}if(V.flags=0,V.head&&(V.head.done=!1),!(V.wrap&1)||(((ae&255)<<8)+(ae>>8))%31){re.msg="incorrect header check",V.mode=pe;break}if((ae&15)!==d){re.msg="unknown compression method",V.mode=pe;break}if(ae>>>=4,ve-=4,st=(ae&15)+8,V.wbits===0)V.wbits=st;else if(st>V.wbits){re.msg="invalid window size",V.mode=pe;break}V.dmax=1<<st,re.adler=V.check=1,V.mode=ae&512?P:F,ae=0,ve=0;break;case n:for(;ve<16;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(V.flags=ae,(V.flags&255)!==d){re.msg="unknown compression method",V.mode=pe;break}if(V.flags&57344){re.msg="unknown header flags set",V.mode=pe;break}V.head&&(V.head.text=ae>>8&1),V.flags&512&&(dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=C(V.check,dt,2,0)),ae=0,ve=0,V.mode=a;case a:for(;ve<32;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.head&&(V.head.time=ae),V.flags&512&&(dt[0]=ae&255,dt[1]=ae>>>8&255,dt[2]=ae>>>16&255,dt[3]=ae>>>24&255,V.check=C(V.check,dt,4,0)),ae=0,ve=0,V.mode=h;case h:for(;ve<16;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.head&&(V.head.xflags=ae&255,V.head.os=ae>>8),V.flags&512&&(dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=C(V.check,dt,2,0)),ae=0,ve=0,V.mode=u;case u:if(V.flags&1024){for(;ve<16;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.length=ae,V.head&&(V.head.extra_len=ae),V.flags&512&&(dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=C(V.check,dt,2,0)),ae=0,ve=0}else V.head&&(V.head.extra=null);V.mode=A;case A:if(V.flags&1024&&(Ge=V.length,Ge>fe&&(Ge=fe),Ge&&(V.head&&(st=V.head.extra_len-V.length,V.head.extra||(V.head.extra=new Array(V.head.extra_len)),b.arraySet(V.head.extra,De,L,Ge,st)),V.flags&512&&(V.check=C(V.check,De,Ge,L)),fe-=Ge,L+=Ge,V.length-=Ge),V.length))break e;V.length=0,V.mode=D;case D:if(V.flags&2048){if(fe===0)break e;Ge=0;do st=De[L+Ge++],V.head&&st&&V.length<65536&&(V.head.name+=String.fromCharCode(st));while(st&&Ge<fe);if(V.flags&512&&(V.check=C(V.check,De,Ge,L)),fe-=Ge,L+=Ge,st)break e}else V.head&&(V.head.name=null);V.length=0,V.mode=T;case T:if(V.flags&4096){if(fe===0)break e;Ge=0;do st=De[L+Ge++],V.head&&st&&V.length<65536&&(V.head.comment+=String.fromCharCode(st));while(st&&Ge<fe);if(V.flags&512&&(V.check=C(V.check,De,Ge,L)),fe-=Ge,L+=Ge,st)break e}else V.head&&(V.head.comment=null);V.mode=S;case S:if(V.flags&512){for(;ve<16;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(ae!==(V.check&65535)){re.msg="header crc mismatch",V.mode=pe;break}ae=0,ve=0}V.head&&(V.head.hcrc=V.flags>>9&1,V.head.done=!0),re.adler=V.check=0,V.mode=F;break;case P:for(;ve<32;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}re.adler=V.check=ze(ae),ae=0,ve=0,V.mode=z;case z:if(V.havedict===0)return re.next_out=he,re.avail_out=H,re.next_in=L,re.avail_in=fe,V.hold=ae,V.bits=ve,e;re.adler=V.check=1,V.mode=F;case F:if(be===_||be===p)break e;case B:if(V.last){ae>>>=ve&7,ve-=ve&7,V.mode=Oe;break}for(;ve<3;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}switch(V.last=ae&1,ae>>>=1,ve-=1,ae&3){case 0:V.mode=W;break;case 1:if(Me(V),V.mode=te,be===p){ae>>>=2,ve-=2;break e}break;case 2:V.mode=G;break;case 3:re.msg="invalid block type",V.mode=pe}ae>>>=2,ve-=2;break;case W:for(ae>>>=ve&7,ve-=ve&7;ve<32;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if((ae&65535)!==(ae>>>16^65535)){re.msg="invalid stored block lengths",V.mode=pe;break}if(V.length=ae&65535,ae=0,ve=0,V.mode=U,be===p)break e;case U:V.mode=I;case I:if(Ge=V.length,Ge){if(Ge>fe&&(Ge=fe),Ge>H&&(Ge=H),Ge===0)break e;b.arraySet(Le,De,L,Ge,he),fe-=Ge,L+=Ge,H-=Ge,he+=Ge,V.length-=Ge;break}V.mode=F;break;case G:for(;ve<14;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(V.nlen=(ae&31)+257,ae>>>=5,ve-=5,V.ndist=(ae&31)+1,ae>>>=5,ve-=5,V.ncode=(ae&15)+4,ae>>>=4,ve-=4,V.nlen>286||V.ndist>30){re.msg="too many length or distance symbols",V.mode=pe;break}V.have=0,V.mode=Y;case Y:for(;V.have<V.ncode;){for(;ve<3;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.lens[At[V.have++]]=ae&7,ae>>>=3,ve-=3}for(;V.have<19;)V.lens[At[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,vt={bits:V.lenbits},lt=v(y,V.lens,0,19,V.lencode,0,V.work,vt),V.lenbits=vt.bits,lt){re.msg="invalid code lengths set",V.mode=pe;break}V.have=0,V.mode=J;case J:for(;V.have<V.nlen+V.ndist;){for(;Ye=V.lencode[ae&(1<<V.lenbits)-1],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(He<=ve);){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(tt<16)ae>>>=He,ve-=He,V.lens[V.have++]=tt;else{if(tt===16){for(Mt=He+2;ve<Mt;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(ae>>>=He,ve-=He,V.have===0){re.msg="invalid bit length repeat",V.mode=pe;break}st=V.lens[V.have-1],Ge=3+(ae&3),ae>>>=2,ve-=2}else if(tt===17){for(Mt=He+3;ve<Mt;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}ae>>>=He,ve-=He,st=0,Ge=3+(ae&7),ae>>>=3,ve-=3}else{for(Mt=He+7;ve<Mt;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}ae>>>=He,ve-=He,st=0,Ge=11+(ae&127),ae>>>=7,ve-=7}if(V.have+Ge>V.nlen+V.ndist){re.msg="invalid bit length repeat",V.mode=pe;break}for(;Ge--;)V.lens[V.have++]=st}}if(V.mode===pe)break;if(V.lens[256]===0){re.msg="invalid code -- missing end-of-block",V.mode=pe;break}if(V.lenbits=9,vt={bits:V.lenbits},lt=v(M,V.lens,0,V.nlen,V.lencode,0,V.work,vt),V.lenbits=vt.bits,lt){re.msg="invalid literal/lengths set",V.mode=pe;break}if(V.distbits=6,V.distcode=V.distdyn,vt={bits:V.distbits},lt=v(g,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,vt),V.distbits=vt.bits,lt){re.msg="invalid distances set",V.mode=pe;break}if(V.mode=te,be===p)break e;case te:V.mode=ne;case ne:if(fe>=6&&H>=258){re.next_out=he,re.avail_out=H,re.next_in=L,re.avail_in=fe,V.hold=ae,V.bits=ve,R(re,Ne),he=re.next_out,Le=re.output,H=re.avail_out,L=re.next_in,De=re.input,fe=re.avail_in,ae=V.hold,ve=V.bits,V.mode===F&&(V.back=-1);break}for(V.back=0;Ye=V.lencode[ae&(1<<V.lenbits)-1],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(He<=ve);){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if($e&&($e&240)===0){for(et=He,bt=$e,xt=tt;Ye=V.lencode[xt+((ae&(1<<et+bt)-1)>>et)],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(et+He<=ve);){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}ae>>>=et,ve-=et,V.back+=et}if(ae>>>=He,ve-=He,V.back+=He,V.length=tt,$e===0){V.mode=_e;break}if($e&32){V.back=-1,V.mode=F;break}if($e&64){re.msg="invalid literal/length code",V.mode=pe;break}V.extra=$e&15,V.mode=le;case le:if(V.extra){for(Mt=V.extra;ve<Mt;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.length+=ae&(1<<V.extra)-1,ae>>>=V.extra,ve-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=ie;case ie:for(;Ye=V.distcode[ae&(1<<V.distbits)-1],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(He<=ve);){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(($e&240)===0){for(et=He,bt=$e,xt=tt;Ye=V.distcode[xt+((ae&(1<<et+bt)-1)>>et)],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(et+He<=ve);){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}ae>>>=et,ve-=et,V.back+=et}if(ae>>>=He,ve-=He,V.back+=He,$e&64){re.msg="invalid distance code",V.mode=pe;break}V.offset=tt,V.extra=$e&15,V.mode=oe;case oe:if(V.extra){for(Mt=V.extra;ve<Mt;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}V.offset+=ae&(1<<V.extra)-1,ae>>>=V.extra,ve-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){re.msg="invalid distance too far back",V.mode=pe;break}V.mode=xe;case xe:if(H===0)break e;if(Ge=Ne-H,V.offset>Ge){if(Ge=V.offset-Ge,Ge>V.whave&&V.sane){re.msg="invalid distance too far back",V.mode=pe;break}Ge>V.wnext?(Ge-=V.wnext,qe=V.wsize-Ge):qe=V.wnext-Ge,Ge>V.length&&(Ge=V.length),_t=V.window}else _t=Le,qe=he-V.offset,Ge=V.length;Ge>H&&(Ge=H),H-=Ge,V.length-=Ge;do Le[he++]=_t[qe++];while(--Ge);V.length===0&&(V.mode=ne);break;case _e:if(H===0)break e;Le[he++]=V.length,H--,V.mode=ne;break;case Oe:if(V.wrap){for(;ve<32;){if(fe===0)break e;fe--,ae|=De[L++]<<ve,ve+=8}if(Ne-=H,re.total_out+=Ne,V.total+=Ne,Ne&&(re.adler=V.check=V.flags?C(V.check,Le,Ne,he-Ne):O(V.check,Le,Ne,he-Ne)),Ne=H,(V.flags?ae:ze(ae))!==V.check){re.msg="incorrect data check",V.mode=pe;break}ae=0,ve=0}V.mode=ye;case ye:if(V.wrap&&V.flags){for(;ve<32;){if(fe===0)break e;fe--,ae+=De[L++]<<ve,ve+=8}if(ae!==(V.total&4294967295)){re.msg="incorrect length check",V.mode=pe;break}ae=0,ve=0}V.mode=ee;case ee:lt=r;break e;case pe:lt=s;break e;case Ce:return o;case Te:default:return t}return re.next_out=he,re.avail_out=H,re.next_in=L,re.avail_in=fe,V.hold=ae,V.bits=ve,(V.wsize||Ne!==re.avail_out&&V.mode<pe&&(V.mode<Oe||be!==x))&&we(re,re.output,re.next_out,Ne-re.avail_out),Ve-=re.avail_in,Ne-=re.avail_out,re.total_in+=Ve,re.total_out+=Ne,V.total+=Ne,V.wrap&&Ne&&(re.adler=V.check=V.flags?C(V.check,Le,Ne,re.next_out-Ne):O(V.check,Le,Ne,re.next_out-Ne)),re.data_type=V.bits+(V.last?64:0)+(V.mode===F?128:0)+(V.mode===te||V.mode===U?256:0),(Ve===0&&Ne===0||be===x)&<===m&&(lt=l),lt}function se(re){if(!re||!re.state)return t;var be=re.state;return be.window&&(be.window=null),re.state=null,m}function ge(re,be){var V;return!re||!re.state||(V=re.state,(V.wrap&2)===0)?t:(V.head=be,be.done=!1,m)}function Se(re,be){var V=be.length,De,Le,L;return!re||!re.state||(De=re.state,De.wrap!==0&&De.mode!==z)?t:De.mode===z&&(Le=1,Le=O(Le,be,V,0),Le!==De.check)?s:(L=we(re,be,V,V),L?(De.mode=Ce,o):(De.havedict=1,m))}w.inflateReset=je,w.inflateReset2=ke,w.inflateResetKeep=Re,w.inflateInit=Z,w.inflateInit2=K,w.inflate=j,w.inflateEnd=se,w.inflateGetHeader=ge,w.inflateSetDictionary=Se,w.inflateInfo="pako inflate (from Nodeca project)"},"./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=15,C=852,R=592,v=0,y=1,M=2,g=[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],x=[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],_=[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],p=[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];k.exports=function(r,e,t,s,o,l,d,i){var n=i.bits,a=0,h=0,u=0,A=0,D=0,T=0,S=0,P=0,z=0,F=0,B,W,U,I,G,Y=null,J=0,te,ne=new b.Buf16(O+1),le=new b.Buf16(O+1),ie=null,oe=0,xe,_e,Oe;for(a=0;a<=O;a++)ne[a]=0;for(h=0;h<s;h++)ne[e[t+h]]++;for(D=n,A=O;A>=1&&ne[A]===0;A--);if(D>A&&(D=A),A===0)return o[l++]=20971520,o[l++]=20971520,i.bits=1,0;for(u=1;u<A&&ne[u]===0;u++);for(D<u&&(D=u),P=1,a=1;a<=O;a++)if(P<<=1,P-=ne[a],P<0)return-1;if(P>0&&(r===v||A!==1))return-1;for(le[1]=0,a=1;a<O;a++)le[a+1]=le[a]+ne[a];for(h=0;h<s;h++)e[t+h]!==0&&(d[le[e[t+h]]++]=h);if(r===v?(Y=ie=d,te=19):r===y?(Y=g,J-=257,ie=x,oe-=257,te=256):(Y=_,ie=p,te=-1),F=0,h=0,a=u,G=l,T=D,S=0,U=-1,z=1<<D,I=z-1,r===y&&z>C||r===M&&z>R)return 1;for(;;){xe=a-S,d[h]<te?(_e=0,Oe=d[h]):d[h]>te?(_e=ie[oe+d[h]],Oe=Y[J+d[h]]):(_e=96,Oe=0),B=1<<a-S,W=1<<T,u=W;do W-=B,o[G+(F>>S)+W]=xe<<24|_e<<16|Oe|0;while(W!==0);for(B=1<<a-1;F&B;)B>>=1;if(B!==0?(F&=B-1,F+=B):F=0,h++,--ne[a]===0){if(a===A)break;a=e[t+d[h]]}if(a>D&&(F&I)!==U){for(S===0&&(S=D),G+=u,T=a-S,P=1<<T;T+S<A&&(P-=ne[T+S],!(P<=0));)T++,P<<=1;if(z+=1<<T,r===y&&z>C||r===M&&z>R)return 1;U=F&I,o[U]=D<<24|T<<16|G-l|0}}return F!==0&&(o[G+F]=a-S<<24|4194304|0),i.bits=D,0}},"./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"(k){k.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"}},"./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js"(k,w,c){var b=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=4,C=0,R=1,v=2;function y(j){for(var se=j.length;--se>=0;)j[se]=0}var M=0,g=1,x=2,_=3,p=258,m=29,r=256,e=r+1+m,t=30,s=19,o=2*e+1,l=15,d=16,i=7,n=256,a=16,h=17,u=18,A=[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],D=[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],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],P=512,z=new Array((e+2)*2);y(z);var F=new Array(t*2);y(F);var B=new Array(P);y(B);var W=new Array(p-_+1);y(W);var U=new Array(m);y(U);var I=new Array(t);y(I);function G(j,se,ge,Se,re){this.static_tree=j,this.extra_bits=se,this.extra_base=ge,this.elems=Se,this.max_length=re,this.has_stree=j&&j.length}var Y,J,te;function ne(j,se){this.dyn_tree=j,this.max_code=0,this.stat_desc=se}function le(j){return j<256?B[j]:B[256+(j>>>7)]}function ie(j,se){j.pending_buf[j.pending++]=se&255,j.pending_buf[j.pending++]=se>>>8&255}function oe(j,se,ge){j.bi_valid>d-ge?(j.bi_buf|=se<<j.bi_valid&65535,ie(j,j.bi_buf),j.bi_buf=se>>d-j.bi_valid,j.bi_valid+=ge-d):(j.bi_buf|=se<<j.bi_valid&65535,j.bi_valid+=ge)}function xe(j,se,ge){oe(j,ge[se*2],ge[se*2+1])}function _e(j,se){var ge=0;do ge|=j&1,j>>>=1,ge<<=1;while(--se>0);return ge>>>1}function Oe(j){j.bi_valid===16?(ie(j,j.bi_buf),j.bi_buf=0,j.bi_valid=0):j.bi_valid>=8&&(j.pending_buf[j.pending++]=j.bi_buf&255,j.bi_buf>>=8,j.bi_valid-=8)}function ye(j,se){var ge=se.dyn_tree,Se=se.max_code,re=se.stat_desc.static_tree,be=se.stat_desc.has_stree,V=se.stat_desc.extra_bits,De=se.stat_desc.extra_base,Le=se.stat_desc.max_length,L,he,fe,H,ae,ve,Ve=0;for(H=0;H<=l;H++)j.bl_count[H]=0;for(ge[j.heap[j.heap_max]*2+1]=0,L=j.heap_max+1;L<o;L++)he=j.heap[L],H=ge[ge[he*2+1]*2+1]+1,H>Le&&(H=Le,Ve++),ge[he*2+1]=H,!(he>Se)&&(j.bl_count[H]++,ae=0,he>=De&&(ae=V[he-De]),ve=ge[he*2],j.opt_len+=ve*(H+ae),be&&(j.static_len+=ve*(re[he*2+1]+ae)));if(Ve!==0){do{for(H=Le-1;j.bl_count[H]===0;)H--;j.bl_count[H]--,j.bl_count[H+1]+=2,j.bl_count[Le]--,Ve-=2}while(Ve>0);for(H=Le;H!==0;H--)for(he=j.bl_count[H];he!==0;)fe=j.heap[--L],!(fe>Se)&&(ge[fe*2+1]!==H&&(j.opt_len+=(H-ge[fe*2+1])*ge[fe*2],ge[fe*2+1]=H),he--)}}function ee(j,se,ge){var Se=new Array(l+1),re=0,be,V;for(be=1;be<=l;be++)Se[be]=re=re+ge[be-1]<<1;for(V=0;V<=se;V++){var De=j[V*2+1];De!==0&&(j[V*2]=_e(Se[De]++,De))}}function pe(){var j,se,ge,Se,re,be=new Array(l+1);for(ge=0,Se=0;Se<m-1;Se++)for(U[Se]=ge,j=0;j<1<<A[Se];j++)W[ge++]=Se;for(W[ge-1]=Se,re=0,Se=0;Se<16;Se++)for(I[Se]=re,j=0;j<1<<D[Se];j++)B[re++]=Se;for(re>>=7;Se<t;Se++)for(I[Se]=re<<7,j=0;j<1<<D[Se]-7;j++)B[256+re++]=Se;for(se=0;se<=l;se++)be[se]=0;for(j=0;j<=143;)z[j*2+1]=8,j++,be[8]++;for(;j<=255;)z[j*2+1]=9,j++,be[9]++;for(;j<=279;)z[j*2+1]=7,j++,be[7]++;for(;j<=287;)z[j*2+1]=8,j++,be[8]++;for(ee(z,e+1,be),j=0;j<t;j++)F[j*2+1]=5,F[j*2]=_e(j,5);Y=new G(z,A,r+1,e,l),J=new G(F,D,0,t,l),te=new G(new Array(0),T,0,s,i)}function Ce(j){var se;for(se=0;se<e;se++)j.dyn_ltree[se*2]=0;for(se=0;se<t;se++)j.dyn_dtree[se*2]=0;for(se=0;se<s;se++)j.bl_tree[se*2]=0;j.dyn_ltree[n*2]=1,j.opt_len=j.static_len=0,j.last_lit=j.matches=0}function Te(j){j.bi_valid>8?ie(j,j.bi_buf):j.bi_valid>0&&(j.pending_buf[j.pending++]=j.bi_buf),j.bi_buf=0,j.bi_valid=0}function We(j,se,ge,Se){Te(j),ie(j,ge),ie(j,~ge),b.arraySet(j.pending_buf,j.window,se,ge,j.pending),j.pending+=ge}function Ie(j,se,ge,Se){var re=se*2,be=ge*2;return j[re]<j[be]||j[re]===j[be]&&Se[se]<=Se[ge]}function Be(j,se,ge){for(var Se=j.heap[ge],re=ge<<1;re<=j.heap_len&&(re<j.heap_len&&Ie(se,j.heap[re+1],j.heap[re],j.depth)&&re++,!Ie(se,Se,j.heap[re],j.depth));)j.heap[ge]=j.heap[re],ge=re,re<<=1;j.heap[ge]=Se}function Fe(j,se,ge){var Se,re,be=0,V,De;if(j.last_lit!==0)do Se=j.pending_buf[j.d_buf+be*2]<<8|j.pending_buf[j.d_buf+be*2+1],re=j.pending_buf[j.l_buf+be],be++,Se===0?xe(j,re,se):(V=W[re],xe(j,V+r+1,se),De=A[V],De!==0&&(re-=U[V],oe(j,re,De)),Se--,V=le(Se),xe(j,V,ge),De=D[V],De!==0&&(Se-=I[V],oe(j,Se,De)));while(be<j.last_lit);xe(j,n,se)}function ze(j,se){var ge=se.dyn_tree,Se=se.stat_desc.static_tree,re=se.stat_desc.has_stree,be=se.stat_desc.elems,V,De,Le=-1,L;for(j.heap_len=0,j.heap_max=o,V=0;V<be;V++)ge[V*2]!==0?(j.heap[++j.heap_len]=Le=V,j.depth[V]=0):ge[V*2+1]=0;for(;j.heap_len<2;)L=j.heap[++j.heap_len]=Le<2?++Le:0,ge[L*2]=1,j.depth[L]=0,j.opt_len--,re&&(j.static_len-=Se[L*2+1]);for(se.max_code=Le,V=j.heap_len>>1;V>=1;V--)Be(j,ge,V);L=be;do V=j.heap[1],j.heap[1]=j.heap[j.heap_len--],Be(j,ge,1),De=j.heap[1],j.heap[--j.heap_max]=V,j.heap[--j.heap_max]=De,ge[L*2]=ge[V*2]+ge[De*2],j.depth[L]=(j.depth[V]>=j.depth[De]?j.depth[V]:j.depth[De])+1,ge[V*2+1]=ge[De*2+1]=L,j.heap[1]=L++,Be(j,ge,1);while(j.heap_len>=2);j.heap[--j.heap_max]=j.heap[1],ye(j,se),ee(ge,Le,j.bl_count)}function Pe(j,se,ge){var Se,re=-1,be,V=se[1],De=0,Le=7,L=4;for(V===0&&(Le=138,L=3),se[(ge+1)*2+1]=65535,Se=0;Se<=ge;Se++)be=V,V=se[(Se+1)*2+1],!(++De<Le&&be===V)&&(De<L?j.bl_tree[be*2]+=De:be!==0?(be!==re&&j.bl_tree[be*2]++,j.bl_tree[a*2]++):De<=10?j.bl_tree[h*2]++:j.bl_tree[u*2]++,De=0,re=be,V===0?(Le=138,L=3):be===V?(Le=6,L=3):(Le=7,L=4))}function Re(j,se,ge){var Se,re=-1,be,V=se[1],De=0,Le=7,L=4;for(V===0&&(Le=138,L=3),Se=0;Se<=ge;Se++)if(be=V,V=se[(Se+1)*2+1],!(++De<Le&&be===V)){if(De<L)do xe(j,be,j.bl_tree);while(--De!==0);else be!==0?(be!==re&&(xe(j,be,j.bl_tree),De--),xe(j,a,j.bl_tree),oe(j,De-3,2)):De<=10?(xe(j,h,j.bl_tree),oe(j,De-3,3)):(xe(j,u,j.bl_tree),oe(j,De-11,7));De=0,re=be,V===0?(Le=138,L=3):be===V?(Le=6,L=3):(Le=7,L=4)}}function je(j){var se;for(Pe(j,j.dyn_ltree,j.l_desc.max_code),Pe(j,j.dyn_dtree,j.d_desc.max_code),ze(j,j.bl_desc),se=s-1;se>=3&&j.bl_tree[S[se]*2+1]===0;se--);return j.opt_len+=3*(se+1)+5+5+4,se}function ke(j,se,ge,Se){var re;for(oe(j,se-257,5),oe(j,ge-1,5),oe(j,Se-4,4),re=0;re<Se;re++)oe(j,j.bl_tree[S[re]*2+1],3);Re(j,j.dyn_ltree,se-1),Re(j,j.dyn_dtree,ge-1)}function K(j){var se=4093624447,ge;for(ge=0;ge<=31;ge++,se>>>=1)if(se&1&&j.dyn_ltree[ge*2]!==0)return C;if(j.dyn_ltree[18]!==0||j.dyn_ltree[20]!==0||j.dyn_ltree[26]!==0)return R;for(ge=32;ge<r;ge++)if(j.dyn_ltree[ge*2]!==0)return R;return C}var Z=!1;function $(j){Z||(pe(),Z=!0),j.l_desc=new ne(j.dyn_ltree,Y),j.d_desc=new ne(j.dyn_dtree,J),j.bl_desc=new ne(j.bl_tree,te),j.bi_buf=0,j.bi_valid=0,Ce(j)}function me(j,se,ge,Se){oe(j,(M<<1)+(Se?1:0),3),We(j,se,ge)}function ce(j){oe(j,g<<1,3),xe(j,n,z),Oe(j)}function Me(j,se,ge,Se){var re,be,V=0;j.level>0?(j.strm.data_type===v&&(j.strm.data_type=K(j)),ze(j,j.l_desc),ze(j,j.d_desc),V=je(j),re=j.opt_len+3+7>>>3,be=j.static_len+3+7>>>3,be<=re&&(re=be)):re=be=ge+5,ge+4<=re&&se!==-1?me(j,se,ge,Se):j.strategy===O||be===re?(oe(j,(g<<1)+(Se?1:0),3),Fe(j,z,F)):(oe(j,(x<<1)+(Se?1:0),3),ke(j,j.l_desc.max_code+1,j.d_desc.max_code+1,V+1),Fe(j,j.dyn_ltree,j.dyn_dtree)),Ce(j),Se&&Te(j)}function we(j,se,ge){return j.pending_buf[j.d_buf+j.last_lit*2]=se>>>8&255,j.pending_buf[j.d_buf+j.last_lit*2+1]=se&255,j.pending_buf[j.l_buf+j.last_lit]=ge&255,j.last_lit++,se===0?j.dyn_ltree[ge*2]++:(j.matches++,se--,j.dyn_ltree[(W[ge]+r+1)*2]++,j.dyn_dtree[le(se)*2]++),j.last_lit===j.lit_bufsize-1}w._tr_init=$,w._tr_stored_block=me,w._tr_flush_block=Me,w._tr_tally=we,w._tr_align=ce},"./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js"(k){function w(){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}k.exports=w},"./src/3Dmol.ts"(k,w,c){c.r(w),c.d(w,{CAP:()=>R.CAP,CC:()=>O.CC,CONTEXTS_PER_VIEWPORT:()=>M.CONTEXTS_PER_VIEWPORT,Color:()=>O.Color,CustomLinear:()=>g.CustomLinear,Cylinder:()=>o.Cylinder,GLDraw:()=>R.GLDraw,GLModel:()=>v.GLModel,GLShape:()=>y.GLShape,GLViewer:()=>M.GLViewer,GLVolumetricRender:()=>t.GLVolumetricRender,Gradient:()=>g.Gradient,GradientType:()=>g.GradientType,Label:()=>x.Label,LabelCount:()=>x.LabelCount,MarchingCube:()=>m.MarchingCube,MarchingCubeInitializer:()=>m.MarchingCubeInitializer,Matrix3:()=>s.Matrix3,Matrix4:()=>s.Matrix4,Parsers:()=>_.Parsers,PausableTimer:()=>r.PausableTimer,PointGrid:()=>m.PointGrid,ProteinSurface:()=>m.ProteinSurface,Quaternion:()=>s.Quaternion,ROYGB:()=>g.ROYGB,RWB:()=>g.RWB,Ray:()=>s.Ray,Sinebow:()=>g.Sinebow,Sphere:()=>o.Sphere,SurfaceType:()=>m.SurfaceType,Triangle:()=>o.Triangle,Vector2:()=>s.Vector2,Vector3:()=>s.Vector3,VolumeData:()=>e.VolumeData,adjustVolumeStyle:()=>r.adjustVolumeStyle,applyPartialCharges:()=>p.applyPartialCharges,autoinit:()=>b.autoinit,autoload:()=>b.autoload,base64ToArray:()=>r.base64ToArray,bondLength:()=>_.bondLength,builtinColorSchemes:()=>O.builtinColorSchemes,builtinGradients:()=>g.builtinGradients,chains:()=>O.chains,clamp:()=>s.clamp,conversionMatrix3:()=>s.conversionMatrix3,createStereoViewer:()=>M.createStereoViewer,createViewer:()=>M.createViewer,createViewerGrid:()=>M.createViewerGrid,deepCopy:()=>r.deepCopy,degToRad:()=>s.degToRad,download:()=>r.download,drawCartoon:()=>C.drawCartoon,elementColors:()=>O.elementColors,extend:()=>r.extend,get:()=>r.get,getAtomProperty:()=>r.getAtomProperty,getColorFromStyle:()=>r.getColorFromStyle,getElement:()=>r.getElement,getExtent:()=>r.getExtent,getGradient:()=>g.getGradient,getPropertyRange:()=>r.getPropertyRange,getbin:()=>r.getbin,htmlColors:()=>O.htmlColors,inflateString:()=>r.inflateString,isEmptyObject:()=>r.isEmptyObject,isNumeric:()=>r.isNumeric,makeFunction:()=>r.makeFunction,mergeGeos:()=>r.mergeGeos,normalizeValue:()=>g.normalizeValue,partialCharges:()=>p.partialCharges,processing_autoinit:()=>b.processing_autoinit,residues:()=>O.residues,setBondLength:()=>_.setBondLength,setSyncSurface:()=>m.setSyncSurface,specStringToObject:()=>r.specStringToObject,splitMesh:()=>y.splitMesh,ssColors:()=>O.ssColors,subdivide_spline:()=>C.subdivide_spline,syncSurface:()=>m.syncSurface,viewers:()=>b.viewers});var b=c("./src/autoload.ts"),O=c("./src/colors.ts"),C=c("./src/glcartoon.ts"),R=c("./src/GLDraw.ts"),v=c("./src/GLModel.ts"),y=c("./src/GLShape.ts"),M=c("./src/GLViewer.ts"),g=c("./src/Gradient.ts"),x=c("./src/Label.ts"),_=c("./src/parsers/index.ts"),p=c("./src/partialCharges.ts"),m=c("./src/ProteinSurface4.ts");c("./src/specs.ts");var r=c("./src/utilities.ts"),e=c("./src/VolumeData.ts"),t=c("./src/VolumetricRender.ts"),s=c("./src/WebGL/math/index.ts"),o=c("./src/WebGL/shapes/index.ts")},"./src/GLDraw.ts"(k,w,c){c.r(w),c.d(w,{CAP:()=>O,GLDraw:()=>C});var b=c("./src/WebGL/math/index.ts"),O;(function(R){R[R.NONE=0]="NONE",R[R.FLAT=1]="FLAT",R[R.ROUND=2]="ROUND"})(O||(O={}));var C;(function(R){function v(e,t,s){var o=Math.hypot(e,t),l,d,i,n,a;o<1e-4?(d=0,i=1):(d=-e/o,i=t/o),t=-d*e+i*t,l=Math.hypot(t,s),l<1e-4?(n=0,a=1):(n=s/l,a=t/l);var h=new Float32Array(9);return h[0]=i,h[1]=d,h[2]=0,h[3]=-d*a,h[4]=i*a,h[5]=n,h[6]=d*n,h[7]=-i*n,h[8]=a,h}class y{constructor(){this.cache={};let t=[],s=4,o=Math.pow(2,s),l=2,d=Math.pow(2,l),i=o/d,n;for(t[0]=new b.Vector3(-1,0,0),t[i]=new b.Vector3(0,0,1),t[i*2]=new b.Vector3(1,0,0),t[i*3]=new b.Vector3(0,0,-1),l=3;l<=s;l++){for(d=Math.pow(2,l-1),i=o/d,n=0;n<d-1;n++)t[i/2+n*i]=t[n*i].clone().add(t[(n+1)*i]).normalize();n=d-1,t[i/2+n*i]=t[n*i].clone().add(t[0]).normalize()}this.basisVectors=t}getVerticesForRadius(t,s,o){if(typeof this.cache<"u"&&this.cache[t]!==void 0&&this.cache[t][s+o]!==void 0)return this.cache[t][s+o];for(var l=this.basisVectors.length,d=[],i=[],n,a=0;a<l;a++)d.push(this.basisVectors[a].clone().multiplyScalar(t)),d.push(this.basisVectors[a].clone().multiplyScalar(t)),n=this.basisVectors[a].clone().normalize(),i.push(n),i.push(n);var h=[],u=10,A=l,D=0,T=Math.PI*2,S=0,P=Math.PI,z,F,B=!1,W=!1;for(F=0;F<=u;F++){B=F===0||F===u,W=F===u/2;var U=[],I=[];for(z=0;z<=A;z++){if(W){var G=z<A?2*z:0;I.push(G+1),U.push(G);continue}var Y=z/A,J=F/u;if(!B||z===0)if(z<A){var te=new b.Vector3;te.x=-t*Math.cos(D+Y*T)*Math.sin(S+J*P),s==1?te.y=0:te.y=t*Math.cos(S+J*P),te.z=t*Math.sin(D+Y*T)*Math.sin(S+J*P),Math.abs(te.x)<1e-5&&(te.x=0),Math.abs(te.y)<1e-5&&(te.y=0),Math.abs(te.z)<1e-5&&(te.z=0),s==O.FLAT?(n=new b.Vector3(0,Math.cos(S+J*P),0),n.normalize()):(n=new b.Vector3(te.x,te.y,te.z),n.normalize()),d.push(te),i.push(n),U.push(d.length-1)}else U.push(d.length-A);else B&&U.push(d.length-1)}W&&h.push(I),h.push(U)}var ne={vertices:d,normals:i,verticesRows:h,w:A,h:u};return t in this.cache||(this.cache[t]={}),this.cache[t][s+o]=ne,ne}}var M=new y;function g(e,t,s,o,l,d=0,i=0){if(!t||!s)return;let n=function(Ve){if(typeof Ve=="string"){let Ne=Ve;return Ne.toLowerCase()=="flat"?O.FLAT:Ne.toLowerCase()=="round"?O.ROUND:O.NONE}else return Ve};d=n(d),i=n(i);var a=i||d;l=l||{r:0,g:0,b:0};var h=v(s.x-t.x,s.y-t.y,s.z-t.z),u=M.getVerticesForRadius(o,i,"to"),A=u.w,D=u.h,T=a?D*A+2:2*A,S=e.updateGeoGroup(T),P=u.vertices,z=u.normals,F=u.verticesRows,B=F[D/2],W=F[D/2+1],U=S.vertices,I,G,Y,J,te,ne,le=S.vertexArray,ie=S.normalArray,oe=S.colorArray,xe=S.faceArray;for(Y=0;Y<A;++Y){var _e=2*Y;J=h[0]*P[_e].x+h[3]*P[_e].y+h[6]*P[_e].z,te=h[1]*P[_e].x+h[4]*P[_e].y+h[7]*P[_e].z,ne=h[5]*P[_e].y+h[8]*P[_e].z,I=3*(U+_e),G=S.faceidx,le[I]=J+t.x,le[I+1]=te+t.y,le[I+2]=ne+t.z,le[I+3]=J+s.x,le[I+4]=te+s.y,le[I+5]=ne+s.z,ie[I]=J,ie[I+3]=J,ie[I+1]=te,ie[I+4]=te,ie[I+2]=ne,ie[I+5]=ne,oe[I]=l.r,oe[I+3]=l.r,oe[I+1]=l.g,oe[I+4]=l.g,oe[I+2]=l.b,oe[I+5]=l.b,xe[G]=W[Y]+U,xe[G+1]=W[Y+1]+U,xe[G+2]=B[Y]+U,xe[G+3]=B[Y]+U,xe[G+4]=W[Y+1]+U,xe[G+5]=B[Y+1]+U,S.faceidx+=6}if(a){var Oe=i?0:D/2,ye=d?D+1:D/2+1,ee,pe,Ce,Te,We,Ie,Be,Fe,ze,Pe,Re,je,ke,K,Z,$,me,ce,Me,we,j,se,ge,Se,re,be,V,De,Le,L,he,fe;for(te=Oe;te<ye;te++)if(te!==D/2){var H=te<=D/2?s:t,ae=M.getVerticesForRadius(o,i,"to"),ve=M.getVerticesForRadius(o,d,"from");for(H===s?(P=ae.vertices,z=ae.normals,F=ae.verticesRows):H==t&&(P=ve.vertices,z=ve.normals,F=ve.verticesRows),J=0;J<A;J++)G=S.faceidx,ee=F[te][J+1],Le=(ee+U)*3,pe=F[te][J],L=(pe+U)*3,Ce=F[te+1][J],he=(Ce+U)*3,Te=F[te+1][J+1],fe=(Te+U)*3,We=h[0]*P[ee].x+h[3]*P[ee].y+h[6]*P[ee].z,Ie=h[0]*P[pe].x+h[3]*P[pe].y+h[6]*P[pe].z,Be=h[0]*P[Ce].x+h[3]*P[Ce].y+h[6]*P[Ce].z,Fe=h[0]*P[Te].x+h[3]*P[Te].y+h[6]*P[Te].z,ze=h[1]*P[ee].x+h[4]*P[ee].y+h[7]*P[ee].z,Pe=h[1]*P[pe].x+h[4]*P[pe].y+h[7]*P[pe].z,Re=h[1]*P[Ce].x+h[4]*P[Ce].y+h[7]*P[Ce].z,je=h[1]*P[Te].x+h[4]*P[Te].y+h[7]*P[Te].z,ke=h[5]*P[ee].y+h[8]*P[ee].z,K=h[5]*P[pe].y+h[8]*P[pe].z,Z=h[5]*P[Ce].y+h[8]*P[Ce].z,$=h[5]*P[Te].y+h[8]*P[Te].z,le[Le]=We+H.x,le[L]=Ie+H.x,le[he]=Be+H.x,le[fe]=Fe+H.x,le[Le+1]=ze+H.y,le[L+1]=Pe+H.y,le[he+1]=Re+H.y,le[fe+1]=je+H.y,le[Le+2]=ke+H.z,le[L+2]=K+H.z,le[he+2]=Z+H.z,le[fe+2]=$+H.z,oe[Le]=l.r,oe[L]=l.r,oe[he]=l.r,oe[fe]=l.r,oe[Le+1]=l.g,oe[L+1]=l.g,oe[he+1]=l.g,oe[fe+1]=l.g,oe[Le+2]=l.b,oe[L+2]=l.b,oe[he+2]=l.b,oe[fe+2]=l.b,me=h[0]*z[ee].x+h[3]*z[ee].y+h[6]*z[ee].z,ce=h[0]*z[pe].x+h[3]*z[pe].y+h[6]*z[pe].z,Me=h[0]*z[Ce].x+h[3]*z[Ce].y+h[6]*z[Ce].z,we=h[0]*z[Te].x+h[3]*z[Te].y+h[6]*z[Te].z,j=h[1]*z[ee].x+h[4]*z[ee].y+h[7]*z[ee].z,se=h[1]*z[pe].x+h[4]*z[pe].y+h[7]*z[pe].z,ge=h[1]*z[Ce].x+h[4]*z[Ce].y+h[7]*z[Ce].z,Se=h[1]*z[Te].x+h[4]*z[Te].y+h[7]*z[Te].z,re=h[5]*z[ee].y+h[8]*z[ee].z,be=h[5]*z[pe].y+h[8]*z[pe].z,V=h[5]*z[Ce].y+h[8]*z[Ce].z,De=h[5]*z[Te].y+h[8]*z[Te].z,te===0?(ie[Le]=me,ie[he]=Me,ie[fe]=we,ie[Le+1]=j,ie[he+1]=ge,ie[fe+1]=Se,ie[Le+2]=re,ie[he+2]=V,ie[fe+2]=De,xe[G]=ee+U,xe[G+1]=Ce+U,xe[G+2]=Te+U,S.faceidx+=3):te===ye-1?(ie[Le]=me,ie[L]=ce,ie[he]=Me,ie[Le+1]=j,ie[L+1]=se,ie[he+1]=ge,ie[Le+2]=re,ie[L+2]=be,ie[he+2]=V,xe[G]=ee+U,xe[G+1]=pe+U,xe[G+2]=Ce+U,S.faceidx+=3):(ie[Le]=me,ie[L]=ce,ie[fe]=we,ie[Le+1]=j,ie[L+1]=se,ie[fe+1]=Se,ie[Le+2]=re,ie[L+2]=be,ie[fe+2]=De,ie[L]=ce,ie[he]=Me,ie[fe]=we,ie[L+1]=se,ie[he+1]=ge,ie[fe+1]=Se,ie[L+2]=be,ie[he+2]=V,ie[fe+2]=De,xe[G]=ee+U,xe[G+1]=pe+U,xe[G+2]=Te+U,xe[G+3]=pe+U,xe[G+4]=Ce+U,xe[G+5]=Te+U,S.faceidx+=6)}}S.vertices+=T}R.drawCylinder=g;function x(e,t,s,o,l){if(!t||!s)return;l=l||{r:0,g:0,b:0};let d=new b.Vector3(s.x-t.x,s.y-t.y,s.z-t.z);var i=v(d.x,d.y,d.z);d=d.normalize();var n=M.basisVectors.length,a=M.basisVectors,h=n+2,u=e.updateGeoGroup(h),A=u.vertices,D,T,S,P,z,F,B=u.vertexArray,W=u.normalArray,U=u.colorArray,I=u.faceArray;for(D=A*3,B[D]=t.x,B[D+1]=t.y,B[D+2]=t.z,W[D]=-d.x,W[D+1]=-d.y,W[D+2]=-d.z,U[D]=l.r,U[D+1]=l.g,U[D+2]=l.b,B[D+3]=s.x,B[D+4]=s.y,B[D+5]=s.z,W[D+3]=d.x,W[D+4]=d.y,W[D+5]=d.z,U[D+3]=l.r,U[D+4]=l.g,U[D+5]=l.b,D+=6,S=0;S<n;++S){var G=a[S].clone();G.multiplyScalar(o),P=i[0]*G.x+i[3]*G.y+i[6]*G.z,z=i[1]*G.x+i[4]*G.y+i[7]*G.z,F=i[5]*G.y+i[8]*G.z,B[D]=P+t.x,B[D+1]=z+t.y,B[D+2]=F+t.z,W[D]=P,W[D+1]=z,W[D+2]=F,U[D]=l.r,U[D+1]=l.g,U[D+2]=l.b,D+=3}for(u.vertices+=n+2,T=u.faceidx,S=0;S<n;S++){var Y=A+2+S,J=A+2+(S+1)%n;I[T]=Y,I[T+1]=J,I[T+2]=A,T+=3,I[T]=Y,I[T+1]=J,I[T+2]=A+1,T+=3}u.faceidx+=6*n}R.drawCone=x;class _{constructor(){this.cache=new Map}getVerticesForRadius(t,s){s=s||2,this.cache.has(s)||this.cache.set(s,new Map);let o=this.cache.get(s);if(o.has(t))return o.get(t);var l={vertices:[],verticesRows:[],normals:[]},d=16*s,i=10*s;t<1&&(d=10*s,i=8*s);var n=0,a=Math.PI*2,h=0,u=Math.PI,A,D;for(D=0;D<=i;D++){let S=[];for(A=0;A<=d;A++){let P=A/d,z=D/i,F=-t*Math.cos(n+P*a)*Math.sin(h+z*u),B=t*Math.cos(h+z*u),W=t*Math.sin(n+P*a)*Math.sin(h+z*u);var T=new b.Vector3(F,B,W);T.normalize(),l.vertices.push({x:F,y:B,z:W}),l.normals.push(T),S.push(l.vertices.length-1)}l.verticesRows.push(S)}return o.set(t,l),l}}var p=new _;function m(e,t,s,o,l){var d=p.getVerticesForRadius(s,l),i=d.vertices,n=d.normals,a=e.updateGeoGroup(i.length),h=a.vertices,u=a.vertexArray,A=a.colorArray,D=a.faceArray,T=a.lineArray,S=a.normalArray;for(let F=0,B=i.length;F<B;++F){let W=3*(h+F),U=i[F];u[W]=U.x+t.x,u[W+1]=U.y+t.y,u[W+2]=U.z+t.z,A[W]=o.r,A[W+1]=o.g,A[W+2]=o.b}a.vertices+=i.length;let P=d.verticesRows,z=P.length-1;for(let F=0;F<z;F++){let B=P[F].length-1;for(let W=0;W<B;W++){let U=a.faceidx,I=a.lineidx,G=P[F][W+1]+h,Y=G*3,J=P[F][W]+h,te=J*3,ne=P[F+1][W]+h,le=ne*3,ie=P[F+1][W+1]+h,oe=ie*3,xe=n[G-h],_e=n[J-h],Oe=n[ne-h],ye=n[ie-h];Math.abs(i[G-h].y)===s?(S[Y]=xe.x,S[le]=Oe.x,S[oe]=ye.x,S[Y+1]=xe.y,S[le+1]=Oe.y,S[oe+1]=ye.y,S[Y+2]=xe.z,S[le+2]=Oe.z,S[oe+2]=ye.z,D[U]=G,D[U+1]=ne,D[U+2]=ie,T[I]=G,T[I+1]=ne,T[I+2]=G,T[I+3]=ie,T[I+4]=ne,T[I+5]=ie,a.faceidx+=3,a.lineidx+=6):Math.abs(i[ne-h].y)===s?(S[Y]=xe.x,S[te]=_e.x,S[le]=Oe.x,S[Y+1]=xe.y,S[te+1]=_e.y,S[le+1]=Oe.y,S[Y+2]=xe.z,S[te+2]=_e.z,S[le+2]=Oe.z,D[U]=G,D[U+1]=J,D[U+2]=ne,T[I]=G,T[I+1]=J,T[I+2]=G,T[I+3]=ne,T[I+4]=J,T[I+5]=ne,a.faceidx+=3,a.lineidx+=6):(S[Y]=xe.x,S[te]=_e.x,S[oe]=ye.x,S[Y+1]=xe.y,S[te+1]=_e.y,S[oe+1]=ye.y,S[Y+2]=xe.z,S[te+2]=_e.z,S[oe+2]=ye.z,S[te]=_e.x,S[le]=Oe.x,S[oe]=ye.x,S[te+1]=_e.y,S[le+1]=Oe.y,S[oe+1]=ye.y,S[te+2]=_e.z,S[le+2]=Oe.z,S[oe+2]=ye.z,D[U]=G,D[U+1]=J,D[U+2]=ie,D[U+3]=J,D[U+4]=ne,D[U+5]=ie,T[I]=G,T[I+1]=J,T[I+2]=G,T[I+3]=ie,T[I+4]=J,T[I+5]=ne,T[I+6]=ne,T[I+7]=ie,a.faceidx+=6,a.lineidx+=8)}}}R.drawSphere=m;function r(e,t,s,o,l,d,i=16,n=4){const a=new b.Vector3(s.x,s.y,s.z),h=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);if(h<1e-4)return;a.multiplyScalar(1/h);let u=new b.Vector3(0,1,0);Math.abs(a.x*u.x+a.y*u.y+a.z*u.z)>.9&&(u=new b.Vector3(1,0,0));const A=new b.Vector3;A.crossVectors(a,u).normalize();const D=new b.Vector3;D.crossVectors(A,a).normalize();const T=(i+1)*(n+1),S=e.updateGeoGroup(T),P=S.vertices,z=S.vertexArray,F=S.colorArray,B=S.normalArray,W=S.faceArray,U=S.lineArray;for(let I=0;I<=i;I++){const G=I/i*2*Math.PI,Y=Math.cos(G),J=Math.sin(G),te=Y*A.x+J*D.x,ne=Y*A.y+J*D.y,le=Y*A.z+J*D.z,ie=t.x+o*te,oe=t.y+o*ne,xe=t.z+o*le;for(let _e=0;_e<=n;_e++){const Oe=_e/n*2*Math.PI,ye=Math.cos(Oe),ee=Math.sin(Oe),pe=ye*te+ee*a.x,Ce=ye*ne+ee*a.y,Te=ye*le+ee*a.z,We=I*(n+1)+_e,Ie=3*(P+We);z[Ie]=ie+l*pe,z[Ie+1]=oe+l*Ce,z[Ie+2]=xe+l*Te,B[Ie]=pe,B[Ie+1]=Ce,B[Ie+2]=Te,F[Ie]=d.r,F[Ie+1]=d.g,F[Ie+2]=d.b}}S.vertices+=T;for(let I=0;I<i;I++)for(let G=0;G<n;G++){const Y=P+I*(n+1)+G,J=P+I*(n+1)+(G+1),te=P+(I+1)*(n+1)+(G+1),ne=P+(I+1)*(n+1)+G,le=S.faceidx;W[le]=Y,W[le+1]=J,W[le+2]=ne,W[le+3]=J,W[le+4]=te,W[le+5]=ne,S.faceidx+=6;const ie=S.lineidx;U[ie]=Y,U[ie+1]=J,U[ie+2]=Y,U[ie+3]=ne,U[ie+4]=J,U[ie+5]=te,U[ie+6]=te,U[ie+7]=ne,S.lineidx+=8}}R.drawTorus=r})(C||(C={}))},"./src/GLModel.ts"(k,w,c){c.r(w),c.d(w,{GLModel:()=>m});var b=c("./src/WebGL/index.ts"),O=c("./src/WebGL/shapes/index.ts"),C=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts"),v=c("./src/GLDraw.ts"),y=c("./src/glcartoon.ts"),M=c("./src/utilities.ts"),g=c("./src/Gradient.ts"),x=c("./src/parsers/index.ts"),_=c("./node_modules/netcdfjs/lib-esm/index.js"),p=c("./src/parsers/utils/assignBonds.ts");class m{static sameObj(e,t){return e&&t?JSON.stringify(e)==JSON.stringify(t):e==t}constructor(e,t,s){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 C.Matrix4,this.dontDuplicateAtoms=!0,this.defaultColor=R.elementColors.defaultColor,this.defaultStickRadius=.25,this._drawnAromaticRings=new Set,this._ringCache=new Map,this.options=t||{},this.viewer=s,this.ElementColors=this.options.defaultcolors?this.options.defaultcolors:R.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 s=this.defaultSphereRadius;if(typeof t.radius<"u")s=t.radius;else if(m.vdwRadii[e.elem])s=m.vdwRadii[e.elem];else if(e.elem.length>1){let o=e.elem;o=o[0].toUpperCase()+o[1].toLowerCase(),m.vdwRadii[o]&&(s=m.vdwRadii[o])}return typeof t.scale<"u"&&(s*=t.scale),s}drawAtomCross(e,t){if(e.style.cross){var s=e.style.cross;if(!s.hidden){var o=s.linewidth||m.defaultlineWidth;t[o]||(t[o]=new b.Geometry);var l=t[o].updateGeoGroup(6),d=this.getRadiusFromStyle(e,s),i=[[d,0,0],[-d,0,0],[0,d,0],[0,-d,0],[0,0,d],[0,0,-d]],n=e.clickable||e.hoverable;n&&e.intersectionShape===void 0&&(e.intersectionShape={sphere:[],cylinder:[],line:[]});for(var a=(0,M.getColorFromStyle)(e,s),h=l.vertexArray,u=l.colorArray,A=0;A<6;A++){var D=l.vertices*3;if(l.vertices++,h[D]=e.x+i[A][0],h[D+1]=e.y+i[A][1],h[D+2]=e.z+i[A][2],u[D]=a.r,u[D+1]=a.g,u[D+2]=a.b,n){var T=new C.Vector3(i[A][0],i[A][1],i[A][2]);T.multiplyScalar(.1),T.set(T.x+e.x,T.y+e.y,T.z+e.z),e.intersectionShape.line.push(T)}}}}}getGoodCross(e,t,s,o){for(var l=null,d=-1,i=0,n=e.bonds.length;i<n;i++)if(e.bonds[i]!=t.index){let h=e.bonds[i],u=this.atoms[h],D=new C.Vector3(u.x,u.y,u.z).clone();D.sub(s);let T=D.clone();T.cross(o);var a=T.lengthSq();if(a>d&&(d=a,l=T,d>.1))return l}return l}getSideBondV(e,t,s){var o,l,d,i,n,a=new C.Vector3(e.x,e.y,e.z),h=new C.Vector3(t.x,t.y,t.z),u=h.clone(),A=null;if(u.sub(a),e.bonds.length===1)if(t.bonds.length===1)A=u.clone(),Math.abs(A.x)>1e-4?A.y+=1:A.x+=1;else{for(d=null,o=0;o<t.bonds.length;o++)if(l=t.bonds[o],l!==e.index){d=this.atoms[l];break}d?(i=new C.Vector3(d.x,d.y,d.z),n=i.clone(),n.sub(a),A=n.clone(),A.cross(u)):(A=u.clone(),A.x+=1)}else if(A=this.getGoodCross(e,t,a,u),A.lengthSq()<.01){var D=this.getGoodCross(t,e,a,u);D!=null&&(A=D)}A.lengthSq()<.01&&(A=u.clone(),Math.abs(A.x)>1e-4?A.y+=1:A.x+=1),A.cross(u),A.normalize();var T=.001;return Math.abs(A.x)>T?A.x<0&&A.negate():Math.abs(A.y)>T?A.y<0&&A.negate():A.z<0&&A.negate(),A}addLine(e,t,s,o,l,d){e[s]=o.x,e[s+1]=o.y,e[s+2]=o.z,t[s]=d.r,t[s+1]=d.g,t[s+2]=d.b,e[s+3]=l.x,e[s+4]=l.y,e[s+5]=l.z,t[s+3]=d.r,t[s+4]=d.g,t[s+5]=d.b}drawBondLines(e,t,s){if(e.style.line){var o=e.style.line;if(!o.hidden){var l,d,i,n,a=o.linewidth||m.defaultlineWidth;s[a]||(s[a]=new b.Geometry);for(var h=s[a].updateGeoGroup(6*e.bonds.length),u=h.vertexArray,A=h.colorArray,D=0;D<e.bonds.length;D++){var T=e.bonds[D],S=t[T];if(S.style.line&&!(e.index>=S.index)){var P=new C.Vector3(e.x,e.y,e.z),z=new C.Vector3(S.x,S.y,S.z),F=P.clone().add(z).multiplyScalar(.5),B=!1,W=e.clickable||e.hoverable,U=S.clickable||S.hoverable;(W||U)&&(W&&(e.intersectionShape===void 0&&(e.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),e.intersectionShape.line.push(P),e.intersectionShape.line.push(F)),U&&(S.intersectionShape===void 0&&(S.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),S.intersectionShape.line.push(F),S.intersectionShape.line.push(z)));var I=(0,M.getColorFromStyle)(e,e.style.line),G=(0,M.getColorFromStyle)(S,S.style.line);if(e.bondStyles&&e.bondStyles[D]){var Y=e.bondStyles[D];if(!Y.iswire)continue;Y.singleBond&&(B=!0),typeof Y.color1<"u"&&(I=R.CC.color(Y.color1)),typeof Y.color2<"u"&&(G=R.CC.color(Y.color2))}var J=h.vertices*3,te,ne;if(e.bondOrder[D]>1&&e.bondOrder[D]<4&&!B){var le=this.getSideBondV(e,S,D),ie=z.clone();ie.sub(P),e.bondOrder[D]==2?(le.multiplyScalar(.1),l=P.clone(),l.add(le),d=P.clone(),d.sub(le),i=l.clone(),i.add(ie),n=d.clone(),n.add(ie),I==G?(h.vertices+=4,this.addLine(u,A,J,l,i,I),this.addLine(u,A,J+6,d,n,I)):(h.vertices+=8,ie.multiplyScalar(.5),te=l.clone(),te.add(ie),ne=d.clone(),ne.add(ie),this.addLine(u,A,J,l,te,I),this.addLine(u,A,J+6,te,i,G),this.addLine(u,A,J+12,d,ne,I),this.addLine(u,A,J+18,ne,n,G))):e.bondOrder[D]==3&&(le.multiplyScalar(.1),l=P.clone(),l.add(le),d=P.clone(),d.sub(le),i=l.clone(),i.add(ie),n=d.clone(),n.add(ie),I==G?(h.vertices+=6,this.addLine(u,A,J,P,z,I),this.addLine(u,A,J+6,l,i,I),this.addLine(u,A,J+12,d,n,I)):(h.vertices+=12,ie.multiplyScalar(.5),te=l.clone(),te.add(ie),ne=d.clone(),ne.add(ie),this.addLine(u,A,J,P,F,I),this.addLine(u,A,J+6,F,z,G),this.addLine(u,A,J+12,l,te,I),this.addLine(u,A,J+18,te,i,G),this.addLine(u,A,J+24,d,ne,I),this.addLine(u,A,J+30,ne,n,G)))}else I==G?(h.vertices+=2,this.addLine(u,A,J,P,z,I)):(h.vertices+=4,this.addLine(u,A,J,P,F,I),this.addLine(u,A,J+6,F,z,G))}}}}}drawAtomSphere(e,t){if(e.style.sphere){var s=e.style.sphere;if(!s.hidden){var o=(0,M.getColorFromStyle)(e,s),l=this.getRadiusFromStyle(e,s);if((e.clickable===!0||e.hoverable)&&e.intersectionShape!==void 0){var d=new C.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new O.Sphere(d,l))}v.GLDraw.drawSphere(t,e,l,o)}}}drawAtomClickSphere(e){if(e.style.clicksphere){var t=e.style.clicksphere;if(!t.hidden){var s=this.getRadiusFromStyle(e,t);if((e.clickable===!0||e.hoverable)&&e.intersectionShape!==void 0){var o=new C.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new O.Sphere(o,s))}}}}drawAtomInstanced(e,t){if(e.style.sphere){var s=e.style.sphere;if(!s.hidden){var o=this.getRadiusFromStyle(e,s),l=(0,M.getColorFromStyle)(e,s),d=t.updateGeoGroup(1),i=d.vertices,n=i*3,a=d.vertexArray,h=d.colorArray,u=d.radiusArray;if(a[n]=e.x,a[n+1]=e.y,a[n+2]=e.z,h[n]=l.r,h[n+1]=l.g,h[n+2]=l.b,u[i]=o,(e.clickable===!0||e.hoverable)&&e.intersectionShape!==void 0){var A=new C.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new O.Sphere(A,o))}d.vertices+=1}}}drawSphereImposter(e,t,s,o){var l=e.updateGeoGroup(4),d,i=l.vertices,n=i*3,a=l.vertexArray,h=l.colorArray;for(d=0;d<4;d++)a[n+3*d]=t.x,a[n+3*d+1]=t.y,a[n+3*d+2]=t.z;var u=l.normalArray;for(d=0;d<4;d++)h[n+3*d]=o.r,h[n+3*d+1]=o.g,h[n+3*d+2]=o.b;u[n+0]=-s,u[n+1]=s,u[n+2]=0,u[n+3]=-s,u[n+4]=-s,u[n+5]=0,u[n+6]=s,u[n+7]=-s,u[n+8]=0,u[n+9]=s,u[n+10]=s,u[n+11]=0,l.vertices+=4;var A=l.faceArray,D=l.faceidx;A[D+0]=i,A[D+1]=i+1,A[D+2]=i+2,A[D+3]=i+2,A[D+4]=i+3,A[D+5]=i,l.faceidx+=6}drawAtomImposter(e,t){if(e.style.sphere){var s=e.style.sphere;if(!s.hidden){var o=this.getRadiusFromStyle(e,s),l=(0,M.getColorFromStyle)(e,s);if((e.clickable===!0||e.hoverable)&&e.intersectionShape!==void 0){var d=new C.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new O.Sphere(d,o))}this.drawSphereImposter(t,e,o,l)}}}drawRingImposter(e,t,s,o,l,d){for(var i=e.updateGeoGroup(4),n=i.vertices,a=n*3,h=i.vertexArray,u=i.colorArray,A=i.normalArray,D=i.radiusArray,T=o+l,S=0;S<4;S++)h[a+3*S]=t.x,h[a+3*S+1]=t.y,h[a+3*S+2]=t.z;for(var P=s.x*l,z=s.y*l,F=s.z*l,S=0;S<4;S++)A[a+3*S]=P,A[a+3*S+1]=z,A[a+3*S+2]=F;var B=Math.abs(d.b);B<1e-4&&(B=1e-4),u[a+0]=d.r,u[a+1]=d.g,u[a+2]=B,u[a+3]=d.r,u[a+4]=d.g,u[a+5]=-B,u[a+6]=d.r,u[a+7]=d.g,u[a+8]=-B,u[a+9]=d.r,u[a+10]=d.g,u[a+11]=B,D[n+0]=-T,D[n+1]=-T,D[n+2]=T,D[n+3]=T,i.vertices+=4;var W=i.faceArray,U=i.faceidx;W[U+0]=n,W[U+1]=n+1,W[U+2]=n+2,W[U+3]=n+2,W[U+4]=n+3,W[U+5]=n,i.faceidx+=6}calculateDashes(e,t,s,o,l,d){var i,n,a;const h=t.x-e.x,u=t.y-e.y,A=t.z-e.z,D=Math.sqrt(h*h+u*u+A*A);if(D<.001)return[{from:new C.Vector3(e.x,e.y,e.z),to:new C.Vector3(t.x,t.y,t.z),color:(i=d==null?void 0:d[0])!==null&&i!==void 0?i:null}];s=Math.max(s,0),o=Math.max(o,.001);const T=Math.max(l,0)+2*s,S=T/2,P=D-2*S;if(P<o)return[{from:new C.Vector3(e.x,e.y,e.z),to:new C.Vector3(t.x,t.y,t.z),color:(n=d==null?void 0:d[0])!==null&&n!==void 0?n:null}];const z=Math.floor((P-o)/(o+T))+1,F=z*o,B=z>1?z-1:0,W=P-F,U=B>0?W/(B+1):W,I=U/2,G=h/D,Y=u/D,J=A/D,te=[],ne=S+I;for(let le=0;le<z;le++){const ie=ne+le*(o+U),oe=ie+o,xe=new C.Vector3(e.x+G*ie,e.y+Y*ie,e.z+J*ie),_e=new C.Vector3(e.x+G*oe,e.y+Y*oe,e.z+J*oe),ye=d&&d.length>1&&le>=z/2?d[1]:(a=d==null?void 0:d[0])!==null&&a!==void 0?a:null;te.push({from:xe,to:_e,color:ye})}return te}calculateTwoColorSegments(e,t,s){const o=[];if(s.length<=1)o.push({from:new C.Vector3(e.x,e.y,e.z),to:new C.Vector3(t.x,t.y,t.z),color:s[0]});else{const l=new C.Vector3((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2);o.push({from:new C.Vector3(e.x,e.y,e.z),to:l,color:s[0]}),o.push({from:l,to:new C.Vector3(t.x,t.y,t.z),color:s[1]})}return o}findSmallestRing(e,t,s=8){const o=e<t?e:t,l=e<t?t:e,d=o+","+l;if(this._ringCache.has(d))return this._ringCache.get(d);const i=[[e]],n=new Set([e]);for(;i.length>0;){const a=i.shift(),h=a[a.length-1];if(a.length>=s)continue;const u=this.atoms[h];if(!(!u||!u.bonds))for(let A=0;A<u.bonds.length;A++){const D=u.bonds[A];if(!(h===e&&D===t)&&!(h===t&&D===e)){if(D===t&&a.length>=2){const T=[...a,t];return this._ringCache.set(d,T),T}n.has(D)||(n.add(D),i.push([...a,D]))}}}return this._ringCache.set(d,null),null}chooseDashedSide(e,t,s,o,l){const d=this.findSmallestRing(e.index,t.index);if(d&&d.length>=3){const i=new C.Vector3(0,0,0);for(let D=0;D<d.length;D++){const T=this.atoms[d[D]];i.x+=T.x,i.y+=T.y,i.z+=T.z}i.multiplyScalar(1/d.length);const n=new C.Vector3().addVectors(s,o).multiplyScalar(.5),a=new C.Vector3(i.x-n.x,i.y-n.y,i.z-n.z),h=l.x*a.x+l.y*a.y+l.z*a.z,u=Math.sqrt(l.x*l.x+l.y*l.y+l.z*l.z),A=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);if(A>=.001&&Math.abs(h)>=.05*u*A)return h>0}return this.chooseDashedPlusV(e,t,s,o,l)}chooseDashedPlusV(e,t,s,o,l){const d=new C.Vector3(0,0,0);let i=0;for(let D=0;D<e.bonds.length;D++){if(e.bonds[D]===t.index)continue;const T=this.atoms[e.bonds[D]];T&&(d.x+=T.x,d.y+=T.y,d.z+=T.z,i++)}for(let D=0;D<t.bonds.length;D++){if(t.bonds[D]===e.index)continue;const T=this.atoms[t.bonds[D]];T&&(d.x+=T.x,d.y+=T.y,d.z+=T.z,i++)}if(i===0)return!1;d.multiplyScalar(1/i);const n=new C.Vector3().addVectors(s,o).multiplyScalar(.5),a=new C.Vector3(d.x-n.x,d.y-n.y,d.z-n.z),h=l.x*a.x+l.y*a.y+l.z*a.z,u=Math.sqrt(l.x*l.x+l.y*l.y+l.z*l.z),A=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);return A<.001||Math.abs(h)<.1*u*A?!1:h>0}drawAromaticRingTorus(e,t,s,o,l){var d;const i=this.findSmallestRing(e.index,t.index);if(!i||i.length<3)return;const n=i.slice().sort((B,W)=>B-W).join(",");if(this._drawnAromaticRings.has(n))return;this._drawnAromaticRings.add(n);const a=new C.Vector3(0,0,0);for(let B=0;B<i.length;B++){const W=this.atoms[i[B]];a.x+=W.x,a.y+=W.y,a.z+=W.z}a.multiplyScalar(1/i.length);const h=new C.Vector3(0,0,0);for(let B=0;B<i.length;B++){const W=this.atoms[i[B]],U=this.atoms[i[(B+1)%i.length]];h.x+=(W.y-U.y)*(W.z+U.z),h.y+=(W.z-U.z)*(W.x+U.x),h.z+=(W.x-U.x)*(W.y+U.y)}const u=Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z);if(u<1e-4)return;h.multiplyScalar(1/u);let A=0,D=0;for(let B=0;B<i.length;B++){const W=this.atoms[i[B]],U=W.x-a.x,I=W.y-a.y,G=W.z-a.z;if(A+=Math.sqrt(U*U+I*I+G*G),!((d=W.style)===null||d===void 0)&&d.sphere&&!W.style.sphere.hidden&&W.style.sphere.radius){const Y=this.getRadiusFromStyle(W,W.style.sphere);Y>D&&(D=Y)}}A/=i.length;const T=o*.5,P=A*Math.cos(Math.PI/i.length)-T-2*o,z=A-T-D-o,F=Math.max(T,Math.min(P,z));s.imposter?this.drawRingImposter(s,a,h,F,T,l):v.GLDraw.drawTorus(s,a,h,F,T,l)}static drawStickImposter(e,t,s,o,l,d=0,i=0){for(var n=e.updateGeoGroup(4),a=n.vertices,h=a*3,u=n.vertexArray,A=n.colorArray,D=n.radiusArray,T=n.normalArray,S=l.r,P=l.g,z=l.b,F=function(G){var Y=-G;return Y==0&&(Y=-1e-4),Y},B=h,W=0;W<4;W++)u[B]=t.x,T[B]=s.x,A[B]=S,B++,u[B]=t.y,T[B]=s.y,A[B]=P,B++,u[B]=t.z,T[B]=s.z,W<2?A[B]=z:A[B]=F(z),B++;n.vertices+=4,D[a]=-o,D[a+1]=o,D[a+2]=-o,D[a+3]=o;var U=n.faceArray,I=n.faceidx;U[I+0]=a,U[I+1]=a+1,U[I+2]=a+2,U[I+3]=a+2,U[I+4]=a+3,U[I+5]=a,n.faceidx+=6}drawBondSticks(e,t,s,o){var l,d,i,n,a,h,u,A,D,T;if(!e.style.stick)return;var S=e.style.stick;if(S.hidden)return;var P=S.radius||this.defaultStickRadius,z=S.doubleBondScaling||.4,F=S.tripleBondScaling||.25;const B=((l=S.dashedBondConfig)===null||l===void 0?void 0:l.dashLength)||.1,W=((d=S.dashedBondConfig)===null||d===void 0?void 0:d.gapLength)||.25,U=S.aromaticStyle||"dashed";var I=P,G=S.singleBonds||!1,Y=S.dashedBonds||!1,J=0,te=0,ne,le,ie,oe,xe,_e,Oe,ye,ee,pe,Ce=(0,M.getColorFromStyle)(e,S),Te,We,Ie;!e.capDrawn&&e.bonds.length<4&&(J=2);const Be=!((i=S.dashedBondConfig)===null||i===void 0)&&i.solidColor?R.CC.color(S.dashedBondConfig.solidColor):null,Fe=!((n=S.dashedBondConfig)===null||n===void 0)&&n.dashedColor?R.CC.color(S.dashedBondConfig.dashedColor):null,ze=we=>{const j=s.imposter?m.drawStickImposter:v.GLDraw.drawCylinder;return!Y&&we%1===0?(se,ge,Se,re,be,V,De=0,Le=0)=>{if(!V||be===V)j(se,ge,Se,re,be,De,Le);else{const L=this.calculateTwoColorSegments(ge,Se,[be,V]);for(let he=0;he<L.length;he++){const fe=L[he],H=he===0?De:0,ae=he===L.length-1?Le:0;j(se,fe.from,fe.to,re,fe.color,H,ae)}}}:(se,ge,Se,re,be,V,De=0,Le=0)=>{const L=V?[be,V]:[be];this.calculateDashes(ge,Se,re,B,W,L).forEach(fe=>{j(se,fe.from,fe.to,re,fe.color,De,Le)})}};for(ie=0;ie<e.bonds.length;ie++){const we=e.bondOrder[ie],j=we===4;let se;j?se=U==="circle"?1:1.5:se=we;const ge=ze(se),Se=e.bonds[ie],re=t[Se];if(Te=We=Ie=null,e.index<re.index){te=0;const be=re.style;if(!be.stick||be.stick.hidden)continue;let V=Ce,De=(0,M.getColorFromStyle)(re,be.stick);I=P,oe=G;const Le=(a=e.bondStyles)===null||a===void 0?void 0:a[ie];if(Le){if(Le.iswire)continue;Le.radius&&(I=Le.radius),Le.singleBond&&(oe=!0),typeof Le.color1<"u"&&(V=R.CC.color(Le.color1)),typeof Le.color2<"u"&&(De=R.CC.color(Le.color2))}const L=new C.Vector3(e.x,e.y,e.z),he=new C.Vector3(re.x,re.y,re.z),fe=!((h=Le==null?void 0:Le.dashedBondConfig)===null||h===void 0)&&h.solidColor?R.CC.color(Le.dashedBondConfig.solidColor):null,H=!((u=Le==null?void 0:Le.dashedBondConfig)===null||u===void 0)&&u.dashedColor?R.CC.color(Le.dashedBondConfig.dashedColor):null,ae=Le&&(typeof Le.color1<"u"||typeof Le.color2<"u"),ve=fe||(ae?V:Be||V),Ve=fe||(ae?De:Be||De),Ne=H||(ae?V:Fe||V),Ge=H||(ae?De:Fe||De),qe=((A=Le==null?void 0:Le.dashedBondConfig)===null||A===void 0?void 0:A.dashLength)||B,_t=((D=Le==null?void 0:Le.dashedBondConfig)===null||D===void 0?void 0:D.gapLength)||W;if(se<=1||oe||se>3){se<1&&(I*=se),!re.capDrawn&&re.bonds.length<4&&(te=2);const Ye=se%1!==0;if(ge(s,L,he,I,Ye?Ne:V,Ye?Ge:De,J,te),ne=e.clickable||e.hoverable,le=re.clickable||re.hoverable,ne||le){if(Te||(Te=new C.Vector3().addVectors(L,he).multiplyScalar(.5)),ne){var Pe=new O.Cylinder(L,Te,I),Re=new O.Sphere(L,I);e.intersectionShape.cylinder.push(Pe),e.intersectionShape.sphere.push(Re)}if(le){var je=new O.Cylinder(he,Te,I),ke=new O.Sphere(he,I);re.intersectionShape.cylinder.push(je),re.intersectionShape.sphere.push(ke)}}if(j&&U==="circle"){const tt=H||Fe||V;this.drawAromaticRingTorus(e,re,o,I,tt)}}else if(se>1){var K=0,Z=0;I!=P&&(K=2,Z=2);const Ye=he.clone();Ye.sub(L);let He,$e,tt,et,bt,xt;const st=this.getSideBondV(e,re,ie);let lt=!1;se%1!==0&&((Le==null?void 0:Le.dashedBondFlip)!=null?lt=Le.dashedBondFlip:lt=this.chooseDashedSide(e,re,L,he,st));const dt=s.imposter?m.drawStickImposter:v.GLDraw.drawCylinder,vt=(At,Lt,Ct,Tt,It,Bt,Ut)=>{if(Tt!=It){const Wt=new C.Vector3().addVectors(At,Lt).multiplyScalar(.5);dt(s,At,Wt,Ct,Tt,Bt,0),dt(s,Wt,Lt,Ct,It,0,Ut)}else dt(s,At,Lt,Ct,Tt,Bt,Ut)},Mt=(At,Lt,Ct,Tt,It,Bt,Ut)=>{const Wt=Tt!=It?[Tt,It]:[Tt];this.calculateDashes(At,Lt,Ct,qe,_t,Wt).forEach(ri=>{dt(s,ri.from,ri.to,Ct,ri.color||Tt,Bt,Ut)})};if(se>1&&se<=2){if(He=I*z,$e=He*(se-1),st.multiplyScalar(He*1.5),tt=L.clone(),tt.add(st),et=L.clone(),et.sub(st),bt=tt.clone(),bt.add(Ye),xt=et.clone(),xt.add(Ye),se===2?(vt(tt,bt,He,V,De,K,Z),vt(et,xt,He,V,De,K,Z)):lt?(Mt(tt,bt,$e,Ne,Ge,K,Z),vt(et,xt,He,ve,Ve,K,Z)):(vt(tt,bt,He,ve,Ve,K,Z),Mt(et,xt,$e,Ne,Ge,K,Z)),ne=e.clickable||e.hoverable,le=re.clickable||re.hoverable,ne||le){Te||(Te=new C.Vector3().addVectors(tt,bt).multiplyScalar(.5)),We||(We=new C.Vector3().addVectors(et,xt).multiplyScalar(.5));const At=se===2?He:lt?$e:He,Lt=se===2||lt?He:$e;ne&&(xe=new O.Cylinder(tt,Te,At),_e=new O.Cylinder(et,We,Lt),e.intersectionShape.cylinder.push(xe),e.intersectionShape.cylinder.push(_e)),le&&(ye=new O.Cylinder(bt,Te,At),ee=new O.Cylinder(xt,We,Lt),re.intersectionShape.cylinder.push(ye),re.intersectionShape.cylinder.push(ee))}}else if(se>2&&se<=3){He=I*F;const At=He*(se-2);if(st.cross(Ye),st.normalize(),st.multiplyScalar(He*3),tt=L.clone(),tt.add(st),et=L.clone(),et.sub(st),bt=tt.clone(),bt.add(Ye),xt=et.clone(),xt.add(Ye),se===3?(vt(tt,bt,He,V,De,K,Z),vt(L,he,He,V,De,J,te),vt(et,xt,He,V,De,K,Z)):lt?(Mt(tt,bt,At,Ne,Ge,K,Z),vt(L,he,He,ve,Ve,J,te),vt(et,xt,He,ve,Ve,K,Z)):(vt(tt,bt,He,ve,Ve,K,Z),vt(L,he,He,ve,Ve,J,te),Mt(et,xt,At,Ne,Ge,K,Z)),ne=e.clickable||e.hoverable,le=re.clickable||re.hoverable,ne||le){Te||(Te=new C.Vector3().addVectors(tt,bt).multiplyScalar(.5)),We||(We=new C.Vector3().addVectors(et,xt).multiplyScalar(.5)),Ie||(Ie=new C.Vector3().addVectors(L,he).multiplyScalar(.5));const Lt=se===3?He:lt?At:He,Ct=se===3||lt?He:At;ne&&(xe=new O.Cylinder(tt.clone(),Te.clone(),Lt),_e=new O.Cylinder(et.clone(),We.clone(),Ct),Oe=new O.Cylinder(L.clone(),Ie.clone(),He),e.intersectionShape.cylinder.push(xe),e.intersectionShape.cylinder.push(_e),e.intersectionShape.cylinder.push(Oe)),le&&(ye=new O.Cylinder(bt.clone(),Te.clone(),Lt),ee=new O.Cylinder(xt.clone(),We.clone(),Ct),pe=new O.Cylinder(he.clone(),Ie.clone(),He),re.intersectionShape.cylinder.push(ye),re.intersectionShape.cylinder.push(ee),re.intersectionShape.cylinder.push(pe))}}}}}var $=!1,me=0,ce=!1;for(ie=0;ie<e.bonds.length;ie++){oe=G;var Me=(T=e.bondStyles)===null||T===void 0?void 0:T[ie];Me&&(Me.singleBond&&(oe=!0),Me.radius&&Me.radius!=P&&(ce=!0)),(oe||e.bondOrder[ie]==1)&&me++}ce?me>0&&($=!0):me==0&&(e.bonds.length>0||S.showNonBonded)&&($=!0),$&&(I=P,s.imposter?this.drawSphereImposter(s.sphereGeometry,e,I,Ce):v.GLDraw.drawSphere(s,e,I,Ce))}createMolObj(e,t){t=t||{},this._drawnAromaticRings=new Set,this._ringCache=new Map;var s=new b.Object3D,o=[],l={},d={},i=this.drawAtomSphere,n=null,a=null,h=null;t.supportsImposters?(h=new b.Geometry(!0),h.imposter=!0,h.radii=!0,i=this.drawAtomImposter,n=new b.Geometry(!0),n.imposter=!0,a=new b.Geometry(!0,!0),a.imposter=!0,a.sphereGeometry=new b.Geometry(!0),a.sphereGeometry.imposter=!0,a.drawnCaps={}):t.supportsAIA?(h=new b.Geometry(!0),i=this.drawAtomInstanced,n=new b.Geometry(!1,!0,!0),n.instanced=!0,a=new b.Geometry(!0)):(h=new b.Geometry(!0),n=new b.Geometry(!0),a=new b.Geometry(!0));var u,A,D,T,S={},P=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(u=0,D=e.length;u<D;u++){var z=e[u];if(z&&z.style){(z.clickable||z.hoverable)&&z.intersectionShape===void 0&&(z.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),T={line:void 0,cross:void 0,stick:void 0,sphere:void 0};for(A in T)z.style[A]?z.style[A].opacity?T[A]=parseFloat(z.style[A].opacity):T[A]=1:T[A]=void 0,S[A]?T[A]!=null&&S[A]!=T[A]&&(console.log("Warning: "+A+" opacity is ambiguous"),S[A]=1):S[A]=T[A];i.call(this,z,n),this.drawAtomClickSphere(z),this.drawAtomCross(z,d),this.drawBondLines(z,e,l),this.drawBondSticks(z,e,a,h),typeof z.style.cartoon<"u"&&!z.style.cartoon.hidden&&(z.style.cartoon.color==="spectrum"&&typeof z.resi=="number"&&!z.hetflag&&(z.resi<P[0]&&(P[0]=z.resi),z.resi>P[1]&&(P[1]=z.resi)),o.push(z))}}if(o.length>0&&(0,y.drawCartoon)(s,o,P,this.defaultCartoonQuality),n&&n.vertices>0){n.initTypedArrays();var F=null,B=null;n.imposter?F=new b.SphereImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):n.instanced?(B=new b.Geometry(!0),v.GLDraw.drawSphere(B,{x:0,y:0,z:0},1,new R.Color(.5,.5,.5)),B.initTypedArrays(),F=new b.InstancedMaterial({sphereMaterial:new b.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),sphere:B})):F=new b.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),S.sphere<1&&S.sphere>=0&&(F.transparent=!0,F.opacity=S.sphere),B=new b.Mesh(n,F),s.add(B)}if(a.vertices>0){var W=null,U=null,I=a.sphereGeometry;(!I||typeof I.vertices>"u"||I.vertices==0)&&(I=null),a.initTypedArrays(),I&&I.initTypedArrays();var G={ambient:0,vertexColors:!0,reflectivity:0};a.imposter?(W=new b.StickImposterMaterial(G),U=new b.SphereImposterMaterial(G)):(W=new b.MeshLambertMaterial(G),U=new b.MeshLambertMaterial(G),W.wireframe&&(a.setUpWireframe(),I&&I.setUpWireframe())),S.stick<1&&S.stick>=0&&(W.transparent=!0,W.opacity=S.stick,U.transparent=!0,U.opacity=S.stick);var Y=new b.Mesh(a,W);if(s.add(Y),I){var J=new b.Mesh(I,U);s.add(J)}}if(h.vertices>0){h.initTypedArrays();var te;h.imposter?te=new b.RingImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):te=new b.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),S.stick<1&&S.stick>=0&&(te.transparent=!0,te.opacity=S.stick),s.add(new b.Mesh(h,te))}var ne;for(u in l)if(l.hasOwnProperty(u)){ne=u;var le=new b.LineBasicMaterial({linewidth:ne,vertexColors:!0});S.line<1&&S.line>=0&&(le.transparent=!0,le.opacity=S.line),l[u].initTypedArrays();var ie=new b.Line(l[u],le,b.LineStyle.LinePieces);s.add(ie)}for(u in d)if(d.hasOwnProperty(u)){ne=u;var oe=new b.LineBasicMaterial({linewidth:ne,vertexColors:!0});S.cross<1&&S.cross>=0&&(oe.transparent=!0,oe.opacity=S.cross),d[u].initTypedArrays();var xe=new b.Line(d[u],oe,b.LineStyle.LinePieces);s.add(xe)}if(this.dontDuplicateAtoms&&this.modelData.symmetries&&this.modelData.symmetries.length>0){var _e=new b.Object3D,Oe;for(Oe=0;Oe<this.modelData.symmetries.length;Oe++){var ye=new b.Object3D;ye=s.clone(),ye.matrix.copy(this.modelData.symmetries[Oe]),ye.matrixAutoUpdate=!1,_e.add(ye)}return _e}return s}getViewer(){return this.viewer}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,C.conversionMatrix3)(e.a,e.b,e.c,e.alpha,e.beta,e.gamma)}return this.modelData.cryst}else return null}setCrystData(e,t,s,o,l,d){e=e||1,t=t||1,s=s||1,o=o||90,l=l||90,d=d||90;const i=(0,C.conversionMatrix3)(e,t,s,o,l,d);this.modelData.cryst={a:e,b:t,c:s,alpha:o,beta:l,gamma:d,matrix:i}}setCrystMatrix(e){e=e||new C.Matrix3(1,0,0,0,1,0,0,0,1),this.modelData.cryst={matrix:e}}getSymmetries(){return typeof this.modelData.symmetries>"u"&&(this.modelData.symmetries=[this.idMatrix]),this.modelData.symmetries}setSymmetries(e){typeof e>"u"?this.modelData.symmetries=[this.idMatrix]:(this.modelData.symmetries=e,this.molObj=null)}getID(){return this.id}getNumFrames(){return this.frames.numFrames!=null?this.frames.numFrames:this.frames.length}adjustCoord(e,t,s,o){var l=t-e;return l<-s?t+o:l>s?t-o:t}adjustCoordinatesToBox(){if(this.box&&this.atomdfs)for(var e=this.box[0],t=this.box[1],s=this.box[2],o=e*.9,l=t*.9,d=s*.9,i=0;i<this.atomdfs.length;i++)for(var n=this.atomdfs[i],a=1;a<n.length;a++){var h=this.atoms[n[a][0]],u=this.atoms[n[a][1]];h.x=this.adjustCoord(u.x,h.x,o,e),h.y=this.adjustCoord(u.y,h.y,l,t),h.z=this.adjustCoord(u.z,h.z,d,s)}}setFrame(e){var t=this.getNumFrames();let s=this,o=this.viewer;return new Promise(function(l,d){if(t==0&&l(),(e<0||e>=t)&&(e=t-1),s.frames.url!=null){var i=s.frames.url;(0,M.getbin)(i+"/traj/frame/"+e+"/"+s.frames.path,void 0,"POST",void 0).then(function(n){for(var a=new Float32Array(n,44),h=0,u=0;u<s.atoms.length;u++)s.atoms[u].x=a[h++],s.atoms[u].y=a[h++],s.atoms[u].z=a[h++];s.box&&s.atomdfs&&s.adjustCoordinatesToBox(),l()}).catch(d)}else s.atoms=s.frames[e],l();s.molObj=null,s.modelDatas&&e<s.modelDatas.length&&(s.modelData=s.modelDatas[e]||{},s.unitCellObjects&&o&&(o.removeUnitCell(s),o.addUnitCell(s)))})}addFrame(e){this.frames.push(e)}vibrate(e=10,t=1,s=!1,o){var l=0,d=e;let i=this.viewer;s&&(l=-e,d=e),this.frames!==void 0&&this.frames.origIndex!==void 0?this.setFrame(this.frames.origIndex):this.setFrame(0),l<d&&(this.frames=[]),s&&(this.frames.origIndex=e);for(var n=l;n<d;n++){var a=[],h=this.frames.length;if(n==0&&!o){this.frames.push(this.atoms);continue}for(var u=0;u<this.atoms.length;u++){var A=(0,M.getAtomProperty)(this.atoms[u],"dx"),D=(0,M.getAtomProperty)(this.atoms[u],"dy"),T=(0,M.getAtomProperty)(this.atoms[u],"dz"),S=new C.Vector3(A,D,T),P=new C.Vector3(this.atoms[u].x,this.atoms[u].y,this.atoms[u].z),z=n*t/e;S.multiplyScalar(z),P.add(S);var F={};for(var B in this.atoms[u])F[B]=this.atoms[u][B];if(F.x=P.x,F.y=P.y,F.z=P.z,a.push(F),i&&o){var W=(0,M.extend)({},o),U=new C.Vector3(A,D,T);if(U.multiplyScalar(t),U.add(P),W.start=P,W.end=U,W.frame=h,!W.color){var I=F.style.sphere;I||(I=F.style.stick),I||(I=F.style.line),W.color=(0,M.getColorFromStyle)(F,I)}i.addArrow(W)}}this.frames.push(a)}}setAtomDefaults(e){for(let t=0;t<e.length;t++){let s=e[t];s&&(s.style=s.style||(0,M.deepCopy)(m.defaultAtomStyle),s.color=s.color||this.ElementColors[s.elem]||this.defaultColor,s.model=this.id,(s.clickable||s.hoverable)&&(s.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}))}}addMolData(e,t,s={}){var o,l=m.parseMolData(e,t,s);this.dontDuplicateAtoms=!s.duplicateAssemblyAtoms;var d=l.modelData;if(d&&(Array.isArray(d)?(this.modelData=d[0]||{},this.modelDatas=d):this.modelData=d),l.box?this.box=l.box:this.box=null,this.frames.length==0){const n=this.modelDatas?[]:null;for(let a=0;a<l.length;a++)l[a].length!=0&&(this.frames.push(l[a]),n&&n.push(this.modelDatas[a]||null));n&&(this.modelDatas=n,n[0]&&(this.modelData=n[0])),this.frames[0]&&(this.atoms=this.frames[0])}else if(s.frames)for(let n=0;n<l.length;n++)this.frames.push(l[n]);else for(var i=0;i<l.length;i++)this.addAtoms(l[i]);for(let n=0;n<this.frames.length;n++)this.setAtomDefaults(this.frames[n]);if(s.vibrate&&s.vibrate.frames&&s.vibrate.amplitude&&this.vibrate(s.vibrate.frames,s.vibrate.amplitude),this.modelDatas)for(let n=0;n<this.modelDatas.length;n++)!((o=this.modelDatas[n])===null||o===void 0)&&o.style&&this.setStyle({frame:n},this.modelDatas[n].style,!0);else d&&d.style&&this.setStyle({},d.style,!0);s.style&&this.setStyle({},s.style)}setDontDuplicateAtoms(e){this.dontDuplicateAtoms=e}setModelData(e){this.modelData=e}propertyMatches(e,t){if(e==t)return!0;if(typeof t=="string"&&typeof e=="number"){var s=t.match(/(-?\d+)\s*-\s*(-?\d+)/);if(s){var o=parseInt(s[1]),l=parseInt(s[2]);if(s&&e>=o&&e<=l)return!0}}return!1}static deepCopyAndCache(e,t){if(typeof e!="object"||e==null||e instanceof m||e.__cache_created)return e;const s={};for(const o in e){const l=e[o];if(Array.isArray(l)){s[o]=[];for(let d=0;d<l.length;d++)s[o].push(m.deepCopyAndCache(l[d],t))}else typeof l=="object"&&o!="properties"&&o!="model"?s[o]=m.deepCopyAndCache(l,t):s[o]=l;if(o=="and"||o=="or"){const d=[];for(const i of s[o]){const n=new Set;for(const a of t.selectedAtoms(i))n.add(a.index);d.push(n)}if(o=="and"){const i=function(a,h){const u=new Set;for(const A of h)a.has(A)&&u.add(A);return u};let n=new Set(d[0]);for(const a of d.splice(1))n=i(n,a);s[o].__cached_results=n}else if(o=="or"){const i=new Set;for(const n of d)for(const a of n)i.add(a);s[o].__cached_results=i}}}return s.__cache_created=!0,s}atomIsSelected(e,t){if(typeof t>"u")return!0;var s=!!t.invert,o=!0;for(var l in t)if(l=="and"||l=="or"||l=="not"){if(l=="not"){if(this.atomIsSelected(e,t[l])){o=!1;break}}else if(t[l].__cached_results===void 0&&(t=m.deepCopyAndCache(t,this)),o=t[l].__cached_results.has(e.index),!o)break}else if(l==="predicate"){if(!t.predicate(e)){o=!1;break}}else if(l=="properties"&&e[l]){for(var d in t.properties)if(!d.startsWith("__cache")){if(typeof e.properties[d]>"u"){o=!1;break}if(e.properties[d]!=t.properties[d]){o=!1;break}}}else if(l=="model"){let h=t.model;if(typeof h=="number"&&h<0&&(h=this.viewer.getNextModelId()+h),Array.isArray(h)){let u=!1;for(let A=0;A<h.length;A++)if(h[A]==this||h[A]==this.id){u=!0;break}if(!u){o=!1;break}}else if(h!=this&&h!=this.id){o=!1;break}}else if(t.hasOwnProperty(l)&&!m.ignoredKeys.has(l)&&!l.startsWith("__cache")){if(typeof e[l]>"u"){o=!1;break}let h=!1;if(l==="bonds"){var i=t[l];if(i!=e.bonds.length){o=!1;break}}else if(Array.isArray(t[l])){var n=t[l],a=e[l];for(let u=0;u<n.length;u++)if(this.propertyMatches(a,n[u])){h=!0;break}if(!h){o=!1;break}}else{let u=t[l];if(!this.propertyMatches(e[l],u)){o=!1;break}}}return s?!o:o}static squaredDistance(e,t){var s=t.x-e.x,o=t.y-e.y,l=t.z-e.z;return s*s+o*o+l*l}expandAtomList(e,t){if(t<=0)return e;for(var s=(0,M.getExtent)(e,void 0),o=[[],[],[]],l=0;l<3;l++)o[0][l]=s[0][l]-t,o[1][l]=s[1][l]+t,o[2][l]=s[2][l];var d=[];for(let h=0;h<this.atoms.length;h++){var i=this.atoms[h].x,n=this.atoms[h].y,a=this.atoms[h].z;i>=o[0][0]&&i<=o[1][0]&&n>=o[0][1]&&n<=o[1][1]&&a>=o[0][2]&&a<=o[1][2]&&(i>=s[0][0]&&i<=s[1][0]&&n>=s[0][1]&&n<=s[1][1]&&a>=s[0][2]&&a<=s[1][2]||d.push(this.atoms[h]))}return d}static getFloat(e){return typeof e=="number"?e:parseFloat(e)}selectedAtoms(e,t){var s=[];e=m.deepCopyAndCache(e||{},this),t||(t=this.atoms);for(var o=t.length,l=0;l<o;l++){var d=t[l];d&&this.atomIsSelected(d,e)&&s.push(d)}if(e.hasOwnProperty("expand")){const F=m.getFloat(e.expand);let B=this.expandAtomList(s,F),W=s.length;const U=F*F;for(let I=0;I<B.length;I++)for(let G=0;G<W;G++){var i=m.squaredDistance(B[I],s[G]);i<U&&i>0&&s.push(B[I])}}if(e.hasOwnProperty("within")&&e.within.hasOwnProperty("sel")&&e.within.hasOwnProperty("distance")){var n=this.selectedAtoms(e.within.sel,this.atoms),a={};const F=m.getFloat(e.within.distance),B=F*F;for(let W=0;W<n.length;W++)for(let U=0;U<s.length;U++){let I=m.squaredDistance(n[W],s[U]);I<B&&I>0&&(a[U]=1)}var h=[];if(e.within.invert)for(let W=0;W<s.length;W++)a[W]||h.push(s[W]);else for(let W in a)h.push(s[W]);s=h}if(e.hasOwnProperty("byres")){var u={},A=[],D=[];for(let F=0;F<s.length;F++){let B=s[F];var T=B.chain,S=B.resi;if(u[T]===void 0&&(u[T]={}),B.hasOwnProperty("resi")&&u[T][S]===void 0){for(u[T][S]=!0,D.push(B);D.length>0;)if(B=D.pop(),T=B.chain,S=B.resi,A[B.index]===void 0){A[B.index]=!0;for(var P=0;P<B.bonds.length;P++){var z=this.atoms[B.bonds[P]];A[z.index]===void 0&&z.hasOwnProperty("resi")&&z.chain==T&&z.resi==S&&(D.push(z),s.push(z))}}}}}return s}addAtoms(e){this.molObj=null;var t=this.atoms.length,s=[],o;for(o=0;o<e.length;o++)typeof e[o].index>"u"&&(e[o].index=o),typeof e[o].serial>"u"&&(e[o].serial=o),s[e[o].index]=t+o;for(o=0;o<e.length;o++){var l=e[o],d=s[l.index],i=(0,M.extend)({},l);i.index=d,i.bonds=[],i.bondOrder=[],i.model=this.id,i.style=i.style||(0,M.deepCopy)(m.defaultAtomStyle),typeof i.color>"u"&&(i.color=this.ElementColors[i.elem]||this.defaultColor);for(var n=l.bonds?l.bonds.length:0,a=0;a<n;a++){var h=s[l.bonds[a]];typeof h<"u"&&(i.bonds.push(h),i.bondOrder.push(l.bondOrder?l.bondOrder[a]:1))}this.atoms.push(i)}}assignBonds(){(0,p.assignBonds)(this.atoms,{assignBonds:!0})}removeAtoms(e){this.molObj=null;var t=[],s;for(s=0;s<e.length;s++)t[e[s].index]=!0;var o=[];for(s=0;s<this.atoms.length;s++){var l=this.atoms[s];t[l.index]||o.push(l)}this.atoms=[],this.addAtoms(o)}setStyle(e,t,s){typeof t>"u"&&typeof s>"u"&&(t=e,e={}),e=e,typeof t=="string"&&(t=(0,M.specStringToObject)(t));var o=!1,l=this,d=function(n){var a=l.selectedAtoms(e,n);for(let h=0;h<n.length;h++)n[h]&&(n[h].capDrawn=!1);for(let h=0;h<a.length;h++){o=!0,(a[h].clickable||a[h].hoverable)&&(a[h].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),s||(a[h].style={});for(let u in t)t.hasOwnProperty(u)&&(a[h].style[u]=a[h].style[u]||{},Object.assign(a[h].style[u],t[u]))}};if(e.frame!==void 0&&e.frame<this.frames.length){let n=e.frame;n<0&&(n=this.frames.length+n),d(this.frames[n])}else{d(this.atoms);for(var i=0;i<this.frames.length;i++)this.frames[i]!==this.atoms&&d(this.frames[i])}o&&(this.molObj=null)}setClickable(e,t,s){if(t=!!t,s=(0,M.makeFunction)(s),s===null){console.log("Callback is not a function");return}var o=this.selectedAtoms(e,this.atoms),l=o.length;for(let d=0;d<l;d++)o[d].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},o[d].clickable=t,s&&(o[d].callback=s);l>0&&(this.molObj=null)}setHoverable(e,t,s,o){if(t=!!t,s=(0,M.makeFunction)(s),o=(0,M.makeFunction)(o),s===null){console.log("Hover_callback is not a function");return}if(o===null){console.log("Unhover_callback is not a function");return}var l=this.selectedAtoms(e,this.atoms),d=l.length;for(let i=0;i<d;i++)l[i].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},l[i].hoverable=t,s&&(l[i].hover_callback=s),o&&(l[i].unhover_callback=o);d>0&&(this.molObj=null)}enableContextMenu(e,t){t=!!t;var s,o=this.selectedAtoms(e,this.atoms),l=o.length;for(s=0;s<l;s++)o[s].intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},o[s].contextMenuEnabled=t;l>0&&(this.molObj=null)}setColorByElement(e,t){if(!(this.molObj!==null&&m.sameObj(t,this.lastColors))){this.lastColors=t;var s=this.selectedAtoms(e,s);s.length>0&&(this.molObj=null);for(var o=0;o<s.length;o++){var l=s[o];typeof t[l.elem]<"u"&&(l.color=t[l.elem])}}}setColorByProperty(e,t,s,o){var l,d,i=this.selectedAtoms(e,i);for(this.lastColors=null,i.length>0&&(this.molObj=null),typeof s=="string"&&typeof g.Gradient.builtinGradients[s]<"u"&&(s=new g.Gradient.builtinGradients[s]),s=s,o||(o=s.range()),o||(o=(0,M.getPropertyRange)(i,t)),l=0;l<i.length;l++){d=i[l];var n=(0,M.getAtomProperty)(d,t);n!=null&&(d.color=s.valueToHex(parseFloat(d.properties[t]),o))}}setColorByFunction(e,t){var s=this.selectedAtoms(e,s);if(typeof t=="function"){this.lastColors=null,s.length>0&&(this.molObj=null);for(let o=0;o<s.length;o++){let l=s[o];l.color=t(l)}}}toCDObject(e=!1){var t={a:[],b:[]};e&&(t.s=[]);for(let o=0;o<this.atoms.length;o++){let l={},d=this.atoms[o];if(l.x=d.x,l.y=d.y,l.z=d.z,d.elem!="C"&&(l.l=d.elem),e){for(var s=0;s<t.s.length&&JSON.stringify(d.style)!==JSON.stringify(t.s[s]);)s++;s===t.s.length&&t.s.push(d.style),s!==0&&(l.s=s)}t.a.push(l);for(let i=0;i<d.bonds.length;i++){let n=o,a=d.bonds[i];if(n>=a)continue;let h={b:n,e:a},u=d.bondOrder[i];u!=1&&(h.o=u),t.b.push(h)}}return t}globj(e,t){(this.molObj===null||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(){var e=this.createMolObj(this.atoms,{supportsImposters:!1,supportsAIA:!1});return e.vrml()}removegl(e){this.renderedMolObj&&(this.renderedMolObj.geometry!==void 0&&this.renderedMolObj.geometry.dispose(),this.renderedMolObj.material!==void 0&&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,s){let o=this.selectedAtoms(t),l=this.viewer,d=(0,M.deepCopy)(s);for(let n=0;n<o.length;n++){let a=o[n];var i=null;typeof a[e]<"u"?i=String(a[e]):typeof a.properties[e]<"u"&&(i=String(a.properties[e])),i!=null&&(d.position=a,l.addLabel(i,d))}}addResLabels(e,t,s=!1){let o=this.viewer;var l=[],d=function(n,a){for(var h=n.selectedAtoms(e,h),u={},A=0;A<h.length;A++){var D=h[A],T=D.chain,S=D.resn,P=D.resi,z=S+""+P;u[T]||(u[T]={}),u[T][z]||(u[T][z]=[]),u[T][z].push(D)}var F=(0,M.deepCopy)(t);for(let W in u)if(u.hasOwnProperty(W)){var B=u[W];for(let U in B)if(B.hasOwnProperty(U)){let I=B[U],G=new C.Vector3(0,0,0);for(let J=0;J<I.length;J++){let te=I[J];G.x+=te.x,G.y+=te.y,G.z+=te.z}G.divideScalar(I.length),F.position=G,F.frame=a;let Y=o.addLabel(U,F,void 0,!0);l.push(Y)}}};if(s){var i=this.getNumFrames();let n=this.atoms;for(let a=0;a<i;a++)this.frames[a]&&(this.atoms=this.frames[a],d(this,a));this.atoms=n}else d(this);return l}setupDFS(){this.atomdfs=[];var e=this,t=new Int8Array(this.atoms.length);t.fill(0);for(var s=function(i,n,a){a.push([i,n]);var h=e.atoms[i];t[i]=1;for(var u=0;u<h.bonds.length;u++){var A=h.bonds[u];e.atoms[A]&&!t[A]&&s(A,i,a)}},o=0;o<this.atoms.length;o++){var l=this.atoms[o];if(l&&!t[o]){var d=[];s(o,-1,d),this.atomdfs.push(d)}}}setCoordinatesFromURL(e,t){this.frames=[];var s=this;return this.box&&this.setupDFS(),e.startsWith("http")||(e="http://"+e),(0,M.get)(e+"/traj/numframes/"+t,function(o){if(!isNaN(parseInt(o)))return s.frames.push(s.atoms),s.frames.numFrames=o,s.frames.url=e,s.frames.path=t,s.setFrame(0)})}setCoordinates(e,t){if(t=t||"",!e)return[];if(/\.gz$/.test(t)){t=t.replace(/\.gz$/,"");try{e=(0,M.inflateString)(e)}catch(u){console.log(u)}}var s={mdcrd:"",inpcrd:"",pdb:"",netcdf:"",array:""};if(s.hasOwnProperty(t)){this.frames=[];for(var o=this.atoms.length,l=m.parseCrd(e,t),d=0;d<l.length;){for(var i=[],n=0;n<o;n++){var a={};for(var h in this.atoms[n])a[h]=this.atoms[n][h];i[n]=a,i[n].x=l[d++],i[n].y=l[d++],i[n].z=l[d++]}this.frames.push(i)}return this.atoms=this.frames[0],this.frames}return[]}addAtomSpecs(e){}static parseCrd(e,t){var s=[],o=0;if(t=="pdb")for(var l=e.indexOf(`
|
|
7
|
+
ATOM`);l!=-1;){for(;e.slice(l,l+5)==`
|
|
8
|
+
ATOM`||e.slice(l,l+7)==`
|
|
9
|
+
HETATM`;)s[o++]=parseFloat(e.slice(l+31,l+39)),s[o++]=parseFloat(e.slice(l+39,l+47)),s[o++]=parseFloat(e.slice(l+47,l+55)),l=e.indexOf(`
|
|
10
|
+
`,l+54),e.slice(l,l+4)==`
|
|
11
|
+
TER`&&(l=e.indexOf(`
|
|
12
|
+
`,l+5));l=e.indexOf(`
|
|
13
|
+
ATOM`,l)}else if(t=="netcdf"){var d=new _.NetCDFReader(e);s=[].concat.apply([],d.getDataVariable("coordinates"))}else{if(t=="array"||Array.isArray(e))return e.flat(2);{let i=e.indexOf(`
|
|
14
|
+
`);t=="inpcrd"&&(i=e.indexOf(`
|
|
15
|
+
`,i+1)),e=e.slice(i+1),s=e.match(/\S+/g).map(parseFloat)}}return s}static parseMolData(e,t="",s){if(!e)return[];if(/\.gz$/.test(t)){t=t.replace(/\.gz$/,"");try{t.match(/bcif/i)?e=(0,M.inflateString)(e,!1):e=(0,M.inflateString)(e)}catch(d){console.log(d)}}typeof x.Parsers[t]>"u"&&(t=t.split(".").pop(),typeof x.Parsers[t]>"u"&&(console.log("Unknown format: "+t),e instanceof Uint8Array?t="bcif":e.match(/^@<TRIPOS>MOLECULE/gm)?t="mol2":e.match(/^data_/gm)&&e.match(/^loop_/gm)?t="cif":e.match(/^HETATM/gm)||e.match(/^ATOM/gm)?t="pdb":e.match(/ITEM: TIMESTEP/gm)?t="lammpstrj":e.match(/^.*\n.*\n.\s*(\d+)\s+(\d+)/gm)?t="sdf":e.match(/^%VERSION\s+VERSION_STAMP/gm)?t="prmtop":t="xyz",console.log("Best guess: "+t)));var o=x.Parsers[t],l=o(e,s);return l}}m.defaultAtomStyle={line:{}},m.defaultlineWidth=1,m.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},m.ignoredKeys=new Set(["props","invert","model","frame","byres","expand","within","and","or","not"])},"./src/GLShape.ts"(k,w,c){c.r(w),c.d(w,{GLShape:()=>_,splitMesh:()=>p});var b=c("./src/WebGL/index.ts"),O=c("./src/WebGL/shapes/index.ts"),C=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts"),v=c("./src/ProteinSurface4.ts"),y=c("./src/VolumeData.ts"),M=c("./src/GLDraw.ts"),g=c("./src/glcartoon.ts"),x=c("./src/utilities.ts");class _{static finalizeGeo(r){var e=r.updateGeoGroup(0);e.vertices>0&&e.truncateArrayBuffers(!0,!0)}static updateColor(r,e){e=e||R.CC.color(e),r.colorsNeedUpdate=!0;var t,s,o;e.constructor!==Array&&(t=e.r,s=e.g,o=e.b);for(let l in r.geometryGroups){let d=r.geometryGroups[l],i=d.colorArray;for(let n=0,a=d.vertices;n<a;++n){if(e.constructor===Array){let h=e[n];t=h.r,s=h.g,o=h.b}i[n*3]=t,i[n*3+1]=s,i[n*3+2]=o}}}static drawArrow(r,e,t){var s=t.start,o=t.end,l=t.radius,d=t.radiusRatio,i=t.mid,n=t.midpos;if(!(s&&o))return;var a=e.updateGeoGroup(51),h=new C.Vector3(o.x,o.y,o.z).sub(s);if(n){let re=h.length();n>0?i=n/re:i=(re+n)/re}h.multiplyScalar(i);var u=new C.Vector3(s.x,s.y,s.z).add(h),A=h.clone().negate();let D=new C.Vector3(s.x,s.y,s.z);r.intersectionShape.cylinder.push(new O.Cylinder(D,u.clone(),l)),r.intersectionShape.sphere.push(new O.Sphere(D,l));var T=[];T[0]=h.clone(),Math.abs(T[0].x)>1e-4?T[0].y+=1:T[0].x+=1,T[0].cross(h),T[0].normalize(),T[4]=T[0].clone(),T[4].crossVectors(T[0],h),T[4].normalize(),T[8]=T[0].clone().negate(),T[12]=T[4].clone().negate(),T[2]=T[0].clone().add(T[4]).normalize(),T[6]=T[4].clone().add(T[8]).normalize(),T[10]=T[8].clone().add(T[12]).normalize(),T[14]=T[12].clone().add(T[0]).normalize(),T[1]=T[0].clone().add(T[2]).normalize(),T[3]=T[2].clone().add(T[4]).normalize(),T[5]=T[4].clone().add(T[6]).normalize(),T[7]=T[6].clone().add(T[8]).normalize(),T[9]=T[8].clone().add(T[10]).normalize(),T[11]=T[10].clone().add(T[12]).normalize(),T[13]=T[12].clone().add(T[14]).normalize(),T[15]=T[14].clone().add(T[0]).normalize();var S=a.vertices,P=a.vertexArray,z=a.faceArray,F=a.normalArray,B=a.lineArray,W,U,I;for(U=0,I=T.length;U<I;++U){W=3*(S+3*U);var G=T[U].clone().multiplyScalar(l).add(s),Y=T[U].clone().multiplyScalar(l).add(u),J=T[U].clone().multiplyScalar(l*d).add(u);if(P[W]=G.x,P[W+1]=G.y,P[W+2]=G.z,P[W+3]=Y.x,P[W+4]=Y.y,P[W+5]=Y.z,P[W+6]=J.x,P[W+7]=J.y,P[W+8]=J.z,U>0){var te=P[W-3],ne=P[W-2],le=P[W-1],ie=new C.Vector3(te,ne,le),oe=new C.Vector3(o.x,o.y,o.z),xe=u.clone(),_e=new C.Vector3(J.x,J.y,J.z);r.intersectionShape.triangle.push(new O.Triangle(_e,oe,ie)),r.intersectionShape.triangle.push(new O.Triangle(ie.clone(),xe,_e.clone()))}}a.vertices+=48,W=a.vertices*3,P[W]=s.x,P[W+1]=s.y,P[W+2]=s.z,P[W+3]=u.x,P[W+4]=u.y,P[W+5]=u.z,P[W+6]=o.x,P[W+7]=o.y,P[W+8]=o.z,a.vertices+=3;var Oe,ye,ee,pe,Ce,Te,We,Ie,Be,Fe,ze,Pe,Re,je,ke,K,Z,$,me,ce=a.vertices-3,Me=a.vertices-2,we=a.vertices-1,j=ce*3,se=Me*3,ge=we*3;for(U=0,I=T.length-1;U<I;++U){var Se=S+3*U;W=Se*3,ye=a.faceidx,ee=a.lineidx,pe=Se,Fe=pe*3,Ce=Se+1,ze=Ce*3,Te=Se+2,Pe=Te*3,We=Se+4,Re=We*3,Ie=Se+5,je=Ie*3,Be=Se+3,ke=Be*3,K=Z=T[U],$=me=T[U+1],F[Fe]=K.x,F[ze]=Z.x,F[ke]=me.x,F[Fe+1]=K.y,F[ze+1]=Z.y,F[ke+1]=me.y,F[Fe+2]=K.z,F[ze+2]=Z.z,F[ke+2]=me.z,F[ze]=Z.x,F[Re]=$.x,F[ke]=me.x,F[ze+1]=Z.y,F[Re+1]=$.y,F[ke+1]=me.y,F[ze+2]=Z.z,F[Re+2]=$.z,F[ke+2]=me.z,F[Pe]=Z.x,F[je]=$.x,F[Pe+1]=Z.y,F[je+1]=$.y,F[Pe+2]=Z.z,F[je+2]=$.z,z[ye]=pe,z[ye+1]=Ce,z[ye+2]=Be,z[ye+3]=Ce,z[ye+4]=We,z[ye+5]=Be,z[ye+6]=pe,z[ye+7]=Be,z[ye+8]=ce,z[ye+9]=Te,z[ye+10]=Me,z[ye+11]=Ie,z[ye+12]=Te,z[ye+13]=we,z[ye+14]=Ie,B[ee]=pe,B[ee+1]=Ce,B[ee+2]=pe,B[ee+3]=Be,B[ee+4]=We,B[ee+5]=Be,B[ee+6]=pe,B[ee+7]=Be,B[ee+8]=Te,B[ee+9]=Ce,B[ee+10]=Te,B[ee+11]=Ie,B[ee+12]=We,B[ee+13]=Ie,B[ee+14]=Te,B[ee+15]=we,B[ee+16]=Te,B[ee+17]=Ie,B[ee+18]=we,B[ee+19]=Ie,a.faceidx+=15,a.lineidx+=20}Oe=[S+45,S+46,S+1,S,S+47,S+2],ye=a.faceidx,ee=a.lineidx,pe=Oe[0],Fe=pe*3,Ce=Oe[1],ze=Ce*3,Te=Oe[4],Pe=Te*3,We=Oe[2],Re=We*3,Ie=Oe[5],je=Ie*3,Be=Oe[3],ke=Be*3,K=Z=T[15],$=me=T[0],F[Fe]=K.x,F[ze]=Z.x,F[ke]=me.x,F[Fe+1]=K.y,F[ze+1]=Z.y,F[ke+1]=me.y,F[Fe+2]=K.z,F[ze+2]=Z.z,F[ke+2]=me.z,F[ze]=Z.x,F[Re]=$.x,F[ke]=me.x,F[ze+1]=Z.y,F[Re+1]=$.y,F[ke+1]=me.y,F[ze+2]=Z.z,F[Re+2]=$.z,F[ke+2]=me.z,F[Pe]=Z.x,F[je]=$.x,F[Pe+1]=Z.y,F[je+1]=$.y,F[Pe+2]=Z.z,F[je+2]=$.z,h.normalize(),A.normalize(),F[j]=A.x,F[se]=F[ge]=h.x,F[j+1]=A.y,F[se+1]=F[ge+1]=h.y,F[j+2]=A.z,F[se+2]=F[ge+2]=h.z,z[ye]=pe,z[ye+1]=Ce,z[ye+2]=Be,z[ye+3]=Ce,z[ye+4]=We,z[ye+5]=Be,z[ye+6]=pe,z[ye+7]=Be,z[ye+8]=ce,z[ye+9]=Te,z[ye+10]=Me,z[ye+11]=Ie,z[ye+12]=Te,z[ye+13]=we,z[ye+14]=Ie,B[ee]=pe,B[ee+1]=Ce,B[ee+2]=pe,B[ee+3]=Be,B[ee+4]=We,B[ee+5]=Be,B[ee+6]=pe,B[ee+7]=Be,B[ee+8]=Te,B[ee+9]=Ce,B[ee+10]=Te,B[ee+11]=Ie,B[ee+12]=We,B[ee+13]=Ie,B[ee+14]=Te,B[ee+15]=we,B[ee+16]=Te,B[ee+17]=Ie,B[ee+18]=we,B[ee+19]=Ie,a.faceidx+=15,a.lineidx+=20}static updateBoundingFromPoints(r,e,t,s){r.center.set(0,0,0);let o=1/0,l=1/0,d=1/0,i=-1/0,n=-1/0,a=-1/0;r.box&&(o=r.box.min.x,i=r.box.max.x,l=r.box.min.y,n=r.box.max.y,d=r.box.min.z,a=r.box.max.z);for(let D=0,T=s;D<T;D++){var h=t[D*3],u=t[D*3+1],A=t[D*3+2];h<o&&(o=h),u<l&&(l=u),A<d&&(d=A),h>i&&(i=h),u>n&&(n=u),A>a&&(a=A)}r.center.set((i+o)/2,(n+l)/2,(a+d)/2),r.radius=r.center.distanceTo({x:i,y:n,z:a}),r.box={min:{x:o,y:l,z:d},max:{x:i,y:n,z:a}}}static addCustomGeo(r,e,t,s,o){var l=e.addGeoGroup(),d=t.vertexArr,i=t.normalArr,n=t.faceArr;l.vertices=d.length,l.faceidx=n.length;var a,h,u,A,D,T,S,P,z,F=l.vertexArray,B=l.colorArray;for(s.constructor!==Array&&(P=s.r,z=s.g,A=s.b),T=0,S=l.vertices;T<S;++T)a=T*3,h=d[T],F[a]=h.x,F[a+1]=h.y,F[a+2]=h.z,s.constructor===Array&&(D=s[T],P=D.r,z=D.g,A=D.b),B[a]=P,B[a+1]=z,B[a+2]=A;if(o)for(T=0,S=l.faceidx/3;T<S;++T){a=T*3,u=n[a],A=n[a+1],D=n[a+2];var W=new C.Vector3,U=new C.Vector3,I=new C.Vector3;r.intersectionShape.triangle.push(new O.Triangle(W.copy(d[u]),U.copy(d[A]),I.copy(d[D])))}if(o){var G=new C.Vector3(0,0,0),Y=0;for(let ne=0;ne<e.geometryGroups.length;ne++)G.add(e.geometryGroups[ne].getCentroid()),Y++;G.divideScalar(Y),_.updateBoundingFromPoints(r.boundingSphere,{centroid:G},F,l.vertices)}if(l.faceArray=new Uint16Array(n),l.truncateArrayBuffers(!0,!0),i.length<l.vertices)l.setNormals();else{var J=l.normalArray=new Float32Array(l.vertices*3),te;for(T=0,S=l.vertices;T<S;++T)a=T*3,te=i[T],J[a]=te.x,J[a+1]=te.y,J[a+2]=te.z}l.setLineIndices(),l.lineidx=l.lineArray.length}static updateFromStyle(r,e){typeof e.color<"u"?(r.color=e.color||new R.Color,e.color instanceof R.Color||(r.color=R.CC.color(e.color))):r.color=R.CC.color(0),r.wireframe=!!e.wireframe,r.opacity=e.alpha?(0,C.clamp)(e.alpha,0,1):1,typeof e.opacity<"u"&&(r.opacity=(0,C.clamp)(e.opacity,0,1)),r.side=e.side!==void 0?e.side:b.DoubleSide,r.linewidth=typeof e.linewidth>"u"?1:e.linewidth,r.clickable=!!e.clickable,r.callback=(0,x.makeFunction)(e.callback),r.hoverable=!!e.hoverable,r.hover_callback=(0,x.makeFunction)(e.hover_callback),r.unhover_callback=(0,x.makeFunction)(e.unhover_callback),r.contextMenuEnabled=!!e.contextMenuEnabled,r.hidden=e.hidden,r.frame=e.frame}constructor(r){this.color=16777215,this.hidden=!1,this.wireframe=!1,this.opacity=1,this.linewidth=1,this.clickable=!1,this.hoverable=!1,this.contextMenuEnabled=!1,this.side=b.DoubleSide,this.stylespec=r||{},this.boundingSphere=new O.Sphere,this.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]},_.updateFromStyle(this,this.stylespec),this.components=[],this.shapeObj=null,this.renderedShapeObj=null,this.geo=new b.Geometry(!0),this.linegeo=new b.Geometry(!0)}updateStyle(r){for(var e in r)this.stylespec[e]=r[e];if(_.updateFromStyle(this,this.stylespec),r.voldata&&r.volscheme){(0,x.adjustVolumeStyle)(r);const t=r.volscheme,s=r.voldata,o=R.CC,l=t.range()||[-1,1];this.geo.setColors(function(d,i,n){let a=s.getVal(d,i,n);return o.color(t.valueToHex(a,l))}),delete this.color}}addCustom(r){r.vertexArr=r.vertexArr||[],r.faceArr=r.faceArr||[],r.normalArr=r.normalArr||[],_.drawCustom(this,this.geo,r)}addSphere(r){r.center||(r.center=new C.Vector3(0,0,0)),r.radius=r.radius?(0,C.clamp)(r.radius,0,1/0):1.5,r.color=R.CC.color(r.color),this.intersectionShape.sphere.push(new O.Sphere(r.center,r.radius)),M.GLDraw.drawSphere(this.geo,r.center,r.radius,r.color,r.quality),this.components.push({centroid:new C.Vector3(r.center.x,r.center.y,r.center.z)});var e=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,e.vertexArray,e.vertices)}addBox(r){var e=r.dimensions||{w:1,h:1,d:1},t;typeof e.w=="number"?t={x:e.w,y:0,z:0}:t=e.w;var s;typeof e.h=="number"?s={x:0,y:e.h,z:0}:s=e.h;var o;typeof e.d=="number"?o={x:0,y:0,z:e.d}:o=e.d;var l=r.corner;l==null&&(r.center!==void 0?l={x:r.center.x-.5*(t.x+s.x+o.x),y:r.center.y-.5*(t.y+s.y+o.y),z:r.center.z-.5*(t.z+s.z+o.z)}:l={x:0,y:0,z:0});var d=[{x:l.x,y:l.y,z:l.z},{x:l.x+t.x,y:l.y+t.y,z:l.z+t.z},{x:l.x+s.x,y:l.y+s.y,z:l.z+s.z},{x:l.x+t.x+s.x,y:l.y+t.y+s.y,z:l.z+t.z+s.z},{x:l.x+o.x,y:l.y+o.y,z:l.z+o.z},{x:l.x+t.x+o.x,y:l.y+t.y+o.y,z:l.z+t.z+o.z},{x:l.x+s.x+o.x,y:l.y+s.y+o.y,z:l.z+s.z+o.z},{x:l.x+t.x+s.x+o.x,y:l.y+t.y+s.y+o.y,z:l.z+t.z+s.z+o.z}],i=[],n=[];i.splice(i.length,0,d[0],d[1],d[2],d[3]),n.splice(n.length,0,0,2,1,1,2,3);var a=4;i.splice(i.length,0,d[2],d[3],d[6],d[7]),n.splice(n.length,0,a+0,a+2,a+1,a+1,a+2,a+3),a+=4,i.splice(i.length,0,d[4],d[5],d[0],d[1]),n.splice(n.length,0,a+0,a+2,a+1,a+1,a+2,a+3),a+=4,i.splice(i.length,0,d[6],d[7],d[4],d[5]),n.splice(n.length,0,a+0,a+2,a+1,a+1,a+2,a+3),a+=4,i.splice(i.length,0,d[3],d[1],d[7],d[5]),n.splice(n.length,0,a+0,a+2,a+1,a+1,a+2,a+3),a+=4,i.splice(i.length,0,d[2],d[6],d[0],d[4]),n.splice(n.length,0,a+0,a+2,a+1,a+1,a+2,a+3),a+=4;var h=(0,x.extend)({},r);h.vertexArr=i,h.faceArr=n,h.normalArr=[],_.drawCustom(this,this.geo,h);var u=new C.Vector3;this.components.push({centroid:u.addVectors(d[0],d[7]).multiplyScalar(.5)});var A=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,A.vertexArray,A.vertices)}addCylinder(r){var e,t;r.start?e=new C.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new C.Vector3(0,0,0),r.end?(t=new C.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new C.Vector3(0,0,0);var s=r.radius||.1,o=R.CC.color(r.color);this.intersectionShape.cylinder.push(new O.Cylinder(e,t,s)),M.GLDraw.drawCylinder(this.geo,e,t,s,o,r.fromCap,r.toCap);var l=new C.Vector3;this.components.push({centroid:l.addVectors(e,t).multiplyScalar(.5)});var d=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,d.vertexArray,d.vertices)}addDashedCylinder(r){r.dashLength=r.dashLength||.25,r.gapLength=r.gapLength||.25;var e;r.start?e=new C.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new C.Vector3(0,0,0);var t;r.end?(t=new C.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new C.Vector3(3,0,0);for(var s=r.radius||.1,o=R.CC.color(r.color),l=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)+Math.pow(e.z-t.z,2)),d=l/(r.gapLength+r.dashLength),i=new C.Vector3(r.start.x||0,r.start.y||0,r.start.z||0),n=new C.Vector3(r.end.x,r.end.y||0,r.end.z||0),a=new C.Vector3((t.x-e.x)/(l/r.gapLength),(t.y-e.y)/(l/r.gapLength),(t.z-e.z)/(l/r.gapLength)),h=new C.Vector3((t.x-e.x)/(l/r.dashLength),(t.y-e.y)/(l/r.dashLength),(t.z-e.z)/(l/r.dashLength)),u=0;u<d;u++)n=new C.Vector3(i.x+h.x,i.y+h.y,i.z+h.z),this.intersectionShape.cylinder.push(new O.Cylinder(i,n,s)),M.GLDraw.drawCylinder(this.geo,i,n,s,o,r.fromCap,r.toCap),i=new C.Vector3(n.x+a.x,n.y+a.y,n.z+a.z);var A=new C.Vector3;this.components.push({centroid:A.addVectors(e,t).multiplyScalar(.5)});var D=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,D.vertexArray,D.vertices)}addCurve(r){r.points=r.points||[],r.smooth=r.smooth||10,typeof r.fromCap>"u"&&(r.fromCap=2),typeof r.toCap>"u"&&(r.toCap=2);var e=(0,g.subdivide_spline)(r.points,r.smooth);if(e.length<3){console.log("Too few points in addCurve");return}var t=r.radius||.1,s=R.CC.color(r.color),o=0,l=e.length-1,d=e[0].distanceTo(e[1]),i=Math.ceil(2*t/d);if(r.toArrow){l-=i;let u={start:e[l],end:e[e.length-1],radius:t,color:s,mid:1e-4};this.addArrow(u)}if(r.fromArrow){o+=i;let u={start:e[o],end:e[0],radius:t,color:s,mid:1e-4};this.addArrow(u)}for(var n=Math.ceil(e.length/2),a={radius:t,color:s,fromCap:2,toCap:2},h=o;h<l;h++)a.start=e[h],a.end=e[h+1],a.fromCap=2,a.toCap=2,h<n?(a.fromCap=2,a.toCap=0):h>n?(a.fromCap=0,a.toCap=2):(a.fromCap=2,a.toCap=2),this.addCylinder(a)}addLine(r){var e,t;r.start?e=new C.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new C.Vector3(0,0,0),r.end?(t=new C.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new C.Vector3(3,0,0);var s=this.geo.updateGeoGroup(2),o=s.vertices,l=o*3,d=s.vertexArray;d[l]=e.x,d[l+1]=e.y,d[l+2]=e.z,d[l+3]=t.x,d[l+4]=t.y,d[l+5]=t.z,s.vertices+=2;var i=s.lineArray,n=s.lineidx;i[n]=o,i[n+1]=o+1,s.lineidx+=2;var a=new C.Vector3;this.components.push({centroid:a.addVectors(e,t).multiplyScalar(.5)}),s=this.geo.updateGeoGroup(0),_.updateBoundingFromPoints(this.boundingSphere,this.components,s.vertexArray,s.vertices)}addArrow(r){if(r.start?r.start=new C.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):r.start=new C.Vector3(0,0,0),r.dir instanceof C.Vector3&&typeof r.length=="number"){var e=r.dir.clone().multiplyScalar(r.length).add(r.start);r.end=e}else r.end?(r.end=new C.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof r.end.x>"u"&&(r.end.x=3)):r.end=new C.Vector3(3,0,0);r.radius=r.radius||.1,r.radiusRatio=r.radiusRatio||1.618034,r.mid=0<r.mid&&r.mid<1?r.mid:.618034,_.drawArrow(this,this.geo,r);var t=new C.Vector3;this.components.push({centroid:t.addVectors(r.start,r.end).multiplyScalar(.5)});var s=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,s.vertexArray,s.vertices)}static distance_from(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2)+Math.pow(r.z-e.z,2))}static inSelectedRegion(r,e,t){for(var s=0;s<e.length;s++)if(_.distance_from(e[s],r)<=t)return!0;return!1}addIsosurface(r,e,t,s){var o=e.isoval!==void 0&&typeof e.isoval=="number"?e.isoval:0,l=!!e.voxel,d=e.smoothness===void 0?1:e.smoothness,i=r.size.x,n=r.size.y,a=r.size.z,h=new Int16Array(i*n*a),u=r.data,A,D;for(A=0,D=h.length;A<D;++A)h[A]=-1;var T=new Uint8Array(i*n*a);for(A=0,D=u.length;A<D;++A){var S=o>=0?u[A]-o:o-u[A];S>0&&(T[A]|=_.ISDONE)}var P=[],z=[];v.MarchingCube.march(T,P,z,{fulltable:!0,voxel:l,unitCube:r.unit,origin:r.origin,matrix:r.matrix,nX:i,nY:n,nZ:a}),!l&&d>0&&v.MarchingCube.laplacianSmooth(d,P,z);var F=[],B=[],W=[];if(e.selectedRegion&&e.coords===void 0&&(e.coords=e.selectedRegion),e.coords===void 0&&e.selection!==void 0&&(s?e.coords=s.selectedAtoms(e.selection):console.log("addIsosurface needs viewer is selection provided.")),e.coords!==void 0){var U=e.coords[0].x,I=e.coords[0].y,G=e.coords[0].z,Y=e.coords[0].x,J=e.coords[0].y,te=e.coords[0].z;for(let ee=0;ee<e.coords.length;ee++)e.coords[ee].x>U?U=e.coords[ee].x:e.coords[ee].x<Y&&(Y=e.coords[ee].x),e.coords[ee].y>I?I=e.coords[ee].y:e.coords[ee].y<J&&(J=e.coords[ee].y),e.coords[ee].z>G?G=e.coords[ee].z:e.coords[ee].z<te&&(te=e.coords[ee].z);var ne=2;e.radius!==void 0&&(ne=e.radius),e.selectedOffset!==void 0&&(ne=e.selectedOffset),e.seldist!==void 0&&(ne=e.seldist),Y-=ne,U+=ne,J-=ne,I+=ne,te-=ne,G+=ne;for(let ee=0;ee<P.length;ee++)P[ee].x>Y&&P[ee].x<U&&P[ee].y>J&&P[ee].y<I&&P[ee].z>te&&P[ee].z<G&&_.inSelectedRegion(P[ee],e.coords,ne)?(F.push(B.length),B.push(P[ee])):F.push(-1);for(let ee=0;ee+2<z.length;ee+=3)F[z[ee]]!==-1&&F[z[ee+1]]!==-1&&F[z[ee+2]]!==-1&&(W.push(z[ee]-(z[ee]-F[z[ee]])),W.push(z[ee+1]-(z[ee+1]-F[z[ee+1]])),W.push(z[ee+2]-(z[ee+2]-F[z[ee+2]])));P=B,z=W}_.drawCustom(this,this.geo,{vertexArr:P,faceArr:z,normalArr:[],clickable:e.clickable,hoverable:e.hoverable}),this.updateStyle(e);var le=new C.Vector3(r.origin.x,r.origin.y,r.origin.z),ie=new C.Vector3(r.size.x*r.unit.x,r.size.y*r.unit.y,r.size.z*r.unit.z),oe=new C.Vector3(0,0,0),xe=le.clone(),_e=le.clone().add(ie);for(let ee=0;ee<P.length;ee++)oe.add(P[ee]),xe.max(P[ee]),_e.min(P[ee]);oe.divideScalar(P.length);var Oe=oe.distanceTo(_e),ye=oe.distanceTo(xe);this.boundingSphere.center=oe,this.boundingSphere.radius=Math.max(Oe,ye),typeof t=="function"&&t()}addVolumetricData(r,e,t){r=new y.VolumeData(r,e),this.addIsosurface(r,t)}finalize(){return _.finalizeGeo(this.geo),this.geo.initTypedArrays(),this.geo}globj(r){if(this.renderedShapeObj&&(r.remove(this.renderedShapeObj),this.renderedShapeObj=null),!this.hidden){_.finalizeGeo(this.geo),this.geo.initTypedArrays(),this.wireframe&&this.geo.setUpWireframe(),typeof this.color<"u"&&_.updateColor(this.geo,this.color),this.shapeObj=new b.Object3D;var e=null;this.side==b.DoubleSide?e=new b.MeshDoubleLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:b.Coloring.VertexColors}):e=new b.MeshLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:b.Coloring.VertexColors});var t=new b.Mesh(this.geo,e);if(this.shapeObj.add(t),this.linegeo&&this.linegeo.vertices>0){var s=new b.LineBasicMaterial({linewidth:this.linewidth,color:this.color}),o=new b.Line(this.linegeo,s,b.LineStyle.LinePieces);this.shapeObj.add(o)}this.renderedShapeObj=this.shapeObj.clone(),r.add(this.renderedShapeObj)}}removegl(r){this.renderedShapeObj&&(this.renderedShapeObj.geometry!==void 0&&this.renderedShapeObj.geometry.dispose(),this.renderedShapeObj.material!==void 0&&this.renderedShapeObj.material.dispose(),r.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}}_.ISDONE=2,_.drawCustom=function(m,r,e){var t=e,s=t.vertexArr,o=t.faceArr;(s.length===0||o.length===0)&&console.warn("Error adding custom shape component: No vertices and/or face indices supplied!");var l=e.color;typeof l>"u"&&(l=m.color),l=R.CC.color(l);for(var d=p(t),i=0,n=d.length;i<n;i++)_.addCustomGeo(m,r,d[i],d[i].colorArr?d[i].colorArr:l,e.clickable)};function p(m){var r=64e3;if(m.vertexArr.length<r)return[m];var e=[{vertexArr:[],normalArr:[],faceArr:[]}];m.colorArr&&(e.colorArr=[]);var t=[],s=[],o=0,l=m.faceArr;for(let i=0,n=l.length;i<n;i+=3){let a=e[o];for(let h=0;h<3;h++){var d=l[i+h];t[d]!==o&&(t[d]=o,s[d]=a.vertexArr.length,a.vertexArr.push(m.vertexArr[d]),m.normalArr&&m.normalArr[d]&&a.normalArr.push(m.normalArr[d]),m.colorArr&&m.colorArr[d]&&a.colorArr.push(m.colorArr[d])),a.faceArr.push(s[d])}a.vertexArr.length>=r&&(e.push({vertexArr:[],normalArr:[],faceArr:[]}),m.colorArr&&(e.colorArr=[]),o++)}return e}},"./src/GLViewer.ts"(k,w,c){c.r(w),c.d(w,{CONTEXTS_PER_VIEWPORT:()=>r,GLViewer:()=>t,createStereoViewer:()=>l,createViewer:()=>s,createViewerGrid:()=>o});var b=c("./node_modules/upng-js/UPNG.js"),O=c("./src/GLModel.ts"),C=c("./src/GLShape.ts"),R=c("./src/Gradient.ts"),v=c("./src/Label.ts"),y=c("./src/ProteinSurface4.ts"),M=c("./src/VolumeData.ts"),g=c("./src/VolumetricRender.ts"),x=c("./src/WebGL/index.ts"),_=c("./src/WebGL/math/index.ts"),p=c("./src/colors.ts"),m=c("./src/utilities.ts");const r=16;class e extends Array{constructor(i){super(...i)}getSymmetries(){if(this.length==0)return[];let i=this[0];return typeof i.symmetries>"u"&&this.setSymmetries([new _.Matrix4]),i.symmetries}setSymmetries(i){typeof i>"u"&&(i=[new _.Matrix4]);for(let n of this)n.symmetries=i,n.finished=!1}}class t{getWidth(){let i=this.container,n=i.offsetWidth;if(n==0&&i.style.display==="none"){let a=i.style.position,h=i.style.visibility;i.style.display="block",i.style.visibility="hidden",i.style.position="absolute",n=i.offsetWidth,i.style.display="none",i.style.visibility=h,i.style.position=a}return n}getHeight(){let i=this.container,n=i.offsetHeight;if(n==0&&i.style.display==="none"){let a=i.style.position,h=i.style.visibility;i.style.display="block",i.style.visibility="hidden",i.style.position="absolute",n=i.offsetHeight,i.style.display="none",i.style.visibility=h,i.style.position=a}return n}setupRenderer(){let i=Object.assign(Object.assign({},this.config),{preserveDrawingBuffer:!0,premultipliedAlpha:!1,containerWidth:this.WIDTH,containerHeight:this.HEIGHT});this.renderer=new x.Renderer(i),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 x.Scene,this.scene.fog=new x.Fog(this.bgColor,100,200),this.modelGroup=new x.Object3D,this.rotationGroup=new x.Object3D,this.rotationGroup.useQuaternion=!0,this.rotationGroup.quaternion=new _.Quaternion(0,0,0,1),this.rotationGroup.add(this.modelGroup),this.scene.add(this.rotationGroup);var i=new x.Light(16777215);i.position=new _.Vector3(.2,.2,1).normalize(),i.intensity=1,this.scene.add(i)}_handleLostContext(i){const n=function(a){const h=a.getBoundingClientRect();return!(h.right<0||h.bottom<0||h.top>(window.innerHeight||document.documentElement.clientHeight)||h.left>(window.innerWidth||document.documentElement.clientWidth))};if(n(this.container)){let a=0;for(let h of document.getElementsByTagName("canvas"))if(n(h)&&h._3dmol_viewer!=null&&(h._3dmol_viewer.resize(),a+=1,a>=r))break}}initContainer(i){this.container=i,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.glDOM._3dmol_viewer=this,this.glDOM.addEventListener("webglcontextlost",this._handleLostContext.bind(this)),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 i=0;for(let a in this.surfaces)if(this.surfaces.hasOwnProperty(a)){var n=parseInt(a);isNaN(n)||n>i&&(i=n)}return i+1}setSlabAndFog(){let i=this.camera.position.z-this.rotationGroup.position.z;i<1&&(i=1),this.camera.near=i+this.slabNear,!this.camera.ortho&&this.camera.near<1&&(this.camera.near=1),this.camera.far=i+this.slabFar,this.camera.near+1>this.camera.far&&(this.camera.far=this.camera.near+1),this.camera.fov=this.fov,this.camera.right=i*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.near+this.fogEnd*(this.camera.far-this.camera.near),this.config.disableFog&&(this.scene.fog.near=this.scene.fog.far)}show(i){if(this.renderer.setViewport(),!!this.scene&&(this.setSlabAndFog(),this.renderer.render(this.scene,this.camera),this.viewChangeCallback&&this.viewChangeCallback(this._viewer.getView()),!i&&this.linkedViewers.length>0))for(var n=this._viewer.getView(),a=0;a<this.linkedViewers.length;a++){var h=this.linkedViewers[a];h.setView(n,!0)}}updateClickables(){this.clickables.splice(0,this.clickables.length),this.hoverables.splice(0,this.hoverables.length),this.contextMenuEnabledObjects.splice(0,this.contextMenuEnabledObjects.length);for(let i=0,n=this.models.length;i<n;i++){let a=this.models[i];if(a){let h=a.selectedAtoms({clickable:!0}),u=a.selectedAtoms({hoverable:!0}),A=a.selectedAtoms({contextMenuEnabled:!0});for(let D=0;D<u.length;D++)this.hoverables.push(u[D]);for(let D=0;D<h.length;D++)this.clickables.push(h[D]);for(let D=0;D<A.length;D++)this.contextMenuEnabledObjects.push(A[D])}}for(let i=0,n=this.shapes.length;i<n;i++){let a=this.shapes[i];a&&a.clickable&&this.clickables.push(a),a&&a.hoverable&&this.hoverables.push(a),a&&a.contextMenuEnabled&&this.contextMenuEnabledObjects.push(a)}}handleClickSelection(i,n,a){let h=this.targetedObjects(i,n,this.clickables);if(h.length){var u=h[0].clickable;u.callback!==void 0&&(typeof u.callback!="function"&&(u.callback=(0,m.makeFunction)(u.callback)),typeof u.callback=="function"&&(this.mouseButton===3&&this.contextMenuEnabledObjects.includes(u)&&this.userContextMenuHandler||u.callback(u,this._viewer,a,this.container,h)))}}canvasOffset(){let i=this.glDOM,n=i.getBoundingClientRect(),a=i.ownerDocument,h=a.documentElement,u=a.defaultView;return{top:n.top+u.pageYOffset-h.clientTop,left:n.left+u.pageXOffset-h.clientLeft}}setHover(i,n,a){i&&i.hidden&&(i=null),this.current_hover!=i&&(this.current_hover&&(typeof this.current_hover.unhover_callback!="function"&&(this.current_hover.unhover_callback=(0,m.makeFunction)(this.current_hover.unhover_callback)),this.current_hover.unhover_callback(this.current_hover,this._viewer,n,this.container,a)),this.current_hover=i,i&&i.hover_callback!==void 0&&(typeof i.hover_callback!="function"&&(i.hover_callback=(0,m.makeFunction)(i.hover_callback)),typeof i.hover_callback=="function"&&i.hover_callback(i,this._viewer,n,this.container,a)))}handleHoverSelection(i,n,a){if(this.hoverables.length==0)return;let h=this.targetedObjects(i,n,this.hoverables);if(h.length){var u=h[0].clickable;this.setHover(u,a,h),this.current_hover=u}else this.setHover(null)}handleHoverContinue(i,n){let a=this.targetedObjects(i,n,this.hoverables);(a.length==0||a[0]===void 0)&&this.setHover(null),a[0]!==void 0&&a[0].clickable!==this.current_hover&&this.setHover(null)}closeEnoughForClick(i,{allowTolerance:n=i.targetTouches,tolerance:a=5}={}){const h=this.getX(i),u=this.getY(i);if(n){const A=Math.abs(h-this.mouseStartX),D=Math.abs(u-this.mouseStartY);return A<=a&&D<=a}else return h===this.mouseStartX&&u===this.mouseStartY}calcTouchDistance(i){var n=i.targetTouches[0].pageX-i.targetTouches[1].pageX,a=i.targetTouches[0].pageY-i.targetTouches[1].pageY;return Math.hypot(n,a)}getX(i){var n=i.pageX;return n==null&&(n=i.pageX),i.targetTouches&&i.targetTouches[0]?n=i.targetTouches[0].pageX:i.changedTouches&&i.changedTouches[0]&&(n=i.changedTouches[0].pageX),n}getY(i){var n=i.pageY;return n==null&&(n=i.pageY),i.targetTouches&&i.targetTouches[0]?n=i.targetTouches[0].pageY:i.changedTouches&&i.changedTouches[0]&&(n=i.changedTouches[0].pageY),n}isInViewer(i,n){if(this.viewers!=null){var a=this.WIDTH/this.cols,h=this.HEIGHT/this.rows,u=this.canvasOffset(),A=i-u.left,D=n-u.top,T=this.rows-Math.floor(D/h)-1,S=Math.floor(A/a);if(T!=this.row||S!=this.col)return!1}return!0}adjustZoomToLimits(i){if(this.config.lowerZoomLimit&&this.config.lowerZoomLimit>0){let n=this.CAMERA_Z-this.config.lowerZoomLimit;i>n&&(i=n)}if(this.config.upperZoomLimit&&this.config.upperZoomLimit>0){let n=this.CAMERA_Z-this.config.upperZoomLimit;i<n&&(i=n)}return i>this.CAMERA_Z-1&&(i=this.CAMERA_Z-1),i}static slerp(i,n,a){if(a==1)return n.clone();if(a==0)return i.clone();let h=i.x*n.x+i.y*n.y+i.z*n.z+i.w*n.w;if(h>.9995){let z=new _.Quaternion(i.x+a*(n.x-i.x),i.y+a*(n.y-i.y),i.z+a*(n.z-i.z),i.w+a*(n.w-i.w));return z.normalize(),z}h<0&&(n=n.clone().multiplyScalar(-1),h=-h),h>1?h=1:h<-1&&(h=-1);var u=Math.acos(h),A=u*a,D=n.clone();D.sub(i.clone().multiplyScalar(h)),D.normalize();var T=Math.cos(A),S=Math.sin(A),P=new _.Quaternion(i.x*T+D.x*S,i.y*T+D.y*S,i.z*T+D.z*S,i.w*T+D.w*S);return P.normalize(),P}constructor(i,n={}){if(this.nomouse=!1,this.glDOM=null,this.models=[],this.surfaces={},this.shapes=[],this.labels=[],this.clickables=[],this.hoverables=[],this.contextMenuEnabledObjects=[],this.current_hover=null,this.hoverDuration=500,this.longTouchDuration=1e3,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.fogEnd=1,this.slabNear=-50,this.slabFar=50,this.cq=new _.Quaternion(0,0,0,1),this.dq=new _.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=n,this.callback=this.config.callback,this.defaultcolors=this.config.defaultcolors,this.defaultcolors||(this.defaultcolors=p.elementColors.defaultColors),this.nomouse=!!this.config.nomouse,this.bgColor=0,this.config.backgroundColor=this.config.backgroundColor||"#ffffff",typeof this.config.backgroundColor<"u"&&(this.bgColor=p.CC.color(this.config.backgroundColor).getHex()),this.config.backgroundAlpha=this.config.backgroundAlpha==null?1:this.config.backgroundAlpha,this.camerax=0,typeof this.config.camerax<"u"&&(this.camerax=typeof this.config.camerax=="string"?parseFloat(this.config.camerax):this.config.camerax),this._viewer=this,this.container=i,this.config.hoverDuration!=null&&(this.hoverDuration=this.config.hoverDuration),this.config.antialias===void 0&&(this.config.antialias=!0),this.config.cartoonQuality===void 0&&(this.config.cartoonQuality=10),this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight(),this.setupRenderer(),this.row=this.config.row==null?0:this.config.row,this.col=this.config.col==null?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 x.Camera(this.fov,this.ASPECT,this.NEAR,this.FAR,this.config.orthographic),this.camera.position=new _.Vector3(this.camerax,0,this.CAMERA_Z),this.lookingAt=new _.Vector3,this.camera.lookAt(this.lookingAt),this.raycaster=new x.Raycaster(new _.Vector3(0,0,0),new _.Vector3(0,0,0)),this.projector=new x.Projector,this.initializeScene(),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),this.scene.fog.color=p.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)),typeof window.ResizeObserver<"u"&&(this.divwatcher=new window.ResizeObserver(this.resize.bind(this)),this.divwatcher.observe(this.container)),typeof window.IntersectionObserver<"u"){let a=(h,u)=>{h.forEach(A=>{A.isIntersecting&&this.resize()})};this.intwatcher=new window.IntersectionObserver(a),this.intwatcher.observe(this.container)}try{typeof this.callback=="function"&&this.callback(this)}catch(a){console.log("error with glviewer callback: "+a)}}targetedObjects(i,n,a){var h={x:i,y:n,z:-1};return Array.isArray(a)||(a=this.selectedAtoms(a)),a.length==0?[]:(this.raycaster.setFromCamera(h,this.camera),this.raycaster.intersectObjects(this.modelGroup,a))}modelToScreen(i){let n=!1;Array.isArray(i)||(i=[i],n=!0);let a=this.renderer.getXRatio(),h=this.renderer.getYRatio(),u=this.col,A=this.row,D=u*(this.WIDTH/a),T=(h-A-1)*(this.HEIGHT/h),S=[],P=this.canvasOffset();return i.forEach(z=>{let F=new _.Vector3(z.x,z.y,z.z);F.applyMatrix4(this.modelGroup.matrixWorld),this.projector.projectVector(F,this.camera);let B=this.WIDTH/a*(F.x+1)/2+P.left+D,W=-(this.HEIGHT/h)*(F.y-1)/2+P.top+T;S.push({x:B,y:W})}),n&&(S=S[0]),S}screenOffsetToModel(i,n,a){var h=i/this.WIDTH,u=n/this.HEIGHT,A=a===void 0?this.rotationGroup.position.z:a,D=this.rotationGroup.quaternion,T=new _.Vector3(0,0,A);return this.projector.projectVector(T,this.camera),T.x+=h*2,T.y-=u*2,this.projector.unprojectVector(T,this.camera),T.z=0,T.applyQuaternion(D),T}screenToModelDistance(i,n){let a=this.canvasOffset(),h=new _.Vector3(n.x,n.y,n.z);h.applyMatrix4(this.modelGroup.matrixWorld);let u=h.clone();this.projector.projectVector(h,this.camera);let A=new _.Vector3((i.x-a.left)*2/this.WIDTH-1,(i.y-a.top)*2/-this.HEIGHT+1,h.z);return this.projector.unprojectVector(A,this.camera),A.distanceTo(u)}setViewChangeCallback(i){(typeof i=="function"||i==null)&&(this.viewChangeCallback=i)}setStateChangeCallback(i){(typeof i=="function"||i==null)&&(this.stateChangeCallback=i)}getConfig(){return this.config}setConfig(i){this.config=i,i.ambientOcclusion&&this.renderer.enableAmbientOcclusion(i.ambientOcclusion)}getInternalState(){var i={models:[],surfaces:[],shapes:[],labels:[]};for(let n=0;n<this.models.length;n++)this.models[n]&&(i.models[n]=this.models[n].getInternalState());return i}setInternalState(i){this.clear();var n=i.models;for(let a=0;a<n.length;a++)n[a]&&(this.models[a]=new O.GLModel(a,void 0,this),this.models[a].setInternalState(n[a]));this.render()}setZoomLimits(i,n){typeof i<"u"&&(this.config.lowerZoomLimit=i),n&&(this.config.upperZoomLimit=n),this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z),this.show()}setCameraParameters(i){i.fov!==void 0&&(this.fov=i.fov,this.camera.fov=this.fov),i.z!==void 0&&(this.CAMERA_Z=i.z,this.camera.z=this.CAMERA_Z),i.orthographic!==void 0&&(this.camera.ortho=i.orthographic),this.setSlabAndFog()}_handleMouseDown(i){if(i.preventDefault(),!this.scene)return;var n=this.getX(i),a=this.getY(i);if(n===void 0)return;this.isDragging=!0,this.mouseButton=i.which,this.mouseStartX=n,this.mouseStartY=a,this.touchHold=!0,this.touchDistanceStart=0,i.targetTouches&&i.targetTouches.length==2&&(this.touchDistanceStart=this.calcTouchDistance(i)),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 h=this;i.targetTouches&&i.targetTouches.length===1&&(this.longTouchTimeout=setTimeout(function(){if(h.touchHold==!0){h.glDOM=h.renderer.domElement;const u=i.targetTouches[0],A=new PointerEvent("contextmenu",Object.assign(Object.assign({},i),{pageX:u.pageX,pageY:u.pageY,screenX:u.screenX,screenY:u.screenY,clientX:u.clientX,clientY:u.clientY}));h.glDOM.dispatchEvent(A)}},this.longTouchDuration))}_handleMouseUp(i){if(this.touchHold=!1,this.isDragging&&this.scene){var n=this.getX(i),a=this.getY(i);if(this.closeEnoughForClick(i)&&this.isInViewer(n,a)){let h=this.mouseXY(n,a);this.handleClickSelection(h.x,h.y,i)}}this.isDragging=!1}_handleMouseScroll(i){if(i.preventDefault(),!!this.scene){var n=this.getX(i),a=this.getY(i);if(n!==void 0&&!(!this.control_all&&!this.isInViewer(n,a))){var h=(this.CAMERA_Z-this.rotationGroup.position.z)*.85,u=1;if(i.ctrlKey&&(u=-1),i.detail)this.rotationGroup.position.z+=u*h*i.detail/10;else if(i.wheelDelta){let A=i.wheelDelta*600/(i.wheelDelta+600);this.rotationGroup.position.z-=u*h*A/400}this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z),this.show()}}}pngURI(){return this.getCanvas().toDataURL("image/png")}apngURI(i){let n=this;return i=i||1,new Promise(function(a){let h=0,u=n.viewChangeCallback,A=[],D=[],T=Date.now();n.viewChangeCallback=function(){D.push(Date.now()-T),T=Date.now(),A.push(new Promise(S=>{n.getCanvas().toBlob(function(P){P.arrayBuffer().then(S)},"image/png")})),h+=1,h==i&&(n.viewChangeCallback=u,Promise.all(A).then(S=>{let P=[];for(let I=0;I<S.length;I++){let G=(0,b.decode)(S[I]);P.push((0,b.toRGBA8)(G)[0])}let z=n.getCanvas().width,F=n.getCanvas().height,B=(0,b.encode)(P,z,F,0,D),W=new Blob([B],{type:"image/png"}),U=new FileReader;U.onload=function(I){a(I.target.result)},U.readAsDataURL(W)}))}})}getCanvas(){return this.glDOM}getRenderer(){return this.renderer}setHoverDuration(i){this.hoverDuration=i}mouseXY(i,n){let a=this.canvasOffset(),h=this.renderer.getXRatio(),u=this.renderer.getYRatio(),A=this.col,D=this.row,T=A*(this.WIDTH/h),S=(u-D-1)*(this.HEIGHT/u),P=(i-a.left-T)/(this.WIDTH/h)*2-1,z=-((n-a.top-S)/(this.HEIGHT/u))*2+1;return{x:P,y:z}}_handleMouseMove(i){clearTimeout(this.hoverTimeout),i.preventDefault();let n=this.getX(i),a=this.getY(i);if(n===void 0)return;let h=this.renderer.getXRatio(),u=this.renderer.getYRatio(),A=this.mouseXY(n,a),D=this;this.current_hover!==null&&this.handleHoverContinue(A.x,A.y);var T=0;if(!(!this.control_all&&!this.isInViewer(n,a))&&this.scene&&(this.hoverables.length>0&&(this.hoverTimeout=setTimeout(function(){D.handleHoverSelection(A.x,A.y,i)},this.hoverDuration)),!!this.isDragging)){i.targetTouches&&(i.targetTouches.length>1||i.targetTouches.length===1&&!this.closeEnoughForClick(i))&&clearTimeout(this.longTouchTimeout);var S=(n-this.mouseStartX)/this.WIDTH,P=(a-this.mouseStartY)/this.HEIGHT;if(this.touchDistanceStart!=0&&i.targetTouches&&i.targetTouches.length==2){var z=this.calcTouchDistance(i);T=2,P=(z-this.touchDistanceStart)*2/(this.WIDTH+this.HEIGHT)}else i.targetTouches&&i.targetTouches.length==3&&(T=1);S*=h,P*=u;var F=Math.hypot(S,P),B;if(T==3||this.mouseButton==3&&i.ctrlKey)this.slabNear=this.cslabNear+S*100,this.slabFar=this.cslabFar-P*100;else if(T==2||this.mouseButton==3||i.shiftKey)B=(this.CAMERA_Z-this.rotationGroup.position.z)*.85,B<80&&(B=80),this.rotationGroup.position.z=this.cz+P*B,this.rotationGroup.position.z=this.adjustZoomToLimits(this.rotationGroup.position.z);else if(T==1||this.mouseButton==2||i.ctrlKey){var W=this.screenOffsetToModel(h*(n-this.mouseStartX),u*(a-this.mouseStartY));this.modelGroup.position.addVectors(this.currentModelPos,W)}else if((T===0||this.mouseButton==1)&&F!==0){var U=Math.sin(F*Math.PI)/F;this.dq.x=Math.cos(F*Math.PI),this.dq.y=0,this.dq.z=U*S,this.dq.w=-U*P,this.rotationGroup.quaternion.set(1,0,0,0),this.rotationGroup.quaternion.multiply(this.dq),this.rotationGroup.quaternion.multiply(this.cq)}this.show()}}_handleContextMenu(i){if(i.preventDefault(),this.closeEnoughForClick(i)){var h=this.mouseStartX,u=this.mouseStartY,a=this.canvasOffset();let A=this.mouseXY(h,u),D=A.x,T=A.y,S=this.targetedObjects(D,T,this.contextMenuEnabledObjects);var n=null;S.length&&(n=S[0].clickable);var a=this.canvasOffset(),h=this.mouseStartX-a.left,u=this.mouseStartY-a.top;this.userContextMenuHandler&&(this.userContextMenuHandler(n,h,u,S,i),this.isDragging=!1)}}setContainer(i){let n=(0,m.getElement)(i)||this.container;return this.initContainer(n),this}setBackgroundColor(i,n){(typeof n>"u"||n<0||n>1)&&(n=1);var a=p.CC.color(i);return this.scene.fog.color=a,this.bgColor=a.getHex(),this.renderer.setClearColorHex(a.getHex(),n),this.show(),this}setProjection(i){this.camera.ortho=i==="orthographic",this.setSlabAndFog()}setViewStyle(i){if(i=i||{},i.style=i.style||"",i.style.includes("outline")?this.renderer.enableOutline(i):this.renderer.disableOutline(),i.style.includes("ambientOcclusion")){var n={};i.strength&&(n.strength=i.strength),i.radius&&(n.radius=i.radius),this.renderer.enableAmbientOcclusion(n)}else this.renderer.disableAmbientOcclusion();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(i){return this.WIDTH=i||this.WIDTH,this.updateSize(),this}setHeight(i){return this.HEIGHT=i||this.HEIGHT,this.updateSize(),this}resize(){this.WIDTH=this.getWidth(),this.HEIGHT=this.getHeight();let i=!1;if(this.renderer.isLost()&&this.WIDTH>0&&this.HEIGHT>0){let n=!1,a=this.container.querySelector("canvas");a&&a!=this.renderer.getCanvas()?this.config.canvas=a:(a.remove(),this.config&&this.config.canvas!=null&&(delete this.config.canvas,n=!0)),this.setupRenderer(),this.initContainer(this.container),this.renderer.setClearColorHex(this.bgColor,this.config.backgroundAlpha),i=!0,n&&(this.config.canvas=this.renderer.getCanvas())}if(this.WIDTH==0||this.HEIGHT==0?this.animated&&this._viewer.pauseAnimate():this.animated&&this._viewer.resumeAnimate(),this.updateSize(),i){let n=this.renderer.supportedExtensions();if(n.regen=!0,this.viewers)for(let a=0,h=this.viewers.length;a<h;a++)for(let u=0,A=this.viewers[a].length;u<A;u++)this.viewers[a][u].render(null,n);this._viewer.render(null,n)}else this.WIDTH>0&&this.HEIGHT>0&&this.show();return this}getModel(i){return i===void 0?this.models.length==0?null:this.models[this.models.length-1]:i instanceof O.GLModel?i:i in this.models?this.models[i]:this.models.length==0?null:this.models[this.models.length-1]}spin(i,n=1,a=!1){if(clearInterval(this.spinInterval),typeof i>"u"&&(i="y"),typeof i=="boolean")if(i)i="y";else return;Array.isArray(i)&&(i={x:i[0],y:i[1],z:i[2]});var h=this;this.spinInterval=setInterval(function(){!h.getCanvas().isConnected&&h.renderer.isLost()&&clearInterval(h.spinInterval),(!a||h.container.checkVisibility&&h.container.checkVisibility())&&h.rotate(1*n,i)},25)}animateMotion(i,n,a,h,u,A){var D=20,T=Math.ceil(i/D);T<1&&(T=1),this.incAnim();var S={mpos:this.modelGroup.position.clone(),rz:this.rotationGroup.position.z,rot:this.rotationGroup.quaternion.clone(),cam:this.lookingAt.clone()};if(n){let F=new Array(T);for(let I=0;I<T;I++){let G=(I+1)/T,Y={mpos:S.mpos,rz:S.rz,rot:S.rot};Y.mpos=a.clone().sub(S.mpos).multiplyScalar(G).add(S.mpos),Y.rz=S.rz+G*(h-S.rz),Y.rot=t.slerp(S.rot,u,G),Y.cam=A.clone().sub(S.cam).multiplyScalar(G).add(S.cam),F[I]=Y}let B=0,W=this,U=function(){var I=F[B];B+=1,W.modelGroup.position=I.mpos,W.rotationGroup.position.z=I.rz,W.rotationGroup.quaternion=I.rot,W.camera.lookAt(I.cam),B<F.length?setTimeout(U,D):W.decAnim(),W.show()};setTimeout(U,D)}else{var P={};let F=1/T;if(a&&(P.mpos=a.clone().sub(S.mpos).multiplyScalar(F)),typeof h<"u"&&h!=null&&(P.rz=F*(h-S.rz)),u){var z=t.slerp(S.rot,u,F);P.rot=S.rot.clone().inverse().multiply(z)}A&&(P.cam=A.clone().sub(S.cam).multiplyScalar(F));let B=0,W=this,U=function(){B+=1,P.mpos&&W.modelGroup.position.add(P.mpos),P.rz&&(W.rotationGroup.position.z+=P.rz),P.rot&&W.rotationGroup.quaternion.multiply(P.rot),P.cam&&(W.lookingAt.add(P.cam),W.camera.lookAt(W.lookingAt)),B<T?setTimeout(U,D):W.decAnim(),W.show()};setTimeout(U,D)}}rotate(i,n="y",a=0,h=!1){if(n=="x"?n={x:1,y:0,z:0}:n=="y"?n={x:0,y:1,z:0}:n=="z"&&(n={x:0,y:0,z:1}),n=="vx"?n={vx:1,vy:0,vz:0}:n=="vy"?n={vx:0,vy:1,vz:0}:n=="vz"&&(n={vx:0,vy:0,vz:1}),typeof n.vx<"u"){var u=new _.Vector3(n.vx,n.vy,n.vz);u.applyQuaternion(this.rotationGroup.quaternion),n={x:u.x,y:u.y,z:u.z}}var A=function(P){var z=Math.sin(P/2),F=Math.cos(P/2),B=0,W=0,U=0;return B=n.x*z,W=n.y*z,U=n.z*z,new _.Quaternion(B,W,U,F).normalize()},D=Math.PI*i/180,T=A(D);if(a){var S=new _.Quaternion().copy(this.rotationGroup.quaternion).multiply(T);this.animateMotion(a,h,this.modelGroup.position,this.rotationGroup.position.z,S,this.lookingAt)}else this.rotationGroup.quaternion.multiply(T),this.show();return this}surfacesFinished(){for(var i in this.surfaces)if(!this.surfaces[i][0].done)return!1;return!0}getView(){if(!this.modelGroup)return[0,0,0,0,0,0,0,1];var i=this.modelGroup.position,n=this.rotationGroup.quaternion;return[i.x,i.y,i.z,this.rotationGroup.position.z,n.x,n.y,n.z,n.w]}setView(i,n){return i===void 0||!(i instanceof Array||i.length!==8)?this:!this.modelGroup||!this.rotationGroup?this:(this.modelGroup.position.x=i[0],this.modelGroup.position.y=i[1],this.modelGroup.position.z=i[2],this.rotationGroup.position.z=i[3],this.rotationGroup.quaternion.x=i[4],this.rotationGroup.quaternion.y=i[5],this.rotationGroup.quaternion.z=i[6],this.rotationGroup.quaternion.w=i[7],typeof i[8]<"u"&&(this.rotationGroup.position.x=i[8],this.rotationGroup.position.y=i[9]),this.show(n),this)}render(i,n){this.renderer.setViewport(),this.updateClickables();var a=this.getView();this.stateChangeCallback&&this.stateChangeCallback(this.getInternalState());var h,u;for(n||(n=this.renderer.supportedExtensions()),h=0;h<this.models.length;h++)this.models[h]&&this.models[h].globj(this.modelGroup,n);for(h=0;h<this.shapes.length;h++)this.shapes[h]&&(typeof this.shapes[h].frame>"u"||this.viewer_frame<0||this.shapes[h].frame<0||this.shapes[h].frame==this.viewer_frame?this.shapes[h].globj(this.modelGroup,n):this.shapes[h].removegl(this.modelGroup));for(h=0;h<this.labels.length;h++)n.regen&&(this.labels[h].dispose(),this.modelGroup.remove(this.labels[h].sprite),this.labels[h].setContext(),this.modelGroup.add(this.labels[h].sprite)),this.labels[h]&&typeof this.labels[h].frame<"u"&&this.labels[h].frame>=0&&(this.modelGroup.remove(this.labels[h].sprite),(this.viewer_frame<0||this.labels[h].frame==this.viewer_frame)&&this.modelGroup.add(this.labels[h].sprite));for(h in this.surfaces)if(this.surfaces.hasOwnProperty(h)){var A=this.surfaces[h];for(u=0;u<A.length;u++)if(A.hasOwnProperty(u)){var D=A[u].geo;if(!A[u].finished||n.regen){D.verticesNeedUpdate=!0,D.elementsNeedUpdate=!0,D.normalsNeedUpdate=!0,D.colorsNeedUpdate=!0,D.buffersNeedUpdate=!0,A[u].mat.needsUpdate=!0,A[u].done&&(A[u].finished=!0),A[u].lastGL&&this.modelGroup.remove(A[u].lastGL);var T=null;if(A[u].mat instanceof x.LineBasicMaterial?T=new x.Line(D,A[u].mat):("wireframe"in A.style&&A.style.wireframe&&D.setUpWireframe(),T=new x.Mesh(D,A[u].mat)),A[u].mat.transparent&&A[u].mat.opacity==0?T.visible=!1:T.visible=!0,A[u].symmetries.length>1||A[u].symmetries.length==1&&!A[u].symmetries[0].isIdentity()){var S,P=new x.Object3D;for(S=0;S<A[u].symmetries.length;S++){var z=T.clone();z.matrix=A[u].symmetries[S],z.matrixAutoUpdate=!1,P.add(z)}A[u].lastGL=P,this.modelGroup.add(P)}else A[u].lastGL=T,this.modelGroup.add(T)}}}return this.setView(a),typeof i=="function"&&i(this),this}getModelList(i){let n=[];if(typeof i>"u"||typeof i.model>"u")for(let h=0;h<this.models.length;h++)this.models[h]&&n.push(this.models[h]);else{let h=i.model;Array.isArray(h)||(h=[h]);for(let u=0;u<h.length;u++)if(typeof h[u]=="number"){var a=h[u];a<0&&(a+=this.models.length),n.push(this.models[a])}else n.push(h[u])}return n}getAtomsFromSel(i){var n=[];typeof i>"u"&&(i={});var a=this.getModelList(i);for(let h=0;h<a.length;h++)n=n.concat(a[h].selectedAtoms(i));return n}atomIsSelected(i,n){typeof n>"u"&&(n={});for(var a=this.getModelList(n),h=0;h<a.length;h++)if(a[h].atomIsSelected(i,n))return!0;return!1}selectedAtoms(i){return this.getAtomsFromSel(i)}getUniqueValues(i,n){typeof n>"u"&&(n={});var a=this.getAtomsFromSel(n),h={};for(var u in a)if(a[u].hasOwnProperty(i)){var A=a[u][i];h[A]=!0}return Object.keys(h)}pdbData(i){for(var n=this.getAtomsFromSel(i),a="",h=0,u=n.length;h<u;++h)a+=n[h].pdbline+`
|
|
16
|
+
`;return a}zoom(i=2,n=0,a=!1){var h=(this.CAMERA_Z-this.rotationGroup.position.z)/i,u=this.CAMERA_Z-h;return n>0?this.animateMotion(n,a,this.modelGroup.position,this.adjustZoomToLimits(u),this.rotationGroup.quaternion,this.lookingAt):(this.rotationGroup.position.z=this.adjustZoomToLimits(u),this.show()),this}translate(i,n,a=0,h=!1){var u=i/this.WIDTH,A=n/this.HEIGHT,D=new _.Vector3(0,0,-this.CAMERA_Z);this.projector.projectVector(D,this.camera),D.x-=u,D.y-=A,this.projector.unprojectVector(D,this.camera),D.z=0;var T=this.lookingAt.clone().add(D);return a>0?this.animateMotion(a,h,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,T):(this.lookingAt=T,this.camera.lookAt(this.lookingAt),this.show()),this}translateScene(i,n,a=0,h=!1){var u=this.screenOffsetToModel(i,n),A=this.modelGroup.position.clone().add(u);return a>0?this.animateMotion(a,h,this.modelGroup.position,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=A,this.show()),this}fitSlab(i){i=i||{};var n=this.getAtomsFromSel(i),a=(0,m.getExtent)(n),h=a[1][0]-a[0][0],u=a[1][1]-a[0][1],A=a[1][2]-a[0][2],D=Math.hypot(h,u,A);return D<5&&(D=5),this.slabNear=-D/1.9,this.slabFar=D/2,this}center(i={},n=0,a=!1){var h,u,A=this.getAtomsFromSel(i),D=(0,m.getExtent)(A);(0,m.isEmptyObject)(i)?(this.shapes.forEach(G=>{if(G&&G.boundingSphere&&G.boundingSphere.center){var Y=G.boundingSphere.center,J=G.boundingSphere.radius;J>0?(A.push(new _.Vector3(Y.x+J,Y.y,Y.z)),A.push(new _.Vector3(Y.x-J,Y.y,Y.z)),A.push(new _.Vector3(Y.x,Y.y+J,Y.z)),A.push(new _.Vector3(Y.x,Y.y-J,Y.z)),A.push(new _.Vector3(Y.x,Y.y,Y.z+J)),A.push(new _.Vector3(Y.x,Y.y,Y.z-J))):A.push(Y)}}),D=(0,m.getExtent)(A),h=A,u=D):(h=this.getAtomsFromSel({}),u=(0,m.getExtent)(h));var T=new _.Vector3(D[2][0],D[2][1],D[2][2]),S=u[1][0]-u[0][0],P=u[1][1]-u[0][1],z=u[1][2]-u[0][2],F=Math.hypot(S,P,z);F<5&&(F=5),this.slabNear=-F/1.9,this.slabFar=F/2,S=D[1][0]-D[0][0],P=D[1][1]-D[0][1],z=D[1][2]-D[0][2],F=Math.hypot(S,P,z),F<5&&(F=5);for(var B=25,W=0;W<A.length;W++)if(A[W]){var U=T.distanceToSquared(A[W]);U>B&&(B=U)}F=Math.sqrt(B)*2;var I=T.clone().multiplyScalar(-1);return n>0?this.animateMotion(n,a,I,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=I,this.show()),this}zoomTo(i={},n=0,a=!1){let h=this.getAtomsFromSel(i),u=(0,m.getExtent)(h),A=u;if((0,m.isEmptyObject)(i)){let Y=h&&h.length;if(this.shapes.forEach(J=>{if(J&&J.boundingSphere){if(J.boundingSphere.box){let le=J.boundingSphere.box;h.push(new _.Vector3(le.min.x,le.min.y,le.min.z)),h.push(new _.Vector3(le.max.x,le.max.y,le.max.z))}else if(J.boundingSphere.center){var te=J.boundingSphere.center,ne=J.boundingSphere.radius;ne>0?(h.push(new _.Vector3(te.x+ne,te.y,te.z)),h.push(new _.Vector3(te.x-ne,te.y,te.z)),h.push(new _.Vector3(te.x,te.y+ne,te.z)),h.push(new _.Vector3(te.x,te.y-ne,te.z)),h.push(new _.Vector3(te.x,te.y,te.z+ne)),h.push(new _.Vector3(te.x,te.y,te.z-ne))):h.push(te)}}}),A=(0,m.getExtent)(h),!Y)for(let J=0;J<3;J++)u[2][J]=(A[0][J]+A[1][J])/2}else{let Y=this.getAtomsFromSel({});A=(0,m.getExtent)(Y)}var D=new _.Vector3(u[2][0],u[2][1],u[2][2]),T=A[1][0]-A[0][0],S=A[1][1]-A[0][1],P=A[1][2]-A[0][2],z=Math.hypot(T,S,P);z<5&&(z=5),this.slabNear=-z/1.9,this.slabFar=z/2,Object.keys(i).length===0&&(this.slabNear=Math.min(-z*2,-50),this.slabFar=Math.max(z*2,50));var F=this.config.minimumZoomToDistance||5;T=u[1][0]-u[0][0],S=u[1][1]-u[0][1],P=u[1][2]-u[0][2],z=Math.hypot(T,S,P),z<F&&(z=F);for(var B=F*F,W=0;W<h.length;W++)if(h[W]){var U=D.distanceToSquared(h[W]);U>B&&(B=U)}z=Math.sqrt(B)*2;var I=D.clone().multiplyScalar(-1),G=-(z*.5/Math.tan(Math.PI/180*this.camera.fov/2)-this.CAMERA_Z);return G=this.adjustZoomToLimits(G),n>0?this.animateMotion(n,a,I,G,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=I,this.rotationGroup.position.z=G,this.show()),this}setSlab(i,n){this.slabNear=i,this.slabFar=n}getSlab(){return{near:this.slabNear,far:this.slabFar}}addLabel(i,n={},a,h=!1){if(a){var u=(0,m.getExtent)(this.getAtomsFromSel(a));n.position={x:u[2][0],y:u[2][1],z:u[2][2]}}var A=new v.Label(i,n);return A.setContext(),this.modelGroup.add(A.sprite),this.labels.push(A),h||this.show(),A}addResLabels(i,n,a=!1){let h=this.labels.length;return this.applyToModels("addResLabels",i,n,a),this.show(),this.labels.slice(h)}addPropertyLabels(i,n,a){return this.applyToModels("addPropertyLabels",i,n,a),this.show(),this}removeLabel(i){for(var n=0;n<this.labels.length;n++)if(this.labels[n]==i){this.labels.splice(n,1),i.dispose(),this.modelGroup.remove(i.sprite);break}return this.show(),this}removeAllLabels(){for(var i=0;i<this.labels.length;i++)this.labels[i]&&this.labels[i].sprite&&this.modelGroup.remove(this.labels[i].sprite);return this.labels.splice(0,this.labels.length),this.show(),this}hideAllLabels(){for(var i=0;i<this.labels.length;i++)this.labels[i]&&this.labels[i].hide();return this.show(),this}showAllLabels(){for(var i=0;i<this.labels.length;i++)this.labels[i]&&this.labels[i].show();return this.show(),this}setLabelStyle(i,n){return this.modelGroup.remove(i.sprite),i.dispose(),i.stylespec=n,i.setContext(),this.modelGroup.add(i.sprite),this.show(),i}setLabelText(i,n){return this.modelGroup.remove(i.sprite),i.dispose(),i.text=n,i.setContext(),this.modelGroup.add(i.sprite),this.show(),i}addShape(i){i=i||{};var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,this.shapes.push(n),n}removeShape(i){if(!i)return this;for(i.removegl(this.modelGroup),delete this.shapes[i.shapePosition];this.shapes.length>0&&typeof this.shapes[this.shapes.length-1]>"u";)this.shapes.pop();return this}removeAllShapes(){for(var i=0;i<this.shapes.length;i++){var n=this.shapes[i];n&&n.removegl(this.modelGroup)}return this.shapes.splice(0,this.shapes.length),this}getSelectionCenter(i){if(i.hasOwnProperty("x")&&i.hasOwnProperty("y")&&i.hasOwnProperty("z"))return i;var n=this.getAtomsFromSel(i);if(n.length==0)return{x:0,y:0,z:0};var a=(0,m.getExtent)(n);return{x:a[0][0]+(a[1][0]-a[0][0])/2,y:a[0][1]+(a[1][1]-a[0][1])/2,z:a[0][2]+(a[1][2]-a[0][2])/2}}addSphere(i){i=i||{},i.center=this.getSelectionCenter(i.center);var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,n.addSphere(i),this.shapes.push(n),n.finalize(),n}addBox(i={}){i.corner!=null&&(i.corner=this.getSelectionCenter(i.corner)),i.center!=null&&(i.center=this.getSelectionCenter(i.center));var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,n.addBox(i),this.shapes.push(n),n.finalize(),n}addArrow(i={}){i.start=this.getSelectionCenter(i.start),i.end=this.getSelectionCenter(i.end);var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,n.addArrow(i),this.shapes.push(n),n.finalize(),n}addCylinder(i={}){i.start=this.getSelectionCenter(i.start),i.end=this.getSelectionCenter(i.end);var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,i.dashed?n.addDashedCylinder(i):n.addCylinder(i),this.shapes.push(n),n.finalize(),n}addCurve(i={}){var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,n.addCurve(i),this.shapes.push(n),n.finalize(),n}addLine(i={}){i.start=this.getSelectionCenter(i.start),i.end=this.getSelectionCenter(i.end),i.wireframe=!0;var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,i.dashed?n=this.addLineDashed(i,n):n.addLine(i),this.shapes.push(n),n.finalize(),n}addUnitCell(i,n){i=this.getModel(i),n=n||{alabel:"a",blabel:"b",clabel:"c"},n.box=n.box||{},n.astyle=n.astyle||{color:"red",radius:.1,midpos:-1},n.bstyle=n.bstyle||{color:"green",radius:.1,midpos:-1},n.cstyle=n.cstyle||{color:"blue",radius:.1,midpos:-1},n.alabelstyle=n.alabelstyle||{fontColor:"red",showBackground:!1,alignment:"center",inFront:!1},n.blabelstyle=n.blabelstyle||{fontColor:"green",showBackground:!1,alignment:"center",inFront:!1},n.clabelstyle=n.clabelstyle||{fontColor:"blue",showBackground:!1,alignment:"center",inFront:!1},i.unitCellObjects&&this.removeUnitCell(i),i.unitCellObjects={shapes:[],labels:[]};var a=i.getCrystData(),h=null;if(a){if(a.matrix)h=a.matrix;else{var u=a.a,A=a.b,D=a.c,T=a.alpha,S=a.beta,P=a.gamma;T=T*Math.PI/180,S=S*Math.PI/180,P=P*Math.PI/180;var z,F,B;z=Math.cos(S),F=(Math.cos(T)-Math.cos(S)*Math.cos(P))/Math.sin(P),B=Math.sqrt(Math.max(0,1-z*z-F*F)),h=new _.Matrix3(u,A*Math.cos(P),D*z,0,A*Math.sin(P),D*F,0,0,D*B)}var W=[new _.Vector3(0,0,0),new _.Vector3(1,0,0),new _.Vector3(0,1,0),new _.Vector3(0,0,1),new _.Vector3(1,1,0),new _.Vector3(0,1,1),new _.Vector3(1,0,1),new _.Vector3(1,1,1)];if(a.matrix4)for(let I=0;I<W.length;I++)a.size&&W[I].multiplyVectors(W[I],a.size),W[I]=W[I].applyMatrix4(a.matrix4);else for(let I=0;I<W.length;I++)W[I]=W[I].applyMatrix3(h);if(n.box&&!n.box.hidden){n.box.wireframe=!0;var U=new C.GLShape(n.box);U.shapePosition=this.shapes.length,U.addLine({start:W[0],end:W[1]}),U.addLine({start:W[0],end:W[2]}),U.addLine({start:W[1],end:W[4]}),U.addLine({start:W[2],end:W[4]}),U.addLine({start:W[0],end:W[3]}),U.addLine({start:W[3],end:W[5]}),U.addLine({start:W[2],end:W[5]}),U.addLine({start:W[1],end:W[6]}),U.addLine({start:W[4],end:W[7]}),U.addLine({start:W[6],end:W[7]}),U.addLine({start:W[3],end:W[6]}),U.addLine({start:W[5],end:W[7]}),this.shapes.push(U),i.unitCellObjects.shapes.push(U),U.finalize()}if(!n.astyle.hidden){n.astyle.start=W[0],n.astyle.end=W[1];let I=this.addArrow(n.astyle);i.unitCellObjects.shapes.push(I)}if(!n.bstyle.hidden){n.bstyle.start=W[0],n.bstyle.end=W[2];let I=this.addArrow(n.bstyle);i.unitCellObjects.shapes.push(I)}if(!n.cstyle.hidden){n.cstyle.start=W[0],n.cstyle.end=W[3];let I=this.addArrow(n.cstyle);i.unitCellObjects.shapes.push(I)}if(n.alabel){n.alabelstyle.position=W[1];let I=this.addLabel(n.alabel,n.alabelstyle);i.unitCellObjects.labels.push(I)}if(n.blabel){n.blabelstyle.position=W[2];let I=this.addLabel(n.blabel,n.blabelstyle);i.unitCellObjects.labels.push(I)}if(n.clabel){n.clabelstyle.position=W[3];let I=this.addLabel(n.clabel,n.clabelstyle);i.unitCellObjects.labels.push(I)}}}removeUnitCell(i){if(i=this.getModel(i),i.unitCellObjects){let n=this;i.unitCellObjects.shapes.forEach(function(a){n.removeShape(a)}),i.unitCellObjects.labels.forEach(function(a){n.removeLabel(a)})}delete i.unitCellObjects}replicateUnitCell(i=3,n=i,a=n,h,u,A){h=this.getModel(h);let D=h.getCrystData();if(D){const T=h.selectedAtoms({}),S=D.matrix;let P=function(F){return F%2==0?-F/2:Math.ceil(F/2)};i<=1&&n<=1&&a<=1&&(A=!0,i=n=a=3);let z=function(F,B,W){return!1};if(A){const F=new _.Matrix3().getInverse3(S);z=function(B,W,U){let I=new _.Vector3(B,W,U).applyMatrix3(F);return!(I.x>-1e-4&&I.x<1.0001&&I.y>-1e-4&&I.y<1.0001&&I.z>-1e-4&&I.z<1.0001)}}for(let F=0;F<i;F++)for(let B=0;B<n;B++)for(let W=0;W<a;W++){if(F==0&&B==0&&W==0)continue;let U=new _.Vector3(P(F),P(B),P(W));U.applyMatrix3(S);let I=[];for(let G=0;G<T.length;G++){let Y=T[G].x+U.x,J=T[G].y+U.y,te=T[G].z+U.z;if(z(Y,J,te))continue;let ne={};for(let le in T[G])ne[le]=T[G][le];ne.x=Y,ne.y=J,ne.z=te,I.push(ne)}h.addAtoms(I)}u&&h.assignBonds()}}addLineDashed(i,n){i.dashLength=i.dashLength||.5,i.gapLength=i.gapLength||.5;var a;i.start?a=new _.Vector3(i.start.x||0,i.start.y||0,i.start.z||0):a=new _.Vector3(0,0,0);var h;i.end?h=new _.Vector3(i.end.x,i.end.y||0,i.end.z||0):h=new _.Vector3(0,0,0);var u=new _.Vector3,A=new _.Vector3,D=new _.Vector3,T,S,P,z=a.clone(),F=0;for(u.subVectors(h,a),T=u.length(),u.normalize(),A=u.clone(),D=u.clone(),A.multiplyScalar(i.dashLength),D.multiplyScalar(i.gapLength),S=A.length(),P=D.length();F<T;){if(F+S>T){i.start=a,i.end=h,n.addLine(i);break}z.addVectors(a,A),i.start=a,i.end=z,n.addLine(i),a=z.clone(),F+=S,z.addVectors(a,D),a=z.clone(),F+=P}return n.finalize(),n}addCustom(i){i=i||{};var n=new C.GLShape(i);return n.shapePosition=this.shapes.length,n.addCustom(i),this.shapes.push(n),n.finalize(),n}addVolumetricData(i,n,a={}){var h=new M.VolumeData(i,n);return a.hasOwnProperty("transferfn")?this.addVolumetricRender(h,a):this.addIsosurface(h,a)}addIsosurface(i,n={},a){var h=new C.GLShape(n);return h.shapePosition=this.shapes.length,h.addIsosurface(i,n,a,this),this.shapes.push(h),h}addVolumetricRender(i,n){n=n||{};var a=new g.GLVolumetricRender(i,n,this);return a.shapePosition=this.shapes.length,this.shapes.push(a),a}hasVolumetricRender(){return this.renderer.supportsVolumetric()}enableFog(i){if(i){this.scene.fog=new x.Fog(this.bgColor,100,200),this.config.disableFog=!1;const n=i;n.fogStart==null?this.fogStart=.4:this.fogStart=n.fogStart,n.fogEnd==null?this.fogEnd=1:this.fogEnd=n.fogEnd}else this.config.disableFog=!0,this.show()}setFrame(i){this.viewer_frame=i;let n=this;return new Promise(function(a){var h=n.models.map(function(u){return u.setFrame(i)});Promise.all(h).then(function(){a()})})}getFrame(){return this.viewer_frame}getNumFrames(){var i=0;for(let n=0;n<this.models.length;n++)this.models[n].getNumFrames()>i&&(i=this.models[n].getNumFrames());for(let n=0;n<this.shapes.length;n++)this.shapes[n].frame&&this.shapes[n].frame>=i&&(i=this.shapes[n].frame+1);for(let n=0;n<this.labels.length;n++)this.labels[n].frame&&this.labels[n].frame>=i&&(i=this.labels[n].frame+1);return i}getNextModelId(){return this.models.length}animate(i){this.incAnim();var n=100,a="forward",h=1/0;i=i||{},i.interval&&(n=i.interval),i.loop&&(a=i.loop),i.reps&&(h=i.reps);var u=this.getNumFrames(),A=this,D=0;i.startFrame&&(D=i.startFrame%u);var T=1;i.step&&(T=i.step,h/=T);var S=0,P=u*h,z=new Date,F,B,W=function(U){z=new Date,U=="forward"?A.setFrame(D).then(function(){D=(D+T)%u,F()}):U=="backward"?A.setFrame(u-1-D).then(function(){D=(D+T)%u,F()}):A.setFrame(D).then(function(){D+=T,T*=D%(u-1)==0?-1:1,F()})};return F=function(){if(A.render(),!A.getCanvas().isConnected)A.stopAnimate();else if(++S>=P||!A.isAnimated())B.cancel(),A.animationTimers.delete(B),A.decAnim();else{var U=n-(new Date().getTime()-z.getTime());U=U>0?U:0,B.cancel(),A.animationTimers.delete(B),B=new m.PausableTimer(W,U,a),A.animationTimers.add(B)}},B=new m.PausableTimer(W,0,a),this.animationTimers.add(B),this}stopAnimate(){return this.animated=0,this.animationTimers.forEach(function(i){i.cancel()}),this.animationTimers=new Set,this}pauseAnimate(){return this.animationTimers.forEach(function(i){i.pause()}),this}resumeAnimate(){return this.animationTimers.forEach(function(i){i.resume()}),this}isAnimated(){return this.animated>0}getModelOpt(i){return i&&!i.defaultcolors?(i.defaultcolors=this.defaultcolors,i.cartoonQuality=i.cartoonQuality||this.config.cartoonQuality):typeof i>"u"&&(i={defaultcolors:this.defaultcolors,cartoonQuality:this.config.cartoonQuality}),i}addModel(i,n="",a){a=this.getModelOpt(a);var h=new O.GLModel(this.models.length,a,this);return h.addMolData(i,n,a),this.models.push(h),h}addModels(i,n,a){a=this.getModelOpt(a),a.multimodel=!0,a.frames=!0;for(var h=O.GLModel.parseMolData(i,n,a),u=0;u<h.length;u++){var A=new O.GLModel(this.models.length,a,this);A.setAtomDefaults(h[u]),A.addFrame(h[u]),A.setFrame(0),h.modelData&&A.setModelData(h.modelData[u]),A.setDontDuplicateAtoms(!a.duplicateAssemblyAtoms),this.models.push(A)}return this.models}addModelsAsFrames(i,n,a){a=this.getModelOpt(a),a.multimodel=!0,a.frames=!0;var h=new O.GLModel(this.models.length,a,this);return h.addMolData(i,n,a),this.models.push(h),h}addAsOneMolecule(i,n,a){a=this.getModelOpt(a),a.multimodel=!0,a.onemol=!0;var h=new O.GLModel(this.models.length,a,this);return h.addMolData(i,n,a),this.models.push(h),h}removeModel(i){if(i=this.getModel(i),!!i){for(i.removegl(this.modelGroup),delete this.models[i.getID()];this.models.length>0&&typeof this.models[this.models.length-1]>"u";)this.models.pop();return this}}removeAllModels(){for(var i=0;i<this.models.length;i++){var n=this.models[i];n&&n.removegl(this.modelGroup)}return this.models.splice(0,this.models.length),this}exportJSON(i,n){var a={};return n===void 0?a.m=this.models.map(function(h){return h.toCDObject(i)}):a.m=[this.models[n].toCDObject()],JSON.stringify(a)}exportVRML(){var i=this.modelGroup;this.applyToModels("removegl",this.modelGroup),this.modelGroup=new x.Object3D,this.render(null,{supportsImposters:!1,supportsAIA:!1,regen:!0});var n=`#VRML V2.0 utf8
|
|
17
|
+
`+this.modelGroup.vrml()+`
|
|
18
|
+
`;return this.applyToModels("removegl",this.modelGroup),this.modelGroup=i,n}createModelFrom(i,n=!1){for(var a=new O.GLModel(this.models.length,this.defaultcolors,this),h=0;h<this.models.length;h++)if(this.models[h]){var u=this.models[h].selectedAtoms(i);a.addAtoms(u),n&&this.models[h].removeAtoms(u)}return this.models.push(a),a}applyToModels(i,n,a,h,u,A,D){for(var T=this.getModelList(n),S=0;S<T.length;S++)T[S][i](n,a,h,u,A,D)}setStyle(i,n){return typeof n>"u"&&(n=i,i={}),this.applyToModels("setStyle",i,n,!1),this}addStyle(i,n){return typeof n>"u"&&(n=i,i={}),this.applyToModels("setStyle",i,n,!0),this}setClickable(i,n,a){return this.applyToModels("setClickable",i,n,a),this}setHoverable(i,n,a,h){return this.applyToModels("setHoverable",i,n,a,h),this}enableContextMenu(i,n){return this.applyToModels("enableContextMenu",i,n),this}vibrate(i,n,a,h){return this.applyToModels("vibrate",i,n,a,h),this}setColorByProperty(i,n,a,h){return this.applyToModels("setColorByProperty",i,n,a,h),this}setColorByElement(i,n){return this.applyToModels("setColorByElement",i,n),this}static getAtomsWithin(i,n){var a=[];for(let u=0;u<i.length;u++){var h=i[u];typeof h>"u"||h.x<n[0][0]||h.x>n[1][0]||h.y<n[0][1]||h.y>n[1][1]||h.z<n[0][2]||h.z>n[1][2]||a.push(h)}return a}static volume(i){var n=i[1][0]-i[0][0],a=i[1][1]-i[0][1],h=i[1][2]-i[0][2];return n*a*h}carveUpExtent(i,n,a){let h=[],u={};for(let z=0,F=n.length;z<F;z++)u[n[z].index]=z;let A=function(z){let F=[];for(let B=0,W=z.length;B<W;B++)z[B].index in u&&F.push(u[z[B].index]);return F},D=function(z){let F=[];return F[0]=[z[0][0],z[0][1],z[0][2]],F[1]=[z[1][0],z[1][1],z[1][2]],F},T=function(z){if(t.volume(z)<t.maxVolume)return[z];var F=z[1][0]-z[0][0],B=z[1][1]-z[0][1],W=z[1][2]-z[0][2],U;F>B&&F>W?U=0:B>F&&B>W?U=1:U=2;var I=D(z),G=D(z),Y=(z[1][U]-z[0][U])/2+z[0][U];I[1][U]=Y,G[0][U]=Y;var J=T(I),te=T(G);return J.concat(te)},S=T(i),P=6;for(let z=0,F=S.length;z<F;z++){let B=D(S[z]);B[0][0]-=P,B[0][1]-=P,B[0][2]-=P,B[1][0]+=P,B[1][1]+=P,B[1][2]+=P;let W=t.getAtomsWithin(n,B),U=t.getAtomsWithin(a,S[z]);h.push({extent:S[z],atoms:A(W),toshow:A(U)})}return h}static generateSurfaceMesh(i,n,a){var h=new x.Geometry(!0),u=h.updateGeoGroup(0),A=[];for(let ee=0,pe=i.length;ee<pe;ee++){var D=i[ee];D&&(typeof D.surfaceColor<"u"?A[ee]=D.surfaceColor:D.color&&(A[ee]=p.CC.color(D.color)))}var T=u.vertexArray,S=n.vertices;for(let ee=0,pe=S.length;ee<pe;ee++){let Ce=u.vertices*3;T[Ce]=S[ee].x,T[Ce+1]=S[ee].y,T[Ce+2]=S[ee].z,u.vertices++}var P=u.colorArray;let z=u.atomArray;if(a.voldata&&a.volscheme){var F=a.volscheme,B=a.voldata,W=F.range()||[-1,1];for(let ee=0,pe=S.length;ee<pe;ee++){let Ce=S[ee].atomid,Te=B.getVal(S[ee].x,S[ee].y,S[ee].z),We=p.CC.color(F.valueToHex(Te,W)),Ie=ee*3;P[Ie]=We.r,P[Ie+1]=We.g,P[Ie+2]=We.b,z[ee]=i[Ce]}}else if(A.length>0)for(let ee=0,pe=S.length;ee<pe;ee++){let Ce=S[ee].atomid,Te=ee*3;P[Te]=A[Ce].r,P[Te+1]=A[Ce].g,P[Te+2]=A[Ce].b,z[ee]=i[Ce]}var U=n.faces;u.faceidx=U.length,h.initTypedArrays();var I=u.vertexArray,G=u.normalArray,Y,J,te,ne;for(let ee=0,pe=U.length;ee<pe;ee+=3){var le=U[ee],ie=U[ee+1],oe=U[ee+2],xe=le*3,_e=ie*3,Oe=oe*3;Y=new _.Vector3(I[xe],I[xe+1],I[xe+2]),J=new _.Vector3(I[_e],I[_e+1],I[_e+2]),te=new _.Vector3(I[Oe],I[Oe+1],I[Oe+2]),te.subVectors(te,J),Y.subVectors(Y,J),te.cross(Y),ne=te,ne.normalize(),G[xe]+=ne.x,G[_e]+=ne.x,G[Oe]+=ne.x,G[xe+1]+=ne.y,G[_e+1]+=ne.y,G[Oe+1]+=ne.y,G[xe+2]+=ne.z,G[_e+2]+=ne.z,G[Oe+2]+=ne.z}u.faceArray=new Uint16Array(U);var ye=new x.Mesh(h,a);return ye}static generateMeshSyncHelper(i,n,a,h,u,A){var D=new y.ProteinSurface;return D.initparm(n,i!==1,A),D.fillvoxels(u,a),D.buildboundary(),(i==y.SurfaceType.SES||i==y.SurfaceType.MS)&&(D.fastdistancemap(),D.boundingatom(!1),D.fillvoxelswaals(u,a)),D.marchingcube(i),D.getFacesAndVertices(h)}static getMatWithStyle(i){let n=null;i.onesided?n=new x.MeshLambertMaterial:n=new x.MeshDoubleLambertMaterial,n.vertexColors=x.Coloring.VertexColors;for(var a in i)a==="color"||a==="map"||i.hasOwnProperty(a)&&(n[a]=i[a]);return i.opacity!==void 0&&(i.opacity===1?n.transparent=!1:n.transparent=!0),i.wireframe!==void 0&&(n.wireframe=i.wireframe),n}addMesh(i){let n={geo:i.geometry,mat:i.material,done:!0,finished:!1};var a=this.nextSurfID();return this.surfaces[a]=new e([n]),a}static shallowCopy(i){var n=[];let a=i.length;for(let h=0;h<a;h++)n[h]=(0,m.extend)({},i[h]);return n}addSurface(i,n={},a={},h,u,A){let D=this.nextSurfID(),T=null,S=this,P=y.SurfaceType.VDW;typeof i=="string"?t.surfaceTypeMap[i.toUpperCase()]!==void 0?P=t.surfaceTypeMap[i]:console.log("Surface type : "+i+" is not recognized"):typeof i=="number"&&(P=i);var z=null,F=null,B=t.shallowCopy(this.getAtomsFromSel(a));h?z=t.shallowCopy(this.getAtomsFromSel(h)):z=B,(0,m.adjustVolumeStyle)(n);var W=!1,U;for(U=0;U<this.models.length;U++)if(this.models[U]){var I=this.models[U].getSymmetries();if(I.length>1||I.length==1&&!I[0].isIdentity()){W=!0;break}}var G=function(oe,xe,_e){u?F=t.shallowCopy(S.getAtomsFromSel(u)):F=_e;var Oe,ye=(0,m.getExtent)(_e,!0);if(n.map&&n.map.prop){var ee=n.map.prop;let je=(0,R.getGradient)(n.map.scheme||n.map.gradient||new R.Gradient.RWB),ke=je.range();ke||(ke=(0,m.getPropertyRange)(_e,ee)),n.colorscheme={prop:ee,gradient:je}}for(let je=0,ke=xe.length;je<ke;je++)Oe=xe[je],Oe.surfaceColor=(0,m.getColorFromStyle)(Oe,n);var pe=t.volume(ye),Ce=S.carveUpExtent(ye,xe,_e);if(F&&F.length&&F.length>0){var Te=(0,m.getExtent)(F,!0),We=function(je,ke){var K=function(me,ce){var Me=me.extent,we=Me[1][0]-Me[0][0],j=Me[1][1]-Me[0][1],se=Me[1][2]-Me[0][2],ge=we-ce[2][0];ge*=ge;var Se=j-ce[2][1];Se*=Se;var re=se-ce[2][2];return re*=re,ge+Se+re},Z=K(je,Te),$=K(ke,Te);return Z-$};Ce.sort(We)}var Ie=[];for(let je=0,ke=xe.length;je<ke;je++)Oe=xe[je],Ie[je]={x:Oe.x,y:Oe.y,z:Oe.z,serial:je,elem:Oe.elem};var Be=!!y.syncSurface;if((typeof $3Dmol>"u"||typeof $3Dmol.SurfaceWorker>"u")&&(console.log("$3Dmol.SurfaceWorker is not defined, using synchronous surface generation."),Be=!0),Be){var Fe=function(ke){return new Promise(function(K){for(var Z=t.generateMeshSyncHelper(P,Ce[ke].extent,Ce[ke].atoms,Ce[ke].toshow,Ie,pe),$=(0,C.splitMesh)({vertexArr:Z.vertices,faceArr:Z.faces}),me=0,ce=$.length;me<ce;me++){Z={vertices:$[me].vertexArr,faces:$[me].faceArr};var Me=t.generateSurfaceMesh(xe,Z,T);(0,m.mergeGeos)(oe.geo,Me)}S.render(),K()})},ze=[];for(let je=0;je<Ce.length;je++)ze.push(Fe(je));return Promise.all(ze).then(function(){return oe.done=!0,S.render(),Promise.resolve(D)})}else{var Pe=[];P<0&&(P=0);for(let je=0,ke=t.numWorkers;je<ke;je++){var Re=new Worker($3Dmol.SurfaceWorker);Pe.push(Re),Re.postMessage({type:-1,atoms:Ie,volume:pe})}return new Promise(function(je,ke){var K=0,Z=function(){!Pe||!Pe.length||Pe.forEach(function(Me){Me&&Me.terminate&&Me.terminate()})},$=function(Me){for(var we=(0,C.splitMesh)({vertexArr:Me.data.vertices,faceArr:Me.data.faces}),j=0,se=we.length;j<se;j++){var ge={vertices:we[j].vertexArr,faces:we[j].faceArr},Se=t.generateSurfaceMesh(xe,ge,T);(0,m.mergeGeos)(oe.geo,Se)}S.render(),K++,K==Ce.length&&(oe.done=!0,Z(),je(D))},me=function(Me){Z(),console.log(Me.message+" ("+Me.filename+":"+Me.lineno+")"),ke(Me)};for(let Me=0;Me<Ce.length;Me++){var ce=Pe[Me%Pe.length];ce.onmessage=$,ce.onerror=me,ce.postMessage({type:P,expandedExtent:Ce[Me].extent,extendedAtoms:Ce[Me].atoms,atomsToShow:Ce[Me].toshow})}})}};n=n||{},T=t.getMatWithStyle(n);let Y=new e([]);Y.style=n,Y.atomsel=a,Y.allsel=h,Y.focus=u;var J=null;if(W){var te={},ne={};for(U=0;U<this.models.length;U++)te[U]=[],ne[U]=[];for(U=0;U<z.length;U++)te[z[U].model].push(z[U]);for(U=0;U<B.length;U++)ne[B[U].model].push(B[U]);var le=[];for(U=0;U<this.models.length;U++)ne[U].length>0&&(Y.push({geo:new x.Geometry(!0),mat:T,done:!1,finished:!1,symmetries:this.models[U].getSymmetries()}),le.push(G(Y[Y.length-1],te[U],ne[U])));J=Promise.all(le)}else Y.push({geo:new x.Geometry(!0),mat:T,done:!1,finished:!1,symmetries:[new _.Matrix4]}),J=G(Y[Y.length-1],z,B);return this.surfaces[D]=Y,J.surfid=D,A&&typeof A=="function"?(J.then(function(ie){A(ie)}),D):J}setSurfaceMaterialStyle(i,n){if((0,m.adjustVolumeStyle)(n),this.surfaces[i]){var a=this.surfaces[i];for(let u=0;u<a.length;u++){var h=a[u].mat=t.getMatWithStyle(n);if(a[u].mat.side=x.FrontSide,n.wireframe&&a[u].geo.setUpWireframe(),n.color){a[u].mat.color=p.CC.color(n.color),a[u].geo.colorsNeedUpdate=!0;const A=p.CC.color(n.color);a[u].geo.setColor(A)}else if(h.voldata&&h.volscheme){const A=h.volscheme,D=h.voldata,T=p.CC,S=A.range()||[-1,1];a[u].geo.setColors(function(P,z,F){let B=D.getVal(P,z,F);return T.color(A.valueToHex(B,S))})}else{a[u].geo.colorsNeedUpdate=!0;for(let A of a[u].geo.geometryGroups)for(let D=0;D<A.vertices;D++){let T=(0,m.getColorFromStyle)(A.atomArray[D],n),S=3*D;A.colorArray[S]=T.r,A.colorArray[S+1]=T.g,A.colorArray[S+2]=T.b}}a[u].finished=!1}}return this}getSurface(i){return this.surfaces[i]}removeSurface(i){for(var n=this.surfaces[i],a=0;a<n.length;a++)n[a]&&n[a].lastGL&&(n[a].geo!==void 0&&n[a].geo.dispose(),n[a].mat!==void 0&&n[a].mat.dispose(),this.modelGroup.remove(n[a].lastGL));return delete this.surfaces[i],this.show(),this}removeAllSurfaces(){for(var i in this.surfaces)if(this.surfaces.hasOwnProperty(i)){for(var n=this.surfaces[i],a=0;a<n.length;a++)n[a]&&n[a].lastGL&&(n[a].geo!==void 0&&n[a].geo.dispose(),n[a].mat!==void 0&&n[a].mat.dispose(),this.modelGroup.remove(n[a].lastGL));delete this.surfaces[i]}return this.show(),this}jmolMoveTo(){var i=this.modelGroup.position,n="center { "+-i.x+" "+-i.y+" "+-i.z+" }; ",a=this.rotationGroup.quaternion;return n+="moveto .5 quaternion { "+a.x+" "+a.y+" "+a.z+" "+a.w+" };",n}clear(){return this.removeAllSurfaces(),this.removeAllModels(),this.removeAllLabels(),this.removeAllShapes(),this.show(),this}mapAtomProperties(i,n){n=n||{};var a=this.getAtomsFromSel(n);if(typeof i=="function")for(let A=0,D=a.length;A<D;A++){let T=a[A];i(T)}else for(let A=0,D=a.length;A<D;A++){var h=a[A];for(let T=0,S=i.length;T<S;T++){let P=i[T];if(P.props)for(var u in P.props)P.props.hasOwnProperty(u)&&this.atomIsSelected(h,P)&&(h.properties||(h.properties={}),h.properties[u]=P.props[u])}}return this}linkViewer(i){return this.linkedViewers.push(i),this}getPerceivedDistance(){return this.CAMERA_Z-this.rotationGroup.position.z}setPerceivedDistance(i){this.rotationGroup.position.z=this.CAMERA_Z-i}setAutoEyeSeparation(i,n){var a=this.getPerceivedDistance();return n||(n=5),i||this.camera.position.x>0?this.camera.position.x=a*Math.tan(Math.PI/180*n):this.camera.position.x=-a*Math.tan(Math.PI/180*n),this.camera.lookAt(new _.Vector3(0,0,this.rotationGroup.position.z)),this.camera.position.x}setDefaultCartoonQuality(i){this.config.cartoonQuality=i}}t.numWorkers=4,t.maxVolume=64e3,t.surfaceTypeMap={VDW:y.SurfaceType.VDW,MS:y.SurfaceType.MS,SAS:y.SurfaceType.SAS,SES:y.SurfaceType.SES};function s(d,i){if(d=(0,m.getElement)(d),!!d){i=i||{};try{var n=new t(d,i);return n}catch(a){throw"error creating viewer: "+a}}}function o(d,i={},n={}){if(d=(0,m.getElement)(d),!!d){var a=[],h=document.createElement("canvas");n.rows=i.rows,n.cols=i.cols,n.control_all=i.control_all!=null?i.control_all:!1,d.appendChild(h);try{for(var u=0;u<i.rows;u++){for(var A=[],D=0;D<i.cols;D++){n.row=u,n.col=D,n.canvas=h,n.viewers=a,n.control_all=i.control_all;var T=s(d,(0,m.extend)({},n));A.push(T)}a.unshift(A)}}catch(S){throw"error creating viewer grid: "+S}return a}}function l(d){var i=this;if(d=(0,m.getElement)(d),!!d){var n=o(d,{rows:1,cols:2,control_all:!0});this.glviewer1=n[0][0],this.glviewer2=n[0][1],this.glviewer1.setAutoEyeSeparation(!1),this.glviewer2.setAutoEyeSeparation(!0),this.glviewer1.linkViewer(this.glviewer2),this.glviewer2.linkViewer(this.glviewer1);for(var a=Object.getOwnPropertyNames(this.glviewer1.__proto__).filter(function(u){return typeof i.glviewer1[u]=="function"}),h=0;h<a.length;h++)this[a[h]]=(function(u){return function(){var A=this.glviewer1[u].apply(this.glviewer1,arguments),D=this.glviewer2[u].apply(this.glviewer2,arguments);return[A,D]}})(a[h]);this.setCoordinates=function(u,A,D){for(var T=0;T<u.length;T++)u[T].setCoordinates(A,D)},this.surfacesFinished=function(){return this.glviewer1.surfacesFinished()&&this.glviewer2.surfacesFinished()},this.isAnimated=function(){return this.glviewer1.isAnimated()||this.glviewer2.isAnimated()},this.render=function(u){this.glviewer1.render(),this.glviewer2.render(),u&&u(this)},this.getCanvas=function(){return this.glviewer1.getCanvas()}}}},"./src/Gradient.ts"(k,w,c){c.r(w),c.d(w,{CustomLinear:()=>g,Gradient:()=>_,GradientType:()=>O,ROYGB:()=>y,RWB:()=>v,Sinebow:()=>M,builtinGradients:()=>x,getGradient:()=>R,normalizeValue:()=>C});var b=c("./src/colors.ts");class O{}function C(p,m,r){return m>=p?(r<p&&(r=p),r>m&&(r=m),{lo:p,hi:m,val:r}):(r>p&&(r=p),r<m&&(r=m),r=p-r+m,{lo:m,hi:p,val:r})}function R(p){if(p instanceof O)return p;if(p.gradient!==void 0&&x[p.gradient]){let m=p.min===void 0?-1:p.min,r=p.max===void 0?1:p.max;return p.mid===void 0?p.colors===void 0?new x[p.gradient](m,r):new x[p.gradient](m,r,p.colors):new x[p.gradient](m,r,p.mid)}else if(typeof p.gradient=="string"&&p.gradient.startsWith("linear_")){let m=p.gradient.split("_");m.shift();let r=p.min===void 0?-1:p.min,e=p.max===void 0?1:p.max;return new g(r,e,m)}return p}class v extends O{constructor(m,r,e){super(),this.gradient="RWB",this.mult=1,this.mid=e,this.min=m,this.max=r,typeof r>"u"&&Array.isArray(m)&&m.length>=2?(this.max=m[1],this.min=m[0]):m&&r&&!Array.isArray(m)&&(this.min=m,this.max=r)}range(){return typeof this.min<"u"&&typeof this.max<"u"?[this.min,this.max]:null}valueToHex(m,r){var e,t;if(m=this.mult*m,r?(e=r[0],t=r[1]):(e=this.min,t=this.max),m===void 0)return 16777215;var s=C(e,t,m);e=s.lo,t=s.hi,m=s.val;var o=(t+e)/2;r&&typeof r[2]<"u"?o=r[2]:typeof this.mid<"u"?o=this.mid:o=(e+t)/2;var l,d;return m<o?(l=Math.floor(255*Math.sqrt((m-e)/(o-e))),d=16711680+256*l+l,d):m>o?(l=Math.floor(255*Math.sqrt(1-(m-o)/(t-o))),d=65536*l+256*l+255,d):16777215}}class y extends O{constructor(m,r){super(),this.gradient="ROYGB",this.mult=1,this.min=m,this.max=r,typeof r>"u"&&Array.isArray(m)&&m.length>=2?(this.max=m[1],this.min=m[0]):m&&r&&!Array.isArray(m)&&(this.min=m,this.max=r)}valueToHex(m,r){var e,t;if(m=this.mult*m,r?(e=r[0],t=r[1]):(e=this.min,t=this.max),typeof m>"u")return 16777215;var s=C(e,t,m);e=s.lo,t=s.hi,m=s.val;var o=(e+t)/2,l=(e+o)/2,d=(o+t)/2,i,n;return m<l?(i=Math.floor(255*Math.sqrt((m-e)/(l-e))),n=16711680+256*i+0,n):m<o?(i=Math.floor(255*Math.sqrt(1-(m-l)/(o-l))),n=65536*i+65280+0,n):m<d?(i=Math.floor(255*Math.sqrt((m-o)/(d-o))),n=65280+1*i,n):(i=Math.floor(255*Math.sqrt(1-(m-d)/(t-d))),n=0+256*i+255,n)}range(){return typeof this.min<"u"&&typeof this.max<"u"?[this.min,this.max]:null}}class M extends O{constructor(m,r){super(),this.gradient="Sinebow",this.mult=1,this.min=m,this.max=r,typeof r>"u"&&Array.isArray(m)&&m.length>=2&&(this.max=m[1],this.min=m[0]),r<m&&(this.mult=-1,this.min*=-1,this.max*=-1)}valueToHex(m,r){var e,t;if(m=this.mult*m,r?(e=r[0],t=r[1]):(e=this.min,t=this.max),typeof m>"u")return 16777215;var s=_.normalizeValue(e,t,m);e=s.lo,t=s.hi,m=s.val;var o=(m-e)/(t-e),l=5*o/6+.5,d=Math.sin(Math.PI*l);d*=d*255;var i=Math.sin(Math.PI*(l+1/3));i*=i*255;var n=Math.sin(Math.PI*(l+2/3));return n*=n*255,65536*Math.floor(d)+256*Math.floor(n)+1*Math.floor(i)}range(){return typeof this.min<"u"&&typeof this.max<"u"?[this.min,this.max]:null}}class g extends O{constructor(m,r,e){super(),this.gradient="linear",this.colors=new Array;var t;if(Array.isArray(m)&&m.length>=2?(this.max=m[1],this.min=m[0],t=r):(this.min=m,this.max=r,t=e),t)for(let s of t)this.colors.push(b.CC.color(s));else this.colors.push(b.CC.color(0))}range(){return typeof this.min<"u"&&typeof this.max<"u"?[this.min,this.max]:null}valueToHex(m,r){var e,t;if(r?(e=r[0],t=r[1]):(e=this.min,t=this.max),m===void 0)return 16777215;var s=C(e,t,m);e=s.lo,t=s.hi,m=s.val;let o=this.colors.length,l=(t-e)/o,d=Math.min(Math.floor((m-e)/l),o-1),i=Math.min(d+1,o-1),n=(m-e-d*l)/l,a=this.colors[d],h=this.colors[i];return new b.Color(a.r+n*(h.r-a.r),a.g+n*(h.g-a.g),a.b+n*(h.b-a.b)).getHex()}}const x={rwb:v,RWB:v,roygb:y,ROYGB:y,sinebow:M,linear:g};class _ extends O{valueToHex(m,r){return 0}range(){return null}}_.RWB=v,_.ROYGB=y,_.Sinebow=M,_.CustomLinear=g,_.builtinGradients=x,_.normalizeValue=C,_.getGradient=R},"./src/Label.ts"(k,w,c){c.r(w),c.d(w,{Label:()=>M,LabelCount:()=>R});var b=c("./src/WebGL/index.ts"),O=c("./src/Gradient.ts"),C=c("./src/colors.ts");let R=0;function v(g,x,_,p,m,r,e){g.beginPath(),g.moveTo(x+r,_),g.lineTo(x+p-r,_),g.quadraticCurveTo(x+p,_,x+p,_+r),g.lineTo(x+p,_+m-r),g.quadraticCurveTo(x+p,_+m,x+p-r,_+m),g.lineTo(x+r,_+m),g.quadraticCurveTo(x,_+m,x,_+m-r),g.lineTo(x,_+r),g.quadraticCurveTo(x,_,x+r,_),g.closePath(),g.fill(),e&&g.stroke()}function y(g,x,_){var p=_;return typeof g<"u"&&(g instanceof C.Color?p=g.scaled():(p=C.CC.color(g),typeof p.scaled<"u"&&(p=p.scaled()))),typeof x<"u"&&(p.a=parseFloat(x)),p}class M{constructor(x,_){this.id=R++,this.stylespec=_||{},this.canvas=document.createElement("canvas"),this.canvas.width=134,this.canvas.height=35,this.context=this.canvas.getContext("2d"),this.sprite=new b.Sprite,this.text=x,this.frame=this.stylespec.frame}getStyle(){return this.stylespec}hide(){this.sprite&&(this.sprite.visible=!1)}show(){this.sprite&&(this.sprite.visible=!0)}setContext(){var x=this.stylespec,_=typeof x.useScreen>"u"?!1:x.useScreen,p=x.showBackground;(p==="0"||p==="false")&&(p=!1),typeof p>"u"&&(p=!0);var m=x.font?x.font:"sans-serif",r=parseInt(x.fontSize)?parseInt(x.fontSize):18,e=y(x.fontColor,x.fontOpacity,{r:255,g:255,b:255,a:1}),t=x.padding?x.padding:4,s=x.borderThickness?x.borderThickness:0,o=y(x.backgroundColor,x.backgroundOpacity,{r:0,g:0,b:0,a:1}),l=y(x.borderColor,x.borderOpacity,o),d=x.position?x.position:{x:-10,y:1,z:1},i=x.inFront!==void 0?x.inFront:!0;(i==="false"||i==="0")&&(i=!1);var n=x.alignment||b.SpriteAlignment.topLeft;typeof n=="string"&&n in b.SpriteAlignment&&(n=b.SpriteAlignment[n]);var a="";x.bold&&(a="bold "),this.context.font=a+r+"px "+m;var h=this.context.measureText(this.text),u=h.width;p||(s=0);var A=u+2.5*s+2*t,D=r*1.25+2*s+2*t;if(x.backgroundImage){var T=x.backgroundImage,S=x.backgroundWidth?x.backgroundWidth:T.width,P=x.backgroundHeight?x.backgroundHeight:T.height;S>A&&(A=S),P>D&&(D=P)}if(this.canvas.width=A,this.canvas.height=D,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),a="",x.bold&&(a="bold "),this.context.font=a+r+"px "+m,this.context.fillStyle="rgba("+o.r+","+o.g+","+o.b+","+o.a+")",this.context.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",x.backgroundGradient){let F=this.context.createLinearGradient(0,D/2,A,D/2),B=O.Gradient.getGradient(x.backgroundGradient),W=B.range(),U=-1,I=1;W&&(U=W[0],I=W[1]);let G=I-U;for(let Y=0;Y<1.01;Y+=.1){let J=y(B.valueToHex(U+G*Y)),te="rgba("+J.r+","+J.g+","+J.b+","+J.a+")";F.addColorStop(Y,te)}this.context.fillStyle=F}this.context.lineWidth=s,p&&v(this.context,s,s,A-2*s,D-2*s,6,s>0),x.backgroundImage&&this.context.drawImage(T,0,0,A,D),this.context.fillStyle="rgba("+e.r+","+e.g+","+e.b+","+e.a+")",this.context.fillText(this.text,s+t,r+s+t,u);var z=new b.Texture(this.canvas);z.needsUpdate=!0,this.sprite.material=new b.SpriteMaterial({map:z,useScreenCoordinates:_,alignment:n,depthTest:!i,screenOffset:x.screenOffset||null}),this.sprite.scale.set(1,1,1),this.sprite.position.set(d.x,d.y,d.z)}dispose(){this.sprite.material.map!==void 0&&this.sprite.material.map.dispose(),this.sprite.material!==void 0&&this.sprite.material.dispose()}}},"./src/ProteinSurface4.ts"(k,w,c){c.r(w),c.d(w,{MarchingCube:()=>y,MarchingCubeInitializer:()=>v,PointGrid:()=>M,ProteinSurface:()=>g,SurfaceType:()=>O,setSyncSurface:()=>R,syncSurface:()=>C});var b=c("./src/WebGL/math/index.ts"),O;(function(x){x[x.VDW=1]="VDW",x[x.MS=2]="MS",x[x.SAS=3]="SAS",x[x.SES=4]="SES"})(O||(O={}));var C=!1;function R(x){C=x}(window.navigator.userAgent.indexOf("MSIE ")>=0||window.navigator.userAgent.indexOf("Trident/")>=0)&&(C=!0);class v{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(_,p,m,r){let e=!!r.fulltable,t=r.hasOwnProperty("origin")&&r.origin.hasOwnProperty("x")?r.origin:{x:0,y:0,z:0},s=!!r.voxel,o=r.matrix,l=r.nX||0,d=r.nY||0,i=r.nZ||0,n=r.scale||1,a=null;r.unitCube?a=r.unitCube:a={x:n,y:n,z:n};let h=new Int32Array(l*d*i),u,A;for(u=0,A=h.length;u<A;++u)h[u]=-1;let D=function(z,F,B,W,U,I){let G={x:0,y:0,z:0},Y=!!(W&1<<U),J=!!(W&1<<I),te=U;if(!Y&&J&&(te=I),te&1&&B++,te&2&&F++,te&4&&z++,o){let le=new b.Vector3(z,F,B);le=le.applyMatrix4(o),G={x:le.x,y:le.y,z:le.z}}else G.x=t.x+a.x*z,G.y=t.y+a.y*F,G.z=t.z+a.z*B;let ne=(d*z+F)*i+B;return s?(p.push(G),p.length-1):(h[ne]<0&&(h[ne]=p.length,p.push(G)),h[ne])},T=new Int32Array(12),S=e?this.edgeTable2:this.edgeTable,P=e?this.triTable2:this.triTable;for(u=0;u<l-1;++u)for(let z=0;z<d-1;++z)for(let F=0;F<i-1;++F){let B=0;for(let I=0;I<8;++I){let G=(d*(u+((I&4)>>2))+z+((I&2)>>1))*i+F+(I&1),Y=!!(_[G]&this.ISDONE);B|=Y<<I}if(B===0||B===255)continue;let W=S[B];if(W===0)continue;let U=P[B];W&1&&(T[0]=D(u,z,F,B,0,1)),W&2&&(T[1]=D(u,z,F,B,1,3)),W&4&&(T[2]=D(u,z,F,B,3,2)),W&8&&(T[3]=D(u,z,F,B,2,0)),W&16&&(T[4]=D(u,z,F,B,4,5)),W&32&&(T[5]=D(u,z,F,B,5,7)),W&64&&(T[6]=D(u,z,F,B,7,6)),W&128&&(T[7]=D(u,z,F,B,6,4)),W&256&&(T[8]=D(u,z,F,B,0,4)),W&512&&(T[9]=D(u,z,F,B,1,5)),W&1024&&(T[10]=D(u,z,F,B,3,7)),W&2048&&(T[11]=D(u,z,F,B,2,6));for(let I=0;I<U.length;I+=3){let G=T[U[I]],Y=T[U[I+1]],J=T[U[I+2]];s&&I>=3&&(p.push(p[G]),G=p.length-1,p.push(p[Y]),Y=p.length-1,p.push(p[J]),J=p.length-1),m.push(G),m.push(Y),m.push(J)}}}laplacianSmooth(_,p,m){let r=new Array(p.length),e,t,s,o,l;for(e=0,t=p.length;e<t;e++)r[e]={x:0,y:0,z:0};let d=new Array(20),i;for(e=0;e<20;e++)d[e]=new Array(p.length);for(e=0,t=p.length;e<t;e++)d[0][e]=0;for(e=0,t=m.length/3;e<t;e++){let h=e*3,u=e*3+1,A=e*3+2;for(i=!0,s=0,o=d[0][m[h]];s<o;s++)if(m[u]==d[s+1][m[h]]){i=!1;break}for(i&&(d[0][m[h]]++,d[d[0][m[h]]][m[h]]=m[u]),i=!0,s=0,o=d[0][m[h]];s<o;s++)if(m[A]==d[s+1][m[h]]){i=!1;break}for(i&&(d[0][m[h]]++,d[d[0][m[h]]][m[h]]=m[A]),i=!0,s=0,o=d[0][m[u]];s<o;s++)if(m[h]==d[s+1][m[u]]){i=!1;break}for(i&&(d[0][m[u]]++,d[d[0][m[u]]][m[u]]=m[h]),i=!0,s=0,o=d[0][m[u]];s<o;s++)if(m[A]==d[s+1][m[u]]){i=!1;break}for(i&&(d[0][m[u]]++,d[d[0][m[u]]][m[u]]=m[A]),i=!0,s=0;s<d[0][m[A]];s++)if(m[h]==d[s+1][m[A]]){i=!1;break}for(i&&(d[0][m[A]]++,d[d[0][m[A]]][m[A]]=m[h]),i=!0,s=0,o=d[0][m[A]];s<o;s++)if(m[u]==d[s+1][m[A]]){i=!1;break}i&&(d[0][m[A]]++,d[d[0][m[A]]][m[A]]=m[u])}let n=1,a=.5;for(l=0;l<_;l++){for(e=0,t=p.length;e<t;e++)if(d[0][e]<3)r[e].x=p[e].x,r[e].y=p[e].y,r[e].z=p[e].z;else if(d[0][e]==3||d[0][e]==4){for(r[e].x=0,r[e].y=0,r[e].z=0,s=0,o=d[0][e];s<o;s++)r[e].x+=p[d[s+1][e]].x,r[e].y+=p[d[s+1][e]].y,r[e].z+=p[d[s+1][e]].z;r[e].x+=a*p[e].x,r[e].y+=a*p[e].y,r[e].z+=a*p[e].z,r[e].x/=a+d[0][e],r[e].y/=a+d[0][e],r[e].z/=a+d[0][e]}else{for(r[e].x=0,r[e].y=0,r[e].z=0,s=0,o=d[0][e];s<o;s++)r[e].x+=p[d[s+1][e]].x,r[e].y+=p[d[s+1][e]].y,r[e].z+=p[d[s+1][e]].z;r[e].x+=n*p[e].x,r[e].y+=n*p[e].y,r[e].z+=n*p[e].z,r[e].x/=n+d[0][e],r[e].y/=n+d[0][e],r[e].z/=n+d[0][e]}for(e=0,t=p.length;e<t;e++)p[e].x=r[e].x,p[e].y=r[e].y,p[e].z=r[e].z}}}let y=new v;class M{constructor(_,p,m){this.data=new Int32Array(_*p*m*3),this.width=p,this.height=m}set(_,p,m,r){let e=((_*this.width+p)*this.height+m)*3;this.data[e]=r.ix,this.data[e+1]=r.iy,this.data[e+2]=r.iz}get(_,p,m){let r=((_*this.width+p)*this.height+m)*3;return{ix:this.data[r],iy:this.data[r+1],iz:this.data[r+2]}}}class g{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])],g.MarchingCube||(g.MarchingCube=new v)}getVDWIndex(_){return!_.elem||typeof this.vdwRadii[_.elem]>"u"?"X":_.elem}getFacesAndVertices(_){let p={};for(let e=0,t=_.length;e<t;e++)p[_[e]]=!0;let m=this.verts;for(let e=0,t=m.length;e<t;e++)m[e].x=m[e].x/this.scaleFactor-this.ptranx,m[e].y=m[e].y/this.scaleFactor-this.ptrany,m[e].z=m[e].z/this.scaleFactor-this.ptranz;let r=[];for(let e=0,t=this.faces.length;e<t;e+=3){let s=this.faces[e],o=this.faces[e+1],l=this.faces[e+2],d=m[s].atomid,i=m[o].atomid,n=m[l].atomid,a=d;i<a&&(a=i),n<a&&(a=n),p[a]&&s!==o&&o!==l&&s!==l&&(r.push(s),r.push(o),r.push(l))}return this.vpBits=null,this.vpDistance=null,this.vpAtomID=null,{vertices:m,faces:r}}initparm(_,p,m){m>1e6&&(this.scaleFactor=this.defaultScaleFactor/2);let r=1/this.scaleFactor*5.5;this.pminx=_[0][0],this.pmaxx=_[1][0],this.pminy=_[0][1],this.pmaxy=_[1][1],this.pminz=_[0][2],this.pmaxz=_[1][2],p?(this.pminx-=this.probeRadius+r,this.pminy-=this.probeRadius+r,this.pminz-=this.probeRadius+r,this.pmaxx+=this.probeRadius+r,this.pmaxy+=this.probeRadius+r,this.pmaxz+=this.probeRadius+r):(this.pminx-=r,this.pminy-=r,this.pminz-=r,this.pmaxx+=r,this.pmaxy+=r,this.pmaxz+=r),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(p),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(_){let p={};for(const m in this.vdwRadii){let r=this.vdwRadii[m];_?p[m]=(r+this.probeRadius)*this.scaleFactor+.5:p[m]=r*this.scaleFactor+.5;let e=p[m]*p[m];this.widxz[m]=Math.floor(p[m])+1,this.depty[m]=new Int32Array(this.widxz[m]*this.widxz[m]);let t=0;for(let s=0;s<this.widxz[m];s++)for(let o=0;o<this.widxz[m];o++){let l=s*s+o*o;if(l>e)this.depty[m][t]=-1;else{let d=Math.sqrt(e-l);this.depty[m][t]=Math.floor(d)}t++}}}fillvoxels(_,p){for(let m=0,r=this.vpBits.length;m<r;m++)this.vpBits[m]=0,this.vpDistance[m]=-1,this.vpAtomID[m]=-1;for(let m in p){let r=_[p[m]];r!==void 0&&this.fillAtom(r,_)}for(let m=0,r=this.vpBits.length;m<r;m++)this.vpBits[m]&this.INOUT&&(this.vpBits[m]|=this.ISDONE)}fillAtom(_,p){let m=Math.floor(.5+this.scaleFactor*(_.x+this.ptranx)),r=Math.floor(.5+this.scaleFactor*(_.y+this.ptrany)),e=Math.floor(.5+this.scaleFactor*(_.z+this.ptranz)),t=this.getVDWIndex(_),s=0,o=this.pWidth*this.pHeight;for(let l=0,d=this.widxz[t];l<d;l++)for(let i=0;i<d;i++){if(this.depty[t][s]!=-1){for(let n=-1;n<2;n++)for(let a=-1;a<2;a++)for(let h=-1;h<2;h++)if(n!==0&&a!==0&&h!==0){let u=n*l,A=h*i;for(let D=0;D<=this.depty[t][s];D++){let T=D*a,S=m+u,P=r+T,z=e+A;if(S<0||P<0||z<0||S>=this.pLength||P>=this.pWidth||z>=this.pHeight)continue;let F=S*o+P*this.pHeight+z;if(!(this.vpBits[F]&this.INOUT))this.vpBits[F]|=this.INOUT,this.vpAtomID[F]=_.serial;else{let B=p[this.vpAtomID[F]];if(B.serial!=_.serial){let W=m+u-Math.floor(.5+this.scaleFactor*(B.x+this.ptranx)),U=r+T-Math.floor(.5+this.scaleFactor*(B.y+this.ptrany)),I=e+A-Math.floor(.5+this.scaleFactor*(B.z+this.ptranz));u*u+T*T+A*A<W*W+U*U+I*I&&(this.vpAtomID[F]=_.serial)}}}}}s++}}fillvoxelswaals(_,p){for(let m=0,r=this.vpBits.length;m<r;m++)this.vpBits[m]&=~this.ISDONE;for(let m in p){let r=_[p[m]];r!==void 0&&this.fillAtomWaals(r,_)}}fillAtomWaals(_,p){let m=0,r=Math.floor(.5+this.scaleFactor*(_.x+this.ptranx)),e=Math.floor(.5+this.scaleFactor*(_.y+this.ptrany)),t=Math.floor(.5+this.scaleFactor*(_.z+this.ptranz)),s=this.getVDWIndex(_),o=this.pWidth*this.pHeight;for(let l=0,d=this.widxz[s];l<d;l++)for(let i=0;i<d;i++){if(this.depty[s][m]!=-1){for(let n=-1;n<2;n++)for(let a=-1;a<2;a++)for(let h=-1;h<2;h++)if(n!==0&&a!==0&&h!==0){let u=n*l,A=h*i;for(let D=0;D<=this.depty[s][m];D++){let T=D*a,S=r+u,P=e+T,z=t+A;if(S<0||P<0||z<0||S>=this.pLength||P>=this.pWidth||z>=this.pHeight)continue;let F=S*o+P*this.pHeight+z;if(!(this.vpBits[F]&this.ISDONE))this.vpBits[F]|=this.ISDONE,this.vpAtomID[F]=_.serial;else{let B=p[this.vpAtomID[F]];if(B.serial!=_.serial){let W=r+u-Math.floor(.5+this.scaleFactor*(B.x+this.ptranx)),U=e+T-Math.floor(.5+this.scaleFactor*(B.y+this.ptrany)),I=t+A-Math.floor(.5+this.scaleFactor*(B.z+this.ptranz));u*u+T*T+A*A<W*W+U*U+I*I&&(this.vpAtomID[F]=_.serial)}}}}}m++}}buildboundary(){let _=this.pWidth*this.pHeight;for(let p=0;p<this.pLength;p++)for(let m=0;m<this.pHeight;m++)for(let r=0;r<this.pWidth;r++){let e=p*_+r*this.pHeight+m;if(this.vpBits[e]&this.INOUT){let t=0;for(;t<26;){let s=p+this.nb[t][0],o=m+this.nb[t][2],l=r+this.nb[t][1];if(s>-1&&s<this.pLength&&l>-1&&l<this.pWidth&&o>-1&&o<this.pHeight&&!(this.vpBits[s*_+l*this.pHeight+o]&this.INOUT)){this.vpBits[e]|=this.ISBOUND;break}else t++}}}}fastdistancemap(){let _=new M(this.pLength,this.pWidth,this.pHeight),p=this.pWidth*this.pHeight,m=this.cutRadius*this.cutRadius,r=[],e=[],t;for(let l=0;l<this.pLength;l++)for(let d=0;d<this.pWidth;d++)for(let i=0;i<this.pHeight;i++)if(t=l*p+d*this.pHeight+i,this.vpBits[t]&=~this.ISDONE,this.vpBits[t]&this.INOUT&&this.vpBits[t]&this.ISBOUND){let n={ix:l,iy:d,iz:i};_.set(l,d,i,n),r.push(n),this.vpDistance[t]=0,this.vpBits[t]|=this.ISDONE,this.vpBits[t]&=~this.ISBOUND}do{e=this.fastoneshell(r,_),r=[];for(let l=0,d=e.length;l<d;l++)t=p*e[l].ix+this.pHeight*e[l].iy+e[l].iz,this.vpBits[t]&=~this.ISBOUND,this.vpDistance[t]<=1.0404*m&&r.push({ix:e[l].ix,iy:e[l].iy,iz:e[l].iz})}while(r.length!==0);r=[],e=[],_=null;let s=this.scaleFactor-.5;s<0&&(s=0);let o=m-.5/(.1+s);for(let l=0;l<this.pLength;l++)for(let d=0;d<this.pWidth;d++)for(let i=0;i<this.pHeight;i++)t=l*p+d*this.pHeight+i,this.vpBits[t]&=~this.ISBOUND,this.vpBits[t]&this.INOUT&&(!(this.vpBits[t]&this.ISDONE)||this.vpBits[t]&this.ISDONE&&this.vpDistance[t]>=o)&&(this.vpBits[t]|=this.ISBOUND)}fastoneshell(_,p){let m,r,e,t,s,o,l,d,i,n=[];if(_.length===0)return n;let a={ix:-1,iy:-1,iz:-1},h=this.pWidth*this.pHeight;for(let u=0,A=_.length;u<A;u++){m=_[u].ix,r=_[u].iy,e=_[u].iz,d=p.get(m,r,e);for(let D=0;D<6;D++)a.ix=m+this.nb[D][0],a.iy=r+this.nb[D][1],a.iz=e+this.nb[D][2],a.ix<this.pLength&&a.ix>-1&&a.iy<this.pWidth&&a.iy>-1&&a.iz<this.pHeight&&a.iz>-1&&(i=a.ix*h+this.pHeight*a.iy+a.iz,this.vpBits[i]&this.INOUT&&!(this.vpBits[i]&this.ISDONE)?(p.set(a.ix,a.iy,e+this.nb[D][2],d),t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,this.vpDistance[i]=l,this.vpBits[i]|=this.ISDONE,this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})):this.vpBits[i]&this.INOUT&&this.vpBits[i]&this.ISDONE&&(t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,l<this.vpDistance[i]&&(p.set(a.ix,a.iy,a.iz,d),this.vpDistance[i]=l,this.vpBits[i]&this.ISBOUND||(this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})))))}for(let u=0,A=_.length;u<A;u++){m=_[u].ix,r=_[u].iy,e=_[u].iz,d=p.get(m,r,e);for(let D=6;D<18;D++)a.ix=m+this.nb[D][0],a.iy=r+this.nb[D][1],a.iz=e+this.nb[D][2],a.ix<this.pLength&&a.ix>-1&&a.iy<this.pWidth&&a.iy>-1&&a.iz<this.pHeight&&a.iz>-1&&(i=a.ix*h+this.pHeight*a.iy+a.iz,this.vpBits[i]&this.INOUT&&!(this.vpBits[i]&this.ISDONE)?(p.set(a.ix,a.iy,e+this.nb[D][2],d),t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,this.vpDistance[i]=l,this.vpBits[i]|=this.ISDONE,this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})):this.vpBits[i]&this.INOUT&&this.vpBits[i]&this.ISDONE&&(t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,l<this.vpDistance[i]&&(p.set(a.ix,a.iy,a.iz,d),this.vpDistance[i]=l,this.vpBits[i]&this.ISBOUND||(this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})))))}for(let u=0,A=_.length;u<A;u++){m=_[u].ix,r=_[u].iy,e=_[u].iz,d=p.get(m,r,e);for(let D=18;D<26;D++)a.ix=m+this.nb[D][0],a.iy=r+this.nb[D][1],a.iz=e+this.nb[D][2],a.ix<this.pLength&&a.ix>-1&&a.iy<this.pWidth&&a.iy>-1&&a.iz<this.pHeight&&a.iz>-1&&(i=a.ix*h+this.pHeight*a.iy+a.iz,this.vpBits[i]&this.INOUT&&!(this.vpBits[i]&this.ISDONE)?(p.set(a.ix,a.iy,e+this.nb[D][2],d),t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,this.vpDistance[i]=l,this.vpBits[i]|=this.ISDONE,this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})):this.vpBits[i]&this.INOUT&&this.vpBits[i]&this.ISDONE&&(t=a.ix-d.ix,s=a.iy-d.iy,o=a.iz-d.iz,l=t*t+s*s+o*o,l<this.vpDistance[i]&&(p.set(a.ix,a.iy,a.iz,d),this.vpDistance[i]=l,this.vpBits[i]&this.ISBOUND||(this.vpBits[i]|=this.ISBOUND,n.push({ix:a.ix,iy:a.iy,iz:a.iz})))))}return n}marchingcubeinit(_){for(let p=0,m=this.vpBits.length;p<m;p++)_==1?this.vpBits[p]&=~this.ISBOUND:_==4?(this.vpBits[p]&=~this.ISDONE,this.vpBits[p]&this.ISBOUND&&(this.vpBits[p]|=this.ISDONE),this.vpBits[p]&=~this.ISBOUND):_==2?this.vpBits[p]&this.ISBOUND&&this.vpBits[p]&this.ISDONE?this.vpBits[p]&=~this.ISBOUND:this.vpBits[p]&this.ISBOUND&&!(this.vpBits[p]&this.ISDONE)&&(this.vpBits[p]|=this.ISDONE):_==3&&(this.vpBits[p]&=~this.ISBOUND)}marchingcube(_){this.marchingcubeinit(_),this.verts=[],this.faces=[],g.MarchingCube.march(this.vpBits,this.verts,this.faces,{smooth:1,nX:this.pLength,nY:this.pWidth,nZ:this.pHeight});let p=this.pWidth*this.pHeight;for(let m=0,r=this.verts.length;m<r;m++)this.verts[m].atomid=this.vpAtomID[this.verts[m].x*p+this.pHeight*this.verts[m].y+this.verts[m].z];g.MarchingCube.laplacianSmooth(1,this.verts,this.faces)}}g.MarchingCube=new v},"./src/SurfaceWorker.js"(){$3Dmol.workerString=(function(){self.onmessage=function(k){var w=k.data,c=w.type;if(c<0)self.atomData=w.atoms,self.volume=w.volume,self.ps=new ProteinSurface;else{var b=self.ps;b.initparm(w.expandedExtent,c!=1,self.volume),b.fillvoxels(self.atomData,w.extendedAtoms),b.buildboundary(),(c===4||c===2)&&(b.fastdistancemap(),b.boundingatom(!1),b.fillvoxelswaals(self.atomData,w.extendedAtoms)),b.marchingcube(c);var O=b.getFacesAndVertices(w.atomsToShow);self.postMessage(O)}}}).toString().replace(/(^.*?\{|\}$)/g,""),$3Dmol.workerString+=`;
|
|
19
|
+
function _classCallCheck() {};`,$3Dmol.workerString+=`;
|
|
20
|
+
`+$3Dmol.Vector3.toString(),$3Dmol.workerString+=`;
|
|
21
|
+
`+$3Dmol.MarchingCubeInitializer.toString()+`;
|
|
22
|
+
|
|
23
|
+
`,$3Dmol.workerString+=`;
|
|
24
|
+
`+$3Dmol.PointGrid.toString()+`;
|
|
25
|
+
`,$3Dmol.workerString+=`;
|
|
26
|
+
var ProteinSurface = `+$3Dmol.ProteinSurface.toString()+`;
|
|
27
|
+
`,$3Dmol.SurfaceWorker=window.URL?window.URL.createObjectURL(new Blob([$3Dmol.workerString],{type:"text/javascript"})):void 0},"./src/VolumeData.ts"(k,w,c){c.r(w),c.d(w,{VolumeData:()=>y});var b=c("./src/utilities.ts"),O=c("./src/WebGL/math/index.ts"),C=c("./src/parsers/VASP.ts"),R=c("./src/parsers/CUBE.ts"),v=c("./node_modules/pako/dist/pako.esm.mjs");class y{constructor(g,x,_){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(t){var s=t/(this.size.y*this.size.z),o=t%(this.size.y*this.size.z),l=t%this.size.z;return s*=this.unit.x,o*=this.unit.y,l*=this.unit.z,s+=this.origin.x,o+=this.origin.y,l+=this.origin.z,{x:s,y:o,z:l}},this.vasp=function(t){var s=t.replace(/^\s+/,"").split(/[\n\r]/),o=(0,C.VASP)(t)[0],l=o.length;if(l==0){console.warn("No good formating of CHG or CHGCAR file, not atomic information provided in the file."),this.data=[];return}var d=1.889725992,i=.036749309,n=parseFloat(s[1]),a;a=s[2].replace(/^\s+/,"").split(/\s+/);var h=new O.Vector3(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2])).multiplyScalar(n*d);a=s[3].replace(/^\s+/,"").split(/\s+/);var u=new O.Vector3(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2])).multiplyScalar(n*d);a=s[4].replace(/^\s+/,"").split(/\s+/);var A=new O.Vector3(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2])).multiplyScalar(n*d),D=h.x*(u.y*A.z-A.y*u.z)-u.x*(h.y*A.z-A.y*h.z)+A.x*(h.y*u.z-u.y*h.z);D=Math.abs(D)/Math.pow(d,3);var T=1/D;s.splice(0,8+l+1);var S=s[0].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),P=Math.abs(parseFloat(S[0])),z=Math.abs(parseFloat(S[1])),F=Math.abs(parseFloat(S[2])),B=this.origin=new O.Vector3(0,0,0);this.size={x:P,y:z,z:F},this.unit=new O.Vector3(h.x,u.y,A.z),h=h.multiplyScalar(1/(d*P)),u=u.multiplyScalar(1/(d*z)),A=A.multiplyScalar(1/(d*F)),(h.y!=0||h.z!=0||u.x!=0||u.z!=0||A.x!=0||A.y!=0)&&(this.matrix=new O.Matrix4(h.x,u.x,A.x,0,h.y,u.y,A.y,0,h.z,u.z,A.z,0,0,0,0,1),this.matrix=this.matrix.multiplyMatrices(this.matrix,new O.Matrix4().makeTranslation(B.x,B.y,B.z)),this.origin=new O.Vector3(0,0,0),this.unit=new O.Vector3(1,1,1)),s.splice(0,1);var W=s.join(" ");W=W.replace(/^\s+/,"");var U=W.split(/[\s\r]+/);U.splice(P*z*F+1);for(var I=Float32Array.from(U,parseFloat),G=0;G<I.length;G++)I[G]=I[G]*T*i;this.data=I},this.dx=function(t){var s=t.split(/[\n\r]+/),o,l=/gridpositions\s+counts\s+(\d+)\s+(\d+)\s+(\d+)/,d=/^origin\s+(\S+)\s+(\S+)\s+(\S+)/,i=/^delta\s+(\S+)\s+(\S+)\s+(\S+)/,n=/data follows/,a=0;for(a=0;a<s.length;a++){var h=s[a];if(o=l.exec(h)){var u=parseInt(o[1]),A=parseInt(o[2]),D=parseInt(o[3]);this.size={x:u,y:A,z:D}}else if(o=i.exec(h)){var T=parseFloat(o[1]);if((parseFloat(o[2])!=0||parseFloat(o[3])!=0)&&console.warn("Non-orthogonal delta matrix not currently supported in dx format"),a+=1,h=s[a],o=i.exec(h),o==null){console.error("Parse error in dx delta matrix");return}var S=parseFloat(o[2]);if((parseFloat(o[1])!=0||parseFloat(o[3])!=0)&&console.warn("Non-orthogonal delta matrix not currently supported in dx format"),a+=1,h=s[a],o=i.exec(h),o==null){console.error("Parse error in dx delta matrix");return}var P=parseFloat(o[3]);(parseFloat(o[1])!=0||parseFloat(o[2])!=0)&&console.warn("Non-orthogonal delta matrix not currently supported in dx format"),this.unit=new O.Vector3(T,S,P)}else if(o=d.exec(h)){var z=parseFloat(o[1]),F=parseFloat(o[2]),B=parseFloat(o[3]);this.origin=new O.Vector3(z,F,B)}else if(o=n.exec(h))break}if(a+=1,!this.size||!this.origin||!this.unit||!this.size){console.error("Error parsing dx format");return}var W=s.splice(a).join(" "),U=W.split(/[\s\r]+/);this.data=Float32Array.from(U,parseFloat)},x=x.toLowerCase(),/\.gz$/.test(x)){x=x.replace(/\.gz$/,"");try{this[x]&&this.isbinary.has(x)?(typeof g=="string"&&(g=(0,b.base64ToArray)(g)),g=(0,v.inflate)(g)):g=new TextDecoder("utf-8").decode((0,v.inflate)(g))}catch(t){console.error(t)}}if(this[x]&&(this.isbinary.has(x)&&typeof g=="string"&&(g=(0,b.base64ToArray)(g)),this[x](g)),_){if(_.negate)for(let t=0,s=this.data.length;t<s;t++)this.data[t]=-this.data[t];if(_.normalize){var p=0;for(let t=0,s=this.data.length;t<s;t++)p+=this.data[t];var m=p/this.data.length;p=0;for(let t=0,s=this.data.length;t<s;t++){var r=this.data[t]-m;p+=r*r}var e=p/this.data.length;for(let t=0,s=this.data.length;t<s;t++)this.data[t]=(this.data[t]-m)/e}}}getIndex(g,x,_){if(this.matrix){this.inversematrix==null&&(this.inversematrix=new O.Matrix4().getInverse(this.matrix));var p=new O.Vector3(g,x,_);p=p.applyMatrix4(this.inversematrix),g=p.x,x=p.y,_=p.z}else g-=this.origin.x,x-=this.origin.y,_-=this.origin.z,g/=this.unit.x,x/=this.unit.y,_/=this.unit.z;return g=Math.round(g),x=Math.round(x),_=Math.round(_),g<0||g>=this.size.x||x<0||x>=this.size.y||_<0||_>=this.size.z?-1:g*this.size.y*this.size.z+x*this.size.z+_}getVal(g,x,_){let p=this.getIndex(g,x,_);return p<0?0:this.data[p]}cube(g){var x=g.split(/\r?\n/);if(!(x.length<6)){var _=(0,R.CUBE)(g,{}).modelData[0].cryst,p=x[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),m=parseFloat(p[0]),r=Math.abs(m);this.origin=_.origin,this.size=_.size,this.unit=_.unit,this.matrix=_.matrix4;var e=6;m<0&&e++;var t=x.splice(r+e).join(" ");t=t.replace(/^\s+/,"");var s=t.split(/[\s\r]+/);this.data=Float32Array.from(s,parseFloat)}}ccp4(g){var x={};g=new Int8Array(g);var _=new Int32Array(g.buffer,0,56),p=new Float32Array(g.buffer,0,56),m=new DataView(g.buffer);if(x.MAP=String.fromCharCode(m.getUint8(208),m.getUint8(209),m.getUint8(210),m.getUint8(211)),x.MACHST=[m.getUint8(212),m.getUint8(213)],x.MACHST[0]===17&&x.MACHST[1]===17)for(var r=g.byteLength,e=0;e<r;e+=4)m.setFloat32(e,m.getFloat32(e),!0);x.NX=_[0],x.NY=_[1],x.NZ=_[2],x.MODE=_[3],x.NXSTART=_[4],x.NYSTART=_[5],x.NZSTART=_[6],x.MX=_[7],x.MY=_[8],x.MZ=_[9],x.xlen=p[10],x.ylen=p[11],x.zlen=p[12],x.alpha=p[13],x.beta=p[14],x.gamma=p[15],x.MAPC=_[16],x.MAPR=_[17],x.MAPS=_[18],x.DMIN=p[19],x.DMAX=p[20],x.DMEAN=p[21],x.ISPG=_[22],x.NSYMBT=_[23],x.LSKFLG=_[24],x.originX=p[49],x.originY=p[50],x.originZ=p[51],x.ARMS=p[54];var t=x,s=[t.xlen,0,0],o=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],l=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];l[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-l[1]*l[1]);var d=[0,s,o,l],i=[0,t.MX,t.MY,t.MZ],n=[0,t.MAPC,t.MAPR,t.MAPS];this.matrix=new O.Matrix4,this.matrix.set(d[n[1]][0]/i[n[1]],d[n[2]][0]/i[n[2]],d[n[3]][0]/i[n[3]],0,d[n[1]][1]/i[n[1]],d[n[2]][1]/i[n[2]],d[n[3]][1]/i[n[3]],0,d[n[1]][2]/i[n[1]],d[n[2]][2]/i[n[2]],d[n[3]][2]/i[n[3]],0,0,0,0,1),this.matrix=this.matrix.multiplyMatrices(this.matrix,new O.Matrix4().makeTranslation(t.NXSTART+t.originX,t.NYSTART+t.originY,t.NZSTART+t.originZ)),this.origin=new O.Vector3(0,0,0),this.unit=new O.Vector3(1,1,1),this.size={x:x.NX,y:x.NY,z:x.NZ},this.dimensionorder=[x.MAPC,x.MAPR,x.MAPS];var a=new Float32Array(g.buffer,1024+x.NSYMBT),h=x.NX,u=x.NY,A=x.NZ;this.data=new Float32Array(h*u*A);for(let D=0;D<h;D++)for(let T=0;T<u;T++)for(let S=0;S<A;S++)this.data[(D*u+T)*A+S]=a[(S*u+T)*h+D]}}},"./src/VolumetricRender.ts"(k,w,c){c.r(w),c.d(w,{GLVolumetricRender:()=>y});var b=c("./src/WebGL/shapes/index.ts"),O=c("./src/WebGL/math/index.ts"),C=c("./src/WebGL/index.ts"),R=c("./src/colors.ts"),v=c("./src/GLShape.ts");class y{static interpolateArray(g,x){function _(l,d,i){return l+(d-l)*i}var p=[],m=(g.length-1)/(x-1);p[0]=g[0];for(var r=1;r<x-1;r++){var e=r*m,t=Math.floor(e),s=Math.ceil(e),o=e-t;p[r]=_(g[t],g[s],o)}return p[x-1]=g[g.length-1],p}constructor(g,x,_){this.hidden=!1,this.boundingSphere=new b.Sphere,this.renderedShapeObj=null,this.shapeObj=null,this.subsamples=5,this.data=null,this.transferfunctionbuffer=[],this.min=0,this.max=0,x=x||{};var p=Object.assign([],x.transferfn);this.subsamples=x.subsamples||5;let m=256;p.forEach(function(u){u.value=parseFloat(u.value)}),p.sort(function(u,A){return u.value-A.value}),this.min=p[0].value,p.length==0&&p.push(p[0]),this.max=p[p.length-1].value;var r,e,t,s,o,l,d,i,n,a;for(let u=0;u<p.length-1;u++)if(t=R.CC.color(p[u].color),s=R.CC.color(p[u+1].color),n=p[u].opacity,a=p[u+1].opacity,r=Math.floor((p[u].value-this.min)*m/(this.max-this.min)),e=Math.floor((p[u+1].value-this.min)*m/(this.max-this.min)),r!=e){o=y.interpolateArray([t.r*255,s.r*255],e-r),l=y.interpolateArray([t.g*255,s.g*255],e-r),d=y.interpolateArray([t.b*255,s.b*255],e-r),i=y.interpolateArray([n*255,a*255],e-r);for(let A=0;A<o.length;A++)this.transferfunctionbuffer.push(o[A]),this.transferfunctionbuffer.push(l[A]),this.transferfunctionbuffer.push(d[A]),this.transferfunctionbuffer.push(i[A])}if(this.transferfunctionbuffer=new Uint8ClampedArray(this.transferfunctionbuffer),g.matrix){let u=new O.Vector3(0,0,0),A=new O.Vector3(g.size.x,g.size.y,g.size.z),D=new O.Vector3(1,1,1);u.applyMatrix4(g.matrix),A.applyMatrix4(g.matrix),D.applyMatrix4(g.matrix).sub(u),this.extent=[[u.x,u.y,u.z],[A.x,A.y,A.z]];for(let z=1;z<7;z++)A.x=z&1?g.size.x:0,A.y=z&2?g.size.y:0,A.z=z&4?g.size.z:0,A.applyMatrix4(g.matrix),this.extent[0][0]=Math.min(this.extent[0][0],A.x),this.extent[0][1]=Math.min(this.extent[0][1],A.y),this.extent[0][2]=Math.min(this.extent[0][2],A.z),this.extent[1][0]=Math.max(this.extent[1][0],A.x),this.extent[1][1]=Math.max(this.extent[1][1],A.y),this.extent[1][2]=Math.max(this.extent[1][2],A.z);let T=A.x-u.x,S=A.y-u.y,P=A.z-u.z;this.maxdepth=Math.sqrt(T*T+S*S+P*P),this.minunit=Math.min(Math.min(D.x,D.y),D.z),this.texmatrix=new O.Matrix4().identity().scale({x:g.size.x,y:g.size.y,z:g.size.z}),this.texmatrix=this.texmatrix.multiplyMatrices(g.matrix,this.texmatrix),this.texmatrix=this.texmatrix.getInverse(this.texmatrix)}else{this.texmatrix=new O.Matrix4().identity();let u=g.unit.x*g.size.x,A=g.unit.y*g.size.y,D=g.unit.z*g.size.z;this.texmatrix.makeTranslation(-g.origin.x/u,-g.origin.y/A,-g.origin.z/D),this.texmatrix.scale({x:1/u,y:1/A,z:1/D}),this.minunit=Math.min(Math.min(g.unit.x,g.unit.y),g.unit.z),this.extent=[[g.origin.x,g.origin.y,g.origin.z],[g.origin.x+u,g.origin.y+A,g.origin.z+D]],this.maxdepth=Math.sqrt(u*u+A*A+D*D)}var h=new v.GLShape({});if(h.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=h.finalize(),this.boundingSphere.center=new O.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,x.coords===void 0&&x.selection!==void 0&&(_?x.coords=_.selectedAtoms(x.selection):console.log("Need to provide viewer to volumetric renderer if selection specified.")),x.coords!==void 0&&x.seldist!==void 0){let u=new Uint8Array(g.data.length),A=x.seldist,D=A*A;for(let T=0,S=x.coords.length;T<S;T++){let P=x.coords[T],z=P.x-A,F=P.y-A,B=P.z-A,W=P.x+A,U=P.y+A,I=P.z+A;if(g.getIndex(z,F,B)>=0||g.getIndex(W,U,I)>=0)for(let G=z;G<W;G+=this.minunit)for(let Y=F;Y<U;Y+=this.minunit)for(let J=B;J<I;J+=this.minunit){let te=g.getIndex(G,Y,J);te>=0&&!u[te]&&(G-P.x)*(G-P.x)+(Y-P.y)*(Y-P.y)+(J-P.z)*(J-P.z)<D&&(u[te]=1)}}for(let T=0,S=g.data.length;T<S;T++)u[T]==0&&(g.data[T]=1/0)}this.data=g}globj(g){if(this.renderedShapeObj&&(g.remove(this.renderedShapeObj),this.renderedShapeObj=null),!this.hidden){this.shapeObj=new C.Object3D;var x=null,_=new C.Texture(this.data,!0),p=new C.Texture(this.transferfunctionbuffer,!1);_.needsUpdate=!0,p.needsUpdate=!0,p.flipY=!1,x=new C.VolumetricMaterial({transferfn:p,transfermin:this.min,transfermax:this.max,map:_,extent:this.extent,maxdepth:this.maxdepth,texmatrix:this.texmatrix,unit:this.minunit,subsamples:this.subsamples});var m=new C.Mesh(this.geo,x);this.shapeObj.add(m),this.renderedShapeObj=this.shapeObj.clone(),g.add(this.renderedShapeObj)}}removegl(g){this.renderedShapeObj&&(this.renderedShapeObj.geometry!==void 0&&this.renderedShapeObj.geometry.dispose(),this.renderedShapeObj.material!==void 0&&this.renderedShapeObj.material.dispose(),g.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}}},"./src/WebGL/Camera.ts"(k,w,c){c.r(w),c.d(w,{Camera:()=>C});var b=c("./src/WebGL/core/index.ts"),O=c("./src/WebGL/math/index.ts");class C extends b.Object3D{constructor(v=50,y=1,M=.1,g=2e3,x=!1){super(),this.projectionMatrix=new O.Matrix4,this.projectionMatrixInverse=new O.Matrix4,this.matrixWorldInverse=new O.Matrix4,this.fov=v,this.aspect=y,this.near=M,this.far=g;var _=this.position.z;this.right=_*Math.tan(Math.PI/180*v),this.left=-this.right,this.top=this.right/this.aspect,this.bottom=-this.top,this.ortho=!!x,this.updateProjectionMatrix()}lookAt(v){this.matrix.lookAt(this.position,v,this.up),this.rotationAutoUpdate&&(this.useQuaternion===!1&&this.rotation instanceof O.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)}}},"./src/WebGL/Fog.ts"(k,w,c){c.r(w),c.d(w,{Fog:()=>O});var b=c("./src/colors.ts");class O{constructor(R,v=1,y=1e3){this.name="",this.color=new b.Color(R),this.near=v,this.far=y}clone(){return new O(this.color.getHex(),this.near,this.far)}}},"./src/WebGL/Renderer.ts"(k,w,c){c.r(w),c.d(w,{Renderer:()=>r});var b=c("./src/WebGL/Camera.ts"),O=c("./src/WebGL/constants/Sides.ts"),C=c("./src/WebGL/constants/TextureConstants.ts"),R=c("./src/WebGL/core/index.ts"),v=c("./src/colors.ts"),y=c("./src/WebGL/materials/index.ts"),M=c("./src/WebGL/math/index.ts"),g=c("./src/WebGL/objects/index.ts"),x=c("./src/WebGL/shaders/index.ts"),_=c("./src/WebGL/SpritePlugin.ts"),p=null,m=null;class r{constructor(t){this.context=null,this.devicePixelRatio=1,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._offscreen=null,this._bitmap=null,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._vector3=new M.Vector3,this._worldInverse=new M.Matrix4,this._projInverse=new M.Matrix4,this._textureMatrix=new M.Matrix4,this._fullProjModelMatrix=new M.Matrix4,this._fullProjModelMatrixInv=new M.Matrix4,this._direction=new M.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._AOshader=null,this._blurshader=null,this._vertexattribpos=null,this._aovertexattribpos=null,this._blurvertexattribpos=null,this._screenQuadVBO=null,this._fb=null,this._targetTexture=null,this._depthTexture=null,this._shadingTexture=null,this._scratchTexture=null,this._upscale=null,this._AOstrength=1,this._AOradius=5,this.SHADE_TEXTURE=3,t=t||{},this.row=t.row,this.col=t.col,this.rows=t.rows,this.cols=t.cols,this._canvas=t.canvas!==void 0?t.canvas:document.createElement("canvas"),this._precision=t.precision!==void 0?t.precision:"highp",this._alpha=t.alpha!==void 0?t.alpha:!0,this._premultipliedAlpha=t.premultipliedAlpha!==void 0?t.premultipliedAlpha:!0,this._antialias=t.antialias!==void 0?t.antialias:!1,this._upscale=t.upscale!==void 0?t.upscale:this._antialias,this._preserveDrawingBuffer=t.preserveDrawingBuffer!==void 0?t.preserveDrawingBuffer:!1,this._clearColor=t.clearColor!==void 0?new v.Color(t.clearColor):new v.Color(0),this._clearAlpha=t.clearAlpha!==void 0?t.clearAlpha:0,this._outlineMaterial=new y.MeshOutlineMaterial(t.outline),this._outlineSphereImposterMaterial=new y.SphereImposterOutlineMaterial(t.outline),this._outlineStickImposterMaterial=new y.StickImposterOutlineMaterial(t.outline),this._outlineEnabled=!!t.outline,this._AOEnabled=!!t.ambientOcclusion,t.ambientOcclusion&&typeof t.ambientOcclusion.strength<"u"&&(this._AOstrength=parseFloat(t.ambientOcclusion.strength)),this._AOstrength==0&&(this._AOEnabled=!1),t.ambientOcclusion&&typeof t.ambientOcclusion.radius<"u"&&(this._AOradius=parseFloat(t.ambientOcclusion.radius)),this.domElement=this._canvas,this._canvas.id=t.id,!(t.containerWidth==0||t.containerHeight==0)&&(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:!!this._extInstanced,supportsImposters:!!this._extFragDepth||!this.isWebGL1(),regen:!1}}getContext(){return this._gl}getCanvas(){return this._canvas}isLost(){return this._gl==null||this._gl.isContextLost()}getPrecision(){return this._precision}setClearColorHex(t,s){this._clearColor.setHex(t),this._clearAlpha=s,this.isLost()||this._gl.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha)}enableOutline(t){this._outlineMaterial=new y.MeshOutlineMaterial(t),this._outlineSphereImposterMaterial=new y.SphereImposterOutlineMaterial(t),this._outlineStickImposterMaterial=new y.StickImposterOutlineMaterial(t),this._outlineEnabled=!0}disableOutline(){this._outlineEnabled=!1}enableAmbientOcclusion(t){t&&(t.strength&&(this._AOstrength=t.strength),t.scale&&(this._AOradius=t.scale)),this._AOEnabled=this._AOstrength>0}disableAmbientOcclusion(){this._AOEnabled=!1}setViewport(){if(this._offscreen&&(this._offscreen.width=this._canvas.width,this._offscreen.height=this._canvas.height),this.rows!=null&&this.cols!=null&&this.row!=null&&this.col!=null&&!this.isLost()){var t=this._gl.drawingBufferWidth/this.cols,s=this._gl.drawingBufferHeight/this.rows;this._viewportWidth=t,this._viewportHeight=s,this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(t*this.col,s*this.row,t,s),this._gl.viewport(t*this.col,s*this.row,t,s)}}setSize(t,s){this.devicePixelRatio=window.devicePixelRatio!==void 0?window.devicePixelRatio:1,this._upscale&&this.devicePixelRatio<2&&(this.devicePixelRatio=2),this._canvas.width=t*this.devicePixelRatio,this._canvas.height=s*this.devicePixelRatio,this._canvas.style.width=t+"px",this._canvas.style.height=s+"px",this.rows!=null&&this.cols!=null&&this.row!=null&&this.col!=null?(this.isLost()||(this._viewportWidth=this._gl.drawingBufferWidth/this.cols,this._viewportHeight=this._gl.drawingBufferHeight/this.rows),this.setViewport()):(this._viewportWidth=this._canvas.width,this._viewportHeight=this._canvas.height,this.isLost()||this._gl.viewport(0,0,this._gl.drawingBufferWidth,this._gl.drawingBufferHeight)),this.initFrameBuffer()}clear(t,s,o){var l=0;(t===void 0||t)&&(l|=this._gl.COLOR_BUFFER_BIT),(s===void 0||s)&&(l|=this._gl.DEPTH_BUFFER_BIT),(o===void 0||o)&&(l|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(l)}setMaterialFaces(t,s){var o=t.side===O.DoubleSide,l=t.side===O.BackSide;t.imposter||(l=s?!l:l),this._oldDoubleSided!==o&&(o?this._gl.disable(this._gl.CULL_FACE):this._gl.enable(this._gl.CULL_FACE),this._oldDoubleSided=o),this._oldFlipSided!==l&&(l?this._gl.frontFace(this._gl.CW):this._gl.frontFace(this._gl.CCW),this._oldFlipSided=l),this._gl.cullFace(this._gl.BACK)}setDepthTest(t){this._oldDepthTest!==t&&(t?this._gl.enable(this._gl.DEPTH_TEST):this._gl.disable(this._gl.DEPTH_TEST),this._oldDepthTest=t)}setDepthWrite(t){this._oldDepthWrite!==t&&(this._gl.depthMask(t),this._oldDepthWrite=t)}setBlending(t){t?(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(t,s,o,l){t.addEventListener("dispose",this.onMaterialDispose.bind(this));var d,i;if(i=t.shaderID,i){var n=x.ShaderLib[i];t.vertexShader=n.vertexShader,t.fragmentShader=n.fragmentShader,t.uniforms=x.ShaderUtils.clone(n.uniforms),t.shaded&&t.makeShaded(this.SHADE_TEXTURE)}d={wireframe:t.wireframe,fragdepth:t.imposter,volumetric:t.volumetric,shaded:t.shaded},t.program=this.buildProgram(t.fragmentShader,t.vertexShader,t.uniforms,d)}renderBuffer(t,s,o,l,d,i){if(l.visible){var n,a;if(n=this.setProgram(t,s,o,l,i,this),!!n){a=n.attributes;var h=!1,u=l.wireframe?1:0,A=d.id*16777215+n.id*2+u;A!==this._currentGeometryGroupHash&&(this._currentGeometryGroupHash=A,h=!0),h&&(this.disableAttributes(),a.position>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglVertexBuffer),this.enableAttribute(a.position),this._gl.vertexAttribPointer(a.position,3,this._gl.FLOAT,!1,0,0)),a.color>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglColorBuffer),this.enableAttribute(a.color),this._gl.vertexAttribPointer(a.color,3,this._gl.FLOAT,!1,0,0)),a.normal>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglNormalBuffer),this.enableAttribute(a.normal),this._gl.vertexAttribPointer(a.normal,3,this._gl.FLOAT,!1,0,0)),a.offset>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglOffsetBuffer),this.enableAttribute(a.offset),this._gl.vertexAttribPointer(a.offset,3,this._gl.FLOAT,!1,0,0)),a.radius>=0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglRadiusBuffer),this.enableAttribute(a.radius),this._gl.vertexAttribPointer(a.radius,1,this._gl.FLOAT,!1,0,0)));var D,T;if(i instanceof g.Mesh){if(l.shaderID==="instanced"){var S=l.sphere.geometryGroups[0];h&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,S.vertexArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,d.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,S.normalArray,this._gl.STATIC_DRAW),this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,d.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,S.faceArray,this._gl.STATIC_DRAW)),D=S.faceidx,this._extInstanced.vertexAttribDivisorANGLE(a.offset,1),this._extInstanced.vertexAttribDivisorANGLE(a.radius,1),this._extInstanced.vertexAttribDivisorANGLE(a.color,1),this._extInstanced.drawElementsInstancedANGLE(this._gl.TRIANGLES,D,this._gl.UNSIGNED_SHORT,0,d.radiusArray.length),this._extInstanced.vertexAttribDivisorANGLE(a.offset,0),this._extInstanced.vertexAttribDivisorANGLE(a.radius,0),this._extInstanced.vertexAttribDivisorANGLE(a.color,0)}else l.wireframe?(T=d.lineidx,this.setLineWidth(l.wireframeLinewidth),h&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,d.__webglLineBuffer),this._gl.drawElements(this._gl.LINES,T,this._gl.UNSIGNED_SHORT,0)):(D=d.faceidx,h&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,d.__webglFaceBuffer),this._gl.drawElements(this._gl.TRIANGLES,D,this._gl.UNSIGNED_SHORT,0));this.info.render.calls++,this.info.render.vertices+=D,this.info.render.faces+=D/3}else i instanceof g.Line&&(T=d.vertices,this.setLineWidth(l.linewidth),this._gl.drawArrays(this._gl.LINES,0,T),this.info.render.calls++)}}}clearShading(){this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._shadingTexture,0),this.clear(!1,!0,!1),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._depthTexture,0)}setShading(t,s,o){let l=t.__lights,d=t.fog,i=[];for(let h=0,u=t.__webglObjects.length;h<u;h++){let A=t.__webglObjects[h];A.render&&A[o]&&i.push(A)}if(i.length==0)return;this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._shadingTexture,0),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.COLOR_ATTACHMENT0,this._gl.TEXTURE_2D,null,0),this.renderObjects(t.__webglObjects,!0,o+"Depth",s,l,d,!1),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._scratchTexture,0),this.clear(!1,!0,!1),this._gl.useProgram(this._AOshader),this._currentProgram=this._AOshader,this.setDepthTest(-1),this.setDepthWrite(-1);let n=this._AOshader.uniforms;this._gl.uniform1f(n.total_strength,this._AOstrength),this._gl.uniform1f(n.radius,this._AOradius),this._fullProjModelMatrix=new M.Matrix4,this._fullProjModelMatrixInv=new M.Matrix4;let a=i[0].object;this._fullProjModelMatrix.multiplyMatrices(s.projectionMatrix,a._modelViewMatrix),this._fullProjModelMatrixInv.getInverse(this._fullProjModelMatrix),this._gl.uniformMatrix4fv(n.projectionMatrix,!1,this._fullProjModelMatrix.elements),this._gl.uniformMatrix4fv(n.projinv,!1,this._fullProjModelMatrixInv.elements),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,this._screenQuadVBO),this._gl.enableVertexAttribArray(this._aovertexattribpos),this._gl.vertexAttribPointer(this._aovertexattribpos,2,this._gl.FLOAT,!1,0,0),this._gl.activeTexture(this._gl.TEXTURE0),this._gl.bindTexture(this._gl.TEXTURE_2D,this._shadingTexture),this._gl.drawArrays(this._gl.TRIANGLES,0,6),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._shadingTexture,0),this.clear(!1,!0,!1),this._gl.useProgram(this._blurshader),this._currentProgram=this._blurshader,this.setDepthTest(-1),this.setDepthWrite(-1),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,this._screenQuadVBO),this._gl.enableVertexAttribArray(this._blurvertexattribpos),this._gl.vertexAttribPointer(this._blurvertexattribpos,2,this._gl.FLOAT,!1,0,0),this._gl.activeTexture(this._gl.TEXTURE0),this._gl.bindTexture(this._gl.TEXTURE_2D,this._scratchTexture),this._gl.drawArrays(this._gl.TRIANGLES,0,6),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)}render(t,s){if(!(s instanceof b.Camera)){console.error("Renderer.render: camera is not an instance of Camera.");return}var o,l,d,i,n,a=t.__lights,h=t.fog;if(this._currentMaterialId=-1,this._lightsNeedUpdate=!0,this.autoUpdateScene&&t.updateMatrixWorld(),s.parent===void 0&&s.updateMatrixWorld(),s.matrixWorldInverse.getInverse(s.matrixWorld),this.isLost())return;this.autoUpdateObjects&&this.initWebGLObjects(t),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._gl.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha),this.clear(!0,!0,!0),n=t.__webglObjects;let u=!1,A=this._AOEnabled;for(o=0,l=n.length;o<l;o++)d=n[o],i=d.object,d.render=!1,i.visible&&(this.setupMatrices(i,s),this.unrollBufferMaterial(d),d.render=!0,d.volumetric&&(u=!0),d.hasAO&&(A=!0));if(this.setBlending(!1),A&&this.setShading(t,s,"opaque"),this.renderObjects(t.__webglObjects,!0,"opaque",s,a,h,!1),A&&this.clearShading(),this.renderSprites(t,s,!1),this.renderObjects(t.__webglObjects,!0,"transparentDepth",s,a,h,!0),this.renderObjects(t.__webglObjects,!1,"transparent",s,a,h,!0),u&&this._fb&&(this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,null,0),this.renderObjects(t.__webglObjects,!1,"volumetric",s,a,h,!0)),this.renderFrameBuffertoScreen(),this.setDepthTest(!0),this.setDepthWrite(!0),this.renderSprites(t,s,!0),this._bitmap){const D=this._offscreen.transferToImageBitmap();this._bitmap.transferFromImageBitmap(D),D.close()}}setFrameBuffer(){if(this.isWebGL1()||!this._fb)return;let t=this._viewportWidth,s=this._viewportHeight;this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(0,0,t,s),this._gl.viewport(0,0,t,s),this._gl.bindTexture(this._gl.TEXTURE_2D,this._targetTexture),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,t,s,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,t,s,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._shadingTexture&&(this._gl.deleteTexture(this._shadingTexture),this._shadingTexture=this._gl.createTexture(),this._gl.bindTexture(this._gl.TEXTURE_2D,this._shadingTexture),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.DEPTH_COMPONENT32F,t,s,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.deleteTexture(this._scratchTexture),this._scratchTexture=this._gl.createTexture(),this._gl.bindTexture(this._gl.TEXTURE_2D,this._scratchTexture),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.DEPTH_COMPONENT32F,t,s,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._shadingTexture,0),this._gl.clearDepth(1),this._gl.clear(this._gl.DEPTH_BUFFER_BIT),this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER,this._gl.DEPTH_ATTACHMENT,this._gl.TEXTURE_2D,this._depthTexture,0)}initFrameBuffer(){if(this.isWebGL1())return;let t=this._viewportWidth,s=this._viewportHeight;this._gl.enable(this._gl.SCISSOR_TEST),this._gl.scissor(0,0,t,s),this._gl.viewport(0,0,t,s),this._targetTexture=this._gl.createTexture(),this._depthTexture=this._gl.createTexture(),this._shadingTexture=this._gl.createTexture(),this._scratchTexture=this._gl.createTexture(),this._fb=this._gl.createFramebuffer();var o=this._antialias?x.ShaderLib.screenaa:x.ShaderLib.screen;this._screenshader=this.buildProgram(o.fragmentShader,o.vertexShader,o.uniforms,{}),this._vertexattribpos=this._gl.getAttribLocation(this._screenshader,"vertexPosition");var l=[1,1,-1,1,-1,-1,-1,-1,1,-1,1,1];this._screenQuadVBO=this._gl.createBuffer(),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,this._screenQuadVBO),this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(l),this._gl.STATIC_DRAW);let d=x.ShaderLib.ssao;this._AOshader=this.buildProgram(d.fragmentShader,d.vertexShader,d.uniforms,{}),this._aovertexattribpos=this._gl.getAttribLocation(this._AOshader,"vertexPosition");let i=x.ShaderLib.blur;this._blurshader=this.buildProgram(i.fragmentShader,i.vertexShader,i.uniforms,{}),this._blurvertexattribpos=this._gl.getAttribLocation(this._blurshader,"vertexPosition")}renderFrameBuffertoScreen(){this.isWebGL1()||this._fb===null||(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(t){if(t.__webglObjects||(t.__webglObjects=[],t.__webglObjectsImmediate=[],t.__webglSprites=[],t.__webglFlares=[]),t.__objectsAdded.length){for(;t.__objectsAdded.length;)this.addObject(t.__objectsAdded[0],t),t.__objectsAdded.splice(0,1);this._currentGeometryGroupHash=-1}for(;t.__objectsRemoved.length;)this.removeObject(t.__objectsRemoved[0],t),t.__objectsRemoved.splice(0,1);for(var s=0,o=t.__webglObjects.length;s<o;s++)this.updateObject(t.__webglObjects[s].object)}getYRatio(){return this.rows!==void 0&&this.row!==void 0?this.rows:1}getXRatio(){return this.cols!==void 0&&this.col!==void 0?this.cols:1}getAspect(t,s){(t==null||s==null)&&(t=this._canvas.width,s=this._canvas.height);var o=t/s;if(this.rows!=null&&this.cols!=null&&this.row!=null&&this.col!=null){var l=t/this.cols,d=s/this.rows;o=l/d}return o}setTexture(t,s,o){if(t.needsUpdate){t.__webglInit||(t.__webglInit=!0,t.addEventListener("dispose",this.onTextureDispose.bind(this)),t.__webglTexture=this._gl.createTexture(),this.info.memory.textures++),this._gl.activeTexture(this._gl.TEXTURE0+s);var l=o?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D;this._gl.bindTexture(l,t.__webglTexture),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,t.flipY),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,t.unpackAlignment),this._gl.pixelStorei(this._gl.PACK_ALIGNMENT,t.unpackAlignment);var d=this.paramToGL(t.format),i=this.paramToGL(t.type);if(o)this.setTextureParameters(this._gl.TEXTURE_3D,t),this._gl.texImage3D(this._gl.TEXTURE_3D,0,this._gl.R32F,t.image.size.z,t.image.size.y,t.image.size.x,0,this._gl.RED,this._gl.FLOAT,t.image.data);else{var n=t.image,a=n.width,h=n.height;typeof a>"u"&&(a=n.length,d==this._gl.RGBA&&(a/=4),h=1),this.setTextureParameters(this._gl.TEXTURE_2D,t),this.isWebGL1()?this._gl.texImage2D(this._gl.TEXTURE_2D,0,d,d,i,t.image):this._gl.texImage2D(this._gl.TEXTURE_2D,0,d,a,h,0,d,i,t.image)}t.needsUpdate=!1,t.onUpdate&&t.onUpdate()}else this._gl.activeTexture(this._gl.TEXTURE0+s),o?this._gl.bindTexture(this._gl.TEXTURE_3D,t.__webglTexture):this._gl.bindTexture(this._gl.TEXTURE_2D,t.__webglTexture)}supportsVolumetric(){return!this.isWebGL1()}enableAttribute(t){this._enabledAttributes[t]||(this._gl.enableVertexAttribArray(t),this._enabledAttributes[t]=!0)}disableAttributes(){for(let t in this._enabledAttributes)this._enabledAttributes[t]&&(this._gl.disableVertexAttribArray(t),this._enabledAttributes[t]=!1)}setPolygonOffset(t,s,o){this._oldPolygonOffset!==t&&(t?this._gl.enable(this._gl.POLYGON_OFFSET_FILL):this._gl.disable(this._gl.POLYGON_OFFSET_FILL))}setLineWidth(t){t!==this._oldLineWidth&&(this._gl.lineWidth(t),this._oldLineWidth=t)}deallocateGeometry(t){if(t.__webglInit=void 0,t.__webglVertexBuffer!==void 0&&this._gl.deleteBuffer(t.__webglVertexBuffer),t.__webglColorBuffer!==void 0&&this._gl.deleteBuffer(t.__webglColorBuffer),t.geometryGroups!==void 0)for(var s=0,o=t.groups;s<o;s++){var l=t.geometryGroups[s];l.__webglVertexBuffer!==void 0&&this._gl.deleteBuffer(l.__webglVertexBuffer),l.__webglColorBuffer!==void 0&&this._gl.deleteBuffer(l.__webglColorBuffer),l.__webglNormalBuffer!==void 0&&this._gl.deleteBuffer(l.__webglNormalBuffer),l.__webglFaceBuffer!==void 0&&this._gl.deleteBuffer(l.__webglFaceBuffer),l.__webglLineBuffer!==void 0&&this._gl.deleteBuffer(l.__webglLineBuffer)}}deallocateMaterial(t){var s=t.program;if(s!==void 0){t.program=void 0;var o,l,d,i=!1;for(o=0,l=this._programs.length;o<l;o++)if(d=this._programs[o],d.program===s){d.usedTimes--,d.usedTimes===0&&(i=!0);break}if(i===!0){var n=[];for(o=0,l=this._programs.length;o<l;o++)d=this._programs[o],d.program!==s&&n.push(d);this._programs=n,this._gl.deleteProgram(s),this.info.memory.programs--}}}deallocateTexture(t){if(t.image&&t.image.__webglTextureCube)this._gl.deleteTexture(t.image.__webglTextureCube);else{if(!t.__webglInit)return;t.__webglInit=!1,this._gl.deleteTexture(t.__webglTexture)}}onGeometryDispose(t){var s=t.target;s.removeEventListener("dispose",this.onGeometryDispose),this.deallocateGeometry(s),this.info.memory.geometries--}onTextureDispose(t){var s=t.target;s.removeEventListener("dispose",this.onTextureDispose),this.deallocateTexture(s),this.info.memory.textures--}onMaterialDispose(t){var s=t.target;s.removeEventListener("dispose",this.onMaterialDispose),this.deallocateMaterial(s)}getShader(t,s){var o;return!this.isWebGL1()&&!s.startsWith("#version")&&(s=s.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),t=="fragment"?s=s.replace(/varying/g,"in"):s=s.replace(/varying/g,"out"),s=s.replace(/attribute/g,"in"),s=s.replace(/texture2D/g,"texture"),s=s.replace(/\/\/DEFINEFRAGCOLOR/g,"out vec4 glFragColor;"),s=s.replace(/gl_FragColor/g,"glFragColor"),s=`#version 300 es
|
|
28
|
+
`+s),t==="fragment"?o=this._gl.createShader(this._gl.FRAGMENT_SHADER):t==="vertex"&&(o=this._gl.createShader(this._gl.VERTEX_SHADER)),o==null?null:(this._gl.shaderSource(o,s),this._gl.compileShader(o),this._gl.getShaderParameter(o,this._gl.COMPILE_STATUS)?o:(console.error(this._gl.getShaderInfoLog(o)),console.error("could not initialize shader"),null))}buildProgram(t,s,o,l){var d,i,n,a,h=[];h.push(t),h.push(s);for(d in l)h.push(d),h.push(l[d]);for(a=h.join(),d=0,i=this._programs.length;d<i;d++){var u=this._programs[d];if(u.code===a)return u.usedTimes++,u.program}if(this.isWebGL1()&&l.volumetric)throw new Error("Volumetric rendering requires webgl2 which is not supported by your hardware.");if(n=this._gl.createProgram(),n==null)return null;var A=this._precision,D="precision "+A+" float;",T=[l.volumetric?"#version 300 es":"",D].join(`
|
|
29
|
+
`),S=[l.volumetric?"#version 300 es":"",l.fragdepth&&this.isWebGL1()?"#extension GL_EXT_frag_depth: enable":"",l.shaded?"#define SHADED 1":"",l.wireframe?"#define WIREFRAME 1":"",D].join(`
|
|
30
|
+
`),P=this.getShader("fragment",S+t),z=this.getShader("vertex",T+s);z!=null&&this._gl.attachShader(n,z),P!=null&&this._gl.attachShader(n,P),this._gl.linkProgram(n),this._gl.getProgramParameter(n,this._gl.LINK_STATUS)||console.error("Could not initialize shader"),n.uniforms={},n.attributes={};var F,B,W;F=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","vWidth","vHeight"];for(B in o)F.push(B);for(W=0;W<F.length;W++){var U=F[W];n.uniforms[U]=this._gl.getUniformLocation(n,U)}for(F=["position","normal","color","lineDistance","offset","radius"],W=0;W<F.length;W++){var I=F[W];n.attributes[I]=this._gl.getAttribLocation(n,I)}return n.id=this._programs_counter++,this._programs.push({program:n,code:a,usedTimes:1}),this.info.memory.programs=this._programs.length,n}setProgram(t,s,o,l,d,i){if(l.needsUpdate&&(l.program&&this.deallocateMaterial(l),this.initMaterial(l,s,o,d),l.needsUpdate=!1),l.program==null)return null;var n=!1,a=l.program,h=a.uniforms,u=l.uniforms;if(a!=this._currentProgram&&(this._gl.useProgram(a),this._currentProgram=a,n=!0),l.id!=this._currentMaterialId&&(this._currentMaterialId=l.id,n=!0),t!=this._currentCamera&&(this._currentCamera=t,n=!0),h.projectionMatrix&&this._gl.uniformMatrix4fv(h.projectionMatrix,!1,t.projectionMatrix.elements),h.modelViewMatrix&&this._gl.uniformMatrix4fv(h.modelViewMatrix,!1,d._modelViewMatrix.elements),h.normalMatrix&&this._gl.uniformMatrix3fv(h.normalMatrix,!1,d._normalMatrix.elements),h.projinv&&(this._projInverse.getInverse(t.projectionMatrix),this._gl.uniformMatrix4fv(h.projinv,!1,this._projInverse.elements)),h.viewMatrix&&this._gl.uniformMatrix4fv(h.viewMatrix,!1,t.matrixWorldInverse.elements),h.vWidth&&this._gl.uniform1f(h.vWidth,this._viewportWidth),h.vHeight&&this._gl.uniform1f(h.vHeight,this._viewportHeight),n){if(u.fogColor.value=o.color,u.fogNear.value=o.near,u.fogFar.value=o.far,l.shaderID.startsWith("lambert")||l.shaderID==="instanced"||l.shaderID.endsWith("imposter"))this._lightsNeedUpdate&&(this.setupLights(a,s),this._lightsNeedUpdate=!1),u.directionalLightColor.value=this._lights.directional.colors,u.directionalLightDirection.value=this._lights.directional.positions;else if(l.shaderID.endsWith("outline"))u.outlineColor.value=l.outlineColor,u.outlineWidth.value=l.outlineWidth,u.outlinePushback.value=l.outlinePushback,u.outlineMaxPixels.value=l.outlineMaxPixels*this.devicePixelRatio;else if(l.shaderID==="volumetric"){d._modelViewMatrix.getScale(this._direction),this._worldInverse.getInverse(d._modelViewMatrix),this._projInverse.getInverse(t.projectionMatrix),this._textureMatrix.multiplyMatrices(d.material.texmatrix,this._worldInverse),this._gl.uniformMatrix4fv(h.textmat,!1,this._textureMatrix.elements),this._gl.uniformMatrix4fv(h.projinv,!1,this._projInverse.elements);let A=Math.min(Math.min(this._direction.x,this._direction.y),this._direction.z);u.step.value=d.material.unit*A,u.maxdepth.value=d.material.maxdepth*A,u.transfermax.value=d.material.transfermax,u.transfermin.value=d.material.transfermin,u.subsamples.value=d.material.subsamples,i.setTexture(d.material.transferfn,4,!1),i.setTexture(d.material.map,3,!0),this._gl.activeTexture(this._gl.TEXTURE5),this._gl.bindTexture(this._gl.TEXTURE_2D,this._depthTexture)}u.opacity.value=l.opacity,this.loadMaterialUniforms(h,u)}return u.shading&&(u.shading.value==3?(this._gl.activeTexture(this._gl.TEXTURE0+this.SHADE_TEXTURE),this._gl.bindTexture(this._gl.TEXTURE_2D,this._shadingTexture)):console.error("Invalid shading textures.")),a}loadMaterialUniforms(t,s){var o,l,d,i;for(o in s)t[o]&&(l=s[o].type,d=s[o].value,i=t[o],l==="f"?this._gl.uniform1f(i,d):l==="i"?this._gl.uniform1i(i,d):l==="fv"?this._gl.uniform3fv(i,d):l==="c"?this._gl.uniform3f(i,d.r,d.g,d.b):l==="f4"&&this._gl.uniform4f(i,d[0],d[1],d[2],d[3]))}addObject(t,s){var o,l,d,i;if(!t.__webglInit&&(t.__webglInit=!0,t._modelViewMatrix=new M.Matrix4,t._normalMatrix=new M.Matrix3,t.geometry!==void 0&&t.geometry.__webglInit===void 0&&(t.geometry.__webglInit=!0,t.geometry.addEventListener("dispose",this.onGeometryDispose.bind(this))),t instanceof g.Mesh||t instanceof g.Line))for(d=t.geometry,o=0,l=d.geometryGroups.length;o<l;o++)i=d.geometryGroups[o],i.id=this._geometryGroupCounter++,i.__webglVertexBuffer||(t instanceof g.Mesh?(this.createMeshBuffers(i),d.elementsNeedUpdate=!0,d.normalsNeedUpdate=!0):t instanceof g.Line&&this.createLineBuffers(i),d.verticesNeedUpdate=!0,d.colorsNeedUpdate=!0);if(!t.__webglActive){if(t instanceof g.Mesh||t instanceof g.Line)for(d=t.geometry,o=0,l=d.geometryGroups.length;o<l;o++)i=d.geometryGroups[o],this.addBuffer(s.__webglObjects,i,t);else t instanceof g.Sprite&&s.__webglSprites.push(t);t.__webglActive=!0}}updateObject(t){var s=t.geometry,o;if(t instanceof g.Mesh||t instanceof g.Line){for(var l=0,d=s.geometryGroups.length;l<d;l++)o=s.geometryGroups[l],(s.verticesNeedUpdate||s.elementsNeedUpdate||s.colorsNeedUpdate||s.normalsNeedUpdate)&&this.setBuffers(o,this._gl.STATIC_DRAW);s.verticesNeedUpdate=!1,s.elementsNeedUpdate=!1,s.normalsNeedUpdate=!1,s.colorsNeedUpdate=!1,s.buffersNeedUpdate=!1}}removeObject(t,s){t instanceof g.Mesh||t instanceof g.Line?this.removeInstances(s.__webglObjects,t):t instanceof g.Sprite&&this.removeInstancesDirect(s.__webglSprites,t),t.__webglActive=!1}removeInstances(t,s){for(var o=t.length-1;o>=0;--o)t[o].object===s&&t.splice(o,1)}removeInstancesDirect(t,s){for(var o=t.length-1;o>=0;--o)t[o]===s&&t.splice(o,1)}unrollBufferMaterial(t){var s=t.object,o=s.material;if(o.volumetric)t.opaque=null,t.transparent=null,t.volumetric=o;else if(o.transparent){if(t.opaque=null,t.volumetric=null,t.transparent=o,!o.wireframe){let l=o.clone();l.opacity=0,t.transparentDepth=l}}else{if(t.opaque=o,t.transparent=null,t.volumetric=null,!o.wireframe){let l=o.clone();l.opacity=0,t.opaqueDepth=l}o.hasAO&&(t.hasAO=!0),(this._AOEnabled||t.hasAO)&&(t.opaqueShaded=o.clone(),t.opaqueShaded.shaded=!0)}}setBuffers(t,s){var o=t.vertexArray,l=t.colorArray;if(t.__webglOffsetBuffer!==void 0?(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglOffsetBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,o,s)):(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglVertexBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,o,s)),this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglColorBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,l,s),t.normalArray&&t.__webglNormalBuffer!==void 0){var d=t.normalArray;this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglNormalBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,d,s)}if(t.radiusArray&&t.__webglRadiusBuffer!==void 0&&(this._gl.bindBuffer(this._gl.ARRAY_BUFFER,t.__webglRadiusBuffer),this._gl.bufferData(this._gl.ARRAY_BUFFER,t.radiusArray,s)),t.faceArray&&t.__webglFaceBuffer!==void 0){var i=t.faceArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,s)}if(t.lineArray&&t.__webglLineBuffer!==void 0){var n=t.lineArray;this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,s)}}createMeshBuffers(t){t.radiusArray&&(t.__webglRadiusBuffer=this._gl.createBuffer()),t.useOffset&&(t.__webglOffsetBuffer=this._gl.createBuffer()),t.__webglVertexBuffer=this._gl.createBuffer(),t.__webglNormalBuffer=this._gl.createBuffer(),t.__webglColorBuffer=this._gl.createBuffer(),t.__webglFaceBuffer=this._gl.createBuffer(),t.__webglLineBuffer=this._gl.createBuffer(),this.info.memory.geometries++}createLineBuffers(t){t.__webglVertexBuffer=this._gl.createBuffer(),t.__webglColorBuffer=this._gl.createBuffer(),this.info.memory.geometries++}addBuffer(t,s,o){t.push({buffer:s,object:o,opaque:null,transparent:null})}setupMatrices(t,s){t._modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,t.matrixWorld),t._normalMatrix.getInverse(t._modelViewMatrix),t._normalMatrix.transpose()}filterFallback(t){return this._gl.LINEAR}setTextureParameters(t,s){t==this._gl.TEXTURE_2D?(this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this.filterFallback(s.magFilter)),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this.filterFallback(s.minFilter))):(this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(t,this._gl.TEXTURE_WRAP_R,this._gl.CLAMP_TO_EDGE),this._extColorBufferFloat&&this._extFloatLinear?(this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR)):(this._gl.texParameteri(t,this._gl.TEXTURE_MAG_FILTER,this._gl.NEAREST),this._gl.texParameteri(t,this._gl.TEXTURE_MIN_FILTER,this._gl.NEAREST)))}paramToGL(t){return t===C.UnsignedByteType?this._gl.UNSIGNED_BYTE:t===C.RGBAFormat?this._gl.RGBA:t===C.NearestFilter?this._gl.NEAREST:0}setupLights(t,s){var o,l,d,i=0,n=0,a=0,h,u,A=this._lights,D=A.directional.colors,T=A.directional.positions,S=0,P=0;for(o=0,l=s.length;o<l;o++)if(d=s[o],h=d.color,u=d.intensity,d instanceof R.Light){if(this._direction.getPositionFromMatrix(d.matrixWorld),this._vector3.getPositionFromMatrix(d.target.matrixWorld),this._direction.sub(this._vector3),this._direction.normalize(),this._direction.x===0&&this._direction.y===0&&this._direction.z===0)continue;T[P]=this._direction.x,T[P+1]=this._direction.y,T[P+2]=this._direction.z,D[P]=h.r*u,D[P+1]=h.g*u,D[P+2]=h.b*u,P+=3,S++}A.ambient[0]=i,A.ambient[1]=n,A.ambient[2]=a,A.directional.length=S}initGL(){try{if(OffscreenCanvas&&!(this.rows!=null&&this.cols!=null&&this.row!=null&&this.col!=null))(m==null||m.isContextLost())&&(p=new OffscreenCanvas(this._canvas.width,this._canvas.height),m=p.getContext("webgl2",{alpha:!0,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,preserveDrawingBuffer:this._preserveDrawingBuffer})),this._offscreen=p,this._gl=m,this._bitmap=this._canvas.getContext("bitmaprenderer",{alpha:!0});else if(!(this._gl=this._canvas.getContext("webgl2",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,preserveDrawingBuffer:this._preserveDrawingBuffer}))&&!(this._gl=this._canvas.getContext("experimental-webgl",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,preserveDrawingBuffer:this._preserveDrawingBuffer}))&&!(this._gl=this._canvas.getContext("webgl",{alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,preserveDrawingBuffer:this._preserveDrawingBuffer})))throw"Error creating WebGL context.";var t=this._gl.getParameter(this._gl.VERSION);this._webglversion=parseInt(t[6])}catch(s){console.error(s)}}isWebGL1(){return this._webglversion==1}setDefaultGLState(){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(t,s,o,l,d,i,n){var a,h,u,A,D,T,S;s?(D=t.length-1,T=-1,S=-1):(D=0,T=t.length,S=1);for(var P=D;P!==T;P+=S)if(a=t[P],a.render){if(h=a.object,u=a.buffer,A=a[o],(a.hasAO||this._AOEnabled)&&a[o+"Shaded"]&&(A=a[o+"Shaded"]),!A)continue;this.setBlending(n),this.setDepthTest(A.depthTest),this.setDepthWrite(A.depthWrite),this.setPolygonOffset(A.polygonOffset,A.polygonOffsetFactor,A.polygonOffsetUnits);var z=h._modelViewMatrix.isReflected();if(this.setMaterialFaces(A,z),this.renderBuffer(l,d,i,A,u,h),(this._outlineEnabled||A.outline)&&!A.wireframe&&A.shaderID!=="basic"&&A.opacity!==0){let F=this._outlineMaterial;A.shaderID=="sphereimposter"?F=this._outlineSphereImposterMaterial:A.shaderID=="stickimposter"&&(F=this._outlineStickImposterMaterial),this.renderBuffer(l,d,i,F,u,h)}}}renderSprites(t,s,o){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(t,s,this._currentWidth,this._currentHeight,o),this._currentGeometryGroupHash=-1,this._currentProgram=null,this._currentCamera=null,this._oldDepthWrite=-1,this._oldDepthTest=-1,this._oldDoubleSided=-1,this._currentMaterialId=-1,this._oldFlipSided=-1}}},"./src/WebGL/SpritePlugin.ts"(k,w,c){c.r(w),c.d(w,{SpritePlugin:()=>O});var b=c("./src/WebGL/shaders/index.ts");class O{constructor(){this.sprite={vertices:null,faces:null,vertexBuffer:null,elementBuffer:null,program:null,attributes:{},uniforms:null}}init(v){this.gl=v.context,this.renderer=v,this.precision=v.getPrecision(),this.sprite.vertices=new Float32Array(16),this.sprite.faces=new Uint16Array(6);var y=0;this.sprite.vertices[y++]=-1,this.sprite.vertices[y++]=-1,this.sprite.vertices[y++]=0,this.sprite.vertices[y++]=0,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=-1,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=0,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=-1,this.sprite.vertices[y++]=1,this.sprite.vertices[y++]=0,this.sprite.vertices[y++]=1,y=0,this.sprite.faces[y++]=0,this.sprite.faces[y++]=1,this.sprite.faces[y++]=2,this.sprite.faces[y++]=0,this.sprite.faces[y++]=2,this.sprite.faces[y++]=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(b.ShaderLib.sprite,this.precision||1),this.sprite.attributes={};const M={};this.sprite.attributes.position=this.gl.getAttribLocation(this.sprite.program,"position"),this.sprite.attributes.uv=this.gl.getAttribLocation(this.sprite.program,"uv"),M.uvOffset=this.gl.getUniformLocation(this.sprite.program,"uvOffset"),M.uvScale=this.gl.getUniformLocation(this.sprite.program,"uvScale"),M.rotation=this.gl.getUniformLocation(this.sprite.program,"rotation"),M.scale=this.gl.getUniformLocation(this.sprite.program,"scale"),M.alignment=this.gl.getUniformLocation(this.sprite.program,"alignment"),M.color=this.gl.getUniformLocation(this.sprite.program,"color"),M.map=this.gl.getUniformLocation(this.sprite.program,"map"),M.opacity=this.gl.getUniformLocation(this.sprite.program,"opacity"),M.useScreenCoordinates=this.gl.getUniformLocation(this.sprite.program,"useScreenCoordinates"),M.screenPosition=this.gl.getUniformLocation(this.sprite.program,"screenPosition"),M.modelViewMatrix=this.gl.getUniformLocation(this.sprite.program,"modelViewMatrix"),M.projectionMatrix=this.gl.getUniformLocation(this.sprite.program,"projectionMatrix"),M.fogNear=this.gl.getUniformLocation(this.sprite.program,"fogNear"),M.fogFar=this.gl.getUniformLocation(this.sprite.program,"fogFar"),M.fogColor=this.gl.getUniformLocation(this.sprite.program,"fogColor"),M.alphaTest=this.gl.getUniformLocation(this.sprite.program,"alphaTest"),this.sprite.uniforms=M}render(v,y,M,g,x){var _,p,m,r,e,t,s,o,l,d;if(!this.gl)throw new Error("WebGLRenderer not initialized");let i=[];(_=v==null?void 0:v.__webglSprites)===null||_===void 0||_.forEach(U=>{(x&&U.material.depthTest==!1||!x&&U.material.depthTest)&&i.push(U)});let n=i.length;if(!n)return;const a=this.sprite.attributes,h=this.sprite.uniforms;if(!h)throw new Error("Uniforms not defined");var u=M*.5,A=g*.5;this.gl.useProgram(this.sprite.program),this.gl.enableVertexAttribArray(a.position),this.gl.enableVertexAttribArray(a.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(a.position,2,this.gl.FLOAT,!1,16,0),this.gl.vertexAttribPointer(a.uv,2,this.gl.FLOAT,!1,16,8),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.sprite.elementBuffer),this.gl.uniformMatrix4fv(h.projectionMatrix,!1,y.projectionMatrix.elements),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.uniform1i(h.map,0);var D=v.fog;D?(this.gl.uniform3f(h.fogColor,D.color.r,D.color.g,D.color.b),this.gl.uniform1f(h.fogNear,D.near),this.gl.uniform1f(h.fogFar,D.far)):(this.gl.uniform1f(h.fogNear,0),this.gl.uniform1f(h.fogFar,0));var T;let S,P,z,F=[];for(T=0;T<n;T++)S=i[T],P=S.material,P&&(P.depthTest==!1&&!x||!S.visible||P.opacity===0||(P.useScreenCoordinates?S.z=-S.position.z:(S._modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,S.matrixWorld),S.z=-S._modelViewMatrix.elements[14])));for(i.sort(C),T=0;T<n;T++)if(S=i[T],P=S.material,!!P&&!(!S.visible||P.opacity===0)&&P.map&&P.map.image&&P.map.image.width){this.gl.uniform1f((h==null?void 0:h.alphaTest)||null,P.alphaTest);var B=P.map.image.width,W=P.map.image.height;F[0]=B*this.renderer.devicePixelRatio/M,F[1]=W*this.renderer.devicePixelRatio/g,P.useScreenCoordinates===!0?(this.gl.uniform1i(h.useScreenCoordinates,1),this.gl.uniform3f(h.screenPosition,(S.position.x*this.renderer.devicePixelRatio-u)/u,(A-S.position.y*this.renderer.devicePixelRatio)/A,Math.max(0,Math.min(1,S.position.z)))):(this.gl.uniform1i(h.useScreenCoordinates,0),this.gl.uniformMatrix4fv(h.modelViewMatrix,!1,S._modelViewMatrix.elements)),z=1/(P.scaleByViewport?g:1),F[0]*=z*S.scale.x,F[1]*=z*S.scale.y;let U=(p=P==null?void 0:P.alignment)===null||p===void 0?void 0:p.x,I=(m=P==null?void 0:P.alignment)===null||m===void 0?void 0:m.y;P.screenOffset&&(U=(U||0)+2*P.screenOffset.x/B,I=(I||0)+2*P.screenOffset.y/W),this.gl.uniform2f(h.uvScale,((r=P==null?void 0:P.uvScale)===null||r===void 0?void 0:r.x)||1,((e=P==null?void 0:P.uvScale)===null||e===void 0?void 0:e.y)||1),this.gl.uniform2f(h.uvOffset,((t=P==null?void 0:P.uvOffset)===null||t===void 0?void 0:t.x)||0,((s=P==null?void 0:P.uvOffset)===null||s===void 0?void 0:s.y)||0),this.gl.uniform2f(h.alignment,U||0,I||0),this.gl.uniform1f(h.opacity,P.opacity),this.gl.uniform3f(h.color,((o=P==null?void 0:P.color)===null||o===void 0?void 0:o.r)||0,((l=P==null?void 0:P.color)===null||l===void 0?void 0:l.g)||0,((d=P==null?void 0:P.color)===null||d===void 0?void 0:d.b)||0),this.gl.uniform1f(h.rotation,S.rotation),this.gl.uniform2fv(h.scale,F),this.renderer.setDepthTest(P.depthTest),this.renderer.setDepthWrite(P.depthWrite),this.renderer.setTexture(P.map,0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}this.gl.enable(this.gl.CULL_FACE)}createProgram(v,y){if(!this.gl)throw new Error("WebGL Rendering context not found");var M=this.gl.createProgram();if(!M)throw new Error("Error creating webgl program");var g=this.gl.createShader(this.gl.FRAGMENT_SHADER),x=this.gl.createShader(this.gl.VERTEX_SHADER);if(!g)throw new Error("Unable to create fragment shader SpritePlugin.createProgram");if(!x)throw new Error("Unable to create vertex shader SpritePlugin.createProgram");var _="precision "+y+` float;
|
|
31
|
+
`;if(this.gl.shaderSource(g,_+v.fragmentShader),this.gl.shaderSource(x,_+v.vertexShader),this.gl.compileShader(g),this.gl.compileShader(x),!this.gl.getShaderParameter(g,this.gl.COMPILE_STATUS)||!this.gl.getShaderParameter(x,this.gl.COMPILE_STATUS))throw new Error(`Error compiling shader:
|
|
32
|
+
${this.gl.getShaderInfoLog(g)}
|
|
33
|
+
${this.gl.getShaderInfoLog(x)}`);return this.gl.attachShader(M,g),this.gl.attachShader(M,x),this.gl.linkProgram(M),this.gl.getProgramParameter(M,this.gl.LINK_STATUS)||console.error("Could not initialize shader"),M}}function C(R,v){return R.z!==v.z?v.z-R.z:v.id-R.id}},"./src/WebGL/constants/Coloring.ts"(k,w,c){c.r(w),c.d(w,{Coloring:()=>b});var b;(function(O){O[O.NoColors=0]="NoColors",O[O.FaceColors=1]="FaceColors",O[O.VertexColors=2]="VertexColors"})(b||(b={}))},"./src/WebGL/constants/Shading.ts"(k,w,c){c.r(w),c.d(w,{Shading:()=>b});var b;(function(O){O[O.NoShading=0]="NoShading",O[O.FlatShading=1]="FlatShading",O[O.SmoothShading=2]="SmoothShading"})(b||(b={}))},"./src/WebGL/constants/Sides.ts"(k,w,c){c.r(w),c.d(w,{BackSide:()=>O,DoubleSide:()=>C,FrontSide:()=>b});const b=0,O=1,C=2},"./src/WebGL/constants/SpriteAlignment.ts"(k,w,c){c.r(w),c.d(w,{SpriteAlignment:()=>O});var b=c("./src/WebGL/math/index.ts");const O={topLeft:new b.Vector2(1,-1),topCenter:new b.Vector2(0,-1),topRight:new b.Vector2(-1,-1),centerLeft:new b.Vector2(1,0),center:new b.Vector2(0,0),centerRight:new b.Vector2(-1,0),bottomLeft:new b.Vector2(1,1),bottomCenter:new b.Vector2(0,1),bottomRight:new b.Vector2(-1,1)}},"./src/WebGL/constants/TextureConstants.ts"(k,w,c){c.r(w),c.d(w,{ClampToEdgeWrapping:()=>b,FloatType:()=>y,LinearFilter:()=>O,LinearMipMapLinearFilter:()=>R,NearestFilter:()=>C,R32Format:()=>x,RFormat:()=>g,RGBAFormat:()=>M,UnsignedByteType:()=>v});const b=1001,O=1006,C=1007,R=1008,v=1009,y=1010,M=1021,g=1022,x=1023},"./src/WebGL/constants/TextureOperations.ts"(k,w,c){c.r(w),c.d(w,{TextureOperations:()=>b});var b;(function(O){O[O.MultiplyOperation=0]="MultiplyOperation",O[O.MixOperation=1]="MixOperation",O[O.AddOperation=2]="AddOperation"})(b||(b={}))},"./src/WebGL/constants/index.ts"(k,w,c){c.r(w),c.d(w,{BackSide:()=>O.BackSide,ClampToEdgeWrapping:()=>v.ClampToEdgeWrapping,Coloring:()=>b.Coloring,DoubleSide:()=>O.DoubleSide,FloatType:()=>v.FloatType,FrontSide:()=>O.FrontSide,LinearFilter:()=>v.LinearFilter,LinearMipMapLinearFilter:()=>v.LinearMipMapLinearFilter,NearestFilter:()=>v.NearestFilter,R32Format:()=>v.R32Format,RFormat:()=>v.RFormat,RGBAFormat:()=>v.RGBAFormat,Shading:()=>C.Shading,SpriteAlignment:()=>R.SpriteAlignment,TextureOperations:()=>y.TextureOperations,UnsignedByteType:()=>v.UnsignedByteType});var b=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Sides.ts"),C=c("./src/WebGL/constants/Shading.ts"),R=c("./src/WebGL/constants/SpriteAlignment.ts"),v=c("./src/WebGL/constants/TextureConstants.ts"),y=c("./src/WebGL/constants/TextureOperations.ts")},"./src/WebGL/core/EventDispatcher.ts"(k,w,c){c.r(w),c.d(w,{EventDispatcher:()=>b});class b{constructor(){this.listeners={}}dispatchEvent(C){var R=this.listeners[C.type];if(R!==void 0){C.target=this;for(var v=0,y=R.length;v<y;v++)R[v].call(this,C)}}removeEventListener(C,R){if(!R)this.listeners[C]=[];else{var v=this.listeners[C].indexOf(R);v!==-1&&this.listeners[C].splice(v,1)}}addEventListener(C,R){this.listeners[C]===void 0&&(this.listeners[C]=[]),this.listeners[C].indexOf(R)===-1&&this.listeners[C].push(R)}}},"./src/WebGL/core/Geometry.ts"(k,w,c){c.r(w),c.d(w,{Geometry:()=>M,GeometryGroup:()=>y,GeometryIDCount:()=>g});var b=c("./src/WebGL/materials/LineBasicMaterial.ts"),O=c("./src/WebGL/core/EventDispatcher.ts"),C=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts");const v=65535;class y{constructor(_=0){this.vertexArray=null,this.colorArray=null,this.normalArray=null,this.radiusArray=null,this.faceArray=null,this.lineArray=null,this.atomArray=Array(),this.vertices=0,this.faceidx=0,this.lineidx=0,this.__inittedArrays=!1,this.id=_}setColor(_){var p=this.vertexArray,m=this.colorArray;if(!p)throw new Error("vertex array not initialized");if(!m)throw new Error("color array not initialized");let r=R.CC.color(_);for(var e=0;e<p.length;e+=3)m[e]=r.r,m[e+1]=r.g,m[e+2]=r.b}setColors(_){var p=this.vertexArray,m=this.colorArray;if(!p)throw new Error("vertex array not initialized");if(!m)throw new Error("color array not initialized");if(p.length!=m.length){console.log("Cannot re-color geometry group due to mismatched lengths.");return}for(var r=0;r<p.length;r+=3){var e=_(p[r],p[r+1],p[r+2]);e instanceof R.Color||(e=R.CC.color(e)),m[r]=e.r,m[r+1]=e.g,m[r+2]=e.b}}getNumVertices(){return this.vertices}getVertices(){return this.vertexArray}getCentroid(){if(!this.vertexArray)throw new Error("vertex array not initialized");for(var _=new C.Vector3,p,m,r,e,t=0;t<this.vertices;++t)p=t*3,m=this.vertexArray[p],r=this.vertexArray[p+1],e=this.vertexArray[p+2],_.x+=m,_.y+=r,_.z+=e;return _.divideScalar(this.vertices),_}setNormals(){var _=this.faceArray,p=this.vertexArray,m=this.normalArray;if(!(!this.vertices||!this.faceidx)){if(!_)throw new Error("face array not initialized");if(!p)throw new Error("vertex array not initialized");if(!m)throw new Error("normal array not initialized");for(var r,e,t,s,o,l,d,i=0;i<_.length/3;++i)r=_[i*3]*3,e=_[i*3+1]*3,t=_[i*3+2]*3,s=new C.Vector3(p[r],p[r+1],p[r+2]),o=new C.Vector3(p[e],p[e+1],p[e+2]),l=new C.Vector3(p[t],p[t+1],p[t+2]),s.subVectors(s,o),l.subVectors(l,o),l.cross(s),d=l,d.normalize(),m[r]+=d.x,m[e]+=d.x,m[t]+=d.x,m[r+1]+=d.y,m[e+1]+=d.y,m[t+1]+=d.y,m[r+2]+=d.z,m[e+2]+=d.z,m[t+2]+=d.z}}setLineIndices(){if(this.faceidx&&!(this.lineArray&&this.lineArray.length==this.faceidx*2&&this.lineidx==this.faceidx*2)){var _=this.faceArray,p=this.lineArray=new Uint16Array(this.faceidx*2);if(this.lineidx=this.faceidx*2,!_)throw new Error("face array not initialized");for(var m=0;m<this.faceidx/3;++m){var r=m*3,e=r*2,t=_[r],s=_[r+1],o=_[r+2];p[e]=t,p[e+1]=s,p[e+2]=t,p[e+3]=o,p[e+4]=s,p[e+5]=o}}}vrml(_,p){var m,r,e,t,s,o,l,d,i,n,a,h,u,A,D,T,S,P,z="";if(z+=_+`Shape {
|
|
34
|
+
`+_+` appearance Appearance {
|
|
35
|
+
`+_+` material Material {
|
|
36
|
+
`+_+" diffuseColor "+((m=p==null?void 0:p.color)===null||m===void 0?void 0:m.r)+" "+((r=p==null?void 0:p.color)===null||r===void 0?void 0:r.g)+" "+((e=p==null?void 0:p.color)===null||e===void 0?void 0:e.b)+`
|
|
37
|
+
`,p.wireframe&&this.colorArray){let B=this.colorArray;z+=_+" emissiveColor "+B[0]+" "+B[1]+" "+B[2]+`
|
|
38
|
+
`}p!=null&&p.transparent&&(z+=_+" transparency "+(1-p.opacity)+`
|
|
39
|
+
`),z+=_+` }
|
|
40
|
+
`,z+=_+` }
|
|
41
|
+
`;var F=_;if(_+=" ",p instanceof b.LineBasicMaterial||p.wireframe){z+=_+`geometry IndexedLineSet {
|
|
42
|
+
`+_+` colorPerVertex TRUE
|
|
43
|
+
`+_+` coord Coordinate {
|
|
44
|
+
`+_+` point [
|
|
45
|
+
`;let B,W,U;for(let I=0;I<this.vertices;++I){let G=I*3;B=(t=this.vertexArray)===null||t===void 0?void 0:t[G],W=(s=this.vertexArray)===null||s===void 0?void 0:s[G+1],U=(o=this.vertexArray)===null||o===void 0?void 0:o[G+2],z+=_+" "+B+" "+W+" "+U+`,
|
|
46
|
+
`}if(z+=_+` ]
|
|
47
|
+
`,z+=_+` }
|
|
48
|
+
`,this.colorArray&&!p.wireframe){z+=_+` color Color {
|
|
49
|
+
`+_+` color [
|
|
50
|
+
`;for(let I=0;I<this.vertices;++I){let G=I*3;B=this.colorArray[G],W=this.colorArray[G+1],U=this.colorArray[G+2],z+=_+" "+B+" "+W+" "+U+`,
|
|
51
|
+
`}z+=_+` ]
|
|
52
|
+
`,z+=_+` }
|
|
53
|
+
`}if(z+=_+` coordIndex [
|
|
54
|
+
`,p.wireframe&&this.faceArray)for(let I=0;I<this.faceidx;I+=3)B=(l=this.faceArray)===null||l===void 0?void 0:l[I],W=(d=this.faceArray)===null||d===void 0?void 0:d[I+1],U=(i=this.faceArray)===null||i===void 0?void 0:i[I+2],z+=_+" "+B+", "+W+", "+U+`, -1,
|
|
55
|
+
`;else for(let I=0;I<this.vertices-1;I+=2)z+=_+" "+I+", "+(I+1)+`, -1,
|
|
56
|
+
`;z+=_+` ]
|
|
57
|
+
`,z+=_+`}
|
|
58
|
+
`}else{z+=_+`geometry IndexedFaceSet {
|
|
59
|
+
`+_+` colorPerVertex TRUE
|
|
60
|
+
`+_+` normalPerVertex TRUE
|
|
61
|
+
`+_+` solid FALSE
|
|
62
|
+
`,z+=_+` coord Coordinate {
|
|
63
|
+
`+_+` point [
|
|
64
|
+
`;let B,W,U;for(let I=0;I<this.vertices;++I){let G=I*3;B=(n=this.vertexArray)===null||n===void 0?void 0:n[G],W=(a=this.vertexArray)===null||a===void 0?void 0:a[G+1],U=(h=this.vertexArray)===null||h===void 0?void 0:h[G+2],z+=_+" "+B+" "+W+" "+U+`,
|
|
65
|
+
`}z+=_+` ]
|
|
66
|
+
`,z+=_+` }
|
|
67
|
+
`,z+=_+` normal Normal {
|
|
68
|
+
`+_+` vector [
|
|
69
|
+
`;for(let I=0;I<this.vertices;++I){let G=I*3;B=(u=this.normalArray)===null||u===void 0?void 0:u[G],W=(A=this.normalArray)===null||A===void 0?void 0:A[G+1],U=(D=this.normalArray)===null||D===void 0?void 0:D[G+2],z+=_+" "+B+" "+W+" "+U+`,
|
|
70
|
+
`}if(z+=_+` ]
|
|
71
|
+
`,z+=_+` }
|
|
72
|
+
`,this.colorArray){z+=_+` color Color {
|
|
73
|
+
`+_+` color [
|
|
74
|
+
`;for(let I=0;I<this.vertices;++I){let G=I*3;B=this.colorArray[G],W=this.colorArray[G+1],U=this.colorArray[G+2],z+=_+" "+B+" "+W+" "+U+`,
|
|
75
|
+
`}z+=_+` ]
|
|
76
|
+
`,z+=_+` }
|
|
77
|
+
`}z+=_+` coordIndex [
|
|
78
|
+
`;for(let I=0;I<this.faceidx;I+=3)B=(T=this.faceArray)===null||T===void 0?void 0:T[I],W=(S=this.faceArray)===null||S===void 0?void 0:S[I+1],U=(P=this.faceArray)===null||P===void 0?void 0:P[I+2],z+=_+" "+B+", "+W+", "+U+`, -1,
|
|
79
|
+
`;z+=_+` ]
|
|
80
|
+
`,z+=_+`}
|
|
81
|
+
`}return z+=F+"}",z}truncateArrayBuffers(_=!0,p=!1){var m=this.vertexArray,r=this.colorArray,e=this.normalArray,t=this.faceArray,s=this.lineArray,o=this.radiusArray;this.vertexArray=(m==null?void 0:m.subarray(0,this.vertices*3))||null,this.colorArray=(r==null?void 0:r.subarray(0,this.vertices*3))||null,_?(this.normalArray=(e==null?void 0:e.subarray(0,this.vertices*3))||null,this.faceArray=(t==null?void 0:t.subarray(0,this.faceidx))||null,this.lineidx>0?this.lineArray=(s==null?void 0:s.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)),o&&(this.radiusArray=o.subarray(0,this.vertices)),p&&(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 M extends O.EventDispatcher{constructor(_=!1,p=!1,m=!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=g++,this.mesh=_,this.radii=p,this.offset=m}updateGeoGroup(_=0){var p,m=this.groups>0?this.geometryGroups[this.groups-1]:null;return(!m||m.vertices+_>(((p=m==null?void 0:m.vertexArray)===null||p===void 0?void 0:p.length)||0)/3)&&(m=this.addGeoGroup()),m}vrml(_,p){for(var m="",r=this.geometryGroups.length,e=0;e<r;e++){var t=this.geometryGroups[e];m+=t.vrml(_,p)+`,
|
|
82
|
+
`}return m}addGeoGroup(){var _=new y(this.geometryGroups.length);return this.geometryGroups.push(_),this.groups=this.geometryGroups.length,_.vertexArray=new Float32Array(v*3),_.colorArray=new Float32Array(v*3),this.mesh&&(_.normalArray=new Float32Array(v*3),_.faceArray=new Uint16Array(v*6),_.lineArray=new Uint16Array(v*6)),this.radii&&(_.radiusArray=new Float32Array(v)),_.useOffset=this.offset,_}setUpNormals(..._){for(var p=0;p<this.groups;p++){var m=this.geometryGroups[p];m.setNormals(..._)}}setColors(..._){for(var p=this.geometryGroups.length,m=0;m<p;m++){var r=this.geometryGroups[m];r.setColors(..._)}}setColor(..._){let p=this.geometryGroups.length;for(var m=0;m<p;m++){var r=this.geometryGroups[m];r.setColor(..._)}}setUpWireframe(..._){let p=this.geometryGroups.length;for(var m=0;m<p;m++){var r=this.geometryGroups[m];r.setLineIndices(..._)}}initTypedArrays(){for(var _=0;_<this.groups;_++){var p=this.geometryGroups[_];p.__inittedArrays!==!0&&p.truncateArrayBuffers(this.mesh,!1)}}dispose(){this.dispatchEvent({type:"dispose"})}get vertices(){for(var _=0,p=0;p<this.groups;p++)_+=this.geometryGroups[p].vertices;return _}}let g=0},"./src/WebGL/core/Object3D.ts"(k,w,c){c.r(w),c.d(w,{Light:()=>y,Object3D:()=>R,Object3DIDCount:()=>C,Scene:()=>v});var b=c("./src/WebGL/math/index.ts"),O=c("./src/colors.ts");let C=0;class R{constructor(){this.id=C++,this.name="",this.children=[],this.position=new b.Vector3,this.rotation=new b.Vector3,this.matrix=new b.Matrix4,this.matrixWorld=new b.Matrix4,this.quaternion=new b.Quaternion,this.eulerOrder="XYZ",this.up=new b.Vector3(0,1,0),this.scale=new b.Vector3(1,1,1),this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!0,this.rotationAutoUpdate=!0,this.useQuaternion=!1,this.visible=!0}lookAt(g){this.matrix.lookAt(g,this.position,this.up),this.rotationAutoUpdate&&(this.useQuaternion===!0?console.error("Unimplemented math operation."):this.rotation instanceof b.Vector3&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder))}add(g){if(g===this){console.error("Can't add $3Dmol.Object3D to itself");return}g.parent=this,this.children.push(g);for(var x=this;x.parent!==void 0;)x=x.parent;x!==void 0&&x instanceof v&&x.__addObject(g)}remove(g){var x=this.children.indexOf(g);if(x!==-1){g.parent=void 0,this.children.splice(x,1);for(var _=this;_.parent!==void 0;)_=_.parent;_!==void 0&&_ instanceof v&&_.__removeObject(g)}}vrml(g){g||(g=" ");var x=2*Math.atan2(this.quaternion.lengthxyz(),this.quaternion.w),_=0,p=0,m=0;if(x!=0){let t=Math.sin(x/2);_=this.quaternion.x/t,p=this.quaternion.y/t,m=this.quaternion.z/t}var r=g+`Transform {
|
|
83
|
+
`+g+" center "+this.position.x+" "+this.position.y+" "+this.position.z+`
|
|
84
|
+
`+g+" rotation "+_+" "+p+" "+m+" "+x+`
|
|
85
|
+
`+g+` children [
|
|
86
|
+
`;this.geometry&&(r+=this.geometry.vrml(g,this.material));for(var e=0;e<this.children.length;e++)r+=this.children[e].vrml(g+" ")+`,
|
|
87
|
+
`;return r+=` ]
|
|
88
|
+
`,r+="}",r}updateMatrix(){this.matrix.setPosition(this.position),this.useQuaternion===!1&&this.rotation instanceof b.Vector3?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):this.matrix.setRotationFromQuaternion(this.quaternion),(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)&&this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(g){this.matrixAutoUpdate===!0&&this.updateMatrix(),(this.matrixWorldNeedsUpdate===!0||g===!0)&&(this.parent===void 0?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1;for(var x=0;x<this.children.length;x++)this.children[x].updateMatrixWorld(!0)}clone(g){g===void 0&&(g=new R),g.name=this.name,g.up.copy(this.up),g.position.copy(this.position),g.rotation instanceof b.Vector3&&this.rotation instanceof b.Vector3?g.rotation.copy(this.rotation):g.rotation=this.rotation,g.eulerOrder=this.eulerOrder,g.scale.copy(this.scale),g.rotationAutoUpdate=this.rotationAutoUpdate,g.matrix.copy(this.matrix),g.matrixWorld.copy(this.matrixWorld),g.quaternion.copy(this.quaternion),g.matrixAutoUpdate=this.matrixAutoUpdate,g.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate,g.useQuaternion=this.useQuaternion,g.visible=this.visible;for(var x=0;x<this.children.length;x++){var _=this.children[x];g.add(_.clone())}return g}setVisible(g){this.visible=g;for(var x=0;x<this.children.length;x++){var _=this.children[x];_.setVisible(g)}}}class v extends R{constructor(){super(...arguments),this.fog=null,this.overrideMaterial=null,this.matrixAutoUpdate=!1,this.__objects=[],this.__lights=[],this.__objectsAdded=[],this.__objectsRemoved=[]}__addObject(g){if(g instanceof y)this.__lights.indexOf(g)===-1&&this.__lights.push(g),g.target&&g.target.parent===void 0&&this.add(g.target);else if(this.__objects.indexOf(g)===-1){this.__objects.push(g),this.__objectsAdded.push(g);var x=this.__objectsRemoved.indexOf(g);x!==-1&&this.__objectsRemoved.splice(x,1)}for(var _=0;_<g.children.length;_++)this.__addObject(g.children[_])}__removeObject(g){var x;if(g instanceof y)x=this.__lights.indexOf(g),x!==-1&&this.__lights.splice(x,1);else if(x=this.__objects.indexOf(g),x!==-1){this.__objects.splice(x,1),this.__objectsRemoved.push(g);var _=this.__objectsAdded.indexOf(g);_!==-1&&this.__objectsAdded.splice(x,1)}for(var p=0;p<g.children.length;p++)this.__removeObject(g.children[p])}}class y extends R{constructor(g,x=1){super(),this.position=new b.Vector3(0,1,0),this.target=new R,this.castShadow=!1,this.onlyShadow=!1,this.color=new O.Color(g),this.intensity=x}}},"./src/WebGL/core/Projector.ts"(k,w,c){c.r(w),c.d(w,{Projector:()=>C});var b=c("./src/WebGL/math/index.ts");const O=new b.Matrix4;class C{static unprojectVector(v,y){return y.projectionMatrixInverse.getInverse(y.projectionMatrix),O.multiplyMatrices(y.matrixWorld,y.projectionMatrixInverse),v.applyProjection(O)}static projectVector(v,y){return y.matrixWorldInverse.getInverse(y.matrixWorld),O.multiplyMatrices(y.projectionMatrix,y.matrixWorldInverse),v.applyProjection(O)}projectVector(v,y){return C.projectVector(v,y)}unprojectVector(v,y){return C.unprojectVector(v,y)}}},"./src/WebGL/core/Raycaster.ts"(k,w,c){c.r(w),c.d(w,{Raycaster:()=>v,intersectObject:()=>t});var b=c("./src/WebGL/math/index.ts"),O=c("./src/WebGL/shapes/index.ts");const C=(s,o)=>s.distance-o.distance,R=new b.Matrix4;class v{constructor(o,l,d,i){this.precision=1e-4,this.linePrecision=.2,this.ray=new b.Ray(o,l),this.ray.direction.lengthSq()>0&&this.ray.direction.normalize(),this.near=i||0,this.far=d||1/0}set(o,l){this.ray.set(o,l)}setFromCamera(o,l){l.ortho?(this.ray.origin.set(o.x,o.y,(l.near+l.far)/(l.near-l.far)).unproject(l),this.ray.direction.set(0,0,-1).transformDirection(l.matrixWorld)):(this.ray.origin.setFromMatrixPosition(l.matrixWorld),this.ray.direction.set(o.x,o.y,o.z),l.projectionMatrixInverse.getInverse(l.projectionMatrix),R.multiplyMatrices(l.matrixWorld,l.projectionMatrixInverse),this.ray.direction.applyProjection(R),this.ray.direction.sub(this.ray.origin).normalize())}intersectObjects(o,l){for(var d=[],i=0,n=l.length;i<n;i++)t(o,l[i],this,d);return d.sort(C),d}}const y=s=>Math.min(Math.max(s,-1),1);var M=new O.Sphere,g=new O.Cylinder,x=new O.Triangle,_=new b.Vector3,p=new b.Vector3,m=new b.Vector3,r=new b.Vector3,e=new b.Vector3;function t(s,o,l,d){if(e.getPositionFromMatrix(s.matrixWorld),o.intersectionShape===void 0||o.hidden)return d;var i=o.intersectionShape,n=l.linePrecision;n*=s.matrixWorld.getMaxScaleOnAxis();var a=n*n;if(o.boundingSphere!==void 0&&o.boundingSphere instanceof O.Sphere&&(M.copy(o.boundingSphere),M.applyMatrix4(s.matrixWorld),!l.ray.isIntersectionSphere(M)))return d;var h,u,A,D,T,S,P,z,F,B,W,U,I,G;for(h=0,u=i.triangle.length;h<u;h++)if(i.triangle[h]instanceof O.Triangle){if(x.copy(i.triangle[h]),x.applyMatrix4(s.matrixWorld),A=x.getNormal(),D=l.ray.direction.dot(A),D>=0||(_.subVectors(x.a,l.ray.origin),P=A.dot(_)/D,P<0))continue;p.copy(l.ray.direction).multiplyScalar(P).add(l.ray.origin),p.sub(x.a),m.copy(x.b).sub(x.a),r.copy(x.c).sub(x.a);var Y=m.dot(r),J=m.lengthSq(),te=r.lengthSq();if(U=(J*p.dot(r)-Y*p.dot(m))/(J*te-Y*Y),U<0||U>1||(W=(p.dot(m)-U*Y)/J,W<0||W>1||W+U>1))continue;d.push({clickable:o,distance:P})}for(h=0,u=i.cylinder.length;h<u;h++)if(i.cylinder[h]instanceof O.Cylinder){if(g.copy(i.cylinder[h]),g.applyMatrix4(s.matrixWorld),_.subVectors(g.c1,l.ray.origin),T=_.dot(g.direction),S=_.dot(l.ray.direction),D=y(l.ray.direction.dot(g.direction)),F=1-D*D,F===0)continue;I=(D*S-T)/F,G=(S-D*T)/F,p.copy(g.direction).multiplyScalar(I).add(g.c1),m.copy(l.ray.direction).multiplyScalar(G).add(l.ray.origin),z=r.subVectors(p,m).lengthSq();var ne=g.radius*g.radius;if(z<=ne){if(B=(D*T-S)*(D*T-S)-F*(_.lengthSq()-T*T-ne),B<=0?U=P=Math.sqrt(z):U=P=(S-D*T-Math.sqrt(B))/F,W=D*U-T,W<0||W*W>g.lengthSq()||U<0)continue;d.push({clickable:o,distance:P})}}for(h=0,u=i.line.length;h<u;h+=2){p.copy(i.line[h]),p.applyMatrix4(s.matrixWorld),m.copy(i.line[h+1]),m.applyMatrix4(s.matrixWorld),r.subVectors(m,p);var le=r.lengthSq();r.normalize(),_.subVectors(p,l.ray.origin);var ie=_.dot(r);S=_.dot(l.ray.direction),D=y(l.ray.direction.dot(r)),F=1-D*D,F!==0&&(I=(D*S-ie)/F,G=(S-D*ie)/F,p.add(r.multiplyScalar(I)),m.copy(l.ray.direction).multiplyScalar(G).add(l.ray.origin),z=r.subVectors(m,p).lengthSq(),z<a&&I*I<le&&d.push({clickable:o,distance:G}))}for(h=0,u=i.sphere.length;h<u;h++)if(i.sphere[h]instanceof O.Sphere&&(M.copy(i.sphere[h]),M.applyMatrix4(s.matrixWorld),l.ray.isIntersectionSphere(M))){p.subVectors(M.center,l.ray.origin);var oe=p.dot(l.ray.direction);if(B=oe*oe-(p.lengthSq()-M.radius*M.radius),oe<0)return d;B<=0?P=oe:P=oe-Math.sqrt(B),d.push({clickable:o,distance:P})}return d}},"./src/WebGL/core/Texture.ts"(k,w,c){c.r(w),c.d(w,{Texture:()=>v,TextureIdCount:()=>y});var b=c("./src/WebGL/constants/TextureConstants.ts"),O=c("./src/WebGL/math/index.ts"),C=c("./src/WebGL/core/EventDispatcher.ts"),R=c("./src/WebGL/core/UVMapping.ts");class v extends C.EventDispatcher{constructor(g,x){super(),this.id=y++,this.name="",this.image=g,this.mapping=new R.UVMapping,this.wrapS=b.ClampToEdgeWrapping,this.wrapT=b.ClampToEdgeWrapping,this.anisotropy=1,x?(this.format=b.RFormat,this.type=b.FloatType,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.magFilter=b.NearestFilter,this.minFilter=b.NearestFilter):(this.format=b.RGBAFormat,this.type=b.UnsignedByteType,this.offset=new O.Vector2(0,0),this.repeat=new O.Vector2(1,1),this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.magFilter=b.LinearFilter,this.minFilter=b.LinearMipMapLinearFilter),this.needsUpdate=!1,this.onUpdate=null}clone(g=new v){return g.image=this.image,g.mapping=this.mapping,g.wrapS=this.wrapS,g.wrapT=this.wrapT,g.magFilter=this.magFilter,g.minFilter=this.minFilter,g.anisotropy=this.anisotropy,g.format=this.format,g.type=this.type,g.offset.copy(this.offset),g.repeat.copy(this.repeat),g.premultiplyAlpha=this.premultiplyAlpha,g.flipY=this.flipY,g.unpackAlignment=this.unpackAlignment,g}dispose(){this.dispatchEvent({type:"dispose"})}}let y=0},"./src/WebGL/core/UVMapping.ts"(k,w,c){c.r(w),c.d(w,{UVMapping:()=>b});class b{}},"./src/WebGL/core/index.ts"(k,w,c){c.r(w),c.d(w,{EventDispatcher:()=>b.EventDispatcher,Geometry:()=>O.Geometry,GeometryGroup:()=>O.GeometryGroup,GeometryIDCount:()=>O.GeometryIDCount,Light:()=>C.Light,Object3D:()=>C.Object3D,Object3DIDCount:()=>C.Object3DIDCount,Projector:()=>R.Projector,Raycaster:()=>v.Raycaster,Scene:()=>C.Scene,Texture:()=>y.Texture,TextureIdCount:()=>y.TextureIdCount,UVMapping:()=>M.UVMapping,intersectObject:()=>v.intersectObject});var b=c("./src/WebGL/core/EventDispatcher.ts"),O=c("./src/WebGL/core/Geometry.ts"),C=c("./src/WebGL/core/Object3D.ts"),R=c("./src/WebGL/core/Projector.ts"),v=c("./src/WebGL/core/Raycaster.ts"),y=c("./src/WebGL/core/Texture.ts"),M=c("./src/WebGL/core/UVMapping.ts")},"./src/WebGL/index.ts"(k,w,c){c.r(w),c.d(w,{BackSide:()=>b.BackSide,Camera:()=>g.Camera,ClampToEdgeWrapping:()=>b.ClampToEdgeWrapping,Coloring:()=>b.Coloring,Cylinder:()=>M.Cylinder,DoubleSide:()=>b.DoubleSide,EventDispatcher:()=>O.EventDispatcher,FloatType:()=>b.FloatType,Fog:()=>x.Fog,FrontSide:()=>b.FrontSide,Geometry:()=>O.Geometry,GeometryGroup:()=>O.GeometryGroup,GeometryIDCount:()=>O.GeometryIDCount,ImposterMaterial:()=>C.ImposterMaterial,InstancedMaterial:()=>C.InstancedMaterial,Light:()=>O.Light,Line:()=>v.Line,LineBasicMaterial:()=>C.LineBasicMaterial,LineStyle:()=>v.LineStyle,LinearFilter:()=>b.LinearFilter,LinearMipMapLinearFilter:()=>b.LinearMipMapLinearFilter,Material:()=>C.Material,MaterialIdCount:()=>C.MaterialIdCount,Matrix3:()=>R.Matrix3,Matrix4:()=>R.Matrix4,Mesh:()=>v.Mesh,MeshDoubleLambertMaterial:()=>C.MeshDoubleLambertMaterial,MeshLambertMaterial:()=>C.MeshLambertMaterial,MeshOutlineMaterial:()=>C.MeshOutlineMaterial,NearestFilter:()=>b.NearestFilter,Object3D:()=>O.Object3D,Object3DIDCount:()=>O.Object3DIDCount,Projector:()=>O.Projector,Quaternion:()=>R.Quaternion,R32Format:()=>b.R32Format,RFormat:()=>b.RFormat,RGBAFormat:()=>b.RGBAFormat,Ray:()=>R.Ray,Raycaster:()=>O.Raycaster,Renderer:()=>_.Renderer,RingImposterMaterial:()=>C.RingImposterMaterial,Scene:()=>O.Scene,ShaderLib:()=>y.ShaderLib,ShaderUtils:()=>y.ShaderUtils,Shading:()=>b.Shading,Sphere:()=>M.Sphere,SphereImposterMaterial:()=>C.SphereImposterMaterial,SphereImposterOutlineMaterial:()=>C.SphereImposterOutlineMaterial,Sprite:()=>v.Sprite,SpriteAlignment:()=>b.SpriteAlignment,SpriteMaterial:()=>C.SpriteMaterial,SpritePlugin:()=>p.SpritePlugin,StickImposterMaterial:()=>C.StickImposterMaterial,StickImposterOutlineMaterial:()=>C.StickImposterOutlineMaterial,Texture:()=>O.Texture,TextureIdCount:()=>O.TextureIdCount,TextureOperations:()=>b.TextureOperations,Triangle:()=>M.Triangle,UVMapping:()=>O.UVMapping,UnsignedByteType:()=>b.UnsignedByteType,Vector2:()=>R.Vector2,Vector3:()=>R.Vector3,VolumetricMaterial:()=>C.VolumetricMaterial,basic:()=>y.basic,clamp:()=>R.clamp,clone:()=>y.clone,conversionMatrix3:()=>R.conversionMatrix3,degToRad:()=>R.degToRad,instanced:()=>y.instanced,intersectObject:()=>O.intersectObject,lambert:()=>y.lambert,lambertdouble:()=>y.lambertdouble,outline:()=>y.outline,ringimposter:()=>y.ringimposter,screen:()=>y.screen,screenaa:()=>y.screenaa,sphereimposter:()=>y.sphereimposter,sphereimposteroutline:()=>y.sphereimposteroutline,sprite:()=>y.sprite,stickimposter:()=>y.stickimposter,stickimposteroutline:()=>y.stickimposteroutline,volumetric:()=>y.volumetric});var b=c("./src/WebGL/constants/index.ts"),O=c("./src/WebGL/core/index.ts"),C=c("./src/WebGL/materials/index.ts"),R=c("./src/WebGL/math/index.ts"),v=c("./src/WebGL/objects/index.ts"),y=c("./src/WebGL/shaders/index.ts"),M=c("./src/WebGL/shapes/index.ts"),g=c("./src/WebGL/Camera.ts"),x=c("./src/WebGL/Fog.ts"),_=c("./src/WebGL/Renderer.ts"),p=c("./src/WebGL/SpritePlugin.ts")},"./src/WebGL/materials/ImposterMaterial.ts"(k,w,c){c.r(w),c.d(w,{ImposterMaterial:()=>y});var b=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),C=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),v=c("./src/WebGL/materials/Material.ts");class y extends v.Material{constructor(g){super(),this.color=new C.Color(16777215),this.ambient=new C.Color(1048575),this.emissive=new C.Color(0),this.imposter=!0,this.wrapAround=!1,this.wrapRGB=new R.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=O.Shading.SmoothShading,this.shaderID=null,this.vertexColors=b.Coloring.NoColors,this.skinning=!1,this.setValues(g)}clone(g=new y){return super.clone.call(this,g),g.color.copy(this.color),g.ambient.copy(this.ambient),g.emissive.copy(this.emissive),g.wrapAround=this.wrapAround,g.wrapRGB.copy(this.wrapRGB),g.map=this.map,g.lightMap=this.lightMap,g.specularMap=this.specularMap,g.envMap=this.envMap,g.combine=this.combine,g.reflectivity=this.reflectivity,g.refractionRatio=this.refractionRatio,g.fog=this.fog,g.shading=this.shading,g.shaderID=this.shaderID,g.vertexColors=this.vertexColors,g.skinning=this.skinning,g.morphTargets=this.morphTargets,g.morphNormals=this.morphNormals,g}}},"./src/WebGL/materials/InstancedMaterial.ts"(k,w,c){c.r(w),c.d(w,{InstancedMaterial:()=>y});var b=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),C=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),v=c("./src/WebGL/materials/Material.ts");class y extends v.Material{constructor(g){super(),this.color=new C.Color(16777215),this.ambient=new C.Color(1048575),this.emissive=new C.Color(0),this.wrapAround=!1,this.wrapRGB=new R.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=O.Shading.SmoothShading,this.shaderID="instanced",this.vertexColors=b.Coloring.NoColors,this.skinning=!1,this.sphere=null,this.setValues(g)}clone(g=new y){return super.clone.call(this,g),g.color.copy(this.color),g.ambient.copy(this.ambient),g.emissive.copy(this.emissive),g.wrapAround=this.wrapAround,g.wrapRGB.copy(this.wrapRGB),g.map=this.map,g.lightMap=this.lightMap,g.specularMap=this.specularMap,g.envMap=this.envMap,g.combine=this.combine,g.reflectivity=this.reflectivity,g.refractionRatio=this.refractionRatio,g.fog=this.fog,g.shading=this.shading,g.shaderID=this.shaderID,g.vertexColors=this.vertexColors,g.skinning=this.skinning,g.morphTargets=this.morphTargets,g.morphNormals=this.morphNormals,g.sphere=this.sphere,g}}},"./src/WebGL/materials/LineBasicMaterial.ts"(k,w,c){c.r(w),c.d(w,{LineBasicMaterial:()=>C});var b=c("./src/colors.ts"),O=c("./src/WebGL/materials/Material.ts");class C extends O.Material{constructor(v){super(),this.color=new b.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.vertexColors=!1,this.fog=!0,this.shaderID="basic",this.setValues(v)}clone(v=new C){return super.clone.call(this,v),v.color.copy(this.color),v}}},"./src/WebGL/materials/Material.ts"(k,w,c){c.r(w),c.d(w,{Material:()=>v,MaterialIdCount:()=>y});var b=c("./src/WebGL/constants/Sides.ts"),O=c("./src/WebGL/core/index.ts"),C=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts");class v extends O.EventDispatcher{constructor(){super(...arguments),this.id=y++,this.name="",this.side=b.FrontSide,this.opacity=1,this.transparent=!1,this.depthTest=!0,this.depthWrite=!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,this.shaded=!1}setValues(g={}){if(g!==void 0)for(var x in g){var _=g[x];if(_===void 0){console.warn("$3Dmol.Material: '"+x+"' parameter is undefined.");continue}if(x in this){var p=this[x];p instanceof R.Color&&_ instanceof R.Color?p.copy(_):p instanceof R.Color?p.set(_):p instanceof C.Vector3&&_ instanceof C.Vector3?p.copy(_):this[x]=_}}}clone(g=new v){return g.name=this.name,g.side=this.side,g.opacity=this.opacity,g.transparent=this.transparent,g.depthTest=this.depthTest,g.depthWrite=this.depthWrite,g.polygonOffset=this.polygonOffset,g.polygonOffsetFactor=this.polygonOffsetFactor,g.polygonOffsetUnits=this.polygonOffsetUnits,g.alphaTest=this.alphaTest,g.overdraw=this.overdraw,g.visible=this.visible,g}makeShaded(g){this.shaded=!0,this.uniforms&&(this.uniforms.shading={type:"i",value:g},this.uniforms.vWidth={type:"f",value:1},this.uniforms.vHeight={type:"f",value:1})}dispose(){this.dispatchEvent({type:"dispose"})}}let y=0},"./src/WebGL/materials/MeshDoubleLambertMaterial.ts"(k,w,c){c.r(w),c.d(w,{MeshDoubleLambertMaterial:()=>C});var b=c("./src/WebGL/constants/Sides.ts"),O=c("./src/WebGL/materials/MeshLambertMaterial.ts");class C extends O.MeshLambertMaterial{constructor(v){super(v),this.shaderID="lambertdouble",this.side=b.DoubleSide,this.outline=!1}clone(v=new C){return super.clone.call(this,v),v}}},"./src/WebGL/materials/MeshLambertMaterial.ts"(k,w,c){c.r(w),c.d(w,{MeshLambertMaterial:()=>y});var b=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),C=c("./src/WebGL/materials/Material.ts"),R=c("./src/colors.ts"),v=c("./src/WebGL/math/index.ts");class y extends C.Material{constructor(g){super(),this.color=new R.Color(16777215),this.ambient=new R.Color(1048575),this.emissive=new R.Color(0),this.wrapAround=!1,this.wrapRGB=new v.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=O.Shading.SmoothShading,this.shaderID="lambert",this.vertexColors=b.Coloring.NoColors,this.skinning=!1,this.setValues(g)}clone(g=new y){return super.clone.call(this,g),g.color.copy(this.color),g.ambient.copy(this.ambient),g.emissive.copy(this.emissive),g.wrapAround=this.wrapAround,g.wrapRGB.copy(this.wrapRGB),g.map=this.map,g.lightMap=this.lightMap,g.specularMap=this.specularMap,g.envMap=this.envMap,g.combine=this.combine,g.reflectivity=this.reflectivity,g.refractionRatio=this.refractionRatio,g.fog=this.fog,g.shading=this.shading,g.shaderID=this.shaderID,g.vertexColors=this.vertexColors,g.skinning=this.skinning,g.morphTargets=this.morphTargets,g.morphNormals=this.morphNormals,g}}},"./src/WebGL/materials/MeshOutlineMaterial.ts"(k,w,c){c.r(w),c.d(w,{MeshOutlineMaterial:()=>C});var b=c("./src/colors.ts"),O=c("./src/WebGL/materials/Material.ts");class C extends O.Material{constructor(v){super(),v=v||{},this.fog=!0,this.shaderID="outline",this.wireframe=!1,this.outlineColor=b.CC.color(v.color||new b.Color(0,0,0)),this.outlineWidth=v.width||.1,this.outlinePushback=v.pushback||1,this.outlineMaxPixels=v.maxpixels||0}clone(v=new C){return super.clone.call(this,v),v.fog=this.fog,v.shaderID=this.shaderID,v.wireframe=this.wireframe,v.outlineColor=this.outlineColor,v.outlineWidth=this.outlineWidth,v.outlinePushback=this.outlinePushback,v.outlineMaxPixels=this.outlineMaxPixels,v}}},"./src/WebGL/materials/RingImposterMaterial.ts"(k,w,c){c.r(w),c.d(w,{RingImposterMaterial:()=>O});var b=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends b.ImposterMaterial{constructor(R){super(R),this.shaderID="ringimposter",this.setValues(R)}clone(R=new O){return super.clone.call(this,R),R}}},"./src/WebGL/materials/SphereImposterMaterial.ts"(k,w,c){c.r(w),c.d(w,{SphereImposterMaterial:()=>O});var b=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends b.ImposterMaterial{constructor(R){super(R),this.shaderID="sphereimposter",this.setValues(R)}clone(R=new O){return super.clone.call(this,R),R}}},"./src/WebGL/materials/SphereImposterOutlineMaterial.ts"(k,w,c){c.r(w),c.d(w,{SphereImposterOutlineMaterial:()=>C});var b=c("./src/colors.ts"),O=c("./src/WebGL/materials/ImposterMaterial.ts");class C extends O.ImposterMaterial{constructor(v){super(v),v=v||{},this.shaderID="sphereimposteroutline",this.outlineColor=b.CC.color(v.color||new b.Color(0,0,0)),this.outlineWidth=v.width||.1,this.outlinePushback=v.pushback||1,this.outlineMaxPixels=v.maxpixels||0,this.setValues(v)}clone(v=new C){return super.clone.call(this,v),v.outlineColor=this.outlineColor,v.outlineWidth=this.outlineWidth,v.outlinePushback=this.outlinePushback,v.outlineMaxPixels=this.outlineMaxPixels,v}}},"./src/WebGL/materials/SpriteMaterial.ts"(k,w,c){c.r(w),c.d(w,{SpriteMaterial:()=>y});var b=c("./src/WebGL/constants/SpriteAlignment.ts"),O=c("./src/WebGL/core/Texture.ts"),C=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),v=c("./src/WebGL/materials/Material.ts");class y extends v.Material{constructor(g){super(),this.color=new C.Color(16777215),this.map=new O.Texture,this.useScreenCoordinates=!0,this.fog=!1,this.uvOffset=new R.Vector2(0,0),this.uvScale=new R.Vector2(1,1),this.depthTest=!this.useScreenCoordinates,this.sizeAttenuation=!this.useScreenCoordinates,this.screenOffset=this.screenOffset,this.scaleByViewPort=!this.sizeAttenuation,this.alignment=b.SpriteAlignment.center.clone(),this.setValues(g),g=g||{},g.depthTest===void 0&&(this.depthTest=!this.useScreenCoordinates),g.sizeAttenuation===void 0&&(this.sizeAttenuation=!this.useScreenCoordinates),g.scaleByViewPort===void 0&&(this.scaleByViewPort=!this.sizeAttenuation)}clone(g=new y){return super.clone.call(this,g),g.color.copy(this.color),g.map=this.map,g.useScreenCoordinates=this.useScreenCoordinates,g.screenOffset=this.screenOffset,g.sizeAttenuation=this.sizeAttenuation,g.scaleByViewport=this.scaleByViewPort,g.alignment.copy(this.alignment),g.uvOffset.copy(this.uvOffset),g}}},"./src/WebGL/materials/StickImposterMaterial.ts"(k,w,c){c.r(w),c.d(w,{StickImposterMaterial:()=>O});var b=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends b.ImposterMaterial{constructor(R){super(R),this.shaderID="stickimposter",this.setValues(R)}clone(R=new O){return super.clone.call(this,R),R}}},"./src/WebGL/materials/StickImposterOutlineMaterial.ts"(k,w,c){c.r(w),c.d(w,{StickImposterOutlineMaterial:()=>C});var b=c("./src/colors.ts"),O=c("./src/WebGL/materials/ImposterMaterial.ts");class C extends O.ImposterMaterial{constructor(v={}){super(v),this.shaderID="stickimposteroutline",this.outlineColor=new b.Color(0,0,0),this.outlineWidth=.1,this.outlinePushback=1,this.outlineMaxPixels=0,v.color&&(this.outlineColor=b.CC.color(v.color)),v.width&&(this.outlineWidth=v.width),v.pushback&&(this.outlinePushback=v.pushback),v.maxpixels&&(this.outlineMaxPixels=v.maxpixels),this.setValues(v)}clone(v=new C){return super.clone.call(this,v),v.outlineColor=this.outlineColor,v.outlineWidth=this.outlineWidth,v.outlinePushback=this.outlinePushback,v.outlineMaxPixels=this.outlineMaxPixels,v}}},"./src/WebGL/materials/VolumetricMaterial.ts"(k,w,c){c.r(w),c.d(w,{VolumetricMaterial:()=>R});var b=c("./src/WebGL/constants/Sides.ts"),O=c("./src/colors.ts"),C=c("./src/WebGL/materials/Material.ts");class R extends C.Material{constructor(y){super(),this.transparent=!1,this.volumetric=!0,this.color=new O.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=b.FrontSide,this.setValues(y)}clone(y=new R){return super.clone.call(this,y),y.transparent=this.transparent,y.volumetric=this.volumetric,y.color=this.color,y.transferfn=this.transferfn,y.map=this.map,y.extent=this.extent,y.maxdepth=this.maxdepth,y.unit=this.unit,y.texmatrix=this.texmatrix,y.transfermin=this.transfermin,y.transfermax=this.transfermax,y.subsamples=this.subsamples,y.shaderID=this.shaderID,y.side=this.side,y}}},"./src/WebGL/materials/index.ts"(k,w,c){c.r(w),c.d(w,{ImposterMaterial:()=>b.ImposterMaterial,InstancedMaterial:()=>O.InstancedMaterial,LineBasicMaterial:()=>C.LineBasicMaterial,Material:()=>R.Material,MaterialIdCount:()=>R.MaterialIdCount,MeshDoubleLambertMaterial:()=>v.MeshDoubleLambertMaterial,MeshLambertMaterial:()=>y.MeshLambertMaterial,MeshOutlineMaterial:()=>M.MeshOutlineMaterial,RingImposterMaterial:()=>g.RingImposterMaterial,SphereImposterMaterial:()=>x.SphereImposterMaterial,SphereImposterOutlineMaterial:()=>_.SphereImposterOutlineMaterial,SpriteMaterial:()=>p.SpriteMaterial,StickImposterMaterial:()=>m.StickImposterMaterial,StickImposterOutlineMaterial:()=>r.StickImposterOutlineMaterial,VolumetricMaterial:()=>e.VolumetricMaterial});var b=c("./src/WebGL/materials/ImposterMaterial.ts"),O=c("./src/WebGL/materials/InstancedMaterial.ts"),C=c("./src/WebGL/materials/LineBasicMaterial.ts"),R=c("./src/WebGL/materials/Material.ts"),v=c("./src/WebGL/materials/MeshDoubleLambertMaterial.ts"),y=c("./src/WebGL/materials/MeshLambertMaterial.ts"),M=c("./src/WebGL/materials/MeshOutlineMaterial.ts"),g=c("./src/WebGL/materials/RingImposterMaterial.ts"),x=c("./src/WebGL/materials/SphereImposterMaterial.ts"),_=c("./src/WebGL/materials/SphereImposterOutlineMaterial.ts"),p=c("./src/WebGL/materials/SpriteMaterial.ts"),m=c("./src/WebGL/materials/StickImposterMaterial.ts"),r=c("./src/WebGL/materials/StickImposterOutlineMaterial.ts"),e=c("./src/WebGL/materials/VolumetricMaterial.ts")},"./src/WebGL/math/Quaternion.ts"(k,w,c){c.r(w),c.d(w,{Quaternion:()=>b});class b{constructor(C,R,v,y){this.x=C||0,this.y=R||0,this.z=v||0,this.w=y!==void 0?y:1}set(C,R,v,y){return this.x=C,this.y=R,this.z=v,this.w=y,this}copy(C){return this.x=C.x,this.y=C.y,this.z=C.z,this.w=C.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 C=this.length();return C===0?(this.x=0,this.y=0,this.z=0,this.w=1):(C=1/C,this.x*=C,this.y*=C,this.z*=C,this.w*=C),this}multiply(C){return this.multiplyQuaternions(this,C)}multiplyScalar(C){return this.x*=C,this.y*=C,this.z*=C,this.w*=C,this}multiplyQuaternions(C,R){const v=C.x,y=C.y,M=C.z,g=C.w,x=R.x,_=R.y,p=R.z,m=R.w;return this.x=v*m+g*x+y*p-M*_,this.y=y*m+g*_+M*x-v*p,this.z=M*m+g*p+v*_-y*x,this.w=g*m-v*x-y*_-M*p,this}sub(C){return this.x-=C.x,this.y-=C.y,this.z-=C.z,this.w-=C.w,this}clone(){return new b(this.x,this.y,this.z,this.w)}setFromEuler(C){const R=Math.cos(C.x/2),v=Math.cos(C.y/2),y=Math.cos(C.z/2),M=Math.sin(C.x/2),g=Math.sin(C.y/2),x=Math.sin(C.z/2);return this.x=M*v*y+R*g*x,this.y=R*g*y-M*v*x,this.z=R*v*x+M*g*y,this.w=R*v*y-M*g*x,this}}},"./src/WebGL/math/Vector2.ts"(k,w,c){c.r(w),c.d(w,{Vector2:()=>b});class b{constructor(C,R){this.x=C||0,this.y=R||0}set(C,R){return this.x=C,this.y=R,this}subVectors(C,R){return this.x=C.x-R.x,this.y=C.y-R.y,this}copy(C){return this.x=C.x,this.y=C.y,this}clone(){return new b(this.x,this.y)}}},"./src/WebGL/math/index.ts"(k,w,c){c.r(w),c.d(w,{Matrix3:()=>y.Matrix3,Matrix4:()=>y.Matrix4,Quaternion:()=>b.Quaternion,Ray:()=>y.Ray,Vector2:()=>O.Vector2,Vector3:()=>y.Vector3,clamp:()=>C.clamp,conversionMatrix3:()=>R.conversionMatrix3,degToRad:()=>v.degToRad});var b=c("./src/WebGL/math/Quaternion.ts"),O=c("./src/WebGL/math/Vector2.ts"),C=c("./src/WebGL/math/utils/clamp.ts"),R=c("./src/WebGL/math/utils/conversionMatrix3.ts"),v=c("./src/WebGL/math/utils/degToRad.ts"),y=c("./src/WebGL/math/math.ts")},"./src/WebGL/math/math.ts"(k,w,c){c.r(w),c.d(w,{Matrix3:()=>_,Matrix4:()=>g,Ray:()=>p,Vector3:()=>x});var b=c("./src/WebGL/math/utils/degToRad.ts"),O=c("./src/WebGL/math/utils/clamp.ts"),C,R,v,y,M;class g{constructor(r=1,e=0,t=0,s=0,o=0,l=1,d=0,i=0,n=0,a=0,h=1,u=0,A=0,D=0,T=0,S=1){typeof r<"u"&&typeof r!="number"?this.elements=new Float32Array(r):(this.elements=new Float32Array(16),this.elements[0]=r,this.elements[4]=e,this.elements[8]=t,this.elements[12]=s,this.elements[1]=o,this.elements[5]=l,this.elements[9]=d,this.elements[13]=i,this.elements[2]=n,this.elements[6]=a,this.elements[10]=h,this.elements[14]=u,this.elements[3]=A,this.elements[7]=D,this.elements[11]=T,this.elements[15]=S)}makeScale(r,e,t){throw new Error("Method not implemented.")}set(r,e,t,s,o,l,d,i,n,a,h,u,A,D,T,S){const P=this.elements;return P[0]=r,P[4]=e,P[8]=t,P[12]=s,P[1]=o,P[5]=l,P[9]=d,P[13]=i,P[2]=n,P[6]=a,P[10]=h,P[14]=u,P[3]=A,P[7]=D,P[11]=T,P[15]=S,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}copy(r){const e=r.elements;return this.set(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]),this}matrix3FromTopLeft(){const r=this.elements;return new _(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10])}setRotationFromEuler(r,e){const t=this.elements,{x:s,y:o,z:l}=r,d=Math.cos(s),i=Math.sin(s),n=Math.cos(o),a=Math.sin(o),h=Math.cos(l),u=Math.sin(l);if(e===void 0||e==="XYZ"){const A=d*h,D=d*u,T=i*h,S=i*u;t[0]=n*h,t[4]=-n*u,t[8]=a,t[1]=D+T*a,t[5]=A-S*a,t[9]=-i*n,t[2]=S-A*a,t[6]=T+D*a,t[10]=d*n}else console.error(`Error with matrix4 setRotationFromEuler. Order: ${e}`);return this}setRotationFromQuaternion(r){const e=this.elements,{x:t,y:s,z:o,w:l}=r,d=t+t,i=s+s,n=o+o,a=t*d,h=t*i,u=t*n,A=s*i,D=s*n,T=o*n,S=l*d,P=l*i,z=l*n;return e[0]=1-(A+T),e[4]=h-z,e[8]=u+P,e[1]=h+z,e[5]=1-(a+T),e[9]=D-S,e[2]=u-P,e[6]=D+S,e[10]=1-(a+A),this}multiplyMatrices(r,e){const t=r.elements,s=e.elements,o=this.elements,l=t[0],d=t[4],i=t[8],n=t[12],a=t[1],h=t[5],u=t[9],A=t[13],D=t[2],T=t[6],S=t[10],P=t[14],z=t[3],F=t[7],B=t[11],W=t[15],U=s[0],I=s[4],G=s[8],Y=s[12],J=s[1],te=s[5],ne=s[9],le=s[13],ie=s[2],oe=s[6],xe=s[10],_e=s[14],Oe=s[3],ye=s[7],ee=s[11],pe=s[15];return o[0]=l*U+d*J+i*ie+n*Oe,o[4]=l*I+d*te+i*oe+n*ye,o[8]=l*G+d*ne+i*xe+n*ee,o[12]=l*Y+d*le+i*_e+n*pe,o[1]=a*U+h*J+u*ie+A*Oe,o[5]=a*I+h*te+u*oe+A*ye,o[9]=a*G+h*ne+u*xe+A*ee,o[13]=a*Y+h*le+u*_e+A*pe,o[2]=D*U+T*J+S*ie+P*Oe,o[6]=D*I+T*te+S*oe+P*ye,o[10]=D*G+T*ne+S*xe+P*ee,o[14]=D*Y+T*le+S*_e+P*pe,o[3]=z*U+F*J+B*ie+W*Oe,o[7]=z*I+F*te+B*oe+W*ye,o[11]=z*G+F*ne+B*xe+W*ee,o[15]=z*Y+F*le+B*_e+W*pe,this}multiplyScalar(r){const e=this.elements;return e[0]*=r,e[4]*=r,e[8]*=r,e[12]*=r,e[1]*=r,e[5]*=r,e[9]*=r,e[13]*=r,e[2]*=r,e[6]*=r,e[10]*=r,e[14]*=r,e[3]*=r,e[7]*=r,e[11]*=r,e[15]*=r,this}makeTranslation(r,e,t){return this.set(1,0,0,r,0,1,0,e,0,0,1,t,0,0,0,1),this}snap(r){const e=Math.pow(10,4),t=this.elements;for(let s=0;s<16;s++){const o=Math.round(t[s]);o===Math.round(t[s]*e)/e&&(t[s]=o)}return this}transpose(){const r=this.elements;let e;return e=r[1],r[1]=r[4],r[4]=e,e=r[2],r[2]=r[8],r[8]=e,e=r[6],r[6]=r[9],r[9]=e,e=r[3],r[3]=r[12],r[12]=e,e=r[7],r[7]=r[13],r[13]=e,e=r[11],r[11]=r[14],r[14]=e,this}setPosition(r){const e=this.elements;return e[12]=r.x,e[13]=r.y,e[14]=r.z,this}translate(r){const e=this.elements;return e[12]+=r.x,e[13]+=r.y,e[14]+=r.z,this}getInverse(r,e){const t=this.elements,s=r.elements,o=s[0],l=s[4],d=s[8],i=s[12],n=s[1],a=s[5],h=s[9],u=s[13],A=s[2],D=s[6],T=s[10],S=s[14],P=s[3],z=s[7],F=s[11],B=s[15];t[0]=h*S*z-u*T*z+u*D*F-a*S*F-h*D*B+a*T*B,t[4]=i*T*z-d*S*z-i*D*F+l*S*F+d*D*B-l*T*B,t[8]=d*u*z-i*h*z+i*a*F-l*u*F-d*a*B+l*h*B,t[12]=i*h*D-d*u*D-i*a*T+l*u*T+d*a*S-l*h*S,t[1]=u*T*P-h*S*P-u*A*F+n*S*F+h*A*B-n*T*B,t[5]=d*S*P-i*T*P+i*A*F-o*S*F-d*A*B+o*T*B,t[9]=i*h*P-d*u*P-i*n*F+o*u*F+d*n*B-o*h*B,t[13]=d*u*A-i*h*A+i*n*T-o*u*T-d*n*S+o*h*S,t[2]=a*S*P-u*D*P+u*A*z-n*S*z-a*A*B+n*D*B,t[6]=i*D*P-l*S*P-i*A*z+o*S*z+l*A*B-o*D*B,t[10]=l*u*P-i*a*P+i*n*z-o*u*z-l*n*B+o*a*B,t[14]=i*a*A-l*u*A-i*n*D+o*u*D+l*n*S-o*a*S,t[3]=h*D*P-a*T*P-h*A*z+n*T*z+a*A*F-n*D*F,t[7]=l*T*P-d*D*P+d*A*z-o*T*z-l*A*F+o*D*F,t[11]=d*a*P-l*h*P-d*n*z+o*h*z+l*n*F-o*a*F,t[15]=l*h*A-d*a*A+d*n*D-o*h*D-l*n*T+o*a*T;const W=o*t[0]+n*t[4]+A*t[8]+P*t[12];if(W===0){const U="Matrix4.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(U);return console.warn(U),this.identity(),this}return this.multiplyScalar(1/W),this}isReflected(){const r=this.elements,e=r[0],t=r[4],s=r[8],o=r[1],l=r[5],d=r[9],i=r[2],n=r[6],a=r[10];return e*l*a+o*n*s+i*t*d-i*l*s-o*t*a-e*n*d<0}scale(r){const e=this.elements,{x:t}=r,{y:s}=r,{z:o}=r;return e[0]*=t,e[4]*=s,e[8]*=o,e[1]*=t,e[5]*=s,e[9]*=o,e[2]*=t,e[6]*=s,e[10]*=o,e[3]*=t,e[7]*=s,e[11]*=o,this}getMaxScaleOnAxis(){const r=this.elements,e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2],t=r[4]*r[4]+r[5]*r[5]+r[6]*r[6],s=r[8]*r[8]+r[9]*r[9]+r[10]*r[10];return Math.sqrt(Math.max(e,Math.max(t,s)))}makeFrustum(r,e,t,s,o,l){const d=this.elements,i=2*o/(e-r),n=2*o/(s-t),a=(e+r)/(e-r),h=(s+t)/(s-t),u=-(l+o)/(l-o),A=-2*l*o/(l-o);return d[0]=i,d[4]=0,d[8]=a,d[12]=0,d[1]=0,d[5]=n,d[9]=h,d[13]=0,d[2]=0,d[6]=0,d[10]=u,d[14]=A,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makePerspective(r,e,t,s){const o=t*Math.tan((0,b.degToRad)(r*.5)),l=-o,d=l*e,i=o*e;return this.makeFrustum(d,i,l,o,t,s)}makeOrthographic(r,e,t,s,o,l){const d=this.elements,i=1/(e-r),n=1/(t-s),a=1/(l-o),h=(e+r)*i,u=(t+s)*n,A=(l+o)*a;return d[0]=2*i,d[4]=0,d[8]=0,d[12]=-h,d[1]=0,d[5]=2*n,d[9]=0,d[13]=-u,d[2]=0,d[6]=0,d[10]=-2*a,d[14]=-A,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}isEqual(r){const e=r.elements,t=this.elements;return t[0]===e[0]&&t[4]===e[4]&&t[8]===e[8]&&t[12]===e[12]&&t[1]===e[1]&&t[5]===e[5]&&t[9]===e[9]&&t[13]===e[13]&&t[2]===e[2]&&t[6]===e[6]&&t[10]===e[10]&&t[14]===e[14]&&t[3]===e[3]&&t[7]===e[7]&&t[11]===e[11]&&t[15]===e[15]}clone(){const r=this.elements;return new g(r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15])}isIdentity(){const r=this.elements;return r[0]===1&&r[4]===0&&r[8]===0&&r[12]===0&&r[1]===0&&r[5]===1&&r[9]===0&&r[13]===0&&r[2]===0&&r[6]===0&&r[10]===1&&r[14]===0&&r[3]===0&&r[7]===0&&r[11]===0&&r[15]===1}isNearlyIdentity(r){return this.clone().snap(r).isIdentity()}getScale(r){const e=this.elements;return r=r||new x,v.set(e[0],e[1],e[2]),y.set(e[4],e[5],e[6]),M.set(e[8],e[9],e[10]),r.x=v.length(),r.y=y.length(),r.z=M.length(),r}lookAt(r,e,t){const s=this.elements;return M.subVectors(r,e).normalize(),M.length()===0&&(M.z=1),v.crossVectors(t,M).normalize(),v.length()===0&&(M.x+=1e-4,v.crossVectors(t,M).normalize()),y.crossVectors(M,v),s[0]=v.x,s[4]=y.x,s[8]=M.x,s[1]=v.y,s[5]=y.y,s[9]=M.y,s[2]=v.z,s[6]=y.z,s[10]=M.z,this}compose(r,e,t){const s=this.elements;return C.identity(),C.setRotationFromQuaternion(e),R.makeScale(t.x,t.y,t.z),this.multiplyMatrices(C,R),s[12]=r.x,s[13]=r.y,s[14]=r.z,this}}C=new g,R=new g;class x{constructor(r,e,t){this.x=r||0,this.y=e||0,this.z=t||0,this.atomid=void 0}set(r,e,t){return this.x=r,this.y=e,this.z=t,this}copy(r){return this.x=r.x,this.y=r.y,this.z=r.z,this}add(r){return this.x+=r.x,this.y+=r.y,this.z+=r.z,this}addVectors(r,e){return this.x=r.x+e.x,this.y=r.y+e.y,this.z=r.z+e.z,this}multiplyVectors(r,e){return this.x=r.x*e.x,this.y=r.y*e.y,this.z=r.z*e.z,this}sub(r){return this.x-=r.x,this.y-=r.y,this.z-=r.z,this}subVectors(r,e){return this.x=r.x-e.x,this.y=r.y-e.y,this.z=r.z-e.z,this}multiplyScalar(r){return this.x*=r,this.y*=r,this.z*=r,this}divideScalar(r){return r!==0?(this.x/=r,this.y/=r,this.z/=r):(this.x=0,this.y=0,this.z=0),this}max(r){return this.x=Math.max(this.x,r.x),this.y=Math.max(this.y,r.y),this.z=Math.max(this.z,r.z),this}min(r){return this.x=Math.min(this.x,r.x),this.y=Math.min(this.y,r.y),this.z=Math.min(this.z,r.z),this}distanceTo(r){return Math.sqrt(this.distanceToSquared(r))}distanceToSquared(r){const e=this.x-r.x,t=this.y-r.y,s=this.z-r.z;return e*e+t*t+s*s}applyMatrix3(r){const{x:e}=this,{y:t}=this,{z:s}=this,o=r.elements;return this.x=o[0]*e+o[3]*t+o[6]*s,this.y=o[1]*e+o[4]*t+o[7]*s,this.z=o[2]*e+o[5]*t+o[8]*s,this}applyMatrix4(r){const{x:e}=this,{y:t}=this,{z:s}=this,o=r.elements;return this.x=o[0]*e+o[4]*t+o[8]*s+o[12],this.y=o[1]*e+o[5]*t+o[9]*s+o[13],this.z=o[2]*e+o[6]*t+o[10]*s+o[14],this}applyProjection(r){const{x:e}=this,{y:t}=this,{z:s}=this,o=r.elements,l=o[3]*e+o[7]*t+o[11]*s+o[15];return this.x=(o[0]*e+o[4]*t+o[8]*s+o[12])/l,this.y=(o[1]*e+o[5]*t+o[9]*s+o[13])/l,this.z=(o[2]*e+o[6]*t+o[10]*s+o[14])/l,this}applyQuaternion(r){const{x:e}=this,{y:t}=this,{z:s}=this,o=r.x,l=r.y,d=r.z,i=r.w,n={};n.x=2*(t*d-s*l),n.y=2*(s*o-e*d),n.z=2*(e*l-t*o);const a={};return a.x=n.y*d-n.z*l,a.y=n.z*o-n.x*d,a.z=n.x*l-n.y*o,this.x=e+i*n.x+a.x,this.y=t+i*n.y+a.y,this.z=s+i*n.z+a.z,this}negate(){return this.multiplyScalar(-1)}dot(r){return this.x*r.x+this.y*r.y+this.z*r.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(r){const{x:e}=this,{y:t}=this,{z:s}=this;return this.x=t*r.z-s*r.y,this.y=s*r.x-e*r.z,this.z=e*r.y-t*r.x,this}crossVectors(r,e){return this.x=r.y*e.z-r.z*e.y,this.y=r.z*e.x-r.x*e.z,this.z=r.x*e.y-r.y*e.x,this}equals(r){return this.x==r.x&&this.y==r.y&&this.z==r.z}getPositionFromMatrix(r){return this.x=r.elements[12],this.y=r.elements[13],this.z=r.elements[14],this}setEulerFromRotationMatrix(r,e){const t=r.elements,s=t[0],o=t[4],l=t[8],d=t[5],i=t[9],n=t[6],a=t[10];return e===void 0||e==="XYZ"?(this.y=Math.asin((0,O.clamp)(l,-1,1)),Math.abs(l)<.99999?(this.x=Math.atan2(-i,a),this.z=Math.atan2(-o,s)):(this.x=Math.atan2(n,d),this.z=0)):console.error(`Error with vector's setEulerFromRotationMatrix: Unknown order: ${e}`),this}rotateAboutVector(r,e){r.normalize();const t=Math.cos(e),s=Math.sin(e),o=this.clone().multiplyScalar(t),l=r.clone().cross(this).multiplyScalar(s),d=r.clone().multiplyScalar(r.clone().dot(this)).multiplyScalar(1-t),i=o.add(l).add(d);return this.x=i.x,this.y=i.y,this.z=i.z,this}setFromMatrixPosition(r){const e=r.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}transformDirection(r){const{x:e}=this,{y:t}=this,{z:s}=this,o=r.elements;return this.x=o[0]*e+o[4]*t+o[8]*s,this.y=o[1]*e+o[5]*t+o[9]*s,this.z=o[2]*e+o[6]*t+o[10]*s,this.normalize()}clone(){return new x(this.x,this.y,this.z)}unproject(r){const e=C;return e.multiplyMatrices(r.matrixWorld,e.getInverse(r.projectionMatrix)),this.applyMatrix4(e)}}v=new x,y=new x,M=new x;class _{constructor(r=1,e=0,t=0,s=0,o=1,l=0,d=0,i=0,n=1){this.elements=new Float32Array(9),this.set(r,e,t,s,o,l,d,i,n)}set(r,e,t,s,o,l,d,i,n){const a=this.elements;return a[0]=r,a[3]=e,a[6]=t,a[1]=s,a[4]=o,a[7]=l,a[2]=d,a[5]=i,a[8]=n,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(r){const e=r.elements;this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8])}multiplyScalar(r){const e=this.elements;return e[0]*=r,e[3]*=r,e[6]*=r,e[1]*=r,e[4]*=r,e[7]*=r,e[2]*=r,e[5]*=r,e[8]*=r,this}getInverse3(r){const e=r.elements,t=this.elements;t[0]=e[4]*e[8]-e[5]*e[7],t[3]=e[6]*e[5]-e[3]*e[8],t[6]=e[3]*e[7]-e[6]*e[4],t[1]=e[7]*e[2]-e[1]*e[8],t[4]=e[0]*e[8]-e[6]*e[2],t[7]=e[1]*e[6]-e[0]*e[7],t[2]=e[1]*e[5]-e[2]*e[4],t[5]=e[2]*e[3]-e[0]*e[5],t[8]=e[0]*e[4]-e[1]*e[3];const s=e[0]*t[0]+e[3]*t[1]+e[6]*t[2];return this.multiplyScalar(1/s),this}getInverse(r,e){const t=r.elements,s=this.elements;s[0]=t[10]*t[5]-t[6]*t[9],s[1]=-t[10]*t[1]+t[2]*t[9],s[2]=t[6]*t[1]-t[2]*t[5],s[3]=-t[10]*t[4]+t[6]*t[8],s[4]=t[10]*t[0]-t[2]*t[8],s[5]=-t[6]*t[0]+t[2]*t[4],s[6]=t[9]*t[4]-t[5]*t[8],s[7]=-t[9]*t[0]+t[1]*t[8],s[8]=t[5]*t[0]-t[1]*t[4];const o=t[0]*s[0]+t[1]*s[3]+t[2]*s[6];if(o===0){const l="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(l);return console.warn(l),this.identity(),this}return this.multiplyScalar(1/o),this}getDeterminant(){const r=this.elements;return r[0]*r[4]*r[8]+r[1]*r[5]*r[6]+r[2]*r[3]*r[7]-r[2]*r[4]*r[6]-r[1]*r[3]*r[8]-r[0]*r[5]*r[7]}transpose(){let r;const e=this.elements;return r=e[1],e[1]=e[3],e[3]=r,r=e[2],e[2]=e[6],e[6]=r,r=e[5],e[5]=e[7],e[7]=r,this}clone(){const r=this.elements;return new _(r[0],r[3],r[6],r[1],r[4],r[7],r[2],r[5],r[8])}getMatrix4(){const r=this.elements;return new g(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0)}}class p{constructor(r,e){this.origin=r!==void 0?r:new x,this.direction=e!==void 0?e:new x}set(r,e){return this.origin.copy(r),this.direction.copy(e),this}copy(r){return this.origin.copy(r.origin),this.direction.copy(r.direction),this}at(r,e){return(e||new x).copy(this.direction).multiplyScalar(r).add(this.origin)}recast(r){const e=v;return this.origin.copy(this.at(r,e)),this}closestPointToPoint(r,e){const t=e||new x;t.subVectors(r,this.origin);const s=t.dot(this.direction);return t.copy(this.direction).multiplyScalar(s).add(this.origin)}distanceToPoint(r){const e=v,t=e.subVectors(r,this.origin).dot(this.direction);return e.copy(this.direction).multiplyScalar(t).add(this.origin),e.distanceTo(r)}isIntersectionCylinder(){}isIntersectionSphere(r){return this.distanceToPoint(r.center)<=r.radius}isIntersectionPlane(r){return r.normal.dot(this.direction)!==0||r.distanceToPoint(this.origin)===0}distanceToPlane(r){const e=r.normal.dot(this.direction);return e===0?r.distanceToPoint(this.origin)===0?0:void 0:-(this.origin.dot(r.normal)+r.constant)/e}intersectPlane(r,e){const t=this.distanceToPlane(r);if(t!==void 0)return this.at(t,e)}applyMatrix4(r){return this.direction.add(this.origin).applyMatrix4(r),this.origin.applyMatrix4(r),this.direction.sub(this.origin),this}clone(){return new p().copy(this)}}},"./src/WebGL/math/utils/clamp.ts"(k,w,c){c.r(w),c.d(w,{clamp:()=>b});function b(O,C,R){return Math.min(Math.max(O,C),R)}},"./src/WebGL/math/utils/conversionMatrix3.ts"(k,w,c){c.r(w),c.d(w,{conversionMatrix3:()=>O});var b=c("./src/WebGL/math/math.ts");function O(C,R,v,y,M,g){y=y*Math.PI/180,M=M*Math.PI/180,g=g*Math.PI/180;const x=t=>t*t,_=Math.cos(y),p=Math.cos(M),m=Math.cos(g),r=Math.sin(g);return new b.Matrix3(C,R*m,v*p,0,R*r,v*(_-p*m)/r,0,0,v*Math.sqrt(1-x(_)-x(p)-x(m)+2*_*p*m)/r)}},"./src/WebGL/math/utils/degToRad.ts"(k,w,c){c.r(w),c.d(w,{degToRad:()=>O});const b=Math.PI/180;function O(C){return C*b}},"./src/WebGL/objects/Line.ts"(k,w,c){c.r(w),c.d(w,{Line:()=>R,LineStyle:()=>C});var b=c("./src/WebGL/materials/index.ts"),O=c("./src/WebGL/core/index.ts"),C;(function(v){v[v.LineStrip=0]="LineStrip",v[v.LinePieces=1]="LinePieces"})(C||(C={}));class R extends O.Object3D{constructor(y,M=new b.LineBasicMaterial({color:Math.random()*16777215}),g=C.LineStrip){super(),this.geometry=y,this.material=M,this.type=g}clone(y=new R(this.geometry,this.material,this.type)){return super.clone.call(this,y),y}}},"./src/WebGL/objects/Mesh.ts"(k,w,c){c.r(w),c.d(w,{Mesh:()=>O});var b=c("./src/WebGL/core/index.ts");class O extends b.Object3D{constructor(R,v){super(),this.geometry=R,this.material=v}clone(R){return R===void 0&&(R=new O(this.geometry,this.material)),super.clone.call(this,R),R}}},"./src/WebGL/objects/Sprite.ts"(k,w,c){c.r(w),c.d(w,{Sprite:()=>C});var b=c("./src/WebGL/materials/index.ts"),O=c("./src/WebGL/core/index.ts");class C extends O.Object3D{constructor(v=new b.SpriteMaterial){super(),this.material=v,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),(this.scale.x!==1||this.scale.y!==1)&&this.matrix.scale(this.scale),this.matrixWorldNeedsUpdate=!0}clone(v=new C(this.material)){return O.Object3D.prototype.clone.call(this,v),v}}},"./src/WebGL/objects/index.ts"(k,w,c){c.r(w),c.d(w,{Line:()=>b.Line,LineStyle:()=>b.LineStyle,Mesh:()=>O.Mesh,Sprite:()=>C.Sprite});var b=c("./src/WebGL/objects/Line.ts"),O=c("./src/WebGL/objects/Mesh.ts"),C=c("./src/WebGL/objects/Sprite.ts")},"./src/WebGL/shaders/ShaderType.ts"(k,w,c){c.r(w)},"./src/WebGL/shaders/index.ts"(k,w,c){c.r(w),c.d(w,{ShaderLib:()=>b.ShaderLib,ShaderUtils:()=>O.ShaderUtils,basic:()=>b.basic,clone:()=>O.clone,instanced:()=>b.instanced,lambert:()=>b.lambert,lambertdouble:()=>b.lambertdouble,outline:()=>b.outline,ringimposter:()=>b.ringimposter,screen:()=>b.screen,screenaa:()=>b.screenaa,sphereimposter:()=>b.sphereimposter,sphereimposteroutline:()=>b.sphereimposteroutline,sprite:()=>b.sprite,stickimposter:()=>b.stickimposter,stickimposteroutline:()=>b.stickimposteroutline,volumetric:()=>b.volumetric});var b=c("./src/WebGL/shaders/lib/index.ts"),O=c("./src/WebGL/shaders/utils/index.ts");c("./src/WebGL/shaders/ShaderType.ts")},"./src/WebGL/shaders/lib/basic/basic.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 viewMatrix;
|
|
89
|
+
uniform float opacity;
|
|
90
|
+
uniform vec3 fogColor;
|
|
91
|
+
uniform float fogNear;
|
|
92
|
+
uniform float fogFar;
|
|
93
|
+
varying vec3 vColor;
|
|
94
|
+
varying vec4 mvPosition;
|
|
95
|
+
|
|
96
|
+
//DEFINEFRAGCOLOR
|
|
97
|
+
void main() {
|
|
98
|
+
gl_FragColor = vec4( vColor, opacity );
|
|
99
|
+
if(fogNear != fogFar) {
|
|
100
|
+
float depth = -mvPosition.z;
|
|
101
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
102
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
103
|
+
}
|
|
104
|
+
}`},"./src/WebGL/shaders/lib/basic/basic.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 modelViewMatrix;
|
|
105
|
+
uniform mat4 projectionMatrix;
|
|
106
|
+
uniform mat4 viewMatrix;
|
|
107
|
+
uniform mat3 normalMatrix;
|
|
108
|
+
|
|
109
|
+
attribute vec3 position;
|
|
110
|
+
attribute vec3 color;
|
|
111
|
+
|
|
112
|
+
varying vec3 vColor;
|
|
113
|
+
varying vec4 mvPosition;
|
|
114
|
+
|
|
115
|
+
void main() {
|
|
116
|
+
|
|
117
|
+
vColor = color;
|
|
118
|
+
mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
119
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
120
|
+
|
|
121
|
+
}`},"./src/WebGL/shaders/lib/basic/index.ts"(k,w,c){c.r(w),c.d(w,{basic:()=>R});var b=c("./src/WebGL/shaders/lib/basic/uniforms.ts"),O=c("./src/WebGL/shaders/lib/basic/basic.frag"),C=c("./src/WebGL/shaders/lib/basic/basic.vert");const R={vertexShader:C.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/basic/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3}}},"./src/WebGL/shaders/lib/blur/blur.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`const float INV_TOTAL_SAMPLES_FACTOR = 1.0 / 9.0;
|
|
122
|
+
uniform highp sampler2D inTex;
|
|
123
|
+
varying highp vec2 vTexCoords;
|
|
124
|
+
|
|
125
|
+
void main() {
|
|
126
|
+
|
|
127
|
+
vec2 texelSize = 1.0 / vec2(textureSize(inTex,0));
|
|
128
|
+
float blurred_visibility_factor = 0.0f;
|
|
129
|
+
for (int t = -1; t <= 1; ++t) {
|
|
130
|
+
for (int s = -1; s <= 1; ++s) {
|
|
131
|
+
vec2 offset = vec2(float(s), float(t)) * texelSize;
|
|
132
|
+
blurred_visibility_factor += texture2D(inTex, vTexCoords + offset).r;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
gl_FragDepthEXT = blurred_visibility_factor * INV_TOTAL_SAMPLES_FACTOR;
|
|
137
|
+
|
|
138
|
+
}`},"./src/WebGL/shaders/lib/blur/blur.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`attribute vec2 vertexPosition;
|
|
139
|
+
varying highp vec2 vTexCoords;
|
|
140
|
+
const vec2 scale = vec2(0.5, 0.5);
|
|
141
|
+
|
|
142
|
+
void main() {
|
|
143
|
+
vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
|
|
144
|
+
gl_Position = vec4(vertexPosition, 0.0, 1.0);
|
|
145
|
+
}
|
|
146
|
+
`},"./src/WebGL/shaders/lib/blur/index.ts"(k,w,c){c.r(w),c.d(w,{blur:()=>R});var b=c("./src/WebGL/shaders/lib/blur/uniforms.ts"),O=c("./src/WebGL/shaders/lib/blur/blur.frag"),C=c("./src/WebGL/shaders/lib/blur/blur.vert");const R={fragmentShader:O.default,vertexShader:C.default,uniforms:b.uniforms}},"./src/WebGL/shaders/lib/blur/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>b});const b={}},"./src/WebGL/shaders/lib/index.ts"(k,w,c){c.r(w),c.d(w,{ShaderLib:()=>o,basic:()=>b.basic,instanced:()=>O.instanced,lambert:()=>C.lambert,lambertdouble:()=>R.lambertdouble,outline:()=>v.outline,ringimposter:()=>g.ringimposter,screen:()=>y.screen,screenaa:()=>M.screenaa,sphereimposter:()=>x.sphereimposter,sphereimposteroutline:()=>_.sphereimposteroutline,sprite:()=>p.sprite,stickimposter:()=>m.stickimposter,stickimposteroutline:()=>r.stickimposteroutline,volumetric:()=>e.volumetric});var b=c("./src/WebGL/shaders/lib/basic/index.ts"),O=c("./src/WebGL/shaders/lib/instanced/index.ts"),C=c("./src/WebGL/shaders/lib/lambert/index.ts"),R=c("./src/WebGL/shaders/lib/lambertdouble/index.ts"),v=c("./src/WebGL/shaders/lib/outline/index.ts"),y=c("./src/WebGL/shaders/lib/screen/index.ts"),M=c("./src/WebGL/shaders/lib/screenaa/index.ts"),g=c("./src/WebGL/shaders/lib/ringimposter/index.ts"),x=c("./src/WebGL/shaders/lib/sphereimposter/index.ts"),_=c("./src/WebGL/shaders/lib/sphereimposteroutline/index.ts"),p=c("./src/WebGL/shaders/lib/sprite/index.ts"),m=c("./src/WebGL/shaders/lib/stickimposter/index.ts"),r=c("./src/WebGL/shaders/lib/stickimposteroutline/index.ts"),e=c("./src/WebGL/shaders/lib/volumetric/index.ts"),t=c("./src/WebGL/shaders/lib/ssao/index.ts"),s=c("./src/WebGL/shaders/lib/blur/index.ts");const o={basic:b.basic,blur:s.blur,instanced:O.instanced,lambert:C.lambert,lambertdouble:R.lambertdouble,outline:v.outline,screen:y.screen,screenaa:M.screenaa,ssao:t.ssao,ringimposter:g.ringimposter,sphereimposter:x.sphereimposter,sphereimposteroutline:_.sphereimposteroutline,sprite:p.sprite,stickimposter:m.stickimposter,stickimposteroutline:r.stickimposteroutline,volumetric:e.volumetric}},"./src/WebGL/shaders/lib/instanced/index.ts"(k,w,c){c.r(w),c.d(w,{instanced:()=>R});var b=c("./src/WebGL/shaders/lib/instanced/uniforms.ts"),O=c("./src/WebGL/shaders/lib/instanced/instanced.frag"),C=c("./src/WebGL/shaders/lib/instanced/instanced.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/instanced/instanced.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 viewMatrix;
|
|
147
|
+
uniform float opacity;
|
|
148
|
+
|
|
149
|
+
uniform vec3 fogColor;
|
|
150
|
+
uniform float fogNear;
|
|
151
|
+
uniform float fogFar;
|
|
152
|
+
#ifdef SHADED
|
|
153
|
+
uniform highp sampler2D shading;
|
|
154
|
+
#endif
|
|
155
|
+
varying vec3 vLightFront;
|
|
156
|
+
varying vec3 vColor;
|
|
157
|
+
//DEFINEFRAGCOLOR
|
|
158
|
+
|
|
159
|
+
void main() {
|
|
160
|
+
|
|
161
|
+
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
|
|
162
|
+
|
|
163
|
+
#ifndef WIREFRAME
|
|
164
|
+
gl_FragColor.xyz *= vLightFront;
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
#ifdef SHADED
|
|
168
|
+
ivec2 dim = textureSize(shading,0);
|
|
169
|
+
float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;
|
|
170
|
+
vColor *= shadowFactor;
|
|
171
|
+
#endif
|
|
172
|
+
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
|
|
173
|
+
float depth = gl_FragCoord.z / gl_FragCoord.w;
|
|
174
|
+
|
|
175
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
176
|
+
|
|
177
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
`},"./src/WebGL/shaders/lib/instanced/instanced.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
183
|
+
|
|
184
|
+
uniform mat4 modelViewMatrix;
|
|
185
|
+
uniform mat4 projectionMatrix;
|
|
186
|
+
uniform mat4 viewMatrix;
|
|
187
|
+
uniform mat3 normalMatrix;
|
|
188
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
189
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
190
|
+
|
|
191
|
+
attribute vec3 offset;
|
|
192
|
+
attribute vec3 position;
|
|
193
|
+
attribute vec3 normal;
|
|
194
|
+
attribute vec3 color;
|
|
195
|
+
attribute float radius;
|
|
196
|
+
|
|
197
|
+
varying vec3 vColor;
|
|
198
|
+
varying vec3 vLightFront;
|
|
199
|
+
|
|
200
|
+
void main() {
|
|
201
|
+
|
|
202
|
+
vColor = color;
|
|
203
|
+
|
|
204
|
+
vec3 objectNormal = normal;
|
|
205
|
+
vec3 transformedNormal = normalMatrix * objectNormal;
|
|
206
|
+
vec4 mvPosition = modelViewMatrix * vec4( position * radius + offset, 1.0 );
|
|
207
|
+
|
|
208
|
+
vLightFront = vec3( 0.0 );
|
|
209
|
+
|
|
210
|
+
transformedNormal = normalize( transformedNormal );
|
|
211
|
+
|
|
212
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
213
|
+
vec3 dirVector = normalize( lDirection.xyz );
|
|
214
|
+
float dotProduct = dot( transformedNormal, dirVector );
|
|
215
|
+
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
|
216
|
+
|
|
217
|
+
vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
|
|
218
|
+
|
|
219
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
`},"./src/WebGL/shaders/lib/instanced/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/lambert/index.ts"(k,w,c){c.r(w),c.d(w,{lambert:()=>R});var b=c("./src/WebGL/shaders/lib/lambert/uniforms.ts"),O=c("./src/WebGL/shaders/lib/lambert/lambert.frag"),C=c("./src/WebGL/shaders/lib/lambert/lambert.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/lambert/lambert.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 viewMatrix;
|
|
223
|
+
uniform float opacity;
|
|
224
|
+
|
|
225
|
+
uniform vec3 fogColor;
|
|
226
|
+
uniform float fogNear;
|
|
227
|
+
uniform float fogFar;
|
|
228
|
+
#ifdef SHADED
|
|
229
|
+
uniform highp sampler2D shading;
|
|
230
|
+
#endif
|
|
231
|
+
varying vec3 vLightFront;
|
|
232
|
+
varying vec3 vColor;
|
|
233
|
+
varying vec4 mvPosition;
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
//DEFINEFRAGCOLOR
|
|
237
|
+
|
|
238
|
+
void main() {
|
|
239
|
+
|
|
240
|
+
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
|
|
241
|
+
|
|
242
|
+
#ifndef WIREFRAME
|
|
243
|
+
gl_FragColor.xyz *= vLightFront;
|
|
244
|
+
#endif
|
|
245
|
+
#ifdef SHADED
|
|
246
|
+
ivec2 dim = textureSize(shading,0);
|
|
247
|
+
float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;
|
|
248
|
+
vColor *= shadowFactor;
|
|
249
|
+
#endif
|
|
250
|
+
gl_FragColor = gl_FragColor * vec4( vColor, opacity );
|
|
251
|
+
|
|
252
|
+
if(fogNear != fogFar) {
|
|
253
|
+
float depth = -mvPosition.z;
|
|
254
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
255
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
}`},"./src/WebGL/shaders/lib/lambert/lambert.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
259
|
+
uniform mat4 modelViewMatrix;
|
|
260
|
+
uniform mat4 projectionMatrix;
|
|
261
|
+
uniform mat4 viewMatrix;
|
|
262
|
+
uniform mat3 normalMatrix;
|
|
263
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
264
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
265
|
+
|
|
266
|
+
attribute vec3 position;
|
|
267
|
+
attribute vec3 normal;
|
|
268
|
+
attribute vec3 color;
|
|
269
|
+
|
|
270
|
+
varying vec3 vColor;
|
|
271
|
+
varying vec3 vLightFront;
|
|
272
|
+
varying vec4 mvPosition;
|
|
273
|
+
|
|
274
|
+
void main() {
|
|
275
|
+
|
|
276
|
+
vColor = color;
|
|
277
|
+
|
|
278
|
+
vec3 objectNormal = normal;
|
|
279
|
+
vec3 transformedNormal = normalMatrix * objectNormal;
|
|
280
|
+
mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
281
|
+
|
|
282
|
+
vLightFront = vec3( 0.0 );
|
|
283
|
+
|
|
284
|
+
transformedNormal = normalize( transformedNormal );
|
|
285
|
+
|
|
286
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
287
|
+
vec3 dirVector = normalize( lDirection.xyz );
|
|
288
|
+
float dotProduct = dot( transformedNormal, dirVector );
|
|
289
|
+
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
|
290
|
+
|
|
291
|
+
vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
|
|
292
|
+
|
|
293
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
294
|
+
}`},"./src/WebGL/shaders/lib/lambert/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/lambertdouble/index.ts"(k,w,c){c.r(w),c.d(w,{lambertdouble:()=>R});var b=c("./src/WebGL/shaders/lib/lambertdouble/uniforms.ts"),O=c("./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag"),C=c("./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
295
|
+
#ifdef SHADED
|
|
296
|
+
uniform highp sampler2D shading;
|
|
297
|
+
#endif
|
|
298
|
+
|
|
299
|
+
uniform mat4 viewMatrix;
|
|
300
|
+
uniform float opacity;
|
|
301
|
+
|
|
302
|
+
uniform vec3 fogColor;
|
|
303
|
+
uniform float fogNear;
|
|
304
|
+
uniform float fogFar;
|
|
305
|
+
|
|
306
|
+
varying vec3 vLightFront;
|
|
307
|
+
varying vec3 vLightBack;
|
|
308
|
+
|
|
309
|
+
varying vec3 vColor;
|
|
310
|
+
varying vec4 mvPosition;
|
|
311
|
+
|
|
312
|
+
//DEFINEFRAGCOLOR
|
|
313
|
+
|
|
314
|
+
void main() {
|
|
315
|
+
|
|
316
|
+
gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
|
|
317
|
+
|
|
318
|
+
#ifndef WIREFRAME
|
|
319
|
+
if ( gl_FrontFacing )
|
|
320
|
+
gl_FragColor.xyz *= vLightFront;
|
|
321
|
+
else
|
|
322
|
+
gl_FragColor.xyz *= vLightBack;
|
|
323
|
+
#endif
|
|
324
|
+
|
|
325
|
+
vec3 color = vColor;
|
|
326
|
+
#ifdef SHADED
|
|
327
|
+
ivec2 dim = textureSize(shading,0);
|
|
328
|
+
float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;
|
|
329
|
+
color *= shadowFactor;
|
|
330
|
+
#endif
|
|
331
|
+
gl_FragColor = gl_FragColor * vec4( color, opacity );
|
|
332
|
+
|
|
333
|
+
if(fogNear != fogFar) {
|
|
334
|
+
float depth = -mvPosition.z;
|
|
335
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
336
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
`},"./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
343
|
+
|
|
344
|
+
uniform mat4 modelViewMatrix;
|
|
345
|
+
uniform mat4 projectionMatrix;
|
|
346
|
+
uniform mat4 viewMatrix;
|
|
347
|
+
uniform mat3 normalMatrix;
|
|
348
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
349
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
350
|
+
|
|
351
|
+
attribute vec3 position;
|
|
352
|
+
attribute vec3 normal;
|
|
353
|
+
attribute vec3 color;
|
|
354
|
+
|
|
355
|
+
varying vec3 vColor;
|
|
356
|
+
varying vec3 vLightFront;
|
|
357
|
+
varying vec3 vLightBack;
|
|
358
|
+
varying vec4 mvPosition;
|
|
359
|
+
|
|
360
|
+
void main() {
|
|
361
|
+
|
|
362
|
+
vColor = color;
|
|
363
|
+
|
|
364
|
+
vec3 objectNormal = normal;
|
|
365
|
+
vec3 transformedNormal = normalMatrix * objectNormal;
|
|
366
|
+
mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
367
|
+
|
|
368
|
+
vLightFront = vec3( 0.0 );
|
|
369
|
+
vLightBack = vec3( 0.0 );
|
|
370
|
+
|
|
371
|
+
transformedNormal = normalize( transformedNormal );
|
|
372
|
+
|
|
373
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
374
|
+
vec3 dirVector = normalize( lDirection.xyz );
|
|
375
|
+
float dotProduct = dot( transformedNormal, dirVector );
|
|
376
|
+
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
|
377
|
+
vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
|
|
378
|
+
|
|
379
|
+
vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
|
|
380
|
+
vLightBack += directionalLightColor[ 0 ] * directionalLightWeightingBack;
|
|
381
|
+
|
|
382
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
`},"./src/WebGL/shaders/lib/lambertdouble/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/outline/index.ts"(k,w,c){c.r(w),c.d(w,{outline:()=>R});var b=c("./src/WebGL/shaders/lib/outline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/outline/outline.frag"),C=c("./src/WebGL/shaders/lib/outline/outline.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/outline/outline.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
386
|
+
|
|
387
|
+
uniform float opacity;
|
|
388
|
+
uniform vec3 outlineColor;
|
|
389
|
+
uniform vec3 fogColor;
|
|
390
|
+
uniform float fogNear;
|
|
391
|
+
uniform float fogFar;
|
|
392
|
+
|
|
393
|
+
varying vec4 mvPosition;
|
|
394
|
+
//DEFINEFRAGCOLOR
|
|
395
|
+
|
|
396
|
+
void main() {
|
|
397
|
+
gl_FragColor = vec4( outlineColor, 1 );
|
|
398
|
+
|
|
399
|
+
if(fogNear != fogFar) {
|
|
400
|
+
float depth = -mvPosition.z;
|
|
401
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
402
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
`},"./src/WebGL/shaders/lib/outline/outline.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
408
|
+
|
|
409
|
+
uniform mat4 modelViewMatrix;
|
|
410
|
+
uniform mat4 projectionMatrix;
|
|
411
|
+
uniform float outlineWidth;
|
|
412
|
+
uniform float outlinePushback;
|
|
413
|
+
uniform float vWidth;
|
|
414
|
+
uniform float vHeight;
|
|
415
|
+
uniform float outlineMaxPixels;
|
|
416
|
+
|
|
417
|
+
attribute vec3 position;
|
|
418
|
+
attribute vec3 normal;
|
|
419
|
+
attribute vec3 color;
|
|
420
|
+
|
|
421
|
+
varying vec4 mvPosition;
|
|
422
|
+
|
|
423
|
+
void main() {
|
|
424
|
+
|
|
425
|
+
vec4 norm = modelViewMatrix*vec4(normalize(normal),0.0);
|
|
426
|
+
mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
427
|
+
mvPosition.xy += norm.xy*outlineWidth;
|
|
428
|
+
vec4 outpos = projectionMatrix * mvPosition;
|
|
429
|
+
|
|
430
|
+
if(outlineMaxPixels > 0.0) {
|
|
431
|
+
vec4 unadjusted = projectionMatrix*modelViewMatrix * vec4( position, 1.0 );
|
|
432
|
+
float w = outpos.w;
|
|
433
|
+
//normalize homogeneous coords
|
|
434
|
+
unadjusted /= unadjusted.w;
|
|
435
|
+
outpos /= outpos.w;
|
|
436
|
+
vec2 diff = outpos.xy-unadjusted.xy;
|
|
437
|
+
//put into pixels
|
|
438
|
+
diff.x *= vWidth;
|
|
439
|
+
diff.y *= vHeight;
|
|
440
|
+
if ( length(diff) > outlineMaxPixels) {
|
|
441
|
+
vec2 ndiff = normalize(diff)*outlineMaxPixels;
|
|
442
|
+
ndiff.x /= vWidth;
|
|
443
|
+
ndiff.y /= vHeight;
|
|
444
|
+
outpos.xy = unadjusted.xy;
|
|
445
|
+
outpos.xy += ndiff;
|
|
446
|
+
}
|
|
447
|
+
outpos *= w; //if I don't do this things blow up
|
|
448
|
+
}
|
|
449
|
+
gl_Position = outpos;
|
|
450
|
+
mvPosition.z -= outlinePushback; //go backwards in model space
|
|
451
|
+
vec4 pushpos = projectionMatrix*mvPosition; //project to get z in projection space, I'm probably missing some simple math to do the same thing..
|
|
452
|
+
gl_Position.z = gl_Position.w*pushpos.z/pushpos.w;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
`},"./src/WebGL/shaders/lib/outline/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new b.Color(0,0,0)},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1},outlineMaxPixels:{type:"f",value:0}}},"./src/WebGL/shaders/lib/ringimposter/index.ts"(k,w,c){c.r(w),c.d(w,{ringimposter:()=>R});var b=c("./src/WebGL/shaders/lib/ringimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/ringimposter/ringimposter.frag"),C=c("./src/WebGL/shaders/lib/ringimposter/ringimposter.vert");const R={vertexShader:C.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/ringimposter/ringimposter.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
456
|
+
uniform float opacity;
|
|
457
|
+
uniform mat4 projectionMatrix;
|
|
458
|
+
|
|
459
|
+
uniform vec3 fogColor;
|
|
460
|
+
uniform float fogNear;
|
|
461
|
+
uniform float fogFar;
|
|
462
|
+
|
|
463
|
+
varying vec3 vColor;
|
|
464
|
+
varying vec2 mapping;
|
|
465
|
+
varying float vOuterR;
|
|
466
|
+
varying float vMinorR;
|
|
467
|
+
varying vec3 vLight;
|
|
468
|
+
varying vec3 center;
|
|
469
|
+
varying vec3 vRingNormal;
|
|
470
|
+
|
|
471
|
+
//DEFINEFRAGCOLOR
|
|
472
|
+
|
|
473
|
+
void main() {
|
|
474
|
+
float majorR = vOuterR - vMinorR;
|
|
475
|
+
|
|
476
|
+
// The fragment represents a view ray at screen position (center.xy + mapping).
|
|
477
|
+
// Intersect this ray with the ring plane to find the in-plane distance.
|
|
478
|
+
// Ring plane: dot(P - center, vRingNormal) = 0
|
|
479
|
+
// Ray: P = (center.x + mapping.x, center.y + mapping.y, center.z + t)
|
|
480
|
+
// Solution: mapping.x*nx + mapping.y*ny + t*nz = 0 => t = -a/nz
|
|
481
|
+
float a = mapping.x * vRingNormal.x + mapping.y * vRingNormal.y;
|
|
482
|
+
float nz = vRingNormal.z;
|
|
483
|
+
|
|
484
|
+
// Clamp |nz| to avoid singularity for edge-on rings
|
|
485
|
+
float nzSafe = nz;
|
|
486
|
+
if (abs(nzSafe) < 0.01) nzSafe = (nzSafe >= 0.0) ? 0.01 : -0.01;
|
|
487
|
+
float zHit = -a / nzSafe;
|
|
488
|
+
|
|
489
|
+
// In-ring-plane distance from center
|
|
490
|
+
// hitPoint = (mapping.x, mapping.y, zHit) is in the ring plane by construction
|
|
491
|
+
float dFromCenterSq = mapping.x * mapping.x + mapping.y * mapping.y + zHit * zHit;
|
|
492
|
+
float dFromCenter = sqrt(dFromCenterSq);
|
|
493
|
+
|
|
494
|
+
// Distance from ring centerline (in ring plane)
|
|
495
|
+
float dRadial = dFromCenter - majorR;
|
|
496
|
+
|
|
497
|
+
// Tube test
|
|
498
|
+
if (dRadial * dRadial > vMinorR * vMinorR)
|
|
499
|
+
discard;
|
|
500
|
+
|
|
501
|
+
// Tube cross-section height
|
|
502
|
+
float tubeZ = sqrt(max(0.0, vMinorR * vMinorR - dRadial * dRadial));
|
|
503
|
+
|
|
504
|
+
// Always render the front surface (closest to camera).
|
|
505
|
+
// The tube extends ±tubeZ along vRingNormal from the ring plane.
|
|
506
|
+
// When vRingNormal.z > 0, +tubeZ is toward camera; when < 0, -tubeZ is.
|
|
507
|
+
float tubeSign = (vRingNormal.z >= 0.0) ? 1.0 : -1.0;
|
|
508
|
+
|
|
509
|
+
// Direction from center to the ring-plane hit point (normalized)
|
|
510
|
+
vec3 hitPoint = vec3(mapping.x, mapping.y, zHit);
|
|
511
|
+
vec3 radDir = (dFromCenter > 0.0001) ? hitPoint / dFromCenter : vec3(1.0, 0.0, 0.0);
|
|
512
|
+
|
|
513
|
+
// Surface normal: radial component + tube bulge toward viewer
|
|
514
|
+
vec3 norm = normalize(dRadial * radDir + tubeSign * tubeZ * vRingNormal);
|
|
515
|
+
|
|
516
|
+
// Surface position: ring-plane intersection + tube bulge toward viewer
|
|
517
|
+
vec3 surfacePos = center + hitPoint + tubeSign * tubeZ * vRingNormal;
|
|
518
|
+
|
|
519
|
+
vec4 clipPos = projectionMatrix * vec4(surfacePos, 1.0);
|
|
520
|
+
float ndcDepth = clipPos.z / clipPos.w;
|
|
521
|
+
gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
|
522
|
+
|
|
523
|
+
float dotProduct = dot( norm, vLight );
|
|
524
|
+
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
|
525
|
+
vec3 vLightResult = directionalLightWeighting;
|
|
526
|
+
vec3 color = vLightResult * vColor;
|
|
527
|
+
gl_FragColor = vec4(color, opacity * opacity);
|
|
528
|
+
|
|
529
|
+
if(fogNear != fogFar) {
|
|
530
|
+
float depth = -surfacePos.z;
|
|
531
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
532
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
`},"./src/WebGL/shaders/lib/ringimposter/ringimposter.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 modelViewMatrix;
|
|
537
|
+
uniform mat4 projectionMatrix;
|
|
538
|
+
uniform mat4 viewMatrix;
|
|
539
|
+
uniform mat3 normalMatrix;
|
|
540
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
541
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
542
|
+
|
|
543
|
+
attribute vec3 position;
|
|
544
|
+
attribute vec3 normal;
|
|
545
|
+
attribute vec3 color;
|
|
546
|
+
attribute float radius;
|
|
547
|
+
|
|
548
|
+
varying vec2 mapping;
|
|
549
|
+
varying vec3 vColor;
|
|
550
|
+
varying float vOuterR;
|
|
551
|
+
varying float vMinorR;
|
|
552
|
+
varying vec3 vLight;
|
|
553
|
+
varying vec3 center;
|
|
554
|
+
varying vec3 vRingNormal;
|
|
555
|
+
|
|
556
|
+
void main() {
|
|
557
|
+
|
|
558
|
+
// Decode: normal direction = ring plane normal, length = minorR
|
|
559
|
+
vMinorR = length(normal);
|
|
560
|
+
vec3 ringNormalObj = normal / max(vMinorR, 0.0001);
|
|
561
|
+
|
|
562
|
+
// Decode: |radius| = outerR, sign(radius) = X billboard corner
|
|
563
|
+
vOuterR = abs(radius);
|
|
564
|
+
float xSign = sign(radius);
|
|
565
|
+
|
|
566
|
+
// Decode: sign(color.b) = Y billboard corner, actual color = (r, g, |b|)
|
|
567
|
+
float ySign = sign(color.b);
|
|
568
|
+
vColor = vec3(color.r, color.g, abs(color.b));
|
|
569
|
+
|
|
570
|
+
// Transform ring center to view space
|
|
571
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
572
|
+
center = mvPosition.xyz;
|
|
573
|
+
|
|
574
|
+
// Transform ring normal to view space
|
|
575
|
+
vRingNormal = normalize( normalMatrix * ringNormalObj );
|
|
576
|
+
|
|
577
|
+
// Billboard expansion
|
|
578
|
+
mapping = vec2(xSign * vOuterR, ySign * vOuterR);
|
|
579
|
+
vec4 projPosition = projectionMatrix * mvPosition;
|
|
580
|
+
vec4 adjust = projectionMatrix * vec4(mapping, 0.0, 0.0);
|
|
581
|
+
adjust.z = 0.0; adjust.w = 0.0;
|
|
582
|
+
|
|
583
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
584
|
+
vLight = normalize( lDirection.xyz );
|
|
585
|
+
gl_Position = projPosition + adjust;
|
|
586
|
+
|
|
587
|
+
}
|
|
588
|
+
`},"./src/WebGL/shaders/lib/ringimposter/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/screen/index.ts"(k,w,c){c.r(w),c.d(w,{screen:()=>R});var b=c("./src/WebGL/shaders/lib/screen/uniforms.ts"),O=c("./src/WebGL/shaders/lib/screen/screen.frag"),C=c("./src/WebGL/shaders/lib/screen/screen.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/screen/screen.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform sampler2D colormap;
|
|
589
|
+
varying highp vec2 vTexCoords;
|
|
590
|
+
uniform vec2 dimensions;
|
|
591
|
+
//DEFINEFRAGCOLOR
|
|
592
|
+
void main (void) {
|
|
593
|
+
gl_FragColor = texture2D(colormap, vTexCoords);
|
|
594
|
+
|
|
595
|
+
//gl_FragColor.g = gl_FragColor.b = gl_FragColor.r; //debug shading
|
|
596
|
+
}
|
|
597
|
+
`},"./src/WebGL/shaders/lib/screen/screen.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`attribute vec2 vertexPosition;
|
|
598
|
+
varying highp vec2 vTexCoords;
|
|
599
|
+
const vec2 scale = vec2(0.5, 0.5);
|
|
600
|
+
|
|
601
|
+
void main() {
|
|
602
|
+
vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
|
|
603
|
+
gl_Position = vec4(vertexPosition, 0.0, 1.0);
|
|
604
|
+
}
|
|
605
|
+
`},"./src/WebGL/shaders/lib/screen/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>b});const b={}},"./src/WebGL/shaders/lib/screenaa/index.ts"(k,w,c){c.r(w),c.d(w,{screenaa:()=>R});var b=c("./src/WebGL/shaders/lib/screenaa/uniforms.ts"),O=c("./src/WebGL/shaders/lib/screenaa/screenaa.frag"),C=c("./src/WebGL/shaders/lib/screenaa/screenaa.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/screenaa/screenaa.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
606
|
+
|
|
607
|
+
precision highp float;
|
|
608
|
+
precision highp int;
|
|
609
|
+
precision highp sampler2D;
|
|
610
|
+
|
|
611
|
+
uniform sampler2D tColor;
|
|
612
|
+
varying highp vec2 vTexCoords;
|
|
613
|
+
|
|
614
|
+
// adapted from https://github.com/kosua20/Rendu
|
|
615
|
+
// MIT License Copyright (c) 2017 Simon Rodriguez
|
|
616
|
+
// by way of molstar (https://github.com/molstar/molstar/blob/master/src/mol-gl/shader/fxaa.frag.ts)
|
|
617
|
+
|
|
618
|
+
#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))
|
|
619
|
+
|
|
620
|
+
float rgb2luma(vec3 rgb){
|
|
621
|
+
return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114)));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
float sampleLuma(vec2 uv) {
|
|
625
|
+
return rgb2luma(texture2D(tColor, uv).rgb);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
float sampleLuma(vec2 uv, float uOffset, float vOffset) {
|
|
629
|
+
uv += vec2(uOffset, vOffset);
|
|
630
|
+
return sampleLuma(uv);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
//DEFINEFRAGCOLOR
|
|
634
|
+
void main(void) {
|
|
635
|
+
ivec2 dim = textureSize(tColor,0);
|
|
636
|
+
vec2 dimensions = vec2(float(dim.x),float(dim.y));
|
|
637
|
+
vec2 inverseScreenSize = vec2(1.0 / dimensions.x, 1.0 / dimensions.y);
|
|
638
|
+
vec2 coords = vTexCoords;
|
|
639
|
+
|
|
640
|
+
vec4 colorCenter = texture2D(tColor, coords);
|
|
641
|
+
float dEdgeThresholdMin = 0.0312;
|
|
642
|
+
float dEdgeThresholdMax = 0.125;
|
|
643
|
+
int dIterations = 12;
|
|
644
|
+
float dSubpixelQuality = 0.3;
|
|
645
|
+
|
|
646
|
+
// Luma at the current fragment
|
|
647
|
+
float lumaCenter = rgb2luma(colorCenter.rgb);
|
|
648
|
+
|
|
649
|
+
// Luma at the four direct neighbours of the current fragment.
|
|
650
|
+
float lumaDown = sampleLuma(coords, 0.0, -inverseScreenSize.y);
|
|
651
|
+
float lumaUp = sampleLuma(coords, 0.0, inverseScreenSize.y);
|
|
652
|
+
float lumaLeft = sampleLuma(coords, -inverseScreenSize.x, 0.0);
|
|
653
|
+
float lumaRight = sampleLuma(coords, inverseScreenSize.x, 0.0);
|
|
654
|
+
|
|
655
|
+
// Find the maximum and minimum luma around the current fragment.
|
|
656
|
+
float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
|
|
657
|
+
float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));
|
|
658
|
+
|
|
659
|
+
// Compute the delta.
|
|
660
|
+
float lumaRange = lumaMax - lumaMin;
|
|
661
|
+
|
|
662
|
+
// If the luma variation is lower that a threshold (or if we are in a really dark area),
|
|
663
|
+
// we are not on an edge, don't perform any AA.
|
|
664
|
+
if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) {
|
|
665
|
+
gl_FragColor = colorCenter;
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// Query the 4 remaining corners lumas.
|
|
670
|
+
float lumaDownLeft = sampleLuma(coords, -inverseScreenSize.x, -inverseScreenSize.y);
|
|
671
|
+
float lumaUpRight = sampleLuma(coords, inverseScreenSize.x, inverseScreenSize.y);
|
|
672
|
+
float lumaUpLeft = sampleLuma(coords, -inverseScreenSize.x, inverseScreenSize.y);
|
|
673
|
+
float lumaDownRight = sampleLuma(coords, inverseScreenSize.x, -inverseScreenSize.y);
|
|
674
|
+
|
|
675
|
+
// Combine the four edges lumas (using intermediary variables for future computations
|
|
676
|
+
// with the same values).
|
|
677
|
+
float lumaDownUp = lumaDown + lumaUp;
|
|
678
|
+
float lumaLeftRight = lumaLeft + lumaRight;
|
|
679
|
+
|
|
680
|
+
// Same for corners
|
|
681
|
+
float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
|
|
682
|
+
float lumaDownCorners = lumaDownLeft + lumaDownRight;
|
|
683
|
+
float lumaRightCorners = lumaDownRight + lumaUpRight;
|
|
684
|
+
float lumaUpCorners = lumaUpRight + lumaUpLeft;
|
|
685
|
+
|
|
686
|
+
// Compute an estimation of the gradient along the horizontal and vertical axis.
|
|
687
|
+
float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);
|
|
688
|
+
float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);
|
|
689
|
+
|
|
690
|
+
// Is the local edge horizontal or vertical ?
|
|
691
|
+
bool isHorizontal = (edgeHorizontal >= edgeVertical);
|
|
692
|
+
|
|
693
|
+
// Choose the step size (one pixel) accordingly.
|
|
694
|
+
float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;
|
|
695
|
+
|
|
696
|
+
// Select the two neighboring texels lumas in the opposite direction to the local edge.
|
|
697
|
+
float luma1 = isHorizontal ? lumaDown : lumaLeft;
|
|
698
|
+
float luma2 = isHorizontal ? lumaUp : lumaRight;
|
|
699
|
+
// Compute gradients in this direction.
|
|
700
|
+
float gradient1 = luma1 - lumaCenter;
|
|
701
|
+
float gradient2 = luma2 - lumaCenter;
|
|
702
|
+
|
|
703
|
+
// Which direction is the steepest ?
|
|
704
|
+
bool is1Steepest = abs(gradient1) >= abs(gradient2);
|
|
705
|
+
|
|
706
|
+
// Gradient in the corresponding direction, normalized.
|
|
707
|
+
float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));
|
|
708
|
+
|
|
709
|
+
// Average luma in the correct direction.
|
|
710
|
+
float lumaLocalAverage = 0.0;
|
|
711
|
+
if(is1Steepest){
|
|
712
|
+
// Switch the direction
|
|
713
|
+
stepLength = -stepLength;
|
|
714
|
+
lumaLocalAverage = 0.5 * (luma1 + lumaCenter);
|
|
715
|
+
} else {
|
|
716
|
+
lumaLocalAverage = 0.5 * (luma2 + lumaCenter);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Shift UV in the correct direction by half a pixel.
|
|
720
|
+
vec2 currentUv = coords;
|
|
721
|
+
if(isHorizontal){
|
|
722
|
+
currentUv.y += stepLength * 0.5;
|
|
723
|
+
} else {
|
|
724
|
+
currentUv.x += stepLength * 0.5;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// Compute offset (for each iteration step) in the right direction.
|
|
728
|
+
vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);
|
|
729
|
+
// Compute UVs to explore on each side of the edge, orthogonally.
|
|
730
|
+
// The QUALITY allows us to step faster.
|
|
731
|
+
vec2 uv1 = currentUv - offset * QUALITY(0);
|
|
732
|
+
vec2 uv2 = currentUv + offset * QUALITY(0);
|
|
733
|
+
|
|
734
|
+
// Read the lumas at both current extremities of the exploration segment,
|
|
735
|
+
// and compute the delta wrt to the local average luma.
|
|
736
|
+
float lumaEnd1 = sampleLuma(uv1);
|
|
737
|
+
float lumaEnd2 = sampleLuma(uv2);
|
|
738
|
+
lumaEnd1 -= lumaLocalAverage;
|
|
739
|
+
lumaEnd2 -= lumaLocalAverage;
|
|
740
|
+
|
|
741
|
+
// If the luma deltas at the current extremities is larger than the local gradient,
|
|
742
|
+
// we have reached the side of the edge.
|
|
743
|
+
bool reached1 = abs(lumaEnd1) >= gradientScaled;
|
|
744
|
+
bool reached2 = abs(lumaEnd2) >= gradientScaled;
|
|
745
|
+
bool reachedBoth = reached1 && reached2;
|
|
746
|
+
|
|
747
|
+
// If the side is not reached, we continue to explore in this direction.
|
|
748
|
+
if(!reached1){
|
|
749
|
+
uv1 -= offset * QUALITY(1);
|
|
750
|
+
}
|
|
751
|
+
if(!reached2){
|
|
752
|
+
uv2 += offset * QUALITY(1);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// If both sides have not been reached, continue to explore.
|
|
756
|
+
if(!reachedBoth){
|
|
757
|
+
for(int i = 2; i < dIterations; i++){
|
|
758
|
+
// If needed, read luma in 1st direction, compute delta.
|
|
759
|
+
if(!reached1){
|
|
760
|
+
lumaEnd1 = sampleLuma(uv1);
|
|
761
|
+
lumaEnd1 = lumaEnd1 - lumaLocalAverage;
|
|
762
|
+
}
|
|
763
|
+
// If needed, read luma in opposite direction, compute delta.
|
|
764
|
+
if(!reached2){
|
|
765
|
+
lumaEnd2 = sampleLuma(uv2);
|
|
766
|
+
lumaEnd2 = lumaEnd2 - lumaLocalAverage;
|
|
767
|
+
}
|
|
768
|
+
// If the luma deltas at the current extremities is larger than the local gradient,
|
|
769
|
+
// we have reached the side of the edge.
|
|
770
|
+
reached1 = abs(lumaEnd1) >= gradientScaled;
|
|
771
|
+
reached2 = abs(lumaEnd2) >= gradientScaled;
|
|
772
|
+
reachedBoth = reached1 && reached2;
|
|
773
|
+
|
|
774
|
+
// If the side is not reached, we continue to explore in this direction,
|
|
775
|
+
// with a variable quality.
|
|
776
|
+
if(!reached1){
|
|
777
|
+
uv1 -= offset * QUALITY(i);
|
|
778
|
+
}
|
|
779
|
+
if(!reached2){
|
|
780
|
+
uv2 += offset * QUALITY(i);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// If both sides have been reached, stop the exploration.
|
|
784
|
+
if(reachedBoth){
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// Compute the distances to each side edge of the edge (!).
|
|
791
|
+
float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y);
|
|
792
|
+
float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y);
|
|
793
|
+
|
|
794
|
+
// In which direction is the side of the edge closer ?
|
|
795
|
+
bool isDirection1 = distance1 < distance2;
|
|
796
|
+
float distanceFinal = min(distance1, distance2);
|
|
797
|
+
|
|
798
|
+
// Thickness of the edge.
|
|
799
|
+
float edgeThickness = (distance1 + distance2);
|
|
800
|
+
|
|
801
|
+
// Is the luma at center smaller than the local average ?
|
|
802
|
+
bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;
|
|
803
|
+
|
|
804
|
+
// If the luma at center is smaller than at its neighbour,
|
|
805
|
+
// the delta luma at each end should be positive (same variation).
|
|
806
|
+
bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller;
|
|
807
|
+
bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller;
|
|
808
|
+
|
|
809
|
+
// Only keep the result in the direction of the closer side of the edge.
|
|
810
|
+
bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;
|
|
811
|
+
|
|
812
|
+
// UV offset: read in the direction of the closest side of the edge.
|
|
813
|
+
float pixelOffset = - distanceFinal / edgeThickness + 0.5;
|
|
814
|
+
|
|
815
|
+
// If the luma variation is incorrect, do not offset.
|
|
816
|
+
float finalOffset = correctVariation ? pixelOffset : 0.0;
|
|
817
|
+
|
|
818
|
+
// Sub-pixel shifting
|
|
819
|
+
// Full weighted average of the luma over the 3x3 neighborhood.
|
|
820
|
+
float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);
|
|
821
|
+
// Ratio of the delta between the global average and the center luma,
|
|
822
|
+
// over the luma range in the 3x3 neighborhood.
|
|
823
|
+
float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);
|
|
824
|
+
float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
|
|
825
|
+
// Compute a sub-pixel offset based on this delta.
|
|
826
|
+
float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality);
|
|
827
|
+
|
|
828
|
+
// Pick the biggest of the two offsets.
|
|
829
|
+
finalOffset = max(finalOffset, subPixelOffsetFinal);
|
|
830
|
+
|
|
831
|
+
// Compute the final UV coordinates.
|
|
832
|
+
vec2 finalUv = coords;
|
|
833
|
+
if(isHorizontal){
|
|
834
|
+
finalUv.y += finalOffset * stepLength;
|
|
835
|
+
} else {
|
|
836
|
+
finalUv.x += finalOffset * stepLength;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// Read the color at the new UV coordinates, and use it.
|
|
840
|
+
gl_FragColor = texture2D(tColor, finalUv);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/* old fxaa implementation
|
|
844
|
+
uniform highp sampler2D colormap;
|
|
845
|
+
varying highp vec2 vTexCoords;
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
// Basic FXAA implementation based on the code on geeks3d.com
|
|
849
|
+
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
|
850
|
+
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
|
851
|
+
#define FXAA_SPAN_MAX 8.0
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
vec4 applyFXAA(vec2 fragCoord, highp sampler2D tex)
|
|
855
|
+
{
|
|
856
|
+
vec4 color;
|
|
857
|
+
ivec2 dim = textureSize(tex,0);
|
|
858
|
+
vec2 dimensions = vec2(float(dim.x),float(dim.y));
|
|
859
|
+
vec2 inverseVP = vec2(1.0 / dimensions.x, 1.0 / dimensions.y);
|
|
860
|
+
vec4 rgbNW = texture2D(tex, fragCoord + vec2(-1.0, -1.0) * inverseVP);
|
|
861
|
+
vec4 rgbNE = texture2D(tex, fragCoord + vec2(1.0, -1.0) * inverseVP);
|
|
862
|
+
vec4 rgbSW = texture2D(tex, fragCoord + vec2(-1.0, 1.0) * inverseVP);
|
|
863
|
+
vec4 rgbSE = texture2D(tex, fragCoord + vec2(1.0, 1.0) * inverseVP);
|
|
864
|
+
vec4 rgbM = texture2D(tex, fragCoord );
|
|
865
|
+
vec3 luma = vec3(0.299, 0.587, 0.114);
|
|
866
|
+
float lumaNW = dot(rgbNW.xyz, luma);
|
|
867
|
+
float lumaNE = dot(rgbNE.xyz, luma);
|
|
868
|
+
float lumaSW = dot(rgbSW.xyz, luma);
|
|
869
|
+
float lumaSE = dot(rgbSE.xyz, luma);
|
|
870
|
+
float lumaM = dot(rgbM.xyz, luma);
|
|
871
|
+
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
|
872
|
+
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
|
873
|
+
|
|
874
|
+
vec2 dir;
|
|
875
|
+
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
|
876
|
+
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
|
877
|
+
|
|
878
|
+
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
|
879
|
+
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
|
880
|
+
|
|
881
|
+
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
|
882
|
+
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
|
883
|
+
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
|
884
|
+
dir * rcpDirMin)) * inverseVP;
|
|
885
|
+
|
|
886
|
+
vec4 rgbA = 0.5 * (
|
|
887
|
+
texture2D(tex, fragCoord + dir * (1.0 / 3.0 - 0.5)) +
|
|
888
|
+
texture2D(tex, fragCoord + dir * (2.0 / 3.0 - 0.5)));
|
|
889
|
+
vec4 rgbB = rgbA * 0.5 + 0.25 * (
|
|
890
|
+
texture2D(tex, fragCoord + dir * -0.5) +
|
|
891
|
+
texture2D(tex, fragCoord + dir * 0.5));
|
|
892
|
+
|
|
893
|
+
float lumaB = dot(rgbB.xyz, luma);
|
|
894
|
+
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
|
895
|
+
color = rgbA;
|
|
896
|
+
else
|
|
897
|
+
color = rgbB;
|
|
898
|
+
|
|
899
|
+
return color;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
//DEFINEFRAGCOLOR
|
|
904
|
+
void main (void) {
|
|
905
|
+
ivec2 dim = textureSize(colormap,0);
|
|
906
|
+
|
|
907
|
+
gl_FragColor = applyFXAA(vTexCoords, colormap);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
*/`},"./src/WebGL/shaders/lib/screenaa/screenaa.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`attribute vec2 vertexPosition;
|
|
911
|
+
varying highp vec2 vTexCoords;
|
|
912
|
+
const vec2 scale = vec2(0.5, 0.5);
|
|
913
|
+
|
|
914
|
+
void main() {
|
|
915
|
+
vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
|
|
916
|
+
gl_Position = vec4(vertexPosition, 0.0, 1.0);
|
|
917
|
+
}
|
|
918
|
+
`},"./src/WebGL/shaders/lib/screenaa/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>b});const b={}},"./src/WebGL/shaders/lib/sphereimposter/index.ts"(k,w,c){c.r(w),c.d(w,{sphereimposter:()=>R});var b=c("./src/WebGL/shaders/lib/sphereimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag"),C=c("./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert");const R={vertexShader:C.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
919
|
+
uniform mat4 viewMatrix;
|
|
920
|
+
uniform float opacity;
|
|
921
|
+
uniform mat4 projectionMatrix;
|
|
922
|
+
|
|
923
|
+
uniform vec3 fogColor;
|
|
924
|
+
uniform float fogNear;
|
|
925
|
+
uniform float fogFar;
|
|
926
|
+
uniform float uDepth;
|
|
927
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
928
|
+
|
|
929
|
+
varying vec3 vColor;
|
|
930
|
+
varying vec2 mapping;
|
|
931
|
+
varying float rval;
|
|
932
|
+
varying vec3 vLight;
|
|
933
|
+
varying vec3 center;
|
|
934
|
+
|
|
935
|
+
#ifdef SHADED
|
|
936
|
+
uniform highp sampler2D shading;
|
|
937
|
+
#endif
|
|
938
|
+
|
|
939
|
+
//DEFINEFRAGCOLOR
|
|
940
|
+
|
|
941
|
+
void main() {
|
|
942
|
+
float lensqr = dot(mapping,mapping);
|
|
943
|
+
float rsqr = rval*rval;
|
|
944
|
+
if(lensqr > rsqr)
|
|
945
|
+
discard;
|
|
946
|
+
float z = sqrt(rsqr-lensqr);
|
|
947
|
+
vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z);
|
|
948
|
+
vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);
|
|
949
|
+
float ndcDepth = clipPos.z / clipPos.w;
|
|
950
|
+
gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
|
951
|
+
vec3 norm = normalize(vec3(mapping.x,mapping.y,z));
|
|
952
|
+
float dotProduct = dot( norm, vLight );
|
|
953
|
+
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
|
954
|
+
vec3 vLight = directionalLightColor[ 0 ] * directionalLightWeighting;
|
|
955
|
+
vec3 color = vLight*vColor;
|
|
956
|
+
#ifdef SHADED
|
|
957
|
+
ivec2 dim = textureSize(shading,0);
|
|
958
|
+
float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;
|
|
959
|
+
color *= shadowFactor;
|
|
960
|
+
#endif
|
|
961
|
+
gl_FragColor = vec4(color, opacity*opacity );
|
|
962
|
+
|
|
963
|
+
if(fogNear != fogFar) {
|
|
964
|
+
float depth = -cameraPos.z;
|
|
965
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
966
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
`},"./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 modelViewMatrix;
|
|
972
|
+
uniform mat4 projectionMatrix;
|
|
973
|
+
uniform mat4 viewMatrix;
|
|
974
|
+
uniform mat3 normalMatrix;
|
|
975
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
976
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
977
|
+
|
|
978
|
+
attribute vec3 position;
|
|
979
|
+
attribute vec3 normal;
|
|
980
|
+
attribute vec3 color;
|
|
981
|
+
|
|
982
|
+
varying vec2 mapping;
|
|
983
|
+
varying vec3 vColor;
|
|
984
|
+
varying float rval;
|
|
985
|
+
varying vec3 vLight;
|
|
986
|
+
varying vec3 center;
|
|
987
|
+
|
|
988
|
+
void main() {
|
|
989
|
+
|
|
990
|
+
vColor = color;
|
|
991
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
992
|
+
center = mvPosition.xyz;
|
|
993
|
+
vec4 projPosition = projectionMatrix * mvPosition;
|
|
994
|
+
vec4 adjust = projectionMatrix* vec4(normal,0.0); adjust.z = 0.0; adjust.w = 0.0;
|
|
995
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
996
|
+
vLight = normalize( lDirection.xyz );
|
|
997
|
+
mapping = normal.xy;
|
|
998
|
+
rval = abs(normal.x);
|
|
999
|
+
gl_Position = projPosition+adjust;
|
|
1000
|
+
|
|
1001
|
+
}
|
|
1002
|
+
`},"./src/WebGL/shaders/lib/sphereimposter/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/sphereimposteroutline/index.ts"(k,w,c){c.r(w),c.d(w,{sphereimposteroutline:()=>R});var b=c("./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag"),C=c("./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1003
|
+
|
|
1004
|
+
uniform float opacity;
|
|
1005
|
+
uniform vec3 outlineColor;
|
|
1006
|
+
uniform vec3 fogColor;
|
|
1007
|
+
uniform float fogNear;
|
|
1008
|
+
uniform float fogFar;
|
|
1009
|
+
uniform mat4 projectionMatrix;
|
|
1010
|
+
varying vec2 mapping;
|
|
1011
|
+
varying float rval;
|
|
1012
|
+
varying vec3 center;
|
|
1013
|
+
|
|
1014
|
+
uniform float outlinePushback;
|
|
1015
|
+
|
|
1016
|
+
//DEFINEFRAGCOLOR
|
|
1017
|
+
|
|
1018
|
+
void main() {
|
|
1019
|
+
float lensqr = dot(mapping,mapping);
|
|
1020
|
+
float rsqr = rval*rval;
|
|
1021
|
+
if(lensqr > rsqr)
|
|
1022
|
+
discard;
|
|
1023
|
+
float z = sqrt(rsqr-lensqr);
|
|
1024
|
+
vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z-outlinePushback);
|
|
1025
|
+
vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);
|
|
1026
|
+
float ndcDepth = clipPos.z / clipPos.w;
|
|
1027
|
+
gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
|
1028
|
+
gl_FragColor = vec4(outlineColor, 1 );
|
|
1029
|
+
|
|
1030
|
+
if(fogNear != fogFar) {
|
|
1031
|
+
float depth = -cameraPos.z;
|
|
1032
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
1033
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
`},"./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1039
|
+
|
|
1040
|
+
uniform mat4 modelViewMatrix;
|
|
1041
|
+
uniform mat4 projectionMatrix;
|
|
1042
|
+
uniform float outlineWidth;
|
|
1043
|
+
uniform float outlinePushback;
|
|
1044
|
+
uniform float outlineMaxPixels;
|
|
1045
|
+
uniform float vWidth;
|
|
1046
|
+
uniform float vHeight;
|
|
1047
|
+
|
|
1048
|
+
attribute vec3 position;
|
|
1049
|
+
attribute vec3 normal;
|
|
1050
|
+
attribute vec3 color;
|
|
1051
|
+
|
|
1052
|
+
varying vec2 mapping;
|
|
1053
|
+
varying float rval;
|
|
1054
|
+
varying vec3 center;
|
|
1055
|
+
|
|
1056
|
+
void main() {
|
|
1057
|
+
|
|
1058
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1059
|
+
center = mvPosition.xyz;
|
|
1060
|
+
vec4 projPosition = projectionMatrix * mvPosition;
|
|
1061
|
+
vec2 norm = normal.xy + vec2(sign(normal.x)*outlineWidth,sign(normal.y)*outlineWidth);
|
|
1062
|
+
|
|
1063
|
+
vec4 adjust = projectionMatrix* vec4(norm,normal.z,1.0);
|
|
1064
|
+
mapping = norm.xy;
|
|
1065
|
+
rval = abs(norm.x);
|
|
1066
|
+
gl_Position = projPosition+vec4(adjust.xy,0.0,0.0);
|
|
1067
|
+
|
|
1068
|
+
if(outlineMaxPixels > 0.0) {
|
|
1069
|
+
vec4 unadjusted = projectionMatrix*vec4(center.x+normal.x, center.y,center.z,1.0);
|
|
1070
|
+
vec4 ccoord = projectionMatrix*vec4(center.xyz,1.0);
|
|
1071
|
+
adjust = projectionMatrix* vec4(center.x+norm.x,center.y,center.z,1.0);
|
|
1072
|
+
//subtract center
|
|
1073
|
+
unadjusted.xyz -= ccoord.xyz;
|
|
1074
|
+
adjust.xyz -= ccoord.xyz;
|
|
1075
|
+
unadjusted /= unadjusted.w;
|
|
1076
|
+
adjust /= adjust.w;
|
|
1077
|
+
float diff = abs(adjust.x-unadjusted.x);
|
|
1078
|
+
diff *= vWidth;
|
|
1079
|
+
if(diff > outlineMaxPixels) {
|
|
1080
|
+
|
|
1081
|
+
float fixlen = abs(unadjusted.x) + outlineMaxPixels/vWidth;
|
|
1082
|
+
//adjsut reval by ratio of lengths
|
|
1083
|
+
rval *= fixlen/abs(adjust.x);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
`},"./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new b.Color(0,0,0)},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1},outlineMaxPixels:{type:"f",value:0}}},"./src/WebGL/shaders/lib/sprite/index.ts"(k,w,c){c.r(w),c.d(w,{sprite:()=>R});var b=c("./src/WebGL/shaders/lib/sprite/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sprite/sprite.frag"),C=c("./src/WebGL/shaders/lib/sprite/sprite.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/sprite/sprite.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1090
|
+
|
|
1091
|
+
uniform vec3 color;
|
|
1092
|
+
uniform sampler2D map;
|
|
1093
|
+
uniform float opacity;
|
|
1094
|
+
|
|
1095
|
+
uniform vec3 fogColor;
|
|
1096
|
+
uniform float fogNear;
|
|
1097
|
+
uniform float fogFar;
|
|
1098
|
+
uniform float alphaTest;
|
|
1099
|
+
|
|
1100
|
+
varying vec2 vUV;
|
|
1101
|
+
//DEFINEFRAGCOLOR
|
|
1102
|
+
|
|
1103
|
+
void main() {
|
|
1104
|
+
|
|
1105
|
+
vec4 texture = texture2D(map, vUV);
|
|
1106
|
+
|
|
1107
|
+
if (texture.a <= alphaTest) discard;
|
|
1108
|
+
|
|
1109
|
+
gl_FragColor = vec4(color * texture.xyz, texture.a * opacity);
|
|
1110
|
+
|
|
1111
|
+
if (fogNear != fogFar) {
|
|
1112
|
+
|
|
1113
|
+
float depth = gl_FragCoord.z / gl_FragCoord.w; //probably wrong
|
|
1114
|
+
float fogFactor = smoothstep(fogNear, fogFar, depth);
|
|
1115
|
+
gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
`},"./src/WebGL/shaders/lib/sprite/sprite.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1120
|
+
|
|
1121
|
+
uniform int useScreenCoordinates;
|
|
1122
|
+
uniform vec3 screenPosition;
|
|
1123
|
+
uniform mat4 modelViewMatrix;
|
|
1124
|
+
uniform mat4 projectionMatrix;
|
|
1125
|
+
uniform float rotation;
|
|
1126
|
+
uniform vec2 scale;
|
|
1127
|
+
uniform vec2 alignment;
|
|
1128
|
+
uniform vec2 uvOffset;
|
|
1129
|
+
uniform vec2 uvScale;
|
|
1130
|
+
|
|
1131
|
+
attribute vec2 position;
|
|
1132
|
+
attribute vec2 uv;
|
|
1133
|
+
|
|
1134
|
+
varying vec2 vUV;
|
|
1135
|
+
|
|
1136
|
+
void main() {
|
|
1137
|
+
|
|
1138
|
+
vUV = uvOffset + uv * uvScale;
|
|
1139
|
+
|
|
1140
|
+
vec2 alignedPosition = position + alignment;
|
|
1141
|
+
|
|
1142
|
+
vec2 rotatedPosition;
|
|
1143
|
+
rotatedPosition.x = ( cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y ) * scale.x;
|
|
1144
|
+
rotatedPosition.y = ( sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y ) * scale.y;
|
|
1145
|
+
|
|
1146
|
+
vec4 finalPosition;
|
|
1147
|
+
|
|
1148
|
+
if(useScreenCoordinates != 0) {
|
|
1149
|
+
finalPosition = vec4(screenPosition.xy + rotatedPosition, screenPosition.z, 1.0);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
else {
|
|
1153
|
+
finalPosition = projectionMatrix * modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); finalPosition /= finalPosition.w;
|
|
1154
|
+
finalPosition.xy += rotatedPosition;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
gl_Position = finalPosition;
|
|
1158
|
+
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
`},"./src/WebGL/shaders/lib/sprite/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>b});const b={}},"./src/WebGL/shaders/lib/ssao/index.ts"(k,w,c){c.r(w),c.d(w,{ssao:()=>R});var b=c("./src/WebGL/shaders/lib/ssao/uniforms.ts"),O=c("./src/WebGL/shaders/lib/ssao/ssao.frag"),C=c("./src/WebGL/shaders/lib/ssao/ssao.vert");const R={fragmentShader:O.default,vertexShader:C.default,uniforms:b.uniforms}},"./src/WebGL/shaders/lib/ssao/ssao.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform sampler2D depthmap;
|
|
1162
|
+
varying highp vec2 vTexCoords;
|
|
1163
|
+
uniform float vWidth;
|
|
1164
|
+
uniform float vHeight;
|
|
1165
|
+
uniform float total_strength;
|
|
1166
|
+
uniform float radius;
|
|
1167
|
+
uniform mat4 projinv;
|
|
1168
|
+
uniform mat4 projectionMatrix;
|
|
1169
|
+
|
|
1170
|
+
//code for pseudorandom vector from chatgpt
|
|
1171
|
+
float hash(vec3 p) {
|
|
1172
|
+
p = fract(p * vec3(0.1031, 0.1030, 0.0973));
|
|
1173
|
+
p += dot(p, p.yzx + 33.33);
|
|
1174
|
+
return fract((p.x + p.y) * p.z);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// Generate a pseudorandom vec3 from a seed vec3
|
|
1178
|
+
vec3 pseudorandomVec3(vec3 seed) {
|
|
1179
|
+
vec3 randomVec;
|
|
1180
|
+
randomVec.x = hash(seed);
|
|
1181
|
+
randomVec.y = hash(seed + vec3(1.0, 0.0, 17.1));
|
|
1182
|
+
randomVec.z = hash(seed + vec3(0.0, 13.23, 0.0));
|
|
1183
|
+
return randomVec;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
void main(void)
|
|
1187
|
+
{
|
|
1188
|
+
const float base = 0.2;
|
|
1189
|
+
const float area = 0.75;
|
|
1190
|
+
const int cycles = 1;
|
|
1191
|
+
|
|
1192
|
+
const int samples = 64;
|
|
1193
|
+
vec3 sample_sphere[64] = vec3[](
|
|
1194
|
+
vec3(0.091258,-0.510164,0.000000),
|
|
1195
|
+
vec3(-0.204347,-0.872967,0.187199),
|
|
1196
|
+
vec3(0.009690,-0.263696,-0.110414),
|
|
1197
|
+
vec3(0.175208,-0.563987,0.228527),
|
|
1198
|
+
vec3(-0.001824,-0.003113,-0.000323),
|
|
1199
|
+
vec3(0.411134,-0.719869,-0.261530),
|
|
1200
|
+
vec3(-0.074272,-0.377368,0.276290),
|
|
1201
|
+
vec3(-0.147773,-0.381587,-0.284529),
|
|
1202
|
+
vec3(0.173317,-0.199635,0.063295),
|
|
1203
|
+
vec3(-0.186452,-0.199460,0.076965),
|
|
1204
|
+
vec3(0.143985,-0.308160,-0.307687),
|
|
1205
|
+
vec3(0.053194,-0.148286,0.169589),
|
|
1206
|
+
vec3(-0.547656,-0.486476,-0.317378),
|
|
1207
|
+
vec3(0.020804,-0.015092,-0.004574),
|
|
1208
|
+
vec3(-0.038006,-0.043165,0.054059),
|
|
1209
|
+
vec3(-0.094795,-0.443908,-0.731525),
|
|
1210
|
+
vec3(0.547552,-0.396466,0.461477),
|
|
1211
|
+
vec3(-0.176886,-0.089989,0.007315),
|
|
1212
|
+
vec3(0.074401,-0.048840,-0.074039),
|
|
1213
|
+
vec3(-0.008240,-0.075697,0.178197),
|
|
1214
|
+
vec3(-0.307880,-0.185053,-0.368943),
|
|
1215
|
+
vec3(0.309520,-0.108483,0.041646),
|
|
1216
|
+
vec3(-0.773478,-0.292946,0.538166),
|
|
1217
|
+
vec3(0.184487,-0.231594,-0.820065),
|
|
1218
|
+
vec3(0.207318,-0.100531,0.361797),
|
|
1219
|
+
vec3(-0.173306,-0.037737,-0.055289),
|
|
1220
|
+
vec3(0.548102,-0.105342,-0.253237),
|
|
1221
|
+
vec3(-0.119342,-0.043907,0.285162),
|
|
1222
|
+
vec3(-0.270247,-0.087861,-0.751357),
|
|
1223
|
+
vec3(0.449312,-0.039777,0.236146),
|
|
1224
|
+
vec3(-0.743773,-0.036095,0.196056),
|
|
1225
|
+
vec3(0.148819,-0.004300,-0.231448),
|
|
1226
|
+
vec3(0.008773,0.000809,0.051047),
|
|
1227
|
+
vec3(-0.461467,0.027390,-0.357386),
|
|
1228
|
+
vec3(0.169626,0.013338,-0.014053),
|
|
1229
|
+
vec3(-0.043786,0.007095,0.047331),
|
|
1230
|
+
vec3(0.004821,0.140371,-0.988260),
|
|
1231
|
+
vec3(0.092402,0.023994,0.101860),
|
|
1232
|
+
vec3(-0.295335,0.061530,-0.027372),
|
|
1233
|
+
vec3(0.024903,0.007537,-0.018901),
|
|
1234
|
+
vec3(-0.081463,0.125402,0.447794),
|
|
1235
|
+
vec3(-0.397119,0.231805,-0.631062),
|
|
1236
|
+
vec3(0.163853,0.059014,0.044905),
|
|
1237
|
+
vec3(-0.495220,0.214357,0.254139),
|
|
1238
|
+
vec3(0.306123,0.373687,-0.825715),
|
|
1239
|
+
vec3(0.021665,0.026737,0.053220),
|
|
1240
|
+
vec3(-0.208231,0.117129,-0.098685),
|
|
1241
|
+
vec3(0.139749,0.080968,-0.043086),
|
|
1242
|
+
vec3(-0.153599,0.182814,0.262090),
|
|
1243
|
+
vec3(-0.159673,0.496777,-0.743568),
|
|
1244
|
+
vec3(0.134797,0.117152,0.095753),
|
|
1245
|
+
vec3(-0.155626,0.120533,0.019395),
|
|
1246
|
+
vec3(0.042311,0.054462,-0.049709),
|
|
1247
|
+
vec3(0.001257,0.031288,0.034468),
|
|
1248
|
+
vec3(-0.002271,0.003199,-0.002304),
|
|
1249
|
+
vec3(0.662104,0.717307,0.033854),
|
|
1250
|
+
vec3(-0.373100,0.576021,0.308274),
|
|
1251
|
+
vec3(0.024233,0.231316,-0.173688),
|
|
1252
|
+
vec3(0.161311,0.420217,0.234273),
|
|
1253
|
+
vec3(-0.045248,0.078031,-0.010411),
|
|
1254
|
+
vec3(0.167453,0.376942,-0.094872),
|
|
1255
|
+
vec3(-0.056194,0.433247,0.173218),
|
|
1256
|
+
vec3(-0.016224,0.123149,-0.035569),
|
|
1257
|
+
vec3(0.067127,0.407641,0.028479)
|
|
1258
|
+
);
|
|
1259
|
+
|
|
1260
|
+
float depth = texture2D(depthmap, vTexCoords).r;
|
|
1261
|
+
if(depth == 1.0) {
|
|
1262
|
+
discard;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
vec4 screen_position = vec4(vTexCoords, depth,1.0);
|
|
1266
|
+
vec4 pos = projinv*screen_position;
|
|
1267
|
+
pos /= pos.w;
|
|
1268
|
+
vec3 position = pos.xyz;
|
|
1269
|
+
|
|
1270
|
+
//approximate the normal from the depth map; I find this simpler
|
|
1271
|
+
//than trying to recompute the exact normal within every possible object shader
|
|
1272
|
+
|
|
1273
|
+
//pixel offset positions in screen space
|
|
1274
|
+
ivec2 dim = textureSize(depthmap,0);
|
|
1275
|
+
vec2 offset1 = vec2(0.0,1.0/float(dim.y));
|
|
1276
|
+
vec2 offset2 = vec2(1.0/float(dim.x),0.0);
|
|
1277
|
+
float depth1 = texture2D(depthmap, vTexCoords + offset1).r;
|
|
1278
|
+
float depth2 = texture2D(depthmap, vTexCoords + offset2).r;
|
|
1279
|
+
|
|
1280
|
+
vec3 p1 = vec3(screen_position.xy+offset1, depth1 - depth);
|
|
1281
|
+
vec3 p2 = vec3(screen_position.xy+offset2, depth2 - depth);
|
|
1282
|
+
|
|
1283
|
+
//convert to model space
|
|
1284
|
+
vec4 pos1 = projinv*vec4(p1,1);
|
|
1285
|
+
pos1 /= pos1.w;
|
|
1286
|
+
vec4 pos2 = projinv*vec4(p2,1);
|
|
1287
|
+
pos2 /= pos2.w;
|
|
1288
|
+
|
|
1289
|
+
vec3 normal = normalize(cross(pos1.xyz-position, pos2.xyz-position)); //model normal, important we normalize in model space
|
|
1290
|
+
|
|
1291
|
+
//pseudo random number
|
|
1292
|
+
|
|
1293
|
+
float occlusion = 0.0;
|
|
1294
|
+
for(int c = 0; c < cycles; c++) {
|
|
1295
|
+
vec3 random = normalize(pseudorandomVec3(position+float(c)));
|
|
1296
|
+
for(int i=0; i < samples; i++) {
|
|
1297
|
+
|
|
1298
|
+
vec3 ray = radius * reflect(sample_sphere[i],random);
|
|
1299
|
+
vec3 hemi_ray = position + sign(dot(ray,normal)) * ray; //model space
|
|
1300
|
+
vec4 hemi_screen = projectionMatrix*vec4(hemi_ray,1.0);
|
|
1301
|
+
hemi_screen /= hemi_screen.w;
|
|
1302
|
+
|
|
1303
|
+
float occ_depth = texture2D(depthmap, clamp(hemi_screen.xy,0.0,1.0)).r;
|
|
1304
|
+
float difference = hemi_screen.z - occ_depth;
|
|
1305
|
+
|
|
1306
|
+
occlusion += step(0.0, difference) * (1.0-smoothstep(0.0, area, difference));
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
float ao = 1.0 - total_strength * occlusion * (1.0 / float(cycles*samples));
|
|
1310
|
+
gl_FragDepthEXT = clamp(ao+base,0.0,1.0);
|
|
1311
|
+
|
|
1312
|
+
}`},"./src/WebGL/shaders/lib/ssao/ssao.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`attribute vec2 vertexPosition;
|
|
1313
|
+
varying highp vec2 vTexCoords;
|
|
1314
|
+
const vec2 scale = vec2(0.5, 0.5);
|
|
1315
|
+
|
|
1316
|
+
void main() {
|
|
1317
|
+
vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
|
|
1318
|
+
gl_Position = vec4(vertexPosition, 0.0, 1.0);
|
|
1319
|
+
}
|
|
1320
|
+
`},"./src/WebGL/shaders/lib/ssao/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>b});const b={total_strength:{type:"f",value:1},radius:{type:"f",value:5},projinv:{type:"mat4",value:[]}}},"./src/WebGL/shaders/lib/stickimposter/index.ts"(k,w,c){c.r(w),c.d(w,{stickimposter:()=>y});var b=c("./src/WebGL/shaders/lib/stickimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/stickimposter/stickimposterFragmentShader.partial.frag"),C=c("./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag"),R=c("./src/WebGL/shaders/lib/stickimposter/stickimposter.vert");const y={fragmentShader:[O.default,C.default].join(`
|
|
1321
|
+
`),vertexShader:R.default,uniforms:b.uniforms}},"./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=` float dotProduct = dot( norm, vLight );
|
|
1322
|
+
vec3 light = vec3( max( dotProduct, 0.0 ) );
|
|
1323
|
+
color *= light;
|
|
1324
|
+
#ifdef SHADED
|
|
1325
|
+
ivec2 dim = textureSize(shading,0);
|
|
1326
|
+
float shadowFactor = texture2D(shading,vec2(gl_FragCoord.x/float(dim.x),gl_FragCoord.y/float(dim.y))).r;
|
|
1327
|
+
color *= shadowFactor;
|
|
1328
|
+
#endif
|
|
1329
|
+
gl_FragColor = vec4(color, opacity*opacity );
|
|
1330
|
+
if(fogNear != fogFar) {
|
|
1331
|
+
float depth = -qi.z;
|
|
1332
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
1333
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
1334
|
+
}
|
|
1335
|
+
}`},"./src/WebGL/shaders/lib/stickimposter/stickimposter.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1336
|
+
|
|
1337
|
+
uniform mat4 modelViewMatrix;
|
|
1338
|
+
uniform mat4 projectionMatrix;
|
|
1339
|
+
uniform mat4 viewMatrix;
|
|
1340
|
+
uniform mat3 normalMatrix;
|
|
1341
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
1342
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
1343
|
+
|
|
1344
|
+
attribute vec3 position;
|
|
1345
|
+
attribute vec3 normal;
|
|
1346
|
+
attribute vec3 color;
|
|
1347
|
+
attribute float radius;
|
|
1348
|
+
|
|
1349
|
+
varying vec3 vColor;
|
|
1350
|
+
varying vec3 vLight;
|
|
1351
|
+
varying vec3 cposition;
|
|
1352
|
+
varying vec3 p1;
|
|
1353
|
+
varying vec3 p2;
|
|
1354
|
+
varying float r;
|
|
1355
|
+
|
|
1356
|
+
void main() {
|
|
1357
|
+
|
|
1358
|
+
vColor = color; vColor.z = abs(vColor.z); //z indicates which vertex and so would vary
|
|
1359
|
+
r = abs(radius);
|
|
1360
|
+
vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder
|
|
1361
|
+
vec4 pt = modelViewMatrix*vec4(position, 1.0);
|
|
1362
|
+
vec4 mvPosition = pt;
|
|
1363
|
+
p1 = pt.xyz; p2 = to.xyz;
|
|
1364
|
+
vec3 norm = to.xyz-pt.xyz;
|
|
1365
|
+
float mult = 1.1; //slop to account for perspective of sphere
|
|
1366
|
+
if(length(p1) > length(p2)) { //billboard at level of closest point
|
|
1367
|
+
mvPosition = to;
|
|
1368
|
+
}
|
|
1369
|
+
vec3 n = normalize(mvPosition.xyz);
|
|
1370
|
+
bool isperspective = (projectionMatrix[3][3] == 0.0);
|
|
1371
|
+
//intersect with the plane defined by the camera looking at the billboard point
|
|
1372
|
+
if(color.z >= 0.0) { //p1
|
|
1373
|
+
if(isperspective) { //perspective
|
|
1374
|
+
vec3 pnorm = normalize(p1);
|
|
1375
|
+
float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);
|
|
1376
|
+
mvPosition.xyz = p1+t*pnorm;
|
|
1377
|
+
} else { //orthographic
|
|
1378
|
+
mvPosition.xyz = p1;
|
|
1379
|
+
}
|
|
1380
|
+
} else {
|
|
1381
|
+
if(isperspective) { //perspective
|
|
1382
|
+
vec3 pnorm = normalize(p2);
|
|
1383
|
+
float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);
|
|
1384
|
+
mvPosition.xyz = p2+t*pnorm;
|
|
1385
|
+
} else { //orthographic
|
|
1386
|
+
mvPosition.xyz = p2;
|
|
1387
|
+
}
|
|
1388
|
+
mult *= -1.0;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
if(isperspective) { //perspective
|
|
1392
|
+
vec3 cr = normalize(cross(mvPosition.xyz,norm))*radius;
|
|
1393
|
+
vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*radius;
|
|
1394
|
+
mvPosition.xyz += mult*(cr + doublecr).xyz;
|
|
1395
|
+
} else {
|
|
1396
|
+
vec3 cr = normalize(cross(vec3(0.0,0.0,-1.0),norm))*radius;
|
|
1397
|
+
vec3 doublecr = normalize(cross(vec3(0.0,0.0,-1.0),cr))*radius;
|
|
1398
|
+
mvPosition.xyz += mult*(cr + doublecr).xyz;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
cposition = mvPosition.xyz;
|
|
1402
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1403
|
+
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
|
|
1404
|
+
vLight = normalize( lDirection.xyz )*directionalLightColor[0]; //not really sure this is right, but color is always white so..
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
`},"./src/WebGL/shaders/lib/stickimposter/stickimposterFragmentShader.partial.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform float opacity;
|
|
1408
|
+
uniform mat4 projectionMatrix;
|
|
1409
|
+
|
|
1410
|
+
uniform vec3 fogColor;
|
|
1411
|
+
uniform float fogNear;
|
|
1412
|
+
uniform float fogFar;
|
|
1413
|
+
|
|
1414
|
+
varying vec3 vLight;
|
|
1415
|
+
varying vec3 vColor;
|
|
1416
|
+
varying vec3 cposition;
|
|
1417
|
+
varying vec3 p1;
|
|
1418
|
+
varying vec3 p2;
|
|
1419
|
+
varying float r;
|
|
1420
|
+
|
|
1421
|
+
#ifdef SHADED
|
|
1422
|
+
uniform highp sampler2D shading;
|
|
1423
|
+
#endif
|
|
1424
|
+
|
|
1425
|
+
//DEFINEFRAGCOLOR
|
|
1426
|
+
|
|
1427
|
+
//cylinder-ray intersection testing taken from http://mrl.nyu.edu/~dzorin/cg05/lecture12.pdf
|
|
1428
|
+
//also useful: http://stackoverflow.com/questions/9595300/cylinder-impostor-in-glsl
|
|
1429
|
+
//with a bit more care (caps) this could be a general cylinder imposter (see also outline)
|
|
1430
|
+
void main() {
|
|
1431
|
+
vec3 color = abs(vColor);
|
|
1432
|
+
vec3 pos = cposition;
|
|
1433
|
+
vec3 p = pos; //ray point
|
|
1434
|
+
vec3 v = vec3(0.0,0.0,-1.0); //ray normal - orthographic
|
|
1435
|
+
if(projectionMatrix[3][3] == 0.0) v = normalize(pos); //ray normal - perspective
|
|
1436
|
+
vec3 pa = p1; //cyl start
|
|
1437
|
+
vec3 va = normalize(p2-p1); //cyl norm
|
|
1438
|
+
vec3 tmp1 = v-(dot(v,va)*va);
|
|
1439
|
+
vec3 deltap = p-pa;
|
|
1440
|
+
float A = dot(tmp1,tmp1);
|
|
1441
|
+
if(A == 0.0) discard;
|
|
1442
|
+
vec3 tmp2 = deltap-(dot(deltap,va)*va);
|
|
1443
|
+
float B = 2.0*dot(tmp1, tmp2);
|
|
1444
|
+
float C = dot(tmp2,tmp2)-r*r;
|
|
1445
|
+
//quadratic equation!
|
|
1446
|
+
float det = (B*B) - (4.0*A*C);
|
|
1447
|
+
if(det < 0.0) discard;
|
|
1448
|
+
float sqrtDet = sqrt(det);
|
|
1449
|
+
float posT = (-B+sqrtDet)/(2.0*A);
|
|
1450
|
+
float negT = (-B-sqrtDet)/(2.0*A);
|
|
1451
|
+
float intersectionT = min(posT,negT);
|
|
1452
|
+
vec3 qi = p+v*intersectionT;
|
|
1453
|
+
float dotp1 = dot(va,qi-p1);
|
|
1454
|
+
float dotp2 = dot(va,qi-p2);
|
|
1455
|
+
vec3 norm;
|
|
1456
|
+
if( dotp1 < 0.0 || dotp2 > 0.0) { //(p-c)^2 + 2(p-c)vt +v^2+t^2 - r^2 = 0
|
|
1457
|
+
vec3 cp;
|
|
1458
|
+
if( dotp1 < 0.0) {
|
|
1459
|
+
// if(vColor.x < 0.0 ) discard; //color sign bit indicates if we should cap or not
|
|
1460
|
+
cp = p1;
|
|
1461
|
+
} else {
|
|
1462
|
+
// if(vColor.y < 0.0 ) discard;
|
|
1463
|
+
cp = p2;
|
|
1464
|
+
}
|
|
1465
|
+
vec3 diff = p-cp;
|
|
1466
|
+
A = dot(v,v);
|
|
1467
|
+
B = dot(diff,v)*2.0;
|
|
1468
|
+
C = dot(diff,diff)-r*r;
|
|
1469
|
+
det = (B*B) - (4.0*C);
|
|
1470
|
+
if(det < 0.0) discard;
|
|
1471
|
+
sqrtDet = sqrt(det);
|
|
1472
|
+
posT = (-B+sqrtDet)/(2.0);
|
|
1473
|
+
negT = (-B-sqrtDet)/(2.0);
|
|
1474
|
+
float t = min(posT,negT);
|
|
1475
|
+
qi = p+v*t;
|
|
1476
|
+
norm = normalize(qi-cp);
|
|
1477
|
+
} else {
|
|
1478
|
+
norm = normalize(qi-(dotp1*va + p1));
|
|
1479
|
+
}
|
|
1480
|
+
vec4 clipPos = projectionMatrix * vec4(qi, 1.0);
|
|
1481
|
+
float ndcDepth = clipPos.z / clipPos.w;
|
|
1482
|
+
float depth = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
|
1483
|
+
gl_FragDepthEXT = depth;`},"./src/WebGL/shaders/lib/stickimposter/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},directionalLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]}}},"./src/WebGL/shaders/lib/stickimposteroutline/index.ts"(k,w,c){c.r(w),c.d(w,{stickimposteroutline:()=>y});var b=c("./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/stickimposter/stickimposterFragmentShader.partial.frag"),C=c("./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.partial.frag"),R=c("./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert");const y={fragmentShader:O.default+C.default,vertexShader:R.default,uniforms:b.uniforms}},"./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.partial.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1484
|
+
gl_FragColor = vec4(color, opacity*opacity );
|
|
1485
|
+
if(fogNear != fogFar) {
|
|
1486
|
+
float depth = -qi.z;
|
|
1487
|
+
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
|
1488
|
+
gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
|
|
1489
|
+
}
|
|
1490
|
+
}`},"./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1491
|
+
|
|
1492
|
+
uniform mat4 modelViewMatrix;
|
|
1493
|
+
uniform mat4 projectionMatrix;
|
|
1494
|
+
uniform mat4 viewMatrix;
|
|
1495
|
+
uniform mat3 normalMatrix;
|
|
1496
|
+
uniform vec3 directionalLightColor[ 1 ];
|
|
1497
|
+
uniform vec3 directionalLightDirection[ 1 ];
|
|
1498
|
+
uniform vec3 outlineColor;
|
|
1499
|
+
uniform float outlineWidth;
|
|
1500
|
+
uniform float outlinePushback;
|
|
1501
|
+
uniform float outlineMaxPixels;
|
|
1502
|
+
uniform float vWidth;
|
|
1503
|
+
uniform mat4 projinv;
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
attribute vec3 position;
|
|
1507
|
+
attribute vec3 normal;
|
|
1508
|
+
attribute vec3 color;
|
|
1509
|
+
attribute float radius;
|
|
1510
|
+
|
|
1511
|
+
varying vec3 vColor;
|
|
1512
|
+
varying vec3 vLight;
|
|
1513
|
+
varying vec3 cposition;
|
|
1514
|
+
varying vec3 p1;
|
|
1515
|
+
varying vec3 p2;
|
|
1516
|
+
varying float r;
|
|
1517
|
+
|
|
1518
|
+
void main() {
|
|
1519
|
+
|
|
1520
|
+
vColor = outlineColor;
|
|
1521
|
+
float rad = radius+sign(radius)*outlineWidth;
|
|
1522
|
+
r = abs(rad);
|
|
1523
|
+
|
|
1524
|
+
vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder
|
|
1525
|
+
vec4 pt = modelViewMatrix*vec4(position, 1.0);
|
|
1526
|
+
//pushback
|
|
1527
|
+
float scale = 1.0;
|
|
1528
|
+
if(projectionMatrix[3][3] != 0.0) { //orthographic
|
|
1529
|
+
to.z -= outlinePushback;
|
|
1530
|
+
pt.z -= outlinePushback;
|
|
1531
|
+
} else { //perspective
|
|
1532
|
+
vec4 midbefore = pt;
|
|
1533
|
+
if(length(to.xyz) < length(pt)) {
|
|
1534
|
+
midbefore = to;
|
|
1535
|
+
}
|
|
1536
|
+
vec4 midafter = midbefore;
|
|
1537
|
+
midafter.xyz += normalize(midbefore.xyz)*outlinePushback;
|
|
1538
|
+
|
|
1539
|
+
to.xyz += normalize(to.xyz)*outlinePushback;
|
|
1540
|
+
pt.xyz += normalize(pt.xyz)*outlinePushback;
|
|
1541
|
+
|
|
1542
|
+
//figure out a scaling factor for radius to account for perspective setback
|
|
1543
|
+
vec4 midbeforer = vec4(midbefore.x+rad,midbefore.y, midbefore.z, midbefore.w);
|
|
1544
|
+
vec4 midafterr = vec4(midafter.x+rad,midafter.y, midafter.z, midafter.w);
|
|
1545
|
+
|
|
1546
|
+
vec4 mb = projectionMatrix*midbefore;
|
|
1547
|
+
vec4 mbr = projectionMatrix*midbeforer;
|
|
1548
|
+
vec4 ma = projectionMatrix*midafter;
|
|
1549
|
+
vec4 mar = projectionMatrix*midafterr;
|
|
1550
|
+
mb /= mb.w;
|
|
1551
|
+
mbr /= mbr.w;
|
|
1552
|
+
ma /= ma.w;
|
|
1553
|
+
mar /= mar.w;
|
|
1554
|
+
scale = abs((mbr.x-mb.x)/(mar.x-ma.x));
|
|
1555
|
+
rad *= scale;
|
|
1556
|
+
r = abs(rad);
|
|
1557
|
+
}
|
|
1558
|
+
vec4 mvPosition = pt;
|
|
1559
|
+
p1 = pt.xyz; p2 = to.xyz;
|
|
1560
|
+
vec3 norm = to.xyz-pt.xyz;
|
|
1561
|
+
float mult = 1.1; //slop to account for perspective of sphere
|
|
1562
|
+
if(length(p1) > length(p2)) { //billboard at level of closest point
|
|
1563
|
+
mvPosition = to;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
vec3 n = normalize(mvPosition.xyz);
|
|
1567
|
+
//intersect with the plane defined by the camera looking at the billboard point
|
|
1568
|
+
if(color.z >= 0.0) { //p1
|
|
1569
|
+
vec3 pnorm = normalize(p1);
|
|
1570
|
+
float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);
|
|
1571
|
+
mvPosition.xyz = p1+t*pnorm;
|
|
1572
|
+
} else {
|
|
1573
|
+
vec3 pnorm = normalize(p2);
|
|
1574
|
+
float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);
|
|
1575
|
+
mvPosition.xyz = p2+t*pnorm;
|
|
1576
|
+
mult *= -1.0;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
if(outlineMaxPixels > 0.0) {
|
|
1580
|
+
vec4 cpos = mvPosition;
|
|
1581
|
+
vec4 unadjusted = projectionMatrix*vec4(cpos.x+abs(scale*radius), cpos.y,cpos.z,cpos.w);
|
|
1582
|
+
vec4 ccoord = projectionMatrix*cpos;
|
|
1583
|
+
vec4 adjust = projectionMatrix*vec4(cpos.x+r,cpos.y,cpos.z,cpos.w);
|
|
1584
|
+
unadjusted /= unadjusted.w;
|
|
1585
|
+
adjust /= adjust.w;
|
|
1586
|
+
unadjusted.xyz -= ccoord.xyz/ccoord.w;
|
|
1587
|
+
adjust.xyz -= ccoord.xyz/ccoord.w;
|
|
1588
|
+
float diff = abs(adjust.x-unadjusted.x);
|
|
1589
|
+
diff *= vWidth; //this should now be in pixels
|
|
1590
|
+
if(diff > outlineMaxPixels) {
|
|
1591
|
+
float fixlen = abs(unadjusted.x) + outlineMaxPixels/vWidth;
|
|
1592
|
+
vec4 pcoord = ccoord;
|
|
1593
|
+
pcoord.x += fixlen*pcoord.w;
|
|
1594
|
+
vec4 altc = projinv*pcoord;
|
|
1595
|
+
r= abs(altc.x-cpos.x);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
vec3 cr = normalize(cross(mvPosition.xyz,norm))*rad;
|
|
1600
|
+
vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*rad;
|
|
1601
|
+
mvPosition.xy += mult*(cr + doublecr).xy;
|
|
1602
|
+
cposition = mvPosition.xyz;
|
|
1603
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1604
|
+
vLight = vec3(1.0,1.0,1.0);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
`},"./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineColor:{type:"c",value:new b.Color(0,0,0)},outlineWidth:{type:"f",value:.1},outlinePushback:{type:"f",value:1},outlineMaxPixels:{type:"f",value:0},projinv:{type:"mat4",value:[]}}},"./src/WebGL/shaders/lib/volumetric/index.ts"(k,w,c){c.r(w),c.d(w,{volumetric:()=>R});var b=c("./src/WebGL/shaders/lib/volumetric/uniforms.ts"),O=c("./src/WebGL/shaders/lib/volumetric/volumetric.frag"),C=c("./src/WebGL/shaders/lib/volumetric/volumetric.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:C.default.replace("#define GLSLIFY 1",""),uniforms:b.uniforms}},"./src/WebGL/shaders/lib/volumetric/uniforms.ts"(k,w,c){c.r(w),c.d(w,{uniforms:()=>O});var b=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new b.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}}},"./src/WebGL/shaders/lib/volumetric/volumetric.frag"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`
|
|
1608
|
+
uniform highp sampler3D data;
|
|
1609
|
+
uniform highp sampler2D colormap;
|
|
1610
|
+
uniform highp sampler2D depthmap;
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
uniform mat4 textmat;
|
|
1614
|
+
uniform mat4 projinv;
|
|
1615
|
+
uniform mat4 projectionMatrix;
|
|
1616
|
+
|
|
1617
|
+
uniform float step;
|
|
1618
|
+
uniform float subsamples;
|
|
1619
|
+
uniform float maxdepth;
|
|
1620
|
+
uniform float transfermin;
|
|
1621
|
+
uniform float transfermax;
|
|
1622
|
+
in vec4 mvPosition;
|
|
1623
|
+
out vec4 color;
|
|
1624
|
+
void main(void) {
|
|
1625
|
+
|
|
1626
|
+
vec4 pos = mvPosition;
|
|
1627
|
+
bool seengood = false;
|
|
1628
|
+
float i = 0.0;
|
|
1629
|
+
color = vec4(1,1,1,0);
|
|
1630
|
+
float increment = 1.0/subsamples;
|
|
1631
|
+
float maxsteps = (maxdepth*subsamples/step);
|
|
1632
|
+
//there's probably a better way to do this..
|
|
1633
|
+
//calculate farthest possible point in model coordinates
|
|
1634
|
+
vec4 maxpos = vec4(pos.x,pos.y,pos.z-maxdepth,1.0);
|
|
1635
|
+
// convert to projection
|
|
1636
|
+
maxpos = projectionMatrix*maxpos;
|
|
1637
|
+
vec4 startp = projectionMatrix*pos;
|
|
1638
|
+
// homogonize
|
|
1639
|
+
maxpos /= maxpos.w;
|
|
1640
|
+
startp /= startp.w;
|
|
1641
|
+
//take x,y from start and z from max
|
|
1642
|
+
maxpos = vec4(startp.x,startp.y,maxpos.z,1.0);
|
|
1643
|
+
//convert back to model space
|
|
1644
|
+
maxpos = projinv*maxpos;
|
|
1645
|
+
maxpos /= maxpos.w;
|
|
1646
|
+
float incr = step/subsamples;
|
|
1647
|
+
//get depth from depthmap
|
|
1648
|
+
//startp is apparently [-1,1]
|
|
1649
|
+
vec2 tpos = startp.xy/2.0+0.5;
|
|
1650
|
+
float depth = texture(depthmap, tpos).r;
|
|
1651
|
+
//compute vector between start and end
|
|
1652
|
+
vec4 direction = maxpos-pos;
|
|
1653
|
+
for( i = 0.0; i <= maxsteps; i++) {
|
|
1654
|
+
vec4 pt = (pos+(i/maxsteps)*direction);
|
|
1655
|
+
vec4 ppt = projectionMatrix*pt;
|
|
1656
|
+
float ptdepth = ppt.z/ppt.w;
|
|
1657
|
+
ptdepth = ((gl_DepthRange.diff * ptdepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
|
1658
|
+
if(ptdepth > depth) break;
|
|
1659
|
+
pt = textmat*pt;
|
|
1660
|
+
// pt /= pt.w;
|
|
1661
|
+
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) {
|
|
1662
|
+
seengood = true;
|
|
1663
|
+
} else if(seengood) {
|
|
1664
|
+
break;
|
|
1665
|
+
}
|
|
1666
|
+
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 ){
|
|
1667
|
+
color.a = 0.0;
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
float val = texture(data, pt.zyx).r;
|
|
1672
|
+
if(isinf(val)) continue; //masked out
|
|
1673
|
+
float cval = (val-transfermin)/(transfermax-transfermin); //scale to texture 0-1 range
|
|
1674
|
+
vec4 val_color = texture(colormap, vec2(cval,0.5));
|
|
1675
|
+
color.rgb = color.rgb*color.a + (1.0-color.a)*val_color.a*val_color.rgb;
|
|
1676
|
+
color.a += (1.0 - color.a) * val_color.a;
|
|
1677
|
+
if(color.a > 0.0) color.rgb /= color.a;
|
|
1678
|
+
// color = vec4(pt.x, pt.y, pt.z, 1.0);
|
|
1679
|
+
}
|
|
1680
|
+
// color = vec4(pt.x, pt.y, pt.z, 0.0)
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
`},"./src/WebGL/shaders/lib/volumetric/volumetric.vert"(k,w,c){c.r(w),c.d(w,{default:()=>b});const b=`uniform mat4 modelViewMatrix;
|
|
1685
|
+
uniform mat4 projectionMatrix;
|
|
1686
|
+
uniform mat4 viewMatrix;
|
|
1687
|
+
|
|
1688
|
+
in vec3 position;
|
|
1689
|
+
out vec4 mvPosition;
|
|
1690
|
+
void main() {
|
|
1691
|
+
|
|
1692
|
+
mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1693
|
+
gl_Position = projectionMatrix*mvPosition;
|
|
1694
|
+
}
|
|
1695
|
+
`},"./src/WebGL/shaders/utils/clone.ts"(k,w,c){c.r(w),c.d(w,{clone:()=>O});var b=c("./src/colors.ts");function O(C){let R={};for(const y in C){R[y]={},R[y].type=C[y].type;var v=C[y].value;v instanceof b.Color?R[y].value=v.clone():typeof v=="number"?R[y].value=v:v instanceof Array?R[y].value=[]:console.error("Error copying shader uniforms from ShaderLib: unknown type for uniform")}return R}},"./src/WebGL/shaders/utils/index.ts"(k,w,c){c.r(w),c.d(w,{ShaderUtils:()=>O,clone:()=>b.clone});var b=c("./src/WebGL/shaders/utils/clone.ts");const O={clone:b.clone}},"./src/WebGL/shapes/Cylinder.ts"(k,w,c){c.r(w),c.d(w,{Cylinder:()=>C});var b=c("./src/WebGL/math/index.ts");let O=new b.Vector3;class C{constructor(v=new b.Vector3,y=new b.Vector3,M=0){this.c1=v,this.c2=y,this.radius=M,this.direction=new b.Vector3().subVectors(this.c2,this.c1).normalize()}copy(v){return this.c1.copy(v.c1),this.c2.copy(v.c2),this.direction.copy(v.direction),this.radius=v.radius,this}lengthSq(){return O.subVectors(this.c2,this.c1).lengthSq()}applyMatrix4(v){return this.direction.add(this.c1).applyMatrix4(v),this.c1.applyMatrix4(v),this.c2.applyMatrix4(v),this.direction.sub(this.c1).normalize(),this.radius=this.radius*v.getMaxScaleOnAxis(),this}}},"./src/WebGL/shapes/Sphere.ts"(k,w,c){c.r(w),c.d(w,{Sphere:()=>O});var b=c("./src/WebGL/math/index.ts");class O{constructor(R={x:0,y:0,z:0},v=0){this.center=new b.Vector3(R.x,R.y,R.z),this.radius=v}set(R,v){return this.center.copy(R),this.radius=v,this}copy(R){return this.center.copy(R.center),this.radius=R.radius,this}applyMatrix4(R){return this.center.applyMatrix4(R),this.radius=this.radius*R.getMaxScaleOnAxis(),this}translate(R){return this.center.add(R),this}equals(R){return R.center.equals(this.center)&&R.radius===this.radius}clone(){return new O().copy(this)}}},"./src/WebGL/shapes/Triangle.ts"(k,w,c){c.r(w),c.d(w,{Triangle:()=>C});var b=c("./src/WebGL/math/index.ts");const O=new b.Vector3;class C{constructor(v=new b.Vector3,y=new b.Vector3,M=new b.Vector3){this.a=v,this.b=y,this.c=M}copy(v){return this.a.copy(v.a),this.b.copy(v.b),this.c.copy(v.c),this}applyMatrix4(v){return this.a.applyMatrix4(v),this.b.applyMatrix4(v),this.c.applyMatrix4(v),this}getNormal(){var v=this.a.clone();return v.sub(this.b),O.subVectors(this.c,this.b),v.cross(O),v.normalize(),v}}},"./src/WebGL/shapes/index.ts"(k,w,c){c.r(w),c.d(w,{Cylinder:()=>O.Cylinder,Sphere:()=>b.Sphere,Triangle:()=>C.Triangle});var b=c("./src/WebGL/shapes/Sphere.ts"),O=c("./src/WebGL/shapes/Cylinder.ts"),C=c("./src/WebGL/shapes/Triangle.ts")},"./src/autoload.ts"(k,w,c){c.r(w),c.d(w,{autoinit:()=>v,autoload:()=>g,processing_autoinit:()=>y,viewers:()=>M});var b=c("./src/GLViewer.ts"),O=c("./src/ProteinSurface4.ts"),C=c("./src/utilities.ts"),R=c("./src/colors.ts"),v=!1,y=!1,M={};function g(x,_){var p,m,r;if(document.querySelector(".viewer_3Dmoljs")!=null&&(v=!0),v){y=!0,x=x??null;var e=0;document.querySelectorAll(".viewer_3Dmoljs").forEach(t=>{var s=[],o=[],l="";t.style.position=="static"&&(t.style.position="relative");var d=null;if(r=null,t.dataset.pdb)s.push("https://files.rcsb.org/view/"+t.dataset.pdb+".pdb"),o.push("pdb");else if(t.dataset.cid)o.push("sdf"),s.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+t.dataset.cid+"/SDF?record_type=3d");else if(t.dataset.href||t.dataset.url){if(t.dataset.href?l=t.dataset.href:l=t.dataset.url,s.push(l),r=l.substring(l.lastIndexOf(".")+1),r=="gz"){let ee=l.substring(0,l.lastIndexOf(".")).lastIndexOf(".");r=l.substring(ee+1)}o.push(r);var i=l.substring(l.lastIndexOf("/")+1,l.lastIndexOf("."));i=="/"&&(i=l.substring(l.lastIndexOf("/")+1)),t.dataset[o[o.length-1]]=i}let n=t.dataset;for(p in n)p.substring(0,3)==="pdb"&&p!=="pdb"?(s.push("https://files.rcsb.org/view/"+n[p]+".pdb"),o.push("pdb")):p.substring(0,4)==="href"&&p!=="href"?(l=n[p],s.push(l),o.push(l.substring(l.lastIndexOf(".")+1))):p.substring(0,3)==="cid"&&p!=="cid"&&(s.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+n[p]+"/SDF?record_type=3d"),o.push("sdf"));var a={};t.dataset.options&&(a=(0,C.specStringToObject)(t.dataset.options));var h=R.CC.color(t.dataset.backgroundcolor),u=t.dataset.backgroundalpha;u=u==null?1:parseFloat(u);var A=!!t.dataset.style,D={line:{}};A&&(D=(0,C.specStringToObject)(t.dataset.style));var T={};t.dataset.select&&(T=(0,C.specStringToObject)(t.dataset.select));var S=[],P=[],z=[],F={},B=null,W=t.dataset,U=/style(.+)/,I=/surface(.*)/,G=/labelres(.*)/,Y=[];for(m in W)Object.prototype.hasOwnProperty.call(W,m)&&Y.push(m);for(Y.sort(),p=0;p<Y.length;p++){m=Y[p];var J=U.exec(m),te,ne,le;J&&(te="select"+J[1],ne=(0,C.specStringToObject)(W[te]),le=(0,C.specStringToObject)(W[m]),S.push([ne,le])),J=I.exec(m),J&&(te="select"+J[1],ne=(0,C.specStringToObject)(W[te]),le=(0,C.specStringToObject)(W[m]),P.push([ne,le])),J=G.exec(m),J&&(te="select"+J[1],ne=(0,C.specStringToObject)(W[te]),le=(0,C.specStringToObject)(W[m]),z.push([ne,le])),m=="zoomto"&&(F=(0,C.specStringToObject)(W[m])),m=="spin"&&(B=(0,C.specStringToObject)(W[m]))}var ie=function(ee){for(A?ee.setStyle(T,D):ee.addStyle(T,D),d&&d.createSelectionAndStyle(T,D),p=0;p<S.length;p++){let pe=S[p][0]||{},Ce=S[p][1]||{line:{}};ee.setStyle(pe,Ce),d&&d.createSelectionAndStyle(T,D)}for(p=0;p<P.length;p++){let pe=P[p][0]||{},Ce=P[p][1]||{};d?ee.addSurface(O.SurfaceType.VDW,Ce,pe,pe).then(We=>{d.loadSurface("VDW",pe,Ce,We)}):ee.addSurface(O.SurfaceType.VDW,Ce,pe,pe)}for(p=0;p<z.length;p++){let pe=z[p][0]||{},Ce=z[p][1]||{};ee.addResLabels(pe,Ce)}ee.render(),ee.zoomTo(F),B&&ee.spin(B.axis,B.speed)};let oe=x;try{var xe=(0,C.specStringToObject)(t.dataset.config)||{};xe.backgroundColor===void 0&&(xe.backgroundColor=h),xe.backgroundAlpha===void 0&&(xe.backgroundAlpha=u),oe==null?oe=M[t.id||e++]=(0,b.createViewer)(t,xe):(oe.setBackgroundColor(h,u),oe.setConfig(xe),d&&d.initiateUI()),t.dataset.ui&&$3Dmol.StateManager&&(d=new $3Dmol.StateManager(oe))}catch(ee){console.log(ee),t.textContent="WebGL appears to be disabled."}if(s.length!=0){let ee=0,pe=((Ce,Te)=>function(We){l=s[ee];var Ie=Ce.dataset.type||Ce.dataset.datatype||o[ee];if(Te.addModel(We,Ie,a),d){var Be=Ce.dataset[o[ee]];d.setModelTitle(Be)}ee+=1,ee<s.length?(0,C.get)(s[ee]).then(pe):(ie(Te),Ce.dataset.callback&&(0,C.makeFunction)(Ce.dataset.callback)(Te),y=!1,_&&_(Te))})(t,oe);r&&r.endsWith("gz")?(0,C.getbin)(s[0]).then(pe):(0,C.get)(s[0]).then(pe)}else{if(t.dataset.element){var _e="#"+t.dataset.element,Oe=document.querySelector(_e),ye=Oe?Oe.textContent:"";r=t.dataset.type||t.dataset.datatype,oe.addModel(ye,r,a)}ie(oe),t.dataset.callback&&(0,C.makeFunction)(t.dataset.callback)(oe),y=!1,_&&_(oe)}})}}document.onreadystatechange=()=>{document.readyState==="complete"&&g()}},"./src/colors.ts"(k,w,c){c.r(w),c.d(w,{CC:()=>O,Color:()=>b,builtinColorSchemes:()=>x,chains:()=>g,elementColors:()=>y,htmlColors:()=>C,residues:()=>M,ssColors:()=>R});class b{constructor(p,m,r){return this.r=0,this.g=0,this.b=0,arguments.length>1&&typeof p=="number"?(this.r=p||0,this.g=m||0,this.b=r||0,this):this.set(p||0)}set(p){return p instanceof b?p.clone():(typeof p=="number"?this.setHex(p):typeof p=="object"&&(this.r=(p==null?void 0:p.r)||0,this.g=(p==null?void 0:p.g)||0,this.b=(p==null?void 0:p.b)||0),this)}setHex(p){return p=Math.floor(p),this.r=(p>>16&255)/255,this.g=(p>>8&255)/255,this.b=(p&255)/255,this}getHex(){var p=Math.round(this.r*255),m=Math.round(this.g*255),r=Math.round(this.b*255);return p<<16|m<<8|r}clone(){return new b(this.r,this.g,this.b)}copy(p){return this.r=p.r,this.g=p.g,this.b=p.b,this}scaled(){var p={};return p.r=Math.round(this.r*255),p.g=Math.round(this.g*255),p.b=Math.round(this.b*255),p.a=1,p}}class O{static color(p){if(!p)return O.cache[0];if(p instanceof b)return p;if(typeof p=="number"&&typeof O.cache[p]<"u")return O.cache[p];if(p&&Array.isArray(p))return p.map(O.color);let m=O.getHex(p),r=new b(m);return O.cache[m]=r,r}static getHex(p){if(Array.isArray(p))return p.map(O.getHex);if(typeof p=="string"){let m=p;if(!isNaN(parseInt(m)))return parseInt(m);if(m=m.trim(),m.length==4&&m[0]=="#"&&(m="#"+m[1]+m[1]+m[2]+m[2]+m[3]+m[3]),m.length==7&&m[0]=="#")return parseInt(m.substring(1),16);let r=O.rgbRegEx.exec(m);if(r){r[1]!=""&&console.log("WARNING: Opacity value in rgba ignored. Specify separately as opacity attribute.");let t=0;for(let s=2;s<5;s++){t*=256;let o=r[s].endsWith("%")?255*parseFloat(r[s])/100:parseFloat(r[s]);t+=Math.round(o)}return t}let e=C[m.toLowerCase()];return e!==void 0?e:(console.error("color not found",p.toLowerCase(),C),0)}return p}}O.rgbRegEx=/rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i,O.cache={0:new b(0)};const C={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,b:255,g:32768,r:16711680,c:49087,m:12517567,y:12566272,k:0,w:16777215},R={pyMol:{h:16711680,s:16776960,c:65280},Jmol:{h:16711808,s:16762880,c:16777215}},v={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},y={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:v,defaultColors:Object.assign({},v),greenCarbon:Object.assign(Object.assign({},v),{C:65280}),cyanCarbon:Object.assign(Object.assign({},v),{C:65535}),magentaCarbon:Object.assign(Object.assign({},v),{C:16711935}),yellowCarbon:Object.assign(Object.assign({},v),{C:16776960}),whiteCarbon:Object.assign(Object.assign({},v),{C:16777215}),orangeCarbon:Object.assign(Object.assign({},v),{C:16753920}),purpleCarbon:Object.assign(Object.assign({},v),{C:8388736}),blueCarbon:Object.assign(Object.assign({},v),{C:255})},M={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}},g={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}},x={ssPyMol:{prop:"ss",map:R.pyMol},ssJmol:{prop:"ss",map:R.Jmol},Jmol:{prop:"elem",map:y.Jmol},amino:{prop:"resn",map:M.amino},shapely:{prop:"resn",map:M.shapely},nucleic:{prop:"resn",map:M.nucleic},chain:{prop:"chain",map:g.atom},rasmol:{prop:"elem",map:y.rasmol},default:{prop:"elem",map:y.defaultColors},greenCarbon:{prop:"elem",map:y.greenCarbon},chainHetatm:{prop:"chain",map:g.hetatm},cyanCarbon:{prop:"elem",map:y.cyanCarbon},magentaCarbon:{prop:"elem",map:y.magentaCarbon},purpleCarbon:{prop:"elem",map:y.purpleCarbon},whiteCarbon:{prop:"elem",map:y.whiteCarbon},orangeCarbon:{prop:"elem",map:y.orangeCarbon},yellowCarbon:{prop:"elem",map:y.yellowCarbon},blueCarbon:{prop:"elem",map:y.blueCarbon}}},"./src/exporter.js"(k){typeof k.exports=="object"&&(k.exports=window.$3Dmol)},"./src/glcartoon.ts"(k,w,c){c.r(w),c.d(w,{drawCartoon:()=>D,subdivide_spline:()=>g});var b=c("./src/WebGL/math/index.ts"),O=c("./src/WebGL/shapes/index.ts"),C=c("./src/WebGL/index.ts"),R=c("./src/Gradient.ts"),v=c("./src/colors.ts"),y=c("./src/GLDraw.ts"),M=c("./src/utilities.ts");function g(T,S){var P=[],z=T;z=[],z.push(T[0]);var F,B,W,U,I,G,Y,J,te;for(F=1,B=T.length-1;F<B;F++)if(I=T[F],G=T[F+1],I.smoothen){var ne=new b.Vector3((I.x+G.x)/2,(I.y+G.y)/2,(I.z+G.z)/2);ne.atom=I.atom,z.push(ne)}else z.push(I);for(z.push(T[T.length-1]),F=-1,W=z.length;F<=W-3;F++)if(U=z[F===-1?0:F],I=z[F+1],G=z[F+2],Y=z[F===W-3?W-1:F+3],J=new b.Vector3().subVectors(G,U).multiplyScalar(.5),te=new b.Vector3().subVectors(Y,I).multiplyScalar(.5),!G.skip)for(var le=0;le<S;le++){var ie=1/S*le,oe=I.x+ie*J.x+ie*ie*(-3*I.x+3*G.x-2*J.x-te.x)+ie*ie*ie*(2*I.x-2*G.x+J.x+te.x),xe=I.y+ie*J.y+ie*ie*(-3*I.y+3*G.y-2*J.y-te.y)+ie*ie*ie*(2*I.y-2*G.y+J.y+te.y),_e=I.z+ie*J.z+ie*ie*(-3*I.z+3*G.z-2*J.z-te.z)+ie*ie*ie*(2*I.z-2*G.z+J.z+te.z),Oe=new b.Vector3(oe,xe,_e);le<S/2?Oe.atom=I.atom:Oe.atom=G.atom,P.push(Oe)}return P.push(z[z.length-1]),P}const x=.5,_=1.3,p=.8,m=.4,r=.4;function e(T,S,P,z){for(var F,B,W,U,I=0,G=S.length;I<G;I++){U=Math.round(I*(z.length-1)/G),W=v.CC.color(z[U]);var Y=T.updateGeoGroup(2),J=Y.vertexArray,te=Y.colorArray,ne=Y.faceArray;F=Y.vertices,B=F*3,J[B]=S[I].x,J[B+1]=S[I].y,J[B+2]=S[I].z,J[B+3]=P[I].x,J[B+4]=P[I].y,J[B+5]=P[I].z;for(var le=0;le<6;++le)te[B+3*le]=W.r,te[B+1+3*le]=W.g,te[B+2+3*le]=W.b;if(I>0){var ie=[F,F+1,F-1,F-2],oe=Y.faceidx;ne[oe]=ie[0],ne[oe+1]=ie[1],ne[oe+2]=ie[3],ne[oe+3]=ie[1],ne[oe+4]=ie[2],ne[oe+5]=ie[3],Y.faceidx+=6}Y.vertices+=2}}function t(T,S,P,z,F,B,W){var U,I,G,Y;if(G=S.length,G<2||S[0].length<2)return;for(U=0;U<G;U++)S[U]=g(S[U],z);if(Y=S[0].length,!F)return e(T,S[0],S[G-1],P);var J,te,ne,le,ie,oe,xe=[],_e=[],Oe=[];for(I=0;I<G;I++)xe.push(.25+1.5*Math.sqrt((G-1)*I-Math.pow(I,2))/(G-1)),_e.push(.5),Oe.push(2*(Math.pow(I/G,2)-I/G)+.6);var ye=[];for(I=0;I<G*2-1;I++)ye[I]=[I,I+1,I+1-2*G,I-2*G];ye[G*2-1]=[I,I+1-2*G,I+1-4*G,I-2*G];var ee,pe,Ce,Te,We,Ie,Be,Fe,ze,Pe;let Re=T.updateGeoGroup();for(U=0;U<Y;U++){let Z=T.groups,$=!1;Re=T.updateGeoGroup(2*G),Z!=T.groups&&U>0&&(U=U-1,$=!0),Ie=Math.round(U*(P.length-1)/Y),We=v.CC.color(P[Ie]),ie=ne,oe=le,ne=[],le=[],J=[],S[0][U].atom!==void 0&&(Te=S[0][U].atom,W==="oval"?te=xe:W==="rectangle"?te=_e:W==="parabola"&&(te=Oe)),te||(te=_e);var je,ke;for(I=0;I<G;I++)U<Y-1?je=S[I][U+1].clone().sub(S[I][U]):je=S[I][U-1].clone().sub(S[I][U]).negate(),I<G-1?ke=S[I+1][U].clone().sub(S[I][U]):ke=S[I-1][U].clone().sub(S[I][U]).negate(),J[I]=ke.cross(je).normalize().multiplyScalar(F*te[I]);for(I=0;I<G;I++)ne[I]=S[I][U].clone().add(J[I].clone().negate());for(I=0;I<G;I++)le[I]=S[I][U].clone().add(J[I]);for(Be=Re.vertexArray,Fe=Re.colorArray,ze=Re.faceArray,ee=Re.vertices,pe=ee*3,I=0;I<G;I++)Be[pe+3*I+0]=ne[I].x,Be[pe+3*I+1]=ne[I].y,Be[pe+3*I+2]=ne[I].z;for(I=0;I<G;I++)Be[pe+3*I+0+3*G]=le[G-1-I].x,Be[pe+3*I+1+3*G]=le[G-1-I].y,Be[pe+3*I+2+3*G]=le[G-1-I].z;for(I=0;I<2*G;++I)Fe[pe+3*I+0]=We.r,Fe[pe+3*I+1]=We.g,Fe[pe+3*I+2]=We.b;if(U>0&&!$){for(I=0;I<G*2;I++)Pe=[ee+ye[I][0],ee+ye[I][1],ee+ye[I][2],ee+ye[I][3]],Ce=Re.faceidx,ze[Ce]=Pe[0],ze[Ce+1]=Pe[1],ze[Ce+2]=Pe[3],ze[Ce+3]=Pe[1],ze[Ce+4]=Pe[2],ze[Ce+5]=Pe[3],Re.faceidx+=6;if(Te.clickable||Te.hoverable){var K=[];K.push(new O.Triangle(ie[0],ne[0],ne[G-1])),K.push(new O.Triangle(ie[0],ne[G-1],ie[G-1])),K.push(new O.Triangle(ie[G-1],ne[G-1],le[G-1])),K.push(new O.Triangle(ie[G-1],le[G-1],oe[G-1])),K.push(new O.Triangle(le[0],oe[0],oe[G-1])),K.push(new O.Triangle(le[G-1],le[0],oe[G-1])),K.push(new O.Triangle(ne[0],ie[0],oe[0])),K.push(new O.Triangle(le[0],ne[0],oe[0]));for(I in K)Te.intersectionShape.triangle.push(K[I])}}Re.vertices+=2*G}for(Be=Re.vertexArray,Fe=Re.colorArray,ze=Re.faceArray,ee=Re.vertices,pe=ee*3,Ce=Re.faceidx,U=0;U<G-1;U++)Pe=[U,U+1,2*G-2-U,2*G-1-U],Ce=Re.faceidx,ze[Ce]=Pe[0],ze[Ce+1]=Pe[1],ze[Ce+2]=Pe[3],ze[Ce+3]=Pe[1],ze[Ce+4]=Pe[2],ze[Ce+5]=Pe[3],Re.faceidx+=6;for(U=0;U<G-1;U++)Pe=[ee-1-U,ee-2-U,ee-2*G+U+1,ee-2*G+U],Ce=Re.faceidx,ze[Ce]=Pe[0],ze[Ce+1]=Pe[1],ze[Ce+2]=Pe[3],ze[Ce+3]=Pe[1],ze[Ce+4]=Pe[2],ze[Ce+5]=Pe[3],Re.faceidx+=6}function s(T,S,P,z,F,B){if(!(S.length<2)){var W,U;if(W=S[0],U=S[S.length-1],W=g(W,z),U=g(U,z),!F)return e(T,W,U,P);var I=[],G,Y,J,te,ne,le=[[0,2,-6,-8],[-4,-2,6,4],[7,-1,-5,3],[-3,5,1,-7]],ie,oe,xe,_e,Oe,ye,ee,pe,Ce,Te,We,Ie,Be,Fe,ze,Pe,Re;for(pe=0,Ce=W.length;pe<Ce;pe++){if(Oe=Math.round(pe*(P.length-1)/Ce),_e=v.CC.color(P[Oe]),I.push(Y=W[pe]),I.push(Y),I.push(J=U[pe]),I.push(J),pe<Ce-1){var je=W[pe+1].clone().sub(W[pe]),ke=U[pe].clone().sub(W[pe]);G=ke.cross(je).normalize().multiplyScalar(F)}for(I.push(te=W[pe].clone().add(G)),I.push(te),I.push(ne=U[pe].clone().add(G)),I.push(ne),Y.atom!==void 0&&(ye=Y.atom),Fe=T.updateGeoGroup(8),ze=Fe.vertexArray,Pe=Fe.colorArray,Re=Fe.faceArray,ie=Fe.vertices,oe=ie*3,ze[oe]=Y.x,ze[oe+1]=Y.y,ze[oe+2]=Y.z,ze[oe+3]=Y.x,ze[oe+4]=Y.y,ze[oe+5]=Y.z,ze[oe+6]=J.x,ze[oe+7]=J.y,ze[oe+8]=J.z,ze[oe+9]=J.x,ze[oe+10]=J.y,ze[oe+11]=J.z,ze[oe+12]=te.x,ze[oe+13]=te.y,ze[oe+14]=te.z,ze[oe+15]=te.x,ze[oe+16]=te.y,ze[oe+17]=te.z,ze[oe+18]=ne.x,ze[oe+19]=ne.y,ze[oe+20]=ne.z,ze[oe+21]=ne.x,ze[oe+22]=ne.y,ze[oe+23]=ne.z,Te=0;Te<8;++Te)Pe[oe+3*Te]=_e.r,Pe[oe+1+3*Te]=_e.g,Pe[oe+2+3*Te]=_e.b;if(pe>0){var K=ee!==void 0&&ye!==void 0&&ee.serial!==ye.serial;for(Te=0;Te<4;Te++){var Z=[ie+le[Te][0],ie+le[Te][1],ie+le[Te][2],ie+le[Te][3]];if(xe=Fe.faceidx,Re[xe]=Z[0],Re[xe+1]=Z[1],Re[xe+2]=Z[3],Re[xe+3]=Z[1],Re[xe+4]=Z[2],Re[xe+5]=Z[3],Fe.faceidx+=6,ye.clickable||ee.clickable||ye.hoverable||ee.hoverable){var $=I[Z[3]].clone(),me=I[Z[0]].clone(),ce=I[Z[2]].clone(),Me=I[Z[1]].clone();if($.atom=I[Z[3]].atom||null,ce.atom=I[Z[2]].atom||null,me.atom=I[Z[0]].atom||null,Me.atom=I[Z[1]].atom||null,K){var we=$.clone().add(me).multiplyScalar(.5),j=ce.clone().add(Me).multiplyScalar(.5),se=$.clone().add(Me).multiplyScalar(.5);Te%2===0?((ee.clickable||ee.hoverable)&&(We=new O.Triangle(we,se,$),Ie=new O.Triangle(j,ce,se),Be=new O.Triangle(se,ce,$),ee.intersectionShape.triangle.push(We),ee.intersectionShape.triangle.push(Ie),ee.intersectionShape.triangle.push(Be)),(ye.clickable||ye.hoverable)&&(We=new O.Triangle(me,Me,se),Ie=new O.Triangle(Me,j,se),Be=new O.Triangle(me,se,we),ye.intersectionShape.triangle.push(We),ye.intersectionShape.triangle.push(Ie),ye.intersectionShape.triangle.push(Be))):((ye.clickable||ye.hoverable)&&(We=new O.Triangle(we,se,$),Ie=new O.Triangle(j,ce,se),Be=new O.Triangle(se,ce,$),ye.intersectionShape.triangle.push(We),ye.intersectionShape.triangle.push(Ie),ye.intersectionShape.triangle.push(Be)),(ee.clickable||ee.hoverable)&&(We=new O.Triangle(me,Me,se),Ie=new O.Triangle(Me,j,se),Be=new O.Triangle(me,se,we),ee.intersectionShape.triangle.push(We),ee.intersectionShape.triangle.push(Ie),ee.intersectionShape.triangle.push(Be)))}else(ye.clickable||ye.hoverable)&&(We=new O.Triangle(me,Me,$),Ie=new O.Triangle(Me,ce,$),ye.intersectionShape.triangle.push(We),ye.intersectionShape.triangle.push(Ie))}}}Fe.vertices+=8,ee=ye}var ge=I.length-8;for(Fe=T.updateGeoGroup(8),ze=Fe.vertexArray,Pe=Fe.colorArray,Re=Fe.faceArray,ie=Fe.vertices,oe=ie*3,xe=Fe.faceidx,pe=0;pe<4;pe++){I.push(I[pe*2]),I.push(I[ge+pe*2]);var Se=I[pe*2],re=I[ge+pe*2];ze[oe+6*pe]=Se.x,ze[oe+1+6*pe]=Se.y,ze[oe+2+6*pe]=Se.z,ze[oe+3+6*pe]=re.x,ze[oe+4+6*pe]=re.y,ze[oe+5+6*pe]=re.z,Pe[oe+6*pe]=_e.r,Pe[oe+1+6*pe]=_e.g,Pe[oe+2+6*pe]=_e.b,Pe[oe+3+6*pe]=_e.r,Pe[oe+4+6*pe]=_e.g,Pe[oe+5+6*pe]=_e.b}ge+=8,We=[ie,ie+2,ie+6,ie+4],Ie=[ie+1,ie+5,ie+7,ie+3],Re[xe]=We[0],Re[xe+1]=We[1],Re[xe+2]=We[3],Re[xe+3]=We[1],Re[xe+4]=We[2],Re[xe+5]=We[3],Re[xe+6]=Ie[0],Re[xe+7]=Ie[1],Re[xe+8]=Ie[3],Re[xe+9]=Ie[1],Re[xe+10]=Ie[2],Re[xe+11]=Ie[3],Fe.faceidx+=12,Fe.vertices+=8}}function o(T,S,P,z,F,B,W){(!W||W==="default")&&(W="rectangle"),W==="edged"?s(T,S,P,z,F):(W==="rectangle"||W==="oval"||W==="parabola")&&t(T,S,P,z,F,B,W)}function l(T){return T&&T.elem==="C"&&T.atom==="CA"}function d(T,S){if(T&&S&&T.chain===S.chain){if(!T.hetflag&&!S.hetflag&&T.reschain===S.reschain&&(T.resi===S.resi||T.resi===S.resi-1))return!0;if(T.resi<S.resi){var P=T.x-S.x,z=T.y-S.y,F=T.z-S.z,B=P*P+z*z+F*F;if(T.atom=="CA"&&S.atom=="CA"&&B<16)return!0;if((T.atom=="P"||S.atom=="P")&&B<64)return!0}}return!1}function i(T,S,P,z,F){if(!(S==null||S.vertices==0)){F&&(S.initTypedArrays(),S.setUpNormals());var B=new C.MeshDoubleLambertMaterial;B.vertexColors=C.Coloring.FaceColors,typeof P=="number"&&P>=0&&P<1&&(B.transparent=!0,B.opacity=P),B.outline=z;var W=new C.Mesh(S,B);T.add(W)}}function n(T,S,P,z,F,B,W,U,I){var G,Y,J,te,ne,le;if(!(!z||!F||!W)){var ie=F.sub(z);ie.normalize();var oe=U[I];for(Y=I+1;Y<U.length&&(oe=U[Y],oe.atom!=W.atom);Y++);if(oe=oe?new b.Vector3(oe.x,oe.y,oe.z):new b.Vector3(0,0,0),oe.sub(z),W.ss==="arrow start"){var xe=oe.clone().multiplyScalar(.3).cross(F);z.add(xe);var _e=oe.clone().cross(ie).normalize();ie.rotateAboutVector(_e,.43)}for(W.style.cartoon.ribbon?G=W.style.cartoon.thickness||m:W.style.cartoon.width?G=W.style.cartoon.width:W.ss==="c"?W.atom==="P"?G=p:G=x:W.ss==="arrow start"?(G=_,ne=!0):W.ss==="arrow end"||W.ss==="h"&&W.style.cartoon.tubes||W.ss==="tube start"?G=x:G=_,B!=null&&ie.dot(B)<0&&ie.negate(),ie.multiplyScalar(G),Y=0;Y<S;Y++)J=-1+Y*2/(S-1),te=new b.Vector3(z.x+J*ie.x,z.y+J*ie.y,z.z+J*ie.z),te.atom=W,W.ss==="s"&&(te.smoothen=!0),T[Y].push(te);if(ne)for(ie.multiplyScalar(2),Y=0;Y<S;Y++)J=-1+Y*2/(S-1),te=new b.Vector3(z.x+J*ie.x,z.y+J*ie.y,z.z+J*ie.z),te.atom=W,te.smoothen=!1,te.skip=!0,T[Y].push(te);return le=W.style.cartoon.style||"default",T.style?T.style!=le&&(console.log("Warning: a cartoon chain's strand-style is ambiguous"),T.style="default"):T.style=le,(W.ss==="arrow start"||W.ss==="arrow end")&&(W.ss="s"),ne}}const a={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},h={DA:!0,DG:!0,A:!0,G:!0},u={DT:!0,DC:!0,U:!0,C:!0,T:!0},A={DA:!0,DG:!0,A:!0,G:!0,DT:!0,DC:!0,U:!0,C:!0,T:!0};function D(T,S,P,z=10){let F=z,B=z;var W,U,I,G,Y,J,te,ne,le,ie,oe,xe,_e,Oe,ye,ee,pe,Ce,Te=new C.Geometry(!0),We=new C.Geometry(!0),Ie=[],Be=[],Fe=1,ze=!1,Pe={};for(var Re in R.Gradient.builtinGradients)R.Gradient.builtinGradients.hasOwnProperty(Re)&&(Pe[Re]=new R.Gradient.builtinGradients[Re](P[1],P[0]));var je=function(Le,L){return P&&L.color==="spectrum"?L.colorscheme in Pe?Pe[L.colorscheme].valueToHex(Le.resi):Pe.sinebow.valueToHex(Le.resi):(0,M.getColorFromStyle)(Le,L).getHex()};for(ne=0;ne<F;ne++)Be[ne]=[];var ke=!1,K=!1,Z=[];for(ne in S){if(G=S[ne],G.elem==="C"&&G.atom==="CA"){var $=d(I,G);$&&G.ss==="s"?ke=!0:ke&&(I&&U&&I.style.cartoon.arrows&&U.style.cartoon.arrows&&(I.ss="arrow end",U.ss="arrow start"),ke=!1),$&&(I.ss==="h"||I.ss=="tube start")&&I.style.cartoon.tubes?!K&&I.ss!="tube start"&&G.style.cartoon.tubes&&(G.ss="tube start",K=!0):K&&(I.ss==="tube start"?I.ss="tube end":U&&U.style.cartoon.tubes&&(U.ss="tube end"),K=!1),U=I,I=G}G&&G.atom in a&&Z.push(G)}K&&I.style.cartoon.tubes&&(I.ss="tube end",K=!1);var me=function(Le){Be[0].length>0&&o(We,Be,Ie,B,te,Fe,Be.style);var L=[],he=null;if(Le){for(ne=0;ne<F;ne++)L[ne]=Be[ne][Be[ne].length-1];he=Ie[Ie.length-1]}for(Be=[],ne=0;ne<F;ne++)Be[ne]=[];if(Ie=[],Le){for(ne=0;ne<F;ne++)Be[ne].push(L[ne]);Ie.push(he)}i(T,We,Fe,ze,!0),i(T,Te,Fe,ze,!1),We=new C.Geometry(!0),Te=new C.Geometry(!0)};I=void 0;let ce=[];for(var Me=0;Me<Z.length;Me++){G=Z[Me];var we=G.resn.trim(),j=we in A;if(Fe=1,W=G.style.cartoon,I&&I.style.cartoon&&(Fe=I.style.cartoon.opacity),I&&I.style.cartoon&&I.style.cartoon.outline&&(ze=I.style.cartoon.outline),I&&I.style.cartoon&&(!G.style.cartoon||I.style.cartoon.opacity!=G.style.cartoon.opacity)&&me(I.chain==G.chain),I&&G&&!d(I,G)&&I.chain&&I.chain==G.chain&&!I.hetflag&&!G.hetflag&&I.reschain+1==G.reschain&&ce.push([I,G]),W.style==="trace"){if(!G.hetflag){if(G.elem==="C"&&G.atom==="CA"||j&&G.atom==="P"||G.atom==="BB"){if(J=je(G,W),(0,M.isNumeric)(W.thickness)?te=W.thickness:te=m,d(I,G))if(J==Y){var se=v.CC.color(J);y.GLDraw.drawCylinder(Te,I,G,te,se,2,2)}else{var ge=new b.Vector3().addVectors(I,G).multiplyScalar(.5),Se=v.CC.color(Y),re=v.CC.color(J);y.GLDraw.drawCylinder(Te,I,ge,te,Se,2,0),y.GLDraw.drawCylinder(Te,ge,G,te,re,0,2)}if((G.clickable===!0||G.hoverable)&&G.intersectionShape!==void 0){var be=new b.Vector3(G.x,G.y,G.z);G.intersectionShape.sphere.push(new O.Sphere(be,te))}I=G,Y=J}}}else{if(l(G)||j&&(G.atom==="P"||G.atom.indexOf("O5")==0)){if(Ce)if(G.ss==="tube end")Ce=!1,pe=new b.Vector3(G.x,G.y,G.z),y.GLDraw.drawCylinder(Te,ee,pe,2,v.CC.color(Y),1,1),G.ss="h";else if(I.chain!=G.chain||I.ss==="tube end")Ce=!1,I.ss="h",pe=new b.Vector3(I.x,I.y,I.z),y.GLDraw.drawCylinder(Te,ee,pe,2,v.CC.color(Y),1,1);else continue;if(I&&(!d(I,G)||I.ss==="tube start")){for(I.ss==="tube start"&&(Ce=!0,ee=new b.Vector3(I.x,I.y,I.z),I.ss="h"),ye&&(xe?Oe=new b.Vector3().addVectors(I,xe).multiplyScalar(.5):Oe=new b.Vector3(I.x,I.y,I.z),y.GLDraw.drawCylinder(Te,Oe,ye,r,v.CC.color(ye.color),0,2),n(Be,F,!0,xe,_e,oe,I,Z,Me),Ie.push(J),Oe=null,ye=null),Be[0].length>0&&o(We,Be,Ie,B,te,Fe,Be.style),Be=[],ne=0;ne<F;ne++)Be[ne]=[];Ie=[]}if(I===void 0||I.rescode!=G.rescode||I.resi!=G.resi){if(ye&&I!=null){Oe=new b.Vector3().addVectors(I,G).multiplyScalar(.5);var V=Oe.clone().sub(ye).multiplyScalar(.02);Oe.add(V),y.GLDraw.drawCylinder(Te,Oe,ye,r,v.CC.color(ye.color),0,2),Oe=null,ye=null}J=je(G,W),Ie.push(J),(0,M.isNumeric)(W.thickness)?te=W.thickness:te=m,I=G,le=new b.Vector3(I.x,I.y,I.z),le.resi=I.resi,Y=J}(G.clickable===!0||G.hoverable===!0)&&(G.intersectionShape===void 0||G.intersectionShape.triangle===void 0)&&(G.intersectionShape={sphere:null,cylinder:[],line:[],triangle:[]})}else I!=null&&(l(I)&&G.atom==="O"||j&&I.atom==="P"&&(G.atom==="OP2"||G.atom==="O2P")||j&&I.atom.indexOf("O5")==0&&G.atom.indexOf("C5")==0)?(ie=new b.Vector3(G.x,G.y,G.z),ie.resi=G.resi,(G.atom==="OP2"||G.atom==="O2P")&&(_e=new b.Vector3(G.x,G.y,G.z))):j&&G.atom.indexOf("O3")==0?xe=new b.Vector3(G.x,G.y,G.z):(G.atom==="N1"&&we in h||G.atom==="N3"&&we in u)&&(ye=new b.Vector3(G.x,G.y,G.z),ye.color=(0,M.getColorFromStyle)(G,W).getHex());ie&&le&&ie.resi===le.resi&&(n(Be,F,!0,le,ie,oe,I,Z,Me),oe=ie,le=null,ie=null,Ie.push(J))}}ye&&(xe?Oe=new b.Vector3().addVectors(I,xe).multiplyScalar(.5):Oe=new b.Vector3(I.x,I.y,I.z),y.GLDraw.drawCylinder(Te,Oe,ye,r,v.CC.color(ye.color),0,2),n(Be,F,!0,xe,_e,oe,I,Z,Me),Ie.push(J)),me(!1);var De=function(Le,L){if(Le.style.cartoon.gapcutoff&&Le.style.cartoon.gapcutoff==L.style.cartoon.gapcutoff){let fe=Le.style.cartoon.gapcutoff,H=L.resi-Le.resi;if(H>0&&H<fe){let ae=.25,ve=L.x-Le.x,Ve=L.y-Le.y,Ne=L.z-Le.z,Ge=Math.sqrt(ve*ve+Ve*Ve+Ne*Ne),qe=Ge/(2*H),_t=new b.Vector3(Le.x,Le.y,Le.z),Ye=Ge/qe,He=new b.Vector3((L.x-Le.x)/Ye,(L.y-Le.y)/Ye,(L.z-Le.z)/Ye);_t.add({x:He.x/2,y:He.y/2,z:He.z/2});let $e=_t.clone().add(He);He.multiplyScalar(2);let tt=(0,M.extend)({},Le);for(var he=0;he<H;he++){tt.resi+=1;let et=je(tt,tt.style.cartoon);y.GLDraw.drawCylinder(Te,_t,$e,ae,v.CC.color(et),y.CAP.FLAT,y.CAP.FLAT),_t.add(He),$e.add(He)}me(!1)}}};for(let Le of ce)De(Le[0],Le[1])}},"./src/index.ts"(k,w,c){c.r(w),c.d(w,{CAP:()=>b.CAP,CC:()=>b.CC,CONTEXTS_PER_VIEWPORT:()=>b.CONTEXTS_PER_VIEWPORT,Color:()=>b.Color,CustomLinear:()=>b.CustomLinear,Cylinder:()=>b.Cylinder,GLDraw:()=>b.GLDraw,GLModel:()=>b.GLModel,GLShape:()=>b.GLShape,GLViewer:()=>b.GLViewer,GLVolumetricRender:()=>b.GLVolumetricRender,Gradient:()=>b.Gradient,GradientType:()=>b.GradientType,Label:()=>b.Label,LabelCount:()=>b.LabelCount,MarchingCube:()=>b.MarchingCube,MarchingCubeInitializer:()=>b.MarchingCubeInitializer,Matrix3:()=>b.Matrix3,Matrix4:()=>b.Matrix4,Parsers:()=>b.Parsers,PausableTimer:()=>b.PausableTimer,PointGrid:()=>b.PointGrid,ProteinSurface:()=>b.ProteinSurface,Quaternion:()=>b.Quaternion,ROYGB:()=>b.ROYGB,RWB:()=>b.RWB,Ray:()=>b.Ray,Sinebow:()=>b.Sinebow,Sphere:()=>b.Sphere,SurfaceType:()=>b.SurfaceType,Triangle:()=>b.Triangle,Vector2:()=>b.Vector2,Vector3:()=>b.Vector3,VolumeData:()=>b.VolumeData,adjustVolumeStyle:()=>b.adjustVolumeStyle,applyPartialCharges:()=>b.applyPartialCharges,autoinit:()=>b.autoinit,autoload:()=>b.autoload,base64ToArray:()=>b.base64ToArray,bondLength:()=>b.bondLength,builtinColorSchemes:()=>b.builtinColorSchemes,builtinGradients:()=>b.builtinGradients,chains:()=>b.chains,clamp:()=>b.clamp,conversionMatrix3:()=>b.conversionMatrix3,createStereoViewer:()=>b.createStereoViewer,createViewer:()=>b.createViewer,createViewerGrid:()=>b.createViewerGrid,deepCopy:()=>b.deepCopy,degToRad:()=>b.degToRad,download:()=>b.download,drawCartoon:()=>b.drawCartoon,elementColors:()=>b.elementColors,extend:()=>b.extend,get:()=>b.get,getAtomProperty:()=>b.getAtomProperty,getColorFromStyle:()=>b.getColorFromStyle,getElement:()=>b.getElement,getExtent:()=>b.getExtent,getGradient:()=>b.getGradient,getPropertyRange:()=>b.getPropertyRange,getbin:()=>b.getbin,htmlColors:()=>b.htmlColors,inflateString:()=>b.inflateString,isEmptyObject:()=>b.isEmptyObject,isNumeric:()=>b.isNumeric,makeFunction:()=>b.makeFunction,mergeGeos:()=>b.mergeGeos,normalizeValue:()=>b.normalizeValue,partialCharges:()=>b.partialCharges,processing_autoinit:()=>b.processing_autoinit,residues:()=>b.residues,setBondLength:()=>b.setBondLength,setSyncSurface:()=>b.setSyncSurface,specStringToObject:()=>b.specStringToObject,splitMesh:()=>b.splitMesh,ssColors:()=>b.ssColors,subdivide_spline:()=>b.subdivide_spline,syncSurface:()=>b.syncSurface,viewers:()=>b.viewers});var b=c("./src/3Dmol.ts");window&&(window.$3Dmol=w)},"./src/parsers/BCIF.ts"(k,w,c){c.r(w),c.d(w,{BCIF:()=>m});var b=c("./src/utilities.ts"),O=c("./src/parsers/utils/computeSecondaryStructure.ts"),C=c("./src/parsers/utils/processSymmetries.ts"),R=c("./src/parsers/cifutils/category.ts"),v=c("./src/parsers/utils/assignPDBBonds.ts"),y=c("./src/WebGL/index.ts"),M=c("./src/parsers/utils/isEmpty.ts"),g=c("./src/vendor/mmtf.js");class x{constructor(e){if(this.C={},e){let t=e.getField("comp_id"),s=e.getField("atom_id_1"),o=e.getField("atom_id_2"),l=e.getField("value_order");for(let d=0;d<t.length;d++){let i=t[d],n=s[d],a=o[d],h=l[d],u=1;h=="doub"?u=2:h=="trip"&&(u=3),this.C[i]==null&&(this.C[i]={}),this.C[i][n]==null&&(this.C[i][n]={}),this.C[i][a]==null&&(this.C[i][a]={}),this.C[i][n][a]=u,this.C[i][a][n]=u}}}order(e,t,s){return this.C[e]!==void 0&&this.C[e][t]!==void 0&&this.C[e][t][s]!==void 0?this.C[e][t][s]:0}}class _{constructor(e){if(this.C=[],e){let t=e.getField("conn_type_id"),s=e.getField("ptnr1_label_asym_id"),o=e.getField("ptnr1_label_seq_id"),l=e.getField("ptnr1_label_comp_id"),d=e.getField("ptnr1_label_atom_id"),i=e.getField("ptnr2_label_asym_id"),n=e.getField("ptnr2_label_seq_id"),a=e.getField("ptnr2_label_comp_id"),h=e.getField("ptnr2_label_atom_id"),u=e.getField("pdbx_value_order");for(let A=0;A<t.length;A++)if(t[A]=="disulf"||t[A]=="covale"){let D=u?u[A]==""?1:parseInt(u[A]):1;this.C.push([[s[A],o[A],l[A],d[A]],[i[A],n[A],a[A],h[A]],D])}}}}class p{constructor(){this.R={}}add(e){this.R[e.lchain]==null&&(this.R[e.lchain]={}),this.R[e.lchain][e.lresi]==null&&(this.R[e.lchain][e.lresi]={}),this.R[e.lchain][e.lresi][e.lresn]==null&&(this.R[e.lchain][e.lresi][e.lresn]=[]),this.R[e.lchain][e.lresi][e.lresn].push(e),this.R[e.lchain][e.lresi][e.lresn][e.atom]=e}geta([e,t,s,o]){if(this.R[e]!==void 0&&this.R[e][t]!==void 0&&this.R[e][t][s]!==void 0)return this.R[e][t][s][o]}setBonds(e,t){for(let s in this.R)for(let o in this.R[s])for(let l in this.R[s][o]){let d=this.R[s][o][l];for(let i=0;i<d.length;i++)for(let n=i+1;n<d.length;n++){let a=d[i],h=d[n],u=e.order(l,a.atom,h.atom);a.altLoc!=h.altLoc&&a.altLoc!=""&&h.altLoc!=""&&(u=0),u>0&&(a.bonds.push(h.index),h.bonds.push(a.index),a.bondOrder.push(u),h.bondOrder.push(u))}}for(let s of t.C){let o=s[0],l=s[1],d=s[2],i=this.geta(o),n=this.geta(l);i!=null&&n!=null&&(i.bonds.push(n.index),n.bonds.push(i.index),i.bondOrder.push(d),n.bondOrder.push(d))}}}function m(r,e){var t=!e.keepH,s=e.altLoc?e.altLoc:"A",o=!e.noComputeSecondaryStructure;const l=!e.doAssembly,d=e.assignBonds===void 0?!0:e.assignBonds;if(typeof r=="string")try{r=(0,b.base64ToArray)(r)}catch{r=new TextEncoder().encode(r)}else r=new Uint8Array(r);var i=g.decodeMsgpack(r);i==31&&(r=(0,b.inflateString)(r,!1),i=g.decodeMsgpack(r));var n=[],a=n.modelData=[],h=i.dataBlocks.length;if(h==0)return n;e.multimodel||(h=1);for(let u=0;u<h;u++){let A=n.length;const D=[];a.push({symmetries:[]}),n.push([]);const T=i.dataBlocks[u],S=Object.create(null);for(const Pe of T.categories)S[Pe.name.substr(1)]=(0,R.Category)(Pe);let P={},z=S.struct_conf;if(z){let Pe=z.getField("conf_type_id"),Re=z.getField("beg_label_asym_id"),je=z.getField("beg_label_seq_id"),ke=z.getField("end_label_seq_id");for(let K=0;K<Pe.length;K++)if(Pe[K].startsWith("H")){let Z=Re[K],$=je[K],me=ke[K];Z in P||(P[Z]={}),P[Z][$]="h1";for(let ce=$+1;ce<me;ce++)P[Z][ce]="h";P[Z][me]="h2"}}let F=S.struct_sheet_range;if(F){let Pe=F.getField("id"),Re=F.getField("beg_label_asym_id"),je=F.getField("beg_label_seq_id"),ke=F.getField("end_label_seq_id");for(let K=0;K<Pe.length;K++){let Z=Re[K],$=je[K],me=ke[K];Z in P||(P[Z]={}),P[Z][$]="s1";for(let ce=$+1;ce<me;ce++)P[Z][ce]="s";P[Z][me]="s2"}}let B=S.pdbx_struct_oper_list,W=B.getField("id");if(W&&!l){let Pe=B.getField("matrix[1][1]"),Re=B.getField("matrix[1][2]"),je=B.getField("matrix[1][3]"),ke=B.getField("matrix[2][1]"),K=B.getField("matrix[2][2]"),Z=B.getField("matrix[2][3]"),$=B.getField("matrix[3][1]"),me=B.getField("matrix[3][2]"),ce=B.getField("matrix[3][3]"),Me=B.getField("vector[1]"),we=B.getField("vector[2]"),j=B.getField("vector[3]");for(let se=0;se<W.length;se++){const ge=new y.Matrix4(Pe[se],Re[se],je[se],Me[se],ke[se],K[se],Z[se],we[se],$[se],me[se],ce[se],j[se]);a[a.length-1].symmetries.push(ge)}}let U=new x(S.chem_comp_bond),I=new p,G=new _(S.struct_conn),Y=S.atom_site,J=Y.rowCount,te=Y.getField("group_PDB"),ne=Y.getField("Cartn_x"),le=Y.getField("Cartn_y"),ie=Y.getField("Cartn_z"),oe=Y.getField("auth_asym_id"),xe=Y.getField("label_asym_id"),_e=Y.getField("auth_seq_id"),Oe=Y.getField("label_seq_id"),ye=Y.getField("auth_comp_id"),ee=Y.getField("label_comp_id"),pe=Y.getField("auth_atom_id"),Ce=Y.getField("label_atom_id"),Te=Y.getField("type_symbol"),We=Y.getField("B_iso_or_equiv"),Ie=Y.getField("id"),Be=Y.getField("label_alt_id"),Fe=Y.getField("pdbx_PDB_model_num"),ze=Fe?Fe[0]:0;for(let Pe=0;Pe<J;Pe++){if(te!==void 0&&te[Pe]==="TER")continue;if(Fe&&Fe[Pe]!=ze)if(ze=Fe[Pe],e.multimodel)e.onemol||(n.push([]),a.push(a[a.length-1]),ze=Fe[Pe],I.setBonds(U,G),I=new p);else break;const Re={};Re.x=ne[Pe],Re.y=le[Pe],Re.z=ie[Pe],Re.chain=oe?oe[Pe]:xe?xe[Pe]:void 0,Re.lchain=xe?xe[Pe]:void 0,Re.resi=_e?_e[Pe]:Oe?Oe[Pe]:void 0,Re.lresi=Oe?Oe[Pe]:void 0,Re.resn=ye?ye[Pe].trim():ee?ee[Pe].trim():void 0,Re.lresn=ee?ee[Pe].trim():void 0,Re.atom=pe?pe[Pe].replace(/"/gm,""):Ce?Ce[Pe].replace(/"/gm,""):void 0,Re.icode=Be?Be[Pe]:void 0,Re.altLoc=Re.icode,Re.hetflag=!te||te[Pe]==="HETA"||te[Pe]==="HETATM";let je="X";Te&&(je=Te[Pe].replace(/\(?\+?\d+.*/,"")),Re.elem=je[0].toUpperCase()+je.substring(1,2).toLowerCase(),We&&(Re.b=We[Pe]),!(t&&Re.elem=="H")&&(Re.altLoc!=""&&Re.altLoc!=s&&s!="*"||(Re.bonds=[],Re.ss="c",Re.serial=Ie[Pe],Re.model=ze,Re.bondOrder=[],Re.properties={},Re.index=n[n.length-1].length,D[Re.serial]=[n.length,Re.index],n[n.length-1].push(Re),I.add(Re)))}if(I.setBonds(U,G),!(0,M.isEmpty)(P))for(let Pe=A;Pe<n.length;Pe++){let Re=n[Pe];for(let je=0;je<Re.length;je++){const ke=Re[je];if(ke!==void 0&&ke.lchain in P&&ke.lresi in P[ke.lchain]){const K=P[ke.lchain][ke.lresi];ke.ss=K[0],K.length>1&&(K[1]=="1"?ke.ssbegin=!0:K[1]=="2"&&(ke.ssend=!0))}}}e.multimodel&&u<h-1&&(e.onemol||(n.push([]),a.push({symmetries:[]})))}for(let u=0;u<n.length;u++)d&&!(e.duplicateAssemblyAtoms&&!e.dontConnectDuplicatedAtoms)&&(0,v.assignPDBBonds)(n[u],e),o&&(0,O.computeSecondaryStructure)(n[u],e.hbondCutoff),(0,C.processSymmetries)(a[u].symmetries,n[u],e,a[u].cryst),e.duplicateAssemblyAtoms&&!e.dontConnectDuplicatedAtoms&&d&&(0,v.assignPDBBonds)(n[u],e);return n}},"./src/parsers/CDJSON.ts"(k,w,c){c.r(w),c.d(w,{CDJSON:()=>b});function b(O,C){var R=[[]];typeof O=="string"&&(O=JSON.parse(O));for(var v=O.m,y=v[0].a,M=v[0].b,g=v[0].s,x=C!==void 0&&C.parseStyle!==void 0?C.parseStyle:g!==void 0,_=R[R.length-1].length,p=0;p<y.length;p++){var m=y[p],r={};r.id=m.i,r.x=m.x,r.y=m.y,r.z=m.z||0,r.bonds=[],r.bondOrder=[];var e=m.l||"C";r.elem=e[0].toUpperCase()+e.substring(1).toLowerCase(),r.serial=R[R.length-1].length,x&&(r.style=g[m.s||0]),R[R.length-1].push(r)}for(let t=0;t<M.length;t++){let s=M[t],o=s.b+_,l=s.e+_,d=s.o||1,i=R[R.length-1][o],n=R[R.length-1][l];i.bonds.push(l),i.bondOrder.push(d),n.bonds.push(o),n.bondOrder.push(d)}return R}},"./src/parsers/CIF.ts"(k,w,c){c.r(w),c.d(w,{CIF:()=>y});var b=c("./src/parsers/utils/computeSecondaryStructure.ts"),O=c("./src/parsers/utils/processSymmetries.ts"),C=c("./src/WebGL/index.ts"),R=c("./src/parsers/utils/assignPDBBonds.ts");const v=function(M,g,x,_){return new C.Vector3(g,x,_).applyMatrix3(M)};function y(M,g={}){const x=[],_=!g.doAssembly,p=x.modelData=[],m=g.assignBonds===void 0?!0:g.assignBonds;function r(d,i){const n=[];let a=0,h=0;for(;h<d.length;){for(;d.substring(h,h+i.length)!==i&&h<d.length;)if(d[h]==="'"){for(h++;h<d.length&&d[h]!=="'";)h++;for(;d.substring(h,h+i.length)!==i&&h<d.length;)h++}else if(d[h]==='"'){for(h++;h<d.length&&d[h]!=='"';)h++;h++}else h++;n.push(d.substring(a,h)),a=h=h+i.length}return n}const e=M.split(/\r?\n|\r/),t=[];let s=!1;for(let d=0;d<e.length;d++){var o=e[d].split("#")[0];if(s?o[0]===";"&&(s=!1):o[0]===";"&&(s=!0),s||o!==""){if(!s&&(o=o.trim(),o[0]==="_")){const i=o.split(/\s/)[0].indexOf(".");if(i>-1){let n=o.split("");n[i]="_",o=n.join(""),o=o.substring(0,i)+"_"+o.substring(i+1)}}t.push(o)}}let l=0;for(;l<t.length;){for(;!t[l].startsWith("data_")||t[l]==="data_global";)l++;l++;const d={};for(;l<t.length&&!t[l].startsWith("data_");)if(t[l][0]===void 0)l++;else if(t[l][0]==="_"){const h=t[l].split(/\s/)[0].toLowerCase(),u=d[h]=d[h]||[],A=t[l].substring(t[l].indexOf(h)+h.length);if(A==="")if(l++,t[l][0]===";"){let D=t[l].substring(1);for(l++;t[l]!==";";)D=D+`
|
|
1696
|
+
`+t[l],l++;u.push(D)}else u.push(t[l]);else u.push(A.trim());l++}else if(t[l].substring(0,5)==="loop_"){l++;const h=[];for(;t[l]===""||t[l][0]==="_";){if(t[l]!==""){let A=t[l].split(/\s/)[0].toLowerCase(),D=d[A]=d[A]||[];h.push(D)}l++}let u=0;for(;l<t.length&&t[l][0]!=="_"&&!t[l].startsWith("loop_")&&!t[l].startsWith("data_");){let A=r(t[l]," ");for(let D=0;D<A.length;D++)A[D]!==""&&(h[u].push(A[D]),u=(u+1)%h.length);l++}}else l++;p.push({symmetries:[]}),x.push([]);const i=d._atom_site_id!==void 0?d._atom_site_id.length:d._atom_site_label.length;let n;if(d._cell_length_a!==void 0){const h=parseFloat(d._cell_length_a),u=parseFloat(d._cell_length_b),A=parseFloat(d._cell_length_c),D=parseFloat(d._cell_angle_alpha)||90,T=parseFloat(d._cell_angle_beta)||90,S=parseFloat(d._cell_angle_gamma)||90;n=(0,C.conversionMatrix3)(h,u,A,D,T,S),p[p.length-1].cryst={a:h,b:u,c:A,alpha:D,beta:T,gamma:S}}for(let h=0;h<i;h++){if(d._atom_site_group_pdb!==void 0&&d._atom_site_group_pdb[h]==="TER")continue;const u={};if(d._atom_site_cartn_x!==void 0)u.x=parseFloat(d._atom_site_cartn_x[h]),u.y=parseFloat(d._atom_site_cartn_y[h]),u.z=parseFloat(d._atom_site_cartn_z[h]);else{const D=v(n,parseFloat(d._atom_site_fract_x[h]),parseFloat(d._atom_site_fract_y[h]),parseFloat(d._atom_site_fract_z[h]));u.x=D.x,u.y=D.y,u.z=D.z}u.chain=d._atom_site_auth_asym_id?d._atom_site_auth_asym_id[h]:d._atom_site_label_asym_id?d._atom_site_label_asym_id[h]:void 0,u.lchain=d._atom_site_label_asym_id?d._atom_site_label_asym_id[h]:void 0,u.resi=d._atom_site_auth_seq_id?parseInt(d._atom_site_auth_seq_id[h]):d._atom_site_label_seq_id?d._atom_site_label_seq_id[h]:void 0,u.resn=d._atom_site_auth_comp_id?d._atom_site_auth_comp_id[h].trim():d._atom_site_label_comp_id?d._atom_site_label_comp_id[h].trim():void 0,u.atom=d._atom_site_auth_atom_id?d._atom_site_auth_atom_id[h].replace(/"/gm,""):d._atom_site_label_atom_id?d._atom_site_label_atom_id[h].replace(/"/gm,""):void 0,u.hetflag=!d._atom_site_group_pdb||d._atom_site_group_pdb[h]==="HETA"||d._atom_site_group_pdb[h]==="HETATM",d._atom_site_b_iso_or_equiv&&(u.b=parseFloat(d._atom_site_b_iso_or_equiv[h]));let A="X";d._atom_site_type_symbol?A=d._atom_site_type_symbol[h].replace(/\(?\+?\d+.*/,""):d._atom_site_label&&(A=d._atom_site_label[h].split("_")[0].replace(/\(?\d+.*/,"")),u.elem=A[0].toUpperCase()+A.substring(1,2).toLowerCase(),u.bonds=[],u.ss="c",u.serial=h,u.bondOrder=[],u.properties={},x[x.length-1].push(u)}if(d._pdbx_struct_oper_list_id!==void 0&&!_)for(let h=0;h<d._pdbx_struct_oper_list_id.length;h++){const u=parseFloat(d["_pdbx_struct_oper_list_matrix[1][1]"][h]),A=parseFloat(d["_pdbx_struct_oper_list_matrix[1][2]"][h]),D=parseFloat(d["_pdbx_struct_oper_list_matrix[1][3]"][h]),T=parseFloat(d["_pdbx_struct_oper_list_vector[1]"][h]),S=parseFloat(d["_pdbx_struct_oper_list_matrix[2][1]"][h]),P=parseFloat(d["_pdbx_struct_oper_list_matrix[2][2]"][h]),z=parseFloat(d["_pdbx_struct_oper_list_matrix[2][3]"][h]),F=parseFloat(d["_pdbx_struct_oper_list_vector[2]"][h]),B=parseFloat(d["_pdbx_struct_oper_list_matrix[3][1]"][h]),W=parseFloat(d["_pdbx_struct_oper_list_matrix[3][2]"][h]),U=parseFloat(d["_pdbx_struct_oper_list_matrix[3][3]"][h]),I=parseFloat(d["_pdbx_struct_oper_list_vector[3]"][h]),G=new C.Matrix4(u,A,D,T,S,P,z,F,B,W,U,I);p[p.length-1].symmetries.push(G)}const a=function(h){const u=h.match("-");h=h.replace(/[-xyz]/g,"");const A=h.split("/");let D,T;return A[1]===void 0?T=1:T=parseInt(A[1]),A[0]===""?D=1:D=parseInt(A[0]),D/T*(u?-1:1)};if(d._symmetry_equiv_pos_as_xyz!==void 0&&!_)for(let h=0;h<d._symmetry_equiv_pos_as_xyz.length;h++){const A=d._symmetry_equiv_pos_as_xyz[h].replace(/["' ]/g,"").split(",").map(function(P){return P.replace(/-/g,"+-")});let D=new C.Matrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);for(let P=0;P<3;P++){const z=A[P].split("+");for(let F=0;F<z.length;F++){const B=z[F];if(B==="")continue;const W=a(B);B.match("x")?D.elements[P+0]=W:B.match("y")?D.elements[P+4]=W:B.match("z")?D.elements[P+8]=W:D.elements[P+12]=W}}const T=n.getMatrix4(),S=new C.Matrix4().getInverse(T,!0);D=new C.Matrix4().multiplyMatrices(D,S),D=new C.Matrix4().multiplyMatrices(T,D),p[p.length-1].symmetries.push(D)}}for(let d=0;d<x.length;d++)m&&!(g.duplicateAssemblyAtoms&&!g.dontConnectDuplicatedAtoms)&&(0,R.assignPDBBonds)(x[d],g),(0,b.computeSecondaryStructure)(x[d],g.hbondCutoff),(0,O.processSymmetries)(p[d].symmetries,x[d],g,p[d].cryst),g.duplicateAssemblyAtoms&&!g.dontConnectDuplicatedAtoms&&m&&(0,R.assignPDBBonds)(x[d],g);return x}},"./src/parsers/CUBE.ts"(k,w,c){c.r(w),c.d(w,{CUBE:()=>R});var b=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts"),C=c("./src/parsers/utils/anumToSymbol.ts");function R(v,y){y=y||{};const M=[[]];let g=v.split(/\r?\n/);const x=y.assignBonds===void 0?!0:y.assignBonds;if(g.length<6)return M;let _=g[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const p=Math.abs(parseFloat(_[0]));let m={origin:void 0,size:void 0,unit:void 0,matrix4:void 0,matrix:void 0};const r=m.origin=new b.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3]));_=g[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),_=g[3].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const e=_[0]>0?.529177:1;r.multiplyScalar(e);const t=Math.abs(_[0]),s=new b.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);_=g[4].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const o=Math.abs(_[0]),l=new b.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);_=g[5].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const d=Math.abs(_[0]),i=new b.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);if(m.size={x:t,y:o,z:d},m.unit=new b.Vector3(s.x,l.y,i.z),s.y!=0||s.z!=0||l.x!=0||l.z!=0||i.x!=0||i.y!=0){m.matrix4=new b.Matrix4(s.x,l.x,i.x,0,s.y,l.y,i.y,0,s.z,l.z,i.z,0,0,0,0,1);let T=new b.Matrix4().makeTranslation(r.x,r.y,r.z);m.matrix4=m.matrix4.multiplyMatrices(T,m.matrix4),m.matrix=m.matrix4.matrix3FromTopLeft(),m.origin=new b.Vector3(0,0,0),m.unit=new b.Vector3(1,1,1)}M.modelData=[{cryst:m}],g=g.splice(6,p);for(var n=M[M.length-1].length,a=n+g.length,h=n;h<a;++h){var u={};u.serial=h;var A=g[h-n],D=A.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");u.elem=C.anumToSymbol[D[0]],u.x=parseFloat(D[2])*e,u.y=parseFloat(D[3])*e,u.z=parseFloat(D[4])*e,u.hetflag=!0,u.bonds=[],u.bondOrder=[],u.properties={},M[M.length-1].push(u)}if(x)for(let T=0;T<M.length;T++)(0,O.assignBonds)(M[T],y);return M}},"./src/parsers/GRO.ts"(k,w,c){c.r(w),c.d(w,{GRO:()=>C});var b=c("./src/parsers/utils/assignPDBBonds.ts"),O=c("./src/parsers/utils/atomNameToElem.ts");function C(R,v){const y=[],M=R.split(/\r?\n|\r/);for(;M.length>0;){const g=parseInt(M[1]);if(M.length<3||isNaN(g)||g<=0||M.length<g+3)break;const _=[];y.push(_);let p=2;const m=_.length,r=m+g;for(let e=m;e<r;e++){const t=M[p++],s={};s.serial=e,s.atom=t.slice(10,15).trim(),s.elem=(0,O.atomNameToElem)(s.atom,!0),s.x=10*parseFloat(t.slice(20,28)),s.y=10*parseFloat(t.slice(28,36)),s.z=10*parseFloat(t.slice(36,44)),s.resi=parseInt(t.slice(0,5)),s.resn=t.slice(5,10).trim(),s.bonds=[],s.bondOrder=[],s.properties={},t.length>44&&(s.dx=10*parseFloat(t.slice(44,52)),s.dy=10*parseFloat(t.slice(52,60)),s.dz=10*parseFloat(t.slice(60,68))),_[e]=s}if(M.length<=p+3){const t=M[p++].trim().split(/\s+/);if(t.length===3){for(let s=0;s<3;s++)t[s]=(parseFloat(t[s])*10).toString();y.box=t}}M.splice(0,++p)}for(let g=0;g<y.length;g++)(0,b.assignPDBBonds)(y[g],v);return y}},"./src/parsers/LAMMPSTRJ.ts"(k,w,c){c.r(w),c.d(w,{LAMMPSTRJ:()=>C});var b=c("./src/parsers/utils/assignBonds.ts");const O={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"};function C(R,v){const y=[],M=R.split(/\r?\n|\r/);let g=0,x=0,_=0;for(;_<M.length-9;){for(var p=_;p<M.length;p++)if(M[p].match(/ITEM: NUMBER OF ATOMS/)&&(x=parseInt(M[p+1])),M[p].match(/ITEM: ATOMS/)){g=p+1;break}const m=M[g-1].replace("ITEM: ATOMS ","").split(" ");y.push([]);for(let r=g;r<g+x;r++){const e={},t={},s=M[r].split(" ");for(let o=0;o<s.length;o++){const l=O[m[o]];l!==void 0&&(l==="serial"?e[l]=parseInt(s[o]):l==="x"||l==="y"||l==="z"?e[l]=parseFloat(s[o]):l==="charge"||l==="radius"?t[l]=parseFloat(s[o]):e[l]=s[o]),e.properties=t,e.bonds=[],e.bondOrder=[]}y[y.length-1][r-g]=e}_=g+x-1}if(v.assignBonds)for(let m=0;m<y.length;m++)(0,b.assignBonds)(y[m],v);return y}},"./src/parsers/MMTF.ts"(k,w,c){c.r(w),c.d(w,{MMTFparser:()=>x});var b=c("./src/utilities.ts"),O=c("./src/WebGL/index.ts"),C=c("./src/parsers/utils/computeSecondaryStructure.ts"),R=c("./src/parsers/utils/processSymmetries.ts"),v=c("./src/vendor/mmtf.js"),y=function(_){return String.fromCharCode.apply(null,_).replace(/\0/g,"")},M=function(_){return _==0||_==2||_==4?"h":_==3?"s":"c"};let g=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 x(_,p){var m=!p.keepH,r=p.altLoc?p.altLoc:"A",e=!!p.noSecondaryStructure,t=!p.noComputeSecondaryStructure,s=!p.doAssembly,o=p.assemblyIndex?p.assemblyIndex:0;typeof _=="string"?_=(0,b.base64ToArray)(_):_=new Uint8Array(_);var l=v.decode(_),d=[[]],i=d.modelData=[],n=0,a=0,h=0,u=l.secStructList,A=l.bFactorList,D=l.altLocList,T=l.occupancyList,S=l.bondAtomList,P=l.bondOrderList,z=l.numModels;if(z==0)return d;p.multimodel||(z=1);var F,B,W,U,I,G,Y=[];if(!s&&l.bioAssemblyList&&l.bioAssemblyList.length>0){var J=l.bioAssemblyList[o].transformList;for(F=0,G=J.length;F<G;F++){var te=new O.Matrix4(J[F].matrix);te.transpose(),Y.push(te)}}var ne=null;if(l.unitCell){var le=l.unitCell;ne={a:le[0],b:le[1],c:le[2],alpha:le[3],beta:le[4],gamma:le[5]}}let ie=[];l.entityList.forEach(fe=>{fe.chainIndexList.forEach(H=>{ie[H]=fe.type=="polymer"})});var oe=0;for(I=0;I<z;I++){var xe=l.chainsPerModel[I],_e=d[d.length-1],Oe=[];for(i.push({symmetries:Y,cryst:ne}),F=0;F<xe;++F){var ye=l.groupsPerChain[n],ee=y(l.chainIdList.subarray(n*4,n*4+4));l.chainNameList&&(ee=y(l.chainNameList.subarray(n*4,n*4+4)));var pe=a,Ce="";for(B=0;B<ye;++B){var Te=l.groupList[l.groupTypeList[a]],We=Te.atomNameList.length,Ie=0,Be=!1,Fe=!1;if(u){Ie=u[a];var ze=M(Ie);(a==0||ze!=Ce)&&(Be=!0),Ce=ze;var Pe=a+1;(Pe>=u.length||M(u[Pe]!=ze))&&(Fe=!0)}var Re=l.groupIdList[a],je=Te.groupName;let fe=Te.chemCompType;var ke=h;let H=g.has(fe)||!ie[n];for(W=0;W<We;++W){var K=Te.elementList[W];if(m&&K=="H"){h+=1;continue}var Z="";A&&(Z=A[h]);var $="";D&&D[h]&&($=String.fromCharCode(D[h]));var me="";if(T&&(me=T[h]),$!=""&&$!=r&&r!="*"){h+=1;continue}var ce=l.atomIdList[h],Me=Te.atomNameList[W],we=0;Te.atomChargeList&&(we=Te.atomChargeList[W]);var j=l.xCoordList[h],se=l.yCoordList[h],ge=l.zCoordList[h];Oe[h]=_e.length,_e.push({resn:je,x:j,y:se,z:ge,elem:K,hetflag:H,chain:ee,resi:Re,icode:$,rescode:Re+($!=" "?"^"+$:""),serial:ce,altLoc:$,index:h,atom:Me,bonds:[],ss:M(Ie),ssbegin:Be,ssend:Fe,bondOrder:[],properties:{charge:we,occupancy:me},b:Z}),h+=1}var Se=Te.bondAtomList;for(W=0,U=Te.bondOrderList.length;W<U;++W){var re=ke+Se[W*2],be=ke+Se[W*2+1],V=Te.bondOrderList[W],De=Oe[re],Le=Oe[be],L=_e[De],he=_e[Le];L&&he&&(L.bonds.push(Le),L.bondOrder.push(V),he.bonds.push(De),he.bondOrder.push(V))}a+=1}for(a=pe,B=0;B<ye;++B)a+=1;n+=1}if(S)for(let fe=oe,H=S.length;fe<H;fe+=2){let ae=S[fe],ve=S[fe+1],Ve=P?P[fe/2]:1;if(ae>=h){oe=fe;break}let Ne=Oe[ae],Ge=Oe[ve],qe=_e[Ne],_t=_e[Ge];qe&&_t&&(qe.bonds.push(Ge),qe.bondOrder.push(Ve),_t.bonds.push(Ne),_t.bondOrder.push(Ve))}p.multimodel&&(p.onemol||d.push([]))}if(!s)for(let fe=0;fe<d.length;fe++)(0,R.processSymmetries)(i[fe].symmetries,d[fe],p,i[fe].cryst);return t&&!e&&(0,C.computeSecondaryStructure)(d,p.hbondCutoff),d}},"./src/parsers/MOL2.ts"(k,w,c){c.r(w),c.d(w,{MOL2:()=>O});let b={"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 O(C,R){var v=[[]],y=!1;typeof R.keepH<"u"&&(y=!R.keepH);var M=C.search(/@<TRIPOS>MOLECULE/),g=C.search(/@<TRIPOS>ATOM/);if(M==-1||g==-1)return v;for(var x=C.substring(M).split(/\r?\n|\r/);x.length>0;){var _=[],p=x[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),m=parseInt(p[0]),r=0;p.length>1&&(r=parseInt(p[1]));var e=4,t;for(t=3;t<x.length;t++)if(x[t]=="@<TRIPOS>ATOM"){e=t+1;break}var s=v[v.length-1].length,o=s+m,l;for(t=s;t<o;t++){l=x[e++],p=l.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var d={},i=p[5];if(b[i]!==void 0?i=b[i]:(i=i.split(".")[0],i=i[0].toUpperCase()+i.substring(1).toLowerCase()),d.atom=p[1],d.elem=i,!(d.elem=="H"&&y)){var n=v[v.length-1].length,a=parseInt(p[0]);d.serial=a,d.x=parseFloat(p[2]),d.y=parseFloat(p[3]),d.z=parseFloat(p[4]),d.atom=p[5];var h=parseFloat(p[8]);d.index=n,d.bonds=[],d.bondOrder=[],d.properties={charge:h,partialCharge:h},_[a]=n,v[v.length-1].push(d)}}for(var u=!1;e<x.length;)if(x[e++]=="@<TRIPOS>BOND"){u=!0;break}if(u&&r)for(t=0;t<r;t++){l=x[e++],p=l.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var A=parseInt(p[1]),D=v[v.length-1][_[A]],T=parseInt(p[2]),S=v[v.length-1][_[T]],P=parseInt(p[3]);isNaN(P)&&(P=1),D!==void 0&&S!==void 0&&(D.bonds.push(_[T]),D.bondOrder.push(P),S.bonds.push(_[A]),S.bondOrder.push(P))}if(R.multimodel){R.onemol||v.push([]),x.splice(0,e),C=x.join(`
|
|
1697
|
+
`);continue}else break}return v}},"./src/parsers/PDB.ts"(k,w,c){c.r(w),c.d(w,{PDB:()=>O});var b=c("./src/parsers/utils/getSinglePDB.ts");function O(C,R){R=R||{};var v=[],y={};v.modelData=[];for(var M=C.split(/\r?\n|\r/);M.length>0;){var g=(0,b.getSinglePDB)(M,R,y),x=g[0],_=g[1];if(M=g[2],x.length!=0){if(R.multimodel&&R.onemol&&v.length>0)for(var p=v[0].length,m=0;m<x.length;m++){var r=x[m];r.index=m;for(var e=0;e<r.bonds.length;e++)r.bonds[e]+=p;v[0].push(r)}else v.modelData.push(_),v.push(x);if(!R.multimodel)break}}return v}},"./src/parsers/PQR.ts"(k,w,c){c.r(w),c.d(w,{PQR:()=>C});var b=c("./src/parsers/utils/assignPDBBonds.ts"),O=c("./src/parsers/utils/computeSecondaryStructure.ts");function C(R,v){var y=[[]],M=!v.noSecondaryStructure;y.modelData=[{symmetries:[]}];var g=[],x=R.split(/\r?\n|\r/),_;for(let u=0;u<x.length;u++){_=x[u].replace(/^\s*/,"");var p=_.substring(0,6);if(p.indexOf("END")==0)if(v.multimodel){v.onemol||y.push([]);continue}else break;else if(p=="ATOM "||p=="HETATM"){var m;let A=parseInt(_.substring(6,11)),D=_.substring(12,16).replace(/ /g,""),T=_.substring(17,20).trim(),S=_.substring(21,22),P=parseInt(_.substring(22,26));var r=_.substring(30).trim().split(/\s+/),e=parseFloat(r[0]),t=parseFloat(r[1]),s=parseFloat(r[2]),o=parseFloat(r[3]),l=parseFloat(r[4]),d=D[0];D.length>1&&D[1].toUpperCase()!=D[1]&&(d=D.substring(0,2)),_[0]=="H"?m=!0:m=!1,g[A]=y[y.length-1].length,y[y.length-1].push({resn:T,x:e,y:t,z:s,elem:d,hetflag:m,chain:S,resi:P,serial:A,atom:D,bonds:[],ss:"c",bondOrder:[],properties:{charge:o,partialCharge:o,radius:l},pdbline:_})}else if(p=="CONECT"){var i=parseInt(_.substring(6,11)),n=y[y.length-1][g[i]];for(let A=0;A<4;A++){var a=parseInt(_.substring([11,16,21,26][A],[11,16,21,26][A]+5)),h=y[y.length-1][g[a]];n!==void 0&&h!==void 0&&(n.bonds.push(g[a]),n.bondOrder.push(1))}}}for(let u=0;u<y.length;u++)(0,b.assignPDBBonds)(y[u],v),M&&(0,O.computeSecondaryStructure)(y[u],v.hbondCutoff);return y}},"./src/parsers/PRMTOP.ts"(k,w,c){c.r(w),c.d(w,{PRMTOP:()=>b});function b(O){var C=[],R,v=0,y=O.split(/\r?\n|\r/);if(y.length>0&&y[0].includes("VERSION")){var M=y.filter(function(s){return s.includes("POINTERS")||s.includes("ATOM_NAME")||s.includes("CHARGE")||s.includes("RADII")||s.includes("BONDS_INC_HYDROGEN")||s.includes("BONDS_WITHOUT_HYDROGEN")||s.includes("RESIDUE_LABEL")||s.includes("RESIDUE_POINTER")}),g=r("POINTERS");if(g==-1)return[];var x=e(g),_=parseInt(y[g+1].slice(0,x[1]));let t=parseInt(y[g+2].slice(x[1],x[0]+x[1]));if(isNaN(_)||_<=0)return[];if(g=r("ATOM_NAME"),g==-1)return[];x=e(g);var p=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(p=_%x[0]);for(let o=0;o<p;o++){let l={},d={charge:"",radii:""};l.serial=v,l.x=0,l.y=0,l.z=0,l.atom=y[g+1].slice(x[1]*o,x[1]*(o+1)).trim(),l.elem=y[g+1].slice(x[1]*o,x[1]*o+1).trim(),l.properties=d,l.bonds=[],l.bondOrder=[],l.index=C.length,C.push(l),v++}g++}if(g=r("CHARGE"),g!=-1){x=e(g),v=0,p=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(p=_%x[0]);for(let o=0;o<p;o++)C[v].properties.charge=parseFloat(y[g+1].slice(x[1]*o,x[1]*(o+1))),v++;g++}}g=r("RESIDUE_POINTER");var m=[];if(g!=-1){x=e(g),p=x[0],g+=1;for(let s=0;s<t/x[0];s++){s==parseInt(t/x[0])&&(p=t%x[0]);for(let o=0;o<p;o++)m.push(parseInt(y[g].slice(x[1]*o,x[1]*(o+1))));g++}if(g=r("RESIDUE_LABEL"),g!=-1){let s=[];x=e(g),p=x[0],g+=1;for(let i=0;i<t/x[0];i++){i==parseInt(t/x[0])&&(p=t%x[0]);for(let n=0;n<p;n++)s.push(y[g].slice(x[1]*n,x[1]*(n+1)).trim());g++}let o=0,l=0,d="";m.push(C.length+1);for(let i=0;i<C.length;i++)i+1>=m[o]&&(d=s[o],o+=1,l+=1),C[i].resi=l,C[i].resn=d}}if(g=r("RADII"),g!=-1){x=e(g),v=0,p=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(p=_%x[0]);for(let o=0;o<p;o++)C[v].properties.radii=parseFloat(y[g+1].slice(x[1]*o,x[1]*(o+1))),v++;g++}}if(g=r("BONDS_WITHOUT_HYDROGEN"),g!=-1)for(x=e(g),v=0,p=x[0],g=g+1;!y[g].match(/^%FLAG/);){y[g+1].match(/^%FLAG/)&&(p=_%x[0]);for(let s=0;s<p;s++)v%3==0?R=parseInt(y[g].slice(x[1]*s,x[1]*(s+1))/3):v%3==1&&(C[R].bonds.push(parseInt(y[g].slice(x[1]*s,x[1]*(s+1))/3)),C[R].bondOrder.push(1)),v++;g++}if(g=r("BONDS_INC_HYDROGEN"),g!=-1)for(x=e(g),v=0,p=x[0],g=g+1;!y[g].match(/^%FLAG/);){y[g+1].match(/^%FLAG/)&&(p=_%x[0]);for(let s=0;s<p;s++)v%3==0?R=parseInt(y[g].slice(x[1]*s,x[1]*(s+1))/3):v%3==1&&(C[R].bonds.push(parseInt(y[g].slice(x[1]*s,x[1]*(s+1))/3)),C[R].bonds.push(1)),v++;g++}}else return[];function r(t){var s=y.indexOf(M.filter(function(o){return o.includes(t)})[0]);if(Number.isInteger(s)&&s>0){for(;!y[s].includes("FORMAT");)s++;return s}else return-1}function e(t){var s=y[t].match(/\((\d*)\S*/),o=y[t].match(/[a-zA-Z](\d*)\)\s*/);return o==null&&(o=y[t].match(/[a-zA-Z](\d*)\.\d*\)\s*/)),[parseInt(s[1]),parseInt(o[1])]}return[C]}},"./src/parsers/SDF.ts"(k,w,c){c.r(w),c.d(w,{SDF:()=>y});const b=function(M,g,x,_){let p;try{p=JSON.parse(M)}catch{console.warn("3DMOL_STYLE: invalid JSON: "+M);return}const m=g.length-1,r=g[m];if(p.bonds&&typeof p.bonds=="object"){const e=p.bonds;for(const t in e){if(!e.hasOwnProperty(t))continue;const s=t.split("-");if(s.length!==2)continue;const o=parseInt(s[0])-1+_,l=parseInt(s[1])-1+_,d=x[o],i=x[l];if(d==null||i==null)continue;const n=e[t],a=d<i?d:i,h=d<i?i:d,u=r[a],A=u.bonds.indexOf(h);A<0||(u.bondStyles||(u.bondStyles=[]),u.bondStyles[A]||(u.bondStyles[A]={}),d>i&&(n.color1||n.color2)&&([n.color1,n.color2]=[n.color2,n.color1]),Object.assign(u.bondStyles[A],n))}delete p.bonds}Object.keys(p).length>0&&(g.modelData[m].style=p)},O=function(M,g,x,_,p){for(;g<M.length&&!M[g].startsWith("M END");)g++;for(g<M.length&&g++;g<M.length;){const m=M[g];let r=m.trim();if(g++,r==="$$$$")return g;const e=m.match(/^>\s*<([^>]+)>/);if(!e)continue;const t=e[1].trim(),s=[];for(;g<M.length&&(r=M[g].trim(),!(r===""||r==="$$$$"||M[g].charAt(0)===">"));)s.push(M[g]),g++;t==="3DMOL_STYLE"&&s.length>0&&b(s.join(" ").trim(),x,_,p)}return g},C=function(M,g,x,_){M[g].bonds.push(x),M[g].bondOrder.push(_),M[x].bonds.push(g),M[x].bondOrder.push(_)},R=function(M,g){const x=[[]],_=x.modelData=[];_.push({});const p=typeof g.keepH<"u"?!g.keepH:!1;let m=0;for(;m<M.length&&!(M.length-m<4);){const r=parseInt(M[m+3].substring(0,3));if(isNaN(r)||r<=0)break;const e=parseInt(M[m+3].substring(3,6));let t=4;if(M.length-m<4+r+e)break;const s=[],o=x[x.length-1],l=o.length,d=l+r;for(let i=l;i<d;i++,t++){const n=M[m+t],a={},h=n.substring(31,34).replace(/ /g,"");a.atom=a.elem=h[0].toUpperCase()+h.substring(1).toLowerCase(),(a.elem!=="H"||!p)&&(a.serial=i,s[i]=o.length,a.x=parseFloat(n.substring(0,10)),a.y=parseFloat(n.substring(10,20)),a.z=parseFloat(n.substring(20,30)),a.hetflag=!0,a.bonds=[],a.bondOrder=[],a.properties={},a.index=o.length,o.push(a))}for(let i=0;i<e;i++,t++){const n=M[m+t],a=s[parseInt(n.substring(0,3))-1+l],h=s[parseInt(n.substring(3,6))-1+l],u=parseFloat(n.substring(6));typeof a<"u"&&typeof h<"u"&&C(o,a,h,u)}if(m=O(M,m+t,x,s,l),!g.multimodel)break;g.onemol||(x.push([]),_.push({}))}return x},v=function(M,g){const x=[[]],_=x.modelData=[];_.push({});const p=typeof g.keepH<"u"?!g.keepH:!1;let m=0;for(;m<M.length&&!(M.length-m<8||!M[m+4].startsWith("M V30 BEGIN CTAB")||!M[m+5].startsWith("M V30 COUNTS")||M[m+5].length<14);){const r=M[m+5].substring(13).match(/\S+/g);if(r.length<2)break;const e=parseInt(r[0]);if(isNaN(e)||e<=0)break;const t=parseInt(r[1]);let s=7;if(M.length-m<8+e+t)break;const o=[],l=x[x.length-1],d=l.length,i=d+e;for(let n=d;n<i;n++,s++){const h=M[m+s].substring(6).match(/\S+/g);if(h.length>4){const u={},A=h[1].replace(/ /g,"");u.atom=u.elem=A[0].toUpperCase()+A.substring(1).toLowerCase(),(u.elem!=="H"||!p)&&(u.serial=n,o[n]=l.length,u.x=parseFloat(h[2]),u.y=parseFloat(h[3]),u.z=parseFloat(h[4]),u.hetflag=!0,u.bonds=[],u.bondOrder=[],u.properties={},u.index=l.length,l.push(u))}}if(M[m+s]==="M V30 END ATOM")s++;else break;if(t!==0&&M[m+s]==="M V30 BEGIN BOND")s++;else break;for(let n=0;n<t;n++,s++){const h=M[m+s].substring(6).match(/\S+/g);if(h.length>3){const u=o[parseInt(h[2])-1+d],A=o[parseInt(h[3])-1+d],D=parseFloat(h[1]);typeof u<"u"&&typeof A<"u"&&C(l,u,A,D)}}if(m=O(M,m+s,x,o,d),!g.multimodel)break;g.onemol||(x.push([]),_.push({}))}return x};function y(M,g){let x="V2000";const _=M.split(/\r?\n|\r/);return _.length>3&&_[3].length>38&&(x=_[3].substring(34,39)),x==="V2000"?R(_,g):x==="V3000"?v(_,g):[[""]]}},"./src/parsers/VASP.ts"(k,w,c){c.r(w),c.d(w,{VASP:()=>C});var b=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts");function C(R,v={}){var y=[[]],M={};const g=v.assignBonds===void 0?!0:v.assignBonds;var x=R.replace(/^\s+/,"").split(/\r?\n/);if(x.length<3)return y;if(x[1].match(/\d+/))M.length=parseFloat(x[1]);else return console.log("Warning: second line of the vasp structure file must be a number"),y;if(M.length<0)return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"),y;M.xVec=new Float32Array(x[2].replace(/^\s+/,"").split(/\s+/)),M.yVec=new Float32Array(x[3].replace(/^\s+/,"").split(/\s+/)),M.zVec=new Float32Array(x[4].replace(/^\s+/,"").split(/\s+/));var _=new b.Matrix3(M.xVec[0],M.xVec[1],M.xVec[2],M.yVec[0],M.yVec[1],M.yVec[2],M.zVec[0],M.zVec[1],M.zVec[2]);_.multiplyScalar(M.length),y.modelData=[{symmetries:[],cryst:{matrix:_}}];var p=x[5].trim().split(/\s+/),m=new Int16Array(x[6].trim().split(/\s+/)),r=x[7].trim(),e=!1;if(r.match(/S/)&&(e=!0,r=x[8].trim()),r.toLowerCase()[0]=="c")r="cartesian";else if(r.toLowerCase()[0]=="d")r="direct";else return console.log("Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"),y;if(p.length!=m.length)return console.log("Warning: declaration of atomary species wrong:"),console.log(p),console.log(m),y;e?x.splice(0,9):x.splice(0,8);for(var t=0,s=0,o=p.length;s<o;s++){for(var l=p[s],d=0,i=m[s];d<i;d++){var n=new Float32Array(x[t+d].trim().split(/\s+/)),a={};a.elem=l,r=="cartesian"?(a.x=M.length*n[0],a.y=M.length*n[1],a.z=M.length*n[2]):(a.x=M.length*(n[0]*M.xVec[0]+n[1]*M.yVec[0]+n[2]*M.zVec[0]),a.y=M.length*(n[0]*M.xVec[1]+n[1]*M.yVec[1]+n[2]*M.zVec[1]),a.z=M.length*(n[0]*M.xVec[2]+n[1]*M.yVec[2]+n[2]*M.zVec[2])),a.bonds=[],a.bondOrder=[],y[0].push(a)}t+=m[s]}if(g)for(let h=0;h<y.length;h++)(0,O.assignBonds)(y[h],v);return y}},"./src/parsers/XYZ.ts"(k,w,c){c.r(w),c.d(w,{XYZ:()=>C});var b=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts");function C(R,v){v=v||{};for(var y=[[]],M=v.assignBonds===void 0?!0:v.assignBonds,g=R.trimStart().split(/\r?\n|\r/);g.length>0&&!(g.length<3);){var x=parseInt(g[0]);if(isNaN(x)||x<=0||g.length<x+2)break;var _=/Lattice\s*=\s*["\{\}]([^"\{\}]+)["\{\}]\s*/gi,p=_.exec(g[1]);if(p!=null&&p.length>1){var m=new Float32Array(p[1].split(/\s+/)),r=new b.Matrix3(m[0],m[3],m[6],m[1],m[4],m[7],m[2],m[5],m[8]);y.modelData=[{cryst:{matrix:r}}]}for(var e=2,t=y[y.length-1].length,s=t+x,o=t;o<s;o++){var l=g[e++],d=l.trim().split(/\s+/),i={};i.serial=o;var n=d[0];i.atom=i.elem=n[0].toUpperCase()+n.substring(1,2).toLowerCase(),i.x=parseFloat(d[1]),i.y=parseFloat(d[2]),i.z=parseFloat(d[3]),i.hetflag=!0,i.bonds=[],i.bondOrder=[],i.properties={},y[y.length-1][o]=i,d.length>=7&&(i.dx=parseFloat(d[4]),i.dy=parseFloat(d[5]),i.dz=parseFloat(d[6]))}if(v.multimodel)y.push([]),g.splice(0,e);else break}if(M)for(let h=0;h<y.length;h++)(0,O.assignBonds)(y[h],v);if(v.onemol){var a=y;y=[],y.push(a[0]);for(let h=1;h<a.length;h++){let u=y[0].length;for(let A=0;A<a[h].length;A++){let D=a[h][A];for(let T=0;T<D.bonds.length;T++)D.bonds[T]=D.bonds[T]+u;D.index=y[0].length,D.serial=y[0].length,y[0].push(D)}}}return y}},"./src/parsers/cifutils/category.ts"(k,w,c){c.r(w),c.d(w,{Category:()=>O});var b=c("./src/parsers/cifutils/decoder.ts");function O(C){const R=Object.create(null),v=Object.create(null);for(const y of C.columns)R[y.name]=y;return{rowCount:C.rowCount,name:C.name.substring(1),fieldNames:C.columns.map(y=>y.name),getField(y){const M=R[y];if(M)return v[y]||(v[y]=(0,b.decode)(M.data)),v[y]}}}},"./src/parsers/cifutils/decoder.ts"(k,w,c){c.r(w),c.d(w,{decode:()=>R});var b=c("./src/parsers/cifutils/encoding.ts");const O=new Uint16Array(new Uint8Array([18,52]).buffer)[0]===13330;function C(u,A){const D=new ArrayBuffer(u.length),T=new Uint8Array(D);for(let S=0,P=u.length;S<P;S+=A)for(let z=0;z<A;z++)T[S+A-z-1]=u[S+z];return D}function R(u){let A=u.data;for(let D=u.encoding.length-1;D>=0;D--)A=v(A,u.encoding[D]);return A}function v(u,A){switch(A.kind){case"ByteArray":switch(A.type){case b.Encoding.IntDataType.Uint8:return u;case b.Encoding.IntDataType.Int8:return g(u);case b.Encoding.IntDataType.Int16:return _(u);case b.Encoding.IntDataType.Uint16:return p(u);case b.Encoding.IntDataType.Int32:return m(u);case b.Encoding.IntDataType.Uint32:return r(u);case b.Encoding.FloatDataType.Float32:return e(u);case b.Encoding.FloatDataType.Float64:return t(u);default:throw new Error("unreachable")}case"FixedPoint":return s(u,A);case"IntervalQuantization":return o(u,A);case"RunLength":return l(u,A);case"Delta":return d(u,A);case"IntegerPacking":return a(u,A);case"StringArray":return h(u,A)}}function y(u,A){switch(u){case b.Encoding.IntDataType.Int8:return new Int8Array(A);case b.Encoding.IntDataType.Int16:return new Int16Array(A);case b.Encoding.IntDataType.Int32:return new Int32Array(A);case b.Encoding.IntDataType.Uint8:return new Uint8Array(A);case b.Encoding.IntDataType.Uint16:return new Uint16Array(A);case b.Encoding.IntDataType.Uint32:return new Uint32Array(A);default:return new Int32Array(A)}}function M(u,A){switch(u){case b.Encoding.FloatDataType.Float32:return new Float32Array(A);case b.Encoding.FloatDataType.Float64:return new Float64Array(A);default:return new Float64Array(A)}}function g(u){return new Int8Array(u.buffer,u.byteOffset)}function x(u,A,D){return(u.byteOffset!=0||u.byteLength!=u.buffer.byteLength)&&(u=new Uint8Array(u)),O?new D(u.buffer):new D(C(u,A))}function _(u){return x(u,2,Int16Array)}function p(u){return x(u,2,Uint16Array)}function m(u){return x(u,4,Int32Array)}function r(u){return x(u,4,Uint32Array)}function e(u){return x(u,4,Float32Array)}function t(u){return x(u,8,Float64Array)}function s(u,A){const D=u.length,T=M(A.srcType,D),S=1/A.factor;for(let P=0;P<D;P++)T[P]=S*u[P];return T}function o(u,A){const D=u.length,T=M(A.srcType,D),S=(A.max-A.min)/(A.numSteps-1),P=A.min;for(let z=0;z<D;z++)T[z]=P+S*u[z];return T}function l(u,A){const D=y(A.srcType,A.srcSize);let T=0;for(let S=0,P=u.length;S<P;S+=2){const z=u[S],F=u[S+1];for(let B=0;B<F;++B)D[T++]=z}return D}function d(u,A){const D=u.length,T=y(A.srcType,D);if(!D)return u;T[0]=u[0]+(A.origin|0);for(let S=1;S<D;++S)T[S]=u[S]+T[S-1];return T}function i(u,A){const D=A.byteCount===1?127:32767,T=-D-1,S=u.length,P=new Int32Array(A.srcSize);let z=0,F=0;for(;z<S;){let B=0,W=u[z];for(;W===D||W===T;)B+=W,z++,W=u[z];B+=W,P[F]=B,z++,F++}return P}function n(u,A){const D=A.byteCount===1?255:65535,T=u.length,S=new Int32Array(A.srcSize);let P=0,z=0;for(;P<T;){let F=0,B=u[P];for(;B===D;)F+=B,P++,B=u[P];F+=B,S[z]=F,P++,z++}return S}function a(u,A){return u.length===A.srcSize?u:A.isUnsigned?n(u,A):i(u,A)}function h(u,A){const D=R({encoding:A.offsetEncoding,data:A.offsets}),T=R({encoding:A.dataEncoding,data:u}),S=A.stringData,P=new Array(D.length);P[0]="";for(let B=1,W=D.length;B<W;B++)P[B]=S.substring(D[B-1],D[B]);let z=0;const F=new Array(T.length);for(let B=0,W=T.length;B<W;B++)F[z++]=P[T[B]+1];return F}},"./src/parsers/cifutils/encoding.ts"(k,w,c){c.r(w),c.d(w,{Encoding:()=>O,VERSION:()=>b});const b="0.3.0";var O;(function(C){(function(y){y[y.Int8=1]="Int8",y[y.Int16=2]="Int16",y[y.Int32=3]="Int32",y[y.Uint8=4]="Uint8",y[y.Uint16=5]="Uint16",y[y.Uint32=6]="Uint32"})(C.IntDataType||(C.IntDataType={})),(function(y){y[y.Float32=32]="Float32",y[y.Float64=33]="Float64"})(C.FloatDataType||(C.FloatDataType={}));function R(y){let M;return y instanceof Int8Array?M=C.IntDataType.Int8:y instanceof Int16Array?M=C.IntDataType.Int16:y instanceof Int32Array?M=C.IntDataType.Int32:y instanceof Uint8Array?M=C.IntDataType.Uint8:y instanceof Uint16Array?M=C.IntDataType.Uint16:y instanceof Uint32Array?M=C.IntDataType.Uint32:y instanceof Float32Array?M=C.FloatDataType.Float32:y instanceof Float64Array?M=C.FloatDataType.Float64:M=C.IntDataType.Int32,M}C.getDataType=R;function v(y){if(y instanceof Int8Array||y instanceof Int16Array||y instanceof Int32Array)return!0;for(let M=0,g=y.length;M<g;M++)if(M<0)return!1;return!0}C.isSignedIntegerDataType=v})(O||(O={}))},"./src/parsers/index.ts"(k,w,c){c.r(w),c.d(w,{Parsers:()=>s,bondLength:()=>t.bondLength,setBondLength:()=>t.setBondLength});var b=c("./src/parsers/VASP.ts"),O=c("./src/parsers/CUBE.ts"),C=c("./src/parsers/XYZ.ts"),R=c("./src/parsers/SDF.ts"),v=c("./src/parsers/CDJSON.ts"),y=c("./src/parsers/CIF.ts"),M=c("./src/parsers/MOL2.ts"),g=c("./src/parsers/PDB.ts"),x=c("./src/parsers/PQR.ts"),_=c("./src/parsers/MMTF.ts"),p=c("./src/parsers/PRMTOP.ts"),m=c("./src/parsers/GRO.ts"),r=c("./src/parsers/LAMMPSTRJ.ts"),e=c("./src/parsers/BCIF.ts"),t=c("./src/parsers/utils/bondLength.ts");const s={vasp:b.VASP,VASP:b.VASP,cube:O.CUBE,CUBE:O.CUBE,xyz:C.XYZ,XYZ:C.XYZ,sdf:R.SDF,SDF:R.SDF,json:v.CDJSON,cdjson:v.CDJSON,CDJSON:v.CDJSON,mcif:y.CIF,cif:y.CIF,CIF:y.CIF,mol2:M.MOL2,MOL2:M.MOL2,pdb:g.PDB,PDB:g.PDB,pdbqt:g.PDB,PDBQT:g.PDB,pqr:x.PQR,PQR:x.PQR,mmtf:_.MMTFparser,MMTF:_.MMTFparser,prmtop:p.PRMTOP,PRMTOP:p.PRMTOP,gro:m.GRO,GRO:m.GRO,lammpstrj:r.LAMMPSTRJ,LAMMPSTRJ:r.LAMMPSTRJ,bcif:e.BCIF,BCIF:e.BCIF}},"./src/parsers/utils/anumToSymbol.ts"(k,w,c){c.r(w),c.d(w,{anumToSymbol:()=>b});const b={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"}},"./src/parsers/utils/areConnected.ts"(k,w,c){c.r(w),c.d(w,{areConnected:()=>C});var b=c("./src/parsers/utils/bondLength.ts");const O=new Set(["Na","K","Ca","Mg","Mn","Sr"]);function C(R,v,y){if(y&&y.unboundCations&&(O.has(R.elem)||O.has(v.elem)))return!1;let M=(0,b.bondLength)(R.elem)+(0,b.bondLength)(v.elem);M+=.25,M*=M;let g=R.x-v.x;if(g*=g,g>M)return!1;let x=R.y-v.y;if(x*=x,x>M)return!1;let _=R.z-v.z;if(_*=_,_>M)return!1;const p=g+x+_;return!(isNaN(p)||p<.5||p>M||R.altLoc!==v.altLoc&&R.altLoc.trim()!==""&&v.altLoc.trim()!=="")}},"./src/parsers/utils/assignBackboneHBonds.ts"(k,w,c){c.r(w),c.d(w,{assignBackboneHBonds:()=>b});function b(O,C){const R=C||3.2,v=R*R,y=[];for(let M=0,g=O.length;M<g;M++){O[M].index=M;const x=O[M];!x.hetflag&&(x.atom==="N"||x.atom==="O")&&(y.push(x),x.hbondOther=null,x.hbondDistanceSq=Number.POSITIVE_INFINITY)}y.sort(function(M,g){return M.z-g.z});for(let M=0,g=y.length;M<g;M++){const x=y[M];for(let _=M+1;_<g;_++){const p=y[_],m=p.z-x.z;if(m>R)break;if(p.atom==x.atom)continue;const r=Math.abs(p.y-x.y);if(r>R)continue;const e=Math.abs(p.x-x.x);if(e>R)continue;const t=e*e+r*r+m*m;t>v||p.chain==x.chain&&Math.abs(p.resi-x.resi)<4||(t<x.hbondDistanceSq&&(x.hbondOther=p,x.hbondDistanceSq=t),t<p.hbondDistanceSq&&(p.hbondOther=x,p.hbondDistanceSq=t))}}}},"./src/parsers/utils/assignBonds.ts"(k,w,c){c.r(w),c.d(w,{assignBonds:()=>R});var b=c("./src/parsers/utils/areConnected.ts");const O=[{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}],C=4.95;function R(v,y){for(let x=0,_=v.length;x<_;x++)v[x].index||(v[x].index=x);const M={x:{y:{z:[]}}};for(let x=0;x<v.length;x++){const _=v[x],p=Math.floor(_.x/C),m=Math.floor(_.y/C),r=Math.floor(_.z/C);M[p]||(M[p]={}),M[p][m]||(M[p][m]={}),M[p][m][r]||(M[p][m][r]=[]),M[p][m][r].push(_)}function g(x,_){for(let p=0;p<x.length;p++){const m=x[p];for(let r=0;r<_.length;r++){const e=_[r];if((0,b.areConnected)(m,e,y)){const t=m.bonds.indexOf(e.index),s=e.bonds.indexOf(m.index);t===-1&&s===-1?(m.bonds.push(e.index),m.bondOrder.push(1),e.bonds.push(m.index),e.bondOrder.push(1)):t===-1?(m.bonds.push(e.index),m.bondOrder.push(e.bondOrder[s])):s===-1&&(e.bonds.push(m.index),e.bondOrder.push(m.bondOrder[t]))}}}}for(let x in M){const _=parseInt(x);for(let p in M[_]){const m=parseInt(p);for(let r in M[_][m]){const e=parseInt(r),t=M[_][m][e];for(let s=0;s<t.length;s++){const o=t[s];for(let l=s+1;l<t.length;l++){const d=t[l];(0,b.areConnected)(o,d,y)&&o.bonds.indexOf(d.index)==-1&&(o.bonds.push(d.index),o.bondOrder.push(1),d.bonds.push(o.index),d.bondOrder.push(1))}}for(let s=0;s<O.length;s++){const o=O[s];if(!M[_+o.x]||!M[_+o.x][m+o.y]||!M[_+o.x][m+o.y][e+o.z])continue;const l=M[_+o.x][m+o.y][e+o.z];g(t,l)}}}}}},"./src/parsers/utils/assignPDBBonds.ts"(k,w,c){c.r(w),c.d(w,{assignPDBBonds:()=>R});var b=c("./src/parsers/utils/areConnected.ts"),O=c("./src/parsers/utils/assignBonds.ts"),C=c("./src/parsers/utils/standardResidues.ts");function R(v,y){const M=[],g=[];for(let m=0,r=v.length;m<r;m++){const e=v[m];e.index=m,e.hetflag||!C.standardResidues.has(e.resn)?g.push(e):M.push(e)}(0,O.assignBonds)(g,y),M.sort(function(m,r){return m.chain!==r.chain?m.chain<r.chain?-1:1:m.resi-r.resi});let x=-1,_=-1,p;for(let m=0,r=M.length;m<r;m++){const e=M[m];e.resi!==x&&(x=e.resi,p||_++,p=!1),e.reschain=_;for(let t=m+1;t<M.length;t++){const s=M[t];if(s.chain!==e.chain||s.resi-e.resi>1)break;(0,b.areConnected)(e,s,y)&&(e.bonds.indexOf(s.index)===-1&&(e.bonds.push(s.index),e.bondOrder.push(1),s.bonds.push(e.index),s.bondOrder.push(1)),e.resi!==s.resi&&(p=!0))}}}},"./src/parsers/utils/atomNameToElem.ts"(k,w,c){c.r(w),c.d(w,{atomNameToElem:()=>O});var b=c("./src/parsers/utils/bondLength.ts");function O(C,R){let v=C.replace(/ /g,"");return v.length>0&&v[0]==="H"&&v!=="Hg"&&v!=="He"&&v!=="Hf"&&v!=="Hs"&&v!=="Ho"&&(v="H"),v.length>1&&(v=v[0].toUpperCase()+v.substring(1).toLowerCase(),b.bondTable[v]===void 0?v=v[0]:R&&(v==="Ca"||v==="Cd")&&(v="C")),v}},"./src/parsers/utils/bondLength.ts"(k,w,c){c.r(w),c.d(w,{bondLength:()=>O,bondTable:()=>b,setBondLength:()=>C});let b={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 O(R){return b[R]||1.6}function C(R,v){v<0&&(v=0),b[R]=v}},"./src/parsers/utils/computeSecondaryStructure.ts"(k,w,c){c.r(w),c.d(w,{computeSecondaryStructure:()=>O});var b=c("./src/parsers/utils/assignBackboneHBonds.ts");function O(C,R){(0,b.assignBackboneHBonds)(C,R);const v={};let y,M,g,x,_,p;for(y=0,M=C.length;y<M;y++)if(_=C[y],v[_.chain]===void 0&&(v[_.chain]=[]),isFinite(_.hbondDistanceSq)){const m=_.hbondOther;v[m.chain]===void 0&&(v[m.chain]=[]),Math.abs(m.resi-_.resi)===4&&(v[_.chain][_.resi]="h")}for(g in v)for(x=1;x<v[g].length-1;x++){const m=v[g][x-1],r=v[g][x+1];p=v[g][x],m=="h"&&m==r&&p!=m&&(v[g][x]=m)}for(y=0,M=C.length;y<M;y++)_=C[y],isFinite(_.hbondDistanceSq)&&v[_.chain][_.resi]!="h"&&_.ss!=="h"&&(v[_.chain][_.resi]="maybesheet");for(let m=0,r=C.length;m<r;m++)if(_=C[m],isFinite(_.hbondDistanceSq)&&v[_.chain][_.resi]=="maybesheet"){let e=_.hbondOther,t=v[e.chain][e.resi];(t=="maybesheet"||t=="s")&&(v[_.chain][_.resi]="s",v[e.chain][e.resi]="s")}for(let m in v){for(let r=1;r<v[m].length-1;r++){const e=v[m][r-1],t=v[m][r+1];p=v[m][r],e=="s"&&e==t&&p!=e&&(v[m][r]=e)}for(let r=0;r<v[m].length;r++){const e=v[m][r];(e=="h"||e=="s")&&v[m][r-1]!=e&&v[m][r+1]!=e&&delete v[m][r]}}for(y=0,M=C.length;y<M;y++)_=C[y],p=v[_.chain][_.resi],delete _.hbondOther,delete _.hbondDistanceSq,!(p===void 0||p==="maybesheet")&&(_.ss=p,v[_.chain][_.resi-1]!=p&&(_.ssbegin=!0),v[_.chain][_.resi+1]!=p&&(_.ssend=!0))}},"./src/parsers/utils/getSinglePDB.ts"(k,w,c){c.r(w),c.d(w,{getSinglePDB:()=>x});var b=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/atomNameToElem.ts"),C=c("./src/parsers/utils/bondLength.ts"),R=c("./src/parsers/utils/computeSecondaryStructure.ts"),v=c("./src/parsers/utils/isEmpty.ts"),y=c("./src/parsers/utils/processSymmetries.ts"),M=c("./src/parsers/utils/assignPDBBonds.ts"),g=c("./src/parsers/utils/validateBonds.ts");function x(_,p,m){const r=[],e=p.assignBonds===void 0?!0:p.assignBonds,t=!p.keepH,s=!!p.noSecondaryStructure,o=!p.noComputeSecondaryStructure,l=!p.doAssembly,d=p.altLoc?p.altLoc:"A",i={symmetries:[],cryst:void 0};let n,a=[];const h=[];let u;const A={};for(let D=0;D<_.length;D++){u=_[D].replace(/^\s*/,"");const T=u.substring(0,6);let S,P,z;if(T.indexOf("END")===0){if(a=_.slice(D+1),T==="END")for(const F in m)m.hasOwnProperty(F)&&delete m[F];break}else if(T==="ATOM "||T==="HETATM"){let F,B,W,U,I,G,Y,J,te,ne,le,ie;if(le=u.substring(16,17),le!==" "&&le!==d&&d!=="*"||(ne=parseInt(u.substring(6,11)),n=u.substring(12,16).replace(/ /g,""),F=u.substring(17,20).replace(/ /g,""),B=u.substring(21,22),W=parseInt(u.substring(22,26)),U=u.substring(26,27),I=parseFloat(u.substring(30,38)),G=parseFloat(u.substring(38,46)),Y=parseFloat(u.substring(46,54)),ie=parseFloat(u.substring(60,68)),te=u.substring(76,78).replace(/ /g,""),te===""||C.bondTable[te]===void 0?te=(0,O.atomNameToElem)(u.substring(12,14),u[0]=="A"):te=te[0].toUpperCase()+te.substring(1).toLowerCase(),te==="H"&&t))continue;T[0]=="H"?J=!0:J=!1,h[ne]=r.length,r.push({resn:F,x:I,y:G,z:Y,elem:te,hetflag:J,altLoc:le,chain:B,resi:W,icode:U,rescode:W+(U!==" "?"^"+U:""),serial:ne,atom:n,bonds:[],ss:"c",bondOrder:[],properties:{},b:ie,pdbline:u})}else if(T==="SHEET "){S=u.substring(21,22),P=parseInt(u.substring(22,26)),z=parseInt(u.substring(33,37)),S in m||(m[S]={}),m[S][P]="s1";for(let F=P+1;F<z;F++)m[S][F]="s";m[S][z]="s2"}else if(T==="CONECT"){const F=parseInt(u.substring(6,11)),B=h[F],W=r[B],U=[11,16,21,26];for(let I=0;I<4;I++){const G=parseInt(u.substring(U[I],U[I]+5)),Y=h[G];let J=B+":"+Y;const te=r[Y];if(W!==void 0&&te!==void 0)if(!A[J])A[J]=1,(W.bonds.length==0||W.bonds[W.bonds.length-1]!==Y)&&(W.bonds.push(Y),W.bondOrder.push(1));else{A[J]+=1;for(let ne=0;ne<W.bonds.length;ne++)if(W.bonds[ne]==Y){const le=A[J];le>=4?W.bondOrder[ne]=1:W.bondOrder[ne]=le}}}}else if(T==="HELIX "){S=u.substring(19,20),P=parseInt(u.substring(21,25)),z=parseInt(u.substring(33,37)),S in m||(m[S]={}),m[S][P]="h1";for(let F=P+1;F<z;F++)m[S][F]="h";m[S][z]="h2"}else if(!l&&T==="REMARK"&&u.substring(13,18)==="BIOMT"){let F,B=new b.Matrix4;for(F=1;F<=3;F++)if(u=_[D].replace(/^\s*/,""),parseInt(u.substring(18,19))==F)B.elements[F-1]=parseFloat(u.substring(23,33)),B.elements[F-1+4]=parseFloat(u.substring(33,43)),B.elements[F-1+8]=parseFloat(u.substring(43,53)),B.elements[F-1+12]=parseFloat(u.substring(53)),D++;else for(;u.substring(13,18)==="BIOMT";)D++,u=_[D].replace(/^\s*/,"");B.elements[3]=0,B.elements[7]=0,B.elements[11]=0,B.elements[15]=1,i.symmetries.push(B),D--}else if(T==="CRYST1"){let F,B,W,U,I,G;F=parseFloat(u.substring(7,15)),B=parseFloat(u.substring(16,24)),W=parseFloat(u.substring(25,33)),U=parseFloat(u.substring(34,40)),I=parseFloat(u.substring(41,47)),G=parseFloat(u.substring(48,54)),i.cryst={a:F,b:B,c:W,alpha:U,beta:I,gamma:G}}else if(T==="ANISOU"){const F=parseInt(u.substring(6,11)),B=h[F],W=r[B];if(W){const U=u.substring(30).trim().split(/\s+/),I={u11:parseInt(U[0]),u22:parseInt(U[1]),u33:parseInt(U[2]),u12:parseInt(U[3]),u13:parseInt(U[4]),u23:parseInt(U[5])};W.uMat=I}}}if((0,g.validateBonds)(r,h),e&&(0,M.assignPDBBonds)(r,p),l||(0,y.processSymmetries)(i.symmetries,r,p,i.cryst),o&&!s&&(0,R.computeSecondaryStructure)(r,p.hbondCutoff),!(0,v.isEmpty)(m))for(let D=0;D<r.length;D++){const T=r[D];if(T!==void 0&&T.chain in m&&T.resi in m[T.chain]){const S=m[T.chain][T.resi];T.ss=S[0],S.length>1&&(S[1]=="1"?T.ssbegin=!0:S[1]=="2"&&(T.ssend=!0))}}return[r,i,a]}},"./src/parsers/utils/isEmpty.ts"(k,w,c){c.r(w),c.d(w,{isEmpty:()=>b});function b(O){for(const C in O)return!1;return!0}},"./src/parsers/utils/processSymmetries.ts"(k,w,c){c.r(w),c.d(w,{processSymmetries:()=>O});var b=c("./src/WebGL/index.ts");function O(C,R,v,y){const M=!v.duplicateAssemblyAtoms,g=R.length;let x=g,_=-1,p=null,m=null;(v.normalizeAssembly||v.wrapAtoms)&&y&&(p=(0,b.conversionMatrix3)(y.a,y.b,y.c,y.alpha,y.beta,y.gamma),m=new b.Matrix3,m.getInverse3(p));let r=function(s){let o=s.clone().applyMatrix3(m);const l=[o.x,o.y,o.z],d=[0,0,0];for(let n=0;n<3;n++){for(;l[n]<-.001;)l[n]+=1,d[n]+=1;for(;l[n]>1.001;)l[n]-=1,d[n]-=1}const i=new b.Vector3(d[0],d[1],d[2]);return i.applyMatrix3(p),i};if(v.normalizeAssembly&&y)for(let s=0;s<C.length;s++){const o=new b.Vector3(0,0,0);for(let d=0;d<g;d++){const i=new b.Vector3(R[d].x,R[d].y,R[d].z);i.applyMatrix4(C[s]),o.add(i)}o.divideScalar(g);const l=r(o);C[s].isNearlyIdentity()&&l.lengthSq()>.001&&(_=s),C[s].translate(l)}if(M){if(C.length>1)for(let s=0;s<R.length;s++){var e=[];for(let o=0;o<C.length;o++)if(!C[o].isNearlyIdentity()){var t=new b.Vector3;t.set(R[s].x,R[s].y,R[s].z),t.applyMatrix4(C[o]),e.push(t)}R[s].symmetries=e}}else{for(let s=0;s<g;s++)R[s].sym=-1;for(let s=0;s<C.length;s++)if(!C[s].isNearlyIdentity()&&_!=s){let o=new b.Vector3;for(let l=0;l<g;l++){const d=[];for(let n=0;n<R[l].bonds.length;n++)d.push(R[l].bonds[n]+x);if(o.set(R[l].x,R[l].y,R[l].z),o.applyMatrix4(C[s]),v.wrapAtoms&&y){let n=r(o);o.add(n)}const i={};for(const n in R[l])i[n]=R[l][n];i.x=o.x,i.y=o.y,i.z=o.z,i.bonds=d,i.sym=s,i.index=R.length,R.push(i)}x=R.length}else for(let o=0;o<g;o++)R[o].sym=s;if(v.wrapAtoms&&y){let s=new b.Vector3;for(let o=0;o<g;o++){s.set(R[o].x,R[o].y,R[o].z);let l=r(s);s.add(l),R[o].x=s.x,R[o].y=s.y,R[o].z=s.z}}if(_>=0){const s=new b.Vector3;for(let o=0;o<g;o++)s.set(R[o].x,R[o].y,R[o].z),s.applyMatrix4(C[_]),R[o].x=s.x,R[o].y=s.y,R[o].z=s.z}C.length=0}}},"./src/parsers/utils/standardResidues.ts"(k,w,c){c.r(w),c.d(w,{standardResidues:()=>b});const b=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"])},"./src/parsers/utils/validateBonds.ts"(k,w,c){c.r(w),c.d(w,{validateBonds:()=>b});function b(O,C){for(let R=0,v=O.length;R<v;R++){const y=O[R];for(let M=0;M<y.bonds.length;M++){const g=y.bonds[M],x=O[g],_=C[y.serial];x&&_&&x.bonds.indexOf(_)<0&&(x.bonds.push(_),x.bondOrder.push(y.bondOrder[M]))}}}},"./src/partialCharges.ts"(k,w,c){c.r(w),c.d(w,{applyPartialCharges:()=>O,partialCharges:()=>b});const b={"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 O(C,R){if((!R||typeof C.partialCharge>"u")&&C.resn&&C.atom){var v=C.resn+":"+C.atom;C.properties.partialCharge=b[v]}}},"./src/specs.ts"(k,w,c){c.r(w)},"./src/utilities.ts"(__unused_webpack_module,__webpack_exports__,__webpack_require__){__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,inflateString:()=>inflateString,isEmptyObject:()=>isEmptyObject,isNumeric:()=>isNumeric,makeFunction:()=>makeFunction,mergeGeos:()=>mergeGeos,specStringToObject:()=>specStringToObject});var _Gradient__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./src/Gradient.ts"),_VolumeData__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./src/VolumeData.ts"),_colors__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./src/colors.ts"),pako__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./node_modules/pako/dist/pako.esm.mjs");function extend(k,w){for(var c in w)w.hasOwnProperty(c)&&w[c]!==void 0&&(k[c]=w[c]);return k}function deepCopy(k){let w,c,b;if(k==null)return{};if(typeof k!="object"||k===null)return k;w=Array.isArray(k)?[]:{};for(b in k)c=k[b],w[b]=deepCopy(c);return w}function isNumeric(k){var w=typeof k;return(w==="number"||w==="string")&&!isNaN(k-parseFloat(k))}function isEmptyObject(k){return Object.keys(k).length===0}function makeFunction(callback){return callback&&typeof callback=="string"&&(callback=eval("("+callback+")")),callback&&typeof callback!="function"?(console.warn("Invalid callback provided."),()=>{}):callback}function adjustVolumeStyle(k){k&&(k.volformat&&!(k.voldata instanceof _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData)&&(k.voldata=new _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData(k.voldata,k.volformat)),k.volscheme&&(k.volscheme=_Gradient__WEBPACK_IMPORTED_MODULE_0__.Gradient.getGradient(k.volscheme)))}function getExtent(k,w){var c,b,O,C,R,v,y,M,g,x,_=!w;if(c=b=O=9999,C=R=v=-9999,y=M=g=x=0,k.length===0)return[[0,0,0],[0,0,0],[0,0,0]];for(var p=0;p<k.length;p++){var m=k[p];if(!(typeof m>"u"||!isFinite(m.x)||!isFinite(m.y)||!isFinite(m.z))&&(x++,y+=m.x,M+=m.y,g+=m.z,c=c<m.x?c:m.x,b=b<m.y?b:m.y,O=O<m.z?O:m.z,C=C>m.x?C:m.x,R=R>m.y?R:m.y,v=v>m.z?v:m.z,m.symmetries&&_))for(var r=0;r<m.symmetries.length;r++)x++,y+=m.symmetries[r].x,M+=m.symmetries[r].y,g+=m.symmetries[r].z,c=c<m.symmetries[r].x?c:m.symmetries[r].x,b=b<m.symmetries[r].y?b:m.symmetries[r].y,O=O<m.symmetries[r].z?O:m.symmetries[r].z,C=C>m.symmetries[r].x?C:m.symmetries[r].x,R=R>m.symmetries[r].y?R:m.symmetries[r].y,v=v>m.symmetries[r].z?v:m.symmetries[r].z}return[[c,b,O],[C,R,v],[y/x,M/x,g/x]]}function getPropertyRange(k,w){for(var c=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,O=0,C=k.length;O<C;O++){var R=k[O],v=getAtomProperty(R,w);v!=null&&(v<c&&(c=v),v>b&&(b=v))}return!isFinite(c)&&!isFinite(b)?c=b=0:isFinite(c)?isFinite(b)||(b=c):c=b,[c,b]}class PausableTimer{constructor(w,c,b){this.total_time_run=0,this.fn=w,this.arg=b,this.countdown=c,this.start_time=new Date().getTime(),this.ident=setTimeout(w,c,b)}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(k){for(var w=window.atob(k),c=w.length,b=new Uint8Array(c),O=0;O<c;O++)b[O]=w.charCodeAt(O);return b}function getAtomProperty(k,w){var c=null;return k.properties&&typeof k.properties[w]<"u"?c=k.properties[w]:typeof k[w]<"u"&&(c=k[w]),c}function mergeGeos(k,w){var c=w.geometry;c!==void 0&&k.geometryGroups.push(c.geometryGroups[0])}function specStringToObject(k){if(typeof k=="object")return k;if(typeof k>"u"||k==null)return k;try{return JSON.parse(k)}catch{}k=k.replace(/%7E/g,"~");var w=function(_){return isNumeric(_)?Math.floor(parseFloat(_))==parseInt(_)||_.indexOf(".")>=0?parseFloat(_):parseInt(_):_==="true"?!0:_==="false"?!1:_},c={};if(k==="all")return c;for(var b=k.split(";"),O=0;O<b.length;O++){var C=b[O].split(":"),R=C[0],v={},y=C[1];if(y)if(y=y.replace(/~/g,"="),y.indexOf("=")!==-1)for(var M=y.split(","),g=0;g<M.length;g++){var x=M[g].split("=",2);v[x[0]]=w(x[1])}else y.indexOf(",")!==-1?v=y.split(","):v=w(y);c[R]=v}return c}function checkStatus(k){if(!k.ok)throw new Error(`HTTP ${k.status} - ${k.statusText}`);return k}function get(k,w){var c=fetch(k).then(checkStatus).then(b=>b.text());return w?c.then(w):c}function getbin(k,w,c,b){var O;return c=="POST"?O=fetch(k,{method:"POST",body:b}).then(C=>checkStatus(C)).then(C=>C.arrayBuffer()):O=fetch(k).then(C=>checkStatus(C)).then(C=>C.arrayBuffer()),w?O.then(w):O}function download(k,w,c,b){var O="",C="",R="",v=null,y=w.addModel();k.indexOf(":")<0&&(k.length==4?k="pdb:"+k:isNaN(k)?k="url:"+k:k="cid:"+k),k.substring(0,5)=="mmtf:"&&(console.warn("WARNING: MMTF now deprecated. Reverting to bcif."),k="bcif:"+k.slice(5));var M=function(g){y.addMolData(g,O,c),w.zoomTo(),w.render()};if(k.substring(0,5)==="bcif:")k=k.substring(5).toUpperCase(),R="https://models.rcsb.org/"+k+".bcif.gz",c&&typeof c.noComputeSecondaryStructure>"u"&&(c.noComputeSecondaryStructure=!0),v=new Promise(function(g){getbin(R).then(function(x){M(x),g(y)}).catch(function(){C=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=C+k+".pdb",O="pdb",console.warn("falling back to pdb format"),get(R).then(function(x){M(x),g(y)}).catch(function(x){M(""),g(y),console.error("fetch of "+R+" failed: "+x.statusText)})})});else{if(k.substring(0,4)==="pdb:"){if(O="bcif",c&&c.format&&(O=c.format),c&&typeof c.noComputeSecondaryStructure>"u"&&(c.noComputeSecondaryStructure=!0),k=k.substring(4).toUpperCase(),!k.match(/^[1-9][A-Za-z0-9]{3}$/)){alert("Wrong PDB ID");return}O=="bcif"?R="https://models.rcsb.org/"+k.toUpperCase()+".bcif.gz":(C=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=C+k+"."+O)}else if(k.substring(0,4)=="cid:"){if(O="sdf",k=k.substring(4),!k.match(/^[0-9]+$/)){alert("Wrong Compound ID");return}R="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+k+"/SDF?record_type=3d"}else k.substring(0,4)=="url:"&&(R=k.substring(4),O=R);v=new Promise(function(g){O=="bcif"?getbin(R).then(function(x){M(x),g(y)}).catch(function(){C=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=C+k+".pdb",O="pdb",console.warn("falling back to pdb format"),get(R).then(function(x){M(x),g(y)}).catch(function(x){M(""),g(y),console.error("fetch of "+R+" failed: "+x.statusText)})}):get(R).then(function(x){M(x),g(y)}).catch(function(x){M(""),g(y),console.error("fetch of "+R+" failed: "+x.statusText)})})}return b?(v.then(function(g){b(g)}),y):v}function getColorFromStyle(k,w){let c=w.colorscheme;if(typeof _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c]<"u")c=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c];else if(typeof c=="string"&&c.endsWith("Carbon")){let R=c.substring(0,c.lastIndexOf("Carbon")).toLowerCase();if(typeof _colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[R]<"u"){let v=Object.assign({},_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors);v.C=_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[R],_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c]={prop:"elem",map:v},c=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c]}}let b=k.color;if(typeof w.color<"u"&&w.color!="spectrum"&&(b=w.color),typeof c<"u"){let R,v;if(typeof _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[c]<"u")c=_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[c],typeof c[k[c.prop]]<"u"&&(b=c.map[k[c.prop]]);else if(typeof c[k[c.prop]]<"u")b=c.map[k[c.prop]];else if(typeof c.prop<"u"&&typeof c.gradient<"u"){R=c.prop;var O=c.gradient;O instanceof _Gradient__WEBPACK_IMPORTED_MODULE_0__.GradientType||(O=(0,_Gradient__WEBPACK_IMPORTED_MODULE_0__.getGradient)(c));let y=O.range()||[-1,1];v=getAtomProperty(k,R),v!=null&&(b=O.valueToHex(v,y))}else typeof c.prop<"u"&&typeof c.map<"u"?(R=c.prop,v=getAtomProperty(k,R),typeof c.map[v]<"u"&&(b=c.map[v])):typeof w.colorscheme[k.elem]<"u"?b=w.colorscheme[k.elem]:console.warn("Could not interpret colorscheme "+c)}else typeof w.colorfunc<"u"&&(b=w.colorfunc(k));return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(b)}function getElement(k){let w=k;return typeof k=="string"?w=document.querySelector("#"+k):typeof k=="object"&&k.get&&(w=k.get(0)),w}function inflateString(k,w=!0){let c;return typeof k=="string"?c=new TextEncoder().encode(k):c=new Uint8Array(k),(0,pako__WEBPACK_IMPORTED_MODULE_3__.inflate)(c,{to:w?"string":null})}},"./src/vendor/mmtf.js"(k,w){(function(c,b){b(w)})(this,function(c){function b(K,Z,$){for(var me=(K.byteLength,0),ce=$.length;ce>me;me++){var Me=$.charCodeAt(me);if(128>Me)K.setUint8(Z++,Me>>>0&127|0);else if(2048>Me)K.setUint8(Z++,Me>>>6&31|192),K.setUint8(Z++,Me>>>0&63|128);else if(65536>Me)K.setUint8(Z++,Me>>>12&15|224),K.setUint8(Z++,Me>>>6&63|128),K.setUint8(Z++,Me>>>0&63|128);else{if(!(1114112>Me))throw new Error("bad codepoint "+Me);K.setUint8(Z++,Me>>>18&7|240),K.setUint8(Z++,Me>>>12&63|128),K.setUint8(Z++,Me>>>6&63|128),K.setUint8(Z++,Me>>>0&63|128)}}}function O(K){for(var Z=0,$=0,me=K.length;me>$;$++){var ce=K.charCodeAt($);if(128>ce)Z+=1;else if(2048>ce)Z+=2;else if(65536>ce)Z+=3;else{if(!(1114112>ce))throw new Error("bad codepoint "+ce);Z+=4}}return Z}function C(K,Z,$){var me=typeof K;if(me==="string"){var ce=O(K);if(32>ce)return Z.setUint8($,160|ce),b(Z,$+1,K),1+ce;if(256>ce)return Z.setUint8($,217),Z.setUint8($+1,ce),b(Z,$+2,K),2+ce;if(65536>ce)return Z.setUint8($,218),Z.setUint16($+1,ce),b(Z,$+3,K),3+ce;if(4294967296>ce)return Z.setUint8($,219),Z.setUint32($+1,ce),b(Z,$+5,K),5+ce}if(K instanceof Uint8Array){var ce=K.byteLength,Me=new Uint8Array(Z.buffer);if(256>ce)return Z.setUint8($,196),Z.setUint8($+1,ce),Me.set(K,$+2),2+ce;if(65536>ce)return Z.setUint8($,197),Z.setUint16($+1,ce),Me.set(K,$+3),3+ce;if(4294967296>ce)return Z.setUint8($,198),Z.setUint32($+1,ce),Me.set(K,$+5),5+ce}if(me==="number"){if(!isFinite(K))throw new Error("Number not finite: "+K);if(Math.floor(K)!==K)return Z.setUint8($,203),Z.setFloat64($+1,K),9;if(K>=0){if(128>K)return Z.setUint8($,K),1;if(256>K)return Z.setUint8($,204),Z.setUint8($+1,K),2;if(65536>K)return Z.setUint8($,205),Z.setUint16($+1,K),3;if(4294967296>K)return Z.setUint8($,206),Z.setUint32($+1,K),5;throw new Error("Number too big 0x"+K.toString(16))}if(K>=-32)return Z.setInt8($,K),1;if(K>=-128)return Z.setUint8($,208),Z.setInt8($+1,K),2;if(K>=-32768)return Z.setUint8($,209),Z.setInt16($+1,K),3;if(K>=-2147483648)return Z.setUint8($,210),Z.setInt32($+1,K),5;throw new Error("Number too small -0x"+(-K).toString(16).substr(1))}if(K===null)return Z.setUint8($,192),1;if(me==="boolean")return Z.setUint8($,K?195:194),1;if(me==="object"){var ce,se=0,we=Array.isArray(K);if(we)ce=K.length;else{var j=Object.keys(K);ce=j.length}var se;if(16>ce?(Z.setUint8($,ce|(we?144:128)),se=1):65536>ce?(Z.setUint8($,we?220:222),Z.setUint16($+1,ce),se=3):4294967296>ce&&(Z.setUint8($,we?221:223),Z.setUint32($+1,ce),se=5),we)for(var ge=0;ce>ge;ge++)se+=C(K[ge],Z,$+se);else for(var ge=0;ce>ge;ge++){var Se=j[ge];se+=C(Se,Z,$+se),se+=C(K[Se],Z,$+se)}return se}throw new Error("Unknown type "+me)}function R(K){var Z=typeof K;if(Z==="string"){var $=O(K);if(32>$)return 1+$;if(256>$)return 2+$;if(65536>$)return 3+$;if(4294967296>$)return 5+$}if(K instanceof Uint8Array){var $=K.byteLength;if(256>$)return 2+$;if(65536>$)return 3+$;if(4294967296>$)return 5+$}if(Z==="number"){if(Math.floor(K)!==K)return 9;if(K>=0){if(128>K)return 1;if(256>K)return 2;if(65536>K)return 3;if(4294967296>K)return 5;throw new Error("Number too big 0x"+K.toString(16))}if(K>=-32)return 1;if(K>=-128)return 2;if(K>=-32768)return 3;if(K>=-2147483648)return 5;throw new Error("Number too small -0x"+K.toString(16).substr(1))}if(Z==="boolean"||K===null)return 1;if(Z==="object"){var $,me=0;if(Array.isArray(K)){$=K.length;for(var ce=0;$>ce;ce++)me+=R(K[ce])}else{var Me=Object.keys(K);$=Me.length;for(var ce=0;$>ce;ce++){var we=Me[ce];me+=R(we)+R(K[we])}}if(16>$)return 1+me;if(65536>$)return 3+me;if(4294967296>$)return 5+me;throw new Error("Array or object too long 0x"+$.toString(16))}throw new Error("Unknown type "+Z)}function v(K){var Z=new ArrayBuffer(R(K)),$=new DataView(Z);return C(K,$,0),new Uint8Array(Z)}function y(K,Z,$){return Z?new K(Z.buffer,Z.byteOffset,Z.byteLength/($||1)):void 0}function M(K){return y(DataView,K)}function g(K){return y(Uint8Array,K)}function x(K){return y(Int8Array,K)}function _(K){return y(Int32Array,K,4)}function p(K){return y(Float32Array,K,4)}function m(K,Z){var $=K.length/2;Z||(Z=new Int16Array($));for(var me=0,ce=0;$>me;++me,ce+=2)Z[me]=K[ce]<<8^K[ce+1]<<0;return Z}function r(K,Z){var $=K.length;Z||(Z=new Uint8Array(2*$));for(var me=M(Z),ce=0;$>ce;++ce)me.setInt16(2*ce,K[ce]);return g(Z)}function e(K,Z){var $=K.length/4;Z||(Z=new Int32Array($));for(var me=0,ce=0;$>me;++me,ce+=4)Z[me]=K[ce]<<24^K[ce+1]<<16^K[ce+2]<<8^K[ce+3]<<0;return Z}function t(K,Z){var $=K.length;Z||(Z=new Uint8Array(4*$));for(var me=M(Z),ce=0;$>ce;++ce)me.setInt32(4*ce,K[ce]);return g(Z)}function s(K,Z){var $=K.length;Z||(Z=new Float32Array($/4));for(var me=M(Z),ce=M(K),Me=0,we=0,j=$/4;j>Me;++Me,we+=4)me.setFloat32(we,ce.getFloat32(we),!0);return Z}function o(K,Z,$){var me=K.length,ce=1/Z;$||($=new Float32Array(me));for(var Me=0;me>Me;++Me)$[Me]=K[Me]*ce;return $}function l(K,Z,$){var me=K.length;$||($=new Int32Array(me));for(var ce=0;me>ce;++ce)$[ce]=Math.round(K[ce]*Z);return $}function d(K,Z){var $,me;if(!Z){var ce=0;for($=0,me=K.length;me>$;$+=2)ce+=K[$+1];Z=new K.constructor(ce)}var Me=0;for($=0,me=K.length;me>$;$+=2)for(var we=K[$],j=K[$+1],se=0;j>se;++se)Z[Me]=we,++Me;return Z}function i(K){if(K.length===0)return new Int32Array;var Z,$,me=2;for(Z=1,$=K.length;$>Z;++Z)K[Z-1]!==K[Z]&&(me+=2);var ce=new Int32Array(me),Me=0,we=1;for(Z=1,$=K.length;$>Z;++Z)K[Z-1]!==K[Z]?(ce[Me]=K[Z-1],ce[Me+1]=we,we=1,Me+=2):++we;return ce[Me]=K[K.length-1],ce[Me+1]=we,ce}function n(K,Z){var $=K.length;Z||(Z=new K.constructor($)),$&&(Z[0]=K[0]);for(var me=1;$>me;++me)Z[me]=K[me]+Z[me-1];return Z}function a(K,Z){var $=K.length;Z||(Z=new K.constructor($)),Z[0]=K[0];for(var me=1;$>me;++me)Z[me]=K[me]-K[me-1];return Z}function h(K,Z){var $,me,ce=K instanceof Int8Array?127:32767,Me=-ce-1,we=K.length;if(!Z){var j=0;for($=0;we>$;++$)K[$]<ce&&K[$]>Me&&++j;Z=new Int32Array(j)}for($=0,me=0;we>$;){for(var se=0;K[$]===ce||K[$]===Me;)se+=K[$],++$;se+=K[$],++$,Z[me]=se,++me}return Z}function u(K,Z){var $,me=32767,ce=-me-1,Me=K.length,we=0;for($=0;Me>$;++$){var j=K[$];j===0?++we:j>0?(we+=Math.ceil(j/me),j%me===0&&(we+=1)):(we+=Math.ceil(j/ce),j%ce===0&&(we+=1))}var se=Z?new Int8Array(we):new Int16Array(we),ge=0;for($=0;Me>$;++$){var j=K[$];if(j>=0)for(;j>=me;)se[ge]=me,++ge,j-=me;else for(;ce>=j;)se[ge]=ce,++ge,j-=ce;se[ge]=j,++ge}return se}function A(K,Z){return n(d(K),Z)}function D(K){return i(a(K))}function T(K,Z,$){return o(d(K,_($)),Z,$)}function S(K,Z){return i(l(K,Z))}function P(K,Z,$){return o(n(K,_($)),Z,$)}function z(K,Z,$){return a(l(K,Z),$)}function F(K,Z,$){return o(h(K,_($)),Z,$)}function B(K,Z,$){var me=h(K,_($));return P(me,Z,p(me))}function W(K,Z,$){return u(z(K,Z),$)}function U(Me){var Z=M(Me),$=Z.getInt32(0),me=Z.getInt32(4),ce=Me.subarray(8,12),Me=Me.subarray(12);return[$,Me,me,ce]}function I(K,Z,$,me){var ce=new ArrayBuffer(12+me.byteLength),Me=new Uint8Array(ce),we=new DataView(ce);return we.setInt32(0,K),we.setInt32(4,Z),$&&Me.set($,8),Me.set(me,12),Me}function G(K){var Z=K.length,$=g(K);return I(2,Z,void 0,$)}function Y(K){var Z=K.length,$=t(K);return I(4,Z,void 0,$)}function J(K,Z){var $=K.length/Z,me=t([Z]),ce=g(K);return I(5,$,me,ce)}function te(K){var Z=K.length,$=t(i(K));return I(6,Z,void 0,$)}function ne(K){var Z=K.length,$=t(D(K));return I(8,Z,void 0,$)}function le(K,Z){var $=K.length,me=t([Z]),ce=t(S(K,Z));return I(9,$,me,ce)}function ie(K,Z){var $=K.length,me=t([Z]),ce=r(W(K,Z));return I(10,$,me,ce)}function oe(K){var Z={};return Be.forEach(function($){K[$]!==void 0&&(Z[$]=K[$])}),K.bondAtomList&&(Z.bondAtomList=Y(K.bondAtomList)),K.bondOrderList&&(Z.bondOrderList=G(K.bondOrderList)),Z.xCoordList=ie(K.xCoordList,1e3),Z.yCoordList=ie(K.yCoordList,1e3),Z.zCoordList=ie(K.zCoordList,1e3),K.bFactorList&&(Z.bFactorList=ie(K.bFactorList,100)),K.atomIdList&&(Z.atomIdList=ne(K.atomIdList)),K.altLocList&&(Z.altLocList=te(K.altLocList)),K.occupancyList&&(Z.occupancyList=le(K.occupancyList,100)),Z.groupIdList=ne(K.groupIdList),Z.groupTypeList=Y(K.groupTypeList),K.secStructList&&(Z.secStructList=G(K.secStructList)),K.insCodeList&&(Z.insCodeList=te(K.insCodeList)),K.sequenceIndexList&&(Z.sequenceIndexList=ne(K.sequenceIndexList)),Z.chainIdList=J(K.chainIdList,4),K.chainNameList&&(Z.chainNameList=J(K.chainNameList,4)),Z}function xe(K){function Z(se){for(var ge={},Se=0;se>Se;Se++){var re=Me();ge[re]=Me()}return ge}function $(se){var ge=K.subarray(we,we+se);return we+=se,ge}function me(se){var ge=K.subarray(we,we+se);we+=se;var Se=65535;if(se>Se){for(var re=[],be=0;be<ge.length;be+=Se)re.push(String.fromCharCode.apply(null,ge.subarray(be,be+Se)));return re.join("")}return String.fromCharCode.apply(null,ge)}function ce(se){for(var ge=new Array(se),Se=0;se>Se;Se++)ge[Se]=Me();return ge}function Me(){var se,ge,Se=K[we];if((128&Se)===0)return we++,Se;if((240&Se)===128)return ge=15&Se,we++,Z(ge);if((240&Se)===144)return ge=15&Se,we++,ce(ge);if((224&Se)===160)return ge=31&Se,we++,me(ge);if((224&Se)===224)return se=j.getInt8(we),we++,se;switch(Se){case 192:return we++,null;case 194:return we++,!1;case 195:return we++,!0;case 196:return ge=j.getUint8(we+1),we+=2,$(ge);case 197:return ge=j.getUint16(we+1),we+=3,$(ge);case 198:return ge=j.getUint32(we+1),we+=5,$(ge);case 202:return se=j.getFloat32(we+1),we+=5,se;case 203:return se=j.getFloat64(we+1),we+=9,se;case 204:return se=K[we+1],we+=2,se;case 205:return se=j.getUint16(we+1),we+=3,se;case 206:return se=j.getUint32(we+1),we+=5,se;case 208:return se=j.getInt8(we+1),we+=2,se;case 209:return se=j.getInt16(we+1),we+=3,se;case 210:return se=j.getInt32(we+1),we+=5,se;case 217:return ge=j.getUint8(we+1),we+=2,me(ge);case 218:return ge=j.getUint16(we+1),we+=3,me(ge);case 219:return ge=j.getUint32(we+1),we+=5,me(ge);case 220:return ge=j.getUint16(we+1),we+=3,ce(ge);case 221:return ge=j.getUint32(we+1),we+=5,ce(ge);case 222:return ge=j.getUint16(we+1),we+=3,Z(ge);case 223:return ge=j.getUint32(we+1),we+=5,Z(ge)}throw new Error("Unknown type 0x"+Se.toString(16))}var we=0,j=new DataView(K.buffer);return Me()}function _e(K,Z,$,me){switch(K){case 1:return s(Z);case 2:return x(Z);case 3:return m(Z);case 4:return e(Z);case 5:return g(Z);case 6:return d(e(Z),new Uint8Array($));case 7:return d(e(Z));case 8:return A(e(Z));case 9:return T(e(Z),e(me)[0]);case 10:return B(m(Z),e(me)[0]);case 11:return o(m(Z),e(me)[0]);case 12:return F(m(Z),e(me)[0]);case 13:return F(x(Z),e(me)[0]);case 14:return h(m(Z));case 15:return h(x(Z))}}function Oe(K,Z){Z=Z||{};var $=Z.ignoreFields,me={};return ze.forEach(function(ce){var Me=$?$.indexOf(ce)!==-1:!1,we=K[ce];Me||we===void 0||(we instanceof Uint8Array?me[ce]=_e.apply(null,U(we)):me[ce]=we)}),me}function ye(K){return String.fromCharCode.apply(null,K).replace(/\0/g,"")}function ee(K,Z,$){$=$||{};var me,ce,Me,we,j,se,ge=$.firstModelOnly,Se=Z.onModel,re=Z.onChain,be=Z.onGroup,V=Z.onAtom,De=Z.onBond,Le=0,L=0,he=0,fe=0,H=0,ae=-1,ve=K.chainNameList,Ve=K.secStructList,Ne=K.insCodeList,Ge=K.sequenceIndexList,qe=K.atomIdList,_t=K.bFactorList,Ye=K.altLocList,He=K.occupancyList,$e=K.bondAtomList,tt=K.bondOrderList;for(me=0,ce=K.chainsPerModel.length;ce>me&&!(ge&&Le>0);++me){var et=K.chainsPerModel[Le];for(Se&&Se({chainCount:et,modelIndex:Le}),Me=0;et>Me;++Me){var bt=K.groupsPerChain[L];if(re){var xt=ye(K.chainIdList.subarray(4*L,4*L+4)),st=null;ve&&(st=ye(ve.subarray(4*L,4*L+4))),re({groupCount:bt,chainIndex:L,modelIndex:Le,chainId:xt,chainName:st})}for(we=0;bt>we;++we){var lt=K.groupList[K.groupTypeList[he]],dt=lt.atomNameList.length;if(be){var vt=null;Ve&&(vt=Ve[he]);var Mt=null;K.insCodeList&&(Mt=String.fromCharCode(Ne[he]));var At=null;Ge&&(At=Ge[he]),be({atomCount:dt,groupIndex:he,chainIndex:L,modelIndex:Le,groupId:K.groupIdList[he],groupType:K.groupTypeList[he],groupName:lt.groupName,singleLetterCode:lt.singleLetterCode,chemCompType:lt.chemCompType,secStruct:vt,insCode:Mt,sequenceIndex:At})}for(j=0;dt>j;++j){if(V){var Lt=null;qe&&(Lt=qe[fe]);var Ct=null;_t&&(Ct=_t[fe]);var Tt=null;Ye&&(Tt=String.fromCharCode(Ye[fe]));var It=null;He&&(It=He[fe]),V({atomIndex:fe,groupIndex:he,chainIndex:L,modelIndex:Le,atomId:Lt,element:lt.elementList[j],atomName:lt.atomNameList[j],formalCharge:lt.formalChargeList[j],xCoord:K.xCoordList[fe],yCoord:K.yCoordList[fe],zCoord:K.zCoordList[fe],bFactor:Ct,altLoc:Tt,occupancy:It})}fe+=1}if(De){var Bt=lt.bondAtomList;for(j=0,se=lt.bondOrderList.length;se>j;++j)De({atomIndex1:fe-dt+Bt[2*j],atomIndex2:fe-dt+Bt[2*j+1],bondOrder:lt.bondOrderList[j]})}he+=1}L+=1}if(H=ae+1,ae=fe-1,De&&$e)for(j=0,se=$e.length;se>j;j+=2){var Ut=$e[j],Wt=$e[j+1];(Ut>=H&&ae>=Ut||Wt>=H&&ae>=Wt)&&De({atomIndex1:Ut,atomIndex2:Wt,bondOrder:tt?tt[j/2]:null})}Le+=1}}function pe(K){return v(oe(K))}function Ce(K,Z){K instanceof ArrayBuffer&&(K=new Uint8Array(K));var $;return $=K instanceof Uint8Array?xe(K):K,Oe($,Z)}function Te(K,Z,$,me){function ce(){try{var we=Ce(Me.response);$(we)}catch(j){me(j)}}var Me=new XMLHttpRequest;Me.addEventListener("load",ce,!0),Me.addEventListener("error",me,!0),Me.responseType="arraybuffer",Me.open("GET",Z+K.toUpperCase()),Me.send()}function We(K,Z,$){Te(K,je,Z,$)}function Ie(K,Z,$){Te(K,ke,Z,$)}var Be=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],Fe=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],ze=Be.concat(Fe),Pe="v1.0.1",Re="//mmtf.rcsb.org/v1.0/",je=Re+"full/",ke=Re+"reduced/";c.encode=pe,c.decode=Ce,c.traverse=ee,c.fetch=We,c.fetchReduced=Ie,c.version=Pe,c.fetchUrl=je,c.fetchReducedUrl=ke,c.encodeMsgpack=v,c.encodeMmtf=oe,c.decodeMsgpack=xe,c.decodeMmtf=Oe})}},__webpack_module_cache__={};function __webpack_require__(k){var w=__webpack_module_cache__[k];if(w!==void 0)return w.exports;if(__webpack_modules__[k]===void 0){var c=new Error("Cannot find module '"+k+"'");throw c.code="MODULE_NOT_FOUND",c}var b=__webpack_module_cache__[k]={exports:{}};return __webpack_modules__[k].call(b.exports,b,b.exports,__webpack_require__),b.exports}__webpack_require__.n=k=>{var w=k&&k.__esModule?()=>k.default:()=>k;return __webpack_require__.d(w,{a:w}),w},__webpack_require__.d=(k,w)=>{for(var c in w)__webpack_require__.o(w,c)&&!__webpack_require__.o(k,c)&&Object.defineProperty(k,c,{enumerable:!0,get:w[c]})},__webpack_require__.o=(k,w)=>Object.prototype.hasOwnProperty.call(k,w),__webpack_require__.r=k=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(k,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(k,"__esModule",{value:!0})},__webpack_require__("./src/index.ts"),__webpack_require__("./src/SurfaceWorker.js");var __webpack_exports__=__webpack_require__("./src/exporter.js");return __webpack_exports__})())})(_3Dmol$1)),_3Dmol$1.exports}var _3DmolExports=require_3Dmol();const supportedMoleculeFormats=["xyz","extxyz","cif","pdb"];new Set(supportedMoleculeFormats);function normalizeFormat(k){const w=k==null?void 0:k.trim().toLowerCase();return!w||w==="extxyz"?"xyz":w}function splitXyzTrajectory(k){var O,C;const w=k.replace(/\r\n/g,`
|
|
1698
|
+
`).replace(/\r/g,`
|
|
1699
|
+
`).split(`
|
|
1700
|
+
`),c=[];let b=0;for(;b<w.length;){for(;b<w.length&&((O=w[b])==null?void 0:O.trim())==="";)b+=1;if(b>=w.length)break;const R=Number.parseInt(((C=w[b])==null?void 0:C.trim())??"",10);if(!Number.isFinite(R)||R<0)return[k];const v=R+2;if(b+v>w.length)return[k];c.push(`${w.slice(b,b+v).join(`
|
|
1701
|
+
`)}
|
|
1702
|
+
`),b+=v}return c.length>0?c:[k]}function normalizeSnapshotFrames(k,w){return w!=="xyz"?k:k.flatMap(c=>splitXyzTrajectory(c))}function joinFramesForExport(k){return k.map(w=>`${w.replace(/\s+$/g,"")}
|
|
1703
|
+
`).join("")}function readMoleculeViewerData(k){if(!k)return{format:"xyz",frames:[],exportContent:""};if(typeof k=="string"){const b=normalizeSnapshotFrames([k],"xyz");return{frames:b,format:"xyz",exportContent:joinFramesForExport(b)}}const w=normalizeFormat(k.format),c=k.content.filter(b=>b.trim().length>0);return{frames:normalizeSnapshotFrames(c,w),format:w,exportContent:joinFramesForExport(c)}}function hasWebGLSupport(){try{const k=document.createElement("canvas");return!!(k.getContext("webgl2")||k.getContext("webgl")||k.getContext("experimental-webgl"))}catch{return!1}}function downloadTextFile(k,w){const c=new Blob([k],{type:"text/plain"}),b=URL.createObjectURL(c),O=document.createElement("a");O.href=b,O.download=w,O.click(),URL.revokeObjectURL(b)}function moleculeSlug(k){return(k==null?void 0:k.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function XyzMoleculeViewer({source:k,moleculeId:w=null,title:c="Molecule Viewer",className:b="",screenshotRequestId:O=null,onScreenshot:C,onSelectionChange:R}){const v=reactExports.useRef(null),y=reactExports.useRef(null),M=reactExports.useRef(null),g=reactExports.useRef(!1),x=reactExports.useRef(!0),[_,p]=reactExports.useState(null),[m,r]=reactExports.useState(0),[e,t]=reactExports.useState(!1),[s,o]=reactExports.useState([]),[l,d]=reactExports.useState([]),[i,n]=reactExports.useState(null),[a,h]=reactExports.useState(null),[u,A]=reactExports.useState(!1),[D,T]=reactExports.useState(!1),S=reactExports.useMemo(()=>readMoleculeViewerData(k),[k]),P=S.frames,z=P[m]??"",F=moleculeSlug(w),B=P.length>0&&m===P.length-1;reactExports.useEffect(()=>{if(P.length===0){r(0);return}r(P.length-1)},[P.length]),reactExports.useEffect(()=>{if(!e||P.length<=1)return;const G=window.setInterval(()=>{r(Y=>Y>=P.length-1?(window.clearInterval(G),t(!1),Y):Y+1)},200);return()=>window.clearInterval(G)},[P.length,e]),reactExports.useEffect(()=>{const G=v.current;if(!G||y.current)return;if(!hasWebGLSupport()){p("WebGL is unavailable in this browser environment. Unable to render the 3D viewer.");return}try{const J=_3DmolExports.createViewer(G,{});y.current=J,J.setBackgroundColor("#fbfbfb",1)}catch(J){console.error("Failed to initialize 3Dmol viewer:",J),p("Failed to initialize the 3D molecule viewer.");return}const Y=()=>{var J,te;(J=y.current)==null||J.resize(),(te=y.current)==null||te.render()};return window.addEventListener("resize",Y),window.setTimeout(Y,100),()=>{window.removeEventListener("resize",Y),y.current=null,M.current=null}},[]),reactExports.useEffect(()=>{const G=y.current;if(!(!G||!z))try{G.removeAllModels(),G.removeAllShapes(),G.removeAllLabels();const Y=G.addModel(z,S.format);M.current=Y,Y.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const J=Y.getCrystData(),te=!!(J&&typeof J=="object"&&Object.keys(J).length>0);T(te),A(te?x.current:!1);const ne=z.split(`
|
|
1704
|
+
`).slice(2).map(le=>le.trim()).filter(Boolean).map(le=>le.split(/\s+/)[0]??"Atom");d(ne),o([]),g.current||(G.zoomTo(),g.current=!0),Y.setClickable({},!0,(le,ie,oe)=>{const xe=le.serial??le.index;xe!==void 0&&o(_e=>!(oe!=null&&oe.shiftKey||oe!=null&&oe.metaKey||oe!=null&&oe.ctrlKey)?_e.length===1&&_e[0]===xe?[]:[xe]:_e.includes(xe)?_e.filter(ye=>ye!==xe):[..._e,xe])}),Y.setHoverable({},!0,(le,ie,oe)=>{oe&&n({x:oe.clientX,y:oe.clientY,label:`${le.atom||le.elem||"Atom"} (${le.serial??le.index??"?"})`,coords:{x:le.x.toFixed(2),y:le.y.toFixed(2),z:le.z.toFixed(2)}})},()=>n(null)),G.render()}catch(Y){console.error("Failed to render molecule:",Y),p("Unable to render this molecular structure.")}},[z,S.format]),reactExports.useEffect(()=>{const G=y.current,Y=M.current;if(!(!G||!Y)){try{G.removeUnitCell(Y)}catch{}if(u&&D)try{G.addUnitCell(Y,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{T(!1),A(!1)}G.render()}},[D,u,z]),reactExports.useEffect(()=>{const G=y.current,Y=M.current;!G||!Y||!z||(Y.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),s.length>0&&Y.setStyle({serial:s},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),G.render(),R==null||R({moleculeId:w,atoms:s}))},[z,w,R,s]),reactExports.useEffect(()=>{if(!z)return;let G=0;const Y=()=>{var te,ne;const J=(ne=(te=y.current)==null?void 0:te.getView)==null?void 0:ne.call(te);if(Array.isArray(J)&&J.length>=8){const[le,ie,oe,xe,_e,Oe,ye,ee]=J;typeof le=="number"&&typeof ie=="number"&&typeof oe=="number"&&typeof xe=="number"&&typeof _e=="number"&&typeof Oe=="number"&&typeof ye=="number"&&typeof ee=="number"&&h({x:le,y:ie,z:oe,zoom:xe,qx:_e,qy:Oe,qz:ye,qw:ee})}G=window.requestAnimationFrame(Y)};return G=window.requestAnimationFrame(Y),()=>window.cancelAnimationFrame(G)},[z]);const W=reactExports.useCallback(async()=>{z&&await navigator.clipboard.writeText(z)},[z]),U=reactExports.useCallback(async()=>{const G=y.current;if(!(G!=null&&G.pngURI))return;G.render();const Y=G.pngURI();if(Y){try{const te=await(await fetch(Y)).blob(),ne={[te.type||"image/png"]:te},le=new ClipboardItem(ne);await navigator.clipboard.write([le])}catch{}C==null||C({moleculeId:w,image:Y})}},[w,C]);reactExports.useEffect(()=>{O&&U()},[U,O]);const I=reactExports.useCallback(()=>{const G=y.current;G&&(G.zoomTo(),G.setCameraParameters({}),G.render())},[]);return jsxRuntimeExports.jsxs("div",{className:`xyz-viewer-plugin ${b}`,children:[jsxRuntimeExports.jsxs("header",{className:"xyz-viewer-plugin__header",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h2",{children:c}),jsxRuntimeExports.jsxs("p",{children:[S.format.toUpperCase()," structure preview"]})]}),jsxRuntimeExports.jsx("span",{children:P.length>1?`${P.length} frames`:"single frame"})]}),jsxRuntimeExports.jsxs("div",{className:"xyz-viewer-plugin__toolbar","aria-label":"Molecule controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:W,disabled:!z,title:"Copy current frame",children:jsxRuntimeExports.jsx(lucideReactExports.Copy,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>downloadTextFile(z,`${F}_frame_${m+1}.${S.format}`),disabled:!z,title:"Download current frame",children:jsxRuntimeExports.jsx(lucideReactExports.Download,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>downloadTextFile(S.exportContent,`${F}_trajectory.${S.format}`),disabled:!S.exportContent,title:"Download all frames",children:jsxRuntimeExports.jsx(lucideReactExports.Box,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:U,disabled:!z,title:"Capture screenshot",children:jsxRuntimeExports.jsx(lucideReactExports.Camera,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("span",{className:"xyz-viewer-plugin__toolbar-divider","aria-hidden":"true"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{var G;return(G=y.current)==null?void 0:G.zoom(1.2)},disabled:!z,title:"Zoom in",children:jsxRuntimeExports.jsx(lucideReactExports.ZoomIn,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{var G;return(G=y.current)==null?void 0:G.zoom(.8)},disabled:!z,title:"Zoom out",children:jsxRuntimeExports.jsx(lucideReactExports.ZoomOut,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:I,disabled:!z,title:"Reset camera",children:jsxRuntimeExports.jsx(lucideReactExports.RotateCcw,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>A(G=>{const Y=!G;return x.current=Y,Y}),disabled:!D,title:u?"Hide unit cell":"Show unit cell",children:jsxRuntimeExports.jsx(lucideReactExports.Boxes,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>o([]),disabled:s.length===0,title:"Clear selection",children:jsxRuntimeExports.jsx(lucideReactExports.Trash2,{"aria-hidden":"true"})})]}),jsxRuntimeExports.jsxs("div",{className:"xyz-viewer-plugin__stage",children:[jsxRuntimeExports.jsx("div",{ref:v,className:"xyz-viewer-plugin__canvas"}),_&&jsxRuntimeExports.jsx("div",{className:"xyz-viewer-plugin__error",children:_}),!_&&!z&&jsxRuntimeExports.jsx("div",{className:"xyz-viewer-plugin__empty",children:"No molecule data available."}),i&&jsxRuntimeExports.jsxs("div",{className:"xyz-viewer-plugin__tooltip",style:{left:i.x-20,top:i.y-50},children:[jsxRuntimeExports.jsx("strong",{children:i.label}),jsxRuntimeExports.jsxs("span",{children:["x: ",i.coords.x," y: ",i.coords.y," z:"," ",i.coords.z]})]})]}),P.length>1&&jsxRuntimeExports.jsxs("div",{className:"xyz-viewer-plugin__timeline",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{t(G=>{const Y=!G;return Y&&m===P.length-1&&r(0),Y})},title:e?"Pause trajectory":"Play trajectory",children:e&&m!==P.length-1?jsxRuntimeExports.jsx(lucideReactExports.Pause,{"aria-hidden":"true"}):jsxRuntimeExports.jsx(lucideReactExports.Play,{"aria-hidden":"true"})}),jsxRuntimeExports.jsx("input",{type:"range",min:0,max:P.length-1,step:1,value:m,onChange:G=>r(Number(G.currentTarget.value)),"aria-label":"Trajectory frame"}),jsxRuntimeExports.jsx("button",{type:"button",className:B?"is-live":"",onClick:()=>r(P.length-1),children:"Live"}),jsxRuntimeExports.jsxs("span",{children:[m+1," / ",P.length]})]}),jsxRuntimeExports.jsxs("footer",{className:"xyz-viewer-plugin__status",children:[jsxRuntimeExports.jsxs("span",{children:["Selected atoms:"," ",s.length>0?s.map(G=>`${l[G]??"Atom"}(${G})`).join(", "):"None"]}),a&&jsxRuntimeExports.jsxs("span",{children:["Camera x=",a.x.toFixed(1)," y=",a.y.toFixed(1)," z=",a.z.toFixed(1)]})]})]})}export{XyzMoleculeViewer};
|