package mapped;

import net.runelite.api.ChatMessageType;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSFriendsChat;
import net.runelite.rs.api.RSMessage;
import net.runelite.rs.api.RSUsername;

@ObfuscatedName("co")
public class Message extends DualNode implements RSMessage {
   @ObfuscatedName("ev")
   @ObfuscatedSignature(
      descriptor = "Ldb;"
   )
   static MouseRecorder mouseRecorder;
   @ObfuscatedName("at")
   @ObfuscatedGetter(
      intValue = -649141539
   )
   int count;
   @ObfuscatedName("ah")
   @ObfuscatedGetter(
      intValue = -1710752709
   )
   int cycle;
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = 776749757
   )
   int type;
   @ObfuscatedName("ao")
   String sender;
   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "Lvj;"
   )
   Username senderUsername;
   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "Lrw;"
   )
   TriBool isFromFriend0;
   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "Lrw;"
   )
   TriBool isFromIgnored0;
   @ObfuscatedName("ac")
   String prefix;
   @ObfuscatedName("al")
   String text;
   public String runeLiteFormatMessage;
   public int rl$timestamp;

   Message(int var1, String var2, String var3, String var4) {
      this.isFromFriend0 = TriBool.TriBool_unknown;
      this.isFromIgnored0 = TriBool.TriBool_unknown;
      this.set_base(var1, var2, var3, var4);
      this.rl$$init();
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V",
      garbageValue = "2135051365"
   )
   void set_base(int var1, String var2, String var3, String var4) {
      int var5 = ++Messages.Messages_count - 1;
      this.count = var5;
      this.cycle = Client.cycle;
      this.type = var1;
      this.sender = var2;
      this.fillSenderUsername_base();
      this.prefix = var3;
      this.text = var4;
      this.clearIsFromFriend_base();
      this.clearIsFromIgnored_base();
      this.setMessage(var1, var2, var3, var4);
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "226988197"
   )
   void clearIsFromFriend_base() {
      this.isFromFriend0 = TriBool.TriBool_unknown;
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(S)Z",
      garbageValue = "-446"
   )
   final boolean isFromFriend_base() {
      if(this.isFromFriend0 == TriBool.TriBool_unknown) {
         this.fillIsFromFriend_base();
      }

      return this.isFromFriend0 == TriBool.TriBool_true;
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "-2127132249"
   )
   void fillIsFromFriend_base() {
      this.isFromFriend0 = class12.friendSystem.friendsList.method8182(this.senderUsername)?TriBool.TriBool_true:TriBool.TriBool_false;
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "71192355"
   )
   void clearIsFromIgnored_base() {
      this.isFromIgnored0 = TriBool.TriBool_unknown;
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(B)Z",
      garbageValue = "92"
   )
   final boolean isFromIgnored_base() {
      if(this.isFromIgnored0 == TriBool.TriBool_unknown) {
         this.fillIsFromIgnored_base();
      }

      return this.isFromIgnored0 == TriBool.TriBool_true;
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "-1277362161"
   )
   void fillIsFromIgnored_base() {
      this.isFromIgnored0 = class12.friendSystem.ignoreList.method8182(this.senderUsername)?TriBool.TriBool_true:TriBool.TriBool_false;
   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "1209997538"
   )
   final void fillSenderUsername_base() {
      if(this.sender != null) {
         this.senderUsername = new Username(UserComparator7.method2959_base(this.sender), class89.loginType);
      } else {
         this.senderUsername = null;
      }

   }

   public int getRSType() {
      return this.type;
   }

   public RSUsername getSenderUsername() {
      return this.senderUsername;
   }

   private void rl$$init() {
      this.rl$timestamp = (int)(System.currentTimeMillis() / 1000L);
   }

   public void setMessage(int var1, String var2, String var3, String var4) {
      this.runeLiteFormatMessage = null;
      this.rl$timestamp = (int)(System.currentTimeMillis() / 1000L);
   }

   public ChatMessageType getType() {
      return ChatMessageType.of(this.getRSType());
   }

   public String getRuneLiteFormatMessage() {
      return this.runeLiteFormatMessage;
   }

   public void setRuneLiteFormatMessage(String var1) {
      this.runeLiteFormatMessage = var1;
   }

   public int getTimestamp() {
      return this.rl$timestamp;
   }

   public void setTimestamp(int var1) {
      this.rl$timestamp = var1;
   }

   public boolean isFromClanMate() {
      RSFriendsChat var1 = SpriteMask.client.getFriendsChatManager();
      return var1 != null && var1.findByName(this.getSenderUsername()) != null;
   }

   public int getId() {
      return this.count;
   }

   public String getName() {
      return this.sender;
   }

   public void setName(String var1) {
      this.sender = var1;
   }

   public String getSender() {
      return this.prefix;
   }

   public void setSender(String var1) {
      this.prefix = var1;
   }

   public String getValue() {
      return this.text;
   }

   public void setValue(String var1) {
      this.text = var1;
   }

   public boolean isFromFriend() {
      return this.isFromFriend_base();
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(II)I",
      garbageValue = "1188584098"
   )
   static int Messages_getHistorySize_base(int var0) {
      ChatChannel var1 = (ChatChannel)Messages.Messages_channels.get(Integer.valueOf(var0));
      return var1 == null?0:var1.size_base();
   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/CharSequence;B)I",
      garbageValue = "11"
   )
   public static int method1245_base(CharSequence var0) {
      int var1 = var0.length();
      int var2 = 0;

      for(int var3 = 0; var3 < var1; ++var3) {
         var2 = (var2 << 5) - var2 + var0.charAt(var3);
      }

      return var2;
   }
}
