import{r as s,c as t,h as i,H as h,g as e}from"./p-ClISz4NF.js";import{c as a}from"./p-vN03FcXN.js";import{v as o}from"./p-NOJjz9dT.js";import{g as n,h as r,i as c}from"./p-B6CqPcY_.js";import{g as l,a as d,t as p}from"./p-CoD1xawt.js";import{F as m}from"./p-5itQzbON.js";import{A as v,a as u}from"./p-Bz_RzYFb.js";import{i as b}from"./p-CzXeijOj.js";import"./p-CgDnDrq5.js";import"./p-CQvUntGY.js";import"./p-BcQO4NH2.js";import"./p-EeKNA85D.js";import"./p-U40vKHrs.js";import"./p-DYcNEwSZ.js";import"./p-DBXGhafv.js";const g=class{constructor(i){s(this,i);this.govFocus=t(this,"gov-focus");this.govBlur=t(this,"gov-blur");this.govChange=t(this,"gov-change");this.hydrated=false;this.noLabel=false;this.checked=false;this.required=false;this.disabled=false;this.size="m";this.inheritedAttributes={};this.checkboxId=a("GovCheckbox");this.h=l(this.host);this.f=n(this.h)}validateSize(s){o(c,s,r.root)}watchDisabled(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("invalid",d(this.invalid));this.f.passAttrToControl("disabled",d(this.disabled));this.f.passAttrToControl("type","switch")}componentDidLoad(){this.attributeObserver=new v(this.host,((s,t)=>{this.onAriaAttributeChange(s,t)}));this.attributeObserver.startObserving(u)}componentWillLoad(){this.passControlAttrs();this.inheritedAttributes=b(this.host)}disconnectedCallback(){var s;(s=this.attributeObserver)===null||s===void 0?void 0:s.stopObserving()}async componentDidRender(){this.f.passAttrToLabel("identifier",this.identifier||this.checkboxId);this.f.passAttrToLabel("required",String(this.required));this.passControlAttrs()}connectedCallback(){this.hydrated=true}onAriaAttributeChange(s,t){this.host.removeAttribute(s);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[s]:t})}render(){const s=s=>{if(this.noLabel){return i("label",{class:r.label},s)}return s};const t=!this.host.querySelector('[slot="label"]');const e=`${this.h.classes(r.root)}${t?` ${r.noLabel}`:""}`;return i(h,{class:e,hydrated:this.hydrated,checked:this.checked,size:this.size,invalid:p(this.invalid)},s(i(m,null,i("input",Object.assign({class:r.input,id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,disabled:this.disabled,checked:this.checked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),ref:s=>this.inputRef=s,required:this.required},this.inheritedAttributes,{"aria-checked":this.checked,"aria-required":p(this.required),"aria-invalid":p(this.invalid),"aria-disabled":p(this.disabled)})),i("span",null,i("span",{class:r.indicator},this.checked&&i("gov-icon",{name:"check-lg",type:"components"})),i("slot",{name:"label"})))))}onClickHandler(s){s.stopPropagation()}onFocusHandler(s){s.stopPropagation();this.govFocus.emit({component:r.root,checked:this.checked,value:this.value,originalEvent:s})}onBlurHandler(s){s.stopPropagation();this.govBlur.emit({component:r.root,checked:this.checked,value:this.value,originalEvent:s})}onChangeHandler(s){this.checked=s.target.checked;s.stopPropagation();this.govChange.emit({component:r.root,checked:this.checked,value:this.value,originalEvent:s})}async getRef(){return this.inputRef}get host(){return e(this)}static get watchers(){return{size:["validateSize","watchDisabled"],disabled:["watchDisabled"],invalid:["watchDisabled"]}}};export{g as gov_form_switch};
//# sourceMappingURL=p-c6b55c0a.entry.js.map