import{proxyCustomElement,HTMLElement,createEvent,h,Host}from"@stencil/core/internal/client";import{c as classnames}from"./index2.js";import{d as defineCustomElement$3}from"./va-icon2.js";import{d as defineCustomElement$2}from"./va-link2.js";const vaLanguageToggleCss=":host{font-size:1rem}:host div{display:inline-block}:host div div.inner-div{border-right:1px solid var(--vads-color-base-light);padding-right:var(--units-1);margin-right:var(--units-1)}:host div a.is-current-lang{font-weight:var(--font-weight-bold);color:var(--vads-color-black);text-decoration:none;padding-top:var(--units-1p5);padding-bottom:var(--units-2)}:host div a.is-current-lang:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px}:host div va-link::part(anchor){text-decoration:none;padding-top:var(--units-1p5);padding-bottom:var(--units-2)}:host div va-link{color:var(--vads-color-link);padding-bottom:2px;border-bottom:1px solid var(--vads-color-link)}",VaLanguageToggleStyle0=vaLanguageToggleCss,VaLanguageToggle$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.vaLanguageToggle=createEvent(this,"vaLanguageToggle",7),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.language="en",this.enHref=void 0,this.esHref=void 0,this.tlHref=void 0,this.urls=void 0,this.routerLinks=!1}getUrl(e){const t=new URL(window.location.href);return t.searchParams.set("lang",e),t.href}handleToggle(e,t,a){this.routerLinks&&(e.preventDefault(),window.history.replaceState(null,null,this.getUrl(t)),this.language=t),this.vaLanguageToggle.emit({language:t});const n={componentName:"va-language-toggle",action:"linkClick",details:{"pipe-delimited-list-header":t,label:a}};this.componentLibraryAnalytics.emit(n)}componentWillLoad(){this.urls=[{label:"English",lang:"en",href:this.enHref}],this.esHref&&(this.urls=[...this.urls,{label:"Español",lang:"es",href:this.esHref}]),this.tlHref&&(this.urls=[...this.urls,{label:"Tagalog",lang:"tl",href:this.tlHref}])}render(){var e;const{language:t,urls:a}=this,n=(null===(e=a.find(e=>e.lang===t))||void 0===e?void 0:e.label)||"English";return h(Host,{key:"77005cba47593b08881ed80f9b5e346c720e1d17"},h("div",{key:"edd5300bfd308ad4cfb4005afa6cf92a1c9b2710",role:"group","aria-label":`Language selection ${n}`},a.map(({href:e,lang:n,label:l},s)=>{const o=classnames({"is-current-lang":n===t}),i=classnames({"inner-div":s<a.length-1});return h("div",{class:i},n===t?h("a",{class:o,href:e,hrefLang:n,onClick:e=>this.handleToggle(e,n,l),"aria-current":"true"},l):h("va-link",{class:o,href:e,language:n,onClick:e=>this.handleToggle(e,n,l),text:l,disableAnalytics:!0}))})))}static get style(){return VaLanguageToggleStyle0}},[1,"va-language-toggle",{language:[1025],enHref:[1,"en-href"],esHref:[1,"es-href"],tlHref:[1,"tl-href"],routerLinks:[4,"router-links"],urls:[32]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["va-language-toggle","va-icon","va-link"].forEach(e=>{switch(e){case"va-language-toggle":customElements.get(e)||customElements.define(e,VaLanguageToggle$1);break;case"va-icon":customElements.get(e)||defineCustomElement$3();break;case"va-link":customElements.get(e)||defineCustomElement$2()}})}const VaLanguageToggle=VaLanguageToggle$1,defineCustomElement=defineCustomElement$1;export{VaLanguageToggle,defineCustomElement};