import{p as i,H as s,c as t,h as e,a as h}from"./index.js";import{c as a}from"./p-vN03FcXN.js";import{v as n}from"./p-BKP-F1qP.js";import{g as o,n as c,o as r}from"./p-9imLQpxb.js";import{g as l,t as d,c as m}from"./p-DKo9A5gq.js";import{F as u}from"./p-5itQzbON.js";import{A as p,a as b,i as v}from"./p-CXgom82_.js";import{d as f}from"./p-BJnSrRNH.js";const g=i(class i extends s{constructor(){super();this.__registerHost();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=o(this.h)}validateSize(i){n(r,i,c.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 p(this.host,((i,s)=>{this.onAriaAttributeChange(i,s)}));this.attributeObserver.startObserving(b)}componentWillLoad(){this.passControlAttrs();this.inheritedAttributes=v(this.host)}disconnectedCallback(){var i;(i=this.attributeObserver)===null||i===void 0?void 0:i.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(i,s){this.host.removeAttribute(i);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[i]:s})}render(){const i=i=>{if(this.noLabel){return e("label",{class:c.label},i)}return i};const s=!this.host.querySelector('[slot="label"]');const t=`${this.h.classes(c.root)}${s?` ${c.noLabel}`:""}`;return e(h,{class:t,hydrated:this.hydrated,checked:this.checked,size:this.size,invalid:m(this.invalid)},i(e(u,null,e("input",Object.assign({class:c.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:i=>this.inputRef=i,required:this.required},this.inheritedAttributes,{"aria-checked":this.checked,"aria-required":m(this.required),"aria-invalid":m(this.invalid),"aria-disabled":m(this.disabled)})),e("span",null,e("span",{class:c.indicator},this.checked&&e("gov-icon",{name:"check-lg",type:"components"})),e("slot",{name:"label"})))))}onClickHandler(i){i.stopPropagation()}onFocusHandler(i){i.stopPropagation();this.govFocus.emit({component:c.root,checked:this.checked,value:this.value,originalEvent:i})}onBlurHandler(i){i.stopPropagation();this.govBlur.emit({component:c.root,checked:this.checked,value:this.value,originalEvent:i})}onChangeHandler(i){this.checked=i.target.checked;i.stopPropagation();this.govChange.emit({component:c.root,checked:this.checked,value:this.value,originalEvent:i})}async getRef(){return this.inputRef}get host(){return this}static get watchers(){return{size:["validateSize","watchDisabled"],disabled:["watchDisabled"],invalid:["watchDisabled"]}}},[4,"gov-form-switch",{value:[1],noLabel:[4,"no-label"],checked:[1540],required:[4],disabled:[516],name:[1],size:[513],identifier:[1],invalid:[4],inheritedAttributes:[32],getRef:[64]},undefined,{size:["validateSize","watchDisabled"],disabled:["watchDisabled"],invalid:["watchDisabled"]}]);function k(){if(typeof customElements==="undefined"){return}const i=["gov-form-switch","gov-icon"];i.forEach((i=>{switch(i){case"gov-form-switch":if(!customElements.get(i)){customElements.define(i,g)}break;case"gov-icon":if(!customElements.get(i)){f()}break}}))}k();const w=g;const j=k;export{w as GovFormSwitch,j as defineCustomElement};
//# sourceMappingURL=gov-form-switch.js.map