<fieldset class="iz-fieldset">
	<legend class="iz-legend iz-visually-hidden">{{ L_TO }}</legend>

	{% if S_ALLOW_MASS_PM %}

		{% if to_recipient %}
			<div class="iz-field">
				<div class="iz-label">{{ L_TO }}{{ L_COLON }}</div>

				<div class="iz-tags" role="list" aria-label="{{ L_TO }}">
					{% for to_recipient in to_recipient %}
						{% if not to_recipient.S_FIRST_ROW and to_recipient.S_ROW_COUNT mod 4 == 0 %}
							</div><div class="iz-tags" role="list" aria-label="{{ L_TO }}">
						{% endif %}

						<span class="iz-tag" role="listitem">
							{% if to_recipient.IS_GROUP %}
								<a class="iz-link" href="{{ to_recipient.U_VIEW }}"><strong>{{ to_recipient.NAME }}</strong></a>
							{% else %}
								{{ to_recipient.NAME_FULL }}
							{% endif %}

							{% if not S_EDIT_POST %}
								<input
									type="submit"
									name="remove_{{ to_recipient.TYPE }}[{{ to_recipient.UG_ID }}]"
									value="×"
									title="{{ L_USER_REMOVE_PLACEHOLDER }}"
									class="iz-tag__remove"
								/>
							{% endif %}
						</span>
					{% endfor %}
				</div>
			</div>
		{% endif %}

		{% if bcc_recipient %}
			<div class="iz-field">
				<div class="iz-label">{{ L_BCC }}{{ L_COLON }}</div>

				<div class="iz-tags" role="list" aria-label="{{ L_BCC }}">
					{% for bcc_recipient in bcc_recipient %}
						{% if not bcc_recipient.S_FIRST_ROW and bcc_recipient.S_ROW_COUNT mod 4 == 0 %}
							</div><div class="iz-tags" role="list" aria-label="{{ L_BCC }}">
						{% endif %}

						<span class="iz-tag" role="listitem">
							{% if bcc_recipient.IS_GROUP %}
								<a class="iz-link" href="{{ bcc_recipient.U_VIEW }}"><strong>{{ bcc_recipient.NAME }}</strong></a>
							{% else %}
								{{ bcc_recipient.NAME_FULL }}
							{% endif %}

							{% if not S_EDIT_POST %}
								<input
									type="submit"
									name="remove_{{ bcc_recipient.TYPE }}[{{ bcc_recipient.UG_ID }}]"
									value="×"
									title="{{ L_GROUP_REMOVE_PLACEHOLDER }}"
									class="iz-tag__remove"
								/>
							{% endif %}
						</span>
					{% endfor %}
				</div>
			</div>
		{% endif %}

		{% if not S_EDIT_POST %}
			<div class="iz-field">
				<label class="iz-label" for="username_list">{{ L_TO }}{{ L_COLON }}</label>

				<div class="iz-inputgroup">
					<input
						type="text"
						id="username_list"
						name="username_list"
						class="iz-input"
						tabindex="1"
						autocomplete="off"
					/>

					<button class="iz-btn iz-btn--ghost" name="add_to" value="{{ L_ADD }}" type="submit" title="{{ L_ADD }}">
						{{ L_ADD }}
					</button>

					<button class="iz-btn iz-btn--ghost" name="add_bcc" value="{{ L_ADD_BCC }}" type="submit" title="{{ L_ADD_BCC }}">
						{{ L_ADD_BCC }}
					</button>

					<a class="iz-btn iz-btn--ghost" href="{{ U_FIND_USERNAME }}" onclick="find_username(this.href); return false;" title="{{ L_FIND_USERNAME }}">
						{{ L_FIND_USERNAME }}
					</a>

					{% EVENT posting_pm_header_find_username_after %}
				</div>
			</div>
		{% endif %}

	{% else %}

		<div class="iz-field">
			<label class="iz-label" for="username_list">{{ L_TO }}{{ L_COLON }}</label>
			{% if not S_EDIT_POST %}
				<p class="iz-hint">
					<a class="iz-link" href="{{ U_FIND_USERNAME }}" onclick="find_username(this.href); return false">{{ L_FIND_USERNAME }}</a>
				</p>
			{% endif %}

			{% if to_recipient %}
				<div id="tagsinput" class="iz-tags" role="list" aria-label="{{ L_TO }}">
					{% for to_recipient in to_recipient %}
						{% if not to_recipient.S_FIRST_ROW and to_recipient.S_ROW_COUNT mod 4 == 0 %}
							</div><div id="tagsinput" class="iz-tags" role="list" aria-label="{{ L_TO }}">
						{% endif %}

						<span class="iz-tag" role="listitem">
							{% if to_recipient.IS_GROUP %}
								<a class="iz-link" href="{{ to_recipient.U_VIEW }}"><strong>{{ to_recipient.NAME }}</strong></a>
							{% else %}
								{{ to_recipient.NAME_FULL }}
							{% endif %}

							{% if not S_EDIT_POST %}
								<input type="submit" name="remove_{{ to_recipient.TYPE }}[{{ to_recipient.UG_ID }}]" value="×" class="iz-tag__remove" />
							{% endif %}
						</span>
					{% endfor %}
				</div>
			{% endif %}

			{% if not S_EDIT_POST %}
				<div class="iz-inputgroup">
					<input class="iz-input" type="text" name="username_list" id="username_list" value="" autocomplete="off" />
					<input type="submit" name="add_to" value="{{ L_ADD }}" class="iz-btn iz-btn--ghost" />
				</div>
			{% endif %}
		</div>

	{% endif %}

	{% if S_GROUP_OPTIONS %}
		<div class="iz-field">
			<label class="iz-label" for="group_list">{{ L_USERGROUPS }}{{ L_COLON }}</label>
			<select class="iz-select" name="group_list[]" id="group_list" multiple="multiple" size="4">
				{{ S_GROUP_OPTIONS }}
			</select>
		</div>
	{% endif %}
</fieldset>
