";let r=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(r+"_counts.html","html",n)})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelections","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_selections.txt","text",[n])})),e.myEventCls.onIds("#"+e.pre+"mn1_exportSelDetails","click",(function(s){let i=e.icn3d;t.setLogCmd("export all selections with details",!1),t.SetChainsAdvancedMenu();let n=i.saveFileCls.exportCustomAtoms(!0),l=i.inputid?i.inputid:"custom";i.saveFileCls.saveFile(l+"_sel_details.txt","text",[n])})),e.myEventCls.onIds(["#"+e.pre+"mn1_sharelink","#"+e.pre+"tool_sharelink"],"click",(async function(t){let s=e.icn3d;await s.shareLinkCls.shareLink()})),e.myEventCls.onIds("#"+e.pre+"mn1_replayon","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayon(),t.setLogCmd("replay on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_replayoff","click",(async function(s){let i=e.icn3d;await i.resizeCanvasCls.replayoff(),t.setLogCmd("replay off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_menuall","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menusimple","click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus()})),e.myEventCls.onIds("#"+e.pre+"mn1_menupref","click",(function(s){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menupref","Select Menus"),t.getHiddenMenusFromCache(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"apply_menupref","#"+e.pre+"apply_menupref2"],"click",(function(s){e.icn3d;var i=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:checked');for(var n of(e.htmlCls.shownMenus={},i))e.htmlCls.shownMenus[n.value]=1;t.applyShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref","#"+e.pre+"reset_menupref2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.simpleMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"reset_menupref_all","#"+e.pre+"reset_menupref_all2"],"click",(function(s){e.icn3d,e.htmlCls.shownMenus=e.hashUtilsCls.cloneHash(e.htmlCls.allMenus),t.applyShownMenus(),t.displayShownMenus()})),e.myEventCls.onIds(["#"+e.pre+"savepref","#"+e.pre+"savepref2"],"click",(function(t){let s=e.icn3d,i="[";var n=document.querySelectorAll('form[name="'+e.pre+'selmenu"] input:not(:checked)');let l=0;for(var r of n)l>0&&(i+=", "),i+='"'+r.value+'"',++l;i+="]",s.saveFileCls.saveFile("icn3d_menus_pref.txt","text",[i])})),e.myEventCls.onIds("#"+e.pre+"reload_menupreffile","click",(function(s){e.icn3d,e.cfg.notebook||dialog.dialog("close");let i=$("#"+e.pre+"menupreffile")[0].files[0];if(i){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let i=s.target.result,n=JSON.parse(i);e.htmlCls.shownMenus={};for(let t in e.htmlCls.allMenus)-1==n.indexOf(t)&&(e.htmlCls.shownMenus[t]=1);t.applyShownMenus(),t.displayShownMenus()},s.readAsText(i)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"mn1_menuloadpref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_menuloadpref","Please input the menu preference file")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_structure","click",(function(t){let s=e.icn3d,i=s.saveFileCls.getLinkToStructureSummary(!0),n=s.structures&&Object.keys(s.structures).length>0?"_blank":"_self";window.open(i,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_bind","click",(function(s){let i=e.icn3d;url="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_structure&from_uid="+i.inputid,t.setLogCmd("link to 3D protein structures bound to CID "+i.inputid+": "+url,!1);let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_vast","click",(function(s){let i=e.icn3d;if(void 0===i.inputid)url="https://www.ncbi.nlm.nih.gov/pccompound?term="+i.molTitle,t.setLogCmd("link to compounds "+i.molTitle+": "+url,!1);else{let s;if(void 0!==e.cfg.cid)s="https://www.ncbi.nlm.nih.gov/pccompound?LinkName=pccompound_pccompound_3d&from_uid="+i.inputid,t.setLogCmd("link to compounds with structure similar to CID "+i.inputid+": "+s,!1);else{let n=i.inputid.split("_");1===n.length?(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+i.inputid,t.setLogCmd("link to structures similar to "+i.inputid+": "+s,!1)):2===n.length&&(s=e.htmlCls.baseUrl+"vastplus/vastplus.cgi?uid="+n[0],t.setLogCmd("link to structures similar to "+n[0]+": "+s,!1))}}let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(url,n)})),e.myEventCls.onIds("#"+e.pre+"mn1_link_pubmed","click",(function(s){let i=e.icn3d;if(void 0===i.inputid){let e;e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.molTitle,t.setLogCmd("link to literature about "+i.molTitle+": "+e,!1);let s=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,s)}else if(i.pmid){let e,s=i.pmid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/"+i.pmid,t.setLogCmd("link to PubMed ID "+i.pmid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to PubMed IDs "+s[0]+", "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else if(isNaN(i.inputid)){let e,s=i.inputid.toString().split("_");1===s.length?(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+i.inputid,t.setLogCmd("link to literature about PDB "+i.inputid+": "+e,!1)):2===s.length&&(e="https://www.ncbi.nlm.nih.gov/pubmed/?term="+s[0]+" OR "+s[1],t.setLogCmd("link to literature about PDB "+s[0]+" OR "+s[1]+": "+e,!1));let n=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(e,n)}else void 0!==e.cfg.cid?alert("No literature information is available for this compound in the SDF file."):alert("No literature information is available for this structure.")})),e.myEventCls.onIds("#"+e.pre+"mn1_link_protein","click",(function(s){let i=e.icn3d,n=Object.keys(i.structures),l=Object.keys(i.chains),r="";for(let e=0,t=l.length;e0&&(r=r.substr(0,r.length-4));let o="https://www.ncbi.nlm.nih.gov/protein/?term="+r;t.setLogCmd("link to Entrez protein about PDB "+n+": "+o,!1);let a=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(o,a)}))}clickMenu2(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn6_selectannotations","#"+e.pre+"tool_selectannotations"],"click",(async function(s){let i=e.icn3d;await i.showAnnoCls.showAnnotations(),t.setLogCmd("view annotations",!0)})),e.myEventCls.onIds("#"+e.pre+"mn2_selectall","click",(function(s){let i=e.icn3d;t.setLogCmd("select all",!0),i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"clearall","click",(function(s){let i=e.icn3d;t.setLogCmd("clear all",!0),i.bSelectResidue=!1,i.selectionCls.selectAll(),i.hlUpdateCls.removeHlAll(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectdisplayed","click",(function(s){let i=e.icn3d;t.setLogCmd("select displayed set",!0),i.hAtoms=e.hashUtilsCls.cloneHash(i.viewSelectionAtoms),i.hlUpdateCls.updateHlAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_fullstru","click",(function(s){let i=e.icn3d;t.setLogCmd("show all",!0),i.selectionCls.showAll()})),e.myEventCls.onIds("#"+e.pre+"mn2_selectcomplement","click",(function(s){let i=e.icn3d;Object.keys(i.hAtoms).lengthnon-selected"+n),$("#"+e.pre+"atomsCustomSphere2").length&&$("#"+e.pre+"atomsCustomSphere2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_aroundsphere","Select a sphere around a set of residues"),i.bSphereCalc=!1,$("#"+e.pre+"atomsCustomSphere").resizable(),$("#"+e.pre+"atomsCustomSphere2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn2_select_chain","#"+e.pre+"definedSets"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_select_chain","Select Structure/Chain/Custom Selection")}))}clickMenu3(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsRibbon","#"+e.pre+"tool_proteinsRibbon"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ribbon"),t.setLogCmd("style proteins ribbon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStrand","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","strand"),t.setLogCmd("style proteins strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCylinder","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","cylinder and plate"),t.setLogCmd("style proteins cylinder and plate",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","schematic"),t.setLogCmd("style proteins schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsCalpha","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","c alpha trace"),t.setLogCmd("style proteins c alpha trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","backbone"),t.setLogCmd("style proteins backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsBfactor","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","b factor tube"),t.setLogCmd("style proteins b factor tube",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsLines","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","lines"),t.setLogCmd("style proteins lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsStick","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","stick"),t.setLogCmd("style proteins stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsBallstick","#"+e.pre+"tool_proteinsBallstick"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","ball and stick"),t.setLogCmd("style proteins ball and stick",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn3_proteinsSphere","#"+e.pre+"tool_proteinsSphere"],"click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","sphere"),t.setLogCmd("style proteins sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_proteinsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("proteins","nothing"),t.setLogCmd("style proteins nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecLines","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","lines2"),t.setLogCmd("style sidec lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecStick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","stick2"),t.setLogCmd("style sidec stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","ball and stick2"),t.setLogCmd("style sidec ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","sphere2"),t.setLogCmd("style sidec sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_sidecNo","click",(function(s){e.icn3d.setOptionCls.setStyle("sidec","nothing"),t.setLogCmd("style sidec nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseLines","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","lines2"),t.setLogCmd("style ntbase lines2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseStick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","stick2"),t.setLogCmd("style ntbase stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","ball and stick2"),t.setLogCmd("style ntbase ball and stick2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","sphere2"),t.setLogCmd("style ntbase sphere2",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ntbaseNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ntbase","nothing"),t.setLogCmd("style ntbase nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclCartoon","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),t.setLogCmd("style nucleotides nucleotide cartoon",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBackbone","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","backbone"),t.setLogCmd("style nucleotides backbone",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","schematic"),t.setLogCmd("style nucleotides schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclPhos","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","o3 trace"),t.setLogCmd("style nucleotides o3 trace",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclLines","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","lines"),t.setLogCmd("style nucleotides lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclStick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","stick"),t.setLogCmd("style nucleotides stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","ball and stick"),t.setLogCmd("style nucleotides ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","sphere"),t.setLogCmd("style nucleotides sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_nuclNo","click",(function(s){e.icn3d.setOptionCls.setStyle("nucleotides","nothing"),t.setLogCmd("style nucleotides nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligLines","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","lines"),t.setLogCmd("style chemicals lines",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligStick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","stick"),t.setLogCmd("style chemicals stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligBallstick","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","ball and stick"),t.setLogCmd("style chemicals ball and stick",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSchematic","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","schematic"),t.setLogCmd("style chemicals schematic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","sphere"),t.setLogCmd("style chemicals sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ligNo","click",(function(s){e.icn3d.setOptionCls.setStyle("chemicals","nothing"),t.setLogCmd("style chemicals nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartYes","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!0,i.drawCls.draw(),t.setLogCmd("glycans cartoon yes",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_glycansCartNo","click",(function(s){let i=e.icn3d;i.bGlycansCartoon=!1,i.drawCls.draw(),t.setLogCmd("glycans cartoon no",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensYes","click",(function(s){let i=e.icn3d;i.showInterCls.showHydrogens(),i.drawCls.draw(),t.setLogCmd("hydrogens",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_hydrogensNo","click",(function(s){let i=e.icn3d;i.showInterCls.hideHydrogens(),i.drawCls.draw(),t.setLogCmd("set hydrogens off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","sphere"),t.setLogCmd("style ions sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsDot","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","dot"),t.setLogCmd("style ions dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_ionsNo","click",(function(s){e.icn3d.setOptionCls.setStyle("ions","nothing"),t.setLogCmd("style ions nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterSphere","click",(function(s){e.icn3d.setOptionCls.setStyle("water","sphere"),t.setLogCmd("style water sphere",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterDot","click",(function(s){e.icn3d.setOptionCls.setStyle("water","dot"),t.setLogCmd("style water dot",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_waterNo","click",(function(s){e.icn3d.setOptionCls.setStyle("water","nothing"),t.setLogCmd("style water nothing",!0)}))}clickMenu4(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum"),t.setLogCmd("color spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumChain","click",(function(s){e.icn3d.setOptionCls.setOption("color","spectrum for chains"),t.setLogCmd("color spectrum for chains",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrumAcross").length&&$("#"+e.pre+"atomsCustomColorSpectrumAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumacrosssets","Please select sets to apply spectrum color for sets"),$("#"+e.pre+"atomsCustomColorSpectrumAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSpectrumSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorSpectrum").length&&$("#"+e.pre+"atomsCustomColorSpectrum").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorspectrumbysets","Please select sets to apply spectrum color for residues"),$("#"+e.pre+"atomsCustomColorSpectrum").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowAcrossSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbowAcross").length&&$("#"+e.pre+"atomsCustomColorRainbowAcross").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowacrosssets","Please select sets to apply rainbow color for sets"),$("#"+e.pre+"atomsCustomColorRainbowAcross").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbowSets","click",(function(s){let i=e.icn3d;t.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomColorRainbow").length&&$("#"+e.pre+"atomsCustomColorRainbow").html(n),i.bRender&&e.htmlCls.dialogCls.openDlg("dl_colorrainbowbysets","Please select sets to apply rainbow color for residues"),$("#"+e.pre+"atomsCustomColorRainbow").resizable()})),e.myEventCls.onIds("#"+e.pre+"mn4_clrRainbow","click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow"),t.setLogCmd("color rainbow",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrRainbowChain","#"+e.pre+"tool_clrRainbowChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","rainbow for chains"),t.setLogCmd("color rainbow for chains",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrChain","#"+e.pre+"tool_clrChain"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","chain"),t.setLogCmd("color chain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrStructure","click",(function(s){e.icn3d.setOptionCls.setOption("color","structure"),t.setLogCmd("color structure",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrdomain","click",(function(s){e.icn3d.setOptionCls.setOption("color","domain"),t.setLogCmd("color domain",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrsets","click",(function(s){e.icn3d.setOptionCls.setOption("color","defined sets"),t.setLogCmd("color defined sets",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrSSGreen","#"+e.pre+"tool_clrSSGreen"],"click",(function(s){let i=e.icn3d;i.sheetcolor="green",i.setOptionCls.setOption("color","secondary structure green"),t.setLogCmd("color secondary structure green",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSYellow","click",(function(s){let i=e.icn3d;i.sheetcolor="yellow",i.setOptionCls.setOption("color","secondary structure yellow"),t.setLogCmd("color secondary structure yellow",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSSSpectrum","click",(function(s){e.icn3d.setOptionCls.setOption("color","secondary structure spectrum"),t.setLogCmd("color secondary structure spectrum",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidue","click",(function(s){e.icn3d.setOptionCls.setOption("color","residue"),t.setLogCmd("color residue",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrResidueCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_rescolorfile","Please input the file on residue colors")})),e.myEventCls.onIds("#"+e.pre+"reload_rescolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+e.pre+"rescolorfile")[0].files[0];if(n){e.htmlCls.setHtmlCls.fileSupport();let s=new FileReader;s.onload=function(s){let n=s.target.result.replace(/#/g,"");i.customResidueColors=JSON.parse(n);for(let t in i.customResidueColors)i.customResidueColors[t.toUpperCase()]=e.parasCls.thr("#"+i.customResidueColors[t]);i.setOptionCls.setOption("color","residue custom"),t.setLogCmd("color residue custom | "+n,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Load'")})),e.myEventCls.onIds("#"+e.pre+"reload_customcolorfile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close"),i.startColor=$("#"+e.pre+"startColor").val(),i.midColor=$("#"+e.pre+"midColor").val(),i.endColor=$("#"+e.pre+"endColor").val();let n=t.setLegendHtml();$("#"+e.pre+"dl_legend").html(n),e.htmlCls.dialogCls.openDlg("dl_legend","Color range"),i.addTrackCls.setCustomFile("color",i.startColor,i.midColor,i.endColor)})),e.myEventCls.onIds("#"+e.pre+"mn6_customref","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_customref","Set custom reference numbers")})),e.myEventCls.onIds("#"+e.pre+"reload_customreffile","click",(function(s){let i=e.icn3d;e.cfg.notebook||dialog.dialog("close");let n=$("#"+i.pre+"cstreffile")[0].files[0];if(n){e.utilsCls.checkFileAPI();let s=new FileReader;s.onload=async function(e){let s=e.target.result;await i.refnumCls.parseCustomRefFile(s),s=s.replace(/\r/g,"").replace(/\n/g,"\\n"),t.setLogCmd("custom refnum | "+s,!0)},s.readAsText(n)}else alert("Please select a file before clicking 'Apply'")})),e.myEventCls.onIds("#"+e.pre+"remove_legend","click",(function(s){e.icn3d,$("#"+e.pre+"legend").hide(),t.setLogCmd("remove legend",!0)})),e.myEventCls.onIds("#"+e.pre+"reload_customtubefile","click",(function(t){let s=e.icn3d;e.cfg.notebook||dialog.dialog("close"),s.addTrackCls.setCustomFile("tube")})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCharge","click",(function(s){e.icn3d.setOptionCls.setOption("color","charge"),t.setLogCmd("color charge",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrHydrophobic","click",(function(s){e.icn3d.setOptionCls.setOption("color","hydrophobic"),t.setLogCmd("color hydrophobic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrNormalizedHP","click",(function(s){e.icn3d.setOptionCls.setOption("color","normalized hydrophobic"),t.setLogCmd("color normalized hydrophobic",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn4_clrAtom","#"+e.pre+"tool_clrAtom"],"click",(function(s){e.icn3d.setOptionCls.setOption("color","atom"),t.setLogCmd("color atom",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactor","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor"),t.setLogCmd("color b factor",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConfidence","click",(function(s){e.icn3d.setOptionCls.setOption("color","confidence"),t.setLogCmd("color confidence",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIgstrand","click",(function(s){e.icn3d.setOptionCls.setOption("color","ig strand"),t.setLogCmd("color ig strand",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrArea","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_colorbyarea","Color based on residue's solvent accessibility")})),e.myEventCls.onIds("#"+e.pre+"applycolorbyarea","click",(function(s){let i=e.icn3d;i.midpercent=$("#"+e.pre+"midpercent").val(),i.setOptionCls.setOption("color","area"),t.setLogCmd("color area | "+i.midpercent,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrBfactorNorm","click",(function(s){e.icn3d.setOptionCls.setOption("color","b factor percentile"),t.setLogCmd("color b factor percentile",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrIdentity","click",(function(s){e.icn3d.setOptionCls.setOption("color","identity"),t.setLogCmd("color identity",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrConserved","click",(function(s){e.icn3d.setOptionCls.setOption("color","conservation"),t.setLogCmd("color conservation",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrCustom","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_clr","Color picker")})),$(document).on("click",".icn3d-color-rad-text",(function(s){let i=e.icn3d;s.stopImmediatePropagation(),s.preventDefault();let n=$(this).attr("color");i.setOptionCls.setOption("color",n),t.setLogCmd("color "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrSave","click",(function(s){e.icn3d.setOptionCls.saveColor(),t.setLogCmd("save color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn4_clrApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedColor(),t.setLogCmd("apply saved color",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleSave","click",(function(s){e.icn3d.setOptionCls.saveStyle(),t.setLogCmd("save style",!0)})),e.myEventCls.onIds("#"+e.pre+"mn3_styleApplySave","click",(function(s){e.icn3d.setOptionCls.applySavedStyle(),t.setLogCmd("apply saved style",!0)}))}clickMenu5(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t=this;e.myEventCls.onIds("#"+e.pre+"mn5_neighborsYes","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_neighborsNo","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.applyMapCls.removeLastSurface(),i.applyMapCls.applySurfaceOptions(),i.bRender&&i.drawCls.render(),t.setLogCmd("set surface neighbors off",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn5_surfaceVDW","#"+e.pre+"tool_surfaceVDW"],"click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","Van der Waals surface"),t.setLogCmd("set surface Van der Waals surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSAS","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","solvent accessible surface"),t.setLogCmd("set surface solvent accessible surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecular","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!1,i.setOptionCls.setOption("surface","molecular surface"),t.setLogCmd("set surface molecular surface",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceVDWContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","Van der Waals surface with context"),t.setLogCmd("set surface Van der Waals surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceSASContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","solvent accessible surface with context"),t.setLogCmd("set surface solvent accessible surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceMolecularContext","click",(function(s){let i=e.icn3d;i.bConsiderNeighbors=!0,i.setOptionCls.setOption("surface","molecular surface with context"),t.setLogCmd("set surface molecular surface with context",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_surfaceNo","click",(function(s){e.icn3d.setOptionCls.setOption("surface","nothing"),t.setLogCmd("set surface nothing",!0)})),$(document).on("click","."+e.pre+"mn5_opacity",(function(s){let i=e.icn3d;i.transparentRenderOrder=!1;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface opacity "+n,!0)})),$(document).on("click","."+e.pre+"mn5_opacityslow",(function(s){let i=e.icn3d;i.transparentRenderOrder=!0;let n=$(this).attr("v");i.setOptionCls.setOption("opacity",n),t.setLogCmd("set surface2 opacity "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","yes"),t.setLogCmd("set surface wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_wireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("wireframe","no"),t.setLogCmd("set surface wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmap2fofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmap2fofc","2Fo-Fc Electron Density Map")})),e.myEventCls.onIds("#"+e.pre+"mn5_elecmapfofc","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_elecmapfofc","Fo-Fc Electron Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_elecmapNo","#"+e.pre+"elecmapNo2","#"+e.pre+"elecmapNo3","#"+e.pre+"elecmapNo4","#"+e.pre+"elecmapNo5"],"click",(function(s){e.icn3d.setOptionCls.setOption("map","nothing"),t.setLogCmd("setoption map nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo","#"+e.pre+"phimapNo","#"+e.pre+"phiurlmapNo","#"+e.pre+"mn1_phimapNo"],"click",(function(s){e.icn3d.setOptionCls.setOption("phimap","nothing"),t.setLogCmd("setoption phimap nothing",!0)})),e.myEventCls.onIds(["#"+e.pre+"delphimapNo2","#"+e.pre+"phimapNo2","#"+e.pre+"phiurlmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("phisurface","nothing"),t.setLogCmd("setoption phisurface nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applymap2fofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigma2fofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"2fofc",n),t.setLogCmd("set map 2fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"applymapfofc","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"sigmafofc").val());i.dsn6ParserCls.dsn6Parser(i.inputid,"fofc",n),t.setLogCmd("set map fofc sigma "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","yes"),t.setLogCmd("set map wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_mapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("mapwireframe","no"),t.setLogCmd("set map wireframe off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmap","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_emmap","EM Density Map")})),e.myEventCls.onIds(["#"+e.pre+"mn5_emmapNo","#"+e.pre+"emmapNo2"],"click",(function(s){e.icn3d.setOptionCls.setOption("emmap","nothing"),t.setLogCmd("setoption emmap nothing",!0)})),e.myEventCls.onIds("#"+e.pre+"applyemmap","click",(function(s){let i=e.icn3d,n=parseFloat($("#"+e.pre+"empercentage").val());i.densityCifParserCls.densityCifParser(i.inputid,"em",n,i.emd),t.setLogCmd("set emmap percentage "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeYes","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","yes"),t.setLogCmd("set emmap wireframe on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn5_emmapwireframeNo","click",(function(s){e.icn3d.setOptionCls.setOption("emmapwireframe","no"),t.setLogCmd("set emmap wireframe off",!0)}))}clickMenu6(){let e=this.icn3dui,t=e.icn3d;if(e.bNode)return;let s=this;e.myEventCls.onIds("#"+e.pre+"mn6_assemblyYes","click",(function(t){let i=e.icn3d;i.bAssembly=!0,s.setLogCmd("set assembly on",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_assemblyNo","click",(function(t){let i=e.icn3d;i.bAssembly=!1,s.setLogCmd("set assembly off",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefYes","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum on",!0),await i.refnumCls.showIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_igrefNo","click",(async function(t){let i=e.icn3d;s.setLogCmd("ig refnum off",!0),await i.refnumCls.hideIgRefNum()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelAtoms","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add atom labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelElements","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addAtomLabels(i.hAtoms,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add element labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResidues","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelResnum","click",(function(t){let i=e.icn3d;i.residueLabelsCls.addResidueLabels(i.hAtoms,void 0,void 0,!0),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add residue number labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelChains","click",(function(t){let i=e.icn3d;i.analysisCls.addChainLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add chain labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelTermini","click",(function(t){let i=e.icn3d;i.analysisCls.addTerminiLabels(i.hAtoms),i.selectionCls.saveSelectionIfSelected(),s.setLogCmd("add terminal labels",!0),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_addlabel","Add custom labels by selection"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn6_addlabelSelection","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_addlabelselection","Add custom labels by the selected")})),e.myEventCls.onIds("#"+e.pre+"mn6_labelColor","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_labelColor","Change color for all labels")})),e.myEventCls.onIds(["#"+e.pre+"mn2_saveselection","#"+e.pre+"tool_saveselection"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_saveselection","Save the selected")})),e.myEventCls.onIds(["#"+e.pre+"mn6_addlabelNo","#"+e.pre+"removeLabels"],"click",(function(t){let i=e.icn3d;i.labelcolor=void 0,i.pickpair=!1;s.setLogCmd("set labels off",!0);for(let e in i.labels)i.labels[e]=[];i.drawCls.draw()})),$(document).on("click","."+e.pre+"mn6_labelscale",(function(t){let i=e.icn3d,n=$(this).attr("v");i.labelScale=n,i.drawCls.draw(),s.setLogCmd("set label scale "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceYes","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distance","Measure the distance of atoms"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0,s.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distTwoSets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_disttwosets","Measure the distance between two sets"),s.setSetsMenus("atomsCustomDist"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distManySets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_distmanysets","Measure the pairwise distance among many sets"),s.setSetsMenus("atomsCustomDistTable"),i.bMeasureDistance=!0})),e.myEventCls.onIds("#"+e.pre+"mn6_distanceNo","click",(function(t){let i=e.icn3d;i.pickpair=!1;s.setLogCmd("set lines off",!0),i.labels.distance=[],i.lines.distance=[],i.distPnts=[],i.pk=2,i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn5_cartoonshape","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_cartoonshape","Draw cartoon for a set");s.setSetsMenus("cartoonshape",!0),i.bCartoonshape=!0})),e.myEventCls.onIds("#"+e.pre+"mn5_linebtwsets","click",(function(t){let i=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_linebtwsets","Draw a line between two sets"),s.setSetsMenus("linebtwsets"),i.bLinebtwsets=!0})),e.myEventCls.onIds(["#"+e.pre+"mn2_selectedcenter","#"+e.pre+"zoomin_selection","#"+e.pre+"tool_selectedcenter"],"click",(function(t){let i=e.icn3d;i.transformCls.zoominSelection(),i.drawCls.draw(),s.setLogCmd("zoom selection",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_center","click",(function(t){let i=e.icn3d;i.applyCenterCls.centerSelection(),i.drawCls.draw(),s.setLogCmd("center selection",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_resetOrientation","#"+e.pre+"resetOrientation","#"+e.pre+"tool_resetOrientation"],"click",(function(t){let i=e.icn3d;i.transformCls.resetOrientation(),i.drawCls.draw(),s.setLogCmd("reset orientation",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindingshow","#"+e.pre+"chemicalbindingshow"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","show"),s.setLogCmd("set chemicalbinding show",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_chemicalbindinghide","#"+e.pre+"chemicalbindinghide"],"click",(function(t){e.icn3d.setOptionCls.setOption("chemicalbinding","hide"),s.setLogCmd("set chemicalbinding hide",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_sidebyside","click",(function(t){let i=e.icn3d;if(i.bInputfile)return void alert("Side-by-Side does NOT work when the input is from a local file.");let n=i.shareLinkCls.shareLinkUrl(void 0);n=n.replace("full.html","full2.html"),n+="&closepopup=1";let l=i.structures&&Object.keys(i.structures).length>0?"_blank":"_self";window.open(n,l),s.setLogCmd("side by side | "+n,!0)})),$(document).on("click","."+e.pre+"mn6_rotate",(function(t){let i=e.icn3d,n=$(this).attr("v").toLowerCase(),l=n.split(" ")[1];s.setLogCmd(n,!0),i.bStopRotate=!1,i.transformCls.rotateCount=0,i.transformCls.rotateCountMax=6e3,i.ROT_DIR=l,i.resizeCanvasCls.rotStruc(l)})),$(document).on("click","."+e.pre+"mn6_rotate90",(function(t){let i,n=e.icn3d,l=$(this).attr("v").toLowerCase(),r=l.split("-")[0];s.setLogCmd(l,!0),"x"==r?i=new THREE.Vector3(1,0,0):"y"==r?i=new THREE.Vector3(0,1,0):"z"==r&&(i=new THREE.Vector3(0,0,1));let o=.5*Math.PI;n.transformCls.setRotation(i,o)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraPers","click",(function(t){e.icn3d.setOptionCls.setOption("camera","perspective"),s.setLogCmd("set camera perspective",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_cameraOrth","click",(function(t){e.icn3d.setOptionCls.setOption("camera","orthographic"),s.setLogCmd("set camera orthographic",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdBlack","click",(function(t){e.icn3d.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"tool_bkgd","click",(function(t){let s=e.icn3d;"black"==s.opts.background?s.setStyleCls.setBackground("white"):s.setStyleCls.setBackground("black")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdGrey","click",(function(t){e.icn3d.setStyleCls.setBackground("grey")})),e.myEventCls.onIds(["#"+e.pre+"mn6_bkgdWhite","#"+e.pre+"tool_bkgdWhite"],"click",(function(t){e.icn3d.setStyleCls.setBackground("white")})),e.myEventCls.onIds("#"+e.pre+"mn6_bkgdTransparent","click",(function(t){e.icn3d.setStyleCls.setBackground("transparent")})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogYes","click",(function(t){let i=e.icn3d;i.opts.fog="yes",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showfogNo","click",(function(t){let i=e.icn3d;i.opts.fog="no",i.fogCls.setFog(!0),i.drawCls.draw(),s.setLogCmd("set fog off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabYes","click",(function(t){e.icn3d.setOptionCls.setOption("slab","yes"),s.setLogCmd("set slab on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showslabNo","click",(function(t){e.icn3d.setOptionCls.setOption("slab","no"),s.setLogCmd("set slab off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisYes","click",(function(t){e.icn3d.setOptionCls.setOption("axis","yes"),s.setLogCmd("set axis on",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisSel","click",(function(t){let i=e.icn3d;i.pc1=!0,i.axesCls.setPc1Axes(),s.setLogCmd("set pc1 axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_showaxisNo","click",(function(t){let i=e.icn3d;i.pc1=!1,i.axes=[],i.setOptionCls.setOption("axis","no"),s.setLogCmd("set axis off",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_symmetry","click",(async function(t){let s=e.icn3d;s.bAxisOnly=!1,await s.symdCls.retrieveSymmetry(Object.keys(s.structures)[0])})),e.myEventCls.onIds("#"+e.pre+"mn6_symd","click",(async function(t){let i=e.icn3d;i.bAxisOnly=!1,await i.symdCls.retrieveSymd(),i.bSymd=!0,s.setLogCmd("symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_clear_sym","click",(function(t){let i=e.icn3d;i.symdArray=[],i.drawCls.draw(),s.setLogCmd("clear symd symmetry",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_axes_only","click",(function(t){let i=e.icn3d;i.bAxisOnly=!0,i.drawCls.draw(),s.setLogCmd("show axis",!0)})),e.myEventCls.onIds("#"+e.pre+"mn6_area","click",(function(t){e.icn3d.analysisCls.calculateArea(),s.setLogCmd("area",!0)})),e.myEventCls.onIds("#"+e.pre+"applysymmetry","click",(function(t){let i=e.icn3d;i.bAxisOnly=!1;let n=$("#"+e.pre+"selectSymmetry").val();i.symmetrytitle="none"===n?void 0:n,i.drawCls.draw(),s.setLogCmd("symmetry "+n,!0)})),e.myEventCls.onIds("#"+e.pre+"clearsymmetry","click",(function(t){let i=e.icn3d;i.symmetrytitle=void 0,i.drawCls.draw(),s.setLogCmd("symmetry none",!0)})),e.myEventCls.onIds(["#"+e.pre+"mn6_hbondsYes","#"+e.pre+"hbondsYes"],"click",(function(t){let i=e.icn3d;s.SetChainsAdvancedMenu();let n=i.definedSetsCls.setAtomMenu(["protein"]);$("#"+e.pre+"atomsCustomHbond").length&&$("#"+e.pre+"atomsCustomHbond").html(" "+n),$("#"+e.pre+"atomsCustomHbond2").length&&$("#"+e.pre+"atomsCustomHbond2").html(" "+n),e.htmlCls.dialogCls.openDlg("dl_hbonds","Hydrogen bonds/interactions between two sets of atoms"),i.bHbondCalc=!1,$("#"+e.pre+"atomsCustomHbond").resizable(),$("#"+e.pre+"atomsCustomHbond2").resizable()})),e.myEventCls.onIds(["#"+e.pre+"mn6_contactmap"],"click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_contact","Set contact map")})),e.myEventCls.onIds("#"+e.pre+"mn6_hbondsNo","click",(function(t){let s=e.icn3d;s.showInterCls.hideHbondsContacts(),s.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerYes","click",(function(t){let i=e.icn3d;i.threeDPrintCls.addStabilizer(),i.threeDPrintCls.prepareFor3Dprint(),s.setLogCmd("stabilizer",!0)})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerNo","click",(function(t){let i=e.icn3d;s.setLogCmd("set stabilizer off",!0),i.threeDPrintCls.hideStabilizer(),i.drawCls.draw()})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer","Add One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_stabilizerRmOne","click",(function(t){let s=e.icn3d;e.htmlCls.dialogCls.openDlg("dl_stabilizer_rm","Remove One Stabilizer"),s.pk=1,s.opts.pk="atom",s.pickpair=!0,s.pAtomNum=0})),e.myEventCls.onIds("#"+e.pre+"mn1_thicknessSet","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness","Set Thickness for 3D Printing")})),e.myEventCls.onIds("#"+e.pre+"mn3_setThickness","click",(function(t){e.icn3d,e.htmlCls.dialogCls.openDlg("dl_thickness2","Style Preferences")})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("disulfide bonds",!0),i.showInterCls.showSsbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportSsbondPairs(),s.setLogCmd("export disulfide bond pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_ssbondsNo","click",(function(t){let i=e.icn3d;i.opts.ssbonds="no";s.setLogCmd("set disulfide bonds off",!0),i.lines.ssbond=[],i.setOptionCls.setStyle("sidec","nothing")})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsYes","click",(function(t){let i=e.icn3d;s.setLogCmd("cross linkage",!0),i.showInterCls.showClbonds()})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsExport","click",(function(t){e.icn3d.viewInterPairsCls.exportClbondPairs(),s.setLogCmd("export cross linkage pairs",!1)})),e.myEventCls.onIds("#"+e.pre+"mn6_clbondsNo","click",(function(t){let i=e.icn3d;i.opts.clbonds="no";s.setLogCmd("set cross linkage off",!0),i.lines.clbond=[],i.setOptionCls.setStyle("sidec","nothing")})),$("#"+e.pre+"newvs2").on("submit",(function(){let s=t.saveFileCls.getAtomPDB(t.hAtoms);return $("#"+e.pre+"pdbstr").val(s),!0})),$("#"+e.pre+"fssubmit").on("click",(function(){let e=t.saveFileCls.getAtomPDB(t.hAtoms),s=window.open("","_blank");s.document.body.innerHTML="\n\nLoading Foldseek\n\n\n\n
Foldseek is loading...
\n",$.ajax({url:"https://search.foldseek.com/api/ticket",type:"POST",data:{q:e,database:["afdb50","afdb-swissprot","gmgcl_id","pdb100","afdb-proteome","mgnify_esm30"],mode:"3diaa"},dataType:"text",success:function(e){s.location="https://search.foldseek.com/queue/"+JSON.parse(e).id},error:function(e,t,s){console.log("Error in submitting data to Foldseek...")}})}))}setLogCmd(e,t,s){var i=this.icn3dui,n=i.icn3d;if(""===e.trim())return!1;let l=e.indexOf("|||");-1!==l&&(e=e.substr(0,l));let r={};if(r.factor=n._zoomFactor,r.mouseChange=n.mouseChange,r.quaternion={},r.quaternion._x=parseFloat(n.quaternion._x).toPrecision(5),r.quaternion._y=parseFloat(n.quaternion._y).toPrecision(5),r.quaternion._z=parseFloat(n.quaternion._z).toPrecision(5),r.quaternion._w=parseFloat(n.quaternion._w).toPrecision(5),t&&n.bAddCommands)if(n.STATENUMBER "+n.logs.join("\n> ")+"\n> "),$("#"+i.pre+"logtext")[0]&&$("#"+i.pre+"logtext").scrollTop($("#"+i.pre+"logtext")[0].scrollHeight)}n.setStyleCls.adjustIcon()}}class d{constructor(e){this.icn3dui=e}getLink(e,t,s,i){return this.icn3dui.htmlCls.setHtmlCls.getLink(e,t,s,i)}getMenuText(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuText(e,t,s,i,n)}getMenuUrl(e,t,s,i,n){return this.icn3dui.htmlCls.setHtmlCls.getMenuUrl(e,t,s,i,n)}getMenuSep(){return this.icn3dui.htmlCls.setHtmlCls.getMenuSep()}getLinkWrapper(e,t,s,i,n,l){let r=this.icn3dui;return r.icn3d,r.htmlCls.setHtmlCls.getLinkWrapper(e,t,s,i,n,l)}getLinkWrapper2(e,t,s,i,n){let l=this.icn3dui;return l.icn3d,l.htmlCls.setHtmlCls.getLinkWrapper2(e,t,s,i,n)}getRadio(e,t,s,i,n,l){return this.icn3dui.htmlCls.setHtmlCls.getRadio(e,t,s,i,n,l)}getRadClr(e,t,s,i,n,l,r){return this.icn3dui.htmlCls.setHtmlCls.getRadioColor(e,t,s,i,n,l,r)}setTopMenusHtml(e,t,s){let i=this.icn3dui;if(i.bNode)return"";let n="black"==i.htmlCls.opts.background?i.htmlCls.GREYD:"black",l="";l+="
",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="
",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="
",t+="
",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="
",t+="
",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
',s+="",s+=e.htmlCls.divStr+"dl_command' style='display:none;'>",s+=e.htmlCls.divStr+"dl_setoperations'>",s+=" ",s+=" ",s+="",s+=" ",s+=e.htmlCls.setHtmlCls.setAdvanced(),s+="",s+="",s+=e.htmlCls.setHtmlCls.setAdvanced(2),s+=e.htmlCls.divStr+"dl_vastplus' class='"+n+"' style='max-width:500px'>",s+="Note: VAST+ finds other macromolecular structures that have a similar biological unit. To do this, VAST+ takes into consideration the complete set of 3D domains that VAST identified within a query structure, throughout all of its component protein molecules, and finds other macromolecular structures that have a similar set of proteins/3D domains.
",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpluspdbid' value='6VXX' size=8> ",s+=e.htmlCls.buttonStr+"reload_vastplus'>VAST+",s+="",s+=e.htmlCls.divStr+"dl_vast' class='"+n+"' style='max-width:500px'>",s+="Note: VAST identifies 3D domains (substructures) within each protein structure in the Molecular Modeling Database (MMDB), and then finds other protein structures that have one or more similar 3D domains, using purely geometric criteria. You have two ways to do a VAST search.
",s+="Optione 1, search with your selection (all residues are selected by default) in the loaded structures: ",s+=' ",s+="Optione 2, search with PDB ID and chain name: ",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpdbid' value='4N7N' size=8> ",s+="Chain Name: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastchainid' value='A' size=8> ",s+=e.htmlCls.buttonStr+"reload_vast'>VAST
",s+="Optione 3, search with a PDB file: ",s+=' ",s+="",s+=e.htmlCls.divStr+"dl_foldseek' class='"+n+"' style='max-width:500px'>",s+='1. your selection (all residues are selected by default) in the loaded structures to Foldseek web server.
',s+='2 (Optional). Once you see the structure neighbors, you can view the alignment in iCn3D by inputing a list of PDB chain IDs or AlphaFold UniProt IDs below.
The PDB chain IDs are the same as the record names such as "1HHO_A". The UniProt ID is the text between "AF-" and "-F1". For example, the UniProt ID for the record name "AF-P69905-F1-model_v4" is "P69905".
',s+="Chain ID List: "+e.htmlCls.inputTextStr+"id='"+e.pre+"foldseekchainids' value='P69905,P01942,1HHO_A' size=30> ",s+=e.htmlCls.buttonStr+"reload_foldseek'>Align",s+="",s+=e.htmlCls.divStr+"dl_mmtfid' class='"+n+"'>",s+="MMTF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmtfid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmtf'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbid' class='"+n+"'>",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"pdbid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_pdb'>Load",s+="",s+=e.htmlCls.divStr+"dl_afid' class='"+n+"'>",s+="Note: AlphaFold produces a per-residue confidence score (pLDDT) between 0 and 100: ",s+=e.htmlCls.clickMenuCls.setAlphaFoldLegend()+" ";let o=e.cfg.afid?e.cfg.afid:"A4D1S0";s+="AlphaFold Uniprot ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"afid' value='"+o+"' size=10>
",s+="PAE Map: "+e.htmlCls.buttonStr+"reload_afmap'>Load Half"+e.htmlCls.buttonStr+"reload_afmapfull' style='margin-left:30px'>Load Full (slow)",s+="",s+=e.htmlCls.divStr+"dl_refseqid' class='"+n+"'>",s+="NCBI Protein Accession: "+e.htmlCls.inputTextStr+"id='"+e.pre+"refseqid' value='NP_001743.1' size=8> ",s+=e.htmlCls.buttonStr+"reload_refseq'>Load",s+="",s+=e.htmlCls.divStr+"dl_opmid' class='"+n+"'>",s+="Orientations of Proteins in Membranes(OPM) PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"opmid' value='6JXR' size=8> ",s+=e.htmlCls.buttonStr+"reload_opm'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbfile' class='"+n+"'>",s+='Note: Several PDB files could be concatenated into a single PDB file. Use the line "ENDMDL" to separate PDB files.
The custom JSON file on residue colors has the following format for proteins("ALA" and "ARG") and nucleotides("G" and "A"): ',s+='{"ALA":"#C8C8C8", "ARG":"#145AFF", ..., "G":"#008000", "A":"#6080FF", ...}
',s+="Residue Color File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"rescolorfile' size=8> ",s+=e.htmlCls.buttonStr+"reload_rescolorfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_customcolor' class='"+n+"'>",s+=" ",s+='
The custom file for the structure has two columns separated by space or tab: ',s+='residue number, and score in the range of 0-100. If you click "Apply Custom Color" button, ',s+='the scores 0, 50 and 100 correspond to the three colors specified below. If you click "Apply Custom Tube", ',s+='the selected residues will be displayed in a style similar to "B-factor Tube".
You can define your own reference numbers in a custom file using Excel, and then export it as a CSV file. An example file is shown below with cells separated by commas. ',s+="
",s+="1TUP_C,,,,,,,200,201,230",s+='The first row defines the reference residue numbers, which could be any strings. The 1st cell could be anything. The rest cells are reference residue numbers (e.g., 11, 21, 10C, etc.) or empty cells. Each chain has a separate row. The first cell of the second row is the chain ID "1TUP_A". The rest cells are the corresponding real residue numbers for reference residue numbers in the first row. For example, the reference numbers for residues 100, 101, and 132 in the chain 1TUP_A are 11, 12, and 22, respectively. The fourth row shows another set of reference numners for the chain "1TUP_C". It could be a chain from a different structure.
',s+='To select all residues corresponding to the reference numbers, you can simplay replace ":" with "%" in the Specification. For example, "%12" selects the residue 101 in 1TUP_A and the residue 111 in 1TUP_B. ".A%12" has the chain "A" filter and selects the residue 101 in 1TUP_A. ',s+="
",s+=e.htmlCls.buttonStr+"reload_customreffile'>Apply Custom Reference Numbers",s+="",s+=e.htmlCls.divStr+"dl_align' class='"+n+"'>",s+="Enter the PDB IDs or MMDB IDs of the structures:
",s+="VAST+ based on VAST: "+e.htmlCls.buttonStr+"reload_align_ori'>All Matching Molecules Superposed"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_align_refined'>Invariant Substructure Superposed
",s+="VAST+ based on TM-align: "+e.htmlCls.buttonStr+"reload_align_tmalign'>All Matching Molecules Superposed
",s+="",s+=e.htmlCls.divStr+"dl_alignaf' class='"+n+"'>",s+="Enter two AlphaFold Uniprot IDs:
",s+=e.htmlCls.buttonStr+"reload_alignaf_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_alignaf' style='margin-left:30px'>Align with VAST",s+="",s+=e.htmlCls.divStr+"dl_chainalign' class='"+n+"'>",s+="
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+=e.htmlCls.buttonStr+"reload_chainalign_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_chainalign_asym' style='margin-left:30px'>Align with VAST
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+="The sequence alignment (followed by structure alignemnt) is based on residue numbers in the First/Master chain: "+e.htmlCls.inputTextStr+"id='"+e.pre+"resalignids' value='1,5,10-50' size=50> ",s+=e.htmlCls.buttonStr+"reload_chainalign_asym2' style='margin-top:3px;'>Align by Sequence Alignment
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+='Please specify the mutations with a comma separated mutation list. Each mutation can be specified as "[uppercase PDB ID or AlphaFold UniProt ID]_[Chain Name]_[Residue Number]_[One Letter Mutant Residue]". E.g., the mutation of N501Y in the E chain of PDB 6M0J can be specified as "6M0J_E_501_Y". For AlphaFold structures, the "Chain ID" is "A". If you load a custom structure without PDB or UniProt ID, you can open "Seq. & Annotations" window and find the chain ID such as "stru_A". The part before the underscore is the structure ID, which can be used to specify the mutation such as "stru_A_...". Remember to choose "Show Mutation in: Current Page".
',s+=e.htmlCls.buttonStr+"reload_mutation_3d' title='Show the mutations in 3D using the scap program'>3D with scap",s+=e.htmlCls.buttonStr+"reload_mutation_inter' style='margin-left:20px' title='Show the mutations in 3D and the change of interactions'>Interactions",s+=e.htmlCls.buttonStr+"reload_mutation_pdb' style='margin-left:20px' title='Show the mutations in 3D and export the PDB of the mutant within 10 angstrom'>PDB",s+="
",s+=e.htmlCls.buttonStr+"reload_afmapfile'>Load Half PAE Map"+e.htmlCls.buttonStr+"reload_afmapfilefull' style='margin-left:30px'>Load Full PAE Map (slow)",s+="",s+=e.htmlCls.divStr+"dl_urlfile' class='"+n+"'>",s+="File type: ",s+=" ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"urlfile' size=20> ",s+=e.htmlCls.buttonStr+"reload_urlfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmciffile' class='"+n+"'>",s+="mmCIF File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"mmciffile' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmciffile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmcifid' class='"+n+"'>",s+="mmCIF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmcifid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmcif'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmdbid' class='"+n+"' style='max-width:500px'>",s+="MMDB or PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbid' value='1TUP' size=8>
",s+=e.htmlCls.buttonStr+"reload_mmdb_asym'>Load Asymmetric Unit (All Chains)"+e.htmlCls.buttonStr+"reload_mmdb' style='margin-left:30px'>Load Biological Unit
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_mmdbafid' class='"+n+"' style='max-width:600px'>",s+="List of PDB, MMDB, or AlphaFold UniProt structures: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>
",s+=""+e.htmlCls.buttonStr+"reload_mmdbaf' style='width:150px'>Load Biological Unit"+e.htmlCls.buttonStr+"reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu2' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_blast_rep_id' style='max-width:600px;' class='"+n+"'>",s+="Enter a Sequence ID (or FASTA sequence) and the aligned protein accession, which can be found using the BLAST search with the Sequence ID or FASTA sequence as input. If the protein accession is not a PDB chain, the corresponding AlphaFold UniProt structure is used.
",s+="Sequence ID(NCBI protein accession of a sequence): "+e.htmlCls.inputTextStr+"id='"+e.pre+"query_id' value='NP_001108451.1' size=8> ",s+="or FASTA sequence:
",s+="NCBI protein accession (or a chain of a PDB): "+e.htmlCls.inputTextStr+"id='"+e.pre+"blast_rep_id' value='1TSR_A' size=8> ",s+=e.htmlCls.buttonStr+"reload_blast_rep_id'>Align with BLAST "+e.htmlCls.wifiStr+e.htmlCls.buttonStr+"reload_alignsw' style='margin-left:30px'>Align with Global Smith-Waterman"+e.htmlCls.buttonStr+"reload_alignswlocal' style='margin-left:30px'>Align with Local Smith-Waterman",s+="",s+=e.htmlCls.divStr+"dl_yournote' class='"+n+"'>",s+='Your note will be saved in the HTML file when you click "File > Save File > iCn3D PNG Image".
',s+=" ",s+=e.htmlCls.buttonStr+"applyyournote'>Save",s+="",s+=e.htmlCls.divStr+"dl_gi' class='"+n+"'>",s+="Protein gi: "+e.htmlCls.inputTextStr+"id='"+e.pre+"gi' value='1310960' size=8> ",s+=e.htmlCls.buttonStr+"reload_gi'>Load",s+="",s+=e.htmlCls.divStr+"dl_cid' class='"+n+"'>",s+="PubChem CID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"cid' value='2244' size=8> ",s+=e.htmlCls.buttonStr+"reload_cid'>Load",s+="",s+=e.htmlCls.divStr+"dl_pngimage' class='"+n+"'>",s+="iCn3D PNG image: "+e.htmlCls.inputFileStr+"id='"+e.pre+"pngimage'> ",s+=e.htmlCls.buttonStr+"reload_pngimage' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_state' class='"+n+"'>",s+="State file: "+e.htmlCls.inputFileStr+"id='"+e.pre+"state'> ",s+=e.htmlCls.buttonStr+"reload_state' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_fixedversion' style='max-width:500px' class='"+n+"'>",s+='Since January 6, 2021, you can show the original view with the archived version of iCn3D by pasting your URL below and click "Show Originial View". Note the version in the parameter "v" was used to replace "full.html" with "full_[v].html" in the URL.
',s+="Share Link URL: "+e.htmlCls.inputTextStr+"id='"+e.pre+"sharelinkurl' size=60> ",s+=e.htmlCls.buttonStr+"reload_fixedversion'>Show Original View
",s+=e.htmlCls.buttonStr+"elecmapNo4'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_dsn6url' class='"+n+"'>",s+="Note: Always load a PDB file before loading DSN6 files.
",s+="2fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurl2fofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurl2fofc' style='margin-top: 6px;'>Load
",s+="fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurlfofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurlfofc' style='margin-top: 6px;'>Load
",s+=e.htmlCls.buttonStr+"elecmapNo5'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_clr' class='"+n+"'>",s+="Click in the input box to use the color picker:
",s+=""+e.htmlCls.buttonStr+"applycontactmap'>Display ",s+="",s+=e.htmlCls.divStr+"dl_hbonds' class='"+n+"'>",s+="1. Choose interaction types and their thresholds: ",s+="
"+e.htmlCls.buttonStr+"hbondWindow'>Highlight Interactions in TableSort Interactions on: "+e.htmlCls.buttonStr+"sortSet1'> Set 1"+e.htmlCls.buttonStr+"sortSet2' style='margin-left:20px'>Set 2
",s+="
"+e.htmlCls.buttonStr+"hbondLineGraph'>2D Interaction Network to show interactions between two lines of residue nodes
",s+="
"+e.htmlCls.buttonStr+"hbondScatterplot'>2D Interaction Map to show interactions as map
",r=':
"+e.htmlCls.buttonStr+"hbondGraph'>2D Graph(Force-Directed) to show interactions with strength parameters in 0-200:",s+='
Helix or Sheet'+r+e.pre+'dist_ss" size="4" value="100">
',s+="
Coil or Nucleotide"+r+e.pre+'dist_coil" size="4" value="50">
1. Select sets below or use your current selection.
",s+=" ",s+="
2. "+e.htmlCls.buttonStr+"applyRealignByStruct_tmalign'>Realign with TM-align"+e.htmlCls.buttonStr+"applyRealignByStruct' style='margin-left:30px'>Realign with VAST
",s+="",s+=e.htmlCls.divStr+"dl_realigntwostru' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select sets below or use your current selection: ",s+=" ",s+="2. Overall maximum RMSD: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxrmsd' value='30' size='2'> Å
",s+="
3. "+e.htmlCls.buttonStr+"applyRealignByStruct_vastplus'>VAST+ Alignment based on TM-align
",s+='',s+="",s+=e.htmlCls.divStr+"dl_elecmap2fofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymap2fofc'>Display"+e.htmlCls.buttonStr+"elecmapNo2'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_elecmapfofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymapfofc'>Display"+e.htmlCls.buttonStr+"elecmapNo3'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_emmap' class='"+n+"'>",s+="Contour at: % of maximum EM values "+e.htmlCls.buttonStr+"applyemmap'>Display"+e.htmlCls.buttonStr+"emmapNo2'>Remove EM Map",s+="",s+=e.htmlCls.divStr+"dl_aroundsphere' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select the first set:",s+=" ",s+=e.htmlCls.divNowrapStr+"2. Sphere with a radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"radius_aroundsphere' value='4' size='2'> Å ",s+=e.htmlCls.divNowrapStr+"3. Select the second set to apply the sphere:",s+=" ",s+=e.htmlCls.divNowrapStr+"4. "+e.htmlCls.buttonStr+"applypick_aroundsphere'>Display the sphere around the first set of atoms ",s+="
"+e.htmlCls.buttonStr+"sphereExport'>Save interacting/contacting residue pairs in a file
",s+="",s+=e.htmlCls.divStr+"dl_adjustmem' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Extracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"extra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. intracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"intra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_adjustmem'>Display the adjusted membranes ",s+="",s+=e.htmlCls.divStr+"dl_selectplane' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Z-axis position of the first X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z1' value='15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. Z-axis position of the second X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z2' value='-15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_selectplane'>Save the region between the planes to Defined Sets ",s+="",s+=e.htmlCls.divStr+"dl_addlabel' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor' value='"+"#ffff00' size=4> ",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"4. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'4. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"5. "+e.htmlCls.buttonStr+"applypick_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_addlabelselection' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext2' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize2' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor2' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"4. "+e.htmlCls.buttonStr+"applyselection_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_labelColor' class='"+n+"'>",s+="Color for all labels: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolorall' value='"+"#ffff00' size=4>
",s+=e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"applylabelcolor'>Display",s+="",s+=e.htmlCls.divStr+"dl_distance' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Line Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"distancecolor' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_measuredistance'>Display",s+="",s+=e.htmlCls.divStr+"dl_stabilizer' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"stabilizercolor' value='ffffff' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_stabilizer'>Add",s+="",s+=e.htmlCls.divStr+"dl_disttwosets' class='"+n+"'>",s+=e.htmlCls.spanNowrapStr+"1. Select two sets ",s+="
",s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applydisttable'>Distances in Table",s+="",s+=e.htmlCls.divStr+"dl_stabilizer_rm' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applypick_stabilizer_rm'>Remove",s+="",s+=e.htmlCls.divStr+"dl_thickness' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("3dprint"),s+="",s+=e.htmlCls.divStr+"dl_thickness2' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("style"),s+="",s+=e.htmlCls.divStr+"dl_menupref' class='"+n+"'>",s+="Note: The following parameters will be saved in cache. You just need to set them once.
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref' style='margin-left:30px'>Save Preferences
",s+="
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref2'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref2' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all2' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref2' style='margin-left:30px'>Save Preferences",s+="",s+=e.htmlCls.divStr+"dl_addtrack' class='"+n+"'>",s+=" ",s+=e.htmlCls.divStr+"dl_addtrack_tabs' style='border:0px;'>",s+="
The full protein sequences with gaps are listed one by one. The sequence of the structure is listed at the top. If there are non-gap residues(e.g., from RefSeq) outside of the sequence of the structure, please remove them. Each sequence has a title line starting with \">\".
",s+="FASTA alignment sequences: ",s+="
",s+="Position of the first residue in Sequences & Annotations window: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_startpos' value='1' size=2>
",s+='Track Text (e.g., "2 G, 5-6 RR" defines a character "G" at the position 2 and two continuous characters "RR" at positions from 5 to 6. The starting position is 1): ',s+="
",s+="",s+=e.htmlCls.divStr+"dl_copyurl' style='width:520px;' class='"+n+"'>",s+='Please copy one of the URLs below. They show the same result. (To add a title to share link, click "Windows > Your Note" and click "File > Share Link" again.)
',s+="Original URL with commands:
",s+="Lifelong Short URL:(To replace this URL, send a pull request to update share.html at iCn3D GitHub) "+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url' value='' style='width:100%'>
",s+='Lifelong Short URL + Window Title:(To update the window title, click "Analysis > Your Note/Window Title".) '+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url_title' value='' style='width:100%'>
",s+="",s+='',s+="",s+=e.htmlCls.divStr+"dl_area' class='"+n+"'>",s+="Solvent Accessible Surface Area(SASA) calculated using the EDTSurf algorithm: ",s+='(0-20% out is considered "in". 50-100% out is considered "out".)
Color each residue based on the percentage of solvent accessilbe surface area. The color ranges from blue, to white, to red for a percentage of 0, 35(variable), and 100, respectively.
"+t.htmlCls.space3+t.htmlCls.buttonStr+"command_apply"+s+"'>Save Selection to Defined Sets
",n+="
",n+="
",n+="
",n+='Specification Tips:
',n+=t.htmlCls.divStr+"specguide"+s+"' style='display:none; width:500px' class='icn3d-box'>",n+='Specification: In the selection "$1HHO,4N7N.A,B,C:5-10,LV,3AlaVal,chemicals@CA,C,C*":',n+='
"$1HHO,4N7N" uses "$" to indicate structure selection. ',n+='
".A,B,C" uses "." to indicate chain selection. ',n+='
":5-10,LV,3LeuVal,chemicals" uses the colon ":" to indicate residue selection. Residue selection could be residue number(5-10), one-letter IUPAC residue name abbreviations(LV), three-letter residue names(AlaVal, "3" indicates each residue name has three letters), or predefined names: "proteins", "nucleotides", "chemicals", "ions", and "water". IUPAC abbreviations can be written either as a contiguous string(e.g., ":LV"), in order to find all instances of that sequence in the structure, or they can be separated by commas(e.g., ":L,V") to select all residues of a given type in the structure(in the latter case, select all Leucine and Valine in the structure). ',n+='
"@CA,C,C*" uses "@" to indicate atom name selection. "C*" selects any atom names starting with "C". ',n+='
Partial definition is allowed, e.g., ":1-10" selects all residue IDs 1-10 in all chains. ',n+='
Different selections can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, ":1-10 or :K" selects all residues 1-10 and all Lys residues. ":1-10 and :K" selects all Lys residues in the range of residue number 1-10. ":1-10 or not :K" selects all residues 1-10, which are not Lys residues. ',n+='
The wild card character "X" or "x" can be used to represent any character.',n+="
",n+="Set Operation:",n+='
Users can select multiple sets in the menu "Select > Defined Sets". ',n+='
Different sets can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, if the "Defined Sets" menu has four sets ":1-10", ":11-20", ":5-15", and ":7-8", the command "saved atoms :1-10 or :11-20 and :5-15 not :7-8" unions all residues 1-10 and 11-20 to get the residues 1-20, then intersects with the residues 5-15 to get the residues 5-15, then exclude the residues 7-8 to get the final residues 5-6 and 9-15.
',n+="Full commands in url or command window:",n+="
Select without saving the set: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* ",n+="
Select and save: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* | name my_name
",n+="",n+="
",n+="",n}getOptionHtml(e,t){let s=this.icn3dui;s.icn3d;let i="";for(let n=0,l=e.length;n"+l+"":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.
",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)
",i+="2. Three directional lights: ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6) ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4) ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)
",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection. ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.
",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.
',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".
";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.
":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+=" The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.
",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".
',i+="
"):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="
",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="
",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>
"+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>
"+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>
"+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+" "),a+="Surface with max potential at: kT/e(25.6mV at 298K)
",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>
"+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>
"+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>
"+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),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.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"
Structure
":"",a=Object.keys(i).length>1?"
Chain
":"";n+="
"+o+a+"
Residue
Number
SASA (Å2)
Percent Out
In/Out
";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?"
","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic ",l+="Light green (G, V, S, T, A, N, P, Q): Polar ",l+="Grey: Charged, not hydrophobic
"):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar ",l+="Red: Negatively Charged ",l+="Blue: Positively Charged
");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
",l+=" ",l+=s.parasCls.residueAbbrev[e[0]]+"
",a%4==3&&(l+=" "),++a);l+="
"}else"b factor"==e?(l+="
B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.
",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+" ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+=" ";n+=i.parasCls.atomnames[s.toUpperCase()]+" "}n+=" "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+=" ";r+=o+"
"}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
";for(let e=0,t=r.length;e",s+=" ",s+=t,s+=" ")}return s+=" (Charges are at pH 7)",s+="
',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="",g+=" ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;g
',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+" ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+" ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+=" Links: ClinVar, dbSNP(rs"+i[t][e]+")",e "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+=" Link: dbSNP(rs"+i[t][e]+")"),e ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+=" Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+=" Link: dbSNP(rs"+i[t][e]+")"),e ")}}y>d&&2==e&&(p+="..")}u+="
"}}_=''+m.toString()+" Pos",_+="",_+=" ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
Assembly Tips: Only the asymmetric unit is shown in the sequence window. Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
"+o+"Annotations of "+c+": "+r+""+a+" "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+" ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+" ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append(" "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:
",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
":"2D integration graph for "+R.length+" structure(s) "+R+'. There are three sections: "Interactions", "Common interactions", and "Different interactions". Each section has '+R.length+" graphs.
",s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets
",s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets
",s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t
",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="
",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="
",t+="
",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="
",t+="
",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
',s+="",s+=e.htmlCls.divStr+"dl_command' style='display:none;'>",s+=e.htmlCls.divStr+"dl_setoperations'>",s+=" ",s+=" ",s+="",s+=" ",s+=e.htmlCls.setHtmlCls.setAdvanced(),s+="",s+="",s+=e.htmlCls.setHtmlCls.setAdvanced(2),s+=e.htmlCls.divStr+"dl_vastplus' class='"+n+"' style='max-width:500px'>",s+="Note: VAST+ finds other macromolecular structures that have a similar biological unit. To do this, VAST+ takes into consideration the complete set of 3D domains that VAST identified within a query structure, throughout all of its component protein molecules, and finds other macromolecular structures that have a similar set of proteins/3D domains.
",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpluspdbid' value='6VXX' size=8> ",s+=e.htmlCls.buttonStr+"reload_vastplus'>VAST+",s+="",s+=e.htmlCls.divStr+"dl_vast' class='"+n+"' style='max-width:500px'>",s+="Note: VAST identifies 3D domains (substructures) within each protein structure in the Molecular Modeling Database (MMDB), and then finds other protein structures that have one or more similar 3D domains, using purely geometric criteria. You have two ways to do a VAST search.
",s+="Optione 1, search with your selection (all residues are selected by default) in the loaded structures: ",s+=' ",s+="Optione 2, search with PDB ID and chain name: ",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpdbid' value='4N7N' size=8> ",s+="Chain Name: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastchainid' value='A' size=8> ",s+=e.htmlCls.buttonStr+"reload_vast'>VAST
",s+="Optione 3, search with a PDB file: ",s+=' ",s+="",s+=e.htmlCls.divStr+"dl_foldseek' class='"+n+"' style='max-width:500px'>",s+='1. your selection (all residues are selected by default) in the loaded structures to Foldseek web server.
',s+='2 (Optional). Once you see the structure neighbors, you can view the alignment in iCn3D by inputing a list of PDB chain IDs or AlphaFold UniProt IDs below.
The PDB chain IDs are the same as the record names such as "1HHO_A". The UniProt ID is the text between "AF-" and "-F1". For example, the UniProt ID for the record name "AF-P69905-F1-model_v4" is "P69905".
',s+="Chain ID List: "+e.htmlCls.inputTextStr+"id='"+e.pre+"foldseekchainids' value='P69905,P01942,1HHO_A' size=30> ",s+=e.htmlCls.buttonStr+"reload_foldseek'>Align",s+="",s+=e.htmlCls.divStr+"dl_mmtfid' class='"+n+"'>",s+="MMTF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmtfid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmtf'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbid' class='"+n+"'>",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"pdbid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_pdb'>Load",s+="",s+=e.htmlCls.divStr+"dl_afid' class='"+n+"'>",s+="Note: AlphaFold produces a per-residue confidence score (pLDDT) between 0 and 100: ",s+=e.htmlCls.clickMenuCls.setAlphaFoldLegend()+" ";let o=e.cfg.afid?e.cfg.afid:"A4D1S0";s+="AlphaFold Uniprot ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"afid' value='"+o+"' size=10>
",s+="PAE Map: "+e.htmlCls.buttonStr+"reload_afmap'>Load Half"+e.htmlCls.buttonStr+"reload_afmapfull' style='margin-left:30px'>Load Full (slow)",s+="",s+=e.htmlCls.divStr+"dl_refseqid' class='"+n+"'>",s+="NCBI Protein Accession: "+e.htmlCls.inputTextStr+"id='"+e.pre+"refseqid' value='NP_001743.1' size=8> ",s+=e.htmlCls.buttonStr+"reload_refseq'>Load",s+="",s+=e.htmlCls.divStr+"dl_opmid' class='"+n+"'>",s+="Orientations of Proteins in Membranes(OPM) PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"opmid' value='6JXR' size=8> ",s+=e.htmlCls.buttonStr+"reload_opm'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbfile' class='"+n+"'>",s+='Note: Several PDB files could be concatenated into a single PDB file. Use the line "ENDMDL" to separate PDB files.
The custom JSON file on residue colors has the following format for proteins("ALA" and "ARG") and nucleotides("G" and "A"): ',s+='{"ALA":"#C8C8C8", "ARG":"#145AFF", ..., "G":"#008000", "A":"#6080FF", ...}
',s+="Residue Color File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"rescolorfile' size=8> ",s+=e.htmlCls.buttonStr+"reload_rescolorfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_customcolor' class='"+n+"'>",s+=" ",s+='
The custom file for the structure has two columns separated by space or tab: ',s+='residue number, and score in the range of 0-100. If you click "Apply Custom Color" button, ',s+='the scores 0, 50 and 100 correspond to the three colors specified below. If you click "Apply Custom Tube", ',s+='the selected residues will be displayed in a style similar to "B-factor Tube".
You can define your own reference numbers in a custom file using Excel, and then export it as a CSV file. An example file is shown below with cells separated by commas. ',s+="
",s+="1TUP_C,,,,,,,200,201,230",s+='The first row defines the reference residue numbers, which could be any strings. The 1st cell could be anything. The rest cells are reference residue numbers (e.g., 11, 21, 10C, etc.) or empty cells. Each chain has a separate row. The first cell of the second row is the chain ID "1TUP_A". The rest cells are the corresponding real residue numbers for reference residue numbers in the first row. For example, the reference numbers for residues 100, 101, and 132 in the chain 1TUP_A are 11, 12, and 22, respectively. The fourth row shows another set of reference numners for the chain "1TUP_C". It could be a chain from a different structure.
',s+='To select all residues corresponding to the reference numbers, you can simplay replace ":" with "%" in the Specification. For example, "%12" selects the residue 101 in 1TUP_A and the residue 111 in 1TUP_B. ".A%12" has the chain "A" filter and selects the residue 101 in 1TUP_A. ',s+="
",s+=e.htmlCls.buttonStr+"reload_customreffile'>Apply Custom Reference Numbers",s+="",s+=e.htmlCls.divStr+"dl_align' class='"+n+"'>",s+="Enter the PDB IDs or MMDB IDs of the structures:
",s+="VAST+ based on VAST: "+e.htmlCls.buttonStr+"reload_align_ori'>All Matching Molecules Superposed"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_align_refined'>Invariant Substructure Superposed
",s+="VAST+ based on TM-align: "+e.htmlCls.buttonStr+"reload_align_tmalign'>All Matching Molecules Superposed
",s+="",s+=e.htmlCls.divStr+"dl_alignaf' class='"+n+"'>",s+="Enter two AlphaFold Uniprot IDs:
",s+=e.htmlCls.buttonStr+"reload_alignaf_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_alignaf' style='margin-left:30px'>Align with VAST",s+="",s+=e.htmlCls.divStr+"dl_chainalign' class='"+n+"'>",s+="
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+=e.htmlCls.buttonStr+"reload_chainalign_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_chainalign_asym' style='margin-left:30px'>Align with VAST
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+="The sequence alignment (followed by structure alignemnt) is based on residue numbers in the First/Master chain: "+e.htmlCls.inputTextStr+"id='"+e.pre+"resalignids' value='1,5,10-50' size=50> ",s+=e.htmlCls.buttonStr+"reload_chainalign_asym2' style='margin-top:3px;'>Align by Sequence Alignment
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+='Please specify the mutations with a comma separated mutation list. Each mutation can be specified as "[uppercase PDB ID or AlphaFold UniProt ID]_[Chain Name]_[Residue Number]_[One Letter Mutant Residue]". E.g., the mutation of N501Y in the E chain of PDB 6M0J can be specified as "6M0J_E_501_Y". For AlphaFold structures, the "Chain ID" is "A". If you load a custom structure without PDB or UniProt ID, you can open "Seq. & Annotations" window and find the chain ID such as "stru_A". The part before the underscore is the structure ID, which can be used to specify the mutation such as "stru_A_...". Remember to choose "Show Mutation in: Current Page".
',s+=e.htmlCls.buttonStr+"reload_mutation_3d' title='Show the mutations in 3D using the scap program'>3D with scap",s+=e.htmlCls.buttonStr+"reload_mutation_inter' style='margin-left:20px' title='Show the mutations in 3D and the change of interactions'>Interactions",s+=e.htmlCls.buttonStr+"reload_mutation_pdb' style='margin-left:20px' title='Show the mutations in 3D and export the PDB of the mutant within 10 angstrom'>PDB",s+="
",s+=e.htmlCls.buttonStr+"reload_afmapfile'>Load Half PAE Map"+e.htmlCls.buttonStr+"reload_afmapfilefull' style='margin-left:30px'>Load Full PAE Map (slow)",s+="",s+=e.htmlCls.divStr+"dl_urlfile' class='"+n+"'>",s+="File type: ",s+=" ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"urlfile' size=20> ",s+=e.htmlCls.buttonStr+"reload_urlfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmciffile' class='"+n+"'>",s+="mmCIF File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"mmciffile' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmciffile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmcifid' class='"+n+"'>",s+="mmCIF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmcifid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmcif'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmdbid' class='"+n+"' style='max-width:500px'>",s+="MMDB or PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbid' value='1TUP' size=8>
",s+=e.htmlCls.buttonStr+"reload_mmdb_asym'>Load Asymmetric Unit (All Chains)"+e.htmlCls.buttonStr+"reload_mmdb' style='margin-left:30px'>Load Biological Unit
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_mmdbafid' class='"+n+"' style='max-width:600px'>",s+="List of PDB, MMDB, or AlphaFold UniProt structures: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>
",s+=""+e.htmlCls.buttonStr+"reload_mmdbaf' style='width:150px'>Load Biological Unit"+e.htmlCls.buttonStr+"reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)
",s+="
or
"+e.htmlCls.buttonStr+"reload_mmdbaf_append' style='width:150px'>Append Biological Unit"+e.htmlCls.buttonStr+"reload_mmdbaf_asym_append' style='margin-left:30px; width:250px'>Append Asymmetric Unit (All Chains)
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu2' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_blast_rep_id' style='max-width:600px;' class='"+n+"'>",s+="Enter a Sequence ID (or FASTA sequence) and the aligned protein accession, which can be found using the BLAST search with the Sequence ID or FASTA sequence as input. If the protein accession is not a PDB chain, the corresponding AlphaFold UniProt structure is used.
",s+="Sequence ID(NCBI protein accession of a sequence): "+e.htmlCls.inputTextStr+"id='"+e.pre+"query_id' value='NP_001108451.1' size=8> ",s+="or FASTA sequence:
",s+="NCBI protein accession (or a chain of a PDB): "+e.htmlCls.inputTextStr+"id='"+e.pre+"blast_rep_id' value='1TSR_A' size=8> ",s+=e.htmlCls.buttonStr+"reload_blast_rep_id'>Align with BLAST "+e.htmlCls.wifiStr+e.htmlCls.buttonStr+"reload_alignsw' style='margin-left:30px'>Align with Global Smith-Waterman"+e.htmlCls.buttonStr+"reload_alignswlocal' style='margin-left:30px'>Align with Local Smith-Waterman",s+="",s+=e.htmlCls.divStr+"dl_yournote' class='"+n+"'>",s+='Your note will be saved in the HTML file when you click "File > Save File > iCn3D PNG Image".
',s+=" ",s+=e.htmlCls.buttonStr+"applyyournote'>Save",s+="",s+=e.htmlCls.divStr+"dl_gi' class='"+n+"'>",s+="Protein gi: "+e.htmlCls.inputTextStr+"id='"+e.pre+"gi' value='1310960' size=8> ",s+=e.htmlCls.buttonStr+"reload_gi'>Load",s+="",s+=e.htmlCls.divStr+"dl_cid' class='"+n+"'>",s+="PubChem CID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"cid' value='2244' size=8> ",s+=e.htmlCls.buttonStr+"reload_cid'>Load",s+="",s+=e.htmlCls.divStr+"dl_pngimage' class='"+n+"'>",s+="iCn3D PNG image: "+e.htmlCls.inputFileStr+"id='"+e.pre+"pngimage'> ",s+=e.htmlCls.buttonStr+"reload_pngimage' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_state' class='"+n+"'>",s+="State file: "+e.htmlCls.inputFileStr+"id='"+e.pre+"state'> ",s+=e.htmlCls.buttonStr+"reload_state' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_fixedversion' style='max-width:500px' class='"+n+"'>",s+='Since January 6, 2021, you can show the original view with the archived version of iCn3D by pasting your URL below and click "Show Originial View". Note the version in the parameter "v" was used to replace "full.html" with "full_[v].html" in the URL.
',s+="Share Link URL: "+e.htmlCls.inputTextStr+"id='"+e.pre+"sharelinkurl' size=60> ",s+=e.htmlCls.buttonStr+"reload_fixedversion'>Show Original View
",s+=e.htmlCls.buttonStr+"elecmapNo4'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_dsn6url' class='"+n+"'>",s+="Note: Always load a PDB file before loading DSN6 files.
",s+="2fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurl2fofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurl2fofc' style='margin-top: 6px;'>Load
",s+="fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurlfofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurlfofc' style='margin-top: 6px;'>Load
",s+=e.htmlCls.buttonStr+"elecmapNo5'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_clr' class='"+n+"'>",s+="Click in the input box to use the color picker:
",s+=""+e.htmlCls.buttonStr+"applycontactmap'>Display ",s+="",s+=e.htmlCls.divStr+"dl_hbonds' class='"+n+"'>",s+="1. Choose interaction types and their thresholds: ",s+="
"+e.htmlCls.buttonStr+"hbondWindow'>Highlight Interactions in TableSort Interactions on: "+e.htmlCls.buttonStr+"sortSet1'> Set 1"+e.htmlCls.buttonStr+"sortSet2' style='margin-left:20px'>Set 2
",s+="
"+e.htmlCls.buttonStr+"hbondLineGraph'>2D Interaction Network to show interactions between two lines of residue nodes
",s+="
"+e.htmlCls.buttonStr+"hbondScatterplot'>2D Interaction Map to show interactions as map
",r=':
"+e.htmlCls.buttonStr+"hbondGraph'>2D Graph(Force-Directed) to show interactions with strength parameters in 0-200:",s+='
Helix or Sheet'+r+e.pre+'dist_ss" size="4" value="100">
',s+="
Coil or Nucleotide"+r+e.pre+'dist_coil" size="4" value="50">
1. Select sets below or use your current selection.
",s+=" ",s+="
2. "+e.htmlCls.buttonStr+"applyRealignByStruct_tmalign'>Realign with TM-align"+e.htmlCls.buttonStr+"applyRealignByStruct' style='margin-left:30px'>Realign with VAST
",s+="",s+=e.htmlCls.divStr+"dl_realigntwostru' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select sets below or use your current selection: ",s+=" ",s+="2. Overall maximum RMSD: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxrmsd' value='30' size='2'> Å
",s+="
3. "+e.htmlCls.buttonStr+"applyRealignByStruct_vastplus'>VAST+ Alignment based on TM-align
",s+='',s+="",s+=e.htmlCls.divStr+"dl_elecmap2fofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymap2fofc'>Display"+e.htmlCls.buttonStr+"elecmapNo2'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_elecmapfofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymapfofc'>Display"+e.htmlCls.buttonStr+"elecmapNo3'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_emmap' class='"+n+"'>",s+="Contour at: % of maximum EM values "+e.htmlCls.buttonStr+"applyemmap'>Display"+e.htmlCls.buttonStr+"emmapNo2'>Remove EM Map",s+="",s+=e.htmlCls.divStr+"dl_aroundsphere' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select the first set:",s+=" ",s+=e.htmlCls.divNowrapStr+"2. Sphere with a radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"radius_aroundsphere' value='4' size='2'> Å ",s+=e.htmlCls.divNowrapStr+"3. Select the second set to apply the sphere:",s+=" ",s+=e.htmlCls.divNowrapStr+"4. "+e.htmlCls.buttonStr+"applypick_aroundsphere'>Display the sphere around the first set of atoms ",s+="
"+e.htmlCls.buttonStr+"sphereExport'>Save interacting/contacting residue pairs in a file
",s+="",s+=e.htmlCls.divStr+"dl_adjustmem' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Extracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"extra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. intracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"intra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_adjustmem'>Display the adjusted membranes ",s+="",s+=e.htmlCls.divStr+"dl_selectplane' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Z-axis position of the first X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z1' value='15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. Z-axis position of the second X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z2' value='-15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_selectplane'>Save the region between the planes to Defined Sets ",s+="",s+=e.htmlCls.divStr+"dl_addlabel' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor' value='"+"#ffff00' size=4> ",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"4. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'4. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"5. "+e.htmlCls.buttonStr+"applypick_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_addlabelselection' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext2' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize2' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor2' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"4. "+e.htmlCls.buttonStr+"applyselection_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_labelColor' class='"+n+"'>",s+="Color for all labels: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolorall' value='"+"#ffff00' size=4>
",s+=e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"applylabelcolor'>Display",s+="",s+=e.htmlCls.divStr+"dl_distance' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Line Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"distancecolor' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_measuredistance'>Display",s+="",s+=e.htmlCls.divStr+"dl_stabilizer' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"stabilizercolor' value='ffffff' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_stabilizer'>Add",s+="",s+=e.htmlCls.divStr+"dl_disttwosets' class='"+n+"'>",s+=e.htmlCls.spanNowrapStr+"1. Select two sets ",s+="
",s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applydisttable'>Distances in Table",s+="",s+=e.htmlCls.divStr+"dl_stabilizer_rm' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applypick_stabilizer_rm'>Remove",s+="",s+=e.htmlCls.divStr+"dl_thickness' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("3dprint"),s+="",s+=e.htmlCls.divStr+"dl_thickness2' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("style"),s+="",s+=e.htmlCls.divStr+"dl_menupref' class='"+n+"'>",s+="Note: The following parameters will be saved in cache. You just need to set them once.
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref' style='margin-left:30px'>Save Preferences
",s+="
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref2'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref2' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all2' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref2' style='margin-left:30px'>Save Preferences",s+="",s+=e.htmlCls.divStr+"dl_addtrack' class='"+n+"'>",s+=" ",s+=e.htmlCls.divStr+"dl_addtrack_tabs' style='border:0px;'>",s+="
The full protein sequences with gaps are listed one by one. The sequence of the structure is listed at the top. If there are non-gap residues(e.g., from RefSeq) outside of the sequence of the structure, please remove them. Each sequence has a title line starting with \">\".
",s+="FASTA alignment sequences: ",s+="
",s+="Position of the first residue in Sequences & Annotations window: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_startpos' value='1' size=2>
",s+='Track Text (e.g., "2 G, 5-6 RR" defines a character "G" at the position 2 and two continuous characters "RR" at positions from 5 to 6. The starting position is 1): ',s+="
",s+="",s+=e.htmlCls.divStr+"dl_copyurl' style='width:520px;' class='"+n+"'>",s+='Please copy one of the URLs below. They show the same result. (To add a title to share link, click "Windows > Your Note" and click "File > Share Link" again.)
',s+="Original URL with commands:
",s+="Lifelong Short URL:(To replace this URL, send a pull request to update share.html at iCn3D GitHub) "+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url' value='' style='width:100%'>
",s+='Lifelong Short URL + Window Title:(To update the window title, click "Analysis > Your Note/Window Title".) '+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url_title' value='' style='width:100%'>
",s+="",s+='',s+="",s+=e.htmlCls.divStr+"dl_area' class='"+n+"'>",s+="Solvent Accessible Surface Area(SASA) calculated using the EDTSurf algorithm: ",s+='(0-20% out is considered "in". 50-100% out is considered "out".)
Color each residue based on the percentage of solvent accessilbe surface area. The color ranges from blue, to white, to red for a percentage of 0, 35(variable), and 100, respectively.
"+t.htmlCls.space3+t.htmlCls.buttonStr+"command_apply"+s+"'>Save Selection to Defined Sets
",n+="
",n+="
",n+="
",n+='Specification Tips:
',n+=t.htmlCls.divStr+"specguide"+s+"' style='display:none; width:500px' class='icn3d-box'>",n+='Specification: In the selection "$1HHO,4N7N.A,B,C:5-10,LV,3AlaVal,chemicals@CA,C,C*":',n+='
"$1HHO,4N7N" uses "$" to indicate structure selection. ',n+='
".A,B,C" uses "." to indicate chain selection. ',n+='
":5-10,LV,3LeuVal,chemicals" uses the colon ":" to indicate residue selection. Residue selection could be residue number(5-10), one-letter IUPAC residue name abbreviations(LV), three-letter residue names(AlaVal, "3" indicates each residue name has three letters), or predefined names: "proteins", "nucleotides", "chemicals", "ions", and "water". IUPAC abbreviations can be written either as a contiguous string(e.g., ":LV"), in order to find all instances of that sequence in the structure, or they can be separated by commas(e.g., ":L,V") to select all residues of a given type in the structure(in the latter case, select all Leucine and Valine in the structure). ',n+='
"@CA,C,C*" uses "@" to indicate atom name selection. "C*" selects any atom names starting with "C". ',n+='
Partial definition is allowed, e.g., ":1-10" selects all residue IDs 1-10 in all chains. ',n+='
Different selections can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, ":1-10 or :K" selects all residues 1-10 and all Lys residues. ":1-10 and :K" selects all Lys residues in the range of residue number 1-10. ":1-10 or not :K" selects all residues 1-10, which are not Lys residues. ',n+='
The wild card character "X" or "x" can be used to represent any character.',n+="
",n+="Set Operation:",n+='
Users can select multiple sets in the menu "Select > Defined Sets". ',n+='
Different sets can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, if the "Defined Sets" menu has four sets ":1-10", ":11-20", ":5-15", and ":7-8", the command "saved atoms :1-10 or :11-20 and :5-15 not :7-8" unions all residues 1-10 and 11-20 to get the residues 1-20, then intersects with the residues 5-15 to get the residues 5-15, then exclude the residues 7-8 to get the final residues 5-6 and 9-15.
',n+="Full commands in url or command window:",n+="
Select without saving the set: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* ",n+="
Select and save: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* | name my_name
",n+="",n+="
",n+="",n}getOptionHtml(e,t){let s=this.icn3dui;s.icn3d;let i="";for(let n=0,l=e.length;n"+l+"":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.
",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)
",i+="2. Three directional lights: ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6) ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4) ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)
",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection. ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.
",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.
',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".
";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.
":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+=" The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.
",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".
',i+="
"):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="
",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="
",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>
"+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>
"+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>
"+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+" "),a+="Surface with max potential at: kT/e(25.6mV at 298K)
",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>
"+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>
"+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>
"+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i>2))+i+((2&t)>>1))*c+n+(1&t)]&this.ISDONE)<=3&&(t.push(t[i]),i=t.length-1,t.push(t[n]),n=t.length-1,t.push(t[l]),l=t.length-1),s.push(i),s.push(n),s.push(l)}}},Xe.prototype.laplacianSmooth=function(e,t,s){let i,n,l,r,o,a=new Array(t.length);for(i=0,n=t.length;ithis.origextent[1][0])&&(!(tthis.origextent[1][1])&&!(sthis.origextent[1][2]))},Ke.prototype.getFacesAndVertices=function(){let e,t,s=this.verts;for(e=0,t=s.length;eh&&(h=this.pmaxy-this.pminy),this.pmaxz-this.pminz>h&&(h=this.pmaxz-this.pminz),this.scaleFactor=(c-1)/h,this.scaleFactor=this.defaultScaleFactor,(this.bCalcArea||this.defaultScaleFactor*h>this.threshbox)&&(c=Math.floor(this.threshbox),this.scaleFactor=(this.threshbox-1)/h),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.finalScaleFactor.x=(this.pLength-1)/(this.pmaxx-this.pminx),this.finalScaleFactor.y=(this.pWidth-1)/(this.pmaxy-this.pminy),this.finalScaleFactor.z=(this.pHeight-1)/(this.pmaxz-this.pminz),this.boundingatom(t),this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpDistance=new Float64Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Int32Array(this.pLength*this.pWidth*this.pHeight),this.vpColor=[],this.vpPot=[]},Ke.prototype.boundingatom=function(e){let t,s,i,n,l=[];for(let r in this.vdwRadii){if(!this.vdwRadii.hasOwnProperty(r))continue;let o=this.vdwRadii[r];l[r]=e?(o+this.probeRadius)*this.scaleFactor+.5:o*this.scaleFactor+.5,i=l[r]*l[r],this.widxz[r]=Math.floor(l[r])+1,this.depty[r]=new Int32Array(this.widxz[r]*this.widxz[r]),n=0;for(let e=0;ei?this.depty[r][n]=-1:(s=Math.sqrt(i-t),this.depty[r][n]=Math.floor(s)),n++}},Ke.prototype.fillvoxels=function(e,t){let s,i,n,l;for(s=0,l=this.vpBits.length;sc&&(a=c),C>h&&(C=h),v>p&&(v=p);let w,_=g[o*m+d*u+y],S=g[a*m+d*u+y],A=g[o*m+C*u+y],x=g[o*m+d*u+v],k=g[a*m+C*u+y],O=g[o*m+C*u+v],R=g[a*m+d*u+v],E=g[a*m+C*u+v],I=r.x-o,T=r.y-d,M=r.z-y,P=((_*(1-I)+S*I)*(1-T)+(A*(1-I)+k*I)*T)*(1-M)+((x*(1-I)+R*I)*(1-T)+(O*(1-I)+E*I)*T)*M,D=s*f+i*b+n;this.vpPot[D]=P,P>this.isovalue&&(P=this.isovalue),P<-this.isovalue&&(P=-this.isovalue),P>0?(P/=1*this.isovalue,w=new THREE.Color(1-P,1-P,1)):(P/=-1*this.isovalue,w=new THREE.Color(1,1-P,1-P)),this.vpColor[D]=w}}for(s=0,l=this.vpBits.length;s=this.pLength||g>=this.pWidth||f>=this.pHeight)continue;let h=u*S+g*this.pHeight+f;if(this.vpBits[h]&this.INOUT){let p=t[this.vpAtomID[h]];p.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(p.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(p.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(p.z+this.ptranz)),a*a+d*d+c*c=this.pLength||p>=this.pWidth||m>=this.pHeight)continue;let u=h*S+p*this.pHeight+m;if(this.vpBits[u]&this.ISDONE){let h=t[this.vpAtomID[u]];h.serial!=e.serial&&(l=s+a-Math.floor(.5+this.scaleFactor*(h.x+this.ptranx)),r=i+d-Math.floor(.5+this.scaleFactor*(h.y+this.ptrany)),o=n+c-Math.floor(.5+this.scaleFactor*(h.z+this.ptranz)),a*a+d*d+c*c-1&&r-1&&a-1&&o=h)||(this.vpBits[n]|=this.ISBOUND))},Ke.prototype.fastoneshell=function(e,t){let s,i,n,l,r,o,a,d,c,h,p,m,u=[];if(0===e.length)return u;let g={ix:-1,iy:-1,iz:-1},f=this.pWidth*this.pHeight;for(a=0,c=e.length;a-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,h-1&&g.iy-1&&g.iz-1&&(m=g.ix*f+this.pHeight*g.iy+g.iz,this.vpBits[m]&this.INOUT&&!(this.vpBits[m]&this.ISDONE)?(t.set(g.ix,g.iy,n+this.nb[d][2],p),l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,this.vpDistance[m]=h,this.vpBits[m]|=this.ISDONE,this.vpBits[m]|=this.ISBOUND,u.push({ix:g.ix,iy:g.iy,iz:g.iz})):this.vpBits[m]&this.INOUT&&this.vpBits[m]&this.ISDONE&&(l=g.ix-p.ix,r=g.iy-p.iy,o=g.iz-p.iz,h=l*l+r*r+o*o,hm&&(m=this.pmaxy-this.pminy),this.pmaxz-this.pminz>m&&(m=this.pmaxz-this.pminz),this.scaleFactor=1,this.pLength=Math.floor(.5+this.scaleFactor*(this.pmaxx-this.pminx))+1,this.pWidth=Math.floor(.5+this.scaleFactor*(this.pmaxy-this.pminy))+1,this.pHeight=Math.floor(.5+this.scaleFactor*(this.pmaxz-this.pminz))+1,this.cutRadius=this.probeRadius*this.scaleFactor,this.vpBits=new Uint8Array(this.pLength*this.pWidth*this.pHeight),this.vpAtomID=new Uint8Array(this.pLength*this.pWidth*this.pHeight)},Qe.prototype.transformMemPro=function(e,t,s,i){let n=e.clone();n.sub(s);let l=n.x*t[0]+n.y*t[1]+n.z*t[2]+i.x,r=n.x*t[3]+n.y*t[4]+n.z*t[5]+i.y,o=n.x*t[6]+n.y*t[7]+n.z*t[8]+i.z;return n.x=l,n.y=r,n.z=o,n},Qe.prototype.fillvoxels=function(e,t){let s,i,n,l,r,o;for(s=0,l=this.vpBits.length;sthis.pLength&&(o=this.pLength),p>this.pWidth&&(p=this.pWidth),b>this.pHeight&&(b=this.pHeight);let C,y=l[r*a+h*d+f],v=l[o*a+h*d+f],w=l[r*a+p*d+f],_=l[r*a+h*d+b],S=l[o*a+p*d+f],A=l[r*a+p*d+b],x=l[o*a+h*d+b],k=l[o*a+p*d+b],O=n.x-r,R=n.y-h,E=n.z-f,I=((y*(1-O)+v*O)*(1-R)+(w*(1-O)+S*O)*R)*(1-E)+((_*(1-O)+x*O)*(1-R)+(A*(1-O)+k*O)*R)*E;I>this.isovalue&&(I=this.isovalue),I<-this.isovalue&&(I=-this.isovalue),I>0?(I/=1*this.isovalue,C=new THREE.Color(1-I,1-I,1)):(I/=-1*this.isovalue,C=new THREE.Color(1,1-I,1-I)),this.icn3d.atoms[t[s]].color=C,this.icn3d.atomPrevColors[t[s]]=C}}else{for(let p in t){let f,b=e[t[p]];if("DUM"!==b.resn){if(void 0!==this.rmsd_supr&&void 0!==this.rmsd_supr.rot){f=this.transformMemPro(b.coord,g,u,m).applyMatrix4(c)}else f=b.coord.clone().applyMatrix4(c);for(s=Math.floor(f.x)-this.maxdist,l=Math.ceil(f.x)+this.maxdist;s<=l;++s)if(!(s<0||s>this.header.xExtent*this.scaleFactor-1))for(i=Math.floor(f.y)-this.maxdist,r=Math.ceil(f.y)+this.maxdist;i<=r;++i)if(!(i<0||i>this.header.yExtent*this.scaleFactor-1))for(n=Math.floor(f.z)-this.maxdist,o=Math.ceil(f.z)+this.maxdist;n<=o;++n){if(n<0||n>this.header.zExtent*this.scaleFactor-1)continue;let e=s*a+i*d+n;h.push(e)}}}for(s=0,l=h.length;s=this.isovalue?1:0:"fofc"==this.type?(this.vpBits[e]=this.dataArray[e]>=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[e]=this.dataArray[e]>=0?1:0):"em"==this.type&&(this.vpBits[e]=this.dataArray[e]>=this.isovalue?1:0)}}}else for(s=0;s=this.isovalue||this.dataArray[e]<=-this.isovalue?1:0,this.vpAtomID[t]=this.dataArray[e]>=0?1:0)}for(s=0,l=this.vpBits.length;s-1&&r-1&&a-1&&o1?"
Structure
":"",a=Object.keys(i).length>1?"
Chain
":"";n+="
"+o+a+"
Residue
Number
SASA (Å2)
Percent Out
In/Out
";for(let e in l.resid2area){let d=e.lastIndexOf("_"),c=e.substr(d+1),h=r.utilsCls.getIdArray(e.substr(0,d));o=Object.keys(s).length>1?"
","normalized hydrophobic"==e?(l+="Dark green (W, F, Y, L, I, C, M): Hydrophobic ",l+="Light green (G, V, S, T, A, N, P, Q): Polar ",l+="Grey: Charged, not hydrophobic
"):(l+="Green (W, F, Y, L, I, C, M): Hydrophobic ",l+="Yellow (G, V, S, T, A, N, P, Q): Polar ",l+="Red: Negatively Charged ",l+="Blue: Positively Charged
");let a=0;for(let e of o)s.parasCls.residueAbbrev[e[0]]&&(l+="
",l+=" ",l+=s.parasCls.residueAbbrev[e[0]]+"
",a%4==3&&(l+=" "),++a);l+="
"}else"b factor"==e?(l+="
B factor quantitates the uncertainty for each atom. A high B factor reflects that the position is less certain.
",l+=s.htmlCls.clickMenuCls.setLegendHtml()):"confidence"==e?l+=s.htmlCls.clickMenuCls.setLegendHtml(!0):(l="",i=!0);$("#"+s.pre+"dl_legend").html(l),s.htmlCls.dialogCls.openDlg("dl_legend","Color Legend"),i&&window.dialog&&window.dialog.dialog("close")}getColorLegendForElem(e,t){let s=this.icn3d,i=s.icn3dui,n="",l={};for(let e in t){let t=s.atoms[e],i=void 0===t||void 0===t.color||"FFFFFF"===t.color.getHexString().toUpperCase()?"DDDDDD":t.color.getHexString();void 0===l[t.elem]&&(l[t.elem]={}),l[t.elem][i]=1}if(Object.keys(l).length>0){n+=""+e+" ";let t=Object.keys(l).sort();for(let e=0,s=t.length;e";for(let e in l[s])n+=" ";n+=i.parasCls.atomnames[s.toUpperCase()]+" "}n+=" "}return n}getRes2color(e,t){let s=this.icn3d,i=s.icn3dui,n={},l=s.firstAtomObjCls.getResiduesFromAtoms(e);for(let e in l){let l=s.residues[e],r=s.firstAtomObjCls.getFirstAtomObj(l),o=t?r.resn:i.parasCls.residueAbbrev[r.resn],a=void 0===r||void 0===r.color||"FFFFFF"===r.color.getHexString().toUpperCase()?"DDDDDD":r.color.getHexString();null!=o&&(void 0===n[o]&&(n[o]={}),n[o][a]=1)}return n}getColorLegendForResidue(e){this.icn3d.icn3dui;let t="",s=this.getRes2color(e);if(Object.keys(s).length>0){t+="
";let e=Object.keys(s).sort(),i="",n=0;for(let l=0,r=e.length;l";for(let e in s[o])r+=" ";r+=o+"
",n%4==3&&(r+=" "),-1!=o.indexOf("(")?(t+=r,++n):i+=r}i&&(t+=" "+i),t+=""}return t}getColorLegendForCharge(e){let t=this.icn3d;t.icn3dui;let s="",i=t.firstAtomObjCls.getResiduesFromAtoms(e),n={};for(let e in i){let s=t.residues[e],i=t.firstAtomObjCls.getFirstAtomObj(s);"ARG"==i.resn||"LYS"==i.resn?n.Positive=1:"HIS"==i.resn?n["Partial-Positive"]=1:"ASP"==i.resn||"GLU"==i.resn||t.nucleotides[i.serial]?n.Negative=1:n.Neutral=1}const l={Positive:"0000ff","Partial-Positive":"8080ff",Negative:"ff0000",Neutral:"888888"};let r=["Positive","Partial-Positive","Negative","Neutral"];s+="
";for(let e=0,t=r.length;e",s+=" ",s+=t,s+=" ")}return s+=" (Charges are at pH 7)",s+="
',b+=o,y+=v)}else h+="-";g=' '+t.toString()+" Residues",g+="",g+=" ",h+=g,p+=g}h+="",p+="",m+="",$("#"+i.pre+"dt_site_"+c).html(h),$("#"+i.pre+"ov_site_"+c).html(p),$("#"+i.pre+"tt_site_"+c).html(m)}}for(let e in i.protein_chainid)r.hasOwnProperty(e)||($("#"+i.pre+"dt_cdd_"+e).html(""),$("#"+i.pre+"ov_cdd_"+e).html(""),$("#"+i.pre+"tt_cdd_"+e).html(""),$("#"+i.pre+"dt_site_"+e).html(""),$("#"+i.pre+"ov_site_"+e).html(""),$("#"+i.pre+"tt_site_"+e).html(""));i.showAnnoCls.enableHlSeq(),i.bAjaxCddSite=!0}getNoCdd(e){let t=this.icn3d;t.icn3dui,console.log("No CDD data were found for the protein "+e+"...");for(let e in t.protein_chainid)$("#"+t.pre+"dt_cdd_"+e).html(""),$("#"+t.pre+"ov_cdd_"+e).html(""),$("#"+t.pre+"tt_cdd_"+e).html(""),$("#"+t.pre+"dt_site_"+e).html(""),$("#"+t.pre+"ov_site_"+e).html(""),$("#"+t.pre+"tt_site_"+e).html("");t.showAnnoCls.enableHlSeq(),t.bAjaxCddSite=!0}setDomainFeature(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d,h=c.icn3dui;s&&(r={},o={},a={},d={});let p=void 0!==e?e.length:0,m=s?14:19,u=s?100:120;for(let g=0;g
',a=o,d=o,c=0;for(let t in s.chainname2residues[e]){let n=s.chainname2residues[e][t];if(!n)continue;let l="Interact ."+t;l.length>17&&(l=l.substr(0,17)+"...");let r="Interact ."+t,h=[];for(let e=0,t=n.length;e'+l+"
",y=s[t].length,v=0,_=0;if(2==e&&(v=0,_=y),m){d=1;let r=0;for(let e=v;e0?_+="; ":0!==e&&1!==e||(O='disease="'+v[t]+'"'),_+=v[t]+"("+w[t]+")",++S;""!=_&&(r"+s[t][e],u+=": "+_,C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(m,"snpin3d","3D with scap","SNP in 3D with scap",70,g)+" ",u+=f.showAnnoCls.addSnpButton(m,"snpinter","Interactions","SNP Interactions in 3D",70,g)+" ",u+=f.showAnnoCls.addSnpButton(m,"snppdb","PDB","Download SNP PDB",35,g)),u+=" Links: ClinVar, dbSNP(rs"+i[t][e]+")",e "),++r)}r>d&&2==e&&(p+="..")}else{d=1;for(let e=v;e"+s[t][e],g)C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),0!=i[t][e]&&(u+=" Link: dbSNP(rs"+i[t][e]+")"),e ");else{let s=l[t][e].split("; "),a=o[t][e].split("; "),d="",c=0;for(let t=0,i=s.length;t0?d+="; ":0!==e&&1!==e||(O='disease="'+s[t]+'"'),d+=s[t]+"("+a[t]+")",++c;""!=d?(u+=": "+d,C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+=" Links: ClinVar, dbSNP(rs"+i[t][e]+")"):(C&&!b.cfg.hidelicense&&(u+=" "+f.showAnnoCls.addSnpButton(r,"snpin3d","3D with scap","SNP in 3D with scap",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snpinter","Interactions","SNP Interactions in 3D",70,m)+" ",u+=f.showAnnoCls.addSnpButton(r,"snppdb","PDB","Download SNP PDB",35,m)),u+=" Link: dbSNP(rs"+i[t][e]+")"),e ")}}y>d&&2==e&&(p+="..")}u+="
"}}_=''+m.toString()+" Pos",_+="",_+=" ",_+="",f+=_,b+=v+_,C+="",$("#"+c.pre+"dt_custom_"+e+"_"+u).html(f),$("#"+c.pre+"ov_custom_"+e+"_"+u).html(b),$("#"+c.pre+"tt_custom_"+e+"_"+u).html(C)}alignSequenceToStructure(e,t,s){let i,n,l,r=this.icn3d,o=r.icn3dui;void 0!==t.data&&(i=t.data[0].query,l=Object.keys(t.data[0].targets)[0],n=t.data[0].targets[l],n=n.hsps[0]);let a="",d=[],c={};if(void 0!==i&&void 0!==n){let h=n.scores.e_value.toPrecision(2);h>1e-200&&(h=parseFloat(h).toExponential()),n.scores.bit_score;let p=t.targets[l].seqdata,m=i.seqdata,u=n.segs;for(let e=0,t=u.length;e0&&(l=n+"H"+d+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_H"+d,r[p]=1,i.ssend&&(h=e+"_C(H"+d,"helix"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):"E"==m?(i.ssbegin&&(++c,Object.keys(r).length>0&&(l=n+"S"+c+")","coil"==t&&(s.selectionCls.selectResidueList(r,l,l,o,a),o||(o=!0)),r={})),n=e+"_S"+c,r[p]=1,i.ssend&&(h=e+"_C(S"+c,"sheet"==t&&(s.selectionCls.selectResidueList(r,n,n,o,a),o||(o=!0)),r={})):(n=h+"-",r[p]=1)}}Object.keys(r).length>0&&(l=n+"Cterm)","coil"==t&&s.selectionCls.selectResidueList(r,l,l,o,a))}simplifyText(e){this.icn3d.icn3dui;let t,s,i="",n=!1,l=-1;for(t=0,s=(e=e.replace(/undefined/g," ")).length;t20)return!1;if(void 0!==o.giSeq&&void 0!==o.giSeq[e]){let r=this.getFullText(s);return s=r.text,this.showNewTrack(e,t,s,void 0,void 0,i,n,l),!1}setTimeout((function(){a.checkGiSeq(e,t,s,i,n,l,r+1)}),100)}getFullText(e){this.icn3d.icn3dui;let t="",s=[],i=[],n=e.split(","),l=-1;for(let e=0,r=n.length;ep?t+=c.substr(0,p):t+=c;for(let e=0;e0&&($("#"+e.pre+"anno_cdd")[0].checked?(this.setAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("set annotation cdd",!0)):(this.hideAnnoTabCdd(),t.htmlCls.clickMenuCls.setLogCmd("hide annotation cdd",!0)))}showAnnoSelectedChains(){let e=this.icn3d,t=e.icn3dui,s={};for(let t in e.hAtoms){let i=e.atoms[t];s[i.structure+"_"+i.chain]=1}$("#"+e.pre+"dl_annotations > .icn3d-annotation").hide();for(let i in s){$("#"+e.pre+"anno_"+i).length&&$("#"+e.pre+"anno_"+i).show();let s=e.firstAtomObjCls.getFirstCalphaAtomObj(e.chains[i]);if(void 0!==s.resn){let i=t.utilsCls.residueName2Abbr(s.resn.substr(0,3));$("#"+e.pre+"anno_"+i).show()}}}showAnnoAllChains(){let e=this.icn3d;e.icn3dui,$("#"+e.pre+"dl_annotations > .icn3d-annotation").show()}setAnnoView(e){let t=this.icn3d;t.icn3dui.bNode||("detailed view"===e?(t.view="detailed view",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",1)):(t.view="overview",$("#"+t.pre+"dl_anno_view_tabs").tabs("option","active",0)))}setAnnoDisplay(e,t){let s=this.icn3d;s.icn3dui;let i=["giseq","custom","site","ptm","snp","clinvar","cdd","domain","interaction","ssbond","crosslink","transmem"];for(let n in i){let l=i[n];$("[id^="+s.pre+t+"_"+l+"]").attr("style",e)}}showFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:block;","tt")}hideFixedTitle(){this.icn3d.icn3dui;this.setAnnoDisplay("display:none!important;","tt")}setAnnoViewAndDisplay(e){let t=this.icn3d;if(t.icn3dui,"detailed view"===e){this.setAnnoView("detailed view");let e="display:block;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:none;",this.setAnnoDisplay(e,"ov")}else{this.setAnnoView("overview"),this.hideFixedTitle();let e="display:none;";this.setAnnoDisplay(e,"dt"),$("#"+t.pre+"seqguide_wrapper").attr("style",e),e="display:block;",this.setAnnoDisplay(e,"ov")}}async updateClinvar(){let e=this.icn3d;if(e.icn3dui,void 0===e.bClinvarShown||!e.bClinvarShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showClinvar(t,s)}e.bClinvarShown=!0}async updateSnp(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSnpShown||!e.bSnpShown)for(let t in e.protein_chainid){let s=e.protein_chainid[t];await e.annoSnpClinVarCls.showSnp(t,s)}e.bSnpShown=!0}updateDomain(){let e=this.icn3d;e.icn3dui,void 0!==e.bDomainShown&&e.bDomainShown||e.annoDomainCls.showDomainAll(),e.bDomainShown=!0}updateInteraction(){let e=this.icn3d;if(e.icn3dui,void 0===e.bInteractionShown||!e.bInteractionShown)for(let t in e.interactChainbase){let s=e.interactChainbase[t];e.annoContactCls.showInteraction(t,s)}e.bInteractionShown=!0}async updatePTM(){let e=this.icn3d;if(e.icn3dui,void 0===e.bPTMShown||!e.bPTMShown)for(let t in e.PTMChainbase){let s=e.PTMChainbase[t];await e.annoPTMCls.showPTM(t,s,"ptm")}e.bPTMShown=!0}updateSsbond(){let e=this.icn3d;if(e.icn3dui,void 0===e.bSSbondShown||!e.bSSbondShown)for(let t in e.ssbondChainbase){let s=e.ssbondChainbase[t];e.annoSsbondCls.showSsbond(t,s)}e.bSSbondShown=!0}updateCrosslink(){let e=this.icn3d;if(e.icn3dui,void 0===e.bCrosslinkShown||!e.bCrosslinkShown)for(let t in e.crosslinkChainbase){let s=e.crosslinkChainbase[t];e.annoCrossLinkCls.showCrosslink(t,s)}e.bCrosslinkShown=!0}async updateTransmem(){let e=this.icn3d,t=e.icn3dui;if(void 0===e.bTranememShown||!e.bTranememShown)for(let s in e.protein_chainid){let i=e.protein_chainid[s];if(void 0!==t.cfg.opmid)e.annoTransMemCls.showTransmem(s,i);else if(e.bAfMem&&e.afmem_start_end){let t=e.afmem_start_end[0],n=e.afmem_start_end[1];await e.annoPTMCls.showPTM(s,i,"afmem",t,n)}else await e.annoPTMCls.showPTM(s,i,"transmem")}e.bTranememShown=!0}}class It{constructor(e){this.icn3d=e}showAnnotations_part1(){let e=this.icn3d,t=e.icn3dui;if(t.htmlCls.dialogCls.openDlg("dl_selectannotations","Sequences and Annotations"),(void 0===e.bAssemblyNote||!e.bAssemblyNote)&&void 0!==e.asuCnt){let t="
Assembly Tips: Only the asymmetric unit is shown in the sequence window. Click \"Assembly\" in the menu \"View\" to switch between asymmetric unit and biological assembly("+e.asuCnt+" asymmetric unit).
"+o+"Annotations of "+c+": "+r+""+a+" "+this.addButton(s,"icn3d-addtrack","Add Track","Add a custom track",60,i)+" ";h+=this.addButton(s,"icn3d-customcolor","Custom Color/Tube","Use a custom file to define the colors or tubes in 3D structure",110,i)+" ",h+=this.addButton(s,"icn3d-helixsets","Helix Sets",'Define sets for each helix in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-sheetsets","Sheet Sets",'Define sets for each sheet in this chain and add them to the menu of "Defined Sets"',60,i)+" "+this.addButton(s,"icn3d-coilsets","Coil Sets",'Define sets for each coil in this chain and add them to the menu of "Defined Sets"',60,i),$("#"+e.pre+"dl_annotations").append(h);let p=["giseq","cdd","clinvar","snp","site","ptm","ssbond","crosslink","transmem","domain","custom","interaction"];for(let t in p){let i=p[t];$("#"+e.pre+"anno_"+s).append(this.getAnDiv(s,i))}$("#"+e.pre+"anno_"+s).append(" "),++n}if(t.bNode||e.annoCddSiteCls.setToolTip(),void 0!==e.chainid_seq)await this.processSeqData(e.chainid_seq);else try{let n=[],l=[];for(let e=0,t=i.length;e=6?l.push(i[e]):n.push(i[e]);if(n.length>0){let s=t.htmlCls.baseUrl+"/vastdyn/vastdyn.cgi?chainlist="+n;e.chainid_seq=await t.getAjaxPromise(s,"jsonp")}else e.chainid_seq={};for(let t=0,s=l.length;t40&&(r=r.substr(0,40)+"...");let o="";0==i&&("protein"==s?o="Proteins:
",h+=c,p+=c,$("#"+n.pre+"dt_giseq_"+e).html(h),$("#"+n.pre+"ov_giseq_"+e).html(p)}async processSeqData(e){let t=this.icn3d,s=t.icn3dui;for(let i in t.protein_chainid){let n=t.protein_chainid[i];if(e.hasOwnProperty(n)){let s=e[n];t.giSeq[i]=s;let l="";for(let e=0;e<10&&e14?"Query: "+o.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+o:"Query: gi "+o;let a="cannot be aligned";t.queryStart="",t.queryEnd="",t.bRender&&alert("The sequence can NOT be aligned to the structure"),t.showSeqCls.showSeq(i,n,void 0,e,l,a,r)}else if(s.cfg.blast_rep_id==i&&(void 0!==t.seqStructAlignData||void 0!==t.seqStructAlignDataSmithwm)){let e,l,r,o,a,d=s.cfg.oriQuery_id?s.cfg.oriQuery_id:s.cfg.query_id;if(e=d.length>14?"Query: "+d.substr(0,6)+"...":isNaN(s.cfg.query_id)?"Query: "+d:"Query: gi "+d,void 0!==t.seqStructAlignData){let e,s,i=t.seqStructAlignData;if(void 0!==i.data){e=i.data[0].query;let t=Object.keys(i.data[0].targets);s=i.data[0].targets[t[0]],s=void 0!==s&&s.hsps.length>0?s.hsps[0]:void 0}if(void 0!==e&&void 0!==s){l=s.scores.e_value.toPrecision(2),l>1e-200&&(l=parseFloat(l).toExponential()),s.scores.bit_score;let t=Object.keys(i.targets);r=i.targets[t[0]].seqdata,o=e.seqdata,a=s.segs}}else{let e=t.seqStructAlignDataSmithwm;l=e.score,r=e.target.replace(/-/g,""),o=e.query.replace(/-/g,""),a=[];let s=-1,i=-1,n=!1,d={};for(let t=0,l=e.target.length;t0)if(i.orifrom-ni.from-l)for(let t=n+1;t
":"2D integration graph for "+R.length+" structure(s) "+R+'. There are three sections: "Interactions", "Common interactions", and "Different interactions". Each section has '+R.length+" graphs.
",s+=""}else if(t){let e,t,l,c,h=p[0],m=o.length,u=a.length,g=1,f=3*g,b=7*g,C=30;t=(m+2)*(f+b)+2*10+C,e=(u+2)*(f+b)+2*10+C,i.scatterplotWidth=2*e,c=i.scatterplotWidth,l=n.scatterplotid,s=r.length>0?"":"No interactions found for these two sets
",s+=""}else{let e=p[0],t=o.length,l=a.length,c=1,h=3*c,m=7*c,u=110,g=10,f=t>l?t*(h+m)+2*g:l*(h+m)+2*g;i.linegraphWidth=2*f,s=r.length>0?"":"No interactions found for these two sets
",s+=""}return i.lineGraphStr+="}\n",i.scatterplotStr=i.lineGraphStr,t?$("#"+i.pre+"scatterplotDiv").html(s):$("#"+i.pre+"linegraphDiv").html(s),s}drawGraphPerType(e,t,s,i,n,l,r,o,a,d,c,h,p,m){let u=this.icn3d;u.icn3dui;let g,f,b="",C=2==t.length&&"2"==t[1].replace(t[0],"");0==e?(g="Interactions in ",f=""):1==e?(g="Common interactions in ",f="_common"):2==e&&(g="Different interactions in ",f="_diff");for(let y=0,v=t.length;y0&&(u.lineGraphStr+=", \n"):u.lineGraphStr+=", \n",u.lineGraphStr+=u.getGraphCls.updateGraphJson(t[y],y+f,i[y],n[y],l[y])}return{heightFinal:o,html:b}}getIdArrayFromNode(e){let t=this.icn3d.icn3dui,s=[];s.push(""),s.push("");let i=e.r.substr(4);return s=s.concat(t.utilsCls.getIdArray(i)),s}drawLineGraph_base(e,t,s,i,n,l,r){let o,a,d=this.icn3d,c=d.icn3dui,h="",p=e.length,m=t.length;p>m?(o=10,a=10*Math.abs(p-m)*.5+10):(a=10,o=10*Math.abs(p-m)*.5+10),l&&(h+=""+l+"");let u=30+n,g=80+n,f="",b={},C={};for(let t=0;t
The following sequence alignment shows the residue mapping of the best aligned sets: "symOri" and "symPerm", which are also available in the menu "Analysis > Defined Sets". ',$("#"+e.pre+"symd_info").html(A),s.setSeqAlignForSymmetry(w,_,S);let x=!1,k=t.htmlCls.alignSeqCls.getAlignSequencesAnnotations(Object.keys(e.alnChains),void 0,void 0,x,S);A=$("#"+e.pre+"dl_sequence2").html()+k.sequencesHtml,$("#"+e.pre+"dl_sequence2").html(A),$("#"+e.pre+"dl_sequence2").width(t.htmlCls.RESIDUE_WIDTH*k.maxSeqCnt+200),t.htmlCls.dialogCls.openDlg("dl_alignment","Select residues in aligned sequences from SymD");let O=Object.keys(e.defNames2Residues).length+Object.keys(e.defNames2Atoms).length,R="symOri"+O;e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1),R="symPerm"+O,e.selectionCls.selectResidueList(v,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(v))+" | name "+R,!1),R="symBoth"+O,y=t.hashUtilsCls.unionHash(y,v),e.selectionCls.selectResidueList(y,R,R),e.selectionCls.updateSelectionNameDesc(),t.htmlCls.clickMenuCls.setLogCmd("select "+e.resid2specCls.residueids2spec(Object.keys(y))+" | name "+R,!1)}}else $("#"+e.pre+"dl_symd").html(" The selected residues have no detected symmetry with a Z score of "+a.zscore+" from the program SymD."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD");e.symdtitle="none"===h?void 0:h,e.drawCls.draw()}catch(s){return $("#"+e.pre+"dl_symd").html(" The web service can not determine the symmetry of the input set."),t.htmlCls.dialogCls.openDlg("dl_symd","Dynamically Calculated Symmetry Using SymD"),void e.ParserUtilsCls.hideLoading()}}getResObj(e){this.icn3d.icn3dui;let t=e.substr(0,e.indexOf(" ")),s=e.indexOf("$"),i=e.indexOf("."),n=e.indexOf(":"),l=e.substr(s+1,i-s-1),r=e.substr(i+1,n-i-1),o=e.substr(n+1);return{resn:t,resid:l+"_"+r+"_"+o,resi:o,aligned:!0}}setSeqAlignForSymmetry(e,t,s){let i=this.icn3d,n=i.icn3dui;i.conservedName1="symOri_cons",i.conservedName2="symPerm_cons",i.consHash1={},i.consHash2={},i.alnChainsAnTtl={},i.alnChainsAnno={},i.alnChainsSeq={},i.alnChains={},i.alnChainsSeq={};let l={};for(let r=0,o=e.length;rThis structure has no symmetry."),void i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}let r,o,a,d=t.rcsb_struct_symmetry;if(void 0!==d){void 0!==s.rmsd_supr&&void 0!==s.rmsd_supr.rot&&(r=s.rmsd_supr.rot,o=s.rmsd_supr.trans1,a=s.rmsd_supr.trans2),s.symmetryHash={};for(let e=0,t=d.length;eThis structure has no symmetry.");else{let e="",t=0;for(let i in s.symmetryHash){e+="",++t}$("#"+s.pre+"selectSymmetry").html(e)}}else $("#"+s.pre+"dl_symmetry").html(" This structure has no symmetry.");i.htmlCls.dialogCls.openDlg("dl_symmetry","Symmetry")}getPolygonColor(e){let t=this.icn3d.icn3dui,s=e.substr(0,1);return"C"==s?t.parasCls.thr(16747520):"D"==s?t.parasCls.thr(65535):"T"==s?t.parasCls.thr(15631086):"O"==s?t.parasCls.thr(16753920):"I"==s?t.parasCls.thr(65280):t.parasCls.thr(11119017)}getAxisColor(e,t){let s=this.icn3d.icn3dui,i=e.substr(0,1);return"C"==i?s.parasCls.thr(16711680):"D"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(16711680):"T"==i?2==t?s.parasCls.thr(65535):s.parasCls.thr(65280):"O"==i||"I"==i?2==t?s.parasCls.thr(65535):3==t?s.parasCls.thr(65280):s.parasCls.thr(16711680):s.parasCls.thr(16711680)}}class bs{constructor(e){this.icn3d=e}alignSW(e,t,s,i,n,l,r){this.icn3d.icn3dui;let o=this.bsa_align(r,e,t,[s,i],[n,l]),a="score: "+o[0]+"\n";a+="start: "+o[1]+"\n",a+="cigar: "+this.bsa_cigar2str(o[2])+"\n\n",a+="alignment:\n\n";let d=this.bsa_cigar2gaps(e,t,o[1],o[2]),c={};return c.score=o[0],c.start=o[1],c.cigar=this.bsa_cigar2str(o[2]),c.target=d[0],c.query=d[1],c}bsg_enc_seq(e,t){if(this.icn3d.icn3dui,null==t)return null;let s=[];s.length=e.length;for(let i=0;i0&&(s=-s),i=0;i=2&&"number"==typeof t[0]&&"number"==typeof t[1]){if(null==s)return null;let e="number"==typeof s?s:s[s.length-1]+1;i=this.bsa_gen_score_matrix(e,t[0],t[1])}else i=t;for(let e=0;eo.length?d:o.length;l=null==l||l<0?c:l;let h,p,m=o.target>d?o.target-d:d-o.target;l=l>m?l:m,"number"==typeof n?(h=0,p=n>0?n:-n):(h=n[0]>0?n[0]:-n[0],p=n[1]>0?n[1]:-n[1]);let u,g=h+p,f=-1073741824,b=[],C=[],y=[],v=0,w=-1,_=-1;if(e)for(let e=0;e<=d;++e)b[e]=C[e]=0;else{b[0]=0,C[0]=-g-g;for(let e=1;e<=d;++e)e>=l?b[e]=C[e]=f:(b[e]=-(g+p*(e-1)),C[e]=-(g+g+p*e))}for(let t=0;tl?t-l:0,u=t+l+10?f:-(g+p*t),n=m>0?f:-(g+g+p*t));for(let t=m;t=o?0:1,a=a>=o?a:o,l=a>=n?l:2,a=a>=n?a:n,l=!e||a>0?l:64,i=a,c=r>a?c:t,r=r>a?r:a,a-=g,a=!e||a>0?a:0,o-=p,l|=o>a?4:0,o=o>a?o:a,C[t]=o,n-=p,l|=n>a?32:0,n=n>a?n:a,s[t]=l}b[u]=i,C[u]=e?0:f,r>v&&(v=r,w=t,_=c)}if(e&&0==v)return null;u=e?v:b[d];let S,A,x,k=[],O=0,R=0;for(e?(A=w,x=_,_!=d-1&&this.push_cigar(k,4,d-1-_)):(A=o.length-1,x=(A+l+1=0&&x>=0&&(S=y[A][x-(A>l?A-l:0)],O=S>>(O<<1)&3,!(0==O&&S>>6));)0==O&&(O=3&S),0==O?(this.push_cigar(k,0,1),--A,--x):1==O?(this.push_cigar(k,2,1),--A):(this.push_cigar(k,1,1),--x);e?(x>=0&&this.push_cigar(k,4,x+1),R=A+1):(A>=0&&this.push_cigar(k,2,A+1),x>=0&&this.push_cigar(k,1,x+1));for(let e=0;e>1;++e)S=k[e],k[e]=k[k.length-1-e],k[k.length-1-e]=S;return[u,R,k]}push_cigar(e,t,s){this.icn3d.icn3dui,0==e.length||t!=(15&e[e.length-1])?e.push(s<<4|t):e[e.length-1]+=s<<4}bsa_cigar2gaps(e,t,s,i){this.icn3d.icn3dui;let n="",l="",r="",o=0,a=s;for(let s=0;s>4;0==r?(n+=t.substr(o,d),l+=e.substr(a,d),o+=d,a+=d):1==r?(n+=t.substr(o,d),l+=Array(d+1).join("-"),o+=d):2==r?(n+=Array(d+1).join("-"),l+=e.substr(a,d),a+=d):4==r&&(o+=d)}let d=l.toUpperCase(),c=n.toUpperCase();for(let e=0;e>4).toString()+"MIDNSHP=XB".charAt(15&e[s]));return t.join("")}}class Cs{constructor(e){this.icn3d=e}calculateArea(){var e=this.icn3d,t=e.icn3dui;e.bCalcArea=!0,e.opts.surface="solvent accessible surface",e.applyMapCls.applySurfaceOptions(),$("#"+e.pre+"areavalue").val(e.areavalue),$("#"+e.pre+"areatable").html(e.areahtml),t.htmlCls.dialogCls.openDlg("dl_area","Surface area calculation"),e.bCalcArea=!1}calcBuriedSurface(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length)alert("Please select the first set");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t);s.bCalcArea=!0,s.opts.surface="solvent accessible surface",s.hAtoms=i.hashUtilsCls.cloneHash(l),s.applyMapCls.applySurfaceOptions();let o=s.areavalue,a=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.cloneHash(r),s.applyMapCls.applySurfaceOptions();let d=s.areavalue,c=i.hashUtilsCls.cloneHash(s.resid2area);s.hAtoms=i.hashUtilsCls.unionHash(s.hAtoms,l),s.applyMapCls.applySurfaceOptions();let h=s.areavalue,p=i.hashUtilsCls.cloneHash(s.resid2area),m=0,u=0,g=0,f=0;for(let e in a)p.hasOwnProperty(e)&&(f+=parseFloat(p[e]));u=(o-f).toFixed(2);for(let e in c)p.hasOwnProperty(e)&&(g+=parseFloat(p[e]));m=(d-g).toFixed(2),s.bCalcArea=!1,s.hAtoms=i.hashUtilsCls.cloneHash(n);let b=(parseFloat(d)+parseFloat(o)-parseFloat(h)).toFixed(2),C=" Calculate solvent accessible surface area in the interface:
";C+="Set 1: "+e+", Surface: "+o+" Å2 ",C+="Set 2: "+t+", Surface: "+d+" Å2 ",C+="Total Surface: "+h+" Å2 ",C+="Buried Surface for Set 1: "+u+" Å2 ",C+="Buried Surface for Set 2: "+m+" Å2
",$("#"+s.pre+"dl_buriedarea").html(C),i.htmlCls.dialogCls.openDlg("dl_buriedarea","Buried solvent accessible surface area in the interface"),i.htmlCls.clickMenuCls.setLogCmd("buried surface "+b,!1)}}measureDistTwoSets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select two sets");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l=s.definedSetsCls.getAtomsFromNameArray(e),r=s.definedSetsCls.getAtomsFromNameArray(t),o=s.contactCls.getExtent(l),a=s.contactCls.getExtent(r),d=new THREE.Vector3(o[2][0],o[2][1],o[2][2]),c=new THREE.Vector3(a[2][0],a[2][1],a[2][2]);s.hAtoms=i.hashUtilsCls.cloneHash(n),void 0===s.distPnts&&(s.distPnts=[]),s.distPnts.push(d),s.distPnts.push(c);let h=$("#"+s.pre+"distancecolor2").val();this.addLine(d.x,d.y,d.z,c.x,c.y,c.z,h,!0,"distance");let p=0,m=0,u=d.clone().add(c).multiplyScalar(.5),g=(parseInt(10*d.distanceTo(c))/10).toString()+" A";this.addLabel(g,u.x,u.y,u.z,p,h,m,"distance"),s.drawCls.draw()}}measureDistManySets(e,t){var s=this.icn3d,i=s.icn3dui;if(0==e.length||0==t.length)alert("Please select sets for distance calculation...");else{let n=i.hashUtilsCls.cloneHash(s.hAtoms),l={};for(let i=0,n=e.length;i
";for(let e=0,s=t.length;e"+t[e]+" (Å)"}r+="
";for(let s=0,i=e.length;s
"+i+" (Å)
";for(let e=0,s=t.length;e'+l[i][s]+"":r+="
0
"}r+=""}r+="
",$("#"+i.pre+"dl_disttable").html(r)}}addLine(e,t,s,i,n,l,r,o,a,d,c){var h=this.icn3d;h.icn3dui;let p={};p.position1=new THREE.Vector3(e,t,s),p.position2=new THREE.Vector3(i,n,l),p.color=r,p.dashed=o,p.radius=d,p.opacity=c,void 0===h.lines[a]&&(h.lines[a]=[]),void 0!==a?h.lines[a].push(p):(void 0===h.lines.custom&&(h.lines.custom=[]),h.lines.custom.push(p)),h.hlObjectsCls.removeHlObjects()}addLineFromPicking(e){var t=this.icn3d,s=t.icn3dui;let i=$("#"+t.pre+e+"color").val();t.pAtom.coord.x,t.pAtom2.coord.x,t.pAtom.coord.y,t.pAtom2.coord.y,t.pAtom.coord.z,t.pAtom2.coord.z;let n="stabilizer"!=e;s.htmlCls.clickMenuCls.setLogCmd("add line | x1 "+t.pAtom.coord.x.toPrecision(4)+" y1 "+t.pAtom.coord.y.toPrecision(4)+" z1 "+t.pAtom.coord.z.toPrecision(4)+" | x2 "+t.pAtom2.coord.x.toPrecision(4)+" y2 "+t.pAtom2.coord.y.toPrecision(4)+" z2 "+t.pAtom2.coord.z.toPrecision(4)+" | color "+i+" | dashed "+n+" | type "+e,!0),this.addLine(t.pAtom.coord.x,t.pAtom.coord.y,t.pAtom.coord.z,t.pAtom2.coord.x,t.pAtom2.coord.y,t.pAtom2.coord.z,i,n,e),t.pickpair=!1}addLabel(e,t,s,i,n,l,r,o){var a=this.icn3d;a.icn3dui;let d={};"0"!==n&&""!==n&&"undefined"!==n||(n=void 0),"0"!==l&&""!==l&&"undefined"!==l||(l=void 0),"0"!==r&&""!==r&&"undefined"!==r||(r=void 0);let c=new THREE.Vector3;c.x=t,c.y=s,c.z=i,d.position=c,d.text=e,d.size=n,d.color=l,d.background=r,void 0===a.labels[o]&&(a.labels[o]=[]),void 0!==o?a.labels[o].push(d):(void 0===a.labels.custom&&(a.labels.custom=[]),a.labels.custom.push(d)),a.hlObjectsCls.removeHlObjects()}addChainLabels(e){var t=this.icn3d;let s=t.icn3dui.hashUtilsCls.intHash(t.hAtoms,e);void 0===t.labels.chain&&(t.labels.chain=[]);let i=t.firstAtomObjCls.getChainsFromAtoms(s);for(let e in i){let s={};s.position=t.applyCenterCls.centerAtoms(t.chains[e]).center;let i=e.indexOf("_"),n=e.substr(i+1),l=t.showSeqCls.getProteinName(e);l.length>20&&(l=l.substr(0,20)+"..."),s.text="Chain "+n+": "+l,s.size=18,t.firstAtomObjCls.getFirstCalphaAtomObj(t.chains[e]).color.getHexString().toUpperCase(),s.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,s.background="#FFFFFF",t.labels.chain.push(s)}t.hlObjectsCls.removeHlObjects()}addTerminiLabels(e){var t=this.icn3d,s=t.icn3dui;let i,n="#FFFFFF";i=s.hashUtilsCls.unionHash(i,t.proteins),i=s.hashUtilsCls.unionHash(i,t.nucleotides);let l=s.hashUtilsCls.intHash(t.dAtoms,i),r=s.hashUtilsCls.intHash(l,e);void 0===t.labels.chain&&(t.labels.chain=[]);let o=t.firstAtomObjCls.getChainsFromAtoms(r);for(let e in o){let i=s.hashUtilsCls.intHash(l,t.chains[e]),r=Object.keys(i),o=t.atoms[r[0]],a=t.atoms[r[r.length-1]],d={},c={};d.position=o.coord,c.position=a.coord,d.text="N-",c.text="C-",t.nucleotides.hasOwnProperty(o.serial)&&(d.text="5'",c.text="3'"),d.size=18,c.size=18,o.color.getHexString().toUpperCase(),a.color.getHexString().toUpperCase(),d.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,c.color="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd,d.background=n,c.background=n,t.labels.chain.push(d),t.labels.chain.push(c)}t.hlObjectsCls.removeHlObjects()}}class ys{constructor(e){this.icn3d=e}draw2Ddgm(e,t,s,i){let n=this.icn3d,l=n.icn3dui,r=.667,o={},a={},d={},c={},h={};if(void 0===e)return"";for(let s in e.moleculeInfor){let i="#"+("000000"+e.moleculeInfor[s].color.toString(16)).slice(-6),l=e.moleculeInfor[s].chain.trim();void 0===h[l]?h[l]=1:++h[l];let r=t+"_"+(1===h[l]?l:l+h[l].toString());void 0!==n.mmdbid_q&&(n.mmdbid_q,n.mmdbid_t),o[s]=r,a[s]=i,d[s]=e.moleculeInfor[s].name,c[r]=s}if(void 0===i||!i)for(let s=0,i=e.intracResidues.length;s";p+=""+t.toUpperCase()+" ",p+="",p+="",n.html2ddgm+=p,$("#"+n.pre+"dl_2ddgm").html(n.html2ddgm),p}set2DdgmNote(e){let t="
Nodes: ";return this.icn3d.icn3dui.utilsCls.isMac()?(t+="◯Protein ",t+="▢Nucleotide ",t+="♢Chemical ",t+="▢Biopolymer "):(t+="OProtein ",t+="▢Nucleotide ",t+="◇Chemical ",t+="▢Biopolymer "),t+=" Lines: Interactions at 4 Å ",e&&(t+="Numbers in red: Aligned chains"),t+="
\n\n",s.saveFileCls.saveFile(r+"-"+t+".html","html",i)}e&&void 0===o.shortLink&&s.saveFileCls.saveFile(r+"_icn3d_loadable.png","png");let d=a.split("page.link/");2==d.length&&(a="https://structure.ncbi.nlm.nih.gov/icn3d/share.html?"+d[1]),$("#"+s.pre+"ori_url").val(n),$("#"+s.pre+"short_url").val(a),$("#"+s.pre+"short_url_title").val(a+"&t="+s.yournote),e||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}getShareLinkPrms(e,t){let s=this.icn3d,i=s.icn3dui;return new Promise((function(n,l){$.ajax({url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBxl9CgM0dY5lagHL4UOhEpLWE1fuwdnvc",type:"POST",data:{longDynamicLink:"https://icn3d.page.link/?link="+encodeURIComponent(e)},dataType:"json",success:function(e){n(e)},error:function(n,l,r){let o="Problem in getting shortened URL";$("#"+s.pre+"ori_url").val(e),$("#"+s.pre+"short_url").val(o),$("#"+s.pre+"short_url_title").val(o+"&t="+s.yournote),t||i.htmlCls.dialogCls.openDlg("dl_copyurl","Copy a Share Link URL")}})}))}shareLinkUrl(e){let t=this.icn3d,s=t.icn3dui,i=s.htmlCls.baseUrl+"icn3d/full.html?";if(s.cfg.bSidebyside&&(i=s.htmlCls.baseUrl+"icn3d/full2.html?"),t.bInputUrlfile){i=window.location.href.split("?")[0]+"?"+t.inputurl+"&"}let n,l={};for(let e in t.cfg){let s=t.cfg[e];"inpara"!==e&&"command"!==e&&"usepdbnum"!==e&&"date"!==e&&"v"!==e&&void 0!==s&&("width"===e&&"100%"===s||"height"===e&&"100%"===s||"resize"===e&&!0===s||"showmenu"===e&&!0===s||"showtitle"===e&&!0===s||"showcommand"===e&&!0===s||"mobilemenu"===e&&!1===s||"showanno"===e&&!1===s||"showseq"===e&&!1===s||"showalignseq"===e&&!1===s||"show2d"===e&&!1===s||"showsets"===e&&!1===s||"rotate"===e&&"right"===s||"command"!==e&&("options"===e?Object.keys(s).length>0&&(l[e]=JSON.stringify(s)):!0===s?l[e]=1:!1===s?l[e]=0:""!==s&&(l[e]=s)))}t.bAfMem?l.afmem="on":(s.cfg.afid||1==Object.keys(t.structures).length&&Object.keys(t.structures)[0].length>5)&&(l.afmem="off");let r=-1;void 0!==s.cfg.inpara&&(r=s.cfg.inpara.indexOf("&command=")),n=-1!==r?s.cfg.inpara.substr(0,r):s.cfg.inpara;let o=!1;if(!t.bInputUrlfile){let e=n&&n.substr(1)?n.substr(1).split("&"):[];for(let t=0,s=e.length;tp){u=t.commands[p].split("|||")[0].split("&command=")[0].trim(),-1!==u.indexOf(f)&&++b}let C,y=p+1,v="";for(let e=t.commands.length;y0&&b%2==0&&u!==f&&(i+=f+"; "),i+=u+"|||"+t.transformCls.getTransformationStr(m),g+=u+"|||"+t.transformCls.getTransformationStr(m)+"\n"),g=g.replace(/!/g,Object.keys(t.structures)[0]+"_"),(t.bInputfile&&!t.bInputUrlfile||t.bInputUrlfile&&t.bAppend||i.length>4e3)&&(i=g),void 0!==t.structures&&1==Object.keys(t.structures).length&&void 0!==t.inputid&&(C=Object.keys(t.structures)[0],i=i.replace(new RegExp(C+"_","g"),"!")),void 0!==s.cfg.blast_rep_id&&(i=i.replace(new RegExp("blast_rep_id=!","g"),"blast_rep_id="+C+"_")),i}getPngText(){let e,t=this.icn3d;t.icn3dui;let s="";if(t.bInputfile)e=this.shareLinkUrl(true),"http"==e.substr(0,4)?s+="\nShare Link: "+e:(s+="\nStart of type file======\n",s+=t.InputfileType+"\n",s+="End of type file======\n",s+="Start of data file======\n",s+=t.saveFileCls.getAtomPDB(t.atoms),s+="End of data file======\n",s+="Start of state file======\n",s+=e+"\n",s+="End of state file======\n");else{e=this.shareLinkUrl(),e.length>4e3||0!==e.indexOf("http")?(e=this.shareLinkUrl(true),s+="\nStart of state file======\n",s+=e+"\n",s+="End of state file======\n"):s+="\nShare Link: "+e}return s=s.replace(/!/g,Object.keys(t.structures)[0]+"_"),s}}class xs{constructor(e){this.icn3d=e}setThichknessFor3Dprint(){let e=this.icn3d,t=e.icn3dui;e.lineRadius=1,e.coilWidth=1.2,e.cylinderRadius=.8,e.crosslinkRadius=.8,e.traceRadius=1,e.dotSphereScale=.6,e.sphereRadius=1.5,e.ribbonthickness=1,e.helixSheetWidth=2,e.nucleicAcidWidth=1.4,t.htmlCls.setHtmlCls.setCookieForThickness()}prepareFor3Dprint(){let e=this.icn3d,t=e.icn3dui;if(e.bShowHighlight=!1,e.hlObjectsCls.removeHlObjects(),e.bDashedLines=!1,e.bSetThickness||void 0!==t.cfg.cid||this.setThichknessFor3Dprint(),void 0!==e.lines.hbond)for(let t=0,s=e.lines.hbond.length;tt.substr(0,s))return 1;if(e.substr(0,s)==t.substr(0,s)){if(parseInt(e.substr(s+1))parseInt(t.substr(i+1)))return 1;if(parseInt(e.substr(s+1))==parseInt(t.substr(i+1)))return 0}}})),i="
",e+=s+this.setIcon(t,"tool_pdbfile","Input PDB Files (appendable)","file-alt")+"",e+=s+this.setIcon(t,"tool_sharelink","Get Share Link","link")+"",e+=s+this.setIcon(t,"saveimage","Save iCn3D PNG Image","camera")+"",e+=i+this.setIcon(t,"tool_definedsets","Defined Sets","object-group")+"",e+=s+this.setIcon(t,"tool_aroundsphere","Select by Distance","dot-circle")+"",e+=s+this.setIcon(t,"tool_saveselection","Save Selection as a Set","save")+"",e+=s+this.setIcon(t,"toggleHighlight","Toggle Highlight","highlighter")+"",e+=i+this.setIcon(t,"show_selected","View Selection","eye")+"",e+=s+this.setIcon(t,"tool_selectedcenter","Zoom in Selection","search-plus")+"",e+=s+this.setIcon(t,"alternate","Alternate the Structures by keying the letter 'a'","a",void 0,!0,!0)+"",e+=s+this.setIcon(t,"tool_resetOrientation","Reset Orientation","undo-alt")+"",e+=i+this.setIcon(t,"tool_proteinsRibbon","Style Ribbon for proteins","dna")+"",e+=s+this.setIcon(t,"tool_proteinsSphere","Style Sphere for proteins","volleyball-ball")+"",e+=s+this.setIcon(t,"tool_surfaceVDW","Show Van der Waals Surface","cloud")+"",e+=s+this.setIcon(t,"tool_bkgd","Toggle Background Color","adjust")+"",e+=i+this.setIcon(t,"tool_clrRainbowChain","Color Rainbow for Chains","rainbow")+"",e+=s+this.setIcon(t,"tool_clrSSGreen","Color by Secondary Structures","ring")+"",e+=s+this.setIcon(t,"tool_clrChain","Color by Chains","layer-group")+"",e+=s+this.setIcon(t,"tool_clrAtom","Color by Atoms","atom")+"",e+=i+this.setIcon(t,"tool_selectannotations","Sequences & Annotations","grip-lines")+"",e+=s+this.setIcon(t,"hbondsYes","Interactions","users")+"",e+=s+this.setIcon(t,"tool_delphi","Delphi Potentials","cloud-meatball")+"",e+=s+this.setIcon(t,"removeLabels","Remove Labels","remove-format")+"",e+=i+this.setIcon("link","tool-gallery","Gallery","image","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#gallery")+"",e+=s+this.setIcon("link","tool-video","Videos","file-video","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#videos")+"",e+=s+this.setIcon("link","tool-github","iCn3D GitHub","code","https://github.com/ncbi/icn3d")+"",e+=s+this.setIcon("link","tool-hints","Transform Hints","info-circle","https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#useicn3d")+"",e+="
",t+="",t+=this.getMenuText("mn1_retrievebyid","Retrieve by ID",void 0,1,1),t+="
",t+=this.getLink("mn1_mmdbafid","PDB/MMDB/AlphaFold IDs"+e.htmlCls.wifiStr,1,2),t+=this.getLink("mn1_mmdbid","NCBI MMDB ID (annotation) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmtfid","RCSB MMTF ID (fast) "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_pdbid","RCSB PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getMenuText("mn1_afwrap","AlphaFold Structures",void 0,void 0,2),t+="
",t+=this.getLink("mn1_afid","UniProt ID "+e.htmlCls.wifiStr,void 0,3),t+=this.getLink("mn1_refseqid","NCBI Protein Accession "+e.htmlCls.wifiStr,void 0,3),t+="
",t+=this.getLink("mn1_opmid","OPM PDB ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_mmcifid","RCSB mmCIF ID "+e.htmlCls.wifiStr,void 0,2),t+=this.getLink("mn1_cid","PubChem CID "+e.htmlCls.wifiStr,1,2),t+="
",t+="",t+=this.getLink("mn1_exportState","State File",void 0,2),t+=this.getLink("mn1_exportSelections","Selection File",void 0,2),t+=this.getLink("mn1_exportSelDetails","Selection Details",void 0,2),t+=this.getLink("mn1_exportCounts","Residue Counts",void 0,2),t+=this.getLink("mn1_exportPdbRes","PDB",1,2),t+=this.getLink("profixpdb","PDB with Missing Atoms",void 0,2),t+=this.getLink("profixpdbh","PDB with Hydrogens",void 0,2),void 0===e.cfg.cid&&(t+=this.getLink("mn1_exportSecondary","Secondary Structure",void 0,2)),t+="
",t+="
",t+="",t+=this.getLink("mn1_sharelink","Share Link "+e.htmlCls.wifiStr,1,1),t+=this.getLink("mn1_replayon","Replay Each Step",void 0,1),t+=this.getMenuSep(),t+=this.getMenuText("mn1_menuwrap","Customize Menus",void 0,1,1),t+="
",t+=this.getRadio("mn5_surface","mn5_surfaceVDW","Van der Waals",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceVDWContext","VDW with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecular","Molecular Surface",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceMolecularContext","MS with Context",void 0,void 0,2),t+=this.getRadio("mn5_surface","mn5_surfaceSAS","Solvent Accessible",void 0,1,2),t+=this.getRadio("mn5_surface","mn5_surfaceSASContext","SA with Context",void 0,void 0,2),t+="
",t+="",t+=this.getMenuSep(),t+=this.getLink("mn5_cartoonshape","Cartoon for a Set",void 0,1),t+=this.getLink("mn5_linebtwsets","Line btw. Two Sets",void 0,1),void 0===e.cfg.cid&&void 0===e.cfg.align&&void 0===e.cfg.chainalign&&void 0===e.cfg.mmdbaf&&(t+=this.getMenuSep(),t+=this.getLinkWrapper2("mn5_map","Electron Density","mapWrapper1",void 0,1),t+="
",t+=this.getRadio("mn4_clr","mn4_clrSSGreen","Sheet in Green",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSYellow","Sheet in Yellow",void 0,1,2),t+=this.getRadio("mn4_clr","mn4_clrSSSpectrum","Spectrum",void 0,void 0,2),t+="
",t+=this.getRadio("mn6_distance","mn6_distanceYes","between Two Atoms",void 0,1,2),t+=this.getRadio("mn6_distance","mn6_distTwoSets","between Two Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distManySets","Among Many Sets",void 0,void 0,2),t+=this.getRadio("mn6_distance","mn6_distanceNo","Hide",!0,1,2),t+="
",t+="",t+=this.getMenuUrl("selhints",e.htmlCls.baseUrl+"icn3d/icn3d.html#selsubset","Selection Hints",void 0,1),t+=this.getMenuUrl("helpdesk","https://support.nlm.nih.gov/support/create-case/","Write to Help Desk",1,1),t+="
",t+="
",t}hideMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="none"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="none"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="none"),$("#"+e.pre+"title")[0].style.margin="10px 0 0 10px")}showMenu(){let e=this.icn3dui;e.bNode||(void 0!==$("#"+e.pre+"mnlist")[0]&&($("#"+e.pre+"mnlist")[0].style.display="block"),void 0!==$("#"+e.pre+"mnLogSection")[0]&&($("#"+e.pre+"mnLogSection")[0].style.display="block"),void 0!==$("#"+e.pre+"cmdlog")[0]&&($("#"+e.pre+"cmdlog")[0].style.display="block"))}}class c{constructor(e){this.icn3dui=e}openDlg(e,t){let s=this.icn3dui;s.icn3d,s.bNode||(e=s.pre+e,s.cfg.notebook?this.openDlgNotebook(e,t):this.openDlgRegular(e,t),s.htmlCls.themecolor||(s.htmlCls.themecolor="blue"),s.htmlCls.setMenuCls.setTheme(s.htmlCls.themecolor))}addSaveButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashSave&&this.dialogHashSave.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashSave&&(this.dialogHashSave={}),this.dialogHashSave[e]=1)}addHideButton(e){let t=this.icn3dui;t.icn3d,t.bNode||void 0!==this.dialogHashHide&&this.dialogHashHide.hasOwnProperty(e)||($("#"+e).parent().children(".ui-dialog-titlebar").append(""),void 0===this.dialogHashHide&&(this.dialogHashHide={}),this.dialogHashHide[e]=1)}getDialogStatus(){let e=this.icn3dui;if(e.icn3d,e.bNode)return;let t={},s={},i=$("#"+e.pre+"dl_selectannotations").hasClass("ui-dialog-content"),n=$("#"+e.pre+"dl_graph").hasClass("ui-dialog-content"),l=$("#"+e.pre+"dl_linegraph").hasClass("ui-dialog-content"),r=$("#"+e.pre+"dl_scatterplot").hasClass("ui-dialog-content"),o=$("#"+e.pre+"dl_contactmap").hasClass("ui-dialog-content"),a=$("#"+e.pre+"dl_alignerrormap").hasClass("ui-dialog-content"),d=$("#"+e.pre+"dl_interactionsorted").hasClass("ui-dialog-content"),c=$("#"+e.pre+"dl_alignment").hasClass("ui-dialog-content"),h=$("#"+e.pre+"dl_2ddgm").hasClass("ui-dialog-content"),p=$("#"+e.pre+"dl_2dctn").hasClass("ui-dialog-content"),m=$("#"+e.pre+"dl_definedsets").hasClass("ui-dialog-content");return t.bSelectannotationsInit2=!1,t.bGraph2=!1,t.bLineGraph2=!1,t.bScatterplot2=!1,t.bTable2=!1,t.bAlignmentInit2=!1,t.bTwoddgmInit2=!1,t.bTwodctnInit2=!1,t.bSetsInit2=!1,s.dl_selectannotations="bSelectannotationsInit2",s.dl_graph="bGraph2",s.dl_linegraph="bLineGraph2",s.dl_scatterplot="bScatterplot2",s.dl_contactmap="bContactmap2",s.dl_alignerrormap="bAlignerrormap2",s.dl_interactionsorted="bTable2",s.dl_alignment="bAlignmentInit2",s.dl_2ddgm="bTwoddgmInit2",s.dl_2dctn="bTwodctnInit2",s.dl_definedsets="bSetsInit2",i&&(t.bSelectannotationsInit2=$("#"+e.pre+"dl_selectannotations").dialog("isOpen")),n&&(t.bGraph2=$("#"+e.pre+"dl_graph").dialog("isOpen")),l&&(t.bLineGraph2=$("#"+e.pre+"dl_linegraph").dialog("isOpen")),r&&(t.bScatterplot2=$("#"+e.pre+"dl_scatterplot").dialog("isOpen")),o&&(t.bContactmap2=$("#"+e.pre+"dl_contactmap").dialog("isOpen")),a&&(t.bAlignerror2=$("#"+e.pre+"dl_alignerrormap").dialog("isOpen")),d&&(t.bTable2=$("#"+e.pre+"dl_interactionsorted").dialog("isOpen")),c&&(t.bAlignmentInit2=$("#"+e.pre+"dl_alignment").dialog("isOpen")),h&&(t.bTwoddgmInit2=$("#"+e.pre+"dl_2ddgm").dialog("isOpen")),p&&(t.bTwodctnInit2=$("#"+e.pre+"dl_2dctn").dialog("isOpen")),m&&(t.bSetsInit2=$("#"+e.pre+"dl_definedsets").dialog("isOpen")),{status:t,id2flag:s}}openDlgHalfWindow(e,t,s,i){let n=this.icn3dui,l=n.icn3d;if(n.bNode)return;let r=this,o=n.htmlCls.width2d+20;l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH-s,n.htmlCls.HEIGHT,i);let a,d=n.htmlCls.HEIGHT,c=s;a=!n.cfg.showmenu||n.utilsCls.isMobile()||n.cfg.mobilemenu?{my:"left top",at:"right top",of:"#"+n.pre+"viewer",collision:"none"}:{my:"left top",at:"right top+40",of:"#"+n.pre+"viewer",collision:"none"},n.cfg.resize=!1,window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:d,width:c,modal:!1,position:a,close:function(t){let s=r.getDialogStatus(),i=s.status,a=s.id2flag,d=!1;for(let t in a){let s=e===n.pre+t;for(let e in i)i.hasOwnProperty(e)||(s=s&&!i[e]);d=d||s}if(d)if(i.bTwoddgmInit2||i.bTwodctnInit2||i.bSetsInit2){let e=n.utilsCls.isMobile()?n.htmlCls.WIDTH:n.htmlCls.WIDTH-o;l.resizeCanvasCls.resizeCanvas(e,n.htmlCls.HEIGHT,!0),i.bTwoddgmInit2&&r.openDlg2Ddgm(n.pre+"dl_2ddgm",void 0,i.bSetsInit2),i.bTwodctnInit2&&r.openDlg2Ddgm(n.pre+"dl_2dctn",void 0,i.bSetsInit2),i.bSetsInit2&&r.openDlg2Ddgm(n.pre+"dl_definedsets")}else l.resizeCanvasCls.resizeCanvas(n.htmlCls.WIDTH,n.htmlCls.HEIGHT,!0)},resize:function(t){if(e==n.pre+"dl_selectannotations")l.annotationCls.hideFixedTitle();else if(e==n.pre+"dl_graph"){let t=$("#"+e).width(),s=$("#"+e).height();d3.select("#"+n.svgid).attr("width",t).attr("height",s)}else if(e==n.pre+"dl_linegraph"||e==n.pre+"dl_scatterplot"||e==n.pre+"dl_contactmap"||e==n.pre+"dl_alignerrormap"){let t=status.bTwoddgmInit2||status.bSetsInit2?(n.htmlCls.WIDTH-o)/2:n.htmlCls.WIDTH/2,s=$("#"+e).width()/t;if(e==n.pre+"dl_linegraph"){let e=l.linegraphWidth*s;$("#"+n.linegraphid).attr("width",e)}else if(e==n.pre+"dl_scatterplot"){let e=l.scatterplotWidth*s;$("#"+n.scatterplotid).attr("width",e)}else if(e==n.pre+"dl_contactmap"){let e=l.contactmapWidth*s;$("#"+n.contactmapid).attr("width",e)}else if(e==n.pre+"dl_alignerrormap"){let e=l.alignerrormapWidth*s;$("#"+n.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}openDlg2Ddgm(e,t,s){let i=this.icn3dui,n=i.icn3d;if(i.bNode)return;let l,r,o=this,a=i.htmlCls.width2d+20;e===i.pre+"dl_definedsets"?(l="right top",r="Select sets"):e!==i.pre+"dl_2ddgm"&&e!==i.pre+"dl_2dctn"||(l=s?"right top+240":"right top",r=e===i.pre+"dl_2ddgm"?"2D Diagram":"2D Cartoon");let d={my:"left top+"+i.htmlCls.MENU_HEIGHT,at:l,of:"#"+i.pre+"viewer",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:r,height:"auto",width:a,modal:!1,position:d,close:function(e){let t=o.getDialogStatus().status;t.bSelectannotationsInit2||t.bGraph2||t.bLineGraph2||t.bScatterplot2||t.bTable2||t.bAlignmentInit2||n.resizeCanvasCls.resizeCanvas(i.htmlCls.WIDTH,i.htmlCls.HEIGHT,!0)},resize:function(t,s){e==i.pre+"dl_2dctn"&&(n.resizeRatioX=s.size.width/i.htmlCls.width2d,n.resizeRatioY=s.size.height/(i.htmlCls.width2d+70))},resizeStop:function(e,t){n.resizeRatioX=t.size.width/i.htmlCls.width2d,n.resizeRatioY=t.size.height/(i.htmlCls.width2d+70)}}),this.addSaveButton(e),this.addHideButton(e)}openDlgRegular(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20,o=this.getDialogStatus().status;if(e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"){let a=.5*s.htmlCls.WIDTH-.5*r;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)this.openDlgHalfWindow(e,t,a,!0),(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2)&&(i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-a-r,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&this.openDlg2Ddgm(s.pre+"dl_definedsets"));else{i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,.5*s.htmlCls.HEIGHT,!0),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH;let a={my:"left top",at:"left bottom+32",of:"#"+s.pre+"canvas",collision:"none"};window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a,close:function(t){if(!((e!==s.pre+"dl_selectannotations"||o.bAlignmentInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_graph"||o.bSelectannotationsInit2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignment"||o.bSelectannotationsInit2||o.bGraph2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_interactionsorted"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_linegraph"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bScatterplot2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_scatterplot"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bContactmap2||o.bAlignerrormap2)&&(e!==s.pre+"dl_contactmap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bAlignerrormap2)&&(e!==s.pre+"dl_alignerrormap"||o.bSelectannotationsInit2||o.bGraph2||o.bAlignmentInit2||o.bTable2||o.bLineGraph2||o.bScatterplot2||o.bContactmap2)))if(o.bTwoddgmInit2||o.bTwodctnInit2||o.bSetsInit2){let e=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(e,s.htmlCls.HEIGHT,!0),o.bTwoddgmInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,o.bSetsInit2),o.bTwodctnInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,o.bSetsInit2),o.bSetsInit2&&thisClass.openDlg2Ddgm(s.pre+"dl_definedsets")}else i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH,s.htmlCls.HEIGHT,!0)},resize:function(t){if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"||e==s.pre+"dl_scatterplot"||e==s.pre+"dl_contactmap"||e==s.pre+"dl_alignerrormap"){let t=o.bTwoddgmInit2||o.bSetsInit2?(s.htmlCls.WIDTH-r)/2:s.htmlCls.WIDTH/2,n=$("#"+e).width()/t;if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*n;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*n;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*n;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*n;$("#"+s.alignerrormapid).attr("width",e)}}}}),this.addSaveButton(e),this.addHideButton(e)}}else if(e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,void 0,o.bSetsInit2);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT,o.bSetsInit2)}}else{let a;if(l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_menupref"&&(n=600,l=500),e===s.pre+"dl_definedsets"){let t=0;if(s.htmlCls.WIDTH>=s.htmlCls.HEIGHT)(o.bSelectannotationsInit2||o.bGraph2||o.bLineGraph2||o.bScatterplot2||o.bTable2||o.bAlignmentInit2)&&(t=.5*s.htmlCls.WIDTH-.5*r),i.resizeCanvasCls.resizeCanvas(s.htmlCls.WIDTH-t-r,s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",void 0,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",void 0,!0);else{let t=s.utilsCls.isMobile()?s.htmlCls.WIDTH:s.htmlCls.WIDTH-r;i.resizeCanvasCls.resizeCanvas(t,.5*s.htmlCls.HEIGHT,!0),this.openDlg2Ddgm(e,.5*s.htmlCls.HEIGHT),o.bTwoddgmInit2&&this.openDlg2Ddgm(s.pre+"dl_2ddgm",.5*s.htmlCls.HEIGHT,!0),o.bTwodctnInit2&&this.openDlg2Ddgm(s.pre+"dl_2dctn",.5*s.htmlCls.HEIGHT,!0)}}else s.utilsCls.isMobile()?a={my:"left top",at:"left bottom-50",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_allinteraction"||e===s.pre+"dl_buriedarea"?(a={my:"right top",at:"right top+50",of:"#"+i.divid,collision:"none"},n=700,l=500):a=e===s.pre+"dl_rmsd"||e===s.pre+"dl_legend"?{my:"left bottom",at:"left+20 bottom-20",of:"#"+s.pre+"canvas",collision:"none"}:e===s.pre+"dl_symd"?{my:"left top",at:"right-200 bottom-200",of:"#"+s.pre+"canvas",collision:"none"}:s.cfg.align?{my:"left top",at:"left top+90",of:"#"+s.pre+"canvas",collision:"none"}:{my:"left top",at:"left top+50",of:"#"+s.pre+"canvas",collision:"none"},window.dialog=$("#"+e).dialog({autoOpen:!0,title:t,height:l,width:n,modal:!1,position:a}),this.addSaveButton(e),this.addHideButton(e)}$(".ui-dialog .ui-button span").removeClass("ui-icon-closethick").addClass("ui-icon-close")}openDlgNotebook(e,t){let s=this.icn3dui,i=s.icn3d;if(s.bNode)return;let n=400,l=150,r=s.htmlCls.width2d+20;e===s.pre+"dl_selectannotations"||e===s.pre+"dl_graph"||e===s.pre+"dl_linegraph"||e===s.pre+"dl_scatterplot"||e===s.pre+"dl_contactmap"||e===s.pre+"dl_alignerrormap"||e===s.pre+"dl_interactionsorted"||e===s.pre+"dl_alignment"?($("#"+e).show(),l=.5*s.htmlCls.HEIGHT,n=s.htmlCls.WIDTH,$("#"+e).width(n),$("#"+e).height(l),$("#"+e).resize((function(t){let n=s.htmlCls.WIDTH/2,l=$("#"+e).width()/n;if(e==s.pre+"dl_selectannotations")i.annotationCls.hideFixedTitle();else if(e==s.pre+"dl_graph"){let t=$("#"+e).width(),i=$("#"+e).height();d3.select("#"+s.svgid).attr("width",t).attr("height",i)}else if(e==s.pre+"dl_linegraph"){let e=i.linegraphWidth*l;$("#"+s.linegraphid).attr("width",e)}else if(e==s.pre+"dl_scatterplot"){let e=i.scatterplotWidth*l;$("#"+s.scatterplotid).attr("width",e)}else if(e==s.pre+"dl_contactmap"){let e=i.contactmapWidth*l;$("#"+s.contactmapid).attr("width",e)}else if(e==s.pre+"dl_alignerrormap"){let e=i.alignerrormapWidth*l;$("#"+s.alignerrormapid).attr("width",e)}}))):(i.bRender&&$("#"+e).show(),l="auto",n="auto",e===s.pre+"dl_addtrack"?n="50%":e===s.pre+"dl_2ddgm"||e===s.pre+"dl_2dctn"||e===s.pre+"dl_definedsets"?n=r:e!==s.pre+"dl_allinteraction"&&e!==s.pre+"dl_buriedarea"||(n=700,l=500),$("#"+e).width(n),$("#"+e).height(l))}}class h{constructor(e){this.icn3dui=e}setCustomDialogs(){let e=this.icn3dui;if(e.icn3d,e.bNode)return"";return""}getHtmlAlignResidueByResidue(e,t,s){let i=this.icn3dui;i.icn3d;let n="";return n+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
',s+="",s+=e.htmlCls.divStr+"dl_command' style='display:none;'>",s+=e.htmlCls.divStr+"dl_setoperations'>",s+=" ",s+=" ",s+="",s+=" ",s+=e.htmlCls.setHtmlCls.setAdvanced(),s+="",s+="",s+=e.htmlCls.setHtmlCls.setAdvanced(2),s+=e.htmlCls.divStr+"dl_vastplus' class='"+n+"' style='max-width:500px'>",s+="Note: VAST+ finds other macromolecular structures that have a similar biological unit. To do this, VAST+ takes into consideration the complete set of 3D domains that VAST identified within a query structure, throughout all of its component protein molecules, and finds other macromolecular structures that have a similar set of proteins/3D domains.
",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpluspdbid' value='6VXX' size=8> ",s+=e.htmlCls.buttonStr+"reload_vastplus'>VAST+",s+="",s+=e.htmlCls.divStr+"dl_vast' class='"+n+"' style='max-width:500px'>",s+="Note: VAST identifies 3D domains (substructures) within each protein structure in the Molecular Modeling Database (MMDB), and then finds other protein structures that have one or more similar 3D domains, using purely geometric criteria. You have two ways to do a VAST search.
",s+="Optione 1, search with your selection (all residues are selected by default) in the loaded structures: ",s+=' ",s+="Optione 2, search with PDB ID and chain name: ",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastpdbid' value='4N7N' size=8> ",s+="Chain Name: "+e.htmlCls.inputTextStr+"id='"+e.pre+"vastchainid' value='A' size=8> ",s+=e.htmlCls.buttonStr+"reload_vast'>VAST
",s+="Optione 3, search with a PDB file: ",s+=' ",s+="",s+=e.htmlCls.divStr+"dl_foldseek' class='"+n+"' style='max-width:500px'>",s+='1. your selection (all residues are selected by default) in the loaded structures to Foldseek web server.
',s+='2 (Optional). Once you see the structure neighbors, you can view the alignment in iCn3D by inputing a list of PDB chain IDs or AlphaFold UniProt IDs below.
The PDB chain IDs are the same as the record names such as "1HHO_A". The UniProt ID is the text between "AF-" and "-F1". For example, the UniProt ID for the record name "AF-P69905-F1-model_v4" is "P69905".
',s+="Chain ID List: "+e.htmlCls.inputTextStr+"id='"+e.pre+"foldseekchainids' value='P69905,P01942,1HHO_A' size=30> ",s+=e.htmlCls.buttonStr+"reload_foldseek'>Align",s+="",s+=e.htmlCls.divStr+"dl_mmtfid' class='"+n+"'>",s+="MMTF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmtfid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmtf'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbid' class='"+n+"'>",s+="PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"pdbid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_pdb'>Load",s+="",s+=e.htmlCls.divStr+"dl_afid' class='"+n+"'>",s+="Note: AlphaFold produces a per-residue confidence score (pLDDT) between 0 and 100: ",s+=e.htmlCls.clickMenuCls.setAlphaFoldLegend()+" ";let o=e.cfg.afid?e.cfg.afid:"A4D1S0";s+="AlphaFold Uniprot ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"afid' value='"+o+"' size=10>
",s+="PAE Map: "+e.htmlCls.buttonStr+"reload_afmap'>Load Half"+e.htmlCls.buttonStr+"reload_afmapfull' style='margin-left:30px'>Load Full (slow)",s+="",s+=e.htmlCls.divStr+"dl_refseqid' class='"+n+"'>",s+="NCBI Protein Accession: "+e.htmlCls.inputTextStr+"id='"+e.pre+"refseqid' value='NP_001743.1' size=8> ",s+=e.htmlCls.buttonStr+"reload_refseq'>Load",s+="",s+=e.htmlCls.divStr+"dl_opmid' class='"+n+"'>",s+="Orientations of Proteins in Membranes(OPM) PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"opmid' value='6JXR' size=8> ",s+=e.htmlCls.buttonStr+"reload_opm'>Load",s+="",s+=e.htmlCls.divStr+"dl_pdbfile' class='"+n+"'>",s+='Note: Several PDB files could be concatenated into a single PDB file. Use the line "ENDMDL" to separate PDB files.
The custom JSON file on residue colors has the following format for proteins("ALA" and "ARG") and nucleotides("G" and "A"): ',s+='{"ALA":"#C8C8C8", "ARG":"#145AFF", ..., "G":"#008000", "A":"#6080FF", ...}
',s+="Residue Color File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"rescolorfile' size=8> ",s+=e.htmlCls.buttonStr+"reload_rescolorfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_customcolor' class='"+n+"'>",s+=" ",s+='
The custom file for the structure has two columns separated by space or tab: ',s+='residue number, and score in the range of 0-100. If you click "Apply Custom Color" button, ',s+='the scores 0, 50 and 100 correspond to the three colors specified below. If you click "Apply Custom Tube", ',s+='the selected residues will be displayed in a style similar to "B-factor Tube".
You can define your own reference numbers in a custom file using Excel, and then export it as a CSV file. An example file is shown below with cells separated by commas. ',s+="
",s+="1TUP_C,,,,,,,200,201,230",s+='The first row defines the reference residue numbers, which could be any strings. The 1st cell could be anything. The rest cells are reference residue numbers (e.g., 11, 21, 10C, etc.) or empty cells. Each chain has a separate row. The first cell of the second row is the chain ID "1TUP_A". The rest cells are the corresponding real residue numbers for reference residue numbers in the first row. For example, the reference numbers for residues 100, 101, and 132 in the chain 1TUP_A are 11, 12, and 22, respectively. The fourth row shows another set of reference numners for the chain "1TUP_C". It could be a chain from a different structure.
',s+='To select all residues corresponding to the reference numbers, you can simplay replace ":" with "%" in the Specification. For example, "%12" selects the residue 101 in 1TUP_A and the residue 111 in 1TUP_B. ".A%12" has the chain "A" filter and selects the residue 101 in 1TUP_A. ',s+="
",s+=e.htmlCls.buttonStr+"reload_customreffile'>Apply Custom Reference Numbers",s+="",s+=e.htmlCls.divStr+"dl_align' class='"+n+"'>",s+="Enter the PDB IDs or MMDB IDs of the structures:
",s+="VAST+ based on VAST: "+e.htmlCls.buttonStr+"reload_align_ori'>All Matching Molecules Superposed"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_align_refined'>Invariant Substructure Superposed
",s+="VAST+ based on TM-align: "+e.htmlCls.buttonStr+"reload_align_tmalign'>All Matching Molecules Superposed
",s+="",s+=e.htmlCls.divStr+"dl_alignaf' class='"+n+"'>",s+="Enter two AlphaFold Uniprot IDs:
",s+=e.htmlCls.buttonStr+"reload_alignaf_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_alignaf' style='margin-left:30px'>Align with VAST",s+="",s+=e.htmlCls.divStr+"dl_chainalign' class='"+n+"'>",s+="
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+=e.htmlCls.buttonStr+"reload_chainalign_tmalign'>Align with TM-align"+e.htmlCls.buttonStr+"reload_chainalign_asym' style='margin-left:30px'>Align with VAST
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+="All chains will be aligned to the first chain in the comma-separated chain IDs. Each chain ID has the form of PDBID_chain (e.g., 1HHO_A, case sensitive) or UniprotID (e.g., P69905 for AlphaFold structures).
",s+="The sequence alignment (followed by structure alignemnt) is based on residue numbers in the First/Master chain: "+e.htmlCls.inputTextStr+"id='"+e.pre+"resalignids' value='1,5,10-50' size=50> ",s+=e.htmlCls.buttonStr+"reload_chainalign_asym2' style='margin-top:3px;'>Align by Sequence Alignment
",s+='(Note: To align chains in custom PDB files, you could load them in "File > Open File > PDB Files (appendable)" and click "Analysis > Defined Sets". Finally select multiple chains in Defined Sets and click "File > Realign Selection".)
",s+='Please specify the mutations with a comma separated mutation list. Each mutation can be specified as "[uppercase PDB ID or AlphaFold UniProt ID]_[Chain Name]_[Residue Number]_[One Letter Mutant Residue]". E.g., the mutation of N501Y in the E chain of PDB 6M0J can be specified as "6M0J_E_501_Y". For AlphaFold structures, the "Chain ID" is "A". If you load a custom structure without PDB or UniProt ID, you can open "Seq. & Annotations" window and find the chain ID such as "stru_A". The part before the underscore is the structure ID, which can be used to specify the mutation such as "stru_A_...". Remember to choose "Show Mutation in: Current Page".
',s+=e.htmlCls.buttonStr+"reload_mutation_3d' title='Show the mutations in 3D using the scap program'>3D with scap",s+=e.htmlCls.buttonStr+"reload_mutation_inter' style='margin-left:20px' title='Show the mutations in 3D and the change of interactions'>Interactions",s+=e.htmlCls.buttonStr+"reload_mutation_pdb' style='margin-left:20px' title='Show the mutations in 3D and export the PDB of the mutant within 10 angstrom'>PDB",s+="
",s+=e.htmlCls.buttonStr+"reload_afmapfile'>Load Half PAE Map"+e.htmlCls.buttonStr+"reload_afmapfilefull' style='margin-left:30px'>Load Full PAE Map (slow)",s+="",s+=e.htmlCls.divStr+"dl_urlfile' class='"+n+"'>",s+="File type: ",s+=" ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"urlfile' size=20> ",s+=e.htmlCls.buttonStr+"reload_urlfile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmciffile' class='"+n+"'>",s+="mmCIF File: "+e.htmlCls.inputFileStr+"id='"+e.pre+"mmciffile' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmciffile'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmcifid' class='"+n+"'>",s+="mmCIF ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmcifid' value='1TUP' size=8> ",s+=e.htmlCls.buttonStr+"reload_mmcif'>Load",s+="",s+=e.htmlCls.divStr+"dl_mmdbid' class='"+n+"' style='max-width:500px'>",s+="MMDB or PDB ID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbid' value='1TUP' size=8>
",s+=e.htmlCls.buttonStr+"reload_mmdb_asym'>Load Asymmetric Unit (All Chains)"+e.htmlCls.buttonStr+"reload_mmdb' style='margin-left:30px'>Load Biological Unit
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_mmdbafid' class='"+n+"' style='max-width:600px'>",s+="List of PDB, MMDB, or AlphaFold UniProt structures: "+e.htmlCls.inputTextStr+"id='"+e.pre+"mmdbafid' placeholder='e.g., 1HHO,4N7N,P69905,P01942' size=30>
",s+=""+e.htmlCls.buttonStr+"reload_mmdbaf' style='width:150px'>Load Biological Unit"+e.htmlCls.buttonStr+"reload_mmdbaf_asym' style='margin-left:30px; width:250px'>Load Asymmetric Unit (All Chains)
",s+='Note: The "biological unit" is the biochemically active form of a biomolecule,
',s+=e.htmlCls.divStr+"asu_bu2' style='display:none;'>",s+='which can range from a monomer (single protein molecule) to an oligomer of 100+ protein molecules.
The "asymmetric unit" is the raw 3D structure data resolved by X-ray crystallography, NMR, or Cryo-electron microscopy. The asymmetric unit is equivalent to the biological unit in approximately 60% of structure records. In the remaining 40% of the records, the asymmetric unit represents a portion of the biological unit that can be reconstructed using crystallographic symmetry, or it represents multiple copies of the biological unit.',s+="",s+=e.htmlCls.divStr+"dl_blast_rep_id' style='max-width:600px;' class='"+n+"'>",s+="Enter a Sequence ID (or FASTA sequence) and the aligned protein accession, which can be found using the BLAST search with the Sequence ID or FASTA sequence as input. If the protein accession is not a PDB chain, the corresponding AlphaFold UniProt structure is used.
",s+="Sequence ID(NCBI protein accession of a sequence): "+e.htmlCls.inputTextStr+"id='"+e.pre+"query_id' value='NP_001108451.1' size=8> ",s+="or FASTA sequence:
",s+="NCBI protein accession (or a chain of a PDB): "+e.htmlCls.inputTextStr+"id='"+e.pre+"blast_rep_id' value='1TSR_A' size=8> ",s+=e.htmlCls.buttonStr+"reload_blast_rep_id'>Align with BLAST "+e.htmlCls.wifiStr+e.htmlCls.buttonStr+"reload_alignsw' style='margin-left:30px'>Align with Global Smith-Waterman"+e.htmlCls.buttonStr+"reload_alignswlocal' style='margin-left:30px'>Align with Local Smith-Waterman",s+="",s+=e.htmlCls.divStr+"dl_yournote' class='"+n+"'>",s+='Your note will be saved in the HTML file when you click "File > Save File > iCn3D PNG Image".
',s+=" ",s+=e.htmlCls.buttonStr+"applyyournote'>Save",s+="",s+=e.htmlCls.divStr+"dl_gi' class='"+n+"'>",s+="Protein gi: "+e.htmlCls.inputTextStr+"id='"+e.pre+"gi' value='1310960' size=8> ",s+=e.htmlCls.buttonStr+"reload_gi'>Load",s+="",s+=e.htmlCls.divStr+"dl_cid' class='"+n+"'>",s+="PubChem CID: "+e.htmlCls.inputTextStr+"id='"+e.pre+"cid' value='2244' size=8> ",s+=e.htmlCls.buttonStr+"reload_cid'>Load",s+="",s+=e.htmlCls.divStr+"dl_pngimage' class='"+n+"'>",s+="iCn3D PNG image: "+e.htmlCls.inputFileStr+"id='"+e.pre+"pngimage'> ",s+=e.htmlCls.buttonStr+"reload_pngimage' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_state' class='"+n+"'>",s+="State file: "+e.htmlCls.inputFileStr+"id='"+e.pre+"state'> ",s+=e.htmlCls.buttonStr+"reload_state' style='margin-top: 6px;'>Load",s+="",s+=e.htmlCls.divStr+"dl_fixedversion' style='max-width:500px' class='"+n+"'>",s+='Since January 6, 2021, you can show the original view with the archived version of iCn3D by pasting your URL below and click "Show Originial View". Note the version in the parameter "v" was used to replace "full.html" with "full_[v].html" in the URL.
',s+="Share Link URL: "+e.htmlCls.inputTextStr+"id='"+e.pre+"sharelinkurl' size=60> ",s+=e.htmlCls.buttonStr+"reload_fixedversion'>Show Original View
",s+=e.htmlCls.buttonStr+"elecmapNo4'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_dsn6url' class='"+n+"'>",s+="Note: Always load a PDB file before loading DSN6 files.
",s+="2fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurl2fofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurl2fofc' style='margin-top: 6px;'>Load
",s+="fofc contour at: σ ",s+="URL in the same host: "+e.htmlCls.inputTextStr+"id='"+e.pre+"dsn6fileurlfofc' size=20>"+e.htmlCls.space3+e.htmlCls.buttonStr+"reload_dsn6fileurlfofc' style='margin-top: 6px;'>Load
",s+=e.htmlCls.buttonStr+"elecmapNo5'>Remove Map ",s+="",s+=e.htmlCls.divStr+"dl_clr' class='"+n+"'>",s+="Click in the input box to use the color picker:
",s+=""+e.htmlCls.buttonStr+"applycontactmap'>Display ",s+="",s+=e.htmlCls.divStr+"dl_hbonds' class='"+n+"'>",s+="1. Choose interaction types and their thresholds: ",s+="
"+e.htmlCls.buttonStr+"hbondWindow'>Highlight Interactions in TableSort Interactions on: "+e.htmlCls.buttonStr+"sortSet1'> Set 1"+e.htmlCls.buttonStr+"sortSet2' style='margin-left:20px'>Set 2
",s+="
"+e.htmlCls.buttonStr+"hbondLineGraph'>2D Interaction Network to show interactions between two lines of residue nodes
",s+="
"+e.htmlCls.buttonStr+"hbondScatterplot'>2D Interaction Map to show interactions as map
",r=':
"+e.htmlCls.buttonStr+"hbondGraph'>2D Graph(Force-Directed) to show interactions with strength parameters in 0-200:",s+='
Helix or Sheet'+r+e.pre+'dist_ss" size="4" value="100">
',s+="
Coil or Nucleotide"+r+e.pre+'dist_coil" size="4" value="50">
1. Select sets below or use your current selection.
",s+=" ",s+="
2. "+e.htmlCls.buttonStr+"applyRealignByStruct_tmalign'>Realign with TM-align"+e.htmlCls.buttonStr+"applyRealignByStruct' style='margin-left:30px'>Realign with VAST
",s+="",s+=e.htmlCls.divStr+"dl_realigntwostru' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select sets below or use your current selection: ",s+=" ",s+="2. Overall maximum RMSD: "+e.htmlCls.inputTextStr+"id='"+e.pre+"maxrmsd' value='30' size='2'> Å
",s+="
3. "+e.htmlCls.buttonStr+"applyRealignByStruct_vastplus'>VAST+ Alignment based on TM-align
",s+='',s+="",s+=e.htmlCls.divStr+"dl_elecmap2fofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymap2fofc'>Display"+e.htmlCls.buttonStr+"elecmapNo2'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_elecmapfofc' class='"+n+"'>",s+="Contour at: σ"+e.htmlCls.buttonStr+"applymapfofc'>Display"+e.htmlCls.buttonStr+"elecmapNo3'>Remove Map",s+="",s+=e.htmlCls.divStr+"dl_emmap' class='"+n+"'>",s+="Contour at: % of maximum EM values "+e.htmlCls.buttonStr+"applyemmap'>Display"+e.htmlCls.buttonStr+"emmapNo2'>Remove EM Map",s+="",s+=e.htmlCls.divStr+"dl_aroundsphere' class='"+n+"'>",s+=e.htmlCls.divNowrapStr+"1. Select the first set:",s+=" ",s+=e.htmlCls.divNowrapStr+"2. Sphere with a radius: "+e.htmlCls.inputTextStr+"id='"+e.pre+"radius_aroundsphere' value='4' size='2'> Å ",s+=e.htmlCls.divNowrapStr+"3. Select the second set to apply the sphere:",s+=" ",s+=e.htmlCls.divNowrapStr+"4. "+e.htmlCls.buttonStr+"applypick_aroundsphere'>Display the sphere around the first set of atoms ",s+="
"+e.htmlCls.buttonStr+"sphereExport'>Save interacting/contacting residue pairs in a file
",s+="",s+=e.htmlCls.divStr+"dl_adjustmem' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Extracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"extra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. intracellular membrane Z-axis position: "+e.htmlCls.inputTextStr+"id='"+e.pre+"intra_mem_z' value='' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_adjustmem'>Display the adjusted membranes ",s+="",s+=e.htmlCls.divStr+"dl_selectplane' class='"+n+"'>",s+="Note: The membranes are parallel to the X-Y plane. The center of the membranes is at Z = 0.
",s+=e.htmlCls.divNowrapStr+"1. Z-axis position of the first X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z1' value='15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"2. Z-axis position of the second X-Y plane: "+e.htmlCls.inputTextStr+"id='"+e.pre+"selectplane_z2' value='-15' size='3'> Å ",s+=e.htmlCls.divNowrapStr+"3. "+e.htmlCls.buttonStr+"apply_selectplane'>Save the region between the planes to Defined Sets ",s+="",s+=e.htmlCls.divStr+"dl_addlabel' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor' value='"+"#ffff00' size=4> ",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"4. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'4. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"5. "+e.htmlCls.buttonStr+"applypick_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_addlabelselection' class='"+n+"'>",s+="1. Text: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labeltext2' value='Text' size=4> ",s+="2. Size: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelsize2' value='18' size=4 maxlength=2> ",s+="3. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolor2' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"4. "+e.htmlCls.buttonStr+"applyselection_labels'>Display",s+="",s+=e.htmlCls.divStr+"dl_labelColor' class='"+n+"'>",s+="Color for all labels: "+e.htmlCls.inputTextStr+"id='"+e.pre+"labelcolorall' value='"+"#ffff00' size=4>
",s+=e.htmlCls.spanNowrapStr+e.htmlCls.buttonStr+"applylabelcolor'>Display",s+="",s+=e.htmlCls.divStr+"dl_distance' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Line Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"distancecolor' value='"+"#ffff00' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_measuredistance'>Display",s+="",s+=e.htmlCls.divStr+"dl_stabilizer' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. Color: "+e.htmlCls.inputTextStr+"id='"+e.pre+"stabilizercolor' value='ffffff' size=4> ",s+=e.htmlCls.spanNowrapStr+"3. "+e.htmlCls.buttonStr+"applypick_stabilizer'>Add",s+="",s+=e.htmlCls.divStr+"dl_disttwosets' class='"+n+"'>",s+=e.htmlCls.spanNowrapStr+"1. Select two sets ",s+="
",s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applydisttable'>Distances in Table",s+="",s+=e.htmlCls.divStr+"dl_stabilizer_rm' class='"+n+"'>",e.utilsCls.isMobile()?s+=e.htmlCls.spanNowrapStr+"1. Touch TWO atoms ":s+=e.htmlCls.spanNowrapStr+'1. Pick TWO atoms while holding "Alt" key ',s+=e.htmlCls.spanNowrapStr+"2. "+e.htmlCls.buttonStr+"applypick_stabilizer_rm'>Remove",s+="",s+=e.htmlCls.divStr+"dl_thickness' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("3dprint"),s+="",s+=e.htmlCls.divStr+"dl_thickness2' class='"+n+"'>",s+=e.htmlCls.setHtmlCls.setThicknessHtml("style"),s+="",s+=e.htmlCls.divStr+"dl_menupref' class='"+n+"'>",s+="Note: The following parameters will be saved in cache. You just need to set them once.
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref' style='margin-left:30px'>Save Preferences
",s+="
",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"apply_menupref2'>Apply",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref2' style='margin-left:30px'>Reset to Simple Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"reset_menupref_all2' style='margin-left:30px'>Reset to All Menus",s+=e.htmlCls.spanNowrapStr+""+e.htmlCls.buttonStr+"savepref2' style='margin-left:30px'>Save Preferences",s+="",s+=e.htmlCls.divStr+"dl_addtrack' class='"+n+"'>",s+=" ",s+=e.htmlCls.divStr+"dl_addtrack_tabs' style='border:0px;'>",s+="
The full protein sequences with gaps are listed one by one. The sequence of the structure is listed at the top. If there are non-gap residues(e.g., from RefSeq) outside of the sequence of the structure, please remove them. Each sequence has a title line starting with \">\".
",s+="FASTA alignment sequences: ",s+="
",s+="Position of the first residue in Sequences & Annotations window: "+e.htmlCls.inputTextStr+"id='"+e.pre+"fasta_startpos' value='1' size=2>
",s+='Track Text (e.g., "2 G, 5-6 RR" defines a character "G" at the position 2 and two continuous characters "RR" at positions from 5 to 6. The starting position is 1): ',s+="
",s+="",s+=e.htmlCls.divStr+"dl_copyurl' style='width:520px;' class='"+n+"'>",s+='Please copy one of the URLs below. They show the same result. (To add a title to share link, click "Windows > Your Note" and click "File > Share Link" again.)
',s+="Original URL with commands:
",s+="Lifelong Short URL:(To replace this URL, send a pull request to update share.html at iCn3D GitHub) "+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url' value='' style='width:100%'>
",s+='Lifelong Short URL + Window Title:(To update the window title, click "Analysis > Your Note/Window Title".) '+e.htmlCls.inputTextStr+"id='"+e.pre+"short_url_title' value='' style='width:100%'>
",s+="",s+='',s+="",s+=e.htmlCls.divStr+"dl_area' class='"+n+"'>",s+="Solvent Accessible Surface Area(SASA) calculated using the EDTSurf algorithm: ",s+='(0-20% out is considered "in". 50-100% out is considered "out".)
Color each residue based on the percentage of solvent accessilbe surface area. The color ranges from blue, to white, to red for a percentage of 0, 35(variable), and 100, respectively.
"+t.htmlCls.space3+t.htmlCls.buttonStr+"command_apply"+s+"'>Save Selection to Defined Sets
",n+="
",n+="
",n+="
",n+='Specification Tips:
',n+=t.htmlCls.divStr+"specguide"+s+"' style='display:none; width:500px' class='icn3d-box'>",n+='Specification: In the selection "$1HHO,4N7N.A,B,C:5-10,LV,3AlaVal,chemicals@CA,C,C*":',n+='
"$1HHO,4N7N" uses "$" to indicate structure selection. ',n+='
".A,B,C" uses "." to indicate chain selection. ',n+='
":5-10,LV,3LeuVal,chemicals" uses the colon ":" to indicate residue selection. Residue selection could be residue number(5-10), one-letter IUPAC residue name abbreviations(LV), three-letter residue names(AlaVal, "3" indicates each residue name has three letters), or predefined names: "proteins", "nucleotides", "chemicals", "ions", and "water". IUPAC abbreviations can be written either as a contiguous string(e.g., ":LV"), in order to find all instances of that sequence in the structure, or they can be separated by commas(e.g., ":L,V") to select all residues of a given type in the structure(in the latter case, select all Leucine and Valine in the structure). ',n+='
"@CA,C,C*" uses "@" to indicate atom name selection. "C*" selects any atom names starting with "C". ',n+='
Partial definition is allowed, e.g., ":1-10" selects all residue IDs 1-10 in all chains. ',n+='
Different selections can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, ":1-10 or :K" selects all residues 1-10 and all Lys residues. ":1-10 and :K" selects all Lys residues in the range of residue number 1-10. ":1-10 or not :K" selects all residues 1-10, which are not Lys residues. ',n+='
The wild card character "X" or "x" can be used to represent any character.',n+="
",n+="Set Operation:",n+='
Users can select multiple sets in the menu "Select > Defined Sets". ',n+='
Different sets can be unioned(with "or", default), intersected(with "and"), or negated(with "not"). For example, if the "Defined Sets" menu has four sets ":1-10", ":11-20", ":5-15", and ":7-8", the command "saved atoms :1-10 or :11-20 and :5-15 not :7-8" unions all residues 1-10 and 11-20 to get the residues 1-20, then intersects with the residues 5-15 to get the residues 5-15, then exclude the residues 7-8 to get the final residues 5-6 and 9-15.
',n+="Full commands in url or command window:",n+="
Select without saving the set: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* ",n+="
Select and save: select $1HHO,4N7N.A,B,C:5-10,LV,chemicals@CA,C,C* | name my_name
",n+="",n+="
",n+="",n}getOptionHtml(e,t){let s=this.icn3dui;s.icn3d;let i="";for(let n=0,l=e.length;n"+l+"":s.htmlCls.optionStr+"'"+l+"'>"+l+""}return i}setColorHints(){let e=this.icn3dui;e.icn3d;let t="";return t+=e.htmlCls.divNowrapStr+'Green: H-Bonds; ',t+='Cyan: Salt Bridge/Ionic; ',t+='Grey: contacts',t+=e.htmlCls.divNowrapStr+'Magenta: Halogen Bonds; ',t+='Red: π-Cation; ',t+='Blue: π-Stacking',t}setThicknessHtml(e){let t=this.icn3dui,s=t.icn3d,i="",n="3dprint"==e?"1":"0.1",l="3dprint"==e?"1.2":"0.3",r="3dprint"==e?"0.8":"0.4",o="3dprint"==e?"0.8":"0.4",a="3dprint"==e?"1":"0.4",d="3dprint"==e?"0.6":"0.3",c="3dprint"==e?"1":"0.2",h="3dprint"==e?"2":"1.3",p="3dprint"==e?"1.4":"0.8",m=40,u=.6,g=.4,f=.2,b=0,C=1,y=0;if("style"==e){if(""!=this.getCookie("shininess")&&(m=parseFloat(this.getCookie("shininess"))),""!=this.getCookie("light1")&&(u=parseFloat(this.getCookie("light1")),g=parseFloat(this.getCookie("light2")),f=parseFloat(this.getCookie("light3"))),""!=this.getCookie("lineRadius")){n=parseFloat(this.getCookie("lineRadius")),l=parseFloat(this.getCookie("coilWidth")),r=parseFloat(this.getCookie("cylinderRadius"));let e=this.getCookie("crosslinkRadius");o=isNaN(e)?s.crosslinkRadius:parseFloat(e),a=parseFloat(this.getCookie("traceRadius")),d=parseFloat(this.getCookie("dotSphereScale")),c=parseFloat(this.getCookie("ribbonthickness")),h=parseFloat(this.getCookie("helixSheetWidth")),p=parseFloat(this.getCookie("nucleicAcidWidth"))}""!=this.getCookie("glycan")&&(b=parseFloat(this.getCookie("glycan"))),""!=this.getCookie("membrane")&&(C=parseFloat(this.getCookie("membrane"))),""!=this.getCookie("cmdwindow")&&(y=parseFloat(this.getCookie("cmdwindow"))),i+="Note: The following parameters will be saved in cache. You just need to set them once.
",i+="1. Shininess: "+t.htmlCls.inputTextStr+"id='"+t.pre+"shininess' value='"+m+"' size=4>"+t.htmlCls.space3+"(for the shininess of the 3D objects, default 40)
",i+="2. Three directional lights: ",i+="Key Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light1' value='"+u+"' size=4>"+t.htmlCls.space3+"(for the light strength of the key light, default 0.6) ",i+="Fill Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light2' value='"+g+"' size=4>"+t.htmlCls.space3+"(for the light strength of the fill light, default 0.4) ",i+="Back Light: "+t.htmlCls.inputTextStr+"id='"+t.pre+"light3' value='"+f+"' size=4>"+t.htmlCls.space3+"(for the light strength of the back light, default 0.2)
",n+=s.htmlCls.divStr+"seqguide"+e+"' style='display:none; white-space:normal;' class='icn3d-box'>"),n+=this.getSelectionHints();return n+="Residue labeling: standard residue with coordinates: UPPER case letter; nonstandard residue with coordinates: the first UPPER case letter plus a period except that water residue uses the letter 'O'; residue missing coordinates: lower case letter."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}setAlignSequenceGuide(e,t){let s=this.icn3dui,i=s.icn3d,n="";let l=i&&i.defNames2Atoms?Object.keys(i.defNames2Atoms).length:1;n+='
",n+=s.htmlCls.divStr+"alignseqguide' style='display:none; white-space:normal;' class='icn3d-box'>",n+=this.getSelectionHints();return n+="Residue labeling: aligned residue with coordinates: UPPER case letter; non-aligned residue with coordinates: lower case letter which can be highlighted; residue missing coordinates: lower case letter which can NOT be highlighted."+(s.utilsCls.isMac()&&!s.utilsCls.isMobile()?"
Turn on scroll bar: System preferences -> General -> show scroll bars -> check Always":"")+" ",n}getSelectionHints(){let e=this.icn3dui;e.icn3d;let t="";if(e.utilsCls.isMobile())t+='Select Aligned Sequences: touch to select, touch again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection. ';else{t+='Select on 1D sequences: drag to select, drag again to deselect, multiple selection is allowed without Ctrl key, click "Save Selection" to save the current selection.
',t+="Select on 2D interaction diagram: click on the nodes or lines. The nodes are chains and can be united with the Ctrl key. The lines are interactions and can NOT be united. Each click on the lines selects half of the lines, i.e., select the interacting residues in one of the two chains.
",t+="Select on 3D structures: "+(e.utilsCls.isMobile()?"use finger to pick":'hold "Alt" and use mouse to pick')+', click the second time to deselect, hold "Ctrl" to union selection, hold "Shift" to select a range, press the up/down arrow to switch among atom/residue/strand/chain/structure, click "Save Selection" to save the current selection.
',t+='Save the current selection(either on 3D structure, 2D interactions, or 1D sequence): open the menu "Select -> Save Selection", specify the name and description for the selection, and click "Save".
";return"delphi"==e?s.cfg.cid?i+="Note: Partial charges(MMFF94) are from PubChem Compound SDF files.
":(i+="Note: Only the selected residues are used for DelPhi potential calculation by solving linear Poisson-Boltzmann equation.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+=" The hydrogens and partial charges of proteins and nucleotides are added using DelPhiPKa with the Amber charge and size files. The hydrogens of ligands are added using Open Babel. The partial charges of ligands are calculated using Antechamber with the Gasteiger charge method. All partial charges are calculated at pH 7.
",i+='Lipids are treated as ligands. Please use "HETATM" instead of "ATOM " for each lipid atom in your PDB file. Each phosphate in lipids is assigned with a charge of -1. You can download PQR and modify it, or prepare your PQR file using other tools. Then load the PQR file at the menu "Analysis > Load PQR/Potential".
',i+="
"):(i+="Note: Always load a PDB file before loading a PQR or DelPhi potential file.",i+='
',i+=s.htmlCls.divStr+t+"' style='display:none;'>",i+='The PDB file can be loaded in the URL with "pdbid=" or at "File > Open File". The PQR file can be prepared at the menu "Analysis > Download PQR" with your modification or using other tools. The DelPhi potential file can be calculated at DelPhi Web Server and be exported as a Cube file. ',"url"==e&&(i+="The PQR or potential file can be accessed in a URL if it is located in the same host as iCn3D."),i+="
",i+=""),i+="",i}getPotentialHtml(e,t){let s=this.icn3dui;s.icn3d;let i,n,l,r,o,a="";r="Equipotential Map",o="Surface with Potential","delphi"==e?n="delphi":"local"==e?(i="pqr",n="phi",l="cube"):"url"==e&&(i="pqrurl",n="phiurl",l="cubeurl"),a+=s.htmlCls.divStr+"dl_"+n+"' class='"+t+"'>",a+=s.htmlCls.divStr+"dl_"+n+"_tabs' style='border:0px;'>",a+="
",d=""+s.htmlCls.buttonStr+n+"mapNo'>Remove Map",a+=s.htmlCls.divStr+n+"tab1_"+i+"2'>",a+=this.addGsizeSalt(i)+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file'>
"+s.htmlCls.buttonStr+"reload_"+i+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file'>
"+s.htmlCls.buttonStr+"reload_"+n+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=s.htmlCls.divStr+n+"tab1_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file'>
"+s.htmlCls.buttonStr+"reload_"+l+"file' style='margin-top: 6px;'>Equipotential Map"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab1_foot"),a+="",a+=s.htmlCls.divStr+n+"tab2'>","delphi"==e&&(a+=this.addGsizeSalt(n)+" "),a+="Surface with max potential at: kT/e(25.6mV at 298K)
",d=""+s.htmlCls.buttonStr+n+"mapNo2'>Remove Surface",a+=s.htmlCls.divStr+n+"tab2_"+i+"2'>",a+=this.addGsizeSalt(i+"2")+" ",a+="PQR URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+i+"file2'>
"+s.htmlCls.buttonStr+"reload_"+i+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+n+"2'>",a+="Phi URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+n+"file2'>
"+s.htmlCls.buttonStr+"reload_"+n+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=s.htmlCls.divStr+n+"tab2_"+l+"2'>",a+="Cube URL in the same host: "+s.htmlCls.inputTextStr+"id='"+s.pre+l+"file2'>
"+s.htmlCls.buttonStr+"reload_"+l+"file2' style='margin-top: 6px;'>Surface with Potential"+d,a+=""),a+=" "+this.getFootHtml(e,n+"tab2_foot"),a+="",a+="",a+="",a}async exportPqr(e){let t=this.icn3dui,s=t.icn3d,i={},n={},l=t.hashUtilsCls.intHash(s.dAtoms,s.hAtoms);for(let e in l)s.atoms[e],s.ions.hasOwnProperty(e)?i[e]=1:n[e]=1;let r=e?"pdb":"pqr";if(t.cfg.cid){let t="",l=!e;t+=s.saveFileCls.getAtomPDB(n,l)+s.saveFileCls.getAtomPDB(i,l);let o=s.inputid?s.inputid:"custom";s.saveFileCls.saveFile(o+"_icn3d."+r,"text",[t])}else{if(t.utilsCls.isCalphaPhosOnly(t.hashUtilsCls.hash2Atoms(n,s.atoms)))return void alert("The potential will not be shown because the side chains are missing in the structure...");let l="";l+=s.saveFileCls.getAtomPDB(n),l+=s.saveFileCls.getAtomPDB(i,!0,void 0,!0);let o="https://www.ncbi.nlm.nih.gov/Structure/delphi/delphi.fcgi",a={pdb2pqr:l,pdbid:t.cfg.cid?t.cfg.cid:Object.keys(s.structures).toString()},d=await t.getAjaxPostPromise(o,a,!0,void 0,void 0,!0,"text");if(e){let e=d.split("\n"),s="";for(let i=0,n=e.length;i PNG Image" in the Data menu...');else if(-1!=l){let t=e.substr(l+n.length);s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1),window.open(t,"_self")}else if(-1!=o){let n="Start of data file======\n",l=e.indexOf(n);i.bInputfile=-1!=l;let a,d=t?t.replace(/;/g,"\n"):"";if(i.bInputfile){let t=e.indexOf("End of data file======\n"),s=e.substr(l+n.length,t-l-n.length);i.InputfileData=i.InputfileData?i.InputfileData+"\nENDMDL\n"+s:s;let c="Start of type file======\n",h=e.indexOf(c),p=e.indexOf("End of type file======\n"),m=e.substr(h+c.length,p-h-c.length-1);i.InputfileType=m;let u=e.indexOf("End of state file======\n");a=e.substr(o+r.length,u-o-r.length),a=decodeURIComponent(a+"\n"+d),"pdb"===m?(await i.pdbParserCls.loadPdbData(s),i.commands=[],i.optsHistory=[]):("mol2"===m?await i.mol2ParserCls.loadMol2Data(s):"sdf"===m?await i.sdfParserCls.loadSdfData(s):"xyz"===m?await i.xyzParserCls.loadXyzData(s):"mmcif"===m&&await i.mmcifParserCls.loadMmcifData(s),i.commands=[],i.optsHistory=[])}else{let t=e.indexOf("End of state file======\n");a=e.substr(o+r.length,t-o-r.length),a=decodeURIComponent(a+"\n"+d),i.commands=[],i.optsHistory=[]}await i.loadScriptCls.loadScript(a,!0),s.htmlCls.clickMenuCls.setLogCmd("load iCn3D PNG image "+$("#"+s.pre+"pngimage").val(),!1)}}fileSupport(){window.File&&window.FileReader&&window.FileList&&window.Blob||alert("The File APIs are not fully supported in this browser.")}getLinkColor(){let e="";return e+=", linkmap: {\n",e+='3: {"type": "peptidebond", "c":""},\n',e+='4: {"type": "ssbond", "c":"FFA500"},\n',e+='5: {"type": "ionic", "c":"0FF"},\n',e+='6: {"type": "ionicInside", "c":"FFF"},\n',e+='11: {"type": "contact", "c":"888"},\n',e+='12: {"type": "contactInside", "c":"FFF"},\n',e+='13: {"type": "hbond", "c":"0F0"},\n',e+='14: {"type": "hbondInside", "c":"FFF"},\n',e+='15: {"type": "clbond", "c":"006400"},\n',e+='17: {"type": "halogen", "c":"F0F"},\n',e+='18: {"type": "halogenInside", "c":"FFF"},\n',e+='19: {"type": "pication", "c":"F00"},\n',e+='20: {"type": "picationInside", "c":"FFF"},\n',e+='21: {"type": "pistacking", "c":"00F"},\n',e+='22: {"type": "pistackingInside", "c":"FFF"}\n',e+="}}\n",', linkmap: {\n3: {"type": "peptidebond", "c":""},\n4: {"type": "ssbond", "c":"FFA500"},\n5: {"type": "ionic", "c":"0FF"},\n6: {"type": "ionicInside", "c":"FFF"},\n11: {"type": "contact", "c":"888"},\n12: {"type": "contactInside", "c":"FFF"},\n13: {"type": "hbond", "c":"0F0"},\n14: {"type": "hbondInside", "c":"FFF"},\n15: {"type": "clbond", "c":"006400"},\n17: {"type": "halogen", "c":"F0F"},\n18: {"type": "halogenInside", "c":"FFF"},\n19: {"type": "pication", "c":"F00"},\n20: {"type": "picationInside", "c":"FFF"},\n21: {"type": "pistacking", "c":"00F"},\n22: {"type": "pistackingInside", "c":"FFF"}\n}}\n'}setCookieForThickness(){let e=this.icn3dui,t=e.icn3d;if(!e.bNode){let e=3650;this.setCookie("lineRadius",t.lineRadius,e),this.setCookie("coilWidth",t.coilWidth,e),this.setCookie("cylinderRadius",t.cylinderRadius,e),this.setCookie("crosslinkRadius",t.crosslinkRadius,e),this.setCookie("traceRadius",t.traceRadius,e),this.setCookie("dotSphereScale",t.dotSphereScale,e),this.setCookie("ribbonthickness",t.ribbonthickness,e),this.setCookie("helixSheetWidth",t.helixSheetWidth,e),this.setCookie("nucleicAcidWidth",t.nucleicAcidWidth,e)}}setLineThickness(e,t){let s=this.icn3dui,i=s.icn3d;if(i.bSetThickness=!0,"style"==e&&(t&&($("#"+s.pre+"shininess").val("40"),$("#"+s.pre+"light1").val("0.6"),$("#"+s.pre+"light2").val("0.4"),$("#"+s.pre+"light3").val("0.2"),$("#"+s.pre+"glycan").val("0"),$("#"+s.pre+"membrane").val("1"),$("#"+s.pre+"cmdwindow").val("0")),i.shininess=parseFloat($("#"+s.pre+"shininess").val()),i.light1=parseFloat($("#"+s.pre+"light1").val()),i.light2=parseFloat($("#"+s.pre+"light2").val()),i.light3=parseFloat($("#"+s.pre+"light3").val()),i.bGlycansCartoon=parseInt($("#"+s.pre+"glycan").val()),i.bMembrane=parseInt($("#"+s.pre+"membrane").val()),i.bCmdWindow=parseInt($("#"+s.pre+"cmdwindow").val())),t&&($("#"+s.pre+"linerad_"+e).val(.1),$("#"+s.pre+"coilrad_"+e).val(.3),$("#"+s.pre+"stickrad_"+e).val(.4),$("#"+s.pre+"crosslinkrad_"+e).val(.4),$("#"+s.pre+"tracerad_"+e).val(.4),$("#"+s.pre+"ballscale_"+e).val(.3),$("#"+s.pre+"ribbonthick_"+e).val(.2),$("#"+s.pre+"prtribbonwidth_"+e).val(1.3),$("#"+s.pre+"nucleotideribbonwidth_"+e).val(.8)),i.lineRadius=parseFloat($("#"+s.pre+"linerad_"+e).val()),i.coilWidth=parseFloat($("#"+s.pre+"coilrad_"+e).val()),i.cylinderRadius=parseFloat($("#"+s.pre+"stickrad_"+e).val()),i.crosslinkRadius=parseFloat($("#"+s.pre+"crosslinkrad_"+e).val()),i.traceRadius=parseFloat($("#"+s.pre+"tracerad_"+e).val()),i.dotSphereScale=parseFloat($("#"+s.pre+"ballscale_"+e).val()),i.ribbonthickness=parseFloat($("#"+s.pre+"ribbonthick_"+e).val()),i.helixSheetWidth=parseFloat($("#"+s.pre+"prtribbonwidth_"+e).val()),i.nucleicAcidWidth=parseFloat($("#"+s.pre+"nucleotideribbonwidth_"+e).val()),!s.bNode){let e=3650;this.setCookie("shininess",i.shininess,e),this.setCookie("light1",i.light1,e),this.setCookie("light2",i.light2,e),this.setCookie("light3",i.light3,e),this.setCookie("glycan",i.bGlycansCartoon,e),this.setCookie("membrane",i.bMembrane,e),this.setCookie("cmdwindow",i.bCmdWindow,e)}if(this.setCookieForThickness(),e=t){let e="reset thickness";s.htmlCls.clickMenuCls.setLogCmd(e,!0),i.bSetThickness=!1,i.threeDPrintCls.resetAfter3Dprint()}else s.htmlCls.clickMenuCls.setLogCmd("set thickness | linerad "+i.lineRadius+" | coilrad "+i.coilWidth+" | stickrad "+i.cylinderRadius+" | crosslinkrad "+i.crosslinkRadius+" | tracerad "+i.traceRadius+" | ribbonthick "+i.ribbonthickness+" | proteinwidth "+i.helixSheetWidth+" | nucleotidewidth "+i.nucleicAcidWidth+" | ballscale "+i.dotSphereScale,!0),s.htmlCls.clickMenuCls.setLogCmd("set glycan "+i.bGlycansCartoon,!0),s.htmlCls.clickMenuCls.setLogCmd("set membrane "+i.bMembrane,!0),s.htmlCls.clickMenuCls.setLogCmd("set cmdwindow "+i.bCmdWindow,!0);i.drawCls.draw()}setCookie(e,t,s){let i=new Date;i.setTime(i.getTime()+24*s*60*60*1e3);let n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}updateSurfPara(e){let t=this.icn3dui,s=t.icn3d;s.phisurftype=$("#"+t.pre+e+"surftype").val(),s.phisurfop=$("#"+t.pre+e+"surfop").val(),s.phisurfwf=$("#"+t.pre+e+"surfwf").val()}exportPdb(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getAtomPDB(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d.pdb","text",[s])}return s}exportSecondary(){let e=this.icn3dui,t=e.icn3d,s="",i=e.hashUtilsCls.intHash(t.dAtoms,t.hAtoms);if(s+=t.saveFileCls.getSecondary(i),!e.bNode){let e=t.inputid?t.inputid:"custom";t.saveFileCls.saveFile(e+"_icn3d_ss.txt","text",[s])}return s}}class g{constructor(e){let t=e;this.icn3dui=e,this.cfg=this.icn3dui.cfg,this.opts={},this.opts.background="black",this.allMenus={},this.allMenusSel={},this.simpleMenus={},this.shownMenus={},this.WIDTH=400,this.HEIGHT=400,this.RESIDUE_WIDTH=10,t.utilsCls.isMobile()||this.cfg.mobilemenu?this.MENU_HEIGHT=0:this.MENU_HEIGHT=40,this.LOG_HEIGHT=65,this.MENU_WIDTH=750,this.LESSWIDTH=20,this.LESSWIDTH_RESIZE=20,this.LESSHEIGHT=20,this.width2d=200,this.CMD_HEIGHT=.8*this.LOG_HEIGHT,this.EXTRAHEIGHT=this.MENU_HEIGHT+this.CMD_HEIGHT,null!=this.cfg.showmenu&&0==this.cfg.showmenu&&(this.EXTRAHEIGHT-=this.MENU_HEIGHT),null!=this.cfg.showcommand&&0==this.cfg.showcommand&&(this.EXTRAHEIGHT-=this.CMD_HEIGHT),this.GREY8="#AAAAAA",this.GREYB="#CCCCCC",this.GREYC="#DDDDDD",this.GREYD="#EEEEEE",this.ORANGE="#FFA500",this.themecolor="blue",this.defaultValue=1,this.ssValue=3,this.coilValue=3,this.contactValue=11,this.contactInsideValue=12,this.hbondValue=13,this.hbondInsideValue=14,this.ssbondValue=4,this.ionicValue=5,this.ionicInsideValue=6,this.clbondValue=15,this.halogenValue=17,this.halogenInsideValue=18,this.picationValue=19,this.picationInsideValue=20,this.pistackingValue=21,this.pistackingInsideValue=22,this.contactColor="888",this.contactInsideColor="FFF",this.hbondColor="0F0",this.hbondInsideColor="FFF",this.ssbondColor="FFA500",this.ionicColor="0FF",this.ionicInsideColor="FFF",this.clbondColor="006400",this.halogenColor="F0F",this.halogenInsideColor="FFF",this.picationColor="F00",this.picationInsideColor="FFF",this.pistackingColor="00F",this.pistackingInsideColor="FFF",this.hideedges=1,this.force=4,this.simulation=void 0,this.baseUrl=window&&window.location&&"structure.ncbi.nlm.nih.gov"==window.location.hostname?"https://structure.ncbi.nlm.nih.gov/Structure/":"https://www.ncbi.nlm.nih.gov/Structure/",this.divStr="
",this.spanNowrapStr="",this.inputTextStr="=2.0 are supported.")));const a=new pe(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===r[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(l),a.setPlugins(r),a.parse(s,i)}parseAsync(e,t){const s=this;return new Promise((function(i,n){s.parse(e,t,i,n)}))}}function b(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class y{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,i=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,l)}}class R{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,i=s.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const l=n.extensions[t],r=i.images[l.source];let o=s.textureLoader;if(r.uri){const e=s.options.manager.getHandler(r.uri);null!==e&&(o=e)}return this.detectSupport().then((function(n){if(n)return s.loadTextureImage(e,l.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const s=e.byteOffset||0,i=e.byteLength||0,l=e.count,r=e.byteStride,o=new ArrayBuffer(l*r),a=new Uint8Array(t[0],s,i);return n.decodeGltfBuffer(new Uint8Array(o),l,r,a,e.mode,e.filter),o}))}return null}}const I="glTF",T=1313821514,M=5130562;class P{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==I)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-12,i=new DataView(e,12);let n=0;for(;n",t).replace("#include ",s).replace("#include ",i).replace("#include ",n).replace("#include ",l)},Object.defineProperties(this,{specular:{get:function(){return r.specular.value},set:function(e){r.specular.value=e}},specularMap:{get:function(){return r.specularMap.value},set:function(e){r.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return r.glossiness.value},set:function(e){r.glossiness.value=e}},glossinessMap:{get:function(){return r.glossinessMap.value},set:function(e){r.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class L{constructor(){this.name=C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return F}extendParams(e,t,s){const i=t.extensions[this.name];e.color=new Color(1,1,1),e.opacity=1;const n=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&n.push(s.assignTexture(e,"map",i.diffuseTexture,sRGBEncoding)),e.emissive=new Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;n.push(s.assignTexture(e,"glossinessMap",t)),n.push(s.assignTexture(e,"specularMap",t,sRGBEncoding))}return Promise.all(n)}createMaterial(e){const t=new F(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class N{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class U extends THREE.Interpolant{constructor(e,t,s,i){super(e,t,s,i)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=s[n+e];return t}}U.prototype.beforeStart_=U.prototype.copySampleValue_,U.prototype.afterEnd_=U.prototype.copySampleValue_,U.prototype.interpolate_=function(e,t,s,i){const n=this.resultBuffer,l=this.sampleValues,r=this.valueSize,o=2*r,a=3*r,d=i-t,c=(s-t)/d,h=c*c,p=h*c,m=e*a,u=m-a,g=-2*p+3*h,f=p-h,b=1-g,C=f-h+c;for(let e=0;e!==r;e++){const t=l[u+e+r],s=l[u+e+o]*d,i=l[m+e+r],a=l[m+e]*d;n[e]=b*t+C*s+g*i+f*a}return n};const q=new THREE.Quaternion;class j extends U{interpolate_(e,t,s,i){const n=super.interpolate_(e,t,s,i);return q.fromArray(n).normalize().toArray(n),n}}const B=0,z=1,G=2,V=3,W=4,Y=5,X=6,K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},J={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},Z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ee={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},te={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},se={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},ie="OPAQUE",ne="MASK",le="BLEND";function re(e,t,s){for(const i in s.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=s.extensions[i])}function oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ae(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,i=t.weights.length;s{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,i]of e.children.entries())n(i,t.children[s])};return n(s,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&m.setY(t,c[e*l+1]),l>=3&&m.setZ(t,c[e*l+2]),l>=4&&m.setW(t,c[e*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,n=t.images[i];let l=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(l=e)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const i=this,n=this.json,l=n.textures[e],r=n.images[t],o=(r.uri||r.bufferView)+":"+l.sampler;if(this.textureCache[o])return this.textureCache[o];const a=this.loadImageSource(t,s).then((function(t){t.flipY=!1,l.name&&(t.name=l.name);const s=(n.samplers||{})[l.sampler]||{};return t.magFilter=Q[s.magFilter]||LinearFilter,t.minFilter=Q[s.minFilter]||LinearMipmapLinearFilter,t.wrapS=J[s.wrapS]||RepeatWrapping,t.wrapT=J[s.wrapT]||RepeatWrapping,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=a,a}loadImageSource(e,t){const s=this,i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const l=i.images[e],r=self.URL||self.webkitURL;let o=l.uri||"",a=!1;if(void 0!==l.bufferView)o=s.getDependency("bufferView",l.bufferView).then((function(e){a=!0;const t=new Blob([e],{type:l.mimeType});return o=r.createObjectURL(t),o}));else if(void 0===l.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(o).then((function(e){return new Promise((function(s,i){let l=s;!0===t.isImageBitmapLoader&&(l=function(e){const t=new Texture(e);t.needsUpdate=!0,s(t)}),t.load(THREE.LoaderUtils.resolveURL(e,n.path),l,void 0,i)}))})).then((function(e){var t;return!0===a&&r.revokeObjectURL(o),e.userData.mimeType=l.mimeType||((t=l.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=d,d}assignTexture(e,t,s,i){const n=this;return this.getDependency("texture",s.index).then((function(l){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[C.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(l);l=n.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(l,e),n.associations.set(l,t)}}return void 0!==i&&(l.encoding=i),e[t]=l,l}))}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const i=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,l=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material.prototype.copy.call(t,s),t.color.copy(s.color),this.cache.add(e,t)),s=t}if(i||n||l){let e="ClonedMaterial:"+s.uuid+":";s.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),i&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),l&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),l&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}s.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=s}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,i=this.extensions,n=s.materials[e];let l;const r={},o=n.extensions||{},a=[];if(o[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else if(o[C.KHR_MATERIALS_UNLIT]){const e=i[C.KHR_MATERIALS_UNLIT];l=e.getMaterialType(),a.push(e.extendParams(r,n,t))}else{const s=n.pbrMetallicRoughness||{};if(r.color=new Color(1,1,1),r.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;r.color.fromArray(e),r.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(r,"map",s.baseColorTexture,sRGBEncoding)),r.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,r.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(r,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(r,"roughnessMap",s.metallicRoughnessTexture))),l=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),a.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,r)}))))}!0===n.doubleSided&&(r.side=DoubleSide);const d=n.alphaMode||ie;if(d===le?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===ne&&(r.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"normalMap",n.normalTexture)),r.normalScale=new Vector2(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;r.normalScale.set(e,e)}return void 0!==n.occlusionTexture&&l!==MeshBasicMaterial&&(a.push(t.assignTexture(r,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(r.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&l!==MeshBasicMaterial&&(r.emissive=(new Color).fromArray(n.emissiveFactor)),void 0!==n.emissiveTexture&&l!==MeshBasicMaterial&&a.push(t.assignTexture(r,"emissiveMap",n.emissiveTexture,sRGBEncoding)),Promise.all(a).then((function(){let s;return s=l===F?i[C.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(r):new l(r),n.name&&(s.name=n.name),oe(s,n),t.associations.set(s,{materials:e}),n.extensions&&re(i,s,n),s}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");let s=t;for(let e=1;this.nodeNamesUsed[s];++e)s=t+"_"+e;return this.nodeNamesUsed[s]=!0,s}loadGeometries(e){const t=this,s=this.extensions,i=this.primitiveCache;function n(e){return s[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(s){return ue(s,e,t)}))}const l=[];for(let s=0,r=e.length;s0&&ae(h,n),h.name=t.createUniqueName(n.name||"mesh_"+e),oe(h,n),c.extensions&&re(i,h,c),t.assignFinalMaterial(h),a.push(h)}for(let s=0,i=a.length;s1?new Group:1===t.length?t[0]:new Object3D,r!==t[0])for(let e=0,s=t.length;e{const t=new Map;for(const[e,s]of n.associations)(e instanceof Material||e instanceof Texture)&&t.set(e,s);return e.traverse((e=>{const s=n.associations.get(e);null!=s&&t.set(e,s)})),t})(l),l}))}}function me(e,t,s,i){const n=s.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===n.skin)return e;let t;return i.getDependency("skin",n.skin).then((function(e){t=e;const s=[];for(let e=0,n=t.joints.length;e{const s=n[e];return s&&(l={profileId:e,profilePath:`${t}/${s.path}`,deprecated:!!s.deprecated}),!!l})),!l){if(!s)throw new Error("No matching profile name found");const e=n[s];if(!e)throw new Error(`No matching profile name found and default profile "${s}" missing.`);l={profileId:s,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}const r=await be(l.profilePath);let o;if(i){let t;if(t="any"===e.handedness?r.layouts[Object.keys(r.layouts)[0]]:r.layouts[e.handedness],!t)throw new Error(`No matching handedness, ${e.handedness}, in profile ${l.profileId}`);t.assetPath&&(o=l.profilePath.replace("profile.json",t.assetPath))}return{profile:r,assetPath:o}}const ye={xAxis:0,yAxis:0,button:0,state:fe.ComponentState.DEFAULT};class ve{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===fe.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(ye)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:i}){const{normalizedXAxis:n,normalizedYAxis:l}=function(e=0,t=0){let s=e,i=t;if(Math.sqrt(e*e+t*t)>1){const n=Math.atan2(t,e);s=Math.cos(n),i=Math.sin(n)}return{normalizedXAxis:.5*s+.5,normalizedYAxis:.5*i+.5}}(e,t);switch(this.componentProperty){case fe.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?n:.5;break;case fe.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?l:.5;break;case fe.ComponentProperty.BUTTON:this.value=this.states.includes(i)?s:0;break;case fe.ComponentProperty.STATE:this.valueNodeProperty===fe.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class we{constructor(e,t){if(!(e&&t&&t.visualResponses&&t.gamepadIndices&&0!==Object.keys(t.gamepadIndices).length))throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach((e=>{const s=new ve(t.visualResponses[e]);this.visualResponses[e]=s})),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:fe.ComponentState.DEFAULT,button:void 0!==this.gamepadIndices.button?0:void 0,xAxis:void 0!==this.gamepadIndices.xAxis?0:void 0,yAxis:void 0!==this.gamepadIndices.yAxis?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=fe.ComponentState.DEFAULT,void 0!==this.gamepadIndices.button&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||1===this.values.button?this.values.state=fe.ComponentState.PRESSED:(t.touched||this.values.button>fe.ButtonTouchThreshold)&&(this.values.state=fe.ComponentState.TOUCHED)}void 0!==this.gamepadIndices.xAxis&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),void 0!==this.gamepadIndices.yAxis&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===fe.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>fe.AxisTouchThreshold&&(this.values.state=fe.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach((e=>{e.updateFromComponent(this.values)}))}}class _e{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach((e=>{const t=this.layoutDescription.components[e];this.components[e]=new we(e,t)})),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach((t=>{e.push(t.data)})),e}updateFromGamepad(){Object.values(this.components).forEach((e=>{e.updateFromGamepad(this.xrInputSource.gamepad)}))}}class Se extends THREE.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:t,minNode:s,maxNode:i,value:n,valueNodeProperty:l}=e;t&&(l===fe.VisualResponseProperty.VISIBILITY?t.visible=n:l===fe.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(s.quaternion,i.quaternion,n),t.position.lerpVectors(s.position,i.position,n)))}))})))}}function Ae(e,t){!function(e,t){Object.values(e.components).forEach((e=>{const{type:s,touchPointNodeName:i,visualResponses:n}=e;if(s===fe.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(i),e.touchPointNode){const t=new SphereGeometry(.001),s=new MeshBasicMaterial({color:255}),i=new Mesh(t,s);e.touchPointNode.add(i)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(n).forEach((e=>{const{valueNodeName:s,minNodeName:i,maxNodeName:n,valueNodeProperty:l}=e;if(l===fe.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(i),e.maxNode=t.getObjectByName(n),!e.minNode)return void console.warn(`Could not find ${i} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${n} in the model`)}e.valueNode=t.getObjectByName(s),e.valueNode||console.warn(`Could not find ${s} in the model`)}))}))}(e.motionController,t),e.envMap&&t.traverse((t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)})),e.add(t)}class xe{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new f)}createControllerModel(e){const t=new Se;let s=null;return e.addEventListener("connected",(e=>{const i=e.data;"tracked-pointer"===i.targetRayMode&&i.gamepad&&Ce(i,this.path,"generic-trigger").then((({profile:e,assetPath:n})=>{t.motionController=new _e(i,e,n);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),Ae(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),Ae(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}}class ke extends THREE.EventDispatcher{constructor(e){if(super(),void 0===e)return void console.error("ControllerGestures must be passed a renderer");const t=new THREE.Clock;this.controller1=e.xr.getController(0),this.controller1.userData.gestures={index:0},this.controller1.userData.selectPressed=!1,this.controller1.addEventListener("selectstart",i),this.controller1.addEventListener("selectend",n),this.controller2=e.xr.getController(1),this.controller2.userData.gestures={index:1},this.controller2.userData.selectPressed=!1,this.controller2.addEventListener("selectstart",i),this.controller2.addEventListener("selectend",n),this.doubleClickLimit=.2,this.pressMinimum=.4,this.right=new THREE.Vector3(1,0,0),this.up=new THREE.Vector3(0,1,0),this.type="unknown",this.prevTap="none",this.clock=t;const s=this;function i(){const e=this.userData.gestures;e.startPosition=void 0,e.startTime=t.getElapsedTime(),-1==s.type.indexOf("tap")&&(e.taps=0),s.type="unknown",this.userData.selectPressed=!0}function n(){const e=this.userData.gestures;e.endTime=t.getElapsedTime();e.endTime-e.startTime.05&&(e.startPosition=this.controller1.position.clone())),this.controller2.userData.selectPressed&&void 0===t.startPosition&&(i=s-t.startTime,i>.05&&(t.startPosition=this.controller2.position.clone())),!this.controller1.userData.selectPressed&&"tap"===this.type&&(i=this.clock.getElapsedTime()-e.endTime,i>this.doubleClickLimit)){switch(e.taps){case 1:self.prevTap="tap";break;case 2:this.dispatchEvent({type:"doubletap",position:this.controller1.position,matrixWorld:this.controller1.matrixWorld}),self.prevTap="doubletap"}this.type="unknown",e.taps=0}if("unknown"===this.type&&this.touch)"doubletap"==self.prevTap?(this.type="pinch",this.startDistance=this.controller1.position.distanceTo(this.controller2.position),this.dispatchEvent({type:"pinch",delta:new THREE.Vector3(0,0,0),scale:1,initialise:!0})):(this.type="pan",this.startPosition=this.controller1.position.clone(),this.dispatchEvent({type:"pan",delta:new THREE.Vector3(0,0,0),initialise:!0}));else if(("pinch"===this.type||"pan"===this.type)&&"doubletap"==self.prevTap&&this.controller2.position){const e=this.controller1.position.distanceTo(this.controller2.position)/this.startDistance,t=this.controller1.position.clone().sub(this.startPosition);this.dispatchEvent({type:"pinch",delta:t,scale:e})}}}class Oe{constructor(e,t){this.config=void 0===t?{panelSize:{width:1,height:1},width:512,height:512,opacity:.7,body:{fontFamily:"Arial",fontSize:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6}}:t,void 0===this.config.width&&(this.config.width=512),void 0===this.config.height&&(this.config.height=512),void 0===this.config.body&&(this.config.body={fontFamily:"Arial",size:30,padding:20,backgroundColor:"#000",fontColor:"#fff",borderRadius:6});const s=this.config.body;void 0===s.borderRadius&&(s.borderRadius=6),void 0===s.fontFamily&&(s.fontFamily="Arial"),void 0===s.padding&&(s.padding=20),void 0===s.fontSize&&(s.fontSize=30),void 0===s.backgroundColor&&(s.backgroundColor="#000"),void 0===s.fontColor&&(s.fontColor="#fff"),Object.entries(this.config).forEach((([e,t])=>{if(!("object"!=typeof t||"panelSize"===e||t instanceof THREE.WebGLRenderer||t instanceof THREE.Scene)){const e=void 0!==t.position?t.position:{x:0,y:0};void 0!==e.left&&void 0===e.x&&(e.x=e.left),void 0!==e.top&&void 0===e.y&&(e.y=e.top);const s=void 0!==t.width?t.width:this.config.width,i=void 0!==t.height?t.height:this.config.height;void 0!==e.right&&void 0===e.x&&(e.x=this.config.width-e.right-s),void 0!==e.bottom&&void 0===e.y&&(e.y=this.config.height-e.bottom-i),void 0===e.x&&(e.x=0),void 0===e.y&&(e.y=0),t.position=e,void 0===t.type&&(t.type="text")}}));const i=this.createOffscreenCanvas(this.config.width,this.config.height);this.context=i.getContext("2d"),this.context.save();const n=void 0!==this.config.opacity?this.config.opacity:.7,l=new THREE.MeshBasicMaterial({transparent:!0,opacity:n});this.panelSize=void 0!==this.config.panelSize?this.config.panelSize:{width:1,height:1};const r=new THREE.PlaneGeometry(this.panelSize.width,this.panelSize.height);this.mesh=new THREE.Mesh(r,l),this.texture=new THREE.CanvasTexture(i),this.mesh.material.map=this.texture,this.scene=this.config.scene;if(Object.values(this.config).filter((e=>"input-text"===e.type)).length>0){this.keyboard=new Re(this.panelSize.width,this.config.renderer);this.keyboard.mesh.position.set(0,-.3,.2),this.mesh.add(this.keyboard.mesh)}if(void 0===e)this.content={body:""},this.config.body.type="text";else{this.content=e;Object.values(t).filter((e=>"button"===e.type||"scroll"===e.overflow||"input-text"===e.type)).length>0&&(void 0===t||void 0===t.renderer?console.warn("CanvasUI: button, scroll or input-text in the config but no renderer"):(this.renderer=t.renderer,this.initControllers()))}this.selectedElements=[void 0,void 0],this.selectPressed=[!1,!1],this.scrollData=[void 0,void 0],this.intersects=[void 0,void 0],this.needsUpdate=!0,this.update()}getIntersectY(e){const t=this.config.height||512,s=this.intersects[e];return void 0===s||void 0===s.uv?0:(1-s.uv.y)*t}initControllers(){this.vec3=new THREE.Vector3,this.mat4=new THREE.Matrix4,this.raycaster=new THREE.Raycaster;const e=this;function t(t){const s=t.target===e.controller?0:1,i=e.selectedElements[s];if(void 0!==i)if("button"==i.type)e.select(s);else if("input-text"==i.type&&e.keyboard)if(e.keyboard.visible)e.keyboard.linkedUI=void 0,e.keyboard.linkedText=void 0,e.keyboard.linkedElement=void 0,e.keyboard.visible=!1;else{let t;e.keyboard.linkedUI=e,Object.entries(e.config).forEach((([e,s])=>{s==i&&(t=e)}));const s=(.5-(i.position.y+i.height+e.config.body.padding)/e.config.height)*e.panelSize.height,n=Math.max(e.panelSize.width,e.panelSize.height)/2;e.keyboard.position.set(0,-n/1.5-s,.1),e.keyboard.linkedText=e.content[t],e.keyboard.linkedName=t,e.keyboard.linkedElement=i,e.keyboard.visible=!0}}function s(t){const s=t.target===e.controller?0:1;if(e.selectPressed[s]=!0,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow){const t=e.selectedElements[s];e.scrollData[s]={scrollY:t.scrollY,rayY:e.getIntersectY(s)}}}function i(t){const s=t.target===e.controller?0:1;e.selectPressed[s]=!1,void 0!==e.selectedElements[s]&&"scroll"==e.selectedElements[s].overflow&&(e.scrollData[s]=void 0)}if(this.controller=this.renderer.xr.getController(0),this.controller.addEventListener("select",t),this.controller.addEventListener("selectstart",s),this.controller.addEventListener("selectend",i),this.controller1=this.renderer.xr.getController(1),this.controller1.addEventListener("select",t),this.controller1.addEventListener("selectstart",s),this.controller1.addEventListener("selectend",i),this.scene){const e=.015,t=new THREE.IcosahedronBufferGeometry(e),s=new THREE.MeshBasicMaterial({color:170}),i=new THREE.Mesh(t,s);i.visible=!1,this.scene.add(i);const n=new THREE.Mesh(t,s);n.visible=!1,this.scene.add(n),this.intersectMesh=[i,n]}}setClip(e){const t=this.context;if(t.restore(),t.save(),void 0!==e.clipPath){const s=new Path2D(e.clipPath);t.clip(s)}else{const s=void 0!==e.position?e.position:{x:0,y:0},i=e.borderRadius||0,n=e.width||this.config.width,l=e.height||this.config.height;if(t.beginPath(),0!==i){const e=Math.PI/2;t.moveTo(s.x+i,s.y),t.arc(s.x+i,s.y+i,i,e,2*e,!0),t.lineTo(s.x,s.y+l-i),t.arc(s.x+i,s.y+l-i,i,0,e,!0),t.lineTo(s.x+n-i,s.y+l),t.arc(s.x+n-i,s.y+l-i,i,3*e,4*e,!0),t.lineTo(s.x+n,s.y+i),t.arc(s.x+n-i,s.y+i,i,2*e,3*e,!0),t.closePath(),t.clip()}else t.rect(s.x,s.y,n,l),t.clip()}}setPosition(e,t,s){void 0!==this.mesh&&this.mesh.position.set(e,t,s)}setRotation(e,t,s){void 0!==this.mesh&&this.mesh.rotation.set(e,t,s)}updateElement(e,t){let s=this.content[e];void 0!==s?("object"==typeof s?s.content=t:s=t,this.content[e]=s,this.needsUpdate=!0):console.warn(`CanvasGUI.updateElement: No ${e} found`)}get panel(){return this.mesh}getElementAtLocation(e,t){const s=this,i=Object.entries(this.config).filter((([i,n])=>{if(!("object"!=typeof n||"panelSize"===i||"body"===i||n instanceof THREE.WebGLRenderer||n instanceof THREE.Scene)){const i=n.position,l=void 0!==n.width?n.width:s.config.width,r=void 0!==n.height?n.height:s.config.height;return e>=i.x&&e=i.y&&t0?(this.hover(t,s[0].uv),this.intersects[t]=s[0],this.scroll(t)):(this.hover(t),this.intersects[t]=void 0,this.scroll(t))}update(){if(void 0===this.mesh)return;if(this.controller&&this.handleController(this.controller,0),this.controller1&&this.handleController(this.controller1,1),this.keyboard&&this.keyboard.visible&&this.keyboard.update(),!this.needsUpdate)return;let e=this.context;e.clearRect(0,0,this.config.width,this.config.height);const t=this.config.body.backgroundColor?this.config.body.backgroundColor:"#000";!this.config.body.fontFamily||this.config.body.fontFamily;const s=this.config.body.fontColor?this.config.body.fontColor:"#fff";!this.config.body.fontSize||this.config.body.fontSize,this.setClip(this.config.body),e.fillStyle=t,e.fillRect(0,0,this.config.width,this.config.height);const i=this;Object.entries(this.content).forEach((([t,n])=>{const l=void 0!==i.config[t]?i.config[t]:i.config.body;if("none"!==(void 0!==l.display?l.display:"block")){const r=void 0!==l.position?l.position:{x:0,y:0},o=void 0!==l.width?l.width:i.config.width,a=void 0!==l.height?l.height:i.config.height;"button"!=l.type||n.toLowerCase().startsWith("")||(void 0===l.borderRadius&&(l.borderRadius=6),void 0===l.textAlign&&(l.textAlign="center")),i.setClip(l);const d=n.toLowerCase().startsWith(""),c=void 0!==i.selectedElements[0]&&this.selectedElements[0]===l||void 0!==i.selectedElements[1]&&this.selectedElements[1]===l;if(void 0!==l.backgroundColor&&(c&&"button"==l.type&&void 0!==l.hover?e.fillStyle=l.hover:e.fillStyle=l.backgroundColor,e.fillRect(r.x,r.y,o,a)),"text"==l.type||"button"==l.type||"input-text"==l.type){let h=!1;if(c?(d||"button"!=l.type?e.fillStyle=void 0!==l.hover?l.hover:void 0!==l.fontColor?l.fontColor:s:e.fillStyle=void 0!==l.fontColor?l.fontColor:s,h=void 0===l.hover):e.fillStyle=void 0!==l.fontColor?l.fontColor:s,d){const t=n.toUpperCase().substring(6,n.length-7);e.save(),e.translate(r.x,r.y);const s=new Path2D(t);e.fill(s),e.restore()}else i.wrapText(t,n);h&&(e.beginPath(),e.strokeStyle="#fff",e.lineWidth=2,e.rect(r.x,r.y,o,a),e.stroke())}else if("img"==l.type)if(void 0===l.img)this.loadImage(n).then((e=>{console.log(`w: ${e.width} | h: ${e.height}`),l.img=e,i.needsUpdate=!0,i.update()})).catch((e=>console.error(e)));else{const t=o/(l.img.width/l.img.height);e.drawImage(l.img,r.x,r.y,o,t)}}})),this.needsUpdate=!1,this.texture.needsUpdate=!0}loadImage(e){return new Promise(((t,s)=>{const i=new THREE.Image;i.addEventListener("load",(()=>t(i))),i.addEventListener("error",(e=>s(e))),i.src=e}))}createOffscreenCanvas(e,t){const s=document.createElement("canvas");return s.width=e,s.height=t,s}fillRoundedRect(e,t,s,i,n){const l=this.context;l.beginPath(),l.moveTo(e+n,t),l.lineTo(e+s-n,t),l.quadraticCurveTo(e+s,t,e+s,t+n),l.lineTo(e+s,t+i-n),l.quadraticCurveTo(e+s,t+i,e+s-n,t+i),l.lineTo(e+n,t+i),l.quadraticCurveTo(e,t+i,e,t+i-n),l.lineTo(e,t+n),l.quadraticCurveTo(e,t,e+n,t),l.closePath(),l.fill()}lookAt(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.lookAt(e):console.error("CanvasUI lookAt called parameter not a THREE.Vector3"))}get visible(){return void 0!==this.mesh&&this.mesh.visible}set visible(e){this.mesh&&(this.mesh.visible=e)}get position(){if(void 0!==this.mesh)return this.mesh.position}set position(e){void 0!==this.mesh&&(e instanceof Vector3?this.mesh.position.copy(e):console.error("CanvasUI trying to set the mesh position using a parameter that is not a THREE.Vector3"))}get quaternion(){if(void 0!==this.mesh)return this.mesh.quaternion}set quaternion(e){void 0!==this.mesh&&(e instanceof QUaternion?this.mesh.quaternion.copy(e):console.error("CanvasUI trying to set the mesh quaternion using a parameter that is not a THREE.Quaternion"))}wrapText(e,t){const s=t.split(" ");let i="";const n=[],l=void 0!==this.config[e]?this.config[e]:this.config.body,r=void 0!==l.width?l.width:this.config.width,o=void 0!==l.height?l.height:this.config.height,a=void 0!==l.position?l.position:{x:0,y:0},d=void 0!==l.padding?l.padding:void 0!==this.config.body.padding?this.config.body.padding:10,c=void 0!==l.paddingTop?l.paddingTop:d,h=void 0!==l.paddingLeft?l.paddingLeft:d,p=void 0!==l.paddingBottom?l.paddingBottom:d,m=void 0!==l.paddingRight?l.paddingRight:d,u={x:a.x+h,y:a.y+c,width:r-h-m,height:o-c-p},g=void 0!==l.textAlign?l.textAlign:void 0!==this.config.body.textAlign?this.config.body.textAlign:"left",f=void 0!==l.fontSize?l.fontSize:void 0!==this.config.body.fontSize?this.config.body.fontSize:30,b=void 0!==l.fontFamily?l.fontFamily:void 0!==this.config.body.fontFamily?this.config.body.fontFamily:"Arial",C=f+(void 0!==l.leading?l.leading:void 0!==this.config.body.leading?this.config.body.leading:8),y=this.context;y.textAlign=g,y.font=`${f}px '${b}'`,s.forEach((function(e){let t=s.length>1?`${i}${e} `:e,l=y.measureText(t);if(l.width>u.width&&e.length>1)if(0==i.length&&l.width>u.width){for(;l.width>u.width;){let s=0;do{s++,t=e.substr(0,s),l=y.measureText(t)}while(l.widthu.height&&"scroll"===l.overflow){void 0===l.scrollY&&(l.scrollY=0);const e=void 0!==l.fontColor?l.fontColor:this.config.body.fontColor;y.fillStyle="#aaa",this.fillRoundedRect(a.x+r-12,a.y,12,o,6),y.fillStyle="#666";const t=u.height/v,s=t*o,i=-l.scrollY*t;this.fillRoundedRect(a.x+r-12,a.y+i,12,s,6),y.fillStyle=e,w=l.scrollY,l.minScrollY=u.height-v}let _,S=w+u.y+f/2;switch(g){case"center":_=u.x+u.width/2;break;case"right":_=u.x+u.width;break;default:_=u.x}n.forEach((e=>{S+C>0&&y.fillText(e,_,S),S+=C}))}}class Re{constructor(e,t,s="EN"){const i=this.getConfig(s);i.panelSize={width:e,height:.5*e},i.height=256,i.body={backgroundColor:"#555"},i.renderer=t;const n=this.getContent(s);this.keyboard=new Oe(n,i),this.keyboard.mesh.visible=!1,this.shift=!1}get mesh(){return this.keyboard.mesh}getConfig(e){const t={};let s=10;const i=39.2,n=49,l="#333",r="#000";let o=s,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e)};t[`btn${e}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<10;e++){const d={type:"button",position:{x:a,y:o},width:i,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+10)};t[`btn${e+10}`]=d,a+=49.2}o+=59,a=s;for(let e=0;e<9;e++){const d=0==e||8==e?1.5*i+5:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+20)};t[`btn${e+20}`]=c,a+=d+s}o+=59,a=s;for(let e=0;e<5;e++){const d=0==e||4==e?88.4:2==e?186.8:i,c={type:"button",position:{x:a,y:o},width:d,height:n,padding:s,paddingTop:20,backgroundColor:r,borderRadius:6,hover:l,onSelect:this.onSelect.bind(this,e+30)};0==e&&(c.fontSize=20),t[`btn${e+30}`]=c,a+=d+s}return t}getContent(e,t=0){let s,i={};switch(this.language=e,this.keyboardIndex=t,t){case 0:s=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","@","⇧","z","x","c","v","b","n","m","⇦","","?123",","," ",".","↲"];for(let e=0;e","_","`","~",":",";","⇦","","abc",","," ",".","↲"];for(let e=0;e=0;e--){let s=t.scene.children[e];t.scene.remove(s)}else t.scene=new THREE.Scene;if(void 0!==t.scene_ghost)for(let e=t.scene_ghost.children.length-1;e>=0;e--){let s=t.scene_ghost.children[e];t.scene_ghost.remove(s)}else t.scene_ghost=new THREE.Scene;if(""!=s.htmlCls.setHtmlCls.getCookie("shininess")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("shininess"));t.shininess!=e&&s.htmlCls.clickMenuCls.setLogCmd("set shininess "+e,!0),t.shininess=e}if(!s.bNode&&""!=s.htmlCls.setHtmlCls.getCookie("light1")){let e=parseFloat(s.htmlCls.setHtmlCls.getCookie("light1")),i=parseFloat(s.htmlCls.setHtmlCls.getCookie("light2")),n=parseFloat(s.htmlCls.setHtmlCls.getCookie("light3"));t.light1==e&&t.light2==i&&t.light3==n||s.htmlCls.clickMenuCls.setLogCmd("set light | light1 "+e+" | light2 "+i+" | light3 "+n,!0),t.light1=e,t.light2=i,t.light3=n}t.directionalLight=new THREE.DirectionalLight(16777215,t.light1),t.directionalLight2=new THREE.DirectionalLight(16777215,t.light2),t.directionalLight3=new THREE.DirectionalLight(16777215,t.light3),t.cam_z>0?(t.directionalLight.position.set(-1,1,1),t.directionalLight2.position.set(1,1,1),t.directionalLight3.position.set(1,1,-1),t.lightPos=new THREE.Vector3(-1,1,1),t.lightPos2=new THREE.Vector3(1,1,1),t.lightPos3=new THREE.Vector3(1,1,-1)):(t.directionalLight.position.set(-1,1,-1),t.directionalLight2.position.set(1,1,-1),t.directionalLight3.position.set(1,1,1),t.lightPos=new THREE.Vector3(-1,1,-1),t.lightPos2=new THREE.Vector3(1,1,-1),t.lightPos3=new THREE.Vector3(1,1,1));let i=new THREE.AmbientLight(8947848);if(t.scene.add(t.directionalLight),t.scene.add(i),void 0!==t.mdl)for(let e=t.mdl.children.length-1;e>=0;e--){let s=t.mdl.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdl.remove(s)}if(void 0!==t.mdlImpostor){for(let e=t.mdlImpostor.children.length-1;e>=0;e--){let s=t.mdlImpostor.children[e];s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose(),t.mdlImpostor.remove(s)}t.mdlImpostor.children.length=0}s.bNode||t.renderer.renderLists.dispose(),t.mdl=new THREE.Object3D,t.mdlImpostor=new THREE.Object3D,t.scene.add(t.mdl),t.scene.add(t.mdlImpostor),t.mdl_ghost=new THREE.Object3D,t.scene_ghost.add(t.mdl_ghost),t.objects=[],t.objects_ghost=[],t.raycaster=new THREE.Raycaster,t.projector=new THREE.Projector,t.mouse=new THREE.Vector2;let n=s.parasCls.backgroundColors[t.opts.background.toLowerCase()];s.bNode||("transparent"===t.opts.background.toLowerCase()?t.renderer.setClearColor(n,0):t.renderer.setClearColor(n,1)),t.perspectiveCamera=new THREE.PerspectiveCamera(20,t.container.whratio,.1,1e4),t.perspectiveCamera.position.set(0,0,t.cam_z),t.perspectiveCamera.lookAt(new THREE.Vector3(0,0,0)),t.orthographicCamera=new THREE.OrthographicCamera,t.orthographicCamera.position.set(0,0,t.cam_z),t.orthographicCamera.lookAt(new THREE.Vector3(0,0,0)),t.cams={perspective:t.perspectiveCamera,orthographic:t.orthographicCamera}}setVrAr(){let e=this.icn3d;e.icn3dui;let t=this;e.bSetVrAr=!0,e.bVr?(e.canvasUI=this.createUI(),e.raycasterVR=new THREE.Raycaster,e.workingMatrix=new THREE.Matrix4,e.workingVector=new THREE.Vector3,e.origin=new THREE.Vector3,e.dolly=new THREE.Object3D,e.dolly.position.z=5,e.dolly.add(e.cam),e.scene.add(e.dolly),e.dollyId=e.dolly.id,e.dummyCam=new THREE.Object3D,e.cam.add(e.dummyCam),e.clock=new THREE.Clock,e.controllers=this.getControllers(),e.controllers.forEach((s=>{s.addEventListener("connected",(function(e){try{const s={},i="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",n="generic-trigger";Ce(e.data,i,n).then((({profile:i,assetPath:n})=>{s.name=i.profileId,s.targetRayMode=e.data.targetRayMode,Object.entries(i.layouts).forEach((([e,t])=>{const i={};Object.values(t.components).forEach((e=>{i[e.rootNodeName]=e.gamepadIndices})),s[e]=i})),t.updateControllers(s)}))}catch(e){}})),s.addEventListener("disconnected",(function(){this.remove(this.children[0]),e.controllers.forEach((e=>{}))}))}))):e.bAr&&(e.gestures=new ke(e.renderer),e.scene.add(e.gestures.controller1),e.scene.add(e.gestures.controller2),e.gestures.addEventListener("doubletap",(e=>{t.positionCenter()})),e.gestures.addEventListener("pinch",(s=>{if(void 0!==s.initialise)t.startPosition=e.mdl.position.clone(),t.startScale=e.mdl.scale.clone();else{let i=1;const n=t.startScale.clone().multiplyScalar(s.scale*i);e.mdl.scale.copy(n)}})))}positionCenter(){let e=this.icn3d;e.icn3dui;const t=e.gestures.controller1;e.mdl.position.set(-.06,0,-.6).applyMatrix4(t.matrixWorld),e.mdl.scale.copy(new THREE.Vector3(.005,.005,.005))}setVrArButtons(){let e=this.icn3d,t=e.icn3dui;e.bSetVrArButtons=!0,t.bNode||($("#"+t.pre+"VRButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.VRButtonCls.createButton(e.renderer)),$("#"+t.pre+"ARButton").remove(),$("#"+t.pre+"viewer").get(0).appendChild(e.ARButtonCls.createButton(e.renderer)))}updateControllers(e){this.icn3d.icn3dui,this.addEventForController(e,"right"),this.addEventForController(e,"left")}addEventForController(e,t){let s=this.icn3d;s.icn3dui;const i="right"==t?s.renderer.xr.getController(0):s.renderer.xr.getController(1),n="right"==t?e.right:e.left;if(void 0!==n){let e=!1,t=!1;Object.keys(n).forEach((i=>{-1!=i.indexOf("trigger")&&(e=!0),-1!=i.indexOf("squeeze")&&(t=!0),-1==i.indexOf("thumbstick")&&-1==i.indexOf("touchpad")||(s.xAxisIndex=n[i].xAxis,s.yAxisIndex=n[i].yAxis)})),e&&(i.addEventListener("selectstart",(function(){this.userData.selectPressed=!0})),i.addEventListener("selectend",(function(){this.userData.selectPressed=!1,this.userData.selected=void 0}))),t&&(i.addEventListener("squeezestart",(function(){this.userData.squeezePressed=!0,s.cam.add(s.canvasUI.mesh)})),i.addEventListener("squeezeend",(function(){this.userData.squeezePressed=!1,s.cam.remove(s.canvasUI.mesh)})))}}createUI(){let e=this.icn3d;e.icn3dui;let t=94,s=50,i=44,n=12,l="#1c94c4",r="#ccc",o="#fbcb09";const a={panelSize:{width:2,height:1.2},height:300,select:{type:"button",position:{top:6,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},residue:{type:"button",position:{top:6,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=2,e.cam.remove(e.canvasUI.mesh)}},secondarySelect:{type:"button",position:{top:6,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=3,e.cam.remove(e.canvasUI.mesh)}},chainSelect:{type:"button",position:{top:6,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.pk=5,e.cam.remove(e.canvasUI.mesh)}},style:{type:"button",position:{top:62,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},ribbon:{type:"button",position:{top:62,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","ribbon"),e.setOptionCls.setStyle("nucleotides","nucleotide cartoon"),e.cam.remove(e.canvasUI.mesh)}},schematic:{type:"button",position:{top:62,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","schematic"),e.setOptionCls.setStyle("nucleotides","schematic"),e.cam.remove(e.canvasUI.mesh)}},stick:{type:"button",position:{top:62,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","stick"),e.setOptionCls.setStyle("nucleotides","stick"),e.cam.remove(e.canvasUI.mesh)}},sphere:{type:"button",position:{top:62,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setStyle("proteins","sphere"),e.setOptionCls.setStyle("nucleotides","sphere"),e.cam.remove(e.canvasUI.mesh)}},color:{type:"button",position:{top:118,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},rainbow:{type:"button",position:{top:118,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","rainbow for chains"),e.cam.remove(e.canvasUI.mesh)}},atomColor:{type:"button",position:{top:118,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","atom"),e.cam.remove(e.canvasUI.mesh)}},secondaryColor:{type:"button",position:{top:118,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","secondary structure green"),e.cam.remove(e.canvasUI.mesh)}},AlphaFold:{type:"button",position:{top:118,left:406},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.setOptionCls.setOption("color","confidence"),e.cam.remove(e.canvasUI.mesh)}},unicolor:{type:"button",position:{top:174,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},red:{type:"button",position:{top:168,left:100},width:i,height:s,fontColor:"red",hover:o,onSelect:function(){e.setOptionCls.setOption("color","red"),e.cam.remove(e.canvasUI.mesh)}},green:{type:"button",position:{top:168,left:150},width:i,height:s,fontColor:"green",hover:o,onSelect:function(){e.setOptionCls.setOption("color","green"),e.cam.remove(e.canvasUI.mesh)}},blue:{type:"button",position:{top:168,left:200},width:i,height:s,fontColor:"blue",hover:o,onSelect:function(){e.setOptionCls.setOption("color","blue"),e.cam.remove(e.canvasUI.mesh)}},magenta:{type:"button",position:{top:168,left:250},width:i,height:s,fontColor:"magenta",hover:o,onSelect:function(){e.setOptionCls.setOption("color","magenta"),e.cam.remove(e.canvasUI.mesh)}},orange:{type:"button",position:{top:168,left:300},width:i,height:s,fontColor:"orange",hover:o,onSelect:function(){e.setOptionCls.setOption("color","FFA500"),e.cam.remove(e.canvasUI.mesh)}},cyan:{type:"button",position:{top:168,left:350},width:i,height:s,fontColor:"cyan",hover:o,onSelect:function(){e.setOptionCls.setOption("color","cyan"),e.cam.remove(e.canvasUI.mesh)}},gray:{type:"button",position:{top:168,left:400},width:i,height:s,fontColor:"gray",hover:o,onSelect:function(){e.setOptionCls.setOption("color","888888"),e.cam.remove(e.canvasUI.mesh)}},white:{type:"button",position:{top:168,left:450},width:i,height:s,fontColor:"white",hover:o,onSelect:function(){e.setOptionCls.setOption("color","white"),e.cam.remove(e.canvasUI.mesh)}},analysis:{type:"button",position:{top:230,left:6},width:t,height:s,fontColor:"#000",fontSize:14,backgroundColor:r},interaction:{type:"button",position:{top:230,left:106},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){try{e.viewInterPairsCls.viewInteractionPairs(["selected"],["non-selected"],!1,"3d",1,1,1,1,1,1),e.cam.remove(e.canvasUI.mesh)}catch(e){}}},removeLabel:{type:"button",position:{top:230,left:206},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){for(let t in e.labels)e.labels[t]=[];e.drawCls.draw(),e.cam.remove(e.canvasUI.mesh)}},reset:{type:"button",position:{top:230,left:306},width:t,height:s,fontColor:l,fontSize:n,backgroundColor:r,hover:o,onSelect:function(){e.selectionCls.resetAll(),e.cam.remove(e.canvasUI.mesh)}},renderer:e.renderer},d=new Oe({select:"Select",residue:"Residue",secondarySelect:"SSE",chainSelect:"Chain",style:"Style",ribbon:"Ribbon",schematic:"Schem.",stick:"Stick",sphere:"Sphere",color:"Color",rainbow:"Rainbow",atomColor:"Atom",secondaryColor:"SSE",AlphaFold:"AlphaFold",unicolor:"UniColor",red:"M 50 15 L 15 15 L 15 50 L 50 50 Z",green:"M 50 15 L 15 15 L 15 50 L 50 50 Z",blue:"M 50 15 L 15 15 L 15 50 L 50 50 Z",magenta:"M 50 15 L 15 15 L 15 50 L 50 50 Z",orange:"M 50 15 L 15 15 L 15 50 L 50 50 Z",cyan:"M 50 15 L 15 15 L 15 50 L 50 50 Z",gray:"M 50 15 L 15 15 L 15 50 L 50 50 Z",white:"M 50 15 L 15 15 L 15 50 L 50 50 Z",analysis:"Analysis",interaction:"Interact",removeLabel:"No Label",reset:"Reset"},a);return d.mesh.position.set(0,0,-3),d}createUILog(){let e=this.icn3d;e.icn3dui;const t={panelSize:{width:2,height:2},height:512,info:{type:"text",overflow:"scroll",position:{top:6,left:6},width:506,height:506,backgroundColor:"#aaa",fontColor:"#000"},renderer:e.renderer},s=new Oe({info:"Debug info"},t);return s.mesh.position.set(0,-1,-2),s}getControllers(){let e=this.icn3d;e.icn3dui;const t=new xe,s=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(0,0,0),new THREE.Vector3(0,0,-1)]),i=new THREE.Line(s);i.name="line",i.scale.z=50;const n=[];for(let s=0;s<=1;s++){const l=e.renderer.xr.getController(s);e.dolly.add(l),l.add(i.clone()),l.userData.selectPressed=!1,e.cam.add(l),n.push(l);const r=e.renderer.xr.getControllerGrip(s);r.add(t.createControllerModel(r)),e.scene.add(r)}return n}}class Ie{constructor(e){this.icn3d=e}setCamera(){let e=this.icn3d,t=e.icn3dui;if(e.bControlGl&&!t.bNode){window.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(window.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?window.camMaxDFactor=1:void 0!==window.camMaxDFactorFog?window.camMaxDFactor=window.camMaxDFactorFog:window.camMaxDFactor=3,window.cam_z>0?window.cam.position.z=s*window.camMaxDFactor:window.cam.position.z=-s*window.camMaxDFactor,"yes"===e.opts.slab?i?window.cam.near=.1:void 0!==window.camMaxDFactorFog?window.cam.near=s*window.camMaxDFactorFog-10:window.cam.near=s*window.camMaxDFactor:window.cam.near=.1,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else window.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?window.cam.right=e.maxD/2*1.5:window.cam.right=e.maxD/2*2.5,window.cam.left=-window.cam.right,window.cam.top=window.cam.right/e.container.whratio,window.cam.bottom=-window.cam.right/e.container.whratio,"yes"===e.opts.slab?window.cam.near=2*e.maxD:window.cam.near=0,window.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(window.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));window.cam.updateProjectionMatrix()}e.cam=e.cams[e.opts.camera.toLowerCase()];let s=e.maxD;if(e.cam===e.perspectiveCamera){let i=void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>e.maxatomcnt;i?e.camMaxDFactor=1:void 0!==e.camMaxDFactorFog?e.camMaxDFactor=e.camMaxDFactorFog:e.camMaxDFactor=3,e.cam_z>0?e.cam.position.z=s*e.camMaxDFactor:e.cam.position.z=-s*e.camMaxDFactor,"yes"===e.opts.slab?i?e.cam.near=.1:void 0!==e.camMaxDFactorFog?e.cam.near=s*e.camMaxDFactorFog-10:e.cam.near=s*e.camMaxDFactor:e.cam.near=.1,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.TrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.TrackballControls(e.cam,document,e):e.controls=new THREE.TrackballControls(e.cam,document.getElementById(e.id),e)}else e.cam===e.orthographicCamera&&(void 0!==e.biomtMatrices&&e.biomtMatrices.length*e.cnt>10*e.maxatomcnt?e.cam.right=e.maxD/2*1.5:e.cam.right=e.maxD/2*2.5,e.cam.left=-e.cam.right,e.cam.top=e.cam.right/e.container.whratio,e.cam.bottom=-e.cam.right/e.container.whratio,"yes"===e.opts.slab?e.cam.near=2*e.maxD:e.cam.near=0,e.cam.far=1e4,e.bControlGl&&!t.bNode?window.controls=new THREE.OrthographicTrackballControls(e.cam,void 0,e):t.bNode?e.controls=new THREE.OrthographicTrackballControls(e.cam,document,e):e.controls=new THREE.OrthographicTrackballControls(e.cam,document.getElementById(e.id),e));e.cam.updateProjectionMatrix()}}class Te{constructor(e){this.icn3d=e}setFog(e){let t=this.icn3d,s=t.icn3dui.parasCls.backgroundColors[t.opts.background.toLowerCase()];if(e){let e=t.applyCenterCls.centerAtoms(t.hAtoms);t.maxD=e.maxD,t.maxD<25&&(t.maxD=25)}let i=void 0!==t.biomtMatrices&&t.biomtMatrices.length*t.cnt>t.maxatomcnt;if("yes"===t.opts.fog)if("perspective"===t.opts.camera)if(i)t.scene.fog=void 0,t.bSetFog=!1;else{let e=t._zoomFactor>1?1*t._zoomFactor:t._zoomFactor;t.scene.fog=new THREE.Fog(s,2.5*t.maxD*e,4*t.maxD*e),t.bSetFog=!0,t.camMaxDFactorFog=3}else"orthographic"===t.opts.camera&&(t.scene.fog=void 0,t.bSetFog=!1);else t.scene.fog=void 0,t.bSetFog=!1}}class Me{constructor(e){this.icn3d=e}createBox(e,t,s,i,n,l){let r=this.icn3d,o=r.icn3dui;if(o.bNode)return;void 0===t&&(t=.8),void 0===s&&(s=!1),void 0===i&&(i=.8),l?void 0===n&&(n=r.hColor):void 0===n&&(n=e.color);let a=s?t:(o.parasCls.vdwRadii[e.elem.toUpperCase()]||t)*(i||1);this.createBox_base(e.coord,a,n,l)}createBox_base(e,t,s,i,n,l,r){let o,a=this.icn3d;a.icn3dui.bNode||(void 0===r&&(r=l?.5:1),new THREE.BoxGeometry(1,1,1),o=new THREE.Mesh(a.boxGeometry,new THREE.MeshPhongMaterial({transparent:!0,opacity:r,specular:a.frac,shininess:a.shininess,emissive:a.emissive,color:s})),o.scale.x=o.scale.y=o.scale.z=t,o.position.copy(e),a.mdl.add(o),i?a.prevHighlightObjects.push(o):n?a.prevOtherMesh.push(o):a.objects.push(o))}createBoxRepresentation_P_CA(e,t,s){let i=this.icn3d;if(i.icn3dui.bNode)return;let n=this;i.reprSubCls.createRepresentationSub(e,(function(e){"CA"!==e.name&&"O3'"!==e.name&&"O3*"!==e.name||n.createBox(e,void 0,void 0,t,void 0,s)}))}}class Pe{constructor(e){this.icn3d=e}createBrick(e,t,s,i){let n=this.icn3d;if(n.icn3dui.bNode)return;let l=new THREE.CylinderGeometry(1,1,1,4,1),r=new THREE.Mesh(l,new THREE.MeshPhongMaterial({specular:n.frac,shininess:n.shininess,emissive:n.emissive,color:i}));r.position.copy(e).add(t).multiplyScalar(.5),r.matrixAutoUpdate=!1,r.lookAt(t.clone().sub(e)),r.updateMatrix(),r.matrix.multiply((new THREE.Matrix4).makeScale(s,s,e.distanceTo(t))).multiply((new THREE.Matrix4).makeRotationX(.5*Math.PI)),n.mdl.add(r)}}class De{constructor(e){this.icn3d=e}createCurveSubArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u){if(this.icn3d.icn3dui.bNode)return;let g=[],f=[];g.push(e),f.push(o),this.prepareStrand(g,f,t,s,i,void 0,n,l,r,a,d,!1,c,h,p,m,u),g=[],f=[]}createStripArrow(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g){if(this.icn3d.icn3dui.bNode)return;let f=[],b=[];f.push(e),f.push(t),b.push(o),b.push(a),this.prepareStrand(f,b,void 0,s,i,n,l,void 0,r,d,c,!0,h,p,m,u,g),f=[],b=[]}prepareStrand(e,t,s,i,n,l,r,o,a,d,c,h,p,m,u,g,f){let b=this.icn3d,C=b.icn3dui;if(1===d.length)return;let y=i,v=!u,w=[];w.push(i[i.length-2]),w.push(i[i.length-1]),n=n||b.axisDIV;let _,S,A,x,k=2/(a-1),O={};for(let e=0,s=t.length;e1)if(void 0!==d){let i,n,l=[];for(let r=0,o=p.length;r0&&i.tubeCls.createTube(a,"CA",i.coilWidth,s),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness,s)):(Object.keys(a).length>0&&i.tubeCls.createTube(a,"CA",i.coilWidth),Object.keys(d).length>0&&i.strandCls.createStrand(d,void 0,void 0,!0,0,i.helixSheetWidth,!1,2*i.ribbonthickness))}createCylinderCurve(e,t,s,i,n){let l=this.icn3d;if(l.icn3dui.bNode)return;let r,o,a,d,c,h,p=null;for(a in e)if(d=e[a],!d.het&&(c=d.structure+"_"+d.chain,h=d.structure+"_"+r,-1!=t.indexOf(d.name))){if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.clone().add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color),l.sphereCls.createSphere(d,s,!0,1,n)}p=d,r=d.chain,o=d.resi,l.sphereCls.createSphere(d,s,!0,1,n),2===n&&l.boxCls.createBox(d,void 0,void 0,void 0,void 0,n)}if(null!==p&&r===d.chain&&l.ParserUtilsCls.getResiNCBI(h,o)+1===l.ParserUtilsCls.getResiNCBI(c,d.resi)&&Math.abs(p.coord.x-d.coord.x)<8&&Math.abs(p.coord.y-d.coord.y)<8&&Math.abs(p.coord.z-d.coord.z)<8){let e=p.coord.add(d.coord).multiplyScalar(.5);if(n)1===n&&(this.createCylinder(p.coord,e,s,p.color,n),this.createCylinder(e,d.coord,s,d.color,n),l.sphereCls.createSphere(d,s,!0,1,n));else if(i){let t=l.lineCls.createSingleLine(p.coord,e,p.color,!1);l.mdl.add(t),l.objects.push(t),t=l.lineCls.createSingleLine(e,d.coord,d.color,!1),l.mdl.add(t),l.objects.push(t)}else this.createCylinder(p.coord,e,s,p.color),this.createCylinder(e,d.coord,s,d.color)}}}class Le{constructor(e){this.icn3d=e}createLineRepresentation(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i=new THREE.BufferGeometry,n=[],l=[],r=0,o=0;s.reprSubCls.createRepresentationSub(e,void 0,(function(e,t){if(e.color===t.color)n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b;else{let s=e.coord.clone().add(t.coord).multiplyScalar(.5);n[r++]=e.coord.x,n[r++]=e.coord.y,n[r++]=e.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,n[r++]=t.coord.x,n[r++]=t.coord.y,n[r++]=t.coord.z,n[r++]=s.x,n[r++]=s.y,n[r++]=s.z,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=e.color.r,l[o++]=e.color.g,l[o++]=e.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b,l[o++]=t.color.r,l[o++]=t.color.g,l[o++]=t.color.b}}));if(i.setAttribute("position",new THREE.BufferAttribute(new Float32Array(n),3)),i.setAttribute("color",new THREE.BufferAttribute(new Float32Array(l),3)),2!==t){let e;1===t||(e=new THREE.LineSegments(i,new THREE.LineBasicMaterial({linewidth:s.linewidth,vertexColors:!0})),s.mdl.add(e)),1===t?s.prevHighlightObjects.push(e):s.objects.push(e)}else 2===t&&s.boxCls.createBoxRepresentation_P_CA(e,.8,t)}createConnCalphSidechain(e,t){let s=this.icn3d;if(s.icn3dui.bNode)return;let i={};for(let s in e){let n=e[s];if(!n.het&&n.style2===t){i[n.structure+"_"+n.chain+"_"+n.resi]=1}}let n=[],l=[];for(let e in i){let t=s.firstAtomObjCls.getFirstAtomObjByName(s.residues[e],"CA");if(void 0!==t)for(let e=0,i=t.bonds.length;e=t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>=e.bonds.length&&t.bonds.length>1))return void console.log("Double bond was not drawn due to the undefined cross plane");s=t.serial,l=t.bonds[0],d=t.bonds[1]}let i=r.atoms[s].coord.clone();i.sub(r.atoms[l].coord);let n=r.atoms[s].coord.clone();n.sub(r.atoms[d].coord),i.cross(n),0==parseInt(1e4*i.length())&&(i=new THREE.Vector3(.2,.3,.5)),c=t.coord.clone(),c.sub(e.coord),c.cross(i).normalize().multiplyScalar(.2*o),0==parseInt(1e4*c.length())&&(i=new THREE.Vector3(.5,.3,.2),c.cross(i).normalize().multiplyScalar(.2*o))}e.color===t.color?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n)):r.bImpo?r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),t.coord.clone().add(c),a,e.color,n,t.color),r.cylinderCls.createCylinder(e.coord.clone().sub(c),t.coord.clone().sub(c),a,e.color,n,t.color)):r.dAtoms.hasOwnProperty(e.serial)&&r.dAtoms.hasOwnProperty(t.serial)&&(r.cylinderCls.createCylinder(e.coord.clone().add(c),i.clone().add(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().add(c),i.clone().add(c),a,t.color,n),r.cylinderCls.createCylinder(e.coord.clone().sub(c),i.clone().sub(c),a,e.color,n),r.cylinderCls.createCylinder(t.coord.clone().sub(c),i.clone().sub(c),a,t.color,n))}else if(r.aromaticbonds.hasOwnProperty(l)){let s,l,d;if(e.bonds.length>t.bonds.length&&e.bonds.length>1)s=e.serial,l=e.bonds[0],d=e.bonds[1];else{if(!(t.bonds.length>1))return;s=t.serial,l=t.bonds[0],d=t.bonds[1]}let c=r.atoms[s].coord.clone();c.sub(r.atoms[l].coord);let h=r.atoms[s].coord.clone();h.sub(r.atoms[d].coord),c.cross(h);let p=t.coord.clone();p.sub(e.coord),p.cross(c).normalize().multiplyScalar(.2*o);let m=0;for(let s=0,i=e.bondOrder.length;so+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random()))):d.bCalphaOnly&&"CA"===b.name&&(G.length>o+1?(s=k.clone(),i=d.atoms[G[G.length-1-o-1]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e6||c&&Math.abs(S.y-c.y)>6||c&&Math.abs(S.z-c.z)>6;if((u!==b.chain||b.ssbegin||b.ssend||B===j-1||p)&&m[0].length>0){let c="CA",u=[],g=[];if(isNaN(d.atoms[P].resi))u=[];else{let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);u=void 0!==t?[t]:[]}if(!isNaN(d.atoms[P].resi)){let e=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+1).toString(),t=d.firstAtomObjCls.getAtomCoordFromResi(e,c);void 0!==t&&g.push(t);let s=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)+2).toString(),i=d.firstAtomObjCls.getAtomCoordFromResi(s,c);void 0!==i&&g.push(i)}if(!p){1===a||2===a?_.push(d.hColor):_.push(R),f=b.ssend&&"sheet"===b.ss?0:"coil"===I&&b.ssbegin||T&&b.ssbegin||"coil"===b.ss?n:l;let s,i,o=4;"O"===b.name?(s=A.clone(),s.sub(S)):d.bCalphaOnly&&"CA"===b.name&&(G.length>o?(s=S.clone(),i=d.atoms[G[G.length-1-o]].coord.clone(),i.sub(s)):s=new THREE.Vector3(Math.random(),Math.random(),Math.random())),s.normalize(),s.multiplyScalar(f),null!==E&&s.dot(E)<0&&s.negate(),E=s;for(let e=0,s=2/(t-1);e0){let e="CA",n=[],l=[];if(isNaN(d.atoms[P].resi))n=[];else{let t=d.atoms[P].structure+"_"+d.atoms[P].chain+"_"+(parseInt(d.atoms[P].resi)-1).toString();d.firstAtomObjCls.getAtomCoordFromResi(t,e)}for(let e=0;!i&&e0;--e){let t=a.structure+"_"+a.chain+"_"+e;if(!c.residues.hasOwnProperty(t))break;let s=c.firstAtomObjCls.getFirstCalphaAtomObj(c.residues[t]);if(s.ss===a.ss&&s.ssbegin){g=s.resi;break}}for(let e=g;e0&&(o!==c.chain||Math.abs(c.coord.x-h.coord.x)>6||Math.abs(c.coord.y-h.coord.y)>6||Math.abs(c.coord.z-h.coord.z)>6||r.ParserUtilsCls.getResiNCBI(c.structure+"_"+o,a)+13||Math.abs(c.coord.y-h.coord.y)>3||Math.abs(c.coord.z-h.coord.z)>3))){if(2!==i){if(!isNaN(d.resi)&&!isNaN(h.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),i=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==i?[i]:[];let l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+1).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),a=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString();if(r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);void 0!==e&&e.ssbegin&&(l=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+2).toString(),o=h.structure+"_"+h.chain+"_"+(parseInt(h.resi)+3).toString(),p.push(e.coord),n?u.push(this.getCustomtubesize(l)):u.push(this.getRadius(s,e)),m.push(e.color))}if(1==p.length&&r.residues.hasOwnProperty(l)){let e=r.firstAtomObjCls.getAtomFromResi(l,t);if(e){p.push(e.coord),m.push(e.color);let t=this.getRadius(s,c);u.push(t),l=o,o=a}}let b=r.firstAtomObjCls.getAtomCoordFromResi(l,t);void 0!==b&&f.push(b);let C=r.firstAtomObjCls.getAtomCoordFromResi(o,t);void 0!==C&&f.push(C)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}p=[],m=[],u=[],g=[],f=[],d=c,b=0}if(0==p.length&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)-1).toString();r.residues.hasOwnProperty(e)&&(h=r.firstAtomObjCls.getAtomFromResi(e,t),void 0!==h&&h.ssend&&(p.push(h.coord),n?u.push(this.getCustomtubesize(e)):u.push(this.getRadius(s,h)),m.push(h.color)))}let e;p.push(c.coord),e=n?this.getCustomtubesize(c.structure+"_"+c.chain+"_"+c.resi):this.getRadius(s,c),u.push(e),m.push(c.color),1===b&&(m[m.length-2]=c.color),o=c.chain,a=c.resi;let l=1.2;2!==i||c.ssbegin||r.boxCls.createBox(c,void 0,void 0,l,void 0,i),++b,h=c}if(2!==i){if(g=[],void 0!==d&&!isNaN(d.resi)){let e=d.structure+"_"+d.chain+"_"+(parseInt(d.resi)-1).toString(),s=r.firstAtomObjCls.getAtomCoordFromResi(e,t);g=void 0!==s?[s]:[]}if(f=[],void 0!==c&&!isNaN(c.resi)){let e=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+1).toString(),i=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+2).toString(),n=c.structure+"_"+c.chain+"_"+(parseInt(c.resi)+3).toString();if(1==p.length&&r.residues.hasOwnProperty(e)){let l=r.firstAtomObjCls.getAtomFromResi(e,t);if(l){p.push(l.coord),m.push(l.color);let t=this.getRadius(s,c);u.push(t),e=i,i=n}}let l=r.firstAtomObjCls.getAtomCoordFromResi(e,t);void 0!==l&&f.push(l);let o=r.firstAtomObjCls.getAtomCoordFromResi(i,t);void 0!==o&&f.push(o)}C.push({pnts:p,colors:m,radii:u,prevone:g,nexttwo:f})}for(let e=0,t=C.length;e1?a.parasCls.thr(t[t.length-2]):a.parasCls.thr(t[e]),f[y++]=d.r,f[y++]=d.g,f[y++]=d.b}}let x,k=0;for(let e=0,t=_.length-1;er&&(l=r,e=1);for(let t=0;t0&&t.b<=100?.01*t.b:t.b>100?1:s.coilWidth),i}}class ze{constructor(e){this.icn3d=e}drawCartoonNucleicAcid(e,t,s,i){this.drawStrandNucleicAcid(e,2,t,!0,void 0,s,i)}drawStrandNucleicAcid(e,t,s,i,n,l,r){let o,a,d,c=this.icn3d;if(c.icn3dui.bNode)return;2===r&&(t=void 0,l=void 0),n=n||c.nucleicAcidWidth,s=s||c.axisDIV,t=t||c.nucleicAcidStrandDIV;let h=[];for(d=0;dy?y=C:C=y);let v=.8*b/y;if(g.width=C,g.height=y,f.clearRect(0,0,C,y),h)if(f.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",f.strokeStyle="rgba("+l.r+","+l.g+","+l.b+","+l.a+")",f.lineWidth=r,p){let e=.4*C;this.circle(f,0,0,C,y,e)}else{let e=0;this.roundRect(f,0,0,C,y,e)}f.font="Bold "+a+"px "+o,f.textAlign="center",f.textBaseline="middle",f.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", 1.0)",f.fillText(e,.5*C,.5*y);let w=new THREE.Texture(g);w.needsUpdate=!0;let _=new THREE.SpriteMaterial({map:w,depthTest:!1,depthWrite:!1});_.map.minFilter=THREE.LinearFilter;let S=new THREE.Sprite(_);return p?S.scale.set(.3*d,.3*d,1):S.scale.set(v*d,d,1),S}roundRect(e,t,s,i,n,l){e.beginPath(),e.moveTo(t+l,s),e.lineTo(t+i-l,s),e.quadraticCurveTo(t+i,s,t+i,s+l),e.lineTo(t+i,s+n-l),e.quadraticCurveTo(t+i,s+n,t+i-l,s+n),e.lineTo(t+l,s+n),e.quadraticCurveTo(t,s+n,t,s+n-l),e.lineTo(t,s+l),e.quadraticCurveTo(t,s,t+l,s),e.closePath(),e.fill(),e.stroke()}circle(e,t,s,i,n,l){e.beginPath(),e.arc(t+i/2,.9*(s+n/2),l,0,2*Math.PI,!0),e.closePath(),e.fill(),e.stroke()}}class Ve{constructor(e){this.icn3d=e,this.textSpriteCls=new Ge(e)}createLabelRepresentation(e){let t=this.icn3d;t.icn3dui;let s=t.oriMaxD/100;s<.4&&(s=.4);let i=3*s*t.labelScale;for(let s in e){let n=void 0!==e[s]?e[s]:[],l="black"!=t.opts.background?t.colorWhitebkgd:t.colorBlackbkgd;for(let e=0,r=n.length;e.99999)h.set(0,0,0,1);else if(e.y<-.99999)h.set(1,0,0,0);else{let t=new THREE.Vector3;t.set(e.z,0,-e.x).normalize();let s=Math.acos(e.y);h.setFromAxisAngle(t,s)}return c.applyQuaternion(h),c.scale.set(l,n,l),c.position.copy(t),c}setPc1Axes(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s=t.hashUtilsCls.intHash(e.hAtoms,e.dAtoms),i=[],n=Object.keys(s).length<100;for(let t in s){let s=e.atoms[t],l=s.structure+"_"+s.chain+"_"+s.resi;(n||""!=l)&&i.push(s.coord.clone())}let l=t.rmsdSuprCls.getEigenForSelection(i,i.length),r=new THREE.Vector3(l.h1[0],l.h1[1],l.h1[2]);if(0==l.k&&e.bRender)return void alert("Can't determine the first principal component. Please select a subset and try it again.");let o=e.applyCenterCls.centerAtoms(s),a=o.maxD,d=o.center,c=d.clone().add(r.normalize().multiplyScalar(.4*a)),h=new THREE.Vector3(l.h2[0],l.h2[1],l.h2[2]),p=d.clone().add(h.normalize().multiplyScalar(.3*a)),m=new THREE.Vector3(l.h3[0],l.h3[1],l.h3[2]),u=d.clone().add(m.normalize().multiplyScalar(.3*a));this.buildAxes(void 0,d,c,p,u,!0);let g=[d,c,p,u];return e.axes.push(g),e.drawCls.draw(),g}}class Ye{constructor(e){this.icn3d=e}showGlycans(){let e=this.icn3d,t=e.icn3dui;if(t.bNode)return;let s={},i=e.dAtoms;for(let n in i){let i=e.atoms[n];i.het&&-1!=t.parasCls.glycanHash.hasOwnProperty(i.resn)&&(void 0===s[i.resn]&&(s[i.resn]={}),"Misc"!=i.chain&&(s[i.resn][i.structure+"_"+i.chain+"_"+i.resi]=1))}let n=Object.keys(s);for(let i=0,l=n.length;i