(function(e){"use strict";functionr(e){vart,o;if(null===e||void0===e)return!1;if(n.isArray(e)){for(t=0;e.length>t;t+=1)if(r(e[t]))return!0;return!1}if("string"==typeofe||"number"==typeofe||"boolean"==typeofe)return!0;for(oine)if(e.hasOwnProperty(o)&&r(e[o]))return!0;return!1}varn=function(){functione(e){return"[object Array]"===Object.prototype.toString.apply(e)}functionr(e,r,n){vart,o=n;for(tine)e.hasOwnProperty(t)&&(o=r(o,e[t],t,e));returno}functionn(e,r,n){vart,o=n;for(t=0;e.length>t;t+=1)o=r(o,e[t],t,e);returno}functiont(t,o,i){returne(t)?n(t,o,i):r(t,o,i)}return{isArray:e,reduce:t}}(),t=function(){functione(e){returne>="a"&&"z">=e||e>="A"&&"Z">=e}functionr(e){returne>="0"&&"9">=e}functionn(e){returnr(e)||e>="a"&&"f">=e||e>="A"&&"F">=e}return{isAlpha:e,isDigit:r,isHexDigit:n}}(),o=function(){functione(e){varr,n,t="",o=u.encode(e);for(n=0;o.length>n;n+=1)r=o.charCodeAt(n),t+="%"+r.toString(16).toUpperCase();returnt}functionr(e,r){return"%"===e[r]&&t.isHexDigit(e[r+1])&&t.isHexDigit(e[r+2])}functionn(e,r){returnparseInt(e.substr(r,2),16)}functiono(e){if(!r(e,0))return!1;vart=n(e,1),o=u.numBytes(t);if(0===o)return!1;for(vari=1;o>i;i+=1)if(!r(e,3*i)||!u.isValidFollowingCharCode(n(e,3*i+1)))return!1;return!0}functioni(e,t){varo=e[t];if(!r(e,t))returno;vari=n(e,t+1),a=u.numBytes(i);if(0===a)returno;for(vars=1;a>s;s+=1)if(!r(e,t+3*s)||!u.isValidFollowingCharCode(n(e,t+3*s+1)))returno;returne.substr(t,3*a)}varu={encode:function(e){returnunescape(encodeURIComponent(e))},numBytes:function(e){return127>=e?1:e>=194&&223>=e?2:e>=224&&239>=e?3:e>=240&&244>=e?4:0},isValidFollowingCharCode:function(e){returne>=128&&191>=e}};return{encodeCharacter:e,isPctEncoded:o,pctCharAt:i}}(),i=function(){functione(e){returnt.isAlpha(e)||t.isDigit(e)||"_"===e||o.isPctEncoded(e)}functionr(e){returnt.isAlpha(e)||t.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}functionn(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:r,isReserved:n}}(),u=function(){functione(e,r){varn,t="",u="";for(("number"==typeofe||"boolean"==typeofe)&&(e=""+e),n=0;e.length>n;n+=u.length)u=o.pctCharAt(e,n),t+=u.length>1?u:i.isUnreserved(u)||r&&i.isReserved(u)?u:o.encodeCharacter(u);returnt}functionr(r){returne(r,!0)}return{encode:e,encodePassReserved:r}}(),a=function(){functione(e){r[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?u.encodePassReserved:u.encode,toString:function(){returnthis.symbol}}}varr={};returne(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){if(r[e])returnr[e];if("=,!@|".indexOf(e)>=0)throwError('Illegal use of reserved operator "'+e+'"');returnr[""]}}}(),s=function(){functione(e){varr,n="",t="";for(r=0;e.length>r;r+=t.length)t=o.pctCharAt(e,r),n+=t.length>0?t:i.isReserved(t)||i.isUnreserved(t)?t:o.encodeCharacter(t);returnn}functionr(e){this.literal=r.encodeLiteral(e)}returnr.encodeLiteral=e,r.prototype.expand=function(){returnthis.literal},r.prototype.toString=r.prototype.expand,r}(),f=function(){functione(e){functionr(){p={varname:u.substring(h,f),exploded:!1,maxLength:null},h=null}functionn(){if(d===f)throwError("after a ':' you have to specify the length. position = "+f);p.maxLength=parseInt(u.substring(d,f),10),d=null}varu,s,f,c=[],p=null,h=null,d=null,g="";for(u=e.substr(1,e.length-2),s=a.valueOf(u.charAt(0)),f=""===s.symbol?0:1,h=f;u.length>f;f+=g.length){if(g=o.pctCharAt(u,f),null!==h){if("."===g){if(h===f)throwError("a varname MUST NOT start with a dot -- see position "+f);continue}if(i.isVarchar(g))continue;r()}if(null!==d){if(t.isDigit(g))continue;n()}if(":"!==g)if("*"!==g){if(","!==g)throwError("illegal character '"+g+"' at position "+f+' of "'+u+'"');c.push(p),p=null,h=f+1}else{if(null===p)throwError("explode exploded at position "+f);if(p.exploded)throwError("explode exploded twice at position "+f);if(p.maxLength)throwError("an explode (*) MUST NOT follow to a prefix, see position "+f);p.exploded=!0}else{if(null!==p.maxLength)throwError("only one :maxLength is allowed per varspec at position "+f);d=f+1}}returnnull!==h&&r(),null!==d&&n(),c.push(p),newl(e,s,c)}functionr(r){varn,t,o=[],i=null,u=0;for(n=0;r.length>n;n+=1)if(t=r.charAt(n),null===u){if(null===i)throwError("reached unreachable code");if("{"===t)throwError("brace was opened in position "+i+" and cannot be reopened in position "+n);if("}"===t){if(i+1===n)throwError("empty braces on position "+i);o.push(e(r.substring(i,n+1))),i=null,u=n+1}}else{if("}"===t)throwError("brace was closed in position "+n+" but never opened");"{"===t&&(n>u&&o.push(news(r.substring(u,n))),u=null,i=n)}if(null!==i)throwError("brace was opened on position "+i+", but never closed");returnr.length>u&&o.push(news(r.substr(u))),newc(r,o)}returnr}(),l=function(){functione(e){returnJSON?JSON.stringify(e):e}functiont(e,r,n){this.templateText=e,this.operator=r,this.varspecs=n}returnt.prototype.toString=function(){returnthis.templateText},t.prototype.expand=function(t){functiono(e,n,t){returnr(n)&&(e.length>0&&(e+=","),c||(e+=d.encode(t)+","),e+=d.encode(n)),e}functioni(e,n,t){returnr(n)&&(e.length>0&&(e+=d.separator),e+=c?s.encodeLiteral(f.varname):d.encode(t),e+="="+d.encode(n)),e}functionu(e,n,t){returnr(n)&&(e.length>0&&(e+=d.separator),c||(e+=d.encode(t)+"="),e+=d.encode(n)),e}vara,f,l,c,p="",h=!0,d=this.operator;for(a=0;this.varspecs.length>a;a+=1)if(f=this.varspecs[a],l=t[f.varname],r(l))if(h?(p+=this.operator.first,h=!1):p+=this.operator.separator,c=n.isArray(l),"string"==typeofl||"number"==typeofl||"boolean"==typeofl){if(l=""+l,this.operator.named){if(p+=s.encodeLiteral(f.varname),""===l){p+=this.operator.ifEmpty;continue}p+="="}f.maxLength&&l.length>f.maxLength&&(l=l.substr(0,f.maxLength)),p+=this.operator.encode(l)}else{if(f.maxLength)throwError("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(l));if(f.exploded)p+=n.reduce(l,d.named?i:u,"");else{if(d.named){if(p+=s.encodeLiteral(f.varname),!r(l)){p+=this.operator.ifEmpty;continue}p+="="}p+=n.reduce(l,o,"")}}returnp},t}(),c=function(){functione(e,r){this.templateText=e,this.expressions=r}returne.prototype.toString=function(){returnthis.templateText},e.prototype.expand=function(e){varr,n="";for(r=0;this.expressions.length>r;r+=1)n+=this.expressions[r].expand(e);returnn},e.parse=f,e}();e(c)})(function(e){"use strict";"undefined"!=typeofmodule?module.exports=e:"undefined"!=typeofdefine?define([],function(){returne}):"undefined"!=typeofwindow?window.UriTemplate=e:global.UriTemplate=e});
(function(e){"use strict";functionn(e){vart,o;if(null===e||void0===e)return!1;if(r.isArray(e)){for(t=0;e.length>t;t+=1)if(n(e[t]))return!0;return!1}if("string"==typeofe||"number"==typeofe||"boolean"==typeofe)return!0;for(oine)if(e.hasOwnProperty(o)&&n(e[o]))return!0;return!1}varr=function(){functione(e){return"[object Array]"===Object.prototype.toString.apply(e)}functionn(e,n,r){vart,o=r;for(tine)e.hasOwnProperty(t)&&(o=n(o,e[t],t,e));returno}functionr(e,n,r){vart,o=r;for(t=0;e.length>t;t+=1)o=n(o,e[t],t,e);returno}functiont(t,o,i){returne(t)?r(t,o,i):n(t,o,i)}return{isArray:e,reduce:t}}(),t=function(){functione(e){returne>="a"&&"z">=e||e>="A"&&"Z">=e}functionn(e){returne>="0"&&"9">=e}functionr(e){returnn(e)||e>="a"&&"f">=e||e>="A"&&"F">=e}return{isAlpha:e,isDigit:n,isHexDigit:r}}(),o=function(){functione(e){varn,r,t="",o=u.encode(e);for(r=0;o.length>r;r+=1)n=o.charCodeAt(r),t+="%"+n.toString(16).toUpperCase();returnt}functionn(e,n){return"%"===e[n]&&t.isHexDigit(e[n+1])&&t.isHexDigit(e[n+2])}functionr(e,n){returnparseInt(e.substr(n,2),16)}functiono(e){if(!n(e,0))return!1;vart=r(e,1),o=u.numBytes(t);if(0===o)return!1;for(vari=1;o>i;i+=1)if(!n(e,3*i)||!u.isValidFollowingCharCode(r(e,3*i+1)))return!1;return!0}functioni(e,t){varo=e[t];if(!n(e,t))returno;vari=r(e,t+1),a=u.numBytes(i);if(0===a)returno;for(vars=1;a>s;s+=1)if(!n(e,t+3*s)||!u.isValidFollowingCharCode(r(e,t+3*s+1)))returno;returne.substr(t,3*a)}varu={encode:function(e){returnunescape(encodeURIComponent(e))},numBytes:function(e){return127>=e?1:e>=194&&223>=e?2:e>=224&&239>=e?3:e>=240&&244>=e?4:0},isValidFollowingCharCode:function(e){returne>=128&&191>=e}};return{encodeCharacter:e,isPctEncoded:o,pctCharAt:i}}(),i=function(){functione(e){returnt.isAlpha(e)||t.isDigit(e)||"_"===e||o.isPctEncoded(e)}functionn(e){returnt.isAlpha(e)||t.isDigit(e)||"-"===e||"."===e||"_"===e||"~"===e}functionr(e){return":"===e||"/"===e||"?"===e||"#"===e||"["===e||"]"===e||"@"===e||"!"===e||"$"===e||"&"===e||"("===e||")"===e||"*"===e||"+"===e||","===e||";"===e||"="===e||"'"===e}return{isVarchar:e,isUnreserved:n,isReserved:r}}(),u=function(){functione(e,n){varr,t="",u="";for(("number"==typeofe||"boolean"==typeofe)&&(e=""+e),r=0;e.length>r;r+=u.length)u=o.pctCharAt(e,r),t+=u.length>1?u:i.isUnreserved(u)||n&&i.isReserved(u)?u:o.encodeCharacter(u);returnt}functionn(n){returne(n,!0)}return{encode:e,encodePassReserved:n}}(),a=function(){functione(e){n[e]={symbol:e,separator:"?"===e?"&":""===e||"+"===e||"#"===e?",":e,named:";"===e||"&"===e||"?"===e,ifEmpty:"&"===e||"?"===e?"=":"",first:"+"===e?"":e,encode:"+"===e||"#"===e?u.encodePassReserved:u.encode,toString:function(){returnthis.symbol}}}varn={};returne(""),e("+"),e("#"),e("."),e("/"),e(";"),e("?"),e("&"),{valueOf:function(e){if(n[e])returnn[e];if("=,!@|".indexOf(e)>=0)throwError('Illegal use of reserved operator "'+e+'"');returnn[""]}}}(),s=function(){functione(e){varn,r="",t="";for(n=0;e.length>n;n+=t.length)t=o.pctCharAt(e,n),r+=t.length>0?t:i.isReserved(t)||i.isUnreserved(t)?t:o.encodeCharacter(t);returnr}functionn(e){this.literal=n.encodeLiteral(e)}returnn.encodeLiteral=e,n.prototype.expand=function(){returnthis.literal},n.prototype.toString=n.prototype.expand,n}(),f=function(){functione(e){functionn(){p={varname:u.substring(d,f),exploded:!1,maxLength:null},d=null}functionr(){if(h===f)throwError("after a ':' you have to specify the length. position = "+f);p.maxLength=parseInt(u.substring(h,f),10),h=null}varu,s,f,c=[],p=null,d=null,h=null,g="";for(u=e.substr(1,e.length-2),s=a.valueOf(u.charAt(0)),f=""===s.symbol?0:1,d=f;u.length>f;f+=g.length){if(g=o.pctCharAt(u,f),null!==d){if("."===g){if(d===f)throwError("a varname MUST NOT start with a dot -- see position "+f);continue}if(i.isVarchar(g))continue;n()}if(null!==h){if(t.isDigit(g))continue;r()}if(":"!==g)if("*"!==g){if(","!==g)throwError("illegal character '"+g+"' at position "+f+' of "'+u+'"');c.push(p),p=null,d=f+1}else{if(null===p)throwError("explode exploded at position "+f);if(p.exploded)throwError("explode exploded twice at position "+f);if(p.maxLength)throwError("an explode (*) MUST NOT follow to a prefix, see position "+f);p.exploded=!0}else{if(null!==p.maxLength)throwError("only one :maxLength is allowed per varspec at position "+f);h=f+1}}returnnull!==d&&n(),null!==h&&r(),c.push(p),newl(e,s,c)}functionn(n){varr,t,o=[],i=null,u=0;for(r=0;n.length>r;r+=1)if(t=n.charAt(r),null===u){if(null===i)throwError("reached unreachable code");if("{"===t)throwError("brace was opened in position "+i+" and cannot be reopened in position "+r);if("}"===t){if(i+1===r)throwError("empty braces on position "+i);o.push(e(n.substring(i,r+1))),i=null,u=r+1}}else{if("}"===t)throwError("brace was closed in position "+r+" but never opened");"{"===t&&(r>u&&o.push(news(n.substring(u,r))),u=null,i=r)}if(null!==i)throwError("brace was opened on position "+i+", but never closed");returnn.length>u&&o.push(news(n.substr(u))),newc(n,o)}returnn}(),l=function(){functione(e){returnJSON?JSON.stringify(e):e}functiont(e,n,r){this.templateText=e,this.operator=n,this.varspecs=r}returnt.prototype.toString=function(){returnthis.templateText},t.prototype.expand=function(t){functiono(e,r,t){returnn(r)&&(e.length>0&&(e+=","),c||(e+=h.encode(t)+","),e+=h.encode(r)),e}functioni(e,r,t){returnn(r)&&(e.length>0&&(e+=h.separator),e+=c?s.encodeLiteral(f.varname):h.encode(t),e+="="+h.encode(r)),e}functionu(e,r,t){returnn(r)&&(e.length>0&&(e+=h.separator),c||(e+=h.encode(t)+"="),e+=h.encode(r)),e}vara,f,l,c,p="",d=!0,h=this.operator;for(a=0;this.varspecs.length>a;a+=1)if(f=this.varspecs[a],l=t[f.varname],n(l))if(d?(p+=h.first,d=!1):p+=h.separator,c=r.isArray(l),"string"==typeofl||"number"==typeofl||"boolean"==typeofl){if(l=""+l,h.named){if(p+=s.encodeLiteral(f.varname),""===l){p+=h.ifEmpty;continue}p+="="}f.maxLength&&l.length>f.maxLength&&(l=l.substr(0,f.maxLength)),p+=h.encode(l)}else{if(f.maxLength)throwError("Prefix modifiers are not applicable to variables that have composite values. You tried to expand "+this+" with "+e(l));if(f.exploded)p+=r.reduce(l,h.named?i:u,"");else{if(h.named){if(p+=s.encodeLiteral(f.varname),!n(l)){p+=h.ifEmpty;continue}p+="="}p+=r.reduce(l,o,"")}}if(d){varg=!1;for(a=0;this.varspecs.length>a;a+=1)if(this.varspecs[a].exploded){g=!0;break}h.named&&!g&&(p+=h.symbol,p+=f.varname+h.ifEmpty)}returnp},t}(),c=function(){functione(e,n){this.templateText=e,this.expressions=n}returne.prototype.toString=function(){returnthis.templateText},e.prototype.expand=function(e){varn,r="";for(n=0;this.expressions.length>n;n+=1)r+=this.expressions[n].expand(e);returnr},e.parse=f,e}();e(c)})(function(e){"use strict";"undefined"!=typeofmodule?module.exports=e:"undefined"!=typeofdefine?define([],function(){returne}):"undefined"!=typeofwindow?window.UriTemplate=e:global.UriTemplate=e});