import{proxyCustomElement,HTMLElement,createEvent,h,Host,Fragment}from"@stencil/core/internal/client";import{i as isMessageSet}from"./utils.js";import{n as normalizeArguments,a as parsePhoneNumber$2,w as withMetadataArgument}from"./parsePhoneNumber_.js";function parsePhoneNumber$1(){var t=normalizeArguments(arguments),e=t.text,n=t.options,o=t.metadata;return parsePhoneNumber$2(e,n,o)}function parsePhoneNumber(){return withMetadataArgument(parsePhoneNumber$1,arguments)}const vaTelephoneCss="button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role='option']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px}a{text-decoration:none;color:var(--vads-color-link);-webkit-transition-duration:0.3s;transition-duration:0.3s;-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-property:color, background-color, border-color;transition-property:color, background-color, border-color}a:hover{background-color:rgba(0, 0, 0, 0.05);color:inherit}a:visited{color:var(--vads-color-link-visited)}.sr-only{border:0;clip:rect(0, 0, 0, 0);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute !important;width:1px;word-wrap:normal !important}:host{font-size:1.06rem}a{white-space:nowrap}a,a:hover{text-decoration:underline}",VaTelephoneStyle0=vaTelephoneCss,VaTelephone=proxyCustomElement(class t extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.componentLibraryAnalytics=createEvent(this,"component-library-analytics",7),this.contact=void 0,this.extension=void 0,this.notClickable=!1,this.international=!1,this.countryCode=void 0,this.tty=!1,this.sms=!1,this.vanity=void 0,this.messageAriaDescribedby=void 0,this.disableAnalytics=!1}static cleanContact(t){return(t||"").replace(/[^\d]/g,"")}static splitContact(e){const n=t.cleanContact(e);if(10===n.length){const t=[.../^(\d{3})(\d{3})(\d{4})$/g.exec(n)];return 4===t.length?t.slice(-3):[n]}return[n]}static formatPhoneNumber({contact:e,extension:n,international:o=!1,countryCode:i,vanity:a,tty:s=!1}){const r=i?[e]:t.splitContact(e);let c=r.join("");if(10===c.length&&!i){const[t,e,i]=r;c=`${t}-${e}-${i}`,o&&(c=`+1-${c}`),n&&(c=`${c}, ext. ${n}`),a&&(c=4===a.length?`${t}-${e}-${a} (${i})`:`${a} (${c})`)}if(i){let t=null;try{t=parsePhoneNumber(`+${i}${c}`)}catch(t){console.error("Error parsing phone number:",t)}t&&n&&t.setExt(n),c=t?t.formatInternational():c.startsWith("+")?`${c}`:`+${i} ${c}`}return s&&(c=`TTY: ${c}`),c}static createHref({contact:e,extension:n,sms:o,countryCode:i}){const a=t.cleanContact(e),s=3===a.length;let r=null;return r=o?`sms:${a}`:s?`tel:${a}`:i?`tel:+${i}${a}`:`tel:+1${a}`,`${r}${n?`,${n}`:""}`}handleClick(){this.disableAnalytics||this.componentLibraryAnalytics.emit({componentName:"va-telephone",action:"click",details:{contact:this.contact,extension:this.extension}})}render(){const{contact:e,extension:n,notClickable:o,international:i,countryCode:a,tty:s,vanity:r,sms:c,messageAriaDescribedby:l}=this,d=t.formatPhoneNumber({contact:e,extension:n,international:i,countryCode:a,vanity:r,tty:s}),u=t.createHref({contact:e,extension:n,sms:c,countryCode:a}),m=isMessageSet(l),p=m?"number-description":null;return h(Host,{key:"a0dede4b4296f8f62a90040da7bbc3cce9082dd7"},o?h(Fragment,null,h("span",{"aria-describedby":p},d)):h("a",{"aria-describedby":p,href:u,onClick:this.handleClick.bind(this)},d),m&&h("span",{key:"fad2ea8811cb4ddd3af535ede772e09f084fc530",id:"number-description",class:"sr-only"},l))}static get style(){return VaTelephoneStyle0}},[1,"va-telephone",{contact:[1],extension:[1],notClickable:[4,"not-clickable"],international:[4],countryCode:[1,"country-code"],tty:[4],sms:[4],vanity:[1],messageAriaDescribedby:[1,"message-aria-describedby"],disableAnalytics:[4,"disable-analytics"]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["va-telephone"].forEach(t=>{"va-telephone"===t&&(customElements.get(t)||customElements.define(t,VaTelephone))})}export{VaTelephone as V,defineCustomElement as d};