package c0;

import a.AbstractC0386a;
import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/* JADX INFO: renamed from: c0.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0572i {
    public static final Object i = new Object();

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static volatile C0572i f9288j;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ReentrantReadWriteLock f9289a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final q.f f9290b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public volatile int f9291c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Handler f9292d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final C0569f f9293e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final InterfaceC0571h f9294f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final int f9295g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final C0567d f9296h;

    public C0572i(o oVar) {
        ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock();
        this.f9289a = reentrantReadWriteLock;
        this.f9291c = 3;
        InterfaceC0571h interfaceC0571h = (InterfaceC0571h) oVar.f4479b;
        this.f9294f = interfaceC0571h;
        int i5 = oVar.f4478a;
        this.f9295g = i5;
        this.f9296h = (C0567d) oVar.f4480c;
        this.f9292d = new Handler(Looper.getMainLooper());
        this.f9290b = new q.f(0);
        C0569f c0569f = new C0569f(this);
        this.f9293e = c0569f;
        reentrantReadWriteLock.writeLock().lock();
        if (i5 == 0) {
            try {
                this.f9291c = 0;
            } catch (Throwable th) {
                this.f9289a.writeLock().unlock();
                throw th;
            }
        }
        reentrantReadWriteLock.writeLock().unlock();
        if (b() == 0) {
            try {
                interfaceC0571h.a(new C0568e(c0569f));
            } catch (Throwable th2) {
                d(th2);
            }
        }
    }

    public static C0572i a() {
        C0572i c0572i;
        synchronized (i) {
            try {
                c0572i = f9288j;
                if (!(c0572i != null)) {
                    throw new IllegalStateException("EmojiCompat is not initialized.\n\nYou must initialize EmojiCompat prior to referencing the EmojiCompat instance.\n\nThe most likely cause of this error is disabling the EmojiCompatInitializer\neither explicitly in AndroidManifest.xml, or by including\nandroidx.emoji2:emoji2-bundled.\n\nAutomatic initialization is typically performed by EmojiCompatInitializer. If\nyou are not expecting to initialize EmojiCompat manually in your application,\nplease check to ensure it has not been removed from your APK's manifest. You can\ndo this in Android Studio using Build > Analyze APK.\n\nIn the APK Analyzer, ensure that the startup entry for\nEmojiCompatInitializer and InitializationProvider is present in\n AndroidManifest.xml. If it is missing or contains tools:node=\"remove\", and you\nintend to use automatic configuration, verify:\n\n  1. Your application does not include emoji2-bundled\n  2. All modules do not contain an exclusion manifest rule for\n     EmojiCompatInitializer or InitializationProvider. For more information\n     about manifest exclusions see the documentation for the androidx startup\n     library.\n\nIf you intend to use emoji2-bundled, please call EmojiCompat.init. You can\nlearn more in the documentation for BundledEmojiCompatConfig.\n\nIf you intended to perform manual configuration, it is recommended that you call\nEmojiCompat.init immediately on application startup.\n\nIf you still cannot resolve this issue, please open a bug with your specific\nconfiguration to help improve error message.");
                }
            } finally {
            }
        }
        return c0572i;
    }

    public final int b() {
        this.f9289a.readLock().lock();
        try {
            return this.f9291c;
        } finally {
            this.f9289a.readLock().unlock();
        }
    }

    public final void c() {
        if (!(this.f9295g == 1)) {
            throw new IllegalStateException("Set metadataLoadStrategy to LOAD_STRATEGY_MANUAL to execute manual loading");
        }
        if (b() == 1) {
            return;
        }
        this.f9289a.writeLock().lock();
        try {
            if (this.f9291c == 0) {
                return;
            }
            this.f9291c = 0;
            this.f9289a.writeLock().unlock();
            C0569f c0569f = this.f9293e;
            C0572i c0572i = (C0572i) c0569f.f9287c;
            try {
                c0572i.f9294f.a(new C0568e(c0569f));
            } catch (Throwable th) {
                c0572i.d(th);
            }
        } finally {
            this.f9289a.writeLock().unlock();
        }
    }

    public final void d(Throwable th) {
        ArrayList arrayList = new ArrayList();
        this.f9289a.writeLock().lock();
        try {
            this.f9291c = 2;
            arrayList.addAll(this.f9290b);
            this.f9290b.clear();
            this.f9289a.writeLock().unlock();
            this.f9292d.post(new J.a(arrayList, this.f9291c, th));
        } catch (Throwable th2) {
            this.f9289a.writeLock().unlock();
            throw th2;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x0096 A[Catch: all -> 0x0078, TryCatch #0 {all -> 0x0078, blocks: (B:32:0x005c, B:35:0x0061, B:37:0x0065, B:39:0x0072, B:44:0x0085, B:46:0x008f, B:48:0x0092, B:50:0x0096, B:52:0x00a6, B:53:0x00a9, B:55:0x00b6, B:58:0x00be, B:63:0x00dd, B:69:0x00e9, B:72:0x00f7, B:73:0x0101, B:74:0x0112, B:76:0x0119, B:77:0x011e, B:79:0x0129, B:81:0x0130, B:83:0x0134, B:85:0x013c, B:87:0x0140, B:90:0x0148, B:93:0x0156, B:94:0x015b, B:96:0x016b, B:42:0x007b), top: B:115:0x005c }] */
    /*  JADX ERROR: JadxRuntimeException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Not found exit edge by exit block: B:61:0x00d9
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.checkLoopExits(LoopRegionMaker.java:226)
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.makeLoopRegion(LoopRegionMaker.java:196)
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.process(LoopRegionMaker.java:63)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:89)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.makeEndlessLoop(LoopRegionMaker.java:282)
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.process(LoopRegionMaker.java:65)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:89)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:102)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:102)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.IfRegionMaker.process(IfRegionMaker.java:96)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:106)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeMthRegion(RegionMaker.java:48)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:25)
        */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final java.lang.CharSequence e(java.lang.CharSequence r12, int r13, int r14) {
        /*
            Method dump skipped, instruction units count: 418
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c0.C0572i.e(java.lang.CharSequence, int, int):java.lang.CharSequence");
    }

    public final void f(AbstractC0570g abstractC0570g) {
        AbstractC0386a.j(abstractC0570g, "initCallback cannot be null");
        this.f9289a.writeLock().lock();
        try {
            if (this.f9291c == 1 || this.f9291c == 2) {
                this.f9292d.post(new J.a(Arrays.asList(abstractC0570g), this.f9291c, (Throwable) null));
            } else {
                this.f9290b.add(abstractC0570g);
            }
            this.f9289a.writeLock().unlock();
        } catch (Throwable th) {
            this.f9289a.writeLock().unlock();
            throw th;
        }
    }
}
