const t={};function e(s,n){"string"!=typeof n&&(n=e.defaultChars);const o=function(e){let s=t[e];if(s)return s;s=t[e]=[];for(let t=0;t<128;t++){const e=String.fromCharCode(t);s.push(e)}for(let t=0;t=55296&&t<=57343?"���":String.fromCharCode(t),s+=6;continue}}if(240==(248&h)&&s+91114111?e+="����":(t-=65536,e+=String.fromCharCode(55296+(t>>10),56320+(1023&t))),s+=9;continue}}e+="�"}}return e})}e.defaultChars=";/?:@&=+$,#",e.componentChars="";const s={};function n(t,e,o){"string"!=typeof e&&(o=e,e=n.defaultChars),void 0===o&&(o=!0);const h=function(t){let e=s[t];if(e)return e;e=s[t]=[];for(let s=0;s<128;s++){const t=String.fromCharCode(s);/^[0-9a-z]$/i.test(t)?e.push(t):e.push("%"+("0"+s.toString(16).toUpperCase()).slice(-2))}for(let s=0;s=55296&&e<=57343){if(e>=55296&&e<=56319&&s+1=56320&&e<=57343){i+=encodeURIComponent(t[s]+t[s+1]),s++;continue}}i+="%EF%BF%BD"}else i+=encodeURIComponent(t[s])}return i}function o(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&-1!==t.hostname.indexOf(":")?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function h(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}n.defaultChars=";/?:@&=+$,-_.!~*'()#",n.componentChars="-_.!~*'()";const i=/^([a-z0-9.+-]+:)/i,r=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(l),f=["%","/","?",";","#"].concat(c),p=["/","?","#"],u=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},d={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function C(t,e){if(t&&t instanceof h)return t;const s=new h;return s.parse(t,e),s}h.prototype.parse=function(t,e){let s,n,o,h=t;if(h=h.trim(),!e&&1===t.split("#").length){const t=a.exec(h);if(t)return this.pathname=t[1],t[2]&&(this.search=t[2]),this}let r=i.exec(h);if(r&&(r=r[0],s=r.toLowerCase(),this.protocol=r,h=h.substr(r.length)),(e||r||h.match(/^\/\/[^@\/]+@[^@\/]+/))&&(o="//"===h.substr(0,2),!o||r&&g[r]||(h=h.substr(2),this.slashes=!0)),!g[r]&&(o||r&&!d[r])){let t,e,s=-1;for(let r=0;r127?n+="x":n+=s[t];if(!n.match(u)){const n=t.slice(0,e),o=t.slice(e+1),i=s.match(m);i&&(n.push(i[1]),o.unshift(i[2])),o.length&&(h=o.join(".")+h),this.hostname=n.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),i&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const l=h.indexOf("#");-1!==l&&(this.hash=h.substr(l),h=h.slice(0,l));const c=h.indexOf("?");return-1!==c&&(this.search=h.substr(c),h=h.slice(0,c)),h&&(this.pathname=h),d[s]&&this.hostname&&!this.pathname&&(this.pathname=""),this},h.prototype.parseHost=function(t){let e=r.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};const b=Object.freeze(Object.defineProperty({__proto__:null,decode:e,encode:n,format:o,parse:C},Symbol.toStringTag,{value:"Module"}));export{e as d,n as e,o as f,b as m,C as u};