package mapped;

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

@ObfuscatedName("tb")
public class DbTableType extends DualNode implements RSDbTableType {
   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "Lol;"
   )
   public static AbstractArchive field5074;
   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "Llk;"
   )
   public static EvictingDualNodeHashTable DBTableType_cache;
   @ObfuscatedName("al")
   @ObfuscatedGetter(
      intValue = 1206229207
   )
   static int Interpreter_intStackSize;
   @ObfuscatedName("ar")
   public int[][] types;
   @ObfuscatedName("ao")
   public Object[][] defaultValues;

   static {
      DBTableType_cache = new EvictingDualNodeHashTable(64);
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(Luj;I)V",
      garbageValue = "-2001833472"
   )
   void method9153(Buffer var1) {
      while(true) {
         int var2 = var1.readUnsignedByte_base();
         if(var2 == 0) {
            return;
         }

         this.method9154(var1, var2);
      }
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Luj;II)V",
      garbageValue = "268630673"
   )
   void method9154(Buffer var1, int var2) {
      if(var2 == 1) {
         int var3 = var1.readUnsignedByte_base();
         if(this.types == null) {
            this.types = new int[var3][];
         }

         for(int var4 = var1.readUnsignedByte_base(); var4 != 255; var4 = var1.readUnsignedByte_base()) {
            int var5 = var4 & 127;
            boolean var6 = (var4 & 128) != 0;
            int[] var7 = new int[var1.readUnsignedByte_base()];

            for(int var8 = 0; var8 < var7.length; ++var8) {
               var7[var8] = var1.readUShortSmart_base();
            }

            this.types[var5] = var7;
            if(var6) {
               if(this.defaultValues == null) {
                  this.defaultValues = new Object[this.types.length][];
               }

               Object[][] var17 = this.defaultValues;
               int var11 = var1.readUShortSmart_base();
               Object[] var12 = new Object[var7.length * var11];

               for(int var13 = 0; var13 < var11; ++var13) {
                  for(int var14 = 0; var14 < var7.length; ++var14) {
                     int var15 = var14 + var7.length * var13;
                     class514 var16 = class472.method8562_base(var7[var14]);
                     var12[var15] = var16.method9126(var1);
                  }
               }

               var17[var5] = var12;
            }
         }
      }

   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "-34"
   )
   void method9150_base() {
   }

   public int[][] getTypes() {
      return this.types;
   }

   public Object[][] getDefaultValues() {
      return this.defaultValues;
   }
}
