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