package sv2; import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.util.Base64; import com.tencent.mm.sdk.platformtools.LocaleUtil; import com.tencent.mm.sdk.platformtools.Log; import com.tencent.thumbplayer.composition.TPMediaCompositionHelper; import com.tencent.thumbplayer.tplayer.plugins.report.TPReportKeys; import ek4.c; import ie1.h; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.zip.GZIPOutputStream; import kh4.l; import lh4.m; import org.json.JSONArray; import org.json.JSONObject; import sv2.t; import wg4.b0; import xg4.c0; import yz3.j; public final class u implements DialogInterface.OnClickListener { /* renamed from: d reason: collision with root package name */ public final /* synthetic */ l<Boolean, b0> f307994d; /* renamed from: e reason: collision with root package name */ public final /* synthetic */ boolean f307995e; /* renamed from: f reason: collision with root package name */ public final /* synthetic */ t.a f307996f; /* renamed from: g reason: collision with root package name */ public final /* synthetic */ String f307997g; /* renamed from: h reason: collision with root package name */ public final /* synthetic */ String f307998h; /* renamed from: i reason: collision with root package name */ public final /* synthetic */ String f307999i; /* renamed from: j reason: collision with root package name */ public final /* synthetic */ List<String> f308000j; /* renamed from: n reason: collision with root package name */ public final /* synthetic */ int f308001n; /* renamed from: o reason: collision with root package name */ public final /* synthetic */ List<int[]> f308002o; /* renamed from: p reason: collision with root package name */ public final /* synthetic */ Activity f308003p; /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: kh4.l<? super java.lang.Boolean, wg4.b0> */ /* JADX WARN: Multi-variable type inference failed */ public u(l<? super Boolean, b0> lVar, boolean z15, t.a aVar, String str, String str2, String str3, List<String> list, int i15, List<int[]> list2, Activity activity) { this.f307994d = lVar; this.f307995e = z15; this.f307996f = aVar; this.f307997g = str; this.f307998h = str2; this.f307999i = str3; this.f308000j = list; this.f308001n = i15; this.f308002o = list2; this.f308003p = activity; } /* JADX WARNING: Removed duplicated region for block: B:42:0x0183 A[SYNTHETIC, Splitter:B:42:0x0183] */ /* JADX WARNING: Removed duplicated region for block: B:48:0x0189 */ /* JADX WARNING: Removed duplicated region for block: B:53:0x01a1 */ public final void onClick(DialogInterface dialogInterface, int i15) { String str; Throwable th5; Iterator<T> it; l<Boolean, b0> lVar = this.f307994d; if (lVar != null) { lVar.invoke(Boolean.TRUE); } if (this.f307995e) { if (this.f307996f != null) { str = "" + "&launchType=" + this.f307996f.f307993d; } else { str = ""; } if (!m.b(this.f307997g, "")) { str = str + "&templateId=" + this.f307997g; } if (!m.b(this.f307998h, "")) { str = str + "&musicKey=" + this.f307998h; } String str2 = this.f307999i; List<String> list = this.f308000j; int i16 = this.f308001n; List<int[]> list2 = this.f308002o; m.g(str2, TPReportKeys.PlayerStep.PLAYER_BUFFERING_SCENE); m.g(list, "mediaPaths"); m.g(list2, "timeRangeList"); m.g(str, "extInfo"); Log.i("MicroMsg.SecondCutUtil", "getSecondCutEditIntent >>>mediaPaths: " + list + " >>>duration: " + i16 + '}'); byte[] bytes = c0.V(list, ",", null, null, 0, null, null, 62, null).getBytes(c.f208058a); m.f(bytes, "this as java.lang.String).getBytes(charset)"); String encodeToString = Base64.encodeToString(bytes, 10); double d15 = ((double) 600) * 0.001d; JSONArray jSONArray = new JSONArray(); Iterator<T> it4 = list.iterator(); char c15 = 0; int i17 = 0; while (true) { GZIPOutputStream gZIPOutputStream = null; if (it4.hasNext()) { T next = it4.next(); int i18 = i17 + 1; if (i17 >= 0) { JSONObject jSONObject = new JSONObject(); jSONObject.put("id", next); int[] iArr = (int[]) c0.R(list2, i17); if (iArr != null) { JSONArray jSONArray2 = new JSONArray(); int i19 = iArr[c15]; int i25 = iArr[1] - i19; jSONArray2.put((int) Math.floor(((double) i19) * d15)); it = it4; jSONArray2.put((int) Math.ceil(((double) i25) * d15)); jSONObject.put(LocaleUtil.TURKEY, jSONArray2); } else { it = it4; } jSONArray.put(jSONObject); it4 = it; i17 = i18; c15 = 0; } else { xg4.u.l(); throw null; } } else { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("timescale", 600); jSONObject2.put(TPMediaCompositionHelper.XML_TAG_ASSERT, jSONArray); String jSONObject3 = jSONObject2.toString(); m.f(jSONObject3, "jsonObject.toString()"); if (jSONObject3.length() != 0) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { GZIPOutputStream gZIPOutputStream2 = new GZIPOutputStream(byteArrayOutputStream); try { gZIPOutputStream2.write(jSONObject3.getBytes()); try { gZIPOutputStream2.close(); } catch (IOException unused) { } } catch (IOException unused2) { gZIPOutputStream = gZIPOutputStream2; if (gZIPOutputStream != null) { } jSONObject3 = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 10); m.f(jSONObject3, "compress(projectJsonString)"); if (!m.b(jSONObject3, "")) { } Intent intent = new Intent(); intent.setData(Uri.parse("miaojian://createvideo?scene=" + str2 + "&assetPaths=" + encodeToString + "&maxDuration=" + i16 + "&from=2" + jSONObject3 + str)); intent.setPackage("com.tencent.phoenix"); intent.setAction("android.intent.action.VIEW"); intent.setFlags(268435456); t.f307987a.d(this.f308003p, intent); return; } catch (Throwable th6) { th5 = th6; gZIPOutputStream = gZIPOutputStream2; if (gZIPOutputStream != null) { } throw th5; } } catch (IOException unused3) { if (gZIPOutputStream != null) { gZIPOutputStream.close(); } jSONObject3 = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 10); m.f(jSONObject3, "compress(projectJsonString)"); if (!m.b(jSONObject3, "")) { } Intent intent2 = new Intent(); intent2.setData(Uri.parse("miaojian://createvideo?scene=" + str2 + "&assetPaths=" + encodeToString + "&maxDuration=" + i16 + "&from=2" + jSONObject3 + str)); intent2.setPackage("com.tencent.phoenix"); intent2.setAction("android.intent.action.VIEW"); intent2.setFlags(268435456); t.f307987a.d(this.f308003p, intent2); return; } catch (Throwable th7) { th5 = th7; if (gZIPOutputStream != null) { try { gZIPOutputStream.close(); } catch (IOException unused4) { } } throw th5; } jSONObject3 = Base64.encodeToString(byteArrayOutputStream.toByteArray(), 10); } m.f(jSONObject3, "compress(projectJsonString)"); if (!m.b(jSONObject3, "")) { jSONObject3 = "&project=" + jSONObject3; } Intent intent22 = new Intent(); intent22.setData(Uri.parse("miaojian://createvideo?scene=" + str2 + "&assetPaths=" + encodeToString + "&maxDuration=" + i16 + "&from=2" + jSONObject3 + str)); intent22.setPackage("com.tencent.phoenix"); intent22.setAction("android.intent.action.VIEW"); intent22.setFlags(268435456); t.f307987a.d(this.f308003p, intent22); return; } } } else { b bVar = b.f307927a; Activity activity = this.f308003p; StringBuilder sb5 = new StringBuilder(); String pi5 = ((h) j.c(h.class)).pi(h.c.f232391tq, "https://miaojian.weixin.qq.com/download/apps?channel="); Log.i("MicroMsg.SecondCutConfig", "SecondCutDownloadUrl: " + pi5); m.f(pi5, "url"); sb5.append(pi5); sb5.append("1101"); bVar.c(activity, sb5.toString()); } } }