"use strict";var React=require("react"),core=require("@gem-sdk/core");const useGpDescription=e=>{let t=React.useRef(null),[r,c]=React.useState(!1),[s,i]=React.useState(!1),o=core.useProduct(),u=core.useCurrentDevice(),a=core.getResponsiveValueByScreen(e?.hasLineClamp,u),l=core.getResponsiveValueByScreen(e?.lineClamp,u),{redirectProductShopifyLink:n}=core.useProductShopifyEditLink(),p=core.useEditorMode(),d=React.useCallback(()=>`calc(${l} * 1lh)`,[l]),R=React.useCallback(e=>a&&l&&e||"auto",[a,l]),g=React.useCallback(()=>{t.current&&(t.current.style.maxHeight=r?d():"none",c(e=>!e))},[r,d]);return React.useEffect(()=>{R(d())},[e?.typo?.custom,R,d]),React.useEffect(()=>{let e=t.current;if(c(!1),!e)return;let r=a&&o?.descriptionHtml;r?setTimeout(()=>{let t=e?.scrollHeight??0,r=e?.clientHeight??0,c=r<t,s=window.getComputedStyle(e).getPropertyValue("line-height"),o=parseInt(s,10)||1,u=Math.round((t??0)/o),a=void 0!==l&&l<u,n=core.isSafari()?a:c;e.style.maxHeight=d(),l&&n?i(()=>!0):i(()=>!1)},100):e.style.maxHeight="none"},[a,l,o?.descriptionHtml,d]),{ref:t,open:r,isShowViewMore:s,handleToggleShowMore:g,mode:p,redirectProductShopifyLink:n}};exports.useGpDescription=useGpDescription;
