import{r as t,c as s,h as i,H as e,g as a}from"./p-ClISz4NF.js";import{g as o,j as h,k as c}from"./p-B6CqPcY_.js";import{g as r,a as n,t as d}from"./p-CoD1xawt.js";import{v as l}from"./p-NOJjz9dT.js";import{c as p}from"./p-vN03FcXN.js";import{p as m}from"./p-Ccwpa1ck.js";import{t as f}from"./p-Cjg0wpDG.js";import{A as v,a as b}from"./p-Bz_RzYFb.js";import{i as u}from"./p-CzXeijOj.js";import"./p-BcQO4NH2.js";import"./p-CQvUntGY.js";import"./p-EeKNA85D.js";import"./p-U40vKHrs.js";import"./p-DYcNEwSZ.js";import"./p-DBXGhafv.js";import"./p-CgDnDrq5.js";import"./p-DNztiAH0.js";const g=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.size="m";this.required=false;this.disabled=false;this.optionsState=[];this.inheritedAttributes={};this.h=r(this.host);this.f=o(this.h);this.selectId=p("GovSelect")}validateSize(t){l(c,t,h.root)}watchOptions(t){this.optionsState=m(t)}watchControlAttrs(){this.passControlAttrs()}watchValue(){this.markSelectedValue()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("invalid",n(this.invalid));this.f.passAttrToControl("success",n(this.success));this.f.passAttrToControl("disabled",n(this.disabled));this.f.passAttrToControl("type","select")}componentDidLoad(){this.attributeObserver=new v(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(b)}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}componentWillLoad(){this.validateSize(this.size);this.markSelectedValue();this.optionsState=m(this.options);this.inheritedAttributes=u(this.host)}async componentDidRender(){this.passControlAttrs();this.f.passAttrToLabel("required",String(this.required));f((()=>this.markSelectedValue()))}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}markSelectedValue(){this.host.querySelectorAll("option").forEach((t=>{if(t.value===this.value){t.setAttribute("selected","selected")}else{t.removeAttribute("selected")}}))}render(){return i(e,{key:"784373d222b67be86b39d3ed61bfdf81d9648a36",class:h.root,size:this.size},this.h.hasSlot("prefix")&&i("slot",{key:"23b99e07df8d0d135c93bdd8c14556de4b4a5433",name:"prefix"}),i("span",{key:"f4c931f58a53db5cc2f8379b2dc6b688bbe84bc8",class:"element"},i("select",Object.assign({key:"e259f55116a12a7b821fac43db61b9ed35457c17",id:this.identifier||this.selectId,onFocus:this.onFocusHandler.bind(this),onChange:this.onChangeHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,name:this.name,disabled:this.disabled,ref:t=>this.selectRef=t},this.inheritedAttributes,{"aria-disabled":d(this.disabled),"aria-required":d(this.required),"aria-invalid":d(this.invalid)}),i("slot",{key:"223133e692d0c7a4c2c9c4706aee2d447f37c37b"}),Array.isArray(this.optionsState)&&this.optionsState.map((t=>{var s;return i("option",{value:t.value,selected:t.value===this.value,disabled:t===null||t===void 0?void 0:t.disabled},(s=t.label)!==null&&s!==void 0?s:t.value)}))),this.success&&i("gov-icon",{key:"97ceacc7ec59f13a9d994dc6df3b58201b5f68ae",class:"validation-icon",name:"check-lg",type:"components"}),this.invalid&&i("gov-icon",{key:"bd9f33ef6da150e5a3f4a5711d41282fe35df49f",class:"validation-icon",name:"exclamation-lg",type:"components"}),i("gov-icon",{key:"c5ca08441cb8f425a4e310e402d6f208c8a75e15",class:"arrow-icon",name:"chevron-down",type:"components"})),this.h.hasSlot("sufix")&&i("slot",{key:"af16a1bd05ed5d665888cea9a811eee2c0fe5749",name:"sufix"}))}onFocusHandler(t){this.focused=true;this.govFocus.emit({component:h.root,originalEvent:t,value:this.value})}onBlurHandler(t){this.focused=false;this.govBlur.emit({component:h.root,originalEvent:t,value:this.value})}onChangeHandler(t){this.value=t.target.value;t.stopPropagation();this.govChange.emit({component:h.root,originalEvent:t,value:this.value})}async setFocus(t){return this.selectRef.focus(t)}async getRef(){return this.selectRef}get host(){return a(this)}static get watchers(){return{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}}};export{g as gov_form_select};
//# sourceMappingURL=p-b93548cc.entry.js.map