package com.l7tech.server.search.processors;

import com.l7tech.gateway.common.security.rbac.Role;
import com.l7tech.objectmodel.EntityHeader;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
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 jakarta.inject.Inject;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.NotNull;

public class RoleDependencyProcessor extends DefaultDependencyProcessor<Role> {
   @Inject
   private EntityCrud entityCrud;
   private static final String[] a;

   @NotNull
   public List<Dependency> findDependencies(@NotNull Role param1, @NotNull DependencyFinder param2) throws FindException, CannotRetrieveDependenciesException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 1
      // 01: ifnonnull 0f
      // 04: bipush 0
      // 05: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 08: goto 0f
      // 0b: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0e: athrow
      // 0f: aload 2
      // 10: ifnonnull 1e
      // 13: bipush 1
      // 14: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 17: goto 1e
      // 1a: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1d: athrow
      // 1e: aload 0
      // 1f: aload 1
      // 20: aload 2
      // 21: invokespecial com/l7tech/server/search/processors/DefaultDependencyProcessor.findDependencies (Ljava/lang/Object;Lcom/l7tech/server/search/processors/DependencyFinder;)Ljava/util/List;
      // 24: astore 3
      // 25: aload 1
      // 26: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityGoid ()Lcom/l7tech/objectmodel/Goid;
      // 29: ifnull 8e
      // 2c: aload 1
      // 2d: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 30: ifnull 8e
      // 33: goto 3a
      // 36: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 39: athrow
      // 3a: aload 1
      // 3b: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 3e: invokestatic com/l7tech/search/Dependency$DependencyType.hasDependencyType (Lcom/l7tech/objectmodel/EntityType;)Z
      // 41: ifeq 8e
      // 44: goto 4b
      // 47: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 4a: athrow
      // 4b: aload 0
      // 4c: getfield com/l7tech/server/search/processors/RoleDependencyProcessor.entityCrud Lcom/l7tech/server/EntityCrud;
      // 4f: aload 1
      // 50: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 53: invokevirtual com/l7tech/objectmodel/EntityType.getEntityClass ()Ljava/lang/Class;
      // 56: aload 1
      // 57: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityGoid ()Lcom/l7tech/objectmodel/Goid;
      // 5a: invokeinterface com/l7tech/server/EntityCrud.find (Ljava/lang/Class;Ljava/io/Serializable;)Lcom/l7tech/objectmodel/Entity; 3
      // 5f: new com/l7tech/objectmodel/EntityHeader
      // 62: dup
      // 63: aload 1
      // 64: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityGoid ()Lcom/l7tech/objectmodel/Goid;
      // 67: aload 1
      // 68: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 6b: aconst_null
      // 6c: aconst_null
      // 6d: invokespecial com/l7tech/objectmodel/EntityHeader.<init> (Lcom/l7tech/objectmodel/Goid;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;Ljava/lang/String;)V
      // 70: invokestatic com/l7tech/server/search/processors/DependencyFinder$FindResults.create (Ljava/lang/Object;Lcom/l7tech/objectmodel/EntityHeader;)Lcom/l7tech/server/search/processors/DependencyFinder$FindResults;
      // 73: astore 4
      // 75: aload 3
      // 76: aload 2
      // 77: aload 1
      // 78: aload 2
      // 79: bipush 1
      // 7a: anewarray 262
      // 7d: dup
      // 7e: bipush 0
      // 7f: aload 4
      // 81: aastore
      // 82: invokestatic java/util/Arrays.asList ([Ljava/lang/Object;)Ljava/util/List;
      // 85: invokevirtual com/l7tech/server/search/processors/DependencyFinder.getDependenciesFromObjects (Ljava/lang/Object;Lcom/l7tech/server/search/processors/DependencyFinder;Ljava/util/List;)Ljava/util/List;
      // 88: invokeinterface java/util/List.addAll (Ljava/util/Collection;)Z 2
      // 8d: pop
      // 8e: aload 3
      // 8f: dup
      // 90: ifnonnull 9e
      // 93: bipush 2
      // 94: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 97: goto 9e
      // 9a: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 9d: athrow
      // 9e: areturn
      // try (0 -> 4): 5 com/l7tech/objectmodel/FindException
      // try (7 -> 11): 12 com/l7tech/objectmodel/FindException
      // try (19 -> 25): 26 com/l7tech/objectmodel/FindException
      // try (22 -> 32): 33 com/l7tech/objectmodel/FindException
      // try (68 -> 73): 74 com/l7tech/objectmodel/FindException
   }

   public void replaceDependencies(@NotNull Role param1, @NotNull Map<EntityHeader, EntityHeader> param2, @NotNull DependencyFinder param3, boolean param4) throws CannotReplaceDependenciesException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 000: aload 1
      // 001: ifnonnull 00f
      // 004: bipush 3
      // 005: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 008: goto 00f
      // 00b: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 00e: athrow
      // 00f: aload 2
      // 010: ifnonnull 01e
      // 013: bipush 4
      // 014: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 017: goto 01e
      // 01a: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 01d: athrow
      // 01e: aload 3
      // 01f: ifnonnull 02d
      // 022: bipush 5
      // 023: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.b (I)V
      // 026: goto 02d
      // 029: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 02c: athrow
      // 02d: aload 0
      // 02e: aload 1
      // 02f: aload 2
      // 030: aload 3
      // 031: iload 4
      // 033: invokespecial com/l7tech/server/search/processors/DefaultDependencyProcessor.replaceDependencies (Ljava/lang/Object;Ljava/util/Map;Lcom/l7tech/server/search/processors/DependencyFinder;Z)V
      // 036: aload 1
      // 037: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityGoid ()Lcom/l7tech/objectmodel/Goid;
      // 03a: ifnull 09a
      // 03d: aload 1
      // 03e: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 041: ifnull 09a
      // 044: goto 04b
      // 047: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 04a: athrow
      // 04b: aload 1
      // 04c: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 04f: invokestatic com/l7tech/search/Dependency$DependencyType.hasDependencyType (Lcom/l7tech/objectmodel/EntityType;)Z
      // 052: ifeq 09a
      // 055: goto 05c
      // 058: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 05b: athrow
      // 05c: new com/l7tech/objectmodel/EntityHeader
      // 05f: dup
      // 060: aload 1
      // 061: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityGoid ()Lcom/l7tech/objectmodel/Goid;
      // 064: aload 1
      // 065: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getEntityType ()Lcom/l7tech/objectmodel/EntityType;
      // 068: aconst_null
      // 069: aconst_null
      // 06a: invokespecial com/l7tech/objectmodel/EntityHeader.<init> (Lcom/l7tech/objectmodel/Goid;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;Ljava/lang/String;)V
      // 06d: astore 5
      // 06f: aload 2
      // 070: aload 5
      // 072: invokeinterface java/util/Map.get (Ljava/lang/Object;)Ljava/lang/Object; 2
      // 077: checkcast com/l7tech/objectmodel/EntityHeader
      // 07a: astore 6
      // 07c: aload 6
      // 07e: ifnull 09a
      // 081: aload 1
      // 082: aload 6
      // 084: invokevirtual com/l7tech/objectmodel/EntityHeader.getGoid ()Lcom/l7tech/objectmodel/Goid;
      // 087: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setEntityGoid (Lcom/l7tech/objectmodel/Goid;)V
      // 08a: aload 1
      // 08b: aload 6
      // 08d: invokevirtual com/l7tech/objectmodel/EntityHeader.getType ()Lcom/l7tech/objectmodel/EntityType;
      // 090: invokevirtual com/l7tech/gateway/common/security/rbac/Role.setEntityType (Lcom/l7tech/objectmodel/EntityType;)V
      // 093: goto 09a
      // 096: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 099: athrow
      // 09a: aload 1
      // 09b: invokevirtual com/l7tech/gateway/common/security/rbac/Role.getRoleAssignments ()Ljava/util/Set;
      // 09e: invokeinterface java/util/Set.iterator ()Ljava/util/Iterator; 1
      // 0a3: astore 5
      // 0a5: aload 5
      // 0a7: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 0ac: ifeq 10e
      // 0af: aload 5
      // 0b1: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 0b6: checkcast com/l7tech/gateway/common/security/rbac/RoleAssignment
      // 0b9: astore 6
      // 0bb: new com/l7tech/objectmodel/IdentityHeader
      // 0be: dup
      // 0bf: aload 6
      // 0c1: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getProviderId ()Lcom/l7tech/objectmodel/Goid;
      // 0c4: aload 6
      // 0c6: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getIdentityId ()Ljava/lang/String;
      // 0c9: aload 0
      // 0ca: aload 6
      // 0cc: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.getEntityType ()Ljava/lang/String;
      // 0cf: invokevirtual com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/String;)Lcom/l7tech/objectmodel/EntityType;
      // 0d2: aconst_null
      // 0d3: aconst_null
      // 0d4: aconst_null
      // 0d5: bipush 0
      // 0d6: invokestatic java/lang/Integer.valueOf (I)Ljava/lang/Integer;
      // 0d9: invokespecial com/l7tech/objectmodel/IdentityHeader.<init> (Lcom/l7tech/objectmodel/Goid;Ljava/lang/String;Lcom/l7tech/objectmodel/EntityType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V
      // 0dc: astore 7
      // 0de: aload 2
      // 0df: aload 7
      // 0e1: invokeinterface java/util/Map.get (Ljava/lang/Object;)Ljava/lang/Object; 2
      // 0e6: checkcast com/l7tech/objectmodel/IdentityHeader
      // 0e9: astore 8
      // 0eb: aload 8
      // 0ed: ifnull 10b
      // 0f0: aload 6
      // 0f2: aload 8
      // 0f4: invokevirtual com/l7tech/objectmodel/IdentityHeader.getProviderGoid ()Lcom/l7tech/objectmodel/Goid;
      // 0f7: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.setProviderId (Lcom/l7tech/objectmodel/Goid;)V
      // 0fa: aload 6
      // 0fc: aload 8
      // 0fe: invokevirtual com/l7tech/objectmodel/IdentityHeader.getStrId ()Ljava/lang/String;
      // 101: invokevirtual com/l7tech/gateway/common/security/rbac/RoleAssignment.setIdentityId (Ljava/lang/String;)V
      // 104: goto 10b
      // 107: invokestatic com/l7tech/server/search/processors/RoleDependencyProcessor.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 10a: athrow
      // 10b: goto 0a5
      // 10e: return
      // try (0 -> 4): 5 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (7 -> 11): 12 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (14 -> 18): 19 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (21 -> 33): 34 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (30 -> 40): 41 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (58 -> 68): 69 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
      // try (104 -> 114): 115 com/l7tech/server/search/exceptions/CannotReplaceDependenciesException
   }

   private EntityType a(String var1) throws CannotReplaceDependenciesException {
      try {
         if (EntityType.USER.getName().equalsIgnoreCase(var1)) {
            return EntityType.USER;
         }
      } catch (CannotReplaceDependenciesException var6) {
         throw a(var6);
      }

      try {
         if (EntityType.GROUP.getName().equalsIgnoreCase(var1)) {
            return EntityType.GROUP;
         }
      } catch (CannotReplaceDependenciesException var7) {
         throw a(var7);
      }

      String var10004 = EntityType.USER.name();
      String var2 = EntityType.GROUP.name();
      String var3 = var10004;
      String var4 = var1;
      String[] var5 = a;
      throw new CannotReplaceDependenciesException(Role.class, var5[9] + var4 + var5[11] + var3 + var5[12] + var2 + "'");
   }

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

   static {
      String[] var5 = new String[13];
      int var3 = 0;
      String var2 = "0\u0016*6\u001f\u0016 6\u001a/6\u0000D&%\u001c56\u0000D5!\u001a/6\u0003S;0\u001c4j\u001cS'|+(u\u0016e1#\u001c)}\u0016O7*)5v\u0010D' \u00165\u00105\u0010)}7D$6\u0017#|\u001dB=6\n\u00065\u0010)}\u0016S\u0004!\u0016+|;0\u0016*6\u001f\u0016 6\u001a/6\u0000D&%\u001c56\u0000D5!\u001a/6\u0003S;0\u001c4j\u001cS'|+(u\u0016e1#\u001c)}\u0016O7*)5v\u0010D' \u00165>\u0012\u000b l\u001eD:'Y!v\u0001\u0001\u0014\u001d\u00163W\u0006M8s\t&k\u0012L1'\u001c59T\u0004'tY(\u007fS\u0004'}\\49\u001eT''Y)v\u0007\u000166Y)l\u001fM\u000e!\u001c7u\u0012B1>\u001c)m>@$\u0013!\u001c7u\u0012B1\u0017\u001c7|\u001dE1=\u001a.|\u0000*\u00137(m=T8?Y*|\u0007I;7Ybj]\u0004's\u00142j\u0007\u0001:<\rgk\u0016U!!\u0017gw\u0006M8\u001e\u0006\u0017,w\u001cV:s+(u\u0016\u00015 \n.~\u001dL1=\rgm\nQ1s^\u00105\u0010)}7D$6\u0017#|\u001dB=6\n";
      int var4 = "0\u0016*6\u001f\u0016 6\u001a/6\u0000D&%\u001c56\u0000D5!\u001a/6\u0003S;0\u001c4j\u001cS'|+(u\u0016e1#\u001c)}\u0016O7*)5v\u0010D' \u00165\u00105\u0010)}7D$6\u0017#|\u001dB=6\n\u00065\u0010)}\u0016S\u0004!\u0016+|;0\u0016*6\u001f\u0016 6\u001a/6\u0000D&%\u001c56\u0000D5!\u001a/6\u0003S;0\u001c4j\u001cS'|+(u\u0016e1#\u001c)}\u0016O7*)5v\u0010D' \u00165>\u0012\u000b l\u001eD:'Y!v\u0001\u0001\u0014\u001d\u00163W\u0006M8s\t&k\u0012L1'\u001c59T\u0004'tY(\u007fS\u0004'}\\49\u001eT''Y)v\u0007\u000166Y)l\u001fM\u000e!\u001c7u\u0012B1>\u001c)m>@$\u0013!\u001c7u\u0012B1\u0017\u001c7|\u001dE1=\u001a.|\u0000*\u00137(m=T8?Y*|\u0007I;7Ybj]\u0004's\u00142j\u0007\u0001:<\rgk\u0016U!!\u0017gw\u0006M8\u001e\u0006\u0017,w\u001cV:s+(u\u0016\u00015 \n.~\u001dL1=\rgm\nQ1s^\u00105\u0010)}7D$6\u0017#|\u001dB=6\n"
         .length();
      char var1 = ';';
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 63;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = b(var10000, c(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     a = var5;
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = "fEuN\u0019C#\"\u001f0oAV/5\u00030yA\u0014\u0006fK:yA\u0014";
                  var4 = "fEuN\u0019C#\"\u001f0oAV/5\u00030yA\u0014\u0006fK:yA\u0014".length();
                  var1 = 20;
                  var7 = -1;
            }

            var10000 = 45;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

   private static char[] c(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 107);
      }

      return var10000;
   }

   private static String b(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 108;
            case 1 -> 70;
            case 2 -> 120;
            case 3 -> 38;
            case 4 -> 76;
            case 5 -> 30;
            default -> 107;
         });
      }

      return new String(var10001).intern();
   }
}
