All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.RealmSettingsSection-G00jJoQt.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as c,Fragment as J}from"react/jsx-runtime";import{_ as Da,dK as Ra,l as Na,cI as Oa,dL as Va,dM as Ka,dm as Ma,dz as sa,dA as Fa,cK as Ha,dN as Ua,dC as _a,dO as Ga,ci as Ba,u as ne,dt as it,v as Ue,a as U,c as ae,f as ve,g as be,ab as He,P as re,F as _e,bt as Te,x as pe,dP as kt,ac as R,ae as F,bR as wt,ai as ra,bq as za,ay as ht,dQ as $a,L as Ie,bx as ja,A as Se,h as N,j as ie,a3 as We,aH as Kt,aI as Mt,aq as qa,aJ as It,y as nt,ad as H,aX as oa,aY as Fe,a8 as $t,Q as Ve,a4 as he,M as je,q as Xe,B as se,aa as st,Z as Re,r as rt,aW as Wa,a_ as lt,ar as Ge,b5 as fe,U as ee,o as pt,d as Ye,T as ca,R as ft,dR as jt,a2 as Le,dS as Ja,dT as xt,dU as Xa,dV as Ya,b as Be,b6 as Ce,b0 as Qa,ao as qt,am as yt,dy as Za,bZ as en,b_ as tn,$ as Ft,dW as ot,at as an,a9 as nn,dX as Wt,J as da,K as ma,aB as ua,N as pa,D as tt,aC as ct,dI as Dt,dJ as Ht,a0 as ha,ba as ln,bb as sn,bc as Jt,bd as fa,dY as rn,s as on,dZ as we,w as cn,ag as Qe,ah as Je,d_ as Ne,d$ as dn,c2 as mn,bD as Xt,af as Lt,e0 as Yt,e1 as un,a1 as pn,cp as hn,e2 as fn,e3 as Qt,e4 as Zt,e5 as ba,c8 as Pt,I as ea,c4 as bn,b3 as gn,c6 as vn,au as yn,S as Tn,a6 as Cn,bE as Sn,a7 as kn}from"./index-C1LIsRX7.js";import In,{useState as u,useEffect as Pe,useMemo as at}from"react";import{u as ge}from"./ConfirmDialog-B5qjiAuo.js";import{R as bt,u as gt}from"./RoutableTabs-j5CUH0-6.js";import{F as Rt,V as Ln}from"./ViewHeader-qjLr6U82.js";import{u as Ut}from"./useLocale-CzIrpa16.js";import{F as te,b as Pn}from"./FormAccess-BcY70QlP.js";import{u as qe}from"./useToggle-K3Kx99tM.js";/* empty css                               */import{a as At}from"./KeySelect-B2uWUd6C.js";import{U as Ze}from"./userProfileMetadata-CFgHgJ2w.js";import{D as Nt}from"./SwitchControl-C3zDl-9W.js";import{K as An}from"./KeyValueInput-CoupoYmE.js";import{J as En}from"./JsonFileUpload-C06Nil7S.js";import{l as wn,K as ze}from"./KeycloakDataTable-jyvvxdb8.js";import{d as ga,D as va,a as ya,b as Ta,c as Ot}from"./DataListItemRow-COCiEHyF.js";import{L as xe,P as xn}from"./PaginatingTableToolbar-CpMLQtqt.js";import{b as Dn}from"./_baseSlice-F8doVSIJ.js";import{a as Rn,s as Nn,o as On}from"./_baseFlatten-BHAcGTxk.js";import{F as _t,a as Oe}from"./FlexItem-DCAd8FXq.js";import{C as Gt,L as Bt}from"./CodeEditor-CIeIZGz7.js";import{T as Q,t as Vn}from"./TimeSelector-yr8Y_36J.js";import{R as Kn}from"./AddRoleMappingModal-Ds4yp8lg.js";import{G as Mn}from"./GroupPickerDialog-DmX3SBxL.js";import{T as vt}from"./Trans-DZTM8FLp.js";import{Q as Fn}from"./question-circle-icon-Dbt6ViOg.js";import{T as Tt,a as $,b as j}from"./Tabs-CNBvRApH.js";import{T as Ca}from"./TimeSelectorControl-BQB3aFfv.js";import{i as Sa}from"./isEqual-DmIBnf3S.js";import{u as Hn}from"./useFormatDate-Ypu7MAgr.js";import{T as $e,U as Un,V as _n,W as ta,X as dt,Y as Gn,Z as mt,a4 as Bn}from"./Td-BwjBKSkH.js";import{F as ka}from"./filter-icon-BVyMUArZ.js";import{D as Ia}from"./DraggableTable-BwAWTeWo.js";import{KeyProviderForm as zn}from"./KeyProviderForm-D1PF08X3.js";import{D as $n}from"./DropdownPanel-CvKbZ6hZ.js";import{p as jn}from"./pickBy-DqRcHijc.js";import{P as qn}from"./pencil-alt-icon-CuChRX1Z.js";import{u as zt,U as Wn}from"./UserProfileContext-BX1nihnb.js";import"react-dom";import"./PageHandler-CFMh3rCu.js";import"./DynamicComponents-CIZcko9u.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./MultiLineInput-AcwuO_FT.js";import"./useParams-n_2fXkN1.js";import"./PageList-D9zZFEpa.js";import"./EmptyStateActions-DBSnfkAA.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./copy-icon-DOS8MmN7.js";import"./FileUploadForm-DXJKFbGA.js";const Vt=l=>{var{children:n,className:a,label:t}=l,i=Da(l,["children","className","label"]);return In.createElement(Ra,Object.assign({className:Na(a),label:t},i),n)};Vt.displayName="SelectGroup";function Jn(l){var n=l==null?0:l.length;return n?Rn(l):[]}function Xn(l){return Nn(On(l,void 0,Jn),l+"")}var Yn="[object Object]",Qn=Function.prototype,Zn=Object.prototype,La=Qn.toString,el=Zn.hasOwnProperty,tl=La.call(Object);function al(l){if(!Oa(l)||Va(l)!=Yn)return!1;var n=Ka(l);if(n===null)return!0;var a=el.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&La.call(a)==tl}function nl(l,n){return n.length<2?l:Ma(l,Dn(n,0,-1))}function ll(l,n){return n=sa(n,l),l=nl(l,n),l==null||delete l[Fa(wn(n))]}function il(l){return al(l)?void 0:l}var sl=1,rl=2,ol=4,Pa=Xn(function(l,n){var a={};if(l==null)return a;var t=!1;n=Ha(n,function(s){return s=sa(s,l),t||(t=s.length>1),s}),Ua(l,_a(l),a),t&&(a=Ga(a,sl|rl|ol,il));for(var i=n.length;i--;)ll(a,n[i]);return a});function cl(l,n){return n=typeof n=="function"?n:void 0,l&&l.length?Ba(l,void 0,n):[]}function dl(){const{adminClient:l}=ne(),{whoAmI:n}=it(),[a,t]=u(),i=n.getUserId();return Ue(()=>l.users.findOne({id:i}),t,[i]),a}const ml=({realm:l,save:n})=>{const{adminClient:a}=ne(),{t}=U(),{realm:i}=ae(),{addAlert:s,addError:p}=ve(),d=dl(),h=be({defaultValues:l}),{control:o,handleSubmit:m,watch:A,reset:I,getValues:O}=h,y=()=>I(l),f=A("smtpServer.from",""),r=A("smtpServer.host",""),[b,g]=qe(),w=He({control:o,name:"smtpServer.auth",defaultValue:""}),x=async()=>{const D=V=>Number(V),k=V=>V==="true",L=new Map([["port",D],["ssl",k],["starttls",k],["auth",k]]),T={...O().smtpServer};for(const[V,P]of L.entries())T[V]=P(T[V]);T.port===0&&(T.port=null);try{g(),await a.realms.testSMTPConnection({realm:l.realm},T),s(t("testConnectionSuccess"),ie.success)}catch(V){p("testConnectionError",V)}g()};return e(re,{variant:"light",children:c(_e,{...h,children:[e(Te,{title:t("template"),className:"kc-email-template",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:m(n),children:[e(pe,{name:"smtpServer.from",label:t("from"),type:"email",placeholder:t("smtpFromPlaceholder"),rules:{pattern:{value:kt,message:t("emailInvalid")},required:t("required")}}),e(pe,{name:"smtpServer.fromDisplayName",label:t("fromDisplayName"),labelIcon:t("fromDisplayNameHelp"),placeholder:t("smtpFromDisplayPlaceholder")}),e(pe,{name:"smtpServer.replyTo",label:t("replyTo"),type:"email",placeholder:t("replyToEmailPlaceholder"),rules:{pattern:{value:kt,message:t("emailInvalid")}}}),e(pe,{name:"smtpServer.replyToDisplayName",label:t("replyToDisplayName"),labelIcon:t("replyToDisplayNameHelp"),placeholder:t("replyToDisplayPlaceholder")}),e(pe,{name:"smtpServer.envelopeFrom",label:t("envelopeFrom"),labelIcon:t("envelopeFromHelp"),placeholder:t("senderEnvelopePlaceholder")})]})}),e(Te,{className:"kc-email-connection",title:t("connectionAndAuthentication"),children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:m(n),children:[e(pe,{name:"smtpServer.host",label:t("host"),rules:{required:t("required")}}),e(pe,{name:"smtpServer.port",label:t("port"),placeholder:t("smtpPortPlaceholder")}),c(R,{label:t("encryption"),fieldId:"kc-html-display-name",children:[e(F,{name:"smtpServer.ssl",control:o,defaultValue:"false",render:({field:D})=>e(wt,{id:"kc-enable-ssl","data-testid":"enable-ssl",label:t("enableSSL"),isChecked:D.value==="true",onChange:(k,L)=>D.onChange(""+L)})}),e(F,{name:"smtpServer.starttls",control:o,defaultValue:"false",render:({field:D})=>e(wt,{id:"kc-enable-start-tls","data-testid":"enable-start-tls",label:t("enableStartTLS"),isChecked:D.value==="true",onChange:(k,L)=>D.onChange(""+L)})})]}),e(ra,{name:"smtpServer.auth",label:t("authentication"),defaultValue:"",labelOn:t("enabled"),labelOff:t("disabled"),stringify:!0}),w==="true"&&c(J,{children:[e(pe,{name:"smtpServer.user",label:t("username"),placeholder:t("loginUsernamePlaceholder"),rules:{required:t("required")}}),e(za,{name:"smtpServer.password",label:t("password"),labelIcon:t("passwordHelp"),rules:{required:t("required")}})]}),d&&e(R,{id:"descriptionTestConnection",children:d.email?e(ht,{variant:"info",component:"h2",isInline:!0,title:t("testConnectionHint.withEmail",{email:d.email})}):e(ht,{variant:"warning",component:"h2",isInline:!0,title:t("testConnectionHint.withoutEmail",{userName:d.username}),actionLinks:e($a,{component:D=>e(Ie,{...D,to:ja({realm:i,id:d.id,tab:"settings"})}),children:t("testConnectionHint.withoutEmailAction")})})}),c(Se,{children:[e(At,{children:e(N,{variant:"primary",type:"submit","data-testid":"email-tab-save",children:t("save")})}),e(At,{children:e(N,{variant:"secondary",onClick:()=>x(),"data-testid":"test-connection-button",isDisabled:!(kt.test(f)&&r)||!d?.email,"aria-describedby":"descriptionTestConnection",isLoading:b,spinnerAriaValueText:t("testingConnection"),children:t("testConnection")})}),e(At,{children:e(N,{variant:"link",onClick:y,"data-testid":"email-tab-revert",children:t("revert")})})]})]})})]})})},ul=({realm:l,save:n})=>{const{adminClient:a}=ne(),{realm:t}=ae(),[i,s]=u();return Ue(()=>a.users.getProfile({realm:t}),p=>s(p),[]),i?e(hl,{realm:l,save:n,userProfileConfig:i}):e(We,{})},pl=["all","external","none"],Et=[Ze.Disabled,Ze.Enabled,Ze.AdminView,Ze.AdminEdit];function hl({realm:l,save:n,userProfileConfig:a}){const{adminClient:t}=ne(),{t:i}=U(),{realm:s}=ae(),p=be(),{control:d,handleSubmit:h,setValue:o,formState:{isDirty:m,errors:A}}=p,O=Kt()(Mt.Organizations),y=()=>{if(Ve(l,o),o("unmanagedAttributePolicy",a.unmanagedAttributePolicy||Et[0]),l.attributes?.["acr.loa.map"]){const r=Object.entries(JSON.parse(l.attributes["acr.loa.map"])).flatMap(([b,g])=>({key:b,value:g}));r.concat({key:"",value:""}),o(It("attributes.acr.loa.map"),r)}};Pe(y,[]);const f=h(async({unmanagedAttributePolicy:r,...b})=>{const g={...a};r===Ze.Disabled?delete g.unmanagedAttributePolicy:g.unmanagedAttributePolicy=r,await n({...b,upConfig:g})});return e(re,{variant:"light",children:e(_e,{...p,children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:f,children:[c(R,{label:i("realmId"),fieldId:"kc-realm-id",isRequired:!0,children:[e(F,{name:"realm",control:d,rules:{required:{value:!0,message:i("required")}},defaultValue:"",render:({field:r})=>e(Pn,{"data-testid":"realmName",onChange:r.onChange,children:r.value})}),A.realm&&e(qa,{"data-testid":"realm-id-error",message:A.realm.message})]}),e(pe,{name:"displayName",label:i("displayName")}),e(pe,{name:"displayNameHtml",label:i("htmlDisplayName")}),e(pe,{name:It("attributes.frontendUrl"),type:"url",label:i("htmlDisplayName"),labelIcon:i("frontendUrlHelp")}),e(nt,{name:"sslRequired",label:i("requireSsl"),labelIcon:i("requireSslHelp"),controller:{defaultValue:"none"},options:pl.map(r=>({key:r,value:i(`sslType.${r}`)}))}),e(R,{label:i("acrToLoAMapping"),fieldId:"acrToLoAMapping",labelIcon:e(H,{helpText:i("acrToLoAMappingHelp"),fieldLabelId:"acrToLoAMapping"}),children:e(An,{label:i("acrToLoAMapping"),name:It("attributes.acr.loa.map")})}),e(Nt,{name:"userManagedAccessAllowed",label:i("userManagedAccess"),labelIcon:i("userManagedAccessHelp")}),O&&e(Nt,{name:"organizationsEnabled",label:i("organizationsEnabled"),labelIcon:i("organizationsEnabledHelp")}),e(nt,{name:"unmanagedAttributePolicy",label:i("unmanagedAttributes"),labelIcon:i("unmanagedAttributesHelpText"),controller:{defaultValue:Et[0]},options:Et.map(r=>({key:r,value:i(`unmanagedAttributePolicy.${r}`)}))}),e(R,{label:i("endpoints"),labelIcon:e(H,{helpText:i("endpointsHelp"),fieldLabelId:"endpoints"}),fieldId:"kc-endpoints",children:c(oa,{children:[e(Fe,{children:e(Rt,{href:`${$t(t.baseUrl)}realms/${s}/.well-known/openid-configuration`,title:i("openIDEndpointConfiguration")})}),e(Fe,{children:e(Rt,{href:`${$t(t.baseUrl)}realms/${s}/protocol/saml/descriptor`,title:i("samlIdentityProviderMetadata")})})]})}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"general-tab-save",isDisabled:!m,children:i("save")}),e(N,{"data-testid":"general-tab-revert",variant:"link",onClick:y,children:i("revert")})]})]})})})}const fl=({realm:l,refresh:n})=>{const{adminClient:a}=ne(),{t}=U(),{addAlert:i,addError:s}=ve(),{realm:p}=ae(),d=async h=>{const o=Array.isArray(h)?Object.keys(h[0])[0]:Object.keys(h)[0];try{await a.realms.update({realm:p},Array.isArray(h)?h.reduce((m,A)=>Object.assign(m,A),l):Object.assign(l,h)),i(t("enableSwitchSuccess",{switch:t(o)})),n()}catch(m){s(t("enableSwitchError"),m)}};return c(re,{variant:"light",children:[e(Te,{className:"kc-login-screen",title:t("loginScreenCustomization"),children:c(te,{isHorizontal:!0,role:"manage-realm",children:[e(R,{label:t("registrationAllowed"),fieldId:"kc-user-reg",labelIcon:e(H,{helpText:t("userRegistrationHelpText"),fieldLabelId:"registrationAllowed"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-user-reg-switch","data-testid":"user-reg-switch",value:l.registrationAllowed?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.registrationAllowed,onChange:(h,o)=>{d({registrationAllowed:o})},"aria-label":t("registrationAllowed")})}),e(R,{label:t("resetPasswordAllowed"),fieldId:"kc-forgot-pw",labelIcon:e(H,{helpText:t("forgotPasswordHelpText"),fieldLabelId:"resetPasswordAllowed"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-forgot-pw-switch","data-testid":"forgot-pw-switch",name:"resetPasswordAllowed",value:l.resetPasswordAllowed?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.resetPasswordAllowed,onChange:(h,o)=>{d({resetPasswordAllowed:o})},"aria-label":t("resetPasswordAllowed")})}),e(R,{label:t("rememberMe"),fieldId:"kc-remember-me",labelIcon:e(H,{helpText:t("rememberMeHelpText"),fieldLabelId:"rememberMe"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-remember-me-switch","data-testid":"remember-me-switch",value:l.rememberMe?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.rememberMe,onChange:(h,o)=>{d({rememberMe:o})},"aria-label":t("rememberMe")})})]})}),e(Te,{className:"kc-email-settings",title:t("emailSettings"),children:c(te,{isHorizontal:!0,role:"manage-realm",children:[e(R,{label:t("registrationEmailAsUsername"),fieldId:"kc-email-as-username",labelIcon:e(H,{helpText:t("emailAsUsernameHelpText"),fieldLabelId:"registrationEmailAsUsername"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-email-as-username-switch","data-testid":"email-as-username-switch",value:l.registrationEmailAsUsername?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.registrationEmailAsUsername,onChange:(h,o)=>{d([{registrationEmailAsUsername:o},{duplicateEmailsAllowed:!1}])},"aria-label":t("registrationEmailAsUsername")})}),e(R,{label:t("loginWithEmailAllowed"),fieldId:"kc-login-with-email",labelIcon:e(H,{helpText:t("loginWithEmailHelpText"),fieldLabelId:"loginWithEmailAllowed"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-login-with-email-switch","data-testid":"login-with-email-switch",value:l.loginWithEmailAllowed?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.loginWithEmailAllowed,onChange:(h,o)=>{d([{loginWithEmailAllowed:o},{duplicateEmailsAllowed:!1}])},"aria-label":t("loginWithEmailAllowed")})}),e(R,{label:t("duplicateEmailsAllowed"),fieldId:"kc-duplicate-emails",labelIcon:e(H,{helpText:t("duplicateEmailsHelpText"),fieldLabelId:"duplicateEmailsAllowed"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-duplicate-emails-switch","data-testid":"duplicate-emails-switch",label:t("on"),labelOff:t("off"),isChecked:l.duplicateEmailsAllowed,onChange:(h,o)=>{d({duplicateEmailsAllowed:o})},isDisabled:l.loginWithEmailAllowed||l.registrationEmailAsUsername,"aria-label":t("duplicateEmailsAllowed")})}),e(R,{label:t("verifyEmail"),fieldId:"kc-verify-email",labelIcon:e(H,{helpText:t("verifyEmailHelpText"),fieldLabelId:"verifyEmail"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-verify-email-switch","data-testid":"verify-email-switch",name:"verifyEmail",value:l.verifyEmail?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.verifyEmail,onChange:(h,o)=>{d({verifyEmail:o})},"aria-label":t("verifyEmail")})})]})}),e(Te,{className:"kc-user-info-settings",title:t("userInfoSettings"),children:e(te,{isHorizontal:!0,role:"manage-realm",children:e(R,{label:t("editUsernameAllowed"),fieldId:"kc-edit-username",labelIcon:e(H,{helpText:t("editUsernameHelp"),fieldLabelId:"editUsernameAllowed"}),hasNoPaddingTop:!0,children:e(he,{id:"kc-edit-username-switch","data-testid":"edit-username-switch",value:l.editUsernameAllowed?"on":"off",label:t("on"),labelOff:t("off"),isChecked:l.editUsernameAllowed,onChange:(h,o)=>{d({editUsernameAllowed:o})},"aria-label":t("editUsernameAllowed")})})})})]})},bl=({isOpen:l,onClose:n})=>{const{adminClient:a}=ne(),{t}=U(),{realm:i}=ae(),{addAlert:s,addError:p}=ve(),[d,h]=u(!1),[o,m]=u(!1),[A,I]=u(!1),O=d||o;async function y(){I(!0);try{const f=await a.realms.export({realm:i,exportClients:o,exportGroupsAndRoles:d});Wa.saveAs(new Blob([lt(f)],{type:"application/json"}),"realm-export.json"),s(t("exportSuccess"),ie.success),n()}catch(f){p("exportFail",f)}I(!1)}return c(je,{variant:Xe.small,title:t("partialExport"),isOpen:l,onClose:n,actions:[e(N,{"data-testid":"export-button",isDisabled:A,onClick:y,children:t("export")},"export"),e(N,{"data-testid":"cancel-button",variant:se.link,onClick:n,children:t("cancel")},"cancel")],children:[e(st,{children:e(Re,{children:t("partialExportHeaderText")})}),c(rt,{isHorizontal:!0,className:"keycloak__realm-settings__partial-import_form",children:[e(R,{label:t("includeGroupsAndRoles"),fieldId:"include-groups-and-roles-check",hasNoPaddingTop:!0,children:e(he,{id:"include-groups-and-roles-check","data-testid":"include-groups-and-roles-check",isChecked:d,onChange:(f,r)=>h(r),label:t("on"),labelOff:t("off"),"aria-label":t("includeGroupsAndRoles")})}),e(R,{label:t("includeClients"),fieldId:"include-clients-check",hasNoPaddingTop:!0,children:e(he,{id:"include-clients-check","data-testid":"include-clients-check",onChange:(f,r)=>m(r),isChecked:o,label:t("on"),labelOff:t("off"),"aria-label":t("includeClients")})})]}),O&&e(ht,{"data-testid":"warning-message",variant:"warning",component:"p",title:t("exportWarningTitle"),isInline:!0,children:t("exportWarningDescription")})]})},aa={users:!1,clients:!1,groups:!1,identityProviders:!1,realmRoles:!1,clientRoles:!1},gl=l=>{const{adminClient:n}=ne(),{t:a}=U(),{realm:t}=ae(),[i,s]=u(),p=!!i,[d,h]=u(!1),[o,m]=u(!1),[A,I]=u(!1),[O,y]=u("FAIL"),[f,r]=u({}),[b,g]=u(),{addError:w}=ve(),[x,D]=u(aa),k=Object.values(x).some(S=>S),L=()=>{D(aa)},T=()=>{s(void 0),r({}),y("FAIL"),L()};Pe(()=>{I(!1),g(void 0),T()},[l.open]);const V=S=>{T(),s(S),Array.isArray(S)?S.length>0&&r(S[0]):r(S)},P=S=>{r(S),h(!1),L()},E=(S,Z)=>{const De=Z.currentTarget.name;D({...x,[De]:S})},M=S=>S.map(Z=>e(ee,{value:Z,"data-testid":Z.id+"-select-option",children:Z.realm||Z.id},Z.id)),G=S=>{y(S),m(!1)},K=()=>[e(ee,{value:"FAIL",children:a("FAIL")},"fail"),e(ee,{value:"SKIP",children:a("SKIP")},"skip"),e(ee,{value:"OVERWRITE",children:a("OVERWRITE")},"overwrite")],q=()=>X("users")||X("groups")||X("clients")||X("identityProviders")||de()||me(),X=S=>{const Z=f[S];return Z!==void 0&&Z.length>0},de=()=>{const S=f.roles?.realm;return S!==void 0&&S.length>0},me=()=>{const S=f.roles?.client;return S!==void 0&&Object.keys(S).length>0},ke=S=>p?S==="realmRoles"?f.roles?.realm?.length??0:S==="clientRoles"?me()?ue(f.roles.client):0:f[S]?.length??0:0,ue=S=>Object.values(S).reduce((Z,De)=>Z+De.length,0),ce=(S,Z)=>e(va,{"aria-labelledby":`${S}-list-item`,children:e(ya,{children:e(Ta,{dataListCells:[e(Ot,{children:e(wt,{id:`${S}-checkbox`,label:`${ke(S)} ${Z}`,"aria-labelledby":`${S}-checkbox`,name:S,isChecked:x[S],onChange:(De,Ct)=>E(Ct,De),"data-testid":S+"-checkbox"})},S)]})})}),B=()=>{const S={ifResourceExists:O,id:f.id,realm:f.realm};return x.users&&(S.users=f.users),x.groups&&(S.groups=f.groups),x.identityProviders&&(S.identityProviders=f.identityProviders),x.clients&&(S.clients=f.clients),(x.realmRoles||x.clientRoles)&&(S.roles=f.roles,x.realmRoles||delete S.roles?.realm,x.clientRoles||delete S.roles?.client),S};async function C(){if(!A){I(!0);try{const S=await n.realms.partialImport({realm:t,rep:B()});g(S)}catch(S){w("importFail",S)}I(!1)}}const v=()=>e(je,{variant:Xe.medium,title:a("partialImport"),isOpen:l.open,onClose:l.toggleDialog,actions:[e(N,{id:"modal-import","data-testid":"import-button",isDisabled:!k,onClick:()=>{C()},children:a("import")},"import"),e(N,{id:"modal-cancel","data-testid":"cancel-button",variant:se.link,onClick:()=>{l.toggleDialog()},children:a("cancel")},"cancel")],children:c(oa,{hasGutter:!0,children:[e(Fe,{children:e(st,{children:e(Re,{children:a("partialImportHeaderText")})})}),e(Fe,{children:e(En,{id:"partial-import-file",allowEditingUploadedText:!0,onChange:V})}),p&&q()&&c(J,{children:[e(Fe,{children:e(Ge,{})}),Array.isArray(i)&&i.length>1&&c(Fe,{children:[c(Re,{children:[a("selectRealm"),":"]}),e(fe,{toggleId:"realm-selector",isOpen:d,typeAheadAriaLabel:a("realmSelector"),"aria-label":"realmSelector",onToggle:()=>h(!d),onSelect:S=>P(S),placeholderText:f.realm||f.id,children:M(i)})]}),c(Fe,{children:[c(Re,{children:[a("chooseResources"),":"]}),c(ga,{"aria-label":a("resourcesToImport"),isCompact:!0,children:[X("users")&&ce("users",a("users")),X("groups")&&ce("groups",a("groups")),X("clients")&&ce("clients",a("clients")),X("identityProviders")&&ce("identityProviders",a("identityProviders")),de()&&ce("realmRoles",a("realmRoles")),me()&&ce("clientRoles",a("clientRoles"))]})]}),c(Fe,{children:[c(Re,{children:[a("selectIfResourceExists"),":"]}),e(fe,{isOpen:o,direction:"up",onToggle:()=>{m(!o)},onSelect:G,placeholderText:a(O),children:K()})]})]})]})}),W=()=>`${a("importAdded",{count:b?.added})}  ${a("importSkipped",{count:b?.skipped})} ${a("importOverwritten",{count:b?.overwritten})}`,le=async(S=0,Z=15)=>{if(!b)return[];const De=Math.min(S+Z,b.results.length);return b.results.slice(S,De)},ye=S=>{switch(S.action){case"ADDED":return e(pt,{color:"green",children:a("added")},S.id);case"SKIPPED":return e(pt,{color:"orange",children:a("skipped")},S.id);case"OVERWRITTEN":return e(pt,{color:"purple",children:a("overwritten")},S.id);default:return""}},Ae=S=>{const Z=new Map([["CLIENT",a("clients")],["REALM_ROLE",a("realmRoles")],["USER",a("users")],["CLIENT_ROLE",a("clientRoles")],["IDP",a("identityProviders")],["GROUP",a("groups")]]);return e("span",{children:Z.get(S.resourceType)})},Ee=()=>c(je,{variant:Xe.medium,title:a("partialImport"),isOpen:l.open,onClose:l.toggleDialog,actions:[e(N,{id:"modal-close","data-testid":"close-button",variant:se.primary,onClick:()=>{l.toggleDialog()},children:a("close")},"close")],children:[e(ht,{variant:"success",component:"p",isInline:!0,title:W()}),e(ze,{loader:le,isPaginated:!0,ariaLabelKey:"partialImport",columns:[{name:"action",displayKey:"action",cellRenderer:ye},{name:"resourceType",displayKey:"type",cellRenderer:Ae},{name:"resourceName",displayKey:"name"},{name:"id",displayKey:"id"}]})]});return b?Ee():v()},vl=()=>{const{adminClient:l}=ne(),{t:n}=U(),{addAlert:a,addError:t}=ve(),{realm:i}=ae(),s=Ye(),[p,d]=u(!1),[h,o]=u(),[m,A]=u(),[I,O]=u(0),[y,f]=u(),[r,b]=u(),g=()=>O(I+1),w=be({mode:"onChange"});Ue(()=>l.clientPolicies.listPolicies({includeGlobalPolicies:!0}),P=>{const E=P.globalPolicies?.map(K=>({...K,global:!0})),M=P.policies?.map(K=>({...K,global:!1})),G=E?.concat(M??[]);o(G),b(G||[]),f(lt(G))},[I]);const x=async()=>h??[],D=async()=>{const P=w.getValues(),E=h?.filter(M=>!M.global).map(M=>{const G=P[M.name],K={...M,enabled:G};return delete K.global,K});try{await l.clientPolicies.updatePolicy({policies:E}),s(xt({realm:i,tab:"policies"})),a(n("updateClientPolicySuccess"),ie.success)}catch(M){t("updateClientPolicyError",M)}},k=P=>Pa(P,"global"),L=async()=>{if(y)try{const P=JSON.parse(y),E=P.filter(G=>!G.global).map(G=>k(G)),M=P.filter(G=>G.global).map(G=>k(G));try{await l.clientPolicies.updatePolicy({policies:E,globalPolicies:M}),a(n("updateClientPoliciesSuccess"),ie.success),g()}catch(G){t("updateClientPoliciesError",G)}}catch(P){console.warn("Invalid json, ignoring value using {}"),t("invalidJsonClientPoliciesError",P)}},[T,V]=ge({titleKey:n("deleteClientPolicyConfirmTitle"),messageKey:n("deleteClientPolicyConfirm",{policyName:m?.name}),continueButtonLabel:n("delete"),continueButtonVariant:se.danger,onConfirm:async()=>{const P=h?.filter(E=>!E.global&&E.name!==m?.name).map(E=>{const M={...E};return delete M.global,M});try{await l.clientPolicies.updatePolicy({policies:P}),a(n("deleteClientPolicySuccess"),ie.success),g()}catch(E){t(n("deleteClientPolicyError"),E)}}});return h?c(J,{children:[e(V,{}),e(re,{children:c(_t,{className:"kc-policies-config-section",children:[e(Oe,{children:e(ca,{headingLevel:"h1",size:"md",children:n("policiesConfigType")})}),e(Oe,{children:e(ft,{isChecked:!p,name:"policiesView",onChange:()=>d(!1),label:n("policiesConfigTypes.formView"),id:"formView-policiesView","data-testid":"formView-policiesView",className:"kc-form-radio-btn pf-v5-u-mr-sm pf-v5-u-ml-sm"})}),e(Oe,{children:e(ft,{isChecked:p,name:"policiesView",onChange:()=>d(!0),label:n("policiesConfigTypes.jsonEditor"),id:"jsonEditor-policiesView","data-testid":"jsonEditor-policiesView",className:"kc-editor-radio-btn"})})]})}),e(Ge,{}),p?c(J,{children:[e("div",{className:"pf-v5-u-mt-md pf-v5-u-ml-lg",children:e(Gt,{isLineNumbersVisible:!0,isLanguageLabelVisible:!0,isReadOnly:!1,code:y,language:Bt.json,height:"30rem",onChange:f})}),c("div",{className:"pf-v5-u-mt-md",children:[e(N,{variant:se.primary,className:"pf-v5-u-mr-md pf-v5-u-ml-lg","data-testid":"jsonEditor-policies-saveBtn",onClick:L,children:n("save")}),e(N,{variant:se.link,"data-testid":"jsonEditor-reloadBtn",onClick:()=>{f(lt(r))},children:n("reload")})]})]}):e(ze,{emptyState:e(xe,{message:n("noClientPolicies"),instructions:n("noClientPoliciesInstructions"),primaryActionText:n("createClientPolicy"),onPrimaryAction:()=>s(jt({realm:i}))}),ariaLabelKey:"clientPolicies",searchPlaceholderKey:"clientPolicySearch",loader:x,toolbarItem:e(Le,{children:e(N,{id:"createPolicy",component:P=>e(Ie,{...P,to:jt({realm:i})}),"data-testid":"createPolicy",children:n("createClientPolicy")})}),isRowDisabled:P=>!!P.global,actions:[{title:n("delete"),onRowClick:P=>{T(),A(P)}}],columns:[{name:"name",cellRenderer:({name:P})=>e(Ie,{to:Ja({realm:i,policyName:P}),children:P})},{name:"enabled",displayKey:"status",cellRenderer:P=>e(yl,{clientPolicy:P,form:w,saveStatus:D,onConfirm:()=>{w.setValue(P.name,!1),D()}})},{name:"description"}]},h.length)]}):e(We,{})},yl=({clientPolicy:l,form:n,saveStatus:a,onConfirm:t})=>{const{t:i}=U(),[s,p]=ge({titleKey:"disablePolicyConfirmTitle",messageKey:"disablePolicyConfirm",continueButtonLabel:"disable",onConfirm:t});return c(J,{children:[e(p,{}),e(F,{name:l.name,"data-testid":`${l.name}-switch`,defaultValue:l.enabled,control:n.control,render:({field:d})=>e(he,{label:i("enabled"),labelOff:i("disabled"),isChecked:d.value,isDisabled:l.global,onChange:(h,o)=>{o?(d.onChange(o),a()):s()},"aria-label":l.name})})]})};function Tl(){const{adminClient:l}=ne(),{t:n}=U(),{realm:a}=ae(),{addAlert:t,addError:i}=ve(),[s,p]=u(),[d,h]=u(),[o,m]=u(),[A,I]=u(!1),[O,y]=u(),[f,r]=u(0);Ue(()=>l.clientPolicies.listProfiles({includeGlobalProfiles:!0}),L=>{h(L.globalProfiles);const T=L.globalProfiles?.map(E=>({...E,global:!0})),V=L.profiles?.map(E=>({...E,global:!1})),P=T?.concat(V??[]);p(P||[]),y(JSON.stringify(P,null,2))},[f]);const b=async()=>s??[],g=L=>Pa(L,"global"),[w,x]=ge({titleKey:n("deleteClientProfileConfirmTitle"),messageKey:n("deleteClientProfileConfirm",{profileName:o?.name}),continueButtonLabel:n("delete"),continueButtonVariant:se.danger,onConfirm:async()=>{const L=s?.filter(T=>T.name!==o?.name&&!T.global).map(T=>g(T));try{await l.clientPolicies.createProfiles({profiles:L,globalProfiles:d}),t(n("deleteClientSuccess"),ie.success),r(f+1)}catch(T){i(n("deleteClientError"),T)}}}),D=L=>c(Ie,{to:Ya({realm:a,profileName:L.name}),children:[L.name," ",L.global&&e(pt,{color:"blue",children:n("global")})]},L.name);if(!s)return e(We,{});const k=async()=>{if(O)try{const L=JSON.parse(O),T=L.filter(P=>!P.global).map(P=>g(P)),V=L.filter(P=>P.global).map(P=>g(P));try{await l.clientPolicies.createProfiles({profiles:T,globalProfiles:V}),t(n("updateClientProfilesSuccess"),ie.success),r(f+1)}catch(P){i("updateClientProfilesError",P)}}catch(L){i("invalidJsonClientProfilesError",L)}};return c(J,{children:[e(x,{}),e(re,{children:c(_t,{className:"kc-profiles-config-section",children:[e(Oe,{children:e(ca,{headingLevel:"h1",size:"md",children:n("profilesConfigType")})}),e(Oe,{children:e(ft,{isChecked:!A,name:"profilesView",onChange:()=>I(!1),label:n("profilesConfigTypes.formView"),id:"formView-profilesView",className:"kc-form-radio-btn pf-v5-u-mr-sm pf-v5-u-ml-sm","data-testid":"formView-profilesView"})}),e(Oe,{children:e(ft,{isChecked:A,name:"profilesView",onChange:()=>I(!0),label:n("profilesConfigTypes.jsonEditor"),id:"jsonEditor-profilesView",className:"kc-editor-radio-btn","data-testid":"jsonEditor-profilesView"})})]})}),e(Ge,{}),A?c(R,{fieldId:"jsonEditor",children:[e("div",{className:"pf-v5-u-mt-md pf-v5-u-ml-lg",children:e(Gt,{isLineNumbersVisible:!0,isLanguageLabelVisible:!0,isReadOnly:!1,code:O,language:Bt.json,height:"30rem",onChange:L=>{y(L??"")}})}),e(Se,{children:c("div",{className:"pf-v5-u-mt-md",children:[e(N,{variant:se.primary,className:"pf-v5-u-mr-md pf-v5-u-ml-lg",onClick:k,"data-testid":"jsonEditor-saveBtn",children:n("save")}),e(N,{variant:se.link,onClick:()=>{y(lt(s))},"data-testid":"jsonEditor-reloadBtn",children:n("reload")})]})})]}):e(ze,{ariaLabelKey:"profiles",searchPlaceholderKey:"clientProfileSearch",loader:b,toolbarItem:e(Le,{children:e(N,{id:"createProfile",component:L=>e(Ie,{...L,to:Xa({realm:a,tab:"profiles"})}),"data-testid":"createProfile",children:n("createClientProfile")})}),isRowDisabled:L=>L.global,actions:[{title:n("delete"),onRowClick:L=>{m(L),w()}}],columns:[{name:"name",displayKey:n("name"),cellRenderer:D},{name:"description",displayKey:n("clientProfileDescription")}],emptyState:e(xe,{message:n("emptyClientProfiles"),instructions:n("emptyClientProfilesInstructions")})},s.length)]})}const Cl=({realm:l,save:n})=>{const{t:a}=U(),{setValue:t,control:i,handleSubmit:s,formState:p}=be(),d=He({control:i,name:"offlineSessionMaxLifespanEnabled"}),h=()=>{Ve(l,t)};return Pe(h,[]),c(re,{variant:"light",children:[e(Te,{title:a("SSOSessionSettings"),className:"kc-sso-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",onSubmit:s(n),children:[e(R,{label:a("SSOSessionIdle"),fieldId:"SSOSessionIdle",labelIcon:e(H,{helpText:a("ssoSessionIdle"),fieldLabelId:"SSOSessionIdle"}),children:e(F,{name:"ssoSessionIdleTimeout",defaultValue:l.ssoSessionIdleTimeout,control:i,render:({field:o})=>e(Q,{className:"kc-sso-session-idle","data-testid":"sso-session-idle-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{label:a("SSOSessionMax"),fieldId:"SSOSessionMax",labelIcon:e(H,{helpText:a("ssoSessionMax"),fieldLabelId:"SSOSessionMax"}),children:e(F,{name:"ssoSessionMaxLifespan",control:i,render:({field:o})=>e(Q,{className:"kc-sso-session-max","data-testid":"sso-session-max-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{label:a("SSOSessionIdleRememberMe"),fieldId:"SSOSessionIdleRememberMe",labelIcon:e(H,{helpText:a("ssoSessionIdleRememberMe"),fieldLabelId:"SSOSessionIdleRememberMe"}),children:e(F,{name:"ssoSessionIdleTimeoutRememberMe",control:i,render:({field:o})=>e(Q,{className:"kc-sso-session-idle-remember-me","data-testid":"sso-session-idle-remember-me-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{label:a("SSOSessionMaxRememberMe"),fieldId:"SSOSessionMaxRememberMe",labelIcon:e(H,{helpText:a("ssoSessionMaxRememberMe"),fieldLabelId:"SSOSessionMaxRememberMe"}),children:e(F,{name:"ssoSessionMaxLifespanRememberMe",control:i,render:({field:o})=>e(Q,{className:"kc-sso-session-max-remember-me","data-testid":"sso-session-max-remember-me-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})})]})}),e(Te,{title:a("clientSessionSettings"),className:"kc-client-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:s(n),children:[e(R,{label:a("clientSessionIdle"),fieldId:"clientSessionIdle",labelIcon:e(H,{helpText:a("clientSessionIdleHelp"),fieldLabelId:"clientSessionIdle"}),children:e(F,{name:"clientSessionIdleTimeout",control:i,render:({field:o})=>e(Q,{className:"kc-client-session-idle","data-testid":"client-session-idle-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{label:a("clientSessionMax"),fieldId:"clientSessionMax",labelIcon:e(H,{helpText:a("clientSessionMaxHelp"),fieldLabelId:"clientSessionMax"}),children:e(F,{name:"clientSessionMaxLifespan",control:i,render:({field:o})=>e(Q,{className:"kc-client-session-max","data-testid":"client-session-max-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})})]})}),e(Te,{title:a("offlineSessionSettings"),className:"kc-offline-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:s(n),children:[e(R,{label:a("offlineSessionIdle"),fieldId:"offlineSessionIdle",labelIcon:e(H,{helpText:a("offlineSessionIdleHelp"),fieldLabelId:"offlineSessionIdle"}),children:e(F,{name:"offlineSessionIdleTimeout",control:i,render:({field:o})=>e(Q,{className:"kc-offline-session-idle","data-testid":"offline-session-idle-input","aria-label":"offline-session-idle-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{hasNoPaddingTop:!0,label:a("offlineSessionMaxLimited"),fieldId:"kc-offlineSessionMaxLimited",labelIcon:e(H,{helpText:a("offlineSessionMaxLimitedHelp"),fieldLabelId:"offlineSessionMaxLimited"}),children:e(F,{name:"offlineSessionMaxLifespanEnabled",control:i,defaultValue:!1,render:({field:o})=>e(he,{id:"kc-offline-session-max","data-testid":"offline-session-max-switch","aria-label":a("offlineSessionMaxLimited"),label:a("enabled"),labelOff:a("disabled"),isChecked:o.value,onChange:o.onChange})})}),d&&e(R,{label:a("offlineSessionMax"),fieldId:"offlineSessionMax",id:"offline-session-max-label",labelIcon:e(H,{helpText:a("offlineSessionMaxHelp"),fieldLabelId:"offlineSessionMax"}),children:e(F,{name:"offlineSessionMaxLifespan",control:i,render:({field:o})=>e(Q,{className:"kc-offline-session-max","data-testid":"offline-session-max-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})})]})}),e(Te,{className:"kc-login-settings-template",title:a("loginSettings"),children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:s(n),children:[e(R,{label:a("loginTimeout"),id:"kc-login-timeout-label",fieldId:"offlineSessionIdle",labelIcon:e(H,{helpText:a("loginTimeoutHelp"),fieldLabelId:"loginTimeout"}),children:e(F,{name:"accessCodeLifespanLogin",control:i,render:({field:o})=>e(Q,{className:"kc-login-timeout","data-testid":"login-timeout-input","aria-label":"login-timeout-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),e(R,{label:a("loginActionTimeout"),fieldId:"loginActionTimeout",id:"login-action-timeout-label",labelIcon:e(H,{helpText:a("loginActionTimeoutHelp"),fieldLabelId:"loginActionTimeout"}),children:e(F,{name:"accessCodeLifespanUserAction",control:i,render:({field:o})=>e(Q,{className:"kc-login-action-timeout","data-testid":"login-action-timeout-input",value:o.value,onChange:o.onChange,units:["minute","hour","day"]})})}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"sessions-tab-save",isDisabled:!p.isDirty,children:a("save")}),e(N,{variant:"link",onClick:h,children:a("revert")})]})]})})]})},Sl=({realm:l,save:n})=>{const{t:a}=U(),[t,i]=u(!1),[s,p]=u(!1),[d,h]=u(!1),[o,m]=u(!1),{control:A,handleSubmit:I,setValue:O}=be(),y=Be().themes,f=()=>{Ve(l,O)};return Pe(f,[]),e(re,{variant:"light",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:I(n),children:[e(R,{label:a("loginTheme"),fieldId:"kc-login-theme",labelIcon:e(H,{helpText:a("loginThemeHelp"),fieldLabelId:"loginTheme"}),children:e(F,{name:"loginTheme",control:A,defaultValue:"",render:({field:r})=>e(fe,{toggleId:"kc-login-theme",onToggle:()=>i(!t),onSelect:b=>{r.onChange(b),i(!1)},selections:r.value,variant:Ce.single,isOpen:t,placeholderText:a("selectATheme"),"data-testid":"select-login-theme","aria-label":a("selectLoginTheme"),children:y.login.map((b,g)=>e(ee,{selected:b.name===r.value,value:b.name,children:a(b.name)},`login-theme-${g}`))})})}),e(R,{label:a("accountTheme"),fieldId:"kc-account-theme",labelIcon:e(H,{helpText:a("accountThemeHelp"),fieldLabelId:"accountTheme"}),children:e(F,{name:"accountTheme",control:A,defaultValue:"",render:({field:r})=>e(fe,{toggleId:"kc-account-theme",onToggle:()=>p(!s),onSelect:b=>{r.onChange(b),p(!1)},selections:r.value,variant:Ce.single,"aria-label":a("selectAccountTheme"),isOpen:s,placeholderText:a("selectATheme"),"data-testid":"select-account-theme",children:y.account.filter(b=>b.name!=="base").map((b,g)=>e(ee,{selected:b.name===r.value,value:b.name,children:a(b.name)},`account-theme-${g}`))})})}),e(R,{label:a("adminTheme"),fieldId:"kc-admin-ui-theme",labelIcon:e(H,{helpText:a("adminThemeHelp"),fieldLabelId:"adminTheme"}),children:e(F,{name:"adminTheme",control:A,defaultValue:"",render:({field:r})=>e(fe,{toggleId:"kc-admin-ui-theme",onToggle:()=>h(!d),onSelect:b=>{r.onChange(b),h(!1)},selections:r.value,variant:Ce.single,isOpen:d,placeholderText:a("selectATheme"),"data-testid":"select-admin-theme","aria-label":"selectAdminTheme",children:y.admin.filter(b=>b.name!=="base").map((b,g)=>e(ee,{selected:b.name===r.value,value:b.name,children:a(b.name)},`admin-theme-${g}`))})})}),e(R,{label:a("emailTheme"),fieldId:"kc-email-theme",labelIcon:e(H,{helpText:a("emailThemeHelp"),fieldLabelId:"emailTheme"}),children:e(F,{name:"emailTheme",control:A,defaultValue:"",render:({field:r})=>e(fe,{toggleId:"kc-email-theme",onToggle:()=>m(!o),onSelect:b=>{r.onChange(b),m(!1)},selections:r.value,variant:Ce.single,isOpen:o,placeholderText:a("selectATheme"),"data-testid":"select-email-theme","aria-label":a("selectEmailTheme"),children:y.email.map((b,g)=>e(ee,{selected:b.name===r.value,value:b.name,children:a(b.name)},`email-theme-${g}`))})})}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"themes-tab-save",children:a("save")}),e(N,{variant:"link",onClick:f,children:a("revert")})]})]})})},kl=({realm:l,reset:n,save:a})=>{const{t}=U(),i=Be(),s=Kt(),{whoAmI:p}=it(),[d,h]=u(!1),o=Qa(i.providers.signature.providers),m=be(),{setValue:A,control:I}=m,O=He({control:I,name:"offlineSessionMaxLifespanEnabled",defaultValue:l.offlineSessionMaxLifespanEnabled}),y=He({control:I,name:"ssoSessionIdleTimeout",defaultValue:36e3}),f=He({control:I,name:"revokeRefreshToken",defaultValue:!1});return Pe(()=>{Ve(l,A)},[]),c(re,{variant:"light",children:[e(Te,{title:t("general"),className:"kc-sso-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",onSubmit:m.handleSubmit(a),children:[e(R,{label:t("defaultSigAlg"),fieldId:"kc-default-signature-algorithm",labelIcon:e(H,{helpText:t("defaultSigAlgHelp"),fieldLabelId:"algorithm"}),children:e(F,{name:"defaultSignatureAlgorithm",defaultValue:"RS256",control:m.control,render:({field:r})=>e(fe,{toggleId:"kc-default-sig-alg",onToggle:()=>h(!d),onSelect:b=>{r.onChange(b.toString()),h(!1)},selections:r.value?.toString(),variant:Ce.single,"aria-label":t("defaultSigAlg"),isOpen:d,"data-testid":"select-default-sig-alg",children:o.map((b,g)=>e(ee,{selected:b===r.value,value:b},`default-sig-alg-${g}`))})})}),s(Mt.DeviceFlow)&&c(J,{children:[e(R,{label:t("oAuthDeviceCodeLifespan"),fieldId:"oAuthDeviceCodeLifespan",labelIcon:e(H,{helpText:t("oAuthDeviceCodeLifespanHelp"),fieldLabelId:"oAuthDeviceCodeLifespan"}),children:e(F,{name:"oauth2DeviceCodeLifespan",defaultValue:0,control:m.control,render:({field:r})=>e(Q,{id:"oAuthDeviceCodeLifespan","data-testid":"oAuthDeviceCodeLifespan",value:r.value||0,onChange:r.onChange,units:["minute","hour","day"]})})}),e(R,{label:t("oAuthDevicePollingInterval"),fieldId:"oAuthDevicePollingInterval",labelIcon:e(H,{helpText:t("oAuthDevicePollingIntervalHelp"),fieldLabelId:"oAuthDevicePollingInterval"}),children:e(F,{name:"oauth2DevicePollingInterval",defaultValue:0,control:m.control,render:({field:r})=>e(qt,{id:"oAuthDevicePollingInterval",value:r.value,min:0,onPlus:()=>r.onChange(Number(r?.value)+1),onMinus:()=>r.onChange(Number(r?.value)>0?Number(r?.value)-1:0),onChange:b=>{const g=Number(b.currentTarget.value);r.onChange(isNaN(g)?0:g)},placeholder:t("oAuthDevicePollingInterval")})})}),e(R,{label:t("shortVerificationUri"),fieldId:"shortVerificationUri",labelIcon:e(H,{helpText:t("shortVerificationUriTooltipHelp"),fieldLabelId:"shortVerificationUri"}),children:e(yt,{id:"shortVerificationUri",placeholder:t("shortVerificationUri"),...m.register("attributes.shortVerificationUri")})}),e(R,{label:t("parRequestUriLifespan"),fieldId:"parRequestUriLifespan",labelIcon:e(H,{helpText:t("parRequestUriLifespanHelp"),fieldLabelId:"parRequestUriLifespan"}),children:e(F,{name:"attributes.parRequestUriLifespan",control:m.control,render:({field:r})=>e(Q,{id:"parRequestUriLifespan",className:"par-request-uri-lifespan","data-testid":"par-request-uri-lifespan-input","aria-label":"par-request-uri-lifespan",value:r.value,onChange:r.onChange})})})]})]})}),e(Te,{title:t("refreshTokens"),className:"kc-client-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:m.handleSubmit(a),children:[e(R,{hasNoPaddingTop:!0,label:t("revokeRefreshToken"),fieldId:"kc-revoke-refresh-token",labelIcon:e(H,{helpText:t("revokeRefreshTokenHelp"),fieldLabelId:"revokeRefreshToken"}),children:e(F,{name:"revokeRefreshToken",control:m.control,defaultValue:!1,render:({field:r})=>e(he,{id:"kc-revoke-refresh-token","data-testid":"revoke-refresh-token-switch","aria-label":t("revokeRefreshToken"),label:t("enabled"),labelOff:t("disabled"),isChecked:r.value,onChange:r.onChange})})}),f&&e(R,{label:t("refreshTokenMaxReuse"),labelIcon:e(H,{helpText:t("refreshTokenMaxReuseHelp"),fieldLabelId:"refreshTokenMaxReuse"}),fieldId:"refreshTokenMaxReuse",children:e(F,{name:"refreshTokenMaxReuse",defaultValue:0,control:m.control,render:({field:r})=>e(qt,{type:"text",id:"refreshTokenMaxReuseMs",value:r.value,onPlus:()=>r.onChange(r.value+1),onMinus:()=>r.onChange(r.value-1),onChange:b=>r.onChange(Number(b.target.value))})})})]})}),e(Te,{title:t("accessTokens"),className:"kc-offline-session-template",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:m.handleSubmit(a),children:[c(R,{label:t("accessTokenLifespan"),fieldId:"accessTokenLifespan",labelIcon:e(H,{helpText:t("accessTokenLifespanHelp"),fieldLabelId:"accessTokenLifespan"}),children:[e(F,{name:"accessTokenLifespan",control:m.control,render:({field:r})=>e(Q,{validated:r.value>y?"warning":"default",className:"kc-access-token-lifespan","data-testid":"access-token-lifespan-input","aria-label":"access-token-lifespan",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})}),e(Za,{children:e(en,{children:e(tn,{children:t("recommendedSsoTimeout",{time:Vn(y,p.getLocale())})})})})]}),e(R,{label:t("accessTokenLifespanImplicitFlow"),fieldId:"accessTokenLifespanImplicitFlow",labelIcon:e(H,{helpText:t("accessTokenLifespanImplicitFlow"),fieldLabelId:"accessTokenLifespanImplicitFlow"}),children:e(F,{name:"accessTokenLifespanForImplicitFlow",control:m.control,render:({field:r})=>e(Q,{className:"kc-access-token-lifespan-implicit","data-testid":"access-token-lifespan-implicit-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),e(R,{label:t("clientLoginTimeout"),fieldId:"clientLoginTimeout",labelIcon:e(H,{helpText:t("clientLoginTimeoutHelp"),fieldLabelId:"clientLoginTimeout"}),children:e(F,{name:"accessCodeLifespan",control:m.control,render:({field:r})=>e(Q,{className:"kc-client-login-timeout","data-testid":"client-login-timeout-input","aria-label":"client-login-timeout",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),O&&e(R,{label:t("offlineSessionMax"),fieldId:"offlineSessionMax",id:"offline-session-max-label",labelIcon:e(H,{helpText:t("offlineSessionMaxHelp"),fieldLabelId:"offlineSessionMax"}),children:e(F,{name:"offlineSessionMaxLifespan",control:m.control,render:({field:r})=>e(Q,{className:"kc-offline-session-max","data-testid":"offline-session-max-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})})]})}),e(Te,{className:"kc-login-settings-template",title:t("actionTokens"),children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",onSubmit:m.handleSubmit(a),children:[e(R,{label:t("userInitiatedActionLifespan"),id:"kc-user-initiated-action-lifespan",fieldId:"userInitiatedActionLifespan",labelIcon:e(H,{helpText:t("userInitiatedActionLifespanHelp"),fieldLabelId:"userInitiatedActionLifespan"}),children:e(F,{name:"actionTokenGeneratedByUserLifespan",control:m.control,render:({field:r})=>e(Q,{className:"kc-user-initiated-action-lifespan","data-testid":"user-initiated-action-lifespan","aria-label":"user-initiated-action-lifespan",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),e(R,{label:t("defaultAdminInitiated"),fieldId:"defaultAdminInitiated",id:"default-admin-initiated-label",labelIcon:e(H,{helpText:t("defaultAdminInitiatedActionLifespanHelp"),fieldLabelId:"defaultAdminInitiated"}),children:e(F,{name:"actionTokenGeneratedByAdminLifespan",control:m.control,render:({field:r})=>e(Q,{className:"kc-default-admin-initiated","data-testid":"default-admin-initated-input","aria-label":"default-admin-initated-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),e(Re,{className:"kc-override-action-tokens-subtitle",component:Ft.h1,children:t("overrideActionTokens")}),e(R,{label:t("emailVerification"),fieldId:"emailVerification",id:"email-verification",children:e(F,{name:`attributes.${ot("actionTokenGeneratedByUserLifespan.verify-email")}`,defaultValue:"",control:m.control,render:({field:r})=>e(Q,{className:"kc-email-verification","data-testid":"email-verification-input",value:r.value,onChange:b=>r.onChange(b.toString()),units:["minute","hour","day"]})})}),e(R,{label:t("idpAccountEmailVerification"),fieldId:"idpAccountEmailVerification",id:"idp-acct-label",children:e(F,{name:`attributes.${ot("actionTokenGeneratedByUserLifespan.idp-verify-account-via-email")}`,defaultValue:"",control:m.control,render:({field:r})=>e(Q,{className:"kc-idp-email-verification","data-testid":"idp-email-verification-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),e(R,{label:t("forgotPassword"),fieldId:"forgotPassword",id:"forgot-password-label",children:e(F,{name:`attributes.${ot("actionTokenGeneratedByUserLifespan.reset-credentials")}`,defaultValue:"",control:m.control,render:({field:r})=>e(Q,{className:"kc-forgot-pw","data-testid":"forgot-pw-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),e(R,{label:t("executeActions"),fieldId:"executeActions",id:"execute-actions",children:e(F,{name:`attributes.${ot("actionTokenGeneratedByUserLifespan.execute-actions")}`,defaultValue:"",control:m.control,render:({field:r})=>e(Q,{className:"kc-execute-actions","data-testid":"execute-actions-input",value:r.value,onChange:r.onChange,units:["minute","hour","day"]})})}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"tokens-tab-save",isDisabled:!m.formState.isDirty,children:t("save")}),e(N,{variant:"link",onClick:n,children:t("revert")})]})]})})]})},Il=()=>{const{adminClient:l}=ne(),{t:n}=U(),[a,t]=qe(),[i,s]=qe(),[p,d]=u(),[h,o]=u([]),[m,A]=u(0),[I,O]=u(0),y=()=>O(I+1),{realm:f}=ae(),{addAlert:r,addError:b}=ve(),{enabled:g}=an();Ue(()=>l.realms.getDefaultGroups({realm:f}),T=>{d(T),A(m+1)},[I]);const w=()=>Promise.resolve(p),x=async()=>{try{await Promise.all(h.map(T=>l.realms.removeDefaultGroup({realm:f,id:T.id}))),r(n("groupRemove",{count:h.length}),ie.success),o([])}catch(T){b("groupRemoveError",T)}y()},D=async T=>{try{await Promise.all(T.map(V=>l.realms.addDefaultGroup({realm:f,id:V.id}))),r(n("defaultGroupAdded",{count:T.length}),ie.success)}catch(V){b("defaultGroupAddedError",V)}y()},[k,L]=ge({titleKey:n("removeConfirmTitle",{count:h.length}),messageKey:n("removeConfirm",{count:h.length}),continueButtonLabel:"delete",continueButtonVariant:se.danger,onConfirm:x});return p?c(J,{children:[e(L,{}),i&&e(Mn,{type:"selectMany",text:{title:"addDefaultGroups",ok:"add"},onConfirm:T=>{D(T||[]),s()},onClose:s}),g&&e(nn,{bodyContent:c(vt,{i18nKey:"defaultGroupsHelp",children:[" ",e(Ie,{to:Wt({realm:f})}),"."]}),children:e(st,{className:"keycloak__section_intro__help",style:{paddingLeft:"var(--pf-v5-c-page__main-section--PaddingLeft)"},children:c(Re,{children:[e(Fn,{})," ",n("whatIsDefaultGroups")]})})}),e(ze,{canSelectAll:!0,onSelect:T=>o([...T]),loader:w,ariaLabelKey:"defaultGroups",searchPlaceholderKey:"searchForGroups",toolbarItem:c(J,{children:[e(Le,{children:e(N,{"data-testid":"openCreateGroupModal",variant:"primary",onClick:s,children:n("addGroups")})}),e(Le,{children:e(da,{toggle:T=>e(ma,{ref:T,isExpanded:a,variant:"plain",onClick:t,isDisabled:h.length===0,children:e(ua,{})}),isOpen:a,shouldFocusToggleOnSelect:!0,children:e(pa,{children:e(tt,{component:"button",onClick:()=>{k(),t()},children:n("remove")},"action")})})})]}),actions:[{title:n("remove"),onRowClick:T=>(o([T]),k(),Promise.resolve(!1))}],columns:[{name:"name",displayKey:"groupName"},{name:"path",displayKey:"path"}],emptyState:e(xe,{hasIcon:!0,message:n("noDefaultGroups"),instructions:c(vt,{i18nKey:"noDefaultGroupsInstructions",children:[" ",e(Ie,{className:"pf-v5-u-font-weight-light",to:Wt({realm:f}),role:"navigation","aria-label":n("identityBrokeringLink")}),"Add groups..."]}),primaryActionText:n("addGroups"),onPrimaryAction:s})},m)]}):e(We,{})},Ll=()=>{const{adminClient:l}=ne(),{t:n}=U(),[a,t]=u(10),{realmRepresentation:i}=ae(),[s,p]=u(0),{addAlert:d,addError:h}=ve(),{realm:o}=ae(),m=async A=>{const I=A;try{await l.roles.createComposite({roleId:i?.defaultRole.id,realm:o},I),p(s+1),d(n("addAssociatedRolesSuccess"),ie.success)}catch(O){h("addAssociatedRolesError",O)}};return c(Tt,{activeKey:a,onSelect:(A,I)=>t(I),children:[e($,{id:"roles",eventKey:10,title:e(j,{children:n("defaultRoles")}),"data-testid":"default-roles-tab",children:e(Kn,{name:i?.defaultRole.name,id:i?.defaultRole.id,type:"roles",isManager:!0,save:A=>m(A.map(I=>I.role))})},s),e($,{id:"groups",eventKey:20,title:e(j,{children:n("defaultGroups")}),"data-testid":"default-groups-tab",children:e(Il,{})})]})};function Aa({ariaLabelKey:l="userEventsRegistered",eventTypes:n,addTypes:a,onSelect:t,onDelete:i}){const{t:s}=U(),p=n.map(d=>({id:d,name:s(`eventTypes.${d}.name`),description:s(`eventTypes.${d}.description`)}));return e(ze,{ariaLabelKey:l,searchPlaceholderKey:"searchEventType",loader:p,onSelect:t||void 0,canSelectAll:!!t,toolbarItem:a&&e(Le,{children:e(N,{id:"addTypes",onClick:a,"data-testid":"addTypes",children:s("addSavedTypes")})}),actions:i?[{title:s("remove"),onRowClick:i}]:[],columns:[{name:"name",displayKey:"eventType"},{name:"description",displayKey:"description"}],emptyState:e(xe,{message:s("emptyEvents"),instructions:s("emptyEventsInstructions")})})}const Pl=({onConfirm:l,onClose:n,configured:a})=>{const{t}=U(),{enums:i}=Be(),[s,p]=u([]);return e(je,{variant:Xe.medium,title:t("addTypes"),isOpen:!0,onClose:n,actions:[e(N,{"data-testid":"addEventTypeConfirm",variant:"primary",onClick:()=>l(s),children:t("add")},"confirm"),e(N,{"data-testid":"moveCancel",variant:"link",onClick:n,children:t("cancel")},"cancel")],children:e(Aa,{ariaLabelKey:"addTypes",onSelect:d=>p(d),eventTypes:i.eventType.filter(d=>!a.includes(d))})})},na=({type:l,form:n,reset:a,clear:t})=>{const{t:i}=U(),{control:s,watch:p,setValue:d,formState:{isDirty:h}}=n,o=l==="admin"?"adminEventsEnabled":"eventsEnabled",m=p(o),[A,I]=ge({titleKey:"events-disable-title",messageKey:"events-disable-confirm",continueButtonLabel:"confirm",onConfirm:()=>d(o,!1,{shouldDirty:!0})});return c(_e,{...n,children:[e(I,{}),e(R,{hasNoPaddingTop:!0,label:i("saveEvents"),fieldId:o,labelIcon:e(H,{helpText:i(`save-${l}-eventsHelp`),fieldLabelId:"saveEvents"}),children:e(F,{name:o,defaultValue:!1,control:s,render:({field:O})=>e(he,{"data-testid":o,id:`${o}-switch`,label:i("on"),labelOff:i("off"),isChecked:O.value,onChange:(y,f)=>{f?O.onChange(f):A()},"aria-label":i("saveEvents")})})}),m&&c(J,{children:[l==="admin"&&e(Nt,{name:"adminEventsDetailsEnabled",label:i("includeRepresentation"),labelIcon:i("includeRepresentationHelp")}),e(Ca,{name:l==="user"?"eventsExpiration":"adminEventsExpiration",label:i("expiration"),labelIcon:i("expirationHelp"),defaultValue:"",units:["minute","hour","day"],controller:{defaultValue:""}})]}),c(Se,{children:[e(N,{variant:"primary",type:"submit",id:`save-${l}`,"data-testid":`save-${l}`,isDisabled:!h,children:i("save")}),e(N,{variant:"link",onClick:a,children:i("revert")})]}),e(Ge,{}),e(R,{label:i(l==="user"?"clearUserEvents":"clearAdminEvents"),fieldId:`clear-${l}-events`,labelIcon:e(H,{helpText:i(`${l}-clearEventsHelp`),fieldLabelId:`clear-${l}-events`}),children:e(N,{variant:"danger",id:`clear-${l}-events`,"data-testid":`clear-${l}-events`,onClick:()=>t(),children:i(l==="user"?"clearUserEvents":"clearAdminEvents")})})]})},Al=({form:l,reset:n})=>{const{t:a}=U(),i=Be().providers?.eventsListener.providers;return c(_e,{...l,children:[e(nt,{name:"eventsListeners",label:a("eventListeners"),labelIcon:a("eventListenersHelpTextHelp"),controller:{defaultValue:""},className:"kc_eventListeners_select",chipGroupProps:{numChips:3,expandedText:a("hide"),collapsedText:a("showRemaining")},variant:Ce.typeaheadMulti,options:Object.keys(i)}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"saveEventListenerBtn",children:a("save")}),e(N,{variant:"link","data-testid":"revertEventListenerBtn",onClick:n,children:a("revert")})]})]})},El=({realm:l})=>{const{adminClient:n}=ne(),{t:a}=U(),t=be(),{setValue:i,handleSubmit:s}=t,[p,d]=u(0),h=()=>d(new Date().getTime()),[o,m]=u(0),A=()=>m(new Date().getTime()),[I,O]=u("event"),[y,f]=u(),[r,b]=u(),[g,w]=u(!1),{addAlert:x,addError:D}=ve(),{realm:k}=ae(),L=K=>{f(K),Ve(K||{},i)},T=async K=>{b(K),V()},[V,P]=ge({titleKey:"deleteEvents",messageKey:"deleteEventsConfirm",continueButtonLabel:"clear",continueButtonVariant:se.danger,onConfirm:async()=>{try{switch(r){case"admin":await n.realms.clearAdminEvents({realm:k});break;case"user":await n.realms.clearEvents({realm:k});break}x(a(`${r}-events-cleared`),ie.success)}catch(K){D(`${r}-events-cleared-error`,K)}}});Ue(()=>n.realms.getConfigEvents({realm:k}),K=>{L({...K,adminEventsExpiration:l.attributes?.adminEventsExpiration}),A()},[p]);const E=async K=>{const q=!Sa(y?.eventsListeners,K.eventsListeners),{adminEventsExpiration:X,...de}=K;l.attributes?.adminEventsExpiration!==X&&await n.realms.update({realm:k},{...l,attributes:{...l.attributes||{},adminEventsExpiration:X}});try{await n.realms.updateConfigEvents({realm:k},de),L({...y,...de,adminEventsExpiration:X}),x(a(q?"saveEventListenersSuccess":"eventConfigSuccessfully"),ie.success)}catch(me){D(a(q?"saveEventListenersError":"eventConfigError"),me)}},M=async K=>{const q=K.map(de=>de.id),X=y.enabledEventTypes?.concat(q);await G(X)},G=async(K=[])=>{const q={...t.getValues(),enabledEventTypes:K};await E(q),w(!1),h()};return c(J,{children:[e(P,{}),g&&e(Pl,{onConfirm:K=>M(K),configured:y?.enabledEventTypes||[],onClose:()=>w(!1)}),c(Tt,{activeKey:I,onSelect:(K,q)=>O(q),children:[e($,{eventKey:"event",title:e(j,{children:a("eventListeners")}),"data-testid":"rs-event-listeners-tab",children:e(re,{children:e(te,{role:"manage-events",isHorizontal:!0,onSubmit:s(E),children:e(Al,{form:t,reset:()=>L(y)})})})}),c($,{eventKey:"user",title:e(j,{children:a("userEventsSettings")}),"data-testid":"rs-events-tab",children:[e(re,{children:e(te,{role:"manage-events",isHorizontal:!0,onSubmit:s(E),children:e(na,{type:"user",form:t,reset:()=>L(y),clear:()=>T("user")})})}),e(re,{children:e(Aa,{addTypes:()=>w(!0),eventTypes:y?.enabledEventTypes||[],onDelete:K=>{const q=y?.enabledEventTypes?.filter(X=>X!==K.id);G(q),f({...y,enabledEventTypes:q})}},o)})]}),e($,{eventKey:"admin",title:e(j,{children:a("adminEventsSettings")}),"data-testid":"rs-admin-events-tab",children:e(re,{children:e(te,{role:"manage-events",isHorizontal:!0,onSubmit:s(E),children:e(na,{type:"admin",form:t,reset:()=>L(y),clear:()=>T("admin")})})})})]})]})},et=["ACTIVE","PASSIVE","DISABLED"],wl=({onFilter:l})=>{const{t:n}=U(),[a,t]=u(et[0]),[i,s]=qe();return e(fe,{width:300,"data-testid":"filter-type-select",isOpen:i,className:"kc-filter-type-select",variant:Ce.single,onToggle:s,toggleIcon:e(ka,{}),onSelect:p=>{const d=et.find(h=>h===p.toString())||et[0];t(d),l(d),s()},selections:a,"aria-label":n("selectFilterType"),children:et.map(p=>e(ee,{"data-testid":`${p}-option`,value:p,children:n(`keysFilter.${p}`)},p))})},xl=({realmComponents:l})=>{const{adminClient:n}=ne(),{t:a}=U(),t=Ye(),i=Hn(),[s,p]=u(""),[d,h]=u(""),{realm:o}=ae(),[m,A]=u(),[I,O]=u();Ue(async()=>(await n.realms.getKeys({realm:o})).keys?.map(w=>{const x=l.find(D=>D.id===w.providerId);return{...w,provider:x?.name}}),A,[]);const[y,f]=ge({titleKey:a("publicKey"),messageKey:s,continueButtonLabel:"close",continueButtonVariant:se.primary,onConfirm:()=>Promise.resolve()}),[r,b]=ge({titleKey:a("certificate"),messageKey:d,continueButtonLabel:"close",continueButtonVariant:se.primary,onConfirm:()=>Promise.resolve()});return m?c(re,{variant:"light",padding:{default:"noPadding"},children:[e(f,{}),e(b,{}),e(ze,{isNotCompact:!0,className:"kc-keys-list",loader:I||m,ariaLabelKey:"keysList",searchPlaceholderKey:"searchKey",searchTypeComponent:e(wl,{onFilter:g=>O(g!==et[0]?m.filter(({status:w})=>w===g):void 0)}),columns:[{name:"algorithm",displayKey:"algorithm",cellFormatters:[ct()],transforms:[$e(15)]},{name:"type",displayKey:"type",cellFormatters:[ct()],transforms:[$e(10)]},{name:"kid",displayKey:"kid",cellFormatters:[ct()],transforms:[$e(10)]},{name:"use",displayKey:"use",cellFormatters:[ct()],transforms:[$e(10)]},{name:"provider",displayKey:"provider",cellRenderer:({provider:g})=>g||"-",transforms:[$e(10)]},{name:"validTo",displayKey:"validTo",cellRenderer:({validTo:g})=>g?i(new Date(g)):"-",transforms:[$e(10)]},{name:"publicKeys",displayKey:"publicKeys",cellRenderer:({type:g,publicKey:w,certificate:x})=>g==="EC"?e(N,{onClick:()=>{y(),p(w)},variant:"secondary",id:"kc-public-key",children:a("publicKey")}):g==="RSA"?c("div",{className:"button-wrapper",children:[e(N,{onClick:()=>{y(),p(w)},variant:"secondary",id:w,children:a("publicKey")}),e(N,{onClick:()=>{r(),h(x)},variant:"secondary",id:x,className:"kc-certificate",children:a("certificate")})]}):g==="OKP"?e(N,{onClick:()=>{y(),p(w)},variant:"secondary",id:"kc-public-key",children:a("publicKey")}):"",transforms:[$e(20)]}],isSearching:!!I,emptyState:e(xe,{hasIcon:!0,message:a("noKeys"),instructions:a("noKeysDescription"),primaryActionText:a("addProvider"),onPrimaryAction:()=>t(Dt({realm:o,tab:"providers"}))})})]}):e(We,{})},Dl="_dialog_121se_2",Rl={dialog:Dl},Nl=({providerType:l,onClose:n})=>{const{t:a}=U();return e(je,{className:Rl.dialog,variant:Xe.medium,title:a("addProvider"),isOpen:!0,onClose:n,children:e(zn,{providerType:l,onClose:n})})},Ol=({onConfirm:l,onClose:n})=>{const{t:a}=U(),i=Be().componentTypes?.[Ht]??[];return e(je,{variant:"medium",title:a("addProvider"),isOpen:!0,onClose:n,children:e(ga,{onSelectDataListItem:(s,p)=>{l(p)},"aria-label":a("addPredefinedMappers"),isCompact:!0,children:i.map(s=>e(va,{"aria-label":s.id,id:s.id,children:e(ya,{children:e(Ta,{dataListCells:[e(Ot,{"data-testid":`option-${s.id}`,children:s.id},`name-${s.id}`),e(Ot,{width:2,children:s.helpText},`helpText-${s.helpText}`)]})})},s.id))})})},Vl=({realmComponents:l,refresh:n})=>{const{adminClient:a}=ne(),{t}=U(),{addAlert:i,addError:s}=ve(),{realm:p}=ae(),[d,h]=u(""),[o,m]=u([]),[A,I]=qe(),y=Be().componentTypes?.[Ht]??[],[f,r]=qe(),[b,g]=u(),[w,x]=u(),D=at(()=>l.map(E=>{const M=y.find(G=>E.providerId===G.id);return{...E,providerDescription:M?.helpText}}),[l]),[k,L]=ge({titleKey:"deleteProviderTitle",messageKey:t("deleteProviderConfirm",{provider:w?.name}),continueButtonLabel:"delete",continueButtonVariant:se.danger,onConfirm:async()=>{try{await a.components.del({id:w.id,realm:p}),n(),i(t("deleteProviderSuccess"),ie.success)}catch(E){s("deleteProviderError",E)}}}),T=()=>{if(d!==""){h(d);const E=D.filter(M=>M.name?.includes(d)||M.providerId?.includes(d));m(E)}else h(""),m(D)},V=E=>{E.key==="Enter"&&T()},P=E=>{h(E)};return c(J,{children:[f&&e(Ol,{onClose:()=>r(),onConfirm:E=>{I(),g(E),r()}}),A&&b&&e(Nl,{providerType:b,onClose:()=>{I(),n()}}),e(L,{}),c(re,{variant:"light",padding:{default:"noPadding"},children:[e(ha,{children:c(ln,{className:"providers-toolbar",children:[e(Le,{children:c(sn,{children:[e(Jt,{isFill:!0,children:e(yt,{name:"inputGroupName",id:"inputGroupName","data-testid":"provider-search-input",type:"search","aria-label":t("search"),placeholder:t("search"),onChange:(E,M)=>P(M),onKeyDown:V})}),e(Jt,{children:e(N,{variant:se.control,"aria-label":t("search"),onClick:T,children:e(fa,{})})})]})}),e(Le,{children:e(N,{"data-testid":"addProviderDropdown",className:"add-provider-dropdown",onClick:()=>r(),children:t("addProvider")})})]})}),e(Ia,{variant:"compact",className:"kc-draggable-table",keyField:"id",data:o.length===0?D:o,onDragFinish:async(E,M)=>{const G=D.map(K=>{const q={...K};return delete q.providerDescription,a.components.update({id:K.id},{...q,config:{priority:[(M.length-M.indexOf(K.id)+100).toString()]}})});try{await Promise.all(G),n(),i(t("saveProviderListSuccess"),ie.success)}catch(K){s("saveProviderError",K)}},columns:[{name:"name",displayKey:"name",cellRenderer:E=>e(Ie,{"data-testid":"provider-name-link",to:rn({realm:p,id:E.id,providerType:E.providerId}),children:E.name},E.name)},{name:"providerId",displayKey:"provider"},{name:"providerDescription",displayKey:"providerDescription"}],actions:[{title:t("delete"),onClick:(E,M,G)=>{x(G),k()}}]})]})]})},Kl=l=>[...l].sort((a,t)=>{const i=Number(a.config?.priority),s=Number(t.config?.priority);return(isNaN(s)?0:s)-(isNaN(i)?0:i)}),Ml=()=>{const{adminClient:l}=ne(),{t:n}=U(),{realm:a}=ae(),[t,i]=u(),[s,p]=u(0),d=()=>{p(s+1)};Ue(()=>l.components.find({type:Ht,realm:a}),A=>i(Kl(A)),[s]);const h=A=>gt(Dt({realm:a,tab:A})),o=h("list"),m=h("providers");return t?c(bt,{mountOnEnter:!0,unmountOnExit:!0,defaultLocation:Dt({realm:a,tab:"list"}),children:[e($,{id:"keysList","data-testid":"rs-keys-list-tab","aria-label":"keys-list-subtab",title:e(j,{children:n("keysList")}),...o,children:e(xl,{realmComponents:t})}),e($,{id:"providers","data-testid":"rs-providers-tab","aria-label":"rs-providers-tab",title:e(j,{children:n("providers")}),...m,children:e(Vl,{realmComponents:t,refresh:d})})]}):e(We,{})},la={theme:"",themeType:"",locale:"",hasWords:[]},Fl=({defaultSupportedLocales:l,defaultLocales:n})=>{const{adminClient:a}=ne(),{t}=U(),{realm:i}=ae(),s=Be(),{whoAmI:p}=it(),d=on(),[h,o]=u(!1),[m,A]=u(!1),[I,O]=u(!1),[y,f]=u(!1),[r,b]=u(!1),[g,w]=u({}),[x,D]=u(0),k=s.themes,L=at(()=>k?d(Object.keys(k),C=>C):[],[k]),T=at(()=>k?d(Object.values(k).flatMap(C=>C.map(v=>v.name)).filter((C,v,W)=>W.indexOf(C)===v),C=>C):[],[k]),V=at(()=>Array.from(new Set([...n,...l])),[n,l]),P={theme:t("theme"),themeType:t("themeType"),locale:t("language"),hasWords:t("hasWords")},{getValues:E,reset:M,formState:{isDirty:G,isValid:K},control:q}=be({mode:"onChange",defaultValues:la}),X=async()=>{try{const C=E();if(["theme","themeType","locale"].some(Ee=>!C[Ee]))return[];const le=await a.serverInfo.findEffectiveMessageBundles({realm:i,...C,locale:C.locale||we,source:!0}),ye=C.hasWords.length>0?le.filter(Ee=>C.hasWords.some(S=>Ee.value.includes(S)||Ee.key.includes(S))):le;return d([...ye],cn("key"))}catch{return[]}};function de(){o(!1),ce()}function me(){M(),ce()}function ke(C){const v={...E()};delete v[C],M({...la,...v}),ce()}function ue(C,v){const W=E(),le=W[C],ye=Array.isArray(le)?le.filter(Ae=>Ae!==v):le;M({...W,[C]:ye}),ce()}function ce(){const C=jn(E(),v=>v!==""||Array.isArray(v)&&v.length>0);w(C),D(x+1)}const B=()=>c(_t,{direction:{default:"column"},spaceItems:{default:"spaceItemsNone"},children:[e(Oe,{children:e(st,{children:e(Re,{className:"pf-v5-u-mb-md pf-v5-u-mt-0 pf-v5-u-mr-md",component:Ft.p,children:t("effectiveMessageBundlesDescription")})})}),e(Oe,{children:e($n,{buttonText:t("searchForEffectiveMessageBundles"),setSearchDropdownOpen:o,searchDropdownOpen:h,marginRight:"2.5rem",width:"15vw",children:c(rt,{isHorizontal:!0,className:"pf-v5-u-w-25vw","data-testid":"effectiveMessageBundlesSearchForm",onSubmit:C=>C.preventDefault(),children:[e(R,{label:t("theme"),fieldId:"kc-theme",isRequired:!0,children:e(F,{name:"theme",control:q,rules:{validate:C=>(C||"").length>0},render:({field:C})=>e(fe,{"data-testid":"effective_message_bundles-theme-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:Ce.single,typeAheadAriaLabel:"Select",onToggle:v=>O(v),selections:C.value,onSelect:v=>{C.onChange(v.toString()),O(!1)},onClear:()=>{C.onChange("")},isOpen:I,"aria-labelledby":t("theme"),chipGroupComponent:e(Qe,{children:e(Je,{onClick:v=>{v.stopPropagation(),C.onChange("")},children:C.value},C.value)}),children:[e(ee,{value:"Select theme",label:t("selectTheme"),className:"kc__effective_message_bundles_search_theme__placeholder",isDisabled:!0},"theme_placeholder")].concat(T.map(v=>e(ee,{value:v},v)))})})}),e(R,{label:t("themeType"),fieldId:"kc-themeType",isRequired:!0,children:e(F,{name:"themeType",control:q,rules:{validate:C=>(C||"").length>0},render:({field:C})=>e(fe,{"data-testid":"effective-message-bundles-feature-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:Ce.single,typeAheadAriaLabel:"Select",onToggle:v=>f(v),selections:C.value,onSelect:v=>{C.onChange(v.toString()),f(!1)},onClear:()=>{C.onChange("")},isOpen:y,"aria-labelledby":t("themeType"),chipGroupComponent:e(Qe,{children:e(Je,{onClick:v=>{v.stopPropagation(),C.onChange("")},children:C.value},C.value)}),children:[e(ee,{value:"Select theme type",label:t("selectThemeType"),className:"pf-m-plain",isDisabled:!0},"themeType_placeholder")].concat(L.map(v=>e(ee,{value:v},v)))})})}),e(R,{label:t("language"),fieldId:"kc-language",isRequired:!0,children:e(F,{name:"locale",control:q,rules:{validate:C=>(C||"").length>0},render:({field:C})=>e(fe,{"data-testid":"effective-message-bundles-language-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:Ce.single,typeAheadAriaLabel:"Select",onToggle:v=>b(v),selections:C.value,onSelect:v=>{C.onChange(v.toString()),b(!1)},onClear:()=>{C.onChange("")},isOpen:r,"aria-labelledby":"language",chipGroupComponent:e(Qe,{children:C.value?e(Je,{onClick:v=>{v.stopPropagation(),C.onChange("")},children:Ne(C.value,p.getLocale())},C.value):null}),children:[e(ee,{value:"Select language",label:t("selectLanguage"),className:"pf-m-plain",isDisabled:!0},"language_placeholder")].concat(V.map(v=>e(ee,{value:v,children:Ne(v,p.getLocale())},v)))})})}),e(R,{label:t("hasWords"),fieldId:"kc-hasWords",children:e(F,{name:"hasWords",control:q,render:({field:C})=>c("div",{children:[e(yt,{id:"kc-hasWords","data-testid":"effective-message-bundles-hasWords-searchField",value:C.value.join(" "),onChange:v=>{const le=v.target.value;if(le.trim().length===0)C.onChange([]);else{const ye=le.split(" ").map(Ae=>Ae.trim());C.onChange(ye)}}}),e(Qe,{children:C.value.map((v,W)=>e(Je,{onClick:le=>{le.stopPropagation();const ye=C.value.filter((Ae,Ee)=>Ee!==W);C.onChange(ye)},children:v},W))})]})})}),c(Se,{className:"pf-v5-u-mt-sm",children:[e(N,{variant:"primary",onClick:()=>{A(!0),de()},"data-testid":"search-effective-message-bundles-btn",isDisabled:!K,children:t("search")}),e(N,{variant:"secondary",onClick:me,"data-testid":"reset-search-effective-message-bundles-btn",isDisabled:!G,children:t("reset")})]})]})})}),e(Oe,{children:Object.entries(g).length>0&&e(J,{children:Object.entries(g).map(C=>{const[v,W]=C;return e(Qe,{className:"pf-v5-u-mt-md pf-v5-u-mr-md",categoryName:P[v],isClosable:!0,onClick:()=>ke(v),children:typeof W=="string"?e(Je,{isReadOnly:!0,children:v==="locale"?Ne(W,p.getLocale())?.toLowerCase():W}):W.map(le=>e(Je,{onClick:()=>ue(v,le),children:le},le))},v)})})})]});return m?e(ze,{loader:X,ariaLabelKey:"effectiveMessageBundles",toolbarItem:B(),columns:[{name:"key",displayKey:"key"},{name:"value",displayKey:"value"}],emptyState:e(xe,{message:t("noSearchResults"),instructions:t("noSearchResultsInstructions")}),isSearching:Object.keys(g).length>0},x):c(J,{children:[e("div",{className:"pf-v5-u-py-lg pf-v5-u-pl-md",children:B()}),e(Ge,{}),e(xe,{message:t("emptyEffectiveMessageBundles"),instructions:t("emptyEffectiveMessageBundlesInstructions"),isSearchVariant:!0})]})},Hl=({handleModalToggle:l,save:n,form:a})=>{const{t}=U();return e(je,{variant:Xe.small,title:t("addTranslation"),isOpen:!0,onClose:l,actions:[e(N,{"data-testid":"add-translation-confirm-button",variant:"primary",type:"submit",form:"translation-form",children:t("create")},"confirm"),e(N,{id:"modal-cancel","data-testid":"cancel",variant:se.link,onClick:()=>{l()},children:t("cancel")},"cancel")],children:e(rt,{id:"translation-form",isHorizontal:!0,onSubmit:a.handleSubmit(n),children:c(_e,{...a,children:[e(pe,{name:"key",label:t("key"),autoFocus:!0,rules:{required:t("required")}}),e(pe,{name:"value",label:t("value"),rules:{required:t("required")}})]})})})},Ul=({internationalizationEnabled:l,watchSupportedLocales:n,realm:a,tableData:t})=>{const{adminClient:i}=ne(),{t:s}=U(),[p,d]=u(!1),[h,o]=u(!1),[m,A]=u([]),[I,O]=u(we),[y,f]=u(!1),{getValues:r,handleSubmit:b}=be(),[g,w]=u(!1),[x,D]=u([]),[k,L]=u(0),[T,V]=u(10),[P,E]=u(0),[M,G]=u(""),K=be({mode:"onChange"}),{addAlert:q,addError:X}=ve(),{realm:de}=ae(),{whoAmI:me}=it(),[ke,ue]=u([]),[ce,B]=u(!1),[C,v]=u({}),[W,le]=u(""),ye=()=>{L(k+1)};Pe(()=>{(async()=>{try{let z=await i.realms.getRealmLocalizationTexts({first:P,max:T,realm:a.realm,selectedLocale:I||r("defaultLocale")||me.getLocale()});if(M){const oe=Ke=>Object.entries(z).filter(St=>St[Ke].includes(M)),Y=cl(oe(0).concat(oe(1)),Sa);z=Object.fromEntries(Y)}return Object.entries(z).slice(P,P+T)}catch{return[]}})().then(z=>{A(z);const oe=z.map(Y=>({rowEditBtnAriaLabel:()=>s("rowEditBtnAriaLabel",{translation:Y[1]}),rowSaveBtnAriaLabel:()=>s("rowSaveBtnAriaLabel",{translation:Y[1]}),rowCancelBtnAriaLabel:()=>s("rowCancelBtnAriaLabel",{translation:Y[1]}),cells:[{title:Y[0],props:{value:Y[0]}},{title:Y[1],props:{value:Y[1]}}]}));D(oe)})},[k,t,P,T,M]);const Ae=()=>{d(!p)},Ee=[e(Vt,{label:s("defaultLocale"),children:e(ee,{value:we,children:Ne(we,me.getDisplayName())},we)},"group1"),e(Ge,{},"divider"),e(Vt,{label:s("supportedLocales"),children:n.map(_=>e(ee,{value:_,children:Ne(_,me.getLocale())},_))},"group2")],S=async _=>{try{await i.realms.addLocalization({realm:de,selectedLocale:I||r("defaultLocale")||we,key:_.key},_.value),i.setConfig({realmName:de}),ye(),K.setValue("key",""),K.setValue("value",""),q(s("addTranslationSuccess"),ie.success)}catch(z){X(s("addTranslationError"),z)}},[Z,De]=ge({titleKey:"deleteConfirmTranslationTitle",messageKey:s("translationDeleteConfirmDialog",{count:ke.length}),continueButtonLabel:"delete",continueButtonVariant:se.danger,onCancel:()=>{ue([]),B(!1)},onConfirm:async()=>{try{for(const _ of ke)await i.realms.deleteRealmLocalizationTexts({realm:de,selectedLocale:I,key:_});B(!1),ue([]),ye(),q(s("deleteAllTranslationsSuccess"),ie.success)}catch(_){X("deleteAllTranslationsError",_)}}}),Ct=(_,z)=>{const oe=(x[z].cells?.[0]).props.value;_.target.checked?ue(Y=>[...Y,oe]):ue(Y=>Y.filter(Ke=>Ke!==oe)),B(x.length===ke.length+(_.target.checked?1:-1))},Ea=()=>{ue(ce?[]:x.map(_=>(_.cells?.[0]).props.value)),B(!ce)},wa=_=>ke.includes(_),xa=async(_,z)=>{const oe=Xt(x),Y=Xt(oe[z]);(Y.cells?.[1]).props.value=_,oe[z]=Y;try{const Ke=(Y.cells?.[0]).props.value,St=(Y.cells?.[1]).props.value;await i.realms.addLocalization({realm:a.realm,selectedLocale:I||r("defaultLocale")||we,key:Ke},St),q(s("updateTranslationSuccess"),ie.success),D(oe)}catch{q(s("updateTranslationError"),ie.danger)}v(Ke=>({...Ke,[z]:!1}))};return c(J,{children:[e(De,{}),p&&e(Hl,{handleModalToggle:Ae,save:_=>{S(_),Ae()},form:K}),e(st,{children:e(Re,{className:"pf-v5-u-mt-lg pf-v5-u-ml-md",component:Ft.p,children:s("realmOverridesDescription")})}),c(xn,{count:m.length,first:P,max:T,onNextClick:E,onPreviousClick:E,onPerPageSelect:(_,z)=>{E(_),V(z)},inputGroupName:"search",inputGroupOnEnter:_=>{G(_),E(0),V(10)},inputGroupPlaceholder:s("searchForTranslation"),toolbarItem:c(J,{children:[e(N,{"data-testid":"add-translationBtn",onClick:()=>{d(!0),B(!1),ue([])},children:s("addTranslation")}),e(Le,{children:e(da,{toggle:_=>e(ma,{ref:_,onClick:()=>f(!y),variant:"plain",isExpanded:y,"data-testid":"toolbar-deleteBtn","aria-label":"kebab",children:e(ua,{})}),isOpen:y,isPlain:!0,children:e(pa,{children:e(tt,{component:"button","data-testid":"delete-selected-TranslationBtn",isDisabled:m.length===0||ke.length===0,onClick:()=>{Z(),f(!1)},children:s("delete")},"action")})})})]}),searchTypeComponent:e(Le,{children:e(fe,{width:180,isOpen:h,className:"kc-filter-by-locale-select",variant:Ce.single,isDisabled:!l,onToggle:_=>o(_),onSelect:_=>{O(_.toString()),w(!0),ye(),o(!1)},selections:g?Ne(I,me.getLocale()):a.defaultLocale!==""?Ne(we,me.getLocale()):s("placeholderText"),children:Ee})}),children:[m.length===0&&!M&&e(xe,{hasIcon:!0,message:s("noTranslations"),instructions:s("noTranslationsInstructions"),onPrimaryAction:Ae}),m.length===0&&M&&e(xe,{hasIcon:!0,icon:fa,isSearchVariant:!0,message:s("noSearchResults"),instructions:s("noRealmOverridesSearchResultsInstructions")}),m.length!==0&&c(Un,{"aria-label":s("editableRowsTable"),"data-testid":"editable-rows-table",children:[e(_n,{children:c(ta,{children:[e(dt,{className:"pf-v5-u-px-lg",children:e("input",{type:"checkbox","aria-label":s("selectAll"),checked:ce,onChange:Ea,"data-testid":"selectAll"})}),e(dt,{className:"pf-v5-u-py-lg",children:s("key")}),e(dt,{className:"pf-v5-u-py-lg",children:s("value")}),e(dt,{"aria-hidden":"true"})]})}),e(Gn,{children:x.map((_,z)=>c(ta,{children:[e(mt,{className:"pf-v5-u-px-lg",select:{rowIndex:z,onSelect:oe=>Ct(oe,z),isSelected:wa((_.cells?.[0]).props.value)}}),e(mt,{className:"pf-m-sm pf-v5-u-px-sm",dataLabel:s("key"),children:(_.cells?.[0]).props.value}),e(mt,{className:"pf-m-sm pf-v5-u-px-sm",dataLabel:s("value"),children:e(rt,{isHorizontal:!0,className:"kc-form-translationValue",onSubmit:b(()=>{xa(W,z)}),children:e(R,{fieldId:"kc-translationValue",className:"pf-v5-u-display-inline-block",children:C[z]?c(J,{children:[e(yt,{"aria-label":s("editTranslationValue"),type:"text",className:"pf-v5-u-w-initial","data-testid":`editTranslationValueInput-${z}`,value:W,onChange:(oe,Y)=>{le(Y)}},`edit-input-${z}`),e(N,{variant:"link",className:"pf-m-plain","data-testid":`editTranslationAcceptBtn-${z}`,type:"submit","aria-label":s("acceptBtn"),icon:e(dn,{})}),e(N,{variant:"link",className:"pf-m-plain","data-testid":`editTranslationCancelBtn-${z}`,icon:e(mn,{}),"aria-label":s("cancelBtn"),onClick:()=>{v(oe=>({...oe,[z]:!1}))}})]}):c(J,{children:[e("span",{children:(_.cells?.[1]).props.value}),e(N,{onClick:()=>{const oe=(x[z].cells?.[1]).props.value;le(oe),v(Y=>({...Y,[z]:!0}))},"aria-label":s("editBtn"),variant:"link",className:"pf-m-plain","data-testid":`editTranslationBtn-${z}`,children:e(qn,{})},`edit-button-${z}`)]})})})},z),e(mt,{isActionCell:!0,children:e(Bn,{items:[{title:s("delete"),onClick:()=>{ue([(_.cells?.[0]).props.value]),m.length===1&&B(!0),Z(),f(!1)}}]})})]},(_.cells?.[0]).props.value))})]})]})]})},_l=({save:l,realm:n,tableData:a})=>{const{t}=U(),{whoAmI:i}=it(),[s,p]=u(0),d=be(),{setValue:h,control:o,handleSubmit:m,formState:A}=d,I=n.supportedLocales?.length?n.supportedLocales:[we],O=Be().themes,y=at(()=>{const w=Object.values(O).flatMap(x=>x.flatMap(({locales:D})=>D||[]));return Array.from(new Set(w))},[O]),f=()=>{Ve(n,h),h("supportedLocales",I)};Pe(f,[]);const r=He({control:o,name:"supportedLocales",defaultValue:I}),b=He({control:o,name:"internationalizationEnabled",defaultValue:n.internationalizationEnabled}),g=He({name:"defaultLocale",control:o,defaultValue:n.defaultLocale?[n.defaultLocale]:[]});return c(Tt,{activeKey:s,onSelect:(w,x)=>p(x),children:[e($,{id:"locales",eventKey:0,title:e(j,{children:t("locales")}),"data-testid":"rs-localization-locales-tab",children:c(te,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg pf-v5-u-ml-md",onSubmit:m(l),children:[c(_e,{...d,children:[e(ra,{name:"internationalizationEnabled",label:t("internationalization"),labelIcon:t("internationalizationHelp"),labelOn:t("enabled"),labelOff:t("disabled"),"aria-label":t("internationalization")}),b&&c(J,{children:[e(nt,{name:"supportedLocales",isScrollable:!0,label:t("supportedLocales"),controller:{defaultValue:I},variant:"typeaheadMulti",placeholderText:t("selectLocales"),options:y.map(w=>({key:w,value:Ne(w,i.getLocale())||w}))}),e(nt,{name:"defaultLocale",label:t("defaultLocale"),controller:{defaultValue:we},"data-testid":"select-default-locale",options:r.map(w=>({key:w,value:Ne(w,i.getLocale())||w}))})]})]}),c(Se,{children:[e(N,{variant:"primary",isDisabled:!A.isDirty,type:"submit","data-testid":"localization-tab-save",children:t("save")}),e(N,{variant:"link",onClick:f,children:t("revert")})]})]})}),e($,{id:"realm-overrides",eventKey:1,title:c(j,{children:[t("realmOverrides")," "]}),"data-testid":"rs-localization-realm-overrides-tab",children:e(Ul,{internationalizationEnabled:b,watchSupportedLocales:r,realm:n,tableData:a})}),e($,{id:"effective-message-bundles",eventKey:2,title:e(j,{children:t("effectiveMessageBundles")}),"data-testid":"rs-localization-effective-message-bundles-tab",children:e(Fl,{defaultSupportedLocales:I,defaultLocales:g})})]})},Me=({fieldName:l,url:n})=>{const{t:a}=U(),t=l.substr(l.indexOf(".")+1);return e(pe,{name:l,label:a(t),labelIcon:c(vt,{i18nKey:`${t}Help`,children:["Default value prevents pages from being included",e(Rt,{href:n,title:a("learnMore")})]})})},Gl=({realm:l,save:n})=>{const{t:a}=U(),t=be(),{setValue:i,formState:{isDirty:s},handleSubmit:p}=t,d=()=>Ve(l,i);return Pe(d,[]),e(_e,{...t,children:c(te,{isHorizontal:!0,role:"manage-realm",className:"keycloak__security-defences__form",onSubmit:p(n),children:[e(Me,{fieldName:"browserSecurityHeaders.xFrameOptions",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),e(Me,{fieldName:"browserSecurityHeaders.contentSecurityPolicy",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy"}),e(Me,{fieldName:"browserSecurityHeaders.contentSecurityPolicyReportOnly",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only"}),e(Me,{fieldName:"browserSecurityHeaders.xContentTypeOptions",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options"}),e(Me,{fieldName:"browserSecurityHeaders.xRobotsTag",url:"https://developers.google.com/search/docs/advanced/robots/robots_meta_tag"}),e(Me,{fieldName:"browserSecurityHeaders.xXSSProtection",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection"}),e(Me,{fieldName:"browserSecurityHeaders.strictTransportSecurity",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security"}),e(Me,{fieldName:"browserSecurityHeaders.referrerPolicy",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy"}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"headers-form-tab-save",isDisabled:!s,children:a("save")}),e(N,{variant:"link",onClick:d,children:a("revert")})]})]})})},ut=({name:l,style:n})=>{const{t:a}=U();return e(Ca,{name:l,style:n,label:a(l),labelIcon:a(`${l}Help`),controller:{defaultValue:"",rules:{required:a("required")}}})},Bl=({realm:l,save:n})=>{const{t:a}=U(),t=be(),{setValue:i,handleSubmit:s,formState:{isDirty:p}}=t,[d,h]=u(!1),[o,m]=u(!1);let A;(f=>{f.Disabled="Disabled",f.PermanentLockout="PermanentLockout",f.TemporaryLockout="TemporaryLockout",f.PermanentAfterTemporaryLockout="PermanentAfterTemporaryLockout"})(A||(A={}));const I=["Disabled","PermanentLockout","TemporaryLockout","PermanentAfterTemporaryLockout"],O=()=>{Ve(l,i),m(!1)};Pe(O,[]);const y=t.getValues("bruteForceProtected")?t.getValues("permanentLockout")?t.getValues("maxTemporaryLockouts")==0?"PermanentLockout":"PermanentAfterTemporaryLockout":"TemporaryLockout":"Disabled";return e(_e,{...t,children:c(te,{role:"manage-realm",isHorizontal:!0,onSubmit:s(n),children:[e(R,{label:a("bruteForceMode"),fieldId:"kc-brute-force-mode",labelIcon:e(H,{helpText:a("bruteForceModeHelpText"),fieldLabelId:"bruteForceMode"}),children:e(fe,{toggleId:"kc-brute-force-mode",onToggle:()=>h(!d),onSelect:f=>{switch(f){case"Disabled":t.setValue("bruteForceProtected",!1),t.setValue("permanentLockout",!1),t.setValue("maxTemporaryLockouts",0);break;case"TemporaryLockout":t.setValue("bruteForceProtected",!0),t.setValue("permanentLockout",!1),t.setValue("maxTemporaryLockouts",0);break;case"PermanentLockout":t.setValue("bruteForceProtected",!0),t.setValue("permanentLockout",!0),t.setValue("maxTemporaryLockouts",0);break;case"PermanentAfterTemporaryLockout":t.setValue("bruteForceProtected",!0),t.setValue("permanentLockout",!0),t.setValue("maxTemporaryLockouts",1);break}m(!0),h(!1)},selections:y,variant:Ce.single,isOpen:d,"data-testid":"select-brute-force-mode","aria-label":a("selectUnmanagedAttributePolicy"),children:I.map(f=>e(ee,{value:f,children:a(`bruteForceMode.${f}`)},f))})}),y!=="Disabled"&&c(J,{children:[e(Lt,{name:"failureFactor",label:a("failureFactor"),labelIcon:a("failureFactorHelp"),controller:{defaultValue:0,rules:{required:a("required")}}}),y==="PermanentAfterTemporaryLockout"&&e(Lt,{name:"maxTemporaryLockouts",label:a("maxTemporaryLockouts"),labelIcon:a("maxTemporaryLockoutsHelp"),controller:{defaultValue:0}}),(y==="TemporaryLockout"||y==="PermanentAfterTemporaryLockout")&&c(J,{children:[e(ut,{name:"waitIncrementSeconds"}),e(ut,{name:"maxFailureWaitSeconds"}),e(ut,{name:"maxDeltaTimeSeconds"})]}),e(Lt,{name:"quickLoginCheckMilliSeconds",label:a("quickLoginCheckMilliSeconds"),labelIcon:a("quickLoginCheckMilliSecondsHelp"),controller:{defaultValue:0}}),e(ut,{name:"minimumQuickLoginWaitSeconds"})]}),c(Se,{children:[e(N,{variant:"primary",type:"submit","data-testid":"brute-force-tab-save",isDisabled:!p&&!o,children:a("save")}),e(N,{variant:"link",onClick:O,children:a("revert")})]})]})})},zl=({realm:l,save:n})=>{const{t:a}=U(),[t,i]=u(10);return c(Tt,{activeKey:t,onSelect:(s,p)=>i(p),children:[e($,{id:"headers",eventKey:10,"data-testid":"security-defenses-headers-tab",title:e(j,{children:a("headers")}),children:e(re,{variant:"light",children:e(Gl,{realm:l,save:n})})}),e($,{id:"bruteForce",eventKey:20,"data-testid":"security-defenses-brute-force-tab",title:e(j,{children:a("bruteForceDetection")}),children:e(re,{variant:"light",children:e(Bl,{realm:l,save:n})})})]})},$l=({setTableData:l})=>{const{adminClient:n}=ne(),{config:a,save:t}=zt(),{t:i}=U(),s=Ut(),p=Ye(),{realm:d}=ae(),[h,o]=u(0),[m,A]=u();Pe(()=>o(r=>r+1),[a]);async function I(){return a?.groups??[]}const[O,y]=ge({titleKey:"deleteDialogTitle",children:c(vt,{i18nKey:"deleteDialogDescription",children:[" ",e("strong",{children:{group:m?.name}}),"."]}),continueButtonLabel:"delete",continueButtonVariant:se.danger,onConfirm:async()=>{const r=(a?.groups??[]).filter(w=>w!==m),b=m?.displayHeader?.substring(2,m?.displayHeader.length-1),g=m?.displayDescription?.substring(2,m?.displayDescription.length-1);try{await Promise.all(s.map(async w=>{try{if(await n.realms.getRealmLocalizationTexts({realm:d,selectedLocale:w})){await n.realms.deleteRealmLocalizationTexts({realm:d,selectedLocale:w,key:b}),await n.realms.deleteRealmLocalizationTexts({realm:d,selectedLocale:w,key:g});const D=await n.realms.getRealmLocalizationTexts({realm:d,selectedLocale:w});l([D])}}catch{console.error(`Error removing translations for ${w}`)}})),t({...a,groups:r},{successMessageKey:"deleteSuccess",errorMessageKey:"deleteAttributeGroupError"})}catch(w){console.error(`Error removing translations or updating attributes group: ${w}`)}}});function f(r){A(r),O()}return c(re,{variant:"light",className:"pf-v5-u-p-0",children:[e(y,{}),e(ze,{loader:I,ariaLabelKey:"tableTitle",toolbarItem:e(Le,{children:e(N,{component:r=>e(Ie,{"data-testid":"create-attributes-groups-action",...r,to:Yt({realm:d})}),children:i("createGroupText")})}),columns:[{name:"name",displayKey:"columnName",cellRenderer:r=>e(Ie,{to:un({realm:d,name:r.name}),children:r.name})},{name:"displayHeader",displayKey:"columnDisplayName"},{name:"displayDescription",displayKey:"columnDisplayDescription"}],actions:[{title:i("delete"),onRowClick:f}],emptyState:e(xe,{message:i("emptyStateMessage"),instructions:i("emptyStateInstructions"),primaryActionText:i("createGroupText"),onPrimaryAction:()=>p(Yt({realm:d}))})},h)]})},ia=["username","email"],jl=({setTableData:l})=>{const{adminClient:n}=ne(),{config:a,save:t}=zt(),{realm:i}=ae(),{t:s}=U(),p=Ut(),d=Ye(),[h,o]=u("allGroups"),[m,A]=qe(),[I,O]=u(a?.attributes),[y,f]=u(""),[r,b]=ge({titleKey:s("deleteAttributeConfirmTitle"),messageKey:s("deleteAttributeConfirm",{attributeName:y}),continueButtonLabel:s("delete"),continueButtonVariant:se.danger,onConfirm:async()=>{if(!a?.attributes)return;const k=a.attributes.find(T=>T.name===y)?.displayName,L=k?.substring(2,k.length-1);try{await Promise.all(p.map(async V=>{try{if(await n.realms.getRealmLocalizationTexts({realm:i,selectedLocale:V})){await n.realms.deleteRealmLocalizationTexts({realm:i,selectedLocale:V,key:L});const E=await n.realms.getRealmLocalizationTexts({realm:i,selectedLocale:V});l([E])}}catch{console.error(`Error removing translations for ${V}`)}}));const T=a.attributes.filter(V=>V.name!==y);t({...a,attributes:T,groups:a.groups},{successMessageKey:"deleteAttributeSuccess",errorMessageKey:"deleteAttributeError"}),f("")}catch(T){console.error(`Error removing translations or updating attributes: ${T}`)}}});if(!a)return e(We,{});const g=a.attributes??[],w=a.groups??[],x=async(k,L)=>{const T=g.findIndex(P=>P.name===k.name);let V={};V=g[T],g.splice(T,1),g.splice(L,0,V),t({attributes:g,groups:w},{successMessageKey:"updatedUserProfileSuccess",errorMessageKey:"updatedUserProfileError"})},D=k=>e(Ie,{to:Qt({realm:i,attributeName:k.name}),children:k.name},k.name);return c(J,{children:[e(ha,{children:c(pn,{children:[e(Le,{children:e(fe,{toggleId:"kc-group-filter",width:200,"data-testid":"filter-select",isOpen:m,variant:Ce.single,onToggle:A,toggleIcon:e(ka,{}),onSelect:k=>{const L=k.toString();o(L),O(L==="allGroups"?g:g.filter(T=>T.group===L)),A()},selections:h==="allGroups"?s(h):h,children:[e(ee,{"data-testid":"all-groups",value:"allGroups",children:s("allGroups")},"allGroups"),...hn(g.filter(k=>!!k.group),"group").map(k=>e(ee,{value:k.group,children:k.group},k.group))]})}),e(Le,{className:"kc-toolbar-attributesTab",children:e(N,{"data-testid":"createAttributeBtn",variant:"primary",component:k=>e(Ie,{...k,to:fn({realm:i})}),children:s("createAttribute")})})]})}),e(Ge,{}),e(b,{}),e(Ia,{keyField:"name",onDragFinish:async(k,L)=>{const T=g.map(M=>M.name),V=L.indexOf(k),P=T.indexOf(k),E=g[P];E.name&&x(E,V)},actions:[{title:s("edit"),onClick:(k,L,T)=>{d(Qt({realm:i,attributeName:T.name}))}},{title:s("delete"),isActionable:({name:k})=>!ia.includes(k),isDisabled:ia.includes(name),onClick:(k,L,T)=>{f(T.name),r()}}],columns:[{name:"name",displayKey:s("attributeName"),cellRenderer:D},{name:"displayName",displayKey:s("attributeDisplayName")},{name:"group",displayKey:s("attributeGroup")}],data:I??g})]})},ql=()=>{const{config:l,save:n,isSaving:a}=zt(),{t}=U(),{addError:i}=ve(),[s,p]=u();Pe(()=>d(),[l,s]);function d(){s?.setValue(l?lt(l):"")}async function h(){const o=s?.getValue();if(o)try{await n(JSON.parse(o))}catch(m){i("invalidJsonError",m);return}}return c(re,{variant:"light",children:[e(Gt,{language:Bt.json,height:"30rem",onEditorDidMount:o=>p(o),isLanguageLabelVisible:!0}),e(rt,{children:c(Se,{children:[e(N,{"data-testid":"save",variant:"primary",onClick:h,isDisabled:a,children:t("save")}),e(N,{variant:"link",onClick:d,isDisabled:a,children:t("revert")})]})})]})},Wl=({setTableData:l})=>{const{realm:n}=ae(),{t:a}=U(),t=d=>gt(Zt({realm:n,tab:d})),i=t("attributes"),s=t("attributes-group"),p=t("json-editor");return e(Wn,{children:c(bt,{defaultLocation:Zt({realm:n,tab:"attributes"}),mountOnEnter:!0,children:[e($,{title:e(j,{children:a("attributes")}),"data-testid":"attributesTab",...i,children:e(jl,{setTableData:l})}),e($,{title:e(j,{children:a("attributesGroup")}),"data-testid":"attributesGroupTab",...s,children:e($l,{setTableData:l})}),e($,{title:e(j,{children:a("jsonEditor")}),"data-testid":"jsonEditorTab",...p,children:e(ql,{})})]})})},Jl=({save:l,onChange:n,value:a,realmName:t,refresh:i})=>{const{adminClient:s}=ne(),{environment:p}=bn(),{t:d}=U(),{refresh:h}=ba(),{addAlert:o,addError:m}=ve(),A=Ye(),[I,O]=u(!1),[y,f]=u(!1),{hasAccess:r}=gn(),b=r("manage-realm"),[g,w]=ge({titleKey:"disableConfirmTitle",messageKey:"disableConfirmRealm",continueButtonLabel:"disable",onConfirm:()=>{n(!a),l()}}),[x,D]=ge({titleKey:"deleteConfirmTitle",messageKey:"deleteConfirmRealmSetting",continueButtonLabel:"delete",continueButtonVariant:se.danger,onConfirm:async()=>{try{await s.realms.del({realm:t}),o(d("deletedSuccessRealmSetting"),ie.success),await h(),A(vn({realm:p.masterRealm})),i()}catch(k){m("deleteErrorRealmSetting",k)}}});return c(J,{children:[e(w,{}),e(D,{}),e(gl,{open:I,toggleDialog:()=>O(!I)}),e(bl,{isOpen:y,onClose:()=>f(!1)}),e(Ln,{titleKey:t,subKey:"realmSettingsExplain",helpUrl:yn.realmSettingsUrl,divider:!1,dropdownItems:[e(tt,{"data-testid":"openPartialImportModal",isDisabled:!b,onClick:()=>{O(!0)},children:d("partialImport")},"import"),e(tt,{"data-testid":"openPartialExportModal",isDisabled:!b,onClick:()=>f(!0),children:d("partialExport")},"export"),e(Ge,{},"separator"),e(tt,{isDisabled:!b,onClick:x,children:d("delete")},"delete")],isEnabled:a,isReadOnly:!b,onToggle:k=>{k?(n(k),l()):g()}})]})},Xl=()=>{const{adminClient:l}=ne(),{t:n}=U(),{addAlert:a,addError:t}=ve(),{realm:i,realmRepresentation:s,refresh:p}=ae(),{refresh:d}=ba(),h=Ut(),o=Ye(),m=Kt(),[A,I]=u(void 0),{control:O,setValue:y,getValues:f}=be({mode:"onChange"}),[r,b]=u(0),g=()=>{b(r+1)},w=(B=s)=>{Ve(B,y)};Pe(()=>{w(),(async()=>{try{await Promise.all(h.map(async C=>{try{const v=await l.realms.getRealmLocalizationTexts({realm:i,selectedLocale:C});v&&I([v])}catch{return[]}}))}catch{return[]}})()},[y,s]);const x=async B=>{B=Tn(B),B.attributes?.["acr.loa.map"]&&typeof B.attributes["acr.loa.map"]!="string"&&(B.attributes["acr.loa.map"]=JSON.stringify(Object.fromEntries(B.attributes["acr.loa.map"].filter(({key:v})=>v!=="").map(({key:v,value:W})=>[v,W]))));try{const v={...s,...B,id:B.realm};v.smtpServer?.port===""&&(v.smtpServer={...v.smtpServer,port:null});const W=await Cn(Sn(l.baseUrl,`admin/realms/${i}/ui-ext`),{method:"PUT",body:JSON.stringify(v),headers:{"Content-Type":"application/json",...kn(await l.getAccessToken())}});if(!W.ok)throw new Error(W.statusText);a(n("realmSaveSuccess"),ie.success)}catch(v){t("realmSaveError",v)}i!==(B.realm||s?.realm)&&(await d(),o(Pt({realm:B.realm,tab:"general"}))),p()},D=B=>gt(Pt({realm:i,tab:B})),k=D("general"),L=D("login"),T=D("email"),V=D("themes"),P=D("keys"),E=D("events"),M=D("localization"),G=D("security-defenses"),K=D("sessions"),q=D("tokens"),X=D("client-policies"),de=D("user-profile"),me=D("user-registration"),ke=B=>gt(xt({realm:i,tab:B})),ue=ke("profiles"),ce=ke("policies");return c(J,{children:[e(F,{name:"enabled",defaultValue:!0,control:O,render:({field:B})=>e(Jl,{value:B.value,onChange:B.onChange,realmName:i,refresh:g,save:()=>x(f())})}),e(re,{variant:"light",className:"pf-v5-u-p-0",children:c(bt,{isBox:!0,mountOnEnter:!0,"aria-label":"realm-settings-tabs",defaultLocation:Pt({realm:i,tab:"general"}),children:[e($,{title:e(j,{children:n("general")}),"data-testid":"rs-general-tab",...k,children:e(ul,{realm:s,save:x})}),e($,{title:e(j,{children:n("login")}),"data-testid":"rs-login-tab",...L,children:e(fl,{refresh:p,realm:s})}),e($,{title:e(j,{children:n("email")}),"data-testid":"rs-email-tab",...T,children:e(ml,{realm:s,save:x})}),e($,{title:e(j,{children:n("themes")}),"data-testid":"rs-themes-tab",...V,children:e(Sl,{realm:s,save:x})}),e($,{title:e(j,{children:n("keys")}),"data-testid":"rs-keys-tab",...P,children:e(Ml,{})}),e($,{title:e(j,{children:n("events")}),"data-testid":"rs-realm-events-tab",...E,children:e(El,{realm:s})}),e($,{title:e(j,{children:n("localization")}),"data-testid":"rs-localization-tab",...M,children:e(_l,{save:x,realm:s,tableData:A},r)}),e($,{title:e(j,{children:n("securityDefences")}),"data-testid":"rs-security-defenses-tab",...G,children:e(zl,{realm:s,save:x})}),e($,{title:e(j,{children:n("sessions")}),"data-testid":"rs-sessions-tab",...K,children:e(Cl,{realm:s,save:x},r)}),e($,{title:e(j,{children:n("tokens")}),"data-testid":"rs-tokens-tab",...q,children:e(kl,{save:x,realm:s})}),m(Mt.ClientPolicies)&&e($,{title:e(j,{children:n("clientPolicies")}),"data-testid":"rs-clientPolicies-tab",...X,children:c(bt,{mountOnEnter:!0,defaultLocation:xt({realm:i,tab:"profiles"}),children:[e($,{id:"profiles","data-testid":"rs-policies-clientProfiles-tab","aria-label":n("clientProfilesSubTab"),title:e(j,{children:n("profiles")}),tooltip:e(ea,{content:n("clientPoliciesProfilesHelpText")}),...ue,children:e(Tl,{})}),e($,{id:"policies","data-testid":"rs-policies-clientPolicies-tab","aria-label":n("clientPoliciesSubTab"),...ce,title:e(j,{children:n("policies")}),tooltip:e(ea,{content:n("clientPoliciesPoliciesHelpText")}),children:e(vl,{})})]})}),e($,{title:e(j,{children:n("userProfile")}),"data-testid":"rs-user-profile-tab",...de,children:e(Wl,{setTableData:I})}),e($,{title:e(j,{children:n("userRegistration")}),"data-testid":"rs-userRegistration-tab",...me,children:e(Ll,{})})]})})]})};function Ji(){return e(Xl,{})}export{Ji as default};
//# sourceMappingURL=RealmSettingsSection-G00jJoQt.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy