package g;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import javax.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public abstract class f0 implements Closeable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    @Nullable
    public Reader f6100b;

    public static final class a extends Reader {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final h.h f6101b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final Charset f6102c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public boolean f6103d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        @Nullable
        public Reader f6104e;

        public a(h.h hVar, Charset charset) {
            this.f6101b = hVar;
            this.f6102c = charset;
        }

        @Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws IOException {
            this.f6103d = true;
            Reader reader = this.f6104e;
            if (reader != null) {
                reader.close();
            } else {
                this.f6101b.close();
            }
        }

        @Override // java.io.Reader
        public int read(char[] cArr, int i2, int i3) throws IOException {
            if (this.f6103d) {
                throw new IOException("Stream closed");
            }
            Reader inputStreamReader = this.f6104e;
            if (inputStreamReader == null) {
                h.h hVar = this.f6101b;
                Charset charset = this.f6102c;
                if (hVar.G(0L, g.i0.c.f6143d)) {
                    hVar.l(r2.k());
                    charset = g.i0.c.f6148i;
                } else {
                    if (hVar.G(0L, g.i0.c.f6144e)) {
                        hVar.l(r2.k());
                        charset = g.i0.c.f6149j;
                    } else {
                        if (hVar.G(0L, g.i0.c.f6145f)) {
                            hVar.l(r2.k());
                            charset = g.i0.c.k;
                        } else {
                            if (hVar.G(0L, g.i0.c.f6146g)) {
                                hVar.l(r2.k());
                                charset = g.i0.c.l;
                            } else {
                                if (hVar.G(0L, g.i0.c.f6147h)) {
                                    hVar.l(r2.k());
                                    charset = g.i0.c.m;
                                }
                            }
                        }
                    }
                }
                inputStreamReader = new InputStreamReader(this.f6101b.I(), charset);
                this.f6104e = inputStreamReader;
            }
            return inputStreamReader.read(cArr, i2, i3);
        }
    }

    public abstract long a();

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        g.i0.c.d(o());
    }

    @Nullable
    public abstract u i();

    public abstract h.h o();
}
