package com.l7tech.xml.xpath;

import com.l7tech.xml.ElementCursor;
import java.util.NoSuchElementException;
import net.sf.saxon.s9api.XdmItem;
import net.sf.saxon.s9api.XdmSequenceIterator;
import org.w3c.dom.Node;

class o implements XpathResultIterator {
   private XdmSequenceIterator a;
   private Node b;
   private Object c;
   private Node d;
   final n this$2;
   private static final String e;

   o(n var1) {
      this.this$2 = var1;
      this.a = this.this$2.this$1.val$result.iterator();
      this.b = null;
      this.c = new p(this);
      this.d = null;
   }

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

   @Override
   public void next(XpathResultNode var1) throws NoSuchElementException {
      this.b = this.a();
      var1.type = this.b.getNodeType();
      var1.localNameHaver = this.b.getLocalName();
      var1.prefixHaver = this.b.getPrefix();
      var1.nodeNameHaver = this.b.getNodeName();
      var1.nodeValueHaver = this.c;
   }

   private Node a() {
      Node var1;
      if (this.d != null) {
         var1 = this.d;
      } else {
         XdmItem var2 = this.a.next();
         var1 = DomCompiledXpath.a(var2);
      }

      try {
         this.d = null;
         if (!(var1 instanceof Node)) {
            throw new IllegalStateException(e + var1.getClass().getName());
         } else {
            return var1;
         }
      } catch (IllegalStateException var3) {
         throw a(var3);
      }
   }

   @Override
   public ElementCursor nextElementAsCursor() throws NoSuchElementException {
      // $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: invokevirtual com/l7tech/xml/xpath/o.a ()Lorg/w3c/dom/Node;
      // 04: astore 1
      // 05: aload 1
      // 06: invokeinterface org/w3c/dom/Node.getNodeType ()S 1
      // 0b: bipush 1
      // 0c: if_icmpeq 2c
      // 0f: aload 1
      // 10: invokeinterface org/w3c/dom/Node.getNodeType ()S 1
      // 15: bipush 9
      // 17: if_icmpeq 2c
      // 1a: goto 21
      // 1d: invokestatic com/l7tech/xml/xpath/o.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 20: athrow
      // 21: aload 0
      // 22: aload 1
      // 23: putfield com/l7tech/xml/xpath/o.d Lorg/w3c/dom/Node;
      // 26: aconst_null
      // 27: areturn
      // 28: invokestatic com/l7tech/xml/xpath/o.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 2b: athrow
      // 2c: aload 0
      // 2d: aload 1
      // 2e: putfield com/l7tech/xml/xpath/o.b Lorg/w3c/dom/Node;
      // 31: new com/l7tech/xml/DomElementCursor
      // 34: dup
      // 35: aload 1
      // 36: bipush 0
      // 37: invokespecial com/l7tech/xml/DomElementCursor.<init> (Lorg/w3c/dom/Node;Z)V
      // 3a: areturn
      // try (3 -> 11): 12 java/util/NoSuchElementException
      // try (7 -> 19): 19 java/util/NoSuchElementException
   }

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

   static {
      String var10002 = a(17, a("\\cF\u0015[SYn\"F\nTNR/p[\t@VN/lQ\u001ePI_{\"W\u0014VVOkgZZ[UT\"LQ\u001eP\u001aUmh[\u0019A\u001aUi\"J\u0003E_\u001a"));
      byte var10001 = -1;
      e = var10002;
   }

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

      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 -> 30;
            case 1 -> 19;
            case 2 -> 47;
            case 3 -> 107;
            case 4 -> 36;
            case 5 -> 43;
            default -> 43;
         });
      }

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