Jmol.Console={buttons:{},buttonWidth:100,click:function(a){Jmol.Console.buttons[a].console.appletConsole.doAction(Jmol.Console.buttons[a])}};
Jmol.Console.JSConsole=function(a){this.applet=a.viewer.applet;var c=this.id=this.applet._id+"_console",b=this;Jmol.Console.buttons[b.id]=b;b.appletConsole=a;b.input=a.input=new Jmol.Console.Input(b);b.output=a.output=new Jmol.Console.Output(b);var d,e=function(a,b){b.console=a;b.id=c+"_"+b.label.replace(/\s/g,"_");Jmol.Console.buttons[b.id]=b;return b.html()};d='
'.replace(/\$ID/g,
c);Jmol.$after("body",d);b.setContainer(Jmol.$("#"+c));b.setPosition();b.dragBind(!0);Jmol.$html(c+"_label1"," close");Jmol.$html(c+"_inputdiv",'');Jmol.$html(c+"_outputdiv",'');d=e(b,a.runButton)+e(b,a.loadButton)+e(b,a.clearInButton)+e(b,a.clearOutButton)+e(b,
a.historyButton)+e(b,a.stateButton);Jmol.$html(c+"_buttondiv",d);Jmol.$bind("#"+c+"_input","keypress",function(a){b.input.keyPressed(a)});Jmol.$bind("#"+c+"_input","keyup",function(a){b.input.keyReleased(a)});Jmol.$bind("#"+c+"_input","mousedown touchstart",function(){b.ignoreMouse=!0});Jmol.$bind("#"+c+"_output","mousedown touchstart",function(){b.ignoreMouse=!0});b.setButton=function(a){return new Jmol.Console.Button(this,a)};b.setVisible=function(a){a?this.container.show():this.container.hide();
this.dragBind(a)};b.setTitle=function(){}};Jmol._setDraggable(Jmol.Console.JSConsole);
Jmol.Console.Input=function(a){this.console=a;this.id=a.id+"_input";this.getText=function(){return Jmol.$val(this.id)};this.setText=function(a){null==a&&(a="");Jmol.$val(this.id,a)};this.keyPressed=function(a){var b=a.which,d=a.ctrlKey;13==b&&(b=10);var e=this.console.appletConsole.processKey(b,401,d);d&&10==b&&this.setText(this.getText()+"\n");if(9==a.keyCode||9==b){var f=this;setTimeout(function(){f.setText(f.getText()+"\t");Jmol.$focus(f.id)},10)}(1==(e&1)||0==b)&&a.preventDefault()};this.keyReleased=
function(a){var b=a.which,d=a.ctrlKey;13==b&&(b=10);38==b||40==b?(this.keyPressed(a),a.preventDefault()):1==(this.console.appletConsole.processKey(b,402,d)&1)&&a.preventDefault()};this.getCaretPosition=function(){var a=Jmol.$get(this.id)[0];if("selectionStart"in a)return a.selectionStart;if(!("selection"in document))return 0;a.focus();var b=document.selection.createRange(),d=document.selection.createRange().text.length;b.moveStart("character",-a.value.length);return b.text.length-d}};
Jmol.Console.Output=function(a){this.id=a.id+"_output";this.getText=function(){return Jmol.$val(this.id)};this.setText=function(a){null==a&&(a="");Jmol.$val(this.id,a)};this.append=function(a){this.setText(this.getText()+a);Jmol.$scrollTo(this.id,-1)}};Jmol.Console.Button=function(a){this.label=a};Jmol.Console.Button.prototype.addConsoleListener=function(a){this.appletConsole=a;Jmol.Console.buttons[this.id]=this};
Jmol.Console.Button.prototype.html=function(){return'"};Clazz.declarePackage("J.api");Clazz.declareInterface(J.api,"JmolAppConsoleInterface");Clazz.declarePackage("J.console");Clazz.declareInterface(J.console,"GenericTextArea");Clazz.declarePackage("J.console");
Clazz.load(["J.api.JmolAppConsoleInterface","$.JmolCallbackListener","java.util.Hashtable"],"J.console.GenericConsole","java.lang.Boolean JU.PT J.constant.EnumCallback J.i18n.GT J.script.T J.viewer.Viewer".split(" "),function(){c$=Clazz.decorateAsClass(function(){this.label1=this.defaultMessage=this.loadButton=this.clearInButton=this.clearOutButton=this.stateButton=this.historyButton=this.runButton=this.editButton=this.menuMap=this.labels=this.viewer=this.output=this.input=null;this.nTab=0;this.incompleteCmd=
null;Clazz.instantialize(this,arguments)},J.console,"GenericConsole",null,[J.api.JmolAppConsoleInterface,J.api.JmolCallbackListener]);Clazz.prepareFields(c$,function(){this.menuMap=new java.util.Hashtable});$_M(c$,"setViewer",function(a){this.viewer=a},"J.api.JmolViewer");$_M(c$,"addButton",function(a,c){a.addConsoleListener(this);this.menuMap.put(c,a);return a},"J.api.JmolAbstractButton,~S");$_M(c$,"getLabel1",function(){return null});$_M(c$,"setupLabels",function(){this.labels.put("help",J.i18n.GT._("&Help"));
this.labels.put("search",J.i18n.GT._("&Search..."));this.labels.put("commands",J.i18n.GT._("&Commands"));this.labels.put("functions",J.i18n.GT._("Math &Functions"));this.labels.put("parameters",J.i18n.GT._("Set &Parameters"));this.labels.put("more",J.i18n.GT._("&More"));this.labels.put("Editor",J.i18n.GT._("Editor"));this.labels.put("State",J.i18n.GT._("State"));this.labels.put("Run",J.i18n.GT._("Run"));this.labels.put("Clear Output",J.i18n.GT._("Clear Output"));this.labels.put("Clear Input",J.i18n.GT._("Clear Input"));
this.labels.put("History",J.i18n.GT._("History"));this.labels.put("Load",J.i18n.GT._("Load"));this.labels.put("label1",J.i18n.GT._("press CTRL-ENTER for new line or paste model data and press Load"));this.labels.put("default",J.i18n.GT._("Messages will appear here. Enter commands in the box below. Click the console Help menu item for on-line help, which will appear in a new browser window."))});$_M(c$,"setLabels",function(){var a=J.i18n.GT.setDoTranslate(!0);this.editButton=this.setButton("Editor");
this.stateButton=this.setButton("State");this.runButton=this.setButton("Run");this.clearOutButton=this.setButton("Clear Output");this.clearInButton=this.setButton("Clear Input");this.historyButton=this.setButton("History");this.loadButton=this.setButton("Load");this.defaultMessage=this.getLabel("default");this.setTitle();J.i18n.GT.setDoTranslate(!1);this.defaultMessage=this.getLabel("default").split("Click")[0];J.i18n.GT.setDoTranslate(a);this.defaultMessage=this.getLabel("default")});$_M(c$,"getLabel",
function(a){null==this.labels&&(this.labels=new java.util.Hashtable,this.labels.put("title",J.i18n.GT._("Jmol Script Console")+" "+J.viewer.Viewer.getJmolVersion()),this.setupLabels());return this.labels.get(a)},"~S");$_M(c$,"displayConsole",function(){this.layoutWindow(null);this.outputMsg(this.defaultMessage)});$_M(c$,"updateLabels",function(){});$_M(c$,"completeCommand",function(a){if(0==a.length)return null;var c=0>=this.nTab||null==this.incompleteCmd?a:this.incompleteCmd;this.incompleteCmd=c;
a=J.console.GenericConsole.splitCommandLine(a);if(null==a)return null;var b=null==a[2],d=null!=a[3],e=a[b?1:2],f=a[1];if(0==e.length)return null;a=J.script.T.getTokenFromName(f.trim());var j=null==a?0:a.tok,h=J.script.T.tokAttr(j,12288);a=J.console.GenericConsole.splitCommandLine(c);var g=null;if(!b&&('"'==e.charAt(0)||"'"==e.charAt(0)))b=e.charAt(0),JU.PT.trim(e,"\"'"),e=JU.PT.trim(a[2],"\"'"),g=this.nextFileName(e,this.nTab),null!=g&&(g=a[0]+a[1]+b+g+b);else{g=null;if(!b&&(e=f,d||a[2].startsWith("$")||
J.script.T.isIDcmd(j)||h))g=new java.util.Hashtable,this.viewer.getObjectMap(g,d||h?"{":a[2].startsWith("$")?"$":"0");g=J.script.T.completeCommand(g,f.equalsIgnoreCase("set "),b,b?a[1]:a[2],this.nTab);g=a[0]+(null==g?e:b?g:a[1]+g)}return null==g||g.equals(c)?null:g},"~S");$_M(c$,"doAction",function(a){if(a===this.runButton)this.execute(null);else if(a===this.editButton)this.viewer.getProperty("DATA_API","scriptEditor",null);else if(a===this.historyButton)this.clearContent(this.viewer.getSetHistory(2147483647));
else if(a===this.stateButton)this.clearContent(this.viewer.getStateInfo());else if(a===this.clearInButton){this.input.setText("");return}a===this.clearOutButton?this.output.setText(""):a===this.loadButton?this.viewer.loadInlineAppend(this.input.getText(),!1):this.isMenuItem(a)&&this.execute(a.getName())},"~O");$_M(c$,"execute",function(a){var c=null==a?this.input.getText():a;null==a&&this.input.setText(null);a=this.viewer.script(c+"\u0001## EDITOR_IGNORE ##");null!=a&&!a.equals("pending")&&this.outputMsg(a)},
"~S");$_M(c$,"destroyConsole",function(){this.viewer.isApplet()&&this.viewer.getProperty("DATA_API","getAppConsole",Boolean.FALSE)});c$.setAbstractButtonLabels=$_M(c$,"setAbstractButtonLabels",function(a,c){for(var b,d=a.keySet().iterator();d.hasNext()&&((b=d.next())||1);){var e=a.get(b),f=c.get(b);if(b.indexOf("Tip")==b.length-3)e.setToolTipText(c.get(b));else{var j=J.console.GenericConsole.getMnemonic(f);" "!=j&&e.setMnemonic(j);f=J.console.GenericConsole.getLabelWithoutMnemonic(f);e.setText(f)}}},
"java.util.Map,java.util.Map");c$.getLabelWithoutMnemonic=$_M(c$,"getLabelWithoutMnemonic",function(a){if(null==a)return null;var c=a.indexOf("&");return-1==c?a:a.substring(0,c)+(cf?h:f);c[2]=h==j?null:a.substring(h);c[3]=0