1import{f as b,r as d,j as i}from"./vendor-react-Bq0AAjM7.js";import{u as x,O as v}from"./useOrganisationTermsConsent-BTnUSwjK.js";import{b2 as y,z as I,w,cM as j,aM as E,aA as R,F as C,J as h}from"./main-D49UUfSD.js";import{u as T}from"./vendor-misc-DMccS2Mw.js";import"./vendor-runtime-DG-GlVKR.js";import"./isEnterpriseOrganisation-Fjb8mzJZ.js";import"./index-Dl4pFCyo.js";import"./vendor-icons-DePtd98t.js";import"./vendor-ui-HM9MEgw-.js";import"./vendor-analytics-DaFEZfd9.js";import"./vendor-sentry-BBJkNfRx.js";try{let e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="68b41c98-d4ab-4ff4-aeef-a7abbf1d1282",e._sentryDebugIdIdentifier="sentry-dbid-68b41c98-d4ab-4ff4-aeef-a7abbf1d1282")}catch{}const $=e=>(e??"").split(",").map(t=>t.trim()).filter(t=>t&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)),F=()=>{const{organisationId:e}=y(),t=I(),a=b(),l=d.useRef(!1),s=x(),m=w(),n=d.useMemo(()=>$(m.invites),[m.invites]),{mutate:c,isPending:u,isSuccess:p,isError:g}=T({mutationFn:async r=>t.organisations.id(e).invites.send(r,s.inviteOptions),onSuccess:(r,o)=>{E.success({title:"Invites sent",description:`Invites were sent to ${o.length} ${o.length===1?"person":"people"}.`}),a(`/org/${e}/dashboard`,{replace:!0})},onError:(r,o)=>{console.error("Failed to send invites:",r),j({action:"send invites",error:r,onRetry:()=>c(o)}),a(`/org/${e}/dashboard`,{replace:!0})}}),f=d.useCallback(()=>{l.current=!0,c(n.map(r=>({email:r,role:R.MEMBER})))},[n,c]);return d.useEffect(()=>{if(!(l.current||u||p||g)){if(n.length===0){l.current=!0,a(`/org/${e}/dashboard`,{replace:!0});return}s.isLoading||s.isRequired||f()}},[n,a,e,u,p,g,f,s.isLoading,s.isRequired]),u||s.isLoading?i.jsx(C,{title:"Sending invitesâ¦"}):s.isRequired&&n.length>0?i.jsx("div",{className:"flex h-full min-h-80 w-full items-center justify-center bg-rb-parchment-light p-4 sm:p-6",children:i.jsxs("div",{className:"flex w-full max-w-sm flex-col gap-4",children:[i.jsxs("h1",{className:"text-title-sm font-medium text-balance text-rb-darkbtn",children:["Invite ",n.length===1?n[0]:`${n.length} colleagues`]}),i.jsx(v,{hasAccepted:s.hasAccepted,onAcceptedChange:s.setHasAccepted}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(h,{size:"md",onClick:()=>a(`/org/${e}/dashboard`,{replace:!0}),children:"Cancel"}),i.jsx(h,{variant:"brand",size:"md",onClick:f,disabled:!s.canSendInvites,className:"flex-1",children:"Send invite"})]})]})}):null};export{F as AutoInvitePage};
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.