"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../helpers.js"),helpers$1=require("../common/helpers.js"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),attrs=require("../common/attrs.js"),system=require("@gem-sdk/system"),translate=require("../settings/configs/translate.js");const StockCounter=({setting:e,styles:s,style:t,advanced:r,builderProps:a,pageContext:l})=>{let{borderRadius:c}=s??{},{showIcon:i,icon:o,oosIcon:d,layout:n="full",template:p,outOfStockMessage:u,continueSelling:g,unlimitedQuantityMessage:y}=e??{},m=helpers$1.getInlineCss(a?.uid,c),$="progress-bar"!==n,S=helpers.getDynamicSourceLocales({val:p,uid:a?.uid,settingId:helpers.createSettingId({id:translate.StockCounter?.template?.id}),pageContext:l,isReplaceInventoryQuantity:!0}),v=helpers.getDynamicSourceLocales({val:u,uid:a?.uid,settingId:helpers.createSettingId({id:translate.StockCounter?.outOfStockMessage?.id}),pageContext:l}),C=helpers.getDynamicSourceLocales({val:g,uid:a?.uid,settingId:helpers.createSettingId({id:translate.StockCounter?.continueSelling?.id}),pageContext:l}),k=helpers.getDynamicSourceLocales({val:y,uid:a?.uid,settingId:helpers.createSettingId({id:translate.StockCounter?.unlimitedQuantityMessage?.id}),pageContext:l}),I=system.createAttr({...attrs.getLiquidTagAttrs(a,e,s)}),f=system.createClass({...core.composeClasses("gp-stock-counter-progress gp-mt-2 data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...classes.getProgressBarClasses(s)}),h=system.createStyle({...styles.getProgressBarStyles(s,e)}),q=system.createStyle({...styles.getContainerStyles(s)}),L=system.createClass({...classes.getContainerClasses(e)}),b=system.createClass({...classes.getLiquidTagClasses(r)}),O=system.createStyle({...t}),A=system.createStyle({...styles.getWrapperStyles(s)}),_=helpers$1.getLiquidInitData(e,s),j=helpers$1.getLiquidTextContent({templateStringDisplay:S,outOfStockMessageDisplay:v,continueSellingDisplay:C,unlimitedQuantityMessageDisplay:k}),D=system.createClass({...classes.getWrapperIconClasses(e)}),T=system.createClass({...core.composeClasses("gp-stock-counter-icon data-[visible=true]:gp-block data-[visible=false]:gp-hidden"),...classes.getIconClasses(),...classes.getOuterIconClasses()}),x=system.createClass({...classes.getWrapperClasses(e)}),P=t=>system.createStyle({...styles.getIconStyles(s,e,t)}),R=({isOutOfStockIcon:e,isVisible:s})=>system.createAttr({...attrs.getIconAttrs(e,s)}),E=system.createAttr({...attrs.getLiquidProgressBarAttrs()}),V=system.createClass({...classes.getTextClasses(s),...core.composeClasses("gp-stock-counter-mark")}),M=e=>system.createStyle({...styles.getTextStyles(s,e)}),B=system.createAttr({...attrs.getLiquidTextAttrs()}),W=helpers$1.getTextDisplayData({templateStringDisplay:S,outOfStockMessageDisplay:v,continueSellingDisplay:C,unlimitedQuantityMessageDisplay:k},s);return core.template`
    ${_}
    <gp-product-stock-counter ${{...I}} class="${b}"
      style="${O}">
      <div class="${x}" style="${A}">
      <style>${m}</style>
        <div
          class="${L}"
          style="${q}"
        >
          <div class="${D}">
            ${core.RenderIf(i,core.template`
              ${system.LiquidIf("is_out_of_stock",core.template`<div
                    ${{...R({isOutOfStockIcon:!0,isVisible:!0})}}
                    class="${T}"
                    style="${P(!0)}"
                  >
                    ${d}
                  </div>
              <div
                    ${{...R({isOutOfStockIcon:!1,isVisible:!1})}}
                     data-slot-type="false"
                    class="${T}"
                    style="${P(!1)}"
                >
                  ${o}
                </div>`,core.template` <div
                    ${{...R({isOutOfStockIcon:!0,isVisible:!1})}}
                    class="${T}"
                    style="${P(!0)}"
                >
                  ${d}
              </div>
              <div
                    ${{...R({isOutOfStockIcon:!1,isVisible:!0})}}
                    class="${T}"
                    style="${P(!1)}"
                >
                  ${o}
                </div>`)}
            `)}
            ${W}
            ${core.RenderIf($,core.template`
              ${system.LiquidIf("is_out_of_stock",core.template`<p
                ${{...B}}
                class="${V}"
                style="${M(!0)}"
              >
                ${j}
              </p>`,core.template`<p
                ${{...B}}
                class="${V}"
                style="${M(!1)}"
              >
                ${j}
              </p>`)}
              `)}

          </div>

          <div
            ${{...E}}
            style="${h}"
            class="${f}"
          ></div>
        </div>
        </div>
      </gp-product-stock-counter>
      ${core.RenderIf(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-stock-counter-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-product-stock-counter-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};exports.default=StockCounter;
