<div class="modal fade" id="add-recipient-modal" tabindex="-1" role="dialog" aria-labelledby="add-endpoint-modal-title"
    aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="add-recipient-modal-title">{{ i18n("endpoint_notifications.add_new_recipient") }}</h5>
                <div class="modal-close">
                    <div class="confirm-closing" style="display: none;">
                        <span class='mx-2' style="vertical-align: middle;"><b>{{ i18n("endpoint_notifications.validation.abort_add_recipient") }}</b></span>
                        <div class="btn-group btn-group-sm">
                            <button class="btn btn-secondary cancel" type="button">{{ i18n("cancel") }}</button>
                            <button data-dismiss="modal" class="btn btn-danger confirm" type="button">{{ i18n("abort") }}</button>
                        </div>
                    </div>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            </div>
            <form autocomplete="off">
                <div class="modal-body">
                    <div class="form-group row">
                        <label class="col-form-label col-sm-3" for="recipient-name-input">
                            <b>{{ i18n("endpoint_notifications.recipient_name") }}</b>
                        </label>
                        <div class="col-sm-5">
                            <input minlength="1" required name="recipient_name" type="text" class="form-control" id="recipient-name-input">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-form-label col-sm-3" for="recipient-type-select">
                            <b>{{ i18n("endpoint_notifications.recipient_select") }}</b>
                        </label>
                        <div class="col-sm-5">
                            <select required name="endpoint" class="form-control" id="endpoint-select">
                                {% for i, endpoint in ipairs(endpoint_list) do %}
				                    {% if not endpoint.endpoint_conf.builtin then %}
                                           <option {{ (i == 1 and "selected" or "") }} data-endpoint-key="{{ endpoint.endpoint_key }}" value="{{ endpoint.endpoint_conf_name }}">
                                             {{ endpoint.endpoint_conf_name }}
                                         </option>
				                    {% end %}
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <div class="recipient-template-container" style="display: none;">

                    </div>
                    <hr>
                    <div class="form-group row">
                        <label class="col-form-label col-sm-3" for="recipient-severity-select">
                            <b>{{ i18n("endpoint_notifications.recipient_severity") }}</b>
                        </label>
                        <div class="col-sm-5">
                            <select required name="recipient_minimum_severity" class="form-control" id="recipient-severity-select">
                                {% for key, alert in pairsByField(alert_severities, 'severity_id', asc) do %}
                                    <option {{ (alert.severity_id == 0 and 'selected' or '') }} value="{{ alert.severity_id }}">{{ i18n("endpoint_notifications.severities."..key) }}</option>
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-form-label col-sm-3" for="recipient-name-input">
                            <b>{{ i18n("endpoint_notifications.recipient_category") }}</b>
                        </label>
                        <div class="col-sm-5">
                            <select multiple name="recipient_user_script_categories" class="form-control selectpicker" id="add-recipient-categories-select">
                                {% for _, category in pairsByKeys(script_categories) do %}
                                    <option selected value="{{ category.id }}">{{ i18n(category.i18n_title) }}</option>
                                {% end %}
                            </select>
                        </div>
                    </div>
                    <span class="invalid-feedback"></span>
                </div>
                <div class="modal-footer">
                    <div class="mr-auto">
                        <button disabled id="add-test-recipient" type="test" class="btn btn-secondary">
                            <span style="display: none;" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                            {{ i18n("endpoint_notifications.test_recipient") }}
                        </button>
                        <span style="display: none;" class="test-feedback"></span>
                    </div>
                    <button type="submit" class="btn btn-primary">{{i18n("add")}}</button>
                </div>
            </form>
        </div>
    </div>
</div>