import{r as p,m as k,M as T,j as n,b6 as y,b7 as C,aJ as S,H as $,aV as L,aK as w,ap as R,ao as W,b8 as B}from"./index-D3uELfdo.js";import{S as v}from"./useBasicWidgetState-DqA4I-I_-DtgK63iS.js";import{v as H,y as M,T as u}from"./checkbox-i_07yegq-B7N8fYE1.js";import"./FormClearHelper-Dgu5Halt-BxICjxpW.js";function V({element:e,disabled:a,widgetMgr:s,fragmentId:c}){const[f,g]=v({getStateFromWidgetMgr:j,getDefaultStateFromProto:X,getCurrStateFromProto:I,updateWidgetMgrState:P,element:e,widgetMgr:s,fragmentId:c}),x=p.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 n.jsx(y,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:n.jsx(H,{checked:f,disabled:a,onChange:x,"aria-label":e.label,checkmarkType:e.type===B.StyleType.TOGGLE?u.toggle:u.default,labelPlacement:M.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:n.jsxs(C,{visibility:S(e.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[n.jsx($,{source:e.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),e.help&&n.jsx(L,{color:m,children:n.jsx(w,{content:e.help,placement:R.TOP_RIGHT})})]})})})}function j(e,a){return e.getBoolValue(a)}function X(e){return e.default??null}function I(e){return e.value??null}function P(e,a,s,c){a.setBoolValue(e,s.value,{fromUi:s.fromUi},c)}const U=p.memo(V);export{U as default};
