package com.l7tech.server;

import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityManager;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import java.util.ArrayList;
import java.util.List;

class b7 extends PeriodicVersionCheck {
   private final Class<? extends Entity> e;
   private List<Goid> f;
   private List<Character> g;
   final EntityVersionChecker this$0;
   private static final String i;

   private b7(EntityVersionChecker var1, EntityManager var2) throws FindException {
      super(var2);
      this.this$0 = var1;
      this.e = var2.getInterfaceClass();
   }

   boolean a(Entity var1) {
      return this.e.isInstance(var1);
   }

   boolean a(PersistentEntity var1, char var2) {
      boolean var3;
      if (var2 == 'D') {
         var3 = this.notifyDelete(var1.getGoid());
      } else {
         var3 = this.notifyUpdate(var1.getGoid(), var1.getVersion());
      }

      return var3;
   }

   @Override
   public void run() {
      this.f = new ArrayList<>();
      this.g = new ArrayList<>();
      super.run();
      this.a(this.e, this.f, this.g);
      this.f = null;
      this.g = null;
   }

   @Override
   protected void onDelete(Goid var1) {
      try {
         if (this.f != null) {
            this.f.add(var1);
            this.g.add('D');
         }
      } catch (IllegalArgumentException var2) {
         throw a(var2);
      }
   }

   @Override
   protected void onUpdate(PersistentEntity var1) {
      try {
         if (this.f != null) {
            this.f.add(var1.getGoid());
            this.g.add('U');
         }
      } catch (IllegalArgumentException var2) {
         throw a(var2);
      }
   }

   @Override
   protected void onCreate(PersistentEntity var1) {
      try {
         if (this.f != null) {
            this.f.add(var1.getGoid());
            this.g.add('C');
         }
      } catch (IllegalArgumentException var2) {
         throw a(var2);
      }
   }

   private void a(Class<? extends Entity> param1, List<Goid> param2, List<Character> param3) {
      // $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 2
      // 01: invokeinterface java/util/List.isEmpty ()Z 1
      // 06: ifne 8f
      // 09: aload 2
      // 0a: invokeinterface java/util/List.size ()I 1
      // 0f: aload 3
      // 10: invokeinterface java/util/List.size ()I 1
      // 15: if_icmpeq 2e
      // 18: goto 1f
      // 1b: invokestatic com/l7tech/server/b7.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 1e: athrow
      // 1f: new java/lang/IllegalArgumentException
      // 22: dup
      // 23: getstatic com/l7tech/server/b7.i Ljava/lang/String;
      // 26: invokespecial java/lang/IllegalArgumentException.<init> (Ljava/lang/String;)V
      // 29: athrow
      // 2a: invokestatic com/l7tech/server/b7.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 2d: athrow
      // 2e: aload 2
      // 2f: invokeinterface java/util/List.size ()I 1
      // 34: anewarray 27
      // 37: astore 4
      // 39: aload 2
      // 3a: invokeinterface java/util/List.size ()I 1
      // 3f: newarray 5
      // 41: astore 5
      // 43: bipush 0
      // 44: istore 6
      // 46: iload 6
      // 48: aload 4
      // 4a: arraylength
      // 4b: if_icmpge 7b
      // 4e: aload 4
      // 50: iload 6
      // 52: aload 2
      // 53: iload 6
      // 55: invokeinterface java/util/List.get (I)Ljava/lang/Object; 2
      // 5a: checkcast com/l7tech/objectmodel/Goid
      // 5d: aastore
      // 5e: aload 5
      // 60: iload 6
      // 62: aload 3
      // 63: iload 6
      // 65: invokeinterface java/util/List.get (I)Ljava/lang/Object; 2
      // 6a: checkcast java/lang/Character
      // 6d: invokevirtual java/lang/Character.charValue ()C
      // 70: castore
      // 71: iinc 6 1
      // 74: goto 46
      // 77: invokestatic com/l7tech/server/b7.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 7a: athrow
      // 7b: aload 0
      // 7c: getfield com/l7tech/server/b7.this$0 Lcom/l7tech/server/EntityVersionChecker;
      // 7f: new com/l7tech/server/event/EntityInvalidationEvent
      // 82: dup
      // 83: aload 0
      // 84: aload 1
      // 85: aload 4
      // 87: aload 5
      // 89: invokespecial com/l7tech/server/event/EntityInvalidationEvent.<init> (Ljava/lang/Object;Ljava/lang/Class;[Lcom/l7tech/objectmodel/Goid;[C)V
      // 8c: invokevirtual com/l7tech/server/EntityVersionChecker.a (Lcom/l7tech/server/event/EntityInvalidationEvent;)V
      // 8f: return
      // try (0 -> 8): 9 java/lang/IllegalArgumentException
      // try (3 -> 16): 16 java/lang/IllegalArgumentException
      // try (28 -> 49): 49 java/lang/IllegalArgumentException
   }

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

   static {
      String var10002 = b(120, b("\u0010ic=/q4\u001b h>|07\nssnmuz\u001aqr/c03\u0011 t'uu"));
      byte var10001 = -1;
      i = var10002;
   }

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

      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 -> 7;
            case 1 -> 120;
            case 2 -> 127;
            case 3 -> 54;
            case 4 -> 119;
            case 5 -> 104;
            default -> 34;
         });
      }

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