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

          </div>

          <div
            ${{...sm}}
            style="${st}"
            class="${ss}"
          ></div>
        </div>
        </div>
      </gp-product-stock-counter>
      ${e(i,`<script ${a('class="gps-link" delay',"src")}="{{ 'gp-product-stock-counter-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${a('class="gps-link" delay',"src")}="${l}/assets-v2/gp-product-stock-counter-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{StockCounter as default};
