<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <ol class="breadcrumb">
        <li><a href="#/realms/{{realm.realm}}/identity-provider-settings">{{:: 'identity-providers' | translate}}</a></li>
        <li data-ng-show="!newIdentityProvider && identityProvider.displayName">{{identityProvider.displayName}}</li>
        <li data-ng-show="!newIdentityProvider && !identityProvider.displayName">{{identityProvider.alias}}</li>
        <li data-ng-show="newIdentityProvider">{{:: 'add-identity-provider' | translate}}</li>
    </ol>

    <kc-tabs-identity-provider></kc-tabs-identity-provider>

    <form class="form-horizontal" name="realmForm" novalidate kc-read-only="!access.manageIdentityProviders">
        <fieldset>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="redirectUri">{{:: 'redirect-uri' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="redirectUri" type="text" value="{{callbackUrl}}{{identityProvider.alias}}/endpoint" readonly kc-select-action="click">
                </div>
                <kc-tooltip>{{:: 'redirect-uri.tooltip' | translate}}</kc-tooltip>
            </div>
        </fieldset>
        <fieldset>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="identifier"><span class="required">*</span> {{:: 'alias' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="identifier" type="text" ng-model="identityProvider.alias" data-ng-readonly="!newIdentityProvider" required>
                </div>
                <kc-tooltip>{{:: 'identity-provider.alias.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="displayName"> {{:: 'display-name' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="displayName" type="text" ng-model="identityProvider.displayName">
                </div>
                <kc-tooltip>{{:: 'identity-provider.display-name.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="enabled">{{:: 'enabled' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.enabled" id="enabled" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'identity-provider.enabled.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="storeToken">{{:: 'store-tokens' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.storeToken" id="storeToken" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'identity-provider.store-tokens.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="storedTokensReadable">{{:: 'stored-tokens-readable' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.addReadTokenRoleOnCreate" id="storedTokensReadable" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'identity-provider.stored-tokens-readable.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="trustEmail">{{:: 'trust-email' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.trustEmail" name="identityProvider.trustEmail" id="trustEmail" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'trust-email.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="linkOnly">{{:: 'link-only' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.linkOnly" name="identityProvider.trustEmail" id="linkOnly" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'link-only.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="hideOnLoginPage">{{:: 'hide-on-login-page' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.config.hideOnLoginPage" name="identityProvider.config.hideOnLoginPage" id="hideOnLoginPage" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'hide-on-login-page.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="guiOrder">{{:: 'gui-order' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="guiOrder" type="text" ng-model="identityProvider.config.guiOrder">
                </div>
                <kc-tooltip>{{:: 'gui-order.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="firstBrokerLoginFlowAlias">{{:: 'first-broker-login-flow' | translate}}</label>
                <div class="col-md-6">
                    <div>
                        <select class="form-control" id="firstBrokerLoginFlowAlias"
                                ng-model="identityProvider.firstBrokerLoginFlowAlias"
                                ng-options="flow.alias as flow.alias for flow in authFlows"
                                required>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'first-broker-login-flow.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="postBrokerLoginFlowAlias">{{:: 'post-broker-login-flow' | translate}}</label>
                <div class="col-md-6">
                    <div>
                        <select class="form-control" id="postBrokerLoginFlowAlias"
                                ng-model="identityProvider.postBrokerLoginFlowAlias"
                                ng-options="flow.alias as flow.alias for flow in postBrokerAuthFlows">
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'post-broker-login-flow.tooltip' | translate}}</kc-tooltip>
            </div>
        </fieldset>
        <fieldset>
            <legend uncollapsed><span class="text">{{:: 'openid-connect-config' | translate}}</span> <kc-tooltip>{{:: 'openid-connect-config.tooltip' | translate}}</kc-tooltip></legend>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="authorizationUrl"><span class="required">*</span> {{:: 'authorization-url' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="authorizationUrl" type="text" ng-model="identityProvider.config.authorizationUrl" required>
                </div>
                <kc-tooltip>{{:: 'authorization-url.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="loginHint">{{:: 'loginHint' | translate}}</label>
                <div class="col-sm-4">
                    <input ng-model="identityProvider.config.loginHint" id="loginHint" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'loginHint.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="uiLocales">{{:: 'uiLocales' | translate}}</label>
                <div class="col-sm-4">
                    <input ng-model="identityProvider.config.uiLocales" id="uiLocales" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'uiLocales.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="tokenUrl"><span class="required">*</span> {{:: 'token-url' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="tokenUrl" type="text" ng-model="identityProvider.config.tokenUrl" required>
                </div>
                <kc-tooltip>{{:: 'token-url.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="userInfoUrl">{{:: 'logout-url' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="logoutUrl" type="text" ng-model="identityProvider.config.logoutUrl">
                </div>
                <kc-tooltip>{{:: 'identity-provider.logout-url.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="backchannelSupported">{{:: 'backchannel-logout' | translate}}</label>
                <div class="col-sm-4">
                    <input ng-model="identityProvider.config.backchannelSupported" id="backchannelSupported" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'backchannel-logout.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="disableUserInfo">{{:: 'disableUserInfo' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.config.disableUserInfo" id="disableUserInfo" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'identity-provider.disableUserInfo.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="userInfoUrl">{{:: 'user-info-url' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="userInfoUrl" type="text" ng-model="identityProvider.config.userInfoUrl">
                </div>
                <kc-tooltip>{{:: 'user-info-url.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="clientId"><span class="required">*</span> {{:: 'client-id' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="clientId" type="text" ng-model="identityProvider.config.clientId" required>
                </div>
                <kc-tooltip>{{:: 'identity-provider.client-id.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="clientSecret"><span class="required">*</span> {{:: 'client-secret' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="clientSecret" kc-password ng-model="identityProvider.config.clientSecret" required>
                </div>
                <kc-tooltip>{{:: 'client-secret.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="issuer">{{:: 'issuer' | translate}} </label>
                <div class="col-md-6">
                    <input class="form-control" id="issuer" type="text" ng-model="identityProvider.config.issuer">
                </div>
                <kc-tooltip>{{:: 'issuer.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group clearfix">
                <label class="col-md-2 control-label" for="defaultScope">{{:: 'default-scopes' | translate}} </label>
                <div class="col-md-6">
                    <input class="form-control" id="defaultScope" type="text" ng-model="identityProvider.config.defaultScope">
                </div>
                <kc-tooltip>{{:: 'identity-provider.default-scopes.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="prompt">{{:: 'prompt' | translate}}</label>
                <div class="col-md-6">
                    <div>
                        <select class="form-control" id="prompt" ng-model="identityProvider.config.prompt">
                            <option value="">{{:: 'unspecified.option' | translate}}</option>
                            <option value="none">{{:: 'none.option' | translate}}</option>
                            <option value="consent">{{:: 'consent.option' | translate}}</option>
                            <option value="login">{{:: 'login.option' | translate}}</option>
                            <option value="select_account">{{:: 'select-account.option' | translate}}</option>
                        </select>
                    </div>
                </div>
                <kc-tooltip>{{:: 'prompt.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="validateSignature">{{:: 'validate-signatures' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.config.validateSignature" id="validateSignature" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'identity-provider.validate-signatures.tooltip' | translate}}</kc-tooltip>
            </div>

            <div data-ng-show="identityProvider.config.validateSignature == 'true'">

                <div class="form-group">
                    <label class="col-md-2 control-label" for="useJwksUrl">{{:: 'use-jwks-url' | translate}}</label>
                    <div class="col-md-6">
                        <input ng-model="identityProvider.config.useJwksUrl" id="useJwksUrl" onoffswitchvalue on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                    </div>
                    <kc-tooltip>{{:: 'identity-provider.use-jwks-url.tooltip' | translate}}</kc-tooltip>
                </div>

                <div class="form-group clearfix" data-ng-show="identityProvider.config.useJwksUrl == 'true'">
                    <label class="col-md-2 control-label" for="jwksUrl">{{:: 'jwks-url' | translate}} </label>
                    <div class="col-md-6">
                        <input class="form-control" id="jwksUrl" type="text" ng-model="identityProvider.config.jwksUrl">
                    </div>
                    <kc-tooltip>{{:: 'identity-provider.jwks-url.tooltip' | translate}}</kc-tooltip>
                </div>

                <div class="form-group clearfix" data-ng-hide="identityProvider.config.useJwksUrl == 'true'">
                    <label class="col-md-2 control-label" for="publicKeySignatureVerifierKey">{{:: 'validating-public-key' | translate}}</label>
                    <div class="col-md-6">
                        <textarea class="form-control" id="publicKeySignatureVerifier" ng-model="identityProvider.config.publicKeySignatureVerifier"/>
                    </div>
                    <kc-tooltip>{{:: 'identity-provider.validating-public-key.tooltip' | translate}}</kc-tooltip>
                </div>

                <div class="form-group clearfix" data-ng-hide="identityProvider.config.useJwksUrl == 'true'">
                    <label class="col-md-2 control-label" for="publicKeySignatureVerifierKeyId">{{:: 'validating-public-key-id' | translate}}</label>
                    <div class="col-md-6">
                        <input class="form-control" id="publicKeySignatureVerifierKeyId" ng-model="identityProvider.config.publicKeySignatureVerifierKeyId"/>
                    </div>
                    <kc-tooltip>{{:: 'identity-provider.validating-public-key-id.tooltip' | translate}}</kc-tooltip>
                </div>

            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="allowedClockSkew">{{:: 'allowed-clock-skew' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="identityProvider.config.allowedClockSkew" id="allowedClockSkew" type="text" class="form-control"/>
                </div>
                <kc-tooltip>{{:: 'identity-provider.allowed-clock-skew.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="forwardParameters">{{:: 'forwarded-query-parameters' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="forwardParameters" type="text" ng-model="identityProvider.config.forwardParameters"/>
                </div>
                <kc-tooltip>{{:: 'identity-provider.forwarded-query-parameters.tooltip' | translate}}</kc-tooltip>
            </div>
        </fieldset>
        <fieldset data-ng-show="newIdentityProvider">
            <legend uncollapsed><span class="text">{{:: 'import-external-idp-config' | translate}}</span> <kc-tooltip>{{:: 'import-external-idp-config.tooltip' | translate}}</kc-tooltip></legend>
            <div class="form-group" data-ng-show="newIdentityProvider">
                <label class="col-md-2 control-label" for="fromUrl">{{:: 'import-from-url' | translate}}</label>
                <div class="col-md-6">
                    <input class="form-control" id="fromUrl" type="text" ng-model="fromUrl.data">
                </div>
                <kc-tooltip>{{:: 'identity-provider.import-from-url.tooltip' | translate}}</kc-tooltip>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="importFrom"></label>
                <div class="col-md-6">
                    <button id="importFrom" type="button" data-ng-click="importFrom()" data-ng-show="importUrl" class="btn btn-primary">{{:: 'import' | translate}}</button>
                </div>
            </div>
            <div class="form-group" data-ng-show="newIdentityProvider">
                <label class="col-md-2 control-label">{{:: 'import-from-file' | translate}}</label>
                <kc-tooltip>{{:: 'identity-provider.import-from-file.tooltip' | translate}}</kc-tooltip>
                <div class="col-md-6">
                    <div class="controls kc-button-input-file" data-ng-show="!files || files.length == 0">
                        <label for="import-file" class="btn btn-default">{{:: 'select-file' | translate}} <i class="pficon pficon-import"></i></label>
                        <input id="import-file" type="file" class="hidden" ng-file-select="onFileSelect($files)">
                    </div>
                <span class="kc-uploaded-file" data-ng-show="files.length > 0">
                    {{files[0].name}}
                </span>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="importFile"></label>
                    <div class="col-md-6" data-ng-show="importFile">
                        <button id="importFile" type="button" data-ng-click="uploadFile()" data-ng-show="importFile" class="btn btn-primary">{{:: 'import' | translate}}</button>
                    </div>
                </div>
            </div>
        </fieldset>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2">
                <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
                <button kc-cancel data-ng-click="cancel()" data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
            </div>
        </div>
    </form>
</div>


<kc-menu></kc-menu>