Loading
function(t,e,n){var i=n(271434);t.exports=function t(e,n,r){if(i(n)||(r=n||r,n=[]),r=r||{},e instanceof RegExp){var a,s,l=n,h=e.source.match(/\((?!\?)/g);if(h)for(var d=0;d<h.length;d++)l.push({name:d,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return e.keys=l,e}if(i(e)){for(var f,p=n,g=r,m=[],y=0;y<e.length;y++)m.push(t(e[y],p,g).source);return(f=RegExp("(?:"+m.join("|")+")",u(g))).keys=p,f}return a=n,c(o(e,s=r),a,s)},t.exports.parse=o,t.exports.compile=function(t,e){return s(o(t,e))},t.exports.tokensToFunction=s,t.exports.tokensToRegExp=c;var r=RegExp("(\\\\.)|([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))","g");function o(t,e){for(var n,i=[],o=0,a=0,s="",u=e&&e.delimiter||"/";null!=(n=r.exec(t));){var c=n[0],h=n[1],d=n.index;if(s+=t.slice(a,d),a=d+c.length,h){s+=h[1];continue}var f=t[a],p=n[2],g=n[3],m=n[4],y=n[5],v=n[6],b=n[7];s&&(i.push(s),s="");var w=null!=p&&null!=f&&f!==p,x="+"===v||"*"===v,_="?"===v||"*"===v,S=n[2]||u,E=m||y;i.push({name:g||o++,prefix:p||"",delimiter:S,optional:_,repeat:x,partial:w,asterisk:!!b,pattern:E?E.replace(/([=!:$\/()])/g,"\\$1"):b?".*":"[^"+l(S)+"]+?"})}return a<t.length&&(s+=t.substr(a)),s&&i.push(s),i}function a(t){return encodeURI(t).replace(/[\/?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function s(t){for(var e=Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=RegExp("^(?:"+t[n].pattern+")$"));return function(n,r){for(var o="",s=n||{},l=(r||{}).pretty?a:encodeURIComponent,u=0;u<t.length;u++){var c,h=t[u];if("string"==typeof h){o+=h;continue}var d=s[h.name];if(null==d)if(h.optional){h.partial&&(o+=h.prefix);continue}else throw TypeError('Expected "'+h.name+'" to be defined');if(i(d)){if(!h.repeat)throw TypeError('Expected "'+h.name+'" to not repeat, but received `'+JSON.stringify(d)+"`");if(0===d.length)if(h.optional)continue;else throw TypeError('Expected "'+h.name+'" to not be empty');for(var f=0;f<d.length;f++){if(c=l(d[f]),!e[u].test(c))throw TypeError('Expected all "'+h.name+'" to match "'+h.pattern+'", but received `'+JSON.stringify(c)+"`");o+=(0===f?h.prefix:h.delimiter)+c}continue}if(c=h.asterisk?encodeURI(d).replace(/[?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}):l(d),!e[u].test(c))throw TypeError('Expected "'+h.name+'" to match "'+h.pattern+'", but received "'+c+'"');o+=h.prefix+c}return o}}function l(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(t){return t.sensitive?"":"i"}function c(t,e,n){i(e)||(n=e||n,e=[]);for(var r,o=(n=n||{}).strict,a=!1!==n.end,s="",c=0;c<t.length;c++){var h=t[c];if("string"==typeof h)s+=l(h);else{var d=l(h.prefix),f="(?:"+h.pattern+")";e.push(h),h.repeat&&(f+="(?:"+d+f+")*"),s+=f=h.optional?h.partial?d+"("+f+")?":"(?:"+d+"("+f+"))?":d+"("+f+")"}}var p=l(n.delimiter||"/"),g=s.slice(-p.length)===p;return o||(s=(g?s.slice(0,-p.length):s)+"(?:"+p+"(?=$))?"),a?s+="$":s+=o&&g?"":"(?="+p+"|$)",(r=RegExp("^"+s,u(n))).keys=e,r}}