import{useRef as e,useState as t,useEffect as i}from"react";import{useCollection as r,useCurrentDevice as o,getResponsiveValueByScreen as l,useEditorMode as n,isSafari as p}from"@gem-sdk/core";let useGpDescription=s=>{let c=e(null),[m,u]=t(!1),[a,d]=t(!1),g=r(),h=o(),C=l(s?.hasLineClamp,h),f=l(s?.lineClamp,h),w=n(),y=()=>{u(e=>!e)};return i(()=>{let e=c.current;u(!1),e&&C&&g?.description&&setTimeout(()=>{let t=e?.scrollHeight??0,i=e?.clientHeight??0,r=window.getComputedStyle(e).getPropertyValue("line-height"),o=parseInt(r,10)||1,l=Math.round((t??0)/o),n=void 0!==f&&f<l,s=i<t,c=p()?n:s;f&&c?d(()=>!0):d(()=>!1)},100)},[C,f,g?.description]),{ref:c,open:m,isShowViewMore:a,handleToggleShowMore:y,mode:w,hasLineClamp:C}};export{useGpDescription};
