package mapped;

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

@ObfuscatedName("rw")
public class TriBool implements RSTriBool {
   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "Lrw;"
   )
   public static final TriBool TriBool_unknown;
   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "Lrw;"
   )
   public static final TriBool TriBool_true;
   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "Lrw;"
   )
   public static final TriBool TriBool_false;

   static {
      TriBool_unknown = new TriBool();
      TriBool_true = new TriBool();
      TriBool_false = new TriBool();
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(III)I",
      garbageValue = "-999239127"
   )
   static int method8281_base(int var0, int var1) {
      FloorOverlayDefinition var2 = Canvas.method333(var0);
      if(var2 == null) {
         return var1;
      } else {
         int var4;
         int var5;
         int var6;
         int var7;
         int var8;
         if(var2.secondaryRgb >= 0) {
            var4 = var2.secondaryHue;
            var5 = var2.secondarySaturation;
            var6 = var2.secondaryLightness;
            if(var6 > 179) {
               var5 /= 2;
            }

            if(var6 > 192) {
               var5 /= 2;
            }

            if(var6 > 217) {
               var5 /= 2;
            }

            if(var6 > 243) {
               var5 /= 2;
            }

            var7 = (var5 / 32 << 7) + var6 / 2 + (var4 / 4 << 10);
            var8 = UserComparator3.method2984_base(var7, 96);
            return Rasterizer3D.Rasterizer3D_colorPalette[var8] | -16777216;
         } else if(var2.texture >= 0) {
            int var3 = UserComparator3.method2984_base(Rasterizer3D.clips.Rasterizer3D_textureLoader.getAverageTextureRGB_base(var2.texture), 96);
            return Rasterizer3D.Rasterizer3D_colorPalette[var3] | -16777216;
         } else if(var2.primaryRgb == 16711935) {
            return var1;
         } else {
            var4 = var2.hue;
            var5 = var2.saturation;
            var6 = var2.lightness;
            if(var6 > 179) {
               var5 /= 2;
            }

            if(var6 > 192) {
               var5 /= 2;
            }

            if(var6 > 217) {
               var5 /= 2;
            }

            if(var6 > 243) {
               var5 /= 2;
            }

            var7 = (var5 / 32 << 7) + var6 / 2 + (var4 / 4 << 10);
            var8 = UserComparator3.method2984_base(var7, 96);
            return Rasterizer3D.Rasterizer3D_colorPalette[var8] | -16777216;
         }
      }
   }
}
