const E=/^xn--/,j=/[^\0-\x7F]/,k=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=35,u=Math.floor,C=String.fromCharCode;function p(o){throw new RangeError(O[o])}function L(o,n){const r=[];let e=o.length;for(;e--;)r[e]=n(o[e]);return r}function A(o,n){const r=o.split("@");let e="";r.length>1&&(e=r[0]+"@",o=r[1]),o=o.replace(k,".");const t=o.split("."),c=L(t,n).join(".");return e+c}function F(o){const n=[];let r=0;const e=o.length;for(;r<e;){const t=o.charCodeAt(r++);if(t>=55296&&t<=56319&&r<e){const c=o.charCodeAt(r++);(c&64512)==56320?n.push(((t&1023)<<10)+(c&1023)+65536):(n.push(t),r--)}else n.push(t)}return n}const M=o=>String.fromCodePoint(...o),P=function(o){return o>=48&&o<58?26+(o-48):o>=65&&o<91?o-65:o>=97&&o<123?o-97:36},b=function(o,n){return o+22+75*(o<26)-((n!=0)<<5)},I=function(o,n,r){let e=0;for(o=r?u(o/700):o>>1,o+=u(o/n);o>w*26>>1;e+=36)o=u(o/w);return u(e+(w+1)*o/(o+38))},S=function(o){const n=[],r=o.length;let e=0,t=128,c=72,l=o.lastIndexOf("-");l<0&&(l=0);for(let s=0;s<l;++s)o.charCodeAt(s)>=128&&p("not-basic"),n.push(o.charCodeAt(s));for(let s=l>0?l+1:0;s<r;){const i=e;for(let f=1,a=36;;a+=36){s>=r&&p("invalid-input");const h=P(o.charCodeAt(s++));h>=36&&p("invalid-input"),h>u((2147483647-e)/f)&&p("overflow"),e+=h*f;const g=a<=c?1:a>=c+26?26:a-c;if(h<g)break;const v=36-g;f>u(2147483647/v)&&p("overflow"),f*=v}const d=n.length+1;c=I(e-i,d,i==0),u(e/d)>2147483647-t&&p("overflow"),t+=u(e/d),e%=d,n.splice(e++,0,t)}return String.fromCodePoint(...n)},m=function(o){const n=[];o=F(o);const r=o.length;let e=128,t=0,c=72;for(const i of o)i<128&&n.push(C(i));const l=n.length;let s=l;for(l&&n.push("-");s<r;){let i=2147483647;for(const f of o)f>=e&&f<i&&(i=f);const d=s+1;i-e>u((2147483647-t)/d)&&p("overflow"),t+=(i-e)*d,e=i;for(const f of o)if(f<e&&++t>2147483647&&p("overflow"),f===e){let a=t;for(let h=36;;h+=36){const g=h<=c?1:h>=c+26?26:h-c;if(a<g)break;const v=a-g,x=36-g;n.push(C(b(g+v%x,0))),a=u(v/x)}n.push(C(b(a,0))),c=I(t,d,s===l),t=0,++s}++t,++e}return n.join("")},B=function(o){return A(o,function(n){return E.test(n)?S(n.slice(4).toLowerCase()):n})},D=function(o){return A(o,function(n){return j.test(n)?"xn--"+m(n):n})},N={version:"2.3.1",ucs2:{decode:F,encode:M},decode:S,encode:m,toASCII:D,toUnicode:B};export{N as O};
