import{d as B,ah as F,al as H,ai as D,ak as k,c as h,b,w as c,ac as y,u as e,am as O,r as v,i as g,l as E,af as I,o as M,aR as T,q as R,ap as N,a as P,an as V,as as S,at as j,au as z,av as L,aw as q,E as U}from"./B2UyoCas.js";import{u as G}from"./DeNTsafF.js";const[x,J]=F("CollapsibleRoot"),K=B({__name:"CollapsibleRoot",props:{defaultOpen:{type:Boolean,default:!1},open:{type:Boolean,default:void 0},disabled:{type:Boolean},unmountOnHide:{type:Boolean,default:!0},asChild:{type:Boolean},as:{}},emits:["update:open"],setup(d,{expose:u,emit:s}){const n=d,o=H(n,"open",s,{defaultValue:n.defaultOpen,passive:n.open===void 0}),{disabled:i,unmountOnHide:r}=D(n);return J({contentId:"",disabled:i,open:o,unmountOnHide:r,onOpenToggle:()=>{i.value||(o.value=!o.value)}}),u({open:o}),k(),(l,C)=>(b(),h(e(O),{as:l.as,"as-child":n.asChild,"data-state":e(o)?"open":"closed","data-disabled":e(i)?"":void 0},{default:c(()=>[y(l.$slots,"default",{open:e(o)})]),_:3},8,["as","as-child","data-state","data-disabled"]))}}),Q=B({inheritAttrs:!1,__name:"CollapsibleContent",props:{forceMount:{type:Boolean},asChild:{type:Boolean},as:{}},emits:["contentFound"],setup(d,{emit:u}){const s=d,n=u,t=x();t.contentId||(t.contentId=G(void 0,"reka-collapsible-content"));const o=v(),{forwardRef:i,currentElement:r}=k(),l=v(0),C=v(0),m=g(()=>t.open.value),f=v(m.value),p=v();E(()=>{var a;return[m.value,(a=o.value)==null?void 0:a.present]},async()=>{await I();const a=r.value;if(!a)return;p.value=p.value||{transitionDuration:a.style.transitionDuration,animationName:a.style.animationName},a.style.transitionDuration="0s",a.style.animationName="none";const _=a.getBoundingClientRect();C.value=_.height,l.value=_.width,f.value||(a.style.transitionDuration=p.value.transitionDuration,a.style.animationName=p.value.animationName)},{immediate:!0});const A=g(()=>f.value&&t.open.value);return M(()=>{requestAnimationFrame(()=>{f.value=!1})}),T(r,"beforematch",a=>{requestAnimationFrame(()=>{t.onOpenToggle(),n("contentFound")})}),(a,_)=>(b(),h(e(V),{ref_key:"presentRef",ref:o,present:a.forceMount||e(t).open.value,"force-mount":!0},{default:c(({present:w})=>{var $;return[R(e(O),N(a.$attrs,{id:e(t).contentId,ref:e(i),"as-child":s.asChild,as:a.as,hidden:w?void 0:e(t).unmountOnHide.value?"":"until-found","data-state":A.value?void 0:e(t).open.value?"open":"closed","data-disabled":($=e(t).disabled)!=null&&$.value?"":void 0,style:{"--reka-collapsible-content-height":`${C.value}px`,"--reka-collapsible-content-width":`${l.value}px`}}),{default:c(()=>[!e(t).unmountOnHide.value||w?y(a.$slots,"default",{key:0}):P("",!0)]),_:2},1040,["id","as-child","as","hidden","data-state","data-disabled","style"])]}),_:3},8,["present"]))}}),W=B({__name:"CollapsibleTrigger",props:{asChild:{type:Boolean},as:{default:"button"}},setup(d){const u=d;k();const s=x();return(n,t)=>{var o,i;return b(),h(e(O),{type:n.as==="button"?"button":void 0,as:n.as,"as-child":u.asChild,"aria-controls":e(s).contentId,"aria-expanded":e(s).open.value,"data-state":e(s).open.value?"open":"closed","data-disabled":(o=e(s).disabled)!=null&&o.value?"":void 0,disabled:(i=e(s).disabled)==null?void 0:i.value,onClick:e(s).onOpenToggle},{default:c(()=>[y(n.$slots,"default")]),_:3},8,["type","as","as-child","aria-controls","aria-expanded","data-state","data-disabled","disabled","onClick"])}}}),X={slots:{root:"",content:"data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden"}},ee={__name:"UCollapsible",props:{as:{type:null,required:!1},class:{type:null,required:!1},ui:{type:null,required:!1},defaultOpen:{type:Boolean,required:!1},open:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0}},emits:["update:open"],setup(d,{emit:u}){const s=d,n=u,t=S(),o=j(),i=z(L(s,"as","defaultOpen","open","disabled","unmountOnHide"),n),r=g(()=>{var l;return q({extend:q(X),...((l=o.ui)==null?void 0:l.collapsible)||{}})()});return(l,C)=>{var m;return b(),h(e(K),N(e(i),{class:r.value.root({class:[(m=s.ui)==null?void 0:m.root,s.class]})}),{default:c(({open:f})=>{var p;return[t.default?(b(),h(e(W),{key:0,"as-child":""},{default:c(()=>[y(l.$slots,"default",{open:f})]),_:2},1024)):P("",!0),R(e(Q),{class:U(r.value.content({class:(p=s.ui)==null?void 0:p.content}))},{default:c(()=>[y(l.$slots,"content")]),_:3},8,["class"])]}),_:3},16,["class"])}}};export{ee as _};
