(function(U,V,W,S,X,u,F,E,G,H,Y,Z,K,$,I,B,M,Q,R,N,P,aa,T,ba,ca,da,ea,fa,ga,O,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,Aa,Ba,Ca,Da,Ea,Fa,Ga,Ha,j,p){u("JS");E(["JU.BS","$.V3"],"JS.VTemp",null,function(){c$=H(function(){this.bsTemp=this.vNorm3=this.vNorm2=this.vNorm1=this.vTemp2=this.vTemp1=this.vB=this.vA=this.vTemp=null;G(this,arguments)},JS,"VTemp");N(c$,function(){this.vTemp=new JU.V3;this.vA=new JU.V3;this.vB=new JU.V3;this.vTemp1=new JU.V3;this.vTemp2=new JU.V3;this.vNorm1=new JU.V3;
this.vNorm2=new JU.V3;this.vNorm3=new JU.V3;this.bsTemp=new JU.BS})});u("J.api");T(J.api,"SmilesMatcherInterface");u("JS");E(["J.api.SmilesMatcherInterface"],"JS.SmilesMatcher","JU.AU $.BS $.PT JS.InvalidSmilesException $.SmilesAtom $.SmilesBond $.SmilesGenerator $.SmilesParser JU.BSUtil $.Elements $.Logger $.Node $.Point3fi".split(" "),function(){c$=R(JS,"SmilesMatcher",null,J.api.SmilesMatcherInterface);p(c$,"getLastException",function(){return JS.InvalidSmilesException.getLastError()});p(c$,"getMolecularFormula",
function(a,b){JS.InvalidSmilesException.clear();var c=JS.SmilesParser.getMolecule(a,b);c.createTopoMap(null);c.nodes=c.jmolAtoms;return c.getMolecularFormula(!b,null,!1)},"~S,~B");p(c$,"getSmiles",function(a,b,c,e,d){JS.InvalidSmilesException.clear();return(new JS.SmilesGenerator).getSmiles(a,b,c,e,d)},"~A,~N,JU.BS,~S,~N");p(c$,"areEqual",function(a,b){JS.InvalidSmilesException.clear();var c=this.findPriv(a,JS.SmilesParser.getMolecule(b,!1),(0<=a.indexOf("*")?2:17)|8256);return null==c?-1:c.length},
"~S,~S");j(c$,"areEqualTest",function(a,b){var c=this.findPriv(a,b,8273);return null!=c&&1==c.length},"~S,JS.SmilesSearch");p(c$,"find",function(a,b,c,e){JS.InvalidSmilesException.clear();b=JS.SmilesParser.cleanPattern(b);a=JS.SmilesParser.cleanPattern(a);b=JS.SmilesParser.getMolecule(b,!1);a=this.findPriv(a,b,(c?2:17)|(e?64:0)|12288);for(c=a.length;0<=--c;){e=a[c];for(var d=e.length;0<=--d;)e[d]=b.jmolAtoms[e[d]].mapIndex}return a},"~S,~S,~B,~B");p(c$,"getRelationship",function(a,b){if(null==a||
null==b||0==a.length||0==b.length)return"";var c=this.getMolecularFormula(a,!1),e=this.getMolecularFormula(b,!1);if(!c.equals(e))return"none";var d,c=JU.PT.countChar(JU.PT.rep(a,"@@","@"),"@"),e=JU.PT.countChar(JU.PT.rep(b,"@@","@"),"@");d=c==e&&0<this.areEqual(b,a);if(!d){d=a+b;if(0<=d.indexOf("/")||0<=d.indexOf("\\")||0<=d.indexOf("@")){if(c==e&&0<c&&(d=0<this.areEqual("/invertstereo/"+b,a)))return"enantiomers";if(d=0<this.areEqual("/nostereo/"+b,a))return c==e?"diastereomers":"ambiguous stereochemistry!"}return"constitutional isomers"}return"identical"},
"~S,~S");p(c$,"reverseChirality",function(a){a=JU.PT.rep(a,"@@","!@");a=JU.PT.rep(a,"@","@@");return a=JU.PT.rep(a,"!@@","@")},"~S");p(c$,"getSubstructureSet",function(a,b,c,e,d){return this.matchPriv(a,b,c,e,null,d|4128)},"~S,~A,~N,JU.BS,~N");p(c$,"getSubstructureSets",function(a,b,c,e,d,f,h){JS.InvalidSmilesException.clear();var g=new JS.SmilesParser(!0),k=null,k=g.parse("");k.firstMatchOnly=!1;k.matchAllAtoms=!1;k.jmolAtoms=b;k.jmolAtomCount=Math.abs(c);k.setSelected(d);k.getRingData(!0,e,h);k.asVector=
!1;k.subSearches=Array(1);k.getSelections();b=new JU.BS;for(d=0;d<a.length;d++)if(null==a[d]||0==a[d].length||a[d].startsWith("#"))f.addLast(null);else if(k.clear(),h=g.getSearch(k,JS.SmilesParser.cleanPattern(a[d]),e),k.subSearches[0]=h,h=JU.BSUtil.copy(k.search(!1)),f.addLast(h),b.or(h),b.cardinality()==c)break},"~A,~A,~N,~N,JU.BS,JU.Lst,~A");p(c$,"getSubstructureSetArray",function(a,b,c,e,d,f){return this.matchPriv(a,b,c,e,d,f|8224)},"~S,~A,~N,JU.BS,JU.BS,~N");p(c$,"polyhedronToSmiles",function(a,
b,c,e,d,f){for(var h=Array(c),g=0;g<c;g++){h[g]=new JS.SmilesAtom;var k=null==e?null:e[g];F(k,JU.Node)?(h[g].elementNumber=k.getElementNumber(),h[g].atomName=k.getAtomName(),h[g].atomNumber=k.getAtomNumber(),h[g].setT(k)):h[g].elementNumber=F(k,JU.Point3fi)?k.sD:-2;h[g].index=g}k=0;for(g=b.length;0<=--g;)for(var j=b[g],n=j.length,l,m,t=n;0<=--t;)if(!((l=j[t])>=c||(m=j[(t+1)%n])>=c)&&null==h[l].getBondTo(h[m]))(new JS.SmilesBond(h[l],h[m],1,!1)).index=k++;for(g=0;g<c;g++)if(n=h[g].bondCount,0==n||
n!=h[g].bonds.length)h[g].bonds=JU.AU.arrayCopyObject(h[g].bonds,n);b=null;b=new JS.SmilesGenerator;null!=e&&(b.stereoReference=a);JS.InvalidSmilesException.clear();b=b.getSmiles(h,c,JU.BSUtil.newBitSet2(0,c),null,d|3328);4096==(d&4096)&&(b="//* "+a+" *//\t["+JU.Elements.elementSymbolFromNumber(a.getElementNumber())+"@PH"+c+(null==f?"":"/"+f+"/")+"]."+b);return b},"JU.Node,~A,~N,~A,~N,~S");p(c$,"getCorrelationMaps",function(a,b,c,e,d){return this.matchPriv(a,b,c,e,null,d|12320)},"~S,~A,~N,JU.BS,~N");
j(c$,"findPriv",function(a,b,c){var e=new JU.BS;b.createTopoMap(e);return this.matchPriv(a,b.jmolAtoms,-b.jmolAtoms.length,null,e,c)},"~S,JS.SmilesSearch,~N");j(c$,"matchPriv",function(a,b,c,e,d,f){JS.InvalidSmilesException.clear();try{var h=JS.SmilesParser.getMolecule(a,2==(f&2));h.jmolAtoms=b;F(b,Array)&&(h.bioAtoms=b);h.jmolAtomCount=Math.abs(c);0>c&&(h.isSmilesFind=!0);h.setSelected(e);h.getSelections();h.bsRequired=null;h.setRingData(d);h.firstMatchOnly=64==(f&64);h.matchAllAtoms=16==(f&16);
switch(f&61440){case 4096:return h.asVector=!1,h.search(!1);case 8192:h.asVector=!0;var g=h.search(!1);return g.toArray(Array(g.size()));case 12288:h.getMaps=!0;var k=h.search(!1);return k.toArray(JU.AU.newInt2(k.size()))}}catch(j){if(I(j,Exception))throw JU.Logger.debugging&&j.printStackTrace(),null==JS.InvalidSmilesException.getLastError()&&JS.InvalidSmilesException.clear(),new JS.InvalidSmilesException(JS.InvalidSmilesException.getLastError());throw j;}return null},"~S,~A,~N,JU.BS,JU.BS,~N");p(c$,
"cleanSmiles",function(a){return JS.SmilesParser.cleanPattern(a)},"~S");M(c$,"SMILES_MODE_BITSET",4096,"SMILES_MODE_ARRAY",8192,"SMILES_MODE_MAP",12288,"SMILES_MODE_MASK",61440)});u("JS");E(["java.lang.Exception"],"JS.InvalidSmilesException",null,function(){c$=R(JS,"InvalidSmilesException",Exception);c$.getLastError=j(c$,"getLastError",function(){return JS.InvalidSmilesException.lastError});c$.clear=j(c$,"clear",function(){JS.InvalidSmilesException.lastError=null});p(c$,"getMessage",function(){return JS.InvalidSmilesException.lastError});
K(c$,function(a){P(this,JS.InvalidSmilesException,[a]);JS.InvalidSmilesException.lastError=a.startsWith("Jmol SMILES")?a:"Jmol SMILES Exception: "+a},"~S");M(c$,"lastError",null)});u("JS");E(["JU.JmolMolecule","JU.BS","$.Lst","JS.VTemp"],"JS.SmilesSearch","java.util.Arrays $.Hashtable JU.AU $.SB JS.SmilesAromatic $.SmilesAtom $.SmilesBond $.SmilesMeasure $.SmilesParser JU.BSUtil $.Logger".split(" "),function(){c$=H(function(){this.bioAtoms=this.jmolAtoms=this.pattern=this.patternAtoms=null;this.jmolAtomCount=
0;this.bsRequired=this.bsSelected=null;this.isTopology=this.isSmilesFind=this.isSmarts=this.matchAllAtoms=this.firstMatchOnly=!1;this.subSearches=null;this.haveBondStereochemistry=this.haveSelected=!1;this.stereo=null;this.needRingData=!1;this.needAromatic=!0;this.needRingMemberships=!1;this.ringDataMax=-2147483648;this.measures=null;this.flags=0;this.lastChainAtom=this.bsAromatic6=this.bsAromatic5=this.bsAromatic=this.ringSets=null;this.getMaps=this.asVector=!1;this.top=null;this.isRingCheck=this.isSilent=
!1;this.selectedAtomCount=0;this.htNested=this.bsFound=this.ringConnections=this.ringCounts=this.ringData=null;this.nNested=0;this.bsReturn=this.vReturn=this.nestedBond=null;this.noncanonical=this.aromaticDouble=this.noAromatic=this.invertStereochemistry=this.ignoreStereochemistry=!1;this.v=this.bsCheck=null;G(this,arguments)},JS,"SmilesSearch",JU.JmolMolecule);N(c$,function(){this.patternAtoms=Array(16);this.measures=new JU.Lst;this.bsAromatic=new JU.BS;this.bsAromatic5=new JU.BS;this.bsAromatic6=
new JU.BS;this.top=this;this.bsFound=new JU.BS;this.bsReturn=new JU.BS;this.v=new JS.VTemp});K(c$,function(){P(this,JS.SmilesSearch,[])});j(c$,"toString",function(){var a=(new JU.SB).append(this.pattern);a.append("\nmolecular formula: "+this.getMolecularFormula(!0,null,!1));return a.toString()});j(c$,"setSelected",function(a){null==a&&(a=JU.BS.newN(this.jmolAtomCount),a.setBits(0,this.jmolAtomCount));this.bsSelected=a},"JU.BS");j(c$,"setAtomArray",function(){this.patternAtoms.length>this.ac&&(this.patternAtoms=
JU.AU.arrayCopyObject(this.patternAtoms,this.ac));this.nodes=this.patternAtoms});j(c$,"addAtom",function(){return this.appendAtom(new JS.SmilesAtom)});j(c$,"appendAtom",function(a){this.ac>=this.patternAtoms.length&&(this.patternAtoms=JU.AU.doubleLength(this.patternAtoms));return this.patternAtoms[this.ac]=a.setIndex(this.ac++)},"JS.SmilesAtom");j(c$,"addNested",function(a){null==this.top.htNested&&(this.top.htNested=new java.util.Hashtable);this.setNested(++this.top.nNested,a);return this.top.nNested},
"~S");j(c$,"clear",function(){this.bsReturn.clearAll();this.nNested=0;this.nestedBond=this.htNested=null;this.clearBsFound(-1)});j(c$,"setNested",function(a,b){this.top.htNested.put("_"+a,b)},"~N,~O");j(c$,"getNested",function(a){return this.top.htNested.get("_"+a)},"~N");j(c$,"getMissingHydrogenCount",function(){for(var a=0,b,c=0;c<this.ac;c++)if(0<=(b=this.patternAtoms[c].missingHydrogenCount))a+=b;return a});j(c$,"setRingData",function(a){this.isTopology&&(this.needAromatic=!1);this.needAromatic&&
(this.needRingData=!0);this.needAromatic=(new Boolean(this.needAromatic&(new Boolean(null==a&0==(this.flags&1))).valueOf())).valueOf();if(!this.needAromatic&&(this.bsAromatic.clearAll(),null!=a&&this.bsAromatic.or(a),!this.needRingMemberships&&!this.needRingData))return;this.getRingData(this.needRingData,this.flags,null)},"JU.BS");j(c$,"getRingData",function(a,b,c){var e=0!=(b&8),d=0!=(b&16);e&&null==c&&(c=JU.AU.createArrayOfArrayList(4));d&&this.needAromatic&&(this.bsAromatic=JS.SmilesAromatic.checkAromaticDefined(this.jmolAtoms,
this.bsSelected),e=!1);0>this.ringDataMax&&(this.ringDataMax=8);e&&6>this.ringDataMax&&(this.ringDataMax=6);a&&(this.ringCounts=B(this.jmolAtomCount,0),this.ringConnections=B(this.jmolAtomCount,0),this.ringData=Array(this.ringDataMax+1));this.ringSets=new JU.SB;for(var f="****";f.length<this.ringDataMax;)f+=f;var h=null;for(b=3;b<=this.ringDataMax;b++)if(!(b>this.jmolAtomCount)){var g="*1"+f.substring(0,b-2)+"*1",g=JS.SmilesParser.getMolecule(g,!0),g=this.subsearch(g,!1,!0);if(null!=c&&5>=b){for(var k=
new JU.Lst,j=g.size();0<=--j;)k.addLast(g.get(j));c[b-3]=k}if(this.needAromatic){if(!d&&(!e||5==b||6==b))for(k=g.size();0<=--k;)if(j=g.get(k),d||JS.SmilesAromatic.isFlatSp2Ring(this.jmolAtoms,this.bsSelected,j,e?0.1:0.01))if(this.bsAromatic.or(j),!e)switch(b){case 5:this.bsAromatic5.or(j);break;case 6:this.bsAromatic6.or(j)}if(e)switch(b){case 5:h=g;break;case 6:d?this.bsAromatic=JS.SmilesAromatic.checkAromaticDefined(this.jmolAtoms,this.bsAromatic):JS.SmilesAromatic.checkAromaticStrict(this.jmolAtoms,
this.bsAromatic,h,g),c[3]=new JU.Lst,this.setAromatic56(h,this.bsAromatic5,5,c[3]),this.setAromatic56(g,this.bsAromatic6,6,c[3])}}if(a){this.ringData[b]=new JU.BS;for(var n=0;n<g.size();n++){k=g.get(n);this.ringData[b].or(k);for(j=k.nextSetBit(0);0<=j;j=k.nextSetBit(j+1))this.ringCounts[j]++}}}if(a)for(b=this.bsSelected.nextSetBit(0);0<=b;b=this.bsSelected.nextSetBit(b+1))if(a=this.jmolAtoms[b],c=a.getEdges(),null!=c)for(n=c.length;0<=--n;)0<this.ringCounts[a.getBondedAtomIndex(n)]&&this.ringConnections[b]++},
"~B,~N,~A");j(c$,"setAromatic56",function(a,b,c,e){for(var d=0;d<a.size();d++){var f=a.get(d);this.v.bsTemp.clearAll();this.v.bsTemp.or(f);this.v.bsTemp.and(this.bsAromatic);this.v.bsTemp.cardinality()==c&&(b.or(f),null!=e&&e.addLast(f))}},"JU.Lst,JU.BS,~N,JU.Lst");j(c$,"subsearch",function(a,b,c){a.ringSets=this.ringSets;a.jmolAtoms=this.jmolAtoms;a.bioAtoms=this.bioAtoms;a.jmolAtomCount=this.jmolAtomCount;a.bsSelected=this.bsSelected;a.htNested=this.htNested;a.isSmilesFind=this.isSmilesFind;a.bsCheck=
this.bsCheck;a.isSmarts=!0;a.bsAromatic=this.bsAromatic;a.bsAromatic5=this.bsAromatic5;a.bsAromatic6=this.bsAromatic6;a.ringData=this.ringData;a.ringCounts=this.ringCounts;a.ringConnections=this.ringConnections;b?(a.bsRequired=null,a.firstMatchOnly=!1,a.matchAllAtoms=!1):c?(a.bsRequired=null,a.isSilent=!0,a.isRingCheck=!0,a.asVector=!0,a.matchAllAtoms=!1):(a.haveSelected=this.haveSelected,a.bsRequired=this.bsRequired,a.firstMatchOnly=this.firstMatchOnly,a.matchAllAtoms=this.matchAllAtoms,a.getMaps=
this.getMaps,a.asVector=this.asVector,a.vReturn=this.vReturn,a.bsReturn=this.bsReturn);return a.search(b)},"JS.SmilesSearch,~B,~B");j(c$,"search",function(a){this.ignoreStereochemistry=0!=(this.flags&2);this.invertStereochemistry=0!=(this.flags&4);this.noAromatic=0!=(this.flags&1);this.noncanonical=0!=(this.flags&64);this.aromaticDouble=0!=(this.flags&32);JU.Logger.debugging&&!this.isSilent&&JU.Logger.debug("SmilesSearch processing "+this.pattern);if(null==this.vReturn&&(this.asVector||this.getMaps))this.vReturn=
new JU.Lst;null==this.bsSelected&&(this.bsSelected=JU.BS.newN(this.jmolAtomCount),this.bsSelected.setBits(0,this.jmolAtomCount));this.selectedAtomCount=this.bsSelected.cardinality();if(null!=this.subSearches)for(a=0;a<this.subSearches.length&&!(null!=this.subSearches[a]&&(this.subsearch(this.subSearches[a],!1,!1),this.firstMatchOnly&&(null==this.vReturn?0<=this.bsReturn.nextSetBit(0):0<this.vReturn.size())));a++);else 0<this.ac&&this.checkMatch(null,-1,-1,a);return this.asVector||this.getMaps?this.vReturn:
this.bsReturn},"~B");j(c$,"checkMatch",function(a,b,c,e){var d;if(null==a)null==this.nestedBond?this.clearBsFound(-1):this.bsReturn.clearAll();else{if(this.bsFound.get(c)||!this.bsSelected.get(c))return!0;d=this.jmolAtoms[c];if(!this.isRingCheck&&!this.isTopology){if(null!=a.atomsOr){for(var f=0;f<a.nAtomsOr;f++)if(!this.checkMatch(a.atomsOr[f],b,c,e))return!1;return!0}if(null==a.primitives){if(!this.checkPrimitiveAtom(a,c))return!0}else for(f=0;f<a.nPrimitives;f++)if(!this.checkPrimitiveAtom(a.primitives[f],
c))return!0}d=d.getEdges();for(f=a.getBondCount();0<=--f;){var h=a.getBond(f);if(h.getAtomIndex2()==a.index){var g=h.atom1,k=g.getMatchingAtomIndex();switch(h.order){case 96:case 112:if(!this.checkMatchBond(a,g,h,c,k,null))return!0;break;default:for(var j=0;j<d.length&&(!(d[j].getAtomIndex1()==k||d[j].getAtomIndex2()==k)||!d[j].isCovalent());j++);if(j==d.length||!this.checkMatchBond(a,g,h,c,k,d[j]))return!0}}}this.patternAtoms[a.index].setMatchingAtom(this.jmolAtoms[c],c);if(JU.Logger.debugging&&
!this.isSilent){for(f=0;f<=b;f++)JU.Logger.debug("pattern atoms "+this.patternAtoms[f]);JU.Logger.debug("--ss--")}this.bsFound.set(c)}if(!this.continueMatch(b,c,e))return!1;0<=c&&this.clearBsFound(c);return!0},"JS.SmilesAtom,~N,~N,~B");j(c$,"continueMatch",function(a,b,c){var e,d;if(++a<this.ac){var f=this.patternAtoms[a],h=0<=b?f.getBondTo(null):0==a?this.nestedBond:null;if(null==h){h=JU.BSUtil.copy(this.bsFound);e=JU.BSUtil.copy(this.bsFound);if(0<=f.notBondedIndex){d=this.patternAtoms[f.notBondedIndex];
var g=d.getMatchingAtom();if(d.isBioAtom)d=g.getOffsetResidueAtom("\x00",1),0<=d&&h.set(d),d=g.getOffsetResidueAtom("\x00",-1),0<=d&&h.set(d);else{d=g.getEdges();for(var k=0;k<d.length;k++)h.set(d[k].getOtherAtomNode(g).getIndex())}}b=0<=b&&f.isBioAtom&&(null==f.atomName||null!=f.residueChar);for(g=this.bsSelected.nextSetBit(0);0<=g;g=this.bsSelected.nextSetBit(g+1)){if(!h.get(g)&&!this.checkMatch(f,a,g,c))return!1;b&&(d=this.jmolAtoms[g].getOffsetResidueAtom(f.atomName,1),0<=d&&(g=d-1))}this.bsFound=
e;return!0}e=h.atom1.getMatchingAtom();switch(h.order){case 96:g=e.getOffsetResidueAtom(f.atomName,1);if(0<=g){h=JU.BSUtil.copy(this.bsFound);e.getGroupBits(this.bsFound);if(!this.checkMatch(f,a,g,c))return!1;this.bsFound=h}return!0;case 112:b=new JU.Lst;e.getCrossLinkVector(b,!0,!0);h=JU.BSUtil.copy(this.bsFound);e.getGroupBits(this.bsFound);for(g=2;g<b.size();g+=3)if(!this.checkMatch(f,a,b.get(g).intValue(),c))return!1;this.bsFound=h;return!0}d=e.getEdges();if(null!=d)for(g=0;g<d.length;g++)if(!this.checkMatch(f,
a,e.getBondedAtomIndex(g),c))return!1;this.clearBsFound(b);return!0}if(!this.ignoreStereochemistry&&!this.checkStereochemistry())return!0;h=new JU.BS;for(g=f=0;g<this.ac;g++)if(b=this.patternAtoms[g].getMatchingAtomIndex(),c||!this.top.haveSelected||this.patternAtoms[g].selected){f++;h.set(b);this.patternAtoms[g].isBioAtom&&null==this.patternAtoms[g].atomName&&this.jmolAtoms[b].getGroupBits(h);if(c)break;!this.isSmarts&&0<this.patternAtoms[g].missingHydrogenCount&&this.getHydrogens(this.jmolAtoms[b],
h)}if(null!=this.bsRequired&&!this.bsRequired.intersects(h)||this.matchAllAtoms&&h.cardinality()!=this.selectedAtomCount)return!0;if(null!=this.bsCheck)if(c){this.bsCheck.clearAll();for(g=0;g<this.ac;g++)this.bsCheck.set(this.patternAtoms[g].getMatchingAtomIndex());if(this.bsCheck.cardinality()!=this.ac)return!0}else if(h.cardinality()!=this.ac)return!0;this.bsReturn.or(h);if(this.getMaps){a=B(f,0);for(h=g=0;g<this.ac;g++)if(c||!this.top.haveSelected||this.patternAtoms[g].selected)a[h++]=this.patternAtoms[g].getMatchingAtomIndex();
this.vReturn.addLast(a);return!this.firstMatchOnly}if(this.asVector){c=!0;for(g=this.vReturn.size();0<=--g&&c;)c=!this.vReturn.get(g).equals(h);if(!c)return!0;this.vReturn.addLast(h)}if(this.isRingCheck){this.ringSets.append(" ");for(k=3*a+2;--k>a;)this.ringSets.append("-").appendI(this.patternAtoms[(k<=2*a?2*a-k+1:k-1)%a].getMatchingAtomIndex());this.ringSets.append("- ");return!0}return this.firstMatchOnly?!1:h.cardinality()!=this.selectedAtomCount},"~N,~N,~B");j(c$,"clearBsFound",function(a){0>
a?null==this.bsCheck&&this.bsFound.clearAll():this.bsFound.clear(a)},"~N");j(c$,"getHydrogens",function(a,b){for(var c=a.getEdges(),e=-1,d=0;d<c.length;d++)if(1==this.jmolAtoms[a.getBondedAtomIndex(d)].getElementNumber()){e=a.getBondedAtomIndex(d);if(null==b)break;b.set(e)}return 0<=e?this.jmolAtoms[e]:null},"JU.Node,JU.BS");j(c$,"checkPrimitiveAtom",function(a,b){for(var c=this.jmolAtoms[b],e=a.not;;){var d;if(0<a.iNested){e=this.getNested(a.iNested);F(e,JS.SmilesSearch)&&(a.isBioAtom&&(e.nestedBond=
a.getBondTo(null)),e=this.subsearch(e,!0,!1),null==e&&(e=new JU.BS),a.isBioAtom||this.setNested(a.iNested,e));e=a.not!=e.get(b);break}if(-2147483648!=a.atomNumber&&a.atomNumber!=c.getAtomNumber())break;if(0<=a.elementNumber&&a.elementNumber!=c.getElementNumber())break;if(0<=a.jmolIndex&&c.getIndex()!=a.jmolIndex)break;if(null!=a.atomName&&(a.isLeadAtom()?!c.isLeadAtom():!a.atomName.equals(c.getAtomName().toUpperCase())))break;if(a.isBioResidue){if(null!=a.residueName&&!a.residueName.equals(c.getGroup3(!1).toUpperCase()))break;
if(-2147483648!=a.residueNumber&&a.residueNumber!=c.getResno())break;if(null!=a.residueChar||-2==a.elementNumber){d=c.getBioSmilesType();var f=a.getBioSmilesType(),h=!0,g=!1;switch(f){case "\x00":case "*":h=!0;break;case "n":h="r"==d||"c"==d;g=!0;break;case "r":case "c":g=!0;default:h=d==f}if(!h)break;h=c.getGroup1("\x00").toUpperCase();f=null==a.residueChar?"*":a.residueChar.charAt(0);h=f==h.charAt(0);switch(f){case "*":h=!0;break;case "N":h=g?"r"==d||"c"==d:h;break;case "R":h=g?c.isPurine():h;break;
case "Y":h=g?c.isPyrimidine():h}if(!h)break}if(a.isBioAtom&&a.notCrossLinked&&c.getCrossLinkVector(null,!0,!0))break}else{if(null!=a.atomType&&!a.atomType.equals(c.getAtomType()))break;d=a.isAromatic();if(!this.noAromatic&&(!a.aromaticAmbiguous&&d!=this.bsAromatic.get(b))&&(!this.noncanonical||a.getExplicitHydrogenCount()!=c.getCovalentHydrogenCount()))break;if(-2147483648!=(d=a.getAtomicMass()))if(g=c.getIsotopeNumber(),0<=d&&d!=g||0>d&&0!=g&&-d!=g)break;if(-2147483648!=(d=a.getCharge())&&d!=c.getFormalCharge())break;
d=a.getCovalentHydrogenCount()+a.missingHydrogenCount;if(0<=d&&d!=c.getCovalentHydrogenCount())break;d=a.implicitHydrogenCount;if(-2147483648!=d&&(g=c.getImplicitHydrogenCount(),-1==d?0==g:d!=g))break;if(0<a.degree&&a.degree!=c.getCovalentBondCount())break;if(0<a.nonhydrogenDegree&&a.nonhydrogenDegree!=c.getCovalentBondCount()-c.getCovalentHydrogenCount())break;if(0<a.valence&&a.valence!=c.getValence())break;if(0<a.connectivity&&a.connectivity!=c.getCovalentBondCount()+c.getImplicitHydrogenCount())break;
if(null!=this.ringData&&-1<=a.ringSize)if(0>=a.ringSize){if(0==this.ringCounts[b]!=(0==a.ringSize))break}else{c=this.ringData[500==a.ringSize?5:600==a.ringSize?6:a.ringSize];if(null==c||!c.get(b))break;if(!this.noAromatic)if(500==a.ringSize){if(!this.bsAromatic5.get(b))break}else if(600==a.ringSize&&!this.bsAromatic6.get(b))break}if(null!=this.ringData&&-1<=a.ringMembership&&(-1==a.ringMembership?0==this.ringCounts[b]:this.ringCounts[b]!=a.ringMembership))break;if(0<=a.ringConnectivity&&(d=this.ringConnections[b],
-1==a.ringConnectivity&&0==d||-1!=a.ringConnectivity&&d!=a.ringConnectivity))break}e=!e;break}return e},"JS.SmilesAtom,~N");j(c$,"checkMatchBond",function(a,b,c,e,d,f){if(null!=c.bondsOr){for(var h=0;h<c.nBondsOr;h++)if(this.checkMatchBond(a,b,c.bondsOr[h],e,d,f))return!0;return!1}if(null==c.primitives){if(!this.checkPrimitiveBond(c,e,d,f))return!1}else for(a=0;a<c.nPrimitives;a++)if(!this.checkPrimitiveBond(c.primitives[a],e,d,f))return!1;c.matchingBond=f;return!0},"JS.SmilesAtom,JS.SmilesAtom,JS.SmilesBond,~N,~N,JU.Edge");
j(c$,"checkPrimitiveBond",function(a,b,c,e){var d=!1;switch(a.order){case 96:return a.isNot!=(this.bioAtoms[c].getOffsetResidueAtom("\x00",1)==this.bioAtoms[b].getOffsetResidueAtom("\x00",0));case 112:return a.isNot!=this.bioAtoms[b].isCrossLinked(this.bioAtoms[c])}var f=!this.noAromatic&&this.bsAromatic.get(b),h=!this.noAromatic&&this.bsAromatic.get(c);e=e.getCovalentOrder();if(f&&h)switch(a.order){case 17:case 65:d=JS.SmilesSearch.isRingBond(this.ringSets,b,c);break;case 1:d=!this.isSmarts||!JS.SmilesSearch.isRingBond(this.ringSets,
b,c);break;case 2:d=!this.isSmarts||this.aromaticDouble&&(2==e||514==e);break;case 769:case 1025:case 81:case -1:d=!0}else switch(a.order){case 81:case -1:d=!0;break;case 1:case 257:case 513:d=1==e||1041==e||1025==e;break;case 769:d=e==(this.isSmilesFind?33:1);break;case 1025:d=e==(this.isSmilesFind?97:1);break;case 2:d=2==e;break;case 3:d=3==e;break;case 65:d=JS.SmilesSearch.isRingBond(this.ringSets,b,c)}return d!=a.isNot},"JS.SmilesBond,~N,~N,JU.Edge");c$.isRingBond=j(c$,"isRingBond",function(a,
b,c){return null!=a&&0<=a.indexOf("-"+b+"-"+c+"-")},"JU.SB,~N,~N");j(c$,"checkStereochemistry",function(){for(var a=0;a<this.measures.size();a++)if(!this.measures.get(a).check())return!1;if(null!=this.stereo&&!this.stereo.checkStereoChemistry(this,this.v))return!1;if(this.haveBondStereochemistry)for(a=0;a<this.ac;a++){for(var b=this.patternAtoms[a],c=null,e=null,d=null,f=0,h=0,g=0,k,j=b.getBondCount(),n=!1,l=0;l<j;l++){k=b.getBond(l);var m=k.atom2===b,t=k.order;switch(t){case 769:case 1025:case 2:if(m)continue;
c=k.atom2;g=t;(n=2!=t)&&(f=k.isNot?-1:1);break;case 257:case 513:e=m?k.atom1:k.atom2,f=m!=(257==t)?1:-1}}if(n){k=b.getBondNotTo(c,!1);if(null==k)return!1;e=k.getOtherAtom(b);k=c.getBondNotTo(b,!1);if(null==k)return!1;d=k.getOtherAtom(c)}else{if(null==c||0==f)continue;j=c.getBondCount();for(l=0;l<j&&0==h;l++)switch(k=c.getBond(l),m=k.atom2===c,t=k.order,t){case 257:case 513:d=m?k.atom1:k.atom2,h=m!=(257==t)?1:-1}if(0==h)continue}this.isSmilesFind&&this.setSmilesBondCoordinates(b,c,g);b=b.getMatchingAtom();
c=c.getMatchingAtom();e=e.getMatchingAtom();d=d.getMatchingAtom();if(null==e||null==d)return!1;JS.SmilesMeasure.setTorsionData(e,b,c,d,this.v,n);if(n){if(h=769==g?1:-1,g=this.v.vTemp1.dot(this.v.vTemp2),0.05>g||0.95<g||0<this.v.vNorm1.dot(this.v.vNorm2)*f*h)return!1}else if(0>this.v.vTemp1.dot(this.v.vTemp2)*f*h)return!1}return!0});j(c$,"setSmilesBondCoordinates",function(a,b,c){a=this.jmolAtoms[a.getMatchingAtomIndex()];b=this.jmolAtoms[b.getMatchingAtomIndex()];a.set(-1,0,0);b.set(1,0,0);if(2==
c){var e=0,d=0;c=a.getEdges();for(var f=c.length;0<=--f;){var h=c[f],g=h.getOtherAtomNode(a);if(g!==b)switch(g.set(-1,0==e++?-1:1,0),g=h.getAtomIndex2()==a.getIndex()?e:-e,h.order){case 1025:d=g;break;case 1041:d=-g}}var k=0,e=0,j=Array(2);c=b.getEdges();for(f=c.length;0<=--f;)if(h=c[f],g=h.getOtherAtomNode(b),g!==a)switch(j[e]=g,g.set(1,0==e++?1:-1,0),g=h.getAtomIndex2()==b.getIndex()?e:-e,h.order){case 1025:k=g;break;case 1041:k=-g}0<d*k==(Math.abs(d)%2==Math.abs(k)%2)&&(a=j[0].y,j[0].y=j[1].y,
j[1].y=a)}else{c=a.getEdges();j=0;for(f=c.length;0<=--f;)if(h=c[f],h.getOtherAtomNode(a)===b){j=33==h.order?1:-1;break}for(f=c.length;0<=--f;)h=c[f],g=h.getOtherAtomNode(a),g!==b&&g.set(-1,1,0);c=b.getEdges();for(f=c.length;0<=--f;)h=c[f],g=h.getOtherAtomNode(b),g!==a&&g.set(1,1,-j/2)}},"JS.SmilesAtom,JS.SmilesAtom,~N");j(c$,"getMappedAtoms",function(a,b,c){for(var e=B(null==c[4]?4:null==c[5]?5:6,0),d=0;d<e.length;d++)e[d]=null==c[d]?104+100*d:c[d].getIndex();for(var f,h=a.getEdges(),g=null==b?null:
b.getEdges(),d=0;d<e.length;d++){for(f=0;f<h.length&&h[f].getOtherAtomNode(a)!==c[d];f++);if(f<h.length)e[d]=10*f+100+d;else if(null!=b){for(f=0;f<g.length&&g[f].getOtherAtomNode(b)!==c[d];f++);f<g.length&&(e[d]=10*f+300+d)}}java.util.Arrays.sort(e);for(d=0;d<e.length;d++)e[d]%=10;return e},"JU.Node,JU.Node,~A");j(c$,"createTopoMap",function(a){null==a&&(a=new JU.BS);var b=this.getMissingHydrogenCount();this.jmolAtoms=b=Array(this.ac+b);for(var c=0,e=new JU.BS,d=0;d<this.ac;d++){var f=this.patternAtoms[d],
h=f.missingHydrogenCount;0>h&&(h=0);var g=b[c]=(new JS.SmilesAtom).setAll(0,c,f.elementNumber,f.getCharge());g.stereo=f.stereo;g.atomName=f.atomName;g.residueName=f.residueName;g.residueChar=f.residueChar;g.residueNumber=f.residueNumber;g.atomNumber=f.residueNumber;g.isBioAtom=f.isBioAtom;g.bioType=f.bioType;g.$isLeadAtom=f.$isLeadAtom;g.mapIndex=d;g.setAtomicMass(f.getAtomicMass());f.isAromatic()&&a.set(c);!f.isFirst&&(1==h&&0<f.getChiralClass())&&e.set(c);f.setMatchingAtom(null,c++);f=Array(f.getBondCount()+
h);for(g.setBonds(f);0<=--h;){f=b[c]=(new JS.SmilesAtom).setAll(0,c,1,0);f.mapIndex=-d-1;c++;f.setBonds(Array(1));var k=new JS.SmilesBond(g,f,1,!1);JU.Logger.debugging&&JU.Logger.info(""+k)}}for(d=0;d<this.ac;d++){f=this.patternAtoms[d];h=f.getMatchingAtomIndex();a=b[h];h=f.getBondCount();for(c=0;c<h;c++)if(g=f.getBond(c),g.atom1===f){k=1;switch(g.order){case 769:k=33;break;case 1025:k=97;break;case 257:k=1025;break;case 513:k=1041;break;case 112:case 96:k=g.order;break;case 1:k=1;break;case 17:k=
514;break;case 2:k=2;break;case 3:k=3}g=b[g.atom2.getMatchingAtomIndex()];k=new JS.SmilesBond(a,g,k,!1);g.bondCount--;JU.Logger.debugging&&JU.Logger.info(""+k)}else g=b[g.atom1.getMatchingAtomIndex()],k=g.getBondTo(a),a.addBond(k)}for(d=e.nextSetBit(0);0<=d;d=e.nextSetBit(d+1))f=b[d].getEdges(),k=f[0],f[0]=f[1],f[1]=k},"JU.BS");j(c$,"setTop",function(a){this.top=null==a?this:a.getTop()},"JS.SmilesSearch");j(c$,"getTop",function(){return this.top===this?this:this.top.getTop()});j(c$,"getSelections",
function(){var a=this.top.htNested;if(!(null==a||0==this.jmolAtoms.length))for(var b=new java.util.Hashtable,c,a=a.entrySet().iterator();a.hasNext()&&((c=a.next())||1);){var e=c.getValue().toString();if(e.startsWith("select")){var d=b.containsKey(e)?b.get(e):this.jmolAtoms[0].findAtomsLike(e.substring(6));null==d&&(d=new JU.BS);b.put(e,d);c.setValue(d)}}});M(c$,"INITIAL_ATOMS",16)});u("JS");E(["java.util.Hashtable","JU.BS","JS.VTemp"],"JS.SmilesGenerator","JU.Lst $.SB JS.InvalidSmilesException $.SmilesAtom $.SmilesBond $.SmilesParser $.SmilesSearch $.SmilesStereo JU.BNode $.BSUtil $.Elements $.JmolMolecule $.Logger".split(" "),
function(){c$=H(function(){this.atoms=null;this.ac=0;this.bsAromatic=this.bsSelected=null;this.explicitH=!1;this.vTemp=this.ringSets=null;this.nPairsMax=this.nPairs=0;this.bsIncludingH=this.bsRingKeys=this.htRings=this.htRingsSequence=this.prevSp2Atoms=this.prevAtom=this.bsToDo=this.bsBondsDn=this.bsBondsUp=null;this.topologyOnly=!1;this.getAromatic=!0;this.noStereo=this.noBioComment=this.addAtomComment=!1;this.smilesStereo=this.stereoReference=null;this.isPolyhedral=!1;G(this,arguments)},JS,"SmilesGenerator");
N(c$,function(){this.vTemp=new JS.VTemp;this.bsBondsUp=new JU.BS;this.bsBondsDn=new JU.BS;this.htRingsSequence=new java.util.Hashtable;this.htRings=new java.util.Hashtable;this.bsRingKeys=new JU.BS});j(c$,"getSmiles",function(a,b,c,e,d){var f=c.nextSetBit(0);if(0>f)return"";this.atoms=a;this.ac=b;this.addAtomComment=524288==(d&524288);c=JU.BSUtil.copy(c);if(65536==(d&65536))return this.getBioSmiles(c,e,d);this.bsSelected=c;this.explicitH=256==(d&256);this.topologyOnly=512==(d&512);this.getAromatic=
1024!=(d&1024);this.noStereo=2048==(d&2048);this.isPolyhedral=4096==(d&4096);return this.getSmilesComponent(a[f],c,!0,!1,!1)},"~A,~N,JU.BS,~S,~N");j(c$,"getBioSmiles",function(a,b,c){this.addAtomComment=524288==(c&524288);var e=69632==(c&69632),d=327680==(c&327680),f=73728==(c&73728);c=90112==(c&90112);var h=f||c,g=new JU.SB;null!=b&&!this.noBioComment&&g.append("//* Jmol bioSMILES ").append(b.$replace("*","_")).append(" *//");b=this.noBioComment?"":"\n";var k=new JU.BS,j=null,n="",l,m=new JU.Lst;
try{for(var t=0,s=a.nextSetBit(0);0<=s;s=a.nextSetBit(s+1)){var q=this.atoms[s],p=q.getGroup1("?"),r=q.getBioStructureTypeName(),w=p===p.toLowerCase();if(null!=b)if(0<g.length()&&g.append(b),b=null,t=0,0<r.length)0!=q.getChainID()&&!d&&(l="//* chain "+q.getChainIDStr()+" "+r+" "+q.getResno()+" *// ",t=l.length,g.append(l)),t++,g.append("~").appendC(r.toLowerCase().charAt(0)).append("~");else{l=this.getSmilesComponent(q,a,!1,!0,!0);if(l.equals(j)){b="";continue}var j=l,L=q.getGroup3(!0),y;d?y="/"+
l+"/":(null!=L&&(l="//* "+L+" *//"+l),y=l+"//");if(0<=n.indexOf(y)){b="";continue}n+=y;g.append(l);b=d?".":".\n";continue}75<=t&&!d&&(g.append("\n  "),t=2);this.addAtomComment&&g.append("\n//* ["+q.getGroup3(!1)+"#"+q.getResno()+"] *//\t");w?this.addBracketedBioName(g,q,0<r.length?".0":null,!1):g.append(p);t++;if(h){q.getCrossLinkVector(m,f,c);for(var A=0;A<m.size();A+=3)g.append(":"),l=this.getRingCache(m.get(A).intValue(),m.get(A+1).intValue(),this.htRingsSequence),g.append(l),t+=1+l.length;m.clear()}q.getGroupBits(k);
a.andNot(k);var v=q.getOffsetResidueAtom("\x00",1);if(0>v||!a.get(v)){d||g.append(" //* ").appendI(q.getResno()).append(" *//");if(0>v&&0>(v=a.nextSetBit(s+1)))break;0<t&&(b=d?".":".\n")}s=v-1}}catch(x){if(I(x,Exception))throw new JS.InvalidSmilesException("//* error: "+x.getMessage()+" *//");throw x;}if(!e&&!this.htRingsSequence.isEmpty())throw this.dumpRingKeys(g,this.htRingsSequence),new JS.InvalidSmilesException("//* ?ring error? *//");l=g.toString();l.endsWith(".\n")?l=l.substring(0,l.length-
2):d&&l.endsWith(".")&&(l=l.substring(0,l.length-1));return l},"JU.BS,~S,~N");j(c$,"addBracketedBioName",function(a,b,c,e){a.append("[");if(null!=c&&F(b,JU.BNode)){var d=b.getChainIDStr();a.append(b.getGroup3(!1));c.equals(".0")||a.append(c).append("#").appendI(b.getElementNumber());e&&(a.append("//* ").appendI(b.getResno()),0<d.length&&a.append(":").append(d),a.append(" *//"))}else a.append(JU.Elements.elementNameFromNumber(b.getElementNumber()));a.append("]")},"JU.SB,JU.Node,~S,~B");j(c$,"getSmilesComponent",
function(a,b,c,e,d){!this.explicitH&&(1==a.getElementNumber()&&0<a.getEdges().length)&&(a=this.atoms[a.getBondedAtomIndex(0)]);this.bsSelected=JU.JmolMolecule.getBranchBitSet(this.atoms,a.getIndex(),JU.BSUtil.copy(b),null,-1,!0,c);b.andNot(this.bsSelected);this.bsIncludingH=JU.BSUtil.copy(this.bsSelected);if(!this.explicitH)for(b=this.bsSelected.nextSetBit(0);0<=b;b=this.bsSelected.nextSetBit(b+1))c=this.atoms[b],1==c.getElementNumber()&&0==c.getIsotopeNumber()&&this.bsSelected.clear(b);this.getAromatic&&
!this.topologyOnly&&2<this.bsSelected.cardinality()?(b=null,b=JS.SmilesParser.getMolecule("A[=&@]A",!0),b.jmolAtoms=this.atoms,F(this.atoms,Array)&&(b.bioAtoms=this.atoms),b.setSelected(this.bsSelected),b.jmolAtomCount=this.ac,b.ringDataMax=7,b.setRingData(null),this.bsAromatic=b.bsAromatic,this.ringSets=b.ringSets,this.setBondDirections()):this.bsAromatic=new JU.BS;this.bsToDo=JU.BSUtil.copy(this.bsSelected);b=new JU.SB;for(c=this.bsToDo.nextSetBit(0);0<=c;c=this.bsToDo.nextSetBit(c+1))if(4<this.atoms[c].getCovalentBondCount()||
this.isPolyhedral)null==a&&b.append("."),this.getSmilesAt(b,this.atoms[c],e,!1,this.explicitH,d),a=null;if(null!=a)for(;null!=(a=this.getSmilesAt(b,a,e,!0,this.explicitH,d)););for(;0<this.bsToDo.cardinality()||!this.htRings.isEmpty();){a=this.htRings.values().iterator();if(a.hasNext()){if(a=this.atoms[a.next()[1].intValue()],!this.bsToDo.get(a.getIndex()))break}else a=this.atoms[this.bsToDo.nextSetBit(0)];b.append(".");for(this.prevAtom=this.prevSp2Atoms=null;null!=(a=this.getSmilesAt(b,a,e,!0,this.explicitH,
d)););}if(!this.htRings.isEmpty())throw this.dumpRingKeys(b,this.htRings),new JS.InvalidSmilesException("//* ?ring error? *//\n"+b);return b.toString()},"JU.Node,JU.BS,~B,~B,~B");j(c$,"getBondStereochemistry",function(a,b){if(null==a)return"\x00";var c=a.index,e=null==b||a.getAtomIndex1()==b.getIndex();return this.bsBondsUp.get(c)?e?"/":"\\":this.bsBondsDn.get(c)?e?"\\":"/":"\x00"},"JU.Edge,JU.Node");j(c$,"setBondDirections",function(){for(var a=new JU.BS,b=O(2,3,null),c=this.bsSelected.nextSetBit(0);0<=
c;c=this.bsSelected.nextSetBit(c+1))for(var e=this.atoms[c],d=e.getEdges(),f=0;f<d.length;f++){var h=d[f],g=h.index;if(!a.get(g)){var k=h.getOtherAtomNode(e);if(!(2!=h.getCovalentOrder()||JS.SmilesSearch.isRingBond(this.ringSets,c,k.getIndex()))){a.set(g);var j=h=null,g=0,n=O(-1,[e,k]);JU.Logger.debugging&&JU.Logger.debug(e+" == "+k);j=1;for(k=0;2>k&&0<j&&3>j;k++)for(var j=0,l=n[k],m=l.getEdges(),t=0;t<m.length;t++)1==m[t].getCovalentOrder()&&(b[k][j++]=m[t],"\x00"!=this.getBondStereochemistry(m[t],
l)&&(h=m[t],g=k));if(!(3==j||0==j))if(null==h&&(g=0,h=b[g][0],this.bsBondsUp.set(h.index)),l=this.getBondStereochemistry(h,n[g]),j=h.getOtherAtomNode(n[g]),null!=j)for(k=0;2>k;k++)for(m=0;2>m;m++)if(t=b[k][m],!(null==t||t===h)){var p=t.index,q=t.getOtherAtomNode(n[k]);if(null!=q){var z=this.getBondStereochemistry(t,n[k]),r=JS.SmilesStereo.isDiaxial(n[g],n[k],j,q,this.vTemp,0);"\x00"==z||z!=l==r?("\\"==l&&r||"/"==l&&!r)==(t.getAtomIndex1()!=q.getIndex())?this.bsBondsUp.set(p):this.bsBondsDn.set(p):
JU.Logger.error("BOND STEREOCHEMISTRY ERROR");JU.Logger.debugging&&JU.Logger.debug(this.getBondStereochemistry(h,n[0])+" "+j.getIndex()+" "+q.getIndex()+" "+this.getBondStereochemistry(t,n[k]))}}}}}});j(c$,"getSmilesAt",function(a,b,c,e,d,f){var h=b.getIndex();if(!this.bsToDo.get(h))return null;this.bsToDo.clear(h);var g=!this.bsSelected.get(h),k=null==this.prevAtom?-1:this.prevAtom.getIndex(),j=this.bsAromatic.get(h),n=null!=this.prevSp2Atoms,l=this.prevSp2Atoms,m=0,t=b.getElementNumber(),p=0,q=
new JU.Lst,z=null,r=null,w=b.getEdges();null!=this.stereoReference&&(e=!1,this.sortBonds(b,this.prevAtom,this.stereoReference));var L=null,y=j?10:0,A=Array(7);JU.Logger.debugging&&JU.Logger.debug(a.toString());if(null!=w)for(var v=w.length;0<=--v;){var x=w[v];if(x.isCovalent()){var C=w[v].getOtherAtomNode(b),x=C.getIndex();if(x==k)r=w[v];else{var D=!d&&1==C.getElementNumber()&&0==C.getIsotopeNumber();if(!this.bsIncludingH.get(x))if(!D&&c&&this.bsSelected.get(h))this.bsToDo.set(x);else continue;D?
(L=C,p++,1<p&&(y=10)):q.addLast(w[v])}}}w=null;null==l&&(l=Array(5));null!=r&&(w=j&&this.bsAromatic.get(k)?"":JS.SmilesBond.getBondOrderString(r.getCovalentOrder()),null==this.prevSp2Atoms?l[m++]=this.prevAtom:m=2);var m=m+p,k=0,B=new JU.BS;if(e)for(v=0;v<q.size();v++){var x=q.get(v),D=x.getOtherAtomNode(b),C=D.getCovalentBondCount()-(d?0:D.getCovalentHydrogenCount()),u=x.getCovalentOrder();if(1==u&&1==C&&v<q.size()-(null==z?1:0))B.set(x.index);else if((1<u||C>k)&&!this.htRings.containsKey(JS.SmilesGenerator.getRingKey(D.getIndex(),
h)))k=1<u?1E3+u:C,z=x}k=null==z?null:z.getOtherAtomNode(b);C=null==z?0:z.getCovalentOrder();7>y&&null!=r&&(2==r.getCovalentOrder()&&2==C&&null!=this.prevSp2Atoms&&null!=this.prevSp2Atoms[1]?(A[y++]=this.prevSp2Atoms[0],A[y++]=this.prevSp2Atoms[1]):A[y++]=this.prevAtom);7>y&&1==p&&(A[y++]=L);L=1==C&&null==this.prevSp2Atoms;u=this.getBondStereochemistry(r,this.prevAtom);r=new JU.SB;for(v=0;v<q.size();v++)x=q.get(v),B.get(x.index)&&(D=x.getOtherAtomNode(b),x=new JU.SB,x.append("("),this.prevAtom=b,this.prevSp2Atoms=
null,this.getSmilesAt(x,D,c,e,d,f),x.append(")"),0<=r.indexOf(x.toString())&&(y=10),r.appendSB(x),q.remove(v--),7>y&&(A[y++]=D),5>m&&(l[m++]=D));v=2==C?k.getIndex():-1;if(1<p||j||0>v||JS.SmilesSearch.isRingBond(this.ringSets,h,v))m=-1;0>m&&(l=null);if(null!=w||"\x00"!=u)"\x00"!=u&&(w=""+u),a.append(w);c=null;if(!e&&!this.noStereo&&null==this.stereoReference&&(5==q.size()||6==q.size()))c=this.sortInorganic(b,q,this.vTemp);for(v=0;v<q.size();v++)x=q.get(v),x!==z&&(D=x.getOtherAtomNode(b),w=JS.SmilesBond.getBondOrderString(x.order),
L||(u=this.getBondStereochemistry(x,b),"\x00"!=u&&(w=""+u)),r.append(w),r.append(this.getRingCache(h,D.getIndex(),this.htRings)),7>y&&(A[y++]=D),null!=l&&5>m&&(l[m++]=D));if(n&&2==y&&2==C&&3==k.getCovalentBondCount()){w=k.getEdges();for(m=0;m<w.length;m++)w[m].isCovalent()&&k.getBondedAtomIndex(m)!=h&&(A[y++]=this.atoms[k.getBondedAtomIndex(m)]);m=0}else null!=k&&7>y&&(A[y++]=k);e=b.getFormalCharge();n=b.getIsotopeNumber();q=b.getValence();v=b.getAtomName();d=F(b,JU.BNode)?b.getBioStructureTypeName():
"";this.addAtomComment&&a.append("\n//* "+b.toString()+" *//\t");this.topologyOnly?a.append("*"):g&&0!=d.length&&0!=v.length?this.addBracketedBioName(a,b,"."+v,!1):a.append(JS.SmilesAtom.getAtomLabel(t,n,f?-1:q,e,p,j,null!=c?c:this.noStereo?null:this.checkStereoPairs(b,h,A,y)));a.appendSB(r);if(null==z)return null;2==C&&(1==m||2==m)?(null==l[0]&&(l[0]=b),null==l[1]&&(l[1]=b)):l=null;this.prevSp2Atoms=l;this.prevAtom=b;return k},"JU.SB,JU.Node,~B,~B,~B,~B");j(c$,"sortBonds",function(a,b,c){if(null==
this.smilesStereo)try{this.smilesStereo=JS.SmilesStereo.newStereo(null)}catch(e){if(!I(e,JS.InvalidSmilesException))throw e;}this.smilesStereo.sortBondsByStereo(a,b,c,a.getEdges(),this.vTemp.vA)},"JU.Node,JU.Node,JU.P3");j(c$,"sortInorganic",function(a,b,c){for(var e=a.getIndex(),d=b.size(),f=new JU.Lst,h=new JU.Lst,g,k,j,n,l=new JU.BS,m=null,p=Array(6),m=!0,s="",q=0;q<d;q++)if(j=b.get(q),p[0]=g=j.getOtherAtomNode(a),0==q?s=this.addStereoCheck(e,p,0,""):m&&null!=this.addStereoCheck(e,p,0,s)&&(m=!1),
!l.get(q)){l.set(q);for(var z=!1,r=q+1;r<d;r++)if(!l.get(r)&&(n=b.get(r),k=n.getOtherAtomNode(a),JS.SmilesStereo.isDiaxial(a,a,g,k,c,-0.95))){f.addLast(O(-1,[j,n]));z=!0;l.set(r);break}z||h.addLast(j)}e=f.size();if(m||6==d&&3!=e||5==d&&0==e)return"";m=f.get(0);j=m[0];p[0]=j.getOtherAtomNode(a);b.clear();b.addLast(j);1<e&&h.addLast(f.get(1)[0]);3==e&&h.addLast(f.get(2)[0]);1<e&&h.addLast(f.get(1)[1]);3==e&&h.addLast(f.get(2)[1]);for(q=0;q<h.size();q++)j=h.get(q),b.addLast(j),p[q+1]=j.getOtherAtomNode(a);
b.addLast(m[1]);return JS.SmilesStereo.getStereoFlag(a,p,d,c)},"JU.Node,JU.Lst,JS.VTemp");j(c$,"checkStereoPairs",function(a,b,c,e){if(4>e)return"";if(4==e&&6==a.getElementNumber())for(var d="",f=0;4>f;f++)if(null==(d=this.addStereoCheck(b,c,f,d))){e=10;break}return 6<e?"":JS.SmilesStereo.getStereoFlag(a,c,e,this.vTemp)},"JU.Node,~N,~A,~N");j(c$,"addStereoCheck",function(a,b,c,e){var d=b[c].getAtomicAndIsotopeNumber(),f=b[c].getCovalentBondCount(),h=6==d&&!this.explicitH?b[c].getCovalentHydrogenCount():
0;if(6==d?4!=f||3!=h:1<f)return e;d=";"+d+"/"+h+"/"+f+",";if(0<=e.indexOf(d)){if(3==h){for(d=h=0;d<f&&3>h;d++){var g=b[c].getBondedAtomIndex(d);g!=a&&(h+=this.atoms[g].getAtomicAndIsotopeNumber())}if(3<h)return e}return null}return e+d},"~N,~A,~N,~S");j(c$,"getRingCache",function(a,b,c){var e=JS.SmilesGenerator.getRingKey(a,b),d=c.get(e),f=null==d?null:d[0];if(null==f)this.bsRingKeys.set(++this.nPairs),this.nPairsMax=Math.max(this.nPairs,this.nPairsMax),c.put(e,O(-1,[f=this.getRingPointer(this.nPairs),
Integer.$valueOf(b),Integer.$valueOf(this.nPairs)])),JU.Logger.debugging&&JU.Logger.debug("adding for "+a+" ring key "+this.nPairs+": "+e);else{c.remove(e);a=d[2].intValue();this.bsRingKeys.clear(a);if(0>this.bsRingKeys.nextSetBit(0)&&(2==this.nPairsMax||99==this.nPairsMax))this.nPairsMax=this.nPairs=99==this.nPairsMax?10:0;JU.Logger.debugging&&JU.Logger.debug("using ring key "+e)}return f},"~N,~N,java.util.Map");j(c$,"getRingPointer",function(a){return 10>a?""+a:100>a?"%"+a:"%("+a+")"},"~N");j(c$,
"dumpRingKeys",function(a,b){JU.Logger.info(a.toString()+"\n\n");for(var c,e=b.keySet().iterator();e.hasNext()&&((c=e.next())||1);)JU.Logger.info("unmatched ring key: "+c)},"JU.SB,java.util.Map");c$.getRingKey=j(c$,"getRingKey",function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)},"~N,~N")});u("JS");E(null,"JS.SmilesAromatic",["JU.BS","$.V3"],function(){c$=R(JS,"SmilesAromatic");c$.isFlatSp2Ring=j(c$,"isFlatSp2Ring",function(a,b,c,e){for(var d=c.nextSetBit(0);0<=d;d=c.nextSetBit(d+1)){var f=a[d],
h=f.getEdges();if(!(3>h.length)&&3<h.length)return!1}if(3.4028235E38==e)return!0;0>=e&&(e=0.01);for(var g=new JU.V3,k=new JU.V3,j=new JU.V3,n=null,d=c.cardinality(),l=Array(2*d),m=0,p=1-5*e,d=c.nextSetBit(0);0<=d;d=c.nextSetBit(d+1)){for(var f=a[d],h=f.getEdges(),s=-1,q=-1,z=-1,h=h.length;0<=--h;){var r=f.getBondedAtomIndex(h);b.get(r)&&(c.get(r)?0>q?q=r:z=r:s=r)}JS.SmilesAromatic.getNormalThroughPoints(a[q],a[d],a[z],g,k,j);null==n&&(n=new JU.V3);if(!JS.SmilesAromatic.addNormal(g,n,p))return!1;l[m++]=
JU.V3.newV(g);if(0<=s){JS.SmilesAromatic.getNormalThroughPoints(a[q],a[s],a[z],g,k,j);if(!JS.SmilesAromatic.addNormal(g,n,p))return!1;l[m++]=JU.V3.newV(g)}}return JS.SmilesAromatic.checkStandardDeviation(l,n,m,e)},"~A,JU.BS,JU.BS,~N");c$.addNormal=j(c$,"addNormal",function(a,b,c){var e=b.dot(a);if(0!=e&&Math.abs(e)<c)return!1;0>e&&a.scale(-1);b.add(a);b.normalize();return!0},"JU.V3,JU.V3,~N");c$.checkStandardDeviation=j(c$,"checkStandardDeviation",function(a,b,c,e){for(var d=0,f=0,h=0;h<c;h++)var g=
a[h].dot(b),d=d+g,f=f+g*g;d=Math.sqrt((f-d*d/c)/(c-1));return d<e},"~A,JU.V3,~N,~N");c$.getNormalThroughPoints=j(c$,"getNormalThroughPoints",function(a,b,c,e,d,f){d.sub2(b,a);f.sub2(c,a);e.cross(d,f);e.normalize();d.setT(a);return-d.dot(e)},"JU.Node,JU.Node,JU.Node,JU.V3,JU.V3,JU.V3");c$.checkAromaticDefined=j(c$,"checkAromaticDefined",function(a,b){for(var c=new JU.BS,e=b.nextSetBit(0);0<=e;e=b.nextSetBit(e+1))for(var d=a[e].getEdges(),f=0;f<d.length;f++)switch(d[f].order){case 515:case 514:case 513:c.set(d[f].getAtomIndex1()),
c.set(d[f].getAtomIndex2())}return c},"~A,JU.BS");c$.checkAromaticStrict=j(c$,"checkAromaticStrict",function(a,b,c,e){for(var d=new JU.BS,f=new JU.BS,h=c.size();0<=--h;){var g=c.get(h);JS.SmilesAromatic.isAromaticRing(b,f,g,5)&&JS.SmilesAromatic.checkAromaticStrict2(a,d,c,e,g,!0)}for(h=e.size();0<=--h;)g=e.get(h),JS.SmilesAromatic.isAromaticRing(b,f,g,6)&&JS.SmilesAromatic.checkAromaticStrict2(a,d,c,e,g,!1);b.clearAll();b.or(d)},"~A,JU.BS,JU.Lst,JU.Lst");c$.isAromaticRing=j(c$,"isAromaticRing",function(a,
b,c,e){b.clearAll();b.or(c);b.and(a);return b.cardinality()==e},"JU.BS,JU.BS,JU.BS,~N");c$.checkAromaticStrict2=j(c$,"checkAromaticStrict2",function(a,b,c,e,d,f){f=JS.SmilesAromatic.countInternalPairs(a,d,f)<<1;switch(f){case -3:break;default:for(var h=d.nextSetBit(0);0<=h;h=d.nextSetBit(h+1))for(var g=a[h].getEdges(),k=0;k<g.length;k++)if(2==g[k].order){var j=g[k].getOtherAtomNode(a[h]).getIndex();if(!d.get(j)){for(var n=!1,l=c.size();0<=--l&&!n;){var m=c.get(l);if(m.get(j)&&(b.get(j)||3==Math.abs(JS.SmilesAromatic.countInternalPairs(a,
m,!0))))n=!0}for(l=e.size();0<=--l&&!n;)if(m=e.get(l),m.get(j)&&(b.get(j)||3==Math.abs(JS.SmilesAromatic.countInternalPairs(a,m,!1))))n=!0;if(!n)return;f++}}}6==f&&b.or(d)},"~A,JU.BS,JU.Lst,JU.Lst,JU.BS,~B");c$.countInternalPairs=j(c$,"countInternalPairs",function(a,b,c){for(var e=0,d=0,f=0,h=b.nextSetBit(0);0<=h;h=b.nextSetBit(h+1)){for(var g=a[h],k=g.getEdges(),j=!1,n=0;n<k.length;n++){var l=k[n].getOtherAtomNode(g).getIndex();if(b.get(l))switch(k[n].order){case 514:case 513:case 515:d++;break;
case 2:e++,j=!0}}if(c&&0==d)switch(g.getElementNumber()){case 7:case 8:case 16:j||f++}}return 0==d?S(e/2)+f:d==(c?5:6)?-3:0},"~A,JU.BS,~B")});u("JS");E(["JU.P3","JU.BNode"],"JS.SmilesAtom",["JU.AU","JU.Elements","$.Logger"],function(){c$=H(function(){this.atomsOr=null;this.nAtomsOr=0;this.primitives=null;this.index=this.nPrimitives=0;this.residueChar=this.residueName=this.referance=this.atomName=null;this.isBioResidue=this.isBioAtom=!1;this.bioType="\x00";this.$isLeadAtom=!1;this.notBondedIndex=-1;
this.notCrossLinked=!1;this.aromaticAmbiguous=!0;this.atomType=null;this.covalentHydrogenCount=-1;this.hasSymbol=this.selected=this.not=!1;this.isFirst=!0;this.jmolIndex=-1;this.elementNumber=-2;this.implicitHydrogenCount=this.missingHydrogenCount=this.residueNumber=this.atomNumber=-2147483648;this.bonds=this.parent=null;this.iNested=this.bondCount=0;this.charge=this.atomicMass=-2147483648;this.matchingIndex=-1;this.stereo=null;this.$isAromatic=!1;this.atomSite=this.component=0;this.nonhydrogenDegree=
this.degree=-1;this.valence=0;this.connectivity=-1;this.ringSize=this.ringMembership=-2147483648;this.ringConnectivity=-1;this.matchingNode=null;this.hasSubpattern=!1;this.mapIndex=-1;G(this,arguments)},JS,"SmilesAtom",JU.P3,JU.BNode);N(c$,function(){this.bonds=Array(4)});c$.allowSmilesUnbracketed=j(c$,"allowSmilesUnbracketed",function(a){return 0<="B, C, N, O, P, S, F, Cl, Br, I, *,".indexOf(a+",")},"~S");K(c$,function(){P(this,JS.SmilesAtom,[])});j(c$,"getChiralClass",function(){return null==this.stereo?
0:this.stereo.chiralClass});j(c$,"isDefined",function(){return this.hasSubpattern||0!=this.iNested||this.isBioAtom||-2!=this.elementNumber||0<this.nAtomsOr||0<this.nPrimitives});j(c$,"setBioAtom",function(a){this.isBioAtom="\x00"!=a;this.bioType=a;null!=this.parent&&(this.parent.bioType=a,this.parent.isBioAtom=this.isBioAtom)},"~S");j(c$,"setAtomName",function(a){null!=a&&(0<a.length&&(this.atomName=a),a.equals("\x00")&&(this.$isLeadAtom=!0),null!=this.parent&&(this.parent.atomName=a))},"~S");j(c$,
"setBonds",function(a){this.bonds=a},"~A");j(c$,"appendAtomOr",function(a){null==this.atomsOr&&(this.atomsOr=Array(2));this.nAtomsOr>=this.atomsOr.length&&(this.atomsOr=JU.AU.doubleLength(this.atomsOr));a.setIndex(this.index);a.parent=this;return this.atomsOr[this.nAtomsOr++]=a},"JS.SmilesAtom");j(c$,"appendPrimitive",function(a){null==this.primitives&&(this.primitives=Array(2));this.nPrimitives>=this.primitives.length&&(this.primitives=JU.AU.doubleLength(this.primitives));a.setIndex(this.index);
a.parent=this;this.primitives[this.nPrimitives++]=a;this.setSymbol("*");this.hasSymbol=!1;return a},"JS.SmilesAtom");j(c$,"setIndex",function(a){this.index=a;return this},"~N");j(c$,"setAll",function(a,b,c,e){this.component=a;this.index=b;this.elementNumber=c;this.charge=e;return this},"~N,~N,~N,~N");j(c$,"setHydrogenCount",function(){if(-2147483648!=this.missingHydrogenCount)return!0;var a=JS.SmilesAtom.getDefaultCount(this.elementNumber,this.$isAromatic);if(0>a)return-1==a;7==this.elementNumber&&
this.$isAromatic&&2==this.bondCount&&1==this.bonds[0].order&&1==this.bonds[1].order&&a++;for(var b=0;b<this.bondCount;b++)switch(this.bonds[b].order){case 81:7==this.elementNumber&&JU.Logger.info("Ambiguous bonding to aromatic N found -- MF may be in error");a-=1;break;case 1:case 257:case 513:a-=1;break;case 2:a-=this.$isAromatic&&6==this.elementNumber?1:2;break;case 3:a-=3}0<=a&&(this.missingHydrogenCount=a);return!0},"JS.SmilesSearch");c$.getDefaultCount=j(c$,"getDefaultCount",function(a,b){switch(a){case 0:case -1:case -2:return-1;
case 6:return b?3:4;case 8:case 16:return 2;case 7:return b?2:3;case 5:case 15:return 3;case 9:case 17:case 35:case 53:return 1}return-2},"~N,~B");p(c$,"getIndex",function(){return this.index});j(c$,"isAromatic",function(){return this.$isAromatic});j(c$,"setSymbol",function(a){this.$isAromatic=a.equals(a.toLowerCase());this.hasSymbol=!0;if(a.equals("*"))return this.$isAromatic=!1,this.elementNumber=-2,!0;if(a.equals("Xx"))return this.elementNumber=0,!0;this.aromaticAmbiguous=!1;if(a.equals("a")||
a.equals("A"))return 0>this.elementNumber&&(this.elementNumber=-1),!0;this.$isAromatic&&(a=a.substring(0,1).toUpperCase()+(1==a.length?"":a.substring(1)));this.elementNumber=JU.Elements.elementNumberFromSymbol(a,!0);return 0!=this.elementNumber},"~S");p(c$,"getElementNumber",function(){return this.elementNumber});j(c$,"getAtomicMass",function(){return this.atomicMass});p(c$,"getAtomNumber",function(){return this.atomNumber});j(c$,"setAtomicMass",function(a){this.atomicMass=a},"~N");j(c$,"getCharge",
function(){return this.charge});j(c$,"setCharge",function(a){this.charge=a},"~N");j(c$,"getMatchingAtomIndex",function(){return this.matchingIndex});j(c$,"getMatchingAtom",function(){return this.matchingNode});j(c$,"setMatchingAtom",function(a,b){this.matchingNode=a;this.matchingIndex=b},"JU.Node,~N");j(c$,"setExplicitHydrogenCount",function(a){this.missingHydrogenCount=a},"~N");j(c$,"setImplicitHydrogenCount",function(a){this.implicitHydrogenCount=a},"~N");j(c$,"setDegree",function(a){this.degree=
a},"~N");j(c$,"setNonhydrogenDegree",function(a){this.nonhydrogenDegree=a},"~N");j(c$,"setValence",function(a){this.valence=a},"~N");j(c$,"setConnectivity",function(a){this.connectivity=a},"~N");j(c$,"setRingMembership",function(a){this.ringMembership=a},"~N");j(c$,"setRingSize",function(a){this.ringSize=a},"~N");j(c$,"setRingConnectivity",function(a){this.ringConnectivity=a},"~N");p(c$,"getModelIndex",function(){return this.component});p(c$,"getAtomSite",function(){return this.atomSite});p(c$,"getImplicitHydrogenCount",
function(){return 0});j(c$,"getExplicitHydrogenCount",function(){System.out.println(this+" "+this.missingHydrogenCount);return this.missingHydrogenCount});p(c$,"getFormalCharge",function(){return this.charge});p(c$,"getIsotopeNumber",function(){return this.atomicMass});p(c$,"getAtomicAndIsotopeNumber",function(){return JU.Elements.getAtomicAndIsotopeNumber(this.elementNumber,this.atomicMass)});p(c$,"getAtomName",function(){return null==this.atomName?"":this.atomName});p(c$,"getGroup3",function(){return null==
this.residueName?"":this.residueName},"~B");p(c$,"getGroup1",function(){return null==this.residueChar?"":this.residueChar},"~S");j(c$,"addBond",function(a){this.bondCount>=this.bonds.length&&(this.bonds=JU.AU.doubleLength(this.bonds));this.bonds[this.bondCount]=a;this.bondCount++},"JS.SmilesBond");j(c$,"setBondArray",function(){this.bonds.length>this.bondCount&&(this.bonds=JU.AU.arrayCopyObject(this.bonds,this.bondCount));null!=this.atomsOr&&this.atomsOr.length>this.nAtomsOr&&(this.atomsOr=JU.AU.arrayCopyObject(this.atomsOr,
this.atomsOr.length));null!=this.primitives&&this.primitives.length>this.nPrimitives&&(this.primitives=JU.AU.arrayCopyObject(this.primitives,this.primitives.length));for(var a=0;a<this.bonds.length;a++)this.isBioAtom&&17==this.bonds[a].order&&(this.bonds[a].order=112),this.bonds[a].atom1.index>this.bonds[a].atom2.index&&this.bonds[a].switchAtoms()});p(c$,"getEdges",function(){return null!=this.parent?this.parent.getEdges():this.bonds});j(c$,"getBond",function(a){return null!=this.parent?this.parent.getBond(a):
0<=a&&a<this.bondCount?this.bonds[a]:null},"~N");p(c$,"getCovalentBondCount",function(){return this.getBondCount()});p(c$,"getBondCount",function(){return null!=this.parent?this.parent.getCovalentBondCount():this.bondCount});j(c$,"getMatchingBondedAtom",function(a){if(null!=this.parent)return this.parent.getMatchingBondedAtom(a);if(a>=this.bondCount)return-1;a=this.bonds[a];return(a.atom1===this?a.atom2:a.atom1).matchingIndex},"~N");p(c$,"getBondedAtomIndex",function(a){return null!=this.parent?this.parent.getBondedAtomIndex(a):
this.bonds[a].getOtherAtom(this).index},"~N");p(c$,"getCovalentHydrogenCount",function(){if(0<=this.covalentHydrogenCount)return this.covalentHydrogenCount;if(null!=this.parent)return this.parent.getCovalentHydrogenCount();for(var a=this.covalentHydrogenCount=0;a<this.bonds.length;a++)1==this.bonds[a].getOtherAtom(this).elementNumber&&this.covalentHydrogenCount++;return this.covalentHydrogenCount});p(c$,"getValence",function(){if(null!=this.parent)return this.parent.getValence();var a=this.valence;
if(0>=a&&null!=this.bonds)for(var b=this.bonds.length;0<=--b;)a+=this.bonds[b].getValence();return this.valence=a});j(c$,"getBondTo",function(a){if(null!=this.parent)return this.parent.getBondTo(a);for(var b,c=0;c<this.bonds.length;c++)if(null!=(b=this.bonds[c]))if(null==a?b.atom2===this:b.getOtherAtom(this)===a)return b;return null},"JS.SmilesAtom");j(c$,"getBondNotTo",function(a,b){for(var c,e=0;e<this.bonds.length;e++)if(null!=(c=this.bonds[e])){var d=c.getOtherAtom(this);if(a!==d&&(b||1!=d.elementNumber))return c}return null},
"JS.SmilesAtom,~B");p(c$,"isLeadAtom",function(){return this.$isLeadAtom});p(c$,"getOffsetResidueAtom",function(a,b){if(this.isBioAtom){if(0==b)return this.index;for(var c=0;c<this.bonds.length;c++)if(this.bonds[c].getAtomIndex1()==this.index&&96==this.bonds[c].order)return this.bonds[c].getOtherAtom(this).index}return-1},"~S,~N");p(c$,"getGroupBits",function(a){a.set(this.index)},"JU.BS");p(c$,"isCrossLinked",function(a){return this.getBondTo(a).isHydrogen()},"JU.BNode");p(c$,"getCrossLinkVector",
function(a){for(var b=!1,c=0;c<this.bonds.length;c++)if(112==this.bonds[c].order){if(null==a)return!0;a.addLast(Integer.$valueOf(this.index));a.addLast(Integer.$valueOf(this.bonds[c].getOtherAtom(this).index));a.addLast(Integer.$valueOf(this.bonds[c].getOtherAtom(this).index));b=!0}return b},"JU.Lst,~B,~B");p(c$,"getBioStructureTypeName",function(){return null});p(c$,"getResno",function(){return this.residueNumber});p(c$,"getChainID",function(){return 0});p(c$,"getChainIDStr",function(){return""});
c$.getAtomLabel=j(c$,"getAtomLabel",function(a,b,c,e,d,f,h){var g=JU.Elements.elementSymbolFromNumber(a);f&&(g=g.toLowerCase(),6!=a&&(c=2147483647));return(null==h||0<h.length||0!=b||0!=e?-1:JS.SmilesAtom.getDefaultCount(a,!1))==c?g:"["+(0>=b?"":""+b)+g+(0>e&&-2147483648!=e?""+e:0<e?"+"+e:"")+(null==h?"":h)+(1<d?"H"+d:1==d?"H":"")+"]"},"~N,~N,~N,~N,~N,~B,~S");p(c$,"getBioSmilesType",function(){return this.bioType});j(c$,"isNucleic",function(){return"n"==this.bioType||"r"==this.bioType||"d"==this.bioType});
p(c$,"isPurine",function(){return null!=this.residueChar&&this.isNucleic()&&0<="AG".indexOf(this.residueChar)});p(c$,"isPyrimidine",function(){return null!=this.residueChar&&this.isNucleic()&&0<="CTUI".indexOf(this.residueChar)});p(c$,"isDeleted",function(){return!1});j(c$,"setAtomType",function(a){this.atomType=a},"~S");p(c$,"getAtomType",function(){return null==this.atomType?this.atomName:this.atomType});p(c$,"findAtomsLike",function(){return null},"~S");p(c$,"toString",function(){var a=null!=this.residueChar||
null!=this.residueName?(null==this.residueChar?this.residueName:this.residueChar)+"."+this.atomName:null!=this.atomName&&-2147483648!=this.atomNumber?null:-1==this.elementNumber?"A":-2==this.elementNumber?"*":JU.Elements.elementSymbolFromNumber(this.elementNumber);if(null==a)return this.atomName+" #"+this.atomNumber;this.$isAromatic&&(a=a.toLowerCase());return"["+a+"."+this.index+(0<=this.matchingIndex?"("+this.matchingNode+")":"")+"]"});M(c$,"UNBRACKETED_SET","B, C, N, O, P, S, F, Cl, Br, I, *,")});
u("JS");E(["JU.Edge"],"JS.SmilesBond",["JS.InvalidSmilesException"],function(){c$=H(function(){this.atom2=this.atom1=null;this.isNot=!1;this.primitives=this.matchingBond=null;this.nPrimitives=0;this.bondsOr=null;this.nBondsOr=0;this.isRingBond=!1;G(this,arguments)},JS,"SmilesBond",JU.Edge);c$.getBondOrderString=j(c$,"getBondOrderString",function(a){switch(a){case 2:return"=";case 3:return"#";default:return""}},"~N");j(c$,"set",function(a){this.order=a.order;this.isNot=a.isNot;this.primitives=a.primitives;
this.nPrimitives=a.nPrimitives;this.bondsOr=a.bondsOr;this.nBondsOr=a.nBondsOr},"JS.SmilesBond");j(c$,"addBondOr",function(){null==this.bondsOr&&(this.bondsOr=Array(2));if(this.nBondsOr>=this.bondsOr.length){var a=Array(2*this.bondsOr.length);System.arraycopy(this.bondsOr,0,a,0,this.bondsOr.length);this.bondsOr=a}a=new JS.SmilesBond(null,null,-1,!1);this.bondsOr[this.nBondsOr]=a;this.nBondsOr++;return a});j(c$,"addPrimitive",function(){null==this.primitives&&(this.primitives=Array(2));if(this.nPrimitives>=
this.primitives.length){var a=Array(2*this.primitives.length);System.arraycopy(this.primitives,0,a,0,this.primitives.length);this.primitives=a}a=new JS.SmilesBond(null,null,-1,!1);this.primitives[this.nPrimitives]=a;this.nPrimitives++;return a});p(c$,"toString",function(){return this.atom1+" -"+(this.isNot?"!":"")+this.order+"- "+this.atom2});K(c$,function(a,b,c,e){P(this,JS.SmilesBond,[]);this.set2(c,e);this.set2a(a,b)},"JS.SmilesAtom,JS.SmilesAtom,~N,~B");j(c$,"set2",function(a,b){this.order=a;
this.isNot=b},"~N,~B");j(c$,"set2a",function(a,b){null!=a&&(this.atom1=a,a.addBond(this));null!=b&&(this.atom2=b,b.isFirst=!1,b.addBond(this))},"JS.SmilesAtom,JS.SmilesAtom");j(c$,"setAtom2",function(a){this.atom2=a;null!=this.atom2&&(a.addBond(this),this.isRingBond=!0)},"JS.SmilesAtom");c$.isBondType=j(c$,"isBondType",function(a,b,c){if(0>"-=#:/\\.+!,&;@~^'".indexOf(a))return!1;if(!b&&0>"-=#:/\\.~^'".indexOf(a))throw new JS.InvalidSmilesException("SMARTS bond type "+a+" not allowed in SMILES");return c&&
"~"==a?!1:!0},"~S,~B,~B");c$.getBondTypeFromCode=j(c$,"getBondTypeFromCode",function(a){switch(a){case ".":return 0;case "-":return 1;case "=":return 2;case "#":return 3;case ":":return 17;case "/":return 257;case "\\":return 513;case "^":return 769;case "'":return 1025;case "@":return 65;case "~":return 81;case "+":return 96}return-1},"~S");j(c$,"getBondType",function(){return this.order});j(c$,"getValence",function(){return this.order&7});j(c$,"getOtherAtom",function(a){return this.atom1===a?this.atom2:
this.atom1},"JS.SmilesAtom");p(c$,"getAtomIndex1",function(){return this.atom1.index});p(c$,"getAtomIndex2",function(){return this.atom2.index});p(c$,"getCovalentOrder",function(){return this.order});p(c$,"getOtherAtomNode",function(a){return a===this.atom1?this.atom2:a===this.atom2?this.atom1:null},"JU.Node");p(c$,"isCovalent",function(){return 112!=this.order});p(c$,"isHydrogen",function(){return 112==this.order});j(c$,"switchAtoms",function(){var a=this.atom1;this.atom1=this.atom2;this.atom2=a;
switch(this.order){case 769:this.order=1025;break;case 1025:this.order=769;break;case 257:this.order=513;break;case 513:this.order=257}});M(c$,"TYPE_UNKNOWN",-1,"TYPE_NONE",0,"TYPE_SINGLE",1,"TYPE_DOUBLE",2,"TYPE_TRIPLE",3,"TYPE_AROMATIC",17,"TYPE_DIRECTIONAL_1",257,"TYPE_DIRECTIONAL_2",513,"TYPE_ATROPISOMER_1",769,"TYPE_ATROPISOMER_2",1025,"TYPE_RING",65,"TYPE_ANY",81,"TYPE_BIO_SEQUENCE",96,"TYPE_BIO_CROSSLINK",112,"TYPE_MULTIPLE",999)});u("JS");E(null,"JS.SmilesMeasure",["JU.PT"],function(){c$=
H(function(){this.search=null;this.index=this.type=this.nPoints=0;this.isNot=!1;this.points=this.minmax=this.indices=null;G(this,arguments)},JS,"SmilesMeasure");N(c$,function(){this.indices=B(4,0);this.points=Array(4)});K(c$,function(a,b,c,e,d){this.search=a;this.type=Math.min(4,Math.max(c,2));this.index=b;this.isNot=e;this.minmax=d;for(a=d.length-2;0<=a;a-=2)d[a]>d[a+1]&&(b=d[a+1],d[a+1]=d[a],d[a]=b)},"JS.SmilesSearch,~N,~N,~B,~A");j(c$,"addPoint",function(a){if(this.nPoints==this.type)return!1;
if(0==this.nPoints)for(var b=1;b<this.type;b++)this.indices[b]=a+b;this.indices[this.nPoints++]=a;return!0},"~N");j(c$,"check",function(){for(var a=0;a<this.type;a++){var b=this.search.patternAtoms[this.indices[a]].getMatchingAtomIndex();this.points[a]=this.search.jmolAtoms[b]}b=0;switch(this.type){case 2:b=this.points[0].distance(this.points[1]);break;case 3:this.search.v.vA.sub2(this.points[0],this.points[1]);this.search.v.vB.sub2(this.points[2],this.points[1]);b=this.search.v.vA.angle(this.search.v.vB)/
0.017453292;break;case 4:JS.SmilesMeasure.setTorsionData(this.points[0],this.points[1],this.points[2],this.points[3],this.search.v,!0),b=this.search.v.vTemp1.angle(this.search.v.vTemp2)/0.017453292*(0>this.search.v.vNorm1.dot(this.search.v.vNorm2)?1:-1)}for(a=this.minmax.length-2;0<=a;a-=2)if(b>=this.minmax[a]&&b<=this.minmax[a+1])return!this.isNot;return this.isNot});c$.setTorsionData=j(c$,"setTorsionData",function(a,b,c,e,d,f){d.vTemp1.sub2(a,b);d.vTemp2.sub2(e,c);f&&(d.vNorm1.sub2(b,c),d.vNorm1.normalize(),
d.vTemp1.cross(d.vTemp1,d.vNorm1),d.vTemp1.normalize(),d.vTemp2.cross(d.vTemp2,d.vNorm1),d.vTemp2.normalize(),d.vNorm2.cross(d.vTemp1,d.vTemp2))},"JU.P3,JU.P3,JU.P3,JU.P3,JS.VTemp,~B");p(c$,"toString",function(){for(var a="(."+"__dat".charAt(this.type)+this.index+":"+JU.PT.toJSON(null,this.minmax)+") for",b=0;b<this.type;b++)a+=" "+(b>=this.nPoints?"?":""+this.indices[b]);return a});M(c$,"TYPES","__dat","radiansPerDegree",0.017453292519943295)});u("JS");E(["java.util.Hashtable"],"JS.SmilesParser",
"java.lang.Character $.Float JU.Lst $.PT $.SB JS.InvalidSmilesException $.SmilesAtom $.SmilesBond $.SmilesMeasure $.SmilesSearch $.SmilesStereo JU.Elements $.Logger".split(" "),function(){c$=H(function(){this.isBioSequence=this.isSmarts=!1;this.bioType="\x00";this.ringBonds=null;this.flags=this.branchLevel=this.braceCount=0;this.atomRefs=this.htMeasures=null;G(this,arguments)},JS,"SmilesParser");N(c$,function(){this.ringBonds=new java.util.Hashtable;this.htMeasures=new java.util.Hashtable});c$.getMolecule=
j(c$,"getMolecule",function(a,b){return(new JS.SmilesParser(b)).parse(a)},"~S,~B");K(c$,function(a){this.isSmarts=a},"~B");j(c$,"reset",function(){this.branchLevel=this.braceCount=0});j(c$,"parse",function(a){if(null==a)throw new JS.InvalidSmilesException("expression must not be null");var b=new JS.SmilesSearch;0<=a.indexOf("$(select")&&(a=this.parseNested(b,a,"select"));a=JS.SmilesParser.cleanPattern(a);for(this.flags=0;a.startsWith("/");){var c=JS.SmilesParser.getSubPattern(a,0,"/").toUpperCase();
a=a.substring(c.length+2);0<=c.indexOf("NONCANONICAL")&&(this.flags|=64);0<=c.indexOf("NOAROMATIC")&&(this.flags|=1);0<=c.indexOf("AROMATICSTRICT")&&(this.flags|=8);0<=c.indexOf("AROMATICDEFINED")&&(this.flags|=16);0<=c.indexOf("AROMATICDOUBLE")&&(this.flags|=32);0<=c.indexOf("NOSTEREO")?this.flags|=2:0<=c.indexOf("INVERTSTEREO")&&(this.flags|=4)}0<=a.indexOf("$")&&(a=this.parseVariables(a));this.isSmarts&&0<=a.indexOf("[$")&&(a=this.parseVariableLength(a));if(0<=a.indexOf("||")){a=JU.PT.split(a,
"||");c="";b.subSearches=Array(a.length);for(var e=0;e<a.length;e++){var d="|"+a[e]+"|";0>c.indexOf(d)&&(b.subSearches[e]=this.getSearch(b,a[e],this.flags),c+=d)}JU.Logger.info(c);return b}return this.getSearch(b,a,this.flags)},"~S");j(c$,"parseVariableLength",function(a){for(var b=new JU.SB,c=a.length-1,e=0,d=!1,f=0;f<c;f++)switch(a.charAt(f)){case "(":e++;break;case ")":e--;break;case "|":0<e&&(d=!0,"|"==a.charAt(f+1)&&(a=a.substring(0,f)+a.substring(f+1),c--))}if(0<=a.indexOf("||")){c=JU.PT.split(a,
"||");for(f=0;f<c.length;f++)b.append("||").append(this.parseVariableLength(c[f]))}else{c=-1;e=B(1,0);for(f=null;0<=(c=a.indexOf("[$",c+1));){var h=c,g=-2147483648,k=-2147483648,c=JS.SmilesParser.getDigits(a,c+2,e),g=e[0];-2147483648!=g&&"-"==JS.SmilesParser.getChar(a,c)&&(c=JS.SmilesParser.getDigits(a,c+1,e),k=e[0]);if("("==JS.SmilesParser.getChar(a,c)&&(f=JS.SmilesParser.getSubPattern(a,h,"["),f.endsWith(")"))){var j=h+f.length+2,n=JS.SmilesParser.getSubPattern(a,c,"("),l=c;JS.SmilesParser.getSubPattern(a,
c,"[");c+=1+n.length;if(0<=n.indexOf(":")&&0>n.indexOf("|")){for(var m=0,p=n.length,s=-1,f=0;f<p;f++)switch(n.charAt(f)){case "[":case "(":m++;break;case ")":case "]":m--;break;case ".":0<=s&&0==m&&(p=f);break;case ":":0>s&&0==m&&(s=f)}0<s&&(n=n.substring(0,s)+"("+n.substring(s,p)+")"+n.substring(p))}if(-2147483648==g){if(f=n.indexOf("|"),0<=f)return this.parseVariableLength(a.substring(0,h)+"[$1"+a.substring(l,l+f+1)+")]"+a.substring(j)+"||"+a.substring(0,h)+"[$1("+a.substring(l+f+2)+a.substring(j))}else{-2147483648==
k&&(k=g);0<=n.indexOf("|")&&(n="[$("+n+")]");for(f=g;f<=k;f++){g=new JU.SB;g.append("||").append(a.substring(0,h));for(l=0;l<f;l++)g.append(n);g.append(a.substring(j));b.appendSB(g)}}}}}return d?this.parseVariableLength(b.substring(2)):2>b.length()?a:b.substring(2)},"~S");j(c$,"getSearch",function(a,b,c){this.htMeasures=new java.util.Hashtable;var e=new JS.SmilesSearch;e.setTop(a);e.isSmarts=this.isSmarts;e.pattern=b;e.flags=c;0<=b.indexOf("$(")&&(b=this.parseNested(e,b,""));this.parseSmiles(e,b,
null,!1);if(0!=this.braceCount)throw new JS.InvalidSmilesException("unmatched '{'");if(!this.ringBonds.isEmpty())throw new JS.InvalidSmilesException("Open ring");e.setAtomArray();e.isTopology=!0;for(a=e.ac;0<=--a;)if(b=e.patternAtoms[a],e.isTopology&&b.isDefined()&&(e.isTopology=!1),b.setBondArray(),!this.isSmarts&&"\x00"==b.bioType&&!b.setHydrogenCount(e))throw new JS.InvalidSmilesException("unbracketed atoms must be one of: B, C, N, O, P, S, F, Cl, Br, I, *,");if(this.isSmarts)for(a=e.ac;0<=--a;){b=
e.patternAtoms[a];this.checkNested(e,b,c);for(var d=0;d<b.nAtomsOr;d++)this.checkNested(e,b.atomsOr[d],c);for(d=0;d<b.nPrimitives;d++)this.checkNested(e,b.primitives[d],c)}!this.isSmarts&&!this.isBioSequence&&(e.elementCounts[1]=e.getMissingHydrogenCount());this.fixChirality(e);return e},"JS.SmilesSearch,~S,~N");j(c$,"checkNested",function(a,b,c){if(0<b.iNested){var e=a.getNested(b.iNested);F(e,String)&&!e.startsWith("select")&&("~"!=e.charAt(0)&&"\x00"!=b.bioType&&(e="~"+b.bioType+"~"+e),c=this.getSearch(a,
e,c),0<c.ac&&c.patternAtoms[0].selected&&(b.selected=!0),a.setNested(b.iNested,c))}},"JS.SmilesSearch,JS.SmilesAtom,~N");j(c$,"fixChirality",function(a){for(var b=a.ac;0<=--b;){var c=a.patternAtoms[b];null!=c.stereo&&c.stereo.fixStereo(c)}},"JS.SmilesSearch");j(c$,"parseSmiles",function(a,b,c,e){for(var d=B(1,0),f=0,h,g=null;null!=b&&0!=b.length;){var k=0;if(null==c||null!=g&&0==g.order)k=this.checkBioType(b,0),k==b.length&&(b+="*"),this.isBioSequence&&(a.needAromatic=a.top.needAromatic=!1);h=JS.SmilesParser.getChar(b,
k);var j=this.checkBrace(a,h,"{");j&&(h=JS.SmilesParser.getChar(b,++k));if("("==h){e=JS.SmilesParser.getSubPattern(b,k,"(");if(0<e.length&&JU.PT.isDigit(e.charAt(0))){if(JS.SmilesParser.getDigits(e,0,d)==e.length&&0<d[0]){var n,k=d[0]-1;if(0>k||k>=a.patternAtoms.length||null==(n=a.patternAtoms[k])||n===c||null!=n.getBondTo(c))throw new JS.InvalidSmilesException("Improper direct atom reference ("+e+").");null!=g&&-1!=g.order&&0!=g.order?g.set2a(null,n):new JS.SmilesBond(n,c,-1,!1)}}else{k="."==JS.SmilesParser.getChar(b,
k+1);if(null==c)throw new JS.InvalidSmilesException("No previous atom for "+(k?"measure":"branch"));e.startsWith(".")?this.parseMeasure(a,e.substring(1),c):0==e.length&&this.isBioSequence?c.notCrossLinked=!0:(this.branchLevel++,this.parseSmiles(a,e,c,!0),this.branchLevel--)}k=e.length+2}else{for(f=k;JS.SmilesBond.isBondType(h,this.isSmarts,this.isBioSequence);)h=JS.SmilesParser.getChar(b,++k);g=this.parseBond(a,null,b.substring(f,k),null,c,!1,e);j&&-1!=g.order&&(k=f);h=JS.SmilesParser.getChar(b,k);
this.checkBrace(a,h,"{")&&(h=JS.SmilesParser.getChar(b,++k));"~"==h&&0==g.order&&(k=this.checkBioType(b,k),k==b.length&&(b+="*"));if("\x00"==h&&0==g.order)break;f=JU.PT.isDigit(h)||"%"==h;j=!f&&("_"==h||"["==h||"*"==h||JU.PT.isLetter(h));if(f)k=JS.SmilesParser.getRingNumber(b,k,h,d),this.parseRing(a,d[0],c,g),g=null;else if(j)switch(h){case "[":case "_":f=JS.SmilesParser.getSubPattern(b,k,h);k+=f.length+("["==h?2:0);this.isBioSequence&&("["==h&&0>f.indexOf(".")&&0>f.indexOf("_"))&&(f+=".0");c=this.parseAtom(a,
null,f,c,g,"["==h,!1,e);c.hasSubpattern=!0;-1!=g.order&&0!=g.order&&g.set2a(null,c);g=null;break;default:f=!this.isBioSequence&&JU.PT.isUpperCase(h)?JS.SmilesParser.getChar(b,k+1):"\x00";if("X"!=h||"x"!=f)if(!JU.PT.isLowerCase(f)||0==JU.Elements.elementNumberFromSymbol(b.substring(k,k+2),!0))f="\x00";"\x00"!=f&&0<="NA CA BA PA SC AC".indexOf(b.substring(k,k+2))&&(f="\x00");h=JU.PT.isUpperCase(h)&&JU.PT.isLowerCase(f)?2:1;c=this.parseAtom(a,null,b.substring(k,k+h),c,g,!1,!1,e);g=null;k+=h}else if("("!=
h)throw new JS.InvalidSmilesException("Unexpected character: "+JS.SmilesParser.getChar(b,k));}h=JS.SmilesParser.getChar(b,k);"}"==h&&this.checkBrace(a,h,"}")&&k++;b=b.substring(k);e=!1}},"JS.SmilesSearch,~S,JS.SmilesAtom,~B");c$.getRingNumber=j(c$,"getRingNumber",function(a,b,c,e){switch(c){case "%":if("("==JS.SmilesParser.getChar(a,b+1)){if(a=JS.SmilesParser.getSubPattern(a,b+1,"("),JS.SmilesParser.getDigits(a,0,e),b+=a.length+3,0>e[0])throw new JS.InvalidSmilesException("Invalid number designation: "+
a);}else if(b+3<=a.length&&(b=JS.SmilesParser.getDigits(a.substring(0,b+3),b+1,e)),10>e[0])throw new JS.InvalidSmilesException("Two digits must follow the % sign");a=e[0];break;default:a=c.charCodeAt(0)-48,b++}e[0]=a;return b},"~S,~N,~S,~A");j(c$,"checkBioType",function(a,b){if(this.isBioSequence="~"==a.charAt(b)){b++;this.bioType="*";var c=JS.SmilesParser.getChar(a,2);if("~"==c&&("*"==(c=a.charAt(1))||JU.PT.isLowerCase(c)))this.bioType=c,b=3}return b},"~S,~N");j(c$,"parseMeasure",function(a,b,c){for(var e=
b.indexOf(":"),d=0>e?b:b.substring(0,e);0!=e;){var f=d.length;1==f&&(d+="0");var h=this.htMeasures.get(d);if(null==h==0>e||0==f)break;try{if(0<e){var g="__dat".indexOf(d.charAt(0));if(2>g)break;var k=B(1,0);JS.SmilesParser.getDigits(d,1,k);var j=k[0];b=b.substring(e+1);var n=b.startsWith("!");n&&(b=b.substring(1));var l=b.startsWith("-");l&&(b=b.substring(1));b=JU.PT.rep(b,"-",",");b=JU.PT.rep(b,",,",",-");l&&(b="-"+b);var m=JU.PT.split(b,",");if(1==m.length%2)break;for(var p=Q(m.length,0),s=m.length;0<=
--s&&!Float.isNaN(p[s]=JU.PT.fVal(m[s])););if(0<=s)break;h=new JS.SmilesMeasure(a,j,g,n,p);a.measures.addLast(h);0<j?this.htMeasures.put(d,h):0==j&&JU.Logger.debugging&&JU.Logger.debug("measure created: "+h)}else{if(!h.addPoint(c.index))break;h.nPoints==h.type&&(this.htMeasures.remove(d),JU.Logger.debugging&&JU.Logger.debug("measure created: "+h));return}if(!h.addPoint(c.index))break}catch(q){if(I(q,NumberFormatException))break;else throw q;}return}throw new JS.InvalidSmilesException("invalid measure: "+
b);},"JS.SmilesSearch,~S,JS.SmilesAtom");j(c$,"checkBrace",function(a,b,c){switch(b){case "{":if(b!=c)break;this.braceCount++;return a.top.haveSelected=!0;case "}":if(b!=c)break;if(0<this.braceCount)return this.braceCount--,!0;break;default:return!1}throw new JS.InvalidSmilesException("Unmatched '}'");},"JS.SmilesSearch,~S,~S");j(c$,"parseNested",function(a,b,c){var e;for(c="$("+c;0<=(e=b.lastIndexOf(c));){var d=JS.SmilesParser.getSubPattern(b,e+1,"("),f=e+d.length+3;b=b.substring(0,e)+"_"+a.addNested(d)+
"_"+b.substring(f)}return b},"JS.SmilesSearch,~S,~S");j(c$,"parseVariables",function(a){var b=new JU.Lst,c=new JU.Lst,e,d=0,f=-1;for(JU.Logger.debugging&&JU.Logger.info(a);0<=(e=a.indexOf("$",d))&&"("!=JS.SmilesParser.getChar(a,d+1);){d=JS.SmilesParser.skipTo(a,e,"=");if(d<=e+1||'"'!=JS.SmilesParser.getChar(a,d+1))break;e=a.substring(e,d);if(0<e.lastIndexOf("$")||0<e.indexOf("]"))throw new JS.InvalidSmilesException("Invalid variable name: "+e);f=JS.SmilesParser.getSubPattern(a,d+1,'"');b.addLast("["+
e+"]");c.addLast(f);d+=f.length+2;d=JS.SmilesParser.skipTo(a,d,";");f=++d}if(0>f)return a;a=a.substring(f);for(d=b.size();0<=--d;)e=b.get(d),f=c.get(d),f.equals(e)||(a=JU.PT.rep(a,e,f));JU.Logger.debugging&&JU.Logger.info(a);return a},"~S");j(c$,"parseAtom",function(a,b,c,e,d,f,h,g){if(null==c||0==c.length)throw new JS.InvalidSmilesException("Empty atom definition");var k=new JS.SmilesAtom;null==b&&a.appendAtom(k);var j=!0;if(!this.checkLogic(a,c,k,null,e,h,g)){var n=B(1,0);this.isBioSequence&&1==
c.length&&(c+=".0");var l=c.charAt(0),m=0,p=!1;if(this.isSmarts&&"!"==l){l=JS.SmilesParser.getChar(c,++m);if("\x00"==l)throw new JS.InvalidSmilesException("invalid '!'");k.not=p=!0}var s=c.indexOf("."),q=c.indexOf("@");if(0<=s&&(0>q||s<q)){k.isBioResidue=!0;l=c.substring(m,s);c=c.substring(s+1).toUpperCase();if(0<=(s=l.indexOf("#")))JS.SmilesParser.getDigits(l,s+1,n),l=l.substring(0,s),k.residueNumber=n[0];0==l.length&&(l="*");1<l.length?k.residueName=l.toUpperCase():l.equals("*")||(k.residueChar=
l);l=c;if(0<=(s=l.indexOf("#")))JS.SmilesParser.getDigits(l,s+1,n),k.elementNumber=n[0],l=l.substring(0,s);0==l.length?l="*":l.equals("0")&&(l="\x00");l.equals("*")||k.setAtomName(l);l="\x00"}k.setBioAtom(this.bioType);for(s=-2147483648;"\x00"!=l&&j;){k.setAtomName(this.isBioSequence?"\x00":"");if(JU.PT.isDigit(l)){m=JS.SmilesParser.getDigits(c,m,n);l=n[0];if(-2147483648==l)throw new JS.InvalidSmilesException("Non numeric atomic mass");"?"==JS.SmilesParser.getChar(c,m)&&(m++,l=-l);k.setAtomicMass(l)}else switch(l){case '"':l=
JU.PT.getQuotedStringAt(c,m);m+=l.length+2;k.setAtomType(l);break;case "_":m=JS.SmilesParser.getDigits(c,m+1,n)+1;if(-2147483648==n[0])throw new JS.InvalidSmilesException("Invalid SEARCH primitive: "+c.substring(m));k.iNested=n[0];if(this.isBioSequence&&f&&m!=c.length)throw new JS.InvalidSmilesException("invalid characters: "+c.substring(m));break;case "=":m=JS.SmilesParser.getDigits(c,m+1,n);k.jmolIndex=n[0];break;case "#":l="-"==c.charAt(m+1);m=JS.SmilesParser.getDigits(c,m+(l?2:1),n);l?k.atomNumber=
n[0]:k.elementNumber=n[0];break;case "(":l=JS.SmilesParser.getSubPattern(c,m,"(");m+=2+l.length;k=this.checkReference(k,l,n);j=1==n[0];j||(p&&(m=0),p=!0);break;case "-":case "+":m=this.checkCharge(c,m,k);break;case "@":null==a.stereo&&(a.stereo=JS.SmilesStereo.newStereo(null));m=JS.SmilesStereo.checkChirality(c,m,a.patternAtoms[k.index]);break;default:var q=JS.SmilesParser.getChar(c,m+1),z=c.substring(m+1,m+(JU.PT.isLowerCase(q)&&(!f||!JU.PT.isDigit(JS.SmilesParser.getChar(c,m+2)))?2:1)),r=Character.toUpperCase(l)+
z,w=!0;f&&JU.PT.isLetter(l)&&(!p&&(h?b:k).hasSymbol?w=!1:"H"==l?w=!JU.PT.isDigit(q)||"?"==JS.SmilesParser.getChar(c,m+2):0<="DdhRrvXx".indexOf(l)&&JU.PT.isDigit(q)?w=!1:!r.equals("A")&&!r.equals("Xx")&&(w=0<JU.Elements.elementNumberFromSymbol(r,!0),!w&&""!==z&&(z="",r=r.substring(0,1),w=0<JU.Elements.elementNumberFromSymbol(r,!0))));if(w){if(!f&&!this.isSmarts&&!this.isBioSequence&&!JS.SmilesAtom.allowSmilesUnbracketed(r)||!k.setSymbol(r=l+z))throw new JS.InvalidSmilesException("Invalid atom symbol: "+
r);h&&(b.hasSymbol=!0);m+=r.length}else switch(m=JS.SmilesParser.getDigits(c,m+1,n),q=n[0],l){default:throw new JS.InvalidSmilesException("Invalid SEARCH primitive: "+c.substring(m));case "D":k.setDegree(-2147483648==q?1:q);break;case "d":k.setNonhydrogenDegree(-2147483648==q?1:q);break;case "H":s=-2147483648==q?1:q;break;case "h":k.setImplicitHydrogenCount(-2147483648==q?-1:q);break;case "R":-2147483648==q&&(q=-1);k.setRingMembership(q);a.top.needRingData=!0;break;case "r":if(-2147483648==q)q=-1,
k.setRingMembership(q);else{k.setRingSize(q);switch(q){case 500:q=5;break;case 600:q=6}q>a.ringDataMax&&(a.ringDataMax=q)}a.top.needRingData=!0;break;case "v":k.setValence(-2147483648==q?1:q);break;case "X":k.setConnectivity(-2147483648==q?1:q);break;case "x":k.setRingConnectivity(-2147483648==q?-1:q),a.top.needRingData=!0}}l=JS.SmilesParser.getChar(c,m);if(p&&"\x00"!=l)throw new JS.InvalidSmilesException("'!' may only involve one primitive.");}-2147483648==s&&f&&(s=-2147483647);k.setExplicitHydrogenCount(s);
a.patternAtoms[k.index].setExplicitHydrogenCount(s)}0<this.braceCount&&(k.selected=!0);j&&null!=b&&(h?b.appendPrimitive(k):b.appendAtomOr(k));null!=e&&0==d.order&&(k.notBondedIndex=e.index);null!=e&&0!=d.order&&(-1==d.order&&(d.order=this.isBioSequence&&g?112:this.isSmarts||e.isAromatic()&&k.isAromatic()?81:1),f||d.set2a(null,k),0==this.branchLevel&&(17==d.order||112==d.order)&&this.branchLevel++);0==this.branchLevel&&(a.lastChainAtom=k);return k},"JS.SmilesSearch,JS.SmilesAtom,~S,JS.SmilesAtom,JS.SmilesBond,~B,~B,~B");
j(c$,"checkReference",function(a,b,c){null==this.atomRefs&&(this.atomRefs=new java.util.Hashtable);var e=this.atomRefs.get(b);if(null==e){this.atomRefs.put(a.referance=b,e=a);if(!a.hasSymbol&&0<b.length){var d=null;2<=b.length&&(0<JU.Elements.elementNumberFromSymbol(d=b.substring(0,2),!0)||0<JU.Elements.elementNumberFromSymbol(d=b.substring(0,1),!0))&&a.setSymbol(d)}c[0]=1}else c[0]=0;return e},"JS.SmilesAtom,~S,~A");j(c$,"parseRing",function(a,b,c,e){a=Integer.$valueOf(b);b=this.ringBonds.get(a);
if(null==b)this.ringBonds.put(a,e);else{this.ringBonds.remove(a);switch(e.order){case -1:e.order=-1!=b.order?b.order:this.isSmarts||c.isAromatic()&&b.atom1.isAromatic()?81:1;break;case 257:e.order=513;break;case 513:e.order=257}if(-1!=b.order&&b.order!=e.order||c===b.atom1||null!=b.atom1.getBondTo(c))throw new JS.InvalidSmilesException("Bad connection type or atom");b.set(e);c.bondCount--;b.setAtom2(c)}},"JS.SmilesSearch,~N,JS.SmilesAtom,JS.SmilesBond");j(c$,"checkCharge",function(a,b,c){var e=a.length,
d=a.charAt(b),f=1;++b;if(b<e){var h=a.charAt(b);if(JU.PT.isDigit(h)){if(e=B(1,0),b=JS.SmilesParser.getDigits(a,b,e),f=e[0],-2147483648==f)throw new JS.InvalidSmilesException("Non numeric charge");}else for(;b<e&&a.charAt(b)==d;)b++,f++}c.setCharge("+"==d?f:-f);return b},"~S,~N,JS.SmilesAtom");j(c$,"parseBond",function(a,b,c,e,d,f,h){var g=JS.SmilesParser.getChar(c,0);if("."==g){if(null!=e||null!=b)throw new JS.InvalidSmilesException("invalid '.'");this.isBioSequence="~"==JS.SmilesParser.getChar(c,
1);return new JS.SmilesBond(null,null,0,!1)}if("+"==g&&null!=b)throw new JS.InvalidSmilesException("invalid '+'");e=null==b?null==e?new JS.SmilesBond(d,null,this.isBioSequence&&null!=d?h?112:96:-1,!1):e:f?b.addPrimitive():b.addBondOr();if("\x00"!=g&&!this.checkLogic(a,c,null,e,d,f,!1)){if(f="!"==g)if(g=JS.SmilesParser.getChar(c,1),"\x00"==g||"!"==g)throw new JS.InvalidSmilesException("invalid '!'");c=JS.SmilesBond.getBondTypeFromCode(g);65==c&&(a.top.needRingMemberships=!0);if(null==d&&0!=c)throw new JS.InvalidSmilesException("Bond without a previous atom");
switch(c){case 769:case 1025:f&&(f=!1,c=769==c?1025:769);a.haveBondStereochemistry=!0;break;case 257:case 513:a.haveBondStereochemistry=!0;break;case 2:case 1:d.isAromatic()&&(a.top.needRingData=!0)}e.set2(c,f);this.isBioSequence&&null!=b&&b.set2(c,f)}return e},"JS.SmilesSearch,JS.SmilesBond,~S,JS.SmilesBond,JS.SmilesAtom,~B,~B");j(c$,"checkLogic",function(a,b,c,e,d,f,h){for(var g=b.indexOf(","),k=b.length;;){var j=0<g;if(j&&!this.isSmarts||0==g)break;var n="",g=b.indexOf(";");if(0<=g){if(!this.isSmarts||
0==g)break;n="&"+b.substring(g+1);b=b.substring(0,g);j||(b+=n,n="")}var l=0;if(j)for(b+=",";0<(g=b.indexOf(",",l))&&g<=k;){l=b.substring(l,g)+n;if(0==l.length)throw new JS.InvalidSmilesException("missing "+(null==e?"atom":"bond")+" token");null==e?this.parseAtom(a,c,l,null,null,!0,!1,h):this.parseBond(a,e,l,null,d,!1,!1);l=g+1}else if(0<=(g=b.indexOf("&"))||null!=e&&1<k&&!f){if(!this.isSmarts||0==g)break;if(null!=e&&0>g&&1<k){f=new JU.SB;for(j=0;j<k;){var m=b.charAt(j++);f.appendC(m);"!"!=m&&j<k&&
f.appendC("&")}b=f.toString();k=b.length}for(b+="&";0<(g=b.indexOf("&",l))&&g<=k;)l=b.substring(l,g)+n,null==e?this.parseAtom(a,c,l,null,null,!0,!0,h):this.parseBond(a,e,l,null,d,!0,!1),l=g+1}else return!1;return!0}m=b.charAt(g);throw new JS.InvalidSmilesException((this.isSmarts?"invalid placement for '"+m+"'":"["+m+"] notation only valid with SMARTS, not SMILES,")+" in "+b);},"JS.SmilesSearch,~S,JS.SmilesAtom,JS.SmilesBond,JS.SmilesAtom,~B,~B");c$.getSubPattern=j(c$,"getSubPattern",function(a,b,
c){var e,d=1;switch(c){case "[":e="]";break;case '"':case "%":case "/":e=c;break;case "(":e=")";break;default:e=c,d=0}for(var f=a.length,h=1,g=b+1;g<f;g++){var k=a.charAt(g);if(k==e){if(h--,0==h)return a.substring(b+d,g+1-d)}else k==c&&h++}throw new JS.InvalidSmilesException("Unmatched "+c);},"~S,~N,~S");c$.getChar=j(c$,"getChar",function(a,b){return b<a.length?a.charAt(b):"\x00"},"~S,~N");c$.getDigits=j(c$,"getDigits",function(a,b,c){for(var e=b,d=a.length;e<d&&JU.PT.isDigit(a.charAt(e));)e++;try{c[0]=
Integer.parseInt(a.substring(b,e))}catch(f){if(I(f,NumberFormatException))c[0]=-2147483648;else throw f;}return e},"~S,~N,~A");c$.skipTo=j(c$,"skipTo",function(a,b,c){for(var e;(e=JS.SmilesParser.getChar(a,++b))!=c&&"\x00"!=e;);return"\x00"==e?-1:b},"~S,~N,~S");c$.cleanPattern=j(c$,"cleanPattern",function(a){a=JU.PT.replaceAllCharacters(a," \t\n\r","");a=JU.PT.rep(a,"^^","'");for(var b=0,c=0;0<=(b=a.indexOf("//*"))&&(c=a.indexOf("*//"))>=b;)a=a.substring(0,b)+a.substring(c+3);return a=JU.PT.rep(a,
"//","")},"~S")});u("JS");E(null,"JS.SmilesExt","java.lang.Float JU.AU $.BS $.Lst $.M4 $.Measure $.P3 J.api.Interface JU.Logger".split(" "),function(){c$=H(function(){this.sm=this.e=null;G(this,arguments)},JS,"SmilesExt");K(c$,function(){});j(c$,"init",function(a){this.e=a;this.sm=this.e.vwr.getSmilesMatcher();return this},"~O");j(c$,"getSmilesCorrelation",function(a,b,c,e,d,f,h,g,k,j,n,l){var m=null==k?0.1:3.4028235E38;try{null==e&&(e=new JU.Lst,d=new JU.Lst);var p=new JU.M4,s=new JU.P3,q=this.e.vwr.ms.at,
z=this.e.vwr.ms.ac,r=this.sm.getCorrelationMaps(c,q,z,a,l|64);null==r&&this.e.evalError(this.sm.getLastException(),null);if(0==r.length)return NaN;var w=r[0];for(a=0;a<w.length;a++)e.addLast(q[w[a]]);r=this.sm.getCorrelationMaps(c,q,z,b,l);null==r&&this.e.evalError(this.sm.getLastException(),null);if(0==r.length)return NaN;JU.Logger.info(r.length+" mappings found");if(n||!g){b=3.4028235E38;c=null;for(a=0;a<r.length;a++){d.clear();for(var u=0;u<r[a].length;u++)d.addLast(q[r[a][u]]);J.api.Interface.getInterface("JU.Eigen",
this.e.vwr,"script");var y=1==d.size()?0:JU.Measure.getTransformMatrix4(e,d,p,null);JU.Logger.info("getSmilesCorrelation stddev="+y);if(null!=h&&y<m){for(var A=new JU.BS,u=0;u<r[a].length;u++)A.set(r[a][u]);h.addLast(A)}y<b&&(c=r[a],null!=f&&f.setM4(p),null!=j&&j.setT(s),b=y)}null!=k&&(k[0]=w,k[1]=c);d.clear();for(a=0;a<c.length;a++)d.addLast(q[c[a]]);return b}for(a=0;a<r.length;a++)for(u=0;u<r[a].length;u++)d.addLast(q[r[a][u]])}catch(v){if(I(v,Exception))this.e.evalError(v.getMessage(),null);else throw v;
}return 0},"JU.BS,JU.BS,~S,JU.Lst,JU.Lst,JU.M4,JU.Lst,~B,~A,JU.P3,~B,~N");j(c$,"getSmilesMatches",function(a,b,c,e,d,f,h){if(0==a.length||a.equals("H")||a.equals("*")||(h=a.equalsIgnoreCase("NOAROMATIC")))try{return this.e.vwr.getSmilesOpt(c,0,0,d|(a.equals("H")?256:0)|(a.equals("*")?512:0)|(h?1024:0))}catch(g){if(I(g,Exception))this.e.evalError(g.getMessage(),null);else throw g;}var k;if(null==e){e=2==(d&2);try{if(null==b)k=this.sm.getSubstructureSetArray(a,this.e.vwr.ms.at,this.e.vwr.ms.ac,c,null,
d);else{var j=this.sm.find(a,b,e,h);if(!f)return!h?j:0==j.length?B(0,0):j[0];var n=new JU.BS;for(f=0;f<j.length;f++)for(var l=j[f],m=l.length;0<=--m;)n.set(l[m]);if(!e)return B(n.cardinality(),0);var p=B(n.cardinality(),0);f=0;for(var s=n.nextSetBit(0);0<=s;s=n.nextSetBit(s+1))p[f++]=s;return p}}catch(q){if(I(q,Exception))return this.e.evalError(q.getMessage(),null),null;throw q;}}else{k=new JU.Lst;n=this.getSmilesCorrelation(e,c,a,null,null,null,k,!1,null,null,!1,d);if(Float.isNaN(n))return f?new JU.BS:
O(-1,[]);this.e.showString("RMSD "+n+" Angstroms");k=k.toArray(Array(k.size()))}if(f){n=new JU.BS;for(f=0;f<k.length;f++)n.or(k[f]);return n}n=new JU.Lst;for(f=0;f<k.length;f++)n.addLast(k[f]);return n},"~S,~S,JU.BS,JU.BS,~N,~B,~B");j(c$,"getFlexFitList",function(a,b,c,e){var d=JU.AU.newInt2(2);this.getSmilesCorrelation(a,b,c,null,null,null,null,!1,d,null,!1,e?2:1);if(null==d[0])return null;a=this.e.vwr.ms.getDihedralMap(d[0]);b=null==a?null:this.e.vwr.ms.getDihedralMap(d[1]);if(null==b||b.length!=
a.length)return null;d=Q(a.length,3,0);c=this.e.vwr.ms.at;JS.SmilesExt.getTorsions(c,b,d,0);JS.SmilesExt.getTorsions(c,a,d,1);b=Q(6*a.length,0);for(e=c=0;c<a.length;c++){var f=a[c];b[e++]=f[0];b[e++]=f[1];b[e++]=f[2];b[e++]=f[3];b[e++]=d[c][0];b[e++]=d[c][1]}return b},"JU.BS,JU.BS,~S,~B");c$.getTorsions=j(c$,"getTorsions",function(a,b,c,e){for(var d=b.length;0<=--d;){var f=b[d],f=JU.Measure.computeTorsion(a[f[0]],a[f[1]],a[f[2]],a[f[3]],!0);1==e&&(180<f-c[d][0]?f-=360:-180>=f-c[d][0]&&(f+=360));c[d][e]=
f}},"~A,~A,~A,~N")})})(Clazz,Clazz.newLongArray,Clazz.doubleToByte,Clazz.doubleToInt,Clazz.doubleToLong,Clazz.declarePackage,Clazz.instanceOf,Clazz.load,Clazz.instantialize,Clazz.decorateAsClass,Clazz.floatToInt,Clazz.floatToLong,Clazz.makeConstructor,Clazz.defineEnumConstant,Clazz.exceptionOf,Clazz.newIntArray,Clazz.defineStatics,Clazz.newFloatArray,Clazz.declareType,Clazz.prepareFields,Clazz.superConstructor,Clazz.newByteArray,Clazz.declareInterface,Clazz.p0p,Clazz.pu$h,Clazz.newShortArray,Clazz.innerTypeInstance,
Clazz.isClassDefined,Clazz.prepareCallback,Clazz.newArray,Clazz.castNullAs,Clazz.floatToShort,Clazz.superCall,Clazz.decorateAsType,Clazz.newBooleanArray,Clazz.newCharArray,Clazz.implementOf,Clazz.newDoubleArray,Clazz.overrideConstructor,Clazz.clone,Clazz.doubleToShort,Clazz.getInheritedLevel,Clazz.getParamsType,Clazz.isAF,Clazz.isAB,Clazz.isAI,Clazz.isAS,Clazz.isASS,Clazz.isAP,Clazz.isAFloat,Clazz.isAII,Clazz.isAFF,Clazz.isAFFF,Clazz.tryToSearchAndExecute,Clazz.getStackTrace,Clazz.inheritArgs,Clazz.alert,
Clazz.defineMethod,Clazz.overrideMethod,Clazz.declareAnonymous,Clazz.cloneFinals);
