package com.google.android.gms.internal.ads;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.URLUtil;
import androidx.media3.exoplayer.rtsp.RtspHeaders;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public final class wx extends zv1 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Map f18244d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Activity f18245e;

    public wx(x50 x50Var, Map map) {
        super(x50Var, "storePicture", 11);
        this.f18244d = map;
        this.f18245e = x50Var.zzj();
    }

    @Override // com.google.android.gms.internal.ads.zv1, com.google.android.gms.internal.ads.f30
    /* JADX INFO: renamed from: zza */
    public final void mo5zza() {
        Activity activity = this.f18245e;
        if (activity == null) {
            c("Activity context is not available");
            return;
        }
        m7.n nVar = m7.n.C;
        p7.r0 r0Var = nVar.f30464c;
        if (!new qn(activity).a()) {
            c("Feature is not supported by the device.");
            return;
        }
        String str = (String) this.f18244d.get("iurl");
        if (TextUtils.isEmpty(str)) {
            c("Image url cannot be empty.");
            return;
        }
        if (!URLUtil.isValidUrl(str)) {
            c("Invalid image url: ".concat(String.valueOf(str)));
            return;
        }
        String lastPathSegment = Uri.parse(str).getLastPathSegment();
        if (TextUtils.isEmpty(lastPathSegment) || !lastPathSegment.matches("([^\\s]+(\\.(?i)(jpg|png|gif|bmp|webp))$)")) {
            c("Image type not recognized: ".concat(String.valueOf(lastPathSegment)));
            return;
        }
        Resources resourcesZzf = nVar.f30469h.zzf();
        AlertDialog.Builder builderJ = p7.r0.j(activity);
        builderJ.setTitle(resourcesZzf != null ? resourcesZzf.getString(k7.d.f29073s1) : "Save image");
        builderJ.setMessage(resourcesZzf != null ? resourcesZzf.getString(k7.d.f29074s2) : "Allow Ad to store image in Picture gallery?");
        builderJ.setPositiveButton(resourcesZzf != null ? resourcesZzf.getString(k7.d.f29075s3) : RtspHeaders.ACCEPT, new gw0(this, str, lastPathSegment));
        builderJ.setNegativeButton(resourcesZzf != null ? resourcesZzf.getString(k7.d.f29076s4) : "Decline", new vx(this));
        builderJ.create().show();
    }
}
