package com.ifpdos.sdk.config.loader;

import kotlin.Metadata;

/* JADX INFO: compiled from: ConfigLoaderTemplate.kt */
/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\"\u0014\u0010\u0000\u001a\u00020\u0001X\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\u0003¨\u0006\u0004"}, d2 = {"CONFIG_LOADER_TEMPLATE", "", "getCONFIG_LOADER_TEMPLATE", "()Ljava/lang/String;", "app"}, k = 2, mv = {1, 5, 1}, xi = 48)
public final class ConfigLoaderTemplateKt {
    private static final String CONFIG_LOADER_TEMPLATE = "\npackage {{package}}\n\nimport android.content.Context\nimport android.content.res.TypedArray\nimport android.util.Log\nimport android.os.SystemProperties\n\nobject {{class}} {\n    private lateinit var typedArray: TypedArray\n\n    fun loadConfig(context: Context, config: Int) {\n        typedArray = context.obtainStyledAttributes(config, R.styleable.Config)\n    }\n    \n    {{#selectForHandlers}}\n    object {{&handlerSampleName}} {\n        {{#configs}}\n        {{#funs}}\n        const val key_{{&config}}_{{&key}} = {{&id}}\n        {{/funs}}\n        {{/configs}}\n    }\n    \n    fun <T> select(handler: {{&handler}}, config: Int, key: Int = 0, prop: String = \"\"): T {\n        return when (config) {\n            {{#configs}}\n            R.styleable.{{&configStyleable}}_{{&config}} ->\n                when (key) {\n                    {{#funs}}\n                    {{&handlerSampleName}}.key_{{&config}}_{{&key}} -> {{&selectFun}}(handler,prop) as T\n                    {{/funs}}\n                    else -> throw Exception(\"can't find func for {{&config}} \" + key)\n                }\n            {{/configs}}\n            else -> throw Exception(\"can't select for \" + config)\n        }\n    }\n    \n    {{/selectForHandlers}}\n    {{#booleanSelectForConfigs}}\n    private fun {{&selectFun}}(handler: {{&handler}}, prop: String = \"\") : {{&targetType}} {\n        var config = typedArray.getBoolean(R.styleable.{{&configStyleable}}_{{&config}}, false)\n        config = if (prop.isNotEmpty()) SystemProperties.getBoolean(prop, config!!) else config\n        return when (config) {\n            {{#values}}\n            {{&configValue}} -> {\n                {{&targetValue}}\n            }\n            {{/values}}\n        }\n    }\n    \n    {{/booleanSelectForConfigs}}\n    {{#intSelectForConfigs}}\n    private fun {{&selectFun}}(handler: {{&handler}},prop: String = \"\") : {{&targetType}} {\n        var config = typedArray.getInt(R.styleable.{{&configStyleable}}_{{&config}}, 0)\n        config = if (prop.isNotEmpty()) SystemProperties.getInt(prop, config!!) else config\n        return when (config) {\n            {{#values}}\n            {{&configValue}} -> {\n                {{&targetValue}}\n            }\n            {{/values}}\n            else -> throw Exception(\"can't select for {{&config}} \" + config)\n        }\n    }\n    \n    {{/intSelectForConfigs}}\n    {{#stringSelectForConfigs}}\n    private fun {{&selectFun}}(handler: {{&handler}}, prop: String = \"\") : {{&targetType}} {\n        var config = typedArray.getString(R.styleable.{{&configStyleable}}_{{&config}})\n        config = if (prop.isNotEmpty()) SystemProperties.get(prop, config!!) else config\n        return when (config) {\n            {{#values}}\n            \"{{&configValue}}\" -> {\n                {{&targetValue}}\n            }\n            {{/values}}\n            else -> throw Exception(\"can't select for {{&config}} \" + config)\n        }\n    }\n    \n    {{/stringSelectForConfigs}}\n    \n    fun getString(index: Int, prop: String = \"\") : String {\n        val config = typedArray.getString(index) ?: \"\"\n        return if (prop.isNotEmpty()) SystemProperties.get(prop, config) else config\n    }\n    \n    fun getInt(index: Int, def: Int, prop: String = \"\") : Int {\n        val config = typedArray.getInt(index, def)\n        return if (prop.isNotEmpty()) SystemProperties.getInt(prop, config) else config\n    }\n    \n    fun getBoolean(index: Int, def: Boolean, prop: String = \"\") : Boolean {\n        val config = typedArray.getBoolean(index, def)\n        return if (prop.isNotEmpty()) SystemProperties.getBoolean(prop, config) else config\n    }\n    \n    fun getFloat(index: Int, def: Float) = typedArray.getFloat(index, def)\n    \n    fun getColor(index: Int, def: Int) = typedArray.getColor(index, def)\n}\n";

    public static final String getCONFIG_LOADER_TEMPLATE() {
        return CONFIG_LOADER_TEMPLATE;
    }
}
