/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.IOUtils
 *  com.l7tech.util.ResourceUtils
 */
package com.l7tech.server.service;

import com.l7tech.server.service.GraphmanBundleProcessor;
import com.l7tech.server.service.e;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.IOUtils;
import com.l7tech.util.ResourceUtils;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.logging.Level;

class f {
    private final OutputStream a;
    private static final String[] b;

    public f(OutputStream outputStream) {
        this.a = outputStream;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void write(Set<e> set, String string) {
        try {
            for (e e10 : set) {
                String[] stringArray = b;
                GraphmanBundleProcessor.a.log(Level.FINE, stringArray[4], new Object[]{e10.getName(), e10.getFilename()});
                this.b(this.a, string);
                this.b(this.a, String.format(stringArray[3], e10.getName(), e10.getFilename()));
                this.b(this.a, stringArray[2] + String.valueOf(e10.getContentType()));
                this.a(this.a);
                this.a(this.a, e10.getInputStreamSupplier().get());
                this.a(this.a);
            }
            this.a(this.a, string + b[1]);
            this.a.flush();
        }
        catch (Exception exception) {
            GraphmanBundleProcessor.a.log(Level.WARNING, ExceptionUtils.getDebugException((Throwable)exception), () -> f.lambda$write$0(exception));
        }
        finally {
            ResourceUtils.closeQuietly((Closeable)this.a);
        }
    }

    private void a(OutputStream outputStream, String string) throws IOException {
        outputStream.write(string.getBytes(StandardCharsets.UTF_8));
    }

    private void b(OutputStream outputStream, String string) throws IOException {
        this.a(outputStream, string);
        outputStream.write(GraphmanBundleProcessor.b);
    }

    private void a(OutputStream outputStream) throws IOException {
        outputStream.write(GraphmanBundleProcessor.b);
    }

    private void a(OutputStream outputStream, InputStream inputStream) throws IOException {
        IOUtils.copyStream((InputStream)inputStream, (OutputStream)outputStream);
    }

    private static String lambda$write$0(Exception exception) {
        return b[0] + ExceptionUtils.getMessageWithCause((Throwable)exception);
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[5];
                var3_1 = 0;
                var2_2 = "\u000e4C\u001c2\u0002-%%^\u0006.V-9#US7J!'#\u0011\u00032G8*4X\u001d'\u0002%>*E\u001a0C:?fC\u00161W-82\u000bS\u0002fk\u000e\b)_\u0007%L<f\u0012H\u0003%\u0018h";
                var4_3 = "\u000e4C\u001c2\u0002-%%^\u0006.V-9#US7J!'#\u0011\u00032G8*4X\u001d'\u0002%>*E\u001a0C:?fC\u00161W-82\u000bS\u0002fk\u000e\b)_\u0007%L<f\u0012H\u0003%\u0018h".length();
                var1_4 = 53;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 95;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = f.a(v0, f.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "Rs\u0005]\u007f\u0016f<X\u0002Zj\u0017axh\u0002FtB2ws\u0019D7\u001cse}P\tt\u0019\u007ft!I\fiZ)1z\u0002E\u007f\u0016s|yV\u000b?\u000b0\u0015Fn\u0002]s\u0016u1l\n[nB2j,\u0016\u0006aIo";
                    var4_3 = "Rs\u0005]\u007f\u0016f<X\u0002Zj\u0017axh\u0002FtB2ws\u0019D7\u001cse}P\tt\u0019\u007ft!I\fiZ)1z\u0002E\u007f\u0016s|yV\u000b?\u000b0\u0015Fn\u0002]s\u0016u1l\n[nB2j,\u0016\u0006aIo".length();
                    var1_4 = 56;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 5;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = f.a(v0, f.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        f.b = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x17);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 20;
                    case 1 -> 25;
                    case 2 -> 110;
                    case 3 -> 44;
                    case 4 -> 31;
                    case 5 -> 125;
                    default -> 23;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

