import{p as t,H as e,c as i,h as s,a}from"./index.js";import{v as o}from"./p-BKP-F1qP.js";import{B as n,a as r,b as c,N as h}from"./p-CNqoJU2V.js";import{g as l,c as d}from"./p-DKo9A5gq.js";import{S as f}from"./p-BcQO4NH2.js";import{a as p}from"./p-Nvj7WFs_.js";import{c as m}from"./p-DrPpH_9c.js";import{d as b}from"./p-CQvUntGY.js";import{A as u,a as v,i as y}from"./p-CXgom82_.js";import{d as g}from"./p-BJnSrRNH.js";function j(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 k;(function(t){t["A"]="a";t["BUTTON"]="button"})(k||(k={}));const C=t(class t extends e{constructor(){super();this.__registerHost();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(r,t,n.root)}validateType(t){o(c,t,n.root)}validateSize(t){o(f,t,n.root)}validateNativeType(t){o(h,t,n.root)}componentDidLoad(){this.attributeObserver=new u(this.host,((t,e)=>{this.onAriaAttributeChange(t,e)}));this.attributeObserver.startObserving(v)}onAriaAttributeChange(t,e){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:e})}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=y(this.host)}async componentDidRender(){if(m()){await b(500);await this.validateAccessibility()}}connectedCallback(){this.hydrated=true}render(){const t=this.href?k.A:k.BUTTON;const e=t===k.A?undefined:this.nativeType;return s(a,{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:e,tabindex:this.disabled?"-1":this.tab},this.inheritedAttributes,{"aria-disabled":d(this.disabled)}),j(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"}),j(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){p(this.triggerRef.getAttribute("aria-label"),this.triggerRef.getAttribute("aria-labelledby"),n.root,this.host)}}get host(){return this}static get watchers(){return{color:["validateColor"],type:["validateType"],size:["validateSize"],nativeType:["validateNativeType"]}}},[4,"gov-button",{color:[513],size:[513],type:[513],expanded:[516],expandedMobile:[516,"expanded-mobile"],name:[1],disabled:[516],nativeType:[1,"native-type"],href:[1],target:[1],download:[4],tab:[2],hreflang:[1],referrerpolicy:[1],rel:[1],loading:[1],focusable:[4],identifier:[1],inheritedAttributes:[32],setFocus:[64],getRef:[64],validateAccessibility:[64]},undefined,{color:["validateColor"],type:["validateType"],size:["validateSize"],nativeType:["validateNativeType"]}]);function T(){if(typeof customElements==="undefined"){return}const t=["gov-button","gov-icon"];t.forEach((t=>{switch(t){case"gov-button":if(!customElements.get(t)){customElements.define(t,C)}break;case"gov-icon":if(!customElements.get(t)){g()}break}}))}T();export{C as G,T as d};
//# sourceMappingURL=p-CWqMiVYH.js.map