"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:r,style:s,styles:o,pageContext:a}=t,{wrapStyle:l,restStyle:u}=styles.getSplitStyle(s),{outOfStockButtonLabel:i,unavailableButtonLabel:n,variantSelectionRequiredMessage:c}=getButtonDynamicSourceLocales.getButtonDynamicSourceLocales({setting:e,pageContext:a,builderProps:r}),{urlData:d}=helpers.getInsertLinkData("",e?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:e?.customURL),p=system.createStateOrContext(helpers$1.getGPProductButtonState(o,e)),g=()=>AddToCartButton_liquid.AddToCartButton({...t,style:u}),y=()=>SoldOutButton_liquid.SoldOutButton({...t,style:u,label:i}),S=()=>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`
    {%- liquid
      assign inventory_quantity = variant.inventory_quantity | default: 0
      assign is_in_stock = variant.available
    -%}
    <gp-product-button
      style="${l}"
      gp-data-wrapper="true"
      gp-href="${d.href}"
      class="gp-product-button"
      gp-label-out-of-stock="${i}"
      gp-label-unavailable="${n}"
      gp-data='${JSON.stringify(p).replaceAll("'","&#039;")}'
      data-variant-selection-required-message="${c}"
    >
      ${g()}
      ${y()}
    </gp-product-button>
    ${S()}
  `};exports.default=ProductButton;
