import{AsYouType as t,isValidNumberForRegion as e}from"libphonenumber-js";import*as o from"@momentum-ui/icons/data/momentumUiIconsNames.json";import*as r from"@momentum-ui/utils/lib/getColorValue";import*as i from"country-codes-list";import*as a from"country-flags-svg";import*as s from"lit";import*as l from"lit/decorators.js";import*as n from"lit/directives/class-map.js";import*as p from"lit/directives/if-defined.js";import*as d from"lit/directives/repeat.js";import*as u from"lit/directives/style-map.js";import*as c from"mobx";var h,m,y={6709(t,e,o){o(2273);var r,i=o(9609),a=o(4084),s=o(526),l=o(457),n=o(2927),p=o(8899),d=o(4955),u=o(2577),c=o(8373),h=function(t,e,o,r){var i,a=arguments.length,s=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(s=(a<3?i(s):a>3?i(e,o,s):i(e,o))||s);return a>3&&s&&Object.defineProperty(e,o,s),s};!function(t){let e=class extends n.LitElement{constructor(){super(...arguments),this.codePlaceholder="+1",this.countryCallingCode="",this.showFlags=!1,this.pill=!1,this.disabled=!1,this.ariaLabel="",this.clearAriaLabel="Clear Country Code",this.id="",this.newMomentum=!1,this.isDropdownArrow=!0,this.countryCode="US",this.codeList=[]}connectedCallback(){super.connectedCallback(),this.codeList=(0,s.customArray)({name:"{countryNameEn}",value:"{countryCallingCode}",code:"{countryCode}"}),""===this.id&&(this.id=`md-country-code-picker-${Math.random().toString(36).substring(2,6)}`)}getCountryFlag(t){return n.html`
        <span class="flag-svg-wrapper">
          <img src="${(0,l.findFlagUrlByIso2Code)(t)}" />
        </span>
      `}countryCodeOptionTemplate(t,e){return n.html`
        <div
          part="option"
          class="md-country-code-picker__option"
          display-value="+${t.value}"
          slot=${e}
          aria-label="+${t.value}, ${t.name}, ${t.code}"
        >
          ${this.showFlags?this.getCountryFlag(t.code):n.nothing}
          <span>${t.name}</span>
          <span>+${t.value}</span>
        </div>
      `}handleCountryChange(t){var e,o;t.detail.value&&(null===(e=t.detail.value)||void 0===e?void 0:e.id)?(this.countryCallingCode=t.detail.value.id,this.countryCode=null===(o=t.detail.value.id.split(",")[2])||void 0===o?void 0:o.trim()):(this.countryCode="US",this.countryCallingCode=""),this.dispatchEvent(new CustomEvent("country-code-changed",{bubbles:!0,composed:!0,detail:{srcEvent:t}}))}get flagClassMap(){return{"new-momentum":this.newMomentum}}get containerClassMap(){return{"md-country-code-picker__container":!0,"show-flags":this.showFlags}}getFormatedCountryCallingCode(){var t;return{id:this.countryCallingCode,value:null===(t=this.countryCallingCode.split(",")[0])||void 0===t?void 0:t.trim()}}static get styles(){return[a.A,c.A]}get sortedCodeList(){return[...this.codeList].sort((t,e)=>t.name.localeCompare(e.name))}render(){return n.html`
        <div class="${(0,d.classMap)(this.containerClassMap)}">
          ${this.showFlags?n.html`
                <span class="flag-box ${(0,d.classMap)(this.flagClassMap)}">${this.getCountryFlag(this.countryCode)}</span>
              `:n.nothing}
          <md-combobox
            part="combobox"
            exportparts="group: combobox-group, combobox-options: options-container"
            ?disabled=${this.disabled}
            shape="${this.pill?"pill":"none"}"
            ariaLabel=${this.ariaLabel}
            placeholder="${this.codePlaceholder}"
            .value="${this.countryCallingCode?[this.getFormatedCountryCallingCode()]:[]}"
            @change-selected=${t=>this.handleCountryChange(t)}
            with-custom-content
            ?newMomentum=${this.newMomentum}
            ?is-dropdown-arrow=${this.isDropdownArrow}
            .clearAriaLabel="${this.clearAriaLabel}"
          >
            ${(0,u.repeat)(this.sortedCodeList,t=>t.name,(t,e)=>this.countryCodeOptionTemplate(t,e))}
          </md-combobox>
        </div>
      `}};h([(0,p.property)({type:String,reflect:!0})],e.prototype,"codePlaceholder",void 0),h([(0,p.property)({type:String,attribute:"country-calling-code"})],e.prototype,"countryCallingCode",void 0),h([(0,p.property)({type:Boolean,attribute:"show-flags"})],e.prototype,"showFlags",void 0),h([(0,p.property)({type:Boolean})],e.prototype,"pill",void 0),h([(0,p.property)({type:Boolean})],e.prototype,"disabled",void 0),h([(0,p.property)({type:String})],e.prototype,"ariaLabel",void 0),h([(0,p.property)({type:String})],e.prototype,"clearAriaLabel",void 0),h([(0,p.property)({type:String})],e.prototype,"id",void 0),h([(0,p.property)({type:Boolean})],e.prototype,"newMomentum",void 0),h([(0,p.property)({type:Boolean})],e.prototype,"isDropdownArrow",void 0),h([(0,p.state)()],e.prototype,"countryCode",void 0),h([(0,p.state)()],e.prototype,"codeList",void 0),h([(0,p.query)("md-combobox")],e.prototype,"combobox",void 0),e=h([(0,i.w)("md-country-code-picker")],e),t.ELEMENT=e}(r||(r={}))},2455(o,r,i){i.d(r,{L:()=>a}),i(2273),i(6709),i(9189);var a,s=i(9609),l=i(2927),n=i(8899),p=i(4955),d=i(6429),u=function(t,e,o,r){var i,a=arguments.length,s=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(s=(a<3?i(s):a>3?i(e,o,s):i(e,o))||s);return a>3&&s&&Object.defineProperty(e,o,s),s};!function(o){let r=class extends l.LitElement{constructor(){super(...arguments),this.codePlaceholder="+1",this.numberPlaceholder="Enter Phone Number",this.countryCallingCode="",this.showFlags=!1,this.pill=!1,this.disabled=!1,this.value="",this.errorMessage="",this.showErrorMessage=!1,this.countryCodeAriaLabel="",this.dialNumberAriaLabel="",this.clearAriaLabel="Clear Input",this.clearCountryCodeAriaLabel="Clear Country Code",this.id="",this.newMomentum=!1,this.countryCode="US",this.formattedValue="",this.isValid=!0}get isRtl(){try{if(!this.isConnected)return!1;const t=getComputedStyle(this);return"rtl"===(null==t?void 0:t.direction)}catch(t){return!1}}connectedCallback(){super.connectedCallback(),""===this.id&&(this.id=`md-phone-input-${Math.random().toString(36).substring(2,6)}`),this.validateInput(this.value)}validateNumber(){this.isValid=!this.value||e(this.value,this.countryCode)}handleCountryChange(t){var e,o;const r=t.detail.srcEvent;r.detail.value&&(null===(e=r.detail.value)||void 0===e?void 0:e.id)?(this.countryCallingCode=r.detail.value.id,this.countryCode=null===(o=r.detail.value.id.split(",")[2])||void 0===o?void 0:o.trim()):(this.countryCode="US",this.countryCallingCode=""),this.validateNumber(),this.dispatchEvent(new CustomEvent("countrycode-change",{bubbles:!0,composed:!0,detail:{srcEvent:r,isValid:this.isValid}}))}handlePhoneChange(t){this.value=t.detail.value,t.stopPropagation(),this.dispatchEvent(new CustomEvent("phoneinput-change",{bubbles:!0,composed:!0,detail:{srcEvent:t,value:`${this.countryCallingCode}${this.value}`,isValid:this.isValid,phoneNumber:this.value}}))}handleKeydown(t){this.isValid=!0,t.stopPropagation(),this.dispatchEvent(new CustomEvent("phoneinput-keydown",{bubbles:!0,composed:!0,detail:{srcEvent:t,value:`${this.countryCallingCode}${this.value}`,isValid:this.isValid,phoneNumber:this.value}}))}handleBlur(t){this.validateInput(this.value),this.validateNumber(),t.stopPropagation(),this.removeCountryCode(),this.dispatchEvent(new CustomEvent("phoneinput-blur",{bubbles:!0,composed:!0,detail:{srcEvent:t,value:`${this.countryCallingCode}${this.value}`,isValid:this.isValid,phoneNumber:this.value}}))}removeCountryCode(){var t;const e=null===(t=this.countryCallingCode.split(",")[0])||void 0===t?void 0:t.trim();if(this.value.startsWith(e)){const t=this.value.slice(e.length).replace(/^-/,"");this.value=t}}validateInput(e){this.formattedValue=new t(this.countryCode).input(e)}get flagClassMap(){return{"new-momentum":this.newMomentum}}get containerClassMap(){return{"md-phone-input__container":!0,rtl:this.isRtl}}static get styles(){return[d.A]}render(){return l.html`
        <div class=${(0,p.classMap)(this.containerClassMap)}>
          <md-country-code-picker
            part="md-country-code-picker"
            exportparts="option: option"
            ?disabled=${this.disabled}
            ?pill=${this.pill}
            ?show-flags=${this.showFlags}
            ariaLabel=${this.countryCodeAriaLabel}
            codePlaceholder="${this.codePlaceholder}"
            .countryCallingCode="${this.countryCallingCode}"
            @country-code-changed=${t=>this.handleCountryChange(t)}
            ?newMomentum=${this.newMomentum}
            ?isDropdownArrow=${!0}
            .clearAriaLabel="${this.clearCountryCodeAriaLabel}"
          ></md-country-code-picker>

          <md-input
            part="md-input"
            ?disabled=${this.disabled}
            placeholder=${this.numberPlaceholder}
            .ariaInvalid=${this.isValid?"false":"true"}
            .ariaLabel=${`${this.dialNumberAriaLabel}`}
            @input-change=${t=>this.handlePhoneChange(t)}
            @input-blur=${t=>this.handleBlur(t)}
            @input-keydown=${t=>this.handleKeydown(t)}
            shape="${this.pill?"pill":"none"}"
            .ariaControls=${this.id}
            clear
            ?newMomentum=${this.newMomentum}
            clearAriaLabel="${this.clearAriaLabel}"
            type="tel"
            value="${this.formattedValue}"
            .messageArr="${!this.isValid||this.showErrorMessage?[{type:"error",id:this.id,ariaLive:"polite",message:this.errorMessage}]:[]}"
          ></md-input>
        </div>
      `}};u([(0,n.property)({type:String,reflect:!0})],r.prototype,"codePlaceholder",void 0),u([(0,n.property)({type:String})],r.prototype,"numberPlaceholder",void 0),u([(0,n.property)({type:String,attribute:"country-calling-code"})],r.prototype,"countryCallingCode",void 0),u([(0,n.property)({type:Boolean,attribute:"show-flags"})],r.prototype,"showFlags",void 0),u([(0,n.property)({type:Boolean})],r.prototype,"pill",void 0),u([(0,n.property)({type:Boolean})],r.prototype,"disabled",void 0),u([(0,n.property)({type:String})],r.prototype,"value",void 0),u([(0,n.property)({type:String})],r.prototype,"errorMessage",void 0),u([(0,n.property)({type:Boolean})],r.prototype,"showErrorMessage",void 0),u([(0,n.property)({type:String})],r.prototype,"countryCodeAriaLabel",void 0),u([(0,n.property)({type:String})],r.prototype,"dialNumberAriaLabel",void 0),u([(0,n.property)({type:String})],r.prototype,"clearAriaLabel",void 0),u([(0,n.property)({type:String})],r.prototype,"clearCountryCodeAriaLabel",void 0),u([(0,n.property)({type:String})],r.prototype,"id",void 0),u([(0,n.property)({type:Boolean})],r.prototype,"newMomentum",void 0),u([(0,n.state)()],r.prototype,"countryCode",void 0),u([(0,n.state)()],r.prototype,"formattedValue",void 0),u([(0,n.state)()],r.prototype,"isValid",void 0),r=u([(0,s.w)("md-phone-input")],r),o.ELEMENT=r}(a||(a={}))},9500(t,e,r){var i,a;t.exports=(i={default:()=>o.default},a={},r.d(a,i),a)},3496(t,e,o){var i,a;t.exports=(i={default:()=>r.default},a={},o.d(a,i),a)},526(t,e,o){var r,a;t.exports=(r={customArray:()=>i.customArray},a={},o.d(a,r),a)},457(t,e,o){var r,i;t.exports=(r={findFlagUrlByIso2Code:()=>a.findFlagUrlByIso2Code},i={},o.d(i,r),i)},2927(t,e,o){var r,i;t.exports=(r={LitElement:()=>s.LitElement,css:()=>s.css,html:()=>s.html,nothing:()=>s.nothing},i={},o.d(i,r),i)},8899(t,e,o){var r,i;t.exports=(r={property:()=>l.property,query:()=>l.query,queryAll:()=>l.queryAll,state:()=>l.state},i={},o.d(i,r),i)},4955(t,e,o){var r,i;t.exports=(r={classMap:()=>n.classMap},i={},o.d(i,r),i)},3517(t,e,o){var r,i;t.exports=(r={ifDefined:()=>p.ifDefined},i={},o.d(i,r),i)},2577(t,e,o){var r,i;t.exports=(r={repeat:()=>d.repeat},i={},o.d(i,r),i)},1156(t,e,o){var r,i;t.exports=(r={styleMap:()=>u.styleMap},i={},o.d(i,r),i)},4980(t,e,o){var r,i;t.exports=(r={action:()=>c.action,observable:()=>c.observable},i={},o.d(i,r),i)}},v={};function C(t){var e=v[t];if(void 0!==e)return e.exports;var o=v[t]={exports:{}};return y[t].call(o.exports,o,o.exports,C),o.exports}C.m=y,h=[],C.O=(t,e,o,r)=>{if(!e){var i=1/0;for(n=0;n<h.length;n++){for(var[e,o,r]=h[n],a=!0,s=0;s<e.length;s++)(!1&r||i>=r)&&Object.keys(C.O).every(t=>C.O[t](e[s]))?e.splice(s--,1):(a=!1,r<i&&(i=r));if(a){h.splice(n--,1);var l=o();void 0!==l&&(t=l)}}return t}r=r||0;for(var n=h.length;n>0&&h[n-1][2]>r;n--)h[n]=h[n-1];h[n]=[e,o,r]},C.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return C.d(e,{a:e}),e},C.d=(t,e)=>{for(var o in e)C.o(e,o)&&!C.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},C.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),C.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{C as __webpack_require__};m={445:0,502:0,1745:0,2169:0,4545:0,4928:0,5369:0,6060:0,6709:0,6753:0,6920:0,8111:0,8442:0},C.C=t=>{var e,o,{__webpack_esm_ids__:r,__webpack_esm_modules__:i,__webpack_esm_runtime__:a}=t,s=0;for(e in i)C.o(i,e)&&(C.m[e]=i[e]);for(a&&a(C);s<r.length;s++)o=r[s],C.o(m,o)&&m[o]&&m[o][0](),m[r[s]]=0;C.O()},C.O.j=t=>0===m[t];import*as g from"../7103.js";C.C(g);import*as b from"../9609.js";C.C(b);import*as f from"../4084.js";C.C(f);import*as w from"../3305.js";C.C(w);import*as $ from"../4739.js";C.C($);import*as j from"../7154.js";C.C(j);import*as L from"../9773.js";C.C(L);import*as M from"../5983.js";C.C(M);import*as A from"../9488.js";C.C(A);import*as x from"../1821.js";C.C(x);import*as E from"../2364.js";C.C(E);import*as _ from"../9938.js";C.C(_);import*as P from"../4781.js";C.C(P);import*as S from"../5201.js";C.C(S);import*as V from"../5584.js";C.C(V);import*as O from"../8227.js";C.C(O);import*as F from"../7704.js";C.C(F);import*as k from"../2797.js";C.C(k);import*as B from"../3970.js";C.C(B);import*as N from"../7906.js";C.C(N);import*as I from"../9336.js";C.C(I);import*as R from"../2369.js";C.C(R);import*as D from"../9189.js";C.C(D);import*as U from"../4047.js";C.C(U);import*as T from"../4431.js";C.C(T);import*as q from"../8138.js";C.C(q);import*as K from"../4654.js";C.C(K);import*as W from"../8373.js";C.C(W);import*as Y from"../6429.js";C.C(Y);var z=C.O(void 0,[7103,9609,4084,3305,4739,7154,9773,5983,9488,1821,2364,9938,4781,5201,5584,8227,7704,2797,3970,7906,9336,2369,9189,4047,4431,8138,4654,8373,6429],()=>C(2455));const G=(z=C.O(z)).L;export{G as PhoneInput};