PageSourceSearch

https://keycloak-production-56e7.up.railway.app/resources/5xwjb/ad…/assets/NewPolicyDialog-DeUBI6zO.js

js keycloak-production-56e7.up.railway.app collected 2026-10-03 08:19:34 UTC 35,327 bytes, 2 lines download raw bytes

1import{jsxs as y,jsx as e,Fragment as w}from"react/jsx-runtime";import{Y as et,aT as z,dI as be,_ as ft,dj as gt,db as Ct,dc as yt,dd as vt,da as It,aH as Tt,$ as xe,bm as St,bn as bt,de as xt,aP as Ot,aQ as Pt,u as le,a as E,b4 as B,E as fe,v as ee,aG as U,b5 as N,al as kt,am as Mt,ak as oe,dJ as Dt,ai as he,dK as Rt,dL as $t,cz as tt,bs as nt,dM as At,h as G,d9 as Et,ci as Ee,an as q,a3 as ge,d as wt,b as it,aN as Vt,B as ce,dE as _t,bh as st,bi as Oe,L as ot,bB as at,bS as Nt,aL as Ht,aM as Ft,M as lt,l as rt,T as Lt,C as Ut,ag as Pe,ah as ke,D as we,aV as Le,ar as Ie,bx as Te,Z as te,ae as K,as as Se,ao as j,bt as _e,bo as Ne,a4 as Ce,aj as Gt,cM as qt,a5 as zt,a6 as Ue,b6 as ct,b7 as de,cs as Kt,k as jt,q as Bt,p as Ge,dN as qe,c2 as ze,r as Wt,P as Yt,m as Jt,A as Qt,dF as Xt,H as Zt,I as Ke,K as en}from"./main-CB1rIpj1.js";import*as M from"react";import{useState as x,useRef as tn,useCallback as nn,useEffect as sn,useMemo as pe}from"react";import{u as dt}from"./ConfirmDialog-CiHOGbsW.js";import{F as on}from"./FormAccess-CfigFn8i.js";import{V as an}from"./ViewHeader-ClYsIt-b.js";import{u as ye}from"./useParams-CqRETWd5.js";import{u as He}from"./useIsAdminPermissionsClient-BbOu3jZr.js";import{u as pt,m as ut}from"./useLocaleSort-DtnxBi5R.js";import{C as ln}from"./ClientSelect-8NrxV3lL.js";import{i as rn,P as cn,h as dn}from"./ClientScopeTypes-DssmJgzM.js";import{g as pn}from"./utils-C-TUnOch.js";import{F as je}from"./filter-icon-iGqWfb2-.js";import{G as un,b as mn}from"./GroupPickerDialog-DaOxBnxy.js";import{C as hn}from"./CodeEditor-CXmmzSKw.js";import{D as fn}from"./SwitchControl-DX9akl-B.js";import{A as gn,a as Cn,S as yn}from"./RoleMapping-CWNLXsf4.js";import{d as Me,D as vn}from"./DatePicker-DgO1Desj.js";import{d as In}from"./debounce-DIzQnDhi.js";const X=" AM",Z=" PM",Tn=(n,i,a,d,r,l)=>{const o=[],m=new Date(new Date().setHours(0,0,0,0)),f=m.getDay();for(;m.getDay()===f;){let C=m.getHours(),t=X;i&&(C===0?C=12:C>=12&&(t=Z),C>12&&(C%=12)),C=i?C.toString():C.toString().padStart(2,"0");const p=m.getMinutes().toString().padStart(2,"0"),s=`${C}${a}${p}${i?t:""}`;ht(d,r,s,a,l)&&o.push(s),m.setMinutes(m.getMinutes()+n)}return o},Q=(n,i,a,d,r)=>{const l=new Date(n);
1if(!isNaN(l.getDate())&&(n instanceof Date||n.includes("T"))){const o=d?`${l.getHours()>12?l.getHours()-12:l.getHours()}`:`${l.getHours()}`.padStart(2,"0"),m=`${l.getMinutes()}`.padStart(2,"0"),f=r?`${l.getSeconds()}`.padStart(2,"0"):"",C=f?`${a}${f}`:"";let t="";return d&&l.getHours()>11?t=Z:d&&(t=X),`${o}${a}${m}${C}${t}`}else if(typeof n=="string"&&(n=n.trim(),n!==""&&mt(n,i,a,d))){const[,o,m,f,C=""]=i.exec(n),t=r?`${a}${f??"00"}`:"";let p="";if(d){const s=C.toUpperCase();s===X.toUpperCase().trim()?p=X:s===Z.toUpperCase().trim()?p=Z:p=new Date().getHours()>11?Z:X}return`${o}${a}${m}${t}${p}`}return n.toString()},mt=(n,i,a,d)=>{const r=new Date(n);if(!isNaN(r.getDate())&&n.includes("T"))return!0;const l=parseInt(n.split(a)[0]),o=l>=(d?1:0)&&l<=(d?12:23);return n===""||i.test(n)&&o},Be=(n,i)=>{const a=n.match(i);return a&&a.length?/pm/i.test(a[4])?parseInt(a[1])===12?parseInt(a[1]):parseInt(a[1])+12:/am/i.test(a[4])&&parseInt(a[1])===12?0:parseInt(a[1]):null},We=(n,i)=>{const a=n.match(i);return a&&a.length?parseInt(a[2]):null},Ye=(n,i)=>{var a;const d=(a=n.match(i))===null||a===void 0?void 0:a[3];return d?parseInt(d):null},ht=(n,i,a,d,r)=>{if(a.trim()==="")return!0;const l=De(n,d,r),o=De(a,d,r),m=De(i,d,r);return l<=o&&o<=m},De=(n,i,a)=>{const r=new RegExp(`^\\s*(\\d\\d?)${i}([0-5]\\d)${i}?([0-5]\\d)?\\s*([AaPp][Mm])?\\s*$`).exec(n);if(!r||!r.length)return;let l=r[1].padStart(2,"0");const o=r[2];let m=r[3]?`${i}${r[3]}`:"";!m&&a&&(m=`${i}00`);const f=r[4]||"";return f.toUpperCase()==="PM"&&l!=="12"?l=`${parseInt(l)+12}`:f.toUpperCase()==="AM"&&l==="12"&&(l="00"),`${l}${i}${o}${m}`},Sn={name:"OutlinedClockIcon",height:512,width:512,svgPath:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200zm61.8-104.4l-84.9-61.7c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v141.7l66.8 48.6c5.4 3.9 6.5 11.4 2.6 16.8L334.6 349c-3.9 5.3-11.4 6.5-16.8 2.6z",yOffset:0,xOffset:0},bn=et(Sn),xn={name:"--pf-v5-c-date-picker__input--c-form-control--Width"};class Fe extends M.Component{constructor(i){super(i),this.baseComponentRef=M.createRef(),this.toggleRef=M.createRef(),this.inputRef=M.createRef(),this.menuRef=M.createRef(),this.onDocClick=t=>{var p,s,c,h;const I=(s=(p=this.toggleRef)===null||p===void 0?void 0:p.current)===null||s===void 0?void 0:s.contains(t.target),T=(h=(c=this.menuRef)===null||c===void 0?void 0:c.current)===null||h===void 0?void 0:h.contains(t.target);this.state.isTimeOptionsOpen&&!(I||T)&&this.onToggle(!1)},this.handleGlobalKeys=t=>{var p,s,c,h;const{isTimeOptionsOpen:I,focusedIndex:T,scrollIndex:D}=this.state;!((s=(p=this.inputRef)===null||p===void 0?void 0:p.current)===null||s===void 0)&&s.contains(t.target)?!I&&t.key!==z.Tab&&t.key!==z.Escape?this.onToggle(!0):I&&(t.key===z.Escape||t.key===z.Tab?this.onToggle(!1):t.key===z.Enter?T!==null?(this.focusSelection(T),t.stopPropagation()):this.onToggle(!1):(t.key===z.ArrowDown||t.key===z.ArrowUp)&&(this.focusSelection(D),this.updateFocusedIndex(0),t.preventDefault())):!((h=(c=this.menuRef)===null||c===void 0?void 0:c.current)===null||h===void 0)&&h.contains(t.target)&&(t.key===z.ArrowDown?(this.updateFocusedIndex(1),t.preventDefault()):t.key===z.ArrowUp?(this.updateFocusedIndex(-1),t.preventDefault()):(t.key===z.Escape||t.key===z.Tab)&&(this.inputRef.current.focus(),this.onToggle(!1)))},this.updateFocusedIndex=t=>{this.setState(p=>{const s=this.getOptions().length-1;let c=p.focusedIndex!==null?p.focusedIndex+t:p.scrollIndex+t;return c<0?c=s:c>s&&(c=0),this.scrollToIndex(c),{focusedIndex:c}})},this.getIndexToScroll=t=>this.props.menuAppendTo==="inline"?t>0?t-1:0:t,this.scrollToIndex=t=>{this.getOptions()[t].closest(`.${be.menuContent}`).scrollTop=this.getOptions()[this.getIndexToScroll(t)].offsetTop},this.focusSelection=t=>{var p;const s=t!==-1?t:0;!((p=this.menuRef)===null||p===void 0)&&p.current&&this.getOptions()[s].querySelector(`.${be.menuItem}`).focus()},this.scrollToSelection=t=>{const{delimiter:p,is24Hour:s}=this.props;let c=t.split(this.props.delimiter),h=null;if(c.length<2?(t=`${t}${p}00`,c=t.split(p)):c.length>2&&(t=Q(t,this.state.timeRegex,p,!s,!1),c=t.split(p)),!s&&c.length>1&&c[1].length<2){const T=c[1].length===0?"00":c[1]+"0";t=`${c[0]}${p}${T}${new Date().getHours()>11?Z:X}`}else!s&&c.length>1&&c[1].length===2&&!t.toUpperCase().includes(X.toUpperCase().trim())&&!t.toUpperCase().includes(Z.toUpperCase().trim())&&(t=`${t}${new Date().getHours()>11?Z:X}`);let I=this.getOptions().findIndex(T=>T.textContent===t);if(I!==-1)this.scrollToIndex(I),h=I;else if(c.length===2){let T="";s||(c[1].toUpperCase().includes("P")?T=Z:c[1].toUpperCase().includes("A")&&(T=X)),t=`${c[0]}${p}00${T}`,I=this.getOptions().findIndex(D=>D.textContent===t),I!==-1&&this.scrollToIndex(I)}this.setState({focusedIndex:h,scrollIndex:I})},this.getRegExp=(t=!0)=>{const{is24Hour:p,delimiter:s}=this.props;let c=`\\s*(\\d\\d?)${s}([0-5]\\d)`;return t&&(c+=`${s}
1?([0-5]\\d)?`),new RegExp(`^${c}${p?"":"\\s*([AaPp][Mm])?"}\\s*$`)},this.getOptions=()=>{var t;return!((t=this.menuRef)===null||t===void 0)&&t.current?Array.from(this.menuRef.current.querySelectorAll(`.${be.menuListItem}`)):[]},this.isValidFormat=t=>{if(this.props.validateTime)return this.props.validateTime(t);const{delimiter:p,is24Hour:s,includeSeconds:c}=this.props;return mt(t,this.getRegExp(c),p,!s)},this.isValidTime=t=>{const{delimiter:p,includeSeconds:s}=this.props,{minTimeState:c,maxTimeState:h}=this.state;return ht(c,h,t,p,s)},this.isValid=t=>this.isValidFormat(t)&&this.isValidTime(t),this.onToggle=t=>{this.setState(p=>{const{timeRegex:s,isInvalid:c,timeState:h}=p,{delimiter:I,is24Hour:T,includeSeconds:D,onChange:$}=this.props,R=Q(h,s,I,!T,D);return $&&!t&&R!==h&&$(null,R,Be(R,s),We(R,s),Ye(R,s),this.isValid(R)),{isTimeOptionsOpen:t,timeState:R,isInvalid:t?c:!this.isValid(R)}}),this.props.setIsOpen(t),t||this.inputRef.current.focus()},this.onSelect=t=>{const{timeRegex:p,timeState:s}=this.state,{delimiter:c,is24Hour:h,includeSeconds:I,setIsOpen:T}=this.props,D=Q(t.target.textContent,p,c,!h,I);D!==s&&this.onInputChange(t,D),this.inputRef.current.focus(),this.setState({isTimeOptionsOpen:!1,isInvalid:!1}),T(!1)},this.onInputClick=t=>{this.state.isTimeOptionsOpen||this.onToggle(!0),t.stopPropagation()},this.onInputChange=(t,p)=>{const{onChange:s}=this.props,{timeRegex:c}=this.state;s&&s(t,p,Be(p,c),We(p,c),Ye(p,c),this.isValid(p)),this.scrollToSelection(p),this.setState({timeState:p})};const{is24Hour:a,delimiter:d,time:r,includeSeconds:l,isOpen:o}=this.props;let{minTime:m,maxTime:f}=this.props;if(m===""){const t=l?`${d}00`:"";m=a?`00${d}00${t}`:`12${d}00${t} AM`}if(f===""){const t=l?`${d}59`:"";f=a?`23${d}59${t}`:`11${d}59${t} PM`}const C=this.getRegExp();this.state={isInvalid:!1,isTimeOptionsOpen:o,timeState:Q(r,C,d,!a,l),focusedIndex:null,scrollIndex:0,timeRegex:C,minTimeState:Q(m,C,d,!a,l),maxTimeState:Q(f,C,d,!a,l)}}componentDidMount(){document.addEventListener("mousedown",this.onDocClick),document.addEventListener("touchstart",this.onDocClick),document.addEventListener("keydown",this.handleGlobalKeys),this.setState({isInvalid:!this.isValid(this.state.timeState)})}componentWillUnmount(){document.removeEventListener("mousedown",this.onDocClick),document.removeEventListener("touchstart",this.onDocClick),document.removeEventListener("keydown",this.handleGlobalKeys)}componentDidUpdate(i,a){const{timeState:d,isTimeOptionsOpen:r,isInvalid:l,timeRegex:o}=this.state,{time:m,is24Hour:f,delimiter:C,includeSeconds:t,isOpen:p,minTime:s,maxTime:c}=this.props;if(i.isOpen!==p&&this.onToggle(p),r&&!a.isTimeOptionsOpen&&d&&!l&&this.scrollToSelection(d),C!==i.delimiter&&this.setState({timeRegex:this.getRegExp()}),m!==""&&m!==i.time){const h=Q(m,o,C,!f,t);this.setState({timeState:h,isInvalid:!this.isValid(h)})}s!==""&&s!==i.minTime&&this.setState({minTimeState:Q(s,o,C,!f,t)}),c!==""&&c!==i.maxTime&&this.setState({maxTimeState:Q(c,o,C,!f,t)})}render(){const i=this.props,{"aria-label":a,isDisabled:d,className:r,placeholder:l,id:o,menuAppendTo:m,is24Hour:f,invalidFormatErrorMessage:C,invalidMinMaxErrorMessage:t,stepMinutes:p,width:s,delimiter:c,inputProps:h,onChange:I,setIsOpen:T,isOpen:D,time:$,validateTime:R,minTime:_,maxTime:W,includeSeconds:S,zIndex:k}=i,V=ft(i,["aria-label","isDisabled","className","placeholder","id","menuAppendTo","is24Hour","invali
1dFormatErrorMessage","invalidMinMaxErrorMessage","stepMinutes","width","delimiter","inputProps","onChange","setIsOpen","isOpen","time","validateTime","minTime","maxTime","includeSeconds","zIndex"]),{timeState:O,isTimeOptionsOpen:g,isInvalid:H,minTimeState:F,maxTimeState:L}=this.state,ne={[xn.name]:s},ie=Tn(p,!f,c,F,L,S),ae=this.isValidFormat(O),Y=o||gt("time-picker"),se=()=>this.baseComponentRef&&this.baseComponentRef.current?this.baseComponentRef.current.parentElement:null,re=M.createElement(Ct,{ref:this.menuRef,isScrollable:!0},M.createElement(yt,{maxMenuHeight:"200px"},M.createElement(vt,{"aria-label":a},ie.map((b,P)=>M.createElement(It,{onClick:this.onSelect,key:b,id:`${Y}-option-${P}`},b))))),u=M.createElement(Tt,Object.assign({"aria-haspopup":"menu",id:`${Y}-input`,"aria-label":a,validated:H?"error":"default",placeholder:l,value:O||"",type:"text",customIcon:M.createElement(bn,null),onClick:this.onInputClick,onChange:this.onInputChange,autoComplete:"off",isDisabled:d,isExpanded:g,ref:this.inputRef},h));let v;switch(m){case"inline":v=()=>this.toggleRef.current;break;case"parent":v=se;break;default:v=m}return M.createElement("div",{ref:this.baseComponentRef,className:xe(Me.datePicker,r)},M.createElement("div",Object.assign({className:xe(Me.datePickerInput),style:ne},V),M.createElement(St,null,M.createElement(bt,null,M.createElement("div",{id:Y},M.createElement("div",{ref:this.toggleRef,style:{paddingLeft:"0"}},M.createElement(xt,{appendTo:v,trigger:u,triggerRef:this.toggleRef,popper:re,popperRef:this.menuRef,isVisible:g,zIndex:k}))))),H&&M.createElement("div",{className:xe(Me.datePickerHelperText)},M.createElement(Ot,null,M.createElement(Pt,{variant:"error"},ae?t:C)))))}}Fe.displayName="TimePicker";Fe.defaultProps={className:"",isDisabled:!1,time:"",is24Hour:!1,invalidFormatErrorMessage:"Invalid time format",invalidMinMaxErrorMessage:"Invalid time entered",placeholder:"hh:mm",delimiter:":","aria-label":"Time picker",width:"150px",menuAppendTo:"inline",stepMinutes:30,inputProps:{},minTime:"",maxTime:"",isOpen:!1,setIsOpen:()=>{},zIndex:9999};const On={name:"CaretUpIcon",height:512,width:320,svgPath:"M288.662 352H31.338c-17.818 0-26.741-21.543-14.142-34.142l128.662-128.662c7.81-7.81 20.474-7.81 28.284 0l128.662 128.662c12.6 12.599 3.676 34.142-14.142 34.142z",yOffset:0,xOffset:0},Pn=et(On),ue=20,Re="show-more",kn=({name:n,label:i,helpText:a,defaultValue:d,isRequired:r,variant:l="typeaheadMulti"})=>{const{adminClient:o}=le(),{t:m}=E(),{control:f,getValues:C,formState:{errors:t}}=B(),p=C(n),[s,c,h]=fe(),[I,T]=x([]),[D,$]=x([]),[R,_]=x(),[W,S]=x(0),[k,V]=x(!1),[O,g]=x(!1),[H,F]=x(""),[L,ne]=x(""),ie=tn(),ae=nn(In(u=>{S(0),V(!1),g(!1),$([]),_(void 0),ne(u)},500),[]);ee(async()=>p?(await Promise.all(p.map(v=>o.users.findOne({id:v})))).filter(v=>v!==void 0):[],u=>{T(u),l!=="typeaheadMulti"&&F(u[0]?.username||"")},[p]),ee(()=>o.users.find({username:L,first:W,max:ue+1}),u=>{const v=u.length>ue,b=v?u.slice(0,ue):u;$(P=>W===0?b:[...P,...b]),V(v),g(!1)},[L,W]),ee(()=>L?o.users.find({username:L,exact:!0,max:1}):Promise.resolve([]),u=>_(u.at(0)),[L]),sn(()=>{(!p||p.length===0)&&(T([]),F(""))},[p]);const Y=pe(()=>R?[R,...D.filter(u=>u.id!==R.id)]:D,[R,D]),se=pe(()=>[...I,...Y],[I,Y]),re=u=>u.map(v=>e(oe,{value:v.id,selected:p?.includes(v.id),children:v.username},v.id));return y(U,{label:m(i),isRequired:r,labelIcon:e(q,{helpText:a,fieldLabelId:m(i)}),fieldId:n,children:[e(N,{name:n,defaultValue:d,control:f,rules:r&&l==="typeaheadMulti"?{validate:u=>u.length>0}:{required:r},render:({field:u})=>e(kt,{id:n,isScrollable:!0,maxMenuHeight:"300px",onOpenChange:c,toggle:v=>e(he,{"data-testid":n,ref:v,variant:"typeahead",onClick:c,isExpanded:s,isFullWidth:!0,status:t[n]?"danger":void 0,children:y(Rt,{isPlain:!0,children:[e($t,{value:H,onClick:c,onChange:(b,P)=>{h(!0),F(P),ae(P)},autoComplete:"off",innerRef:ie,placeholderText:m("selectAUser"),...u.value&&{"aria-activedescendant":u.value},role:"combobox",isExpanded:s,"aria-controls":"select-create-typeahead-listbox",children:l==="typeaheadMulti"&&Array.isArray(u.value)&&e(tt,{"aria-label":"Current selections",children:u.value.map((b,P)=>e(nt,{onClick:A=>{A.stopPropagation(),u.onChange(u.value.filter(J=>J!==b))},children:se.find(A=>A.id===b)?.username},P))})}),e(At,{children:!!L&&e(G,{variant:"plain",onClick:()=>{ae.cancel(),F(""),S(0),V(!1),g(!1),$([]),_(void 0),ne(""),u.onChange([]),ie.current?.focus()},"aria-label":"Clear input value",children:e(Et,{"aria-hidden":!0})})})]})}),isOpen:s,selected:u.value,onSelect:(v,b)=>{const P=b?.toString();if(P===Re){g(!0),S(A=>A+ue);return}if(l!=="typeaheadMulti"){const A=u.value.includes(P);A?u.onChange([]):u.onChange([P]),F(A?"":se.find(J=>J.id===P)?.username||""),h(!1)}else{const A=u.value.find(J=>J===P)?u.value.filter(J=>J!==P):[...u.value,P];u.onChange(A)}},"aria-label":m(n),children:y(Mt,{children:[re(Y),k&&e(oe,{value:Re,isDisabled:O,"aria-label":m(O?"spinnerLoading":"showMoreUsers"),children:O?y(w,{children:[e(Dt,{size:"sm"})," ",m("spinnerLoading")]}):m("showMore")},Re)]})})}),t[n]&&e(Ee,{message:m("required")})]})},$e=["UNANIMOUS","AFFIRMATIVE","CONSENSUS"],Mn=({helpLabel:n,isDisabled:i=!1,isLimited:a=!1})=>{const{t:d}=E(),{control:r}=B();return e(U,{label:d("decisionStrategy"),labelIcon:e(q,{helpText:d(n||"decisionStrategyHelp"),fieldLabelId:"decisionStrategy"}),fieldId:"decisionStrategy",hasNoPaddingTop:!0,children:e(N,{name:"decisionStrategy","data-testid":"decisionStrategy",defaultValue:$e[0],control:r,render:({field:l})=>e(w,{children:(a?$e.slice(0,2):$e).map(o=>e(ge,{id:o,"data-testid":o,isChecked:l.value===o,isDisabled:i,name:"decisionStrategy",onChange:()=>l.onChange(o),label:d(`decisionStrategies.${o}`),className:"pf-v5-u-mb-md"},o))})})})},Dn={resources:{searchFunction:"listResources",fetchFunction:"getAssociatedResources"},policies:{searchFunction:"listPolicies",fetchFunction:"getAssociatedPolicies"}},Rn=({name:n,clientId:i,permissionId:a,variant:d=Oe.typeaheadMulti,preSelected:r,isRequired:l=!1})=>{const{adminClient:o}=le(),{realm:m}=wt(),{t:f}=E(),C=it(),{control:t,formState:{errors:p,isDirty:s}}=B(),[c,h]=x([]),[I,T]=x(""),[D,$]=x(!1),[R,_]=fe(),[W,S]=x(),[k,V]=x(),O=He(i),[g,H]=x([]),F=Dn[n],L=Vt({control:t,name:n,defaultValue:r?[r]:[]}),ne=u=>({id:"_id"in u?u._id:"id"in u?u.id:void 0,name:u.name,type:u.type});ee(async()=>{const u=Object.assign({id:i,first:0,max:10,permission:"false"},I===""?null:{name:I});return await Promise.all([o.clients.listPolicyProviders({id:i}),o.clients[F.searchFunction](u),a?o.clients[F.fetchFunction]({id:i,permissionId:a}):Promise.resolve([]),r&&n==="resources"?o.clients.getResource({id:i,resourceId:r}):Promise.resolve([])])},([u,...v])=>{S(u.filter(b=>b.type!=="resource"&&b.type!=="scope")),h(v.flat().filter(b=>typeof b!="string").map(ne).filter(({id:b},P,A)=>P===A.findIndex(({id:J})=>b===J)))},[I]),ee(async()=>n==="resources"?await Promise.all((L||[]).map(u=>o.clients.getResource({id:i,resourceId:u}))):await Promise.all((L||[]).map(async u=>o.clients.findOnePolicy({id:i,policyId:u}))),u=>H(u.map(v=>ne(v))),[L]);const[ie,ae]=dt({titleKey:f("unsavedChangesTitle"),messageKey:f("unsavedChangesConfirm"),continueButtonLabel:f("continue"),continueButtonVariant:ce.danger,onConfirm:()=>k?.()}),Y=u=>n==="policies"?at({realm:m,id:i,policyId:u.id,policyType:u.type}):Nt({realm:m,id:i,resourceId:u.id}),se=()=>c.map(u=>e(oe,{value:u.id,children:u.name},u.id)),re=u=>e(tt,{children:g.map(v=>e(nt,{onClick:()=>{u.onChange(u.value?.filter(b=>b!==v.id)||[]),H(g.filter(b=>b.id!==v.id))},children:O?v.name:e(ot,{to:Y(v),onClick:b=>
1{s&&(b.preventDefault(),V(()=>()=>{C(Y(v))}),ie())},children:v.name})},v.id))});return y(w,{children:[e(ae,{}),R&&e(zn,{policyProviders:W,onSelect:u=>{C(_t({id:i,realm:m,policyType:u.type}))},toggleDialog:_}),e(N,{name:n,defaultValue:r?[r]:[],control:t,rules:{validate:u=>!l||u.length>0},render:({field:u})=>e(st,{toggleId:n,variant:d,onToggle:v=>$(v),onFilter:v=>(T(v),se()),onClear:()=>{u.onChange([]),T("")},selections:d===Oe.typeaheadMulti?u.value:g.find(v=>v.id===u.value?.[0])?.name,onSelect:v=>{const b=v.toString();if(d===Oe.typeaheadMulti){const P=u.value?.find(A=>A===b)?u.value.filter(A=>A!==b):[...u.value,b];u.onChange(P)}else{u.onChange([b]);const P=c.find(A=>A.id===b);P&&H([P])}T("")},isOpen:D,"aria-label":f(n),validated:p[n]?"error":"default",typeAheadAriaLabel:f(n),chipGroupComponent:re(u),footer:n==="policies"&&!O?e(G,{variant:"link",isInline:!0,onClick:()=>{s?($(!1),V(()=>_),ie()):_()},children:f("createPolicy")}):void 0,children:se()})})]})},$n=()=>{const{t:n}=E(),{id:i}=ye(),{permissionClientId:a}=ye();return y(w,{children:[e(U,{label:n("applyPolicy"),fieldId:"policies",labelIcon:e(q,{helpText:n("applyPolicyHelp"),fieldLabelId:"policies"}),children:e(Rn,{name:"policies",clientId:a||i})}),e(Mn,{helpLabel:"policyDecisionStagey"})]})},An=()=>{const{t:n}=E();return e(ln,{name:"clients",label:n("clients"),helpText:n("policyClientHelp"),required:!0,defaultValue:[],variant:"typeaheadMulti",clientKey:"id"})},En=({clientScopes:n,clientName:i,open:a,toggleDialog:d,onAdd:r,isClientScopesConditionType:l})=>{const{t:o}=E(),m=Ht(),[f,C]=x(!1),[t,p]=x([]),[s,c]=x("Name"),[h,I]=x("All"),T=m(Ft.OpenId4VCI),[D,$]=fe(),[R,_]=fe(!1),W=pe(()=>h==="OpenID Connect"?n.filter(g=>g.protocol==="openid-connect"):h==="SAML"?n.filter(g=>g.protocol==="saml"):h==="OpenID4VC"?n.filter(g=>g.protocol==="oid4vc"):n,[n,s,h]),S=g=>{const H=t.map(F=>({scope:F,type:g}));r(H),C(!1),d()},k=g=>{g==="Name"?c("Protocol"):g==="Protocol"&&(c("Name"),I("All")),$()},V=g=>{g==="SAML"?I("SAML"):g==="OpenID Connect"?I("OpenID Connect"):g==="OpenID4VC"?I("OpenID4VC"):g==="All"&&I("All"),_()},O=pe(()=>{const g=[e(oe,{value:"SAML",children:o("protocolTypes.saml")},1),e(oe,{value:"OpenID Connect",children:o("protocolTypes.openid-connect")},2)];return T&&g.push(e(oe,{value:"OpenID4VC",children:o("protocolTypes.oid4vc")},3)),g.push(e(oe,{value:"All",children:o("protocolTypes.all")},4)),g},[o,T]);return e(lt,{variant:rt.medium,title:l?o("addClientScope"):o("addClientScopesTo",{clientName:i}),isOpen:a,onClose:d,actions:l?[e(G,{id:"modal-add","data-testid":"confirm",variant:ce.primary,onClick:()=>{const g=t.map(H=>({scope:H}));r(g),d()},isDisabled:t.length===0,children:o("add")},"add"),e(G,{id:"modal-cancel","data-testid":"cancel",variant:ce.link,onClick:()=>{p([]),d()},children:o("cancel")},"cancel")]:[e(Pe,{popperProps:{direction:"up"},onOpenChange:g=>C(g),className:"keycloak__client-scopes-add__add-dropdown",isOpen:f,toggle:g=>e(he,{ref:g,isDisabled:t.length===0,onClick:()=>C(!f),variant:"primary",id:"add-dropdown","data-testid":"add-dropdown",statusIcon:e(Pn,{}),children:o("add")}),children:e(ke,{children:dn(o,S,t)})},"add-dropdown"),e(G,{id:"modal-cancel",variant:ce.link,onClick:()=>{p([]),d()},children:o("cancel")},"cancel")],children:e(Lt,{loader:W,ariaLabelKey:"chooseAMapperType",searchPlaceholderKey:s==="Name"?"searchForClientScope":void 0,isSearching:s!=="Name",searchTypeComponent:e(Pe,{onSelect:()=>{k(s)},onOpenChange:$,toggle:g=>e(he,{ref:g,"data-testid":"filter-type-dropdown",id:"toggle-id-9",onClick:$,icon:e(je,{}),statusIcon:e(Le,{}),children:s}),isOpen:D,children:e(ke,{children:e(we,{"data-testid":"filter-type-dropdown-item",children:o(s==="Name"?"protocol":"name")},"filter-type")})}),toolbarItem:s==="Protocol"&&y(w,{children:[e(Pe,{onSelect:()=>{k(s)},onOpenChange:$,"data-testid":"filter-type-dropdown",toggle:g=>e(he,{ref:g,id:"toggle-id-9",onClick:$,statusIcon:e(Le,{}),icon:e(je,{}),children:s}),isOpen:D,children:e(ke,{children:e(we,{"data-testid":"filter-type-dropdown-item",children:o("name")},"filter-type")})}),e(st,{className:"kc-protocolType-select","aria-label":o("selectOne"),onToggle:_,onSelect:g=>V(g.toString()),selections:h,isOpen:R,children:O})]}),canSelectAll:!0,onSelect:g=>p(g),columns:[{name:"name",cellRenderer:g=>y(w,{children:[g.name," ",rn(g)&&e(cn,{})]})},{name:"protocol",displayKey:"protocol",cellRenderer:g=>pn(o,g.protocol??"openid-connect")},{name:"description"}],emptyState:e(Ut,{message:o("emptyAddClientScopes"),instructions:o("emptyAddClientScopesInstructions")})})})},wn=()=>{const{adminClient:n}=le(),{t:i}=E(),{control:a,getValues:d,setValue:r}=B(),[l,o]=x(!1),[m,f]=x([]),[C,t]=x([]),p=pt();return ee(()=>n.clientScopes.find(),s=>{const c=d("clientScopes");t(c.map(h=>s.find(I=>I.id===h.id))),f(p(s,ut("name")))},[]),y(U,{label:i("clientScopes"),labelIcon:e(q,{helpText:i("clientsClientScopesHelp"),fieldLabelId:"clientScopes"}),fieldId:"clientScopes",children:[e(N,{name:"clientScopes",control:a,defaultValue:[],render:({field:s})=>y(w,{children:[l&&e(En,{clientScopes:m.filter(c=>!s.value.map(h=>
1h.id).includes(c.id)),isClientScopesConditionType:!0,open:l,toggleDialog:()=>o(!l),onAdd:c=>{t([...C,...c.map(h=>h.scope)]),s.onChange([...s.value,...c.map(h=>h.scope).map(h=>({id:h.id,required:!1}))])}}),e(G,{"data-testid":"select-scope-button",variant:"secondary",onClick:()=>{o(!0)},children:i("addClientScopes")})]})}),C.length>0&&y(Ie,{variant:"compact",children:[e(Te,{children:y(te,{children:[e(K,{children:i("clientScopeTitle")}),e(K,{children:i("required")}),e(K,{"aria-hidden":"true"})]})}),e(Se,{children:C.map((s,c)=>y(te,{children:[e(j,{children:s.name}),e(j,{children:e(N,{name:`clientScopes.${c}.required`,defaultValue:!1,control:a,render:({field:h})=>e(_e,{id:"required","data-testid":"standard",name:"required",isChecked:h.value,onChange:h.onChange})})}),e(j,{children:e(G,{variant:"link",className:"keycloak__client-authorization__policy-row-remove",icon:e(Ne,{}),onClick:()=>{r("clientScopes",[...d("clientScopes").filter(h=>h.id!==s.id)]),t([...C.filter(h=>h.id!==s.id)])}})})]},s.id))})]})]})},Vn=()=>{const{adminClient:n}=le(),{t:i}=E(),{control:a,getValues:d,setValue:r}=B(),l=d("groups"),[o,m]=x(!1),[f,C]=x([]);return ee(()=>l&&l.length>0?Promise.all(l.map(t=>n.groups.findOne({id:t.id}))):Promise.resolve([]),t=>{const p=t.filter(s=>s);C(p)},[]),y(w,{children:[e(Ce,{name:"groupsClaim",label:i("groupsClaim"),labelIcon:i("groupsClaimHelp")}),y(U,{label:i("groups"),labelIcon:e(q,{helpText:i("policyGroupsHelp"),fieldLabelId:"groups"}),fieldId:"groups",children:[e(N,{name:"groups",control:a,defaultValue:[],render:({field:t})=>y(w,{children:[o&&e(un,{value:n.groups,children:e(mn,{type:"selectMany",text:{title:"addGroupsToGroupPolicy",ok:"add"},onConfirm:p=>{t.onChange([...t.value||[],...(p||[]).map(({id:s})=>({id:s}))]),C([...f,...p||[]]),m(!1)},onClose:()=>{m(!1)},filterGroups:f})}),e(G,{"data-testid":"select-group-button",variant:"secondary",onClick:()=>{m(!0)},children:i("addGroups")})]})}),f.length>0&&y(Ie,{variant:"compact",children:[e(Te,{children:y(te,{children:[e(K,{children:i("groups")}),e(K,{children:i("extendToChildren")}),e(K,{"aria-hidden":"true"})]})}),e(Se,{children:f.map((t,p)=>y(te,{children:[e(j,{children:t.path}),e(j,{children:e(N,{name:`groups.${p}.extendChildren`,defaultValue:!1,control:a,render:({field:s})=>e(_e,{id:"extendChildren","data-testid":"standard",name:"extendChildren",isChecked:s.value,onChange:s.onChange,isDisabled:t.subGroupCount===0})})}),e(j,{children:e(G,{variant:"link",className:"keycloak__client-authorization__policy-row-remove",icon:e(Ne,{}),onClick:()=>{r("groups",[...(l||[]).filter(({id:s})=>s!==t.id)]),C([...f.filter(({id:s})=>s!==t.id)])}})})]},t.id))})]})]})]})},_n=()=>{const{t:n}=E(),{control:i}=B();return e(U,{label:n("code"),labelIcon:e(q,{helpText:n("policyCodeHelp"),fieldLabelId:"code"}),fieldId:"code",isRequired:!0,children:e(N,{name:"code",defaultValue:"",control:i,render:({field:a})=>e(hn,{id:"code","data-testid":"code",readOnly:!0,value:a.value,language:"js",height:600})})})},Je=["POSITIVE","NEGATIVE"],Nn=({isDisabled:n})=>{const{t:i}=E(),{control:a}=B();return e(U,{label:i("logic"),labelIcon:e(q,{helpText:i("logicHelp"),fieldLabelId:"logic"}),fieldId:"logic",hasNoPaddingTop:!0,children:e(N,{name:"logic","data-testid":"logic",defaultValue:Je[0],control:a,render:({field:d})=>e(w,{children:Je.map(r=>e(ge,{id:r,"data-testid":r,isChecked:d.value===r,name:"logic",onChange:()=>d.onChange(r),label:i(`logicType.${r.toLowerCase()}`),className:"pf-v5-u-mb-md",isDisabled:n},r))})})})},Hn=({isDisabled:n,clientId:i})=>{const{t:a}=E(),d=He(i);return y(w,{children:[e(Ce,{name:"name",label:a("name"),labelIcon:d?a("permissionNameHelpText"):"",rules:{required:a("required")},isDisabled:n}),e(Gt,{name:"description",label:a("description"),rules:{maxLength:{message:a("maxLength",{length:255}),value:255}},isDisabled:n})]})},Fn=()=>{const{t:n}=E();return y(w,{children:[e(Ce,{name:"targetClaim",label:n("targetClaim"),labelIcon:n("targetClaimHelp"),rules:{required:n("required")}}),e(Ce,{name:"pattern",label:n("regexPattern"),labelIcon:n("regexPatternHelp"),rules:{required:n("required")}}),e(qt,{name:"targetContextAttributes",label:n("targetContextAttributes"),labelIcon:n("targetContextAttributesHelp"),labelOn:n("yes"),labelOff:n("no")})]})},Ln=()=>{const{adminClient:n}=le(),{t:i}=E(),{control:a,getValues:d,setValue:r}=B(),l=d("roles"),[o,m]=x(!1),[f,C]=x("clients"),[t,p]=x([]);return ee(async()=>
1{if(l&&l.length>0){const s=await Promise.all(l.map(c=>n.roles.findOneById({id:c.id})));return Promise.all(s.map(async c=>({role:c,client:c.clientRole?await n.clients.findOne({id:c?.containerId}):void 0})))}return Promise.resolve([])},p,[]),y(w,{children:[y(U,{label:i("roles"),labelIcon:e(q,{helpText:i("policyRolesHelp"),fieldLabelId:"roles"}),fieldId:"roles",children:[e(N,{name:"roles",control:a,defaultValue:[],render:({field:s})=>y(w,{children:[o&&e(gn,{id:"role",type:"roles",title:i("assignRole"),filterType:f,onAssign:c=>{s.onChange([...s.value||[],...c.map(h=>({id:h.role.id}))]),p([...t,...c]),m(!1)},onClose:()=>{m(!1)}}),e(Cn,{"data-testid":"select-role-button",variant:"secondary",onFilerTypeChange:c=>{C(c),m(!0)}})]})}),t.length>0&&y(Ie,{variant:"compact",children:[e(Te,{children:y(te,{children:[e(K,{children:i("roles")}),e(K,{children:i("required")}),e(K,{"aria-hidden":"true"})]})}),e(Se,{children:t.map((s,c)=>y(te,{children:[e(j,{children:e(yn,{role:s.role,client:s.client})}),e(j,{children:e(N,{name:`roles.${c}.required`,defaultValue:!1,control:a,render:({field:h})=>e(_e,{id:"required","data-testid":"standard",name:"required",isChecked:h.value,onChange:h.onChange})})}),e(j,{children:e(G,{variant:"link",className:"keycloak__client-authorization__policy-row-remove",icon:e(Ne,{}),onClick:()=>{r("roles",[...(l||[]).filter(h=>h.id!==s.role.id)]),p([...t.filter(h=>h.role.id!==s.role.id)])}})})]},s.role.id))})]})]}),e(fn,{name:"fetchRoles",label:i("fetchRoles"),labelIcon:i("fetchRolesHelp")})]})},Ae=/(\d\d\d\d-\d\d-\d\d)? (\d\d?):(\d\d?)/,Qe=n=>n.toString().padStart(2,"0"),Xe=({name:n})=>{const{control:i}=B(),a=(r,l)=>{if(!l)return r;const o=Ae.exec(r);return`${[l.getFullYear(),Qe(l.getMonth()+1),Qe(l.getDate())].join("-")} ${o?o[2]:"00"}:${o?o[3]:"00"}:00`},d=(r,l,o)=>{const m=Ae.exec(r);return o!=null?`${m?m[1]:""} ${l}:${o<10?`0${o}`:o}:00`:r};return e(N,{name:n,defaultValue:"",control:i,rules:{required:!0},render:({field:r})=>{const l=r.value.match(Ae)||["","","0","00"];return y(ct,{hasGutter:!0,id:n,children:[e(de,{children:e(vn,{value:l[1],onChange:(o,m,f)=>{r.onChange(a(r.value,f))}})}),e(de,{children:e(Fe,{time:`${l[2]}:${l[3]}`,onChange:(o,m,f,C)=>r.onChange(d(r.value,f,C)),is24Hour:!0})})]})}})},Ze=({name:n,min:i,max:a})=>{const{control:d}=B(),r=l=>Math.max(i,Math.min(l,a));return e(N,{name:n,defaultValue:"",control:d,render:({field:l})=>e(Kt,{id:n,value:l.value,min:i,max:a,onPlus:()=>l.onChange(r(Number(l.value)+1)),onMinus:()=>l.onChange(r(Number(l.value)-1)),onChange:o=>{const m=Number(o.currentTarget.value);l.onChange(r(isNaN(m)?0:m))}})})},me=({name:n,...i})=>{const{t:a}=E();return e(U,{label:a(n),fieldId:n,labelIcon:e(q,{helpText:a(`${n}Help`),fieldLabelId:n}),children:y(ct,{hasGutter:!0,children:[e(de,{children:e(Ze,{name:n,...i})}),e(de,{children:a("to")}),e(de,{children:e(Ze,{name:`${n}End`,...i})})]})})},Un=()=>{const{t:n}=E(),{getValues:i,formState:{errors:a}}=B(),[d,r]=x(i("month"));return y(w,{children:[e(U,{label:n("repeat"),fieldId:"repeat",labelIcon:e(q,{helpText:n("repeatHelp"),fieldLabelId:"repeat"}),children:y(zt,{children:[e(Ue,{children:e(ge,{id:"notRepeat","data-testid":"notRepeat",isChecked:!d,name:"repeat",onChange:()=>r(!1),label:n("notRepeat"),className:"pf-v5-u-mb-md"})}),e(Ue,{children:e(ge,{id:"repeat","data-testid":"repeat",isChecked:d,name:"repeat",onChange:()=>r(!0),label:n("repeat"),className:"pf-v5-u-mb-md"})})]})}),d&&y(w,{children:[e(me,{name:"month",min:1,max:12}),e(me,{name:"dayMonth",min:1,max:31}),e(me,{name:"hour",min:0,max:23}),e(me,{name:"minute",min:0,max:59})]}),y(U,{label:n("startTime"),fieldId:"notBefore",labelIcon:e(q,{helpText:n("startTimeHelp"),fieldLabelId:"startTime"}),isRequired:!0,children:[e(Xe,{name:"notBefore"}),a.notBefore&&e(Ee,{message:n("required")})]}),y(U,{label:n("expireTime"),fieldId:"notOnOrAfter",labelIcon:e(q,{helpText:n("expireTimeHelp"),fieldLabelId:"expireTime"}),isRequired:!0,children:[e(Xe,{name:"notOnOrAfter"}),a.notOnOrAfter&&e(Ee,{message:n("required")})]})]})},Gn=()=>{const{t:n}=E();return e(kn,{name:"users",label:"users",helpText:n("policyUsers"),defaultValue:[],variant:"typeaheadMulti"})},Ve={aggregate:$n,client:An,user:Gn,"client-scope":wn,group:Vn,regex:Fn,role:Ln,time:Un,js:_n},ve=n=>n in Ve;function qn(){const{adminClient:n}=le(),{t:i}=E(),{id:a,realm:d,policyId:r,policyType:l}=ye(),{permissionClientId:o}=ye(),m=it(),f=jt(),{reset:C,handleSubmit:t}=f,{addAlert:p,addError:s}=Bt(),[c,h]=x(),I=l==="js",T=He(o);ee(async()=>
1{if(r){const S=await Promise.all([n.clients.findOnePolicyWithType({id:o??a,type:l,policyId:r}),n.clients.getAssociatedPolicies({id:o??a,permissionId:r})]);if(!S[0])throw new Error(i("notFound"));return{policy:S[0],policies:S[1].map(k=>k.id)}}if(!ve(l)){const k=(await n.clients.listPolicyProviders({id:o??a})).find(V=>V.type===l);if(k)return{policy:{code:k.code,description:k.description}}}return{}},({policy:S,policies:k})=>{C({...S,policies:k}),h(S)},[o,a,l,r]);const D=async S=>{S.groups=S.groups?.filter(O=>O.id),S.clientScopes=S.clientScopes?.filter(O=>O.id),S.roles=S.roles?.filter(O=>O.id).map(O=>({...O,required:O.required||!1}));const k=T?o:a,V=T?Xt:at;try{if(r)await n.clients.updatePolicy({id:k,type:l,policyId:r},S);else{const O=await n.clients.createPolicy({id:k,type:l},S);m(V({realm:d,id:k,permissionClientId:k,policyId:O.id,policyType:O.type}))}p(i((r?"update":"create")+"PolicySuccess"),Ge.success)}catch(O){s("policySaveError",O)}},[$,R]=dt({titleKey:"deletePolicy",messageKey:"deletePolicyConfirm",continueButtonLabel:"confirm",onConfirm:async()=>{try{await n.clients.delPolicy({id:T?o:a,policyId:r}),p(i("policyDeletedSuccess"),Ge.success),m(T?qe({realm:d,permissionClientId:o,tab:"policies"}):ze({realm:d,clientId:a,tab:"policies"}))}catch(S){s("policyDeletedError",S)}}});if(r&&!c)return e(Wt,{});function _(){return ve(l)?Ve[l]:Ve.js}const W=_();return y(w,{children:[e(R,{}),e(an,{titleKey:r?c?.name:i("createPolicyOfType",{policyType:l}),dropdownItems:r?[e(we,{"data-testid":"delete-policy",onClick:()=>$(),children:i("delete")},"delete")]:void 0}),e(Yt,{variant:"light",children:y(on,{isHorizontal:!0,onSubmit:t(S=>D(S)),role:"anyone",children:[y(Jt,{...f,children:[e(Hn,{isDisabled:I}),e(W,{}),e(Nn,{isDisabled:I})]}),e(Qt,{children:y("div",{className:"pf-v5-u-mt-md",children:[e(G,{isDisabled:I,variant:ce.primary,className:"pf-v5-u-mr-md",type:"submit","data-testid":"save",children:i("save")}),e(G,{variant:"link","data-testid":"cancel",component:S=>e(ot,{...S,to:T?qe({realm:d,permissionClientId:o,tab:"policies"}):ze({realm:d,clientId:a,tab:"policies"})}),children:i("cancel")})]})})]})})]})}const di=Object.freeze(Object.defineProperty({__proto__:null,default:qn,isValidComponentType:ve},Symbol.toStringTag,{value:"Module"})),zn=({policyProviders:n,onSelect:i,toggleDialog:a})=>{const{t:d}=E(),r=pt(),l=pe(()=>n?r(n,ut("name")):[],[n]);return e(lt,{"aria-label":d("createPolicy"),variant:rt.medium,header:y(Zt,{children:[e(Ke,{component:en.h1,children:d("chooseAPolicyType")}),e(Ke,{children:d("chooseAPolicyTypeInstructions")})]}),isOpen:!0,onClose:a,children:y(Ie,{"aria-label":d("policies"),variant:"compact",children:[e(Te,{children:y(te,{children:[e(K,{children:d("name")}),e(K,{children:d("description")})]})}),e(Se,{children:l.map(o=>y(te,{"data-testid":o.type,onRowClick:()=>i(o),isClickable:!0,children:[e(j,{children:o.name}),e(j,{style:{textWrap:"wrap"},children:ve(o.type)?d(`policyProvider.${o.type}`):o.description})]},o.type))})]})})};export{En as A,wn as C,Mn as D,Vn as G,_n as J,Nn as L,zn as N,di as P,Rn as R,Un as T,kn as U,Ln as a,Fn as b,Gn as c,An as d,$n as e,Hn as f};
2//# sourceMappingURL=NewPolicyDialog-DeUBI6zO.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.