typeofb)for(varginb)Object.prototype.hasOwnProperty.call(b,g)&&d.addQuery(a,g,b[g]);elseif("string"===typeofb)a[b]===e?a[b]=c:("string"===typeofa[b]&&(a[b]=[a[b]]),j(c)||(c=[c]),a[b]=a[b].concat(c));elsethrownewTypeError("URI.addQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,b,c){if(j(b))for(varc=0,g=b.length;c<g;c++)a[b[c]]=e;elseif("object"===typeofb)for(ginb)Object.prototype.hasOwnProperty.call(b,g)&&d.removeQuery(a,g,b[g]);elseif("string"===
typeofb)if(c!==e)if(a[b]===c)a[b]=e;else{if(j(a[b])){varg=a[b],f={},h,i;if(j(c)){h=0;for(i=c.length;h<i;h++)f[c[h]]=!0}elsef[c]=!0;h=0;for(i=g.length;h<i;h++)f[g[h]]!==e&&(g.splice(h,1),i--,h--);a[b]=g}}elsea[b]=e;elsethrownewTypeError("URI.addQuery() accepts an object, string as the first parameter");};d.commonPath=function(a,b){varc=Math.min(a.length,b.length),d;for(d=0;d<c;d++)if(a[d]!==b[d]){d--;break}if(1>d)returna[0]===b[0]&&"/"===a[0]?"/":"";"/"!==a[d]&&(d=a.substring(0,d).lastIndexOf("/"));
returna.substring(0,d+1)};d.withinString=function(a,b){returna.replace(d.find_uri_expression,b)};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!l)thrownewTypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(l.toASCII(a).match(d.invalid_hostname_characters))thrownewTypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-]");}};f.build=function(a){if(!0===a)this._deferred_build=!0;elseif(a===
case"ip":returnb;case"ip4":case"ipv4":case"inet4":returnc;case"ip6":case"ipv6":case"inet6":returng;case"idn":returnh;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":returni}returnnull};varz=f.protocol,v=f.port,s=f.hostname;f.protocol=function(a,b){if(a!==e&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))thrownewTypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]");returnz.call(this,a,b)};f.scheme=f.protocol;f.port=
function(a,b){if(this._parts.urn)returna===e?"":this;if(a!==e&&(0===a&&(a=null),a&&(a+="",":"===a[0]&&(a=a.substring(1)),a.match(/[^0-9]/))))thrownewTypeError("Port '"+a+"' contains characters other than [0-9]");returnv.call(this,a,b)};f.hostname=function(a,b){if(this._parts.urn)returna===e?"":this;if(a!==e){varc={};d.parseHost(a,c);a=c.hostname}returns.call(this,a,b)};f.host=function(a,b){if(this._parts.urn)returna===e?"":this;if(a===e)returnthis._parts.hostname?d.buildHost(this._parts):
e?"":this;"boolean"==typeofa&&(b=a,a=e);if(a===e){if(!this._parts.hostname||this.is("IP"))return"";varc=this._parts.hostname.match(/\./g);if(c&&2>c.length)returnthis._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;returnthis._parts.hostname.substring(c)||""}if(!a)thrownewTypeError("cannot set domain empty");d.ensureValidHostname(a);this._parts.hostname=!this._parts.hostname||this.is("IP")?a:this._parts.hostname.replace(RegExp(h(this.domain())+
a+"' contains characters other than [A-Z0-9]");else{if(!this._parts.hostname||this.is("IP"))thrownewReferenceError("cannot set TLD on non-domain host");c=RegExp(h(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}elsethrownewTypeError("cannot set TLD empty");this.build(!b);returnthis};f.directory=function(a,b){if(this._parts.urn)returna===e?"":this;if(a===e||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";varc=this._parts.path.substring(0,
a.hash()};f.absoluteTo=function(a){varb=this.clone(),c=["protocol","username","password","hostname","port"];if(this._parts.urn)throwError("URNs do not have any generally defined hierachical components");if(this._parts.hostname)returnb;ainstanceofd||(a=newd(a));for(vare=0,f;f=c[e];e++)b._parts[f]=a._parts[f];"/"!==b.path()[0]&&(a=a.directory(),b._parts.path=(a?a+"/":"")+b._parts.path,b.normalizePath());b.build();returnb};f.relativeTo=function(a){varb=this.clone(),c=["protocol","username",
"password","hostname","port"],e;if(this._parts.urn)throwError("URNs do not have any generally defined hierachical components");ainstanceofd||(a=newd(a));if("/"!==this.path()[0]||"/"!==a.path()[0])throwError("Cannot calculate common path from non-relative URLs");e=d.commonPath(b.path(),a.path());for(vara=a.directory(),f=0,i;i=c[f];f++)b._parts[i]=null;if(!e||"/"===e)returnb;if(a+"/"===e)b._parts.path="./"+b.filename();else{c="../";e=RegExp("^"+h(e));for(a=a.replace(e,"/").match(/\//g).length-