import{r as u,ap as k,b8 as T,j as c,ck as y,cl as L,c0 as w,bc as C,c9 as S,c1 as $,bJ as R,b1 as W,cm as B}from"./index-DCNLpqIv.js";import{a as v}from"./useBasicWidgetState-9vtYd9vP.js";import{S as j,L as X,a as p}from"./checkbox-BNaalk8J.js";import"./FormClearHelper-fvwQICEk.js";function H({element:e,disabled:a,widgetMgr:s,fragmentId:n}){const[f,g]=v({getStateFromWidgetMgr:M,getDefaultStateFromProto:V,getCurrStateFromProto:F,updateWidgetMgrState:P,element:e,widgetMgr:s,fragmentId:n}),x=u.useCallback(i=>{g({value:i.target.checked,fromUi:!0})},[g]),t=k(),{colors:o,spacing:h,sizes:r}=t,b=T(t),m=a?o.fadedText40:o.bodyText;return c.jsx(y,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:c.jsx(j,{checked:f,disabled:a,onChange:x,"aria-label":e.label,checkmarkType:e.type===B.StyleType.TOGGLE?p.toggle:p.default,labelPlacement:X.right,overrides:{Root:{style:({$isFocusVisible:i})=>({marginBottom:h.none,marginTop:h.none,backgroundColor:i?o.darkenedBgMix25:"",display:"flex",alignItems:"start"})},Toggle:{style:({$checked:i})=>{let d=b?o.bgColor:o.bodyText;return a&&(d=b?o.gray70:o.gray90),{width:`calc(${r.checkbox} - ${t.spacing.twoXS})`,height:`calc(${r.checkbox} - ${t.spacing.twoXS})`,transform:i?`translateX(${r.checkbox})`:"",backgroundColor:d,boxShadow:""}}},ToggleTrack:{style:({$checked:i,$isHovered:d})=>{let l=o.fadedText40;return d&&!a&&(l=o.fadedText20),i&&!a&&(l=o.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:t.spacing.twoXS,paddingLeft:t.spacing.threeXS,paddingRight:t.spacing.threeXS,width:`calc(2 * ${r.checkbox})`,minWidth:`calc(2 * ${r.checkbox})`,height:r.checkbox,minHeight:r.checkbox,borderBottomLeftRadius:t.radii.full,borderTopLeftRadius:t.radii.full,borderBottomRightRadius:t.radii.full,borderTopRightRadius:t.radii.full,backgroundColor:l}}},Checkmark:{style:({$isFocusVisible:i,$checked:d})=>{const l=d&&!a?o.primary:o.fadedText40;return{outline:0,width:r.checkbox,height:r.checkbox,marginTop:t.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:i&&d?`0 0 0 0.2rem ${W(o.primary,.5)}`:"",borderLeftWidth:r.borderWidth,borderRightWidth:r.borderWidth,borderTopWidth:r.borderWidth,borderBottomWidth:r.borderWidth,borderLeftColor:l,borderRightColor:l,borderTopColor:l,borderBottomColor:l}}},Label:{style:{lineHeight:t.lineHeights.small,paddingLeft:t.spacing.sm,position:"relative",color:m}}},children:c.jsxs(L,{visibility:w(e.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[c.jsx(C,{source:e.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),e.help&&c.jsx(S,{color:m,children:c.jsx($,{content:e.help,placement:R.TOP_RIGHT})})]})})})}function M(e,a){return e.getBoolValue(a)}function V(e){return e.default??null}function F(e){return e.value??null}function P(e,a,s,n){a.setBoolValue(e,s.value,{fromUi:s.fromUi},n)}const I=u.memo(H);export{I as default};
