/
esp-connect-api.js
1 lines (1 loc) · 269 KB
/
esp-connect-api.js
1
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.esp_connect=t():e.esp_connect=t()}(global,(()=>(()=>{var e,t,r={4981:e=>{"use strict";e.exports=e=>{e=Object.assign({onlyFirst:!1},e);const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e.onlyFirst?void 0:"g")}},2686:e=>{"use strict";e.exports={mask:(e,t,r,n,s)=>{for(var i=0;i<s;i++)r[n+i]=e[i]^t[3&i]},unmask:(e,t)=>{const r=e.length;for(var n=0;n<r;n++)e[n]^=t[3&n]}}},1675:(e,t,r)=>{"use strict";try{e.exports=r(9740)(__dirname)}catch(t){e.exports=r(2686)}},676:e=>{e.exports=n,n.strict=s,n.loose=i;var t=Object.prototype.toString,r={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function n(e){return s(e)||i(e)}function s(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function i(e){return r[t.call(e)]}},9740:(e,t,r)=>{var n=r(7147),s=r(1017),i=r(2037),o=require,a=process.config&&process.config.variables||{},u=!!process.env.PREBUILDS_ONLY,h=process.versions.modules,l=!(!process.versions||!process.versions.electron)||!!process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type?"electron":process.versions&&process.versions.nw?"node-webkit":"node",c=process.env.npm_config_arch||i.arch(),p=process.env.npm_config_platform||i.platform(),d=process.env.LIBC||(function(e){return"linux"===e&&n.existsSync("/etc/alpine-release")}(p)?"musl":"glibc"),f=process.env.ARM_VERSION||("arm64"===c?"8":a.arm_version)||"",g=(process.versions.uv||"").split(".")[0];function m(e){return o(m.path(e))}function v(e){try{return n.readdirSync(e)}catch(e){return[]}}function _(e,t){var r=v(e).filter(t);return r[0]&&s.join(e,r[0])}function y(e){return/\.node$/.test(e)}function w(e){var t=e.split("-");if(2===t.length){var r=t[0],n=t[1].split("+");if(r&&n.length&&n.every(Boolean))return{name:e,platform:r,architectures:n}}}function b(e,t){return function(r){return null!=r&&(r.platform===e&&r.architectures.includes(t))}}function O(e,t){return e.architectures.length-t.architectures.length}function E(e){var t=e.split("."),r={file:e,specificity:0};if("node"===t.pop()){for(var n=0;n<t.length;n++){var s=t[n];if("node"===s||"electron"===s||"node-webkit"===s)r.runtime=s;else if("napi"===s)r.napi=!0;else if("abi"===s.slice(0,3))r.abi=s.slice(3);else if("uv"===s.slice(0,2))r.uv=s.slice(2);else if("armv"===s.slice(0,4))r.armv=s.slice(4);else{if("glibc"!==s&&"musl"!==s)continue;r.libc=s}r.specificity++}return r}}function N(e,t){return function(r){return null!=r&&(!(r.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(r))&&(!(r.abi!==t&&!r.napi)&&((!r.uv||r.uv===g)&&((!r.armv||r.armv===f)&&(!r.libc||r.libc===d)))))}}function S(e){return function(t,r){return t.runtime!==r.runtime?t.runtime===e?-1:1:t.abi!==r.abi?t.abi?-1:1:t.specificity!==r.specificity?t.specificity>r.specificity?-1:1:0}}e.exports=m,m.path=function(e){e=s.resolve(e||".");try{var t=o(s.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}if(!u){var r=_(s.join(e,"build/Release"),y);if(r)return r;var n=_(s.join(e,"build/Debug"),y);if(n)return n}var i=x(e);if(i)return i;var a=x(s.dirname(process.execPath));if(a)return a;var m=["platform="+p,"arch="+c,"runtime="+l,"abi="+h,"uv="+g,f?"armv="+f:"","libc="+d,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","webpack=true"].filter(Boolean).join(" ");throw new Error("No native build was found for "+m+"\n loaded from: "+e+"\n");function x(e){var t=v(s.join(e,"prebuilds")).map(w).filter(b(p,c)).sort(O)[0];if(t){var r=s.join(e,"prebuilds",t.name),n=v(r).map(E).filter(N(l,h)).sort(S(l))[0];return n?s.join(r,n.file):void 0}}},m.parseTags=E,m.matchTags=N,m.compareTags=S,m.parseTuple=w,m.matchTuple=b,m.compareTuples=O},7627:(e,t,r)=>{"use strict";var n=r(7147),s=r(2128);e.exports=function(e){var t=(e=e||{}).sigint,r=e.eot,i=e.autocomplete=e.autocomplete||function(){return[]},o=e.history;return a.history=o||{save:function(){}},a.hide=function(e){return a(e,{echo:""})},a;function a(e,s,a){var h,l,c=0,p=0;a=a||{},Object(e)===e?e=(a=e).ask:Object(s)===s&&(s=(a=s).value),e=e||"";var d=a.echo,f="echo"in a;i=a.autocomplete||i;var g="win32"===process.platform?process.stdin.fd:n.openSync("/dev/tty","rs"),m=process.stdin.isRaw;m||process.stdin.setRawMode&&process.stdin.setRawMode(!0);var v,_,y=Buffer.alloc(3),w="";l="",e&&process.stdout.write(e);for(var b=0;;)if((_=n.readSync(g,y,0,3))>1)switch(y.toString()){case"[A":if(f)break;if(!o)break;if(o.atStart())break;o.atEnd()&&(l=w,p=c),c=(w=o.prev()).length,process.stdout.write("[2K[0G"+e+w);break;case"[B":if(f)break;if(!o)break;if(o.pastEnd())break;o.atPenultimate()?(w=l,c=p,o.next()):c=(w=o.next()).length,process.stdout.write("[2K[0G"+e+w+"["+(c+e.length+1)+"G");break;case"[D":if(f)break;c-(c=--c<0?0:c)&&process.stdout.write("[1D");break;case"[C":if(f)break;c=++c>w.length?w.length:c,process.stdout.write("["+(c+e.length+1)+"G");break;default:y.toString()&&(u(f,e,d,w=(w+=y.toString()).replace(/\0/g,""),c=w.length),process.stdout.write("["+(c+e.length+1)+"G"),y=Buffer.alloc(3))}else{if(3==(v=y[_-1]))return process.stdout.write("^C\n"),n.closeSync(g),t&&process.exit(130),process.stdin.setRawMode&&process.stdin.setRawMode(m),null;if(4==v&&0==w.length&&r&&(process.stdout.write("exit\n"),process.exit(0)),13==v){if(n.closeSync(g),!o)break;!f&&w.length&&o.push(w),o.reset();break}if(9==v){if(w==(h=i(w))[0]?h=i(""):h.length,0==h.length){process.stdout.write("\t");continue}var O=h[b++]||h[(b=0,b++)];O&&(process.stdout.write("\r[K"+e+O),w=O,c=O.length)}if(127==v||"win32"==process.platform&&8==v){if(!c)continue;w=w.slice(0,c-1)+w.slice(c),c--,process.stdout.write("[2D")}else{if(v<32||v>126)continue;w=w.slice(0,c)+String.fromCharCode(v)+w.slice(c),c++}u(f,e,d,w,c)}return process.stdout.write("\n"),process.stdin.setRawMode&&process.stdin.setRawMode(m),w||s||""}function u(e,t,r,n,i){if(e)process.stdout.write("[2K[0G"+t+Array(n.length+1).join(r));else{process.stdout.write("[s"),i==n.length||t?process.stdout.write("[2K[0G"+t+n):process.stdout.write("[2K[0G"+n+"["+(n.length-i)+"D");var o=s(t).length;process.stdout.write(`[${o+1+(""==r?0:i)}G`)}}}},2128:(e,t,r)=>{"use strict";const n=r(4981),s=e=>"string"==typeof e?e.replace(n(),""):e;e.exports=s,e.exports.default=s},8004:(e,t,r)=>{e.exports=r(946)},946:(e,t,r)=>{"use strict";r(1808);var n,s=r(4404),i=r(3685),o=r(5687),a=r(2361),u=(r(9491),r(3837));function h(e){var t=this;t.options=e||{},t.proxyOptions=t.options.proxy||{},t.maxSockets=t.options.maxSockets||i.Agent.defaultMaxSockets,t.requests=[],t.sockets=[],t.on("free",(function(e,r,n,s){for(var i=c(r,n,s),o=0,a=t.requests.length;o<a;++o){var u=t.requests[o];if(u.host===i.host&&u.port===i.port)return t.requests.splice(o,1),void u.request.onSocket(e)}e.destroy(),t.removeSocket(e)}))}function l(e,t){var r=this;h.prototype.createSocket.call(r,e,(function(n){var i=e.request.getHeader("host"),o=p({},r.options,{socket:n,servername:i?i.replace(/:.*$/,""):e.host}),a=s.connect(0,o);r.sockets[r.sockets.indexOf(n)]=a,t(a)}))}function c(e,t,r){return"string"==typeof e?{host:e,port:t,localAddress:r}:e}function p(e){for(var t=1,r=arguments.length;t<r;++t){var n=arguments[t];if("object"==typeof n)for(var s=Object.keys(n),i=0,o=s.length;i<o;++i){var a=s[i];void 0!==n[a]&&(e[a]=n[a])}}return e}t.httpOverHttp=function(e){var t=new h(e);return t.request=i.request,t},t.httpsOverHttp=function(e){var t=new h(e);return t.request=i.request,t.createSocket=l,t.defaultPort=443,t},t.httpOverHttps=function(e){var t=new h(e);return t.request=o.request,t},t.httpsOverHttps=function(e){var t=new h(e);return t.request=o.request,t.createSocket=l,t.defaultPort=443,t},u.inherits(h,a.EventEmitter),h.prototype.addRequest=function(e,t,r,n){var s=this,i=p({request:e},s.options,c(t,r,n));s.sockets.length>=this.maxSockets?s.requests.push(i):s.createSocket(i,(function(t){function r(){s.emit("free",t,i)}function n(e){s.removeSocket(t),t.removeListener("free",r),t.removeListener("close",n),t.removeListener("agentRemove",n)}t.on("free",r),t.on("close",n),t.on("agentRemove",n),e.onSocket(t)}))},h.prototype.createSocket=function(e,t){var r=this,s={};r.sockets.push(s);var i=p({},r.proxyOptions,{method:"CONNECT",path:e.host+":"+e.port,agent:!1,headers:{host:e.host+":"+e.port}});e.localAddress&&(i.localAddress=e.localAddress),i.proxyAuth&&(i.headers=i.headers||{},i.headers["Proxy-Authorization"]="Basic "+new Buffer(i.proxyAuth).toString("base64")),n("making CONNECT request");var o=r.request(i);function a(i,a,u){var h;return o.removeAllListeners(),a.removeAllListeners(),200!==i.statusCode?(n("tunneling socket could not be established, statusCode=%d",i.statusCode),a.destroy(),(h=new Error("tunneling socket could not be established, statusCode="+i.statusCode)).code="ECONNRESET",e.request.emit("error",h),void r.removeSocket(s)):u.length>0?(n("got illegal response body from proxy"),a.destroy(),(h=new Error("got illegal response body from proxy")).code="ECONNRESET",e.request.emit("error",h),void r.removeSocket(s)):(n("tunneling connection has established"),r.sockets[r.sockets.indexOf(s)]=a,t(a))}o.useChunkedEncodingByDefault=!1,o.once("response",(function(e){e.upgrade=!0})),o.once("upgrade",(function(e,t,r){process.nextTick((function(){a(e,t,r)}))})),o.once("connect",a),o.once("error",(function(t){o.removeAllListeners(),n("tunneling socket could not be established, cause=%s\n",t.message,t.stack);var i=new Error("tunneling socket could not be established, cause="+t.message);i.code="ECONNRESET",e.request.emit("error",i),r.removeSocket(s)})),o.end()},h.prototype.removeSocket=function(e){var t=this.sockets.indexOf(e);if(-1!==t){this.sockets.splice(t,1);var r=this.requests.shift();r&&this.createSocket(r,(function(e){r.request.onSocket(e)}))}},n=process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments);"string"==typeof e[0]?e[0]="TUNNEL: "+e[0]:e.unshift("TUNNEL:"),console.error.apply(console,e)}:function(){},t.debug=n},7243:(e,t,r)=>{var n=r(676).strict;e.exports=function(e){if(n(e)){var t=Buffer.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(t=t.slice(e.byteOffset,e.byteOffset+e.byteLength)),t}return Buffer.from(e)}},7987:e=>{"use strict";e.exports=function(e){const t=e.length;let r=0;for(;r<t;)if(0==(128&e[r]))r++;else if(192==(224&e[r])){if(r+1===t||128!=(192&e[r+1])||192==(254&e[r]))return!1;r+=2}else if(224==(240&e[r])){if(r+2>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||224===e[r]&&128==(224&e[r+1])||237===e[r]&&160==(224&e[r+1]))return!1;r+=3}else{if(240!=(248&e[r]))return!1;if(r+3>=t||128!=(192&e[r+1])||128!=(192&e[r+2])||128!=(192&e[r+3])||240===e[r]&&128==(240&e[r+1])||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}},9574:(e,t,r)=>{"use strict";try{e.exports=r(9740)(__dirname)}catch(t){e.exports=r(7987)}},4748:(e,t,r)=>{e.exports=r(2426)},8478:e=>{var t={disableWarnings:!1,deprecationWarningMap:{},warn:function(e){!this.disableWarnings&&this.deprecationWarningMap[e]&&(console.warn("DEPRECATION WARNING: "+this.deprecationWarningMap[e]),this.deprecationWarningMap[e]=!1)}};e.exports=t},7521:(e,t,r)=>{var n=r(1109),s=r(7243),i=r(293);const o=0,a=1,u=2,h=3;function l(e,t,r,s,a,u){i.EventTarget.call(this),(u=u||{}).assembleFragments=!0;var h=this;this._url=e,this._readyState=o,this._protocol=void 0,this._extensions="",this._bufferedAmount=0,this._binaryType="arraybuffer",this._connection=void 0,this._client=new n(u),this._client.on("connect",(function(e){d.call(h,e)})),this._client.on("connectFailed",(function(){f.call(h)})),this._client.connect(e,t,r,s,a)}function c(e,t){var r=new i.Event("close");return r.code=e,r.reason=t,r.wasClean=void 0===e||1e3===e,r}function p(e){var t=new i.Event("message");return t.data=e,t}function d(e){var t=this;this._readyState=a,this._connection=e,this._protocol=e.protocol,this._extensions=e.extensions,this._connection.on("close",(function(e,r){g.call(t,e,r)})),this._connection.on("message",(function(e){m.call(t,e)})),this.dispatchEvent(new i.Event("open"))}function f(){v.call(this),this._readyState=h;try{this.dispatchEvent(new i.Event("error"))}finally{this.dispatchEvent(c(1006,"connection failed"))}}function g(e,t){v.call(this),this._readyState=h,this.dispatchEvent(c(e,t||""))}function m(e){if(e.utf8Data)this.dispatchEvent(p(e.utf8Data));else if(e.binaryData&&"arraybuffer"===this.binaryType){for(var t=e.binaryData,r=new ArrayBuffer(t.length),n=new Uint8Array(r),s=0,i=t.length;s<i;++s)n[s]=t[s];this.dispatchEvent(p(r))}}function v(){this._client.removeAllListeners(),this._connection&&this._connection.removeAllListeners()}e.exports=l,Object.defineProperties(l.prototype,{url:{get:function(){return this._url}},readyState:{get:function(){return this._readyState}},protocol:{get:function(){return this._protocol}},extensions:{get:function(){return this._extensions}},bufferedAmount:{get:function(){return this._bufferedAmount}}}),Object.defineProperties(l.prototype,{binaryType:{get:function(){return this._binaryType},set:function(e){if("arraybuffer"!==e)throw new SyntaxError('just "arraybuffer" type allowed for "binaryType" attribute');this._binaryType=e}}}),[["CONNECTING",o],["OPEN",a],["CLOSING",u],["CLOSED",h]].forEach((function(e){Object.defineProperty(l.prototype,e[0],{get:function(){return e[1]}})})),[["CONNECTING",o],["OPEN",a],["CLOSING",u],["CLOSED",h]].forEach((function(e){Object.defineProperty(l,e[0],{get:function(){return e[1]}})})),l.prototype.send=function(e){if(this._readyState!==a)throw new Error("cannot call send() while not connected");if("string"==typeof e||e instanceof String)this._connection.sendUTF(e);else if(e instanceof Buffer)this._connection.sendBytes(e);else{if(!e.byteLength&&0!==e.byteLength)throw new Error("unknown binary data:",e);e=s(e),this._connection.sendBytes(e)}},l.prototype.close=function(e,t){switch(this._readyState){case o:f.call(this),this._client.on("connect",(function(r){e?r.close(e,t):r.close()}));break;case a:this._readyState=u,e?this._connection.close(e,t):this._connection.close()}}},1109:(e,t,r)=>{var n=r(3569),s=n.extend,i=r(3837),o=r(2361).EventEmitter,a=r(3685),u=r(5687),h=r(7310),l=r(6113),c=r(8918),p=n.bufferAllocUnsafe,d=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],f=["hostname","port","method","path","headers"];function g(e){var t;(o.call(this),this.config={maxReceivedFrameSize:1048576,maxReceivedMessageSize:8388608,fragmentOutgoingMessages:!0,fragmentationThreshold:16384,webSocketVersion:13,assembleFragments:!0,disableNagleAlgorithm:!0,closeTimeout:5e3,tlsOptions:{}},e)&&(e.tlsOptions?(t=e.tlsOptions,delete e.tlsOptions):t={},s(this.config,e),s(this.config.tlsOptions,t));switch(this._req=null,this.config.webSocketVersion){case 8:case 13:break;default:throw new Error("Requested webSocketVersion is not supported. Allowed values are 8 and 13.")}}i.inherits(g,o),g.prototype.connect=function(e,t,r,i,o){var l=this;if("string"==typeof t&&(t=t.length>0?[t]:[]),t instanceof Array||(t=[]),this.protocols=t,this.origin=r,this.url="string"==typeof e?h.parse(e):e,!this.url.protocol)throw new Error("You must specify a full WebSocket URL, including protocol.");if(!this.url.host)throw new Error("You must specify a full WebSocket URL, including hostname. Relative URLs are not supported.");this.secure="wss:"===this.url.protocol,this.protocols.forEach((function(e){for(var t=0;t<e.length;t++){var r=e.charCodeAt(t),n=e.charAt(t);if(r<33||r>126||-1!==d.indexOf(n))throw new Error('Protocol list contains invalid character "'+String.fromCharCode(r)+'"')}}));this.url.port||(this.url.port={"ws:":"80","wss:":"443"}[this.url.protocol]);for(var c=p(16),g=0;g<16;g++)c[g]=Math.round(255*Math.random());this.base64nonce=c.toString("base64");var m=this.url.hostname;("ws:"===this.url.protocol&&"80"!==this.url.port||"wss:"===this.url.protocol&&"443"!==this.url.port)&&(m+=":"+this.url.port);var v,_={};function y(e){l._req=null,l.emit("connectFailed",e)}this.secure&&this.config.tlsOptions.hasOwnProperty("headers")&&s(_,this.config.tlsOptions.headers),i&&s(_,i),s(_,{Upgrade:"websocket",Connection:"Upgrade","Sec-WebSocket-Version":this.config.webSocketVersion.toString(10),"Sec-WebSocket-Key":this.base64nonce,Host:_.Host||m}),this.protocols.length>0&&(_["Sec-WebSocket-Protocol"]=this.protocols.join(", ")),this.origin&&(13===this.config.webSocketVersion?_.Origin=this.origin:8===this.config.webSocketVersion&&(_["Sec-WebSocket-Origin"]=this.origin)),v=this.url.pathname?this.url.path:this.url.path?"/"+this.url.path:"/";var w={agent:!1};if(o&&s(w,o),s(w,{hostname:this.url.hostname,port:this.url.port,method:"GET",path:v,headers:_}),this.secure){var b=this.config.tlsOptions;for(var O in b)b.hasOwnProperty(O)&&-1===f.indexOf(O)&&(w[O]=b[O])}var E=this._req=(this.secure?u:a).request(w);E.on("upgrade",(function(e,t,r){l._req=null,E.removeListener("error",y),l.socket=t,l.response=e,l.firstDataChunk=r,l.validateHandshake()})),E.on("error",y),E.on("response",(function(e){if(l._req=null,n.eventEmitterListenerCount(l,"httpResponse")>0)l.emit("httpResponse",e,l),e.socket&&e.socket.end();else{var t=[];for(var r in e.headers)t.push(r+": "+e.headers[r]);l.failHandshake("Server responded with a non-101 status: "+e.statusCode+" "+e.statusMessage+"\nResponse Headers Follow:\n"+t.join("\n")+"\n")}})),E.end()},g.prototype.validateHandshake=function(){var e=this.response.headers;if(this.protocols.length>0){if(this.protocol=e["sec-websocket-protocol"],!this.protocol)return void this.failHandshake("Expected a Sec-WebSocket-Protocol header.");if(-1===this.protocols.indexOf(this.protocol))return void this.failHandshake("Server did not respond with a requested protocol.")}if(e.connection&&"upgrade"===e.connection.toLocaleLowerCase())if(e.upgrade&&"websocket"===e.upgrade.toLocaleLowerCase()){var t=l.createHash("sha1");t.update(this.base64nonce+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var r=t.digest("base64");e["sec-websocket-accept"]?e["sec-websocket-accept"]===r?this.succeedHandshake():this.failHandshake("Sec-WebSocket-Accept header from server didn't match expected value of "+r):this.failHandshake("Expected Sec-WebSocket-Accept header from server")}else this.failHandshake("Expected an Upgrade: websocket header from the server");else this.failHandshake("Expected a Connection: Upgrade header from the server")},g.prototype.failHandshake=function(e){this.socket&&this.socket.writable&&this.socket.end(),this.emit("connectFailed",new Error(e))},g.prototype.succeedHandshake=function(){var e=new c(this.socket,[],this.protocol,!0,this.config);e.webSocketVersion=this.config.webSocketVersion,e._addSocketEventListeners(),this.emit("connect",e),this.firstDataChunk.length>0&&e.handleSocketData(this.firstDataChunk),this.firstDataChunk=null},g.prototype.abort=function(){this._req&&this._req.abort()},e.exports=g},8918:(e,t,r)=>{var n=r(3837),s=r(3569),i=r(2361).EventEmitter,o=r(587),a=r(4218),u=r(9574),h=s.bufferAllocUnsafe,l=s.bufferFromString;const c="open",p="peer_requested_close",d="ending",f="closed";var g="setImmediate"in global?global.setImmediate.bind(global):process.nextTick.bind(process),m=0;function v(e,t,r,n,u){if(this._debug=s.BufferingLogger("websocket:connection",++m),this._debug("constructor"),this._debug.enabled&&function(e,t){if(!e._debug.enabled)return;var r=t.emit;for(var n in t.emit=function(t){e._debug("||| Socket Event '%s'",t),r.apply(this,arguments)},t)"function"==typeof t[n]&&-1===["emit"].indexOf(n)&&function(r){var n=t[r];t[r]="on"!==r?function(){return e._debug("||| Socket method called: %s",r),n.apply(this,arguments)}:function(){return e._debug("||| Socket method called: %s (%s)",r,arguments[0]),n.apply(this,arguments)}}(n)}(this,e),i.call(this),this._pingListenerCount=0,this.on("newListener",(function(e){"ping"===e&&this._pingListenerCount++})).on("removeListener",(function(e){"ping"===e&&this._pingListenerCount--})),this.config=u,this.socket=e,this.protocol=r,this.extensions=t,this.remoteAddress=e.remoteAddress,this.closeReasonCode=-1,this.closeDescription=null,this.closeEventEmitted=!1,this.maskOutgoingPackets=n,this.maskBytes=h(4),this.frameHeader=h(10),this.bufferList=new a,this.currentFrame=new o(this.maskBytes,this.frameHeader,this.config),this.fragmentationSize=0,this.frameQueue=[],this.connected=!0,this.state=c,this.waitingForCloseResponse=!1,this.receivedEnd=!1,this.closeTimeout=this.config.closeTimeout,this.assembleFragments=this.config.assembleFragments,this.maxReceivedMessageSize=this.config.maxReceivedMessageSize,this.outputBufferFull=!1,this.inputPaused=!1,this.receivedDataHandler=this.processReceivedData.bind(this),this._closeTimerHandler=this.handleCloseTimer.bind(this),this.socket.setNoDelay(this.config.disableNagleAlgorithm),this.socket.setTimeout(0),this.config.keepalive&&!this.config.useNativeKeepalive){if("number"!=typeof this.config.keepaliveInterval)throw new Error("keepaliveInterval must be specified and numeric if keepalive is true.");if(this._keepaliveTimerHandler=this.handleKeepaliveTimer.bind(this),this.setKeepaliveTimer(),this.config.dropConnectionOnKeepaliveTimeout){if("number"!=typeof this.config.keepaliveGracePeriod)throw new Error("keepaliveGracePeriod must be specified and numeric if dropConnectionOnKeepaliveTimeout is true.");this._gracePeriodTimerHandler=this.handleGracePeriodTimer.bind(this)}}else if(this.config.keepalive&&this.config.useNativeKeepalive){if(!("setKeepAlive"in this.socket))throw new Error("Unable to use native keepalive: unsupported by this version of Node.");this.socket.setKeepAlive(!0,this.config.keepaliveInterval)}this.socket.removeAllListeners("error")}function _(e){return!(e<1e3)&&(e>=1e3&&e<=2999?-1!==[1e3,1001,1002,1003,1007,1008,1009,1010,1011,1012,1013,1014,1015].indexOf(e):e>=3e3&&e<=3999||(e>=4e3&&e<=4999||!(e>=5e3)&&void 0))}v.CLOSE_REASON_NORMAL=1e3,v.CLOSE_REASON_GOING_AWAY=1001,v.CLOSE_REASON_PROTOCOL_ERROR=1002,v.CLOSE_REASON_UNPROCESSABLE_INPUT=1003,v.CLOSE_REASON_RESERVED=1004,v.CLOSE_REASON_NOT_PROVIDED=1005,v.CLOSE_REASON_ABNORMAL=1006,v.CLOSE_REASON_INVALID_DATA=1007,v.CLOSE_REASON_POLICY_VIOLATION=1008,v.CLOSE_REASON_MESSAGE_TOO_BIG=1009,v.CLOSE_REASON_EXTENSION_REQUIRED=1010,v.CLOSE_REASON_INTERNAL_SERVER_ERROR=1011,v.CLOSE_REASON_TLS_HANDSHAKE_FAILED=1015,v.CLOSE_DESCRIPTIONS={1e3:"Normal connection closure",1001:"Remote peer is going away",1002:"Protocol error",1003:"Unprocessable input",1004:"Reserved",1005:"Reason not provided",1006:"Abnormal closure, no further detail available",1007:"Invalid data received",1008:"Policy violation",1009:"Message too big",1010:"Extension requested by client is required",1011:"Internal Server Error",1015:"TLS Handshake Failed"},n.inherits(v,i),v.prototype._addSocketEventListeners=function(){this.socket.on("error",this.handleSocketError.bind(this)),this.socket.on("end",this.handleSocketEnd.bind(this)),this.socket.on("close",this.handleSocketClose.bind(this)),this.socket.on("drain",this.handleSocketDrain.bind(this)),this.socket.on("pause",this.handleSocketPause.bind(this)),this.socket.on("resume",this.handleSocketResume.bind(this)),this.socket.on("data",this.handleSocketData.bind(this))},v.prototype.setKeepaliveTimer=function(){this._debug("setKeepaliveTimer"),this.config.keepalive&&!this.config.useNativeKeepalive&&(this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this._keepaliveTimeoutID=setTimeout(this._keepaliveTimerHandler,this.config.keepaliveInterval))},v.prototype.clearKeepaliveTimer=function(){this._keepaliveTimeoutID&&clearTimeout(this._keepaliveTimeoutID)},v.prototype.handleKeepaliveTimer=function(){this._debug("handleKeepaliveTimer"),this._keepaliveTimeoutID=null,this.ping(),this.config.dropConnectionOnKeepaliveTimeout?this.setGracePeriodTimer():this.setKeepaliveTimer()},v.prototype.setGracePeriodTimer=function(){this._debug("setGracePeriodTimer"),this.clearGracePeriodTimer(),this._gracePeriodTimeoutID=setTimeout(this._gracePeriodTimerHandler,this.config.keepaliveGracePeriod)},v.prototype.clearGracePeriodTimer=function(){this._gracePeriodTimeoutID&&clearTimeout(this._gracePeriodTimeoutID)},v.prototype.handleGracePeriodTimer=function(){this._debug("handleGracePeriodTimer"),this._gracePeriodTimeoutID=null,this.drop(v.CLOSE_REASON_ABNORMAL,"Peer not responding.",!0)},v.prototype.handleSocketData=function(e){this._debug("handleSocketData"),this.setKeepaliveTimer(),this.bufferList.write(e),this.processReceivedData()},v.prototype.processReceivedData=function(){if(this._debug("processReceivedData"),this.connected&&!this.inputPaused){var e=this.currentFrame;if(e.addData(this.bufferList)){var t=this;if(e.protocolError)return this._debug("-- protocol error"),void process.nextTick((function(){t.drop(v.CLOSE_REASON_PROTOCOL_ERROR,e.dropReason)}));if(e.frameTooLarge)return this._debug("-- frame too large"),void process.nextTick((function(){t.drop(v.CLOSE_REASON_MESSAGE_TOO_BIG,e.dropReason)}));if(e.rsv1||e.rsv2||e.rsv3)return this._debug("-- illegal rsv flag"),void process.nextTick((function(){t.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unsupported usage of rsv bits without negotiated extension.")}));this.assembleFragments||(this._debug("-- emitting frame"),process.nextTick((function(){t.emit("frame",e)}))),process.nextTick((function(){t.processFrame(e)})),this.currentFrame=new o(this.maskBytes,this.frameHeader,this.config),this.bufferList.length>0&&g(this.receivedDataHandler)}else this._debug("-- insufficient data for frame")}},v.prototype.handleSocketError=function(e){this._debug("handleSocketError: %j",e),this.state!==f?(this.closeReasonCode=v.CLOSE_REASON_ABNORMAL,this.closeDescription="Socket Error: "+e.syscall+" "+e.code,this.connected=!1,this.state=f,this.fragmentationSize=0,s.eventEmitterListenerCount(this,"error")>0&&this.emit("error",e),this.socket.destroy(),this._debug.printOutput()):this._debug(" --- Socket 'error' after 'close'")},v.prototype.handleSocketEnd=function(){this._debug("handleSocketEnd: received socket end. state = %s",this.state),this.receivedEnd=!0,this.state!==f?this.state!==p&&this.state!==d&&(this._debug(" --- UNEXPECTED socket end."),this.socket.end()):this._debug(" --- Socket 'end' after 'close'")},v.prototype.handleSocketClose=function(e){this._debug("handleSocketClose: received socket close"),this.socketHadError=e,this.connected=!1,this.state=f,-1===this.closeReasonCode&&(this.closeReasonCode=v.CLOSE_REASON_ABNORMAL,this.closeDescription="Connection dropped by remote peer."),this.clearCloseTimer(),this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this.closeEventEmitted||(this.closeEventEmitted=!0,this._debug("-- Emitting WebSocketConnection close event"),this.emit("close",this.closeReasonCode,this.closeDescription))},v.prototype.handleSocketDrain=function(){this._debug("handleSocketDrain: socket drain event"),this.outputBufferFull=!1,this.emit("drain")},v.prototype.handleSocketPause=function(){this._debug("handleSocketPause: socket pause event"),this.inputPaused=!0,this.emit("pause")},v.prototype.handleSocketResume=function(){this._debug("handleSocketResume: socket resume event"),this.inputPaused=!1,this.emit("resume"),this.processReceivedData()},v.prototype.pause=function(){this._debug("pause: pause requested"),this.socket.pause()},v.prototype.resume=function(){this._debug("resume: resume requested"),this.socket.resume()},v.prototype.close=function(e,t){if(this.connected){if(this._debug("close: Initating clean WebSocket close sequence."),"number"!=typeof e&&(e=v.CLOSE_REASON_NORMAL),!_(e))throw new Error("Close code "+e+" is not valid.");"string"!=typeof t&&(t=v.CLOSE_DESCRIPTIONS[e]),this.closeReasonCode=e,this.closeDescription=t,this.setCloseTimer(),this.sendCloseFrame(this.closeReasonCode,this.closeDescription),this.state=d,this.connected=!1}},v.prototype.drop=function(e,t,r){this._debug("drop"),"number"!=typeof e&&(e=v.CLOSE_REASON_PROTOCOL_ERROR),"string"!=typeof t&&(t=v.CLOSE_DESCRIPTIONS[e]),this._debug("Forcefully dropping connection. skipCloseFrame: %s, code: %d, description: %s",r,e,t),this.closeReasonCode=e,this.closeDescription=t,this.frameQueue=[],this.fragmentationSize=0,r||this.sendCloseFrame(e,t),this.connected=!1,this.state=f,this.clearCloseTimer(),this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this.closeEventEmitted||(this.closeEventEmitted=!0,this._debug("Emitting WebSocketConnection close event"),this.emit("close",this.closeReasonCode,this.closeDescription)),this._debug("Drop: destroying socket"),this.socket.destroy()},v.prototype.setCloseTimer=function(){this._debug("setCloseTimer"),this.clearCloseTimer(),this._debug("Setting close timer"),this.waitingForCloseResponse=!0,this.closeTimer=setTimeout(this._closeTimerHandler,this.closeTimeout)},v.prototype.clearCloseTimer=function(){this._debug("clearCloseTimer"),this.closeTimer&&(this._debug("Clearing close timer"),clearTimeout(this.closeTimer),this.waitingForCloseResponse=!1,this.closeTimer=null)},v.prototype.handleCloseTimer=function(){this._debug("handleCloseTimer"),this.closeTimer=null,this.waitingForCloseResponse&&(this._debug("Close response not received from client. Forcing socket end."),this.waitingForCloseResponse=!1,this.state=f,this.socket.end())},v.prototype.processFrame=function(e){if(this._debug("processFrame"),this._debug(" -- frame: %s",e),0!==this.frameQueue.length&&e.opcode>0&&e.opcode<8)this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Illegal frame opcode 0x"+e.opcode.toString(16)+" received in middle of fragmented message.");else switch(e.opcode){case 2:this._debug("-- Binary Frame"),this.assembleFragments&&(e.fin?(this._debug("---- Emitting 'message' event"),this.emit("message",{type:"binary",binaryData:e.binaryPayload})):(this.frameQueue.push(e),this.fragmentationSize=e.length));break;case 1:if(this._debug("-- Text Frame"),this.assembleFragments)if(e.fin){if(!u(e.binaryPayload))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this._debug("---- Emitting 'message' event"),this.emit("message",{type:"utf8",utf8Data:e.binaryPayload.toString("utf8")})}else this.frameQueue.push(e),this.fragmentationSize=e.length;break;case 0:if(this._debug("-- Continuation Frame"),this.assembleFragments){if(0===this.frameQueue.length)return void this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected Continuation Frame");if(this.fragmentationSize+=e.length,this.fragmentationSize>this.maxReceivedMessageSize)return void this.drop(v.CLOSE_REASON_MESSAGE_TOO_BIG,"Maximum message size exceeded.");if(this.frameQueue.push(e),e.fin){var t=0,r=h(this.fragmentationSize),n=this.frameQueue[0].opcode;switch(this.frameQueue.forEach((function(e){e.binaryPayload.copy(r,t),t+=e.binaryPayload.length})),this.frameQueue=[],this.fragmentationSize=0,n){case 2:this.emit("message",{type:"binary",binaryData:r});break;case 1:if(!u(r))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.emit("message",{type:"utf8",utf8Data:r.toString("utf8")});break;default:return void this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected first opcode in fragmentation sequence: 0x"+n.toString(16))}}}break;case 9:if(this._debug("-- Ping Frame"),this._pingListenerCount>0){var s=!1;this.emit("ping",(function(){s=!0}),e.binaryPayload),s||this.pong(e.binaryPayload)}else this.pong(e.binaryPayload);break;case 10:this._debug("-- Pong Frame"),this.emit("pong",e.binaryPayload);break;case 8:if(this._debug("-- Close Frame"),this.waitingForCloseResponse)return this._debug("---- Got close response from peer. Completing closing handshake."),this.clearCloseTimer(),this.waitingForCloseResponse=!1,this.state=f,void this.socket.end();var i;if(this._debug("---- Closing handshake initiated by peer."),this.state=p,e.invalidCloseFrameLength?(this.closeReasonCode=1005,i=v.CLOSE_REASON_PROTOCOL_ERROR):-1===e.closeStatus||_(e.closeStatus)?(this.closeReasonCode=e.closeStatus,i=v.CLOSE_REASON_NORMAL):(this.closeReasonCode=e.closeStatus,i=v.CLOSE_REASON_PROTOCOL_ERROR),e.binaryPayload.length>1){if(!u(e.binaryPayload))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.closeDescription=e.binaryPayload.toString("utf8")}else this.closeDescription=v.CLOSE_DESCRIPTIONS[this.closeReasonCode];this._debug("------ Remote peer %s - code: %d - %s - close frame payload length: %d",this.remoteAddress,this.closeReasonCode,this.closeDescription,e.length),this._debug("------ responding to remote peer's close request."),this.sendCloseFrame(i,null),this.connected=!1;break;default:this._debug("-- Unrecognized Opcode %d",e.opcode),this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unrecognized Opcode: 0x"+e.opcode.toString(16))}},v.prototype.send=function(e,t){if(this._debug("send"),Buffer.isBuffer(e))this.sendBytes(e,t);else{if("function"!=typeof e.toString)throw new Error("Data provided must either be a Node Buffer or implement toString()");this.sendUTF(e,t)}},v.prototype.sendUTF=function(e,t){e=l(e.toString(),"utf8"),this._debug("sendUTF: %d bytes",e.length);var r=new o(this.maskBytes,this.frameHeader,this.config);r.opcode=1,r.binaryPayload=e,this.fragmentAndSend(r,t)},v.prototype.sendBytes=function(e,t){if(this._debug("sendBytes"),!Buffer.isBuffer(e))throw new Error("You must pass a Node Buffer object to WebSocketConnection.prototype.sendBytes()");var r=new o(this.maskBytes,this.frameHeader,this.config);r.opcode=2,r.binaryPayload=e,this.fragmentAndSend(r,t)},v.prototype.ping=function(e){this._debug("ping");var t=new o(this.maskBytes,this.frameHeader,this.config);t.opcode=9,t.fin=!0,e&&(Buffer.isBuffer(e)||(e=l(e.toString(),"utf8")),e.length>125&&(this._debug("WebSocket: Data for ping is longer than 125 bytes. Truncating."),e=e.slice(0,124)),t.binaryPayload=e),this.sendFrame(t)},v.prototype.pong=function(e){this._debug("pong");var t=new o(this.maskBytes,this.frameHeader,this.config);t.opcode=10,Buffer.isBuffer(e)&&e.length>125&&(this._debug("WebSocket: Data for pong is longer than 125 bytes. Truncating."),e=e.slice(0,124)),t.binaryPayload=e,t.fin=!0,this.sendFrame(t)},v.prototype.fragmentAndSend=function(e,t){if(this._debug("fragmentAndSend"),e.opcode>7)throw new Error("You cannot fragment control frames.");var r=this.config.fragmentationThreshold,n=e.binaryPayload.length;if(!this.config.fragmentOutgoingMessages||e.binaryPayload&&n<=r)return e.fin=!0,void this.sendFrame(e,t);for(var s=Math.ceil(n/r),i=0,a=function(e){e?"function"==typeof t&&(t(e),t=null):++i===s&&"function"==typeof t&&t()},u=1;u<=s;u++){var h=new o(this.maskBytes,this.frameHeader,this.config);h.opcode=1===u?e.opcode:0,h.fin=u===s;var l=u===s?n-r*(u-1):r,c=r*(u-1);h.binaryPayload=e.binaryPayload.slice(c,c+l),this.sendFrame(h,a)}},v.prototype.sendCloseFrame=function(e,t,r){if("number"!=typeof e&&(e=v.CLOSE_REASON_NORMAL),this._debug("sendCloseFrame state: %s, reasonCode: %d, description: %s",this.state,e,t),this.state===c||this.state===p){var n=new o(this.maskBytes,this.frameHeader,this.config);n.fin=!0,n.opcode=8,n.closeStatus=e,"string"==typeof t&&(n.binaryPayload=l(t,"utf8")),this.sendFrame(n,r),this.socket.end()}},v.prototype.sendFrame=function(e,t){this._debug("sendFrame"),e.mask=this.maskOutgoingPackets;var r=this.socket.write(e.toBuffer(),t);return this.outputBufferFull=!r,r},e.exports=v},587:(e,t,r)=>{var n=r(1675),s=r(3569).bufferAllocUnsafe;function i(e,t,r){this.maskBytes=e,this.frameHeader=t,this.config=r,this.maxReceivedFrameSize=r.maxReceivedFrameSize,this.protocolError=!1,this.frameTooLarge=!1,this.invalidCloseFrameLength=!1,this.parseState=1,this.closeStatus=-1}i.prototype.addData=function(e){if(1===this.parseState&&e.length>=2){e.joinInto(this.frameHeader,0,0,2),e.advance(2);var t=this.frameHeader[0],r=this.frameHeader[1];if(this.fin=Boolean(128&t),this.rsv1=Boolean(64&t),this.rsv2=Boolean(32&t),this.rsv3=Boolean(16&t),this.mask=Boolean(128&r),this.opcode=15&t,this.length=127&r,this.opcode>=8){if(this.length>125)return this.protocolError=!0,this.dropReason="Illegal control frame longer than 125 bytes.",!0;if(!this.fin)return this.protocolError=!0,this.dropReason="Control frames must not be fragmented.",!0}126===this.length?this.parseState=2:127===this.length?this.parseState=3:this.parseState=4}if(2===this.parseState)e.length>=2&&(e.joinInto(this.frameHeader,2,0,2),e.advance(2),this.length=this.frameHeader.readUInt16BE(2),this.parseState=4);else if(3===this.parseState&&e.length>=8){e.joinInto(this.frameHeader,2,0,8),e.advance(8);var i=[this.frameHeader.readUInt32BE(2),this.frameHeader.readUInt32BE(6)];if(0!==i[0])return this.protocolError=!0,this.dropReason="Unsupported 64-bit length frame received",!0;this.length=i[1],this.parseState=4}if(4===this.parseState&&(this.mask?e.length>=4&&(e.joinInto(this.maskBytes,0,0,4),e.advance(4),this.parseState=5):this.parseState=5),5===this.parseState){if(this.length>this.maxReceivedFrameSize)return this.frameTooLarge=!0,this.dropReason="Frame size of "+this.length.toString(10)+" bytes exceeds maximum accepted frame size",!0;if(0===this.length)return this.binaryPayload=s(0),this.parseState=6,!0;if(e.length>=this.length)return this.binaryPayload=e.take(this.length),e.advance(this.length),this.mask&&n.unmask(this.binaryPayload,this.maskBytes),8===this.opcode&&(1===this.length&&(this.binaryPayload=s(0),this.invalidCloseFrameLength=!0),this.length>=2&&(this.closeStatus=this.binaryPayload.readUInt16BE(0),this.binaryPayload=this.binaryPayload.slice(2))),this.parseState=6,!0}return!1},i.prototype.throwAwayPayload=function(e){return e.length>=this.length&&(e.advance(this.length),this.parseState=6,!0)},i.prototype.toBuffer=function(e){var t,r,i,o=2,a=0,u=0;this.fin&&(a|=128),this.rsv1&&(a|=64),this.rsv2&&(a|=32),this.rsv3&&(a|=16),this.mask&&(u|=128),a|=15&this.opcode,8===this.opcode?(this.length=2,this.binaryPayload&&(this.length+=this.binaryPayload.length),(r=s(this.length)).writeUInt16BE(this.closeStatus,0),this.length>2&&this.binaryPayload.copy(r,2)):this.binaryPayload?(r=this.binaryPayload,this.length=r.length):this.length=0,this.length<=125?u|=127&this.length:this.length>125&&this.length<=65535?(u|=126,o+=2):this.length>65535&&(u|=127,o+=8);var h=s(this.length+o+(this.mask?4:0));return h[0]=a,h[1]=u,i=2,this.length>125&&this.length<=65535?(h.writeUInt16BE(this.length,i),i+=2):this.length>65535&&(h.writeUInt32BE(0,i),h.writeUInt32BE(this.length,i+4),i+=8),this.mask?(t=e?0:4294967295*Math.random()>>>0,this.maskBytes.writeUInt32BE(t,0),this.maskBytes.copy(h,i),i+=4,r&&n.mask(r,this.maskBytes,h,i,this.length)):r&&r.copy(h,i),h},i.prototype.toString=function(){return"Opcode: "+this.opcode+", fin: "+this.fin+", length: "+this.length+", hasPayload: "+Boolean(this.binaryPayload)+", masked: "+this.mask},e.exports=i},5286:(e,t,r)=>{for(var n=r(6113),s=r(3837),i=r(7310),o=r(2361).EventEmitter,a=r(8918),u=/,\s*/,h=/;\s*/,l=/[\r\n]/g,c=/,\s*/,p=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],d=[String.fromCharCode(127)],f=0;f<31;f++)d.push(String.fromCharCode(f));var g=/([\x00-\x20\x22\x28\x29\x2c\x2f\x3a-\x3f\x40\x5b-\x5e\x7b\x7d\x7f])/,m=/[^\x21\x23-\x2b\x2d-\x3a\x3c-\x5b\x5d-\x7e]/,v=/^"[^"]*"$/,_=/[\x00-\x20\x3b]/g,y=/[;,] */,w={100:"Continue",101:"Switching Protocols",200:"OK",201:"Created",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",406:"Not Acceptable",407:"Proxy Authorization Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Long",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",426:"Upgrade Required",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported"};function b(e,t,r){o.call(this),this.socket=e,this.httpRequest=t,this.resource=t.url,this.remoteAddress=e.remoteAddress,this.remoteAddresses=[this.remoteAddress],this.serverConfig=r,this._socketIsClosing=!1,this._socketCloseHandler=this._handleSocketCloseBeforeAccept.bind(this),this.socket.on("end",this._socketCloseHandler),this.socket.on("close",this._socketCloseHandler),this._resolved=!1}function O(e){process.nextTick((function(){e.drop(1006,"TCP connection lost before handshake completed.",!0)}))}s.inherits(b,o),b.prototype.readHandshake=function(){var e=this,t=this.httpRequest;if(this.resourceURL=i.parse(this.resource,!0),this.host=t.headers.host,!this.host)throw new Error("Client must provide a Host header.");if(this.key=t.headers["sec-websocket-key"],!this.key)throw new Error("Client must provide a value for Sec-WebSocket-Key.");if(this.webSocketVersion=parseInt(t.headers["sec-websocket-version"],10),!this.webSocketVersion||isNaN(this.webSocketVersion))throw new Error("Client must provide a value for Sec-WebSocket-Version.");switch(this.webSocketVersion){case 8:case 13:break;default:var r=new Error("Unsupported websocket client version: "+this.webSocketVersion+"Only versions 8 and 13 are supported.");throw r.httpCode=426,r.headers={"Sec-WebSocket-Version":"13"},r}13===this.webSocketVersion?this.origin=t.headers.origin:8===this.webSocketVersion&&(this.origin=t.headers["sec-websocket-origin"]);var n=t.headers["sec-websocket-protocol"];(this.protocolFullCaseMap={},this.requestedProtocols=[],n)&&n.split(u).forEach((function(t){var r=t.toLocaleLowerCase();e.requestedProtocols.push(r),e.protocolFullCaseMap[r]=t}));if(!this.serverConfig.ignoreXForwardedFor&&t.headers["x-forwarded-for"]){var s=this.remoteAddress;this.remoteAddresses=t.headers["x-forwarded-for"].split(c),this.remoteAddresses.push(s),this.remoteAddress=this.remoteAddresses[0]}if(this.serverConfig.parseExtensions){var o=t.headers["sec-websocket-extensions"];this.requestedExtensions=this.parseExtensions(o)}else this.requestedExtensions=[];if(this.serverConfig.parseCookies){var a=t.headers.cookie;this.cookies=this.parseCookies(a)}else this.cookies=[]},b.prototype.parseExtensions=function(e){if(!e||0===e.length)return[];var t=e.toLocaleLowerCase().split(u);return t.forEach((function(e,t,r){var n=e.split(h),s=n[0],i=n.slice(1);i.forEach((function(e,t,r){var n=e.split("="),s={name:n[0],value:n[1]};r.splice(t,1,s)}));var o={name:s,params:i};r.splice(t,1,o)})),t},b.prototype.parseCookies=function(e){if(!e||"string"!=typeof e)return[];var t=[];return e.split(y).forEach((function(e){var r=e.indexOf("=");if(-1!==r){var n=e.substr(0,r).trim(),s=e.substr(++r,e.length).trim();'"'===s[0]&&(s=s.slice(1,-1)),t.push({name:n,value:decodeURIComponent(s)})}else t.push({name:e,value:null})})),t},b.prototype.accept=function(e,t,r){var s;this._verifyResolution(),e?void 0===(s=this.protocolFullCaseMap[e.toLocaleLowerCase()])&&(s=e):s=e,this.protocolFullCaseMap=null;var i=n.createHash("sha1");i.update(this.key+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var o="HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "+i.digest("base64")+"\r\n";if(s){for(var u=0;u<s.length;u++){var h=s.charCodeAt(u),c=s.charAt(u);if(h<33||h>126||-1!==p.indexOf(c))throw this.reject(500),new Error('Illegal character "'+String.fromCharCode(c)+'" in subprotocol.')}if(-1===this.requestedProtocols.indexOf(e))throw this.reject(500),new Error("Specified protocol was not requested by the client.");s=s.replace(l,""),o+="Sec-WebSocket-Protocol: "+s+"\r\n"}if(this.requestedProtocols=null,t&&(t=t.replace(l,""),13===this.webSocketVersion?o+="Origin: "+t+"\r\n":8===this.webSocketVersion&&(o+="Sec-WebSocket-Origin: "+t+"\r\n")),r){if(!Array.isArray(r))throw this.reject(500),new Error('Value supplied for "cookies" argument must be an array.');var d={};r.forEach(function(e){if(!e.name||!e.value)throw this.reject(500),new Error('Each cookie to set must at least provide a "name" and "value"');if(e.name=e.name.replace(_,""),e.value=e.value.replace(_,""),d[e.name])throw this.reject(500),new Error("You may not specify the same cookie name twice.");d[e.name]=!0;var t=e.name.match(g);if(t)throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie name");if(t=e.value.match(v)?e.value.slice(1,-1).match(m):e.value.match(m))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie value");var r=[e.name+"="+e.value];if(e.path){if(t=e.path.match(_))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie path");r.push("Path="+e.path)}if(e.domain){if("string"!=typeof e.domain)throw this.reject(500),new Error("Domain must be specified and must be a string.");if(t=e.domain.match(_))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie domain");r.push("Domain="+e.domain.toLowerCase())}if(e.expires){if(!(e.expires instanceof Date))throw this.reject(500),new Error('Value supplied for cookie "expires" must be a vaild date object');r.push("Expires="+e.expires.toGMTString())}if(e.maxage){var n=e.maxage;if("string"==typeof n&&(n=parseInt(n,10)),isNaN(n)||n<=0)throw this.reject(500),new Error('Value supplied for cookie "maxage" must be a non-zero number');n=Math.round(n),r.push("Max-Age="+n.toString(10))}if(e.secure){if("boolean"!=typeof e.secure)throw this.reject(500),new Error('Value supplied for cookie "secure" must be of type boolean');r.push("Secure")}if(e.httponly){if("boolean"!=typeof e.httponly)throw this.reject(500),new Error('Value supplied for cookie "httponly" must be of type boolean');r.push("HttpOnly")}o+="Set-Cookie: "+r.join(";")+"\r\n"}.bind(this))}this._resolved=!0,this.emit("requestResolved",this),o+="\r\n";var f=new a(this.socket,[],e,!1,this.serverConfig);f.webSocketVersion=this.webSocketVersion,f.remoteAddress=this.remoteAddress,f.remoteAddresses=this.remoteAddresses;var y=this;return this._socketIsClosing?O(f):this.socket.write(o,"ascii",(function(e){e?O(f):(y._removeSocketCloseListeners(),f._addSocketEventListeners())})),this.emit("requestAccepted",f),f},b.prototype.reject=function(e,t,r){this._verifyResolution(),this._resolved=!0,this.emit("requestResolved",this),"number"!=typeof e&&(e=403);var n="HTTP/1.1 "+e+" "+w[e]+"\r\nConnection: close\r\n";if(t&&(n+="X-WebSocket-Reject-Reason: "+(t=t.replace(l,""))+"\r\n"),r)for(var s in r){var i=r[s].toString().replace(l,"");n+=s.replace(l,"")+": "+i+"\r\n"}n+="\r\n",this.socket.end(n,"ascii"),this.emit("requestRejected",this)},b.prototype._handleSocketCloseBeforeAccept=function(){this._socketIsClosing=!0,this._removeSocketCloseListeners()},b.prototype._removeSocketCloseListeners=function(){this.socket.removeListener("end",this._socketCloseHandler),this.socket.removeListener("close",this._socketCloseHandler)},b.prototype._verifyResolution=function(){if(this._resolved)throw new Error("WebSocketRequest may only be accepted or rejected one time.")},e.exports=b},7780:(e,t,r)=>{var n=r(3569).extend,s=r(3837),i=r(2361).EventEmitter,o=r(5875);function a(e){i.call(this),this.config={server:null},e&&n(this.config,e),this.handlers=[],this._requestHandler=this.handleRequest.bind(this),this.config.server&&this.attachServer(this.config.server)}s.inherits(a,i),a.prototype.attachServer=function(e){if(!e)throw new Error("You must specify a WebSocketServer instance to attach to.");this.server=e,this.server.on("request",this._requestHandler)},a.prototype.detachServer=function(){if(!this.server)throw new Error("Cannot detach from server: not attached.");this.server.removeListener("request",this._requestHandler),this.server=null},a.prototype.mount=function(e,t,r){if(!e)throw new Error("You must specify a path for this handler.");if(t||(t="____no_protocol____"),!r)throw new Error("You must specify a callback for this handler.");if(!((e=this.pathToRegExp(e))instanceof RegExp))throw new Error("Path must be specified as either a string or a RegExp.");var n=e.toString();if(t=t.toLocaleLowerCase(),-1!==this.findHandlerIndex(n,t))throw new Error("You may only mount one handler per path/protocol combination.");this.handlers.push({path:e,pathString:n,protocol:t,callback:r})},a.prototype.unmount=function(e,t){var r=this.findHandlerIndex(this.pathToRegExp(e).toString(),t);if(-1===r)throw new Error("Unable to find a route matching the specified path and protocol.");this.handlers.splice(r,1)},a.prototype.findHandlerIndex=function(e,t){t=t.toLocaleLowerCase();for(var r=0,n=this.handlers.length;r<n;r++){var s=this.handlers[r];if(s.pathString===e&&s.protocol===t)return r}return-1},a.prototype.pathToRegExp=function(e){return"string"==typeof e&&("*"===e?e=/^.*$/:(e=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),e=new RegExp("^"+e+"$"))),e},a.prototype.handleRequest=function(e){var t=e.requestedProtocols;0===t.length&&(t=["____no_protocol____"]);for(var r=0;r<t.length;r++)for(var n=t[r].toLocaleLowerCase(),s=0,i=this.handlers.length;s<i;s++){var a=this.handlers[s];if(a.path.test(e.resourceURL.pathname)&&(n===a.protocol||"*"===a.protocol)){var u=new o(e,n);return void a.callback(u)}}e.reject(404,"No handler is available for the given request.")},e.exports=a},5875:(e,t,r)=>{var n=r(3837),s=r(2361).EventEmitter;function i(e,t){s.call(this),this.webSocketRequest=e,this.protocol="____no_protocol____"===t?null:t,this.origin=e.origin,this.resource=e.resource,this.resourceURL=e.resourceURL,this.httpRequest=e.httpRequest,this.remoteAddress=e.remoteAddress,this.webSocketVersion=e.webSocketVersion,this.requestedExtensions=e.requestedExtensions,this.cookies=e.cookies}n.inherits(i,s),i.prototype.accept=function(e,t){var r=this.webSocketRequest.accept(this.protocol,e,t);return this.emit("requestAccepted",r),r},i.prototype.reject=function(e,t,r){this.webSocketRequest.reject(e,t,r),this.emit("requestRejected",this)},e.exports=i},6074:(e,t,r)=>{var n=r(3569).extend,s=r(3569),i=r(3837),o=r(67)("websocket:server"),a=r(2361).EventEmitter,u=r(5286),h=function(e){a.call(this),this._handlers={upgrade:this.handleUpgrade.bind(this),requestAccepted:this.handleRequestAccepted.bind(this),requestResolved:this.handleRequestResolved.bind(this)},this.connections=[],this.pendingRequests=[],e&&this.mount(e)};i.inherits(h,a),h.prototype.mount=function(e){if(this.config={httpServer:null,maxReceivedFrameSize:65536,maxReceivedMessageSize:1048576,fragmentOutgoingMessages:!0,fragmentationThreshold:16384,keepalive:!0,keepaliveInterval:2e4,dropConnectionOnKeepaliveTimeout:!0,keepaliveGracePeriod:1e4,useNativeKeepalive:!1,assembleFragments:!0,autoAcceptConnections:!1,ignoreXForwardedFor:!1,parseCookies:!0,parseExtensions:!0,disableNagleAlgorithm:!0,closeTimeout:5e3},n(this.config,e),!this.config.httpServer)throw new Error("You must specify an httpServer on which to mount the WebSocket server.");Array.isArray(this.config.httpServer)||(this.config.httpServer=[this.config.httpServer]);var t=this._handlers.upgrade;this.config.httpServer.forEach((function(e){e.on("upgrade",t)}))},h.prototype.unmount=function(){var e=this._handlers.upgrade;this.config.httpServer.forEach((function(t){t.removeListener("upgrade",e)}))},h.prototype.closeAllConnections=function(){this.connections.forEach((function(e){e.close()})),this.pendingRequests.forEach((function(e){process.nextTick((function(){e.reject(503)}))}))},h.prototype.broadcast=function(e){Buffer.isBuffer(e)?this.broadcastBytes(e):"function"==typeof e.toString&&this.broadcastUTF(e)},h.prototype.broadcastUTF=function(e){this.connections.forEach((function(t){t.sendUTF(e)}))},h.prototype.broadcastBytes=function(e){this.connections.forEach((function(t){t.sendBytes(e)}))},h.prototype.shutDown=function(){this.unmount(),this.closeAllConnections()},h.prototype.handleUpgrade=function(e,t){var r=this,n=new u(t,e,this.config);try{n.readHandshake()}catch(e){return n.reject(e.httpCode?e.httpCode:400,e.message,e.headers),o("Invalid handshake: %s",e.message),void this.emit("upgradeError",e)}this.pendingRequests.push(n),n.once("requestAccepted",this._handlers.requestAccepted),n.once("requestResolved",this._handlers.requestResolved),t.once("close",(function(){r._handlers.requestResolved(n)})),!this.config.autoAcceptConnections&&s.eventEmitterListenerCount(this,"request")>0?this.emit("request",n):this.config.autoAcceptConnections?n.accept(n.requestedProtocols[0],n.origin):n.reject(404,"No handler is configured to accept the connection.")},h.prototype.handleRequestAccepted=function(e){var t=this;e.once("close",(function(r,n){t.handleConnectionClose(e,r,n)})),this.connections.push(e),this.emit("connect",e)},h.prototype.handleConnectionClose=function(e,t,r){var n=this.connections.indexOf(e);-1!==n&&this.connections.splice(n,1),this.emit("close",e,t,r)},h.prototype.handleRequestResolved=function(e){var t=this.pendingRequests.indexOf(e);-1!==t&&this.pendingRequests.splice(t,1)},e.exports=h},3569:(e,t,r)=>{var n=t.noop=function(){};function s(e,t,r){this.logFunction=r,this.identifier=e,this.uniqueID=t,this.buffer=[]}t.extend=function(e,t){for(var r in t)e[r]=t[r]},t.eventEmitterListenerCount=r(2361).EventEmitter.listenerCount||function(e,t){return e.listeners(t).length},t.bufferAllocUnsafe=Buffer.allocUnsafe?Buffer.allocUnsafe:function(e){return new Buffer(e)},t.bufferFromString=Buffer.from?Buffer.from:function(e,t){return new Buffer(e,t)},t.BufferingLogger=function(e,t){var i=r(67)(e);if(i.enabled){var o=new s(e,t,i),a=o.log.bind(o);return a.printOutput=o.printOutput.bind(o),a.enabled=i.enabled,a}return i.printOutput=n,i},s.prototype.log=function(){return this.buffer.push([new Date,Array.prototype.slice.call(arguments)]),this},s.prototype.clear=function(){return this.buffer=[],this},s.prototype.printOutput=function(e){e||(e=this.logFunction);var t=this.uniqueID;this.buffer.forEach((function(r){var n=r[0].toLocaleString(),s=r[1].slice(),i=s[0];null!=i&&(i="%s - %s - "+i.toString(),s.splice(0,1,i,n,t),e.apply(global,s))}))}},3108:(e,t,r)=>{e.exports=r(873).version},2426:(e,t,r)=>{e.exports={server:r(6074),client:r(1109),router:r(7780),frame:r(587),request:r(5286),connection:r(8918),w3cwebsocket:r(7521),deprecation:r(8478),version:r(3108)}},9238:(e,t,r)=>{function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=r(811)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var s=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(s++,"%c"===e&&(i=s))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())},811:(e,t,r)=>{var n;function s(e){function r(){if(r.enabled){var e=r,s=+new Date,i=s-(n||s);e.diff=i,e.prev=n,e.curr=s,n=s;for(var o=new Array(arguments.length),a=0;a<o.length;a++)o[a]=arguments[a];o[0]=t.coerce(o[0]),"string"!=typeof o[0]&&o.unshift("%O");var u=0;o[0]=o[0].replace(/%([a-zA-Z%])/g,(function(r,n){if("%%"===r)return r;u++;var s=t.formatters[n];if("function"==typeof s){var i=o[u];r=s.call(e,i),o.splice(u,1),u--}return r})),t.formatArgs.call(e,o);var h=r.log||t.log||console.log.bind(console);h.apply(e,o)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),"function"==typeof t.init&&t.init(r),r}(t=e.exports=s.debug=s.default=s).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){t.save(e),t.names=[],t.skips=[];for(var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length,s=0;s<n;s++)r[s]&&("-"===(e=r[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(4328),t.names=[],t.skips=[],t.formatters={}},67:(e,t,r)=>{"undefined"!=typeof process&&"renderer"===process.type?e.exports=r(9238):e.exports=r(2959)},2959:(e,t,r)=>{var n=r(6224),s=r(3837);(t=e.exports=r(811)).init=function(e){e.inspectOpts={};for(var r=Object.keys(t.inspectOpts),n=0;n<r.length;n++)e.inspectOpts[r[n]]=t.inspectOpts[r[n]]},t.log=function(){return o.write(s.format.apply(s,arguments)+"\n")},t.formatArgs=function(e){var r=this.namespace;if(this.useColors){var n=this.color,s=" [3"+n+";1m"+r+" [0m";e[0]=s+e[0].split("\n").join("\n"+s),e.push("[3"+n+"m+"+t.humanize(this.diff)+"[0m")}else e[0]=(new Date).toUTCString()+" "+r+" "+e[0]},t.save=function(e){null==e?delete process.env.DEBUG:process.env.DEBUG=e},t.load=a,t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(i)},t.colors=[6,2,3,4,5,1],t.inspectOpts=Object.keys(process.env).filter((function(e){return/^debug_/i.test(e)})).reduce((function(e,t){var r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(function(e,t){return t.toUpperCase()})),n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e}),{});var i=parseInt(process.env.DEBUG_FD,10)||2;1!==i&&2!==i&&s.deprecate((function(){}),"except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)")();var o=1===i?process.stdout:2===i?process.stderr:function(e){var t;switch(process.binding("tty_wrap").guessHandleType(e)){case"TTY":(t=new n.WriteStream(e))._type="tty",t._handle&&t._handle.unref&&t._handle.unref();break;case"FILE":var s=r(7147);(t=new s.SyncWriteStream(e,{autoClose:!1}))._type="fs";break;case"PIPE":case"TCP":var i=r(1808);(t=new i.Socket({fd:e,readable:!1,writable:!0})).readable=!1,t.read=null,t._type="pipe",t._handle&&t._handle.unref&&t._handle.unref();break;default:throw new Error("Implement me. Unknown stream file type!")}return t.fd=e,t._isStdio=!0,t}(i);function a(){return process.env.DEBUG}t.formatters.o=function(e){return this.inspectOpts.colors=this.useColors,s.inspect(e,this.inspectOpts).split("\n").map((function(e){return e.trim()})).join(" ")},t.formatters.O=function(e){return this.inspectOpts.colors=this.useColors,s.inspect(e,this.inspectOpts)},t.enable(a())},4328:e=>{var t=1e3,r=60*t,n=60*r,s=24*n,i=365.25*s;function o(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}e.exports=function(e,a){a=a||{};var u,h=typeof e;if("string"===h&&e.length>0)return function(e){if((e=String(e)).length>100)return;var o=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!o)return;var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*i;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*n;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===h&&!1===isNaN(e))return a.long?o(u=e,s,"day")||o(u,n,"hour")||o(u,r,"minute")||o(u,t,"second")||u+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=n)return Math.round(e/n)+"h";if(e>=r)return Math.round(e/r)+"m";if(e>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4218:(e,t,r)=>{var n=r(4300).Buffer,s=r(2361).EventEmitter,i=r(3569).bufferAllocUnsafe;function o(e){if(!(this instanceof o))return new o(e);s.call(this);var t=this;void 0===e&&(e={}),t.encoding=e.encoding;var r={next:null,buffer:null},a={next:null,buffer:null},u=0;t.__defineGetter__("length",(function(){return u}));var h=0;t.write=function(e){return r.buffer?(a.next={next:null,buffer:e},a=a.next):(r.buffer=e,a=r),u+=e.length,t.emit("write",e),!0},t.end=function(e){n.isBuffer(e)&&t.write(e)},t.push=function(){var e=[].concat.apply([],arguments);return e.forEach(t.write),t},t.forEach=function(e){if(!r.buffer)return i(0);if(r.buffer.length-h<=0)return t;for(var n={buffer:r.buffer.slice(h),next:r.next};n&&n.buffer;){if(e(n.buffer))break;n=n.next}return t},t.join=function(e,n){if(!r.buffer)return i(0);null==e&&(e=0),null==n&&(n=t.length);var s=i(n-e),o=0;return t.forEach((function(t){if(e<o+t.length&&o<n&&t.copy(s,Math.max(0,o-e),Math.max(0,e-o),Math.min(t.length,n-o)),(o+=t.length)>n)return!0})),s},t.joinInto=function(e,n,s,o){if(!r.buffer)return new i(0);null==s&&(s=0),null==o&&(o=t.length);var a=e;if(a.length-n<o-s)throw new Error("Insufficient space available in target Buffer.");var u=0;return t.forEach((function(e){if(s<u+e.length&&u<o&&e.copy(a,Math.max(n,n+u-s),Math.max(0,s-u),Math.min(e.length,o-u)),(u+=e.length)>o)return!0})),a},t.advance=function(e){for(h+=e,u-=e;r.buffer&&h>=r.buffer.length;)h-=r.buffer.length,r=r.next?r.next:{buffer:null,next:null};return null===r.buffer&&(a={next:null,buffer:null}),t.emit("advance",e),t},t.take=function(e,r){null==e?e=t.length:"number"!=typeof e&&(r=e,e=t.length);if(r||(r=t.encoding),r){var n="";return t.forEach((function(t){if(e<=0)return!0;n+=t.toString(r,0,Math.min(e,t.length)),e-=t.length})),n}return t.join(0,e)},t.toString=function(){return t.take("binary")}}e.exports=o,e.exports.BufferList=o,r(3837).inherits(o,s)},7829:(e,t,r)=>{function n(e){this.options=e||{locator:{}}}function s(){this.cdata=!1}function i(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function o(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function a(e,t,r){return"string"==typeof e?e.substr(t,r):e.length>=t+r||t?new java.lang.String(e,t,r)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}n.prototype.parseFromString=function(e,t){var r=this.options,n=new c,i=r.domBuilder||new s,a=r.errorHandler,u=r.locator,l=r.xmlns||{},p=/\/x?html?$/.test(t),d=p?h.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return u&&i.setDocumentLocator(u),n.errorHandler=function(e,t,r){if(!e){if(t instanceof s)return t;e=t}var n={},i=e instanceof Function;function a(t){var s=e[t];!s&&i&&(s=2==e.length?function(r){e(t,r)}:e),n[t]=s&&function(e){s("[xmldom "+t+"]\t"+e+o(r))}||function(){}}return r=r||{},a("warning"),a("error"),a("fatalError"),n}(a,i,u),n.domBuilder=r.domBuilder||i,p&&(l[""]="http://www.w3.org/1999/xhtml"),l.xml=l.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?n.parse(e,l,d):n.errorHandler.error("invalid doc source"),i.doc},s.prototype={startDocument:function(){this.doc=(new d).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,r,n){var s=this.doc,o=s.createElementNS(e,r||t),a=n.length;u(this,o),this.currentElement=o,this.locator&&i(this.locator,o);for(var h=0;h<a;h++){e=n.getURI(h);var l=n.getValue(h),c=(r=n.getQName(h),s.createAttributeNS(e,r));this.locator&&i(n.getLocator(h),c),c.value=c.nodeValue=l,o.setAttributeNode(c)}},endElement:function(e,t,r){var n=this.currentElement;n.tagName;this.currentElement=n.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var r=this.doc.createProcessingInstruction(e,t);this.locator&&i(this.locator,r),u(this,r)},ignorableWhitespace:function(e,t,r){},characters:function(e,t,r){if(e=a.apply(this,arguments)){if(this.cdata)var n=this.doc.createCDATASection(e);else n=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(e)&&this.doc.appendChild(n),this.locator&&i(this.locator,n)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,r){e=a.apply(this,arguments);var n=this.doc.createComment(e);this.locator&&i(this.locator,n),u(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,r){var n=this.doc.implementation;if(n&&n.createDocumentType){var s=n.createDocumentType(e,t,r);this.locator&&i(this.locator,s),u(this,s)}},warning:function(e){console.warn("[xmldom warning]\t"+e,o(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,o(this.locator))},fatalError:function(e){throw new p(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,(function(e){s.prototype[e]=function(){return null}}));var h=r(8604),l=r(1132),c=l.XMLReader,p=l.ParseError,d=t.DOMImplementation=r(1695).DOMImplementation;t.XMLSerializer=r(1695).XMLSerializer,t.DOMParser=n,t.__DOMHandler=s},1695:(e,t)=>{function r(e,t){for(var r in e)t[r]=e[r]}function n(e,t){var n=e.prototype;if(!(n instanceof t)){function s(){}s.prototype=t.prototype,r(n,s=new s),e.prototype=n=s}n.constructor!=e&&("function"!=typeof e&&console.error("unknow Class:"+e),n.constructor=e)}var s={},i=s.ELEMENT_NODE=1,o=s.ATTRIBUTE_NODE=2,a=s.TEXT_NODE=3,u=s.CDATA_SECTION_NODE=4,h=s.ENTITY_REFERENCE_NODE=5,l=s.ENTITY_NODE=6,c=s.PROCESSING_INSTRUCTION_NODE=7,p=s.COMMENT_NODE=8,d=s.DOCUMENT_NODE=9,f=s.DOCUMENT_TYPE_NODE=10,g=s.DOCUMENT_FRAGMENT_NODE=11,m=s.NOTATION_NODE=12,v={},_={},y=(v.INDEX_SIZE_ERR=(_[1]="Index size error",1),v.DOMSTRING_SIZE_ERR=(_[2]="DOMString size error",2),v.HIERARCHY_REQUEST_ERR=(_[3]="Hierarchy request error",3)),w=(v.WRONG_DOCUMENT_ERR=(_[4]="Wrong document",4),v.INVALID_CHARACTER_ERR=(_[5]="Invalid character",5),v.NO_DATA_ALLOWED_ERR=(_[6]="No data allowed",6),v.NO_MODIFICATION_ALLOWED_ERR=(_[7]="No modification allowed",7),v.NOT_FOUND_ERR=(_[8]="Not found",8)),b=(v.NOT_SUPPORTED_ERR=(_[9]="Not supported",9),v.INUSE_ATTRIBUTE_ERR=(_[10]="Attribute in use",10));v.INVALID_STATE_ERR=(_[11]="Invalid state",11),v.SYNTAX_ERR=(_[12]="Syntax error",12),v.INVALID_MODIFICATION_ERR=(_[13]="Invalid modification",13),v.NAMESPACE_ERR=(_[14]="Invalid namespace",14),v.INVALID_ACCESS_ERR=(_[15]="Invalid access",15);function O(e,t){if(t instanceof Error)var r=t;else r=this,Error.call(this,_[e]),this.message=_[e],Error.captureStackTrace&&Error.captureStackTrace(this,O);return r.code=e,t&&(this.message=this.message+": "+t),r}function E(){}function N(e,t){this._node=e,this._refresh=t,S(this)}function S(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);ne(e,"length",n.length),r(n,e),e._inc=t}}function x(){}function A(e,t){for(var r=e.length;r--;)if(e[r]===t)return r}function T(e,t,r,n){if(n?t[A(t,n)]=r:t[t.length++]=r,e){r.ownerElement=e;var s=e.ownerDocument;s&&(n&&L(s,e,n),function(e,t,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==r.namespaceURI&&(t._nsMap[r.prefix?r.localName:""]=r.value)}(s,e,r))}}function C(e,t,r){var n=A(t,r);if(!(n>=0))throw O(w,new Error(e.tagName+"@"+r));for(var s=t.length-1;n<s;)t[n]=t[++n];if(t.length=s,e){var i=e.ownerDocument;i&&(L(i,e,r),r.ownerElement=null)}}function R(e){if(this._features={},e)for(var t in e)this._features=e[t]}function P(){}function k(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function D(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(D(e,t))return!0}while(e=e.nextSibling)}function I(){}function L(e,t,r,n){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==r.namespaceURI&&delete t._nsMap[r.prefix?r.localName:""]}function F(e,t,r){if(e&&e._inc){e._inc++;var n=t.childNodes;if(r)n[n.length++]=r;else{for(var s=t.firstChild,i=0;s;)n[i++]=s,s=s.nextSibling;n.length=i}}}function j(e,t){var r=t.previousSibling,n=t.nextSibling;return r?r.nextSibling=n:e.firstChild=n,n?n.previousSibling=r:e.lastChild=r,F(e.ownerDocument,e),t}function U(e,t,r){var n=t.parentNode;if(n&&n.removeChild(t),t.nodeType===g){var s=t.firstChild;if(null==s)return t;var i=t.lastChild}else s=i=t;var o=r?r.previousSibling:e.lastChild;s.previousSibling=o,i.nextSibling=r,o?o.nextSibling=s:e.firstChild=s,null==r?e.lastChild=i:r.previousSibling=i;do{s.parentNode=e}while(s!==i&&(s=s.nextSibling));return F(e.ownerDocument||e,e),t.nodeType==g&&(t.firstChild=t.lastChild=null),t}function B(){this._nsMap={}}function q(){}function M(){}function H(){}function V(){}function W(){}function G(){}function z(){}function X(){}function K(){}function Y(){}function J(){}function Q(){}function $(e,t){var r=[],n=9==this.nodeType&&this.documentElement||this,s=n.prefix,i=n.namespaceURI;if(i&&null==s&&null==(s=n.lookupPrefix(i)))var o=[{namespace:i,prefix:null}];return ee(this,r,e,t,o),r.join("")}function Z(e,t,r){var n=e.prefix||"",s=e.namespaceURI;if(!n&&!s)return!1;if("xml"===n&&"http://www.w3.org/XML/1998/namespace"===s||"http://www.w3.org/2000/xmlns/"==s)return!1;for(var i=r.length;i--;){var o=r[i];if(o.prefix==n)return o.namespace!=s}return!0}function ee(e,t,r,n,s){if(n){if(!(e=n(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case i:s||(s=[]);s.length;var l=e.attributes,m=l.length,v=e.firstChild,_=e.tagName;r="http://www.w3.org/1999/xhtml"===e.namespaceURI||r,t.push("<",_);for(var y=0;y<m;y++){"xmlns"==(w=l.item(y)).prefix?s.push({prefix:w.localName,namespace:w.value}):"xmlns"==w.nodeName&&s.push({prefix:"",namespace:w.value})}for(y=0;y<m;y++){var w;if(Z(w=l.item(y),0,s)){var b=w.prefix||"",O=w.namespaceURI,E=b?" xmlns:"+b:" xmlns";t.push(E,'="',O,'"'),s.push({prefix:b,namespace:O})}ee(w,t,r,n,s)}if(Z(e,0,s)){b=e.prefix||"";if(O=e.namespaceURI){E=b?" xmlns:"+b:" xmlns";t.push(E,'="',O,'"'),s.push({prefix:b,namespace:O})}}if(v||r&&!/^(?:meta|link|img|br|hr|input)$/i.test(_)){if(t.push(">"),r&&/^script$/i.test(_))for(;v;)v.data?t.push(v.data):ee(v,t,r,n,s),v=v.nextSibling;else for(;v;)ee(v,t,r,n,s),v=v.nextSibling;t.push("</",_,">")}else t.push("/>");return;case d:case g:for(v=e.firstChild;v;)ee(v,t,r,n,s),v=v.nextSibling;return;case o:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,k),'"');case a:return t.push(e.data.replace(/[<&]/g,k).replace(/]]>/g,"]]>"));case u:return t.push("<![CDATA[",e.data,"]]>");case p:return t.push("\x3c!--",e.data,"--\x3e");case f:var N=e.publicId,S=e.systemId;if(t.push("<!DOCTYPE ",e.name),N)t.push(" PUBLIC ",N),S&&"."!=S&&t.push(" ",S),t.push(">");else if(S&&"."!=S)t.push(" SYSTEM ",S,">");else{var x=e.internalSubset;x&&t.push(" [",x,"]"),t.push(">")}return;case c:return t.push("<?",e.target," ",e.data,"?>");case h:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,r){var n;switch(t.nodeType){case i:(n=t.cloneNode(!1)).ownerDocument=e;case g:break;case o:r=!0}if(n||(n=t.cloneNode(!1)),n.ownerDocument=e,n.parentNode=null,r)for(var s=t.firstChild;s;)n.appendChild(te(e,s,r)),s=s.nextSibling;return n}function re(e,t,r){var n=new t.constructor;for(var s in t){var a=t[s];"object"!=typeof a&&a!=n[s]&&(n[s]=a)}switch(t.childNodes&&(n.childNodes=new E),n.ownerDocument=e,n.nodeType){case i:var u=t.attributes,h=n.attributes=new x,l=u.length;h._ownerElement=n;for(var c=0;c<l;c++)n.setAttributeNode(re(e,u.item(c),!0));break;case o:r=!0}if(r)for(var p=t.firstChild;p;)n.appendChild(re(e,p,r)),p=p.nextSibling;return n}function ne(e,t,r){e[t]=r}O.prototype=Error.prototype,r(v,O),E.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var r=[],n=0;n<this.length;n++)ee(this[n],r,e,t);return r.join("")}},N.prototype.item=function(e){return S(this),this[e]},n(N,E),x.prototype={length:0,item:E.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var r=this[t];if(r.nodeName==e)return r}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new O(b);var r=this.getNamedItem(e.nodeName);return T(this._ownerElement,this,e,r),r},setNamedItemNS:function(e){var t,r=e.ownerElement;if(r&&r!=this._ownerElement)throw new O(b);return t=this.getNamedItemNS(e.namespaceURI,e.localName),T(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return C(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var r=this.getNamedItemNS(e,t);return C(this._ownerElement,this,r),r},getNamedItemNS:function(e,t){for(var r=this.length;r--;){var n=this[r];if(n.localName==t&&n.namespaceURI==e)return n}return null}},R.prototype={hasFeature:function(e,t){var r=this._features[e.toLowerCase()];return!(!r||t&&!(t in r))},createDocument:function(e,t,r){var n=new I;if(n.implementation=this,n.childNodes=new E,n.doctype=r,r&&n.appendChild(r),t){var s=n.createElementNS(e,t);n.appendChild(s)}return n},createDocumentType:function(e,t,r){var n=new G;return n.name=e,n.nodeName=e,n.publicId=t,n.systemId=r,n}},P.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return U(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return j(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return re(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==a&&e.nodeType==a?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var r=t._nsMap;if(r)for(var n in r)if(r[n]==e)return n;t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var r=t._nsMap;if(r&&e in r)return r[e];t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},r(s,P),r(s,P.prototype),I.prototype={nodeName:"#document",nodeType:d,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==g){for(var r=e.firstChild;r;){var n=r.nextSibling;this.insertBefore(r,t),r=n}return e}return null==this.documentElement&&e.nodeType==i&&(this.documentElement=e),U(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),j(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return D(this.documentElement,(function(r){if(r.nodeType==i&&r.getAttribute("id")==e)return t=r,!0})),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new N(this,(function(e){var r=[];return D(e.documentElement,(function(n){n!==e&&n.nodeType==i&&t.test(n.getAttribute("class"))&&r.push(n)})),r}))},createElement:function(e){var t=new B;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new E,(t.attributes=new x)._ownerElement=t,t},createDocumentFragment:function(){var e=new Y;return e.ownerDocument=this,e.childNodes=new E,e},createTextNode:function(e){var t=new H;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new W;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var r=new J;return r.ownerDocument=this,r.tagName=r.target=e,r.nodeValue=r.data=t,r},createAttribute:function(e){var t=new q;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new K;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var r=new B,n=t.split(":"),s=r.attributes=new x;return r.childNodes=new E,r.ownerDocument=this,r.nodeName=t,r.tagName=t,r.namespaceURI=e,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,s._ownerElement=r,r},createAttributeNS:function(e,t){var r=new q,n=t.split(":");return r.ownerDocument=this,r.nodeName=t,r.name=t,r.namespaceURI=e,r.specified=!0,2==n.length?(r.prefix=n[0],r.localName=n[1]):r.localName=t,r}},n(I,P),B.prototype={nodeType:i,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var r=this.ownerDocument.createAttribute(e);r.value=r.nodeValue=""+t,this.setAttributeNode(r)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===g?this.insertBefore(e,null):function(e,t){var r=t.parentNode;if(r){var n=e.lastChild;r.removeChild(t),n=e.lastChild}return n=e.lastChild,t.parentNode=e,t.previousSibling=n,t.nextSibling=null,n?n.nextSibling=t:e.firstChild=t,e.lastChild=t,F(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var r=this.getAttributeNodeNS(e,t);r&&this.removeAttributeNode(r)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var r=this.getAttributeNodeNS(e,t);return r&&r.value||""},setAttributeNS:function(e,t,r){var n=this.ownerDocument.createAttributeNS(e,t);n.value=n.nodeValue=""+r,this.setAttributeNode(n)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new N(this,(function(t){var r=[];return D(t,(function(n){n===t||n.nodeType!=i||"*"!==e&&n.tagName!=e||r.push(n)})),r}))},getElementsByTagNameNS:function(e,t){return new N(this,(function(r){var n=[];return D(r,(function(s){s===r||s.nodeType!==i||"*"!==e&&s.namespaceURI!==e||"*"!==t&&s.localName!=t||n.push(s)})),n}))}},I.prototype.getElementsByTagName=B.prototype.getElementsByTagName,I.prototype.getElementsByTagNameNS=B.prototype.getElementsByTagNameNS,n(B,P),q.prototype.nodeType=o,n(q,P),M.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(_[y])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,r){r=this.data.substring(0,e)+r+this.data.substring(e+t),this.nodeValue=this.data=r,this.length=r.length}},n(M,P),H.prototype={nodeName:"#text",nodeType:a,splitText:function(e){var t=this.data,r=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var n=this.ownerDocument.createTextNode(r);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}},n(H,M),V.prototype={nodeName:"#comment",nodeType:p},n(V,M),W.prototype={nodeName:"#cdata-section",nodeType:u},n(W,M),G.prototype.nodeType=f,n(G,P),z.prototype.nodeType=m,n(z,P),X.prototype.nodeType=l,n(X,P),K.prototype.nodeType=h,n(K,P),Y.prototype.nodeName="#document-fragment",Y.prototype.nodeType=g,n(Y,P),J.prototype.nodeType=c,n(J,P),Q.prototype.serializeToString=function(e,t,r){return $.call(e,t,r)},P.prototype.toString=$;try{if(Object.defineProperty){function se(e){switch(e.nodeType){case i:case g:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(se(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(N.prototype,"length",{get:function(){return S(this),this.$$length}}),Object.defineProperty(P.prototype,"textContent",{get:function(){return se(this)},set:function(e){switch(this.nodeType){case i:case g:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ne=function(e,t,r){e["$$"+t]=r}}}catch(ie){}t.DOMImplementation=R,t.XMLSerializer=Q},8604:(e,t)=>{t.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}},1132:(e,t)=>{var r=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,n=new RegExp("[\\-\\.0-9"+r.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),s=new RegExp("^"+r.source+n.source+"*(?::"+r.source+n.source+"*)?$");function i(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,i)}function o(){}function a(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function u(e,t,r,n,s,i){function o(e,t,n){e in r.attributeNames&&i.fatalError("Attribute "+e+" redefined"),r.addValue(e,t,n)}for(var a,u=++t,h=0;;){var l=e.charAt(u);switch(l){case"=":if(1===h)a=e.slice(t,u),h=3;else{if(2!==h)throw new Error("attribute equal must after attrName");h=3}break;case"'":case'"':if(3===h||1===h){if(1===h&&(i.warning('attribute value must after "="'),a=e.slice(t,u)),t=u+1,!((u=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");o(a,c=e.slice(t,u).replace(/&#?\w+;/g,s),t-1),h=5}else{if(4!=h)throw new Error('attribute value must after "="');o(a,c=e.slice(t,u).replace(/&#?\w+;/g,s),t),i.warning('attribute "'+a+'" missed start quot('+l+")!!"),t=u+1,h=5}break;case"/":switch(h){case 0:r.setTagName(e.slice(t,u));case 5:case 6:case 7:h=7,r.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),0==h&&r.setTagName(e.slice(t,u)),u;case">":switch(h){case 0:r.setTagName(e.slice(t,u));case 5:case 6:case 7:break;case 4:case 1:"/"===(c=e.slice(t,u)).slice(-1)&&(r.closed=!0,c=c.slice(0,-1));case 2:2===h&&(c=a),4==h?(i.warning('attribute "'+c+'" missed quot(")!'),o(a,c.replace(/&#?\w+;/g,s),t)):("http://www.w3.org/1999/xhtml"===n[""]&&c.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+c+'" missed value!! "'+c+'" instead!!'),o(c,c,t));break;case 3:throw new Error("attribute value missed!!")}return u;case"":l=" ";default:if(l<=" ")switch(h){case 0:r.setTagName(e.slice(t,u)),h=6;break;case 1:a=e.slice(t,u),h=2;break;case 4:var c=e.slice(t,u).replace(/&#?\w+;/g,s);i.warning('attribute "'+c+'" missed quot(")!!'),o(a,c,t);case 5:h=6}else switch(h){case 2:r.tagName;"http://www.w3.org/1999/xhtml"===n[""]&&a.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+a+'" missed value!! "'+a+'" instead2!!'),o(a,a,t),t=u,h=1;break;case 5:i.warning('attribute space is required"'+a+'"!!');case 6:h=1,t=u;break;case 3:h=4,t=u;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}u++}}function h(e,t,r){for(var n=e.tagName,s=null,i=e.length;i--;){var o=e[i],a=o.qName,u=o.value;if((d=a.indexOf(":"))>0)var h=o.prefix=a.slice(0,d),l=a.slice(d+1),c="xmlns"===h&&l;else l=a,h=null,c="xmlns"===a&&"";o.localName=l,!1!==c&&(null==s&&(s={},p(r,r={})),r[c]=s[c]=u,o.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(c,u))}for(i=e.length;i--;){(h=(o=e[i]).prefix)&&("xml"===h&&(o.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==h&&(o.uri=r[h||""]))}var d;(d=n.indexOf(":"))>0?(h=e.prefix=n.slice(0,d),l=e.localName=n.slice(d+1)):(h=null,l=e.localName=n);var f=e.uri=r[h||""];if(t.startElement(f,l,n,e),!e.closed)return e.currentNSMap=r,e.localNSMap=s,!0;if(t.endElement(f,l,n),s)for(h in s)t.endPrefixMapping(h)}function l(e,t,r,n,s){if(/^(?:script|textarea)$/i.test(r)){var i=e.indexOf("</"+r+">",t),o=e.substring(t+1,i);if(/[&<]/.test(o))return/^script$/i.test(r)?(s.characters(o,0,o.length),i):(o=o.replace(/&#?\w+;/g,n),s.characters(o,0,o.length),i)}return t+1}function c(e,t,r,n){var s=n[r];return null==s&&((s=e.lastIndexOf("</"+r+">"))<t&&(s=e.lastIndexOf("</"+r)),n[r]=s),s<t}function p(e,t){for(var r in e)t[r]=e[r]}function d(e,t,r,n){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(s=e.indexOf("--\x3e",t+4))>t?(r.comment(e,t+4,s-t-4),s+3):(n.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var s=e.indexOf("]]>",t+9);return r.startCDATA(),r.characters(e,t+9,s-t-9),r.endCDATA(),s+3}var i=function(e,t){var r,n=[],s=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;s.lastIndex=t,s.exec(e);for(;r=s.exec(e);)if(n.push(r),r[1])return n}(e,t),o=i.length;if(o>1&&/!doctype/i.test(i[0][0])){var a=i[1][0],u=!1,h=!1;o>3&&(/^public$/i.test(i[2][0])?(u=i[3][0],h=o>4&&i[4][0]):/^system$/i.test(i[2][0])&&(h=i[3][0]));var l=i[o-1];return r.startDTD(a,u,h),r.endDTD(),l.index+l[0].length}return-1}function f(e,t,r){var n=e.indexOf("?>",t);if(n){var s=e.substring(t,n).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(s){s[0].length;return r.processingInstruction(s[1],s[2]),n+2}return-1}return-1}function g(){this.attributeNames={}}i.prototype=new Error,i.prototype.name=i.name,o.prototype={parse:function(e,t,r){var n=this.domBuilder;n.startDocument(),p(t,t={}),function(e,t,r,n,s){function o(e){if(e>65535){var t=55296+((e-=65536)>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}function p(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?o(parseInt(t.substr(1).replace("x","0x"))):(s.error("entity not found:"+e),e)}function m(t){if(t>N){var r=e.substring(N,t).replace(/&#?\w+;/g,p);b&&v(N),n.characters(r,0,t-N),N=t}}function v(t,r){for(;t>=y&&(r=w.exec(e));)_=r.index,y=_+r[0].length,b.lineNumber++;b.columnNumber=t-_+1}var _=0,y=0,w=/.*(?:\r\n?|\n)|.*$/g,b=n.locator,O=[{currentNSMap:t}],E={},N=0;for(;;){try{var S=e.indexOf("<",N);if(S<0){if(!e.substr(N).match(/^\s*$/)){var x=n.doc,A=x.createTextNode(e.substr(N));x.appendChild(A),n.currentElement=A}return}switch(S>N&&m(S),e.charAt(S+1)){case"/":var T=e.indexOf(">",S+3),C=e.substring(S+2,T),R=O.pop();T<0?(C=e.substring(S+2).replace(/[\s<].*/,""),s.error("end tag name: "+C+" is not complete:"+R.tagName),T=S+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),s.error("end tag name: "+C+" maybe not complete"),T=S+1+C.length);var P=R.localNSMap,k=R.tagName==C;if(k||R.tagName&&R.tagName.toLowerCase()==C.toLowerCase()){if(n.endElement(R.uri,R.localName,C),P)for(var D in P)n.endPrefixMapping(D);k||s.fatalError("end tag name: "+C+" is not match the current start tagName:"+R.tagName)}else O.push(R);T++;break;case"?":b&&v(S),T=f(e,S,n);break;case"!":b&&v(S),T=d(e,S,n,s);break;default:b&&v(S);var I=new g,L=O[O.length-1].currentNSMap,F=(T=u(e,S,I,L,p,s),I.length);if(!I.closed&&c(e,T,I.tagName,E)&&(I.closed=!0,r.nbsp||s.warning("unclosed xml attribute")),b&&F){for(var j=a(b,{}),U=0;U<F;U++){var B=I[U];v(B.offset),B.locator=a(b,{})}n.locator=j,h(I,n,L)&&O.push(I),n.locator=b}else h(I,n,L)&&O.push(I);"http://www.w3.org/1999/xhtml"!==I.uri||I.closed?T++:T=l(e,T,I.tagName,p,n)}}catch(e){if(e instanceof i)throw e;s.error("element parse error: "+e),T=-1}T>N?N=T:m(Math.max(S,N)+1)}}(e,t,r,n,this.errorHandler),n.endDocument()}},g.prototype={setTagName:function(e){if(!s.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!s.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},t.XMLReader=o,t.ParseError=i},8025:(e,t)=>{!function(e){"use strict";var t=function(e,t){for(var r=0;r<t.length;r+=1)e(t[r],r,t)},r=function(e,r,n){var s=r;return t((function(t,r){s=e(s,t,r)}),n),s},n=function(e,r){var n=new Array(r.length);return t((function(t,r){n[r]=e(t)}),r),n};function s(e){return e.toString()}var i=function(e,t){return t.join(e)},o=function(e,t,r){return e+r+t},a=Array.prototype.concat;function u(e,t){for(var r=Object(e),n=1;n<arguments.length;n++){var s=arguments[n];if(null!=s)for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])}return r}function h(){this.init()}function l(e){this.expression=e}function c(e,t,r){t in e||(e[t]=r)}function p(){}function d(e){arguments.length>0&&this.init(e)}function f(e){arguments.length>0&&this.init(e)}function g(e,t){arguments.length>0&&this.init(e,t)}function m(e,t){arguments.length>0&&this.init(e,t)}function v(e,t){arguments.length>0&&this.init(e,t)}function _(e,t){arguments.length>0&&this.init(e,t)}function y(e,t){arguments.length>0&&this.init(e,t)}function w(e,t){arguments.length>0&&this.init(e,t)}function b(e,t){arguments.length>0&&this.init(e,t)}function O(e,t){arguments.length>0&&this.init(e,t)}function E(e,t){arguments.length>0&&this.init(e,t)}function N(e,t){arguments.length>0&&this.init(e,t)}function S(e,t){arguments.length>0&&this.init(e,t)}function x(e,t){arguments.length>0&&this.init(e,t)}function A(e,t){arguments.length>0&&this.init(e,t)}function T(e,t){arguments.length>0&&this.init(e,t)}function C(e,t){arguments.length>0&&this.init(e,t)}function R(e,t,r){arguments.length>0&&this.init(e,t,r)}function P(e){for(;e&&e.parentNode;)e=e.parentNode;return e}function k(e,t,r){return R.applyPredicates(e.predicates,t,R.applyStep(e,t,r))}function D(e,t,r){return function(e){for(var t=[],r=0;r<e.length;r+=32767){var n=e.slice(r,r+32767);t=a.apply(t,n)}return t}(n(k.bind(null,r,e),t))}function I(e,t){arguments.length>0&&this.init(e,t)}function L(e,t,r){arguments.length>0&&this.init(e,t,r)}function F(e,t){arguments.length>0&&this.init(e,t)}function j(e){arguments.length>0&&this.init(e)}function U(e,t){arguments.length>0&&this.init(e,t)}h.prototype=new Object,h.prototype.constructor=h,h.superclass=Object.prototype,h.prototype.init=function(){this.reduceActions=[],this.reduceActions[3]=function(e){return new m(e[0],e[2])},this.reduceActions[5]=function(e){return new v(e[0],e[2])},this.reduceActions[7]=function(e){return new _(e[0],e[2])},this.reduceActions[8]=function(e){return new y(e[0],e[2])},this.reduceActions[10]=function(e){return new w(e[0],e[2])},this.reduceActions[11]=function(e){return new b(e[0],e[2])},this.reduceActions[12]=function(e){return new O(e[0],e[2])},this.reduceActions[13]=function(e){return new E(e[0],e[2])},this.reduceActions[15]=function(e){return new N(e[0],e[2])},this.reduceActions[16]=function(e){return new S(e[0],e[2])},this.reduceActions[18]=function(e){return new x(e[0],e[2])},this.reduceActions[19]=function(e){return new A(e[0],e[2])},this.reduceActions[20]=function(e){return new T(e[0],e[2])},this.reduceActions[22]=function(e){return new f(e[1])},this.reduceActions[24]=function(e){return new C(e[0],e[2])},this.reduceActions[25]=function(e){return new R(void 0,void 0,e[0])},this.reduceActions[27]=function(e){return e[0].locationPath=e[2],e[0]},this.reduceActions[28]=function(e){return e[0].locationPath=e[2],e[0].locationPath.steps.unshift(new L(L.DESCENDANTORSELF,F.nodeTest,[])),e[0]},this.reduceActions[29]=function(e){return new R(e[0],[],void 0)},this.reduceActions[30]=function(e){return Q.instance_of(e[0],R)?(null==e[0].filterPredicates&&(e[0].filterPredicates=[]),e[0].filterPredicates.push(e[1]),e[0]):new R(e[0],[e[1]],void 0)},this.reduceActions[32]=function(e){return e[1]},this.reduceActions[33]=function(e){return new q(e[0])},this.reduceActions[34]=function(e){return new M(e[0])},this.reduceActions[36]=function(e){return new U(e[0],[])},this.reduceActions[37]=function(e){return new U(e[0],e[2])},this.reduceActions[38]=function(e){return[e[0]]},this.reduceActions[39]=function(e){return e[2].unshift(e[0]),e[2]},this.reduceActions[43]=function(e){return new I(!0,[])},this.reduceActions[44]=function(e){return e[1].absolute=!0,e[1]},this.reduceActions[46]=function(e){return new I(!1,[e[0]])},this.reduceActions[47]=function(e){return e[0].steps.push(e[2]),e[0]},this.reduceActions[49]=function(e){return new L(e[0],e[1],[])},this.reduceActions[50]=function(e){return new L(L.CHILD,e[0],[])},this.reduceActions[51]=function(e){return new L(e[0],e[1],e[2])},this.reduceActions[52]=function(e){return new L(L.CHILD,e[0],e[1])},this.reduceActions[54]=function(e){return[e[0]]},this.reduceActions[55]=function(e){return e[1].unshift(e[0]),e[1]},this.reduceActions[56]=function(e){return"ancestor"==e[0]?L.ANCESTOR:"ancestor-or-self"==e[0]?L.ANCESTORORSELF:"attribute"==e[0]?L.ATTRIBUTE:"child"==e[0]?L.CHILD:"descendant"==e[0]?L.DESCENDANT:"descendant-or-self"==e[0]?L.DESCENDANTORSELF:"following"==e[0]?L.FOLLOWING:"following-sibling"==e[0]?L.FOLLOWINGSIBLING:"namespace"==e[0]?L.NAMESPACE:"parent"==e[0]?L.PARENT:"preceding"==e[0]?L.PRECEDING:"preceding-sibling"==e[0]?L.PRECEDINGSIBLING:"self"==e[0]?L.SELF:-1},this.reduceActions[57]=function(e){return L.ATTRIBUTE},this.reduceActions[59]=function(e){return"comment"==e[0]?F.commentTest:"text"==e[0]?F.textTest:"processing-instruction"==e[0]?F.anyPiTest:"node"==e[0]?F.nodeTest:new F(-1,void 0)},this.reduceActions[60]=function(e){return new F.PITest(e[2])},this.reduceActions[61]=function(e){return e[1]},this.reduceActions[63]=function(e){return e[1].absolute=!0,e[1].steps.unshift(new L(L.DESCENDANTORSELF,F.nodeTest,[])),e[1]},this.reduceActions[64]=function(e){return e[0].steps.push(new L(L.DESCENDANTORSELF,F.nodeTest,[])),e[0].steps.push(e[2]),e[0]},this.reduceActions[65]=function(e){return new L(L.SELF,F.nodeTest,[])},this.reduceActions[66]=function(e){return new L(L.PARENT,F.nodeTest,[])},this.reduceActions[67]=function(e){return new j(e[1])},this.reduceActions[68]=function(e){return F.nameTestAny},this.reduceActions[69]=function(e){return new F.NameTestPrefixAny(e[0].split(":")[0])},this.reduceActions[70]=function(e){return new F.NameTestQName(e[0])}},h.actionTable=[" s s sssssssss s ss s ss"," s ","r rrrrrrrrr rrrrrrr rr r "," rrrrr "," s s sssssssss s ss s ss","rs rrrrrrrr s sssssrrrrrr rrs rs "," s s sssssssss s ss s ss"," s "," s ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr "," s "," s "," s s sssss s s ","r rrrrrrrrr rrrrrrr rr r ","a ","r s rr r ","r sr rr r ","r s rr s rr r ","r rssrr rss rr r ","r rrrrr rrrss rr r ","r rrrrrsss rrrrr rr r ","r rrrrrrrr rrrrr rr r ","r rrrrrrrr rrrrrs rr r ","r rrrrrrrr rrrrrr rr r ","r rrrrrrrr rrrrrr rr r ","r srrrrrrrr rrrrrrs rr sr ","r srrrrrrrr rrrrrrs rr r ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrr rrrrrr rr r ","r rrrrrrrr rrrrrr rr r ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr r "," sssss ","r rrrrrrrrr rrrrrrr rr sr ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr "," s ","r srrrrrrrr rrrrrrs rr r ","r rrrrrrrr rrrrr rr r "," s "," s "," rrrrr "," s s sssssssss s sss s ss","r srrrrrrrr rrrrrrs rr r "," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss s ss s ss"," s s sssssssss ss s ss"," s s sssssssss s ss s ss"," s s sssss s s "," s s sssss s s ","r rrrrrrrrr rrrrrrr rr rr "," s s sssss s s "," s s sssss s s ","r rrrrrrrrr rrrrrrr rr sr ","r rrrrrrrrr rrrrrrr rr sr ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr rr "," s ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr "," rr "," s "," rs ","r sr rr r ","r s rr s rr r ","r rssrr rss rr r ","r rssrr rss rr r ","r rrrrr rrrss rr r ","r rrrrr rrrss rr r ","r rrrrr rrrss rr r ","r rrrrr rrrss rr r ","r rrrrrsss rrrrr rr r ","r rrrrrsss rrrrr rr r ","r rrrrrrrr rrrrr rr r ","r rrrrrrrr rrrrr rr r ","r rrrrrrrr rrrrr rr r ","r rrrrrrrr rrrrrr rr r "," r "," s ","r srrrrrrrr rrrrrrs rr r ","r srrrrrrrr rrrrrrs rr r ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr r ","r rrrrrrrrr rrrrrrr rr rr ","r rrrrrrrrr rrrrrrr rr rr "," s s sssssssss s ss s ss","r rrrrrrrrr rrrrrrr rr rr "," r "],h.actionTableNumber=[" 1 0 /.-,+*)(' & %$ # \"!"," J ","a aaaaaaaaa aaaaaaa aa a "," YYYYY "," 1 0 /.-,+*)(' & %$ # \"!","K1 KKKKKKKK . +*)('KKKKKK KK# K\" "," 1 0 /.-,+*)(' & %$ # \"!"," N "," O ","e eeeeeeeee eeeeeee ee ee ","f fffffffff fffffff ff ff ","d ddddddddd ddddddd dd dd ","B BBBBBBBBB BBBBBBB BB BB ","A AAAAAAAAA AAAAAAA AA AA "," P "," Q "," 1 . +*)(' # \" ","b bbbbbbbbb bbbbbbb bb b "," ","! S !! ! ",'" T" "" " ',"$ V $$ U $$ $ ","& &ZY&& &XW && & ",") ))))) )))\\[ )) ) ",". ....._^] ..... .. . ","1 11111111 11111 11 1 ","5 55555555 55555` 55 5 ","7 77777777 777777 77 7 ","9 99999999 999999 99 9 ",": c:::::::: ::::::b :: a: ","I fIIIIIIII IIIIIIe II I ","= ========= ======= == == ","? ????????? ??????? ?? ?? ","C CCCCCCCCC CCCCCCC CC CC ","J JJJJJJJJ JJJJJJ JJ J ","M MMMMMMMM MMMMMM MM M ","N NNNNNNNNN NNNNNNN NN N ","P PPPPPPPPP PPPPPPP PP P "," +*)(' ","R RRRRRRRRR RRRRRRR RR aR ","U UUUUUUUUU UUUUUUU UU U ","Z ZZZZZZZZZ ZZZZZZZ ZZ ZZ ","c ccccccccc ccccccc cc cc "," j ","L fLLLLLLLL LLLLLLe LL L ","6 66666666 66666 66 6 "," k "," l "," XXXXX "," 1 0 /.-,+*)(' & %$m # \"!","_ f________ ______e __ _ "," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 0 /.-,+*)(' %$ # \"!"," 1 0 /.-,+*)(' & %$ # \"!"," 1 . +*)(' # \" "," 1 . +*)(' # \" ","> >>>>>>>>> >>>>>>> >> >> "," 1 . +*)(' # \" "," 1 . +*)(' # \" ","Q QQQQQQQQQ QQQQQQQ QQ aQ ","V VVVVVVVVV VVVVVVV VV aV ","T TTTTTTTTT TTTTTTT TT T ","@ @@@@@@@@@ @@@@@@@ @@ @@ "," ","[ [[[[[[[[[ [[[[[[[ [[ [[ ","D DDDDDDDDD DDDDDDD DD DD "," HH "," "," F ","# T# ## # ","% V %% U %% % ","' 'ZY'' 'XW '' ' ","( (ZY(( (XW (( ( ","+ +++++ +++\\[ ++ + ","* ***** ***\\[ ** * ","- ----- ---\\[ -- - ",", ,,,,, ,,,\\[ ,, , ","0 00000_^] 00000 00 0 ","/ /////_^] ///// // / ","2 22222222 22222 22 2 ","3 33333333 33333 33 3 ","4 44444444 44444 44 4 ","8 88888888 888888 88 8 "," ^ "," ","; f;;;;;;;; ;;;;;;e ;; ; ","< f<<<<<<<< <<<<<<e << < ","O OOOOOOOOO OOOOOOO OO O ","` ````````` ``````` `` ` ","S SSSSSSSSS SSSSSSS SS S ","W WWWWWWWWW WWWWWWW WW W ","\\ \\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\ \\\\ \\\\ ","E EEEEEEEEE EEEEEEE EE EE "," 1 0 /.-,+*)(' & %$ # \"!","] ]]]]]]]]] ]]]]]]] ]] ]] "," G "],h.gotoTable=["3456789:;<=>?@ AB CDEFGH IJ "," "," "," ","L456789:;<=>?@ AB CDEFGH IJ "," M EFGH IJ "," N;<=>?@ AB CDEFGH IJ "," "," "," "," "," "," "," "," "," "," S EFGH IJ "," "," "," "," "," "," "," "," "," "," "," "," "," e "," "," "," "," "," "," "," "," "," h J "," i j "," "," "," "," "," "," "," "," "," ","o456789:;<=>?@ ABpqCDEFGH IJ "," "," r6789:;<=>?@ AB CDEFGH IJ "," s789:;<=>?@ AB CDEFGH IJ "," t89:;<=>?@ AB CDEFGH IJ "," u89:;<=>?@ AB CDEFGH IJ "," v9:;<=>?@ AB CDEFGH IJ "," w9:;<=>?@ AB CDEFGH IJ "," x9:;<=>?@ AB CDEFGH IJ "," y9:;<=>?@ AB CDEFGH IJ "," z:;<=>?@ AB CDEFGH IJ "," {:;<=>?@ AB CDEFGH IJ "," |;<=>?@ AB CDEFGH IJ "," };<=>?@ AB CDEFGH IJ "," ~;<=>?@ AB CDEFGH IJ "," =>?@ AB CDEFGH IJ ","456789:;<=>?@ AB CDEFGH IJ"," EFGH IJ "," EFGH IJ "," "," GH IJ ","
GH IJ "," i "," i "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","o456789:;<=>?@ ABqCDEFGH IJ "," "," "],h.productions=[[1,1,2],[2,1,3],[3,1,4],[3,3,3,-9,4],[4,1,5],[4,3,4,-8,5],[5,1,6],[5,3,5,-22,6],[5,3,5,-5,6],[6,1,7],[6,3,6,-23,7],[6,3,6,-24,7],[6,3,6,-6,7],[6,3,6,-7,7],[7,1,8],[7,3,7,-25,8],[7,3,7,-26,8],[8,1,9],[8,3,8,-12,9],[8,3,8,-11,9],[8,3,8,-10,9],[9,1,10],[9,2,-26,9],[10,1,11],[10,3,10,-27,11],[11,1,12],[11,1,13],[11,3,13,-28,14],[11,3,13,-4,14],[13,1,15],[13,2,13,16],[15,1,17],[15,3,-29,2,-30],[15,1,-15],[15,1,-16],[15,1,18],[18,3,-13,-29,-30],[18,4,-13,-29,19,-30],[19,1,20],[19,3,20,-31,19],[20,1,2],[12,1,14],[12,1,21],[21,1,-28],[21,2,-28,14],[21,1,22],[14,1,23],[14,3,14,-28,23],[14,1,24],[23,2,25,26],[23,1,26],[23,3,25,26,27],[23,2,26,27],[23,1,28],[27,1,16],[27,2,16,27],[25,2,-14,-3],[25,1,-32],[26,1,29],[26,3,-20,-29,-30],[26,4,-21,-29,-15,-30],[16,3,-33,30,-34],[30,1,2],[22,2,-4,14],[24,3,14,-4,23],[28,1,-35],[28,1,-2],[17,2,-36,-18],[29,1,-17],[29,1,-19],[29,1,-18]],h.DOUBLEDOT=2,h.DOUBLECOLON=3,h.DOUBLESLASH=4,h.NOTEQUAL=5,h.LESSTHANOREQUAL=6,h.GREATERTHANOREQUAL=7,h.AND=8,h.OR=9,h.MOD=10,h.DIV=11,h.MULTIPLYOPERATOR=12,h.FUNCTIONNAME=13,h.AXISNAME=14,h.LITERAL=15,h.NUMBER=16,h.ASTERISKNAMETEST=17,h.QNAME=18,h.NCNAMECOLONASTERISK=19,h.NODETYPE=20,h.PROCESSINGINSTRUCTIONWITHLITERAL=21,h.EQUALS=22,h.LESSTHAN=23,h.GREATERTHAN=24,h.PLUS=25,h.MINUS=26,h.BAR=27,h.SLASH=28,h.LEFTPARENTHESIS=29,h.RIGHTPARENTHESIS=30,h.COMMA=31,h.AT=32,h.LEFTBRACKET=33,h.RIGHTBRACKET=34,h.DOT=35,h.DOLLAR=36,h.prototype.tokenize=function(e){for(var t=[],r=[],n=e+"\0",s=0,i=n.charAt(s++);;){for(;" "==i||"\t"==i||"\r"==i||"\n"==i;)i=n.charAt(s++);if("\0"==i||s>=n.length)break;if("("!=i)if(")"!=i)if("["!=i)if("]"!=i)if("@"!=i)if(","!=i)if("|"!=i)if("+"!=i)if("-"!=i)if("="!=i)if("$"!=i)if("."!=i)if("'"!=i&&'"'!=i)if(i>="0"&&i<="9"){c=i;for(i=n.charAt(s++);i>="0"&&i<="9";)c+=i,i=n.charAt(s++);if("."==i&&n.charAt(s)>="0"&&n.charAt(s)<="9")for(c+=i,c+=n.charAt(s++),i=n.charAt(s++);i>="0"&&i<="9";)c+=i,i=n.charAt(s++);t.push(h.NUMBER),r.push(c)}else if("*"!=i)if(":"!=i||":"!=n.charAt(s))if("/"!=i)if("!"!=i||"="!=n.charAt(s))if("<"!=i)if(">"!=i){if("_"!=i&&!Q.isLetter(i.charCodeAt(0)))throw new Error("Unexpected character "+i);var o=i;for(i=n.charAt(s++);Q.isNCNameChar(i.charCodeAt(0));)o+=i,i=n.charAt(s++);if(t.length>0&&(a=t[t.length-1])!=h.AT&&a!=h.DOUBLECOLON&&a!=h.LEFTPARENTHESIS&&a!=h.LEFTBRACKET&&a!=h.AND&&a!=h.OR&&a!=h.MOD&&a!=h.DIV&&a!=h.MULTIPLYOPERATOR&&a!=h.SLASH&&a!=h.DOUBLESLASH&&a!=h.BAR&&a!=h.PLUS&&a!=h.MINUS&&a!=h.EQUALS&&a!=h.NOTEQUAL&&a!=h.LESSTHAN&&a!=h.LESSTHANOREQUAL&&a!=h.GREATERTHAN&&a!=h.GREATERTHANOREQUAL){if("and"==o){t.push(h.AND),r.push(o);continue}if("or"==o){t.push(h.OR),r.push(o);continue}if("mod"==o){t.push(h.MOD),r.push(o);continue}if("div"==o){t.push(h.DIV),r.push(o);continue}}if(":"==i){if("*"==n.charAt(s)){t.push(h.NCNAMECOLONASTERISK),r.push(o+":*"),s++,i=n.charAt(s++);continue}if("_"==n.charAt(s)||Q.isLetter(n.charCodeAt(s))){for(o+=":",i=n.charAt(s++);Q.isNCNameChar(i.charCodeAt(0));)o+=i,i=n.charAt(s++);if("("==i){t.push(h.FUNCTIONNAME),r.push(o);continue}t.push(h.QNAME),r.push(o);continue}if(":"==n.charAt(s)){t.push(h.AXISNAME),r.push(o);continue}}if("("==i){if("comment"==o||"text"==o||"node"==o){t.push(h.NODETYPE),r.push(o);continue}if("processing-instruction"==o){")"==n.charAt(s)?t.push(h.NODETYPE):t.push(h.PROCESSINGINSTRUCTIONWITHLITERAL),r.push(o);continue}t.push(h.FUNCTIONNAME),r.push(o);continue}t.push(h.QNAME),r.push(o)}else{if("="==n.charAt(s)){t.push(h.GREATERTHANOREQUAL),r.push(">="),s++,i=n.charAt(s++);continue}t.push(h.GREATERTHAN),r.push(">"),i=n.charAt(s++)}else{if("="==n.charAt(s)){t.push(h.LESSTHANOREQUAL),r.push("<="),s++,i=n.charAt(s++);continue}t.push(h.LESSTHAN),r.push("<"),i=n.charAt(s++)}else t.push(h.NOTEQUAL),r.push("!="),s++,i=n.charAt(s++);else{if("/"==(i=n.charAt(s++))){t.push(h.DOUBLESLASH),r.push("//"),i=n.charAt(s++);continue}t.push(h.SLASH),r.push("/")}else t.push(h.DOUBLECOLON),r.push("::"),s++,i=n.charAt(s++);else{var a;if(t.length>0&&(a=t[t.length-1])!=h.AT&&a!=h.DOUBLECOLON&&a!=h.LEFTPARENTHESIS&&a!=h.LEFTBRACKET&&a!=h.AND&&a!=h.OR&&a!=h.MOD&&a!=h.DIV&&a!=h.MULTIPLYOPERATOR&&a!=h.SLASH&&a!=h.DOUBLESLASH&&a!=h.BAR&&a!=h.PLUS&&a!=h.MINUS&&a!=h.EQUALS&&a!=h.NOTEQUAL&&a!=h.LESSTHAN&&a!=h.LESSTHANOREQUAL&&a!=h.GREATERTHAN&&a!=h.GREATERTHANOREQUAL){t.push(h.MULTIPLYOPERATOR),r.push(i),i=n.charAt(s++);continue}t.push(h.ASTERISKNAMETEST),r.push(i),i=n.charAt(s++)}else{for(var u=i,l="";s<n.length&&(i=n.charAt(s))!==u;)l+=i,s+=1;if(i!==u)throw $.fromMessage("Unterminated string literal: "+u+l);s+=1,t.push(h.LITERAL),r.push(l),i=n.charAt(s++)}else{if("."==(i=n.charAt(s++))){t.push(h.DOUBLEDOT),r.push(".."),i=n.charAt(s++);continue}if(i>="0"&&i<="9"){var c="."+i;for(i=n.charAt(s++);i>="0"&&i<="9";)c+=i,i=n.charAt(s++);t.push(h.NUMBER),r.push(c);continue}t.push(h.DOT),r.push(".")}else t.push(h.DOLLAR),r.push(i),i=n.charAt(s++);else t.push(h.EQUALS),r.push(i),i=n.charAt(s++);else t.push(h.MINUS),r.push(i),i=n.charAt(s++);else t.push(h.PLUS),r.push(i),i=n.charAt(s++);else t.push(h.BAR),r.push(i),i=n.charAt(s++);else t.push(h.COMMA),r.push(i),i=n.charAt(s++);else t.push(h.AT),r.push(i),i=n.charAt(s++);else t.push(h.RIGHTBRACKET),r.push(i),i=n.charAt(s++);else t.push(h.LEFTBRACKET),r.push(i),i=n.charAt(s++);else t.push(h.RIGHTPARENTHESIS),r.push(i),i=n.charAt(s++);else t.push(h.LEFTPARENTHESIS),r.push(i),i=n.charAt(s++)}return t.push(1),r.push("[EOF]"),[t,r]},h.SHIFT="s",h.REDUCE="r",h.ACCEPT="a",h.prototype.parse=function(e){var t,r,n=this.tokenize(e);if(null!=n){t=n[0],r=n[1];var s,i,o=0,a=[],u=[],c=[];for(a.push(0),u.push(1),c.push("_S"),s=t[o],i=r[o++];;)switch(e=a[a.length-1],h.actionTable[e].charAt(s-1)){case h.SHIFT:u.push(-s),c.push(i),a.push(h.actionTableNumber[e].charCodeAt(s-1)-32),s=t[o],i=r[o++];break;case h.REDUCE:for(var p=h.productions[h.actionTableNumber[e].charCodeAt(s-1)-32][1],d=[],f=0;f<p;f++)u.pop(),d.unshift(c.pop()),a.pop();var g=a[a.length-1];u.push(h.productions[h.actionTableNumber[e].charCodeAt(s-1)-32][0]),null==this.reduceActions[h.actionTableNumber[e].charCodeAt(s-1)-32]?c.push(d[0]):c.push(this.reduceActions[h.actionTableNumber[e].charCodeAt(s-1)-32](d)),a.push(h.gotoTable[g].charCodeAt(h.productions[h.actionTableNumber[e].charCodeAt(s-1)-32][0]-2)-33);break;case h.ACCEPT:return new l(c.pop());default:throw new Error("XPath parse error")}}},l.prototype=new Object,l.prototype.constructor=l,l.superclass=Object.prototype,l.prototype.toString=function(){return this.expression.toString()},l.prototype.evaluate=function(e){return e.contextNode=e.expressionContextNode,e.contextSize=1,e.contextPosition=1,e.isHtml&&(c(e,"caseInsensitive",!0),c(e,"allowAnyNamespaceForNoPrefix",!0)),c(e,"caseInsensitive",!1),this.expression.evaluate(e)},l.XML_NAMESPACE_URI="http://www.w3.org/XML/1998/namespace",l.XMLNS_NAMESPACE_URI="http://www.w3.org/2000/xmlns/",p.prototype=new Object,p.prototype.constructor=p,p.superclass=Object.prototype,p.prototype.init=function(){},p.prototype.toString=function(){return"<Expression>"},p.prototype.evaluate=function(e){throw new Error("Could not evaluate expression.")},d.prototype=new p,d.prototype.constructor=d,d.superclass=p.prototype,d.prototype.init=function(e){this.rhs=e},f.prototype=new d,f.prototype.constructor=f,f.superclass=d.prototype,f.prototype.init=function(e){f.superclass.init.call(this,e)},f.prototype.evaluate=function(e){return this.rhs.evaluate(e).number().negate()},f.prototype.toString=function(){return"-"+this.rhs.toString()},g.prototype=new p,g.prototype.constructor=g,g.superclass=p.prototype,g.prototype.init=function(e,t){this.lhs=e,this.rhs=t},m.prototype=new g,m.prototype.constructor=m,m.superclass=g.prototype,m.prototype.init=function(e,t){m.superclass.init.call(this,e,t)},m.prototype.toString=function(){return"("+this.lhs.toString()+" or "+this.rhs.toString()+")"},m.prototype.evaluate=function(e){var t=this.lhs.evaluate(e).bool();return t.booleanValue()?t:this.rhs.evaluate(e).bool()},v.prototype=new g,v.prototype.constructor=v,v.superclass=g.prototype,v.prototype.init=function(e,t){v.superclass.init.call(this,e,t)},v.prototype.toString=function(){return"("+this.lhs.toString()+" and "+this.rhs.toString()+")"},v.prototype.evaluate=function(e){var t=this.lhs.evaluate(e).bool();return t.booleanValue()?this.rhs.evaluate(e).bool():t},_.prototype=new g,_.prototype.constructor=_,_.superclass=g.prototype,_.prototype.init=function(e,t){_.superclass.init.call(this,e,t)},_.prototype.toString=function(){return"("+this.lhs.toString()+" = "+this.rhs.toString()+")"},_.prototype.evaluate=function(e){return this.lhs.evaluate(e).equals(this.rhs.evaluate(e))},y.prototype=new g,y.prototype.constructor=y,y.superclass=g.prototype,y.prototype.init=function(e,t){y.superclass.init.call(this,e,t)},y.prototype.toString=function(){return"("+this.lhs.toString()+" != "+this.rhs.toString()+")"},y.prototype.evaluate=function(e){return this.lhs.evaluate(e).notequal(this.rhs.evaluate(e))},w.prototype=new g,w.prototype.constructor=w,w.superclass=g.prototype,w.prototype.init=function(e,t){w.superclass.init.call(this,e,t)},w.prototype.evaluate=function(e){return this.lhs.evaluate(e).lessthan(this.rhs.evaluate(e))},w.prototype.toString=function(){return"("+this.lhs.toString()+" < "+this.rhs.toString()+")"},b.prototype=new g,b.prototype.constructor=b,b.superclass=g.prototype,b.prototype.init=function(e,t){b.superclass.init.call(this,e,t)},b.prototype.evaluate=function(e){return this.lhs.evaluate(e).greaterthan(this.rhs.evaluate(e))},b.prototype.toString=function(){return"("+this.lhs.toString()+" > "+this.rhs.toString()+")"},O.prototype=new g,O.prototype.constructor=O,O.superclass=g.prototype,O.prototype.init=function(e,t){O.superclass.init.call(this,e,t)},O.prototype.evaluate=function(e){return this.lhs.evaluate(e).lessthanorequal(this.rhs.evaluate(e))},O.prototype.toString=function(){return"("+this.lhs.toString()+" <= "+this.rhs.toString()+")"},E.prototype=new g,E.prototype.constructor=E,E.superclass=g.prototype,E.prototype.init=function(e,t){E.superclass.init.call(this,e,t)},E.prototype.evaluate=function(e){return this.lhs.evaluate(e).greaterthanorequal(this.rhs.evaluate(e))},E.prototype.toString=function(){return"("+this.lhs.toString()+" >= "+this.rhs.toString()+")"},N.prototype=new g,N.prototype.constructor=N,N.superclass=g.prototype,N.prototype.init=function(e,t){N.superclass.init.call(this,e,t)},N.prototype.evaluate=function(e){return this.lhs.evaluate(e).number().plus(this.rhs.evaluate(e).number())},N.prototype.toString=function(){return"("+this.lhs.toString()+" + "+this.rhs.toString()+")"},S.prototype=new g,S.prototype.constructor=S,S.superclass=g.prototype,S.prototype.init=function(e,t){S.superclass.init.call(this,e,t)},S.prototype.evaluate=function(e){return this.lhs.evaluate(e).number().minus(this.rhs.evaluate(e).number())},S.prototype.toString=function(){return"("+this.lhs.toString()+" - "+this.rhs.toString()+")"},x.prototype=new g,x.prototype.constructor=x,x.superclass=g.prototype,x.prototype.init=function(e,t){x.superclass.init.call(this,e,t)},x.prototype.evaluate=function(e){return this.lhs.evaluate(e).number().multiply(this.rhs.evaluate(e).number())},x.prototype.toString=function(){return"("+this.lhs.toString()+" * "+this.rhs.toString()+")"},A.prototype=new g,A.prototype.constructor=A,A.superclass=g.prototype,A.prototype.init=function(e,t){A.superclass.init.call(this,e,t)},A.prototype.evaluate=function(e){return this.lhs.evaluate(e).number().div(this.rhs.evaluate(e).number())},A.prototype.toString=function(){return"("+this.lhs.toString()+" div "+this.rhs.toString()+")"},T.prototype=new g,T.prototype.constructor=T,T.superclass=g.prototype,T.prototype.init=function(e,t){T.superclass.init.call(this,e,t)},T.prototype.evaluate=function(e){return this.lhs.evaluate(e).number().mod(this.rhs.evaluate(e).number())},T.prototype.toString=function(){return"("+this.lhs.toString()+" mod "+this.rhs.toString()+")"},C.prototype=new g,C.prototype.constructor=C,C.superclass=g.prototype,C.prototype.init=function(e,t){C.superclass.init.call(this,e,t)},C.prototype.evaluate=function(e){return this.lhs.evaluate(e).nodeset().union(this.rhs.evaluate(e).nodeset())},C.prototype.toString=function(){return n(s,[this.lhs,this.rhs]).join(" | ")},R.prototype=new p,R.prototype.constructor=R,R.superclass=p.prototype,R.prototype.init=function(e,t,r){R.superclass.init.call(this),this.filter=e,this.filterPredicates=t,this.locationPath=r},R.applyPredicates=function(e,n,s){if(0===e.length)return s;var i=n.extend({});return r((function(e,r){return i.contextSize=e.length,n=function(e,t){return i.contextNode=e,i.contextPosition=t+1,R.predicateMatches(r,i)},s=[],t((function(e,t){n(e,t)&&s.push(e)}),e),s;var n,s}),s,e)},R.getRoot=function(e,t){var r=t[0];if(9===r.nodeType)return r;if(e.virtualRoot)return e.virtualRoot;var n=r.ownerDocument;if(n)return n;for(var s=r;null!=s.parentNode;)s=s.parentNode;return s},R.applyStep=function(e,t,r){var n=[];switch(t.contextNode=r,e.axis){case L.ANCESTOR:if(t.contextNode===t.virtualRoot)break;for(s=2==t.contextNode.nodeType?R.getOwnerElement(t.contextNode):t.contextNode.parentNode;null!=s&&(e.nodeTest.matches(s,t)&&n.push(s),s!==t.virtualRoot);)s=s.parentNode;break;case L.ANCESTORORSELF:for(var s=t.contextNode;null!=s&&(e.nodeTest.matches(s,t)&&n.push(s),s!==t.virtualRoot);s=2==s.nodeType?R.getOwnerElement(s):s.parentNode);break;case L.ATTRIBUTE:var i=t.contextNode.attributes;if(null!=i)for(var o=0;o<i.length;o++){s=i.item(o);e.nodeTest.matches(s,t)&&n.push(s)}break;case L.CHILD:for(s=t.contextNode.firstChild;null!=s;s=s.nextSibling)e.nodeTest.matches(s,t)&&n.push(s);break;case L.DESCENDANT:for(var a=[t.contextNode.firstChild];a.length>0;)for(s=a.pop();null!=s;)e.nodeTest.matches(s,t)&&n.push(s),null!=s.firstChild?(a.push(s.nextSibling),s=s.firstChild):s=s.nextSibling;break;case L.DESCENDANTORSELF:e.nodeTest.matches(t.contextNode,t)&&n.push(t.contextNode);for(a=[t.contextNode.firstChild];a.length>0;)for(s=a.pop();null!=s;)e.nodeTest.matches(s,t)&&n.push(s),null!=s.firstChild?(a.push(s.nextSibling),s=s.firstChild):s=s.nextSibling;break;case L.FOLLOWING:if(t.contextNode===t.virtualRoot)break;a=[];null!=t.contextNode.firstChild?a.unshift(t.contextNode.firstChild):a.unshift(t.contextNode.nextSibling);for(s=t.contextNode.parentNode;null!=s&&9!=s.nodeType&&s!==t.virtualRoot;s=s.parentNode)a.unshift(s.nextSibling);do{for(s=a.pop();null!=s;)e.nodeTest.matches(s,t)&&n.push(s),null!=s.firstChild?(a.push(s.nextSibling),s=s.firstChild):s=s.nextSibling}while(a.length>0);break;case L.FOLLOWINGSIBLING:if(t.contextNode===t.virtualRoot)break;for(s=t.contextNode.nextSibling;null!=s;s=s.nextSibling)e.nodeTest.matches(s,t)&&n.push(s);break;case L.NAMESPACE:var u={};if(1==t.contextNode.nodeType){u.xml=l.XML_NAMESPACE_URI,u.xmlns=l.XMLNS_NAMESPACE_URI;for(s=t.contextNode;null!=s&&1==s.nodeType;s=s.parentNode)for(o=0;o<s.attributes.length;o++){var h=s.attributes.item(o),c=String(h.name);if("xmlns"==c)null==u[""]&&(u[""]=h.value);else if(c.length>6&&"xmlns:"==c.substring(0,6)){null==u[p=c.substring(6,c.length)]&&(u[p]=h.value)}}for(var p in u){var d=new G(p,u[p],t.contextNode);e.nodeTest.matches(d,t)&&n.push(d)}}break;case L.PARENT:s=null,t.contextNode!==t.virtualRoot&&(s=2==t.contextNode.nodeType?R.getOwnerElement(t.contextNode):t.contextNode.parentNode),null!=s&&e.nodeTest.matches(s,t)&&n.push(s);break;case L.PRECEDING:a=null!=t.virtualRoot?[t.virtualRoot]:[P(t.contextNode)];e:for(;a.length>0;)for(s=a.pop();null!=s;){if(s==t.contextNode)break e;e.nodeTest.matches(s,t)&&n.unshift(s),null!=s.firstChild?(a.push(s.nextSibling),s=s.firstChild):s=s.nextSibling}break;case L.PRECEDINGSIBLING:if(t.contextNode===t.virtualRoot)break;for(s=t.contextNode.previousSibling;null!=s;s=s.previousSibling)e.nodeTest.matches(s,t)&&n.push(s);break;case L.SELF:e.nodeTest.matches(t.contextNode,t)&&n.push(t.contextNode)}return n},R.applySteps=function(e,t,n){return r(D.bind(null,t),n,e)},R.prototype.applyFilter=function(e,t){if(!this.filter)return{nodes:[e.contextNode]};var r=this.filter.evaluate(e);if(!Q.instance_of(r,W)){if(null!=this.filterPredicates&&this.filterPredicates.length>0||null!=this.locationPath)throw new Error("Path expression filter must evaluate to a nodeset if predicates or location path are used");return{nonNodes:r}}return{nodes:R.applyPredicates(this.filterPredicates||[],t,r.toUnsortedArray())}},R.applyLocationPath=function(e,t,r){if(!e)return r;var n=e.absolute?[R.getRoot(t,r)]:r;return R.applySteps(e.steps,t,n)},R.prototype.evaluate=function(e){var t=u(new z,e),r=this.applyFilter(e,t);if("nonNodes"in r)return r.nonNodes;var n=new W;return n.addArray(R.applyLocationPath(this.locationPath,t,r.nodes)),n},R.predicateMatches=function(e,t){var r=e.evaluate(t);return Q.instance_of(r,M)?t.contextPosition===r.numberValue():r.booleanValue()},R.predicateString=function(e){return o("[","]",e.toString())},R.predicatesString=function(e){return i("",n(R.predicateString,e))},R.prototype.toString=function(){if(null!=this.filter){var e=s(this.filter);return Q.instance_of(this.filter,q)?o("'","'",e):null!=this.filterPredicates&&this.filterPredicates.length?o("(",")",e)+R.predicatesString(this.filterPredicates):null!=this.locationPath?e+(this.locationPath.absolute?"":"/")+s(this.locationPath):e}return s(this.locationPath)},R.getOwnerElement=function(e){if(e.ownerElement)return e.ownerElement;try{if(e.selectSingleNode)return e.selectSingleNode("..")}catch(e){}for(var t=(9==e.nodeType?e:e.ownerDocument).getElementsByTagName("*"),r=0;r<t.length;r++)for(var n=t.item(r),s=n.attributes,i=0;i<s.length;i++){if(s.item(i)===e)return n}return null},I.prototype=new Object,I.prototype.constructor=I,I.superclass=Object.prototype,I.prototype.init=function(e,t){this.absolute=e,this.steps=t},I.prototype.toString=function(){return(this.absolute?"/":"")+n(s,this.steps).join("/")},L.prototype=new Object,L.prototype.constructor=L,L.superclass=Object.prototype,L.prototype.init=function(e,t,r){this.axis=e,this.nodeTest=t,this.predicates=r},L.prototype.toString=function(){return L.STEPNAMES[this.axis]+"::"+this.nodeTest.toString()+R.predicatesString(this.predicates)},L.ANCESTOR=0,L.ANCESTORORSELF=1,L.ATTRIBUTE=2,L.CHILD=3,L.DESCENDANT=4,L.DESCENDANTORSELF=5,L.FOLLOWING=6,L.FOLLOWINGSIBLING=7,L.NAMESPACE=8,L.PARENT=9,L.PRECEDING=10,L.PRECEDINGSIBLING=11,L.SELF=12,L.STEPNAMES=r((function(e,t){return e[t[0]]=t[1],e}),{},[[L.ANCESTOR,"ancestor"],[L.ANCESTORORSELF,"ancestor-or-self"],[L.ATTRIBUTE,"attribute"],[L.CHILD,"child"],[L.DESCENDANT,"descendant"],[L.DESCENDANTORSELF,"descendant-or-self"],[L.FOLLOWING,"following"],[L.FOLLOWINGSIBLING,"following-sibling"],[L.NAMESPACE,"namespace"],[L.PARENT,"parent"],[L.PRECEDING,"preceding"],[L.PRECEDINGSIBLING,"preceding-sibling"],[L.SELF,"self"]]),F.prototype=new Object,F.prototype.constructor=F,F.superclass=Object.prototype,F.prototype.init=function(e,t){this.type=e,this.value=t},F.prototype.toString=function(){return"<unknown nodetest type>"},F.prototype.matches=function(e,t){console.warn("unknown node test type")},F.NAMETESTANY=0,F.NAMETESTPREFIXANY=1,F.NAMETESTQNAME=2,F.COMMENT=3,F.TEXT=4,F.PI=5,F.NODE=6,F.isNodeType=function(e){return function(t){return function(e,t){for(var r=0;r<e.length;r+=1)if(e[r]===t)return!0;return!1}(e,t.nodeType)}},F.makeNodeTestType=function(e,t,r){var n=r||function(){};return n.prototype=new F(e),n.prototype.constructor=n,u(n.prototype,t),n},F.makeNodeTypeTest=function(e,t,r){return new(F.makeNodeTestType(e,{matches:F.isNodeType(t),toString:(n=r,function(){return n})}));var n},F.hasPrefix=function(e){return e.prefix||-1!==(e.nodeName||e.tagName).indexOf(":")},F.isElementOrAttribute=F.isNodeType([1,2]),F.nameSpaceMatches=function(e,t,r){var n=r.namespaceURI||"";if(!e)return!n||t.allowAnyNamespaceForNoPrefix&&!F.hasPrefix(r);var s=t.namespaceResolver.getNamespace(e,t.expressionContextNode);if(null==s)throw new Error("Cannot resolve QName "+e);return s===n},F.localNameMatches=function(e,t,r){var n=r.localName||r.nodeName;return t.caseInsensitive?e.toLowerCase()===n.toLowerCase():e===n},F.NameTestPrefixAny=F.makeNodeTestType(F.NAMETESTPREFIXANY,{matches:function(e,t){return F.isElementOrAttribute(e)&&F.nameSpaceMatches(this.prefix,t,e)},toString:function(){return this.prefix+":*"}},(function(e){this.prefix=e})),F.NameTestQName=F.makeNodeTestType(F.NAMETESTQNAME,{matches:function(e,t){return F.isNodeType([1,2,G.XPATH_NAMESPACE_NODE])(e)&&F.nameSpaceMatches(this.prefix,t,e)&&F.localNameMatches(this.localName,t,e)},toString:function(){return this.name}},(function(e){var t=e.split(":");this.name=e,this.prefix=t.length>1?t[0]:null,this.localName=t[t.length>1?1:0]})),F.PITest=F.makeNodeTestType(F.PI,{matches:function(e,t){return F.isNodeType([7])(e)&&(e.target||e.nodeName)===this.name},toString:function(){return o('processing-instruction("','")',this.name)}},(function(e){this.name=e})),F.nameTestAny=F.makeNodeTypeTest(F.NAMETESTANY,[1,2,G.XPATH_NAMESPACE_NODE],"*"),F.textTest=F.makeNodeTypeTest(F.TEXT,[3,4],"text()"),F.commentTest=F.makeNodeTypeTest(F.COMMENT,[8],"comment()"),F.nodeTest=F.makeNodeTypeTest(F.NODE,[1,2,3,4,7,8,9],"node()"),F.anyPiTest=F.makeNodeTypeTest(F.PI,[7],"processing-instruction()"),j.prototype=new p,j.prototype.constructor=j,j.superclass=p.prototype,j.prototype.init=function(e){this.variable=e},j.prototype.toString=function(){return"$"+this.variable},j.prototype.evaluate=function(e){var t=Q.resolveQName(this.variable,e.namespaceResolver,e.contextNode,!1);if(null==t[0])throw new Error("Cannot resolve QName "+fn);var r=e.variableResolver.getVariable(t[1],t[0]);if(!r)throw $.fromMessage("Undeclared variable: "+this.toString());return r},U.prototype=new p,U.prototype.constructor=U,U.superclass=p.prototype,U.prototype.init=function(e,t){this.functionName=e,this.arguments=t},U.prototype.toString=function(){for(var e=this.functionName+"(",t=0;t<this.arguments.length;t++)t>0&&(e+=", "),e+=this.arguments[t].toString();return e+")"},U.prototype.evaluate=function(e){var t=K.getFunctionFromContext(this.functionName,e);if(!t)throw new Error("Unknown function "+this.functionName);var r=[e].concat(this.arguments);return t.apply(e.functionResolver.thisArg,r)};var B=new Object;function q(e){arguments.length>0&&this.init(e)}function M(e){arguments.length>0&&this.init(e)}function H(e){arguments.length>0&&this.init(e)}function V(e){this.init(e)}function W(){this.init()}function G(e,t,r){this.isXPathNamespace=!0,this.ownerDocument=r.ownerDocument,this.nodeName="#namespace",this.prefix=e,this.localName=e,this.namespaceURI=t,this.nodeValue=t,this.ownerElement=r,this.nodeType=G.XPATH_NAMESPACE_NODE}function z(e,t,r){this.variableResolver=null!=e?e:new X,this.namespaceResolver=null!=t?t:new Y,this.functionResolver=null!=r?r:new K}function X(){}function K(e){this.thisArg=null!=e?e:J,this.functions=new Object,this.addStandardFunctions()}function Y(){}B.equals=function(e,t){return e.equals(t)},B.notequal=function(e,t){return e.notequal(t)},B.lessthan=function(e,t){return e.lessthan(t)},B.greaterthan=function(e,t){return e.greaterthan(t)},B.lessthanorequal=function(e,t){return e.lessthanorequal(t)},B.greaterthanorequal=function(e,t){return e.greaterthanorequal(t)},q.prototype=new p,q.prototype.constructor=q,q.superclass=p.prototype,q.prototype.init=function(e){this.str=String(e)},q.prototype.toString=function(){return this.str},q.prototype.evaluate=function(e){return this},q.prototype.string=function(){return this},q.prototype.number=function(){return new M(this.str)},q.prototype.bool=function(){return new H(this.str)},q.prototype.nodeset=function(){throw new Error("Cannot convert string to nodeset")},q.prototype.stringValue=function(){return this.str},q.prototype.numberValue=function(){return this.number().numberValue()},q.prototype.booleanValue=function(){return this.bool().booleanValue()},q.prototype.equals=function(e){return Q.instance_of(e,H)?this.bool().equals(e):Q.instance_of(e,M)?this.number().equals(e):Q.instance_of(e,W)?e.compareWithString(this,B.equals):new H(this.str==e.str)},q.prototype.notequal=function(e){return Q.instance_of(e,H)?this.bool().notequal(e):Q.instance_of(e,M)?this.number().notequal(e):Q.instance_of(e,W)?e.compareWithString(this,B.notequal):new H(this.str!=e.str)},q.prototype.lessthan=function(e){return this.number().lessthan(e)},q.prototype.greaterthan=function(e){return this.number().greaterthan(e)},q.prototype.lessthanorequal=function(e){return this.number().lessthanorequal(e)},q.prototype.greaterthanorequal=function(e){return this.number().greaterthanorequal(e)},M.prototype=new p,M.prototype.constructor=M,M.superclass=p.prototype,M.prototype.init=function(e){this.num="string"==typeof e?this.parse(e):Number(e)},M.prototype.numberFormat=/^\s*-?[0-9]*\.?[0-9]+\s*$/,M.prototype.parse=function(e){return this.numberFormat.test(e)?parseFloat(e):Number.NaN},M.prototype.toString=function(){var e=this.num.toString();return-1!==e.indexOf("e-")?function(e){for(var t=e.split("e-"),r=t[0].replace(".",""),n=Number(t[1]),s=0;s<n-1;s+=1)r="0"+r;return"0."+r}(e):-1!==e.indexOf("e")?function(e){for(var t=e.split("e"),r=t[0].replace(".",""),n=Number(t[1])+1-r.length,s=0;s<n;s+=1)r+="0";return r}(e):e},M.prototype.evaluate=function(e){return this},M.prototype.string=function(){return new q(this.toString())},M.prototype.number=function(){return this},M.prototype.bool=function(){return new H(this.num)},M.prototype.nodeset=function(){throw new Error("Cannot convert number to nodeset")},M.prototype.stringValue=function(){return this.string().stringValue()},M.prototype.numberValue=function(){return this.num},M.prototype.booleanValue=function(){return this.bool().booleanValue()},M.prototype.negate=function(){return new M(-this.num)},M.prototype.equals=function(e){return Q.instance_of(e,H)?this.bool().equals(e):Q.instance_of(e,q)?this.equals(e.number()):Q.instance_of(e,W)?e.compareWithNumber(this,B.equals):new H(this.num==e.num)},M.prototype.notequal=function(e){return Q.instance_of(e,H)?this.bool().notequal(e):Q.instance_of(e,q)?this.notequal(e.number()):Q.instance_of(e,W)?e.compareWithNumber(this,B.notequal):new H(this.num!=e.num)},M.prototype.lessthan=function(e){return Q.instance_of(e,W)?e.compareWithNumber(this,B.greaterthan):Q.instance_of(e,H)||Q.instance_of(e,q)?this.lessthan(e.number()):new H(this.num<e.num)},M.prototype.greaterthan=function(e){return Q.instance_of(e,W)?e.compareWithNumber(this,B.lessthan):Q.instance_of(e,H)||Q.instance_of(e,q)?this.greaterthan(e.number()):new H(this.num>e.num)},M.prototype.lessthanorequal=function(e){return Q.instance_of(e,W)?e.compareWithNumber(this,B.greaterthanorequal):Q.instance_of(e,H)||Q.instance_of(e,q)?this.lessthanorequal(e.number()):new H(this.num<=e.num)},M.prototype.greaterthanorequal=function(e){return Q.instance_of(e,W)?e.compareWithNumber(this,B.lessthanorequal):Q.instance_of(e,H)||Q.instance_of(e,q)?this.greaterthanorequal(e.number()):new H(this.num>=e.num)},M.prototype.plus=function(e){return new M(this.num+e.num)},M.prototype.minus=function(e){return new M(this.num-e.num)},M.prototype.multiply=function(e){return new M(this.num*e.num)},M.prototype.div=function(e){return new M(this.num/e.num)},M.prototype.mod=function(e){return new M(this.num%e.num)},H.prototype=new p,H.prototype.constructor=H,H.superclass=p.prototype,H.prototype.init=function(e){this.b=Boolean(e)},H.prototype.toString=function(){return this.b.toString()},H.prototype.evaluate=function(e){return this},H.prototype.string=function(){return new q(this.b)},H.prototype.number=function(){return new M(this.b)},H.prototype.bool=function(){return this},H.prototype.nodeset=function(){throw new Error("Cannot convert boolean to nodeset")},H.prototype.stringValue=function(){return this.string().stringValue()},H.prototype.numberValue=function(){return this.number().numberValue()},H.prototype.booleanValue=function(){return this.b},H.prototype.not=function(){return new H(!this.b)},H.prototype.equals=function(e){return Q.instance_of(e,q)||Q.instance_of(e,M)?this.equals(e.bool()):Q.instance_of(e,W)?e.compareWithBoolean(this,B.equals):new H(this.b==e.b)},H.prototype.notequal=function(e){return Q.instance_of(e,q)||Q.instance_of(e,M)?this.notequal(e.bool()):Q.instance_of(e,W)?e.compareWithBoolean(this,B.notequal):new H(this.b!=e.b)},H.prototype.lessthan=function(e){return this.number().lessthan(e)},H.prototype.greaterthan=function(e){return this.number().greaterthan(e)},H.prototype.lessthanorequal=function(e){return this.number().lessthanorequal(e)},H.prototype.greaterthanorequal=function(e){return this.number().greaterthanorequal(e)},H.true_=new H(!0),H.false_=new H(!1),V.prototype=new Object,V.prototype.constructor=V,V.superclass=Object.prototype,V.prototype.init=function(e){this.left=null,this.right=null,this.node=e,this.depth=1},V.prototype.balance=function(){var e=null==this.left?0:this.left.depth,t=null==this.right?0:this.right.depth;if(e>t+1)(null==this.left.left?0:this.left.left.depth)<(null==this.left.right?0:this.left.right.depth)&&this.left.rotateRR(),this.rotateLL();else if(e+1<t){var r=null==this.right.right?0:this.right.right.depth;(null==this.right.left?0:this.right.left.depth)>r&&this.right.rotateLL(),this.rotateRR()}},V.prototype.rotateLL=function(){var e=this.node,t=this.right;this.node=this.left.node,this.right=this.left,this.left=this.left.left,this.right.left=this.right.right,this.right.right=t,this.right.node=e,this.right.updateInNewLocation(),this.updateInNewLocation()},V.prototype.rotateRR=function(){var e=this.node,t=this.left;this.node=this.right.node,this.left=this.right,this.right=this.right.right,this.left.right=this.left.left,this.left.left=t,this.left.node=e,this.left.updateInNewLocation(),this.updateInNewLocation()},V.prototype.updateInNewLocation=function(){this.getDepthFromChildren()},V.prototype.getDepthFromChildren=function(){this.depth=null==this.node?0:1,null!=this.left&&(this.depth=this.left.depth+1),null!=this.right&&this.depth<=this.right.depth&&(this.depth=this.right.depth+1)},V.prototype.add=function(e){if(e===this.node)return!1;var t=function(e,t){if(e===t)return 0;if(e.compareDocumentPosition){var r=e.compareDocumentPosition(t);return 1&r||10&r?1:20&r?-1:0}for(var n=0,s=0,i=e;null!=i;i=i.parentNode||i.ownerElement)n++;for(var o=t;null!=o;o=o.parentNode||o.ownerElement)s++;if(n>s){for(;n>s;)e=e.parentNode||e.ownerElement,n--;if(e===t)return 1}else if(s>n){for(;s>n;)t=t.parentNode||t.ownerElement,s--;if(e===t)return-1}for(var a=e.parentNode||e.ownerElement,u=t.parentNode||t.ownerElement;a!==u;)t=u,a=(e=a).parentNode||e.ownerElement,u=t.parentNode||t.ownerElement;var h=Q.isAttribute(e),l=Q.isAttribute(t);if(h&&!l)return-1;if(!h&&l)return 1;if(a)for(var c=h?a.attributes:a.childNodes,p=c.length,d=0;d<p;d+=1){var f=c[d];if(f===e)return-1;if(f===t)return 1}throw new Error("Unexpected: could not determine node order")}(e,this.node),r=!1;return-1==t?null==this.left?(this.left=new V(e),r=!0):(r=this.left.add(e))&&this.balance():1==t&&(null==this.right?(this.right=new V(e),r=!0):(r=this.right.add(e))&&this.balance()),r&&this.getDepthFromChildren(),r},W.prototype=new p,W.prototype.constructor=W,W.superclass=p.prototype,W.prototype.init=function(){this.tree=null,this.nodes=[],this.size=0},W.prototype.toString=function(){var e=this.first();return null==e?"":this.stringForNode(e)},W.prototype.evaluate=function(e){return this},W.prototype.string=function(){return new q(this.toString())},W.prototype.stringValue=function(){return this.toString()},W.prototype.number=function(){return new M(this.string())},W.prototype.numberValue=function(){return Number(this.string())},W.prototype.bool=function(){return new H(this.booleanValue())},W.prototype.booleanValue=function(){return!!this.size},W.prototype.nodeset=function(){return this},W.prototype.stringForNode=function(e){return 9==e.nodeType||1==e.nodeType||11===e.nodeType?this.stringForContainerNode(e):2===e.nodeType?e.value||e.nodeValue:e.isNamespaceNode?e.namespace:e.nodeValue},W.prototype.stringForContainerNode=function(e){for(var t="",r=e.firstChild;null!=r;r=r.nextSibling){var n=r.nodeType;1!==n&&3!==n&&4!==n&&9!==n&&11!==n||(t+=this.stringForNode(r))}return t},W.prototype.buildTree=function(){if(!this.tree&&this.nodes.length){this.tree=new V(this.nodes[0]);for(var e=1;e<this.nodes.length;e+=1)this.tree.add(this.nodes[e])}return this.tree},W.prototype.first=function(){var e=this.buildTree();if(null==e)return null;for(;null!=e.left;)e=e.left;return e.node},W.prototype.add=function(e){for(var t=0;t<this.nodes.length;t+=1)if(e===this.nodes[t])return;this.tree=null,this.nodes.push(e),this.size+=1},W.prototype.addArray=function(e){var r=this;t((function(e){r.add(e)}),e)},W.prototype.toArray=function(){var e=[];return this.toArrayRec(this.buildTree(),e),e},W.prototype.toArrayRec=function(e,t){null!=e&&(this.toArrayRec(e.left,t),t.push(e.node),this.toArrayRec(e.right,t))},W.prototype.toUnsortedArray=function(){return this.nodes.slice()},W.prototype.compareWithString=function(e,t){for(var r=this.toUnsortedArray(),n=0;n<r.length;n++){var s=r[n],i=t(new q(this.stringForNode(s)),e);if(i.booleanValue())return i}return new H(!1)},W.prototype.compareWithNumber=function(e,t){for(var r=this.toUnsortedArray(),n=0;n<r.length;n++){var s=r[n],i=t(new M(this.stringForNode(s)),e);if(i.booleanValue())return i}return new H(!1)},W.prototype.compareWithBoolean=function(e,t){return t(this.bool(),e)},W.prototype.compareWithNodeSet=function(e,t){for(var r=this.toUnsortedArray(),n=function(e,r){return t(r,e)},s=0;s<r.length;s++){var i=new q(this.stringForNode(r[s])),o=e.compareWithString(i,n);if(o.booleanValue())return o}return new H(!1)},W.compareWith=function(e){var t=Array.prototype.slice,r=e.length,n=function(e,r){return function(){return r.apply(this,e.concat(t.call(arguments)))}},s=function(){var i=t.call(arguments);return i.length<r?n(i,s):e.apply(this,t.apply(arguments,[0,r]))};return s}((function(e,t){return Q.instance_of(t,q)?this.compareWithString(t,e):Q.instance_of(t,M)?this.compareWithNumber(t,e):Q.instance_of(t,H)?this.compareWithBoolean(t,e):this.compareWithNodeSet(t,e)})),W.prototype.equals=W.compareWith(B.equals),W.prototype.notequal=W.compareWith(B.notequal),W.prototype.lessthan=W.compareWith(B.lessthan),W.prototype.greaterthan=W.compareWith(B.greaterthan),W.prototype.lessthanorequal=W.compareWith(B.lessthanorequal),W.prototype.greaterthanorequal=W.compareWith(B.greaterthanorequal),W.prototype.union=function(e){var t=new W;return t.addArray(this.toUnsortedArray()),t.addArray(e.toUnsortedArray()),t},G.prototype=new Object,G.prototype.constructor=G,G.superclass=Object.prototype,G.prototype.toString=function(){return'{ "'+this.prefix+'", "'+this.namespaceURI+'" }'},z.prototype=new Object,z.prototype.constructor=z,z.superclass=Object.prototype,z.prototype.extend=function(e){return u(new z,this,e)},X.prototype=new Object,X.prototype.constructor=X,X.superclass=Object.prototype,X.prototype.getVariable=function(e,t){return null},K.prototype=new Object,K.prototype.constructor=K,K.superclass=Object.prototype,K.prototype.addStandardFunctions=function(){this.functions["{}last"]=J.last,this.functions["{}position"]=J.position,this.functions["{}count"]=J.count,this.functions["{}id"]=J.id,this.functions["{}local-name"]=J.localName,this.functions["{}namespace-uri"]=J.namespaceURI,this.functions["{}name"]=J.name,this.functions["{}string"]=J.string,this.functions["{}concat"]=J.concat,this.functions["{}starts-with"]=J.startsWith,this.functions["{}contains"]=J.contains,this.functions["{}substring-before"]=J.substringBefore,this.functions["{}substring-after"]=J.substringAfter,this.functions["{}substring"]=J.substring,this.functions["{}string-length"]=J.stringLength,this.functions["{}normalize-space"]=J.normalizeSpace,this.functions["{}translate"]=J.translate,this.functions["{}boolean"]=J.boolean_,this.functions["{}not"]=J.not,this.functions["{}true"]=J.true_,this.functions["{}false"]=J.false_,this.functions["{}lang"]=J.lang,this.functions["{}number"]=J.number,this.functions["{}sum"]=J.sum,this.functions["{}floor"]=J.floor,this.functions["{}ceiling"]=J.ceiling,this.functions["{}round"]=J.round},K.prototype.addFunction=function(e,t,r){this.functions["{"+e+"}"+t]=r},K.getFunctionFromContext=function(e,t){var r=Q.resolveQName(e,t.namespaceResolver,t.contextNode,!1);if(null===r[0])throw new Error("Cannot resolve QName "+name);return t.functionResolver.getFunction(r[1],r[0])},K.prototype.getFunction=function(e,t){return this.functions["{"+t+"}"+e]},Y.prototype=new Object,Y.prototype.constructor=Y,Y.superclass=Object.prototype,Y.prototype.getNamespace=function(e,t){if("xml"==e)return l.XML_NAMESPACE_URI;if("xmlns"==e)return l.XMLNS_NAMESPACE_URI;for(9==t.nodeType?t=t.documentElement:2==t.nodeType?t=R.getOwnerElement(t):1!=t.nodeType&&(t=t.parentNode);null!=t&&1==t.nodeType;){for(var r=t.attributes,n=0;n<r.length;n++){var s=r.item(n),i=s.name||s.nodeName;if("xmlns"===i&&""===e||i==="xmlns:"+e)return String(s.value||s.nodeValue)}t=t.parentNode}return null};var J=new Object;J.last=function(e){if(1!=arguments.length)throw new Error("Function last expects ()");return new M(e.contextSize)},J.position=function(e){if(1!=arguments.length)throw new Error("Function position expects ()");return new M(e.contextPosition)},J.count=function(){var e,t=arguments[0];if(2!=arguments.length||!Q.instance_of(e=arguments[1].evaluate(t),W))throw new Error("Function count expects (node-set)");return new M(e.size)},J.id=function(){var e,t=arguments[0];if(2!=arguments.length)throw new Error("Function id expects (object)");e=arguments[1].evaluate(t);for(var r=(e=Q.instance_of(e,W)?e.toArray().join(" "):e.stringValue()).split(/[\x0d\x0a\x09\x20]+/),n=new W,s=9==t.contextNode.nodeType?t.contextNode:t.contextNode.ownerDocument,i=0;i<r.length;i++){var o;null!=(o=s.getElementById?s.getElementById(r[i]):Q.getElementById(s,r[i]))&&(n.add(o))}return n},J.localName=function(e,t){var r;if(1==arguments.length)r=e.contextNode;else{if(2!=arguments.length)throw new Error("Function local-name expects (node-set?)");r=t.evaluate(e).first()}return new q(null==r?"":r.localName||r.baseName||r.target||r.nodeName||"")},J.namespaceURI=function(){var e,t=arguments[0];if(1==arguments.length)e=t.contextNode;else{if(2!=arguments.length)throw new Error("Function namespace-uri expects (node-set?)");e=arguments[1].evaluate(t).first()}return new q(null==e?"":e.namespaceURI)},J.name=function(){var e,t=arguments[0];if(1==arguments.length)e=t.contextNode;else{if(2!=arguments.length)throw new Error("Function name expects (node-set?)");e=arguments[1].evaluate(t).first()}return null==e?new q(""):1==e.nodeType?new q(e.nodeName):2==e.nodeType?new q(e.name||e.nodeName):7===e.nodeType?new q(e.target||e.nodeName):null==e.localName?new q(""):new q(e.localName)},J.string=function(){var e=arguments[0];if(1==arguments.length)return new q(W.prototype.stringForNode(e.contextNode));if(2==arguments.length)return arguments[1].evaluate(e).string();throw new Error("Function string expects (object?)")},J.concat=function(e){if(arguments.length<3)throw new Error("Function concat expects (string, string[, string]*)");for(var t="",r=1;r<arguments.length;r++)t+=arguments[r].evaluate(e).stringValue();return new q(t)},J.startsWith=function(){var e=arguments[0];if(3!=arguments.length)throw new Error("Function startsWith expects (string, string)");var t=arguments[1].evaluate(e).stringValue(),r=arguments[2].evaluate(e).stringValue();return new H(t.substring(0,r.length)==r)},J.contains=function(){var e=arguments[0];if(3!=arguments.length)throw new Error("Function contains expects (string, string)");var t=arguments[1].evaluate(e).stringValue(),r=arguments[2].evaluate(e).stringValue();return new H(-1!==t.indexOf(r))},J.substringBefore=function(){var e=arguments[0];if(3!=arguments.length)throw new Error("Function substring-before expects (string, string)");var t=arguments[1].evaluate(e).stringValue(),r=arguments[2].evaluate(e).stringValue();return new q(t.substring(0,t.indexOf(r)))},J.substringAfter=function(){var e=arguments[0];if(3!=arguments.length)throw new Error("Function substring-after expects (string, string)");var t=arguments[1].evaluate(e).stringValue(),r=arguments[2].evaluate(e).stringValue();if(0==r.length)return new q(t);var n=t.indexOf(r);return new q(-1==n?"":t.substring(n+r.length))},J.substring=function(){var e=arguments[0];if(3!=arguments.length&&4!=arguments.length)throw new Error("Function substring expects (string, number, number?)");var t=arguments[1].evaluate(e).stringValue(),r=Math.round(arguments[2].evaluate(e).numberValue())-1,n=4==arguments.length?r+Math.round(arguments[3].evaluate(e).numberValue()):void 0;return new q(t.substring(r,n))},J.stringLength=function(){var e,t=arguments[0];if(1==arguments.length)e=W.prototype.stringForNode(t.contextNode);else{if(2!=arguments.length)throw new Error("Function string-length expects (string?)");e=arguments[1].evaluate(t).stringValue()}return new M(e.length)},J.normalizeSpace=function(){var e,t=arguments[0];if(1==arguments.length)e=W.prototype.stringForNode(t.contextNode);else{if(2!=arguments.length)throw new Error("Function normalize-space expects (string?)");e=arguments[1].evaluate(t).stringValue()}for(var r=0,n=e.length-1;Q.isSpace(e.charCodeAt(n));)n--;for(var s="";r<=n&&Q.isSpace(e.charCodeAt(r));)r++;for(;r<=n;)if(Q.isSpace(e.charCodeAt(r)))for(s+=" ";r<=n&&Q.isSpace(e.charCodeAt(r));)r++;else s+=e.charAt(r),r++;return new q(s)},J.translate=function(e,t,s,o){if(4!=arguments.length)throw new Error("Function translate expects (string, string, string)");var a=t.evaluate(e).stringValue(),u=s.evaluate(e).stringValue(),h=o.evaluate(e).stringValue(),l=r((function(e,t,r){return t in e||(e[t]=r>h.length?"":h[r]),e}),{},u),c=i("",n((function(e){return e in l?l[e]:e}),a));return new q(c)},J.boolean_=function(){var e=arguments[0];if(2!=arguments.length)throw new Error("Function boolean expects (object)");return arguments[1].evaluate(e).bool()},J.not=function(e,t){if(2!=arguments.length)throw new Error("Function not expects (object)");return t.evaluate(e).bool().not()},J.true_=function(){if(1!=arguments.length)throw new Error("Function true expects ()");return H.true_},J.false_=function(){if(1!=arguments.length)throw new Error("Function false expects ()");return H.false_},J.lang=function(){var e,t=arguments[0];if(2!=arguments.length)throw new Error("Function lang expects (string)");for(var r=t.contextNode;null!=r&&9!=r.nodeType;r=r.parentNode){var n=r.getAttributeNS(l.XML_NAMESPACE_URI,"lang");if(null!=n){e=String(n);break}}if(null==e)return H.false_;var s=arguments[1].evaluate(t).stringValue();return new H(e.substring(0,s.length)==s&&(e.length==s.length||"-"==e.charAt(s.length)))},J.number=function(){var e=arguments[0];if(1!=arguments.length&&2!=arguments.length)throw new Error("Function number expects (object?)");return 1==arguments.length?new M(W.prototype.stringForNode(e.contextNode)):arguments[1].evaluate(e).number()},J.sum=function(){var e,t=arguments[0];if(2!=arguments.length||!Q.instance_of(e=arguments[1].evaluate(t),W))throw new Error("Function sum expects (node-set)");e=e.toUnsortedArray();for(var r=0,n=0;n<e.length;n++)r+=new M(W.prototype.stringForNode(e[n])).numberValue();return new M(r)},J.floor=function(){var e=arguments[0];if(2!=arguments.length)throw new Error("Function floor expects (number)");return new M(Math.floor(arguments[1].evaluate(e).numberValue()))},J.ceiling=function(){var e=arguments[0];if(2!=arguments.length)throw new Error("Function ceiling expects (number)");return new M(Math.ceil(arguments[1].evaluate(e).numberValue()))},J.round=function(){var e=arguments[0];if(2!=arguments.length)throw new Error("Function round expects (number)");return new M(Math.round(arguments[1].evaluate(e).numberValue()))};var Q=new Object;Q.isAttribute=function(e){return e&&(2===e.nodeType||e.ownerElement)},Q.splitQName=function(e){var t=e.indexOf(":");return-1==t?[null,e]:[e.substring(0,t),e.substring(t+1)]},Q.resolveQName=function(e,t,r,n){var s=Q.splitQName(e);return null!=s[0]?s[0]=t.getNamespace(s[0],r):n?(s[0]=t.getNamespace("",r),null==s[0]&&(s[0]="")):s[0]="",s},Q.isSpace=function(e){return 9==e||13==e||10==e||32==e},Q.isLetter=function(e){return e>=65&&e<=90||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=255||e>=256&&e<=305||e>=308&&e<=318||e>=321&&e<=328||e>=330&&e<=382||e>=384&&e<=451||e>=461&&e<=496||e>=500&&e<=501||e>=506&&e<=535||e>=592&&e<=680||e>=699&&e<=705||902==e||e>=904&&e<=906||908==e||e>=910&&e<=929||e>=931&&e<=974||e>=976&&e<=982||986==e||988==e||990==e||992==e||e>=994&&e<=1011||e>=1025&&e<=1036||e>=1038&&e<=1103||e>=1105&&e<=1116||e>=1118&&e<=1153||e>=1168&&e<=1220||e>=1223&&e<=1224||e>=1227&&e<=1228||e>=1232&&e<=1259||e>=1262&&e<=1269||e>=1272&&e<=1273||e>=1329&&e<=1366||1369==e||e>=1377&&e<=1414||e>=1488&&e<=1514||e>=1520&&e<=1522||e>=1569&&e<=1594||e>=1601&&e<=1610||e>=1649&&e<=1719||e>=1722&&e<=1726||e>=1728&&e<=1742||e>=1744&&e<=1747||1749==e||e>=1765&&e<=1766||e>=2309&&e<=2361||2365==e||e>=2392&&e<=2401||e>=2437&&e<=2444||e>=2447&&e<=2448||e>=2451&&e<=2472||e>=2474&&e<=2480||2482==e||e>=2486&&e<=2489||e>=2524&&e<=2525||e>=2527&&e<=2529||e>=2544&&e<=2545||e>=2565&&e<=2570||e>=2575&&e<=2576||e>=2579&&e<=2600||e>=2602&&e<=2608||e>=2610&&e<=2611||e>=2613&&e<=2614||e>=2616&&e<=2617||e>=2649&&e<=2652||2654==e||e>=2674&&e<=2676||e>=2693&&e<=2699||2701==e||e>=2703&&e<=2705||e>=2707&&e<=2728||e>=2730&&e<=2736||e>=2738&&e<=2739||e>=2741&&e<=2745||2749==e||2784==e||e>=2821&&e<=2828||e>=2831&&e<=2832||e>=2835&&e<=2856||e>=2858&&e<=2864||e>=2866&&e<=2867||e>=2870&&e<=2873||2877==e||e>=2908&&e<=2909||e>=2911&&e<=2913||e>=2949&&e<=2954||e>=2958&&e<=2960||e>=2962&&e<=2965||e>=2969&&e<=2970||2972==e||e>=2974&&e<=2975||e>=2979&&e<=2980||e>=2984&&e<=2986||e>=2990&&e<=2997||e>=2999&&e<=3001||e>=3077&&e<=3084||e>=3086&&e<=3088||e>=3090&&e<=3112||e>=3114&&e<=3123||e>=3125&&e<=3129||e>=3168&&e<=3169||e>=3205&&e<=3212||e>=3214&&e<=3216||e>=3218&&e<=3240||e>=3242&&e<=3251||e>=3253&&e<=3257||3294==e||e>=3296&&e<=3297||e>=3333&&e<=3340||e>=3342&&e<=3344||e>=3346&&e<=3368||e>=3370&&e<=3385||e>=3424&&e<=3425||e>=3585&&e<=3630||3632==e||e>=3634&&e<=3635||e>=3648&&e<=3653||e>=3713&&e<=3714||3716==e||e>=3719&&e<=3720||3722==e||3725==e||e>=3732&&e<=3735||e>=3737&&e<=3743||e>=3745&&e<=3747||3749==e||3751==e||e>=3754&&e<=3755||e>=3757&&e<=3758||3760==e||e>=3762&&e<=3763||3773==e||e>=3776&&e<=3780||e>=3904&&e<=3911||e>=3913&&e<=3945||e>=4256&&e<=4293||e>=4304&&e<=4342||4352==e||e>=4354&&e<=4355||e>=4357&&e<=4359||4361==e||e>=4363&&e<=4364||e>=4366&&e<=4370||4412==e||4414==e||4416==e||4428==e||4430==e||4432==e||e>=4436&&e<=4437||4441==e||e>=4447&&e<=4449||4451==e||4453==e||4455==e||4457==e||e>=4461&&e<=4462||e>=4466&&e<=4467||4469==e||4510==e||4520==e||4523==e||e>=4526&&e<=4527||e>=4535&&e<=4536||4538==e||e>=4540&&e<=4546||4587==e||4592==e||4601==e||e>=7680&&e<=7835||e>=7840&&e<=7929||e>=7936&&e<=7957||e>=7960&&e<=7965||e>=7968&&e<=8005||e>=8008&&e<=8013||e>=8016&&e<=8023||8025==e||8027==e||8029==e||e>=8031&&e<=8061||e>=8064&&e<=8116||e>=8118&&e<=8124||8126==e||e>=8130&&e<=8132||e>=8134&&e<=8140||e>=8144&&e<=8147||e>=8150&&e<=8155||e>=8160&&e<=8172||e>=8178&&e<=8180||e>=8182&&e<=8188||8486==e||e>=8490&&e<=8491||8494==e||e>=8576&&e<=8578||e>=12353&&e<=12436||e>=12449&&e<=12538||e>=12549&&e<=12588||e>=44032&&e<=55203||e>=19968&&e<=40869||12295==e||e>=12321&&e<=12329},Q.isNCNameChar=function(e){return e>=48&&e<=57||e>=1632&&e<=1641||e>=1776&&e<=1785||e>=2406&&e<=2415||e>=2534&&e<=2543||e>=2662&&e<=2671||e>=2790&&e<=2799||e>=2918&&e<=2927||e>=3047&&e<=3055||e>=3174&&e<=3183||e>=3302&&e<=3311||e>=3430&&e<=3439||e>=3664&&e<=3673||e>=3792&&e<=3801||e>=3872&&e<=3881||46==e||45==e||95==e||Q.isLetter(e)||e>=768&&e<=837||e>=864&&e<=865||e>=1155&&e<=1158||e>=1425&&e<=1441||e>=1443&&e<=1465||e>=1467&&e<=1469||1471==e||e>=1473&&e<=1474||1476==e||e>=1611&&e<=1618||1648==e||e>=1750&&e<=1756||e>=1757&&e<=1759||e>=1760&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e>=2305&&e<=2307||2364==e||e>=2366&&e<=2380||2381==e||e>=2385&&e<=2388||e>=2402&&e<=2403||e>=2433&&e<=2435||2492==e||2494==e||2495==e||e>=2496&&e<=2500||e>=2503&&e<=2504||e>=2507&&e<=2509||2519==e||e>=2530&&e<=2531||2562==e||2620==e||2622==e||2623==e||e>=2624&&e<=2626||e>=2631&&e<=2632||e>=2635&&e<=2637||e>=2672&&e<=2673||e>=2689&&e<=2691||2748==e||e>=2750&&e<=2757||e>=2759&&e<=2761||e>=2763&&e<=2765||e>=2817&&e<=2819||2876==e||e>=2878&&e<=2883||e>=2887&&e<=2888||e>=2891&&e<=2893||e>=2902&&e<=2903||e>=2946&&e<=2947||e>=3006&&e<=3010||e>=3014&&e<=3016||e>=3018&&e<=3021||3031==e||e>=3073&&e<=3075||e>=3134&&e<=3140||e>=3142&&e<=3144||e>=3146&&e<=3149||e>=3157&&e<=3158||e>=3202&&e<=3203||e>=3262&&e<=3268||e>=3270&&e<=3272||e>=3274&&e<=3277||e>=3285&&e<=3286||e>=3330&&e<=3331||e>=3390&&e<=3395||e>=3398&&e<=3400||e>=3402&&e<=3405||3415==e||3633==e||e>=3636&&e<=3642||e>=3655&&e<=3662||3761==e||e>=3764&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=3864&&e<=3865||3893==e||3895==e||3897==e||3902==e||3903==e||e>=3953&&e<=3972||e>=3974&&e<=3979||e>=3984&&e<=3989||3991==e||e>=3993&&e<=4013||e>=4017&&e<=4023||4025==e||e>=8400&&e<=8412||8417==e||e>=12330&&e<=12335||12441==e||12442==e||183==e||720==e||721==e||903==e||1600==e||3654==e||3782==e||12293==e||e>=12337&&e<=12341||e>=12445&&e<=12446||e>=12540&&e<=12542},Q.coalesceText=function(e){for(var t=e.firstChild;null!=t;t=t.nextSibling)if(3==t.nodeType||4==t.nodeType){var r=t.nodeValue,n=t;for(t=t.nextSibling;null!=t&&(3==t.nodeType||4==t.nodeType);){r+=t.nodeValue;var s=t;t=t.nextSibling,s.parentNode.removeChild(s)}if(4==n.nodeType){var i=n.parentNode;if(null==n.nextSibling)i.removeChild(n),i.appendChild(i.ownerDocument.createTextNode(r));else{var o=n.nextSibling;i.removeChild(n),i.insertBefore(i.ownerDocument.createTextNode(r),o)}}else n.nodeValue=r;if(null==t)break}else 1==t.nodeType&&Q.coalesceText(t)},Q.instance_of=function(e,t){for(;null!=e;){if(e.constructor===t)return!0;if(e===Object)return!1;e=e.constructor.superclass}return!1},Q.getElementById=function(e,t){if(1==e.nodeType&&(e.getAttribute("id")==t||e.getAttributeNS(null,"id")==t))return e;for(var r=e.firstChild;null!=r;r=r.nextSibling){var n=Q.getElementById(r,t);if(null!=n)return n}return null};var $=function(){function e(t,r,n){var s=Error.call(this,function(t,r){var n=r?": "+r.toString():"";switch(t){case e.INVALID_EXPRESSION_ERR:return"Invalid expression"+n;case e.TYPE_ERR:return"Type error"+n}return null}(t,r)||n);return s.code=t,s.exception=r,s}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.superclass=Error,e.prototype.toString=function(){return this.message},e.fromMessage=function(t,r){return new e(null,r,t)},e.INVALID_EXPRESSION_ERR=51,e.TYPE_ERR=52,e}();function Z(e,t,r){this.xpath=r.parse(e),this.context=new z,this.context.namespaceResolver=new ee(t)}function ee(e){this.xpathNSResolver=e}function te(e){this.node=e,this.namespaceResolver=new Y}function re(e,t){switch(t==re.ANY_TYPE&&(e.constructor===q?t=re.STRING_TYPE:e.constructor===M?t=re.NUMBER_TYPE:e.constructor===H?t=re.BOOLEAN_TYPE:e.constructor===W&&(t=re.UNORDERED_NODE_ITERATOR_TYPE)),this.resultType=t,t){case re.NUMBER_TYPE:return void(this.numberValue=e.numberValue());case re.STRING_TYPE:return void(this.stringValue=e.stringValue());case re.BOOLEAN_TYPE:return void(this.booleanValue=e.booleanValue());case re.ANY_UNORDERED_NODE_TYPE:case re.FIRST_ORDERED_NODE_TYPE:if(e.constructor===W)return void(this.singleNodeValue=e.first());break;case re.UNORDERED_NODE_ITERATOR_TYPE:case re.ORDERED_NODE_ITERATOR_TYPE:if(e.constructor===W)return this.invalidIteratorState=!1,this.nodes=e.toArray(),void(this.iteratorIndex=0);break;case re.UNORDERED_NODE_SNAPSHOT_TYPE:case re.ORDERED_NODE_SNAPSHOT_TYPE:if(e.constructor===W)return this.nodes=e.toArray(),void(this.snapshotLength=this.nodes.length)}throw new $($.TYPE_ERR)}function ne(e,t){e.createExpression=function(e,r){try{return new Z(e,r,t)}catch(e){throw new $($.INVALID_EXPRESSION_ERR,e)}},e.createNSResolver=function(e){return new te(e)},e.evaluate=function(r,n,s,i,o){if(i<0||i>9)throw{code:0,toString:function(){return"Request type not supported"}};return e.createExpression(r,s,t).evaluate(n,i,o)}}Z.prototype={},Z.prototype.constructor=Z,Z.superclass=Object.prototype,Z.getOwnerDocument=function(e){return 9===e.nodeType?e:e.ownerDocument},Z.detectHtmlDom=function(e){if(!e)return!1;var t=Z.getOwnerDocument(e);try{return t.implementation.hasFeature("HTML","2.0")}catch(e){return!0}},Z.prototype.evaluate=function(e,t,r){return this.context.expressionContextNode=e,this.context.caseInsensitive=Z.detectHtmlDom(e),new re(this.xpath.evaluate(this.context),t)},ee.prototype={},ee.prototype.constructor=ee,ee.superclass=Object.prototype,ee.prototype.getNamespace=function(e,t){return null==this.xpathNSResolver?null:this.xpathNSResolver.lookupNamespaceURI(e)},te.prototype={},te.prototype.constructor=te,te.superclass=Object.prototype,te.prototype.lookupNamespaceURI=function(e){return this.namespaceResolver.getNamespace(e,this.node)},re.prototype={},re.prototype.constructor=re,re.superclass=Object.prototype,re.prototype.iterateNext=function(){if(this.resultType!=re.UNORDERED_NODE_ITERATOR_TYPE&&this.resultType!=re.ORDERED_NODE_ITERATOR_TYPE)throw new $($.TYPE_ERR);return this.nodes[this.iteratorIndex++]},re.prototype.snapshotItem=function(e){if(this.resultType!=re.UNORDERED_NODE_SNAPSHOT_TYPE&&this.resultType!=re.ORDERED_NODE_SNAPSHOT_TYPE)throw new $($.TYPE_ERR);return this.nodes[e]},re.ANY_TYPE=0,re.NUMBER_TYPE=1,re.STRING_TYPE=2,re.BOOLEAN_TYPE=3,re.UNORDERED_NODE_ITERATOR_TYPE=4,re.ORDERED_NODE_ITERATOR_TYPE=5,re.UNORDERED_NODE_SNAPSHOT_TYPE=6,re.ORDERED_NODE_SNAPSHOT_TYPE=7,re.ANY_UNORDERED_NODE_TYPE=8,re.FIRST_ORDERED_NODE_TYPE=9;try{var se=!0;try{document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("XPath",null)&&(se=!1)}catch(e){}se&&ne(document,new h)}catch(e){}ne(e,new h),function(){var t=new h,r=new Y,n=new K,s=new X;function i(e){return{getNamespace:function(t,n){return e(t,n)||r.getNamespace(t,n)}}}function o(e){return e&&"function"==typeof e.getNamespace?i((t=e).getNamespace.bind(t)):"function"==typeof e?i(e):"object"==typeof e?function(e){return i((function(t){return e[t]}))}(e):r;var t}function a(e){if(null==e||e instanceof q||e instanceof H||e instanceof M||e instanceof W)return e;switch(typeof e){case"string":return new q(e);case"boolean":return new H(e);case"number":return new M(e)}var t=new W;return t.addArray([].concat(e)),t}function u(e){return{getFunction:function(t,r){var s=e(t,r);return s?function(e){return function(t){var r=Array.prototype.slice.call(arguments,1).map((function(e){return e.evaluate(t)}));return a(e.apply(this,[].concat(t,r)))}}(s):n.getFunction(t,r)}}}function l(e){return e&&"function"==typeof e.getFunction?u((t=e).getFunction.bind(t)):"function"==typeof e?u(e):"object"==typeof e?function(e){return u((function(t){return e[t]}))}(e):n;var t}function c(e){return{getVariable:function(t,r){return a(e(t,r))}}}function p(e,t,r){e in r&&(t[e]=r[e])}function d(e){var t=new z;return e?(t.namespaceResolver=o(e.namespaces),t.functionResolver=l(e.functions),t.variableResolver=function(e){if(e){if("function"==typeof e.getVariable)return c(e.getVariable.bind(e));if("function"==typeof e)return c(e);if("object"==typeof e)return c((function(t){return e[t]}))}return s}(e.variables),t.expressionContextNode=e.node,p("allowAnyNamespaceForNoPrefix",t,e),p("isHtml",t,e)):t.namespaceResolver=r,t}var f={evaluate:function(e){return function(e,t){var r=d(t);return e.evaluate(r)}(this.expression,e)},evaluateNumber:function(e){return this.evaluate(e).numberValue()},evaluateString:function(e){return this.evaluate(e).stringValue()},evaluateBoolean:function(e){return this.evaluate(e).booleanValue()},evaluateNodeSet:function(e){return this.evaluate(e).nodeset()},select:function(e){return this.evaluateNodeSet(e).toArray()},select1:function(e){return this.select(e)[0]}};e.parse=function(e){var r=t.parse(e);return Object.create(f,{expression:{value:r}})}}(),u(e,{XPath:l,XPathParser:h,XPathResult:re,Step:L,PathExpr:R,NodeTest:F,LocationPath:I,OrOperation:m,AndOperation:v,BarOperation:C,EqualsOperation:_,NotEqualOperation:y,LessThanOperation:w,GreaterThanOperation:b,LessThanOrEqualOperation:O,GreaterThanOrEqualOperation:E,PlusOperation:N,MinusOperation:S,MultiplyOperation:x,DivOperation:A,ModOperation:T,UnaryMinusOperation:f,FunctionCall:U,VariableReference:j,XPathContext:z,XNodeSet:W,XBoolean:H,XString:q,XNumber:M,NamespaceResolver:Y,FunctionResolver:K,VariableResolver:X,Utilities:Q}),e.select=function(t,r,n){return e.selectWithResolver(t,r,null,n)},e.useNamespaces=function(t){var r={mappings:t||{},lookupNamespaceURI:function(e){return this.mappings[e]}};return function(t,n,s){return e.selectWithResolver(t,n,r,s)}},e.selectWithResolver=function(e,t,r,n){var s=new Z(e,r,new h),i=re.ANY_TYPE,o=s.evaluate(t,i,null);return o.resultType==re.STRING_TYPE?o=o.stringValue:o.resultType==re.NUMBER_TYPE?o=o.numberValue:o.resultType==re.BOOLEAN_TYPE?o=o.booleanValue:(o=o.nodes,n&&(o=o[0])),o},e.select1=function(t,r){return e.select(t,r,!0)}}(t)},293:(e,t,r)=>{e.exports={EventTarget:r(4399),Event:r(7525)}},7525:e=>{e.exports=function(e){this.type=e,this.isTrusted=!1,this._yaeti=!0}},4399:e=>{function t(){"function"!=typeof this.addEventListener&&(this._listeners={},this.addEventListener=r,this.removeEventListener=n,this.dispatchEvent=s)}function r(e,t){var r,n,s;if(e&&t){for(void 0===(r=this._listeners[e])&&(this._listeners[e]=r=[]),n=0;s=r[n];n++)if(s===t)return;r.push(t)}}function n(e,t){var r,n,s;if(e&&t&&void 0!==(r=this._listeners[e])){for(n=0;s=r[n];n++)if(s===t){r.splice(n,1);break}0===r.length&&delete this._listeners[e]}}function s(e){var t,r,n,s,i,o=!1;if(!e||"string"!=typeof e.type)throw new Error("`event` must have a valid `type` property");e._yaeti&&(e.target=this,e.cancelable=!0);try{e.stopImmediatePropagation=function(){o=!0}}catch(e){}for(t=e.type,r=this._listeners[t]||[],"function"==typeof(n=this["on"+t])&&n.call(this,e),s=0;(i=r[s])&&!o;s++)i.call(this,e);return!e.defaultPrevented}e.exports=t,Object.defineProperties(t.prototype,{listeners:{get:function(){return this._listeners}}})},9491:e=>{"use strict";e.exports=require("assert")},4300:e=>{"use strict";e.exports=require("buffer")},6113:e=>{"use strict";e.exports=require("crypto")},2361:e=>{"use strict";e.exports=require("events")},7147:e=>{"use strict";e.exports=require("fs")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},4404:e=>{"use strict";e.exports=require("tls")},6224:e=>{"use strict";e.exports=require("tty")},7310:e=>{"use strict";e.exports=require("url")},3837:e=>{"use strict";e.exports=require("util")},873:e=>{"use strict";e.exports={version:"1.0.34"}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return r[e](s,s.exports,i),s.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var s=Object.create(null);i.r(s);var o={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>r[e]));return o.default=()=>r,i.d(s,o),s},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";i.r(a),i.d(a,{api:()=>oe});class e{constructor(e){this._options={},this.setOpts(e)}get numOpts(){return Object.keys(this._options).length}get keys(){var e=[];for(var t in this._options)e.push(t);return e}setOpts(e){if(null!=e){var t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){}for(var r in t)this.setOpt(r,t[r])}}getOpts(){return this._options}hasOpt(e){var t=e.toLowerCase();return this._options.hasOwnProperty(t)}hasOpts(e){var t=!0;for(var r of e)0==this.hasOpt(r)&&(t=!1);return t}getOpt(e,t){var r=null,n=e.toLowerCase();return this._options.hasOwnProperty(n)&&(r=this._options[n]),null==r&&null!=t&&(r=t),r}getOptAndClear(e,t){var r=this.getOpt(e,t);return this.clearOpt(e),r}getInt(e,t){var r=0,n=this.getOpt(e,t);return null!=n&&(r=parseInt(n)),r}getArray(e,t){var r=null,n=this.getOpt(e,t);return null!=n&&Array.isArray(n)&&(r=n),r}setOpt(e,t){var r=e.toLowerCase();null==t?this._options.hasOwnProperty(r)&&(delete this._options[r],this.optionCleared(r,t)):(this._options[r]=t,this.optionSet(r,t))}clearOpt(e){var t=e.toLowerCase();this._options.hasOwnProperty(t)&&(delete this._options[t],this.optionCleared(t))}clearOpts(e){for(var t of e)this.clearOpt(t)}reset(){this._options={}}addOpts(e,t){if(null!=t)t.forEach((t=>{if(this._options.hasOwnProperty(t)){const r=this._options[t];e[t]=r instanceof Function?r.toString():r}}));else for(var r in this._options){const t=this._options[r];e[r]=t instanceof Function?t.toString():t}}optionSet(){}optionCleared(){}resolve(e){for(var t in this._options){var r=new RegExp("@"+t+"@","g");e=e.replace(r,this._options[t])}return e}clone(e){var t={};return this.addOpts(t,e),t}supports(e){var t=this.getOpt(e);return null!=t&&"function"==typeof t}toString(){return JSON.stringify(this._options)}}var t=!1;"object"==typeof process&&process.hasOwnProperty("versions")&&process.versions.hasOwnProperty("node")&&(t=!0);var r=null,n=null,u=null,h=null,l=null,c=null;if(t&&(null!=process.env.http_proxy&&(u=new URL(process.env.http_proxy)),null!=process.env.https_proxy&&(h=new URL(process.env.https_proxy)),null!=process.env.NO_PROXY)){c=[];var p=process.env.NO_PROXY.split(",");for(var d of p)c.push(d.trim())}class f{constructor(e,t,r){this._a=[],this._lower=parseFloat(e)-.01,this._upper=parseFloat(t)+.01,this._num=parseFloat(r),this._interval=(this._upper-this._lower)/this._num;for(var n=new Number(this._lower),s=0;s<this._num+1;s++)this._a.push(n),n+=this._interval}get lower(){return this._lower}get upper(){return this._upper}get interval(){return this._interval}get length(){return this._a.length}index(e){for(var t=-1,r=0;r<this._a.length-1;r++)if(e>=this._a[r]&&e<=this._a[r+1]){t=r;break}return t}createSteps(e){for(var t,r,n=[],s=0;s<this._a.length-1;s++)t=parseFloat(this._a[s]),r=parseFloat(this._a[s+1]),n.push({range:[t,r],color:e[s]});return n}toString(){return JSON.stringify(this._a)}}class g{constructor(){this._items=[],this._running=!1}add(e){0==m.supports(e,"run")&&m.exception("The timer entry must implement the run method"),0==m.supports(e,"getInterval")&&m.exception("The timer entry must implement the getInterval method"),Object.defineProperty(e,"fired",{get(){return this._fired},set(e){this._fired=e}}),e._fired=0,this._items.push(e)}start(){this._running=!0;var e=this;setTimeout((function(){e.run()}),1e3)}stop(){this._running=!1}run(){var e=new Date,t=[],r=1e3;if(this._items.forEach((n=>{var s=e.getTime()-n.fired,i=n.getInterval();s>i?(i<r&&(r=i),t.push(n)):(s=e.getTime()-n.fired+i)<r&&(r=s)})),t.forEach((e=>{e.run()})),this._running){var n=this;setTimeout((function(){n.run()}),r)}}}var m={_established:{},s4:function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},guid:function(){return(this.s4()+this.s4()+"-"+this.s4()+"-4"+this.s4().substr(0,3)+"-"+this.s4()+"-"+this.s4()+this.s4()+this.s4()).toLowerCase()},supports:function(e,t){return null!=e&&t in e&&"function"==typeof e[t]},anySupports:function(e,t){var r=null;if(null!=e)if(Array.isArray(e)){for(var n of e)if(this.supports(n,t)){r=n;break}}else this.supports(e,t)&&(r=e);return r},contains:function(e,t){if(null!=e)for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},indexOf:function(e,t){if(null!=e)for(var r=0;r<e.length;r++)if(e[r]==t)return r;return-1},addTo:function(e,t){return 0==this.contains(e,t)&&(e.push(t),!0)},setItem:function(e,t){for(var r=null,n=0;n<e.length;n++)if(e[n]==t){r=e[n];break}if(null==r)r=t,e.push(t);else for(var s in t)r[s]=t[s];return r},removeFrom:function(e,t){var r=this.indexOf(e,t);return r>=0&&(e.splice(r,1),!0)},createRange:function(e,t,r){return new f(e,t,r)},createTimer:function(){return new g},createFunction:function(e,t){var r=null,n=e.indexOf("function");if(-1!=n){var s=e.indexOf("(",n),i=e.indexOf(")",s),o=e.substring(s+1,i).split(",");if(-1!=(s=e.indexOf("{",i+1))){i=-1;for(var a=1,u=++s;u<e.length;u++)if("}"==e[u]){if(0==--a){i=u;break}}else"{"==e[u]&&a++;if(-1!=i){var h=e.substring(s,i);r=new Function(o,h)}}}return r},createUrl:function(e){var r={},n=t?new URL(e):new URL(e,document.URL);return r.protocol=n.protocol,"http"!=n.protocol&&(n.protocol="http",n=new URL(n.toString())),r.host=n.hostname,r.port=n.port,r.path=n.pathname,r.secure="https:"==r.protocol||"wss:"==r.protocol,r.searchParams=n.searchParams,r.toString=function(){return this.protocol+"//"+this.host+":"+this.port+this.path},r},reverse:function(e){for(var t=[],r=e.length-1;r>=0;r--)t.push(e[r]);return t},createBuffer:function(e){for(var t=new DataView(new ArrayBuffer(e.length)),r=0;r<e.length;r++)t.setUint8(r,e.charCodeAt(r));return t.buffer},arrayBufferToBuffer:function(e){for(var t=new Buffer.alloc(e.byteLength),r=new Uint8Array(e),n=0;n<t.length;n++)t[n]=r[n];return t},bufferToArrayBuffer:function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e[n];return t},stringFromBytes:function(e){var t="";return e.forEach((e=>{t+=String.fromCharCode(e)})),t},stringFromArrayBuffer:function(e){for(var t="",r=new DataView(e),n=0;n<e.byteLength;n++)t+=String.fromCharCode(r.getUint8(n));return t},bytesFromString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r));return t},createWebSocket:function(e,s,o){return new Promise(((o,a)=>{const c=this,p=this.supports(s,"open"),d=this.supports(s,"error"),f=this.supports(s,"message"),g=this.supports(s,"close");if(t){var m=function(){function t(e){this.binaryType="arraybuffer";var t={};t.tlsOptions=null!=t?t:{};var i="wss:"==new URL(e).protocol.toLowerCase(),o=null,a=80;i?null!=h&&(o=h.hostname,a=h.port):null!=u&&(o=u.hostname,a=u.port);var l=null;if(null!=o){var m=null;m=i?n.httpsOverHttp({proxy:{host:o,port:a}}):n.httpOverHttp({proxy:{host:o,port:a}}),(l={}).agent=m}const v=this;this.onopen=function(){c._established[e]=!0,p&&s.open(v)},this.onclose=function(){g&&s.close(v)},this.onerror=function(){d&&s.error(v)},this.onmessage=function(e){f&&s.message(v,e)},r.call(this,e,null,null,null,l,t)}t.prototype=Object.create(r.prototype),t.prototype.constructor=t;var i=new t(e);o(i)},v=function(){null!=u&&null==n?Promise.resolve().then(i.t.bind(i,8004,19)).then((function(e){n=e.default,m()})):m()};null==r?Promise.resolve().then(i.t.bind(i,4748,19)).then((function(e){r=e.default.w3cwebsocket,v()})).catch((e=>{console.log("import error on websocket: "+e)})):v()}else{if(null!=l)e=l+"/"+e;const t=this;(m=new WebSocket(e)).onopen=function(e){p&&s.open(t)},m.onclose=function(e){g&&s.close(t)},m.onerror=function(e){d&&s.error(t)},m.onmessage=function(e){f&&s.message(t,e)},o(m)}}))},createDataFromCsv:function(t,r){var n,s,i,o,a,u,h=new e(r),l=[],c=t.split("\n"),p=null,d=null,f=0,g=0;for(h.hasOpt("fields")?d=h.getOpt("fields"):h.getOpt("header",!1)&&(p=(a=c[g].trim()).split(","),g++);g<c.length;)if(0!=(a=c[g].trim()).length){n=[],i="";for(var m=0;m<a.length;m++)","==(o=a[m])?f>0?i+=o:(n.push(i),i=""):'"'==o?"\\"==s?i+=o:f^=1:"\\"==o?"\\"==s&&(i+=o):i+=o,s=o;if(i.length>0&&n.push(i),null!=d){u={};for(var v=0;v<n.length;v++)d.hasOwnProperty(v)&&(u[d[v]]=n[v])}else if(null!=p){u={};for(v=0;v<n.length;v++)u[p[v]]=n[v]}else u=n;l.push(u),g++}else g++;return l},formatDate:function(e,t){var r,n,s;n="";for(var i=0;i<t.length;i++)"%"==(s=t[i])?i<t.length-1&&("m"==(r=t[++i])?n+=e.getUTCMonth():"d"==r||"e"==r?n+=e.getUTCDate():"Y"==r?n+=e.getFullYear():"%"==r&&(n+="%")):n+=s;return n},btoa:function(e){var t=encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode("0x"+t)}));return btoa(t)},b64Encode:function(e){return t?Buffer.from(e).toString("base64"):this.btoa(e)},b64Decode:function(e){return t?Buffer.from(e,"base64"):atob(e)},stringify:function(e){var t=JSON.parse(JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t)));return JSON.stringify(t,null," ")},createCommandLineOpts:function(){for(var t,r=new e,n=null,s=null,i=2;i<process.argv.length;i++)if(t=process.argv[i],null!=s)s.length>0&&(s+=" "),s+=t;else{if("--"==t){s="";continue}t.startsWith("--")?(null!=n&&r.setOpt(n,!0),n=t.substr(2)):null!=n&&(r.setOpt(n,this.createValue(t)),n=null)}return null!=s&&r.setOpt("_end",s),null!=n&&r.setOpt(n,!0),r},createValue:function(e){var t=e;return 0==e.indexOf("[")&&e.lastIndexOf("]")==e.length-1?t=e=(e=e.substr(1,e.length-2)).split(","):0==e.indexOf("{")&&e.lastIndexOf("}")==e.length-1?t=JSON.parse(e):"true"==e?t=!0:"false"==e&&(t=!1),t},getBorders:function(e,t){var r={left:0,top:0,right:0,bottom:0};if(Object.defineProperty(r,"hsize",{get(){return this.left+this.right}}),Object.defineProperty(r,"vsize",{get(){return this.top+this.bottom}}),null==e||"none"==e.style.display)return r;var n=window.getComputedStyle(e,null);return r.left=parseInt(n.getPropertyValue("border-left-width")),r.top=parseInt(n.getPropertyValue("border-top-width")),r.right=parseInt(n.getPropertyValue("border-right-width")),r.bottom=parseInt(n.getPropertyValue("border-bottom-width")),t&&(r.left+=parseInt(n.getPropertyValue("padding-left")),r.top+=parseInt(n.getPropertyValue("padding-top")),r.right+=parseInt(n.getPropertyValue("padding-right")),r.bottom+=parseInt(n.getPropertyValue("padding-bottom"))),isNaN(r.left)&&(r.left=0),isNaN(r.top)&&(r.top=0),isNaN(r.right)&&(r.right=0),isNaN(r.bottom)&&(r.bottom=0),r},getMargins:function(e){var t={left:0,top:0,right:0,bottom:0};if(null==e||"none"==e.style.display)return t;var r=window.getComputedStyle(e,null);return t.left=parseInt(r.marginLeft),t.top=parseInt(r.marginTop),t.right=parseInt(r.marginRight),t.bottom=parseInt(r.marginBottom),isNaN(t.left)&&(t.left=0),isNaN(t.top)&&(t.top=0),isNaN(t.right)&&(t.right=0),isNaN(t.bottom)&&(t.bottom=0),t},getPadding:function(e){var t={left:0,top:0,right:0,bottom:0};if(Object.defineProperty(t,"hsize",{get(){return this.left+this.right}}),Object.defineProperty(t,"vsize",{get(){return this.top+this.bottom}}),null==e||"none"==e.style.display)return t;var r=window.getComputedStyle(e,null);return t.left+=parseInt(r.getPropertyValue("padding-left")),t.top+=parseInt(r.getPropertyValue("padding-top")),t.right+=parseInt(r.getPropertyValue("padding-right")),t.bottom+=parseInt(r.getPropertyValue("padding-bottom")),t},getOffset:function(e){var t=new Object;t._x=0,t._y=0,t._parentX=-1,t._parentY=-1,t._width=0,t._height=0;var r=e;for(null!=e.firstChild&&1==e.firstChild.nodeType&&(r=e.firstChild);null!=r;)t._x+=r.offsetLeft,t._y+=r.offsetTop,-1==t._parentX&&(t._parentX=r.offsetLeft,t._parentY=r.offsetTop),t._x-=r.scrollLeft,t._y-=r.scrollTop,r=r.offsetParent;return t._width=e.offsetWidth,t._height=e.offsetHeight,t.right=function(){return this._x+this._width},t.bottom=function(){return this._y+this._height},t},getCbState:function(e){var t="string"==typeof e?document.getElementById(e):e,r=!1;if(null!=t){var n=t.firstChild;0==n.disabled&&(r=n.checked)}return r},setCbState:function(e,t){var r="string"==typeof e?document.getElementById(e):e,n=!1;if(null!=r){var s=r.firstChild;t.hasOwnProperty("checked")&&(s.checked=t.checked),t.hasOwnProperty("enabled")&&(t.enabled?(r.style.opacity=1,s.disabled=!1,n=s.checked):(r.style.opacity=.3,s.disabled=!0))}return n},setLinkState:function(e,t){var r="string"==typeof e?document.getElementById(e):e;return null!=r&&(0==r.hasOwnProperty("_enabled")&&(r._enabled=!0,r._href=r.href),t?(r.href=r._href,r.style.opacity=1,r.style.cursor="pointer"):(r.href="#",r.style.opacity=.3,r.style.cursor="default")),t},build(e,t){var r=e;t.forEach((e=>{0==r.hasOwnProperty(e)&&(r[e]={},r=r[e])}))},exception:function(e){var r="string"==typeof e?e:this.stringify(e);throw t?new Error(r):r},readfile:function(e){return new Promise(((t,r)=>{Promise.resolve().then(i.t.bind(i,7147,19)).then((function(r){const n=r.default.readFileSync(e);t(n)}))}))},tokens:function(e,t){for(var r in t)e=e.replaceAll("@"+r+"@",t[r]);return e},getHttpProxy:function(){return u},setHttpProxy:function(e){u=null!=e?new URL(e):null},getHttpsProxy:function(){return h},setHttpsProxy:function(e){h=null!=e?new URL(e):null},getNoProxy:function(){return c},setWsProxy(e){l=e},setNoProxy:function(e){c=e},isNoProxy:function(e){var t="localhost"==e;return 0==t&&null!=c&&(t=m.contains(c,e)),t},established:function(e){return this._established.hasOwnProperty(e)}};String.prototype.splitNoSpaces=function(){return this.split(" ").filter((function(e){return e}))},String.prototype.equalsIgnoreCase=function(e){return this.toLowerCase()==e.toLowerCase()},String.prototype.pad=function(e,t){for(var r="",n=0;n<e-this.length;n++)r+=t;return r+=this},Object.defineProperty(m,"isNode",{get:()=>t});class v{constructor(e){this._size=e,this._bits=new Uint8Array(e)}get value(){for(var e=0,t=0;t<this._size;t++)1==this._bits[t]&&(e|=1<<this._size-1-t);return e}set(e){e<this._size&&(this._bits[this._size-1-e]=1)}unset(e){e<this._size&&(this._bits[e]=0)}setBits(e){for(var t=this._size-1;t>=0;t--)e&1<<t&&this.set(t)}to_string(){for(var e="",t=0;t<this._size;t++)0==this._bits[t]?e+="0":e+="1";return e}}class _{constructor(e){this._size=2*this.size(e),this._data=new ArrayBuffer(this._size),this._view=new DataView(this._data),this._index=0,this._debug=!1,this.encode(e)}get data(){return this._index<this._size?this._data.slice(0,this._index):this_data}encode(e,t){if(e instanceof Object)if(Array.isArray(e)){null!=t&&this.writeString(t),this.beginArray();const r=this;e.forEach((e=>{r.encode(e)})),this.endArray()}else if(e instanceof ArrayBuffer)this.writeBuffer(e,t);else{for(var r in null!=t&&this.writeString(t),this.beginObject(),e)this.encode(e[r],r);this.endObject()}else this.writeValue(e,t)}beginArray(){var e=new v(8);e.setBits(31),e.set(7),this._view.setUint8(this._index,e.value),this._index+=1}endArray(){this.writeStopCode()}beginObject(){var e=new v(8);e.setBits(31),e.set(5),e.set(7),this._view.setUint8(this._index,e.value),this._index+=1}endObject(){this.writeStopCode()}writeStopCode(){var e=new v(8);e.setBits(31),e.set(5),e.set(6),e.set(7),this._view.setUint8(this._index,e.value),this._index+=1}writeValue(e,t){if(0==isNaN(e))Number.isInteger(e)?this.writeI32(e,t):this.writeDouble(e,t);else{var r=typeof e;"string"==r?this.writeString(e,t):"boolean"==r&&this.writeBool(e,t)}}writeString(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r;e.length<24?((r=new v(8)).setBits(e.length),r.set(5),r.set(6),this._view.setInt8(this._index,r.value),this._index+=1):((r=new v(8)).set(1),r.set(3),r.set(4),r.set(5),r.set(6),this._view.setInt8(this._index,r.value),this._index+=1,this._view.setInt32(this._index,e.length),this._index+=4);for(var n=0;n<e.length;n++)this._view.setUint8(this._index,e.charCodeAt(n)),this._index++}writeI8(e,t){null!=t&&t.length>0&&this.writeString(t,null);e.length<24?((r=new v(8)).setBits(e.length),r.set(5),r.set(6),this._view.setInt8(this._index,r.value),this._index+=1):((r=new v(8)).set(1),r.set(3),r.set(4),r.set(5),r.set(6),this._view.setInt8(this._index,r.value),this._index+=1,this._view.setInt32(this._index,e.length),this._index+=4);if(e>=24)(r=new v(8)).set(3),r.set(4),negative&&r.set(5),this._view.setInt8(this._index,r.value);else if(negative){var r;(r=new v(8)).setBits(e),r.set(5),this._view.setInt8(this._index,r.value)}else this._view.setInt8(this._index,e);this._index+=1}writeI8(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r=e<0;if(r&&(e=-1-e),e>=24)(n=new v(8)).set(3),n.set(4),r&&n.set(5),this._view.setInt8(this._index,n.value);else if(r){var n;(n=new v(8)).setBits(e),n.set(5),this._view.setInt8(this._index,n.value)}else this._view.setInt8(this._index,e);this._index+=1}writeI32(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r=e<0;r&&(e=-1-e);var n=new v(8);n.set(1),n.set(3),n.set(4),r&&n.set(5),this._view.setInt8(this._index,n.value),this._index+=1,this._view.setInt32(this._index,e),this._index+=4}writeI64(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r=e<0;r&&(e=-1-e);var n=new v(8);n.set(0),n.set(1),n.set(3),n.set(4),r&&n.set(5),this._view.setInt8(this._index,n.value),this._index+=1,this._view.setBigInt64(this._index,e),this._index+=8}writeDouble(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r=new v(8);r.set(0),r.set(1),r.set(3),r.set(4),r.set(5),r.set(6),r.set(7),this._view.setUint8(this._index,r.value),this._index+=1,this._view.setFloat64(this._index,e),this._index+=8}writeBuffer(e,t){null!=t&&t.length>0&&this.writeString(t,null);var r=new v(8);r.set(1),r.set(3),r.set(4),r.set(6),this._view.setUint8(this._index,r.value),this._index+=1;var n=new DataView(e);this._view.setUint32(this._index,n.byteLength);for(var s=0;s<n.byteLength;s++)this._view.setUint8(this._index,n.getUint8(s)),this._index+=1}size(e){var t=0,r=typeof e;if("string"==r)t=2*e.length;else if("number"==r)t=8;else if("bigint"==r)t=8;else if("boolean"==r)t=4;else if("object"==r)if(e instanceof ArrayBuffer)t=e.byteLength;else for(var n in e)t+=this.size(e[n]);else{if("array"!=r)throw"unknown type: "+r;e.forEach((e=>{t+=this.size(e)}))}return t+=5}}class y{constructor(e){this._data=new DataView(e,0),this._size=this._data.buffer.byteLength,this._index=0,this._o=null,this._debug=!1,this.addTo();var t=this.getHeader();this.addTo(t.type,t.info,null)}addTo(e,t,r){5==e?this.addObject(t,r):4==e?this.addArray(t,r):this.addValue(e,t,"",r)}addArray(e,t){null==this._o&&(this._o=[],t=this._o);for(var r,n=31!=e?this.getUnsigned(e):null;null!=(r=this.getHeader())&&(null!=n||7!=r.type||31!=r.info);){if(4==r.type){if(Array.isArray(t)){var s=[];this.addTo(r.type,r.info,s),t.push(s)}}else if(5==r.type){if(Array.isArray(t)){s={};this.addTo(r.type,r.info,s),t.push(s)}}else this.addTo(r.type,r.info,t);if(null!=n&&0==--n)break}}addObject(e,t){null==this._o&&(this._o={},t=this._o);for(var r,n=31!=e?this.getUnsigned(e):null,s=null;null!=(r=this.getHeader())&&(null!=n||7!=r.type||31!=r.info);){if(3!=r.type){console.log("====== bad");break}if(s=this.getString(r.info),4==(r=this.getHeader()).type?(t[s]=[],this.addTo(r.type,r.info,t[s])):5==r.type?(t[s]={},this.addTo(r.type,r.info,t[s])):this.addValue(r.type,r.info,s,t),null!=n&&0==--n)break}}addValue(e,t,r,n){var s=null;if(0==e||1==e||2==e||3==e||7==e)if(0==e)s=this.getUnsigned(t);else if(1==e){var i=this.getUnsigned(t);s=BigInt(-1)-i}else if(2==e){var o=this.getUnsigned(t);o>0&&(s=new Uint8Array(this._data.buffer,this._index,o),s=w._isNode?Buffer.from(s).toString("base64"):btoa(s.reduce((function(e,t){return e+String.fromCharCode(t)}),"")),this._index+=o)}else 3==e?s=this.getString(t):7==e&&(s=this.getDouble(t));null!=s&&(null==this._o?this._o=s:Array.isArray(n)?n.push(s):n[r]=s)}getHeader(){if(this._index>=this._size)return null;var e=this._data.getUint8(this._index),t={};return t.type=(224&e)>>5,t.info=31&e,this._index++,t}getString(e){var t=null,r=this.getUnsigned(e);r>0&&(t=new Uint8Array(this._data.buffer,this._index,r).reduce((function(e,t){return e+String.fromCharCode(t)}),""),this._index+=r);return t}getUnsigned(e){var t=0;return e<24?t=e:e<=27&&(24==e?(t=this._data.getUint8(this._index),this._index+=1):25==e?(t=this._data.getUint16(this._index),this._index+=2):26==e?(t=this._data.getUint32(this._index),this._index+=4):27==e&&(t=this._data.getBigInt64(this._index),this._index+=8)),t}getDouble(e){var t=0;return e<25?e<24?t=e:this._index+=1:25==e?this._index+=2:26==e?(t=this._data.getFloat32(this._index),this._index+=4):27==e&&(t=this._data.getFloat64(this._index),this._index+=8),t}}var w={_isNode:!1,_supportsGetBigInt:!1,init:function(){var e=new ArrayBuffer(2),t=new DataView(e);t.setInt16(0,256,!0),this._supportsGetBigInt="getBigInt64"in t&&"function"==typeof t.getBigInt64,"object"==typeof process&&process.hasOwnProperty("versions")&&process.versions.hasOwnProperty("node")&&(this._isNode=!0)},encode:function(e){return new _(e).data},decode:function(e){return(e=new y(e))._o}};w.init();m.getHttpProxy(),m.getHttpsProxy();m.isNode;class b extends e{constructor(e,t,r,n,s,i){super(s),this._host=e,this._port=new Number(t),this._path=r,this._secure=n,this._config=i,0==this._port&&(this._port=this._secure?443:80),this._reconnect={interval:5,attempts:0,timestamp:0,timer:null},this._websocket=null}get websocket(){return this._websocket}get protocol(){return this._secure?"wss":"ws"}get httpProtocol(){return this._secure?"https":"http"}get host(){return this._host}get port(){return this._port}get path(){return this._path}get isSecure(){return this._secure}get parms(){var e="",t=this.getOpts();for(var r in t)e.length>0&&(e+="&"),e+=r+"="+t[r];return e}get urlBase(){var e="";return e+=this.protocol,e+="://",e+=this.host,e+=":",e+=this.port}get url(){var e=this.urlBase;return null!=this._path&&this._path.length>0&&(e+=this._path),this.numOpts>0&&(e+="?",e+=this.parms),e}get httpurlBase(){var e="";return e+=this.httpProtocol,e+="://",e+=this.host,e+=":",e+=this.port}get httpurl(){var e=this.httpurlBase;return null!=this._path&&this._path.length>0&&(e+=this._path),this.numOpts>0&&(e+="?",e+=this.parms),e}get hasAuthorization(){return null!=this._authorization&&this._authorization.length>0}get authorization(){return this._authorization}set authorization(e){this._authorization=e,null!=this._authorization&&this.isConnected()&&0==this.isHandshakeComplete()&&this._websocket.send(this._authorization)}getType(){return this.constructor.name}ready(){}closed(e){}error(){}handshakeComplete(){}start(){if(this._reconnect.timer=null,!this.isConnected()){this.clear();var e=this.getUrl();if(null==e)throw"invalid url";this._ready=!1;var t=this,r={open:function(e){t._ready=!0,t.ready(e)},close:function(e){t.clear(),t.closed(e)},error:function(e){t.clear(),t.error(e)},message:function(e,r){if(m.isNode)if("string"==typeof r.data)t.message(r.data);else{var n=w.decode(r.data);t.data(n)}else if(r.data instanceof ArrayBuffer||r.data instanceof Blob){var s=new FileReader;s.onload=function(e){var r=w.decode(e.target.result);t.data(r)},s.readAsArrayBuffer(r.data)}else t.message(r.data)}};m.createWebSocket(e,r).then((function(e){t._websocket=e,t._ready=!0}),(function(e){console.log("create websocket error: "+e)}))}}stop(){return!!this.isConnected()&&(this.clear(),!0)}restart(){this.clear(),this.start()}reconnect(e){if(null==this._reconnect.timer&&(0==m.established(this.getUrl())?this._reconnect.interval=5:this._reconnect.interval=e,0==this.isConnected())){var t=this;this._reconnect.timer=setTimeout((function(){t.start()}),1e3*t._reconnect.interval)}}message(e){if(!this._handshakeComplete){for(var t,r="",n=null,s=0;s<e.length;s++)if("\n"==(t=e.charAt(s))){if(0==r.length)break;null==this._headers&&(this._headers=new Object),this._headers[r]=null!=n?n.trim():"",r="",n=null}else null!=n?n+=t:":"==t?n="":r+=t;var i=this.getHeader("status");if(null!=i)if(200==i)this._handshakeComplete=!0,this.handshakeComplete();else if(401==i)if(null!=this._authorization)this._websocket.send(this._authorization);else{var o=this.getHeader("www-authenticate","").toLowerCase(),a=o.split(" ");a.length>1&&(o=a[0]);var u=!1;if(this._delegates.forEach((e=>{m.supports(e,"authenticate")&&(e.authenticate(this,o),u=!0)})),0==u){var h=this.getHeader("status");throw h+="\n",h+=this.getHeader("www-authenticate",""),h+="\n",m.isNode?new Error(h):h}}}}setBearer(e){this.authorization="Bearer "+e}setBasic(e){this.authorization="Basic "+e}data(e){}clear(){null!=this._websocket&&(this._websocket._connection=null,this._websocket.close(),this._websocket=null),this._ready=!1,this._handshakeComplete=!1,this._headers=null}getHeader(e,t){var r=t;return null!=this._headers&&this._headers.hasOwnProperty(e)&&(r=this._headers[e]),r}isHandshakeComplete(){return this._handshakeComplete}send(e){null!=this._websocket&&this._websocket.send(e)}sendObject(e){this.getOpt("debug_send",!1)&&console.log(JSON.stringify(e,null,"\t")),this.send(m.stringify(e))}sendBinary(e){var t=w.encode(e);this.send(t)}isConnected(){return null!=this._websocket}getUrl(){return this.url}static create(e,t){var r=m.createUrl(decodeURI(e));return new b(r.host,r.port,r.path,r.secure,t)}static createDelegateConnection(e,t,r,n){var s=m.createUrl(decodeURI(t));return new O(e,s.host,s.port,s.path,s.secure,r,n)}}class O extends b{constructor(e,t,r,n,s,i,o){super(t,r,n,s,i,o),this._delegate=e}ready(){m.supports(this._delegate,"ready")&&this._delegate.ready()}closed(){m.supports(this._delegate,"closed")&&this._delegate.closed()}error(){m.supports(this._delegate,"error")&&this._delegate.error()}handshakeComplete(){m.supports(this._delegate,"handshakeComplete")&&this._delegate.handshakeComplete()}message(e){0!=this.isHandshakeComplete()?m.supports(this._delegate,"message")&&this._delegate.message(e):super.message(e)}data(e){m.supports(this._delegate,"data")&&this._delegate.data(e)}}var E=null,N=null,S=null;m.isNode&&(Promise.resolve().then(i.t.bind(i,8025,19)).then((e=>{N=e.default})).catch((e=>{console.log("import error on xpath: "+e)})),Promise.resolve().then(i.t.bind(i,7829,19)).then((e=>{var t=e.default.DOMParser,r=e.default.XMLSerializer;S=new t,E=new r})).catch((e=>{console.log("import error on xmldom: "+e)})));var x={getNodes:function(e,t){var r=new Array;if(m.isNode){if(null!=(i=this.getXPath().select(e,t)))for(var n=0;n<i.length;n++)r.push(i[n])}else for(var s,i=(null==t?t=document:null!=t.ownerDocument?t.ownerDocument:t).evaluate(e,t,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);null!=(s=i.iterateNext());)r.push(s);return r},getElements:function(e){for(var t=[],r=0;r<e.children.length;r++)t.push(e.children.item(r));return t},getChildren:function(e){for(var t=[],r=0;r<e.childNodes.length;r++)t.push(e.childNodes.item(r));return t},getNode:function(e,t){var r=null,n=this.getNodes(e,t);return n.length>0&&(r=n[0]),r},getString:function(e,t){var r="";return this.getNodes(e,t).forEach((e=>{r+=null!=e.textContent?e.textContent:e.nodeValue})),r},nodeText:function(e){var t="",r=e;return null!=e.firstChild&&(4==e.firstChild.nodeType&&(r=e.firstChild),t=null!=r.textContent?r.textContent:r.nodeValue),t},xmlString:function(e){return m.isNode?E.serializeToString(e):(new XMLSerializer).serializeToString(e)},setNodeText:function(e,t){e.textContent=t},format:function(e,t){var r=new Object;return r._s="",null==t&&(t=" "),this.formatNode(r,e,0,t),r._s},formatNode:function(e,t,r,n){if(1==t.nodeType){for(var s=0;s<r;s++)e._s+=n;if(e._s+="<"+t.tagName,t.attributes.length>0){var i;for(s=0;s<t.attributes.length;s++)i=t.attributes[s],e._s+=" "+i.nodeName+"='"+i.nodeValue+"'"}if(t.hasChildNodes()){e._s+=">";var o,a=!1,u=!1,h=!1;for(s=0;s<t.childNodes.length;s++)3==(o=t.childNodes[s]).nodeType?a=!0:4==o.nodeType?u=!0:h=!0;if(0==h&&(a||u))e._s+=u?"<![CDATA["+t.textContent+"]]>":t.textContent,e._s+="</"+t.tagName+">",r>0&&(e._s+="\n");else{e._s+="\n";for(s=0;s<t.childNodes.length;s++)this.formatNode(e,t.childNodes[s],r+1,n);for(s=0;s<r;s++)e._s+=n;e._s+="</"+t.tagName+">",r>0&&(e._s+="\n")}}else e._s+="></"+t.tagName+">\n"}},createXml:function(e){return m.isNode?S.parseFromString(e,"application/xml"):(new DOMParser).parseFromString(e,"application/xml")},addOpts:function(e,t){this.getNodes("*",e).forEach((e=>{var r=e.tagName,n=this.nodeText(e);t.setOpt(r,n)}))},getXPath:function(){return N}},A=null,T=null,C=null;class R extends e{constructor(e){super(),this._url=e,this._requestHeaders=new Object,this._responseHeaders=null,this._response=this,this._method="GET",this._request=null,this._data=null}get url(){return this._url}get status(){return null!=this._request?this._request.status:0}get text(){return null!=this._request?this._request.responseText:""}get xml(){var e=null;if(null!=this._request&&null==(e=this._request.responseXML)){var t=this.getResponseHeader("content-type");-1==t.indexOf("text/xml")&&-1==t.indexOf("application/xml")||(e=x.createXml(this._request.responseText))}return e}send(e){return new Promise(((t,r)=>{null!=e&&(this._method=e);var n=new URL(this._url,document.URL);"file:"==n.protocol.toLowerCase()&&m.exception("file protocol is not supported"),this._request=new XMLHttpRequest,this._request.withCredentials=!0;var s=!1,i=this;this._request.onreadystatechange=function(){if(3==this.readyState)s=!0;else if(4==this.readyState){if(401==this.status)return void r(i);if("HEAD"==i._method)0==this.status?r(i):t(i);else if(0==s)r(i);else{this.getResponseHeader("content-type");0==this.status?null!=this.responseText&&this.responseText.length>0||null!=this.responseXML?t(i):r(i):t(i)}}},this._request.onerror=function(e){r(i)};var o=this._url;null!=A&&(n.hostname==A.hostname&&n.port==A.port||(o=A+o));if(this._request.open(this._method,o,!0),null!=this._requestHeaders)for(var a in this._requestHeaders)this._request.setRequestHeader(a,this._requestHeaders[a]);try{this._request.send(this._data)}catch(e){console.log("error: "+this._url+" : "+e)}}))}get(){return this.send("GET")}post(){return this.send("POST")}put(){return this.send("PUT")}del(){return this.send("DELETE")}head(){return this.send("HEAD")}setRequestHeaders(e){for(var t in e)this.setRequestHeader(t,e[t])}setRequestHeader(e,t){this._requestHeaders[e]=t}getRequestHeader(e){return this._requestHeaders[e]}getResponseHeader(e){return this._request.getResponseHeader(e)}setData(e,t){this._data=e,null!=t&&this.setRequestHeader("content-type",t)}toString(){var e="";return e+=this._url,e+=", ",e+="status="+this.status}}var P=null;m.isNode&&Promise.resolve().then(i.t.bind(i,8004,19)).then((function(e){P=e.default}));class k extends e{constructor(e){super(),this._url=e,this._requestHeaders=new Object,this._options={},this._response=null,this._text="",this._data=null,this._xml=null,this._bearer=null}get url(){return this._url}get status(){return null!=this._response?this._response.statusCode:0}get text(){return this._text}get xml(){var e=null;return null!=this._text&&(e=x.createXml(this._text)),e}get bearer(){return this._bearer}set bearer(e){this._bearer=e}send(e){return new Promise(((t,r)=>{null!=e&&(this._options.method=e);var n=new URL(this._url);this._options.hostname=n.hostname,this._options.port=n.port,this._options.path=n.pathname+n.search;var s=n.protocol.toLowerCase(),o=this;if("file:"!=s){var a=function(e){o.setProxy().then((function(){!function(e){for(var n in e.shouldKeepAlive=!1,e.on("response",(function(e){o._response=e;var r=e.headers["content-type"],n="";e.on("data",(function(e){n+=e.toString()})),e.on("end",(function(e){o._text=n,null!=r&&(-1==r.indexOf("text/xml")&&-1==r.indexOf("application/xml")||(o._xml=x.createXml(n))),t(o)}))})),e.on("error",(function(e){o.error=e,r(o)})),e.on("timeout",(function(t){console.log("++++++++++++++++++++++ TIME OUT"),e.abort(),r(o)})),o._requestHeaders)e.setHeader(n,o._requestHeaders[n]);0==o._requestHeaders.hasOwnProperty("connection")&&e.setHeader("Connection","close"),null!=o._bearer&&e.setHeader("Authorization","Bearer "+o._bearer),null!=o._data&&e.write(o._data),e.end()}(e.request(o._options))}))};"https:"==s?null==T?Promise.resolve().then(i.t.bind(i,5687,19)).then((e=>{T=e.default,a(T)})).catch((e=>{console.log("import error on https: "+e)})):a(T):null==C?Promise.resolve().then(i.t.bind(i,3685,19)).then((e=>{C=e.default,a(C)})).catch((e=>{console.log("import error on http: "+e)})):a(C)}else{var u=this._url.substr(7);Promise.resolve().then(i.t.bind(i,7147,19)).then((function(e){e.default.readFile(u,null,(function(e,n){null!=e?r(o):(o._text=n.toString(),t(o))}))}))}}))}get(e){return this.setOptions(e),this.send("GET")}post(e){return this.setOptions(e),this.send("POST")}put(e){return this.setOptions(e),this.send("PUT")}del(e){return this.setOptions(e),this.send("DELETE")}head(){return this.send("HEAD")}setOptions(e){if(null!=e)for(var t in e)this._options[t]=e[t]}setOption(e,t){this._options[e]=t}setAccept(e){this.setRequestHeader("accept",e)}setRequestHeaders(e){for(var t in e)this.setRequestHeader(t,e[t])}setRequestHeader(e,t){var r=e.toLowerCase();null!=t&&(this._requestHeaders[r]=t)}getRequestHeader(e){return this._requestHeaders[e.toLowerCase()]}setData(e,t){this._data=e,null!=t&&this.setRequestHeader("content-type",t)}setProxy(){return new Promise(((e,t)=>{var r=new URL(this._url);if(m.isNoProxy(r.hostname))e();else{var n=m.getHttpProxy(),s="https:"==r.protocol.toLowerCase(),i=null,o=80;if(s){var a=m.getHttpsProxy();null!=a&&(i=a.hostname,0!=a.port&&(o=a.port))}else null!=n&&(i=n.hostname,0!=n.port&&(o=n.port));if(null!=i){var u=null;u=s?P.httpsOverHttp({proxy:{host:i,port:o}}):P.httpOverHttp({proxy:{host:i,port:o}}),this._options.agent=u,e()}else e()}}))}toString(){var e="";return e+=this._url,e+=", ",e+="status="+this.status}}var D={create:function(e){return m.isNode?new k(e):new R(e)},setHttpProxy:function(e){A=new URL(e)}};class I extends e{constructor(){super(),this._fields=[],this._fieldMap={},this._keyFields=[],this._columns=[]}get size(){return this._fields.length}get numkeys(){return this._keyFields.length}setFields(t){var r,n,s;this._fields=[],this._fieldMap={},this._keyFields=[],this._columns=[],t.forEach((t=>{s=new e,r=t.name,s.setOpt("name",r),s.setOpt("espType",t.type),s.setOpt("isNumber",!1),s.setOpt("isTime",!1),s.setOpt("isDate",!1),s.setOpt("isArray",!1),t.hasOwnProperty("label")&&s.setOpt("label",t.label),"utf8str"==(n=s.getOpt("espType"))?s.setOpt("type","string"):"int32"==n||"int64"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0)):"double"==n||"money"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0)):"array(dbl)"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"array(i32)"==n||"array(i64)"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"date"==n?(s.setOpt("type","date"),s.setOpt("isDate",!0)):"timestamp"==n?(s.setOpt("type","datetime"),s.setOpt("isTime",!0)):s.setOpt("type",n),s.setOpt("isKey",t.hasOwnProperty("key")&&"true"==t.key),this._fields.push(s),this._columns.push(r),this._fieldMap[r]=s,s.isKey&&this._keyFields.push(s)}))}fromXml(t){var r,n,s;for(var i of(this._fields=[],this._fieldMap={},this._keyFields=[],this._columns=[],x.getNodes(".//fields/field",t)))s=new e,r=i.getAttribute("name"),s.setOpt("name",r),s.setOpt("espType",i.getAttribute("type")),s.setOpt("isNumber",!1),s.setOpt("isTime",!1),s.setOpt("isDate",!1),s.setOpt("isArray",!1),"utf8str"==(n=s.getOpt("espType"))?s.setOpt("type","string"):"int32"==n||"int64"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0)):"double"==n||"money"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0)):"array(dbl)"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"array(i32)"==n||"array(i64)"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"date"==n?(s.setOpt("type","date"),s.setOpt("isDate",!0)):"timestamp"==n?(s.setOpt("type","datetime"),s.setOpt("isTime",!0)):s.setOpt("type",n),s.setOpt("isKey","true"==i.getAttribute("key")),this._fields.push(s),this._columns.push(r),this._fieldMap[r]=s,s.getOpt("isKey",!1)&&this._keyFields.push(s)}fromJson(t){var r,n,s;this._fields=[],this._fieldMap={},this._keyFields=[],this._columns=[];var i=t.fields;null!=i&&0!=i.length||(i=t.field_array),null==i&&(i=[]),i.forEach((t=>{s=new e,r=t["@name"],s.setOpt("name",r),s.setOpt("espType",t["@type"]),s.setOpt("isNumber",!1),s.setOpt("isTime",!1),s.setOpt("isDate",!1),s.setOpt("isArray",!1),"utf8str"==(n=s.getOpt("espType"))?s.setOpt("type","string"):"int32"==n||"int64"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0)):"double"==n||"money"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0)):"array(dbl)"==n?(s.setOpt("type","float"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"array(i32)"==n||"array(i64)"==n?(s.setOpt("type","int"),s.setOpt("isNumber",!0),s.setOpt("isArray",!0)):"date"==n?(s.setOpt("type","date"),s.setOpt("isDate",!0)):"timestamp"==n?(s.setOpt("type","datetime"),s.setOpt("isTime",!0)):s.setOpt("type",n),s.setOpt("isKey",t.hasOwnProperty("@key")&&"true"==t["@key"]),this._fields.push(s),this._columns.push(r),this._fieldMap[r]=s,s.getOpt("isKey",!1)&&this._keyFields.push(s)}))}getField(e){return this._fieldMap.hasOwnProperty(e)?this._fieldMap[e]:null}getFields(){return this._fields}getFieldDescriptors(e){var t=[];return this._fields.forEach((e=>{t.push(e.getOpts())})),t}getKeyFields(){return this._keyFields}getColumnFields(){var e=[];for(var t of this._fields)0==t.getOpt("isKey",!1)&&e.push(t);return e}getKeyFieldNames(e){var t=[],r=this.getKeyFields();if(null!=r)for(var n of r)t.push(n.getOpt("name"));return t}toString(){return m.stringify(this._fieldMap)}createDataFromCsv(t,r){var n,s,i,o,a,u,h,l,c=new e(r),p=c.getOpt("delegate"),d=[],f=t.split("\n"),g=this.getFields(),v=null,_=0,y=!1,w=0;c.getOpt("header",!1)&&(v=(u=f[w].trim()).split(","),w++);for(var b=c.getOpt("opcodes",!1),O=c.getOpt("flags",!1),E=m.supports(p,"filter")?p.filter:null,N=m.supports(p,"supplement")?p.supplement:null;w<f.length;)if(0!=(u=f[w].trim()).length)if("/*"!=u)if(y&&"*/"==u)y=!1,w++;else if(y)w++;else{h=[],o="";for(var S=0;S<u.length;S++)","==(a=u[S])?_>0?o+=a:(h.push(o),o=""):'"'==a?"\\"==i?o+=a:_^=1:"\\"==a?"\\"==i&&(o+=a):o+=a,i=a;if(o.length>0&&h.push(o),l={},null!=v)for(var x=0;x<h.length;x++)null!=(n=this.getField(v[x]))&&(l[n.getOpt("name")]=h[x]);else{s=0;for(x=0;x<h.length;x++)b&&0==x?"i"!=(u=h[x].trim().toLowerCase())&&"u"!=u&&"p"!=u&&"d"!=u||("i"==u?l.opcode="insert":"u"==u?l.opcode="update":"p"==u?l.opcode="upsert":"d"==u&&(l.opcode="delete")):O&&1==x?u=h[x].trim().toLowerCase():s<g.length&&(l[(n=g[s]).getOpt("name")]=h[x],s++)}w++,null!=E&&0==E(l)||(null!=N&&N(l),d.push(l))}else y=!0,w++;else w++;return d}}class L{constructor(e){this._projects=[],this._contqueries=[],this._windows=[],this._sourceWindows=[];for(var t,r,n,s,i,o,a,u,h,l,c,p,d,f,g,m,v=x.getNodes("//project",e),_=0;_<v.length;_++){d=v[_].getAttribute("name"),(n=new Object).xml=v[_],n.key=d,n.name=d,n.index=v[_].getAttribute("index"),m=v[_].getAttribute("read"),n.hasReadPermission=!(null!=m&&m.length>0)||"true"==m,m=v[_].getAttribute("write"),n.hasWritePermission=!(null!=m&&m.length>0)||"true"==m,this._projects.push(n),n.contqueries=new Array,t=x.getNodes(".//contquery",v[_]);for(var y=0;y<t.length;y++)if(l=t[y].getAttribute("name"),(r=new Object).key=d+"/"+l,r.name=l,r.index=t[y].getAttribute("index"),m=t[y].getAttribute("read"),r.hasReadPermission=!(null!=m&&m.length>0)||"true"==m,m=t[y].getAttribute("write"),r.hasWritePermission=!(null!=m&&m.length>0)||"true"==m,n.contqueries.push(r),this._contqueries.push(r),r.windows=new Array,r.edges=new Array,0==(s=x.getNodes(".//window",t[y])).length&&(s=x.getNodes(".//windows/*",t[y])),0!=s.length){for(var w,b,O=0;O<s.length;O++)(h=this.addWindow(n,r,s[O])).xml=s[O],null!=(w=x.getNode("./xml",s[O]))?(b=x.createXml(x.nodeText(w)),h.xmlsource=x.xmlString(b.documentElement)):h.xmlsource=x.format(h.xml),h.pubsubEnabled="true"==s[O].getAttribute("pubsub"),m=s[O].getAttribute("read"),h.hasReadPermission=!(null!=m&&m.length>0)||"true"==m,m=s[O].getAttribute("write"),h.hasWritePermission=!(null!=m&&m.length>0)||"true"==m,r.windows.push(h);a=x.getNodes("./edges/edge",t[y]);for(O=0;O<a.length;O++){o=a[O].getAttribute("source").split(" "),i=a[O].getAttribute("target").split(" ");for(var E=0;E<o.length;E++)if(f=d+"/"+l+"/"+o[E].trim(),null!=(c=this.getWindow(f)))for(var N=0;N<i.length;N++)(m=i[N].trim()).length>0&&(g=d+"/"+l+"/"+m,null!=(p=this.getWindow(g))&&(c.outgoing.push(p),p.incoming.push(c),(u=new Object).a=c.key,u.z=p.key,r.edges.push(u)))}}}for(_=0;_<this._contqueries.length;_++)this._contqueries[_].windows.sort(F.compareNames);this._xml=e,this._xml.documentElement.removeAttribute("id")}get xml(){return this._xml}get xmlstring(){return x.xmlString(this._xml)}get projects(){return this._projects}addWindow(e,t,r){var n=r.getAttribute("name"),s=r.getAttribute("type");null!=s&&0!=s.length||(s=r.nodeName);var i=s.split("-");if(i.length>1){s="";for(var o=1;o<i.length;o++)s.length>0&&(s+="-"),s+=i[o]}var a=new Object;a.p=e.name,a.cq=t.name,a.name=n,a.type=s,a.index=r.getAttribute("index"),a.class=F._windowClasses.hasOwnProperty(s)?F._windowClasses[s]:"unknown",null==a.index&&null==(a.index=t.index)&&null==(a.index=e.index)&&(a.index="pi_HASH");var u=new I;return u.fromXml(r),a.schema=u,a.key=e.name+"/"+t.name+"/"+n,a.incoming=new Array,a.outgoing=new Array,a.cpu=0,a.count=0,this._windows.push(a),"window-source"==a.type&&(this.sourceWindows[a.key]=!0),a}getProjects(e){return this._projects}getProject(e){return this.get(e,this._projects)}getContqueries(e){return this._contqueries}getContquery(e){return this.get(e,this._contqueries)}getWindows(){return this._windows}getSourceWindows(){var e=[];return this._windows.forEach((t=>{"source"==t.type&&e.push(t)})),e}getWindowsForProject(e){var t=[];return this._windows.forEach((r=>{"*"!=e&&e!=r.p||t.push(r)})),t}getWindow(e){return this.get(e,this._windows)}getWindowType(e){var t=null,r=this.getWindow(e);return null!=r&&(t=r.type),t}get(e,t){for(var r=0;r<t.length;r++)if(t[r].key==e)return t[r];return null}removeIsolated(e){for(var t,r=new Array,n=0;n<e.windows.length;n++)("source"==(t=e.windows[n]).type||"window-source"==t.type||t.incoming.length>0||t.outgoing.length>0)&&r.push(t);e.windows=r}}var F={_windowClasses:new Object,init(){this._windowClasses.source="input",this._windowClasses.filter="transformation",this._windowClasses.aggregate="transformation",this._windowClasses.compute="transformation",this._windowClasses.union="transformation",this._windowClasses.join="transformation",this._windowClasses.copy="transformation",this._windowClasses.functional="transformation",this._windowClasses.notification="utility",this._windowClasses.pattern="utility",this._windowClasses.counter="utility",this._windowClasses.geofence="utility",this._windowClasses.procedural="utility",this._windowClasses["model-supervisor"]="analytics",this._windowClasses["model-reader"]="analytics",this._windowClasses.train="analytics",this._windowClasses.calculate="analytics",this._windowClasses.score="analytics",this._windowClasses["text-context"]="textanalytics",this._windowClasses["text-category"]="textanalytics",this._windowClasses["text-sentiment"]="textanalytics",this._windowClasses["text-topic"]="textanalytics"},compareNames:function(e,t){return e.name.localeCompare(t.name)},create:e=>new L(e)};F.init();class j{constructor(e,t){this._api=e,this._delegate=t,this._eventsources={},this._running=!1,this._paused=!1,this._restart=!1,this._config=null,this._api.connection.addDelegate(this)}get connect(){return this._api.connect}get running(){return this._running}get configuration(){return this._config}get paused(){return this._paused}set paused(e){this._paused=e}ready(e){this._restart&&(this._restart=!1,this.start())}closed(e){Object.values(this._eventsources).forEach((e=>{e.reset()})),this._restart=!0}configure(t,r){this._config=t;var n=t.hasOwnProperty("nodeType")?x.xmlString(t):t;null!=r&&(n=new e(r).resolve(n));var s=x.createXml(n).documentElement;x.getNodes("./event-sources/*",s).forEach((e=>{var t=e.tagName,r={};x.getNodes("./options/option",e).forEach((e=>{var t=e.getAttribute("name"),n=x.nodeText(e);r[t]=n}));var n=null;"url-event-source"==t?n=new B(this,r):"code-event-source"==t?n=new M(this,r):"csv-event-source"==t&&(n=new q(this,r)),null==n&&m.exception("failed to create event source from \n\n"+x.xmlString(e)+"\n"),this.addEventSource(n)})),x.getNodes("./edges/edge",s).forEach((e=>{var t=e.getAttribute("source").split(" "),r=e.getAttribute("target").split(" ");t.forEach((e=>{r.forEach((t=>{this.addEdge(e,t)}))}))}))}configureFromUrl(t,r,n){var s=this,i=new e(r),o=i.getOptAndClear("start",!1);D.create(t).get().then((function(e){s.configure(e.text,i.getOpts()),o&&s.start(),null!=n&&m.supports(n,"ready")&&n.ready(s)}),(function(e){console.log("error: "+e)}))}createEventSource(t){var r=new e(t),n=r.getOpt("type",""),s=r.getOpt("name",""),i=r.getOpt("window","");0!=n.length&&0!=s.length&&0!=i.length||m.exception("you must specify type, name and window for each event source");var o=null;t={name:s,window:i};return"url"==n?o=new B(this,t):"code"==n?o=new M(this,t):"csv"==n&&(o=new q(this,t)),null==o&&m.exception("invalid event source type: "+n),o.setOpts(r.getOpts()),this.addEventSource(o),o}addEventSource(e){"name"in e==0&&m.exception("the event source must have a name property"),this._eventsources.hasOwnProperty(e.name)&&m.exception("event source "+e.name+" already exists"),this._eventsources[e.name]=e}addEdge(e,t){var r=this.getEventSource(e);null==r&&m.exception("cannot find event source "+e);var n=this.getEventSource(t);null==n&&m.exception("cannot find event source "+t),n._sources.push(r)}getEventSource(e){return this._eventsources.hasOwnProperty(e)?this._eventsources[e]:null}togglePlay(){return 0==this._running?this.start():this._paused?this._paused=!1:this._paused=!0,0==this._paused}start(){Object.values(this._eventsources).forEach((e=>{e.init()})),this._running=!0;var e=this;setTimeout((function(){e.run()}),1e3)}run(){if(this._paused){var e=this;setTimeout((function(){e.run()}),1e3)}else{var t=new Date,r=(e=[],!1),n=5e3,s=0;if(Object.values(this._eventsources).forEach((i=>{if(i.repeat>=0&&0==i.done){if(0==i.sending)if(i.checkDependencies()){var o=t.getTime()-i.timestamp,a=i.interval;o>a?(a<n&&(n=a),e.push(i)):(o=t.getTime()-i.timestamp+a)<n&&(n=o)}else r=!0}else s++})),e.forEach((e=>{e.repeat>=0&&e.process()})),s==Object.keys(this._eventsources).length)if(this._running=!1,m.supports(this._delegate,"complete")){e=this;setTimeout((function(){e._delegate.complete(e)}),1e3)}else setTimeout((function(){console.log("exiting")}),2e3);else{e=this;setTimeout((function(){e.run()}),r?1e3:n)}}}publish(e,t){0==this._eventsources.hasOwnProperty(e)&&m.exception("cannot find event source "+e),this._eventsources[e].process(t)}}class U extends e{constructor(e,t){super(t),this._eventsources=e,this._api=e._api,this._window=null,this._plugin=null,this._ready=!1,this._done=!1,this._sources=[],this._times=0,this._timestamp=0,this._senders=[],this._publisher=null,this._interval=3e4,this.hasOpt("interval")&&(this.interval=this.getOpt("interval"))}get name(){return this.getOpt("name","")}set name(e){this.setOpt("name",e)}get esp(){return this._eventsources.connect}get publisher(){return this._publisher}get repeat(){return this.getOpt("repeat","1")}get interval(){return this._interval}set interval(e){var t=e.split(" "),r=(e=parseFloat(t[0]),2==t.length?t[1]:"milliseconds");"second"==r||"seconds"==r?e*=1e3:"minute"==r||"minutes"==r?e*=6e4:"hour"!=r&&"hours"!=r||(e*=36e5),this._interval=e}get done(){return this._done&&0==this.sending}set done(e){this._done=e}get sending(){return this._senders.length>0}get timestamp(){return this._timestamp}set timestamp(e){this._timestamp=e}get tools(){return m}init(){if(this._times=0,this._timestamp=0,this.done=!1,this.checkCycles(),this._window=this.getOpt("window"),this._plugin=this.getOpt("plugin"),null!=this._window){var e={window:this._window};this.hasOpt("dateformat")&&(e.dateformat=this.getOpt("dateformat")),this._api.version<7&&(e.format="json");const t=this;this._api.getPublisher(e).then((function(e){t._publisher=e}))}this._ready=!0}reset(){this._times=0,this._timestamp=0,this._senders=[],this._publisher=null}send(e){new H(this,e).run()}dependsOn(e){var t=!1;for(var r of this._sources)if(r==e||r.dependsOn(e)){t=!0;break}return t}checkCycles(){for(var e of this._sources)e.dependsOn(this)&&m.exception("cyclical dependency detected on "+e.name+" to "+this.name),e.checkCycles()}checkDependencies(){var e=!0;for(var t of this._sources){if(0==t.done){e=!1;break}if(0==t.checkDependencies()){e=!1;break}}return e}process(e){this.run(e)&&(this._timestamp=(new Date).getTime(),this._times++,this.repeat>0&&this._times>=this.repeat&&(this._done=!0))}run(e){return!1}createXml(e){return x.createXml(e)}getNodes(e,t){return x.getNodes(t,e)}getNode(e,t){return x.getNode(t,e)}getNodeText(e,t){var r="",n=null!=t?this.getNode(e,t):e;return null!=n&&(r=x.nodeText(n)),r}}class B extends U{constructor(e,t){super(e,t),this._transform=null,this.hasOpt("transform")&&(this._transform=new Function("eventsource","data",this.getOpt("transform")))}get transform(){return this._transform}set transform(e){this._transform=e}init(){super.init(this),null!=this._window&&null==this._transform&&m.exception("you must specify the transform value for the UrlEventSource"),0==this.hasOpt("url")&&0==this.hasOpt("url-func")&&m.exception("you must specify the either a url or a url function value for the UrlEventSource")}run(t){var r=!1,n=null;if(this.hasOpt("url"))n=this.getOpt("url");else if(this.hasOpt("url-func")){n=new Function(this.getOpt("url-func"))()}if(null!=n){if(null!=t)n=new e(t).resolve(n);var s=this;this._api.version>7&&this.getOpt("use-connect",!1)?this._api.get(n).then((function(e){if(null!=s._plugin)console.log("plugin");else{var t=s._transform(s,e);null!=t&&s.send(t)}}),(function(e){console.log("error: "+e)})):D.create(n).get().then((function(e){if(null!=s._plugin)s.send(e.text);else{var t=s._transform(s,e.text);null!=t&&s.send(t)}}),(function(e){console.log("error: "+e)})),r=!0}return r}}class q extends U{constructor(e,t){super(e,t),this._data=null,this._filter=null,this._supplement=null}init(){if(super.init(),0==this.hasOpt("csv")&&0==this.hasOpt("url")&&m.exception("you must specify CSV data for the event source with either the csv or url option"),this.hasOpt("csv"))this._data=this.getOpt("csv");else{var e=this;D.create(this.getOpt("url")).get().then((function(t){e._data=t.text}),(function(t){console.log("error: "+e.getOpt("url")+" "+t)}))}this.hasOpt("filter")&&(this._filter=new Function("o",this.getOpt("filter"))),this.hasOpt("supplement")&&(this._supplement=new Function("o",this.getOpt("supplement")))}run(e){var t=!1;if(this._publisher.schema.size>0&&null!=this._data){t=!0;var r={};null!=this._filter&&(r.filter=this._filter),null!=this._supplement&&(r.supplement=this._supplement);var n=this.clone();n.delegate=r;var s=this.publisher._schema.createDataFromCsv(this._data,n);this.send(s)}return t}}class M extends U{constructor(e,t){super(e,t),this._code=null,this.hasOpt("code")&&(this._code=new Function("esp","publisher",this.getOpt("code")))}init(){super.init(),null==this._code&&m.exception("you must specify the code value for the UrlEventSource")}run(e){return this._code(this._eventsources,this._publisher),!0}}class H{constructor(e,t){this._eventsource=e,this._data=t,null!=this._eventsource._publisher?(0==Array.isArray(this._data)&&m.exception("data must be an array"),this._opcode=e.getOpt("opcode","upsert"),this._delay=e.getInt("delay",0),this._index=e.getInt("start",0),this._chunksize=e.getInt("chunk_size",1),m.addTo(this._eventsource._senders,this)):null!=this._eventsource._plugin&&m.addTo(this._eventsource._senders,this)}run(){var e=this;if(null!=this._eventsource._plugin){var t=this._eventsource._api.httpurlBase;t+="/eventStreamProcessing/v1/plugin/",t+=this._eventsource._plugin;var r=D.create(t);return r.setData(this._data),void r.post({timeout:1e3}).then((function(t){console.log(t.text),m.removeFrom(e._eventsource._senders,e)}),(function(t){console.log("error: "+t),m.removeFrom(e._eventsource._senders,e)}))}if(null!=this._eventsource._publisher){var n=this._eventsource.getOpt("maxevents",0);if(0==n&&(n=this._data.length),0==this._delay)this._data.forEach((e=>{0==e.hasOwnProperty("opcode")&&(e.opcode=this._opcode),this._eventsource._publisher.add(e)})),this._eventsource._publisher.publish(),m.removeFrom(this._eventsource._senders,this);else if(this._index<n)if(0==this._eventsource._eventsources.paused){for(var s=0;s<this._chunksize&&this._index<n;s++)0==this._data[this._index].hasOwnProperty("opcode")&&(this._data[this._index].opcode=this._opcode),this._eventsource._publisher.add(this._data[this._index]),this._index++;this._eventsource._publisher.publish(),setTimeout((function(){e.run()}),this._delay)}else setTimeout((function(){e.run()}),1e3);else m.removeFrom(this._eventsource._senders,this)}else m.removeFrom(this._eventsource._senders,this)}}var V=function(e,t){return new j(e,t)};const W=new class{constructor(){this._languages=null,this._parms=null,this._strings=null,this._delegate=null,this._locale=null;try{navigator.hasOwnProperty("language")&&(this._languages=[navigator.language]),null==this._languages&&(this._languages=navigator.languages);var e=window.location.search,t=new Object;for(var r in e.replace(new RegExp("([^?=&]+)(=([^&]*))?","g"),(function(e,r,n,s){t[r]=s})),t)t[r]=decodeURIComponent(t[r]);this._parms=t,this._strings=new Object}catch(e){}}getParm(e){var t=null;return null!=this._parms&&this._parms.hasOwnProperty(e)&&(t=unescape(this._parms[e])),t}getParms(){return this._parms}load(e,t){this._delegate=t,D.create(e).get().then(this.response)}response(e,t,r){this._strings=new Object;for(var n,s,i,o=!1,a="",u=0;u<t.length;u++)"\n"==t[u]?(0==o&&(n=a.indexOf("="))>0&&(i=a.substr(0,n),s=a.substr(n+1),this._strings[i]=s),a="",o=!1):0==a.length?"#"==t[u]?o=!0:a+=t[u]:0==o&&(a+=t[u]);m.supports(this._delegate,"resourcesLoaded")&&this._delegate.resourcesLoaded(this)}error(e){var t=e.getUrl();t+="<br/>",t+=e.getResponseText(),alert(t)}getString(e,t){var r=null;if(null!=this._strings&&this._strings.hasOwnProperty(e)&&(r=this._strings[e]),null==r)return e+" not found";if(null!=t)for(var n in t)r=r.replace("$"+n,t[n]);return r}findString(e,t){var r=null;if(null!=this._strings&&this._strings.hasOwnProperty(e)&&(r=this._strings[e]),null!=r&&null!=t)for(var n in t)r=r.replace("$"+n,t[n]);return r}getStrings(){return this._strings}getLanguages(){return this._languages}getLocale(){return this._locale}setClassText(e,t,r){var n=null!=r?r:new Object,s=n.hasOwnProperty("contains")&&n.contains,i=n.hasOwnProperty("space")&&n.space,o=(!!n.hasOwnProperty("tips")&&n.tips,n.hasOwnProperty("element")?n.element:"*"),a=this.getString(t),u="";u+="//",u+=o,s?(u+="[contains(@class,'",u+=e,i&&(u+=" "),u+="')"):(u+="[@class='",u+=e,u+="'"),u+="]";for(var h=x.getNodes(u,document.body),l=0;l<h.length;l++)-1==(o=h[l]).className.indexOf("icon")?o.textContent=a:o.title=a}toString(){var e="";for(var t in this._strings)e+=t,e+="=",e+=this._strings[t];return e}};class G extends e{constructor(e,t){super(t),this._connection=e,this._version=this.createVersion(7.1),this._closed=!1,this.init()}get connection(){return this._connection}get connect(){return this._connection.connect}get version(){return this._version}set version(e){this._version=this.createVersion(e)}get protocol(){return this._connection.protocol}get httpProtocol(){return this._connection.httpProtocol}get host(){return this._connection.host}get port(){return this._connection.port}get isSecure(){return this._connection.isSecure}get urlBase(){return this._connection.urlBase}get url(){return this._connection.url}get httpurlBase(){return this._connection.httpurlBase}get httpurl(){return this._connection.httpurl}get closed(){return this._closed}set closed(e){this._closed=e}init(){this._datasources={},this._handlers={},this._publishers={},this._stats=new Y(this),this._log=new J(this),this._projectUpdateDelegates=[]}addHandler(e,t){0==m.supports(t,"process")&&m.exception("The handler must implement the process method"),this._handlers[e]=t}versionGreaterThan(e){var t=this.createVersion(e),r=!1;return this._version.major>=t.major&&this._version.minor>t.minor&&(r=!0),r}versionLessThan(e){var t=this.createVersion(e),r=!1;return this._version.major<=t.major&&this._version.minor<t.minor&&(r=!0),r}stop(){this._connection.stop()}closed(){}close(){this.closed=!0;var e={connection:{}};e.connection.action="close",this.sendObject(e)}send(e){this._connection.send(e)}sendObject(e){this._connection.sendObject(e)}sendBinary(e){this._connection.sendBinary(e)}message(e){if(0!=e.length){for(var t=null,r=null,n=0;n<e.length;n++){if("{"==e[n]||"["==e[n]){r=JSON.parse(e);break}if("<"==e[n]){t=x.createXml(e);break}}null!=r?this.processJson(r):null!=t&&this.processXml(t,e)}}data(e){this.processJson(e)}processJson(e){if(this.getOpt("debug_receive",!1)&&console.log(m.stringify(e)),e.hasOwnProperty("events")){if((n=e.events).hasOwnProperty("@id")){var t=n["@id"];null!=(r=this._datasources[t])&&r.events(n)}}else if(e.hasOwnProperty("info")){if((n=e.info).hasOwnProperty("@id")){var r;t=n["@id"];null!=(r=this._datasources[t])&&n.hasOwnProperty("page")&&(r._page=parseInt(n.page),r._pages=parseInt(n.pages),r.deliverInfoChange())}}else if(e.hasOwnProperty("schema")){t=(n=e.schema)["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n),delete this._handlers[t])}else if(e.hasOwnProperty("load-project")||e.hasOwnProperty("load-router")){t=(n=e.hasOwnProperty("load-project")?e["load-project"]:e["load-router"])["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n),delete this._handlers[t])}else if(e.hasOwnProperty("delete-project")){t=(n=e["delete-project"])["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n),delete this._handlers[t])}else if(e.hasOwnProperty("stats")){var n=e.stats;this._stats.processJson(n)}else if(e.hasOwnProperty("response")){t=(n=e.response)["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n),delete this._handlers[t])}else if(e.hasOwnProperty("url-publisher")||e.hasOwnProperty("data-publisher")){t=(n=e.hasOwnProperty("url-publisher")?e["url-publisher"]:e["data-publisher"])["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n),delete this._handlers[t])}else if(e.hasOwnProperty("loggers")){t=(n=e.loggers)["@id"];this._handlers.hasOwnProperty(t)&&(this._handlers[t].process(n.contexts),delete this._handlers[t])}else if(e.hasOwnProperty("project-loaded")||e.hasOwnProperty("project-removed"))if(e.hasOwnProperty("project-loaded")){var s=(n=e["project-loaded"]).name;for(var i in this._datasources)(o=this._datasources[i]).p==s&&(o.open(),o.deliverProjectLoaded());this._projectUpdateDelegates.forEach((e=>{e.projectLoaded(s)}))}else{var o;s=(n=e["project-removed"]).name;for(var i in this._datasources)(o=this._datasources[i]).p==s&&o.deliverProjectRemoved();this._projectUpdateDelegates.forEach((e=>{e.projectRemoved(s)}))}else if(e.hasOwnProperty("error")){if((n=e.error).hasOwnProperty("@id")){t=n["@id"];this._handlers.hasOwnProperty(t)?(m.supports(this._handlers[t]),this._handlers[t].error(n),delete this._handlers[t]):console.log(m.stringify(n))}}}processXml(e){const t=e.documentElement,r=t.nodeName,n=t.hasAttribute("id")?t.getAttribute("id"):"";if(this.getOpt("debug",!1)&&console.log(x.format(e.documentElement)),this._handlers.hasOwnProperty(n))this._handlers[n].process(e),delete this._handlers[n];else if("events"==r||"info"==r){if(this._datasources.hasOwnProperty(n)){var s=this._datasources[n];"events"==r?s.eventsXml(t):"info"==r&&s.info(t)}}else if("schema"==r)n.length>0?this._datasources.hasOwnProperty(n)&&this._datasources[n].setSchemaFromXml(t):t.hasAttribute("publisher")&&(n=t.getAttribute("publisher"),this._publishers.hasOwnProperty(n)&&this._publishers[n].setSchemaFromXml(t));else if("stats"==r)this._stats.processXml(e);else if("log"==r)this._log.process(e);else if("publisher"==r){if(this._publishers.hasOwnProperty(n)){var i=this._publishers[n];"true"==t.getAttribute("complete")&&(i._complete=!0)}}else"connection"==r&&console.log(x.format(t))}addProjectUpdateDelegate(e){if(0!=m.supports(e,"projectLoaded")&&0!=m.supports(e,"projectRemoved")||m.exception("The project update delegate must implement the projectLoaded and projectRemoved methods"),m.addTo(this._projectUpdateDelegates,e)&&1==this._projectUpdateDelegates.length){var t={"project-status":{}};t["project-status"].on=!0,this.sendObject(t)}}removeProjectUpdateDelegate(e){if(m.removeFrom(this._projectUpdateDelegates,e)&&0==this._projectUpdateDelegates.length){var t={"project-status":{}};t["project-status"].on=!1,this.sendObject(t)}}getDatasource(t){var r=new e(t),n="stream";return r.hasOpt("mode")&&(n=r.getOpt("mode")),"collection"==n?this.getEventCollection(r.getOpts()):this.getEventStream(r.getOpts())}getEventCollection(e){return new Promise(((t,r)=>{e.mode="collection";var n=new X(this,e);this._datasources[n._id]=n,n.open().then((function(e){t(e)}),(function(e){r(e)}))}))}getEventStream(e){return new Promise(((t,r)=>{var n=new K(this,e);this._datasources[n._id]=n,n.open().then((function(e){t(e)}),(function(e){r(e)}))}))}getPublisher(e){return new Promise(((t,r)=>{if(e.hasOwnProperty("id")){var n=e.id;if(this._publishers.hasOwnProperty(n))return void t(this._publishers[n])}var s=new Q(this,e);this._publishers[s._id]=s,s.open().then((function(e){t(s)}),(function(e){r(s)}))}))}closePublisher(e){this._publishers.hasOwnProperty(e)&&this._publishers[e].close()}clearWindow(e){var t={"clear-window":{}};t["clear-window"].window=e,this.sendObject(t)}publishDataFrom(e,t,r){return new Promise(((n,s)=>{var i=this;D.create(t).get().then((function(t){i.publishData(e,t.text,r)}),(function(e){console.log(e)}))}))}publishData(t,r,n){return new Promise(((s,i)=>{var o=new e(n),a=o.getOpt("blocksize",1),u=o.getOpt("times",1),h=o.getOpt("pause",0),l=o.getOpt("id",m.guid()),c={},p={"data-publisher":{}};(c=p["data-publisher"]).id=l,c.window=t,c.data=m.b64Encode(r),c.blocksize=a,c.times=u,c.pause=h,c.informat=o.getOpt("informat","csv"),o.hasOpt("dateformat")&&(c.dateformat=o.getOpt("dateformat")),o.hasOpt("opcode")&&(c.opcode=o.getOpt("opcode")),o.hasOpt("flags")&&(c.flags=o.getOpt("flags")),this.addHandler(l,{process:function(){s()}}),this.sendObject(p)}))}publishUrl(t,r,n,s){return new Promise(((n,i)=>{var o=new e(s),a=o.getOpt("blocksize",1),u=o.getOpt("times",1),h={},l=m.guid(),c={"url-publisher":{}};(h=c["url-publisher"]).id=l,h.window=t,h.url=r,h.blocksize=a,h.times=u,o.hasOpt("informat")&&(h.informat=o.getOpt("informat")),o.hasOpt("dateformat")&&(h.dateformat=o.getOpt("dateformat")),this.addHandler(l,{process:function(){n()}}),this.sendObject(c)}))}getStats(e){return null!=e&&this._stats.setOpts(e),this._stats}getLog(){return this._log}get(t,r){return new Promise(((n,s)=>{var i={get:{}},o=i.get,a=m.guid();o.id=a,o.url=t,o.format="cbor",this.addHandler(a,{process:function(t){if(t.hasOwnProperty("data")){const s=new e(r);var i=t.data;s.getOpt("decode",!0)&&(i=m.b64Decode(i)),n(i)}else s()}}),this.sendObject(i)}))}getModel(t){return new Promise(((r,n)=>{var s=m.guid(),i=new e(t),o={model:{}},a=o.model;a.id=s,a.schema=i.getOpt("schema",!1),a.index=i.getOpt("index",!0),a.xml=i.getOpt("xml",!1),i.hasOpt("name")&&(a.name=i.getOpt("name")),this.addHandler(s,{process:function(e){r(new L(e))}}),this.sendObject(o)}))}loadUrl(e,t){return new Promise(((e,r)=>{D.create(t).get().then((function(t){e(t)}),(function(e){r(e)}))}))}loadProjectFrom(e,t,r,n,s){return new Promise(((i,o)=>{var a=this;D.create(t).get().then((function(t){a.loadProject(e,t.text,r,n,s).then((function(){i()}),(function(){o()}))}),(function(e){o(e)}))}))}loadRouterFrom(e,t,r){return new Promise(((n,s)=>{var i=this;D.create(t).get().then((function(t){i.loadRouter(e,t.text,r).then((function(){n()}),(function(){s()}))}),(function(e){s(e)}))}))}loadProject(e,t,r,n,s){return new Promise(((i,o)=>{var a=m.guid(),u={project:{}},h=u.project;if(h.name=e,h.id=a,h.action="load",null!=r)for(var l in r)h[l]=r[l];if(null!=n&&Object.keys(n).length>0){var c={};for(var l in n)c[l]=n[l];h.parms=c}if(null!=s&&Object.keys(s).length>0){var p={};for(var l in s)p[l]=s[l];h.env=p}h.data=m.b64Encode(t),this.addHandler(a,{process:function(e){if(0==e["@code"])i();else{var t="";if(e.hasOwnProperty("text")&&(t+=e.text),e.hasOwnProperty("details")){var r=e.details;if(Array.isArray(r))for(var n of r)t+="\n",t+=n.detail;else t+=r.detail}o(t)}}}),this.sendObject(u)}))}loadRouter(e,t,r){return new Promise(((n,s)=>{var i=m.guid(),o={router:{}},a=o.router;if(a.name=e,a.id=i,a.action="load",null!=r)for(var u in r)a[u]=r[u];a.data=m.b64Encode(t),this.addHandler(i,{process:function(e){if(0==e["@code"])n();else{var t="";if(e.hasOwnProperty("text")&&(t+=e.text),e.hasOwnProperty("details")){var r=e.details;for(var i of r)t+="\n",t+=i.detail}s(t)}}}),this.sendObject(o)}))}deleteProject(e){return new Promise(((t,r)=>{var n=m.guid(),s=(this.url,{project:{}}),i=s.project;i.name=e,i.id=n,i.action="delete",this.addHandler(n,{process:function(e){0==e["@code"]?t(e):r(e)}}),this.sendObject(s)}))}getProjectXml(e,t){return new Promise(((r,n)=>{var s=m.guid(),i={xml:{}},o=i.xml;if(o.id=s,null!=e&&(o.name=e),null!=t)for(var a in t)o[a]=t[a];this.addHandler(s,{process:function(e){var t=e.documentElement,n=e,s=-1;t.hasAttribute("code")&&(s=parseInt(t.getAttribute("code"))),0==s&&(n=x.getNode(".//project",e)),r(n)}}),this.sendObject(i)}))}getXml(e,t){this.getProjectXml(null,t)}getLoggers(e){return new Promise(((t,r)=>{var n=m.guid(),s={loggers:{}},i=s.loggers;null!=e&&(i.context=e),i.id=n,this.addHandler(n,{process:function(e){t(e)}}),this.sendObject(s)}))}setLogger(e,t){return new Promise(((r,n)=>{var s=m.guid(),i={loggers:{}},o=i.loggers;o.id=s,o.context=e,o.level=t,this.addHandler(s,{process:function(e){r(e)}}),this.sendObject(i)}))}createModel(e){return new L(e)}getGuids(e){return new Promise(((t,r)=>{var n=m.guid(),s={guids:{}},i=s.guids;i.id=n,null!=e&&(i.num=e),this.addHandler(n,{process:function(e){for(var r=[],n=x.getNodes("./guid",e.documentElement),s=0;s<n.length;s++)r.push(x.nodeText(n[s]));t(r)}}),this.sendObject(s)}))}guid(){return m.guid()}getStatus(){this.sendObject({request:"status"})}createVersion(e){var t=new String(e).split("."),r=0,n=0;return 2==t.length&&(r=parseInt(t[0]),n=parseInt(t[1])),{major:r,minor:n}}createEventSources(e){return V(this,e)}handleError(e,t){var r="";if(e.hasOwnProperty("text")&&(r+=e.text),e.hasOwnProperty("details")){var n=e.details;for(var s of n)r+="\n",r+=s.detail}m.supports(t,"error")?t.error(r):console.log(r)}toString(){var e="";return e+=this._connection.getUrl()}}class z extends e{constructor(e,t){super(t),this._api=e,this._id=this.getOpt("id",m.guid()),this._path=this.getOpt("window"),this._schema=new I;var r=this._path.split("/");if(3!=r.length)throw"The window must be in the form project/contquery/window";this._p=r[0],this._cq=r[1],this._w=r[2],this._data=null,this._list=null,this._delegates=[],this._paused=!1}get id(){return this._id}get p(){return this._p}get cq(){return this._cq}get w(){return this._w}get api(){return this._api}get connection(){return this._api.connection}get schema(){return this._schema}get name(){var e=this.getOpt("name","");return 0==e.length&&(e=this.getOpt("window")),e}set name(e){this.setOpt("name",e)}get size(){var e=0;return null!=this._data&&(e=Array.isArray(this._data)?this._data.length:Object.keys(this._data).length),e}isArray(){return null!=this._data&&Array.isArray(this._data)}setIntervalProperty(){var e=null;this.hasOpt("interval")?e=this.getOpt("interval"):this._api.hasOpt("interval")&&(e=this._api.getOpt("interval")),null==e&&(e=0),this.setOpt("interval",e)}setFilter(e){this.setOpt("filter",e),this.set(!0),this.deliverFilterChange()}clearFilter(){this.clearOpt("filter"),this.set(!0),this.deliverFilterChange()}getFilter(){return this.getOpt("filter")}play(){this._paused=!1}pause(){this._paused=!0}togglePlay(){var e=!1;return this._paused?(this.play(),e=!0):this.pause(),e}setSchemaFromXml(e){this._schema.fromXml(e)}setSchemaFromJson(e){this._schema.fromJson(e,this)}getKey(e){var t,r="";return this._schema._keyFields.forEach((n=>{t=n.getOpt("name"),0!=e.hasOwnProperty(t)&&(r.length>0&&(r+="-"),r+=e[t])})),r}isSelected(e){return null!=e&&e.hasOwnProperty("@selected")&&1==e["@selected"]}toggleSelectedKeys(e,t){var r;t&&this.deselectAll(),e.forEach((e=>{null!=(r=this.getDataByKey(e))&&this.toggleSelected(r)})),this.deliverSelectionChange(null,!1)}toggleSelected(e){return e.hasOwnProperty("@selected")?e["@selected"]=!e["@selected"]:e["@selected"]=!1,e["@selected"]}deselectAll(){Array.isArray(this._data)?this._data.forEach((e=>{e["@selected"]=!1})):Object.values(this._data).forEach((e=>{e["@selected"]=!1}))}setSelectedIndices(e,t){t&&this.deselectAll();var r=this.getList();e.forEach((e=>{e<r.length&&(r[e]["@selected"]=!0)})),this.deliverSelectionChange(null,!1)}toggleSelectedIndices(e,t){t&&this.deselectAll();var r=this.getList();e.forEach((e=>{e<r.length&&this.toggleSelected(r[e])})),this.deliverSelectionChange(null,!1)}selectByKeys(e){this.deselectAll(),e.forEach((e=>{console.log("key: "+e)}))}getSelectedItems(){var e=[];return this.getList().forEach((t=>{this.isSelected(t)&&e.push(t)})),e}getSelectedIndices(){var e=[],t=0;return this.getList().forEach((r=>{this.isSelected(r)&&e.push(t),t++})),e}getSelectedKeys(){var e=[];return this.getList().forEach((t=>{this.isSelected(t)&&e.push(t["@key"])})),e}getSelectedItem(){var e=this.getSelectedItems();return e.length>0?e[0]:null}getSelectedIndex(){var e=this.getSelectedIndices();return e.length>0?e[0]:null}getSelectedKey(){var e=this.getSelectedKeys();return e.length>0?e[0]:null}getKeyValues(){var e=[];if(Array.isArray(this._data))for(var t of this._data)e.push(t["@key"]);else for(var r in this._data)e.push(r);return e}getList(){var e=null;if(null!=this._data)if(Array.isArray(this._data))e=this._data;else if(null!=this._list)e=this._list;else for(var t in e=[],this._data)e.push(this._data[t]);return e}getValues(e){var t=this._schema.getField(e);if(null==t)return null;var r,n=[],s=t.getOpt("isNumber",!1);if(Array.isArray(this._data)||null!=this._list)(null!=this._list?this._list:this._data).forEach((t=>{t.hasOwnProperty(e)?s?n.push(parseFloat(t[e])):n.push(t[e]):s?n.push(0):n.push("")}));else for(var i in this._data)(r=this._data[i]).hasOwnProperty(e)?s?n.push(parseFloat(r[e])):n.push(r[e]):s?n.push(0):n.push("");return n}getLimits(e){var t=null,r=this.getValues(e);r.length>0&&(t={min:Math.min.apply(Math,r),max:Math.max.apply(Math,r),values:r});return t}getValuesBy(e,t,r,n="."){if(0==this.schema.size)return null;var s,i={},o=[];for(var a of e){if(null==(s=this._schema.getField(a)))throw"field "+a+" not found";null!=r&&r.hasOwnProperty(s.getOpt("name"))||(o.push(s),i[s.getOpt("name")]=[])}var u=!1,h=!1;1==o.length&&((s=o[0]).getOpt("isDate",!1)?u=!0:s.getOpt("isTime",!1)&&(h=!0));var l=[];for(var a of t){if(null==(s=this._schema.getField(a)))throw"field "+a+" not found";l.push(s)}var c=this.getList();if(null==c)throw"invalid data";var p,d,f,g,m={};for(var v of c){if(null!=r){var _=!0;for(var y in r)if(r[y]!=v[y]){_=!1;break}if(0==_)continue}if(g="",o.forEach((e=>{f=e.getOpt("name"),v.hasOwnProperty(f)&&(p=v[f],g.length>0&&(g+=n),g+=p,0==i[f].includes(p)&&i[f].push(p))})),m.hasOwnProperty(g))d=m[g];else{for(s of(d={},l))f=s.getOpt("name"),d[f]=0;m[g]={key:g,data:d,selected:this.isSelected(v)}}for(s of l)s.getOpt("isNumber",!1)&&(f=s.getOpt("name"),d[f]+=parseFloat(v[f]))}var w={};for(s of l)f=s.getOpt("name"),w[f]=[];var b=[],O=[];return Object.values(m).forEach((e=>{if(g=e.key,d=e.data,u){var t=new Date,r=1e3*new Number(g);t.setTime(r),b.push(t)}else if(h){t=new Date,r=new Number(g)/1e3;t.setTime(r),b.push(t)}else b.push(g);for(s of(O.push(e.selected),l))f=s.getOpt("name"),s.getOpt("isNumber",!1)?w[f].push(parseFloat(d[f])):w[f].push(d[f])})),{keys:b,keyvalues:i,values:w,selected:O}}getKeyFieldNames(){return null!=this._schema?this._schema.getKeyFieldNames():null}events(e){}info(e){}set(e){}addDelegate(e){0==m.supports(e,"dataChanged")&&m.exception("The datasource delegate must implement the dataChanged method"),m.addTo(this._delegates,e)}removeDelegate(e){m.removeFrom(this._delegates,e)}clear(){null!=this._data&&(Array.isArray(this._data),this._data=[]),this.deliverDataChange(null,!0)}deliverDataChange(e,t){this._delegates.forEach((r=>{r.dataChanged(this,e,t)}))}deliverInfoChange(){this._delegates.forEach((e=>{m.supports(e,"infoChanged")&&e.infoChanged(this)}))}deliverInfo(e){this._delegates.forEach((t=>{m.supports(t,"info")&&t.info(this,e)}))}deliverFilterChange(){this._delegates.forEach((e=>{m.supports(e,"filterChanged")&&e.filterChanged(this)}))}deliverSelectionChange(){this._delegates.forEach((e=>{m.supports(e,"selectionChanged")&&e.selectionChanged(this)}))}deliverProjectLoaded(){this._delegates.forEach((e=>{m.supports(e,"projectLoaded")&&e.projectLoaded(this)}))}deliverProjectRemoved(){this._delegates.forEach((e=>{m.supports(e,"projectRemoved")&&e.projectRemoved(this)}))}getDataByKey(e){var t=null;if(null!=this._data)if(Array.isArray(this._data)){for(var r of this._data)if(e==r["@key"]){t=r;break}}else t=this._data[e];return t}createDataFromCsv(e){var t=null;return null!=this._schema&&(t=this._schema.createDataFromCsv(e)),t}}class X extends z{constructor(e,t){super(e,t),this.setOpt("format","cbor"),this._data={},this._list=[],this._page=0,this._pages=0,this._sort=null,this._sortdir=0}open(){return new Promise(((e,t)=>{var r={"event-collection":{}},n=r["event-collection"];n.id=this._id,n.action="set",n.window=this._path,n.schema=!0,n.load=!0,n.info=5,n.format="xml",this.setIntervalProperty();var s=this.getOpts();for(var i in s)n[i]=s[i];0==this.hasOpt("filter")&&(n.filter="");const o=this;this._api.addHandler(this._id,{process:function(t){o._schema.fromJson(t),e(o)},error:function(e){t(e)}}),this._api.sendObject(r)}))}set(e){var t={"event-collection":{}},r=t["event-collection"];r.id=this._id,r.action="set",this.setIntervalProperty();var n=this.getOpts();for(var s in n)r[s]=n[s];0==this.hasOpt("filter")&&(r.filter=""),r.load=1==e,this._api.sendObject(t)}close(){var e={"event-collection":{}},t=e["event-collection"];t.id=this._id,t.action="close",this._api.sendObject(e)}play(){var e={"event-collection":{}},t=e["event-collection"];t.id=this._id,t.action="play",this._api.sendObject(e),super.play(this)}pause(){var e={"event-collection":{}},t=e["event-collection"];t.id=this._id,t.action="pause",this._api.sendObject(e),super.play(this)}sort(e,t){var r=parseFloat(e[this._sort]),n=parseFloat(t[this._sort]);return 0==this._sortdir?n-r:r-n}load(){this.loadPage(null)}first(){this.loadPage("first")}last(){this.loadPage("last")}prev(){this.loadPage("prev")}next(){this.loadPage("next")}loadPage(e){var t={"event-collection":{}},r=t["event-collection"];r.id=this._id,r.action="load",null!=e&&(r.page=e),this._api.sendObject(t)}setSchemaFromXml(e){super.setSchemaFromXml(e),this.deliverSchemaSet()}setSchemaFromJson(e){super.setSchemaFromJson(e),this.deliverSchemaSet()}events(e){if(this.getOpt("debug")&&(console.log("events for "+this._path),console.log(m.stringify(e))),0!=e.hasOwnProperty("entries")){var t,r=[],n=e.entries;if(null!=n)n.forEach((e=>{for(var n in t={},e)t[n]=e[n];0==t.hasOwnProperty("@opcode")&&(t["@opcode"]="insert"),t["@key"]=this.getKey(t),r.push(t)}));var s=e.hasOwnProperty("info")?e.info:null;this.process(r,null!=s),null!=s&&this.info(s)}}eventsXml(e){this.getOpt("debug")&&(console.log("events for "+this._path),console.log(x.format(e)));var t,r,n,s,i=[];x.getNodes("//entries/event",e);x.getNodes("//entries/event",e).forEach((e=>{null!=(n=e.getAttribute("opcode"))&&0!=n.length||(n="insert"),o={},o["@opcode"]=n,null!=(s=e.getAttribute("timestamp"))&&s.length>0&&(o["@timestamp"]=s),x.getNodes("./*",e).forEach((function(e){t=e.getAttribute("type"),r=e.textContent,null!=t&&t.length>0?o[e.nodeName]="_data://"+t+":"+r:o[e.nodeName]=r})),o["@key"]=this.getKey(o),i.push(o)}));var a=e.hasAttribute("page");this.process(i,a),a&&this.info(e)}info(e){e.hasOwnProperty("page")&&(this._page=e.page,this._pages=e.pages,this.deliverInfoChange())}process(e,t){var r,n,s=null;t&&(s=this.getSelectedKeys(),this._data={},this._list=[]),e.forEach((e=>{null!=(r=e["@key"])&&("delete"==e["@opcode"]?this._data.hasOwnProperty(r)&&(m.removeFrom(this._list,this._data[r]),delete this._data[r]):t?((n={})["@key"]=r,this._data[r]=n,this._list.push(n),n["@selected"]=s.includes(r),this._schema._columns.forEach((t=>{e.hasOwnProperty(t)&&(n[t]=e[t])}))):(this._data.hasOwnProperty(r)?(n=this._data[r],m.setItem(this._list,n)):((n={})["@key"]=r,n["@selected"]=!1,this._data[r]=n,this._list.push(n)),this._schema._columns.forEach((t=>{e.hasOwnProperty(t)&&(n[t]=e[t])}))))})),this.deliverDataChange(e,t)}}class K extends z{constructor(e,t){super(e,t),this.setOpt("format","json"),this.setOpt("format","cbor"),this._data=[],this._counter=1}open(){return new Promise(((t,r)=>{var n={"event-stream":{}},s=n["event-stream"];s.id=this._id,s.action="set",s.window=this._path,s.schema=!0,s.load=!0,s.format="xml",this.setIntervalProperty();var i=this.getOpts();for(var o in i)s[o]=i[o];0==this.hasOpt("filter")&&(s.filter="");const a=this;this._api.addHandler(this._id,{process:function(r){a._schema.fromJson(r);for(var n=0;n<a._schema._fields.length;n++)a._schema._fields[n].setOpt("isKey",!1);var s;s=new e({name:"@opcode",espType:"utf8str",type:"string",isKey:!1,isNumber:!1,isDate:!1,isTime:!1}),a._schema._fields.unshift(s),a._schema._columns.unshift(s.getOpt("name")),a._schema._fieldMap[s.getOpt("name")]=s,s=new e({name:"@timestamp",espType:"timestamp",type:"date",isKey:!1,isNumber:!0,isDate:!1,isTime:!0}),a._schema._fields.unshift(s),a._schema._columns.unshift(s.getOpt("name")),a._schema._fieldMap[s.getOpt("name")]=s,s=new e({name:"@counter",espType:"int32",type:"int",isKey:!0,isNumber:!0,isDate:!1,isTime:!1}),a._schema._fields.unshift(s),a._schema._columns.unshift(s.getOpt("name")),a._schema._fieldMap[s.getOpt("name")]=s,a._schema._keyFields=[s],t(a)},error:function(e){console.log("got error"),r(e)}}),this._api.sendObject(n)}))}set(e){var t={"event-stream":{}},r=t["event-stream"];r.id=this._id,r.action="set",this.setIntervalProperty();var n=this.getOpts();for(var s in n)r[s]=n[s];0==this.hasOpt("filter")&&(r.filter=""),r.load=1==e,this._api.sendObject(t)}close(){var e={"event-stream":{}},t=e["event-stream"];t.id=this._id,t.action="close",this._api.sendObject(e)}play(){var e={"event-stream":{}},t=e["event-stream"];t.id=this._id,t.action="play",this._api.sendObject(e),super.play(this)}pause(){var e={"event-stream":{}},t=e["event-stream"];t.id=this._id,t.action="pause",this._api.sendObject(e),super.play(this)}setSchemaFromXml(e){super.setSchemaFromXml(e,this),this.deliverSchemaSet()}setSchemaFromJson(e){super.setSchemaFromJson(e),this.deliverSchemaSet()}events(e){if(this.getOpt("debug")&&(console.log("events for "+this._path),console.log(m.stringify(e))),0!=e.hasOwnProperty("entries")){var t=e.entries,r=[];if(null!=t){var n,s=this.getOpt("ignore_deletes",!1);for(var i of t){for(var o in n={},i)n[o]=i[o];if(0==n.hasOwnProperty("@opcode"))n["@opcode"]="insert";else if(s&&"delete"==n["@opcode"])continue;n["@key"]=this.getKey(n),r.push(n)}}this.process(r)}}eventsXml(e){this.getOpt("debug")&&(console.log("events for "+this._path),console.log(x.format(e)));for(var t,r,n,i,o,a,u=x.getNodes("//entries/event",e),h=new Array,l=this.getOpt("ignore_deletes",!1),c=0;c<u.length;c++)if(null!=(n=(o=u[c]).getAttribute("opcode"))&&0!=n.length||(n="insert"),"delete"!=n||!l){(a={})["@opcode"]=n,s=o.getAttribute("timestamp"),null!=s&&s.length>0&&(a["@timestamp"]=s),r=x.getNodes("./*",o);for(var p=0;p<r.length;p++)i=r[p].getAttribute("type"),t=r[p].textContent,null!=i&&i.length,a[r[p].nodeName]=t;h.push(a)}this.process(h)}process(e){var t,r=!1;e.length>0&&((n=e[0]).hasOwnProperty("event")&&"object"==typeof n.event&&(r=!0));for(var n of e){for(var s of(t={},r&&(n=n.event),this._schema._columns))n.hasOwnProperty(s)&&(n[s].hasOwnProperty("*value")?t[s]=n[s]["*value"]:t[s]=n[s]);t["@counter"]=this._counter,t["@key"]=this.getKey(t),t["@selected"]=!1,n["@counter"]=t["@counter"],n["@key"]=t["@key"],this._counter+=1,this._data.push(t)}var i=this.getOpt("maxevents",50),o=this._data.length-i;if(o>0)for(var a=0;a<o;a++)this._data.shift();this.deliverDataChange(e,!1)}info(e){}}class Y extends e{constructor(e,t){super(t),this._api=e;var r=W.getString("Project"),n=W.getString("Contquery"),s=W.getString("Window"),i=W.getString("CPU"),o=W.getString("Interval"),a=W.getString("Count"),u=new Array;u.push({name:"project",label:r,isKey:!0}),u.push({name:"contquery",label:n,isKey:!0}),u.push({name:"window",label:s,isKey:!0}),u.push({name:"cpu",label:i,type:"int"}),u.push({name:"interval",label:o,type:"int"}),u.push({name:"count",label:a,type:"int"}),this._windows=[],this._memory={},this._config={},this._delegates=[]}get api(){return this._api}get windows(){return this._windows}get memory(){return this._memory}get config(){return this._config}process(e){}processJson(e){if(this._windows=[],e.hasOwnProperty("projects"))for(var t=e.projects,r=0;r<t.length;r++){var n=t[r];if(0!=n.hasOwnProperty("contqueries"))for(var s=n["@name"],i=n.contqueries,o=0;o<i.length;o++){var a=i[o];if(0!=a.hasOwnProperty("windows"))for(var u=a["@name"],h=a.windows,l=0;l<h.length;l++){var c=h[l],p=new Object;p.project=s,p.contquery=u,p.window=c["@name"],p.cpu=new Number(c["@cpu"]),p.interval=new Number(c["@interval"]),p.count=c.hasOwnProperty("@count")?new Number(c["@count"]):0,p["@key"]=s+"."+u+"."+c["@name"],this._windows.push(p)}}}if(this._windows.sort(this.sort),this._memory={},e.hasOwnProperty("server-memory")){var d=e["server-memory"];this._memory.system=d.system,this._memory.virtual=d.virtual,this._memory.resident=d.resident}if(this._config={},e.hasOwnProperty("properties")){var f,g,m=e.properties;for(r=0;r<m.length;r++)f=m[r]["@name"],g=m[r]["*value"],this._config[f]=!(null!=g&&g.length>0)||g}for(r=0;r<this._delegates.length;r++)this._delegates[r].handleStats(this)}processXml(e){this._windows=[];for(var t,r,n,s,i,o,a=x.getNodes(".//project",e),u=0;u<a.length;u++){n=a[u].getAttribute("name"),t=x.getNodes("./contquery",a[u]);for(var h=0;h<t.length;h++){s=t[h].getAttribute("name"),r=x.getNodes("./window",t[h]);for(var l=0;l<r.length;l++)i=r[l],(o=new Object).project=n,o.contquery=s,o.window=i.getAttribute("name"),o.cpu=new Number(i.getAttribute("cpu")),o.interval=new Number(i.getAttribute("interval")),o.count=new Number(i.getAttribute("count")),this._windows.push(o)}}this._windows.sort(this.sort),this._memory={};var c=x.getNode(".//server-memory",e);null!=c&&(this._memory.system=parseInt(x.getString("system",c)),this._memory.virtual=parseInt(x.getString("virtual",c)),this._memory.resident=parseInt(x.getString("resident",c))),this._config={};var p,d,f=x.getNodes(".//properties/property",e);if(f.length>0)for(var g of f)p=g.getAttribute("name"),d=x.nodeText(g),this._config[p]=!(d.length>0)||d;for(u=0;u<this._delegates.length;u++)this._delegates[u].handleStats(this)}sort(e,t){return t-e}optionSet(e,t){null!=this._delegates&&this._delegates.length>0&&this.set()}set(){var e={stats:{}},t=e.stats;t.action="set",t.interval=this.getOpt("interval",1),t.minCpu=this.getOpt("mincpu",5),t.counts=this.getOpt("counts",!1),t.config=this.getOpt("config",!1),t.memory=this.getOpt("memory",!0),t.format="xml",t.format="cbor",this._api.sendObject(e)}stop(){var e={stats:{}};e.stats.action="stop",this._api.sendObject(e)}addDelegate(e){if(0==m.supports(e,"handleStats"))throw"The stats delegate must implement the handleStats method";m.addTo(this._delegates,e)&&1==this._delegates.length&&this.set()}removeDelegate(e){m.removeFrom(this._delegates,e)&&0==this._delegates.length&&this.stop()}getWindows(){return this._windows}getMemoryData(){return this._memory}getConfig(){return this._config}}class J extends e{constructor(e,t){super(t),this._api=e,this._delegates=[],this._filter=null}get filter(){return this._filter}set filter(e){this._filter=e;var t={logs:{}};t.logs.filter=this._filter,this._api.sendObject(t)}process(e){for(var t,r=x.nodeText(e.documentElement),n=0;n<this._delegates.length;n++)t=this.createObject(r),this._delegates[n].handleLog(this,t)}createObject(e){if(null==e||0==e.length)return null;var t=null;if("{"==e[0])try{t=JSON.parse(e)}catch(e){console.log("log parse error")}else{var r,n;if((t={})._timestamp=e.substr(0,19),-1!=(n=e.indexOf("["))&&-1!=(r=e.indexOf("]",n))){var s=(i=e.substring(n+1,r-1)).split(":");3==s.length&&(t.logLevel=s[0],t.messageFile=s[1],t.messageLine=s[2])}if(-1!=r)if(-1!=(n=e.indexOf("[",r+1))&&(r=e.indexOf("]",n+1)),-1!=r){var i=e.substr(r+1);i=e.replace(this._newlines,"<br/>"),i=e.replace(this._spaces," "),t.messageContent=i}}return t}start(){var e={logs:{}};e.logs.capture=!0,this._api.sendObject(e)}stop(){var e={logs:{}};e.logs.capture=!1,this._api.sendObject(e)}addDelegate(e){if(0==m.supports(e,"handleLog"))throw"The stats delegate must implement the handleLog method";return m.addTo(this._delegates,e)&&1==this._delegates.length&&this.start(),!0}removeDelegate(e){m.removeFrom(this._delegates,e)&&0==this._delegates.length&&this.stop()}}class Q extends e{constructor(e,t){super(t),this._api=e,this._path=this.getOpt("window"),this._id=this.getOpt("id",m.guid()),this._data=new Array,this._schema=new I,this._total=0,this._csv=null}get schema(){return this._schema}get size(){return this._data.length}get total(){return this._total}open(){return new Promise(((e,t)=>{var r={};this.addOpts(r);var n={publisher:{}};(r=n.publisher).id=this._id,r.action="set",r.window=this._path,r.schema=!0,this.hasOpt("dateformat")&&(r.dateformat=this.getOpt("dateformat")),0==this._api._publishers.hasOwnProperty(this._id)&&(this._api._publishers[this._id]=this);const s=this;this._api.addHandler(this._id,{process:function(t){s._schema.fromJson(t),e()},error:function(e){console.log("error: "+JSON.stringify(e)),t()}}),this._api.sendObject(n)}))}close(){var e={publisher:{}},t=e.publisher;t.id=this._id,t.action="delete",this._api._publishers.hasOwnProperty(this._id)&&delete this._api._publishers[this._id],this._api.sendObject(e)}begin(){this._o=new Object}set(e,t){null!=this._o&&(this._o[e]=t)}end(){null!=this._o&&(this._data.push(this._o),this._o=new Object)}add(e){if(Array.isArray(e))for(var t of e)this._data.push(e);else this._data.push(e)}publish(){if(this._data.length>0){var e={publisher:{}},t=e.publisher;t.id=this._id,t.action="publish",t.data=this._data,this.getOpt("binary",!1)?this._api.sendBinary(e):this._api.sendObject(e),this._total+=this._data.length,this._data=new Array}}send(){if(this._csv.index<this._csv.items.length){const r=this._csv.options.getOpt("chunksize",1);this._csv.options.getOpt("opcode","insert");for(;this._csv.index<this._csv.items.length&&(this.add(this._csv.items[this._csv.index]),this._csv.index++,!(this.size>=r)););if(this.publish(),this._csv.index<this._csv.items.length){var e=this._csv.options.getOpt("pause",0);if(e>0){var t=this;setTimeout((function(){t.send()}),e)}}else this._csv.options.getOpt("close",!1)&&this.close()}}csv(){this._csv.items=this._schema.createDataFromCsv(this._csv.data,this._csv.options.getOpts());const e=this._csv.options.getOpt("pause",0);if(e>0){var t=this;setTimeout((function(){t.send()}),e)}else{const e=this._csv.options.getOpt("chunksize",1);this._csv.options.getOpt("opcode","insert");for(var r of this._csv.items)r.hasOwnProperty("@opcode")||r.hasOwnProperty("opcode")?r.opcode=r.hasOwnProperty("@opcode")?r["@opcode"]:r.opcode:r.opcode="insert",this.add(r),this.size>=e&&this.publish();this.publish(),this._csv.options.getOpt("close",!1)&&this.close()}}publishCsvFrom(e,t){var r=this;D.create(e).get().then((function(e){r.publishCsv(e.text,t)}),(function(e){console.log("error: "+e)}))}publishCsv(t,r){this._csv={data:t,options:new e(r),index:0},0!=this._schema.size&&this.csv()}isBinary(){return this.getOpt("binary",!0)}}class $ extends b{constructor(e,t,r,n,s,i,o){super(t,r,n,s,o,e.config),this._connect=e,this._delegates=[],null!=i&&(Array.isArray(i)?i.forEach((e=>{m.addTo(this._delegates,e)})):m.addTo(this._delegates,i)),this._impl=null}get connect(){return this._connect}handshakeComplete(){var e=this.getHeader("version");null!=e&&(this._impl=new G(this,this.getOpts())),null!=this._impl&&(this._impl.version=e,this._delegates.forEach((e=>{m.supports(e,"ready")&&e.ready(this._impl)})))}load(t){return new Promise(((r,n)=>{var s=new e(t),i=t.hasOwnProperty("options")?t.options:{},o=t.hasOwnProperty("parms")?t.parms:{},a=t.hasOwnProperty("env")?t.env:{};if(s.getOpt("force",!1))this._impl.loadProject(t.name,t.data,i,o,a).then((function(){r()}),(function(e){n(e)}));else{const e=this;this._impl.getProjectXml(t.name).then((function(s){var u=null;if(1==s.nodeType?u=s:9==s.nodeType&&(u=s.documentElement),null==u)e._impl.loadProject(t.name,t.data,i,o,a).then((function(){r()}),(function(e){n(e)}));else{u.removeAttribute("name");const s=x.xmlString(u);t.data!=s?e._impl.loadProject(t.name,t.data,i,o,a).then((function(){r()}),(function(e){n(e)})):r()}}))}}))}closed(e){if(null!=this._impl){this._delegates.forEach((e=>{m.supports(e,"closed")&&e.closed(this._impl)}));const e=this._impl.closed;if(null!=this._impl&&(this._impl=null),0==e){var t=this.getOpt("reconnect",1);t>0&&this.reconnect(t)}}}error(e){if(null==this._impl||!this._impl.closed){if(0==m.established(this.getUrl()))if(m.isNode){if(this.isSecure){var t="\n\nconnection to "+this.getUrl()+" failed. If you are using self-signed certificates you may need to\n\nexport NODE_TLS_REJECT_UNAUTHORIZED=0\n\nin your environment\n\n";throw new Error(t)}}else if(this.isSecure){var r=this.httpurlBase;r+="/eventStreamProcessing/v1/server",window.open(r)}this._delegates.forEach((e=>{m.supports(e,"connectionError")&&e.connectionError(this)}));var n=this.getOpt("reconnect",5);n>0&&this.reconnect(n)}}message(e){0!=this.isHandshakeComplete()?null!=this._impl&&this._impl.message(e):super.message(e)}data(e){null!=this._impl&&this._impl.data(e)}addDelegate(e){m.addTo(this._delegates,e),null!=this._impl&&m.supports(e,"ready")&&e.ready(this._impl)}removeDelegate(e){m.removeFrom(this._delegates,e)}getUrl(){var e="";e+=this.protocol,e+="://",e+=this.host,e+=":",e+=this.port,null!=this._path&&this._path.length>0&&(e+=this._path),0==e.endsWith("/")&&(e+="/"),e+="eventStreamProcessing/v1/connect";var t="",r="";return this.hasOpt("access_token")&&(t+="access_token="+this.getOpt("access_token")),this.hasOpt("threadin")&&(r+="incoming"),this.hasOpt("threadout")&&(r.length>0&&(r+=","),r+="outgoing"),r.length>0&&(t.length>0&&(t+="&"),t+="_threads="+r),t.length>0&&(e+="?"+t),e}}var Z=function(e,t,r,n){var s=m.createUrl(decodeURI(t));return new $(e,s.host,s.port,s.path,s.secure,r,n)};class ee{constructor(){this._servers={},this._connections={},this._destinations={},this._routes={},this._models={},this._errors={}}configure(e){var t=x.createXml(e);x.getNodes("//esp-engines/esp-engine",t).forEach((e=>{var t=e.getAttribute("name"),r="http://"+e.getAttribute("host")+":"+e.getAttribute("port");this.addServer(t,r)})),x.getNodes("//esp-destinations/*",t).forEach((e=>{if("publish-destination"==e.tagName){var t=e.getAttribute("name"),r=x.getNode("publish-target",e);if(null==r)throw"no target for publish destination";var n,s=new re(this);if(s.opcode=e.getAttribute("opcode"),null==(n=x.getNode("engine-func",r)))throw"you must supply the engine-func element";if(s.getEngine=new Function("data",x.nodeText(n)),null==(n=x.getNode("project-func",r)))throw"you must supply the project-func element";if(s.getProject=new Function("data",x.nodeText(n)),null==(n=x.getNode("contquery-func",r)))throw"you must supply the contquery-func element";if(s.getContquery=new Function("data",x.nodeText(n)),null==(n=x.getNode("window-func",r)))throw"you must supply the window-func element";s.getWindow=new Function("data",x.nodeText(n)),this._destinations[t]=s}})),this._routes={},x.getNodes("//esp-routes/esp-route",t).forEach((e=>{var t,r=e.getAttribute("name"),n=new ne(r,this);n.to=e.getAttribute("to"),null!=(t=x.getNode("engine-expr",e))&&(n.engine=x.nodeText(t)),null!=(t=x.getNode("project-expr",e))&&(n.project=x.nodeText(t)),null!=(t=x.getNode("contquery-expr",e))&&(n.contquery=x.nodeText(t)),null!=(t=x.getNode("window-expr",e))&&(n.win=x.nodeText(t)),this._routes[r]=n}))}addServer(e,t){this._servers[e]=t}addDestination(e){var t=new te(this);return this._destinations[e]=t,t}addPublishDestination(e){var t=new re(this);return this._destinations[e]=t,t}addRoute(e){var t=new ne(e,this);return this._routes[e]=t,t}ready(e){this._connections[e.getOpt("name")]=e;const t=this;e.getModel().then((function(r){t.modelLoaded(r,e)}))}error(e){var t=e.getOpt("name");0==this._errors.hasOwnProperty(t)&&(console.log("server error "+e),this._errors[t]=e),delete this._models[t]}getEngine(e){return this._connections.hasOwnProperty(e)?this._connections[e]:null}getModel(e){return this._models.hasOwnProperty(e)?this._models[e]:null}modelLoaded(e,t){var r=t.getOpt("name");this._models[r]=e,this._errors.hasOwnProperty(r)&&(console.log("server back up "+t),delete this._errors[r]),Object.keys(this._models).length+Object.keys(this._errors).length==Object.keys(this._connections).length&&(Object.values(this._destinations).forEach((e=>{e.init()})),Object.values(this._routes).forEach((e=>{e.init()})))}start(){Object.values(this._connections).forEach((e=>{e.close()})),this._connections={},Object.keys(this._servers).forEach((e=>{var t=this._servers[e];Z(t,this,{name:e}).start()}))}stop(){Object.values(this._connections).forEach((e=>{e.close()}))}}class te{constructor(e){this._router=e}init(){if(0==m.supports(this,"process"))throw"destination must implement the process(data) method"}}class re extends te{constructor(e){super(e),this._publishers={},this._opcode=null}set opcode(e){this._opcode=e}get opcode(){return this._opcode}init(){super.init(),["getEngine","getProject","getContquery","getWindow"].forEach((e=>{if(0==m.supports(this,e))throw"destination must implement the "+e+" method"})),this._publishers={}}process(e){var t=this.getEngine(e);if(null!=t){var r=this._router.getEngine(t);if(null!=r){var n=this.getProject(e),s=this.getContquery(e),i=this.getWindow(e),o=t+"/"+n+"/"+s+"/"+i,a=null;if(this._publishers.hasOwnProperty(o))a=this._publishers[o];else{var u=n+"/"+s+"/"+i;a=r.getPublisher({window:u,id:u,binary:!0}),this._publishers[o]=a}a.add(e),a.publish()}else console.log("cannot find engine: "+t)}}}class ne{constructor(e,t){this._name=e,this._router=t,this._engine=null,this._project=null,this._contquery=null,this._window=null,this._to=null,this._destinations=[]}get name(){return this._name}get engine(){return this._engine}set engine(e){this._engine=null!=e?new RegExp(e):null}get project(){return this._project}set project(e){this._project=null!=e?new RegExp(e):null}get contquery(){return this._contquery}set contquery(e){this._contquery=null!=e?new RegExp(e):null}get win(){return this._window}set win(e){this._window=null!=e?new RegExp(e):null}get to(){return this._to}set to(e){this._to=null!=e?e.split(","):null}init(){if(null==this._to)throw"route "+this.name+" does not have any destinations associated with it";null!=this._engine&&Object.keys(this._router._connections).forEach((e=>{if(this._engine.test(e)){var t=this._router._connections[e],r=[];this._router.getModel(t.getOpt("name")).projects.forEach((e=>{(null==this._project||this._project.test(e.name))&&r.push(e)}));var n=[];r.forEach((e=>{e.contqueries.forEach((e=>{(null==this._contquery||this._contquery.test(e.name))&&n.push(e)}))}));var s=[];n.forEach((e=>{e.windows.forEach((e=>{(null==this._window||this._window.test(e.name))&&s.push(e)}))})),s.forEach((e=>{t.getEventStream({window:e.key,maxevents:0,schema:!1}).addDelegate(this)}))}})),this._destinations=[],this._to.forEach((e=>{this._router._destinations.hasOwnProperty(e)&&this._destinations.push(this._router._destinations[e])}))}dataChanged(e,t,r){t.forEach((e=>{this._destinations.forEach((t=>{t.process(e)}))}))}}class se extends e{constructor(e){super(e),this._index=0,this._tabs=this.getOpt("tabs",4),this._incommand=!1,this._command=null,this._prev=null,this._text=null,this._listing=null,this._cl="<",this._cr=">",this._colors={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37}}format(e,t,r,n){return this._text=null!=n?n:"",this._index=0,this._prev=null,this._incommand=!1,this._command=null,Array.isArray(e)?e.forEach((e=>{this.process(e,t,r),this._text+="\n\n",this._text+=null!=n?n:"",this._index=0,this._prev=null,this._incommand=!1,this._command=null})):this.process(e,t,r),this._text}process(e,t,r){if(null!=e){for(var n,s="",i=0;i<e.length;i++)if((n=e[i])==this._cl)this.word(s),s="",this._incommand=!0,this._command="";else if(n==this._cr)this.word(s),s="",this._incommand&&(this._incommand=!1,this.command(r));else if(this._incommand)this._command+=n;else if(null!=this._listing)this._listing+=n;else if(" "==n||"\t"==n||"\n"==n||"."==n){if(" "==n&&0==this._index&&0==s.length)continue;if(this.word(s),s=""," "==n)null!=t&&this._index>=t?(this._text+="\n",this._index=0,null!=r&&(this._text+=r)):this._text+=n;else if("\t"==n)for(var o=0;o<this._tabs;o++)this._text+=" ";else"\n"==n?(this._text+="\n",this._index=0,null!=r&&(this._text+=r)):"."==n&&(this._text+=n)}else this._prev=n,s+=n;s.length>0&&this.word(s)}}command(t){if("note"==this._command){var r="NOTE";this._text+="[7mNOTE[0m",this._index+=r.length}else if("b"==this._command)this._text+="[1m";else if("/b"==this._command)this._text+="[22m";else if("br/"==this._command)this._text+="\n",null!=t&&(this._text+=t),this._index=0;else if(0==this._command.indexOf("fg:")){var n=this._command.split(":")[1];this._colors.hasOwnProperty(n)&&(this._text+="["+this._colors[n]+"m")}else if(0==this._command.indexOf("bg:")){n=this._command.split(":")[1];this._colors.hasOwnProperty(n)&&(this._text+="["+(this._colors[n]+10)+"m")}else if("/fg"==this._command)this._text+="[30m";else if("/bg"==this._command)this._text+="[47m";else if("listing"==this._command)this._listing="";else if("/listing"==this._command){const r=this.getListing(this._listing);var s=[];r.values.forEach((t=>{s.push(new e(t))})),r.values=s,r.indent=t,r.headers=!0,this._text+="\n",this._text+=this.listing(r),this._text+="\n"+t,this._listing=null}else"dot"==this._command&&(this._text+=".")}word(e){this._text+=e,this._index+=e.length}tab(e){var t="";null==e&&(e=1);for(var r=this.getOpt("tabs"," "),n=0;n<e;n++)t+=r;return t}listing(t){var r,n=new e(t),s=n.getOpt("fields"),i=n.getOpt("values"),o=n.getOpt("indent",""),a="",u={};s.forEach((e=>{u[e]=0})),n.getOpt("headers",!1)&&s.forEach((e=>{e.length>u[e]&&(u[e]=new Number(e.length))})),i.forEach((e=>{s.forEach((t=>{(r=e.getOpt(t,"")).length>u[t]&&(u[t]=new Number(r.length))}))}));const h=n.getOpt("spacing",2);return n.getOpt("headers",!1)&&(s.forEach((e=>{a+=o,a+=e,a+=this.spaces(u[e]-e.length+h)})),a+="\n",s.forEach((e=>{a+=o,r=(r="-").pad(u[e],"-"),a+=r,a+=this.spaces(u[e]-r.length+h)})),a+="\n"),i.forEach((e=>{s.forEach((t=>{r=e.getOpt(t,""),a+=o,a+=r,a+=this.spaces(u[t]-r.length+h)})),a+="\n"})),a}spaces(e){for(var t="",r=0;r<e;r++)t+=" ";return t}getListing(e){var t=null;if(this.getOpt("listings",!1)){const r=this.getOpt("listings");r.hasOwnProperty(e)&&(t=r[e])}return t}}var ie=null,oe={_args:null,_config:null,isNode:function(){return m.isNode},connect:function(t,r,n,s){const i=this;var o=new e(n),a=o.hasOpt("model")?new e(o.getOpt("model")):null,u=null!=a?a.getOpt("name"):null;if((o.hasOpt("k8s")?o.getOpt("k8s"):this.isK8sUrl(t))&&null==a)m.exception("You must supply a model for Kubernetes");else{var h=null,l=null;o.hasOpt("token")&&(h=o.getOptAndClear("token")),o.hasOpt("credentials")&&(l=o.getOptAndClear("credentials"));var c=function(){var e=Z(i,t,r,o.getOpts());if(null!=h?e.setBearer(h):null!=l&&e.setBasic(l),null==s||s)try{e.start()}catch(t){null!=m.anySupports(r,"connectionError")?r.forEach((r=>{m.supports(r,"connectionError")&&r.connectionError(e,t)})):alert(t)}};if(null!=a){var p=function(e){var r=t,n=D.create(r+="/eventStreamProcessing/v1/projects/"+u);n.setData(e),n.setRequestHeader("Content-Type","text/xml"),n.put().then((function(e){e.status>=400||c()}),(function(e){console.log("error loading")}))};i.getModelFrom(a).then((function(e){var r=x.createXml(e);r.documentElement.setAttribute("name",u),e=x.xmlString(r.documentElement);var n=t;D.create(n+="/eventStreamProcessing/v1/projectXml?name="+u).get().then((function(t){if(console.log("STATUS: "+t.status),t.status>=400)p(e);else{var r=x.createXml(t.text),n=x.getNodes("//project[@name='"+u+"']",r),s=!0;if(1==n.length){const t=x.xmlString(n[0]);s=e!=t}s?p(e):c()}}),(function(t){console.log("ERR STATUS: "+t.status),t.status>=400&&p(e)}))}))}else c()}},closed:function(e){for(var t of this._visuals)t.closed(e)},getModelFrom:function(e){return 0==e.hasOpt("url")&&0==e.hasOpt("data")&&m.exception("the model must contain either a data or url field"),new Promise(((t,r)=>{e.hasOpt("data")?t(e.getOpt("data")):e.hasOpt("url")&&D.create(e.getOpt("url")).get().then((function(e){t(e.text)}),(function(e){r()}))}))},createWebSocket:function(e,t){return m.createWebSocket(e,t)},getAjax:function(){return D},getTools:function(){return m},getFormatter:function(){return new se},getXPath:function(){return x},getResources:function(){return resources},createRouter:function(){return new ee},createOptions:function(t){return new e(t)},createOptionsFromArgs:function(){return new e(this.getArgs())},getArgs:function(){return null==this._args&&(this._args=m.createCommandLineOpts()),this._args},getArg:function(e,t){return this.getArgs().getOpt(e,t)},hasArg:function(e){return this.getArgs().hasOpt(e)},guid:function(){return m.guid()},createTimer:function(){return m.createTimer()},createFunction:function(e,t){return m.createFunction(e,t)},isK8sUrl:function(e){var t=!1,r=e.split("/");return r.length>=2&&(t="esp"==r[r.length-1]||"esp"==r[r.length-2]),t},formatDate:function(e,t){return m.formatDate(e,t)},encode:function(e){return w.encode(e)},decode:function(e){return w.decode(e)},createBuffer:function(e){return m.createBuffer(e)},stringFromBytes:function(e){return m.stringFromBytes(e)},bytesFromString:function(e){return m.bytesFromString(e)},b64Encode:function(e){return m.b64Encode(e)},b64Decode:function(e){return m.b64Decode(e)},stringify:function(e){return m.stringify(e)},setHttpProxy:function(e){m.setHttpProxy(e)},setHttpsProxy:function(e){m.setHttpsProxy(e)},setNoProxy:function(e){m.setNoProxy(e)},usage:function(t){var r=new e(t),n=new se(t),s=r.getOpt("name",""),i=r.getOpt("summary","");const o=r.getOpt("width",60);console.log(""),console.log("[1m[34m"+s+"(1)\t\t\tESP Connect Node.js Commands\t\t\t"+s+"(1)[30m[0m"),console.log(""),console.log("[1m%s[0m","NAME"),console.log(n.tab()+s+" -- "+i),console.log(""),console.log("[1m%s[0m","SYNOPSIS");var a=r.getOpt("options",[]);r.getOpt("show_auth",!0)&&(a.push({name:"access_token",arg:"OAuth Token",description:"OAuth authentiation token",required:!1}),a.push({name:"user",arg:"Auth User",description:"Authentication user",required:!1}),a.push({name:"pw",arg:"Auth Password",description:"Authentication password",required:!1})),r.getOpt("show_cert",!0)&&a.push({name:"cert",arg:"certificate file",description:"certificate to use for secure connections."});var u=0,h="";if(null!=a&&a.forEach((t=>{h+=" ";var r=new e(t),n=r.getOpt("name",""),s=r.getOpt("arg",""),i=n;s.length>0&&(i+=" "+s),i.length>u&&(u=i.length),r.getOpt("required",!1)?h+="--"+n:h+="[--"+n+"]"})),console.log("%s[1m%s[0m",n.tab(),"node "+s+".mjs"+h),console.log(""),console.log("[1m%s[0m","DESCRIPTION"),r.hasOpt("description")){var l=n.format(r.getOpt("description",""),o,n.tab(),n.tab());console.log(l)}if(null!=a){console.log(""),console.log("[1m%s[0m","OPTIONS"),u=10;var c=0;a.forEach((t=>{var r=new e(t),i=r.getOpt("name",""),o=r.getOpt("arg","");h=i,o.length>0&&(h+=" "+o);n.tab();for(var a=0;a<u;a++)" ";c>0&&console.log("");var l=n.format(r.getOpt("description"),50+u,n.tab(2),n.tab(2));if(console.log("%s--%s [4m%s[0m",n.tab(),i,o),console.log(l),r.hasOpt("examples")){n.spaces(2*(u-h.length+2));console.log(""),console.log("%s[1m%s[0m",n.tab(3),"Examples");var c=0;r.getOpt("examples").forEach((t=>{var r=new e(t),i=r.getOpt("title","Example "+c);i=n.format(i,null,n.tab(0),n.tab(0)),console.log("%s[1m%s[0m",n.tab(4),i),console.log(n.tab(5)+"$ node "+s+" "+r.getOpt("command",""));var o=n.format(r.getOpt("output",""),null,n.tab(5),n.tab(5));console.log(o)})),c++}console.log("")}))}if(r.hasOpt("examples")){console.log(""),console.log("[1m%s[0m","EXAMPLES");c=0;r.getOpt("examples").forEach((t=>{var r=new e(t),i=r.getOpt("title","Example "+c);i=n.format(i,null,n.tab(0),n.tab(0)),console.log("%s[1m%s[22m",n.tab(),i),console.log(n.tab(2)+"$ node "+s+" "+r.getOpt("command",""));var o=n.format(r.getOpt("output",""),null,n.tab(2),n.tab(2));console.log(o)}))}if(r.hasOpt("see_also")){console.log(""),console.log("[1m%s[0m","SEE ALSO");var p=0;r.getOpt("see_also").forEach((t=>{var r=new e(t).getOpt("name","");r.length>p&&(p=r.length)})),r.getOpt("see_also").forEach((t=>{for(var r=new e(t),s=r.getOpt("name",""),i=r.getOpt("link",""),o="",a=0;a<p-s.length;a++)o+=" ";o+=" ",console.log("%s[1m%s[0m%s%s",n.tab(),s,o,i)}))}console.log(""),console.log("[1m[34m%s[0m","SAS ESP Connect\t\t\t\t"+(new Date).toDateString()+"\t\t\t\tSAS ESP Connect[30m[0m"),console.log("")},getCredentials:function(){if(m.isNode)return new Promise(((e,t)=>{var r=function(){console.log("");var t=ie(),r=t("User: ");0==r.length&&process.exit(1);var n=t("Password: ");console.log(""),e({user:r,password:n})};null==ie?Promise.resolve().then(i.t.bind(i,7627,19)).then((function(e){ie=e.default,r()}),(function(){console.log("failed to import prompt-sync"),process.exit(1)})):r()}))}};Object.defineProperty(oe,"config",{get(){return this._config},set(e){this._config=e}})})(),a})()));