package t9; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.common.api.Api; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import x9.v; /* loaded from: classes2.dex */ abstract class d { /* renamed from: a, reason: collision with root package name */ static final c[] f14480a; /* renamed from: b, reason: collision with root package name */ static final Map f14481b; static final class a { /* renamed from: a, reason: collision with root package name */ private final List f14482a; /* renamed from: b, reason: collision with root package name */ private final x9.e f14483b; /* renamed from: c, reason: collision with root package name */ private final int f14484c; /* renamed from: d, reason: collision with root package name */ private int f14485d; /* renamed from: e, reason: collision with root package name */ c[] f14486e; /* renamed from: f, reason: collision with root package name */ int f14487f; /* renamed from: g, reason: collision with root package name */ int f14488g; /* renamed from: h, reason: collision with root package name */ int f14489h; a(int i10, v vVar) { this(i10, i10, vVar); } private void a() { int i10 = this.f14485d; int i11 = this.f14489h; if (i10 < i11) { if (i10 == 0) { b(); } else { d(i11 - i10); } } } private void b() { Arrays.fill(this.f14486e, (Object) null); this.f14487f = this.f14486e.length - 1; this.f14488g = 0; this.f14489h = 0; } private int c(int i10) { return this.f14487f + 1 + i10; } private int d(int i10) { int i11; int i12 = 0; if (i10 > 0) { int length = this.f14486e.length; while (true) { length--; i11 = this.f14487f; if (length < i11 || i10 <= 0) { break; } int i13 = this.f14486e[length].f14479c; i10 -= i13; this.f14489h -= i13; this.f14488g--; i12++; } c[] cVarArr = this.f14486e; System.arraycopy(cVarArr, i11 + 1, cVarArr, i11 + 1 + i12, this.f14488g); this.f14487f += i12; } return i12; } private x9.f f(int i10) { if (h(i10)) { return d.f14480a[i10].f14477a; } int c10 = c(i10 - d.f14480a.length); if (c10 >= 0) { c[] cVarArr = this.f14486e; if (c10 < cVarArr.length) { return cVarArr[c10].f14477a; } } throw new IOException("Header index too large " + (i10 + 1)); } private void g(int i10, c cVar) { this.f14482a.add(cVar); int i11 = cVar.f14479c; if (i10 != -1) { i11 -= this.f14486e[c(i10)].f14479c; } int i12 = this.f14485d; if (i11 > i12) { b(); return; } int d10 = d((this.f14489h + i11) - i12); if (i10 == -1) { int i13 = this.f14488g + 1; c[] cVarArr = this.f14486e; if (i13 > cVarArr.length) { c[] cVarArr2 = new c[cVarArr.length * 2]; System.arraycopy(cVarArr, 0, cVarArr2, cVarArr.length, cVarArr.length); this.f14487f = this.f14486e.length - 1; this.f14486e = cVarArr2; } int i14 = this.f14487f; this.f14487f = i14 - 1; this.f14486e[i14] = cVar; this.f14488g++; } else { this.f14486e[i10 + c(i10) + d10] = cVar; } this.f14489h += i11; } private boolean h(int i10) { return i10 >= 0 && i10 <= d.f14480a.length - 1; } private int i() { return this.f14483b.readByte() & 255; } private void l(int i10) { if (h(i10)) { this.f14482a.add(d.f14480a[i10]); return; } int c10 = c(i10 - d.f14480a.length); if (c10 >= 0) { c[] cVarArr = this.f14486e; if (c10 < cVarArr.length) { this.f14482a.add(cVarArr[c10]); return; } } throw new IOException("Header index too large " + (i10 + 1)); } private void n(int i10) { g(-1, new c(f(i10), j())); } private void o() { g(-1, new c(d.a(j()), j())); } private void p(int i10) { this.f14482a.add(new c(f(i10), j())); } private void q() { this.f14482a.add(new c(d.a(j()), j())); } public List e() { ArrayList arrayList = new ArrayList(this.f14482a); this.f14482a.clear(); return arrayList; } x9.f j() { int i10 = i(); boolean z10 = (i10 & 128) == 128; int m10 = m(i10, 127); return z10 ? x9.f.j(k.f().c(this.f14483b.p(m10))) : this.f14483b.d(m10); } void k() { while (!this.f14483b.g()) { int readByte = this.f14483b.readByte() & 255; if (readByte == 128) { throw new IOException("index == 0"); } if ((readByte & 128) == 128) { l(m(readByte, 127) - 1); } else if (readByte == 64) { o(); } else if ((readByte & 64) == 64) { n(m(readByte, 63) - 1); } else if ((readByte & 32) == 32) { int m10 = m(readByte, 31); this.f14485d = m10; if (m10 < 0 || m10 > this.f14484c) { throw new IOException("Invalid dynamic table size update " + this.f14485d); } a(); } else if (readByte == 16 || readByte == 0) { q(); } else { p(m(readByte, 15) - 1); } } } int m(int i10, int i11) { int i12 = i10 & i11; if (i12 < i11) { return i12; } int i13 = 0; while (true) { int i14 = i(); if ((i14 & 128) == 0) { return i11 + (i14 << i13); } i11 += (i14 & 127) << i13; i13 += 7; } } a(int i10, int i11, v vVar) { this.f14482a = new ArrayList(); this.f14486e = new c[8]; this.f14487f = r0.length - 1; this.f14488g = 0; this.f14489h = 0; this.f14484c = i10; this.f14485d = i11; this.f14483b = x9.n.c(vVar); } } static final class b { /* renamed from: a, reason: collision with root package name */ private final x9.c f14490a; /* renamed from: b, reason: collision with root package name */ private final boolean f14491b; /* renamed from: c, reason: collision with root package name */ private int f14492c; /* renamed from: d, reason: collision with root package name */ private boolean f14493d; /* renamed from: e, reason: collision with root package name */ int f14494e; /* renamed from: f, reason: collision with root package name */ int f14495f; /* renamed from: g, reason: collision with root package name */ c[] f14496g; /* renamed from: h, reason: collision with root package name */ int f14497h; /* renamed from: i, reason: collision with root package name */ int f14498i; /* renamed from: j, reason: collision with root package name */ int f14499j; b(x9.c cVar) { this(4096, true, cVar); } private void a() { int i10 = this.f14495f; int i11 = this.f14499j; if (i10 < i11) { if (i10 == 0) { b(); } else { c(i11 - i10); } } } private void b() { Arrays.fill(this.f14496g, (Object) null); this.f14497h = this.f14496g.length - 1; this.f14498i = 0; this.f14499j = 0; } private int c(int i10) { int i11; int i12 = 0; if (i10 > 0) { int length = this.f14496g.length; while (true) { length--; i11 = this.f14497h; if (length < i11 || i10 <= 0) { break; } int i13 = this.f14496g[length].f14479c; i10 -= i13; this.f14499j -= i13; this.f14498i--; i12++; } c[] cVarArr = this.f14496g; System.arraycopy(cVarArr, i11 + 1, cVarArr, i11 + 1 + i12, this.f14498i); c[] cVarArr2 = this.f14496g; int i14 = this.f14497h; Arrays.fill(cVarArr2, i14 + 1, i14 + 1 + i12, (Object) null); this.f14497h += i12; } return i12; } private void d(c cVar) { int i10 = cVar.f14479c; int i11 = this.f14495f; if (i10 > i11) { b(); return; } c((this.f14499j + i10) - i11); int i12 = this.f14498i + 1; c[] cVarArr = this.f14496g; if (i12 > cVarArr.length) { c[] cVarArr2 = new c[cVarArr.length * 2]; System.arraycopy(cVarArr, 0, cVarArr2, cVarArr.length, cVarArr.length); this.f14497h = this.f14496g.length - 1; this.f14496g = cVarArr2; } int i13 = this.f14497h; this.f14497h = i13 - 1; this.f14496g[i13] = cVar; this.f14498i++; this.f14499j += i10; } void e(int i10) { this.f14494e = i10; int min = Math.min(i10, 16384); int i11 = this.f14495f; if (i11 == min) { return; } if (min < i11) { this.f14492c = Math.min(this.f14492c, min); } this.f14493d = true; this.f14495f = min; a(); } void f(x9.f fVar) { if (!this.f14491b || k.f().e(fVar) >= fVar.n()) { h(fVar.n(), 127, 0); this.f14490a.v0(fVar); return; } x9.c cVar = new x9.c(); k.f().d(fVar, cVar); x9.f f02 = cVar.f0(); h(f02.n(), 127, 128); this.f14490a.v0(f02); } void g(List list) { int i10; int i11; if (this.f14493d) { int i12 = this.f14492c; if (i12 < this.f14495f) { h(i12, 31, 32); } this.f14493d = false; this.f14492c = Api.BaseClientBuilder.API_PRIORITY_OTHER; h(this.f14495f, 31, 32); } int size = list.size(); for (int i13 = 0; i13 < size; i13++) { c cVar = (c) list.get(i13); x9.f q10 = cVar.f14477a.q(); x9.f fVar = cVar.f14478b; Integer num = (Integer) d.f14481b.get(q10); if (num != null) { i10 = num.intValue() + 1; if (i10 > 1 && i10 < 8) { c[] cVarArr = d.f14480a; if (Objects.equals(cVarArr[i10 - 1].f14478b, fVar)) { i11 = i10; } else if (Objects.equals(cVarArr[i10].f14478b, fVar)) { i11 = i10; i10++; } } i11 = i10; i10 = -1; } else { i10 = -1; i11 = -1; } if (i10 == -1) { int i14 = this.f14497h + 1; int length = this.f14496g.length; while (true) { if (i14 >= length) { break; } if (Objects.equals(this.f14496g[i14].f14477a, q10)) { if (Objects.equals(this.f14496g[i14].f14478b, fVar)) { i10 = d.f14480a.length + (i14 - this.f14497h); break; } else if (i11 == -1) { i11 = (i14 - this.f14497h) + d.f14480a.length; } } i14++; } } if (i10 != -1) { h(i10, 127, 128); } else if (i11 == -1) { this.f14490a.h(64); f(q10); f(fVar); d(cVar); } else if (!q10.o(c.f14471d) || c.f14476i.equals(q10)) { h(i11, 63, 64); f(fVar); d(cVar); } else { h(i11, 15, 0); f(fVar); } } } void h(int i10, int i11, int i12) { if (i10 < i11) { this.f14490a.h(i10 | i12); return; } this.f14490a.h(i12 | i11); int i13 = i10 - i11; while (i13 >= 128) { this.f14490a.h(128 | (i13 & 127)); i13 >>>= 7; } this.f14490a.h(i13); } b(int i10, boolean z10, x9.c cVar) { this.f14492c = Api.BaseClientBuilder.API_PRIORITY_OTHER; this.f14496g = new c[8]; this.f14497h = r0.length - 1; this.f14498i = 0; this.f14499j = 0; this.f14494e = i10; this.f14495f = i10; this.f14491b = z10; this.f14490a = cVar; } } static { x9.f fVar = c.f14473f; x9.f fVar2 = c.f14474g; x9.f fVar3 = c.f14475h; x9.f fVar4 = c.f14472e; f14480a = new c[]{new c(c.f14476i, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c(fVar, "GET"), new c(fVar, "POST"), new c(fVar2, "/"), new c(fVar2, "/index.html"), new c(fVar3, "http"), new c(fVar3, "https"), new c(fVar4, "200"), new c(fVar4, "204"), new c(fVar4, "206"), new c(fVar4, "304"), new c(fVar4, "400"), new c(fVar4, "404"), new c(fVar4, "500"), new c("accept-charset", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept-encoding", "gzip, deflate"), new c("accept-language", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept-ranges", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("access-control-allow-origin", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("age", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("allow", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("authorization", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("cache-control", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-disposition", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-encoding", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-language", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-length", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-location", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-type", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("cookie", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("date", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("etag", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("expect", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("expires", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("from", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("host", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-match", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-modified-since", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-none-match", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-unmodified-since", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("last-modified", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("link", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("location", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("max-forwards", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("proxy-authenticate", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("proxy-authorization", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("referer", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("refresh", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("retry-after", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("server", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("set-cookie", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("strict-transport-security", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("transfer-encoding", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("user-agent", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("vary", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("via", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("www-authenticate", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED)}; f14481b = b(); } static x9.f a(x9.f fVar) { int n10 = fVar.n(); for (int i10 = 0; i10 < n10; i10++) { byte h10 = fVar.h(i10); if (h10 >= 65 && h10 <= 90) { throw new IOException("PROTOCOL_ERROR response malformed: mixed case name: " + fVar.s()); } } return fVar; } private static Map b() { LinkedHashMap linkedHashMap = new LinkedHashMap(f14480a.length); int i10 = 0; while (true) { c[] cVarArr = f14480a; if (i10 >= cVarArr.length) { return Collections.unmodifiableMap(linkedHashMap); } if (!linkedHashMap.containsKey(cVarArr[i10].f14477a)) { linkedHashMap.put(cVarArr[i10].f14477a, Integer.valueOf(i10)); } i10++; } } }