import*as t from"react";import{TransitionEasings as e,withDelay as i}from"./transition-utils.js";import{AnimatePresence as n}from"../../../../framer-motion/dist/es/components/AnimatePresence/index.js";import{motion as a}from"../../../../framer-motion/dist/es/render/dom/motion.js";import{warn as r}from"../../../utils/dist/esm/function.js";import o from"../../../../lodash.mergewith/index.js";import{cx as s}from"../../../utils/dist/esm/dom.js";import{__DEV__ as l}from"../../../utils/dist/esm/assertion.js";function m(){return(m=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var u={exit:{height:{duration:.2,ease:e.ease},opacity:{duration:.3,ease:e.ease}},enter:{height:{duration:.3,ease:e.ease},opacity:{duration:.4,ease:e.ease}}},d={exit:t=>{var e,n,{animateOpacity:a,startingHeight:r,transition:o,transitionEnd:s,delay:l}=t;return m({},a&&{opacity:(n=r,null!=n&&parseInt(n.toString(),10)>0?1:0)},{overflow:"hidden",height:r,transitionEnd:null==s?void 0:s.exit,transition:null!=(e=null==o?void 0:o.exit)?e:i.exit(u.exit,l)})},enter:t=>{var e,{animateOpacity:n,endingHeight:a,transition:r,transitionEnd:o,delay:s}=t;return m({},n&&{opacity:1},{height:a,transitionEnd:null==o?void 0:o.enter,transition:null!=(e=null==r?void 0:r.enter)?e:i.enter(u.enter,s)})}},c=t.forwardRef(((e,i)=>{var{in:l,unmountOnExit:u,animateOpacity:c=!0,startingHeight:p=0,endingHeight:g="auto",style:h,className:f,transition:y,transitionEnd:v}=e,x=function(t,e){if(null==t)return{};var i,n,a={},r=Object.keys(t);for(n=0;n<r.length;n++)i=r[n],e.indexOf(i)>=0||(a[i]=t[i]);return a}(e,["in","unmountOnExit","animateOpacity","startingHeight","endingHeight","style","className","transition","transitionEnd"]),[E,O]=t.useState(!1);t.useEffect((()=>{var t=setTimeout((()=>{O(!0)}));return()=>clearTimeout(t)}),[]),r({condition:Boolean(p>0&&u),message:"startingHeight and unmountOnExit are mutually exclusive. You can't use them together"});var j=parseFloat(p.toString())>0,H={startingHeight:p,endingHeight:g,animateOpacity:c,transition:E?y:{enter:{duration:0}},transitionEnd:o(v,{enter:{overflow:"initial"},exit:u?void 0:{display:j?"block":"none"}})},w=!u||l,b=l||u?"enter":"exit";return t.createElement(n,{initial:!1,custom:H},w&&t.createElement(a.div,m({ref:i},x,{className:s("chakra-collapse",f),style:m({overflow:"hidden",display:"block"},h),custom:H,variants:d,initial:!!u&&"exit",animate:b,exit:"exit"})))}));l&&(c.displayName="Collapse");export{c as Collapse};
//# sourceMappingURL=collapse.js.map
