<div class="modal-content">
    <div class="modal-header">
        <h5 class="modal-title"><%- i18n('streams', 'form-title', {id: id}) %></h5>
        <button type="button" class="close cancel" aria-label="Close" data-dismiss="modal">&nbsp;</button>
    </div>
    <div class="modal-body has-tabs">
        <div class="alert alert-danger mb-0 rounded-0" id="le-error-info" role="alert"></div>
        <form>
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="nav-item"><a href="#details" aria-controls="tab1" role="tab" data-toggle="tab" class="nav-link active"><i class="fe fe-zap"></i> <%- i18n('all-hosts', 'details') %></a></li>
                <li role="presentation" class="nav-item"><a href="#ssl-options" aria-controls="tab2" role="tab" data-toggle="tab" class="nav-link"><i class="fe fe-shield"></i> <%- i18n('str', 'ssl') %></a></li>
            </ul>
            <div class="tab-content">
                <!-- Details -->
                <div role="tabpanel" class="tab-pane active" id="details">
                    <div class="row">
                        <div class="col-sm-12 col-md-12">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('streams', 'incoming-port') %> <span class="form-required">*</span></label>
                                <input name="incoming_port" type="number" class="form-control text-monospace" placeholder="eg: 8080" min="1" max="65535" value="<%- incoming_port %>" required>
                            </div>
                        </div>
                        <div class="col-sm-8 col-md-8">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('streams', 'forwarding-host') %><span class="form-required">*</span></label>
                                <input type="text" name="forwarding_host" class="form-control text-monospace" placeholder="example.com or 10.0.0.1 or 2001:db8:3333:4444:5555:6666:7777:8888" value="<%- forwarding_host %>" autocomplete="off" maxlength="255" required>
                            </div>
                        </div>
                        <div class="col-sm-4 col-md-4">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('streams', 'forwarding-port') %> <span class="form-required">*</span></label>
                                <input name="forwarding_port" type="number" class="form-control text-monospace" placeholder="eg: 80" min="1" max="65535" value="<%- forwarding_port %>" required>
                            </div>
                        </div>
                        <div class="col-sm-6 col-md-6">
                            <div class="form-group">
                                <label class="custom-switch">
                                    <input type="checkbox" class="custom-switch-input" name="tcp_forwarding" value="1"<%- tcp_forwarding ? ' checked' : '' %>>
                                    <span class="custom-switch-indicator"></span>
                                    <span class="custom-switch-description"><%- i18n('streams', 'tcp-forwarding') %></span>
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-6 col-md-6">
                            <div class="form-group">
                                <label class="custom-switch">
                                    <input type="checkbox" class="custom-switch-input" name="udp_forwarding" value="1"<%- udp_forwarding ? ' checked' : '' %>>
                                    <span class="custom-switch-indicator"></span>
                                    <span class="custom-switch-description"><%- i18n('streams', 'udp-forwarding') %></span>
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-12">
                            <div class="forward-type-error invalid-feedback"><%- i18n('streams', 'forward-type-error') %></div>
                        </div>
                    </div>
                </div>

                <!-- SSL -->
                <div role="tabpanel" class="tab-pane" id="ssl-options">
                    <div class="row">
                        <div class="col-sm-12 col-md-12">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('streams', 'ssl-certificate') %></label>
                                <select name="certificate_id" class="form-control custom-select" placeholder="<%- i18n('all-hosts', 'none') %>">
                                    <option selected value="0" data-data="{&quot;id&quot;:0}" <%- certificate_id ? '' : 'selected' %>><%- i18n('all-hosts', 'none') %></option>
                                    <option selected value="new" data-data="{&quot;id&quot;:&quot;new&quot;}"><%- i18n('all-hosts', 'new-cert') %></option>
                                </select>
                            </div>
                        </div>

                        <!-- DNS challenge -->
                        <div class="col-sm-12 col-md-12 letsencrypt">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('all-hosts', 'domain-names') %> <span class="form-required">*</span></label>
                                <input type="text" name="domain_names" class="form-control" id="input-domains" value="<%- domain_names.join(',') %>">
                            </div>
                            <div class="form-group">
                                <label class="custom-switch">
                                    <input
                                            type="checkbox"
                                            class="custom-switch-input"
                                            name="meta[dns_challenge]"
                                            value="1"
                                            checked
                                            disabled
                                    >
                                    <span class="custom-switch-indicator"></span>
                                    <span class="custom-switch-description"><%= i18n('ssl', 'dns-challenge') %></span>
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-12 letsencrypt">
                            <fieldset class="form-fieldset dns-challenge">
                                <div class="text-red mb-4"><i class="fe fe-alert-triangle"></i> <%= i18n('ssl', 'certbot-warning') %></div>

                                <!-- Certbot DNS plugin selection -->
                                <div class="row">
                                    <div class="col-sm-12 col-md-12">
                                        <div class="form-group">
                                            <label class="form-label"><%- i18n('ssl', 'dns-provider') %> <span class="form-required">*</span></label>
                                            <select
                                                    name="meta[dns_provider]"
                                                    id="dns_provider"
                                                    class="form-control custom-select"
                                            >
                                                <option
                                                        value=""
                                                        disabled
                                                        hidden
                                                        <%- getDnsProvider() === null ? 'selected' : '' %>
                                                >Please Choose...</option>
                                                <% _.each(dns_plugins, function(plugin_info, plugin_name){ %>
                                                    <option
                                                            value="<%- plugin_name %>"
                                                            <%- getDnsProvider() === plugin_name ? 'selected' : '' %>
                                                    ><%- plugin_info.name %></option>
                                                <% }); %>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <!-- Certbot credentials file content -->
                                <div class="row credentials-file-content">
                                    <div class="col-sm-12 col-md-12">
                                        <div class="form-group">
                                            <label class="form-label"><%- i18n('ssl', 'credentials-file-content') %> <span class="form-required">*</span></label>
                                            <textarea
                                                    name="meta[dns_provider_credentials]"
                                                    class="form-control text-monospace"
                                                    id="dns_provider_credentials"
                                            ><%- getDnsProviderCredentials() %></textarea>
                                            <div class="text-secondary small">
                                                <i class="fe fe-info"></i>
                                                <%= i18n('ssl', 'credentials-file-content-info') %>
                                            </div>
                                            <div class="text-red small">
                                                <i class="fe fe-alert-triangle"></i>
                                                <%= i18n('ssl', 'stored-as-plaintext-info') %>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- DNS propagation delay -->
                                <div class="row">
                                    <div class="col-sm-12 col-md-12">
                                        <div class="form-group mb-0">
                                            <label class="form-label"><%- i18n('ssl', 'propagation-seconds') %></label>
                                            <input
                                                    type="number"
                                                    min="0"
                                                    name="meta[propagation_seconds]"
                                                    class="form-control"
                                                    id="propagation_seconds"
                                                    value="<%- getPropagationSeconds() %>"
                                            >
                                            <div class="text-secondary small">
                                                <i class="fe fe-info"></i>
                                                <%= i18n('ssl', 'propagation-seconds-info') %>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        </div>

                        <!-- Lets encrypt -->
                        <div class="col-sm-12 col-md-12 letsencrypt">
                            <div class="form-group">
                                <label class="form-label"><%- i18n('ssl', 'letsencrypt-email') %> <span class="form-required">*</span></label>
                                <input name="meta[letsencrypt_email]" type="email" class="form-control" placeholder="" value="<%- getLetsencryptEmail() %>" required disabled>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-12 letsencrypt">
                            <div class="form-group">
                                <label class="custom-switch">
                                    <input type="checkbox" class="custom-switch-input" name="meta[letsencrypt_agree]" value="1" required disabled>
                                    <span class="custom-switch-indicator"></span>
                                    <span class="custom-switch-description"><%= i18n('ssl', 'letsencrypt-agree', {url: 'https://letsencrypt.org/repository/'}) %> <span class="form-required">*</span></span>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-secondary cancel" data-dismiss="modal"><%- i18n('str', 'cancel') %></button>
        <button type="button" class="btn btn-teal save"><%- i18n('str', 'save') %></button>
    </div>
</div>
