'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),helpers$1=require("../../helpers.js"),attrs=require("../common/attrs.js"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),ButtonIcon=require("./ButtonIcon.js"),ButtonLabel=require("./ButtonLabel.js"),ButtonLoadingIndicator=require("./ButtonLoadingIndicator.js"),helpers=require("../common/helpers.js");const Button=e=>{let{children:s,advanced:t,className:a,nodePrice:l,customAttrs:r,styles:n={},setting:o={},builderProps:u,builderAttrs:c,wrapClassName:i="",onClick:y}=e,{iconSvg:m,btnLink:d,htmlType:g,loading:j,disabled:x,shouldClearSpace:p,enableBtnLink:B}=o,{enableTextStyle:C=!0}=n,h=core.useEditorMode(),I=core.usePageType(),{customCss:f,wrapStyle:b,restStyle:L,dataState:q,dataIdAttr:S,isShowIcon:R,isScrollToElement:k,getArialLabel:v,getLabelToDisplay:T,checkIsShowLabel:N,checkIsEditableLabel:M}=helpers.getData(e),{HTMLTag:_,urlData:H,shouldRenderLink:W}=helpers.getInsertLinkData({enableBtnLink:B,htmlType:g,setting:d,defaultTag:"button",pageType:I}),A=system.createStyle({...styles.getButtonStyles(n,o.enableHoverEffect)}),D=system.createStyle({...styles.getTypoStyles(n)}),E=system.createStyle({...styles.getTypoStyles(n),...styles.getButtonIconStyles(n,o)}),P=system.createStyle({...styles.getButtonWrapperStyles(L,n)}),$=system.createClass({...classes.getButtonClasses({styles:n,className:a,shouldRenderLink:W,uid:u?.uid,advanced:t})}),O=system.createClass({...classes.getButtonIconClasses(T(),p,C)}),w=system.createClass({...classes.getButtonLabelClasses(n,M({mode:h}))}),z=system.createClass({...classes.getButtonWrapperClasses(i,a,t?.cssClass)}),F=system.createClass({...classes.getButtonContentWrapperClasses(o)}),G=system.createClass({...classes.getButtonContainerClasses()}),J=system.createAttr({...attrs.getButtonAttributes({disabled:x,dataState:q,dataId:S,arialLabel:v()})}),K=e=>{y?.(e),helpers$1.handleClickLink(d,h)};return jsxRuntime.jsx("div",{style:b,className:G,children:jsxRuntime.jsxs("div",{...c,style:P,className:z,children:[jsxRuntime.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:f}}),system.If(k,jsxRuntime.jsx("a",{className:"gp-trigger-button-link gp-hidden",href:H.href,target:H.target})),jsxRuntime.jsxs(_,{...J,...r,..."button"!==_&&{setting:H},style:A,className:$,onClick:K,children:[system.If(j,jsxRuntime.jsx(ButtonLoadingIndicator.default,{})),jsxRuntime.jsxs("div",{className:F,children:[system.If(R,jsxRuntime.jsx(ButtonIcon.default,{iconSvg:m??"",styles:E,classes:O})),system.If(C&&N(),jsxRuntime.jsx(ButtonLabel.default,{label:T(),styles:D,classes:w}))]}),system.If(!!l,l??"")]}),s]})})};exports.default=Button;
