import{r as m,l as k,m as T,j as n,o as C,p as y,q as S,P as L,t as W,v as w,C as B,w as R}from"./index.CS3tpmQq.js";import{W as E}from"./WidgetLabelHelpIconInline.B31eEkR7.js";import{u as P}from"./useBasicWidgetState.DxPSDiCY.js";import{S as v,L as $,a as u}from"./checkbox.D1dO0sd2.js";import"./FormClearHelper.DyKNX1aO.js";function X({element:t,disabled:a,widgetMgr:s,fragmentId:d}){const[p,g]=P({getStateFromWidgetMgr:H,getDefaultStateFromProto:M,getCurrStateFromProto:V,updateWidgetMgrState:F,element:t,widgetMgr:s,fragmentId:d}),f=m.useCallback(i=>{g({value:i.target.checked,fromUi:!0})},[g]),e=k(),{colors:o,spacing:h,sizes:r}=e,b=T(e),x=a?o.fadedText40:o.bodyText;return n(R,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:n(v,{checked:p,disabled:a,onChange:f,"aria-label":t.label,checkmarkType:t.type===B.StyleType.TOGGLE?u.toggle:u.default,labelPlacement:$.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 c=b?o.bgColor:o.bodyText;return a&&(c=b?o.gray70:o.gray90),{width:`calc(${r.checkbox} - ${e.spacing.twoXS})`,height:`calc(${r.checkbox} - ${e.spacing.twoXS})`,transform:i?`translateX(${r.checkbox})`:"",backgroundColor:c,boxShadow:""}}},ToggleTrack:{style:({$checked:i,$isHovered:c})=>{let l=o.fadedText40;return c&&!a&&(l=o.fadedText20),i&&!a&&(l=o.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:e.spacing.twoXS,paddingLeft:e.spacing.threeXS,paddingRight:e.spacing.threeXS,width:`calc(2 * ${r.checkbox})`,minWidth:`calc(2 * ${r.checkbox})`,height:r.checkbox,minHeight:r.checkbox,borderBottomLeftRadius:e.radii.full,borderTopLeftRadius:e.radii.full,borderBottomRightRadius:e.radii.full,borderTopRightRadius:e.radii.full,backgroundColor:l}}},Checkmark:{style:({$isFocusVisible:i,$checked:c})=>{const l=c&&!a?o.primary:o.fadedText40;return{outline:0,width:r.checkbox,height:r.checkbox,marginTop:e.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:i&&c?w(o.primary):"",borderLeftWidth:r.borderWidth,borderRightWidth:r.borderWidth,borderTopWidth:r.borderWidth,borderBottomWidth:r.borderWidth,borderLeftColor:l,borderRightColor:l,borderTopColor:l,borderBottomColor:l}}},Label:{style:{lineHeight:e.lineHeights.small,paddingLeft:e.spacing.sm,position:"relative",color:x}}},children:C(W,{visibility:y(t.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[n(S,{source:t.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),t.help&&n(E,{content:t.help,placement:L.TOP_RIGHT,label:t.label})]})})})}function H(t,a){return t.getBoolValue(a)}function M(t){return t.default??null}function V(t){return t.value??null}function F(t,a,s,d){a.setBoolValue(t,s.value,{fromUi:s.fromUi},d)}const A=m.memo(X);export{A as default};
