import e from"@babel/runtime/helpers/slicedToArray";import{useState as r,useRef as t,useEffect as i}from"react";import n from"prop-types";import{makeStyles as o,Button as a}from"@material-ui/core";import{jsxs as c,jsx as l,Fragment as d}from"react/jsx-runtime";var p=o((function(e){return{contentWrapper:{position:"relative"},content:{overflow:"hidden"},readMore:{height:40,display:"block",textAlign:"right"},blackOut:{width:"100%",position:"absolute",justifyContent:"flex-end",background:"linear-gradient(to bottom, transparent, ".concat(e.palette.background.paper,")"),height:40,marginTop:-40}}})),s=function(n){var o=n.maxHeight,s=n.children,m=p(),u=r(!1),h=e(u,2),f=h[0],g=h[1],b=r(!1),v=e(b,2),x=v[0],y=v[1],H=t();return i((function(){!function(){var e=o&&H.current.clientHeight>o+40;y(e),g(e)}()}),[s]),c("div",{className:m.contentWrapper,children:[l("div",{className:m.content,style:{maxHeight:x?o:"initial"},children:l("div",{ref:H,children:s})}),f&&c("div",{className:m.readMore,children:[x&&l("div",{className:m.blackOut}),l(a,{onClick:function(){y((function(e){return!e})),x&&window.innerHeight<H.current.clientHeight&&H.current.scrollIntoView()},children:x?l(d,{children:"Read more …"}):"Show less"})]})]})};s.propTypes={children:n.oneOfType([n.node,n.string]).isRequired,maxHeight:n.number},s.defaultProps={maxHeight:120};export{s as default};
