{% macro progressbar(data) %}
	<div class="progress progress-thin" role="progressbar" aria-valuenow="{{ data.percent }}">
		<div class="progress-bar {{ data.style }}" style="width: {{ data.percent }}%;"></div>
	</div>
	<div class="text-end small">
		{% if data.infotext is not empty %}
			<i class="fa-solid fa-circle-info" data-bs-trigger="hover" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-html="true" data-bs-content="{{ data.infotext|raw|nl2br }}"></i>
		{% endif %}
		{{ data.text }}
	</div>
{% endmacro %}

{% macro boolean(data) %}
	{% if (data) %}
		<i class="fa-solid fa-check-circle text-success"></i>
	{% else %}
		<i class="fa-solid fa-times-circle text-danger"></i>
	{% endif %}
{% endmacro %}

{% macro booleanWithInfo(data) %}
	{% if (data.checked) %}
		<i class="fa-solid fa-check-circle text-success"></i>
	{% else %}
		<i class="fa-solid fa-times-circle text-danger"></i>
	{% endif %}
	{% if data.info is not empty %}
		{{ data.info }}
	{% endif %}
{% endmacro %}

{% macro type2fa(data) %}
	{% if (data == 1) %}
		<i class="fa-solid fa-envelope text-success"></i>
	{% elseif (data == 2) %}
		<i class="fa-solid fa-mobile text-success"></i>
	{% else %}
		<i class="fa-solid fa-lock-open text-warning"></i>
	{% endif %}
{% endmacro %}

{% macro link(data) %}
	{% apply spaceless %}
	<a href="{{ data.href }}" {% if data.class is defined %} class="{{ data.class }}" {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %} {% if data.title is defined %} title="{{ data.title }}" {% endif %}>
		{% if data.icon is defined %}
			<i class="{{ data.icon }}"></i>
		{% endif %}
		{% if data.text is defined %}
			{{ data.text }}
		{% endif %}
	</a>
	{% endapply %}
{% endmacro %}

{% macro button(data) %}
	{% apply spaceless %}
	<{% if data.href is defined %}a{% else %}span{% endif %} class="{% if data.class is defined %}btn btn-sm {{ data.class }}{% else %}btn btn-sm btn-outline-secondary{% endif %}" {% if data.modal is defined and data.modal is iterable %} data-bs-toggle="modal" role="button" href="#{{ data.modal.id }}" {% else %} {% if data.href is defined %}href="{{ data.href }}"{% endif %} {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %} {% if data.title is defined %} title="{{ data.title }}" {% endif %}>
		{% if data.icon is defined %}
			<i class="{{ data.icon }}"></i>
		{% endif %}
		{% if data.text is defined %}
			{{ data.text }}
		{% endif %}
	</{% if data.href is defined %}a{% else %}span{% endif %}>
	{% endapply %}
	{# the modal-markup if any will be generated using actions_modal()-macro after the table itself #}
{% endmacro %}

{% macro domainWithSan(data) %}
	{{ data.domain }}
	{% if data.san is not empty %}
		<br/>
		<span class="small">
			SAN: {{ data.san }}
		</span>
	{% endif %}
{% endmacro %}

{% macro actions(data) %}
	{% for action in data %}
		{% if action.visible is not defined or action.visible is defined and action.visible %}
			{{ _self.button(action) }}
		{% endif %}
	{% endfor %}
{% endmacro %}

{% macro actions_modal(data) %}
	{% for action in data %}
		{% if action.visible is not defined or action.visible is defined and action.visible %}
			{% apply spaceless %}
				{% if action.modal is defined and action.modal is iterable %}
					<div class="modal fade" data-action="{{ action.modal.action|default('') }}" data-entry="{{ action.modal.entry }}" id="{{ action.modal.id }}" aria-hidden="true" aria-labelledby="{{ action.modal.id }}Label" tabindex="-1">
						<div class="modal-dialog {{ action.modal.size|default('modal-xl') }} modal-dialog-centered">
							<div class="modal-content">
								<div class="modal-header">
									<h5 class="modal-title" id="{{ action.modal.id }}Label">{{ action.modal.title }}</h5>
									<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ lng('panel.modalclose') }}"></button>
								</div>
								<div class="modal-body text-start">
									{{ action.modal.body|raw }}
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-primary" data-bs-dismiss="modal">{{ lng('panel.modalclose') }}</button>
								</div>
							</div>
						</div>
					</div>
				{% endif %}
			{% endapply %}
		{% endif %}
	{% endfor %}
{% endmacro %}
