@onescience/onecode-web 1.14.50-202609020932 → 1.14.50-202609031600
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/assets/3Dmol-CcTSgS_I.js +1697 -0
- package/assets/{account-system-CdLg3pKW.js → account-system-DRcY1oD1.js} +1 -1
- package/assets/{alert-05-Bl8njajc.js → alert-01-CPXWs6nf.js} +1 -1
- package/assets/{alert-01-BOoRj25G.js → alert-02-DI1DD_3d.js} +1 -1
- package/assets/{alert-02-Bkr1qirU.js → alert-04-Db4ZS6xF.js} +1 -1
- package/assets/{alert-04-Cntc_GD0.js → alert-05-BrjFsUk3.js} +1 -1
- package/assets/alert-06-CBhGhcW9.js +1 -0
- package/assets/alert-07-BiN6DBuL.js +1 -0
- package/assets/alert-08-pH5OhsOk.js +1 -0
- package/assets/alert-10-kyJVFv2A.js +1 -0
- package/assets/{bip-bop-03-uhYGDH17.js → bip-bop-03-CYdvX8k_.js} +1 -1
- package/assets/{bip-bop-04-Bh4cNFTB.js → bip-bop-04-KJbD4lUd.js} +1 -1
- package/assets/{bip-bop-06-Cw-vGoPK.js → bip-bop-06-Cc85gIuq.js} +1 -1
- package/assets/{bip-bop-08-CmxH5qOK.js → bip-bop-08-DQAl-h9L.js} +1 -1
- package/assets/bip-bop-09-C5SnVe_l.js +1 -0
- package/assets/center-Cp7MBrmk.js +1 -0
- package/assets/{dialog-edit-project-DK9kgMU9.js → dialog-edit-project-TXt8WU1J.js} +1 -1
- package/assets/{dialog-fork-BQprfhHP.js → dialog-fork-fs_cIK4A.js} +1 -1
- package/assets/{dialog-project-upload-bq54ULi_.js → dialog-project-upload-B8QKyumt.js} +2 -2
- package/assets/{dialog-select-file-BIwldBl-.js → dialog-select-file-CfgzSPbz.js} +1 -1
- package/assets/{dialog-select-model-PdGraPN8.js → dialog-select-model-C8p6HIH2.js} +2 -2
- package/assets/{dialog-terminal-unavailable-DjjbI2FV.js → dialog-terminal-unavailable-BPf6D9pa.js} +3 -3
- package/assets/{docs-CGjz1sDz.js → docs-BW2dQfrB.js} +1 -1
- package/assets/{ghostty-web-CW4JZJ_z.js → ghostty-web-CbT7vRAF.js} +1 -1
- package/assets/home-v-RyEJXO.js +1 -0
- package/assets/index-Cxa2Vk80.js +2774 -0
- package/assets/{index-Bpc6ia3z.css → index-q70uwQje.css} +1 -1
- package/assets/intro-BwCcm56A.js +1 -0
- package/assets/{nope-02-BejrPVJn.js → nope-02-CEsZCG3w.js} +1 -1
- package/assets/{nope-05-B6HACZcF.js → nope-05-BpK9LKjZ.js} +1 -1
- package/assets/{nope-08-CUZdkhuT.js → nope-08-D-5nAWNU.js} +1 -1
- package/assets/{nope-11-HqRoevb2.js → nope-11-COnsf8VE.js} +1 -1
- package/assets/nope-12-UlwuxqTc.js +1 -0
- package/assets/{onescience-BpKf7M0Q.js → onescience-DBtZsoEm.js} +27 -27
- package/assets/{onescience-skill-detail-dialog-CPXWVuLj.js → onescience-skill-detail-dialog-C23957tN.js} +1 -1
- package/assets/{resources-CMhdiU1T.js → resources-C7NB-V9a.js} +2 -2
- package/assets/shell-Bex4QMb_.js +2 -0
- package/assets/skills-BgxyM9mc.js +1 -0
- package/assets/{staplebops-03-BFNSaaN1.js → staplebops-03-DSwM4GRQ.js} +1 -1
- package/assets/{staplebops-04-C1lCJhbW.js → staplebops-04-ze2zihJz.js} +1 -1
- package/assets/{staplebops-06-Cj3ptVIB.js → staplebops-06-BJVX7hv9.js} +1 -1
- package/assets/{staplebops-07-BbrHCuYa.js → staplebops-07-B3Bn5VQK.js} +1 -1
- package/assets/{status-popover-body-DIJtSAoV.js → status-popover-body-BhWWbkYJ.js} +2 -2
- package/assets/wizard-BQDxCspK.js +1 -0
- package/assets/{yup-01-CZlscUiz.js → yup-01-Ctxq7OVz.js} +1 -1
- package/assets/{yup-03-_cQ6zYSx.js → yup-03-C8Lemx9x.js} +1 -1
- package/assets/{yup-04-Dy9AqZzo.js → yup-04-tKpnqLFc.js} +1 -1
- package/assets/{yup-05-WrE2LRAl.js → yup-05-ByOdNO_N.js} +1 -1
- package/assets/{zh-Dqvial9G.js → zh-hGVdj13G.js} +1 -1
- package/index.html +11 -11
- package/package.json +2 -2
- package/assets/alert-06-DKcTO8SC.js +0 -1
- package/assets/alert-07-DuaaPhy4.js +0 -1
- package/assets/alert-08-Db7RcnOO.js +0 -1
- package/assets/alert-10-CWJZrK2o.js +0 -1
- package/assets/bip-bop-09-Tl9LULYQ.js +0 -1
- package/assets/catalog-Cz3JtNfO.js +0 -273
- package/assets/center-DbXC0qGn.js +0 -1
- package/assets/home-AeX4sJBp.js +0 -1
- package/assets/index-BA1jwG_A.js +0 -2494
- package/assets/intro-CaWNHH2V.js +0 -1
- package/assets/nope-12-CjOQ8jCx.js +0 -1
- package/assets/shell-BH0laPPE.js +0 -2
- package/assets/skills-Dsu1SSpr.js +0 -1
- package/assets/wizard-BsJBhDp_.js +0 -1
|
@@ -0,0 +1,1697 @@
|
|
|
1
|
+
import{e8 as getDefaultExportFromCjs}from"./index-Cxa2Vk80.js";function _mergeNamespaces(K,D){for(var c=0;c<D.length;c++){const y=D[c];if(typeof y!="string"&&!Array.isArray(y)){for(const O in y)if(O!=="default"&&!(O in K)){const w=Object.getOwnPropertyDescriptor(y,O);w&&Object.defineProperty(K,O,w.get?w:{enumerable:!0,get:()=>y[O]})}}}return Object.freeze(Object.defineProperty(K,Symbol.toStringTag,{value:"Module"}))}var _3Dmol$3={exports:{}};/*!
|
|
2
|
+
* 3dmol v2.5.5
|
|
3
|
+
* JavaScript/TypeScript molecular visualization library
|
|
4
|
+
* Author: David Koes and contributors
|
|
5
|
+
*/var _3Dmol$2=_3Dmol$3.exports,hasRequired_3Dmol;function require_3Dmol(){return hasRequired_3Dmol||(hasRequired_3Dmol=1,(function(module,exports$1){(function(D,c){module.exports=c()})(_3Dmol$2,()=>(()=>{var __webpack_modules__={"./node_modules/iobuffer/lib-esm/IOBuffer.js"(K,D,c){c.r(D),c.d(D,{IOBuffer:()=>p});var y=c("./node_modules/iobuffer/lib-esm/text.js");const O=1024*8,w=(()=>{const E=new Uint8Array(4),M=new Uint32Array(E.buffer);return!((M[0]=1)&E[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 p{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(M=O,g={}){let x=!1;typeof M=="number"?M=new ArrayBuffer(M):(x=!0,this.lastWrittenByte=M.byteLength);const _=g.offset?g.offset>>>0:0,v=M.byteLength-_;let m=_;(ArrayBuffer.isView(M)||M instanceof p)&&(M.byteLength!==M.buffer.byteLength&&(m=M.byteOffset+_),M=M.buffer),x?this.lastWrittenByte=v:this.lastWrittenByte=0,this.buffer=M,this.length=v,this.byteLength=v,this.byteOffset=m,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,m,v),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,v=this.buffer.slice(_,_+x);if(this.littleEndian===w&&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](v);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,y.decode)(this.readBytes(M))}decodeText(M=1,g="utf8"){return(0,y.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,y.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,D,c){c.r(D),c.d(D,{decode:()=>y,encode:()=>w});function y(R,p="utf8"){return new TextDecoder(p).decode(R)}const O=new TextEncoder;function w(R){return O.encode(R)}},"./node_modules/netcdfjs/lib-esm/data.js"(K,D,c){c.r(D),c.d(D,{nonRecord:()=>O,record:()=>w});var y=c("./node_modules/netcdfjs/lib-esm/types.js");function O(R,p){const E=(0,y.str2num)(p.type),M=p.size/(0,y.num2bytes)(E),g=new Array(M);for(let x=0;x<M;x++)g[x]=(0,y.readType)(R,E,1);return g}function w(R,p,E){const M=(0,y.str2num)(p.type),g=p.size?p.size/(0,y.num2bytes)(M):1,x=E.length,_=new Array(x),v=E.recordStep;if(v)for(let m=0;m<x;m++){const r=R.offset;_[m]=(0,y.readType)(R,M,g),R.seek(r+v)}else throw new Error("recordDimension.recordStep is undefined");return _}},"./node_modules/netcdfjs/lib-esm/header.js"(K,D,c){c.r(D),c.d(D,{header:()=>g});var y=c("./node_modules/netcdfjs/lib-esm/types.js"),O=c("./node_modules/netcdfjs/lib-esm/utils.js");const w=0,R=10,p=11,E=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=v(m,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===w)return(0,O.notNetcdf)(m.readUint32()!==w,"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===w)return(0,O.notNetcdf)(m.readUint32()!==w,"wrong empty tag for list of attributes"),[];{(0,O.notNetcdf)(r!==E,"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,y.readType)(m,l,d);(0,O.padding)(m),e[s]={name:o,type:(0,y.num2str)(l),value:i}}}return e}function v(m,r,e){const t=m.readUint32();let s=0,o;if(t===w)return(0,O.notNetcdf)(m.readUint32()!==w,"wrong empty tag for list of variables"),[];{(0,O.notNetcdf)(t!==p,"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 L=m.readUint32();e===2&&((0,O.notNetcdf)(L>0,"offsets larger than 4GB not supported"),L=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,y.num2str)(u),size:A,offset:L,record:T}}}return{variables:o,recordStep:s}}},"./node_modules/netcdfjs/lib-esm/index.js"(K,D,c){c.r(D),c.d(D,{NetCDFReader:()=>y.NetCDFReader});var y=c("./node_modules/netcdfjs/lib-esm/parser.js")},"./node_modules/netcdfjs/lib-esm/parser.js"(K,D,c){c.r(D),c.d(D,{NetCDFReader:()=>E});var y=c("./node_modules/iobuffer/lib-esm/IOBuffer.js"),O=c("./node_modules/netcdfjs/lib-esm/data.js"),w=c("./node_modules/netcdfjs/lib-esm/header.js"),R=c("./node_modules/netcdfjs/lib-esm/toString.js"),p=c("./node_modules/netcdfjs/lib-esm/utils.js");class E{constructor(g){this.toString=R.toString;const x=new y.IOBuffer(g);x.setBigEndian(),(0,p.notNetcdf)(x.readChars(3)!=="CDF","should start with CDF");const _=x.readByte();(0,p.notNetcdf)(_>2,"unknown version"),this.header=(0,w.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,D,c){c.r(D),c.d(D,{toString:()=>y});function y(){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 w=JSON.parse(JSON.stringify(this.variables));O.push(""),O.push("VARIABLES:");for(const R of w){R.value=this.getDataVariable(R);let p=JSON.stringify(R.value);p.length>50&&(p=p.substring(0,50)),isNaN(R.value.length)||(p+=` (length: ${R.value.length})`),O.push(` ${R.name.padEnd(30)} = ${p}`)}return O.join(`
|
|
6
|
+
`)}},"./node_modules/netcdfjs/lib-esm/types.js"(K,D,c){c.r(D),c.d(D,{num2bytes:()=>w,num2str:()=>O,readType:()=>E,str2num:()=>R});const y={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function O(g){switch(Number(g)){case y.BYTE:return"byte";case y.CHAR:return"char";case y.SHORT:return"short";case y.INT:return"int";case y.FLOAT:return"float";case y.DOUBLE:return"double";default:return"undefined"}}function w(g){switch(Number(g)){case y.BYTE:return 1;case y.CHAR:return 1;case y.SHORT:return 2;case y.INT:return 4;case y.FLOAT:return 4;case y.DOUBLE:return 8;default:return-1}}function R(g){switch(String(g)){case"byte":return y.BYTE;case"char":return y.CHAR;case"short":return y.SHORT;case"int":return y.INT;case"float":return y.FLOAT;case"double":return y.DOUBLE;default:return-1}}function p(g,x){if(g!==1){const _=new Array(g);for(let v=0;v<g;v++)_[v]=x();return _}else return x()}function E(g,x,_){switch(x){case y.BYTE:return Array.from(g.readBytes(_));case y.CHAR:return M(g.readChars(_));case y.SHORT:return p(_,g.readInt16.bind(g));case y.INT:return p(_,g.readInt32.bind(g));case y.FLOAT:return p(_,g.readFloat32.bind(g));case y.DOUBLE:return p(_,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,D,c){c.r(D),c.d(D,{notNetcdf:()=>y,padding:()=>O,readName:()=>w});function y(R,p){if(R)throw new TypeError(`Not a valid NetCDF v3.x file: ${p}`)}function O(R){R.offset%4!==0&&R.skip(4-R.offset%4)}function w(R){const p=R.readUint32(),E=R.readChars(p);return O(R),E}},"./node_modules/pako/dist/pako.esm.mjs"(K,D,c){c.r(D),c.d(D,{Deflate:()=>Wr,Inflate:()=>jr,constants:()=>Zr,default:()=>Gs,deflate:()=>Gr,deflateRaw:()=>Nr,gzip:()=>Vr,inflate:()=>kr,inflateRaw:()=>Hr,ungzip:()=>Kr});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const y=4,O=0,w=1,R=2;function p(f){let G=f.length;for(;--G>=0;)f[G]=0}const E=0,M=1,g=2,x=3,_=258,v=29,m=256,r=m+1+v,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]),L=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,I=new Array((r+2)*2);p(I);const z=new Array(e*2);p(z);const B=new Array(S);p(B);const F=new Array(_-x+1);p(F);const W=new Array(v);p(W);const U=new Array(e);p(U);function P(f,G,b,X,Q){this.static_tree=f,this.extra_bits=G,this.extra_base=b,this.elems=X,this.max_length=Q,this.has_stree=f&&f.length}let N,q,ee;function ie(f,G){this.dyn_tree=f,this.max_code=0,this.stat_desc=G}const ne=f=>f<256?B[f]:B[256+(f>>>7)],de=(f,G)=>{f.pending_buf[f.pending++]=G&255,f.pending_buf[f.pending++]=G>>>8&255},re=(f,G,b)=>{f.bi_valid>l-b?(f.bi_buf|=G<<f.bi_valid&65535,de(f,f.bi_buf),f.bi_buf=G>>l-f.bi_valid,f.bi_valid+=b-l):(f.bi_buf|=G<<f.bi_valid&65535,f.bi_valid+=b)},oe=(f,G,b)=>{re(f,b[G*2],b[G*2+1])},be=(f,G)=>{let b=0;do b|=f&1,f>>>=1,b<<=1;while(--G>0);return b>>>1},_e=f=>{f.bi_valid===16?(de(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,G)=>{const b=G.dyn_tree,X=G.max_code,Q=G.stat_desc.static_tree,$=G.stat_desc.has_stree,ye=G.stat_desc.extra_bits,ue=G.stat_desc.extra_base,Xe=G.stat_desc.max_length;let fe,Ee,ct,Ze,Ue,Qe,Et=0;for(Ze=0;Ze<=o;Ze++)f.bl_count[Ze]=0;for(b[f.heap[f.heap_max]*2+1]=0,fe=f.heap_max+1;fe<s;fe++)Ee=f.heap[fe],Ze=b[b[Ee*2+1]*2+1]+1,Ze>Xe&&(Ze=Xe,Et++),b[Ee*2+1]=Ze,!(Ee>X)&&(f.bl_count[Ze]++,Ue=0,Ee>=ue&&(Ue=ye[Ee-ue]),Qe=b[Ee*2],f.opt_len+=Qe*(Ze+Ue),$&&(f.static_len+=Qe*(Q[Ee*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(Ee=f.bl_count[Ze];Ee!==0;)ct=f.heap[--fe],!(ct>X)&&(b[ct*2+1]!==Ze&&(f.opt_len+=(Ze-b[ct*2+1])*b[ct*2],b[ct*2+1]=Ze),Ee--)}},Me=(f,G,b)=>{const X=new Array(o+1);let Q=0,$,ye;for($=1;$<=o;$++)Q=Q+b[$-1]<<1,X[$]=Q;for(ye=0;ye<=G;ye++){let ue=f[ye*2+1];ue!==0&&(f[ye*2]=be(X[ue]++,ue))}},J=()=>{let f,G,b,X,Q;const $=new Array(o+1);for(b=0,X=0;X<v-1;X++)for(W[X]=b,f=0;f<1<<u[X];f++)F[b++]=X;for(F[b-1]=X,Q=0,X=0;X<16;X++)for(U[X]=Q,f=0;f<1<<A[X];f++)B[Q++]=X;for(Q>>=7;X<e;X++)for(U[X]=Q<<7,f=0;f<1<<A[X]-7;f++)B[256+Q++]=X;for(G=0;G<=o;G++)$[G]=0;for(f=0;f<=143;)I[f*2+1]=8,f++,$[8]++;for(;f<=255;)I[f*2+1]=9,f++,$[9]++;for(;f<=279;)I[f*2+1]=7,f++,$[7]++;for(;f<=287;)I[f*2+1]=8,f++,$[8]++;for(Me(I,r+1,$),f=0;f<e;f++)z[f*2+1]=5,z[f*2]=be(f,5);N=new P(I,u,m+1,r,o),q=new P(z,A,0,e,o),ee=new P(new Array(0),L,0,t,d)},ve=f=>{let G;for(G=0;G<r;G++)f.dyn_ltree[G*2]=0;for(G=0;G<e;G++)f.dyn_dtree[G*2]=0;for(G=0;G<t;G++)f.bl_tree[G*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?de(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,G,b,X)=>{const Q=G*2,$=b*2;return f[Q]<f[$]||f[Q]===f[$]&&X[G]<=X[b]},We=(f,G,b)=>{const X=f.heap[b];let Q=b<<1;for(;Q<=f.heap_len&&(Q<f.heap_len&&Te(G,f.heap[Q+1],f.heap[Q],f.depth)&&Q++,!Te(G,X,f.heap[Q],f.depth));)f.heap[b]=f.heap[Q],b=Q,Q<<=1;f.heap[b]=X},Ie=(f,G,b)=>{let X,Q,$=0,ye,ue;if(f.sym_next!==0)do X=f.pending_buf[f.sym_buf+$++]&255,X+=(f.pending_buf[f.sym_buf+$++]&255)<<8,Q=f.pending_buf[f.sym_buf+$++],X===0?oe(f,Q,G):(ye=F[Q],oe(f,ye+m+1,G),ue=u[ye],ue!==0&&(Q-=W[ye],re(f,Q,ue)),X--,ye=ne(X),oe(f,ye,b),ue=A[ye],ue!==0&&(X-=U[ye],re(f,X,ue)));while($<f.sym_next);oe(f,i,G)},Fe=(f,G)=>{const b=G.dyn_tree,X=G.stat_desc.static_tree,Q=G.stat_desc.has_stree,$=G.stat_desc.elems;let ye,ue,Xe=-1,fe;for(f.heap_len=0,f.heap_max=s,ye=0;ye<$;ye++)b[ye*2]!==0?(f.heap[++f.heap_len]=Xe=ye,f.depth[ye]=0):b[ye*2+1]=0;for(;f.heap_len<2;)fe=f.heap[++f.heap_len]=Xe<2?++Xe:0,b[fe*2]=1,f.depth[fe]=0,f.opt_len--,Q&&(f.static_len-=X[fe*2+1]);for(G.max_code=Xe,ye=f.heap_len>>1;ye>=1;ye--)We(f,b,ye);fe=$;do ye=f.heap[1],f.heap[1]=f.heap[f.heap_len--],We(f,b,1),ue=f.heap[1],f.heap[--f.heap_max]=ye,f.heap[--f.heap_max]=ue,b[fe*2]=b[ye*2]+b[ue*2],f.depth[fe]=(f.depth[ye]>=f.depth[ue]?f.depth[ye]:f.depth[ue])+1,b[ye*2+1]=b[ue*2+1]=fe,f.heap[1]=fe++,We(f,b,1);while(f.heap_len>=2);f.heap[--f.heap_max]=f.heap[1],Oe(f,G),Me(b,Xe,f.bl_count)},Be=(f,G,b)=>{let X,Q=-1,$,ye=G[1],ue=0,Xe=7,fe=4;for(ye===0&&(Xe=138,fe=3),G[(b+1)*2+1]=65535,X=0;X<=b;X++)$=ye,ye=G[(X+1)*2+1],!(++ue<Xe&&$===ye)&&(ue<fe?f.bl_tree[$*2]+=ue:$!==0?($!==Q&&f.bl_tree[$*2]++,f.bl_tree[n*2]++):ue<=10?f.bl_tree[a*2]++:f.bl_tree[h*2]++,ue=0,Q=$,ye===0?(Xe=138,fe=3):$===ye?(Xe=6,fe=3):(Xe=7,fe=4))},ze=(f,G,b)=>{let X,Q=-1,$,ye=G[1],ue=0,Xe=7,fe=4;for(ye===0&&(Xe=138,fe=3),X=0;X<=b;X++)if($=ye,ye=G[(X+1)*2+1],!(++ue<Xe&&$===ye)){if(ue<fe)do oe(f,$,f.bl_tree);while(--ue!==0);else $!==0?($!==Q&&(oe(f,$,f.bl_tree),ue--),oe(f,n,f.bl_tree),re(f,ue-3,2)):ue<=10?(oe(f,a,f.bl_tree),re(f,ue-3,3)):(oe(f,h,f.bl_tree),re(f,ue-11,7));ue=0,Q=$,ye===0?(Xe=138,fe=3):$===ye?(Xe=6,fe=3):(Xe=7,fe=4)}},Re=f=>{let G;for(Be(f,f.dyn_ltree,f.l_desc.max_code),Be(f,f.dyn_dtree,f.d_desc.max_code),Fe(f,f.bl_desc),G=t-1;G>=3&&f.bl_tree[T[G]*2+1]===0;G--);return f.opt_len+=3*(G+1)+5+5+4,G},Pe=(f,G,b,X)=>{let Q;for(re(f,G-257,5),re(f,b-1,5),re(f,X-4,4),Q=0;Q<X;Q++)re(f,f.bl_tree[T[Q]*2+1],3);ze(f,f.dyn_ltree,G-1),ze(f,f.dyn_dtree,b-1)},je=f=>{let G=4093624447,b;for(b=0;b<=31;b++,G>>>=1)if(G&1&&f.dyn_ltree[b*2]!==0)return O;if(f.dyn_ltree[18]!==0||f.dyn_ltree[20]!==0||f.dyn_ltree[26]!==0)return w;for(b=32;b<m;b++)if(f.dyn_ltree[b*2]!==0)return w;return O};let ke=!1;const H=f=>{ke||(J(),ke=!0),f.l_desc=new ie(f.dyn_ltree,N),f.d_desc=new ie(f.dyn_dtree,q),f.bl_desc=new ie(f.bl_tree,ee),f.bi_buf=0,f.bi_valid=0,ve(f)},Z=(f,G,b,X)=>{re(f,(E<<1)+(X?1:0),3),Ce(f),de(f,b),de(f,~b),b&&f.pending_buf.set(f.window.subarray(G,G+b),f.pending),f.pending+=b},Y=f=>{re(f,M<<1,3),oe(f,i,I),_e(f)},me=(f,G,b,X)=>{let Q,$,ye=0;f.level>0?(f.strm.data_type===R&&(f.strm.data_type=je(f)),Fe(f,f.l_desc),Fe(f,f.d_desc),ye=Re(f),Q=f.opt_len+3+7>>>3,$=f.static_len+3+7>>>3,$<=Q&&(Q=$)):Q=$=b+5,b+4<=Q&&G!==-1?Z(f,G,b,X):f.strategy===y||$===Q?(re(f,(M<<1)+(X?1:0),3),Ie(f,I,z)):(re(f,(g<<1)+(X?1:0),3),Pe(f,f.l_desc.max_code+1,f.d_desc.max_code+1,ye+1),Ie(f,f.dyn_ltree,f.dyn_dtree)),ve(f),X&&Ce(f)},ce=(f,G,b)=>(f.pending_buf[f.sym_buf+f.sym_next++]=G,f.pending_buf[f.sym_buf+f.sym_next++]=G>>8,f.pending_buf[f.sym_buf+f.sym_next++]=b,G===0?f.dyn_ltree[b*2]++:(f.matches++,G--,f.dyn_ltree[(F[b]+m+1)*2]++,f.dyn_dtree[ne(G)*2]++),f.sym_next===f.sym_end);var Ae=H,we=Z,j=me,se=ce,ge=Y,Se={_tr_init:Ae,_tr_stored_block:we,_tr_flush_block:j,_tr_tally:se,_tr_align:ge},xe=(f,G,b,X)=>{let Q=f&65535|0,$=f>>>16&65535|0,ye=0;for(;b!==0;){ye=b>2e3?2e3:b,b-=ye;do Q=Q+G[X++]|0,$=$+Q|0;while(--ye);Q%=65521,$%=65521}return Q|$<<16|0};const V=()=>{let f,G=[];for(var b=0;b<256;b++){f=b;for(var X=0;X<8;X++)f=f&1?3988292384^f>>>1:f>>>1;G[b]=f}return G},Le=new Uint32Array(V());var C=(f,G,b,X)=>{const Q=Le,$=X+b;f^=-1;for(let ye=X;ye<$;ye++)f=f>>>8^Q[(f^G[ye])&255];return f^-1},le={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"},he={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:k,_tr_stored_block:ae,_tr_flush_block:pe,_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:pt,Z_FIXED:Mt,Z_DEFAULT_STRATEGY:At,Z_UNKNOWN:Dt,Z_DEFLATED:Ct}=he,Tt=9,Rt=15,Bt=8,gi=256+1+29,ii=30,Yr=19,$r=2*gi+1,Qr=15,at=3,Nt=258,It=Nt+at+1,Jr=32,$t=42,wi=57,Ci=69,Di=73,Li=91,Ti=103,kt=113,ri=666,Lt=1,Qt=2,Ht=3,Jt=4,qr=3,Kt=(f,G)=>(f.msg=le[G],G),Vi=f=>f*2-(f>4?9:0),Vt=f=>{let G=f.length;for(;--G>=0;)f[G]=0},en=f=>{let G,b,X,Q=f.w_size;G=f.hash_size,X=G;do b=f.head[--X],f.head[X]=b>=Q?b-Q:0;while(--G);G=Q,X=G;do b=f.prev[--X],f.prev[X]=b>=Q?b-Q:0;while(--G)};let jt=(f,G,b)=>(G<<f.hash_shift^b)&f.hash_mask;const St=f=>{const G=f.state;let b=G.pending;b>f.avail_out&&(b=f.avail_out),b!==0&&(f.output.set(G.pending_buf.subarray(G.pending_out,G.pending_out+b),f.next_out),f.next_out+=b,G.pending_out+=b,f.total_out+=b,f.avail_out-=b,G.pending-=b,G.pending===0&&(G.pending_out=0))},Ot=(f,G)=>{pe(f,f.block_start>=0?f.block_start:-1,f.strstart-f.block_start,G),f.block_start=f.strstart,St(f.strm)},ut=(f,G)=>{f.pending_buf[f.pending++]=G},ni=(f,G)=>{f.pending_buf[f.pending++]=G>>>8&255,f.pending_buf[f.pending++]=G&255},Si=(f,G,b,X)=>{let Q=f.avail_in;return Q>X&&(Q=X),Q===0?0:(f.avail_in-=Q,G.set(f.input.subarray(f.next_in,f.next_in+Q),b),f.state.wrap===1?f.adler=xe(f.adler,G,Q,b):f.state.wrap===2&&(f.adler=C(f.adler,G,Q,b)),f.next_in+=Q,f.total_in+=Q,Q)},ji=(f,G)=>{let b=f.max_chain_length,X=f.strstart,Q,$,ye=f.prev_length,ue=f.nice_match;const Xe=f.strstart>f.w_size-It?f.strstart-(f.w_size-It):0,fe=f.window,Ee=f.w_mask,ct=f.prev,Ze=f.strstart+Nt;let Ue=fe[X+ye-1],Qe=fe[X+ye];f.prev_length>=f.good_match&&(b>>=2),ue>f.lookahead&&(ue=f.lookahead);do if(Q=G,!(fe[Q+ye]!==Qe||fe[Q+ye-1]!==Ue||fe[Q]!==fe[X]||fe[++Q]!==fe[X+1])){X+=2,Q++;do;while(fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&fe[++X]===fe[++Q]&&X<Ze);if($=Nt-(Ze-X),X=Ze-Nt,$>ye){if(f.match_start=G,ye=$,$>=ue)break;Ue=fe[X+ye-1],Qe=fe[X+ye]}}while((G=ct[G&Ee])>Xe&&--b!==0);return ye<=f.lookahead?ye:f.lookahead},qt=f=>{const G=f.w_size;let b,X,Q;do{if(X=f.window_size-f.lookahead-f.strstart,f.strstart>=G+(G-It)&&(f.window.set(f.window.subarray(G,G+G-X),0),f.match_start-=G,f.strstart-=G,f.block_start-=G,f.insert>f.strstart&&(f.insert=f.strstart),en(f),X+=G),f.strm.avail_in===0)break;if(b=Si(f.strm,f.window,f.strstart+f.lookahead,X),f.lookahead+=b,f.lookahead+f.insert>=at)for(Q=f.strstart-f.insert,f.ins_h=f.window[Q],f.ins_h=jt(f,f.ins_h,f.window[Q+1]);f.insert&&(f.ins_h=jt(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<It&&f.strm.avail_in!==0)},ki=(f,G)=>{let b=f.pending_buf_size-5>f.w_size?f.w_size:f.pending_buf_size-5,X,Q,$,ye=0,ue=f.strm.avail_in;do{if(X=65535,$=f.bi_valid+42>>3,f.strm.avail_out<$||($=f.strm.avail_out-$,Q=f.strstart-f.block_start,X>Q+f.strm.avail_in&&(X=Q+f.strm.avail_in),X>$&&(X=$),X<b&&(X===0&&G!==Ye||G===Ge||X!==Q+f.strm.avail_in)))break;ye=G===Ye&&X===Q+f.strm.avail_in?1:0,ae(f,0,0,ye),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&&(Si(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(ye===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),ye?Jt:G!==Ge&&G!==Ye&&f.strm.avail_in===0&&f.strstart===f.block_start?Qt:($=f.window_size-f.strstart,f.strm.avail_in>$&&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++,$+=f.w_size,f.insert>f.strstart&&(f.insert=f.strstart)),$>f.strm.avail_in&&($=f.strm.avail_in),$&&(Si(f.strm,f.window,f.strstart,$),f.strstart+=$,f.insert+=$>f.w_size-f.insert?f.w_size-f.insert:$),f.high_water<f.strstart&&(f.high_water=f.strstart),$=f.bi_valid+42>>3,$=f.pending_buf_size-$>65535?65535:f.pending_buf_size-$,b=$>f.w_size?f.w_size:$,Q=f.strstart-f.block_start,(Q>=b||(Q||G===Ye)&&G!==Ge&&f.strm.avail_in===0&&Q<=$)&&(X=Q>$?$:Q,ye=G===Ye&&f.strm.avail_in===0&&X===Q?1:0,ae(f,f.block_start,X,ye),f.block_start+=X,St(f.strm)),ye?Ht:Lt)},Oi=(f,G)=>{let b,X;for(;;){if(f.lookahead<It){if(qt(f),f.lookahead<It&&G===Ge)return Lt;if(f.lookahead===0)break}if(b=0,f.lookahead>=at&&(f.ins_h=jt(f,f.ins_h,f.window[f.strstart+at-1]),b=f.prev[f.strstart&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=f.strstart),b!==0&&f.strstart-b<=f.w_size-It&&(f.match_length=ji(f,b)),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=jt(f,f.ins_h,f.window[f.strstart+at-1]),b=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=jt(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 Lt}return f.insert=f.strstart<at-1?f.strstart:at-1,G===Ye?(Ot(f,!0),f.strm.avail_out===0?Ht:Jt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Lt:Qt},ei=(f,G)=>{let b,X,Q;for(;;){if(f.lookahead<It){if(qt(f),f.lookahead<It&&G===Ge)return Lt;if(f.lookahead===0)break}if(b=0,f.lookahead>=at&&(f.ins_h=jt(f,f.ins_h,f.window[f.strstart+at-1]),b=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,b!==0&&f.prev_length<f.max_lazy_match&&f.strstart-b<=f.w_size-It&&(f.match_length=ji(f,b),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=jt(f,f.ins_h,f.window[f.strstart+at-1]),b=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 Lt}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 Lt}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,G===Ye?(Ot(f,!0),f.strm.avail_out===0?Ht:Jt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Lt:Qt},tn=(f,G)=>{let b,X,Q,$;const ye=f.window;for(;;){if(f.lookahead<=Nt){if(qt(f),f.lookahead<=Nt&&G===Ge)return Lt;if(f.lookahead===0)break}if(f.match_length=0,f.lookahead>=at&&f.strstart>0&&(Q=f.strstart-1,X=ye[Q],X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q])){$=f.strstart+Nt;do;while(X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&X===ye[++Q]&&Q<$);f.match_length=Nt-($-Q),f.match_length>f.lookahead&&(f.match_length=f.lookahead)}if(f.match_length>=at?(b=Ve(f,1,f.match_length-at),f.lookahead-=f.match_length,f.strstart+=f.match_length,f.match_length=0):(b=Ve(f,0,f.window[f.strstart]),f.lookahead--,f.strstart++),b&&(Ot(f,!1),f.strm.avail_out===0))return Lt}return f.insert=0,G===Ye?(Ot(f,!0),f.strm.avail_out===0?Ht:Jt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Lt:Qt},rn=(f,G)=>{let b;for(;;){if(f.lookahead===0&&(qt(f),f.lookahead===0)){if(G===Ge)return Lt;break}if(f.match_length=0,b=Ve(f,0,f.window[f.strstart]),f.lookahead--,f.strstart++,b&&(Ot(f,!1),f.strm.avail_out===0))return Lt}return f.insert=0,G===Ye?(Ot(f,!0),f.strm.avail_out===0?Ht:Jt):f.sym_next&&(Ot(f,!1),f.strm.avail_out===0)?Lt:Qt};function zt(f,G,b,X,Q){this.good_length=f,this.max_lazy=G,this.nice_length=b,this.max_chain=X,this.func=Q}const si=[new zt(0,0,0,0,ki),new zt(4,4,8,4,Oi),new zt(4,5,16,8,Oi),new zt(4,6,32,32,Oi),new zt(4,4,16,16,ei),new zt(8,16,32,32,ei),new zt(8,16,128,128,ei),new zt(8,32,128,256,ei),new zt(32,128,258,1024,ei),new zt(32,258,258,4096,ei)],nn=f=>{f.window_size=2*f.w_size,Vt(f.head),f.max_lazy_match=si[f.level].max_lazy,f.good_match=si[f.level].good_length,f.nice_match=si[f.level].nice_length,f.max_chain_length=si[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 sn(){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($r*2),this.dyn_dtree=new Uint16Array((2*ii+1)*2),this.bl_tree=new Uint16Array((2*Yr+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Qr+1),this.heap=new Uint16Array(2*gi+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*gi+1),Vt(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 ai=f=>{if(!f)return 1;const G=f.state;return!G||G.strm!==f||G.status!==$t&&G.status!==wi&&G.status!==Ci&&G.status!==Di&&G.status!==Li&&G.status!==Ti&&G.status!==kt&&G.status!==ri?1:0},Hi=f=>{if(ai(f))return Kt(f,et);f.total_in=f.total_out=0,f.data_type=Dt;const G=f.state;return G.pending=0,G.pending_out=0,G.wrap<0&&(G.wrap=-G.wrap),G.status=G.wrap===2?wi:G.wrap?$t:kt,f.adler=G.wrap===2?0:1,G.last_flush=-2,k(G),$e},Ki=f=>{const G=Hi(f);return G===$e&&nn(f.state),G},an=(f,G)=>ai(f)||f.state.wrap!==2?et:(f.state.gzhead=G,$e),Zi=(f,G,b,X,Q,$)=>{if(!f)return et;let ye=1;if(G===st&&(G=6),X<0?(ye=0,X=-X):X>15&&(ye=2,X-=16),Q<1||Q>Tt||b!==Ct||X<8||X>15||G<0||G>9||$<0||$>Mt||X===8&&ye!==1)return Kt(f,et);X===8&&(X=9);const ue=new sn;return f.state=ue,ue.strm=f,ue.status=$t,ue.wrap=ye,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=G,ue.strategy=$,ue.method=b,Ki(f)},on=(f,G)=>Zi(f,G,Ct,Rt,Bt,At),ln=(f,G)=>{if(ai(f)||G>He||G<0)return f?Kt(f,et):et;const b=f.state;if(!f.output||f.avail_in!==0&&!f.input||b.status===ri&&G!==Ye)return Kt(f,f.avail_out===0?xt:et);const X=b.last_flush;if(b.last_flush=G,b.pending!==0){if(St(f),f.avail_out===0)return b.last_flush=-1,$e}else if(f.avail_in===0&&Vi(G)<=Vi(X)&&G!==Ye)return Kt(f,xt);if(b.status===ri&&f.avail_in!==0)return Kt(f,xt);if(b.status===$t&&b.wrap===0&&(b.status=kt),b.status===$t){let Q=Ct+(b.w_bits-8<<4)<<8,$=-1;if(b.strategy>=dt||b.level<2?$=0:b.level<6?$=1:b.level===6?$=2:$=3,Q|=$<<6,b.strstart!==0&&(Q|=Jr),Q+=31-Q%31,ni(b,Q),b.strstart!==0&&(ni(b,f.adler>>>16),ni(b,f.adler&65535)),f.adler=1,b.status=kt,St(f),b.pending!==0)return b.last_flush=-1,$e}if(b.status===wi){if(f.adler=0,ut(b,31),ut(b,139),ut(b,8),b.gzhead)ut(b,(b.gzhead.text?1:0)+(b.gzhead.hcrc?2:0)+(b.gzhead.extra?4:0)+(b.gzhead.name?8:0)+(b.gzhead.comment?16:0)),ut(b,b.gzhead.time&255),ut(b,b.gzhead.time>>8&255),ut(b,b.gzhead.time>>16&255),ut(b,b.gzhead.time>>24&255),ut(b,b.level===9?2:b.strategy>=dt||b.level<2?4:0),ut(b,b.gzhead.os&255),b.gzhead.extra&&b.gzhead.extra.length&&(ut(b,b.gzhead.extra.length&255),ut(b,b.gzhead.extra.length>>8&255)),b.gzhead.hcrc&&(f.adler=C(f.adler,b.pending_buf,b.pending,0)),b.gzindex=0,b.status=Ci;else if(ut(b,0),ut(b,0),ut(b,0),ut(b,0),ut(b,0),ut(b,b.level===9?2:b.strategy>=dt||b.level<2?4:0),ut(b,qr),b.status=kt,St(f),b.pending!==0)return b.last_flush=-1,$e}if(b.status===Ci){if(b.gzhead.extra){let Q=b.pending,$=(b.gzhead.extra.length&65535)-b.gzindex;for(;b.pending+$>b.pending_buf_size;){let ue=b.pending_buf_size-b.pending;if(b.pending_buf.set(b.gzhead.extra.subarray(b.gzindex,b.gzindex+ue),b.pending),b.pending=b.pending_buf_size,b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q)),b.gzindex+=ue,St(f),b.pending!==0)return b.last_flush=-1,$e;Q=0,$-=ue}let ye=new Uint8Array(b.gzhead.extra);b.pending_buf.set(ye.subarray(b.gzindex,b.gzindex+$),b.pending),b.pending+=$,b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q)),b.gzindex=0}b.status=Di}if(b.status===Di){if(b.gzhead.name){let Q=b.pending,$;do{if(b.pending===b.pending_buf_size){if(b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q)),St(f),b.pending!==0)return b.last_flush=-1,$e;Q=0}b.gzindex<b.gzhead.name.length?$=b.gzhead.name.charCodeAt(b.gzindex++)&255:$=0,ut(b,$)}while($!==0);b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q)),b.gzindex=0}b.status=Li}if(b.status===Li){if(b.gzhead.comment){let Q=b.pending,$;do{if(b.pending===b.pending_buf_size){if(b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q)),St(f),b.pending!==0)return b.last_flush=-1,$e;Q=0}b.gzindex<b.gzhead.comment.length?$=b.gzhead.comment.charCodeAt(b.gzindex++)&255:$=0,ut(b,$)}while($!==0);b.gzhead.hcrc&&b.pending>Q&&(f.adler=C(f.adler,b.pending_buf,b.pending-Q,Q))}b.status=Ti}if(b.status===Ti){if(b.gzhead.hcrc){if(b.pending+2>b.pending_buf_size&&(St(f),b.pending!==0))return b.last_flush=-1,$e;ut(b,f.adler&255),ut(b,f.adler>>8&255),f.adler=0}if(b.status=kt,St(f),b.pending!==0)return b.last_flush=-1,$e}if(f.avail_in!==0||b.lookahead!==0||G!==Ge&&b.status!==ri){let Q=b.level===0?ki(b,G):b.strategy===dt?rn(b,G):b.strategy===pt?tn(b,G):si[b.level].func(b,G);if((Q===Ht||Q===Jt)&&(b.status=ri),Q===Lt||Q===Ht)return f.avail_out===0&&(b.last_flush=-1),$e;if(Q===Qt&&(G===qe?Ne(b):G!==He&&(ae(b,0,0,!1),G===_t&&(Vt(b.head),b.lookahead===0&&(b.strstart=0,b.block_start=0,b.insert=0))),St(f),f.avail_out===0))return b.last_flush=-1,$e}return G!==Ye?$e:b.wrap<=0?tt:(b.wrap===2?(ut(b,f.adler&255),ut(b,f.adler>>8&255),ut(b,f.adler>>16&255),ut(b,f.adler>>24&255),ut(b,f.total_in&255),ut(b,f.total_in>>8&255),ut(b,f.total_in>>16&255),ut(b,f.total_in>>24&255)):(ni(b,f.adler>>>16),ni(b,f.adler&65535)),St(f),b.wrap>0&&(b.wrap=-b.wrap),b.pending!==0?$e:tt)},hn=f=>{if(ai(f))return et;const G=f.state.status;return f.state=null,G===kt?Kt(f,bt):$e},fn=(f,G)=>{let b=G.length;if(ai(f))return et;const X=f.state,Q=X.wrap;if(Q===2||Q===1&&X.status!==$t||X.lookahead)return et;if(Q===1&&(f.adler=xe(f.adler,G,b,0)),X.wrap=0,b>=X.w_size){Q===0&&(Vt(X.head),X.strstart=0,X.block_start=0,X.insert=0);let Xe=new Uint8Array(X.w_size);Xe.set(G.subarray(b-X.w_size,b),0),G=Xe,b=X.w_size}const $=f.avail_in,ye=f.next_in,ue=f.input;for(f.avail_in=b,f.next_in=0,f.input=G,qt(X);X.lookahead>=at;){let Xe=X.strstart,fe=X.lookahead-(at-1);do X.ins_h=jt(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(--fe);X.strstart=Xe,X.lookahead=at-1,qt(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=ye,f.input=ue,f.avail_in=$,X.wrap=Q,$e};var dn=on,cn=Zi,un=Ki,gn=Hi,mn=an,vn=ln,pn=hn,_n=fn,xn="pako deflate (from Nodeca project)",oi={deflateInit:dn,deflateInit2:cn,deflateReset:un,deflateResetKeep:gn,deflateSetHeader:mn,deflate:vn,deflateEnd:pn,deflateSetDictionary:_n,deflateInfo:xn};const bn=(f,G)=>Object.prototype.hasOwnProperty.call(f,G);var yn=function(f){const G=Array.prototype.slice.call(arguments,1);for(;G.length;){const b=G.shift();if(b){if(typeof b!="object")throw new TypeError(b+"must be non-object");for(const X in b)bn(b,X)&&(f[X]=b[X])}}return f},En=f=>{let G=0;for(let X=0,Q=f.length;X<Q;X++)G+=f[X].length;const b=new Uint8Array(G);for(let X=0,Q=0,$=f.length;X<$;X++){let ye=f[X];b.set(ye,Q),Q+=ye.length}return b},mi={assign:yn,flattenChunks:En};let Xi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Xi=!1}const li=new Uint8Array(256);for(let f=0;f<256;f++)li[f]=f>=252?6:f>=248?5:f>=240?4:f>=224?3:f>=192?2:1;li[254]=li[254]=1;var An=f=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(f);let G,b,X,Q,$,ye=f.length,ue=0;for(Q=0;Q<ye;Q++)b=f.charCodeAt(Q),(b&64512)===55296&&Q+1<ye&&(X=f.charCodeAt(Q+1),(X&64512)===56320&&(b=65536+(b-55296<<10)+(X-56320),Q++)),ue+=b<128?1:b<2048?2:b<65536?3:4;for(G=new Uint8Array(ue),$=0,Q=0;$<ue;Q++)b=f.charCodeAt(Q),(b&64512)===55296&&Q+1<ye&&(X=f.charCodeAt(Q+1),(X&64512)===56320&&(b=65536+(b-55296<<10)+(X-56320),Q++)),b<128?G[$++]=b:b<2048?(G[$++]=192|b>>>6,G[$++]=128|b&63):b<65536?(G[$++]=224|b>>>12,G[$++]=128|b>>>6&63,G[$++]=128|b&63):(G[$++]=240|b>>>18,G[$++]=128|b>>>12&63,G[$++]=128|b>>>6&63,G[$++]=128|b&63);return G};const Mn=(f,G)=>{if(G<65534&&f.subarray&&Xi)return String.fromCharCode.apply(null,f.length===G?f:f.subarray(0,G));let b="";for(let X=0;X<G;X++)b+=String.fromCharCode(f[X]);return b};var wn=(f,G)=>{const b=G||f.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(f.subarray(0,G));let X,Q;const $=new Array(b*2);for(Q=0,X=0;X<b;){let ye=f[X++];if(ye<128){$[Q++]=ye;continue}let ue=li[ye];if(ue>4){$[Q++]=65533,X+=ue-1;continue}for(ye&=ue===2?31:ue===3?15:7;ue>1&&X<b;)ye=ye<<6|f[X++]&63,ue--;if(ue>1){$[Q++]=65533;continue}ye<65536?$[Q++]=ye:(ye-=65536,$[Q++]=55296|ye>>10&1023,$[Q++]=56320|ye&1023)}return Mn($,Q)},Cn=(f,G)=>{G=G||f.length,G>f.length&&(G=f.length);let b=G-1;for(;b>=0&&(f[b]&192)===128;)b--;return b<0||b===0?G:b+li[f[b]]>G?b:G},hi={string2buf:An,buf2string:wn,utf8border:Cn};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 Yi=Dn;const $i=Object.prototype.toString,{Z_NO_FLUSH:Ln,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:Sn,Z_FINISH:On,Z_OK:vi,Z_STREAM_END:Pn,Z_DEFAULT_COMPRESSION:Rn,Z_DEFAULT_STRATEGY:In,Z_DEFLATED:zn}=he;function fi(f){this.options=mi.assign({level:Rn,method:zn,chunkSize:16384,windowBits:15,memLevel:8,strategy:In},f||{});let G=this.options;G.raw&&G.windowBits>0?G.windowBits=-G.windowBits:G.gzip&&G.windowBits>0&&G.windowBits<16&&(G.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yi,this.strm.avail_out=0;let b=oi.deflateInit2(this.strm,G.level,G.method,G.windowBits,G.memLevel,G.strategy);if(b!==vi)throw new Error(le[b]);if(G.header&&oi.deflateSetHeader(this.strm,G.header),G.dictionary){let X;if(typeof G.dictionary=="string"?X=hi.string2buf(G.dictionary):$i.call(G.dictionary)==="[object ArrayBuffer]"?X=new Uint8Array(G.dictionary):X=G.dictionary,b=oi.deflateSetDictionary(this.strm,X),b!==vi)throw new Error(le[b]);this._dict_set=!0}}fi.prototype.push=function(f,G){const b=this.strm,X=this.options.chunkSize;let Q,$;if(this.ended)return!1;for(G===~~G?$=G:$=G===!0?On:Ln,typeof f=="string"?b.input=hi.string2buf(f):$i.call(f)==="[object ArrayBuffer]"?b.input=new Uint8Array(f):b.input=f,b.next_in=0,b.avail_in=b.input.length;;){if(b.avail_out===0&&(b.output=new Uint8Array(X),b.next_out=0,b.avail_out=X),($===Tn||$===Sn)&&b.avail_out<=6){this.onData(b.output.subarray(0,b.next_out)),b.avail_out=0;continue}if(Q=oi.deflate(b,$),Q===Pn)return b.next_out>0&&this.onData(b.output.subarray(0,b.next_out)),Q=oi.deflateEnd(this.strm),this.onEnd(Q),this.ended=!0,Q===vi;if(b.avail_out===0){this.onData(b.output);continue}if($>0&&b.next_out>0){this.onData(b.output.subarray(0,b.next_out)),b.avail_out=0;continue}if(b.avail_in===0)break}return!0},fi.prototype.onData=function(f){this.chunks.push(f)},fi.prototype.onEnd=function(f){f===vi&&(this.result=mi.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function Pi(f,G){const b=new fi(G);if(b.push(f,!0),b.err)throw b.msg||le[b.err];return b.result}function Bn(f,G){return G=G||{},G.raw=!0,Pi(f,G)}function Fn(f,G){return G=G||{},G.gzip=!0,Pi(f,G)}var Un=fi,Wn=Pi,Gn=Bn,Nn=Fn,Vn={Deflate:Un,deflate:Wn,deflateRaw:Gn,gzip:Nn};const pi=16209,jn=16191;var kn=function(G,b){let X,Q,$,ye,ue,Xe,fe,Ee,ct,Ze,Ue,Qe,Et,ht,rt,mt,nt,Ke,gt,wt,Je,vt,ft,it;const ot=G.state;X=G.next_in,ft=G.input,Q=X+(G.avail_in-5),$=G.next_out,it=G.output,ye=$-(b-G.avail_out),ue=$+(G.avail_out-257),Xe=ot.dmax,fe=ot.wsize,Ee=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[$++]=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){G.msg="invalid distance too far back",ot.mode=pi;break e}if(Ue>>>=Ke,Qe-=Ke,Ke=$-ye,wt>Ke){if(Ke=wt-Ke,Ke>Ee&&ot.sane){G.msg="invalid distance too far back",ot.mode=pi;break e}if(Je=0,vt=Ze,ct===0){if(Je+=fe-Ke,Ke<gt){gt-=Ke;do it[$++]=Ze[Je++];while(--Ke);Je=$-wt,vt=it}}else if(ct<Ke){if(Je+=fe+ct-Ke,Ke-=ct,Ke<gt){gt-=Ke;do it[$++]=Ze[Je++];while(--Ke);if(Je=0,ct<gt){Ke=ct,gt-=Ke;do it[$++]=Ze[Je++];while(--Ke);Je=$-wt,vt=it}}}else if(Je+=ct-Ke,Ke<gt){gt-=Ke;do it[$++]=Ze[Je++];while(--Ke);Je=$-wt,vt=it}for(;gt>2;)it[$++]=vt[Je++],it[$++]=vt[Je++],it[$++]=vt[Je++],gt-=3;gt&&(it[$++]=vt[Je++],gt>1&&(it[$++]=vt[Je++]))}else{Je=$-wt;do it[$++]=it[Je++],it[$++]=it[Je++],it[$++]=it[Je++],gt-=3;while(gt>2);gt&&(it[$++]=it[Je++],gt>1&&(it[$++]=it[Je++]))}}else if((Ke&64)===0){nt=ht[(nt&65535)+(Ue&(1<<Ke)-1)];continue i}else{G.msg="invalid distance code",ot.mode=pi;break e}break}}else if((Ke&64)===0){nt=Et[(nt&65535)+(Ue&(1<<Ke)-1)];continue t}else if(Ke&32){ot.mode=jn;break e}else{G.msg="invalid literal/length code",ot.mode=pi;break e}break}}while(X<Q&&$<ue);gt=Qe>>3,X-=gt,Qe-=gt<<3,Ue&=(1<<Qe)-1,G.next_in=X,G.next_out=$,G.avail_in=X<Q?5+(Q-X):5-(X-Q),G.avail_out=$<ue?257+(ue-$):257-($-ue),ot.hold=Ue,ot.bits=Qe};const ti=15,Qi=852,Ji=592,qi=0,Ri=1,er=2,Hn=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]),Kn=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]),Zn=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]),Xn=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 di=(f,G,b,X,Q,$,ye,ue)=>{const Xe=ue.bits;let fe=0,Ee=0,ct=0,Ze=0,Ue=0,Qe=0,Et=0,ht=0,rt=0,mt=0,nt,Ke,gt,wt,Je,vt=null,ft;const it=new Uint16Array(ti+1),ot=new Uint16Array(ti+1);let Yt=null,Xr,Ai,Mi;for(fe=0;fe<=ti;fe++)it[fe]=0;for(Ee=0;Ee<X;Ee++)it[G[b+Ee]]++;for(Ue=Xe,Ze=ti;Ze>=1&&it[Ze]===0;Ze--);if(Ue>Ze&&(Ue=Ze),Ze===0)return Q[$++]=1<<24|64<<16|0,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,fe=1;fe<=ti;fe++)if(ht<<=1,ht-=it[fe],ht<0)return-1;if(ht>0&&(f===qi||Ze!==1))return-1;for(ot[1]=0,fe=1;fe<ti;fe++)ot[fe+1]=ot[fe]+it[fe];for(Ee=0;Ee<X;Ee++)G[b+Ee]!==0&&(ye[ot[G[b+Ee]]++]=Ee);if(f===qi?(vt=Yt=ye,ft=20):f===Ri?(vt=Hn,Yt=Kn,ft=257):(vt=Zn,Yt=Xn,ft=0),mt=0,Ee=0,fe=ct,Je=$,Qe=Ue,Et=0,gt=-1,rt=1<<Ue,wt=rt-1,f===Ri&&rt>Qi||f===er&&rt>Ji)return 1;for(;;){Xr=fe-Et,ye[Ee]+1<ft?(Ai=0,Mi=ye[Ee]):ye[Ee]>=ft?(Ai=Yt[ye[Ee]-ft],Mi=vt[ye[Ee]-ft]):(Ai=96,Mi=0),nt=1<<fe-Et,Ke=1<<Qe,ct=Ke;do Ke-=nt,Q[Je+(mt>>Et)+Ke]=Xr<<24|Ai<<16|Mi|0;while(Ke!==0);for(nt=1<<fe-1;mt&nt;)nt>>=1;if(nt!==0?(mt&=nt-1,mt+=nt):mt=0,Ee++,--it[fe]===0){if(fe===Ze)break;fe=G[b+ye[Ee]]}if(fe>Ue&&(mt&wt)!==gt){for(Et===0&&(Et=Ue),Je+=ct,Qe=fe-Et,ht=1<<Qe;Qe+Et<Ze&&(ht-=it[Qe+Et],!(ht<=0));)Qe++,ht<<=1;if(rt+=1<<Qe,f===Ri&&rt>Qi||f===er&&rt>Ji)return 1;gt=mt&wt,Q[gt]=Ue<<24|Qe<<16|Je-$|0}}return mt!==0&&(Q[Je+mt]=fe-Et<<24|64<<16|0),ue.bits=Ue,0};const Yn=0,tr=1,ir=2,{Z_FINISH:rr,Z_BLOCK:$n,Z_TREES:_i,Z_OK:Zt,Z_STREAM_END:Qn,Z_NEED_DICT:Jn,Z_STREAM_ERROR:Pt,Z_DATA_ERROR:nr,Z_MEM_ERROR:sr,Z_BUF_ERROR:qn,Z_DEFLATED:ar}=he,xi=16180,or=16181,lr=16182,hr=16183,fr=16184,dr=16185,cr=16186,ur=16187,gr=16188,mr=16189,bi=16190,Wt=16191,Ii=16192,vr=16193,zi=16194,pr=16195,_r=16196,xr=16197,br=16198,yi=16199,Ei=16200,yr=16201,Er=16202,Ar=16203,Mr=16204,wr=16205,Bi=16206,Cr=16207,Dr=16208,yt=16209,Lr=16210,Tr=16211,es=852,ts=592,is=15,Sr=f=>(f>>>24&255)+(f>>>8&65280)+((f&65280)<<8)+((f&255)<<24);function rs(){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 Xt=f=>{if(!f)return 1;const G=f.state;return!G||G.strm!==f||G.mode<xi||G.mode>Tr?1:0},Or=f=>{if(Xt(f))return Pt;const G=f.state;return f.total_in=f.total_out=G.total=0,f.msg="",G.wrap&&(f.adler=G.wrap&1),G.mode=xi,G.last=0,G.havedict=0,G.flags=-1,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new Int32Array(es),G.distcode=G.distdyn=new Int32Array(ts),G.sane=1,G.back=-1,Zt},Pr=f=>{if(Xt(f))return Pt;const G=f.state;return G.wsize=0,G.whave=0,G.wnext=0,Or(f)},Rr=(f,G)=>{let b;if(Xt(f))return Pt;const X=f.state;return G<0?(b=0,G=-G):(b=(G>>4)+5,G<48&&(G&=15)),G&&(G<8||G>15)?Pt:(X.window!==null&&X.wbits!==G&&(X.window=null),X.wrap=b,X.wbits=G,Pr(f))},Ir=(f,G)=>{if(!f)return Pt;const b=new rs;f.state=b,b.strm=f,b.window=null,b.mode=xi;const X=Rr(f,G);return X!==Zt&&(f.state=null),X},ns=f=>Ir(f,is);let zr=!0,Fi,Ui;const ss=f=>{if(zr){Fi=new Int32Array(512),Ui=new Int32Array(32);let G=0;for(;G<144;)f.lens[G++]=8;for(;G<256;)f.lens[G++]=9;for(;G<280;)f.lens[G++]=7;for(;G<288;)f.lens[G++]=8;for(di(tr,f.lens,0,288,Fi,0,f.work,{bits:9}),G=0;G<32;)f.lens[G++]=5;di(ir,f.lens,0,32,Ui,0,f.work,{bits:5}),zr=!1}f.lencode=Fi,f.lenbits=9,f.distcode=Ui,f.distbits=5},Br=(f,G,b,X)=>{let Q;const $=f.state;return $.window===null&&($.wsize=1<<$.wbits,$.wnext=0,$.whave=0,$.window=new Uint8Array($.wsize)),X>=$.wsize?($.window.set(G.subarray(b-$.wsize,b),0),$.wnext=0,$.whave=$.wsize):(Q=$.wsize-$.wnext,Q>X&&(Q=X),$.window.set(G.subarray(b-X,b-X+Q),$.wnext),X-=Q,X?($.window.set(G.subarray(b-X,b),0),$.wnext=X,$.whave=$.wsize):($.wnext+=Q,$.wnext===$.wsize&&($.wnext=0),$.whave<$.wsize&&($.whave+=Q))),0},as=(f,G)=>{let b,X,Q,$,ye,ue,Xe,fe,Ee,ct,Ze,Ue,Qe,Et,ht=0,rt,mt,nt,Ke,gt,wt,Je,vt;const ft=new Uint8Array(4);let it,ot;const Yt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Xt(f)||!f.output||!f.input&&f.avail_in!==0)return Pt;b=f.state,b.mode===Wt&&(b.mode=Ii),ye=f.next_out,Q=f.output,Xe=f.avail_out,$=f.next_in,X=f.input,ue=f.avail_in,fe=b.hold,Ee=b.bits,ct=ue,Ze=Xe,vt=Zt;e:for(;;)switch(b.mode){case xi:if(b.wrap===0){b.mode=Ii;break}for(;Ee<16;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(b.wrap&2&&fe===35615){b.wbits===0&&(b.wbits=15),b.check=0,ft[0]=fe&255,ft[1]=fe>>>8&255,b.check=C(b.check,ft,2,0),fe=0,Ee=0,b.mode=or;break}if(b.head&&(b.head.done=!1),!(b.wrap&1)||(((fe&255)<<8)+(fe>>8))%31){f.msg="incorrect header check",b.mode=yt;break}if((fe&15)!==ar){f.msg="unknown compression method",b.mode=yt;break}if(fe>>>=4,Ee-=4,Je=(fe&15)+8,b.wbits===0&&(b.wbits=Je),Je>15||Je>b.wbits){f.msg="invalid window size",b.mode=yt;break}b.dmax=1<<b.wbits,b.flags=0,f.adler=b.check=1,b.mode=fe&512?mr:Wt,fe=0,Ee=0;break;case or:for(;Ee<16;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(b.flags=fe,(b.flags&255)!==ar){f.msg="unknown compression method",b.mode=yt;break}if(b.flags&57344){f.msg="unknown header flags set",b.mode=yt;break}b.head&&(b.head.text=fe>>8&1),b.flags&512&&b.wrap&4&&(ft[0]=fe&255,ft[1]=fe>>>8&255,b.check=C(b.check,ft,2,0)),fe=0,Ee=0,b.mode=lr;case lr:for(;Ee<32;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.head&&(b.head.time=fe),b.flags&512&&b.wrap&4&&(ft[0]=fe&255,ft[1]=fe>>>8&255,ft[2]=fe>>>16&255,ft[3]=fe>>>24&255,b.check=C(b.check,ft,4,0)),fe=0,Ee=0,b.mode=hr;case hr:for(;Ee<16;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.head&&(b.head.xflags=fe&255,b.head.os=fe>>8),b.flags&512&&b.wrap&4&&(ft[0]=fe&255,ft[1]=fe>>>8&255,b.check=C(b.check,ft,2,0)),fe=0,Ee=0,b.mode=fr;case fr:if(b.flags&1024){for(;Ee<16;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.length=fe,b.head&&(b.head.extra_len=fe),b.flags&512&&b.wrap&4&&(ft[0]=fe&255,ft[1]=fe>>>8&255,b.check=C(b.check,ft,2,0)),fe=0,Ee=0}else b.head&&(b.head.extra=null);b.mode=dr;case dr:if(b.flags&1024&&(Ue=b.length,Ue>ue&&(Ue=ue),Ue&&(b.head&&(Je=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Uint8Array(b.head.extra_len)),b.head.extra.set(X.subarray($,$+Ue),Je)),b.flags&512&&b.wrap&4&&(b.check=C(b.check,X,Ue,$)),ue-=Ue,$+=Ue,b.length-=Ue),b.length))break e;b.length=0,b.mode=cr;case cr:if(b.flags&2048){if(ue===0)break e;Ue=0;do Je=X[$+Ue++],b.head&&Je&&b.length<65536&&(b.head.name+=String.fromCharCode(Je));while(Je&&Ue<ue);if(b.flags&512&&b.wrap&4&&(b.check=C(b.check,X,Ue,$)),ue-=Ue,$+=Ue,Je)break e}else b.head&&(b.head.name=null);b.length=0,b.mode=ur;case ur:if(b.flags&4096){if(ue===0)break e;Ue=0;do Je=X[$+Ue++],b.head&&Je&&b.length<65536&&(b.head.comment+=String.fromCharCode(Je));while(Je&&Ue<ue);if(b.flags&512&&b.wrap&4&&(b.check=C(b.check,X,Ue,$)),ue-=Ue,$+=Ue,Je)break e}else b.head&&(b.head.comment=null);b.mode=gr;case gr:if(b.flags&512){for(;Ee<16;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(b.wrap&4&&fe!==(b.check&65535)){f.msg="header crc mismatch",b.mode=yt;break}fe=0,Ee=0}b.head&&(b.head.hcrc=b.flags>>9&1,b.head.done=!0),f.adler=b.check=0,b.mode=Wt;break;case mr:for(;Ee<32;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}f.adler=b.check=Sr(fe),fe=0,Ee=0,b.mode=bi;case bi:if(b.havedict===0)return f.next_out=ye,f.avail_out=Xe,f.next_in=$,f.avail_in=ue,b.hold=fe,b.bits=Ee,Jn;f.adler=b.check=1,b.mode=Wt;case Wt:if(G===$n||G===_i)break e;case Ii:if(b.last){fe>>>=Ee&7,Ee-=Ee&7,b.mode=Bi;break}for(;Ee<3;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}switch(b.last=fe&1,fe>>>=1,Ee-=1,fe&3){case 0:b.mode=vr;break;case 1:if(ss(b),b.mode=yi,G===_i){fe>>>=2,Ee-=2;break e}break;case 2:b.mode=_r;break;case 3:f.msg="invalid block type",b.mode=yt}fe>>>=2,Ee-=2;break;case vr:for(fe>>>=Ee&7,Ee-=Ee&7;Ee<32;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if((fe&65535)!==(fe>>>16^65535)){f.msg="invalid stored block lengths",b.mode=yt;break}if(b.length=fe&65535,fe=0,Ee=0,b.mode=zi,G===_i)break e;case zi:b.mode=pr;case pr:if(Ue=b.length,Ue){if(Ue>ue&&(Ue=ue),Ue>Xe&&(Ue=Xe),Ue===0)break e;Q.set(X.subarray($,$+Ue),ye),ue-=Ue,$+=Ue,Xe-=Ue,ye+=Ue,b.length-=Ue;break}b.mode=Wt;break;case _r:for(;Ee<14;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(b.nlen=(fe&31)+257,fe>>>=5,Ee-=5,b.ndist=(fe&31)+1,fe>>>=5,Ee-=5,b.ncode=(fe&15)+4,fe>>>=4,Ee-=4,b.nlen>286||b.ndist>30){f.msg="too many length or distance symbols",b.mode=yt;break}b.have=0,b.mode=xr;case xr:for(;b.have<b.ncode;){for(;Ee<3;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.lens[Yt[b.have++]]=fe&7,fe>>>=3,Ee-=3}for(;b.have<19;)b.lens[Yt[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,it={bits:b.lenbits},vt=di(Yn,b.lens,0,19,b.lencode,0,b.work,it),b.lenbits=it.bits,vt){f.msg="invalid code lengths set",b.mode=yt;break}b.have=0,b.mode=br;case br:for(;b.have<b.nlen+b.ndist;){for(;ht=b.lencode[fe&(1<<b.lenbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ee);){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(nt<16)fe>>>=rt,Ee-=rt,b.lens[b.have++]=nt;else{if(nt===16){for(ot=rt+2;Ee<ot;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(fe>>>=rt,Ee-=rt,b.have===0){f.msg="invalid bit length repeat",b.mode=yt;break}Je=b.lens[b.have-1],Ue=3+(fe&3),fe>>>=2,Ee-=2}else if(nt===17){for(ot=rt+3;Ee<ot;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}fe>>>=rt,Ee-=rt,Je=0,Ue=3+(fe&7),fe>>>=3,Ee-=3}else{for(ot=rt+7;Ee<ot;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}fe>>>=rt,Ee-=rt,Je=0,Ue=11+(fe&127),fe>>>=7,Ee-=7}if(b.have+Ue>b.nlen+b.ndist){f.msg="invalid bit length repeat",b.mode=yt;break}for(;Ue--;)b.lens[b.have++]=Je}}if(b.mode===yt)break;if(b.lens[256]===0){f.msg="invalid code -- missing end-of-block",b.mode=yt;break}if(b.lenbits=9,it={bits:b.lenbits},vt=di(tr,b.lens,0,b.nlen,b.lencode,0,b.work,it),b.lenbits=it.bits,vt){f.msg="invalid literal/lengths set",b.mode=yt;break}if(b.distbits=6,b.distcode=b.distdyn,it={bits:b.distbits},vt=di(ir,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,it),b.distbits=it.bits,vt){f.msg="invalid distances set",b.mode=yt;break}if(b.mode=yi,G===_i)break e;case yi:b.mode=Ei;case Ei:if(ue>=6&&Xe>=258){f.next_out=ye,f.avail_out=Xe,f.next_in=$,f.avail_in=ue,b.hold=fe,b.bits=Ee,kn(f,Ze),ye=f.next_out,Q=f.output,Xe=f.avail_out,$=f.next_in,X=f.input,ue=f.avail_in,fe=b.hold,Ee=b.bits,b.mode===Wt&&(b.back=-1);break}for(b.back=0;ht=b.lencode[fe&(1<<b.lenbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ee);){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(mt&&(mt&240)===0){for(Ke=rt,gt=mt,wt=nt;ht=b.lencode[wt+((fe&(1<<Ke+gt)-1)>>Ke)],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(Ke+rt<=Ee);){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}fe>>>=Ke,Ee-=Ke,b.back+=Ke}if(fe>>>=rt,Ee-=rt,b.back+=rt,b.length=nt,mt===0){b.mode=wr;break}if(mt&32){b.back=-1,b.mode=Wt;break}if(mt&64){f.msg="invalid literal/length code",b.mode=yt;break}b.extra=mt&15,b.mode=yr;case yr:if(b.extra){for(ot=b.extra;Ee<ot;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.length+=fe&(1<<b.extra)-1,fe>>>=b.extra,Ee-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=Er;case Er:for(;ht=b.distcode[fe&(1<<b.distbits)-1],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(rt<=Ee);){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if((mt&240)===0){for(Ke=rt,gt=mt,wt=nt;ht=b.distcode[wt+((fe&(1<<Ke+gt)-1)>>Ke)],rt=ht>>>24,mt=ht>>>16&255,nt=ht&65535,!(Ke+rt<=Ee);){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}fe>>>=Ke,Ee-=Ke,b.back+=Ke}if(fe>>>=rt,Ee-=rt,b.back+=rt,mt&64){f.msg="invalid distance code",b.mode=yt;break}b.offset=nt,b.extra=mt&15,b.mode=Ar;case Ar:if(b.extra){for(ot=b.extra;Ee<ot;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}b.offset+=fe&(1<<b.extra)-1,fe>>>=b.extra,Ee-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){f.msg="invalid distance too far back",b.mode=yt;break}b.mode=Mr;case Mr:if(Xe===0)break e;if(Ue=Ze-Xe,b.offset>Ue){if(Ue=b.offset-Ue,Ue>b.whave&&b.sane){f.msg="invalid distance too far back",b.mode=yt;break}Ue>b.wnext?(Ue-=b.wnext,Qe=b.wsize-Ue):Qe=b.wnext-Ue,Ue>b.length&&(Ue=b.length),Et=b.window}else Et=Q,Qe=ye-b.offset,Ue=b.length;Ue>Xe&&(Ue=Xe),Xe-=Ue,b.length-=Ue;do Q[ye++]=Et[Qe++];while(--Ue);b.length===0&&(b.mode=Ei);break;case wr:if(Xe===0)break e;Q[ye++]=b.length,Xe--,b.mode=Ei;break;case Bi:if(b.wrap){for(;Ee<32;){if(ue===0)break e;ue--,fe|=X[$++]<<Ee,Ee+=8}if(Ze-=Xe,f.total_out+=Ze,b.total+=Ze,b.wrap&4&&Ze&&(f.adler=b.check=b.flags?C(b.check,Q,Ze,ye-Ze):xe(b.check,Q,Ze,ye-Ze)),Ze=Xe,b.wrap&4&&(b.flags?fe:Sr(fe))!==b.check){f.msg="incorrect data check",b.mode=yt;break}fe=0,Ee=0}b.mode=Cr;case Cr:if(b.wrap&&b.flags){for(;Ee<32;){if(ue===0)break e;ue--,fe+=X[$++]<<Ee,Ee+=8}if(b.wrap&4&&fe!==(b.total&4294967295)){f.msg="incorrect length check",b.mode=yt;break}fe=0,Ee=0}b.mode=Dr;case Dr:vt=Qn;break e;case yt:vt=nr;break e;case Lr:return sr;case Tr:default:return Pt}return f.next_out=ye,f.avail_out=Xe,f.next_in=$,f.avail_in=ue,b.hold=fe,b.bits=Ee,(b.wsize||Ze!==f.avail_out&&b.mode<yt&&(b.mode<Bi||G!==rr))&&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,b.total+=Ze,b.wrap&4&&Ze&&(f.adler=b.check=b.flags?C(b.check,Q,Ze,f.next_out-Ze):xe(b.check,Q,Ze,f.next_out-Ze)),f.data_type=b.bits+(b.last?64:0)+(b.mode===Wt?128:0)+(b.mode===yi||b.mode===zi?256:0),(ct===0&&Ze===0||G===rr)&&vt===Zt&&(vt=qn),vt},os=f=>{if(Xt(f))return Pt;let G=f.state;return G.window&&(G.window=null),f.state=null,Zt},ls=(f,G)=>{if(Xt(f))return Pt;const b=f.state;return(b.wrap&2)===0?Pt:(b.head=G,G.done=!1,Zt)},hs=(f,G)=>{const b=G.length;let X,Q,$;return Xt(f)||(X=f.state,X.wrap!==0&&X.mode!==bi)?Pt:X.mode===bi&&(Q=1,Q=xe(Q,G,b,0),Q!==X.check)?nr:($=Br(f,G,b,b),$?(X.mode=Lr,sr):(X.havedict=1,Zt))};var fs=Pr,ds=Rr,cs=Or,us=ns,gs=Ir,ms=as,vs=os,ps=ls,_s=hs,xs="pako inflate (from Nodeca project)",Gt={inflateReset:fs,inflateReset2:ds,inflateResetKeep:cs,inflateInit:us,inflateInit2:gs,inflate:ms,inflateEnd:vs,inflateGetHeader:ps,inflateSetDictionary:_s,inflateInfo:xs};function bs(){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 ys=bs;const Fr=Object.prototype.toString,{Z_NO_FLUSH:Es,Z_FINISH:As,Z_OK:ci,Z_STREAM_END:Wi,Z_NEED_DICT:Gi,Z_STREAM_ERROR:Ms,Z_DATA_ERROR:Ur,Z_MEM_ERROR:ws}=he;function ui(f){this.options=mi.assign({chunkSize:65536,windowBits:15,to:""},f||{});const G=this.options;G.raw&&G.windowBits>=0&&G.windowBits<16&&(G.windowBits=-G.windowBits,G.windowBits===0&&(G.windowBits=-15)),G.windowBits>=0&&G.windowBits<16&&!(f&&f.windowBits)&&(G.windowBits+=32),G.windowBits>15&&G.windowBits<48&&(G.windowBits&15)===0&&(G.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yi,this.strm.avail_out=0;let b=Gt.inflateInit2(this.strm,G.windowBits);if(b!==ci)throw new Error(le[b]);if(this.header=new ys,Gt.inflateGetHeader(this.strm,this.header),G.dictionary&&(typeof G.dictionary=="string"?G.dictionary=hi.string2buf(G.dictionary):Fr.call(G.dictionary)==="[object ArrayBuffer]"&&(G.dictionary=new Uint8Array(G.dictionary)),G.raw&&(b=Gt.inflateSetDictionary(this.strm,G.dictionary),b!==ci)))throw new Error(le[b])}ui.prototype.push=function(f,G){const b=this.strm,X=this.options.chunkSize,Q=this.options.dictionary;let $,ye,ue;if(this.ended)return!1;for(G===~~G?ye=G:ye=G===!0?As:Es,Fr.call(f)==="[object ArrayBuffer]"?b.input=new Uint8Array(f):b.input=f,b.next_in=0,b.avail_in=b.input.length;;){for(b.avail_out===0&&(b.output=new Uint8Array(X),b.next_out=0,b.avail_out=X),$=Gt.inflate(b,ye),$===Gi&&Q&&($=Gt.inflateSetDictionary(b,Q),$===ci?$=Gt.inflate(b,ye):$===Ur&&($=Gi));b.avail_in>0&&$===Wi&&b.state.wrap>0&&f[b.next_in]!==0;)Gt.inflateReset(b),$=Gt.inflate(b,ye);switch($){case Ms:case Ur:case Gi:case ws:return this.onEnd($),this.ended=!0,!1}if(ue=b.avail_out,b.next_out&&(b.avail_out===0||$===Wi))if(this.options.to==="string"){let Xe=hi.utf8border(b.output,b.next_out),fe=b.next_out-Xe,Ee=hi.buf2string(b.output,Xe);b.next_out=fe,b.avail_out=X-fe,fe&&b.output.set(b.output.subarray(Xe,Xe+fe),0),this.onData(Ee)}else this.onData(b.output.length===b.next_out?b.output:b.output.subarray(0,b.next_out));if(!($===ci&&ue===0)){if($===Wi)return $=Gt.inflateEnd(this.strm),this.onEnd($),this.ended=!0,!0;if(b.avail_in===0)break}}return!0},ui.prototype.onData=function(f){this.chunks.push(f)},ui.prototype.onEnd=function(f){f===ci&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mi.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg};function Ni(f,G){const b=new ui(G);if(b.push(f),b.err)throw b.msg||le[b.err];return b.result}function Cs(f,G){return G=G||{},G.raw=!0,Ni(f,G)}var Ds=ui,Ls=Ni,Ts=Cs,Ss=Ni,Os={Inflate:Ds,inflate:Ls,inflateRaw:Ts,ungzip:Ss};const{Deflate:Ps,deflate:Rs,deflateRaw:Is,gzip:zs}=Vn,{Inflate:Bs,inflate:Fs,inflateRaw:Us,ungzip:Ws}=Os;var Wr=Ps,Gr=Rs,Nr=Is,Vr=zs,jr=Bs,kr=Fs,Hr=Us,Kr=Ws,Zr=he,Gs={Deflate:Wr,deflate:Gr,deflateRaw:Nr,gzip:Vr,Inflate:jr,inflate:kr,inflateRaw:Hr,ungzip:Kr,constants:Zr}},"./node_modules/upng-js/UPNG.js"(K,D,c){(function(){var y={},O;K.exports=y,O=c("./node_modules/upng-js/node_modules/pako/index.js"),(function(w,R){w.toRGBA8=function(p){var E=p.width,M=p.height;if(p.tabs.acTL==null)return[w.toRGBA8.decodeImage(p.data,E,M,p).buffer];var g=[];p.frames[0].data==null&&(p.frames[0].data=p.data);for(var x,_=new Uint8Array(E*M*4),v=0;v<p.frames.length;v++){var m=p.frames[v],r=m.rect.x,e=m.rect.y,t=m.rect.width,s=m.rect.height,o=w.toRGBA8.decodeImage(m.data,t,s,p);if(v==0?x=o:m.blend==0?w._copyTile(o,t,s,x,E,M,r,e,0):m.blend==1&&w._copyTile(o,t,s,x,E,M,r,e,1),g.push(x.buffer),x=x.slice(0),m.dispose!=0){if(m.dispose==1)w._copyTile(_,t,s,x,E,M,r,e,0);else if(m.dispose==2){for(var l=v-1;p.frames[l].dispose==2;)l--;x=new Uint8Array(g[l]).slice(0)}}}return g},w.toRGBA8.decodeImage=function(p,E,M,g){var x=E*M,_=w.decode._getBPP(g),v=Math.ceil(E*_/8),m=new Uint8Array(x*4),r=new Uint32Array(m.buffer),e=g.ctype,t=g.depth,s=w._bin.readUshort;if(e==6){var o=x<<2;if(t==8)for(var l=0;l<o;l++)m[l]=p[l];if(t==16)for(var l=0;l<o;l++)m[l]=p[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]=p[u],m[h+1]=p[u+1],m[h+2]=p[u+2],m[h+3]=255,i!=-1&&p[u]==i&&p[u+1]==n&&p[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]=p[u],m[h+1]=p[u+2],m[h+2]=p[u+4],m[h+3]=255,i!=-1&&s(p,u)==i&&s(p,u+2)==n&&s(p,u+4)==a&&(m[h+3]=0)}}else if(e==3){var A=g.tabs.PLTE,L=g.tabs.tRNS,T=L?L.length:0;if(t==1)for(var S=0;S<M;S++)for(var I=S*v,z=S*E,l=0;l<E;l++){var h=z+l<<2,B=p[I+(l>>3)]>>7-((l&7)<<0)&1,F=3*B;m[h]=A[F],m[h+1]=A[F+1],m[h+2]=A[F+2],m[h+3]=B<T?L[B]:255}if(t==2)for(var S=0;S<M;S++)for(var I=S*v,z=S*E,l=0;l<E;l++){var h=z+l<<2,B=p[I+(l>>2)]>>6-((l&3)<<1)&3,F=3*B;m[h]=A[F],m[h+1]=A[F+1],m[h+2]=A[F+2],m[h+3]=B<T?L[B]:255}if(t==4)for(var S=0;S<M;S++)for(var I=S*v,z=S*E,l=0;l<E;l++){var h=z+l<<2,B=p[I+(l>>1)]>>4-((l&1)<<2)&15,F=3*B;m[h]=A[F],m[h+1]=A[F+1],m[h+2]=A[F+2],m[h+3]=B<T?L[B]:255}if(t==8)for(var l=0;l<x;l++){var h=l<<2,B=p[l],F=3*B;m[h]=A[F],m[h+1]=A[F+1],m[h+2]=A[F+2],m[h+3]=B<T?L[B]:255}}else if(e==4){if(t==8)for(var l=0;l<x;l++){var h=l<<2,W=l<<1,U=p[W];m[h]=U,m[h+1]=U,m[h+2]=U,m[h+3]=p[W+1]}if(t==16)for(var l=0;l<x;l++){var h=l<<2,W=l<<2,U=p[W];m[h]=U,m[h+1]=U,m[h+2]=U,m[h+3]=p[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*(p[l>>3]>>7-(l&7)&1),P=U==i*255?0:255;r[l]=P<<24|U<<16|U<<8|U}if(t==2)for(var l=0;l<x;l++){var U=85*(p[l>>2]>>6-((l&3)<<1)&3),P=U==i*85?0:255;r[l]=P<<24|U<<16|U<<8|U}if(t==4)for(var l=0;l<x;l++){var U=17*(p[l>>1]>>4-((l&1)<<2)&15),P=U==i*17?0:255;r[l]=P<<24|U<<16|U<<8|U}if(t==8)for(var l=0;l<x;l++){var U=p[l],P=U==i?0:255;r[l]=P<<24|U<<16|U<<8|U}if(t==16)for(var l=0;l<x;l++){var U=p[l<<1],P=s(p,l<<1)==i?0:255;r[l]=P<<24|U<<16|U<<8|U}}return m},w.decode=function(p){for(var E=new Uint8Array(p),M=8,g=w._bin,x=g.readUshort,_=g.readUint,v={tabs:{},frames:[]},m=new Uint8Array(E.length),r=0,e,t=0,s=[137,80,78,71,13,10,26,10],o=0;o<8;o++)if(E[o]!=s[o])throw"The input is not a PNG file!";for(;M<E.length;){var l=g.readUint(E,M);M+=4;var d=g.readASCII(E,M,4);if(M+=4,d=="IHDR")w.decode._IHDR(E,M,v);else if(d=="IDAT"){for(var o=0;o<l;o++)m[r+o]=E[M+o];r+=l}else if(d=="acTL")v.tabs[d]={num_frames:_(E,M),num_plays:_(E,M+4)},e=new Uint8Array(E.length);else if(d=="fcTL"){if(t!=0){var i=v.frames[v.frames.length-1];i.data=w.decode._decompress(v,e.slice(0,t),i.rect.width,i.rect.height),t=0}var n={x:_(E,M+12),y:_(E,M+16),width:_(E,M+4),height:_(E,M+8)},a=x(E,M+22);a=x(E,M+20)/(a==0?100:a);var h={rect:n,delay:Math.round(a*1e3),dispose:E[M+24],blend:E[M+25]};v.frames.push(h)}else if(d=="fdAT"){for(var o=0;o<l-4;o++)e[t+o]=E[M+o+4];t+=l-4}else if(d=="pHYs")v.tabs[d]=[g.readUint(E,M),g.readUint(E,M+4),E[M+8]];else if(d=="cHRM"){v.tabs[d]=[];for(var o=0;o<8;o++)v.tabs[d].push(g.readUint(E,M+o*4))}else if(d=="tEXt"){v.tabs[d]==null&&(v.tabs[d]={});var u=g.nextZero(E,M),A=g.readASCII(E,M,u-M),L=g.readASCII(E,u+1,M+l-u-1);v.tabs[d][A]=L}else if(d=="iTXt"){v.tabs[d]==null&&(v.tabs[d]={});var u=0,T=M;u=g.nextZero(E,T);var A=g.readASCII(E,T,u-T);T=u+1,E[T],E[T+1],T+=2,u=g.nextZero(E,T),g.readASCII(E,T,u-T),T=u+1,u=g.nextZero(E,T),g.readUTF8(E,T,u-T),T=u+1;var L=g.readUTF8(E,T,l-(T-M));v.tabs[d][A]=L}else if(d=="PLTE")v.tabs[d]=g.readBytes(E,M,l);else if(d=="hIST"){var S=v.tabs.PLTE.length/3;v.tabs[d]=[];for(var o=0;o<S;o++)v.tabs[d].push(x(E,M+o*2))}else if(d=="tRNS")v.ctype==3?v.tabs[d]=g.readBytes(E,M,l):v.ctype==0?v.tabs[d]=x(E,M):v.ctype==2&&(v.tabs[d]=[x(E,M),x(E,M+2),x(E,M+4)]);else if(d=="gAMA")v.tabs[d]=g.readUint(E,M)/1e5;else if(d=="sRGB")v.tabs[d]=E[M];else if(d=="bKGD")v.ctype==0||v.ctype==4?v.tabs[d]=[x(E,M)]:v.ctype==2||v.ctype==6?v.tabs[d]=[x(E,M),x(E,M+2),x(E,M+4)]:v.ctype==3&&(v.tabs[d]=E[M]);else if(d=="IEND"){if(t!=0){var i=v.frames[v.frames.length-1];i.data=w.decode._decompress(v,e.slice(0,t),i.rect.width,i.rect.height),t=0}v.data=w.decode._decompress(v,m,v.width,v.height);break}M+=l,g.readUint(E,M),M+=4}return delete v.compress,delete v.interlace,delete v.filter,v},w.decode._decompress=function(p,E,M,g){return p.compress==0&&(E=w.decode._inflate(E)),p.interlace==0?E=w.decode._filterZero(E,p,0,M,g):p.interlace==1&&(E=w.decode._readInterlace(E,p)),E},w.decode._inflate=function(p){return R.inflate(p)},w.decode._readInterlace=function(p,E){for(var M=E.width,g=E.height,x=w.decode._getBPP(E),_=x>>3,v=Math.ceil(M*x/8),m=new Uint8Array(g*v),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);w.decode._filterZero(p,E,r,n,a);for(var L=0,T=e[l];T<g;){for(var S=t[l],I=r+L*A<<3;S<M;){if(x==1){var z=p[I>>3];z=z>>7-(I&7)&1,m[T*v+(S>>3)]|=z<<7-((S&3)<<0)}if(x==2){var z=p[I>>3];z=z>>6-(I&7)&3,m[T*v+(S>>2)]|=z<<6-((S&3)<<1)}if(x==4){var z=p[I>>3];z=z>>4-(I&7)&15,m[T*v+(S>>1)]|=z<<4-((S&1)<<2)}if(x>=8)for(var B=T*v+S*_,F=0;F<_;F++)m[B+F]=p[(I>>3)+F];I+=x,S+=i}L++,T+=d}n*a!=0&&(r+=a*(1+A)),l=l+1}return m},w.decode._getBPP=function(p){var E=[1,null,3,1,2,null,4][p.ctype];return E*p.depth},w.decode._filterZero=function(p,E,M,g,x){var _=w.decode._getBPP(E),v=Math.ceil(g*_/8),m=w.decode._paeth;_=Math.ceil(_/8);for(var r=0;r<x;r++){var e=M+r*v,t=e+r+1,s=p[t-1];if(s==0)for(var o=0;o<v;o++)p[e+o]=p[t+o];else if(s==1){for(var o=0;o<_;o++)p[e+o]=p[t+o];for(var o=_;o<v;o++)p[e+o]=p[t+o]+p[e+o-_]&255}else if(r==0){for(var o=0;o<_;o++)p[e+o]=p[t+o];if(s==2)for(var o=_;o<v;o++)p[e+o]=p[t+o]&255;if(s==3)for(var o=_;o<v;o++)p[e+o]=p[t+o]+(p[e+o-_]>>1)&255;if(s==4)for(var o=_;o<v;o++)p[e+o]=p[t+o]+m(p[e+o-_],0,0)&255}else{if(s==2)for(var o=0;o<v;o++)p[e+o]=p[t+o]+p[e+o-v]&255;if(s==3){for(var o=0;o<_;o++)p[e+o]=p[t+o]+(p[e+o-v]>>1)&255;for(var o=_;o<v;o++)p[e+o]=p[t+o]+(p[e+o-v]+p[e+o-_]>>1)&255}if(s==4){for(var o=0;o<_;o++)p[e+o]=p[t+o]+m(0,p[e+o-v],0)&255;for(var o=_;o<v;o++)p[e+o]=p[t+o]+m(p[e+o-_],p[e+o-v],p[e+o-_-v])&255}}}return p},w.decode._paeth=function(p,E,M){var g=p+E-M,x=Math.abs(g-p),_=Math.abs(g-E),v=Math.abs(g-M);return x<=_&&x<=v?p:_<=v?E:M},w.decode._IHDR=function(p,E,M){var g=w._bin;M.width=g.readUint(p,E),E+=4,M.height=g.readUint(p,E),E+=4,M.depth=p[E],E++,M.ctype=p[E],E++,M.compress=p[E],E++,M.filter=p[E],E++,M.interlace=p[E],E++},w._bin={nextZero:function(p,E){for(;p[E]!=0;)E++;return E},readUshort:function(p,E){return p[E]<<8|p[E+1]},writeUshort:function(p,E,M){p[E]=M>>8&255,p[E+1]=M&255},readUint:function(p,E){return p[E]*16777216+(p[E+1]<<16|p[E+2]<<8|p[E+3])},writeUint:function(p,E,M){p[E]=M>>24&255,p[E+1]=M>>16&255,p[E+2]=M>>8&255,p[E+3]=M&255},readASCII:function(p,E,M){for(var g="",x=0;x<M;x++)g+=String.fromCharCode(p[E+x]);return g},writeASCII:function(p,E,M){for(var g=0;g<M.length;g++)p[E+g]=M.charCodeAt(g)},readBytes:function(p,E,M){for(var g=[],x=0;x<M;x++)g.push(p[E+x]);return g},pad:function(p){return p.length<2?"0"+p:p},readUTF8:function(p,E,M){for(var g="",x,_=0;_<M;_++)g+="%"+w._bin.pad(p[E+_].toString(16));try{x=decodeURIComponent(g)}catch{return w._bin.readASCII(p,E,M)}return x}},w._copyTile=function(p,E,M,g,x,_,v,m,r){for(var e=Math.min(E,x),t=Math.min(M,_),s=0,o=0,l=0;l<t;l++)for(var d=0;d<e;d++)if(v>=0&&m>=0?(s=l*E+d<<2,o=(m+l)*x+v+d<<2):(s=(-m+l)*E-v+d<<2,o=l*x+d<<2),r==0)g[o]=p[s],g[o+1]=p[s+1],g[o+2]=p[s+2],g[o+3]=p[s+3];else if(r==1){var i=p[s+3]*.00392156862745098,n=p[s]*i,a=p[s+1]*i,h=p[s+2]*i,u=g[o+3]*(1/255),A=g[o]*u,L=g[o+1]*u,T=g[o+2]*u,S=1-i,I=i+u*S,z=I==0?0:1/I;g[o+3]=255*I,g[o+0]=(n+A*S)*z,g[o+1]=(a+L*S)*z,g[o+2]=(h+T*S)*z}else if(r==2){var i=p[s+3],n=p[s],a=p[s+1],h=p[s+2],u=g[o+3],A=g[o],L=g[o+1],T=g[o+2];i==u&&n==A&&a==L&&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=p[s+3],n=p[s],a=p[s+1],h=p[s+2],u=g[o+3],A=g[o],L=g[o+1],T=g[o+2];if(i==u&&n==A&&a==L&&h==T)continue;if(i<220&&u>20)return!1}return!0},w.encode=function(p,E,M,g,x,_){g==null&&(g=0),_==null&&(_=!1);for(var v=new Uint8Array(p[0].byteLength*p.length+100),m=[137,80,78,71,13,10,26,10],r=0;r<8;r++)v[r]=m[r];var e=8,t=w._bin,s=w.crc.crc,o=t.writeUint,l=t.writeUshort,d=t.writeASCII,i=w.encode.compressPNG(p,E,M,g,_);o(v,e,13),e+=4,d(v,e,"IHDR"),e+=4,o(v,e,E),e+=4,o(v,e,M),e+=4,v[e]=i.depth,e++,v[e]=i.ctype,e++,v[e]=0,e++,v[e]=0,e++,v[e]=0,e++,o(v,e,s(v,e-17,17)),e+=4,o(v,e,1),e+=4,d(v,e,"sRGB"),e+=4,v[e]=1,e++,o(v,e,s(v,e-5,5)),e+=4;var n=p.length>1;if(n&&(o(v,e,8),e+=4,d(v,e,"acTL"),e+=4,o(v,e,p.length),e+=4,o(v,e,0),e+=4,o(v,e,s(v,e-12,12)),e+=4),i.ctype==3){var a=i.plte.length;o(v,e,a*3),e+=4,d(v,e,"PLTE"),e+=4;for(var r=0;r<a;r++){var h=r*3,u=i.plte[r],A=u&255,L=u>>8&255,T=u>>16&255;v[e+h+0]=A,v[e+h+1]=L,v[e+h+2]=T}if(e+=a*3,o(v,e,s(v,e-a*3-4,a*3+4)),e+=4,i.gotAlpha){o(v,e,a),e+=4,d(v,e,"tRNS"),e+=4;for(var r=0;r<a;r++)v[e+r]=i.plte[r]>>24&255;e+=a,o(v,e,s(v,e-a-4,a+4)),e+=4}}for(var S=0,I=0;I<i.frames.length;I++){var z=i.frames[I];n&&(o(v,e,26),e+=4,d(v,e,"fcTL"),e+=4,o(v,e,S++),e+=4,o(v,e,z.rect.width),e+=4,o(v,e,z.rect.height),e+=4,o(v,e,z.rect.x),e+=4,o(v,e,z.rect.y),e+=4,l(v,e,x[I]),e+=2,l(v,e,1e3),e+=2,v[e]=z.dispose,e++,v[e]=z.blend,e++,o(v,e,s(v,e-30,30)),e+=4);var B=z.cimg,a=B.length;o(v,e,a+(I==0?0:4)),e+=4;var F=e;d(v,e,I==0?"IDAT":"fdAT"),e+=4,I!=0&&(o(v,e,S++),e+=4);for(var r=0;r<a;r++)v[e+r]=B[r];e+=a,o(v,e,s(v,F,e-F)),e+=4}return o(v,e,0),e+=4,d(v,e,"IEND"),e+=4,o(v,e,s(v,e-4,4)),e+=4,v.buffer.slice(0,e)},w.encode.compressPNG=function(p,E,M,g,x){for(var _=w.encode.compress(p,E,M,g,!1,x),v=0;v<p.length;v++){var m=_.frames[v];m.rect.width;var r=m.rect.height,e=m.bpl,t=m.bpp,s=new Uint8Array(r*e+r);m.cimg=w.encode._filterZero(m.img,r,t,e,s)}return _},w.encode.compress=function(p,E,M,g,x,_){_==null&&(_=!1);for(var v=6,m=8,r=4,e=255,t=0;t<p.length;t++)for(var s=new Uint8Array(p[t]),o=s.length,l=0;l<o;l+=4)e&=s[l+3];var d=e!=255,i={},n=[];if(p.length!=0&&(i[0]=0,n.push(0),g!=0&&g--),g!=0){var a=w.quantize(p,g,x);p=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<p.length;t++)for(var u=new Uint32Array(p[t]),o=u.length,l=0;l<o;l++){var h=u[l];if((l<E||h!=u[l-1]&&h!=u[l-E])&&i[h]==null&&(i[h]=n.length,n.push(h),n.length>=300))break}var A=d?x:!1,L=n.length;L<=256&&_==!1&&(L<=2?m=1:L<=4?m=2:L<=16?m=4:m=8,x&&(m=8),d=!0);for(var T=[],t=0;t<p.length;t++){var S=new Uint8Array(p[t]),I=new Uint32Array(S.buffer),z=0,B=0,F=E,W=M,U=0;if(t!=0&&!A){for(var P=x||t==1||T[T.length-2].dispose==2?1:2,N=0,q=1e9,ee=0;ee<P;ee++){for(var Me=new Uint8Array(p[t-1-ee]),ie=new Uint32Array(p[t-1-ee]),ne=E,de=M,re=-1,oe=-1,be=0;be<M;be++)for(var _e=0;_e<E;_e++){var l=be*E+_e;I[l]!=ie[l]&&(_e<ne&&(ne=_e),_e>re&&(re=_e),be<de&&(de=be),be>oe&&(oe=be))}var Oe=re==-1?1:(re-ne+1)*(oe-de+1);Oe<q&&(q=Oe,N=ee,re==-1?(z=B=0,F=W=1):(z=ne,B=de,F=re-ne+1,W=oe-de+1))}var Me=new Uint8Array(p[t-1-N]);N==1&&(T[T.length-1].dispose=2);var J=new Uint8Array(F*W*4);new Uint32Array(J.buffer),w._copyTile(Me,E,M,J,F,W,-z,-B,0),w._copyTile(S,E,M,J,F,W,-z,-B,3)?(w._copyTile(S,E,M,J,F,W,-z,-B,2),U=1):(w._copyTile(S,E,M,J,F,W,-z,-B,0),U=0),S=J,I=new Uint32Array(S.buffer)}var ve=4*F;if(L<=256&&_==!1){ve=Math.ceil(m*F/8);for(var J=new Uint8Array(ve*W),be=0;be<W;be++){var l=be*ve,Ce=be*F;if(m==8)for(var _e=0;_e<F;_e++)J[l+_e]=i[I[Ce+_e]];else if(m==4)for(var _e=0;_e<F;_e++)J[l+(_e>>1)]|=i[I[Ce+_e]]<<4-(_e&1)*4;else if(m==2)for(var _e=0;_e<F;_e++)J[l+(_e>>2)]|=i[I[Ce+_e]]<<6-(_e&3)*2;else if(m==1)for(var _e=0;_e<F;_e++)J[l+(_e>>3)]|=i[I[Ce+_e]]<<7-(_e&7)*1}S=J,v=3,r=1}else if(d==!1&&p.length==1){for(var J=new Uint8Array(F*W*3),Te=F*W,l=0;l<Te;l++){var We=l*3,Ie=l*4;J[We]=S[Ie],J[We+1]=S[Ie+1],J[We+2]=S[Ie+2]}S=J,v=2,r=3,ve=3*F}T.push({rect:{x:z,y:B,width:F,height:W},img:S,bpl:ve,bpp:r,blend:U,dispose:A?1:0})}return{ctype:v,depth:m,plte:n,gotAlpha:d,frames:T}},w.encode._filterZero=function(p,E,M,g,x){for(var _=[],v=0;v<5;v++)if(!(E*g>5e5&&(v==2||v==3||v==4))){for(var m=0;m<E;m++)w.encode._filterLine(x,p,m,g,M,v);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]},w.encode._filterLine=function(p,E,M,g,x,_){var v=M*g,m=v+M,r=w.decode._paeth;if(p[m]=_,m++,_==0)for(var e=0;e<g;e++)p[m+e]=E[v+e];else if(_==1){for(var e=0;e<x;e++)p[m+e]=E[v+e];for(var e=x;e<g;e++)p[m+e]=E[v+e]-E[v+e-x]+256&255}else if(M==0){for(var e=0;e<x;e++)p[m+e]=E[v+e];if(_==2)for(var e=x;e<g;e++)p[m+e]=E[v+e];if(_==3)for(var e=x;e<g;e++)p[m+e]=E[v+e]-(E[v+e-x]>>1)+256&255;if(_==4)for(var e=x;e<g;e++)p[m+e]=E[v+e]-r(E[v+e-x],0,0)+256&255}else{if(_==2)for(var e=0;e<g;e++)p[m+e]=E[v+e]+256-E[v+e-g]&255;if(_==3){for(var e=0;e<x;e++)p[m+e]=E[v+e]+256-(E[v+e-g]>>1)&255;for(var e=x;e<g;e++)p[m+e]=E[v+e]+256-(E[v+e-g]+E[v+e-x]>>1)&255}if(_==4){for(var e=0;e<x;e++)p[m+e]=E[v+e]+256-r(0,E[v+e-g],0)&255;for(var e=x;e<g;e++)p[m+e]=E[v+e]+256-r(E[v+e-x],E[v+e-g],E[v+e-x-g])&255}}},w.crc={table:(function(){for(var p=new Uint32Array(256),E=0;E<256;E++){for(var M=E,g=0;g<8;g++)M&1?M=3988292384^M>>>1:M=M>>>1;p[E]=M}return p})(),update:function(p,E,M,g){for(var x=0;x<g;x++)p=w.crc.table[(p^E[M+x])&255]^p>>>8;return p},crc:function(p,E,M){return w.crc.update(4294967295,p,E,M)^4294967295}},w.quantize=function(p,E,M){for(var g=[],x=0,_=0;_<p.length;_++)g.push(w.encode.alphaMul(new Uint8Array(p[_]),M)),x+=p[_].byteLength;for(var v=new Uint8Array(x),m=new Uint32Array(v.buffer),r=0,_=0;_<g.length;_++){for(var e=g[_],t=e.length,s=0;s<t;s++)v[r+s]=e[s];r+=t}var o={i0:0,i1:v.length,bst:null,est:null,tdst:0,left:null,right:null};o.bst=w.quantize.stats(v,o.i0,o.i1),o.est=w.quantize.estats(o.bst);for(var l=[o];l.length<E;){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=w.quantize.splitPixels(v,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=w.quantize.stats(v,h.i0,h.i1),h.est=w.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=w.quantize.estats(u.bst),n.left=h,n.right=u,l[i]=h,l.push(u)}l.sort(function(P,N){return N.bst.N-P.bst.N});for(var A=0;A<g.length;A++){for(var L=w.quantize.planeDst,T=new Uint8Array(g[A].buffer),S=new Uint32Array(g[A].buffer),I=T.length,_=0;_<I;_+=4){for(var z=T[_]*.00392156862745098,B=T[_+1]*(1/255),F=T[_+2]*(1/255),W=T[_+3]*(1/255),U=o;U.left;)U=L(U.est,z,B,F,W)<=0?U.left:U.right;S[_>>2]=U.est.rgba}g[A]=S.buffer}return{bufs:g,plte:l}},w.quantize.getNearest=function(p,E,M,g,x){if(p.left==null)return p.tdst=w.quantize.dist(p.est.q,E,M,g,x),p;var _=w.quantize.planeDst(p.est,E,M,g,x),v=p.left,m=p.right;_>0&&(v=p.right,m=p.left);var r=w.quantize.getNearest(v,E,M,g,x);if(r.tdst<=_*_)return r;var e=w.quantize.getNearest(m,E,M,g,x);return e.tdst<r.tdst?e:r},w.quantize.planeDst=function(p,E,M,g,x){var _=p.e;return _[0]*E+_[1]*M+_[2]*g+_[3]*x-p.eMq},w.quantize.dist=function(p,E,M,g,x){var _=E-p[0],v=M-p[1],m=g-p[2],r=x-p[3];return _*_+v*v+m*m+r*r},w.quantize.splitPixels=function(p,E,M,g,x,_){var v=w.quantize.vecDot;for(g-=4;M<g;){for(;v(p,M,x)<=_;)M+=4;for(;v(p,g,x)>_;)g-=4;if(M>=g)break;var m=E[M>>2];E[M>>2]=E[g>>2],E[g>>2]=m,M+=4,g-=4}for(;v(p,M,x)>_;)M-=4;return M+4},w.quantize.vecDot=function(p,E,M){return p[E]*M[0]+p[E+1]*M[1]+p[E+2]*M[2]+p[E+3]*M[3]},w.quantize.stats=function(p,E,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-E>>2,v=E;v<M;v+=4){var m=p[v]*.00392156862745098,r=p[v+1]*(1/255),e=p[v+2]*(1/255),t=p[v+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:_}},w.quantize.estats=function(p){var E=p.R,M=p.m,g=p.N,x=M[0],_=M[1],v=M[2],m=M[3],r=g==0?0:1/g,e=[E[0]-x*x*r,E[1]-x*_*r,E[2]-x*v*r,E[3]-x*m*r,E[4]-_*x*r,E[5]-_*_*r,E[6]-_*v*r,E[7]-_*m*r,E[8]-v*x*r,E[9]-v*_*r,E[10]-v*v*r,E[11]-v*m*r,E[12]-m*x*r,E[13]-m*_*r,E[14]-m*v*r,E[15]-m*m*r],t=e,s=w.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,v*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}},w.M4={multVec:function(p,E){return[p[0]*E[0]+p[1]*E[1]+p[2]*E[2]+p[3]*E[3],p[4]*E[0]+p[5]*E[1]+p[6]*E[2]+p[7]*E[3],p[8]*E[0]+p[9]*E[1]+p[10]*E[2]+p[11]*E[3],p[12]*E[0]+p[13]*E[1]+p[14]*E[2]+p[15]*E[3]]},dot:function(p,E){return p[0]*E[0]+p[1]*E[1]+p[2]*E[2]+p[3]*E[3]},sml:function(p,E){return[p*E[0],p*E[1],p*E[2],p*E[3]]}},w.encode.alphaMul=function(p,E){for(var M=new Uint8Array(p.length),g=p.length>>2,x=0;x<g;x++){var _=x<<2,v=p[_+3];E&&(v=v<128?0:255);var m=v*(1/255);M[_+0]=p[_+0]*m,M[_+1]=p[_+1]*m,M[_+2]=p[_+2]*m,M[_+3]=v}return M}})(y,O)})()},"./node_modules/upng-js/node_modules/pako/index.js"(K,D,c){var y=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"),w=c("./node_modules/upng-js/node_modules/pako/lib/inflate.js"),R=c("./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js"),p={};y(p,O,w,R),K.exports=p},"./node_modules/upng-js/node_modules/pako/lib/deflate.js"(K,D,c){var y=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"),w=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"),p=c("./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js"),E=Object.prototype.toString,M=0,g=4,x=0,_=1,v=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 p,this.strm.avail_out=0;var n=y.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(n!==x)throw new Error(R[n]);if(i.header&&y.deflateSetHeader(this.strm,i.header),i.dictionary){var a;if(typeof i.dictionary=="string"?a=w.string2buf(i.dictionary):E.call(i.dictionary)==="[object ArrayBuffer]"?a=new Uint8Array(i.dictionary):a=i.dictionary,n=y.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=w.string2buf(d):E.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=y.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===v))&&(this.options.to==="string"?this.onData(w.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=y.deflateEnd(this.strm),this.onEnd(h),this.ended=!0,h===x):(u===v&&(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)}D.Deflate=t,D.deflate=s,D.deflateRaw=o,D.gzip=l},"./node_modules/upng-js/node_modules/pako/lib/inflate.js"(K,D,c){var y=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"),w=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"),p=c("./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"),E=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 E,this.strm.avail_out=0;var e=y.inflateInit2(this.strm,r.windowBits);if(e!==R.Z_OK)throw new Error(p[e]);if(this.header=new M,y.inflateGetHeader(this.strm,this.header),r.dictionary&&(typeof r.dictionary=="string"?r.dictionary=w.string2buf(r.dictionary):g.call(r.dictionary)==="[object ArrayBuffer]"&&(r.dictionary=new Uint8Array(r.dictionary)),r.raw&&(e=y.inflateSetDictionary(this.strm,r.dictionary),e!==R.Z_OK)))throw new Error(p[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=w.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=y.inflate(e,R.Z_NO_FLUSH),o===R.Z_NEED_DICT&&s&&(o=y.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=w.utf8border(e.output,e.next_out),i=e.next_out-d,n=w.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=y.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||p[e.err];return e.result}function v(m,r){return r=r||{},r.raw=!0,_(m,r)}D.Inflate=x,D.inflate=_,D.inflateRaw=v,D.ungzip=_},"./node_modules/upng-js/node_modules/pako/lib/utils/common.js"(K,D){var c=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function y(R,p){return Object.prototype.hasOwnProperty.call(R,p)}D.assign=function(R){for(var p=Array.prototype.slice.call(arguments,1);p.length;){var E=p.shift();if(E){if(typeof E!="object")throw new TypeError(E+"must be non-object");for(var M in E)y(E,M)&&(R[M]=E[M])}}return R},D.shrinkBuf=function(R,p){return R.length===p?R:R.subarray?R.subarray(0,p):(R.length=p,R)};var O={arraySet:function(R,p,E,M,g){if(p.subarray&&R.subarray){R.set(p.subarray(E,E+M),g);return}for(var x=0;x<M;x++)R[g+x]=p[E+x]},flattenChunks:function(R){var p,E,M,g,x,_;for(M=0,p=0,E=R.length;p<E;p++)M+=R[p].length;for(_=new Uint8Array(M),g=0,p=0,E=R.length;p<E;p++)x=R[p],_.set(x,g),g+=x.length;return _}},w={arraySet:function(R,p,E,M,g){for(var x=0;x<M;x++)R[g+x]=p[E+x]},flattenChunks:function(R){return[].concat.apply([],R)}};D.setTyped=function(R){R?(D.Buf8=Uint8Array,D.Buf16=Uint16Array,D.Buf32=Int32Array,D.assign(D,O)):(D.Buf8=Array,D.Buf16=Array,D.Buf32=Array,D.assign(D,w))},D.setTyped(c)},"./node_modules/upng-js/node_modules/pako/lib/utils/strings.js"(K,D,c){var y=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=!0,w=!0;try{String.fromCharCode.apply(null,[0])}catch{O=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{w=!1}for(var R=new y.Buf8(256),p=0;p<256;p++)R[p]=p>=252?6:p>=248?5:p>=240?4:p>=224?3:p>=192?2:1;R[254]=R[254]=1,D.string2buf=function(M){var g,x,_,v,m,r=M.length,e=0;for(v=0;v<r;v++)x=M.charCodeAt(v),(x&64512)===55296&&v+1<r&&(_=M.charCodeAt(v+1),(_&64512)===56320&&(x=65536+(x-55296<<10)+(_-56320),v++)),e+=x<128?1:x<2048?2:x<65536?3:4;for(g=new y.Buf8(e),m=0,v=0;m<e;v++)x=M.charCodeAt(v),(x&64512)===55296&&v+1<r&&(_=M.charCodeAt(v+1),(_&64512)===56320&&(x=65536+(x-55296<<10)+(_-56320),v++)),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 E(M,g){if(g<65534&&(M.subarray&&w||!M.subarray&&O))return String.fromCharCode.apply(null,y.shrinkBuf(M,g));for(var x="",_=0;_<g;_++)x+=String.fromCharCode(M[_]);return x}D.buf2binstring=function(M){return E(M,M.length)},D.binstring2buf=function(M){for(var g=new y.Buf8(M.length),x=0,_=g.length;x<_;x++)g[x]=M.charCodeAt(x);return g},D.buf2string=function(M,g){var x,_,v,m,r=g||M.length,e=new Array(r*2);for(_=0,x=0;x<r;){if(v=M[x++],v<128){e[_++]=v;continue}if(m=R[v],m>4){e[_++]=65533,x+=m-1;continue}for(v&=m===2?31:m===3?15:7;m>1&&x<r;)v=v<<6|M[x++]&63,m--;if(m>1){e[_++]=65533;continue}v<65536?e[_++]=v:(v-=65536,e[_++]=55296|v>>10&1023,e[_++]=56320|v&1023)}return E(e,_)},D.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 D(c,y,O,w){for(var R=c&65535|0,p=c>>>16&65535|0,E=0;O!==0;){E=O>2e3?2e3:O,O-=E;do R=R+y[w++]|0,p=p+R|0;while(--E);R%=65521,p%=65521}return R|p<<16|0}K.exports=D},"./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 D(){for(var O,w=[],R=0;R<256;R++){O=R;for(var p=0;p<8;p++)O=O&1?3988292384^O>>>1:O>>>1;w[R]=O}return w}var c=D();function y(O,w,R,p){var E=c,M=p+R;O^=-1;for(var g=p;g<M;g++)O=O>>>8^E[(O^w[g])&255];return O^-1}K.exports=y},"./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js"(K,D,c){var y=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"),w=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"),p=c("./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js"),E=0,M=1,g=3,x=4,_=5,v=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,L=8,T=29,S=256,I=S+1+T,z=30,B=19,F=2*I+1,W=15,U=3,P=258,N=P+U+1,q=32,ee=42,ie=69,ne=73,de=91,re=103,oe=113,be=666,_e=1,Oe=2,Me=3,J=4,ve=3;function Ce(C,le){return C.msg=p[le],le}function Te(C){return(C<<1)-(C>4?9:0)}function We(C){for(var le=C.length;--le>=0;)C[le]=0}function Ie(C){var le=C.state,he=le.pending;he>C.avail_out&&(he=C.avail_out),he!==0&&(y.arraySet(C.output,le.pending_buf,le.pending_out,he,C.next_out),C.next_out+=he,le.pending_out+=he,C.total_out+=he,C.avail_out-=he,le.pending-=he,le.pending===0&&(le.pending_out=0))}function Fe(C,le){O._tr_flush_block(C,C.block_start>=0?C.block_start:-1,C.strstart-C.block_start,le),C.block_start=C.strstart,Ie(C.strm)}function Be(C,le){C.pending_buf[C.pending++]=le}function ze(C,le){C.pending_buf[C.pending++]=le>>>8&255,C.pending_buf[C.pending++]=le&255}function Re(C,le,he,k){var ae=C.avail_in;return ae>k&&(ae=k),ae===0?0:(C.avail_in-=ae,y.arraySet(le,C.input,C.next_in,ae,he),C.state.wrap===1?C.adler=w(C.adler,le,ae,he):C.state.wrap===2&&(C.adler=R(C.adler,le,ae,he)),C.next_in+=ae,C.total_in+=ae,ae)}function Pe(C,le){var he=C.max_chain_length,k=C.strstart,ae,pe,Ve=C.prev_length,Ne=C.nice_match,Ge=C.strstart>C.w_size-N?C.strstart-(C.w_size-N):0,qe=C.window,_t=C.w_mask,Ye=C.prev,He=C.strstart+P,$e=qe[k+Ve-1],tt=qe[k+Ve];C.prev_length>=C.good_match&&(he>>=2),Ne>C.lookahead&&(Ne=C.lookahead);do if(ae=le,!(qe[ae+Ve]!==tt||qe[ae+Ve-1]!==$e||qe[ae]!==qe[k]||qe[++ae]!==qe[k+1])){k+=2,ae++;do;while(qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&qe[++k]===qe[++ae]&&k<He);if(pe=P-(He-k),k=He-P,pe>Ve){if(C.match_start=le,Ve=pe,pe>=Ne)break;$e=qe[k+Ve-1],tt=qe[k+Ve]}}while((le=Ye[le&_t])>Ge&&--he!==0);return Ve<=C.lookahead?Ve:C.lookahead}function je(C){var le=C.w_size,he,k,ae,pe,Ve;do{if(pe=C.window_size-C.lookahead-C.strstart,C.strstart>=le+(le-N)){y.arraySet(C.window,C.window,le,le,0),C.match_start-=le,C.strstart-=le,C.block_start-=le,k=C.hash_size,he=k;do ae=C.head[--he],C.head[he]=ae>=le?ae-le:0;while(--k);k=le,he=k;do ae=C.prev[--he],C.prev[he]=ae>=le?ae-le:0;while(--k);pe+=le}if(C.strm.avail_in===0)break;if(k=Re(C.strm,C.window,C.strstart+C.lookahead,pe),C.lookahead+=k,C.lookahead+C.insert>=U)for(Ve=C.strstart-C.insert,C.ins_h=C.window[Ve],C.ins_h=(C.ins_h<<C.hash_shift^C.window[Ve+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[Ve+U-1])&C.hash_mask,C.prev[Ve&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=Ve,Ve++,C.insert--,!(C.lookahead+C.insert<U)););}while(C.lookahead<N&&C.strm.avail_in!==0)}function ke(C,le){var he=65535;for(he>C.pending_buf_size-5&&(he=C.pending_buf_size-5);;){if(C.lookahead<=1){if(je(C),C.lookahead===0&&le===E)return _e;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var k=C.block_start+he;if((C.strstart===0||C.strstart>=k)&&(C.lookahead=C.strstart-k,C.strstart=k,Fe(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-N&&(Fe(C,!1),C.strm.avail_out===0))return _e}return C.insert=0,le===x?(Fe(C,!0),C.strm.avail_out===0?Me:J):(C.strstart>C.block_start&&(Fe(C,!1),C.strm.avail_out===0),_e)}function H(C,le){for(var he,k;;){if(C.lookahead<N){if(je(C),C.lookahead<N&&le===E)return _e;if(C.lookahead===0)break}if(he=0,C.lookahead>=U&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+U-1])&C.hash_mask,he=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),he!==0&&C.strstart-he<=C.w_size-N&&(C.match_length=Pe(C,he)),C.match_length>=U)if(k=O._tr_tally(C,C.strstart-C.match_start,C.match_length-U),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=U){C.match_length--;do C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+U-1])&C.hash_mask,he=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart;while(--C.match_length!==0);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else k=O._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(k&&(Fe(C,!1),C.strm.avail_out===0))return _e}return C.insert=C.strstart<U-1?C.strstart:U-1,le===x?(Fe(C,!0),C.strm.avail_out===0?Me:J):C.last_lit&&(Fe(C,!1),C.strm.avail_out===0)?_e:Oe}function Z(C,le){for(var he,k,ae;;){if(C.lookahead<N){if(je(C),C.lookahead<N&&le===E)return _e;if(C.lookahead===0)break}if(he=0,C.lookahead>=U&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+U-1])&C.hash_mask,he=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=U-1,he!==0&&C.prev_length<C.max_lazy_match&&C.strstart-he<=C.w_size-N&&(C.match_length=Pe(C,he),C.match_length<=5&&(C.strategy===o||C.match_length===U&&C.strstart-C.match_start>4096)&&(C.match_length=U-1)),C.prev_length>=U&&C.match_length<=C.prev_length){ae=C.strstart+C.lookahead-U,k=O._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-U),C.lookahead-=C.prev_length-1,C.prev_length-=2;do++C.strstart<=ae&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+U-1])&C.hash_mask,he=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart);while(--C.prev_length!==0);if(C.match_available=0,C.match_length=U-1,C.strstart++,k&&(Fe(C,!1),C.strm.avail_out===0))return _e}else if(C.match_available){if(k=O._tr_tally(C,0,C.window[C.strstart-1]),k&&Fe(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return _e}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(k=O._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<U-1?C.strstart:U-1,le===x?(Fe(C,!0),C.strm.avail_out===0?Me:J):C.last_lit&&(Fe(C,!1),C.strm.avail_out===0)?_e:Oe}function Y(C,le){for(var he,k,ae,pe,Ve=C.window;;){if(C.lookahead<=P){if(je(C),C.lookahead<=P&&le===E)return _e;if(C.lookahead===0)break}if(C.match_length=0,C.lookahead>=U&&C.strstart>0&&(ae=C.strstart-1,k=Ve[ae],k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae])){pe=C.strstart+P;do;while(k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&k===Ve[++ae]&&ae<pe);C.match_length=P-(pe-ae),C.match_length>C.lookahead&&(C.match_length=C.lookahead)}if(C.match_length>=U?(he=O._tr_tally(C,1,C.match_length-U),C.lookahead-=C.match_length,C.strstart+=C.match_length,C.match_length=0):(he=O._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++),he&&(Fe(C,!1),C.strm.avail_out===0))return _e}return C.insert=0,le===x?(Fe(C,!0),C.strm.avail_out===0?Me:J):C.last_lit&&(Fe(C,!1),C.strm.avail_out===0)?_e:Oe}function me(C,le){for(var he;;){if(C.lookahead===0&&(je(C),C.lookahead===0)){if(le===E)return _e;break}if(C.match_length=0,he=O._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++,he&&(Fe(C,!1),C.strm.avail_out===0))return _e}return C.insert=0,le===x?(Fe(C,!0),C.strm.avail_out===0?Me:J):C.last_lit&&(Fe(C,!1),C.strm.avail_out===0)?_e:Oe}function ce(C,le,he,k,ae){this.good_length=C,this.max_lazy=le,this.nice_length=he,this.max_chain=k,this.func=ae}var Ae;Ae=[new ce(0,0,0,0,ke),new ce(4,4,8,4,H),new ce(4,5,16,8,H),new ce(4,6,32,32,H),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(C){C.window_size=2*C.w_size,We(C.head),C.max_lazy_match=Ae[C.level].max_lazy,C.good_match=Ae[C.level].good_length,C.nice_match=Ae[C.level].nice_length,C.max_chain_length=Ae[C.level].max_chain,C.strstart=0,C.block_start=0,C.lookahead=0,C.insert=0,C.match_length=C.prev_length=U-1,C.match_available=0,C.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 y.Buf16(F*2),this.dyn_dtree=new y.Buf16((2*z+1)*2),this.bl_tree=new y.Buf16((2*B+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 y.Buf16(W+1),this.heap=new y.Buf16(2*I+1),We(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new y.Buf16(2*I+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(C){var le;return!C||!C.state?Ce(C,r):(C.total_in=C.total_out=0,C.data_type=a,le=C.state,le.pending=0,le.pending_out=0,le.wrap<0&&(le.wrap=-le.wrap),le.status=le.wrap?ee:oe,C.adler=le.wrap===2?0:1,le.last_flush=E,O._tr_init(le),v)}function ge(C){var le=se(C);return le===v&&we(C.state),le}function Se(C,le){return!C||!C.state||C.state.wrap!==2?r:(C.state.gzhead=le,v)}function te(C,le,he,k,ae,pe){if(!C)return r;var Ve=1;if(le===s&&(le=6),k<0?(Ve=0,k=-k):k>15&&(Ve=2,k-=16),ae<1||ae>u||he!==h||k<8||k>15||le<0||le>9||pe<0||pe>i)return Ce(C,r);k===8&&(k=9);var Ne=new j;return C.state=Ne,Ne.strm=C,Ne.wrap=Ve,Ne.gzhead=null,Ne.w_bits=k,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 y.Buf8(Ne.w_size*2),Ne.head=new y.Buf16(Ne.hash_size),Ne.prev=new y.Buf16(Ne.w_size),Ne.lit_bufsize=1<<ae+6,Ne.pending_buf_size=Ne.lit_bufsize*4,Ne.pending_buf=new y.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=le,Ne.strategy=pe,Ne.method=he,ge(C)}function xe(C,le){return te(C,le,h,A,L,n)}function V(C,le){var he,k,ae,pe;if(!C||!C.state||le>_||le<0)return C?Ce(C,r):r;if(k=C.state,!C.output||!C.input&&C.avail_in!==0||k.status===be&&le!==x)return Ce(C,C.avail_out===0?t:r);if(k.strm=C,he=k.last_flush,k.last_flush=le,k.status===ee)if(k.wrap===2)C.adler=0,Be(k,31),Be(k,139),Be(k,8),k.gzhead?(Be(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),Be(k,k.gzhead.time&255),Be(k,k.gzhead.time>>8&255),Be(k,k.gzhead.time>>16&255),Be(k,k.gzhead.time>>24&255),Be(k,k.level===9?2:k.strategy>=l||k.level<2?4:0),Be(k,k.gzhead.os&255),k.gzhead.extra&&k.gzhead.extra.length&&(Be(k,k.gzhead.extra.length&255),Be(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(C.adler=R(C.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=ie):(Be(k,0),Be(k,0),Be(k,0),Be(k,0),Be(k,0),Be(k,k.level===9?2:k.strategy>=l||k.level<2?4:0),Be(k,ve),k.status=oe);else{var Ve=h+(k.w_bits-8<<4)<<8,Ne=-1;k.strategy>=l||k.level<2?Ne=0:k.level<6?Ne=1:k.level===6?Ne=2:Ne=3,Ve|=Ne<<6,k.strstart!==0&&(Ve|=q),Ve+=31-Ve%31,k.status=oe,ze(k,Ve),k.strstart!==0&&(ze(k,C.adler>>>16),ze(k,C.adler&65535)),C.adler=1}if(k.status===ie)if(k.gzhead.extra){for(ae=k.pending;k.gzindex<(k.gzhead.extra.length&65535)&&!(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),Ie(C),ae=k.pending,k.pending===k.pending_buf_size));)Be(k,k.gzhead.extra[k.gzindex]&255),k.gzindex++;k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=ne)}else k.status=ne;if(k.status===ne)if(k.gzhead.name){ae=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),Ie(C),ae=k.pending,k.pending===k.pending_buf_size)){pe=1;break}k.gzindex<k.gzhead.name.length?pe=k.gzhead.name.charCodeAt(k.gzindex++)&255:pe=0,Be(k,pe)}while(pe!==0);k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),pe===0&&(k.gzindex=0,k.status=de)}else k.status=de;if(k.status===de)if(k.gzhead.comment){ae=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),Ie(C),ae=k.pending,k.pending===k.pending_buf_size)){pe=1;break}k.gzindex<k.gzhead.comment.length?pe=k.gzhead.comment.charCodeAt(k.gzindex++)&255:pe=0,Be(k,pe)}while(pe!==0);k.gzhead.hcrc&&k.pending>ae&&(C.adler=R(C.adler,k.pending_buf,k.pending-ae,ae)),pe===0&&(k.status=re)}else k.status=re;if(k.status===re&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&Ie(C),k.pending+2<=k.pending_buf_size&&(Be(k,C.adler&255),Be(k,C.adler>>8&255),C.adler=0,k.status=oe)):k.status=oe),k.pending!==0){if(Ie(C),C.avail_out===0)return k.last_flush=-1,v}else if(C.avail_in===0&&Te(le)<=Te(he)&&le!==x)return Ce(C,t);if(k.status===be&&C.avail_in!==0)return Ce(C,t);if(C.avail_in!==0||k.lookahead!==0||le!==E&&k.status!==be){var Ge=k.strategy===l?me(k,le):k.strategy===d?Y(k,le):Ae[k.level].func(k,le);if((Ge===Me||Ge===J)&&(k.status=be),Ge===_e||Ge===Me)return C.avail_out===0&&(k.last_flush=-1),v;if(Ge===Oe&&(le===M?O._tr_align(k):le!==_&&(O._tr_stored_block(k,0,0,!1),le===g&&(We(k.head),k.lookahead===0&&(k.strstart=0,k.block_start=0,k.insert=0))),Ie(C),C.avail_out===0))return k.last_flush=-1,v}return le!==x?v:k.wrap<=0?m:(k.wrap===2?(Be(k,C.adler&255),Be(k,C.adler>>8&255),Be(k,C.adler>>16&255),Be(k,C.adler>>24&255),Be(k,C.total_in&255),Be(k,C.total_in>>8&255),Be(k,C.total_in>>16&255),Be(k,C.total_in>>24&255)):(ze(k,C.adler>>>16),ze(k,C.adler&65535)),Ie(C),k.wrap>0&&(k.wrap=-k.wrap),k.pending!==0?v:m)}function Le(C){var le;return!C||!C.state?r:(le=C.state.status,le!==ee&&le!==ie&&le!==ne&&le!==de&&le!==re&&le!==oe&&le!==be?Ce(C,r):(C.state=null,le===oe?Ce(C,e):v))}function De(C,le){var he=le.length,k,ae,pe,Ve,Ne,Ge,qe,_t;if(!C||!C.state||(k=C.state,Ve=k.wrap,Ve===2||Ve===1&&k.status!==ee||k.lookahead))return r;for(Ve===1&&(C.adler=w(C.adler,le,he,0)),k.wrap=0,he>=k.w_size&&(Ve===0&&(We(k.head),k.strstart=0,k.block_start=0,k.insert=0),_t=new y.Buf8(k.w_size),y.arraySet(_t,le,he-k.w_size,k.w_size,0),le=_t,he=k.w_size),Ne=C.avail_in,Ge=C.next_in,qe=C.input,C.avail_in=he,C.next_in=0,C.input=le,je(k);k.lookahead>=U;){ae=k.strstart,pe=k.lookahead-(U-1);do k.ins_h=(k.ins_h<<k.hash_shift^k.window[ae+U-1])&k.hash_mask,k.prev[ae&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=ae,ae++;while(--pe);k.strstart=ae,k.lookahead=U-1,je(k)}return k.strstart+=k.lookahead,k.block_start=k.strstart,k.insert=k.lookahead,k.lookahead=0,k.match_length=k.prev_length=U-1,k.match_available=0,C.next_in=Ge,C.input=qe,C.avail_in=Ne,k.wrap=Ve,v}D.deflateInit=xe,D.deflateInit2=te,D.deflateReset=ge,D.deflateResetKeep=se,D.deflateSetHeader=Se,D.deflate=V,D.deflateEnd=Le,D.deflateSetDictionary=De,D.deflateInfo="pako deflate (from Nodeca project)"},"./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js"(K){function D(){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=D},"./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js"(K){var D=30,c=12;K.exports=function(O,w){var R,p,E,M,g,x,_,v,m,r,e,t,s,o,l,d,i,n,a,h,u,A,L,T,S;R=O.state,p=O.next_in,T=O.input,E=p+(O.avail_in-5),M=O.next_out,S=O.output,g=M-(w-O.avail_out),x=M+(O.avail_out-257),_=R.dmax,v=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[p++]<<s,s+=8,t+=T[p++]<<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[p++]<<s,s+=8),h+=t&(1<<a)-1,t>>>=a,s-=a),s<15&&(t+=T[p++]<<s,s+=8,t+=T[p++]<<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[p++]<<s,s+=8,s<a&&(t+=T[p++]<<s,s+=8)),u+=t&(1<<a)-1,u>_){O.msg="invalid distance too far back",R.mode=D;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=D;break e}if(A=0,L=e,r===0){if(A+=v-a,a<h){h-=a;do S[M++]=e[A++];while(--a);A=M-u,L=S}}else if(r<a){if(A+=v+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,L=S}}}else if(A+=r-a,a<h){h-=a;do S[M++]=e[A++];while(--a);A=M-u,L=S}for(;h>2;)S[M++]=L[A++],S[M++]=L[A++],S[M++]=L[A++],h-=3;h&&(S[M++]=L[A++],h>1&&(S[M++]=L[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=D;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=D;break e}break}}while(p<E&&M<x);h=s>>3,p-=h,s-=h<<3,t&=(1<<s)-1,O.next_in=p,O.next_out=M,O.avail_in=p<E?5+(E-p):5-(p-E),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,D,c){var y=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"),w=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"),p=c("./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js"),E=0,M=1,g=2,x=4,_=5,v=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,L=7,T=8,S=9,I=10,z=11,B=12,F=13,W=14,U=15,P=16,N=17,q=18,ee=19,ie=20,ne=21,de=22,re=23,oe=24,be=25,_e=26,Oe=27,Me=28,J=29,ve=30,Ce=31,Te=32,We=852,Ie=592,Fe=15,Be=Fe;function ze(te){return(te>>>24&255)+(te>>>8&65280)+((te&65280)<<8)+((te&255)<<24)}function Re(){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 y.Buf16(320),this.work=new y.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Pe(te){var xe;return!te||!te.state?t:(xe=te.state,te.total_in=te.total_out=xe.total=0,te.msg="",xe.wrap&&(te.adler=xe.wrap&1),xe.mode=i,xe.last=0,xe.havedict=0,xe.dmax=32768,xe.head=null,xe.hold=0,xe.bits=0,xe.lencode=xe.lendyn=new y.Buf32(We),xe.distcode=xe.distdyn=new y.Buf32(Ie),xe.sane=1,xe.back=-1,m)}function je(te){var xe;return!te||!te.state?t:(xe=te.state,xe.wsize=0,xe.whave=0,xe.wnext=0,Pe(te))}function ke(te,xe){var V,Le;return!te||!te.state||(Le=te.state,xe<0?(V=0,xe=-xe):(V=(xe>>4)+1,xe<48&&(xe&=15)),xe&&(xe<8||xe>15))?t:(Le.window!==null&&Le.wbits!==xe&&(Le.window=null),Le.wrap=V,Le.wbits=xe,je(te))}function H(te,xe){var V,Le;return te?(Le=new Re,te.state=Le,Le.window=null,V=ke(te,xe),V!==m&&(te.state=null),V):t}function Z(te){return H(te,Be)}var Y=!0,me,ce;function Ae(te){if(Y){var xe;for(me=new y.Buf32(512),ce=new y.Buf32(32),xe=0;xe<144;)te.lens[xe++]=8;for(;xe<256;)te.lens[xe++]=9;for(;xe<280;)te.lens[xe++]=7;for(;xe<288;)te.lens[xe++]=8;for(p(M,te.lens,0,288,me,0,te.work,{bits:9}),xe=0;xe<32;)te.lens[xe++]=5;p(g,te.lens,0,32,ce,0,te.work,{bits:5}),Y=!1}te.lencode=me,te.lenbits=9,te.distcode=ce,te.distbits=5}function we(te,xe,V,Le){var De,C=te.state;return C.window===null&&(C.wsize=1<<C.wbits,C.wnext=0,C.whave=0,C.window=new y.Buf8(C.wsize)),Le>=C.wsize?(y.arraySet(C.window,xe,V-C.wsize,C.wsize,0),C.wnext=0,C.whave=C.wsize):(De=C.wsize-C.wnext,De>Le&&(De=Le),y.arraySet(C.window,xe,V-Le,De,C.wnext),Le-=De,Le?(y.arraySet(C.window,xe,V-Le,Le,0),C.wnext=Le,C.whave=C.wsize):(C.wnext+=De,C.wnext===C.wsize&&(C.wnext=0),C.whave<C.wsize&&(C.whave+=De))),0}function j(te,xe){var V,Le,De,C,le,he,k,ae,pe,Ve,Ne,Ge,qe,_t,Ye=0,He,$e,tt,et,bt,xt,st,lt,dt=new y.Buf8(4),pt,Mt,At=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!te||!te.state||!te.output||!te.input&&te.avail_in!==0)return t;V=te.state,V.mode===B&&(V.mode=F),le=te.next_out,De=te.output,k=te.avail_out,C=te.next_in,Le=te.input,he=te.avail_in,ae=V.hold,pe=V.bits,Ve=he,Ne=k,lt=m;e:for(;;)switch(V.mode){case i:if(V.wrap===0){V.mode=F;break}for(;pe<16;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(V.wrap&2&&ae===35615){V.check=0,dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=w(V.check,dt,2,0),ae=0,pe=0,V.mode=n;break}if(V.flags=0,V.head&&(V.head.done=!1),!(V.wrap&1)||(((ae&255)<<8)+(ae>>8))%31){te.msg="incorrect header check",V.mode=ve;break}if((ae&15)!==d){te.msg="unknown compression method",V.mode=ve;break}if(ae>>>=4,pe-=4,st=(ae&15)+8,V.wbits===0)V.wbits=st;else if(st>V.wbits){te.msg="invalid window size",V.mode=ve;break}V.dmax=1<<st,te.adler=V.check=1,V.mode=ae&512?I:B,ae=0,pe=0;break;case n:for(;pe<16;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(V.flags=ae,(V.flags&255)!==d){te.msg="unknown compression method",V.mode=ve;break}if(V.flags&57344){te.msg="unknown header flags set",V.mode=ve;break}V.head&&(V.head.text=ae>>8&1),V.flags&512&&(dt[0]=ae&255,dt[1]=ae>>>8&255,V.check=w(V.check,dt,2,0)),ae=0,pe=0,V.mode=a;case a:for(;pe<32;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=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=w(V.check,dt,4,0)),ae=0,pe=0,V.mode=h;case h:for(;pe<16;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=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=w(V.check,dt,2,0)),ae=0,pe=0,V.mode=u;case u:if(V.flags&1024){for(;pe<16;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=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=w(V.check,dt,2,0)),ae=0,pe=0}else V.head&&(V.head.extra=null);V.mode=A;case A:if(V.flags&1024&&(Ge=V.length,Ge>he&&(Ge=he),Ge&&(V.head&&(st=V.head.extra_len-V.length,V.head.extra||(V.head.extra=new Array(V.head.extra_len)),y.arraySet(V.head.extra,Le,C,Ge,st)),V.flags&512&&(V.check=w(V.check,Le,Ge,C)),he-=Ge,C+=Ge,V.length-=Ge),V.length))break e;V.length=0,V.mode=L;case L:if(V.flags&2048){if(he===0)break e;Ge=0;do st=Le[C+Ge++],V.head&&st&&V.length<65536&&(V.head.name+=String.fromCharCode(st));while(st&&Ge<he);if(V.flags&512&&(V.check=w(V.check,Le,Ge,C)),he-=Ge,C+=Ge,st)break e}else V.head&&(V.head.name=null);V.length=0,V.mode=T;case T:if(V.flags&4096){if(he===0)break e;Ge=0;do st=Le[C+Ge++],V.head&&st&&V.length<65536&&(V.head.comment+=String.fromCharCode(st));while(st&&Ge<he);if(V.flags&512&&(V.check=w(V.check,Le,Ge,C)),he-=Ge,C+=Ge,st)break e}else V.head&&(V.head.comment=null);V.mode=S;case S:if(V.flags&512){for(;pe<16;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(ae!==(V.check&65535)){te.msg="header crc mismatch",V.mode=ve;break}ae=0,pe=0}V.head&&(V.head.hcrc=V.flags>>9&1,V.head.done=!0),te.adler=V.check=0,V.mode=B;break;case I:for(;pe<32;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}te.adler=V.check=ze(ae),ae=0,pe=0,V.mode=z;case z:if(V.havedict===0)return te.next_out=le,te.avail_out=k,te.next_in=C,te.avail_in=he,V.hold=ae,V.bits=pe,e;te.adler=V.check=1,V.mode=B;case B:if(xe===_||xe===v)break e;case F:if(V.last){ae>>>=pe&7,pe-=pe&7,V.mode=Oe;break}for(;pe<3;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}switch(V.last=ae&1,ae>>>=1,pe-=1,ae&3){case 0:V.mode=W;break;case 1:if(Ae(V),V.mode=ie,xe===v){ae>>>=2,pe-=2;break e}break;case 2:V.mode=N;break;case 3:te.msg="invalid block type",V.mode=ve}ae>>>=2,pe-=2;break;case W:for(ae>>>=pe&7,pe-=pe&7;pe<32;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if((ae&65535)!==(ae>>>16^65535)){te.msg="invalid stored block lengths",V.mode=ve;break}if(V.length=ae&65535,ae=0,pe=0,V.mode=U,xe===v)break e;case U:V.mode=P;case P:if(Ge=V.length,Ge){if(Ge>he&&(Ge=he),Ge>k&&(Ge=k),Ge===0)break e;y.arraySet(De,Le,C,Ge,le),he-=Ge,C+=Ge,k-=Ge,le+=Ge,V.length-=Ge;break}V.mode=B;break;case N:for(;pe<14;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(V.nlen=(ae&31)+257,ae>>>=5,pe-=5,V.ndist=(ae&31)+1,ae>>>=5,pe-=5,V.ncode=(ae&15)+4,ae>>>=4,pe-=4,V.nlen>286||V.ndist>30){te.msg="too many length or distance symbols",V.mode=ve;break}V.have=0,V.mode=q;case q:for(;V.have<V.ncode;){for(;pe<3;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}V.lens[At[V.have++]]=ae&7,ae>>>=3,pe-=3}for(;V.have<19;)V.lens[At[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,pt={bits:V.lenbits},lt=p(E,V.lens,0,19,V.lencode,0,V.work,pt),V.lenbits=pt.bits,lt){te.msg="invalid code lengths set",V.mode=ve;break}V.have=0,V.mode=ee;case ee: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<=pe);){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(tt<16)ae>>>=He,pe-=He,V.lens[V.have++]=tt;else{if(tt===16){for(Mt=He+2;pe<Mt;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(ae>>>=He,pe-=He,V.have===0){te.msg="invalid bit length repeat",V.mode=ve;break}st=V.lens[V.have-1],Ge=3+(ae&3),ae>>>=2,pe-=2}else if(tt===17){for(Mt=He+3;pe<Mt;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}ae>>>=He,pe-=He,st=0,Ge=3+(ae&7),ae>>>=3,pe-=3}else{for(Mt=He+7;pe<Mt;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}ae>>>=He,pe-=He,st=0,Ge=11+(ae&127),ae>>>=7,pe-=7}if(V.have+Ge>V.nlen+V.ndist){te.msg="invalid bit length repeat",V.mode=ve;break}for(;Ge--;)V.lens[V.have++]=st}}if(V.mode===ve)break;if(V.lens[256]===0){te.msg="invalid code -- missing end-of-block",V.mode=ve;break}if(V.lenbits=9,pt={bits:V.lenbits},lt=p(M,V.lens,0,V.nlen,V.lencode,0,V.work,pt),V.lenbits=pt.bits,lt){te.msg="invalid literal/lengths set",V.mode=ve;break}if(V.distbits=6,V.distcode=V.distdyn,pt={bits:V.distbits},lt=p(g,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,pt),V.distbits=pt.bits,lt){te.msg="invalid distances set",V.mode=ve;break}if(V.mode=ie,xe===v)break e;case ie:V.mode=ne;case ne:if(he>=6&&k>=258){te.next_out=le,te.avail_out=k,te.next_in=C,te.avail_in=he,V.hold=ae,V.bits=pe,R(te,Ne),le=te.next_out,De=te.output,k=te.avail_out,C=te.next_in,Le=te.input,he=te.avail_in,ae=V.hold,pe=V.bits,V.mode===B&&(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<=pe);){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=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<=pe);){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}ae>>>=et,pe-=et,V.back+=et}if(ae>>>=He,pe-=He,V.back+=He,V.length=tt,$e===0){V.mode=_e;break}if($e&32){V.back=-1,V.mode=B;break}if($e&64){te.msg="invalid literal/length code",V.mode=ve;break}V.extra=$e&15,V.mode=de;case de:if(V.extra){for(Mt=V.extra;pe<Mt;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}V.length+=ae&(1<<V.extra)-1,ae>>>=V.extra,pe-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=re;case re:for(;Ye=V.distcode[ae&(1<<V.distbits)-1],He=Ye>>>24,$e=Ye>>>16&255,tt=Ye&65535,!(He<=pe);){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=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<=pe);){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}ae>>>=et,pe-=et,V.back+=et}if(ae>>>=He,pe-=He,V.back+=He,$e&64){te.msg="invalid distance code",V.mode=ve;break}V.offset=tt,V.extra=$e&15,V.mode=oe;case oe:if(V.extra){for(Mt=V.extra;pe<Mt;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}V.offset+=ae&(1<<V.extra)-1,ae>>>=V.extra,pe-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){te.msg="invalid distance too far back",V.mode=ve;break}V.mode=be;case be:if(k===0)break e;if(Ge=Ne-k,V.offset>Ge){if(Ge=V.offset-Ge,Ge>V.whave&&V.sane){te.msg="invalid distance too far back",V.mode=ve;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=De,qe=le-V.offset,Ge=V.length;Ge>k&&(Ge=k),k-=Ge,V.length-=Ge;do De[le++]=_t[qe++];while(--Ge);V.length===0&&(V.mode=ne);break;case _e:if(k===0)break e;De[le++]=V.length,k--,V.mode=ne;break;case Oe:if(V.wrap){for(;pe<32;){if(he===0)break e;he--,ae|=Le[C++]<<pe,pe+=8}if(Ne-=k,te.total_out+=Ne,V.total+=Ne,Ne&&(te.adler=V.check=V.flags?w(V.check,De,Ne,le-Ne):O(V.check,De,Ne,le-Ne)),Ne=k,(V.flags?ae:ze(ae))!==V.check){te.msg="incorrect data check",V.mode=ve;break}ae=0,pe=0}V.mode=Me;case Me:if(V.wrap&&V.flags){for(;pe<32;){if(he===0)break e;he--,ae+=Le[C++]<<pe,pe+=8}if(ae!==(V.total&4294967295)){te.msg="incorrect length check",V.mode=ve;break}ae=0,pe=0}V.mode=J;case J:lt=r;break e;case ve:lt=s;break e;case Ce:return o;case Te:default:return t}return te.next_out=le,te.avail_out=k,te.next_in=C,te.avail_in=he,V.hold=ae,V.bits=pe,(V.wsize||Ne!==te.avail_out&&V.mode<ve&&(V.mode<Oe||xe!==x))&&we(te,te.output,te.next_out,Ne-te.avail_out),Ve-=te.avail_in,Ne-=te.avail_out,te.total_in+=Ve,te.total_out+=Ne,V.total+=Ne,V.wrap&&Ne&&(te.adler=V.check=V.flags?w(V.check,De,Ne,te.next_out-Ne):O(V.check,De,Ne,te.next_out-Ne)),te.data_type=V.bits+(V.last?64:0)+(V.mode===B?128:0)+(V.mode===ie||V.mode===U?256:0),(Ve===0&&Ne===0||xe===x)&<===m&&(lt=l),lt}function se(te){if(!te||!te.state)return t;var xe=te.state;return xe.window&&(xe.window=null),te.state=null,m}function ge(te,xe){var V;return!te||!te.state||(V=te.state,(V.wrap&2)===0)?t:(V.head=xe,xe.done=!1,m)}function Se(te,xe){var V=xe.length,Le,De,C;return!te||!te.state||(Le=te.state,Le.wrap!==0&&Le.mode!==z)?t:Le.mode===z&&(De=1,De=O(De,xe,V,0),De!==Le.check)?s:(C=we(te,xe,V,V),C?(Le.mode=Ce,o):(Le.havedict=1,m))}D.inflateReset=je,D.inflateReset2=ke,D.inflateResetKeep=Pe,D.inflateInit=Z,D.inflateInit2=H,D.inflate=j,D.inflateEnd=se,D.inflateGetHeader=ge,D.inflateSetDictionary=Se,D.inflateInfo="pako inflate (from Nodeca project)"},"./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js"(K,D,c){var y=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=15,w=852,R=592,p=0,E=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],v=[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,L=0,T=0,S=0,I=0,z=0,B=0,F,W,U,P,N,q=null,ee=0,ie,ne=new y.Buf16(O+1),de=new y.Buf16(O+1),re=null,oe=0,be,_e,Oe;for(a=0;a<=O;a++)ne[a]=0;for(h=0;h<s;h++)ne[e[t+h]]++;for(L=n,A=O;A>=1&&ne[A]===0;A--);if(L>A&&(L=A),A===0)return o[l++]=20971520,o[l++]=20971520,i.bits=1,0;for(u=1;u<A&&ne[u]===0;u++);for(L<u&&(L=u),I=1,a=1;a<=O;a++)if(I<<=1,I-=ne[a],I<0)return-1;if(I>0&&(r===p||A!==1))return-1;for(de[1]=0,a=1;a<O;a++)de[a+1]=de[a]+ne[a];for(h=0;h<s;h++)e[t+h]!==0&&(d[de[e[t+h]]++]=h);if(r===p?(q=re=d,ie=19):r===E?(q=g,ee-=257,re=x,oe-=257,ie=256):(q=_,re=v,ie=-1),B=0,h=0,a=u,N=l,T=L,S=0,U=-1,z=1<<L,P=z-1,r===E&&z>w||r===M&&z>R)return 1;for(;;){be=a-S,d[h]<ie?(_e=0,Oe=d[h]):d[h]>ie?(_e=re[oe+d[h]],Oe=q[ee+d[h]]):(_e=96,Oe=0),F=1<<a-S,W=1<<T,u=W;do W-=F,o[N+(B>>S)+W]=be<<24|_e<<16|Oe|0;while(W!==0);for(F=1<<a-1;B&F;)F>>=1;if(F!==0?(B&=F-1,B+=F):B=0,h++,--ne[a]===0){if(a===A)break;a=e[t+d[h]]}if(a>L&&(B&P)!==U){for(S===0&&(S=L),N+=u,T=a-S,I=1<<T;T+S<A&&(I-=ne[T+S],!(I<=0));)T++,I<<=1;if(z+=1<<T,r===E&&z>w||r===M&&z>R)return 1;U=B&P,o[U]=L<<24|T<<16|N-l|0}}return B!==0&&(o[N+B]=a-S<<24|4194304|0),i.bits=L,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,D,c){var y=c("./node_modules/upng-js/node_modules/pako/lib/utils/common.js"),O=4,w=0,R=1,p=2;function E(j){for(var se=j.length;--se>=0;)j[se]=0}var M=0,g=1,x=2,_=3,v=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],L=[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],I=512,z=new Array((e+2)*2);E(z);var B=new Array(t*2);E(B);var F=new Array(I);E(F);var W=new Array(v-_+1);E(W);var U=new Array(m);E(U);var P=new Array(t);E(P);function N(j,se,ge,Se,te){this.static_tree=j,this.extra_bits=se,this.extra_base=ge,this.elems=Se,this.max_length=te,this.has_stree=j&&j.length}var q,ee,ie;function ne(j,se){this.dyn_tree=j,this.max_code=0,this.stat_desc=se}function de(j){return j<256?F[j]:F[256+(j>>>7)]}function re(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,re(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 be(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?(re(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 Me(j,se){var ge=se.dyn_tree,Se=se.max_code,te=se.stat_desc.static_tree,xe=se.stat_desc.has_stree,V=se.stat_desc.extra_bits,Le=se.stat_desc.extra_base,De=se.stat_desc.max_length,C,le,he,k,ae,pe,Ve=0;for(k=0;k<=l;k++)j.bl_count[k]=0;for(ge[j.heap[j.heap_max]*2+1]=0,C=j.heap_max+1;C<o;C++)le=j.heap[C],k=ge[ge[le*2+1]*2+1]+1,k>De&&(k=De,Ve++),ge[le*2+1]=k,!(le>Se)&&(j.bl_count[k]++,ae=0,le>=Le&&(ae=V[le-Le]),pe=ge[le*2],j.opt_len+=pe*(k+ae),xe&&(j.static_len+=pe*(te[le*2+1]+ae)));if(Ve!==0){do{for(k=De-1;j.bl_count[k]===0;)k--;j.bl_count[k]--,j.bl_count[k+1]+=2,j.bl_count[De]--,Ve-=2}while(Ve>0);for(k=De;k!==0;k--)for(le=j.bl_count[k];le!==0;)he=j.heap[--C],!(he>Se)&&(ge[he*2+1]!==k&&(j.opt_len+=(k-ge[he*2+1])*ge[he*2],ge[he*2+1]=k),le--)}}function J(j,se,ge){var Se=new Array(l+1),te=0,xe,V;for(xe=1;xe<=l;xe++)Se[xe]=te=te+ge[xe-1]<<1;for(V=0;V<=se;V++){var Le=j[V*2+1];Le!==0&&(j[V*2]=_e(Se[Le]++,Le))}}function ve(){var j,se,ge,Se,te,xe=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,te=0,Se=0;Se<16;Se++)for(P[Se]=te,j=0;j<1<<L[Se];j++)F[te++]=Se;for(te>>=7;Se<t;Se++)for(P[Se]=te<<7,j=0;j<1<<L[Se]-7;j++)F[256+te++]=Se;for(se=0;se<=l;se++)xe[se]=0;for(j=0;j<=143;)z[j*2+1]=8,j++,xe[8]++;for(;j<=255;)z[j*2+1]=9,j++,xe[9]++;for(;j<=279;)z[j*2+1]=7,j++,xe[7]++;for(;j<=287;)z[j*2+1]=8,j++,xe[8]++;for(J(z,e+1,xe),j=0;j<t;j++)B[j*2+1]=5,B[j*2]=_e(j,5);q=new N(z,A,r+1,e,l),ee=new N(B,L,0,t,l),ie=new N(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?re(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),re(j,ge),re(j,~ge),y.arraySet(j.pending_buf,j.window,se,ge,j.pending),j.pending+=ge}function Ie(j,se,ge,Se){var te=se*2,xe=ge*2;return j[te]<j[xe]||j[te]===j[xe]&&Se[se]<=Se[ge]}function Fe(j,se,ge){for(var Se=j.heap[ge],te=ge<<1;te<=j.heap_len&&(te<j.heap_len&&Ie(se,j.heap[te+1],j.heap[te],j.depth)&&te++,!Ie(se,Se,j.heap[te],j.depth));)j.heap[ge]=j.heap[te],ge=te,te<<=1;j.heap[ge]=Se}function Be(j,se,ge){var Se,te,xe=0,V,Le;if(j.last_lit!==0)do Se=j.pending_buf[j.d_buf+xe*2]<<8|j.pending_buf[j.d_buf+xe*2+1],te=j.pending_buf[j.l_buf+xe],xe++,Se===0?be(j,te,se):(V=W[te],be(j,V+r+1,se),Le=A[V],Le!==0&&(te-=U[V],oe(j,te,Le)),Se--,V=de(Se),be(j,V,ge),Le=L[V],Le!==0&&(Se-=P[V],oe(j,Se,Le)));while(xe<j.last_lit);be(j,n,se)}function ze(j,se){var ge=se.dyn_tree,Se=se.stat_desc.static_tree,te=se.stat_desc.has_stree,xe=se.stat_desc.elems,V,Le,De=-1,C;for(j.heap_len=0,j.heap_max=o,V=0;V<xe;V++)ge[V*2]!==0?(j.heap[++j.heap_len]=De=V,j.depth[V]=0):ge[V*2+1]=0;for(;j.heap_len<2;)C=j.heap[++j.heap_len]=De<2?++De:0,ge[C*2]=1,j.depth[C]=0,j.opt_len--,te&&(j.static_len-=Se[C*2+1]);for(se.max_code=De,V=j.heap_len>>1;V>=1;V--)Fe(j,ge,V);C=xe;do V=j.heap[1],j.heap[1]=j.heap[j.heap_len--],Fe(j,ge,1),Le=j.heap[1],j.heap[--j.heap_max]=V,j.heap[--j.heap_max]=Le,ge[C*2]=ge[V*2]+ge[Le*2],j.depth[C]=(j.depth[V]>=j.depth[Le]?j.depth[V]:j.depth[Le])+1,ge[V*2+1]=ge[Le*2+1]=C,j.heap[1]=C++,Fe(j,ge,1);while(j.heap_len>=2);j.heap[--j.heap_max]=j.heap[1],Me(j,se),J(ge,De,j.bl_count)}function Re(j,se,ge){var Se,te=-1,xe,V=se[1],Le=0,De=7,C=4;for(V===0&&(De=138,C=3),se[(ge+1)*2+1]=65535,Se=0;Se<=ge;Se++)xe=V,V=se[(Se+1)*2+1],!(++Le<De&&xe===V)&&(Le<C?j.bl_tree[xe*2]+=Le:xe!==0?(xe!==te&&j.bl_tree[xe*2]++,j.bl_tree[a*2]++):Le<=10?j.bl_tree[h*2]++:j.bl_tree[u*2]++,Le=0,te=xe,V===0?(De=138,C=3):xe===V?(De=6,C=3):(De=7,C=4))}function Pe(j,se,ge){var Se,te=-1,xe,V=se[1],Le=0,De=7,C=4;for(V===0&&(De=138,C=3),Se=0;Se<=ge;Se++)if(xe=V,V=se[(Se+1)*2+1],!(++Le<De&&xe===V)){if(Le<C)do be(j,xe,j.bl_tree);while(--Le!==0);else xe!==0?(xe!==te&&(be(j,xe,j.bl_tree),Le--),be(j,a,j.bl_tree),oe(j,Le-3,2)):Le<=10?(be(j,h,j.bl_tree),oe(j,Le-3,3)):(be(j,u,j.bl_tree),oe(j,Le-11,7));Le=0,te=xe,V===0?(De=138,C=3):xe===V?(De=6,C=3):(De=7,C=4)}}function je(j){var se;for(Re(j,j.dyn_ltree,j.l_desc.max_code),Re(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 te;for(oe(j,se-257,5),oe(j,ge-1,5),oe(j,Se-4,4),te=0;te<Se;te++)oe(j,j.bl_tree[S[te]*2+1],3);Pe(j,j.dyn_ltree,se-1),Pe(j,j.dyn_dtree,ge-1)}function H(j){var se=4093624447,ge;for(ge=0;ge<=31;ge++,se>>>=1)if(se&1&&j.dyn_ltree[ge*2]!==0)return w;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 w}var Z=!1;function Y(j){Z||(ve(),Z=!0),j.l_desc=new ne(j.dyn_ltree,q),j.d_desc=new ne(j.dyn_dtree,ee),j.bl_desc=new ne(j.bl_tree,ie),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),be(j,n,z),Oe(j)}function Ae(j,se,ge,Se){var te,xe,V=0;j.level>0?(j.strm.data_type===p&&(j.strm.data_type=H(j)),ze(j,j.l_desc),ze(j,j.d_desc),V=je(j),te=j.opt_len+3+7>>>3,xe=j.static_len+3+7>>>3,xe<=te&&(te=xe)):te=xe=ge+5,ge+4<=te&&se!==-1?me(j,se,ge,Se):j.strategy===O||xe===te?(oe(j,(g<<1)+(Se?1:0),3),Be(j,z,B)):(oe(j,(x<<1)+(Se?1:0),3),ke(j,j.l_desc.max_code+1,j.d_desc.max_code+1,V+1),Be(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[de(se)*2]++),j.last_lit===j.lit_bufsize-1}D._tr_init=Y,D._tr_stored_block=me,D._tr_flush_block=Ae,D._tr_tally=we,D._tr_align=ce},"./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js"(K){function D(){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=D},"./src/3Dmol.ts"(K,D,c){c.r(D),c.d(D,{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:()=>p.GLModel,GLShape:()=>E.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:()=>v.applyPartialCharges,autoinit:()=>y.autoinit,autoload:()=>y.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:()=>w.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:()=>v.partialCharges,processing_autoinit:()=>y.processing_autoinit,residues:()=>O.residues,setBondLength:()=>_.setBondLength,setSyncSurface:()=>m.setSyncSurface,specStringToObject:()=>r.specStringToObject,splitMesh:()=>E.splitMesh,ssColors:()=>O.ssColors,subdivide_spline:()=>w.subdivide_spline,syncSurface:()=>m.syncSurface,viewers:()=>y.viewers});var y=c("./src/autoload.ts"),O=c("./src/colors.ts"),w=c("./src/glcartoon.ts"),R=c("./src/GLDraw.ts"),p=c("./src/GLModel.ts"),E=c("./src/GLShape.ts"),M=c("./src/GLViewer.ts"),g=c("./src/Gradient.ts"),x=c("./src/Label.ts"),_=c("./src/parsers/index.ts"),v=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,D,c){c.r(D),c.d(D,{CAP:()=>O,GLDraw:()=>w});var y=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 w;(function(R){function p(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 E{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 y.Vector3(-1,0,0),t[i]=new y.Vector3(0,0,1),t[i*2]=new y.Vector3(1,0,0),t[i*3]=new y.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,L=0,T=Math.PI*2,S=0,I=Math.PI,z,B,F=!1,W=!1;for(B=0;B<=u;B++){F=B===0||B===u,W=B===u/2;var U=[],P=[];for(z=0;z<=A;z++){if(W){var N=z<A?2*z:0;P.push(N+1),U.push(N);continue}var q=z/A,ee=B/u;if(!F||z===0)if(z<A){var ie=new y.Vector3;ie.x=-t*Math.cos(L+q*T)*Math.sin(S+ee*I),s==1?ie.y=0:ie.y=t*Math.cos(S+ee*I),ie.z=t*Math.sin(L+q*T)*Math.sin(S+ee*I),Math.abs(ie.x)<1e-5&&(ie.x=0),Math.abs(ie.y)<1e-5&&(ie.y=0),Math.abs(ie.z)<1e-5&&(ie.z=0),s==O.FLAT?(n=new y.Vector3(0,Math.cos(S+ee*I),0),n.normalize()):(n=new y.Vector3(ie.x,ie.y,ie.z),n.normalize()),d.push(ie),i.push(n),U.push(d.length-1)}else U.push(d.length-A);else F&&U.push(d.length-1)}W&&h.push(P),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 E;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=p(s.x-t.x,s.y-t.y,s.z-t.z),u=M.getVerticesForRadius(o,i,"to"),A=u.w,L=u.h,T=a?L*A+2:2*A,S=e.updateGeoGroup(T),I=u.vertices,z=u.normals,B=u.verticesRows,F=B[L/2],W=B[L/2+1],U=S.vertices,P,N,q,ee,ie,ne,de=S.vertexArray,re=S.normalArray,oe=S.colorArray,be=S.faceArray;for(q=0;q<A;++q){var _e=2*q;ee=h[0]*I[_e].x+h[3]*I[_e].y+h[6]*I[_e].z,ie=h[1]*I[_e].x+h[4]*I[_e].y+h[7]*I[_e].z,ne=h[5]*I[_e].y+h[8]*I[_e].z,P=3*(U+_e),N=S.faceidx,de[P]=ee+t.x,de[P+1]=ie+t.y,de[P+2]=ne+t.z,de[P+3]=ee+s.x,de[P+4]=ie+s.y,de[P+5]=ne+s.z,re[P]=ee,re[P+3]=ee,re[P+1]=ie,re[P+4]=ie,re[P+2]=ne,re[P+5]=ne,oe[P]=l.r,oe[P+3]=l.r,oe[P+1]=l.g,oe[P+4]=l.g,oe[P+2]=l.b,oe[P+5]=l.b,be[N]=W[q]+U,be[N+1]=W[q+1]+U,be[N+2]=F[q]+U,be[N+3]=F[q]+U,be[N+4]=W[q+1]+U,be[N+5]=F[q+1]+U,S.faceidx+=6}if(a){var Oe=i?0:L/2,Me=d?L+1:L/2+1,J,ve,Ce,Te,We,Ie,Fe,Be,ze,Re,Pe,je,ke,H,Z,Y,me,ce,Ae,we,j,se,ge,Se,te,xe,V,Le,De,C,le,he;for(ie=Oe;ie<Me;ie++)if(ie!==L/2){var k=ie<=L/2?s:t,ae=M.getVerticesForRadius(o,i,"to"),pe=M.getVerticesForRadius(o,d,"from");for(k===s?(I=ae.vertices,z=ae.normals,B=ae.verticesRows):k==t&&(I=pe.vertices,z=pe.normals,B=pe.verticesRows),ee=0;ee<A;ee++)N=S.faceidx,J=B[ie][ee+1],De=(J+U)*3,ve=B[ie][ee],C=(ve+U)*3,Ce=B[ie+1][ee],le=(Ce+U)*3,Te=B[ie+1][ee+1],he=(Te+U)*3,We=h[0]*I[J].x+h[3]*I[J].y+h[6]*I[J].z,Ie=h[0]*I[ve].x+h[3]*I[ve].y+h[6]*I[ve].z,Fe=h[0]*I[Ce].x+h[3]*I[Ce].y+h[6]*I[Ce].z,Be=h[0]*I[Te].x+h[3]*I[Te].y+h[6]*I[Te].z,ze=h[1]*I[J].x+h[4]*I[J].y+h[7]*I[J].z,Re=h[1]*I[ve].x+h[4]*I[ve].y+h[7]*I[ve].z,Pe=h[1]*I[Ce].x+h[4]*I[Ce].y+h[7]*I[Ce].z,je=h[1]*I[Te].x+h[4]*I[Te].y+h[7]*I[Te].z,ke=h[5]*I[J].y+h[8]*I[J].z,H=h[5]*I[ve].y+h[8]*I[ve].z,Z=h[5]*I[Ce].y+h[8]*I[Ce].z,Y=h[5]*I[Te].y+h[8]*I[Te].z,de[De]=We+k.x,de[C]=Ie+k.x,de[le]=Fe+k.x,de[he]=Be+k.x,de[De+1]=ze+k.y,de[C+1]=Re+k.y,de[le+1]=Pe+k.y,de[he+1]=je+k.y,de[De+2]=ke+k.z,de[C+2]=H+k.z,de[le+2]=Z+k.z,de[he+2]=Y+k.z,oe[De]=l.r,oe[C]=l.r,oe[le]=l.r,oe[he]=l.r,oe[De+1]=l.g,oe[C+1]=l.g,oe[le+1]=l.g,oe[he+1]=l.g,oe[De+2]=l.b,oe[C+2]=l.b,oe[le+2]=l.b,oe[he+2]=l.b,me=h[0]*z[J].x+h[3]*z[J].y+h[6]*z[J].z,ce=h[0]*z[ve].x+h[3]*z[ve].y+h[6]*z[ve].z,Ae=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[J].x+h[4]*z[J].y+h[7]*z[J].z,se=h[1]*z[ve].x+h[4]*z[ve].y+h[7]*z[ve].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,te=h[5]*z[J].y+h[8]*z[J].z,xe=h[5]*z[ve].y+h[8]*z[ve].z,V=h[5]*z[Ce].y+h[8]*z[Ce].z,Le=h[5]*z[Te].y+h[8]*z[Te].z,ie===0?(re[De]=me,re[le]=Ae,re[he]=we,re[De+1]=j,re[le+1]=ge,re[he+1]=Se,re[De+2]=te,re[le+2]=V,re[he+2]=Le,be[N]=J+U,be[N+1]=Ce+U,be[N+2]=Te+U,S.faceidx+=3):ie===Me-1?(re[De]=me,re[C]=ce,re[le]=Ae,re[De+1]=j,re[C+1]=se,re[le+1]=ge,re[De+2]=te,re[C+2]=xe,re[le+2]=V,be[N]=J+U,be[N+1]=ve+U,be[N+2]=Ce+U,S.faceidx+=3):(re[De]=me,re[C]=ce,re[he]=we,re[De+1]=j,re[C+1]=se,re[he+1]=Se,re[De+2]=te,re[C+2]=xe,re[he+2]=Le,re[C]=ce,re[le]=Ae,re[he]=we,re[C+1]=se,re[le+1]=ge,re[he+1]=Se,re[C+2]=xe,re[le+2]=V,re[he+2]=Le,be[N]=J+U,be[N+1]=ve+U,be[N+2]=Te+U,be[N+3]=ve+U,be[N+4]=Ce+U,be[N+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 y.Vector3(s.x-t.x,s.y-t.y,s.z-t.z);var i=p(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,L,T,S,I,z,B,F=u.vertexArray,W=u.normalArray,U=u.colorArray,P=u.faceArray;for(L=A*3,F[L]=t.x,F[L+1]=t.y,F[L+2]=t.z,W[L]=-d.x,W[L+1]=-d.y,W[L+2]=-d.z,U[L]=l.r,U[L+1]=l.g,U[L+2]=l.b,F[L+3]=s.x,F[L+4]=s.y,F[L+5]=s.z,W[L+3]=d.x,W[L+4]=d.y,W[L+5]=d.z,U[L+3]=l.r,U[L+4]=l.g,U[L+5]=l.b,L+=6,S=0;S<n;++S){var N=a[S].clone();N.multiplyScalar(o),I=i[0]*N.x+i[3]*N.y+i[6]*N.z,z=i[1]*N.x+i[4]*N.y+i[7]*N.z,B=i[5]*N.y+i[8]*N.z,F[L]=I+t.x,F[L+1]=z+t.y,F[L+2]=B+t.z,W[L]=I,W[L+1]=z,W[L+2]=B,U[L]=l.r,U[L+1]=l.g,U[L+2]=l.b,L+=3}for(u.vertices+=n+2,T=u.faceidx,S=0;S<n;S++){var q=A+2+S,ee=A+2+(S+1)%n;P[T]=q,P[T+1]=ee,P[T+2]=A,T+=3,P[T]=q,P[T+1]=ee,P[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,L;for(L=0;L<=i;L++){let S=[];for(A=0;A<=d;A++){let I=A/d,z=L/i,B=-t*Math.cos(n+I*a)*Math.sin(h+z*u),F=t*Math.cos(h+z*u),W=t*Math.sin(n+I*a)*Math.sin(h+z*u);var T=new y.Vector3(B,F,W);T.normalize(),l.vertices.push({x:B,y:F,z:W}),l.normals.push(T),S.push(l.vertices.length-1)}l.verticesRows.push(S)}return o.set(t,l),l}}var v=new _;function m(e,t,s,o,l){var d=v.getVerticesForRadius(s,l),i=d.vertices,n=d.normals,a=e.updateGeoGroup(i.length),h=a.vertices,u=a.vertexArray,A=a.colorArray,L=a.faceArray,T=a.lineArray,S=a.normalArray;for(let B=0,F=i.length;B<F;++B){let W=3*(h+B),U=i[B];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 I=d.verticesRows,z=I.length-1;for(let B=0;B<z;B++){let F=I[B].length-1;for(let W=0;W<F;W++){let U=a.faceidx,P=a.lineidx,N=I[B][W+1]+h,q=N*3,ee=I[B][W]+h,ie=ee*3,ne=I[B+1][W]+h,de=ne*3,re=I[B+1][W+1]+h,oe=re*3,be=n[N-h],_e=n[ee-h],Oe=n[ne-h],Me=n[re-h];Math.abs(i[N-h].y)===s?(S[q]=be.x,S[de]=Oe.x,S[oe]=Me.x,S[q+1]=be.y,S[de+1]=Oe.y,S[oe+1]=Me.y,S[q+2]=be.z,S[de+2]=Oe.z,S[oe+2]=Me.z,L[U]=N,L[U+1]=ne,L[U+2]=re,T[P]=N,T[P+1]=ne,T[P+2]=N,T[P+3]=re,T[P+4]=ne,T[P+5]=re,a.faceidx+=3,a.lineidx+=6):Math.abs(i[ne-h].y)===s?(S[q]=be.x,S[ie]=_e.x,S[de]=Oe.x,S[q+1]=be.y,S[ie+1]=_e.y,S[de+1]=Oe.y,S[q+2]=be.z,S[ie+2]=_e.z,S[de+2]=Oe.z,L[U]=N,L[U+1]=ee,L[U+2]=ne,T[P]=N,T[P+1]=ee,T[P+2]=N,T[P+3]=ne,T[P+4]=ee,T[P+5]=ne,a.faceidx+=3,a.lineidx+=6):(S[q]=be.x,S[ie]=_e.x,S[oe]=Me.x,S[q+1]=be.y,S[ie+1]=_e.y,S[oe+1]=Me.y,S[q+2]=be.z,S[ie+2]=_e.z,S[oe+2]=Me.z,S[ie]=_e.x,S[de]=Oe.x,S[oe]=Me.x,S[ie+1]=_e.y,S[de+1]=Oe.y,S[oe+1]=Me.y,S[ie+2]=_e.z,S[de+2]=Oe.z,S[oe+2]=Me.z,L[U]=N,L[U+1]=ee,L[U+2]=re,L[U+3]=ee,L[U+4]=ne,L[U+5]=re,T[P]=N,T[P+1]=ee,T[P+2]=N,T[P+3]=re,T[P+4]=ee,T[P+5]=ne,T[P+6]=ne,T[P+7]=re,a.faceidx+=6,a.lineidx+=8)}}}R.drawSphere=m;function r(e,t,s,o,l,d,i=16,n=4){const a=new y.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 y.Vector3(0,1,0);Math.abs(a.x*u.x+a.y*u.y+a.z*u.z)>.9&&(u=new y.Vector3(1,0,0));const A=new y.Vector3;A.crossVectors(a,u).normalize();const L=new y.Vector3;L.crossVectors(A,a).normalize();const T=(i+1)*(n+1),S=e.updateGeoGroup(T),I=S.vertices,z=S.vertexArray,B=S.colorArray,F=S.normalArray,W=S.faceArray,U=S.lineArray;for(let P=0;P<=i;P++){const N=P/i*2*Math.PI,q=Math.cos(N),ee=Math.sin(N),ie=q*A.x+ee*L.x,ne=q*A.y+ee*L.y,de=q*A.z+ee*L.z,re=t.x+o*ie,oe=t.y+o*ne,be=t.z+o*de;for(let _e=0;_e<=n;_e++){const Oe=_e/n*2*Math.PI,Me=Math.cos(Oe),J=Math.sin(Oe),ve=Me*ie+J*a.x,Ce=Me*ne+J*a.y,Te=Me*de+J*a.z,We=P*(n+1)+_e,Ie=3*(I+We);z[Ie]=re+l*ve,z[Ie+1]=oe+l*Ce,z[Ie+2]=be+l*Te,F[Ie]=ve,F[Ie+1]=Ce,F[Ie+2]=Te,B[Ie]=d.r,B[Ie+1]=d.g,B[Ie+2]=d.b}}S.vertices+=T;for(let P=0;P<i;P++)for(let N=0;N<n;N++){const q=I+P*(n+1)+N,ee=I+P*(n+1)+(N+1),ie=I+(P+1)*(n+1)+(N+1),ne=I+(P+1)*(n+1)+N,de=S.faceidx;W[de]=q,W[de+1]=ee,W[de+2]=ne,W[de+3]=ee,W[de+4]=ie,W[de+5]=ne,S.faceidx+=6;const re=S.lineidx;U[re]=q,U[re+1]=ee,U[re+2]=q,U[re+3]=ne,U[re+4]=ee,U[re+5]=ie,U[re+6]=ie,U[re+7]=ne,S.lineidx+=8}}R.drawTorus=r})(w||(w={}))},"./src/GLModel.ts"(K,D,c){c.r(D),c.d(D,{GLModel:()=>m});var y=c("./src/WebGL/index.ts"),O=c("./src/WebGL/shapes/index.ts"),w=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts"),p=c("./src/GLDraw.ts"),E=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"),v=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 w.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 y.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 L=l.vertices*3;if(l.vertices++,h[L]=e.x+i[A][0],h[L+1]=e.y+i[A][1],h[L+2]=e.z+i[A][2],u[L]=a.r,u[L+1]=a.g,u[L+2]=a.b,n){var T=new w.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],L=new w.Vector3(u.x,u.y,u.z).clone();L.sub(s);let T=L.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 w.Vector3(e.x,e.y,e.z),h=new w.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 w.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 L=this.getGoodCross(t,e,a,u);L!=null&&(A=L)}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 y.Geometry);for(var h=s[a].updateGeoGroup(6*e.bonds.length),u=h.vertexArray,A=h.colorArray,L=0;L<e.bonds.length;L++){var T=e.bonds[L],S=t[T];if(S.style.line&&!(e.index>=S.index)){var I=new w.Vector3(e.x,e.y,e.z),z=new w.Vector3(S.x,S.y,S.z),B=I.clone().add(z).multiplyScalar(.5),F=!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(I),e.intersectionShape.line.push(B)),U&&(S.intersectionShape===void 0&&(S.intersectionShape={sphere:[],cylinder:[],line:[],triangle:[]}),S.intersectionShape.line.push(B),S.intersectionShape.line.push(z)));var P=(0,M.getColorFromStyle)(e,e.style.line),N=(0,M.getColorFromStyle)(S,S.style.line);if(e.bondStyles&&e.bondStyles[L]){var q=e.bondStyles[L];if(!q.iswire)continue;q.singleBond&&(F=!0),typeof q.color1<"u"&&(P=R.CC.color(q.color1)),typeof q.color2<"u"&&(N=R.CC.color(q.color2))}var ee=h.vertices*3,ie,ne;if(e.bondOrder[L]>1&&e.bondOrder[L]<4&&!F){var de=this.getSideBondV(e,S,L),re=z.clone();re.sub(I),e.bondOrder[L]==2?(de.multiplyScalar(.1),l=I.clone(),l.add(de),d=I.clone(),d.sub(de),i=l.clone(),i.add(re),n=d.clone(),n.add(re),P==N?(h.vertices+=4,this.addLine(u,A,ee,l,i,P),this.addLine(u,A,ee+6,d,n,P)):(h.vertices+=8,re.multiplyScalar(.5),ie=l.clone(),ie.add(re),ne=d.clone(),ne.add(re),this.addLine(u,A,ee,l,ie,P),this.addLine(u,A,ee+6,ie,i,N),this.addLine(u,A,ee+12,d,ne,P),this.addLine(u,A,ee+18,ne,n,N))):e.bondOrder[L]==3&&(de.multiplyScalar(.1),l=I.clone(),l.add(de),d=I.clone(),d.sub(de),i=l.clone(),i.add(re),n=d.clone(),n.add(re),P==N?(h.vertices+=6,this.addLine(u,A,ee,I,z,P),this.addLine(u,A,ee+6,l,i,P),this.addLine(u,A,ee+12,d,n,P)):(h.vertices+=12,re.multiplyScalar(.5),ie=l.clone(),ie.add(re),ne=d.clone(),ne.add(re),this.addLine(u,A,ee,I,B,P),this.addLine(u,A,ee+6,B,z,N),this.addLine(u,A,ee+12,l,ie,P),this.addLine(u,A,ee+18,ie,i,N),this.addLine(u,A,ee+24,d,ne,P),this.addLine(u,A,ee+30,ne,n,N)))}else P==N?(h.vertices+=2,this.addLine(u,A,ee,I,z,P)):(h.vertices+=4,this.addLine(u,A,ee,I,B,P),this.addLine(u,A,ee+6,B,z,N))}}}}}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 w.Vector3(e.x,e.y,e.z);e.intersectionShape.sphere.push(new O.Sphere(d,l))}p.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 w.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 w.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,L=l.faceidx;A[L+0]=i,A[L+1]=i+1,A[L+2]=i+2,A[L+3]=i+2,A[L+4]=i+3,A[L+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 w.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,L=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 I=s.x*l,z=s.y*l,B=s.z*l,S=0;S<4;S++)A[a+3*S]=I,A[a+3*S+1]=z,A[a+3*S+2]=B;var F=Math.abs(d.b);F<1e-4&&(F=1e-4),u[a+0]=d.r,u[a+1]=d.g,u[a+2]=F,u[a+3]=d.r,u[a+4]=d.g,u[a+5]=-F,u[a+6]=d.r,u[a+7]=d.g,u[a+8]=-F,u[a+9]=d.r,u[a+10]=d.g,u[a+11]=F,L[n+0]=-T,L[n+1]=-T,L[n+2]=T,L[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,L=Math.sqrt(h*h+u*u+A*A);if(L<.001)return[{from:new w.Vector3(e.x,e.y,e.z),to:new w.Vector3(t.x,t.y,t.z),color:(i=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,I=L-2*S;if(I<o)return[{from:new w.Vector3(e.x,e.y,e.z),to:new w.Vector3(t.x,t.y,t.z),color:(n=d?.[0])!==null&&n!==void 0?n:null}];const z=Math.floor((I-o)/(o+T))+1,B=z*o,F=z>1?z-1:0,W=I-B,U=F>0?W/(F+1):W,P=U/2,N=h/L,q=u/L,ee=A/L,ie=[],ne=S+P;for(let de=0;de<z;de++){const re=ne+de*(o+U),oe=re+o,be=new w.Vector3(e.x+N*re,e.y+q*re,e.z+ee*re),_e=new w.Vector3(e.x+N*oe,e.y+q*oe,e.z+ee*oe),Me=d&&d.length>1&&de>=z/2?d[1]:(a=d?.[0])!==null&&a!==void 0?a:null;ie.push({from:be,to:_e,color:Me})}return ie}calculateTwoColorSegments(e,t,s){const o=[];if(s.length<=1)o.push({from:new w.Vector3(e.x,e.y,e.z),to:new w.Vector3(t.x,t.y,t.z),color:s[0]});else{const l=new w.Vector3((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2);o.push({from:new w.Vector3(e.x,e.y,e.z),to:l,color:s[0]}),o.push({from:l,to:new w.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 L=u.bonds[A];if(!(h===e&&L===t)&&!(h===t&&L===e)){if(L===t&&a.length>=2){const T=[...a,t];return this._ringCache.set(d,T),T}n.has(L)||(n.add(L),i.push([...a,L]))}}}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 w.Vector3(0,0,0);for(let L=0;L<d.length;L++){const T=this.atoms[d[L]];i.x+=T.x,i.y+=T.y,i.z+=T.z}i.multiplyScalar(1/d.length);const n=new w.Vector3().addVectors(s,o).multiplyScalar(.5),a=new w.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 w.Vector3(0,0,0);let i=0;for(let L=0;L<e.bonds.length;L++){if(e.bonds[L]===t.index)continue;const T=this.atoms[e.bonds[L]];T&&(d.x+=T.x,d.y+=T.y,d.z+=T.z,i++)}for(let L=0;L<t.bonds.length;L++){if(t.bonds[L]===e.index)continue;const T=this.atoms[t.bonds[L]];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 w.Vector3().addVectors(s,o).multiplyScalar(.5),a=new w.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((F,W)=>F-W).join(",");if(this._drawnAromaticRings.has(n))return;this._drawnAromaticRings.add(n);const a=new w.Vector3(0,0,0);for(let F=0;F<i.length;F++){const W=this.atoms[i[F]];a.x+=W.x,a.y+=W.y,a.z+=W.z}a.multiplyScalar(1/i.length);const h=new w.Vector3(0,0,0);for(let F=0;F<i.length;F++){const W=this.atoms[i[F]],U=this.atoms[i[(F+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,L=0;for(let F=0;F<i.length;F++){const W=this.atoms[i[F]],U=W.x-a.x,P=W.y-a.y,N=W.z-a.z;if(A+=Math.sqrt(U*U+P*P+N*N),!((d=W.style)===null||d===void 0)&&d.sphere&&!W.style.sphere.hidden&&W.style.sphere.radius){const q=this.getRadiusFromStyle(W,W.style.sphere);q>L&&(L=q)}}A/=i.length;const T=o*.5,I=A*Math.cos(Math.PI/i.length)-T-2*o,z=A-T-L-o,B=Math.max(T,Math.min(I,z));s.imposter?this.drawRingImposter(s,a,h,B,T,l):p.GLDraw.drawTorus(s,a,h,B,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,L=n.radiusArray,T=n.normalArray,S=l.r,I=l.g,z=l.b,B=function(N){var q=-N;return q==0&&(q=-1e-4),q},F=h,W=0;W<4;W++)u[F]=t.x,T[F]=s.x,A[F]=S,F++,u[F]=t.y,T[F]=s.y,A[F]=I,F++,u[F]=t.z,T[F]=s.z,W<2?A[F]=z:A[F]=B(z),F++;n.vertices+=4,L[a]=-o,L[a+1]=o,L[a+2]=-o,L[a+3]=o;var U=n.faceArray,P=n.faceidx;U[P+0]=a,U[P+1]=a+1,U[P+2]=a+2,U[P+3]=a+2,U[P+4]=a+3,U[P+5]=a,n.faceidx+=6}drawBondSticks(e,t,s,o){var l,d,i,n,a,h,u,A,L,T;if(!e.style.stick)return;var S=e.style.stick;if(S.hidden)return;var I=S.radius||this.defaultStickRadius,z=S.doubleBondScaling||.4,B=S.tripleBondScaling||.25;const F=((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 P=I,N=S.singleBonds||!1,q=S.dashedBonds||!1,ee=0,ie=0,ne,de,re,oe,be,_e,Oe,Me,J,ve,Ce=(0,M.getColorFromStyle)(e,S),Te,We,Ie;!e.capDrawn&&e.bonds.length<4&&(ee=2);const Fe=!((i=S.dashedBondConfig)===null||i===void 0)&&i.solidColor?R.CC.color(S.dashedBondConfig.solidColor):null,Be=!((n=S.dashedBondConfig)===null||n===void 0)&&n.dashedColor?R.CC.color(S.dashedBondConfig.dashedColor):null,ze=we=>{const j=s.imposter?m.drawStickImposter:p.GLDraw.drawCylinder;return!q&&we%1===0?(se,ge,Se,te,xe,V,Le=0,De=0)=>{if(!V||xe===V)j(se,ge,Se,te,xe,Le,De);else{const C=this.calculateTwoColorSegments(ge,Se,[xe,V]);for(let le=0;le<C.length;le++){const he=C[le],k=le===0?Le:0,ae=le===C.length-1?De:0;j(se,he.from,he.to,te,he.color,k,ae)}}}:(se,ge,Se,te,xe,V,Le=0,De=0)=>{const C=V?[xe,V]:[xe];this.calculateDashes(ge,Se,te,F,W,C).forEach(he=>{j(se,he.from,he.to,te,he.color,Le,De)})}};for(re=0;re<e.bonds.length;re++){const we=e.bondOrder[re],j=we===4;let se;j?se=U==="circle"?1:1.5:se=we;const ge=ze(se),Se=e.bonds[re],te=t[Se];if(Te=We=Ie=null,e.index<te.index){ie=0;const xe=te.style;if(!xe.stick||xe.stick.hidden)continue;let V=Ce,Le=(0,M.getColorFromStyle)(te,xe.stick);P=I,oe=N;const De=(a=e.bondStyles)===null||a===void 0?void 0:a[re];if(De){if(De.iswire)continue;De.radius&&(P=De.radius),De.singleBond&&(oe=!0),typeof De.color1<"u"&&(V=R.CC.color(De.color1)),typeof De.color2<"u"&&(Le=R.CC.color(De.color2))}const C=new w.Vector3(e.x,e.y,e.z),le=new w.Vector3(te.x,te.y,te.z),he=!((h=De?.dashedBondConfig)===null||h===void 0)&&h.solidColor?R.CC.color(De.dashedBondConfig.solidColor):null,k=!((u=De?.dashedBondConfig)===null||u===void 0)&&u.dashedColor?R.CC.color(De.dashedBondConfig.dashedColor):null,ae=De&&(typeof De.color1<"u"||typeof De.color2<"u"),pe=he||(ae?V:Fe||V),Ve=he||(ae?Le:Fe||Le),Ne=k||(ae?V:Be||V),Ge=k||(ae?Le:Be||Le),qe=((A=De?.dashedBondConfig)===null||A===void 0?void 0:A.dashLength)||F,_t=((L=De?.dashedBondConfig)===null||L===void 0?void 0:L.gapLength)||W;if(se<=1||oe||se>3){se<1&&(P*=se),!te.capDrawn&&te.bonds.length<4&&(ie=2);const Ye=se%1!==0;if(ge(s,C,le,P,Ye?Ne:V,Ye?Ge:Le,ee,ie),ne=e.clickable||e.hoverable,de=te.clickable||te.hoverable,ne||de){if(Te||(Te=new w.Vector3().addVectors(C,le).multiplyScalar(.5)),ne){var Re=new O.Cylinder(C,Te,P),Pe=new O.Sphere(C,P);e.intersectionShape.cylinder.push(Re),e.intersectionShape.sphere.push(Pe)}if(de){var je=new O.Cylinder(le,Te,P),ke=new O.Sphere(le,P);te.intersectionShape.cylinder.push(je),te.intersectionShape.sphere.push(ke)}}if(j&&U==="circle"){const tt=k||Be||V;this.drawAromaticRingTorus(e,te,o,P,tt)}}else if(se>1){var H=0,Z=0;P!=I&&(H=2,Z=2);const Ye=le.clone();Ye.sub(C);let He,$e,tt,et,bt,xt;const st=this.getSideBondV(e,te,re);let lt=!1;se%1!==0&&(De?.dashedBondFlip!=null?lt=De.dashedBondFlip:lt=this.chooseDashedSide(e,te,C,le,st));const dt=s.imposter?m.drawStickImposter:p.GLDraw.drawCylinder,pt=(At,Dt,Ct,Tt,Rt,Bt,Ft)=>{if(Tt!=Rt){const Ut=new w.Vector3().addVectors(At,Dt).multiplyScalar(.5);dt(s,At,Ut,Ct,Tt,Bt,0),dt(s,Ut,Dt,Ct,Rt,0,Ft)}else dt(s,At,Dt,Ct,Tt,Bt,Ft)},Mt=(At,Dt,Ct,Tt,Rt,Bt,Ft)=>{const Ut=Tt!=Rt?[Tt,Rt]:[Tt];this.calculateDashes(At,Dt,Ct,qe,_t,Ut).forEach(ii=>{dt(s,ii.from,ii.to,Ct,ii.color||Tt,Bt,Ft)})};if(se>1&&se<=2){if(He=P*z,$e=He*(se-1),st.multiplyScalar(He*1.5),tt=C.clone(),tt.add(st),et=C.clone(),et.sub(st),bt=tt.clone(),bt.add(Ye),xt=et.clone(),xt.add(Ye),se===2?(pt(tt,bt,He,V,Le,H,Z),pt(et,xt,He,V,Le,H,Z)):lt?(Mt(tt,bt,$e,Ne,Ge,H,Z),pt(et,xt,He,pe,Ve,H,Z)):(pt(tt,bt,He,pe,Ve,H,Z),Mt(et,xt,$e,Ne,Ge,H,Z)),ne=e.clickable||e.hoverable,de=te.clickable||te.hoverable,ne||de){Te||(Te=new w.Vector3().addVectors(tt,bt).multiplyScalar(.5)),We||(We=new w.Vector3().addVectors(et,xt).multiplyScalar(.5));const At=se===2?He:lt?$e:He,Dt=se===2||lt?He:$e;ne&&(be=new O.Cylinder(tt,Te,At),_e=new O.Cylinder(et,We,Dt),e.intersectionShape.cylinder.push(be),e.intersectionShape.cylinder.push(_e)),de&&(Me=new O.Cylinder(bt,Te,At),J=new O.Cylinder(xt,We,Dt),te.intersectionShape.cylinder.push(Me),te.intersectionShape.cylinder.push(J))}}else if(se>2&&se<=3){He=P*B;const At=He*(se-2);if(st.cross(Ye),st.normalize(),st.multiplyScalar(He*3),tt=C.clone(),tt.add(st),et=C.clone(),et.sub(st),bt=tt.clone(),bt.add(Ye),xt=et.clone(),xt.add(Ye),se===3?(pt(tt,bt,He,V,Le,H,Z),pt(C,le,He,V,Le,ee,ie),pt(et,xt,He,V,Le,H,Z)):lt?(Mt(tt,bt,At,Ne,Ge,H,Z),pt(C,le,He,pe,Ve,ee,ie),pt(et,xt,He,pe,Ve,H,Z)):(pt(tt,bt,He,pe,Ve,H,Z),pt(C,le,He,pe,Ve,ee,ie),Mt(et,xt,At,Ne,Ge,H,Z)),ne=e.clickable||e.hoverable,de=te.clickable||te.hoverable,ne||de){Te||(Te=new w.Vector3().addVectors(tt,bt).multiplyScalar(.5)),We||(We=new w.Vector3().addVectors(et,xt).multiplyScalar(.5)),Ie||(Ie=new w.Vector3().addVectors(C,le).multiplyScalar(.5));const Dt=se===3?He:lt?At:He,Ct=se===3||lt?He:At;ne&&(be=new O.Cylinder(tt.clone(),Te.clone(),Dt),_e=new O.Cylinder(et.clone(),We.clone(),Ct),Oe=new O.Cylinder(C.clone(),Ie.clone(),He),e.intersectionShape.cylinder.push(be),e.intersectionShape.cylinder.push(_e),e.intersectionShape.cylinder.push(Oe)),de&&(Me=new O.Cylinder(bt.clone(),Te.clone(),Dt),J=new O.Cylinder(xt.clone(),We.clone(),Ct),ve=new O.Cylinder(le.clone(),Ie.clone(),He),te.intersectionShape.cylinder.push(Me),te.intersectionShape.cylinder.push(J),te.intersectionShape.cylinder.push(ve))}}}}}var Y=!1,me=0,ce=!1;for(re=0;re<e.bonds.length;re++){oe=N;var Ae=(T=e.bondStyles)===null||T===void 0?void 0:T[re];Ae&&(Ae.singleBond&&(oe=!0),Ae.radius&&Ae.radius!=I&&(ce=!0)),(oe||e.bondOrder[re]==1)&&me++}ce?me>0&&(Y=!0):me==0&&(e.bonds.length>0||S.showNonBonded)&&(Y=!0),Y&&(P=I,s.imposter?this.drawSphereImposter(s.sphereGeometry,e,P,Ce):p.GLDraw.drawSphere(s,e,P,Ce))}createMolObj(e,t){t=t||{},this._drawnAromaticRings=new Set,this._ringCache=new Map;var s=new y.Object3D,o=[],l={},d={},i=this.drawAtomSphere,n=null,a=null,h=null;t.supportsImposters?(h=new y.Geometry(!0),h.imposter=!0,h.radii=!0,i=this.drawAtomImposter,n=new y.Geometry(!0),n.imposter=!0,a=new y.Geometry(!0,!0),a.imposter=!0,a.sphereGeometry=new y.Geometry(!0),a.sphereGeometry.imposter=!0,a.drawnCaps={}):t.supportsAIA?(h=new y.Geometry(!0),i=this.drawAtomInstanced,n=new y.Geometry(!1,!0,!0),n.instanced=!0,a=new y.Geometry(!0)):(h=new y.Geometry(!0),n=new y.Geometry(!0),a=new y.Geometry(!0));var u,A,L,T,S={},I=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY];for(u=0,L=e.length;u<L;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<I[0]&&(I[0]=z.resi),z.resi>I[1]&&(I[1]=z.resi)),o.push(z))}}if(o.length>0&&(0,E.drawCartoon)(s,o,I,this.defaultCartoonQuality),n&&n.vertices>0){n.initTypedArrays();var B=null,F=null;n.imposter?B=new y.SphereImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):n.instanced?(F=new y.Geometry(!0),p.GLDraw.drawSphere(F,{x:0,y:0,z:0},1,new R.Color(.5,.5,.5)),F.initTypedArrays(),B=new y.InstancedMaterial({sphereMaterial:new y.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),sphere:F})):B=new y.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),S.sphere<1&&S.sphere>=0&&(B.transparent=!0,B.opacity=S.sphere),F=new y.Mesh(n,B),s.add(F)}if(a.vertices>0){var W=null,U=null,P=a.sphereGeometry;(!P||typeof P.vertices>"u"||P.vertices==0)&&(P=null),a.initTypedArrays(),P&&P.initTypedArrays();var N={ambient:0,vertexColors:!0,reflectivity:0};a.imposter?(W=new y.StickImposterMaterial(N),U=new y.SphereImposterMaterial(N)):(W=new y.MeshLambertMaterial(N),U=new y.MeshLambertMaterial(N),W.wireframe&&(a.setUpWireframe(),P&&P.setUpWireframe())),S.stick<1&&S.stick>=0&&(W.transparent=!0,W.opacity=S.stick,U.transparent=!0,U.opacity=S.stick);var q=new y.Mesh(a,W);if(s.add(q),P){var ee=new y.Mesh(P,U);s.add(ee)}}if(h.vertices>0){h.initTypedArrays();var ie;h.imposter?ie=new y.RingImposterMaterial({ambient:0,vertexColors:!0,reflectivity:0}):ie=new y.MeshLambertMaterial({ambient:0,vertexColors:!0,reflectivity:0}),S.stick<1&&S.stick>=0&&(ie.transparent=!0,ie.opacity=S.stick),s.add(new y.Mesh(h,ie))}var ne;for(u in l)if(l.hasOwnProperty(u)){ne=u;var de=new y.LineBasicMaterial({linewidth:ne,vertexColors:!0});S.line<1&&S.line>=0&&(de.transparent=!0,de.opacity=S.line),l[u].initTypedArrays();var re=new y.Line(l[u],de,y.LineStyle.LinePieces);s.add(re)}for(u in d)if(d.hasOwnProperty(u)){ne=u;var oe=new y.LineBasicMaterial({linewidth:ne,vertexColors:!0});S.cross<1&&S.cross>=0&&(oe.transparent=!0,oe.opacity=S.cross),d[u].initTypedArrays();var be=new y.Line(d[u],oe,y.LineStyle.LinePieces);s.add(be)}if(this.dontDuplicateAtoms&&this.modelData.symmetries&&this.modelData.symmetries.length>0){var _e=new y.Object3D,Oe;for(Oe=0;Oe<this.modelData.symmetries.length;Oe++){var Me=new y.Object3D;Me=s.clone(),Me.matrix.copy(this.modelData.symmetries[Oe]),Me.matrixAutoUpdate=!1,_e.add(Me)}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,w.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,w.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 w.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"),L=(0,M.getAtomProperty)(this.atoms[u],"dy"),T=(0,M.getAtomProperty)(this.atoms[u],"dz"),S=new w.Vector3(A,L,T),I=new w.Vector3(this.atoms[u].x,this.atoms[u].y,this.atoms[u].z),z=n*t/e;S.multiplyScalar(z),I.add(S);var B={};for(var F in this.atoms[u])B[F]=this.atoms[u][F];if(B.x=I.x,B.y=I.y,B.z=I.z,a.push(B),i&&o){var W=(0,M.extend)({},o),U=new w.Vector3(A,L,T);if(U.multiplyScalar(t),U.add(I),W.start=I,W.end=U,W.frame=h,!W.color){var P=B.style.sphere;P||(P=B.style.stick),P||(P=B.style.line),W.color=(0,M.getColorFromStyle)(B,P)}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 B=m.getFloat(e.expand);let F=this.expandAtomList(s,B),W=s.length;const U=B*B;for(let P=0;P<F.length;P++)for(let N=0;N<W;N++){var i=m.squaredDistance(F[P],s[N]);i<U&&i>0&&s.push(F[P])}}if(e.hasOwnProperty("within")&&e.within.hasOwnProperty("sel")&&e.within.hasOwnProperty("distance")){var n=this.selectedAtoms(e.within.sel,this.atoms),a={};const B=m.getFloat(e.within.distance),F=B*B;for(let W=0;W<n.length;W++)for(let U=0;U<s.length;U++){let P=m.squaredDistance(n[W],s[U]);P<F&&P>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=[],L=[];for(let B=0;B<s.length;B++){let F=s[B];var T=F.chain,S=F.resi;if(u[T]===void 0&&(u[T]={}),F.hasOwnProperty("resi")&&u[T][S]===void 0){for(u[T][S]=!0,L.push(F);L.length>0;)if(F=L.pop(),T=F.chain,S=F.resi,A[F.index]===void 0){A[F.index]=!0;for(var I=0;I<F.bonds.length;I++){var z=this.atoms[F.bonds[I]];A[z.index]===void 0&&z.hasOwnProperty("resi")&&z.chain==T&&z.resi==S&&(L.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,v.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 L=h[A],T=L.chain,S=L.resn,I=L.resi,z=S+""+I;u[T]||(u[T]={}),u[T][z]||(u[T][z]=[]),u[T][z].push(L)}var B=(0,M.deepCopy)(t);for(let W in u)if(u.hasOwnProperty(W)){var F=u[W];for(let U in F)if(F.hasOwnProperty(U)){let P=F[U],N=new w.Vector3(0,0,0);for(let ee=0;ee<P.length;ee++){let ie=P[ee];N.x+=ie.x,N.y+=ie.y,N.z+=ie.z}N.divideScalar(P.length),B.position=N,B.frame=a;let q=o.addLabel(U,B,void 0,!0);l.push(q)}}};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,D,c){c.r(D),c.d(D,{GLShape:()=>_,splitMesh:()=>v});var y=c("./src/WebGL/index.ts"),O=c("./src/WebGL/shapes/index.ts"),w=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts"),p=c("./src/ProteinSurface4.ts"),E=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 w.Vector3(o.x,o.y,o.z).sub(s);if(n){let te=h.length();n>0?i=n/te:i=(te+n)/te}h.multiplyScalar(i);var u=new w.Vector3(s.x,s.y,s.z).add(h),A=h.clone().negate();let L=new w.Vector3(s.x,s.y,s.z);r.intersectionShape.cylinder.push(new O.Cylinder(L,u.clone(),l)),r.intersectionShape.sphere.push(new O.Sphere(L,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,I=a.vertexArray,z=a.faceArray,B=a.normalArray,F=a.lineArray,W,U,P;for(U=0,P=T.length;U<P;++U){W=3*(S+3*U);var N=T[U].clone().multiplyScalar(l).add(s),q=T[U].clone().multiplyScalar(l).add(u),ee=T[U].clone().multiplyScalar(l*d).add(u);if(I[W]=N.x,I[W+1]=N.y,I[W+2]=N.z,I[W+3]=q.x,I[W+4]=q.y,I[W+5]=q.z,I[W+6]=ee.x,I[W+7]=ee.y,I[W+8]=ee.z,U>0){var ie=I[W-3],ne=I[W-2],de=I[W-1],re=new w.Vector3(ie,ne,de),oe=new w.Vector3(o.x,o.y,o.z),be=u.clone(),_e=new w.Vector3(ee.x,ee.y,ee.z);r.intersectionShape.triangle.push(new O.Triangle(_e,oe,re)),r.intersectionShape.triangle.push(new O.Triangle(re.clone(),be,_e.clone()))}}a.vertices+=48,W=a.vertices*3,I[W]=s.x,I[W+1]=s.y,I[W+2]=s.z,I[W+3]=u.x,I[W+4]=u.y,I[W+5]=u.z,I[W+6]=o.x,I[W+7]=o.y,I[W+8]=o.z,a.vertices+=3;var Oe,Me,J,ve,Ce,Te,We,Ie,Fe,Be,ze,Re,Pe,je,ke,H,Z,Y,me,ce=a.vertices-3,Ae=a.vertices-2,we=a.vertices-1,j=ce*3,se=Ae*3,ge=we*3;for(U=0,P=T.length-1;U<P;++U){var Se=S+3*U;W=Se*3,Me=a.faceidx,J=a.lineidx,ve=Se,Be=ve*3,Ce=Se+1,ze=Ce*3,Te=Se+2,Re=Te*3,We=Se+4,Pe=We*3,Ie=Se+5,je=Ie*3,Fe=Se+3,ke=Fe*3,H=Z=T[U],Y=me=T[U+1],B[Be]=H.x,B[ze]=Z.x,B[ke]=me.x,B[Be+1]=H.y,B[ze+1]=Z.y,B[ke+1]=me.y,B[Be+2]=H.z,B[ze+2]=Z.z,B[ke+2]=me.z,B[ze]=Z.x,B[Pe]=Y.x,B[ke]=me.x,B[ze+1]=Z.y,B[Pe+1]=Y.y,B[ke+1]=me.y,B[ze+2]=Z.z,B[Pe+2]=Y.z,B[ke+2]=me.z,B[Re]=Z.x,B[je]=Y.x,B[Re+1]=Z.y,B[je+1]=Y.y,B[Re+2]=Z.z,B[je+2]=Y.z,z[Me]=ve,z[Me+1]=Ce,z[Me+2]=Fe,z[Me+3]=Ce,z[Me+4]=We,z[Me+5]=Fe,z[Me+6]=ve,z[Me+7]=Fe,z[Me+8]=ce,z[Me+9]=Te,z[Me+10]=Ae,z[Me+11]=Ie,z[Me+12]=Te,z[Me+13]=we,z[Me+14]=Ie,F[J]=ve,F[J+1]=Ce,F[J+2]=ve,F[J+3]=Fe,F[J+4]=We,F[J+5]=Fe,F[J+6]=ve,F[J+7]=Fe,F[J+8]=Te,F[J+9]=Ce,F[J+10]=Te,F[J+11]=Ie,F[J+12]=We,F[J+13]=Ie,F[J+14]=Te,F[J+15]=we,F[J+16]=Te,F[J+17]=Ie,F[J+18]=we,F[J+19]=Ie,a.faceidx+=15,a.lineidx+=20}Oe=[S+45,S+46,S+1,S,S+47,S+2],Me=a.faceidx,J=a.lineidx,ve=Oe[0],Be=ve*3,Ce=Oe[1],ze=Ce*3,Te=Oe[4],Re=Te*3,We=Oe[2],Pe=We*3,Ie=Oe[5],je=Ie*3,Fe=Oe[3],ke=Fe*3,H=Z=T[15],Y=me=T[0],B[Be]=H.x,B[ze]=Z.x,B[ke]=me.x,B[Be+1]=H.y,B[ze+1]=Z.y,B[ke+1]=me.y,B[Be+2]=H.z,B[ze+2]=Z.z,B[ke+2]=me.z,B[ze]=Z.x,B[Pe]=Y.x,B[ke]=me.x,B[ze+1]=Z.y,B[Pe+1]=Y.y,B[ke+1]=me.y,B[ze+2]=Z.z,B[Pe+2]=Y.z,B[ke+2]=me.z,B[Re]=Z.x,B[je]=Y.x,B[Re+1]=Z.y,B[je+1]=Y.y,B[Re+2]=Z.z,B[je+2]=Y.z,h.normalize(),A.normalize(),B[j]=A.x,B[se]=B[ge]=h.x,B[j+1]=A.y,B[se+1]=B[ge+1]=h.y,B[j+2]=A.z,B[se+2]=B[ge+2]=h.z,z[Me]=ve,z[Me+1]=Ce,z[Me+2]=Fe,z[Me+3]=Ce,z[Me+4]=We,z[Me+5]=Fe,z[Me+6]=ve,z[Me+7]=Fe,z[Me+8]=ce,z[Me+9]=Te,z[Me+10]=Ae,z[Me+11]=Ie,z[Me+12]=Te,z[Me+13]=we,z[Me+14]=Ie,F[J]=ve,F[J+1]=Ce,F[J+2]=ve,F[J+3]=Fe,F[J+4]=We,F[J+5]=Fe,F[J+6]=ve,F[J+7]=Fe,F[J+8]=Te,F[J+9]=Ce,F[J+10]=Te,F[J+11]=Ie,F[J+12]=We,F[J+13]=Ie,F[J+14]=Te,F[J+15]=we,F[J+16]=Te,F[J+17]=Ie,F[J+18]=we,F[J+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 L=0,T=s;L<T;L++){var h=t[L*3],u=t[L*3+1],A=t[L*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,L,T,S,I,z,B=l.vertexArray,F=l.colorArray;for(s.constructor!==Array&&(I=s.r,z=s.g,A=s.b),T=0,S=l.vertices;T<S;++T)a=T*3,h=d[T],B[a]=h.x,B[a+1]=h.y,B[a+2]=h.z,s.constructor===Array&&(L=s[T],I=L.r,z=L.g,A=L.b),F[a]=I,F[a+1]=z,F[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],L=n[a+2];var W=new w.Vector3,U=new w.Vector3,P=new w.Vector3;r.intersectionShape.triangle.push(new O.Triangle(W.copy(d[u]),U.copy(d[A]),P.copy(d[L])))}if(o){var N=new w.Vector3(0,0,0),q=0;for(let ne=0;ne<e.geometryGroups.length;ne++)N.add(e.geometryGroups[ne].getCentroid()),q++;N.divideScalar(q),_.updateBoundingFromPoints(r.boundingSphere,{centroid:N},B,l.vertices)}if(l.faceArray=new Uint16Array(n),l.truncateArrayBuffers(!0,!0),i.length<l.vertices)l.setNormals();else{var ee=l.normalArray=new Float32Array(l.vertices*3),ie;for(T=0,S=l.vertices;T<S;++T)a=T*3,ie=i[T],ee[a]=ie.x,ee[a+1]=ie.y,ee[a+2]=ie.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,w.clamp)(e.alpha,0,1):1,typeof e.opacity<"u"&&(r.opacity=(0,w.clamp)(e.opacity,0,1)),r.side=e.side!==void 0?e.side:y.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=y.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 y.Geometry(!0),this.linegeo=new y.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 w.Vector3(0,0,0)),r.radius=r.radius?(0,w.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 w.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 w.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 w.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new w.Vector3(0,0,0),r.end?(t=new w.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new w.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 w.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 w.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new w.Vector3(0,0,0);var t;r.end?(t=new w.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new w.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 w.Vector3(r.start.x||0,r.start.y||0,r.start.z||0),n=new w.Vector3(r.end.x,r.end.y||0,r.end.z||0),a=new w.Vector3((t.x-e.x)/(l/r.gapLength),(t.y-e.y)/(l/r.gapLength),(t.z-e.z)/(l/r.gapLength)),h=new w.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 w.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 w.Vector3(n.x+a.x,n.y+a.y,n.z+a.z);var A=new w.Vector3;this.components.push({centroid:A.addVectors(e,t).multiplyScalar(.5)});var L=this.geo.updateGeoGroup(0);_.updateBoundingFromPoints(this.boundingSphere,this.components,L.vertexArray,L.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 w.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):e=new w.Vector3(0,0,0),r.end?(t=new w.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof t.x>"u"&&(t.x=3)):t=new w.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 w.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 w.Vector3(r.start.x||0,r.start.y||0,r.start.z||0):r.start=new w.Vector3(0,0,0),r.dir instanceof w.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 w.Vector3(r.end.x,r.end.y||0,r.end.z||0),typeof r.end.x>"u"&&(r.end.x=3)):r.end=new w.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 w.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,L;for(A=0,L=h.length;A<L;++A)h[A]=-1;var T=new Uint8Array(i*n*a);for(A=0,L=u.length;A<L;++A){var S=o>=0?u[A]-o:o-u[A];S>0&&(T[A]|=_.ISDONE)}var I=[],z=[];p.MarchingCube.march(T,I,z,{fulltable:!0,voxel:l,unitCube:r.unit,origin:r.origin,matrix:r.matrix,nX:i,nY:n,nZ:a}),!l&&d>0&&p.MarchingCube.laplacianSmooth(d,I,z);var B=[],F=[],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,P=e.coords[0].y,N=e.coords[0].z,q=e.coords[0].x,ee=e.coords[0].y,ie=e.coords[0].z;for(let J=0;J<e.coords.length;J++)e.coords[J].x>U?U=e.coords[J].x:e.coords[J].x<q&&(q=e.coords[J].x),e.coords[J].y>P?P=e.coords[J].y:e.coords[J].y<ee&&(ee=e.coords[J].y),e.coords[J].z>N?N=e.coords[J].z:e.coords[J].z<ie&&(ie=e.coords[J].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),q-=ne,U+=ne,ee-=ne,P+=ne,ie-=ne,N+=ne;for(let J=0;J<I.length;J++)I[J].x>q&&I[J].x<U&&I[J].y>ee&&I[J].y<P&&I[J].z>ie&&I[J].z<N&&_.inSelectedRegion(I[J],e.coords,ne)?(B.push(F.length),F.push(I[J])):B.push(-1);for(let J=0;J+2<z.length;J+=3)B[z[J]]!==-1&&B[z[J+1]]!==-1&&B[z[J+2]]!==-1&&(W.push(z[J]-(z[J]-B[z[J]])),W.push(z[J+1]-(z[J+1]-B[z[J+1]])),W.push(z[J+2]-(z[J+2]-B[z[J+2]])));I=F,z=W}_.drawCustom(this,this.geo,{vertexArr:I,faceArr:z,normalArr:[],clickable:e.clickable,hoverable:e.hoverable}),this.updateStyle(e);var de=new w.Vector3(r.origin.x,r.origin.y,r.origin.z),re=new w.Vector3(r.size.x*r.unit.x,r.size.y*r.unit.y,r.size.z*r.unit.z),oe=new w.Vector3(0,0,0),be=de.clone(),_e=de.clone().add(re);for(let J=0;J<I.length;J++)oe.add(I[J]),be.max(I[J]),_e.min(I[J]);oe.divideScalar(I.length);var Oe=oe.distanceTo(_e),Me=oe.distanceTo(be);this.boundingSphere.center=oe,this.boundingSphere.radius=Math.max(Oe,Me),typeof t=="function"&&t()}addVolumetricData(r,e,t){r=new E.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 y.Object3D;var e=null;this.side==y.DoubleSide?e=new y.MeshDoubleLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:y.Coloring.VertexColors}):e=new y.MeshLambertMaterial({wireframe:this.wireframe,side:this.side,transparent:this.opacity<1,opacity:this.opacity,wireframeLinewidth:this.linewidth,vertexColors:y.Coloring.VertexColors});var t=new y.Mesh(this.geo,e);if(this.shapeObj.add(t),this.linegeo&&this.linegeo.vertices>0){var s=new y.LineBasicMaterial({linewidth:this.linewidth,color:this.color}),o=new y.Line(this.linegeo,s,y.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=v(t),i=0,n=d.length;i<n;i++)_.addCustomGeo(m,r,d[i],d[i].colorArr?d[i].colorArr:l,e.clickable)};function v(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,D,c){c.r(D),c.d(D,{CONTEXTS_PER_VIEWPORT:()=>r,GLViewer:()=>t,createStereoViewer:()=>l,createViewer:()=>s,createViewerGrid:()=>o});var y=c("./node_modules/upng-js/UPNG.js"),O=c("./src/GLModel.ts"),w=c("./src/GLShape.ts"),R=c("./src/Gradient.ts"),p=c("./src/Label.ts"),E=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"),v=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 L=0;L<u.length;L++)this.hoverables.push(u[L]);for(let L=0;L<h.length;L++)this.clickables.push(h[L]);for(let L=0;L<A.length;L++)this.contextMenuEnabledObjects.push(A[L])}}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),L=Math.abs(u-this.mouseStartY);return A<=a&&L<=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,L=n-u.top,T=this.rows-Math.floor(L/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,L=n.clone();L.sub(i.clone().multiplyScalar(h)),L.normalize();var T=Math.cos(A),S=Math.sin(A),I=new _.Quaternion(i.x*T+L.x*S,i.y*T+L.y*S,i.z*T+L.z*S,i.w*T+L.w*S);return I.normalize(),I}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=v.elementColors.defaultColors),this.nomouse=!!this.config.nomouse,this.bgColor=0,this.config.backgroundColor=this.config.backgroundColor||"#ffffff",typeof this.config.backgroundColor<"u"&&(this.bgColor=v.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=v.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,L=u*(this.WIDTH/a),T=(h-A-1)*(this.HEIGHT/h),S=[],I=this.canvasOffset();return i.forEach(z=>{let B=new _.Vector3(z.x,z.y,z.z);B.applyMatrix4(this.modelGroup.matrixWorld),this.projector.projectVector(B,this.camera);let F=this.WIDTH/a*(B.x+1)/2+I.left+L,W=-(this.HEIGHT/h)*(B.y-1)/2+I.top+T;S.push({x:F,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,L=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(L),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=[],L=[],T=Date.now();n.viewChangeCallback=function(){L.push(Date.now()-T),T=Date.now(),A.push(new Promise(S=>{n.getCanvas().toBlob(function(I){I.arrayBuffer().then(S)},"image/png")})),h+=1,h==i&&(n.viewChangeCallback=u,Promise.all(A).then(S=>{let I=[];for(let P=0;P<S.length;P++){let N=(0,y.decode)(S[P]);I.push((0,y.toRGBA8)(N)[0])}let z=n.getCanvas().width,B=n.getCanvas().height,F=(0,y.encode)(I,z,B,0,L),W=new Blob([F],{type:"image/png"}),U=new FileReader;U.onload=function(P){a(P.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,L=this.row,T=A*(this.WIDTH/h),S=(u-L-1)*(this.HEIGHT/u),I=(i-a.left-T)/(this.WIDTH/h)*2-1,z=-((n-a.top-S)/(this.HEIGHT/u))*2+1;return{x:I,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),L=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(){L.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,I=(a-this.mouseStartY)/this.HEIGHT;if(this.touchDistanceStart!=0&&i.targetTouches&&i.targetTouches.length==2){var z=this.calcTouchDistance(i);T=2,I=(z-this.touchDistanceStart)*2/(this.WIDTH+this.HEIGHT)}else i.targetTouches&&i.targetTouches.length==3&&(T=1);S*=h,I*=u;var B=Math.hypot(S,I),F;if(T==3||this.mouseButton==3&&i.ctrlKey)this.slabNear=this.cslabNear+S*100,this.slabFar=this.cslabFar-I*100;else if(T==2||this.mouseButton==3||i.shiftKey)F=(this.CAMERA_Z-this.rotationGroup.position.z)*.85,F<80&&(F=80),this.rotationGroup.position.z=this.cz+I*F,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)&&B!==0){var U=Math.sin(B*Math.PI)/B;this.dq.x=Math.cos(B*Math.PI),this.dq.y=0,this.dq.z=U*S,this.dq.w=-U*I,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),L=A.x,T=A.y,S=this.targetedObjects(L,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=v.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 L=20,T=Math.ceil(i/L);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 B=new Array(T);for(let P=0;P<T;P++){let N=(P+1)/T,q={mpos:S.mpos,rz:S.rz,rot:S.rot};q.mpos=a.clone().sub(S.mpos).multiplyScalar(N).add(S.mpos),q.rz=S.rz+N*(h-S.rz),q.rot=t.slerp(S.rot,u,N),q.cam=A.clone().sub(S.cam).multiplyScalar(N).add(S.cam),B[P]=q}let F=0,W=this,U=function(){var P=B[F];F+=1,W.modelGroup.position=P.mpos,W.rotationGroup.position.z=P.rz,W.rotationGroup.quaternion=P.rot,W.camera.lookAt(P.cam),F<B.length?setTimeout(U,L):W.decAnim(),W.show()};setTimeout(U,L)}else{var I={};let B=1/T;if(a&&(I.mpos=a.clone().sub(S.mpos).multiplyScalar(B)),typeof h<"u"&&h!=null&&(I.rz=B*(h-S.rz)),u){var z=t.slerp(S.rot,u,B);I.rot=S.rot.clone().inverse().multiply(z)}A&&(I.cam=A.clone().sub(S.cam).multiplyScalar(B));let F=0,W=this,U=function(){F+=1,I.mpos&&W.modelGroup.position.add(I.mpos),I.rz&&(W.rotationGroup.position.z+=I.rz),I.rot&&W.rotationGroup.quaternion.multiply(I.rot),I.cam&&(W.lookingAt.add(I.cam),W.camera.lookAt(W.lookingAt)),F<T?setTimeout(U,L):W.decAnim(),W.show()};setTimeout(U,L)}}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(I){var z=Math.sin(I/2),B=Math.cos(I/2),F=0,W=0,U=0;return F=n.x*z,W=n.y*z,U=n.z*z,new _.Quaternion(F,W,U,B).normalize()},L=Math.PI*i/180,T=A(L);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 L=A[u].geo;if(!A[u].finished||n.regen){L.verticesNeedUpdate=!0,L.elementsNeedUpdate=!0,L.normalsNeedUpdate=!0,L.colorsNeedUpdate=!0,L.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(L,A[u].mat):("wireframe"in A.style&&A.style.wireframe&&L.setUpWireframe(),T=new x.Mesh(L,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,I=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,I.add(z)}A[u].lastGL=I,this.modelGroup.add(I)}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,L=new _.Vector3(0,0,-this.CAMERA_Z);this.projector.projectVector(L,this.camera),L.x-=u,L.y-=A,this.projector.unprojectVector(L,this.camera),L.z=0;var T=this.lookingAt.clone().add(L);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],L=Math.hypot(h,u,A);return L<5&&(L=5),this.slabNear=-L/1.9,this.slabFar=L/2,this}center(i={},n=0,a=!1){var h,u,A=this.getAtomsFromSel(i),L=(0,m.getExtent)(A);(0,m.isEmptyObject)(i)?(this.shapes.forEach(N=>{if(N&&N.boundingSphere&&N.boundingSphere.center){var q=N.boundingSphere.center,ee=N.boundingSphere.radius;ee>0?(A.push(new _.Vector3(q.x+ee,q.y,q.z)),A.push(new _.Vector3(q.x-ee,q.y,q.z)),A.push(new _.Vector3(q.x,q.y+ee,q.z)),A.push(new _.Vector3(q.x,q.y-ee,q.z)),A.push(new _.Vector3(q.x,q.y,q.z+ee)),A.push(new _.Vector3(q.x,q.y,q.z-ee))):A.push(q)}}),L=(0,m.getExtent)(A),h=A,u=L):(h=this.getAtomsFromSel({}),u=(0,m.getExtent)(h));var T=new _.Vector3(L[2][0],L[2][1],L[2][2]),S=u[1][0]-u[0][0],I=u[1][1]-u[0][1],z=u[1][2]-u[0][2],B=Math.hypot(S,I,z);B<5&&(B=5),this.slabNear=-B/1.9,this.slabFar=B/2,S=L[1][0]-L[0][0],I=L[1][1]-L[0][1],z=L[1][2]-L[0][2],B=Math.hypot(S,I,z),B<5&&(B=5);for(var F=25,W=0;W<A.length;W++)if(A[W]){var U=T.distanceToSquared(A[W]);U>F&&(F=U)}B=Math.sqrt(F)*2;var P=T.clone().multiplyScalar(-1);return n>0?this.animateMotion(n,a,P,this.rotationGroup.position.z,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=P,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 q=h&&h.length;if(this.shapes.forEach(ee=>{if(ee&&ee.boundingSphere){if(ee.boundingSphere.box){let de=ee.boundingSphere.box;h.push(new _.Vector3(de.min.x,de.min.y,de.min.z)),h.push(new _.Vector3(de.max.x,de.max.y,de.max.z))}else if(ee.boundingSphere.center){var ie=ee.boundingSphere.center,ne=ee.boundingSphere.radius;ne>0?(h.push(new _.Vector3(ie.x+ne,ie.y,ie.z)),h.push(new _.Vector3(ie.x-ne,ie.y,ie.z)),h.push(new _.Vector3(ie.x,ie.y+ne,ie.z)),h.push(new _.Vector3(ie.x,ie.y-ne,ie.z)),h.push(new _.Vector3(ie.x,ie.y,ie.z+ne)),h.push(new _.Vector3(ie.x,ie.y,ie.z-ne))):h.push(ie)}}}),A=(0,m.getExtent)(h),!q)for(let ee=0;ee<3;ee++)u[2][ee]=(A[0][ee]+A[1][ee])/2}else{let q=this.getAtomsFromSel({});A=(0,m.getExtent)(q)}var L=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],I=A[1][2]-A[0][2],z=Math.hypot(T,S,I);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 B=this.config.minimumZoomToDistance||5;T=u[1][0]-u[0][0],S=u[1][1]-u[0][1],I=u[1][2]-u[0][2],z=Math.hypot(T,S,I),z<B&&(z=B);for(var F=B*B,W=0;W<h.length;W++)if(h[W]){var U=L.distanceToSquared(h[W]);U>F&&(F=U)}z=Math.sqrt(F)*2;var P=L.clone().multiplyScalar(-1),N=-(z*.5/Math.tan(Math.PI/180*this.camera.fov/2)-this.CAMERA_Z);return N=this.adjustZoomToLimits(N),n>0?this.animateMotion(n,a,P,N,this.rotationGroup.quaternion,this.lookingAt):(this.modelGroup.position=P,this.rotationGroup.position.z=N,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 p.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 w.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 w.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 w.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 w.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 w.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 w.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 w.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,L=a.c,T=a.alpha,S=a.beta,I=a.gamma;T=T*Math.PI/180,S=S*Math.PI/180,I=I*Math.PI/180;var z,B,F;z=Math.cos(S),B=(Math.cos(T)-Math.cos(S)*Math.cos(I))/Math.sin(I),F=Math.sqrt(Math.max(0,1-z*z-B*B)),h=new _.Matrix3(u,A*Math.cos(I),L*z,0,A*Math.sin(I),L*B,0,0,L*F)}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 P=0;P<W.length;P++)a.size&&W[P].multiplyVectors(W[P],a.size),W[P]=W[P].applyMatrix4(a.matrix4);else for(let P=0;P<W.length;P++)W[P]=W[P].applyMatrix3(h);if(n.box&&!n.box.hidden){n.box.wireframe=!0;var U=new w.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 P=this.addArrow(n.astyle);i.unitCellObjects.shapes.push(P)}if(!n.bstyle.hidden){n.bstyle.start=W[0],n.bstyle.end=W[2];let P=this.addArrow(n.bstyle);i.unitCellObjects.shapes.push(P)}if(!n.cstyle.hidden){n.cstyle.start=W[0],n.cstyle.end=W[3];let P=this.addArrow(n.cstyle);i.unitCellObjects.shapes.push(P)}if(n.alabel){n.alabelstyle.position=W[1];let P=this.addLabel(n.alabel,n.alabelstyle);i.unitCellObjects.labels.push(P)}if(n.blabel){n.blabelstyle.position=W[2];let P=this.addLabel(n.blabel,n.blabelstyle);i.unitCellObjects.labels.push(P)}if(n.clabel){n.clabelstyle.position=W[3];let P=this.addLabel(n.clabel,n.clabelstyle);i.unitCellObjects.labels.push(P)}}}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 L=h.getCrystData();if(L){const T=h.selectedAtoms({}),S=L.matrix;let I=function(B){return B%2==0?-B/2:Math.ceil(B/2)};i<=1&&n<=1&&a<=1&&(A=!0,i=n=a=3);let z=function(B,F,W){return!1};if(A){const B=new _.Matrix3().getInverse3(S);z=function(F,W,U){let P=new _.Vector3(F,W,U).applyMatrix3(B);return!(P.x>-1e-4&&P.x<1.0001&&P.y>-1e-4&&P.y<1.0001&&P.z>-1e-4&&P.z<1.0001)}}for(let B=0;B<i;B++)for(let F=0;F<n;F++)for(let W=0;W<a;W++){if(B==0&&F==0&&W==0)continue;let U=new _.Vector3(I(B),I(F),I(W));U.applyMatrix3(S);let P=[];for(let N=0;N<T.length;N++){let q=T[N].x+U.x,ee=T[N].y+U.y,ie=T[N].z+U.z;if(z(q,ee,ie))continue;let ne={};for(let de in T[N])ne[de]=T[N][de];ne.x=q,ne.y=ee,ne.z=ie,P.push(ne)}h.addAtoms(P)}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,L=new _.Vector3,T,S,I,z=a.clone(),B=0;for(u.subVectors(h,a),T=u.length(),u.normalize(),A=u.clone(),L=u.clone(),A.multiplyScalar(i.dashLength),L.multiplyScalar(i.gapLength),S=A.length(),I=L.length();B<T;){if(B+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(),B+=S,z.addVectors(a,L),a=z.clone(),B+=I}return n.finalize(),n}addCustom(i){i=i||{};var n=new w.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 w.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,L=0;i.startFrame&&(L=i.startFrame%u);var T=1;i.step&&(T=i.step,h/=T);var S=0,I=u*h,z=new Date,B,F,W=function(U){z=new Date,U=="forward"?A.setFrame(L).then(function(){L=(L+T)%u,B()}):U=="backward"?A.setFrame(u-1-L).then(function(){L=(L+T)%u,B()}):A.setFrame(L).then(function(){L+=T,T*=L%(u-1)==0?-1:1,B()})};return B=function(){if(A.render(),!A.getCanvas().isConnected)A.stopAnimate();else if(++S>=I||!A.isAnimated())F.cancel(),A.animationTimers.delete(F),A.decAnim();else{var U=n-(new Date().getTime()-z.getTime());U=U>0?U:0,F.cancel(),A.animationTimers.delete(F),F=new m.PausableTimer(W,U,a),A.animationTimers.add(F)}},F=new m.PausableTimer(W,0,a),this.animationTimers.add(F),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,L){for(var T=this.getModelList(n),S=0;S<T.length;S++)T[S][i](n,a,h,u,A,L)}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,B=n.length;z<B;z++)u[n[z].index]=z;let A=function(z){let B=[];for(let F=0,W=z.length;F<W;F++)z[F].index in u&&B.push(u[z[F].index]);return B},L=function(z){let B=[];return B[0]=[z[0][0],z[0][1],z[0][2]],B[1]=[z[1][0],z[1][1],z[1][2]],B},T=function(z){if(t.volume(z)<t.maxVolume)return[z];var B=z[1][0]-z[0][0],F=z[1][1]-z[0][1],W=z[1][2]-z[0][2],U;B>F&&B>W?U=0:F>B&&F>W?U=1:U=2;var P=L(z),N=L(z),q=(z[1][U]-z[0][U])/2+z[0][U];P[1][U]=q,N[0][U]=q;var ee=T(P),ie=T(N);return ee.concat(ie)},S=T(i),I=6;for(let z=0,B=S.length;z<B;z++){let F=L(S[z]);F[0][0]-=I,F[0][1]-=I,F[0][2]-=I,F[1][0]+=I,F[1][1]+=I,F[1][2]+=I;let W=t.getAtomsWithin(n,F),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 J=0,ve=i.length;J<ve;J++){var L=i[J];L&&(typeof L.surfaceColor<"u"?A[J]=L.surfaceColor:L.color&&(A[J]=v.CC.color(L.color)))}var T=u.vertexArray,S=n.vertices;for(let J=0,ve=S.length;J<ve;J++){let Ce=u.vertices*3;T[Ce]=S[J].x,T[Ce+1]=S[J].y,T[Ce+2]=S[J].z,u.vertices++}var I=u.colorArray;let z=u.atomArray;if(a.voldata&&a.volscheme){var B=a.volscheme,F=a.voldata,W=B.range()||[-1,1];for(let J=0,ve=S.length;J<ve;J++){let Ce=S[J].atomid,Te=F.getVal(S[J].x,S[J].y,S[J].z),We=v.CC.color(B.valueToHex(Te,W)),Ie=J*3;I[Ie]=We.r,I[Ie+1]=We.g,I[Ie+2]=We.b,z[J]=i[Ce]}}else if(A.length>0)for(let J=0,ve=S.length;J<ve;J++){let Ce=S[J].atomid,Te=J*3;I[Te]=A[Ce].r,I[Te+1]=A[Ce].g,I[Te+2]=A[Ce].b,z[J]=i[Ce]}var U=n.faces;u.faceidx=U.length,h.initTypedArrays();var P=u.vertexArray,N=u.normalArray,q,ee,ie,ne;for(let J=0,ve=U.length;J<ve;J+=3){var de=U[J],re=U[J+1],oe=U[J+2],be=de*3,_e=re*3,Oe=oe*3;q=new _.Vector3(P[be],P[be+1],P[be+2]),ee=new _.Vector3(P[_e],P[_e+1],P[_e+2]),ie=new _.Vector3(P[Oe],P[Oe+1],P[Oe+2]),ie.subVectors(ie,ee),q.subVectors(q,ee),ie.cross(q),ne=ie,ne.normalize(),N[be]+=ne.x,N[_e]+=ne.x,N[Oe]+=ne.x,N[be+1]+=ne.y,N[_e+1]+=ne.y,N[Oe+1]+=ne.y,N[be+2]+=ne.z,N[_e+2]+=ne.z,N[Oe+2]+=ne.z}u.faceArray=new Uint16Array(U);var Me=new x.Mesh(h,a);return Me}static generateMeshSyncHelper(i,n,a,h,u,A){var L=new E.ProteinSurface;return L.initparm(n,i!==1,A),L.fillvoxels(u,a),L.buildboundary(),(i==E.SurfaceType.SES||i==E.SurfaceType.MS)&&(L.fastdistancemap(),L.boundingatom(!1),L.fillvoxelswaals(u,a)),L.marchingcube(i),L.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 L=this.nextSurfID(),T=null,S=this,I=E.SurfaceType.VDW;typeof i=="string"?t.surfaceTypeMap[i.toUpperCase()]!==void 0?I=t.surfaceTypeMap[i]:console.log("Surface type : "+i+" is not recognized"):typeof i=="number"&&(I=i);var z=null,B=null,F=t.shallowCopy(this.getAtomsFromSel(a));h?z=t.shallowCopy(this.getAtomsFromSel(h)):z=F,(0,m.adjustVolumeStyle)(n);var W=!1,U;for(U=0;U<this.models.length;U++)if(this.models[U]){var P=this.models[U].getSymmetries();if(P.length>1||P.length==1&&!P[0].isIdentity()){W=!0;break}}var N=function(oe,be,_e){u?B=t.shallowCopy(S.getAtomsFromSel(u)):B=_e;var Oe,Me=(0,m.getExtent)(_e,!0);if(n.map&&n.map.prop){var J=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,J)),n.colorscheme={prop:J,gradient:je}}for(let je=0,ke=be.length;je<ke;je++)Oe=be[je],Oe.surfaceColor=(0,m.getColorFromStyle)(Oe,n);var ve=t.volume(Me),Ce=S.carveUpExtent(Me,be,_e);if(B&&B.length&&B.length>0){var Te=(0,m.getExtent)(B,!0),We=function(je,ke){var H=function(me,ce){var Ae=me.extent,we=Ae[1][0]-Ae[0][0],j=Ae[1][1]-Ae[0][1],se=Ae[1][2]-Ae[0][2],ge=we-ce[2][0];ge*=ge;var Se=j-ce[2][1];Se*=Se;var te=se-ce[2][2];return te*=te,ge+Se+te},Z=H(je,Te),Y=H(ke,Te);return Z-Y};Ce.sort(We)}var Ie=[];for(let je=0,ke=be.length;je<ke;je++)Oe=be[je],Ie[je]={x:Oe.x,y:Oe.y,z:Oe.z,serial:je,elem:Oe.elem};var Fe=!!E.syncSurface;if((typeof $3Dmol>"u"||typeof $3Dmol.SurfaceWorker>"u")&&(console.log("$3Dmol.SurfaceWorker is not defined, using synchronous surface generation."),Fe=!0),Fe){var Be=function(ke){return new Promise(function(H){for(var Z=t.generateMeshSyncHelper(I,Ce[ke].extent,Ce[ke].atoms,Ce[ke].toshow,Ie,ve),Y=(0,w.splitMesh)({vertexArr:Z.vertices,faceArr:Z.faces}),me=0,ce=Y.length;me<ce;me++){Z={vertices:Y[me].vertexArr,faces:Y[me].faceArr};var Ae=t.generateSurfaceMesh(be,Z,T);(0,m.mergeGeos)(oe.geo,Ae)}S.render(),H()})},ze=[];for(let je=0;je<Ce.length;je++)ze.push(Be(je));return Promise.all(ze).then(function(){return oe.done=!0,S.render(),Promise.resolve(L)})}else{var Re=[];I<0&&(I=0);for(let je=0,ke=t.numWorkers;je<ke;je++){var Pe=new Worker($3Dmol.SurfaceWorker);Re.push(Pe),Pe.postMessage({type:-1,atoms:Ie,volume:ve})}return new Promise(function(je,ke){var H=0,Z=function(){!Re||!Re.length||Re.forEach(function(Ae){Ae&&Ae.terminate&&Ae.terminate()})},Y=function(Ae){for(var we=(0,w.splitMesh)({vertexArr:Ae.data.vertices,faceArr:Ae.data.faces}),j=0,se=we.length;j<se;j++){var ge={vertices:we[j].vertexArr,faces:we[j].faceArr},Se=t.generateSurfaceMesh(be,ge,T);(0,m.mergeGeos)(oe.geo,Se)}S.render(),H++,H==Ce.length&&(oe.done=!0,Z(),je(L))},me=function(Ae){Z(),console.log(Ae.message+" ("+Ae.filename+":"+Ae.lineno+")"),ke(Ae)};for(let Ae=0;Ae<Ce.length;Ae++){var ce=Re[Ae%Re.length];ce.onmessage=Y,ce.onerror=me,ce.postMessage({type:I,expandedExtent:Ce[Ae].extent,extendedAtoms:Ce[Ae].atoms,atomsToShow:Ce[Ae].toshow})}})}};n=n||{},T=t.getMatWithStyle(n);let q=new e([]);q.style=n,q.atomsel=a,q.allsel=h,q.focus=u;var ee=null;if(W){var ie={},ne={};for(U=0;U<this.models.length;U++)ie[U]=[],ne[U]=[];for(U=0;U<z.length;U++)ie[z[U].model].push(z[U]);for(U=0;U<F.length;U++)ne[F[U].model].push(F[U]);var de=[];for(U=0;U<this.models.length;U++)ne[U].length>0&&(q.push({geo:new x.Geometry(!0),mat:T,done:!1,finished:!1,symmetries:this.models[U].getSymmetries()}),de.push(N(q[q.length-1],ie[U],ne[U])));ee=Promise.all(de)}else q.push({geo:new x.Geometry(!0),mat:T,done:!1,finished:!1,symmetries:[new _.Matrix4]}),ee=N(q[q.length-1],z,F);return this.surfaces[L]=q,ee.surfid=L,A&&typeof A=="function"?(ee.then(function(re){A(re)}),L):ee}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=v.CC.color(n.color),a[u].geo.colorsNeedUpdate=!0;const A=v.CC.color(n.color);a[u].geo.setColor(A)}else if(h.voldata&&h.volscheme){const A=h.volscheme,L=h.voldata,T=v.CC,S=A.range()||[-1,1];a[u].geo.setColors(function(I,z,B){let F=L.getVal(I,z,B);return T.color(A.valueToHex(F,S))})}else{a[u].geo.colorsNeedUpdate=!0;for(let A of a[u].geo.geometryGroups)for(let L=0;L<A.vertices;L++){let T=(0,m.getColorFromStyle)(A.atomArray[L],n),S=3*L;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,L=a.length;A<L;A++){let T=a[A];i(T)}else for(let A=0,L=a.length;A<L;A++){var h=a[A];for(let T=0,S=i.length;T<S;T++){let I=i[T];if(I.props)for(var u in I.props)I.props.hasOwnProperty(u)&&this.atomIsSelected(h,I)&&(h.properties||(h.properties={}),h.properties[u]=I.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:E.SurfaceType.VDW,MS:E.SurfaceType.MS,SAS:E.SurfaceType.SAS,SES:E.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=[],L=0;L<i.cols;L++){n.row=u,n.col=L,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),L=this.glviewer2[u].apply(this.glviewer2,arguments);return[A,L]}})(a[h]);this.setCoordinates=function(u,A,L){for(var T=0;T<u.length;T++)u[T].setCoordinates(A,L)},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,D,c){c.r(D),c.d(D,{CustomLinear:()=>g,Gradient:()=>_,GradientType:()=>O,ROYGB:()=>E,RWB:()=>p,Sinebow:()=>M,builtinGradients:()=>x,getGradient:()=>R,normalizeValue:()=>w});var y=c("./src/colors.ts");class O{}function w(v,m,r){return m>=v?(r<v&&(r=v),r>m&&(r=m),{lo:v,hi:m,val:r}):(r>v&&(r=v),r<m&&(r=m),r=v-r+m,{lo:m,hi:v,val:r})}function R(v){if(v instanceof O)return v;if(v.gradient!==void 0&&x[v.gradient]){let m=v.min===void 0?-1:v.min,r=v.max===void 0?1:v.max;return v.mid===void 0?v.colors===void 0?new x[v.gradient](m,r):new x[v.gradient](m,r,v.colors):new x[v.gradient](m,r,v.mid)}else if(typeof v.gradient=="string"&&v.gradient.startsWith("linear_")){let m=v.gradient.split("_");m.shift();let r=v.min===void 0?-1:v.min,e=v.max===void 0?1:v.max;return new g(r,e,m)}return v}class p 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=w(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 E 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=w(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(y.CC.color(s));else this.colors.push(y.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=w(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 y.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:p,RWB:p,roygb:E,ROYGB:E,sinebow:M,linear:g};class _ extends O{valueToHex(m,r){return 0}range(){return null}}_.RWB=p,_.ROYGB=E,_.Sinebow=M,_.CustomLinear=g,_.builtinGradients=x,_.normalizeValue=w,_.getGradient=R},"./src/Label.ts"(K,D,c){c.r(D),c.d(D,{Label:()=>M,LabelCount:()=>R});var y=c("./src/WebGL/index.ts"),O=c("./src/Gradient.ts"),w=c("./src/colors.ts");let R=0;function p(g,x,_,v,m,r,e){g.beginPath(),g.moveTo(x+r,_),g.lineTo(x+v-r,_),g.quadraticCurveTo(x+v,_,x+v,_+r),g.lineTo(x+v,_+m-r),g.quadraticCurveTo(x+v,_+m,x+v-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 E(g,x,_){var v=_;return typeof g<"u"&&(g instanceof w.Color?v=g.scaled():(v=w.CC.color(g),typeof v.scaled<"u"&&(v=v.scaled()))),typeof x<"u"&&(v.a=parseFloat(x)),v}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 y.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,v=x.showBackground;(v==="0"||v==="false")&&(v=!1),typeof v>"u"&&(v=!0);var m=x.font?x.font:"sans-serif",r=parseInt(x.fontSize)?parseInt(x.fontSize):18,e=E(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=E(x.backgroundColor,x.backgroundOpacity,{r:0,g:0,b:0,a:1}),l=E(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||y.SpriteAlignment.topLeft;typeof n=="string"&&n in y.SpriteAlignment&&(n=y.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;v||(s=0);var A=u+2.5*s+2*t,L=r*1.25+2*s+2*t;if(x.backgroundImage){var T=x.backgroundImage,S=x.backgroundWidth?x.backgroundWidth:T.width,I=x.backgroundHeight?x.backgroundHeight:T.height;S>A&&(A=S),I>L&&(L=I)}if(this.canvas.width=A,this.canvas.height=L,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 B=this.context.createLinearGradient(0,L/2,A,L/2),F=O.Gradient.getGradient(x.backgroundGradient),W=F.range(),U=-1,P=1;W&&(U=W[0],P=W[1]);let N=P-U;for(let q=0;q<1.01;q+=.1){let ee=E(F.valueToHex(U+N*q)),ie="rgba("+ee.r+","+ee.g+","+ee.b+","+ee.a+")";B.addColorStop(q,ie)}this.context.fillStyle=B}this.context.lineWidth=s,v&&p(this.context,s,s,A-2*s,L-2*s,6,s>0),x.backgroundImage&&this.context.drawImage(T,0,0,A,L),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 y.Texture(this.canvas);z.needsUpdate=!0,this.sprite.material=new y.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,D,c){c.r(D),c.d(D,{MarchingCube:()=>E,MarchingCubeInitializer:()=>p,PointGrid:()=>M,ProteinSurface:()=>g,SurfaceType:()=>O,setSyncSurface:()=>R,syncSurface:()=>w});var y=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 w=!1;function R(x){w=x}(window.navigator.userAgent.indexOf("MSIE ")>=0||window.navigator.userAgent.indexOf("Trident/")>=0)&&(w=!0);class p{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(_,v,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 L=function(z,B,F,W,U,P){let N={x:0,y:0,z:0},q=!!(W&1<<U),ee=!!(W&1<<P),ie=U;if(!q&&ee&&(ie=P),ie&1&&F++,ie&2&&B++,ie&4&&z++,o){let de=new y.Vector3(z,B,F);de=de.applyMatrix4(o),N={x:de.x,y:de.y,z:de.z}}else N.x=t.x+a.x*z,N.y=t.y+a.y*B,N.z=t.z+a.z*F;let ne=(d*z+B)*i+F;return s?(v.push(N),v.length-1):(h[ne]<0&&(h[ne]=v.length,v.push(N)),h[ne])},T=new Int32Array(12),S=e?this.edgeTable2:this.edgeTable,I=e?this.triTable2:this.triTable;for(u=0;u<l-1;++u)for(let z=0;z<d-1;++z)for(let B=0;B<i-1;++B){let F=0;for(let P=0;P<8;++P){let N=(d*(u+((P&4)>>2))+z+((P&2)>>1))*i+B+(P&1),q=!!(_[N]&this.ISDONE);F|=q<<P}if(F===0||F===255)continue;let W=S[F];if(W===0)continue;let U=I[F];W&1&&(T[0]=L(u,z,B,F,0,1)),W&2&&(T[1]=L(u,z,B,F,1,3)),W&4&&(T[2]=L(u,z,B,F,3,2)),W&8&&(T[3]=L(u,z,B,F,2,0)),W&16&&(T[4]=L(u,z,B,F,4,5)),W&32&&(T[5]=L(u,z,B,F,5,7)),W&64&&(T[6]=L(u,z,B,F,7,6)),W&128&&(T[7]=L(u,z,B,F,6,4)),W&256&&(T[8]=L(u,z,B,F,0,4)),W&512&&(T[9]=L(u,z,B,F,1,5)),W&1024&&(T[10]=L(u,z,B,F,3,7)),W&2048&&(T[11]=L(u,z,B,F,2,6));for(let P=0;P<U.length;P+=3){let N=T[U[P]],q=T[U[P+1]],ee=T[U[P+2]];s&&P>=3&&(v.push(v[N]),N=v.length-1,v.push(v[q]),q=v.length-1,v.push(v[ee]),ee=v.length-1),m.push(N),m.push(q),m.push(ee)}}}laplacianSmooth(_,v,m){let r=new Array(v.length),e,t,s,o,l;for(e=0,t=v.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(v.length);for(e=0,t=v.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=v.length;e<t;e++)if(d[0][e]<3)r[e].x=v[e].x,r[e].y=v[e].y,r[e].z=v[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+=v[d[s+1][e]].x,r[e].y+=v[d[s+1][e]].y,r[e].z+=v[d[s+1][e]].z;r[e].x+=a*v[e].x,r[e].y+=a*v[e].y,r[e].z+=a*v[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+=v[d[s+1][e]].x,r[e].y+=v[d[s+1][e]].y,r[e].z+=v[d[s+1][e]].z;r[e].x+=n*v[e].x,r[e].y+=n*v[e].y,r[e].z+=n*v[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=v.length;e<t;e++)v[e].x=r[e].x,v[e].y=r[e].y,v[e].z=r[e].z}}}let E=new p;class M{constructor(_,v,m){this.data=new Int32Array(_*v*m*3),this.width=v,this.height=m}set(_,v,m,r){let e=((_*this.width+v)*this.height+m)*3;this.data[e]=r.ix,this.data[e+1]=r.iy,this.data[e+2]=r.iz}get(_,v,m){let r=((_*this.width+v)*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 p)}getVDWIndex(_){return!_.elem||typeof this.vdwRadii[_.elem]>"u"?"X":_.elem}getFacesAndVertices(_){let v={};for(let e=0,t=_.length;e<t;e++)v[_[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),v[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(_,v,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],v?(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(v),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 v={};for(const m in this.vdwRadii){let r=this.vdwRadii[m];_?v[m]=(r+this.probeRadius)*this.scaleFactor+.5:v[m]=r*this.scaleFactor+.5;let e=v[m]*v[m];this.widxz[m]=Math.floor(v[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(_,v){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 v){let r=_[v[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(_,v){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 L=0;L<=this.depty[t][s];L++){let T=L*a,S=m+u,I=r+T,z=e+A;if(S<0||I<0||z<0||S>=this.pLength||I>=this.pWidth||z>=this.pHeight)continue;let B=S*o+I*this.pHeight+z;if(!(this.vpBits[B]&this.INOUT))this.vpBits[B]|=this.INOUT,this.vpAtomID[B]=_.serial;else{let F=v[this.vpAtomID[B]];if(F.serial!=_.serial){let W=m+u-Math.floor(.5+this.scaleFactor*(F.x+this.ptranx)),U=r+T-Math.floor(.5+this.scaleFactor*(F.y+this.ptrany)),P=e+A-Math.floor(.5+this.scaleFactor*(F.z+this.ptranz));u*u+T*T+A*A<W*W+U*U+P*P&&(this.vpAtomID[B]=_.serial)}}}}}s++}}fillvoxelswaals(_,v){for(let m=0,r=this.vpBits.length;m<r;m++)this.vpBits[m]&=~this.ISDONE;for(let m in v){let r=_[v[m]];r!==void 0&&this.fillAtomWaals(r,_)}}fillAtomWaals(_,v){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 L=0;L<=this.depty[s][m];L++){let T=L*a,S=r+u,I=e+T,z=t+A;if(S<0||I<0||z<0||S>=this.pLength||I>=this.pWidth||z>=this.pHeight)continue;let B=S*o+I*this.pHeight+z;if(!(this.vpBits[B]&this.ISDONE))this.vpBits[B]|=this.ISDONE,this.vpAtomID[B]=_.serial;else{let F=v[this.vpAtomID[B]];if(F.serial!=_.serial){let W=r+u-Math.floor(.5+this.scaleFactor*(F.x+this.ptranx)),U=e+T-Math.floor(.5+this.scaleFactor*(F.y+this.ptrany)),P=t+A-Math.floor(.5+this.scaleFactor*(F.z+this.ptranz));u*u+T*T+A*A<W*W+U*U+P*P&&(this.vpAtomID[B]=_.serial)}}}}}m++}}buildboundary(){let _=this.pWidth*this.pHeight;for(let v=0;v<this.pLength;v++)for(let m=0;m<this.pHeight;m++)for(let r=0;r<this.pWidth;r++){let e=v*_+r*this.pHeight+m;if(this.vpBits[e]&this.INOUT){let t=0;for(;t<26;){let s=v+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),v=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*v+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=v*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*v+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(_,v){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=v.get(m,r,e);for(let L=0;L<6;L++)a.ix=m+this.nb[L][0],a.iy=r+this.nb[L][1],a.iz=e+this.nb[L][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)?(v.set(a.ix,a.iy,e+this.nb[L][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]&&(v.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=v.get(m,r,e);for(let L=6;L<18;L++)a.ix=m+this.nb[L][0],a.iy=r+this.nb[L][1],a.iz=e+this.nb[L][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)?(v.set(a.ix,a.iy,e+this.nb[L][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]&&(v.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=v.get(m,r,e);for(let L=18;L<26;L++)a.ix=m+this.nb[L][0],a.iy=r+this.nb[L][1],a.iz=e+this.nb[L][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)?(v.set(a.ix,a.iy,e+this.nb[L][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]&&(v.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 v=0,m=this.vpBits.length;v<m;v++)_==1?this.vpBits[v]&=~this.ISBOUND:_==4?(this.vpBits[v]&=~this.ISDONE,this.vpBits[v]&this.ISBOUND&&(this.vpBits[v]|=this.ISDONE),this.vpBits[v]&=~this.ISBOUND):_==2?this.vpBits[v]&this.ISBOUND&&this.vpBits[v]&this.ISDONE?this.vpBits[v]&=~this.ISBOUND:this.vpBits[v]&this.ISBOUND&&!(this.vpBits[v]&this.ISDONE)&&(this.vpBits[v]|=this.ISDONE):_==3&&(this.vpBits[v]&=~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 v=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*v+this.pHeight*this.verts[m].y+this.verts[m].z];g.MarchingCube.laplacianSmooth(1,this.verts,this.faces)}}g.MarchingCube=new p},"./src/SurfaceWorker.js"(){$3Dmol.workerString=function(){self.onmessage=function(K){var D=K.data,c=D.type;if(c<0)self.atomData=D.atoms,self.volume=D.volume,self.ps=new ProteinSurface;else{var y=self.ps;y.initparm(D.expandedExtent,c!=1,self.volume),y.fillvoxels(self.atomData,D.extendedAtoms),y.buildboundary(),(c===4||c===2)&&(y.fastdistancemap(),y.boundingatom(!1),y.fillvoxelswaals(self.atomData,D.extendedAtoms)),y.marchingcube(c);var O=y.getFacesAndVertices(D.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,D,c){c.r(D),c.d(D,{VolumeData:()=>E});var y=c("./src/utilities.ts"),O=c("./src/WebGL/math/index.ts"),w=c("./src/parsers/VASP.ts"),R=c("./src/parsers/CUBE.ts"),p=c("./node_modules/pako/dist/pako.esm.mjs");class E{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,w.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),L=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);L=Math.abs(L)/Math.pow(d,3);var T=1/L;s.splice(0,8+l+1);var S=s[0].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),I=Math.abs(parseFloat(S[0])),z=Math.abs(parseFloat(S[1])),B=Math.abs(parseFloat(S[2])),F=this.origin=new O.Vector3(0,0,0);this.size={x:I,y:z,z:B},this.unit=new O.Vector3(h.x,u.y,A.z),h=h.multiplyScalar(1/(d*I)),u=u.multiplyScalar(1/(d*z)),A=A.multiplyScalar(1/(d*B)),(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(F.x,F.y,F.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(I*z*B+1);for(var P=Float32Array.from(U,parseFloat),N=0;N<P.length;N++)P[N]=P[N]*T*i;this.data=P},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]),L=parseInt(o[3]);this.size={x:u,y:A,z:L}}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 I=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,I)}else if(o=d.exec(h)){var z=parseFloat(o[1]),B=parseFloat(o[2]),F=parseFloat(o[3]);this.origin=new O.Vector3(z,B,F)}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,y.base64ToArray)(g)),g=(0,p.inflate)(g)):g=new TextDecoder("utf-8").decode((0,p.inflate)(g))}catch(t){console.error(t)}}if(this[x]&&(this.isbinary.has(x)&&typeof g=="string"&&(g=(0,y.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 v=0;for(let t=0,s=this.data.length;t<s;t++)v+=this.data[t];var m=v/this.data.length;v=0;for(let t=0,s=this.data.length;t<s;t++){var r=this.data[t]-m;v+=r*r}var e=v/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 v=new O.Vector3(g,x,_);v=v.applyMatrix4(this.inversematrix),g=v.x,x=v.y,_=v.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 v=this.getIndex(g,x,_);return v<0?0:this.data[v]}cube(g){var x=g.split(/\r?\n/);if(!(x.length<6)){var _=(0,R.CUBE)(g,{}).modelData[0].cryst,v=x[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),m=parseFloat(v[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),v=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=v[10],x.ylen=v[11],x.zlen=v[12],x.alpha=v[13],x.beta=v[14],x.gamma=v[15],x.MAPC=_[16],x.MAPR=_[17],x.MAPS=_[18],x.DMIN=v[19],x.DMAX=v[20],x.DMEAN=v[21],x.ISPG=_[22],x.NSYMBT=_[23],x.LSKFLG=_[24],x.originX=v[49],x.originY=v[50],x.originZ=v[51],x.ARMS=v[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 L=0;L<h;L++)for(let T=0;T<u;T++)for(let S=0;S<A;S++)this.data[(L*u+T)*A+S]=a[(S*u+T)*h+L]}}},"./src/VolumetricRender.ts"(K,D,c){c.r(D),c.d(D,{GLVolumetricRender:()=>E});var y=c("./src/WebGL/shapes/index.ts"),O=c("./src/WebGL/math/index.ts"),w=c("./src/WebGL/index.ts"),R=c("./src/colors.ts"),p=c("./src/GLShape.ts");class E{static interpolateArray(g,x){function _(l,d,i){return l+(d-l)*i}var v=[],m=(g.length-1)/(x-1);v[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;v[r]=_(g[t],g[s],o)}return v[x-1]=g[g.length-1],v}constructor(g,x,_){this.hidden=!1,this.boundingSphere=new y.Sphere,this.renderedShapeObj=null,this.shapeObj=null,this.subsamples=5,this.data=null,this.transferfunctionbuffer=[],this.min=0,this.max=0,x=x||{};var v=Object.assign([],x.transferfn);this.subsamples=x.subsamples||5;let m=256;v.forEach(function(u){u.value=parseFloat(u.value)}),v.sort(function(u,A){return u.value-A.value}),this.min=v[0].value,v.length==0&&v.push(v[0]),this.max=v[v.length-1].value;var r,e,t,s,o,l,d,i,n,a;for(let u=0;u<v.length-1;u++)if(t=R.CC.color(v[u].color),s=R.CC.color(v[u+1].color),n=v[u].opacity,a=v[u+1].opacity,r=Math.floor((v[u].value-this.min)*m/(this.max-this.min)),e=Math.floor((v[u+1].value-this.min)*m/(this.max-this.min)),r!=e){o=E.interpolateArray([t.r*255,s.r*255],e-r),l=E.interpolateArray([t.g*255,s.g*255],e-r),d=E.interpolateArray([t.b*255,s.b*255],e-r),i=E.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),L=new O.Vector3(1,1,1);u.applyMatrix4(g.matrix),A.applyMatrix4(g.matrix),L.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,I=A.z-u.z;this.maxdepth=Math.sqrt(T*T+S*S+I*I),this.minunit=Math.min(Math.min(L.x,L.y),L.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,L=g.unit.z*g.size.z;this.texmatrix.makeTranslation(-g.origin.x/u,-g.origin.y/A,-g.origin.z/L),this.texmatrix.scale({x:1/u,y:1/A,z:1/L}),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+L]],this.maxdepth=Math.sqrt(u*u+A*A+L*L)}var h=new p.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,L=A*A;for(let T=0,S=x.coords.length;T<S;T++){let I=x.coords[T],z=I.x-A,B=I.y-A,F=I.z-A,W=I.x+A,U=I.y+A,P=I.z+A;if(g.getIndex(z,B,F)>=0||g.getIndex(W,U,P)>=0)for(let N=z;N<W;N+=this.minunit)for(let q=B;q<U;q+=this.minunit)for(let ee=F;ee<P;ee+=this.minunit){let ie=g.getIndex(N,q,ee);ie>=0&&!u[ie]&&(N-I.x)*(N-I.x)+(q-I.y)*(q-I.y)+(ee-I.z)*(ee-I.z)<L&&(u[ie]=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 w.Object3D;var x=null,_=new w.Texture(this.data,!0),v=new w.Texture(this.transferfunctionbuffer,!1);_.needsUpdate=!0,v.needsUpdate=!0,v.flipY=!1,x=new w.VolumetricMaterial({transferfn:v,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 w.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,D,c){c.r(D),c.d(D,{Camera:()=>w});var y=c("./src/WebGL/core/index.ts"),O=c("./src/WebGL/math/index.ts");class w extends y.Object3D{constructor(p=50,E=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=p,this.aspect=E,this.near=M,this.far=g;var _=this.position.z;this.right=_*Math.tan(Math.PI/180*p),this.left=-this.right,this.top=this.right/this.aspect,this.bottom=-this.top,this.ortho=!!x,this.updateProjectionMatrix()}lookAt(p){this.matrix.lookAt(this.position,p,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,D,c){c.r(D),c.d(D,{Fog:()=>O});var y=c("./src/colors.ts");class O{constructor(R,p=1,E=1e3){this.name="",this.color=new y.Color(R),this.near=p,this.far=E}clone(){return new O(this.color.getHex(),this.near,this.far)}}},"./src/WebGL/Renderer.ts"(K,D,c){c.r(D),c.d(D,{Renderer:()=>r});var y=c("./src/WebGL/Camera.ts"),O=c("./src/WebGL/constants/Sides.ts"),w=c("./src/WebGL/constants/TextureConstants.ts"),R=c("./src/WebGL/core/index.ts"),p=c("./src/colors.ts"),E=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"),v=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 p.Color(t.clearColor):new p.Color(0),this._clearAlpha=t.clearAlpha!==void 0?t.clearAlpha:0,this._outlineMaterial=new E.MeshOutlineMaterial(t.outline),this._outlineSphereImposterMaterial=new E.SphereImposterOutlineMaterial(t.outline),this._outlineStickImposterMaterial=new E.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 E.MeshOutlineMaterial(t),this._outlineSphereImposterMaterial=new E.SphereImposterOutlineMaterial(t),this._outlineStickImposterMaterial=new E.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 L,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)),L=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,L,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)):(L=d.faceidx,h&&this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER,d.__webglFaceBuffer),this._gl.drawElements(this._gl.TRIANGLES,L,this._gl.UNSIGNED_SHORT,0));this.info.render.calls++,this.info.render.vertices+=L,this.info.render.faces+=L/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 y.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 L=this._offscreen.transferToImageBitmap();this._bitmap.transferFromImageBitmap(L),L.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,L="precision "+A+" float;",T=[l.volumetric?"#version 300 es":"",L].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":"",L].join(`
|
|
30
|
+
`),I=this.getShader("fragment",S+t),z=this.getShader("vertex",T+s);z!=null&&this._gl.attachShader(n,z),I!=null&&this._gl.attachShader(n,I),this._gl.linkProgram(n),this._gl.getProgramParameter(n,this._gl.LINK_STATUS)||console.error("Could not initialize shader"),n.uniforms={},n.attributes={};var B,F,W;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","vWidth","vHeight"];for(F in o)B.push(F);for(W=0;W<B.length;W++){var U=B[W];n.uniforms[U]=this._gl.getUniformLocation(n,U)}for(B=["position","normal","color","lineDistance","offset","radius"],W=0;W<B.length;W++){var P=B[W];n.attributes[P]=this._gl.getAttribLocation(n,P)}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===w.UnsignedByteType?this._gl.UNSIGNED_BYTE:t===w.RGBAFormat?this._gl.RGBA:t===w.NearestFilter?this._gl.NEAREST:0}setupLights(t,s){var o,l,d,i=0,n=0,a=0,h,u,A=this._lights,L=A.directional.colors,T=A.directional.positions,S=0,I=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[I]=this._direction.x,T[I+1]=this._direction.y,T[I+2]=this._direction.z,L[I]=h.r*u,L[I+1]=h.g*u,L[I+2]=h.b*u,I+=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())&&(v=new OffscreenCanvas(this._canvas.width,this._canvas.height),m=v.getContext("webgl2",{alpha:!0,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,preserveDrawingBuffer:this._preserveDrawingBuffer})),this._offscreen=v,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,L,T,S;s?(L=t.length-1,T=-1,S=-1):(L=0,T=t.length,S=1);for(var I=L;I!==T;I+=S)if(a=t[I],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 B=this._outlineMaterial;A.shaderID=="sphereimposter"?B=this._outlineSphereImposterMaterial:A.shaderID=="stickimposter"&&(B=this._outlineStickImposterMaterial),this.renderBuffer(l,d,i,B,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,D,c){c.r(D),c.d(D,{SpritePlugin:()=>O});var y=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(p){this.gl=p.context,this.renderer=p,this.precision=p.getPrecision(),this.sprite.vertices=new Float32Array(16),this.sprite.faces=new Uint16Array(6);var E=0;this.sprite.vertices[E++]=-1,this.sprite.vertices[E++]=-1,this.sprite.vertices[E++]=0,this.sprite.vertices[E++]=0,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=-1,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=0,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=-1,this.sprite.vertices[E++]=1,this.sprite.vertices[E++]=0,this.sprite.vertices[E++]=1,E=0,this.sprite.faces[E++]=0,this.sprite.faces[E++]=1,this.sprite.faces[E++]=2,this.sprite.faces[E++]=0,this.sprite.faces[E++]=2,this.sprite.faces[E++]=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(y.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(p,E,M,g,x){var _,v,m,r,e,t,s,o,l,d;if(!this.gl)throw new Error("WebGLRenderer not initialized");let i=[];(_=p?.__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,E.projectionMatrix.elements),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.uniform1i(h.map,0);var L=p.fog;L?(this.gl.uniform3f(h.fogColor,L.color.r,L.color.g,L.color.b),this.gl.uniform1f(h.fogNear,L.near),this.gl.uniform1f(h.fogFar,L.far)):(this.gl.uniform1f(h.fogNear,0),this.gl.uniform1f(h.fogFar,0));var T;let S,I,z,B=[];for(T=0;T<n;T++)S=i[T],I=S.material,I&&(I.depthTest==!1&&!x||!S.visible||I.opacity===0||(I.useScreenCoordinates?S.z=-S.position.z:(S._modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,S.matrixWorld),S.z=-S._modelViewMatrix.elements[14])));for(i.sort(w),T=0;T<n;T++)if(S=i[T],I=S.material,!!I&&!(!S.visible||I.opacity===0)&&I.map&&I.map.image&&I.map.image.width){this.gl.uniform1f(h?.alphaTest||null,I.alphaTest);var F=I.map.image.width,W=I.map.image.height;B[0]=F*this.renderer.devicePixelRatio/M,B[1]=W*this.renderer.devicePixelRatio/g,I.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/(I.scaleByViewport?g:1),B[0]*=z*S.scale.x,B[1]*=z*S.scale.y;let U=(v=I?.alignment)===null||v===void 0?void 0:v.x,P=(m=I?.alignment)===null||m===void 0?void 0:m.y;I.screenOffset&&(U=(U||0)+2*I.screenOffset.x/F,P=(P||0)+2*I.screenOffset.y/W),this.gl.uniform2f(h.uvScale,((r=I?.uvScale)===null||r===void 0?void 0:r.x)||1,((e=I?.uvScale)===null||e===void 0?void 0:e.y)||1),this.gl.uniform2f(h.uvOffset,((t=I?.uvOffset)===null||t===void 0?void 0:t.x)||0,((s=I?.uvOffset)===null||s===void 0?void 0:s.y)||0),this.gl.uniform2f(h.alignment,U||0,P||0),this.gl.uniform1f(h.opacity,I.opacity),this.gl.uniform3f(h.color,((o=I?.color)===null||o===void 0?void 0:o.r)||0,((l=I?.color)===null||l===void 0?void 0:l.g)||0,((d=I?.color)===null||d===void 0?void 0:d.b)||0),this.gl.uniform1f(h.rotation,S.rotation),this.gl.uniform2fv(h.scale,B),this.renderer.setDepthTest(I.depthTest),this.renderer.setDepthWrite(I.depthWrite),this.renderer.setTexture(I.map,0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}this.gl.enable(this.gl.CULL_FACE)}createProgram(p,E){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 "+E+` float;
|
|
31
|
+
`;if(this.gl.shaderSource(g,_+p.fragmentShader),this.gl.shaderSource(x,_+p.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 w(R,p){return R.z!==p.z?p.z-R.z:p.id-R.id}},"./src/WebGL/constants/Coloring.ts"(K,D,c){c.r(D),c.d(D,{Coloring:()=>y});var y;(function(O){O[O.NoColors=0]="NoColors",O[O.FaceColors=1]="FaceColors",O[O.VertexColors=2]="VertexColors"})(y||(y={}))},"./src/WebGL/constants/Shading.ts"(K,D,c){c.r(D),c.d(D,{Shading:()=>y});var y;(function(O){O[O.NoShading=0]="NoShading",O[O.FlatShading=1]="FlatShading",O[O.SmoothShading=2]="SmoothShading"})(y||(y={}))},"./src/WebGL/constants/Sides.ts"(K,D,c){c.r(D),c.d(D,{BackSide:()=>O,DoubleSide:()=>w,FrontSide:()=>y});const y=0,O=1,w=2},"./src/WebGL/constants/SpriteAlignment.ts"(K,D,c){c.r(D),c.d(D,{SpriteAlignment:()=>O});var y=c("./src/WebGL/math/index.ts");const O={topLeft:new y.Vector2(1,-1),topCenter:new y.Vector2(0,-1),topRight:new y.Vector2(-1,-1),centerLeft:new y.Vector2(1,0),center:new y.Vector2(0,0),centerRight:new y.Vector2(-1,0),bottomLeft:new y.Vector2(1,1),bottomCenter:new y.Vector2(0,1),bottomRight:new y.Vector2(-1,1)}},"./src/WebGL/constants/TextureConstants.ts"(K,D,c){c.r(D),c.d(D,{ClampToEdgeWrapping:()=>y,FloatType:()=>E,LinearFilter:()=>O,LinearMipMapLinearFilter:()=>R,NearestFilter:()=>w,R32Format:()=>x,RFormat:()=>g,RGBAFormat:()=>M,UnsignedByteType:()=>p});const y=1001,O=1006,w=1007,R=1008,p=1009,E=1010,M=1021,g=1022,x=1023},"./src/WebGL/constants/TextureOperations.ts"(K,D,c){c.r(D),c.d(D,{TextureOperations:()=>y});var y;(function(O){O[O.MultiplyOperation=0]="MultiplyOperation",O[O.MixOperation=1]="MixOperation",O[O.AddOperation=2]="AddOperation"})(y||(y={}))},"./src/WebGL/constants/index.ts"(K,D,c){c.r(D),c.d(D,{BackSide:()=>O.BackSide,ClampToEdgeWrapping:()=>p.ClampToEdgeWrapping,Coloring:()=>y.Coloring,DoubleSide:()=>O.DoubleSide,FloatType:()=>p.FloatType,FrontSide:()=>O.FrontSide,LinearFilter:()=>p.LinearFilter,LinearMipMapLinearFilter:()=>p.LinearMipMapLinearFilter,NearestFilter:()=>p.NearestFilter,R32Format:()=>p.R32Format,RFormat:()=>p.RFormat,RGBAFormat:()=>p.RGBAFormat,Shading:()=>w.Shading,SpriteAlignment:()=>R.SpriteAlignment,TextureOperations:()=>E.TextureOperations,UnsignedByteType:()=>p.UnsignedByteType});var y=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Sides.ts"),w=c("./src/WebGL/constants/Shading.ts"),R=c("./src/WebGL/constants/SpriteAlignment.ts"),p=c("./src/WebGL/constants/TextureConstants.ts"),E=c("./src/WebGL/constants/TextureOperations.ts")},"./src/WebGL/core/EventDispatcher.ts"(K,D,c){c.r(D),c.d(D,{EventDispatcher:()=>y});class y{constructor(){this.listeners={}}dispatchEvent(w){var R=this.listeners[w.type];if(R!==void 0){w.target=this;for(var p=0,E=R.length;p<E;p++)R[p].call(this,w)}}removeEventListener(w,R){if(!R)this.listeners[w]=[];else{var p=this.listeners[w].indexOf(R);p!==-1&&this.listeners[w].splice(p,1)}}addEventListener(w,R){this.listeners[w]===void 0&&(this.listeners[w]=[]),this.listeners[w].indexOf(R)===-1&&this.listeners[w].push(R)}}},"./src/WebGL/core/Geometry.ts"(K,D,c){c.r(D),c.d(D,{Geometry:()=>M,GeometryGroup:()=>E,GeometryIDCount:()=>g});var y=c("./src/WebGL/materials/LineBasicMaterial.ts"),O=c("./src/WebGL/core/EventDispatcher.ts"),w=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts");const p=65535;class E{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 v=this.vertexArray,m=this.colorArray;if(!v)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<v.length;e+=3)m[e]=r.r,m[e+1]=r.g,m[e+2]=r.b}setColors(_){var v=this.vertexArray,m=this.colorArray;if(!v)throw new Error("vertex array not initialized");if(!m)throw new Error("color array not initialized");if(v.length!=m.length){console.log("Cannot re-color geometry group due to mismatched lengths.");return}for(var r=0;r<v.length;r+=3){var e=_(v[r],v[r+1],v[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 w.Vector3,v,m,r,e,t=0;t<this.vertices;++t)v=t*3,m=this.vertexArray[v],r=this.vertexArray[v+1],e=this.vertexArray[v+2],_.x+=m,_.y+=r,_.z+=e;return _.divideScalar(this.vertices),_}setNormals(){var _=this.faceArray,v=this.vertexArray,m=this.normalArray;if(!(!this.vertices||!this.faceidx)){if(!_)throw new Error("face array not initialized");if(!v)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 w.Vector3(v[r],v[r+1],v[r+2]),o=new w.Vector3(v[e],v[e+1],v[e+2]),l=new w.Vector3(v[t],v[t+1],v[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,v=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];v[e]=t,v[e+1]=s,v[e+2]=t,v[e+3]=o,v[e+4]=s,v[e+5]=o}}}vrml(_,v){var m,r,e,t,s,o,l,d,i,n,a,h,u,A,L,T,S,I,z="";if(z+=_+`Shape {
|
|
34
|
+
`+_+` appearance Appearance {
|
|
35
|
+
`+_+` material Material {
|
|
36
|
+
`+_+" diffuseColor "+((m=v?.color)===null||m===void 0?void 0:m.r)+" "+((r=v?.color)===null||r===void 0?void 0:r.g)+" "+((e=v?.color)===null||e===void 0?void 0:e.b)+`
|
|
37
|
+
`,v.wireframe&&this.colorArray){let F=this.colorArray;z+=_+" emissiveColor "+F[0]+" "+F[1]+" "+F[2]+`
|
|
38
|
+
`}v?.transparent&&(z+=_+" transparency "+(1-v.opacity)+`
|
|
39
|
+
`),z+=_+` }
|
|
40
|
+
`,z+=_+` }
|
|
41
|
+
`;var B=_;if(_+=" ",v instanceof y.LineBasicMaterial||v.wireframe){z+=_+`geometry IndexedLineSet {
|
|
42
|
+
`+_+` colorPerVertex TRUE
|
|
43
|
+
`+_+` coord Coordinate {
|
|
44
|
+
`+_+` point [
|
|
45
|
+
`;let F,W,U;for(let P=0;P<this.vertices;++P){let N=P*3;F=(t=this.vertexArray)===null||t===void 0?void 0:t[N],W=(s=this.vertexArray)===null||s===void 0?void 0:s[N+1],U=(o=this.vertexArray)===null||o===void 0?void 0:o[N+2],z+=_+" "+F+" "+W+" "+U+`,
|
|
46
|
+
`}if(z+=_+` ]
|
|
47
|
+
`,z+=_+` }
|
|
48
|
+
`,this.colorArray&&!v.wireframe){z+=_+` color Color {
|
|
49
|
+
`+_+` color [
|
|
50
|
+
`;for(let P=0;P<this.vertices;++P){let N=P*3;F=this.colorArray[N],W=this.colorArray[N+1],U=this.colorArray[N+2],z+=_+" "+F+" "+W+" "+U+`,
|
|
51
|
+
`}z+=_+` ]
|
|
52
|
+
`,z+=_+` }
|
|
53
|
+
`}if(z+=_+` coordIndex [
|
|
54
|
+
`,v.wireframe&&this.faceArray)for(let P=0;P<this.faceidx;P+=3)F=(l=this.faceArray)===null||l===void 0?void 0:l[P],W=(d=this.faceArray)===null||d===void 0?void 0:d[P+1],U=(i=this.faceArray)===null||i===void 0?void 0:i[P+2],z+=_+" "+F+", "+W+", "+U+`, -1,
|
|
55
|
+
`;else for(let P=0;P<this.vertices-1;P+=2)z+=_+" "+P+", "+(P+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 F,W,U;for(let P=0;P<this.vertices;++P){let N=P*3;F=(n=this.vertexArray)===null||n===void 0?void 0:n[N],W=(a=this.vertexArray)===null||a===void 0?void 0:a[N+1],U=(h=this.vertexArray)===null||h===void 0?void 0:h[N+2],z+=_+" "+F+" "+W+" "+U+`,
|
|
65
|
+
`}z+=_+` ]
|
|
66
|
+
`,z+=_+` }
|
|
67
|
+
`,z+=_+` normal Normal {
|
|
68
|
+
`+_+` vector [
|
|
69
|
+
`;for(let P=0;P<this.vertices;++P){let N=P*3;F=(u=this.normalArray)===null||u===void 0?void 0:u[N],W=(A=this.normalArray)===null||A===void 0?void 0:A[N+1],U=(L=this.normalArray)===null||L===void 0?void 0:L[N+2],z+=_+" "+F+" "+W+" "+U+`,
|
|
70
|
+
`}if(z+=_+` ]
|
|
71
|
+
`,z+=_+` }
|
|
72
|
+
`,this.colorArray){z+=_+` color Color {
|
|
73
|
+
`+_+` color [
|
|
74
|
+
`;for(let P=0;P<this.vertices;++P){let N=P*3;F=this.colorArray[N],W=this.colorArray[N+1],U=this.colorArray[N+2],z+=_+" "+F+" "+W+" "+U+`,
|
|
75
|
+
`}z+=_+` ]
|
|
76
|
+
`,z+=_+` }
|
|
77
|
+
`}z+=_+` coordIndex [
|
|
78
|
+
`;for(let P=0;P<this.faceidx;P+=3)F=(T=this.faceArray)===null||T===void 0?void 0:T[P],W=(S=this.faceArray)===null||S===void 0?void 0:S[P+1],U=(I=this.faceArray)===null||I===void 0?void 0:I[P+2],z+=_+" "+F+", "+W+", "+U+`, -1,
|
|
79
|
+
`;z+=_+` ]
|
|
80
|
+
`,z+=_+`}
|
|
81
|
+
`}return z+=B+"}",z}truncateArrayBuffers(_=!0,v=!1){var m=this.vertexArray,r=this.colorArray,e=this.normalArray,t=this.faceArray,s=this.lineArray,o=this.radiusArray;this.vertexArray=m?.subarray(0,this.vertices*3)||null,this.colorArray=r?.subarray(0,this.vertices*3)||null,_?(this.normalArray=e?.subarray(0,this.vertices*3)||null,this.faceArray=t?.subarray(0,this.faceidx)||null,this.lineidx>0?this.lineArray=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)),v&&(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,v=!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=v,this.offset=m}updateGeoGroup(_=0){var v,m=this.groups>0?this.geometryGroups[this.groups-1]:null;return(!m||m.vertices+_>(((v=m?.vertexArray)===null||v===void 0?void 0:v.length)||0)/3)&&(m=this.addGeoGroup()),m}vrml(_,v){for(var m="",r=this.geometryGroups.length,e=0;e<r;e++){var t=this.geometryGroups[e];m+=t.vrml(_,v)+`,
|
|
82
|
+
`}return m}addGeoGroup(){var _=new E(this.geometryGroups.length);return this.geometryGroups.push(_),this.groups=this.geometryGroups.length,_.vertexArray=new Float32Array(p*3),_.colorArray=new Float32Array(p*3),this.mesh&&(_.normalArray=new Float32Array(p*3),_.faceArray=new Uint16Array(p*6),_.lineArray=new Uint16Array(p*6)),this.radii&&(_.radiusArray=new Float32Array(p)),_.useOffset=this.offset,_}setUpNormals(..._){for(var v=0;v<this.groups;v++){var m=this.geometryGroups[v];m.setNormals(..._)}}setColors(..._){for(var v=this.geometryGroups.length,m=0;m<v;m++){var r=this.geometryGroups[m];r.setColors(..._)}}setColor(..._){let v=this.geometryGroups.length;for(var m=0;m<v;m++){var r=this.geometryGroups[m];r.setColor(..._)}}setUpWireframe(..._){let v=this.geometryGroups.length;for(var m=0;m<v;m++){var r=this.geometryGroups[m];r.setLineIndices(..._)}}initTypedArrays(){for(var _=0;_<this.groups;_++){var v=this.geometryGroups[_];v.__inittedArrays!==!0&&v.truncateArrayBuffers(this.mesh,!1)}}dispose(){this.dispatchEvent({type:"dispose"})}get vertices(){for(var _=0,v=0;v<this.groups;v++)_+=this.geometryGroups[v].vertices;return _}}let g=0},"./src/WebGL/core/Object3D.ts"(K,D,c){c.r(D),c.d(D,{Light:()=>E,Object3D:()=>R,Object3DIDCount:()=>w,Scene:()=>p});var y=c("./src/WebGL/math/index.ts"),O=c("./src/colors.ts");let w=0;class R{constructor(){this.id=w++,this.name="",this.children=[],this.position=new y.Vector3,this.rotation=new y.Vector3,this.matrix=new y.Matrix4,this.matrixWorld=new y.Matrix4,this.quaternion=new y.Quaternion,this.eulerOrder="XYZ",this.up=new y.Vector3(0,1,0),this.scale=new y.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 y.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 p&&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 p&&_.__removeObject(g)}}vrml(g){g||(g=" ");var x=2*Math.atan2(this.quaternion.lengthxyz(),this.quaternion.w),_=0,v=0,m=0;if(x!=0){let t=Math.sin(x/2);_=this.quaternion.x/t,v=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 "+_+" "+v+" "+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 y.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 y.Vector3&&this.rotation instanceof y.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 p 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 E)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 E)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 v=0;v<g.children.length;v++)this.__removeObject(g.children[v])}}class E extends R{constructor(g,x=1){super(),this.position=new y.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,D,c){c.r(D),c.d(D,{Projector:()=>w});var y=c("./src/WebGL/math/index.ts");const O=new y.Matrix4;class w{static unprojectVector(p,E){return E.projectionMatrixInverse.getInverse(E.projectionMatrix),O.multiplyMatrices(E.matrixWorld,E.projectionMatrixInverse),p.applyProjection(O)}static projectVector(p,E){return E.matrixWorldInverse.getInverse(E.matrixWorld),O.multiplyMatrices(E.projectionMatrix,E.matrixWorldInverse),p.applyProjection(O)}projectVector(p,E){return w.projectVector(p,E)}unprojectVector(p,E){return w.unprojectVector(p,E)}}},"./src/WebGL/core/Raycaster.ts"(K,D,c){c.r(D),c.d(D,{Raycaster:()=>p,intersectObject:()=>t});var y=c("./src/WebGL/math/index.ts"),O=c("./src/WebGL/shapes/index.ts");const w=(s,o)=>s.distance-o.distance,R=new y.Matrix4;class p{constructor(o,l,d,i){this.precision=1e-4,this.linePrecision=.2,this.ray=new y.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(w),d}}const E=s=>Math.min(Math.max(s,-1),1);var M=new O.Sphere,g=new O.Cylinder,x=new O.Triangle,_=new y.Vector3,v=new y.Vector3,m=new y.Vector3,r=new y.Vector3,e=new y.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,L,T,S,I,z,B,F,W,U,P,N;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(),L=l.ray.direction.dot(A),L>=0||(_.subVectors(x.a,l.ray.origin),I=A.dot(_)/L,I<0))continue;v.copy(l.ray.direction).multiplyScalar(I).add(l.ray.origin),v.sub(x.a),m.copy(x.b).sub(x.a),r.copy(x.c).sub(x.a);var q=m.dot(r),ee=m.lengthSq(),ie=r.lengthSq();if(U=(ee*v.dot(r)-q*v.dot(m))/(ee*ie-q*q),U<0||U>1||(W=(v.dot(m)-U*q)/ee,W<0||W>1||W+U>1))continue;d.push({clickable:o,distance:I})}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),L=E(l.ray.direction.dot(g.direction)),B=1-L*L,B===0)continue;P=(L*S-T)/B,N=(S-L*T)/B,v.copy(g.direction).multiplyScalar(P).add(g.c1),m.copy(l.ray.direction).multiplyScalar(N).add(l.ray.origin),z=r.subVectors(v,m).lengthSq();var ne=g.radius*g.radius;if(z<=ne){if(F=(L*T-S)*(L*T-S)-B*(_.lengthSq()-T*T-ne),F<=0?U=I=Math.sqrt(z):U=I=(S-L*T-Math.sqrt(F))/B,W=L*U-T,W<0||W*W>g.lengthSq()||U<0)continue;d.push({clickable:o,distance:I})}}for(h=0,u=i.line.length;h<u;h+=2){v.copy(i.line[h]),v.applyMatrix4(s.matrixWorld),m.copy(i.line[h+1]),m.applyMatrix4(s.matrixWorld),r.subVectors(m,v);var de=r.lengthSq();r.normalize(),_.subVectors(v,l.ray.origin);var re=_.dot(r);S=_.dot(l.ray.direction),L=E(l.ray.direction.dot(r)),B=1-L*L,B!==0&&(P=(L*S-re)/B,N=(S-L*re)/B,v.add(r.multiplyScalar(P)),m.copy(l.ray.direction).multiplyScalar(N).add(l.ray.origin),z=r.subVectors(m,v).lengthSq(),z<a&&P*P<de&&d.push({clickable:o,distance:N}))}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))){v.subVectors(M.center,l.ray.origin);var oe=v.dot(l.ray.direction);if(F=oe*oe-(v.lengthSq()-M.radius*M.radius),oe<0)return d;F<=0?I=oe:I=oe-Math.sqrt(F),d.push({clickable:o,distance:I})}return d}},"./src/WebGL/core/Texture.ts"(K,D,c){c.r(D),c.d(D,{Texture:()=>p,TextureIdCount:()=>E});var y=c("./src/WebGL/constants/TextureConstants.ts"),O=c("./src/WebGL/math/index.ts"),w=c("./src/WebGL/core/EventDispatcher.ts"),R=c("./src/WebGL/core/UVMapping.ts");class p extends w.EventDispatcher{constructor(g,x){super(),this.id=E++,this.name="",this.image=g,this.mapping=new R.UVMapping,this.wrapS=y.ClampToEdgeWrapping,this.wrapT=y.ClampToEdgeWrapping,this.anisotropy=1,x?(this.format=y.RFormat,this.type=y.FloatType,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.magFilter=y.NearestFilter,this.minFilter=y.NearestFilter):(this.format=y.RGBAFormat,this.type=y.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=y.LinearFilter,this.minFilter=y.LinearMipMapLinearFilter),this.needsUpdate=!1,this.onUpdate=null}clone(g=new p){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 E=0},"./src/WebGL/core/UVMapping.ts"(K,D,c){c.r(D),c.d(D,{UVMapping:()=>y});class y{}},"./src/WebGL/core/index.ts"(K,D,c){c.r(D),c.d(D,{EventDispatcher:()=>y.EventDispatcher,Geometry:()=>O.Geometry,GeometryGroup:()=>O.GeometryGroup,GeometryIDCount:()=>O.GeometryIDCount,Light:()=>w.Light,Object3D:()=>w.Object3D,Object3DIDCount:()=>w.Object3DIDCount,Projector:()=>R.Projector,Raycaster:()=>p.Raycaster,Scene:()=>w.Scene,Texture:()=>E.Texture,TextureIdCount:()=>E.TextureIdCount,UVMapping:()=>M.UVMapping,intersectObject:()=>p.intersectObject});var y=c("./src/WebGL/core/EventDispatcher.ts"),O=c("./src/WebGL/core/Geometry.ts"),w=c("./src/WebGL/core/Object3D.ts"),R=c("./src/WebGL/core/Projector.ts"),p=c("./src/WebGL/core/Raycaster.ts"),E=c("./src/WebGL/core/Texture.ts"),M=c("./src/WebGL/core/UVMapping.ts")},"./src/WebGL/index.ts"(K,D,c){c.r(D),c.d(D,{BackSide:()=>y.BackSide,Camera:()=>g.Camera,ClampToEdgeWrapping:()=>y.ClampToEdgeWrapping,Coloring:()=>y.Coloring,Cylinder:()=>M.Cylinder,DoubleSide:()=>y.DoubleSide,EventDispatcher:()=>O.EventDispatcher,FloatType:()=>y.FloatType,Fog:()=>x.Fog,FrontSide:()=>y.FrontSide,Geometry:()=>O.Geometry,GeometryGroup:()=>O.GeometryGroup,GeometryIDCount:()=>O.GeometryIDCount,ImposterMaterial:()=>w.ImposterMaterial,InstancedMaterial:()=>w.InstancedMaterial,Light:()=>O.Light,Line:()=>p.Line,LineBasicMaterial:()=>w.LineBasicMaterial,LineStyle:()=>p.LineStyle,LinearFilter:()=>y.LinearFilter,LinearMipMapLinearFilter:()=>y.LinearMipMapLinearFilter,Material:()=>w.Material,MaterialIdCount:()=>w.MaterialIdCount,Matrix3:()=>R.Matrix3,Matrix4:()=>R.Matrix4,Mesh:()=>p.Mesh,MeshDoubleLambertMaterial:()=>w.MeshDoubleLambertMaterial,MeshLambertMaterial:()=>w.MeshLambertMaterial,MeshOutlineMaterial:()=>w.MeshOutlineMaterial,NearestFilter:()=>y.NearestFilter,Object3D:()=>O.Object3D,Object3DIDCount:()=>O.Object3DIDCount,Projector:()=>O.Projector,Quaternion:()=>R.Quaternion,R32Format:()=>y.R32Format,RFormat:()=>y.RFormat,RGBAFormat:()=>y.RGBAFormat,Ray:()=>R.Ray,Raycaster:()=>O.Raycaster,Renderer:()=>_.Renderer,RingImposterMaterial:()=>w.RingImposterMaterial,Scene:()=>O.Scene,ShaderLib:()=>E.ShaderLib,ShaderUtils:()=>E.ShaderUtils,Shading:()=>y.Shading,Sphere:()=>M.Sphere,SphereImposterMaterial:()=>w.SphereImposterMaterial,SphereImposterOutlineMaterial:()=>w.SphereImposterOutlineMaterial,Sprite:()=>p.Sprite,SpriteAlignment:()=>y.SpriteAlignment,SpriteMaterial:()=>w.SpriteMaterial,SpritePlugin:()=>v.SpritePlugin,StickImposterMaterial:()=>w.StickImposterMaterial,StickImposterOutlineMaterial:()=>w.StickImposterOutlineMaterial,Texture:()=>O.Texture,TextureIdCount:()=>O.TextureIdCount,TextureOperations:()=>y.TextureOperations,Triangle:()=>M.Triangle,UVMapping:()=>O.UVMapping,UnsignedByteType:()=>y.UnsignedByteType,Vector2:()=>R.Vector2,Vector3:()=>R.Vector3,VolumetricMaterial:()=>w.VolumetricMaterial,basic:()=>E.basic,clamp:()=>R.clamp,clone:()=>E.clone,conversionMatrix3:()=>R.conversionMatrix3,degToRad:()=>R.degToRad,instanced:()=>E.instanced,intersectObject:()=>O.intersectObject,lambert:()=>E.lambert,lambertdouble:()=>E.lambertdouble,outline:()=>E.outline,ringimposter:()=>E.ringimposter,screen:()=>E.screen,screenaa:()=>E.screenaa,sphereimposter:()=>E.sphereimposter,sphereimposteroutline:()=>E.sphereimposteroutline,sprite:()=>E.sprite,stickimposter:()=>E.stickimposter,stickimposteroutline:()=>E.stickimposteroutline,volumetric:()=>E.volumetric});var y=c("./src/WebGL/constants/index.ts"),O=c("./src/WebGL/core/index.ts"),w=c("./src/WebGL/materials/index.ts"),R=c("./src/WebGL/math/index.ts"),p=c("./src/WebGL/objects/index.ts"),E=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"),v=c("./src/WebGL/SpritePlugin.ts")},"./src/WebGL/materials/ImposterMaterial.ts"(K,D,c){c.r(D),c.d(D,{ImposterMaterial:()=>E});var y=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),w=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),p=c("./src/WebGL/materials/Material.ts");class E extends p.Material{constructor(g){super(),this.color=new w.Color(16777215),this.ambient=new w.Color(1048575),this.emissive=new w.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=y.Coloring.NoColors,this.skinning=!1,this.setValues(g)}clone(g=new E){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,D,c){c.r(D),c.d(D,{InstancedMaterial:()=>E});var y=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),w=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),p=c("./src/WebGL/materials/Material.ts");class E extends p.Material{constructor(g){super(),this.color=new w.Color(16777215),this.ambient=new w.Color(1048575),this.emissive=new w.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=y.Coloring.NoColors,this.skinning=!1,this.sphere=null,this.setValues(g)}clone(g=new E){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,D,c){c.r(D),c.d(D,{LineBasicMaterial:()=>w});var y=c("./src/colors.ts"),O=c("./src/WebGL/materials/Material.ts");class w extends O.Material{constructor(p){super(),this.color=new y.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.vertexColors=!1,this.fog=!0,this.shaderID="basic",this.setValues(p)}clone(p=new w){return super.clone.call(this,p),p.color.copy(this.color),p}}},"./src/WebGL/materials/Material.ts"(K,D,c){c.r(D),c.d(D,{Material:()=>p,MaterialIdCount:()=>E});var y=c("./src/WebGL/constants/Sides.ts"),O=c("./src/WebGL/core/index.ts"),w=c("./src/WebGL/math/index.ts"),R=c("./src/colors.ts");class p extends O.EventDispatcher{constructor(){super(...arguments),this.id=E++,this.name="",this.side=y.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 v=this[x];v instanceof R.Color&&_ instanceof R.Color?v.copy(_):v instanceof R.Color?v.set(_):v instanceof w.Vector3&&_ instanceof w.Vector3?v.copy(_):this[x]=_}}}clone(g=new p){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 E=0},"./src/WebGL/materials/MeshDoubleLambertMaterial.ts"(K,D,c){c.r(D),c.d(D,{MeshDoubleLambertMaterial:()=>w});var y=c("./src/WebGL/constants/Sides.ts"),O=c("./src/WebGL/materials/MeshLambertMaterial.ts");class w extends O.MeshLambertMaterial{constructor(p){super(p),this.shaderID="lambertdouble",this.side=y.DoubleSide,this.outline=!1}clone(p=new w){return super.clone.call(this,p),p}}},"./src/WebGL/materials/MeshLambertMaterial.ts"(K,D,c){c.r(D),c.d(D,{MeshLambertMaterial:()=>E});var y=c("./src/WebGL/constants/Coloring.ts"),O=c("./src/WebGL/constants/Shading.ts"),w=c("./src/WebGL/materials/Material.ts"),R=c("./src/colors.ts"),p=c("./src/WebGL/math/index.ts");class E extends w.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 p.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=y.Coloring.NoColors,this.skinning=!1,this.setValues(g)}clone(g=new E){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,D,c){c.r(D),c.d(D,{MeshOutlineMaterial:()=>w});var y=c("./src/colors.ts"),O=c("./src/WebGL/materials/Material.ts");class w extends O.Material{constructor(p){super(),p=p||{},this.fog=!0,this.shaderID="outline",this.wireframe=!1,this.outlineColor=y.CC.color(p.color||new y.Color(0,0,0)),this.outlineWidth=p.width||.1,this.outlinePushback=p.pushback||1,this.outlineMaxPixels=p.maxpixels||0}clone(p=new w){return super.clone.call(this,p),p.fog=this.fog,p.shaderID=this.shaderID,p.wireframe=this.wireframe,p.outlineColor=this.outlineColor,p.outlineWidth=this.outlineWidth,p.outlinePushback=this.outlinePushback,p.outlineMaxPixels=this.outlineMaxPixels,p}}},"./src/WebGL/materials/RingImposterMaterial.ts"(K,D,c){c.r(D),c.d(D,{RingImposterMaterial:()=>O});var y=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends y.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,D,c){c.r(D),c.d(D,{SphereImposterMaterial:()=>O});var y=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends y.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,D,c){c.r(D),c.d(D,{SphereImposterOutlineMaterial:()=>w});var y=c("./src/colors.ts"),O=c("./src/WebGL/materials/ImposterMaterial.ts");class w extends O.ImposterMaterial{constructor(p){super(p),p=p||{},this.shaderID="sphereimposteroutline",this.outlineColor=y.CC.color(p.color||new y.Color(0,0,0)),this.outlineWidth=p.width||.1,this.outlinePushback=p.pushback||1,this.outlineMaxPixels=p.maxpixels||0,this.setValues(p)}clone(p=new w){return super.clone.call(this,p),p.outlineColor=this.outlineColor,p.outlineWidth=this.outlineWidth,p.outlinePushback=this.outlinePushback,p.outlineMaxPixels=this.outlineMaxPixels,p}}},"./src/WebGL/materials/SpriteMaterial.ts"(K,D,c){c.r(D),c.d(D,{SpriteMaterial:()=>E});var y=c("./src/WebGL/constants/SpriteAlignment.ts"),O=c("./src/WebGL/core/Texture.ts"),w=c("./src/colors.ts"),R=c("./src/WebGL/math/index.ts"),p=c("./src/WebGL/materials/Material.ts");class E extends p.Material{constructor(g){super(),this.color=new w.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=y.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 E){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,D,c){c.r(D),c.d(D,{StickImposterMaterial:()=>O});var y=c("./src/WebGL/materials/ImposterMaterial.ts");class O extends y.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,D,c){c.r(D),c.d(D,{StickImposterOutlineMaterial:()=>w});var y=c("./src/colors.ts"),O=c("./src/WebGL/materials/ImposterMaterial.ts");class w extends O.ImposterMaterial{constructor(p={}){super(p),this.shaderID="stickimposteroutline",this.outlineColor=new y.Color(0,0,0),this.outlineWidth=.1,this.outlinePushback=1,this.outlineMaxPixels=0,p.color&&(this.outlineColor=y.CC.color(p.color)),p.width&&(this.outlineWidth=p.width),p.pushback&&(this.outlinePushback=p.pushback),p.maxpixels&&(this.outlineMaxPixels=p.maxpixels),this.setValues(p)}clone(p=new w){return super.clone.call(this,p),p.outlineColor=this.outlineColor,p.outlineWidth=this.outlineWidth,p.outlinePushback=this.outlinePushback,p.outlineMaxPixels=this.outlineMaxPixels,p}}},"./src/WebGL/materials/VolumetricMaterial.ts"(K,D,c){c.r(D),c.d(D,{VolumetricMaterial:()=>R});var y=c("./src/WebGL/constants/Sides.ts"),O=c("./src/colors.ts"),w=c("./src/WebGL/materials/Material.ts");class R extends w.Material{constructor(E){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=y.FrontSide,this.setValues(E)}clone(E=new R){return super.clone.call(this,E),E.transparent=this.transparent,E.volumetric=this.volumetric,E.color=this.color,E.transferfn=this.transferfn,E.map=this.map,E.extent=this.extent,E.maxdepth=this.maxdepth,E.unit=this.unit,E.texmatrix=this.texmatrix,E.transfermin=this.transfermin,E.transfermax=this.transfermax,E.subsamples=this.subsamples,E.shaderID=this.shaderID,E.side=this.side,E}}},"./src/WebGL/materials/index.ts"(K,D,c){c.r(D),c.d(D,{ImposterMaterial:()=>y.ImposterMaterial,InstancedMaterial:()=>O.InstancedMaterial,LineBasicMaterial:()=>w.LineBasicMaterial,Material:()=>R.Material,MaterialIdCount:()=>R.MaterialIdCount,MeshDoubleLambertMaterial:()=>p.MeshDoubleLambertMaterial,MeshLambertMaterial:()=>E.MeshLambertMaterial,MeshOutlineMaterial:()=>M.MeshOutlineMaterial,RingImposterMaterial:()=>g.RingImposterMaterial,SphereImposterMaterial:()=>x.SphereImposterMaterial,SphereImposterOutlineMaterial:()=>_.SphereImposterOutlineMaterial,SpriteMaterial:()=>v.SpriteMaterial,StickImposterMaterial:()=>m.StickImposterMaterial,StickImposterOutlineMaterial:()=>r.StickImposterOutlineMaterial,VolumetricMaterial:()=>e.VolumetricMaterial});var y=c("./src/WebGL/materials/ImposterMaterial.ts"),O=c("./src/WebGL/materials/InstancedMaterial.ts"),w=c("./src/WebGL/materials/LineBasicMaterial.ts"),R=c("./src/WebGL/materials/Material.ts"),p=c("./src/WebGL/materials/MeshDoubleLambertMaterial.ts"),E=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"),v=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,D,c){c.r(D),c.d(D,{Quaternion:()=>y});class y{constructor(w,R,p,E){this.x=w||0,this.y=R||0,this.z=p||0,this.w=E!==void 0?E:1}set(w,R,p,E){return this.x=w,this.y=R,this.z=p,this.w=E,this}copy(w){return this.x=w.x,this.y=w.y,this.z=w.z,this.w=w.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 w=this.length();return w===0?(this.x=0,this.y=0,this.z=0,this.w=1):(w=1/w,this.x*=w,this.y*=w,this.z*=w,this.w*=w),this}multiply(w){return this.multiplyQuaternions(this,w)}multiplyScalar(w){return this.x*=w,this.y*=w,this.z*=w,this.w*=w,this}multiplyQuaternions(w,R){const p=w.x,E=w.y,M=w.z,g=w.w,x=R.x,_=R.y,v=R.z,m=R.w;return this.x=p*m+g*x+E*v-M*_,this.y=E*m+g*_+M*x-p*v,this.z=M*m+g*v+p*_-E*x,this.w=g*m-p*x-E*_-M*v,this}sub(w){return this.x-=w.x,this.y-=w.y,this.z-=w.z,this.w-=w.w,this}clone(){return new y(this.x,this.y,this.z,this.w)}setFromEuler(w){const R=Math.cos(w.x/2),p=Math.cos(w.y/2),E=Math.cos(w.z/2),M=Math.sin(w.x/2),g=Math.sin(w.y/2),x=Math.sin(w.z/2);return this.x=M*p*E+R*g*x,this.y=R*g*E-M*p*x,this.z=R*p*x+M*g*E,this.w=R*p*E-M*g*x,this}}},"./src/WebGL/math/Vector2.ts"(K,D,c){c.r(D),c.d(D,{Vector2:()=>y});class y{constructor(w,R){this.x=w||0,this.y=R||0}set(w,R){return this.x=w,this.y=R,this}subVectors(w,R){return this.x=w.x-R.x,this.y=w.y-R.y,this}copy(w){return this.x=w.x,this.y=w.y,this}clone(){return new y(this.x,this.y)}}},"./src/WebGL/math/index.ts"(K,D,c){c.r(D),c.d(D,{Matrix3:()=>E.Matrix3,Matrix4:()=>E.Matrix4,Quaternion:()=>y.Quaternion,Ray:()=>E.Ray,Vector2:()=>O.Vector2,Vector3:()=>E.Vector3,clamp:()=>w.clamp,conversionMatrix3:()=>R.conversionMatrix3,degToRad:()=>p.degToRad});var y=c("./src/WebGL/math/Quaternion.ts"),O=c("./src/WebGL/math/Vector2.ts"),w=c("./src/WebGL/math/utils/clamp.ts"),R=c("./src/WebGL/math/utils/conversionMatrix3.ts"),p=c("./src/WebGL/math/utils/degToRad.ts"),E=c("./src/WebGL/math/math.ts")},"./src/WebGL/math/math.ts"(K,D,c){c.r(D),c.d(D,{Matrix3:()=>_,Matrix4:()=>g,Ray:()=>v,Vector3:()=>x});var y=c("./src/WebGL/math/utils/degToRad.ts"),O=c("./src/WebGL/math/utils/clamp.ts"),w,R,p,E,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,L=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]=L,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,L,T,S){const I=this.elements;return I[0]=r,I[4]=e,I[8]=t,I[12]=s,I[1]=o,I[5]=l,I[9]=d,I[13]=i,I[2]=n,I[6]=a,I[10]=h,I[14]=u,I[3]=A,I[7]=L,I[11]=T,I[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,L=d*u,T=i*h,S=i*u;t[0]=n*h,t[4]=-n*u,t[8]=a,t[1]=L+T*a,t[5]=A-S*a,t[9]=-i*n,t[2]=S-A*a,t[6]=T+L*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,L=s*n,T=o*n,S=l*d,I=l*i,z=l*n;return e[0]=1-(A+T),e[4]=h-z,e[8]=u+I,e[1]=h+z,e[5]=1-(a+T),e[9]=L-S,e[2]=u-I,e[6]=L+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],L=t[2],T=t[6],S=t[10],I=t[14],z=t[3],B=t[7],F=t[11],W=t[15],U=s[0],P=s[4],N=s[8],q=s[12],ee=s[1],ie=s[5],ne=s[9],de=s[13],re=s[2],oe=s[6],be=s[10],_e=s[14],Oe=s[3],Me=s[7],J=s[11],ve=s[15];return o[0]=l*U+d*ee+i*re+n*Oe,o[4]=l*P+d*ie+i*oe+n*Me,o[8]=l*N+d*ne+i*be+n*J,o[12]=l*q+d*de+i*_e+n*ve,o[1]=a*U+h*ee+u*re+A*Oe,o[5]=a*P+h*ie+u*oe+A*Me,o[9]=a*N+h*ne+u*be+A*J,o[13]=a*q+h*de+u*_e+A*ve,o[2]=L*U+T*ee+S*re+I*Oe,o[6]=L*P+T*ie+S*oe+I*Me,o[10]=L*N+T*ne+S*be+I*J,o[14]=L*q+T*de+S*_e+I*ve,o[3]=z*U+B*ee+F*re+W*Oe,o[7]=z*P+B*ie+F*oe+W*Me,o[11]=z*N+B*ne+F*be+W*J,o[15]=z*q+B*de+F*_e+W*ve,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],L=s[6],T=s[10],S=s[14],I=s[3],z=s[7],B=s[11],F=s[15];t[0]=h*S*z-u*T*z+u*L*B-a*S*B-h*L*F+a*T*F,t[4]=i*T*z-d*S*z-i*L*B+l*S*B+d*L*F-l*T*F,t[8]=d*u*z-i*h*z+i*a*B-l*u*B-d*a*F+l*h*F,t[12]=i*h*L-d*u*L-i*a*T+l*u*T+d*a*S-l*h*S,t[1]=u*T*I-h*S*I-u*A*B+n*S*B+h*A*F-n*T*F,t[5]=d*S*I-i*T*I+i*A*B-o*S*B-d*A*F+o*T*F,t[9]=i*h*I-d*u*I-i*n*B+o*u*B+d*n*F-o*h*F,t[13]=d*u*A-i*h*A+i*n*T-o*u*T-d*n*S+o*h*S,t[2]=a*S*I-u*L*I+u*A*z-n*S*z-a*A*F+n*L*F,t[6]=i*L*I-l*S*I-i*A*z+o*S*z+l*A*F-o*L*F,t[10]=l*u*I-i*a*I+i*n*z-o*u*z-l*n*F+o*a*F,t[14]=i*a*A-l*u*A-i*n*L+o*u*L+l*n*S-o*a*S,t[3]=h*L*I-a*T*I-h*A*z+n*T*z+a*A*B-n*L*B,t[7]=l*T*I-d*L*I+d*A*z-o*T*z-l*A*B+o*L*B,t[11]=d*a*I-l*h*I-d*n*z+o*h*z+l*n*B-o*a*B,t[15]=l*h*A-d*a*A+d*n*L-o*h*L-l*n*T+o*a*T;const W=o*t[0]+n*t[4]+A*t[8]+I*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,y.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,p.set(e[0],e[1],e[2]),E.set(e[4],e[5],e[6]),M.set(e[8],e[9],e[10]),r.x=p.length(),r.y=E.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),p.crossVectors(t,M).normalize(),p.length()===0&&(M.x+=1e-4,p.crossVectors(t,M).normalize()),E.crossVectors(M,p),s[0]=p.x,s[4]=E.x,s[8]=M.x,s[1]=p.y,s[5]=E.y,s[9]=M.y,s[2]=p.z,s[6]=E.z,s[10]=M.z,this}compose(r,e,t){const s=this.elements;return w.identity(),w.setRotationFromQuaternion(e),R.makeScale(t.x,t.y,t.z),this.multiplyMatrices(w,R),s[12]=r.x,s[13]=r.y,s[14]=r.z,this}}w=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=w;return e.multiplyMatrices(r.matrixWorld,e.getInverse(r.projectionMatrix)),this.applyMatrix4(e)}}p=new x,E=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 v{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=p;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=p,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 v().copy(this)}}},"./src/WebGL/math/utils/clamp.ts"(K,D,c){c.r(D),c.d(D,{clamp:()=>y});function y(O,w,R){return Math.min(Math.max(O,w),R)}},"./src/WebGL/math/utils/conversionMatrix3.ts"(K,D,c){c.r(D),c.d(D,{conversionMatrix3:()=>O});var y=c("./src/WebGL/math/math.ts");function O(w,R,p,E,M,g){E=E*Math.PI/180,M=M*Math.PI/180,g=g*Math.PI/180;const x=t=>t*t,_=Math.cos(E),v=Math.cos(M),m=Math.cos(g),r=Math.sin(g);return new y.Matrix3(w,R*m,p*v,0,R*r,p*(_-v*m)/r,0,0,p*Math.sqrt(1-x(_)-x(v)-x(m)+2*_*v*m)/r)}},"./src/WebGL/math/utils/degToRad.ts"(K,D,c){c.r(D),c.d(D,{degToRad:()=>O});const y=Math.PI/180;function O(w){return w*y}},"./src/WebGL/objects/Line.ts"(K,D,c){c.r(D),c.d(D,{Line:()=>R,LineStyle:()=>w});var y=c("./src/WebGL/materials/index.ts"),O=c("./src/WebGL/core/index.ts"),w;(function(p){p[p.LineStrip=0]="LineStrip",p[p.LinePieces=1]="LinePieces"})(w||(w={}));class R extends O.Object3D{constructor(E,M=new y.LineBasicMaterial({color:Math.random()*16777215}),g=w.LineStrip){super(),this.geometry=E,this.material=M,this.type=g}clone(E=new R(this.geometry,this.material,this.type)){return super.clone.call(this,E),E}}},"./src/WebGL/objects/Mesh.ts"(K,D,c){c.r(D),c.d(D,{Mesh:()=>O});var y=c("./src/WebGL/core/index.ts");class O extends y.Object3D{constructor(R,p){super(),this.geometry=R,this.material=p}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,D,c){c.r(D),c.d(D,{Sprite:()=>w});var y=c("./src/WebGL/materials/index.ts"),O=c("./src/WebGL/core/index.ts");class w extends O.Object3D{constructor(p=new y.SpriteMaterial){super(),this.material=p,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(p=new w(this.material)){return O.Object3D.prototype.clone.call(this,p),p}}},"./src/WebGL/objects/index.ts"(K,D,c){c.r(D),c.d(D,{Line:()=>y.Line,LineStyle:()=>y.LineStyle,Mesh:()=>O.Mesh,Sprite:()=>w.Sprite});var y=c("./src/WebGL/objects/Line.ts"),O=c("./src/WebGL/objects/Mesh.ts"),w=c("./src/WebGL/objects/Sprite.ts")},"./src/WebGL/shaders/ShaderType.ts"(K,D,c){c.r(D)},"./src/WebGL/shaders/index.ts"(K,D,c){c.r(D),c.d(D,{ShaderLib:()=>y.ShaderLib,ShaderUtils:()=>O.ShaderUtils,basic:()=>y.basic,clone:()=>O.clone,instanced:()=>y.instanced,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 y=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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{basic:()=>R});var y=c("./src/WebGL/shaders/lib/basic/uniforms.ts"),O=c("./src/WebGL/shaders/lib/basic/basic.frag"),w=c("./src/WebGL/shaders/lib/basic/basic.vert");const R={vertexShader:w.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/basic/uniforms.ts"(K,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3}}},"./src/WebGL/shaders/lib/blur/blur.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{blur:()=>R});var y=c("./src/WebGL/shaders/lib/blur/uniforms.ts"),O=c("./src/WebGL/shaders/lib/blur/blur.frag"),w=c("./src/WebGL/shaders/lib/blur/blur.vert");const R={fragmentShader:O.default,vertexShader:w.default,uniforms:y.uniforms}},"./src/WebGL/shaders/lib/blur/uniforms.ts"(K,D,c){c.r(D),c.d(D,{uniforms:()=>y});const y={}},"./src/WebGL/shaders/lib/index.ts"(K,D,c){c.r(D),c.d(D,{ShaderLib:()=>o,basic:()=>y.basic,instanced:()=>O.instanced,lambert:()=>w.lambert,lambertdouble:()=>R.lambertdouble,outline:()=>p.outline,ringimposter:()=>g.ringimposter,screen:()=>E.screen,screenaa:()=>M.screenaa,sphereimposter:()=>x.sphereimposter,sphereimposteroutline:()=>_.sphereimposteroutline,sprite:()=>v.sprite,stickimposter:()=>m.stickimposter,stickimposteroutline:()=>r.stickimposteroutline,volumetric:()=>e.volumetric});var y=c("./src/WebGL/shaders/lib/basic/index.ts"),O=c("./src/WebGL/shaders/lib/instanced/index.ts"),w=c("./src/WebGL/shaders/lib/lambert/index.ts"),R=c("./src/WebGL/shaders/lib/lambertdouble/index.ts"),p=c("./src/WebGL/shaders/lib/outline/index.ts"),E=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"),v=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:y.basic,blur:s.blur,instanced:O.instanced,lambert:w.lambert,lambertdouble:R.lambertdouble,outline:p.outline,screen:E.screen,screenaa:M.screenaa,ssao:t.ssao,ringimposter:g.ringimposter,sphereimposter:x.sphereimposter,sphereimposteroutline:_.sphereimposteroutline,sprite:v.sprite,stickimposter:m.stickimposter,stickimposteroutline:r.stickimposteroutline,volumetric:e.volumetric}},"./src/WebGL/shaders/lib/instanced/index.ts"(K,D,c){c.r(D),c.d(D,{instanced:()=>R});var y=c("./src/WebGL/shaders/lib/instanced/uniforms.ts"),O=c("./src/WebGL/shaders/lib/instanced/instanced.frag"),w=c("./src/WebGL/shaders/lib/instanced/instanced.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/instanced/instanced.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{lambert:()=>R});var y=c("./src/WebGL/shaders/lib/lambert/uniforms.ts"),O=c("./src/WebGL/shaders/lib/lambert/lambert.frag"),w=c("./src/WebGL/shaders/lib/lambert/lambert.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/lambert/lambert.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{lambertdouble:()=>R});var y=c("./src/WebGL/shaders/lib/lambertdouble/uniforms.ts"),O=c("./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag"),w=c("./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{outline:()=>R});var y=c("./src/WebGL/shaders/lib/outline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/outline/outline.frag"),w=c("./src/WebGL/shaders/lib/outline/outline.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/outline/outline.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new y.Color(0,0,0)},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{ringimposter:()=>R});var y=c("./src/WebGL/shaders/lib/ringimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/ringimposter/ringimposter.frag"),w=c("./src/WebGL/shaders/lib/ringimposter/ringimposter.vert");const R={vertexShader:w.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/ringimposter/ringimposter.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{screen:()=>R});var y=c("./src/WebGL/shaders/lib/screen/uniforms.ts"),O=c("./src/WebGL/shaders/lib/screen/screen.frag"),w=c("./src/WebGL/shaders/lib/screen/screen.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/screen/screen.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>y});const y={}},"./src/WebGL/shaders/lib/screenaa/index.ts"(K,D,c){c.r(D),c.d(D,{screenaa:()=>R});var y=c("./src/WebGL/shaders/lib/screenaa/uniforms.ts"),O=c("./src/WebGL/shaders/lib/screenaa/screenaa.frag"),w=c("./src/WebGL/shaders/lib/screenaa/screenaa.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/screenaa/screenaa.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>y});const y={}},"./src/WebGL/shaders/lib/sphereimposter/index.ts"(K,D,c){c.r(D),c.d(D,{sphereimposter:()=>R});var y=c("./src/WebGL/shaders/lib/sphereimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag"),w=c("./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert");const R={vertexShader:w.default.replace("#define GLSLIFY 1",""),fragmentShader:O.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{sphereimposteroutline:()=>R});var y=c("./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag"),w=c("./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},outlineColor:{type:"c",value:new y.Color(0,0,0)},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{sprite:()=>R});var y=c("./src/WebGL/shaders/lib/sprite/uniforms.ts"),O=c("./src/WebGL/shaders/lib/sprite/sprite.frag"),w=c("./src/WebGL/shaders/lib/sprite/sprite.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/sprite/sprite.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>y});const y={}},"./src/WebGL/shaders/lib/ssao/index.ts"(K,D,c){c.r(D),c.d(D,{ssao:()=>R});var y=c("./src/WebGL/shaders/lib/ssao/uniforms.ts"),O=c("./src/WebGL/shaders/lib/ssao/ssao.frag"),w=c("./src/WebGL/shaders/lib/ssao/ssao.vert");const R={fragmentShader:O.default,vertexShader:w.default,uniforms:y.uniforms}},"./src/WebGL/shaders/lib/ssao/ssao.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>y});const y={total_strength:{type:"f",value:1},radius:{type:"f",value:5},projinv:{type:"mat4",value:[]}}},"./src/WebGL/shaders/lib/stickimposter/index.ts"(K,D,c){c.r(D),c.d(D,{stickimposter:()=>E});var y=c("./src/WebGL/shaders/lib/stickimposter/uniforms.ts"),O=c("./src/WebGL/shaders/lib/stickimposter/stickimposterFragmentShader.partial.frag"),w=c("./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag"),R=c("./src/WebGL/shaders/lib/stickimposter/stickimposter.vert");const E={fragmentShader:[O.default,w.default].join(`
|
|
1321
|
+
`),vertexShader:R.default,uniforms:y.uniforms}},"./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=` 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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{stickimposteroutline:()=>E});var y=c("./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts"),O=c("./src/WebGL/shaders/lib/stickimposter/stickimposterFragmentShader.partial.frag"),w=c("./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.partial.frag"),R=c("./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert");const E={fragmentShader:O.default+w.default,vertexShader:R.default,uniforms:y.uniforms}},"./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.partial.frag"(K,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.Color(1,1,1)},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},outlineColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{volumetric:()=>R});var y=c("./src/WebGL/shaders/lib/volumetric/uniforms.ts"),O=c("./src/WebGL/shaders/lib/volumetric/volumetric.frag"),w=c("./src/WebGL/shaders/lib/volumetric/volumetric.vert");const R={fragmentShader:O.default.replace("#define GLSLIFY 1",""),vertexShader:w.default.replace("#define GLSLIFY 1",""),uniforms:y.uniforms}},"./src/WebGL/shaders/lib/volumetric/uniforms.ts"(K,D,c){c.r(D),c.d(D,{uniforms:()=>O});var y=c("./src/colors.ts");const O={opacity:{type:"f",value:1},fogColor:{type:"c",value:new y.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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`
|
|
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,D,c){c.r(D),c.d(D,{default:()=>y});const y=`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,D,c){c.r(D),c.d(D,{clone:()=>O});var y=c("./src/colors.ts");function O(w){let R={};for(const E in w){R[E]={},R[E].type=w[E].type;var p=w[E].value;p instanceof y.Color?R[E].value=p.clone():typeof p=="number"?R[E].value=p:p instanceof Array?R[E].value=[]:console.error("Error copying shader uniforms from ShaderLib: unknown type for uniform")}return R}},"./src/WebGL/shaders/utils/index.ts"(K,D,c){c.r(D),c.d(D,{ShaderUtils:()=>O,clone:()=>y.clone});var y=c("./src/WebGL/shaders/utils/clone.ts");const O={clone:y.clone}},"./src/WebGL/shapes/Cylinder.ts"(K,D,c){c.r(D),c.d(D,{Cylinder:()=>w});var y=c("./src/WebGL/math/index.ts");let O=new y.Vector3;class w{constructor(p=new y.Vector3,E=new y.Vector3,M=0){this.c1=p,this.c2=E,this.radius=M,this.direction=new y.Vector3().subVectors(this.c2,this.c1).normalize()}copy(p){return this.c1.copy(p.c1),this.c2.copy(p.c2),this.direction.copy(p.direction),this.radius=p.radius,this}lengthSq(){return O.subVectors(this.c2,this.c1).lengthSq()}applyMatrix4(p){return this.direction.add(this.c1).applyMatrix4(p),this.c1.applyMatrix4(p),this.c2.applyMatrix4(p),this.direction.sub(this.c1).normalize(),this.radius=this.radius*p.getMaxScaleOnAxis(),this}}},"./src/WebGL/shapes/Sphere.ts"(K,D,c){c.r(D),c.d(D,{Sphere:()=>O});var y=c("./src/WebGL/math/index.ts");class O{constructor(R={x:0,y:0,z:0},p=0){this.center=new y.Vector3(R.x,R.y,R.z),this.radius=p}set(R,p){return this.center.copy(R),this.radius=p,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,D,c){c.r(D),c.d(D,{Triangle:()=>w});var y=c("./src/WebGL/math/index.ts");const O=new y.Vector3;class w{constructor(p=new y.Vector3,E=new y.Vector3,M=new y.Vector3){this.a=p,this.b=E,this.c=M}copy(p){return this.a.copy(p.a),this.b.copy(p.b),this.c.copy(p.c),this}applyMatrix4(p){return this.a.applyMatrix4(p),this.b.applyMatrix4(p),this.c.applyMatrix4(p),this}getNormal(){var p=this.a.clone();return p.sub(this.b),O.subVectors(this.c,this.b),p.cross(O),p.normalize(),p}}},"./src/WebGL/shapes/index.ts"(K,D,c){c.r(D),c.d(D,{Cylinder:()=>O.Cylinder,Sphere:()=>y.Sphere,Triangle:()=>w.Triangle});var y=c("./src/WebGL/shapes/Sphere.ts"),O=c("./src/WebGL/shapes/Cylinder.ts"),w=c("./src/WebGL/shapes/Triangle.ts")},"./src/autoload.ts"(K,D,c){c.r(D),c.d(D,{autoinit:()=>p,autoload:()=>g,processing_autoinit:()=>E,viewers:()=>M});var y=c("./src/GLViewer.ts"),O=c("./src/ProteinSurface4.ts"),w=c("./src/utilities.ts"),R=c("./src/colors.ts"),p=!1,E=!1,M={};function g(x,_){var v,m,r;if(document.querySelector(".viewer_3Dmoljs")!=null&&(p=!0),p){E=!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 J=l.substring(0,l.lastIndexOf(".")).lastIndexOf(".");r=l.substring(J+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(v in n)v.substring(0,3)==="pdb"&&v!=="pdb"?(s.push("https://files.rcsb.org/view/"+n[v]+".pdb"),o.push("pdb")):v.substring(0,4)==="href"&&v!=="href"?(l=n[v],s.push(l),o.push(l.substring(l.lastIndexOf(".")+1))):v.substring(0,3)==="cid"&&v!=="cid"&&(s.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/"+n[v]+"/SDF?record_type=3d"),o.push("sdf"));var a={};t.dataset.options&&(a=(0,w.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,L={line:{}};A&&(L=(0,w.specStringToObject)(t.dataset.style));var T={};t.dataset.select&&(T=(0,w.specStringToObject)(t.dataset.select));var S=[],I=[],z=[],B={},F=null,W=t.dataset,U=/style(.+)/,P=/surface(.*)/,N=/labelres(.*)/,q=[];for(m in W)Object.prototype.hasOwnProperty.call(W,m)&&q.push(m);for(q.sort(),v=0;v<q.length;v++){m=q[v];var ee=U.exec(m),ie,ne,de;ee&&(ie="select"+ee[1],ne=(0,w.specStringToObject)(W[ie]),de=(0,w.specStringToObject)(W[m]),S.push([ne,de])),ee=P.exec(m),ee&&(ie="select"+ee[1],ne=(0,w.specStringToObject)(W[ie]),de=(0,w.specStringToObject)(W[m]),I.push([ne,de])),ee=N.exec(m),ee&&(ie="select"+ee[1],ne=(0,w.specStringToObject)(W[ie]),de=(0,w.specStringToObject)(W[m]),z.push([ne,de])),m=="zoomto"&&(B=(0,w.specStringToObject)(W[m])),m=="spin"&&(F=(0,w.specStringToObject)(W[m]))}var re=function(J){for(A?J.setStyle(T,L):J.addStyle(T,L),d&&d.createSelectionAndStyle(T,L),v=0;v<S.length;v++){let ve=S[v][0]||{},Ce=S[v][1]||{line:{}};J.setStyle(ve,Ce),d&&d.createSelectionAndStyle(T,L)}for(v=0;v<I.length;v++){let ve=I[v][0]||{},Ce=I[v][1]||{};d?J.addSurface(O.SurfaceType.VDW,Ce,ve,ve).then(We=>{d.loadSurface("VDW",ve,Ce,We)}):J.addSurface(O.SurfaceType.VDW,Ce,ve,ve)}for(v=0;v<z.length;v++){let ve=z[v][0]||{},Ce=z[v][1]||{};J.addResLabels(ve,Ce)}J.render(),J.zoomTo(B),F&&J.spin(F.axis,F.speed)};let oe=x;try{var be=(0,w.specStringToObject)(t.dataset.config)||{};be.backgroundColor===void 0&&(be.backgroundColor=h),be.backgroundAlpha===void 0&&(be.backgroundAlpha=u),oe==null?oe=M[t.id||e++]=(0,y.createViewer)(t,be):(oe.setBackgroundColor(h,u),oe.setConfig(be),d&&d.initiateUI()),t.dataset.ui&&$3Dmol.StateManager&&(d=new $3Dmol.StateManager(oe))}catch(J){console.log(J),t.textContent="WebGL appears to be disabled."}if(s.length!=0){let J=0,ve=((Ce,Te)=>function(We){l=s[J];var Ie=Ce.dataset.type||Ce.dataset.datatype||o[J];if(Te.addModel(We,Ie,a),d){var Fe=Ce.dataset[o[J]];d.setModelTitle(Fe)}J+=1,J<s.length?(0,w.get)(s[J]).then(ve):(re(Te),Ce.dataset.callback&&(0,w.makeFunction)(Ce.dataset.callback)(Te),E=!1,_&&_(Te))})(t,oe);r&&r.endsWith("gz")?(0,w.getbin)(s[0]).then(ve):(0,w.get)(s[0]).then(ve)}else{if(t.dataset.element){var _e="#"+t.dataset.element,Oe=document.querySelector(_e),Me=Oe?Oe.textContent:"";r=t.dataset.type||t.dataset.datatype,oe.addModel(Me,r,a)}re(oe),t.dataset.callback&&(0,w.makeFunction)(t.dataset.callback)(oe),E=!1,_&&_(oe)}})}}document.onreadystatechange=()=>{document.readyState==="complete"&&g()}},"./src/colors.ts"(K,D,c){c.r(D),c.d(D,{CC:()=>O,Color:()=>y,builtinColorSchemes:()=>x,chains:()=>g,elementColors:()=>E,htmlColors:()=>w,residues:()=>M,ssColors:()=>R});class y{constructor(v,m,r){return this.r=0,this.g=0,this.b=0,arguments.length>1&&typeof v=="number"?(this.r=v||0,this.g=m||0,this.b=r||0,this):this.set(v||0)}set(v){return v instanceof y?v.clone():(typeof v=="number"?this.setHex(v):typeof v=="object"&&(this.r=v?.r||0,this.g=v?.g||0,this.b=v?.b||0),this)}setHex(v){return v=Math.floor(v),this.r=(v>>16&255)/255,this.g=(v>>8&255)/255,this.b=(v&255)/255,this}getHex(){var v=Math.round(this.r*255),m=Math.round(this.g*255),r=Math.round(this.b*255);return v<<16|m<<8|r}clone(){return new y(this.r,this.g,this.b)}copy(v){return this.r=v.r,this.g=v.g,this.b=v.b,this}scaled(){var v={};return v.r=Math.round(this.r*255),v.g=Math.round(this.g*255),v.b=Math.round(this.b*255),v.a=1,v}}class O{static color(v){if(!v)return O.cache[0];if(v instanceof y)return v;if(typeof v=="number"&&typeof O.cache[v]<"u")return O.cache[v];if(v&&Array.isArray(v))return v.map(O.color);let m=O.getHex(v),r=new y(m);return O.cache[m]=r,r}static getHex(v){if(Array.isArray(v))return v.map(O.getHex);if(typeof v=="string"){let m=v;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=w[m.toLowerCase()];return e!==void 0?e:(console.error("color not found",v.toLowerCase(),w),0)}return v}}O.rgbRegEx=/rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i,O.cache={0:new y(0)};const w={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}},p={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},E={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:p,defaultColors:Object.assign({},p),greenCarbon:Object.assign(Object.assign({},p),{C:65280}),cyanCarbon:Object.assign(Object.assign({},p),{C:65535}),magentaCarbon:Object.assign(Object.assign({},p),{C:16711935}),yellowCarbon:Object.assign(Object.assign({},p),{C:16776960}),whiteCarbon:Object.assign(Object.assign({},p),{C:16777215}),orangeCarbon:Object.assign(Object.assign({},p),{C:16753920}),purpleCarbon:Object.assign(Object.assign({},p),{C:8388736}),blueCarbon:Object.assign(Object.assign({},p),{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:E.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:E.rasmol},default:{prop:"elem",map:E.defaultColors},greenCarbon:{prop:"elem",map:E.greenCarbon},chainHetatm:{prop:"chain",map:g.hetatm},cyanCarbon:{prop:"elem",map:E.cyanCarbon},magentaCarbon:{prop:"elem",map:E.magentaCarbon},purpleCarbon:{prop:"elem",map:E.purpleCarbon},whiteCarbon:{prop:"elem",map:E.whiteCarbon},orangeCarbon:{prop:"elem",map:E.orangeCarbon},yellowCarbon:{prop:"elem",map:E.yellowCarbon},blueCarbon:{prop:"elem",map:E.blueCarbon}}},"./src/exporter.js"(K){typeof K.exports=="object"&&(K.exports=window.$3Dmol)},"./src/glcartoon.ts"(K,D,c){c.r(D),c.d(D,{drawCartoon:()=>L,subdivide_spline:()=>g});var y=c("./src/WebGL/math/index.ts"),O=c("./src/WebGL/shapes/index.ts"),w=c("./src/WebGL/index.ts"),R=c("./src/Gradient.ts"),p=c("./src/colors.ts"),E=c("./src/GLDraw.ts"),M=c("./src/utilities.ts");function g(T,S){var I=[],z=T;z=[],z.push(T[0]);var B,F,W,U,P,N,q,ee,ie;for(B=1,F=T.length-1;B<F;B++)if(P=T[B],N=T[B+1],P.smoothen){var ne=new y.Vector3((P.x+N.x)/2,(P.y+N.y)/2,(P.z+N.z)/2);ne.atom=P.atom,z.push(ne)}else z.push(P);for(z.push(T[T.length-1]),B=-1,W=z.length;B<=W-3;B++)if(U=z[B===-1?0:B],P=z[B+1],N=z[B+2],q=z[B===W-3?W-1:B+3],ee=new y.Vector3().subVectors(N,U).multiplyScalar(.5),ie=new y.Vector3().subVectors(q,P).multiplyScalar(.5),!N.skip)for(var de=0;de<S;de++){var re=1/S*de,oe=P.x+re*ee.x+re*re*(-3*P.x+3*N.x-2*ee.x-ie.x)+re*re*re*(2*P.x-2*N.x+ee.x+ie.x),be=P.y+re*ee.y+re*re*(-3*P.y+3*N.y-2*ee.y-ie.y)+re*re*re*(2*P.y-2*N.y+ee.y+ie.y),_e=P.z+re*ee.z+re*re*(-3*P.z+3*N.z-2*ee.z-ie.z)+re*re*re*(2*P.z-2*N.z+ee.z+ie.z),Oe=new y.Vector3(oe,be,_e);de<S/2?Oe.atom=P.atom:Oe.atom=N.atom,I.push(Oe)}return I.push(z[z.length-1]),I}const x=.5,_=1.3,v=.8,m=.4,r=.4;function e(T,S,I,z){for(var B,F,W,U,P=0,N=S.length;P<N;P++){U=Math.round(P*(z.length-1)/N),W=p.CC.color(z[U]);var q=T.updateGeoGroup(2),ee=q.vertexArray,ie=q.colorArray,ne=q.faceArray;B=q.vertices,F=B*3,ee[F]=S[P].x,ee[F+1]=S[P].y,ee[F+2]=S[P].z,ee[F+3]=I[P].x,ee[F+4]=I[P].y,ee[F+5]=I[P].z;for(var de=0;de<6;++de)ie[F+3*de]=W.r,ie[F+1+3*de]=W.g,ie[F+2+3*de]=W.b;if(P>0){var re=[B,B+1,B-1,B-2],oe=q.faceidx;ne[oe]=re[0],ne[oe+1]=re[1],ne[oe+2]=re[3],ne[oe+3]=re[1],ne[oe+4]=re[2],ne[oe+5]=re[3],q.faceidx+=6}q.vertices+=2}}function t(T,S,I,z,B,F,W){var U,P,N,q;if(N=S.length,N<2||S[0].length<2)return;for(U=0;U<N;U++)S[U]=g(S[U],z);if(q=S[0].length,!B)return e(T,S[0],S[N-1],I);var ee,ie,ne,de,re,oe,be=[],_e=[],Oe=[];for(P=0;P<N;P++)be.push(.25+1.5*Math.sqrt((N-1)*P-Math.pow(P,2))/(N-1)),_e.push(.5),Oe.push(2*(Math.pow(P/N,2)-P/N)+.6);var Me=[];for(P=0;P<N*2-1;P++)Me[P]=[P,P+1,P+1-2*N,P-2*N];Me[N*2-1]=[P,P+1-2*N,P+1-4*N,P-2*N];var J,ve,Ce,Te,We,Ie,Fe,Be,ze,Re;let Pe=T.updateGeoGroup();for(U=0;U<q;U++){let Z=T.groups,Y=!1;Pe=T.updateGeoGroup(2*N),Z!=T.groups&&U>0&&(U=U-1,Y=!0),Ie=Math.round(U*(I.length-1)/q),We=p.CC.color(I[Ie]),re=ne,oe=de,ne=[],de=[],ee=[],S[0][U].atom!==void 0&&(Te=S[0][U].atom,W==="oval"?ie=be:W==="rectangle"?ie=_e:W==="parabola"&&(ie=Oe)),ie||(ie=_e);var je,ke;for(P=0;P<N;P++)U<q-1?je=S[P][U+1].clone().sub(S[P][U]):je=S[P][U-1].clone().sub(S[P][U]).negate(),P<N-1?ke=S[P+1][U].clone().sub(S[P][U]):ke=S[P-1][U].clone().sub(S[P][U]).negate(),ee[P]=ke.cross(je).normalize().multiplyScalar(B*ie[P]);for(P=0;P<N;P++)ne[P]=S[P][U].clone().add(ee[P].clone().negate());for(P=0;P<N;P++)de[P]=S[P][U].clone().add(ee[P]);for(Fe=Pe.vertexArray,Be=Pe.colorArray,ze=Pe.faceArray,J=Pe.vertices,ve=J*3,P=0;P<N;P++)Fe[ve+3*P+0]=ne[P].x,Fe[ve+3*P+1]=ne[P].y,Fe[ve+3*P+2]=ne[P].z;for(P=0;P<N;P++)Fe[ve+3*P+0+3*N]=de[N-1-P].x,Fe[ve+3*P+1+3*N]=de[N-1-P].y,Fe[ve+3*P+2+3*N]=de[N-1-P].z;for(P=0;P<2*N;++P)Be[ve+3*P+0]=We.r,Be[ve+3*P+1]=We.g,Be[ve+3*P+2]=We.b;if(U>0&&!Y){for(P=0;P<N*2;P++)Re=[J+Me[P][0],J+Me[P][1],J+Me[P][2],J+Me[P][3]],Ce=Pe.faceidx,ze[Ce]=Re[0],ze[Ce+1]=Re[1],ze[Ce+2]=Re[3],ze[Ce+3]=Re[1],ze[Ce+4]=Re[2],ze[Ce+5]=Re[3],Pe.faceidx+=6;if(Te.clickable||Te.hoverable){var H=[];H.push(new O.Triangle(re[0],ne[0],ne[N-1])),H.push(new O.Triangle(re[0],ne[N-1],re[N-1])),H.push(new O.Triangle(re[N-1],ne[N-1],de[N-1])),H.push(new O.Triangle(re[N-1],de[N-1],oe[N-1])),H.push(new O.Triangle(de[0],oe[0],oe[N-1])),H.push(new O.Triangle(de[N-1],de[0],oe[N-1])),H.push(new O.Triangle(ne[0],re[0],oe[0])),H.push(new O.Triangle(de[0],ne[0],oe[0]));for(P in H)Te.intersectionShape.triangle.push(H[P])}}Pe.vertices+=2*N}for(Fe=Pe.vertexArray,Be=Pe.colorArray,ze=Pe.faceArray,J=Pe.vertices,ve=J*3,Ce=Pe.faceidx,U=0;U<N-1;U++)Re=[U,U+1,2*N-2-U,2*N-1-U],Ce=Pe.faceidx,ze[Ce]=Re[0],ze[Ce+1]=Re[1],ze[Ce+2]=Re[3],ze[Ce+3]=Re[1],ze[Ce+4]=Re[2],ze[Ce+5]=Re[3],Pe.faceidx+=6;for(U=0;U<N-1;U++)Re=[J-1-U,J-2-U,J-2*N+U+1,J-2*N+U],Ce=Pe.faceidx,ze[Ce]=Re[0],ze[Ce+1]=Re[1],ze[Ce+2]=Re[3],ze[Ce+3]=Re[1],ze[Ce+4]=Re[2],ze[Ce+5]=Re[3],Pe.faceidx+=6}function s(T,S,I,z,B,F){if(!(S.length<2)){var W,U;if(W=S[0],U=S[S.length-1],W=g(W,z),U=g(U,z),!B)return e(T,W,U,I);var P=[],N,q,ee,ie,ne,de=[[0,2,-6,-8],[-4,-2,6,4],[7,-1,-5,3],[-3,5,1,-7]],re,oe,be,_e,Oe,Me,J,ve,Ce,Te,We,Ie,Fe,Be,ze,Re,Pe;for(ve=0,Ce=W.length;ve<Ce;ve++){if(Oe=Math.round(ve*(I.length-1)/Ce),_e=p.CC.color(I[Oe]),P.push(q=W[ve]),P.push(q),P.push(ee=U[ve]),P.push(ee),ve<Ce-1){var je=W[ve+1].clone().sub(W[ve]),ke=U[ve].clone().sub(W[ve]);N=ke.cross(je).normalize().multiplyScalar(B)}for(P.push(ie=W[ve].clone().add(N)),P.push(ie),P.push(ne=U[ve].clone().add(N)),P.push(ne),q.atom!==void 0&&(Me=q.atom),Be=T.updateGeoGroup(8),ze=Be.vertexArray,Re=Be.colorArray,Pe=Be.faceArray,re=Be.vertices,oe=re*3,ze[oe]=q.x,ze[oe+1]=q.y,ze[oe+2]=q.z,ze[oe+3]=q.x,ze[oe+4]=q.y,ze[oe+5]=q.z,ze[oe+6]=ee.x,ze[oe+7]=ee.y,ze[oe+8]=ee.z,ze[oe+9]=ee.x,ze[oe+10]=ee.y,ze[oe+11]=ee.z,ze[oe+12]=ie.x,ze[oe+13]=ie.y,ze[oe+14]=ie.z,ze[oe+15]=ie.x,ze[oe+16]=ie.y,ze[oe+17]=ie.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)Re[oe+3*Te]=_e.r,Re[oe+1+3*Te]=_e.g,Re[oe+2+3*Te]=_e.b;if(ve>0){var H=J!==void 0&&Me!==void 0&&J.serial!==Me.serial;for(Te=0;Te<4;Te++){var Z=[re+de[Te][0],re+de[Te][1],re+de[Te][2],re+de[Te][3]];if(be=Be.faceidx,Pe[be]=Z[0],Pe[be+1]=Z[1],Pe[be+2]=Z[3],Pe[be+3]=Z[1],Pe[be+4]=Z[2],Pe[be+5]=Z[3],Be.faceidx+=6,Me.clickable||J.clickable||Me.hoverable||J.hoverable){var Y=P[Z[3]].clone(),me=P[Z[0]].clone(),ce=P[Z[2]].clone(),Ae=P[Z[1]].clone();if(Y.atom=P[Z[3]].atom||null,ce.atom=P[Z[2]].atom||null,me.atom=P[Z[0]].atom||null,Ae.atom=P[Z[1]].atom||null,H){var we=Y.clone().add(me).multiplyScalar(.5),j=ce.clone().add(Ae).multiplyScalar(.5),se=Y.clone().add(Ae).multiplyScalar(.5);Te%2===0?((J.clickable||J.hoverable)&&(We=new O.Triangle(we,se,Y),Ie=new O.Triangle(j,ce,se),Fe=new O.Triangle(se,ce,Y),J.intersectionShape.triangle.push(We),J.intersectionShape.triangle.push(Ie),J.intersectionShape.triangle.push(Fe)),(Me.clickable||Me.hoverable)&&(We=new O.Triangle(me,Ae,se),Ie=new O.Triangle(Ae,j,se),Fe=new O.Triangle(me,se,we),Me.intersectionShape.triangle.push(We),Me.intersectionShape.triangle.push(Ie),Me.intersectionShape.triangle.push(Fe))):((Me.clickable||Me.hoverable)&&(We=new O.Triangle(we,se,Y),Ie=new O.Triangle(j,ce,se),Fe=new O.Triangle(se,ce,Y),Me.intersectionShape.triangle.push(We),Me.intersectionShape.triangle.push(Ie),Me.intersectionShape.triangle.push(Fe)),(J.clickable||J.hoverable)&&(We=new O.Triangle(me,Ae,se),Ie=new O.Triangle(Ae,j,se),Fe=new O.Triangle(me,se,we),J.intersectionShape.triangle.push(We),J.intersectionShape.triangle.push(Ie),J.intersectionShape.triangle.push(Fe)))}else(Me.clickable||Me.hoverable)&&(We=new O.Triangle(me,Ae,Y),Ie=new O.Triangle(Ae,ce,Y),Me.intersectionShape.triangle.push(We),Me.intersectionShape.triangle.push(Ie))}}}Be.vertices+=8,J=Me}var ge=P.length-8;for(Be=T.updateGeoGroup(8),ze=Be.vertexArray,Re=Be.colorArray,Pe=Be.faceArray,re=Be.vertices,oe=re*3,be=Be.faceidx,ve=0;ve<4;ve++){P.push(P[ve*2]),P.push(P[ge+ve*2]);var Se=P[ve*2],te=P[ge+ve*2];ze[oe+6*ve]=Se.x,ze[oe+1+6*ve]=Se.y,ze[oe+2+6*ve]=Se.z,ze[oe+3+6*ve]=te.x,ze[oe+4+6*ve]=te.y,ze[oe+5+6*ve]=te.z,Re[oe+6*ve]=_e.r,Re[oe+1+6*ve]=_e.g,Re[oe+2+6*ve]=_e.b,Re[oe+3+6*ve]=_e.r,Re[oe+4+6*ve]=_e.g,Re[oe+5+6*ve]=_e.b}ge+=8,We=[re,re+2,re+6,re+4],Ie=[re+1,re+5,re+7,re+3],Pe[be]=We[0],Pe[be+1]=We[1],Pe[be+2]=We[3],Pe[be+3]=We[1],Pe[be+4]=We[2],Pe[be+5]=We[3],Pe[be+6]=Ie[0],Pe[be+7]=Ie[1],Pe[be+8]=Ie[3],Pe[be+9]=Ie[1],Pe[be+10]=Ie[2],Pe[be+11]=Ie[3],Be.faceidx+=12,Be.vertices+=8}}function o(T,S,I,z,B,F,W){(!W||W==="default")&&(W="rectangle"),W==="edged"?s(T,S,I,z,B):(W==="rectangle"||W==="oval"||W==="parabola")&&t(T,S,I,z,B,F,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 I=T.x-S.x,z=T.y-S.y,B=T.z-S.z,F=I*I+z*z+B*B;if(T.atom=="CA"&&S.atom=="CA"&&F<16)return!0;if((T.atom=="P"||S.atom=="P")&&F<64)return!0}}return!1}function i(T,S,I,z,B){if(!(S==null||S.vertices==0)){B&&(S.initTypedArrays(),S.setUpNormals());var F=new w.MeshDoubleLambertMaterial;F.vertexColors=w.Coloring.FaceColors,typeof I=="number"&&I>=0&&I<1&&(F.transparent=!0,F.opacity=I),F.outline=z;var W=new w.Mesh(S,F);T.add(W)}}function n(T,S,I,z,B,F,W,U,P){var N,q,ee,ie,ne,de;if(!(!z||!B||!W)){var re=B.sub(z);re.normalize();var oe=U[P];for(q=P+1;q<U.length&&(oe=U[q],oe.atom!=W.atom);q++);if(oe=oe?new y.Vector3(oe.x,oe.y,oe.z):new y.Vector3(0,0,0),oe.sub(z),W.ss==="arrow start"){var be=oe.clone().multiplyScalar(.3).cross(B);z.add(be);var _e=oe.clone().cross(re).normalize();re.rotateAboutVector(_e,.43)}for(W.style.cartoon.ribbon?N=W.style.cartoon.thickness||m:W.style.cartoon.width?N=W.style.cartoon.width:W.ss==="c"?W.atom==="P"?N=v:N=x:W.ss==="arrow start"?(N=_,ne=!0):W.ss==="arrow end"||W.ss==="h"&&W.style.cartoon.tubes||W.ss==="tube start"?N=x:N=_,F!=null&&re.dot(F)<0&&re.negate(),re.multiplyScalar(N),q=0;q<S;q++)ee=-1+q*2/(S-1),ie=new y.Vector3(z.x+ee*re.x,z.y+ee*re.y,z.z+ee*re.z),ie.atom=W,W.ss==="s"&&(ie.smoothen=!0),T[q].push(ie);if(ne)for(re.multiplyScalar(2),q=0;q<S;q++)ee=-1+q*2/(S-1),ie=new y.Vector3(z.x+ee*re.x,z.y+ee*re.y,z.z+ee*re.z),ie.atom=W,ie.smoothen=!1,ie.skip=!0,T[q].push(ie);return de=W.style.cartoon.style||"default",T.style?T.style!=de&&(console.log("Warning: a cartoon chain's strand-style is ambiguous"),T.style="default"):T.style=de,(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 L(T,S,I,z=10){let B=z,F=z;var W,U,P,N,q,ee,ie,ne,de,re,oe,be,_e,Oe,Me,J,ve,Ce,Te=new w.Geometry(!0),We=new w.Geometry(!0),Ie=[],Fe=[],Be=1,ze=!1,Re={};for(var Pe in R.Gradient.builtinGradients)R.Gradient.builtinGradients.hasOwnProperty(Pe)&&(Re[Pe]=new R.Gradient.builtinGradients[Pe](I[1],I[0]));var je=function(De,C){return I&&C.color==="spectrum"?C.colorscheme in Re?Re[C.colorscheme].valueToHex(De.resi):Re.sinebow.valueToHex(De.resi):(0,M.getColorFromStyle)(De,C).getHex()};for(ne=0;ne<B;ne++)Fe[ne]=[];var ke=!1,H=!1,Z=[];for(ne in S){if(N=S[ne],N.elem==="C"&&N.atom==="CA"){var Y=d(P,N);Y&&N.ss==="s"?ke=!0:ke&&(P&&U&&P.style.cartoon.arrows&&U.style.cartoon.arrows&&(P.ss="arrow end",U.ss="arrow start"),ke=!1),Y&&(P.ss==="h"||P.ss=="tube start")&&P.style.cartoon.tubes?!H&&P.ss!="tube start"&&N.style.cartoon.tubes&&(N.ss="tube start",H=!0):H&&(P.ss==="tube start"?P.ss="tube end":U&&U.style.cartoon.tubes&&(U.ss="tube end"),H=!1),U=P,P=N}N&&N.atom in a&&Z.push(N)}H&&P.style.cartoon.tubes&&(P.ss="tube end",H=!1);var me=function(De){Fe[0].length>0&&o(We,Fe,Ie,F,ie,Be,Fe.style);var C=[],le=null;if(De){for(ne=0;ne<B;ne++)C[ne]=Fe[ne][Fe[ne].length-1];le=Ie[Ie.length-1]}for(Fe=[],ne=0;ne<B;ne++)Fe[ne]=[];if(Ie=[],De){for(ne=0;ne<B;ne++)Fe[ne].push(C[ne]);Ie.push(le)}i(T,We,Be,ze,!0),i(T,Te,Be,ze,!1),We=new w.Geometry(!0),Te=new w.Geometry(!0)};P=void 0;let ce=[];for(var Ae=0;Ae<Z.length;Ae++){N=Z[Ae];var we=N.resn.trim(),j=we in A;if(Be=1,W=N.style.cartoon,P&&P.style.cartoon&&(Be=P.style.cartoon.opacity),P&&P.style.cartoon&&P.style.cartoon.outline&&(ze=P.style.cartoon.outline),P&&P.style.cartoon&&(!N.style.cartoon||P.style.cartoon.opacity!=N.style.cartoon.opacity)&&me(P.chain==N.chain),P&&N&&!d(P,N)&&P.chain&&P.chain==N.chain&&!P.hetflag&&!N.hetflag&&P.reschain+1==N.reschain&&ce.push([P,N]),W.style==="trace"){if(!N.hetflag){if(N.elem==="C"&&N.atom==="CA"||j&&N.atom==="P"||N.atom==="BB"){if(ee=je(N,W),(0,M.isNumeric)(W.thickness)?ie=W.thickness:ie=m,d(P,N))if(ee==q){var se=p.CC.color(ee);E.GLDraw.drawCylinder(Te,P,N,ie,se,2,2)}else{var ge=new y.Vector3().addVectors(P,N).multiplyScalar(.5),Se=p.CC.color(q),te=p.CC.color(ee);E.GLDraw.drawCylinder(Te,P,ge,ie,Se,2,0),E.GLDraw.drawCylinder(Te,ge,N,ie,te,0,2)}if((N.clickable===!0||N.hoverable)&&N.intersectionShape!==void 0){var xe=new y.Vector3(N.x,N.y,N.z);N.intersectionShape.sphere.push(new O.Sphere(xe,ie))}P=N,q=ee}}}else{if(l(N)||j&&(N.atom==="P"||N.atom.indexOf("O5")==0)){if(Ce)if(N.ss==="tube end")Ce=!1,ve=new y.Vector3(N.x,N.y,N.z),E.GLDraw.drawCylinder(Te,J,ve,2,p.CC.color(q),1,1),N.ss="h";else if(P.chain!=N.chain||P.ss==="tube end")Ce=!1,P.ss="h",ve=new y.Vector3(P.x,P.y,P.z),E.GLDraw.drawCylinder(Te,J,ve,2,p.CC.color(q),1,1);else continue;if(P&&(!d(P,N)||P.ss==="tube start")){for(P.ss==="tube start"&&(Ce=!0,J=new y.Vector3(P.x,P.y,P.z),P.ss="h"),Me&&(be?Oe=new y.Vector3().addVectors(P,be).multiplyScalar(.5):Oe=new y.Vector3(P.x,P.y,P.z),E.GLDraw.drawCylinder(Te,Oe,Me,r,p.CC.color(Me.color),0,2),n(Fe,B,!0,be,_e,oe,P,Z,Ae),Ie.push(ee),Oe=null,Me=null),Fe[0].length>0&&o(We,Fe,Ie,F,ie,Be,Fe.style),Fe=[],ne=0;ne<B;ne++)Fe[ne]=[];Ie=[]}if(P===void 0||P.rescode!=N.rescode||P.resi!=N.resi){if(Me&&P!=null){Oe=new y.Vector3().addVectors(P,N).multiplyScalar(.5);var V=Oe.clone().sub(Me).multiplyScalar(.02);Oe.add(V),E.GLDraw.drawCylinder(Te,Oe,Me,r,p.CC.color(Me.color),0,2),Oe=null,Me=null}ee=je(N,W),Ie.push(ee),(0,M.isNumeric)(W.thickness)?ie=W.thickness:ie=m,P=N,de=new y.Vector3(P.x,P.y,P.z),de.resi=P.resi,q=ee}(N.clickable===!0||N.hoverable===!0)&&(N.intersectionShape===void 0||N.intersectionShape.triangle===void 0)&&(N.intersectionShape={sphere:null,cylinder:[],line:[],triangle:[]})}else P!=null&&(l(P)&&N.atom==="O"||j&&P.atom==="P"&&(N.atom==="OP2"||N.atom==="O2P")||j&&P.atom.indexOf("O5")==0&&N.atom.indexOf("C5")==0)?(re=new y.Vector3(N.x,N.y,N.z),re.resi=N.resi,(N.atom==="OP2"||N.atom==="O2P")&&(_e=new y.Vector3(N.x,N.y,N.z))):j&&N.atom.indexOf("O3")==0?be=new y.Vector3(N.x,N.y,N.z):(N.atom==="N1"&&we in h||N.atom==="N3"&&we in u)&&(Me=new y.Vector3(N.x,N.y,N.z),Me.color=(0,M.getColorFromStyle)(N,W).getHex());re&&de&&re.resi===de.resi&&(n(Fe,B,!0,de,re,oe,P,Z,Ae),oe=re,de=null,re=null,Ie.push(ee))}}Me&&(be?Oe=new y.Vector3().addVectors(P,be).multiplyScalar(.5):Oe=new y.Vector3(P.x,P.y,P.z),E.GLDraw.drawCylinder(Te,Oe,Me,r,p.CC.color(Me.color),0,2),n(Fe,B,!0,be,_e,oe,P,Z,Ae),Ie.push(ee)),me(!1);var Le=function(De,C){if(De.style.cartoon.gapcutoff&&De.style.cartoon.gapcutoff==C.style.cartoon.gapcutoff){let he=De.style.cartoon.gapcutoff,k=C.resi-De.resi;if(k>0&&k<he){let ae=.25,pe=C.x-De.x,Ve=C.y-De.y,Ne=C.z-De.z,Ge=Math.sqrt(pe*pe+Ve*Ve+Ne*Ne),qe=Ge/(2*k),_t=new y.Vector3(De.x,De.y,De.z),Ye=Ge/qe,He=new y.Vector3((C.x-De.x)/Ye,(C.y-De.y)/Ye,(C.z-De.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)({},De);for(var le=0;le<k;le++){tt.resi+=1;let et=je(tt,tt.style.cartoon);E.GLDraw.drawCylinder(Te,_t,$e,ae,p.CC.color(et),E.CAP.FLAT,E.CAP.FLAT),_t.add(He),$e.add(He)}me(!1)}}};for(let De of ce)Le(De[0],De[1])}},"./src/index.ts"(K,D,c){c.r(D),c.d(D,{CAP:()=>y.CAP,CC:()=>y.CC,CONTEXTS_PER_VIEWPORT:()=>y.CONTEXTS_PER_VIEWPORT,Color:()=>y.Color,CustomLinear:()=>y.CustomLinear,Cylinder:()=>y.Cylinder,GLDraw:()=>y.GLDraw,GLModel:()=>y.GLModel,GLShape:()=>y.GLShape,GLViewer:()=>y.GLViewer,GLVolumetricRender:()=>y.GLVolumetricRender,Gradient:()=>y.Gradient,GradientType:()=>y.GradientType,Label:()=>y.Label,LabelCount:()=>y.LabelCount,MarchingCube:()=>y.MarchingCube,MarchingCubeInitializer:()=>y.MarchingCubeInitializer,Matrix3:()=>y.Matrix3,Matrix4:()=>y.Matrix4,Parsers:()=>y.Parsers,PausableTimer:()=>y.PausableTimer,PointGrid:()=>y.PointGrid,ProteinSurface:()=>y.ProteinSurface,Quaternion:()=>y.Quaternion,ROYGB:()=>y.ROYGB,RWB:()=>y.RWB,Ray:()=>y.Ray,Sinebow:()=>y.Sinebow,Sphere:()=>y.Sphere,SurfaceType:()=>y.SurfaceType,Triangle:()=>y.Triangle,Vector2:()=>y.Vector2,Vector3:()=>y.Vector3,VolumeData:()=>y.VolumeData,adjustVolumeStyle:()=>y.adjustVolumeStyle,applyPartialCharges:()=>y.applyPartialCharges,autoinit:()=>y.autoinit,autoload:()=>y.autoload,base64ToArray:()=>y.base64ToArray,bondLength:()=>y.bondLength,builtinColorSchemes:()=>y.builtinColorSchemes,builtinGradients:()=>y.builtinGradients,chains:()=>y.chains,clamp:()=>y.clamp,conversionMatrix3:()=>y.conversionMatrix3,createStereoViewer:()=>y.createStereoViewer,createViewer:()=>y.createViewer,createViewerGrid:()=>y.createViewerGrid,deepCopy:()=>y.deepCopy,degToRad:()=>y.degToRad,download:()=>y.download,drawCartoon:()=>y.drawCartoon,elementColors:()=>y.elementColors,extend:()=>y.extend,get:()=>y.get,getAtomProperty:()=>y.getAtomProperty,getColorFromStyle:()=>y.getColorFromStyle,getElement:()=>y.getElement,getExtent:()=>y.getExtent,getGradient:()=>y.getGradient,getPropertyRange:()=>y.getPropertyRange,getbin:()=>y.getbin,htmlColors:()=>y.htmlColors,inflateString:()=>y.inflateString,isEmptyObject:()=>y.isEmptyObject,isNumeric:()=>y.isNumeric,makeFunction:()=>y.makeFunction,mergeGeos:()=>y.mergeGeos,normalizeValue:()=>y.normalizeValue,partialCharges:()=>y.partialCharges,processing_autoinit:()=>y.processing_autoinit,residues:()=>y.residues,setBondLength:()=>y.setBondLength,setSyncSurface:()=>y.setSyncSurface,specStringToObject:()=>y.specStringToObject,splitMesh:()=>y.splitMesh,ssColors:()=>y.ssColors,subdivide_spline:()=>y.subdivide_spline,syncSurface:()=>y.syncSurface,viewers:()=>y.viewers});var y=c("./src/3Dmol.ts");window&&(window.$3Dmol=D)},"./src/parsers/BCIF.ts"(K,D,c){c.r(D),c.d(D,{BCIF:()=>m});var y=c("./src/utilities.ts"),O=c("./src/parsers/utils/computeSecondaryStructure.ts"),w=c("./src/parsers/utils/processSymmetries.ts"),R=c("./src/parsers/cifutils/category.ts"),p=c("./src/parsers/utils/assignPDBBonds.ts"),E=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 L=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]],L])}}}}class v{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,y.base64ToArray)(r)}catch{r=new TextEncoder().encode(r)}else r=new Uint8Array(r);var i=g.decodeMsgpack(r);i==31&&(r=(0,y.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 L=[];a.push({symmetries:[]}),n.push([]);const T=i.dataBlocks[u],S=Object.create(null);for(const Re of T.categories)S[Re.name.substr(1)]=(0,R.Category)(Re);let I={},z=S.struct_conf;if(z){let Re=z.getField("conf_type_id"),Pe=z.getField("beg_label_asym_id"),je=z.getField("beg_label_seq_id"),ke=z.getField("end_label_seq_id");for(let H=0;H<Re.length;H++)if(Re[H].startsWith("H")){let Z=Pe[H],Y=je[H],me=ke[H];Z in I||(I[Z]={}),I[Z][Y]="h1";for(let ce=Y+1;ce<me;ce++)I[Z][ce]="h";I[Z][me]="h2"}}let B=S.struct_sheet_range;if(B){let Re=B.getField("id"),Pe=B.getField("beg_label_asym_id"),je=B.getField("beg_label_seq_id"),ke=B.getField("end_label_seq_id");for(let H=0;H<Re.length;H++){let Z=Pe[H],Y=je[H],me=ke[H];Z in I||(I[Z]={}),I[Z][Y]="s1";for(let ce=Y+1;ce<me;ce++)I[Z][ce]="s";I[Z][me]="s2"}}let F=S.pdbx_struct_oper_list,W=F.getField("id");if(W&&!l){let Re=F.getField("matrix[1][1]"),Pe=F.getField("matrix[1][2]"),je=F.getField("matrix[1][3]"),ke=F.getField("matrix[2][1]"),H=F.getField("matrix[2][2]"),Z=F.getField("matrix[2][3]"),Y=F.getField("matrix[3][1]"),me=F.getField("matrix[3][2]"),ce=F.getField("matrix[3][3]"),Ae=F.getField("vector[1]"),we=F.getField("vector[2]"),j=F.getField("vector[3]");for(let se=0;se<W.length;se++){const ge=new E.Matrix4(Re[se],Pe[se],je[se],Ae[se],ke[se],H[se],Z[se],we[se],Y[se],me[se],ce[se],j[se]);a[a.length-1].symmetries.push(ge)}}let U=new x(S.chem_comp_bond),P=new v,N=new _(S.struct_conn),q=S.atom_site,ee=q.rowCount,ie=q.getField("group_PDB"),ne=q.getField("Cartn_x"),de=q.getField("Cartn_y"),re=q.getField("Cartn_z"),oe=q.getField("auth_asym_id"),be=q.getField("label_asym_id"),_e=q.getField("auth_seq_id"),Oe=q.getField("label_seq_id"),Me=q.getField("auth_comp_id"),J=q.getField("label_comp_id"),ve=q.getField("auth_atom_id"),Ce=q.getField("label_atom_id"),Te=q.getField("type_symbol"),We=q.getField("B_iso_or_equiv"),Ie=q.getField("id"),Fe=q.getField("label_alt_id"),Be=q.getField("pdbx_PDB_model_num"),ze=Be?Be[0]:0;for(let Re=0;Re<ee;Re++){if(ie!==void 0&&ie[Re]==="TER")continue;if(Be&&Be[Re]!=ze)if(ze=Be[Re],e.multimodel)e.onemol||(n.push([]),a.push(a[a.length-1]),ze=Be[Re],P.setBonds(U,N),P=new v);else break;const Pe={};Pe.x=ne[Re],Pe.y=de[Re],Pe.z=re[Re],Pe.chain=oe?oe[Re]:be?be[Re]:void 0,Pe.lchain=be?be[Re]:void 0,Pe.resi=_e?_e[Re]:Oe?Oe[Re]:void 0,Pe.lresi=Oe?Oe[Re]:void 0,Pe.resn=Me?Me[Re].trim():J?J[Re].trim():void 0,Pe.lresn=J?J[Re].trim():void 0,Pe.atom=ve?ve[Re].replace(/"/gm,""):Ce?Ce[Re].replace(/"/gm,""):void 0,Pe.icode=Fe?Fe[Re]:void 0,Pe.altLoc=Pe.icode,Pe.hetflag=!ie||ie[Re]==="HETA"||ie[Re]==="HETATM";let je="X";Te&&(je=Te[Re].replace(/\(?\+?\d+.*/,"")),Pe.elem=je[0].toUpperCase()+je.substring(1,2).toLowerCase(),We&&(Pe.b=We[Re]),!(t&&Pe.elem=="H")&&(Pe.altLoc!=""&&Pe.altLoc!=s&&s!="*"||(Pe.bonds=[],Pe.ss="c",Pe.serial=Ie[Re],Pe.model=ze,Pe.bondOrder=[],Pe.properties={},Pe.index=n[n.length-1].length,L[Pe.serial]=[n.length,Pe.index],n[n.length-1].push(Pe),P.add(Pe)))}if(P.setBonds(U,N),!(0,M.isEmpty)(I))for(let Re=A;Re<n.length;Re++){let Pe=n[Re];for(let je=0;je<Pe.length;je++){const ke=Pe[je];if(ke!==void 0&&ke.lchain in I&&ke.lresi in I[ke.lchain]){const H=I[ke.lchain][ke.lresi];ke.ss=H[0],H.length>1&&(H[1]=="1"?ke.ssbegin=!0:H[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,p.assignPDBBonds)(n[u],e),o&&(0,O.computeSecondaryStructure)(n[u],e.hbondCutoff),(0,w.processSymmetries)(a[u].symmetries,n[u],e,a[u].cryst),e.duplicateAssemblyAtoms&&!e.dontConnectDuplicatedAtoms&&d&&(0,p.assignPDBBonds)(n[u],e);return n}},"./src/parsers/CDJSON.ts"(K,D,c){c.r(D),c.d(D,{CDJSON:()=>y});function y(O,w){var R=[[]];typeof O=="string"&&(O=JSON.parse(O));for(var p=O.m,E=p[0].a,M=p[0].b,g=p[0].s,x=w!==void 0&&w.parseStyle!==void 0?w.parseStyle:g!==void 0,_=R[R.length-1].length,v=0;v<E.length;v++){var m=E[v],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,D,c){c.r(D),c.d(D,{CIF:()=>E});var y=c("./src/parsers/utils/computeSecondaryStructure.ts"),O=c("./src/parsers/utils/processSymmetries.ts"),w=c("./src/WebGL/index.ts"),R=c("./src/parsers/utils/assignPDBBonds.ts");const p=function(M,g,x,_){return new w.Vector3(g,x,_).applyMatrix3(M)};function E(M,g={}){const x=[],_=!g.doAssembly,v=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 L=t[l].substring(1);for(l++;t[l]!==";";)L=L+`
|
|
1696
|
+
`+t[l],l++;u.push(L)}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(),L=d[A]=d[A]||[];h.push(L)}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 L=0;L<A.length;L++)A[L]!==""&&(h[u].push(A[L]),u=(u+1)%h.length);l++}}else l++;v.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),L=parseFloat(d._cell_angle_alpha)||90,T=parseFloat(d._cell_angle_beta)||90,S=parseFloat(d._cell_angle_gamma)||90;n=(0,w.conversionMatrix3)(h,u,A,L,T,S),v[v.length-1].cryst={a:h,b:u,c:A,alpha:L,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 L=p(n,parseFloat(d._atom_site_fract_x[h]),parseFloat(d._atom_site_fract_y[h]),parseFloat(d._atom_site_fract_z[h]));u.x=L.x,u.y=L.y,u.z=L.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]),L=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]),I=parseFloat(d["_pdbx_struct_oper_list_matrix[2][2]"][h]),z=parseFloat(d["_pdbx_struct_oper_list_matrix[2][3]"][h]),B=parseFloat(d["_pdbx_struct_oper_list_vector[2]"][h]),F=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]),P=parseFloat(d["_pdbx_struct_oper_list_vector[3]"][h]),N=new w.Matrix4(u,A,L,T,S,I,z,B,F,W,U,P);v[v.length-1].symmetries.push(N)}const a=function(h){const u=h.match("-");h=h.replace(/[-xyz]/g,"");const A=h.split("/");let L,T;return A[1]===void 0?T=1:T=parseInt(A[1]),A[0]===""?L=1:L=parseInt(A[0]),L/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(I){return I.replace(/-/g,"+-")});let L=new w.Matrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);for(let I=0;I<3;I++){const z=A[I].split("+");for(let B=0;B<z.length;B++){const F=z[B];if(F==="")continue;const W=a(F);F.match("x")?L.elements[I+0]=W:F.match("y")?L.elements[I+4]=W:F.match("z")?L.elements[I+8]=W:L.elements[I+12]=W}}const T=n.getMatrix4(),S=new w.Matrix4().getInverse(T,!0);L=new w.Matrix4().multiplyMatrices(L,S),L=new w.Matrix4().multiplyMatrices(T,L),v[v.length-1].symmetries.push(L)}}for(let d=0;d<x.length;d++)m&&!(g.duplicateAssemblyAtoms&&!g.dontConnectDuplicatedAtoms)&&(0,R.assignPDBBonds)(x[d],g),(0,y.computeSecondaryStructure)(x[d],g.hbondCutoff),(0,O.processSymmetries)(v[d].symmetries,x[d],g,v[d].cryst),g.duplicateAssemblyAtoms&&!g.dontConnectDuplicatedAtoms&&m&&(0,R.assignPDBBonds)(x[d],g);return x}},"./src/parsers/CUBE.ts"(K,D,c){c.r(D),c.d(D,{CUBE:()=>R});var y=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts"),w=c("./src/parsers/utils/anumToSymbol.ts");function R(p,E){E=E||{};const M=[[]];let g=p.split(/\r?\n/);const x=E.assignBonds===void 0?!0:E.assignBonds;if(g.length<6)return M;let _=g[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const v=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 y.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 y.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);_=g[4].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const o=Math.abs(_[0]),l=new y.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);_=g[5].replace(/^\s+/,"").replace(/\s+/g," ").split(" ");const d=Math.abs(_[0]),i=new y.Vector3(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])).multiplyScalar(e);if(m.size={x:t,y:o,z:d},m.unit=new y.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 y.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 y.Matrix4().makeTranslation(r.x,r.y,r.z);m.matrix4=m.matrix4.multiplyMatrices(T,m.matrix4),m.matrix=m.matrix4.matrix3FromTopLeft(),m.origin=new y.Vector3(0,0,0),m.unit=new y.Vector3(1,1,1)}M.modelData=[{cryst:m}],g=g.splice(6,v);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],L=A.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");u.elem=w.anumToSymbol[L[0]],u.x=parseFloat(L[2])*e,u.y=parseFloat(L[3])*e,u.z=parseFloat(L[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],E);return M}},"./src/parsers/GRO.ts"(K,D,c){c.r(D),c.d(D,{GRO:()=>w});var y=c("./src/parsers/utils/assignPDBBonds.ts"),O=c("./src/parsers/utils/atomNameToElem.ts");function w(R,p){const E=[],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 _=[];E.push(_);let v=2;const m=_.length,r=m+g;for(let e=m;e<r;e++){const t=M[v++],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<=v+3){const t=M[v++].trim().split(/\s+/);if(t.length===3){for(let s=0;s<3;s++)t[s]=(parseFloat(t[s])*10).toString();E.box=t}}M.splice(0,++v)}for(let g=0;g<E.length;g++)(0,y.assignPDBBonds)(E[g],p);return E}},"./src/parsers/LAMMPSTRJ.ts"(K,D,c){c.r(D),c.d(D,{LAMMPSTRJ:()=>w});var y=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 w(R,p){const E=[],M=R.split(/\r?\n|\r/);let g=0,x=0,_=0;for(;_<M.length-9;){for(var v=_;v<M.length;v++)if(M[v].match(/ITEM: NUMBER OF ATOMS/)&&(x=parseInt(M[v+1])),M[v].match(/ITEM: ATOMS/)){g=v+1;break}const m=M[g-1].replace("ITEM: ATOMS ","").split(" ");E.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=[]}E[E.length-1][r-g]=e}_=g+x-1}if(p.assignBonds)for(let m=0;m<E.length;m++)(0,y.assignBonds)(E[m],p);return E}},"./src/parsers/MMTF.ts"(K,D,c){c.r(D),c.d(D,{MMTFparser:()=>x});var y=c("./src/utilities.ts"),O=c("./src/WebGL/index.ts"),w=c("./src/parsers/utils/computeSecondaryStructure.ts"),R=c("./src/parsers/utils/processSymmetries.ts"),p=c("./src/vendor/mmtf.js"),E=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(_,v){var m=!v.keepH,r=v.altLoc?v.altLoc:"A",e=!!v.noSecondaryStructure,t=!v.noComputeSecondaryStructure,s=!v.doAssembly,o=v.assemblyIndex?v.assemblyIndex:0;typeof _=="string"?_=(0,y.base64ToArray)(_):_=new Uint8Array(_);var l=p.decode(_),d=[[]],i=d.modelData=[],n=0,a=0,h=0,u=l.secStructList,A=l.bFactorList,L=l.altLocList,T=l.occupancyList,S=l.bondAtomList,I=l.bondOrderList,z=l.numModels;if(z==0)return d;v.multimodel||(z=1);var B,F,W,U,P,N,q=[];if(!s&&l.bioAssemblyList&&l.bioAssemblyList.length>0){var ee=l.bioAssemblyList[o].transformList;for(B=0,N=ee.length;B<N;B++){var ie=new O.Matrix4(ee[B].matrix);ie.transpose(),q.push(ie)}}var ne=null;if(l.unitCell){var de=l.unitCell;ne={a:de[0],b:de[1],c:de[2],alpha:de[3],beta:de[4],gamma:de[5]}}let re=[];l.entityList.forEach(he=>{he.chainIndexList.forEach(k=>{re[k]=he.type=="polymer"})});var oe=0;for(P=0;P<z;P++){var be=l.chainsPerModel[P],_e=d[d.length-1],Oe=[];for(i.push({symmetries:q,cryst:ne}),B=0;B<be;++B){var Me=l.groupsPerChain[n],J=E(l.chainIdList.subarray(n*4,n*4+4));l.chainNameList&&(J=E(l.chainNameList.subarray(n*4,n*4+4)));var ve=a,Ce="";for(F=0;F<Me;++F){var Te=l.groupList[l.groupTypeList[a]],We=Te.atomNameList.length,Ie=0,Fe=!1,Be=!1;if(u){Ie=u[a];var ze=M(Ie);(a==0||ze!=Ce)&&(Fe=!0),Ce=ze;var Re=a+1;(Re>=u.length||M(u[Re]!=ze))&&(Be=!0)}var Pe=l.groupIdList[a],je=Te.groupName;let he=Te.chemCompType;var ke=h;let k=g.has(he)||!re[n];for(W=0;W<We;++W){var H=Te.elementList[W];if(m&&H=="H"){h+=1;continue}var Z="";A&&(Z=A[h]);var Y="";L&&L[h]&&(Y=String.fromCharCode(L[h]));var me="";if(T&&(me=T[h]),Y!=""&&Y!=r&&r!="*"){h+=1;continue}var ce=l.atomIdList[h],Ae=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:H,hetflag:k,chain:J,resi:Pe,icode:Y,rescode:Pe+(Y!=" "?"^"+Y:""),serial:ce,altLoc:Y,index:h,atom:Ae,bonds:[],ss:M(Ie),ssbegin:Fe,ssend:Be,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 te=ke+Se[W*2],xe=ke+Se[W*2+1],V=Te.bondOrderList[W],Le=Oe[te],De=Oe[xe],C=_e[Le],le=_e[De];C&&le&&(C.bonds.push(De),C.bondOrder.push(V),le.bonds.push(Le),le.bondOrder.push(V))}a+=1}for(a=ve,F=0;F<Me;++F)a+=1;n+=1}if(S)for(let he=oe,k=S.length;he<k;he+=2){let ae=S[he],pe=S[he+1],Ve=I?I[he/2]:1;if(ae>=h){oe=he;break}let Ne=Oe[ae],Ge=Oe[pe],qe=_e[Ne],_t=_e[Ge];qe&&_t&&(qe.bonds.push(Ge),qe.bondOrder.push(Ve),_t.bonds.push(Ne),_t.bondOrder.push(Ve))}v.multimodel&&(v.onemol||d.push([]))}if(!s)for(let he=0;he<d.length;he++)(0,R.processSymmetries)(i[he].symmetries,d[he],v,i[he].cryst);return t&&!e&&(0,w.computeSecondaryStructure)(d,v.hbondCutoff),d}},"./src/parsers/MOL2.ts"(K,D,c){c.r(D),c.d(D,{MOL2:()=>O});let y={"C.1":"C",C1:"C","C.2":"C",C2:"C","C.3":"C",C3:"C","C.ar":"C",Car:"C","C.cat":"C",Ccat:"C","H.spc":"H",Hspc:"H","H.t3p":"H",Ht3p:"H","N.1":"N",N1:"N","N.2":"N",N2:"N","N.3":"N",N3:"N","N.4":"N",N4:"N","N.am":"N",Nam:"N","N.ar":"N",Nar:"N","N.p13":"N",Np13:"N","O.2":"O",O2:"O","O.3":"O",O3:"O","O.co2":"O",Oco2:"O","O.spc":"O",Ospc:"O","O.t3p":"O",Ot3p:"O","P.3":"P",P3:"P","S.2":"S",S2:"S","S.3":"S",S3:"S","S.o":"S",So:"S","S.o2":"S",So2:"S"};function O(w,R){var p=[[]],E=!1;typeof R.keepH<"u"&&(E=!R.keepH);var M=w.search(/@<TRIPOS>MOLECULE/),g=w.search(/@<TRIPOS>ATOM/);if(M==-1||g==-1)return p;for(var x=w.substring(M).split(/\r?\n|\r/);x.length>0;){var _=[],v=x[2].replace(/^\s+/,"").replace(/\s+/g," ").split(" "),m=parseInt(v[0]),r=0;v.length>1&&(r=parseInt(v[1]));var e=4,t;for(t=3;t<x.length;t++)if(x[t]=="@<TRIPOS>ATOM"){e=t+1;break}var s=p[p.length-1].length,o=s+m,l;for(t=s;t<o;t++){l=x[e++],v=l.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var d={},i=v[5];if(y[i]!==void 0?i=y[i]:(i=i.split(".")[0],i=i[0].toUpperCase()+i.substring(1).toLowerCase()),d.atom=v[1],d.elem=i,!(d.elem=="H"&&E)){var n=p[p.length-1].length,a=parseInt(v[0]);d.serial=a,d.x=parseFloat(v[2]),d.y=parseFloat(v[3]),d.z=parseFloat(v[4]),d.atom=v[5];var h=parseFloat(v[8]);d.index=n,d.bonds=[],d.bondOrder=[],d.properties={charge:h,partialCharge:h},_[a]=n,p[p.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++],v=l.replace(/^\s+/,"").replace(/\s+/g," ").split(" ");var A=parseInt(v[1]),L=p[p.length-1][_[A]],T=parseInt(v[2]),S=p[p.length-1][_[T]],I=parseInt(v[3]);isNaN(I)&&(I=1),L!==void 0&&S!==void 0&&(L.bonds.push(_[T]),L.bondOrder.push(I),S.bonds.push(_[A]),S.bondOrder.push(I))}if(R.multimodel){R.onemol||p.push([]),x.splice(0,e),w=x.join(`
|
|
1697
|
+
`);continue}else break}return p}},"./src/parsers/PDB.ts"(K,D,c){c.r(D),c.d(D,{PDB:()=>O});var y=c("./src/parsers/utils/getSinglePDB.ts");function O(w,R){R=R||{};var p=[],E={};p.modelData=[];for(var M=w.split(/\r?\n|\r/);M.length>0;){var g=(0,y.getSinglePDB)(M,R,E),x=g[0],_=g[1];if(M=g[2],x.length!=0){if(R.multimodel&&R.onemol&&p.length>0)for(var v=p[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]+=v;p[0].push(r)}else p.modelData.push(_),p.push(x);if(!R.multimodel)break}}return p}},"./src/parsers/PQR.ts"(K,D,c){c.r(D),c.d(D,{PQR:()=>w});var y=c("./src/parsers/utils/assignPDBBonds.ts"),O=c("./src/parsers/utils/computeSecondaryStructure.ts");function w(R,p){var E=[[]],M=!p.noSecondaryStructure;E.modelData=[{symmetries:[]}];var g=[],x=R.split(/\r?\n|\r/),_;for(let u=0;u<x.length;u++){_=x[u].replace(/^\s*/,"");var v=_.substring(0,6);if(v.indexOf("END")==0)if(p.multimodel){p.onemol||E.push([]);continue}else break;else if(v=="ATOM "||v=="HETATM"){var m;let A=parseInt(_.substring(6,11)),L=_.substring(12,16).replace(/ /g,""),T=_.substring(17,20).trim(),S=_.substring(21,22),I=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=L[0];L.length>1&&L[1].toUpperCase()!=L[1]&&(d=L.substring(0,2)),_[0]=="H"?m=!0:m=!1,g[A]=E[E.length-1].length,E[E.length-1].push({resn:T,x:e,y:t,z:s,elem:d,hetflag:m,chain:S,resi:I,serial:A,atom:L,bonds:[],ss:"c",bondOrder:[],properties:{charge:o,partialCharge:o,radius:l},pdbline:_})}else if(v=="CONECT"){var i=parseInt(_.substring(6,11)),n=E[E.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=E[E.length-1][g[a]];n!==void 0&&h!==void 0&&(n.bonds.push(g[a]),n.bondOrder.push(1))}}}for(let u=0;u<E.length;u++)(0,y.assignPDBBonds)(E[u],p),M&&(0,O.computeSecondaryStructure)(E[u],p.hbondCutoff);return E}},"./src/parsers/PRMTOP.ts"(K,D,c){c.r(D),c.d(D,{PRMTOP:()=>y});function y(O){var w=[],R,p=0,E=O.split(/\r?\n|\r/);if(E.length>0&&E[0].includes("VERSION")){var M=E.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(E[g+1].slice(0,x[1]));let t=parseInt(E[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 v=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(v=_%x[0]);for(let o=0;o<v;o++){let l={},d={charge:"",radii:""};l.serial=p,l.x=0,l.y=0,l.z=0,l.atom=E[g+1].slice(x[1]*o,x[1]*(o+1)).trim(),l.elem=E[g+1].slice(x[1]*o,x[1]*o+1).trim(),l.properties=d,l.bonds=[],l.bondOrder=[],l.index=w.length,w.push(l),p++}g++}if(g=r("CHARGE"),g!=-1){x=e(g),p=0,v=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(v=_%x[0]);for(let o=0;o<v;o++)w[p].properties.charge=parseFloat(E[g+1].slice(x[1]*o,x[1]*(o+1))),p++;g++}}g=r("RESIDUE_POINTER");var m=[];if(g!=-1){x=e(g),v=x[0],g+=1;for(let s=0;s<t/x[0];s++){s==parseInt(t/x[0])&&(v=t%x[0]);for(let o=0;o<v;o++)m.push(parseInt(E[g].slice(x[1]*o,x[1]*(o+1))));g++}if(g=r("RESIDUE_LABEL"),g!=-1){let s=[];x=e(g),v=x[0],g+=1;for(let i=0;i<t/x[0];i++){i==parseInt(t/x[0])&&(v=t%x[0]);for(let n=0;n<v;n++)s.push(E[g].slice(x[1]*n,x[1]*(n+1)).trim());g++}let o=0,l=0,d="";m.push(w.length+1);for(let i=0;i<w.length;i++)i+1>=m[o]&&(d=s[o],o+=1,l+=1),w[i].resi=l,w[i].resn=d}}if(g=r("RADII"),g!=-1){x=e(g),p=0,v=x[0];for(let s=0;s<_/x[0];s++){s==parseInt(_/x[0])&&(v=_%x[0]);for(let o=0;o<v;o++)w[p].properties.radii=parseFloat(E[g+1].slice(x[1]*o,x[1]*(o+1))),p++;g++}}if(g=r("BONDS_WITHOUT_HYDROGEN"),g!=-1)for(x=e(g),p=0,v=x[0],g=g+1;!E[g].match(/^%FLAG/);){E[g+1].match(/^%FLAG/)&&(v=_%x[0]);for(let s=0;s<v;s++)p%3==0?R=parseInt(E[g].slice(x[1]*s,x[1]*(s+1))/3):p%3==1&&(w[R].bonds.push(parseInt(E[g].slice(x[1]*s,x[1]*(s+1))/3)),w[R].bondOrder.push(1)),p++;g++}if(g=r("BONDS_INC_HYDROGEN"),g!=-1)for(x=e(g),p=0,v=x[0],g=g+1;!E[g].match(/^%FLAG/);){E[g+1].match(/^%FLAG/)&&(v=_%x[0]);for(let s=0;s<v;s++)p%3==0?R=parseInt(E[g].slice(x[1]*s,x[1]*(s+1))/3):p%3==1&&(w[R].bonds.push(parseInt(E[g].slice(x[1]*s,x[1]*(s+1))/3)),w[R].bonds.push(1)),p++;g++}}else return[];function r(t){var s=E.indexOf(M.filter(function(o){return o.includes(t)})[0]);if(Number.isInteger(s)&&s>0){for(;!E[s].includes("FORMAT");)s++;return s}else return-1}function e(t){var s=E[t].match(/\((\d*)\S*/),o=E[t].match(/[a-zA-Z](\d*)\)\s*/);return o==null&&(o=E[t].match(/[a-zA-Z](\d*)\.\d*\)\s*/)),[parseInt(s[1]),parseInt(o[1])]}return[w]}},"./src/parsers/SDF.ts"(K,D,c){c.r(D),c.d(D,{SDF:()=>E});const y=function(M,g,x,_){let v;try{v=JSON.parse(M)}catch{console.warn("3DMOL_STYLE: invalid JSON: "+M);return}const m=g.length-1,r=g[m];if(v.bonds&&typeof v.bonds=="object"){const e=v.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 v.bonds}Object.keys(v).length>0&&(g.modelData[m].style=v)},O=function(M,g,x,_,v){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&&y(s.join(" ").trim(),x,_,v)}return g},w=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 v=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"||!v)&&(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"&&w(o,a,h,u)}if(m=O(M,m+t,x,s,l),!g.multimodel)break;g.onemol||(x.push([]),_.push({}))}return x},p=function(M,g){const x=[[]],_=x.modelData=[];_.push({});const v=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"||!v)&&(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],L=parseFloat(h[1]);typeof u<"u"&&typeof A<"u"&&w(l,u,A,L)}}if(m=O(M,m+s,x,o,d),!g.multimodel)break;g.onemol||(x.push([]),_.push({}))}return x};function E(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"?p(_,g):[[""]]}},"./src/parsers/VASP.ts"(K,D,c){c.r(D),c.d(D,{VASP:()=>w});var y=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts");function w(R,p={}){var E=[[]],M={};const g=p.assignBonds===void 0?!0:p.assignBonds;var x=R.replace(/^\s+/,"").split(/\r?\n/);if(x.length<3)return E;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"),E;if(M.length<0)return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"),E;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 y.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),E.modelData=[{symmetries:[],cryst:{matrix:_}}];var v=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)"),E;if(v.length!=m.length)return console.log("Warning: declaration of atomary species wrong:"),console.log(v),console.log(m),E;e?x.splice(0,9):x.splice(0,8);for(var t=0,s=0,o=v.length;s<o;s++){for(var l=v[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=[],E[0].push(a)}t+=m[s]}if(g)for(let h=0;h<E.length;h++)(0,O.assignBonds)(E[h],p);return E}},"./src/parsers/XYZ.ts"(K,D,c){c.r(D),c.d(D,{XYZ:()=>w});var y=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/assignBonds.ts");function w(R,p){p=p||{};for(var E=[[]],M=p.assignBonds===void 0?!0:p.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,v=_.exec(g[1]);if(v!=null&&v.length>1){var m=new Float32Array(v[1].split(/\s+/)),r=new y.Matrix3(m[0],m[3],m[6],m[1],m[4],m[7],m[2],m[5],m[8]);E.modelData=[{cryst:{matrix:r}}]}for(var e=2,t=E[E.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={},E[E.length-1][o]=i,d.length>=7&&(i.dx=parseFloat(d[4]),i.dy=parseFloat(d[5]),i.dz=parseFloat(d[6]))}if(p.multimodel)E.push([]),g.splice(0,e);else break}if(M)for(let h=0;h<E.length;h++)(0,O.assignBonds)(E[h],p);if(p.onemol){var a=E;E=[],E.push(a[0]);for(let h=1;h<a.length;h++){let u=E[0].length;for(let A=0;A<a[h].length;A++){let L=a[h][A];for(let T=0;T<L.bonds.length;T++)L.bonds[T]=L.bonds[T]+u;L.index=E[0].length,L.serial=E[0].length,E[0].push(L)}}}return E}},"./src/parsers/cifutils/category.ts"(K,D,c){c.r(D),c.d(D,{Category:()=>O});var y=c("./src/parsers/cifutils/decoder.ts");function O(w){const R=Object.create(null),p=Object.create(null);for(const E of w.columns)R[E.name]=E;return{rowCount:w.rowCount,name:w.name.substring(1),fieldNames:w.columns.map(E=>E.name),getField(E){const M=R[E];if(M)return p[E]||(p[E]=(0,y.decode)(M.data)),p[E]}}}},"./src/parsers/cifutils/decoder.ts"(K,D,c){c.r(D),c.d(D,{decode:()=>R});var y=c("./src/parsers/cifutils/encoding.ts");const O=new Uint16Array(new Uint8Array([18,52]).buffer)[0]===13330;function w(u,A){const L=new ArrayBuffer(u.length),T=new Uint8Array(L);for(let S=0,I=u.length;S<I;S+=A)for(let z=0;z<A;z++)T[S+A-z-1]=u[S+z];return L}function R(u){let A=u.data;for(let L=u.encoding.length-1;L>=0;L--)A=p(A,u.encoding[L]);return A}function p(u,A){switch(A.kind){case"ByteArray":switch(A.type){case y.Encoding.IntDataType.Uint8:return u;case y.Encoding.IntDataType.Int8:return g(u);case y.Encoding.IntDataType.Int16:return _(u);case y.Encoding.IntDataType.Uint16:return v(u);case y.Encoding.IntDataType.Int32:return m(u);case y.Encoding.IntDataType.Uint32:return r(u);case y.Encoding.FloatDataType.Float32:return e(u);case y.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 E(u,A){switch(u){case y.Encoding.IntDataType.Int8:return new Int8Array(A);case y.Encoding.IntDataType.Int16:return new Int16Array(A);case y.Encoding.IntDataType.Int32:return new Int32Array(A);case y.Encoding.IntDataType.Uint8:return new Uint8Array(A);case y.Encoding.IntDataType.Uint16:return new Uint16Array(A);case y.Encoding.IntDataType.Uint32:return new Uint32Array(A);default:return new Int32Array(A)}}function M(u,A){switch(u){case y.Encoding.FloatDataType.Float32:return new Float32Array(A);case y.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,L){return(u.byteOffset!=0||u.byteLength!=u.buffer.byteLength)&&(u=new Uint8Array(u)),O?new L(u.buffer):new L(w(u,A))}function _(u){return x(u,2,Int16Array)}function v(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 L=u.length,T=M(A.srcType,L),S=1/A.factor;for(let I=0;I<L;I++)T[I]=S*u[I];return T}function o(u,A){const L=u.length,T=M(A.srcType,L),S=(A.max-A.min)/(A.numSteps-1),I=A.min;for(let z=0;z<L;z++)T[z]=I+S*u[z];return T}function l(u,A){const L=E(A.srcType,A.srcSize);let T=0;for(let S=0,I=u.length;S<I;S+=2){const z=u[S],B=u[S+1];for(let F=0;F<B;++F)L[T++]=z}return L}function d(u,A){const L=u.length,T=E(A.srcType,L);if(!L)return u;T[0]=u[0]+(A.origin|0);for(let S=1;S<L;++S)T[S]=u[S]+T[S-1];return T}function i(u,A){const L=A.byteCount===1?127:32767,T=-L-1,S=u.length,I=new Int32Array(A.srcSize);let z=0,B=0;for(;z<S;){let F=0,W=u[z];for(;W===L||W===T;)F+=W,z++,W=u[z];F+=W,I[B]=F,z++,B++}return I}function n(u,A){const L=A.byteCount===1?255:65535,T=u.length,S=new Int32Array(A.srcSize);let I=0,z=0;for(;I<T;){let B=0,F=u[I];for(;F===L;)B+=F,I++,F=u[I];B+=F,S[z]=B,I++,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 L=R({encoding:A.offsetEncoding,data:A.offsets}),T=R({encoding:A.dataEncoding,data:u}),S=A.stringData,I=new Array(L.length);I[0]="";for(let F=1,W=L.length;F<W;F++)I[F]=S.substring(L[F-1],L[F]);let z=0;const B=new Array(T.length);for(let F=0,W=T.length;F<W;F++)B[z++]=I[T[F]+1];return B}},"./src/parsers/cifutils/encoding.ts"(K,D,c){c.r(D),c.d(D,{Encoding:()=>O,VERSION:()=>y});const y="0.3.0";var O;(function(w){(function(E){E[E.Int8=1]="Int8",E[E.Int16=2]="Int16",E[E.Int32=3]="Int32",E[E.Uint8=4]="Uint8",E[E.Uint16=5]="Uint16",E[E.Uint32=6]="Uint32"})(w.IntDataType||(w.IntDataType={})),(function(E){E[E.Float32=32]="Float32",E[E.Float64=33]="Float64"})(w.FloatDataType||(w.FloatDataType={}));function R(E){let M;return E instanceof Int8Array?M=w.IntDataType.Int8:E instanceof Int16Array?M=w.IntDataType.Int16:E instanceof Int32Array?M=w.IntDataType.Int32:E instanceof Uint8Array?M=w.IntDataType.Uint8:E instanceof Uint16Array?M=w.IntDataType.Uint16:E instanceof Uint32Array?M=w.IntDataType.Uint32:E instanceof Float32Array?M=w.FloatDataType.Float32:E instanceof Float64Array?M=w.FloatDataType.Float64:M=w.IntDataType.Int32,M}w.getDataType=R;function p(E){if(E instanceof Int8Array||E instanceof Int16Array||E instanceof Int32Array)return!0;for(let M=0,g=E.length;M<g;M++)if(M<0)return!1;return!0}w.isSignedIntegerDataType=p})(O||(O={}))},"./src/parsers/index.ts"(K,D,c){c.r(D),c.d(D,{Parsers:()=>s,bondLength:()=>t.bondLength,setBondLength:()=>t.setBondLength});var y=c("./src/parsers/VASP.ts"),O=c("./src/parsers/CUBE.ts"),w=c("./src/parsers/XYZ.ts"),R=c("./src/parsers/SDF.ts"),p=c("./src/parsers/CDJSON.ts"),E=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"),v=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:y.VASP,VASP:y.VASP,cube:O.CUBE,CUBE:O.CUBE,xyz:w.XYZ,XYZ:w.XYZ,sdf:R.SDF,SDF:R.SDF,json:p.CDJSON,cdjson:p.CDJSON,CDJSON:p.CDJSON,mcif:E.CIF,cif:E.CIF,CIF:E.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:v.PRMTOP,PRMTOP:v.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,D,c){c.r(D),c.d(D,{anumToSymbol:()=>y});const y={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,D,c){c.r(D),c.d(D,{areConnected:()=>w});var y=c("./src/parsers/utils/bondLength.ts");const O=new Set(["Na","K","Ca","Mg","Mn","Sr"]);function w(R,p,E){if(E&&E.unboundCations&&(O.has(R.elem)||O.has(p.elem)))return!1;let M=(0,y.bondLength)(R.elem)+(0,y.bondLength)(p.elem);M+=.25,M*=M;let g=R.x-p.x;if(g*=g,g>M)return!1;let x=R.y-p.y;if(x*=x,x>M)return!1;let _=R.z-p.z;if(_*=_,_>M)return!1;const v=g+x+_;return!(isNaN(v)||v<.5||v>M||R.altLoc!==p.altLoc&&R.altLoc.trim()!==""&&p.altLoc.trim()!=="")}},"./src/parsers/utils/assignBackboneHBonds.ts"(K,D,c){c.r(D),c.d(D,{assignBackboneHBonds:()=>y});function y(O,w){const R=w||3.2,p=R*R,E=[];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")&&(E.push(x),x.hbondOther=null,x.hbondDistanceSq=Number.POSITIVE_INFINITY)}E.sort(function(M,g){return M.z-g.z});for(let M=0,g=E.length;M<g;M++){const x=E[M];for(let _=M+1;_<g;_++){const v=E[_],m=v.z-x.z;if(m>R)break;if(v.atom==x.atom)continue;const r=Math.abs(v.y-x.y);if(r>R)continue;const e=Math.abs(v.x-x.x);if(e>R)continue;const t=e*e+r*r+m*m;t>p||v.chain==x.chain&&Math.abs(v.resi-x.resi)<4||(t<x.hbondDistanceSq&&(x.hbondOther=v,x.hbondDistanceSq=t),t<v.hbondDistanceSq&&(v.hbondOther=x,v.hbondDistanceSq=t))}}}},"./src/parsers/utils/assignBonds.ts"(K,D,c){c.r(D),c.d(D,{assignBonds:()=>R});var y=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}],w=4.95;function R(p,E){for(let x=0,_=p.length;x<_;x++)p[x].index||(p[x].index=x);const M={x:{y:{z:[]}}};for(let x=0;x<p.length;x++){const _=p[x],v=Math.floor(_.x/w),m=Math.floor(_.y/w),r=Math.floor(_.z/w);M[v]||(M[v]={}),M[v][m]||(M[v][m]={}),M[v][m][r]||(M[v][m][r]=[]),M[v][m][r].push(_)}function g(x,_){for(let v=0;v<x.length;v++){const m=x[v];for(let r=0;r<_.length;r++){const e=_[r];if((0,y.areConnected)(m,e,E)){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 v in M[_]){const m=parseInt(v);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,y.areConnected)(o,d,E)&&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,D,c){c.r(D),c.d(D,{assignPDBBonds:()=>R});var y=c("./src/parsers/utils/areConnected.ts"),O=c("./src/parsers/utils/assignBonds.ts"),w=c("./src/parsers/utils/standardResidues.ts");function R(p,E){const M=[],g=[];for(let m=0,r=p.length;m<r;m++){const e=p[m];e.index=m,e.hetflag||!w.standardResidues.has(e.resn)?g.push(e):M.push(e)}(0,O.assignBonds)(g,E),M.sort(function(m,r){return m.chain!==r.chain?m.chain<r.chain?-1:1:m.resi-r.resi});let x=-1,_=-1,v;for(let m=0,r=M.length;m<r;m++){const e=M[m];e.resi!==x&&(x=e.resi,v||_++,v=!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,y.areConnected)(e,s,E)&&(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&&(v=!0))}}}},"./src/parsers/utils/atomNameToElem.ts"(K,D,c){c.r(D),c.d(D,{atomNameToElem:()=>O});var y=c("./src/parsers/utils/bondLength.ts");function O(w,R){let p=w.replace(/ /g,"");return p.length>0&&p[0]==="H"&&p!=="Hg"&&p!=="He"&&p!=="Hf"&&p!=="Hs"&&p!=="Ho"&&(p="H"),p.length>1&&(p=p[0].toUpperCase()+p.substring(1).toLowerCase(),y.bondTable[p]===void 0?p=p[0]:R&&(p==="Ca"||p==="Cd")&&(p="C")),p}},"./src/parsers/utils/bondLength.ts"(K,D,c){c.r(D),c.d(D,{bondLength:()=>O,bondTable:()=>y,setBondLength:()=>w});let y={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 y[R]||1.6}function w(R,p){p<0&&(p=0),y[R]=p}},"./src/parsers/utils/computeSecondaryStructure.ts"(K,D,c){c.r(D),c.d(D,{computeSecondaryStructure:()=>O});var y=c("./src/parsers/utils/assignBackboneHBonds.ts");function O(w,R){(0,y.assignBackboneHBonds)(w,R);const p={};let E,M,g,x,_,v;for(E=0,M=w.length;E<M;E++)if(_=w[E],p[_.chain]===void 0&&(p[_.chain]=[]),isFinite(_.hbondDistanceSq)){const m=_.hbondOther;p[m.chain]===void 0&&(p[m.chain]=[]),Math.abs(m.resi-_.resi)===4&&(p[_.chain][_.resi]="h")}for(g in p)for(x=1;x<p[g].length-1;x++){const m=p[g][x-1],r=p[g][x+1];v=p[g][x],m=="h"&&m==r&&v!=m&&(p[g][x]=m)}for(E=0,M=w.length;E<M;E++)_=w[E],isFinite(_.hbondDistanceSq)&&p[_.chain][_.resi]!="h"&&_.ss!=="h"&&(p[_.chain][_.resi]="maybesheet");for(let m=0,r=w.length;m<r;m++)if(_=w[m],isFinite(_.hbondDistanceSq)&&p[_.chain][_.resi]=="maybesheet"){let e=_.hbondOther,t=p[e.chain][e.resi];(t=="maybesheet"||t=="s")&&(p[_.chain][_.resi]="s",p[e.chain][e.resi]="s")}for(let m in p){for(let r=1;r<p[m].length-1;r++){const e=p[m][r-1],t=p[m][r+1];v=p[m][r],e=="s"&&e==t&&v!=e&&(p[m][r]=e)}for(let r=0;r<p[m].length;r++){const e=p[m][r];(e=="h"||e=="s")&&p[m][r-1]!=e&&p[m][r+1]!=e&&delete p[m][r]}}for(E=0,M=w.length;E<M;E++)_=w[E],v=p[_.chain][_.resi],delete _.hbondOther,delete _.hbondDistanceSq,!(v===void 0||v==="maybesheet")&&(_.ss=v,p[_.chain][_.resi-1]!=v&&(_.ssbegin=!0),p[_.chain][_.resi+1]!=v&&(_.ssend=!0))}},"./src/parsers/utils/getSinglePDB.ts"(K,D,c){c.r(D),c.d(D,{getSinglePDB:()=>x});var y=c("./src/WebGL/index.ts"),O=c("./src/parsers/utils/atomNameToElem.ts"),w=c("./src/parsers/utils/bondLength.ts"),R=c("./src/parsers/utils/computeSecondaryStructure.ts"),p=c("./src/parsers/utils/isEmpty.ts"),E=c("./src/parsers/utils/processSymmetries.ts"),M=c("./src/parsers/utils/assignPDBBonds.ts"),g=c("./src/parsers/utils/validateBonds.ts");function x(_,v,m){const r=[],e=v.assignBonds===void 0?!0:v.assignBonds,t=!v.keepH,s=!!v.noSecondaryStructure,o=!v.noComputeSecondaryStructure,l=!v.doAssembly,d=v.altLoc?v.altLoc:"A",i={symmetries:[],cryst:void 0};let n,a=[];const h=[];let u;const A={};for(let L=0;L<_.length;L++){u=_[L].replace(/^\s*/,"");const T=u.substring(0,6);let S,I,z;if(T.indexOf("END")===0){if(a=_.slice(L+1),T==="END")for(const B in m)m.hasOwnProperty(B)&&delete m[B];break}else if(T==="ATOM "||T==="HETATM"){let B,F,W,U,P,N,q,ee,ie,ne,de,re;if(de=u.substring(16,17),de!==" "&&de!==d&&d!=="*"||(ne=parseInt(u.substring(6,11)),n=u.substring(12,16).replace(/ /g,""),B=u.substring(17,20).replace(/ /g,""),F=u.substring(21,22),W=parseInt(u.substring(22,26)),U=u.substring(26,27),P=parseFloat(u.substring(30,38)),N=parseFloat(u.substring(38,46)),q=parseFloat(u.substring(46,54)),re=parseFloat(u.substring(60,68)),ie=u.substring(76,78).replace(/ /g,""),ie===""||w.bondTable[ie]===void 0?ie=(0,O.atomNameToElem)(u.substring(12,14),u[0]=="A"):ie=ie[0].toUpperCase()+ie.substring(1).toLowerCase(),ie==="H"&&t))continue;T[0]=="H"?ee=!0:ee=!1,h[ne]=r.length,r.push({resn:B,x:P,y:N,z:q,elem:ie,hetflag:ee,altLoc:de,chain:F,resi:W,icode:U,rescode:W+(U!==" "?"^"+U:""),serial:ne,atom:n,bonds:[],ss:"c",bondOrder:[],properties:{},b:re,pdbline:u})}else if(T==="SHEET "){S=u.substring(21,22),I=parseInt(u.substring(22,26)),z=parseInt(u.substring(33,37)),S in m||(m[S]={}),m[S][I]="s1";for(let B=I+1;B<z;B++)m[S][B]="s";m[S][z]="s2"}else if(T==="CONECT"){const B=parseInt(u.substring(6,11)),F=h[B],W=r[F],U=[11,16,21,26];for(let P=0;P<4;P++){const N=parseInt(u.substring(U[P],U[P]+5)),q=h[N];let ee=F+":"+q;const ie=r[q];if(W!==void 0&&ie!==void 0)if(!A[ee])A[ee]=1,(W.bonds.length==0||W.bonds[W.bonds.length-1]!==q)&&(W.bonds.push(q),W.bondOrder.push(1));else{A[ee]+=1;for(let ne=0;ne<W.bonds.length;ne++)if(W.bonds[ne]==q){const de=A[ee];de>=4?W.bondOrder[ne]=1:W.bondOrder[ne]=de}}}}else if(T==="HELIX "){S=u.substring(19,20),I=parseInt(u.substring(21,25)),z=parseInt(u.substring(33,37)),S in m||(m[S]={}),m[S][I]="h1";for(let B=I+1;B<z;B++)m[S][B]="h";m[S][z]="h2"}else if(!l&&T==="REMARK"&&u.substring(13,18)==="BIOMT"){let B,F=new y.Matrix4;for(B=1;B<=3;B++)if(u=_[L].replace(/^\s*/,""),parseInt(u.substring(18,19))==B)F.elements[B-1]=parseFloat(u.substring(23,33)),F.elements[B-1+4]=parseFloat(u.substring(33,43)),F.elements[B-1+8]=parseFloat(u.substring(43,53)),F.elements[B-1+12]=parseFloat(u.substring(53)),L++;else for(;u.substring(13,18)==="BIOMT";)L++,u=_[L].replace(/^\s*/,"");F.elements[3]=0,F.elements[7]=0,F.elements[11]=0,F.elements[15]=1,i.symmetries.push(F),L--}else if(T==="CRYST1"){let B,F,W,U,P,N;B=parseFloat(u.substring(7,15)),F=parseFloat(u.substring(16,24)),W=parseFloat(u.substring(25,33)),U=parseFloat(u.substring(34,40)),P=parseFloat(u.substring(41,47)),N=parseFloat(u.substring(48,54)),i.cryst={a:B,b:F,c:W,alpha:U,beta:P,gamma:N}}else if(T==="ANISOU"){const B=parseInt(u.substring(6,11)),F=h[B],W=r[F];if(W){const U=u.substring(30).trim().split(/\s+/),P={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=P}}}if((0,g.validateBonds)(r,h),e&&(0,M.assignPDBBonds)(r,v),l||(0,E.processSymmetries)(i.symmetries,r,v,i.cryst),o&&!s&&(0,R.computeSecondaryStructure)(r,v.hbondCutoff),!(0,p.isEmpty)(m))for(let L=0;L<r.length;L++){const T=r[L];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,D,c){c.r(D),c.d(D,{isEmpty:()=>y});function y(O){for(const w in O)return!1;return!0}},"./src/parsers/utils/processSymmetries.ts"(K,D,c){c.r(D),c.d(D,{processSymmetries:()=>O});var y=c("./src/WebGL/index.ts");function O(w,R,p,E){const M=!p.duplicateAssemblyAtoms,g=R.length;let x=g,_=-1,v=null,m=null;(p.normalizeAssembly||p.wrapAtoms)&&E&&(v=(0,y.conversionMatrix3)(E.a,E.b,E.c,E.alpha,E.beta,E.gamma),m=new y.Matrix3,m.getInverse3(v));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 y.Vector3(d[0],d[1],d[2]);return i.applyMatrix3(v),i};if(p.normalizeAssembly&&E)for(let s=0;s<w.length;s++){const o=new y.Vector3(0,0,0);for(let d=0;d<g;d++){const i=new y.Vector3(R[d].x,R[d].y,R[d].z);i.applyMatrix4(w[s]),o.add(i)}o.divideScalar(g);const l=r(o);w[s].isNearlyIdentity()&&l.lengthSq()>.001&&(_=s),w[s].translate(l)}if(M){if(w.length>1)for(let s=0;s<R.length;s++){var e=[];for(let o=0;o<w.length;o++)if(!w[o].isNearlyIdentity()){var t=new y.Vector3;t.set(R[s].x,R[s].y,R[s].z),t.applyMatrix4(w[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<w.length;s++)if(!w[s].isNearlyIdentity()&&_!=s){let o=new y.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(w[s]),p.wrapAtoms&&E){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(p.wrapAtoms&&E){let s=new y.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 y.Vector3;for(let o=0;o<g;o++)s.set(R[o].x,R[o].y,R[o].z),s.applyMatrix4(w[_]),R[o].x=s.x,R[o].y=s.y,R[o].z=s.z}w.length=0}}},"./src/parsers/utils/standardResidues.ts"(K,D,c){c.r(D),c.d(D,{standardResidues:()=>y});const y=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,D,c){c.r(D),c.d(D,{validateBonds:()=>y});function y(O,w){for(let R=0,p=O.length;R<p;R++){const E=O[R];for(let M=0;M<E.bonds.length;M++){const g=E.bonds[M],x=O[g],_=w[E.serial];x&&_&&x.bonds.indexOf(_)<0&&(x.bonds.push(_),x.bondOrder.push(E.bondOrder[M]))}}}},"./src/partialCharges.ts"(K,D,c){c.r(D),c.d(D,{applyPartialCharges:()=>O,partialCharges:()=>y});const y={"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(w,R){if((!R||typeof w.partialCharge>"u")&&w.resn&&w.atom){var p=w.resn+":"+w.atom;w.properties.partialCharge=y[p]}}},"./src/specs.ts"(K,D,c){c.r(D)},"./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,D){for(var c in D)D.hasOwnProperty(c)&&D[c]!==void 0&&(K[c]=D[c]);return K}function deepCopy(K){let D,c,y;if(K==null)return{};if(typeof K!="object"||K===null)return K;D=Array.isArray(K)?[]:{};for(y in K)c=K[y],D[y]=deepCopy(c);return D}function isNumeric(K){var D=typeof K;return(D==="number"||D==="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,D){var c,y,O,w,R,p,E,M,g,x,_=!D;if(c=y=O=9999,w=R=p=-9999,E=M=g=x=0,K.length===0)return[[0,0,0],[0,0,0],[0,0,0]];for(var v=0;v<K.length;v++){var m=K[v];if(!(typeof m>"u"||!isFinite(m.x)||!isFinite(m.y)||!isFinite(m.z))&&(x++,E+=m.x,M+=m.y,g+=m.z,c=c<m.x?c:m.x,y=y<m.y?y:m.y,O=O<m.z?O:m.z,w=w>m.x?w:m.x,R=R>m.y?R:m.y,p=p>m.z?p:m.z,m.symmetries&&_))for(var r=0;r<m.symmetries.length;r++)x++,E+=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,y=y<m.symmetries[r].y?y:m.symmetries[r].y,O=O<m.symmetries[r].z?O:m.symmetries[r].z,w=w>m.symmetries[r].x?w:m.symmetries[r].x,R=R>m.symmetries[r].y?R:m.symmetries[r].y,p=p>m.symmetries[r].z?p:m.symmetries[r].z}return[[c,y,O],[w,R,p],[E/x,M/x,g/x]]}function getPropertyRange(K,D){for(var c=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,O=0,w=K.length;O<w;O++){var R=K[O],p=getAtomProperty(R,D);p!=null&&(p<c&&(c=p),p>y&&(y=p))}return!isFinite(c)&&!isFinite(y)?c=y=0:isFinite(c)?isFinite(y)||(y=c):c=y,[c,y]}class PausableTimer{constructor(D,c,y){this.total_time_run=0,this.fn=D,this.arg=y,this.countdown=c,this.start_time=new Date().getTime(),this.ident=setTimeout(D,c,y)}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 D=window.atob(K),c=D.length,y=new Uint8Array(c),O=0;O<c;O++)y[O]=D.charCodeAt(O);return y}function getAtomProperty(K,D){var c=null;return K.properties&&typeof K.properties[D]<"u"?c=K.properties[D]:typeof K[D]<"u"&&(c=K[D]),c}function mergeGeos(K,D){var c=D.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 D=function(_){return isNumeric(_)?Math.floor(parseFloat(_))==parseInt(_)||_.indexOf(".")>=0?parseFloat(_):parseInt(_):_==="true"?!0:_==="false"?!1:_},c={};if(K==="all")return c;for(var y=K.split(";"),O=0;O<y.length;O++){var w=y[O].split(":"),R=w[0],p={},E=w[1];if(E)if(E=E.replace(/~/g,"="),E.indexOf("=")!==-1)for(var M=E.split(","),g=0;g<M.length;g++){var x=M[g].split("=",2);p[x[0]]=D(x[1])}else E.indexOf(",")!==-1?p=E.split(","):p=D(E);c[R]=p}return c}function checkStatus(K){if(!K.ok)throw new Error(`HTTP ${K.status} - ${K.statusText}`);return K}function get(K,D){var c=fetch(K).then(checkStatus).then(y=>y.text());return D?c.then(D):c}function getbin(K,D,c,y){var O;return c=="POST"?O=fetch(K,{method:"POST",body:y}).then(w=>checkStatus(w)).then(w=>w.arrayBuffer()):O=fetch(K).then(w=>checkStatus(w)).then(w=>w.arrayBuffer()),D?O.then(D):O}function download(K,D,c,y){var O="",w="",R="",p=null,E=D.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){E.addMolData(g,O,c),D.zoomTo(),D.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),p=new Promise(function(g){getbin(R).then(function(x){M(x),g(E)}).catch(function(){w=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=w+K+".pdb",O="pdb",console.warn("falling back to pdb format"),get(R).then(function(x){M(x),g(E)}).catch(function(x){M(""),g(E),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":(w=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=w+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);p=new Promise(function(g){O=="bcif"?getbin(R).then(function(x){M(x),g(E)}).catch(function(){w=c&&c.pdbUri?c.pdbUri:"https://files.rcsb.org/view/",R=w+K+".pdb",O="pdb",console.warn("falling back to pdb format"),get(R).then(function(x){M(x),g(E)}).catch(function(x){M(""),g(E),console.error("fetch of "+R+" failed: "+x.statusText)})}):get(R).then(function(x){M(x),g(E)}).catch(function(x){M(""),g(E),console.error("fetch of "+R+" failed: "+x.statusText)})})}return y?(p.then(function(g){y(g)}),E):p}function getColorFromStyle(K,D){let c=D.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 p=Object.assign({},_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors);p.C=_colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[R],_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c]={prop:"elem",map:p},c=_colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[c]}}let y=K.color;if(typeof D.color<"u"&&D.color!="spectrum"&&(y=D.color),typeof c<"u"){let R,p;if(typeof _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[c]<"u")c=_colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[c],typeof c[K[c.prop]]<"u"&&(y=c.map[K[c.prop]]);else if(typeof c[K[c.prop]]<"u")y=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 E=O.range()||[-1,1];p=getAtomProperty(K,R),p!=null&&(y=O.valueToHex(p,E))}else typeof c.prop<"u"&&typeof c.map<"u"?(R=c.prop,p=getAtomProperty(K,R),typeof c.map[p]<"u"&&(y=c.map[p])):typeof D.colorscheme[K.elem]<"u"?y=D.colorscheme[K.elem]:console.warn("Could not interpret colorscheme "+c)}else typeof D.colorfunc<"u"&&(y=D.colorfunc(K));return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(y)}function getElement(K){let D=K;return typeof K=="string"?D=document.querySelector("#"+K):typeof K=="object"&&K.get&&(D=K.get(0)),D}function inflateString(K,D=!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:D?"string":null})}},"./src/vendor/mmtf.js"(K,D){(function(c,y){y(D)})(this,function(c){function y(H,Z,Y){for(var me=(H.byteLength,0),ce=Y.length;ce>me;me++){var Ae=Y.charCodeAt(me);if(128>Ae)H.setUint8(Z++,Ae>>>0&127|0);else if(2048>Ae)H.setUint8(Z++,Ae>>>6&31|192),H.setUint8(Z++,Ae>>>0&63|128);else if(65536>Ae)H.setUint8(Z++,Ae>>>12&15|224),H.setUint8(Z++,Ae>>>6&63|128),H.setUint8(Z++,Ae>>>0&63|128);else{if(!(1114112>Ae))throw new Error("bad codepoint "+Ae);H.setUint8(Z++,Ae>>>18&7|240),H.setUint8(Z++,Ae>>>12&63|128),H.setUint8(Z++,Ae>>>6&63|128),H.setUint8(Z++,Ae>>>0&63|128)}}}function O(H){for(var Z=0,Y=0,me=H.length;me>Y;Y++){var ce=H.charCodeAt(Y);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 w(H,Z,Y){var me=typeof H;if(me==="string"){var ce=O(H);if(32>ce)return Z.setUint8(Y,160|ce),y(Z,Y+1,H),1+ce;if(256>ce)return Z.setUint8(Y,217),Z.setUint8(Y+1,ce),y(Z,Y+2,H),2+ce;if(65536>ce)return Z.setUint8(Y,218),Z.setUint16(Y+1,ce),y(Z,Y+3,H),3+ce;if(4294967296>ce)return Z.setUint8(Y,219),Z.setUint32(Y+1,ce),y(Z,Y+5,H),5+ce}if(H instanceof Uint8Array){var ce=H.byteLength,Ae=new Uint8Array(Z.buffer);if(256>ce)return Z.setUint8(Y,196),Z.setUint8(Y+1,ce),Ae.set(H,Y+2),2+ce;if(65536>ce)return Z.setUint8(Y,197),Z.setUint16(Y+1,ce),Ae.set(H,Y+3),3+ce;if(4294967296>ce)return Z.setUint8(Y,198),Z.setUint32(Y+1,ce),Ae.set(H,Y+5),5+ce}if(me==="number"){if(!isFinite(H))throw new Error("Number not finite: "+H);if(Math.floor(H)!==H)return Z.setUint8(Y,203),Z.setFloat64(Y+1,H),9;if(H>=0){if(128>H)return Z.setUint8(Y,H),1;if(256>H)return Z.setUint8(Y,204),Z.setUint8(Y+1,H),2;if(65536>H)return Z.setUint8(Y,205),Z.setUint16(Y+1,H),3;if(4294967296>H)return Z.setUint8(Y,206),Z.setUint32(Y+1,H),5;throw new Error("Number too big 0x"+H.toString(16))}if(H>=-32)return Z.setInt8(Y,H),1;if(H>=-128)return Z.setUint8(Y,208),Z.setInt8(Y+1,H),2;if(H>=-32768)return Z.setUint8(Y,209),Z.setInt16(Y+1,H),3;if(H>=-2147483648)return Z.setUint8(Y,210),Z.setInt32(Y+1,H),5;throw new Error("Number too small -0x"+(-H).toString(16).substr(1))}if(H===null)return Z.setUint8(Y,192),1;if(me==="boolean")return Z.setUint8(Y,H?195:194),1;if(me==="object"){var ce,se=0,we=Array.isArray(H);if(we)ce=H.length;else{var j=Object.keys(H);ce=j.length}var se;if(16>ce?(Z.setUint8(Y,ce|(we?144:128)),se=1):65536>ce?(Z.setUint8(Y,we?220:222),Z.setUint16(Y+1,ce),se=3):4294967296>ce&&(Z.setUint8(Y,we?221:223),Z.setUint32(Y+1,ce),se=5),we)for(var ge=0;ce>ge;ge++)se+=w(H[ge],Z,Y+se);else for(var ge=0;ce>ge;ge++){var Se=j[ge];se+=w(Se,Z,Y+se),se+=w(H[Se],Z,Y+se)}return se}throw new Error("Unknown type "+me)}function R(H){var Z=typeof H;if(Z==="string"){var Y=O(H);if(32>Y)return 1+Y;if(256>Y)return 2+Y;if(65536>Y)return 3+Y;if(4294967296>Y)return 5+Y}if(H instanceof Uint8Array){var Y=H.byteLength;if(256>Y)return 2+Y;if(65536>Y)return 3+Y;if(4294967296>Y)return 5+Y}if(Z==="number"){if(Math.floor(H)!==H)return 9;if(H>=0){if(128>H)return 1;if(256>H)return 2;if(65536>H)return 3;if(4294967296>H)return 5;throw new Error("Number too big 0x"+H.toString(16))}if(H>=-32)return 1;if(H>=-128)return 2;if(H>=-32768)return 3;if(H>=-2147483648)return 5;throw new Error("Number too small -0x"+H.toString(16).substr(1))}if(Z==="boolean"||H===null)return 1;if(Z==="object"){var Y,me=0;if(Array.isArray(H)){Y=H.length;for(var ce=0;Y>ce;ce++)me+=R(H[ce])}else{var Ae=Object.keys(H);Y=Ae.length;for(var ce=0;Y>ce;ce++){var we=Ae[ce];me+=R(we)+R(H[we])}}if(16>Y)return 1+me;if(65536>Y)return 3+me;if(4294967296>Y)return 5+me;throw new Error("Array or object too long 0x"+Y.toString(16))}throw new Error("Unknown type "+Z)}function p(H){var Z=new ArrayBuffer(R(H)),Y=new DataView(Z);return w(H,Y,0),new Uint8Array(Z)}function E(H,Z,Y){return Z?new H(Z.buffer,Z.byteOffset,Z.byteLength/(Y||1)):void 0}function M(H){return E(DataView,H)}function g(H){return E(Uint8Array,H)}function x(H){return E(Int8Array,H)}function _(H){return E(Int32Array,H,4)}function v(H){return E(Float32Array,H,4)}function m(H,Z){var Y=H.length/2;Z||(Z=new Int16Array(Y));for(var me=0,ce=0;Y>me;++me,ce+=2)Z[me]=H[ce]<<8^H[ce+1]<<0;return Z}function r(H,Z){var Y=H.length;Z||(Z=new Uint8Array(2*Y));for(var me=M(Z),ce=0;Y>ce;++ce)me.setInt16(2*ce,H[ce]);return g(Z)}function e(H,Z){var Y=H.length/4;Z||(Z=new Int32Array(Y));for(var me=0,ce=0;Y>me;++me,ce+=4)Z[me]=H[ce]<<24^H[ce+1]<<16^H[ce+2]<<8^H[ce+3]<<0;return Z}function t(H,Z){var Y=H.length;Z||(Z=new Uint8Array(4*Y));for(var me=M(Z),ce=0;Y>ce;++ce)me.setInt32(4*ce,H[ce]);return g(Z)}function s(H,Z){var Y=H.length;Z||(Z=new Float32Array(Y/4));for(var me=M(Z),ce=M(H),Ae=0,we=0,j=Y/4;j>Ae;++Ae,we+=4)me.setFloat32(we,ce.getFloat32(we),!0);return Z}function o(H,Z,Y){var me=H.length,ce=1/Z;Y||(Y=new Float32Array(me));for(var Ae=0;me>Ae;++Ae)Y[Ae]=H[Ae]*ce;return Y}function l(H,Z,Y){var me=H.length;Y||(Y=new Int32Array(me));for(var ce=0;me>ce;++ce)Y[ce]=Math.round(H[ce]*Z);return Y}function d(H,Z){var Y,me;if(!Z){var ce=0;for(Y=0,me=H.length;me>Y;Y+=2)ce+=H[Y+1];Z=new H.constructor(ce)}var Ae=0;for(Y=0,me=H.length;me>Y;Y+=2)for(var we=H[Y],j=H[Y+1],se=0;j>se;++se)Z[Ae]=we,++Ae;return Z}function i(H){if(H.length===0)return new Int32Array;var Z,Y,me=2;for(Z=1,Y=H.length;Y>Z;++Z)H[Z-1]!==H[Z]&&(me+=2);var ce=new Int32Array(me),Ae=0,we=1;for(Z=1,Y=H.length;Y>Z;++Z)H[Z-1]!==H[Z]?(ce[Ae]=H[Z-1],ce[Ae+1]=we,we=1,Ae+=2):++we;return ce[Ae]=H[H.length-1],ce[Ae+1]=we,ce}function n(H,Z){var Y=H.length;Z||(Z=new H.constructor(Y)),Y&&(Z[0]=H[0]);for(var me=1;Y>me;++me)Z[me]=H[me]+Z[me-1];return Z}function a(H,Z){var Y=H.length;Z||(Z=new H.constructor(Y)),Z[0]=H[0];for(var me=1;Y>me;++me)Z[me]=H[me]-H[me-1];return Z}function h(H,Z){var Y,me,ce=H instanceof Int8Array?127:32767,Ae=-ce-1,we=H.length;if(!Z){var j=0;for(Y=0;we>Y;++Y)H[Y]<ce&&H[Y]>Ae&&++j;Z=new Int32Array(j)}for(Y=0,me=0;we>Y;){for(var se=0;H[Y]===ce||H[Y]===Ae;)se+=H[Y],++Y;se+=H[Y],++Y,Z[me]=se,++me}return Z}function u(H,Z){var Y,me=32767,ce=-me-1,Ae=H.length,we=0;for(Y=0;Ae>Y;++Y){var j=H[Y];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(Y=0;Ae>Y;++Y){var j=H[Y];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(H,Z){return n(d(H),Z)}function L(H){return i(a(H))}function T(H,Z,Y){return o(d(H,_(Y)),Z,Y)}function S(H,Z){return i(l(H,Z))}function I(H,Z,Y){return o(n(H,_(Y)),Z,Y)}function z(H,Z,Y){return a(l(H,Z),Y)}function B(H,Z,Y){return o(h(H,_(Y)),Z,Y)}function F(H,Z,Y){var me=h(H,_(Y));return I(me,Z,v(me))}function W(H,Z,Y){return u(z(H,Z),Y)}function U(Ae){var Z=M(Ae),Y=Z.getInt32(0),me=Z.getInt32(4),ce=Ae.subarray(8,12),Ae=Ae.subarray(12);return[Y,Ae,me,ce]}function P(H,Z,Y,me){var ce=new ArrayBuffer(12+me.byteLength),Ae=new Uint8Array(ce),we=new DataView(ce);return we.setInt32(0,H),we.setInt32(4,Z),Y&&Ae.set(Y,8),Ae.set(me,12),Ae}function N(H){var Z=H.length,Y=g(H);return P(2,Z,void 0,Y)}function q(H){var Z=H.length,Y=t(H);return P(4,Z,void 0,Y)}function ee(H,Z){var Y=H.length/Z,me=t([Z]),ce=g(H);return P(5,Y,me,ce)}function ie(H){var Z=H.length,Y=t(i(H));return P(6,Z,void 0,Y)}function ne(H){var Z=H.length,Y=t(L(H));return P(8,Z,void 0,Y)}function de(H,Z){var Y=H.length,me=t([Z]),ce=t(S(H,Z));return P(9,Y,me,ce)}function re(H,Z){var Y=H.length,me=t([Z]),ce=r(W(H,Z));return P(10,Y,me,ce)}function oe(H){var Z={};return Fe.forEach(function(Y){H[Y]!==void 0&&(Z[Y]=H[Y])}),H.bondAtomList&&(Z.bondAtomList=q(H.bondAtomList)),H.bondOrderList&&(Z.bondOrderList=N(H.bondOrderList)),Z.xCoordList=re(H.xCoordList,1e3),Z.yCoordList=re(H.yCoordList,1e3),Z.zCoordList=re(H.zCoordList,1e3),H.bFactorList&&(Z.bFactorList=re(H.bFactorList,100)),H.atomIdList&&(Z.atomIdList=ne(H.atomIdList)),H.altLocList&&(Z.altLocList=ie(H.altLocList)),H.occupancyList&&(Z.occupancyList=de(H.occupancyList,100)),Z.groupIdList=ne(H.groupIdList),Z.groupTypeList=q(H.groupTypeList),H.secStructList&&(Z.secStructList=N(H.secStructList)),H.insCodeList&&(Z.insCodeList=ie(H.insCodeList)),H.sequenceIndexList&&(Z.sequenceIndexList=ne(H.sequenceIndexList)),Z.chainIdList=ee(H.chainIdList,4),H.chainNameList&&(Z.chainNameList=ee(H.chainNameList,4)),Z}function be(H){function Z(se){for(var ge={},Se=0;se>Se;Se++){var te=Ae();ge[te]=Ae()}return ge}function Y(se){var ge=H.subarray(we,we+se);return we+=se,ge}function me(se){var ge=H.subarray(we,we+se);we+=se;var Se=65535;if(se>Se){for(var te=[],xe=0;xe<ge.length;xe+=Se)te.push(String.fromCharCode.apply(null,ge.subarray(xe,xe+Se)));return te.join("")}return String.fromCharCode.apply(null,ge)}function ce(se){for(var ge=new Array(se),Se=0;se>Se;Se++)ge[Se]=Ae();return ge}function Ae(){var se,ge,Se=H[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,Y(ge);case 197:return ge=j.getUint16(we+1),we+=3,Y(ge);case 198:return ge=j.getUint32(we+1),we+=5,Y(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=H[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(H.buffer);return Ae()}function _e(H,Z,Y,me){switch(H){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(Y));case 7:return d(e(Z));case 8:return A(e(Z));case 9:return T(e(Z),e(me)[0]);case 10:return F(m(Z),e(me)[0]);case 11:return o(m(Z),e(me)[0]);case 12:return B(m(Z),e(me)[0]);case 13:return B(x(Z),e(me)[0]);case 14:return h(m(Z));case 15:return h(x(Z))}}function Oe(H,Z){Z=Z||{};var Y=Z.ignoreFields,me={};return ze.forEach(function(ce){var Ae=Y?Y.indexOf(ce)!==-1:!1,we=H[ce];Ae||we===void 0||(we instanceof Uint8Array?me[ce]=_e.apply(null,U(we)):me[ce]=we)}),me}function Me(H){return String.fromCharCode.apply(null,H).replace(/\0/g,"")}function J(H,Z,Y){Y=Y||{};var me,ce,Ae,we,j,se,ge=Y.firstModelOnly,Se=Z.onModel,te=Z.onChain,xe=Z.onGroup,V=Z.onAtom,Le=Z.onBond,De=0,C=0,le=0,he=0,k=0,ae=-1,pe=H.chainNameList,Ve=H.secStructList,Ne=H.insCodeList,Ge=H.sequenceIndexList,qe=H.atomIdList,_t=H.bFactorList,Ye=H.altLocList,He=H.occupancyList,$e=H.bondAtomList,tt=H.bondOrderList;for(me=0,ce=H.chainsPerModel.length;ce>me&&!(ge&&De>0);++me){var et=H.chainsPerModel[De];for(Se&&Se({chainCount:et,modelIndex:De}),Ae=0;et>Ae;++Ae){var bt=H.groupsPerChain[C];if(te){var xt=Me(H.chainIdList.subarray(4*C,4*C+4)),st=null;pe&&(st=Me(pe.subarray(4*C,4*C+4))),te({groupCount:bt,chainIndex:C,modelIndex:De,chainId:xt,chainName:st})}for(we=0;bt>we;++we){var lt=H.groupList[H.groupTypeList[le]],dt=lt.atomNameList.length;if(xe){var pt=null;Ve&&(pt=Ve[le]);var Mt=null;H.insCodeList&&(Mt=String.fromCharCode(Ne[le]));var At=null;Ge&&(At=Ge[le]),xe({atomCount:dt,groupIndex:le,chainIndex:C,modelIndex:De,groupId:H.groupIdList[le],groupType:H.groupTypeList[le],groupName:lt.groupName,singleLetterCode:lt.singleLetterCode,chemCompType:lt.chemCompType,secStruct:pt,insCode:Mt,sequenceIndex:At})}for(j=0;dt>j;++j){if(V){var Dt=null;qe&&(Dt=qe[he]);var Ct=null;_t&&(Ct=_t[he]);var Tt=null;Ye&&(Tt=String.fromCharCode(Ye[he]));var Rt=null;He&&(Rt=He[he]),V({atomIndex:he,groupIndex:le,chainIndex:C,modelIndex:De,atomId:Dt,element:lt.elementList[j],atomName:lt.atomNameList[j],formalCharge:lt.formalChargeList[j],xCoord:H.xCoordList[he],yCoord:H.yCoordList[he],zCoord:H.zCoordList[he],bFactor:Ct,altLoc:Tt,occupancy:Rt})}he+=1}if(Le){var Bt=lt.bondAtomList;for(j=0,se=lt.bondOrderList.length;se>j;++j)Le({atomIndex1:he-dt+Bt[2*j],atomIndex2:he-dt+Bt[2*j+1],bondOrder:lt.bondOrderList[j]})}le+=1}C+=1}if(k=ae+1,ae=he-1,Le&&$e)for(j=0,se=$e.length;se>j;j+=2){var Ft=$e[j],Ut=$e[j+1];(Ft>=k&&ae>=Ft||Ut>=k&&ae>=Ut)&&Le({atomIndex1:Ft,atomIndex2:Ut,bondOrder:tt?tt[j/2]:null})}De+=1}}function ve(H){return p(oe(H))}function Ce(H,Z){H instanceof ArrayBuffer&&(H=new Uint8Array(H));var Y;return Y=H instanceof Uint8Array?be(H):H,Oe(Y,Z)}function Te(H,Z,Y,me){function ce(){try{var we=Ce(Ae.response);Y(we)}catch(j){me(j)}}var Ae=new XMLHttpRequest;Ae.addEventListener("load",ce,!0),Ae.addEventListener("error",me,!0),Ae.responseType="arraybuffer",Ae.open("GET",Z+H.toUpperCase()),Ae.send()}function We(H,Z,Y){Te(H,je,Z,Y)}function Ie(H,Z,Y){Te(H,ke,Z,Y)}var Fe=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],Be=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],ze=Fe.concat(Be),Re="v1.0.1",Pe="//mmtf.rcsb.org/v1.0/",je=Pe+"full/",ke=Pe+"reduced/";c.encode=ve,c.decode=Ce,c.traverse=J,c.fetch=We,c.fetchReduced=Ie,c.version=Re,c.fetchUrl=je,c.fetchReducedUrl=ke,c.encodeMsgpack=p,c.encodeMmtf=oe,c.decodeMsgpack=be,c.decodeMmtf=Oe})}},__webpack_module_cache__={};function __webpack_require__(K){var D=__webpack_module_cache__[K];if(D!==void 0)return D.exports;if(__webpack_modules__[K]===void 0){var c=new Error("Cannot find module '"+K+"'");throw c.code="MODULE_NOT_FOUND",c}var y=__webpack_module_cache__[K]={exports:{}};return __webpack_modules__[K].call(y.exports,y,y.exports,__webpack_require__),y.exports}__webpack_require__.n=K=>{var D=K&&K.__esModule?()=>K.default:()=>K;return __webpack_require__.d(D,{a:D}),D},__webpack_require__.d=(K,D)=>{for(var c in D)__webpack_require__.o(D,c)&&!__webpack_require__.o(K,c)&&Object.defineProperty(K,c,{enumerable:!0,get:D[c]})},__webpack_require__.o=(K,D)=>Object.prototype.hasOwnProperty.call(K,D),__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$3)),_3Dmol$3.exports}var _3DmolExports=require_3Dmol();const _3Dmol=getDefaultExportFromCjs(_3DmolExports),_3Dmol$1=_mergeNamespaces({__proto__:null,default:_3Dmol},[_3DmolExports]);export{_3Dmol$1 as _};
|