{#
	The protection level picker (ProtectionLevelPicker builds its data), shown by the setup guide's step and by
	Configure's Protection level tab. Pick a level, see what changes: three choices, each saying how many settings it
	would change on this site, and under them one list of what the chosen level would change, as it is and as it
	would be. Every level's list is here; the picker script shows the chosen one, and the settings it leaves alone
	when their count is clicked. Each place gives its form's classes and data attributes: the setup guide's step is
	submitted the setup guide's way; elsewhere the form says where it goes.
#}
{% import '/common/macros.twig' as icwp_macros %}
<form class="{{ [ 'protection-levels' ]|merge( form_classes )|join( ' ' ) }}" data-protection-levels="1"
	  {%- for attr, value in form_data %} data-{{ attr }}="{{ value|e('html_attr') }}"{% endfor %}>
	{{ icwp_macros.formInput_Hidden( 'step_slug', vars.step_slug ) }}
	{{ icwp_macros.formInput_Hidden( 'picker_place', vars.place ) }}
	<input type="hidden" name="security_profile" value="{{ vars.recommended }}" data-protection-levels-choice="1">

	<div class="protection-levels__choices" role="group" aria-label="{{ strings.levels_label }}">
		{% for level in vars.levels %}
			<button type="button"
					class="protection-levels__choice"
					data-protection-level="{{ level.key }}"
					data-apply-label="{{ level.strings.apply|e('html_attr') }}"
					aria-pressed="{{ level.key == vars.recommended ? 'true' : 'false' }}">
				<span class="protection-levels__name">
					<span class="protection-levels__dot" aria-hidden="true"></span>{{ level.title }}
					{% if level.key == vars.recommended %}
						<span class="protection-levels__recommended">{{ strings.recommended }}</span>
					{% endif %}
				</span>
				<span class="protection-levels__subtitle">{{ level.subtitle }}</span>
				<span class="protection-levels__changes">{{ level.strings.changes }}</span>
				{% if level.strings.loosens is not empty %}
					<span class="protection-levels__loosens">{{ level.strings.loosens }}</span>
				{% endif %}
			</button>
		{% endfor %}
	</div>

	{% for level in vars.levels %}
		{% set comparison = level.comparison %}
		<div class="protection-levels__comparison"
			 data-protection-level-comparison="{{ level.key }}"
			 {% if level.key != vars.recommended %}hidden{% endif %}>
			<div class="protection-levels__summary">
				<strong>{{ level.strings.compared }}</strong>
				{% if comparison.stricter > 0 %}
					<span class="protection-levels__chip is-stricter">{{ strings.stricter|format( comparison.stricter ) }}</span>
				{% endif %}
				{% if comparison.looser > 0 %}
					<span class="protection-levels__chip is-looser">{{ strings.looser|format( comparison.looser ) }}</span>
				{% endif %}
				{# What a level leaves alone is out of the way; its count is the way to it, and back. #}
				{% if comparison.unchanged > 0 %}
					<button type="button"
							class="protection-levels__chip protection-levels__chip--toggle"
							data-protection-levels-show-unchanged="1"
							aria-pressed="false"
							title="{{ strings.show_unchanged|e('html_attr') }}">
						{{ strings.unchanged|format( comparison.unchanged ) }}<i class="bi bi-chevron-down" aria-hidden="true"></i>
					</button>
				{% endif %}
			</div>

			<div class="protection-levels__list">
				<div class="protection-levels__row protection-levels__row--head" aria-hidden="true">
					<span>{{ strings.col_setting }}</span>
					<span>{{ strings.col_now }}</span>
					<span></span>
					<span>{{ strings.col_after }}</span>
					<span></span>
				</div>
				{% if level.changes == 0 %}
					<p class="protection-levels__match">{{ strings.all_match }}</p>
				{% endif %}
				{% for group in comparison.groups %}
					<div class="protection-levels__group{{ group.has_changes ? ' has-changes' : '' }}">
						<div class="protection-levels__group-title">{{ group.title }}</div>
						{% for row in group.rows %}
							{# Written out in full: the stylesheet only keeps class names it can find in a template. #}
							{% set change_class = { stricter: 'is-stricter', looser: 'is-looser', same: 'is-same', unavailable: 'is-unavailable' }[row.change] %}
							<div class="protection-levels__row {{ change_class }}">
								<span class="protection-levels__setting">{{ row.title }}</span>
								<span class="protection-levels__now">{{ row.now }}</span>
								<span class="protection-levels__arrow" aria-hidden="true"><i class="bi bi-arrow-right"></i></span>
								<span class="protection-levels__after">{{ row.after }}</span>
								<span class="protection-levels__chip {{ change_class }}">{{ strings.change_labels[row.change] }}</span>
							</div>
						{% endfor %}
					</div>
				{% endfor %}
			</div>
		</div>
	{% endfor %}

	<div class="merlin-form-footer protection-levels__foot">
		{# With no level chosen yet there's nothing to apply, so the button waits for a choice. #}
		<button type="submit" class="btn btn-primary" data-protection-levels-apply="1"
				{% if vars.recommended is empty %}disabled{% endif %}>{{ vars.recommended is empty ? strings.choose_first : vars.levels[vars.recommended].strings.apply }}</button>
	</div>
</form>
