import{r as e,j as s,M as a}from"./vendor--leCAzSo.js";import{a as n,b as t,c as r,d as i,e as l,f as c,g as o,h as d,i as m,j as x,k as h,l as p,m as u,n as f}from"./c723dd3dd-58n3MxoB.js";import{T as j,I as g}from"./c87b7760f-oG193yNp.js";import{M as b,m as v,a as N}from"./cb6154120-B04LnQv2.js";import{a8 as y,aw as k}from"./index-DZuQva-j.js";import{c as w}from"./ca9c256b9-7brFE8T2.js";const L=e.forwardRef((e,a)=>{const{className:r,children:i,...l}=e;return s.jsxs(n,{ref:a,className:`group/cb inline-flex items-center border-0 outline-none hide-focus-ring ring-focus cursor-default ${r??""}`,...l,children:[s.jsx("span",{className:"inline-flex items-center justify-center size-[16px] shrink-0 p-[2.4px]",children:s.jsx("span",{className:"flex items-center justify-center size-full rounded-[2.4px] bg-[var(--ui-switch-off-background)] group-data-[checked]/cb:bg-[var(--accent)]",children:s.jsx(t,{className:"flex items-center justify-center data-[unchecked]:hidden",keepMounted:!0,children:s.jsx("svg",{width:"6",height:"5",viewBox:"0 0 5.875 5.375",fill:"none","aria-hidden":"true",className:"text-[var(--core-white)]",children:s.jsx("path",{d:"M0.500014 2.75004L2.25001 4.87504L5.37501 0.500039",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})})})}),i]})});function z({items:n,groups:t,itemToLabel:L,renderItemIcon:z,renderItemTrailing:C,value:I,onSelect:M,icon:S,triggerLabel:E,triggerAriaLabel:T,triggerClassName:F,tooltip:O,placeholder:R,emptyMessage:V,disabled:$,side:q="top",onQueryChange:A,isLoading:B=!1,footer:D}){const[G,H]=e.useState(""),K=e.useMemo(()=>function(e,s,a){if(""===s)return e.slice();const n=e.map(e=>{const s=a(e),n=s.lastIndexOf("/");return{item:e,label:s,name:n>=0?s.slice(n+1):s}});return k(n,s,[{name:"name",weight:.7},{name:"label",weight:.3}]).map(e=>e.item.item)}(n,G,L),[n,G,L]),[P,Q]=e.useState(!1),_=e.useRef(!1),J=P||""===G.trim()?void 0:K[0],U=e=>s.jsxs(u,{value:e,className:N({className:w("group","data-[selected]:before:bg-fill-uncontained-hover",e===J&&"before:bg-fill-uncontained-hover")}),children:[z&&s.jsx("span",{className:"flex items-center justify-center size-[16px] shrink-0",children:z(e)}),s.jsx("span",{className:"flex-1 min-w-0 truncate",children:L(e)}),C?C(e):s.jsx(f,{className:"flex items-center justify-center size-[16px] shrink-0 ml-[6px]",children:s.jsx(g,{name:"CheckSelection",size:"m"})})]},L(e)),W=s.jsxs("div",{className:"relative flex items-center gap-g5 mx-[6px] px-p6 h-h4 shrink-0 rounded-r5 bg-[var(--z0)]",children:[s.jsx(g,{name:"Search",size:"s"}),s.jsx(p,{placeholder:R,"aria-label":R,onKeyDown:e=>{"Enter"===e.key&&!_.current&&""!==G.trim()&&K.length>0&&M(K[0])},className:"flex-1 min-w-0 bg-transparent border-0 outline-none hide-focus-ring text-body text-t8 placeholder:text-t6"}),B&&s.jsxs("div",{role:"status",className:"absolute inset-x-0 h-[2px] overflow-hidden rounded-full "+("top"===q?"top-0":"bottom-0"),children:[s.jsx("div",{className:"epitaxy-linear-sweep h-full w-[30%] bg-[var(--t6)]"}),s.jsx("span",{className:"sr-only",children:s.jsx(a,{defaultMessage:"Loading results",id:"LvCm24GPqE"})})]})]}),X=t&&""===G;return s.jsxs(r,{items:K,itemToStringLabel:L,filter:null,onInputValueChange:e=>{H(e),A?.(e)},onItemHighlighted:e=>{const s=void 0!==e;_.current=s,Q(s)},value:I,onValueChange:e=>{null!==e&&M(e)},children:[(e=>O?s.jsx(j,{label:O,children:$?s.jsx("span",{className:"inline-flex",children:e}):e}):e)(s.jsxs(i,{"aria-label":T,className:F,disabled:$,children:[s.jsx(g,{name:S,size:"s"}),E&&s.jsx("span",{className:"truncate max-w-[200px]",children:E})]})),s.jsx(l,{children:s.jsx(c,{className:"epitaxy-root z-[60]",side:q,align:"start",sideOffset:8,children:s.jsxs(o,{className:`${v("popover")} !max-h-[min(360px,var(--available-height))]`,children:[s.jsx(y,{elevation:"popover"}),"bottom"===q&&s.jsxs(s.Fragment,{children:[W,s.jsx("div",{className:"h-p5 shrink-0"})]}),s.jsx(d,{className:b,children:X?t.map(e=>e.items.length>0&&s.jsxs(m,{children:[s.jsx(x,{className:"px-p8 py-p2 text-footnote text-t6",children:e.label}),e.items.map(U)]},e.label)):K.map(U)}),s.jsx(h,{className:"px-p8 py-p5 text-body text-t6",children:V}),D,"top"===q&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-p5 shrink-0"}),W]})]})})})]})}L.displayName="EpitaxyCheckbox";export{z as E,L as a};
