import{r as t,c as i,h as s,H as e,g as a}from"./p-ClISz4NF.js";import{v as o}from"./p-NOJjz9dT.js";import{b as n,B as h,c as r,N as c}from"./p-Bo1ROm5Q.js";import{g as l,t as d}from"./p-CoD1xawt.js";import{S as p}from"./p-BcQO4NH2.js";import{v as f}from"./p-CDIRBJsi.js";import{c as m}from"./p-CgDnDrq5.js";import{d as b}from"./p-CQvUntGY.js";import{i as v}from"./p-CzXeijOj.js";import{A as u,a as y}from"./p-Bz_RzYFb.js";import"./p-U40vKHrs.js";import"./p-vN03FcXN.js";import"./p-DNztiAH0.js";function g(t){if(typeof t==="string"){return["true","True","TRUE","1"].indexOf(t)!==-1}else if(typeof t==="number"){return t>0}else if(typeof t==="boolean"){return t}else{return t?true:false}}var j;(function(t){t["A"]="a";t["BUTTON"]="button"})(j||(j={}));const C=class{constructor(s){t(this,s);this.govClick=i(this,"gov-click");this.govFocus=i(this,"gov-focus");this.govBlur=i(this,"gov-blur");this.hydrated=false;this.size="m";this.expanded=false;this.expandedMobile=false;this.disabled=false;this.nativeType="button";this.tab=0;this.focusable=true;this.inheritedAttributes={};this.h=l(this.host)}validateColor(t){o(h,t,n.root)}validateType(t){o(r,t,n.root)}validateSize(t){o(p,t,n.root)}validateNativeType(t){o(c,t,n.root)}componentDidLoad(){this.attributeObserver=new u(this.host,((t,i)=>{this.onAriaAttributeChange(t,i)}));this.attributeObserver.startObserving(y)}onAriaAttributeChange(t,i){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:i})}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}componentWillLoad(){this.validateColor(this.color);this.validateType(this.type);this.validateSize(this.size);this.validateNativeType(this.nativeType);this.inheritedAttributes=v(this.host)}async componentDidRender(){if(m()){await b(500);await this.validateAccessibility()}}connectedCallback(){this.hydrated=true}render(){const t=this.href?j.A:j.BUTTON;const i=t===j.A?undefined:this.nativeType;return s(e,{key:"0d010913c0331fcb11918152cb9bb2598923c5eb",size:this.size,hydrated:this.hydrated,color:this.color,class:this.h.classes(n.root),type:this.type},s(t,Object.assign({key:"d413645e924857fb5451c8e03c986013d85ddc06",class:"element",ref:t=>this.triggerRef=t,onClick:this.onClickHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),disabled:this.disabled,id:this.identifier,href:this.href,target:this.target,download:this.download,hreflang:this.hreflang,rel:this.rel,name:this.name,type:i,tabindex:this.disabled?"-1":this.tab},this.inheritedAttributes,{"aria-disabled":d(this.disabled)}),g(this.loading)&&!this.h.hasSlot("icon-end")&&s("gov-icon",{key:"13528203c29059fe167ca9b6f1f9134415517d47",name:"loader",class:"gov-spin-animation",type:"components"}),this.h.hasSlot("icon-start")&&s("slot",{key:"304d82f1e7136a3f11ab44ce5e5b3166c2be2976",name:"icon-start"}),s("slot",{key:"6bc84a79e2acc72405c7b6831951d4984e5a6092"}),this.h.hasSlot("icon-end")&&s("slot",{key:"044971729141feb76253c649de01db88e9459ccf",name:"icon-end"}),g(this.loading)&&this.h.hasSlot("icon-end")&&s("gov-icon",{key:"b55541b4d8ec377ec0aa9c80596b212306a5c02a",name:"loader",class:"gov-spin-animation",type:"components"})))}onClickHandler(t){t.stopPropagation();if(this.disabled===false){this.govClick.emit({component:n.root,originalEvent:t,ref:this.host})}}onFocusHandler(t){t.stopPropagation();this.govFocus.emit({component:n.root,originalEvent:t,ref:this.host})}onBlurHandler(t){t.stopPropagation();this.govBlur.emit({component:n.root,originalEvent:t,ref:this.host})}async setFocus(){this.triggerRef.focus()}async getRef(){return this.triggerRef}async validateAccessibility(){if(this.focusable){f(this.triggerRef.getAttribute("aria-label"),this.triggerRef.getAttribute("aria-labelledby"),n.root,this.host)}}get host(){return a(this)}static get watchers(){return{color:["validateColor"],type:["validateType"],size:["validateSize"],nativeType:["validateNativeType"]}}};export{C as gov_button};
//# sourceMappingURL=p-f58a20af.entry.js.map