package androidx.room;

import android.os.RemoteException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import kotlin.Metadata;
import kotlin.collections.EmptySet;
import kotlin.collections.builders.SetBuilder;
import kotlin.jvm.internal.FunctionReferenceImpl;

/* JADX INFO: loaded from: classes.dex */
@Metadata(k = 3, mv = {2, 0, 0}, xi = 48)
final /* synthetic */ class InvalidationTracker$implementation$1 extends FunctionReferenceImpl implements sd.l {
    @Override // sd.l
    public final Object invoke(Object obj) {
        Collection collection;
        Set set = (Set) obj;
        nb.g.i(set, "p0");
        q qVar = (q) this.receiver;
        ReentrantLock reentrantLock = qVar.f4128g;
        reentrantLock.lock();
        try {
            List<y> listQ1 = kotlin.collections.n.q1(qVar.f4127f.values());
            reentrantLock.unlock();
            for (y yVar : listQ1) {
                yVar.getClass();
                int[] iArr = yVar.f4212b;
                int length = iArr.length;
                if (length == 0) {
                    collection = EmptySet.f29205a;
                } else if (length != 1) {
                    SetBuilder setBuilder = new SetBuilder();
                    int length2 = iArr.length;
                    int i10 = 0;
                    int i11 = 0;
                    while (i10 < length2) {
                        int i12 = i11 + 1;
                        if (set.contains(Integer.valueOf(iArr[i10]))) {
                            setBuilder.add(yVar.f4213c[i11]);
                        }
                        i10++;
                        i11 = i12;
                    }
                    setBuilder.g();
                    collection = setBuilder;
                } else {
                    collection = set.contains(Integer.valueOf(iArr[0])) ? yVar.f4214d : EmptySet.f29205a;
                }
                if (!collection.isEmpty()) {
                    s sVar = yVar.f4211a;
                    sVar.getClass();
                    u uVar = sVar.f4143b;
                    if (!uVar.f4161e.get()) {
                        try {
                            o oVar = uVar.f4163g;
                            if (oVar != null) {
                                oVar.z2(uVar.f4162f, (String[]) collection.toArray(new String[0]));
                            }
                        } catch (RemoteException unused) {
                        }
                    }
                }
            }
            return kd.e.f29109a;
        } catch (Throwable th) {
            reentrantLock.unlock();
            throw th;
        }
    }
}
