import{r as t,c as s,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 r,F as n,a as c}from"./p-B6CqPcY_.js";import{g as l,a as p,t as d}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 g}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 f=class{constructor(i){t(this,i);this.govFocus=s(this,"gov-focus");this.govBlur=s(this,"gov-blur");this.govChange=s(this,"gov-change");this.hydrated=false;this.checked=false;this.required=false;this.disabled=false;this.indeterminate=false;this.size="m";this.noLabel=false;this.inheritedAttributes={};this.checkboxId=a("GovCheckbox");this.h=l(this.host);this.f=r(this.h)}validateSize(t){o(c,t,n.root)}watchControlAttrs(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("disabled",p(this.disabled));this.f.passAttrToControl("invalid",p(this.invalid));this.f.passAttrToControl("type","checkbox")}componentWillLoad(){this.passControlAttrs();this.inheritedAttributes=g(this.host)}componentDidLoad(){this.attributeObserver=new v(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(u)}async componentDidRender(){this.f.passAttrToLabel("identifier",this.identifier||this.checkboxId);this.f.passAttrToLabel("required",String(this.required));this.passControlAttrs()}connectedCallback(){this.hydrated=true}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}render(){const t=t=>{if(this.noLabel){return i("label",{class:n.label},t)}return t};return i(h,{class:n.root,hydrated:this.hydrated,checked:this.checked,size:this.size,invalid:d(this.invalid)},t(i(m,null,i("input",Object.assign({id:this.identifier||this.checkboxId,type:"checkbox",value:this.value,name:this.name,checked:this.checked,onClick:this.onClickHandler.bind(this),onChange:this.onChangeHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,disabled:this.disabled,indeterminate:this.indeterminate,ref:t=>this.inputRef=t},this.inheritedAttributes,{"aria-checked":p(this.checked),"aria-required":d(this.required),"aria-invalid":d(this.invalid),"aria-disabled":d(this.disabled)})),i("span",null,i("slot",{name:"label"}),i("gov-icon",{class:n.check,name:"check-lg",type:"components"}),i("gov-icon",{class:n.indeterminate,name:"dash-lg",type:"components"})))))}onFocusHandler(t){t.stopPropagation();this.govFocus.emit({component:n.root,value:this.value,checked:this.checked,originalEvent:t})}onBlurHandler(t){t.stopPropagation();this.govBlur.emit({component:n.root,value:this.value,checked:this.checked,originalEvent:t})}onClickHandler(t){t.stopPropagation()}onChangeHandler(t){this.checked=t.target.checked;t.stopPropagation();this.govChange.emit({component:n.root,value:this.value,checked:this.checked,originalEvent:t})}async getRef(){return this.inputRef}get host(){return e(this)}static get watchers(){return{size:["validateSize","watchControlAttrs"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"]}}};export{f as gov_form_checkbox};
//# sourceMappingURL=p-5721cf9b.entry.js.map