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