c):"")};d.addQuery=function(a,b,c){if("object"===typeofb)for(varhinb)w.call(b,h)&&d.addQuery(a,h,b[h]);elseif("string"===typeofb)void0===a[b]?a[b]=c:("string"===typeofa[b]&&(a[b]=[a[b]]),l(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){varh;if(l(b))for(c=0,h=b.length;c<h;c++)a[b[c]]=void0;elseif("object"===typeofb)for(hinb)w.call(b,h)&&d.removeQuery(a,h,b[h]);elseif("string"===
typeofb)if(void0!==c)if(a[b]===c)a[b]=void0;else{if(l(a[b])){h=a[b];varp={},e,f;if(l(c))for(e=0,f=c.length;e<f;e++)p[c[e]]=!0;elsep[c]=!0;e=0;for(f=h.length;e<f;e++)void0!==p[h[e]]&&(h.splice(e,1),f--,e--);a[b]=h}}elsea[b]=void0;elsethrownewTypeError("URI.addQuery() accepts an object, string as the first parameter");};d.hasQuery=function(a,b,c,h){if("object"===typeofb){for(vareinb)if(w.call(b,e)&&!d.hasQuery(a,e,b[e]))return!1;return!0}if("string"!==typeofb)thrownewTypeError("URI.hasQuery() accepts an object, string as the name parameter");
switch(q(c)){case"Undefined":returnbina;case"Boolean":returna=Boolean(l(a[b])?a[b].length:a[b]),c===a;case"Function":return!!c(a[b],b,a);case"Array":returnl(a[b])?(h?r:z)(a[b],c):!1;case"RegExp":returnl(a[b])?h?r(a[b],c):!1:Boolean(a[b]&&a[b].match(c));case"Number":c=String(c);case"String":returnl(a[b])?h?r(a[b],c):!1:a[b]===c;default:thrownewTypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");}};d.commonPath=function(a,b){varc=
g);if(l&&k.test(l))continue}varl=g+a.slice(g).search(e),q=a.slice(g,l).replace(f,"");c.ignore&&c.ignore.test(q)||(l=g+q.length,q=b(q,g,l,a),a=a.slice(0,g)+q+a.slice(l),h.lastIndex=g+q.length)}h.lastIndex=0;returna};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!e)thrownewTypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(e.toASCII(a).match(d.invalid_hostname_characters))thrownewTypeError("Hostname '"+
a+"' contains characters other than [A-Z0-9.-]");}};d.noConflict=function(a){if(a)returna={URI:this.noConflict()},URITemplate&&"function"==typeofURITemplate.noConflict&&(a.URITemplate=URITemplate.noConflict()),k&&"function"==typeofk.noConflict&&(a.IPv6=k.noConflict()),SecondLevelDomains&&"function"==typeofSecondLevelDomains.noConflict&&(a.SecondLevelDomains=SecondLevelDomains.noConflict()),a;m.URI===this&&(m.URI=C);returnthis};f.build=function(a){if(!0===a)this._deferred_build=!0;elseif(void0===
case"ip":returnb;case"ip4":case"ipv4":case"inet4":returnc;case"ip6":case"ipv6":case"inet6":returnh;case"idn":returng;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":returnk}returnnull};varI=f.protocol,H=f.port,G=f.hostname;f.protocol=function(a,b){if(void0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))thrownewTypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");returnI.call(this,
a,b)};f.scheme=f.protocol;f.port=function(a,b){if(this._parts.urn)returnvoid0===a?"":this;if(void0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))thrownewTypeError("Port '"+a+"' contains characters other than [0-9]");returnH.call(this,a,b)};f.hostname=function(a,b){if(this._parts.urn)returnvoid0===a?"":this;if(void0!==a){varc={};d.parseHost(a,c);a=c.hostname}returnG.call(this,a,b)};f.host=function(a,b){if(this._parts.urn)returnvoid0===a?"":this;
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.is("IP")?this._parts.hostname=a:(c=RegExp(g(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);returnthis};f.tld=function(a,b){if(this._parts.urn)returnvoid0===a?"":
this;"boolean"===typeofa&&(b=a,a=void0);if(void0===a){if(!this._parts.hostname||this.is("IP"))return"";varc=this._parts.hostname.lastIndexOf("."),c=this._parts.hostname.substring(c+1);return!0!==b&&u&&u.list[c.toLowerCase()]?u.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(u&&u.is(a))c=RegExp(g(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);elsethrownewTypeError("TLD '"+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(g(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)returnvoid0===a?"":this;if(void0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";varc=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0,
(c=b,b=a,a=void0);if(void0!==a&&"number"!==typeofa)throwError("Bad segment '"+a+"', must be 0-based integer");f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void0===b)returnvoid0===a?e:e[a];if(null===a||void0===e[a])if(l(b)){e=[];a=0;for(varg=b.length;a<g;a++)if(b[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(b[a])}else{if(b||"string"===typeofb)""===e[e.length-1]?e[e.length-1]=b:e.push(b)}elseb||"string"===typeofb&&b.length?e[a]=b:e.splice(a,
if("object"===typeofa)for(varfina)w.call(a,f)&&(e[f]=a[f]);elseif("string"===typeofa)e[a]=void0!==b?b:null;elsethrownewTypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeofa&&(c=b);this.build(!c);returnthis};f.addQuery=function(a,b,c){vare=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.addQuery(e,a,void0===b?null:b);this._parts.query=
"password","hostname","port"],e,f;if(this._parts.urn)throwError("URNs do not have any generally defined hierarchical components");ainstanceofd||(a=newd(a));b._parts.protocol||(b._parts.protocol=a._parts.protocol);if(this._parts.hostname)returnb;for(e=0;f=c[e];e++)b._parts[f]=a._parts[f];b._parts.path?".."===b._parts.path.substring(-2)&&(b._parts.path+="/"):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query));"/"!==b.path().charAt(0)&&(a=a.directory(),b._parts.path=(a?
a+"/":"")+b._parts.path,b.normalizePath());b.build();returnb};f.relativeTo=function(a){varb=this.clone().normalize(),c,e,f,g;if(b._parts.urn)throwError("URNs do not have any generally defined hierarchical components");a=(newd(a)).normalize();c=b._parts;e=a._parts;f=b.path();g=a.path();if("/"!==f.charAt(0))throwError("URI is already relative");if("/"!==g.charAt(0))throwError("Cannot calculate a URI relative to another relative URI");c.protocol===e.protocol&&(c.protocol=null);if(c.username===