import{b as m,N as x,aj as C,c as n,j as T,G as L,aG as S,aH as B,cY as W,cZ as w,c_ as R}from"./index.BdH_oWMm.js";import{W as v}from"./WidgetLabelHelpIconInline.Dc0B3Bjn.js";import{a as P}from"./useBasicWidgetState.U_bd_Q53.js";import{a as E,L as H,S as u}from"./checkbox.DIKfU0fO.js";import"./styled-components.jdcyFPSS.js";import"./FormClearHelper.B3vyDvH9.js";function M({element:e,disabled:a,widgetMgr:s,fragmentId:d}){const f=e.queryParamKey?{paramKey:e.queryParamKey,valueType:"bool_value",clearable:!1}:void 0,[p,g]=P({getStateFromWidgetMgr:V,getDefaultStateFromProto:X,getCurrStateFromProto:$,updateWidgetMgrState:_,element:e,widgetMgr:s,fragmentId:d,formClearBehavior:"resetValueOnly",queryParamBinding:f}),k=m.useCallback(i=>{g({value:i.target.checked,fromUi:!0})},[g]),o=x(),{colors:r,spacing:h,sizes:t}=o,b=C(o),y=a?r.fadedText40:r.bodyText;return n(R,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:n(E,{checked:p,disabled:a,onChange:k,"aria-label":e.label,checkmarkType:e.type===w.StyleType.TOGGLE?u.toggle:u.default,labelPlacement:H.right,overrides:{Root:{style:({$isFocusVisible:i})=>({marginBottom:h.none,marginTop:h.none,backgroundColor:i?r.darkenedBgMix25:"",display:"flex",alignItems:"start"})},Toggle:{style:({$checked:i})=>{let c=b?r.bgColor:r.bodyText;return a&&(c=b?r.gray70:r.gray90),{width:`calc(${t.checkbox} - ${o.spacing.twoXS})`,height:`calc(${t.checkbox} - ${o.spacing.twoXS})`,transform:i?`translateX(${t.checkbox})`:"",backgroundColor:c,boxShadow:""}}},ToggleTrack:{style:({$checked:i,$isHovered:c})=>{let l=r.borderColor;return c&&!a&&(l=r.darkenedBgMix15),i&&!a&&(l=r.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:o.spacing.twoXS,paddingLeft:o.spacing.threeXS,paddingRight:o.spacing.threeXS,width:`calc(2 * ${t.checkbox})`,minWidth:`calc(2 * ${t.checkbox})`,height:t.checkbox,minHeight:t.checkbox,borderBottomLeftRadius:o.radii.full,borderTopLeftRadius:o.radii.full,borderBottomRightRadius:o.radii.full,borderTopRightRadius:o.radii.full,backgroundColor:l}}},Checkmark:{style:({$isFocusVisible:i,$checked:c})=>{const l=c&&!a?r.primary:r.borderColor;return{outline:0,width:t.checkbox,height:t.checkbox,marginTop:o.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:i&&c?o.shadows.focusRing:"",borderLeftWidth:t.borderWidth,borderRightWidth:t.borderWidth,borderTopWidth:t.borderWidth,borderBottomWidth:t.borderWidth,borderLeftColor:l,borderRightColor:l,borderTopColor:l,borderBottomColor:l}}},Label:{style:{lineHeight:o.lineHeights.small,paddingLeft:o.spacing.sm,position:"relative",color:y}}},children:T(W,{visibility:B(e.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[n(L,{source:e.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),e.help&&n(v,{content:e.help,placement:S.TOP_RIGHT,label:e.label})]})})})}function V(e,a){return e.getBoolValue(a)}function X(e){return e.default??!1}function $(e){return e.value??!1}function _(e,a,s,d){a.setBoolValue(e,s.value,{fromUi:s.fromUi},d)}const N=m.memo(M);export{N as default};
