package com.l7tech.common.io;

import com.l7tech.util.ResourceUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

public class HexLoggingInputStream extends InputStream {
   private static final String a;
   private static final String b;
   private final HexLogger c;
   private final InputStream d;
   private static final String[] e;

   public HexLoggingInputStream(String var1, Logger var2, InputStream var3) {
      this(new HexLogger(var2, var1), var3);
   }

   @Override
   public int available() throws IOException {
      return this.d.available();
   }

   @Override
   public void close() throws IOException {
      try {
         this.d.close();
      } finally {
         ResourceUtils.closeQuietly(this.c);
      }
   }

   @Override
   public void mark(int var1) {
      this.d.mark(var1);
   }

   @Override
   public boolean markSupported() {
      return this.d.markSupported();
   }

   @Override
   public int read() throws IOException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 0
      // 01: getfield com/l7tech/common/io/HexLoggingInputStream.d Ljava/io/InputStream;
      // 04: invokevirtual java/io/InputStream.read ()I
      // 07: istore 1
      // 08: iload 1
      // 09: iflt 2f
      // 0c: aload 0
      // 0d: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ()Z
      // 10: ifeq 2f
      // 13: goto 1a
      // 16: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 19: athrow
      // 1a: aload 0
      // 1b: bipush 1
      // 1c: newarray 8
      // 1e: dup
      // 1f: bipush 0
      // 20: iload 1
      // 21: i2b
      // 22: bastore
      // 23: bipush 0
      // 24: bipush 1
      // 25: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ([BII)V
      // 28: goto 2f
      // 2b: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 2e: athrow
      // 2f: iload 1
      // 30: ireturn
      // try (4 -> 9): 10 java/io/IOException
      // try (6 -> 23): 24 java/io/IOException
   }

   @Override
   public int read(byte[] param1) throws IOException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 0
      // 01: getfield com/l7tech/common/io/HexLoggingInputStream.d Ljava/io/InputStream;
      // 04: aload 1
      // 05: invokevirtual java/io/InputStream.read ([B)I
      // 08: istore 2
      // 09: iload 2
      // 0a: ifle 29
      // 0d: aload 0
      // 0e: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ()Z
      // 11: ifeq 29
      // 14: goto 1b
      // 17: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 1a: athrow
      // 1b: aload 0
      // 1c: aload 1
      // 1d: bipush 0
      // 1e: iload 2
      // 1f: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ([BII)V
      // 22: goto 29
      // 25: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 28: athrow
      // 29: iload 2
      // 2a: ireturn
      // try (5 -> 10): 11 java/io/IOException
      // try (7 -> 18): 19 java/io/IOException
   }

   @Override
   public int read(byte[] param1, int param2, int param3) throws IOException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 0
      // 01: getfield com/l7tech/common/io/HexLoggingInputStream.d Ljava/io/InputStream;
      // 04: aload 1
      // 05: iload 2
      // 06: iload 3
      // 07: invokevirtual java/io/InputStream.read ([BII)I
      // 0a: istore 4
      // 0c: iload 4
      // 0e: ifle 2e
      // 11: aload 0
      // 12: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ()Z
      // 15: ifeq 2e
      // 18: goto 1f
      // 1b: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 1e: athrow
      // 1f: aload 0
      // 20: aload 1
      // 21: iload 2
      // 22: iload 4
      // 24: invokevirtual com/l7tech/common/io/HexLoggingInputStream.a ([BII)V
      // 27: goto 2e
      // 2a: invokestatic com/l7tech/common/io/HexLoggingInputStream.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 2d: athrow
      // 2e: iload 4
      // 30: ireturn
      // try (7 -> 12): 13 java/io/IOException
      // try (9 -> 20): 21 java/io/IOException
   }

   @Override
   public void reset() throws IOException {
      try {
         this.d.reset();
         if (this.a()) {
            this.a(e[1]);
         }
      } catch (IOException var1) {
         throw a(var1);
      }
   }

   @Override
   public long skip(long var1) throws IOException {
      long var3 = this.d.skip(var1);

      try {
         if (this.a()) {
            this.a(e[0], var3);
         }

         return var3;
      } catch (IOException var5) {
         throw a(var5);
      }
   }

   protected HexLoggingInputStream(HexLogger var1, InputStream var2) {
      this.c = var1;
      this.d = var2;
   }

   private boolean a() {
      return this.c.traceEnabled();
   }

   private void a(byte[] var1, int var2, int var3) throws IOException {
      this.c.trace(var1, var2, var3);
   }

   private void a(String var1, Object... var2) throws IOException {
      this.c.traceInfo(var1, var2);
   }

   private static IOException a(IOException var0) {
      return var0;
   }

   static {
      String[] var5 = new String[4];
      int var3 = 0;
      String var2 = "\u000b9lSj%&x)5^:\";,7v\f\u000b&wF{-b*7vFn";
      int var4 = "\u000b9lSj%&x)5^:\";,7v\f\u000b&wF{-b*7vFn".length();
      char var1 = 17;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 117;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = a(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     e = var5;
                     String[] var9 = e;
                     a = e[3];
                     b = var9[2];
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = "$\u0016C|E\n\tW\u0006\u001aq\u0015\r\u0014\u0003\u0018Y\f$\tXiT\u0002M\u0005\u0018YiA";
                  var4 = "$\u0016C|E\n\tW\u0006\u001aq\u0015\r\u0014\u0003\u0018Y\f$\tXiT\u0002M\u0005\u0018YiA".length();
                  var1 = 17;
                  var7 = -1;
            }

            var10000 = 90;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

   private static char[] a(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 55);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 45;
            case 1 -> 39;
            case 2 -> 112;
            case 3 -> 86;
            case 4 -> 111;
            case 5 -> 53;
            default -> 55;
         });
      }

      return new String(var10001).intern();
   }
}
