package com.vungle.warren; import android.content.Context; import android.text.TextUtils; import android.util.DisplayMetrics; import android.view.MotionEvent; import android.view.WindowManager; import androidx.recyclerview.widget.RecyclerView; import com.vungle.warren.AdConfig; import com.vungle.warren.utility.ViewUtility; import java.util.regex.Pattern; /* loaded from: classes2.dex */ public class l { /* renamed from: d, reason: collision with root package name */ private static final String f8278d = Pattern.quote("{{{req_width}}}"); /* renamed from: e, reason: collision with root package name */ private static final String f8279e = Pattern.quote("{{{req_height}}}"); /* renamed from: f, reason: collision with root package name */ private static final String f8280f = Pattern.quote("{{{width}}}"); /* renamed from: g, reason: collision with root package name */ private static final String f8281g = Pattern.quote("{{{height}}}"); /* renamed from: h, reason: collision with root package name */ private static final String f8282h = Pattern.quote("{{{down_x}}}"); /* renamed from: i, reason: collision with root package name */ private static final String f8283i = Pattern.quote("{{{down_y}}}"); /* renamed from: j, reason: collision with root package name */ private static final String f8284j = Pattern.quote("{{{up_x}}}"); /* renamed from: k, reason: collision with root package name */ private static final String f8285k = Pattern.quote("{{{up_y}}}"); /* renamed from: a, reason: collision with root package name */ private final com.vungle.warren.model.c f8286a; /* renamed from: b, reason: collision with root package name */ private final y7.a f8287b; /* renamed from: c, reason: collision with root package name */ a f8288c; static class a { /* renamed from: a, reason: collision with root package name */ b f8289a = new b(RecyclerView.UNDEFINED_DURATION, RecyclerView.UNDEFINED_DURATION); /* renamed from: b, reason: collision with root package name */ b f8290b = new b(RecyclerView.UNDEFINED_DURATION, RecyclerView.UNDEFINED_DURATION); public boolean a() { b bVar = this.f8289a; if (bVar.f8291a != Integer.MIN_VALUE && bVar.f8292b != Integer.MIN_VALUE) { b bVar2 = this.f8290b; if (bVar2.f8291a != Integer.MIN_VALUE && bVar2.f8292b != Integer.MIN_VALUE) { return true; } } return false; } public void b(b bVar) { this.f8289a = bVar; } public void c(b bVar) { this.f8290b = bVar; } } static class b { /* renamed from: a, reason: collision with root package name */ int f8291a; /* renamed from: b, reason: collision with root package name */ int f8292b; public b(int i10, int i11) { this.f8291a = i10; this.f8292b = i11; } } public static class c { /* renamed from: c, reason: collision with root package name */ private static c f8293c; /* renamed from: a, reason: collision with root package name */ private final Context f8294a; /* renamed from: b, reason: collision with root package name */ private final DisplayMetrics f8295b; private c(Context context) { Context applicationContext = context.getApplicationContext(); this.f8294a = applicationContext; DisplayMetrics displayMetrics = new DisplayMetrics(); this.f8295b = displayMetrics; ((WindowManager) applicationContext.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics); } public static c c(Context context) { if (f8293c == null) { f8293c = new c(context); } return f8293c; } public int a() { return this.f8295b.heightPixels; } public int b() { return this.f8295b.widthPixels; } } public l(com.vungle.warren.model.c cVar, y7.a aVar) { this.f8286a = cVar; this.f8287b = aVar; } private int a() { if (Vungle.appContext() != null) { return c.c(Vungle.appContext()).a(); } return 0; } private int b() { if (Vungle.appContext() != null) { return c.c(Vungle.appContext()).b(); } return 0; } private int c() { if (Vungle.appContext() == null || this.f8286a.d() == null) { return 0; } AdConfig.AdSize a10 = this.f8286a.d().a(); return a10 == AdConfig.AdSize.VUNGLE_DEFAULT ? a() : ViewUtility.a(Vungle.appContext(), a10.getHeight()); } private int d() { if (Vungle.appContext() == null || this.f8286a.d() == null) { return 0; } AdConfig.AdSize a10 = this.f8286a.d().a(); return a10 == AdConfig.AdSize.VUNGLE_DEFAULT ? b() : ViewUtility.a(Vungle.appContext(), a10.getWidth()); } private void e() { String[] D; if (this.f8287b == null || (D = this.f8286a.D("video.clickCoordinates")) == null || D.length == 0) { return; } int d10 = d(); int c10 = c(); int d11 = d(); int c11 = c(); for (int i10 = 0; i10 < D.length; i10++) { String str = D[i10]; if (!TextUtils.isEmpty(str)) { D[i10] = str.replaceAll(f8278d, Integer.toString(d10)).replaceAll(f8279e, Integer.toString(c10)).replaceAll(f8280f, Integer.toString(d11)).replaceAll(f8281g, Integer.toString(c11)).replaceAll(f8282h, Integer.toString(this.f8288c.f8289a.f8291a)).replaceAll(f8283i, Integer.toString(this.f8288c.f8289a.f8292b)).replaceAll(f8284j, Integer.toString(this.f8288c.f8290b.f8291a)).replaceAll(f8285k, Integer.toString(this.f8288c.f8290b.f8292b)); } } this.f8287b.c(D); } public void f(MotionEvent motionEvent) { if (this.f8286a.I()) { if (this.f8288c == null) { this.f8288c = new a(); } int action = motionEvent.getAction(); if (action == 0) { this.f8288c.b(new b((int) motionEvent.getX(), (int) motionEvent.getY())); } else { if (action != 1) { return; } this.f8288c.c(new b((int) motionEvent.getX(), (int) motionEvent.getY())); if (this.f8288c.a()) { e(); } } } } }