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

          </div>

          <div
            ${{...N}}
            style="${D}"
            class="${j}"
          ></div>
        </div>
        </div>
      </gp-product-stock-counter>
      ${e.RenderIf(e.isLocalEnv,`<script ${t.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-stock-counter-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${t.getSettingPreloadData('class="gps-link" delay',"src")}="${e.baseAssetURL}/assets-v2/gp-product-stock-counter-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
