const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/v1/vendor-ant-cds-D9wBqb0f.css","assets/v1/c4b350ac1-BjS1Z-Ak.css"])))=>i.map(i=>d[i]);
import{r as e,j as s,_ as a}from"./vendor-react-DcxrbCFs.js";import{ap as n,Y as t,f as i,_ as r,aq as o,ar as d,as as l,at as c,au as u,av as p,aw as m,ax as f,ay as x}from"./c4b350ac1-BTR_0NaM.js";import{u as g,O as h,T as j}from"./c0e977562-BYJ_xmcc.js";import{M as _}from"./vendor-intl-C0z7gCkr.js";import{u as b}from"./vendor-query-DdY22HAU.js";function y({surface:a,isOpen:i,onClose:r,title:o,subtitle:d}){const{handleUpgradeClick:l,handleDismissed:c}=g(a,i),u=e.useRef(!1),p=e.useCallback(()=>{u.current||c(),u.current=!1,r()},[c,r]);return s.jsx(n,{isOpen:i,onClose:p,modalSize:"lg",hasCloseButton:!0,className:"sm:!px-8 sm:!pt-8 sm:!pb-8 !px-6 !pt-8 !pb-8 !min-h-0",title:s.jsx("div",{className:"font-xl-bold",children:o}),children:s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 w-full py-3 mt-4 px-4 border-0.5 border-border-300 rounded-xl text-left",children:[s.jsx(h,{className:"w-5 h-5 text-text-300 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("p",{className:"font-base-bold text-text-000 flex items-center gap-2",children:[s.jsx(_,{defaultMessage:"Share with your team",id:"SR0wOS9AQM"}),s.jsx(j,{})]}),s.jsx("p",{className:"font-base text-text-300",children:d})]})]}),s.jsx("div",{className:"mt-2 flex w-full items-center justify-end gap-2",children:s.jsx(t,{variant:"secondary",size:"default",onClick:()=>{u.current=!0,l()},children:s.jsx(_,{defaultMessage:"Upgrade to Team plan",id:"g5TMaIxuqQ"})})})]})})}const v="pending_shares";function S(e){const{activeOrganization:s}=i(),a=s?.uuid;return r(`/api/organizations/${a}/projects/${e}/pending_shares`,{queryKey:[v,{orgUuid:a,projectUuid:e}],enabled:!!a&&!!e,meta:{noToast:!0}})}function T(e){const{activeOrganization:s}=i(),a=s?.uuid;return r(`/api/organizations/${a}/skills/${e}/pending_shares`,{queryKey:[v,{orgUuid:a,skillId:e}],enabled:!!a&&!!e,meta:{noToast:!0}})}function z(e={}){const{activeOrganization:s}=i(),a=s?.uuid,n=b();return o(`/api/organizations/${a}/pending_shares`,"POST",{...e,enabled:!!a,async onSuccess(s,t,i){const r="skill"===t.resource_type?[v,{orgUuid:a,skillId:t.resource_id}]:[v,{orgUuid:a,projectUuid:t.resource_id}];"pending"===s.pending_share.status&&n.setQueryData(r,e=>[...e??[],s.pending_share]),await(e.onSuccess?.(s,t,i))}})}function O(e={}){const{activeOrganization:s}=i(),a=s?.uuid,n=b();return o(e=>`/api/organizations/${a}/pending_shares/${e.pendingShareId}`,"DELETE",{...e,enabled:!!a,async onSuccess(s,a,t){n.setQueriesData({queryKey:[v]},e=>e?.filter(e=>e.id!==a.pendingShareId)),await(e.onSuccess?.(s,a,t))}})}function N(){const e=d(),s=l(),{unclaimedSeatsByTier:a}=c(),{data:n}=u(),t=p(),{data:i}=m(),{tiers:r}=f({includeUnassigned:!1}),o=e?"enterprise_usage_based":i?.default_new_member_tier??r[0]??"unassigned",x=new Set(n?.tiers_with_unlimited_seats??[]);return{defaultSeatTier:o,stripePromise:t,seatsNeededFor:e=>{if(!s)return 0;let n=0;for(const s of r){if(x.has(s))return 0;n+=a[s]||0}return Math.max(0,e-n)}}}const C=e.lazy(()=>a(()=>import("./ccf5b4c65-C56oYKHd.js"),__vite__mapDeps([0,1])).then(e=>({default:e.Elements}))),M=e.lazy(()=>a(()=>import("./c818056db-CAUHgqrv.js").then(e=>e.a),__vite__mapDeps([0,1])).then(e=>({default:e.InsufficientSeatsModal})));function w({isOpen:a,stripePromise:t,onClose:i,onCloseAddMemberModal:r,emails:o,role:d,seatTier:l,seatsNeeded:c,onSendInvites:u}){return s.jsx(e.Suspense,{fallback:s.jsx(n,{isOpen:a,onClose:r,modalSize:"md",children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(x,{size:"sm"})})}),children:s.jsx(C,{stripe:t,children:s.jsx(M,{isOpen:a,onClose:i,onCloseAddMemberModal:r,emails:o,role:d,seatTier:l,canChangeTier:!1,crossTierAssign:!0,seatsNeeded:c,inviteType:1===o.length?"individual":"bulk",onSendInvites:u})})})}export{w as L,y as T,z as a,O as b,N as c,S as d,T as u};
