import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import javax.swing.undo.UndoManager;
import java.awt.datatransfer.StringSelection;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;
import net.coobird.thumbnailator.Thumbnailator;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import javax.swing.border.*;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.text.*;
class main {
static boolean transpileRaw_silent;
static String transpileRaw(String mainJava) {
return (String) call(dm_transpiler(), "transpileRaw", mainJava);
}
static class JavaEval extends DynPrintLog {
String expression;
transient boolean calculating;
transient Object value;
transient JTextField tfInput;
transient Throwable error;
JComponent visualize() {
return northAndCenterWithMargins(
centerAndEastWithMarginInbetween(
tfInput = onEnter(jtextfield(expression), runnableThread(new Runnable() { public void run() { try { evalIt();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "evalIt();"; }})),
hstackWithSpacing(
jbutton("Fresh", runnableThread(new Runnable() { public void run() { try { refresh(); evalIt() ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "refresh(); evalIt()"; }})),
jbutton("Eval", runnableThread(new Runnable() { public void run() { try { evalIt();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "evalIt();"; }})))),
super.visualize());
}
void refresh() {
call(dm_transpiler(), "refresh");
print("Refreshed translator.");
}
void evalIt() {
if (calculating) return;
calculating = true;
AutoCloseable __2 = tempAfterwards(new Runnable() { public void run() { try { calculating = false ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "calculating = false"; }}); try {
dm_javaEvalModule_doIt(gtt(tfInput));
} finally { _close(__2); }}
}
static A call(Object o) {
return (A) callF(o);
}
// varargs assignment fixer for a single string array argument
static A call(Object o, String method, String[] arg) {
return call(o, method, new Object[] {arg});
}
static A call(Object o, String method, Object... args) {
return (A) call_cached(o, method, args);
}
static Object dm_transpiler() {
return dm_getModule(dm_requireModule("#1017065/Transpiler"));
}
static JPanel northAndCenterWithMargins(Component n, Component c) {
return applyDefaultMargin(northAndCenter(withBottomMargin(n), c));
}
static JPanel centerAndEastWithMarginInbetween(Component c, final Component e) {
return centerAndEast(c, withLeftMargin(e));
}
static JTextField onEnter(final JTextField tf, final Object action) {
if (action == null || tf == null) return tf;
tf.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent _evt) { try {
tf.selectAll();
callF(action);
} catch (Throwable __e) { messageBox(__e); }}});
return tf;
}
static JButton onEnter(JButton btn, final Object action) {
if (action == null || btn == null) return btn;
btn.addActionListener(actionListener(action));
return btn;
}
static JList onEnter(JList list, Object action) {
list.addKeyListener(enterKeyListener(rCallOnSelectedListItem(list, action)));
return list;
}
static JComboBox onEnter(final JComboBox cb, final Object action) {
{ swing(new Runnable() { public void run() { try {
if (cb.isEditable()) {
JTextField text = (JTextField) cb.getEditor().getEditorComponent();
onEnter(text, action);
} else {
cb.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "enter");
cb.getActionMap().put("enter", abstractAction("", new Runnable() { public void run() { try { cb.hidePopup(); callF(action);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "cb.hidePopup(); callF(action);"; }}));
}
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (cb.isEditable()) {\r\n JTextField text = (JTextField) cb.getEditor().g..."; }}); }
return cb;
}
static JTable onEnter(final JTable table, final Object action) {
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
table.getActionMap().put("Enter", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
callF(action, table.getSelectedRow());
}
});
return table;
}
/*static JTextArea onEnter(final JTextArea ta, fO action) {
addKeyListener(ta, enterKeyListener(action));
ret ta;
}*/
static JTextField onEnter(Object action, JTextField tf) {
return onEnter(tf, action);
}
static JTextField jtextfield() {
return jTextField();
}
static JTextField jtextfield(String text) {
return jTextField(text);
}
static JTextField jtextfield(Object o) {
return jTextField(o);
}
static Runnable runnableThread(final Runnable r) {
return new Runnable() { public void run() { try { startThread(r) ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "startThread(r)"; }};
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static int hstackWithSpacing_spacing = 10;
// first part can be spacing value
static JPanel hstackWithSpacing(Object... parts) {
parts = flattenArray2(parts); // allow collections in parameters
int spacing = hstackWithSpacing_spacing;
int i = 0;
if (first(parts) instanceof Integer) {
spacing = toInt(first(parts));
++i;
}
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.weighty = 1;
gbc.fill = GridBagConstraints.VERTICAL;
gbc.gridheight = GridBagConstraints.REMAINDER;
for (; i < l(parts); i++) {
if (i != 0)
panel.add(javax.swing.Box.createRigidArea(new Dimension(spacing, 0)), gbc);
panel.add(wrapForSmartAdd(parts[i]), gbc);
}
gbc.weightx = 1;
panel.add(jrigid(), gbc);
return panel;
}
static JButton jbutton(String text, Object action) {
return newButton(text, action);
}
// button without action
static JButton jbutton(String text) {
return newButton(text, null);
}
/*static JButton jbutton(BufferedImage img, O action) {
ret setButtonImage(img, jbutton("", action));
}*/
static JButton jbutton(Action action) {
return swingNu(JButton.class, action);
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
//static int print_maxLineLength = 0; // 0 = unset
static boolean print_silent; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal