/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.apache.tomcat.util.net.NioEndpoint
 *  org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper
 *  org.apache.tomcat.util.net.SecureNioChannel
 *  org.apache.tomcat.util.net.SocketBufferHandler
 */
package com.l7tech.server.tomcat.nio;

import com.l7tech.server.tomcat.TraceChannel;
import com.l7tech.server.tomcat.nio.SsgNioEndpoint;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import org.apache.tomcat.util.net.NioEndpoint;
import org.apache.tomcat.util.net.SecureNioChannel;
import org.apache.tomcat.util.net.SocketBufferHandler;

class b
extends SecureNioChannel {
    private TraceChannel a;
    private TraceChannel b;
    private static final String[] c;

    b(SsgNioEndpoint ssgNioEndpoint, SocketBufferHandler socketBufferHandler, NioEndpoint nioEndpoint) {
        super(socketBufferHandler, nioEndpoint);
    }

    public void reset(SocketChannel socketChannel, NioEndpoint.NioSocketWrapper nioSocketWrapper) throws IOException {
        super.reset(socketChannel, nioSocketWrapper);
        String[] stringArray = c;
        this.a = new TraceChannel(stringArray[1], true);
        this.b = new TraceChannel(stringArray[0], true);
    }

    public void close() throws IOException {
        this.a.close();
        this.b.close();
        super.close();
    }

    public int read(ByteBuffer byteBuffer) throws IOException {
        return this.a.trace(byteBuffer, byteBuffer.position(), super.read(byteBuffer));
    }

    public long read(ByteBuffer[] byteBufferArray) throws IOException {
        return this.read(byteBufferArray, 0, byteBufferArray.length);
    }

    public long read(ByteBuffer[] byteBufferArray, int n2, int n3) throws IOException {
        try {
            if (this.a.traceEnabled()) {
                return this.a.trace(byteBufferArray, n2, n3, this.a.positions(byteBufferArray), super.read(byteBufferArray, n2, n3));
            }
        }
        catch (IOException iOException) {
            throw com.l7tech.server.tomcat.nio.b.a(iOException);
        }
        return super.read(byteBufferArray, n2, n3);
    }

    public int write(ByteBuffer byteBuffer) throws IOException {
        return this.b.trace(byteBuffer, byteBuffer.position(), super.write(byteBuffer));
    }

    public long write(ByteBuffer[] byteBufferArray) throws IOException {
        return this.write(byteBufferArray, 0, byteBufferArray.length);
    }

    public long write(ByteBuffer[] byteBufferArray, int n2, int n3) throws IOException {
        try {
            if (this.b.traceEnabled()) {
                return this.b.trace(byteBufferArray, n2, n3, this.b.positions(byteBufferArray), super.write(byteBufferArray, n2, n3));
            }
        }
        catch (IOException iOException) {
            throw com.l7tech.server.tomcat.nio.b.a(iOException);
        }
        return super.write(byteBufferArray, n2, n3);
    }

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

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "N\u0005>\bj_GS\u0005@\tN\u0005>\bj_AH{";
        int n3 = "N\u0005>\bj_GS\u0005@\tN\u0005>\bj_AH{".length();
        int n4 = 10;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = com.l7tech.server.tomcat.nio.b.a(31, com.l7tech.server.tomcat.nio.b.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x37);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 57;
                    case 1 -> 110;
                    case 2 -> 85;
                    case 3 -> 103;
                    case 4 -> 6;
                    case 5 -> 109;
                    default -> 55;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

