import"./vue-C2cMydZB.js";import{a5 as k,y as H,i as w,r as x,s as q,o as z,w as $,I as B,d as P,J as D,C as J,R as T,a6 as V,V as j,M as I}from"./@vue-Bf7e1FJA.js";const R="--vc-auto-duration",K=`height var(${R}) 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 N(t){return t.value?parseFloat(getComputedStyle(t.value).height):0}function F(t){if(!t.value)return{};const{transition:l}=getComputedStyle(t.value);return l==="all 0s ease 0s"||l==="all"?{transition:K}:{transition:l}}function M(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 U=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 S(){return o.value?c:n.value===0?E:h.value}const f=q(S()),r=e=>f.value=e,u=e=>r({...f.value,...e}),y=x(Y),A=e=>y.value=e,C=w(()=>({[R]:`${y.value}ms`}));let p=NaN;function m(){r(c),d("expanded"),s("expanded")}function b(){r(h.value),d("collapsed"),s("collapsed")}z(()=>{if(!a.value)return;const e=G(a.value.scrollHeight-n.value);e>0&&A(e),!o.value&&n.value===0&&r(h.value)}),$(o,e=>{if(a.value)if(p=NaN,e){if(M(a))return m();d("expanding"),s("expand"),r({...c,...v.value,...C.value}),requestAnimationFrame(()=>{if(a.value.scrollHeight===0)return m();p=a.value.scrollHeight,u({...F(a),height:`${p}px`,willChange:"height"})})}else{if(M(a)||(d("collapsing"),s("collapse"),u({...C.value,height:`${a.value.scrollHeight}px`}),a.value.scrollHeight===0))return b();requestAnimationFrame(()=>{u({...v.value,...F(a),willChange:"height"})})}}),$(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-N(a))<1?m():p<a.value.scrollHeight&&u({height:`${a.value.scrollHeight}px`}):Math.abs(n.value-N(a))<1&&b())}return(e,L)=>(P(),B(I(i.as),{ref_key:"collapseRef",ref:a,style:j(f.value),onTransitionend:_,"data-collapse":g.value},{default:D(()=>[J(e.$slots,"default",T(V({state:g.value})))]),_:3},40,["style","data-collapse"]))}});export{U as J};
