package com.l7tech.message;

import com.l7tech.common.io.UncheckedIOException;
import com.l7tech.common.mime.ContentTypeHeader;
import com.l7tech.common.mime.NoSuchPartException;
import com.l7tech.common.mime.PartInfo;
import com.l7tech.common.mime.PartIterator;
import com.l7tech.util.ConfigFactory;
import java.io.IOException;
import java.io.InputStream;

class j implements MimeKnob {
   private final MimeKnob a;
   final XmlFacet this$0;
   private static final String b;

   public j(final XmlFacet param1, MimeKnob nullx) {
      this.this$0 = var1;
      if (nullx == null) {
         throw new NullPointerException();
      }

      this.a = nullx;
   }

   @Override
   public boolean isMultipart() {
      return this.a.isMultipart();
   }

   @Override
   public PartIterator getParts() throws IOException {
      return new l(this, this.a.getParts());
   }

   @Override
   public PartIterator iterator() {
      try {
         return this.getParts();
      } catch (IOException var2) {
         throw new UncheckedIOException(var2);
      }
   }

   @Override
   public PartInfo getPart(int var1) throws IOException, NoSuchPartException {
      try {
         if (var1 == 0) {
            return this.getFirstPart();
         }
      } catch (IOException var2) {
         throw a(var2);
      }

      return this.a.getPart(var1);
   }

   @Override
   public PartInfo getPartByContentId(String var1) throws IOException, NoSuchPartException {
      PartInfo var2 = this.a.getPartByContentId(var1);

      try {
         return var2.getPosition() == 0 ? this.getFirstPart() : var2;
      } catch (IOException var3) {
         throw a(var3);
      }
   }

   @Override
   public void setContentLengthLimit(long var1) throws IOException {
      this.a.setContentLengthLimit(var1);
   }

   @Override
   public long getContentLengthLimit() {
      return this.a.getContentLengthLimit();
   }

   @Override
   public ContentTypeHeader getOuterContentType() {
      return this.a.getOuterContentType();
   }

   @Override
   public void setOuterContentType(ContentTypeHeader var1) {
      this.a.setOuterContentType(var1);
   }

   @Override
   public long getContentLength() throws IOException {
      this.a();
      return this.a.getContentLength();
   }

   @Override
   public void setStreamValidatedPartsOnly() {
      this.a.setStreamValidatedPartsOnly();
   }

   @Override
   public InputStream getEntireMessageBodyAsInputStream() throws IOException, NoSuchPartException {
      this.a();
      return this.a.getEntireMessageBodyAsInputStream();
   }

   @Override
   public InputStream getEntireMessageBodyAsInputStream(boolean var1) throws IOException, NoSuchPartException {
      this.a();
      return this.a.getEntireMessageBodyAsInputStream(var1);
   }

   @Override
   public PartInfo getFirstPart() throws IOException {
      return new k(this, this.a.getFirstPart());
   }

   @Override
   public void setBufferingDisallowed(boolean var1) {
      this.a.setBufferingDisallowed(var1);
   }

   @Override
   public boolean isBufferingDisallowed() {
      return this.a.isBufferingDisallowed();
   }

   private void a() 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/message/j.this$0 Lcom/l7tech/message/XmlFacet;
      // 04: getfield com/l7tech/message/XmlFacet.e Z
      // 07: ifeq 0f
      // 0a: return
      // 0b: invokestatic com/l7tech/message/j.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 0e: athrow
      // 0f: aload 0
      // 10: getfield com/l7tech/message/j.this$0 Lcom/l7tech/message/XmlFacet;
      // 13: getfield com/l7tech/message/XmlFacet.d Lcom/l7tech/xml/DomElementCursor;
      // 16: ifnonnull 26
      // 19: aload 0
      // 1a: getfield com/l7tech/message/j.this$0 Lcom/l7tech/message/XmlFacet;
      // 1d: bipush 1
      // 1e: putfield com/l7tech/message/XmlFacet.e Z
      // 21: return
      // 22: invokestatic com/l7tech/message/j.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 25: athrow
      // 26: aload 0
      // 27: getfield com/l7tech/message/j.this$0 Lcom/l7tech/message/XmlFacet;
      // 2a: getfield com/l7tech/message/XmlFacet.d Lcom/l7tech/xml/DomElementCursor;
      // 2d: invokevirtual com/l7tech/xml/DomElementCursor.getDocument ()Lorg/w3c/dom/Document;
      // 30: invokestatic com/l7tech/common/io/XmlUtil.toRawByteArray (Lorg/w3c/dom/Node;)Lcom/l7tech/util/Triple;
      // 33: astore 1
      // 34: aload 0
      // 35: getfield com/l7tech/message/j.a Lcom/l7tech/message/MimeKnob;
      // 38: invokeinterface com/l7tech/message/MimeKnob.getFirstPart ()Lcom/l7tech/common/mime/PartInfo; 1
      // 3d: astore 2
      // 3e: aload 2
      // 3f: aload 1
      // 40: getfield com/l7tech/util/Triple.left Ljava/lang/Object;
      // 43: checkcast [B
      // 46: aload 1
      // 47: getfield com/l7tech/util/Triple.middle Ljava/lang/Object;
      // 4a: checkcast java/lang/Integer
      // 4d: invokevirtual java/lang/Integer.intValue ()I
      // 50: aload 1
      // 51: getfield com/l7tech/util/Triple.right Ljava/lang/Object;
      // 54: checkcast java/lang/Integer
      // 57: invokevirtual java/lang/Integer.intValue ()I
      // 5a: invokeinterface com/l7tech/common/mime/PartInfo.setBodyBytes ([BII)V 4
      // 5f: aload 2
      // 60: invokeinterface com/l7tech/common/mime/PartInfo.getContentType ()Lcom/l7tech/common/mime/ContentTypeHeader; 1
      // 65: astore 3
      // 66: aload 0
      // 67: invokevirtual com/l7tech/message/j.b ()Z
      // 6a: ifne 81
      // 6d: getstatic com/l7tech/util/Charsets.UTF8 Ljava/nio/charset/Charset;
      // 70: aload 3
      // 71: invokevirtual com/l7tech/common/mime/ContentTypeHeader.getEncoding ()Ljava/nio/charset/Charset;
      // 74: invokevirtual java/nio/charset/Charset.equals (Ljava/lang/Object;)Z
      // 77: ifne ab
      // 7a: goto 81
      // 7d: invokestatic com/l7tech/message/j.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 80: athrow
      // 81: aload 3
      // 82: getstatic com/l7tech/common/mime/ContentTypeHeader.SOAP_1_2_DEFAULT Lcom/l7tech/common/mime/ContentTypeHeader;
      // 85: invokevirtual com/l7tech/common/mime/ContentTypeHeader.matches (Lcom/l7tech/common/mime/ContentTypeHeader;)Z
      // 88: ifeq a2
      // 8b: goto 92
      // 8e: invokestatic com/l7tech/message/j.a (Ljava/io/IOException;)Ljava/io/IOException;
      // 91: athrow
      // 92: aload 2
      // 93: getstatic com/l7tech/common/mime/ContentTypeHeader.SOAP_1_2_DEFAULT Lcom/l7tech/common/mime/ContentTypeHeader;
      // 96: invokeinterface com/l7tech/common/mime/PartInfo.setContentType (Lcom/l7tech/common/mime/ContentTypeHeader;)V 2
      // 9b: goto ab
      // 9e: invokestatic com/l7tech/message/j.a (Ljava/io/IOException;)Ljava/io/IOException;
      // a1: athrow
      // a2: aload 2
      // a3: getstatic com/l7tech/common/mime/ContentTypeHeader.XML_DEFAULT Lcom/l7tech/common/mime/ContentTypeHeader;
      // a6: invokeinterface com/l7tech/common/mime/PartInfo.setContentType (Lcom/l7tech/common/mime/ContentTypeHeader;)V 2
      // ab: aload 0
      // ac: getfield com/l7tech/message/j.this$0 Lcom/l7tech/message/XmlFacet;
      // af: bipush 1
      // b0: putfield com/l7tech/message/XmlFacet.e Z
      // b3: return
      // try (0 -> 5): 5 java/io/IOException
      // try (7 -> 16): 16 java/io/IOException
      // try (44 -> 52): 53 java/io/IOException
      // try (47 -> 59): 60 java/io/IOException
      // try (55 -> 66): 66 java/io/IOException
   }

   private boolean b() {
      return ConfigFactory.getBooleanProperty(b, false);
   }

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

   static {
      String var10002 = a(92, a("Tza|bW\u0004Rvd|c\u0005\u0003Dtk7 8\u001d[Sm1k\u0014^Dpx\u0011a\u000e\u0004R{x\u0006w\u0010\u0015x{O=c\r\u0019C"));
      byte var10001 = -1;
      b = var10002;
   }

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

      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 -> 107;
            case 1 -> 73;
            case 2 -> 80;
            case 3 -> 14;
            case 4 -> 82;
            case 5 -> 60;
            default -> 44;
         });
      }

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