what-the-bank/sources/com/google/firebase/firestore/remote/RemoteSerializer.java

1313 lines
54 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.firestore.remote;
import com.google.firebase.Timestamp;
import com.google.firebase.firestore.core.CompositeFilter;
import com.google.firebase.firestore.core.FieldFilter;
import com.google.firebase.firestore.core.Filter;
import com.google.firebase.firestore.core.OrderBy;
import com.google.firebase.firestore.core.Query;
import com.google.firebase.firestore.core.Target;
import com.google.firebase.firestore.local.QueryPurpose;
import com.google.firebase.firestore.local.TargetData;
import com.google.firebase.firestore.model.DatabaseId;
import com.google.firebase.firestore.model.DocumentKey;
import com.google.firebase.firestore.model.FieldPath;
import com.google.firebase.firestore.model.MutableDocument;
import com.google.firebase.firestore.model.ObjectValue;
import com.google.firebase.firestore.model.ResourcePath;
import com.google.firebase.firestore.model.SnapshotVersion;
import com.google.firebase.firestore.model.Values;
import com.google.firebase.firestore.model.mutation.ArrayTransformOperation;
import com.google.firebase.firestore.model.mutation.DeleteMutation;
import com.google.firebase.firestore.model.mutation.FieldMask;
import com.google.firebase.firestore.model.mutation.FieldTransform;
import com.google.firebase.firestore.model.mutation.Mutation;
import com.google.firebase.firestore.model.mutation.MutationResult;
import com.google.firebase.firestore.model.mutation.NumericIncrementTransformOperation;
import com.google.firebase.firestore.model.mutation.PatchMutation;
import com.google.firebase.firestore.model.mutation.Precondition;
import com.google.firebase.firestore.model.mutation.ServerTimestampOperation;
import com.google.firebase.firestore.model.mutation.SetMutation;
import com.google.firebase.firestore.model.mutation.TransformOperation;
import com.google.firebase.firestore.model.mutation.VerifyMutation;
import com.google.firebase.firestore.remote.WatchChange;
import com.google.firebase.firestore.util.Assert;
import io.grpc.Status;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import o.AQX;
import o.Boy;
import o.C10521eGo;
import o.C13401fZd;
import o.C17555xkr;
import o.CoM;
import o.JBL;
import o.JsL;
import o.MTP;
import o.NSZ;
import o.PeW;
import o.SPR;
import o.YJK;
import o.ZAx;
import o.ZMV;
import o.Zhm;
import o.gNP;
import o.ksi;
import o.sbb;
import o.uOO;
import o.veo;
/* loaded from: classes2.dex */
public final class RemoteSerializer {
private final DatabaseId databaseId;
private final String databaseName;
public RemoteSerializer(DatabaseId databaseId) {
this.databaseId = databaseId;
this.databaseName = encodedDatabaseId(databaseId).canonicalString();
}
public final AQX encodeTimestamp(Timestamp timestamp) {
AQX.IeS b = AQX.b();
b.c(timestamp.getSeconds());
b.e(timestamp.getNanoseconds());
return b.build();
}
public final Timestamp decodeTimestamp(AQX aqx) {
return new Timestamp(aqx.seconds_, aqx.nanos_);
}
public final AQX encodeVersion(SnapshotVersion snapshotVersion) {
return encodeTimestamp(snapshotVersion.getTimestamp());
}
public final String encodeKey(DocumentKey documentKey) {
return encodeResourceName(this.databaseId, documentKey.getPath());
}
public final DocumentKey decodeKey(String str) {
ResourcePath decodeResourceName = decodeResourceName(str);
Assert.hardAssert(decodeResourceName.getSegment(1).equals(this.databaseId.getProjectId()), "Tried to deserialize key from different project.", new Object[0]);
Assert.hardAssert(decodeResourceName.getSegment(3).equals(this.databaseId.getDatabaseId()), "Tried to deserialize key from different database.", new Object[0]);
return DocumentKey.fromPath(extractLocalPathFromResourceName(decodeResourceName));
}
private String encodeQueryPath(ResourcePath resourcePath) {
return encodeResourceName(this.databaseId, resourcePath);
}
private ResourcePath decodeQueryPath(String str) {
ResourcePath decodeResourceName = decodeResourceName(str);
if (decodeResourceName.length() == 4) {
return ResourcePath.EMPTY;
}
return extractLocalPathFromResourceName(decodeResourceName);
}
private String encodeResourceName(DatabaseId databaseId, ResourcePath resourcePath) {
return encodedDatabaseId(databaseId).append("documents").append(resourcePath).canonicalString();
}
private ResourcePath decodeResourceName(String str) {
ResourcePath fromString = ResourcePath.fromString(str);
Assert.hardAssert(isValidResourceName(fromString), "Tried to deserialize invalid key %s", fromString);
return fromString;
}
private static ResourcePath encodedDatabaseId(DatabaseId databaseId) {
return ResourcePath.fromSegments(Arrays.asList("projects", databaseId.getProjectId(), "databases", databaseId.getDatabaseId()));
}
private static ResourcePath extractLocalPathFromResourceName(ResourcePath resourcePath) {
Assert.hardAssert(resourcePath.length() > 4 && resourcePath.getSegment(4).equals("documents"), "Tried to deserialize invalid key %s", resourcePath);
return resourcePath.popFirst(5);
}
private static boolean isValidResourceName(ResourcePath resourcePath) {
return resourcePath.length() >= 4 && resourcePath.getSegment(0).equals("projects") && resourcePath.getSegment(2).equals("databases");
}
public final SPR encodeDocument(DocumentKey documentKey, ObjectValue objectValue) {
SPR.IeS e = SPR.e();
e.d(encodeKey(documentKey));
e.c(objectValue.getFieldsMap());
return e.build();
}
public final JsL encodeMutation(Mutation mutation) {
JsL.LWm c = JsL.c();
if (mutation instanceof SetMutation) {
c.d(encodeDocument(mutation.getKey(), ((SetMutation) mutation).getValue()));
} else if (mutation instanceof PatchMutation) {
c.d(encodeDocument(mutation.getKey(), ((PatchMutation) mutation).getValue()));
c.e(encodeDocumentMask(mutation.getFieldMask()));
} else if (mutation instanceof DeleteMutation) {
c.d(encodeKey(mutation.getKey()));
} else if (mutation instanceof VerifyMutation) {
c.c(encodeKey(mutation.getKey()));
} else {
throw Assert.fail("unknown mutation type %s", mutation.getClass());
}
Iterator<FieldTransform> it = mutation.getFieldTransforms().iterator();
while (it.hasNext()) {
c.e(encodeFieldTransform(it.next()));
}
if (!mutation.getPrecondition().isNone()) {
c.c(encodePrecondition(mutation.getPrecondition()));
}
return c.build();
}
private C10521eGo encodePrecondition(Precondition precondition) {
Assert.hardAssert(!precondition.isNone(), "Can't serialize an empty precondition", new Object[0]);
C10521eGo.HBt c = C10521eGo.c();
if (precondition.getUpdateTime() != null) {
return c.a(encodeVersion(precondition.getUpdateTime())).build();
}
if (precondition.getExists() != null) {
return c.d(precondition.getExists().booleanValue()).build();
}
throw Assert.fail("Unknown Precondition", new Object[0]);
}
private Precondition decodePrecondition(C10521eGo c10521eGo) {
AQX c;
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$Precondition$ConditionTypeCase[C10521eGo.IeS.b(c10521eGo.conditionTypeCase_).ordinal()];
if (i == 1) {
if (c10521eGo.conditionTypeCase_ == 2) {
c = (AQX) c10521eGo.conditionType_;
} else {
c = AQX.c();
}
return Precondition.updateTime(decodeVersion(c));
}
if (i == 2) {
return Precondition.exists(c10521eGo.conditionTypeCase_ == 1 ? ((Boolean) c10521eGo.conditionType_).booleanValue() : false);
}
if (i == 3) {
return Precondition.NONE;
}
throw Assert.fail("Unknown precondition", new Object[0]);
}
private Zhm encodeDocumentMask(FieldMask fieldMask) {
Zhm.IeS d = Zhm.d();
Iterator<FieldPath> it = fieldMask.getMask().iterator();
while (it.hasNext()) {
d.b(it.next().canonicalString());
}
return d.build();
}
private FieldMask decodeDocumentMask(Zhm zhm) {
int size = zhm.fieldPaths_.size();
HashSet hashSet = new HashSet(size);
for (int i = 0; i < size; i++) {
hashSet.add(FieldPath.fromServerFormat(zhm.fieldPaths_.get(i)));
}
return FieldMask.fromSet(hashSet);
}
private veo.Sts encodeFieldTransform(FieldTransform fieldTransform) {
TransformOperation operation = fieldTransform.getOperation();
if (operation instanceof ServerTimestampOperation) {
return veo.Sts.b().d(fieldTransform.getFieldPath().canonicalString()).d(veo.Sts.EnumC0125Sts.REQUEST_TIME).build();
}
if (operation instanceof ArrayTransformOperation.Union) {
return veo.Sts.b().d(fieldTransform.getFieldPath().canonicalString()).d(uOO.a().b(((ArrayTransformOperation.Union) operation).getElements())).build();
}
if (operation instanceof ArrayTransformOperation.Remove) {
return veo.Sts.b().d(fieldTransform.getFieldPath().canonicalString()).c(uOO.a().b(((ArrayTransformOperation.Remove) operation).getElements())).build();
}
if (operation instanceof NumericIncrementTransformOperation) {
return veo.Sts.b().d(fieldTransform.getFieldPath().canonicalString()).c(((NumericIncrementTransformOperation) operation).getOperand()).build();
}
throw Assert.fail("Unknown transform: %s", operation);
}
private FieldTransform decodeFieldTransform(veo.Sts sts) {
uOO e;
uOO e2;
sbb a;
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase[veo.Sts.HBt.c(sts.transformTypeCase_).ordinal()];
if (i == 1) {
Assert.hardAssert(sts.d() == veo.Sts.EnumC0125Sts.REQUEST_TIME, "Unknown transform setToServerValue: %s", sts.d());
return new FieldTransform(FieldPath.fromServerFormat(sts.fieldPath_), ServerTimestampOperation.getInstance());
}
if (i == 2) {
FieldPath fromServerFormat = FieldPath.fromServerFormat(sts.fieldPath_);
if (sts.transformTypeCase_ == 6) {
e = (uOO) sts.transformType_;
} else {
e = uOO.e();
}
return new FieldTransform(fromServerFormat, new ArrayTransformOperation.Union(e.values_));
}
if (i == 3) {
FieldPath fromServerFormat2 = FieldPath.fromServerFormat(sts.fieldPath_);
if (sts.transformTypeCase_ == 7) {
e2 = (uOO) sts.transformType_;
} else {
e2 = uOO.e();
}
return new FieldTransform(fromServerFormat2, new ArrayTransformOperation.Remove(e2.values_));
}
if (i == 4) {
FieldPath fromServerFormat3 = FieldPath.fromServerFormat(sts.fieldPath_);
if (sts.transformTypeCase_ == 3) {
a = (sbb) sts.transformType_;
} else {
a = sbb.a();
}
return new FieldTransform(fromServerFormat3, new NumericIncrementTransformOperation(a));
}
throw Assert.fail("Unknown FieldTransform proto: %s", sts);
}
public final MutationResult decodeMutationResult(gNP gnp, SnapshotVersion snapshotVersion) {
AQX aqx = gnp.updateTime_;
if (aqx == null) {
aqx = AQX.c();
}
SnapshotVersion decodeVersion = decodeVersion(aqx);
if (!SnapshotVersion.NONE.equals(decodeVersion)) {
snapshotVersion = decodeVersion;
}
int size = gnp.transformResults_.size();
ArrayList arrayList = new ArrayList(size);
for (int i = 0; i < size; i++) {
arrayList.add(gnp.transformResults_.get(i));
}
return new MutationResult(snapshotVersion, arrayList);
}
public final Map<String, String> encodeListenRequestLabels(TargetData targetData) {
String encodeLabel = encodeLabel(targetData.getPurpose());
if (encodeLabel == null) {
return null;
}
HashMap hashMap = new HashMap(1);
hashMap.put("goog-listen-tags", encodeLabel);
return hashMap;
}
private String encodeLabel(QueryPurpose queryPurpose) {
int i = AnonymousClass1.$SwitchMap$com$google$firebase$firestore$local$QueryPurpose[queryPurpose.ordinal()];
if (i == 1) {
return null;
}
if (i == 2) {
return "existence-filter-mismatch";
}
if (i == 3) {
return "limbo-document";
}
throw Assert.fail("Unrecognized query purpose: %s", queryPurpose);
}
public final ksi encodeTarget(TargetData targetData) {
ksi.HBt b = ksi.b();
Target target = targetData.getTarget();
if (target.isDocumentQuery()) {
b.a(encodeDocumentsTarget(target));
} else {
b.b(encodeQueryTarget(target));
}
b.b(targetData.getTargetId());
if (targetData.getResumeToken().g() == 0 && targetData.getSnapshotVersion().compareTo(SnapshotVersion.NONE) > 0) {
b.c(encodeTimestamp(targetData.getSnapshotVersion().getTimestamp()));
} else {
b.d(targetData.getResumeToken());
}
return b.build();
}
public final ksi.RVV encodeDocumentsTarget(Target target) {
ksi.RVV.Sts b = ksi.RVV.b();
b.d(encodeQueryPath(target.getPath()));
return b.build();
}
public final Target decodeDocumentsTarget(ksi.RVV rvv) {
int size = rvv.documents_.size();
Assert.hardAssert(size == 1, "DocumentsTarget contained other than 1 document %d", Integer.valueOf(size));
return Query.atPath(decodeQueryPath(rvv.documents_.get(0))).toTarget();
}
public final ksi.Sts encodeQueryTarget(Target target) {
ksi.Sts.RVV e = ksi.Sts.e();
CoM.IeS b = CoM.b();
ResourcePath path = target.getPath();
if (target.getCollectionGroup() != null) {
Assert.hardAssert(path.length() % 2 == 0, "Collection Group queries should be within a document path or root.", new Object[0]);
e.c(encodeQueryPath(path));
CoM.RVV.C0081RVV e2 = CoM.RVV.e();
e2.a(target.getCollectionGroup());
e2.d();
b.b(e2);
} else {
Assert.hardAssert(path.length() % 2 != 0, "Document queries with filters are not supported.", new Object[0]);
e.c(encodeQueryPath(path.popLast()));
CoM.RVV.C0081RVV e3 = CoM.RVV.e();
e3.a(path.getLastSegment());
b.b(e3);
}
if (target.getFilters().size() > 0) {
b.e(encodeFilters(target.getFilters()));
}
Iterator<OrderBy> it = target.getOrderBy().iterator();
while (it.hasNext()) {
b.d(encodeOrderBy(it.next()));
}
if (target.hasLimit()) {
b.e(C17555xkr.d().a((int) target.getLimit()));
}
if (target.getStartAt() != null) {
PeW.HBt e4 = PeW.e();
e4.e(target.getStartAt().getPosition());
e4.b(target.getStartAt().isInclusive());
b.b(e4);
}
if (target.getEndAt() != null) {
PeW.HBt e5 = PeW.e();
e5.e(target.getEndAt().getPosition());
e5.b(!target.getEndAt().isInclusive());
b.c(e5);
}
e.c(b);
return e.build();
}
/* JADX WARN: Removed duplicated region for block: B:10:0x003a */
/* JADX WARN: Removed duplicated region for block: B:16:0x0054 */
/* JADX WARN: Removed duplicated region for block: B:23:0x0078 */
/* JADX WARN: Removed duplicated region for block: B:29:0x008a */
/* JADX WARN: Removed duplicated region for block: B:38:0x00aa */
/* JADX WARN: Removed duplicated region for block: B:48:0x00a5 */
/* JADX WARN: Removed duplicated region for block: B:49:0x0084 */
/* JADX WARN: Removed duplicated region for block: B:50:0x006f */
/* JADX WARN: Removed duplicated region for block: B:51:0x0047 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final com.google.firebase.firestore.core.Target decodeQueryTarget(java.lang.String r14, o.CoM r15) {
/*
r13 = this;
com.google.firebase.firestore.model.ResourcePath r14 = r13.decodeQueryPath(r14)
o.MTP$RVV<o.CoM$RVV> r0 = r15.from_
int r0 = r0.size()
r1 = 1
r2 = 0
r3 = 0
if (r0 <= 0) goto L34
if (r0 != r1) goto L13
r0 = r1
goto L14
L13:
r0 = r2
L14:
java.lang.Object[] r4 = new java.lang.Object[r2]
java.lang.String r5 = "StructuredQuery.from with more than one collection is not supported."
com.google.firebase.firestore.util.Assert.hardAssert(r0, r5, r4)
o.MTP$RVV<o.CoM$RVV> r0 = r15.from_
java.lang.Object r0 = r0.get(r2)
o.CoM$RVV r0 = (o.CoM.RVV) r0
boolean r4 = r0.allDescendants_
if (r4 == 0) goto L2c
java.lang.String r0 = r0.collectionId_
r5 = r14
r6 = r0
goto L36
L2c:
java.lang.String r0 = r0.collectionId_
com.google.firebase.firestore.model.BasePath r14 = r14.append(r0)
com.google.firebase.firestore.model.ResourcePath r14 = (com.google.firebase.firestore.model.ResourcePath) r14
L34:
r5 = r14
r6 = r3
L36:
o.CoM$tOB r14 = r15.where_
if (r14 == 0) goto L47
o.CoM$tOB r14 = r15.where_
if (r14 != 0) goto L42
o.CoM$tOB r14 = o.CoM.tOB.d()
L42:
java.util.List r14 = r13.decodeFilters(r14)
goto L4b
L47:
java.util.List r14 = java.util.Collections.emptyList()
L4b:
r7 = r14
o.MTP$RVV<o.CoM$ZqN> r14 = r15.orderBy_
int r14 = r14.size()
if (r14 <= 0) goto L6f
java.util.ArrayList r0 = new java.util.ArrayList
r0.<init>(r14)
L59:
if (r2 >= r14) goto L6d
o.MTP$RVV<o.CoM$ZqN> r4 = r15.orderBy_
java.lang.Object r4 = r4.get(r2)
o.CoM$ZqN r4 = (o.CoM.ZqN) r4
com.google.firebase.firestore.core.OrderBy r4 = r13.decodeOrderBy(r4)
r0.add(r4)
int r2 = r2 + 1
goto L59
L6d:
r8 = r0
goto L74
L6f:
java.util.List r14 = java.util.Collections.emptyList()
r8 = r14
L74:
o.xkr r14 = r15.limit_
if (r14 == 0) goto L84
o.xkr r14 = r15.limit_
if (r14 != 0) goto L80
o.xkr r14 = o.C17555xkr.b()
L80:
int r14 = r14.value_
long r9 = (long) r14
goto L86
L84:
r9 = -1
L86:
o.PeW r14 = r15.startAt_
if (r14 == 0) goto La5
com.google.firebase.firestore.core.Bound r14 = new com.google.firebase.firestore.core.Bound
o.PeW r0 = r15.startAt_
if (r0 != 0) goto L94
o.PeW r0 = o.PeW.c()
L94:
o.MTP$RVV<o.sbb> r0 = r0.values_
o.PeW r2 = r15.startAt_
if (r2 != 0) goto L9e
o.PeW r2 = o.PeW.c()
L9e:
boolean r2 = r2.before_
r14.<init>(r0, r2)
r11 = r14
goto La6
La5:
r11 = r3
La6:
o.PeW r14 = r15.endAt_
if (r14 == 0) goto Lc4
com.google.firebase.firestore.core.Bound r3 = new com.google.firebase.firestore.core.Bound
o.PeW r14 = r15.endAt_
if (r14 != 0) goto Lb4
o.PeW r14 = o.PeW.c()
Lb4:
o.MTP$RVV<o.sbb> r14 = r14.values_
o.PeW r15 = r15.endAt_
if (r15 != 0) goto Lbe
o.PeW r15 = o.PeW.c()
Lbe:
boolean r15 = r15.before_
r15 = r15 ^ r1
r3.<init>(r14, r15)
Lc4:
r12 = r3
com.google.firebase.firestore.core.Target r14 = new com.google.firebase.firestore.core.Target
r4 = r14
r4.<init>(r5, r6, r7, r8, r9, r11, r12)
return r14
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.firestore.remote.RemoteSerializer.decodeQueryTarget(java.lang.String, o.CoM):com.google.firebase.firestore.core.Target");
}
private CoM.tOB encodeFilters(List<Filter> list) {
return encodeFilter(new CompositeFilter(list, CompositeFilter.Operator.AND));
}
private List<Filter> decodeFilters(CoM.tOB tob) {
Filter decodeFilter = decodeFilter(tob);
if (decodeFilter instanceof CompositeFilter) {
CompositeFilter compositeFilter = (CompositeFilter) decodeFilter;
if (compositeFilter.isFlatConjunction()) {
return compositeFilter.getFilters();
}
}
return Collections.singletonList(decodeFilter);
}
final CoM.tOB encodeFilter(Filter filter) {
if (filter instanceof FieldFilter) {
return encodeUnaryOrFieldFilter((FieldFilter) filter);
}
if (filter instanceof CompositeFilter) {
return encodeCompositeFilter((CompositeFilter) filter);
}
throw Assert.fail("Unrecognized filter type %s", filter.toString());
}
final CoM.tOB encodeUnaryOrFieldFilter(FieldFilter fieldFilter) {
CoM.jbe.HBt hBt;
CoM.jbe.HBt hBt2;
if (fieldFilter.getOperator() == FieldFilter.Operator.EQUAL || fieldFilter.getOperator() == FieldFilter.Operator.NOT_EQUAL) {
CoM.jbe.LWm d = CoM.jbe.d();
d.a(encodeFieldPath(fieldFilter.getField()));
if (Values.isNanValue(fieldFilter.getValue())) {
if (fieldFilter.getOperator() == FieldFilter.Operator.EQUAL) {
hBt2 = CoM.jbe.HBt.IS_NAN;
} else {
hBt2 = CoM.jbe.HBt.IS_NOT_NAN;
}
d.b(hBt2);
return CoM.tOB.c().b(d).build();
}
if (Values.isNullValue(fieldFilter.getValue())) {
if (fieldFilter.getOperator() == FieldFilter.Operator.EQUAL) {
hBt = CoM.jbe.HBt.IS_NULL;
} else {
hBt = CoM.jbe.HBt.IS_NOT_NULL;
}
d.b(hBt);
return CoM.tOB.c().b(d).build();
}
}
CoM.Sts.LWm b = CoM.Sts.b();
b.c(encodeFieldPath(fieldFilter.getField()));
b.b(encodeFieldFilterOperator(fieldFilter.getOperator()));
b.d(fieldFilter.getValue());
return CoM.tOB.c().b(b).build();
}
final CoM.LWm.Sts encodeCompositeFilterOperator(CompositeFilter.Operator operator) {
int i = AnonymousClass1.$SwitchMap$com$google$firebase$firestore$core$CompositeFilter$Operator[operator.ordinal()];
if (i == 1) {
return CoM.LWm.Sts.AND;
}
if (i == 2) {
return CoM.LWm.Sts.OR;
}
throw Assert.fail("Unrecognized composite filter type.", new Object[0]);
}
final CompositeFilter.Operator decodeCompositeFilterOperator(CoM.LWm.Sts sts) {
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$StructuredQuery$CompositeFilter$Operator[sts.ordinal()];
if (i == 1) {
return CompositeFilter.Operator.AND;
}
if (i == 2) {
return CompositeFilter.Operator.OR;
}
throw Assert.fail("Only AND and OR composite filter types are supported.", new Object[0]);
}
final CoM.tOB encodeCompositeFilter(CompositeFilter compositeFilter) {
ArrayList arrayList = new ArrayList(compositeFilter.getFilters().size());
Iterator<Filter> it = compositeFilter.getFilters().iterator();
while (it.hasNext()) {
arrayList.add(encodeFilter(it.next()));
}
if (arrayList.size() == 1) {
return (CoM.tOB) arrayList.get(0);
}
CoM.LWm.HBt e = CoM.LWm.e();
e.a(encodeCompositeFilterOperator(compositeFilter.getOperator()));
e.d(arrayList);
return CoM.tOB.c().e(e).build();
}
final Filter decodeFilter(CoM.tOB tob) {
CoM.LWm b;
CoM.Sts d;
CoM.jbe c;
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$StructuredQuery$Filter$FilterTypeCase[CoM.tOB.IeS.d(tob.filterTypeCase_).ordinal()];
if (i == 1) {
if (tob.filterTypeCase_ == 1) {
b = (CoM.LWm) tob.filterType_;
} else {
b = CoM.LWm.b();
}
return decodeCompositeFilter(b);
}
if (i == 2) {
if (tob.filterTypeCase_ == 2) {
d = (CoM.Sts) tob.filterType_;
} else {
d = CoM.Sts.d();
}
return decodeFieldFilter(d);
}
if (i == 3) {
if (tob.filterTypeCase_ == 3) {
c = (CoM.jbe) tob.filterType_;
} else {
c = CoM.jbe.c();
}
return decodeUnaryFilter(c);
}
throw Assert.fail("Unrecognized Filter.filterType %d", CoM.tOB.IeS.d(tob.filterTypeCase_));
}
final FieldFilter decodeFieldFilter(CoM.Sts sts) {
CoM.ojQ ojq = sts.field_;
if (ojq == null) {
ojq = CoM.ojQ.b();
}
FieldPath fromServerFormat = FieldPath.fromServerFormat(ojq.fieldPath_);
CoM.Sts.RVV c = CoM.Sts.RVV.c(sts.op_);
if (c == null) {
c = CoM.Sts.RVV.UNRECOGNIZED;
}
FieldFilter.Operator decodeFieldFilterOperator = decodeFieldFilterOperator(c);
sbb sbbVar = sts.value_;
if (sbbVar == null) {
sbbVar = sbb.a();
}
return FieldFilter.create(fromServerFormat, decodeFieldFilterOperator, sbbVar);
}
private Filter decodeUnaryFilter(CoM.jbe jbeVar) {
CoM.ojQ b;
if (jbeVar.operandTypeCase_ == 2) {
b = (CoM.ojQ) jbeVar.operandType_;
} else {
b = CoM.ojQ.b();
}
FieldPath fromServerFormat = FieldPath.fromServerFormat(b.fieldPath_);
int[] iArr = AnonymousClass1.$SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator;
CoM.jbe.HBt c = CoM.jbe.HBt.c(jbeVar.op_);
if (c == null) {
c = CoM.jbe.HBt.UNRECOGNIZED;
}
int i = iArr[c.ordinal()];
if (i == 1) {
return FieldFilter.create(fromServerFormat, FieldFilter.Operator.EQUAL, Values.NAN_VALUE);
}
if (i == 2) {
return FieldFilter.create(fromServerFormat, FieldFilter.Operator.EQUAL, Values.NULL_VALUE);
}
if (i == 3) {
return FieldFilter.create(fromServerFormat, FieldFilter.Operator.NOT_EQUAL, Values.NAN_VALUE);
}
if (i == 4) {
return FieldFilter.create(fromServerFormat, FieldFilter.Operator.NOT_EQUAL, Values.NULL_VALUE);
}
CoM.jbe.HBt c2 = CoM.jbe.HBt.c(jbeVar.op_);
if (c2 == null) {
c2 = CoM.jbe.HBt.UNRECOGNIZED;
}
throw Assert.fail("Unrecognized UnaryFilter.operator %d", c2);
}
final CompositeFilter decodeCompositeFilter(CoM.LWm lWm) {
ArrayList arrayList = new ArrayList();
Iterator<CoM.tOB> it = lWm.filters_.iterator();
while (it.hasNext()) {
arrayList.add(decodeFilter(it.next()));
}
CoM.LWm.Sts d = CoM.LWm.Sts.d(lWm.op_);
if (d == null) {
d = CoM.LWm.Sts.UNRECOGNIZED;
}
return new CompositeFilter(arrayList, decodeCompositeFilterOperator(d));
}
private CoM.ojQ encodeFieldPath(FieldPath fieldPath) {
return CoM.ojQ.d().e(fieldPath.canonicalString()).build();
}
private CoM.Sts.RVV encodeFieldFilterOperator(FieldFilter.Operator operator) {
switch (AnonymousClass1.$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[operator.ordinal()]) {
case 1:
return CoM.Sts.RVV.LESS_THAN;
case 2:
return CoM.Sts.RVV.LESS_THAN_OR_EQUAL;
case 3:
return CoM.Sts.RVV.EQUAL;
case 4:
return CoM.Sts.RVV.NOT_EQUAL;
case 5:
return CoM.Sts.RVV.GREATER_THAN;
case 6:
return CoM.Sts.RVV.GREATER_THAN_OR_EQUAL;
case 7:
return CoM.Sts.RVV.ARRAY_CONTAINS;
case 8:
return CoM.Sts.RVV.IN;
case 9:
return CoM.Sts.RVV.ARRAY_CONTAINS_ANY;
case 10:
return CoM.Sts.RVV.NOT_IN;
default:
throw Assert.fail("Unknown operator %d", operator);
}
}
private FieldFilter.Operator decodeFieldFilterOperator(CoM.Sts.RVV rvv) {
switch (AnonymousClass1.$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[rvv.ordinal()]) {
case 1:
return FieldFilter.Operator.LESS_THAN;
case 2:
return FieldFilter.Operator.LESS_THAN_OR_EQUAL;
case 3:
return FieldFilter.Operator.EQUAL;
case 4:
return FieldFilter.Operator.NOT_EQUAL;
case 5:
return FieldFilter.Operator.GREATER_THAN_OR_EQUAL;
case 6:
return FieldFilter.Operator.GREATER_THAN;
case 7:
return FieldFilter.Operator.ARRAY_CONTAINS;
case 8:
return FieldFilter.Operator.IN;
case 9:
return FieldFilter.Operator.ARRAY_CONTAINS_ANY;
case 10:
return FieldFilter.Operator.NOT_IN;
default:
throw Assert.fail("Unhandled FieldFilter.operator %d", rvv);
}
}
private CoM.ZqN encodeOrderBy(OrderBy orderBy) {
CoM.ZqN.IeS b = CoM.ZqN.b();
if (orderBy.getDirection().equals(OrderBy.Direction.ASCENDING)) {
b.e(CoM.HBt.ASCENDING);
} else {
b.e(CoM.HBt.DESCENDING);
}
b.c(encodeFieldPath(orderBy.getField()));
return b.build();
}
private OrderBy decodeOrderBy(CoM.ZqN zqN) {
OrderBy.Direction direction;
CoM.ojQ ojq = zqN.field_;
if (ojq == null) {
ojq = CoM.ojQ.b();
}
FieldPath fromServerFormat = FieldPath.fromServerFormat(ojq.fieldPath_);
int[] iArr = AnonymousClass1.$SwitchMap$com$google$firestore$v1$StructuredQuery$Direction;
CoM.HBt d = CoM.HBt.d(zqN.direction_);
if (d == null) {
d = CoM.HBt.UNRECOGNIZED;
}
int i = iArr[d.ordinal()];
if (i == 1) {
direction = OrderBy.Direction.ASCENDING;
} else if (i == 2) {
direction = OrderBy.Direction.DESCENDING;
} else {
CoM.HBt d2 = CoM.HBt.d(zqN.direction_);
if (d2 == null) {
d2 = CoM.HBt.UNRECOGNIZED;
}
throw Assert.fail("Unrecognized direction %d", d2);
}
return OrderBy.getInstance(direction, fromServerFormat);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: com.google.firebase.firestore.remote.RemoteSerializer$1, reason: invalid class name */
/* loaded from: classes2.dex */
public static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$com$google$firebase$firestore$core$CompositeFilter$Operator;
static final int[] $SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator;
static final int[] $SwitchMap$com$google$firebase$firestore$local$QueryPurpose;
static final int[] $SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase;
static final int[] $SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase;
static final int[] $SwitchMap$com$google$firestore$v1$Precondition$ConditionTypeCase;
static final int[] $SwitchMap$com$google$firestore$v1$StructuredQuery$CompositeFilter$Operator;
static final int[] $SwitchMap$com$google$firestore$v1$StructuredQuery$Direction;
static final int[] $SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator;
static final int[] $SwitchMap$com$google$firestore$v1$StructuredQuery$Filter$FilterTypeCase;
static final int[] $SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator;
static final int[] $SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType;
static final int[] $SwitchMap$com$google$firestore$v1$Write$OperationCase;
static {
int[] iArr = new int[ZMV.Sts.values().length];
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase = iArr;
try {
iArr[ZMV.Sts.TARGET_CHANGE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.DOCUMENT_CHANGE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.DOCUMENT_DELETE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.DOCUMENT_REMOVE.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.FILTER.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.RESPONSETYPE_NOT_SET.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
int[] iArr2 = new int[ZAx.IeS.values().length];
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType = iArr2;
try {
iArr2[ZAx.IeS.NO_CHANGE.ordinal()] = 1;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType[ZAx.IeS.ADD.ordinal()] = 2;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType[ZAx.IeS.REMOVE.ordinal()] = 3;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType[ZAx.IeS.CURRENT.ordinal()] = 4;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType[ZAx.IeS.RESET.ordinal()] = 5;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType[ZAx.IeS.UNRECOGNIZED.ordinal()] = 6;
} catch (NoSuchFieldError unused12) {
}
int[] iArr3 = new int[CoM.HBt.values().length];
$SwitchMap$com$google$firestore$v1$StructuredQuery$Direction = iArr3;
try {
iArr3[CoM.HBt.ASCENDING.ordinal()] = 1;
} catch (NoSuchFieldError unused13) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$Direction[CoM.HBt.DESCENDING.ordinal()] = 2;
} catch (NoSuchFieldError unused14) {
}
int[] iArr4 = new int[CoM.Sts.RVV.values().length];
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator = iArr4;
try {
iArr4[CoM.Sts.RVV.LESS_THAN.ordinal()] = 1;
} catch (NoSuchFieldError unused15) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.LESS_THAN_OR_EQUAL.ordinal()] = 2;
} catch (NoSuchFieldError unused16) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.EQUAL.ordinal()] = 3;
} catch (NoSuchFieldError unused17) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.NOT_EQUAL.ordinal()] = 4;
} catch (NoSuchFieldError unused18) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.GREATER_THAN_OR_EQUAL.ordinal()] = 5;
} catch (NoSuchFieldError unused19) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.GREATER_THAN.ordinal()] = 6;
} catch (NoSuchFieldError unused20) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.ARRAY_CONTAINS.ordinal()] = 7;
} catch (NoSuchFieldError unused21) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.IN.ordinal()] = 8;
} catch (NoSuchFieldError unused22) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.ARRAY_CONTAINS_ANY.ordinal()] = 9;
} catch (NoSuchFieldError unused23) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$FieldFilter$Operator[CoM.Sts.RVV.NOT_IN.ordinal()] = 10;
} catch (NoSuchFieldError unused24) {
}
int[] iArr5 = new int[FieldFilter.Operator.values().length];
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator = iArr5;
try {
iArr5[FieldFilter.Operator.LESS_THAN.ordinal()] = 1;
} catch (NoSuchFieldError unused25) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.LESS_THAN_OR_EQUAL.ordinal()] = 2;
} catch (NoSuchFieldError unused26) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.EQUAL.ordinal()] = 3;
} catch (NoSuchFieldError unused27) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.NOT_EQUAL.ordinal()] = 4;
} catch (NoSuchFieldError unused28) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.GREATER_THAN.ordinal()] = 5;
} catch (NoSuchFieldError unused29) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.GREATER_THAN_OR_EQUAL.ordinal()] = 6;
} catch (NoSuchFieldError unused30) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.ARRAY_CONTAINS.ordinal()] = 7;
} catch (NoSuchFieldError unused31) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.IN.ordinal()] = 8;
} catch (NoSuchFieldError unused32) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.ARRAY_CONTAINS_ANY.ordinal()] = 9;
} catch (NoSuchFieldError unused33) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$FieldFilter$Operator[FieldFilter.Operator.NOT_IN.ordinal()] = 10;
} catch (NoSuchFieldError unused34) {
}
int[] iArr6 = new int[CoM.jbe.HBt.values().length];
$SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator = iArr6;
try {
iArr6[CoM.jbe.HBt.IS_NAN.ordinal()] = 1;
} catch (NoSuchFieldError unused35) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator[CoM.jbe.HBt.IS_NULL.ordinal()] = 2;
} catch (NoSuchFieldError unused36) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator[CoM.jbe.HBt.IS_NOT_NAN.ordinal()] = 3;
} catch (NoSuchFieldError unused37) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$UnaryFilter$Operator[CoM.jbe.HBt.IS_NOT_NULL.ordinal()] = 4;
} catch (NoSuchFieldError unused38) {
}
int[] iArr7 = new int[CoM.tOB.IeS.values().length];
$SwitchMap$com$google$firestore$v1$StructuredQuery$Filter$FilterTypeCase = iArr7;
try {
iArr7[CoM.tOB.IeS.COMPOSITE_FILTER.ordinal()] = 1;
} catch (NoSuchFieldError unused39) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$Filter$FilterTypeCase[CoM.tOB.IeS.FIELD_FILTER.ordinal()] = 2;
} catch (NoSuchFieldError unused40) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$Filter$FilterTypeCase[CoM.tOB.IeS.UNARY_FILTER.ordinal()] = 3;
} catch (NoSuchFieldError unused41) {
}
int[] iArr8 = new int[CoM.LWm.Sts.values().length];
$SwitchMap$com$google$firestore$v1$StructuredQuery$CompositeFilter$Operator = iArr8;
try {
iArr8[CoM.LWm.Sts.AND.ordinal()] = 1;
} catch (NoSuchFieldError unused42) {
}
try {
$SwitchMap$com$google$firestore$v1$StructuredQuery$CompositeFilter$Operator[CoM.LWm.Sts.OR.ordinal()] = 2;
} catch (NoSuchFieldError unused43) {
}
int[] iArr9 = new int[CompositeFilter.Operator.values().length];
$SwitchMap$com$google$firebase$firestore$core$CompositeFilter$Operator = iArr9;
try {
iArr9[CompositeFilter.Operator.AND.ordinal()] = 1;
} catch (NoSuchFieldError unused44) {
}
try {
$SwitchMap$com$google$firebase$firestore$core$CompositeFilter$Operator[CompositeFilter.Operator.OR.ordinal()] = 2;
} catch (NoSuchFieldError unused45) {
}
int[] iArr10 = new int[QueryPurpose.values().length];
$SwitchMap$com$google$firebase$firestore$local$QueryPurpose = iArr10;
try {
iArr10[QueryPurpose.LISTEN.ordinal()] = 1;
} catch (NoSuchFieldError unused46) {
}
try {
$SwitchMap$com$google$firebase$firestore$local$QueryPurpose[QueryPurpose.EXISTENCE_FILTER_MISMATCH.ordinal()] = 2;
} catch (NoSuchFieldError unused47) {
}
try {
$SwitchMap$com$google$firebase$firestore$local$QueryPurpose[QueryPurpose.LIMBO_RESOLUTION.ordinal()] = 3;
} catch (NoSuchFieldError unused48) {
}
int[] iArr11 = new int[veo.Sts.HBt.values().length];
$SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase = iArr11;
try {
iArr11[veo.Sts.HBt.SET_TO_SERVER_VALUE.ordinal()] = 1;
} catch (NoSuchFieldError unused49) {
}
try {
$SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase[veo.Sts.HBt.APPEND_MISSING_ELEMENTS.ordinal()] = 2;
} catch (NoSuchFieldError unused50) {
}
try {
$SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase[veo.Sts.HBt.REMOVE_ALL_FROM_ARRAY.ordinal()] = 3;
} catch (NoSuchFieldError unused51) {
}
try {
$SwitchMap$com$google$firestore$v1$DocumentTransform$FieldTransform$TransformTypeCase[veo.Sts.HBt.INCREMENT.ordinal()] = 4;
} catch (NoSuchFieldError unused52) {
}
int[] iArr12 = new int[C10521eGo.IeS.values().length];
$SwitchMap$com$google$firestore$v1$Precondition$ConditionTypeCase = iArr12;
try {
iArr12[C10521eGo.IeS.UPDATE_TIME.ordinal()] = 1;
} catch (NoSuchFieldError unused53) {
}
try {
$SwitchMap$com$google$firestore$v1$Precondition$ConditionTypeCase[C10521eGo.IeS.EXISTS.ordinal()] = 2;
} catch (NoSuchFieldError unused54) {
}
try {
$SwitchMap$com$google$firestore$v1$Precondition$ConditionTypeCase[C10521eGo.IeS.CONDITIONTYPE_NOT_SET.ordinal()] = 3;
} catch (NoSuchFieldError unused55) {
}
int[] iArr13 = new int[JsL.HBt.values().length];
$SwitchMap$com$google$firestore$v1$Write$OperationCase = iArr13;
try {
iArr13[JsL.HBt.UPDATE.ordinal()] = 1;
} catch (NoSuchFieldError unused56) {
}
try {
$SwitchMap$com$google$firestore$v1$Write$OperationCase[JsL.HBt.DELETE.ordinal()] = 2;
} catch (NoSuchFieldError unused57) {
}
try {
$SwitchMap$com$google$firestore$v1$Write$OperationCase[JsL.HBt.VERIFY.ordinal()] = 3;
} catch (NoSuchFieldError unused58) {
}
}
}
public final WatchChange decodeWatchChange(ZMV zmv) {
ZAx c;
WatchChange.WatchTargetChangeType watchTargetChangeType;
C13401fZd d;
Boy a;
YJK a2;
JBL b;
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$ListenResponse$ResponseTypeCase[ZMV.Sts.b(zmv.responseTypeCase_).ordinal()];
Status status = null;
if (i == 1) {
if (zmv.responseTypeCase_ == 2) {
c = (ZAx) zmv.responseType_;
} else {
c = ZAx.c();
}
int[] iArr = AnonymousClass1.$SwitchMap$com$google$firestore$v1$TargetChange$TargetChangeType;
ZAx.IeS e = ZAx.IeS.e(c.targetChangeType_);
if (e == null) {
e = ZAx.IeS.UNRECOGNIZED;
}
int i2 = iArr[e.ordinal()];
if (i2 == 1) {
watchTargetChangeType = WatchChange.WatchTargetChangeType.NoChange;
} else if (i2 == 2) {
watchTargetChangeType = WatchChange.WatchTargetChangeType.Added;
} else if (i2 == 3) {
watchTargetChangeType = WatchChange.WatchTargetChangeType.Removed;
NSZ nsz = c.cause_;
if (nsz == null) {
nsz = NSZ.e();
}
status = fromStatus(nsz);
} else if (i2 == 4) {
watchTargetChangeType = WatchChange.WatchTargetChangeType.Current;
} else if (i2 == 5) {
watchTargetChangeType = WatchChange.WatchTargetChangeType.Reset;
} else {
throw new IllegalArgumentException("Unknown target change type");
}
return new WatchChange.WatchTargetChange(watchTargetChangeType, c.targetIds_, c.resumeToken_, status);
}
if (i == 2) {
if (zmv.responseTypeCase_ == 3) {
d = (C13401fZd) zmv.responseType_;
} else {
d = C13401fZd.d();
}
MTP.Sts sts = d.targetIds_;
MTP.Sts sts2 = d.removedTargetIds_;
SPR spr = d.document_;
if (spr == null) {
spr = SPR.c();
}
DocumentKey decodeKey = decodeKey(spr.name_);
SPR spr2 = d.document_;
if (spr2 == null) {
spr2 = SPR.c();
}
AQX aqx = spr2.updateTime_;
if (aqx == null) {
aqx = AQX.c();
}
SnapshotVersion decodeVersion = decodeVersion(aqx);
Assert.hardAssert(!decodeVersion.equals(SnapshotVersion.NONE), "Got a document change without an update time", new Object[0]);
SPR spr3 = d.document_;
if (spr3 == null) {
spr3 = SPR.c();
}
MutableDocument newFoundDocument = MutableDocument.newFoundDocument(decodeKey, decodeVersion, ObjectValue.fromMap(Collections.unmodifiableMap(spr3.fields_)));
return new WatchChange.DocumentChange(sts, sts2, newFoundDocument.getKey(), newFoundDocument);
}
if (i == 3) {
if (zmv.responseTypeCase_ == 4) {
a = (Boy) zmv.responseType_;
} else {
a = Boy.a();
}
MTP.Sts sts3 = a.removedTargetIds_;
DocumentKey decodeKey2 = decodeKey(a.document_);
AQX aqx2 = a.readTime_;
if (aqx2 == null) {
aqx2 = AQX.c();
}
MutableDocument newNoDocument = MutableDocument.newNoDocument(decodeKey2, decodeVersion(aqx2));
return new WatchChange.DocumentChange(Collections.emptyList(), sts3, newNoDocument.getKey(), newNoDocument);
}
if (i == 4) {
if (zmv.responseTypeCase_ == 6) {
a2 = (YJK) zmv.responseType_;
} else {
a2 = YJK.a();
}
return new WatchChange.DocumentChange(Collections.emptyList(), a2.removedTargetIds_, decodeKey(a2.document_), null);
}
if (i == 5) {
if (zmv.responseTypeCase_ == 5) {
b = (JBL) zmv.responseType_;
} else {
b = JBL.b();
}
return new WatchChange.ExistenceFilterWatchChange(b.targetId_, new ExistenceFilter(b.count_));
}
throw new IllegalArgumentException("Unknown change type set");
}
public final SnapshotVersion decodeVersionFromListenResponse(ZMV zmv) {
ZAx c;
ZAx c2;
if (ZMV.Sts.b(zmv.responseTypeCase_) != ZMV.Sts.TARGET_CHANGE) {
return SnapshotVersion.NONE;
}
if (zmv.responseTypeCase_ == 2) {
c = (ZAx) zmv.responseType_;
} else {
c = ZAx.c();
}
if (c.targetIds_.size() != 0) {
return SnapshotVersion.NONE;
}
if (zmv.responseTypeCase_ == 2) {
c2 = (ZAx) zmv.responseType_;
} else {
c2 = ZAx.c();
}
AQX aqx = c2.readTime_;
if (aqx == null) {
aqx = AQX.c();
}
return decodeVersion(aqx);
}
private Status fromStatus(NSZ nsz) {
return Status.fromCodeValue(nsz.code_).withDescription(nsz.message_);
}
public final Mutation decodeMutation(JsL jsL) {
Precondition precondition;
SPR c;
SPR c2;
SPR c3;
SPR c4;
if (jsL.currentDocument_ != null) {
C10521eGo c10521eGo = jsL.currentDocument_;
if (c10521eGo == null) {
c10521eGo = C10521eGo.e();
}
precondition = decodePrecondition(c10521eGo);
} else {
precondition = Precondition.NONE;
}
Precondition precondition2 = precondition;
ArrayList arrayList = new ArrayList();
Iterator<veo.Sts> it = jsL.updateTransforms_.iterator();
while (it.hasNext()) {
arrayList.add(decodeFieldTransform(it.next()));
}
int i = AnonymousClass1.$SwitchMap$com$google$firestore$v1$Write$OperationCase[JsL.HBt.e(jsL.operationCase_).ordinal()];
if (i != 1) {
if (i == 2) {
return new DeleteMutation(decodeKey(jsL.operationCase_ == 2 ? (String) jsL.operation_ : ""), precondition2);
}
if (i == 3) {
return new VerifyMutation(decodeKey(jsL.operationCase_ == 5 ? (String) jsL.operation_ : ""), precondition2);
}
throw Assert.fail("Unknown mutation operation: %d", JsL.HBt.e(jsL.operationCase_));
}
if (jsL.updateMask_ != null) {
if (jsL.operationCase_ == 1) {
c3 = (SPR) jsL.operation_;
} else {
c3 = SPR.c();
}
DocumentKey decodeKey = decodeKey(c3.name_);
if (jsL.operationCase_ == 1) {
c4 = (SPR) jsL.operation_;
} else {
c4 = SPR.c();
}
ObjectValue fromMap = ObjectValue.fromMap(Collections.unmodifiableMap(c4.fields_));
Zhm zhm = jsL.updateMask_;
if (zhm == null) {
zhm = Zhm.a();
}
return new PatchMutation(decodeKey, fromMap, decodeDocumentMask(zhm), precondition2, arrayList);
}
if (jsL.operationCase_ == 1) {
c = (SPR) jsL.operation_;
} else {
c = SPR.c();
}
DocumentKey decodeKey2 = decodeKey(c.name_);
if (jsL.operationCase_ == 1) {
c2 = (SPR) jsL.operation_;
} else {
c2 = SPR.c();
}
return new SetMutation(decodeKey2, ObjectValue.fromMap(Collections.unmodifiableMap(c2.fields_)), precondition2, arrayList);
}
public final Target decodeQueryTarget(ksi.Sts sts) {
CoM e;
String str = sts.parent_;
if (sts.queryTypeCase_ == 2) {
e = (CoM) sts.queryType_;
} else {
e = CoM.e();
}
return decodeQueryTarget(str, e);
}
public final SnapshotVersion decodeVersion(AQX aqx) {
if (aqx.seconds_ == 0 && aqx.nanos_ == 0) {
return SnapshotVersion.NONE;
}
return new SnapshotVersion(decodeTimestamp(aqx));
}
public final String databaseName() {
return this.databaseName;
}
}