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

theme.keycloak.v2.admin.resources.assets.ClientDetails-048733ef.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{_ as jt,r as c,k as Me,ao as rn,c as he,u as k,Y as As,W as He,q as ie,j as e,ap as et,F as b,h as C,a0 as cn,g as A,aq as Je,a as X,C as N,R as tt,U as Ce,ad as O,S as de,B as P,a1 as Es,ar as dn,e as Oe,d as oe,l as fe,A as Y,ae as Ae,as as Fe,L as ge,ab as ws,O as Vt,x as qt,P as xe,at as Tt,au as Pe,av as Ke,V as ve,aw as un,N as Le,ax as ft,ay as Bt,az as pn,aA as mn,aB as hn,X as Ue,aC as xn,Q as Ze,f as De,T as ht,aD as gn,K as Ee,b as st,aE as xt,o as Nt,D as Ut,E as Os,G as Qe,aF as jn,a4 as nt,aG as Xt,aH as Ps,aI as Zt,aJ as _s,aK as es,aL as fn,a7 as yn,aM as bn,aN as Ls,aO as Sn,al as vn,aP as Cn,aQ as Tn,aR as ts,aS as ss,aT as In,y as kn,z as ns,aU as Rn}from"./index-0cda761d.js";import{C as Gt,u as Te}from"./ConfirmDialog-100e6a40.js";import{g as An}from"./getAuthorizationHeaders-f2376d1a.js";import{K as at}from"./KeycloakTextArea-9049d04c.js";import{a as it,M as ze}from"./Modal-ea09312d.js";import{F as ye,A as Ie}from"./Form-4087ddae.js";import{S as En,a as as,F as ce,C as wn,b as Ds}from"./FormAccess-835af982.js";import{S as J,a as G,b as z}from"./Select-68736f55.js";import{P as On}from"./PermissionTab-06b68a7e.js";import{R as Pn}from"./RolesList-4cd78856.js";import{R as wt,u as Ot}from"./RoutableTabs-56121a9c.js";import{V as _n}from"./ViewHeader-ff389f8e.js";import{u as Ln,F as Dn}from"./useIsFeatureEnabled-7d978ee4.js";import{u as Ht}from"./useParams-bc47a968.js";import{u as be}from"./useToggle-3764a2a4.js";import{S as Ns}from"./ScrollForm-e9e4a7be.js";import{K as Nn}from"./KeyValueInput-597f6e1a.js";import{M as Fs}from"./MultiLineInput-05f00b93.js";import{T as $t}from"./TimeSelector-5680ad0f.js";import{L as we,P as It}from"./PaginatingTableToolbar-11bdf18a.js";import{K as kt}from"./KeycloakDataTable-a1a2bfca.js";import{u as Wt,F as Ks}from"./useFormatDate-108df619.js";import{K as pe}from"./KeycloakTextInput-ada01047.js";import{E as Ms}from"./ExpandableSection-967fdc24.js";import{b as je,T as Fn,c as Kn}from"./ToolbarContent-fee3570e.js";import{T as zs}from"./Trans-4d909f1b.js";import{T as me,a as Vs}from"./Text-b9444fb8.js";import{S as Mn}from"./SessionsTable-7834737d.js";import{C as zn,a as Vn}from"./ClientDescription-8cf89631.js";import{F as Rt}from"./FixedButtonGroup-8d7378f6.js";import{L as qn}from"./LoginSettings-3493ef63.js";import{C as Bn}from"./ClientSelect-ab12f3f6.js";import{U as qs,i as Un,D as Gn,A as Hn}from"./PolicyDetails-63e32b3b.js";import{d as Bs,i as St,g as $n}from"./utils-49fe564a.js";import{c as Wn}from"./camelCase-5c23217e.js";import{T as Ve,O as qe,P as ae,Q as B,R as Be,S as F,U as lt}from"./Td-d9b96677.js";import{M as Jn}from"./minus-circle-icon-ac3563ca.js";import{P as Us}from"./plus-circle-icon-fe78809e.js";import{D as is}from"./policyRepresentation-618c0846.js";import{D as ot,a as Qn,b as Yn,c as Xn}from"./DescriptionListTerm-b3172289.js";import{s as Zn,P as ls,a as os}from"./TableToolbar-470a2060.js";import{E as Gs,a as Hs}from"./EmptyStateBody-f9d2c033.js";import{E as ea}from"./EmptyStateSecondaryActions-e8364506.js";import{u as $s,m as Ws}from"./useLocaleSort-ef2c79ac.js";import{D as ta}from"./DeleteScopeDialog-6e82b745.js";import{J as sa}from"./JsonFileUpload-9098f471.js";import{R as gt}from"./Radio-a79edd45.js";import{P as Ft}from"./PasswordInput-bb06acaa.js";import{C as Ct}from"./Card-d5c0a973.js";import{C as Ye}from"./CardBody-8867799e.js";import{F as Js}from"./FileUpload-2469f593.js";import{C as na}from"./CardHeader-3276a0b8.js";import{C as aa}from"./CardTitle-2a7bf3d6.js";import{F as ia}from"./FormPanel-8c11e1e2.js";import{F as la}from"./Flex-a3793595.js";import{F as rs}from"./FlexItem-742749b8.js";import{S as oa,a as ra,C as ca,n as da,t as ua}from"./SearchFilter-5d051f5f.js";import{A as cs,e as ds,f as pa,a as ma,g as ha,C as us}from"./ClientScopeTypes-d24d11d6.js";import{c as pt,T as xa,a as se,b as ne}from"./Tabs-76c5b0e3.js";import{Q as ga}from"./question-circle-icon-38235421.js";import{G as ja,a as ps}from"./GridItem-1535d986.js";import{R as fa}from"./AddRoleMappingModal-71c36ce9.js";import"./copy-icon-b8d617db.js";import"./check-fc57dbe1.js";import"./star-icon-2ee5dfa7.js";import"./minus-icon-21b0d1e4.js";import"./ActionListItem-c859aeaf.js";import"./ListItem-644b3aa5.js";import"./Checkbox-3affa1d3.js";import"./SwitchControl-ac2ce3d1.js";import"./ResourcesPolicySelect-7e343dcc.js";import"./filter-icon-56a9cd24.js";import"./GroupPickerDialog-9d38b823.js";import"./admin-ui-endpoint-f934fa67.js";import"./DataListItemRow-7ca17a45.js";import"./data-list-7d55714c.js";import"./grip-vertical-icon-ba7b06db.js";import"./CodeEditor-781232a0.js";import"./DatePicker-66178c4a.js";import"./MenuList-7fad6760.js";import"./NumberInput-1d7f57ff.js";import"./plus-icon-4f91635d.js";import"./capitalize-633f53e4.js";import"./FileUploadForm-eb2a90b9.js";import"./resource-0803fa9b.js";const bt={codeBlock:"pf-c-code-block",codeBlockActions:"pf-c-code-block__actions",codeBlockCode:"pf-c-code-block__code",codeBlockContent:"pf-c-code-block__content",codeBlockHeader:"pf-c-code-block__header",codeBlockPre:"pf-c-code-block__pre"},Qs=s=>{var{children:n=null,className:i,actions:t=null}=s,a=jt(s,["children","className","actions"]);return c.createElement("div",Object.assign({className:Me(bt.codeBlock,i)},a),c.createElement("div",{className:Me(bt.codeBlockHeader)},c.createElement("div",{className:Me(bt.codeBlockActions)},t&&t)),c.createElement("div",{className:Me(bt.codeBlockContent)},n))};Qs.displayName="CodeBlock";const Ys=s=>{var{children:n=null,className:i}=s,t=jt(s,["children","className"]);return c.createElement("div",Object.assign({className:Me("pf-c-code-block__actions-item",i)},t),n)};Ys.displayName="CodeBlockAction";const Kt=s=>{var{className:n,children:i}=s,t=jt(s,["className","children"]);return c.createElement("div",Object.assign({className:Me(Zn.panelHeader,n)},t),i)};Kt.displayName="PanelHeader";var Mt;(function(s){s.ul="ul",s.ol="ol",s.dl="dl"})(Mt||(Mt={}));const Xs=s=>{var{children:n=null,className:i="",component:t=Mt.ul,isPlain:a=!1}=s,o=jt(s,["children","className","component","isPlain"]);const l=t;return c.createElement(l,Object.assign({},o,{className:Me(a&&rn.modifiers.plain,i)}),n)};Xs.displayName="TextList";var zt;(function(s){s.li="li",s.dt="dt",s.dd="dd"})(zt||(zt={}));const Zs=s=>{var{children:n=null,className:i="",component:t=zt.li}=s,a=jt(s,["children","className","component"]);const o=t;return c.createElement(o,Object.assign({},a,{className:Me(i)}),n)};Zs.displayName="TextListItem";const ya=({id:s,open:n,toggleDialog:i,protocol:t="openid-connect"})=>{const{realm:a}=he(),{t:o}=k("common"),{enabled:l}=As(),r=He().clientInstallations[t],[m,h]=c.useState(r[r.length-1].id),[p,d]=c.useState(),[x,j]=c.useState(!1),S=c.useMemo(()=>r.find(g=>g.id===m)??null,[m]),y=g=>g.replace(/.*<\/PrivateKeyPem>/gs,`${o("clients:privateKeyMask")}`);return ie(async()=>{if(S?.mediaType==="application/zip")return(await fetch(`${cn(A.baseUrl)}admin/realms/${a}/clients/${s}/installation/providers/${m}`,{method:"GET",headers:An(await A.getAccessToken())})).arrayBuffer();{const g=await A.clients.getInstallationProviders({id:s,providerId:m});return typeof g=="string"?y(g):Je(g)}},g=>d(g),[s,m]),c.useEffect(()=>d(""),[s,m]),e.jsx(Gt,{titleKey:o("clients:downloadAdaptorTitle"),continueButtonLabel:o("download"),onConfirm:()=>{et.saveAs(new Blob([p],{type:S?.mediaType}),S?.filename)},open:n,toggleDialog:i,variant:it.medium,children:e.jsx(ye,{children:e.jsxs(En,{hasGutter:!0,children:[e.jsx(as,{children:e.jsx(b,{fieldId:"type",label:o("clients:formatOption"),labelIcon:e.jsx(C,{helpText:o("clients-help:downloadType"),fieldLabelId:"clients:formatOption"}),children:e.jsx(J,{toggleId:"type",isOpen:x,onToggle:g=>j(g),variant:G.single,value:m,selections:m,onSelect:(g,M)=>{h(M.toString()),j(!1)},"aria-label":"Select Input",menuAppendTo:()=>document.body,children:r.map(g=>e.jsx(z,{value:g.id,isSelected:m===g.id,description:l?g.helpText:void 0,children:g.displayType},g.id))})})}),!S?.downloadOnly&&e.jsx(as,{isFilled:!0,children:e.jsx(b,{fieldId:"details",label:o("details"),labelIcon:e.jsx(C,{helpText:o("clients-help:details"),fieldLabelId:"clients:details"}),children:e.jsx(at,{id:"details",readOnly:!0,rows:12,resizeOrientation:"vertical",value:p&&typeof p=="string"?p:"","aria-label":"text area example"})})})]})})})},ms="tokenLifespan.inherited",hs="tokenLifespan.never",xs="tokenLifespan.expires",mt=({id:s,name:n,defaultValue:i,units:t})=>{const{t:a}=k("clients"),[o,l]=c.useState(!1),[u,r]=c.useState(!1),m=()=>r(!0),h=()=>r(!1),{control:p}=X(),d=x=>typeof x=="number"&&x!==-1||typeof x=="string"&&x!==""&&x!=="-1"||u;return e.jsx(b,{label:a(s),fieldId:s,labelIcon:e.jsx(C,{helpText:a(`clients-help:${s}`),fieldLabelId:`clients:${s}`}),children:e.jsx(N,{name:n,defaultValue:"",control:p,render:({field:x})=>e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{children:e.jsxs(J,{variant:G.single,onToggle:l,isOpen:o,onSelect:(j,S)=>{x.onChange(S),l(!1)},selections:[d(x.value)?a(xs):x.value===""?a(ms):a(hs)],children:[e.jsx(z,{value:"",children:a(ms)}),e.jsx(z,{value:-1,children:a(hs)}),e.jsx(z,{value:60,children:a(xs)})]})}),e.jsx(Ce,{children:x.value!=="-1"&&x.value!==-1&&e.jsx($t,{units:t,value:x.value===""?i:x.value,onChange:x.onChange,onFocus:m,onBlur:h,min:1,isDisabled:x.value===""})})]})})})},ba=({save:s,reset:n,protocol:i,hasConfigureAccess:t})=>{const{t:a}=k("clients"),[o,l]=c.useState(!1),[u,r]=c.useState(),{realm:m}=he();ie(()=>A.realms.findOne({realm:m}),r,[]);const{control:h}=X();return e.jsxs(ce,{role:"manage-realm",fineGrainedAccess:t,isHorizontal:!0,children:[i!=="openid-connect"&&e.jsx(b,{label:a("assertionLifespan"),fieldId:"assertionLifespan",labelIcon:e.jsx(C,{helpText:a("clients-help:assertionLifespan"),fieldLabelId:"clients:assertionLifespan"}),children:e.jsx(N,{name:O("attributes.saml.assertion.lifespan"),defaultValue:"",control:h,render:({field:p})=>e.jsx($t,{units:["minute","day","hour"],value:p.value,onChange:p.onChange})})}),i==="openid-connect"&&e.jsxs(e.Fragment,{children:[e.jsx(mt,{id:"accessTokenLifespan",name:O("attributes.access.token.lifespan"),defaultValue:u?.accessTokenLifespan,units:["minute","day","hour"]}),e.jsx(mt,{id:"clientSessionIdle",name:O("attributes.client.session.idle.timeout"),defaultValue:u?.clientSessionIdleTimeout,units:["minute","day","hour"]}),e.jsx(mt,{id:"clientSessionMax",name:O("attributes.client.session.max.lifespan"),defaultValue:u?.clientSessionMaxLifespan,units:["minute","day","hour"]}),e.jsx(mt,{id:"clientOfflineSessionIdle",name:O("attributes.client.offline.session.idle.timeout"),defaultValue:u?.offlineSessionIdleTimeout,units:["minute","day","hour"]}),e.jsx(mt,{id:"clientOfflineSessionMax",name:O("attributes.client.offline.session.max.lifespan"),defaultValue:u?.offlineSessionMaxLifespan,units:["minute","day","hour"]}),e.jsx(b,{label:a("oAuthMutual"),fieldId:"oAuthMutual",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:a("clients-help:oAuthMutual"),fieldLabelId:"clients:oAuthMutual"}),children:e.jsx(N,{name:O("attributes.tls.client.certificate.bound.access.tokens"),defaultValue:!1,control:h,render:({field:p})=>e.jsx(de,{id:"oAuthMutual-switch",label:a("common:on"),labelOff:a("common:off"),isChecked:p.value==="true",onChange:d=>p.onChange(""+d),"aria-label":a("oAuthMutual")})})}),e.jsx(b,{label:a("keyForCodeExchange"),fieldId:"keyForCodeExchange",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:a("clients-help:keyForCodeExchange"),fieldLabelId:"clients:keyForCodeExchange"}),children:e.jsx(N,{name:O("attributes.pkce.code.challenge.method"),defaultValue:"",control:h,render:({field:p})=>e.jsx(J,{toggleId:"keyForCodeExchange",variant:G.single,onToggle:l,isOpen:o,onSelect:(d,x)=>{p.onChange(x),l(!1)},selections:[p.value||a("common:choose")],children:["","S256","plain"].map(d=>e.jsx(z,{value:d,children:d||a("common:choose")},d))})})}),e.jsx(b,{label:a("pushedAuthorizationRequestRequired"),fieldId:"pushedAuthorizationRequestRequired",labelIcon:e.jsx(C,{helpText:a("clients-help:pushedAuthorizationRequestRequired"),fieldLabelId:"clients:pushedAuthorizationRequestRequired"}),children:e.jsx(N,{name:O("attributes.require.pushed.authorization.requests"),defaultValue:"false",control:h,render:({field:p})=>e.jsx(de,{id:"pushedAuthorizationRequestRequired",label:a("common:on"),labelOff:a("common:off"),isChecked:p.value==="true",onChange:d=>p.onChange(d.toString()),"aria-label":a("pushedAuthorizationRequestRequired")})})}),e.jsx(b,{label:a("acrToLoAMapping"),fieldId:"acrToLoAMapping",labelIcon:e.jsx(C,{helpText:a("clients-help:acrToLoAMapping"),fieldLabelId:"clients:acrToLoAMapping"}),children:e.jsx(Nn,{name:O("attributes.acr.loa.map")})}),e.jsx(b,{label:a("defaultACRValues"),fieldId:"defaultACRValues",labelIcon:e.jsx(C,{helpText:a("clients-help:defaultACRValues"),fieldLabelId:"clients:defaultACRValues"}),children:e.jsx(Fs,{id:"defaultACRValues","aria-label":"defaultACRValues",name:O("attributes.default.acr.values"),stringify:!0})})]}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"secondary",onClick:s,"data-testid":"OIDCAdvancedSave",children:a("common:save")}),e.jsx(P,{variant:"link",onClick:n,"data-testid":"OIDCAdvancedRevert",children:a("common:revert")})]})]})},Sa=({protocol:s,save:n,reset:i,hasConfigureAccess:t})=>{const{t:a}=k("clients"),[o,l]=c.useState([]),[u,r]=c.useState(!1),[m,h]=c.useState(!1),{control:p}=X();return ie(()=>A.authenticationManagement.getFlows(),d=>{let x=[...d.filter(j=>j.providerId!=="client-flow")];x=Es(x,[j=>j.alias]),l([e.jsx(z,{value:"",children:a("common:choose")},"empty"),...x.map(j=>e.jsx(z,{value:j.id,children:j.alias},j.id))])},[]),e.jsxs(ce,{role:"manage-clients",fineGrainedAccess:t,isHorizontal:!0,children:[e.jsx(b,{label:a("browserFlow"),fieldId:"browserFlow",labelIcon:e.jsx(C,{helpText:a("clients-help:browserFlow"),fieldLabelId:"clients:browserFlow"}),children:e.jsx(N,{name:"authenticationFlowBindingOverrides.browser",defaultValue:"",control:p,render:({field:d})=>e.jsx(J,{toggleId:"browserFlow",variant:G.single,onToggle:r,isOpen:u,onSelect:(x,j)=>{d.onChange(j),r(!1)},selections:[d.value],children:o})})}),s==="openid-connect"&&e.jsx(b,{label:a("directGrant"),fieldId:"directGrant",labelIcon:e.jsx(C,{helpText:a("clients-help:directGrant"),fieldLabelId:"clients:directGrant"}),children:e.jsx(N,{name:"authenticationFlowBindingOverrides.direct_grant",defaultValue:"",control:p,render:({field:d})=>e.jsx(J,{toggleId:"directGrant",variant:G.single,onToggle:h,isOpen:m,onSelect:(x,j)=>{d.onChange(j),h(!1)},selections:[d.value],children:o})})}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"secondary",onClick:n,"data-testid":"OIDCAuthFlowOverrideSave",children:a("common:save")}),e.jsx(P,{variant:"link",onClick:i,"data-testid":"OIDCAuthFlowOverrideRevert",children:a("common:revert")})]})]})},va=s=>{const{field:n}=dn(s);return e.jsx($t,{...s,...n})},Ca=({clientId:s,isOpen:n,onAdded:i,onClose:t})=>{const{t:a}=k("clients"),{register:o,handleSubmit:l,formState:{isDirty:u,isValid:r}}=Oe(),{addAlert:m,addError:h}=oe();async function p({node:d}){try{await A.clients.addClusterNode({id:s,node:d}),i(d),m(a("addedNodeSuccess"),Y.success)}catch(x){h("clients:addedNodeFail",x)}t()}return e.jsx(ze,{title:a("addNode"),isOpen:n,onClose:t,variant:"small",actions:[e.jsx(P,{id:"add-node-confirm",type:"submit",form:"add-host-form",isDisabled:!u||!r,children:a("common:save")},"confirm"),e.jsx(P,{id:"add-node-cancel",variant:fe.link,onClick:t,children:a("common:cancel")},"cancel")],children:e.jsx(ye,{id:"add-host-form",onSubmit:l(p),isHorizontal:!0,children:e.jsx(b,{label:a("nodeHost"),fieldId:"nodeHost",isRequired:!0,children:e.jsx(pe,{id:"nodeHost",...o("node",{required:!0}),isRequired:!0})})})})},Ta=({save:s,client:{id:n,registeredNodes:i,access:t}})=>{const{t:a}=k("clients"),{addAlert:o,addError:l}=oe(),u=Wt(),[r,m]=c.useState(i||{}),[h,p]=c.useState(!1),[d,x]=c.useState(""),[j,S]=c.useState(!1),[y,g]=c.useState(0),M=()=>g(new Date().getTime()),U=async()=>{const E=await A.clients.testNodesAvailable({id:n});tn(E,"testCluster",o,a)},[Q,R]=Te({titleKey:"clients:deleteNode",messageKey:a("deleteNodeBody",{node:d}),continueButtonLabel:"common:delete",continueButtonVariant:fe.danger,onConfirm:async()=>{try{await A.clients.deleteClusterNode({id:n,node:d}),m({...Object.keys(r).reduce((E,H)=>(H!==d&&(E[H]=r[H]),E),{})}),M(),o(a("deleteNodeSuccess"),Y.success)}catch(E){l("clients:deleteNodeFail",E)}}});return e.jsxs(e.Fragment,{children:[e.jsx(ce,{role:"manage-clients",fineGrainedAccess:t?.configure,isHorizontal:!0,children:e.jsx(b,{label:a("nodeReRegistrationTimeout"),fieldId:"kc-node-reregistration-timeout",labelIcon:e.jsx(C,{helpText:a("clients-help:nodeReRegistrationTimeout"),fieldLabelId:"clients:nodeReRegistrationTimeout"}),children:e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{children:e.jsx(va,{name:"nodeReRegistrationTimeout"})}),e.jsx(Ce,{children:e.jsx(P,{variant:fe.secondary,onClick:()=>s(),children:a("common:save")})})]})})}),e.jsxs(e.Fragment,{children:[e.jsx(R,{}),e.jsx(Ca,{clientId:n,isOpen:j,onAdded:E=>{r[E]=Date.now()/1e3,M()},onClose:()=>S(!1)}),e.jsx(Ms,{toggleText:a("registeredClusterNodes"),onToggle:p,isExpanded:h,children:e.jsx(kt,{ariaLabelKey:"registeredClusterNodes",loader:()=>Promise.resolve(Object.entries(r||{}).map(E=>({host:E[0],registration:E[1]}))),toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(je,{children:e.jsx(P,{id:"testClusterAvailability",onClick:U,variant:fe.secondary,isDisabled:Object.keys(r).length===0,children:a("testClusterAvailability")})}),e.jsx(je,{children:e.jsx(P,{id:"registerNodeManually",onClick:()=>S(!0),variant:fe.tertiary,children:a("registerNodeManually")})})]}),actions:[{title:a("common:delete"),onRowClick:E=>{x(E.host),Q()}}],columns:[{name:"host",displayKey:"clients:nodeHost"},{name:"registration",displayKey:"clients:lastRegistration",cellFormatters:[E=>E?u(new Date(parseInt(E.toString())*1e3),Ks):""]}],emptyState:e.jsx(we,{message:a("noNodes"),instructions:a("noNodesInstructions"),primaryActionText:a("registerNodeManually"),onPrimaryAction:()=>S(!0)})},y)})]})]})},en=s=>{const{t:n}=k("clients");return e.jsxs(e.Fragment,{children:[e.jsx(Ae,{name:"attributes.logoUri",label:n("clients:logoUrl"),labelIcon:n("clients-help:logoUrl"),type:"url",...s}),e.jsx(Ae,{name:"attributes.policyUri",label:n("clients:policyUrl"),labelIcon:n("clients-help:policyUrl"),type:"url",...s}),e.jsx(Ae,{name:"attributes.tosUri",label:n("clients:termsOfServiceUrl"),labelIcon:n("clients-help:termsOfServiceUrl"),type:"url",...s})]})},Ia=({save:s,reset:n,hasConfigureAccess:i})=>{const{t}=k("clients"),a=He().providers,o=a?.clientSignature.providers,l=a?.contentencryption.providers,u=a?.cekmanagement.providers,r=a?.signature.providers,[m,h]=c.useState(!1),[p,d]=c.useState(!1),[x,j]=c.useState(!1),[S,y]=c.useState(!1),[g,M]=c.useState(!1),[U,Q]=c.useState(!1),[R,E]=c.useState(!1),[H,w]=c.useState(!1),[I,f]=c.useState(!1),[v,q]=c.useState(!1),[_,L]=c.useState(!1),[V,D]=c.useState(!1),[K,le]=c.useState(!1),[Se,ee]=c.useState(!1),{control:$}=X(),te=[e.jsx(z,{value:"",children:t("common:choose")},"empty"),...Fe(o).map(T=>e.jsx(z,{value:T},T))],ke=[e.jsx(z,{value:"",children:t("common:choose")},"empty"),...Fe(u).map(T=>e.jsx(z,{value:T},T))],rt=[e.jsx(z,{value:"",children:t("unsigned")},"unsigned"),...Fe(r).map(T=>e.jsx(z,{value:T},T))],Ne=[e.jsx(z,{value:"",children:t("common:choose")},"empty"),...Fe(l).map(T=>e.jsx(z,{value:T},T))],ct=[e.jsx(z,{value:"any",children:t("common:any")},"any"),e.jsx(z,{value:"none",children:t("common:none")},"none"),...Fe(o).map(T=>e.jsx(z,{value:T},T))],dt=[e.jsx(z,{value:"any",children:t("common:any")},"any"),...Fe(u).map(T=>e.jsx(z,{value:T},T))],$e=[e.jsx(z,{value:"any",children:t("common:any")},"any"),...Fe(l).map(T=>e.jsx(z,{value:T},T))],We=[e.jsx(z,{value:"",children:t("common:choose")},"empty"),...Fe(r).map(T=>e.jsx(z,{value:T},T))],ue=["not required","request or request_uri","request only","request_uri only"].map(T=>e.jsx(z,{value:T,children:t(`requestObject.${T}`)},T));return e.jsxs(ce,{role:"manage-clients",fineGrainedAccess:i,isHorizontal:!0,children:[e.jsx(en,{}),e.jsx(b,{label:t("accessTokenSignatureAlgorithm"),fieldId:"accessTokenSignatureAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:accessTokenSignatureAlgorithm"),fieldLabelId:"clients:accessTokenSignatureAlgorithm"}),children:e.jsx(N,{name:O("attributes.access.token.signed.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"accessTokenSignatureAlgorithm",variant:G.single,onToggle:h,isOpen:m,onSelect:(re,W)=>{T.onChange(W),h(!1)},selections:T.value,children:te})})}),e.jsx(b,{label:t("idTokenSignatureAlgorithm"),fieldId:"kc-id-token-signature",labelIcon:e.jsx(C,{helpText:t("clients-help:idTokenSignatureAlgorithm"),fieldLabelId:"clients:idTokenSignatureAlgorithm"}),children:e.jsx(N,{name:O("attributes.id.token.signed.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"idTokenSignatureAlgorithm",variant:G.single,onToggle:d,isOpen:p,onSelect:(re,W)=>{T.onChange(W),d(!1)},selections:T.value,children:te})})}),e.jsx(b,{label:t("idTokenEncryptionKeyManagementAlgorithm"),fieldId:"idTokenEncryptionKeyManagementAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:idTokenEncryptionKeyManagementAlgorithm"),fieldLabelId:"clients:idTokenEncryptionKeyManagementAlgorithm"}),children:e.jsx(N,{name:O("attributes.id.token.encrypted.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"idTokenEncryptionKeyManagementAlgorithm",variant:G.single,onToggle:j,isOpen:x,onSelect:(re,W)=>{T.onChange(W),j(!1)},selections:T.value,children:ke})})}),e.jsx(b,{label:t("idTokenEncryptionContentEncryptionAlgorithm"),fieldId:"idTokenEncryptionContentEncryptionAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:idTokenEncryptionContentEncryptionAlgorithm"),fieldLabelId:"clients:idTokenEncryptionContentEncryptionAlgorithm"}),children:e.jsx(N,{name:O("attributes.id.token.encrypted.response.enc"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"idTokenEncryptionContentEncryptionAlgorithm",variant:G.single,onToggle:y,isOpen:S,onSelect:(re,W)=>{T.onChange(W),y(!1)},selections:T.value,children:Ne})})}),e.jsx(b,{label:t("userInfoSignedResponseAlgorithm"),fieldId:"userInfoSignedResponseAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:userInfoSignedResponseAlgorithm"),fieldLabelId:"clients:userInfoSignedResponseAlgorithm"}),children:e.jsx(N,{name:O("attributes.user.info.response.signature.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"userInfoSignedResponseAlgorithm",variant:G.single,onToggle:M,isOpen:g,onSelect:(re,W)=>{T.onChange(W),M(!1)},selections:T.value,children:rt})})}),e.jsx(b,{label:t("userInfoResponseEncryptionKeyManagementAlgorithm"),fieldId:"userInfoResponseEncryptionKeyManagementAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:userInfoResponseEncryptionKeyManagementAlgorithm"),fieldLabelId:"clients:userInfoResponseEncryptionKeyManagementAlgorithm"}),children:e.jsx(N,{name:O("attributes.user.info.encrypted.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"userInfoResponseEncryptionKeyManagementAlgorithm",variant:G.single,onToggle:le,isOpen:K,onSelect:(re,W)=>{T.onChange(W),le(!1)},selections:T.value,children:ke})})}),e.jsx(b,{label:t("userInfoResponseEncryptionContentEncryptionAlgorithm"),fieldId:"userInfoResponseEncryptionContentEncryptionAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:userInfoResponseEncryptionContentEncryptionAlgorithm"),fieldLabelId:"clients:userInfoResponseEncryptionContentEncryptionAlgorithm"}),children:e.jsx(N,{name:O("attributes.user.info.encrypted.response.enc"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"userInfoResponseEncryptionContentEncryptionAlgorithm",variant:G.single,onToggle:ee,isOpen:Se,onSelect:(re,W)=>{T.onChange(W),ee(!1)},selections:T.value,children:Ne})})}),e.jsx(b,{label:t("requestObjectSignatureAlgorithm"),fieldId:"requestObjectSignatureAlgorithm",labelIcon:e.jsx(C,{helpText:t("clients-help:requestObjectSignatureAlgorithm"),fieldLabelId:"clients:requestObjectSignatureAlgorithm"}),children:e.jsx(N,{name:O("attributes.request.object.signature.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"requestObjectSignatureAlgorithm",variant:G.single,onToggle:Q,isOpen:U,onSelect:(re,W)=>{T.onChange(W),Q(!1)},selections:T.value,children:ct})})}),e.jsx(b,{label:t("requestObjectEncryption"),fieldId:"requestObjectEncryption",labelIcon:e.jsx(C,{helpText:t("clients-help:requestObjectEncryption"),fieldLabelId:"clients:requestObjectEncryption"}),children:e.jsx(N,{name:O("attributes.request.object.encryption.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"requestObjectEncryption",variant:G.single,onToggle:w,isOpen:H,onSelect:(re,W)=>{T.onChange(W),w(!1)},selections:T.value,children:dt})})}),e.jsx(b,{label:t("requestObjectEncoding"),fieldId:"requestObjectEncoding",labelIcon:e.jsx(C,{helpText:t("clients-help:requestObjectEncoding"),fieldLabelId:"clients:requestObjectEncoding"}),children:e.jsx(N,{name:O("attributes.request.object.encryption.enc"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"requestObjectEncoding",variant:G.single,onToggle:f,isOpen:I,onSelect:(re,W)=>{T.onChange(W),f(!1)},selections:T.value,children:$e})})}),e.jsx(b,{label:t("requestObjectRequired"),fieldId:"requestObjectRequired",labelIcon:e.jsx(C,{helpText:t("clients-help:requestObjectRequired"),fieldLabelId:"clients:requestObjectRequired"}),children:e.jsx(N,{name:O("attributes.request.object.required"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"requestObjectRequired",variant:G.single,onToggle:E,isOpen:R,onSelect:(re,W)=>{T.onChange(W),E(!1)},selections:T.value,children:ue})})}),e.jsx(b,{label:t("validRequestURIs"),fieldId:"validRequestURIs",labelIcon:e.jsx(C,{helpText:t("clients-help:validRequestURIs"),fieldLabelId:"clients:validRequestURIs"}),children:e.jsx(Fs,{name:O("attributes.request.uris"),"aria-label":t("validRequestURIs"),addButtonLabel:"clients:addRequestUri",stringify:!0})}),e.jsx(b,{label:t("authorizationSignedResponseAlg"),fieldId:"authorizationSignedResponseAlg",labelIcon:e.jsx(C,{helpText:t("clients-help:authorizationSignedResponseAlg"),fieldLabelId:"clients:authorizationSignedResponseAlg"}),children:e.jsx(N,{name:O("attributes.authorization.signed.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"authorizationSignedResponseAlg",variant:G.single,onToggle:q,isOpen:v,onSelect:(re,W)=>{T.onChange(W),q(!1)},selections:T.value,children:We})})}),e.jsx(b,{label:t("authorizationEncryptedResponseAlg"),fieldId:"authorizationEncryptedResponseAlg",labelIcon:e.jsx(C,{helpText:t("clients-help:authorizationEncryptedResponseAlg"),fieldLabelId:"clients:authorizationEncryptedResponseAlg"}),children:e.jsx(N,{name:O("attributes.authorization.encrypted.response.alg"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"authorizationEncryptedResponseAlg",variant:G.single,onToggle:L,isOpen:_,onSelect:(re,W)=>{T.onChange(W),L(!1)},selections:T.value,children:ke})})}),e.jsx(b,{label:t("authorizationEncryptedResponseEnc"),fieldId:"authorizationEncryptedResponseEnc",labelIcon:e.jsx(C,{helpText:t("clients-help:authorizationEncryptedResponseEnc"),fieldLabelId:"clients:authorizationEncryptedResponseEnc"}),children:e.jsx(N,{name:O("attributes.authorization.encrypted.response.enc"),defaultValue:"",control:$,render:({field:T})=>e.jsx(J,{toggleId:"authorizationEncryptedResponseEnc",variant:G.single,onToggle:D,isOpen:V,onSelect:(re,W)=>{T.onChange(W),D(!1)},selections:T.value,children:Ne})})}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"secondary",id:"fineGrainSave",onClick:s,children:t("common:save")}),e.jsx(P,{id:"fineGrainRevert",variant:"link",onClick:n,children:t("common:revert")})]})]})},ka=({save:s,reset:n})=>{const{t:i}=k("clients");return e.jsxs(ce,{role:"manage-realm",isHorizontal:!0,children:[e.jsx(en,{}),e.jsx(Ae,{name:"attributes.saml_assertion_consumer_url_post",label:i("assertionConsumerServicePostBindingURL"),labelIcon:i("clients-help:assertionConsumerServicePostBindingURL"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_assertion_consumer_url_redirect",label:i("assertionConsumerServiceRedirectBindingURL"),labelIcon:i("clients-help:assertionConsumerServiceRedirectBindingURL"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_single_logout_service_url_post",label:i("logoutServicePostBindingURL"),labelIcon:i("clients-help:logoutServicePostBindingURL"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_single_logout_service_url_redirect",label:i("logoutServiceRedirectBindingURL"),labelIcon:i("clients-help:logoutServiceRedirectBindingURL"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_single_logout_service_url_soap",label:i("logoutServiceSoapBindingUrl"),labelIcon:i("clients-help:logoutServiceSoapBindingUrl"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_single_logout_service_url_artifact",label:i("logoutServiceArtifactBindingUrl"),labelIcon:i("clients-help:logoutServiceArtifactBindingUrl"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_artifact_binding_url",label:i("artifactBindingUrl"),labelIcon:i("clients-help:artifactBindingUrl"),type:"url"}),e.jsx(Ae,{name:"attributes.saml_artifact_resolution_service_url",label:i("artifactResolutionService"),labelIcon:i("clients-help:artifactResolutionService"),type:"url"}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"tertiary",onClick:s,"data-testid":"fineGrainSave",children:i("common:save")}),e.jsx(P,{variant:"link",onClick:n,"data-testid":"fineGrainRevert",children:i("common:revert")})]})]})},Ra=({save:s,reset:n,hasConfigureAccess:i})=>{const{t}=k("clients"),{control:a}=X();return e.jsxs(ce,{role:"manage-clients",fineGrainedAccess:i,isHorizontal:!0,children:[e.jsx(b,{label:t("excludeSessionStateFromAuthenticationResponse"),fieldId:"excludeSessionStateFromAuthenticationResponse",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:t("clients-help:excludeSessionStateFromAuthenticationResponse"),fieldLabelId:"clients:excludeSessionStateFromAuthenticationResponse"}),children:e.jsx(N,{name:O("attributes.exclude.session.state.from.auth.response"),defaultValue:"",control:a,render:({field:o})=>e.jsx(de,{id:"excludeSessionStateFromAuthenticationResponse-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:o.value==="true",onChange:l=>o.onChange(l.toString()),"aria-label":t("excludeSessionStateFromAuthenticationResponse")})})}),e.jsx(b,{label:t("useRefreshTokens"),fieldId:"useRefreshTokens",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:t("clients-help:useRefreshTokens"),fieldLabelId:"clients:useRefreshTokens"}),children:e.jsx(N,{name:O("attributes.use.refresh.tokens"),defaultValue:"true",control:a,render:({field:o})=>e.jsx(de,{id:"useRefreshTokens",label:t("common:on"),labelOff:t("common:off"),isChecked:o.value==="true",onChange:l=>o.onChange(l.toString()),"aria-label":t("useRefreshTokens")})})}),e.jsx(b,{label:t("useRefreshTokenForClientCredentialsGrant"),fieldId:"useRefreshTokenForClientCredentialsGrant",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:t("clients-help:useRefreshTokenForClientCredentialsGrant"),fieldLabelId:"clients:useRefreshTokenForClientCredentialsGrant"}),children:e.jsx(N,{name:O("attributes.client_credentials.use_refresh_token"),defaultValue:"false",control:a,render:({field:o})=>e.jsx(de,{id:"useRefreshTokenForClientCredentialsGrant",label:t("common:on"),labelOff:t("common:off"),isChecked:o.value==="true",onChange:l=>o.onChange(l.toString()),"aria-label":t("useRefreshTokenForClientCredentialsGrant")})})}),e.jsx(b,{label:t("useLowerCaseBearerType"),fieldId:"useLowerCaseBearerType",hasNoPaddingTop:!0,labelIcon:e.jsx(C,{helpText:t("clients-help:useLowerCaseBearerType"),fieldLabelId:"clients:useLowerCaseBearerType"}),children:e.jsx(N,{name:O("attributes.token.response.type.bearer.lower-case"),defaultValue:"false",control:a,render:({field:o})=>e.jsx(de,{id:"useLowerCaseBearerType",label:t("common:on"),labelOff:t("common:off"),isChecked:o.value==="true",onChange:l=>o.onChange(l.toString()),"aria-label":t("useLowerCaseBearerType")})})}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"secondary",onClick:s,"data-testid":"OIDCCompatabilitySave",children:t("common:save")}),e.jsx(P,{variant:"link",onClick:n,"data-testid":"OIDCCompatabilityRevert",children:t("common:revert")})]})]})},Aa=({save:s,client:{id:n,adminUrl:i,access:t}})=>{const a="notBefore",o=c.useRef(),{t:l}=k("clients"),{realm:u}=he(),{addAlert:r}=oe(),m=Wt(),{getValues:h,setValue:p,register:d}=X(),x=(y,g)=>{p(a,y),s({messageKey:g})};c.useEffect(()=>{d(a)},[d]);const j=()=>{const y=h(a);return y>0?m(new Date(y*1e3),Ks):l("common:none")},S=async()=>{const y=await A.clients.pushRevocation({id:n});tn(y,"notBeforePush",r,l)};return e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:e.jsxs(zs,{i18nKey:"clients-help:notBeforeIntro",children:["In order to successfully push setup url on",e.jsx(ge,{to:ws({realm:u,clientId:n,tab:"settings"}),children:l("settings")}),"tab"]})}),e.jsxs(ce,{role:"manage-clients",fineGrainedAccess:t?.configure,isHorizontal:!0,children:[e.jsx(b,{label:l("notBefore"),fieldId:"kc-not-before",labelIcon:e.jsx(C,{helpText:l("clients-help:notBefore"),fieldLabelId:"clients:notBefore"}),children:e.jsxs(Vt,{children:[e.jsx(pe,{type:"text",id:"kc-not-before",name:"notBefore",isReadOnly:!0,value:j()}),e.jsx(P,{id:"setToNow",variant:"control",onClick:()=>{x(Date.now()/1e3,"notBeforeSetToNow")},children:l("setToNow")}),e.jsx(P,{id:"clear",variant:"control",onClick:()=>{x(0,"notBeforeNowClear")},children:l("clear")})]})}),e.jsxs(Ie,{children:[!i&&e.jsx(qt,{reference:o,content:l("clients-help:notBeforeTooltip")}),e.jsx(P,{id:"push",variant:"secondary",onClick:S,isAriaDisabled:!i,ref:o,children:l("push")})]})]})]})},tn=(s,n,i,t)=>{const a=s.successRequests?.length||0,o=s.failedRequests?.length||0;a===0&&o===0?i(t("noAdminUrlSet"),Y.warning):o>0?(i(t(n+"Success",{successNodes:s.successRequests}),Y.success),i(t(n+"Fail",{failedNodes:s.failedRequests}),Y.danger)):i(t(n+"Success",{successNodes:s.successRequests}),Y.success)},Ea=({save:s,client:n})=>{const{t:i}=k("clients"),t="openid-connect",{setValue:a}=X(),{publicClient:o,attributes:l,protocol:u,authenticationFlowBindingOverrides:r}=n,m=h=>{for(const p of h)a(O(`attributes.${p}`),l?.[p]||"")};return e.jsx(xe,{variant:"light",className:"pf-u-py-0",children:e.jsx(Ns,{sections:[{title:i("revocation"),isHidden:u!==t,panel:e.jsx(Aa,{client:n,save:s})},{title:i("clustering"),isHidden:!o,panel:e.jsx(Ta,{client:n,save:s})},{title:i("fineGrainOpenIdConnectConfiguration"),isHidden:u!==t,panel:e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:i("clients-help:fineGrainOpenIdConnectConfiguration")}),e.jsx(Ia,{save:s,reset:()=>{m(["logoUri","policyUri","tosUri","access.token.signed.response.alg","id.token.signed.response.alg","id.token.encrypted.response.alg","id.token.encrypted.response.enc","user.info.response.signature.alg","user.info.encrypted.response.alg","user.info.encrypted.response.enc","request.object.signature.alg","request.object.encryption.alg","request.object.encryption.enc","request.object.required","request.uris","authorization.signed.response.alg","authorization.encrypted.response.alg","authorization.encrypted.response.enc"])}})]})},{title:i("openIdConnectCompatibilityModes"),isHidden:u!==t,panel:e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:i("clients-help:openIdConnectCompatibilityModes")}),e.jsx(Ra,{save:()=>s(),reset:()=>m(["exclude.session.state.from.auth.response","use.refresh.tokens","client_credentials.use_refresh_token","token.response.type.bearer.lower-case"])})]})},{title:i("fineGrainSamlEndpointConfig"),isHidden:u===t,panel:e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:i("clients-help:fineGrainSamlEndpointConfig")}),e.jsx(ka,{save:()=>s(),reset:()=>m(["logoUri","policyUri","tosUri","saml_assertion_consumer_url_post","saml_assertion_consumer_url_redirect","saml_single_logout_service_url_post","saml_single_logout_service_url_redirect","saml_single_logout_service_url_artifact","saml_artifact_binding_url","saml_artifact_resolution_service_url"])})]})},{title:i("advancedSettings"),panel:e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:i("clients-help:advancedSettings"+Tt(u||""))}),e.jsx(ba,{protocol:u,save:()=>s(),reset:()=>{m(["saml.assertion.lifespan","access.token.lifespan","tls.client.certificate.bound.access.tokens","pkce.code.challenge.method"])}})]})},{title:i("authenticationOverrides"),panel:e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"pf-u-pb-lg",children:i("clients-help:authenticationOverrides")}),e.jsx(Sa,{protocol:u,save:()=>s(),reset:()=>{a("authenticationFlowBindingOverrides.browser",r?.browser),a("authenticationFlowBindingOverrides.direct_grant",r?.direct_grant)}})]})}],borders:!0})})},wa=({client:s})=>{const{t:n}=k("sessions"),i=async(t,a)=>{const o=u=>r=>r.map(m=>({type:u,...m}));return(await Promise.all([A.clients.listSessions({id:s.id,first:t,max:a}).then(o(n("sessions:sessionsType.regularSSO"))),A.clients.listOfflineSessions({id:s.id,first:t,max:a}).then(o(n("sessions:sessionsType.offline")))])).flat()};return e.jsx(xe,{variant:"light",className:"pf-u-p-0",children:e.jsx(Mn,{loader:i,hiddenColumns:["clients"],emptyInstructions:n("noSessionsForClient")})})},_e=({name:s,label:n})=>{const{t:i}=k("clients"),{control:t}=X();return e.jsx(b,{hasNoPaddingTop:!0,label:i(n),fieldId:n,labelIcon:e.jsx(C,{helpText:i(`clients-help:${n}`),fieldLabelId:`clients:${n}`}),children:e.jsx(N,{name:s,defaultValue:"false",control:t,render:({field:a})=>e.jsx(de,{id:s,"data-testid":n,label:i("common:on"),labelOff:i("common:off"),isChecked:a.value==="true",onChange:o=>a.onChange(o.toString()),"aria-label":i(n)})})})},Oa=()=>{const{t:s}=k("clients"),{control:n}=X(),[i,t]=c.useState(!1);return e.jsxs(ce,{isHorizontal:!0,role:"manage-clients",className:"keycloak__capability-config__form",children:[e.jsx(b,{label:s("nameIdFormat"),fieldId:"nameIdFormat",labelIcon:e.jsx(C,{helpText:s("clients-help:nameIdFormat"),fieldLabelId:"clients:nameIdFormat"}),children:e.jsx(N,{name:"attributes.saml_name_id_format",defaultValue:"username",control:n,render:({field:a})=>e.jsx(J,{toggleId:"samlNameIdFormat",onToggle:t,onSelect:(o,l)=>{a.onChange(l.toString()),t(!1)},selections:a.value,variant:G.single,"aria-label":s("nameIdFormat"),isOpen:i,children:["username","email","transient","persistent"].map(o=>e.jsx(z,{selected:o===a.value,value:o},o))})})}),e.jsx(_e,{name:"attributes.saml_force_name_id_format",label:"forceNameIdFormat"}),e.jsx(_e,{name:O("attributes.saml.force.post.binding"),label:"forcePostBinding"}),e.jsx(_e,{name:O("attributes.saml.artifact.binding"),label:"forceArtifactBinding"}),e.jsx(_e,{name:O("attributes.saml.authnstatement"),label:"includeAuthnStatement"}),e.jsx(_e,{name:O("attributes.saml.onetimeuse.condition"),label:"includeOneTimeUseCondition"}),e.jsx(_e,{name:O("attributes.saml.server.signature.keyinfo.ext"),label:"optimizeLookup"}),e.jsx(_e,{name:O("attributes.saml.allow.ecp.flow"),label:"allowEcpFlow"})]})},gs=["RSA_SHA1","RSA_SHA256","RSA_SHA256_MGF1","RSA_SHA512","RSA_SHA512_MGF1","DSA_SHA1"],js=["NONE","KEY_ID","CERT_SUBJECT"],Pt=[{name:"EXCLUSIVE",value:"http://www.w3.org/2001/10/xml-exc-c14n#"},{name:"EXCLUSIVE_WITH_COMMENTS",value:"http://www.w3.org/2001/10/xml-exc-c14n#WithComments"},{name:"INCLUSIVE",value:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"},{name:"INCLUSIVE_WITH_COMMENTS",value:"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"}],Pa=()=>{const{t:s}=k("clients"),[n,i]=c.useState(!1),[t,a]=c.useState(!1),[o,l]=c.useState(!1),{control:u,watch:r}=X(),m=r(O("attributes.saml.server.signature")),h=r(O("attributes.saml.assertion.signature"));return e.jsxs(ce,{isHorizontal:!0,role:"manage-clients",className:"keycloak__capability-config__form",children:[e.jsx(_e,{name:O("attributes.saml.server.signature"),label:"signDocuments"}),e.jsx(_e,{name:O("attributes.saml.assertion.signature"),label:"signAssertions"}),(m==="true"||h==="true")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{label:s("signatureAlgorithm"),fieldId:"signatureAlgorithm",labelIcon:e.jsx(C,{helpText:s("clients-help:signatureAlgorithm"),fieldLabelId:"clients:signatureAlgorithm"}),children:e.jsx(N,{name:O("attributes.saml.signature.algorithm"),defaultValue:gs[0],control:u,render:({field:p})=>e.jsx(J,{toggleId:"signatureAlgorithm",onToggle:i,onSelect:(d,x)=>{p.onChange(x.toString()),i(!1)},selections:p.value,variant:G.single,"aria-label":s("signatureAlgorithm"),isOpen:n,children:gs.map(d=>e.jsx(z,{selected:d===p.value,value:d},d))})})}),e.jsx(b,{label:s("signatureKeyName"),fieldId:"signatureKeyName",labelIcon:e.jsx(C,{helpText:s("clients-help:signatureKeyName"),fieldLabelId:"clients:signatureKeyName"}),children:e.jsx(N,{name:O("attributes.saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer"),defaultValue:js[0],control:u,render:({field:p})=>e.jsx(J,{toggleId:"signatureKeyName",onToggle:a,onSelect:(d,x)=>{p.onChange(x.toString()),a(!1)},selections:p.value,variant:G.single,"aria-label":s("signatureKeyName"),isOpen:t,children:js.map(d=>e.jsx(z,{selected:d===p.value,value:d},d))})})}),e.jsx(b,{label:s("canonicalization"),fieldId:"canonicalization",labelIcon:e.jsx(C,{helpText:s("clients-help:canonicalization"),fieldLabelId:"clients:canonicalization"}),children:e.jsx(N,{name:"attributes.saml_signature_canonicalization_method",defaultValue:Pt[0].value,control:u,render:({field:p})=>e.jsx(J,{toggleId:"canonicalization",onToggle:l,onSelect:(d,x)=>{p.onChange(x.toString()),l(!1)},selections:Pt.find(d=>d.value===p.value)?.name,variant:G.single,"aria-label":s("canonicalization"),isOpen:o,children:Pt.map(d=>e.jsx(z,{selected:d.value===p.value,value:d.value,children:d.name},d.name))})})})]})]})},_a=({client:s,save:n,reset:i})=>{const{t}=k("clients"),{register:a,watch:o}=X(),{hasAccess:l}=Pe(),u=l("manage-clients")||s.access?.configure,r=o("protocol");return e.jsxs(ce,{isHorizontal:!0,fineGrainedAccess:s.access?.configure,role:"manage-clients",children:[!s.bearerOnly&&e.jsx(qn,{protocol:r}),r!=="saml"&&e.jsx(b,{label:t("adminURL"),fieldId:"kc-admin-url",labelIcon:e.jsx(C,{helpText:t("clients-help:adminURL"),fieldLabelId:"clients:adminURL"}),children:e.jsx(pe,{id:"kc-admin-url",type:"url",...a("adminUrl")})}),s.bearerOnly&&e.jsx(Rt,{name:"settings",save:n,reset:i,isActive:!u})]})},La=({access:s})=>{const{t:n}=k("clients"),{register:i,control:t,watch:a}=X(),[o,l]=c.useState(!1),u=He().themes.login,r=a("consentRequired"),m=a(O("attributes.display.on.consent.screen"));return e.jsxs(ce,{isHorizontal:!0,fineGrainedAccess:s,role:"manage-clients",children:[e.jsx(b,{label:n("loginTheme"),labelIcon:e.jsx(C,{helpText:n("clients-help:loginTheme"),fieldLabelId:"clients:loginTheme"}),fieldId:"loginTheme",children:e.jsx(N,{name:"attributes.login_theme",defaultValue:"",control:t,render:({field:h})=>e.jsx(J,{toggleId:"loginTheme",onToggle:l,onSelect:(p,d)=>{h.onChange(d.toString()),l(!1)},selections:h.value||n("common:choose"),variant:G.single,"aria-label":n("loginTheme"),isOpen:o,children:[e.jsx(z,{value:"",children:n("common:choose")},"empty"),...u.map(p=>e.jsx(z,{selected:p.name===h.value,value:p.name},p.name))]})})}),e.jsx(b,{label:n("consentRequired"),labelIcon:e.jsx(C,{helpText:n("clients-help:consentRequired"),fieldLabelId:"clients:consentRequired"}),fieldId:"kc-consent",hasNoPaddingTop:!0,children:e.jsx(N,{name:"consentRequired",defaultValue:!1,control:t,render:({field:h})=>e.jsx(de,{id:"kc-consent-switch",label:n("common:on"),labelOff:n("common:off"),isChecked:h.value,onChange:h.onChange,"aria-label":n("consentRequired")})})}),e.jsx(b,{label:n("displayOnClient"),labelIcon:e.jsx(C,{helpText:n("clients-help:displayOnClient"),fieldLabelId:"clients:displayOnClient"}),fieldId:"kc-display-on-client",hasNoPaddingTop:!0,children:e.jsx(N,{name:O("attributes.display.on.consent.screen"),defaultValue:!1,control:t,render:({field:h})=>e.jsx(de,{id:"kc-display-on-client-switch",label:n("common:on"),labelOff:n("common:off"),isChecked:h.value==="true",onChange:p=>h.onChange(""+p),isDisabled:!r,"aria-label":n("displayOnClient")})})}),e.jsx(b,{label:n("consentScreenText"),labelIcon:e.jsx(C,{helpText:n("clients-help:consentScreenText"),fieldLabelId:"clients:consentScreenText"}),fieldId:"kc-consent-screen-text",children:e.jsx(at,{id:"kc-consent-screen-text",...i(O("attributes.consent.screen.text")),isDisabled:!(r&&m==="true")})})]})},fs=(s,n)=>(s?.startsWith("https://")||s?.startsWith("http://"))&&!s.includes("*")||s===""||n,Da=({save:s,reset:n,client:{access:i}})=>{const{t}=k("clients"),{register:a,control:o,watch:l,formState:{errors:u}}=X(),{hasAccess:r}=Pe(),m=r("manage-clients")||i?.configure,h=l("protocol"),p=l("frontchannelLogout");return e.jsxs(ce,{isHorizontal:!0,fineGrainedAccess:i?.configure,role:"manage-clients",children:[e.jsx(b,{label:t("frontchannelLogout"),labelIcon:e.jsx(C,{helpText:t("clients-help:frontchannelLogout"),fieldLabelId:"clients:frontchannelLogout"}),fieldId:"kc-frontchannelLogout",hasNoPaddingTop:!0,children:e.jsx(N,{name:"frontchannelLogout",defaultValue:!0,control:o,render:({field:d})=>e.jsx(de,{id:"kc-frontchannelLogout-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:d.value,onChange:d.onChange,"aria-label":t("frontchannelLogout")})})}),h==="openid-connect"&&p&&e.jsx(b,{label:t("frontchannelLogoutUrl"),fieldId:"frontchannelLogoutUrl",labelIcon:e.jsx(C,{helpText:t("clients-help:frontchannelLogoutUrl"),fieldLabelId:"clients:frontchannelLogoutUrl"}),helperTextInvalid:u.attributes?.[Ke("frontchannel.logout.url")]?.message,validated:u.attributes?.[Ke("frontchannel.logout.url")]?.message?ve.error:ve.default,children:e.jsx(pe,{id:"frontchannelLogoutUrl",type:"url",...a(O("attributes.frontchannel.logout.url"),{validate:d=>fs(d,t("frontchannelUrlInvalid").toString())}),validated:u.attributes?.[Ke("frontchannel.logout.url")]?.message?ve.error:ve.default})}),h==="openid-connect"&&e.jsxs(e.Fragment,{children:[e.jsx(b,{label:t("backchannelLogoutUrl"),fieldId:"backchannelLogoutUrl",labelIcon:e.jsx(C,{helpText:t("clients-help:backchannelLogoutUrl"),fieldLabelId:"clients:backchannelLogoutUrl"}),helperTextInvalid:u.attributes?.[Ke("backchannel.logout.url")]?.message,validated:u.attributes?.[Ke("backchannel.logout.url")]?.message?ve.error:ve.default,children:e.jsx(pe,{id:"backchannelLogoutUrl",type:"url",...a(O("attributes.backchannel.logout.url"),{validate:d=>fs(d,t("backchannelUrlInvalid").toString())}),validated:u.attributes?.[Ke("backchannel.logout.url")]?.message?ve.error:ve.default})}),e.jsx(b,{label:t("backchannelLogoutSessionRequired"),labelIcon:e.jsx(C,{helpText:t("clients-help:backchannelLogoutSessionRequired"),fieldLabelId:"clients:backchannelLogoutSessionRequired"}),fieldId:"backchannelLogoutSessionRequired",hasNoPaddingTop:!0,children:e.jsx(N,{name:O("attributes.backchannel.logout.session.required"),defaultValue:"true",control:o,render:({field:d})=>e.jsx(de,{id:"backchannelLogoutSessionRequired",label:t("common:on"),labelOff:t("common:off"),isChecked:d.value==="true",onChange:x=>d.onChange(x.toString()),"aria-label":t("backchannelLogoutSessionRequired")})})}),e.jsx(b,{label:t("backchannelLogoutRevokeOfflineSessions"),labelIcon:e.jsx(C,{helpText:t("clients-help:backchannelLogoutRevokeOfflineSessions"),fieldLabelId:"clients:backchannelLogoutRevokeOfflineSessions"}),fieldId:"backchannelLogoutRevokeOfflineSessions",hasNoPaddingTop:!0,children:e.jsx(N,{name:O("attributes.backchannel.logout.revoke.offline.tokens"),defaultValue:"false",control:o,render:({field:d})=>e.jsx(de,{id:"backchannelLogoutRevokeOfflineSessions",label:t("common:on"),labelOff:t("common:off"),isChecked:d.value==="true",onChange:x=>d.onChange(x.toString()),"aria-label":t("backchannelLogoutRevokeOfflineSessions")})})})]}),e.jsx(Rt,{name:"settings",save:s,reset:n,isActive:m})]})},Na=s=>{const{t:n}=k("clients"),{watch:i}=X(),t=i("protocol"),{client:a}=s;return e.jsx(Ns,{className:"pf-u-px-lg pf-u-pb-lg",sections:[{title:n("generalSettings"),panel:e.jsx(ye,{isHorizontal:!0,children:e.jsx(zn,{protocol:a.protocol,hasConfigureAccess:a.access?.configure})})},{title:n("accessSettings"),panel:e.jsx(_a,{...s})},{title:n("samlCapabilityConfig"),isHidden:t!=="saml"||a.bearerOnly,panel:e.jsx(Oa,{})},{title:n("signatureAndEncryption"),isHidden:t!=="saml"||a.bearerOnly,panel:e.jsx(Pa,{})},{title:n("capabilityConfig"),isHidden:t!=="openid-connect"||a.bearerOnly,panel:e.jsx(Vn,{})},{title:n("loginSettings"),isHidden:a.bearerOnly,panel:e.jsx(La,{access:a.access?.configure})},{title:n("logoutSettings"),isHidden:a.bearerOnly,panel:e.jsx(Da,{...s})}]})};const Fa=({name:s,rowIndex:n,attribute:i,selectableValues:t,resources:a})=>{const{t:o}=k("common"),{control:l,register:u,getValues:r}=X(),[m,h]=c.useState([!1]),p=(S,y)=>{const g=[...m];g[S]=y,h(g)},d=c.useMemo(()=>{let S=[];return t&&(S=Bs.find(y=>y.key===r().context?.[n]?.key)?.values),S},[r]),x=()=>{const S=a?.find(y=>y.name===r().resources?.[n]?.key)?.scopes;if(d?.length&&!a)return d.map(y=>e.jsx(z,{value:y.key,children:y.name},y.key));if(S?.length)return S.map(y=>e.jsx(z,{value:y.name,children:y.name},y.name))},j=S=>Wn(S).replace(/\W/g,"");return e.jsx(F,{children:a||d?.length?e.jsx(N,{name:`${s}.${n}.value`,defaultValue:[],control:l,render:({field:S})=>e.jsx(J,{toggleId:`${i.id}-value`,className:"kc-attribute-value-selectable",name:`${s}.${n}.value`,chipGroupProps:{numChips:1,expandedText:o("common:hide"),collapsedText:o("common:showRemaining")},onToggle:y=>p(n,y),isOpen:m[n],variant:G.typeahead,typeAheadAriaLabel:o("clients:selectOrTypeAKey"),placeholderText:o("clients:selectOrTypeAKey"),selections:S.value,onSelect:(y,g)=>{S.onChange(g),p(n,!1)},children:x()})}):e.jsx(pe,{id:`${j(i.key)}-value`,className:"value-input",defaultValue:i.value,"data-testid":"attribute-value-input","aria-label":o("common:value"),...u(`${s}.${n}.value`)})})},ys=({name:s,selectableValues:n,resources:i})=>{const{t}=k("common"),{control:a,watch:o}=X(),{fields:l,append:u,remove:r}=un({control:a,name:s}),[m,h]=c.useState([!1]),p=(x,j)=>{const S=[...m];S[x]=j,h(S)};c.useEffect(()=>{l.length||u({key:"",value:""},{shouldFocus:!1})},[l]);const d=o(`${s}.${l.length-1}.value`,"");return e.jsxs(Ve,{className:"kc-attributes__table","aria-label":"Role attribute keys and values",variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{width:40,children:t("key")}),e.jsx(B,{width:40,children:t("value")})]})}),e.jsxs(Be,{children:[l.map((x,j)=>e.jsxs(ae,{"data-testid":"attribute-row",children:[e.jsx(F,{children:e.jsx(N,{name:`${s}.${j}.key`,defaultValue:"",control:a,render:({field:S})=>e.jsx(J,{toggleId:`${s}.${j}.key`,className:"kc-attribute-key-selectable",name:`${s}.${j}.key`,onToggle:y=>p(j,y),isOpen:m[j],variant:G.typeahead,typeAheadAriaLabel:t("clients:selectOrTypeAKey"),placeholderText:t("clients:selectOrTypeAKey"),selections:S.value,onSelect:(y,g)=>{S.onChange(g.toString()),p(j,!1)},children:n?.map(y=>e.jsx(z,{selected:y.name===S.value,value:i?y.name:y.key,children:y.name},y.key))})})}),e.jsx(Fa,{name:s,attribute:x,rowIndex:j,selectableValues:n,resources:i}),e.jsx(F,{children:e.jsx(P,{id:`${s}-minus-button-${j}`,variant:"link",className:"kc-attributes__minus-icon",onClick:()=>r(j),"aria-label":t("common:remove"),children:e.jsx(Jn,{})})})]},x.id)),e.jsx(ae,{children:e.jsx(F,{children:e.jsx(P,{"aria-label":t("addAttribute"),id:`${s}-plus-icon`,variant:"link",className:"kc-attributes__plus-icon",onClick:()=>{u({key:"",value:""}),h([...m,!1])},icon:e.jsx(Us,{}),isDisabled:!d,"data-testid":"attribute-add-row",children:t("addAttribute")})})})]})]})},Ka=({data:s})=>{const{t:n}=k("clients"),[i,t]=be();return e.jsxs(e.Fragment,{children:[e.jsx(P,{"data-testid":"authorization-revert",onClick:t,variant:"secondary",children:n("showAuthData")}),e.jsx(ze,{variant:it.medium,isOpen:i,"aria-label":n("authData"),header:e.jsxs(Le,{children:[e.jsx(me,{component:Vs.h1,children:n("authData")}),e.jsx(me,{children:n("authDataDescription")})]}),onClose:t,actions:[e.jsx(P,{"data-testid":"cancel",id:"modal-cancel",onClick:t,children:n("common:cancel")},"cancel")],children:e.jsx(at,{readOnly:!0,rows:20,value:Je(s)})})]})},Ma=({idx:s,rowIndex:n,outerPolicy:i,resource:t})=>{const[a,o]=c.useState(!1),{t:l}=k("clients"),{realm:u}=he(),{clientId:r}=Ht();return e.jsxs(Be,{isExpanded:a,children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:n,isExpanded:a,onToggle:()=>o(m=>!m)}}),e.jsx(F,{"data-testid":`name-column-${t.resource}`,children:e.jsx(ge,{to:ft({realm:u,id:r,permissionType:i.policy?.type,permissionId:i.policy?.id}),children:i.policy?.name})}),e.jsx(F,{id:i.status?.toLowerCase(),children:l(i.status?.toLowerCase())}),e.jsx(F,{children:l(`${i.policy?.decisionStrategy?.toLowerCase()}`)}),e.jsx(F,{children:i.status===is.Permit?t.policies?.[n]?.scopes?.join(", "):"-"}),e.jsx(F,{children:i.status===is.Deny&&t.policies?.[n]?.scopes?.length?t.policies[n].scopes?.join(", "):"-"})]}),e.jsxs(ae,{isExpanded:a,children:[e.jsx(F,{}),e.jsx(F,{colSpan:5,children:a&&e.jsx(lt,{children:e.jsx(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:e.jsx(Le,{children:e.jsx(Xs,{children:i.associatedPolicies?.map(m=>e.jsxs(Zs,{children:[e.jsx(ge,{to:Bt({realm:u,id:r,policyType:m.policy?.type,policyId:m.policy?.id}),children:m.policy?.name}),l("votedToStatus",{status:pn(m.status)})]},"policyDetails"))})})})})})]},`child-${t.resource}`)]},s)},za=({rowIndex:s,resource:n,evaluateResults:i})=>{const[t,a]=c.useState(!1),{t:o}=k("clients");return e.jsxs(Be,{isExpanded:t,children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:s,isExpanded:t,onToggle:()=>a(l=>!l)}}),e.jsx(F,{"data-testid":`name-column-${n.resource}`,children:n.resource?.name}),e.jsx(F,{id:n.status?.toLowerCase(),children:o(`${n.status?.toLowerCase()}`)}),e.jsx(F,{children:n.allowedScopes?.length?n.allowedScopes.map(l=>l.name):"-"})]}),e.jsxs(ae,{isExpanded:t,children:[e.jsx(F,{}),e.jsx(F,{colSpan:5,children:e.jsx(lt,{children:t&&e.jsx(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:e.jsxs(Ve,{"aria-label":o("evaluationResults"),children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{"aria-hidden":"true"}),e.jsx(B,{children:o("permission")}),e.jsx(B,{children:o("results")}),e.jsx(B,{children:o("decisionStrategy")}),e.jsx(B,{children:o("grantedScopes")}),e.jsx(B,{children:o("deniedScopes")}),e.jsx(B,{"aria-hidden":"true"})]})}),Object.values(i[s].policies).map((l,u)=>e.jsx(Ma,{idx:u,rowIndex:s,outerPolicy:l,resource:n},u))]})})})})]},`child-${n.resource}`)]})};function Va(s,n){switch(n){case"STATUS_PERMITTED":return s.filter(({status:i})=>i==="PERMIT");case"STATUS_DENIED":return s.filter(({status:i})=>i==="DENY");default:return s}}const qa=({evaluateResult:s,refresh:n,back:i})=>{const{t}=k("clients"),[a,o]=be(),[l,u]=c.useState("ALL"),[r,m]=c.useState(""),[h,p]=c.useState(""),d=()=>{m(h)},x=g=>{g.key==="Enter"&&d()},j=c.useMemo(()=>Va(s.results,l).filter(({resource:g})=>g?.name?.includes(r)??!1),[s.results,l,r]),S=s.results.length===0,y=j.length===0;return e.jsxs(xe,{children:[e.jsx(Fn,{children:e.jsxs(Kn,{className:"providers-toolbar",children:[e.jsx(je,{children:e.jsxs(Vt,{children:[e.jsx(mn,{name:"inputGroupName",id:"inputGroupName",type:"search","aria-label":t("common:search"),placeholder:t("common:search"),onChange:p,onKeyDown:x}),e.jsx(P,{variant:fe.control,"aria-label":t("common:search"),onClick:()=>d(),children:e.jsx(hn,{})})]})}),e.jsx(je,{children:e.jsxs(J,{width:300,"data-testid":"filter-type-select",isOpen:a,className:"kc-filter-type-select",variant:G.single,onToggle:o,onSelect:(g,M)=>{u(M),o(),n()},selections:l,children:[e.jsx(z,{"data-testid":"all-results-option",value:"ALL",isPlaceholder:!0,children:t("allResults")}),e.jsx(z,{"data-testid":"result-permit-option",value:"STATUS_PERMITTED",children:t("resultPermit")}),e.jsx(z,{"data-testid":"result-deny-option",value:"STATUS_DENIED",children:t("resultDeny")})]})})]})}),!y&&e.jsxs(Ve,{"aria-label":t("evaluationResults"),children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{"aria-hidden":"true"}),e.jsx(B,{children:t("resource")}),e.jsx(B,{children:t("overallResults")}),e.jsx(B,{children:t("scopes")}),e.jsx(B,{"aria-hidden":"true"})]})}),j.map((g,M)=>e.jsx(za,{rowIndex:M,resource:g,evaluateResults:s.results},M))]}),(y||S)&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx(we,{isSearchVariant:!0,message:t("common:noSearchResults"),instructions:t("common:noSearchResultsInstructions")})]}),e.jsx(ye,{children:e.jsxs(Rt,{name:"authorization",children:[e.jsx(P,{"data-testid":"authorization-eval",id:"back-btn",onClick:i,children:t("common:back")})," ",e.jsx(P,{"data-testid":"authorization-reevaluate",id:"reevaluate-btn",variant:"secondary",onClick:n,children:t("clients:reevaluate")})," ",e.jsx(Ka,{data:s.rpt})]})})]})},Ba=s=>{const{hasAccess:n}=Pe();return n("view-users")?e.jsx(Ua,{...s}):e.jsx(xn,{permissionNeeded:"view-users"})},Ua=({client:s})=>{const n=Oe({mode:"onChange"}),{control:i,register:t,reset:a,trigger:o,formState:{isValid:l,errors:u}}=n,{t:r}=k("clients"),{addError:m}=oe(),h=he(),[p,d]=c.useState(!1),[x,j]=c.useState(!1),[S,y]=c.useState(!1),[g,M]=c.useState(!1),[U,Q]=c.useState([]),[R,E]=c.useState([]),[H,w]=c.useState(),[I,f]=c.useState([]);ie(()=>A.roles.find(),L=>{f(L)},[]),ie(()=>Promise.all([A.clients.listResources({id:s.id}),A.clients.listAllScopes({id:s.id})]),([L,V])=>{Q(L),E(V)},[]);const v=async()=>{if(!await o())return;const L=n.getValues(),V=gn(L.resources),D={roleIds:L.roleIds??[],clientId:L.client.id,userId:L.user[0],resources:U.filter(K=>Object.keys(V).includes(K.name)).map(K=>({...K,scopes:K.scopes?.filter(le=>Object.values(V).flatMap(Se=>Se).includes(le.name))})),entitlements:!1,context:{attributes:Object.fromEntries(L.context.attributes.filter(K=>K.key||K.value!=="").map(({key:K,value:le})=>[K,le]))}};try{const K=await A.clients.evaluateResource({id:s.id,realm:h.realm},D);w(K)}catch(K){m("clients:evaluateError",K)}},q=Ze({control:i,name:"user",defaultValue:[]}),_=Ze({control:i,name:"roleIds",defaultValue:[]});return H?e.jsx(qa,{evaluateResult:H,refresh:v,back:()=>w(void 0)}):e.jsx(xe,{children:e.jsxs(De,{...n,children:[e.jsxs(ls,{children:[e.jsx(Kt,{children:e.jsx(ht,{headingLevel:"h2",children:r("clients:identityInformation")})}),e.jsx(os,{children:e.jsxs(ce,{isHorizontal:!0,role:"view-clients",children:[e.jsx(Bn,{name:"client",label:"client",namespace:"clients",helpText:"clients-help:client",defaultValue:s.clientId}),e.jsx(qs,{name:"user",label:"users",helpText:r("clients-help:selectUser"),defaultValue:[],variant:G.typeahead,isRequired:_?.length===0}),e.jsx(b,{label:r("roles"),labelIcon:e.jsx(C,{helpText:r("clients-help:roles"),fieldLabelId:"clients:roles"}),fieldId:"realmRole",validated:u.roleIds?"error":"default",helperTextInvalid:r("common:required"),isRequired:q.length===0,children:e.jsx(N,{name:"roleIds",control:i,defaultValue:[],rules:{validate:L=>(L||"").length>0||q.length>0},render:({field:L})=>e.jsx(J,{placeholderText:r("selectARole"),variant:G.typeaheadMulti,toggleId:"role",onToggle:j,selections:L.value,onSelect:(V,D)=>{const K=D.toString();L.value?.includes(K)?L.onChange(L.value.filter(le=>le!==K)):L.onChange([...L.value||[],K]),j(!1)},onClear:V=>{V.stopPropagation(),L.onChange([])},"aria-label":r("realmRole"),isOpen:x,children:I.map(V=>e.jsx(z,{selected:V.name===L.value,value:V.name},V.name))})})})]})})]}),e.jsxs(ls,{children:[e.jsx(Kt,{children:e.jsx(ht,{headingLevel:"h2",children:r("clients:identityInformation")})}),e.jsx(os,{children:e.jsxs(ce,{isHorizontal:!0,role:"view-clients",children:[e.jsx(b,{label:r("applyToResourceType"),fieldId:"applyToResourceType",labelIcon:e.jsx(C,{helpText:r("clients-help:applyToResourceType"),fieldLabelId:"clients:applyToResourceType"}),children:e.jsx(de,{id:"applyToResource-switch",label:r("common:on"),labelOff:r("common:off"),isChecked:g,onChange:M,"aria-label":r("applyToResourceType")})}),g?e.jsxs(e.Fragment,{children:[e.jsx(b,{label:r("resourceType"),isRequired:!0,labelIcon:e.jsx(C,{helpText:r("clients-help:resourceType"),fieldLabelId:"clients:resourceType"}),fieldId:"client",validated:u.alias?"error":"default",helperTextInvalid:r("common:required"),children:e.jsx(pe,{id:"alias","aria-label":"resource-type","data-testid":"alias",...t("alias",{required:!0})})}),e.jsx(b,{label:r("authScopes"),labelIcon:e.jsx(C,{helpText:r("clients-help:scopesSelect"),fieldLabelId:"clients:client"}),fieldId:"authScopes",children:e.jsx(N,{name:"authScopes",defaultValue:[],control:i,render:({field:L})=>e.jsx(J,{toggleId:"authScopes",onToggle:d,onSelect:(V,D)=>{const K=D.toString();L.value.includes(K)?L.onChange(L.value.filter(le=>le!==K)):L.onChange([...L.value,K]),d(!1)},selections:L.value,variant:G.typeaheadMulti,typeAheadAriaLabel:r("authScopes"),isOpen:p,children:R.map(V=>e.jsx(z,{selected:L.value.includes(V.name),value:V.name},V.id))})})})]}):e.jsx(b,{label:r("resourcesAndScopes"),id:"resourcesAndScopes",labelIcon:e.jsx(C,{helpText:r("clients-help:contextualAttributes"),fieldLabelId:"resourcesAndScopes"}),fieldId:"resourcesAndScopes",children:e.jsx(ys,{selectableValues:U.map(L=>({name:L.name,key:L._id})),resources:U,name:"resources"})}),e.jsx(Ms,{toggleText:r("contextualInfo"),onToggle:()=>y(!S),isExpanded:S,children:e.jsx(b,{label:r("contextualAttributes"),id:"contextualAttributes",labelIcon:e.jsx(C,{helpText:r("clients-help:contextualAttributes"),fieldLabelId:"contextualAttributes"}),helperTextInvalid:r("common:required"),fieldId:"contextualAttributes",children:e.jsx(ys,{selectableValues:Bs,name:"context.attributes"})})})]})})]}),e.jsxs(Ie,{children:[e.jsx(P,{"data-testid":"authorization-eval",id:"authorization-eval",className:"pf-u-mr-md",isDisabled:!l,onClick:()=>v(),children:r("evaluate")}),e.jsx(P,{"data-testid":"authorization-revert",id:"authorization-revert",className:"pf-u-mr-md",variant:"link",onClick:()=>a(),children:r("common:revert")})]})]})})},Ga=()=>{const{t:s}=k("clients"),{clientId:n}=Ht(),{addAlert:i,addError:t}=oe(),[a,o]=c.useState(),[l,u]=c.useState();ie(()=>A.clients.exportResource({id:n}),m=>{o(JSON.stringify(m,null,2)),u(m)},[]);const r=()=>{try{et.saveAs(new Blob([Je(l)],{type:"application/json"}),"test-authz-config.json"),i(s("exportAuthDetailsSuccess"),Y.success)}catch(m){t("exportAuthDetailsError",m)}};return a?e.jsx(xe,{children:e.jsxs(ce,{isHorizontal:!0,role:"view-realm",className:"pf-u-mt-lg",children:[e.jsx(b,{label:s("authDetails"),labelIcon:e.jsx(C,{helpText:s("clients-help:authDetails"),fieldLabelId:"clients:authDetails"}),fieldId:"client",children:e.jsx(at,{id:"authorizationDetails",readOnly:!0,resizeOrientation:"vertical",value:a,"aria-label":s("authDetails"),rows:10})}),e.jsxs(Ie,{children:[e.jsx(P,{"data-testid":"authorization-export-download",onClick:()=>r(),children:s("common:download")}),e.jsx(P,{"data-testid":"authorization-export-copy",variant:"secondary",onClick:async()=>{try{await navigator.clipboard.writeText(a),i(s("copied"),Y.success)}catch(m){t(s("copyError"),m)}},children:s("copy")})]})]})}):e.jsx(Ee,{})};function Ha(s){return e.jsx(Ge,{...s})}function Ge({name:s,array:n,convert:i,link:t}){const{t:a}=k("clients");return e.jsxs(Qn,{children:[e.jsx(Yn,{children:a(s)}),e.jsxs(Xn,{children:[n?.map(o=>{const l=typeof o=="string"?o:i(o);return t?e.jsx(ge,{to:t(o),className:"pf-u-pr-sm",children:l},l):e.jsx("span",{className:"pf-u-pr-sm",children:l},l)}),n?.length===0&&e.jsx("i",{children:a("common:none")})]})]})}const bs=({permissionType:s,disabled:n=!1,clientId:i})=>{const{t}=k("clients"),{realm:a}=he(),o=st();return e.jsx(P,{"data-testid":`create-${s}`,className:n?"keycloak__permissions__empty_state ":"pf-u-m-sm",variant:"secondary",onClick:()=>!n&&o(xt({realm:a,id:i,permissionType:s})),children:t(`create${Tt(s)}BasedPermission`)})},Ss=({permissionType:s,disabled:n,...i})=>{const{t}=k("clients");return n?e.jsx(qt,{content:t(`no${Tt(s)}CreateHint`),children:e.jsx(bs,{...i,disabled:n,permissionType:s})}):e.jsx(bs,{...i,disabled:n,permissionType:s})},$a=({clientId:s,isResourceEnabled:n,isScopeEnabled:i})=>{const{t}=k("clients");return e.jsxs(Gs,{"data-testid":"empty-state",variant:"large",children:[e.jsx(ea,{icon:Us}),e.jsx(ht,{headingLevel:"h1",size:"lg",children:t("emptyPermissions")}),e.jsx(Hs,{children:t("emptyPermissionInstructions")}),e.jsx(Ss,{permissionType:"resource",disabled:n,clientId:s}),e.jsx("br",{}),e.jsx(Ss,{permissionType:"scope",disabled:i,clientId:s})]})},Jt=({array:s})=>{const{t:n}=k("clients");return!s||s.length<=1?null:e.jsx(Nt,{color:"blue",children:n("common:more",{count:s.length-1})})};const Qt=({types:s,search:n,onSearch:i,isResource:t=!1})=>{const{t:a}=k("clients"),{register:o,control:l,reset:u,formState:{isDirty:r},handleSubmit:m}=Oe({mode:"onChange"}),[h,p]=be(),[d,x]=be(),j=y=>{p(),i(y)};c.useEffect(()=>u(n),[n]);const S=y=>[e.jsx(z,{value:"",children:a("allTypes")},"empty"),...(s||[]).map(g=>e.jsx(z,{selected:g.type===y,value:g.type,children:g.name},g.type))];return e.jsx(Ut,{"data-testid":"searchdropdown_dorpdown",className:"pf-u-ml-md",toggle:e.jsx(Os,{onToggle:p,className:"keycloak__client_authentication__searchdropdown",children:a("searchForPermission")}),isOpen:h,children:e.jsxs(ye,{isHorizontal:!0,className:"keycloak__client_authentication__searchdropdown_form",onSubmit:m(j),children:[e.jsx(b,{label:a("common:name"),fieldId:"name",children:e.jsx(pe,{id:"name","data-testid":"searchdropdown_name",...o("name")})}),t&&e.jsxs(e.Fragment,{children:[e.jsx(b,{label:a("common:type"),fieldId:"type",children:e.jsx(pe,{id:"type","data-testid":"searchdropdown_type",...o("type")})}),e.jsx(b,{label:a("uris"),fieldId:"uri",children:e.jsx(pe,{id:"uri","data-testid":"searchdropdown_uri",...o("uri")})}),e.jsx(b,{label:a("owner"),fieldId:"owner",children:e.jsx(pe,{id:"owner","data-testid":"searchdropdown_owner",...o("owner")})})]}),!t&&e.jsx(b,{label:a("resource"),fieldId:"resource",children:e.jsx(pe,{id:"resource","data-testid":"searchdropdown_resource",...o("resource")})}),e.jsx(b,{label:a("scope"),fieldId:"scope",children:e.jsx(pe,{id:"scope","data-testid":"searchdropdown_scope",...o("scope")})}),!t&&e.jsx(b,{label:a("common:type"),fieldId:"type",children:e.jsx(N,{name:"type",defaultValue:"",control:l,render:({field:y})=>e.jsx(J,{toggleId:"type",onToggle:x,onSelect:(g,M)=>{g.stopPropagation(),y.onChange(M),x()},selections:y.value||a("allTypes"),variant:G.single,"aria-label":a("common:type"),isOpen:d,children:S(y.value)})})}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"primary",type:"submit","data-testid":"search-btn",isDisabled:!r,children:a("common:search")}),e.jsx(P,{variant:"link","data-testid":"revert-btn",onClick:()=>i({}),children:a("common:clear")})]})]})})};const Wa=({row:s})=>e.jsxs(e.Fragment,{children:[s.associatedPolicies?.[0]?.name," ",e.jsx(Jt,{array:s.associatedPolicies})]}),Ja=({clientId:s})=>{const{t:n}=k("clients"),i=st(),{addAlert:t,addError:a}=oe(),{realm:o}=he(),[l,u]=c.useState(),[r,m]=c.useState(),[h,p]=c.useState(),[d,x]=c.useState(),[j,S]=be(),[y,g]=c.useState({}),[M,U]=c.useState(0),Q=()=>U(M+1),[R,E]=c.useState(10),[H,w]=c.useState(0);ie(async()=>{const _=await A.clients.findPermissions({first:H,max:R+1,id:s,...y});return await Promise.all(_.map(async L=>{const V=await A.clients.getAssociatedPolicies({id:s,permissionId:L.id});return{...L,associatedPolicies:V,isExpanded:!1}}))},u,[M,y,H,R]),ie(async()=>{const _={first:0,max:1},[L,V,D]=await Promise.all([A.clients.listPolicyProviders({id:s}),A.clients.listResources({..._,id:s}),A.clients.listAllScopes({..._,id:s})]);return{policies:L.filter(K=>K.type==="resource"||K.type==="scope"),resources:V.length!==1,scopes:D.length!==1}},({policies:_,resources:L,scopes:V})=>{p(_),x({resources:L,scopes:V})},[]);const[I,f]=Te({titleKey:"clients:deletePermission",messageKey:n("deletePermissionConfirm",{permission:r?.name}),continueButtonVariant:fe.danger,continueButtonLabel:"clients:confirm",onConfirm:async()=>{try{await A.clients.delPermission({id:s,type:r?.type,permissionId:r?.id}),t(n("permissionDeletedSuccess"),Y.success),Q()}catch(_){a("clients:permissionDeletedError",_)}}});if(!l)return e.jsx(Ee,{});const v=l.length===0,q=Object.keys(y).length!==0;return e.jsxs(xe,{variant:"light",className:"pf-u-p-0",children:[e.jsx(f,{}),(!v||q)&&e.jsx(It,{count:l.length,first:H,max:R,onNextClick:w,onPreviousClick:w,onPerPageSelect:(_,L)=>{w(_),E(L)},toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(je,{children:e.jsx(Qt,{types:h,search:y,onSearch:g})}),e.jsx(je,{children:e.jsx(Ut,{toggle:e.jsx(Os,{onToggle:S,isPrimary:!0,"data-testid":"permissionCreateDropdown",children:n("createPermission")}),isOpen:j,dropdownItems:[e.jsx(Qe,{"data-testid":"create-resource",isDisabled:d?.resources,component:"button",onClick:()=>i(xt({realm:o,id:s,permissionType:"resource"})),children:n("createResourceBasedPermission")},"createResourceBasedPermission"),e.jsx(jn,{},"separator"),e.jsxs(Qe,{"data-testid":"create-scope",isDisabled:d?.scopes,component:"button",onClick:()=>i(xt({realm:o,id:s,permissionType:"scope"})),children:[n("createScopeBasedPermission"),d?.scopes&&e.jsx(nt,{className:"pf-u-mt-sm",variant:"warning",isInline:!0,isPlain:!0,title:n("noScopeCreateHint")})]},"createScopeBasedPermission")]})})]}),children:!v&&e.jsxs(Ve,{"aria-label":n("resources"),variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{}),e.jsx(B,{children:n("common:name")}),e.jsx(B,{children:n("common:type")}),e.jsx(B,{children:n("associatedPolicy")}),e.jsx(B,{children:n("common:description")}),e.jsx(B,{})]})}),l.map((_,L)=>e.jsxs(Be,{isExpanded:_.isExpanded,children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:L,isExpanded:_.isExpanded,onToggle:(V,D)=>{const K=l.map((le,Se)=>Se===D?{...le,isExpanded:!le.isExpanded}:le);u(K)}}}),e.jsx(F,{"data-testid":`name-column-${_.name}`,children:e.jsx(ge,{to:ft({realm:o,id:s,permissionType:_.type,permissionId:_.id}),children:_.name})}),e.jsx(F,{children:h?.find(V=>V.type===_.type)?.name}),e.jsx(F,{children:e.jsx(Wa,{row:_})}),e.jsx(F,{children:_.description}),e.jsx(F,{actions:{items:[{title:n("common:delete"),onClick:async()=>{m(_),I()}}]}})]}),e.jsxs(ae,{isExpanded:_.isExpanded,children:[e.jsx(F,{}),e.jsx(F,{colSpan:5,children:e.jsx(lt,{children:_.isExpanded&&e.jsx(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:e.jsx(Ge,{name:"associatedPolicy",array:_.associatedPolicies,convert:V=>V.name,link:V=>Bt({id:s,realm:o,policyId:V.id,policyType:V.type})})})})})]},`child-${_.id}`)]},_.id))]})}),v&&!q&&e.jsx($a,{clientId:s,isResourceEnabled:d?.resources,isScopeEnabled:d?.scopes}),v&&q&&e.jsx(we,{isSearchVariant:!0,message:n("common:noSearchResults"),instructions:n("common:noSearchResultsInstructions")})]})},vs=({policyProviders:s,onSelect:n,toggleDialog:i})=>{const{t}=k("clients"),a=$s(),o=c.useMemo(()=>s?a(s,Ws("name")):[],[s]);return e.jsx(ze,{"aria-labelledby":t("addPredefinedMappers"),variant:it.medium,header:e.jsxs(Le,{children:[e.jsx(me,{component:Vs.h1,children:t("chooseAPolicyType")}),e.jsx(me,{children:t("chooseAPolicyTypeInstructions")})]}),isOpen:!0,onClose:i,children:e.jsxs(Ve,{"aria-label":t("policies"),variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{children:t("common:name")}),e.jsx(B,{children:t("common:description")})]})}),e.jsx(Be,{children:o.map(l=>e.jsxs(ae,{"data-testid":l.type,onRowClick:()=>n(l),isHoverable:!0,children:[e.jsx(F,{children:l.name}),e.jsx(F,{children:Un(l.type)&&t(`policyProvider.${l.type}`)})]},l.type))})]})})},Qa=({row:s})=>e.jsxs(e.Fragment,{children:[s.dependentPolicies?.[0]?.name," ",e.jsx(Jt,{array:s.dependentPolicies})]}),Ya=({clientId:s})=>{const{t:n}=k("clients"),{addAlert:i,addError:t}=oe(),{realm:a}=he(),o=st(),[l,u]=c.useState(),[r,m]=c.useState(),[h,p]=c.useState(),[d,x]=c.useState(0),j=()=>x(d+1),[S,y]=c.useState(10),[g,M]=c.useState(0),[U,Q]=c.useState({}),[R,E]=be();ie(async()=>{const v=await A.clients.listPolicies({first:g,max:S+1,id:s,permission:"false",...U});return await Promise.all([A.clients.listPolicyProviders({id:s}),...(v||[]).map(async q=>{const _=await A.clients.listDependentPolicies({id:s,policyId:q.id});return{...q,dependentPolicies:_,isExpanded:!1}})])},([v,...q])=>{p(v.filter(_=>_.type!=="resource"&&_.type!=="scope")),u(q)},[d,U,g,S]);const[H,w]=Te({titleKey:"clients:deletePolicy",children:e.jsxs(e.Fragment,{children:[n("deletePolicyConfirm"),r?.dependentPolicies&&r.dependentPolicies.length>0&&e.jsx(nt,{variant:"warning",isInline:!0,isPlain:!0,component:"p",title:n("deletePolicyWarning"),className:"pf-u-pt-lg",children:e.jsx("p",{className:"pf-u-pt-xs",children:r.dependentPolicies.map(v=>e.jsx("strong",{className:"pf-u-pr-md",children:v.name},v.id))})})]}),continueButtonLabel:"clients:confirm",onConfirm:async()=>{try{await A.clients.delPolicy({id:s,policyId:r?.id}),i(n("policyDeletedSuccess"),Y.success),j()}catch(v){t("clients:policyDeletedError",v)}}});if(!l)return e.jsx(Ee,{});const I=l.length===0,f=Object.keys(U).length!==0;return e.jsxs(xe,{variant:"light",className:"pf-u-p-0",children:[e.jsx(w,{}),(!I||f)&&e.jsxs(e.Fragment,{children:[R&&e.jsx(vs,{policyProviders:h,onSelect:v=>o(Xt({id:s,realm:a,policyType:v.type})),toggleDialog:E}),e.jsx(It,{count:l.length,first:g,max:S,onNextClick:M,onPreviousClick:M,onPerPageSelect:(v,q)=>{M(v),y(q)},toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(je,{children:e.jsx(Qt,{types:h,search:U,onSearch:Q})}),e.jsx(je,{children:e.jsx(P,{"data-testid":"createPolicy",onClick:E,children:n("createPolicy")})})]}),children:!I&&e.jsxs(Ve,{"aria-label":n("resources"),variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{"aria-hidden":"true"}),e.jsx(B,{children:n("common:name")}),e.jsx(B,{children:n("common:type")}),e.jsx(B,{children:n("dependentPermission")}),e.jsx(B,{children:n("common:description")}),e.jsx(B,{"aria-hidden":"true"})]})}),l.map((v,q)=>e.jsxs(Be,{isExpanded:v.isExpanded,children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:q,isExpanded:v.isExpanded,onToggle:(_,L)=>{const V=l.map((D,K)=>K===L?{...D,isExpanded:!D.isExpanded}:D);u(V)}}}),e.jsx(F,{"data-testid":`name-column-${v.name}`,children:e.jsx(ge,{to:Bt({realm:a,id:s,policyType:v.type,policyId:v.id}),children:v.name})}),e.jsx(F,{children:Tt(v.type)}),e.jsx(F,{children:e.jsx(Qa,{row:v})}),e.jsx(F,{children:v.description}),e.jsx(F,{actions:{items:[{title:n("common:delete"),onClick:async()=>{m(v),H()}}]}})]}),e.jsxs(ae,{isExpanded:v.isExpanded,children:[e.jsx(F,{}),e.jsx(F,{colSpan:4,children:e.jsx(lt,{children:v.isExpanded&&e.jsx(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:e.jsx(Ge,{name:"dependentPermission",array:v.dependentPolicies,convert:_=>_.name,link:_=>ft({realm:a,id:s,permissionId:_.id,permissionType:_.type})})})})})]},`child-${v.id}`)]},v.id))]})})]}),I&&f&&e.jsx(we,{isSearchVariant:!0,message:n("common:noSearchResults"),instructions:n("common:noSearchResultsInstructions")}),I&&!f&&e.jsxs(e.Fragment,{children:[R&&e.jsx(vs,{policyProviders:h?.filter(v=>v.type!=="aggregate"),onSelect:v=>o(Xt({id:s,realm:a,policyType:v.type})),toggleDialog:E}),e.jsx(we,{message:n("emptyPolicies"),instructions:n("emptyPoliciesInstructions"),primaryActionText:n("createPolicy"),onPrimaryAction:E})]})]})};const Xa=({id:s,clientId:n,uris:i})=>{const{realm:t}=he(),[a,o]=c.useState(),[l,u]=c.useState();return ie(()=>Promise.all([A.clients.listScopesByResource({id:n,resourceName:s}),A.clients.listPermissionsByResource({id:n,resourceId:s})]),([r,m])=>{o(r),u(m)},[]),!l||!a?e.jsx(Ee,{}):e.jsxs(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:[e.jsx(Ha,{name:"uris",array:i}),e.jsx(Ge,{name:"scopes",array:a,convert:r=>r.name,link:r=>Ps({id:n,realm:t,scopeId:r.id})}),e.jsx(Ge,{name:"associatedPermissions",array:l,convert:r=>r.name,link:r=>ft({id:n,realm:t,permissionId:r.id,permissionType:"resource"})})]})},Za=({row:s})=>e.jsxs(e.Fragment,{children:[s.uris?.[0]," ",e.jsx(Jt,{array:s.uris})]}),ei=({clientId:s})=>{const{t:n}=k("clients"),i=st(),{addAlert:t,addError:a}=oe(),{realm:o}=he(),[l,u]=c.useState(),[r,m]=c.useState(),[h,p]=c.useState(),[d,x]=c.useState(0),j=()=>x(d+1),[S,y]=c.useState(10),[g,M]=c.useState(0),[U,Q]=c.useState({});ie(()=>{const f={first:g,max:S+1,deep:!1,...U};return A.clients.listResources({...f,id:s})},f=>u(f.map(v=>({...v,isExpanded:!1}))),[d,U,g,S]);const R=async f=>A.clients.listPermissionsByResource({id:s,resourceId:f}),[E,H]=Te({titleKey:"clients:deleteResource",children:e.jsxs(e.Fragment,{children:[n("deleteResourceConfirm"),h?.length&&e.jsx(nt,{variant:"warning",isInline:!0,isPlain:!0,title:n("deleteResourceWarning"),className:"pf-u-pt-lg",children:e.jsx("p",{className:"pf-u-pt-xs",children:h.map(f=>e.jsx("strong",{className:"pf-u-pr-md",children:f.name},f.id))})})]}),continueButtonLabel:"clients:confirm",onConfirm:async()=>{try{await A.clients.delResource({id:s,resourceId:r?._id}),t(n("resourceDeletedSuccess"),Y.success),j()}catch(f){a("clients:resourceDeletedError",f)}}});if(!l)return e.jsx(Ee,{});const w=l.length===0,I=Object.keys(U).length!==0;return e.jsxs(xe,{variant:"light",className:"pf-u-p-0",children:[e.jsx(H,{}),(!w||I)&&e.jsx(It,{count:l.length,first:g,max:S,onNextClick:M,onPreviousClick:M,onPerPageSelect:(f,v)=>{M(f),y(v)},toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(je,{children:e.jsx(Qt,{search:U,onSearch:Q,isResource:!0})}),e.jsx(je,{children:e.jsx(P,{"data-testid":"createResource",component:f=>e.jsx(ge,{...f,to:Zt({realm:o,id:s})}),children:n("createResource")})})]}),children:!w&&e.jsxs(Ve,{"aria-label":n("resources"),variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{}),e.jsx(B,{children:n("common:name")}),e.jsx(B,{children:n("displayName")}),e.jsx(B,{children:n("common:type")}),e.jsx(B,{children:n("owner")}),e.jsx(B,{children:n("uris")}),e.jsx(B,{}),e.jsx(B,{})]})}),l.map((f,v)=>e.jsxs(Be,{isExpanded:f.isExpanded,children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:v,isExpanded:f.isExpanded,onToggle:(q,_)=>{const L=l.map((V,D)=>D===_?{...V,isExpanded:!V.isExpanded}:V);u(L)}}}),e.jsx(F,{"data-testid":`name-column-${f.name}`,children:e.jsx(ge,{to:_s({realm:o,id:s,resourceId:f._id}),children:f.name})}),e.jsx(F,{children:f.displayName}),e.jsx(F,{children:f.type}),e.jsx(F,{children:f.owner?.name}),e.jsx(F,{children:e.jsx(Za,{row:f})}),e.jsx(F,{width:10,children:e.jsx(P,{variant:"link",component:q=>e.jsx(ge,{...q,to:xt({realm:o,id:s,permissionType:"resource",selectedId:f._id})}),children:n("createPermission")})}),e.jsx(F,{actions:{items:[{title:n("common:delete"),onClick:async()=>{m(f),p(await R(f._id)),E()}}]}})]}),e.jsxs(ae,{isExpanded:f.isExpanded,children:[e.jsx(F,{}),e.jsx(F,{colSpan:4,children:e.jsx(lt,{children:f.isExpanded&&e.jsx(Xa,{clientId:s,id:f._id,uris:f.uris})})})]},`child-${f._id}`)]},f._id))]})}),w&&I&&e.jsx(we,{isSearchVariant:!0,message:n("common:noSearchResults"),instructions:n("common:noSearchResultsInstructions")}),w&&!I&&e.jsx(we,{message:n("emptyResources"),instructions:n("emptyResourcesInstructions"),primaryActionText:n("createResource"),onPrimaryAction:()=>i(Zt({realm:o,id:s}))})]})},ti=({clientId:s})=>{const{t:n}=k("clients"),i=st(),{realm:t}=he(),[a,o]=be(),[l,u]=c.useState(),[r,m]=c.useState(),[h,p]=c.useState([]),[d,x]=c.useState(0),j=()=>x(d+1),[S,y]=c.useState(10),[g,M]=c.useState(0),[U,Q]=c.useState("");ie(()=>{const I={first:g,max:S+1,deep:!1,name:U};return A.clients.listAllScopes({...I,id:s})},I=>{u(I.map(f=>({...f,isLoaded:!1}))),p(I.map(f=>({id:f.id,isExpanded:!1})))},[d,U,g,S]);const R=I=>l?.find(f=>f.id===I),E=I=>h.find(f=>f.id===I)?.isExpanded||!1;if(ie(()=>{const I=h.filter(f=>f.isExpanded).map(({id:f})=>R(f)).filter(f=>!f.isLoaded);return Promise.all(I.map(async f=>{const[v,q]=await Promise.all([A.clients.listAllResourcesByScope({id:s,scopeId:f.id}),A.clients.listAllPermissionsByScope({id:s,scopeId:f.id})]);return{...f,resources:v,permissions:q,isLoaded:!0}}))},I=>{let f=[...l||[]];I.forEach(v=>{const q=l?.findIndex(_=>v.id===_.id);f=[...f.slice(0,q),v,...f.slice(q+1)]}),u(f)},[h]),!l)return e.jsx(Ee,{});const H=l.length===0,w=U!=="";return e.jsxs(xe,{variant:"light",className:"pf-u-p-0",children:[e.jsx(ta,{clientId:s,open:a,toggleDialog:o,selectedScope:r,refresh:j}),(!H||w)&&e.jsx(It,{count:l.length,first:g,max:S,onNextClick:M,onPreviousClick:M,onPerPageSelect:(I,f)=>{M(I),y(f)},inputGroupName:"search",inputGroupPlaceholder:n("searchByName"),inputGroupOnEnter:Q,toolbarItem:e.jsx(je,{children:e.jsx(P,{"data-testid":"createAuthorizationScope",component:I=>e.jsx(ge,{...I,to:es({realm:t,id:s})}),children:n("createAuthorizationScope")})}),children:!H&&e.jsxs(Ve,{"aria-label":n("scopes"),variant:"compact",children:[e.jsx(qe,{children:e.jsxs(ae,{children:[e.jsx(B,{}),e.jsx(B,{children:n("common:name")}),e.jsx(B,{children:n("displayName")}),e.jsx(B,{}),e.jsx(B,{})]})}),l.map((I,f)=>e.jsxs(Be,{isExpanded:E(I.id),children:[e.jsxs(ae,{children:[e.jsx(F,{expand:{rowIndex:f,isExpanded:E(I.id),onToggle:(v,q,_)=>{p([...h.slice(0,q),{id:I.id,isExpanded:_},...h.slice(q+1)])}}}),e.jsx(F,{"data-testid":`name-column-${I.name}`,children:e.jsx(ge,{to:Ps({realm:t,id:s,scopeId:I.id}),children:I.name})}),e.jsx(F,{children:I.displayName}),e.jsx(F,{width:10,children:e.jsx(P,{variant:"link",component:v=>e.jsx(ge,{...v,to:xt({realm:t,id:s,permissionType:"scope",selectedId:I.id})}),children:n("createPermission")})}),e.jsx(F,{isActionCell:!0,actions:{items:[{title:n("common:delete"),onClick:()=>{m(I),o()}}]}})]}),e.jsxs(ae,{isExpanded:E(I.id),children:[e.jsx(F,{}),e.jsx(F,{colSpan:4,children:e.jsx(lt,{children:E(I.id)&&I.isLoaded?e.jsxs(ot,{isHorizontal:!0,className:"keycloak_resource_details",children:[e.jsx(Ge,{name:"resources",array:I.resources,convert:v=>v.name,link:v=>_s({id:s,realm:t,resourceId:v._id})}),e.jsx(Ge,{name:"associatedPermissions",array:I.permissions,convert:v=>v.name,link:v=>ft({id:s,realm:t,permissionId:v.id,permissionType:v.type})})]}):e.jsx(Ee,{})})})]},`child-${I.id}`)]},I.id))]})}),H&&!w&&e.jsx(we,{message:n("emptyAuthorizationScopes"),instructions:n("emptyAuthorizationInstructions"),onPrimaryAction:()=>i(es({id:s,realm:t})),primaryActionText:n("createAuthorizationScope")}),H&&w&&e.jsx(we,{isSearchVariant:!0,message:n("common:noSearchResults"),instructions:n("common:noSearchResultsInstructions")})]})},si=({onConfirm:s,closeDialog:n})=>{const{t:i}=k("clients"),[t,a]=c.useState({});return e.jsxs(ze,{title:i("import"),isOpen:!0,variant:"small",onClose:n,actions:[e.jsx(P,{id:"modal-confirm",onClick:()=>{s(t),n()},"data-testid":"confirm",children:i("confirm")},"confirm"),e.jsx(P,{"data-testid":"cancel",id:"modal-cancel",variant:fe.link,onClick:()=>{n()},children:i("common:cancel")},"cancel")],children:[e.jsx(ye,{children:e.jsx(sa,{id:"import-resource",onChange:a})}),Object.keys(t).length!==0&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx("p",{className:"pf-u-my-lg",children:i("importResources")}),e.jsxs(ye,{isHorizontal:!0,children:[e.jsx(b,{label:i("policyEnforcementMode"),labelIcon:e.jsx(C,{helpText:i("clients-help:policyEnforcementMode"),fieldLabelId:"clients:policyEnforcementMode"}),fieldId:"policyEnforcementMode",hasNoPaddingTop:!0,children:e.jsx(gt,{id:"policyEnforcementMode",name:"policyEnforcementMode",label:i(`policyEnforcementModes.${t.policyEnforcementMode}`),isChecked:!0,isDisabled:!0,className:"pf-u-mb-md"})}),e.jsx(b,{label:i("decisionStrategy"),labelIcon:e.jsx(C,{helpText:i("clients-help:decisionStrategy"),fieldLabelId:"clients:decisionStrategy"}),fieldId:"decisionStrategy",hasNoPaddingTop:!0,children:e.jsx(gt,{id:"decisionStrategy",name:"decisionStrategy",isChecked:!0,isDisabled:!0,label:i(`decisionStrategies.${t.decisionStrategy}`),className:"pf-u-mb-md"})}),e.jsx(b,{hasNoPaddingTop:!0,label:i("allowRemoteResourceManagement"),fieldId:"allowRemoteResourceManagement",labelIcon:e.jsx(C,{helpText:i("allowRemoteResourceManagement"),fieldLabelId:"clients:allowRemoteResourceManagement"}),children:e.jsx(de,{id:"allowRemoteResourceManagement",label:i("common:on"),labelOff:i("common:off"),isChecked:t.allowRemoteResourceManagement,isDisabled:!0,"aria-label":i("allowRemoteResourceManagement")})})]}),e.jsx("div",{className:"pf-u-mt-md",children:Object.entries(t).filter(([,o])=>Array.isArray(o)).map(([o,l])=>e.jsxs(c.Fragment,{children:[e.jsx(Ue,{}),e.jsx("p",{className:"pf-u-my-sm",children:e.jsxs("strong",{children:[l.length," ",i(o)]})})]},o))}),e.jsx(Ue,{}),e.jsx(nt,{variant:"warning",className:"pf-u-mt-lg",isInline:!0,title:i("importWarning")})]})]})},Cs=["ENFORCING","PERMISSIVE","DISABLED"],ni=({clientId:s})=>{const{t:n}=k("clients"),[i,t]=c.useState(),[a,o]=be(),l=Oe({}),{control:u,reset:r,handleSubmit:m}=l,{addAlert:h,addError:p}=oe();ie(()=>A.clients.getResourceServer({id:s}),j=>{t(j),r(j)},[]);const d=async j=>{try{await A.clients.importResource({id:s},j),h(n("importResourceSuccess"),Y.success),r({...j})}catch(S){p("clients:importResourceError",S)}},x=async j=>{try{await A.clients.updateResourceServer({id:s},j),h(n("updateResourceSuccess"),Y.success)}catch(S){p("clients:resourceSaveError",S)}};return i?e.jsxs(xe,{variant:"light",children:[a&&e.jsx(si,{onConfirm:d,closeDialog:o}),e.jsxs(ce,{role:"view-clients",isHorizontal:!0,onSubmit:m(x),children:[e.jsx(b,{label:n("import"),fieldId:"import",labelIcon:e.jsx(C,{helpText:n("clients-help:import"),fieldLabelId:"clients:import"}),children:e.jsx(P,{variant:"secondary",onClick:o,children:n("import")})}),e.jsx(Ue,{}),e.jsx(b,{label:n("policyEnforcementMode"),labelIcon:e.jsx(C,{helpText:n("clients-help:policyEnforcementMode"),fieldLabelId:"clients:policyEnforcementMode"}),fieldId:"policyEnforcementMode",hasNoPaddingTop:!0,children:e.jsx(N,{name:"policyEnforcementMode","data-testid":"policyEnforcementMode",defaultValue:Cs[0],control:u,render:({field:j})=>e.jsx(e.Fragment,{children:Cs.map(S=>e.jsx(gt,{id:S,"data-testid":S,isChecked:j.value===S,name:"policyEnforcementMode",onChange:()=>j.onChange(S),label:n(`policyEnforcementModes.${S}`),className:"pf-u-mb-md"},S))})})}),e.jsx(De,{...l,children:e.jsx(Gn,{isLimited:!0})}),e.jsx(b,{hasNoPaddingTop:!0,label:n("allowRemoteResourceManagement"),fieldId:"allowRemoteResourceManagement",labelIcon:e.jsx(C,{helpText:n("clients-help:allowRemoteResourceManagement"),fieldLabelId:"clients:allowRemoteResourceManagement"}),children:e.jsx(N,{name:"allowRemoteResourceManagement","data-testid":"allowRemoteResourceManagement",defaultValue:!1,control:u,render:({field:j})=>e.jsx(de,{id:"allowRemoteResourceManagement",label:n("common:on"),labelOff:n("common:off"),isChecked:j.value,onChange:j.onChange,"aria-label":n("allowRemoteResourceManagement")})})}),e.jsx(Rt,{name:"authenticationSettings",reset:()=>r(i),isActive:!0,isSubmit:!0})]})]}):e.jsx(Ee,{})},sn=({id:s,label:n,text:i,variant:t="plain"})=>{const{t:a}=k("clients"),o=fn(),[l,u]=c.useState(0),r=c.useMemo(()=>{switch(l){case 0:return a("copyToClipboard");case 1:return a("copySuccess");case 2:return a("clipboardCopyError")}},[l]);c.useEffect(()=>{if(l!==0)return o(()=>u(0),1e3)},[l]);const m=async h=>{try{await navigator.clipboard.writeText(h),u(1)}catch{u(2)}};return e.jsx(wn,{id:`copy-button-${s}`,textId:n,"aria-label":a("copyToClipboard"),onClick:()=>m(i),exitDelay:600,variant:t,children:r})},Ts=({id:s,buttonLabel:n,client:i,secret:t,toggle:a})=>{const{t:o}=k("clients"),l=X(),{hasAccess:u}=Pe(),r=u("manage-clients")||i.access?.configure;return e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{isFilled:!0,children:e.jsxs(Vt,{children:[e.jsx(Ft,{id:s,value:t,isReadOnly:!0}),e.jsx(sn,{id:s,text:t,label:"clientSecret",variant:"control"})]})}),e.jsx(Ce,{children:e.jsx(P,{variant:"secondary",isDisabled:l.formState.isDirty||!r,onClick:a,children:o(n)})})]})},Is=({time:s})=>{const{t:n}=k("clients"),i=Wt(),t=a=>a?n("secretExpiresOn",{time:i(new Date(a*1e3),{dateStyle:"full",timeStyle:"long"})}):void 0;return e.jsx("div",{className:"pf-u-my-md",children:t(s)})},ai=({client:s,secret:n,toggle:i})=>{const{t}=k("clients"),{addAlert:a,addError:o}=oe(),[l,u]=c.useState(s.attributes?.["client.secret.rotated"]),r=s.attributes?.["client.secret.expiration.time"],m=s.attributes?.["client.secret.rotated.expiration.time"],h=x=>new Date().getTime()>=x*1e3,[p,d]=Te({titleKey:"clients:invalidateRotatedSecret",messageKey:"clients:invalidateRotatedSecretExplain",continueButtonLabel:"common:confirm",onConfirm:async()=>{try{await A.clients.invalidateSecret({id:s.id}),u(void 0),a(t("invalidateRotatedSuccess"))}catch(x){o("clients:invalidateRotatedError",x)}}});return e.jsxs(e.Fragment,{children:[e.jsx(d,{}),e.jsxs(b,{label:t("clientSecret"),fieldId:"kc-client-secret",className:"pf-u-my-md",children:[e.jsx(Ts,{id:"kc-client-secret",client:s,secret:n,toggle:i,buttonLabel:"regenerate"}),e.jsx(Is,{time:r}),h(r)&&e.jsx(nt,{variant:"warning",isInline:!0,title:t("secretHasExpired")})]}),l&&e.jsxs(b,{label:t("secretRotated"),fieldId:"secretRotated",children:[e.jsx(Ts,{id:"secretRotated",client:s,secret:l,toggle:p,buttonLabel:"invalidateSecret"}),e.jsx(Is,{time:m})]})]})},ii=({clientAuthenticatorType:s})=>{const{control:n}=X(),{cryptoInfo:i}=He(),t=s==="client-jwt"?i?.clientSignatureAsymmetricAlgorithms??[]:i?.clientSignatureSymmetricAlgorithms??[],{t:a}=k("clients"),[o,l]=c.useState(!1);return e.jsx(b,{label:a("signatureAlgorithm"),fieldId:"kc-signature-algorithm",labelIcon:e.jsx(C,{helpText:a("clients-help:signature-algorithm"),fieldLabelId:"clients:signatureAlgorithm"}),children:e.jsx(N,{name:O("attributes.token.endpoint.auth.signing.alg"),defaultValue:"",control:n,render:({field:u})=>e.jsxs(J,{maxHeight:200,toggleId:"kc-signature-algorithm",onToggle:l,onSelect:(r,m)=>{u.onChange(m.toString()),l(!1)},selections:u.value||a("anyAlgorithm"),variant:G.single,"aria-label":a("signatureAlgorithm"),isOpen:o,children:[e.jsx(z,{selected:u.value==="",value:"",children:a("anyAlgorithm")},"any"),e.jsx(e.Fragment,{children:t.map(r=>e.jsx(z,{selected:r===u.value,value:r},r))})]})})})},li=()=>{const{t:s}=k("clients"),{register:n,control:i,formState:{errors:t}}=X();return e.jsxs(e.Fragment,{children:[e.jsx(b,{label:s("allowRegexComparison"),labelIcon:e.jsx(C,{helpText:s("clients-help:allowRegexComparison"),fieldLabelId:"clients:allowRegexComparison"}),fieldId:"allowRegexComparison",hasNoPaddingTop:!0,children:e.jsx(N,{name:O("attributes.x509.allow.regex.pattern.comparison"),defaultValue:"false",control:i,render:({field:a})=>e.jsx(de,{id:"allowRegexComparison",label:s("common:on"),labelOff:s("common:off"),isChecked:a.value==="true",onChange:o=>a.onChange(o.toString()),"aria-label":s("allowRegexComparison")})})}),e.jsx(b,{label:s("subject"),fieldId:"kc-subject",labelIcon:e.jsx(C,{helpText:s("clients-help:subject"),fieldLabelId:"clients:subject"}),helperTextInvalid:s("common:required"),validated:t.attributes?.[Ke("x509.subjectdn")]?ve.error:ve.default,isRequired:!0,children:e.jsx(pe,{type:"text",id:"kc-subject",validated:t.attributes?.[Ke("x509.subjectdn")]?ve.error:ve.default,...n(O("attributes.x509.subjectdn"),{required:!0})})})]})},oi=({client:s,save:n,refresh:i})=>{const{t}=k("clients"),{addAlert:a,addError:o}=oe(),l=s.id,[u,r]=c.useState([]),{control:m,formState:{isDirty:h},handleSubmit:p}=X(),d=Ze({control:m,name:"clientAuthenticatorType",defaultValue:""}),[x,j]=c.useState(""),[S,y]=c.useState(""),[g,M]=c.useState(!1);ie(()=>Promise.all([A.authenticationManagement.getClientAuthenticatorProviders(),A.clients.getClientSecret({id:l})]),([f,v])=>{r(f),j(v.value)},[]);async function U(f,v){try{const q=await f(l);return a(t(`${v}Success`),Y.success),q}catch(q){o(`clients:${v}Error`,q)}}const Q=async()=>{const f=await U(v=>A.clients.generateNewClientSecret({id:v}),"clientSecret");j(f?.value||""),i()},[R,E]=Te({titleKey:"clients:confirmClientSecretTitle",messageKey:"clients:confirmClientSecretBody",continueButtonLabel:"common:yes",cancelButtonLabel:"common:no",onConfirm:Q}),H=async()=>{const f=await U(v=>A.clients.generateRegistrationAccessToken({id:v}),"accessToken");y(f?.registrationAccessToken||"")},[w,I]=Te({titleKey:"clients:confirmAccessTokenTitle",messageKey:"clients:confirmAccessTokenBody",continueButtonLabel:"common:yes",cancelButtonLabel:"common:no",onConfirm:H});return e.jsx(xe,{children:e.jsxs(ce,{onSubmit:p(n),isHorizontal:!0,className:"pf-u-mt-md",role:"manage-clients",fineGrainedAccess:s.access?.configure,children:[e.jsx(E,{}),e.jsx(I,{}),e.jsxs(Ct,{isFlat:!0,children:[e.jsxs(Ye,{children:[e.jsx(b,{label:t("clientAuthenticator"),fieldId:"kc-client-authenticator-type",labelIcon:e.jsx(C,{helpText:t("clients-help:client-authenticator-type"),fieldLabelId:"clients:clientAuthenticator"}),children:e.jsx(N,{name:"clientAuthenticatorType",control:m,defaultValue:"",render:({field:f})=>e.jsx(J,{toggleId:"kc-client-authenticator-type",required:!0,onToggle:M,onSelect:(v,q)=>{f.onChange(q),M(!1)},selections:f.value,variant:G.single,"aria-label":t("clientAuthenticator"),isOpen:g,children:u.map(v=>e.jsx(z,{selected:v.id===f.value,value:v.id,children:v.displayName},v.id))})})}),(d==="client-jwt"||d==="client-secret-jwt")&&e.jsx(ii,{clientAuthenticatorType:d}),d==="client-jwt"&&e.jsx(b,{children:e.jsx(nt,{variant:"info",isInline:!0,title:t("signedJWTConfirm")})}),d==="client-x509"&&e.jsx(li,{}),e.jsx(Ie,{children:e.jsx(P,{variant:"primary",type:"submit",isDisabled:!h,children:t("common:save")})})]}),(d==="client-secret"||d==="client-secret-jwt")&&e.jsx(Ue,{}),(d==="client-secret"||d==="client-secret-jwt")&&e.jsx(Ye,{children:e.jsx(ai,{client:s,secret:x,toggle:R})})]}),e.jsx(Ct,{isFlat:!0,children:e.jsx(Ye,{children:e.jsx(b,{label:t("registrationAccessToken"),fieldId:"kc-access-token",labelIcon:e.jsx(C,{helpText:t("clients-help:registration-access-token"),fieldLabelId:"clients:registrationAccessToken"}),children:e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{isFilled:!0,children:e.jsx(Ds,{id:"kc-access-token",isReadOnly:!0,children:S})}),e.jsx(Ce,{children:e.jsx(P,{variant:"secondary",onClick:w,children:t("regenerate")})})]})})})})]})})},ks=({id:s,keyInfo:n})=>{const{t:i}=k("clients");return e.jsx(at,{readOnly:!0,rows:5,id:s,"data-testid":"certificate",value:n?.certificate,"aria-label":i("certificate")})},Yt=({keyInfo:s,plain:n=!1})=>{const{t:i}=k("clients"),t=c.useId();return n?e.jsx(ks,{id:t,keyInfo:s}):e.jsx(b,{label:i("certificate"),fieldId:t,labelIcon:e.jsx(C,{helpText:i("clients-help:certificate"),fieldLabelId:`clients:${t}`}),children:e.jsx(ks,{id:t,keyInfo:s})})},nn=({hidePassword:s=!1,isSaml:n=!1})=>{const{t:i}=k("clients"),{register:t,formState:{errors:a}}=X();return e.jsxs(e.Fragment,{children:[e.jsx(b,{label:i("keyAlias"),fieldId:"keyAlias",isRequired:!0,labelIcon:e.jsx(C,{helpText:i("clients-help:keyAlias"),fieldLabelId:"clients:keyAlias"}),helperTextInvalid:i("common:required"),validated:a.keyAlias?"error":"default",children:e.jsx(pe,{"data-testid":"keyAlias",id:"keyAlias",validated:a.keyAlias?"error":"default",...t("keyAlias",{required:!0})})}),!s&&e.jsx(b,{label:i("keyPassword"),fieldId:"keyPassword",isRequired:!0,labelIcon:e.jsx(C,{helpText:i("clients-help:keyPassword"),fieldLabelId:"clients:keyPassword"}),helperTextInvalid:i("common:required"),validated:a.keyPassword?"error":"default",children:e.jsx(Ft,{"data-testid":"keyPassword",id:"keyPassword",validated:a.keyPassword?"error":"default",...t("keyPassword",{required:!0})})}),n&&e.jsx(b,{label:i("realmCertificateAlias"),fieldId:"realmCertificateAlias",labelIcon:e.jsx(C,{helpText:i("clients-help:realmCertificateAlias"),fieldLabelId:"clients:realmCertificateAlias"}),children:e.jsx(pe,{"data-testid":"realmCertificateAlias",id:"realmCertificateAlias",...t("realmAlias")})}),e.jsx(b,{label:i("storePassword"),fieldId:"storePassword",isRequired:!0,labelIcon:e.jsx(C,{helpText:i("clients-help:storePassword"),fieldLabelId:"clients:storePassword"}),helperTextInvalid:i("common:required"),validated:a.storePassword?"error":"default",children:e.jsx(Ft,{"data-testid":"storePassword",id:"storePassword",validated:a.storePassword?"error":"default",...t("storePassword",{required:!0})})})]})},Rs="Certificate PEM",ri=new Map([["PKCS12","p12"],["JKS","jks"],["BCFKS","bcfks"]]),an=s=>ri.get(s),At=({isSaml:s=!1,hasPem:n=!1,useFile:i=!1})=>{const{t}=k("clients"),[a,o]=c.useState(),[l,u]=c.useState(!1),{control:r,watch:m}=X(),h=m("format"),{cryptoInfo:p}=He(),d=[...p?.supportedKeystoreTypes??[],...n?[Rs]:[]];return e.jsxs(ye,{className:"pf-u-pt-lg",children:[e.jsx(b,{label:t("archiveFormat"),labelIcon:e.jsx(C,{helpText:t("clients-help:archiveFormat"),fieldLabelId:"clients:archiveFormat"}),fieldId:"archiveFormat",children:e.jsx(N,{name:"format",defaultValue:d[0],control:r,render:({field:x})=>e.jsx(J,{toggleId:"archiveFormat",onToggle:u,onSelect:(j,S)=>{x.onChange(S.toString()),u(!1)},selections:x.value,variant:G.single,"aria-label":t("archiveFormat"),isOpen:l,menuAppendTo:"parent",children:d.map(j=>e.jsx(z,{selected:j===x.value,value:j},j))})})}),i&&e.jsx(b,{label:t("importFile"),labelIcon:e.jsx(C,{helpText:t("clients-help:importFile"),fieldLabelId:"clients:importFile"}),fieldId:"importFile",children:e.jsx(N,{name:"file",defaultValue:"",control:r,render:({field:x})=>e.jsx(Js,{id:"importFile",value:x.value,filename:a,browseButtonText:t("browse"),onChange:(j,S)=>{o(S),x.onChange(j)}})})}),h!==Rs&&e.jsx(nn,{hidePassword:i,isSaml:s})]})},ci=({clientId:s,save:n,toggleDialog:i})=>{const{t}=k("clients"),a=Oe({defaultValues:{keyAlias:s},mode:"onChange"}),{handleSubmit:o,formState:{isValid:l}}=a;return e.jsxs(ze,{variant:it.medium,title:t("generateKeys"),isOpen:!0,onClose:i,actions:[e.jsx(P,{id:"modal-confirm","data-testid":"confirm",isDisabled:!l,onClick:()=>{o(u=>{n(u),i()})()},children:t("generate")},"confirm"),e.jsx(P,{id:"modal-cancel","data-testid":"cancel",variant:fe.link,onClick:()=>{i()},children:t("common:cancel")},"cancel")],children:[e.jsx(Le,{children:e.jsx(me,{children:t("clients-help:generateKeysDescription")})}),e.jsx(De,{...a,children:e.jsx(At,{})})]})},di=({save:s,toggleDialog:n})=>{const{t:i}=k("clients"),t=Oe(),{control:a,handleSubmit:o}=t,[l,u]=c.useState(!1),r=He().cryptoInfo?.supportedKeystoreTypes??[],m=r.concat(["Certificate PEM","Public Key PEM","JSON Web Key Set"]),h=Ze({control:a,name:"keystoreFormat",defaultValue:m[0]});return e.jsxs(ze,{variant:it.medium,title:i("generateKeys"),isOpen:!0,onClose:n,actions:[e.jsx(P,{id:"modal-confirm","data-testid":"confirm",onClick:()=>{o(p=>{s(p),n()})()},children:i("import")},"confirm"),e.jsx(P,{id:"modal-cancel","data-testid":"cancel",variant:fe.link,onClick:()=>{n()},children:i("common:cancel")},"cancel")],children:[e.jsx(Le,{children:e.jsx(me,{children:i("clients-help:generateKeysDescription")})}),e.jsxs(ye,{className:"pf-u-pt-lg",children:[e.jsx(b,{label:i("archiveFormat"),labelIcon:e.jsx(C,{helpText:i("clients-help:archiveFormat"),fieldLabelId:"clients:archiveFormat"}),fieldId:"archiveFormat",children:e.jsx(N,{name:"keystoreFormat",control:a,defaultValue:m[0],render:({field:p})=>e.jsx(J,{toggleId:"archiveFormat",onToggle:u,onSelect:(d,x)=>{p.onChange(x),u(!1)},selections:p.value,variant:G.single,"aria-label":i("archiveFormat"),isOpen:l,children:m.map(d=>e.jsx(z,{selected:d===p.value,value:d},d))})})}),r.includes(h)&&e.jsx(De,{...t,children:e.jsx(nn,{hidePassword:!0})}),e.jsx(b,{label:i("importFile"),fieldId:"importFile",children:e.jsx(N,{name:"file",control:a,defaultValue:{filename:""},render:({field:p})=>e.jsx(Js,{id:"importFile",value:p.value.value,filename:p.value.filename,onChange:(d,x)=>p.onChange({value:d,filename:x})})})})]})]})},_t="jwt.credential",ui=({clientId:s,save:n,hasConfigureAccess:i})=>{const{t}=k("clients"),{control:a,register:o,getValues:l,formState:{isDirty:u}}=X(),{addAlert:r,addError:m}=oe(),[h,p]=c.useState(),[d,x,j]=be(),[S,y,g]=be(),[M,U]=c.useState(0),Q=()=>U(M+1),R=Ze({control:a,name:O("attributes.use.jwks.url"),defaultValue:"false"});ie(()=>A.clients.getKeyInfo({id:s,attr:_t}),w=>p(w),[M]);const E=async w=>{try{const I=await A.clients.generateAndDownloadKey({id:s,attr:_t},w);et.saveAs(new Blob([I],{type:"application/octet-stream"}),`keystore.${an(w.format??"")}`),r(t("generateSuccess"),Y.success),Q()}catch(I){m("clients:generateError",I)}},H=async w=>{try{const I=new FormData,{file:f,...v}=w;for(const[q,_]of Object.entries(v))I.append(q,_);I.append("file",f.value),await A.clients.uploadCertificate({id:s,attr:_t},I),r(t("importSuccess"),Y.success),Q()}catch(I){m("clients:importError",I)}};return e.jsxs(xe,{variant:"light",className:"keycloak__form",children:[d&&e.jsx(ci,{clientId:l("clientId"),toggleDialog:x,save:E}),S&&e.jsx(di,{toggleDialog:y,save:H}),e.jsxs(Ct,{isFlat:!0,children:[e.jsx(na,{children:e.jsx(aa,{children:t("jwksUrlConfig")})}),e.jsx(Ye,{children:e.jsx(Le,{children:e.jsx(me,{children:t("keysIntro")})})}),e.jsx(Ye,{children:e.jsxs(ce,{role:"manage-clients",fineGrainedAccess:i,isHorizontal:!0,children:[e.jsx(b,{hasNoPaddingTop:!0,label:t("useJwksUrl"),fieldId:"useJwksUrl",labelIcon:e.jsx(C,{helpText:t("clients-help:useJwksUrl"),fieldLabelId:"clients:useJwksUrl"}),children:e.jsx(N,{name:O("attributes.use.jwks.url"),control:a,render:({field:w})=>e.jsx(de,{"data-testid":"useJwksUrl",id:"useJwksUrl-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:w.value==="true",onChange:I=>w.onChange(`${I}`),"aria-label":t("useJwksUrl")})})}),R!=="true"&&(h?e.jsx(Yt,{plain:!0,keyInfo:h}):"No client certificate configured"),R==="true"&&e.jsx(b,{label:t("jwksUrl"),fieldId:"jwksUrl",labelIcon:e.jsx(C,{helpText:t("clients-help:jwksUrl"),fieldLabelId:"clients:jwksUrl"}),children:e.jsx(pe,{id:"jwksUrl",type:"url",...o(O("attributes.jwks.url"))})}),e.jsxs(Ie,{children:[e.jsx(P,{"data-testid":"saveKeys",onClick:n,isDisabled:!u,children:t("common:save")}),e.jsx(P,{"data-testid":"generate",variant:"secondary",onClick:()=>j(!0),children:t("generateNewKeys")}),e.jsx(P,{"data-testid":"import",variant:"secondary",onClick:()=>g(!0),isDisabled:R==="true",children:t("import")})]})]})})]})]})},pi=({clientId:s,close:n})=>{const{t:i}=k("clients"),{realm:t}=he(),{addAlert:a,addError:o}=oe(),l=Oe({defaultValues:{realmAlias:t}}),u=async r=>{try{const m=await A.clients.downloadKey({id:s,attr:"saml.signing"},r);et.saveAs(new Blob([m],{type:"application/octet-stream"}),`keystore.${an(r.format??"")}`),a(i("samlKeysExportSuccess")),n()}catch(m){o("clients:samlKeysExportError",m)}};return e.jsx(ze,{variant:"medium",title:i("exportSamlKeyTitle"),isOpen:!0,onClose:n,actions:[e.jsx(P,{id:"modal-confirm","data-testid":"confirm",type:"submit",form:"export-saml-key-form",children:i("common:export")},"confirm"),e.jsx(P,{id:"modal-cancel","data-testid":"cancel",variant:"link",onClick:()=>{n()},children:i("common:cancel")},"cancel")],children:e.jsx(ye,{id:"export-saml-key-form",className:"pf-u-pt-lg",onSubmit:l.handleSubmit(u),children:e.jsx(De,{...l,children:e.jsx(At,{isSaml:!0})})})})},ln=async(s,n,i,t)=>{try{const a=new FormData,{file:o,...l}=s;Object.entries(l).map(([u,r])=>a.append(u==="format"?"keystoreFormat":u,r.toString())),a.append("file",o),await A.clients.uploadKey({id:n,attr:i},a),t()}catch(a){t(a)}},mi=({id:s,attr:n,onClose:i,onCancel:t})=>{const{t:a}=k("clients"),[o,l]=c.useState(!1),[u,r]=c.useState(),m=Oe({mode:"onChange"}),{handleSubmit:h,formState:{isValid:p}}=m,{addAlert:d,addError:x}=oe(),j=y=>{ln(y,s,n,g=>{g?x("clients:importError",g):d(a("importSuccess"),Y.success)})},S=async()=>{try{const y=await A.clients.generateKey({id:s,attr:n});r(y),et.saveAs(new Blob([y.privateKey],{type:"application/octet-stream"}),"private.key"),d(a("generateSuccess"),Y.success)}catch(y){x("clients:generateError",y)}};return e.jsx(ze,{variant:it.medium,"aria-labelledby":a("enableClientSignatureRequired"),header:e.jsxs(Le,{children:[e.jsx(ht,{headingLevel:"h1",children:a("enableClientSignatureRequired")}),e.jsx(me,{children:a("enableClientSignatureRequiredExplain")})]}),isOpen:!0,onClose:i,actions:[e.jsx(P,{id:"modal-confirm","data-testid":"confirm",variant:"primary",isDisabled:!p&&!u,onClick:()=>{o&&h(j)(),i()},children:a("confirm")},"confirm"),e.jsx(P,{id:"modal-cancel","data-testid":"cancel",variant:fe.link,onClick:t,children:a("common:cancel")},"cancel")],children:e.jsxs(De,{...m,children:[e.jsxs(ye,{isHorizontal:!0,children:[e.jsx(b,{label:a("selectMethod"),fieldId:"selectMethod",hasNoPaddingTop:!0,children:e.jsxs(la,{children:[e.jsx(rs,{children:e.jsx(gt,{isChecked:!o,name:"selectMethodType",onChange:()=>l(!1),label:a("selectMethodType.generate"),id:"selectMethodType-generate"})}),e.jsx(rs,{children:e.jsx(gt,{isChecked:o,name:"selectMethodType",onChange:()=>l(!0),label:a("selectMethodType.import"),id:"selectMethodType-import"})})]})}),!o&&e.jsx(b,{label:a("certificate"),fieldId:"certificate",labelIcon:e.jsx(C,{helpText:a("clients-help:certificate"),fieldLabelId:"clients:certificate"}),children:e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{isFilled:!0,children:e.jsx(Yt,{plain:!0,keyInfo:u})}),e.jsx(Ce,{children:e.jsx(P,{variant:"secondary","data-testid":"generate",onClick:S,children:a("generate")})})]})})]}),o&&e.jsx(At,{useFile:!0})]})})},hi=({id:s,attr:n,onClose:i})=>{const{t}=k("clients"),a=X(),{handleSubmit:o}=a,{addAlert:l,addError:u}=oe(),r=m=>{ln(m,s,n,h=>{h?u("clients:importError",h):l(t("importSuccess"),Y.success)})};return e.jsx(Gt,{open:!0,toggleDialog:i,continueButtonLabel:"clients:import",titleKey:"clients:importKey",onConfirm:()=>{o(r)(),i()},children:e.jsx(De,{...a,children:e.jsx(At,{useFile:!0,hasPem:!0})})})},Lt=["saml.signing","saml.encryption"],Xe={"saml.signing":{name:O("attributes.saml.client.signature"),title:"signingKeysConfig",key:"clientSignature"},"saml.encryption":{name:O("attributes.saml.encrypt"),title:"encryptionKeysConfig",key:"encryptAssertions"}},xi=({clientId:s,keyInfo:n,attr:i,onChanged:t,onGenerate:a,onImport:o})=>{const{t:l}=k("clients"),{control:u,watch:r}=X(),m=Xe[i].title,h=Xe[i].key,p=Xe[i].name,[d,x]=be(),j=r(p);return e.jsxs(e.Fragment,{children:[d&&e.jsx(pi,{clientId:s,close:x}),e.jsxs(ia,{title:l(m),className:"kc-form-panel__panel",children:[e.jsx(Le,{className:"pf-u-pb-lg",children:e.jsx(me,{children:l(`${m}Explain`)})}),e.jsx(ce,{role:"manage-clients",isHorizontal:!0,children:e.jsx(b,{labelIcon:e.jsx(C,{helpText:l(`clients-help:${h}`),fieldLabelId:`clients:${h}`}),label:l(h),fieldId:h,hasNoPaddingTop:!0,children:e.jsx(N,{name:p,control:u,defaultValue:"false",render:({field:S})=>e.jsx(de,{"data-testid":h,id:h,label:l("common:on"),labelOff:l("common:off"),isChecked:S.value==="true",onChange:y=>{const g=y.toString();g==="true"?(t(i),S.onChange(g)):a(i,!1)},"aria-label":l(h)})})})})]}),n?.certificate&&j==="true"&&e.jsx(Ct,{isFlat:!0,children:e.jsx(Ye,{className:"kc-form-panel__body",children:e.jsxs(ye,{isHorizontal:!0,children:[e.jsx(Yt,{keyInfo:n}),e.jsxs(Ie,{children:[e.jsx(P,{variant:"secondary",onClick:()=>a(i,!0),children:l("regenerate")}),e.jsx(P,{variant:"secondary",onClick:()=>o(i),children:l("importKey")}),e.jsx(P,{variant:"tertiary",onClick:x,children:l("common:export")})]})]})})})]})},gi=({clientId:s,save:n})=>{const{t:i}=k("clients"),[t,a]=c.useState(),[o,l]=c.useState(),[u,r]=c.useState(),[m,h]=c.useState(),[p,d]=c.useState(0),{setValue:x}=X(),{addAlert:j,addError:S}=oe();ie(()=>Promise.all(Lt.map(E=>A.clients.getKeyInfo({id:s,attr:E}))),E=>l(E),[p]);const y=async E=>{const H=Lt.indexOf(E);try{const w=[...o||[]];w[H]=await A.clients.generateKey({id:s,attr:E}),l(w),et.saveAs(new Blob([w[H].privateKey],{type:"application/octet-stream"}),"private.key"),j(i("generateSuccess"),Y.success)}catch(w){S("clients:generateError",w)}},g=u?Xe[u].key:"",[M,U]=Te({titleKey:i("disableSigning",{key:i(g)}),messageKey:i("disableSigningExplain",{key:i(g)}),continueButtonLabel:"common:yes",cancelButtonLabel:"common:no",onConfirm:()=>{x(Xe[u].name,"false"),n()}}),[Q,R]=Te({titleKey:"clients:reGenerateSigning",messageKey:"clients:reGenerateSigningExplain",continueButtonLabel:"common:yes",cancelButtonLabel:"common:no",onConfirm:()=>{y(u)}});return e.jsxs(xe,{variant:"light",className:"keycloak__form",children:[t&&e.jsx(mi,{id:s,attr:t,onClose:()=>{a(void 0),n(),d(p+1)},onCancel:()=>{x(Xe[u].name,"false"),a(void 0)}}),e.jsx(U,{}),e.jsx(R,{}),Lt.map((E,H)=>e.jsxs(c.Fragment,{children:[m===E&&e.jsx(hi,{id:s,attr:E,onClose:()=>h(void 0)}),e.jsx(xi,{clientId:s,keyInfo:o?.[H],attr:E,onChanged:a,onGenerate:(w,I)=>{r(w),I?Q():M()},onImport:()=>h(E)})]},E))]})},vt="dedicated",ji=({clientId:s,refresh:n,fineGrainedAccess:i,...t})=>{const{t:a}=k("clients"),{addAlert:o,addError:l}=oe(),{hasAccess:u}=Pe(),r=h=>h.id===vt,m=u("manage-clients")||i;return e.jsx(ma,{isDisabled:r(t)||!m,clientScope:t,type:t.type,onSelect:async h=>{try{await ha(s,t,t.type,h),o(a("clientScopeSuccess"),Y.success),n()}catch(p){l("clients:clientScopeError",p)}}})},fi=({clientId:s,protocol:n,clientName:i,fineGrainedAccess:t})=>{const{t:a}=k("clients"),{addAlert:o,addError:l}=oe(),{realm:u}=he(),r=$s(),[m,h]=c.useState("name"),[p,d]=c.useState(cs.none),[x,j]=c.useState(!1),[S,y]=c.useState(),[g,M]=c.useState([]),U=D=>M(D.filter(({id:K})=>K!==vt)),[Q,R]=c.useState(!1),[E,H]=c.useState(0),w=()=>H(E+1),I=D=>D.id===vt,{hasAccess:f}=Pe(),v=f("manage-clients")||t,q=f("view-clients")||t,_=async(D,K,le)=>{const Se=await A.clients.listDefaultClientScopes({id:s}),ee=await A.clients.listOptionalClientScopes({id:s}),$=await A.clientScopes.find(),te=ue=>$.find(T=>ue===T.id),ke=ee.map(ue=>{const T=te(ue.id);return{...ue,type:us.optional,description:T?.description}}),rt=Se.map(ue=>{const T=te(ue.id);return{...ue,type:us.default,description:T?.description}}),Ne=[...ke,...rt],ct=Ne.map(ue=>ue.name);y($.filter(ue=>!ct.includes(ue.name)).filter(ue=>ue.protocol===n));const dt=m==="name"?da(le):ua(p),$e=Number(D),We=r(Ne.filter(dt),Ws("name"));return q&&We.unshift({id:vt,name:a("dedicatedScopeName",{clientName:i}),type:cs.none,description:a("dedicatedScopeDescription")}),We.slice($e,$e+Number(K))},[L,V]=Te({titleKey:a("client-scopes:deleteClientScope",{count:g.length,name:g[0]?.name}),messageKey:"client-scopes:deleteConfirm",continueButtonLabel:"common:delete",continueButtonVariant:fe.danger,onConfirm:async()=>{try{await ds(s,g[0],g[0].type),o(a("clientScopeRemoveSuccess"),Y.success),w()}catch(D){l("clients:clientScopeRemoveError",D)}}});return e.jsxs(e.Fragment,{children:[S&&e.jsx(Hn,{clientScopes:S,clientName:i,open:x,toggleDialog:()=>j(!x),onAdd:async D=>{try{await Promise.all(D.map(async K=>await pa(s,K.scope,K.type))),o(a("clientScopeSuccess"),Y.success),w()}catch(K){l("clients:clientScopeError",K)}}}),e.jsx(kt,{loader:_,ariaLabelKey:`clients:clientScopeList-${E}`,searchPlaceholderKey:m==="name"?"clients:searchByName":void 0,canSelectAll:!0,isPaginated:!0,isSearching:m==="type",onSelect:D=>U([...D]),searchTypeComponent:e.jsx(oa,{searchType:m,onSelect:D=>h(D)}),toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(ra,{searchType:m,type:p,onSelect:D=>h(D),onType:D=>{d(D),w()}}),v&&e.jsxs(e.Fragment,{children:[e.jsx(V,{}),e.jsx(je,{children:e.jsx(P,{onClick:()=>j(!0),children:a("addClientScope")})}),e.jsx(je,{children:e.jsx(ca,{clientId:s,selectedRows:g,refresh:w})}),e.jsx(je,{children:e.jsx(Ut,{toggle:e.jsx(yn,{onToggle:()=>R(!Q)}),isOpen:Q,isPlain:!0,dropdownItems:[e.jsx(Qe,{isDisabled:g.length===0,onClick:async()=>{try{await Promise.all(g.map(D=>ds(s,{...D},D.type))),R(!1),U([]),o(a("clients:clientScopeRemoveSuccess")),w()}catch(D){l("clients:clientScopeRemoveError",D)}},children:a("common:remove")},"deleteAll")]})})]})]}),columns:[{name:"name",displayKey:"clients:assignedClientScope",cellRenderer:D=>I(D)?e.jsx(ge,{to:bn({realm:u,clientId:s}),children:D.name}):D.name},{name:"type",displayKey:"clients:assignedType",cellRenderer:D=>e.jsx(ji,{clientId:s,refresh:w,...D})},{name:"description"}],actions:v?[{title:a("common:remove"),onRowClick:async D=>(U([D]),L(),!0)}]:[],emptyState:e.jsx(we,{message:a("clients:emptyClientScopes"),instructions:a("clients:emptyClientScopesInstructions"),primaryActionText:a("clients:emptyClientScopesPrimaryAction"),onPrimaryAction:()=>j(!0)})},E)]})},Dt=({text:s,user:n,label:i})=>{const{t}=k("clients");return n?e.jsx(Qs,{id:i,actions:e.jsx(Ys,{children:e.jsx(sn,{id:"code",text:s,label:i})}),children:e.jsx(at,{id:`text-area-${i}`,rows:20,value:s})}):e.jsxs(Gs,{variant:"large",id:i,children:[e.jsx(ht,{headingLevel:"h2",size:"lg",children:t(`${i}No`)}),e.jsx(Hs,{children:t(`${i}IsDisabled`)})]})};const yi=({protocolMappers:s})=>{const[n,i]=c.useState(0);return c.useEffect(()=>{i(n+1)},[s]),e.jsx(kt,{loader:()=>Promise.resolve(s),ariaLabelKey:"clients:effectiveProtocolMappers",searchPlaceholderKey:"clients:searchForProtocol",columns:[{name:"mapperName",displayKey:"common:name"},{name:"containerName",displayKey:"clients:parentClientScope"},{name:"type.category",displayKey:"common:category"},{name:"type.priority",displayKey:"common:priority"}]},n)},bi=({effectiveRoles:s})=>{const[n,i]=c.useState(0);return c.useEffect(()=>{i(n+1)},[s]),e.jsx(kt,{loader:()=>Promise.resolve(s),ariaLabelKey:"client:effectiveRoleScopeMappings",searchPlaceholderKey:"clients:searchForRole",columns:[{name:"name",displayKey:"clients:role"},{name:"containerId",displayKey:"clients:origin"}]},n)},Si=({clientId:s,protocol:n})=>{const i="openid",{t}=k("clients"),{enabled:a}=As(),{realm:o}=he(),l=He().protocolMapperTypes[n],[u,r]=c.useState([]),[m,h]=c.useState(!1),[p,d]=c.useState([i]),[x,j]=c.useState(0),[S,y]=c.useState(""),g=()=>y(`${new Date().getTime()}`),[M,U]=c.useState([]),[Q,R]=c.useState([]),[E,H]=c.useState(""),[w,I]=c.useState(""),[f,v]=c.useState(""),q=c.useRef(null),_=c.useRef(null),L=c.useRef(null),V=c.useRef(null),D=c.useRef(null),K=Oe(),{hasAccess:le}=Pe(),Se=le("view-users");return ie(()=>A.clients.listOptionalClientScopes({id:s}),ee=>r(ee),[]),ie(async()=>{const ee=p.join(" "),$=await A.clients.evaluatePermission({id:s,roleContainer:o,scope:ee,type:"granted"});return{mapperList:await A.clients.evaluateListProtocolMapper({id:s,scope:ee}),effectiveRoles:$}},({mapperList:ee,effectiveRoles:$})=>{U($),ee.map(te=>{te.type=l.filter(ke=>ke.id===te.protocolMapper)[0]}),R(ee),g()},[p]),ie(async()=>{const ee=p.join(" "),$=K.getValues("user");return $?await Promise.all([A.clients.evaluateGenerateAccessToken({id:s,userId:$[0],scope:ee}),A.clients.evaluateGenerateUserInfo({id:s,userId:$[0],scope:ee}),A.clients.evaluateGenerateIdToken({id:s,userId:$[0],scope:ee})]):[]},([ee,$,te])=>{H(Je(ee)),I(Je($)),v(Je(te))},[K.getValues("user"),p]),e.jsxs(e.Fragment,{children:[e.jsxs(xe,{variant:"light",children:[a&&e.jsx(Le,{className:"keycloak__section_intro__help",children:e.jsxs(me,{children:[e.jsx(ga,{})," ",t("clients-help:evaluateExplain")]})}),e.jsxs(ye,{isHorizontal:!0,children:[e.jsx(b,{label:t("scopeParameter"),fieldId:"scopeParameter",labelIcon:e.jsx(C,{helpText:t("clients-help:scopeParameter"),fieldLabelId:"clients:scopeParameter"}),children:e.jsxs(tt,{hasGutter:!0,children:[e.jsx(Ce,{isFilled:!0,children:e.jsx(J,{toggleId:"scopeParameter",variant:G.typeaheadMulti,typeAheadAriaLabel:t("scopeParameter"),onToggle:()=>h(!m),isOpen:m,selections:p,onSelect:(ee,$)=>{const te=$;p.includes(te)?te!==i&&d(p.filter(ke=>ke!==te)):d([...p,te])},"aria-labelledby":t("scopeParameter"),placeholderText:t("scopeParameterPlaceholder"),children:u.map((ee,$)=>e.jsx(z,{value:ee.name},$))})}),e.jsx(Ce,{children:e.jsx(Ds,{className:"keycloak__scopes_evaluate__clipboard-copy",children:p.join(" ")})})]})}),Se&&e.jsx(De,{...K,children:e.jsx(qs,{name:"user",label:"users",helpText:t("clients-help:user"),defaultValue:"",variant:G.typeahead,isRequired:!0})})]})]}),e.jsxs(ja,{hasGutter:!0,className:"keycloak__scopes_evaluate__tabs",children:[e.jsxs(ps,{span:8,children:[e.jsx(pt,{"aria-labelledby":"pf-tab-0-effectiveProtocolMappers",eventKey:0,id:"effectiveProtocolMappers",ref:q,children:e.jsx(yi,{protocolMappers:Q})}),e.jsx(pt,{"aria-labelledby":"pf-tab-0-effectiveRoleScopeMappings",eventKey:1,id:"effectiveRoleScopeMappings",ref:_,hidden:!0,children:e.jsx(bi,{effectiveRoles:M})}),e.jsx(pt,{"aria-labelledby":t("generatedAccessToken"),eventKey:2,id:"tab-generated-access-token",ref:L,hidden:!0,children:e.jsx(Dt,{text:E,user:K.getValues("user"),label:"generatedAccessToken"})}),e.jsx(pt,{"aria-labelledby":t("generatedIdToken"),eventKey:3,id:"tab-generated-id-token",ref:V,hidden:!0,children:e.jsx(Dt,{text:f,user:K.getValues("user"),label:"generatedIdToken"})}),e.jsx(pt,{"aria-labelledby":t("generatedUserInfo"),eventKey:4,id:"tab-generated-user-info",ref:D,hidden:!0,children:e.jsx(Dt,{text:w,user:K.getValues("user"),label:"generatedUserInfo"})})]}),e.jsx(ps,{span:4,children:e.jsxs(xa,{id:"tabs",isVertical:!0,activeKey:x,onSelect:(ee,$)=>j($),children:[e.jsx(se,{id:"effectiveProtocolMappers","aria-controls":"effectiveProtocolMappers",eventKey:0,title:e.jsxs(ne,{children:[t("effectiveProtocolMappers")," ",e.jsx(C,{fieldLabelId:"clients:effectiveProtocolMappers",helpText:t("clients-help:effectiveProtocolMappers"),noVerticalAlign:!1,unWrap:!0})]}),tabContentRef:q}),e.jsx(se,{id:"effectiveRoleScopeMappings","aria-controls":"effectiveRoleScopeMappings",eventKey:1,title:e.jsxs(ne,{children:[t("effectiveRoleScopeMappings")," ",e.jsx(C,{fieldLabelId:"clients:effectiveRoleScopeMappings",helpText:t("clients-help:effectiveRoleScopeMappings"),noVerticalAlign:!1,unWrap:!0})]}),tabContentRef:_}),e.jsx(se,{id:"generatedAccessToken","aria-controls":"generatedAccessToken",eventKey:2,title:e.jsxs(ne,{children:[t("generatedAccessToken")," ",e.jsx(C,{fieldLabelId:"clients:generatedAccessToken",helpText:t("clients-help:generatedAccessToken"),noVerticalAlign:!1,unWrap:!0})]}),tabContentRef:L}),e.jsx(se,{id:"generatedIdToken","aria-controls":"generatedIdToken",eventKey:3,title:e.jsxs(ne,{children:[t("generatedIdToken")," ",e.jsx(C,{fieldLabelId:"clients:generatedIdToken",helpText:t("clients-help:generatedIdToken"),noVerticalAlign:!1,unWrap:!0})]}),tabContentRef:V}),e.jsx(se,{id:"generatedUserInfo","aria-controls":"generatedUserInfo",eventKey:4,title:e.jsxs(ne,{children:[t("generatedUserInfo")," ",e.jsx(C,{fieldLabelId:"clients:generatedUserInfo",helpText:t("clients-help:generatedUserInfo"),noVerticalAlign:!1,unWrap:!0})]}),tabContentRef:D})]},S)})]})]})};const vi=({client:s})=>{const{t:n}=k("clients"),{addAlert:i,addError:t}=oe(),{realm:a}=he(),[o,l]=c.useState(),{hasAccess:u}=Pe(),r=u("manage-clients");ie(()=>A.clients.getServiceAccountUser({id:s.id}),h=>l(h),[]);const m=async h=>{try{const p=h.filter(d=>d.client===void 0).map(d=>d.role).flat();await A.users.addRealmRoleMappings({id:o?.id,roles:p}),await Promise.all(h.filter(d=>d.client!==void 0).map(d=>A.users.addClientRoleMappings({id:o?.id,clientUniqueId:d.client.id,roles:[d.role]}))),i(n("roleMappingUpdatedSuccess"),Y.success)}catch(p){t("clients:roleMappingUpdatedError",p)}};return o?e.jsxs(e.Fragment,{children:[e.jsxs(xe,{className:"pf-u-pb-0",children:[e.jsx(Ls,{className:"pf-c-alert__icon keycloak--service-account--info-text"}),e.jsx("span",{className:"pf-u-pl-sm",children:e.jsxs(zs,{i18nKey:"clients-help:manageServiceAccountUser",children:["",e.jsx(ge,{to:Sn({realm:a,id:o.id,tab:"settings"}),children:{link:o.username}})]})})]}),e.jsx(fa,{name:s.clientId,id:o.id,type:"users",isManager:r||s.access?.configure,save:m})]}):e.jsx(Ee,{})},Ci=({onChange:s,value:n,save:i,client:t,toggleDownloadDialog:a,toggleDeleteDialog:o})=>{const{t:l}=k("clients"),[u,r]=Te({titleKey:"clients:disableConfirmTitle",messageKey:"clients:disableConfirm",continueButtonLabel:"common:disable",onConfirm:()=>{s(!n),i()}}),m=c.useMemo(()=>{const x=$n(l,t.protocol??"openid-connect");return[{text:t.bearerOnly?e.jsx(qt,{"data-testid":"bearer-only-explainer-tooltip",content:l("explainBearerOnly"),children:e.jsx(Nt,{"data-testid":"bearer-only-explainer-label",icon:e.jsx(Ls,{}),children:x})}):e.jsx(Nt,{children:x})}]},[t,l]),{hasAccess:h}=Pe(),p=h("manage-clients")||t.access?.configure,d=[e.jsx(Qe,{onClick:a,children:l("downloadAdapterConfig")},"download"),e.jsx(Qe,{onClick:()=>In(t),children:l("common:export")},"export"),...!St(t)&&p?[e.jsx(Ue,{},"divider"),e.jsx(Qe,{"data-testid":"delete-client",onClick:o,children:l("common:delete")},"delete")]:[]];return e.jsxs(e.Fragment,{children:[e.jsx(r,{}),e.jsx(_n,{titleKey:t.clientId,subKey:"clients:clientsExplain",badges:m,divider:!1,isReadOnly:!p,helpTextKey:"clients-help:enableDisable",dropdownItems:d,isEnabled:n,onToggle:x=>{x?(s(x),i()):u()}})]})};function to(){const{t:s}=k("clients"),{addAlert:n,addError:i}=oe(),{realm:t}=he(),{hasAccess:a}=Pe(),o=Ln(),l=a("manage-authorization"),u=a("manage-clients"),r=a("view-clients"),m=a("view-users"),h=o(Dn.AdminFineGrainedAuthz)&&l,p=st(),[d,x]=be(),[j,S]=be(),y=Oe(),{clientId:g}=Ht(),[M,U]=c.useState(0),Q=Ze({control:y.control,name:"clientAuthenticatorType",defaultValue:"client-secret"}),[R,E]=c.useState(),H=async()=>{const Z=await A.clients.listRoles({id:g});return Es(Z,ut=>ut.name?.toUpperCase())},w=Z=>Ot(ws({realm:t,clientId:g,tab:Z})),I=w("settings"),f=w("keys"),v=w("credentials"),q=w("roles"),_=w("clientScopes"),L=w("authorization"),V=w("serviceAccount"),D=w("sessions"),K=w("permissions"),le=w("advanced"),Se=Z=>Ot(ts({realm:t,clientId:g,tab:Z})),ee=Se("setup"),$=Se("evaluate"),te=Z=>Ot(ss({realm:t,clientId:g,tab:Z})),ke=te("settings"),rt=te("resources"),Ne=te("scopes"),ct=te("policies"),dt=te("permissions"),$e=te("evaluate"),We=te("export"),[ue,T]=Te({titleKey:"clients:clientDeleteConfirmTitle",messageKey:"clients:clientDeleteConfirm",continueButtonLabel:"common:delete",continueButtonVariant:fe.danger,onConfirm:async()=>{try{await A.clients.del({id:g}),n(s("clientDeletedSuccess"),Y.success),p(vn({realm:t}))}catch(Z){i("clients:clientDeleteError",Z)}}}),re=Z=>{y.reset({...Z}),kn(Z,y.setValue),Z.attributes?.["acr.loa.map"]&&y.setValue(O("attributes.acr.loa.map"),Object.entries(JSON.parse(Z.attributes["acr.loa.map"])).flatMap(([ut,Et])=>({key:ut,value:Et})))};ie(()=>A.clients.findOne({id:g}),Z=>{if(!Z)throw new Error(s("common:notFound"));E(Rn(Z)),re(Z)},[g,M]);const W=async({confirmed:Z=!1,messageKey:ut="clientSaveSuccess"}={confirmed:!1,messageKey:"clientSaveSuccess"})=>{if(!await y.trigger())return;if(!R?.publicClient&&R?.clientAuthenticatorType!==Q&&!Z){S();return}const Et=ns(y.getValues()),yt=ns(Et);yt.attributes?.["acr.loa.map"]&&(yt.attributes["acr.loa.map"]=JSON.stringify(Object.fromEntries(yt.attributes["acr.loa.map"].filter(({key:Re})=>Re!=="").map(({key:Re,value:on})=>[Re,on]))));try{const Re={...R,...yt};Re.clientId=Re.clientId?.trim(),await A.clients.update({id:g},Re),re(Re),E(Re),n(s(ut),Y.success)}catch(Re){i("clients:clientSaveError",Re)}};return R?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{continueButtonLabel:"common:yes",cancelButtonLabel:"common:no",titleKey:s("changeAuthenticatorConfirmTitle",{clientAuthenticatorType:Q}),open:j,toggleDialog:S,onConfirm:()=>W({confirmed:!0}),children:e.jsx(e.Fragment,{children:s("changeAuthenticatorConfirm",{clientAuthenticatorType:Q})})}),e.jsx(T,{}),d&&e.jsx(ya,{id:R.id,protocol:R.protocol,open:!0,toggleDialog:x}),e.jsx(N,{name:"enabled",control:y.control,defaultValue:!0,render:({field:Z})=>e.jsx(Ci,{value:Z.value,onChange:Z.onChange,client:R,save:W,toggleDeleteDialog:ue,toggleDownloadDialog:x})}),e.jsx(xe,{variant:"light",className:"pf-u-p-0",children:e.jsx(De,{...y,children:e.jsxs(wt,{"data-testid":"client-tabs","aria-label":"client-tabs",isBox:!0,mountOnEnter:!0,children:[e.jsx(se,{id:"settings","data-testid":"clientSettingsTab",title:e.jsx(ne,{children:s("common:settings")}),...I,children:e.jsx(Na,{client:R,save:()=>W(),reset:()=>re(R)})}),(!R.publicClient&&!St(R)||R.protocol==="saml")&&e.jsxs(se,{id:"keys","data-testid":"keysTab",title:e.jsx(ne,{children:s("keys")}),...f,children:[R.protocol==="openid-connect"&&e.jsx(ui,{clientId:g,save:W,hasConfigureAccess:R.access?.configure}),R.protocol==="saml"&&e.jsx(gi,{clientId:g,save:W})]}),!R.publicClient&&!St(R)&&(r||R.access?.configure)&&e.jsx(se,{id:"credentials",title:e.jsx(ne,{children:s("credentials")}),...v,children:e.jsx(oi,{client:R,save:W,refresh:()=>U(M+1)},M)}),e.jsx(se,{id:"roles","data-testid":"rolesTab",title:e.jsx(ne,{children:s("roles")}),...q,children:e.jsx(Pn,{loader:H,paginated:!1,messageBundle:"clients",toCreate:Cn({realm:t,clientId:R.id}),toDetail:Z=>Tn({realm:t,clientId:R.id,id:Z,tab:"details"}),isReadOnly:!(u||R.access?.configure)})}),!St(R)&&!R.bearerOnly&&e.jsx(se,{id:"clientScopes","data-testid":"clientScopesTab",title:e.jsx(ne,{children:s("clientScopes")}),..._,children:e.jsxs(wt,{defaultLocation:ts({realm:t,clientId:g,tab:"setup"}),children:[e.jsx(se,{id:"setup",title:e.jsx(ne,{children:s("setup")}),...ee,children:e.jsx(fi,{clientName:R.clientId,clientId:g,protocol:R.protocol,fineGrainedAccess:R.access?.manage})}),e.jsx(se,{id:"evaluate",title:e.jsx(ne,{children:s("evaluate")}),...$,children:e.jsx(Si,{clientId:g,protocol:R.protocol})})]})}),R.authorizationServicesEnabled&&l&&e.jsx(se,{id:"authorization","data-testid":"authorizationTab",title:e.jsx(ne,{children:s("authorization")}),...L,children:e.jsxs(wt,{mountOnEnter:!0,unmountOnExit:!0,defaultLocation:ss({realm:t,clientId:g,tab:"settings"}),children:[e.jsx(se,{id:"settings","data-testid":"authorizationSettings",title:e.jsx(ne,{children:s("settings")}),...ke,children:e.jsx(ni,{clientId:g})}),e.jsx(se,{id:"resources","data-testid":"authorizationResources",title:e.jsx(ne,{children:s("resources")}),...rt,children:e.jsx(ei,{clientId:g})}),e.jsx(se,{id:"scopes","data-testid":"authorizationScopes",title:e.jsx(ne,{children:s("scopes")}),...Ne,children:e.jsx(ti,{clientId:g})}),e.jsx(se,{id:"policies","data-testid":"authorizationPolicies",title:e.jsx(ne,{children:s("policies")}),...ct,children:e.jsx(Ya,{clientId:g})}),e.jsx(se,{id:"permissions","data-testid":"authorizationPermissions",title:e.jsx(ne,{children:s("common:permissions")}),...dt,children:e.jsx(Ja,{clientId:g})}),e.jsx(se,{id:"evaluate","data-testid":"authorizationEvaluate",title:e.jsx(ne,{children:s("evaluate")}),...$e,children:e.jsx(Ba,{client:R,save:W})}),e.jsx(se,{id:"export","data-testid":"authorizationExport",title:e.jsx(ne,{children:s("common:export")}),...We,children:e.jsx(Ga,{})})]})}),R.serviceAccountsEnabled&&m&&e.jsx(se,{id:"serviceAccount","data-testid":"serviceAccountTab",title:e.jsx(ne,{children:s("serviceAccount")}),...V,children:e.jsx(vi,{client:R})}),e.jsx(se,{id:"sessions","data-testid":"sessionsTab",title:e.jsx(ne,{children:s("sessions")}),...D,children:e.jsx(wa,{client:R})}),h&&(u||R.access?.manage)&&e.jsx(se,{id:"permissions","data-testid":"permissionsTab",title:e.jsx(ne,{children:s("common:permissions")}),...K,children:e.jsx(On,{id:R.id,type:"clients"})}),e.jsx(se,{id:"advanced","data-testid":"advancedTab",title:e.jsx(ne,{children:s("advanced")}),...le,children:e.jsx(Ea,{save:W,client:R})})]})})})]}):e.jsx(Ee,{})}export{to as default};
//# sourceMappingURL=ClientDetails-048733ef.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy