"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),attrs=require("../common/attrs.js"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers$1=require("../../helpers.js"),ButtonIcon_liquid=require("./ButtonIcon.liquid.js"),ButtonLabel_liquid=require("./ButtonLabel.liquid.js"),ButtonLoadingIndicator_liquid=require("./ButtonLoadingIndicator.liquid.js"),helpers=require("../common/helpers.js");const Button=e=>{let{advanced:s,className:t,nodePrice:a,customAttrs:l,styles:r={},setting:i={},builderProps:o,wrapClassName:n=""}=e,{iconSvg:u,btnLink:c,htmlType:d,disabled:y,enableBtnLink:g,shouldClearSpace:p,disabledLoading:m=!0}=i,{enableTextStyle:$=!0}=r,{customCss:q,wrapStyle:f,restStyle:B,dataState:L,dataIdAttr:S,isShowIcon:b,isScrollToElement:I,getArialLabel:C,getLabelToDisplay:v,checkIsShowLabel:h,checkIsEditableLabel:j}=helpers.getData(e),{HTMLTag:_,urlData:k,shouldRenderLink:E}=helpers.getInsertLinkData({enableBtnLink:g,htmlType:d,setting:c,defaultTag:"button",isLiquid:!0}),T=system.createStyle({...styles.getButtonStyles(r,i?.enableHoverEffect)}),A=system.createStyle({...styles.getTypoStyles(r)}),D=system.createStyle({...styles.getTypoStyles(r),...styles.getButtonIconStyles(r,i)}),P=system.createStyle({...styles.getButtonWrapperStyles(B,r)}),x=system.createClass({...classes.getButtonClasses({styles:r,className:t,shouldRenderLink:E,uid:o?.uid,advanced:s})}),M=system.createClass({...classes.getButtonIconClasses(v({isLiquid:!0}),p,$)}),O=system.createClass({...classes.getButtonLabelClasses(r,j({isLiquid:!0}))}),W=system.createClass({...classes.getButtonWrapperClasses(n,t,s?.cssClass)}),G=system.createClass({...classes.getButtonContentWrapperClasses(i)}),H=system.createClass({...classes.getButtonContainerClasses()}),R=system.createAttr({...attrs.getButtonAttributes({disabled:y,dataState:L,dataId:S,arialLabel:C({isLiquid:!0})})}),N=system.createStateOrContext({btnLink:i?.btnLink});return system.Liquid(core.template`
    <gp-button
      gp-data='${core.dataStringify(N)}'
      style="${{...f}}"
      class="${H}"
    >
      <div style="${P}" class="${W}">
        <style>${q}</style>
        ${system.If(I,`<a
            class="gp-trigger-button-link gp-hidden"
            href=${k.href}
            target=${k.target}
          ></a>`)}
        <${_}
          ${{...R}}
          ${{...l}}
          ${{...k}}
          style="${T}"
          class="${x}"
        >
        ${system.If(!m,ButtonLoadingIndicator_liquid.default(),"")}
        <div class="${G}">
          ${system.If(b,ButtonIcon_liquid.default({iconSvg:u??"",styles:D,classes:M}))}
          ${system.If($&&h({isLiquid:!0}),ButtonLabel_liquid.default({label:v({isLiquid:!0}),styles:A,classes:O}))}
        </div>
        ${system.If(!!a,a?.toString()??"","")}
        </${_}>
      </div>
      ${system.If(core.isLocalEnv,`<script ${helpers$1.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers$1.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
    </gp-button>
  `)};exports.default=Button;
