functionO(a,b,c,d,e){b=b.a(d);c=c.a(d);varf;if(binstanceofC&&cinstanceofC){b=H(b);for(d=I(b);d;d=I(b))for(e=H(c),f=I(e);f;f=I(e))if(a(z(d),z(f)))return!0;return!1}if(binstanceofC||cinstanceofC){binstanceofC?(e=b,d=c):(e=c,d=b);f=H(e);for(varg=typeofd,h=I(f);h;h=I(f)){switch(g){case"number":h=+z(h);break;case"boolean":h=!!z(h);break;case"string":h=z(h);break;default:throwError("Illegal primitive type for comparison.");}if(e==b&&a(h,d)||e==c&&a(d,h))return!0}return!1}returne?"boolean"==
P(">",4,2,function(a,b,c){returnO(function(a,b){returna>b},a,b,c)});P("<=",4,2,function(a,b,c){returnO(function(a,b){returna<=b},a,b,c)});P(">=",4,2,function(a,b,c){returnO(function(a,b){returna>=b},a,b,c)});varWa=P("=",3,2,function(a,b,c){returnO(function(a,b){returna==b},a,b,c,!0)});P("!=",3,2,function(a,b,c){returnO(function(a,b){returna!=b},a,b,c,!0)});P("and",2,2,function(a,b,c){returnM(a,c)&&M(b,c)});P("or",1,2,function(a,b,c){returnM(a,c)||M(b,c)});functionQ(a,b,c){this.a=a;this.b=b||1;this.f=c||1};functionZa(a,b){if(b.a.length&&4!=a.i)throwError("Primary expression must evaluate to nodeset if filter has predicate(s).");n.call(this,a.i);this.c=a;this.h=b;this.g=a.g;this.b=a.b}m(Za);Za.prototype.a=function(a){a=this.c.a(a);return$a(this.h,a)};Za.prototype.toString=function(){vara;a="Filter:"+J(this.c);returna+=J(this.h)};functionab(a,b){if(b.length<a.A)throwError("Function "+a.j+" expects at least"+a.A+" arguments, "+b.length+" given");if(null!==a.v&&b.length>a.v)throwError("Function "+a.j+" expects at most "+a.v+" arguments, "+b.length+" given");a.B&&r(b,function(b,d){if(4!=b.i)throwError("Argument "+d+" to function "+a.j+" is not of type Nodeset: "+b);});n.call(this,a.i);this.h=a;this.c=b;Ua(this,a.g||ja(b,function(a){returna.g}));Va(this,a.D&&!b.length||a.C&&!!b.length||ja(b,function(a){returna.b}))}m(ab);
R("lang",2,!1,!1,function(){return!1},1);R("last",1,!0,!1,function(a){if(1!=arguments.length)throwError("Function last expects ()");returna.f},0);R("local-name",3,!1,!0,function(a,b){varc=b?Ra(b.a(a)):a.a;returnc?c.localName||c.nodeName.toLowerCase():""},0,1,!0);R("name",3,!1,!0,function(a,b){varc=b?Ra(b.a(a)):a.a;returnc?c.nodeName.toLowerCase():""},0,1,!0);R("namespace-uri",3,!0,!1,function(){return""},0,1,!0);
functionob(a){return"/"==a||"//"==a}kb.prototype.a=function(a){varb=this.h.a(a);if(!(binstanceofC))throwError("Filter expression must evaluate to nodeset.");a=this.c;for(varc=0,d=a.length;c<d&&b.l;c++){vare=a[c],f=H(b,e.c.a),g;if(e.g||e.c!=pb)if(e.g||e.c!=qb)for(g=I(f),b=e.a(newQ(g));null!=(g=I(f));)g=e.a(newQ(g)),b=Pa(b,g);elseg=I(f),b=e.a(newQ(g));else{for(g=I(f);(b=I(f))&&(!g.contains||g.contains(b))&&b.compareDocumentPosition(g)&8;g=b);b=e.a(newQ(g))}}returnb};
kb.prototype.toString=function(){vara;a="Path Expression:"+J(this.h);if(this.c.length){varb=t(this.c,function(a,b){returna+J(b)},"Steps:");a+=J(b)}returna};functionrb(a){n.call(this,4);this.c=a;Ua(this,ja(this.c,function(a){returna.g}));Va(this,ja(this.c,function(a){returna.b}))}m(rb);rb.prototype.a=function(a){varb=newC;r(this.c,function(c){c=c.a(a);if(!(cinstanceofC))throwError("Path expression must evaluate to NodeSet.");b=Pa(b,c)});returnb};rb.prototype.toString=function(){returnt(this.c,function(a,b){returna+J(b)},"Union Expression:")};functionsb(a,b){this.a=a;this.b=!!b}
function$a(a,b,c){for(c=c||0;c<a.a.length;c++)for(vard=a.a[c],e=H(b),f=b.l,g,h=0;g=I(e);h++){varp=a.b?f-h:h+1;g=d.a(newQ(g,p,f));if("number"==typeofg)p=p==g;elseif("string"==typeofg||"boolean"==typeofg)p=!!g;elseif(ginstanceofC)p=0<g.l;elsethrowError("Predicate.evaluate returned an unexpected type.");if(!p){p=e;g=p.f;vary=p.a;if(!y)throwError("Next must be called at least once before remove.");varD=y.b,y=y.a;D?D.a=y:g.a=y;y?y.b=D:g.b=D;g.l--;p.a=null}}returnb}
V("preceding-sibling",function(a,b){for(varc=newC,d=b;d=d.previousSibling;)a.a(d)&&Qa(c,d);returnc},!0);varyb=V("self",function(a,b){varc=newC;a.a(b)&&F(c,b);returnc},!1);functionzb(a){n.call(this,1);this.c=a;this.g=a.g;this.b=a.b}m(zb);zb.prototype.a=function(a){return-K(this.c,a)};zb.prototype.toString=function(){return"Unary Expression: -"+J(this.c)};functionAb(a){n.call(this,1);this.c=a}m(Ab);Ab.prototype.a=function(){returnthis.c};Ab.prototype.toString=function(){return"Number: "+this.c};functionBb(a,b){this.a=a;this.b=b}functionCb(a){for(varb,c=[];;){W(a,"Missing right hand side of binary expression.");b=Db(a);vard=T(a.a);if(!d)break;vare=(d=Ya[d]||null)&&d.w;if(!e){a.a.a--;break}for(;c.length&&e<=c[c.length-1].w;)b=newN(c.pop(),c.pop(),b);c.push(b,d)}for(;c.length;)b=newN(c.pop(),c.pop(),b);returnb}functionW(a,b){if(ib(a.a))throwError(b);}functionEb(a,b){varc=T(a.a);if(c!=b)throwError("Bad token, expected: "+b+" got: "+c);}
functionHb(a){varb,c=[],d;if(ob(S(a.a))){b=T(a.a);d=S(a.a);if("/"==b&&(ib(a.a)||"."!=d&&".."!=d&&"@"!=d&&"*"!=d&&!/(?![0-9])[\w]/.test(d)))returnnewmb;d=newmb;W(a,"Missing next location step.");b=Ib(a,b);c.push(b)}else{a:{b=S(a.a);d=b.charAt(0);switch(d){case"$":throwError("Variable reference not allowed in HTML XPath");case"(":T(a.a);b=Cb(a);W(a,'unclosed "("');Eb(a,")");break;case'"':case"'":b=Gb(a);break;default:if(isNaN(+b))if(!db(b)&&/(?![0-9])[\w]/.test(d)&&"("==S(a.a,1)){b=T(a.a);
b=cb[b]||null;T(a.a);for(d=[];")"!=S(a.a);){W(a,"Missing function argument list.");d.push(Cb(a));if(","!=S(a.a))break;T(a.a)}W(a,"Unclosed function argument list.");Fb(a);b=newab(b,d)}else{b=null;breaka}elseb=newAb(+T(a.a))}"["==S(a.a)&&(d=newsb(Jb(a)),b=newZa(b,d))}if(b)if(ob(S(a.a)))d=b;elsereturnb;elseb=Ib(a,"/"),d=newnb,c.push(b)}for(;ob(S(a.a));)b=T(a.a),W(a,"Missing next location step."),b=Ib(a,b),c.push(b);returnnewkb(d,c)}
functionIb(a,b){varc,d,e;if("/"!=b&&"//"!=b)throwError('Step op should be "/" or "//"');if("."==S(a.a))returnd=newU(yb,newG("node")),T(a.a),d;if(".."==S(a.a))returnd=newU(xb,newG("node")),T(a.a),d;varf;if("@"==S(a.a))f=lb,T(a.a),W(a,"Missing attribute name");elseif("::"==S(a.a,1)){if(!/(?![0-9])[\w]/.test(S(a.a).charAt(0)))throwError("Bad token: "+T(a.a));c=T(a.a);f=wb[c]||null;if(!f)throwError("No axis with name: "+c);T(a.a);W(a,"Missing node name")}elsef=tb;c=S(a.a);if(/(?![0-9])[\w\*]/.test(c.charAt(0)))if("("==
S(a.a,1)){if(!db(c))throwError("Invalid node type: "+c);c=T(a.a);if(!db(c))throwError("Invalid type name: "+c);Eb(a,"(");W(a,"Bad nodetype");e=S(a.a).charAt(0);varg=null;if('"'==e||"'"==e)g=Gb(a);W(a,"Bad nodetype");Fb(a);c=newG(c,g)}elseif(c=T(a.a),e=c.indexOf(":"),-1==e)c=newE(c);else{varg=c.substring(0,e),h;if("*"==g)h="*";elseif(h=a.b(g),!h)throwError("Namespace prefix not declared: "+g);c=c.substr(e+1);c=newE(c,h)}elsethrowError("Bad token: "+T(a.a));e=newsb(Jb(a),f.a);returnd||
newU(f,c,e,"//"==b)}functionJb(a){for(varb=[];"["==S(a.a);){T(a.a);W(a,"Missing predicate expression.");varc=Cb(a);b.push(c);W(a,"Unclosed predicate expression.");Eb(a,"]")}returnb}functionDb(a){if("-"==S(a.a))returnT(a.a),newzb(Db(a));varb=Hb(a);if("|"!=S(a.a))a=b;else{for(b=[b];"|"==T(a.a);)W(a,"Missing next union location path."),b.push(Hb(a));a.a.a--;a=newrb(b)}returna};functionKb(a){switch(a.nodeType){case1:returnea(Lb,a);case9:returnKb(a.documentElement);case11:case10:case6:case12:returnMb;default:returna.parentNode?Kb(a.parentNode):Mb}}functionMb(){returnnull}functionLb(a,b){if(a.prefix==b)returna.namespaceURI||"http://www.w3.org/1999/xhtml";varc=a.getAttributeNode("xmlns:"+b);returnc&&c.specified?c.value||null:a.parentNode&&9!=a.parentNode.nodeType?Lb(a.parentNode,b):null};functionNb(a,b){if(!a.length)throwError("Empty XPath expression.");varc=fb(a);if(ib(c))throwError("Invalid XPath expression.");b?"function"==aa(b)||(b=da(b.lookupNamespaceURI,b)):b=function(){returnnull};vard=Cb(newBb(c,b));if(!ib(c))throwError("Bad token: "+T(c));this.evaluate=function(a,b){varc=d.a(newQ(a));returnnewY(c,b)}}
functionY(a,b){if(0==b)if(ainstanceofC)b=4;elseif("string"==typeofa)b=2;elseif("number"==typeofa)b=1;elseif("boolean"==typeofa)b=3;elsethrowError("Unexpected evaluation result.");if(2!=b&&1!=b&&3!=b&&!(ainstanceofC))throwError("value could not be converted to the specified type");this.resultType=b;varc;switch(b){case2:this.stringValue=ainstanceofC?Sa(a):""+a;break;case1:this.numberValue=ainstanceofC?+Sa(a):+a;break;case3:this.booleanValue=ainstanceofC?0<a.l:!!a;break;case4:case5:case6:case7:vard=
H(a);c=[];for(vare=I(d);e;e=I(d))c.push(einstanceofx?e.a:e);this.snapshotLength=a.l;this.invalidIteratorState=!1;break;case8:case9:d=Ra(a);this.singleNodeValue=dinstanceofx?d.a:d;break;default:throwError("Unknown XPathResult type.");}varf=0;this.iterateNext=function(){if(4!=b&&5!=b)throwError("iterateNext called with wrong result type");returnf>=c.length?null:c[f++]};this.snapshotItem=function(a){if(6!=b&&7!=b)throwError("snapshotItem called with wrong result type");returna>=c.length||