import"./vue-DrbDkNea.js";import{a6 as k,j as H,l as w,r as x,s as q,o as z,w as N,J as B,d as D,K as P,D as j,S as J,a7 as K,W as T,N as V}from"./@vue-DGKlPIvk.js";const A="--vc-auto-duration",W=`height var(${A}) cubic-bezier(0.33, 1, 0.68, 1)`,c={padding:0},Y=300,E={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"};function $(t){return t.value?parseFloat(getComputedStyle(t.value).height):0}function S(t){if(!t.value)return{};const{transition:l}=getComputedStyle(t.value);return l==="all 0s ease 0s"||l==="all"?{transition:W}:{transition:l}}function F(t){if(!t.value)return!0;const{transition:l}=getComputedStyle(t.value);return typeof window.requestAnimationFrame>"u"||window.matchMedia("(prefers-reduced-motion: reduce)").matches||l.includes("none")||l.includes("height 0s")}function G(t=0){if(t===0)return 0;const l=t/36,i=Math.round((4+15*l**.25+l/5)*10);return Number.isFinite(i)?i:0}const Q=k({inheritAttrs:!0,__name:"Collapse",props:{when:{type:Boolean},baseHeight:{default:0},as:{default:"div"}},emits:["collapse","expand","collapsed","expanded"],setup(t,{emit:l}){const i=t,s=l,o=H(i,"when"),n=H(i,"baseHeight"),v=w(()=>({overflow:"hidden",height:`${n.value}px`})),h=w(()=>({...c,...n.value===0?{display:"none"}:v.value})),a=x(null),g=x(o.value?"expanded":"collapsed"),d=e=>g.value=e;function M(){return o.value?c:n.value===0?E:h.value}const f=q(M()),r=e=>f.value=e,u=e=>r({...f.value,...e}),y=x(Y),R=e=>y.value=e,b=w(()=>({[A]:`${y.value}ms`}));let p=NaN;function m(){r(c),d("expanded"),s("expanded")}function C(){r(h.value),d("collapsed"),s("collapsed")}z(()=>{if(!a.value)return;const e=G(a.value.scrollHeight-n.value);e>0&&R(e),!o.value&&n.value===0&&r(h.value)}),N(o,e=>{if(a.value)if(p=NaN,e){if(F(a))return m();d("expanding"),s("expand"),r({...c,...v.value,...b.value}),requestAnimationFrame(()=>{if(a.value.scrollHeight===0)return m();p=a.value.scrollHeight,u({...S(a),height:`${p}px`,willChange:"height"})})}else{if(F(a)||(d("collapsing"),s("collapse"),u({...b.value,height:`${a.value.scrollHeight}px`}),a.value.scrollHeight===0))return C();requestAnimationFrame(()=>{u({...v.value,...S(a),willChange:"height"})})}}),N(n,e=>{o.value||(e>0?u({display:void 0,height:`${e}px`}):u({display:"none"}))});function _(e){e.target&&e.target===a.value&&e.propertyName==="height"&&(o.value?Math.abs(a.value.scrollHeight-$(a))<1?m():p<a.value.scrollHeight&&u({height:`${a.value.scrollHeight}px`}):Math.abs(n.value-$(a))<1&&C())}return(e,I)=>(D(),B(V(i.as),{ref_key:"collapseRef",ref:a,style:T(f.value),onTransitionend:_,"data-collapse":g.value},{default:P(()=>[j(e.$slots,"default",J(K({state:g.value})))]),_:3},40,["style","data-collapse"]))}});export{Q as J};
