import{Ci as e,Gt as t,Ja as n,Kt as r,Nr as i,Pt as a,Qa as o,Sa as s,Ya as c,_n as l,cr as u,io as d,mn as f}from"./index.dkY5s53S.js";import{n as p,r as m,t as h}from"./checkbox.UCpp4Z27.js";import{n as g}from"./useBasicWidgetState.C674_qFj.js";var _=d(o(),1);function v({element:o,disabled:d,widgetMgr:v,fragmentId:C}){let[w,T]=g({getStateFromWidgetMgr:y,getDefaultStateFromProto:b,getCurrStateFromProto:x,updateWidgetMgrState:S,element:o,widgetMgr:v,fragmentId:C,formClearBehavior:`resetValueOnly`,queryParamBinding:o.queryParamKey?{paramKey:o.queryParamKey,valueType:`bool_value`,clearable:!1}:void 0}),E=(0,_.useCallback)(e=>{T({value:e.target.checked,fromUi:!0})},[T]),D=u(),{colors:O,spacing:k,sizes:A}=D,j=i(D),M=d?O.fadedText40:O.bodyText;return n(t,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:n(h,{checked:w,disabled:d,onChange:E,"aria-label":o.label,checkmarkType:o.type===s.StyleType.TOGGLE?m.toggle:m.default,labelPlacement:p.right,overrides:{Root:{style:({$isFocusVisible:e})=>({marginBottom:k.none,marginTop:k.none,backgroundColor:e?O.darkenedBgMix25:``,display:`flex`,alignItems:`start`})},Toggle:{style:({$checked:e})=>{let t=j?O.bgColor:O.bodyText;return d&&(t=j?O.gray70:O.gray90),{width:`calc(${A.checkbox} - ${D.spacing.twoXS})`,height:`calc(${A.checkbox} - ${D.spacing.twoXS})`,transform:e?`translateX(${A.checkbox})`:``,backgroundColor:t,boxShadow:``}}},ToggleTrack:{style:({$checked:e,$isHovered:t})=>{let n=O.borderColor;return t&&!d&&(n=O.darkenedBgMix15),e&&!d&&(n=O.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:D.spacing.twoXS,paddingLeft:D.spacing.threeXS,paddingRight:D.spacing.threeXS,width:`calc(2 * ${A.checkbox})`,minWidth:`calc(2 * ${A.checkbox})`,height:A.checkbox,minHeight:A.checkbox,borderBottomLeftRadius:D.radii.full,borderTopLeftRadius:D.radii.full,borderBottomRightRadius:D.radii.full,borderTopRightRadius:D.radii.full,backgroundColor:n}}},Checkmark:{style:({$isFocusVisible:e,$checked:t})=>{let n=t&&!d?O.primary:O.borderColor;return{outline:0,width:A.checkbox,height:A.checkbox,marginTop:D.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:e&&t?D.shadows.focusRing:``,borderLeftWidth:A.borderWidth,borderRightWidth:A.borderWidth,borderTopWidth:A.borderWidth,borderBottomWidth:A.borderWidth,borderLeftColor:n,borderRightColor:n,borderTopColor:n,borderBottomColor:n}}},Label:{style:{lineHeight:D.lineHeights.small,paddingLeft:D.spacing.sm,position:`relative`,color:M}}},children:c(r,{visibility:e(o.labelVisibility?.value),"data-testid":`stWidgetLabel`,children:[n(f,{source:o.label,allowHTML:!1,isLabel:!0}),o.help&&n(a,{content:o.help,placement:l.TOP_RIGHT,label:o.label})]})})})}function y(e,t){return e.getBoolValue(t)}function b(e){return e.default??!1}function x(e){return e.value??!1}function S(e,t,n,r){t.setBoolValue(e,n.value,{fromUi:n.fromUi},r)}var C=(0,_.memo)(v);export{C as default};