<div id="organization-permissions" data-name="organization-permissions" class="settings-section">
    <form class="form-horizontal admin-realm-form org-permissions-form">

        <div id="org-org-join" class="org-subsection-parent">
            <div class="subsection-header">
                <h3>{{t "Joining the organization" }}</h3>
                {{> settings_save_discard_widget section_name="org-join" }}
            </div>
            <div class="m-10 inline-block organization-permissions-parent">
                <div class="input-group">
                    <label for="realm_user_invite_restriction" class="dropdown-title">{{t "Are invitations required for joining the organization?" }}</label>
                    <select name="realm_user_invite_restriction" id="id_realm_user_invite_restriction" class="prop-element">
                        <option value="no_invite_required">{{t "No" }}</option>
                        <option value="by_anyone">{{t "Yes. Members and admins can send invitations." }}</option>
                        <option value="by_admins_only">{{t "Yes. Only admins can send invitations." }}</option>
                    </select>
                </div>

                <div class="input-group">
                    <label for="realm_org_join_restrictions" class="dropdown-title">{{t "Restrict email domains of new users?" }}</label>
                    <select name="realm_org_join_restrictions" id="id_realm_org_join_restrictions" class="prop-element">
                        <option value="no_restriction">{{t "No restrictions" }}</option>
                        <option value="no_disposable_email">{{t "Don’t allow disposable email addresses" }}</option>
                        <option value="only_selected_domain">{{t "Restrict to a list of domains" }}</option>
                    </select>
                </div>
                <div class="dependent-block">
                    <p id="allowed_domains_label" class="inline-block"></p>
                    {{#if is_admin }}
                    <a data-toggle="modal" href="#realm_domains_modal">{{t "[Configure]" }}</a>
                    {{/if}}
                </div>
                <div class="input-group">
                    <label for="realm_waiting_period_setting" class="dropdown-title">
                        {{t "Waiting period before new members turn into full members" }}
                        <a href="/help/restrict-permissions-of-new-members" target="_blank">
                            <i class="fa fa-question-circle-o" aria-hidden="true"></i>
                        </a>
                    </label>
                    <select name="realm_waiting_period_setting" id="id_realm_waiting_period_setting" class="prop-element">
                        <option value="none">{{t "None" }}</option>
                        <option value="three_days">{{t "3 days" }}</option>
                        <option value="custom_days">{{t "Custom" }}</option>
                    </select>
                </div>
                {{!-- This setting is hidden unless `custom_days` --}}
                <div class="dependent-block">
                    <label for="aitin" class="inline-block">{{t "Waiting period (days)" }}:</label>
                    <input type="text" id="id_realm_waiting_period_threshold"
                      name="realm_waiting_period_threshold"
                      class="admin-realm-time-limit-input prop-element"
                      value="{{ realm_waiting_period_threshold }}"/>
                </div>
            </div>
        </div>

        <div id="org-user-identity" class="org-subsection-parent">
            <div class="subsection-header">
                <h3>{{t "User identity" }}</h3>
                {{> settings_save_discard_widget section_name="user-identity" }}
            </div>
            <div class="inline-block organization-permissions-parent">
                {{> settings_checkbox
                  setting_name="realm_name_changes_disabled"
                  prefix="id_"
                  is_checked=realm_name_changes_disabled
                  label=admin_settings_label.realm_name_changes_disabled}}

                {{> settings_checkbox
                  setting_name="realm_email_changes_disabled"
                  prefix="id_"
                  is_checked=realm_email_changes_disabled
                  label=admin_settings_label.realm_email_changes_disabled}}

                {{> settings_checkbox
                  setting_name="realm_avatar_changes_disabled"
                  prefix="id_"
                  is_checked=realm_avatar_changes_disabled
                  label=admin_settings_label.realm_avatar_changes_disabled}}
            </div>
            <div class="input-group">
                <label for="realm_email_address_visibility">{{t "Who can access user email addresses" }}
                    <a href="/help/restrict-visibility-of-email-addresses" target="_blank">
                        <i class="fa fa-question-circle-o" aria-hidden="true"></i>
                    </a>
                </label>
                <select name="realm_email_address_visibility" class="setting-widget prop-element" id="id_realm_email_address_visibility" data-setting-widget-type="integer">
                    {{> dropdown_options_widget option_values=email_address_visibility_values}}
                </select>
            </div>
        </div>

        <div id="org-stream-permissions" class="org-subsection-parent">
            <div class="subsection-header">
                <h3>{{t "Stream permissions" }}</h3>
                {{> settings_save_discard_widget section_name="stream-permissions" }}
            </div>
            <div class="m-10 inline-block organization-permissions-parent">
                <div class="input-group">
                    <label for="realm_create_stream_policy" class="dropdown-title">{{t "Who can create streams" }}</label>
                    <select name="realm_create_stream_policy" id="id_realm_create_stream_policy" class="prop-element" data-setting-widget-type="integer">
                        {{> dropdown_options_widget option_values=create_stream_policy_values}}
                    </select>
                </div>
                <div class="input-group">
                    <label for="realm_invite_to_stream_policy" class="dropdown-title">{{t "Who can add users to streams" }}</label>
                    <select name="realm_invite_to_stream_policy" id="id_realm_invite_to_stream_policy" class="prop-element" data-setting-widget-type="integer">
                        {{> dropdown_options_widget option_values=invite_to_stream_policy_values}}
                    </select>
                </div>
            </div>
        </div>

        <div id="org-other-permissions" class="org-subsection-parent">
            <div class="subsection-header">
                <h3>{{t "Other permissions" }}</h3>
                {{> settings_save_discard_widget section_name="other-permissions" }}
            </div>
            <div class="m-10 inline-block organization-permissions-parent">
                <div class="input-group">
                    <label for="realm_bot_creation_policy">{{t "Who can add bots" }}</label>
                    <select name="realm_bot_creation_policy" class="setting-widget prop-element" id="id_realm_bot_creation_policy" data-setting-widget-type="integer">
                        {{> dropdown_options_widget option_values=bot_creation_policy_values}}
                    </select>
                </div>

                <div class="input-group">
                    <label for="realm_user_group_edit_policy" class="dropdown-title">{{t "Who can create and manage user groups" }}</label>
                    <select name="realm_user_group_edit_policy" id="id_realm_user_group_edit_policy" class="prop-element" data-setting-widget-type="integer">
                        {{> dropdown_options_widget option_values=user_group_edit_policy_values}}
                    </select>
                </div>

                <div class="input-group">
                    <label for="realm_add_emoji_by_admins_only" class="dropdown-title">{{t "Who can add custom emoji" }}</label>
                    <select name="realm_add_emoji_by_admins_only" id="id_realm_add_emoji_by_admins_only" class="prop-element">
                        <option value="by_admins_only">{{t "Admins" }}</option>
                        <option value="by_anyone">{{t "Admins and members" }}</option>
                    </select>
                </div>

                <div class="input-group">
                    <label for="realm_private_message_policy">{{t "Who can use private messages" }} ({{t "beta" }})
                        <a href="/help/restrict-private-messages" target="_blank">
                            <i class="fa fa-question-circle-o" aria-hidden="true"></i>
                        </a>
                    </label>
                    <select name="realm_private_message_policy" class="setting-widget prop-element" id="id_realm_private_message_policy" data-setting-widget-type="integer">
                        {{> dropdown_options_widget option_values=private_message_policy_values}}
                    </select>
                </div>
            </div>
        </div>
    </form>
</div>
