package com.bytedance.vmsdk.jsbridge;

import X.C4259Lh4;
import X.LCG;
import com.bytedance.covode.number.Covode;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class JSModuleWrapper {
    public final JSModule LIZ;
    public final ArrayList<MethodDescriptor> LIZIZ = new ArrayList<>();
    public final ArrayList<AttributeDescriptor> LIZJ = new ArrayList<>();
    public final String LIZLLL;

    static {
        Covode.recordClassIndex(40221);
    }

    public JSModule getModule() {
        return this.LIZ;
    }

    public String getName() {
        return this.LIZLLL;
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(6:9|10|11|12|13|22) */
    /* JADX WARNING: Missing exception handler attribute for start block: B:12:0x004d */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public java.util.Collection<com.bytedance.vmsdk.jsbridge.AttributeDescriptor> getAttributeDescriptor() {
        /*
            r9 = this;
            java.util.ArrayList<com.bytedance.vmsdk.jsbridge.AttributeDescriptor> r0 = r9.LIZJ
            boolean r0 = r0.isEmpty()
            if (r0 == 0) goto L_0x0075
            java.util.HashSet r8 = new java.util.HashSet     // Catch:{ RuntimeException -> 0x0075 }
            r8.<init>()     // Catch:{ RuntimeException -> 0x0075 }
            com.bytedance.vmsdk.jsbridge.JSModule r0 = r9.LIZ     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.Class r0 = r0.getClass()     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.reflect.Field[] r7 = r0.getDeclaredFields()     // Catch:{ RuntimeException -> 0x0075 }
            int r6 = r7.length     // Catch:{ RuntimeException -> 0x0075 }
            r5 = 0
        L_0x0019:
            if (r5 >= r6) goto L_0x0075
            r4 = r7[r5]     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.Class<X.Lh6> r0 = X.C4261Lh6.class
            java.lang.annotation.Annotation r0 = r4.getAnnotation(r0)     // Catch:{ RuntimeException -> 0x0075 }
            X.Lh6 r0 = (X.C4261Lh6) r0     // Catch:{ RuntimeException -> 0x0075 }
            if (r0 == 0) goto L_0x0052
            java.lang.String r3 = r4.getName()     // Catch:{ RuntimeException -> 0x0075 }
            boolean r0 = r8.contains(r3)     // Catch:{ RuntimeException -> 0x0075 }
            if (r0 != 0) goto L_0x0055
            r8.add(r3)     // Catch:{ RuntimeException -> 0x0075 }
            com.bytedance.vmsdk.jsbridge.AttributeDescriptor r2 = new com.bytedance.vmsdk.jsbridge.AttributeDescriptor     // Catch:{ RuntimeException -> 0x0075 }
            r2.<init>()     // Catch:{ RuntimeException -> 0x0075 }
            r2.LIZ = r3     // Catch:{ RuntimeException -> 0x0075 }
            com.bytedance.vmsdk.jsbridge.utils.JavaOnlyArray r0 = new com.bytedance.vmsdk.jsbridge.utils.JavaOnlyArray     // Catch:{ RuntimeException -> 0x0075 }
            r0.<init>()     // Catch:{ RuntimeException -> 0x0075 }
            r2.LIZIZ = r0     // Catch:{ RuntimeException -> 0x0075 }
            com.bytedance.vmsdk.jsbridge.utils.JavaOnlyArray r1 = r2.LIZIZ     // Catch:{ IllegalAccessException -> 0x004d }
            com.bytedance.vmsdk.jsbridge.JSModule r0 = r9.LIZ     // Catch:{ IllegalAccessException -> 0x004d }
            java.lang.Object r0 = r4.get(r0)     // Catch:{ IllegalAccessException -> 0x004d }
            r1.add(r0)     // Catch:{ IllegalAccessException -> 0x004d }
        L_0x004d:
            java.util.ArrayList<com.bytedance.vmsdk.jsbridge.AttributeDescriptor> r0 = r9.LIZJ     // Catch:{ RuntimeException -> 0x0075 }
            r0.add(r2)     // Catch:{ RuntimeException -> 0x0075 }
        L_0x0052:
            int r5 = r5 + 1
            goto L_0x0019
        L_0x0055:
            java.lang.IllegalArgumentException r2 = new java.lang.IllegalArgumentException     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.StringBuilder r1 = new java.lang.StringBuilder     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.String r0 = "Java Module "
            r1.<init>(r0)     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.String r0 = r9.getName()     // Catch:{ RuntimeException -> 0x0075 }
            r1.append(r0)     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.String r0 = " attribute name already registered: "
            r1.append(r0)     // Catch:{ RuntimeException -> 0x0075 }
            r1.append(r3)     // Catch:{ RuntimeException -> 0x0075 }
            java.lang.String r0 = r1.toString()     // Catch:{ RuntimeException -> 0x0075 }
            r2.<init>(r0)     // Catch:{ RuntimeException -> 0x0075 }
            throw r2     // Catch:{ RuntimeException -> 0x0075 }
        L_0x0075:
            java.util.ArrayList<com.bytedance.vmsdk.jsbridge.AttributeDescriptor> r0 = r9.LIZJ
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.vmsdk.jsbridge.JSModuleWrapper.getAttributeDescriptor():java.util.Collection");
    }

    public Collection<MethodDescriptor> getMethodDescriptors() {
        if (this.LIZIZ.isEmpty()) {
            try {
                HashSet hashSet = new HashSet();
                for (Method method : this.LIZ.getClass().getDeclaredMethods()) {
                    if (((LCG) method.getAnnotation(LCG.class)) != null) {
                        String name = method.getName();
                        if (!hashSet.contains(name)) {
                            hashSet.add(name);
                            MethodDescriptor methodDescriptor = new MethodDescriptor();
                            C4259Lh4 lh4 = new C4259Lh4(method);
                            methodDescriptor.LIZJ = name;
                            methodDescriptor.LIZIZ = lh4.LIZ();
                            methodDescriptor.LIZ = method;
                            this.LIZIZ.add(methodDescriptor);
                        } else {
                            throw new IllegalArgumentException("Java Module " + getName() + " method name already registered: " + name);
                        }
                    }
                }
            } catch (RuntimeException unused) {
            }
        }
        return this.LIZIZ;
    }

    public JSModuleWrapper(String str, JSModule jSModule) {
        this.LIZLLL = str;
        this.LIZ = jSModule;
    }
}
