// -*- mode: kotlin -*-

/*
 * AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT.
 */
{# The rendered markdown is autogenerated, but this
Jinja2 template is not. Please file bugs! #}

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
{% macro obj_declaration(obj, suffix='', access='', lazy=False) %}
{% if (access != "private ") -%}
@get:JvmName("{{ obj.name|camelize }}{{ suffix }}")
{% endif -%}
{{ access }}val {{ obj.name|camelize }}{{ suffix }}: {{ obj|type_name }}{% if lazy %} by lazy { {%- else %} ={% endif %} // generated from {{ obj.identifier() }}

        {{ obj|type_name }}(
            {% for arg_name in extra_args if obj[arg_name] is defined %}
            {{ arg_name|camelize }} = {{ obj[arg_name]|kotlin }}{{ "," if not loop.last }}
            {% endfor %}
        )
{% if lazy %}    }{% endif %}{% endmacro %}

/* ktlint-disable no-blank-line-before-rbrace */
@file:Suppress("PackageNaming", "MaxLineLength")
package {{ namespace }}

import {{ glean_namespace }}.private.HistogramType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.Lifetime // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.MemoryUnit // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.NoExtraKeys // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.NoReasonCodes // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.TimeUnit // ktlint-disable import-ordering no-unused-imports
{% for obj_type in obj_types %}
import {{ glean_namespace }}.private.{{ obj_type }} // ktlint-disable import-ordering
{% endfor %}
{% if has_labeled_metrics %}
import {{ glean_namespace }}.private.LabeledMetricType // ktlint-disable import-ordering
{% endif %}

internal object {{ category_name|Camelize }} {
{% for obj in objs.values() %}
    {% if obj|attr("_generate_enums") %}
    {% for name, suffix in obj["_generate_enums"] %}
    {% if obj|attr(name)|length %}
    @Suppress("ClassNaming", "EnumNaming")
    enum class {{ obj.name|camelize }}{{ suffix }} {
    {% for key in obj|attr(name) %}
        {{ key|camelize }}{{ "," if not loop.last }}
    {% endfor %}
    }
    {% endif %}
    {% endfor %}
    {% endif %}
{% endfor %}
{% for obj in objs.values() %}
    {% if obj.labeled %}
    {{ obj_declaration(obj, 'Label', 'private ') }}
    /**
     * {{ obj.description|wordwrap() | replace('\n', '\n        * ') }}
     */
    val {{ obj.name|camelize }}: LabeledMetricType<{{ obj|type_name }}> by lazy { // generated from {{ obj.identifier() }}
        LabeledMetricType(
            category = {{ obj.category|kotlin }},
            name = {{ obj.name|kotlin }},
            subMetric = {{ obj.name|camelize }}Label,
            disabled = {{ obj.is_disabled()|kotlin }},
            lifetime = {{ obj.lifetime|kotlin }},
            sendInPings = {{ obj.send_in_pings|kotlin }},
            labels = {{ obj.labels|kotlin }}
        )
    }
    {% else %}
    /**
     * {{ obj.description|wordwrap() | replace('\n', '\n     * ') }}
     */
    {{ obj_declaration(obj, lazy=obj.type != 'ping') }}
    {% endif %}
{%- endfor %}
}
