import{$ as G,a as J,w as Q,T as W,r as X}from"./fd5caeb3.js";import{R as I,r as t}from"./index.9be5fb1a.js";import{O as N,I as g,y as T,T as Y,o as S,f as Z,u as R,d as k,H as C,U as j,D as K,a as _,h as ee,b as D}from"./66d5f687.js";import{u as te}from"./c05ec191.js";var V;let re=(V=I.startTransition)!=null?V:function(e){e()};var se=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(se||{}),oe=(e=>(e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.CloseDisclosure=1]="CloseDisclosure",e[e.SetButtonId=2]="SetButtonId",e[e.SetPanelId=3]="SetPanelId",e[e.LinkPanel=4]="LinkPanel",e[e.UnlinkPanel=5]="UnlinkPanel",e))(oe||{});let ne={[0]:e=>({...e,disclosureState:R(e.disclosureState,{[0]:1,[1]:0})}),[1]:e=>e.disclosureState===1?e:{...e,disclosureState:1},[4](e){return e.linkedPanel===!0?e:{...e,linkedPanel:!0}},[5](e){return e.linkedPanel===!1?e:{...e,linkedPanel:!1}},[2](e,r){return e.buttonId===r.buttonId?e:{...e,buttonId:r.buttonId}},[3](e,r){return e.panelId===r.panelId?e:{...e,panelId:r.panelId}}},h=t.exports.createContext(null);h.displayName="DisclosureContext";function w(e){let r=t.exports.useContext(h);if(r===null){let a=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,w),a}return r}let F=t.exports.createContext(null);F.displayName="DisclosureAPIContext";function q(e){let r=t.exports.useContext(F);if(r===null){let a=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,q),a}return r}let O=t.exports.createContext(null);O.displayName="DisclosurePanelContext";function le(){return t.exports.useContext(O)}function ue(e,r){return R(r.type,ne,e,r)}let ae=t.exports.Fragment;function ie(e,r){let{defaultOpen:a=!1,...d}=e,l=t.exports.useRef(null),o=T(r,Y(p=>{l.current=p},e.as===void 0||e.as===t.exports.Fragment)),f=t.exports.useRef(null),s=t.exports.useRef(null),u=t.exports.useReducer(ue,{disclosureState:a?0:1,linkedPanel:!1,buttonRef:s,panelRef:f,buttonId:null,panelId:null}),[{disclosureState:m,buttonId:n},P]=u,c=S(p=>{P({type:1});let b=ee(l);if(!b||!n)return;let $=(()=>p?p instanceof HTMLElement?p:p.current instanceof HTMLElement?p.current:b.getElementById(n):b.getElementById(n))();$==null||$.focus()}),y=t.exports.useMemo(()=>({close:c}),[c]),x=t.exports.useMemo(()=>({open:m===0,close:c}),[m,c]),E={ref:o};return I.createElement(h.Provider,{value:u},I.createElement(F.Provider,{value:y},I.createElement(te,{value:c},I.createElement(Z,{value:R(m,{[0]:k.Open,[1]:k.Closed})},C({ourProps:E,theirProps:d,slot:x,defaultTag:ae,name:"Disclosure"})))))}let ce="button";function pe(e,r){let a=t.exports.useId(),{id:d=`headlessui-disclosure-button-${a}`,disabled:l=!1,autoFocus:o=!1,...f}=e,[s,u]=w("Disclosure.Button"),m=le(),n=m===null?!1:m===s.panelId,P=t.exports.useRef(null),c=T(P,r,n?null:s.buttonRef),y=j();t.exports.useEffect(()=>{if(!n)return u({type:2,buttonId:d}),()=>{u({type:2,buttonId:null})}},[d,u,n]);let x=S(i=>{var v;if(n){if(s.disclosureState===1)return;switch(i.key){case D.Space:case D.Enter:i.preventDefault(),i.stopPropagation(),u({type:0}),(v=s.buttonRef.current)==null||v.focus();break}}else switch(i.key){case D.Space:case D.Enter:i.preventDefault(),i.stopPropagation(),u({type:0});break}}),E=S(i=>{switch(i.key){case D.Space:i.preventDefault();break}}),p=S(i=>{var v;X(i.currentTarget)||l||(n?(u({type:0}),(v=s.buttonRef.current)==null||v.focus()):u({type:0}))}),{isFocusVisible:b,focusProps:$}=G({autoFocus:o}),{isHovered:B,hoverProps:M}=J({isDisabled:l}),{pressed:H,pressProps:U}=Q({disabled:l}),z=t.exports.useMemo(()=>({open:s.disclosureState===0,hover:B,active:H,disabled:l,focus:b,autofocus:o}),[s,B,H,b,l,o]),L=W(e,P),A=n?K({ref:c,type:L,disabled:l||void 0,autoFocus:o,onKeyDown:x,onClick:p},$,M,U):K({ref:c,id:d,type:L,"aria-expanded":s.disclosureState===0,"aria-controls":s.linkedPanel?s.panelId:void 0,disabled:l||void 0,autoFocus:o,onKeyDown:x,onKeyUp:E,onClick:p},$,M,U);return C({mergeRefs:y,ourProps:A,theirProps:f,slot:z,defaultTag:ce,name:"Disclosure.Button"})}let de="div",fe=N.RenderStrategy|N.Static;function me(e,r){let a=t.exports.useId(),{id:d=`headlessui-disclosure-panel-${a}`,...l}=e,[o,f]=w("Disclosure.Panel"),{close:s}=q("Disclosure.Panel"),u=j(),m=T(r,o.panelRef,x=>{re(()=>f({type:x?4:5}))});t.exports.useEffect(()=>(f({type:3,panelId:d}),()=>{f({type:3,panelId:null})}),[d,f]);let n=_(),P=(()=>n!==null?(n&k.Open)===k.Open:o.disclosureState===0)(),c=t.exports.useMemo(()=>({open:o.disclosureState===0,close:s}),[o,s]),y={ref:m,id:d};return I.createElement(O.Provider,{value:o.panelId},C({mergeRefs:u,ourProps:y,theirProps:l,slot:c,defaultTag:de,features:fe,visible:P,name:"Disclosure.Panel"}))}let Pe=g(ie),xe=g(pe),be=g(me),De=Object.assign(Pe,{Button:xe,Panel:be});export{De as w};
//# sourceMappingURL=a6a953cf.js.map