Files
hive/frontend/node_modules/@headlessui/react/dist/components/combobox/combobox.js
anthonyrawlins 85bf1341f3 Add comprehensive frontend UI and distributed infrastructure
Frontend Enhancements:
- Complete React TypeScript frontend with modern UI components
- Distributed workflows management interface with real-time updates
- Socket.IO integration for live agent status monitoring
- Agent management dashboard with cluster visualization
- Project management interface with metrics and task tracking
- Responsive design with proper error handling and loading states

Backend Infrastructure:
- Distributed coordinator for multi-agent workflow orchestration
- Cluster management API with comprehensive agent operations
- Enhanced database models for agents and projects
- Project service for filesystem-based project discovery
- Performance monitoring and metrics collection
- Comprehensive API documentation and error handling

Documentation:
- Complete distributed development guide (README_DISTRIBUTED.md)
- Comprehensive development report with architecture insights
- System configuration templates and deployment guides

The platform now provides a complete web interface for managing the distributed AI cluster
with real-time monitoring, workflow orchestration, and agent coordination capabilities.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-10 08:41:59 +10:00

2 lines
20 KiB
JavaScript

import{useVirtualizer as Ee}from"@tanstack/react-virtual";import w,{createContext as ie,createRef as Pe,Fragment as me,useCallback as Ie,useContext as ue,useEffect as Ve,useMemo as U,useReducer as _e,useRef as B,useState as Fe}from"react";import{useComputed as pe}from'../../hooks/use-computed.js';import{useControllable as Le}from'../../hooks/use-controllable.js';import{useDisposables as se}from'../../hooks/use-disposables.js';import{useEvent as m}from'../../hooks/use-event.js';import{useId as Q}from'../../hooks/use-id.js';import{useIsoMorphicEffect as H}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as De}from'../../hooks/use-latest-value.js';import{useOutsideClick as Me}from'../../hooks/use-outside-click.js';import{useOwnerDocument as he}from'../../hooks/use-owner.js';import{useResolveButtonType as Be}from'../../hooks/use-resolve-button-type.js';import{useSyncRefs as Z}from'../../hooks/use-sync-refs.js';import{useTrackedPointer as ke}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as we}from'../../hooks/use-tree-walker.js';import{useWatch as Te}from'../../hooks/use-watch.js';import{Features as Ue,Hidden as He}from'../../internal/hidden.js';import{OpenClosedProvider as Ne,State as re,useOpenClosed as Ge}from'../../internal/open-closed.js';import{history as xe}from'../../utils/active-element-history.js';import{isDisabledReactIssue7711 as Xe}from'../../utils/bugs.js';import{calculateActiveIndex as ge,Focus as y}from'../../utils/calculate-active-index.js';import{disposables as ve}from'../../utils/disposables.js';import{sortByDomNode as je}from'../../utils/focus-management.js';import{objectToFormEntries as Je}from'../../utils/form.js';import{match as W}from'../../utils/match.js';import{isMobile as Ke}from'../../utils/platform.js';import{compact as We,Features as Oe,forwardRefWithAs as $,render as q}from'../../utils/render.js';import{Keys as M}from'../keyboard.js';var $e=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))($e||{}),qe=(o=>(o[o.Single=0]="Single",o[o.Multi=1]="Multi",o))(qe||{}),ze=(a=>(a[a.Pointer=0]="Pointer",a[a.Focus=1]="Focus",a[a.Other=2]="Other",a))(ze||{}),Ye=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.RegisterOption=3]="RegisterOption",e[e.UnregisterOption=4]="UnregisterOption",e[e.RegisterLabel=5]="RegisterLabel",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualOptions=7]="UpdateVirtualOptions",e))(Ye||{});function de(t,r=o=>o){let o=t.activeOptionIndex!==null?t.options[t.activeOptionIndex]:null,a=r(t.options.slice()),i=a.length>0&&a[0].dataRef.current.order!==null?a.sort((p,c)=>p.dataRef.current.order-c.dataRef.current.order):je(a,p=>p.dataRef.current.domRef.current),u=o?i.indexOf(o):null;return u===-1&&(u=null),{options:i,activeOptionIndex:u}}let Qe={[1](t){var r;return(r=t.dataRef.current)!=null&&r.disabled||t.comboboxState===1?t:{...t,activeOptionIndex:null,comboboxState:1}},[0](t){var r,o;if((r=t.dataRef.current)!=null&&r.disabled||t.comboboxState===0)return t;if((o=t.dataRef.current)!=null&&o.value){let a=t.dataRef.current.calculateIndex(t.dataRef.current.value);if(a!==-1)return{...t,activeOptionIndex:a,comboboxState:0}}return{...t,comboboxState:0}},[2](t,r){var u,p,c,e,l;if((u=t.dataRef.current)!=null&&u.disabled||(p=t.dataRef.current)!=null&&p.optionsRef.current&&!((c=t.dataRef.current)!=null&&c.optionsPropsRef.current.static)&&t.comboboxState===1)return t;if(t.virtual){let T=r.focus===y.Specific?r.idx:ge(r,{resolveItems:()=>t.virtual.options,resolveActiveIndex:()=>{var f,v;return(v=(f=t.activeOptionIndex)!=null?f:t.virtual.options.findIndex(S=>!t.virtual.disabled(S)))!=null?v:null},resolveDisabled:t.virtual.disabled,resolveId(){throw new Error("Function not implemented.")}}),g=(e=r.trigger)!=null?e:2;return t.activeOptionIndex===T&&t.activationTrigger===g?t:{...t,activeOptionIndex:T,activationTrigger:g}}let o=de(t);if(o.activeOptionIndex===null){let T=o.options.findIndex(g=>!g.dataRef.current.disabled);T!==-1&&(o.activeOptionIndex=T)}let a=r.focus===y.Specific?r.idx:ge(r,{resolveItems:()=>o.options,resolveActiveIndex:()=>o.activeOptionIndex,resolveId:T=>T.id,resolveDisabled:T=>T.dataRef.current.disabled}),i=(l=r.trigger)!=null?l:2;return t.activeOptionIndex===a&&t.activationTrigger===i?t:{...t,...o,activeOptionIndex:a,activationTrigger:i}},[3]:(t,r)=>{var u,p,c;if((u=t.dataRef.current)!=null&&u.virtual)return{...t,options:[...t.options,r.payload]};let o=r.payload,a=de(t,e=>(e.push(o),e));t.activeOptionIndex===null&&(p=t.dataRef.current)!=null&&p.isSelected(r.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(o));let i={...t,...a,activationTrigger:2};return(c=t.dataRef.current)!=null&&c.__demoMode&&t.dataRef.current.value===void 0&&(i.activeOptionIndex=0),i},[4]:(t,r)=>{var a;if((a=t.dataRef.current)!=null&&a.virtual)return{...t,options:t.options.filter(i=>i.id!==r.id)};let o=de(t,i=>{let u=i.findIndex(p=>p.id===r.id);return u!==-1&&i.splice(u,1),i});return{...t,...o,activationTrigger:2}},[5]:(t,r)=>t.labelId===r.id?t:{...t,labelId:r.id},[6]:(t,r)=>t.activationTrigger===r.trigger?t:{...t,activationTrigger:r.trigger},[7]:(t,r)=>{var a;if(((a=t.virtual)==null?void 0:a.options)===r.options)return t;let o=t.activeOptionIndex;if(t.activeOptionIndex!==null){let i=r.options.indexOf(t.virtual.options[t.activeOptionIndex]);i!==-1?o=i:o=null}return{...t,activeOptionIndex:o,virtual:Object.assign({},t.virtual,{options:r.options})}}},be=ie(null);be.displayName="ComboboxActionsContext";function ee(t){let r=ue(be);if(r===null){let o=new Error(`<${t} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,ee),o}return r}let Ce=ie(null);function Ze(t){var c;let r=j("VirtualProvider"),[o,a]=U(()=>{let e=r.optionsRef.current;if(!e)return[0,0];let l=window.getComputedStyle(e);return[parseFloat(l.paddingBlockStart||l.paddingTop),parseFloat(l.paddingBlockEnd||l.paddingBottom)]},[r.optionsRef.current]),i=Ee({scrollPaddingStart:o,scrollPaddingEnd:a,count:r.virtual.options.length,estimateSize(){return 40},getScrollElement(){var e;return(e=r.optionsRef.current)!=null?e:null},overscan:12}),[u,p]=Fe(0);return H(()=>{p(e=>e+1)},[(c=r.virtual)==null?void 0:c.options]),w.createElement(Ce.Provider,{value:i},w.createElement("div",{style:{position:"relative",width:"100%",height:`${i.getTotalSize()}px`},ref:e=>{if(e){if(typeof process!="undefined"&&process.env.JEST_WORKER_ID!==void 0||r.activationTrigger===0)return;r.activeOptionIndex!==null&&r.virtual.options.length>r.activeOptionIndex&&i.scrollToIndex(r.activeOptionIndex)}}},i.getVirtualItems().map(e=>{var l;return w.createElement(me,{key:e.key},w.cloneElement((l=t.children)==null?void 0:l.call(t,{option:r.virtual.options[e.index],open:r.comboboxState===0}),{key:`${u}-${e.key}`,"data-index":e.index,"aria-setsize":r.virtual.options.length,"aria-posinset":e.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${e.start}px)`,overflowAnchor:"none"}}))})))}let ce=ie(null);ce.displayName="ComboboxDataContext";function j(t){let r=ue(ce);if(r===null){let o=new Error(`<${t} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,j),o}return r}function et(t,r){return W(r.type,Qe,t,r)}let tt=me;function ot(t,r){var fe;let{value:o,defaultValue:a,onChange:i,form:u,name:p,by:c=null,disabled:e=!1,__demoMode:l=!1,nullable:T=!1,multiple:g=!1,immediate:f=!1,virtual:v=null,...S}=t,R=!1,s=null,[I=g?[]:void 0,V]=Le(o,i,a),[_,E]=_e(et,{dataRef:Pe(),comboboxState:l?0:1,options:[],virtual:s?{options:s.options,disabled:(fe=s.disabled)!=null?fe:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,labelId:null}),k=B(!1),J=B({static:!1,hold:!1}),K=B(null),z=B(null),te=B(null),X=B(null),x=m(typeof c=="string"?(d,b)=>{let P=c;return(d==null?void 0:d[P])===(b==null?void 0:b[P])}:c!=null?c:(d,b)=>d===b),O=m(d=>s?c===null?s.options.indexOf(d):s.options.findIndex(b=>x(b,d)):_.options.findIndex(b=>x(b.dataRef.current.value,d))),L=Ie(d=>W(n.mode,{[1]:()=>I.some(b=>x(b,d)),[0]:()=>x(I,d)}),[I]),oe=m(d=>_.activeOptionIndex===O(d)),n=U(()=>({..._,immediate:R,optionsPropsRef:J,labelRef:K,inputRef:z,buttonRef:te,optionsRef:X,value:I,defaultValue:a,disabled:e,mode:g?1:0,virtual:_.virtual,get activeOptionIndex(){if(k.current&&_.activeOptionIndex===null&&(s?s.options.length>0:_.options.length>0)){if(s){let b=s.options.findIndex(P=>{var G,Y;return!((Y=(G=s==null?void 0:s.disabled)==null?void 0:G.call(s,P))!=null&&Y)});if(b!==-1)return b}let d=_.options.findIndex(b=>!b.dataRef.current.disabled);if(d!==-1)return d}return _.activeOptionIndex},calculateIndex:O,compare:x,isSelected:L,isActive:oe,nullable:T,__demoMode:l}),[I,a,e,g,T,l,_,s]);H(()=>{s&&E({type:7,options:s.options})},[s,s==null?void 0:s.options]),H(()=>{_.dataRef.current=n},[n]),Me([n.buttonRef,n.inputRef,n.optionsRef],()=>le.closeCombobox(),n.comboboxState===0);let F=U(()=>{var d,b,P;return{open:n.comboboxState===0,disabled:e,activeIndex:n.activeOptionIndex,activeOption:n.activeOptionIndex===null?null:n.virtual?n.virtual.options[(d=n.activeOptionIndex)!=null?d:0]:(P=(b=n.options[n.activeOptionIndex])==null?void 0:b.dataRef.current.value)!=null?P:null,value:I}},[n,e,I]),A=m(()=>{if(n.activeOptionIndex!==null){if(n.virtual)ae(n.virtual.options[n.activeOptionIndex]);else{let{dataRef:d}=n.options[n.activeOptionIndex];ae(d.current.value)}le.goToOption(y.Specific,n.activeOptionIndex)}}),h=m(()=>{E({type:0}),k.current=!0}),C=m(()=>{E({type:1}),k.current=!1}),D=m((d,b,P)=>(k.current=!1,d===y.Specific?E({type:2,focus:y.Specific,idx:b,trigger:P}):E({type:2,focus:d,trigger:P}))),N=m((d,b)=>(E({type:3,payload:{id:d,dataRef:b}}),()=>{n.isActive(b.current.value)&&(k.current=!0),E({type:4,id:d})})),ye=m(d=>(E({type:5,id:d}),()=>E({type:5,id:null}))),ae=m(d=>W(n.mode,{[0](){return V==null?void 0:V(d)},[1](){let b=n.value.slice(),P=b.findIndex(G=>x(G,d));return P===-1?b.push(d):b.splice(P,1),V==null?void 0:V(b)}})),Re=m(d=>{E({type:6,trigger:d})}),le=U(()=>({onChange:ae,registerOption:N,registerLabel:ye,goToOption:D,closeCombobox:C,openCombobox:h,setActivationTrigger:Re,selectActiveOption:A}),[]),Ae=r===null?{}:{ref:r},ne=B(null),Se=se();return Ve(()=>{ne.current&&a!==void 0&&Se.addEventListener(ne.current,"reset",()=>{V==null||V(a)})},[ne,V]),w.createElement(be.Provider,{value:le},w.createElement(ce.Provider,{value:n},w.createElement(Ne,{value:W(n.comboboxState,{[0]:re.Open,[1]:re.Closed})},p!=null&&I!=null&&Je({[p]:I}).map(([d,b],P)=>w.createElement(He,{features:Ue.Hidden,ref:P===0?G=>{var Y;ne.current=(Y=G==null?void 0:G.closest("form"))!=null?Y:null}:void 0,...We({key:d,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:u,disabled:e,name:d,value:b})})),q({ourProps:Ae,theirProps:S,slot:F,defaultTag:tt,name:"Combobox"}))))}let nt="input";function rt(t,r){var X,x,O,L,oe;let o=Q(),{id:a=`headlessui-combobox-input-${o}`,onChange:i,displayValue:u,type:p="text",...c}=t,e=j("Combobox.Input"),l=ee("Combobox.Input"),T=Z(e.inputRef,r),g=he(e.inputRef),f=B(!1),v=se(),S=m(()=>{l.onChange(null),e.optionsRef.current&&(e.optionsRef.current.scrollTop=0),l.goToOption(y.Nothing)}),R=function(){var n;return typeof u=="function"&&e.value!==void 0?(n=u(e.value))!=null?n:"":typeof e.value=="string"?e.value:""}();Te(([n,F],[A,h])=>{if(f.current)return;let C=e.inputRef.current;C&&((h===0&&F===1||n!==A)&&(C.value=n),requestAnimationFrame(()=>{if(f.current||!C||(g==null?void 0:g.activeElement)!==C)return;let{selectionStart:D,selectionEnd:N}=C;Math.abs((N!=null?N:0)-(D!=null?D:0))===0&&D===0&&C.setSelectionRange(C.value.length,C.value.length)}))},[R,e.comboboxState,g]),Te(([n],[F])=>{if(n===0&&F===1){if(f.current)return;let A=e.inputRef.current;if(!A)return;let h=A.value,{selectionStart:C,selectionEnd:D,selectionDirection:N}=A;A.value="",A.value=h,N!==null?A.setSelectionRange(C,D,N):A.setSelectionRange(C,D)}},[e.comboboxState]);let s=B(!1),I=m(()=>{s.current=!0}),V=m(()=>{v.nextFrame(()=>{s.current=!1})}),_=m(n=>{switch(f.current=!0,n.key){case M.Enter:if(f.current=!1,e.comboboxState!==0||s.current)return;if(n.preventDefault(),n.stopPropagation(),e.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),e.mode===0&&l.closeCombobox();break;case M.ArrowDown:return f.current=!1,n.preventDefault(),n.stopPropagation(),W(e.comboboxState,{[0]:()=>l.goToOption(y.Next),[1]:()=>l.openCombobox()});case M.ArrowUp:return f.current=!1,n.preventDefault(),n.stopPropagation(),W(e.comboboxState,{[0]:()=>l.goToOption(y.Previous),[1]:()=>{l.openCombobox(),v.nextFrame(()=>{e.value||l.goToOption(y.Last)})}});case M.Home:if(n.shiftKey)break;return f.current=!1,n.preventDefault(),n.stopPropagation(),l.goToOption(y.First);case M.PageUp:return f.current=!1,n.preventDefault(),n.stopPropagation(),l.goToOption(y.First);case M.End:if(n.shiftKey)break;return f.current=!1,n.preventDefault(),n.stopPropagation(),l.goToOption(y.Last);case M.PageDown:return f.current=!1,n.preventDefault(),n.stopPropagation(),l.goToOption(y.Last);case M.Escape:return f.current=!1,e.comboboxState!==0?void 0:(n.preventDefault(),e.optionsRef.current&&!e.optionsPropsRef.current.static&&n.stopPropagation(),e.nullable&&e.mode===0&&e.value===null&&S(),l.closeCombobox());case M.Tab:if(f.current=!1,e.comboboxState!==0)return;e.mode===0&&e.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),E=m(n=>{i==null||i(n),e.nullable&&e.mode===0&&n.target.value===""&&S(),l.openCombobox()}),k=m(n=>{var A,h,C;let F=(A=n.relatedTarget)!=null?A:xe.find(D=>D!==n.currentTarget);if(f.current=!1,!((h=e.optionsRef.current)!=null&&h.contains(F))&&!((C=e.buttonRef.current)!=null&&C.contains(F))&&e.comboboxState===0)return n.preventDefault(),e.mode===0&&(e.nullable&&e.value===null?S():e.activationTrigger!==1&&l.selectActiveOption()),l.closeCombobox()}),J=m(n=>{var A,h,C;let F=(A=n.relatedTarget)!=null?A:xe.find(D=>D!==n.currentTarget);(h=e.buttonRef.current)!=null&&h.contains(F)||(C=e.optionsRef.current)!=null&&C.contains(F)||e.disabled||e.immediate&&e.comboboxState!==0&&(l.openCombobox(),v.nextFrame(()=>{l.setActivationTrigger(1)}))}),K=pe(()=>{if(e.labelId)return[e.labelId].join(" ")},[e.labelId]),z=U(()=>({open:e.comboboxState===0,disabled:e.disabled}),[e]),te={ref:T,id:a,role:"combobox",type:p,"aria-controls":(X=e.optionsRef.current)==null?void 0:X.id,"aria-expanded":e.comboboxState===0,"aria-activedescendant":e.activeOptionIndex===null?void 0:e.virtual?(x=e.options.find(n=>{var F;return!((F=e.virtual)!=null&&F.disabled(n.dataRef.current.value))&&e.compare(n.dataRef.current.value,e.virtual.options[e.activeOptionIndex])}))==null?void 0:x.id:(O=e.options[e.activeOptionIndex])==null?void 0:O.id,"aria-labelledby":K,"aria-autocomplete":"list",defaultValue:(oe=(L=t.defaultValue)!=null?L:e.defaultValue!==void 0?u==null?void 0:u(e.defaultValue):null)!=null?oe:e.defaultValue,disabled:e.disabled,onCompositionStart:I,onCompositionEnd:V,onKeyDown:_,onChange:E,onFocus:J,onBlur:k};return q({ourProps:te,theirProps:c,slot:z,defaultTag:nt,name:"Combobox.Input"})}let at="button";function lt(t,r){var S;let o=j("Combobox.Button"),a=ee("Combobox.Button"),i=Z(o.buttonRef,r),u=Q(),{id:p=`headlessui-combobox-button-${u}`,...c}=t,e=se(),l=m(R=>{switch(R.key){case M.ArrowDown:return R.preventDefault(),R.stopPropagation(),o.comboboxState===1&&a.openCombobox(),e.nextFrame(()=>{var s;return(s=o.inputRef.current)==null?void 0:s.focus({preventScroll:!0})});case M.ArrowUp:return R.preventDefault(),R.stopPropagation(),o.comboboxState===1&&(a.openCombobox(),e.nextFrame(()=>{o.value||a.goToOption(y.Last)})),e.nextFrame(()=>{var s;return(s=o.inputRef.current)==null?void 0:s.focus({preventScroll:!0})});case M.Escape:return o.comboboxState!==0?void 0:(R.preventDefault(),o.optionsRef.current&&!o.optionsPropsRef.current.static&&R.stopPropagation(),a.closeCombobox(),e.nextFrame(()=>{var s;return(s=o.inputRef.current)==null?void 0:s.focus({preventScroll:!0})}));default:return}}),T=m(R=>{if(Xe(R.currentTarget))return R.preventDefault();o.comboboxState===0?a.closeCombobox():(R.preventDefault(),a.openCombobox()),e.nextFrame(()=>{var s;return(s=o.inputRef.current)==null?void 0:s.focus({preventScroll:!0})})}),g=pe(()=>{if(o.labelId)return[o.labelId,p].join(" ")},[o.labelId,p]),f=U(()=>({open:o.comboboxState===0,disabled:o.disabled,value:o.value}),[o]),v={ref:i,id:p,type:Be(t,o.buttonRef),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(S=o.optionsRef.current)==null?void 0:S.id,"aria-expanded":o.comboboxState===0,"aria-labelledby":g,disabled:o.disabled,onClick:T,onKeyDown:l};return q({ourProps:v,theirProps:c,slot:f,defaultTag:at,name:"Combobox.Button"})}let it="label";function ut(t,r){let o=Q(),{id:a=`headlessui-combobox-label-${o}`,...i}=t,u=j("Combobox.Label"),p=ee("Combobox.Label"),c=Z(u.labelRef,r);H(()=>p.registerLabel(a),[a]);let e=m(()=>{var g;return(g=u.inputRef.current)==null?void 0:g.focus({preventScroll:!0})}),l=U(()=>({open:u.comboboxState===0,disabled:u.disabled}),[u]);return q({ourProps:{ref:c,id:a,onClick:e},theirProps:i,slot:l,defaultTag:it,name:"Combobox.Label"})}let pt="ul",st=Oe.RenderStrategy|Oe.Static;function dt(t,r){let o=Q(),{id:a=`headlessui-combobox-options-${o}`,hold:i=!1,...u}=t,p=j("Combobox.Options"),c=Z(p.optionsRef,r),e=Ge(),l=(()=>e!==null?(e&re.Open)===re.Open:p.comboboxState===0)();H(()=>{var v;p.optionsPropsRef.current.static=(v=t.static)!=null?v:!1},[p.optionsPropsRef,t.static]),H(()=>{p.optionsPropsRef.current.hold=i},[p.optionsPropsRef,i]),we({container:p.optionsRef.current,enabled:p.comboboxState===0,accept(v){return v.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:v.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(v){v.setAttribute("role","none")}});let T=pe(()=>{var v,S;return(S=p.labelId)!=null?S:(v=p.buttonRef.current)==null?void 0:v.id},[p.labelId,p.buttonRef.current]),g=U(()=>({open:p.comboboxState===0,option:void 0}),[p]),f={"aria-labelledby":T,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:a,ref:c};return p.virtual&&p.comboboxState===0&&Object.assign(u,{children:w.createElement(Ze,null,u.children)}),q({ourProps:f,theirProps:u,slot:g,defaultTag:pt,features:st,visible:l,name:"Combobox.Options"})}let bt="li";function ct(t,r){var X;let o=Q(),{id:a=`headlessui-combobox-option-${o}`,disabled:i=!1,value:u,order:p=null,...c}=t,e=j("Combobox.Option"),l=ee("Combobox.Option"),T=e.virtual?e.activeOptionIndex===e.calculateIndex(u):e.activeOptionIndex===null?!1:((X=e.options[e.activeOptionIndex])==null?void 0:X.id)===a,g=e.isSelected(u),f=B(null),v=De({disabled:i,value:u,domRef:f,order:p}),S=ue(Ce),R=Z(r,f,S?S.measureElement:null),s=m(()=>l.onChange(u));H(()=>l.registerOption(a,v),[v,a]);let I=B(!(e.virtual||e.__demoMode));H(()=>{if(!e.virtual||!e.__demoMode)return;let x=ve();return x.requestAnimationFrame(()=>{I.current=!0}),x.dispose},[e.virtual,e.__demoMode]),H(()=>{if(!I.current||e.comboboxState!==0||!T||e.activationTrigger===0)return;let x=ve();return x.requestAnimationFrame(()=>{var O,L;(L=(O=f.current)==null?void 0:O.scrollIntoView)==null||L.call(O,{block:"nearest"})}),x.dispose},[f,T,e.comboboxState,e.activationTrigger,e.activeOptionIndex]);let V=m(x=>{var O;if(i||(O=e.virtual)!=null&&O.disabled(u))return x.preventDefault();s(),Ke()||requestAnimationFrame(()=>{var L;return(L=e.inputRef.current)==null?void 0:L.focus({preventScroll:!0})}),e.mode===0&&requestAnimationFrame(()=>l.closeCombobox())}),_=m(()=>{var O;if(i||(O=e.virtual)!=null&&O.disabled(u))return l.goToOption(y.Nothing);let x=e.calculateIndex(u);l.goToOption(y.Specific,x)}),E=ke(),k=m(x=>E.update(x)),J=m(x=>{var L;if(!E.wasMoved(x)||i||(L=e.virtual)!=null&&L.disabled(u)||T)return;let O=e.calculateIndex(u);l.goToOption(y.Specific,O,0)}),K=m(x=>{var O;E.wasMoved(x)&&(i||(O=e.virtual)!=null&&O.disabled(u)||T&&(e.optionsPropsRef.current.hold||l.goToOption(y.Nothing)))}),z=U(()=>({active:T,selected:g,disabled:i}),[T,g,i]);return q({ourProps:{id:a,ref:R,role:"option",tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":g,disabled:void 0,onClick:V,onFocus:_,onPointerEnter:k,onMouseEnter:k,onPointerMove:J,onMouseMove:J,onPointerLeave:K,onMouseLeave:K},theirProps:c,slot:z,defaultTag:bt,name:"Combobox.Option"})}let ft=$(ot),mt=$(lt),Tt=$(rt),xt=$(ut),gt=$(dt),vt=$(ct),qt=Object.assign(ft,{Input:Tt,Button:mt,Label:xt,Options:gt,Option:vt});export{qt as Combobox};