"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),Button_liquid=require("../../button/components/Button.liquid.js"),helpers=require("../../helpers.js"),system=require("@gem-sdk/system"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),helpers$1=require("../common/helpers.js"),translate=require("../settings/configs/translate.js");const Coupon=({setting:e,builderProps:t,builderAttrs:s,style:l,styles:r,advanced:a,pageContext:i})=>{let{backgroundColorV2:n,textColor:o,enableTextStyle:u}=r??{},{defaultLabel:c,clickedLabel:d,copyContent:p}=e??{},g=helpers.getDynamicSourceLocales({val:d,uid:t?.uid,settingId:helpers.createSettingId({id:translate.Coupon?.defaultLabel?.id}),pageContext:i??{}}),y=helpers.getDynamicSourceLocales({val:d,uid:t?.uid,settingId:helpers.createSettingId({id:translate.Coupon?.clickedLabel?.id}),pageContext:i??{}}),m=system.createStateOrContext({defaultLabel:g,clickedLabel:y,copyContent:p,uid:t?.uid,enableTextStyle:u}),S=system.createClass(classes.getActiveClasses(n,o)),f=styles.getInnerBorderCornerCss({uid:t?.uid,styles:r}),$=styles.getInnerActiveStyles(r),h=()=>core.RenderIf(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-coupon-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-coupon-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);return core.template`
    <gp-coupon data-id="${t?.uid}" data-active="false" gp-setting='${JSON.stringify(m).replaceAll("'","&#039;")}' class="${S}">
    <style>${`${f}${$}`}</style>
    ${Button_liquid.default({builderProps:{...t,uidInteraction:`${t?.uid}-interaction`},builderAttrs:s,setting:{...helpers$1.getButtonSetting({setting:e,label:c,htmlType:"button",styles:r})},translateSetting:translate.Coupon?.defaultLabel?.id,style:{...styles.getButtonStyle(l,r)},styles:{...styles.getButtonStyles(r)},advanced:a,pageContext:i})}
    </gp-coupon>
    ${h()}
  `};exports.default=Coupon;
