package mapped;

import java.util.HashMap;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;

@ObfuscatedName("os")
public class class381 {
   @ObfuscatedName("at")
   final HashMap spriteMap;
   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "Lrv;"
   )
   Bounds bounds;
   @ObfuscatedName("ar")
   int[] field4385;
   @ObfuscatedName("ao")
   int[] field4386;
   @ObfuscatedName("ab")
   @ObfuscatedGetter(
      intValue = -1596078923
   )
   int field4388;

   public class381() {
      this.spriteMap = new HashMap();
      this.bounds = new Bounds(0, 0);
      this.field4385 = new int[2048];
      this.field4386 = new int[2048];
      this.field4388 = 0;
      class162.method3451_base();
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "-18604685"
   )
   void method7157_base(int var1) {
      int var2 = var1 * 2 + 1;
      double[] var3 = class384.method7186_base(0.0D, (double)((float)var1 / 3.0F), var1);
      double var4 = var3[var1] * var3[var1];
      int[] var6 = new int[var2 * var2];
      boolean var7 = false;

      for(int var8 = 0; var8 < var2; ++var8) {
         for(int var9 = 0; var9 < var2; ++var9) {
            int var10 = var6[var9 + var2 * var8] = (int)(256.0D * (var3[var9] * var3[var8] / var4));
            if(!var7 && var10 > 0) {
               var7 = true;
            }
         }
      }

      SpritePixels var11 = new SpritePixels(var6, var2, var2);
      this.spriteMap.put(Integer.valueOf(var1), var11);
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(II)Luz;",
      garbageValue = "1127436045"
   )
   SpritePixels method7177(int var1) {
      if(!this.spriteMap.containsKey(Integer.valueOf(var1))) {
         this.method7157_base(var1);
      }

      return (SpritePixels)this.spriteMap.get(Integer.valueOf(var1));
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(III)V",
      garbageValue = "-1542973383"
   )
   public final void method7159_base(int var1, int var2) {
      if(this.field4388 < this.field4385.length) {
         this.field4385[this.field4388] = var1;
         this.field4386[this.field4388] = var2;
         ++this.field4388;
      }
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(S)V",
      garbageValue = "-26946"
   )
   public final void method7163_base() {
      this.field4388 = 0;
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(IILuz;FB)V",
      garbageValue = "127"
   )
   public final void method7162(int var1, int var2, SpritePixels var3, float var4) {
      int var5 = (int)(var4 * 18.0F);
      SpritePixels var6 = this.method7177(var5);
      int var7 = var5 * 2 + 1;
      Bounds var8 = new Bounds(0, 0, var3.subWidth, var3.subHeight);
      Bounds var9 = new Bounds(0, 0);
      this.bounds.setHigh_base(var7, var7);
      System.nanoTime();

      int var10;
      int var11;
      int var12;
      for(var10 = 0; var10 < this.field4388; ++var10) {
         var11 = this.field4385[var10];
         var12 = this.field4386[var10];
         int var13 = (int)((float)(var11 - var1) * var4) - var5;
         int var14 = (int)((float)var3.subHeight - (float)(var12 - var2) * var4) - var5;
         this.bounds.setLow_base(var13, var14);
         this.bounds.method8377(var8, var9);
         this.method7163(var6, var3, var9);
      }

      System.nanoTime();
      System.nanoTime();

      for(var10 = 0; var10 < var3.pixels.length; ++var10) {
         if(var3.pixels[var10] == 0) {
            var3.pixels[var10] = -16777216;
         } else {
            var11 = (var3.pixels[var10] + 64 - 1) / 256;
            if(var11 <= 0) {
               var3.pixels[var10] = -16777216;
            } else {
               if(var11 > ChatChannel.field996.length) {
                  var11 = ChatChannel.field996.length;
               }

               var12 = ChatChannel.field996[var11 - 1];
               var3.pixels[var10] = -16777216 | var12;
            }
         }
      }

      System.nanoTime();
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(Luz;Luz;Lrv;I)V",
      garbageValue = "-1645913083"
   )
   void method7163(SpritePixels var1, SpritePixels var2, Bounds var3) {
      if(var3.highX != 0 && var3.highY != 0) {
         int var4 = 0;
         int var5 = 0;
         if(var3.lowX == 0) {
            var4 = var1.subWidth - var3.highX;
         }

         if(var3.lowY == 0) {
            var5 = var1.subHeight - var3.highY;
         }

         int var6 = var4 + var5 * var1.subWidth;
         int var7 = var3.lowX + var2.subWidth * var3.lowY;

         for(int var8 = 0; var8 < var3.highY; ++var8) {
            for(int var9 = 0; var9 < var3.highX; ++var9) {
               int var10001 = var7++;
               var2.pixels[var10001] += var1.pixels[var6++];
            }

            var6 += var1.subWidth - var3.highX;
            var7 += var2.subWidth - var3.highX;
         }

      }
   }
}
