package o;

import android.content.Context;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.os.Build;
import android.util.Log;
import com.google.android.gms.common.util.concurrent.NamedThreadFactory;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Ew0 {
    public static Ew0 e;
    public int a = 3;
    public Object b;
    public Object c;
    public Object d;

    public Ew0(Paint paint) {
        this.b = paint;
    }

    public static synchronized Ew0 l(Context context) {
        try {
            if (e == null) {
                ScheduledExecutorService scheduledExecutorServiceUnconfigurableScheduledExecutorService = Executors.unconfigurableScheduledExecutorService(Executors.newScheduledThreadPool(1, new NamedThreadFactory("MessengerIpcClient")));
                Ew0 ew0 = new Ew0();
                ew0.d = new Tu0(ew0);
                ew0.a = 1;
                ew0.c = scheduledExecutorServiceUnconfigurableScheduledExecutorService;
                ew0.b = context.getApplicationContext();
                e = ew0;
            }
        } catch (Throwable th) {
            throw th;
        }
        return e;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [java.lang.Object, java.util.Collection, java.util.List] */
    public void a(CX cx, boolean z) {
        NX nx = (NX) this.d;
        ?? r1 = cx.a;
        int size = r1.size();
        for (int i = 0; i < size; i++) {
            if (((IX) r1.get(i)).b()) {
                k(cx);
                return;
            }
        }
        InterfaceC1184fK interfaceC1184fK = (InterfaceC1184fK) this.b;
        if (interfaceC1184fK == null) {
            throw new IllegalStateException("layoutCoordinates not set");
        }
        C1884mi0.N(cx, interfaceC1184fK.L(0L), new K3(13, this, nx), false);
        if (this.a == 2) {
            if (z) {
                int size2 = r1.size();
                for (int i2 = 0; i2 < size2; i2++) {
                    ((IX) r1.get(i2)).a();
                }
            }
            C2513tI c2513tI = cx.b;
            if (c2513tI != null) {
                c2513tI.b = !nx.c;
            }
        }
    }

    public int b() {
        Paint.Cap strokeCap = ((Paint) this.b).getStrokeCap();
        int i = strokeCap == null ? -1 : I4.a[strokeCap.ordinal()];
        if (i == 1) {
            return 0;
        }
        if (i != 2) {
            return i != 3 ? 0 : 2;
        }
        return 1;
    }

    public int c() {
        Paint.Join strokeJoin = ((Paint) this.b).getStrokeJoin();
        int i = strokeJoin == null ? -1 : I4.b[strokeJoin.ordinal()];
        if (i == 1) {
            return 0;
        }
        if (i != 2) {
            return i != 3 ? 0 : 1;
        }
        return 2;
    }

    public void d(float f) {
        ((Paint) this.b).setAlpha((int) Math.rint(f * 255.0f));
    }

    public void e(int i) {
        if (this.a == i) {
            return;
        }
        this.a = i;
        Paint paint = (Paint) this.b;
        if (Build.VERSION.SDK_INT >= 29) {
            paint.setBlendMode(AbstractC1692kh0.O(i));
        } else {
            paint.setXfermode(new PorterDuffXfermode(AbstractC1692kh0.R(i)));
        }
    }

    public void f(long j) {
        ((Paint) this.b).setColor(AbstractC0752ap.g0(j));
    }

    public void g(C0444Rd c0444Rd) {
        this.d = c0444Rd;
        ((Paint) this.b).setColorFilter(c0444Rd != null ? c0444Rd.a : null);
    }

    public void h(int i) {
        ((Paint) this.b).setStrokeCap(i == 2 ? Paint.Cap.SQUARE : i == 1 ? Paint.Cap.ROUND : i == 0 ? Paint.Cap.BUTT : Paint.Cap.BUTT);
    }

    public void i(int i) {
        ((Paint) this.b).setStrokeJoin(i == 0 ? Paint.Join.MITER : i == 2 ? Paint.Join.BEVEL : i == 1 ? Paint.Join.ROUND : Paint.Join.MITER);
    }

    public void j(int i) {
        ((Paint) this.b).setStyle(i == 1 ? Paint.Style.STROKE : Paint.Style.FILL);
    }

    public void k(CX cx) {
        if (this.a == 2) {
            InterfaceC1184fK interfaceC1184fK = (InterfaceC1184fK) this.b;
            if (interfaceC1184fK == null) {
                throw new IllegalStateException("layoutCoordinates not set");
            }
            C1884mi0.N(cx, interfaceC1184fK.L(0L), new C2769w(25, (NX) this.d), true);
        }
        this.a = 3;
    }

    public synchronized Hw0 m(jw0 jw0Var) {
        try {
            if (Log.isLoggable("MessengerIpcClient", 3)) {
                "Queueing ".concat(jw0Var.toString());
            }
            if (!((Tu0) this.d).d(jw0Var)) {
                Tu0 tu0 = new Tu0(this);
                this.d = tu0;
                tu0.d(jw0Var);
            }
        } catch (Throwable th) {
            throw th;
        }
        return jw0Var.b.a;
    }
}
