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