import{template as t,isLocalEnv as s,baseAssetURL as a}from"@gem-sdk/core";import{createClass as i,createStateOrContext as e,Liquid as o,LiquidFor as n,If as l}from"@gem-sdk/system";import{getDynamicSourceLocales as r,createSettingId as d,getSettingPreloadData as p}from"../../../helpers.js";import{getButtonClasses as m}from"./common/classes.js";import{getButtonStyles as c}from"./common/styles.js";import{Button as u}from"../../../button/settings/configs/translate.js";let Button=({setting:g,advanced:y,styles:f,pageContext:_,builderProps:$,className:b=""})=>{let v=r({pageContext:_??{},settingId:d({id:u?.label?.id}),val:g?.label,uid:$?.uid}),j=i({...!!b&&{[b]:!0},...m({styles:f,uid:$?.uid})}),S=c({styles:f,uid:$?.uid}),h=e({setting:{label:g?.label},totalVariant:"{{total_combinations}}"});return t`
    ${o("{%- assign total_combinations = 1 -%}")}
    ${n("option in product.options_with_values","{%- assign total_combinations = total_combinations | times: option.values.size -%}")}
    ${o(`
      {%- liquid
        assign inventory_quantity = variant.inventory_quantity | default: 0
        assign supported_payment_methods = shop.enabled_payment_types
      -%}
    `)}
    <gp-product-dynamic data-id="${$?.uid}" data-translate-label='${v}' class="${y?.cssClass}" gp-data='${JSON.stringify(h).replaceAll("'","&#039;")}
    '>
    <div class="${j}">
        {{ form | payment_button }}
    </div>
    {% style %}
      ${S}
    {% endstyle %}
    </gp-product-dynamic>
    ${l(s,`<script ${p('class="gps-link" delay',"src")}="{{ 'gp-product-dynamic-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${p('class="gps-link" delay',"src")}="${a}/assets-v2/gp-product-dynamic-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{Button as default};
