import{template as s,dataStringify as t,isLocalEnv as i,baseAssetURL as e}from"@gem-sdk/core";import{createStyle as o,createClass as r,createAttr as l,createStateOrContext as a,Liquid as d,If as m}from"@gem-sdk/system";import{getButtonAttributes as n}from"../common/attrs.js";import{getButtonStyles as p,getTypoStyles as c,getButtonIconStyles as u,getButtonWrapperStyles as $}from"../common/styles.js";import{getButtonClasses as f,getButtonIconClasses as g,getButtonLabelClasses as b,getButtonWrapperClasses as L,getButtonContentWrapperClasses as y,getButtonContainerClasses as j}from"../common/classes.js";import{getSettingPreloadData as v}from"../../helpers.js";import q from"./ButtonIcon.liquid.js";import k from"./ButtonLabel.liquid.js";import S from"./ButtonLoadingIndicator.liquid.js";import{getData as h,getInsertLinkData as B}from"../common/helpers.js";let Button=E=>{let{advanced:I,className:T,nodePrice:A,customAttrs:G,styles:H={},setting:M={},builderProps:_,wrapClassName:x=""}=E,{iconSvg:C,btnLink:N,htmlType:O,disabled:P,enableBtnLink:R,shouldClearSpace:V,disabledLoading:w=!0}=M,{enableTextStyle:z=!0}=H,{customCss:D,wrapStyle:F,restStyle:J,dataState:K,dataIdAttr:Q,isShowIcon:U,isScrollToElement:W,getArialLabel:X,getLabelToDisplay:Y,checkIsShowLabel:Z,checkIsEditableLabel:ss}=h(E),{HTMLTag:st,urlData:si,shouldRenderLink:se}=B({enableBtnLink:R,htmlType:O,setting:N,defaultTag:"button",isLiquid:!0}),so=o({...p(H,M?.enableHoverEffect)}),sr=o({...c(H)}),sl=o({...c(H),...u(H,M)}),sa=o({...$(J,H)}),sd=r({...f({styles:H,className:T,shouldRenderLink:se,uid:_?.uid,advanced:I})}),sm=r({...g(Y({isLiquid:!0}),V,z)}),sn=r({...b(H,ss({isLiquid:!0}))}),sp=r({...L(x,T,I?.cssClass)}),sc=r({...y(M)}),su=r({...j()}),s$=l({...n({disabled:P,dataState:K,dataId:Q,arialLabel:X({isLiquid:!0})})}),sf=a({btnLink:M?.btnLink});return d(s`
    <gp-button
      gp-data='${t(sf)}'
      style="${{...F}}"
      class="${su}"
    >
      <div style="${sa}" class="${sp}">
        <style>${D}</style>
        ${m(W,`<a
            class="gp-trigger-button-link gp-hidden"
            href=${si.href}
            target=${si.target}
          ></a>`)}
        <${st}
          ${{...s$}}
          ${{...G}}
          ${{...si}}
          style="${so}"
          class="${sd}"
        >
        ${m(!w,S(),"")}
        <div class="${sc}">
          ${m(U,q({iconSvg:C??"",styles:sl,classes:sm}))}
          ${m(z&&Z({isLiquid:!0}),k({label:Y({isLiquid:!0}),styles:sr,classes:sn}))}
        </div>
        ${m(!!A,A?.toString()??"","")}
        </${st}>
      </div>
      ${m(i,`<script ${v('class="gps-link" delay',"src")}="{{ 'gp-button-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${v('class="gps-link" delay',"src")}="${e}/assets-v2/gp-button-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
    </gp-button>
  `)};export{Button as default};
