{%- from "introspection" import extend_list %}

namespace {{ name }} {
    {% include "introspection" %}

    interface Interface {{ extend_list(extends) }} {
        {%- for method in virtual_methods %}
        {{ method|indent(8) }}
        {%- endfor %}
    }
}

{{ jsdoc if jsdoc }}
interface {{ name }} {{ extend_list(extends+[name+".Interface"]) }} {
    readonly $signals: {{ name }}.SignalSignatures
    readonly $readableProperties: {{ name }}.ReadableProperties
    readonly $writableProperties: {{ name }}.WritableProperties
    readonly $constructOnlyProperties: {{ name }}.ConstructOnlyProperties

    {%- for property in properties %}
    {{ property.jsdoc|indent(4) }}
    {%- if property.readable %}
    get {{ property.name|camel_case }}(): {{ property.type }}
    {%- endif %}
    {%- if property.writable and not property.constuct_only %}
    set {{ property.name|camel_case }}(value: {{ property.type }})
    {%- endif %}
    {%- endfor %}

    {%- for method in methods %}
    {{ method|indent(4) }}
    {%- endfor %}
}


interface {{ name_iface }} {
    readonly $gtype: GObject.GType<{{ name }}>
    readonly prototype: {{ name }}

    {%- for fn in functions %}
    {{ fn|indent(4) }}
    {%- endfor %}

    {%- for fn in class_functions %}
    {{ fn|indent(4) }}
    {%- endfor %}

    [Symbol.hasInstance](instance: unknown): instance is {{ name }}
}

const {{ name }}: {{ name_iface }}
