{% set _count = layerset_groups | length %}
<p>{{ 'mb.manager.source.instance.embedded_in_applications' | trans({count: _count}) }}{{ _count ? ':' : '.' }}</p>
<ul class="list-default">
{% for lsg in layerset_groups %}
    {%- set application = lsg.application -%}
    <li>{%- set _linkToApp = is_granted(constant('FOM\\UserBundle\\Security\\Permission\\ResourceDomainApplication::ACTION_EDIT'), application) -%}
        {%- if _linkToApp -%}
        <a href="{{ path('mapbender_manager_application_edit', {'slug': application.slug}) ~ '#tabLayers' }}">
        {%- endif -%}
            {{- application.title -}}
            {%- if not has_public_access(application) -%}&nbsp;<span class="badge bg-info">{{ "mb.states.inactive" | trans }}</span>{%- endif -%}
        {%- if _linkToApp -%}
        </a>
        {%- endif -%}
        <ul class="list-default">
        {%- for instance_group in lsg.instance_groups -%}
        {%- set layerset = instance_group.layerset -%}
        {%- for assignment in instance_group.instance_assignments -%}
            {%- set instance = assignment.instance -%}
        <li>{%- if _linkToApp -%}
            <a href="{{ path('mapbender_manager_repository_instance', {'slug': application.slug, 'instanceId' : instance.id}) }}">
            {%- endif -%}
                {%- if instance.layerset -%}
                <span title="{{ 'mb.terms.sourceinstance.bound.singular' | trans }}"><i class="fas fa-anchor"></i></span>&nbsp;
                {%- else -%}
                <span title="{{ 'mb.terms.sourceinstance.reusable.singular' | trans }} #{{ instance.id }}"><i class="fas fa-wifi"></i></span>&nbsp;
                {%- endif -%}
                {{ assignment.instance.title | default('#' ~ assignment.instance.id) }}
                ({{ "mb.terms.layerset.singular" | trans }} {{ layerset.title | default(layerset.id) }})
                {%- if not assignment.enabled -%}&nbsp;<span class="badge">{{ "mb.states.inactive" | trans }}</span>{%- endif -%}
            {%- if _linkToApp -%}
                </a>
            {%- endif -%}
        </li>
        {%- endfor -%}
        {%- endfor -%}
        </ul>
    </li>
{% endfor %}
</ul>

