package com.tencent.luggage.bridge;

import android.text.TextUtils;
import com.tencent.luggage.g.d;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.ytcommon.BuildConfig;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

final class q implements p {
    private static final Pattern bON = Pattern.compile("^<<//([a-z]{0,10})//>>");
    private o bOA;

    static {
        AppMethodBeat.i(90745);
        AppMethodBeat.o(90745);
    }

    q(o oVar) {
        this.bOA = oVar;
    }

    public final void wO() {
        AppMethodBeat.i(90742);
        f fVar = this.bOA.bOH;
        d.i("Java2JsMessageQueue", "reset");
        fVar.bOq = false;
        fVar.bOp.clear();
        AppMethodBeat.o(90742);
    }

    /* JADX WARNING: Removed duplicated region for block: B:26:0x0084 A:{SYNTHETIC, Splitter:B:26:0x0084} */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x0048 A:{SYNTHETIC, Splitter:B:13:0x0048} */
    public final void onReady() {
        /*
        r10 = this;
        r9 = 1;
        r8 = 90743; // 0x16277 float:1.27158E-40 double:4.4833E-319;
        r7 = 0;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r8);
        r0 = r10.bOA;
        r2 = 0;
        r1 = 4096; // 0x1000 float:5.74E-42 double:2.0237E-320;
        r3 = new char[r1];
        r4 = new java.io.StringWriter;
        r4.<init>();
        r1 = new java.io.InputStreamReader;	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
        r5 = r0.bOF;	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
        r5 = r5.getContext();	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
        r5 = r5.getAssets();	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
        r6 = "LuggageBridge.js";
        r5 = r5.open(r6);	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
        r1.<init>(r5);	 Catch:{ Exception -> 0x009c, all -> 0x0080 }
    L_0x002a:
        r2 = -1;
        r5 = r1.read(r3);	 Catch:{ Exception -> 0x0036 }
        if (r2 == r5) goto L_0x004f;
    L_0x0031:
        r2 = 0;
        r4.write(r3, r2, r5);	 Catch:{ Exception -> 0x0036 }
        goto L_0x002a;
    L_0x0036:
        r0 = move-exception;
    L_0x0037:
        r2 = "LuggageBridge";
        r3 = "injectJavascript: read error, %s";
        r4 = 1;
        r4 = new java.lang.Object[r4];	 Catch:{ all -> 0x009a }
        r5 = 0;
        r4[r5] = r0;	 Catch:{ all -> 0x009a }
        com.tencent.luggage.g.d.e(r2, r3, r4);	 Catch:{ all -> 0x009a }
        if (r1 == 0) goto L_0x004b;
    L_0x0048:
        r1.close();	 Catch:{ Exception -> 0x006e }
    L_0x004b:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
    L_0x004e:
        return;
    L_0x004f:
        r1.close();	 Catch:{ Exception -> 0x005f }
    L_0x0052:
        r0 = r0.bOF;
        r1 = r4.toString();
        r0.by(r1);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        goto L_0x004e;
    L_0x005f:
        r1 = move-exception;
        r2 = "LuggageBridge";
        r3 = "injectJavascript: close error, %s";
        r5 = new java.lang.Object[r9];
        r5[r7] = r1;
        com.tencent.luggage.g.d.e(r2, r3, r5);
        goto L_0x0052;
    L_0x006e:
        r0 = move-exception;
        r1 = "LuggageBridge";
        r2 = "injectJavascript: close error, %s";
        r3 = new java.lang.Object[r9];
        r3[r7] = r0;
        com.tencent.luggage.g.d.e(r1, r2, r3);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        goto L_0x004e;
    L_0x0080:
        r0 = move-exception;
        r1 = r2;
    L_0x0082:
        if (r1 == 0) goto L_0x0087;
    L_0x0084:
        r1.close();	 Catch:{ Exception -> 0x008b }
    L_0x0087:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r8);
        throw r0;
    L_0x008b:
        r1 = move-exception;
        r2 = "LuggageBridge";
        r3 = "injectJavascript: close error, %s";
        r4 = new java.lang.Object[r9];
        r4[r7] = r1;
        com.tencent.luggage.g.d.e(r2, r3, r4);
        goto L_0x0087;
    L_0x009a:
        r0 = move-exception;
        goto L_0x0082;
    L_0x009c:
        r0 = move-exception;
        r1 = r2;
        goto L_0x0037;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.luggage.bridge.q.onReady():void");
    }

    public final String bx(String str) {
        AppMethodBeat.i(90744);
        if (TextUtils.isEmpty(str)) {
            AppMethodBeat.o(90744);
            return null;
        }
        String group;
        Matcher matcher = bON.matcher(str);
        if (matcher.find()) {
            group = matcher.group(1);
        } else {
            group = null;
        }
        if (group == null) {
            AppMethodBeat.o(90744);
            return null;
        }
        String h = this.bOA.bOG.h(str.replaceFirst("^<<//([a-z]{0,10})//>>", BuildConfig.FLAVOR), group.equals("sync"));
        AppMethodBeat.o(90744);
        return h;
    }
}
