"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");const StockCounter=({setting:e,styles:s,style:t,advanced:a,builderProps:r,pageContext:l})=>{let{borderRadius:c}=s??{},{showIcon:i,icon:o,oosIcon:n,layout:d="full",template:p,outOfStockMessage:y,continueSelling:u,unlimitedQuantityMessage:g}=e??{},m=helpers$1.getInlineCss(r?.uid,c),$="progress-bar"!==d,v=helpers.getDynamicSourceLocales({val:p,uid:r?.uid,settingId:"template",pageContext:l,translate:e?.translate,isReplaceInventoryQuantity:!0}),S=helpers.getDynamicSourceLocales({val:y,uid:r?.uid,settingId:"outOfStockMessage",pageContext:l,translate:e?.translate}),C=helpers.getDynamicSourceLocales({val:u,uid:r?.uid,settingId:"continueSelling",pageContext:l,translate:e?.translate}),f=helpers.getDynamicSourceLocales({val:g,uid:r?.uid,settingId:"unlimitedQuantityMessage",pageContext:l,translate:e?.translate}),k=system.createAttr({...attrs.getLiquidTagAttrs(r,e,s)}),I=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(a)}),O=system.createStyle({...t}),A=system.createStyle({...styles.getWrapperStyles(s)}),_=helpers$1.getLiquidInitData(e,s),D=helpers$1.getLiquidTextContent({templateStringDisplay:v,outOfStockMessageDisplay:S,continueSellingDisplay:C,unlimitedQuantityMessageDisplay:f}),j=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:v,outOfStockMessageDisplay:S,continueSellingDisplay:C,unlimitedQuantityMessageDisplay:f},s);return core.template`
    ${_}
    <gp-product-stock-counter ${{...k}} class="${b}"
      style="${O}">
      <div class="${x}" style="${A}">
      <style>${m}</style>
        <div
          class="${L}"
          style="${q}"
        >
          <div class="${j}">
            ${core.RenderIf(i,core.template`
              ${system.LiquidIf("is_out_of_stock",core.template`<div
                    ${{...R({isOutOfStockIcon:!0,isVisible:!0})}}
                    class="${T}"
                    style="${P(!0)}"
                  >
                    ${n}
                  </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)}"
                >
                  ${n}
              </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)}"
              >
                ${D}
              </p>`,core.template`<p
                ${{...B}}
                class="${V}"
                style="${M(!1)}"
              >
                ${D}
              </p>`)}
              `)}

          </div>

          <div
            ${{...E}}
            style="${h}"
            class="${I}"
          ></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;
