(function(n,t){"object"==typeof module&&module.exports?module.exports=t(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"==typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):n.URI=t(n.punycode,n.IPv6,n.SecondLevelDomains,n)})(this,function(n,t,i,r){function u(n,t){var i=1<=arguments.length,r=2<=arguments.length;if(!(this instanceof u))return i?r?new u(n,t):new u(n):new u;if(void 0===n){if(i)throw new TypeError("undefined is not a valid argument for URI");n="undefined"!=typeof location?location.href+"":""}if(null===n&&i)throw new TypeError("null is not a valid argument for URI");return this.href(n),void 0!==t?this.absoluteTo(t):this}function h(n){return n.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function c(n){return void 0===n?"Undefined":String(Object.prototype.toString.call(n)).slice(8,-1)}function e(n){return"Array"===c(n)}function b(n,t){var r={},u,i;if("RegExp"===c(t))r=null;else if(e(t))for(i=0,u=t.length;i<u;i++)r[t[i]]=!0;else r[t]=!0;for(i=0,u=n.length;i<u;i++)(r&&void 0!==r[n[i]]||!r&&t.test(n[i]))&&(n.splice(i,1),u--,i--);return n}function l(n,t){var r,i,u;if(e(t)){for(i=0,r=t.length;i<r;i++)if(!l(n,t[i]))return!1;return!0}for(u=c(t),i=0,r=n.length;i<r;i++)if("RegExp"===u){if("string"==typeof n[i]&&n[i].match(t))return!0}else if(n[i]===t)return!0;return!1}function k(n,t){if(!e(n)||!e(t)||n.length!==t.length)return!1;n.sort(),t.sort();for(var i=0,r=n.length;i<r;i++)if(n[i]!==t[i])return!1;return!0}function p(n){return n.replace(/^\/+|\/+$/g,"")}function nt(n){return escape(n)}function w(n){return encodeURIComponent(n).replace(/[!'()*]/g,nt).replace(/\*/g,"%2A")}function a(n){return function(t,i){return void 0===t?this._parts[n]||"":(this._parts[n]=t||null,this.build(!i),this)}}function d(n,t){return function(i,r){return void 0===i?this._parts[n]||"":(null!==i&&(i+="",i.charAt(0)===t&&(i=i.substring(1))),this._parts[n]=i,this.build(!r),this)}}var tt=r&&r.URI,f,o,s,v,y,g;u.version="1.19.2",f=u.prototype,o=Object.prototype.hasOwnProperty,u._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:u.preventInvalidHostname,duplicateQueryParameters:u.duplicateQueryParameters,escapeQuerySpace:u.escapeQuerySpace}},u.preventInvalidHostname=!1,u.duplicateQueryParameters=!1,u.escapeQuerySpace=!0,u.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,u.idn_expression=/[^a-z0-9\._-]/i,u.punycode_expression=/(xn--)/i,u.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,u.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*$/,u.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`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig,u.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},u.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},u.hostProtocols=["http","https"],u.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,u.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},u.getDomAttribute=function(n){if(n&&n.nodeName){var t=n.nodeName.toLowerCase();if("input"!==t||"image"===n.type)return u.domAttributes[t]}},u.encode=w,u.decode=decodeURIComponent,u.iso8859=function(){u.encode=escape,u.decode=unescape},u.unicode=function(){u.encode=w,u.decode=decodeURIComponent},u.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},u.encodeQuery=function(n,t){var i=u.encode(n+"");return void 0===t&&(t=u.escapeQuerySpace),t?i.replace(/%20/g,"+"):i},u.decodeQuery=function(n,t){n+="",void 0===t&&(t=u.escapeQuerySpace);try{return u.decode(t?n.replace(/\+/g,"%20"):n)}catch(i){return n}},s={encode:"encode",decode:"decode"},y=function(n,t){return function(i){try{return u[t](i+"").replace(u.characters[n][t].expression,function(i){return u.characters[n][t].map[i]})}catch(r){return i}}};for(v in s)u[v+"PathSegment"]=y("pathname",s[v]),u[v+"UrnPathSegment"]=y("urnpath",s[v]);s=function(n,t,i){return function(r){var o=i?function(n){return u[t](u[i](n))}:u[t],f,e;for(r=(r+"").split(n),f=0,e=r.length;f<e;f++)r[f]=o(r[f]);return r.join(n)}},u.decodePath=s("/","decodePathSegment"),u.decodeUrnPath=s(":","decodeUrnPathSegment"),u.recodePath=s("/","encodePathSegment","decode"),u.recodeUrnPath=s(":","encodeUrnPathSegment","decode"),u.encodeReserved=y("reserved","encode"),u.parse=function(n,t){t||(t={preventInvalidHostname:u.preventInvalidHostname});var i=n.indexOf("#");return-1<i&&(t.fragment=n.substring(i+1)||null,n=n.substring(0,i)),i=n.indexOf("?"),-1<i&&(t.query=n.substring(i+1)||null,n=n.substring(0,i)),"//"===n.substring(0,2)?(t.protocol=null,n=n.substring(2),n=u.parseAuthority(n,t)):(i=n.indexOf(":"),-1<i&&(t.protocol=n.substring(0,i)||null,t.protocol&&!t.protocol.match(u.protocol_expression)?t.protocol=void 0:"//"===n.substring(i+1,i+3)?(n=n.substring(i+3),n=u.parseAuthority(n,t)):(n=n.substring(i+1),t.urn=!0))),t.path=n,t},u.parseHost=function(n,t){var i,r,f;return n||(n=""),n=n.replace(/\\/g,"/"),i=n.indexOf("/"),-1===i&&(i=n.length),"["===n.charAt(0)?(r=n.indexOf("]"),t.hostname=n.substring(1,r)||null,t.port=n.substring(r+2,i)||null,"/"===t.port&&(t.port=null)):(f=n.indexOf(":"),r=n.indexOf("/"),f=n.indexOf(":",f+1),-1!==f&&(-1===r||f<r)?(t.hostname=n.substring(0,i)||null,t.port=null):(r=n.substring(0,i).split(":"),t.hostname=r[0]||null,t.port=r[1]||null)),t.hostname&&"/"!==n.substring(i).charAt(0)&&(i++,n="/"+n),t.preventInvalidHostname&&u.ensureValidHostname(t.hostname,t.protocol),t.port&&u.ensureValidPort(t.port),n.substring(i)||"/"},u.parseAuthority=function(n,t){return n=u.parseUserinfo(n,t),u.parseHost(n,t)},u.parseUserinfo=function(n,t){var i=n.indexOf("/"),r=n.lastIndexOf("@",-1<i?i:n.length-1);return-1<r&&(-1===i||r<i)?(i=n.substring(0,r).split(":"),t.username=i[0]?u.decode(i[0]):null,i.shift(),t.password=i[0]?u.decode(i.join(":")):null,n=n.substring(r+1)):(t.username=null,t.password=null),n},u.parseQuery=function(n,t){if(!n)return{};if(n=n.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,""),!n)return{};for(var i={},s=n.split("&"),h=s.length,f,r,e=0;e<h;e++)(f=s[e].split("="),r=u.decodeQuery(f.shift(),t),f=f.length?u.decodeQuery(f.join("="),t):null,o.call(i,r))?(("string"==typeof i[r]||null===i[r])&&(i[r]=[i[r]]),i[r].push(f)):i[r]=f;return i},u.build=function(n){var t="",i=!1;return n.protocol&&(t+=n.protocol+":"),!n.urn&&(t||n.hostname)&&(t+="//",i=!0),t+=u.buildAuthority(n)||"","string"==typeof n.path&&("/"!==n.path.charAt(0)&&i&&(t+="/"),t+=n.path),"string"==typeof n.query&&n.query&&(t+="?"+n.query),"string"==typeof n.fragment&&n.fragment&&(t+="#"+n.fragment),t},u.buildHost=function(n){var t="";if(n.hostname)t=u.ip6_expression.test(n.hostname)?t+("["+n.hostname+"]"):t+n.hostname;else return"";return n.port&&(t+=":"+n.port),t},u.buildAuthority=function(n){return u.buildUserinfo(n)+u.buildHost(n)},u.buildUserinfo=function(n){var t="";return n.username&&(t+=u.encode(n.username)),n.password&&(t+=":"+u.encode(n.password)),t&&(t+="@"),t},u.buildQuery=function(n,t,i){var s="",r,c,h,f;for(r in n)if(o.call(n,r))if(e(n[r]))for(h={},f=0,c=n[r].length;f<c;f++)void 0!==n[r][f]&&void 0===h[n[r][f]+""]&&(s+="&"+u.buildQueryParameter(r,n[r][f],i),!0!==t&&(h[n[r][f]+""]=!0));else void 0!==n[r]&&(s+="&"+u.buildQueryParameter(r,n[r],i));return s.substring(1)},u.buildQueryParameter=function(n,t,i){return u.encodeQuery(n,i)+(null!==t?"="+u.encodeQuery(t,i):"")},u.addQuery=function(n,t,i){if("object"==typeof t)for(var r in t)o.call(t,r)&&u.addQuery(n,r,t[r]);else if("string"==typeof t)void 0===n[t]?n[t]=i:("string"==typeof n[t]&&(n[t]=[n[t]]),e(i)||(i=[i]),n[t]=(n[t]||[]).concat(i));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");},u.setQuery=function(n,t,i){if("object"==typeof t)for(var r in t)o.call(t,r)&&u.setQuery(n,r,t[r]);else if("string"==typeof t)n[t]=void 0===i?null:i;else throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");},u.removeQuery=function(n,t,i){var r;if(e(t))for(i=0,r=t.length;i<r;i++)n[t[i]]=void 0;else if("RegExp"===c(t))for(r in n)t.test(r)&&(n[r]=void 0);else if("object"==typeof t)for(r in t)o.call(t,r)&&u.removeQuery(n,r,t[r]);else if("string"==typeof t)void 0!==i?"RegExp"===c(i)?n[t]=!e(n[t])&&i.test(n[t])?void 0:b(n[t],i):n[t]!==String(i)||e(i)&&1!==i.length?e(n[t])&&(n[t]=b(n[t],i)):n[t]=void 0:n[t]=void 0;else throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");},u.hasQuery=function(n,t,i,r){var f,s;switch(c(t)){case"String":break;case"RegExp":for(f in n)if(o.call(n,f)&&t.test(f)&&(void 0===i||u.hasQuery(n,f,i)))return!0;return!1;case"Object":for(s in t)if(o.call(t,s)&&!u.hasQuery(n,s,t[s]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");}switch(c(i)){case"Undefined":return t in n;case"Boolean":return n=!(e(n[t])?!n[t].length:!n[t]),i===n;case"Function":return!!i(n[t],t,n);case"Array":return e(n[t])?(r?l:k)(n[t],i):!1;case"RegExp":return e(n[t])?r?l(n[t],i):!1:!(!n[t]||!n[t].match(i));case"Number":i=String(i);case"String":return e(n[t])?r?l(n[t],i):!1:n[t]===i;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");}},u.joinPaths=function(){for(var n,i,r=[],t=[],e=0,f=0;f<arguments.length;f++)for(n=new u(arguments[f]),r.push(n),n=n.segment(),i=0;i<n.length;i++)"string"==typeof n[i]&&t.push(n[i]),n[i]&&e++;return!t.length||!e?new u(""):(t=new u("").segment(t),""!==r[0].path()&&"/"!==r[0].path().slice(0,1)||t.path("/"+t.path()),t.normalize())},u.commonPath=function(n,t){for(var r=Math.min(n.length,t.length),i=0;i<r;i++)if(n.charAt(i)!==t.charAt(i)){i--;break}return 1>i?n.charAt(0)===t.charAt(0)&&"/"===n.charAt(0)?"/":"":(("/"!==n.charAt(i)||"/"!==t.charAt(i))&&(i=n.substring(0,i).lastIndexOf("/")),n.substring(0,i+1))},u.withinString=function(n,t,i){var e,o,r,f,h;i||(i={});var s=i.start||u.findUri.start,l=i.end||u.findUri.end,c=i.trim||u.findUri.trim,a=i.parens||u.findUri.parens,v=/[a-z0-9-]=["']?$/i;for(s.lastIndex=0;;){if(e=s.exec(n),!e)break;if(o=e.index,!i.ignoreHtml||(r=n.slice(Math.max(o-3,0),o),!r||!v.test(r))){for(f=o+n.slice(o).search(l),r=n.slice(o,f),f=-1;;){if(h=a.exec(r),!h)break;f=Math.max(f,h.index+h[0].length)}r=-1<f?r.slice(0,f)+r.slice(f).replace(c,""):r.replace(c,""),r.length<=e[0].length||i.ignore&&i.ignore.test(r)||(f=o+r.length,e=t(r,o,f,n),void 0===e?s.lastIndex=f:(e=String(e),n=n.slice(0,o)+e+n.slice(f),s.lastIndex=o+e.length))}}return s.lastIndex=0,n},u.ensureValidHostname=function(t,i){var f=!!t,r=!1;if(i&&(r=l(u.hostProtocols,i)),r&&!f)throw new TypeError("Hostname cannot be empty, if protocol is "+i);if(t&&t.match(u.invalid_hostname_characters)){if(!n)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(n.toASCII(t).match(u.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]');}},u.ensureValidPort=function(n){if(n){var t=Number(n);if(!(/^[0-9]+$/.test(t)&&0<t&&65536>t))throw new TypeError('Port "'+n+'" is not a valid port');}},u.noConflict=function(n){return n?(n={URI:this.noConflict()},r.URITemplate&&"function"==typeof r.URITemplate.noConflict&&(n.URITemplate=r.URITemplate.noConflict()),r.IPv6&&"function"==typeof r.IPv6.noConflict&&(n.IPv6=r.IPv6.noConflict()),r.SecondLevelDomains&&"function"==typeof r.SecondLevelDomains.noConflict&&(n.SecondLevelDomains=r.SecondLevelDomains.noConflict()),n):(r.URI===this&&(r.URI=tt),this)},f.build=function(n){return!0===n?this._deferred_build=!0:(void 0===n||this._deferred_build)&&(this._string=u.build(this._parts),this._deferred_build=!1),this},f.clone=function(){return new u(this)},f.valueOf=f.toString=function(){return this.build(!1)._string},f.protocol=a("protocol"),f.username=a("username"),f.password=a("password"),f.hostname=a("hostname"),f.port=a("port"),f.query=d("query","?"),f.fragment=d("fragment","#"),f.search=function(n,t){var i=this.query(n,t);return"string"==typeof i&&i.length?"?"+i:i},f.hash=function(n,t){var i=this.fragment(n,t);return"string"==typeof i&&i.length?"#"+i:i},f.pathname=function(n,t){if(void 0===n||!0===n){var i=this._parts.path||(this._parts.hostname?"/":"");return n?(this._parts.urn?u.decodeUrnPath:u.decodePath)(i):i}return this._parts.path=this._parts.urn?n?u.recodeUrnPath(n):"":n?u.recodePath(n):"/",this.build(!t),this},f.path=f.pathname,f.href=function(n,t){var f,i,r;if(void 0===n)return this.toString();if(this._string="",this._parts=u._parts(),i=n instanceof u,r="object"==typeof n&&(n.hostname||n.path||n.pathname),n.nodeName&&(r=u.getDomAttribute(n),n=n[r]||"",r=!1),!i&&r&&void 0!==n.pathname&&(n=n.toString()),"string"==typeof n||n instanceof String)this._parts=u.parse(String(n),this._parts);else if(i||r){i=i?n._parts:n;for(f in i)"query"!==f&&o.call(this._parts,f)&&(this._parts[f]=i[f]);i.query&&this.query(i.query,!1)}else throw new TypeError("invalid input");return this.build(!t),this},f.is=function(n){var r=!1,f=!1,e=!1,t=!1,s=!1,h=!1,c=!1,o=!this._parts.urn;this._parts.hostname&&(o=!1,f=u.ip4_expression.test(this._parts.hostname),e=u.ip6_expression.test(this._parts.hostname),r=f||e,s=(t=!r)&&i&&i.has(this._parts.hostname),h=t&&u.idn_expression.test(this._parts.hostname),c=t&&u.punycode_expression.test(this._parts.hostname));switch(n.toLowerCase()){case"relative":return o;case"absolute":return!o;case"domain":case"name":return t;case"sld":return s;case"ip":return r;case"ip4":case"ipv4":case"inet4":return f;case"ip6":case"ipv6":case"inet6":return e;case"idn":return h;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return c}return null};var it=f.protocol,rt=f.port,ut=f.hostname;return f.protocol=function(n,t){if(n&&(n=n.replace(/:(\/\/)?$/,""),!n.match(u.protocol_expression)))throw new TypeError('Protocol "'+n+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return it.call(this,n,t)},f.scheme=f.protocol,f.port=function(n,t){return this._parts.urn?void 0===n?"":this:(void 0!==n&&(0===n&&(n=null),n&&(n+="",":"===n.charAt(0)&&(n=n.substring(1)),u.ensureValidPort(n))),rt.call(this,n,t))},f.hostname=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0!==n){var i={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==u.parseHost(n,i))throw new TypeError('Hostname "'+n+'" contains characters other than [A-Z0-9.-]');n=i.hostname,this._parts.preventInvalidHostname&&u.ensureValidHostname(n,this._parts.protocol)}return ut.call(this,n,t)},f.origin=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n){var i=this.protocol();return this.authority()?(i?i+"://":"")+this.authority():""}return i=u(n),this.protocol(i.protocol()).authority(i.authority()).build(!t),this},f.host=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n)return this._parts.hostname?u.buildHost(this._parts):"";if("/"!==u.parseHost(n,this._parts))throw new TypeError('Hostname "'+n+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},f.authority=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n)return this._parts.hostname?u.buildAuthority(this._parts):"";if("/"!==u.parseAuthority(n,this._parts))throw new TypeError('Hostname "'+n+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},f.userinfo=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n){var i=u.buildUserinfo(this._parts);return i?i.substring(0,i.length-1):i}return"@"!==n[n.length-1]&&(n+="@"),u.parseUserinfo(n,this._parts),this.build(!t),this},f.resource=function(n,t){if(void 0===n)return this.path()+this.search()+this.hash();var i=u.parse(n);return this._parts.path=i.path,this._parts.query=i.query,this._parts.fragment=i.fragment,this.build(!t),this},f.subdomain=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n){if(!this._parts.hostname||this.is("IP"))return"";var i=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,i)||""}if(i=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,i),i=new RegExp("^"+h(i)),n&&"."!==n.charAt(n.length-1)&&(n+="."),-1!==n.indexOf(":"))throw new TypeError("Domains cannot contain colons");return n&&u.ensureValidHostname(n,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(i,n),this.build(!t),this},f.domain=function(n,t){if(this._parts.urn)return void 0===n?"":this;if("boolean"==typeof n&&(t=n,n=void 0),void 0===n){if(!this._parts.hostname||this.is("IP"))return"";var i=this._parts.hostname.match(/\./g);return i&&2>i.length?this._parts.hostname:(i=this._parts.hostname.length-this.tld(t).length-1,i=this._parts.hostname.lastIndexOf(".",i-1)+1,this._parts.hostname.substring(i)||"")}if(!n)throw new TypeError("cannot set domain empty");if(-1!==n.indexOf(":"))throw new TypeError("Domains cannot contain colons");return u.ensureValidHostname(n,this._parts.protocol),!this._parts.hostname||this.is("IP")?this._parts.hostname=n:(i=new RegExp(h(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(i,n)),this.build(!t),this},f.tld=function(n,t){if(this._parts.urn)return void 0===n?"":this;if("boolean"==typeof n&&(t=n,n=void 0),void 0===n){if(!this._parts.hostname||this.is("IP"))return"";var r=this._parts.hostname.lastIndexOf(".");return r=this._parts.hostname.substring(r+1),!0!==t&&i&&i.list[r.toLowerCase()]?i.get(this._parts.hostname)||r:r}if(n)if(n.match(/[^a-zA-Z0-9-]/))if(i&&i.is(n))r=new RegExp(h(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,n);else throw new TypeError('TLD "'+n+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");r=new RegExp(h(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,n)}else throw new TypeError("cannot set TLD empty");return this.build(!t),this},f.directory=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n||!0===n){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var i=this._parts.path.length-this.filename().length-1;return i=this._parts.path.substring(0,i)||(this._parts.hostname?"/":""),n?u.decodePath(i):i}return i=this._parts.path.length-this.filename().length,i=this._parts.path.substring(0,i),i=new RegExp("^"+h(i)),this.is("relative")||(n||(n="/"),"/"!==n.charAt(0)&&(n="/"+n)),n&&"/"!==n.charAt(n.length-1)&&(n+="/"),n=u.recodePath(n),this._parts.path=this._parts.path.replace(i,n),this.build(!t),this},f.filename=function(n,t){var i,r;return this._parts.urn?void 0===n?"":this:"string"!=typeof n?!this._parts.path||"/"===this._parts.path?"":(i=this._parts.path.lastIndexOf("/"),i=this._parts.path.substring(i+1),n?u.decodePathSegment(i):i):(i=!1,"/"===n.charAt(0)&&(n=n.substring(1)),n.match(/\.?\//)&&(i=!0),r=new RegExp(h(this.filename())+"$"),n=u.recodePath(n),this._parts.path=this._parts.path.replace(r,n),i?this.normalizePath(t):this.build(!t),this)},f.suffix=function(n,t){if(this._parts.urn)return void 0===n?"":this;if(void 0===n||!0===n){if(!this._parts.path||"/"===this._parts.path)return"";var i=this.filename(),r=i.lastIndexOf(".");return-1===r?"":(i=i.substring(r+1),i=/^[a-z0-9%]+$/i.test(i)?i:"",n?u.decodePathSegment(i):i)}if("."===n.charAt(0)&&(n=n.substring(1)),i=this.suffix())r=n?new RegExp(h(i)+"$"):new RegExp(h("."+i)+"$");else{if(!n)return this;this._parts.path+="."+u.recodePath(n)}return r&&(n=u.recodePath(n),this._parts.path=this._parts.path.replace(r,n)),this.build(!t),this},f.segment=function(n,t,i){var u=this._parts.urn?":":"/",r=this.path(),f="/"===r.substring(0,1),o;if(r=r.split(u),void 0!==n&&"number"!=typeof n&&(i=t,t=n,n=void 0),void 0!==n&&"number"!=typeof n)throw Error('Bad segment "'+n+'", must be 0-based integer');if(f&&r.shift(),0>n&&(n=Math.max(r.length+n,0)),void 0===t)return void 0===n?r:r[n];if(null===n||void 0===r[n])if(e(t))for(r=[],n=0,o=t.length;n<o;n++)(t[n].length||r.length&&r[r.length-1].length)&&(r.length&&!r[r.length-1].length&&r.pop(),r.push(p(t[n])));else(t||"string"==typeof t)&&(t=p(t),""===r[r.length-1]?r[r.length-1]=t:r.push(t));else t?r[n]=p(t):r.splice(n,1);return f&&r.unshift(""),this.path(r.join(u),i)},f.segmentCoded=function(n,t,i){var f,r;if("number"!=typeof n&&(i=t,t=n,n=void 0),void 0===t){if(n=this.segment(n,t,i),e(n))for(r=0,f=n.length;r<f;r++)n[r]=u.decode(n[r]);else n=void 0!==n?u.decode(n):void 0;return n}if(e(t))for(r=0,f=t.length;r<f;r++)t[r]=u.encode(t[r]);else t="string"==typeof t||t instanceof String?u.encode(t):t;return this.segment(n,t,i)},g=f.query,f.query=function(n,t){if(!0===n)return u.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"==typeof n){var i=u.parseQuery(this._parts.query,this._parts.escapeQuerySpace),r=n.call(this,i);return this._parts.query=u.buildQuery(r||i,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!t),this}return void 0!==n&&"string"!=typeof n?(this._parts.query=u.buildQuery(n,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!t),this):g.call(this,n,t)},f.setQuery=function(n,t,i){var f=u.parseQuery(this._parts.query,this._parts.escapeQuerySpace),r;if("string"==typeof n||n instanceof String)f[n]=void 0!==t?t:null;else if("object"==typeof n)for(r in n)o.call(n,r)&&(f[r]=n[r]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");return this._parts.query=u.buildQuery(f,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof n&&(i=t),this.build(!i),this},f.addQuery=function(n,t,i){var r=u.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return u.addQuery(r,n,void 0===t?null:t),this._parts.query=u.buildQuery(r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof n&&(i=t),this.build(!i),this},f.removeQuery=function(n,t,i){var r=u.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return u.removeQuery(r,n,t),this._parts.query=u.buildQuery(r,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),"string"!=typeof n&&(i=t),this.build(!i),this},f.hasQuery=function(n,t,i){var r=u.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return u.hasQuery(r,n,t,i)},f.setSearch=f.setQuery,f.addSearch=f.addQuery,f.removeSearch=f.removeQuery,f.hasSearch=f.hasQuery,f.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()},f.normalizeProtocol=function(n){return"string"==typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!n)),this},f.normalizeHostname=function(i){return this._parts.hostname&&(this.is("IDN")&&n?this._parts.hostname=n.toASCII(this._parts.hostname):this.is("IPv6")&&t&&(this._parts.hostname=t.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!i)),this},f.normalizePort=function(n){return"string"==typeof this._parts.protocol&&this._parts.port===u.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!n)),this},f.normalizePath=function(n){var t=this._parts.path,r,e,i,f;if(!t)return this;if(this._parts.urn)return this._parts.path=u.recodeUrnPath(this._parts.path),this.build(!n),this;if("/"===this._parts.path)return this;for(t=u.recodePath(t),r="","/"!==t.charAt(0)&&(e=!0,t="/"+t),("/.."===t.slice(-3)||"/."===t.slice(-2))&&(t+="/"),t=t.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/"),e&&(r=t.substring(1).match(/^(\.\.\/)+/)||"")&&(r=r[0]);;){if(i=t.search(/\/\.\.(\/|$)/),-1===i)break;else if(0===i){t=t.substring(3);continue}f=t.substring(0,i).lastIndexOf("/"),-1===f&&(f=i),t=t.substring(0,f)+t.substring(i+3)}return e&&this.is("relative")&&(t=r+t.substring(1)),this._parts.path=t,this.build(!n),this},f.normalizePathname=f.normalizePath,f.normalizeQuery=function(n){return"string"==typeof this._parts.query&&(this._parts.query.length?this.query(u.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!n)),this},f.normalizeFragment=function(n){return this._parts.fragment||(this._parts.fragment=null,this.build(!n)),this},f.normalizeSearch=f.normalizeQuery,f.normalizeHash=f.normalizeFragment,f.iso8859=function(){var n=u.encode,t=u.decode;u.encode=escape,u.decode=decodeURIComponent;try{this.normalize()}finally{u.encode=n,u.decode=t}return this},f.unicode=function(){var n=u.encode,t=u.decode;u.encode=w,u.decode=unescape;try{this.normalize()}finally{u.encode=n,u.decode=t}return this},f.readable=function(){var t=this.clone(),i,r;if(t.username("").password("").normalize(),i="",t._parts.protocol&&(i+=t._parts.protocol+"://"),t._parts.hostname&&(t.is("punycode")&&n?(i+=n.toUnicode(t._parts.hostname),t._parts.port&&(i+=":"+t._parts.port)):i+=t.host()),t._parts.hostname&&t._parts.path&&"/"!==t._parts.path.charAt(0)&&(i+="/"),i+=t.path(!0),t._parts.query){for(var f="",e=0,o=t._parts.query.split("&"),s=o.length;e<s;e++)r=(o[e]||"").split("="),f+="&"+u.decodeQuery(r[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"),void 0!==r[1]&&(f+="="+u.decodeQuery(r[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"));i+="?"+f.substring(1)}return i+=u.decodeQuery(t.hash(),!0)},f.absoluteTo=function(n){var t=this.clone(),i=["protocol","username","password","hostname","port"],r,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");if((n instanceof u||(n=new u(n)),t._parts.protocol)||(t._parts.protocol=n._parts.protocol,this._parts.hostname))return t;for(r=0;f=i[r];r++)t._parts[f]=n._parts[f];return t._parts.path?(".."===t._parts.path.substring(-2)&&(t._parts.path+="/"),"/"!==t.path().charAt(0)&&(i=(i=n.directory())?i:0===n.path().indexOf("/")?"/":"",t._parts.path=(i?i+"/":"")+t._parts.path,t.normalizePath())):(t._parts.path=n._parts.path,t._parts.query||(t._parts.query=n._parts.query)),t.build(),t},f.relativeTo=function(n){var r=this.clone().normalize();if(r._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");n=new u(n).normalize();var t=r._parts,i=n._parts,f=r.path();if(n=n.path(),"/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==n.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");if(t.protocol===i.protocol&&(t.protocol=null),t.username===i.username&&t.password===i.password&&null===t.protocol&&null===t.username&&null===t.password&&t.hostname===i.hostname&&t.port===i.port)t.hostname=null,t.port=null;else return r.build();return f===n?(t.path="",r.build()):(f=u.commonPath(f,n),!f)?r.build():(i=i.path.substring(f.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../"),t.path=i+t.path.substring(f.length)||"./",r.build())},f.equals=function(n){var t=this.clone(),f=new u(n),i,s,r;if(n={},t.normalize(),f.normalize(),t.toString()===f.toString())return!0;if(s=t.query(),r=f.query(),t.query(""),f.query(""),t.toString()!==f.toString()||s.length!==r.length)return!1;t=u.parseQuery(s,this._parts.escapeQuerySpace),r=u.parseQuery(r,this._parts.escapeQuerySpace);for(i in t)if(o.call(t,i)){if(e(t[i])){if(!k(t[i],r[i]))return!1}else if(t[i]!==r[i])return!1;n[i]=!0}for(i in r)if(o.call(r,i)&&!n[i])return!1;return!0},f.preventInvalidHostname=function(n){return this._parts.preventInvalidHostname=!!n,this},f.duplicateQueryParameters=function(n){return this._parts.duplicateQueryParameters=!!n,this},f.escapeQuerySpace=function(n){return this._parts.escapeQuerySpace=!!n,this},u});var UriHelper=function(){"use strict";var n={};return n.addLocationContext=function(n){if(URI){var t=URI.parseQuery(new URI(location.href).query());t.returnURL&&(t=new URI(t.returnURL).query()),n=URI.decode(new URI(n).setSearch(t).toString())}return n},n}(),FacebookConnect={FBLogout:function(n){try{FB.getLoginStatus(function(t){t.authResponse?FB.logout(function(){window.location.href=n}):window.location.href=n})}catch(t){window.location.href=n}},FBLogin:function(n){var t=$("#facebookConnectLightBox").html();$.colorbox({html:t,close:"",fastIframe:!0,scrolling:!1,transition:"none",top:"1px",open:!0,top:40}),FacebookSDK.OnSuccessUrl=n,FB.login(function(t){if(t.authResponse){var i=t.authResponse.accessToken,r={fbDetails:{Token:i,ReturnUrl:n,UserAgentDetails:typeof UserAgentHelper!="undefined"&&UserAgentHelper.userAgentDetails?UserAgentHelper.userAgentDetails():{}}};$.ajax({type:"POST",url:UriHelper.addLocationContext("/WebServices/Ajax/SocialNetworkRegistrationService.svc/FacebookConnect"),data:JSON.stringify(r),dataType:"json",contentType:"application/json; charset=utf-8",success:FacebookSDK.OnComplete,error:FacebookSDK.OnFail})}else $.colorbox.close(),console.warn("User cancelled login or did not fully authorize.")},{scope:"email"})},FBLoginLP:function(n,t,i){var r=$("#facebookConnectLightBox").html();$.colorbox({html:r,close:"",fastIframe:!0,scrolling:!1,transition:"none",top:"1px",open:!0,top:10}),FB.login(function(r){if(r.authResponse){var u=r.authResponse.accessToken,f={fbDetails:{Token:u,ReturnUrl:redirectURL,UserAgentDetails:typeof UserAgentHelper!="undefined"&&UserAgentHelper.userAgentDetails?UserAgentHelper.userAgentDetails():{}},flowDetails:{ExpertID:n,CategoryID:t,IsPhone:i,LPID1:lpid1,LPID2:lpid2}};$.ajax({type:"POST",url:UriHelper.addLocationContext("/WebServices/Ajax/SocialNetworkRegistrationService.svc/FacebookConnect"),data:JSON.stringify(f),dataType:"json",contentType:"application/json; charset=utf-8",success:FacebookSDK.OnComplete,error:FacebookSDK.OnFail})}else $.colorbox.close(),console.warn("User cancelled login or did not fully authorize.")},{scope:"email"})}},FacebookSDK={ReturnUrl:"",OnSuccessUrl:"/",pageId:null,RegistrationStatus:{Success:0,InvalidUsername:1,InvalidPassword:2,InvalidScreenName:3,CountryEmbargo:4,Failure:5,AlreadySignedIn:6,InvalidCreditCard:7},OnComplete:function(n){var t=n.Status,i;t==FacebookSDK.RegistrationStatus.Success?(i={event:"facebookconnectbutton"},dataLayer.push(i),FacebookSDK.ReturnUrl=n.ReturnUrl,RenderPixelTrackingRegisterWithCallback(n.UserID,0,"FacebookSDK.PixelFired")):t==FacebookSDK.RegistrationStatus.AlreadySignedIn?window.location.href=FacebookSDK.OnSuccessUrl:SignUpSDK.EnableSubmit()},OnFail:function(n){Logger.Error("FacebookConnect error | (data = "+JSON.stringify(n)+")"),$.colorbox.close()},PixelFired:function(){window.location.href=FacebookSDK.OnSuccessUrl},doPostBack:function(n){FacebookSDK.pageId==null?Logger.Error("FacebookConnect error, FacebookSDK.pageId is null"):__doPostBack(pageId,n)}},AppleConnect={AppleLogout:function(n){window.location.href=n},AppleClick:function(){var n=$("#AppleConnectLightBox").html();$.colorbox({html:n,close:"",fastIframe:!0,scrolling:!1,transition:"none",top:"1px",open:!0,top:40}),document.getElementById("appleid-signin").click()},AppleLoginInit:function(n){AppleSDK.OnSuccessUrl=n,AppleID.auth.init({clientId:"com.kasamba.web",scope:"name email",redirectURI:"https://www.kasamba.com/",state:"[STATE]",usePopup:!0}),document.addEventListener("AppleIDSignInOnSuccess",function(n){try{var t=n.detail.authorization.code,i=n.detail.authorization.id_token,r=n.detail.user&&n.detail.user.email,u=n.detail.user&&n.detail.user.name.firstName,f=n.detail.user&&n.detail.user.name.lastName,e={appleDetails:{State:"state",Token:i,ReturnUrl:"/",Code:t,Email:r,FirstName:u,LastName:f,UserAgentDetails:typeof UserAgentHelper!="undefined"&&UserAgentHelper.userAgentDetails?UserAgentHelper.userAgentDetails():{}}};$.ajax({type:"POST",url:UriHelper.addLocationContext("/WebServices/Ajax/SocialNetworkRegistrationService.svc/AppleConnect"),data:JSON.stringify(e),dataType:"json",contentType:"application/json; charset=utf-8",success:AppleSDK.OnComplete,error:AppleSDK.OnFail})}catch(o){$.colorbox.close(),console.error(n),console.error(o)}}),document.addEventListener("AppleIDSignInOnFailure",function(){$.colorbox.close()})}},AppleSDK={ReturnUrl:"",OnSuccessUrl:"/",pageId:null,RegistrationStatus:{Success:0,InvalidUsername:1,InvalidPassword:2,InvalidScreenName:3,CountryEmbargo:4,Failure:5,AlreadySignedIn:6,InvalidCreditCard:7},OnComplete:function(n){var t=n.Status,i;t==AppleSDK.RegistrationStatus.Success?(i={event:"appleconnectbutton"},dataLayer.push(i),AppleSDK.ReturnUrl=n.ReturnUrl,RenderPixelTrackingRegisterWithCallback(n.UserID,0,"AppleSDK.PixelFired")):t==AppleSDK.RegistrationStatus.AlreadySignedIn?window.location.href=AppleSDK.OnSuccessUrl:SignUpSDK&&SignUpSDK.EnableSubmit()},OnFail:function(n){Logger.Error("AppleConnect error | (data = "+JSON.stringify(n)+")"),$.colorbox.close()},PixelFired:function(){window.location.href=AppleSDK.OnSuccessUrl},doPostBack:function(n){AppleSDK.pageId==null?Logger.Error("AppleConnect error, AppleSDK.pageId is null"):__doPostBack(pageId,n)}},GoogleConnect={Mode:"popup",TokenClient:null,CodeClient:null,GoogleLoginInit:function(n){GoogleSDK.OnSuccessUrl=n,this.InitClients()},InitClients:function(){GoogleConnect.TokenClient=google.accounts.oauth2.initTokenClient({client_id:GoogleSDK.ClientId,scope:"https://www.googleapis.com/auth/userinfo.email                     https://www.googleapis.com/auth/userinfo.profile",callback:function(n){if(n.error)return console.error(n.error);GoogleConnect.SignInCallback(n)},error_callback:function(n){n.type=="popup_failed_to_open"&&(GoogleConnect.Mode="redirect",GoogleConnect.GoogleClick())}}),GoogleConnect.CodeClient=google.accounts.oauth2.initCodeClient({client_id:GoogleSDK.ClientId,scope:"email profile",ux_mode:"redirect",state:GoogleConnect.GetState(),redirect_uri:GoogleSDK.RedirectUrl})},GoogleLogout:function(n){window.location.href=n},GoogleClick:function(){this.Mode=="popup"?this.TokenClient.requestAccessToken():this.Mode=="redirect"&&this.CodeClient.requestCode()},GetState:function(){if(URI){var n=URI.parseQuery(new URI(location.href).query());if(n){if(n.QS)return"?QS="+n.QS;if(n.returnUrl)return"?returnUrl="+n.returnUrl}}return""},SignInCallback:function(n){if(n)try{var t={googleDetails:{State:"state",Token:n.access_token,ReturnUrl:"/",UserAgentDetails:typeof UserAgentHelper!="undefined"&&UserAgentHelper.userAgentDetails?UserAgentHelper.userAgentDetails():{}}};$.ajax({type:"POST",url:UriHelper.addLocationContext(GoogleSDK.RegistrationServiceUrl),data:JSON.stringify(t),dataType:"json",contentType:"application/json; charset=utf-8",success:GoogleSDK.OnComplete,error:GoogleSDK.OnFail})}catch(i){console.error(data),console.error(i)}}},GoogleSDK={ReturnUrl:"",OnSuccessUrl:"/",pageId:null,ClientId:"",RedirectUrl:"",RegistrationServiceUrl:"",RegistrationStatus:{Success:0,InvalidUsername:1,InvalidPassword:2,InvalidScreenName:3,CountryEmbargo:4,Failure:5,AlreadySignedIn:6,InvalidCreditCard:7},OnComplete:function(n){var t=n.Status,i;t==GoogleSDK.RegistrationStatus.Success?(i={event:"googleconnectbutton"},dataLayer.push(i),GoogleSDK.ReturnUrl=n.ReturnUrl,RenderPixelTrackingRegisterWithCallback(n.UserID,0,"GoogleSDK.PixelFired")):t==GoogleSDK.RegistrationStatus.AlreadySignedIn?window.location.href=GoogleSDK.OnSuccessUrl:SignUpSDK&&SignUpSDK.EnableSubmit()},OnFail:function(n){Logger.Error("GoogleConnect error | (data = "+JSON.stringify(n)+")")},PixelFired:function(){window.location.href=GoogleSDK.OnSuccessUrl},doPostBack:function(n){GoogleSDK.pageId==null?Logger.Error("GoogleConnect error, GoogleSDK.pageId is null"):__doPostBack(pageId,n)}}