k[c]);else{vara=newXMLHttpRequest;a.open("GET",c,!0);a.onreadystatechange=function(){varf;4===a.readyState&&(0===a.status&&!a.responseText?d("File "+c+" is empty."):200===a.status||0===a.status?(f="binary"===b?"undefined"!==typeofVBArray?(newVBArray(a.responseBody)).toArray():e.byteArrayFromString(a.responseText,"binary"):a.responseText,k[c]=f,d(null,f)):d(a.responseText||a.statusText))};a.overrideMimeType&&("binary"!==b?a.overrideMimeType("text/plain; charset="+b):a.overrideMimeType("text/plain; charset=x-user-defined"));
try{a.send(null)}catch(f){d(f.message)}}};this.read=function(c,a,d,o){if(k.hasOwnProperty(c))o(null,k[c].slice(a,a+d));else{varf=newXMLHttpRequest;f.open("GET",c,!0);f.onreadystatechange=function(){vari;4===f.readyState&&(0===f.status&&!f.responseText?o("File "+c+" is empty."):200===f.status||0===f.status?(i="undefined"!==typeofVBArray?(newVBArray(f.responseBody)).toArray():e.byteArrayFromString(f.responseText,"binary"),k[c]=i,o(null,i.slice(a,a+d))):o(f.responseText||f.statusText))};f.overrideMimeType&&
function(){4===o.readyState&&(0===o.status&&!o.responseText?d("File "+c+" is empty."):200<=o.status&&300>o.status||0===o.status?d(null):d("Status "+o.status+": "+o.responseText||o.statusText))};a=a.buffer&&!o.sendAsBinary?a.buffer:e.byteArrayToString(a,"binary");try{o.sendAsBinary?o.sendAsBinary(a):o.send(a)}catch(f){e.log("HUH? "+f+" "+a),d(f.message)}};this.deleteFile=function(c,a){vard=newXMLHttpRequest;d.open("DELETE",c,!0);d.onreadystatechange=function(){4===d.readyState&&(200>d.status&&300<=
d.status?a(d.responseText):a(null))};d.send(null)};this.loadXML=function(a,b){vard=newXMLHttpRequest;d.open("GET",a,!0);d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){4===d.readyState&&(0===d.status&&!d.responseText?b("File "+a+" is empty."):200===d.status||0===d.status?b(null,d.responseXML):b(d.responseText))};try{d.send(null)}catch(o){b(o.message)}};this.isFile=function(a,b){e.getFileSize(a,function(a){b(-1!==a)})};this.getFileSize=function(a,b){vard=newXMLHttpRequest;
d.open("HEAD",a,!0);d.onreadystatechange=function(){if(4===d.readyState){vara=d.getResponseHeader("Content-Length");a?b(parseInt(a,10)):b(-1)}};d.send(null)};this.log=m;this.setTimeout=function(a,b){setTimeout(function(){a()},b)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){returnwindow.document.implementation};this.exit=function(a){m("Calling exit with code "+a+", but exit() is not implemented.")};
function(a){varb=[],d,o=a.length;for(d=0;d<o;d+=1)b[d]=a.charCodeAt(d)&255;returnb};this.byteArrayToString=Runtime.byteArrayToString;this.concatByteArrays=function(a,b){returna.concat(b)};this.loadXML=function(a,b){vard=newPackages.java.io.File(a),o;try{o=e.parse(d)}catch(f){print(f);b(f);return}b(null,o)};this.readFile=function(a,b,d){varo=newPackages.java.io.File(a),f="binary"===b?"latin1":b;o.isFile()?(a=readFile(a,f),"binary"===b&&(a=g.byteArrayFromString(a,"binary")),d(null,a)):d(a+" is not a file.")};
this.writeFile=function(a,b,d){vara=newPackages.java.io.FileOutputStream(a),o,f=b.length;for(o=0;o<f;o+=1)a.write(b[o]);a.close();d(null)};this.deleteFile=function(a,b){(newPackages.java.io.File(a))["delete"]()?b(null):b("Could not delete "+a)};this.read=function(c,b,d,o){a&&(c=a+"/"+c);varf;f=c;varh="binary";(newPackages.java.io.File(f)).isFile()?("binary"===h&&(h="latin1"),f=readFile(f,h)):f=null;f?o(null,this.byteArrayFromString(f.substring(b,b+d),"binary")):o("Cannot read "+c)};this.readFileSync=
eval(i)}catch(j){e[h]=null,runtime.log("Cannot load manifest for "+h+".")}elsee[h]=null;if((h=e[h])&&h.indexOf&&-1!==h.indexOf(a))returnb[c]+"/"+a}returnnull}if(!IS_COMPILED_CODE&&!m.hasOwnProperty(k)){varc=k.split("."),b;b=g(c);if(!b&&(b=function(c){varb,f;f=a(c);if(!f)throwc+" is not listed in any manifest.js.";try{b=runtime.readFileSync(f,"utf8")}catch(e){throwruntime.log("Error loading "+c+" "+e),e;}if(void0===b)throw"Cannot load class "+c;try{b=eval(c+" = eval(code);")}catch(i){throwruntime.log("Error loading "+
c+" "+i),i;}returnb}(k),!b||Runtime.getFunctionName(b)!==c[c.length-1]))throwruntime.log("Loaded code is not for "+c[c.length-1]),"Loaded code is not for "+c[c.length-1];m[k]=!0}}})();
core.UnitTestRunner=function(){functiong(a){k+=1;runtime.log("fail",a)}functionm(a,c){varb;try{if(a.length!==c.length)return!1;for(b=0;b<a.length;b+=1)if(a[b]!==c[b])return!1}catch(d){return!1}return!0}functione(a,c,b){("string"!==typeofc||"string"!==typeofb)&&runtime.log("WARN: shouldBe() expects string arguments");vard,e;try{e=eval(c)}catch(f){d=f}a=eval(b);d?g(c+" should be "+a+". Threw exception "+d):(0===a?e===a&&1/e===1/a:e===a||("number"===typeofa&&isNaN(a)?"number"===typeofe&&isNaN(e):
Object.prototype.toString.call(a)===Object.prototype.toString.call([])&&m(e,a)))?runtime.log("pass",c+" is "+b):typeofe===typeofa?g(c+" should be "+a+". Was "+(0===e&&0>1/e?"-0":""+e)+"."):g(c+" should be "+a+" (of type "+typeofa+"). Was "+e+" (of type "+typeofe+").")}vark=0;this.shouldBeNull=function(a,c){e(a,c,"null")};this.shouldBeNonNull=function(a,c){varb,d;try{d=eval(c)}catch(e){b=e}b?g(c+" should be non-null. Threw exception "+b):null!==d?runtime.log("pass",c+" is non-null."):g(c+" should be non-null. Was "+
25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}functionc(a,c){varb,f,d,e,j,h,l,g=this;this.load=function(c){if(void0!==g.data)c(null,g.data);else{vard=j+34+b+f+256;d+l>n&&(d=n-l);runtime.read(a,l,d,function(b,f){if(b)c(b,f);elsea:{vard=f,l=newcore.ByteArray(d),i=l.readUInt32LE(),q;if(67324752!==i)c("File entry signature is wrong."+i.toString()+" "+d.length.toString(),null);else{l.pos+=22;i=l.readUInt16LE();q=l.readUInt16LE();l.pos+=i+q;if(e){d=d.slice(l.pos,
l.pos+j);if(j!==d.length){c("The amount of compressed bytes read was "+d.length.toString()+" instead of "+j.toString()+" for "+g.filename+" in "+a+".",null);breaka}d=p(d,h)}elsed=d.slice(l.pos,l.pos+h);h!==d.length?c("The amount of bytes read was "+d.length.toString()+" instead of "+h.toString()+" for "+g.filename+" in "+a+".",null):(g.data=d,c(null,d))}}})}};this.set=function(a,c,b,d){g.filename=a;g.data=c;g.compressed=b;g.date=d};this.error=null;c&&(33639248!==c.readUInt32LE()?this.error="Central directory entry has wrong signature at position "+
(c.pos-4).toString()+' for file "'+a+'": '+c.data.length.toString():(c.pos+=6,e=c.readUInt16LE(),this.date=k(c.readUInt32LE()),c.readUInt32LE(),j=c.readUInt32LE(),h=c.readUInt32LE(),b=c.readUInt16LE(),f=c.readUInt16LE(),d=c.readUInt16LE(),c.pos+=8,l=c.readUInt32LE(),this.filename=runtime.byteArrayToString(c.data.slice(c.pos,c.pos+b),"utf8"),c.pos+=b+f+d))}functionb(a,b){if(22!==a.length)b("Central directory length should be 22.",t);else{vard=newcore.ByteArray(a),f;f=d.readUInt32LE();101010256!==
f?b("Central directory signature is wrong: "+f.toString(),t):0!==d.readUInt16LE()?b("Zip files with non-zero disk numbers are not supported.",t):0!==d.readUInt16LE()?b("Zip files with non-zero disk numbers are not supported.",t):(f=d.readUInt16LE(),x=d.readUInt16LE(),f!==x?b("Number of entries is inconsistent.",t):(f=d.readUInt32LE(),d=d.readUInt16LE(),d=n-22-f,runtime.read(g,d,n-d,function(a,d){a:{varf=newcore.ByteArray(d),e,l;j=[];for(e=0;e<x;e+=1){l=newc(g,f);if(l.error){b(l.error,t);breaka}j[j.length]=
l}b(null,t)}})))}}functiond(a,c){varb=null,d,f;for(f=0;f<j.length;f+=1)if(d=j[f],d.filename===a){b=d;break}b?b.data?c(null,b.data):b.load(c):c(a+" not found.",null)}functiono(a,c){d(a,function(a,b){if(a)returnc(a,null);b=runtime.byteArrayToString(b,"utf8");c(null,b)})}functionf(c){varb=newcore.ByteArrayWriter("utf8"),d=0;b.appendArray([80,75,3,4,20,0,0,0,0,0]);c.data&&(d=c.data.length);b.appendUInt32LE(a(c.date));b.appendUInt32LE(e(c.data));b.appendUInt32LE(d);b.appendUInt32LE(d);b.appendUInt16LE(c.filename.length);
xmldom.RelaxNGParser=function(){functiong(a,c){this.message=function(){c&&(a+=1===c.nodeType?" Element ":" Node ",a+=c.nodeName,c.nodeValue&&(a+=" with value '"+c.nodeValue+"'"),a+=".");returna}}functionm(a){if(2>=a.e.length)returna;varc={name:a.name,e:a.e.slice(0,2)};returnm({name:a.name,e:[c].concat(a.e.slice(2))})}functione(a){vara=a.split(":",2),c="",b;1===a.length?a=["",a[0]]:c=a[0];for(bind)d[b]===c&&(a[0]=b);returna}functionk(a,c){for(varb=0,d,g,o=a.name;a.e&&b<a.e.length;)if(d=
a.e[b],"ref"===d.name){g=c[d.a.name];if(!g)throwd.a.name+" was not defined.";d=a.e.slice(b+1);a.e=a.e.slice(0,b);a.e=a.e.concat(g.e);a.e=a.e.concat(d)}elseb+=1,k(d,c);d=a.e;if("choice"===o&&(!d||!d[1]||"empty"===d[1].name))!d||!d[0]||"empty"===d[0].name?(deletea.e,a.name="empty"):(d[1]=d[0],d[0]={name:"empty"});if("group"===o||"interleave"===o)"empty"===d[0].name?"empty"===d[1].name?(deletea.e,a.name="empty"):(o=a.name=d[1].name,a.names=d[1].names,d=a.e=d[1].e):"empty"===d[1].name&&(o=a.name=
f.documentElement,i,void0),n,m,p={};for(n=0;n<j.e.length;n+=1)m=j.e[n],"define"===m.name?p[m.a.name]=m:"start"===m.name&&(b=m);if(!b)return[newg("No Relax NG start element was found.")];k(b,p);for(ninp)p.hasOwnProperty(n)&&k(p[n],p);for(n=0;n<i.length;n+=1)k(i[n],p);e&&(c.rootPattern=e(b.e[0],i));a(b,i);for(n=0;n<i.length;n+=1)a(i[n],i);c.start=b;c.elements=i;c.nsmap=d;returnnull}};
case"choice":returnh(y(a.e[0],d),y(a.e[1],d));case"interleave":f=y(a.e[0],d);for(e=1;e<a.e.length;e+=1)f=i(f,y(a.e[e],d));returnf;case"group":returnj(y(a.e[0],d),y(a.e[1],d));case"oneOrMore":returnx(y(a.e[0],d));case"attribute":returnt(r(a.e[0]),y(a.e[1],d));case"value":returnp(a.text);case"data":returnf=a.a&&a.a.type,void0===f&&(f=""),z(f);case"list":returnb()}throw"No support for "+a.name;};this.makePattern=function(a,b){varc={},d;for(dinb)b.hasOwnProperty(d)&&(c[d]=b[d]);returnd=
s(a,c)};this.validate=function(a,b){varc;a.currentNode=a.root;c=w(null,G,a);c.nullable?b(null):(runtime.log("Error in Relax NG validation: "+c),b(["Error in Relax NG validation: "+c]))};this.init=function(a){G=a}};
// Input 16
runtime.loadClass("xmldom.RelaxNGParser");
xmldom.RelaxNG2=function(){functiong(a,c){this.message=function(){c&&(a+=1===c.nodeType?" Element ":" Node ",a+=c.nodeName,c.nodeValue&&(a+=" with value '"+c.nodeValue+"'"),a+=".");returna}}functionm(b,c,e,f){return"empty"===b.name?null:a(b,c,e,f)}functione(a,d){if(2!==a.e.length)throw"Element with wrong # of elements: "+a.e.length;for(vare=d.currentNode,f=e?e.nodeType:0,h=null;1<f;){if(8!==f&&(3!==f||!/^\s+$/.test(d.currentNode.nodeValue)))return[newg("Not allowed node of type "+f+".")];f=
(e=d.nextSibling())?e.nodeType:0}if(!e)return[newg("Missing element "+a.names)];if(a.names&&-1===a.names.indexOf(c[e.namespaceURI]+":"+e.localName))return[newg("Found "+e.nodeName+" instead of "+a.names+".",e)];if(d.firstChild()){for(h=m(a.e[1],d,e);d.nextSibling();)if(f=d.currentNode.nodeType,(!d.currentNode||!(3===d.currentNode.nodeType&&/^\s+$/.test(d.currentNode.nodeValue)))&&8!==f)return[newg("Spurious content.",d.currentNode)];if(d.parentNode()!==e)return[newg("Implementation error.")]}elseh=
m(a.e[1],d,e);d.nextSibling();returnh}vark,a,c;a=function(b,c,o,f){varh=b.name,i=null;if("text"===h)a:{for(varj=(b=c.currentNode)?b.nodeType:0;b!==o&&3!==j;){if(1===j){i=[newg("Element not allowed here.",b)];breaka}j=(b=c.nextSibling())?b.nodeType:0}c.nextSibling();i=null}elseif("data"===h)i=null;elseif("value"===h)f!==b.text&&(i=[newg("Wrong value, should be '"+b.text+"', not '"+f+"'",o)]);elseif("list"===h)i=null;elseif("attribute"===h)a:{if(2!==b.e.length)throw"Attribute with wrong # of elements: "+
b.e.length;h=b.localnames.length;for(i=0;i<h;i+=1){f=o.getAttributeNS(b.namespaces[i],b.localnames[i]);""===f&&!o.hasAttributeNS(b.namespaces[i],b.localnames[i])&&(f=void0);if(void0!==j&&void0!==f){i=[newg("Attribute defined too often.",o)];breaka}j=f}i=void0===j?[newg("Attribute not found: "+b.names,o)]:m(b.e[1],c,o,j)}elseif("element"===h)i=e(b,c,o);elseif("oneOrMore"===h){f=0;doj=c.currentNode,h=a(b.e[0],c,o),f+=1;while(!h&&j!==c.currentNode);1<f?(c.currentNode=j,i=null):i=h}elseif("choice"===
h){if(2!==b.e.length)throw"Choice with wrong # of options: "+b.e.length;j=c.currentNode;if("empty"===b.e[0].name){if(h=a(b.e[1],c,o,f))c.currentNode=j;i=null}else{if(h=m(b.e[0],c,o,f))c.currentNode=j,h=a(b.e[1],c,o,f);i=h}}elseif("group"===h){if(2!==b.e.length)throw"Group with wrong # of members: "+b.e.length;i=a(b.e[0],c,o)||a(b.e[1],c,o)}elseif("interleave"===h)a:{for(varj=b.e.length,f=[j],n=j,k,p,t,r;0<n;){k=0;p=c.currentNode;for(i=0;i<j;i+=1)t=c.currentNode,!0!==f[i]&&f[i]!==t&&(r=b.e[i],(h=
a(r,c,o))?(c.currentNode=t,void0===f[i]&&(f[i]=!1)):t===c.currentNode||"oneOrMore"===r.name||"choice"===r.name&&("oneOrMore"===r.e[0].name||"oneOrMore"===r.e[1].name)?(k+=1,f[i]=t):(k+=1,f[i]=!0));if(p===c.currentNode&&k===n)break;if(0===k){for(i=0;i<j;i+=1)if(!1===f[i]){i=[newg("Interleave does not match.",o)];breaka}break}for(i=n=0;i<j;i+=1)!0!==f[i]&&(n+=1)}i=null}elsethrowh+" not allowed in nonEmptyPattern.";returni};this.validate=function(a,c){a.currentNode=a.root;vare=m(k.e[0],a,a.root);