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 java.util.function.*;
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 java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;
import static x30_pkg.x30_util.DynamicObject;
import java.text.*;
import java.text.NumberFormat;
import java.util.TimeZone;
import java.awt.geom.*;
class main {
static void test_dataURLMimeType() {
testFunctionValues(url -> dataURLMimeType((String) url),
"data:image/png;base64,iVBORw0K...", "image/png",
"data:image/png,iVBORw0K...", "image/png",
null, null,
"bla", null,
"data:image/png", null);
}
// params = input, output, input, output, ...
static void testFunctionValues(IF1 function, Object... params) {
for (int i = 0; i+1 < l(params); i += 2) {
Object in = params[i], expected = params[i+1];
testFunctionValue(function, in, expected);
}
}
static String dataURLMimeType(String dataURL) {
if (!isDataURL(dataURL)) return null;
String s = dropPrefixOrNull("data:", dataURL);
if (s == null) return null;
int i = indexOfAny(s, ";,");
if (i < 0) return null;
return takeFirst(s, i);
}
static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(boolean[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(short[] a) { return a == null ? 0 : a.length; }
static int l(long[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(double[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Iterator i) { return iteratorCount_int_close(i); } // consumes the iterator && closes it if possible
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
static long l(File f) { return f == null ? 0 : f.length(); }
static int l(IMultiMap mm) { return mm == null ? 0 : mm.size(); }
static int l(IntSize o) { return o == null ? 0 : o.size(); }
// TODO: make work again for IF2 etc
static void testFunctionValue(IF1 function, A in, B expected) {
String what = print(renderFunctionCall(str(function), in));
assertEqualsVerbose(what, expected, function.get(in));
}
static boolean isDataURL(String url) {
return startsWith(url, "data:");
}
static String dropPrefixOrNull(String prefix, String s) {
return s != null && s.startsWith(prefix) ? s.substring(l(prefix)) : null;
}
static int indexOfAny(List l, int i, A... x) {
while (i < l(l))
if (eqOneOf(l.get(i), x)) return i; else ++i;
return -1;
}
static int indexOfAny(List l, Collection x) {
return indexOfAny(l, 0, x);
}
static int indexOfAny(List l, int i, Collection x) {
if (nempty(x))
while (i < l(l))
if (x.contains(l.get(i))) return i; else ++i;
return -1;
}
static int indexOfAny(String s, int i, String chars) {
for (; i < l(s); i++)
if (chars.indexOf(s.charAt(i)) >= 0)
return i;
return -1;
}
static int indexOfAny(String s, String chars) { return indexOfAny(s, 0, chars); }
static List takeFirst(List l, int n) {
return l(l) <= n ? l : newSubListOrSame(l, 0, n);
}
static List takeFirst(int n, List l) {
return takeFirst(l, n);
}
static String takeFirst(int n, String s) { return substring(s, 0, n); }
static String takeFirst(String s, int n) { return substring(s, 0, n); }
static CharSequence takeFirst(int n, CharSequence s) { return subCharSequence(s, 0, n); }
static List takeFirst(int n, Iterator it) {
if (it == null) return null;
List l = new ArrayList();
for (int _repeat_0 = 0; _repeat_0 < n; _repeat_0++) { if (it.hasNext()) l.add(it.next()); else break; }
return l;
}
static List takeFirst(int n, Iterable i) {
if (i == null) return null;
return i == null ? null : takeFirst(n, i.iterator());
}
static List takeFirst(int n, IterableIterator i) {
return takeFirst(n, (Iterator) i);
}
static int[] takeFirst(int n, int[] a) { return takeFirstOfIntArray(n, a); }
static short[] takeFirst(int n, short[] a) { return takeFirstOfShortArray(n, a); }
static byte[] takeFirst(int n, byte[] a) { return takeFirstOfByteArray(n, a); }
static byte[] takeFirst(byte[] a, int n) { return takeFirstOfByteArray(n, a); }
static double[] takeFirst(int n, double[] a) { return takeFirstOfDoubleArray(n, a); }
static double[] takeFirst(double[] a, int n) { return takeFirstOfDoubleArray(n, a); }
static int iteratorCount_int_close(Iterator i) { try {
int n = 0;
if (i != null) while (i.hasNext()) { i.next(); ++n; }
if (i instanceof AutoCloseable) ((AutoCloseable) i).close();
return n;
} catch (Exception __e) { throw rethrow(__e); } }
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static boolean printAlsoToSystemOut = true;
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 boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal