import{aw as C,R as h,j as a,az as _,ax as D,aO as E,h as m,i as p,o as R,at as b,bk as L}from"./app-BgLa5dit.js";import{C as O}from"./WnxftYBO.chunk.js";import{C as x}from"./BWCfLV66.chunk.js";import{a as T,b as y}from"./B11DWb8Z.chunk.js";import{P as f}from"./B4GQiiZ9.chunk.js";import{S as U}from"./DV8zX5C-.chunk.js";import{S as u}from"./CIRO_mWB.chunk.js";import{u as j,a as k}from"./BoupYpv9.chunk.js";import{C as v}from"./q-IBKcuF.chunk.js";import"./DJ0pq8J_.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";import"./Bs6fQ2wT.chunk.js";import"./BUT90D7O.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";const A="_container_m2ls4_1",M={container:A},N=[u.RMUnify,u.RMUnifyGlow];function W(t){return N.includes(t)}function w(t){return[{label:"Generate license key",appLink:{application:p.CRM_STUDIO,action:m.CrmStudio.GENREATE_LICENSE_KEY,args:[t]}}]}function F(t){const o=C(),S=h.useMemo(()=>[...U].sort((i,e)=>i.name.localeCompare(e.name)),[]),d=t.ssoSettings.filter(i=>i.idp.type===u.SAML2).sort((i,e)=>i.idp.order-e.idp.order);function I(i){i!==o.values.idpId&&o.setValues({idpId:i})}function g(i){if(i!==o.values.idpId){const e=t.ssoSettings.find(s=>s.idp.id===i);o.setValues({idpId:i,type:u.SAML2,isOrgIdp:e.idp.ownerId.toString()!==t.customerId.toLowerCase()})}}function P(i){return t.isEditing?"You cannot change the provider for editing":T.getProviderDisabledStatus(i,t.mappedIdps)}function r(i){return W(i)?w(t.customerId):null}function c(i){const{idp:e}=i,s=i.idp.ownerId.toString()!==t.customerId.toString();return[{label:"Edit IDP",disabled:s,className:s?"disabled":"",tooltip:s?"This IDP is managed by an organisation":"",appLink:{application:p.CRM_STUDIO,action:m.CrmStudio.CUSTOMER_SSO_WIZARD_EDIT_IDP_POPUP,args:[t.customerId],params:{idpId:e.id}}},{label:"Delete IDP",disabled:s,className:s?"disabled":"",tooltip:s?"This IDP is managed by an organisation":"",appLink:{application:p.CRM_STUDIO,action:m.CrmStudio.CUSTOMER_SSO_WIZARD_DELETE_IDP_POPUP,args:[e.id]}}]}return a.jsx("div",{className:M.container,children:a.jsx(_,{children:a.jsx(D,{type:"radio",checkboxLabelFontWeight:"normal",name:"idpId",id:"idpId",children:()=>a.jsxs("div",{className:"d-flex flex-wrap gap-3 mt-4 text-center",children:[S.map(i=>{const e=i.id===o.values.idpId,s=P(i.id),l=!!s,n=r(i.id);return a.jsx(f,{id:i.id,label:i.name,imageUrl:i.logo,isSelected:e,isDisabled:l,tooltip:s,actions:n,onClick:()=>I(i.id)},i.id)}),d.map(i=>{const{idp:e,idpAttributeBindings:s}=i,l=e.id===o.values.idpId;let n="";return t.isEditing&&(n="You cannot change the provider for editing"),s!=null&&s.length&&(n="Bindings for this IDP have already been configured"),a.jsx(f,{id:e.id,label:e.name,imageUrl:e.logoUrl||E.SsoWizard.SAML_LOGO,isSelected:l,isDisabled:!!n,tooltip:n,actions:c(i),onClick:()=>g(e.id)},e.id)})]})})})})}function ui(t){const{customerSaml:o,isLoading:S}=j(t.id),{customerIdpMappings:d,isLoading:I}=k(t.id),g=(d==null?void 0:d.map(s=>s.idpId.toLowerCase()))||[],P=o&&(o==null?void 0:o.idpCode.toString().toLowerCase()),r=[...g],c=R(v.getSsoSettings(t.id));o&&r.push(P);const i=t.queryParams.isEdit==="true",e=S||I||!c.hasCompleted;return a.jsxs(x,{id:t.id,currentStepId:y.PROVIDER,queryParams:t.queryParams,isLoading:e,rightContent:a.jsx(b,{svg:L,className:"btn btn-outline-dark",appLink:{application:p.CRM_STUDIO,action:m.CrmStudio.CUSTOMER_SSO_WIZARD_CREATE_IDP_POPUP,args:[t.id]},children:"Create custom IDP"}),children:[a.jsx("h2",{className:"h3",children:"Select an IDP provider"}),a.jsx("div",{className:"mt-4",children:a.jsx(O,{})}),a.jsx(F,{ssoSettings:c.data??[],mappedIdps:r??[],isEditing:i,customerId:t.id})]})}export{ui as CustomerSsoWizardProviderView};
//# sourceMappingURL=dYp0YV3r.chunk.js.map
