package com.pichillilorenzo.flutter_inappwebview_android.process_global_config;

import a4.k0;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.webkit.ProcessGlobalConfig;
import com.google.android.gms.measurement.internal.u1;
import com.pichillilorenzo.flutter_inappwebview_android.ISettings;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import z3.c0;

/* JADX INFO: loaded from: classes.dex */
public class ProcessGlobalConfigSettings implements ISettings<ProcessGlobalConfig> {
    public static final String LOG_TAG = "ProcessGlobalConfigSettings";

    @Nullable
    public String dataDirectorySuffix;

    @Nullable
    public DirectoryBasePaths directoryBasePaths;

    public static class DirectoryBasePaths implements ISettings<Object> {
        public static final String LOG_TAG = "ProcessGlobalConfigSettings";
        public String cacheDirectoryBasePath;
        public String dataDirectoryBasePath;

        @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
        @NonNull
        public Map<String, Object> getRealSettings(@NonNull Object obj) {
            return toMap();
        }

        @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
        @NonNull
        public /* bridge */ /* synthetic */ ISettings<Object> parse(@NonNull Map map) {
            return parse2((Map<String, Object>) map);
        }

        @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
        @NonNull
        public Map<String, Object> toMap() {
            HashMap map = new HashMap();
            map.put("cacheDirectoryBasePath", this.cacheDirectoryBasePath);
            map.put("dataDirectoryBasePath", this.dataDirectoryBasePath);
            return map;
        }

        @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
        @NonNull
        /* JADX INFO: renamed from: parse, reason: avoid collision after fix types in other method */
        public ISettings<Object> parse2(@NonNull Map<String, Object> map) {
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                String key = entry.getKey();
                Object value = entry.getValue();
                if (value != null) {
                    key.getClass();
                    if (key.equals("dataDirectoryBasePath")) {
                        this.dataDirectoryBasePath = (String) value;
                    } else if (key.equals("cacheDirectoryBasePath")) {
                        this.cacheDirectoryBasePath = (String) value;
                    }
                }
            }
            return this;
        }
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public /* bridge */ /* synthetic */ ISettings<ProcessGlobalConfig> parse(@NonNull Map map) {
        return parse2((Map<String, Object>) map);
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public Map<String, Object> toMap() {
        HashMap map = new HashMap();
        map.put("dataDirectorySuffix", this.dataDirectorySuffix);
        return map;
    }

    public ProcessGlobalConfig toProcessGlobalConfig(@NonNull Context context) {
        ProcessGlobalConfig processGlobalConfig = new ProcessGlobalConfig();
        if (this.dataDirectorySuffix != null && c0.b(context, "STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX")) {
            String str = this.dataDirectorySuffix;
            if (!k0.D.a(context)) {
                throw k0.a();
            }
            if (str.equals("")) {
                throw new IllegalArgumentException("Suffix cannot be an empty string");
            }
            if (str.indexOf(File.separatorChar) >= 0) {
                throw new IllegalArgumentException(u1.k("Suffix ", str, " contains a path separator"));
            }
            processGlobalConfig.f4407a = str;
        }
        if (this.directoryBasePaths != null && c0.b(context, "STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS")) {
            File file = new File(this.directoryBasePaths.dataDirectoryBasePath);
            File file2 = new File(this.directoryBasePaths.cacheDirectoryBasePath);
            if (!k0.E.a(context)) {
                throw k0.a();
            }
            if (!file.isAbsolute()) {
                throw new IllegalArgumentException("dataDirectoryBasePath must be a non-empty absolute path");
            }
            if (!file2.isAbsolute()) {
                throw new IllegalArgumentException("cacheDirectoryBasePath must be a non-empty absolute path");
            }
            processGlobalConfig.f4408b = file.getAbsolutePath();
            processGlobalConfig.f4409c = file2.getAbsolutePath();
        }
        return processGlobalConfig;
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    public Map<String, Object> getRealSettings(@NonNull ProcessGlobalConfig processGlobalConfig) {
        return toMap();
    }

    /* JADX WARN: Type inference failed for: r0v5, types: [com.pichillilorenzo.flutter_inappwebview_android.process_global_config.ProcessGlobalConfigSettings$DirectoryBasePaths] */
    @Override // com.pichillilorenzo.flutter_inappwebview_android.ISettings
    @NonNull
    /* JADX INFO: renamed from: parse, reason: avoid collision after fix types in other method */
    public ISettings<ProcessGlobalConfig> parse2(@NonNull Map<String, Object> map) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (value != null) {
                key.getClass();
                if (key.equals("dataDirectorySuffix")) {
                    this.dataDirectorySuffix = (String) value;
                } else if (key.equals("directoryBasePaths")) {
                    this.directoryBasePaths = new DirectoryBasePaths().parse2((Map<String, Object>) value);
                }
            }
        }
        return this;
    }
}
