package com.ss.android.ugc.aweme.ecommerce.address.list;

import X.0CB;
import X.0CH;
import X.2k0;
import X.3Ct;
import X.5An;
import X.6Is;
import X.7XD;
import X.BJ3;
import X.BTH;
import X.C3400BIu;
import X.C42;
import X.C43;
import X.C45;
import X.C46;
import X.C48;
import X.C49;
import X.C5543C3f;
import X.C5544C3g;
import X.C5545C3h;
import X.C5546C3i;
import X.C5547C3j;
import X.C5549C3l;
import X.C5563C3z;
import X.Crj;
import X.DrK;
import X.DrS;
import X.LsD;
import X.M12;
import X.Qeg;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.bytedance.jedi.ext.adapter.JediViewHolder;
import com.ss.android.ugc.aweme.ecommerce.address.dto.Address;
import com.ss.android.ugc.aweme.ecommerce.delivery.repo.dto.ReachableAddress;
import java.util.LinkedHashMap;
import java.util.Objects;
import kotlin.h.b.n;

public final class AddressAdapter extends DrS<Object> {
    public final 0CH LIZLLL;

    static {
        Covode.recordClassIndex(68220);
    }

    public final class AddAddressBarHolder extends JediSimpleViewHolder<C5549C3l> implements 6Is {
        public final Crj LJFF;
        public final /* synthetic */ AddressAdapter LJI;

        static {
            Covode.recordClassIndex(68221);
        }

        public final void onStateChanged(0CH r1, 0CB r2) {
            super.onStateChanged(r1, r2);
        }

        public final void LJ() {
            AddressAdapter.super.LJ();
            View view = this.itemView;
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            view.setBackground(3Ct.LIZLLL(view2.getContext()));
        }

        /* JADX WARNING: type inference failed for: r0v4, types: [X.BIu, android.view.View$OnClickListener] */
        public final /* synthetic */ void LIZ(Object obj) {
            M12.LIZ(obj);
            BJ3 bj3 = BTH.LIZLLL;
            View view = this.itemView;
            n.LIZIZ(view, "");
            boolean z = true;
            if (this.LJIIIIZZ == this.LJI.getItemCount() - 1) {
                z = false;
            }
            bj3.LIZ(view, z);
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            view2.setOnClickListener(new C3400BIu(this));
        }

        /* JADX WARNING: Illegal instructions before constructor call */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public AddAddressBarHolder(com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter r4, android.view.ViewGroup r5) {
            /*
                r3 = this;
                X.M12.LIZ(r5)
                r3.LJI = r4
                android.content.Context r0 = r5.getContext()
                android.view.LayoutInflater r2 = android.view.LayoutInflater.from(r0)
                r1 = 2131558994(0x7f0d0252, float:1.874332E38)
                r0 = 0
                android.view.View r1 = X.0HH.LIZ(r2, r1, r5, r0)
                java.lang.String r0 = ""
                kotlin.h.b.n.LIZIZ(r1, r0)
                r3.<init>(r1)
                java.lang.Class<com.ss.android.ugc.aweme.ecommerce.address.list.AddressListViewModel> r1 = com.ss.android.ugc.aweme.ecommerce.address.list.AddressListViewModel.class
                X.KEN r0 = X.KEM.LIZ
                X.D1G r1 = r0.LIZ(r1)
                X.BIh r0 = new X.BIh
                r0.<init>(r3, r1, r1)
                X.Crj r0 = X.7he.LIZ(r0)
                r3.LJFF = r0
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter.AddAddressBarHolder.<init>(com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter, android.view.ViewGroup):void");
        }
    }

    public final int getBasicItemViewType(int i) {
        return this.LIZ.LIZIZ(i);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public AddressAdapter(0CH r3) {
        super(r3, new C5547C3j(), 4);
        M12.LIZ(r3);
        this.LIZLLL = r3;
    }

    public final void LIZ(DrK<JediViewHolder<? extends 5An, ?>> drK) {
        M12.LIZ(drK);
        DrK unused = drK.LIZ(new C5545C3h(this), (LsD) null, new C5544C3g(this));
        DrK unused2 = drK.LIZ(new C5546C3i(this), (LsD) null, new C5543C3f(this));
    }

    public final class AddressViewHolder extends JediSimpleViewHolder<ReachableAddress> implements 6Is {
        public final /* synthetic */ AddressAdapter LJFF;
        public final Crj LJI;

        static {
            Covode.recordClassIndex(68224);
        }

        public final AddressListViewModel LJIIL() {
            return (AddressListViewModel) this.LJI.getValue();
        }

        public final void onStateChanged(0CH r1, 0CB r2) {
            super.onStateChanged(r1, r2);
        }

        /* JADX WARNING: type inference failed for: r4v1, types: [X.C3z, android.view.View] */
        /* JADX WARNING: type inference failed for: r0v38, types: [android.view.View$OnClickListener, X.C49] */
        /* JADX WARNING: type inference failed for: r0v44, types: [X.C46, android.view.View$OnClickListener] */
        /* JADX WARNING: type inference failed for: r0v45, types: [android.view.View$OnClickListener, X.C48] */
        /* JADX WARNING: type inference failed for: r0v46, types: [X.C43, android.view.View$OnClickListener] */
        /* JADX WARNING: type inference failed for: r0v56, types: [X.C45, android.view.View$OnClickListener] */
        public final /* synthetic */ void LIZ(Object obj) {
            boolean z;
            int i;
            boolean z2;
            String str;
            ReachableAddress reachableAddress = (ReachableAddress) obj;
            M12.LIZ(reachableAddress);
            BJ3 bj3 = BTH.LIZLLL;
            View view = this.itemView;
            n.LIZIZ(view, "");
            if (this.LJIIIIZZ != this.LJFF.getItemCount() - 1) {
                z = true;
            } else {
                z = false;
            }
            bj3.LIZ(view, z);
            View view2 = this.itemView;
            Objects.requireNonNull(view2, "null cannot be cast to non-null type com.ss.android.ugc.aweme.ecommerce.widget.AddressInfoCard");
            ? r4 = (C5563C3z) view2;
            r4.setUiMode("show_all");
            r4.setHasPrefix(false);
            if (LJIIL().LIZLLL()) {
                i = 3;
            } else {
                i = 1;
            }
            r4.setSuffixType(i);
            if (reachableAddress.LIZ || LJIIL().LJFF == null) {
                z2 = true;
            } else {
                z2 = false;
            }
            r4.setReachable(z2);
            if (n.LIZ(reachableAddress.LIZLLL, false)) {
                str = reachableAddress.LIZJ;
            } else {
                str = "";
            }
            r4.setHintText(str);
            r4.setPaddingVertical(22);
            Address address = reachableAddress.LIZIZ;
            if (address != null) {
                withState(LJIIL(), new C42(address, r4, this, reachableAddress));
                String LIZ = address.LIZ("name");
                if (LIZ == null) {
                    LIZ = "";
                }
                r4.setNameText(LIZ);
                String LIZ2 = address.LIZ("phone");
                if (LIZ2 == null) {
                    LIZ2 = "";
                }
                r4.setPhoneText(LIZ2);
                String LIZ3 = address.LIZ("email");
                if (LIZ3 == null) {
                    LIZ3 = "";
                }
                r4.setEmailText(LIZ3);
                r4.setAddressDetailText(address.LIZIZ());
                r4.setRegionText(Address.LIZ(address));
                String LIZ4 = address.LIZ("zipcode");
                if (LIZ4 == null) {
                    LIZ4 = "";
                }
                r4.setZipcodeText(LIZ4);
                r4.setDefault(address.LIZ());
                if (LJIIL().LIZLLL()) {
                    r4.setOnClickListener(new C45(address, r4, this, reachableAddress));
                } else {
                    if (r4.getReachable()) {
                        AddressListViewModel LJIIL = LJIIL();
                        if (((Boolean) LJIIL.LIZIZ.LIZ(LJIIL, AddressListViewModel.LIZ[0])).booleanValue()) {
                            r4.setOnClickListener(new C43(address, r4, this, reachableAddress));
                        } else {
                            r4.setOnClickListener(new C46(address, r4, this, reachableAddress));
                        }
                        Qeg LIZ5 = r4.LIZ(2131364360);
                        n.LIZIZ(LIZ5, "");
                        LIZ5.setOnClickListener(new C48(address, r4, this, reachableAddress));
                    }
                    Qeg LIZ6 = r4.LIZ(2131364360);
                    n.LIZIZ(LIZ6, "");
                    LIZ6.setOnClickListener(new C49(address, r4, this, reachableAddress));
                }
                boolean LIZ7 = address.LIZ();
                int i2 = this.LJIIIIZZ - 1;
                Boolean bool = reachableAddress.LIZLLL;
                2k0 r3 = 2k0.LIZ;
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                linkedHashMap.putAll(7XD.LIZ);
                linkedHashMap.put("EVENT_ORIGIN_FEATURE", "TEMAI");
                linkedHashMap.put("page_name", "shipping_info");
                linkedHashMap.put("module_name", "address");
                if (bool != null) {
                    bool.booleanValue();
                    linkedHashMap.put("is_valid", Integer.valueOf(bool.booleanValue() ? 1 : 0));
                }
                linkedHashMap.put("is_default", Integer.valueOf(LIZ7 ? 1 : 0));
                linkedHashMap.put("rank", Integer.valueOf(i2));
                r3.LIZ("tiktokec_module_show", linkedHashMap);
            }
        }

        /* JADX WARNING: type inference failed for: r3v0, types: [X.C3z, android.view.View] */
        /* JADX WARNING: Illegal instructions before constructor call */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public AddressViewHolder(com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter r5, android.view.ViewGroup r6) {
            /*
                r4 = this;
                X.M12.LIZ(r6)
                r4.LJFF = r5
                X.C3z r3 = new X.C3z
                android.content.Context r2 = r6.getContext()
                java.lang.String r0 = ""
                kotlin.h.b.n.LIZIZ(r2, r0)
                r1 = 0
                r0 = 6
                r3.<init>((android.content.Context) r2, (android.util.AttributeSet) r1, (int) r0)
                r4.<init>(r3)
                java.lang.Class<com.ss.android.ugc.aweme.ecommerce.address.list.AddressListViewModel> r1 = com.ss.android.ugc.aweme.ecommerce.address.list.AddressListViewModel.class
                X.KEN r0 = X.KEM.LIZ
                X.D1G r1 = r0.LIZ(r1)
                X.BIi r0 = new X.BIi
                r0.<init>(r4, r1, r1)
                X.Crj r0 = X.7he.LIZ(r0)
                r4.LJI = r0
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter.AddressViewHolder.<init>(com.ss.android.ugc.aweme.ecommerce.address.list.AddressAdapter, android.view.ViewGroup):void");
        }

        public final void LIZ(boolean z, String str) {
            int i = this.LJIIIIZZ - 1;
            Boolean bool = ((ReachableAddress) LJIIJJI()).LIZLLL;
            M12.LIZ(str);
            2k0 r3 = 2k0.LIZ;
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            linkedHashMap.putAll(7XD.LIZ);
            linkedHashMap.put("EVENT_ORIGIN_FEATURE", "TEMAI");
            linkedHashMap.put("page_name", "shipping_info");
            linkedHashMap.put("module_name", "address");
            if (bool != null) {
                bool.booleanValue();
                linkedHashMap.put("is_valid", Integer.valueOf(bool.booleanValue() ? 1 : 0));
            }
            linkedHashMap.put("is_default", Integer.valueOf(z ? 1 : 0));
            linkedHashMap.put("rank", Integer.valueOf(i));
            linkedHashMap.put("click_area", str);
            r3.LIZ("tiktokec_module_click", linkedHashMap);
        }
    }
}
