File: //opt/netdata/netdata-web-files/v3/9883.ecbf573077bab8baa788.chunk.js
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"0725d67f2585acd82a0d73d488b6cd9060c3224d"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="72850c72-f4f1-439b-bbea-0197fc4e98fb",e._sentryDebugIdIdentifier="sentry-dbid-72850c72-f4f1-439b-bbea-0197fc4e98fb")}catch(e){}}(),(globalThis.webpackChunkcloud_frontend=globalThis.webpackChunkcloud_frontend||[]).push([[9883],{34646(e,t,n){n.d(t,{FX:()=>r,ON:()=>a,Uj:()=>s,Zl:()=>i,lG:()=>l,lt:()=>d});var o=n(91130);const i=e=>o.A.get(`/api/v3/spaces/${e}/scim`),r=(e,t)=>e?o.A.get(`/api/v3/spaces/${t}/scim/${e}`):Promise.resolve({data:null}),l=(e,t)=>o.A.post(`/api/v3/spaces/${e}/scim`,t),a=(e,t,n)=>o.A.patch(`/api/v3/spaces/${t}/scim/${e}`,n),s=(e,t)=>o.A.delete(`/api/v3/spaces/${t}/scim/${e}`),d=(e,t)=>e?o.A.post(`/api/v3/spaces/${t}/scim/${e}/rotate-token`):Promise.resolve({data:null})},1457(e,t,n){n.d(t,{Rq:()=>l,oL:()=>a,u:()=>s,ue:()=>r});var o=n(52035),i=n(18790);const r={items:[],error:"",id:null,loading:!0,loaded:!1},l=(0,i.I)(()=>(0,o.eU)(0)),a=(0,i.I)(e=>(0,o.eU)({...r,id:e})),s=(0,i.I)(()=>(0,o.eU)(null))},63956(e,t,n){n.d(t,{Bc:()=>u,Hy:()=>m,Xy:()=>p,cP:()=>x,dI:()=>f,nB:()=>h});var o=n(96540),i=n(52035),r=n(34843),l=n(18790),a=n(24609),s=n(1457),d=n(34646),c=n(57377);const u=()=>{const e=(0,a.vt)();return(0,r.md)((0,s.Rq)(e))},h=()=>{const e=(0,a.vt)(),t=(0,r.Xr)((0,s.Rq)(e));return(0,o.useCallback)(()=>t(e=>e+1),[t])},g=(0,l.I)(e=>{let{id:t,key:n}=e;return(0,i.eU)(e=>{const o=e((0,s.oL)(t));return n?o[n]:o},(e,o,i)=>{o((0,s.oL)(t),e=>n?{...e,[n]:i}:{...e,...i})})},c.Ay),x=(e,t)=>(0,r.Xr)(g({id:e,key:t})),p=e=>{const t=(0,a.vt)();return(0,r.md)(g({id:t,key:e}))},m=e=>(0,r.fp)((0,s.u)(e)),f=e=>{const t=(0,a.vt)(),[n,i]=m(t),r=(0,o.useCallback)(function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,d.lG)(t,{integrationID:e,...n})},[t]),l=(0,o.useCallback)(function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,d.ON)(e,t,n)},[e,t]);return{integration:n,create:r,update:l,remove:(0,o.useCallback)(()=>(0,d.Uj)(e,t).then(()=>(i(null),Promise.resolve())),[e,t,i]),rotateToken:(0,o.useCallback)(()=>(0,d.lt)(e,t),[e,t])}}},53746(e,t,n){n.d(t,{A:()=>s});var o=n(34646),i=n(24609),r=n(32052),l=n(1457),a=n(63956);const s=()=>{const e=(0,i.vt)(),t=(0,a.cP)(e),n=(0,a.Bc)();(0,r.A)(()=>({enabled:!!e,fetch:()=>(0,o.Zl)(e),onFail:e=>t({...l.ue,error:e?.response?.data||e}),onSettle:()=>t({loading:!1,loaded:!0}),onSuccess:e=>{t({...l.ue,items:e||[]})}}),[n,e])}},49883(e,t,n){n.r(t),n.d(t,{default:()=>ke});var o=n(78904),i=n(60908),r=n(74891),l=n(74848);const a=(0,r.A)(o.Button),s="rows",d="grid",c=e=>t=>e==s&&t||e==d&&!t?{flavour:"hollow"}:{},u=e=>{let{showGrid:t,toggleLayout:n}=e;return(0,l.jsxs)(o.Flex,{alignItems:"center",children:[(0,l.jsx)(a,{small:!0,groupFirst:!0,icon:"list",onClick:n,tooltip:"Show in rows",...c(s)(t)}),(0,l.jsx)(a,{small:!0,groupLast:!0,icon:"grid",onClick:n,tooltip:"Show in grid",...c(d)(t)})]})};n(98992),n(72577);var h=n(91130);var g=n(24609),x=n(32052),p=n(52035),m=n(18790);const f={items:[],error:"",id:null,loading:!0,loaded:!1,oidcID:null},j=(0,m.I)(()=>(0,p.eU)(0)),b=(0,m.I)(e=>(0,p.eU)({...f,id:e})),v=(0,m.I)(()=>(0,p.eU)(null));var C=n(96540),k=n(34843),A=n(57377);const y=(0,m.I)(e=>{let{id:t,key:n}=e;return(0,p.eU)(e=>{const o=e(b(t));return n?o[n]:o},(e,o,i)=>{o(b(t),e=>n?{...e,[n]:"function"===typeof i?i(e):i}:{...e,..."function"===typeof i?i(e):i})})},A.Ay),w=e=>((e,t)=>(0,k.md)(y({id:e,key:t})))((0,g.vt)(),e),D=e=>(0,k.fp)(v(e)),S=e=>{const t=(0,g.vt)(),[n,o]=D(t),i=(0,C.useCallback)(function(){return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h.A.post(`/api/v3/spaces/${e}/oidc`,{...t})}(t,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},[t]),r=(0,C.useCallback)(function(){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return h.A.patch(`/api/v3/spaces/${t}/oidc/${e}`,n)}(e,t,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},[e,t]),l=(0,C.useCallback)(()=>((e,t)=>h.A.delete(`/api/v3/spaces/${t}/oidc/${e}`))(e,t).then(()=>(o(null),Promise.resolve())),[e,t,o]);return{config:n,isEdit:!!e,save:e?r:i,remove:l}},F=()=>{const e=(0,g.vt)(),t=((e,t)=>(0,k.Xr)(y({id:e,key:t})))(e),n=(()=>{const e=(0,g.vt)();return(0,k.md)(j(e))})();(0,x.A)(()=>({enabled:!!e,fetch:()=>(e=>h.A.get(`/api/v3/spaces/${e}/oidc`))(e),onFail:e=>t({...f,error:e?.response?.data||e}),onSettle:()=>t({loading:!1,loaded:!0}),onSuccess:e=>{const{oidcID:n}=e.find(e=>{let{oidcID:t}=e;return!!t})||{};t(t=>({...t,items:e,oidcID:n}))}}),[n,e])};n(54520),n(81454);var I=n(55093),T=n(79748),L=n(95565),M=n(76375);const $="authentication",B=function(){let{flavour:e,error:t={},logProps:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{loaded:r,isPaid:a}=(0,M.A)(),{errorMsgKey:s}=t,d=(0,C.useMemo)(()=>function(){let{flavour:e,isPaid:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=e===$;return{ErrForbidden:{title:"No permissions",Content:()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.Text,{children:"You don't have permissions to view the authentication methods."}),(0,l.jsx)(o.Text,{children:"Please contact the Space administrators if this is unexpected."})]})},ErrNotAvailable:{title:"No available "+(n?"Authn":"Authz"),Content:()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.Text,{children:["No available ",n?"authentication":"authorization"," integrations found."]}),t?null:(0,l.jsxs)(o.Text,{children:["To enable this feature, please"," ",(0,l.jsx)(L.A,{children:(0,l.jsx)(o.Text,{color:"primary",children:"upgrade to the Business plan"})}),"."]})]})},default:{title:"Error",Content:()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.Text,{children:"Something went wrong, please check again later."}),(0,l.jsxs)(o.Text,{children:["If the problem persists feel free to contact us with a"," ",(0,l.jsx)(T.A,{href:"https://github.com/netdata/netdata-cloud/issues/new/choose",target:"_blank",rel:"noopener noreferrer",children:"ticket"})]})]})}}}({flavour:e,isPaid:a}),[e,a]),{title:c,Content:u}=d[s]||d.default;return r?(0,l.jsx)(i.DL,{errorMsgKey:s,...n,children:(0,l.jsxs)(o.Flex,{column:!0,gap:1,padding:[4,0],children:[(0,l.jsxs)(o.Flex,{alignItems:"center",gap:2,children:[(0,l.jsx)(o.Icon,{name:"warning_triangle",color:"warning"}),(0,l.jsx)(o.H5,{children:c})]}),(0,l.jsx)(u,{})]})}):null},E={flexWrap:!0},P={column:!0},U=e=>{let{flavour:t,loading:n,loaded:i,items:r=[],oidcID:a,error:s,showGrid:d,CardComponent:c,errorViewProps:u={},noLoader:h}=e;const g=r.filter(e=>{let{available:t}=e;return!!t}),x=(0,C.useMemo)(()=>({width:"100%",gap:4,...d?E:P}),[d]),p=(0,C.useMemo)(()=>d?{height:37,width:75,margin:[0,0,4,0]}:{},[d]);return!i&&n?h?null:(0,l.jsx)(I.A,{title:"Loading..."}):i?s?(0,l.jsx)(B,{flavour:t,error:s,...u}):g.length?c?(0,l.jsx)(o.Flex,{...x,children:g.map(e=>(0,l.jsx)(c,{configuredItemExists:!!a,...p,...e},e.id))}):null:(0,l.jsx)(B,{flavour:t,error:{errorMsgKey:"ErrNotAvailable"},...u}):(0,l.jsx)(B,{flavour:t,error:"Something went wrong",...u})};var R=n(6304);n(23215);const q=e=>{const t=(0,g.vt)(),[,n]=D(t);(0,x.A)(()=>({enabled:!!t,fetch:()=>((e,t)=>e?h.A.get(`/api/v3/spaces/${t}/oidc/${e}`):Promise.resolve({data:null}))(e,t),onSuccess:e=>{n(e)}}),[t,e])},_={okta:{name:"okta",color:"bright"},"auth-server":{name:"openid",color:"bright"}},N=e=>{let{title:t,onConfirm:n,onDecline:i,isConfirmLoading:r}=e;return(0,l.jsx)(o.ConfirmationDialog,{confirmLabel:"Yes, delete",handleConfirm:n,handleDecline:i,message:(0,l.jsxs)(l.Fragment,{children:["You are about to delete ",(0,l.jsx)("strong",{children:t})," configuration.",(0,l.jsx)("br",{}),"Are you sure you want to continue?"]}),title:"Delete configuration",isConfirmLoading:r})};var G=n(99728),O=n(94404),X=n(3319);const Y=(0,r.A)((0,O.A)(o.Button)),z=e=>{let{title:t,isLoading:n,isEditable:i,validFields:r,onSave:a,onConfirmDelete:s}=e;const[d,,c,u]=(0,R.A)(),h=(0,G.JT)("oidc:Manage"),{sendLog:g}=(0,X.A)(),x=(0,C.useCallback)(()=>{s(),u(),g({feature:"OidcModalConfirmDeleteButton",title:t})},[s,u]),p=(0,C.useMemo)(()=>({feature:"OidcModalSaveButton",label:"Save",onClick:a,disabled:!r||!h||n,tooltip:h?r?"Save the configuration":"Please provide values to the required fields":"You don't have permission to manage single sign-on configurations."}),[a,r,h,n]),m=(0,C.useMemo)(()=>({feature:"OidcModalDeleteButton",label:"Delete",flavour:"hollow",danger:!0,onClick:c,disabled:!h||n,tooltip:h?"Delete the configuration":"You don't have permission to manage single sign-on configurations."}),[c,n,h]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.ModalFooter,{gap:2,children:[i?(0,l.jsx)(Y,{...m}):null,(0,l.jsx)(Y,{...p})]}),d?(0,l.jsx)(N,{title:t,onConfirm:x,onDecline:u,isConfirmLoading:n}):null]})};n(74423);const H={string:e=>{let{propKey:t,title:n,setFormData:i,...r}=e;const a=(0,C.useCallback)(e=>{let{target:n}=e;i(e=>({...e,[t]:n.value}))},[t,i]);return(0,l.jsx)(o.TextInput,{label:n,onChange:a,...r})},default:()=>null},V=e=>{let{propKey:t,type:n,setFormData:o,...i}=e;const r=H[n]||H.default,a=(0,C.useCallback)(e=>{let{target:n}=e;o(e=>({...e,initialData:!1,[t]:n.value}))},[o]);return(0,l.jsx)(r,{onChange:a,...i})},K=e=>{let{properties:t={},errors:n={},formData:i,required:r,setFormData:a}=e;return(0,l.jsx)(o.Flex,{column:!0,gap:2,children:Object.entries(t).map(e=>{let[t,o]=e;return(0,l.jsx)(V,{propKey:t,isRequired:r.includes(t),...o,value:i[t]||"",setFormData:a,error:n[t]},t)})})};var W=n(63872);n(8872);const Z={string:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{format:n}=t;return"uri"!=n||(e=>{try{const{host:t}=new URL(e);return/^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)(\.[a-zA-Z0-9]{1,63})+$/.test(t)}catch{return!1}})(e)?null:"Invalid URL format"},default:()=>null},J=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.entries(e).reduce((e,n)=>{let[o,i]=n;const r=t[o]||{},l=(Z[r.type]||Z.default)(i,r);return l&&(e[o]=l),e},{})},Q=e=>{let{id:t,oidcID:n,title:r,slug:a,description:s,properties:d={},required:c=[],isEditable:u,docsUrl:h,onClose:x,openDnsRecord:p}=e;q(n);const{config:m,isEdit:f,save:b,remove:v}=S(n),[A,y]=(0,C.useState)({}),[w,,D,F]=(0,R.A)(),L=(()=>{const e=(0,g.vt)(),t=(0,k.Xr)(j(e));return(0,C.useCallback)(()=>t(e=>e+1),[t])})(),[M,$]=(0,W.A)(),[B,E]=(0,C.useState)({}),P=c.every(e=>!!A[e]);(0,C.useEffect)(()=>{y(m||{})},[m]),(0,C.useEffect)(()=>{E(J(A,d))},[A,d,E]);const U=(0,C.useCallback)(()=>{D(),b({...f?{}:{integrationID:t},...A}).then(function(){let{data:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};M({header:"Success",text:`Successfully configured ${r}`}),x(),L(),e?.dnsRecordValue&&p()}).catch($).finally(()=>{F()})},[b,A,f,M,$,x,L,D,F]),N=(0,C.useCallback)(()=>{D(),v().then(()=>{M({header:"Success",text:`Successfully deleted ${r} configuration`}),x(),L()}).catch($).finally(()=>{F()})},[v,M,$,x,L,D,F]);return(0,l.jsx)(i.Ay,{feature:"AuthModal",title:r,children:(0,l.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onEsc:x,children:(0,l.jsxs)(o.ModalContent,{width:{min:100,base:140},children:[(0,l.jsxs)(o.ModalHeader,{border:{side:"bottom",color:"disabled"},column:!0,gap:.5,padding:[6,4,3],children:[(0,l.jsxs)(o.Flex,{alignItems:"center",children:[(0,l.jsxs)(o.Flex,{gap:1,alignItems:"center",children:[(0,l.jsx)(o.Icon,{..._[a]||{}}),(0,l.jsx)(o.H3,{children:r})]}),x&&(0,l.jsx)(o.ModalCloseButton,{onClose:x,tooltip:"Close modal"})]}),(0,l.jsxs)(o.TextSmall,{as:o.Box,children:[s,h?(0,l.jsxs)(l.Fragment,{children:["\xa0",(0,l.jsx)(T.A,{Component:o.TextSmall,href:h,target:"_blank",whiteSpace:"nowrap",children:"Learn how to configure it."})]}):null]})]}),(0,l.jsx)(o.ModalBody,{height:{min:60,base:60},overflow:{vertical:"auto"},children:w?(0,l.jsx)(I.A,{height:60,title:"Loading..."}):(0,l.jsx)(K,{formData:A,required:c,setFormData:y,properties:d,errors:B})}),(0,l.jsx)(z,{title:r,isLoading:w,isEditable:u,validFields:P||!!Object.keys(B).length,onSave:U,onConfirmDelete:N})]})})})};var ee=n(30005);const te=e=>{let{oidcID:t,title:n,slug:r,onClose:a}=e;q(t);const{config:s}=S(t);return s?.dnsRecordValue?(0,l.jsx)(i.Ay,{feature:"AuthDnsRecord",title:n,children:(0,l.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onEsc:a,children:(0,l.jsxs)(o.ModalContent,{width:{min:100,base:140},children:[(0,l.jsx)(o.ModalHeader,{border:{side:"bottom",color:"disabled"},column:!0,gap:.5,padding:[6,4,3],children:(0,l.jsxs)(o.Flex,{alignItems:"center",children:[(0,l.jsxs)(o.Flex,{gap:1,alignItems:"center",children:[(0,l.jsx)(o.Icon,{..._[r]||{}}),(0,l.jsx)(o.H3,{children:"Create a new TXT record in the DNS settings"})]}),a&&(0,l.jsx)(o.ModalCloseButton,{onClose:a,tooltip:"Close modal"})]})}),(0,l.jsx)(o.ModalBody,{height:{min:60,base:60},overflow:{vertical:"auto"},children:(0,l.jsxs)(o.Flex,{column:!0,gap:2,padding:[4],children:[(0,l.jsx)(o.Text,{children:"In your domain's DNS settings, create a new TXT record and use the code below as its' value."}),(0,l.jsx)(ee.Ay,{"data-testid":"dnsRecordValue",children:s.dnsRecordValue}),(0,l.jsx)(T.A,{Component:o.TextSmall,href:"https://learn.netdata.cloud/docs/netdata-cloud/authentication-&-authorization/enterprise-sso-authentication#how-to-authenticate-to-netdata",target:"_blank",whiteSpace:"nowrap",children:"Learn how to configure DNS TXT records"})]})})]})})}):null},ne=(0,r.A)(o.Button),oe=e=>{let{title:t,isEditable:n,isDisabled:o,onClick:i}=e;const r=(0,C.useMemo)(()=>o?"You have already configured a SSO provider":n?`Edit ${t} configuration`:`Configure ${t}`,[o,n,t]);return(0,l.jsx)(ne,{label:n?"Edit":"Configure",flavour:"hollow",icon:"gear",onClick:i,disabled:o,tooltip:r,tooltipProps:{align:"bottom"}})};var ie=n(98563);const re=e=>{let{id:t,slug:n,title:i,description:r,"data-testid":a="card",configuredItemExists:s,oidcID:d,schema:c={},...u}=e;const h=_[n],[g,,x,p]=(0,R.A)(),[m,,f,j]=(0,R.A)(),b=s&&!d,v=s&&!!d,{annotations:C={},properties:k={},required:A=[]}=c,{docsUrl:y}=C;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.Flex,{background:"elementBackground",column:!0,"data-testid":a,justifyContent:"between",flex:!1,padding:[3,2,2,3],position:"relative",overflow:"hidden",round:.5,...u,children:[(0,l.jsx)(ie.MU,{"data-testid":`${a}-blurredIcon`,...h}),(0,l.jsxs)(o.Flex,{column:!0,"data-testid":`${a}-details`,gap:3,margin:[0,0,3,0],children:[(0,l.jsxs)(o.Flex,{"data-testid":`${a}-header`,justifyContent:"between",children:[(0,l.jsxs)(o.Flex,{alignItems:"center","data-testid":`${a}-titleContainer`,gap:1,children:[(0,l.jsx)(o.Icon,{"data-testid":`${a}-icon`,...h}),(0,l.jsx)(o.Text,{"data-testid":`${a}-title`,children:i})]}),(0,l.jsxs)(o.Flex,{gap:1,children:[v&&(0,l.jsx)(o.Button,{label:"DNS TXT record",flavour:"hollow",icon:"serviceDNS",onClick:f,neutral:!0}),(0,l.jsx)(oe,{title:i,isEditable:v,isDisabled:b,onClick:x})]})]}),(0,l.jsxs)(o.TextSmall,{color:"textDescription","data-testid":`${a}-description`,children:[r," ",y&&(0,l.jsx)(T.A,{Component:ie.W6,"data-testid":`${a}-docsLink`,href:y,target:"_blank",whiteSpace:"nowrap",children:"Learn more."})]})]})]}),g&&(0,l.jsx)(Q,{id:t,oidcID:d,slug:n,title:i,description:r,docsUrl:y,properties:k,required:A,onClose:p,isEditable:v,openDnsRecord:f}),m&&(0,l.jsx)(te,{oidcID:d,slug:n,title:i,onClose:j})]})},le=e=>{let{showGrid:t}=e;F();const n=w();return(0,l.jsx)(U,{flavour:"authentication",showGrid:t,CardComponent:re,errorViewProps:{logProps:{feature:"AuthenticationIntegrationError"}},...n})};var ae=n(53746),se=n(63956),de=n(34646);const ce=e=>{const t=(0,g.vt)(),[,n]=(0,se.Hy)(t);(0,x.A)(()=>({enabled:!!t,fetch:()=>(0,de.FX)(e,t),onSuccess:e=>{n(e)}}),[t])},ue=e=>{let{title:t,onConfirm:n,onDecline:i,isConfirmLoading:r}=e;return(0,l.jsx)(o.ConfirmationDialog,{confirmLabel:"Yes, delete",handleConfirm:n,handleDecline:i,message:(0,l.jsxs)(l.Fragment,{children:["You are about to delete ",(0,l.jsx)("strong",{children:t})," integration.",(0,l.jsx)("br",{}),"Are you sure you want to continue?"]}),title:"Delete integration",isConfirmLoading:r})},he=(0,r.A)((0,O.A)(o.Button)),ge=e=>{let{title:t,isLoading:n,isEditable:i,isDirty:r,credentials:a,validFields:s,onActivate:d,onUpdate:c,onRotateToken:u,onConfirmDelete:h,onClose:g}=e;const[x,,p,m]=(0,R.A)(),f=(0,G.JT)("oidc:Manage"),{sendLog:j}=(0,X.A)(),b=(0,C.useCallback)(()=>{h(),m(),j({feature:"ScimModalConfirmDeleteButton",title:t})},[h,m]),v=(0,C.useMemo)(()=>({feature:"ScimModalSaveButton",label:"Save",onClick:c,disabled:!r||!s||!f||n,tooltip:f?s?"Save the integration":"Please provide values to the required fields":"You don't have permission to manage scim integrations."}),[c,r,s,f,n]),k=(0,C.useMemo)(()=>({feature:"ScimModalDeleteButton",label:"Delete",flavour:"hollow",danger:!0,onClick:p,disabled:!f||n,tooltip:f?"Delete the integration":"You don't have permission to manage scim integrations."}),[p,n,f]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.ModalFooter,{gap:2,justifyContent:"between",children:[i&&!a?(0,l.jsx)(he,{...k}):(0,l.jsx)("div",{}),(0,l.jsx)(o.Flex,{gap:2,children:a?(0,l.jsx)(he,{label:"Done",onClick:g}):i?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(he,{label:"Regenerate token",flavour:"hollow",onClick:u}),(0,l.jsx)(he,{...v})]}):(0,l.jsx)(he,{label:"Activate",onClick:d})})]}),x?(0,l.jsx)(ue,{title:t,onConfirm:b,onDecline:m,isConfirmLoading:n}):null]})};var xe=n(67723);const pe=e=>{let{baseURL:t,token:n}=e;return(0,l.jsxs)(o.Flex,{column:!0,gap:2,children:[(0,l.jsxs)(o.Flex,{column:!0,gap:1,children:[(0,l.jsx)(o.Text,{as:"label",children:"Base URL"}),(0,l.jsx)(xe.A,{logProps:{feature:"CopyScimBaseURL"},padding:[2],noMargin:!0,children:t})]}),(0,l.jsxs)(o.Flex,{column:!0,gap:1,children:[(0,l.jsx)(o.Text,{as:"label",children:"Token"}),(0,l.jsx)(xe.A,{logProps:{feature:"CopyScimToken"},padding:[2],noMargin:!0,children:n})]})]})},me="Loading...",fe=e=>{let{id:t,scimID:n,title:r,slug:a,description:s,properties:d={},required:c=[],docsUrl:u,onClose:h}=e;ce(n);const g=(0,C.useRef)(),{integration:x,create:p,update:m,remove:f,rotateToken:j}=(0,se.dI)(n||t),b=(0,se.nB)(),[v,,k]=(0,R.A)(),[A,y]=(0,C.useState)({}),{isLoading:w,loadingText:D,startLoading:S,startLoadingToken:F,stopLoading:L}=(()=>{const[e,,t,n]=(0,R.A)(),[o,i]=(0,C.useState)(me),r=(0,C.useCallback)(()=>{i("Generating token..."),t()},[t,i]),l=(0,C.useCallback)(()=>{n(),i(me)},[n,i]);return{isLoading:e,loadingText:o,startLoading:t,startLoadingToken:r,stopLoading:l}})(),[M,$]=(0,W.A)(),[B,E]=(0,C.useState)({}),P=c.every(e=>!!A[e]),[U,q]=(0,C.useState)();(0,C.useEffect)(()=>{if(Object.keys(x||{}).length){const e={...x,initialData:!0};y(e)}},[x]),(0,C.useEffect)(()=>{E(J(A,d))},[A,d,E]),(0,C.useEffect)(()=>{Object.keys(A).length&&!A.initialData&&(g.current=!0)},[A]);const N=(0,C.useCallback)(()=>{v&&b(),h()},[v,b,h]),G=(0,C.useCallback)(()=>{const{scimToken:e}=A||{};F(),p({scimToken:e}).then(e=>{let{data:t}=e;q(t),k()}).catch(e=>{$(e)}).finally(()=>L())},[t,A,p,k,q,F,L,$]),O=(0,C.useCallback)(()=>{const{scimToken:e}=A||{};S(),m({scimToken:e}).then(()=>{M("Successfully updated integration")}).catch($).finally(L)},[A,m,S,L,M,$]),X=(0,C.useCallback)(()=>{F(),j().then(e=>{let{data:t}=e;q(t),k()}).catch(e=>{$(e)}).finally(()=>L())},[j,F,L,q,k,$]),Y=(0,C.useCallback)(()=>{S(),f().then(()=>{M({header:"Success",text:`Successfully deleted ${r} integration`}),b(),N()}).catch($).finally(()=>{L()})},[f,b,M,$,N,S,L]);return(0,l.jsx)(i.Ay,{feature:"AuthModal",title:r,children:(0,l.jsx)(o.Modal,{backdropProps:{backdropBlur:!0},onEsc:N,children:(0,l.jsxs)(o.ModalContent,{width:{min:100,base:140},children:[(0,l.jsxs)(o.ModalHeader,{border:{side:"bottom",color:"disabled"},column:!0,gap:.5,padding:[6,4,3],children:[(0,l.jsxs)(o.Flex,{alignItems:"center",children:[(0,l.jsxs)(o.Flex,{gap:1,alignItems:"center",children:[(0,l.jsx)(o.Icon,{..._[a]||{}}),(0,l.jsx)(o.H3,{children:r})]}),h&&(0,l.jsx)(o.ModalCloseButton,{onClose:N,tooltip:"Close modal"})]}),(0,l.jsxs)(o.TextSmall,{as:o.Box,children:[s,u?(0,l.jsxs)(l.Fragment,{children:["\xa0",(0,l.jsx)(T.A,{Component:o.TextSmall,href:u,target:"_blank",whiteSpace:"nowrap",children:"Learn how to configure it."})]}):null]})]}),(0,l.jsx)(o.ModalBody,{height:{min:40,base:60},overflow:{vertical:"auto"},children:w?(0,l.jsx)(I.A,{height:40,title:D}):U?(0,l.jsx)(pe,{...U}):(0,l.jsx)(K,{formData:A,required:c,setFormData:y,properties:d,errors:B})}),(0,l.jsx)(ge,{title:r,isLoading:w,isEditable:!!n,isDirty:g?.current,credentials:U,validFields:P||!!Object.keys(B).length,onActivate:G,onUpdate:O,onRotateToken:X,onConfirmDelete:Y,onClose:N})]})})})},je=(0,r.A)(o.Button),be=e=>{let{title:t,isActive:n,onClick:o}=e;const{tooltip:i,buttonLabel:r,icon:a}=(0,C.useMemo)(()=>({tooltip:n?`Configure ${t}`:`Activate ${t}`,buttonLabel:n?"Configure":"Activate",icon:n?"gear":null}),[n]);return(0,l.jsx)(je,{label:r,flavour:"hollow",icon:a,onClick:o,tooltip:i,tooltipProps:{align:"bottom"}})},ve=e=>{let{id:t,slug:n,title:i,description:r,"data-testid":a="card",schema:s={},SCIMID:d,...c}=e;const[u,,h,g]=(0,R.A)(),x=!!d,{annotations:p={},properties:m={},required:f=[]}=s,{docsUrl:j}=p;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.Flex,{background:"elementBackground",column:!0,"data-testid":a,justifyContent:"between",flex:!1,padding:[3,2,2,3],position:"relative",overflow:"hidden",round:.5,...c,children:[(0,l.jsx)(ie.MU,{"data-testid":`${a}-blurredIcon`}),(0,l.jsxs)(o.Flex,{column:!0,"data-testid":`${a}-details`,gap:3,margin:[0,0,3,0],children:[(0,l.jsxs)(o.Flex,{"data-testid":`${a}-header`,justifyContent:"between",children:[(0,l.jsx)(o.Text,{"data-testid":`${a}-title`,children:i}),(0,l.jsx)(be,{title:i,onClick:h,isActive:x})]}),(0,l.jsxs)(o.TextSmall,{color:"textDescription","data-testid":`${a}-description`,children:[r," ",j&&(0,l.jsx)(T.A,{Component:ie.W6,"data-testid":`${a}-docsLink`,href:j,target:"_blank",whiteSpace:"nowrap",children:"Learn more."})]})]})]}),u&&(0,l.jsx)(fe,{id:t,scimID:d,slug:n,title:i,description:r,docsUrl:j,properties:m,required:f,onClose:g})]})},Ce=e=>{let{showGrid:t}=e;(0,ae.A)();const n=(0,se.Xy)();return(0,l.jsx)(U,{flavour:"authorization",showGrid:t,CardComponent:ve,errorViewProps:{logProps:{feature:"AuthorizationIntegrationError"}},...n,noLoader:!0})},ke=e=>{const[t,n]=(0,R.A)();return(0,l.jsx)(i.Ay,{tab:"AuthenticationAndAuthorization",children:(0,l.jsxs)(o.Flex,{column:!0,gap:4,height:"100%",overflow:{vertical:"auto"},flex:"grow",padding:[2,4,0,4],...e,children:[(0,l.jsxs)(o.Flex,{alignItems:"center",justifyContent:"between",children:[(0,l.jsx)(o.TextBig,{margin:[1,0,3],children:"See the available single sign-on, authorization, and authentication integrations and configure the ones that your company supports."}),(0,l.jsx)(u,{showGrid:t,toggleLayout:n})]}),(0,l.jsx)(le,{showGrid:t}),(0,l.jsx)(o.Box,{as:"hr",height:"1px",width:"100%",margin:t?[-4,0,0,0]:[0],sx:{borderWidth:"1px 0px 0px 0px",borderColor:"borderSecondary",borderStyle:"solid"}}),(0,l.jsx)(Ce,{showGrid:t})]})})}}}]);