package com.facebook.shimmer;

import android.content.res.TypedArray;
import android.graphics.RectF;
import defpackage.n41;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/* JADX INFO: loaded from: classes.dex */
public class b {
    public final float[] a = new float[4];
    public final int[] b = new int[4];
    public int c;
    public int d;
    public int e;
    public int f;
    public int g;
    public int h;
    public float i;
    public float j;
    public float k;
    public float l;
    public float m;
    public boolean n;
    public boolean o;
    public boolean p;
    public int q;
    public int r;
    public long s;
    public long t;

    public static class a extends AbstractC0083b<a> {
        public a() {
            this.a.p = true;
        }

        @Override // com.facebook.shimmer.b.AbstractC0083b
        public final AbstractC0083b c() {
            return this;
        }
    }

    /* JADX INFO: renamed from: com.facebook.shimmer.b$b, reason: collision with other inner class name */
    public static abstract class AbstractC0083b<T extends AbstractC0083b<T>> {
        public final b a = new b();

        public final b a() {
            b bVar = this.a;
            int[] iArr = bVar.b;
            int i = bVar.f;
            if (i != 1) {
                int i2 = bVar.e;
                iArr[0] = i2;
                int i3 = bVar.d;
                iArr[1] = i3;
                iArr[2] = i3;
                iArr[3] = i2;
            } else {
                int i4 = bVar.d;
                iArr[0] = i4;
                iArr[1] = i4;
                int i5 = bVar.e;
                iArr[2] = i5;
                iArr[3] = i5;
            }
            float[] fArr = bVar.a;
            if (i != 1) {
                fArr[0] = Math.max(((1.0f - bVar.k) - bVar.l) / 2.0f, 0.0f);
                fArr[1] = Math.max(((1.0f - bVar.k) - 0.001f) / 2.0f, 0.0f);
                fArr[2] = Math.min(((bVar.k + 1.0f) + 0.001f) / 2.0f, 1.0f);
                fArr[3] = Math.min(((bVar.k + 1.0f) + bVar.l) / 2.0f, 1.0f);
                return bVar;
            }
            fArr[0] = 0.0f;
            fArr[1] = Math.min(bVar.k, 1.0f);
            fArr[2] = Math.min(bVar.k + bVar.l, 1.0f);
            fArr[3] = 1.0f;
            return bVar;
        }

        public AbstractC0083b b(TypedArray typedArray) {
            boolean zHasValue = typedArray.hasValue(3);
            b bVar = this.a;
            if (zHasValue) {
                bVar.n = typedArray.getBoolean(3, bVar.n);
            }
            if (typedArray.hasValue(0)) {
                bVar.o = typedArray.getBoolean(0, bVar.o);
            }
            if (typedArray.hasValue(1)) {
                d(typedArray.getFloat(1, 0.3f));
            }
            if (typedArray.hasValue(11)) {
                g(typedArray.getFloat(11, 1.0f));
            }
            if (typedArray.hasValue(7)) {
                f(typedArray.getInt(7, (int) bVar.s));
            }
            if (typedArray.hasValue(14)) {
                bVar.q = typedArray.getInt(14, bVar.q);
            }
            if (typedArray.hasValue(15)) {
                long j = typedArray.getInt(15, (int) bVar.t);
                if (j < 0) {
                    throw new IllegalArgumentException(n41.j(j, "Given a negative repeat delay: "));
                }
                bVar.t = j;
            }
            if (typedArray.hasValue(16)) {
                bVar.r = typedArray.getInt(16, bVar.r);
            }
            if (typedArray.hasValue(5)) {
                int i = typedArray.getInt(5, bVar.c);
                if (i == 1) {
                    e(1);
                } else if (i == 2) {
                    e(2);
                } else if (i != 3) {
                    e(0);
                } else {
                    e(3);
                }
            }
            if (typedArray.hasValue(17)) {
                if (typedArray.getInt(17, bVar.f) != 1) {
                    bVar.f = 0;
                } else {
                    bVar.f = 1;
                }
            }
            if (typedArray.hasValue(6)) {
                float f = typedArray.getFloat(6, bVar.l);
                if (f < 0.0f) {
                    throw new IllegalArgumentException("Given invalid dropoff value: " + f);
                }
                bVar.l = f;
            }
            if (typedArray.hasValue(9)) {
                int dimensionPixelSize = typedArray.getDimensionPixelSize(9, bVar.g);
                if (dimensionPixelSize < 0) {
                    throw new IllegalArgumentException(n41.k("Given invalid width: ", dimensionPixelSize));
                }
                bVar.g = dimensionPixelSize;
            }
            if (typedArray.hasValue(8)) {
                int dimensionPixelSize2 = typedArray.getDimensionPixelSize(8, bVar.h);
                if (dimensionPixelSize2 < 0) {
                    throw new IllegalArgumentException(n41.k("Given invalid height: ", dimensionPixelSize2));
                }
                bVar.h = dimensionPixelSize2;
            }
            if (typedArray.hasValue(13)) {
                float f2 = typedArray.getFloat(13, bVar.k);
                if (f2 < 0.0f) {
                    throw new IllegalArgumentException("Given invalid intensity value: " + f2);
                }
                bVar.k = f2;
            }
            if (typedArray.hasValue(19)) {
                float f3 = typedArray.getFloat(19, bVar.i);
                if (f3 < 0.0f) {
                    throw new IllegalArgumentException("Given invalid width ratio: " + f3);
                }
                bVar.i = f3;
            }
            if (typedArray.hasValue(10)) {
                float f4 = typedArray.getFloat(10, bVar.j);
                if (f4 < 0.0f) {
                    throw new IllegalArgumentException("Given invalid height ratio: " + f4);
                }
                bVar.j = f4;
            }
            if (typedArray.hasValue(18)) {
                bVar.m = typedArray.getFloat(18, bVar.m);
            }
            return c();
        }

        public abstract AbstractC0083b c();

        public final AbstractC0083b d(float f) {
            int iMin = ((int) (Math.min(1.0f, Math.max(0.0f, f)) * 255.0f)) << 24;
            b bVar = this.a;
            bVar.e = iMin | (bVar.e & 16777215);
            return c();
        }

        public final AbstractC0083b e(int i) {
            this.a.c = i;
            return c();
        }

        public final AbstractC0083b f(long j) {
            if (j < 0) {
                throw new IllegalArgumentException(n41.j(j, "Given a negative duration: "));
            }
            this.a.s = j;
            return c();
        }

        public final AbstractC0083b g(float f) {
            int iMin = ((int) (Math.min(1.0f, Math.max(0.0f, f)) * 255.0f)) << 24;
            b bVar = this.a;
            bVar.d = iMin | (bVar.d & 16777215);
            return c();
        }
    }

    public static class c extends AbstractC0083b<c> {
        @Override // com.facebook.shimmer.b.AbstractC0083b
        public final AbstractC0083b b(TypedArray typedArray) {
            super.b(typedArray);
            boolean zHasValue = typedArray.hasValue(2);
            b bVar = this.a;
            if (zHasValue) {
                bVar.e = (typedArray.getColor(2, bVar.e) & 16777215) | (bVar.e & (-16777216));
            }
            if (typedArray.hasValue(12)) {
                bVar.d = typedArray.getColor(12, bVar.d);
            }
            return this;
        }

        @Override // com.facebook.shimmer.b.AbstractC0083b
        public final AbstractC0083b c() {
            return this;
        }
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface d {
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface e {
    }

    public b() {
        new RectF();
        this.c = 0;
        this.d = -1;
        this.e = 1291845631;
        this.f = 0;
        this.g = 0;
        this.h = 0;
        this.i = 1.0f;
        this.j = 1.0f;
        this.k = 0.0f;
        this.l = 0.5f;
        this.m = 20.0f;
        this.n = true;
        this.o = true;
        this.p = true;
        this.q = -1;
        this.r = 1;
        this.s = 1000L;
    }
}
