import{makeStyleResponsive as e,makeLineClamp as t,dataStringify as s,template as i,baseAssetURL as o,isLocalEnv as r}from"@gem-sdk/core";import{getDynamicSourceLocales as p,createSettingId as a,getSettingPreloadData as n}from"../../../helpers.js";import{createClass as d,createStyle as l,createAttr as c,createStateOrContext as m,LiquidIf as $,Liquid as u,LiquidUnless as g,If as v}from"@gem-sdk/system";import{getClasses as f,getButtonClasses as x,getClassPreBuilt as w}from"./common/classes.js";import{getTextStyle as h,getButtonStyle as y,getStaticCss as C}from"./common/styles.js";import{ICON_SVG as b}from"./common/helpers.js";import{ProductDescription as j}from"../../settings/product-description/configs/translate.js";let M=M=>{let{setting:S,advanced:I,builderProps:L,pageContext:T}=M,{htmlTag:k,viewMoreText:E,viewLessText:P}=S??{},V="html"===k?"div":"p",A=d({"gp-product-description":!0,[I?.cssClass]:!0}),D=d(f({setting:S,isLiquid:!0})),G=d(x({setting:S})),_=d({"gp-show-more-text":!0}),q=d({"gp-show-more-icon gp-ml-1":!0}),H=l({...h({setting:S,renderMaxHeight:!0}),...e("line-clamp",t(S?.lineClamp,S?.hasLineClamp))}),N=d(w()),O=l(y({setting:S})),R=c({"data-id":`${L?.uid}`}),z=c({"data-gp-text":""}),{textDescriptionCss:B,gpDescriptionCss:F}=C(),J="product.description == blank",K=p({val:E,uid:L?.uid,settingId:a({id:j?.viewMoreText?.id}),pageContext:T??{}}),Q=p({val:P,uid:L?.uid,settingId:a({id:j?.viewLessText?.id}),pageContext:T??{}}),U=m({setting:{lineClamp:S?.lineClamp,hasLineClamp:S?.hasLineClamp,viewMoreText:K,viewLessText:Q,enableViewMoreIcon:S?.enableViewMoreIcon},textStyle:H});return $(J,"",u(i`
    <gp-product-description
      ${R}
      class="${A}"
      gp-data='${s(U).replaceAll("'","&#039;")}'
      data-view-more-text="${K}"
      data-view-less-text="${Q}"
    >
      <style>${B}</style>
      <style>${F}</style>
      <div class="${N}" ></div>
      ${g("product","<p>Product not found</p>",i`<${V} ${z} class="${D}" style="${H}">
          {{product.description}}
        </${V}>
        ${g(J,i`<button type="button" class="${G}" style="${O}">
          <span class="${_}">
            ${v(!1,Q?.toString(),K?.toString())}
          </span>
          ${v(S?.enableViewMoreIcon,i`<span class="${q}">${b}</span>`," ")}
          </button>`)}`)}
    </gp-product-description>

    ${(()=>{let e=r?"{{ 'gp-product-description-v7-5.js' | asset_url }}":`${o}/assets-v2/gp-product-description-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;return`<script ${n('class="gps-link" delay',"src")}="${e}" defer="defer"></script>`})()}
  `))};export{M as default};
