import{o as a}from"./rolldown-runtime-iuO8RvI4.js";import{At as e}from"./vendor-all-0-fRSUBfCr.js";import{Ll as i,Nf as t,Qf as r,Ul as s,Vm as n,ap as o,dd as u,dm as d,fm as l,jm as m,xp as c,zm as p}from"./shared-0-C4kdVF7Y.js";import{Mi as g}from"./vendor-frame-CwiylG4Y.js";import{g as v}from"./shared-3-D-Ux4aGn.js";var y=a(g());function f({onError:a,organizationUuid:e}){const{activeOrganization:t}=i(),r=e??t?.uuid,{data:s,variables:n,...o}=p(`/api/billing/${r}/ss_enterprise_pricing`,"POST",{enabled:!!r,meta:{noToast:!0},onError:a}),[u,d]=(0,y.useState)(),[l,m]=(0,y.useState)();return(0,y.useEffect)(()=>{s&&(d(s),m(n))},[s,n]),{data:u,variables:l,...o}}var _=a=>{const{activeOrganization:e}=i();return p(`/api/organizations/${e?.uuid}/subscription/ss-enterprise`,"PUT",{enabled:!!e,...a?.noToast?{meta:{noToast:a.noToast}}:{}})};function b({enabled:a=!0}={}){const{activeOrganization:e}=i(),t=e?.uuid,r=s(u.BillingManage);return n(`/api/organizations/${t}/team/upgrade_to_ss_enterprise_eligibility`,{queryKey:["upgrade_to_ss_enterprise_eligibility",t],enabled:a&&!!t&&r,meta:{noToast:!0}})}function q(a={}){const{activeOrganization:s}=i(),n=e(),u=a.organizationUuid??s?.uuid;return p(`/api/organizations/${u}/team/upgrade_to_ss_enterprise`,"PUT",{...a,async onSuccess(e,i,s){!e.idvRequirement||v(e.idvRequirement.status)?(n.setQueriesData({queryKey:[d,u]},a=>{if(a)return{...a,status:"active"}}),n.invalidateQueries({queryKey:[c,u]}),n.invalidateQueries({queryKey:[l,u]}),n.invalidateQueries({queryKey:[m,u]}),n.invalidateQueries({queryKey:[r,u]}),await n.invalidateQueries({queryKey:[o,u]}),await n.invalidateQueries({queryKey:[t]}),await(a.onSuccess?.(e,i,s))):await(a.onSuccess?.(e,i,s))},enabled:!!u})}export{q as i,f as n,b as r,_ as t};