function isIPv4(a){return RE_V4.test(a)?!0:RE_V4_HEX.test(a)?!0:RE_V4_NUMERIC.test(a)?!0:!1}function isIPv6(a){function f(a,b){return(a.length-a.replace(new RegExp(b,"g"),"").length)/b.length}var b=0,c=a.match(RE_V4inV6);if(c){for(var d=c[0].split("."),e=0;4>e;e++)if(/^0[0-9]+/.test(d[e]))return!1;if(a=a.replace(RE_V4inV6,""),/[0-9]$/.test(a))return!1;a+=d.join(":"),b=2}if(RE_BAD_CHARACTERS.test(a))return!1;if(RE_BAD_ADDRESS.test(a))return!1;var g=f(a,"::");return 1==g&&f(a,":")<=8+b?!0:0==g&&f(a,":")==7+b?!0:!1}function getBaseDomain(a){if(a=a.replace(/\.+$/,""),isIPv6(a)||isIPv4(a))return a;a.indexOf("xn--")>=0&&(a=punycode.toUnicode(a));for(var b=[],c=a,d=c.indexOf("."),e=0;;){var f=publicSuffixes[c];if("undefined"!=typeof f){e=f;break}if(0>d){e=1;break}b.push(c.substring(0,d)),c=c.substring(d+1),d=c.indexOf(".")}for(;e>0&&b.length>0;)c=b.pop()+"."+c,e--;return c}function isThirdParty(a,b){a=a.replace(/\.+$/,""),b=b.replace(/\.+$/,"");var c=getBaseDomain(b);return a.length>c.length?a.substr(a.length-c.length-1)!="."+c:a!=c}function extractHostFromURL(a){if(a&&extractHostFromURL._lastURL==a)return extractHostFromURL._lastDomain;var b="";try{b=new URI(a).host}catch(c){}return extractHostFromURL._lastURL=a,extractHostFromURL._lastDomain=b,b}function URI(a){if(this.spec=a,this._schemeEnd=a.indexOf(":"),this._schemeEnd<0)throw new Error("Invalid URI scheme");if("//"!=a.substr(this._schemeEnd+1,2))throw new Error("Unexpected URI structure");if(this._hostPortStart=this._schemeEnd+3,this._hostPortEnd=a.indexOf("/",this._hostPortStart),this._hostPortEnd<0)throw new Error("Invalid URI host");var b=a.indexOf("@",this._hostPortStart);b>=0&&b<this._hostPortEnd&&(this._hostPortStart=b+1),this._portStart=-1,this._hostEnd=a.indexOf("]",this._hostPortStart+1),"["==a[this._hostPortStart]&&this._hostEnd>=0&&this._hostEnd<this._hostPortEnd?(this._hostStart=this._hostPortStart+1,":"==a[this._hostEnd+1]&&(this._portStart=this._hostEnd+2)):(this._hostStart=this._hostPortStart,this._hostEnd=a.indexOf(":",this._hostStart),this._hostEnd>=0&&this._hostEnd<this._hostPortEnd?this._portStart=this._hostEnd+1:this._hostEnd=this._hostPortEnd)}const RE_V4=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0[0-7]{3})\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0[0-7]{3})$/i,RE_V4_HEX=/^0x([0-9a-f]{8})$/i,RE_V4_NUMERIC=/^[0-9]+$/,RE_V4inV6=/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,RE_BAD_CHARACTERS=/([^0-9a-f:])/i,RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]$)/i;URI.prototype={spec:null,get scheme(){return this.spec.substring(0,this._schemeEnd).toLowerCase()},get host(){return this.spec.substring(this._hostStart,this._hostEnd)},get asciiHost(){var a=this.host;return/^[\x00-\x7F]+$/.test(a)?a:punycode.toASCII(a)},get hostPort(){return this.spec.substring(this._hostPortStart,this._hostPortEnd)},get port(){return this._portStart<0?-1:parseInt(this.spec.substring(this._portStart,this._hostPortEnd),10)},get path(){return this.spec.substring(this._hostPortEnd)},get prePath(){return this.spec.substring(0,this._hostPortEnd)}};