(function(A){if(typeof define==="function"&&define.amd){define(A)}else{window.purl=A()}})(function(){var E={a:"href",img:"src",form:"action",base:"href",script:"src",iframe:"src",link:"href",embed:"src",object:"data"},D=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","fragment"],O={"anchor":"fragment"},A={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},P=/^[0-9]+$/;function F(S,R){var V=decodeURI(S),U=A[R||false?"strict":"loose"].exec(V),W={attr:{},param:{},seg:{}},T=14;while(T--){W.attr[D[T]]=U[T]||""}W.param["query"]=Q(W.attr["query"]);W.param["fragment"]=Q(W.attr["fragment"]);W.seg["path"]=W.attr.path.replace(/^\/+|\/+$/g,"").split("/");W.seg["fragment"]=W.attr.fragment.replace(/^\/+|\/+$/g,"").split("/");W.attr["base"]=W.attr.host?(W.attr.protocol?W.attr.protocol+"://"+W.attr.host:W.attr.host)+(W.attr.port?":"+W.attr.port:""):"";return W}function C(S){var R=S.tagName;if(typeof R!=="undefined"){return E[R.toLowerCase()]}return R}function I(U,R){if(U[R].length===0){return U[R]={}}var T={};for(var S in U[R]){T[S]=U[R][S]}U[R]=T;return T}function B(R,W,S,U){var V=R.shift();if(!V){if(J(W[S])){W[S].push(U)}else{if("object"==typeof W[S]){W[S]=U}else{if("undefined"==typeof W[S]){W[S]=U}else{W[S]=[W[S],U]}}}}else{var T=W[S]=W[S]||[];if("]"==V){if(J(T)){if(""!==U){T.push(U)}}else{if("object"==typeof T){T[M(T).length]=U}else{T=W[S]=[W[S],U]}}}else{if(~V.indexOf("]")){V=V.substr(0,V.length-1);if(!P.test(V)&&J(T)){T=I(W,S)}B(R,T,V,U)}else{if(!P.test(V)&&J(T)){T=I(W,S)}B(R,T,V,U)}}}}function K(V,S,T){if(~S.indexOf("]")){var R=S.split("[");B(R,V,"base",T)}else{if(!P.test(S)&&J(V.base)){var U={};for(var W in V.base){U[W]=V.base[W]}V.base=U}if(S!==""){L(V.base,S,T)}}return V}function Q(R){return N(String(R).split(/&|;/),function(W,T){try{T=decodeURIComponent(T.replace(/\+/g," "))}catch(U){}var X=T.indexOf("="),Y=G(T),S=T.substr(0,Y||X),V=T.substr(Y||X,T.length);V=V.substr(V.indexOf("=")+1,V.length);if(S===""){S=T;V=""}return K(W,S,V)},{base:{}}).base}function L(S,R,U){var T=S[R];if(typeof T==="undefined"){S[R]=U}else{if(J(T)){T.push(U)}else{S[R]=[T,U]}}}function G(T){var U=T.length,V,R;for(var S=0;S>0,U=arguments[2];while(R