"use client";import m,{createContext as D,useContext as d,useMemo as u,useState as T}from"react";import{useEvent as P}from'../../hooks/use-event.js';import{useId as g}from'../../hooks/use-id.js';import{useIsoMorphicEffect as x}from'../../hooks/use-iso-morphic-effect.js';import{useSlot as y}from'../../hooks/use-slot.js';import{useSyncRefs as E}from'../../hooks/use-sync-refs.js';import{useDisabled as v}from'../../internal/disabled.js';import{forwardRefWithAs as R,useRender as S}from'../../utils/render.js';let a=D(null);a.displayName="DescriptionContext";function f(){let r=d(a);if(r===null){let e=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(e,f),e}return r}function w(){var r,e;return(e=(r=d(a))==null?void 0:r.value)!=null?e:void 0}function H(){let[r,e]=T([]);return[r.length>0?r.join(" "):void 0,u(()=>function(t){let i=P(n=>(e(o=>[...o,n]),()=>e(o=>{let s=o.slice(),p=s.indexOf(n);return p!==-1&&s.splice(p,1),s}))),l=u(()=>({register:i,slot:t.slot,name:t.name,props:t.props,value:t.value}),[i,t.slot,t.name,t.props,t.value]);return m.createElement(a.Provider,{value:l},t.children)},[e])]}let I="p";function C(r,e){let c=g(),t=v(),{id:i=`headlessui-description-${c}`,...l}=r,n=f(),o=E(e);x(()=>n.register(i),[i,n.register]);let s=y({...n.slot,disabled:t||!1}),p={ref:o,...n.props,id:i};return S()({ourProps:p,theirProps:l,slot:s,defaultTag:I,name:n.name||"Description"})}let _=R(C),M=Object.assign(_,{});export{M as Description,w as useDescribedBy,H as useDescriptions};
