/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.policy.assertion.ext.message.CustomJsonData
 *  com.l7tech.policy.assertion.ext.message.format.CustomMessageFormat
 *  com.l7tech.policy.assertion.ext.message.format.CustomMessageFormatFactory
 *  com.l7tech.policy.assertion.ext.message.format.NoSuchMessageFormatException
 *  org.jetbrains.annotations.NotNull
 */
package com.l7tech.server.custom.format;

import com.l7tech.policy.assertion.ext.message.CustomJsonData;
import com.l7tech.policy.assertion.ext.message.format.CustomMessageFormat;
import com.l7tech.policy.assertion.ext.message.format.CustomMessageFormatFactory;
import com.l7tech.policy.assertion.ext.message.format.NoSuchMessageFormatException;
import com.l7tech.server.custom.format.CustomMessageFormatRegistry;
import java.io.InputStream;
import java.util.Collection;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;

public class CustomMessageFormatFactoryImpl
implements CustomMessageFormatFactory {
    public static final String XML_FORMAT_DESC;
    public static final String JSON_FORMAT_DESC;
    public static final String INPUT_STREAM_FORMAT_DESC;
    private final CustomMessageFormatRegistry a;
    private static final String[] b;

    public CustomMessageFormatRegistry getCustomMessageFormatRegistry() {
        return this.a;
    }

    protected CustomMessageFormatFactoryImpl(@NotNull CustomMessageFormatRegistry customMessageFormatRegistry) {
        if (customMessageFormatRegistry == null) {
            CustomMessageFormatFactoryImpl.a(0);
        }
        this.a = customMessageFormatRegistry;
    }

    public Collection<CustomMessageFormat> getKnownFormats() {
        return this.a.getKnownFormats();
    }

    public <T> CustomMessageFormat<T> getFormat(Class<T> clazz) throws NoSuchMessageFormatException {
        try {
            if (clazz == null) {
                throw new NoSuchMessageFormatException(clazz, b[5]);
            }
        }
        catch (NoSuchMessageFormatException noSuchMessageFormatException) {
            throw CustomMessageFormatFactoryImpl.a(noSuchMessageFormatException);
        }
        CustomMessageFormat<T> customMessageFormat = this.getCustomMessageFormatRegistry().get(clazz);
        try {
            if (customMessageFormat != null) {
                return customMessageFormat;
            }
        }
        catch (NoSuchMessageFormatException noSuchMessageFormatException) {
            throw CustomMessageFormatFactoryImpl.a(noSuchMessageFormatException);
        }
        throw new NoSuchMessageFormatException(clazz);
    }

    public CustomMessageFormat getFormatByName(String string) throws NoSuchMessageFormatException {
        try {
            if (string == null) {
                throw new NoSuchMessageFormatException(string, b[3]);
            }
        }
        catch (NoSuchMessageFormatException noSuchMessageFormatException) {
            throw CustomMessageFormatFactoryImpl.a(noSuchMessageFormatException);
        }
        CustomMessageFormat customMessageFormat = this.getCustomMessageFormatRegistry().getForName(string);
        try {
            if (customMessageFormat != null) {
                return customMessageFormat;
            }
        }
        catch (NoSuchMessageFormatException noSuchMessageFormatException) {
            throw CustomMessageFormatFactoryImpl.a(noSuchMessageFormatException);
        }
        throw new NoSuchMessageFormatException(string);
    }

    public CustomMessageFormat<Document> getXmlFormat() throws NoSuchMessageFormatException {
        return this.getFormat(Document.class);
    }

    public CustomMessageFormat<CustomJsonData> getJsonFormat() throws NoSuchMessageFormatException {
        return this.getFormat(CustomJsonData.class);
    }

    public CustomMessageFormat<InputStream> getStreamFormat() throws NoSuchMessageFormatException {
        return this.getFormat(InputStream.class);
    }

    private static /* synthetic */ void a(int n2) {
        String[] stringArray = b;
        throw new IllegalArgumentException(String.format(stringArray[8], stringArray[0], stringArray[2], stringArray[1]));
    }

    private static NoSuchMessageFormatException a(NoSuchMessageFormatException noSuchMessageFormatException) {
        return noSuchMessageFormatException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "}\u000eQGu]Z{\bQR}UQq\tORnbry\u0012QGhI\u0006\"\u0012LZn\u000e>}\u0014O\u001cv\u0007c{\u0018J\u001ciUeh\u001eP\u001cyEdj\u0014O\u001c|_es\u001aV\u001cYEdj\u0014O~\u007fCd\u007f\u001cGuuBz\u007f\u000fdRyDxl\u0002k^j\\\u0013X\u0014P^{D7p\u001aOV:Yd>\u0015W_v\"W\u0015RFn\u0010Dj\tGRw\u0010Tk\bV\\w\u0010Z{\bQR}U7X\u0014P^{D\u001dL\u001eRA\u007fCrp\u000fCGs_y>8NRiC7w\b\u0002]o\\{0\u0019Z4o\u0013YEdj\u0014O\u0013WUdm\u001aEV:vxl\u0016CG";
                var4_3 = "}\u000eQGu]Z{\bQR}UQq\tORnbry\u0012QGhI\u0006\"\u0012LZn\u000e>}\u0014O\u001cv\u0007c{\u0018J\u001ciUeh\u001eP\u001cyEdj\u0014O\u001c|_es\u001aV\u001cYEdj\u0014O~\u007fCd\u007f\u001cGuuBz\u007f\u000fdRyDxl\u0002k^j\\\u0013X\u0014P^{D7p\u001aOV:Yd>\u0015W_v\"W\u0015RFn\u0010Dj\tGRw\u0010Tk\bV\\w\u0010Z{\bQR}U7X\u0014P^{D\u001dL\u001eRA\u007fCrp\u000fCGs_y>8NRiC7w\b\u0002]o\\{0\u0019Z4o\u0013YEdj\u0014O\u0013WUdm\u001aEV:vxl\u0016CG".length();
                var1_4 = 27;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = CustomMessageFormatFactoryImpl.a(v0, CustomMessageFormatFactoryImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "!]\u0018\bO\u0006\u0017\u0018z8+O\b\u0007\u0018}6!\ne$\u0004|:'\u001b>*|03\u0002 \f\u001f.1)\u001de\"%a#\b\u001a)\u000eK~64\u000e(\u0007\u001fk%fH`\u0011L.8 O`\u0011E+$f\u00020\u0011\u001f.9)\u001be\u0000\u000e.93\u0003)";
                    var4_3 = "!]\u0018\bO\u0006\u0017\u0018z8+O\b\u0007\u0018}6!\ne$\u0004|:'\u001b>*|03\u0002 \f\u001f.1)\u001de\"%a#\b\u001a)\u000eK~64\u000e(\u0007\u001fk%fH`\u0011L.8 O`\u0011E+$f\u00020\u0011\u001f.9)\u001be\u0000\u000e.93\u0003)".length();
                    var1_4 = 26;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 82;
                        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++] = CustomMessageFormatFactoryImpl.a(v0, CustomMessageFormatFactoryImpl.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;
            }
        }
        CustomMessageFormatFactoryImpl.b = var5;
        CustomMessageFormatFactoryImpl.XML_FORMAT_DESC = CustomMessageFormatFactoryImpl.b[6];
        CustomMessageFormatFactoryImpl.INPUT_STREAM_FORMAT_DESC = CustomMessageFormatFactoryImpl.b[4];
        CustomMessageFormatFactoryImpl.JSON_FORMAT_DESC = CustomMessageFormatFactoryImpl.b[7];
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x30);
        }
        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 -> 57;
                    case 1 -> 92;
                    case 2 -> 5;
                    case 3 -> 20;
                    case 4 -> 61;
                    case 5 -> 23;
                    default -> 48;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

