package mapped;

import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSUserComparator6;

@ObfuscatedName("ey")
public class UserComparator6 extends AbstractUserComparator implements RSUserComparator6 {
   @ObfuscatedName("au")
   @ObfuscatedGetter(
      intValue = -655054217
   )
   static int field1464;
   @ObfuscatedName("at")
   final boolean reversed;

   public UserComparator6(boolean var1) {
      this.reversed = var1;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Lrh;Lrh;I)I",
      garbageValue = "-464829605"
   )
   int method3012(Buddy var1, Buddy var2) {
      return var1.world != 0 && var2.world != 0?(this.reversed?var1.method8171().method9958(var2.method8171()):var2.method8171().method9958(var1.method8171())):this.method8173(var1, var2);
   }

   public int compare(Object var1, Object var2) {
      return this.method3012((Buddy)var1, (Buddy)var2);
   }

   @ObfuscatedName("ai")
   @ObfuscatedSignature(
      descriptor = "(ILdt;ZB)I",
      garbageValue = "-32"
   )
   static int method3019(int var0, Script var1, boolean var2) {
      Widget var3;
      if(var0 != 1927 && var0 != 2927) {
         int var4;
         if(var0 == 1928) {
            var3 = var2?Interpreter.scriptDotWidget:HealthBar.scriptActiveWidget;
            var4 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
            if(var4 >= 1 && var4 <= 10) {
               class102 var9 = new class102(var4, var3.id, var3.childIndex, var3.itemId);
               Interpreter.field847.add(var9);
               return 1;
            } else {
               throw new RuntimeException();
            }
         } else if(var0 == 2928) {
            DbTableType.Interpreter_intStackSize -= 3;
            int var8 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize];
            var4 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize + 1];
            int var5 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize + 2];
            if(var5 >= 1 && var5 <= 10) {
               class102 var6 = new class102(var5, var8, var4, HealthBarDefinition.widgetDefinition.method6287(var8).itemId);
               Interpreter.field847.add(var6);
               return 1;
            } else {
               throw new RuntimeException();
            }
         } else {
            return 2;
         }
      } else if(Interpreter.field849 >= 10) {
         throw new RuntimeException();
      } else {
         if(var0 >= 2000) {
            var3 = HealthBarDefinition.widgetDefinition.method6287(Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize]);
         } else {
            var3 = var2?Interpreter.scriptDotWidget:HealthBar.scriptActiveWidget;
         }

         if(var3.onResize == null) {
            return 0;
         } else {
            ScriptEvent var7 = new ScriptEvent();
            var7.widget = var3;
            var7.args = var3.onResize;
            var7.field1063 = Interpreter.field849 + 1;
            Client.scriptEvents.method7233(var7);
            return 1;
         }
      }
   }
}
