import{getSplitStyle as t}from"./common/styles.js";import{getGPProductButtonState as o}from"./common/helpers.js";import{template as s,isLocalEnv as r,baseAssetURL as e}from"@gem-sdk/core";import{createStateOrContext as a,Liquid as i,LiquidFor as l,If as n}from"@gem-sdk/system";import{getInsertLinkData as p,getSettingPreloadData as c}from"../../../helpers.js";import{getButtonDynamicSourceLocales as u}from"./helpers/getButtonDynamicSourceLocales.js";import{SoldOutButton as m}from"./SoldOutButton.liquid.js";import{AddToCartButton as d}from"./AddToCartButton.liquid.js";let f=f=>{let{setting:g,builderProps:b,style:y,styles:$,pageContext:v}=f,{wrapStyle:_,restStyle:h}=t(y),{outOfStockButtonLabel:S,unavailableButtonLabel:j,variantSelectionRequiredMessage:k,successMessage:E,errorMessage:q}=u({setting:g,pageContext:v,builderProps:b}),{urlData:A}=p("",g?.actionEffect==="open-cart-drawer"?{link:"/cart",target:"_self"}:g?.customURL),B=a(o({styles:$,setting:g,successMessage:E,errorMessage:q,variantSelectionRequiredMessage:k}));return s`
    ${i("{%- assign total_combinations = 1 -%}")}
    ${l("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="${_}"
      gp-data-wrapper="true"
      gp-href="${A.href}"
      class="gp-product-button"
      gp-label-out-of-stock="${S}"
      gp-label-unavailable="${j}"
      gp-data='${JSON.stringify(B)}'
      gp-enable-third-partycart="{{shop.metafields.GEMPAGES.enableThirdPartyCart}}"
    >
      ${d({...f,style:h})}
      ${m({...f,style:h,label:S})}
    </gp-product-button>
    ${n(r,`<script ${c('class="gps-link" delay',"src")}="{{ 'gp-product-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${c('class="gps-link" delay',"src")}="${e}/assets-v2/gp-product-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{f as default};
