import{composeClasses as s,RenderIf as t,template as i,isLocalEnv as e,baseAssetURL as o}from"@gem-sdk/core";import{getDynamicSourceLocales as l,createSettingId as c,getSettingPreloadData as d}from"../../helpers.js";import{getLiquidInitData as r,getInlineCss as a,getTextDisplayData as $,getLiquidTextContent as p}from"../common/helpers.js";import{getProgressBarClasses as u,getContainerClasses as n,getLiquidTagClasses as m,getWrapperIconClasses as v,getOuterIconClasses as g,getIconClasses as f,getWrapperClasses as k,getTextClasses as y}from"../common/classes.js";import{getProgressBarStyles as S,getContainerStyles as b,getWrapperStyles as I,getIconStyles as O,getTextStyles as j}from"../common/styles.js";import{getLiquidTagAttrs as _,getLiquidProgressBarAttrs as h,getLiquidTextAttrs as V,getIconAttrs as E}from"../common/attrs.js";import{createAttr as M,createClass as A,createStyle as C,LiquidIf as G}from"@gem-sdk/system";import{StockCounter as Q}from"../settings/configs/translate.js";let R=({setting:R,styles:x,style:N,advanced:P,builderProps:T,pageContext:q})=>{let{borderRadius:w}=x??{},{showIcon:z,icon:B,oosIcon:D,layout:F="full",template:H,outOfStockMessage:J,continueSelling:K,unlimitedQuantityMessage:L}=R??{},U=a(T?.uid,w),W=l({val:H,uid:T?.uid,settingId:c({id:Q?.template?.id}),pageContext:q,isReplaceInventoryQuantity:!0}),X=l({val:J,uid:T?.uid,settingId:c({id:Q?.outOfStockMessage?.id}),pageContext:q}),Y=l({val:K,uid:T?.uid,settingId:c({id:Q?.continueSelling?.id}),pageContext:q}),Z=l({val:L,uid:T?.uid,settingId:c({id:Q?.unlimitedQuantityMessage?.id}),pageContext:q}),ss=M({..._(T,R,x)}),st=A({...s("gp-stock-counter-progress gp-mt-2 data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...u(x)}),si=C({...S(x,R)}),se=C({...b(x)}),so=A({...n(R)}),sl=A({...m(P)}),sc=C({...N}),sd=C({...I(x)}),sr=r(R,x),sa=p({templateStringDisplay:W,outOfStockMessageDisplay:X,continueSellingDisplay:Y,unlimitedQuantityMessageDisplay:Z}),s$=A({...v(R)}),sp=A({...s("gp-stock-counter-icon data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...f(),...g()}),su=A({...k(R)}),sn=s=>C({...O(x,R,s)}),sm=({isOutOfStockIcon:s,isVisible:t})=>M({...E(s,t)}),sv=M({...h()}),sg=A({...y(x),...s("gp-stock-counter-mark")}),sf=s=>C({...j(x,s)}),sk=M({...V()}),sy=$({templateStringDisplay:W,outOfStockMessageDisplay:X,continueSellingDisplay:Y,unlimitedQuantityMessageDisplay:Z},x);return i`
    ${sr}
    <gp-product-stock-counter ${{...ss}} class="${sl}"
      style="${sc}">
      <div class="${su}" style="${sd}">
      <style>${U}</style>
        <div
          class="${so}"
          style="${se}"
        >
          <div class="${s$}">
            ${t(z,i`
              ${G("is_out_of_stock",i`<div
                    ${{...sm({isOutOfStockIcon:!0,isVisible:!0})}}
                    class="${sp}"
                    style="${sn(!0)}"
                  >
                    ${D}
                  </div>
              <div
                    ${{...sm({isOutOfStockIcon:!1,isVisible:!1})}}
                     data-slot-type="false"
                    class="${sp}"
                    style="${sn(!1)}"
                >
                  ${B}
                </div>`,i` <div
                    ${{...sm({isOutOfStockIcon:!0,isVisible:!1})}}
                    class="${sp}"
                    style="${sn(!0)}"
                >
                  ${D}
              </div>
              <div
                    ${{...sm({isOutOfStockIcon:!1,isVisible:!0})}}
                    class="${sp}"
                    style="${sn(!1)}"
                >
                  ${B}
                </div>`)}
            `)}
            ${sy}
            ${t("progress-bar"!==F,i`
              ${G("is_out_of_stock",i`<p
                ${{...sk}}
                class="${sg}"
                style="${sf(!0)}"
              >
                ${sa}
              </p>`,i`<p
                ${{...sk}}
                class="${sg}"
                style="${sf(!1)}"
              >
                ${sa}
              </p>`)}
              `)}

          </div>

          <div
            ${{...sv}}
            style="${si}"
            class="${st}"
          ></div>
        </div>
        </div>
      </gp-product-stock-counter>
      ${t(e,`<script ${d('class="gps-link" delay',"src")}="{{ 'gp-product-stock-counter-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${d('class="gps-link" delay',"src")}="${o}/assets-v2/gp-product-stock-counter-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{R as default};
