import{computed as m,defineComponent as x,inject as R,onMounted as v,onUnmounted as D,provide as j,ref as u,unref as y}from"vue";import{useId as C}from'../../hooks/use-id.js';import{render as h}from'../../utils/render.js';let p=Symbol("DescriptionContext");function b(){let t=R(p,null);if(t===null)throw new Error("Missing parent");return t}function M({slot:t=u({}),name:i="Description",props:o={}}={}){let e=u([]);function s(n){return e.value.push(n),()=>{let r=e.value.indexOf(n);r!==-1&&e.value.splice(r,1)}}return j(p,{register:s,slot:t,name:i,props:o}),m(()=>e.value.length>0?e.value.join(" "):void 0)}let E=x({name:"Description",props:{as:{type:[Object,String],default:"p"},id:{type:String,default:()=>`headlessui-description-${C()}`}},setup(t,{attrs:i,slots:o}){let e=b();return v(()=>D(e.register(t.id))),()=>{let{name:s="Description",slot:n=u({}),props:r={}}=e,{id:d,...l}=t,c={...Object.entries(r).reduce((f,[a,g])=>Object.assign(f,{[a]:y(g)}),{}),id:d};return h({ourProps:c,theirProps:l,slot:n.value,attrs:i,slots:o,name:s})}}});export{E as Description,M as useDescriptions};
