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