/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.log.SinkConfiguration
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.EntityHeader
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.SsgKeyHeader
 *  com.l7tech.util.Functions$BinaryThrows
 *  com.l7tech.util.Functions$TernaryThrows
 *  jakarta.inject.Inject
 *  org.jetbrains.annotations.NotNull
 */
package com.l7tech.server.search.processors;

import com.l7tech.gateway.common.log.SinkConfiguration;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.SsgKeyHeader;
import com.l7tech.server.EntityCrud;
import com.l7tech.server.search.exceptions.CannotReplaceDependenciesException;
import com.l7tech.server.search.exceptions.CannotRetrieveDependenciesException;
import com.l7tech.server.search.objects.Dependency;
import com.l7tech.server.search.processors.DefaultDependencyProcessor;
import com.l7tech.server.search.processors.DependencyFinder;
import com.l7tech.server.search.processors.DependencyProcessor;
import com.l7tech.server.search.processors.ad;
import com.l7tech.server.search.processors.ae;
import com.l7tech.server.search.processors.af;
import com.l7tech.server.search.processors.ag;
import com.l7tech.util.Functions;
import jakarta.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.NotNull;

/*
 * Exception performing whole class analysis ignored.
 */
public class LogSinkDependencyProcessor
extends DefaultDependencyProcessor<SinkConfiguration>
implements DependencyProcessor<SinkConfiguration> {
    @Inject
    private EntityCrud entityCrud;
    private static final String[] a;

    @Override
    @NotNull
    public List<Dependency> findDependencies(@NotNull SinkConfiguration sinkConfiguration, @NotNull DependencyFinder dependencyFinder) throws FindException, CannotRetrieveDependenciesException {
        List<Dependency> list;
        List<Dependency> list2;
        block14: {
            try {
                if (sinkConfiguration == null) {
                    LogSinkDependencyProcessor.b(0);
                }
            }
            catch (FindException findException) {
                throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
            }
            try {
                if (dependencyFinder == null) {
                    LogSinkDependencyProcessor.b(1);
                }
            }
            catch (FindException findException) {
                throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
            }
            list2 = super.findDependencies(sinkConfiguration, dependencyFinder);
            ad ad2 = new ad(this);
            try {
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[4], EntityType.SERVICE, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[3], EntityType.SSG_CONNECTOR, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[24], EntityType.EMAIL_LISTENER, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[14], EntityType.JMS_ENDPOINT, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[8], EntityType.POLICY, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[23], EntityType.FOLDER, ad2));
                list2.addAll(this.a(sinkConfiguration, dependencyFinder, a[9], EntityType.USER, new ae(this)));
                if (sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEYSTORE_ID) == null || sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEY_ALIAS) == null) break block14;
            }
            catch (FindException findException) {
                throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
            }
            Entity entity = this.entityCrud.find((EntityHeader)new SsgKeyHeader(null, Goid.parseGoid((String)sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEYSTORE_ID)), sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEY_ALIAS), ""));
            Dependency dependency = dependencyFinder.a(DependencyFinder.FindResults.create(entity, null));
            try {
                if (dependency != null) {
                    list2.add(dependency);
                }
            }
            catch (FindException findException) {
                throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
            }
        }
        try {
            list = list2;
            if (list == null) {
                LogSinkDependencyProcessor.b(2);
            }
        }
        catch (FindException findException) {
            throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
        }
        return list;
    }

    private List<Dependency> a(@NotNull SinkConfiguration sinkConfiguration, @NotNull DependencyFinder dependencyFinder, String string, EntityType entityType, Functions.BinaryThrows<EntityHeader, String, EntityType, CannotRetrieveDependenciesException> binaryThrows) throws FindException, CannotRetrieveDependenciesException {
        try {
            if (sinkConfiguration == null) {
                LogSinkDependencyProcessor.b(3);
            }
        }
        catch (FindException findException) {
            throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
        }
        try {
            if (dependencyFinder == null) {
                LogSinkDependencyProcessor.b(4);
            }
        }
        catch (FindException findException) {
            throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
        }
        ArrayList<Dependency> arrayList = new ArrayList<Dependency>();
        if (sinkConfiguration.getFilters().containsKey(string)) {
            for (String string2 : (List)sinkConfiguration.getFilters().get(string)) {
                Entity entity = this.entityCrud.find((EntityHeader)binaryThrows.call((Object)string2, (Object)entityType));
                Dependency dependency = dependencyFinder.a(DependencyFinder.FindResults.create(entity, null));
                try {
                    if (dependency == null) continue;
                    arrayList.add(dependency);
                }
                catch (FindException findException) {
                    throw LogSinkDependencyProcessor.a((Exception)((Object)findException));
                }
            }
        }
        return arrayList;
    }

    @Override
    public void replaceDependencies(@NotNull SinkConfiguration sinkConfiguration, @NotNull Map<EntityHeader, EntityHeader> map, @NotNull DependencyFinder dependencyFinder, boolean bl2) throws CannotReplaceDependenciesException {
        block12: {
            try {
                if (sinkConfiguration == null) {
                    LogSinkDependencyProcessor.b(5);
                }
            }
            catch (CannotReplaceDependenciesException cannotReplaceDependenciesException) {
                throw LogSinkDependencyProcessor.a(cannotReplaceDependenciesException);
            }
            try {
                if (map == null) {
                    LogSinkDependencyProcessor.b(6);
                }
            }
            catch (CannotReplaceDependenciesException cannotReplaceDependenciesException) {
                throw LogSinkDependencyProcessor.a(cannotReplaceDependenciesException);
            }
            try {
                if (dependencyFinder == null) {
                    LogSinkDependencyProcessor.b(7);
                }
            }
            catch (CannotReplaceDependenciesException cannotReplaceDependenciesException) {
                throw LogSinkDependencyProcessor.a(cannotReplaceDependenciesException);
            }
            super.replaceDependencies(sinkConfiguration, map, dependencyFinder, bl2);
            af af2 = new af(this);
            HashMap<String, List<String>> hashMap = new HashMap<String, List<String>>(sinkConfiguration.getFilters());
            try {
                this.a(hashMap, map, a[1], EntityType.SERVICE, af2);
                this.a(hashMap, map, a[12], EntityType.SSG_CONNECTOR, af2);
                this.a(hashMap, map, a[0], EntityType.EMAIL_LISTENER, af2);
                this.a(hashMap, map, a[7], EntityType.JMS_ENDPOINT, af2);
                this.a(hashMap, map, a[22], EntityType.POLICY, af2);
                this.a(hashMap, map, a[6], EntityType.FOLDER, af2);
                this.a(hashMap, map, a[20], EntityType.USER, new ag(this));
                sinkConfiguration.setFilters(hashMap);
                if (sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEYSTORE_ID) == null || sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEY_ALIAS) == null) break block12;
            }
            catch (CannotReplaceDependenciesException cannotReplaceDependenciesException) {
                throw LogSinkDependencyProcessor.a(cannotReplaceDependenciesException);
            }
            String string = sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEYSTORE_ID) + ":" + sinkConfiguration.getProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEY_ALIAS);
            EntityHeader entityHeader = new EntityHeader(string, EntityType.SSG_KEY_ENTRY, null, null);
            if (map.containsKey(entityHeader)) {
                SsgKeyHeader ssgKeyHeader = (SsgKeyHeader)map.get(entityHeader);
                sinkConfiguration.setProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEYSTORE_ID, ssgKeyHeader.getKeystoreId().toString());
                sinkConfiguration.setProperty(SinkConfiguration.PROP_SYSLOG_SSL_KEY_ALIAS, ssgKeyHeader.getAlias());
            }
        }
    }

    private void a(Map<String, List<String>> map, @NotNull Map<EntityHeader, EntityHeader> map2, String string, EntityType entityType, Functions.TernaryThrows<String, String, EntityType, Map<EntityHeader, EntityHeader>, CannotReplaceDependenciesException> ternaryThrows) throws CannotReplaceDependenciesException {
        try {
            if (map2 == null) {
                LogSinkDependencyProcessor.b(8);
            }
        }
        catch (CannotReplaceDependenciesException cannotReplaceDependenciesException) {
            throw LogSinkDependencyProcessor.a(cannotReplaceDependenciesException);
        }
        if (map.containsKey(string)) {
            List<String> list = map.get(string);
            ArrayList<String> arrayList = new ArrayList<String>();
            for (String string2 : list) {
                arrayList.add((String)ternaryThrows.call((Object)string2, (Object)entityType, map2));
            }
            map.put(string, arrayList);
        }
    }

    /*
     * Exception decompiling
     */
    private static /* synthetic */ void b(int var0) {
        /*
         * This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
         * 
         * org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [0[TRYBLOCK]], but top level block is 6[SWITCH]
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:435)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:484)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:736)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:850)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
         *     at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
         *     at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1050)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
         *     at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
         *     at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
         *     at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
         *     at org.benf.cfr.reader.Main.main(Main.java:54)
         */
        throw new IllegalStateException("Decompilation failed");
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[25];
                var3_1 = 0;
                var2_2 = "v\rG`\u001e>?z\u0013Rl\u001cv!>\tB\n`\u0005T\u007f\u001bp6>\tB\u000ft\u0005RM\u0017c6}\u0004Cg\u0011z6`\u000e\u007f\tU}\u0017}~c\u000fT}_z7\n`\u0005T\u007f\u001bp6>\tB\u0013a\u0005Ve\u0013p6W\u0005Vl\u001cw6}\u0003Ol\u0001\tu\u000fJm\u0017a~z\u0004\u000fy\rU$\u001ez g\u0005Hl\u0000>:w\tc\u000fJ`\u0011j~z\u0004\u0007f\u0013C{_z7\u0006u\tHm\u0017a*S.I}<f?\u007f@Kl\u0006{<w@\u0003z\\6 3\rSz\u00063=|\u0014\u0006{\u0017g&a\u000e\u0006g\u0007\u007f?\u000e\u007f\tU}\u0017}~c\u000fT}_z7\u0010u\tHm6v#v\u000eBl\u001cp:v\u0013\u000fy\rU$\u001ez g\u0005Hl\u0000>:w>p\u000fK&\u001e$'v\u0003N&\u0001v!e\u0005T&\u0001v2a\u0003N&\u0002a<p\u0005Uz\u001da <,In!z=x$Cy\u0017}7v\u000eEp\"a<p\u0005Uz\u001da>R\u0012A|\u001fv=g@@f\u00003\u0013]\u000fRG\u0007\u007f?3\u0010G{\u0013~6g\u0005T)U6 4@IoR6 =EU)\u001ff g@Hf\u000631v@H|\u001e\u007f\u0011`\tHb1|=u\tA|\u0000r'z\u000fH>p\u000fK&\u001e$'v\u0003N&\u0001v!e\u0005T&\u0001v2a\u0003N&\u0002a<p\u0005Uz\u001da <,In!z=x$Cy\u0017}7v\u000eEp\"a<p\u0005Uz\u001da\u0010u\tHm6v#v\u000eBl\u001cp:v\u0013\u0007f\u0013C{_z7\u000ea\u0005Ve\u0013p6~\u0005H}?r#\tc\u000fJ`\u0011j~z\u0004";
                var4_3 = "v\rG`\u001e>?z\u0013Rl\u001cv!>\tB\n`\u0005T\u007f\u001bp6>\tB\u000ft\u0005RM\u0017c6}\u0004Cg\u0011z6`\u000e\u007f\tU}\u0017}~c\u000fT}_z7\n`\u0005T\u007f\u001bp6>\tB\u0013a\u0005Ve\u0013p6W\u0005Vl\u001cw6}\u0003Ol\u0001\tu\u000fJm\u0017a~z\u0004\u000fy\rU$\u001ez g\u0005Hl\u0000>:w\tc\u000fJ`\u0011j~z\u0004\u0007f\u0013C{_z7\u0006u\tHm\u0017a*S.I}<f?\u007f@Kl\u0006{<w@\u0003z\\6 3\rSz\u00063=|\u0014\u0006{\u0017g&a\u000e\u0006g\u0007\u007f?\u000e\u007f\tU}\u0017}~c\u000fT}_z7\u0010u\tHm6v#v\u000eBl\u001cp:v\u0013\u000fy\rU$\u001ez g\u0005Hl\u0000>:w>p\u000fK&\u001e$'v\u0003N&\u0001v!e\u0005T&\u0001v2a\u0003N&\u0002a<p\u0005Uz\u001da <,In!z=x$Cy\u0017}7v\u000eEp\"a<p\u0005Uz\u001da>R\u0012A|\u001fv=g@@f\u00003\u0013]\u000fRG\u0007\u007f?3\u0010G{\u0013~6g\u0005T)U6 4@IoR6 =EU)\u001ff g@Hf\u000631v@H|\u001e\u007f\u0011`\tHb1|=u\tA|\u0000r'z\u000fH>p\u000fK&\u001e$'v\u0003N&\u0001v!e\u0005T&\u0001v2a\u0003N&\u0002a<p\u0005Uz\u001da <,In!z=x$Cy\u0017}7v\u000eEp\"a<p\u0005Uz\u001da\u0010u\tHm6v#v\u000eBl\u001cp:v\u0013\u0007f\u0013C{_z7\u000ea\u0005Ve\u0013p6~\u0005H}?r#\tc\u000fJ`\u0011j~z\u0004".length();
                var1_4 = 17;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = LogSinkDependencyProcessor.b(v0, LogSinkDependencyProcessor.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "B8}Z VIM3\u0011A:pW)\t\bM$e[+A\u0016\t>u";
                    var4_3 = "B8}Z VIM3\u0011A:pW)\t\bM$e[+A\u0016\t>u".length();
                    var1_4 = 9;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 48;
                        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++] = LogSinkDependencyProcessor.b(v0, LogSinkDependencyProcessor.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;
            }
        }
        LogSinkDependencyProcessor.a = var5;
    }

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 103;
                    case 2 -> 33;
                    case 3 -> 14;
                    case 4 -> 117;
                    case 5 -> 20;
                    default -> 84;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

