terminus 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/bin/terminus +5 -5
  2. data/lib/capybara/driver/terminus.rb +24 -13
  3. data/lib/terminus.rb +21 -15
  4. data/lib/terminus/application.rb +6 -6
  5. data/lib/terminus/browser.rb +77 -60
  6. data/lib/terminus/client.rb +33 -16
  7. data/lib/terminus/client/browser.rb +10 -9
  8. data/lib/terminus/client/phantom.js +25 -3
  9. data/lib/terminus/client/phantomjs.rb +44 -7
  10. data/lib/terminus/connector.rb +2 -2
  11. data/lib/terminus/connector/server.rb +15 -15
  12. data/lib/terminus/connector/socket_handler.rb +11 -11
  13. data/lib/terminus/controller.rb +62 -26
  14. data/lib/terminus/headers.rb +25 -0
  15. data/lib/terminus/host.rb +6 -6
  16. data/lib/terminus/node.rb +36 -22
  17. data/lib/terminus/proxy.rb +81 -45
  18. data/lib/terminus/proxy/driver_body.rb +14 -15
  19. data/lib/terminus/proxy/external.rb +12 -6
  20. data/lib/terminus/proxy/rewrite.rb +7 -6
  21. data/lib/terminus/public/compiled/terminus-min.js +3 -3
  22. data/lib/terminus/public/compiled/terminus.js +225 -180
  23. data/lib/terminus/public/pathology.js +87 -87
  24. data/lib/terminus/public/terminus.js +138 -93
  25. data/lib/terminus/server.rb +7 -7
  26. data/lib/terminus/timeouts.rb +8 -8
  27. data/lib/terminus/views/bootstrap.erb +7 -7
  28. data/lib/terminus/views/index.erb +4 -4
  29. data/lib/terminus/views/infinite.html +4 -4
  30. data/spec/1.1/reports/android.txt +874 -0
  31. data/spec/{reports → 1.1/reports}/chrome.txt +72 -69
  32. data/spec/{reports → 1.1/reports}/firefox.txt +72 -69
  33. data/spec/{reports → 1.1/reports}/opera.txt +72 -69
  34. data/spec/{reports → 1.1/reports}/phantomjs.txt +72 -69
  35. data/spec/{reports → 1.1/reports}/safari.txt +72 -69
  36. data/spec/{spec_helper.rb → 1.1/spec_helper.rb} +5 -2
  37. data/spec/{terminus_driver_spec.rb → 1.1/terminus_driver_spec.rb} +2 -2
  38. data/spec/{terminus_session_spec.rb → 1.1/terminus_session_spec.rb} +2 -2
  39. data/spec/2.0/reports/android.txt +815 -0
  40. data/spec/2.0/reports/chrome.txt +806 -0
  41. data/spec/2.0/reports/firefox.txt +812 -0
  42. data/spec/2.0/reports/opera.txt +806 -0
  43. data/spec/2.0/reports/phantomjs.txt +803 -0
  44. data/spec/2.0/reports/safari.txt +806 -0
  45. data/spec/2.0/spec_helper.rb +21 -0
  46. data/spec/2.0/terminus_spec.rb +25 -0
  47. metadata +41 -32
  48. data/spec/reports/android.txt +0 -875
@@ -1,22 +1,23 @@
1
1
  module Terminus
2
2
  class Proxy
3
-
3
+
4
4
  module Rewrite
5
5
  attr_writer :dock_host
6
-
6
+
7
7
  def each(&block)
8
8
  handler = lambda do |fragment|
9
9
  block.call(rewrite(fragment))
10
10
  end
11
11
  super(&handler)
12
12
  end
13
-
13
+
14
14
  def rewrite(fragment)
15
- fragment.gsub(/\b(action|href)=('[^']*?'|"[^"]*?"|\S*)/i) do
16
- %Q{#{$1}="#{ Terminus.rewrite_remote($2[1..-2], @dock_host) }"}
15
+ fragment.gsub(/\b(action|href)=('[^']*?'|"[^"]*?")/i) do
16
+ q = $2.chars.first
17
+ %Q{#{$1}=#{q}#{ Terminus.rewrite_remote($2[1..-2], @dock_host) }#{q}}
17
18
  end
18
19
  end
19
20
  end
20
-
21
+
21
22
  end
22
23
  end
@@ -1,3 +1,3 @@
1
- var Pathology={evaluate:function(e,t,n,r,i){i=i||new Pathology.XPathResult(r);var s=Pathology.XPathParser.parse(e);return s.evaluate(t,t,r,i),i},atomize:function(e,t,n){var r=e.evaluate(t,n);return r&&r.atomize&&(r=r.atomize()),r},array:function(e){if(!e)return[];var t=[],n=e.length;while(n--)t[n]=e[n];return t},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}};typeof XPathResult=="undefined"&&(XPathResult={ANY_TYPE:0,NUMBER_TYPE:1,STRING_TYPE:2,BOOLEAN_TYPE:3,UNORDERED_NODE_ITERATOR_TYPE:4,ORDERED_NODE_ITERATOR_TYPE:5,UNORDERED_NODE_SNAPSHOT_TYPE:6,ORDERED_NODE_SNAPSHOT_TYPE:7,ANY_UNORDERED_NODE_TYPE:8,FIRST_ORDERED_NODE_TYPE:9}),typeof document.evaluate=="undefined"&&(document.evaluate=function(){return Pathology.evaluate.apply(Pathology,arguments)}),Pathology.XPathResult=function(e){this._type=e,this._nodes=[],this._index=0},Pathology.XPathResult.prototype.push=function(e){if(this._type!==0&&e.nodeType!==this._type)return;if(Pathology.indexOf(this._nodes,e)>=0)return;this._nodes.push(e)},Pathology.XPathResult.prototype.iterateNext=function(){var e=this._nodes[this._index];return e?(this._index+=1,e):null},Pathology.XPathResult.prototype.atomize=function(){if(this._nodes.length===0)return null;if(this._nodes.length===1){var e=this._nodes[0];return e.nodeValue===undefined||e.nodeValue===null?e:e.nodeValue}var t=[];for(var n=0,r=this._nodes.length;n<r;n++)t.push(this._nodes[n].nodeValue);return t},Pathology.XPathResult.prototype.makeString=function(){var e=this._nodes[0];if(!e)return"";switch(e.nodeType){case XPathResult.STRING_TYPE:return this.atomize();case XPathResult.BOOLEAN_TYPE:var t=[];for(var n=0,r=this._nodes.length;n<r;n++)t.push(this._nodes[n].nodeValue);return t.join("");default:var i=document.evaluate("//text()",e,null,XPathResult.ANY_TYPE,null);return i.makeString()}},function(){var e=function(e,t){if(!e||!t)return e;for(var n in t)e[n]!==t[n]&&(e[n]=t[n]);return e},t=function(e,t){var n=t.split("."),r;while(r=n.shift()){e=e[r];if(e===undefined)throw new Error("Cannot find object named "+t)}return e},n=function(e){var t=e.input.split(/\n/g),n=0,r=0;while(r<e.offset+1)r+=t[n].length+1,n+=1;var i="Line "+n+": expected "+e.expected+"\n",s=t[n-1];i+=s+"\n",r-=s.length+1;while(r<e.offset)i+=" ",r+=1;return i+"^"},r={__consume__union_expression:function(n){var r=null,i=this._offset;this._nodeCache.union_expression=this._nodeCache.union_expression||{};var s=this._nodeCache.union_expression[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null;l=this.__consume__location_path();if(l){u.push(l),f+=l.textValue,a.head=l;var c=null,h=0,p=this._offset,d=[],v="",m=!0;while(m){var g=this._offset,y=[],b={},w="",E=null;E=this.__consume__space();if(E){y.push(E),w+=E.textValue,b.space=E;var S=null,x=null;this._input.length>this._offset?x=this._input.substring(this._offset,this._offset+1):x=null;if(x==="|"){var T=this.constructor.SyntaxNode,N=null;S=new T("|",this._offset,[]),typeof N=="object"&&e(S,N),this._offset+=1}else{S=null;var C=null;this._input.length>this._offset?C=this._input.substring(this._offset,this._offset+1):C=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"|"'}}if(S){y.push(S),w+=S.textValue;var k=null;k=this.__consume__space();if(k){y.push(k),w+=k.textValue,b.space=k;var L=null;L=this.__consume__location_path(),L?(y.push(L),w+=L.textValue,b.location_path=L):(y=null,this._offset=g)}else y=null,this._offset=g}else y=null,this._offset=g}else y=null,this._offset=g;if(y){this._offset=g;var A=this.constructor.SyntaxNode,O=null;m=new A(w,this._offset,y,b),typeof O=="object"&&e(m,O),this._offset+=w.length}else m=null;m&&(d.push(m),v+=m.textValue,h-=1)}if(h<=0){this._offset=p;var M=this.constructor.SyntaxNode,_=null;c=new M(v,this._offset,d),typeof _=="object"&&e(c,_),this._offset+=v.length}else c=null;c?(u.push(c),f+=c.textValue,a.rest=c):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var D=this.constructor.SyntaxNode,P=t(this.constructor,"Union");r=new D(f,this._offset,u,a),typeof P=="object"&&e(r,P),this._offset+=f.length}else r=null;return this._nodeCache.union_expression[i]=r},__consume__location_path:function(n){var r=null,i=this._offset;this._nodeCache.location_path=this._nodeCache.location_path||{};var s=this._nodeCache.location_path[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null;l=this.__consume__location_step();if(l){u.push(l),f+=l.textValue,a.head=l;var c=null,h=0,p=this._offset,d=[],v="",m=!0;while(m)m=this.__consume__location_step(),m&&(d.push(m),v+=m.textValue,h-=1);if(h<=0){this._offset=p;var g=this.constructor.SyntaxNode,y=null;c=new g(v,this._offset,d),typeof y=="object"&&e(c,y),this._offset+=v.length}else c=null;c?(u.push(c),f+=c.textValue,a.rest=c):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var b=this.constructor.SyntaxNode,w=t(this.constructor,"LocationPath");r=new b(f,this._offset,u,a),typeof w=="object"&&e(r,w),this._offset+=f.length}else r=null;return this._nodeCache.location_path[i]=r},__consume__location_step:function(n){var r=null,i=this._offset;this._nodeCache.location_step=this._nodeCache.location_step||{};var s=this._nodeCache.location_step[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null,c=this._offset,h=null;this._input.length>this._offset?h=this._input.substring(this._offset,this._offset+1):h=null;if(h==="/"){var p=this.constructor.SyntaxNode,d=null;l=new p("/",this._offset,[]),typeof d=="object"&&e(l,d),this._offset+=1}else{l=null;var v=null;this._input.length>this._offset?v=this._input.substring(this._offset,this._offset+1):v=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"/"'}}if(!l){this._offset=c;var m=this.constructor.SyntaxNode,g=null;l=new m("",this._offset,[]),typeof g=="object"&&e(l,g),this._offset+=0}if(l){u.push(l),f+=l.textValue;var y=null,b=this._offset,w=this._offset,E=[],S={},x="",T=null;T=this.__consume__axis();if(T){E.push(T),x+=T.textValue,S.axis=T;var N=null,C=this._offset;N=this.__consume__node_test();if(!N){this._offset=C;var k=this.constructor.SyntaxNode,L=null;N=new k("",this._offset,[]),typeof L=="object"&&e(N,L),this._offset+=0}N?(E.push(N),x+=N.textValue,S.test=N):(E=null,this._offset=w)}else E=null,this._offset=w;if(E){this._offset=w;var A=this.constructor.SyntaxNode,O=null;y=new A(x,this._offset,E,S),typeof O=="object"&&e(y,O),this._offset+=x.length}else y=null;if(!y){this._offset=b;var M=this._offset,_=[],D={},P="",H=null,B=this._offset;H=this.__consume__axis();if(!H){this._offset=B;var j=this.constructor.SyntaxNode,F=null;H=new j("",this._offset,[]),typeof F=="object"&&e(H,F),this._offset+=0}if(H){_.push(H),P+=H.textValue,D.axis=H;var I=null;I=this.__consume__node_test(),I?(_.push(I),P+=I.textValue,D.test=I):(_=null,this._offset=M)}else _=null,this._offset=M;if(_){this._offset=M;var q=this.constructor.SyntaxNode,R=null;y=new q(P,this._offset,_,D),typeof R=="object"&&e(y,R),this._offset+=P.length}else y=null;y||(this._offset=b)}if(y){u.push(y),f+=y.textValue,a.selector=y;var U=null,z=0,W=this._offset,X=[],V="",$=!0;while($)$=this.__consume__node_predicate(),$&&(X.push($),V+=$.textValue,z-=1);if(z<=0){this._offset=W;var J=this.constructor.SyntaxNode,K=null;U=new J(V,this._offset,X),typeof K=="object"&&e(U,K),this._offset+=V.length}else U=null;U?(u.push(U),f+=U.textValue,a.predicates=U):(u=null,this._offset=o)}else u=null,this._offset=o}else u=null,this._offset=o;if(u){this._offset=o;var Q=this.constructor.SyntaxNode,G=t(this.constructor,"LocationStep");r=new Q(f,this._offset,u,a),typeof G=="object"&&e(r,G),this._offset+=f.length}else r=null;return this._nodeCache.location_step[i]=r},__consume__axis:function(t){var n=null,r=this._offset;this._nodeCache.axis=this._nodeCache.axis||{};var i=this._nodeCache.axis[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=this._offset,u=[],a={},f="",l=null,c=1,h=this._offset,p=[],d="",v=!0;while(v){var m=null;this._input.length>this._offset?m=this._input.substring(this._offset,this._offset+1):m=null;if(m&&/^[a-z\-]/.test(m)){var g=this.constructor.SyntaxNode,y=null;v=new g(m,this._offset,[]),typeof y=="object"&&e(v,y),this._offset+=1}else{v=null;var b=null;this._input.length>this._offset?b=this._input.substring(this._offset,this._offset+1):b=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"}}v&&(p.push(v),d+=v.textValue,c-=1)}if(c<=0){this._offset=h;var w=this.constructor.SyntaxNode,E=null;l=new w(d,this._offset,p),typeof E=="object"&&e(l,E),this._offset+=d.length}else l=null;if(l){u.push(l),f+=l.textValue,a.axis_name=l;var S=null,x=null;this._input.length>this._offset?x=this._input.substring(this._offset,this._offset+2):x=null;if(x==="::"){var T=this.constructor.SyntaxNode,N=null;S=new T("::",this._offset,[]),typeof N=="object"&&e(S,N),this._offset+=2}else{S=null;var C=null;this._input.length>this._offset?C=this._input.substring(this._offset,this._offset+1):C=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"::"'}}S?(u.push(S),f+=S.textValue):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var k=this.constructor.SyntaxNode,L=null;n=new k(f,this._offset,u,a),typeof L=="object"&&e(n,L),this._offset+=f.length}else n=null;return n||(this._offset=s,n=this.__consume__axis_shorthand(),n||(this._offset=s)),this._nodeCache.axis[r]=n},__consume__axis_shorthand:function(t){var n=null,r=this._offset;this._nodeCache.axis_shorthand=this._nodeCache.axis_shorthand||{};var i=this._nodeCache.axis_shorthand[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=null;this._input.length>this._offset?o=this._input.substring(this._offset,this._offset+1):o=null;if(o==="@"){var u=this.constructor.SyntaxNode,a=null;n=new u("@",this._offset,[]),typeof a=="object"&&e(n,a),this._offset+=1}else{n=null;var f=null;this._input.length>this._offset?f=this._input.substring(this._offset,this._offset+1):f=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"@"'}}if(!n){this._offset=s;var l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+2):l=null;if(l===".."){var c=this.constructor.SyntaxNode,h=null;n=new c("..",this._offset,[]),typeof h=="object"&&e(n,h),this._offset+=2}else{n=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'".."'}}if(!n){this._offset=s;var d=null;this._input.length>this._offset?d=this._input.substring(this._offset,this._offset+1):d=null;if(d==="."){var v=this.constructor.SyntaxNode,m=null;n=new v(".",this._offset,[]),typeof m=="object"&&e(n,m),this._offset+=1}else{n=null;var g=null;this._input.length>this._offset?g=this._input.substring(this._offset,this._offset+1):g=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"."'}}if(!n){this._offset=s;var y=null;this._input.length>this._offset?y=this._input.substring(this._offset,this._offset+1):y=null;if(y==="/"){var b=this.constructor.SyntaxNode,w=null;n=new b("/",this._offset,[]),typeof w=="object"&&e(n,w),this._offset+=1}else{n=null;var E=null;this._input.length>this._offset?E=this._input.substring(this._offset,this._offset+1):E=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"/"'}}n||(this._offset=s)}}}return this._nodeCache.axis_shorthand[r]=n},__consume__node_test:function(n){var r=null,i=this._offset;this._nodeCache.node_test=this._nodeCache.node_test||{};var s=this._nodeCache.node_test[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null,c=this._offset;l=this.__consume__node_condition();if(!l){this._offset=c,l=this.__consume__node_name();if(!l){this._offset=c;var h=null;this._input.length>this._offset?h=this._input.substring(this._offset,this._offset+1):h=null;if(h==="*"){var p=this.constructor.SyntaxNode,d=null;l=new p("*",this._offset,[]),typeof d=="object"&&e(l,d),this._offset+=1}else{l=null;var v=null;this._input.length>this._offset?v=this._input.substring(this._offset,this._offset+1):v=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"*"'}}l||(this._offset=c)}}if(l){u.push(l),f+=l.textValue;var m=null,g=this._offset;m=this.__consume__subscript();if(!m){this._offset=g;var y=this.constructor.SyntaxNode,b=null;m=new y("",this._offset,[]),typeof b=="object"&&e(m,b),this._offset+=0}m?(u.push(m),f+=m.textValue,a.subscript=m):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var w=this.constructor.SyntaxNode,E=t(this.constructor,"NodeTest");r=new w(f,this._offset,u,a),typeof E=="object"&&e(r,E),this._offset+=f.length}else r=null;return this._nodeCache.node_test[i]=r},__consume__node_condition:function(t){var n=null,r=this._offset;this._nodeCache.node_condition=this._nodeCache.node_condition||{};var i=this._nodeCache.node_condition[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=[],u={},a="",f=null,l=1,c=this._offset,h=[],p="",d=!0;while(d){var v=null;this._input.length>this._offset?v=this._input.substring(this._offset,this._offset+1):v=null;if(v&&/^[a-z\-]/.test(v)){var m=this.constructor.SyntaxNode,g=null;d=new m(v,this._offset,[]),typeof g=="object"&&e(d,g),this._offset+=1}else{d=null;var y=null;this._input.length>this._offset?y=this._input.substring(this._offset,this._offset+1):y=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"}}d&&(h.push(d),p+=d.textValue,l-=1)}if(l<=0){this._offset=c;var b=this.constructor.SyntaxNode,w=null;f=new b(p,this._offset,h),typeof w=="object"&&e(f,w),this._offset+=p.length}else f=null;if(f){o.push(f),a+=f.textValue,u.condition_name=f;var E=null,S=null;this._input.length>this._offset?S=this._input.substring(this._offset,this._offset+2):S=null;if(S==="()"){var x=this.constructor.SyntaxNode,T=null;E=new x("()",this._offset,[]),typeof T=="object"&&e(E,T),this._offset+=2}else{E=null;var N=null;this._input.length>this._offset?N=this._input.substring(this._offset,this._offset+1):N=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"()"'}}E?(o.push(E),a+=E.textValue):(o=null,this._offset=s)}else o=null,this._offset=s;if(o){this._offset=s;var C=this.constructor.SyntaxNode,k=null;n=new C(a,this._offset,o,u),typeof k=="object"&&e(n,k),this._offset+=a.length}else n=null;return this._nodeCache.node_condition[r]=n},__consume__node_name:function(t){var n=null,r=this._offset;this._nodeCache.node_name=this._nodeCache.node_name||{};var i=this._nodeCache.node_name[r];if(i)return this._offset+=i.textValue.length,i;var s=1,o=this._offset,u=[],a="",f=!0;while(f){var l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l&&/^[A-Za-z0-9\-]/.test(l)){var c=this.constructor.SyntaxNode,h=null;f=new c(l,this._offset,[]),typeof h=="object"&&e(f,h),this._offset+=1}else{f=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[A-Za-z0-9\\-]"}}f&&(u.push(f),a+=f.textValue,s-=1)}if(s<=0){this._offset=o;var d=this.constructor.SyntaxNode,v=null;n=new d(a,this._offset,u),typeof v=="object"&&e(n,v),this._offset+=a.length}else n=null;return this._nodeCache.node_name[r]=n},__consume__subscript:function(t){var n=null,r=this._offset;this._nodeCache.subscript=this._nodeCache.subscript||{};var i=this._nodeCache.subscript[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=[],u={},a="",f=null,l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l==="["){var c=this.constructor.SyntaxNode,h=null;f=new c("[",this._offset,[]),typeof h=="object"&&e(f,h),this._offset+=1}else{f=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"["'}}if(f){o.push(f),a+=f.textValue;var d=null;d=this.__consume__space();if(d){o.push(d),a+=d.textValue,u.space=d;var v=null;v=this.__consume__integer();if(v){o.push(v),a+=v.textValue,u.integer=v;var m=null;m=this.__consume__space();if(m){o.push(m),a+=m.textValue,u.space=m;var g=null,y=null;this._input.length>this._offset?y=this._input.substring(this._offset,this._offset+1):y=null;if(y==="]"){var b=this.constructor.SyntaxNode,w=null;g=new b("]",this._offset,[]),typeof w=="object"&&e(g,w),this._offset+=1}else{g=null;var E=null;this._input.length>this._offset?E=this._input.substring(this._offset,this._offset+1):E=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"]"'}}g?(o.push(g),a+=g.textValue):(o=null,this._offset=s)}else o=null,this._offset=s}else o=null,this._offset=s}else o=null,this._offset=s}else o=null,this._offset=s;if(o){this._offset=s;var S=this.constructor.SyntaxNode,x=null;n=new S(a,this._offset,o,u),typeof x=="object"&&e(n,x),this._offset+=a.length}else n=null;return this._nodeCache.subscript[r]=n},__consume__node_predicate:function(t){var n=null,r=this._offset;this._nodeCache.node_predicate=this._nodeCache.node_predicate||{};var i=this._nodeCache.node_predicate[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=[],u={},a="",f=null,l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l==="["){var c=this.constructor.SyntaxNode,h=null;f=new c("[",this._offset,[]),typeof h=="object"&&e(f,h),this._offset+=1}else{f=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"["'}}if(f){o.push(f),a+=f.textValue;var d=null;d=this.__consume__expression();if(d){o.push(d),a+=d.textValue,u.expression=d;var v=null,m=null;this._input.length>this._offset?m=this._input.substring(this._offset,this._offset+1):m=null;if(m==="]"){var g=this.constructor.SyntaxNode,y=null;v=new g("]",this._offset,[]),typeof y=="object"&&e(v,y),this._offset+=1}else{v=null;var b=null;this._input.length>this._offset?b=this._input.substring(this._offset,this._offset+1):b=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"]"'}}if(v){o.push(v),a+=v.textValue;var w=null,E=this._offset;w=this.__consume__subscript();if(!w){this._offset=E;var S=this.constructor.SyntaxNode,x=null;w=new S("",this._offset,[]),typeof x=="object"&&e(w,x),this._offset+=0}w?(o.push(w),a+=w.textValue,u.subscript=w):(o=null,this._offset=s)}else o=null,this._offset=s}else o=null,this._offset=s}else o=null,this._offset=s;if(o){this._offset=s;var T=this.constructor.SyntaxNode,N=null;n=new T(a,this._offset,o,u),typeof N=="object"&&e(n,N),this._offset+=a.length}else n=null;return this._nodeCache.node_predicate[r]=n},__consume__expression:function(e){var t=null,n=this._offset;this._nodeCache.expression=this._nodeCache.expression||{};var r=this._nodeCache.expression[n];if(r)return this._offset+=r.textValue.length,r;var i=this._offset;return t=this.__consume__or_expression(),t||(this._offset=i,t=this.__consume__and_expression(),t||(this._offset=i,t=this.__consume__comparison(),t||(this._offset=i,t=this.__consume__atom(),t||(this._offset=i)))),this._nodeCache.expression[n]=t},__consume__or_expression:function(n){var r=null,i=this._offset;this._nodeCache.or_expression=this._nodeCache.or_expression||{};var s=this._nodeCache.or_expression[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=this._offset,a=[],f={},l="",c=null;c=this.__consume__and_expression();if(c){a.push(c),l+=c.textValue,f.left=c;var h=null,p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+2):p=null;if(p==="or"){var d=this.constructor.SyntaxNode,v=null;h=new d("or",this._offset,[]),typeof v=="object"&&e(h,v),this._offset+=2}else{h=null;var m=null;this._input.length>this._offset?m=this._input.substring(this._offset,this._offset+1):m=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"or"'}}if(h){a.push(h),l+=h.textValue;var g=null;g=this.__consume__or_expression(),g?(a.push(g),l+=g.textValue,f.right=g):(a=null,this._offset=u)}else a=null,this._offset=u}else a=null,this._offset=u;if(a){this._offset=u;var y=this.constructor.SyntaxNode,b=t(this.constructor,"Or");r=new y(l,this._offset,a,f),typeof b=="object"&&e(r,b),this._offset+=l.length}else r=null;return r||(this._offset=o,r=this.__consume__and_expression(),r||(this._offset=o)),this._nodeCache.or_expression[i]=r},__consume__and_expression:function(n){var r=null,i=this._offset;this._nodeCache.and_expression=this._nodeCache.and_expression||{};var s=this._nodeCache.and_expression[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=this._offset,a=[],f={},l="",c=null;c=this.__consume__comparison();if(c){a.push(c),l+=c.textValue,f.left=c;var h=null,p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+3):p=null;if(p==="and"){var d=this.constructor.SyntaxNode,v=null;h=new d("and",this._offset,[]),typeof v=="object"&&e(h,v),this._offset+=3}else{h=null;var m=null;this._input.length>this._offset?m=this._input.substring(this._offset,this._offset+1):m=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"and"'}}if(h){a.push(h),l+=h.textValue;var g=null;g=this.__consume__and_expression(),g?(a.push(g),l+=g.textValue,f.right=g):(a=null,this._offset=u)}else a=null,this._offset=u}else a=null,this._offset=u;if(a){this._offset=u;var y=this.constructor.SyntaxNode,b=t(this.constructor,"And");r=new y(l,this._offset,a,f),typeof b=="object"&&e(r,b),this._offset+=l.length}else r=null;return r||(this._offset=o,r=this.__consume__comparison(),r||(this._offset=o)),this._nodeCache.and_expression[i]=r},__consume__comparison:function(n){var r=null,i=this._offset;this._nodeCache.comparison=this._nodeCache.comparison||{};var s=this._nodeCache.comparison[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=this._offset,a=[],f={},l="",c=null;c=this.__consume__atom();if(c){a.push(c),l+=c.textValue,f.left=c;var h=null;h=this.__consume__comparator();if(h){a.push(h),l+=h.textValue,f.comparator=h;var p=null;p=this.__consume__comparison(),p?(a.push(p),l+=p.textValue,f.right=p):(a=null,this._offset=u)}else a=null,this._offset=u}else a=null,this._offset=u;if(a){this._offset=u;var d=this.constructor.SyntaxNode,v=t(this.constructor,"Comparison");r=new d(l,this._offset,a,f),typeof v=="object"&&e(r,v),this._offset+=l.length}else r=null;return r||(this._offset=o,r=this.__consume__atom(),r||(this._offset=o)),this._nodeCache.comparison[i]=r},__consume__comparator:function(t){var n=null,r=this._offset;this._nodeCache.comparator=this._nodeCache.comparator||{};var i=this._nodeCache.comparator[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=null;this._input.length>this._offset?o=this._input.substring(this._offset,this._offset+2):o=null;if(o==="!="){var u=this.constructor.SyntaxNode,a=null;n=new u("!=",this._offset,[]),typeof a=="object"&&e(n,a),this._offset+=2}else{n=null;var f=null;this._input.length>this._offset?f=this._input.substring(this._offset,this._offset+1):f=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"!="'}}if(!n){this._offset=s;var l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l==="="){var c=this.constructor.SyntaxNode,h=null;n=new c("=",this._offset,[]),typeof h=="object"&&e(n,h),this._offset+=1}else{n=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"="'}}n||(this._offset=s)}return this._nodeCache.comparator[r]=n},__consume__atom:function(n){var r=null,i=this._offset;this._nodeCache.atom=this._nodeCache.atom||{};var s=this._nodeCache.atom[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null;l=this.__consume__space();if(l){u.push(l),f+=l.textValue,a.space=l;var c=null,h=this._offset,p=this._offset,d=[],v={},m="",g=null,y=null;this._input.length>this._offset?y=this._input.substring(this._offset,this._offset+1):y=null;if(y==="("){var b=this.constructor.SyntaxNode,w=null;g=new b("(",this._offset,[]),typeof w=="object"&&e(g,w),this._offset+=1}else{g=null;var E=null;this._input.length>this._offset?E=this._input.substring(this._offset,this._offset+1):E=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"("'}}if(g){d.push(g),m+=g.textValue;var S=null;S=this.__consume__expression();if(S){d.push(S),m+=S.textValue,v.in_parens=S;var x=null,T=null;this._input.length>this._offset?T=this._input.substring(this._offset,this._offset+1):T=null;if(T===")"){var N=this.constructor.SyntaxNode,C=null;x=new N(")",this._offset,[]),typeof C=="object"&&e(x,C),this._offset+=1}else{x=null;var k=null;this._input.length>this._offset?k=this._input.substring(this._offset,this._offset+1):k=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'")"'}}x?(d.push(x),m+=x.textValue):(d=null,this._offset=p)}else d=null,this._offset=p}else d=null,this._offset=p;if(d){this._offset=p;var L=this.constructor.SyntaxNode,A=null;c=new L(m,this._offset,d,v),typeof A=="object"&&e(c,A),this._offset+=m.length}else c=null;c||(this._offset=h,c=this.__consume__value(),c||(this._offset=h));if(c){u.push(c),f+=c.textValue,a.expression=c;var O=null;O=this.__consume__space(),O?(u.push(O),f+=O.textValue,a.space=O):(u=null,this._offset=o)}else u=null,this._offset=o}else u=null,this._offset=o;if(u){this._offset=o;var M=this.constructor.SyntaxNode,_=t(this.constructor,"Atom");r=new M(f,this._offset,u,a),typeof _=="object"&&e(r,_),this._offset+=f.length}else r=null;return this._nodeCache.atom[i]=r},__consume__value:function(e){var t=null,n=this._offset;this._nodeCache.value=this._nodeCache.value||{};var r=this._nodeCache.value[n];if(r)return this._offset+=r.textValue.length,r;var i=this._offset;return t=this.__consume__function_call(),t||(this._offset=i,t=this.__consume__string(),t||(this._offset=i,t=this.__consume__union_expression(),t||(this._offset=i))),this._nodeCache.value[n]=t},__consume__function_call:function(n){var r=null,i=this._offset;this._nodeCache.function_call=this._nodeCache.function_call||{};var s=this._nodeCache.function_call[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null;l=this.__consume__function_name();if(l){u.push(l),f+=l.textValue,a.function_name=l;var c=null,h=null;this._input.length>this._offset?h=this._input.substring(this._offset,this._offset+1):h=null;if(h==="("){var p=this.constructor.SyntaxNode,d=null;c=new p("(",this._offset,[]),typeof d=="object"&&e(c,d),this._offset+=1}else{c=null;var v=null;this._input.length>this._offset?v=this._input.substring(this._offset,this._offset+1):v=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"("'}}if(c){u.push(c),f+=c.textValue;var m=null;m=this.__consume__function_args();if(m){u.push(m),f+=m.textValue,a.function_args=m;var g=null,y=null;this._input.length>this._offset?y=this._input.substring(this._offset,this._offset+1):y=null;if(y===")"){var b=this.constructor.SyntaxNode,w=null;g=new b(")",this._offset,[]),typeof w=="object"&&e(g,w),this._offset+=1}else{g=null;var E=null;this._input.length>this._offset?E=this._input.substring(this._offset,this._offset+1):E=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'")"'}}g?(u.push(g),f+=g.textValue):(u=null,this._offset=o)}else u=null,this._offset=o}else u=null,this._offset=o}else u=null,this._offset=o;if(u){this._offset=o;var S=this.constructor.SyntaxNode,x=t(this.constructor,"FunctionCall");r=new S(f,this._offset,u,a),typeof x=="object"&&e(r,x),this._offset+=f.length}else r=null;return this._nodeCache.function_call[i]=r},__consume__function_name:function(t){var n=null,r=this._offset;this._nodeCache.function_name=this._nodeCache.function_name||{};var i=this._nodeCache.function_name[r];if(i)return this._offset+=i.textValue.length,i;var s=1,o=this._offset,u=[],a="",f=!0;while(f){var l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l&&/^[a-z\-]/.test(l)){var c=this.constructor.SyntaxNode,h=null;f=new c(l,this._offset,[]),typeof h=="object"&&e(f,h),this._offset+=1}else{f=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"}}f&&(u.push(f),a+=f.textValue,s-=1)}if(s<=0){this._offset=o;var d=this.constructor.SyntaxNode,v=null;n=new d(a,this._offset,u),typeof v=="object"&&e(n,v),this._offset+=a.length}else n=null;return this._nodeCache.function_name[r]=n},__consume__function_args:function(t){var n=null,r=this._offset;this._nodeCache.function_args=this._nodeCache.function_args||{};var i=this._nodeCache.function_args[r];if(i)return this._offset+=i.textValue.length,i;var s=this._offset,o=this._offset,u=[],a={},f="",l=null;l=this.__consume__expression();if(l){u.push(l),f+=l.textValue,a.first=l;var c=null,h=0,p=this._offset,d=[],v="",m=!0;while(m){var g=this._offset,y=[],b={},w="",E=null,S=null;this._input.length>this._offset?S=this._input.substring(this._offset,this._offset+1):S=null;if(S===","){var x=this.constructor.SyntaxNode,T=null;E=new x(",",this._offset,[]),typeof T=="object"&&e(E,T),this._offset+=1}else{E=null;var N=null;this._input.length>this._offset?N=this._input.substring(this._offset,this._offset+1):N=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'","'}}if(E){y.push(E),w+=E.textValue;var C=null;C=this.__consume__expression(),C?(y.push(C),w+=C.textValue,b.expression=C):(y=null,this._offset=g)}else y=null,this._offset=g;if(y){this._offset=g;var k=this.constructor.SyntaxNode,L=null;m=new k(w,this._offset,y,b),typeof L=="object"&&e(m,L),this._offset+=w.length}else m=null;m&&(d.push(m),v+=m.textValue,h-=1)}if(h<=0){this._offset=p;var A=this.constructor.SyntaxNode,O=null;c=new A(v,this._offset,d),typeof O=="object"&&e(c,O),this._offset+=v.length}else c=null;c?(u.push(c),f+=c.textValue,a.rest=c):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var M=this.constructor.SyntaxNode,_=null;n=new M(f,this._offset,u,a),typeof _=="object"&&e(n,_),this._offset+=f.length}else n=null;if(!n){this._offset=s;var D=this.constructor.SyntaxNode,P=null;n=new D("",this._offset,[]),typeof P=="object"&&e(n,P),this._offset+=0}return this._nodeCache.function_args[r]=n},__consume__integer:function(n){var r=null,i=this._offset;this._nodeCache.integer=this._nodeCache.integer||{};var s=this._nodeCache.integer[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=[],a={},f="",l=null,c=null;this._input.length>this._offset?c=this._input.substring(this._offset,this._offset+1):c=null;if(c&&/^[1-9]/
2
- .test(c)){var h=this.constructor.SyntaxNode,p=null;l=new h(c,this._offset,[]),typeof p=="object"&&e(l,p),this._offset+=1}else{l=null;var d=null;this._input.length>this._offset?d=this._input.substring(this._offset,this._offset+1):d=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[1-9]"}}if(l){u.push(l),f+=l.textValue;var v=null,m=0,g=this._offset,y=[],b="",w=!0;while(w){var E=null;this._input.length>this._offset?E=this._input.substring(this._offset,this._offset+1):E=null;if(E&&/^[0-9]/.test(E)){var S=this.constructor.SyntaxNode,x=null;w=new S(E,this._offset,[]),typeof x=="object"&&e(w,x),this._offset+=1}else{w=null;var T=null;this._input.length>this._offset?T=this._input.substring(this._offset,this._offset+1):T=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[0-9]"}}w&&(y.push(w),b+=w.textValue,m-=1)}if(m<=0){this._offset=g;var N=this.constructor.SyntaxNode,C=null;v=new N(b,this._offset,y),typeof C=="object"&&e(v,C),this._offset+=b.length}else v=null;v?(u.push(v),f+=v.textValue):(u=null,this._offset=o)}else u=null,this._offset=o;if(u){this._offset=o;var k=this.constructor.SyntaxNode,L=t(this.constructor,"Integer");r=new k(f,this._offset,u,a),typeof L=="object"&&e(r,L),this._offset+=f.length}else r=null;return this._nodeCache.integer[i]=r},__consume__string:function(n){var r=null,i=this._offset;this._nodeCache.string=this._nodeCache.string||{};var s=this._nodeCache.string[i];if(s)return this._offset+=s.textValue.length,s;var o=this._offset,u=this._offset,a=[],f={},l="",c=null,h=null;this._input.length>this._offset?h=this._input.substring(this._offset,this._offset+1):h=null;if(h==="'"){var p=this.constructor.SyntaxNode,d=null;c=new p("'",this._offset,[]),typeof d=="object"&&e(c,d),this._offset+=1}else{c=null;var v=null;this._input.length>this._offset?v=this._input.substring(this._offset,this._offset+1):v=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\'"'}}if(c){a.push(c),l+=c.textValue;var m=null,g=0,y=this._offset,b=[],w="",E=!0;while(E){var S=this._offset,x=this._offset,T=[],N={},C="",k=null,L=null;this._input.length>this._offset?L=this._input.substring(this._offset,this._offset+1):L=null;if(L==="\\"){var A=this.constructor.SyntaxNode,O=null;k=new A("\\",this._offset,[]),typeof O=="object"&&e(k,O),this._offset+=1}else{k=null;var M=null;this._input.length>this._offset?M=this._input.substring(this._offset,this._offset+1):M=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\\\"'}}if(k){T.push(k),C+=k.textValue;var _=null,D=null;this._input.length>this._offset?D=this._input.substring(this._offset,this._offset+1):D=null;var P=D;if(P===null){_=null;var H=null;this._input.length>this._offset?H=this._input.substring(this._offset,this._offset+1):H=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"<any char>"}}else{var B=this.constructor.SyntaxNode,j=null;_=new B(P,this._offset,[]),typeof j=="object"&&e(_,j),this._offset+=1}_?(T.push(_),C+=_.textValue):(T=null,this._offset=x)}else T=null,this._offset=x;if(T){this._offset=x;var F=this.constructor.SyntaxNode,I=null;E=new F(C,this._offset,T,N),typeof I=="object"&&e(E,I),this._offset+=C.length}else E=null;if(!E){this._offset=S;var q=null;this._input.length>this._offset?q=this._input.substring(this._offset,this._offset+1):q=null;if(q&&/^[^']/.test(q)){var R=this.constructor.SyntaxNode,U=null;E=new R(q,this._offset,[]),typeof U=="object"&&e(E,U),this._offset+=1}else{E=null;var z=null;this._input.length>this._offset?z=this._input.substring(this._offset,this._offset+1):z=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[^']"}}E||(this._offset=S)}E&&(b.push(E),w+=E.textValue,g-=1)}if(g<=0){this._offset=y;var W=this.constructor.SyntaxNode,X=null;m=new W(w,this._offset,b),typeof X=="object"&&e(m,X),this._offset+=w.length}else m=null;if(m){a.push(m),l+=m.textValue;var V=null,$=null;this._input.length>this._offset?$=this._input.substring(this._offset,this._offset+1):$=null;if($==="'"){var J=this.constructor.SyntaxNode,K=null;V=new J("'",this._offset,[]),typeof K=="object"&&e(V,K),this._offset+=1}else{V=null;var Q=null;this._input.length>this._offset?Q=this._input.substring(this._offset,this._offset+1):Q=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\'"'}}V?(a.push(V),l+=V.textValue):(a=null,this._offset=u)}else a=null,this._offset=u}else a=null,this._offset=u;if(a){this._offset=u;var G=this.constructor.SyntaxNode,Y=null;r=new G(l,this._offset,a,f),typeof Y=="object"&&e(r,Y),this._offset+=l.length}else r=null;if(r){var Z=t(this.constructor,"String");typeof Z=="object"&&e(r,Z)}else{this._offset=o;var et=this._offset,tt=[],nt={},rt="",it=null,st=null;this._input.length>this._offset?st=this._input.substring(this._offset,this._offset+1):st=null;if(st==='"'){var ot=this.constructor.SyntaxNode,ut=null;it=new ot('"',this._offset,[]),typeof ut=="object"&&e(it,ut),this._offset+=1}else{it=null;var at=null;this._input.length>this._offset?at=this._input.substring(this._offset,this._offset+1):at=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\""'}}if(it){tt.push(it),rt+=it.textValue;var ft=null,lt=0,ct=this._offset,ht=[],pt="",dt=!0;while(dt){var vt=this._offset,mt=this._offset,gt=[],yt={},bt="",wt=null,Et=null;this._input.length>this._offset?Et=this._input.substring(this._offset,this._offset+1):Et=null;if(Et==="\\"){var St=this.constructor.SyntaxNode,xt=null;wt=new St("\\",this._offset,[]),typeof xt=="object"&&e(wt,xt),this._offset+=1}else{wt=null;var Tt=null;this._input.length>this._offset?Tt=this._input.substring(this._offset,this._offset+1):Tt=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\\\"'}}if(wt){gt.push(wt),bt+=wt.textValue;var Nt=null,Ct=null;this._input.length>this._offset?Ct=this._input.substring(this._offset,this._offset+1):Ct=null;var kt=Ct;if(kt===null){Nt=null;var Lt=null;this._input.length>this._offset?Lt=this._input.substring(this._offset,this._offset+1):Lt=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"<any char>"}}else{var At=this.constructor.SyntaxNode,Ot=null;Nt=new At(kt,this._offset,[]),typeof Ot=="object"&&e(Nt,Ot),this._offset+=1}Nt?(gt.push(Nt),bt+=Nt.textValue):(gt=null,this._offset=mt)}else gt=null,this._offset=mt;if(gt){this._offset=mt;var Mt=this.constructor.SyntaxNode,_t=null;dt=new Mt(bt,this._offset,gt,yt),typeof _t=="object"&&e(dt,_t),this._offset+=bt.length}else dt=null;if(!dt){this._offset=vt;var Dt=null;this._input.length>this._offset?Dt=this._input.substring(this._offset,this._offset+1):Dt=null;if(Dt&&/^[^"]/.test(Dt)){var Pt=this.constructor.SyntaxNode,Ht=null;dt=new Pt(Dt,this._offset,[]),typeof Ht=="object"&&e(dt,Ht),this._offset+=1}else{dt=null;var Bt=null;this._input.length>this._offset?Bt=this._input.substring(this._offset,this._offset+1):Bt=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'[^"]'}}dt||(this._offset=vt)}dt&&(ht.push(dt),pt+=dt.textValue,lt-=1)}if(lt<=0){this._offset=ct;var jt=this.constructor.SyntaxNode,Ft=null;ft=new jt(pt,this._offset,ht),typeof Ft=="object"&&e(ft,Ft),this._offset+=pt.length}else ft=null;if(ft){tt.push(ft),rt+=ft.textValue;var It=null,qt=null;this._input.length>this._offset?qt=this._input.substring(this._offset,this._offset+1):qt=null;if(qt==='"'){var Rt=this.constructor.SyntaxNode,Ut=null;It=new Rt('"',this._offset,[]),typeof Ut=="object"&&e(It,Ut),this._offset+=1}else{It=null;var zt=null;this._input.length>this._offset?zt=this._input.substring(this._offset,this._offset+1):zt=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\""'}}It?(tt.push(It),rt+=It.textValue):(tt=null,this._offset=et)}else tt=null,this._offset=et}else tt=null,this._offset=et;if(tt){this._offset=et;var Wt=this.constructor.SyntaxNode,Xt=null;r=new Wt(rt,this._offset,tt,nt),typeof Xt=="object"&&e(r,Xt),this._offset+=rt.length}else r=null;if(r){var Vt=t(this.constructor,"String");typeof Vt=="object"&&e(r,Vt)}else this._offset=o}return this._nodeCache.string[i]=r},__consume__space:function(t){var n=null,r=this._offset;this._nodeCache.space=this._nodeCache.space||{};var i=this._nodeCache.space[r];if(i)return this._offset+=i.textValue.length,i;var s=0,o=this._offset,u=[],a="",f=!0;while(f){var l=null;this._input.length>this._offset?l=this._input.substring(this._offset,this._offset+1):l=null;if(l===" "){var c=this.constructor.SyntaxNode,h=null;f=new c(" ",this._offset,[]),typeof h=="object"&&e(f,h),this._offset+=1}else{f=null;var p=null;this._input.length>this._offset?p=this._input.substring(this._offset,this._offset+1):p=null;if(!this.error||this.error.offset<=this._offset)this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'" "'}}f&&(u.push(f),a+=f.textValue,s-=1)}if(s<=0){this._offset=o;var d=this.constructor.SyntaxNode,v=null;n=new d(a,this._offset,u),typeof v=="object"&&e(n,v),this._offset+=a.length}else n=null;return this._nodeCache.space[r]=n}},i=function(e){this._input=e,this._offset=0,this._nodeCache={}};i.prototype.parse=function(){var e=this.__consume__union_expression();if(e&&this._offset===this._input.length)return e;this.error||(this.error={input:this._input,offset:this._offset,expected:"<EOF>"});var t=n(this.error),r=new Error(t);throw r},i.parse=function(e){var t=new i(e);return t.parse()},e(i.prototype,r);var s=function(e,t,n,r){this.textValue=e,this.offset=t,this.elements=n||[];if(!r)return;for(var i in r)this[i]=r[i]};s.prototype.forEach=function(e,t){for(var n=0,r=this.elements.length;n<r;n++)e.call(t,this.elements[n],n)},i.SyntaxNode=s;if(typeof require=="function"&&typeof exports=="object")exports.Grammar=r,exports.Parser=i,exports.parse=i.parse,typeof Pathology!="undefined"&&(Pathology.XPath=r,Pathology.XPathParser=i,Pathology.XPathParser.formatError=n);else{var o=this;o=o.Pathology=o.Pathology||{},Pathology.XPath=r,Pathology.XPathParser=i,Pathology.XPathParser.formatError=n}}(),Pathology.XPathParser.And={evaluate:function(e,t){return Pathology.atomize(this.left,e,t)&&Pathology.atomize(this.right,e,t)}},Pathology.XPathParser.Atom={evaluate:function(e,t){var n=this.expression.in_parens||this.expression;return n.evaluate(e,t)}},Pathology.Axis=function(e){this.name=e},Pathology.Axis.prototype.walk=function(e,t,n){var r=e.childNodes,i=Pathology.array(e.attributes),s;e.checked&&i.push({nodeName:"checked",nodeValue:!0,nodeType:XPathResult.STRING_TYPE}),e.selected&&i.push({nodeName:"selected",nodeValue:!0,nodeType:XPathResult.STRING_TYPE});switch(this.name){case"attribute":for(var o=0,u=i.length;o<u;o++)t.call(n,i[o]);break;case"child":for(var o=0,u=r.length;o<u;o++)t.call(n,r[o]);break;case"descendant-or-self":t.call(n,e);for(var o=0,u=r.length;o<u;o++)this.walk(r[o],t,n);break;case"following-sibling":s=e.nextSibling;while(s)t.call(n,s),s=s.nextSibling;break;case"parent":t.call(n,e.parentNode);break;case"self":t.call(n,e)}},Pathology.Axis.SHORTHANDS={"@":"attribute","..":"parent",".":"self","/":"descendant-or-self","":"child"},Pathology.Axis.fromAST=function(e){var t=e.axis_name?e.axis_name.textValue:e.textValue;return new this(this.SHORTHANDS[t]||t)},Pathology.XPathParser.Comparison={evaluate:function(e,t){var n=this.comparator.textValue,r=this.left.evaluate(e,t),i=Pathology.atomize(this.right,e,t),s=!1,o=i instanceof Array,u;if(r._nodes){for(var a=0,f=r._nodes.length;a<f;a++)u=r._nodes[a],n==="="?s=s||(o?Pathology.indexOf(i,u.nodeValue)>=0:u.nodeValue===i||u.innerHTML===i):n==="!="&&(s=s||(o?Pathology.indexOf(i,u.nodeValue)<0:u.nodeValue!==i&&u.innerHTML!==i));return s}switch(n){case"=":return o?Pathology.indexOf(i,r.nodeValue)>=0:r==i;case"!=":return o?Pathology.indexOf(i,u.nodeValue)<0:r!=i}}},Pathology.XPathParser.FunctionCall={getArguments:function(e,t){var n=[],r=this.function_args.rest;this.function_args.first&&this.function_args.first.evaluate&&n.push(this.function_args.first.evaluate(e,t));if(r)for(var i=0,s=r.elements.length;i<s;i++)n.push(r.elements[i].expression.evaluate(e,t));return n},evaluate:function(e,t){var n=this.getArguments(e,t),r=this.REGISTER[this.function_name.textValue];return r.apply(e,n)},REGISTER:{concat:function(){var e="";for(var t=0,n=arguments.length;t<n;t++)e+=arguments[t].makeString?arguments[t].makeString():arguments[t];return e},contains:function(e,t){return e?(e.makeString&&(e=e.makeString()),e.toString().indexOf(t)>=0):!1},"normalize-space":function(e){return e.makeString&&(e=e.makeString()),e.toString().replace(/^\s*/g,"").replace(/\s*$/g,"").replace(/\s+/g," ")},name:function(){return this.nodeName.toLowerCase()},not:function(e){return e&&e.atomize&&(e=e.atomize()),typeof e=="string"?!1:!e},string:function(e){return e.atomize().innerText},text:function(){return document.evaluate("/text()",this,null,XPathResult.ANY_TYPE,null)}}},Pathology.XPathParser.LocationPath={eachStep:function(e,t){var n=[this.head].concat(this.rest.elements);for(var r=0,i=n.length;r<i;r++)e.call(t,n[r])},evaluate:function(e,t,n,r){r=r||new Pathology.XPathResult(XPathResult.ANY_TYPE),n=n||XPathResult.ANY_TYPE;var i=new Pathology.XPathResult(n),s=this.head.isRelative()?e:t,o=[this.head].concat(this.rest.elements),u,a,f,l,c,h;i.push(s);for(f=0,c=o.length;f<c;f++){u=o[f],a=new Pathology.XPathResult(n);for(l=0,h=i._nodes.length;l<h;l++)u.evaluate(i._nodes[l],t,n,a);i=a}for(f=0,c=i._nodes.length;f<c;f++)r.push(i._nodes[f]);return r}},Pathology.XPathParser.LocationStep={isRelative:function(){return this.elements[0].textValue!=="/"},evaluate:function(e,t,n,r){var i=this.selector.axis,s=this.selector.test,o=[[]];Pathology.Axis.fromAST(i).walk(e,function(e){if(!s||!s.evaluate)return r.push(e);s.evaluate(e,this.predicates,t,n,o,r)},this)}},Pathology.XPathParser.NodeTest={evaluate:function(e,t,n,r,i,s){var o=this.elements[0].condition_name,u=u=this.elements[0].textValue.toLowerCase(),a={expression:{evaluate:function(){if(o&&o.textValue==="node")return!0;if(o&&o.textValue==="text"){if(e.nodeType!==XPathResult.BOOLEAN_TYPE)return!1}else if(u==="*"){if(e.nodeType!==1)return!1}else{if(!e.nodeName)return!1;if(e.nodeName.toLowerCase()!==u)return!1}return!0}},subscript:this.subscript};t=[a].concat(t.elements);var f,l;for(var c=0,h=t.length;c<h;c++){i[c]=i[c]||[],l=t[c],f=Pathology.atomize(l.expression,e,n),typeof f=="string"&&(f=!0);if(!f)return;i[c].push(e);if(l.subscript.integer&&l.subscript.integer.evaluate()!==i[c].length)return}s.push(e)}},Pathology.XPathParser.Or={evaluate:function(e,t){return Pathology.atomize(this.left,e,t)||Pathology.atomize(this.right,e,t)}},Pathology.XPathParser.Integer={evaluate:function(e,t){return parseInt(this.textValue,10)}},Pathology.XPathParser.String={evaluate:function(context,root){return eval(this.textValue)}},Pathology.XPathParser.Union={evaluate:function(e,t,n,r){r=r||new Pathology.XPathResult(XPathResult.ANY_TYPE),n=n||XPathResult.ANY_TYPE,this.head.evaluate(e,t,n,r);var i=this.rest.elements;for(var s=0,o=i.length;s<o;s++)i[s].location_path.evaluate(e,t,n,r);return r}},function(){var e=function(e,t){var n;for(n in t)e[n]=t[n];return e},t={msie:!!window.attachEvent&&!window.opera,opera:!!window.opera,webkit:navigator.userAgent.indexOf("AppleWebKit/")>-1,safari:navigator.userAgent.indexOf("AppleWebKit/")>-1&&navigator.userAgent.indexOf("Chrome/")===-1,gecko:navigator.userAgent.indexOf("Gecko")>-1,mobilesafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/),rhino:navigator.userAgent.match(/Rhino/)&&!0},n=function(t,n,r){var i=r.ownerDocument.createEventObject();return e(i,n)},r={},i=1,s="_synthetic"+(new Date).getTime(),o,u,a=/keypress|keyup|keydown/,f=/load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll/,l,c=function(e,t,n,r){return new c.init(e,t,n,r)};o=function(e,t,n){return e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},u=function(e,t,n){return e.addEventListener?e.removeEventListener(t,n,!1):e.detachEvent("on"+t,n)},e(c,{init:function(e,t,n,r){var i=c.args(t,n,r),s=this;this.queue=[],this.element=i.element,typeof this[e]=="function"?this[e](i.options,i.element,function(e,t){i.callback&&i.callback.apply(s,arguments),s.done.apply(s,arguments)}):(this.result=c.trigger(e,i.options,i.element),i.callback&&i.callback.call(this,i.element,this.result))},jquery:function(e,t){return window.FuncUnit&&window.FuncUnit.jQuery?window.FuncUnit.jQuery:e?c.helpers.getWindow(e).jQuery||window.jQuery:window.jQuery},args:function(){var e={},t=0;for(;t<arguments.length;t++)typeof arguments[t]=="function"?e.callback=arguments[t]:arguments[t]&&arguments[t].jquery?e.element=arguments[t][0]:arguments[t]&&arguments[t].nodeName?e.element=arguments[t]:e.options&&typeof arguments[t]=="string"?e.element=document.getElementById(arguments[t]):arguments[t]&&(e.options=arguments[t]);return e},click:function(e,t,n){c("click!",e,t,n)},defaults:{focus:function(){if(!c.support.focusChanges){var e=this,t=e.nodeName.toLowerCase();c.data(e,"syntheticvalue",e.value),(t==="input"||t==="textarea")&&o(e,"blur",function(){c.data(e,"syntheticvalue")!=e.value&&c.trigger("change",{},e),u(e,"blur",arguments.callee)})}},submit:function(){c.onParents(this,function(e){if(e.nodeName.toLowerCase()==="form")return e.submit(),!1})}},changeOnBlur:function(e,t,n){o(e,"blur",function(){n!==e[t]&&c.trigger("change",{},e),u(e,"blur",arguments.callee)})},closest:function(e,t){while(e&&e.nodeName.toLowerCase()!==t.toLowerCase())e=e.parentNode;return e},data:function(e,t,n){var o;e[s]||(e[s]=i++),r[e[s]]||(r[e[s]]={}),o=r[e[s]];if(!n)return r[e[s]][t];r[e[s]][t]=n},onParents:function(e,t){var n;while(e&&n!==!1)n=t(e),e=e.parentNode;return e},focusable:/^(a|area|frame|iframe|label|input|select|textarea|button|html|object)$/i,isFocusable:function(e){var t;return(this.focusable.test(e.nodeName)||(t=e.getAttributeNode("tabIndex"))&&t.specified)&&c.isVisible(e)},isVisible:function(e){return e.offsetWidth&&e.offsetHeight||e.clientWidth&&e.clientHeight},tabIndex:function(e){var t=e.getAttributeNode("tabIndex");return t&&t.specified&&(parseInt(e.getAttribute("tabIndex"))||0)},bind:o,unbind:u,browser:t,helpers:{createEventObject:n,createBasicStandardEvent:function(t,n,r){var i;try{i=r.createEvent("Events")}catch(s){i=r.createEvent("UIEvents")}finally{i.initEvent(t,!0,!0),e(i,n)}return i},inArray:function(e,t){var n=0;for(;n<t.length;n++)if(t[n]===e)return n;return-1},getWindow:function(e){return e.ownerDocument.defaultView||e.ownerDocument.parentWindow},extend:e,scrollOffset:function(e,t){var n=e.document.documentElement,r=e.document.body;if(!t)return{left:(n&&n.scrollLeft||r&&r.scrollLeft||0)+(n.clientLeft||0),top:(n&&n.scrollTop||r&&r.scrollTop||0)+(n.clientTop||0)};window.scrollTo(t.left,t.top)},scrollDimensions:function(e){var t=e.document.documentElement,n=e.document.body,r=t.clientWidth,i=t.clientHeight,s=e.document.compatMode==="CSS1Compat";return{height:s&&i||n.clientHeight||i,width:s&&r||n.clientWidth||r}},addOffset:function(e,t){var n=c.jquery(t),r;typeof e=="object"&&e.clientX===undefined&&e.clientY===undefined&&e.pageX===undefined&&e.pageY===undefined&&n&&(t=n(t),r=t.offset(),e.pageX=r.left+t.width()/2,e.pageY=r.top+t.height()/2)}},key:{ctrlKey:null,altKey:null,shiftKey:null,metaKey:null},dispatch:function(e,t,n,r){if(t.dispatchEvent&&e){var i=e.preventDefault,s=r?-1:0;return r&&o(t,n,function(e){e.preventDefault(),u(this,n,arguments.callee)}),e.preventDefault=function(){s++,++s>0&&i.apply(this,[])},t.dispatchEvent(e),s<=0}try{window.event=e}catch(a){}return t.sourceIndex<=0||t.fireEvent&&t.fireEvent("on"+n,e)},create:{page:{event:function(e,t,r){var i=c.helpers.getWindow(r).document||document,s;if(i.createEvent)return s=i.createEvent("Events"),s.initEvent(e,!0,!0),s;try{s=n(e,t,r)}catch(o){}return s}},focus:{event:function(e,t,n){return c.onParents(n,function(e){if(c.isFocusable(e)){if(e.nodeName.toLowerCase()!=="html")e.focus(),l=e;else if(l){var t=c.helpers.getWindow(n).document;if(t!==window.document)return!1;t.activeElement?(t.activeElement.blur(),l=null):(l.blur(),l=null)}return!1}}),!0}}},support:{clickChanges:!1,clickSubmits:!1,keypressSubmits:!1,mouseupSubmits:!1,radioClickChanges:!1,focusChanges:!1,linkHrefJS:!1,keyCharacters:!1,backspaceWorks:!1,mouseDownUpClicks:!1,tabKeyTabs:!1,keypressOnAnchorClicks:!1,optionClickBubbles:!1,ready:0},trigger:function(e,t,n){t||(t={});var r=c.create,i=r[e]&&r[e].setup,s=a.test(e)?"key":f.test(e)?"page":"mouse",o=r[e]||{},u=r[s],l,h,p,d=n;return c.support.ready===2&&i&&i(e,t,n),p=t._autoPrevent,delete t._autoPrevent,o.event?h=o.event(e,t,n):(t=u.options?u.options(e,t,n):t,!c.support.changeBubbles&&/option/i.test(n.nodeName)&&(d=n.parentNode),l=u.event(e,t,d),h=c.dispatch(l,d,e,p)),h&&c.support.ready===2&&c.defaults[e]&&c.defaults[e].call(n,t,p),h},eventSupported:function(e){var t=document.createElement("div");e="on"+e;var n=e in t;return n||(t.setAttribute(e,"return;"),n=typeof t[e]=="function"),t=null,n}}),e(c.init.prototype,{then:function(e,t,n,r){c.autoDelay&&this.delay();var i=c.args(t,n,r),s=this;return this.queue.unshift(function(t,n){if(typeof this[e]!="function")return this.result=c.trigger(e,i.options,i.element),i.callback&&i.callback.call(this,i.element,this.result),this;this.element=i.element||t,this[e](i.options,this.element,function(e,t){i.callback&&i.callback.apply(s,arguments),s.done.apply(s,arguments)})}),this},delay:function(e,t){typeof e=="function"&&(t=e,e=null),e=e||600;var n=this;return this.queue.unshift(function(){setTimeout(function(){t&&t.apply(n,[]),n.done.apply(n,arguments)},e)}),this},done:function(e,t){t&&(this.element=t),this.queue.length&&this.queue.pop().call(this,this.element,e)},_click:function(e,t,n,r){c.helpers.addOffset(e,t),c.trigger("mousedown",e,t),setTimeout(function(){c.trigger("mouseup",e,t),!c.support.mouseDownUpClicks||r?(c.trigger("click",e,t),n(!0)):(c.create.click.setup("click",e,t),c.defaults.click.call(t),setTimeout(function(){n(!0)},1))},1)},_rightClick:function(t,n,r){c.helpers.addOffset(t,n);var i=e(e({},c.mouse.browser.right.mouseup),t);c.trigger("mousedown",i,n),setTimeout(function(){c.trigger("mouseup",i,n),c.mouse.browser.right.contextmenu&&c.trigger("contextmenu",e(e({},c.mouse.browser.right.contextmenu),t),n),r(!0)},1)},_dblclick:function(e,t,n){c.helpers.addOffset(e,t);var r=this;this._click(e,t,function(){setTimeout(function(){r._click(e,t,function(){c.trigger("dblclick",e,t),n(!0)},!0)},2)})}});var h=["click","dblclick","move","drag","key","type","rightClick"],p=function(e){c[e]=function(t,n,r){return c("_"+e,t,n,r)},c.init.prototype[e]=function(t,n,r){return this.then("_"+e,t,n,r)}},d=0;for(;d<h.length;d++)p(h[d]);if(window.FuncUnit&&window.FuncUnit.jQuery||window.jQuery)(window.FuncUnit&&window.FuncUnit.jQuery||window.jQuery).fn.triggerSyn=function(e,t,n){if(!this[0])throw"Can't "+e.substring(1)+" because no element matching '"+this.selector+"' was found";return c(e,t,this[0],n),this};window.Syn=c}(),function(){var h=Syn.helpers,getWin=h.getWindow;Syn.mouse={},h.extend(Syn.defaults,{mousedown:function(e){Syn.trigger("focus",{},this)},click:function(){var element=this;try{element.nodeType}catch(e){return}var href,radioChanged=Syn.data(element,"radioChanged"),scope=getWin(element),nodeName=element.nodeName.toLowerCase();if(!Syn.support.linkHrefJS&&/^\s*javascript:/.test(element.href)){var code=element.href.replace(/^\s*javascript:/,"");code!="//"&&code.indexOf("void(0)")==-1&&(window.selenium?eval("with(selenium.browserbot.getCurrentWindow()){"+code+"}"):eval("with(scope){"+code+"}"))}if(!Syn.support.clickSubmits&&nodeName=="input"&&element.type=="submit"||nodeName=="button"){var form=Syn.closest(element,"form");form&&Syn.trigger("submit",{},form)}nodeName=="a"&&element.href&&!/^\s*javascript:/.test(element.href)&&(scope.location.href=element.href),nodeName=="input"&&element.type=="checkbox"&&(Syn.support.clickChanges||Syn.trigger("change",{},element)),nodeName=="input"&&element.type=="radio"&&radioChanged&&!Syn.support.radioClickChanges&&Syn.trigger("change",{},element),nodeName=="option"&&Syn.data(element,"createChange")&&(Syn.trigger("change",{},element.parentNode),Syn.data(element,"createChange",!1))}}),h.extend(Syn.create,{mouse:{options:function(e,t,n){var r=document.documentElement,i=document.body,s=[t.pageX||0,t.pageY||0],o=Syn.mouse.browser&&Syn.mouse.browser.left[e],u=Syn.mouse.browser&&Syn.mouse.browser.right[e];return h.extend({bubbles:!0,cancelable:!0,view:window,detail:1,screenX:1,screenY:1,clientX:t.clientX||s[0]-(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r.clientLeft||0),clientY:t.clientY||s[1]-(r&&r.scrollTop||i&&i.scrollTop||0)-(r.clientTop||0),ctrlKey:!!Syn.key.ctrlKey,altKey:!!Syn.key.altKey,shiftKey:!!Syn.key.shiftKey,metaKey:!!Syn.key.metaKey,button:o&&o.button!=null?o.button:u&&u.button||(e=="contextmenu"?2:0),relatedTarget:document.documentElement},t)},event:function(e,t,n){var r=getWin(n).document||document;if(r.createEvent){var i;try{i=r.createEvent("MouseEvents"),i.initMouseEvent(e,t.bubbles,t.cancelable,t.view,t.detail,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,t.relatedTarget)}catch(s){i=h.createBasicStandardEvent(e,t,r)}return i.synthetic=!0,i}var i;try{i=h.createEventObject(e,t,n)}catch(s){}return i}},click:{setup:function(e,t,n){var r=n.nodeName.toLowerCase(),e;if(!Syn.support.clickChecks&&!Syn.support.changeChecks&&r==="input"){e=n.type.toLowerCase(),e==="checkbox"&&(n.checked=!n.checked);if(e==="radio"&&!n.checked){try{Syn.data(n,"radioChanged",!0)}catch(i){}n.checked=!0}}r=="a"&&n.href&&!/^\s*javascript:/.test(n.href)&&Syn.data(n,"href",n.href);if(/option/i.test(n.nodeName)){var s=n.parentNode.firstChild,o=-1;while(s){if(s.nodeType==1){o++;if(s==n)break}s=s.nextSibling}o!==n.parentNode.selectedIndex&&(n.parentNode.selectedIndex=o,Syn.data(n,"createChange",!0))}}},mousedown:{setup:function(e,t,n){var r=n.nodeName.toLowerCase();Syn.browser.safari&&(r=="select"||r=="option")&&(t._autoPrevent=!0)}}}),function(){if(!document.body){setTimeout(arguments.callee,1);return}var e=window.__synthTest;window.__synthTest=function(){Syn.support.linkHrefJS=!0};var t=document.createElement("div"),n,r,i,s,o;t.innerHTML="<form id='outer'><input name='checkbox' type='checkbox'/><input name='radio' type='radio' /><input type='submit' name='submitter'/><input type='input' name='inputter'/><input name='one'><input name='two'/><a href='javascript:__synthTest()' id='synlink'></a><select><option></option></select></form>",document.documentElement.appendChild(t),i=t.firstChild,n=i.childNodes[0],r=i.childNodes[2],o=i.getElementsByTagName("select")[0],n.checked=!1,n.onchange=function(){Syn.support.clickChanges=!0},Syn.trigger("click",{},n),Syn.support.clickChecks=n.checked,n.checked=!1,Syn.trigger("change",{},n),Syn.support.changeChecks=n.checked,i.onsubmit=function(e){return e.preventDefault&&e.preventDefault(),Syn.support.clickSubmits=!0,!1},Syn.trigger("click",{},r),i.childNodes[1].onchange=function(){Syn.support.radioClickChanges=!0},Syn.trigger("click",{},i.childNodes[1]),Syn.bind(t,"click",function(){Syn.support.optionClickBubbles=!0,Syn.unbind(t,"click",arguments.callee)}),Syn.trigger("click",{},o.firstChild),Syn.support.changeBubbles=Syn.eventSupported("change");var u=0;t.onclick=function(){Syn.support.mouseDownUpClicks=!0},Syn.trigger("mousedown",{},t),Syn.trigger("mouseup",{},t),document.documentElement.removeChild(t),window.__synthTest=e,Syn.support.ready++}()}(),function(){Syn.key.browsers={webkit:{prevent:{keyup:[],keydown:["char","keypress"],keypress:["char"]},character:{keydown:[0,"key"],keypress:["char","char"],keyup:[0,"key"]},specialChars:{keydown:[0,"char"],keyup:[0,"char"]},navigation:{keydown:[0,"key"],keyup:[0,"key"]},special:{keydown:[0,"key"],keyup:[0,"key"]},tab:{keydown:[0,"char"],keyup:[0,"char"]},"pause-break":{keydown:[0,"key"],keyup:[0,"key"]},caps:{keydown:[0,"key"],keyup:[0,"key"]},escape:{keydown:[0,"key"],keyup:[0,"key"]},"num-lock":{keydown:[0,"key"],keyup:[0,"key"]},"scroll-lock":{keydown:[0,"key"],keyup:[0,"key"]},print:{keyup:[0,"key"]},"function":{keydown:[0,"key"],keyup:[0,"key"]},"\r":{keydown:[0,"key"],keypress:["char","key"],keyup:[0,"key"]}},gecko:{prevent:{keyup:[],keydown:["char"],keypress:["char"]},character:{keydown:[0,"key"],keypress:["char",0],keyup:[0,"key"]},specialChars:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},navigation:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},special:{keydown:[0,"key"],keyup:[0,"key"]}," ":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},"pause-break":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},caps:{keydown:[0,"key"],keyup:[0,"key"]},escape:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},"num-lock":{keydown:[0,"key"],keyup:[0,"key"]},"scroll-lock":{keydown:[0,"key"],keyup:[0,"key"]},print:{keyup:[0,"key"]},"function":{keydown:[0,"key"],keyup:[0,"key"]},"\r":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]}},msie:{prevent:{keyup:[],keydown:["char","keypress"],keypress:["char"]},character:{keydown:[null,"key"],keypress:[null,"char"],keyup:[null,"key"]},specialChars:{keydown:[null,"char"],keyup:[null,"char"]},navigation:{keydown:[null,"key"],keyup:[null,"key"]},special:{keydown:[null,"key"],keyup:[null,"key"]},tab:{keydown:[null,"char"],keyup:[null,"char"]},"pause-break":{keydown:[null,"key"],keyup:[null,"key"]},caps:{keydown:[null,"key"],keyup:[null,"key"]},escape:{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},"num-lock":{keydown:[null,"key"],keyup:[null,"key"]},"scroll-lock":{keydown:[null,"key"],keyup:[null,"key"]},print:{keyup:[null,"key"]},"function":{keydown:[null,"key"],keyup:[null,"key"]},"\r":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]}},opera:{prevent:{keyup:[],keydown:[],keypress:["char"]},character:{keydown:[null,"key"],keypress:[null,"char"],keyup:[null,"key"]},specialChars:{keydown:[null,"char"],keypress:[null,"char"],keyup:[null,"char"]},navigation:{keydown:[null,"key"],keypress:[null,"key"]},special:{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},tab:{keydown:[null,"char"],keypress:[null,"char"],keyup:[null,"char"]},"pause-break":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},caps:{keydown:[null,"key"],keyup:[null,"key"]},escape:{keydown:[null,"key"],keypress:[null,"key"]},"num-lock":{keyup:[null,"key"],keydown:[null,"key"],keypress:[null,"key"]},"scroll-lock":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},print:{},"function":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},"\r":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]}}},Syn.mouse.browsers={webkit:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},opera:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},msie:{right:{mousedown:{button:2},mouseup:{button:2},contextmenu:{button:0}},left:{mousedown:{button:1},mouseup:{button:1},click:{button:0}}},chrome:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},gecko:{left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}},right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}}}},Syn.key.browser=function(){if(Syn.key.browsers[window.navigator.userAgent])return Syn.key.browsers[window.navigator.userAgent];for(var e in Syn.browser)if(Syn.browser[e]&&Syn.key.browsers[e])return Syn.key.browsers[e];return Syn.key.browsers.gecko}(),Syn.mouse.browser=function(){if(Syn.mouse.browsers[window.navigator.userAgent])return Syn.mouse.browsers[window.navigator.userAgent];for(var e in Syn.browser)if(Syn.browser[e]&&Syn.mouse.browsers[e])return Syn.mouse.browsers[e];return Syn.mouse.browsers
3
- .gecko}()}(),function(){(function(){if(!document.body){setTimeout(arguments.callee,1);return}var e=document.createElement("div");document.body.appendChild(e),Syn.helpers.extend(e.style,{width:"100px",height:"10000px",backgroundColor:"blue",position:"absolute",top:"10px",left:"0px",zIndex:19999}),document.body.scrollTop=11;if(!document.elementFromPoint)return;var t=document.elementFromPoint(3,1);t==e?Syn.support.elementFromClient=!0:Syn.support.elementFromPage=!0,document.body.removeChild(e),document.body.scrollTop=0})();var e=function(e,t){var n=e.clientX,r=e.clientY,i=Syn.helpers.getWindow(t),s;if(Syn.support.elementFromPage){var o=Syn.helpers.scrollOffset(i);n+=o.left,r+=o.top}return s=i.document.elementFromPoint?i.document.elementFromPoint(n,r):t,s===i.document.documentElement&&(e.clientY<0||e.clientX<0)?t:s},t=function(t,n,r){var i=e(n,r);return Syn.trigger(t,n,i||r),i},n=function(t,n,r){var i=e(t,n);if(r!=i&&i&&r){var s=Syn.helpers.extend({},t);s.relatedTarget=i,Syn.trigger("mouseout",s,r),s.relatedTarget=r,Syn.trigger("mouseover",s,i)}return Syn.trigger("mousemove",t,i||n),i},r=function(t,r,i,s,o){var u=new Date,a=r.clientX-t.clientX,f=r.clientY-t.clientY,l=Syn.helpers.getWindow(s),c=e(t,s),h=l.document.createElement("div"),p=0;move=function(){var e=new Date,d=Syn.helpers.scrollOffset(l),v=(p==0?0:e-u)/i,m={clientX:a*v+t.clientX,clientY:f*v+t.clientY};p++,v<1?(Syn.helpers.extend(h.style,{left:m.clientX+d.left+2+"px",top:m.clientY+d.top+2+"px"}),c=n(m,s,c),setTimeout(arguments.callee,15)):(c=n(r,s,c),l.document.body.removeChild(h),o())},Syn.helpers.extend(h.style,{height:"5px",width:"5px",backgroundColor:"red",position:"absolute",zIndex:19999,fontSize:"1px"}),l.document.body.appendChild(h),move()},i=function(e,n,i,s,o){t("mousedown",e,s),r(e,n,i,s,function(){t("mouseup",n,s),o()})},s=function(e){var t=Syn.jquery()(e),n=t.offset();return{pageX:n.left+t.outerWidth()/2,pageY:n.top+t.outerHeight()/2}},o=function(e,t,n){var r=/(\d+)[x ](\d+)/,i=/(\d+)X(\d+)/,o=/([+-]\d+)[xX ]([+-]\d+)/;if(typeof e=="string"&&o.test(e)&&n){var u=s(n),a=e.match(o);e={pageX:u.pageX+parseInt(a[1]),pageY:u.pageY+parseInt(a[2])}}if(typeof e=="string"&&r.test(e)){var a=e.match(r);e={pageX:parseInt(a[1]),pageY:parseInt(a[2])}}if(typeof e=="string"&&i.test(e)){var a=e.match(i);e={clientX:parseInt(a[1]),clientY:parseInt(a[2])}}typeof e=="string"&&(e=Syn.jquery()(e,t.document)[0]),e.nodeName&&(e=s(e));if(e.pageX){var f=Syn.helpers.scrollOffset(t);e={clientX:e.pageX-f.left,clientY:e.pageY-f.top}}return e},u=function(e,t,n){if(e.clientY<0){var r=Syn.helpers.scrollOffset(n),i=Syn.helpers.scrollDimensions(n),s=r.top+e.clientY-100,o=s-r.top;s>0||(s=0,o=-r.top),e.clientY=e.clientY-o,t.clientY=t.clientY-o,Syn.helpers.scrollOffset(n,{top:s,left:r.left})}};Syn.helpers.extend(Syn.init.prototype,{_move:function(e,t,n){var i=Syn.helpers.getWindow(t),s=o(e.from||t,i,t),a=o(e.to||e,i,t);e.adjust!==!1&&u(s,a,i),r(s,a,e.duration||500,t,n)},_drag:function(e,t,n){var r=Syn.helpers.getWindow(t),s=o(e.from||t,r,t),a=o(e.to||e,r,t);e.adjust!==!1&&u(s,a,r),i(s,a,e.duration||500,t,n)}})}(),Terminus={isIE:/\bMSIE\b/.test(navigator.userAgent),connect:function(e,t){if(this._bayeux)return;this._host=e,this._pageId=Faye.random(),this._id=window.name=window.name||document.name||Faye.random(),this._id=this._id.split("|")[0];var n=document.getElementsByTagName("iframe"),r=n.length;while(r--)n[r].contentDocument.name=n[r].id;this.Registry.initialize(),this.Worker.initialize(),this.AjaxMonitor.initialize(),Faye.Event.on(window,"beforeunload",function(){Terminus.disabled=!0});var i="http://"+e+":"+t+"/messaging",s=this._bayeux=new Faye.Client(i),o=this;s.addExtension({outgoing:function(e,t){e.href=window.location.href,e.connectionType==="websocket"&&(o._socketCapable=!0),t(e)}}),this.getId(function(e){var t=window.name.split("|")[1];t||s.subscribe("/terminus/sockets/"+e,function(e){window.name+="|"+e.url,this.openSocket(e.url)},this);var n=s.subscribe("/terminus/clients/"+e,this.handleMessage,this);n.callback(function(){this.ping(),t&&this.openSocket(t)},this)},this)},browserDetails:function(e,t){this.getId(function(n){e.call(t,{host:this._host,id:n,infinite:!!window.TERMINUS_INFINITE_REDIRECT,page:this._pageId,sockets:this._socketCapable,ua:navigator.userAgent,url:window.location.href})},this)},getId:function(e,t){var n=this._id;if(this.isIE)return e.call(t,n);if(opener&&opener.Terminus)opener.Terminus.getId(function(r){e.call(t,r+"/"+n)});else if(parent&&parent!==window){var r=function(){if(!parent.Terminus)return setTimeout(r,100);parent.Terminus.getId(function(r){e.call(t,r+"/"+n)})};r()}else e.call(t,n)},openSocket:function(e){if(this.disabled||this._socket)return;var t=this,n=window.MozWebSocket||window.WebSocket,r=new n(e);r.onopen=function(){t._socket=r,up=!0},r.onclose=function(){var n=!!t._socket;t._socket=null,n?t.openSocket(e):window.name=window.name.split("|")[0]},r.onmessage=function(e){t.handleMessage(JSON.parse(e.data))}},ping:function(){if(this.disabled)return;this.browserDetails(function(e){this._bayeux.publish("/terminus/ping",e);var t=this;setTimeout(function(){t.ping()},3e3)},this)},handleMessage:function(e){var t=e.command,n=t.shift(),r=this.Driver,i=this.Worker,s=!1,o=this;t.push(function(t){if(s)return;o.postResult(e.commandId,t),s=!0}),i.monitor=!0,r[n].apply(r,t),i.monitor=!1},postResult:function(e,t){if(this.disabled||!e)return;if(this._socket)return this._socket.send(JSON.stringify({value:t}));this.getId(function(n){this._bayeux.publish("/terminus/results",{id:n,commandId:e,result:t})},this)},getAttribute:function(e,t){return Terminus.isIE?(e.getAttributeNode(t)||{}).nodeValue||!1:e.getAttribute(t)},Driver:{_node:function(e){return Terminus.Registry.get(e)},attribute:function(e,t,n){var r=this._node(e);if(!r)return n(null);!!Terminus.isIE||t!=="checked"&&t!=="selected"?n(Terminus.getAttribute(r,t)):n(!!r[t])},set_attribute:function(e,t,n,r){var i=this._node(e);if(!i)return r(null);i.setAttribute(t,n),r(!0)},body:function(e){var t=document.getElementsByTagName("html")[0];e(t.outerHTML||"<html>\n"+t.innerHTML+"\n</html>\n")},clear_cookies:function(e){var t=document.cookie.split(";"),n,r=new Date;r.setTime(r.getTime()-864e5);for(var i=0,s=t.length;i<s;i++)n=t[i].split("=")[0],document.cookie=n+"=; expires="+r.toGMTString()+"; path=/";e(!0)},click:function(e,t,n){var r=this._node(e),i=t.resynchronization_timeout;if(!r)return n(!0);Syn.trigger("click",{},r);if(t.resynchronize===!1)return n(!0);i&&Terminus.Worker._setTimeout.call(window,function(){n("failed to resynchronize, ajax request timed out")},1e3*i),Terminus.Worker.callback(function(){n(!0)})},current_url:function(e){Terminus.browserDetails(function(t){e(t.url)})},drag:function(e,t){var n=this._node(e.from),r=this._node(e.to);if(!n||!r)return t(null);Syn.drag({to:r},n,function(){t(!0)})},evaluate:function(expression,callback){callback(eval(expression))},execute:function(expression,callback){eval(expression),callback(!0)},find:function(e,t,n){var r=t?this._node(t):document;if(!r)return n([]);var i=document.evaluate(e,r,null,XPathResult.ANY_TYPE,null),s=[],o;while(o=i.iterateNext())s.push(Terminus.Registry.put(o));return n(s)},is_visible:function(e,t){var n=this._node(e);if(!n)return t(null);while(n.tagName&&n.tagName.toLowerCase()!=="body"){if(n.style.display==="none"||n.type==="hidden")return t(!1);n=n.parentNode}t(!0)},select:function(e,t){var n=this._node(e);if(!n)return t(null);n.selected=!0,Syn.trigger("change",{},n.parentNode),t(!0)},set:function(e,t,n){var r=this._node(e),i=Terminus.getAttribute(r,"maxlength");if(!r)return n(null);if(r.type==="file")return n("not_allowed");Syn.trigger("focus",{},r),Syn.trigger("click",{},r);switch(typeof t){case"string":i&&(t=t.substr(0,parseInt(i))),r.value=t;break;case"boolean":r.checked=t}Syn.trigger("change",{},r),n(!0)},tag_name:function(e,t){var n=this._node(e);if(!n)return t(null);t(n.tagName.toLowerCase())},text:function(e,t){var n=this._node(e);if(!n)return t(null);var r=n.textContent||n.innerText||"",i=n.getElementsByTagName("script"),s=i.length;while(s--)r=r.replace(i[s].textContent||i[s].innerText,"");r=r.replace(/^\s*|\s*$/g,""),t(r)},trigger:function(e,t,n){var r=this._node(e);if(!r)return n(null);Syn.trigger(t,{},r),n(!0)},unselect:function(e,t){var n=this._node(e);if(!n)return t(null);if(!n.parentNode.multiple)return t(!1);n.selected=!1,Syn.trigger("change",{},n.parentNode),t(!0)},value:function(e,t){var n=this._node(e);if(!n)return t(null);if(n.tagName.toLowerCase()!=="select"||!n.multiple)return t(n.value);var r=n.children,i=[];for(var s=0,o=r.length;s<o;s++)r[s].selected&&i.push(r[s].value);t(i)},visit:function(e,t){window.location.href=e,t(e)}},Registry:{initialize:function(){this._namespace=new Faye.Namespace,this._elements={}},get:function(e){var t=this._elements[e],n=t;while(n&&n.tagName!=="BODY"&&n.tagName!=="HTML")n=n.parentNode;return n?t:null},put:function(e){var t=this._namespace.generate();return this._elements[t]=e,t}},Worker:{initialize:function(){this._callbacks=[],this._pending=0,Terminus.isIE||this._wrapTimeouts()},callback:function(e,t){this._pending===0?this._setTimeout?this._setTimeout.call(window,function(){e.call(t)},0):setTimeout(function(){e.call(t)},0):this._callbacks.push([e,t])},suspend:function(){this._pending+=1},resume:function(){if(this._pending===0)return;this._pending-=1;if(this._pending!==0)return;var e;for(var t=0,n=this._callbacks.length;t<n;t++)e=this._callbacks[t],e[0].call(e[1]);this._callbacks=[]},_wrapTimeouts:function(){var timeout=window.setTimeout,clear=window.clearTimeout,timeouts={},self=this,finish=function(e){if(!timeouts.hasOwnProperty(e))return;delete timeouts[e],self.resume()};window.setTimeout=function(callback,delay){var id=timeout.call(window,function(){try{switch(typeof callback){case"function":callback();break;case"string":eval(callback)}}finally{finish(id)}},delay);return self.monitor&&(timeouts[id]=!0,self.suspend()),id},window.clearTimeout=function(e){return finish(e),clear(e)},this._setTimeout=timeout}},AjaxMonitor:{initialize:function(){window.jQuery&&this._patchJquery()},_patchJquery:function(){var e=jQuery.ajax;jQuery.ajax=function(t,n){var r=(typeof t=="string"?n:t)||{},i=r.complete,s=Terminus.Worker.monitor;return r.complete=function(){var e;try{e=i.apply(this,arguments)}finally{s&&Terminus.Worker.resume()}return e},s&&Terminus.Worker.suspend(),typeof t=="string"?e.call(jQuery,t,r):e.call(jQuery,r)}}}};
1
+ var Pathology={evaluate:function(t,e,s,n,i){i=i||new Pathology.XPathResult(n);var o=Pathology.XPathParser.parse(t);return o.evaluate(e,e,n,i),i},atomize:function(t,e,s){var n=t.evaluate(e,s);return n&&n.atomize&&(n=n.atomize()),n},array:function(t){if(!t)return[];for(var e=[],s=t.length;s--;)e[s]=t[s];return e},indexOf:function(t,e){if(t.indexOf)return t.indexOf(e);for(var s=0,n=t.length;n>s;s++)if(t[s]===e)return s;return-1}};"undefined"==typeof XPathResult&&(XPathResult={ANY_TYPE:0,NUMBER_TYPE:1,STRING_TYPE:2,BOOLEAN_TYPE:3,UNORDERED_NODE_ITERATOR_TYPE:4,ORDERED_NODE_ITERATOR_TYPE:5,UNORDERED_NODE_SNAPSHOT_TYPE:6,ORDERED_NODE_SNAPSHOT_TYPE:7,ANY_UNORDERED_NODE_TYPE:8,FIRST_ORDERED_NODE_TYPE:9}),document.evaluate===void 0&&(document.evaluate=function(){return Pathology.evaluate.apply(Pathology,arguments)}),Pathology.XPathResult=function(t){this._type=t,this._nodes=[],this._index=0},Pathology.XPathResult.prototype.push=function(t){(0===this._type||t.nodeType===this._type)&&(Pathology.indexOf(this._nodes,t)>=0||this._nodes.push(t))},Pathology.XPathResult.prototype.iterateNext=function(){var t=this._nodes[this._index];return t?(this._index+=1,t):null},Pathology.XPathResult.prototype.atomize=function(){if(0===this._nodes.length)return null;if(1===this._nodes.length){var t=this._nodes[0];return void 0===t.nodeValue||null===t.nodeValue?t:t.nodeValue}for(var e=[],s=0,n=this._nodes.length;n>s;s++)e.push(this._nodes[s].nodeValue);return e},Pathology.XPathResult.prototype.makeString=function(){var t=this._nodes[0];if(!t)return"";switch(t.nodeType){case XPathResult.STRING_TYPE:return this.atomize();case XPathResult.BOOLEAN_TYPE:for(var e=[],s=0,n=this._nodes.length;n>s;s++)e.push(this._nodes[s].nodeValue);return e.join("");default:var i=document.evaluate("//text()",t,null,XPathResult.ANY_TYPE,null);return i.makeString()}},function(){var t=function(t,e){if(!t||!e)return t;for(var s in e)t[s]!==e[s]&&(t[s]=e[s]);return t},e=function(t,e){for(var s,n=e.split(".");s=n.shift();)if(t=t[s],void 0===t)throw Error("Cannot find object named "+e);return t},s=function(t){for(var e=t.input.split(/\n/g),s=0,n=0;t.offset+1>n;)n+=e[s].length+1,s+=1;var i="Line "+s+": expected "+t.expected+"\n",o=e[s-1];for(i+=o+"\n",n-=o.length+1;t.offset>n;)i+=" ",n+=1;return i+"^"},n={__consume__union_expression:function(){var s=null,n=this._offset;this._nodeCache.union_expression=this._nodeCache.union_expression||{};var i=this._nodeCache.union_expression[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null;if(l=this.__consume__location_path()){r.push(l),u+=l.textValue,f.head=l;for(var h=null,a=0,c=this._offset,_=[],p="",d=!0;d;){var y=this._offset,g=[],m={},v="",k=null;if(k=this.__consume__space()){g.push(k),v+=k.textValue,m.space=k;var b=null,x=null;if(x=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"|"===x){var w=this.constructor.SyntaxNode,S=null;b=new w("|",this._offset,[]),"object"==typeof S&&t(b,S),this._offset+=1}else{b=null;var N=null;N=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"|"'})}if(b){g.push(b),v+=b.textValue;var C=null;if(C=this.__consume__space()){g.push(C),v+=C.textValue,m.space=C;var E=null;E=this.__consume__location_path(),E?(g.push(E),v+=E.textValue,m.location_path=E):(g=null,this._offset=y)}else g=null,this._offset=y}else g=null,this._offset=y}else g=null,this._offset=y;if(g){this._offset=y;var P=this.constructor.SyntaxNode,T=null;d=new P(v,this._offset,g,m),"object"==typeof T&&t(d,T),this._offset+=v.length}else d=null;d&&(_.push(d),p+=d.textValue,a-=1)}if(0>=a){this._offset=c;var V=this.constructor.SyntaxNode,j=null;h=new V(p,this._offset,_),"object"==typeof j&&t(h,j),this._offset+=p.length}else h=null;h?(r.push(h),u+=h.textValue,f.rest=h):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var X=this.constructor.SyntaxNode,R=e(this.constructor,"Union");s=new X(u,this._offset,r,f),"object"==typeof R&&t(s,R),this._offset+=u.length}else s=null;return this._nodeCache.union_expression[n]=s},__consume__location_path:function(){var s=null,n=this._offset;this._nodeCache.location_path=this._nodeCache.location_path||{};var i=this._nodeCache.location_path[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null;if(l=this.__consume__location_step()){r.push(l),u+=l.textValue,f.head=l;for(var h=null,a=0,c=this._offset,_=[],p="",d=!0;d;)d=this.__consume__location_step(),d&&(_.push(d),p+=d.textValue,a-=1);if(0>=a){this._offset=c;var y=this.constructor.SyntaxNode,g=null;h=new y(p,this._offset,_),"object"==typeof g&&t(h,g),this._offset+=p.length}else h=null;h?(r.push(h),u+=h.textValue,f.rest=h):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var m=this.constructor.SyntaxNode,v=e(this.constructor,"LocationPath");s=new m(u,this._offset,r,f),"object"==typeof v&&t(s,v),this._offset+=u.length}else s=null;return this._nodeCache.location_path[n]=s},__consume__location_step:function(){var s=null,n=this._offset;this._nodeCache.location_step=this._nodeCache.location_step||{};var i=this._nodeCache.location_step[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null,h=this._offset,a=null;if(a=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"/"===a){var c=this.constructor.SyntaxNode,_=null;l=new c("/",this._offset,[]),"object"==typeof _&&t(l,_),this._offset+=1}else{l=null;var p=null;p=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"/"'})}if(l);else{this._offset=h;var d=this.constructor.SyntaxNode,y=null;l=new d("",this._offset,[]),"object"==typeof y&&t(l,y),this._offset+=0}if(l){r.push(l),u+=l.textValue;var g=null,m=this._offset,v=this._offset,k=[],b={},x="",w=null;if(w=this.__consume__axis()){k.push(w),x+=w.textValue,b.axis=w;var S=null,N=this._offset;if(S=this.__consume__node_test());else{this._offset=N;var C=this.constructor.SyntaxNode,E=null;S=new C("",this._offset,[]),"object"==typeof E&&t(S,E),this._offset+=0}S?(k.push(S),x+=S.textValue,b.test=S):(k=null,this._offset=v)}else k=null,this._offset=v;if(k){this._offset=v;var P=this.constructor.SyntaxNode,T=null;g=new P(x,this._offset,k,b),"object"==typeof T&&t(g,T),this._offset+=x.length}else g=null;if(g);else{this._offset=m;var V=this._offset,j=[],X={},R="",A=null,Y=this._offset;if(A=this.__consume__axis());else{this._offset=Y;var O=this.constructor.SyntaxNode,I=null;A=new O("",this._offset,[]),"object"==typeof I&&t(A,I),this._offset+=0}if(A){j.push(A),R+=A.textValue,X.axis=A;var D=null;D=this.__consume__node_test(),D?(j.push(D),R+=D.textValue,X.test=D):(j=null,this._offset=V)}else j=null,this._offset=V;if(j){this._offset=V;var L=this.constructor.SyntaxNode,z=null;g=new L(R,this._offset,j,X),"object"==typeof z&&t(g,z),this._offset+=R.length}else g=null;g||(this._offset=m)}if(g){r.push(g),u+=g.textValue,f.selector=g;for(var W=null,F=0,H=this._offset,M=[],K="",U=!0;U;)U=this.__consume__node_predicate(),U&&(M.push(U),K+=U.textValue,F-=1);if(0>=F){this._offset=H;var B=this.constructor.SyntaxNode,q=null;W=new B(K,this._offset,M),"object"==typeof q&&t(W,q),this._offset+=K.length}else W=null;W?(r.push(W),u+=W.textValue,f.predicates=W):(r=null,this._offset=o)}else r=null,this._offset=o}else r=null,this._offset=o;if(r){this._offset=o;var Q=this.constructor.SyntaxNode,G=e(this.constructor,"LocationStep");s=new Q(u,this._offset,r,f),"object"==typeof G&&t(s,G),this._offset+=u.length}else s=null;return this._nodeCache.location_step[n]=s},__consume__axis:function(){var e=null,s=this._offset;this._nodeCache.axis=this._nodeCache.axis||{};var n=this._nodeCache.axis[s];if(n)return this._offset+=n.textValue.length,n;for(var i=this._offset,o=this._offset,r=[],f={},u="",l=null,h=1,a=this._offset,c=[],_="",p=!0;p;){var d=null;if(d=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,d&&/^[a-z\-]/.test(d)){var y=this.constructor.SyntaxNode,g=null;p=new y(d,this._offset,[]),"object"==typeof g&&t(p,g),this._offset+=1}else{p=null;var m=null;m=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"})}p&&(c.push(p),_+=p.textValue,h-=1)}if(0>=h){this._offset=a;var v=this.constructor.SyntaxNode,k=null;l=new v(_,this._offset,c),"object"==typeof k&&t(l,k),this._offset+=_.length}else l=null;if(l){r.push(l),u+=l.textValue,f.axis_name=l;var b=null,x=null;if(x=this._input.length>this._offset?this._input.substring(this._offset,this._offset+2):null,"::"===x){var w=this.constructor.SyntaxNode,S=null;b=new w("::",this._offset,[]),"object"==typeof S&&t(b,S),this._offset+=2}else{b=null;var N=null;N=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"::"'})}b?(r.push(b),u+=b.textValue):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var C=this.constructor.SyntaxNode,E=null;e=new C(u,this._offset,r,f),"object"==typeof E&&t(e,E),this._offset+=u.length}else e=null;return e||(this._offset=i,e=this.__consume__axis_shorthand(),e||(this._offset=i)),this._nodeCache.axis[s]=e},__consume__axis_shorthand:function(){var e=null,s=this._offset;this._nodeCache.axis_shorthand=this._nodeCache.axis_shorthand||{};var n=this._nodeCache.axis_shorthand[s];if(n)return this._offset+=n.textValue.length,n;var i=this._offset,o=null;if(o=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"@"===o){var r=this.constructor.SyntaxNode,f=null;e=new r("@",this._offset,[]),"object"==typeof f&&t(e,f),this._offset+=1}else{e=null;var u=null;u=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"@"'})}if(e);else{this._offset=i;var l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+2):null,".."===l){var h=this.constructor.SyntaxNode,a=null;e=new h("..",this._offset,[]),"object"==typeof a&&t(e,a),this._offset+=2}else{e=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'".."'})}if(e);else{this._offset=i;var _=null;if(_=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"."===_){var p=this.constructor.SyntaxNode,d=null;e=new p(".",this._offset,[]),"object"==typeof d&&t(e,d),this._offset+=1}else{e=null;var y=null;y=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"."'})}if(e);else{this._offset=i;var g=null;if(g=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"/"===g){var m=this.constructor.SyntaxNode,v=null;e=new m("/",this._offset,[]),"object"==typeof v&&t(e,v),this._offset+=1}else{e=null;var k=null;k=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"/"'})}e||(this._offset=i)}}}return this._nodeCache.axis_shorthand[s]=e},__consume__node_test:function(){var s=null,n=this._offset;this._nodeCache.node_test=this._nodeCache.node_test||{};var i=this._nodeCache.node_test[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null,h=this._offset;if(l=this.__consume__node_condition());else if(this._offset=h,l=this.__consume__node_name());else{this._offset=h;var a=null;if(a=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"*"===a){var c=this.constructor.SyntaxNode,_=null;l=new c("*",this._offset,[]),"object"==typeof _&&t(l,_),this._offset+=1}else{l=null;var p=null;p=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"*"'})}l||(this._offset=h)}if(l){r.push(l),u+=l.textValue;var d=null,y=this._offset;if(d=this.__consume__subscript());else{this._offset=y;var g=this.constructor.SyntaxNode,m=null;d=new g("",this._offset,[]),"object"==typeof m&&t(d,m),this._offset+=0}d?(r.push(d),u+=d.textValue,f.subscript=d):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var v=this.constructor.SyntaxNode,k=e(this.constructor,"NodeTest");s=new v(u,this._offset,r,f),"object"==typeof k&&t(s,k),this._offset+=u.length}else s=null;return this._nodeCache.node_test[n]=s},__consume__node_condition:function(){var e=null,s=this._offset;this._nodeCache.node_condition=this._nodeCache.node_condition||{};var n=this._nodeCache.node_condition[s];if(n)return this._offset+=n.textValue.length,n;for(var i=this._offset,o=[],r={},f="",u=null,l=1,h=this._offset,a=[],c="",_=!0;_;){var p=null;if(p=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,p&&/^[a-z\-]/.test(p)){var d=this.constructor.SyntaxNode,y=null;_=new d(p,this._offset,[]),"object"==typeof y&&t(_,y),this._offset+=1}else{_=null;var g=null;g=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"})}_&&(a.push(_),c+=_.textValue,l-=1)}if(0>=l){this._offset=h;var m=this.constructor.SyntaxNode,v=null;u=new m(c,this._offset,a),"object"==typeof v&&t(u,v),this._offset+=c.length}else u=null;if(u){o.push(u),f+=u.textValue,r.condition_name=u;var k=null,b=null;if(b=this._input.length>this._offset?this._input.substring(this._offset,this._offset+2):null,"()"===b){var x=this.constructor.SyntaxNode,w=null;k=new x("()",this._offset,[]),"object"==typeof w&&t(k,w),this._offset+=2}else{k=null;var S=null;S=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"()"'})}k?(o.push(k),f+=k.textValue):(o=null,this._offset=i)}else o=null,this._offset=i;if(o){this._offset=i;var N=this.constructor.SyntaxNode,C=null;e=new N(f,this._offset,o,r),"object"==typeof C&&t(e,C),this._offset+=f.length}else e=null;return this._nodeCache.node_condition[s]=e},__consume__node_name:function(){var e=null,s=this._offset;this._nodeCache.node_name=this._nodeCache.node_name||{};var n=this._nodeCache.node_name[s];if(n)return this._offset+=n.textValue.length,n;for(var i=1,o=this._offset,r=[],f="",u=!0;u;){var l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,l&&/^[A-Za-z0-9\-]/.test(l)){var h=this.constructor.SyntaxNode,a=null;u=new h(l,this._offset,[]),"object"==typeof a&&t(u,a),this._offset+=1}else{u=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[A-Za-z0-9\\-]"})}u&&(r.push(u),f+=u.textValue,i-=1)}if(0>=i){this._offset=o;var _=this.constructor.SyntaxNode,p=null;e=new _(f,this._offset,r),"object"==typeof p&&t(e,p),this._offset+=f.length}else e=null;return this._nodeCache.node_name[s]=e},__consume__subscript:function(){var e=null,s=this._offset;this._nodeCache.subscript=this._nodeCache.subscript||{};var n=this._nodeCache.subscript[s];if(n)return this._offset+=n.textValue.length,n;var i=this._offset,o=[],r={},f="",u=null,l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"["===l){var h=this.constructor.SyntaxNode,a=null;u=new h("[",this._offset,[]),"object"==typeof a&&t(u,a),this._offset+=1}else{u=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"["'})}if(u){o.push(u),f+=u.textValue;var _=null;if(_=this.__consume__space()){o.push(_),f+=_.textValue,r.space=_;var p=null;if(p=this.__consume__integer()){o.push(p),f+=p.textValue,r.integer=p;var d=null;if(d=this.__consume__space()){o.push(d),f+=d.textValue,r.space=d;var y=null,g=null;if(g=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"]"===g){var m=this.constructor.SyntaxNode,v=null;y=new m("]",this._offset,[]),"object"==typeof v&&t(y,v),this._offset+=1}else{y=null;var k=null;k=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"]"'})}y?(o.push(y),f+=y.textValue):(o=null,this._offset=i)}else o=null,this._offset=i}else o=null,this._offset=i}else o=null,this._offset=i}else o=null,this._offset=i;if(o){this._offset=i;var b=this.constructor.SyntaxNode,x=null;e=new b(f,this._offset,o,r),"object"==typeof x&&t(e,x),this._offset+=f.length}else e=null;return this._nodeCache.subscript[s]=e},__consume__node_predicate:function(){var e=null,s=this._offset;this._nodeCache.node_predicate=this._nodeCache.node_predicate||{};var n=this._nodeCache.node_predicate[s];if(n)return this._offset+=n.textValue.length,n;var i=this._offset,o=[],r={},f="",u=null,l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"["===l){var h=this.constructor.SyntaxNode,a=null;u=new h("[",this._offset,[]),"object"==typeof a&&t(u,a),this._offset+=1}else{u=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"["'})}if(u){o.push(u),f+=u.textValue;var _=null;if(_=this.__consume__expression()){o.push(_),f+=_.textValue,r.expression=_;var p=null,d=null;if(d=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"]"===d){var y=this.constructor.SyntaxNode,g=null;p=new y("]",this._offset,[]),"object"==typeof g&&t(p,g),this._offset+=1}else{p=null;var m=null;m=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"]"'})}if(p){o.push(p),f+=p.textValue;var v=null,k=this._offset;if(v=this.__consume__subscript());else{this._offset=k;var b=this.constructor.SyntaxNode,x=null;v=new b("",this._offset,[]),"object"==typeof x&&t(v,x),this._offset+=0}v?(o.push(v),f+=v.textValue,r.subscript=v):(o=null,this._offset=i)}else o=null,this._offset=i}else o=null,this._offset=i}else o=null,this._offset=i;if(o){this._offset=i;var w=this.constructor.SyntaxNode,S=null;e=new w(f,this._offset,o,r),"object"==typeof S&&t(e,S),this._offset+=f.length}else e=null;return this._nodeCache.node_predicate[s]=e},__consume__expression:function(){var t=null,e=this._offset;this._nodeCache.expression=this._nodeCache.expression||{};var s=this._nodeCache.expression[e];if(s)return this._offset+=s.textValue.length,s;var n=this._offset;return t=this.__consume__or_expression(),t||(this._offset=n,t=this.__consume__and_expression(),t||(this._offset=n,t=this.__consume__comparison(),t||(this._offset=n,t=this.__consume__atom(),t||(this._offset=n)))),this._nodeCache.expression[e]=t},__consume__or_expression:function(){var s=null,n=this._offset;this._nodeCache.or_expression=this._nodeCache.or_expression||{};var i=this._nodeCache.or_expression[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=this._offset,f=[],u={},l="",h=null;if(h=this.__consume__and_expression()){f.push(h),l+=h.textValue,u.left=h;var a=null,c=null;if(c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+2):null,"or"===c){var _=this.constructor.SyntaxNode,p=null;a=new _("or",this._offset,[]),"object"==typeof p&&t(a,p),this._offset+=2}else{a=null;var d=null;d=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"or"'})}if(a){f.push(a),l+=a.textValue;var y=null;y=this.__consume__or_expression(),y?(f.push(y),l+=y.textValue,u.right=y):(f=null,this._offset=r)}else f=null,this._offset=r}else f=null,this._offset=r;if(f){this._offset=r;var g=this.constructor.SyntaxNode,m=e(this.constructor,"Or");s=new g(l,this._offset,f,u),"object"==typeof m&&t(s,m),this._offset+=l.length}else s=null;return s||(this._offset=o,s=this.__consume__and_expression(),s||(this._offset=o)),this._nodeCache.or_expression[n]=s},__consume__and_expression:function(){var s=null,n=this._offset;this._nodeCache.and_expression=this._nodeCache.and_expression||{};var i=this._nodeCache.and_expression[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=this._offset,f=[],u={},l="",h=null;if(h=this.__consume__comparison()){f.push(h),l+=h.textValue,u.left=h;var a=null,c=null;if(c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+3):null,"and"===c){var _=this.constructor.SyntaxNode,p=null;a=new _("and",this._offset,[]),"object"==typeof p&&t(a,p),this._offset+=3}else{a=null;var d=null;d=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"and"'})}if(a){f.push(a),l+=a.textValue;var y=null;y=this.__consume__and_expression(),y?(f.push(y),l+=y.textValue,u.right=y):(f=null,this._offset=r)}else f=null,this._offset=r}else f=null,this._offset=r;if(f){this._offset=r;var g=this.constructor.SyntaxNode,m=e(this.constructor,"And");s=new g(l,this._offset,f,u),"object"==typeof m&&t(s,m),this._offset+=l.length}else s=null;return s||(this._offset=o,s=this.__consume__comparison(),s||(this._offset=o)),this._nodeCache.and_expression[n]=s},__consume__comparison:function(){var s=null,n=this._offset;this._nodeCache.comparison=this._nodeCache.comparison||{};var i=this._nodeCache.comparison[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=this._offset,f=[],u={},l="",h=null;if(h=this.__consume__atom()){f.push(h),l+=h.textValue,u.left=h;var a=null;if(a=this.__consume__comparator()){f.push(a),l+=a.textValue,u.comparator=a;var c=null;c=this.__consume__comparison(),c?(f.push(c),l+=c.textValue,u.right=c):(f=null,this._offset=r)}else f=null,this._offset=r}else f=null,this._offset=r;if(f){this._offset=r;var _=this.constructor.SyntaxNode,p=e(this.constructor,"Comparison");s=new _(l,this._offset,f,u),"object"==typeof p&&t(s,p),this._offset+=l.length}else s=null;return s||(this._offset=o,s=this.__consume__atom(),s||(this._offset=o)),this._nodeCache.comparison[n]=s},__consume__comparator:function(){var e=null,s=this._offset;this._nodeCache.comparator=this._nodeCache.comparator||{};var n=this._nodeCache.comparator[s];if(n)return this._offset+=n.textValue.length,n;var i=this._offset,o=null;if(o=this._input.length>this._offset?this._input.substring(this._offset,this._offset+2):null,"!="===o){var r=this.constructor.SyntaxNode,f=null;e=new r("!=",this._offset,[]),"object"==typeof f&&t(e,f),this._offset+=2}else{e=null;var u=null;u=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"!="'})}if(e);else{this._offset=i;var l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"="===l){var h=this.constructor.SyntaxNode,a=null;e=new h("=",this._offset,[]),"object"==typeof a&&t(e,a),this._offset+=1}else{e=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"="'})}e||(this._offset=i)}return this._nodeCache.comparator[s]=e},__consume__atom:function(){var s=null,n=this._offset;this._nodeCache.atom=this._nodeCache.atom||{};var i=this._nodeCache.atom[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null;if(l=this.__consume__space()){r.push(l),u+=l.textValue,f.space=l;var h=null,a=this._offset,c=this._offset,_=[],p={},d="",y=null,g=null;if(g=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"("===g){var m=this.constructor.SyntaxNode,v=null;y=new m("(",this._offset,[]),"object"==typeof v&&t(y,v),this._offset+=1}else{y=null;var k=null;k=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"("'})}if(y){_.push(y),d+=y.textValue;var b=null;if(b=this.__consume__expression()){_.push(b),d+=b.textValue,p.in_parens=b;var x=null,w=null;if(w=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,")"===w){var S=this.constructor.SyntaxNode,N=null;x=new S(")",this._offset,[]),"object"==typeof N&&t(x,N),this._offset+=1}else{x=null;var C=null;C=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'")"'})}x?(_.push(x),d+=x.textValue):(_=null,this._offset=c)}else _=null,this._offset=c}else _=null,this._offset=c;if(_){this._offset=c;var E=this.constructor.SyntaxNode,P=null;h=new E(d,this._offset,_,p),"object"==typeof P&&t(h,P),this._offset+=d.length}else h=null;if(h||(this._offset=a,h=this.__consume__value(),h||(this._offset=a)),h){r.push(h),u+=h.textValue,f.expression=h;var T=null;T=this.__consume__space(),T?(r.push(T),u+=T.textValue,f.space=T):(r=null,this._offset=o)}else r=null,this._offset=o}else r=null,this._offset=o;if(r){this._offset=o;var V=this.constructor.SyntaxNode,j=e(this.constructor,"Atom");s=new V(u,this._offset,r,f),"object"==typeof j&&t(s,j),this._offset+=u.length}else s=null;return this._nodeCache.atom[n]=s},__consume__value:function(){var t=null,e=this._offset;this._nodeCache.value=this._nodeCache.value||{};var s=this._nodeCache.value[e];if(s)return this._offset+=s.textValue.length,s;var n=this._offset;return t=this.__consume__function_call(),t||(this._offset=n,t=this.__consume__string(),t||(this._offset=n,t=this.__consume__union_expression(),t||(this._offset=n))),this._nodeCache.value[e]=t},__consume__function_call:function(){var s=null,n=this._offset;this._nodeCache.function_call=this._nodeCache.function_call||{};var i=this._nodeCache.function_call[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null;if(l=this.__consume__function_name()){r.push(l),u+=l.textValue,f.function_name=l;var h=null,a=null;if(a=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"("===a){var c=this.constructor.SyntaxNode,_=null;h=new c("(",this._offset,[]),"object"==typeof _&&t(h,_),this._offset+=1}else{h=null;var p=null;p=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"("'})}if(h){r.push(h),u+=h.textValue;var d=null;if(d=this.__consume__function_args()){r.push(d),u+=d.textValue,f.function_args=d;var y=null,g=null;if(g=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,")"===g){var m=this.constructor.SyntaxNode,v=null;y=new m(")",this._offset,[]),"object"==typeof v&&t(y,v),this._offset+=1}else{y=null;var k=null;k=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'")"'})}y?(r.push(y),u+=y.textValue):(r=null,this._offset=o)}else r=null,this._offset=o}else r=null,this._offset=o}else r=null,this._offset=o;if(r){this._offset=o;var b=this.constructor.SyntaxNode,x=e(this.constructor,"FunctionCall");s=new b(u,this._offset,r,f),"object"==typeof x&&t(s,x),this._offset+=u.length}else s=null;return this._nodeCache.function_call[n]=s},__consume__function_name:function(){var e=null,s=this._offset;this._nodeCache.function_name=this._nodeCache.function_name||{};var n=this._nodeCache.function_name[s];if(n)return this._offset+=n.textValue.length,n;for(var i=1,o=this._offset,r=[],f="",u=!0;u;){var l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,l&&/^[a-z\-]/.test(l)){var h=this.constructor.SyntaxNode,a=null;u=new h(l,this._offset,[]),"object"==typeof a&&t(u,a),this._offset+=1}else{u=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[a-z\\-]"})}u&&(r.push(u),f+=u.textValue,i-=1)}if(0>=i){this._offset=o;var _=this.constructor.SyntaxNode,p=null;e=new _(f,this._offset,r),"object"==typeof p&&t(e,p),this._offset+=f.length}else e=null;return this._nodeCache.function_name[s]=e},__consume__function_args:function(){var e=null,s=this._offset;this._nodeCache.function_args=this._nodeCache.function_args||{};var n=this._nodeCache.function_args[s];if(n)return this._offset+=n.textValue.length,n;var i=this._offset,o=this._offset,r=[],f={},u="",l=null;if(l=this.__consume__expression()){r.push(l),u+=l.textValue,f.first=l;for(var h=null,a=0,c=this._offset,_=[],p="",d=!0;d;){var y=this._offset,g=[],m={},v="",k=null,b=null;if(b=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,","===b){var x=this.constructor.SyntaxNode,w=null;k=new x(",",this._offset,[]),"object"==typeof w&&t(k,w),this._offset+=1}else{k=null;var S=null;S=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'","'})}if(k){g.push(k),v+=k.textValue;var N=null;N=this.__consume__expression(),N?(g.push(N),v+=N.textValue,m.expression=N):(g=null,this._offset=y)}else g=null,this._offset=y;if(g){this._offset=y;var C=this.constructor.SyntaxNode,E=null;d=new C(v,this._offset,g,m),"object"==typeof E&&t(d,E),this._offset+=v.length}else d=null;d&&(_.push(d),p+=d.textValue,a-=1)}if(0>=a){this._offset=c;var P=this.constructor.SyntaxNode,T=null;h=new P(p,this._offset,_),"object"==typeof T&&t(h,T),this._offset+=p.length}else h=null;h?(r.push(h),u+=h.textValue,f.rest=h):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var V=this.constructor.SyntaxNode,j=null;
2
+ e=new V(u,this._offset,r,f),"object"==typeof j&&t(e,j),this._offset+=u.length}else e=null;if(e);else{this._offset=i;var X=this.constructor.SyntaxNode,R=null;e=new X("",this._offset,[]),"object"==typeof R&&t(e,R),this._offset+=0}return this._nodeCache.function_args[s]=e},__consume__integer:function(){var s=null,n=this._offset;this._nodeCache.integer=this._nodeCache.integer||{};var i=this._nodeCache.integer[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=[],f={},u="",l=null,h=null;if(h=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,h&&/^[1-9]/.test(h)){var a=this.constructor.SyntaxNode,c=null;l=new a(h,this._offset,[]),"object"==typeof c&&t(l,c),this._offset+=1}else{l=null;var _=null;_=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[1-9]"})}if(l){r.push(l),u+=l.textValue;for(var p=null,d=0,y=this._offset,g=[],m="",v=!0;v;){var k=null;if(k=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,k&&/^[0-9]/.test(k)){var b=this.constructor.SyntaxNode,x=null;v=new b(k,this._offset,[]),"object"==typeof x&&t(v,x),this._offset+=1}else{v=null;var w=null;w=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[0-9]"})}v&&(g.push(v),m+=v.textValue,d-=1)}if(0>=d){this._offset=y;var S=this.constructor.SyntaxNode,N=null;p=new S(m,this._offset,g),"object"==typeof N&&t(p,N),this._offset+=m.length}else p=null;p?(r.push(p),u+=p.textValue):(r=null,this._offset=o)}else r=null,this._offset=o;if(r){this._offset=o;var C=this.constructor.SyntaxNode,E=e(this.constructor,"Integer");s=new C(u,this._offset,r,f),"object"==typeof E&&t(s,E),this._offset+=u.length}else s=null;return this._nodeCache.integer[n]=s},__consume__string:function(){var s=null,n=this._offset;this._nodeCache.string=this._nodeCache.string||{};var i=this._nodeCache.string[n];if(i)return this._offset+=i.textValue.length,i;var o=this._offset,r=this._offset,f=[],u={},l="",h=null,a=null;if(a=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"'"===a){var c=this.constructor.SyntaxNode,_=null;h=new c("'",this._offset,[]),"object"==typeof _&&t(h,_),this._offset+=1}else{h=null;var p=null;p=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\'"'})}if(h){f.push(h),l+=h.textValue;for(var d=null,y=0,g=this._offset,m=[],v="",k=!0;k;){var b=this._offset,x=this._offset,w=[],S={},N="",C=null,E=null;if(E=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"\\"===E){var P=this.constructor.SyntaxNode,T=null;C=new P("\\",this._offset,[]),"object"==typeof T&&t(C,T),this._offset+=1}else{C=null;var V=null;V=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\\\"'})}if(C){w.push(C),N+=C.textValue;var j=null,X=null;X=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null;var R=X;if(null===R){j=null;var A=null;A=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"<any char>"})}else{var Y=this.constructor.SyntaxNode,O=null;j=new Y(R,this._offset,[]),"object"==typeof O&&t(j,O),this._offset+=1}j?(w.push(j),N+=j.textValue):(w=null,this._offset=x)}else w=null,this._offset=x;if(w){this._offset=x;var I=this.constructor.SyntaxNode,D=null;k=new I(N,this._offset,w,S),"object"==typeof D&&t(k,D),this._offset+=N.length}else k=null;if(k);else{this._offset=b;var L=null;if(L=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,L&&/^[^']/.test(L)){var z=this.constructor.SyntaxNode,W=null;k=new z(L,this._offset,[]),"object"==typeof W&&t(k,W),this._offset+=1}else{k=null;var F=null;F=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"[^']"})}k||(this._offset=b)}k&&(m.push(k),v+=k.textValue,y-=1)}if(0>=y){this._offset=g;var H=this.constructor.SyntaxNode,M=null;d=new H(v,this._offset,m),"object"==typeof M&&t(d,M),this._offset+=v.length}else d=null;if(d){f.push(d),l+=d.textValue;var K=null,U=null;if(U=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"'"===U){var B=this.constructor.SyntaxNode,q=null;K=new B("'",this._offset,[]),"object"==typeof q&&t(K,q),this._offset+=1}else{K=null;var Q=null;Q=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\'"'})}K?(f.push(K),l+=K.textValue):(f=null,this._offset=r)}else f=null,this._offset=r}else f=null,this._offset=r;if(f){this._offset=r;var G=this.constructor.SyntaxNode,J=null;s=new G(l,this._offset,f,u),"object"==typeof J&&t(s,J),this._offset+=l.length}else s=null;if(s){var $=e(this.constructor,"String");"object"==typeof $&&t(s,$)}else{this._offset=o;var Z=this._offset,te=[],ee={},se="",ne=null,ie=null;if(ie=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,'"'===ie){var oe=this.constructor.SyntaxNode,re=null;ne=new oe('"',this._offset,[]),"object"==typeof re&&t(ne,re),this._offset+=1}else{ne=null;var fe=null;fe=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\""'})}if(ne){te.push(ne),se+=ne.textValue;for(var ue=null,le=0,he=this._offset,ae=[],ce="",_e=!0;_e;){var pe=this._offset,de=this._offset,ye=[],ge={},me="",ve=null,ke=null;if(ke=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,"\\"===ke){var be=this.constructor.SyntaxNode,xe=null;ve=new be("\\",this._offset,[]),"object"==typeof xe&&t(ve,xe),this._offset+=1}else{ve=null;var we=null;we=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\\\"'})}if(ve){ye.push(ve),me+=ve.textValue;var Se=null,Ne=null;Ne=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null;var Ce=Ne;if(null===Ce){Se=null;var Ee=null;Ee=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:"<any char>"})}else{var Pe=this.constructor.SyntaxNode,Te=null;Se=new Pe(Ce,this._offset,[]),"object"==typeof Te&&t(Se,Te),this._offset+=1}Se?(ye.push(Se),me+=Se.textValue):(ye=null,this._offset=de)}else ye=null,this._offset=de;if(ye){this._offset=de;var Ve=this.constructor.SyntaxNode,je=null;_e=new Ve(me,this._offset,ye,ge),"object"==typeof je&&t(_e,je),this._offset+=me.length}else _e=null;if(_e);else{this._offset=pe;var Xe=null;if(Xe=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,Xe&&/^[^"]/.test(Xe)){var Re=this.constructor.SyntaxNode,Ae=null;_e=new Re(Xe,this._offset,[]),"object"==typeof Ae&&t(_e,Ae),this._offset+=1}else{_e=null;var Ye=null;Ye=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'[^"]'})}_e||(this._offset=pe)}_e&&(ae.push(_e),ce+=_e.textValue,le-=1)}if(0>=le){this._offset=he;var Oe=this.constructor.SyntaxNode,Ie=null;ue=new Oe(ce,this._offset,ae),"object"==typeof Ie&&t(ue,Ie),this._offset+=ce.length}else ue=null;if(ue){te.push(ue),se+=ue.textValue;var De=null,Le=null;if(Le=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,'"'===Le){var ze=this.constructor.SyntaxNode,We=null;De=new ze('"',this._offset,[]),"object"==typeof We&&t(De,We),this._offset+=1}else{De=null;var Fe=null;Fe=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'"\\""'})}De?(te.push(De),se+=De.textValue):(te=null,this._offset=Z)}else te=null,this._offset=Z}else te=null,this._offset=Z;if(te){this._offset=Z;var He=this.constructor.SyntaxNode,Me=null;s=new He(se,this._offset,te,ee),"object"==typeof Me&&t(s,Me),this._offset+=se.length}else s=null;if(s){var Ke=e(this.constructor,"String");"object"==typeof Ke&&t(s,Ke)}else this._offset=o}return this._nodeCache.string[n]=s},__consume__space:function(){var e=null,s=this._offset;this._nodeCache.space=this._nodeCache.space||{};var n=this._nodeCache.space[s];if(n)return this._offset+=n.textValue.length,n;for(var i=0,o=this._offset,r=[],f="",u=!0;u;){var l=null;if(l=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null," "===l){var h=this.constructor.SyntaxNode,a=null;u=new h(" ",this._offset,[]),"object"==typeof a&&t(u,a),this._offset+=1}else{u=null;var c=null;c=this._input.length>this._offset?this._input.substring(this._offset,this._offset+1):null,(!this.error||this.error.offset<=this._offset)&&(this.error=this.constructor.lastError={input:this._input,offset:this._offset,expected:'" "'})}u&&(r.push(u),f+=u.textValue,i-=1)}if(0>=i){this._offset=o;var _=this.constructor.SyntaxNode,p=null;e=new _(f,this._offset,r),"object"==typeof p&&t(e,p),this._offset+=f.length}else e=null;return this._nodeCache.space[s]=e}},i=function(t){this._input=t,this._offset=0,this._nodeCache={}};i.prototype.parse=function(){var t=this.__consume__union_expression();if(t&&this._offset===this._input.length)return t;this.error||(this.error={input:this._input,offset:this._offset,expected:"<EOF>"});var e=s(this.error),n=Error(e);throw n},i.parse=function(t){var e=new i(t);return e.parse()},t(i.prototype,n);var o=function(t,e,s,n){if(this.textValue=t,this.offset=e,this.elements=s||[],n)for(var i in n)this[i]=n[i]};if(o.prototype.forEach=function(t,e){for(var s=0,n=this.elements.length;n>s;s++)t.call(e,this.elements[s],s)},i.SyntaxNode=o,"function"==typeof require&&"object"==typeof exports)exports.Grammar=n,exports.Parser=i,exports.parse=i.parse,Pathology!==void 0&&(Pathology.XPath=n,Pathology.XPathParser=i,Pathology.XPathParser.formatError=s);else{var r=this;r=r.Pathology=r.Pathology||{},Pathology.XPath=n,Pathology.XPathParser=i,Pathology.XPathParser.formatError=s}}(),Pathology.XPathParser.And={evaluate:function(t,e){return Pathology.atomize(this.left,t,e)&&Pathology.atomize(this.right,t,e)}},Pathology.XPathParser.Atom={evaluate:function(t,e){var s=this.expression.in_parens||this.expression;return s.evaluate(t,e)}},Pathology.Axis=function(t){this.name=t},Pathology.Axis.prototype.walk=function(t,e,s){var n,i=t.childNodes,o=Pathology.array(t.attributes);switch(t.checked&&o.push({nodeName:"checked",nodeValue:!0,nodeType:XPathResult.STRING_TYPE}),t.selected&&o.push({nodeName:"selected",nodeValue:!0,nodeType:XPathResult.STRING_TYPE}),this.name){case"attribute":for(var r=0,f=o.length;f>r;r++)e.call(s,o[r]);break;case"child":for(var r=0,f=i.length;f>r;r++)e.call(s,i[r]);break;case"descendant-or-self":e.call(s,t);for(var r=0,f=i.length;f>r;r++)this.walk(i[r],e,s);break;case"following-sibling":for(n=t.nextSibling;n;)e.call(s,n),n=n.nextSibling;break;case"parent":e.call(s,t.parentNode);break;case"self":e.call(s,t)}},Pathology.Axis.SHORTHANDS={"@":"attribute","..":"parent",".":"self","/":"descendant-or-self","":"child"},Pathology.Axis.fromAST=function(t){var e=t.axis_name?t.axis_name.textValue:t.textValue;return new this(this.SHORTHANDS[e]||e)},Pathology.XPathParser.Comparison={evaluate:function(t,e){var s,n=this.comparator.textValue,i=this.left.evaluate(t,e),o=Pathology.atomize(this.right,t,e),r=!1,f=o instanceof Array;if(i._nodes){for(var u=0,l=i._nodes.length;l>u;u++)s=i._nodes[u],"="===n?r=r||(f?Pathology.indexOf(o,s.nodeValue)>=0:s.nodeValue===o||s.innerHTML===o):"!="===n&&(r=r||(f?0>Pathology.indexOf(o,s.nodeValue):s.nodeValue!==o&&s.innerHTML!==o));return r}switch(n){case"=":return f?Pathology.indexOf(o,i.nodeValue)>=0:i==o;case"!=":return f?0>Pathology.indexOf(o,s.nodeValue):i!=o}}},Pathology.XPathParser.FunctionCall={getArguments:function(t,e){var s=[],n=this.function_args.rest;if(this.function_args.first&&this.function_args.first.evaluate&&s.push(this.function_args.first.evaluate(t,e)),n)for(var i=0,o=n.elements.length;o>i;i++)s.push(n.elements[i].expression.evaluate(t,e));return s},evaluate:function(t,e){var s=this.getArguments(t,e),n=this.REGISTER[this.function_name.textValue];return n.apply(t,s)},REGISTER:{concat:function(){for(var t="",e=0,s=arguments.length;s>e;e++)t+=arguments[e].makeString?arguments[e].makeString():arguments[e];return t},contains:function(t,e){return t?(t.makeString&&(t=t.makeString()),(""+t).indexOf(e)>=0):!1},"normalize-space":function(t){return t.makeString&&(t=t.makeString()),(""+t).replace(/^\s*/g,"").replace(/\s*$/g,"").replace(/\s+/g," ")},name:function(){return this.nodeName.toLowerCase()},not:function(t){return t&&t.atomize&&(t=t.atomize()),"string"==typeof t?!1:!t},string:function(t){return t.atomize().innerText},text:function(){return document.evaluate("/text()",this,null,XPathResult.ANY_TYPE,null)}}},Pathology.XPathParser.LocationPath={eachStep:function(t,e){for(var s=[this.head].concat(this.rest.elements),n=0,i=s.length;i>n;n++)t.call(e,s[n])},evaluate:function(t,e,s,n){n=n||new Pathology.XPathResult(XPathResult.ANY_TYPE),s=s||XPathResult.ANY_TYPE;var i,o,r,f,u,l,h=new Pathology.XPathResult(s),a=this.head.isRelative()?t:e,c=[this.head].concat(this.rest.elements);for(h.push(a),r=0,u=c.length;u>r;r++){for(i=c[r],o=new Pathology.XPathResult(s),f=0,l=h._nodes.length;l>f;f++)i.evaluate(h._nodes[f],e,s,o);h=o}for(r=0,u=h._nodes.length;u>r;r++)n.push(h._nodes[r]);return n}},Pathology.XPathParser.LocationStep={isRelative:function(){return"/"!==this.elements[0].textValue},evaluate:function(t,e,s,n){var i=this.selector.axis,o=this.selector.test,r=[[]];Pathology.Axis.fromAST(i).walk(t,function(t){return o&&o.evaluate?(o.evaluate(t,this.predicates,e,s,r,n),void 0):n.push(t)},this)}},Pathology.XPathParser.NodeTest={evaluate:function(t,e,s,n,i,o){var r=this.elements[0].condition_name,f=f=this.elements[0].textValue.toLowerCase(),u={expression:{evaluate:function(){if(r&&"node"===r.textValue)return!0;if(r&&"text"===r.textValue){if(t.nodeType!==XPathResult.BOOLEAN_TYPE)return!1}else if("*"===f){if(1!==t.nodeType)return!1}else{if(!t.nodeName)return!1;if(t.nodeName.toLowerCase()!==f)return!1}return!0}},subscript:this.subscript};e=[u].concat(e.elements);for(var l,h,a=0,c=e.length;c>a;a++){if(i[a]=i[a]||[],h=e[a],l=Pathology.atomize(h.expression,t,s),"string"==typeof l&&(l=!0),!l)return;if(i[a].push(t),h.subscript.integer&&h.subscript.integer.evaluate()!==i[a].length)return}o.push(t)}},Pathology.XPathParser.Or={evaluate:function(t,e){return Pathology.atomize(this.left,t,e)||Pathology.atomize(this.right,t,e)}},Pathology.XPathParser.Integer={evaluate:function(){return parseInt(this.textValue,10)}},Pathology.XPathParser.String={evaluate:function(context,root){return eval(this.textValue)}},Pathology.XPathParser.Union={evaluate:function(t,e,s,n){n=n||new Pathology.XPathResult(XPathResult.ANY_TYPE),s=s||XPathResult.ANY_TYPE,this.head.evaluate(t,e,s,n);for(var i=this.rest.elements,o=0,r=i.length;r>o;o++)i[o].location_path.evaluate(t,e,s,n);return n}},function(){var t,e,s,n=function(t,e){var s;for(s in e)t[s]=e[s];return t},i={msie:!(!window.attachEvent||window.opera),opera:!!window.opera,webkit:navigator.userAgent.indexOf("AppleWebKit/")>-1,safari:navigator.userAgent.indexOf("AppleWebKit/")>-1&&-1===navigator.userAgent.indexOf("Chrome/"),gecko:navigator.userAgent.indexOf("Gecko")>-1,mobilesafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/),rhino:navigator.userAgent.match(/Rhino/)&&!0},o=function(t,e,s){var i=s.ownerDocument.createEventObject();return n(i,e)},r={},f=1,u="_synthetic"+(new Date).getTime(),l=/keypress|keyup|keydown/,h=/load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll/,a=function(t,e,s,n){return new a.init(t,e,s,n)};t=function(t,e,s){return t.addEventListener?t.addEventListener(e,s,!1):t.attachEvent("on"+e,s)},e=function(t,e,s){return t.addEventListener?t.removeEventListener(e,s,!1):t.detachEvent("on"+e,s)},n(a,{init:function(t,e,s,n){var i=a.args(e,s,n),o=this;this.queue=[],this.element=i.element,"function"==typeof this[t]?this[t](i.options,i.element,function(){i.callback&&i.callback.apply(o,arguments),o.done.apply(o,arguments)}):(this.result=a.trigger(t,i.options,i.element),i.callback&&i.callback.call(this,i.element,this.result))},jquery:function(t){return window.FuncUnit&&window.FuncUnit.jQuery?window.FuncUnit.jQuery:t?a.helpers.getWindow(t).jQuery||window.jQuery:window.jQuery},args:function(){for(var t={},e=0;arguments.length>e;e++)"function"==typeof arguments[e]?t.callback=arguments[e]:arguments[e]&&arguments[e].jquery?t.element=arguments[e][0]:arguments[e]&&arguments[e].nodeName?t.element=arguments[e]:t.options&&"string"==typeof arguments[e]?t.element=document.getElementById(arguments[e]):arguments[e]&&(t.options=arguments[e]);return t},click:function(t,e,s){a("click!",t,e,s)},defaults:{focus:function(){if(!a.support.focusChanges){var s=this,n=s.nodeName.toLowerCase();a.data(s,"syntheticvalue",s.value),("input"===n||"textarea"===n)&&t(s,"blur",function(){a.data(s,"syntheticvalue")!=s.value&&a.trigger("change",{},s),e(s,"blur",arguments.callee)})}},submit:function(){a.onParents(this,function(t){return"form"===t.nodeName.toLowerCase()?(t.submit(),!1):void 0})}},changeOnBlur:function(s,n,i){t(s,"blur",function(){i!==s[n]&&a.trigger("change",{},s),e(s,"blur",arguments.callee)})},closest:function(t,e){for(;t&&t.nodeName.toLowerCase()!==e.toLowerCase();)t=t.parentNode;return t},data:function(t,e,s){var n;return t[u]||(t[u]=f++),r[t[u]]||(r[t[u]]={}),n=r[t[u]],s?(r[t[u]][e]=s,void 0):r[t[u]][e]},onParents:function(t,e){for(var s;t&&s!==!1;)s=e(t),t=t.parentNode;return t},focusable:/^(a|area|frame|iframe|label|input|select|textarea|button|html|object)$/i,isFocusable:function(t){var e;return(this.focusable.test(t.nodeName)||(e=t.getAttributeNode("tabIndex"))&&e.specified)&&a.isVisible(t)},isVisible:function(t){return t.offsetWidth&&t.offsetHeight||t.clientWidth&&t.clientHeight},tabIndex:function(t){var e=t.getAttributeNode("tabIndex");return e&&e.specified&&(parseInt(t.getAttribute("tabIndex"))||0)},bind:t,unbind:e,browser:i,helpers:{createEventObject:o,createBasicStandardEvent:function(t,e,s){var i;try{i=s.createEvent("Events")}catch(o){i=s.createEvent("UIEvents")}finally{i.initEvent(t,!0,!0),n(i,e)}return i},inArray:function(t,e){for(var s=0;e.length>s;s++)if(e[s]===t)return s;return-1},getWindow:function(t){return t.ownerDocument.defaultView||t.ownerDocument.parentWindow},extend:n,scrollOffset:function(t,e){var s=t.document.documentElement,n=t.document.body;return e?(window.scrollTo(e.left,e.top),void 0):{left:(s&&s.scrollLeft||n&&n.scrollLeft||0)+(s.clientLeft||0),top:(s&&s.scrollTop||n&&n.scrollTop||0)+(s.clientTop||0)}},scrollDimensions:function(t){var e=t.document.documentElement,s=t.document.body,n=e.clientWidth,i=e.clientHeight,o="CSS1Compat"===t.document.compatMode;return{height:o&&i||s.clientHeight||i,width:o&&n||s.clientWidth||n}},addOffset:function(t,e){var s,n=a.jquery(e);"object"==typeof t&&void 0===t.clientX&&void 0===t.clientY&&void 0===t.pageX&&void 0===t.pageY&&n&&(e=n(e),s=e.offset(),t.pageX=s.left+e.width()/2,t.pageY=s.top+e.height()/2)}},key:{ctrlKey:null,altKey:null,shiftKey:null,metaKey:null},dispatch:function(s,n,i,o){if(n.dispatchEvent&&s){var r=s.preventDefault,f=o?-1:0;return o&&t(n,i,function(t){t.preventDefault(),e(this,i,arguments.callee)}),s.preventDefault=function(){f++,++f>0&&r.apply(this,[])},n.dispatchEvent(s),0>=f}try{window.event=s}catch(u){}return 0>=n.sourceIndex||n.fireEvent&&n.fireEvent("on"+i,s)},create:{page:{event:function(t,e,s){var n,i=a.helpers.getWindow(s).document||document;if(i.createEvent)return n=i.createEvent("Events"),n.initEvent(t,!0,!0),n;try{n=o(t,e,s)}catch(r){}return n}},focus:{event:function(t,e,n){return a.onParents(n,function(t){if(a.isFocusable(t)){if("html"!==t.nodeName.toLowerCase())t.focus(),s=t;else if(s){var e=a.helpers.getWindow(n).document;if(e!==window.document)return!1;e.activeElement?(e.activeElement.blur(),s=null):(s.blur(),s=null)}return!1}}),!0}}},support:{clickChanges:!1,clickSubmits:!1,keypressSubmits:!1,mouseupSubmits:!1,radioClickChanges:!1,focusChanges:!1,linkHrefJS:!1,keyCharacters:!1,backspaceWorks:!1,mouseDownUpClicks:!1,tabKeyTabs:!1,keypressOnAnchorClicks:!1,optionClickBubbles:!1,ready:0},trigger:function(t,e,s){e||(e={});var n,i,o,r=a.create,f=r[t]&&r[t].setup,u=l.test(t)?"key":h.test(t)?"page":"mouse",c=r[t]||{},_=r[u],p=s;return 2===a.support.ready&&f&&f(t,e,s),o=e._autoPrevent,delete e._autoPrevent,c.event?i=c.event(t,e,s):(e=_.options?_.options(t,e,s):e,!a.support.changeBubbles&&/option/i.test(s.nodeName)&&(p=s.parentNode),n=_.event(t,e,p),i=a.dispatch(n,p,t,o)),i&&2===a.support.ready&&a.defaults[t]&&a.defaults[t].call(s,e,o),i},eventSupported:function(t){var e=document.createElement("div");t="on"+t;var s=t in e;return s||(e.setAttribute(t,"return;"),s="function"==typeof e[t]),e=null,s}}),n(a.init.prototype,{then:function(t,e,s,n){a.autoDelay&&this.delay();var i=a.args(e,s,n),o=this;return this.queue.unshift(function(e){return"function"!=typeof this[t]?(this.result=a.trigger(t,i.options,i.element),i.callback&&i.callback.call(this,i.element,this.result),this):(this.element=i.element||e,this[t](i.options,this.element,function(){i.callback&&i.callback.apply(o,arguments),o.done.apply(o,arguments)}),void 0)}),this},delay:function(t,e){"function"==typeof t&&(e=t,t=null),t=t||600;var s=this;return this.queue.unshift(function(){setTimeout(function(){e&&e.apply(s,[]),s.done.apply(s,arguments)},t)}),this},done:function(t,e){e&&(this.element=e),this.queue.length&&this.queue.pop().call(this,this.element,t)},_click:function(t,e,s,n){a.helpers.addOffset(t,e),a.trigger("mousedown",t,e),setTimeout(function(){a.trigger("mouseup",t,e),!a.support.mouseDownUpClicks||n?(a.trigger("click",t,e),s(!0)):(a.create.click.setup("click",t,e),a.defaults.click.call(e),setTimeout(function(){s(!0)},1))},1)},_rightClick:function(t,e,s){a.helpers.addOffset(t,e);var i=n(n({},a.mouse.browser.right.mouseup),t);a.trigger("mousedown",i,e),setTimeout(function(){a.trigger("mouseup",i,e),a.mouse.browser.right.contextmenu&&a.trigger("contextmenu",n(n({},a.mouse.browser.right.contextmenu),t),e),s(!0)},1)},_dblclick:function(t,e,s){a.helpers.addOffset(t,e);var n=this;this._click(t,e,function(){setTimeout(function(){n._click(t,e,function(){a.trigger("dblclick",t,e),s(!0)},!0)},2)})}});for(var c=["click","dblclick","move","drag","key","type","rightClick"],_=function(t){a[t]=function(e,s,n){return a("_"+t,e,s,n)},a.init.prototype[t]=function(e,s,n){return this.then("_"+t,e,s,n)}},p=0;c.length>p;p++)_(c[p]);(window.FuncUnit&&window.FuncUnit.jQuery||window.jQuery)&&((window.FuncUnit&&window.FuncUnit.jQuery||window.jQuery).fn.triggerSyn=function(t,e,s){if(!this[0])throw"Can't "+t.substring(1)+" because no element matching '"+this.selector+"' was found";return a(t,e,this[0],s),this}),window.Syn=a}(),function(){var h=Syn.helpers,getWin=h.getWindow;Syn.mouse={},h.extend(Syn.defaults,{mousedown:function(){Syn.trigger("focus",{},this)},click:function(){var element=this;try{element.nodeType}catch(e){return}var href,radioChanged=Syn.data(element,"radioChanged"),scope=getWin(element),nodeName=element.nodeName.toLowerCase();if(!Syn.support.linkHrefJS&&/^\s*javascript:/.test(element.href)){var code=element.href.replace(/^\s*javascript:/,"");"//"!=code&&-1==code.indexOf("void(0)")&&(window.selenium?eval("with(selenium.browserbot.getCurrentWindow()){"+code+"}"):eval("with(scope){"+code+"}"))}if(!Syn.support.clickSubmits&&"input"==nodeName&&"submit"==element.type||"button"==nodeName){var form=Syn.closest(element,"form");form&&Syn.trigger("submit",{},form)}"a"==nodeName&&element.href&&!/^\s*javascript:/.test(element.href)&&(scope.location.href=element.href),"input"==nodeName&&"checkbox"==element.type&&(Syn.support.clickChanges||Syn.trigger("change",{},element)),"input"==nodeName&&"radio"==element.type&&radioChanged&&!Syn.support.radioClickChanges&&Syn.trigger("change",{},element),"option"==nodeName&&Syn.data(element,"createChange")&&(Syn.trigger("change",{},element.parentNode),Syn.data(element,"createChange",!1))}}),h.extend(Syn.create,{mouse:{options:function(t,e){var s=document.documentElement,n=document.body,i=[e.pageX||0,e.pageY||0],o=Syn.mouse.browser&&Syn.mouse.browser.left[t],r=Syn.mouse.browser&&Syn.mouse.browser.right[t];return h.extend({bubbles:!0,cancelable:!0,view:window,detail:1,screenX:1,screenY:1,clientX:e.clientX||i[0]-(s&&s.scrollLeft||n&&n.scrollLeft||0)-(s.clientLeft||0),clientY:e.clientY||i[1]-(s&&s.scrollTop||n&&n.scrollTop||0)-(s.clientTop||0),ctrlKey:!!Syn.key.ctrlKey,altKey:!!Syn.key.altKey,shiftKey:!!Syn.key.shiftKey,metaKey:!!Syn.key.metaKey,button:o&&null!=o.button?o.button:r&&r.button||("contextmenu"==t?2:0),relatedTarget:document.documentElement},e)},event:function(t,e,s){var n=getWin(s).document||document;if(n.createEvent){var i;try{i=n.createEvent("MouseEvents"),i.initMouseEvent(t,e.bubbles,e.cancelable,e.view,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget)}catch(o){i=h.createBasicStandardEvent(t,e,n)}return i.synthetic=!0,i}var i;try{i=h.createEventObject(t,e,s)}catch(o){}return i}},click:{setup:function(t,e,s){var t,n=s.nodeName.toLowerCase();if(!Syn.support.clickChecks&&!Syn.support.changeChecks&&"input"===n&&(t=s.type.toLowerCase(),"checkbox"===t&&(s.checked=!s.checked),"radio"===t&&!s.checked)){try{Syn.data(s,"radioChanged",!0)}catch(i){}s.checked=!0}if("a"==n&&s.href&&!/^\s*javascript:/.test(s.href)&&Syn.data(s,"href",s.href),/option/i.test(s.nodeName)){for(var o=s.parentNode.firstChild,r=-1;o&&(1!=o.nodeType||(r++,o!=s));)o=o.nextSibling;r!==s.parentNode.selectedIndex&&(s.parentNode.selectedIndex=r,Syn.data(s,"createChange",!0))}}},mousedown:{setup:function(t,e,s){var n=s.nodeName.toLowerCase();!Syn.browser.safari||"select"!=n&&"option"!=n||(e._autoPrevent=!0)}}}),function(){if(!document.body)return setTimeout(arguments.callee,1),void 0;var t=window.__synthTest;window.__synthTest=function(){Syn.support.linkHrefJS=!0};var e,s,n,i,o=document.createElement("div");o.innerHTML="<form id='outer'><input name='checkbox' type='checkbox'/><input name='radio' type='radio' /><input type='submit' name='submitter'/><input type='input' name='inputter'/><input name='one'><input name='two'/><a href='javascript:__synthTest()' id='synlink'></a><select><option></option></select></form>",document.documentElement.appendChild(o),n=o.firstChild,e=n.childNodes[0],s=n.childNodes[2],i=n.getElementsByTagName("select")[0],e.checked=!1,e.onchange=function(){Syn.support.clickChanges=!0},Syn.trigger("click",{},e),Syn.support.clickChecks=e.checked,e.checked=!1,Syn.trigger("change",{},e),Syn.support.changeChecks=e.checked,n.onsubmit=function(t){return t.preventDefault&&t.preventDefault(),Syn.support.clickSubmits=!0,!1},Syn.trigger("click",{},s),n.childNodes[1].onchange=function(){Syn.support.radioClickChanges=!0},Syn.trigger("click",{},n.childNodes[1]),Syn.bind(o,"click",function(){Syn.support.optionClickBubbles=!0,Syn.unbind(o,"click",arguments.callee)}),Syn.trigger("click",{},i.firstChild),Syn.support.changeBubbles=Syn.eventSupported("change"),o.onclick=function(){Syn.support.mouseDownUpClicks=!0},Syn.trigger("mousedown",{},o),Syn.trigger("mouseup",{},o),document.documentElement.removeChild(o),window.__synthTest=t,Syn.support.ready++}()}(),function(){Syn.key.browsers={webkit:{prevent:{keyup:[],keydown:["char","keypress"],keypress:["char"]},character:{keydown:[0,"key"],keypress:["char","char"],keyup:[0,"key"]},specialChars:{keydown:[0,"char"],keyup:[0,"char"]},navigation:{keydown:[0,"key"],keyup:[0,"key"]},special:{keydown:[0,"key"],keyup:[0,"key"]},tab:{keydown:[0,"char"],keyup:[0,"char"]},"pause-break":{keydown:[0,"key"],keyup:[0,"key"]},caps:{keydown:[0,"key"],keyup:[0,"key"]},escape:{keydown:[0,"key"],keyup:[0,"key"]},"num-lock":{keydown:[0,"key"],keyup:[0,"key"]},"scroll-lock":{keydown:[0,"key"],keyup:[0,"key"]},print:{keyup:[0,"key"]},"function":{keydown:[0,"key"],keyup:[0,"key"]},"\r":{keydown:[0,"key"],keypress:["char","key"],keyup:[0,"key"]}},gecko:{prevent:{keyup:[],keydown:["char"],keypress:["char"]},character:{keydown:[0,"key"],keypress:["char",0],keyup:[0,"key"]},specialChars:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},navigation:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},special:{keydown:[0,"key"],keyup:[0,"key"]}," ":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},"pause-break":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},caps:{keydown:[0,"key"],keyup:[0,"key"]},escape:{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]},"num-lock":{keydown:[0,"key"],keyup:[0,"key"]},"scroll-lock":{keydown:[0,"key"],keyup:[0,"key"]},print:{keyup:[0,"key"]},"function":{keydown:[0,"key"],keyup:[0,"key"]},"\r":{keydown:[0,"key"],keypress:[0,"key"],keyup:[0,"key"]}},msie:{prevent:{keyup:[],keydown:["char","keypress"],keypress:["char"]},character:{keydown:[null,"key"],keypress:[null,"char"],keyup:[null,"key"]},specialChars:{keydown:[null,"char"],keyup:[null,"char"]},navigation:{keydown:[null,"key"],keyup:[null,"key"]},special:{keydown:[null,"key"],keyup:[null,"key"]},tab:{keydown:[null,"char"],keyup:[null,"char"]},"pause-break":{keydown:[null,"key"],keyup:[null,"key"]},caps:{keydown:[null,"key"],keyup:[null,"key"]},escape:{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},"num-lock":{keydown:[null,"key"],keyup:[null,"key"]},"scroll-lock":{keydown:[null,"key"],keyup:[null,"key"]},print:{keyup:[null,"key"]},"function":{keydown:[null,"key"],keyup:[null,"key"]},"\r":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]}},opera:{prevent:{keyup:[],keydown:[],keypress:["char"]},character:{keydown:[null,"key"],keypress:[null,"char"],keyup:[null,"key"]},specialChars:{keydown:[null,"char"],keypress:[null,"char"],keyup:[null,"char"]},navigation:{keydown:[null,"key"],keypress:[null,"key"]},special:{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},tab:{keydown:[null,"char"],keypress:[null,"char"],keyup:[null,"char"]},"pause-break":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},caps:{keydown:[null,"key"],keyup:[null,"key"]},escape:{keydown:[null,"key"],keypress:[null,"key"]},"num-lock":{keyup:[null,"key"],keydown:[null,"key"],keypress:[null,"key"]},"scroll-lock":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},print:{},"function":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]},"\r":{keydown:[null,"key"],keypress:[null,"key"],keyup:[null,"key"]}}},Syn.mouse.browsers={webkit:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},opera:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},msie:{right:{mousedown:{button:2},mouseup:{button:2},contextmenu:{button:0}},left:{mousedown:{button:1},mouseup:{button:1},click:{button:0}}},chrome:{right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}},left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}}},gecko:{left:{mousedown:{button:0,which:1},mouseup:{button:0,which:1},click:{button:0,which:1}},right:{mousedown:{button:2,which:3},mouseup:{button:2,which:3},contextmenu:{button:2,which:3}}}},Syn.key.browser=function(){if(Syn.key.browsers[window.navigator.userAgent])return Syn.key.browsers[window.navigator.userAgent];
3
+ for(var t in Syn.browser)if(Syn.browser[t]&&Syn.key.browsers[t])return Syn.key.browsers[t];return Syn.key.browsers.gecko}(),Syn.mouse.browser=function(){if(Syn.mouse.browsers[window.navigator.userAgent])return Syn.mouse.browsers[window.navigator.userAgent];for(var t in Syn.browser)if(Syn.browser[t]&&Syn.mouse.browsers[t])return Syn.mouse.browsers[t];return Syn.mouse.browsers.gecko}()}(),function(){(function(){if(!document.body)return setTimeout(arguments.callee,1),void 0;var t=document.createElement("div");if(document.body.appendChild(t),Syn.helpers.extend(t.style,{width:"100px",height:"10000px",backgroundColor:"blue",position:"absolute",top:"10px",left:"0px",zIndex:19999}),document.body.scrollTop=11,document.elementFromPoint){var e=document.elementFromPoint(3,1);e==t?Syn.support.elementFromClient=!0:Syn.support.elementFromPage=!0,document.body.removeChild(t),document.body.scrollTop=0}})();var t=function(t,e){var s,n=t.clientX,i=t.clientY,o=Syn.helpers.getWindow(e);if(Syn.support.elementFromPage){var r=Syn.helpers.scrollOffset(o);n+=r.left,i+=r.top}return s=o.document.elementFromPoint?o.document.elementFromPoint(n,i):e,s===o.document.documentElement&&(0>t.clientY||0>t.clientX)?e:s},e=function(e,s,n){var i=t(s,n);return Syn.trigger(e,s,i||n),i},s=function(e,s,n){var i=t(e,s);if(n!=i&&i&&n){var o=Syn.helpers.extend({},e);o.relatedTarget=i,Syn.trigger("mouseout",o,n),o.relatedTarget=n,Syn.trigger("mouseover",o,i)}return Syn.trigger("mousemove",e,i||s),i},n=function(e,n,i,o,r){var f=new Date,u=n.clientX-e.clientX,l=n.clientY-e.clientY,h=Syn.helpers.getWindow(o),a=t(e,o),c=h.document.createElement("div"),_=0;move=function(){var t=new Date,p=Syn.helpers.scrollOffset(h),d=(0==_?0:t-f)/i,y={clientX:u*d+e.clientX,clientY:l*d+e.clientY};_++,1>d?(Syn.helpers.extend(c.style,{left:y.clientX+p.left+2+"px",top:y.clientY+p.top+2+"px"}),a=s(y,o,a),setTimeout(arguments.callee,15)):(a=s(n,o,a),h.document.body.removeChild(c),r())},Syn.helpers.extend(c.style,{height:"5px",width:"5px",backgroundColor:"red",position:"absolute",zIndex:19999,fontSize:"1px"}),h.document.body.appendChild(c),move()},i=function(t,s,i,o,r){e("mousedown",t,o),n(t,s,i,o,function(){e("mouseup",s,o),r()})},o=function(t){var e=Syn.jquery()(t),s=e.offset();return{pageX:s.left+e.outerWidth()/2,pageY:s.top+e.outerHeight()/2}},r=function(t,e,s){var n=/(\d+)[x ](\d+)/,i=/(\d+)X(\d+)/,r=/([+-]\d+)[xX ]([+-]\d+)/;if("string"==typeof t&&r.test(t)&&s){var f=o(s),u=t.match(r);t={pageX:f.pageX+parseInt(u[1]),pageY:f.pageY+parseInt(u[2])}}if("string"==typeof t&&n.test(t)){var u=t.match(n);t={pageX:parseInt(u[1]),pageY:parseInt(u[2])}}if("string"==typeof t&&i.test(t)){var u=t.match(i);t={clientX:parseInt(u[1]),clientY:parseInt(u[2])}}if("string"==typeof t&&(t=Syn.jquery()(t,e.document)[0]),t.nodeName&&(t=o(t)),t.pageX){var l=Syn.helpers.scrollOffset(e);t={clientX:t.pageX-l.left,clientY:t.pageY-l.top}}return t},f=function(t,e,s){if(0>t.clientY){var n=Syn.helpers.scrollOffset(s),i=(Syn.helpers.scrollDimensions(s),n.top+t.clientY-100),o=i-n.top;i>0||(i=0,o=-n.top),t.clientY=t.clientY-o,e.clientY=e.clientY-o,Syn.helpers.scrollOffset(s,{top:i,left:n.left})}};Syn.helpers.extend(Syn.init.prototype,{_move:function(t,e,s){var i=Syn.helpers.getWindow(e),o=r(t.from||e,i,e),u=r(t.to||t,i,e);t.adjust!==!1&&f(o,u,i),n(o,u,t.duration||500,e,s)},_drag:function(t,e,s){var n=Syn.helpers.getWindow(e),o=r(t.from||e,n,e),u=r(t.to||t,n,e);t.adjust!==!1&&f(o,u,n),i(o,u,t.duration||500,e,s)}})}(),Terminus={isIE:/\bMSIE\b/.test(navigator.userAgent),connect:function(t,e){if(!this._bayeux){this._host=t,this._pageId=Faye.random(),this._id=window.name=window.name||document.name||Faye.random(),this._id=this._id.split("|")[0];for(var s=document.getElementsByTagName("iframe"),n=s.length;n--;)s[n].contentDocument.name=s[n].id;this.Registry.initialize(),this.Worker.initialize(),this.AjaxMonitor.initialize(),Faye.Event.on(window,"beforeunload",function(){Terminus.disabled=!0});var i="http://"+t+":"+e+"/messaging",o=this._bayeux=new Faye.Client(i),r=this;o.addExtension({outgoing:function(t,e){t.href=window.location.href,"websocket"===t.connectionType&&(r._socketCapable=!0),e(t)}}),this.getId(function(t){var e=window.name.split("|")[1];e||o.subscribe("/terminus/sockets/"+t,function(t){window.name+="|"+t.url,this.openSocket(t.url)},this);var s=o.subscribe("/terminus/clients/"+t,this.handleMessage,this);s.callback(function(){this.ping(),e&&this.openSocket(e)},this)},this)}},browserDetails:function(t,e){this.getId(function(s){t.call(e,{host:this._host,id:s,infinite:!!window.TERMINUS_INFINITE_REDIRECT,page:this._pageId,sockets:this._socketCapable,ua:navigator.userAgent,url:window.location.href})},this)},getId:function(t,e){var s=this._id;if(this.isIE)return t.call(e,s);if(opener&&opener.Terminus)opener.Terminus.getId(function(n){t.call(e,n+"/"+s)});else if(parent&&parent!==window){var n=function(){return parent.Terminus?(parent.Terminus.getId(function(n){t.call(e,n+"/"+s)}),void 0):setTimeout(n,100)};n()}else t.call(e,s)},openSocket:function(t){if(!this.disabled&&!this._socket){var e=this,s=window.MozWebSocket||window.WebSocket,n=new s(t);n.onopen=function(){e._socket=n,up=!0},n.onclose=function(){var s=!!e._socket;e._socket=null,s?e.openSocket(t):window.name=window.name.split("|")[0]},n.onmessage=function(t){e.handleMessage(JSON.parse(t.data))}}},ping:function(){this.disabled||this.browserDetails(function(t){this._bayeux.publish("/terminus/ping",t);var e=this;setTimeout(function(){e.ping()},3e3)},this)},handleMessage:function(t){var e=t.command,s=e.shift(),n=this.Driver,i=this.Worker,o=!1,r=this;e.push(function(e){o||(r.postResult(t.commandId,e),o=!0)}),i.monitor=!0,n[s].apply(n,e),i.monitor=!1},postResult:function(t,e){return!this.disabled&&t?this._socket?this._socket.send(JSON.stringify({value:e})):(this.getId(function(s){this._bayeux.publish("/terminus/results",{id:s,commandId:t,result:e})},this),void 0):void 0},getAttribute:function(t,e){return Terminus.isIE?(t.getAttributeNode(e)||{}).nodeValue||!1:t.getAttribute(e)},hideNodes:function(t,e){if(!t)return e;e=e||[];var s="script"===(t.tagName||"").toLowerCase(),n="none"===(t.style||{}).display;if(s||n){var i=t.parentNode,o=t.nextSibling;s||e.push([t,i,o]),i&&i.removeChild(t)}else for(var r=t.childNodes||[],f=0,u=r.length;u>f;f++)this.hideNodes(r[f],e);return e},showNodes:function(t){for(var e,s,n,i,o=0,r=t.length;r>o;o++)e=t[o],s=e[0],n=e[1],i=e[2],n&&(i?n.insertBefore(s,i):n.appendChild(s))},Driver:{_node:function(t){return Terminus.Registry.get(t)},attribute:function(t,e,s){var n=this._node(t);return n?(Terminus.isIE||"checked"!==e&&"selected"!==e?"textarea"===n.tagName.toLowerCase()&&"type"===e?s("textarea"):s(Terminus.getAttribute(n,e)):s(!!n[e]),void 0):s(null)},set_attribute:function(t,e,s,n){var i=this._node(t);return i?(i.setAttribute(e,s),n(!0),void 0):n(null)},body:function(t){var e=document.getElementsByTagName("html")[0];t(e.outerHTML||"<html>\n"+e.innerHTML+"\n</html>\n")},clear_cookies:function(t){var e,s=document.cookie.split(";"),n=new Date;n.setTime(n.getTime()-864e5);for(var i=0,o=s.length;o>i;i++)e=s[i].split("=")[0],document.cookie=e+"=; expires="+n.toGMTString()+"; path=/";t(!0)},click:function(t,e,s){var n=this._node(t),i=e.resynchronization_timeout;return n?(Syn.trigger("click",{},n),e.resynchronize===!1?s(!0):(i&&Terminus.Worker._setTimeout.call(window,function(){s("failed to resynchronize, ajax request timed out")},1e3*i),Terminus.Worker.callback(function(){s(!0)}),void 0)):s(!0)},current_url:function(t){Terminus.browserDetails(function(e){t(e.url)})},drag:function(t,e){var s=this._node(t.from),n=this._node(t.to);return s&&n?(Syn.drag({to:n},s,function(){e(!0)}),void 0):e(null)},evaluate:function(expression,callback){callback(eval(expression))},execute:function(expression,callback){eval(expression),callback(!0)},find:function(t,e,s){var n=e?this._node(e):document;if(!n)return s([]);for(var i,o=document.evaluate(t,n,null,XPathResult.ANY_TYPE,null),r=[];i=o.iterateNext();)r.push(Terminus.Registry.put(i));return s(r)},is_visible:function(t,e){var s=this._node(t);if(!s)return e(null);for(;s.tagName&&"body"!==s.tagName.toLowerCase();){if("none"===s.style.display||"hidden"===s.type)return e(!1);s=s.parentNode}e(!0)},select:function(t,e){var s=this._node(t);return s?(s.selected=!0,Syn.trigger("change",{},s.parentNode),e(!0),void 0):e(null)},set:function(t,e,s){var n=this._node(t),i=Terminus.getAttribute(n,"maxlength");if(!n)return s(null);if("file"===n.type)return s("not_allowed");switch(Syn.trigger("focus",{},n),Syn.trigger("click",{},n),typeof e){case"string":i&&(e=e.substr(0,parseInt(i))),n.value=e;break;case"boolean":n.checked=e}Syn.trigger("change",{},n),s(!0)},tag_name:function(t,e){var s=this._node(t);return s?(e(s.tagName.toLowerCase()),void 0):e(null)},text:function(t,e){var s=this._node(t);if(!s)return e(null);var n=Terminus.hideNodes(s),i=document.title;document.title="";var o=s.textContent||s.innerText||"";document.title=i,Terminus.showNodes(n),o=o.replace(/^\s*|\s*$/g,"").replace(/\s+/g," "),e(o)},trigger:function(t,e,s){var n=this._node(t);return n?(Syn.trigger(e,{},n),s(!0),void 0):s(null)},unselect:function(t,e){var s=this._node(t);return s?s.parentNode.multiple?(s.selected=!1,Syn.trigger("change",{},s.parentNode),e(!0),void 0):e(!1):e(null)},value:function(t,e){var s=this._node(t);if(!s)return e(null);if("select"!==s.tagName.toLowerCase()||!s.multiple)return e(s.value);for(var n=s.children,i=[],o=0,r=n.length;r>o;o++)n[o].selected&&i.push(n[o].value);e(i)},visit:function(t,e){window.location.href=t,e(t)}},Registry:{initialize:function(){this._namespace=new Faye.Namespace,this._elements={}},get:function(t){for(var e=this._elements[t],s=e;s&&"BODY"!==s.tagName&&"HTML"!==s.tagName;)s=s.parentNode;return s?e:null},put:function(t){var e=t["data-terminus-id"];return e||(e=this._namespace.generate(),t["data-terminus-id"]=e),this._elements[e]=t,e}},Worker:{initialize:function(){this._callbacks=[],this._pending=0,Terminus.isIE||this._wrapTimeouts()},callback:function(t,e){0===this._pending?this._setTimeout?this._setTimeout.call(window,function(){t.call(e)},0):setTimeout(function(){t.call(e)},0):this._callbacks.push([t,e])},suspend:function(){this._pending+=1},resume:function(){if(0!==this._pending&&(this._pending-=1,0===this._pending)){for(var t,e=0,s=this._callbacks.length;s>e;e++)t=this._callbacks[e],t[0].call(t[1]);this._callbacks=[]}},_wrapTimeouts:function(){var timeout=window.setTimeout,clear=window.clearTimeout,timeouts={},self=this,finish=function(t){timeouts.hasOwnProperty(t)&&(delete timeouts[t],self.resume())};window.setTimeout=function(callback,delay){var id=timeout.call(window,function(){try{switch(typeof callback){case"function":callback();break;case"string":eval(callback)}}finally{finish(id)}},delay);return self.monitor&&(timeouts[id]=!0,self.suspend()),id},window.clearTimeout=function(t){return finish(t),clear(t)},this._setTimeout=timeout}},AjaxMonitor:{initialize:function(){window.jQuery&&this._patchJquery()},_patchJquery:function(){var t=jQuery.ajax;jQuery.ajax=function(e,s){var n=("string"==typeof e?s:e)||{},i=n.complete,o=Terminus.Worker.monitor;return n.complete=function(){var t;try{t=i.apply(this,arguments)}finally{o&&Terminus.Worker.resume()}return t},o&&Terminus.Worker.suspend(),"string"==typeof e?t.call(jQuery,e,n):t.call(jQuery,n)}}}};
@@ -5,20 +5,20 @@ var Pathology = {
5
5
  expression.evaluate(context, context, resultType, result);
6
6
  return result;
7
7
  },
8
-
8
+
9
9
  atomize: function(expression, context, root) {
10
10
  var result = expression.evaluate(context, root);
11
11
  if (result && result.atomize) result = result.atomize();
12
12
  return result;
13
13
  },
14
-
14
+
15
15
  array: function(list) {
16
16
  if (!list) return [];
17
17
  var array = [], i = list.length;
18
18
  while (i--) array[i] = list[i];
19
19
  return array;
20
20
  },
21
-
21
+
22
22
  indexOf: function(list, item) {
23
23
  if (list.indexOf) return list.indexOf(item);
24
24
  for (var i = 0, n = list.length; i < n; i++) {
@@ -85,17 +85,17 @@ Pathology.XPathResult.prototype.atomize = function() {
85
85
  Pathology.XPathResult.prototype.makeString = function() {
86
86
  var first = this._nodes[0];
87
87
  if (!first) return '';
88
-
88
+
89
89
  switch (first.nodeType) {
90
90
  case XPathResult.STRING_TYPE:
91
91
  return this.atomize();
92
-
92
+
93
93
  case XPathResult.BOOLEAN_TYPE:
94
94
  var parts = [];
95
95
  for (var i = 0, n = this._nodes.length; i < n; i++)
96
96
  parts.push(this._nodes[i].nodeValue);
97
97
  return parts.join('');
98
-
98
+
99
99
  default:
100
100
  var result = document.evaluate('//text()', first, null, XPathResult.ANY_TYPE, null);
101
101
  return result.makeString();
@@ -112,11 +112,11 @@ Pathology.XPathResult.prototype.makeString = function() {
112
112
  }
113
113
  return destination;
114
114
  };
115
-
115
+
116
116
  var find = function (root, objectName) {
117
117
  var parts = objectName.split('.'),
118
118
  part;
119
-
119
+
120
120
  while (part = parts.shift()) {
121
121
  root = root[part];
122
122
  if (root === undefined)
@@ -124,31 +124,31 @@ Pathology.XPathResult.prototype.makeString = function() {
124
124
  }
125
125
  return root;
126
126
  };
127
-
127
+
128
128
  var formatError = function (error) {
129
129
  var lines = error.input.split(/\n/g),
130
130
  lineNo = 0,
131
131
  offset = 0;
132
-
132
+
133
133
  while (offset < error.offset + 1) {
134
134
  offset += lines[lineNo].length + 1;
135
135
  lineNo += 1;
136
136
  }
137
137
  var message = 'Line ' + lineNo + ': expected ' + error.expected + '\n',
138
138
  line = lines[lineNo - 1];
139
-
139
+
140
140
  message += line + '\n';
141
141
  offset -= line.length + 1;
142
-
142
+
143
143
  while (offset < error.offset) {
144
144
  message += ' ';
145
145
  offset += 1;
146
146
  }
147
147
  return message + '^';
148
148
  };
149
-
149
+
150
150
  var Grammar = {
151
- __consume__union_expression: function(input) {
151
+ __consume__union_expression: function() {
152
152
  var address0 = null, index0 = this._offset;
153
153
  this._nodeCache["union_expression"] = this._nodeCache["union_expression"] || {};
154
154
  var cached = this._nodeCache["union_expression"][index0];
@@ -287,7 +287,7 @@ Pathology.XPathResult.prototype.makeString = function() {
287
287
  }
288
288
  return this._nodeCache["union_expression"][index0] = address0;
289
289
  },
290
- __consume__location_path: function(input) {
290
+ __consume__location_path: function() {
291
291
  var address0 = null, index0 = this._offset;
292
292
  this._nodeCache["location_path"] = this._nodeCache["location_path"] || {};
293
293
  var cached = this._nodeCache["location_path"][index0];
@@ -350,7 +350,7 @@ Pathology.XPathResult.prototype.makeString = function() {
350
350
  }
351
351
  return this._nodeCache["location_path"][index0] = address0;
352
352
  },
353
- __consume__location_step: function(input) {
353
+ __consume__location_step: function() {
354
354
  var address0 = null, index0 = this._offset;
355
355
  this._nodeCache["location_step"] = this._nodeCache["location_step"] || {};
356
356
  var cached = this._nodeCache["location_step"][index0];
@@ -557,7 +557,7 @@ Pathology.XPathResult.prototype.makeString = function() {
557
557
  }
558
558
  return this._nodeCache["location_step"][index0] = address0;
559
559
  },
560
- __consume__axis: function(input) {
560
+ __consume__axis: function() {
561
561
  var address0 = null, index0 = this._offset;
562
562
  this._nodeCache["axis"] = this._nodeCache["axis"] || {};
563
563
  var cached = this._nodeCache["axis"][index0];
@@ -679,7 +679,7 @@ Pathology.XPathResult.prototype.makeString = function() {
679
679
  }
680
680
  return this._nodeCache["axis"][index0] = address0;
681
681
  },
682
- __consume__axis_shorthand: function(input) {
682
+ __consume__axis_shorthand: function() {
683
683
  var address0 = null, index0 = this._offset;
684
684
  this._nodeCache["axis_shorthand"] = this._nodeCache["axis_shorthand"] || {};
685
685
  var cached = this._nodeCache["axis_shorthand"][index0];
@@ -810,7 +810,7 @@ Pathology.XPathResult.prototype.makeString = function() {
810
810
  }
811
811
  return this._nodeCache["axis_shorthand"][index0] = address0;
812
812
  },
813
- __consume__node_test: function(input) {
813
+ __consume__node_test: function() {
814
814
  var address0 = null, index0 = this._offset;
815
815
  this._nodeCache["node_test"] = this._nodeCache["node_test"] || {};
816
816
  var cached = this._nodeCache["node_test"][index0];
@@ -904,7 +904,7 @@ Pathology.XPathResult.prototype.makeString = function() {
904
904
  }
905
905
  return this._nodeCache["node_test"][index0] = address0;
906
906
  },
907
- __consume__node_condition: function(input) {
907
+ __consume__node_condition: function() {
908
908
  var address0 = null, index0 = this._offset;
909
909
  this._nodeCache["node_condition"] = this._nodeCache["node_condition"] || {};
910
910
  var cached = this._nodeCache["node_condition"][index0];
@@ -1016,7 +1016,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1016
1016
  }
1017
1017
  return this._nodeCache["node_condition"][index0] = address0;
1018
1018
  },
1019
- __consume__node_name: function(input) {
1019
+ __consume__node_name: function() {
1020
1020
  var address0 = null, index0 = this._offset;
1021
1021
  this._nodeCache["node_name"] = this._nodeCache["node_name"] || {};
1022
1022
  var cached = this._nodeCache["node_name"][index0];
@@ -1072,7 +1072,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1072
1072
  }
1073
1073
  return this._nodeCache["node_name"][index0] = address0;
1074
1074
  },
1075
- __consume__subscript: function(input) {
1075
+ __consume__subscript: function() {
1076
1076
  var address0 = null, index0 = this._offset;
1077
1077
  this._nodeCache["subscript"] = this._nodeCache["subscript"] || {};
1078
1078
  var cached = this._nodeCache["subscript"][index0];
@@ -1193,7 +1193,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1193
1193
  }
1194
1194
  return this._nodeCache["subscript"][index0] = address0;
1195
1195
  },
1196
- __consume__node_predicate: function(input) {
1196
+ __consume__node_predicate: function() {
1197
1197
  var address0 = null, index0 = this._offset;
1198
1198
  this._nodeCache["node_predicate"] = this._nodeCache["node_predicate"] || {};
1199
1199
  var cached = this._nodeCache["node_predicate"][index0];
@@ -1316,7 +1316,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1316
1316
  }
1317
1317
  return this._nodeCache["node_predicate"][index0] = address0;
1318
1318
  },
1319
- __consume__expression: function(input) {
1319
+ __consume__expression: function() {
1320
1320
  var address0 = null, index0 = this._offset;
1321
1321
  this._nodeCache["expression"] = this._nodeCache["expression"] || {};
1322
1322
  var cached = this._nodeCache["expression"][index0];
@@ -1347,7 +1347,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1347
1347
  }
1348
1348
  return this._nodeCache["expression"][index0] = address0;
1349
1349
  },
1350
- __consume__or_expression: function(input) {
1350
+ __consume__or_expression: function() {
1351
1351
  var address0 = null, index0 = this._offset;
1352
1352
  this._nodeCache["or_expression"] = this._nodeCache["or_expression"] || {};
1353
1353
  var cached = this._nodeCache["or_expression"][index0];
@@ -1434,7 +1434,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1434
1434
  }
1435
1435
  return this._nodeCache["or_expression"][index0] = address0;
1436
1436
  },
1437
- __consume__and_expression: function(input) {
1437
+ __consume__and_expression: function() {
1438
1438
  var address0 = null, index0 = this._offset;
1439
1439
  this._nodeCache["and_expression"] = this._nodeCache["and_expression"] || {};
1440
1440
  var cached = this._nodeCache["and_expression"][index0];
@@ -1521,7 +1521,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1521
1521
  }
1522
1522
  return this._nodeCache["and_expression"][index0] = address0;
1523
1523
  },
1524
- __consume__comparison: function(input) {
1524
+ __consume__comparison: function() {
1525
1525
  var address0 = null, index0 = this._offset;
1526
1526
  this._nodeCache["comparison"] = this._nodeCache["comparison"] || {};
1527
1527
  var cached = this._nodeCache["comparison"][index0];
@@ -1584,7 +1584,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1584
1584
  }
1585
1585
  return this._nodeCache["comparison"][index0] = address0;
1586
1586
  },
1587
- __consume__comparator: function(input) {
1587
+ __consume__comparator: function() {
1588
1588
  var address0 = null, index0 = this._offset;
1589
1589
  this._nodeCache["comparator"] = this._nodeCache["comparator"] || {};
1590
1590
  var cached = this._nodeCache["comparator"][index0];
@@ -1655,7 +1655,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1655
1655
  }
1656
1656
  return this._nodeCache["comparator"][index0] = address0;
1657
1657
  },
1658
- __consume__atom: function(input) {
1658
+ __consume__atom: function() {
1659
1659
  var address0 = null, index0 = this._offset;
1660
1660
  this._nodeCache["atom"] = this._nodeCache["atom"] || {};
1661
1661
  var cached = this._nodeCache["atom"][index0];
@@ -1808,7 +1808,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1808
1808
  }
1809
1809
  return this._nodeCache["atom"][index0] = address0;
1810
1810
  },
1811
- __consume__value: function(input) {
1811
+ __consume__value: function() {
1812
1812
  var address0 = null, index0 = this._offset;
1813
1813
  this._nodeCache["value"] = this._nodeCache["value"] || {};
1814
1814
  var cached = this._nodeCache["value"][index0];
@@ -1834,7 +1834,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1834
1834
  }
1835
1835
  return this._nodeCache["value"][index0] = address0;
1836
1836
  },
1837
- __consume__function_call: function(input) {
1837
+ __consume__function_call: function() {
1838
1838
  var address0 = null, index0 = this._offset;
1839
1839
  this._nodeCache["function_call"] = this._nodeCache["function_call"] || {};
1840
1840
  var cached = this._nodeCache["function_call"][index0];
@@ -1945,7 +1945,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1945
1945
  }
1946
1946
  return this._nodeCache["function_call"][index0] = address0;
1947
1947
  },
1948
- __consume__function_name: function(input) {
1948
+ __consume__function_name: function() {
1949
1949
  var address0 = null, index0 = this._offset;
1950
1950
  this._nodeCache["function_name"] = this._nodeCache["function_name"] || {};
1951
1951
  var cached = this._nodeCache["function_name"][index0];
@@ -2001,7 +2001,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2001
2001
  }
2002
2002
  return this._nodeCache["function_name"][index0] = address0;
2003
2003
  },
2004
- __consume__function_args: function(input) {
2004
+ __consume__function_args: function() {
2005
2005
  var address0 = null, index0 = this._offset;
2006
2006
  this._nodeCache["function_args"] = this._nodeCache["function_args"] || {};
2007
2007
  var cached = this._nodeCache["function_args"][index0];
@@ -2132,7 +2132,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2132
2132
  }
2133
2133
  return this._nodeCache["function_args"][index0] = address0;
2134
2134
  },
2135
- __consume__integer: function(input) {
2135
+ __consume__integer: function() {
2136
2136
  var address0 = null, index0 = this._offset;
2137
2137
  this._nodeCache["integer"] = this._nodeCache["integer"] || {};
2138
2138
  var cached = this._nodeCache["integer"][index0];
@@ -2243,7 +2243,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2243
2243
  }
2244
2244
  return this._nodeCache["integer"][index0] = address0;
2245
2245
  },
2246
- __consume__string: function(input) {
2246
+ __consume__string: function() {
2247
2247
  var address0 = null, index0 = this._offset;
2248
2248
  this._nodeCache["string"] = this._nodeCache["string"] || {};
2249
2249
  var cached = this._nodeCache["string"][index0];
@@ -2722,7 +2722,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2722
2722
  }
2723
2723
  return this._nodeCache["string"][index0] = address0;
2724
2724
  },
2725
- __consume__space: function(input) {
2725
+ __consume__space: function() {
2726
2726
  var address0 = null, index0 = this._offset;
2727
2727
  this._nodeCache["space"] = this._nodeCache["space"] || {};
2728
2728
  var cached = this._nodeCache["space"][index0];
@@ -2779,13 +2779,13 @@ Pathology.XPathResult.prototype.makeString = function() {
2779
2779
  return this._nodeCache["space"][index0] = address0;
2780
2780
  }
2781
2781
  };
2782
-
2782
+
2783
2783
  var Parser = function(input) {
2784
2784
  this._input = input;
2785
2785
  this._offset = 0;
2786
2786
  this._nodeCache = {};
2787
2787
  };
2788
-
2788
+
2789
2789
  Parser.prototype.parse = function() {
2790
2790
  var result = this.__consume__union_expression();
2791
2791
  if (result && this._offset === this._input.length) {
@@ -2798,14 +2798,14 @@ Pathology.XPathResult.prototype.makeString = function() {
2798
2798
  var error = new Error(message);
2799
2799
  throw error;
2800
2800
  };
2801
-
2801
+
2802
2802
  Parser.parse = function(input) {
2803
2803
  var parser = new Parser(input);
2804
2804
  return parser.parse();
2805
2805
  };
2806
-
2806
+
2807
2807
  extend(Parser.prototype, Grammar);
2808
-
2808
+
2809
2809
  var SyntaxNode = function(textValue, offset, elements, properties) {
2810
2810
  this.textValue = textValue;
2811
2811
  this.offset = offset;
@@ -2813,20 +2813,20 @@ Pathology.XPathResult.prototype.makeString = function() {
2813
2813
  if (!properties) return;
2814
2814
  for (var key in properties) this[key] = properties[key];
2815
2815
  };
2816
-
2816
+
2817
2817
  SyntaxNode.prototype.forEach = function(block, context) {
2818
2818
  for (var i = 0, n = this.elements.length; i < n; i++) {
2819
2819
  block.call(context, this.elements[i], i);
2820
2820
  }
2821
2821
  };
2822
-
2822
+
2823
2823
  Parser.SyntaxNode = SyntaxNode;
2824
-
2824
+
2825
2825
  if (typeof require === "function" && typeof exports === "object") {
2826
2826
  exports.Grammar = Grammar;
2827
2827
  exports.Parser = Parser;
2828
2828
  exports.parse = Parser.parse;
2829
-
2829
+
2830
2830
  if (typeof Pathology !== "undefined") {
2831
2831
  Pathology.XPath = Grammar;
2832
2832
  Pathology.XPathParser = Parser;
@@ -2866,39 +2866,39 @@ Pathology.Axis.prototype.walk = function(context, block, scope) {
2866
2866
  var children = context.childNodes,
2867
2867
  attributes = Pathology.array(context.attributes),
2868
2868
  sibling;
2869
-
2869
+
2870
2870
  if (context.checked)
2871
2871
  attributes.push({ nodeName: 'checked',
2872
2872
  nodeValue: true,
2873
2873
  nodeType: XPathResult.STRING_TYPE
2874
2874
  });
2875
-
2875
+
2876
2876
  if (context.selected)
2877
2877
  attributes.push({ nodeName: 'selected',
2878
2878
  nodeValue: true,
2879
2879
  nodeType: XPathResult.STRING_TYPE
2880
2880
  });
2881
-
2881
+
2882
2882
  switch (this.name) {
2883
2883
  case 'attribute':
2884
2884
  for (var i = 0, n = attributes.length; i < n; i++) {
2885
2885
  block.call(scope, attributes[i]);
2886
2886
  }
2887
2887
  break;
2888
-
2888
+
2889
2889
  case 'child':
2890
2890
  for (var i = 0, n = children.length; i < n; i++) {
2891
2891
  block.call(scope, children[i]);
2892
2892
  }
2893
2893
  break;
2894
-
2894
+
2895
2895
  case 'descendant-or-self':
2896
2896
  block.call(scope, context);
2897
2897
  for (var i = 0, n = children.length; i < n; i++) {
2898
2898
  this.walk(children[i], block, scope);
2899
2899
  }
2900
2900
  break;
2901
-
2901
+
2902
2902
  case 'following-sibling':
2903
2903
  sibling = context.nextSibling;
2904
2904
  while (sibling) {
@@ -2906,11 +2906,11 @@ Pathology.Axis.prototype.walk = function(context, block, scope) {
2906
2906
  sibling = sibling.nextSibling;
2907
2907
  }
2908
2908
  break;
2909
-
2909
+
2910
2910
  case 'parent':
2911
2911
  block.call(scope, context.parentNode);
2912
2912
  break;
2913
-
2913
+
2914
2914
  case 'self':
2915
2915
  block.call(scope, context);
2916
2916
  break;
@@ -2924,12 +2924,12 @@ Pathology.Axis.SHORTHANDS = {
2924
2924
  '/' : 'descendant-or-self',
2925
2925
  '' : 'child'
2926
2926
  };
2927
-
2927
+
2928
2928
  Pathology.Axis.fromAST = function(node) {
2929
2929
  var name = node.axis_name
2930
2930
  ? node.axis_name.textValue
2931
2931
  : node.textValue;
2932
-
2932
+
2933
2933
  return new this(this.SHORTHANDS[name] || name);
2934
2934
  };
2935
2935
 
@@ -2943,7 +2943,7 @@ Pathology.XPathParser.Comparison = {
2943
2943
  viable = false,
2944
2944
  array = (right instanceof Array),
2945
2945
  node;
2946
-
2946
+
2947
2947
  if (left._nodes) {
2948
2948
  for (var i = 0, n = left._nodes.length; i < n; i++) {
2949
2949
  node = left._nodes[i];
@@ -2954,7 +2954,7 @@ Pathology.XPathParser.Comparison = {
2954
2954
  }
2955
2955
  }
2956
2956
  return viable;
2957
-
2957
+
2958
2958
  } else {
2959
2959
  switch (comparator) {
2960
2960
  case '=': return array ? Pathology.indexOf(right, left.nodeValue) >= 0 : left == right;
@@ -2969,7 +2969,7 @@ Pathology.XPathParser.FunctionCall = {
2969
2969
  getArguments: function(context, root) {
2970
2970
  var args = [],
2971
2971
  rest = this.function_args.rest;
2972
-
2972
+
2973
2973
  if (this.function_args.first && this.function_args.first.evaluate) {
2974
2974
  args.push(this.function_args.first.evaluate(context, root));
2975
2975
  }
@@ -2979,14 +2979,14 @@ Pathology.XPathParser.FunctionCall = {
2979
2979
  }
2980
2980
  return args;
2981
2981
  },
2982
-
2982
+
2983
2983
  evaluate: function(context, root) {
2984
2984
  var args = this.getArguments(context, root),
2985
2985
  proc = this.REGISTER[this.function_name.textValue];
2986
-
2986
+
2987
2987
  return proc.apply(context, args);
2988
2988
  },
2989
-
2989
+
2990
2990
  REGISTER: {
2991
2991
  'concat': function() {
2992
2992
  var string = '';
@@ -2994,36 +2994,36 @@ Pathology.XPathParser.FunctionCall = {
2994
2994
  string += arguments[i].makeString ? arguments[i].makeString() : arguments[i];
2995
2995
  return string;
2996
2996
  },
2997
-
2997
+
2998
2998
  'contains': function(haystack, needle) {
2999
2999
  if (!haystack) return false;
3000
3000
  if (haystack.makeString) haystack = haystack.makeString();
3001
-
3001
+
3002
3002
  return haystack.toString().indexOf(needle) >= 0;
3003
3003
  },
3004
-
3004
+
3005
3005
  'normalize-space': function(string) {
3006
3006
  if (string.makeString) string = string.makeString();
3007
-
3007
+
3008
3008
  return string.toString().replace(/^\s*/g, '')
3009
3009
  .replace(/\s*$/g, '')
3010
3010
  .replace(/\s+/g, ' ');
3011
3011
  },
3012
-
3012
+
3013
3013
  'name': function() {
3014
3014
  return this.nodeName.toLowerCase();
3015
3015
  },
3016
-
3016
+
3017
3017
  'not': function(value) {
3018
3018
  if (value && value.atomize) value = value.atomize();
3019
3019
  if (typeof value === 'string') return false;
3020
3020
  return !value;
3021
3021
  },
3022
-
3022
+
3023
3023
  'string': function(value) {
3024
3024
  return value.atomize().innerText;
3025
3025
  },
3026
-
3026
+
3027
3027
  'text': function() {
3028
3028
  return document.evaluate('/text()', this, null, XPathResult.ANY_TYPE, null);
3029
3029
  }
@@ -3037,20 +3037,20 @@ Pathology.XPathParser.LocationPath = {
3037
3037
  for (var i = 0, n = list.length; i < n; i++)
3038
3038
  block.call(scope, list[i]);
3039
3039
  },
3040
-
3040
+
3041
3041
  evaluate: function(context, root, resultType, result) {
3042
3042
  result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
3043
3043
  resultType = resultType || XPathResult.ANY_TYPE;
3044
-
3044
+
3045
3045
  var intermediate = new Pathology.XPathResult(resultType),
3046
3046
  startNode = this.head.isRelative() ? context : root,
3047
3047
  steps = [this.head].concat(this.rest.elements),
3048
3048
  step,
3049
3049
  nextStage,
3050
3050
  i, j, n, m;
3051
-
3051
+
3052
3052
  intermediate.push(startNode);
3053
-
3053
+
3054
3054
  for (i = 0, n = steps.length; i < n; i++) {
3055
3055
  step = steps[i];
3056
3056
  nextStage = new Pathology.XPathResult(resultType);
@@ -3059,10 +3059,10 @@ Pathology.XPathParser.LocationPath = {
3059
3059
  }
3060
3060
  intermediate = nextStage;
3061
3061
  }
3062
-
3062
+
3063
3063
  for (i = 0, n = intermediate._nodes.length; i < n; i++)
3064
3064
  result.push(intermediate._nodes[i]);
3065
-
3065
+
3066
3066
  return result;
3067
3067
  }
3068
3068
  };
@@ -3072,12 +3072,12 @@ Pathology.XPathParser.LocationStep = {
3072
3072
  isRelative: function() {
3073
3073
  return this.elements[0].textValue !== '/';
3074
3074
  },
3075
-
3075
+
3076
3076
  evaluate: function(context, root, resultType, result) {
3077
3077
  var axis = this.selector.axis,
3078
3078
  test = this.selector.test,
3079
3079
  levels = [[]];
3080
-
3080
+
3081
3081
  Pathology.Axis.fromAST(axis).walk(context, function(node) {
3082
3082
  if (!test || !test.evaluate) return result.push(node);
3083
3083
  test.evaluate(node, this.predicates, root, resultType, levels, result);
@@ -3090,7 +3090,7 @@ Pathology.XPathParser.NodeTest = {
3090
3090
  evaluate: function(context, predicates, root, resultType, levels, result) {
3091
3091
  var name = this.elements[0].condition_name,
3092
3092
  tagName = tagName = this.elements[0].textValue.toLowerCase();
3093
-
3093
+
3094
3094
  var first = {
3095
3095
  expression: {
3096
3096
  evaluate: function() {
@@ -3111,25 +3111,25 @@ Pathology.XPathParser.NodeTest = {
3111
3111
  },
3112
3112
  subscript: this.subscript
3113
3113
  };
3114
-
3114
+
3115
3115
  predicates = [first].concat(predicates.elements);
3116
3116
  var accepted, predicate;
3117
-
3117
+
3118
3118
  for (var i = 0, n = predicates.length; i < n; i++) {
3119
3119
  levels[i] = levels[i] || [];
3120
3120
  predicate = predicates[i];
3121
-
3121
+
3122
3122
  accepted = Pathology.atomize(predicate.expression, context, root);
3123
3123
  if (typeof accepted === 'string') accepted = true;
3124
3124
  if (!accepted) return;
3125
-
3125
+
3126
3126
  levels[i].push(context);
3127
-
3127
+
3128
3128
  if (predicate.subscript.integer) {
3129
3129
  if (predicate.subscript.integer.evaluate() !== levels[i].length) return;
3130
3130
  }
3131
3131
  }
3132
-
3132
+
3133
3133
  result.push(context);
3134
3134
  }
3135
3135
  };
@@ -3161,13 +3161,13 @@ Pathology.XPathParser.Union = {
3161
3161
  evaluate: function(context, root, resultType, result) {
3162
3162
  result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
3163
3163
  resultType = resultType || XPathResult.ANY_TYPE;
3164
-
3164
+
3165
3165
  this.head.evaluate(context, root, resultType, result);
3166
-
3166
+
3167
3167
  var sections = this.rest.elements;
3168
3168
  for (var i = 0, n = sections.length; i < n; i++)
3169
3169
  sections[i].location_path.evaluate(context, root, resultType, result);
3170
-
3170
+
3171
3171
  return result;
3172
3172
  }
3173
3173
  };
@@ -4780,29 +4780,29 @@ Pathology.XPathParser.Union = {
4780
4780
 
4781
4781
  Terminus = {
4782
4782
  isIE: /\bMSIE\b/.test(navigator.userAgent),
4783
-
4783
+
4784
4784
  connect: function(host, port) {
4785
4785
  if (this._bayeux) return;
4786
-
4786
+
4787
4787
  this._host = host;
4788
4788
  this._pageId = Faye.random();
4789
4789
  this._id = window.name = window.name || document.name || Faye.random();
4790
4790
  this._id = this._id.split('|')[0];
4791
-
4791
+
4792
4792
  var iframes = document.getElementsByTagName('iframe'), i = iframes.length;
4793
4793
  while (i--)
4794
4794
  iframes[i].contentDocument.name = iframes[i].id;
4795
-
4795
+
4796
4796
  this.Registry.initialize();
4797
4797
  this.Worker.initialize();
4798
4798
  this.AjaxMonitor.initialize();
4799
-
4799
+
4800
4800
  Faye.Event.on(window, 'beforeunload', function() { Terminus.disabled = true });
4801
-
4801
+
4802
4802
  var endpoint = 'http://' + host + ':' + port + '/messaging',
4803
4803
  bayeux = this._bayeux = new Faye.Client(endpoint),
4804
4804
  self = this;
4805
-
4805
+
4806
4806
  bayeux.addExtension({
4807
4807
  outgoing: function(message, callback) {
4808
4808
  message.href = window.location.href;
@@ -4810,16 +4810,16 @@ Terminus = {
4810
4810
  callback(message);
4811
4811
  }
4812
4812
  });
4813
-
4813
+
4814
4814
  this.getId(function(id) {
4815
4815
  var url = window.name.split('|')[1];
4816
-
4816
+
4817
4817
  if (!url)
4818
4818
  bayeux.subscribe('/terminus/sockets/' + id, function(message) {
4819
4819
  window.name += '|' + message.url;
4820
4820
  this.openSocket(message.url);
4821
4821
  }, this);
4822
-
4822
+
4823
4823
  var sub = bayeux.subscribe('/terminus/clients/' + id, this.handleMessage, this);
4824
4824
  sub.callback(function() {
4825
4825
  this.ping();
@@ -4827,7 +4827,7 @@ Terminus = {
4827
4827
  }, this);
4828
4828
  }, this);
4829
4829
  },
4830
-
4830
+
4831
4831
  browserDetails: function(callback, context) {
4832
4832
  this.getId(function(id) {
4833
4833
  callback.call(context, {
@@ -4841,11 +4841,11 @@ Terminus = {
4841
4841
  });
4842
4842
  }, this);
4843
4843
  },
4844
-
4844
+
4845
4845
  getId: function(callback, context) {
4846
4846
  var id = this._id;
4847
4847
  if (this.isIE) return callback.call(context, id);
4848
-
4848
+
4849
4849
  if (opener && opener.Terminus) {
4850
4850
  opener.Terminus.getId(function(prefix) {
4851
4851
  callback.call(context, prefix + '/' + id);
@@ -4862,14 +4862,14 @@ Terminus = {
4862
4862
  callback.call(context, id);
4863
4863
  }
4864
4864
  },
4865
-
4865
+
4866
4866
  openSocket: function(endpoint) {
4867
4867
  if (this.disabled || this._socket) return;
4868
-
4868
+
4869
4869
  var self = this,
4870
4870
  WS = window.MozWebSocket || window.WebSocket,
4871
4871
  ws = new WS(endpoint);
4872
-
4872
+
4873
4873
  ws.onopen = function() {
4874
4874
  self._socket = ws;
4875
4875
  up = true;
@@ -4886,17 +4886,17 @@ Terminus = {
4886
4886
  self.handleMessage(JSON.parse(event.data));
4887
4887
  };
4888
4888
  },
4889
-
4889
+
4890
4890
  ping: function() {
4891
4891
  if (this.disabled) return;
4892
-
4892
+
4893
4893
  this.browserDetails(function(details) {
4894
4894
  this._bayeux.publish('/terminus/ping', details);
4895
4895
  var self = this;
4896
4896
  setTimeout(function() { self.ping() }, 3000);
4897
4897
  }, this);
4898
4898
  },
4899
-
4899
+
4900
4900
  handleMessage: function(message) {
4901
4901
  var command = message.command,
4902
4902
  method = command.shift(),
@@ -4904,24 +4904,24 @@ Terminus = {
4904
4904
  worker = this.Worker,
4905
4905
  posted = false,
4906
4906
  self = this;
4907
-
4907
+
4908
4908
  command.push(function(result) {
4909
4909
  if (posted) return;
4910
4910
  self.postResult(message.commandId, result);
4911
4911
  posted = true;
4912
4912
  });
4913
-
4913
+
4914
4914
  worker.monitor = true;
4915
4915
  driver[method].apply(driver, command);
4916
4916
  worker.monitor = false;
4917
4917
  },
4918
-
4918
+
4919
4919
  postResult: function(commandId, result) {
4920
4920
  if (this.disabled || !commandId) return;
4921
-
4921
+
4922
4922
  if (this._socket)
4923
4923
  return this._socket.send(JSON.stringify({value: result}));
4924
-
4924
+
4925
4925
  this.getId(function(id) {
4926
4926
  this._bayeux.publish('/terminus/results', {
4927
4927
  id: id,
@@ -4930,118 +4930,154 @@ Terminus = {
4930
4930
  });
4931
4931
  }, this);
4932
4932
  },
4933
-
4933
+
4934
4934
  getAttribute: function(node, name) {
4935
4935
  return Terminus.isIE ? (node.getAttributeNode(name) || {}).nodeValue || false
4936
4936
  : node.getAttribute(name);
4937
4937
  },
4938
-
4938
+
4939
+ hideNodes: function(root, list) {
4940
+ if (!root) return list;
4941
+ list = list || [];
4942
+
4943
+ var isScript = (root.tagName || '').toLowerCase() === 'script',
4944
+ isHidden = (root.style || {}).display === 'none';
4945
+
4946
+ if (isScript || isHidden) {
4947
+ var parent = root.parentNode, next = root.nextSibling;
4948
+ if (!isScript) list.push([root, parent, next]);
4949
+ if (parent) parent.removeChild(root);
4950
+ } else {
4951
+ var children = root.childNodes || [];
4952
+ for (var i = 0, n = children.length; i < n; i++) {
4953
+ this.hideNodes(children[i], list);
4954
+ }
4955
+ }
4956
+ return list;
4957
+ },
4958
+
4959
+ showNodes: function(hidden) {
4960
+ var hide, node, parent, next;
4961
+ for (var i = 0, n = hidden.length; i < n; i++) {
4962
+ hide = hidden[i];
4963
+ node = hide[0];
4964
+ parent = hide[1];
4965
+ next = hide[2];
4966
+
4967
+ if (!parent) continue;
4968
+ if (next) parent.insertBefore(node, next);
4969
+ else parent.appendChild(node);
4970
+ }
4971
+ },
4972
+
4939
4973
  Driver: {
4940
4974
  _node: function(id) {
4941
4975
  return Terminus.Registry.get(id);
4942
4976
  },
4943
-
4977
+
4944
4978
  attribute: function(nodeId, name, callback) {
4945
4979
  var node = this._node(nodeId);
4946
4980
  if (!node) return callback(null);
4947
-
4981
+
4948
4982
  if (!Terminus.isIE && (name === 'checked' || name === 'selected')) {
4949
4983
  callback(!!node[name]);
4984
+ } else if (node.tagName.toLowerCase() === 'textarea' && name === 'type') {
4985
+ callback('textarea');
4950
4986
  } else {
4951
4987
  callback(Terminus.getAttribute(node, name));
4952
4988
  }
4953
4989
  },
4954
-
4990
+
4955
4991
  set_attribute: function(nodeId, name, value, callback) {
4956
4992
  var node = this._node(nodeId);
4957
4993
  if (!node) return callback(null);
4958
4994
  node.setAttribute(name, value);
4959
4995
  callback(true);
4960
4996
  },
4961
-
4997
+
4962
4998
  body: function(callback) {
4963
4999
  var html = document.getElementsByTagName('html')[0];
4964
5000
  callback(html.outerHTML ||
4965
5001
  '<html>\n' + html.innerHTML + '\n</html>\n');
4966
5002
  },
4967
-
5003
+
4968
5004
  clear_cookies: function(callback) {
4969
5005
  var cookies = document.cookie.split(';'), name;
4970
-
5006
+
4971
5007
  var expiry = new Date();
4972
5008
  expiry.setTime(expiry.getTime() - 24*60*60*1000);
4973
-
5009
+
4974
5010
  for (var i = 0, n = cookies.length; i < n; i++) {
4975
5011
  name = cookies[i].split('=')[0];
4976
5012
  document.cookie = name + '=; expires=' + expiry.toGMTString() + '; path=/';
4977
5013
  }
4978
5014
  callback(true);
4979
5015
  },
4980
-
5016
+
4981
5017
  click: function(nodeId, options, callback) {
4982
5018
  var element = this._node(nodeId),
4983
5019
  timeout = options.resynchronization_timeout;
4984
-
5020
+
4985
5021
  if (!element) return callback(true);
4986
-
5022
+
4987
5023
  Syn.trigger('click', {}, element);
4988
-
5024
+
4989
5025
  if (options.resynchronize === false) return callback(true);
4990
-
5026
+
4991
5027
  if (timeout)
4992
5028
  Terminus.Worker._setTimeout.call(window, function() {
4993
5029
  callback('failed to resynchronize, ajax request timed out');
4994
5030
  }, 1000 * timeout);
4995
-
5031
+
4996
5032
  Terminus.Worker.callback(function() {
4997
5033
  callback(true);
4998
5034
  });
4999
5035
  },
5000
-
5036
+
5001
5037
  current_url: function(callback) {
5002
5038
  Terminus.browserDetails(function(details) {
5003
5039
  callback(details.url);
5004
5040
  });
5005
5041
  },
5006
-
5042
+
5007
5043
  drag: function(options, callback) {
5008
5044
  var draggable = this._node(options.from),
5009
5045
  droppable = this._node(options.to);
5010
-
5046
+
5011
5047
  if (!draggable || !droppable) return callback(null);
5012
-
5048
+
5013
5049
  Syn.drag({to: droppable}, draggable, function() {
5014
5050
  callback(true);
5015
5051
  });
5016
5052
  },
5017
-
5053
+
5018
5054
  evaluate: function(expression, callback) {
5019
5055
  callback(eval(expression));
5020
5056
  },
5021
-
5057
+
5022
5058
  execute: function(expression, callback) {
5023
5059
  eval(expression);
5024
5060
  callback(true);
5025
5061
  },
5026
-
5062
+
5027
5063
  find: function(xpath, nodeId, callback) {
5028
5064
  var root = nodeId ? this._node(nodeId) : document;
5029
5065
  if (!root) return callback([]);
5030
-
5066
+
5031
5067
  var result = document.evaluate(xpath, root, null, XPathResult.ANY_TYPE, null),
5032
5068
  list = [],
5033
5069
  element;
5034
-
5070
+
5035
5071
  while (element = result.iterateNext())
5036
5072
  list.push(Terminus.Registry.put(element));
5037
-
5073
+
5038
5074
  return callback(list);
5039
5075
  },
5040
-
5076
+
5041
5077
  is_visible: function(nodeId, callback) {
5042
5078
  var node = this._node(nodeId);
5043
5079
  if (!node) return callback(null);
5044
-
5080
+
5045
5081
  while (node.tagName && node.tagName.toLowerCase() !== 'body') {
5046
5082
  if (node.style.display === 'none' || node.type === 'hidden')
5047
5083
  return callback(false);
@@ -5049,7 +5085,7 @@ Terminus = {
5049
5085
  }
5050
5086
  callback(true);
5051
5087
  },
5052
-
5088
+
5053
5089
  select: function(nodeId, callback) {
5054
5090
  var option = this._node(nodeId);
5055
5091
  if (!option) return callback(null);
@@ -5057,17 +5093,17 @@ Terminus = {
5057
5093
  Syn.trigger('change', {}, option.parentNode);
5058
5094
  callback(true);
5059
5095
  },
5060
-
5096
+
5061
5097
  set: function(nodeId, value, callback) {
5062
5098
  var field = this._node(nodeId),
5063
5099
  max = Terminus.getAttribute(field, 'maxlength');
5064
-
5100
+
5065
5101
  if (!field) return callback(null);
5066
5102
  if (field.type === 'file') return callback('not_allowed');
5067
-
5103
+
5068
5104
  Syn.trigger('focus', {}, field);
5069
5105
  Syn.trigger('click', {}, field);
5070
-
5106
+
5071
5107
  switch (typeof value) {
5072
5108
  case 'string':
5073
5109
  if (max) value = value.substr(0, parseInt(max));
@@ -5080,33 +5116,38 @@ Terminus = {
5080
5116
  Syn.trigger('change', {}, field);
5081
5117
  callback(true);
5082
5118
  },
5083
-
5119
+
5084
5120
  tag_name: function(nodeId, callback) {
5085
5121
  var node = this._node(nodeId);
5086
5122
  if (!node) return callback(null);
5087
5123
  callback(node.tagName.toLowerCase());
5088
5124
  },
5089
-
5125
+
5090
5126
  text: function(nodeId, callback) {
5091
5127
  var node = this._node(nodeId);
5092
5128
  if (!node) return callback(null);
5093
-
5094
- var text = node.textContent || node.innerText || '',
5095
- scripts = node.getElementsByTagName('script'),
5096
- i = scripts.length;
5097
-
5098
- while (i--) text = text.replace(scripts[i].textContent || scripts[i].innerText, '');
5099
- text = text.replace(/^\s*|\s*$/g, '');
5129
+
5130
+ var hidden = Terminus.hideNodes(node),
5131
+ title = document.title;
5132
+
5133
+ document.title = '';
5134
+
5135
+ var text = node.textContent || node.innerText || '';
5136
+
5137
+ document.title = title;
5138
+ Terminus.showNodes(hidden);
5139
+
5140
+ text = text.replace(/^\s*|\s*$/g, '').replace(/\s+/g, ' ');
5100
5141
  callback(text);
5101
5142
  },
5102
-
5143
+
5103
5144
  trigger: function(nodeId, eventType, callback) {
5104
5145
  var node = this._node(nodeId);
5105
5146
  if (!node) return callback(null);
5106
5147
  Syn.trigger(eventType, {}, node);
5107
5148
  callback(true);
5108
5149
  },
5109
-
5150
+
5110
5151
  unselect: function(nodeId, callback) {
5111
5152
  var option = this._node(nodeId);
5112
5153
  if (!option) return callback(null);
@@ -5115,35 +5156,35 @@ Terminus = {
5115
5156
  Syn.trigger('change', {}, option.parentNode);
5116
5157
  callback(true);
5117
5158
  },
5118
-
5159
+
5119
5160
  value: function(nodeId, callback) {
5120
5161
  var node = this._node(nodeId);
5121
5162
  if (!node) return callback(null);
5122
-
5163
+
5123
5164
  if (node.tagName.toLowerCase() !== 'select' || !node.multiple)
5124
5165
  return callback(node.value);
5125
-
5166
+
5126
5167
  var options = node.children,
5127
5168
  values = [];
5128
-
5169
+
5129
5170
  for (var i = 0, n = options.length; i < n; i++) {
5130
5171
  if (options[i].selected) values.push(options[i].value);
5131
5172
  }
5132
5173
  callback(values);
5133
5174
  },
5134
-
5175
+
5135
5176
  visit: function(url, callback) {
5136
5177
  window.location.href = url;
5137
5178
  callback(url);
5138
5179
  }
5139
5180
  },
5140
-
5181
+
5141
5182
  Registry: {
5142
5183
  initialize: function() {
5143
5184
  this._namespace = new Faye.Namespace();
5144
5185
  this._elements = {};
5145
5186
  },
5146
-
5187
+
5147
5188
  get: function(id) {
5148
5189
  var node = this._elements[id], root = node;
5149
5190
  while (root && root.tagName !== 'BODY' && root.tagName !== 'HTML')
@@ -5151,22 +5192,26 @@ Terminus = {
5151
5192
  if (!root) return null;
5152
5193
  return node;
5153
5194
  },
5154
-
5195
+
5155
5196
  put: function(element) {
5156
- var id = this._namespace.generate();
5197
+ var id = element['data-terminus-id'];
5198
+ if (!id) {
5199
+ id = this._namespace.generate();
5200
+ element['data-terminus-id'] = id;
5201
+ }
5157
5202
  this._elements[id] = element;
5158
5203
  return id;
5159
5204
  }
5160
5205
  },
5161
-
5206
+
5162
5207
  Worker: {
5163
5208
  initialize: function() {
5164
5209
  this._callbacks = [];
5165
5210
  this._pending = 0;
5166
-
5211
+
5167
5212
  if (!Terminus.isIE) this._wrapTimeouts();
5168
5213
  },
5169
-
5214
+
5170
5215
  callback: function(callback, scope) {
5171
5216
  if (this._pending === 0) {
5172
5217
  if (this._setTimeout)
@@ -5177,16 +5222,16 @@ Terminus = {
5177
5222
  this._callbacks.push([callback, scope]);
5178
5223
  }
5179
5224
  },
5180
-
5225
+
5181
5226
  suspend: function() {
5182
5227
  this._pending += 1;
5183
5228
  },
5184
-
5229
+
5185
5230
  resume: function() {
5186
5231
  if (this._pending === 0) return;
5187
5232
  this._pending -= 1;
5188
5233
  if (this._pending !== 0) return;
5189
-
5234
+
5190
5235
  var callback;
5191
5236
  for (var i = 0, n = this._callbacks.length; i < n; i++) {
5192
5237
  callback = this._callbacks[i];
@@ -5194,19 +5239,19 @@ Terminus = {
5194
5239
  }
5195
5240
  this._callbacks = [];
5196
5241
  },
5197
-
5242
+
5198
5243
  _wrapTimeouts: function() {
5199
5244
  var timeout = window.setTimeout,
5200
5245
  clear = window.clearTimeout,
5201
5246
  timeouts = {},
5202
5247
  self = this;
5203
-
5248
+
5204
5249
  var finish = function(id) {
5205
5250
  if (!timeouts.hasOwnProperty(id)) return;
5206
5251
  delete timeouts[id];
5207
5252
  self.resume();
5208
5253
  };
5209
-
5254
+
5210
5255
  window.setTimeout = function(callback, delay) {
5211
5256
  var id = timeout.call(window, function() {
5212
5257
  try {
@@ -5218,35 +5263,35 @@ Terminus = {
5218
5263
  finish(id);
5219
5264
  }
5220
5265
  }, delay);
5221
-
5266
+
5222
5267
  if (self.monitor) {
5223
5268
  timeouts[id] = true;
5224
5269
  self.suspend();
5225
5270
  }
5226
5271
  return id;
5227
5272
  };
5228
-
5273
+
5229
5274
  window.clearTimeout = function(id) {
5230
5275
  finish(id);
5231
5276
  return clear(id);
5232
5277
  };
5233
-
5278
+
5234
5279
  this._setTimeout = timeout;
5235
5280
  }
5236
5281
  },
5237
-
5282
+
5238
5283
  AjaxMonitor: {
5239
5284
  initialize: function() {
5240
5285
  if (window.jQuery) this._patchJquery();
5241
5286
  },
5242
-
5287
+
5243
5288
  _patchJquery: function() {
5244
5289
  var ajax = jQuery.ajax;
5245
5290
  jQuery.ajax = function(url, settings) {
5246
5291
  var options = ((typeof url === 'string') ? settings : url) || {},
5247
5292
  complete = options.complete,
5248
5293
  monitor = Terminus.Worker.monitor;
5249
-
5294
+
5250
5295
  options.complete = function() {
5251
5296
  var result;
5252
5297
  try {
@@ -5256,9 +5301,9 @@ Terminus = {
5256
5301
  }
5257
5302
  return result;
5258
5303
  };
5259
-
5304
+
5260
5305
  if (monitor) Terminus.Worker.suspend();
5261
-
5306
+
5262
5307
  if (typeof url === 'string')
5263
5308
  return ajax.call(jQuery, url, options);
5264
5309
  else