package mapped;

import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSUserComparator5;

@ObfuscatedName("et")
public class UserComparator5 extends AbstractUserComparator implements RSUserComparator5 {
   @ObfuscatedName("at")
   final boolean reversed;

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

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Lrh;Lrh;I)I",
      garbageValue = "-405710173"
   )
   int method2967(Buddy var1, Buddy var2) {
      if(var1.world != 0) {
         if(var2.world == 0) {
            return this.reversed?-1:1;
         }
      } else if(var2.world != 0) {
         return this.reversed?1:-1;
      }

      return this.method8173(var1, var2);
   }

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

   @ObfuscatedName("mm")
   @ObfuscatedSignature(
      descriptor = "([Lnn;IB)V",
      garbageValue = "58"
   )
   static final void method2971(Widget[] var0, int var1) {
      for(int var2 = 0; var2 < var0.length; ++var2) {
         Widget var3 = var0[var2];
         if(var3 != null) {
            if(var3.type == 0) {
               if(var3.children != null) {
                  method2971(var3.children, var1);
               }

               InterfaceParent var4 = (InterfaceParent)Client.interfaceParents.get((long)var3.id);
               if(var4 != null) {
                  class514.runIntfCloseListeners_base(var4.group, var1);
               }
            }

            ScriptEvent var5;
            if(var1 == 0 && var3.onDialogAbort != null) {
               var5 = new ScriptEvent();
               var5.widget = var3;
               var5.args = var3.onDialogAbort;
               class157.method3403(var5);
            }

            if(var1 == 1 && var3.onSubChange != null) {
               if(var3.childIndex >= 0) {
                  Widget var6 = HealthBarDefinition.widgetDefinition.method6287(var3.id);
                  if(var6 == null || var6.children == null || var3.childIndex >= var6.children.length || var3 != var6.children[var3.childIndex]) {
                     continue;
                  }
               }

               var5 = new ScriptEvent();
               var5.widget = var3;
               var5.args = var3.onSubChange;
               class157.method3403(var5);
            }
         }
      }

   }
}
