import{Lr as e}from"./shared-0-C4kdVF7Y.js";import{Ei as s,ki as a}from"./vendor-frame-CwiylG4Y.js";import{nn as t}from"./vendor-all-2-BJdkbLSj.js";import{$ as r,O as l,V as n,nt as i}from"./shared-frame-DbQbH4Yr.js";var o=a();function d({value:a,onChange:d,roles:c,disabled:x=!1,removeOption:p,triggerClassName:m,align:h="end",triggerAriaLabel:u,popupClassName:j,triggerVariant:g="compact"}){const b=c.find(e=>e.value===a),f="row"===g?"flex items-center gap-2 rounded px-3 py-2 text-body text-primary transition-colors hover:bg-alpha-1 data-[popup-open]:bg-alpha-1":"flex h-7 items-center gap-1 rounded-md px-2 text-xs text-text-300 transition-colors hover:bg-bg-200 hover:text-text-100 data-[popup-open]:bg-bg-200 data-[popup-open]:text-text-100",v=(0,o.jsx)("span",{className:"truncate",children:b?.label??(0,o.jsx)(t,{id:"kQAf2d9u+x",defaultMessage:"Select"})});if(x)return(0,o.jsx)("span",{className:s("row"===g?"flex items-center gap-2 rounded px-3 py-2 text-body text-disabled":"flex h-7 items-center gap-1 rounded-md px-2 text-xs text-text-400",m),children:v});const N=p&&(0,o.jsx)(l.Item,{variant:"danger",disabled:p.disabled,onClick:p.onSelect,children:p.label??(0,o.jsx)(t,{id:"G/yZLul6P1",defaultMessage:"Remove"})});return(0,o.jsxs)(l.Root,{children:[(0,o.jsx)(l.Trigger,{render:(0,o.jsxs)("button",{type:"button","aria-label":u,className:s(f,m),children:[v,(0,o.jsx)(e,{className:"row"===g?"size-4 text-muted":"size-3.5"})]})}),(0,o.jsx)(i,{className:"contents",children:(0,o.jsxs)(l.Popup,{align:h,className:s("min-w-56",j),children:[(0,o.jsx)(l.Group,{children:c.filter(e=>!e.hidden).map(e=>{const s=(0,o.jsxs)("span",{className:"flex min-w-0 flex-col whitespace-normal",children:[(0,o.jsx)("span",{children:e.label}),e.description&&(0,o.jsx)("span",{className:"text-footnote text-muted",children:e.description})]});return e.locked?(0,o.jsx)(l.Item,{disabled:!0,trailing:(0,o.jsx)("span",{className:"-mr-1 flex size-4 shrink-0 items-center justify-center",children:(0,o.jsx)(r,{name:"Lock",size:"sm"})}),className:"!items-start",children:s},e.value):(0,o.jsx)(l.Item,{checked:e.value===a,checkedRole:"radio",onClick:()=>d(e.value),className:"!items-start",children:s},e.value)})}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.Separator,{}),p.disabled&&p.disabledTooltip?(0,o.jsx)(n,{content:p.disabledTooltip,side:"left",children:(0,o.jsx)("span",{className:"block",children:N})}):N]})]})})]})}export{d as t};