(function(T,U,V,O,W,B,L,E,F,G,X,Y,M,Z,H,v,I,P,N,K,Q,$,R,aa,ba,ca,da,ea,fa,S,ga,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,h,n){B("JS");E(["JU.BS","$.V3"],"JS.VTemp",null,function(){c$=G(function(){this.bsTemp=this.vNorm3=this.vNorm2=this.vNorm1=this.vTemp2=this.vTemp1=this.vB=this.vA=this.vTemp=null;F(this,arguments)},JS,"VTemp");K(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})});B("J.api");R(J.api,"SmilesMatcherInterface");B("JS");E(["J.api.SmilesMatcherInterface"],"JS.SmilesMatcher","JU.AU $.BS $.PT JS.InvalidSmilesException $.SmilesGenerator $.SmilesParser JU.BSUtil".split(" "),function(){c$=N(JS,"SmilesMatcher",null,J.api.SmilesMatcherInterface);n(c$,"getLastException",function(){return JS.InvalidSmilesException.getLastError()});n(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");n(c$,"getSmiles",function(a,b,c,d,e,f,k,j){JS.InvalidSmilesException.clear();return d?(new JS.SmilesGenerator).getBioSmiles(a,b,c,e,f,k):(new JS.SmilesGenerator).getSmiles(a,b,c,j)},"~A,~N,JU.BS,~B,~B,~B,~S,~B");h(c$,"areEqual",function(a,b){var c=this.find(a,b,!1,!1);return null==c?-1:c.length},"~S,~S");h(c$,"areEqual",function(a,b){var c=this.find(a,b,!1,!0,!0);return null!=
c&&1==c.length},"~S,JS.SmilesSearch");h(c$,"find",function(a,b,c,d){JS.InvalidSmilesException.clear();b=JS.SmilesParser.getMolecule(b,!1);return this.find(a,b,c,!c,d)},"~S,~S,~B,~B");n(c$,"getRelationship",function(a,b){if(null==a||null==b||0==a.length||0==b.length)return"";var c=this.getMolecularFormula(a,!1),d=this.getMolecularFormula(b,!1);if(!c.equals(d))return"none";var e,c=JS.SmilesMatcher.countStereo(a),d=JS.SmilesMatcher.countStereo(b);e=c==d&&0<this.areEqual(b,a);if(!e){e=a+b;if(0<=e.indexOf("/")||
0<=e.indexOf("\\")||0<=e.indexOf("@")){if(c==d&&0<c&&(a=this.reverseChirality(a),e=0<this.areEqual(a,b)))return"enantiomers";if(e=0<this.areEqual("/nostereo/"+b,a))return c==d?"diastereomers":"ambiguous stereochemistry!"}return"constitutional isomers"}return"identical"},"~S,~S");n(c$,"reverseChirality",function(a){a=JU.PT.rep(a,"@@","!@");a=JU.PT.rep(a,"@","@@");a=JU.PT.rep(a,"!@@","@");a=JU.PT.rep(a,"@@SP","@SP");a=JU.PT.rep(a,"@@OH","@OH");return a=JU.PT.rep(a,"@@TB","@TB")},"~S");n(c$,"getSubstructureSet",
function(a,b,c,d,e,f){return this.match(a,b,c,d,null,e,!1,f,1)},"~S,~A,~N,JU.BS,~B,~B");n(c$,"getSubstructureSets",function(a,b,c,d,e,f,k){JS.InvalidSmilesException.clear();var j=new JS.SmilesParser(!0),g=null,g=j.parse("");g.firstMatchOnly=!1;g.matchAllAtoms=!1;g.jmolAtoms=b;g.jmolAtomCount=Math.abs(c);g.setSelected(e);g.getRingData(!0,d,k);g.asVector=!1;g.subSearches=Array(1);g.getSelections();b=new JU.BS;for(e=0;e<a.length;e++)if(null==a[e]||0==a[e].length||a[e].startsWith("#"))f.addLast(null);
else if(g.clear(),k=j.getSearch(g,JS.SmilesParser.cleanPattern(a[e]),d),g.subSearches[0]=k,k=JU.BSUtil.copy(g.search(!1)),f.addLast(k),b.or(k),b.cardinality()==c)break},"~A,~A,~N,~N,JU.BS,JU.Lst,~A");n(c$,"getSubstructureSetArray",function(a,b,c,d,e,f,k){return this.match(a,b,c,d,e,f,!1,k,2)},"~S,~A,~N,JU.BS,JU.BS,~B,~B");n(c$,"getCorrelationMaps",function(a,b,c,d,e,f){return this.match(a,b,c,d,null,e,!1,f,3)},"~S,~A,~N,JU.BS,~B,~B");h(c$,"find",function(a,b,c,d,e){var f=new JU.BS;b.createTopoMap(f);
return this.match(a,b.jmolAtoms,-b.jmolAtoms.length,null,f,c,d,e,2)},"~S,JS.SmilesSearch,~B,~B,~B");h(c$,"match",function(a,b,c,d,e,f,k,j,g){JS.InvalidSmilesException.clear();try{var h=JS.SmilesParser.getMolecule(a,f);h.jmolAtoms=b;h.jmolAtomCount=Math.abs(c);0>c&&(h.isSmilesFind=!0);h.setSelected(d);h.getSelections();h.bsRequired=null;h.setRingData(e);h.firstMatchOnly=j;h.matchAllAtoms=k;switch(g){case 1:return h.asVector=!1,h.search(!1);case 2:h.asVector=!0;var l=h.search(!1);return l.toArray(Array(l.size()));
case 3:h.getMaps=!0;var m=h.search(!1);return m.toArray(JU.AU.newInt2(m.size()))}}catch(s){if(H(s,Exception))throw null==JS.InvalidSmilesException.getLastError()&&JS.InvalidSmilesException.clear(),new JS.InvalidSmilesException(JS.InvalidSmilesException.getLastError());throw s;}return null},"~S,~A,~N,JU.BS,JU.BS,~B,~B,~B,~N");c$.countStereo=h(c$,"countStereo",function(a){a=JU.PT.rep(a,"@@","@");for(var b=a.lastIndexOf("@")+1,c=0;0<=--b;)"@"==a.charAt(b)&&c++;return c},"~S");I(c$,"MODE_BITSET",1,"MODE_ARRAY",
2,"MODE_MAP",3)});B("JS");E(["java.lang.Exception"],"JS.InvalidSmilesException",null,function(){c$=N(JS,"InvalidSmilesException",Exception);c$.getLastError=h(c$,"getLastError",function(){return JS.InvalidSmilesException.lastError});c$.clear=h(c$,"clear",function(){JS.InvalidSmilesException.lastError=null});M(c$,function(a){Q(this,JS.InvalidSmilesException,[a]);JS.InvalidSmilesException.lastError=a},"~S");I(c$,"lastError",null)});B("JS");E(["JU.JmolMolecule","JU.BS","$.Lst","JS.VTemp"],"JS.SmilesSearch",
"java.util.Arrays $.Hashtable JU.AU $.SB $.V3 JS.SmilesAromatic $.SmilesAtom $.SmilesBond $.SmilesMeasure $.SmilesParser JU.BSUtil $.Logger".split(" "),function(){c$=G(function(){this.bioAtoms=this.smartsAtoms=this.jmolAtoms=this.pattern=this.patternAtoms=null;this.jmolAtomCount=0;this.bsRequired=this.bsSelected=null;this.isSmilesFind=this.isSmarts=this.matchAllAtoms=this.firstMatchOnly=!1;this.subSearches=null;this.needRingData=this.haveAtomStereochemistry=this.haveBondStereochemistry=this.haveSelected=
!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.aromaticDouble=this.noAromatic=this.ignoreStereochemistry=
!1;this.v=this.bsCheck=null;F(this,arguments)},JS,"SmilesSearch",JU.JmolMolecule);K(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});h(c$,"toString",function(){var a=(new JU.SB).append(this.pattern);a.append("\nmolecular formula: "+this.getMolecularFormula(!0,null,!1));return a.toString()});h(c$,"setSelected",function(a){null==
a&&(a=JU.BS.newN(this.jmolAtomCount),a.setBits(0,this.jmolAtomCount));this.bsSelected=a},"JU.BS");h(c$,"setAtomArray",function(){this.patternAtoms.length>this.ac&&(this.patternAtoms=JU.AU.arrayCopyObject(this.patternAtoms,this.ac));this.nodes=this.patternAtoms});h(c$,"addAtom",function(){this.ac>=this.patternAtoms.length&&(this.patternAtoms=JU.AU.doubleLength(this.patternAtoms));var a=(new JS.SmilesAtom).setIndex(this.ac);this.patternAtoms[this.ac]=a;this.ac++;return a});h(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");h(c$,"clear",function(){this.bsReturn.clearAll();this.nNested=0;this.nestedBond=this.htNested=null;this.clearBsFound(-1)});h(c$,"setNested",function(a,b){this.top.htNested.put("_"+a,b)},"~N,~O");h(c$,"getNested",function(a){return this.top.htNested.get("_"+a)},"~N");h(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});h(c$,"setRingData",function(a){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");h(c$,"getRingData",function(a,b,c){var d=0!=(b&4),e=0!=(b&8);d&&null==c&&(c=JU.AU.createArrayOfArrayList(4));
e&&this.needAromatic&&(this.bsAromatic=JS.SmilesAromatic.checkAromaticDefined(this.jmolAtoms,this.bsSelected),d=!1);0>this.ringDataMax&&(this.ringDataMax=8);d&&6>this.ringDataMax&&(this.ringDataMax=6);a&&(this.ringCounts=v(this.jmolAtomCount,0),this.ringConnections=v(this.jmolAtomCount,0),this.ringData=Array(this.ringDataMax+1));this.ringSets=new JU.SB;for(var f="****";f.length<this.ringDataMax;)f+=f;var k=null;for(b=3;b<=this.ringDataMax;b++)if(!(b>this.jmolAtomCount)){var j="*1"+f.substring(0,b-
2)+"*1",j=JS.SmilesParser.getMolecule(j,!0),j=this.subsearch(j,!1,!0);if(null!=c&&5>=b){for(var g=new JU.Lst,h=j.size();0<=--h;)g.addLast(j.get(h));c[b-3]=g}if(this.needAromatic){if(!e&&(!d||5==b||6==b))for(g=j.size();0<=--g;)h=j.get(g),(e||JS.SmilesAromatic.isFlatSp2Ring(this.jmolAtoms,this.bsSelected,h,d?0.1:0.01))&&this.bsAromatic.or(h);if(d)switch(b){case 5:k=j;break;case 6:e?this.bsAromatic=JS.SmilesAromatic.checkAromaticDefined(this.jmolAtoms,this.bsAromatic):JS.SmilesAromatic.checkAromaticStrict(this.jmolAtoms,
this.bsAromatic,k,j),c[3]=new JU.Lst,this.setAromatic56(k,this.bsAromatic5,5,c[3]),this.setAromatic56(j,this.bsAromatic6,6,c[3])}}if(a){this.ringData[b]=new JU.BS;for(var l=0;l<j.size();l++){g=j.get(l);this.ringData[b].or(g);for(h=g.nextSetBit(0);0<=h;h=g.nextSetBit(h+1))this.ringCounts[h]++}}}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(l=c.length;0<=--l;)0<this.ringCounts[a.getBondedAtomIndex(l)]&&this.ringConnections[b]++},
"~B,~N,~A");h(c$,"setAromatic56",function(a,b,c,d){for(var e=0;e<a.size();e++){var f=a.get(e);this.v.bsTemp.clearAll();this.v.bsTemp.or(f);this.v.bsTemp.and(this.bsAromatic);this.v.bsTemp.cardinality()==c&&(b.or(f),null!=d&&d.addLast(f))}},"JU.Lst,JU.BS,~N,JU.Lst");h(c$,"subsearch",function(a,b,c){a.ringSets=this.ringSets;a.jmolAtoms=this.jmolAtoms;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");h(c$,"search",function(a){this.ignoreStereochemistry=0!=(this.flags&2);this.noAromatic=0!=(this.flags&1);this.aromaticDouble=0!=(this.flags&16);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");h(c$,"checkMatch",function(a,b,c,d){var e;if(null==a)null==this.nestedBond?this.clearBsFound(-1):
this.bsReturn.clearAll();else{if(this.bsFound.get(c)||!this.bsSelected.get(c))return!0;e=this.jmolAtoms[c];if(!this.isRingCheck){if(null!=a.atomsOr){for(var f=0;f<a.nAtomsOr;f++)if(!this.checkMatch(a.atomsOr[f],b,c,d))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}e=e.getEdges();for(f=a.getBondCount();0<=--f;){var k=a.getBond(f);if(k.getAtomIndex2()==a.index){var j=k.atom1,
g=j.getMatchingAtom();switch(k.order){case 96:case 112:if(!this.checkMatchBond(a,j,k,c,g,null))return!0;break;default:for(var h=0;h<e.length&&(!(e[h].getAtomIndex1()==g||e[h].getAtomIndex2()==g)||!e[h].isCovalent());h++);if(h==e.length||!this.checkMatchBond(a,j,k,c,g,e[h]))return!0}}}this.patternAtoms[a.index].setMatchingAtom(c);JU.Logger.debugging&&!this.isSilent&&JU.Logger.debug("pattern atom "+b+" "+a);this.bsFound.set(c)}if(!this.continueMatch(b,c,d))return!1;0<=c&&this.clearBsFound(c);return!0},
"JS.SmilesAtom,~N,~N,~B");h(c$,"continueMatch",function(a,b,c){var d,e;if(++a<this.ac){var f=this.patternAtoms[a],k=0<=b?f.getBondTo(null):0==a?this.nestedBond:null;if(null==k){k=JU.BSUtil.copy(this.bsFound);if(0<=f.notBondedIndex){d=this.patternAtoms[f.notBondedIndex];var j=this.jmolAtoms[d.getMatchingAtom()];if(d.isBioAtom)d=j.getOffsetResidueAtom("0",1),0<=d&&k.set(d),d=j.getOffsetResidueAtom("0",-1),0<=d&&k.set(d);else{e=j.getEdges();for(d=0;d<e.length;d++)k.set(e[d].getOtherAtomNode(j).getIndex())}}b=
0<=b&&f.isBioAtom&&(null==f.atomName||null!=f.residueChar);for(j=this.bsSelected.nextSetBit(0);0<=j;j=this.bsSelected.nextSetBit(j+1)){if(!k.get(j)&&!this.checkMatch(f,a,j,c))return!1;b&&(d=this.jmolAtoms[j].getOffsetResidueAtom(f.atomName,1),0<=d&&(j=d-1))}this.bsFound=k;return!0}d=this.jmolAtoms[k.atom1.getMatchingAtom()];switch(k.order){case 96:j=d.getOffsetResidueAtom(f.atomName,1);if(0<=j){k=JU.BSUtil.copy(this.bsFound);d.getGroupBits(this.bsFound);if(!this.checkMatch(f,a,j,c))return!1;this.bsFound=
k}return!0;case 112:b=new JU.Lst;d.getCrossLinkLeadAtomIndexes(b);k=JU.BSUtil.copy(this.bsFound);d.getGroupBits(this.bsFound);for(j=0;j<b.size();j++)if(!this.checkMatch(f,a,b.get(j).intValue(),c))return!1;this.bsFound=k;return!0}e=d.getEdges();if(null!=e)for(j=0;j<e.length;j++)if(!this.checkMatch(f,a,d.getBondedAtomIndex(j),c))return!1;this.clearBsFound(b);return!0}if(!this.ignoreStereochemistry&&!this.checkStereochemistry())return!0;k=new JU.BS;for(j=f=0;j<this.ac;j++)if(b=this.patternAtoms[j].getMatchingAtom(),
c||!this.top.haveSelected||this.patternAtoms[j].selected){f++;k.set(b);this.patternAtoms[j].isBioAtom&&null==this.patternAtoms[j].atomName&&this.jmolAtoms[b].getGroupBits(k);if(c)break;!this.isSmarts&&0<this.patternAtoms[j].missingHydrogenCount&&this.getHydrogens(this.jmolAtoms[b],k)}if(null!=this.bsRequired&&!this.bsRequired.intersects(k)||this.matchAllAtoms&&k.cardinality()!=this.selectedAtomCount)return!0;if(null!=this.bsCheck)if(c){this.bsCheck.clearAll();for(j=0;j<this.ac;j++)this.bsCheck.set(this.patternAtoms[j].getMatchingAtom());
if(this.bsCheck.cardinality()!=this.ac)return!0}else if(k.cardinality()!=this.ac)return!0;this.bsReturn.or(k);if(this.getMaps){a=v(f,0);for(k=j=0;j<this.ac;j++)if(c||!this.top.haveSelected||this.patternAtoms[j].selected)a[k++]=this.patternAtoms[j].getMatchingAtom();this.vReturn.addLast(a);return!this.firstMatchOnly}if(this.asVector){c=!0;for(j=this.vReturn.size();0<=--j&&c;)c=!this.vReturn.get(j).equals(k);if(!c)return!0;this.vReturn.addLast(k)}if(this.isRingCheck){this.ringSets.append(" ");for(d=
3*a+2;--d>a;)this.ringSets.append("-").appendI(this.patternAtoms[(d<=2*a?2*a-d+1:d-1)%a].getMatchingAtom());this.ringSets.append("- ");return!0}return this.firstMatchOnly?!1:k.cardinality()!=this.selectedAtomCount},"~N,~N,~B");h(c$,"clearBsFound",function(a){0>a?null==this.bsCheck&&this.bsFound.clearAll():this.bsFound.clear(a)},"~N");h(c$,"getHydrogens",function(a,b){for(var c=a.getEdges(),d=-1,e=0;e<c.length;e++)if(1==this.jmolAtoms[a.getBondedAtomIndex(e)].getElementNumber()){d=a.getBondedAtomIndex(e);
if(null==b)break;b.set(d)}return 0<=d?this.jmolAtoms[d]:null},"JU.Node,JU.BS");h(c$,"checkPrimitiveAtom",function(a,b){for(var c=this.jmolAtoms[b],d=a.not;;){var e;if(0<a.iNested){d=this.getNested(a.iNested);L(d,JS.SmilesSearch)&&(a.isBioAtom&&(d.nestedBond=a.getBondTo(null)),d=this.subsearch(d,!0,!1),null==d&&(d=new JU.BS),a.isBioAtom||this.setNested(a.iNested,d));d=a.not!=d.get(b);break}if(a.isBioAtom){e=c;if(null!=a.atomName&&(a.isLeadAtom()?!e.isLeadAtom():!a.atomName.equals(e.getAtomName().toUpperCase())))break;
if(a.notCrossLinked&&e.getCrossLinkLeadAtomIndexes(null))break;if(null!=a.residueName&&!a.residueName.equals(e.getGroup3(!1).toUpperCase()))break;if(null!=a.residueChar){if(a.isDna()&&!e.isDna()||a.isRna()&&!e.isRna()||a.isProtein()&&!e.isProtein()||a.isNucleic()&&!e.isNucleic())break;var f=e.getGroup1("\x00").toUpperCase(),f=a.residueChar.equals(f);switch(a.residueChar.charAt(0)){case "N":f=a.isNucleic()?e.isNucleic():f;break;case "R":f=a.isNucleic()?e.isPurine():f;break;case "Y":f=a.isNucleic()?
e.isPyrimidine():f}if(!f)break}if(0<=a.elementNumber&&a.elementNumber!=c.getElementNumber())break}else{if(null!=a.atomName&&!a.atomName.equals(c.getAtomName().toUpperCase()))break;if(0<=a.jmolIndex&&c.getIndex()!=a.jmolIndex)break;if(null!=a.atomType&&!a.atomType.equals(c.getAtomType()))break;if(0<=a.elementNumber&&a.elementNumber!=c.getElementNumber())break;e=a.isAromatic();if(!this.noAromatic&&!a.aromaticAmbiguous&&e!=this.bsAromatic.get(b))break;if(-2147483648!=(e=a.getAtomicMass()))if(f=c.getIsotopeNumber(),
0<=e&&e!=f||0>e&&0!=f&&-e!=f)break;if(-2147483648!=(e=a.getCharge())&&e!=c.getFormalCharge())break;e=a.getCovalentHydrogenCount()+a.missingHydrogenCount;if(0<=e&&e!=c.getCovalentHydrogenCount())break;e=a.implicitHydrogenCount;if(-2147483648!=e&&(f=c.getImplicitHydrogenCount(),-1==e?0==f:e!=f))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&&(e=this.ringConnections[b],-1==a.ringConnectivity&&0==e||-1!=a.ringConnectivity&&e!=a.ringConnectivity))break}d=!d;break}return d},"JS.SmilesAtom,~N");h(c$,"checkMatchBond",function(a,b,c,d,e,f){if(null!=c.bondsOr){for(var k=0;k<c.nBondsOr;k++)if(this.checkMatchBond(a,b,c.bondsOr[k],d,e,f))return!0;return!1}if(null==c.primitives){if(!this.checkPrimitiveBond(c,d,e,f))return!1}else for(a=0;a<c.nPrimitives;a++)if(!this.checkPrimitiveBond(c.primitives[a],
d,e,f))return!1;c.matchingBond=f;return!0},"JS.SmilesAtom,JS.SmilesAtom,JS.SmilesBond,~N,~N,JU.Edge");h(c$,"checkPrimitiveBond",function(a,b,c,d){var e=!1;switch(a.order){case 96:return a.isNot!=(this.bioAtoms[c].getOffsetResidueAtom("0",1)==this.bioAtoms[b].getOffsetResidueAtom("0",0));case 112:return a.isNot!=this.bioAtoms[b].isCrossLinked(this.bioAtoms[c])}var f=!this.noAromatic&&this.bsAromatic.get(b),k=!this.noAromatic&&this.bsAromatic.get(c);d=d.getCovalentOrder();if(f&&k)switch(a.order){case 17:case 65:e=
JS.SmilesSearch.isRingBond(this.ringSets,b,c);break;case 1:e=!this.isSmarts||!JS.SmilesSearch.isRingBond(this.ringSets,b,c);break;case 2:e=!this.isSmarts||this.aromaticDouble&&(2==d||514==d);break;case 769:case 1025:case 81:case -1:e=!0}else switch(a.order){case 81:case -1:e=!0;break;case 1:case 257:case 513:e=1==d||1041==d||1025==d;break;case 769:e=d==(this.isSmilesFind?33:1);break;case 1025:e=d==(this.isSmilesFind?97:1);break;case 2:e=2==d;break;case 3:e=3==d;break;case 65:e=JS.SmilesSearch.isRingBond(this.ringSets,
b,c)}return e!=a.isNot},"JS.SmilesBond,~N,~N,JU.Edge");c$.isRingBond=h(c$,"isRingBond",function(a,b,c){return null!=a&&0<=a.indexOf("-"+b+"-"+c+"-")},"JU.SB,~N,~N");h(c$,"checkStereochemistry",function(){for(var a=0;a<this.measures.size();a++)if(!this.measures.get(a).check())return!1;if(this.haveAtomStereochemistry){JU.Logger.debugging&&JU.Logger.debug("checking stereochemistry...");for(var b=null,c=null,d=null,e=null,f=null,k=null,j=c=null,a=0;a<this.ac;a++){var g=this.patternAtoms[a],h=this.jmolAtoms[g.getMatchingAtom()],
k=g.missingHydrogenCount;0>k&&(k=0);var l=g.getChiralClass();if(-2147483648!=l){var m=g.getChiralOrder();if(this.isSmilesFind&&h.getAtomSite()>>8!=l)return!1;JU.Logger.debugging&&JU.Logger.debug("...type "+l+" for pattern atom "+g+" "+h);switch(l){case 2:c=g.getBond(0).getOtherAtom(g);j=g.getBond(1).getOtherAtom(g);if(null==c||null==j)continue;for(d=b=g;2==c.getBondCount()&&2==j.getBondCount()&&4==c.getValence()&&4==j.getValence();)g=c.getBondNotTo(b,!0),b=c,c=g.getOtherAtom(c),g=j.getBondNotTo(d,
!0),d=j,j=g.getOtherAtom(j);g=c;e=Array(6);e[4]=(new JS.SmilesAtom).setIndex(604);d=g.getBondCount();for(b=0;b<d;b++)c=g.bonds[b].getOtherAtom(g),2==g.bonds[b].matchingBond.getCovalentOrder()?null==j&&(j=c):null==e[0]?e[0]=this.getJmolAtom(c.getMatchingAtom()):e[1]=this.getJmolAtom(c.getMatchingAtom());if(null==j)continue;d=j.getBondCount();if(2>d||3<d)continue;for(b=0;b<d;b++)c=j.bonds[b].getOtherAtom(j),2!=j.bonds[b].matchingBond.getCovalentOrder()&&(null==e[2]?e[2]=this.getJmolAtom(c.getMatchingAtom()):
e[3]=this.getJmolAtom(c.getMatchingAtom()));if(this.isSmilesFind&&(null==e[1]&&this.getX(g,e,1,!1,!0),null==e[3]&&this.getX(j,e,3,!1,!1),!this.setSmilesCoordinates(h,g,j,e)))return!1;null==e[1]&&this.getX(g,e,1,!0,!1);null==e[3]&&this.getX(j,e,3,!0,!1);if(!JS.SmilesSearch.checkStereochemistryAll(g.not,h,l,m,e[0],e[1],e[2],e[3],null,null,this.v))return!1;continue;case 4:case 8:case 5:case 6:b=this.getJmolAtom(g.getMatchingBondedAtom(0));switch(k){case 0:c=this.getJmolAtom(g.getMatchingBondedAtom(1));
break;case 1:c=this.getHydrogens(this.getJmolAtom(g.getMatchingAtom()),null);g.isFirst&&(d=c,c=b,b=d);break;default:continue}d=this.getJmolAtom(g.getMatchingBondedAtom(2-k));e=this.getJmolAtom(g.getMatchingBondedAtom(3-k));f=this.getJmolAtom(g.getMatchingBondedAtom(4-k));k=this.getJmolAtom(g.getMatchingBondedAtom(5-k));if(this.isSmilesFind&&!this.setSmilesCoordinates(h,g,j,[b,c,d,e,f,k])||!JS.SmilesSearch.checkStereochemistryAll(g.not,h,l,m,b,c,d,e,f,k,this.v))return!1}}}}if(this.haveBondStereochemistry)for(b=
0;b<this.ac;b++){c=this.patternAtoms[b];e=f=j=null;l=h=a=0;d=c.getBondCount();m=!1;for(k=0;k<d;k++){var g=c.getBond(k),s=g.atom2===c,n=g.order;switch(n){case 769:case 1025:case 2:if(s)continue;j=g.atom2;l=n;(m=2!=n)&&(a=g.isNot?-1:1);break;case 257:case 513:f=s?g.atom1:g.atom2,a=s!=(257==n)?1:-1}}if(m){g=c.getBondNotTo(j,!1);if(null==g)return!1;f=g.getOtherAtom(c);g=j.getBondNotTo(c,!1);if(null==g)return!1;e=g.getOtherAtom(j)}else{if(null==j||0==a)continue;d=j.getBondCount();for(k=0;k<d&&0==h;k++)switch(g=
j.getBond(k),s=g.atom2===j,n=g.order,n){case 257:case 513:e=s?g.atom1:g.atom2,h=s!=(257==n)?1:-1}if(0==h)continue}this.isSmilesFind&&this.setSmilesBondCoordinates(c,j,l);c=this.getJmolAtom(c.getMatchingAtom());j=this.getJmolAtom(j.getMatchingAtom());g=this.getJmolAtom(f.getMatchingAtom());d=this.getJmolAtom(e.getMatchingAtom());if(null==g||null==d)return!1;JS.SmilesMeasure.setTorsionData(g,c,j,d,this.v,m);if(m){if(h=769==l?1:-1,j=this.v.vTemp1.dot(this.v.vTemp2),0.05>j||0.95<j||0<this.v.vNorm1.dot(this.v.vNorm2)*
a*h)return!1}else if(0>this.v.vTemp1.dot(this.v.vTemp2)*a*h)return!1}return!0});h(c$,"getX",function(a,b,c,d,e){var f=this.getJmolAtom(a.getMatchingAtom()),k=a.isFirst||3==c;if(d){if(this.isSmarts){var j=f.getEdges();for(d=0;d<j.length;d++)if(2!=j[d].getCovalentOrder()){var g=this.jmolAtoms[f.getBondedAtomIndex(d)];if(g!==b[c-1]){b[c]=g;break}}}if(null==b[c]){j=new JU.V3;for(d=g=0;4>d;d++)null!=b[d]&&(g++,j.sub(b[d]));0==j.length()?(j.setT(b[4]),k=!1):(j.scaleAdd2(g+1,this.getJmolAtom(a.getMatchingAtom()),
j),k=this.isSmilesFind||k);b[c]=(new JS.SmilesAtom).setIndex(-1);b[c].setT(j)}}null==b[c]&&(b[c]=this.getHydrogens(f,null),e&&(k=!0));null!=b[c]&&k&&(g=b[c],b[c]=b[c-1],b[c-1]=g)},"JS.SmilesAtom,~A,~N,~B,~B");c$.checkStereochemistryAll=h(c$,"checkStereochemistryAll",function(a,b,c,d,e,f,k,j,g,h,l){switch(c){default:case 2:case 4:return a==(JS.SmilesSearch.getHandedness(f,k,j,e,l)!=d);case 5:return a==(!JS.SmilesSearch.isDiaxial(b,b,g,e,l,-0.95)||JS.SmilesSearch.getHandedness(f,k,j,e,l)!=d);case 6:if(a!=
!JS.SmilesSearch.isDiaxial(b,b,h,e,l,-0.95))return!1;JS.SmilesSearch.getPlaneNormals(f,k,j,g,l);if(a!=(0>l.vNorm1.dot(l.vNorm2)||0>l.vNorm2.dot(l.vNorm3)))return!1;l.vNorm2.sub2(b,e);return a==((0>l.vNorm1.dot(l.vNorm2)?2:1)==d);case 8:return JS.SmilesSearch.getPlaneNormals(e,f,k,j,l),0>l.vNorm1.dot(l.vNorm2)?a==(3!=d):0>l.vNorm2.dot(l.vNorm3)?a==(2!=d):a==(1!=d)}},"~B,JU.Node,~N,~N,JU.Node,JU.Node,JU.Node,JU.Node,JU.Node,JU.Node,JS.VTemp");h(c$,"getJmolAtom",function(a){return 0>a||a>=this.jmolAtoms.length?
null:this.jmolAtoms[a]},"~N");h(c$,"setSmilesBondCoordinates",function(a,b,c){a=this.jmolAtoms[a.getMatchingAtom()];b=this.jmolAtoms[b.getMatchingAtom()];a.set(-1,0,0);b.set(1,0,0);if(2==c){var d=0,e=0;c=a.getEdges();for(var f=c.length;0<=--f;){var k=c[f],j=k.getOtherAtomNode(a);if(j!==b)switch(j.set(-1,0==d++?-1:1,0),j=k.getAtomIndex2()==a.getIndex()?d:-d,k.order){case 1025:e=j;break;case 1041:e=-j}}var g=0,d=0,h=Array(2);c=b.getEdges();for(f=c.length;0<=--f;)if(k=c[f],j=k.getOtherAtomNode(b),j!==
a)switch(h[d]=j,j.set(1,0==d++?1:-1,0),j=k.getAtomIndex2()==b.getIndex()?d:-d,k.order){case 1025:g=j;break;case 1041:g=-j}0<e*g==(Math.abs(e)%2==Math.abs(g)%2)&&(a=h[0].y,h[0].y=h[1].y,h[1].y=a)}else{c=a.getEdges();h=0;for(f=c.length;0<=--f;)if(k=c[f],k.getOtherAtomNode(a)===b){h=33==k.order?1:-1;break}for(f=c.length;0<=--f;)k=c[f],j=k.getOtherAtomNode(a),j!==b&&j.set(-1,1,0);c=b.getEdges();for(f=c.length;0<=--f;)k=c[f],j=k.getOtherAtomNode(b),j!==a&&j.set(1,1,-h/2)}},"JS.SmilesAtom,JS.SmilesAtom,~N");
h(c$,"setSmilesCoordinates",function(a,b,c,d){var e=a.getAtomSite();if(-2147483648==e)return!1;var f=e>>8,e=e&255;c=2==f||3==f?c=this.jmolAtoms[c.getMatchingAtom()]:null;a.set(0,0,0);a=this.jmolAtoms[b.getMatchingAtom()];a.set(0,0,0);a=this.getMappedAtoms(a,c,d);switch(f){case 2:case 4:2==e&&(e=a[0],a[0]=a[1],a[1]=e);d[a[0]].set(0,0,1);d[a[1]].set(1,0,-1);d[a[2]].set(0,1,-1);d[a[3]].set(-1,-1,-1);break;case 8:switch(e){case 1:d[a[0]].set(1,0,0);d[a[1]].set(0,1,0);d[a[2]].set(-1,0,0);d[a[3]].set(0,
-1,0);break;case 2:d[a[0]].set(1,0,0);d[a[1]].set(-1,0,0);d[a[2]].set(0,1,0);d[a[3]].set(0,-1,0);break;case 3:d[a[0]].set(1,0,0),d[a[1]].set(0,1,0),d[a[2]].set(0,-1,0),d[a[3]].set(-1,0,0)}break;case 5:case 6:f=a.length,2==e&&(e=a[0],a[0]=a[f-1],a[f-1]=e),d[a[0]].set(0,0,1),d[a[f-1]].set(0,0,-1),d[a[1]].set(1,0,0),d[a[2]].set(0,1,0),d[a[3]].set(-1,0,0),6==f&&d[a[4]].set(0,-1,0)}return!0},"JU.Node,JS.SmilesAtom,JS.SmilesAtom,~A");h(c$,"getMappedAtoms",function(a,b,c){for(var d=v(null==c[4]?4:null==
c[5]?5:6,0),e=0;e<d.length;e++)d[e]=null==c[e]?104+100*e:c[e].getIndex();for(var f,k=a.getEdges(),j=null==b?null:b.getEdges(),e=0;e<d.length;e++){for(f=0;f<k.length&&k[f].getOtherAtomNode(a)!==c[e];f++);if(f<k.length)d[e]=10*f+100+e;else if(null!=b){for(f=0;f<j.length&&j[f].getOtherAtomNode(b)!==c[e];f++);f<j.length&&(d[e]=10*f+300+e)}}java.util.Arrays.sort(d);for(e=0;e<d.length;e++)d[e]%=10;return d},"JU.Node,JU.Node,~A");c$.isDiaxial=h(c$,"isDiaxial",function(a,b,c,d,e,f){e.vA.sub2(a,c);e.vB.sub2(b,
d);e.vA.normalize();e.vB.normalize();return e.vA.dot(e.vB)<f},"JU.Node,JU.Node,JU.Node,JU.Node,JS.VTemp,~N");c$.getHandedness=h(c$,"getHandedness",function(a,b,c,d,e){a=JS.SmilesAromatic.getNormalThroughPoints(a,b,c,e.vTemp,e.vA,e.vB);return 0<JS.SmilesSearch.distanceToPlane(e.vTemp,a,d)?1:2},"JU.Node,JU.Node,JU.Node,JU.Node,JS.VTemp");c$.getPlaneNormals=h(c$,"getPlaneNormals",function(a,b,c,d,e){JS.SmilesAromatic.getNormalThroughPoints(a,b,c,e.vNorm1,e.vTemp1,e.vTemp2);JS.SmilesAromatic.getNormalThroughPoints(b,
c,d,e.vNorm2,e.vTemp1,e.vTemp2);JS.SmilesAromatic.getNormalThroughPoints(c,d,a,e.vNorm3,e.vTemp1,e.vTemp2)},"JU.Node,JU.Node,JU.Node,JU.Node,JS.VTemp");c$.distanceToPlane=h(c$,"distanceToPlane",function(a,b,c){return null==a?NaN:(a.x*c.x+a.y*c.y+a.z*c.z+b)/Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z)},"JU.V3,~N,JU.P3");h(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,d=new JU.BS,e=0;e<this.ac;e++){var f=this.patternAtoms[e],
k=f.getChiralClass(),j=f.missingHydrogenCount;0>j&&(j=0);var g=b[c]=(new JS.SmilesAtom).setAll(0,c,-2147483648==k?k:(k<<8)+f.getChiralOrder(),f.elementNumber,f.getCharge());g.atomName=f.atomName;g.residueName=f.residueName;g.residueChar=f.residueChar;g.isBioAtom=f.isBioAtom;g.$isLeadAtom=f.$isLeadAtom;g.setAtomicMass(f.getAtomicMass());f.isAromatic()&&a.set(c);!f.isFirst&&(1==j&&0<k)&&d.set(c);f.setMatchingAtom(c++);f=Array(f.getBondCount()+j);for(g.setBonds(f);0<=--j;)f=b[c]=(new JS.SmilesAtom).setAll(0,
c,0,1,0),c++,f.setBonds(Array(1)),k=new JS.SmilesBond(g,f,1,!1),JU.Logger.info(""+k)}for(e=0;e<this.ac;e++){f=this.patternAtoms[e];j=f.getMatchingAtom();a=b[j];j=f.getBondCount();for(c=0;c<j;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.getMatchingAtom()];k=new JS.SmilesBond(a,g,k,!1);g.bondCount--;
JU.Logger.info(""+k)}else g=b[g.atom1.getMatchingAtom()],k=g.getBondTo(a),a.addBond(k)}for(e=d.nextSetBit(0);0<=e;e=d.nextSetBit(e+1))f=b[e].getEdges(),k=f[0],f[0]=f[1],f[1]=k},"JU.BS");h(c$,"setTop",function(a){this.top=null==a?this:a.getTop()},"JS.SmilesSearch");h(c$,"getTop",function(){return this.top===this?this:this.top.getTop()});h(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 d=c.getValue().toString();if(d.startsWith("select")){var e=b.containsKey(d)?b.get(d):this.smartsAtoms[0].findAtomsLike(d.substring(6));null==e&&(e=new JU.BS);b.put(d,e);c.setValue(e)}}});I(c$,"INITIAL_ATOMS",16)});B("JS");E(["java.util.Hashtable","JU.BS","JS.VTemp"],"JS.SmilesGenerator","JU.Lst $.SB JS.InvalidSmilesException $.SmilesAromatic $.SmilesAtom $.SmilesBond $.SmilesParser $.SmilesSearch JU.BNode $.BSUtil $.Elements $.JmolMolecule $.Logger".split(" "),function(){c$=
G(function(){this.atoms=null;this.ac=0;this.bsAromatic=this.bsSelected=null;this.explicitH=!1;this.vTemp=this.ringSets=null;this.nPairs=0;this.bsIncludingH=this.htRings=this.htRingsSequence=this.prevSp2Atoms=this.prevAtom=this.bsToDo=this.bsBondsDn=this.bsBondsUp=null;F(this,arguments)},JS,"SmilesGenerator");K(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});h(c$,"getSmiles",
function(a,b,c,d){var e=c.nextSetBit(0);if(0>e)return"";this.atoms=a;this.ac=b;this.bsSelected=c=JU.BSUtil.copy(c);this.explicitH=d;return this.getSmilesComponent(a[e],c,!1)},"~A,~N,JU.BS,~B");h(c$,"getBioSmiles",function(a,b,c,d,e,f){this.atoms=a;this.ac=b;b=new JU.SB;c=JU.BSUtil.copy(c);null!=f&&b.append("//* Jmol bioSMILES ").append(f.$replace("*","_")).append(" *//");f="\n";var k=new JU.BS,j=null,g,h=new JU.Lst;try{for(var l=0,m=c.nextSetBit(0);0<=m;m=c.nextSetBit(m+1)){var s=a[m],n=s.getGroup1("?"),
p=s.getBioStructureTypeName(),t=n.equals("?");if(null!=f)if(0<b.length()&&b.append(f),f=null,l=0,0<p.length)0!=s.getChainID()&&(g="//* chain "+s.getChainIDStr()+" "+p+" "+s.getResno()+" *// ",l=g.length,b.append(g)),b.append("~").appendC(p.charAt(0)).append("~"),l++;else{g=this.getSmilesComponent(s,c,!0);if(g.equals(j))f="";else{var j=g,q=s.getGroup3(!0);null!=q&&b.append("//* ").append(q).append(" *//");b.append(g);f=".\n"}continue}75<=l&&(b.append("\n  "),l=2);t?this.addBracketedBioName(b,s,0<p.length?
".0":null):b.append(n);l++;var r=s.getOffsetResidueAtom("0",0);if(e){s.getCrossLinkLeadAtomIndexes(h);for(var z=0;z<h.size();z++)b.append(":"),g=this.getRingCache(r,h.get(z).intValue(),this.htRingsSequence),b.append(g),l+=1+g.length;h.clear()}s.getGroupBits(k);c.andNot(k);var x=s.getOffsetResidueAtom("0",1);if(0>x||!c.get(x)){b.append(" //* ").appendI(s.getResno()).append(" *//");if(0>x&&0>(x=c.nextSetBit(m+1)))break;0<l&&(f=".\n")}m=x-1}}catch(A){if(H(A,Exception))throw new JS.InvalidSmilesException("//* error: "+
A.getMessage()+" *//");throw A;}if(!d&&!this.htRingsSequence.isEmpty())throw this.dumpRingKeys(b,this.htRingsSequence),new JS.InvalidSmilesException("//* ?ring error? *//");g=b.toString();g.endsWith(".\n")&&(g=g.substring(0,g.length-2));return g},"~A,~N,JU.BS,~B,~B,~S");h(c$,"addBracketedBioName",function(a,b,c){a.append("[");if(null!=c&&L(b,JU.BNode)){var d=b.getChainIDStr();a.append(b.getGroup3(!1));c.equals(".0")||a.append(c).append("#").appendI(b.getElementNumber());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");h(c$,"getSmilesComponent",function(a,b,c){!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,!1);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)){var d=this.atoms[b];1==d.getElementNumber()&&0==d.getIsotopeNumber()&&this.bsSelected.clear(b)}2<this.bsSelected.cardinality()?(b=null,b=JS.SmilesParser.getMolecule("A[=&@]A",!0),b.jmolAtoms=this.atoms,L(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(d=this.bsToDo.nextSetBit(0);0<=d;d=this.bsToDo.nextSetBit(d+1))4<this.atoms[d].getCovalentBondCount()&&(this.getSmiles(b,this.atoms[d],c,!1,this.explicitH),a=null);if(null!=a)for(;null!=(a=this.getSmiles(b,a,c,!0,this.explicitH)););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.getSmiles(b,a,c,!0,this.explicitH)););}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");h(c$,"getBondStereochemistry",function(a,b){if(null==a)return"\x00";var c=a.index,d=null==b||a.getAtomIndex1()==b.getIndex();return this.bsBondsUp.get(c)?d?"/":"\\":this.bsBondsDn.get(c)?d?"\\":"/":"\x00"},"JU.Edge,JU.Node");h(c$,
"setBondDirections",function(){for(var a=new JU.BS,b=S(2,3,null),c=this.bsSelected.nextSetBit(0);0<=c;c=this.bsSelected.nextSetBit(c+1))for(var d=this.atoms[c],e=d.getEdges(),f=0;f<e.length;f++){var k=e[f],j=k.index;if(!a.get(j)){var g=k.getOtherAtomNode(d);if(!(2!=k.getCovalentOrder()||JS.SmilesSearch.isRingBond(this.ringSets,c,g.getIndex()))){a.set(j);var h=k=null,j=0,l=[d,g];JU.Logger.debugging&&JU.Logger.debug(d+" == "+g);h=1;for(g=0;2>g&&0<h&&3>h;g++)for(var h=0,m=l[g],s=m.getEdges(),n=0;n<s.length;n++)1==
s[n].getCovalentOrder()&&(b[g][h++]=s[n],"\x00"!=this.getBondStereochemistry(s[n],m)&&(k=s[n],j=g));if(!(3==h||0==h))if(null==k&&(j=0,k=b[j][0],this.bsBondsUp.set(k.index)),m=this.getBondStereochemistry(k,l[j]),h=k.getOtherAtomNode(l[j]),null!=h)for(g=0;2>g;g++)for(s=0;2>s;s++)if(n=b[g][s],!(null==n||n===k)){var p=n.index,t=n.getOtherAtomNode(l[g]);if(null!=t){var q=this.getBondStereochemistry(n,l[g]),r=JS.SmilesSearch.isDiaxial(l[j],l[g],h,t,this.vTemp,0);"\x00"==q||q!=m==r?("\\"==m&&r||"/"==m&&
!r)==(n.getAtomIndex1()!=t.getIndex())?this.bsBondsUp.set(p):this.bsBondsDn.set(p):JU.Logger.error("BOND STEREOCHEMISTRY ERROR");JU.Logger.debugging&&JU.Logger.debug(this.getBondStereochemistry(k,l[0])+" "+h.getIndex()+" "+t.getIndex()+" "+this.getBondStereochemistry(n,l[g]))}}}}}});h(c$,"getSmiles",function(a,b,c,d,e){var f=b.getIndex();if(!this.bsToDo.get(f))return null;this.bsToDo.clear(f);var k=!this.bsSelected.get(f),j=null==this.prevAtom?-1:this.prevAtom.getIndex(),g=this.bsAromatic.get(f),
h=null!=this.prevSp2Atoms,l=this.prevSp2Atoms,m=0,n=b.getElementNumber(),w=0,p=new JU.Lst,t=null,q=null,r=b.getEdges(),z=null,x=g?10:0,A=Array(7);JU.Logger.debugging&&JU.Logger.debug(a.toString());if(null!=r)for(var u=r.length;0<=--u;){var y=r[u];if(y.isCovalent()){var C=r[u].getOtherAtomNode(b),y=C.getIndex();if(y==j)q=r[u];else{var D=!e&&1==C.getElementNumber()&&0==C.getIsotopeNumber();if(!this.bsIncludingH.get(y))if(!D&&c&&this.bsSelected.get(f))this.bsToDo.set(y);else continue;D?(z=C,w++,1<w&&
(x=10)):p.addLast(r[u])}}}r=null;null==l&&(l=Array(5));null!=q&&(r=JS.SmilesBond.getBondOrderString(q.getCovalentOrder()),null==this.prevSp2Atoms?l[m++]=this.prevAtom:m=2);var m=m+w,j=0,B=new JU.BS;if(d)for(u=0;u<p.size();u++){var y=p.get(u),D=y.getOtherAtomNode(b),C=D.getCovalentBondCount()-(e?0:D.getCovalentHydrogenCount()),v=y.getCovalentOrder();if(1==v&&1==C&&u<p.size()-(null==t?1:0))B.set(y.index);else if((1<v||C>j)&&!this.htRings.containsKey(JS.SmilesGenerator.getRingKey(D.getIndex(),f)))j=
1<v?1E3+v:C,t=y}j=null==t?null:t.getOtherAtomNode(b);C=null==t?0:t.getCovalentOrder();7>x&&null!=q&&(2==q.getCovalentOrder()&&2==C&&null!=this.prevSp2Atoms&&null!=this.prevSp2Atoms[1]?(A[x++]=this.prevSp2Atoms[0],A[x++]=this.prevSp2Atoms[1]):A[x++]=this.prevAtom);7>x&&1==w&&(A[x++]=z);z=1==C&&null==this.prevSp2Atoms;v=this.getBondStereochemistry(q,this.prevAtom);q=new JU.SB;for(u=0;u<p.size();u++)y=p.get(u),B.get(y.index)&&(D=y.getOtherAtomNode(b),y=new JU.SB,y.append("("),this.prevAtom=b,this.prevSp2Atoms=
null,this.getSmiles(y,D,c,d,e),y.append(")"),0<=q.indexOf(y.toString())&&(x=10),q.appendSB(y),p.remove(u--),7>x&&(A[x++]=D),5>m&&(l[m++]=D));u=2==C?j.getIndex():-1;if(1<w||g||0>u||JS.SmilesSearch.isRingBond(this.ringSets,f,u))m=-1;0>m&&(l=null);if(null!=r||"\x00"!=v)"\x00"!=v&&(r=""+v),a.append(r);c=null;if(!d&&(5==p.size()||6==p.size()))c=this.sortInorganic(b,p);for(u=0;u<p.size();u++)y=p.get(u),y!==t&&(D=y.getOtherAtomNode(b),d=this.getRingCache(f,D.getIndex(),this.htRings),r=JS.SmilesBond.getBondOrderString(y.order),
z||(v=this.getBondStereochemistry(y,b),"\x00"!=v&&(r=""+v)),q.append(r),q.append(d),7>x&&(A[x++]=D),null!=l&&5>m&&(l[m++]=D));if(h&&2==x&&2==C&&3==j.getCovalentBondCount()){r=j.getEdges();for(m=0;m<r.length;m++)r[m].isCovalent()&&j.getBondedAtomIndex(m)!=f&&(A[x++]=this.atoms[j.getBondedAtomIndex(m)]);m=0}else null!=j&&7>x&&(A[x++]=j);h=b.getFormalCharge();p=b.getIsotopeNumber();d=b.getValence();u=b.getAtomName();e=L(b,JU.BNode)?b.getBioStructureTypeName():"";JU.Logger.debugging&&a.append("\n//* "+
b+" *//\t");k&&0!=e.length&&0!=u.length?this.addBracketedBioName(a,b,"."+u):a.append(JS.SmilesAtom.getAtomLabel(n,p,d,h,w,g,null!=c?c:this.checkStereoPairs(b,f,A,x)));a.appendSB(q);if(null==t)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 j},"JU.SB,JU.Node,~B,~B,~B");h(c$,"sortInorganic",function(a,b){for(var c=a.getIndex(),d=b.size(),e=new JU.Lst,f=new JU.Lst,k,j,g,h,l=new JU.BS,m=null,n=Array(6),m=!0,w="",p=0;p<d;p++)if(g=
b.get(p),n[0]=k=g.getOtherAtomNode(a),0==p?w=this.addStereoCheck(c,n,0,""):m&&null!=this.addStereoCheck(c,n,0,w)&&(m=!1),!l.get(p)){l.set(p);for(var t=!1,q=p+1;q<d;q++)if(!l.get(q)&&(h=b.get(q),j=h.getOtherAtomNode(a),JS.SmilesSearch.isDiaxial(a,a,k,j,this.vTemp,-0.95))){e.addLast([g,h]);t=!0;l.set(q);break}t||f.addLast(g)}c=e.size();if(m||6==d&&3!=c||5==d&&0==c)return"";m=e.get(0);g=m[0];n[0]=g.getOtherAtomNode(a);b.clear();b.addLast(g);1<c&&f.addLast(e.get(1)[0]);3==c&&f.addLast(e.get(2)[0]);1<
c&&f.addLast(e.get(1)[1]);3==c&&f.addLast(e.get(2)[1]);for(p=0;p<f.size();p++)g=f.get(p),b.addLast(g),n[p+1]=g.getOtherAtomNode(a);b.addLast(m[1]);return JS.SmilesGenerator.getStereoFlag(a,n,d,this.vTemp)},"JU.Node,JU.Lst");h(c$,"checkStereoPairs",function(a,b,c,d){if(4>d)return"";if(4==d&&6==a.getElementNumber())for(var e="",f=0;4>f;f++)if(null==(e=this.addStereoCheck(b,c,f,e))){d=10;break}return 6<d?"":JS.SmilesGenerator.getStereoFlag(a,c,d,this.vTemp)},"JU.Node,~N,~A,~N");c$.getStereoFlag=h(c$,
"getStereoFlag",function(a,b,c,d){var e=b[0],f=b[1],k=b[2],j=b[3],g=b[4];b=b[5];var h=4;switch(c){default:case 5:case 6:return JS.SmilesSearch.checkStereochemistryAll(!1,a,h,1,e,f,k,j,g,b,d)?"@":"@@";case 2:case 4:if(null==k||null==j)break;c=JS.SmilesAromatic.getNormalThroughPoints(e,f,k,d.vTemp,d.vA,d.vB);if(0.2>Math.abs(JS.SmilesSearch.distanceToPlane(d.vTemp,c,j))){h=8;if(JS.SmilesSearch.checkStereochemistryAll(!1,a,h,1,e,f,k,j,g,b,d))return"@SP1";if(JS.SmilesSearch.checkStereochemistryAll(!1,
a,h,2,e,f,k,j,g,b,d))return"@SP2";if(JS.SmilesSearch.checkStereochemistryAll(!1,a,h,3,e,f,k,j,g,b,d))return"@SP3"}else return JS.SmilesSearch.checkStereochemistryAll(!1,a,h,1,e,f,k,j,g,b,d)?"@":"@@"}return""},"JU.Node,~A,~N,JS.VTemp");h(c$,"addStereoCheck",function(a,b,c,d){var e=b[c].getAtomicAndIsotopeNumber(),f=b[c].getCovalentBondCount(),k=6==e&&!this.explicitH?b[c].getCovalentHydrogenCount():0;if(6==e?4!=f||3!=k:1<f)return d;e=";"+e+"/"+k+"/"+f+",";if(0<=d.indexOf(e)){if(3==k){for(e=k=0;e<f&&
3>k;e++){var j=b[c].getBondedAtomIndex(e);j!=a&&(k+=this.atoms[j].getAtomicAndIsotopeNumber())}if(3<k)return d}return null}return d+e},"~N,~A,~N,~S");h(c$,"getRingCache",function(a,b,c){var d=JS.SmilesGenerator.getRingKey(a,b),e=c.get(d),e=null==e?null:e[0];null==e?(c.put(d,[e=JS.SmilesParser.getRingPointer(++this.nPairs),Integer.$valueOf(b)]),JU.Logger.debugging&&JU.Logger.debug("adding for "+a+" ring key "+this.nPairs+": "+d)):(c.remove(d),JU.Logger.debugging&&JU.Logger.debug("using ring key "+
d));return e},"~N,~N,java.util.Map");h(c$,"dumpRingKeys",function(a,b){JU.Logger.info(a.toString()+"\n\n");for(var c,d=b.keySet().iterator();d.hasNext()&&((c=d.next())||1);)JU.Logger.info("unmatched ring key: "+c)},"JU.SB,java.util.Map");c$.getRingKey=h(c$,"getRingKey",function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)},"~N,~N")});B("JS");E(null,"JS.SmilesAromatic",["JU.BS","$.V3"],function(){c$=N(JS,"SmilesAromatic");c$.isFlatSp2Ring=h(c$,"isFlatSp2Ring",function(a,b,c,d){for(var e=c.nextSetBit(0);0<=
e;e=c.nextSetBit(e+1)){var f=a[e],k=f.getEdges();if(!(3>k.length)&&3<k.length)return!1}if(3.4028235E38==d)return!0;0>=d&&(d=0.01);for(var j=new JU.V3,g=new JU.V3,h=new JU.V3,l=null,e=c.cardinality(),m=Array(2*e),n=0,w=1-5*d,e=c.nextSetBit(0);0<=e;e=c.nextSetBit(e+1)){for(var f=a[e],k=f.getEdges(),p=-1,t=-1,q=-1,k=k.length;0<=--k;){var r=f.getBondedAtomIndex(k);b.get(r)&&(c.get(r)?0>t?t=r:q=r:p=r)}JS.SmilesAromatic.getNormalThroughPoints(a[t],a[e],a[q],j,g,h);null==l&&(l=new JU.V3);if(!JS.SmilesAromatic.addNormal(j,
l,w))return!1;m[n++]=JU.V3.newV(j);if(0<=p){JS.SmilesAromatic.getNormalThroughPoints(a[t],a[p],a[q],j,g,h);if(!JS.SmilesAromatic.addNormal(j,l,w))return!1;m[n++]=JU.V3.newV(j)}}return JS.SmilesAromatic.checkStandardDeviation(m,l,n,d)},"~A,JU.BS,JU.BS,~N");c$.addNormal=h(c$,"addNormal",function(a,b,c){var d=b.dot(a);if(0!=d&&Math.abs(d)<c)return!1;0>d&&a.scale(-1);b.add(a);b.normalize();return!0},"JU.V3,JU.V3,~N");c$.checkStandardDeviation=h(c$,"checkStandardDeviation",function(a,b,c,d){for(var e=
0,f=0,k=0;k<c;k++)var j=a[k].dot(b),e=e+j,f=f+j*j;e=Math.sqrt((f-e*e/c)/(c-1));return e<d},"~A,JU.V3,~N,~N");c$.getNormalThroughPoints=h(c$,"getNormalThroughPoints",function(a,b,c,d,e,f){e.sub2(b,a);f.sub2(c,a);d.cross(e,f);d.normalize();e.setT(a);return-e.dot(d)},"JU.Node,JU.Node,JU.Node,JU.V3,JU.V3,JU.V3");c$.checkAromaticDefined=h(c$,"checkAromaticDefined",function(a,b){for(var c=new JU.BS,d=b.nextSetBit(0);0<=d;d=b.nextSetBit(d+1))for(var e=a[d].getEdges(),f=0;f<e.length;f++)switch(e[f].order){case 515:case 514:case 513:c.set(e[f].getAtomIndex1()),
c.set(e[f].getAtomIndex2())}return c},"~A,JU.BS");c$.checkAromaticStrict=h(c$,"checkAromaticStrict",function(a,b,c,d){for(var e=new JU.BS,f=new JU.BS,k=c.size();0<=--k;){var j=c.get(k);JS.SmilesAromatic.isAromaticRing(b,f,j,5)&&JS.SmilesAromatic.checkAromaticStrict2(a,e,c,d,j,!0)}for(k=d.size();0<=--k;)j=d.get(k),JS.SmilesAromatic.isAromaticRing(b,f,j,6)&&JS.SmilesAromatic.checkAromaticStrict2(a,e,c,d,j,!1);b.clearAll();b.or(e)},"~A,JU.BS,JU.Lst,JU.Lst");c$.isAromaticRing=h(c$,"isAromaticRing",function(a,
b,c,d){b.clearAll();b.or(c);b.and(a);return b.cardinality()==d},"JU.BS,JU.BS,JU.BS,~N");c$.checkAromaticStrict2=h(c$,"checkAromaticStrict2",function(a,b,c,d,e,f){f=JS.SmilesAromatic.countInternalPairs(a,e,f)<<1;switch(f){case -3:break;default:for(var k=e.nextSetBit(0);0<=k;k=e.nextSetBit(k+1))for(var j=a[k].getEdges(),g=0;g<j.length;g++)if(2==j[g].order){var h=j[g].getOtherAtomNode(a[k]).getIndex();if(!e.get(h)){for(var l=!1,m=c.size();0<=--m&&!l;){var n=c.get(m);if(n.get(h)&&(b.get(h)||3==Math.abs(JS.SmilesAromatic.countInternalPairs(a,
n,!0))))l=!0}for(m=d.size();0<=--m&&!l;)if(n=d.get(m),n.get(h)&&(b.get(h)||3==Math.abs(JS.SmilesAromatic.countInternalPairs(a,n,!1))))l=!0;if(!l)return;f++}}}6==f&&b.or(e)},"~A,JU.BS,JU.Lst,JU.Lst,JU.BS,~B");c$.countInternalPairs=h(c$,"countInternalPairs",function(a,b,c){for(var d=0,e=0,f=0,k=b.nextSetBit(0);0<=k;k=b.nextSetBit(k+1)){for(var j=a[k],g=j.getEdges(),h=!1,l=0;l<g.length;l++){var m=g[l].getOtherAtomNode(j).getIndex();if(b.get(m))switch(g[l].order){case 514:case 513:case 515:e++;break;
case 2:d++,h=!0}}if(c&&0==e)switch(j.getElementNumber()){case 7:case 8:case 16:h||f++}}return 0==e?O(d/2)+f:e==(c?5:6)?-3:0},"~A,JU.BS,~B")});B("JS");E(["JU.P3","JU.BNode"],"JS.SmilesAtom",["JU.AU","JU.Elements","$.Logger"],function(){c$=G(function(){this.atomsOr=null;this.nAtomsOr=0;this.primitives=null;this.index=this.nPrimitives=0;this.residueChar=this.residueName=this.atomName=null;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=-2147483648;this.bonds=this.parent=null;this.iNested=this.bondCount=0;this.charge=this.atomicMass=-2147483648;this.matchingAtom=-1;this.chiralOrder=this.chiralClass=-2147483648;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;F(this,arguments)},JS,"SmilesAtom",JU.P3,JU.BNode);K(c$,function(){this.bonds=Array(4)});c$.getChiralityClass=h(c$,"getChiralityClass",function(a){return O(("0;11;AL;33;TH;TP;OH;77;SP;".indexOf(a)+1)/3)},"~S");c$.allowSmilesUnbracketed=h(c$,"allowSmilesUnbracketed",function(a){return 0<="B, C, N, O, P, S, F, Cl, Br, I,".indexOf(a+",")},"~S");h(c$,"setBioAtom",function(a){this.isBioAtom="\x00"!=a;this.bioType=a;null!=this.parent&&
(this.parent.bioType=a,this.parent.isBioAtom=this.isBioAtom)},"~S");h(c$,"setAtomName",function(a){null!=a&&(0<a.length&&(this.atomName=a),a.equals("0")&&(this.$isLeadAtom=!0),null!=this.parent&&(this.parent.atomName=a))},"~S");h(c$,"setBonds",function(a){this.bonds=a},"~A");h(c$,"addAtomOr",function(){null==this.atomsOr&&(this.atomsOr=Array(2));this.nAtomsOr>=this.atomsOr.length&&(this.atomsOr=JU.AU.doubleLength(this.atomsOr));var a=(new JS.SmilesAtom).setIndex(this.index);a.parent=this;this.atomsOr[this.nAtomsOr]=
a;this.nAtomsOr++;return a});h(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.SmilesAtom).setIndex(this.index);a.parent=this;this.primitives[this.nPrimitives]=a;this.setSymbol("*");this.hasSymbol=!1;this.nPrimitives++;return a});n(c$,"toString",function(){var a=null!=this.residueChar||null!=this.residueName?
(null==this.residueChar?this.residueName:this.residueChar)+"."+this.atomName:-1==this.elementNumber?"A":-2==this.elementNumber?"*":JU.Elements.elementSymbolFromNumber(this.elementNumber);this.$isAromatic&&(a=a.toLowerCase());return"["+a+"."+this.index+(0<=this.matchingAtom?"("+this.matchingAtom+")":"")+"]"});h(c$,"setIndex",function(a){this.index=a;return this},"~N");h(c$,"setAll",function(a,b,c,d,e){this.component=a;this.index=b;this.atomSite=c;this.elementNumber=d;this.charge=e;return this},"~N,~N,~N,~N,~N");
h(c$,"setHydrogenCount",function(){if(-2147483648!=this.missingHydrogenCount)return!0;var a=JS.SmilesAtom.getDefaultCount(this.elementNumber,this.$isAromatic);if(-2==a)return!1;if(-1==a)return!0;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=h(c$,"getDefaultCount",function(a,b){switch(a){case 0:case -1: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");n(c$,"getIndex",function(){return this.index});h(c$,"isAromatic",function(){return this.$isAromatic});h(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");n(c$,"getElementNumber",function(){return this.elementNumber});
h(c$,"getAtomicMass",function(){return this.atomicMass});h(c$,"setAtomicMass",function(a){this.atomicMass=a},"~N");h(c$,"getCharge",function(){return this.charge});h(c$,"setCharge",function(a){this.charge=a},"~N");h(c$,"getMatchingAtom",function(){return this.matchingAtom});h(c$,"setMatchingAtom",function(a){this.matchingAtom=a},"~N");h(c$,"getChiralClass",function(){return this.chiralClass});h(c$,"setChiralClass",function(a){this.chiralClass=a},"~N");h(c$,"getChiralOrder",function(){return this.chiralOrder});
h(c$,"setChiralOrder",function(a){this.chiralOrder=a},"~N");h(c$,"setExplicitHydrogenCount",function(a){this.missingHydrogenCount=a},"~N");h(c$,"setImplicitHydrogenCount",function(a){this.implicitHydrogenCount=a},"~N");h(c$,"setDegree",function(a){this.degree=a},"~N");h(c$,"setNonhydrogenDegree",function(a){this.nonhydrogenDegree=a},"~N");h(c$,"setValence",function(a){this.valence=a},"~N");h(c$,"setConnectivity",function(a){this.connectivity=a},"~N");h(c$,"setRingMembership",function(a){this.ringMembership=
a},"~N");h(c$,"setRingSize",function(a){this.ringSize=a},"~N");h(c$,"setRingConnectivity",function(a){this.ringConnectivity=a},"~N");n(c$,"getModelIndex",function(){return this.component});n(c$,"getAtomSite",function(){return this.atomSite});n(c$,"getImplicitHydrogenCount",function(){return 0});h(c$,"getExplicitHydrogenCount",function(){return this.missingHydrogenCount});n(c$,"getFormalCharge",function(){return this.charge});n(c$,"getIsotopeNumber",function(){return this.atomicMass});n(c$,"getAtomicAndIsotopeNumber",
function(){return JU.Elements.getAtomicAndIsotopeNumber(this.elementNumber,this.atomicMass)});n(c$,"getAtomName",function(){return null==this.atomName?"":this.atomName});n(c$,"getGroup3",function(){return null==this.residueName?"":this.residueName},"~B");n(c$,"getGroup1",function(){return null==this.residueChar?"":this.residueChar},"~S");h(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");
h(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()});n(c$,"getEdges",function(){return null!=this.parent?this.parent.getEdges():this.bonds});h(c$,"getBond",function(a){return null!=this.parent?this.parent.getBond(a):0<=a&&a<this.bondCount?this.bonds[a]:null},"~N");n(c$,"getCovalentBondCount",function(){return this.getBondCount()});h(c$,"getBondCount",function(){return null!=this.parent?this.parent.getCovalentBondCount():this.bondCount});h(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).matchingAtom},"~N");n(c$,"getBondedAtomIndex",function(a){return null!=this.parent?this.parent.getBondedAtomIndex(a):this.bonds[a].getOtherAtom(this).index},"~N");n(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});n(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});h(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");h(c$,"getBondNotTo",function(a,b){for(var c,d=0;d<this.bonds.length;d++)if(null!=(c=this.bonds[d])){var e=c.getOtherAtom(this);if(a!==e&&(b||1!=e.elementNumber))return c}return null},"JS.SmilesAtom,~B");n(c$,"isLeadAtom",function(){return this.$isLeadAtom});n(c$,"getOffsetResidueAtom",function(){if(this.isBioAtom)for(var a=0;a<this.bonds.length;a++)if(this.bonds[a].getAtomIndex1()==this.index&&96==this.bonds[a].order)return this.bonds[a].getOtherAtom(this).index;return-1},"~S,~N");
n(c$,"getGroupBits",function(a){a.set(this.index)},"JU.BS");n(c$,"isCrossLinked",function(a){return this.getBondTo(a).isHydrogen()},"JU.BNode");n(c$,"getCrossLinkLeadAtomIndexes",function(a){for(var b=0;b<this.bonds.length;b++)112==this.bonds[b].order&&a.addLast(Integer.$valueOf(this.bonds[b].getOtherAtom(this).index));return!0},"JU.Lst");n(c$,"getBioStructureTypeName",function(){return null});n(c$,"getResno",function(){return 0});n(c$,"getChainID",function(){return 0});n(c$,"getChainIDStr",function(){return""});
c$.getAtomLabel=h(c$,"getAtomLabel",function(a,b,c,d,e,f,k){var j=JU.Elements.elementSymbolFromNumber(a);f&&(j=j.toLowerCase(),6!=a&&(c=2147483647));return(0<k.length||0!=b||0!=d?-1:JS.SmilesAtom.getDefaultCount(a,!1))==c?j:"["+(0>=b?"":""+b)+j+(0>d?""+d:0<d?"+"+d:"")+k+(1<e?"H"+e:1==e?"H":"")+"]"},"~N,~N,~N,~N,~N,~B,~S");n(c$,"isDna",function(){return"d"==this.bioType});n(c$,"isRna",function(){return"r"==this.bioType});n(c$,"isNucleic",function(){return"n"==this.bioType||"r"==this.bioType||"d"==
this.bioType});n(c$,"isProtein",function(){return"p"==this.bioType});n(c$,"isPurine",function(){return null!=this.residueChar&&this.isNucleic()&&0<="AG".indexOf(this.residueChar)});n(c$,"isPyrimidine",function(){return null!=this.residueChar&&this.isNucleic()&&0<="CTUI".indexOf(this.residueChar)});n(c$,"isDeleted",function(){return!1});h(c$,"setAtomType",function(a){this.atomType=a},"~S");n(c$,"getAtomType",function(){return null==this.atomType?this.atomName:this.atomType});n(c$,"findAtomsLike",function(){return null},
"~S");I(c$,"STEREOCHEMISTRY_DEFAULT",0,"STEREOCHEMISTRY_ALLENE",2,"STEREOCHEMISTRY_TETRAHEDRAL",4,"STEREOCHEMISTRY_TRIGONAL_BIPYRAMIDAL",5,"STEREOCHEMISTRY_OCTAHEDRAL",6,"STEREOCHEMISTRY_SQUARE_PLANAR",8,"UNBRACKETED_SET","B, C, N, O, P, S, F, Cl, Br, I,")});B("JS");E(["JU.Edge"],"JS.SmilesBond",["JS.InvalidSmilesException"],function(){c$=G(function(){this.atom2=this.atom1=null;this.isNot=!1;this.primitives=this.matchingBond=null;this.nPrimitives=0;this.bondsOr=null;this.nBondsOr=0;F(this,arguments)},
JS,"SmilesBond",JU.Edge);c$.getBondOrderString=h(c$,"getBondOrderString",function(a){switch(a){case 1:return"";case 2:return"=";case 3:return"#";default:return""}},"~N");h(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");h(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});h(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});n(c$,"toString",function(){return this.atom1+" -"+(this.isNot?"!":"")+this.order+"- "+this.atom2});M(c$,function(a,b,c,d){Q(this,JS.SmilesBond,[]);this.set2(c,d);this.set2a(a,b)},"JS.SmilesAtom,JS.SmilesAtom,~N,~B");h(c$,"set2",function(a,b){this.order=a;this.isNot=b},"~N,~B");h(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");c$.isBondType=h(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=h(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");h(c$,"setAtom2",function(a){this.atom2=
a;null!=this.atom2&&a.addBond(this)},"JS.SmilesAtom");h(c$,"getBondType",function(){return this.order});h(c$,"getOtherAtom",function(a){return this.atom1===a?this.atom2:this.atom1},"JS.SmilesAtom");n(c$,"getAtomIndex1",function(){return this.atom1.index});n(c$,"getAtomIndex2",function(){return this.atom2.index});n(c$,"getCovalentOrder",function(){return this.order});n(c$,"getOtherAtomNode",function(a){return a===this.atom1?this.atom2:a===this.atom2?this.atom1:null},"JU.Node");n(c$,"isCovalent",function(){return 112!=
this.order});h(c$,"getValence",function(){return this.order&7});n(c$,"isHydrogen",function(){return 112==this.order});h(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}});I(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_PAIR",112,"TYPE_MULTIPLE",999)});B("JS");c$=G(function(){this.search=null;this.index=this.type=this.nPoints=0;this.isNot=!1;this.indices=null;this.max=this.min=0;this.points=null;F(this,arguments)},JS,"SmilesMeasure");K(c$,function(){this.indices=v(4,0);this.points=Array(4)});M(c$,function(a,b,c,d,e,f){this.search=a;this.type=Math.min(4,Math.max(c,2));this.index=b;this.min=Math.min(d,e);this.max=Math.max(d,
e);this.isNot=f},"JS.SmilesSearch,~N,~N,~N,~N,~B");n(c$,"toString",function(){for(var a="(."+"__dat".charAt(this.type)+this.index+":"+this.min+","+this.max+") for",b=0;b<this.type;b++)a+=" "+(b>=this.nPoints?"?":""+this.indices[b]);return a});h(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");h(c$,"check",function(){for(var a=0;a<this.type;a++){var b=this.search.patternAtoms[this.indices[a]].getMatchingAtom();
this.points[a]=this.search.jmolAtoms[b]}a=0;switch(this.type){case 2:a=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]);a=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),a=this.search.v.vTemp1.angle(this.search.v.vTemp2)/0.017453292*(0>this.search.v.vNorm1.dot(this.search.v.vNorm2)?
1:-1)}return(a<this.min||a>this.max)==this.isNot});c$.setTorsionData=h(c$,"setTorsionData",function(a,b,c,d,e,f){e.vTemp1.sub2(a,b);e.vTemp2.sub2(d,c);f&&(e.vNorm1.sub2(b,c),e.vNorm1.normalize(),e.vTemp1.cross(e.vTemp1,e.vNorm1),e.vTemp1.normalize(),e.vTemp2.cross(e.vTemp2,e.vNorm1),e.vTemp2.normalize(),e.vNorm2.cross(e.vTemp1,e.vTemp2))},"JU.P3,JU.P3,JU.P3,JU.P3,JS.VTemp,~B");I(c$,"TYPES","__dat","radiansPerDegree",0.017453292519943295);B("JS");E(["java.util.Hashtable"],"JS.SmilesParser","java.lang.Character JU.Lst $.PT $.SB JS.InvalidSmilesException $.SmilesAtom $.SmilesBond $.SmilesMeasure $.SmilesSearch JU.Elements $.Logger".split(" "),
function(){c$=G(function(){this.isBioSequence=this.isSmarts=!1;this.bioType="\x00";this.ringBonds=null;this.flags=this.branchLevel=this.braceCount=0;this.htMeasures=null;F(this,arguments)},JS,"SmilesParser");K(c$,function(){this.ringBonds=new java.util.Hashtable;this.htMeasures=new java.util.Hashtable});c$.getMolecule=h(c$,"getMolecule",function(a,b){return(new JS.SmilesParser(b)).parse(a)},"~S,~B");M(c$,function(a){this.isSmarts=a},"~B");h(c$,"reset",function(){this.branchLevel=this.braceCount=0});
h(c$,"parse",function(a){if(null==a)throw new JS.InvalidSmilesException("SMILES expressions must not be null");var b=new JS.SmilesSearch;0<=a.indexOf("$(select")&&(a=this.parseNested(b,a,"select"));for(a=JS.SmilesParser.cleanPattern(a);a.startsWith("/");){var c=JS.SmilesParser.getSubPattern(a,0,"/").toUpperCase();a=a.substring(c.length);this.flags=0;0<=c.indexOf("NOAROMATIC")&&(this.flags|=1);0<=c.indexOf("AROMATICSTRICT")&&(this.flags|=4);0<=c.indexOf("AROMATICDEFINED")&&(this.flags|=8);0<=c.indexOf("AROMATICDOUBLE")&&
(this.flags|=16);0<=c.indexOf("NOSTEREO")&&(this.flags|=2)}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 d=0;d<a.length;d++){var e="|"+a[d]+"|";0>c.indexOf(e)&&(b.subSearches[d]=this.getSearch(b,a[d],this.flags),c+=e)}JU.Logger.info(c);return b}return this.getSearch(b,a,this.flags)},"~S");h(c$,"parseVariableLength",function(a){for(var b=new JU.SB,
c=a.length-1,d=0,e=!1,f=0;f<c;f++)switch(a.charAt(f)){case "(":d++;break;case ")":d--;break;case "|":0<d&&(e=!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;d=v(1,0);for(f=null;0<=(c=a.indexOf("[$",c+1));){var k=c,j=-2147483648,g=-2147483648,c=JS.SmilesParser.getDigits(a,c+2,d),j=d[0];-2147483648!=j&&"-"==JS.SmilesParser.getChar(a,c)&&(c=JS.SmilesParser.getDigits(a,
c+1,d),g=d[0]);if("("==JS.SmilesParser.getChar(a,c)&&(f=JS.SmilesParser.getSubPattern(a,k,"["),f.endsWith(")"))){var h=k+f.length+2,l=JS.SmilesParser.getSubPattern(a,c,"("),m=c;JS.SmilesParser.getSubPattern(a,c,"[");c+=1+l.length;if(0<=l.indexOf(":")&&0>l.indexOf("|")){for(var n=0,w=l.length,p=-1,f=0;f<w;f++)switch(l.charAt(f)){case "[":case "(":n++;break;case ")":case "]":n--;break;case ".":0<=p&&0==n&&(w=f);break;case ":":0>p&&0==n&&(p=f)}0<p&&(l=l.substring(0,p)+"("+l.substring(p,w)+")"+l.substring(w))}if(-2147483648==
j){if(f=l.indexOf("|"),0<=f)return this.parseVariableLength(a.substring(0,k)+"[$1"+a.substring(m,m+f+1)+")]"+a.substring(h)+"||"+a.substring(0,k)+"[$1("+a.substring(m+f+2)+a.substring(h))}else{-2147483648==g&&(g=j);0<=l.indexOf("|")&&(l="[$("+l+")]");for(f=j;f<=g;f++){j=new JU.SB;j.append("||").append(a.substring(0,k));for(m=0;m<f;m++)j.append(l);j.append(a.substring(h));b.appendSB(j)}}}}}return e?this.parseVariableLength(b.substring(2)):2>b.length()?a:b.substring(2)},"~S");h(c$,"getSearch",function(a,
b,c){this.htMeasures=new java.util.Hashtable;var d=new JS.SmilesSearch;d.setTop(a);d.isSmarts=this.isSmarts;d.pattern=b;d.flags=c;0<=b.indexOf("$(")&&(b=this.parseNested(d,b,""));this.parseSmiles(d,b,null,!1);if(0!=this.braceCount)throw new JS.InvalidSmilesException("unmatched '{'");if(!this.ringBonds.isEmpty())throw new JS.InvalidSmilesException("Open ring");d.setAtomArray();for(a=d.ac;0<=--a;)if(b=d.patternAtoms[a],b.setBondArray(),!this.isSmarts&&"\x00"==b.bioType&&!b.setHydrogenCount(d))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=d.ac;0<=--a;){b=d.patternAtoms[a];this.checkNested(d,b,c);for(var e=0;e<b.nAtomsOr;e++)this.checkNested(d,b.atomsOr[e],c);for(e=0;e<b.nPrimitives;e++)this.checkNested(d,b.primitives[e],c)}!this.isSmarts&&!this.isBioSequence&&(d.elementCounts[1]=d.getMissingHydrogenCount());this.fixChirality(d);return d},"JS.SmilesSearch,~S,~N");h(c$,"checkNested",function(a,b,c){if(0<b.iNested){var d=a.getNested(b.iNested);L(d,String)&&!d.startsWith("select")&&("~"!=d.charAt(0)&&"\x00"!=b.bioType&&
(d="~"+b.bioType+"~"+d),c=this.getSearch(a,d,c),0<c.ac&&c.patternAtoms[0].selected&&(b.selected=!0),a.setNested(b.iNested,c))}},"JS.SmilesSearch,JS.SmilesAtom,~N");h(c$,"fixChirality",function(a){for(var b=a.ac;0<=--b;){var c=a.patternAtoms[b],d=c.getChiralClass();if(-2147483648!=d){var e=c.missingHydrogenCount;0>e&&(e=0);e+=c.getBondCount();switch(d){case 0:switch(e){case 2:d=3==c.getValence()?3:2;break;case 3:case 4:case 5:case 6:d=e}break;case 8:4!=e&&(d=0);break;case 2:case 6:case 4:case 5:e!=
d&&(d=0)}if(0==d)throw new JS.InvalidSmilesException("Incorrect number of bonds for stereochemistry descriptor");c.setChiralClass(d)}}},"JS.SmilesSearch");h(c$,"parseSmiles",function(a,b,c,d){for(var e=v(1,0),f=0,k,j=null;null!=b&&0!=b.length;){var g=0;if(null==c||null!=j&&0==j.order)this.isBioSequence&&(a.top.needAromatic=!1),g=this.checkBioType(b,0);k=JS.SmilesParser.getChar(b,g);var h=this.checkBrace(a,k,"{");h&&(k=JS.SmilesParser.getChar(b,++g));if("("==k){d="."==JS.SmilesParser.getChar(b,g+1);
if(null==c)throw new JS.InvalidSmilesException("No previous atom for "+(d?"measure":"branch"));g=JS.SmilesParser.getSubPattern(b,g,"(");g.startsWith(".")?this.parseMeasure(a,g.substring(1),c):0==g.length&&this.isBioSequence?c.notCrossLinked=!0:(this.branchLevel++,this.parseSmiles(a,g,c,!0),this.branchLevel--);g=g.length+2}else{for(f=g;JS.SmilesBond.isBondType(k,this.isSmarts,this.isBioSequence);)k=JS.SmilesParser.getChar(b,++g);j=this.parseBond(a,null,b.substring(f,g),null,c,!1,d);h&&-1!=j.order&&
(g=f);k=JS.SmilesParser.getChar(b,g);this.checkBrace(a,k,"{")&&(k=JS.SmilesParser.getChar(b,++g));"~"==k&&0==j.order&&(g=this.checkBioType(b,g),k=JS.SmilesParser.getChar(b,g));if("\x00"==k&&0==j.order)break;f=JU.PT.isDigit(k)||"%"==k;h=!f&&("_"==k||"["==k||"*"==k||JU.PT.isLetter(k));if(f){switch(k){case "%":if("("==JS.SmilesParser.getChar(b,g+1)){if(f=JS.SmilesParser.getSubPattern(b,g+1,"("),JS.SmilesParser.getDigits(f,0,e),g+=f.length+3,0>e[0])throw new JS.InvalidSmilesException("Invalid ring designation: "+
f);}else if(g+3<=b.length&&(g=JS.SmilesParser.getDigits(b.substring(0,g+3),g+1,e)),10>e[0])throw new JS.InvalidSmilesException("Two digits must follow the % sign");d=e[0];break;default:d=k.charCodeAt(0)-48,g++}this.parseRing(a,d,c,j)}else if(h)switch(k){case "[":case "_":f=JS.SmilesParser.getSubPattern(b,g,k);g+=f.length+("["==k?2:0);this.isBioSequence&&("["==k&&0>f.indexOf(".")&&0>f.indexOf("_"))&&(f+=".0");c=this.parseAtom(a,null,f,c,j,"["==k,!1,d);-1!=j.order&&0!=j.order&&j.set2a(null,c);break;
default:f=!this.isBioSequence&&JU.PT.isUpperCase(k)?JS.SmilesParser.getChar(b,g+1):"\x00";if("X"!=k||"x"!=f)if(!JU.PT.isLowerCase(f)||0==JU.Elements.elementNumberFromSymbol(b.substring(g,g+2),!0))f="\x00";"\x00"!=f&&0<="NA CA BA PA SC AC".indexOf(b.substring(g,g+2))&&(f="\x00");k=JU.PT.isUpperCase(k)&&JU.PT.isLowerCase(f)?2:1;c=this.parseAtom(a,null,b.substring(g,g+k),c,j,!1,!1,d);g+=k}else throw new JS.InvalidSmilesException("Unexpected character: "+JS.SmilesParser.getChar(b,g));}k=JS.SmilesParser.getChar(b,
g);"}"==k&&this.checkBrace(a,k,"}")&&g++;b=b.substring(g);d=!1}},"JS.SmilesSearch,~S,JS.SmilesAtom,~B");h(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");h(c$,"parseMeasure",function(a,b,c){for(var d=b.indexOf(":"),e=!1,f=0>d?b:b.substring(0,d);0!=d;){1==f.length&&(f+="0");var k=this.htMeasures.get(f);if(null==k==0>d)break;try{if(0<
d){var j="__dat".indexOf(f.charAt(0));if(2>j)break;var g=v(1,0),h=JS.SmilesParser.getDigits(f,1,g),l=b.indexOf(",",d);0>l&&(l=b.indexOf("-",d+1));if(0>l)break;var m=b.substring(d+1,l);m.startsWith("!")&&(e=!0,m=m.substring(1));var n=d+1==l?0:JU.PT.fVal(m),m=b.substring(l+1),w=0==m.length?3.4028235E38:JU.PT.fVal(m),k=new JS.SmilesMeasure(a,h,j,n,w,e);a.measures.addLast(k);0<h?this.htMeasures.put(f,k):0==h&&JU.Logger.debugging&&JU.Logger.debug("measure created: "+k)}else{if(!k.addPoint(c.index))break;
k.nPoints==k.type&&(this.htMeasures.remove(f),JU.Logger.debugging&&JU.Logger.debug("measure created: "+k));return}if(!k.addPoint(c.index))break}catch(p){if(H(p,NumberFormatException))break;else throw p;}return}throw new JS.InvalidSmilesException("invalid measure: "+b);},"JS.SmilesSearch,~S,JS.SmilesAtom");h(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");h(c$,"parseNested",function(a,b,c){var d;for(c="$("+c;0<=(d=b.lastIndexOf(c));){var e=JS.SmilesParser.getSubPattern(b,d+1,"("),f=d+e.length+3;b=b.substring(0,d)+"_"+a.addNested(e)+"_"+b.substring(f)}return b},"JS.SmilesSearch,~S,~S");h(c$,"parseVariables",function(a){for(var b=new JU.Lst,c=new JU.Lst,d,e=0,f=-1;0<=(d=a.indexOf("$",e))&&"("!=JS.SmilesParser.getChar(a,e+1);){e=JS.SmilesParser.skipTo(a,d,"=");if(e<=d+1||'"'!=JS.SmilesParser.getChar(a,e+1))break;d=a.substring(d,
e);if(0<d.lastIndexOf("$")||0<d.indexOf("]"))throw new JS.InvalidSmilesException("Invalid variable name: "+d);f=JS.SmilesParser.getSubPattern(a,e+1,'"');b.addLast("["+d+"]");c.addLast(f);e+=f.length+2;e=JS.SmilesParser.skipTo(a,e,";");f=++e}return 0>f?a:JU.PT.replaceStrings(a.substring(f),b,c)},"~S");h(c$,"parseAtom",function(a,b,c,d,e,f,k,j){if(null==c||0==c.length)throw new JS.InvalidSmilesException("Empty atom definition");var g=null==b?a.addAtom():k?b.addPrimitive():b.addAtomOr();0<this.braceCount&&
(g.selected=!0);if(!this.checkLogic(a,c,g,null,d,k,j)){var h=v(1,0);this.isBioSequence&&1==c.length&&(c+=".0");var l=c.charAt(0),m=0,n=!1;if(this.isSmarts&&"!"==l){l=JS.SmilesParser.getChar(c,++m);if("\x00"==l)throw new JS.InvalidSmilesException("invalid '!'");g.not=n=!0}var w=-2147483648,p=c.indexOf(".");if(0<=p){l=c.substring(m,p);0==l.length&&(l="*");1<l.length?g.residueName=l.toUpperCase():l.equals("*")||(g.residueChar=l);l=c.substring(p+1).toUpperCase();if(0<=(p=l.indexOf("#")))JS.SmilesParser.getDigits(l,
p+1,h),g.elementNumber=h[0],l=l.substring(0,p);0==l.length&&(l="*");l.equals("*")||g.setAtomName(l);l="\x00"}for(g.setBioAtom(this.bioType);"\x00"!=l;){g.setAtomName(this.isBioSequence?"0":"");if(JU.PT.isDigit(l)){m=JS.SmilesParser.getDigits(c,m,h);l=h[0];if(-2147483648==l)throw new JS.InvalidSmilesException("Non numeric atomic mass");"?"==JS.SmilesParser.getChar(c,m)&&(m++,l=-l);g.setAtomicMass(l)}else switch(l){case '"':l=JU.PT.getQuotedStringAt(c,m);m+=l.length+2;g.setAtomType(l);break;case "_":m=
JS.SmilesParser.getDigits(c,m+1,h)+1;if(-2147483648==h[0])throw new JS.InvalidSmilesException("Invalid SEARCH primitive: "+c.substring(m));g.iNested=h[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,h);g.jmolIndex=h[0];break;case "#":m=JS.SmilesParser.getDigits(c,m+1,h);g.elementNumber=h[0];break;case "-":case "+":m=this.checkCharge(c,m,g);break;case "@":a.haveAtomStereochemistry=!0;
m=this.checkChirality(c,m,a.patternAtoms[g.index]);break;default:var p=JS.SmilesParser.getChar(c,m+1),t=c.substring(m+1,m+(JU.PT.isLowerCase(p)&&(!f||!JU.PT.isDigit(JS.SmilesParser.getChar(c,m+2)))?2:1)),q=Character.toUpperCase(l)+t,r=!0;f&&JU.PT.isLetter(l)&&(!n&&(k?b:g).hasSymbol?r=!1:"H"==l?r=!JU.PT.isDigit(p)||"?"==JS.SmilesParser.getChar(c,m+2):0<="DdhRrvXx".indexOf(l)&&JU.PT.isDigit(p)?r=!1:!q.equals("A")&&!q.equals("Xx")&&(r=0<JU.Elements.elementNumberFromSymbol(q,!0),!r&&""!==t&&(t="",q=q.substring(0,
1),r=0<JU.Elements.elementNumberFromSymbol(q,!0))));if(r){if(!f&&!this.isSmarts&&!this.isBioSequence&&!JS.SmilesAtom.allowSmilesUnbracketed(q)||!g.setSymbol(q=l+t))throw new JS.InvalidSmilesException("Invalid atom symbol: "+q);k&&(b.hasSymbol=!0);m+=q.length}else switch(m=JS.SmilesParser.getDigits(c,m+1,h),p=h[0],l){default:throw new JS.InvalidSmilesException("Invalid SEARCH primitive: "+c.substring(m));case "D":g.setDegree(-2147483648==p?1:p);break;case "d":g.setNonhydrogenDegree(-2147483648==p?
1:p);break;case "H":w=-2147483648==p?1:p;break;case "h":g.setImplicitHydrogenCount(-2147483648==p?-1:p);break;case "R":-2147483648==p&&(p=-1);g.setRingMembership(p);a.top.needRingData=!0;break;case "r":if(-2147483648==p)p=-1,g.setRingMembership(p);else{g.setRingSize(p);switch(p){case 500:p=5;break;case 600:p=6}p>a.ringDataMax&&(a.ringDataMax=p)}a.top.needRingData=!0;break;case "v":g.setValence(-2147483648==p?1:p);break;case "X":g.setConnectivity(-2147483648==p?1:p);break;case "x":g.setRingConnectivity(-2147483648==
p?-1:p),a.top.needRingData=!0}}l=JS.SmilesParser.getChar(c,m);if(n&&"\x00"!=l)throw new JS.InvalidSmilesException("'!' may only involve one primitive.");}-2147483648==w&&f&&(w=-2147483647);g.setExplicitHydrogenCount(w);a.patternAtoms[g.index].setExplicitHydrogenCount(w)}null!=d&&0==e.order&&(g.notBondedIndex=d.index);null!=d&&0!=e.order&&(-1==e.order&&(e.order=this.isBioSequence&&j?112:this.isSmarts||d.isAromatic()&&g.isAromatic()?81:1),f||e.set2a(null,g),0==this.branchLevel&&(17==e.order||112==e.order)&&
this.branchLevel++);0==this.branchLevel&&(a.lastChainAtom=g);return g},"JS.SmilesSearch,JS.SmilesAtom,~S,JS.SmilesAtom,JS.SmilesBond,~B,~B,~B");h(c$,"parseRing",function(a,b,c,d){a=Integer.$valueOf(b);b=this.ringBonds.get(a);if(null==b)this.ringBonds.put(a,d);else{this.ringBonds.remove(a);switch(d.order){case -1:d.order=-1!=b.order?b.order:this.isSmarts||c.isAromatic()&&b.atom1.isAromatic()?81:1;break;case 257:d.order=513;break;case 513:d.order=257}if(-1!=b.order&&b.order!=d.order)throw new JS.InvalidSmilesException("Incoherent bond type for ring");
b.set(d);c.bondCount--;b.setAtom2(c)}},"JS.SmilesSearch,~N,JS.SmilesAtom,JS.SmilesBond");h(c$,"checkCharge",function(a,b,c){var d=a.length,e=a.charAt(b),f=1;++b;if(b<d){var k=a.charAt(b);if(JU.PT.isDigit(k)){if(d=v(1,0),b=JS.SmilesParser.getDigits(a,b,d),f=d[0],-2147483648==f)throw new JS.InvalidSmilesException("Non numeric charge");}else for(;b<d&&a.charAt(b)==e;)b++,f++}c.setCharge("+"==e?f:-f);return b},"~S,~N,JS.SmilesAtom");h(c$,"checkChirality",function(a,b,c){var d=0,e=-2147483648,f=a.length,
k,d=0,e=1;if(++b<f){switch(k=a.charAt(b)){case "@":e=2;b++;break;case "H":break;case "A":case "D":case "E":case "O":case "S":case "T":d=b+1<f?JS.SmilesAtom.getChiralityClass(a.substring(b,b+2)):-1;b+=2;break;default:e=JU.PT.isDigit(k)?1:-1}k=b;if(1==e){for(;k<f&&JU.PT.isDigit(a.charAt(k));)k++;if(k>b){try{e=Integer.parseInt(a.substring(b,k))}catch(j){if(H(j,NumberFormatException))e=-1;else throw j;}b=k}}if(1>e||0>d)throw new JS.InvalidSmilesException("Invalid stereochemistry descriptor");}c.setChiralClass(d);
c.setChiralOrder(e);"?"==JS.SmilesParser.getChar(a,b)&&(JU.Logger.info("Ignoring '?' in stereochemistry"),b++);return b},"~S,~N,JS.SmilesAtom");h(c$,"parseBond",function(a,b,c,d,e,f,k){var j=JS.SmilesParser.getChar(c,0);if("."==j){if(null!=d||null!=b)throw new JS.InvalidSmilesException("invalid '.'");this.isBioSequence="~"==JS.SmilesParser.getChar(c,1);return new JS.SmilesBond(null,null,0,!1)}if("+"==j&&null!=b)throw new JS.InvalidSmilesException("invalid '+'");d=null==b?null==d?new JS.SmilesBond(e,
null,this.isBioSequence&&null!=e?k?112:96:-1,!1):d:f?b.addPrimitive():b.addBondOr();if("\x00"!=j&&!this.checkLogic(a,c,null,d,e,f,!1)){if(f="!"==j)if(j=JS.SmilesParser.getChar(c,1),"\x00"==j||"!"==j)throw new JS.InvalidSmilesException("invalid '!'");c=JS.SmilesBond.getBondTypeFromCode(j);65==c&&(a.top.needRingMemberships=!0);if(null==e&&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:e.isAromatic()&&(a.top.needRingData=!0)}d.set2(c,f);this.isBioSequence&&null!=b&&b.set2(c,f)}return d},"JS.SmilesSearch,JS.SmilesBond,~S,JS.SmilesBond,JS.SmilesAtom,~B,~B");h(c$,"checkLogic",function(a,b,c,d,e,f,k){for(var j=b.indexOf(","),g=b.length;;){var h=0<j;if(h&&!this.isSmarts||0==j)break;var l="",j=b.indexOf(";");if(0<=j){if(!this.isSmarts||0==j)break;l="&"+b.substring(j+1);b=b.substring(0,j);h||(b+=l,l="")}var m=0;if(h)for(b+=
",";0<(j=b.indexOf(",",m))&&j<=g;){m=b.substring(m,j)+l;if(0==m.length)throw new JS.InvalidSmilesException("missing "+(null==d?"atom":"bond")+" token");null==d?this.parseAtom(a,c,m,null,null,!0,!1,k):this.parseBond(a,d,m,null,e,!1,!1);m=j+1}else if(0<=(j=b.indexOf("&"))||null!=d&&1<g&&!f){if(!this.isSmarts||0==j)break;if(null!=d&&0>j&&1<g){f=new JU.SB;for(h=0;h<g;){var n=b.charAt(h++);f.appendC(n);"!"!=n&&h<g&&f.appendC("&")}b=f.toString();g=b.length}for(b+="&";0<(j=b.indexOf("&",m))&&j<=g;)m=b.substring(m,
j)+l,null==d?this.parseAtom(a,c,m,null,null,!0,!0,k):this.parseBond(a,d,m,null,e,!0,!1),m=j+1}else return!1;return!0}n=b.charAt(j);throw new JS.InvalidSmilesException((this.isSmarts?"invalid placement for '"+n+"'":"["+n+"] notation only valid with SMARTS, not SMILES,")+" in "+b);},"JS.SmilesSearch,~S,JS.SmilesAtom,JS.SmilesBond,JS.SmilesAtom,~B,~B");c$.getSubPattern=h(c$,"getSubPattern",function(a,b,c){var d,e=1;switch(c){case "[":d="]";break;case '"':case "%":d=c;break;case "(":d=")";break;default:d=
c,e=0}for(var f=a.length,h=1,j=b+1;j<f;j++){var g=a.charAt(j);if(g==d){if(h--,0==h)return a.substring(b+e,j+1-e)}else g==c&&h++}throw new JS.InvalidSmilesException("Unmatched "+c);},"~S,~N,~S");c$.getChar=h(c$,"getChar",function(a,b){return b<a.length?a.charAt(b):"\x00"},"~S,~N");c$.getDigits=h(c$,"getDigits",function(a,b,c){for(var d=b,e=a.length;d<e&&JU.PT.isDigit(a.charAt(d));)d++;try{c[0]=Integer.parseInt(a.substring(b,d))}catch(f){if(H(f,NumberFormatException))c[0]=-2147483648;else throw f;}return d},
"~S,~N,~A");c$.skipTo=h(c$,"skipTo",function(a,b,c){for(var d;(d=JS.SmilesParser.getChar(a,++b))!=c&&"\x00"!=d;);return"\x00"==d?-1:b},"~S,~N,~S");c$.getRingPointer=h(c$,"getRingPointer",function(a){return 10>a?""+a:100>a?"%"+a:"%("+a+")"},"~N");c$.cleanPattern=h(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")});
B("JS");E(["JS.JmolSmilesExtension"],"JS.SmilesExt","java.lang.Float JU.AU $.BS $.Lst $.M4 $.Measure $.P3 J.api.Interface JM.BondSet JU.BSUtil $.Logger".split(" "),function(){c$=G(function(){this.sm=this.e=null;F(this,arguments)},JS,"SmilesExt",null,JS.JmolSmilesExtension);M(c$,function(){});n(c$,"init",function(a){this.e=a;this.sm=this.e.vwr.getSmilesMatcher();return this},"~O");n(c$,"getSmilesCorrelation",function(a,b,c,d,e,f,h,j,g,n,l,m,s){var w=null==n?0.1:3.4028235E38;try{null==d&&(d=new JU.Lst,
e=new JU.Lst);var p=new JU.M4,t=new JU.P3,q=this.e.vwr.ms.at,r=this.e.vwr.ms.ac,z=this.sm.getCorrelationMaps(c,q,r,a,j,!0);null==z&&this.e.evalError(this.sm.getLastException(),null);if(0==z.length)return NaN;var x=z[0];for(a=0;a<x.length;a++)d.addLast(q[x[a]]);z=this.sm.getCorrelationMaps(c,q,r,b,j,m);null==z&&this.e.evalError(this.sm.getLastException(),null);if(0==z.length)return NaN;JU.Logger.info(z.length+" mappings found");if(s||!g){b=3.4028235E38;c=null;for(a=0;a<z.length;a++){e.clear();for(var A=
0;A<z[a].length;A++)e.addLast(q[z[a][A]]);J.api.Interface.getInterface("JU.Eigen",this.e.vwr,"script");var u=JU.Measure.getTransformMatrix4(d,e,p,t);JU.Logger.info("getSmilesCorrelation stddev="+u);if(null!=h&&u<w){for(var y=new JU.BS,A=0;A<z[a].length;A++)y.set(z[a][A]);h.addLast(y)}u<b&&(c=z[a],null!=f&&f.setM4(p),null!=l&&l.setT(t),b=u)}null!=n&&(n[0]=x,n[1]=c);e.clear();for(a=0;a<c.length;a++)e.addLast(q[c[a]]);return b}for(a=0;a<z.length;a++)for(A=0;A<z[a].length;A++)e.addLast(q[z[a][A]])}catch(v){if(H(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,~B,~A,JU.P3,~B,~B");n(c$,"getSmilesMatches",function(a,b,c,d,e,f){if(0==a.length||a.equals("H"))try{return this.e.vwr.getSmilesOpt(c,0,0,a.equals("H"),!f,!1,!0,!0)}catch(h){if(H(h,Exception))this.e.evalError(h.getMessage(),null);else throw h;}var j=!0,g;if(null==d){j=null==b;try{g=j?this.sm.getSubstructureSetArray(a,this.e.vwr.ms.at,this.e.vwr.ms.ac,c,null,e,!1):this.sm.find(a,b,
e,!1)}catch(n){if(H(n,Exception))return this.e.evalError(n.getMessage(),null),null;throw n;}}else{g=new JU.Lst;a=this.getSmilesCorrelation(d,c,a,null,null,null,g,e,!1,null,null,!1,!1);if(Float.isNaN(a))return f?new JU.BS:[];this.e.showString("RMSD "+a+" Angstroms");g=g.toArray(Array(g.size()))}if(f){f=new JU.BS;for(a=0;a<g.length;a++)f.or(g[a]);if(j)return f;if(!e)return Integer.$valueOf(f.cardinality());e=v(f.cardinality(),0);j=0;for(g=f.nextSetBit(0);0<=g;g=f.nextSetBit(g+1))e[j++]=g+1;return e}if(!j)for(a=
0;a<g.length;a++)g[a]=JU.BSUtil.copy2(g[a],new JM.BondSet);e=new JU.Lst;for(a=0;a<g.length;a++)e.addLast(g[a]);return e},"~S,~S,JU.BS,JU.BS,~B,~B");n(c$,"getFlexFitList",function(a,b,c,d){var e=JU.AU.newInt2(2);this.getSmilesCorrelation(a,b,c,null,null,null,null,d,!1,e,null,!1,!1);if(null==e[0])return null;a=this.e.vwr.ms.getDihedralMap(e[0]);b=null==a?null:this.e.vwr.ms.getDihedralMap(e[1]);if(null==b||b.length!=a.length)return null;e=P(a.length,3,0);c=this.e.vwr.ms.at;JS.SmilesExt.getTorsions(c,
b,e,0);JS.SmilesExt.getTorsions(c,a,e,1);b=P(6*a.length,0);for(d=c=0;c<a.length;c++){var f=a[c];b[d++]=f[0];b[d++]=f[1];b[d++]=f[2];b[d++]=f[3];b[d++]=e[c][0];b[d++]=e[c][1]}return b},"JU.BS,JU.BS,~S,~B");c$.getTorsions=h(c$,"getTorsions",function(a,b,c,d){for(var e=b.length;0<=--e;){var f=b[e],f=JU.Measure.computeTorsion(a[f[0]],a[f[1]],a[f[2]],a[f[3]],!0);1==d&&(180<f-c[e][0]?f-=360:-180>=f-c[e][0]&&(f+=360));c[e][d]=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.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);
