'use client';
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useCurrentVariant as s,useQuantity as o}from"@gem-sdk/core";import{createAttr as l,createClass as n,createStyle as r,If as a}from"@gem-sdk/system";import{useProductQuantity as i}from"./hooks/useProductQuantity.js";import{getContainerAttrs as m,getInputAttr as u,getButtonAttrs as c}from"./common/attrs.js";import{getContainerClasses as d,getWrapperClasses as y,getInputClasses as b,getButtonClass as f,getIconWrapperClasses as p}from"./common/classes.js";import{getContainerStyles as h,getWrapperStyles as g,getInputStyle as N,getButtonStyle as S}from"./common/styles.js";import{getIconWidth as j,getMinusIcon as v,getPlusIcon as B}from"./common/helpers.js";let H=H=>{let{setting:k={},styles:C={},builderProps:D,advanced:_}=H,Q=s(),{quantity:x}=o(),{isInStock:I,ref:L,onClickIncrement:M,onClickDecrement:P,onChangeInput:T,onFocusInput:F}=i(H),{plusIcon:V,minusIcon:q}=k,w=k.defaultQtyValue||1,{inputHeight:z,buttonBackgroundColor:A,backgroundColor:E,iconColor:G,inputBackgroundColor:J,textColor:K,align:O,borderBtn:R,buttonWidth:U,iconSizeCustom:W,corner:X}=C,Y=k?.hasButton,Z=l({...m({isDisabled:!I,uid:D?.uid||""})}),$=n({...d(_?.cssClass)}),tt=r({...h({align:O,inputHeight:z})}),te=n({...y()}),ts=r({...g({backgroundColor:E,styles:C})}),to=l({...u({hasButton:Y,quantity:x,currentVariant:Q,defaultQty:w})}),tl=n({...b({styles:C,borderBtn:R,inputBackgroundColor:J,textColor:K,isDisabled:!I})}),tn=r({...N(H)}),tr=n({...f({borderBtn:R,buttonBackgroundColor:A,iconColor:G,buttonSide:"left",isDisabled:!I})}),ta=r({...S({borderBtn:R,buttonWidth:U,buttonBackgroundColor:A,iconColor:G,corner:X,enableHoverButton:k?.enableHoverButton})}),ti=l({...c({buttonSide:"left"})}),tm=n({...f({borderBtn:R,buttonBackgroundColor:A,iconColor:G,buttonSide:"right",isDisabled:!I})}),tu=r({...S({borderBtn:R,buttonWidth:U,buttonBackgroundColor:A,iconColor:G,corner:X,flipStyle:!0,enableHoverButton:k?.enableHoverButton})}),tc=l({...c({buttonSide:"right"})}),td=n({...p()}),ty=r({...j(W)});return t("div",{ref:L,...Z,className:$,style:tt,children:e("div",{className:te,style:ts,children:[a(Y,t("button",{...ti,onClick:P,className:tr,style:ta,children:t("span",{className:td,style:ty,dangerouslySetInnerHTML:{__html:v(q)}})})),t("input",{...to,className:tl,style:tn,onChange:t=>T(t),onFocus:t=>F(t)}),a(Y,t("button",{...tc,onClick:M,className:tm,style:tu,children:t("span",{className:td,style:ty,dangerouslySetInnerHTML:{__html:B(V)}})}))]})})};export{H as default};
