text: !function(e){function r(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function n(t){return"[object Array]"===String(Object.prototype.toString.call(t))}function s(t,r){var s,a,i={};if(n(r))for(s=0,a=r.length;a>s;s++)i[r[s]]=!0;else i[r]=!0;for(s=0,a=t.length;a>s;s++)i[t[s]]!==e&&(t.splice(s,1),a--,s--);return t}var a="undefined"!=typeof module&&module.exports?require("./punycode"):window.punycode,i="undefined"!=typeof module&&module.exports?require("./IPv6"):window.IPv6,o=function(t,r){return this instanceof o?(t===e&&(t=location.href+""),this.href(t),r!==e?this.absoluteTo(r):this):new o(t)},h=o.prototype;o.idn_expression=/[^a-z0-9\.-]/i,o.punycode_expression=/(xn--)/i,o.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,o.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,o.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,o.defaultPorts={http:"80",https:"443",ftp:"21"},o.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,o.encode=encodeURIComponent,o.decode=decodeURIComponent,o.iso8859=function(){o.encode=escape,o.decode=unescape},o.unicode=function(){o.encode=encodeURIComponent,o.decode=decodeURIComponent},o.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}}},o.encodeQuery=function(t){return o.encode(t+"").replace(/%20/g,"+")},o.decodeQuery=function(t){return o.decode((t+"").replace(/\+/g,"%20"))},o.recodePath=function(t){for(var e=(t+"").split("/"),r=0,n=e.length;n>r;r++)e[r]=o.encodePathSegment(o.decode(e[r]));return e.join("/")},o.decodePath=function(t){for(var e=(t+"").split("/"),r=0,n=e.length;n>r;r++)e[r]=o.decodePathSegment(e[r]);return e.join("/")};var u,p={encode:"encode",decode:"decode"};for(u in p)o[u+"PathSegment"]=function(t){return function(e){return o[t](e+"").replace(o.characters.pathname[t].expression,function(e){return o.characters.pathname[t].map[e]})}}(p[u]);o.parse=function(t){var e,r={};return e=t.indexOf("#"),e>-1&&(r.fragment=t.substring(e+1)||null,t=t.substring(0,e)),e=t.indexOf("?"),e>-1&&(r.query=t.substring(e+1)||null,t=t.substring(0,e)),e=t.indexOf("://"),e>-1&&(r.protocol=t.substring(0,e),t=t.substring(e+3),t=o.parseAuthority(t,r)),r.path=t,r},o.parseHost=function(e,r){var n=e.indexOf("/");if(-1===n&&(n=e.length),"["===e[0]){var s=e.indexOf("]");r.hostname=e.substring(1,s)||null,r.port=e.substring(s+2,n)||null}else e.indexOf(":")!==e.lastIndexOf(":")?(r.hostname=e.substring(0,n)||null,r.port=null):(t=e.substring(0,n).split(":"),r.hostname=t[0]||null,r.port=t[1]||null);return r.hostname&&"/"!==e.substring(n)[0]&&(n++,e="/"+e),e.substring(n)||"/"},o.parseAuthority=function(e,r){var n=e.indexOf("@"),s=e.indexOf("/");return n>-1&&(-1===s||s>n)?(t=e.substring(0,n).split(":"),r.username=t[0]?o.decode(t[0]):null,r.password=t[1]?o.decode(t[1]):null,e=e.substring(n+1)):(r.username=null,r.password=null),o.parseHost(e,r)},o.parseQuery=function(t){if(!t)return{};if(t=t.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!t)return{};for(var e={},r=t.split("&"),n=r.length,s=0;n>s;s++){var a=r[s].split("="),i=o.decodeQuery(a.shift()),h=a.length?o.decodeQuery(a.join("=")):null;e[i]?("string"==typeof e[i]&&(e[i]=[e[i]]),e[i].push(h)):e[i]=h}return e},o.build=function(t){var e="";return"string"==typeof t.protocol&&t.protocol.length&&(e+=t.protocol+"://"),e+=o.buildAuthority(t)||"","string"==typeof t.path&&("/"!==t.path[0]&&"string"==typeof t.hostname&&(e+="/"),e+=t.path),"string"==typeof t.query&&(e+="?"+t.query),"string"==typeof t.fragment&&(e+="#"+t.fragment),e},o.buildHost=function(t){var e="";return t.hostname?(o.ip6_expression.test(t.hostname)?e+=t.port?"["+t.hostname+"]:"+t.port:t.hostname:(e+=t.hostname,t.port&&(e+=":"+t.port)),e):""},o.buildAuthority=function(t){var e="";return t.username&&(e+=o.encode(t.username),t.password&&(e+=":"+o.encode(t.password)),e+="@"),e+=o.buildHost(t)},o.buildQuery=function(t,r){var s="";for(var a in t)if(Object.hasOwnProperty.call(t,a)&&a)if(n(t[a]))for(var i={},h=0,u=t[a].length;u>h;h++)t[a][h]!==e&&i[t[a][h]+""]===e&&(s+="&"+o.buildQueryParameter(a,t[a][h]),r!==!0&&(i[t[a][h]+""]=!0));else t[a]!==e&&(s+="&"+o.buildQueryParameter(a,t[a]));return s.substring(1)},o.buildQueryParameter=function(t,e){return o.encodeQuery(t)+(null!==e?"="+o.encodeQuery(e):"")},o.addQuery=function(t,r,s){if("object"==typeof r)for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.addQuery(t,a,r[a]);else{if("string"!=typeof r)throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");if(t[r]===e)return void(t[r]=s);"string"==typeof t[r]&&(t[r]=[t[r]]),n(s)||(s=[s]),t[r]=t[r].concat(s)}},o.removeQuery=function(t,r,a){if(n(r))for(var i=0,h=r.length;h>i;i++)t[r[i]]=e;else if("object"==typeof r)for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&o.removeQuery(t,u,r[u]);else{if("string"!=typeof r)throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");a!==e?t[r]===a?t[r]=e:n(t[r])&&(t[r]=s(t[r],a)):t[r]=e}},o.commonPath=function(t,e){var r,n=Math.min(t.length,e.length);for(r=0;n>r;r++)if(t[r]!==e[r]){r--;break}return 1>r?t[0]===e[0]&&"/"===t[0]?"/":"":("/"!==t[r]&&(r=t.substring(0,r).lastIndexOf("/")),t.substring(0,r+1))},o.withinString=function(t,e){return t.replace(o.find_uri_expression,e)},o.ensureValidHostname=function(t){if(t.match(o.invalid_hostname_characters)){if(!a)throw new TypeError("Hostname '"+t+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(a.toASCII(t).match(o.invalid_hostname_characters))throw new TypeError("Hostname '"+t+"' contains characters other than [A-Z0-9.-]")}},h.build=function(t){return t===!0?this._deferred_build=!0:(t===e||this._deferred_build)&&(this._string=o.build(this._parts),this._deferred_build=!1),this},h.toString=function(){return this.build(!1)._string},h.valueOf=function(){return this.toString()},p={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};for(u in p)h[u]=function(t){return function(r,n){return r===e?this._parts[t]||"":(this._parts[t]=r,this.build(!n),this)}}(p[u]);p={query:"?",fragment:"#"};for(u in p)h[u]=function(t,r){return function(n,s){return n===e?this._parts[t]||"":(null!==n&&(n+="",n[0]===r&&(n=n.substring(1))),this._parts[t]=n,this.build(!s),this)}}(u,p[u]);p={search:["?","query"],hash:["#","fragment"]};for(u in p)h[u]=function(t,e){return function(r,n){var s=this[t](r,n);return"string"==typeof s&&s.length?e+s:s}}(p[u][1],p[u][0]);h.pathname=function(t,r){if(t===e||t===!0){var n=this._parts.path||"/";return t?o.decodePath(n):n}return this._parts.path=t?o.recodePath(t):"/",this.build(!r),this},h.path=h.pathname,h.href=function(t,r){if(t===e)return this.toString();this._string="",this._parts={protocol:null,username:null,password:null,hostname:null,port:null,path:null,query:null,fragment:null};var n,s=t instanceof o,a="object"==typeof t&&(t.hostname||t.path);if("string"==typeof t)this._parts=o.parse(t);else{if(!s&&!a)throw new TypeError("invalid input");var i=s?t._parts:t;for(n in i)Object.hasOwnProperty.call(this._parts,n)&&(this._parts[n]=i[n])}return this.build(!r),this},h.is=function(t){var e=!1,r=!1,n=!1,s=!1,a=!1,i=!1,h=!0;switch(this._parts.hostname&&(h=!1,r=o.ip4_expression.test(this._parts.hostname),n=o.ip6_expression.test(this._parts.hostname),e=r||n,s=!e,a=s&&o.idn_expression.test(this._parts.hostname),i=s&&o.punycode_expression.test(this._parts.hostname)),t.toLowerCase()){case"relative":return h;case"domain":case"name":return s;case"ip":return e;case"ip4":case"ipv4":case"inet4":return r;case"ip6":case"ipv6":case"inet6":return n;case"idn":return a;case"punycode":return i}return null};var d=h.protocol,l=h.port,c=h.hostname;h.protocol=function(t,r){if(t!==e&&t)if(":"===t[t.length-1])t=t.substring(0,t.length-1);else if(t.match(/[^a-zA-z0-9\.+-]/))throw new TypeError("Protocol '"+t+"' contains characters other than [A-Z0-9.+-]");return d.call(this,t,r)},h.port=function(t,r){if(t!==e&&(0===t&&(t=null),t&&(t+="",":"===t[0]&&(t=t.substring(1)),t.match(/[^0-9]/))))throw new TypeError("Port '"+t+"' contains characters other than [0-9]");return l.call(this,t,r)},h.hostname=function(t,r){if(t!==e){var n={};o.parseHost(t,n),t=n.hostname}return c.call(this,t,r)},h.host=function(t,r){return t===e?this._parts.hostname?o.buildHost(this._parts):"":(o.parseHost(t,this._parts),this.build(!r),this)},h.authority=function(t,r){return t===e?this._parts.hostname?o.buildAuthority(this._parts):"":(o.parseAuthority(t,this._parts),this.build(!r),this)},h.subdomain=function(t,n){if(t===e){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,s)||""}var a=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,a),h=new RegExp("^"+r(i));return t&&"."!==t[t.length-1]&&(t+="."),t&&o.ensureValidHostname(t),this._parts.hostname=this._parts.hostname.replace(h,t),this.build(!n),this},h.domain=function(t,n){if(t===e)return!this._parts.hostname||this.is("IP")?"":this._parts.hostname.match(/\.?([^\.]+\.[^\.]+)$/)[1]||this._parts.hostname;if(!t)throw new TypeError("cannot set domain empty");if(o.ensureValidHostname(t),!this._parts.hostname||this.is("IP"))this._parts.hostname=t;else{var s=new RegExp(r(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(s,t)}return this.build(!n),this},h.tld=function(t,n){if(t===e){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf(".");return this._parts.hostname.substring(s+1)}if(!t)throw new TypeError("cannot set TLD empty");if(t.match(/[^a-zA-Z0-9-]/))throw new TypeError("TLD '"+t+"' contains characters other than [A-Z0-9]");if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");var a=new RegExp(r(this.tld())+"$");return this._parts.hostname=this._parts.hostname.replace(a,t),this.build(!n),this},h.directory=function(t,n){if(t===e||t===!0){if(!this._parts.path||"/"===this._parts.path)return"/";var s=this._parts.path.length-this.filename().length-1,a=this._parts.path.substring(0,s)||"/";return t?o.decodePath(a):a}var i=this._parts.path.length-this.filename().length,h=this._parts.path.substring(0,i),u=new RegExp("^"+r(h));return this.is("relative")||(t||(t="/"),"/"!==t[0]&&(t="/"+t)),t&&"/"!==t[t.length-1]&&(t+="/"),t=o.recodePath(t),this._parts.path=this._parts.path.replace(u,t),this.build(!n),this},h.filename=function(t,n){if(t===e||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var s=this._parts.path.lastIndexOf("/"),a=this._parts.path.substring(s+1);return t?o.decodePathSegment(a):a}var i=!1;"/"===t[0]&&(t=t.substring(1)),t.match(/\.?\//)&&(i=!0);var h=new RegExp(r(this.filename())+"$");return t=o.recodePath(t),this._parts.path=this._parts.path.replace(h,t),i?this.normalizePath(n):this.build(!n),this},h.suffix=function(t,n){if(t===e||t===!0){if(!this._parts.path||"/"===this._parts.path)return"";var s,a=this.filename(),i=a.lastIndexOf(".");return-1===i?"":(s=a.substring(i+1),res=/^[a-z0-9%]+$/i.test(s)?s:"",t?o.decodePathSegment(res):res)}"."===t[0]&&(t=t.substring(1));var h,u=this.suffix();if(u)h=new RegExp(t?r(u)+"$":r("."+u)+"$");else{if(!t)return this;this._parts.path+="."+o.recodePath(t)}return h&&(t=o.recodePath(t),this._parts.path=this._parts.path.replace(h,t)),this.build(!n),this};var f=h.query;h.query=function(t,r){return t===!0?o.parseQuery(this._parts.query):t!==e&&"string"!=typeof t?(this._parts.query=o.buildQuery(t),this.build(!r),this):f.call(this,t,r)},h.addQuery=function(t,e,r){var n=o.parseQuery(this._parts.query);return o.addQuery(n,t,e),this._parts.query=o.buildQuery(n),"string"!=typeof t&&(r=e),this.build(!r),this},h.removeQuery=function(t,e,r){var n=o.parseQuery(this._parts.query);return o.removeQuery(n,t,e),this._parts.query=o.buildQuery(n),"string"!=typeof t&&(r=e),this.build(!r),this},h.addSearch=h.addQuery,h.removeSearch=h.removeQuery,h.normalize=function(){return this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},h.normalizeProtocol=function(t){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!t)),this},h.normalizeHostname=function(t){return this._parts.hostname&&(this.is("IDN")&&a?this._parts.hostname=a.toASCII(this._parts.hostname):this.is("IPv6")&&i&&(this._parts.hostname=i.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!t)),this},h.normalizePort=function(t){return"string"==typeof this._parts.protocol&&this._parts.port===o.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!t)),this},h.normalizePath=function(t){if(!this._parts.path||"/"===this._parts.path)return this;var e,r,n,s,a=this._parts.path;for("/"!==a[0]&&("."===a[0]&&(r=a.substring(0,a.indexOf("/"))),e=!0,a="/"+a),a=a.replace(/(\/(\.\/)+)|\/{2,}/g,"/");;){if(n=a.indexOf("/../"),-1===n)break;if(0===n){a=a.substring(3);break}s=a.substring(0,n).lastIndexOf("/"),-1===s&&(s=n),a=a.substring(0,s)+a.substring(n+3)}return e&&this.is("relative")&&(a=r?r+a:a.substring(1)),a=o.recodePath(a),this._parts.path=a,this.build(!t),this},h.normalizePathname=h.normalizePath,h.normalizeQuery=function(t){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(o.parseQuery(this._parts.query)):this._parts.query=null,this.build(!t)),this},h.normalizeFragment=function(t){return this._parts.fragment||(this._parts.fragment=null,this.build(!t)),this},h.normalizeSearch=h.normalizeQuery,h.normalizeHash=h.normalizeFragment,h.iso8859=function(){var t=o.encode,e=o.decode;return o.encode=escape,o.decode=decodeURIComponent,this.normalize(),o.encode=t,o.decode=e,this},h.unicode=function(){var t=o.encode,e=o.decode;return o.encode=encodeURIComponent,o.decode=unescape,this.normalize(),o.encode=t,o.decode=e,this},h.readable=function(){var t=new o(this);t.username("").password("").normalize();var r="";if(t._parts.protocol&&(r+=t._parts.protocol+"://"),t._parts.hostname&&(t.is("punycode")&&a?(r+=a.toUnicode(t._parts.hostname),t._parts.port&&(r+=":"+t._parts.port)):r+=t.host()),t._parts.hostname&&t._parts.path&&"/"!==t._parts.path[0]&&(r+="/"),r+=t.path(!0),t._parts.query){for(var n="",s=0,i=t._parts.query.split("&"),h=i.length;h>s;s++){var u=(i[s]||"").split("=");n+="&"+o.decodeQuery(u[0]).replace(/&/g,"%26"),u[1]!==e&&(n+="="+o.decodeQuery(u[1]).replace(/&/g,"%26"))}r+="?"+n.substring(1)}return r+=t.hash()},h.absoluteTo=function(t){if(!this.is("relative"))throw new Error("Cannot resolve non-relative URL");t instanceof o||(t=new o(t));for(var e,r=new o(this),n=["protocol","username","password","hostname","port"],s=0;e=n[s];s++)r._parts[e]=t._parts[e];return"/"!==r.path()[0]&&(r._parts.path=t.directory()+"/"+r._parts.path,r.normalizePath()),r.build(),r},h.relativeTo=function(t){if(t instanceof o||(t=new o(t)),"/"!==this.path()[0]||"/"!==t.path()[0])throw new Error("Cannot calculate common path from non-relative URLs");for(var e,n=new o(this),s=["protocol","username","password","hostname","port"],a=o.commonPath(n.path(),t.path()),i=t.directory(),h=0;e=s[h];h++)n._parts[e]=null;if(!a||"/"===a)return n;if(i+"/"===a)n._parts.path="./"+n.filename();else{for(var u="../",p=new RegExp("^"+r(a)),d=i.replace(p,"/").match(/\//g).length-1;d--;)u+="../";n._parts.path=n._parts.path.replace(p,u)}return n.build(),n},h.equals=function(t){var e,r,s,a=new o(this),i=new o(t),h={},u={},p={};if(a.normalize(),i.normalize(),a.toString()===i.toString())return!0;if(e=a.query(),r=i.query(),a.query(""),i.query(""),a.toString()!==i.toString())return!1;if(e.length!==r.length)return!1;h=o.parseQuery(e),u=o.parseQuery(r);for(s in h)if(Object.prototype.hasOwnProperty.call(h,s)){if(n(h[s])){if(!n(u[s]))return!1;if(h[s].length!==u[s].length)return!1;h[s].sort(),u[s].sort();for(var d=0,l=h[s].length;l>d;d++)if(h[s][d]!==u[s][d])return!1}else if(h[s]!==u[s])return!1;p[s]=!0}for(s in u)if(Object.prototype.hasOwnProperty.call(u,s)&&!p[s])return!1;return!0},"undefined"!=typeof module&&module.exports?module.exports=o:window.URI=o}();