<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <kc-tabs-realm></kc-tabs-realm>

    <form class="form-horizontal" name="realmForm" novalidate kc-read-only="!access.manageRealm">

        <div class="form-group">
            <label class="col-md-2 control-label" for="defaultSignatureAlgorithm">{{:: 'default-signature-algorithm' | translate}}</label>

            <div class="col-md-6">
                <select id="defaultSignatureAlgorithm" class="form-control" ng-model="realm.defaultSignatureAlgorithm"
                        ng-options="provider for provider in serverInfo.listProviderIds('signature')">
                </select>
            </div>

            <kc-tooltip>{{:: 'default-signature-algorithm.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="revokeRefreshToken">{{:: 'revoke-refresh-token' | translate}}</label>

            <div class="col-md-6">
                <input ng-change="" ng-model="realm.revokeRefreshToken" name="revokeRefreshToken" id="revokeRefreshToken" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
            </div>

            <kc-tooltip>{{:: 'revoke-refresh-token.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group" data-ng-show="realm.revokeRefreshToken == true">
            <label class="col-md-2 control-label" for="refreshTokenMaxReuse">{{:: 'refresh-token-max-reuse' | translate}}</label>

            <div class="col-md-6">
                <input class="form-control" type="number" required min="0" max="31536000" data-ng-model="realm.refreshTokenMaxReuse" id="refreshTokenMaxReuse"
                       name="refreshTokenMaxReuse"/>
            </div>

            <kc-tooltip>{{:: 'refresh-token-max-reuse.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="ssoSessionIdleTimeout">{{:: 'sso-session-idle' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.ssoSessionIdleTimeout.time" id="ssoSessionIdleTimeout"
                       name="ssoSessionIdleTimeout"/>
                <select class="form-control" name="ssoSessionIdleTimeoutUnit" data-ng-model="realm.ssoSessionIdleTimeout.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'sso-session-idle.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="ssoSessionMaxLifespan">{{:: 'sso-session-max' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1"
                       max="31536000" data-ng-model="realm.ssoSessionMaxLifespan.time"
                       id="ssoSessionMaxLifespan" name="ssoSessionMaxLifespan"/>
                <select class="form-control" name="ssoSessionMaxLifespanUnit" data-ng-model="realm.ssoSessionMaxLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'sso-session-max.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="ssoSessionIdleTimeoutRememberMe">{{:: 'sso-session-idle-remember-me' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0"
                       max="31536000" data-ng-model="realm.ssoSessionIdleTimeoutRememberMe.time"
                       id="ssoSessionIdleTimeoutRememberMe" name="ssoSessionIdleTimeoutRememberMe"/>
                <select class="form-control" name="ssoSessionIdleTimeoutRememberMe" data-ng-model="realm.ssoSessionIdleTimeoutRememberMe.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'sso-session-idle-remember-me.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="ssoSessionMaxLifespanRememberMe">{{:: 'sso-session-max-remember-me' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0"
                       max="31536000" data-ng-model="realm.ssoSessionMaxLifespanRememberMe.time"
                       id="ssoSessionMaxLifespanRememberMe" name="ssoSessionMaxLifespanRememberMe"/>
                <select class="form-control" name="ssoSessionMaxLifespanRememberMeUnit" data-ng-model="realm.ssoSessionMaxLifespanRememberMe.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'sso-session-max-remember-me.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="offlineSessionIdleTimeout">{{:: 'offline-session-idle' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1"
                       max="31536000" data-ng-model="realm.offlineSessionIdleTimeout.time"
                       id="offlineSessionIdleTimeout" name="offlineSessionIdleTimeout"/>
                <select class="form-control" name="offlineSessionIdleTimeoutUnit" data-ng-model="realm.offlineSessionIdleTimeout.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'offline-session-idle.tooltip' | translate}}</kc-tooltip>
        </div>

        <!-- KEYCLOAK-7688 Offline Session Max for Offline Token -->
        <div class="form-group">
            <label class="col-md-2 control-label" for="offlineSessionMaxLifespanEnabled">{{:: 'offline-session-max-limited' | translate}}</label>
            <div class="col-md-3">
                <input ng-change="" ng-model="realm.offlineSessionMaxLifespanEnabled"
                       name="offlineSessionMaxLifespanEnabled"
                       id="offlineSessionMaxLifespanEnabled"
                       onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}"/>
            </div>
            <kc-tooltip>{{:: 'offline-session-max-limited.tooltip' | translate}}</kc-tooltip>
        </div>
        <div class="form-group" data-ng-show="realm.offlineSessionMaxLifespanEnabled">
            <label class="col-md-2 control-label" for="offlineSessionMaxLifespan">{{:: 'offline-session-max' | translate}}</label>
            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1"
                       max="31536000" data-ng-model="realm.offlineSessionMaxLifespan.time"
                       id="offlineSessionMaxLifespan" name="offlineSessionMaxLifespan"/>
                <select class="form-control" name="offlineSessionMaxLifespanUnit" data-ng-model="realm.offlineSessionMaxLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'offline-session-max.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group" data-ng-show="realm.offlineSessionMaxLifespanEnabled">
            <label class="col-md-2 control-label" for="clientOfflineSessionIdleTimeout">{{::
                'client-offline-session-idle' | translate}}</label>
            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0" max="31536000"
                    data-ng-model="realm.clientOfflineSessionIdleTimeout.time" id="clientOfflineSessionIdleTimeout"
                    name="clientOfflineSessionIdleTimeout" /> <select class="form-control"
                    name="clientOfflineSessionIdleTimeoutUnit" data-ng-model="realm.clientOfflineSessionIdleTimeout.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'client-offline-session-idle.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group" data-ng-show="realm.offlineSessionMaxLifespanEnabled">
            <label class="col-md-2 control-label" for="clientOfflineSessionMaxLifespan">{{::
                'client-offline-session-max' | translate}}</label>
            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0" max="31536000"
                    data-ng-model="realm.clientOfflineSessionMaxLifespan.time" id="clientOfflineSessionMaxLifespan"
                    name="clientOfflineSessionMaxLifespan" /> <select class="form-control"
                    name="clientOfflineSessionMaxLifespanUnit" data-ng-model="realm.clientOfflineSessionMaxLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'client-offline-session-max.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="clientSessionIdleTimeout">{{:: 'client-session-idle' | translate}}</label>
            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0"
                       max="31536000" data-ng-model="realm.clientSessionIdleTimeout.time"
                       id="clientSessionIdleTimeout" name="clientSessionIdleTimeout"/>
                <select class="form-control" name="clientSessionIdleTimeoutUnit" data-ng-model="realm.clientSessionIdleTimeout.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'client-session-idle.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="clientSessionMaxLifespan">{{:: 'client-session-max' | translate}}</label>
            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="0"
                       max="31536000" data-ng-model="realm.clientSessionMaxLifespan.time"
                       id="clientSessionMaxLifespan" name="clientSessionMaxLifespan"/>
                <select class="form-control" name="clientSessionMaxLifespanUnit" data-ng-model="realm.clientSessionMaxLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'client-session-max.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="accessTokenLifespan">{{:: 'access-token-lifespan' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1"
                       max="31536000" data-ng-model="realm.accessTokenLifespan.time"
                       id="accessTokenLifespan" name="accessTokenLifespan"/>
                <select class="form-control" name="accessTokenLifespanUnit" data-ng-model="realm.accessTokenLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'access-token-lifespan.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="accessTokenLifespanForImplicitFlow">{{:: 'access-token-lifespan-for-implicit-flow' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1"
                       max="31536000" data-ng-model="realm.accessTokenLifespanForImplicitFlow.time"
                       id="accessTokenLifespanForImplicitFlow" name="accessTokenLifespanForImplicitFlow"/>
                <select class="form-control" name="accessTokenLifespanForImplicitFlowUnit" data-ng-model="realm.accessTokenLifespanForImplicitFlow.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'access-token-lifespan-for-implicit-flow.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="accessCodeLifespan">{{:: 'client-login-timeout' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.accessCodeLifespan.time" id="accessCodeLifespan"
                       name="accessCodeLifespan">
                <select class="form-control" name="accessCodeLifespanUnit" data-ng-model="realm.accessCodeLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'client-login-timeout.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="accessCodeLifespanLogin" class="two-lines">{{:: 'login-timeout' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.accessCodeLifespanLogin.time"
                       id="accessCodeLifespanLogin" name="accessCodeLifespanLogin">
                <select class="form-control" name="accessCodeLifespanLoginUnit" data-ng-model="realm.accessCodeLifespanLogin.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'login-timeout.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="accessCodeLifespanUserAction" class="two-lines">{{:: 'login-action-timeout' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.accessCodeLifespanUserAction.time"
                       id="accessCodeLifespanUserAction" name="accessCodeLifespanUserAction">
                <select class="form-control" name="accessCodeLifespanUserActionUnit" data-ng-model="realm.accessCodeLifespanUserAction.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>
                {{:: 'login-action-timeout.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="actionTokenGeneratedByUserLifespan" class="two-lines">{{:: 'action-token-generated-by-user-lifespan' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.actionTokenGeneratedByUserLifespan.time"
                       id="actionTokenGeneratedByUserLifespan" name="actionTokenGeneratedByUserLifespan">
                <select class="form-control" name="actionTokenGeneratedByUserLifespanUnit" data-ng-model="realm.actionTokenGeneratedByUserLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>
                {{:: 'action-token-generated-by-user-lifespan.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="actionTokenGeneratedByAdminLifespan" class="two-lines">{{:: 'action-token-generated-by-admin-lifespan' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.actionTokenGeneratedByAdminLifespan.time"
                       id="actionTokenGeneratedByAdminLifespan" name="actionTokenGeneratedByAdminLifespan">
                <select class="form-control" name="actionTokenGeneratedByAdminLifespanUnit" data-ng-model="realm.actionTokenGeneratedByAdminLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>
                {{:: 'action-token-generated-by-admin-lifespan.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="requestUriLifespan" class="two-lines">{{:: 'request-uri-lifespan' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" string-to-number data-ng-model="realm.attributes.parRequestUriLifespan.time"
                       id="requestUriLifespan" name="requestUriLifespan">
                <select class="form-control" name="requestUriLifespanUnit" data-ng-model="realm.attributes.parRequestUriLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>
                {{:: 'request-uri-lifespan.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="actionTokenAttributeSelect" class="two-lines">
                {{:: 'action-token-generated-by-user.operation' | translate }} </label>
            <div class="form-inline col-md-6 time-selector">
                <select class="form-control" name="actionTokenAttributeSelect" id="actionTokenAttributeSelect"
                        ng-model="actionLifespanId">
                    <option value="" disabled selected>{{:: 'select-one.placeholder' | translate}}</option>
                    <option ng-repeat="(actionTokenId, value) in actionTokenProviders" value="{{actionTokenId}}">
                        {{:: 'action-token-generated-by-user.' + actionTokenId | translate }}
                    </option>
                </select>
                <input class="form-control" type="number" min="1" max="31536000" data-ng-model="actionTokenAttribute.time"
                       id="actionTokenAttributeTime" name="actionTokenAttributeTime">
                <select class="form-control" name="actionTokenAttributeUnit"
                        data-ng-model="actionTokenAttribute.unit">
                    <option value="Minutes" ng-selected="true">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
                <button data-ng-click="resetToDefaultToken(actionTokenId)">{{:: 'action-token-generated-by-user.reset' | translate}}</button>
            </div>
            <kc-tooltip>
                {{:: 'action-token-generated-by-user.tooltip' | translate}}
            </kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="oauth2DeviceCodeLifespan">{{:: 'oauth2-device-code-lifespan' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.oauth2DeviceCodeLifespan.time" id="oauth2DeviceCodeLifespan"
                       name="oauth2DeviceCodeLifespan">
                <select class="form-control" name="oauth2DeviceCodeLifespanUnit" data-ng-model="realm.oauth2DeviceCodeLifespan.unit">
                    <option value="Minutes">{{:: 'minutes' | translate}}</option>
                    <option value="Hours">{{:: 'hours' | translate}}</option>
                    <option value="Days">{{:: 'days' | translate}}</option>
                </select>
            </div>
            <kc-tooltip>{{:: 'oauth2-device-code-lifespan.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <label class="col-md-2 control-label" for="oauth2DevicePollingInterval">{{:: 'oauth2-device-polling-interval' | translate}}</label>

            <div class="col-md-6 time-selector">
                <input class="form-control" type="number" required min="1" max="31536000" data-ng-model="realm.oauth2DevicePollingInterval" id="oauth2DevicePollingInterval"
                       name="oauth2DevicePollingInterval">
            </div>
            <kc-tooltip>{{:: 'oauth2-device-polling-interval.tooltip' | translate}}</kc-tooltip>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="access.manageRealm">
                <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
                <button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
            </div>
        </div>

    </form>

</div>

<kc-menu></kc-menu>