package com.vinfast.companion.map;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
@kotlin.Metadata(d1 = {"\u0000v\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0006\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0015\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u0007\u0010\bJ\u001f\u0010\u000b\u001a\u0004\u0018\u00010\n2\u0006\u0010\t\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0004¢\u0006\u0004\b\u000b\u0010\fJ#\u0010\u000f\u001a\u0004\u0018\u00010\n2\b\u0010\r\u001a\u0004\u0018\u00010\u00042\b\u0010\u000e\u001a\u0004\u0018\u00010\u0004¢\u0006\u0004\b\u000f\u0010\u0010J\u001f\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0012\u001a\u00020\u00112\b\u0010\u0013\u001a\u0004\u0018\u00010\u0006¢\u0006\u0004\b\u0015\u0010\u0016J9\u0010\u001d\u001a\u0004\u0018\u00010\u001c2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0018\u001a\u0004\u0018\u00010\u00172\b\u0010\u0019\u001a\u0004\u0018\u00010\n2\n\b\u0002\u0010\u001b\u001a\u0004\u0018\u00010\u001a¢\u0006\u0004\b\u001d\u0010\u001eJ+\u0010!\u001a\u0004\u0018\u00010\u001c2\b\u0010\u0018\u001a\u0004\u0018\u00010\u00172\b\u0010 \u001a\u0004\u0018\u00010\u001f2\u0006\u0010\u001b\u001a\u00020\u001a¢\u0006\u0004\b!\u0010\"J7\u0010&\u001a\u0004\u0018\u00010%2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0018\u001a\u0004\u0018\u00010\u00172\b\u0010#\u001a\u0004\u0018\u00010\u00142\b\u0010$\u001a\u0004\u0018\u00010\u0014¢\u0006\u0004\b&\u0010'J#\u0010(\u001a\u0004\u0018\u00010\u001f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0019\u001a\u0004\u0018\u00010\n¢\u0006\u0004\b(\u0010)J\u0015\u0010-\u001a\u00020,2\u0006\u0010+\u001a\u00020*¢\u0006\u0004\b-\u0010.J\u001f\u00101\u001a\u0002002\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\u0006\u0010/\u001a\u00020\u0014¢\u0006\u0004\b1\u00102J\u001f\u00106\u001a\u00020\u00062\b\u00104\u001a\u0004\u0018\u0001032\u0006\u00105\u001a\u00020\n¢\u0006\u0004\b6\u00107J\u001f\u00108\u001a\u00020\u00042\b\u00104\u001a\u0004\u0018\u0001032\u0006\u00105\u001a\u00020\n¢\u0006\u0004\b8\u00109¨\u0006:"}, d2 = {"Lcom/vinfast/companion/map/MapUtils;", "", "<init>", "()V", "", "distanceInMeter", "", "l", "(D)J", "curLevel", "", "m", "(DD)Ljava/lang/Integer;", "curKwh", "maxKwh", "a", "(Ljava/lang/Double;Ljava/lang/Double;)Ljava/lang/Integer;", "Landroid/content/Context;", "context", "seconds", "", "j", "(Landroid/content/Context;Ljava/lang/Long;)Ljava/lang/String;", "Lcom/vinfast/companion/map/model/MapLocation;", "mapLocation", "drawableResId", "Lcom/here/sdk/core/Anchor2D;", "anchor2D", "Lcom/here/sdk/mapview/MapMarker;", "d", "(Landroid/content/Context;Lcom/vinfast/companion/map/model/MapLocation;Ljava/lang/Integer;Lcom/here/sdk/core/Anchor2D;)Lcom/here/sdk/mapview/MapMarker;", "Lcom/here/sdk/mapview/MapImage;", "mapImage", "e", "(Lcom/vinfast/companion/map/model/MapLocation;Lcom/here/sdk/mapview/MapImage;Lcom/here/sdk/core/Anchor2D;)Lcom/here/sdk/mapview/MapMarker;", "geometryFile", "textureFile", "Lcom/here/sdk/mapview/MapMarker3D;", "g", "(Landroid/content/Context;Lcom/vinfast/companion/map/model/MapLocation;Ljava/lang/String;Ljava/lang/String;)Lcom/here/sdk/mapview/MapMarker3D;", "c", "(Landroid/content/Context;Ljava/lang/Integer;)Lcom/here/sdk/mapview/MapImage;", "Lcom/here/sdk/core/GeoPolyline;", "geoPolyline", "Lcom/here/sdk/mapview/MapPolyline;", "h", "(Lcom/here/sdk/core/GeoPolyline;)Lcom/here/sdk/mapview/MapPolyline;", "fileName", "", "b", "(Landroid/content/Context;Ljava/lang/String;)Z", "Lcom/here/sdk/routing/Route;", "route", "sectionIndex", "i", "(Lcom/here/sdk/routing/Route;I)J", "k", "(Lcom/here/sdk/routing/Route;I)D", "hereSdk_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class MapUtils {
    public static final com.vinfast.companion.map.MapUtils a = new com.vinfast.companion.map.MapUtils();

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(k = 3, mv = {2, 2, 0}, xi = 48)
    public static final /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[com.here.sdk.routing.PostActionType.values().length];
            try {
                iArr[com.here.sdk.routing.PostActionType.CHARGING_SETUP.ordinal()] = 1;
            } catch (java.lang.NoSuchFieldError unused) {
            }
            try {
                iArr[com.here.sdk.routing.PostActionType.CHARGING.ordinal()] = 2;
            } catch (java.lang.NoSuchFieldError unused2) {
            }
            try {
                iArr[com.here.sdk.routing.PostActionType.WAIT.ordinal()] = 3;
            } catch (java.lang.NoSuchFieldError unused3) {
            }
            a = iArr;
        }
    }

    private MapUtils() {
    }

    public static /* synthetic */ com.here.sdk.mapview.MapMarker f(com.vinfast.companion.map.MapUtils mapUtils, android.content.Context context, com.vinfast.companion.map.model.MapLocation mapLocation, java.lang.Integer num, com.here.sdk.core.Anchor2D anchor2D, int i, java.lang.Object obj) {
        if ((i & 8) != 0) {
            anchor2D = null;
        }
        return mapUtils.d(context, mapLocation, num, anchor2D);
    }

    public final java.lang.Integer a(java.lang.Double curKwh, java.lang.Double maxKwh) {
        if (curKwh == null || maxKwh == null) {
            return null;
        }
        return java.lang.Integer.valueOf((int) ((curKwh.doubleValue() / maxKwh.doubleValue()) * ((double) 100)));
    }

    public final boolean b(android.content.Context context, java.lang.String fileName) {
        android.content.res.AssetManager assets;
        kotlin.jvm.internal.Intrinsics.l(fileName, "fileName");
        if (context != null && (assets = context.getAssets()) != null) {
            try {
                assets.open(fileName);
                return true;
            } catch (java.lang.Exception e) {
                timber.log.Timber.a.d(e);
            }
        }
        return false;
    }

    public final com.here.sdk.mapview.MapImage c(android.content.Context context, java.lang.Integer drawableResId) {
        if (context != null && drawableResId != null && drawableResId.intValue() != 0) {
            return com.here.sdk.mapview.MapImageFactory.fromResource(context.getResources(), drawableResId.intValue());
        }
        timber.log.Timber.a.c("MapDEBUG cannot create MapImage because args null, (context, drawable) = (%s, %s)", new java.lang.Object[]{context, drawableResId});
        return null;
    }

    public final com.here.sdk.mapview.MapMarker d(android.content.Context context, com.vinfast.companion.map.model.MapLocation mapLocation, java.lang.Integer drawableResId, com.here.sdk.core.Anchor2D anchor2D) {
        if (context == null || mapLocation == null || drawableResId == null || drawableResId.intValue() == 0) {
            timber.log.Timber.a.c("MapDEBUG cannot create MapMarker because args null, (context, mapLocation, drawableResId) = (%s, %s, %s)", new java.lang.Object[]{context, mapLocation, drawableResId});
            return null;
        }
        com.here.sdk.mapview.MapImage mapImageFromResource = com.here.sdk.mapview.MapImageFactory.fromResource(context.getResources(), drawableResId.intValue());
        return anchor2D != null ? new com.here.sdk.mapview.MapMarker(mapLocation.l(), mapImageFromResource, anchor2D) : new com.here.sdk.mapview.MapMarker(mapLocation.l(), mapImageFromResource);
    }

    public final com.here.sdk.mapview.MapMarker e(com.vinfast.companion.map.model.MapLocation mapLocation, com.here.sdk.mapview.MapImage mapImage, com.here.sdk.core.Anchor2D anchor2D) {
        kotlin.jvm.internal.Intrinsics.l(anchor2D, "anchor2D");
        if (mapLocation != null && mapImage != null) {
            return new com.here.sdk.mapview.MapMarker(mapLocation.l(), mapImage, anchor2D);
        }
        timber.log.Timber.a.c("MapDEBUG cannot create MapMarker because args null, (mapLocation, mapImage) = (%s, %s)", new java.lang.Object[]{mapLocation, mapImage});
        return null;
    }

    public final com.here.sdk.mapview.MapMarker3D g(android.content.Context context, com.vinfast.companion.map.model.MapLocation mapLocation, java.lang.String geometryFile, java.lang.String textureFile) {
        com.here.sdk.core.GeoCoordinates geoCoordinatesL;
        if (mapLocation == null || (geoCoordinatesL = mapLocation.l()) == null || geometryFile == null || textureFile == null || !b(context, geometryFile) || !b(context, textureFile)) {
            return null;
        }
        return new com.here.sdk.mapview.MapMarker3D(geoCoordinatesL, new com.here.sdk.mapview.MapMarker3DModel(geometryFile, textureFile));
    }

    public final com.here.sdk.mapview.MapPolyline h(com.here.sdk.core.GeoPolyline geoPolyline) {
        kotlin.jvm.internal.Intrinsics.l(geoPolyline, "geoPolyline");
        com.here.sdk.mapview.RenderSize.Unit unit = com.here.sdk.mapview.RenderSize.Unit.PIXELS;
        com.here.sdk.mapview.MapMeasureDependentRenderSize mapMeasureDependentRenderSize = new com.here.sdk.mapview.MapMeasureDependentRenderSize(unit, 11.0d);
        com.vinfast.companion.map.MapConstants mapConstants = com.vinfast.companion.map.MapConstants.a;
        return new com.here.sdk.mapview.MapPolyline(geoPolyline, new com.here.sdk.mapview.MapPolyline.SolidRepresentation(mapMeasureDependentRenderSize, mapConstants.e(), new com.here.sdk.mapview.MapMeasureDependentRenderSize(unit, 1.0d), mapConstants.f(), com.here.sdk.mapview.LineCap.ROUND));
    }

    public final long i(com.here.sdk.routing.Route route, int sectionIndex) {
        if (route == null) {
            return 0L;
        }
        int seconds = 0;
        if (sectionIndex >= 0) {
            int i = 0;
            while (true) {
                seconds += (int) ((com.here.sdk.routing.Section) route.getSections().get(i)).getDuration().getSeconds();
                if (i == sectionIndex) {
                    break;
                }
                i++;
            }
        }
        return seconds;
    }

    public final java.lang.String j(android.content.Context context, java.lang.Long seconds) {
        kotlin.jvm.internal.Intrinsics.l(context, "context");
        if (seconds == null) {
            return "-";
        }
        long jLongValue = seconds.longValue() / 86400;
        long jLongValue2 = seconds.longValue() % 86400;
        long j = jLongValue2 / 3600;
        long j2 = jLongValue2 % 3600;
        long j3 = j2 / 60;
        long j4 = j2 % 60;
        int i = (int) jLongValue;
        java.lang.String string = i == 1 ? context.getResources().getString(com.vinfast.companion.map.R.string.common_day_one) : context.getResources().getString(com.vinfast.companion.map.R.string.common_day_many, java.lang.Integer.valueOf(i));
        kotlin.jvm.internal.Intrinsics.i(string);
        java.lang.String string2 = j != 0 ? context.getResources().getString(com.vinfast.companion.map.R.string.common_time_hour_value, java.lang.Integer.valueOf((int) j)) : "";
        kotlin.jvm.internal.Intrinsics.i(string2);
        java.lang.String string3 = j3 != 0 ? context.getResources().getString(com.vinfast.companion.map.R.string.common_time_minute_value, java.lang.Integer.valueOf((int) j3)) : "";
        kotlin.jvm.internal.Intrinsics.i(string3);
        java.lang.String string4 = context.getResources().getString(com.vinfast.companion.map.R.string.common_seconds_value, java.lang.String.valueOf(j4));
        kotlin.jvm.internal.Intrinsics.k(string4, "getString(...)");
        if (jLongValue > 0) {
            return string + " " + string2;
        }
        if (j <= 0) {
            return j3 > 0 ? string3 : string4;
        }
        return string2 + " " + string3;
    }

    public final double k(com.here.sdk.routing.Route route, int sectionIndex) {
        if (route == null) {
            return 0.0d;
        }
        int lengthInMeters = 0;
        if (sectionIndex >= 0) {
            int i = 0;
            while (true) {
                lengthInMeters += ((com.here.sdk.routing.Section) route.getSections().get(i)).getLengthInMeters();
                if (i == sectionIndex) {
                    break;
                }
                i++;
            }
        }
        return lengthInMeters;
    }

    public final long l(double distanceInMeter) {
        return (long) (distanceInMeter / 9.72222d);
    }

    public final java.lang.Integer m(double curLevel, double distanceInMeter) {
        double d = curLevel - ((distanceInMeter / 1000.0d) * 0.29411764705d);
        return java.lang.Integer.valueOf(d < 0.0d ? 0 : (int) d);
    }
}
