{% macro shieldpro() %}
	<span class="shieldpro"><strong>Shield</strong><span style="text-transform: uppercase">pro</span></span>
{% endmacro %}

{% macro icon(icon_class, classes=[]) %}
	<span class="svg-container {{ classes|join(' ') }}"><i class="{{ icon_class }}" aria-hidden="true"></i></span>
{% endmacro %}

{% macro renderAttributes(attributes={}) %}
	{% for attr_name, attr_value in attributes %} {{ attr_name|e('html_attr') }}="{{ attr_value|e('html_attr') }}"{% endfor %}
{% endmacro %}

{#
 # For a PIN typed in to unlock something (never a stored login credential), so password
 # manager extensions shouldn't offer to fill or save it. Each opt-out is that vendor's own:
 #   keeper-ignore class: Keeper           data-1p-ignore: 1Password
 #   data-lpignore="true": LastPass        data-form-type="other": Dashlane
 #   data-bwignore: Bitwarden (honoured only if the user turns on its "skip fields" setting)
 #   data-protonpass-ignore: Proton Pass   data-spignore: Sticky Password
 # Browsers' built-in password managers have no opt-out for password fields.
 #}
{% macro pinEntryAttributes(classes='') %}
	type="password" class="keeper-ignore {{ classes }}" autocomplete="off"
	data-1p-ignore data-lpignore="true" data-form-type="other" data-bwignore
	data-protonpass-ignore="true" data-spignore="true"
{% endmacro %}

{% macro tagAnchor(href,text,id='',classes=[],new_window=false,datas=[],disabled=false,is_action=false) %}
	{% set attributes = {} %}
	{% if id is not empty %}
		{% set attributes = attributes|merge( { id: id } ) %}
	{% endif %}
	{% if new_window and not is_action %}
		{% set attributes = attributes|merge( { target: '_blank' } ) %}
	{% endif %}
	{% if datas is not empty %}
		{% for data_key,data_value in datas %}
			{% set attributes = attributes|merge( { ('data-'~data_key): data_value } ) %}
		{% endfor %}
	{% endif %}
	{% if disabled %}
		{% set attributes = attributes|merge( is_action ? { disabled: 'disabled' } : { 'aria-disabled': 'true', tabindex: '-1' } ) %}
	{% endif %}
	{% if is_action %}
		<button type="button"
				class="{{ classes|join(' ') }} {{ disabled ? 'disabled' : '' }}"{{ _self.renderAttributes( attributes ) }}
		>{{ text }}</button>
	{% else %}
		<a href="{{ disabled ? '#' : href }}"
		   class="{{ classes|join(' ') }} {{ disabled ? 'disabled' : '' }}"{{ _self.renderAttributes( attributes ) }}
		>{{ text }}</a>
	{% endif %}
{% endmacro %}

{% macro formInput_Hidden(name,value) %}
	<input name="{{ name }}" value="{{ value }}" type="hidden" />
{% endmacro %}

{#
 # A tick box that sends 'Y' when ticked. The help beneath it may hold links, so it's given as markup; everything
 # else is text.
 #}
{% macro formInput_Checkbox(name,toplabel,label,help,checked=false,classes='',enabled=true) %}
	<div class="row mb-3">
		<label class="col-4 col-form-label" for="_{{ name }}">{{ toplabel }}</label>
		<div class="col-8">
			<div class="form-check">
				<input type="checkbox" name="{{ name }}"
					   class="form-check-input {{ classes }} {{ enabled ? '' : 'disabled' }}"
					   id="_{{ name }}" value="Y"
						{{ checked ? 'checked' : '' }}
						{{ enabled ? '' : 'disabled' }}
				/>
				<label class="form-check-label" for="_{{ name }}">
					{{ label }}
				</label>
			</div>
			<small class="form-text text-muted">{{ help|raw }}</small>
		</div>
	</div>
{% endmacro %}

{% macro formInput_Password(name,label,placeholder,help='',classes='') %}
	<div class="form-group row">
		<label class="col-4 col-form-label" for="_{{ name }}">{{ label }}</label>
		<div class="col-8">
			<input name="{{ name }}" value="" type="password"
				   class="form-control {{ classes }}" id="_{{ name }}" placeholder="{{ placeholder }}"
			>
			{% if help is not empty %}
				<small class="form-text text-muted">{{ help }}</small>
			{% endif %}
		</div>
	</div>
{% endmacro %}

{% macro formInput_Submit(label,classes='') %}
	<div class="row">
		<div class="col-8 offset-4">
			<button type="submit" class="btn btn-secondary {{ classes }}">{{ label }}</button>
		</div>
	</div>
{% endmacro %}

{% macro silentcaptcha( classes=[] ) %}
	<span class="silentcaptcha {{ classes|join(' ') }}"><span class="fst-italic">silent</span><span
				class="text-capitalize">CAPTCHA</span></span></span>
{% endmacro %}
