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