"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./common/styles.js"),e=require("./common/helpers.js"),s=require("@gem-sdk/core"),r=require("@gem-sdk/system"),a=require("../../../helpers.js"),i=require("./helpers/getButtonDynamicSourceLocales.js"),o=require("./SoldOutButton.liquid.js"),l=require("./AddToCartButton.liquid.js");exports.default=n=>{let{setting:u,builderProps:c,style:p,styles:d,pageContext:g}=n,{wrapStyle:y,restStyle:b}=t.getSplitStyle(p),{outOfStockButtonLabel:f,unavailableButtonLabel:m,variantSelectionRequiredMessage:S,successMessage:q,errorMessage:v}=i.getButtonDynamicSourceLocales({setting:u,pageContext:g,builderProps:c}),{urlData:_}=a.getInsertLinkData("",u?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:u?.customURL),$=r.createStateOrContext(e.getGPProductButtonState({styles:d,setting:u,successMessage:q,errorMessage:v,variantSelectionRequiredMessage:S}));return s.template`
    ${r.Liquid("{%- assign total_combinations = 1 -%}")}
    ${r.LiquidFor("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
    {%- liquid
      assign inventory_quantity = variant.inventory_quantity | default: 0
      assign is_in_stock = variant.available
    -%}
    <gp-product-button
      style="${y}"
      gp-data-wrapper="true"
      gp-href="${_.href}"
      class="gp-product-button"
      gp-label-out-of-stock="${f}"
      gp-label-unavailable="${m}"
      gp-data='${JSON.stringify($)}'
      gp-enable-third-partycart="{{shop.metafields.GEMPAGES.enableThirdPartyCart}}"
    >
      ${l.AddToCartButton({...n,style:b})}
      ${o.SoldOutButton({...n,style:b,label:f})}
    </gp-product-button>
    ${r.If(s.isLocalEnv,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-product-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${a.getSettingPreloadData('class="gps-link" delay',"src")}="${s.baseAssetURL}/assets-v2/gp-product-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
