"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="",translateSetting:u,isForceValue:c}=e,{iconSvg:d,btnLink:y,htmlType:g,disabled:p,enableBtnLink:m,shouldClearSpace:$,disabledLoading:q=!0}=i,{enableTextStyle:f=!0}=r,{customCss:B,wrapStyle:L,restStyle:S,dataState:b,dataIdAttr:I,isShowIcon:C,isScrollToElement:v,getArialLabel:h,getLabelToDisplay:j,checkIsShowLabel:_,checkIsEditableLabel:k}=helpers.getData(e),{HTMLTag:E,urlData:T,shouldRenderLink:A}=helpers.getInsertLinkData({enableBtnLink:m,htmlType:g,setting:y,defaultTag:"button",isLiquid:!0}),D=system.createStyle({...styles.getButtonStyles(r,i?.enableHoverEffect)}),P=system.createStyle({...styles.getTypoStyles(r)}),x=system.createStyle({...styles.getTypoStyles(r),...styles.getButtonIconStyles(r,i)}),M=system.createStyle({...styles.getButtonWrapperStyles(S,r)}),O=system.createClass({...classes.getButtonClasses({styles:r,className:t,shouldRenderLink:A,uid:o?.uid,advanced:s})}),W=system.createClass({...classes.getButtonIconClasses(j({isLiquid:!0,translateSetting:u,isForceValue:c}),$,f)}),G=system.createClass({...classes.getButtonLabelClasses(r,k({isLiquid:!0}))}),H=system.createClass({...classes.getButtonWrapperClasses(n,t,s?.cssClass)}),R=system.createClass({...classes.getButtonContentWrapperClasses(i)}),N=system.createClass({...classes.getButtonContainerClasses()}),U=system.createAttr({...attrs.getButtonAttributes({disabled:p,dataState:b,dataId:I,arialLabel:h({isLiquid:!0})})}),V=system.createStateOrContext({btnLink:i?.btnLink});return system.Liquid(core.template`
    <gp-button
      gp-data='${core.dataStringify(V)}'
      style="${{...L}}"
      class="${N}"
    >
      <div style="${M}" class="${H}">
        <style>${B}</style>
        ${system.If(v,`<a
            class="gp-trigger-button-link gp-hidden"
            href=${T.href}
            target=${T.target}
          ></a>`)}
        <${E}
          ${{...U}}
          ${{...l}}
          ${{...T}}
          style="${D}"
          class="${O}"
        >
        ${system.If(!q,ButtonLoadingIndicator_liquid.default(),"")}
        <div class="${R}">
          ${system.If(C,ButtonIcon_liquid.default({iconSvg:d??"",styles:x,classes:W}))}
          ${system.If(f&&_({isLiquid:!0}),ButtonLabel_liquid.default({label:j({isLiquid:!0,translateSetting:u,isForceValue:c}),styles:P,classes:G}))}
        </div>
        ${system.If(!!a,a?.toString()??"","")}
        </${E}>
      </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;
