import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{El as a,Ul as s,dd as r,lu as n}from"./shared-0-C4kdVF7Y.js";import{Mi as o,ki as i}from"./vendor-frame-CwiylG4Y.js";import{rn as m}from"./vendor-all-2-BJdkbLSj.js";import{x as l}from"./shared-frame-DbQbH4Yr.js";import{U as t}from"./shared-13-Uoqh3mCb.js";var d=e(o()),u=i();function g(){const e=n(),a=s(r.OwnersManage),o=s(r.MembersManage);return e&&(a||o)}function c(){const e=m();return(0,d.useMemo)(()=>({user:{value:"user",label:e.formatMessage({defaultMessage:"User",id:"EwRIOmjuqR"}),description:e.formatMessage({defaultMessage:"Can create chats",id:"V1xV3xRuDo"})},membershipAdmin:{value:"membership_admin",label:e.formatMessage({defaultMessage:"Admin",id:"iHN12uxiqf"}),description:e.formatMessage({defaultMessage:"Can manage user membership",id:"s+lL3TYjLp"})},owner:{value:"owner",label:e.formatMessage({defaultMessage:"Owner",id:"zINlaoBlL/"}),description:e.formatMessage({defaultMessage:"Can manage user roles and organization settings",id:"gmqgos5sJs"})},primaryOwner:{value:"primary_owner",label:e.formatMessage({defaultMessage:"Primary owner",id:"NXBWjcGhIs"}),description:e.formatMessage({defaultMessage:"Can manage org and data settings",id:"n+urWme5N2"})},managed:{value:"managed",label:e.formatMessage({defaultMessage:"Custom",id:"Sjo1P44FYy"}),description:e.formatMessage({defaultMessage:"Can access features from custom roles assigned by group membership",id:"zg6yp5A84z"})}}),[e])}function f(){const e=c(),a=g();return(0,d.useMemo)(()=>{const s=[...a?[e.managed]:[],e.user,e.membershipAdmin,e.owner,e.primaryOwner];return Object.fromEntries(s.map(e=>[e.value,e.label]))},[e.user,e.membershipAdmin,e.owner,e.primaryOwner,e.managed,a])}function p({value:e,onSelect:n,disabled:o,className:i,label:f,matchWidth:p,allowPrimaryOwnerSelection:b,rolesLockedByProvisioning:h}){const w=m(),j=c(),y=s(r.MembershipAdminsManage),v=s(r.OwnersManage),x=g(),O="primary_owner"===a()?.role,C=w.formatMessage({defaultMessage:"Managed by your SSO Identity Provider",id:"AHkzQ+FqjJ"}),N=e=>h?{...e,disabled:!0,description:C}:e,A=(0,d.useMemo)(()=>[...x?[N(j.managed)]:[],N(j.user),...y?[N(j.membershipAdmin)]:[],...v?[N(j.owner)]:[],...O&&b?[j.primaryOwner]:[]],[j,x,y,v,O,b,h]),z=t(),k=(0,d.useCallback)(e=>{e&&n(e)},[n]);return(0,u.jsx)(M,{label:f,children:(0,u.jsx)(l,{mode:"select",size:"sm",searchable:!1,fullWidth:p??!1,items:A,value:e,onChange:k,disabled:o,placeholder:z[e]??e.replace("_"," "),className:i,popupClassName:p?void 0:"min-w-72"})})}function M({label:e,children:a}){return e?(0,u.jsxs)("label",{className:"flex flex-col gap-sm",children:[(0,u.jsx)("span",{className:"text-footnote text-secondary",children:e}),a]}):(0,u.jsx)(u.Fragment,{children:a})}export{g as i,M as n,f as r,p as t};