package com.bytedance.android.live.slot;

import X.6Is;
import X.7he;
import X.AnonymousClass0CB;
import X.AnonymousClass0CH;
import X.AnonymousClass0CN;
import X.AnonymousClass14K;
import X.AnonymousClass14N;
import X.AnonymousClass14O;
import X.C13960hO;
import X.C265514b;
import X.C265614c;
import X.C265814e;
import X.C266114h;
import X.C267814y;
import X.C38101fE;
import X.C39401hK;
import X.C530327x;
import X.C530427y;
import X.Crj;
import X.M12;
import android.content.Context;
import android.os.Bundle;
import com.bytedance.android.live.slot.IFrameSlot;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.PriorityBlockingQueue;
import kotlin.h.b.n;

public final class FreeFrameSlotController implements 6Is {
    public DataChannel LIZ;
    public final Crj LIZIZ = 7he.LIZ(new C530427y(this));
    public final C39401hK LIZJ;
    public AnonymousClass14N LIZLLL;
    public Queue<C266114h> LJ;
    public final Crj LJFF = 7he.LIZ(C530327x.LIZ);

    static {
        Covode.recordClassIndex(10580);
    }

    private final HashMap<String, Object> LIZ() {
        return (HashMap) this.LJFF.getValue();
    }

    public final void onStateChanged(AnonymousClass0CH r2, AnonymousClass0CB r3) {
        if (r3 == AnonymousClass0CB.ON_CREATE) {
            onCreate();
        } else if (r3 == AnonymousClass0CB.ON_START) {
            onStart();
        } else if (r3 == AnonymousClass0CB.ON_RESUME) {
            onResume();
        } else if (r3 == AnonymousClass0CB.ON_PAUSE) {
            onPause();
        } else if (r3 == AnonymousClass0CB.ON_STOP) {
            onStop();
        } else if (r3 == AnonymousClass0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_DESTROY)
    public final void onDestroy() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LJII();
            }
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_PAUSE)
    public final void onPause() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LJ();
            }
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_RESUME)
    public final void onResume() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LIZLLL();
            }
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_START)
    public final void onStart() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LJFF();
            }
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_STOP)
    public final void onStop() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LJI();
            }
        }
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_CREATE)
    public final void onCreate() {
        Queue<C266114h> queue = this.LJ;
        if (queue != null) {
            for (C266114h r1 : queue) {
                n.LIZIZ(r1, "");
                r1.LIZIZ.LIZ(new Bundle());
            }
        }
    }

    public final void LIZ(AnonymousClass14O r6) {
        M12.LIZ(r6);
        this.LJ = new PriorityBlockingQueue(3, AnonymousClass14K.LIZ);
        List<C265814e> LIZ2 = C13960hO.LIZ().LIZ(AnonymousClass14O.SLOT_LIVE_FREE_FRAME);
        if (LIZ2 != null) {
            for (C265814e r0 : LIZ2) {
                C267814y r2 = r0.LIZIZ;
                n.LIZIZ(r2, "");
                C265614c<IFrameSlot, IFrameSlot.SlotViewModel, AnonymousClass14O> LIZ3 = r2.LIZ((Context) this.LIZJ, r6);
                if (LIZ3 != null) {
                    n.LIZIZ(LIZ3, "");
                    C266114h r22 = new C266114h();
                    r22.LIZIZ = LIZ3;
                    Queue<C266114h> queue = this.LJ;
                    if (queue != null) {
                        queue.offer(r22);
                    }
                    LIZ3.LIZ((Map<String, Object>) LIZ(), (C265514b) new C38101fE(this, r22, LIZ3));
                }
            }
        }
    }

    public final void LIZ(String str, Object obj) {
        LIZ().put(str, obj);
    }

    public FreeFrameSlotController(C39401hK r2, AnonymousClass14N r3) {
        M12.LIZ(r2, r3);
        this.LIZJ = r2;
        this.LIZLLL = r3;
    }
}
