/*! URI.js v1.8.3 http://medialize.github.com/URI.js/ */
/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js, jquery.URI.js */
(function(f,h){"object"===typeof exports?module.exports=h():"function"===typeof define&&define.amd?define(h):f.IPv6=h()})(this,function(){return{best:function(f){f=f.toLowerCase().split(":");var h=f.length,j=8;""===f[0]&&""===f[1]&&""===f[2]?(f.shift(),f.shift()):""===f[0]&&""===f[1]?f.shift():""===f[h-1]&&""===f[h-2]&&f.pop();h=f.length;-1!==f[h-1].indexOf(".")&&(j=7);var d;for(d=0;d<h&&""!==f[d];d++);if(d<j)for(f.splice(d,1,"0000");f.length<j;)f.splice(d,0,"0000");for(d=0;d<j;d++){for(var h=f[d].split(""),
l=0;3>l;l++)if("0"===h[0]&&1<h.length)h.splice(0,1);else break;f[d]=h.join("")}var h=-1,u=l=0,k=-1,b=!1;for(d=0;d<j;d++)b?"0"===f[d]?u+=1:(b=!1,u>l&&(h=k,l=u)):"0"==f[d]&&(b=!0,k=d,u=1);u>l&&(h=k,l=u);1<l&&f.splice(h,l,"");h=f.length;j="";""===f[0]&&(beststr=":");for(d=0;d<h;d++){j+=f[d];if(d===h-1)break;j+=":"}""===f[h-1]&&(j+=":");return j}}});
(function(f){function h(a){throw RangeError(D[a]);}function j(a,c){for(var e=a.length;e--;)a[e]=c(a[e]);return a}function d(a){for(var c=[],e=0,d=a.length,t,b;e<d;)t=a.charCodeAt(e++),55296==(t&63488)&&e<d?(b=a.charCodeAt(e++),56320==(b&64512)?c.push(((t&1023)<<10)+(b&1023)+65536):c.push(t,b)):c.push(t);return c}function l(a){return j(a,function(a){var c="";65535<a&&(a-=65536,c+=z(a>>>10&1023|55296),a=56320|a&1023);return c+=z(a)}).join("")}function u(e,d,t){var b=0;e=t?w(e/c):e>>1;for(e+=w(e/d);e>
x*s>>1;b+=n)e=w(e/x);return w(b+(x+1)*e/(e+a))}function k(a){var c=[],d=a.length,b,g=0,f=t,k=e,m,v,q,j,r;m=a.lastIndexOf(C);0>m&&(m=0);for(v=0;v<m;++v)128<=a.charCodeAt(v)&&h("not-basic"),c.push(a.charCodeAt(v));for(m=0<m?m+1:0;m<d;){v=g;b=1;for(q=n;;q+=n){m>=d&&h("invalid-input");j=a.charCodeAt(m++);j=10>j-48?j-22:26>j-65?j-65:26>j-97?j-97:n;(j>=n||j>w((p-g)/b))&&h("overflow");g+=j*b;r=q<=k?A:q>=k+s?s:q-k;if(j<r)break;j=n-r;b>w(p/j)&&h("overflow");b*=j}b=c.length+1;k=u(g-v,b,0==v);w(g/b)>p-f&&h("overflow");
f+=w(g/b);g%=b;c.splice(g++,0,f)}return l(c)}function b(a){var c,b,g,f,m,k,v,j,q,r=[],l,y,x;a=d(a);l=a.length;c=t;b=0;m=e;for(k=0;k<l;++k)q=a[k],128>q&&r.push(z(q));for((g=f=r.length)&&r.push(C);g<l;){v=p;for(k=0;k<l;++k)q=a[k],q>=c&&q<v&&(v=q);y=g+1;v-c>w((p-b)/y)&&h("overflow");b+=(v-c)*y;c=v;for(k=0;k<l;++k)if(q=a[k],q<c&&++b>p&&h("overflow"),q==c){j=b;for(v=n;;v+=n){q=v<=m?A:v>=m+s?s:v-m;if(j<q)break;x=j-q;j=n-q;r.push(z(q+x%j+22+75*(26>q+x%j)-0));j=w(x/j)}r.push(z(j+22+75*(26>j)-0));m=u(b,y,
g==f);b=0;++g}++b;++c}return r.join("")}var q,r="function"==typeof define&&"object"==typeof define.amd&&define.amd&&define,g="object"==typeof exports&&exports,m="object"==typeof module&&module,p=2147483647,n=36,A=1,s=26,a=38,c=700,e=72,t=128,C="-",v=/[^ -~]/,y=/^xn--/,D={overflow:"Overflow: input needs wider integers to process.","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=n-A,w=Math.floor,z=String.fromCharCode,B;q={version:"1.1.1",ucs2:{decode:d,
encode:l},decode:k,encode:b,toASCII:function(a){return j(a.split("."),function(a){return v.test(a)?"xn--"+b(a):a}).join(".")},toUnicode:function(a){return j(a.split("."),function(a){return y.test(a)?k(a.slice(4).toLowerCase()):a}).join(".")}};if(g)if(m&&m.exports==g)m.exports=q;else for(B in q)q.hasOwnProperty(B)&&(g[B]=q[B]);else r?define("punycode",q):f.punycode=q})(this);
(function(f,h){"object"===typeof exports?module.exports=h():"function"===typeof define&&define.amd?define(h):f.SecondLevelDomains=h()})(this,function(){var f=Object.prototype.hasOwnProperty,h={list:{ac:"com|gov|mil|net|org",ae:"ac|co|gov|mil|name|net|org|pro|sch",af:"com|edu|gov|net|org",al:"com|edu|gov|mil|net|org",ao:"co|ed|gv|it|og|pb",ar:"com|edu|gob|gov|int|mil|net|org|tur",at:"ac|co|gv|or",au:"asn|com|csiro|edu|gov|id|net|org",ba:"co|com|edu|gov|mil|net|org|rs|unbi|unmo|unsa|untz|unze",bb:"biz|co|com|edu|gov|info|net|org|store|tv",
bh:"biz|cc|com|edu|gov|info|net|org",bn:"com|edu|gov|net|org",bo:"com|edu|gob|gov|int|mil|net|org|tv",br:"adm|adv|agr|am|arq|art|ato|b|bio|blog|bmd|cim|cng|cnt|com|coop|ecn|edu|eng|esp|etc|eti|far|flog|fm|fnd|fot|fst|g12|ggf|gov|imb|ind|inf|jor|jus|lel|mat|med|mil|mus|net|nom|not|ntr|odo|org|ppg|pro|psc|psi|qsl|rec|slg|srv|tmp|trd|tur|tv|vet|vlog|wiki|zlg",bs:"com|edu|gov|net|org",bz:"du|et|om|ov|rg",ca:"ab|bc|mb|nb|nf|nl|ns|nt|nu|on|pe|qc|sk|yk",ck:"biz|co|edu|gen|gov|info|net|org",cn:"ac|ah|bj|com|cq|edu|fj|gd|gov|gs|gx|gz|ha|hb|he|hi|hl|hn|jl|js|jx|ln|mil|net|nm|nx|org|qh|sc|sd|sh|sn|sx|tj|tw|xj|xz|yn|zj",
co:"com|edu|gov|mil|net|nom|org",cr:"ac|c|co|ed|fi|go|or|sa",cy:"ac|biz|com|ekloges|gov|ltd|name|net|org|parliament|press|pro|tm","do":"art|com|edu|gob|gov|mil|net|org|sld|web",dz:"art|asso|com|edu|gov|net|org|pol",ec:"com|edu|fin|gov|info|med|mil|net|org|pro",eg:"com|edu|eun|gov|mil|name|net|org|sci",er:"com|edu|gov|ind|mil|net|org|rochest|w",es:"com|edu|gob|nom|org",et:"biz|com|edu|gov|info|name|net|org",fj:"ac|biz|com|info|mil|name|net|org|pro",fk:"ac|co|gov|net|nom|org",fr:"asso|com|f|gouv|nom|prd|presse|tm",
gg:"co|net|org",gh:"com|edu|gov|mil|org",gn:"ac|com|gov|net|org",gr:"com|edu|gov|mil|net|org",gt:"com|edu|gob|ind|mil|net|org",gu:"com|edu|gov|net|org",hk:"com|edu|gov|idv|net|org",id:"ac|co|go|mil|net|or|sch|web",il:"ac|co|gov|idf|k12|muni|net|org","in":"ac|co|edu|ernet|firm|gen|gov|i|ind|mil|net|nic|org|res",iq:"com|edu|gov|i|mil|net|org",ir:"ac|co|dnssec|gov|i|id|net|org|sch",it:"edu|gov",je:"co|net|org",jo:"com|edu|gov|mil|name|net|org|sch",jp:"ac|ad|co|ed|go|gr|lg|ne|or",ke:"ac|co|go|info|me|mobi|ne|or|sc",
kh:"com|edu|gov|mil|net|org|per",ki:"biz|com|de|edu|gov|info|mob|net|org|tel",km:"asso|com|coop|edu|gouv|k|medecin|mil|nom|notaires|pharmaciens|presse|tm|veterinaire",kn:"edu|gov|net|org",kr:"ac|busan|chungbuk|chungnam|co|daegu|daejeon|es|gangwon|go|gwangju|gyeongbuk|gyeonggi|gyeongnam|hs|incheon|jeju|jeonbuk|jeonnam|k|kg|mil|ms|ne|or|pe|re|sc|seoul|ulsan",kw:"com|edu|gov|net|org",ky:"com|edu|gov|net|org",kz:"com|edu|gov|mil|net|org",lb:"com|edu|gov|net|org",lk:"assn|com|edu|gov|grp|hotel|int|ltd|net|ngo|org|sch|soc|web",
lr:"com|edu|gov|net|org",lv:"asn|com|conf|edu|gov|id|mil|net|org",ly:"com|edu|gov|id|med|net|org|plc|sch",ma:"ac|co|gov|m|net|org|press",mc:"asso|tm",me:"ac|co|edu|gov|its|net|org|priv",mg:"com|edu|gov|mil|nom|org|prd|tm",mk:"com|edu|gov|inf|name|net|org|pro",ml:"com|edu|gov|net|org|presse",mn:"edu|gov|org",mo:"com|edu|gov|net|org",mt:"com|edu|gov|net|org",mv:"aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro",mw:"ac|co|com|coop|edu|gov|int|museum|net|org",mx:"com|edu|gob|net|org",my:"com|edu|gov|mil|name|net|org|sch",
nf:"arts|com|firm|info|net|other|per|rec|store|web",ng:"biz|com|edu|gov|mil|mobi|name|net|org|sch",ni:"ac|co|com|edu|gob|mil|net|nom|org",np:"com|edu|gov|mil|net|org",nr:"biz|com|edu|gov|info|net|org",om:"ac|biz|co|com|edu|gov|med|mil|museum|net|org|pro|sch",pe:"com|edu|gob|mil|net|nom|org|sld",ph:"com|edu|gov|i|mil|net|ngo|org",pk:"biz|com|edu|fam|gob|gok|gon|gop|gos|gov|net|org|web",pl:"art|bialystok|biz|com|edu|gda|gdansk|gorzow|gov|info|katowice|krakow|lodz|lublin|mil|net|ngo|olsztyn|org|poznan|pwr|radom|slupsk|szczecin|torun|warszawa|waw|wroc|wroclaw|zgora",
pr:"ac|biz|com|edu|est|gov|info|isla|name|net|org|pro|prof",ps:"com|edu|gov|net|org|plo|sec",pw:"belau|co|ed|go|ne|or",ro:"arts|com|firm|info|nom|nt|org|rec|store|tm|www",rs:"ac|co|edu|gov|in|org",sb:"com|edu|gov|net|org",sc:"com|edu|gov|net|org",sh:"co|com|edu|gov|net|nom|org",sl:"com|edu|gov|net|org",st:"co|com|consulado|edu|embaixada|gov|mil|net|org|principe|saotome|store",sv:"com|edu|gob|org|red",sz:"ac|co|org",tr:"av|bbs|bel|biz|com|dr|edu|gen|gov|info|k12|name|net|org|pol|tel|tsk|tv|web",tt:"aero|biz|cat|co|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel",
tw:"club|com|ebiz|edu|game|gov|idv|mil|net|org",mu:"ac|co|com|gov|net|or|org",mz:"ac|co|edu|gov|org",na:"co|com",nz:"ac|co|cri|geek|gen|govt|health|iwi|maori|mil|net|org|parliament|school",pa:"abo|ac|com|edu|gob|ing|med|net|nom|org|sld",pt:"com|edu|gov|int|net|nome|org|publ",py:"com|edu|gov|mil|net|org",qa:"com|edu|gov|mil|net|org",re:"asso|com|nom",ru:"ac|adygeya|altai|amur|arkhangelsk|astrakhan|bashkiria|belgorod|bir|bryansk|buryatia|cbg|chel|chelyabinsk|chita|chukotka|chuvashia|com|dagestan|e-burg|edu|gov|grozny|int|irkutsk|ivanovo|izhevsk|jar|joshkar-ola|kalmykia|kaluga|kamchatka|karelia|kazan|kchr|kemerovo|khabarovsk|khakassia|khv|kirov|koenig|komi|kostroma|kranoyarsk|kuban|kurgan|kursk|lipetsk|magadan|mari|mari-el|marine|mil|mordovia|mosreg|msk|murmansk|nalchik|net|nnov|nov|novosibirsk|nsk|omsk|orenburg|org|oryol|penza|perm|pp|pskov|ptz|rnd|ryazan|sakhalin|samara|saratov|simbirsk|smolensk|spb|stavropol|stv|surgut|tambov|tatarstan|tom|tomsk|tsaritsyn|tsk|tula|tuva|tver|tyumen|udm|udmurtia|ulan-ude|vladikavkaz|vladimir|vladivostok|volgograd|vologda|voronezh|vrn|vyatka|yakutia|yamal|yekaterinburg|yuzhno-sakhalinsk",
rw:"ac|co|com|edu|gouv|gov|int|mil|net",sa:"com|edu|gov|med|net|org|pub|sch",sd:"com|edu|gov|info|med|net|org|tv",se:"a|ac|b|bd|c|d|e|f|g|h|i|k|l|m|n|o|org|p|parti|pp|press|r|s|t|tm|u|w|x|y|z",sg:"com|edu|gov|idn|net|org|per",sn:"art|com|edu|gouv|org|perso|univ",sy:"com|edu|gov|mil|net|news|org",th:"ac|co|go|in|mi|net|or",tj:"ac|biz|co|com|edu|go|gov|info|int|mil|name|net|nic|org|test|web",tn:"agrinet|com|defense|edunet|ens|fin|gov|ind|info|intl|mincom|nat|net|org|perso|rnrt|rns|rnu|tourism",tz:"ac|co|go|ne|or",
ua:"biz|cherkassy|chernigov|chernovtsy|ck|cn|co|com|crimea|cv|dn|dnepropetrovsk|donetsk|dp|edu|gov|if|in|ivano-frankivsk|kh|kharkov|kherson|khmelnitskiy|kiev|kirovograd|km|kr|ks|kv|lg|lugansk|lutsk|lviv|me|mk|net|nikolaev|od|odessa|org|pl|poltava|pp|rovno|rv|sebastopol|sumy|te|ternopil|uzhgorod|vinnica|vn|zaporizhzhe|zhitomir|zp|zt",ug:"ac|co|go|ne|or|org|sc",uk:"ac|bl|british-library|co|cym|gov|govt|icnet|jet|lea|ltd|me|mil|mod|national-library-scotland|nel|net|nhs|nic|nls|org|orgn|parliament|plc|police|sch|scot|soc",
us:"dni|fed|isa|kids|nsn",uy:"com|edu|gub|mil|net|org",ve:"co|com|edu|gob|info|mil|net|org|web",vi:"co|com|k12|net|org",vn:"ac|biz|com|edu|gov|health|info|int|name|net|org|pro",ye:"co|com|gov|ltd|me|net|org|plc",yu:"ac|co|edu|gov|org",za:"ac|agric|alt|bourse|city|co|cybernet|db|edu|gov|grondar|iaccess|imt|inca|landesign|law|mil|net|ngo|nis|nom|olivetti|org|pix|school|tm|web",zm:"ac|co|com|edu|gov|net|org|sch"},has_expression:null,is_expression:null,has:function(f){return!!f.match(h.has_expression)},
is:function(f){return!!f.match(h.is_expression)},get:function(f){return(f=f.match(h.has_expression))&&f[1]||null},init:function(){var j="",d;for(d in h.list)f.call(h.list,d)&&(j+="|("+("("+h.list[d]+")."+d)+")");h.has_expression=RegExp("\\.("+j.substr(1)+")$","i");h.is_expression=RegExp("^("+j.substr(1)+")$","i")}};h.init();return h});
(function(f,h){"object"===typeof exports?module.exports=h(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],h):f.URI=h(f.punycode,f.IPv6,f.SecondLevelDomains)})(this,function(f,h,j){function d(a,c){if(!(this instanceof d))return new d(a,c);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==c?this.absoluteTo(c):this}function l(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,
"\\$1")}function u(a){return"[object Array]"===String(Object.prototype.toString.call(a))}function k(a){return encodeURIComponent(a).replace(/[!'()*]/g,escape).replace(/\*/g,"%2A")}var b=d.prototype,q=Object.prototype.hasOwnProperty;d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:d.duplicateQueryParameters}};d.duplicateQueryParameters=!1;d.protocol_expression=/^[a-z][a-z0-9-+-]*$/i;d.idn_expression=
/[^a-z0-9\.-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;d.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*$/;
d.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;d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;d.encode=k;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=
k;d.decode=decodeURIComponent};d.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":"="}}}};d.encodeQuery=function(a){return d.encode(a+"").replace(/%20/g,"+")};d.decodeQuery=function(a){return d.decode((a+"").replace(/\+/g,"%20"))};d.recodePath=function(a){a=(a+"").split("/");for(var c=0,e=a.length;c<e;c++)a[c]=d.encodePathSegment(d.decode(a[c]));return a.join("/")};d.decodePath=function(a){a=(a+"").split("/");for(var c=0,e=a.length;c<e;c++)a[c]=d.decodePathSegment(a[c]);return a.join("/")};var r={encode:"encode",decode:"decode"},g,m=function(a,c){return function(e){return d[c](e+
"").replace(d.characters[a][c].expression,function(e){return d.characters[a][c].map[e]})}};for(g in r)d[g+"PathSegment"]=m("pathname",r[g]);d.encodeReserved=m("reserved","encode");d.parse=function(a,c){var e;c||(c={});e=a.indexOf("#");-1<e&&(c.fragment=a.substring(e+1)||null,a=a.substring(0,e));e=a.indexOf("?");-1<e&&(c.query=a.substring(e+1)||null,a=a.substring(0,e));"//"===a.substring(0,2)?(c.protocol="",a=a.substring(2),a=d.parseAuthority(a,c)):(e=a.indexOf(":"),-1<e&&(c.protocol=a.substring(0,
e),c.protocol&&!c.protocol.match(d.protocol_expression)?c.protocol=void 0:"file"===c.protocol?a=a.substring(e+3):"//"===a.substring(e+1,e+3)?(a=a.substring(e+3),a=d.parseAuthority(a,c)):(a=a.substring(e+1),c.urn=!0)));c.path=a;return c};d.parseHost=function(a,c){var e=a.indexOf("/"),d;-1===e&&(e=a.length);"["===a[0]?(d=a.indexOf("]"),c.hostname=a.substring(1,d)||null,c.port=a.substring(d+2,e)||null):a.indexOf(":")!==a.lastIndexOf(":")?(c.hostname=a.substring(0,e)||null,c.port=null):(d=a.substring(0,
e).split(":"),c.hostname=d[0]||null,c.port=d[1]||null);c.hostname&&"/"!==a.substring(e)[0]&&(e++,a="/"+a);return a.substring(e)||"/"};d.parseAuthority=function(a,c){a=d.parseUserinfo(a,c);return d.parseHost(a,c)};d.parseUserinfo=function(a,c){var e=a.indexOf("@"),t=a.indexOf("/");-1<e&&(-1===t||e<t)?(t=a.substring(0,e).split(":"),c.username=t[0]?d.decode(t[0]):null,t.shift(),c.password=t[0]?d.decode(t.join(":")):null,a=a.substring(e+1)):(c.username=null,c.password=null);return a};d.parseQuery=function(a){if(!a)return{};
a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};var c={};a=a.split("&");for(var e=a.length,t,b,g=0;g<e;g++)t=a[g].split("="),b=d.decodeQuery(t.shift()),t=t.length?d.decodeQuery(t.join("=")):null,c[b]?("string"===typeof c[b]&&(c[b]=[c[b]]),c[b].push(t)):c[b]=t;return c};d.build=function(a){var c="";a.protocol&&(c+=a.protocol+":");if(!a.urn&&(c||a.hostname))c+="//";c+=d.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path[0]&&"string"===typeof a.hostname&&(c+="/"),c+=a.path);
"string"===typeof a.query&&a.query&&(c+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(c+="#"+a.fragment);return c};d.buildHost=function(a){var c="";if(a.hostname)d.ip6_expression.test(a.hostname)?c=a.port?c+("["+a.hostname+"]:"+a.port):c+a.hostname:(c+=a.hostname,a.port&&(c+=":"+a.port));else return"";return c};d.buildAuthority=function(a){return d.buildUserinfo(a)+d.buildHost(a)};d.buildUserinfo=function(a){var c="";a.username&&(c+=d.encode(a.username),a.password&&(c+=":"+d.encode(a.password)),
c+="@");return c};d.buildQuery=function(a,c){var e="",b,g,f,k;for(g in a)if(q.call(a,g)&&g)if(u(a[g])){b={};f=0;for(k=a[g].length;f<k;f++)void 0!==a[g][f]&&void 0===b[a[g][f]+""]&&(e+="&"+d.buildQueryParameter(g,a[g][f]),!0!==c&&(b[a[g][f]+""]=!0))}else void 0!==a[g]&&(e+="&"+d.buildQueryParameter(g,a[g]));return e.substring(1)};d.buildQueryParameter=function(a,c){return d.encodeQuery(a)+(null!==c?"="+d.encodeQuery(c):"")};d.addQuery=function(a,c,e){if("object"===typeof c)for(var b in c)q.call(c,
b)&&d.addQuery(a,b,c[b]);else if("string"===typeof c)void 0===a[c]?a[c]=e:("string"===typeof a[c]&&(a[c]=[a[c]]),u(e)||(e=[e]),a[c]=a[c].concat(e));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,c,e){var b;if(u(c)){e=0;for(b=c.length;e<b;e++)a[c[e]]=void 0}else if("object"===typeof c)for(b in c)q.call(c,b)&&d.removeQuery(a,b,c[b]);else if("string"===typeof c)if(void 0!==e)if(a[c]===e)a[c]=void 0;else{if(u(a[c])){b=a[c];var g={},
f,k;if(u(e)){f=0;for(k=e.length;f<k;f++)g[e[f]]=!0}else g[e]=!0;f=0;for(k=b.length;f<k;f++)void 0!==g[b[f]]&&(b.splice(f,1),k--,f--);a[c]=b}}else a[c]=void 0;else throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");};d.commonPath=function(a,c){var e=Math.min(a.length,c.length),d;for(d=0;d<e;d++)if(a[d]!==c[d]){d--;break}if(1>d)return a[0]===c[0]&&"/"===a[0]?"/":"";"/"!==a[d]&&(d=a.substring(0,d).lastIndexOf("/"));return a.substring(0,d+1)};d.withinString=function(a,
c){return a.replace(d.find_uri_expression,c)};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!f)throw new TypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-] and Punycode.js is not available");if(f.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError("Hostname '"+a+"' contains characters other than [A-Z0-9.-]");}};b.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),
this._deferred_build=!1;return this};b.clone=function(){return new d(this)};b.valueOf=b.toString=function(){return this.build(!1)._string};r={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};m=function(a){return function(c,e){if(void 0===c)return this._parts[a]||"";this._parts[a]=c;this.build(!e);return this}};for(g in r)b[g]=m(r[g]);r={query:"?",fragment:"#"};m=function(a,c){return function(e,d){if(void 0===e)return this._parts[a]||"";null!==e&&(e+="",
e[0]===c&&(e=e.substring(1)));this._parts[a]=e;this.build(!d);return this}};for(g in r)b[g]=m(g,r[g]);r={search:["?","query"],hash:["#","fragment"]};m=function(a,c){return function(e,d){var b=this[a](e,d);return"string"===typeof b&&b.length?c+b:b}};for(g in r)b[g]=m(r[g][1],r[g][0]);b.pathname=function(a,c){if(void 0===a||!0===a){var e=this._parts.path||(this._parts.urn?"":"/");return a?d.decodePath(e):e}this._parts.path=a?d.recodePath(a):"/";this.build(!c);return this};b.path=b.pathname;b.href=function(a,
c){var e;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var b=a instanceof d,g="object"===typeof a&&(a.hostname||a.path);!b&&(g&&"[object Object]"!==Object.prototype.toString.call(a))&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(b||g)for(e in b=b?a._parts:a,b)q.call(this._parts,e)&&(this._parts[e]=b[e]);else throw new TypeError("invalid input");this.build(!c);return this};b.is=function(a){var c=!1,e=!1,b=!1,g=!1,f=!1,k=!1,m=!1,h=
!this._parts.urn;this._parts.hostname&&(h=!1,e=d.ip4_expression.test(this._parts.hostname),b=d.ip6_expression.test(this._parts.hostname),c=e||b,f=(g=!c)&&j&&j.has(this._parts.hostname),k=g&&d.idn_expression.test(this._parts.hostname),m=g&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return h;case "absolute":return!h;case "domain":case "name":return g;case "sld":return f;case "ip":return c;case "ip4":case "ipv4":case "inet4":return e;case "ip6":case "ipv6":case "inet6":return b;
case "idn":return k;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return m}return null};var p=b.protocol,n=b.port,A=b.hostname;b.protocol=function(a,c){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),a.match(/[^a-zA-z0-9\.+-]/)))throw new TypeError("Protocol '"+a+"' contains characters other than [A-Z0-9.+-]");return p.call(this,a,c)};b.scheme=b.protocol;b.port=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",
":"===a[0]&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError("Port '"+a+"' contains characters other than [0-9]");return n.call(this,a,c)};b.hostname=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var e={};d.parseHost(a,e);a=e.hostname}return A.call(this,a,c)};b.host=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!c);return this};b.authority=
function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!c);return this};b.userinfo=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var e=d.buildUserinfo(this._parts);return e.substring(0,e.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!c);return this};b.resource=function(a,c){var e;
if(void 0===a)return this.path()+this.search()+this.hash();e=d.parse(a);this._parts.path=e.path;this._parts.query=e.query;this._parts.fragment=e.fragment;this.build(!c);return this};b.subdomain=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,e)||""}e=this._parts.hostname.length-this.domain().length;e=this._parts.hostname.substring(0,
e);e=RegExp("^"+l(e));a&&"."!==a[a.length-1]&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(e,a);this.build(!c);return this};b.domain=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.match(/\./g);if(e&&2>e.length)return this._parts.hostname;e=this._parts.hostname.length-this.tld(c).length-1;e=this._parts.hostname.lastIndexOf(".",
e-1)+1;return this._parts.hostname.substring(e)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(e=RegExp(l(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(e,a));this.build(!c);return this};b.tld=function(a,c){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(c=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var e=this._parts.hostname.lastIndexOf("."),
e=this._parts.hostname.substring(e+1);return!0!==c&&j&&j.list[e.toLowerCase()]?j.get(this._parts.hostname)||e:e}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(j&&j.is(a))e=RegExp(l(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(e,a);else throw new TypeError("TLD '"+a+"' 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");e=RegExp(l(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(e,
a)}else throw new TypeError("cannot set TLD empty");this.build(!c);return this};b.directory=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var e=this._parts.path.length-this.filename().length-1,e=this._parts.path.substring(0,e)||(this._parts.hostname?"/":"");return a?d.decodePath(e):e}e=this._parts.path.length-this.filename().length;e=this._parts.path.substring(0,e);e=RegExp("^"+
l(e));this.is("relative")||(a||(a="/"),"/"!==a[0]&&(a="/"+a));a&&"/"!==a[a.length-1]&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);this.build(!c);return this};b.filename=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var e=this._parts.path.lastIndexOf("/"),e=this._parts.path.substring(e+1);return a?d.decodePathSegment(e):e}e=!1;"/"===a[0]&&(a=a.substring(1));a.match(/\.?\//)&&(e=!0);
var b=RegExp(l(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(b,a);e?this.normalizePath(c):this.build(!c);return this};b.suffix=function(a,c){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var e=this.filename(),b=e.lastIndexOf(".");if(-1===b)return"";e=e.substring(b+1);e=/^[a-z0-9%]+$/i.test(e)?e:"";return a?d.decodePathSegment(e):e}"."===a[0]&&(a=a.substring(1));if(e=this.suffix())b=a?RegExp(l(e)+
"$"):RegExp(l("."+e)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}b&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(b,a));this.build(!c);return this};b.segment=function(a,c,e){var d=this._parts.urn?":":"/",b=this.path(),g="/"===b.substring(0,1),b=b.split(d);"number"!==typeof a&&(e=c,c=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error("Bad segment '"+a+"', must be 0-based integer");g&&b.shift();0>a&&(a=Math.max(b.length+a,0));if(void 0===c)return void 0===
a?b:b[a];if(null===a||void 0===b[a])if(u(c))b=c;else{if(c||"string"===typeof c&&c.length)""===b[b.length-1]?b[b.length-1]=c:b.push(c)}else c||"string"===typeof c&&c.length?b[a]=c:b.splice(a,1);g&&b.unshift("");return this.path(b.join(d),e)};var s=b.query;b.query=function(a,c){return!0===a?d.parseQuery(this._parts.query):void 0!==a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters),this.build(!c),this):s.call(this,a,c)};b.addQuery=function(a,c,e){var b=d.parseQuery(this._parts.query);
d.addQuery(b,a,void 0===c?null:c);this._parts.query=d.buildQuery(b,this._parts.duplicateQueryParameters);"string"!==typeof a&&(e=c);this.build(!e);return this};b.removeQuery=function(a,c,e){var b=d.parseQuery(this._parts.query);d.removeQuery(b,a,c);this._parts.query=d.buildQuery(b,this._parts.duplicateQueryParameters);"string"!==typeof a&&(e=c);this.build(!e);return this};b.addSearch=b.addQuery;b.removeSearch=b.removeQuery;b.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():
this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};b.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};b.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&h&&(this._parts.hostname=h.best(this._parts.hostname)),this._parts.hostname=
this._parts.hostname.toLowerCase(),this.build(!a));return this};b.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};b.normalizePath=function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var c,e,b=this._parts.path,g,f;"/"!==b[0]&&("."===b[0]&&(e=b.substring(0,b.indexOf("/"))),c=!0,b="/"+b);for(b=b.replace(/(\/(\.\/)+)|\/{2,}/g,"/");;){g=b.indexOf("/../");
if(-1===g)break;else if(0===g){b=b.substring(3);break}f=b.substring(0,g).lastIndexOf("/");-1===f&&(f=g);b=b.substring(0,f)+b.substring(g+3)}c&&this.is("relative")&&(b=e?e+b:b.substring(1));b=d.recodePath(b);this._parts.path=b;this.build(!a);return this};b.normalizePathname=b.normalizePath;b.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query)):this._parts.query=null,this.build(!a));return this};b.normalizeFragment=function(a){this._parts.fragment||
(this._parts.fragment=null,this.build(!a));return this};b.normalizeSearch=b.normalizeQuery;b.normalizeHash=b.normalizeFragment;b.iso8859=function(){var a=d.encode,c=d.decode;d.encode=escape;d.decode=decodeURIComponent;this.normalize();d.encode=a;d.decode=c;return this};b.unicode=function(){var a=d.encode,c=d.decode;d.encode=k;d.decode=unescape;this.normalize();d.encode=a;d.decode=c;return this};b.readable=function(){var a=this.clone();a.username("").password("").normalize();var c="";a._parts.protocol&&
(c+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(c+=f.toUnicode(a._parts.hostname),a._parts.port&&(c+=":"+a._parts.port)):c+=a.host());a._parts.hostname&&(a._parts.path&&"/"!==a._parts.path[0])&&(c+="/");c+=a.path(!0);if(a._parts.query){for(var b="",g=0,k=a._parts.query.split("&"),h=k.length;g<h;g++){var m=(k[g]||"").split("="),b=b+("&"+d.decodeQuery(m[0]).replace(/&/g,"%26"));void 0!==m[1]&&(b+="="+d.decodeQuery(m[1]).replace(/&/g,"%26"))}c+="?"+b.substring(1)}return c+=a.hash()};
b.absoluteTo=function(a){var c=this.clone(),b=["protocol","username","password","hostname","port"],g,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierachical components");if(this._parts.hostname)return c;a instanceof d||(a=new d(a));g=0;for(f;f=b[g];g++)c._parts[f]=a._parts[f];b=["query","path"];g=0;for(f;f=b[g];g++)!c._parts[f]&&a._parts[f]&&(c._parts[f]=a._parts[f]);"/"!==c.path()[0]&&(a=a.directory(),c._parts.path=(a?a+"/":"")+c._parts.path,c.normalizePath());c.build();
return c};b.relativeTo=function(a){var c=this.clone(),b=["protocol","username","password","hostname","port"],g;if(this._parts.urn)throw Error("URNs do not have any generally defined hierachical components");a instanceof d||(a=new d(a));if("/"!==this.path()[0]||"/"!==a.path()[0])throw Error("Cannot calculate common path from non-relative URLs");g=d.commonPath(c.path(),a.path());if(!g||"/"===g)return c;for(var f=0,k;k=b[f];f++)c._parts[k]=null;a=a.directory();b=this.directory();if(a===b)return c._parts.path=
"./"+c.filename(),c.build();a.substring(g.length);b=b.substring(g.length);if(a+"/"===g)return b&&(b+="/"),c._parts.path="./"+b+c.filename(),c.build();b="../";g=RegExp("^"+l(g));for(a=a.replace(g,"/").match(/\//g).length-1;a--;)b+="../";c._parts.path=c._parts.path.replace(g,b);return c.build()};b.equals=function(a){var c=this.clone(),b=new d(a),g={},f={};a={};var k;c.normalize();b.normalize();if(c.toString()===b.toString())return!0;g=c.query();f=b.query();c.query("");b.query("");if(c.toString()!==
b.toString()||g.length!==f.length)return!1;g=d.parseQuery(g);f=d.parseQuery(f);for(k in g)if(q.call(g,k)){if(u(g[k])){if(!u(f[k])||g[k].length!==f[k].length)return!1;g[k].sort();f[k].sort();c=0;for(b=g[k].length;c<b;c++)if(g[k][c]!==f[k][c])return!1}else if(g[k]!==f[k])return!1;a[k]=!0}for(k in f)if(q.call(f,k)&&!a[k])return!1;return!0};b.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};return d});
(function(f,h){"object"===typeof exports?module.exports=h(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],h):f.URITemplate=h(f.URI)})(this,function(f){function h(d){if(h._cache[d])return h._cache[d];if(!(this instanceof h))return new h(d);this.expression=d;h._cache[d]=this;return this}function j(d){this.data=d;this.cache={}}var d=Object.prototype.hasOwnProperty,l=h.prototype,u={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"},"+":{prefix:"",separator:",",
named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&",separator:"&",named:!0,
empty_name_separator:!0,encode:"encode"}};h._cache={};h.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;h.VARIABLE_PATTERN=/^([^*:]+)((\*)|:(\d+))?$/;h.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_]/;h.expand=function(d,b){var f=u[d.operator],j=f.named?"Named":"Unnamed",g=d.variables,m=[],p,n,l;for(l=0;n=g[l];l++)p=b.get(n.name),p.val.length?m.push(h["expand"+j](p,f,n.explode,n.explode&&f.separator||",",n.maxlength,n.name)):p.type&&m.push("");return m.length?f.prefix+m.join(f.separator):""};h.expandNamed=
function(d,b,h,j,g,m){var p="",n=b.encode;b=b.empty_name_separator;var l=!d[n].length,s=2===d.type?"":f[n](m),a,c,e;c=0;for(e=d.val.length;c<e;c++)g?(a=f[n](d.val[c][1].substring(0,g)),2===d.type&&(s=f[n](d.val[c][0].substring(0,g)))):l?(a=f[n](d.val[c][1]),2===d.type?(s=f[n](d.val[c][0]),d[n].push([s,a])):d[n].push([void 0,a])):(a=d[n][c][1],2===d.type&&(s=d[n][c][0])),p&&(p+=j),h?p+=s+(b||a?"=":"")+a:(c||(p+=f[n](m)+(b||a?"=":"")),2===d.type&&(p+=s+","),p+=a);return p};h.expandUnnamed=function(d,
b,h,j,g){var m="",p=b.encode;b=b.empty_name_separator;var n=!d[p].length,l,s,a,c;a=0;for(c=d.val.length;a<c;a++)g?s=f[p](d.val[a][1].substring(0,g)):n?(s=f[p](d.val[a][1]),d[p].push([2===d.type?f[p](d.val[a][0]):void 0,s])):s=d[p][a][1],m&&(m+=j),2===d.type&&(l=g?f[p](d.val[a][0].substring(0,g)):d[p][a][0],m+=l,m=h?m+(b||s?"=":""):m+","),m+=s;return m};l.expand=function(d){var b="";(!this.parts||!this.parts.length)&&this.parse();d instanceof j||(d=new j(d));for(var f=0,r=this.parts.length;f<r;f++)b+=
"string"===typeof this.parts[f]?this.parts[f]:h.expand(this.parts[f],d);return b};l.parse=function(){var d=this.expression,b=h.EXPRESSION_PATTERN,f=h.VARIABLE_PATTERN,j=h.VARIABLE_NAME_PATTERN,g=[],m=0,p,n,l;for(b.lastIndex=0;;){n=b.exec(d);if(null===n){g.push(d.substring(m));break}else g.push(d.substring(m,n.index)),m=n.index+n[0].length;if(u[n[1]]){if(!n[3])throw Error('Unclosed Expression "'+n[0]+'"');}else throw Error('Unknown Operator "'+n[1]+'" in "'+n[0]+'"');p=n[2].split(",");for(var s=0,
a=p.length;s<a;s++){l=p[s].match(f);if(null===l)throw Error('Invalid Variable "'+p[s]+'" in "'+n[0]+'"');if(l[1].match(j))throw Error('Invalid Variable Name "'+l[1]+'" in "'+n[0]+'"');p[s]={name:l[1],explode:!!l[3],maxlength:l[4]&&parseInt(l[4],10)}}if(!p.length)throw Error('Expression Missing Variable(s) "'+n[0]+'"');g.push({expression:n[0],operator:n[1],variables:p})}g.length||g.push(d);this.parts=g;return this};j.prototype.get=function(f){var b=this.data,h={type:0,val:[],encode:[],encodeReserved:[]},
j;if(void 0!==this.cache[f])return this.cache[f];this.cache[f]=h;b="[object Function]"===String(Object.prototype.toString.call(b))?b(f):"[object Function]"===String(Object.prototype.toString.call(b[f]))?b[f](f):b[f];if(!(void 0===b||null===b))if("[object Array]"===String(Object.prototype.toString.call(b))){j=0;for(f=b.length;j<f;j++)void 0!==b[j]&&null!==b[j]&&h.val.push([void 0,String(b[j])]);h.val.length&&(h.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(b))){for(j in b)d.call(b,
j)&&(void 0!==b[j]&&null!==b[j])&&h.val.push([j,String(b[j])]);h.val.length&&(h.type=2)}else h.type=1,h.val.push([void 0,String(b)]);return h};f.expand=function(d,b){var j=(new h(d)).expand(b);return new f(j)};return h});
(function(f,h){"object"===typeof exports?module.exports=h(require("jquery","./URI")):"function"===typeof define&&define.amd?define(["jquery","./URI"],h):h(f.jQuery,f.URI)})(this,function(f,h){function j(b){return b.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function d(b){var d;f.each(["src","href","action"],function(f,h){return h in b?(d=h,!1):!0});return"input"===b.nodeName.toLowerCase()&&"image"!==b.type?void 0:d}function l(b,h){var j,n,l;if(!d(b)||!h)return!1;j=h.match(r);if(!j||!j[5]&&":"!==
j[2]&&!k[j[2]])return!1;l=f(b).uri();if(j[5])return l.is(j[5]);if(":"===j[2])return n=j[1].toLowerCase()+":",!k[n]?!1:k[n](l,j[4]);n=j[1].toLowerCase();return!u[n]?!1:k[j[2]](l[n](),j[4],n)}var u={},k={"=":function(b,d){return b===d},"^=":function(b,d){return!!(b+"").match(RegExp("^"+j(d),"i"))},"$=":function(b,d){return!!(b+"").match(RegExp(j(d)+"$","i"))},"*=":function(b,d,f){"directory"==f&&(b+="/");return!!(b+"").match(RegExp(j(d),"i"))},"equals:":function(b,d){return b.equals(d)},"is:":function(b,
d){return b.is(d)}};f.each("authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username".split(" "),function(b,d){u[d]=!0;f.attrHooks["uri:"+d]={get:function(b){return f(b).uri()[d]()},set:function(b,g){f(b).uri()[d](g);return g}}});var b=function(b,d){return f(b).uri().href(d).toString()};f.each(["src","href","action","uri"],function(d,h){f.attrHooks[h]={set:b}});f.attrHooks.uri.get=function(b){return f(b).uri()};
f.fn.uri=function(b){var f=this.first(),j=f.get(0),k=d(j);if(!k)throw Error('Element "'+j.nodeName+'" does not have either property: href, src, action');if(void 0!==b){var l=f.data("uri");if(l)return l.href(b);b instanceof h||(b=h(b))}else{if(b=f.data("uri"))return b;b=h(f.attr(k))}b._dom_element=j;b._dom_attribute=k;b.normalize();f.data("uri",b);return b};h.prototype.build=function(b){if(this._dom_element)this._string=h.build(this._parts),this._deferred_build=!1,this._dom_element.setAttribute(this._dom_attribute,
this._string),this._dom_element[this._dom_attribute]=this._string;else if(!0===b)this._deferred_build=!0;else if(void 0===b||this._deferred_build)this._string=h.build(this._parts),this._deferred_build=!1;return this};var q,r=/^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;q=f.expr.createPseudo?f.expr.createPseudo(function(b){return function(d){return l(d,b)}}):function(b,d,f){return l(b,f[3])};f.expr[":"].uri=q;return{}});
