airdcpp-share-backup 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -169,7 +169,7 @@ dependency on an undocumented, API-unreachable command -- every call is a
169
169
  plain, independent request keyed by a real disk path, and it's fully
170
170
  public, documented API surface.
171
171
 
172
- ## Notes (1.0.3)
172
+ ## Notes (1.0.4)
173
173
 
174
174
  Forgot to build it :)
175
175
 
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e={3605(e,t,r){const n=r(7927),o=r(7074);e.exports=function(e,t){const{extensionName:i,configVersion:s,definitions:a}=t;n(s,"Settings version should be a positive integer"),n(Array.isArray(a),"Setting definitions should be an array");const c=((e,t)=>({postDefinitions:r=>e.post(`extensions/${t}/settings/definitions`,r),getSettings:()=>e.get(`extensions/${t}/settings`),updateSettings:r=>e.patch(`extensions/${t}/settings`,r),addSettingUpdateListener:r=>e.addListener("extensions","extension_settings_updated",r,t)}))(e,i);return o(t,e.logger,r(9896),c)}},7074(e,t,r){const n=r(7927),o=(e,t)=>Object.keys(e).reduce((r,n)=>{const o=t.find(e=>e.key===n);return o?(e[n]===o.default_value||(r[n]=e[n]),r):r},{});e.exports=function(e,t,r,i){const{configFile:s,configVersion:a,definitions:c}=e;let u,h;const l=e=>{u={...u,...e},h&&h(e),t.verbose(`Writing settings to ${s}...`);const n={version:a,settings:o(u,c)};r.writeFile(s,JSON.stringify(n,null,2),e=>{e&&t.error(`Failed to save settings to ${s}: ${e}`)})},f=e=>!!c.find(t=>t.key===e);return{getValue:e=>(n(f(e),`Definition for key ${e} was not found`),u[e]),setValue:(e,t)=>(n(f(e),`Definition for key ${e} was not found`),i.updateSettings({[e]:t})),load:async e=>{let o=!1;try{t.verbose(`Loading settings from ${s}...`);const i=JSON.parse(r.readFileSync(s,"utf8"));if(i&&(!i.version||!i.settings))throw"Invalid settings format";i.version!==a&&e?(u=e(i.version,i.settings),n(u,"Migration handler should return the new settings")):u=i.settings,o=!0}catch(e){t.verbose(`Failed to load settings: ${e}`)}try{await(async e=>{if(await i.postDefinitions(c),e){const e=Object.keys(u).reduce((e,t)=>(f(t)&&(e[t]=u[t]),e),{});await i.updateSettings(e)}u=await i.getSettings(),i.addSettingUpdateListener(l)})(o)}catch(e){t.error("Failed to register settings: "+e.message)}h&&h(u)},set onValuesUpdated(e){h=e},getValues:()=>({...u})}}},5482(e,t,r){"use strict";r.d(t,{ManagedExtension:()=>W});var n=r.cw(function(e,t){const n=r(4083),{stdout:s,stderr:a}=h(),{stringReplaceAll:c,stringEncaseCRLFWithFirstIndex:u}=i(),{isArray:l}=Array,f=["ansi","ansi","ansi256","ansi16m"],d=Object.create(null);class p{constructor(e){return m(e)}}const m=e=>{const t={};return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=s?s.level:0;e.level=void 0===t.level?r:t.level})(t,e),t.template=(...e)=>_(t.template,...e),Object.setPrototypeOf(t,g.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=p,t.template};function g(e){return m(e)}for(const[e,t]of Object.entries(n))d[e]={get(){const r=w(this,b(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:r}),r}};d.visible={get(){const e=w(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};const y=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(const e of y)d[e]={get(){const{level:t}=this;return function(...r){const o=b(n.color[f[t]][e](...r),n.color.close,this._styler);return w(this,o,this._isEmpty)}}};for(const e of y)d["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...r){const o=b(n.bgColor[f[t]][e](...r),n.bgColor.close,this._styler);return w(this,o,this._isEmpty)}}};const v=Object.defineProperties(()=>{},{...d,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),b=(e,t,r)=>{let n,o;return void 0===r?(n=e,o=t):(n=r.openAll+e,o=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:o,parent:r}},w=(e,t,r)=>{const n=(...e)=>l(e[0])&&l(e[0].raw)?k(n,_(n,...e)):k(n,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(n,v),n._generator=e,n._styler=t,n._isEmpty=r,n},k=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t;let r=e._styler;if(void 0===r)return t;const{openAll:n,closeAll:o}=r;if(-1!==t.indexOf(""))for(;void 0!==r;)t=c(t,r.close,r.open),r=r.parent;const i=t.indexOf("\n");return-1!==i&&(t=u(t,o,n,i)),n+t+o};let S;const _=(e,...t)=>{const[r]=t;if(!l(r)||!l(r.raw))return t.join(" ");const n=t.slice(1),i=[r.raw[0]];for(let e=1;e<r.length;e++)i.push(String(n[e-1]).replace(/[{}\\]/g,"\\$&"),String(r.raw[e]));return void 0===S&&(S=o()),S(e,i.join(""))};Object.defineProperties(g.prototype,d);const E=g();E.supportsColor=s,E.stderr=g({level:a?a.level:0}),E.stderr.supportsColor=a,e.exports=E}),o=()=>r(2991),i=r.cw(function(e,t){e.exports={stringReplaceAll:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return e;const o=t.length;let i=0,s="";do{s+=e.substr(i,n-i)+t+r,i=n+o,n=e.indexOf(t,i)}while(-1!==n);return s+=e.substr(i),s},stringEncaseCRLFWithFirstIndex:(e,t,r,n)=>{let o=0,i="";do{const s="\r"===e[n-1];i+=e.substr(o,(s?n-1:n)-o)+t+(s?"\r\n":"\n")+r,o=n+1,n=e.indexOf("\n",o)}while(-1!==n);return i+=e.substr(o),i}}}),s=r.cw(function(e,t){e.exports=(e,t=process.argv)=>{const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)}}),a=r.cw(function(e,t){function r(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,t){t||(t={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof t.unknown&&(o.unknownFn=t.unknown),"boolean"==typeof t.boolean&&t.boolean?o.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(e){o.bools[e]=!0});var i={};function s(e){return i[e].some(function(e){return o.bools[e]})}Object.keys(t.alias||{}).forEach(function(e){i[e]=[].concat(t.alias[e]),i[e].forEach(function(t){i[t]=[e].concat(i[e].filter(function(e){return t!==e}))})}),[].concat(t.string).filter(Boolean).forEach(function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach(function(e){o.strings[e]=!0})});var a=t.default||{},c={_:[]};function u(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var c=t[t.length-1];n(i,c)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[c]||o.bools[c]||"boolean"==typeof i[c]?i[c]=r:Array.isArray(i[c])?i[c].push(r):i[c]=[i[c],r])}function h(e,t,n){if(!n||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,n)||!1!==o.unknownFn(n)){var s=!o.strings[e]&&r(t)?Number(t):t;u(c,e.split("."),s),(i[e]||[]).forEach(function(e){u(c,e.split("."),s)})}}Object.keys(o.bools).forEach(function(e){h(e,void 0!==a[e]&&a[e])});var l=[];-1!==e.indexOf("--")&&(l=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var f=0;f<e.length;f++){var d,p,m=e[f];if(/^--.+=/.test(m)){var g=m.match(/^--([^=]+)=([\s\S]*)$/);d=g[1];var y=g[2];o.bools[d]&&(y="false"!==y),h(d,y,m)}else if(/^--no-.+/.test(m))h(d=m.match(/^--no-(.+)/)[1],!1,m);else if(/^--.+/.test(m))d=m.match(/^--(.+)/)[1],void 0===(p=e[f+1])||/^(-|--)[^-]/.test(p)||o.bools[d]||o.allBools||i[d]&&s(d)?/^(true|false)$/.test(p)?(h(d,"true"===p,m),f+=1):h(d,!o.strings[d]||"",m):(h(d,p,m),f+=1);else if(/^-[^-]+/.test(m)){for(var v=m.slice(1,-1).split(""),b=!1,w=0;w<v.length;w++)if("-"!==(p=m.slice(w+2))){if(/[A-Za-z]/.test(v[w])&&"="===p[0]){h(v[w],p.slice(1),m),b=!0;break}if(/[A-Za-z]/.test(v[w])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){h(v[w],p,m),b=!0;break}if(v[w+1]&&v[w+1].match(/\W/)){h(v[w],m.slice(w+2),m),b=!0;break}h(v[w],!o.strings[v[w]]||"",m)}else h(v[w],p,m);d=m.slice(-1)[0],b||"-"===d||(!e[f+1]||/^(-|--)[^-]/.test(e[f+1])||o.bools[d]||i[d]&&s(d)?e[f+1]&&/^(true|false)$/.test(e[f+1])?(h(d,"true"===e[f+1],m),f+=1):h(d,!o.strings[d]||"",m):(h(d,e[f+1],m),f+=1))}else if(o.unknownFn&&!1===o.unknownFn(m)||c._.push(o.strings._||!r(m)?m:Number(m)),t.stopEarly){c._.push.apply(c._,e.slice(f+1));break}}return Object.keys(a).forEach(function(e){var t,r,n;t=c,r=e.split("."),n=t,r.slice(0,-1).forEach(function(e){n=n[e]||{}}),r[r.length-1]in n||(u(c,e.split("."),a[e]),(i[e]||[]).forEach(function(t){u(c,t.split("."),a[e])}))}),t["--"]?c["--"]=l.slice():l.forEach(function(e){c._.push(e)}),c}}),c=r.cw(function(e,t){e.exports=u()}),u=()=>r(7706),h=r.cw(function(e,t){const r=l(),n=f(),o=s(),{env:i}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function u(e,t){if(0===a)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const n=a||0;if("dumb"===i.TERM)return n;if("win32"===process.platform){const e=r.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in i)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in i)||"codeship"===i.CI_NAME?1:n;if("TEAMCITY_VERSION"in i)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0;if("truecolor"===i.COLORTERM)return 3;if("TERM_PROGRAM"in i){const e=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)||"COLORTERM"in i?1:n}o("no-color")||o("no-colors")||o("color=false")||o("color=never")?a=0:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(a=1),"FORCE_COLOR"in i&&(a="true"===i.FORCE_COLOR?1:"false"===i.FORCE_COLOR?0:0===i.FORCE_COLOR.length?1:Math.min(parseInt(i.FORCE_COLOR,10),3)),e.exports={stdout:c(u(!0,n.isatty(1))),stderr:c(u(!0,n.isatty(2)))}}),l=()=>r(857),f=()=>r(2018);const d="sessions/authorize";function p(){return p.c||(p.c=r.n(l()))}function m(){return m.c||(m.c=r.n(n()))}l(),n(),"object"==typeof navigator&&navigator.userAgent&&navigator.userAgent.includes("jsdom"),"object"==typeof process&&process.versions&&process.versions.node;const g="object"==typeof window&&"object"==typeof document&&9===document.nodeType;var y,v=r(7927),b=r.n(v),w=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},k="error",S="warn",_="info",E="verbose",C=((y={}).none=-1,y[k]=0,y[S]=1,y[_]=2,y[E]=3,y),O=!g||!!global.process&&!!global.process.env&&"test"===global.process.env.NODE_ENV;var x,B=r(4434),A=function(e,t){return!!t&&(Array.isArray(t)?-1!==t.indexOf(e):t.test(e))};x="undefined"!=typeof Promise?Promise:c();var R=Object.assign(x,{pending:function(){var e,t,r=new x(function(){e=arguments[0],t=arguments[1]});return{resolve:e,reject:t,promise:r}}});const T=R;var M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},M.apply(this,arguments)},F=function(e,t,r){var n=r.ignoredListenerEvents,o=void 0===n?[]:n,i=function(e,t){return b()(0!==t,'Entity ID "0" is not allowed'),t?e+t:e},s={},a=new B.EventEmitter,c={},u=function(r,n,o,i){n(o,function(n){e().post(r+"/"+i+"/resolve",n).catch(function(e){return t.error("Failed to complete hook action",r,e)})},function(n,o){e().post(r+"/"+i+"/reject",{reject_id:n,message:o}).catch(function(e){return t.error("Failed to complete failed hook action",r,e)})})},h=function(e){var t=c[e];t.forEach(function(e){return e.resolver.resolve(e.removeHandler)}),s[e]=t.length,delete c[e]},l=function(e,t){c[e].forEach(function(e){return e.resolver.reject(t)}),delete c[e]},f=function(r,n,o,i){var u=function(i){return void 0===i&&(i=!0),function(r,n,o,i){e().isConnected()&&(s[n]--,a.removeListener(n,o),0===s[n]&&(i&&e().isConnected()&&e().delete(r).catch(function(e){t.error("Failed to remove socket listener",r,e)}),delete s[n]))}(r,n,o,i)};if(!s[n]){c[n]||(c[n]=[],e().post(r,i).then(h.bind(F,n),l.bind(F,n)));var f=T.pending();return c[n].push({resolver:f,removeHandler:u}),f.promise}return s[n]++,T.resolve(u)},d={addViewUpdateListener:function(e,t,r){var n=i(e+"_updated",r);return a.on(n,t),function(){return function(e,t){a.removeListener(e,t)}(n,t)}},addListener:function(t,r,n,o){if(!e().isConnected())throw"Listeners can be added only for a connected socket";b()(-1===t.indexOf("/"),"The first argument should only contain the API section without any path tokens (entity ID should be supplied separately)");var s=i(r,o),c=function(e,t,r){return t?e+"/"+t+"/listeners/"+r:e+"/listeners/"+r}(t,o,r);return a.on(s,n),f(c,s,n)},hasListeners:function(){return Object.keys(s).length>0||Object.keys(s).reduce(function(e,t){return a.listenerCount(t)+e},0)>0},addHook:function(t,r,n,o){if(!e().isConnected())throw"Hooks can be added only for a connected socket";b()(-1===t.indexOf("/"),"The first argument should only contain the API section without any path tokens");var i=r;if(s[i]||c[i])throw"Hook exists";var h=t+"/hooks/"+r;return n=u.bind(F,h,n),a.on(i,n),f(h,i,n,o)},getPendingSubscriptionCount:function(){return Object.keys(c).length}};return M(M({},{onSocketDisconnected:function(){a.removeAllListeners(),s={}},handleMessage:function(e){var r=A(e.event,o);e.completion_id?(r||t.verbose(e.event,"(completion id "+e.completion_id+")",e.data),a.emit(e.event,e.data,e.completion_id)):(r||t.verbose(e.event,e.id?"(entity "+e.id+")":"(no entity)",e.data),e.id&&a.emit(i(e.event,e.id),e.data,e.id),a.emit(e.event,e.data,e.id))}}),{socket:d})};const P=F;var I=function(){return I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},I.apply(this,arguments)};var L=function(){return L=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},L.apply(this,arguments)},N={autoReconnect:!0,reconnectInterval:10,userSession:!1};const D=function(e,t){var r,n=L(L({},N),e),o=null,i=null,s=null,a=!0,c=null,u=null,h=null,l=function(e){var t=e.logLevel,r=void 0===t?E:t,n=e.logOutput,o=void 0===n?console:n,i=C[r];b()(o.log&&o.info&&o.warn&&o.error,"Invalid logOutput provided");var s=function(e,t,r){var n,i=w([],Array.prototype.slice.call(e),!0);O&&r&&(i=w([m()().magenta((n=new Date,"["+n.toLocaleDateString()+" "+n.toLocaleTimeString()+":"+n.getMilliseconds()+"]"))],i.map(function(e){return r("object"==typeof e?JSON.stringify(e,null," "):e)}),!0)),t.apply(o,i)},a={verbose:function(){i<C[E]||s(arguments,o.log,m()().gray)},info:function(){i<C[_]||s(arguments,o.info,m()().white.bold)},warn:function(){i<C[S]||s(arguments,o.warn,m()().yellow.bold)},error:function(){i<C[k]||s(arguments,o.error,m()().red.bold)}};return a}(n),f=P(function(){return s},l,n),p=function(e,t,r){var n,o=r.requestTimeout,i=void 0===o?30:o,s=r.ignoredRequestPaths,a={},c=0,u=function(r,n,o,i){if(void 0===i&&(i=!1),!i&&!e().isConnected())return t.warn("Attempting to send request on a non-authenticated socket: "+n),T.reject("Not authorized");if(!e().nativeSocket)return t.warn("Attempting to send request without a socket: "+n),T.reject("No socket");var u=(c>1e5&&(c=0),c+=1);b()(n,"Attempting socket request without a path");var h=A(n,s);h||t.verbose(m()().white.bold(u.toString()),r,n,o?function(e){return e&&e.hasOwnProperty("password")?I(I({},e),{password:"(hidden)"}):e}(o):"(no data)");var l=T.pending();a[u]={time:Date.now(),resolver:l,ignored:h};var f={path:n,method:r,data:o,callback_id:u};return e().nativeSocket.send(JSON.stringify(f)),l.promise},h=function(){var e=Date.now();Object.keys(a).forEach(function(r){a[r].time+1e3*i<e&&t.warn("Request "+r+" timed out")})},l={put:function(e,t){return u("PUT",e,t)},patch:function(e,t){return u("PATCH",e,t)},post:function(e,t){return u("POST",e,t)},delete:function(e){return u("DELETE",e)},get:function(e){return u("GET",e)},getPendingRequestCount:function(){return Object.keys(a).length}};return Object.assign(l,{reportRequestTimeouts:h}),I(I({},{onSocketConnected:function(){n=setInterval(h,3e4)},onSocketDisconnected:function(){var e;void 0===(e="Socket disconnected")&&(e="Request cancelled"),Object.keys(a).forEach(function(r){t.verbose("Canceling a pending request "+r+" ("+e+")"),a[r].resolver.reject(e)}),a={},clearTimeout(n)},handleMessage:function(e){var r=e.callback_id;if(a.hasOwnProperty(r)){if(e.code>=200&&e.code<=204){var n=e.data;a[r].ignored||t.verbose(m()().green(r.toString()),"SUCCEEDED",n||"(no data)"),a[r].resolver.resolve(n)}else{var o=e;o.error||t.warn("Error message missing from the response (this is an API bug that should be reported)",r,e);var i=o.code,s=o.error||{message:"(no error description)"};t.warn(r,i,s.message,function(e){return e.field&&e.code?e.field+" ("+e.code+")":""}(s)),a[r].resolver.reject({message:s.message,code:i,json:s})}delete a[r]}else t.warn("No pending request for an API response",r,e)},postAuthenticate:function(e,t){return u("POST",e,t,!0)}}),{socket:l})}(function(){return s},l,n);b()(e.url,'"url" must be defined in settings object');var g=function(){i&&(u&&u(),i=null)},y=function(e){e.wasClean?l.info("Websocket was closed normally"):l.error("Websocket failed: "+e.reason+" (code: "+e.code+")"),p.onSocketDisconnected(),f.onSocketDisconnected(),o=null,h&&h(e.reason,e.code,e.wasClean),i&&n.autoReconnect&&!a&&setTimeout(function(){a||s.reconnect().catch(function(e){l.error("Reconnect failed for a closed socket",e.message)})})},v=function(e){var t=JSON.parse(e.data);t.callback_id?p.handleMessage(t):f.handleMessage(t)},x=function(e,t){if(void 0===e&&(e=n.username),void 0===t&&(t=n.password),!e)throw'"username" option was not supplied for authentication';if(!t)throw'"password" option was not supplied for authentication';var r={username:e,password:t,grant_type:"password"};return p.postAuthenticate(d,r)},B=function(){var e={auth_token:i};return p.postAuthenticate("sessions/socket",e)},R=function(e,t,r,o){r().then(function(t){!function(e){if(i?l.info("Socket associated with an existing session"):(l.info("Login succeed"),i=e.auth_token),c){try{c(e)}catch(e){console.error("Error in socket connect handler",e.message)}p.onSocketConnected()}}(t),e(t)}).catch(function(r){return r.code?i&&400===r.code&&n.autoReconnect?(l.info("Session lost, re-sending credentials"),g(),void R(e,t,x,o)):(401===r.code&&g(),s.disconnect(void 0,"Authentication failed"),void t(r)):(l.info("Socket disconnected during authentication, reconnecting"),void o())})},M=function(e,i,s,a){void 0===a&&(a=!0),o=new t(n.url);var c=function(){o=null,a?r=setTimeout(function(){l.info("Socket reconnecting"),M(e,i,s,a)},1e3*n.reconnectInterval):i("Cannot connect to the server")};o.onopen=function(){l.info("Socket connected"),o.onerror=function(e){l.error("Websocket failed: "+e.reason)},o.onclose=y,o.onmessage=v,R(e,i,s,c)},o.onerror=function(e){l.error("Connecting socket failed"),c()}},F=function(e,t){return a=!1,new T(function(r,n){l.info("Starting socket connect"),M(r,n,e,t)})},D=function(){return!(!o||o.readyState!==(o.OPEN||1)||!i)},j=function(){return!!o},U=function(){clearTimeout(r),a=!0},q=function(e,t){void 0===e&&(e=!1),void 0===t&&(t="Manually disconnected by the client"),o?(l.info("Disconnecting socket"),e||U(),o.close(1e3,t)):a?l.warn("Attempting to disconnect a closed socket (ignore)"):e?l.verbose("Attempting to disconnect a closed socket with auto reconnect enabled (continue connecting)"):(l.verbose("Disconnecting a closed socket with auto reconnect enabled (cancel reconnect)"),U())};return s=L(L({connect:function(e,t,r){if(void 0===r&&(r=!0),j())throw"Connect may only be used for a closed socket";return g(),F(function(){return x(e,t)},r)},connectRefreshToken:function(e,t){if(void 0===t&&(t=!0),j())throw"Connect may only be used for a closed socket";return g(),F(function(){return function(e){if(!e)throw'"refreshToken" option was not supplied for authentication';var t={refresh_token:e,grant_type:"refresh_token"};return p.postAuthenticate(d,t)}(e)},t)},reconnect:function(e,t){if(void 0===e&&(e=void 0),void 0===t&&(t=!0),j())throw"Reconnect may only be used for a closed socket";if(e&&(i=e),!i)throw"No session token available for reconnecting";return l.info("Reconnecting socket"),F(B,t)},logout:function(){var e=T.pending();return s.delete("sessions/self").then(function(t){l.info("Logout succeed"),g(),e.resolve(t),q(void 0,"Logged out")}).catch(function(t){l.error("Logout failed",t),e.reject(t)}),e.promise},disconnect:q,isConnecting:function(){return!(!o||D())},isConnected:D,isActive:j,logger:l,waitDisconnected:function(e){void 0===e&&(e=2e3);var t=e>0?e/50:0;return new T(function(r,n){var o=0,i=function(){j()?o>=t?(l.error("Socket disconnect timed out after "+e+" ms"),n("Socket disconnect timed out")):(setTimeout(i,50),o++):r()};i()})},set onConnected(e){c=e},set onSessionReset(e){u=e},set onDisconnected(e){h=e},get onConnected(){return c},get onSessionReset(){return u},get onDisconnected(){return h},get nativeSocket(){return o}},f.socket),p.socket)};function j(){return j.c||(j.c=r.n(a()))}a();const U={autoReconnect:!1,ignoredRequestPaths:["sessions/activity"]},q={minSleepDetectTimeout:3e4,aliveCheckInterval:5e3},z=(e,t)=>{const n=j()()(process.argv.slice(2)),o=`ws://${n.apiUrl}`,i=D(Object.assign(Object.assign(Object.assign({logLevel:n.debug?"verbose":"info"},U),e),{url:o}),r(5488).w3cwebsocket),s=((e,t)=>({activity:()=>e.post("sessions/activity"),getSettingValues:t=>e.post("settings/get",{keys:t}),ready:()=>e.post(`extensions/${t.name}/ready`)}))(i,n);return{argv:n,socket:i,connectUrl:o,api:s,options:Object.assign(Object.assign({},q),t)}},$=(e,t)=>e.argv.appPid?((e,{socket:t,api:r,options:n},o)=>{let i,s=Date.now(),a=n.minSleepDetectTimeout;const c=()=>{if(s+a<Date.now())return t.logger.error(`Wake up detected (last alive ${Date.now()-s} ms ago), requesting restart...`),o(),void process.exit(124);(e=>{try{return process.kill(e,0)}catch(e){return"EPERM"===e.code}})(e)||(t.logger.error(`Parent dead (PID ${e}), exiting...`),o(),process.exit(69)),s=Date.now()};return{start:()=>{r.getSettingValues(["ping_timeout"]).then(e=>{const r=1e3*e.ping_timeout;r>a&&(a=r,t.logger.info(`Alive check timeout adjusted to match the API ping timeout (${r} ms)`)),i=setInterval(c,n.aliveCheckInterval)}).catch(e=>{t.logger.error("Failed to get ping timeout value from the API",e),process.exit(1)})},stop:()=>{clearInterval(i)},getStats:()=>({sleepDetectTimeoutMs:a})}})(e.argv.appPid,e,t):(({socket:e,api:t},r)=>{let n,o=Date.now()+9999;const i=()=>{if(o+1e4<Date.now())return e.logger.error("Socket timed out, requesting restart..."),r(),void process.exit(124);t.activity().then(e=>{o=Date.now()}).catch(t=>{e.logger.error(`Ping failed: ${t.message}`)})};return{start:()=>{n=setInterval(i,4e3)},stop:()=>{clearInterval(n)},getStats:()=>({sleepDetectTimeoutMs:1e4})}})(e,t);var H=r(7016);const G=e=>{const t=new H.URL(e);return{address:t.host,secure:"wss"===t.protocol}},W=(e,t={},r={},n=z)=>{const o=n(t,r),{argv:i,socket:s,connectUrl:a,api:c}=o;let u,h;process.title=i.name,s.logger.verbose("Starting the extension",JSON.stringify(process.argv),JSON.stringify(i,null,2),JSON.stringify({nodeVersion:process.version,arch:p()().arch(),osVersion:p()().version?p()().version():"N/A",totalmem:p()().totalmem(),cpuCount:p()().cpus().length},null,2));const l=()=>{h&&h()},f=$(o,l);s.onConnected=e=>{setTimeout(()=>{f.start(),u&&Promise.resolve(u(e)).then(()=>{i.signalReady&&c.ready().catch(e=>s.logger.error(`Failed to signal ready state: ${e.message}`))})},10)},s.onDisconnected=(e,t,r)=>{l(),r?(s.logger.info("Socket disconnected (clean), exiting"),process.exit(1)):(s.logger.info(`Socket disconnected (unclean, ${e}), requesting restart`),process.exit(124))};const d=()=>{s.logger.info("Exit requested"),process.exit()};process.on("exit",l),process.on("SIGINT",d),process.on("SIGTERM",d);const m="function"==typeof e?e:e.default;if(!m)throw"Extension entry is not a function ";return m(s,{name:i.name,configPath:i.settingsPath,logPath:i.logPath,debugMode:i.debug,server:G(a),set onStart(e){u=e},set onStop(e){h=e}}),s.reconnect(i.authToken,!1).catch(e=>{s.logger.error(`Failed to connect to server ${i.apiUrl}, exiting...`),l(),process.exit(1)}),{stop:()=>{f.stop()},getStats:()=>f.getStats()}};r(9896),r(3480),r(6928)},4083(e,t,r){"use strict";e=r.nmd(e);const n=(e,t)=>(...r)=>`[${e(...r)+t}m`,o=(e,t)=>(...r)=>{const n=e(...r);return`[${38+t};5;${n}m`},i=(e,t)=>(...r)=>{const n=e(...r);return`[${38+t};2;${n[0]};${n[1]};${n[2]}m`},s=e=>e,a=(e,t,r)=>[e,t,r],c=(e,t,r)=>{Object.defineProperty(e,t,{get:()=>{const n=r();return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})};let u;const h=(e,t,n,o)=>{void 0===u&&(u=r(734));const i=o?10:0,s={};for(const[r,o]of Object.entries(u)){const a="ansi16"===r?"ansi":r;r===t?s[a]=e(n,i):"object"==typeof o&&(s[a]=e(o[t],i))}return s};Object.defineProperty(e,"exports",{enumerable:!0,get:function(){const e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(const[r,n]of Object.entries(t)){for(const[r,o]of Object.entries(n))t[r]={open:`[${o[0]}m`,close:`[${o[1]}m`},n[r]=t[r],e.set(o[0],o[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="",t.bgColor.close="",c(t.color,"ansi",()=>h(n,"ansi16",s,!1)),c(t.color,"ansi256",()=>h(o,"ansi256",s,!1)),c(t.color,"ansi16m",()=>h(i,"rgb",a,!1)),c(t.bgColor,"ansi",()=>h(n,"ansi16",s,!0)),c(t.bgColor,"ansi256",()=>h(o,"ansi256",s,!0)),c(t.bgColor,"ansi16m",()=>h(i,"rgb",a,!0)),t}})},983(e,t,r){"use strict";var n=r(7342),o=[];function i(){this.task=null,this.domain=null}e.exports=function(e){var t;(t=o.length?o.pop():new i).task=e,t.domain=process.domain,n(t)},i.prototype.call=function(){this.domain&&this.domain.enter();var e=!0;try{this.task.call(),e=!1,this.domain&&this.domain.exit()}finally{e&&n.requestFlush(),this.task=null,this.domain=null,o.push(this)}}},7342(e,t,r){"use strict";var n,o="function"==typeof setImmediate;function i(e){s.length||(h(),a=!0),s[s.length]=e}e.exports=i;var s=[],a=!1,c=0;function u(){for(;c<s.length;){var e=c;if(c+=1,s[e].call(),c>1024){for(var t=0,r=s.length-c;t<r;t++)s[t]=s[t+c];s.length-=c,c=0}}s.length=0,c=0,a=!1}function h(){var e=process.domain;e&&(n||(n=r(3167)),n.active=process.domain=null),a&&o?setImmediate(u):process.nextTick(u),e&&(n.active=process.domain=e)}i.requestFlush=h},6489(e){"use strict";e.exports={mask:(e,t,r,n,o)=>{for(var i=0;i<o;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]}}},2627(e,t,r){"use strict";try{e.exports=r(8169)(__dirname)}catch(t){e.exports=r(6489)}},2991(e){"use strict";const t=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,r=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,n=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,o=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,i=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a",""]]);function s(e){const t="u"===e[0],r="{"===e[1];return t&&!r&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(parseInt(e.slice(2,-1),16)):i.get(e)||e}function a(e,t){const r=[],i=t.trim().split(/\s*,\s*/g);let a;for(const t of i){const i=Number(t);if(Number.isNaN(i)){if(!(a=t.match(n)))throw new Error(`Invalid Chalk template style argument: ${t} (in style '${e}')`);r.push(a[2].replace(o,(e,t,r)=>t?s(t):r))}else r.push(i)}return r}function c(e){r.lastIndex=0;const t=[];let n;for(;null!==(n=r.exec(e));){const e=n[1];if(n[2]){const r=a(e,n[2]);t.push([e].concat(r))}else t.push([e])}return t}function u(e,t){const r={};for(const e of t)for(const t of e.styles)r[t[0]]=e.inverse?null:t.slice(1);let n=e;for(const[e,t]of Object.entries(r))if(Array.isArray(t)){if(!(e in n))throw new Error(`Unknown Chalk style: ${e}`);n=t.length>0?n[e](...t):n[e]}return n}e.exports=(e,r)=>{const n=[],o=[];let i=[];if(r.replace(t,(t,r,a,h,l,f)=>{if(r)i.push(s(r));else if(h){const t=i.join("");i=[],o.push(0===n.length?t:u(e,n)(t)),n.push({inverse:a,styles:c(h)})}else if(l){if(0===n.length)throw new Error("Found extraneous } in Chalk template literal");o.push(u(e,n)(i.join(""))),i=[],n.pop()}else i.push(f)}),o.push(i.join("")),n.length>0){const e=`Chalk template literal is missing ${n.length} closing bracket${1===n.length?"":"s"} (\`}\`)`;throw new Error(e)}return o.join("")}},5659(e,t,r){const n=r(8156),o={};for(const e of Object.keys(n))o[n[e]]=e;const i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=i;for(const e of Object.keys(i)){if(!("channels"in i[e]))throw new Error("missing channels property: "+e);if(!("labels"in i[e]))throw new Error("missing channel labels property: "+e);if(i[e].labels.length!==i[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:r}=i[e];delete i[e].channels,delete i[e].labels,Object.defineProperty(i[e],"channels",{value:t}),Object.defineProperty(i[e],"labels",{value:r})}function s(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}i.rgb.hsl=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.min(t,r,n),i=Math.max(t,r,n),s=i-o;let a,c;i===o?a=0:t===i?a=(r-n)/s:r===i?a=2+(n-t)/s:n===i&&(a=4+(t-r)/s),a=Math.min(60*a,360),a<0&&(a+=360);const u=(o+i)/2;return c=i===o?0:u<=.5?s/(i+o):s/(2-i-o),[a,100*c,100*u]},i.rgb.hsv=function(e){let t,r,n,o,i;const s=e[0]/255,a=e[1]/255,c=e[2]/255,u=Math.max(s,a,c),h=u-Math.min(s,a,c),l=function(e){return(u-e)/6/h+.5};return 0===h?(o=0,i=0):(i=h/u,t=l(s),r=l(a),n=l(c),s===u?o=n-r:a===u?o=1/3+t-n:c===u&&(o=2/3+r-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*i,100*u]},i.rgb.hwb=function(e){const t=e[0],r=e[1];let n=e[2];const o=i.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(r,n));return n=1-1/255*Math.max(t,Math.max(r,n)),[o,100*s,100*n]},i.rgb.cmyk=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-r,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-r-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},i.rgb.keyword=function(e){const t=o[e];if(t)return t;let r,i=1/0;for(const t of Object.keys(n)){const o=s(e,n[t]);o<i&&(i=o,r=t)}return r},i.keyword.rgb=function(e){return n[e]},i.rgb.xyz=function(e){let t=e[0]/255,r=e[1]/255,n=e[2]/255;return t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,[100*(.4124*t+.3576*r+.1805*n),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let r=t[0],n=t[1],o=t[2];return r/=95.047,n/=100,o/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,[116*n-16,500*(r-n),200*(n-o)]},i.hsl.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100;let o,i,s;if(0===r)return s=255*n,[s,s,s];o=n<.5?n*(1+r):n+r-n*r;const a=2*n-o,c=[0,0,0];for(let e=0;e<3;e++)i=t+1/3*-(e-1),i<0&&i++,i>1&&i--,s=6*i<1?a+6*(o-a)*i:2*i<1?o:3*i<2?a+(o-a)*(2/3-i)*6:a,c[e]=255*s;return c},i.hsl.hsv=function(e){const t=e[0];let r=e[1]/100,n=e[2]/100,o=r;const i=Math.max(n,.01);return n*=2,r*=n<=1?n:2-n,o*=i<=1?i:2-i,[t,100*(0===n?2*o/(i+o):2*r/(n+r)),(n+r)/2*100]},i.hsv.rgb=function(e){const t=e[0]/60,r=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,i=t-Math.floor(t),s=255*n*(1-r),a=255*n*(1-r*i),c=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,c,s];case 1:return[a,n,s];case 2:return[s,n,c];case 3:return[s,a,n];case 4:return[c,s,n];case 5:return[n,s,a]}},i.hsv.hsl=function(e){const t=e[0],r=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let i,s;s=(2-r)*n;const a=(2-r)*o;return i=r*o,i/=a<=1?a:2-a,i=i||0,s/=2,[t,100*i,100*s]},i.hwb.rgb=function(e){const t=e[0]/360;let r=e[1]/100,n=e[2]/100;const o=r+n;let i;o>1&&(r/=o,n/=o);const s=Math.floor(6*t),a=1-n;i=6*t-s,1&s&&(i=1-i);const c=r+i*(a-r);let u,h,l;switch(s){default:case 6:case 0:u=a,h=c,l=r;break;case 1:u=c,h=a,l=r;break;case 2:u=r,h=a,l=c;break;case 3:u=r,h=c,l=a;break;case 4:u=c,h=r,l=a;break;case 5:u=a,h=r,l=c}return[255*u,255*h,255*l]},i.cmyk.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},i.xyz.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100;let o,i,s;return o=3.2406*t+-1.5372*r+-.4986*n,i=-.9689*t+1.8758*r+.0415*n,s=.0557*t+-.204*r+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*o,255*i,255*s]},i.xyz.lab=function(e){let t=e[0],r=e[1],n=e[2];return t/=95.047,r/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*r-16,500*(t-r),200*(r-n)]},i.lab.xyz=function(e){let t,r,n;r=(e[0]+16)/116,t=e[1]/500+r,n=r-e[2]/200;const o=r**3,i=t**3,s=n**3;return r=o>.008856?o:(r-16/116)/7.787,t=i>.008856?i:(t-16/116)/7.787,n=s>.008856?s:(n-16/116)/7.787,t*=95.047,r*=100,n*=108.883,[t,r,n]},i.lab.lch=function(e){const t=e[0],r=e[1],n=e[2];let o;return o=360*Math.atan2(n,r)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(r*r+n*n),o]},i.lch.lab=function(e){const t=e[0],r=e[1],n=e[2]/360*2*Math.PI;return[t,r*Math.cos(n),r*Math.sin(n)]},i.rgb.ansi16=function(e,t=null){const[r,n,o]=e;let s=null===t?i.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let a=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(r/255));return 2===s&&(a+=60),a},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){const t=e[0],r=e[1],n=e[2];return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},i.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const r=.5*(1+~~(e>50));return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},i.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},i.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},i.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let r=t[0];3===t[0].length&&(r=r.split("").map(e=>e+e).join(""));const n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},i.rgb.hcg=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,r),n),i=Math.min(Math.min(t,r),n),s=o-i;let a,c;return a=s<1?i/(1-s):0,c=s<=0?0:o===t?(r-n)/s%6:o===r?2+(n-t)/s:4+(t-r)/s,c/=6,c%=1,[360*c,100*s,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=r<.5?2*t*r:2*t*(1-r);let o=0;return n<1&&(o=(r-.5*n)/(1-n)),[e[0],100*n,100*o]},i.hsv.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=t*r;let o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},i.hcg.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];const o=[0,0,0],i=t%1*6,s=i%1,a=1-s;let c=0;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return c=(1-r)*n,[255*(r*o[0]+c),255*(r*o[1]+c),255*(r*o[2]+c)]},i.hcg.hsv=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t);let n=0;return r>0&&(n=t/r),[e[0],100*n,100*r]},i.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let n=0;return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},i.hcg.hwb=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t);return[e[0],100*(r-t),100*(1-r)]},i.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,n=r-t;let o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=function(e){return[0,0,e[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},734(e,t,r){const n=r(5659),o=r(8507),i={};Object.keys(n).forEach(e=>{i[e]={},Object.defineProperty(i[e],"channels",{value:n[e].channels}),Object.defineProperty(i[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach(r=>{const n=t[r];i[e][r]=function(e){const t=function(...t){const r=t[0];if(null==r)return r;r.length>1&&(t=r);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(n),i[e][r].raw=function(e){const t=function(...t){const r=t[0];return null==r?r:(r.length>1&&(t=r),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)})}),e.exports=i},8507(e,t,r){const n=r(5659);function o(e,t){return function(r){return t(e(r))}}function i(e,t){const r=[t[e].parent,e];let i=n[t[e].parent][e],s=t[e].parent;for(;t[s].parent;)r.unshift(t[s].parent),i=o(n[t[s].parent][s],i),s=t[s].parent;return i.conversion=r,i}e.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(n);for(let r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null};return e}(),r=[e];for(t[e].distance=0;r.length;){const e=r.pop(),o=Object.keys(n[e]);for(let n=o.length,i=0;i<n;i++){const n=o[i],s=t[n];-1===s.distance&&(s.distance=t[e].distance+1,s.parent=e,r.unshift(n))}}return t}(e),r={},o=Object.keys(t);for(let e=o.length,n=0;n<e;n++){const e=o[n];null!==t[e].parent&&(r[e]=i(e,t))}return r}},8156(e){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},7833(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(9910)).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){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),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(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("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())},9910(e,t,r){var n;function o(e){function r(){if(r.enabled){var e=r,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=s[c];r=o.call(e,i),s.splice(c,1),c--}return r}),t.formatArgs.call(e,s),(r.log||t.log||console.log.bind(console)).apply(e,s)}}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=o.debug=o.default=o).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,o=0;o<n;o++)r[o]&&("-"===(e=r[o].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(6585),t.names=[],t.skips=[],t.formatters={}},5753(e,t,r){"undefined"!=typeof process&&"renderer"===process.type?e.exports=r(7833):e.exports=r(6033)},6033(e,t,r){var n=r(2018),o=r(9023);(t=e.exports=r(9910)).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 s.write(o.format.apply(o,arguments)+"\n")},t.formatArgs=function(e){var r=this.namespace;if(this.useColors){var n=this.color,o=" [3"+n+";1m"+r+" ";e[0]=o+e[0].split("\n").join("\n"+o),e.push("[3"+n+"m+"+t.humanize(this.diff)+"")}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&&o.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 s=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":(t=new(r(9896).SyncWriteStream)(e,{autoClose:!1}))._type="fs";break;case"PIPE":case"TCP":(t=new(r(9278).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,o.inspect(e,this.inspectOpts).split("\n").map(function(e){return e.trim()}).join(" ")},t.formatters.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)},t.enable(a())},7927(e){"use strict";e.exports=function(e,t,r,n,o,i,s,a){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,i,s,a],h=0;(c=new Error(t.replace(/%s/g,function(){return u[h++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},9225(e){e.exports=n,n.strict=o,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 o(e)||i(e)}function o(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)]}},3480(e,t,r){const n=r(5737),o=r(1276),{mkdirpNative:i,mkdirpNativeSync:s}=r(3831),{mkdirpManual:a,mkdirpManualSync:c}=r(6990),{useNative:u,useNativeSync:h}=r(4443),l=(e,t)=>(e=o(e),t=n(t),u(t)?i(e,t):a(e,t));l.sync=(e,t)=>(e=o(e),t=n(t),h(t)?s(e,t):c(e,t)),l.native=(e,t)=>i(o(e),n(t)),l.manual=(e,t)=>a(o(e),n(t)),l.nativeSync=(e,t)=>s(o(e),n(t)),l.manualSync=(e,t)=>c(o(e),n(t)),e.exports=l},4523(e,t,r){const{dirname:n}=r(6928),o=(e,t,r=void 0)=>r===t?Promise.resolve():e.statAsync(t).then(e=>e.isDirectory()?r:void 0,r=>"ENOENT"===r.code?o(e,n(t),t):void 0),i=(e,t,r=void 0)=>{if(r!==t)try{return e.statSync(t).isDirectory()?r:void 0}catch(r){return"ENOENT"===r.code?i(e,n(t),t):void 0}};e.exports={findMade:o,findMadeSync:i}},6990(e,t,r){const{dirname:n}=r(6928),o=(e,t,r)=>{t.recursive=!1;const i=n(e);return i===e?t.mkdirAsync(e,t).catch(e=>{if("EISDIR"!==e.code)throw e}):t.mkdirAsync(e,t).then(()=>r||e,n=>{if("ENOENT"===n.code)return o(i,t).then(r=>o(e,t,r));if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;return t.statAsync(e).then(e=>{if(e.isDirectory())return r;throw n},()=>{throw n})})},i=(e,t,r)=>{const o=n(e);if(t.recursive=!1,o===e)try{return t.mkdirSync(e,t)}catch(e){if("EISDIR"!==e.code)throw e;return}try{return t.mkdirSync(e,t),r||e}catch(n){if("ENOENT"===n.code)return i(e,t,i(o,t,r));if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(!t.statSync(e).isDirectory())throw n}catch(e){throw n}}};e.exports={mkdirpManual:o,mkdirpManualSync:i}},3831(e,t,r){const{dirname:n}=r(6928),{findMade:o,findMadeSync:i}=r(4523),{mkdirpManual:s,mkdirpManualSync:a}=r(6990);e.exports={mkdirpNative:(e,t)=>(t.recursive=!0,n(e)===e?t.mkdirAsync(e,t):o(t,e).then(r=>t.mkdirAsync(e,t).then(()=>r).catch(r=>{if("ENOENT"===r.code)return s(e,t);throw r}))),mkdirpNativeSync:(e,t)=>{if(t.recursive=!0,n(e)===e)return t.mkdirSync(e,t);const r=i(t,e);try{return t.mkdirSync(e,t),r}catch(r){if("ENOENT"===r.code)return a(e,t);throw r}}}},5737(e,t,r){const{promisify:n}=r(9023),o=r(9896);e.exports=e=>{if(e)if("object"==typeof e)e={mode:511,fs:o,...e};else if("number"==typeof e)e={mode:e,fs:o};else{if("string"!=typeof e)throw new TypeError("invalid options argument");e={mode:parseInt(e,8),fs:o}}else e={mode:511,fs:o};return e.mkdir=e.mkdir||e.fs.mkdir||o.mkdir,e.mkdirAsync=n(e.mkdir),e.stat=e.stat||e.fs.stat||o.stat,e.statAsync=n(e.stat),e.statSync=e.statSync||e.fs.statSync||o.statSync,e.mkdirSync=e.mkdirSync||e.fs.mkdirSync||o.mkdirSync,e}},1276(e,t,r){const n=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:o,parse:i}=r(6928);e.exports=e=>{if(/\0/.test(e))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:e,code:"ERR_INVALID_ARG_VALUE"});if(e=o(e),"win32"===n){const t=/[*|"<>?:]/,{root:r}=i(e);if(t.test(e.substr(r.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e}},4443(e,t,r){const n=r(9896),o=(process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version).replace(/^v/,"").split("."),i=+o[0]>10||10===+o[0]&&+o[1]>=12,s=i?e=>e.mkdir===n.mkdir:()=>!1,a=i?e=>e.mkdirSync===n.mkdirSync:()=>!1;e.exports={useNative:s,useNativeSync:a}},6585(e){var t=1e3,r=60*t,n=60*r,o=24*n;function i(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,s){s=s||{};var a,c=typeof e;if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(i){var s=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*n;case"minutes":case"minute":case"mins":case"min":case"m":return s*r;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===c&&!1===isNaN(e))return s.long?i(a=e,o,"day")||i(a,n,"hour")||i(a,r,"minute")||i(a,t,"second")||a+" ms":function(e){return e>=o?Math.round(e/o)+"d":e>=n?Math.round(e/n)+"h":e>=r?Math.round(e/r)+"m":e>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},8169(e,t,r){const n=require;"function"==typeof n.addon?e.exports=n.addon.bind(n):e.exports=r(1381)},1381(e,t,r){var n=r(9896),o=r(6928),i=r(857),s=require,a=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,u=process.versions.modules,h=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",l=process.env.npm_config_arch||i.arch(),f=process.env.npm_config_platform||i.platform(),d=process.env.LIBC||(function(e){return"linux"===e&&n.existsSync("/etc/alpine-release")}(f)?"musl":"glibc"),p=process.env.ARM_VERSION||("arm64"===l?"8":a.arm_version)||"",m=(process.versions.uv||"").split(".")[0];function g(e){return s(g.resolve(e))}function y(e){try{return n.readdirSync(e)}catch(e){return[]}}function v(e,t){var r=y(e).filter(t);return r[0]&&o.join(e,r[0])}function b(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 k(e,t){return function(r){return null!=r&&r.platform===e&&r.architectures.includes(t)}}function S(e,t){return e.architectures.length-t.architectures.length}function _(e){var t=e.split("."),r={file:e,specificity:0};if("node"===t.pop()){for(var n=0;n<t.length;n++){var o=t[n];if("node"===o||"electron"===o||"node-webkit"===o)r.runtime=o;else if("napi"===o)r.napi=!0;else if("abi"===o.slice(0,3))r.abi=o.slice(3);else if("uv"===o.slice(0,2))r.uv=o.slice(2);else if("armv"===o.slice(0,4))r.armv=o.slice(4);else{if("glibc"!==o&&"musl"!==o)continue;r.libc=o}r.specificity++}return r}}function E(e,t){return function(r){return!(null==r||r.runtime&&r.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(r)||r.abi&&r.abi!==t&&!r.napi||r.uv&&r.uv!==m||r.armv&&r.armv!==p||r.libc&&r.libc!==d)}}function C(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=g,g.resolve=g.path=function(e){e=o.resolve(e||".");try{var t=s(o.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}if(!c){var r=v(o.join(e,"build/Release"),b);if(r)return r;var n=v(o.join(e,"build/Debug"),b);if(n)return n}var i=O(e);if(i)return i;var a=O(o.dirname(process.execPath));if(a)return a;var g=["platform="+f,"arch="+l,"runtime="+h,"abi="+u,"uv="+m,p?"armv="+p:"","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 "+g+"\n loaded from: "+e+"\n");function O(e){var t=y(o.join(e,"prebuilds")).map(w).filter(k(f,l)).sort(S)[0];if(t){var r=o.join(e,"prebuilds",t.name),n=y(r).map(_).filter(E(h,u)).sort(C(h))[0];return n?o.join(r,n.file):void 0}}},g.parseTags=_,g.matchTags=E,g.compareTags=C,g.parseTuple=w,g.matchTuple=k,g.compareTuples=S},9551(e,t,r){"use strict";var n=r(7342);function o(){}var i=null,s={};function a(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("Promise constructor's argument is not a function");this._x=0,this._y=0,this._z=null,this._A=null,e!==o&&d(e,this)}function c(e,t){for(;3===e._y;)e=e._z;if(a._B&&a._B(e),0===e._y)return 0===e._x?(e._x=1,void(e._A=t)):1===e._x?(e._x=2,void(e._A=[e._A,t])):void e._A.push(t);!function(e,t){n(function(){var r=1===e._y?t.onFulfilled:t.onRejected;if(null!==r){var n=function(e,t){try{return e(t)}catch(e){return i=e,s}}(r,e._z);n===s?h(t.promise,i):u(t.promise,n)}else 1===e._y?u(t.promise,e._z):h(t.promise,e._z)})}(e,t)}function u(e,t){if(t===e)return h(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){var r=function(e){try{return e.then}catch(e){return i=e,s}}(t);if(r===s)return h(e,i);if(r===e.then&&t instanceof a)return e._y=3,e._z=t,void l(e);if("function"==typeof r)return void d(r.bind(t),e)}e._y=1,e._z=t,l(e)}function h(e,t){e._y=2,e._z=t,a._C&&a._C(e,t),l(e)}function l(e){if(1===e._x&&(c(e,e._A),e._A=null),2===e._x){for(var t=0;t<e._A.length;t++)c(e,e._A[t]);e._A=null}}function f(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function d(e,t){var r=!1,n=function(e){try{e(function(e){r||(r=!0,u(t,e))},function(e){r||(r=!0,h(t,e))})}catch(e){return i=e,s}}(e);r||n!==s||(r=!0,h(t,i))}e.exports=a,a._B=null,a._C=null,a._D=o,a.prototype.then=function(e,t){if(this.constructor!==a)return function(e,t,r){return new e.constructor(function(n,i){var s=new a(o);s.then(n,i),c(e,new f(t,r,s))})}(this,e,t);var r=new a(o);return c(this,new f(e,t,r)),r}},5556(e,t,r){"use strict";var n=r(9551);e.exports=n,n.prototype.done=function(e,t){(arguments.length?this.then.apply(this,arguments):this).then(null,function(e){setTimeout(function(){throw e},0)})}},8635(e,t,r){"use strict";var n=r(9551);e.exports=n;var o=h(!0),i=h(!1),s=h(null),a=h(void 0),c=h(0),u=h("");function h(e){var t=new n(n._D);return t._y=1,t._z=e,t}n.resolve=function(e){if(e instanceof n)return e;if(null===e)return s;if(void 0===e)return a;if(!0===e)return o;if(!1===e)return i;if(0===e)return c;if(""===e)return u;if("object"==typeof e||"function"==typeof e)try{var t=e.then;if("function"==typeof t)return new n(t.bind(e))}catch(e){return new n(function(t,r){r(e)})}return h(e)};var l=function(e){return"function"==typeof Array.from?(l=Array.from,Array.from(e)):(l=function(e){return Array.prototype.slice.call(e)},Array.prototype.slice.call(e))};function f(e){return{status:"fulfilled",value:e}}function d(e){return{status:"rejected",reason:e}}function p(e){if(e&&("object"==typeof e||"function"==typeof e)){if(e instanceof n&&e.then===n.prototype.then)return e.then(f,d);var t=e.then;if("function"==typeof t)return new n(t.bind(e)).then(f,d)}return f(e)}function m(e){if("function"==typeof AggregateError)return new AggregateError(e,"All promises were rejected");var t=new Error("All promises were rejected");return t.name="AggregateError",t.errors=e,t}n.all=function(e){var t=l(e);return new n(function(e,r){if(0===t.length)return e([]);var o=t.length;function i(s,a){if(a&&("object"==typeof a||"function"==typeof a)){if(a instanceof n&&a.then===n.prototype.then){for(;3===a._y;)a=a._z;return 1===a._y?i(s,a._z):(2===a._y&&r(a._z),void a.then(function(e){i(s,e)},r))}var c=a.then;if("function"==typeof c)return void new n(c.bind(a)).then(function(e){i(s,e)},r)}t[s]=a,0===--o&&e(t)}for(var s=0;s<t.length;s++)i(s,t[s])})},n.allSettled=function(e){return n.all(l(e).map(p))},n.reject=function(e){return new n(function(t,r){r(e)})},n.race=function(e){return new n(function(t,r){l(e).forEach(function(e){n.resolve(e).then(t,r)})})},n.prototype.catch=function(e){return this.then(null,e)},n.any=function(e){return new n(function(t,r){var o=l(e),i=!1,s=[];function a(e){i||(i=!0,t(e))}function c(e){s.push(e),s.length===o.length&&r(m(s))}0===o.length?r(m(s)):o.forEach(function(e){n.resolve(e).then(a,c)})})}},4293(e,t,r){"use strict";var n=r(9551);e.exports=n,n.prototype.finally=function(e){return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})})}},7706(e,t,r){"use strict";e.exports=r(9551),r(5556),r(4293),r(8635),r(9791),r(1727)},9791(e,t,r){"use strict";var n=r(9551),o=r(983);e.exports=n,n.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?function(e,t){for(var r=[],o=0;o<t;o++)r.push("a"+o);var s=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([i]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}(e,t):function(e){for(var t=Math.max(e.length-1,3),r=[],o=0;o<t;o++)r.push("a"+o);var s=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+i+";","var res;","switch (argLength) {",r.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(r.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}(e)};var i="function (err, res) {if (err) { rj(err); } else { rs(res); }}";n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),r="function"==typeof t[t.length-1]?t.pop():null,i=this;try{return e.apply(this,arguments).nodeify(r,i)}catch(e){if(null==r)return new n(function(t,r){r(e)});o(function(){r.call(i,e)})}}},n.prototype.nodeify=function(e,t){if("function"!=typeof e)return this;this.then(function(r){o(function(){e.call(t,null,r)})},function(r){o(function(){e.call(t,r)})})}},1727(e,t,r){"use strict";var n=r(9551);e.exports=n,n.enableSynchronous=function(){n.prototype.isPending=function(){return 0==this.getState()},n.prototype.isFulfilled=function(){return 1==this.getState()},n.prototype.isRejected=function(){return 2==this.getState()},n.prototype.getValue=function(){if(3===this._y)return this._z.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._z},n.prototype.getReason=function(){if(3===this._y)return this._z.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._z},n.prototype.getState=function(){return 3===this._y?this._z.getState():-1===this._y||-2===this._y?0:this._y}},n.disableSynchronous=function(){n.prototype.isPending=void 0,n.prototype.isFulfilled=void 0,n.prototype.isRejected=void 0,n.prototype.getValue=void 0,n.prototype.getReason=void 0,n.prototype.getState=void 0}},4527(e,t,r){var n=r(9225).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)}},6556(e){"use strict";e.exports=function(e){const t=e.length;let r=0;for(;r<t;)if(128&e[r])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}else r++;return!0}},3148(e,t,r){"use strict";try{e.exports=r(8169)(__dirname)}catch(t){e.exports=r(6556)}},5488(e,t,r){e.exports=r(907)},4194(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},8828(e,t,r){var n=r(4552),o=r(4527),i=r(1909);const s=0,a=1,c=2,u=3;function h(e,t,r,o,a,c){i.EventTarget.call(this),(c=c||{}).assembleFragments=!0;var u=this;this._url=e,this._readyState=s,this._protocol=void 0,this._extensions="",this._bufferedAmount=0,this._binaryType="arraybuffer",this._connection=void 0,this._client=new n(c),this._client.on("connect",function(e){d.call(u,e)}),this._client.on("connectFailed",function(){p.call(u)}),this._client.connect(e,t,r,o,a)}function l(e,t){var r=new i.Event("close");return r.code=e,r.reason=t,r.wasClean=void 0===e||1e3===e,r}function f(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){m.call(t,e,r)}),this._connection.on("message",function(e){g.call(t,e)}),this.dispatchEvent(new i.Event("open"))}function p(){y.call(this),this._readyState=u;try{this.dispatchEvent(new i.Event("error"))}finally{this.dispatchEvent(l(1006,"connection failed"))}}function m(e,t){y.call(this),this._readyState=u,this.dispatchEvent(l(e,t||""))}function g(e){if(e.utf8Data)this.dispatchEvent(f(e.utf8Data));else if(e.binaryData&&"arraybuffer"===this.binaryType){for(var t=e.binaryData,r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0,i=t.length;o<i;++o)n[o]=t[o];this.dispatchEvent(f(r))}}function y(){this._client.removeAllListeners(),this._connection&&this._connection.removeAllListeners()}e.exports=h,Object.defineProperties(h.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(h.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",s],["OPEN",a],["CLOSING",c],["CLOSED",u]].forEach(function(e){Object.defineProperty(h.prototype,e[0],{get:function(){return e[1]}})}),[["CONNECTING",s],["OPEN",a],["CLOSING",c],["CLOSED",u]].forEach(function(e){Object.defineProperty(h,e[0],{get:function(){return e[1]}})}),h.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=o(e),this._connection.sendBytes(e)}},h.prototype.close=function(e,t){switch(this._readyState){case s:p.call(this),this._client.on("connect",function(r){e?r.close(e,t):r.close()});break;case a:this._readyState=c,e?this._connection.close(e,t):this._connection.close()}}},4552(e,t,r){var n=r(5237),o=n.extend,i=r(9023),s=r(4434).EventEmitter,a=r(8611),c=r(5692),u=r(7016),h=r(6982),l=r(2819),f=n.bufferAllocUnsafe,d=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],p=["hostname","port","method","path","headers"];function m(e){var t;switch(s.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={},o(this.config,e),o(this.config.tlsOptions,t)),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(m,s),m.prototype.connect=function(e,t,r,i,s){var h=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?u.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 l=f(16),m=0;m<16;m++)l[m]=Math.round(255*Math.random());this.base64nonce=l.toString("base64");var g=this.url.hostname;("ws:"===this.url.protocol&&"80"!==this.url.port||"wss:"===this.url.protocol&&"443"!==this.url.port)&&(g+=":"+this.url.port);var y,v={};function b(e){h._req=null,h.emit("connectFailed",e)}this.secure&&this.config.tlsOptions.hasOwnProperty("headers")&&o(v,this.config.tlsOptions.headers),i&&o(v,i),o(v,{Upgrade:"websocket",Connection:"Upgrade","Sec-WebSocket-Version":this.config.webSocketVersion.toString(10),"Sec-WebSocket-Key":this.base64nonce,Host:v.Host||g}),this.protocols.length>0&&(v["Sec-WebSocket-Protocol"]=this.protocols.join(", ")),this.origin&&(13===this.config.webSocketVersion?v.Origin=this.origin:8===this.config.webSocketVersion&&(v["Sec-WebSocket-Origin"]=this.origin)),y=this.url.pathname?this.url.path:this.url.path?"/"+this.url.path:"/";var w={agent:!1};if(s&&o(w,s),o(w,{hostname:this.url.hostname,port:this.url.port,method:"GET",path:y,headers:v}),this.secure){var k=this.config.tlsOptions;for(var S in k)k.hasOwnProperty(S)&&-1===p.indexOf(S)&&(w[S]=k[S])}var _=this._req=(this.secure?c:a).request(w);_.on("upgrade",function(e,t,r){h._req=null,_.removeListener("error",b),h.socket=t,h.response=e,h.firstDataChunk=r,h.validateHandshake()}),_.on("error",b),_.on("response",function(e){if(h._req=null,n.eventEmitterListenerCount(h,"httpResponse")>0)h.emit("httpResponse",e,h),e.socket&&e.socket.end();else{var t=[];for(var r in e.headers)t.push(r+": "+e.headers[r]);h.failHandshake("Server responded with a non-101 status: "+e.statusCode+" "+e.statusMessage+"\nResponse Headers Follow:\n"+t.join("\n")+"\n")}}),_.end()},m.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=h.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")},m.prototype.failHandshake=function(e){this.socket&&this.socket.writable&&this.socket.end(),this.emit("connectFailed",new Error(e))},m.prototype.succeedHandshake=function(){var e=new l(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},m.prototype.abort=function(){this._req&&this._req.abort()},e.exports=m},2819(e,t,r){var n=r(9023),o=r(5237),i=r(4434).EventEmitter,s=r(1338),a=r(3603),c=r(3148),u=o.bufferAllocUnsafe,h=o.bufferFromString;const l="open",f="peer_requested_close",d="ending",p="closed";var m="setImmediate"in global?global.setImmediate.bind(global):process.nextTick.bind(process),g=0;function y(e,t,r,n,c){if(this._debug=o.BufferingLogger("websocket:connection",++g),this._debug("constructor"),this._debug.enabled&&function(e,t){if(e._debug.enabled){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=c,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=u(4),this.frameHeader=u(10),this.bufferList=new a,this.currentFrame=new s(this.maskBytes,this.frameHeader,this.config),this.fragmentationSize=0,this.frameQueue=[],this.connected=!0,this.state=l,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 v(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)}y.CLOSE_REASON_NORMAL=1e3,y.CLOSE_REASON_GOING_AWAY=1001,y.CLOSE_REASON_PROTOCOL_ERROR=1002,y.CLOSE_REASON_UNPROCESSABLE_INPUT=1003,y.CLOSE_REASON_RESERVED=1004,y.CLOSE_REASON_NOT_PROVIDED=1005,y.CLOSE_REASON_ABNORMAL=1006,y.CLOSE_REASON_INVALID_DATA=1007,y.CLOSE_REASON_POLICY_VIOLATION=1008,y.CLOSE_REASON_MESSAGE_TOO_BIG=1009,y.CLOSE_REASON_EXTENSION_REQUIRED=1010,y.CLOSE_REASON_INTERNAL_SERVER_ERROR=1011,y.CLOSE_REASON_TLS_HANDSHAKE_FAILED=1015,y.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(y,i),y.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))},y.prototype.setKeepaliveTimer=function(){this._debug("setKeepaliveTimer"),this.config.keepalive&&!this.config.useNativeKeepalive&&(this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this._keepaliveTimeoutID=setTimeout(this._keepaliveTimerHandler,this.config.keepaliveInterval))},y.prototype.clearKeepaliveTimer=function(){this._keepaliveTimeoutID&&clearTimeout(this._keepaliveTimeoutID)},y.prototype.handleKeepaliveTimer=function(){this._debug("handleKeepaliveTimer"),this._keepaliveTimeoutID=null,this.ping(),this.config.dropConnectionOnKeepaliveTimeout?this.setGracePeriodTimer():this.setKeepaliveTimer()},y.prototype.setGracePeriodTimer=function(){this._debug("setGracePeriodTimer"),this.clearGracePeriodTimer(),this._gracePeriodTimeoutID=setTimeout(this._gracePeriodTimerHandler,this.config.keepaliveGracePeriod)},y.prototype.clearGracePeriodTimer=function(){this._gracePeriodTimeoutID&&clearTimeout(this._gracePeriodTimeoutID)},y.prototype.handleGracePeriodTimer=function(){this._debug("handleGracePeriodTimer"),this._gracePeriodTimeoutID=null,this.drop(y.CLOSE_REASON_ABNORMAL,"Peer not responding.",!0)},y.prototype.handleSocketData=function(e){this._debug("handleSocketData"),this.setKeepaliveTimer(),this.bufferList.write(e),this.processReceivedData()},y.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(y.CLOSE_REASON_PROTOCOL_ERROR,e.dropReason)});if(e.frameTooLarge)return this._debug("-- frame too large"),void process.nextTick(function(){t.drop(y.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(y.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 s(this.maskBytes,this.frameHeader,this.config),this.bufferList.length>0&&m(this.receivedDataHandler)}else this._debug("-- insufficient data for frame")}},y.prototype.handleSocketError=function(e){this._debug("handleSocketError: %j",e),this.state!==p?(this.closeReasonCode=y.CLOSE_REASON_ABNORMAL,this.closeDescription="Socket Error: "+e.syscall+" "+e.code,this.connected=!1,this.state=p,this.fragmentationSize=0,o.eventEmitterListenerCount(this,"error")>0&&this.emit("error",e),this.socket.destroy(),this._debug.printOutput()):this._debug(" --- Socket 'error' after 'close'")},y.prototype.handleSocketEnd=function(){this._debug("handleSocketEnd: received socket end. state = %s",this.state),this.receivedEnd=!0,this.state!==p?this.state!==f&&this.state!==d&&(this._debug(" --- UNEXPECTED socket end."),this.socket.end()):this._debug(" --- Socket 'end' after 'close'")},y.prototype.handleSocketClose=function(e){this._debug("handleSocketClose: received socket close"),this.socketHadError=e,this.connected=!1,this.state=p,-1===this.closeReasonCode&&(this.closeReasonCode=y.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))},y.prototype.handleSocketDrain=function(){this._debug("handleSocketDrain: socket drain event"),this.outputBufferFull=!1,this.emit("drain")},y.prototype.handleSocketPause=function(){this._debug("handleSocketPause: socket pause event"),this.inputPaused=!0,this.emit("pause")},y.prototype.handleSocketResume=function(){this._debug("handleSocketResume: socket resume event"),this.inputPaused=!1,this.emit("resume"),this.processReceivedData()},y.prototype.pause=function(){this._debug("pause: pause requested"),this.socket.pause()},y.prototype.resume=function(){this._debug("resume: resume requested"),this.socket.resume()},y.prototype.close=function(e,t){if(this.connected){if(this._debug("close: Initating clean WebSocket close sequence."),"number"!=typeof e&&(e=y.CLOSE_REASON_NORMAL),!v(e))throw new Error("Close code "+e+" is not valid.");"string"!=typeof t&&(t=y.CLOSE_DESCRIPTIONS[e]),this.closeReasonCode=e,this.closeDescription=t,this.setCloseTimer(),this.sendCloseFrame(this.closeReasonCode,this.closeDescription),this.state=d,this.connected=!1}},y.prototype.drop=function(e,t,r){this._debug("drop"),"number"!=typeof e&&(e=y.CLOSE_REASON_PROTOCOL_ERROR),"string"!=typeof t&&(t=y.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=p,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()},y.prototype.setCloseTimer=function(){this._debug("setCloseTimer"),this.clearCloseTimer(),this._debug("Setting close timer"),this.waitingForCloseResponse=!0,this.closeTimer=setTimeout(this._closeTimerHandler,this.closeTimeout)},y.prototype.clearCloseTimer=function(){this._debug("clearCloseTimer"),this.closeTimer&&(this._debug("Clearing close timer"),clearTimeout(this.closeTimer),this.waitingForCloseResponse=!1,this.closeTimer=null)},y.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=p,this.socket.end())},y.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(y.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(!c(e.binaryPayload))return void this.drop(y.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(y.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected Continuation Frame");if(this.fragmentationSize+=e.length,this.fragmentationSize>this.maxReceivedMessageSize)return void this.drop(y.CLOSE_REASON_MESSAGE_TOO_BIG,"Maximum message size exceeded.");if(this.frameQueue.push(e),e.fin){var t=0,r=u(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(!c(r))return void this.drop(y.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.emit("message",{type:"utf8",utf8Data:r.toString("utf8")});break;default:return void this.drop(y.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 o=!1;this.emit("ping",function(){o=!0},e.binaryPayload),o||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=p,void this.socket.end();var i;if(this._debug("---- Closing handshake initiated by peer."),this.state=f,e.invalidCloseFrameLength?(this.closeReasonCode=1005,i=y.CLOSE_REASON_PROTOCOL_ERROR):-1===e.closeStatus||v(e.closeStatus)?(this.closeReasonCode=e.closeStatus,i=y.CLOSE_REASON_NORMAL):(this.closeReasonCode=e.closeStatus,i=y.CLOSE_REASON_PROTOCOL_ERROR),e.binaryPayload.length>1){if(!c(e.binaryPayload))return void this.drop(y.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.closeDescription=e.binaryPayload.toString("utf8")}else this.closeDescription=y.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(y.CLOSE_REASON_PROTOCOL_ERROR,"Unrecognized Opcode: 0x"+e.opcode.toString(16))}},y.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)}},y.prototype.sendUTF=function(e,t){e=h(e.toString(),"utf8"),this._debug("sendUTF: %d bytes",e.length);var r=new s(this.maskBytes,this.frameHeader,this.config);r.opcode=1,r.binaryPayload=e,this.fragmentAndSend(r,t)},y.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 s(this.maskBytes,this.frameHeader,this.config);r.opcode=2,r.binaryPayload=e,this.fragmentAndSend(r,t)},y.prototype.ping=function(e){this._debug("ping");var t=new s(this.maskBytes,this.frameHeader,this.config);t.opcode=9,t.fin=!0,e&&(Buffer.isBuffer(e)||(e=h(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)},y.prototype.pong=function(e){this._debug("pong");var t=new s(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)},y.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 o=Math.ceil(n/r),i=0,a=function(e){e?"function"==typeof t&&(t(e),t=null):++i===o&&"function"==typeof t&&t()},c=1;c<=o;c++){var u=new s(this.maskBytes,this.frameHeader,this.config);u.opcode=1===c?e.opcode:0,u.fin=c===o;var h=c===o?n-r*(c-1):r,l=r*(c-1);u.binaryPayload=e.binaryPayload.slice(l,l+h),this.sendFrame(u,a)}},y.prototype.sendCloseFrame=function(e,t,r){if("number"!=typeof e&&(e=y.CLOSE_REASON_NORMAL),this._debug("sendCloseFrame state: %s, reasonCode: %d, description: %s",this.state,e,t),this.state===l||this.state===f){var n=new s(this.maskBytes,this.frameHeader,this.config);n.fin=!0,n.opcode=8,n.closeStatus=e,"string"==typeof t&&(n.binaryPayload=h(t,"utf8")),this.sendFrame(n,r),this.socket.end()}},y.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=y},1338(e,t,r){var n=r(2627),o=r(5237).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=o(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=o(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,s=2,a=0,c=0;this.fin&&(a|=128),this.rsv1&&(a|=64),this.rsv2&&(a|=32),this.rsv3&&(a|=16),this.mask&&(c|=128),a|=15&this.opcode,8===this.opcode?(this.length=2,this.binaryPayload&&(this.length+=this.binaryPayload.length),(r=o(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?c|=127&this.length:this.length>125&&this.length<=65535?(c|=126,s+=2):this.length>65535&&(c|=127,s+=8);var u=o(this.length+s+(this.mask?4:0));return u[0]=a,u[1]=c,i=2,this.length>125&&this.length<=65535?(u.writeUInt16BE(this.length,i),i+=2):this.length>65535&&(u.writeUInt32BE(0,i),u.writeUInt32BE(this.length,i+4),i+=8),this.mask?(t=e?0:4294967295*Math.random()>>>0,this.maskBytes.writeUInt32BE(t,0),this.maskBytes.copy(u,i),i+=4,r&&n.mask(r,this.maskBytes,u,i,this.length)):r&&r.copy(u,i),u},i.prototype.toString=function(){return"Opcode: "+this.opcode+", fin: "+this.fin+", length: "+this.length+", hasPayload: "+Boolean(this.binaryPayload)+", masked: "+this.mask},e.exports=i},5334(e,t,r){for(var n=r(6982),o=r(9023),i=r(7016),s=r(4434).EventEmitter,a=r(2819),c=/,\s*/,u=/;\s*/,h=/[\r\n]/g,l=/,\s*/,f=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],d=[String.fromCharCode(127)],p=0;p<31;p++)d.push(String.fromCharCode(p));var m=/([\x00-\x20\x22\x28\x29\x2c\x2f\x3a-\x3f\x40\x5b-\x5e\x7b\x7d\x7f])/,g=/[^\x21\x23-\x2b\x2d-\x3a\x3c-\x5b\x5d-\x7e]/,y=/^"[^"]*"$/,v=/[\x00-\x20\x3b]/g,b=/[;,] */,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 k(e,t,r){s.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 S(e){process.nextTick(function(){e.drop(1006,"TCP connection lost before handshake completed.",!0)})}o.inherits(k,s),k.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"];if(this.protocolFullCaseMap={},this.requestedProtocols=[],n&&n.split(c).forEach(function(t){var r=t.toLocaleLowerCase();e.requestedProtocols.push(r),e.protocolFullCaseMap[r]=t}),!this.serverConfig.ignoreXForwardedFor&&t.headers["x-forwarded-for"]){var o=this.remoteAddress;this.remoteAddresses=t.headers["x-forwarded-for"].split(l),this.remoteAddresses.push(o),this.remoteAddress=this.remoteAddresses[0]}if(this.serverConfig.parseExtensions){var s=t.headers["sec-websocket-extensions"];this.requestedExtensions=this.parseExtensions(s)}else this.requestedExtensions=[];if(this.serverConfig.parseCookies){var a=t.headers.cookie;this.cookies=this.parseCookies(a)}else this.cookies=[]},k.prototype.parseExtensions=function(e){if(!e||0===e.length)return[];var t=e.toLocaleLowerCase().split(c);return t.forEach(function(e,t,r){var n=e.split(u),o=n[0],i=n.slice(1);i.forEach(function(e,t,r){var n=e.split("="),o={name:n[0],value:n[1]};r.splice(t,1,o)});var s={name:o,params:i};r.splice(t,1,s)}),t},k.prototype.parseCookies=function(e){if(!e||"string"!=typeof e)return[];var t=[];return e.split(b).forEach(function(e){var r=e.indexOf("=");if(-1!==r){var n=e.substr(0,r).trim(),o=e.substr(++r,e.length).trim();'"'===o[0]&&(o=o.slice(1,-1)),t.push({name:n,value:decodeURIComponent(o)})}else t.push({name:e,value:null})}),t},k.prototype.accept=function(e,t,r){var o;this._verifyResolution(),e?void 0===(o=this.protocolFullCaseMap[e.toLocaleLowerCase()])&&(o=e):o=e,this.protocolFullCaseMap=null;var i=n.createHash("sha1");i.update(this.key+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s="HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "+i.digest("base64")+"\r\n";if(o){for(var c=0;c<o.length;c++){var u=o.charCodeAt(c),l=o.charAt(c);if(u<33||u>126||-1!==f.indexOf(l))throw this.reject(500),new Error('Illegal character "'+String.fromCharCode(l)+'" in subprotocol.')}if(-1===this.requestedProtocols.indexOf(e))throw this.reject(500),new Error("Specified protocol was not requested by the client.");o=o.replace(h,""),s+="Sec-WebSocket-Protocol: "+o+"\r\n"}if(this.requestedProtocols=null,t&&(t=t.replace(h,""),13===this.webSocketVersion?s+="Origin: "+t+"\r\n":8===this.webSocketVersion&&(s+="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(v,""),e.value=e.value.replace(v,""),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(m);if(t)throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie name");if(t=e.value.match(y)?e.value.slice(1,-1).match(g):e.value.match(g))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(v))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(v))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")}s+="Set-Cookie: "+r.join(";")+"\r\n"}.bind(this))}this._resolved=!0,this.emit("requestResolved",this),s+="\r\n";var p=new a(this.socket,[],e,!1,this.serverConfig);p.webSocketVersion=this.webSocketVersion,p.remoteAddress=this.remoteAddress,p.remoteAddresses=this.remoteAddresses;var b=this;return this._socketIsClosing?S(p):this.socket.write(s,"ascii",function(e){e?S(p):(b._removeSocketCloseListeners(),p._addSocketEventListeners())}),this.emit("requestAccepted",p),p},k.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(h,""))+"\r\n"),r)for(var o in r){var i=r[o].toString().replace(h,"");n+=o.replace(h,"")+": "+i+"\r\n"}n+="\r\n",this.socket.end(n,"ascii"),this.emit("requestRejected",this)},k.prototype._handleSocketCloseBeforeAccept=function(){this._socketIsClosing=!0,this._removeSocketCloseListeners()},k.prototype._removeSocketCloseListeners=function(){this.socket.removeListener("end",this._socketCloseHandler),this.socket.removeListener("close",this._socketCloseHandler)},k.prototype._verifyResolution=function(){if(this._resolved)throw new Error("WebSocketRequest may only be accepted or rejected one time.")},e.exports=k},9834(e,t,r){var n=r(5237).extend,o=r(9023),i=r(4434).EventEmitter,s=r(7705);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)}o.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 o=this.handlers[r];if(o.pathString===e&&o.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(),o=0,i=this.handlers.length;o<i;o++){var a=this.handlers[o];if(a.path.test(e.resourceURL.pathname)&&(n===a.protocol||"*"===a.protocol)){var c=new s(e,n);return void a.callback(c)}}e.reject(404,"No handler is available for the given request.")},e.exports=a},7705(e,t,r){var n=r(9023),o=r(4434).EventEmitter;function i(e,t){o.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,o),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},7788(e,t,r){var n=r(5237).extend,o=r(5237),i=r(9023),s=r(5753)("websocket:server"),a=r(4434).EventEmitter,c=r(5334),u=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(u,a),u.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)})},u.prototype.unmount=function(){var e=this._handlers.upgrade;this.config.httpServer.forEach(function(t){t.removeListener("upgrade",e)})},u.prototype.closeAllConnections=function(){this.connections.forEach(function(e){e.close()}),this.pendingRequests.forEach(function(e){process.nextTick(function(){e.reject(503)})})},u.prototype.broadcast=function(e){Buffer.isBuffer(e)?this.broadcastBytes(e):"function"==typeof e.toString&&this.broadcastUTF(e)},u.prototype.broadcastUTF=function(e){this.connections.forEach(function(t){t.sendUTF(e)})},u.prototype.broadcastBytes=function(e){this.connections.forEach(function(t){t.sendBytes(e)})},u.prototype.shutDown=function(){this.unmount(),this.closeAllConnections()},u.prototype.handleUpgrade=function(e,t){var r=this,n=new c(t,e,this.config);try{n.readHandshake()}catch(e){return n.reject(e.httpCode?e.httpCode:400,e.message,e.headers),s("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&&o.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.")},u.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)},u.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)},u.prototype.handleRequestResolved=function(e){var t=this.pendingRequests.indexOf(e);-1!==t&&this.pendingRequests.splice(t,1)},e.exports=u},5237(e,t,r){var n=t.noop=function(){};function o(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(4434).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(5753)(e);if(i.enabled){var s=new o(e,t,i),a=s.log.bind(s);return a.printOutput=s.printOutput.bind(s),a.enabled=i.enabled,a}return i.printOutput=n,i},o.prototype.log=function(){return this.buffer.push([new Date,Array.prototype.slice.call(arguments)]),this},o.prototype.clear=function(){return this.buffer=[],this},o.prototype.printOutput=function(e){e||(e=this.logFunction);var t=this.uniqueID;this.buffer.forEach(function(r){var n=r[0].toLocaleString(),o=r[1].slice(),i=o[0];null!=i&&(i="%s - %s - "+i.toString(),o.splice(0,1,i,n,t),e.apply(global,o))})}},9840(e,t,r){e.exports=r(9003).version},907(e,t,r){e.exports={...void r(7788),...void r(4552),...void r(9834),...void r(1338),...void r(5334),...void r(2819),w3cwebsocket:r(8828),...void r(4194),...void r(9840)}},3603(e,t,r){var n=r(181).Buffer,o=r(4434).EventEmitter,i=r(5237).bufferAllocUnsafe;function s(e){if(!(this instanceof s))return new s(e);o.call(this);var t=this;void 0===e&&(e={}),t.encoding=e.encoding;var r={next:null,buffer:null},a={next:null,buffer:null},c=0;t.__defineGetter__("length",function(){return c});var u=0;t.write=function(e){return r.buffer?(a.next={next:null,buffer:e},a=a.next):(r.buffer=e,a=r),c+=e.length,t.emit("write",e),!0},t.end=function(e){n.isBuffer(e)&&t.write(e)},t.push=function(){return[].concat.apply([],arguments).forEach(t.write),t},t.forEach=function(e){if(!r.buffer)return i(0);if(r.buffer.length-u<=0)return t;for(var n={buffer:r.buffer.slice(u),next:r.next};n&&n.buffer&&!e(n.buffer);)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 o=i(n-e),s=0;return t.forEach(function(t){if(e<s+t.length&&s<n&&t.copy(o,Math.max(0,s-e),Math.max(0,e-s),Math.min(t.length,n-s)),(s+=t.length)>n)return!0}),o},t.joinInto=function(e,n,o,s){if(!r.buffer)return new i(0);null==o&&(o=0),null==s&&(s=t.length);var a=e;if(a.length-n<s-o)throw new Error("Insufficient space available in target Buffer.");var c=0;return t.forEach(function(e){if(o<c+e.length&&c<s&&e.copy(a,Math.max(n,n+c-o),Math.max(0,o-c),Math.min(e.length,s-c)),(c+=e.length)>s)return!0}),a},t.advance=function(e){for(u+=e,c-=e;r.buffer&&u>=r.buffer.length;)u-=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){if(null==e?e=t.length:"number"!=typeof e&&(r=e,e=t.length),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=s,e.exports.BufferList=s,r(9023).inherits(s,o)},1909(e,t,r){e.exports={EventTarget:r(5384),Event:r(485)}},485(e){e.exports=function(e){this.type=e,this.isTrusted=!1,this._yaeti=!0}},5384(e){function t(){"function"!=typeof this.addEventListener&&(this._listeners={},this.addEventListener=r,this.removeEventListener=n,this.dispatchEvent=o)}function r(e,t){var r,n,o;if(e&&t){for(void 0===(r=this._listeners[e])&&(this._listeners[e]=r=[]),n=0;o=r[n];n++)if(o===t)return;r.push(t)}}function n(e,t){var r,n,o;if(e&&t&&void 0!==(r=this._listeners[e])){for(n=0;o=r[n];n++)if(o===t){r.splice(n,1);break}0===r.length&&delete this._listeners[e]}}function o(e){var t,r,n,o,i,s=!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(){s=!0}}catch(e){}for(t=e.type,r=this._listeners[t]||[],"function"==typeof(n=this["on"+t])&&n.call(this,e),o=0;(i=r[o])&&!s;o++)i.call(this,e);return!e.defaultPrevented}e.exports=t,Object.defineProperties(t.prototype,{listeners:{get:function(){return this._listeners}}})},3109(e,t,r){"use strict";const{parentPort:n,workerData:o}=r(8167),i=r(650);try{const e=Buffer.from(o.buffer),t=o.blockSizeMultiplier||9,r=Buffer.from(i.Bzip2.compressFile(e,void 0,t)),s=function(e,t){try{const r=Buffer.from(i.Bzip2.decompressFile(t));return r.length===e.length&&r.equals(e)?null:"decompressed output does not match the original data"}catch(e){return e&&e.message?e.message:String(e)}}(e,r);if(s)n.postMessage({ok:!1,verifyFailed:!0,error:s});else{const e=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);n.postMessage({ok:!0,buffer:e},[e])}}catch(e){n.postMessage({ok:!1,error:e&&e.message?e.message:String(e)})}},8803(e,t,r){"use strict";const n=r(9896),o=n.promises,i=r(6928),{Worker:s}=r(8167),a=r(3605),c="0.1.18-beta",u=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],h=[{key:"backup_folder",title:"Folder to save backups in",help:"If empty, backups go to the extension's own log folder.",default_value:"",type:"string",optional:!0},{key:"compress_backup",title:"Compress backups to bz2 (much slower, but smaller file)",help:"Off by default: backups are saved as a .xml file -- faster (no compression step). Turn this on to compress to .xml.bz2 instead, it's noticeably slower.",default_value:!1,type:"boolean"},{key:"nick",title:"Your AirDC++ nickname (used in the backup filename)",help:"Leave empty to auto-detect. Fill in to force a specific name instead.",default_value:"",type:"string",optional:!0},{key:"exclude_virtual_folders",title:"Skip these virtual folders (comma-separated)",help:"Leave empty to back up everything.",default_value:"",type:"string",optional:!0},{key:"schedule_days",title:"Automatically back up on these days (comma-separated)",help:'English day names, e.g. "monday" or "monday,thursday".',default_value:"",type:"string",optional:!0},{key:"retention_days",title:"Delete backups older than this many days (0 = never)",help:"Checked after every backup (manual or automatic).",default_value:60,type:"number",min:0}];function l(e){return String(e).padStart(2,"0")}function f(e){return`${e.getFullYear()}-${l(e.getMonth()+1)}-${l(e.getDate())}`}function d(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function p(e){return new Promise(t=>setTimeout(t,e))}function m(e,t){return new Promise((r,n)=>{const o=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let i;try{i=new s(__filename,{workerData:{buffer:o,blockSizeMultiplier:t},transferList:[o]})}catch(e){return void n(e)}i.once("message",e=>{if(i.terminate().catch(()=>{}),e&&e.ok)r(Buffer.from(e.buffer));else{const t=new Error(e&&e.error||"bz2 compression failed for an unknown reason");e&&e.verifyFailed&&(t.verifyFailed=!0),n(t)}}),i.once("error",e=>{i.terminate().catch(()=>{}),n(e)})})}e.exports=function(e,t){const r=a(e,{extensionName:t.name,configFile:t.configPath+"config.json",configVersion:1,definitions:h});let s=!1,l="",g=null;async function y(t,r){try{await e.post("events",{text:`[Share-backup] ${t}`,severity:r||"info"})}catch(e){console.error(`Could not send system log message: ${e.message}`)}}function v(){return i.join(t.configPath,"share-backup-state.json")}function b(e){return String(e).replace(/[<>:"/\\|?*\x00-\x1f]/g,"_").trim()}async function w(t){let r=0;const n=[];for(;;){let o,i;for(let n=1;n<=5;n++)try{o=await e.post(`share/directories/by_real/content/${r}/1000`,{path:t}),i=null;break}catch(e){i=e,await p(300)}if(i)throw i;if(n.push(...o||[]),!o||o.length<1e3)break;r+=1e3}return n}async function k(e,t,r,n,o,i,s,a){if(s>60)return void await y(`Stopped descending at "${e}" -- reached the maximum folder depth (60). This can happen with a symlink loop on disk. Skipping the rest of this branch; the rest of the backup continues normally.`,"warning");const c=e.toLowerCase();if(i.has(c))return void await y(`Stopped descending at "${e}" -- this exact real path was already visited during this backup. This can happen with a symlink loop on disk. Skipping the rest of this branch; the rest of the backup continues normally.`,"warning");let u;i.add(c);try{u=await w(e)}catch(t){return void await y(`Could not read "${e}", skipping it: ${t&&t.message?t.message:t}`,"warning")}const h=u.filter(e=>e.type&&"directory"===e.type.id),l=u.filter(e=>!e.type||"directory"!==e.type.id);for(const e of l)t.write(`${r}<File Name="${d(e.name)}" Size="${e.size||0}" TTH="${e.tth||""}"/>\n`),n.files+=1,n.bytes+=e.size||0,o();for(const e of h){if(a.has((e.name||"").toLowerCase())){n.excluded+=1;continue}const c=e.time?` Date="${e.time}"`:"";t.write(`${r}<Directory Name="${d(e.name)}"${c}>\n`),n.dirs+=1,await k(e.path,t,r+"\t",n,o,i,s+1,a),t.write(`${r}</Directory>\n`)}}async function S(a,u){if(s)return void await y("A backup is already in progress, please wait for it to finish.","warning");s=!0;let h=null;try{const s="scheduled"===u?" (scheduled backup)":"";await y(`Backup started${a&&"/"!==a?` for "${a}"`:""}${s}...`,"info");const{nick:p,source:g}=await async function(){const t=(r.getValue("nick")||"").trim();if(t)return{nick:t,source:"manual"};const n=(await async function(){try{const t=await e.get("hubs");if(Array.isArray(t)&&t.length){const e=t.find(e=>e&&e.connect_state&&"connected"===e.connect_state.id&&e.settings&&e.settings.nick);if(e)return e.settings.nick;const r=t.find(e=>e&&e.settings&&e.settings.nick);if(r)return r.settings.nick}}catch(e){}try{const t=await e.get("settings");if(t&&t.nick)return t.nick}catch(e){}return""}()).trim();return n?{nick:n,source:"auto-detected"}:{nick:"Unknown",source:"fallback"}}();"auto-detected"===g?await y(`Using auto-detected nick "${p}" for the backup filename (set "Your AirDC++ nickname" to override).`,"info"):"fallback"===g&&await y(`Could not auto-detect a nick (no connected hub found) and none is set manually -- using placeholder name "${p}" instead. The backup still includes every file and folder; only the filename may not be recognized by AirDC++'s "Open filelist" until you set "Your AirDC++ nickname" or connect to a hub.`,"warning");const v=await async function(){return await e.get("share_roots")||[]}();if(!v.length)throw new Error("No shared folders found -- nothing to back up.");const S=function(e){const t=[],r=new Map;for(const n of e){const e=(n.virtual_name||"").toLowerCase();let o=r.get(e);o||(o={virtual_name:n.virtual_name,roots:[]},r.set(e,o),t.push(o)),o.roots.push(n)}return t}(v),_=(a||"/").trim().replace(/^\/+|\/+$/g,""),E=_?await async function(e,t){const r=e.split("/").map(e=>e.trim()).filter(Boolean);if(0===r.length)return null;const n=r[0].toLowerCase(),o=t.find(e=>(e.virtual_name||"").toLowerCase()===n);if(!o)throw new Error(`Could not find a share root named "${r[0]}"`);if(1===r.length)return{displayName:o.virtual_name,realPaths:o.roots.map(e=>e.path)};let i=o.roots[0].path,s=o.roots[0].virtual_name;for(let e=1;e<r.length;e++){const t=(await w(i)).find(t=>t.type&&"directory"===t.type.id&&(t.name||"").toLowerCase()===r[e].toLowerCase());if(!t)throw new Error(`Could not find subfolder "${r[e]}" inside "${r.slice(0,e).join("/")}"`);i=t.path,s=t.name}return{displayName:s,realPaths:[i]}}(_,S):null,C=(r.getValue("backup_folder")||"").trim()||i.join(t.logPath,"backups");await o.mkdir(C,{recursive:!0});const O=new Date;h=i.join(C,`.share-backup-${Date.now()}.tmp.xml`);const x=n.createWriteStream(h,{encoding:"utf8"});x.write('<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n'),x.write(`<FileListing Version="1" CID="${d(l)}" Base="${d(a||"/")}" BaseDate="${Math.floor(O.getTime()/1e3)}" Generator="ShareFixxers Share-Backup ${c}">\n`);const B=function(){const e=(r.getValue("exclude_virtual_folders")||"").trim();return e?new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean)):new Set}(),A={files:0,dirs:0,bytes:0,excluded:0};let R=Date.now();const T=()=>{const e=Date.now();e-R>=5e3&&(R=e,y(`Still working... ${A.files} files, ${A.dirs} folders so far.`,"info").catch(()=>{}))},M=new Set;if(E){x.write(`\t<Directory Name="${d(E.displayName)}">\n`),A.dirs+=1;for(const e of E.realPaths)await k(e,x,"\t\t",A,T,M,1,B);x.write("\t</Directory>\n")}else for(const e of S)if(B.has((e.virtual_name||"").toLowerCase()))A.excluded+=e.roots.length;else{x.write(`\t<Directory Name="${d(e.virtual_name)}">\n`),A.dirs+=1;for(const t of e.roots)await k(t.path,x,"\t\t",A,T,M,1,B);x.write("\t</Directory>\n")}x.write("</FileListing>\n"),await new Promise((e,t)=>{x.end(r=>r?t(r):e())});const F=await o.readFile(h),P=!!r.getValue("compress_backup");let I,L,N=!1;if(P){await y("Compressing the backup to bz2 (this can take a few minutes for a large share, running in the background)...","info");const e=await async function(e,t){try{return{compressed:await m(e,9)}}catch(e){if(!e.verifyFailed)throw e;await t(`bz2 self-verification failed on the first attempt (${e.message}) -- retrying with a different block size...`,"warning")}try{return{compressed:await m(e,3)}}catch(e){if(!e.verifyFailed)throw e;return await t(`bz2 self-verification failed again (${e.message}) -- saving this backup as an uncompressed .xml instead, so it's never silently corrupt. This is a known rare bug in the pure-JS bzip2 compressor on some large shares.`,"warning"),{fallbackToXml:!0}}}(F,y);I=e.compressed,L=e.fallbackToXml,N=!!e.fallbackToXml}else L=!0;const{dayFolder:D,filePath:j}=function(e,t,r){const n=i.join(e,f(t)),o=`${b(r)}.${b(l)}.xml.bz2`;return{dayFolder:n,filePath:i.join(n,o)}}(C,O,p);await o.mkdir(D,{recursive:!0});const U=L?j.replace(/\.xml\.bz2$/,".xml"):j;let q,z=!1;try{await o.access(U),z=!0}catch(e){}L?(await o.writeFile(U,F),q=F.length):(await o.writeFile(U,I),q=I.length),await o.unlink(h).catch(()=>{}),h=null;const $=await async function(e,t){if(!t||t<=0)return 0;const r=Date.now()-24*t*60*60*1e3;let n;try{n=await o.readdir(e,{withFileTypes:!0})}catch(e){return 0}let s=0;for(const t of n){if(!t.isDirectory())continue;const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.name);if(!n)continue;const a=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(a.getTime())||a.getTime()>=r)continue;const c=i.join(e,t.name);try{await o.rm(c,{recursive:!0,force:!0}),s+=1}catch(e){}}return s}(C,r.getValue("retention_days")),H=(q/1024/1024).toFixed(2),G=A.excluded>0?`, ${A.excluded} folder(s) skipped by name`:"",W=$>0?`, ${$} old backup(s) deleted`:"",V=z?", overwrote the previous backup already saved today":"",Y=P?N?" (uncompressed .xml -- bz2 verification failed, see warning above)":" (bz2)":" (uncompressed .xml)";await y(`Backup complete: ${A.files} files, ${A.dirs} folders, ${H} MB${Y}${G}${W}${V}. Saved to: ${U}`,"info")}catch(e){await y(`Backup failed: ${e&&e.message?e.message:e}`,"error")}finally{h&&await o.unlink(h).catch(()=>{}),s=!1}}async function _(){try{const t=await e.get("hash/stats");if(!t)return!1;const r="number"==typeof t.hash_files_left?t.hash_files_left:0,n="number"==typeof t.hashers?t.hashers:0;return r>0||n>0}catch(e){return!1}}function E(){try{const e=function(){const e=(r.getValue("schedule_days")||"").trim();if(!e)return new Set;const t=new Set;for(const r of e.split(",")){const e=r.trim().toLowerCase(),n=u.indexOf(e);n>=0&&t.add(n)}return t}();if(0===e.size)return;const o=new Date;if(!e.has(o.getDay()))return;const i=function(){try{return JSON.parse(n.readFileSync(v(),"utf8"))}catch(e){return{}}}(),s=f(o);if(i.lastAutoBackup===s)return;!function(e){try{n.writeFileSync(v(),JSON.stringify(e))}catch(e){console.error(`Could not save share-backup state: ${e.message}`)}}({...i,lastAutoBackup:s});const a="number"==typeof t.__hashWaitMaxMsOverride?t.__hashWaitMaxMsOverride:12e5;(async()=>{await async function(e){const r="number"==typeof t.__hashWaitPollMsOverride?t.__hashWaitPollMsOverride:15e3,n=Date.now();let o=!1;for(;Date.now()-n<e;){if(!await _())return;o||(await y('AirDC++ appears to still be hashing/refreshing the share (e.g. "Refresh share at startup") -- waiting for it to finish before starting the scheduled backup, so the snapshot is not taken mid-refresh...',"info"),o=!0),await p(r)}o&&await y("Still hashing after waiting -- starting the scheduled backup anyway rather than skipping it. It may include some entries that were not yet refreshed.","warning")}(a),await S("/","scheduled")})().catch(e=>console.error(`Scheduled backup error: ${e.message}`))}catch(e){console.error(`checkSchedule failed unexpectedly: ${e&&e.message?e.message:e}`)}}const C='\nShare-backup commands\n\n/sharebackup - Back up the whole share\n/sharebackup <path> - Back up only that share-relative folder (e.g. /Music/)\n\nSaves an XML snapshot (names, sizes, TTH) named <nick>.<CID>.xml, in a\nYYYY-MM-DD subfolder, openable directly with "Open filelist" in AirDC++ or most other DC++ clients.\nSchedule, retention, bz2 compression and excluded folders are all set in\nthis extension\'s Settings tab.',O=async(t,r,n)=>{if(t&&r)try{await e.post(`${t}/${r}/status_message`,{text:n,severity:"info"})}catch(e){console.error(`Could not send status message: ${e.message}`)}else await y(n,"info")},x=async(e,t,r)=>{const n=(t.command||"").toLowerCase(),o=t.args||[];if("sharebackup"===n){const t=o.join(" ").trim();if("help"===t.toLowerCase())return void await O(e,r,C);S(t||"/","manual").catch(e=>console.error(`Unexpected backup error: ${e.message}`))}else"sharebackuphelp"===n&&await O(e,r,C)};t.onStart=async n=>{l=n&&n.system_info&&n.system_info.cid||"",await r.load();const o=r.getValues();o&&void 0!==o.retention_days||await y("Warning: settings registration with AirDC++ appears to have failed -- no options will be visible or changeable in this extension's Settings tab, and default values will be used for everything. Check this extension's error.log for details, then restart AirDC++ to retry.","error");try{await e.addListener("hubs","hub_text_command",(e,t)=>x("hubs",e,t)),await e.addListener("private_chat","private_chat_text_command",(e,t)=>x("private_chat",e,t))}catch(e){console.error(`Could not register command listener: ${e.message}`)}const i="number"==typeof t.__startupGraceMsOverride?t.__startupGraceMsOverride:12e4,s=setTimeout(E,i);"function"==typeof s.unref&&s.unref(),g=setInterval(E,36e5),"function"==typeof g.unref&&g.unref(),await y(`Extension started (v${c}), command /sharebackup <path> is active. Type /sharebackuphelp for help.`,"info")},t.onStop=()=>{g&&(clearInterval(g),g=null)}}},9010(e,t,r){var n,o,i,s,a,c,u;e.exports=(n=r(6956),o=r(6015),i=console.assert.bind(console),s=function(e,t,r,n){var o;for(o=0;o<n;o++)t[o]=0;for(o=0;o<r;o++)t[e[o]]++},a=function(e,t,r,n){var o,i=0;if(n)for(o=0;o<r;o++)i+=e[o],t[o]=i;else for(o=0;o<r;o++)i+=e[o],t[o]=i-e[o]},c=function(e,t,r,n,u,h){var l,f,d,p,m,g,y,v,b,w,k,S,_,E=0,C=0;for(u<=256?(l=o.makeS32Buffer(u),u<=r?(f=t.subarray(n+r-u),C=1):(f=o.makeS32Buffer(u),C=3)):u<=r?(l=t.subarray(n+r-u),u<=r-u?(f=t.subarray(n+r-2*u),C=0):u<=1024?(f=o.makeS32Buffer(u),C=2):(f=l,C=8)):(l=f=o.makeS32Buffer(u),C=12),s(e,l,n,u),a(l,f,u,!0),p=0;p<n;p++)t[p]=0;g=-1,p=n-1,m=n,y=0,S=e[n-1];do{_=S}while(--p>=0&&(S=e[p])>=_);for(;p>=0;){do{_=S}while(--p>=0&&(S=e[p])<=_);if(p>=0){g>=0&&(t[g]=m),g=--f[_],m=p,++y;do{_=S}while(--p>=0&&(S=e[p])>=_)}}if(y>1?(function(e,t,r,n,o,c){var u,h,l,f,d;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],l--,t[u++]=e[l]<d?~l:l,h=0;h<o;h++)(l=t[h])>0?(i(e[l]>=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(h<u),l--,t[u++]=e[l]<d?~l:l,t[h]=0):l<0&&(t[h]=~l);for(r===n&&s(e,r,o,c),a(r,n,c,1),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0&&(i(e[l]<=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(u<=h),l--,t[--u]=e[l]>d?~(l+1):l,t[h]=0)}(e,t,l,f,n,u),w=function(e,t,r,n){var o,s,a,c,u,h,l,f,d,p;for(i(r>0),o=0;(a=t[o])<0;o++)t[o]=~a,i(o+1<r);if(o<n)for(s=o,o++;i(o<r),!((a=t[o])<0&&(t[s++]=~a,t[o]=0,s===n));o++);f=e[o=s=r-1];do{d=f}while(--o>=0&&(f=e[o])>=d);for(;o>=0;){do{d=f}while(--o>=0&&(f=e[o])<=d);if(o>=0){t[n+(o+1>>>1)]=s-o,s=o+1;do{d=f}while(--o>=0&&(f=e[o])>=d)}}for(o=0,l=0,c=r,h=0;o<n;o++){if(p=!0,(u=t[n+((a=t[o])>>>1)])===h&&c+u<r){for(s=0;s<u&&e[a+s]===e[c+s];)s++;s===u&&(p=!1)}p&&(l++,c=a,h=u),t[n+(a>>>1)]=l}return l}(e,t,n,y)):1===y?(t[g]=m+1,w=1):w=0,w<y){for(4&C&&(l=null,f=null),2&C&&(f=null),k=n+r-2*y,13&C||(u+w<=k?k-=u:C|=8),i(n>>>1<=k+y),p=y+(n>>>1)-1,m=2*y+k-1;y<=p;p--)0!==t[p]&&(t[m--]=t[p]-1);d=t.subarray(y+k),c(d,t,k,y,w,!1),d=null,p=n-1,m=2*y-1,S=e[n-1];do{_=S}while(--p>=0&&(S=e[p])>=_);for(;p>=0;){do{_=S}while(--p>=0&&(S=e[p])<=_);if(p>=0){t[m--]=p+1;do{_=S}while(--p>=0&&(S=e[p])>=_)}}for(p=0;p<y;p++)t[p]=t[y+t[p]];4&C&&(l=f=o.makeS32Buffer(u)),2&C&&(f=o.makeS32Buffer(u))}if(8&C&&s(e,l,n,u),y>1){a(l,f,u,!0),p=y-1,m=n,_=e[v=t[y-1]];do{for(b=f[S=_];b<m;)t[--m]=0;do{if(t[--m]=v,--p<0)break;v=t[p]}while((_=e[v])===S)}while(p>=0);for(;m>0;)t[--m]=0}return h?E=function(e,t,r,n,o,c){var u,h,l,f,d,p=-1;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],t[u++]=l>0&&e[l-1]<d?~l:l,h=0;h<o;h++)(l=t[h])>0?(l--,i(e[l]>=e[l+1]),t[h]=~(f=e[l]),f!==d&&(n[d]=u,u=n[d=f]),i(h<u),t[u++]=l>0&&e[l-1]<d?~l:l):0!==l&&(t[h]=~l);for(r===n&&s(e,r,o,c),a(r,n,c,!0),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0?(l--,i(e[l]<=e[l+1]),t[h]=f=e[l],f!==d&&(n[d]=u,u=n[d=f]),i(u<=h),t[--u]=l>0&&e[l-1]>d?~e[l-1]:l):0!==l?t[h]=~l:p=h;return p}(e,t,l,f,n,u):function(e,t,r,n,o,c){var u,h,l,f,d;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],t[u++]=l>0&&e[l-1]<d?~l:l,h=0;h<o;h++)l=t[h],t[h]=~l,l>0&&(l--,i(e[l]>=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(h<u),t[u++]=l>0&&e[l-1]<d?~l:l);for(r===n&&s(e,r,o,c),a(r,n,c,!0),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0?(l--,i(e[l]<=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(u<=h),t[--u]=0===l||e[l-1]>d?~l:l):t[h]=~l}(e,t,l,f,n,u),l=null,f=null,E},(u=Object.create(null)).suffixsort=function(e,t,r,n){if(i(e&&t&&e.length>=r&&t.length>=r),r<=1)return 1===r&&(t[0]=0),0;if(!n)if(1===e.BYTES_PER_ELEMENT)n=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");n=65536}return i(n>0),e.BYTES_PER_ELEMENT&&i(n<=1<<8*e.BYTES_PER_ELEMENT),c(e,t,0,r,n,!1)},u.bwtransform=function(e,t,r,n,o){var s,a;if(i(e&&t&&r),i(e.length>=n&&t.length>=n&&r.length>=n),n<=1)return 1===n&&(t[0]=e[0]),n;if(!o)if(1===e.BYTES_PER_ELEMENT)o=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");o=65536}for(i(o>0),e.BYTES_PER_ELEMENT&&i(o<=1<<8*e.BYTES_PER_ELEMENT),a=c(e,r,0,n,o,!0),t[0]=e[n-1],s=0;s<a;s++)t[s+1]=r[s];for(s+=1;s<n;s++)t[s]=r[s];return a+1},u.unbwtransform=function(e,t,r,n,i){var s,a,c=o.makeU32Buffer(256);for(s=0;s<256;s++)c[s]=0;for(s=0;s<n;s++)r[s]=c[e[s]]++;for(s=0,a=0;s<256;s++)a+=c[s],c[s]=a-c[s];for(s=n-1,a=0;s>=0;s--)a=r[a]+c[t[s]=e[a]],a+=a<i?1:0;c=null},u.bwtransform2=function(e,t,r,n){var s,a,u,h=0;if(i(e&&t),i(e.length>=r&&t.length>=r),r<=1)return 1===r&&(t[0]=e[0]),0;if(!n)if(1===e.BYTES_PER_ELEMENT)n=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");n=65536}if(i(n>0),e.BYTES_PER_ELEMENT&&i(n<=1<<8*e.BYTES_PER_ELEMENT),(u=e.length>=2*r?e:n<=256?o.makeU8Buffer(2*r):n<=65536?o.makeU16Buffer(2*r):o.makeU32Buffer(2*r))!==e)for(s=0;s<r;s++)u[s]=e[s];for(s=0;s<r;s++)u[r+s]=u[s];var l=o.makeS32Buffer(2*r);for(c(u,l,0,2*r,n,!1),s=0,a=0;s<2*r;s++){var f=l[s];f<r&&(0===f&&(h=a),--f<0&&(f=r-1),t[a++]=e[f])}return i(a===r),h},n(u))},1793(e,t,r){var n,o,i,s,a,c,u,h;e.exports=(r(6956),n=r(9010),o=r(936),i=r(5623),s=r(9461),a=r(1679),c=r(1249),u=r(3403),h=r(6015),u.EOF,BWTC=Object.create(null),BWTC.MAGIC="bwtc",BWTC.compressFile=h.compressFileHelper(BWTC.MAGIC,function(e,t,r,u,l){var f=new c(t);f.encodeStart(l,1);var d=9;"number"==typeof u&&u>=1&&u<=9&&(d=u),f.encodeByte(d);var p=d<=5;d*=1e5;var m,g,y,v,b,w,k=h.makeU8Buffer(d),S=function(){var t;for(t=0;t<d;){var r=e.readByte();if(r<0)break;k[t++]=r}return t},_=h.makeU8Buffer(d),E=h.makeS32Buffer(d),C=h.makeU8Buffer(256),O=a.factory(f),x=new s(d,0,O,O);do{if(0===(m=S()))break;m===k.length?(f.encodeFreq(1,0,3),g=k):(f.encodeFreq(1,1,3),x.encode(m),g=k.subarray(0,m)),v=n.bwtransform(g,_,E,m,256),x.encode(v);var B=h.makeU16Buffer(512);for(b=0;b<m;b++)B[256+(y=_[b])]=1;for(b=255;b>0;b--)B[b]=B[2*b]+B[2*b+1];for(B[0]=1,b=1;b<512;b++){var A=b>>>1,R=1<<9-h.fls(b);if(0===B[A]||B[A]===2*R);else if(b>=256)f.encodeBit(B[b]);else{var T=B[b];T=0===T?0:T===R?2:1,f.encodeFreq(1,T,3)}}var M=0;for(b=0;b<256;b++)B[256+b]&&(C[M++]=b);for(B=null,b=0;b<m;b++){for(y=_[b],w=0;w<M&&C[w]!==y;w++);for(console.assert(w<M),_[b]=w;w>0;w--)C[w]=C[w-1];C[0]=y}var F=new i(f,M+1,65280,256);p&&(F=new o(f,M+1));var P=0,I=function(){for(;0!==P;)1&P?(F.encode(0),P-=1):(F.encode(1),P-=2),P>>>=1};for(b=0;b<m;b++)0===(y=_[b])?P++:(I(),F.encode(y+1),P=0);I()}while(m===k.length);f.encodeFreq(1,2,3),f.encodeFinish()},!0),BWTC.decompressFile=h.decompressFileHelper(BWTC.MAGIC,function(e,t,r){var u=new c(e);u.decodeStart(!0);var l=u.decodeByte();console.assert(l>=1&&l<=9);var f=l<=5;l*=1e5;for(var d,p,m,g,y,v=h.makeU8Buffer(l),b=h.makeU8Buffer(l),w=h.makeS32Buffer(l),k=h.makeU8Buffer(256),S=a.factory(u),_=new s(l,0,S,S);;){var E=u.decodeCulFreq(3);if(u.decodeUpdate(1,E,3),0===E)p=l,d=v;else if(1===E)p=_.decode(),d=v.subarray(0,p);else if(2===E)break;var C=_.decode(),O=h.makeU16Buffer(512);for(O[0]=1,m=1;m<512;m++){var x=m>>>1,B=1<<9-h.fls(m);if(0===O[x]||O[x]===2*B)O[m]=O[x]>>>1;else if(m>=256)O[m]=u.decodeBit();else{var A=u.decodeCulFreq(3);u.decodeUpdate(1,A,3),O[m]=2===A?B:A}}var R=0;for(m=0;m<256;m++)O[256+m]&&(k[R++]=m);O=null;var T=new i(u,R+1,65280,256);f&&(T=new o(u,R+1,!0));var M=1;for(m=0;m<p;)if(0===(y=T.decode())){for(g=0;g<M;g++)d[m++]=0;M*=2}else if(1===y){for(g=0;g<M;g++)d[m++]=0,d[m++]=0;M*=2}else M=1,d[m++]=y-1;for(m=0;m<p;m++){for(g=d[m],d[m]=y=k[g];g>0;g--)k[g]=k[g-1];k[0]=y}n.unbwtransform(v,b,w,p,C),t.write(b,0,p)}u.decodeFinish()}),BWTC)},8196(e,t,r){var n,o;e.exports=(n=r(3403),(o=function(e){(function(){var t=256;this.readBit=function(){if(!(255&t)){var r=e.readByte();if(r===n.EOF)return this._eof=!0,r;t=r<<1|1}var o=256&t?1:0;return t<<=1,o},this.seekBit=function(e){var t=e>>>3,r=e-8*t;this.seek(t),this._eof=!1,this.readBits(r)},this.tellBit=function(){for(var r=8*e.tell(),n=t;255&n;)r--,n<<=1;return r},this.readByte=function(){return 255&t?this.readBits(8):e.readByte()},this.seek=function(r){e.seek(r),t=256}}).call(this),function(){var t=1;this.writeBit=function(r){t<<=1,r&&(t|=1),256&t&&(e.writeByte(255&t),t=1)},this.writeByte=function(r){1===t?e.writeByte(r):e.writeBits(8,r)},this.flush=function(){for(;1!==t;)this.writeBit(0);e.flush&&e.flush()}}.call(this)}).EOF=n.EOF,(o.prototype=Object.create(n.prototype)).readBits=function(e){var t,r=0;if(e>31)return(r=65536*this.readBits(e-16))+this.readBits(16);for(t=0;t<e;t++)r<<=1,this.readBit()>0&&r++;return r},o.prototype.writeBits=function(e,t){if(e>32){var r=65535&t,n=(t-r)/65536;return this.writeBits(e-16,n),void this.writeBits(16,r)}var o;for(o=e-1;o>=0;o--)this.writeBit(t>>>o&1)},o)},7026(e,t,r){e.exports=function(e,t,r,n,o,i,s){var a=50,c=54156738319193,u=25779555029136,h=i.EOF,l=function(e,t){var r,n=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=n,n},f={OK:0,LAST_BLOCK:-1,NOT_BZIP_DATA:-2,UNEXPECTED_INPUT_EOF:-3,UNEXPECTED_OUTPUT_EOF:-4,DATA_ERROR:-5,OUT_OF_MEMORY:-6,OBSOLETE_INPUT:-7,END_OF_BLOCK:-8},d={};d[f.LAST_BLOCK]="Bad file checksum",d[f.NOT_BZIP_DATA]="Not bzip data",d[f.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",d[f.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",d[f.DATA_ERROR]="Data error",d[f.OUT_OF_MEMORY]="Out of memory",d[f.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var p=function(e,t){var r=d[e]||"unknown error";t&&(r+=": "+t);var n=new TypeError(r);throw n.errorCode=e,n},m=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};m.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new n,!0):(this.writeCount=-1,!1)},m.prototype._start_bunzip=function(e,r){var n=s.makeU8Buffer(4);4===e.read(n,0,4)&&"BZh"===String.fromCharCode(n[0],n[1],n[2])||p(f.NOT_BZIP_DATA,"bad magic");var o=n[3]-48;(o<1||o>9)&&p(f.NOT_BZIP_DATA,"level out of range"),this.reader=new t(e),this.dbufSize=1e5*o,this.nextoutput=0,this.outputStream=r,this.streamCRC=0},m.prototype._get_next_block=function(){var e,t,r,n=this.reader,o=n.readBits(48);if(o===u)return!1;o!==c&&p(f.NOT_BZIP_DATA),this.targetBlockCRC=n.readBits(32),this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,n.readBits(1)&&p(f.OBSOLETE_INPUT);var i=n.readBits(24);i>this.dbufSize&&p(f.DATA_ERROR,"initial position out of bounds");var a=n.readBits(16),h=s.makeU8Buffer(256),d=0;for(e=0;e<16;e++)if(a&1<<15-e){var m=16*e;for(r=n.readBits(16),t=0;t<16;t++)r&1<<15-t&&(h[d++]=m+t)}var g=n.readBits(3);(g<2||g>6)&&p(f.DATA_ERROR);var y=n.readBits(15);0===y&&p(f.DATA_ERROR);var v=s.makeU8Buffer(256);for(e=0;e<g;e++)v[e]=e;var b=s.makeU8Buffer(y);for(e=0;e<y;e++){for(t=0;n.readBits(1);t++)t>=g&&p(f.DATA_ERROR);b[e]=l(v,t)}var w,k=d+2,S=[];for(t=0;t<g;t++){var _,E,C=s.makeU8Buffer(k),O=s.makeU16Buffer(21);for(a=n.readBits(5),e=0;e<k;e++){for(;(a<1||a>20)&&p(f.DATA_ERROR),n.readBits(1);)n.readBits(1)?a--:a++;C[e]=a}for(_=E=C[0],e=1;e<k;e++)C[e]>E?E=C[e]:C[e]<_&&(_=C[e]);w={},S.push(w),w.permute=s.makeU16Buffer(258),w.limit=s.makeU32Buffer(22),w.base=s.makeU32Buffer(21),w.minLen=_,w.maxLen=E;var x=0;for(e=_;e<=E;e++)for(O[e]=w.limit[e]=0,a=0;a<k;a++)C[a]===e&&(w.permute[x++]=a);for(e=0;e<k;e++)O[C[e]]++;for(x=a=0,e=_;e<E;e++)x+=O[e],w.limit[e]=x-1,x<<=1,a+=O[e],w.base[e+1]=x-a;w.limit[E+1]=Number.MAX_VALUE,w.limit[E]=x+O[E]-1,w.base[_]=0}var B=s.makeU32Buffer(256);for(e=0;e<256;e++)v[e]=e;var A,R=0,T=0,M=0,F=this.dbuf=s.makeU32Buffer(this.dbufSize);for(k=0;;){for(k--||(k=49,M>=y&&p(f.DATA_ERROR),w=S[b[M++]]),e=w.minLen,t=n.readBits(e);e>w.maxLen&&p(f.DATA_ERROR),!(t<=w.limit[e]);e++)t=t<<1|n.readBits(1);((t-=w.base[e])<0||t>=258)&&p(f.DATA_ERROR);var P=w.permute[t];if(0!==P&&1!==P){if(R)for(R=0,T+a>this.dbufSize&&p(f.DATA_ERROR),B[A=h[v[0]]]+=a;a--;)F[T++]=A;if(P>d)break;T>=this.dbufSize&&p(f.DATA_ERROR),B[A=h[A=l(v,e=P-1)]]++,F[T++]=A}else R||(R=1,a=0),a+=0===P?R:2*R,R<<=1}for((i<0||i>=T)&&p(f.DATA_ERROR),t=0,e=0;e<256;e++)r=t+B[e],B[e]=t,t=r;for(e=0;e<T;e++)F[B[A=255&F[e]]]|=e<<8,B[A]++;var I=0,L=0,N=0;return T&&(L=255&(I=F[i]),I>>=8,N=-1),this.writePos=I,this.writeCurrent=L,this.writeCount=T,this.writeRun=N,!0},m.prototype._read_bunzip=function(e,t){var r,n,o;if(this.writeCount<0)return 0;for(var i=this.dbuf,s=this.writePos,a=this.writeCurrent,c=this.writeCount,u=(this.outputsize,this.writeRun);c;){for(c--,n=a,a=255&(s=i[s]),s>>=8,3===u++?(r=a,o=n,a=-1):(r=1,o=a),this.blockCRC.updateCRCRun(o,r);r--;)this.outputStream.writeByte(o),this.nextoutput++;a!=n&&(u=0)}return this.writeCount=c,this.blockCRC.getCRC()!==this.targetBlockCRC&&p(f.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput},m.Err=f,m.decode=function(e,t,r){for(var n=s.coerceInputStream(e),o=s.coerceOutputStream(t,t),i=o.stream,a=new m(n,i);!("eof"in n)||!n.eof();)if(a._init_block())a._read_bunzip();else{var c=a.reader.readBits(32);if(c!==a.streamCRC&&p(f.DATA_ERROR,"Bad stream CRC (got "+a.streamCRC.toString(16)+" expected "+c.toString(16)+")"),!r||!("eof"in n)||n.eof())break;a._start_bunzip(n,i)}return o.retval},m.decodeBlock=function(e,t,r){var o=s.coerceInputStream(e),i=s.coerceOutputStream(r,r),a=i.stream,c=new m(o,a);return c.reader.seekBit(t),c._get_next_block()&&(c.blockCRC=new n,c.writeCopies=0,c._read_bunzip()),i.retval},m.table=function(e,t,r){var n=new i;n.delegate=s.coerceInputStream(e),n.pos=0,n.readByte=function(){return this.pos++,this.delegate.readByte()},n.tell=function(){return this.pos},n.delegate.eof&&(n.eof=n.delegate.eof.bind(n.delegate));var o=new i;o.pos=0,o.writeByte=function(){this.pos++};for(var a=new m(n,o),c=a.dbufSize;!("eof"in n)||!n.eof();){var u=a.reader.tellBit();if(a._init_block()){var h=o.pos;a._read_bunzip(),t(u,o.pos-h)}else{if(a.reader.readBits(32),!r||!("eof"in n)||n.eof())break;a._start_bunzip(n,o),console.assert(a.dbufSize===c,"shouldn't change block size within multistream file")}}};var g=function(e,t){var r,n=[];for(r=0;r<t;r++)n[r]=e[r]<<9|r;n.sort(function(e,t){return e-t});var i=n.map(function(e){return e>>>9});for(o.allocateHuffmanCodeLengths(i,20),this.codeLengths=s.makeU8Buffer(t),r=0;r<t;r++){var a=511&n[r];this.codeLengths[a]=i[r]}};g.prototype.computeCanonical=function(){var e,t=this.codeLengths.length,r=[];for(e=0;e<t;e++)r[e]=this.codeLengths[e]<<9|e;r.sort(function(e,t){return e-t}),this.code=s.makeU32Buffer(t);var n=0,o=0;for(e=0;e<t;e++){var i=r[e]>>>9,a=511&r[e];console.assert(o<=i),n<<=i-o,this.code[a]=n++,o=i}},g.prototype.cost=function(e,t,r){var n,o=0;for(n=0;n<r;n++)o+=this.codeLengths[e[t+n]];return o},g.prototype.emit=function(e){var t,r=this.codeLengths[0];for(e.writeBits(5,r),t=0;t<this.codeLengths.length;t++){var n,o,i=this.codeLengths[t];for(console.assert(i>0&&i<=20),r<i?(n=2,o=i-r):(n=3,o=r-i);o-- >0;)e.writeBits(2,n);e.writeBit(0),r=i}},g.prototype.encode=function(e,t){e.writeBits(this.codeLengths[t],this.code[t])};var y=function(e,t,r,n){for(var o=0,i=-1,s=0;o<r&&!(4===s&&(t[o++]=0,o>=r));){var a=e.readByte();if(a===h)break;if(n.updateCRC(a),a!==i)i=a,s=1;else if(++s>4){if(s<256){t[o-1]++;continue}s=1}t[o++]=a}return o},v=function(e,t,r){var n,o,i;for(n=0,i=0;n<r.length;n+=a){var s=Math.min(a,r.length-n),c=0,u=t[0].cost(r,n,s);for(o=1;o<t.length;o++){var h=t[o].cost(r,n,s);h<u&&(c=o,u=h)}e[i++]=c}},b=function(e,t,n){var o,i,c,u,h=s.makeU8Buffer(t),f=r.bwtransform2(e,h,t,256);n.writeBit(0),n.writeBits(24,f);var d=[],p=[];for(i=0;i<t;i++)d[o=e[i]]=!0,p[o>>>4]=!0;for(i=0;i<16;i++)n.writeBit(!!p[i]);for(i=0;i<16;i++)if(p[i])for(c=0;c<16;c++)n.writeBit(!!d[i<<4|c]);var m=0;for(i=0;i<256;i++)d[i]&&m++;var y=s.makeU16Buffer(t+1),b=m+1,w=[];for(i=0;i<=b;i++)w[i]=0;var k=s.makeU8Buffer(m);for(i=0,c=0;i<256;i++)d[i]&&(k[c++]=i);d=null,p=null;var S=0,_=0,E=function(e){y[S++]=e,w[e]++},C=function(){for(;0!==_;)1&_?(E(0),_-=1):(E(1),_-=2),_>>>=1};for(i=0;i<h.length;i++){for(o=h[i],c=0;c<m&&k[c]!==o;c++);console.assert(c!==m),l(k,c),0===c?_++:(C(),E(c+1),_=0)}C(),E(b),y=y.subarray(0,S);var O,x=[];for(O=S>=2400?6:S>=1200?5:S>=600?4:S>=200?3:2,x.push(new g(w,b+1)),i=0;i<=b;i++)w[i]=1;x.push(new g(w,b+1)),w=null;var B=s.makeU8Buffer(Math.ceil(S/a));for(function(e,t,r,n,o){for(var i,s,c,u=[];e.length<t;){for(v(n,e,r),i=0;i<e.length;i++)u[i]=0;for(i=0;i<n.length;i++)u[n[i]]++;var h=u.indexOf(Math.max.apply(Math,u)),l=[];for(i=0,s=0;i<n.length;i++)if(n[i]===h){var f=i*a,d=Math.min(f+a,r.length);l.push({index:i,cost:e[h].cost(r,f,d-f)})}for(l.sort(function(e,t){return e.cost-t.cost}),i=l.length>>>1;i<l.length;i++)n[l[i].index]=e.length;e.push(null);var p,m=[];for(i=0;i<e.length;i++)for(p=m[i]=[],s=0;s<o;s++)p[s]=0;for(i=0,s=0;i<r.length;)for(p=m[n[s++]],c=0;c<a&&i<r.length;c++)p[r[i++]]++;for(i=0;i<e.length;i++)e[i]=new g(m[i],o)}}(x,O,y,B,b+1),v(B,x,y),console.assert(x.length>=2&&x.length<=6),n.writeBits(3,x.length),n.writeBits(15,B.length),i=0;i<x.length;i++)k[i]=i;for(i=0;i<B.length;i++){var A=B[i];for(c=0;c<x.length&&k[c]!==A;c++);for(console.assert(c<x.length),l(k,c);c>0;c--)n.writeBit(1);n.writeBit(0)}for(i=0;i<x.length;i++)x[i].emit(n),x[i].computeCanonical();for(i=0,u=0;i<S;){var R=x[B[u++]];for(c=0;c<a&&i<S;c++)R.encode(n,y[i++])}},w=Object.create(null);return w.compressFile=function(e,r,o){e=s.coerceInputStream(e);var i=s.coerceOutputStream(r,r);r=new t(i.stream);var a=9;if("number"==typeof o&&(a=o),a<1||a>9)throw new Error("Invalid block size multiplier");var h=1e5*a;h-=19,r.writeByte("B".charCodeAt(0)),r.writeByte("Z".charCodeAt(0)),r.writeByte("h".charCodeAt(0)),r.writeByte("0".charCodeAt(0)+a);var l,f=s.makeU8Buffer(h),d=0;do{var p=new n;(l=y(e,f,h,p))>0&&(d=((d<<1|d>>>31)^p.getCRC())>>>0,r.writeBits(48,c),r.writeBits(32,p.getCRC()),b(f,l,r))}while(l===h);return r.writeBits(48,u),r.writeBits(32,d),r.flush(),i.retval},w.decompressFile=m.decode,w.decompressBlock=m.decodeBlock,w.table=m.table,w}(r(6956),r(8196),r(9010),r(4064),r(8197),r(3403),r(6015))},4064(e,t,r){var n,o;e.exports=(n=r(6015),o=n.arraycopy(n.makeU32Buffer(256),[0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,1461550545,1406951526,1302016099,1230646740,1142491917,1087903418,2896545431,2825181984,2770861561,2716262478,3215044683,3143675388,3055782693,3001194130,2326604591,2389456536,2200899649,2280525302,2578013683,2640855108,2418763421,2498394922,3769900519,3832873040,3912640137,3992402750,4088425275,4151408268,4197601365,4277358050,3334271071,3263032808,3476998961,3422541446,3585640067,3514407732,3694837229,3640369242,1762451694,1842216281,1619975040,1682949687,2047383090,2127137669,1938468188,2001449195,1325665622,1271206113,1183200824,1111960463,1543535498,1489069629,1434599652,1363369299,622672798,568075817,748617968,677256519,907627842,853037301,1067152940,995781531,51762726,131386257,177728840,240578815,269590778,349224269,429104020,491947555,4046411278,4126034873,4172115296,4234965207,3794477266,3874110821,3953728444,4016571915,3609705398,3555108353,3735388376,3664026991,3290680682,3236090077,3449943556,3378572211,3174993278,3120533705,3032266256,2961025959,2923101090,2868635157,2813903052,2742672763,2604032198,2683796849,2461293480,2524268063,2284983834,2364738477,2175806836,2238787779,1569362073,1498123566,1409854455,1355396672,1317987909,1246755826,1192025387,1137557660,2072149281,2135122070,1912620623,1992383480,1753615357,1816598090,1627664531,1707420964,295390185,358241886,404320391,483945776,43990325,106832002,186451547,266083308,932423249,861060070,1041341759,986742920,613929101,542559546,756411363,701822548,3316196985,3244833742,3425377559,3370778784,3601682597,3530312978,3744426955,3689838204,3819031489,3881883254,3928223919,4007849240,4037393693,4100235434,4180117107,4259748804,2310601993,2373574846,2151335527,2231098320,2596047829,2659030626,2470359227,2550115596,2947551409,2876312838,2788305887,2733848168,3165939309,3094707162,3040238851,2985771188]),function(){var e=4294967295;this.getCRC=function(){return~e>>>0},this.updateCRC=function(t){e=e<<8^o[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^o[255&(e>>>24^t)]}})},4820(e,t,r){var n,o,i,s;e.exports=(n=r(8196),o=r(886),i=r(6015),(s=function(e,t,r){var n;for(this.literalModel=[],n=0;n<t;n++)this.literalModel[n]=e(r)}).prototype.encode=function(e,t){this.literalModel[t].encode(e)},s.prototype.decode=function(e){return this.literalModel[e].decode()},s.MAGIC="ctx1",s.compressFile=i.compressFileHelper(s.MAGIC,function(e,t,r,a){var c=new n(t),u=256;r<0&&u++;var h=o.factory(c,8191),l=new s(h,256,u),f=32,d={encode:function(e){l.encode(e,f),f=e}};i.compressWithModel(e,r,d),c.flush()}),s.decompressFile=i.decompressFileHelper(s.MAGIC,function(e,t,r){var a=new n(e),c=256;r<0&&c++;var u=o.factory(a,8191),h=new s(u,256,c),l=32,f={decode:function(){var e=h.decode(l);return l=e,e}};i.decompressWithModel(t,r,f)}),s)},936(e,t,r){var n,o,i,s;e.exports=(n=r(1249),r(3403),o=r(6015),i=256,(s=function(e,t,r){var n;console.assert(t<300);var s=this.numSyms=t;for(this.coder=e,this.prob=o.makeU16Buffer(t+2),this.escape=o.makeU16Buffer(t+1),this.update=o.makeU16Buffer(t+1),this.prob[s+1]=i,n=0;n<=this.numSyms;n++)this.escape[n]=n;if(this.updateCount=0,this.updateThresh=i-Math.floor(128),r){for(this.probToSym=o.makeU16Buffer(i),this.escProbToSym=o.makeU16Buffer(this.numSyms),n=0;n<i;n++)this.probToSym[n]=s;for(n=0;n<this.numSyms;n++)this.escProbToSym[n]=n}}).factory=function(e,t){return function(r){return new s(e,r,t)}},s.prototype._update=function(e,t){if(e===this.numSyms){if(this.update[e]>=40)return;if(this.updateCount>=this.updateThresh-1)return}if(this.update[e]++,this.updateCount++,!(this.updateCount<this.updateThresh)){var r,n,o,s,a,c;for(this.escape[0]=this.prob[0]=r=n=o=0,s=0;s<this.numSyms+1;s++){var u=(this.prob[s+1]-this.prob[s]>>>1)+this.update[s];u?(this.prob[s]=r,r+=u,1&u&&o++,this.escape[s]=n):(this.prob[s]=r,this.escape[s]=n,n++)}for(this.prob[s]=r,console.assert(r===i),this.updateThresh=i-Math.floor((r-o)/2),s=0;s<this.numSyms+1;s++)this.update[s]=0;if(this.update[this.numSyms]=1,this.updateCount=1,t)for(s=0,a=0,c=0;s<this.numSyms+1;s++){for(var h=this.prob[s+1];a<h;a++)this.probToSym[a]=s;for(var l=this.escape[s+1];c<l;c++)this.escProbToSym[c]=s}}},s.prototype.encode=function(e){var t=this.prob[e],r=this.prob[e+1]-t;if(console.assert(this.prob[this.numSyms+1]===i),r)return this.coder.encodeShift(r,t,8),this._update(e);console.assert(e!==this.numSyms),this.encode(this.numSyms),t=this.escape[e],r=this.escape[e+1]-t;var n=this.escape[this.numSyms];return this.coder.encodeFreq(r,t,n),this._update(e)},s.prototype.decode=function(){var e=this.coder.decodeCulShift(8),t=this.probToSym[e],r=this.prob[t],n=this.prob[t+1]-r;if(this.coder.decodeUpdate(n,r,i),this._update(t,!0),t!==this.numSyms)return t;var o=this.escape[this.numSyms];return e=this.coder.decodeCulFreq(o),t=this.escProbToSym[e],r=this.escape[t],n=this.escape[t+1]-r,this.coder.decodeUpdate(n,r,o),this._update(t,!0),t},s.MAGIC="dfsm",s.compressFile=o.compressFileHelper(s.MAGIC,function(e,t,r,i,a){var c=new n(t);c.encodeStart(a,1);var u=new s(c,r<0?257:256);o.compressWithModel(e,r,u),c.encodeFinish()},!0),s.decompressFile=o.decompressFileHelper(s.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var a=new s(i,r<0?257:256,!0);o.decompressWithModel(t,r,a),i.decodeFinish()}),s)},2139(e,t,r){e.exports=function(e,t,r,n){var o=Object.create(null);o.MAGIC="dmc!";var i=function(t,r,o){this.out=[],this.model=o?o.clone():new e(t,r,65280,256),this.count=n.makeU16Buffer(r),this.sum=0};i.prototype.clone=function(e,t){var r,n=new i(e,t,null);for(r=0;r<t;r++)n.out[r]=this.out[r];return n};var s=function(e,t,r,n){var o,s;for(this.coder=e,this.size=t,this.MIN_CNT1=r||8,this.MIN_CNT2=n||128,this.nodes=[],o=0;o<t;o++)this.nodes[o]=new i(e,t);for(o=0;o<t;o++)for(s=0;s<t;s++)this.nodes[o].out[s]=this.nodes[s];this.current=this.nodes[0]};return s.prototype.maybeSplit=function(e,t,r){var n,o=e.count[t],i=r.sum;if(o<=this.MIN_CNT1||i-o<=this.MIN_CNT2)return r;var s=r.clone(this.coder,this.size);for(this.nodes.push(s),e.out[t]=s,s.sum=r.sum=0,n=0;n<this.size;n++)s.count[n]=r.count[n]*o/i,s.sum+=s.count[n],r.count[n]-=s.count[n],r.sum+=r.count[n];return s},s.prototype.encode=function(e){var t=this.current;t.model.encode(e);var r=t.out[e];65535!==t.count[e]&&(t.count[e]++,t.sum++),this.current=this.maybeSplit(t,e,r)},s.prototype.decode=function(){var e=this.current,t=e.model.decode(),r=e.out[t];return 65535!==e.count[t]&&(e.count[t]++,e.sum++),this.current=this.maybeSplit(e,t,r),t},o.compressFile=n.compressFileHelper(o.MAGIC,function(e,o,i,a){var c=+(a=a||{}).m||8,u=+a.n||128;n.writeUnsignedNumber(o,c),n.writeUnsignedNumber(o,u);var h=new t(o);h.encodeStart(202,0);for(var l=new s(h,i<0?257:256,c,u),f=0;f!==i;){var d=e.readByte();if(d===r.EOF){l.encode(256);break}l.encode(d),f++}h.encodeFinish()}),o.decompressFile=n.decompressFileHelper(o.MAGIC,function(e,r,o){var i=n.readUnsignedNumber(e),a=n.readUnsignedNumber(e),c=new t(e);c.decodeStart();for(var u=new s(c,o<0?257:256,i,a),h=0;h!==o;){var l=u.decode();if(256===l)break;r.writeByte(l),h++}c.decodeFinish()}),o}(r(417),r(1249),r(3403),r(6015))},5623(e,t,r){var n,o,i,s,a,c,u;e.exports=(n=r(1249),r(3403),o=r(6015),i=65535,s=4294901760,a=16,c=4294901758,(u=function(e,t,r,n){var i;for(this.coder=e,this.numSyms=t+1,this.tree=o.makeU32Buffer(2*this.numSyms),this.increment=+n||256,this.max_prob=+r||65280,console.assert(this.max_prob+(this.increment-1)<=65535),console.assert(t<=65535),i=0;i<t;i++)this.tree[this.numSyms+i]=1;this.tree[this.numSyms+i]=0|this.increment<<a,this._sumTree()}).factory=function(e,t,r){return function(n){return new u(e,n,t,r)}},u.prototype.clone=function(){var e,t=new u(this.coder,this.size,this.max_prob,this.increment);for(e=1;e<this.tree.length;e++)t.tree[e]=this.tree[e];return t},u.prototype.encode=function(e){var t=this.numSyms+e,r=this.tree[t],n=s,o=a,c=this.increment<<a;0===(r&s)?(this.encode(this.numSyms-1),n=i,c-=1,o=0):e===this.numSyms-1&&(this.tree[1]&i)>>>0==1&&(c=-this.tree[t]);for(var u=0;t>1;){var h=t>>>1;1&t&&(u+=this.tree[2*h]),this.tree[t]+=c,t=h}var l=this.tree[1];this.tree[1]+=c,r=(r&n)>>>o,u=(u&n)>>>o,l=(l&n)>>>o,this.coder.encodeFreq(r,u,l),(this.tree[1]&s)>>>a>=this.max_prob&&this._rescale()},u.prototype._decode=function(e){var t=s,r=a,n=this.increment<<a;e&&(t=i,n-=1,r=0);for(var o=(this.tree[1]&t)>>>r,c=this.coder.decodeCulFreq(o),u=1,h=0;u<this.numSyms;){this.tree[u]+=n;var l=(this.tree[2*u]&t)>>>r;u*=2,c-h>=l&&(h+=l,u++)}var f=u-this.numSyms,d=(this.tree[u]&t)>>>r;if(this.tree[u]+=n,this.coder.decodeUpdate(d,h,o),f===this.numSyms-1&&(this.tree[1]&i)>>>0==1)for(n=-this.tree[u];u>=1;)this.tree[u]+=n,u>>>=1;return(this.tree[1]&s)>>>a>=this.max_prob&&this._rescale(),f},u.prototype.decode=function(){var e=this._decode(!1);return e===this.numSyms-1&&(e=this._decode(!0)),e},u.prototype._rescale=function(){var e,t,r=!0;for(e=0;e<this.numSyms-1;e++)0===((t=this.tree[this.numSyms+e])&i)?(0==(t=(t&c)>>>1)&&(t=1,r=!1),this.tree[this.numSyms+e]=t):r=!1;t=((t=this.tree[this.numSyms+e])&c)>>>1,r?t=0:0===t&&(t=65536),this.tree[this.numSyms+e]=t,this._sumTree()},u.prototype._sumTree=function(){var e;for(e=this.numSyms-1;e>0;e--)this.tree[e]=this.tree[2*e]+this.tree[2*e+1]},u.MAGIC="fenw",u.compressFile=o.compressFileHelper(u.MAGIC,function(e,t,r,i,s){var a=new n(t);a.encodeStart(s,1);var c=new u(a,r<0?257:256);o.compressWithModel(e,r,c),a.encodeFinish()},!0),u.decompressFile=o.decompressFileHelper(u.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var s=new u(i,r<0?257:256);o.decompressWithModel(t,r,s),i.decodeFinish()}),u)},886(e,t,r){e.exports=function(e,t){var r=function(e,t,r,n){this.up=e,this.down=t,this.symbol=r,this.weight=n};r.prototype.clone=function(){return new r(this.up,this.down,this.symbol,this.weight)},r.prototype.set=function(e){this.up=e.up,this.down=e.down,this.symbol=e.symbol,this.weight=e.weight};var n=function(e,t,n,o){var i;for(console.assert(e&&"number"==typeof e),(!t||t>e)&&(t=e),(t<<=1)&&t--,this.table=[],i=0;i<=t;i++)this.table[i]=new r(0,0,0,0);if(this.map=[],this.size=e)for(i=0;i<e;i++)this.map[i]=0;this.esc=this.root=t,n&&(this.readBit=n.readBit.bind(n),this.writeBit=n.writeBit.bind(n)),this.max_weight=o};return n.factory=function(e,t){return function(r){return new n(r,r,e,t)}},n.prototype.split=function(e){var t,r;return(t=this.esc)?(this.esc--,(r=this.esc)?(this.table[t].down=r,this.table[t].weight=1,this.table[r].up=t,this.esc--):(t=0,r=1),this.table[r].symbol=e,this.table[r].weight=0,this.table[r].down=0,this.map[e]=r,this.table[this.esc].weight=0,this.table[this.esc].down=0,this.table[this.esc].up=t,r):(console.assert(!1),0)},n.prototype.leader=function(e){for(var t,r,n=this.table[e].weight,o=e;n===this.table[o+1].weight;)o++;return o===e?e:(r=this.table[e].symbol,t=this.table[o].symbol,this.table[o].symbol=r,this.table[e].symbol=t,this.map[r]=o,this.map[t]=e,o)},n.prototype.slide=function(e){var t,r=e;if(1&(t=this.table[r++].clone()).weight)for(;t.weight>this.table[r+1].weight;)r++;return this.table[e].set(this.table[r]),this.table[r].set(t),this.table[r].up=this.table[e].up,this.table[e].up=t.up,1&t.weight?(this.table[t.down].up=r,this.table[t.down-1].up=r,this.map[this.table[e].symbol]=e):(this.table[this.table[e].down-1].up=e,this.table[this.table[e].down].up=e,this.map[t.symbol]=r),r},n.prototype.increment=function(e){var t;for(this.table[e].up===e+1?(this.table[e].weight+=2,e++):e=this.leader(e);this.table[e].weight+=2,t=this.table[e].up;){for(;this.table[e].weight>this.table[e+1].weight;)e=this.slide(e);e=1&this.table[e].weight?t:this.table[e].up}this.max_weight&&this.table[this.root].weight>=this.max_weight&&this.scale(1)},n.prototype.scale=function(e){for(var t,r,n=this.esc;++n<=this.root;)for(1&this.table[n].weight?(t=-2&this.table[this.table[n].down].weight)&&(t+=1|this.table[this.table[n].down-1].weight):(t=this.table[n].weight>>e&-2)||(this.map[this.table[n].symbol]=0,this.esc++&&this.esc++),this.table[n].weight=t,r=n;t<this.table[--r].weight;)this.slide(r);this.table[this.esc].down=0},n.prototype.sendid=function(e){for(var t,r=0;e--;)this.map[e]||r++;if(t=this.size-Math.floor((this.root-this.esc)/2)-1)do{this.writeBit(1&r),r>>=1}while(t>>=1)},n.prototype.encode=function(e){var t,r,n,o,i=1;if(e<this.size){if((n=o=this.map[e])||(n=this.esc)){for(;r=this.table[n].up;)i<<=1,i|=1&n,n=r;for(;t=1&i,i>>=1;)this.writeBit(t);o||(this.sendid(e),o=this.split(e)),this.increment(o)}}else console.assert(!1)},n.prototype.readid=function(){var e,t,r=0,n=1;if(e=this.size-Math.floor((this.root-this.esc)/2)-1)do{r|=this.readBit()?n:0,n<<=1}while(e>>=1);for(t=0;t<this.size;t++)if(!this.map[t]&&!r--)return t;return console.assert(!1),0},n.prototype.decode=function(){for(var e,t,r=this.root;t=this.table[r].down;)r=this.readBit()?t-1:t;if(r===this.esc){if(!this.esc)return console.assert(!1),0;e=this.readid(),r=this.split(e)}else e=this.table[r].symbol;return this.increment(r),e},n.MAGIC="huff",n.compressFile=t.compressFileHelper(n.MAGIC,function(r,o,i,s){var a=new e(o),c=256;i<0&&c++;var u=new n(257,c,a,8191);t.compressWithModel(r,i,u),a.flush()}),n.decompressFile=t.decompressFileHelper(n.MAGIC,function(r,o,i){var s=new e(r),a=256;i<0&&a++;var c=new n(257,a,s,8191);t.decompressWithModel(o,i,c)}),n}(r(8196),r(6015))},8197(e,t,r){var n,o,i;e.exports=(n=r(6956),o=r(6015),i=function(e,t,r){for(var n=e.length,o=t,i=e.length-2;t>=r&&e[t]%n>o;)i=t,t-=o-t+1;for(t=Math.max(r-1,t);i>t+1;){var s=t+i>>1;e[s]%n>o?i=s:t=s}return i},n({allocateHuffmanCodeLengths:function(e,t){switch(e.length){case 2:e[1]=1;case 1:return void(e[0]=1)}!function(e){var t,r,n,o,i=e.length;for(e[0]+=e[1],t=0,r=1,n=2;r<i-1;r++)n>=i||e[t]<e[n]?(o=e[t],e[t++]=r):o=e[n++],n>=i||t<r&&e[t]<e[n]?(o+=e[t],e[t++]=r+i):o+=e[n++],e[r]=o}(e);var r=function(e,t){var r,n=e.length-2;for(r=1;r<t-1&&n>1;r++)n=i(e,n-1,0);return n}(e,t);e[0]%e.length>=r?function(e){var t,r,n,o,s=e.length-2,a=e.length-1;for(t=1,r=2;r>0;t++){for(o=r-((n=s)-(s=i(e,n-1,0)));o>0;o--)e[a--]=t;r=n-s<<1}}(e):function(e,t,r){var n,o,s,a,c=e.length-2,u=e.length-1,h=1==r?2:1,l=1==r?t-2:t;for(n=h<<1;n>0;h++){for(o=c,c=c<=t?c:i(e,o-1,t),s=0,h>=r?s=Math.min(l,1<<h-r):h==r-1&&(s=1,e[c]==o&&c++),a=n-(o-c+s);a>0;a--)e[u--]=h;l-=s,n=o-c+s<<1}}(e,r,t-o.fls(r-1))}}))},9461(e,t,r){var n,o;e.exports=(n=r(6015),(o=function(e,t,r,o){var i,s=n.fls(e-1);for(this.extraStates=+t||0,this.lgDistanceModel=r(1+s+t),this.distanceModel=[],i=2;i<=s;i++){var a=i-1;this.distanceModel[i]=o(1<<a)}}).prototype.encode=function(e){if(e<2)this.lgDistanceModel.encode(e+this.extraStates);else{var t=n.fls(e);console.assert(e&1<<t-1),console.assert(t>=2),this.lgDistanceModel.encode(t+this.extraStates);var r=e&(1<<t-1)-1;this.distanceModel[t].encode(r)}},o.prototype.decode=function(){var e=this.lgDistanceModel.decode()-this.extraStates;return e<2?e:(1<<e-1)+this.distanceModel[e].decode()},o)},4845(e,t,r){e.exports=function(e,t){var r=Object.create(null);r.MAGIC="lzjb";var n=1023,o=e.EOF;return r.compressFile=t.compressFileHelper(r.MAGIC,function(e,r,i,s){var a,c,u,h,l,f,d,p=1024,m=1;"number"==typeof s&&(p*=2,s=Math.max(1,Math.min(9,s))-1,m=1<<Math.floor(s/2),1&s&&(m=Math.round(1.5*m)),s>=2&&s<=4&&m++),f=t.makeU16Buffer(p*m);for(var g=t.makeU8Buffer(1024),y=0,v=function(e){return g[y++]=e,y>=g.length&&(y=0),e},b=t.makeU8Buffer(17),w=0,k=function(){var e;for(e=0;e<w;e++)r.writeByte(b[e]);w=0},S=[],_=function(){return S.length?S.pop():e.readByte()},E=function(e){S.push(e)},C=128,O=[];;){var x=_();if(x===o)break;256==(C<<=1)&&(k(),C=1,b[0]=0,w=1);var B=_();if(B===o){b[w++]=v(x);break}var A=_();if(A!==o){for(h=(x<<16)+(B<<8)+A,h^=h>>9,h+=h>>5,l=((h^=x)&p-1)*m,O.length=0,d=0;d<m;d++){u=y-f[l+d]&n,a=g.length+y-u;var R=g[a&n],T=g[a+1&n],M=g[a+2&n];0===u?R=1^x:1==u?(T=x,M=B):2==u&&(M=x),x===R&&B===T&&A===M&&O.push(u)}for(d=m-1;d>0;d--)f[l+d]=f[l+d-1];if(f[l]=y,0===O.length)b[w++]=v(x),E(A),E(B);else{b[0]|=C,v(x),v(B),v(A);var F=_(),P=O[0],I=g.length+y;for(c=3;c<66&&F!==o;c++,I++){for(d=0;d<O.length;)F!==g[I-O[d]&n]?(P=O[d],O.splice(d,1)):d++;if(0===O.length)break;v(F),F=_()}0!==O.length&&(P=O[0]),E(F),b[w++]=c-3<<2|P>>8,b[w++]=255&P}}else b[w++]=v(x),E(B)}k()}),r.decompressFile=t.decompressFileHelper(r.MAGIC,function(e,r,i){for(var s,a,c,u,h=t.makeU8Buffer(1024),l=0,f=128;0!==i&&(u=e.readByte())!==o;)if(256==(f<<=1)&&(f=1,a=u,u=e.readByte()),a&f)for(c=3+(u>>2),(s=l-((u<<8|e.readByte())&n))<0&&(s+=h.length),i>=0&&(i-=c);--c>=0;)u=h[l++]=h[s++],r.writeByte(u),l>=h.length&&(l=0),s>=h.length&&(s=0);else r.writeByte(u),h[l++]=u,l>=h.length&&(l=0),i>=0&&i--}),r}(r(3403),r(6015))},6831(e,t,r){e.exports=function(e,t,r,n,o,i,s){var a=Object.create(null);a.MAGIC="lzjR";var c=1023;return a.compressFile=s.compressFileHelper(a.MAGIC,function(a,u,h,l,f){var d,p,m,g,y,v,b,w=1024,k=1;"number"==typeof l&&(w*=2,l=Math.max(1,Math.min(9,l))-1,k=1<<Math.floor(l/2),1&l&&(k=Math.round(1.5*k)),l>=2&&l<=4&&k++);var S=new o(u);S.encodeStart(f,1),v=s.makeU16Buffer(w*k);for(var _=s.makeU8Buffer(1024),E=0,C=function(e){return _[E++]=e,E>=_.length&&(E=0),e},O=[],x=function(){return O.length?O.pop():a.readByte()},B=function(e){O.push(e)},A=[],R=n.factory(S),T=t.factory(S,65280,256),M=new e(T,256,1+(h<0?257:256)),F=function(e){return e<=32?T(e):R(e)},P=new r(64,0,T,F),I=new r(1024,1,T,F),L=32,N=0;;){var D=E,j=x();if(j===i.EOF)break;var U=x();if(U===i.EOF){M.encode(C(j),L);break}var q=x();if(q!==i.EOF){for(g=(j<<16)+(U<<8)+q,g^=g>>9,g+=g>>5,y=((g^=j)&w-1)*k,A.length=0,b=0;b<k;b++){m=E-v[y+b]&c,d=_.length+E-m;var z=_[d&c],$=_[d+1&c],H=_[d+2&c];1==m?($=j,H=U):2==m&&(H=j),j===z&&U===$&&q===H&&A.push(m)}for(b=k-1;b>0;b--)v[y+b]=v[y+b-1];if(v[y]=E,0===A.length)M.encode(C(j),L),B(q),B(U),L=j;else{M.encode(256,L),C(j),C(U),C(q),L=q;var G=x(),W=A[0],V=_.length+E;for(p=3;p<66&&G!==i.EOF;p++,V++){for(b=0;b<A.length;)G!==_[V-A[b]&c]?(W=A[b],A.splice(b,1)):b++;if(0===A.length)break;C(G),L=G,G=x()}0!==A.length&&(W=A[0]),B(G),P.encode(p-3),(m=D-W&c)===N?I.encode(-1):(I.encode(m),N=m)}}else M.encode(C(j),L),B(U),L=j}h<0&&M.encode(257,L),S.encodeFinish()},!0),a.decompressFile=s.decompressFileHelper(a.MAGIC,function(i,a,c){var u,h,l,f=s.makeU8Buffer(1024),d=0,p=new o(i);p.decodeStart(!0);for(var m=n.factory(p),g=t.factory(p,65280,256),y=new e(g,256,1+(c<0?257:256)),v=function(e){return e<=32?g(e):m(e)},b=new r(64,0,g,v),w=new r(1024,1,g,v),k=32,S=0;0!==c&&257!==(l=y.decode(k));)if(256===l)for(h=b.decode()+3,(u=w.decode())<0?u=S:S=u,c>=0&&(c-=h);--h>=0;)l=k=f[d++]=f[u++],a.writeByte(l),d>=f.length&&(d=0),u>=f.length&&(u=0);else a.writeByte(l),f[d++]=k=l,d>=f.length&&(d=0),c>=0&&c--;p.decodeFinish()}),a}(r(4820),r(5623),r(9461),r(1679),r(1249),r(3403),r(6015))},4416(e,t,r){e.exports=function(e,t,r,n,o,i,s,a,c,u){var h=Object.create(null);h.MAGIC="lzp3";var l=1<<20,f=65535,d=function(e){this.buffer=u.makeU8Buffer(Math.min(e+4,l)),this.pos=0,this.ctxt4=u.makeU32Buffer(65536),this.ctxt3=u.makeU32Buffer(4096),this.ctxt2=u.makeU32Buffer(65536),this.put(99),this.put(83),this.put(97),this.put(32)};return d.prototype.put=function(e){return this.buffer[this.pos++]=e,this.pos>=l&&(this.pos=0),e},d.prototype.get=function(e){return this.buffer[1048575&e]},d.prototype.context=function(e,t){var r,n=0;for(e=e-t&1048575,r=0;r<t;r++)n=n<<8|this.buffer[e++],e>=l&&(e=0);return n},d.prototype.getIndex=function(e,t){var r=this.context(e,4),n=65535&(r>>>15^r),o=4095&(r>>>11^r),i=r&f,s=0;return 0===t&&(0!==(s=this.ctxt4[n])&&r!==this.context(s-1,4)&&(s=0),0===s&&(0!==(s=this.ctxt3[o])&&(16777215&r)!==this.context(s-1,3)&&(s=0),0===s&&0!==(s=this.ctxt2[i])&&(r&&f)!==this.context(s-1,2)&&(s=0))),t&&t--,this.ctxt4[n]=this.ctxt3[o]=this.ctxt2[i]=1+(e|t<<20),s},h.compressFile=u.compressFileHelper(h.MAGIC,function(e,r,o,u){var h,f,p,m=new d(o>=0?o:l),g=new a(r);g.encodeStart(0,0),h=n.factory(g,65280,256);var y=s.factory(g);f=function(e){return e>256?y(e):h(e)},p=function(){g.encodeFinish()};var v,b=new t(h,256,o<0?257:256),w=[];for(v=0;v<16;v++)w[v]=new i(1048576,1,h,f);for(var k,S=0,_=0;S!==o;){var E=e.readByte();k=m.pos;var C=m.getIndex(k,0);if(0!==C){for(var O=(--C>>>20)+1,x=0;m.get(C+x)===E&&x<1048575;)x++,m.put(E),E=e.readByte();O===x?w[15&_].encode(-1):w[15&_].encode(x),m.getIndex(k,x),S+=x,_<<=1,x>0&&(_|=1)}var B=m.get(m.pos-1);if(E===c.EOF){o<0&&b.encode(256,B);break}b.encode(E,B),m.put(E),S++}p&&p()}),h.decompressFile=u.decompressFileHelper(h.MAGIC,function(r,c,u){var h,p,m,g=!!(128&r.readByte()),y=new d(u>=0?u:l);if(g){var v=new e(r);h=o.factory(v,f),p=s.factory(v)}else{var b=new a(r);b.decodeStart(!0),h=n.factory(b,65280,256);var w=s.factory(b);p=function(e){return e>256?w(e):h(e)},m=function(){b.decodeFinish()}}var k,S=new t(h,256,u<0?257:256),_=[];for(k=0;k<16;k++)_[k]=new i(1048576,1,h,p);for(var E,C,O=0,x=0;O!==u;){E=y.pos;var B=y.getIndex(E,0);if(0!==B){var A=(--B>>>20)+1,R=_[15&x].decode();for(R<0&&(R=A),k=0;k<R;k++)C=y.get(B+k),c.writeByte(y.put(C));y.getIndex(E,R),O+=R,x<<=1,R>0&&(x|=1)}if(O===u)break;var T=y.get(y.pos-1);if(256===(C=S.decode(T)))break;c.writeByte(y.put(C)),O++}m&&m()}),h}(r(8196),r(4820),r(936),r(5623),r(886),r(9461),r(1679),r(1249),r(3403),r(6015))},417(e,t,r){var n,o,i,s;e.exports=(n=r(1249),r(3403),o=r(6015),i=function(e,t){return e-t},(s=function(e,t,r,n,i){this.coder=e,this.increment=+n||256,this.max_prob=+r||65280,console.assert(this.max_prob+(this.increment-1)<=65535),this.sym=o.makeU16Buffer(t+1),this.prob=o.makeU16Buffer(t+2),this.sym[0]=t,this.prob[0]=0,this.seenSyms=1,this.prob[this.seenSyms]=this.increment,this.numSyms=t,i&&(this.sortedSeen=[t])}).factory=function(e,t,r,n){return function(o){return new s(e,o,t,r,n)}},s.prototype.clone=function(){var e,t=new s(this.coder,this.numSyms,this.max_prob,this.increment,!!this.sortedSeen);for(e=0;e<this.seenSyms;e++)t.sym[e]=this.sym[e],t.prob[e]=this.prob[e];return t.prob[e]=this.prob[e],t.seenSyms=this.seenSyms,this.sortedSeen&&(t.sortedSeen=this.sortedSeen.slice(0)),t},s.prototype._update=function(e,t,r){var n,o;for(n=t;n<this.seenSyms-1;n++)this.sym[n]=this.sym[n+1],this.prob[n]=this.prob[n+1]-r;t<this.seenSyms?(this.sym[n]=e,this.prob[n]=this.prob[n+1]-r,this.prob[this.seenSyms]=o=this.prob[this.seenSyms]+this.increment,e===this.numSyms&&this.seenSyms>=this.numSyms&&(o=this.prob[--this.seenSyms],this.sortedSeen&&this.sortedSeen.length--)):(o=this.prob[this.seenSyms],this.sym[t]=e,this.prob[t]=o,o+=this.increment,this.prob[++this.seenSyms]=o,this.sortedSeen&&(this.sortedSeen.push(e),this.sortedSeen.sort(i))),o>=this.max_prob&&this._rescale()},s.prototype._rescale=function(){var e,t,r=0,n=!0;for(this.sortedSeen&&(this.sortedSeen.length=0),e=0,t=0;e<this.seenSyms;e++){var o=this.sym[e],s=this.prob[e+1]-this.prob[e];(s>>>=1)>0&&(o===this.numSyms&&(n=!1),this.sym[t]=o,this.prob[t++]=r,r+=s,this.sortedSeen&&this.sortedSeen.push(o))}this.prob[t]=r,this.seenSyms=t,this.sortedSeen&&this.sortedSeen.sort(i),n&&this.seenSyms<this.numSyms&&this._update(this.numSyms,this.seenSyms)},s.prototype.decode=function(){var e,t=this.prob[this.seenSyms],r=this.coder.decodeCulFreq(t);for(e=this.seenSyms-1;e>=0&&!(this.prob[e]<=r);e--);console.assert(e>=0);var n=this.sym[e],o=this.prob[e],i=this.prob[e+1]-o;if(this.coder.decodeUpdate(i,o,t),this._update(n,e,i),n===this.numSyms){if(i=1,t=this.numSyms,this.sortedSeen){var s=this.sortedSeen;for(t=this.numSyms-this.seenSyms,s[s.length-1]===this.numSyms&&t++,n=o=this.coder.decodeCulFreq(t),e=0;e<s.length&&s[e]<=n;e++)n++}else n=o=this.coder.decodeCulFreq(t);this.coder.decodeUpdate(i,o,t),this._update(n,this.seenSyms)}return n},s.prototype.encode=function(e){var t,r,n,o;for(t=this.seenSyms-1;t>=0;t--)if(e===this.sym[t])return n=this.prob[t],r=this.prob[t+1]-n,o=this.prob[this.seenSyms],this.coder.encodeFreq(r,n,o),this._update(e,t,r);if(console.assert(e!==this.numSyms),this.encode(this.numSyms),r=1,n=e,o=this.numSyms,this.sortedSeen){var i=this.sortedSeen;for(o-=this.seenSyms,i[i.length-1]===this.numSyms&&o++,t=0;t<i.length&&i[t]<e;t++)n--}return this.coder.encodeFreq(r,n,o),this._update(e,this.seenSyms)},s.MAGIC="mtfm",s.compressFile=o.compressFileHelper(s.MAGIC,function(e,t,r,i,a){var c=new n(t);c.encodeStart(a,1);var u=new s(c,r<0?257:256);o.compressWithModel(e,r,u),c.encodeFinish()},!0),s.decompressFile=o.decompressFileHelper(s.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var a=new s(i,r<0?257:256);o.decompressWithModel(t,r,a),i.decodeFinish()}),s)},1679(e,t,r){var n,o,i;e.exports=(n=r(8196),o=r(6015),(i=function(e,t){this.bitstream=e,this.bits=o.fls(t-1)}).factory=function(e){return function(t){return new i(e,t)}},i.prototype.encode=function(e){var t;for(t=this.bits-1;t>=0;t--){var r=e>>>t&1;this.bitstream.writeBit(r)}},i.prototype.decode=function(){var e,t=0;for(e=this.bits-1;e>=0;e--)t<<=1,this.bitstream.readBit()&&t++;return t},i.MAGIC="nomo",i.compressFile=o.compressFileHelper(i.MAGIC,function(e,t,r,s){var a=new n(t),c=new i(a,r<0?257:256);o.compressWithModel(e,r,c),a.flush()}),i.decompressFile=o.decompressFileHelper(i.MAGIC,function(e,t,r){var s=new n(e),a=new i(s,r<0?257:256);o.decompressWithModel(t,r,a)}),i)},736(e,t,r){e.exports=function(e,t){var r=1<<18,n=function(){this.buffer=t.makeU8Buffer(r),this.pos=0,this.firstPass=!0;for(var e=0;e<5;e++)this.put("cSaCsA".charCodeAt(e%6))};n.prototype.put=function(e){return this.buffer[this.pos++]=e,this.pos>=r&&(this.pos=0,this.firstPass=!1),e},n.prototype.get=function(e){return this.buffer[262143&e]},n.prototype.context=function(e,t){var n,o=[];for(e=e-t&262143,n=0;n<t;n++)o.push(this.buffer[e++]),e>=r&&(e=0);return String.fromCharCode.apply(String,o)};var o=function(e,t){this.window=new n,this.contexts=Object.create(null);var r=function(){};r.prototype.encode=function(r,n){var o,i=0;for(o=0;o<r;o++)n[o]||i++;var s=t-n.total;e.encodeFreq(1,i,s)},r.prototype.decode=function(r){var n,o,i,s=t-r.total;for(o=i=e.decodeCulFreq(s),n=0;n<=o;n++)r[n]&&o++;return e.decodeUpdate(1,i,s),o},this.cm1coder=new r;var o=function(){this.sym=[t],this.prob=[0,256],this.refcount=0};o.prototype._rescale=function(){var e,r,n=this.sym.length,o=0,i=!0;for(e=0,r=0;e<n;e++){var s=this.sym[e],a=this.prob[e+1]-this.prob[e];(a>>>=1)>0&&(s===t&&(i=!1),this.sym[r]=s,this.prob[r++]=o,o+=a)}return this.prob[r]=o,n=this.sym.length=r,this.prob.length=n+1,i&&n<t&&(o=this._update(t,n,0,1)),o},o.prototype.update=function(e,t){var r=0;for(r=0;r<this.sym.length;r++)if(this.sym[r]===e)return this._update(e,r,this.prob[r+1]-this.prob[r],t);return this._update(e,r,0,t)},o.prototype._update=function(e,r,n,o){var i,s,a,c=this.sym.length;for(s=r;s<c-1;s++)this.sym[s]=this.sym[s+1],this.prob[s]=this.prob[s+1]-n;if(r<c)this.sym[s]=e,this.prob[s]=this.prob[s+1]-n,this.prob[c]=a=this.prob[c]+o;else if(a=this.prob[c],this.sym[r]=e,this.prob[r]=a,a+=o,this.prob[++c]=a,this.sym.length>t)for(i=0;i<c;i++)t===this.sym[i]&&(this._update(t,i,this.prob[i+1]-this.prob[i],-1),this.sym.length--,this.prob.length--,a=this.prob[this.prob.length-1]);return a>=65280&&(a=this._rescale()),a},o.prototype.encode=function(r,n){var o,i,s,a,c,u,h=this.sym.length,l=0,f=0,d=0;for(o=h-1;o>=0;o--){if(a=this.prob[o],s=this.prob[o+1]-a,r===this.sym[o]){for(i=o-1;i>=0&&l<n.total;i--)n[this.sym[i]]&&(l+=1,f+=u=this.prob[i+1]-this.prob[i],d+=u);return c=this.prob[h],a-=f,c-=d,e.encodeFreq(s,a,c),r!==t||(this._update(r,o,s,128),!1)}n[this.sym[o]]&&(l+=1,d+=s)}for(this.encode(t,n),console.assert(this.sym[this.sym.length-1]===t),o=0;o<this.sym.length-1;o++)n[this.sym[o]]||(n[this.sym[o]]=!0,n.total++)},o.prototype.decode=function(r){var n,o,i=this.sym.length,s=this.prob[i],a=0,c=0,u=0;for(o=i-1;o>=0&&a<r.total;o--)r[this.sym[o]]&&(a+=1,u+=this.prob[o+1]-this.prob[o]);var h=e.decodeCulFreq(s-u)+u;for(c=u,o=i-1;o>=0;o--)if(r[this.sym[o]])c-=n=this.prob[o+1]-this.prob[o],h-=n;else if(this.prob[o]<=h)break;console.assert(o>=0);var l=this.sym[o],f=this.prob[o],d=this.prob[o+1]-f;if(e.decodeUpdate(d,f-c,s-u),l<t)return l;for(this._update(l,o,d,128),console.assert(this.sym[this.sym.length-1]===t),o=0;o<this.sym.length-1;o++)r[this.sym[o]]||(r[this.sym[o]]=!0,r.total++);return-1},this.newContext=function(e){return new o},this.newExclude=function(){var e=Object.create(null);return e.total=0,e},function(){var e,t;for(e=0;e<5;e++)for(t=0;t<=e;t++){var r=this.window.context(t+(4-e),t);this.contexts[r]||(this.contexts[r]=this.newContext()),this.contexts[r].refcount++}}.call(this)};return o.prototype.update=function(e,t,r){var n,o,i;for(o=0;o<=5;o++)i=t.slice(5-o),(n=this.contexts[i])||(n=this.contexts[i]=this.newContext()),o>=r&&n.update(e,128),n.refcount++;t=this.window.context(this.window.pos+5,5);var s=this.window.firstPass;for(o=5;o>=0&&!s;o--)i=t.slice(0,o),n=this.contexts[i],console.assert(n),--n.refcount<=0&&(console.assert(""!==i),delete this.contexts[i]);this.window.put(e)},o.prototype.decode=function(){var e,t,r,n,o=this.window.context(this.window.pos,5),i=this.newExclude();for(t=5;t>=0;t--)if(r=o.slice(5-t),(e=this.contexts[r])&&(n=e.decode(i))>=0)return this.update(n,o,t),n;return n=this.cm1coder.decode(i),this.update(n,o,t),n},o.prototype.encode=function(e){var t,r=this.window.context(this.window.pos,5),n=this.newExclude();for(t=5;t>=0;t--){var o=r.slice(5-t),i=this.contexts[o];if(i&&i.encode(e,n))return void this.update(e,r,t)}this.cm1coder.encode(e,n),this.update(e,r,t)},o.MAGIC="ppm2",o.compressFile=t.compressFileHelper(o.MAGIC,function(r,n,i,s,a){var c=new e(n);c.encodeStart(a,1);var u=new o(c,i<0?257:256);t.compressWithModel(r,i,u),c.encodeFinish()},!0),o.decompressFile=t.decompressFileHelper(o.MAGIC,function(r,n,i){var s=new e(r);s.decodeStart(!0);var a=new o(s,i<0?257:256);t.decompressWithModel(n,i,a),s.decodeFinish()}),o}(r(1249),r(6015))},1249(e){e.exports=function(){var e=Math.pow(2,31),t=e>>>8,r=Math.pow(2,32)-1,n=function(t){this.low=0,this.range=e,this.buffer=0,this.help=0,this.bytecount=0,this.stream=t},o=function(n,o){for(;n.range<=t;){if(n.low<255<<23){for(o.writeByte(n.buffer);n.help;n.help--)o.writeByte(255);n.buffer=n.low>>>23&255}else if(n.low&e){for(o.writeByte(n.buffer+1);n.help;n.help--)o.writeByte(0);n.buffer=n.low>>>23&255}else if(n.help++,n.help>r)throw new Error("Too many bytes outstanding, file too large!");n.range=n.range<<8>>>0,n.low=(n.low<<8&e-1)>>>0,n.bytecount++}};n.prototype.encodeStart=function(t,r){this.low=0,this.range=e,this.buffer=t,this.help=0,this.bytecount=r},n.prototype.encodeFreq=function(e,t,r){o(this,this.stream);var n=this.range/r>>>0,i=n*t;this.low+=i,t+e<r?this.range=n*e:this.range-=i},n.prototype.encodeShift=function(e,t,r){o(this,this.stream);var n=this.range>>>r,i=n*t;this.low+=i,t+e>>>r?this.range-=i:this.range=n*e},n.prototype.encodeBit=function(e){this.encodeShift(1,e?1:0,1)},n.prototype.encodeByte=function(e){this.encodeShift(1,e,8)},n.prototype.encodeShort=function(e){this.encodeShift(1,e,16)},n.prototype.encodeFinish=function(){var e=this.stream;o(this,e),this.bytecount+=5;var r=this.low>>>23;if((this.low&t-1)>=(16777215&this.bytecount)>>>1&&r++,r>255)for(e.writeByte(this.buffer+1);this.help;this.help--)e.writeByte(0);else for(e.writeByte(this.buffer);this.help;this.help--)e.writeByte(255);return e.writeByte(255&r),e.writeByte(this.bytecount>>>16&255),e.writeByte(this.bytecount>>>8&255),e.writeByte(255&this.bytecount),this.bytecount},n.prototype.decodeStart=function(e){var t=e?0:this.stream.readByte();return"number"!=typeof t||t<0||(this.buffer=this.stream.readByte(),this.low=this.buffer>>>1,this.range=128),t};var i=function(e,r){for(;e.range<=t;)e.low=e.low<<8|e.buffer<<7&255,e.buffer=r.readByte(),e.low|=e.buffer>>>1,e.low=e.low>>>0,e.range=e.range<<8>>>0};return n.prototype.decodeCulFreq=function(e){i(this,this.stream),this.help=this.range/e>>>0;var t=this.low/this.help>>>0;return t>=e?e-1:t},n.prototype.decodeCulShift=function(e){i(this,this.stream),this.help=this.range>>>e;var t=this.low/this.help>>>0;return t>>>e?(1<<e)-1:t},n.prototype.decodeUpdate=function(e,t,r){var n=this.help*t;this.low-=n,t+e<r?this.range=this.help*e:this.range-=n},n.prototype.decodeBit=function(){var e=this.decodeCulShift(1);return this.decodeUpdate(1,e,2),e},n.prototype.decodeByte=function(){var e=this.decodeCulShift(8);return this.decodeUpdate(1,e,256),e},n.prototype.decodeShort=function(){var e=this.decodeCulShift(16);return this.decodeUpdate(1,e,65536),e},n.prototype.decodeFinish=function(){i(this,this.stream)},n.prototype.writeBit=n.prototype.encodeBit,n.prototype.readBit=n.prototype.decodeBit,n.prototype.writeByte=n.prototype.encodeByte,n.prototype.readByte=n.prototype.decodeByte,n}()},1737(e,t,r){var n,o,i,s,a;e.exports=(n=r(1249),o=r(3403),i=r(6015),s=1<<17,(a=Object.create(null)).MAGIC="smpl",a.compressFile=i.compressFileHelper(a.MAGIC,function(e,t,r,a,c){var u=new n(t);u.encodeStart(c,1);for(var h=i.makeU8Buffer(s),l=[],f=0,d=!1,p=function(){var t=0;for(t=0;t<256;t++)l[t]=0;if(d)f=0;else{for(t=0;t<s;){var r=e.readByte();if(r===o.EOF){d=!0;break}if(h[t++]=r,l[r]++,65535===l[r])break}f=t}};;){var m;if(p(),d&&0===f)break;for(u.encodeBit(!0),m=0;m<256;m++)u.encodeShort(l[m]);for(l[256]=f,m=256;m;m--)l[m-1]=l[m]-l[m-1];for(m=0;m<f;m++){var g=h[m];u.encodeFreq(l[g+1]-l[g],l[g],l[256])}}u.encodeBit(!1),u.encodeFinish()},!0),a.decompressFile=i.decompressFileHelper(a.MAGIC,function(e,t,r){var o=new n(e);for(o.decodeStart(!0);o.decodeBit();){var i,s=[];for(i=0;i<256;i++)s[i]=o.decodeShort();var a=0;for(i=0;i<256;i++){var c=s[i];s[i]=a,a+=c}for(s[256]=a,i=0;i<a;i++){var u,h=o.decodeCulFreq(a);for(u=0;u<256&&!(s[u]<=h&&h<s[u+1]);u++);o.decodeUpdate(s[u+1]-s[u],s[u],a),t.writeByte(u)}}o.decodeFinish()}),a)},3403(e,t,r){var n,o;e.exports=(n=r(6956),(o=function(){}).prototype.readByte=function(){var e=[0];return 0===this.read(e,0,1)?(this._eof=!0,-1):e[0]},o.prototype.read=function(e,t,r){for(var n,o=0;o<r;){if(-1===(n=this.readByte())){this._eof=!0;break}e[t+o++]=n}return o},o.prototype.eof=function(){return!!this._eof},o.prototype.seek=function(e){throw new Error("Stream is not seekable.")},o.prototype.tell=function(){throw new Error("Stream is not seekable.")},o.prototype.writeByte=function(e){var t=[e];this.write(t,0,1)},o.prototype.write=function(e,t,r){var n;for(n=0;n<r;n++)this.writeByte(e[t+n]);return r},o.prototype.flush=function(){},o.EOF=-1,n(o))},6015(e,t,r){e.exports=function(e,t){var r=Object.create(null),n=t.EOF;r.coerceInputStream=function(e,r){if("readByte"in e){if(r&&!("read"in e)){var o=e;(e=new t).readByte=function(){var e=o.readByte();return e===n&&(this._eof=!0),e},"size"in o&&(e.size=o.size),"seek"in o&&(e.seek=function(e){o.seek(e),this._eof=!1}),"tell"in o&&(e.tell=o.tell.bind(o))}}else{var i=e;(e=new t).size=i.length,e.pos=0,e.readByte=function(){return this.pos>=this.size?n:i[this.pos++]},e.read=function(e,t,r){for(var n=0;n<r&&this.pos<i.length;)e[t++]=i[this.pos++],n++;return n},e.seek=function(e){this.pos=e},e.tell=function(){return this.pos},e.eof=function(){return this.pos>=i.length}}return e};var o=function(e,t){this.buffer=e,this.resizeOk=t,this.pos=0};(o.prototype=Object.create(t.prototype)).writeByte=function(e){if(this.resizeOk&&this.pos>=this.buffer.length){var t=r.makeU8Buffer(2*this.buffer.length);t.set(this.buffer),this.buffer=t}this.buffer[this.pos++]=e},o.prototype.getBuffer=function(){if(this.pos!==this.buffer.length){if(!this.resizeOk)throw new TypeError("outputsize does not match decoded input");var e=r.makeU8Buffer(this.pos);e.set(this.buffer.subarray(0,this.pos)),this.buffer=e}return this.buffer},r.coerceOutputStream=function(e,t){var n={stream:e,retval:e};if(e){if("object"==typeof e&&"writeByte"in e)return n;"number"==typeof t?(console.assert(t>=0),n.stream=new o(r.makeU8Buffer(t),!1)):n.stream=new o(e,!1)}else n.stream=new o(r.makeU8Buffer(16384),!0);return Object.defineProperty(n,"retval",{get:n.stream.getBuffer.bind(n.stream)}),n},r.compressFileHelper=function(e,t,n){return function(o,i,s){o=r.coerceInputStream(o);var a,c,u=r.coerceOutputStream(i,i);for(i=u.stream,a=0;a<e.length;a++)i.writeByte(e.charCodeAt(a));if(c="size"in o&&o.size>=0?o.size:-1,n){var h=r.coerceOutputStream([]);for(r.writeUnsignedNumber(h.stream,c+1),h=h.retval,a=0;a<h.length-1;a++)i.writeByte(h[a]);n=h[h.length-1]}else r.writeUnsignedNumber(i,c+1);return t(o,i,c,s,n),u.retval}},r.decompressFileHelper=function(e,t){return function(n,o){var i;for(n=r.coerceInputStream(n),i=0;i<e.length;i++)if(e.charCodeAt(i)!==n.readByte())throw new Error("Bad magic");var s=r.readUnsignedNumber(n)-1,a=r.coerceOutputStream(o,s);return o=a.stream,t(n,o,s),a.retval}},r.compressWithModel=function(e,t,r){for(var o=0;o!==t;){var i=e.readByte();if(i===n){r.encode(256);break}r.encode(i),o++}},r.decompressWithModel=function(e,t,r){for(var n=0;n!==t;){var o=r.decode();if(256===o)break;e.writeByte(o),n++}},r.writeUnsignedNumber=function(e,t){console.assert(t>=0);var r,n=[];do{n.push(127&t),t=Math.floor(t/128)}while(0!==t);for(n[0]|=128,r=n.length-1;r>=0;r--)e.writeByte(n[r]);return e},r.readUnsignedNumber=function(e){for(var t,r=0;;){if(128&(t=e.readByte())){r+=127&t;break}r=128*(r+t)}return r};var i=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},s=function(e){return i(new Array(e))},a=function(e){return e};"undefined"!=typeof process&&Array.prototype.some.call(new Uint32Array(128),function(e){return 0!==e})&&(a=i),r.makeU8Buffer="undefined"!=typeof Uint8Array?function(e){return a(new Uint8Array(e))}:"undefined"!=typeof Buffer?function(e){var t=new Buffer(e);return t.fill(0),t}:s,r.makeU16Buffer="undefined"!=typeof Uint16Array?function(e){return a(new Uint16Array(e))}:s,r.makeU32Buffer="undefined"!=typeof Uint32Array?function(e){return a(new Uint32Array(e))}:s,r.makeS32Buffer="undefined"!=typeof Int32Array?function(e){return a(new Int32Array(e))}:s,r.arraycopy=function(e,t){console.assert(e.length>=t.length);for(var r=0,n=t.length;r<n;r++)e[r]=t[r];return e};var c=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];console.assert(256===c.length);var u=r.fls=function(e){return console.assert(e>=0),e>4294967295?32+u(Math.floor(e/4294967296)):4294901760&e?4278190080&e?24+c[e>>>24&255]:16+c[e>>>16]:65280&e?8+c[e>>>8]:c[e]};return r.log2c=function(e){return 0===e?-1:u(e-1)},e(r)}(r(6956),r(3403))},6956(e){e.exports=function(){"use strict";return Object.freeze?Object.freeze:function(e){return e}}()},650(e,t,r){e.exports=function(e,t,r,n,o,i,s,a,c,u,h,l,f,d,p,m,g,y,v){"use strict";return e({version:"0.0.1",BitStream:t,Stream:r,BWT:n,Context1Model:o,DefSumModel:i,FenwickModel:s,MTFModel:a,NoModel:c,Huffman:u,RangeCoder:h,BWTC:l,Bzip2:f,Dmc:d,Lzjb:p,LzjbR:m,Lzp3:g,PPM:y,Simple:v})}(r(6956),r(8196),r(3403),r(9010),r(4820),r(936),r(5623),r(417),r(1679),r(886),r(1249),r(1793),r(7026),r(2139),r(4845),r(6831),r(4416),r(736),r(1737))},181(e){"use strict";e.exports=require("buffer")},6982(e){"use strict";e.exports=require("crypto")},3167(e){"use strict";e.exports=require("domain")},4434(e){"use strict";e.exports=require("events")},9896(e){"use strict";e.exports=require("fs")},8611(e){"use strict";e.exports=require("http")},5692(e){"use strict";e.exports=require("https")},9278(e){"use strict";e.exports=require("net")},857(e){"use strict";e.exports=require("os")},6928(e){"use strict";e.exports=require("path")},2018(e){"use strict";e.exports=require("tty")},7016(e){"use strict";e.exports=require("url")},9023(e){"use strict";e.exports=require("util")},8167(e){"use strict";e.exports=require("worker_threads")},9003(e){"use strict";e.exports={version:"1.0.35"}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const i=t[n]={id:n,loaded:!1,exports:{}};return e[n](i,i.exports,r),i.loaded=!0,i.exports}r.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.cw=e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";const{isMainThread:e}=r(8167);if(e){process.env.UV_THREADPOOL_SIZE||(process.env.UV_THREADPOOL_SIZE="32"),process.removeAllListeners("warning"),process.on("warning",e=>{"DEP0169"!==e.code&&console.error(e.stack||`${e.name}: ${e.message}`)});const{ManagedExtension:e}=r(5482);e(r(8803),{})}else r(3109)})(),module.exports={}})();
1
+ (()=>{var e={3605(e,t,r){const n=r(7927),o=r(7074);e.exports=function(e,t){const{extensionName:i,configVersion:s,definitions:a}=t;n(s,"Settings version should be a positive integer"),n(Array.isArray(a),"Setting definitions should be an array");const c=((e,t)=>({postDefinitions:r=>e.post(`extensions/${t}/settings/definitions`,r),getSettings:()=>e.get(`extensions/${t}/settings`),updateSettings:r=>e.patch(`extensions/${t}/settings`,r),addSettingUpdateListener:r=>e.addListener("extensions","extension_settings_updated",r,t)}))(e,i);return o(t,e.logger,r(9896),c)}},7074(e,t,r){const n=r(7927),o=(e,t)=>Object.keys(e).reduce((r,n)=>{const o=t.find(e=>e.key===n);return o?(e[n]===o.default_value||(r[n]=e[n]),r):r},{});e.exports=function(e,t,r,i){const{configFile:s,configVersion:a,definitions:c}=e;let u,h;const l=e=>{u={...u,...e},h&&h(e),t.verbose(`Writing settings to ${s}...`);const n={version:a,settings:o(u,c)};r.writeFile(s,JSON.stringify(n,null,2),e=>{e&&t.error(`Failed to save settings to ${s}: ${e}`)})},f=e=>!!c.find(t=>t.key===e);return{getValue:e=>(n(f(e),`Definition for key ${e} was not found`),u[e]),setValue:(e,t)=>(n(f(e),`Definition for key ${e} was not found`),i.updateSettings({[e]:t})),load:async e=>{let o=!1;try{t.verbose(`Loading settings from ${s}...`);const i=JSON.parse(r.readFileSync(s,"utf8"));if(i&&(!i.version||!i.settings))throw"Invalid settings format";i.version!==a&&e?(u=e(i.version,i.settings),n(u,"Migration handler should return the new settings")):u=i.settings,o=!0}catch(e){t.verbose(`Failed to load settings: ${e}`)}try{await(async e=>{if(await i.postDefinitions(c),e){const e=Object.keys(u).reduce((e,t)=>(f(t)&&(e[t]=u[t]),e),{});await i.updateSettings(e)}u=await i.getSettings(),i.addSettingUpdateListener(l)})(o)}catch(e){t.error("Failed to register settings: "+e.message)}h&&h(u)},set onValuesUpdated(e){h=e},getValues:()=>({...u})}}},5482(e,t,r){"use strict";r.d(t,{ManagedExtension:()=>W});var n=r.cw(function(e,t){const n=r(4083),{stdout:s,stderr:a}=h(),{stringReplaceAll:c,stringEncaseCRLFWithFirstIndex:u}=i(),{isArray:l}=Array,f=["ansi","ansi","ansi256","ansi16m"],d=Object.create(null);class p{constructor(e){return m(e)}}const m=e=>{const t={};return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=s?s.level:0;e.level=void 0===t.level?r:t.level})(t,e),t.template=(...e)=>_(t.template,...e),Object.setPrototypeOf(t,g.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=p,t.template};function g(e){return m(e)}for(const[e,t]of Object.entries(n))d[e]={get(){const r=w(this,b(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:r}),r}};d.visible={get(){const e=w(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};const y=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(const e of y)d[e]={get(){const{level:t}=this;return function(...r){const o=b(n.color[f[t]][e](...r),n.color.close,this._styler);return w(this,o,this._isEmpty)}}};for(const e of y)d["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...r){const o=b(n.bgColor[f[t]][e](...r),n.bgColor.close,this._styler);return w(this,o,this._isEmpty)}}};const v=Object.defineProperties(()=>{},{...d,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),b=(e,t,r)=>{let n,o;return void 0===r?(n=e,o=t):(n=r.openAll+e,o=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:o,parent:r}},w=(e,t,r)=>{const n=(...e)=>l(e[0])&&l(e[0].raw)?k(n,_(n,...e)):k(n,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(n,v),n._generator=e,n._styler=t,n._isEmpty=r,n},k=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t;let r=e._styler;if(void 0===r)return t;const{openAll:n,closeAll:o}=r;if(-1!==t.indexOf(""))for(;void 0!==r;)t=c(t,r.close,r.open),r=r.parent;const i=t.indexOf("\n");return-1!==i&&(t=u(t,o,n,i)),n+t+o};let S;const _=(e,...t)=>{const[r]=t;if(!l(r)||!l(r.raw))return t.join(" ");const n=t.slice(1),i=[r.raw[0]];for(let e=1;e<r.length;e++)i.push(String(n[e-1]).replace(/[{}\\]/g,"\\$&"),String(r.raw[e]));return void 0===S&&(S=o()),S(e,i.join(""))};Object.defineProperties(g.prototype,d);const E=g();E.supportsColor=s,E.stderr=g({level:a?a.level:0}),E.stderr.supportsColor=a,e.exports=E}),o=()=>r(2991),i=r.cw(function(e,t){e.exports={stringReplaceAll:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return e;const o=t.length;let i=0,s="";do{s+=e.substr(i,n-i)+t+r,i=n+o,n=e.indexOf(t,i)}while(-1!==n);return s+=e.substr(i),s},stringEncaseCRLFWithFirstIndex:(e,t,r,n)=>{let o=0,i="";do{const s="\r"===e[n-1];i+=e.substr(o,(s?n-1:n)-o)+t+(s?"\r\n":"\n")+r,o=n+1,n=e.indexOf("\n",o)}while(-1!==n);return i+=e.substr(o),i}}}),s=r.cw(function(e,t){e.exports=(e,t=process.argv)=>{const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)}}),a=r.cw(function(e,t){function r(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function n(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"===t}e.exports=function(e,t){t||(t={});var o={bools:{},strings:{},unknownFn:null};"function"==typeof t.unknown&&(o.unknownFn=t.unknown),"boolean"==typeof t.boolean&&t.boolean?o.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(e){o.bools[e]=!0});var i={};function s(e){return i[e].some(function(e){return o.bools[e]})}Object.keys(t.alias||{}).forEach(function(e){i[e]=[].concat(t.alias[e]),i[e].forEach(function(t){i[t]=[e].concat(i[e].filter(function(e){return t!==e}))})}),[].concat(t.string).filter(Boolean).forEach(function(e){o.strings[e]=!0,i[e]&&[].concat(i[e]).forEach(function(e){o.strings[e]=!0})});var a=t.default||{},c={_:[]};function u(e,t,r){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(n(i,a))return;void 0===i[a]&&(i[a]={}),i[a]!==Object.prototype&&i[a]!==Number.prototype&&i[a]!==String.prototype||(i[a]={}),i[a]===Array.prototype&&(i[a]=[]),i=i[a]}var c=t[t.length-1];n(i,c)||(i!==Object.prototype&&i!==Number.prototype&&i!==String.prototype||(i={}),i===Array.prototype&&(i=[]),void 0===i[c]||o.bools[c]||"boolean"==typeof i[c]?i[c]=r:Array.isArray(i[c])?i[c].push(r):i[c]=[i[c],r])}function h(e,t,n){if(!n||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,n)||!1!==o.unknownFn(n)){var s=!o.strings[e]&&r(t)?Number(t):t;u(c,e.split("."),s),(i[e]||[]).forEach(function(e){u(c,e.split("."),s)})}}Object.keys(o.bools).forEach(function(e){h(e,void 0!==a[e]&&a[e])});var l=[];-1!==e.indexOf("--")&&(l=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var f=0;f<e.length;f++){var d,p,m=e[f];if(/^--.+=/.test(m)){var g=m.match(/^--([^=]+)=([\s\S]*)$/);d=g[1];var y=g[2];o.bools[d]&&(y="false"!==y),h(d,y,m)}else if(/^--no-.+/.test(m))h(d=m.match(/^--no-(.+)/)[1],!1,m);else if(/^--.+/.test(m))d=m.match(/^--(.+)/)[1],void 0===(p=e[f+1])||/^(-|--)[^-]/.test(p)||o.bools[d]||o.allBools||i[d]&&s(d)?/^(true|false)$/.test(p)?(h(d,"true"===p,m),f+=1):h(d,!o.strings[d]||"",m):(h(d,p,m),f+=1);else if(/^-[^-]+/.test(m)){for(var v=m.slice(1,-1).split(""),b=!1,w=0;w<v.length;w++)if("-"!==(p=m.slice(w+2))){if(/[A-Za-z]/.test(v[w])&&"="===p[0]){h(v[w],p.slice(1),m),b=!0;break}if(/[A-Za-z]/.test(v[w])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){h(v[w],p,m),b=!0;break}if(v[w+1]&&v[w+1].match(/\W/)){h(v[w],m.slice(w+2),m),b=!0;break}h(v[w],!o.strings[v[w]]||"",m)}else h(v[w],p,m);d=m.slice(-1)[0],b||"-"===d||(!e[f+1]||/^(-|--)[^-]/.test(e[f+1])||o.bools[d]||i[d]&&s(d)?e[f+1]&&/^(true|false)$/.test(e[f+1])?(h(d,"true"===e[f+1],m),f+=1):h(d,!o.strings[d]||"",m):(h(d,e[f+1],m),f+=1))}else if(o.unknownFn&&!1===o.unknownFn(m)||c._.push(o.strings._||!r(m)?m:Number(m)),t.stopEarly){c._.push.apply(c._,e.slice(f+1));break}}return Object.keys(a).forEach(function(e){var t,r,n;t=c,r=e.split("."),n=t,r.slice(0,-1).forEach(function(e){n=n[e]||{}}),r[r.length-1]in n||(u(c,e.split("."),a[e]),(i[e]||[]).forEach(function(t){u(c,t.split("."),a[e])}))}),t["--"]?c["--"]=l.slice():l.forEach(function(e){c._.push(e)}),c}}),c=r.cw(function(e,t){e.exports=u()}),u=()=>r(7706),h=r.cw(function(e,t){const r=l(),n=f(),o=s(),{env:i}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function u(e,t){if(0===a)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const n=a||0;if("dumb"===i.TERM)return n;if("win32"===process.platform){const e=r.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in i)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(e=>e in i)||"codeship"===i.CI_NAME?1:n;if("TEAMCITY_VERSION"in i)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(i.TEAMCITY_VERSION)?1:0;if("truecolor"===i.COLORTERM)return 3;if("TERM_PROGRAM"in i){const e=parseInt((i.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(i.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(i.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(i.TERM)||"COLORTERM"in i?1:n}o("no-color")||o("no-colors")||o("color=false")||o("color=never")?a=0:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(a=1),"FORCE_COLOR"in i&&(a="true"===i.FORCE_COLOR?1:"false"===i.FORCE_COLOR?0:0===i.FORCE_COLOR.length?1:Math.min(parseInt(i.FORCE_COLOR,10),3)),e.exports={stdout:c(u(!0,n.isatty(1))),stderr:c(u(!0,n.isatty(2)))}}),l=()=>r(857),f=()=>r(2018);const d="sessions/authorize";function p(){return p.c||(p.c=r.n(l()))}function m(){return m.c||(m.c=r.n(n()))}l(),n(),"object"==typeof navigator&&navigator.userAgent&&navigator.userAgent.includes("jsdom"),"object"==typeof process&&process.versions&&process.versions.node;const g="object"==typeof window&&"object"==typeof document&&9===document.nodeType;var y,v=r(7927),b=r.n(v),w=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},k="error",S="warn",_="info",E="verbose",C=((y={}).none=-1,y[k]=0,y[S]=1,y[_]=2,y[E]=3,y),O=!g||!!global.process&&!!global.process.env&&"test"===global.process.env.NODE_ENV;var x,B=r(4434),A=function(e,t){return!!t&&(Array.isArray(t)?-1!==t.indexOf(e):t.test(e))};x="undefined"!=typeof Promise?Promise:c();var R=Object.assign(x,{pending:function(){var e,t,r=new x(function(){e=arguments[0],t=arguments[1]});return{resolve:e,reject:t,promise:r}}});const T=R;var M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},M.apply(this,arguments)},F=function(e,t,r){var n=r.ignoredListenerEvents,o=void 0===n?[]:n,i=function(e,t){return b()(0!==t,'Entity ID "0" is not allowed'),t?e+t:e},s={},a=new B.EventEmitter,c={},u=function(r,n,o,i){n(o,function(n){e().post(r+"/"+i+"/resolve",n).catch(function(e){return t.error("Failed to complete hook action",r,e)})},function(n,o){e().post(r+"/"+i+"/reject",{reject_id:n,message:o}).catch(function(e){return t.error("Failed to complete failed hook action",r,e)})})},h=function(e){var t=c[e];t.forEach(function(e){return e.resolver.resolve(e.removeHandler)}),s[e]=t.length,delete c[e]},l=function(e,t){c[e].forEach(function(e){return e.resolver.reject(t)}),delete c[e]},f=function(r,n,o,i){var u=function(i){return void 0===i&&(i=!0),function(r,n,o,i){e().isConnected()&&(s[n]--,a.removeListener(n,o),0===s[n]&&(i&&e().isConnected()&&e().delete(r).catch(function(e){t.error("Failed to remove socket listener",r,e)}),delete s[n]))}(r,n,o,i)};if(!s[n]){c[n]||(c[n]=[],e().post(r,i).then(h.bind(F,n),l.bind(F,n)));var f=T.pending();return c[n].push({resolver:f,removeHandler:u}),f.promise}return s[n]++,T.resolve(u)},d={addViewUpdateListener:function(e,t,r){var n=i(e+"_updated",r);return a.on(n,t),function(){return function(e,t){a.removeListener(e,t)}(n,t)}},addListener:function(t,r,n,o){if(!e().isConnected())throw"Listeners can be added only for a connected socket";b()(-1===t.indexOf("/"),"The first argument should only contain the API section without any path tokens (entity ID should be supplied separately)");var s=i(r,o),c=function(e,t,r){return t?e+"/"+t+"/listeners/"+r:e+"/listeners/"+r}(t,o,r);return a.on(s,n),f(c,s,n)},hasListeners:function(){return Object.keys(s).length>0||Object.keys(s).reduce(function(e,t){return a.listenerCount(t)+e},0)>0},addHook:function(t,r,n,o){if(!e().isConnected())throw"Hooks can be added only for a connected socket";b()(-1===t.indexOf("/"),"The first argument should only contain the API section without any path tokens");var i=r;if(s[i]||c[i])throw"Hook exists";var h=t+"/hooks/"+r;return n=u.bind(F,h,n),a.on(i,n),f(h,i,n,o)},getPendingSubscriptionCount:function(){return Object.keys(c).length}};return M(M({},{onSocketDisconnected:function(){a.removeAllListeners(),s={}},handleMessage:function(e){var r=A(e.event,o);e.completion_id?(r||t.verbose(e.event,"(completion id "+e.completion_id+")",e.data),a.emit(e.event,e.data,e.completion_id)):(r||t.verbose(e.event,e.id?"(entity "+e.id+")":"(no entity)",e.data),e.id&&a.emit(i(e.event,e.id),e.data,e.id),a.emit(e.event,e.data,e.id))}}),{socket:d})};const P=F;var I=function(){return I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},I.apply(this,arguments)};var L=function(){return L=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},L.apply(this,arguments)},N={autoReconnect:!0,reconnectInterval:10,userSession:!1};const D=function(e,t){var r,n=L(L({},N),e),o=null,i=null,s=null,a=!0,c=null,u=null,h=null,l=function(e){var t=e.logLevel,r=void 0===t?E:t,n=e.logOutput,o=void 0===n?console:n,i=C[r];b()(o.log&&o.info&&o.warn&&o.error,"Invalid logOutput provided");var s=function(e,t,r){var n,i=w([],Array.prototype.slice.call(e),!0);O&&r&&(i=w([m()().magenta((n=new Date,"["+n.toLocaleDateString()+" "+n.toLocaleTimeString()+":"+n.getMilliseconds()+"]"))],i.map(function(e){return r("object"==typeof e?JSON.stringify(e,null," "):e)}),!0)),t.apply(o,i)},a={verbose:function(){i<C[E]||s(arguments,o.log,m()().gray)},info:function(){i<C[_]||s(arguments,o.info,m()().white.bold)},warn:function(){i<C[S]||s(arguments,o.warn,m()().yellow.bold)},error:function(){i<C[k]||s(arguments,o.error,m()().red.bold)}};return a}(n),f=P(function(){return s},l,n),p=function(e,t,r){var n,o=r.requestTimeout,i=void 0===o?30:o,s=r.ignoredRequestPaths,a={},c=0,u=function(r,n,o,i){if(void 0===i&&(i=!1),!i&&!e().isConnected())return t.warn("Attempting to send request on a non-authenticated socket: "+n),T.reject("Not authorized");if(!e().nativeSocket)return t.warn("Attempting to send request without a socket: "+n),T.reject("No socket");var u=(c>1e5&&(c=0),c+=1);b()(n,"Attempting socket request without a path");var h=A(n,s);h||t.verbose(m()().white.bold(u.toString()),r,n,o?function(e){return e&&e.hasOwnProperty("password")?I(I({},e),{password:"(hidden)"}):e}(o):"(no data)");var l=T.pending();a[u]={time:Date.now(),resolver:l,ignored:h};var f={path:n,method:r,data:o,callback_id:u};return e().nativeSocket.send(JSON.stringify(f)),l.promise},h=function(){var e=Date.now();Object.keys(a).forEach(function(r){a[r].time+1e3*i<e&&t.warn("Request "+r+" timed out")})},l={put:function(e,t){return u("PUT",e,t)},patch:function(e,t){return u("PATCH",e,t)},post:function(e,t){return u("POST",e,t)},delete:function(e){return u("DELETE",e)},get:function(e){return u("GET",e)},getPendingRequestCount:function(){return Object.keys(a).length}};return Object.assign(l,{reportRequestTimeouts:h}),I(I({},{onSocketConnected:function(){n=setInterval(h,3e4)},onSocketDisconnected:function(){var e;void 0===(e="Socket disconnected")&&(e="Request cancelled"),Object.keys(a).forEach(function(r){t.verbose("Canceling a pending request "+r+" ("+e+")"),a[r].resolver.reject(e)}),a={},clearTimeout(n)},handleMessage:function(e){var r=e.callback_id;if(a.hasOwnProperty(r)){if(e.code>=200&&e.code<=204){var n=e.data;a[r].ignored||t.verbose(m()().green(r.toString()),"SUCCEEDED",n||"(no data)"),a[r].resolver.resolve(n)}else{var o=e;o.error||t.warn("Error message missing from the response (this is an API bug that should be reported)",r,e);var i=o.code,s=o.error||{message:"(no error description)"};t.warn(r,i,s.message,function(e){return e.field&&e.code?e.field+" ("+e.code+")":""}(s)),a[r].resolver.reject({message:s.message,code:i,json:s})}delete a[r]}else t.warn("No pending request for an API response",r,e)},postAuthenticate:function(e,t){return u("POST",e,t,!0)}}),{socket:l})}(function(){return s},l,n);b()(e.url,'"url" must be defined in settings object');var g=function(){i&&(u&&u(),i=null)},y=function(e){e.wasClean?l.info("Websocket was closed normally"):l.error("Websocket failed: "+e.reason+" (code: "+e.code+")"),p.onSocketDisconnected(),f.onSocketDisconnected(),o=null,h&&h(e.reason,e.code,e.wasClean),i&&n.autoReconnect&&!a&&setTimeout(function(){a||s.reconnect().catch(function(e){l.error("Reconnect failed for a closed socket",e.message)})})},v=function(e){var t=JSON.parse(e.data);t.callback_id?p.handleMessage(t):f.handleMessage(t)},x=function(e,t){if(void 0===e&&(e=n.username),void 0===t&&(t=n.password),!e)throw'"username" option was not supplied for authentication';if(!t)throw'"password" option was not supplied for authentication';var r={username:e,password:t,grant_type:"password"};return p.postAuthenticate(d,r)},B=function(){var e={auth_token:i};return p.postAuthenticate("sessions/socket",e)},R=function(e,t,r,o){r().then(function(t){!function(e){if(i?l.info("Socket associated with an existing session"):(l.info("Login succeed"),i=e.auth_token),c){try{c(e)}catch(e){console.error("Error in socket connect handler",e.message)}p.onSocketConnected()}}(t),e(t)}).catch(function(r){return r.code?i&&400===r.code&&n.autoReconnect?(l.info("Session lost, re-sending credentials"),g(),void R(e,t,x,o)):(401===r.code&&g(),s.disconnect(void 0,"Authentication failed"),void t(r)):(l.info("Socket disconnected during authentication, reconnecting"),void o())})},M=function(e,i,s,a){void 0===a&&(a=!0),o=new t(n.url);var c=function(){o=null,a?r=setTimeout(function(){l.info("Socket reconnecting"),M(e,i,s,a)},1e3*n.reconnectInterval):i("Cannot connect to the server")};o.onopen=function(){l.info("Socket connected"),o.onerror=function(e){l.error("Websocket failed: "+e.reason)},o.onclose=y,o.onmessage=v,R(e,i,s,c)},o.onerror=function(e){l.error("Connecting socket failed"),c()}},F=function(e,t){return a=!1,new T(function(r,n){l.info("Starting socket connect"),M(r,n,e,t)})},D=function(){return!(!o||o.readyState!==(o.OPEN||1)||!i)},j=function(){return!!o},U=function(){clearTimeout(r),a=!0},q=function(e,t){void 0===e&&(e=!1),void 0===t&&(t="Manually disconnected by the client"),o?(l.info("Disconnecting socket"),e||U(),o.close(1e3,t)):a?l.warn("Attempting to disconnect a closed socket (ignore)"):e?l.verbose("Attempting to disconnect a closed socket with auto reconnect enabled (continue connecting)"):(l.verbose("Disconnecting a closed socket with auto reconnect enabled (cancel reconnect)"),U())};return s=L(L({connect:function(e,t,r){if(void 0===r&&(r=!0),j())throw"Connect may only be used for a closed socket";return g(),F(function(){return x(e,t)},r)},connectRefreshToken:function(e,t){if(void 0===t&&(t=!0),j())throw"Connect may only be used for a closed socket";return g(),F(function(){return function(e){if(!e)throw'"refreshToken" option was not supplied for authentication';var t={refresh_token:e,grant_type:"refresh_token"};return p.postAuthenticate(d,t)}(e)},t)},reconnect:function(e,t){if(void 0===e&&(e=void 0),void 0===t&&(t=!0),j())throw"Reconnect may only be used for a closed socket";if(e&&(i=e),!i)throw"No session token available for reconnecting";return l.info("Reconnecting socket"),F(B,t)},logout:function(){var e=T.pending();return s.delete("sessions/self").then(function(t){l.info("Logout succeed"),g(),e.resolve(t),q(void 0,"Logged out")}).catch(function(t){l.error("Logout failed",t),e.reject(t)}),e.promise},disconnect:q,isConnecting:function(){return!(!o||D())},isConnected:D,isActive:j,logger:l,waitDisconnected:function(e){void 0===e&&(e=2e3);var t=e>0?e/50:0;return new T(function(r,n){var o=0,i=function(){j()?o>=t?(l.error("Socket disconnect timed out after "+e+" ms"),n("Socket disconnect timed out")):(setTimeout(i,50),o++):r()};i()})},set onConnected(e){c=e},set onSessionReset(e){u=e},set onDisconnected(e){h=e},get onConnected(){return c},get onSessionReset(){return u},get onDisconnected(){return h},get nativeSocket(){return o}},f.socket),p.socket)};function j(){return j.c||(j.c=r.n(a()))}a();const U={autoReconnect:!1,ignoredRequestPaths:["sessions/activity"]},q={minSleepDetectTimeout:3e4,aliveCheckInterval:5e3},z=(e,t)=>{const n=j()()(process.argv.slice(2)),o=`ws://${n.apiUrl}`,i=D(Object.assign(Object.assign(Object.assign({logLevel:n.debug?"verbose":"info"},U),e),{url:o}),r(5488).w3cwebsocket),s=((e,t)=>({activity:()=>e.post("sessions/activity"),getSettingValues:t=>e.post("settings/get",{keys:t}),ready:()=>e.post(`extensions/${t.name}/ready`)}))(i,n);return{argv:n,socket:i,connectUrl:o,api:s,options:Object.assign(Object.assign({},q),t)}},$=(e,t)=>e.argv.appPid?((e,{socket:t,api:r,options:n},o)=>{let i,s=Date.now(),a=n.minSleepDetectTimeout;const c=()=>{if(s+a<Date.now())return t.logger.error(`Wake up detected (last alive ${Date.now()-s} ms ago), requesting restart...`),o(),void process.exit(124);(e=>{try{return process.kill(e,0)}catch(e){return"EPERM"===e.code}})(e)||(t.logger.error(`Parent dead (PID ${e}), exiting...`),o(),process.exit(69)),s=Date.now()};return{start:()=>{r.getSettingValues(["ping_timeout"]).then(e=>{const r=1e3*e.ping_timeout;r>a&&(a=r,t.logger.info(`Alive check timeout adjusted to match the API ping timeout (${r} ms)`)),i=setInterval(c,n.aliveCheckInterval)}).catch(e=>{t.logger.error("Failed to get ping timeout value from the API",e),process.exit(1)})},stop:()=>{clearInterval(i)},getStats:()=>({sleepDetectTimeoutMs:a})}})(e.argv.appPid,e,t):(({socket:e,api:t},r)=>{let n,o=Date.now()+9999;const i=()=>{if(o+1e4<Date.now())return e.logger.error("Socket timed out, requesting restart..."),r(),void process.exit(124);t.activity().then(e=>{o=Date.now()}).catch(t=>{e.logger.error(`Ping failed: ${t.message}`)})};return{start:()=>{n=setInterval(i,4e3)},stop:()=>{clearInterval(n)},getStats:()=>({sleepDetectTimeoutMs:1e4})}})(e,t);var H=r(7016);const G=e=>{const t=new H.URL(e);return{address:t.host,secure:"wss"===t.protocol}},W=(e,t={},r={},n=z)=>{const o=n(t,r),{argv:i,socket:s,connectUrl:a,api:c}=o;let u,h;process.title=i.name,s.logger.verbose("Starting the extension",JSON.stringify(process.argv),JSON.stringify(i,null,2),JSON.stringify({nodeVersion:process.version,arch:p()().arch(),osVersion:p()().version?p()().version():"N/A",totalmem:p()().totalmem(),cpuCount:p()().cpus().length},null,2));const l=()=>{h&&h()},f=$(o,l);s.onConnected=e=>{setTimeout(()=>{f.start(),u&&Promise.resolve(u(e)).then(()=>{i.signalReady&&c.ready().catch(e=>s.logger.error(`Failed to signal ready state: ${e.message}`))})},10)},s.onDisconnected=(e,t,r)=>{l(),r?(s.logger.info("Socket disconnected (clean), exiting"),process.exit(1)):(s.logger.info(`Socket disconnected (unclean, ${e}), requesting restart`),process.exit(124))};const d=()=>{s.logger.info("Exit requested"),process.exit()};process.on("exit",l),process.on("SIGINT",d),process.on("SIGTERM",d);const m="function"==typeof e?e:e.default;if(!m)throw"Extension entry is not a function ";return m(s,{name:i.name,configPath:i.settingsPath,logPath:i.logPath,debugMode:i.debug,server:G(a),set onStart(e){u=e},set onStop(e){h=e}}),s.reconnect(i.authToken,!1).catch(e=>{s.logger.error(`Failed to connect to server ${i.apiUrl}, exiting...`),l(),process.exit(1)}),{stop:()=>{f.stop()},getStats:()=>f.getStats()}};r(9896),r(3480),r(6928)},4083(e,t,r){"use strict";e=r.nmd(e);const n=(e,t)=>(...r)=>`[${e(...r)+t}m`,o=(e,t)=>(...r)=>{const n=e(...r);return`[${38+t};5;${n}m`},i=(e,t)=>(...r)=>{const n=e(...r);return`[${38+t};2;${n[0]};${n[1]};${n[2]}m`},s=e=>e,a=(e,t,r)=>[e,t,r],c=(e,t,r)=>{Object.defineProperty(e,t,{get:()=>{const n=r();return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})};let u;const h=(e,t,n,o)=>{void 0===u&&(u=r(734));const i=o?10:0,s={};for(const[r,o]of Object.entries(u)){const a="ansi16"===r?"ansi":r;r===t?s[a]=e(n,i):"object"==typeof o&&(s[a]=e(o[t],i))}return s};Object.defineProperty(e,"exports",{enumerable:!0,get:function(){const e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(const[r,n]of Object.entries(t)){for(const[r,o]of Object.entries(n))t[r]={open:`[${o[0]}m`,close:`[${o[1]}m`},n[r]=t[r],e.set(o[0],o[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="",t.bgColor.close="",c(t.color,"ansi",()=>h(n,"ansi16",s,!1)),c(t.color,"ansi256",()=>h(o,"ansi256",s,!1)),c(t.color,"ansi16m",()=>h(i,"rgb",a,!1)),c(t.bgColor,"ansi",()=>h(n,"ansi16",s,!0)),c(t.bgColor,"ansi256",()=>h(o,"ansi256",s,!0)),c(t.bgColor,"ansi16m",()=>h(i,"rgb",a,!0)),t}})},983(e,t,r){"use strict";var n=r(7342),o=[];function i(){this.task=null,this.domain=null}e.exports=function(e){var t;(t=o.length?o.pop():new i).task=e,t.domain=process.domain,n(t)},i.prototype.call=function(){this.domain&&this.domain.enter();var e=!0;try{this.task.call(),e=!1,this.domain&&this.domain.exit()}finally{e&&n.requestFlush(),this.task=null,this.domain=null,o.push(this)}}},7342(e,t,r){"use strict";var n,o="function"==typeof setImmediate;function i(e){s.length||(h(),a=!0),s[s.length]=e}e.exports=i;var s=[],a=!1,c=0;function u(){for(;c<s.length;){var e=c;if(c+=1,s[e].call(),c>1024){for(var t=0,r=s.length-c;t<r;t++)s[t]=s[t+c];s.length-=c,c=0}}s.length=0,c=0,a=!1}function h(){var e=process.domain;e&&(n||(n=r(3167)),n.active=process.domain=null),a&&o?setImmediate(u):process.nextTick(u),e&&(n.active=process.domain=e)}i.requestFlush=h},6489(e){"use strict";e.exports={mask:(e,t,r,n,o)=>{for(var i=0;i<o;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]}}},2627(e,t,r){"use strict";try{e.exports=r(8169)(__dirname)}catch(t){e.exports=r(6489)}},2991(e){"use strict";const t=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,r=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,n=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,o=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,i=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a",""]]);function s(e){const t="u"===e[0],r="{"===e[1];return t&&!r&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(parseInt(e.slice(2,-1),16)):i.get(e)||e}function a(e,t){const r=[],i=t.trim().split(/\s*,\s*/g);let a;for(const t of i){const i=Number(t);if(Number.isNaN(i)){if(!(a=t.match(n)))throw new Error(`Invalid Chalk template style argument: ${t} (in style '${e}')`);r.push(a[2].replace(o,(e,t,r)=>t?s(t):r))}else r.push(i)}return r}function c(e){r.lastIndex=0;const t=[];let n;for(;null!==(n=r.exec(e));){const e=n[1];if(n[2]){const r=a(e,n[2]);t.push([e].concat(r))}else t.push([e])}return t}function u(e,t){const r={};for(const e of t)for(const t of e.styles)r[t[0]]=e.inverse?null:t.slice(1);let n=e;for(const[e,t]of Object.entries(r))if(Array.isArray(t)){if(!(e in n))throw new Error(`Unknown Chalk style: ${e}`);n=t.length>0?n[e](...t):n[e]}return n}e.exports=(e,r)=>{const n=[],o=[];let i=[];if(r.replace(t,(t,r,a,h,l,f)=>{if(r)i.push(s(r));else if(h){const t=i.join("");i=[],o.push(0===n.length?t:u(e,n)(t)),n.push({inverse:a,styles:c(h)})}else if(l){if(0===n.length)throw new Error("Found extraneous } in Chalk template literal");o.push(u(e,n)(i.join(""))),i=[],n.pop()}else i.push(f)}),o.push(i.join("")),n.length>0){const e=`Chalk template literal is missing ${n.length} closing bracket${1===n.length?"":"s"} (\`}\`)`;throw new Error(e)}return o.join("")}},5659(e,t,r){const n=r(8156),o={};for(const e of Object.keys(n))o[n[e]]=e;const i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=i;for(const e of Object.keys(i)){if(!("channels"in i[e]))throw new Error("missing channels property: "+e);if(!("labels"in i[e]))throw new Error("missing channel labels property: "+e);if(i[e].labels.length!==i[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:r}=i[e];delete i[e].channels,delete i[e].labels,Object.defineProperty(i[e],"channels",{value:t}),Object.defineProperty(i[e],"labels",{value:r})}function s(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}i.rgb.hsl=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.min(t,r,n),i=Math.max(t,r,n),s=i-o;let a,c;i===o?a=0:t===i?a=(r-n)/s:r===i?a=2+(n-t)/s:n===i&&(a=4+(t-r)/s),a=Math.min(60*a,360),a<0&&(a+=360);const u=(o+i)/2;return c=i===o?0:u<=.5?s/(i+o):s/(2-i-o),[a,100*c,100*u]},i.rgb.hsv=function(e){let t,r,n,o,i;const s=e[0]/255,a=e[1]/255,c=e[2]/255,u=Math.max(s,a,c),h=u-Math.min(s,a,c),l=function(e){return(u-e)/6/h+.5};return 0===h?(o=0,i=0):(i=h/u,t=l(s),r=l(a),n=l(c),s===u?o=n-r:a===u?o=1/3+t-n:c===u&&(o=2/3+r-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*i,100*u]},i.rgb.hwb=function(e){const t=e[0],r=e[1];let n=e[2];const o=i.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(r,n));return n=1-1/255*Math.max(t,Math.max(r,n)),[o,100*s,100*n]},i.rgb.cmyk=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-r,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-r-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},i.rgb.keyword=function(e){const t=o[e];if(t)return t;let r,i=1/0;for(const t of Object.keys(n)){const o=s(e,n[t]);o<i&&(i=o,r=t)}return r},i.keyword.rgb=function(e){return n[e]},i.rgb.xyz=function(e){let t=e[0]/255,r=e[1]/255,n=e[2]/255;return t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,[100*(.4124*t+.3576*r+.1805*n),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let r=t[0],n=t[1],o=t[2];return r/=95.047,n/=100,o/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,[116*n-16,500*(r-n),200*(n-o)]},i.hsl.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100;let o,i,s;if(0===r)return s=255*n,[s,s,s];o=n<.5?n*(1+r):n+r-n*r;const a=2*n-o,c=[0,0,0];for(let e=0;e<3;e++)i=t+1/3*-(e-1),i<0&&i++,i>1&&i--,s=6*i<1?a+6*(o-a)*i:2*i<1?o:3*i<2?a+(o-a)*(2/3-i)*6:a,c[e]=255*s;return c},i.hsl.hsv=function(e){const t=e[0];let r=e[1]/100,n=e[2]/100,o=r;const i=Math.max(n,.01);return n*=2,r*=n<=1?n:2-n,o*=i<=1?i:2-i,[t,100*(0===n?2*o/(i+o):2*r/(n+r)),(n+r)/2*100]},i.hsv.rgb=function(e){const t=e[0]/60,r=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,i=t-Math.floor(t),s=255*n*(1-r),a=255*n*(1-r*i),c=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,c,s];case 1:return[a,n,s];case 2:return[s,n,c];case 3:return[s,a,n];case 4:return[c,s,n];case 5:return[n,s,a]}},i.hsv.hsl=function(e){const t=e[0],r=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let i,s;s=(2-r)*n;const a=(2-r)*o;return i=r*o,i/=a<=1?a:2-a,i=i||0,s/=2,[t,100*i,100*s]},i.hwb.rgb=function(e){const t=e[0]/360;let r=e[1]/100,n=e[2]/100;const o=r+n;let i;o>1&&(r/=o,n/=o);const s=Math.floor(6*t),a=1-n;i=6*t-s,1&s&&(i=1-i);const c=r+i*(a-r);let u,h,l;switch(s){default:case 6:case 0:u=a,h=c,l=r;break;case 1:u=c,h=a,l=r;break;case 2:u=r,h=a,l=c;break;case 3:u=r,h=c,l=a;break;case 4:u=c,h=r,l=a;break;case 5:u=a,h=r,l=c}return[255*u,255*h,255*l]},i.cmyk.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},i.xyz.rgb=function(e){const t=e[0]/100,r=e[1]/100,n=e[2]/100;let o,i,s;return o=3.2406*t+-1.5372*r+-.4986*n,i=-.9689*t+1.8758*r+.0415*n,s=.0557*t+-.204*r+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*o,255*i,255*s]},i.xyz.lab=function(e){let t=e[0],r=e[1],n=e[2];return t/=95.047,r/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*r-16,500*(t-r),200*(r-n)]},i.lab.xyz=function(e){let t,r,n;r=(e[0]+16)/116,t=e[1]/500+r,n=r-e[2]/200;const o=r**3,i=t**3,s=n**3;return r=o>.008856?o:(r-16/116)/7.787,t=i>.008856?i:(t-16/116)/7.787,n=s>.008856?s:(n-16/116)/7.787,t*=95.047,r*=100,n*=108.883,[t,r,n]},i.lab.lch=function(e){const t=e[0],r=e[1],n=e[2];let o;return o=360*Math.atan2(n,r)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(r*r+n*n),o]},i.lch.lab=function(e){const t=e[0],r=e[1],n=e[2]/360*2*Math.PI;return[t,r*Math.cos(n),r*Math.sin(n)]},i.rgb.ansi16=function(e,t=null){const[r,n,o]=e;let s=null===t?i.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let a=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(r/255));return 2===s&&(a+=60),a},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){const t=e[0],r=e[1],n=e[2];return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},i.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const r=.5*(1+~~(e>50));return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},i.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},i.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},i.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let r=t[0];3===t[0].length&&(r=r.split("").map(e=>e+e).join(""));const n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},i.rgb.hcg=function(e){const t=e[0]/255,r=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,r),n),i=Math.min(Math.min(t,r),n),s=o-i;let a,c;return a=s<1?i/(1-s):0,c=s<=0?0:o===t?(r-n)/s%6:o===r?2+(n-t)/s:4+(t-r)/s,c/=6,c%=1,[360*c,100*s,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=r<.5?2*t*r:2*t*(1-r);let o=0;return n<1&&(o=(r-.5*n)/(1-n)),[e[0],100*n,100*o]},i.hsv.hcg=function(e){const t=e[1]/100,r=e[2]/100,n=t*r;let o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},i.hcg.rgb=function(e){const t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];const o=[0,0,0],i=t%1*6,s=i%1,a=1-s;let c=0;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return c=(1-r)*n,[255*(r*o[0]+c),255*(r*o[1]+c),255*(r*o[2]+c)]},i.hcg.hsv=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t);let n=0;return r>0&&(n=t/r),[e[0],100*n,100*r]},i.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let n=0;return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},i.hcg.hwb=function(e){const t=e[1]/100,r=t+e[2]/100*(1-t);return[e[0],100*(r-t),100*(1-r)]},i.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,n=r-t;let o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=function(e){return[0,0,e[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},734(e,t,r){const n=r(5659),o=r(8507),i={};Object.keys(n).forEach(e=>{i[e]={},Object.defineProperty(i[e],"channels",{value:n[e].channels}),Object.defineProperty(i[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach(r=>{const n=t[r];i[e][r]=function(e){const t=function(...t){const r=t[0];if(null==r)return r;r.length>1&&(t=r);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}(n),i[e][r].raw=function(e){const t=function(...t){const r=t[0];return null==r?r:(r.length>1&&(t=r),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)})}),e.exports=i},8507(e,t,r){const n=r(5659);function o(e,t){return function(r){return t(e(r))}}function i(e,t){const r=[t[e].parent,e];let i=n[t[e].parent][e],s=t[e].parent;for(;t[s].parent;)r.unshift(t[s].parent),i=o(n[t[s].parent][s],i),s=t[s].parent;return i.conversion=r,i}e.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(n);for(let r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null};return e}(),r=[e];for(t[e].distance=0;r.length;){const e=r.pop(),o=Object.keys(n[e]);for(let n=o.length,i=0;i<n;i++){const n=o[i],s=t[n];-1===s.distance&&(s.distance=t[e].distance+1,s.parent=e,r.unshift(n))}}return t}(e),r={},o=Object.keys(t);for(let e=o.length,n=0;n<e;n++){const e=o[n];null!==t[e].parent&&(r[e]=i(e,t))}return r}},8156(e){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},7833(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(9910)).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){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),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(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("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())},9910(e,t,r){var n;function o(e){function r(){if(r.enabled){var e=r,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=s[c];r=o.call(e,i),s.splice(c,1),c--}return r}),t.formatArgs.call(e,s),(r.log||t.log||console.log.bind(console)).apply(e,s)}}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=o.debug=o.default=o).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,o=0;o<n;o++)r[o]&&("-"===(e=r[o].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(6585),t.names=[],t.skips=[],t.formatters={}},5753(e,t,r){"undefined"!=typeof process&&"renderer"===process.type?e.exports=r(7833):e.exports=r(6033)},6033(e,t,r){var n=r(2018),o=r(9023);(t=e.exports=r(9910)).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 s.write(o.format.apply(o,arguments)+"\n")},t.formatArgs=function(e){var r=this.namespace;if(this.useColors){var n=this.color,o=" [3"+n+";1m"+r+" ";e[0]=o+e[0].split("\n").join("\n"+o),e.push("[3"+n+"m+"+t.humanize(this.diff)+"")}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&&o.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 s=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":(t=new(r(9896).SyncWriteStream)(e,{autoClose:!1}))._type="fs";break;case"PIPE":case"TCP":(t=new(r(9278).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,o.inspect(e,this.inspectOpts).split("\n").map(function(e){return e.trim()}).join(" ")},t.formatters.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)},t.enable(a())},7927(e){"use strict";e.exports=function(e,t,r,n,o,i,s,a){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,i,s,a],h=0;(c=new Error(t.replace(/%s/g,function(){return u[h++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},9225(e){e.exports=n,n.strict=o,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 o(e)||i(e)}function o(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)]}},3480(e,t,r){const n=r(5737),o=r(1276),{mkdirpNative:i,mkdirpNativeSync:s}=r(3831),{mkdirpManual:a,mkdirpManualSync:c}=r(6990),{useNative:u,useNativeSync:h}=r(4443),l=(e,t)=>(e=o(e),t=n(t),u(t)?i(e,t):a(e,t));l.sync=(e,t)=>(e=o(e),t=n(t),h(t)?s(e,t):c(e,t)),l.native=(e,t)=>i(o(e),n(t)),l.manual=(e,t)=>a(o(e),n(t)),l.nativeSync=(e,t)=>s(o(e),n(t)),l.manualSync=(e,t)=>c(o(e),n(t)),e.exports=l},4523(e,t,r){const{dirname:n}=r(6928),o=(e,t,r=void 0)=>r===t?Promise.resolve():e.statAsync(t).then(e=>e.isDirectory()?r:void 0,r=>"ENOENT"===r.code?o(e,n(t),t):void 0),i=(e,t,r=void 0)=>{if(r!==t)try{return e.statSync(t).isDirectory()?r:void 0}catch(r){return"ENOENT"===r.code?i(e,n(t),t):void 0}};e.exports={findMade:o,findMadeSync:i}},6990(e,t,r){const{dirname:n}=r(6928),o=(e,t,r)=>{t.recursive=!1;const i=n(e);return i===e?t.mkdirAsync(e,t).catch(e=>{if("EISDIR"!==e.code)throw e}):t.mkdirAsync(e,t).then(()=>r||e,n=>{if("ENOENT"===n.code)return o(i,t).then(r=>o(e,t,r));if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;return t.statAsync(e).then(e=>{if(e.isDirectory())return r;throw n},()=>{throw n})})},i=(e,t,r)=>{const o=n(e);if(t.recursive=!1,o===e)try{return t.mkdirSync(e,t)}catch(e){if("EISDIR"!==e.code)throw e;return}try{return t.mkdirSync(e,t),r||e}catch(n){if("ENOENT"===n.code)return i(e,t,i(o,t,r));if("EEXIST"!==n.code&&"EROFS"!==n.code)throw n;try{if(!t.statSync(e).isDirectory())throw n}catch(e){throw n}}};e.exports={mkdirpManual:o,mkdirpManualSync:i}},3831(e,t,r){const{dirname:n}=r(6928),{findMade:o,findMadeSync:i}=r(4523),{mkdirpManual:s,mkdirpManualSync:a}=r(6990);e.exports={mkdirpNative:(e,t)=>(t.recursive=!0,n(e)===e?t.mkdirAsync(e,t):o(t,e).then(r=>t.mkdirAsync(e,t).then(()=>r).catch(r=>{if("ENOENT"===r.code)return s(e,t);throw r}))),mkdirpNativeSync:(e,t)=>{if(t.recursive=!0,n(e)===e)return t.mkdirSync(e,t);const r=i(t,e);try{return t.mkdirSync(e,t),r}catch(r){if("ENOENT"===r.code)return a(e,t);throw r}}}},5737(e,t,r){const{promisify:n}=r(9023),o=r(9896);e.exports=e=>{if(e)if("object"==typeof e)e={mode:511,fs:o,...e};else if("number"==typeof e)e={mode:e,fs:o};else{if("string"!=typeof e)throw new TypeError("invalid options argument");e={mode:parseInt(e,8),fs:o}}else e={mode:511,fs:o};return e.mkdir=e.mkdir||e.fs.mkdir||o.mkdir,e.mkdirAsync=n(e.mkdir),e.stat=e.stat||e.fs.stat||o.stat,e.statAsync=n(e.stat),e.statSync=e.statSync||e.fs.statSync||o.statSync,e.mkdirSync=e.mkdirSync||e.fs.mkdirSync||o.mkdirSync,e}},1276(e,t,r){const n=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:o,parse:i}=r(6928);e.exports=e=>{if(/\0/.test(e))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:e,code:"ERR_INVALID_ARG_VALUE"});if(e=o(e),"win32"===n){const t=/[*|"<>?:]/,{root:r}=i(e);if(t.test(e.substr(r.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e}},4443(e,t,r){const n=r(9896),o=(process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version).replace(/^v/,"").split("."),i=+o[0]>10||10===+o[0]&&+o[1]>=12,s=i?e=>e.mkdir===n.mkdir:()=>!1,a=i?e=>e.mkdirSync===n.mkdirSync:()=>!1;e.exports={useNative:s,useNativeSync:a}},6585(e){var t=1e3,r=60*t,n=60*r,o=24*n;function i(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,s){s=s||{};var a,c=typeof e;if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(i){var s=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*n;case"minutes":case"minute":case"mins":case"min":case"m":return s*r;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===c&&!1===isNaN(e))return s.long?i(a=e,o,"day")||i(a,n,"hour")||i(a,r,"minute")||i(a,t,"second")||a+" ms":function(e){return e>=o?Math.round(e/o)+"d":e>=n?Math.round(e/n)+"h":e>=r?Math.round(e/r)+"m":e>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},8169(e,t,r){const n=require;"function"==typeof n.addon?e.exports=n.addon.bind(n):e.exports=r(1381)},1381(e,t,r){var n=r(9896),o=r(6928),i=r(857),s=require,a=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,u=process.versions.modules,h=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",l=process.env.npm_config_arch||i.arch(),f=process.env.npm_config_platform||i.platform(),d=process.env.LIBC||(function(e){return"linux"===e&&n.existsSync("/etc/alpine-release")}(f)?"musl":"glibc"),p=process.env.ARM_VERSION||("arm64"===l?"8":a.arm_version)||"",m=(process.versions.uv||"").split(".")[0];function g(e){return s(g.resolve(e))}function y(e){try{return n.readdirSync(e)}catch(e){return[]}}function v(e,t){var r=y(e).filter(t);return r[0]&&o.join(e,r[0])}function b(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 k(e,t){return function(r){return null!=r&&r.platform===e&&r.architectures.includes(t)}}function S(e,t){return e.architectures.length-t.architectures.length}function _(e){var t=e.split("."),r={file:e,specificity:0};if("node"===t.pop()){for(var n=0;n<t.length;n++){var o=t[n];if("node"===o||"electron"===o||"node-webkit"===o)r.runtime=o;else if("napi"===o)r.napi=!0;else if("abi"===o.slice(0,3))r.abi=o.slice(3);else if("uv"===o.slice(0,2))r.uv=o.slice(2);else if("armv"===o.slice(0,4))r.armv=o.slice(4);else{if("glibc"!==o&&"musl"!==o)continue;r.libc=o}r.specificity++}return r}}function E(e,t){return function(r){return!(null==r||r.runtime&&r.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(r)||r.abi&&r.abi!==t&&!r.napi||r.uv&&r.uv!==m||r.armv&&r.armv!==p||r.libc&&r.libc!==d)}}function C(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=g,g.resolve=g.path=function(e){e=o.resolve(e||".");try{var t=s(o.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"])}catch(e){}if(!c){var r=v(o.join(e,"build/Release"),b);if(r)return r;var n=v(o.join(e,"build/Debug"),b);if(n)return n}var i=O(e);if(i)return i;var a=O(o.dirname(process.execPath));if(a)return a;var g=["platform="+f,"arch="+l,"runtime="+h,"abi="+u,"uv="+m,p?"armv="+p:"","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 "+g+"\n loaded from: "+e+"\n");function O(e){var t=y(o.join(e,"prebuilds")).map(w).filter(k(f,l)).sort(S)[0];if(t){var r=o.join(e,"prebuilds",t.name),n=y(r).map(_).filter(E(h,u)).sort(C(h))[0];return n?o.join(r,n.file):void 0}}},g.parseTags=_,g.matchTags=E,g.compareTags=C,g.parseTuple=w,g.matchTuple=k,g.compareTuples=S},9551(e,t,r){"use strict";var n=r(7342);function o(){}var i=null,s={};function a(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("Promise constructor's argument is not a function");this._x=0,this._y=0,this._z=null,this._A=null,e!==o&&d(e,this)}function c(e,t){for(;3===e._y;)e=e._z;if(a._B&&a._B(e),0===e._y)return 0===e._x?(e._x=1,void(e._A=t)):1===e._x?(e._x=2,void(e._A=[e._A,t])):void e._A.push(t);!function(e,t){n(function(){var r=1===e._y?t.onFulfilled:t.onRejected;if(null!==r){var n=function(e,t){try{return e(t)}catch(e){return i=e,s}}(r,e._z);n===s?h(t.promise,i):u(t.promise,n)}else 1===e._y?u(t.promise,e._z):h(t.promise,e._z)})}(e,t)}function u(e,t){if(t===e)return h(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){var r=function(e){try{return e.then}catch(e){return i=e,s}}(t);if(r===s)return h(e,i);if(r===e.then&&t instanceof a)return e._y=3,e._z=t,void l(e);if("function"==typeof r)return void d(r.bind(t),e)}e._y=1,e._z=t,l(e)}function h(e,t){e._y=2,e._z=t,a._C&&a._C(e,t),l(e)}function l(e){if(1===e._x&&(c(e,e._A),e._A=null),2===e._x){for(var t=0;t<e._A.length;t++)c(e,e._A[t]);e._A=null}}function f(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function d(e,t){var r=!1,n=function(e){try{e(function(e){r||(r=!0,u(t,e))},function(e){r||(r=!0,h(t,e))})}catch(e){return i=e,s}}(e);r||n!==s||(r=!0,h(t,i))}e.exports=a,a._B=null,a._C=null,a._D=o,a.prototype.then=function(e,t){if(this.constructor!==a)return function(e,t,r){return new e.constructor(function(n,i){var s=new a(o);s.then(n,i),c(e,new f(t,r,s))})}(this,e,t);var r=new a(o);return c(this,new f(e,t,r)),r}},5556(e,t,r){"use strict";var n=r(9551);e.exports=n,n.prototype.done=function(e,t){(arguments.length?this.then.apply(this,arguments):this).then(null,function(e){setTimeout(function(){throw e},0)})}},8635(e,t,r){"use strict";var n=r(9551);e.exports=n;var o=h(!0),i=h(!1),s=h(null),a=h(void 0),c=h(0),u=h("");function h(e){var t=new n(n._D);return t._y=1,t._z=e,t}n.resolve=function(e){if(e instanceof n)return e;if(null===e)return s;if(void 0===e)return a;if(!0===e)return o;if(!1===e)return i;if(0===e)return c;if(""===e)return u;if("object"==typeof e||"function"==typeof e)try{var t=e.then;if("function"==typeof t)return new n(t.bind(e))}catch(e){return new n(function(t,r){r(e)})}return h(e)};var l=function(e){return"function"==typeof Array.from?(l=Array.from,Array.from(e)):(l=function(e){return Array.prototype.slice.call(e)},Array.prototype.slice.call(e))};function f(e){return{status:"fulfilled",value:e}}function d(e){return{status:"rejected",reason:e}}function p(e){if(e&&("object"==typeof e||"function"==typeof e)){if(e instanceof n&&e.then===n.prototype.then)return e.then(f,d);var t=e.then;if("function"==typeof t)return new n(t.bind(e)).then(f,d)}return f(e)}function m(e){if("function"==typeof AggregateError)return new AggregateError(e,"All promises were rejected");var t=new Error("All promises were rejected");return t.name="AggregateError",t.errors=e,t}n.all=function(e){var t=l(e);return new n(function(e,r){if(0===t.length)return e([]);var o=t.length;function i(s,a){if(a&&("object"==typeof a||"function"==typeof a)){if(a instanceof n&&a.then===n.prototype.then){for(;3===a._y;)a=a._z;return 1===a._y?i(s,a._z):(2===a._y&&r(a._z),void a.then(function(e){i(s,e)},r))}var c=a.then;if("function"==typeof c)return void new n(c.bind(a)).then(function(e){i(s,e)},r)}t[s]=a,0===--o&&e(t)}for(var s=0;s<t.length;s++)i(s,t[s])})},n.allSettled=function(e){return n.all(l(e).map(p))},n.reject=function(e){return new n(function(t,r){r(e)})},n.race=function(e){return new n(function(t,r){l(e).forEach(function(e){n.resolve(e).then(t,r)})})},n.prototype.catch=function(e){return this.then(null,e)},n.any=function(e){return new n(function(t,r){var o=l(e),i=!1,s=[];function a(e){i||(i=!0,t(e))}function c(e){s.push(e),s.length===o.length&&r(m(s))}0===o.length?r(m(s)):o.forEach(function(e){n.resolve(e).then(a,c)})})}},4293(e,t,r){"use strict";var n=r(9551);e.exports=n,n.prototype.finally=function(e){return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})})}},7706(e,t,r){"use strict";e.exports=r(9551),r(5556),r(4293),r(8635),r(9791),r(1727)},9791(e,t,r){"use strict";var n=r(9551),o=r(983);e.exports=n,n.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?function(e,t){for(var r=[],o=0;o<t;o++)r.push("a"+o);var s=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([i]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}(e,t):function(e){for(var t=Math.max(e.length-1,3),r=[],o=0;o<t;o++)r.push("a"+o);var s=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+i+";","var res;","switch (argLength) {",r.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(r.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(n,e)}(e)};var i="function (err, res) {if (err) { rj(err); } else { rs(res); }}";n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),r="function"==typeof t[t.length-1]?t.pop():null,i=this;try{return e.apply(this,arguments).nodeify(r,i)}catch(e){if(null==r)return new n(function(t,r){r(e)});o(function(){r.call(i,e)})}}},n.prototype.nodeify=function(e,t){if("function"!=typeof e)return this;this.then(function(r){o(function(){e.call(t,null,r)})},function(r){o(function(){e.call(t,r)})})}},1727(e,t,r){"use strict";var n=r(9551);e.exports=n,n.enableSynchronous=function(){n.prototype.isPending=function(){return 0==this.getState()},n.prototype.isFulfilled=function(){return 1==this.getState()},n.prototype.isRejected=function(){return 2==this.getState()},n.prototype.getValue=function(){if(3===this._y)return this._z.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._z},n.prototype.getReason=function(){if(3===this._y)return this._z.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._z},n.prototype.getState=function(){return 3===this._y?this._z.getState():-1===this._y||-2===this._y?0:this._y}},n.disableSynchronous=function(){n.prototype.isPending=void 0,n.prototype.isFulfilled=void 0,n.prototype.isRejected=void 0,n.prototype.getValue=void 0,n.prototype.getReason=void 0,n.prototype.getState=void 0}},4527(e,t,r){var n=r(9225).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)}},6556(e){"use strict";e.exports=function(e){const t=e.length;let r=0;for(;r<t;)if(128&e[r])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}else r++;return!0}},3148(e,t,r){"use strict";try{e.exports=r(8169)(__dirname)}catch(t){e.exports=r(6556)}},5488(e,t,r){e.exports=r(907)},4194(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},8828(e,t,r){var n=r(4552),o=r(4527),i=r(1909);const s=0,a=1,c=2,u=3;function h(e,t,r,o,a,c){i.EventTarget.call(this),(c=c||{}).assembleFragments=!0;var u=this;this._url=e,this._readyState=s,this._protocol=void 0,this._extensions="",this._bufferedAmount=0,this._binaryType="arraybuffer",this._connection=void 0,this._client=new n(c),this._client.on("connect",function(e){d.call(u,e)}),this._client.on("connectFailed",function(){p.call(u)}),this._client.connect(e,t,r,o,a)}function l(e,t){var r=new i.Event("close");return r.code=e,r.reason=t,r.wasClean=void 0===e||1e3===e,r}function f(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){m.call(t,e,r)}),this._connection.on("message",function(e){g.call(t,e)}),this.dispatchEvent(new i.Event("open"))}function p(){y.call(this),this._readyState=u;try{this.dispatchEvent(new i.Event("error"))}finally{this.dispatchEvent(l(1006,"connection failed"))}}function m(e,t){y.call(this),this._readyState=u,this.dispatchEvent(l(e,t||""))}function g(e){if(e.utf8Data)this.dispatchEvent(f(e.utf8Data));else if(e.binaryData&&"arraybuffer"===this.binaryType){for(var t=e.binaryData,r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0,i=t.length;o<i;++o)n[o]=t[o];this.dispatchEvent(f(r))}}function y(){this._client.removeAllListeners(),this._connection&&this._connection.removeAllListeners()}e.exports=h,Object.defineProperties(h.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(h.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",s],["OPEN",a],["CLOSING",c],["CLOSED",u]].forEach(function(e){Object.defineProperty(h.prototype,e[0],{get:function(){return e[1]}})}),[["CONNECTING",s],["OPEN",a],["CLOSING",c],["CLOSED",u]].forEach(function(e){Object.defineProperty(h,e[0],{get:function(){return e[1]}})}),h.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=o(e),this._connection.sendBytes(e)}},h.prototype.close=function(e,t){switch(this._readyState){case s:p.call(this),this._client.on("connect",function(r){e?r.close(e,t):r.close()});break;case a:this._readyState=c,e?this._connection.close(e,t):this._connection.close()}}},4552(e,t,r){var n=r(5237),o=n.extend,i=r(9023),s=r(4434).EventEmitter,a=r(8611),c=r(5692),u=r(7016),h=r(6982),l=r(2819),f=n.bufferAllocUnsafe,d=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],p=["hostname","port","method","path","headers"];function m(e){var t;switch(s.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={},o(this.config,e),o(this.config.tlsOptions,t)),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(m,s),m.prototype.connect=function(e,t,r,i,s){var h=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?u.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 l=f(16),m=0;m<16;m++)l[m]=Math.round(255*Math.random());this.base64nonce=l.toString("base64");var g=this.url.hostname;("ws:"===this.url.protocol&&"80"!==this.url.port||"wss:"===this.url.protocol&&"443"!==this.url.port)&&(g+=":"+this.url.port);var y,v={};function b(e){h._req=null,h.emit("connectFailed",e)}this.secure&&this.config.tlsOptions.hasOwnProperty("headers")&&o(v,this.config.tlsOptions.headers),i&&o(v,i),o(v,{Upgrade:"websocket",Connection:"Upgrade","Sec-WebSocket-Version":this.config.webSocketVersion.toString(10),"Sec-WebSocket-Key":this.base64nonce,Host:v.Host||g}),this.protocols.length>0&&(v["Sec-WebSocket-Protocol"]=this.protocols.join(", ")),this.origin&&(13===this.config.webSocketVersion?v.Origin=this.origin:8===this.config.webSocketVersion&&(v["Sec-WebSocket-Origin"]=this.origin)),y=this.url.pathname?this.url.path:this.url.path?"/"+this.url.path:"/";var w={agent:!1};if(s&&o(w,s),o(w,{hostname:this.url.hostname,port:this.url.port,method:"GET",path:y,headers:v}),this.secure){var k=this.config.tlsOptions;for(var S in k)k.hasOwnProperty(S)&&-1===p.indexOf(S)&&(w[S]=k[S])}var _=this._req=(this.secure?c:a).request(w);_.on("upgrade",function(e,t,r){h._req=null,_.removeListener("error",b),h.socket=t,h.response=e,h.firstDataChunk=r,h.validateHandshake()}),_.on("error",b),_.on("response",function(e){if(h._req=null,n.eventEmitterListenerCount(h,"httpResponse")>0)h.emit("httpResponse",e,h),e.socket&&e.socket.end();else{var t=[];for(var r in e.headers)t.push(r+": "+e.headers[r]);h.failHandshake("Server responded with a non-101 status: "+e.statusCode+" "+e.statusMessage+"\nResponse Headers Follow:\n"+t.join("\n")+"\n")}}),_.end()},m.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=h.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")},m.prototype.failHandshake=function(e){this.socket&&this.socket.writable&&this.socket.end(),this.emit("connectFailed",new Error(e))},m.prototype.succeedHandshake=function(){var e=new l(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},m.prototype.abort=function(){this._req&&this._req.abort()},e.exports=m},2819(e,t,r){var n=r(9023),o=r(5237),i=r(4434).EventEmitter,s=r(1338),a=r(3603),c=r(3148),u=o.bufferAllocUnsafe,h=o.bufferFromString;const l="open",f="peer_requested_close",d="ending",p="closed";var m="setImmediate"in global?global.setImmediate.bind(global):process.nextTick.bind(process),g=0;function y(e,t,r,n,c){if(this._debug=o.BufferingLogger("websocket:connection",++g),this._debug("constructor"),this._debug.enabled&&function(e,t){if(e._debug.enabled){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=c,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=u(4),this.frameHeader=u(10),this.bufferList=new a,this.currentFrame=new s(this.maskBytes,this.frameHeader,this.config),this.fragmentationSize=0,this.frameQueue=[],this.connected=!0,this.state=l,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 v(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)}y.CLOSE_REASON_NORMAL=1e3,y.CLOSE_REASON_GOING_AWAY=1001,y.CLOSE_REASON_PROTOCOL_ERROR=1002,y.CLOSE_REASON_UNPROCESSABLE_INPUT=1003,y.CLOSE_REASON_RESERVED=1004,y.CLOSE_REASON_NOT_PROVIDED=1005,y.CLOSE_REASON_ABNORMAL=1006,y.CLOSE_REASON_INVALID_DATA=1007,y.CLOSE_REASON_POLICY_VIOLATION=1008,y.CLOSE_REASON_MESSAGE_TOO_BIG=1009,y.CLOSE_REASON_EXTENSION_REQUIRED=1010,y.CLOSE_REASON_INTERNAL_SERVER_ERROR=1011,y.CLOSE_REASON_TLS_HANDSHAKE_FAILED=1015,y.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(y,i),y.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))},y.prototype.setKeepaliveTimer=function(){this._debug("setKeepaliveTimer"),this.config.keepalive&&!this.config.useNativeKeepalive&&(this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this._keepaliveTimeoutID=setTimeout(this._keepaliveTimerHandler,this.config.keepaliveInterval))},y.prototype.clearKeepaliveTimer=function(){this._keepaliveTimeoutID&&clearTimeout(this._keepaliveTimeoutID)},y.prototype.handleKeepaliveTimer=function(){this._debug("handleKeepaliveTimer"),this._keepaliveTimeoutID=null,this.ping(),this.config.dropConnectionOnKeepaliveTimeout?this.setGracePeriodTimer():this.setKeepaliveTimer()},y.prototype.setGracePeriodTimer=function(){this._debug("setGracePeriodTimer"),this.clearGracePeriodTimer(),this._gracePeriodTimeoutID=setTimeout(this._gracePeriodTimerHandler,this.config.keepaliveGracePeriod)},y.prototype.clearGracePeriodTimer=function(){this._gracePeriodTimeoutID&&clearTimeout(this._gracePeriodTimeoutID)},y.prototype.handleGracePeriodTimer=function(){this._debug("handleGracePeriodTimer"),this._gracePeriodTimeoutID=null,this.drop(y.CLOSE_REASON_ABNORMAL,"Peer not responding.",!0)},y.prototype.handleSocketData=function(e){this._debug("handleSocketData"),this.setKeepaliveTimer(),this.bufferList.write(e),this.processReceivedData()},y.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(y.CLOSE_REASON_PROTOCOL_ERROR,e.dropReason)});if(e.frameTooLarge)return this._debug("-- frame too large"),void process.nextTick(function(){t.drop(y.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(y.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 s(this.maskBytes,this.frameHeader,this.config),this.bufferList.length>0&&m(this.receivedDataHandler)}else this._debug("-- insufficient data for frame")}},y.prototype.handleSocketError=function(e){this._debug("handleSocketError: %j",e),this.state!==p?(this.closeReasonCode=y.CLOSE_REASON_ABNORMAL,this.closeDescription="Socket Error: "+e.syscall+" "+e.code,this.connected=!1,this.state=p,this.fragmentationSize=0,o.eventEmitterListenerCount(this,"error")>0&&this.emit("error",e),this.socket.destroy(),this._debug.printOutput()):this._debug(" --- Socket 'error' after 'close'")},y.prototype.handleSocketEnd=function(){this._debug("handleSocketEnd: received socket end. state = %s",this.state),this.receivedEnd=!0,this.state!==p?this.state!==f&&this.state!==d&&(this._debug(" --- UNEXPECTED socket end."),this.socket.end()):this._debug(" --- Socket 'end' after 'close'")},y.prototype.handleSocketClose=function(e){this._debug("handleSocketClose: received socket close"),this.socketHadError=e,this.connected=!1,this.state=p,-1===this.closeReasonCode&&(this.closeReasonCode=y.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))},y.prototype.handleSocketDrain=function(){this._debug("handleSocketDrain: socket drain event"),this.outputBufferFull=!1,this.emit("drain")},y.prototype.handleSocketPause=function(){this._debug("handleSocketPause: socket pause event"),this.inputPaused=!0,this.emit("pause")},y.prototype.handleSocketResume=function(){this._debug("handleSocketResume: socket resume event"),this.inputPaused=!1,this.emit("resume"),this.processReceivedData()},y.prototype.pause=function(){this._debug("pause: pause requested"),this.socket.pause()},y.prototype.resume=function(){this._debug("resume: resume requested"),this.socket.resume()},y.prototype.close=function(e,t){if(this.connected){if(this._debug("close: Initating clean WebSocket close sequence."),"number"!=typeof e&&(e=y.CLOSE_REASON_NORMAL),!v(e))throw new Error("Close code "+e+" is not valid.");"string"!=typeof t&&(t=y.CLOSE_DESCRIPTIONS[e]),this.closeReasonCode=e,this.closeDescription=t,this.setCloseTimer(),this.sendCloseFrame(this.closeReasonCode,this.closeDescription),this.state=d,this.connected=!1}},y.prototype.drop=function(e,t,r){this._debug("drop"),"number"!=typeof e&&(e=y.CLOSE_REASON_PROTOCOL_ERROR),"string"!=typeof t&&(t=y.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=p,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()},y.prototype.setCloseTimer=function(){this._debug("setCloseTimer"),this.clearCloseTimer(),this._debug("Setting close timer"),this.waitingForCloseResponse=!0,this.closeTimer=setTimeout(this._closeTimerHandler,this.closeTimeout)},y.prototype.clearCloseTimer=function(){this._debug("clearCloseTimer"),this.closeTimer&&(this._debug("Clearing close timer"),clearTimeout(this.closeTimer),this.waitingForCloseResponse=!1,this.closeTimer=null)},y.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=p,this.socket.end())},y.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(y.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(!c(e.binaryPayload))return void this.drop(y.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(y.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected Continuation Frame");if(this.fragmentationSize+=e.length,this.fragmentationSize>this.maxReceivedMessageSize)return void this.drop(y.CLOSE_REASON_MESSAGE_TOO_BIG,"Maximum message size exceeded.");if(this.frameQueue.push(e),e.fin){var t=0,r=u(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(!c(r))return void this.drop(y.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.emit("message",{type:"utf8",utf8Data:r.toString("utf8")});break;default:return void this.drop(y.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 o=!1;this.emit("ping",function(){o=!0},e.binaryPayload),o||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=p,void this.socket.end();var i;if(this._debug("---- Closing handshake initiated by peer."),this.state=f,e.invalidCloseFrameLength?(this.closeReasonCode=1005,i=y.CLOSE_REASON_PROTOCOL_ERROR):-1===e.closeStatus||v(e.closeStatus)?(this.closeReasonCode=e.closeStatus,i=y.CLOSE_REASON_NORMAL):(this.closeReasonCode=e.closeStatus,i=y.CLOSE_REASON_PROTOCOL_ERROR),e.binaryPayload.length>1){if(!c(e.binaryPayload))return void this.drop(y.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.closeDescription=e.binaryPayload.toString("utf8")}else this.closeDescription=y.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(y.CLOSE_REASON_PROTOCOL_ERROR,"Unrecognized Opcode: 0x"+e.opcode.toString(16))}},y.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)}},y.prototype.sendUTF=function(e,t){e=h(e.toString(),"utf8"),this._debug("sendUTF: %d bytes",e.length);var r=new s(this.maskBytes,this.frameHeader,this.config);r.opcode=1,r.binaryPayload=e,this.fragmentAndSend(r,t)},y.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 s(this.maskBytes,this.frameHeader,this.config);r.opcode=2,r.binaryPayload=e,this.fragmentAndSend(r,t)},y.prototype.ping=function(e){this._debug("ping");var t=new s(this.maskBytes,this.frameHeader,this.config);t.opcode=9,t.fin=!0,e&&(Buffer.isBuffer(e)||(e=h(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)},y.prototype.pong=function(e){this._debug("pong");var t=new s(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)},y.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 o=Math.ceil(n/r),i=0,a=function(e){e?"function"==typeof t&&(t(e),t=null):++i===o&&"function"==typeof t&&t()},c=1;c<=o;c++){var u=new s(this.maskBytes,this.frameHeader,this.config);u.opcode=1===c?e.opcode:0,u.fin=c===o;var h=c===o?n-r*(c-1):r,l=r*(c-1);u.binaryPayload=e.binaryPayload.slice(l,l+h),this.sendFrame(u,a)}},y.prototype.sendCloseFrame=function(e,t,r){if("number"!=typeof e&&(e=y.CLOSE_REASON_NORMAL),this._debug("sendCloseFrame state: %s, reasonCode: %d, description: %s",this.state,e,t),this.state===l||this.state===f){var n=new s(this.maskBytes,this.frameHeader,this.config);n.fin=!0,n.opcode=8,n.closeStatus=e,"string"==typeof t&&(n.binaryPayload=h(t,"utf8")),this.sendFrame(n,r),this.socket.end()}},y.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=y},1338(e,t,r){var n=r(2627),o=r(5237).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=o(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=o(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,s=2,a=0,c=0;this.fin&&(a|=128),this.rsv1&&(a|=64),this.rsv2&&(a|=32),this.rsv3&&(a|=16),this.mask&&(c|=128),a|=15&this.opcode,8===this.opcode?(this.length=2,this.binaryPayload&&(this.length+=this.binaryPayload.length),(r=o(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?c|=127&this.length:this.length>125&&this.length<=65535?(c|=126,s+=2):this.length>65535&&(c|=127,s+=8);var u=o(this.length+s+(this.mask?4:0));return u[0]=a,u[1]=c,i=2,this.length>125&&this.length<=65535?(u.writeUInt16BE(this.length,i),i+=2):this.length>65535&&(u.writeUInt32BE(0,i),u.writeUInt32BE(this.length,i+4),i+=8),this.mask?(t=e?0:4294967295*Math.random()>>>0,this.maskBytes.writeUInt32BE(t,0),this.maskBytes.copy(u,i),i+=4,r&&n.mask(r,this.maskBytes,u,i,this.length)):r&&r.copy(u,i),u},i.prototype.toString=function(){return"Opcode: "+this.opcode+", fin: "+this.fin+", length: "+this.length+", hasPayload: "+Boolean(this.binaryPayload)+", masked: "+this.mask},e.exports=i},5334(e,t,r){for(var n=r(6982),o=r(9023),i=r(7016),s=r(4434).EventEmitter,a=r(2819),c=/,\s*/,u=/;\s*/,h=/[\r\n]/g,l=/,\s*/,f=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],d=[String.fromCharCode(127)],p=0;p<31;p++)d.push(String.fromCharCode(p));var m=/([\x00-\x20\x22\x28\x29\x2c\x2f\x3a-\x3f\x40\x5b-\x5e\x7b\x7d\x7f])/,g=/[^\x21\x23-\x2b\x2d-\x3a\x3c-\x5b\x5d-\x7e]/,y=/^"[^"]*"$/,v=/[\x00-\x20\x3b]/g,b=/[;,] */,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 k(e,t,r){s.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 S(e){process.nextTick(function(){e.drop(1006,"TCP connection lost before handshake completed.",!0)})}o.inherits(k,s),k.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"];if(this.protocolFullCaseMap={},this.requestedProtocols=[],n&&n.split(c).forEach(function(t){var r=t.toLocaleLowerCase();e.requestedProtocols.push(r),e.protocolFullCaseMap[r]=t}),!this.serverConfig.ignoreXForwardedFor&&t.headers["x-forwarded-for"]){var o=this.remoteAddress;this.remoteAddresses=t.headers["x-forwarded-for"].split(l),this.remoteAddresses.push(o),this.remoteAddress=this.remoteAddresses[0]}if(this.serverConfig.parseExtensions){var s=t.headers["sec-websocket-extensions"];this.requestedExtensions=this.parseExtensions(s)}else this.requestedExtensions=[];if(this.serverConfig.parseCookies){var a=t.headers.cookie;this.cookies=this.parseCookies(a)}else this.cookies=[]},k.prototype.parseExtensions=function(e){if(!e||0===e.length)return[];var t=e.toLocaleLowerCase().split(c);return t.forEach(function(e,t,r){var n=e.split(u),o=n[0],i=n.slice(1);i.forEach(function(e,t,r){var n=e.split("="),o={name:n[0],value:n[1]};r.splice(t,1,o)});var s={name:o,params:i};r.splice(t,1,s)}),t},k.prototype.parseCookies=function(e){if(!e||"string"!=typeof e)return[];var t=[];return e.split(b).forEach(function(e){var r=e.indexOf("=");if(-1!==r){var n=e.substr(0,r).trim(),o=e.substr(++r,e.length).trim();'"'===o[0]&&(o=o.slice(1,-1)),t.push({name:n,value:decodeURIComponent(o)})}else t.push({name:e,value:null})}),t},k.prototype.accept=function(e,t,r){var o;this._verifyResolution(),e?void 0===(o=this.protocolFullCaseMap[e.toLocaleLowerCase()])&&(o=e):o=e,this.protocolFullCaseMap=null;var i=n.createHash("sha1");i.update(this.key+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s="HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "+i.digest("base64")+"\r\n";if(o){for(var c=0;c<o.length;c++){var u=o.charCodeAt(c),l=o.charAt(c);if(u<33||u>126||-1!==f.indexOf(l))throw this.reject(500),new Error('Illegal character "'+String.fromCharCode(l)+'" in subprotocol.')}if(-1===this.requestedProtocols.indexOf(e))throw this.reject(500),new Error("Specified protocol was not requested by the client.");o=o.replace(h,""),s+="Sec-WebSocket-Protocol: "+o+"\r\n"}if(this.requestedProtocols=null,t&&(t=t.replace(h,""),13===this.webSocketVersion?s+="Origin: "+t+"\r\n":8===this.webSocketVersion&&(s+="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(v,""),e.value=e.value.replace(v,""),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(m);if(t)throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie name");if(t=e.value.match(y)?e.value.slice(1,-1).match(g):e.value.match(g))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(v))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(v))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")}s+="Set-Cookie: "+r.join(";")+"\r\n"}.bind(this))}this._resolved=!0,this.emit("requestResolved",this),s+="\r\n";var p=new a(this.socket,[],e,!1,this.serverConfig);p.webSocketVersion=this.webSocketVersion,p.remoteAddress=this.remoteAddress,p.remoteAddresses=this.remoteAddresses;var b=this;return this._socketIsClosing?S(p):this.socket.write(s,"ascii",function(e){e?S(p):(b._removeSocketCloseListeners(),p._addSocketEventListeners())}),this.emit("requestAccepted",p),p},k.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(h,""))+"\r\n"),r)for(var o in r){var i=r[o].toString().replace(h,"");n+=o.replace(h,"")+": "+i+"\r\n"}n+="\r\n",this.socket.end(n,"ascii"),this.emit("requestRejected",this)},k.prototype._handleSocketCloseBeforeAccept=function(){this._socketIsClosing=!0,this._removeSocketCloseListeners()},k.prototype._removeSocketCloseListeners=function(){this.socket.removeListener("end",this._socketCloseHandler),this.socket.removeListener("close",this._socketCloseHandler)},k.prototype._verifyResolution=function(){if(this._resolved)throw new Error("WebSocketRequest may only be accepted or rejected one time.")},e.exports=k},9834(e,t,r){var n=r(5237).extend,o=r(9023),i=r(4434).EventEmitter,s=r(7705);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)}o.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 o=this.handlers[r];if(o.pathString===e&&o.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(),o=0,i=this.handlers.length;o<i;o++){var a=this.handlers[o];if(a.path.test(e.resourceURL.pathname)&&(n===a.protocol||"*"===a.protocol)){var c=new s(e,n);return void a.callback(c)}}e.reject(404,"No handler is available for the given request.")},e.exports=a},7705(e,t,r){var n=r(9023),o=r(4434).EventEmitter;function i(e,t){o.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,o),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},7788(e,t,r){var n=r(5237).extend,o=r(5237),i=r(9023),s=r(5753)("websocket:server"),a=r(4434).EventEmitter,c=r(5334),u=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(u,a),u.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)})},u.prototype.unmount=function(){var e=this._handlers.upgrade;this.config.httpServer.forEach(function(t){t.removeListener("upgrade",e)})},u.prototype.closeAllConnections=function(){this.connections.forEach(function(e){e.close()}),this.pendingRequests.forEach(function(e){process.nextTick(function(){e.reject(503)})})},u.prototype.broadcast=function(e){Buffer.isBuffer(e)?this.broadcastBytes(e):"function"==typeof e.toString&&this.broadcastUTF(e)},u.prototype.broadcastUTF=function(e){this.connections.forEach(function(t){t.sendUTF(e)})},u.prototype.broadcastBytes=function(e){this.connections.forEach(function(t){t.sendBytes(e)})},u.prototype.shutDown=function(){this.unmount(),this.closeAllConnections()},u.prototype.handleUpgrade=function(e,t){var r=this,n=new c(t,e,this.config);try{n.readHandshake()}catch(e){return n.reject(e.httpCode?e.httpCode:400,e.message,e.headers),s("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&&o.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.")},u.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)},u.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)},u.prototype.handleRequestResolved=function(e){var t=this.pendingRequests.indexOf(e);-1!==t&&this.pendingRequests.splice(t,1)},e.exports=u},5237(e,t,r){var n=t.noop=function(){};function o(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(4434).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(5753)(e);if(i.enabled){var s=new o(e,t,i),a=s.log.bind(s);return a.printOutput=s.printOutput.bind(s),a.enabled=i.enabled,a}return i.printOutput=n,i},o.prototype.log=function(){return this.buffer.push([new Date,Array.prototype.slice.call(arguments)]),this},o.prototype.clear=function(){return this.buffer=[],this},o.prototype.printOutput=function(e){e||(e=this.logFunction);var t=this.uniqueID;this.buffer.forEach(function(r){var n=r[0].toLocaleString(),o=r[1].slice(),i=o[0];null!=i&&(i="%s - %s - "+i.toString(),o.splice(0,1,i,n,t),e.apply(global,o))})}},9840(e,t,r){e.exports=r(9003).version},907(e,t,r){e.exports={...void r(7788),...void r(4552),...void r(9834),...void r(1338),...void r(5334),...void r(2819),w3cwebsocket:r(8828),...void r(4194),...void r(9840)}},3603(e,t,r){var n=r(181).Buffer,o=r(4434).EventEmitter,i=r(5237).bufferAllocUnsafe;function s(e){if(!(this instanceof s))return new s(e);o.call(this);var t=this;void 0===e&&(e={}),t.encoding=e.encoding;var r={next:null,buffer:null},a={next:null,buffer:null},c=0;t.__defineGetter__("length",function(){return c});var u=0;t.write=function(e){return r.buffer?(a.next={next:null,buffer:e},a=a.next):(r.buffer=e,a=r),c+=e.length,t.emit("write",e),!0},t.end=function(e){n.isBuffer(e)&&t.write(e)},t.push=function(){return[].concat.apply([],arguments).forEach(t.write),t},t.forEach=function(e){if(!r.buffer)return i(0);if(r.buffer.length-u<=0)return t;for(var n={buffer:r.buffer.slice(u),next:r.next};n&&n.buffer&&!e(n.buffer);)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 o=i(n-e),s=0;return t.forEach(function(t){if(e<s+t.length&&s<n&&t.copy(o,Math.max(0,s-e),Math.max(0,e-s),Math.min(t.length,n-s)),(s+=t.length)>n)return!0}),o},t.joinInto=function(e,n,o,s){if(!r.buffer)return new i(0);null==o&&(o=0),null==s&&(s=t.length);var a=e;if(a.length-n<s-o)throw new Error("Insufficient space available in target Buffer.");var c=0;return t.forEach(function(e){if(o<c+e.length&&c<s&&e.copy(a,Math.max(n,n+c-o),Math.max(0,o-c),Math.min(e.length,s-c)),(c+=e.length)>s)return!0}),a},t.advance=function(e){for(u+=e,c-=e;r.buffer&&u>=r.buffer.length;)u-=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){if(null==e?e=t.length:"number"!=typeof e&&(r=e,e=t.length),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=s,e.exports.BufferList=s,r(9023).inherits(s,o)},1909(e,t,r){e.exports={EventTarget:r(5384),Event:r(485)}},485(e){e.exports=function(e){this.type=e,this.isTrusted=!1,this._yaeti=!0}},5384(e){function t(){"function"!=typeof this.addEventListener&&(this._listeners={},this.addEventListener=r,this.removeEventListener=n,this.dispatchEvent=o)}function r(e,t){var r,n,o;if(e&&t){for(void 0===(r=this._listeners[e])&&(this._listeners[e]=r=[]),n=0;o=r[n];n++)if(o===t)return;r.push(t)}}function n(e,t){var r,n,o;if(e&&t&&void 0!==(r=this._listeners[e])){for(n=0;o=r[n];n++)if(o===t){r.splice(n,1);break}0===r.length&&delete this._listeners[e]}}function o(e){var t,r,n,o,i,s=!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(){s=!0}}catch(e){}for(t=e.type,r=this._listeners[t]||[],"function"==typeof(n=this["on"+t])&&n.call(this,e),o=0;(i=r[o])&&!s;o++)i.call(this,e);return!e.defaultPrevented}e.exports=t,Object.defineProperties(t.prototype,{listeners:{get:function(){return this._listeners}}})},3109(e,t,r){"use strict";const{parentPort:n,workerData:o}=r(8167),i=r(650);try{const e=Buffer.from(o.buffer),t=o.blockSizeMultiplier||9,r=Buffer.from(i.Bzip2.compressFile(e,void 0,t)),s=function(e,t){try{const r=Buffer.from(i.Bzip2.decompressFile(t));return r.length===e.length&&r.equals(e)?null:"decompressed output does not match the original data"}catch(e){return e&&e.message?e.message:String(e)}}(e,r);if(s)n.postMessage({ok:!1,verifyFailed:!0,error:s});else{const e=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);n.postMessage({ok:!0,buffer:e},[e])}}catch(e){n.postMessage({ok:!1,error:e&&e.message?e.message:String(e)})}},8803(e,t,r){"use strict";const n=r(9896),o=n.promises,i=r(6928),{Worker:s}=r(8167),a=r(3605),c=r(8330).rE,u=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],h=[{key:"backup_folder",title:"Folder to save backups in",help:"If empty, backups go to the extension's own log folder.",default_value:"",type:"string",optional:!0},{key:"compress_backup",title:"Compress backups to bz2 (much slower, but smaller file)",help:"Off by default: backups are saved as a .xml file -- faster (no compression step). Turn this on to compress to .xml.bz2 instead, it's noticeably slower.",default_value:!1,type:"boolean"},{key:"nick",title:"Your AirDC++ nickname (used in the backup filename)",help:"Leave empty to auto-detect. Fill in to force a specific name instead.",default_value:"",type:"string",optional:!0},{key:"exclude_virtual_folders",title:"Skip these virtual folders (comma-separated)",help:"Leave empty to back up everything.",default_value:"",type:"string",optional:!0},{key:"schedule_days",title:"Automatically back up on these days (comma-separated)",help:'English day names, e.g. "monday" or "monday,thursday".',default_value:"",type:"string",optional:!0},{key:"retention_days",title:"Delete backups older than this many days (0 = never)",help:"Checked after every backup (manual or automatic).",default_value:60,type:"number",min:0}];function l(e){return String(e).padStart(2,"0")}function f(e){return`${e.getFullYear()}-${l(e.getMonth()+1)}-${l(e.getDate())}`}function d(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function p(e){return new Promise(t=>setTimeout(t,e))}function m(e,t){return new Promise((r,n)=>{const o=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let i;try{i=new s(__filename,{workerData:{buffer:o,blockSizeMultiplier:t},transferList:[o]})}catch(e){return void n(e)}i.once("message",e=>{if(i.terminate().catch(()=>{}),e&&e.ok)r(Buffer.from(e.buffer));else{const t=new Error(e&&e.error||"bz2 compression failed for an unknown reason");e&&e.verifyFailed&&(t.verifyFailed=!0),n(t)}}),i.once("error",e=>{i.terminate().catch(()=>{}),n(e)})})}e.exports=function(e,t){const r=a(e,{extensionName:t.name,configFile:t.configPath+"config.json",configVersion:1,definitions:h});let s=!1,l="",g=null;async function y(t,r){try{await e.post("events",{text:`[Share-backup] ${t}`,severity:r||"info"})}catch(e){console.error(`Could not send system log message: ${e.message}`)}}function v(){return i.join(t.configPath,"share-backup-state.json")}function b(e){return String(e).replace(/[<>:"/\\|?*\x00-\x1f]/g,"_").trim()}async function w(t){let r=0;const n=[];for(;;){let o,i;for(let n=1;n<=5;n++)try{o=await e.post(`share/directories/by_real/content/${r}/1000`,{path:t}),i=null;break}catch(e){i=e,await p(300)}if(i)throw i;if(n.push(...o||[]),!o||o.length<1e3)break;r+=1e3}return n}async function k(e,t,r,n,o,i,s,a){if(s>60)return void await y(`Stopped descending at "${e}" -- reached the maximum folder depth (60). This can happen with a symlink loop on disk. Skipping the rest of this branch; the rest of the backup continues normally.`,"warning");const c=e.toLowerCase();if(i.has(c))return void await y(`Stopped descending at "${e}" -- this exact real path was already visited during this backup. This can happen with a symlink loop on disk. Skipping the rest of this branch; the rest of the backup continues normally.`,"warning");let u;i.add(c);try{u=await w(e)}catch(t){return void await y(`Could not read "${e}", skipping it: ${t&&t.message?t.message:t}`,"warning")}const h=u.filter(e=>e.type&&"directory"===e.type.id),l=u.filter(e=>!e.type||"directory"!==e.type.id);for(const e of l)t.write(`${r}<File Name="${d(e.name)}" Size="${e.size||0}" TTH="${e.tth||""}"/>\n`),n.files+=1,n.bytes+=e.size||0,o();for(const e of h){if(a.has((e.name||"").toLowerCase())){n.excluded+=1;continue}const c=e.time?` Date="${e.time}"`:"";t.write(`${r}<Directory Name="${d(e.name)}"${c}>\n`),n.dirs+=1,await k(e.path,t,r+"\t",n,o,i,s+1,a),t.write(`${r}</Directory>\n`)}}async function S(a,u){if(s)return void await y("A backup is already in progress, please wait for it to finish.","warning");s=!0;let h=null;try{const s="scheduled"===u?" (scheduled backup)":"";await y(`Backup started${a&&"/"!==a?` for "${a}"`:""}${s}...`,"info");const{nick:p,source:g}=await async function(){const t=(r.getValue("nick")||"").trim();if(t)return{nick:t,source:"manual"};const n=(await async function(){try{const t=await e.get("hubs");if(Array.isArray(t)&&t.length){const e=t.find(e=>e&&e.connect_state&&"connected"===e.connect_state.id&&e.settings&&e.settings.nick);if(e)return e.settings.nick;const r=t.find(e=>e&&e.settings&&e.settings.nick);if(r)return r.settings.nick}}catch(e){}try{const t=await e.get("settings");if(t&&t.nick)return t.nick}catch(e){}return""}()).trim();return n?{nick:n,source:"auto-detected"}:{nick:"Unknown",source:"fallback"}}();"auto-detected"===g?await y(`Using auto-detected nick "${p}" for the backup filename (set "Your AirDC++ nickname" to override).`,"info"):"fallback"===g&&await y(`Could not auto-detect a nick (no connected hub found) and none is set manually -- using placeholder name "${p}" instead. The backup still includes every file and folder; only the filename may not be recognized by AirDC++'s "Open filelist" until you set "Your AirDC++ nickname" or connect to a hub.`,"warning");const v=await async function(){return await e.get("share_roots")||[]}();if(!v.length)throw new Error("No shared folders found -- nothing to back up.");const S=function(e){const t=[],r=new Map;for(const n of e){const e=(n.virtual_name||"").toLowerCase();let o=r.get(e);o||(o={virtual_name:n.virtual_name,roots:[]},r.set(e,o),t.push(o)),o.roots.push(n)}return t}(v),_=(a||"/").trim().replace(/^\/+|\/+$/g,""),E=_?await async function(e,t){const r=e.split("/").map(e=>e.trim()).filter(Boolean);if(0===r.length)return null;const n=r[0].toLowerCase(),o=t.find(e=>(e.virtual_name||"").toLowerCase()===n);if(!o)throw new Error(`Could not find a share root named "${r[0]}"`);if(1===r.length)return{displayName:o.virtual_name,realPaths:o.roots.map(e=>e.path)};let i=o.roots[0].path,s=o.roots[0].virtual_name;for(let e=1;e<r.length;e++){const t=(await w(i)).find(t=>t.type&&"directory"===t.type.id&&(t.name||"").toLowerCase()===r[e].toLowerCase());if(!t)throw new Error(`Could not find subfolder "${r[e]}" inside "${r.slice(0,e).join("/")}"`);i=t.path,s=t.name}return{displayName:s,realPaths:[i]}}(_,S):null,C=(r.getValue("backup_folder")||"").trim()||i.join(t.logPath,"backups");await o.mkdir(C,{recursive:!0});const O=new Date;h=i.join(C,`.share-backup-${Date.now()}.tmp.xml`);const x=n.createWriteStream(h,{encoding:"utf8"});x.write('<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n'),x.write(`<FileListing Version="1" CID="${d(l)}" Base="${d(a||"/")}" BaseDate="${Math.floor(O.getTime()/1e3)}" Generator="ShareFixxers Share-Backup ${c}">\n`);const B=function(){const e=(r.getValue("exclude_virtual_folders")||"").trim();return e?new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean)):new Set}(),A={files:0,dirs:0,bytes:0,excluded:0};let R=Date.now();const T=()=>{const e=Date.now();e-R>=5e3&&(R=e,y(`Still working... ${A.files} files, ${A.dirs} folders so far.`,"info").catch(()=>{}))},M=new Set;if(E){x.write(`\t<Directory Name="${d(E.displayName)}">\n`),A.dirs+=1;for(const e of E.realPaths)await k(e,x,"\t\t",A,T,M,1,B);x.write("\t</Directory>\n")}else for(const e of S)if(B.has((e.virtual_name||"").toLowerCase()))A.excluded+=e.roots.length;else{x.write(`\t<Directory Name="${d(e.virtual_name)}">\n`),A.dirs+=1;for(const t of e.roots)await k(t.path,x,"\t\t",A,T,M,1,B);x.write("\t</Directory>\n")}x.write("</FileListing>\n"),await new Promise((e,t)=>{x.end(r=>r?t(r):e())});const F=await o.readFile(h),P=!!r.getValue("compress_backup");let I,L,N=!1;if(P){await y("Compressing the backup to bz2 (this can take a few minutes for a large share, running in the background)...","info");const e=await async function(e,t){try{return{compressed:await m(e,9)}}catch(e){if(!e.verifyFailed)throw e;await t(`bz2 self-verification failed on the first attempt (${e.message}) -- retrying with a different block size...`,"warning")}try{return{compressed:await m(e,3)}}catch(e){if(!e.verifyFailed)throw e;return await t(`bz2 self-verification failed again (${e.message}) -- saving this backup as an uncompressed .xml instead, so it's never silently corrupt. This is a known rare bug in the pure-JS bzip2 compressor on some large shares.`,"warning"),{fallbackToXml:!0}}}(F,y);I=e.compressed,L=e.fallbackToXml,N=!!e.fallbackToXml}else L=!0;const{dayFolder:D,filePath:j}=function(e,t,r){const n=i.join(e,f(t)),o=`${b(r)}.${b(l)}.xml.bz2`;return{dayFolder:n,filePath:i.join(n,o)}}(C,O,p);await o.mkdir(D,{recursive:!0});const U=L?j.replace(/\.xml\.bz2$/,".xml"):j;let q,z=!1;try{await o.access(U),z=!0}catch(e){}L?(await o.writeFile(U,F),q=F.length):(await o.writeFile(U,I),q=I.length),await o.unlink(h).catch(()=>{}),h=null;const $=await async function(e,t){if(!t||t<=0)return 0;const r=Date.now()-24*t*60*60*1e3;let n;try{n=await o.readdir(e,{withFileTypes:!0})}catch(e){return 0}let s=0;for(const t of n){if(!t.isDirectory())continue;const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.name);if(!n)continue;const a=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));if(Number.isNaN(a.getTime())||a.getTime()>=r)continue;const c=i.join(e,t.name);try{await o.rm(c,{recursive:!0,force:!0}),s+=1}catch(e){}}return s}(C,r.getValue("retention_days")),H=(q/1024/1024).toFixed(2),G=A.excluded>0?`, ${A.excluded} folder(s) skipped by name`:"",W=$>0?`, ${$} old backup(s) deleted`:"",V=z?", overwrote the previous backup already saved today":"",Y=P?N?" (uncompressed .xml -- bz2 verification failed, see warning above)":" (bz2)":" (uncompressed .xml)";await y(`Backup complete: ${A.files} files, ${A.dirs} folders, ${H} MB${Y}${G}${W}${V}. Saved to: ${U}`,"info")}catch(e){await y(`Backup failed: ${e&&e.message?e.message:e}`,"error")}finally{h&&await o.unlink(h).catch(()=>{}),s=!1}}async function _(){try{const t=await e.get("hash/stats");if(!t)return!1;const r="number"==typeof t.hash_files_left?t.hash_files_left:0,n="number"==typeof t.hashers?t.hashers:0;return r>0||n>0}catch(e){return!1}}function E(){try{const e=function(){const e=(r.getValue("schedule_days")||"").trim();if(!e)return new Set;const t=new Set;for(const r of e.split(",")){const e=r.trim().toLowerCase(),n=u.indexOf(e);n>=0&&t.add(n)}return t}();if(0===e.size)return;const o=new Date;if(!e.has(o.getDay()))return;const i=function(){try{return JSON.parse(n.readFileSync(v(),"utf8"))}catch(e){return{}}}(),s=f(o);if(i.lastAutoBackup===s)return;!function(e){try{n.writeFileSync(v(),JSON.stringify(e))}catch(e){console.error(`Could not save share-backup state: ${e.message}`)}}({...i,lastAutoBackup:s});const a="number"==typeof t.__hashWaitMaxMsOverride?t.__hashWaitMaxMsOverride:12e5;(async()=>{await async function(e){const r="number"==typeof t.__hashWaitPollMsOverride?t.__hashWaitPollMsOverride:15e3,n=Date.now();let o=!1;for(;Date.now()-n<e;){if(!await _())return;o||(await y('AirDC++ appears to still be hashing/refreshing the share (e.g. "Refresh share at startup") -- waiting for it to finish before starting the scheduled backup, so the snapshot is not taken mid-refresh...',"info"),o=!0),await p(r)}o&&await y("Still hashing after waiting -- starting the scheduled backup anyway rather than skipping it. It may include some entries that were not yet refreshed.","warning")}(a),await S("/","scheduled")})().catch(e=>console.error(`Scheduled backup error: ${e.message}`))}catch(e){console.error(`checkSchedule failed unexpectedly: ${e&&e.message?e.message:e}`)}}const C='\nShare-backup commands\n\n/sharebackup - Back up the whole share\n/sharebackup <path> - Back up only that share-relative folder (e.g. /Music/)\n\nSaves an XML snapshot (names, sizes, TTH) named <nick>.<CID>.xml, in a\nYYYY-MM-DD subfolder, openable directly with "Open filelist" in AirDC++ or most other DC++ clients.\nSchedule, retention, bz2 compression and excluded folders are all set in\nthis extension\'s Settings tab.',O=async(t,r,n)=>{if(t&&r)try{await e.post(`${t}/${r}/status_message`,{text:n,severity:"info"})}catch(e){console.error(`Could not send status message: ${e.message}`)}else await y(n,"info")},x=async(e,t,r)=>{const n=(t.command||"").toLowerCase(),o=t.args||[];if("sharebackup"===n){const t=o.join(" ").trim();if("help"===t.toLowerCase())return void await O(e,r,C);S(t||"/","manual").catch(e=>console.error(`Unexpected backup error: ${e.message}`))}else"sharebackuphelp"===n&&await O(e,r,C)};t.onStart=async n=>{l=n&&n.system_info&&n.system_info.cid||"",await r.load();const o=r.getValues();o&&void 0!==o.retention_days||await y("Warning: settings registration with AirDC++ appears to have failed -- no options will be visible or changeable in this extension's Settings tab, and default values will be used for everything. Check this extension's error.log for details, then restart AirDC++ to retry.","error");try{await e.addListener("hubs","hub_text_command",(e,t)=>x("hubs",e,t)),await e.addListener("private_chat","private_chat_text_command",(e,t)=>x("private_chat",e,t))}catch(e){console.error(`Could not register command listener: ${e.message}`)}const i="number"==typeof t.__startupGraceMsOverride?t.__startupGraceMsOverride:12e4,s=setTimeout(E,i);"function"==typeof s.unref&&s.unref(),g=setInterval(E,36e5),"function"==typeof g.unref&&g.unref(),await y(`Extension started (v${c}), command /sharebackup <path> is active. Type /sharebackuphelp for help.`,"info")},t.onStop=()=>{g&&(clearInterval(g),g=null)}}},9010(e,t,r){var n,o,i,s,a,c,u;e.exports=(n=r(6956),o=r(6015),i=console.assert.bind(console),s=function(e,t,r,n){var o;for(o=0;o<n;o++)t[o]=0;for(o=0;o<r;o++)t[e[o]]++},a=function(e,t,r,n){var o,i=0;if(n)for(o=0;o<r;o++)i+=e[o],t[o]=i;else for(o=0;o<r;o++)i+=e[o],t[o]=i-e[o]},c=function(e,t,r,n,u,h){var l,f,d,p,m,g,y,v,b,w,k,S,_,E=0,C=0;for(u<=256?(l=o.makeS32Buffer(u),u<=r?(f=t.subarray(n+r-u),C=1):(f=o.makeS32Buffer(u),C=3)):u<=r?(l=t.subarray(n+r-u),u<=r-u?(f=t.subarray(n+r-2*u),C=0):u<=1024?(f=o.makeS32Buffer(u),C=2):(f=l,C=8)):(l=f=o.makeS32Buffer(u),C=12),s(e,l,n,u),a(l,f,u,!0),p=0;p<n;p++)t[p]=0;g=-1,p=n-1,m=n,y=0,S=e[n-1];do{_=S}while(--p>=0&&(S=e[p])>=_);for(;p>=0;){do{_=S}while(--p>=0&&(S=e[p])<=_);if(p>=0){g>=0&&(t[g]=m),g=--f[_],m=p,++y;do{_=S}while(--p>=0&&(S=e[p])>=_)}}if(y>1?(function(e,t,r,n,o,c){var u,h,l,f,d;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],l--,t[u++]=e[l]<d?~l:l,h=0;h<o;h++)(l=t[h])>0?(i(e[l]>=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(h<u),l--,t[u++]=e[l]<d?~l:l,t[h]=0):l<0&&(t[h]=~l);for(r===n&&s(e,r,o,c),a(r,n,c,1),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0&&(i(e[l]<=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(u<=h),l--,t[--u]=e[l]>d?~(l+1):l,t[h]=0)}(e,t,l,f,n,u),w=function(e,t,r,n){var o,s,a,c,u,h,l,f,d,p;for(i(r>0),o=0;(a=t[o])<0;o++)t[o]=~a,i(o+1<r);if(o<n)for(s=o,o++;i(o<r),!((a=t[o])<0&&(t[s++]=~a,t[o]=0,s===n));o++);f=e[o=s=r-1];do{d=f}while(--o>=0&&(f=e[o])>=d);for(;o>=0;){do{d=f}while(--o>=0&&(f=e[o])<=d);if(o>=0){t[n+(o+1>>>1)]=s-o,s=o+1;do{d=f}while(--o>=0&&(f=e[o])>=d)}}for(o=0,l=0,c=r,h=0;o<n;o++){if(p=!0,(u=t[n+((a=t[o])>>>1)])===h&&c+u<r){for(s=0;s<u&&e[a+s]===e[c+s];)s++;s===u&&(p=!1)}p&&(l++,c=a,h=u),t[n+(a>>>1)]=l}return l}(e,t,n,y)):1===y?(t[g]=m+1,w=1):w=0,w<y){for(4&C&&(l=null,f=null),2&C&&(f=null),k=n+r-2*y,13&C||(u+w<=k?k-=u:C|=8),i(n>>>1<=k+y),p=y+(n>>>1)-1,m=2*y+k-1;y<=p;p--)0!==t[p]&&(t[m--]=t[p]-1);d=t.subarray(y+k),c(d,t,k,y,w,!1),d=null,p=n-1,m=2*y-1,S=e[n-1];do{_=S}while(--p>=0&&(S=e[p])>=_);for(;p>=0;){do{_=S}while(--p>=0&&(S=e[p])<=_);if(p>=0){t[m--]=p+1;do{_=S}while(--p>=0&&(S=e[p])>=_)}}for(p=0;p<y;p++)t[p]=t[y+t[p]];4&C&&(l=f=o.makeS32Buffer(u)),2&C&&(f=o.makeS32Buffer(u))}if(8&C&&s(e,l,n,u),y>1){a(l,f,u,!0),p=y-1,m=n,_=e[v=t[y-1]];do{for(b=f[S=_];b<m;)t[--m]=0;do{if(t[--m]=v,--p<0)break;v=t[p]}while((_=e[v])===S)}while(p>=0);for(;m>0;)t[--m]=0}return h?E=function(e,t,r,n,o,c){var u,h,l,f,d,p=-1;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],t[u++]=l>0&&e[l-1]<d?~l:l,h=0;h<o;h++)(l=t[h])>0?(l--,i(e[l]>=e[l+1]),t[h]=~(f=e[l]),f!==d&&(n[d]=u,u=n[d=f]),i(h<u),t[u++]=l>0&&e[l-1]<d?~l:l):0!==l&&(t[h]=~l);for(r===n&&s(e,r,o,c),a(r,n,c,!0),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0?(l--,i(e[l]<=e[l+1]),t[h]=f=e[l],f!==d&&(n[d]=u,u=n[d=f]),i(u<=h),t[--u]=l>0&&e[l-1]>d?~e[l-1]:l):0!==l?t[h]=~l:p=h;return p}(e,t,l,f,n,u):function(e,t,r,n,o,c){var u,h,l,f,d;for(r===n&&s(e,r,o,c),a(r,n,c,!1),u=n[d=e[l=o-1]],t[u++]=l>0&&e[l-1]<d?~l:l,h=0;h<o;h++)l=t[h],t[h]=~l,l>0&&(l--,i(e[l]>=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(h<u),t[u++]=l>0&&e[l-1]<d?~l:l);for(r===n&&s(e,r,o,c),a(r,n,c,!0),h=o-1,u=n[d=0];h>=0;h--)(l=t[h])>0?(l--,i(e[l]<=e[l+1]),(f=e[l])!==d&&(n[d]=u,u=n[d=f]),i(u<=h),t[--u]=0===l||e[l-1]>d?~l:l):t[h]=~l}(e,t,l,f,n,u),l=null,f=null,E},(u=Object.create(null)).suffixsort=function(e,t,r,n){if(i(e&&t&&e.length>=r&&t.length>=r),r<=1)return 1===r&&(t[0]=0),0;if(!n)if(1===e.BYTES_PER_ELEMENT)n=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");n=65536}return i(n>0),e.BYTES_PER_ELEMENT&&i(n<=1<<8*e.BYTES_PER_ELEMENT),c(e,t,0,r,n,!1)},u.bwtransform=function(e,t,r,n,o){var s,a;if(i(e&&t&&r),i(e.length>=n&&t.length>=n&&r.length>=n),n<=1)return 1===n&&(t[0]=e[0]),n;if(!o)if(1===e.BYTES_PER_ELEMENT)o=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");o=65536}for(i(o>0),e.BYTES_PER_ELEMENT&&i(o<=1<<8*e.BYTES_PER_ELEMENT),a=c(e,r,0,n,o,!0),t[0]=e[n-1],s=0;s<a;s++)t[s+1]=r[s];for(s+=1;s<n;s++)t[s]=r[s];return a+1},u.unbwtransform=function(e,t,r,n,i){var s,a,c=o.makeU32Buffer(256);for(s=0;s<256;s++)c[s]=0;for(s=0;s<n;s++)r[s]=c[e[s]]++;for(s=0,a=0;s<256;s++)a+=c[s],c[s]=a-c[s];for(s=n-1,a=0;s>=0;s--)a=r[a]+c[t[s]=e[a]],a+=a<i?1:0;c=null},u.bwtransform2=function(e,t,r,n){var s,a,u,h=0;if(i(e&&t),i(e.length>=r&&t.length>=r),r<=1)return 1===r&&(t[0]=e[0]),0;if(!n)if(1===e.BYTES_PER_ELEMENT)n=256;else{if(2!==e.BYTES_PER_ELEMENT)throw new Error("Need to specify alphabetSize");n=65536}if(i(n>0),e.BYTES_PER_ELEMENT&&i(n<=1<<8*e.BYTES_PER_ELEMENT),(u=e.length>=2*r?e:n<=256?o.makeU8Buffer(2*r):n<=65536?o.makeU16Buffer(2*r):o.makeU32Buffer(2*r))!==e)for(s=0;s<r;s++)u[s]=e[s];for(s=0;s<r;s++)u[r+s]=u[s];var l=o.makeS32Buffer(2*r);for(c(u,l,0,2*r,n,!1),s=0,a=0;s<2*r;s++){var f=l[s];f<r&&(0===f&&(h=a),--f<0&&(f=r-1),t[a++]=e[f])}return i(a===r),h},n(u))},1793(e,t,r){var n,o,i,s,a,c,u,h;e.exports=(r(6956),n=r(9010),o=r(936),i=r(5623),s=r(9461),a=r(1679),c=r(1249),u=r(3403),h=r(6015),u.EOF,BWTC=Object.create(null),BWTC.MAGIC="bwtc",BWTC.compressFile=h.compressFileHelper(BWTC.MAGIC,function(e,t,r,u,l){var f=new c(t);f.encodeStart(l,1);var d=9;"number"==typeof u&&u>=1&&u<=9&&(d=u),f.encodeByte(d);var p=d<=5;d*=1e5;var m,g,y,v,b,w,k=h.makeU8Buffer(d),S=function(){var t;for(t=0;t<d;){var r=e.readByte();if(r<0)break;k[t++]=r}return t},_=h.makeU8Buffer(d),E=h.makeS32Buffer(d),C=h.makeU8Buffer(256),O=a.factory(f),x=new s(d,0,O,O);do{if(0===(m=S()))break;m===k.length?(f.encodeFreq(1,0,3),g=k):(f.encodeFreq(1,1,3),x.encode(m),g=k.subarray(0,m)),v=n.bwtransform(g,_,E,m,256),x.encode(v);var B=h.makeU16Buffer(512);for(b=0;b<m;b++)B[256+(y=_[b])]=1;for(b=255;b>0;b--)B[b]=B[2*b]+B[2*b+1];for(B[0]=1,b=1;b<512;b++){var A=b>>>1,R=1<<9-h.fls(b);if(0===B[A]||B[A]===2*R);else if(b>=256)f.encodeBit(B[b]);else{var T=B[b];T=0===T?0:T===R?2:1,f.encodeFreq(1,T,3)}}var M=0;for(b=0;b<256;b++)B[256+b]&&(C[M++]=b);for(B=null,b=0;b<m;b++){for(y=_[b],w=0;w<M&&C[w]!==y;w++);for(console.assert(w<M),_[b]=w;w>0;w--)C[w]=C[w-1];C[0]=y}var F=new i(f,M+1,65280,256);p&&(F=new o(f,M+1));var P=0,I=function(){for(;0!==P;)1&P?(F.encode(0),P-=1):(F.encode(1),P-=2),P>>>=1};for(b=0;b<m;b++)0===(y=_[b])?P++:(I(),F.encode(y+1),P=0);I()}while(m===k.length);f.encodeFreq(1,2,3),f.encodeFinish()},!0),BWTC.decompressFile=h.decompressFileHelper(BWTC.MAGIC,function(e,t,r){var u=new c(e);u.decodeStart(!0);var l=u.decodeByte();console.assert(l>=1&&l<=9);var f=l<=5;l*=1e5;for(var d,p,m,g,y,v=h.makeU8Buffer(l),b=h.makeU8Buffer(l),w=h.makeS32Buffer(l),k=h.makeU8Buffer(256),S=a.factory(u),_=new s(l,0,S,S);;){var E=u.decodeCulFreq(3);if(u.decodeUpdate(1,E,3),0===E)p=l,d=v;else if(1===E)p=_.decode(),d=v.subarray(0,p);else if(2===E)break;var C=_.decode(),O=h.makeU16Buffer(512);for(O[0]=1,m=1;m<512;m++){var x=m>>>1,B=1<<9-h.fls(m);if(0===O[x]||O[x]===2*B)O[m]=O[x]>>>1;else if(m>=256)O[m]=u.decodeBit();else{var A=u.decodeCulFreq(3);u.decodeUpdate(1,A,3),O[m]=2===A?B:A}}var R=0;for(m=0;m<256;m++)O[256+m]&&(k[R++]=m);O=null;var T=new i(u,R+1,65280,256);f&&(T=new o(u,R+1,!0));var M=1;for(m=0;m<p;)if(0===(y=T.decode())){for(g=0;g<M;g++)d[m++]=0;M*=2}else if(1===y){for(g=0;g<M;g++)d[m++]=0,d[m++]=0;M*=2}else M=1,d[m++]=y-1;for(m=0;m<p;m++){for(g=d[m],d[m]=y=k[g];g>0;g--)k[g]=k[g-1];k[0]=y}n.unbwtransform(v,b,w,p,C),t.write(b,0,p)}u.decodeFinish()}),BWTC)},8196(e,t,r){var n,o;e.exports=(n=r(3403),(o=function(e){(function(){var t=256;this.readBit=function(){if(!(255&t)){var r=e.readByte();if(r===n.EOF)return this._eof=!0,r;t=r<<1|1}var o=256&t?1:0;return t<<=1,o},this.seekBit=function(e){var t=e>>>3,r=e-8*t;this.seek(t),this._eof=!1,this.readBits(r)},this.tellBit=function(){for(var r=8*e.tell(),n=t;255&n;)r--,n<<=1;return r},this.readByte=function(){return 255&t?this.readBits(8):e.readByte()},this.seek=function(r){e.seek(r),t=256}}).call(this),function(){var t=1;this.writeBit=function(r){t<<=1,r&&(t|=1),256&t&&(e.writeByte(255&t),t=1)},this.writeByte=function(r){1===t?e.writeByte(r):e.writeBits(8,r)},this.flush=function(){for(;1!==t;)this.writeBit(0);e.flush&&e.flush()}}.call(this)}).EOF=n.EOF,(o.prototype=Object.create(n.prototype)).readBits=function(e){var t,r=0;if(e>31)return(r=65536*this.readBits(e-16))+this.readBits(16);for(t=0;t<e;t++)r<<=1,this.readBit()>0&&r++;return r},o.prototype.writeBits=function(e,t){if(e>32){var r=65535&t,n=(t-r)/65536;return this.writeBits(e-16,n),void this.writeBits(16,r)}var o;for(o=e-1;o>=0;o--)this.writeBit(t>>>o&1)},o)},7026(e,t,r){e.exports=function(e,t,r,n,o,i,s){var a=50,c=54156738319193,u=25779555029136,h=i.EOF,l=function(e,t){var r,n=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=n,n},f={OK:0,LAST_BLOCK:-1,NOT_BZIP_DATA:-2,UNEXPECTED_INPUT_EOF:-3,UNEXPECTED_OUTPUT_EOF:-4,DATA_ERROR:-5,OUT_OF_MEMORY:-6,OBSOLETE_INPUT:-7,END_OF_BLOCK:-8},d={};d[f.LAST_BLOCK]="Bad file checksum",d[f.NOT_BZIP_DATA]="Not bzip data",d[f.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",d[f.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",d[f.DATA_ERROR]="Data error",d[f.OUT_OF_MEMORY]="Out of memory",d[f.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var p=function(e,t){var r=d[e]||"unknown error";t&&(r+=": "+t);var n=new TypeError(r);throw n.errorCode=e,n},m=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};m.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new n,!0):(this.writeCount=-1,!1)},m.prototype._start_bunzip=function(e,r){var n=s.makeU8Buffer(4);4===e.read(n,0,4)&&"BZh"===String.fromCharCode(n[0],n[1],n[2])||p(f.NOT_BZIP_DATA,"bad magic");var o=n[3]-48;(o<1||o>9)&&p(f.NOT_BZIP_DATA,"level out of range"),this.reader=new t(e),this.dbufSize=1e5*o,this.nextoutput=0,this.outputStream=r,this.streamCRC=0},m.prototype._get_next_block=function(){var e,t,r,n=this.reader,o=n.readBits(48);if(o===u)return!1;o!==c&&p(f.NOT_BZIP_DATA),this.targetBlockCRC=n.readBits(32),this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,n.readBits(1)&&p(f.OBSOLETE_INPUT);var i=n.readBits(24);i>this.dbufSize&&p(f.DATA_ERROR,"initial position out of bounds");var a=n.readBits(16),h=s.makeU8Buffer(256),d=0;for(e=0;e<16;e++)if(a&1<<15-e){var m=16*e;for(r=n.readBits(16),t=0;t<16;t++)r&1<<15-t&&(h[d++]=m+t)}var g=n.readBits(3);(g<2||g>6)&&p(f.DATA_ERROR);var y=n.readBits(15);0===y&&p(f.DATA_ERROR);var v=s.makeU8Buffer(256);for(e=0;e<g;e++)v[e]=e;var b=s.makeU8Buffer(y);for(e=0;e<y;e++){for(t=0;n.readBits(1);t++)t>=g&&p(f.DATA_ERROR);b[e]=l(v,t)}var w,k=d+2,S=[];for(t=0;t<g;t++){var _,E,C=s.makeU8Buffer(k),O=s.makeU16Buffer(21);for(a=n.readBits(5),e=0;e<k;e++){for(;(a<1||a>20)&&p(f.DATA_ERROR),n.readBits(1);)n.readBits(1)?a--:a++;C[e]=a}for(_=E=C[0],e=1;e<k;e++)C[e]>E?E=C[e]:C[e]<_&&(_=C[e]);w={},S.push(w),w.permute=s.makeU16Buffer(258),w.limit=s.makeU32Buffer(22),w.base=s.makeU32Buffer(21),w.minLen=_,w.maxLen=E;var x=0;for(e=_;e<=E;e++)for(O[e]=w.limit[e]=0,a=0;a<k;a++)C[a]===e&&(w.permute[x++]=a);for(e=0;e<k;e++)O[C[e]]++;for(x=a=0,e=_;e<E;e++)x+=O[e],w.limit[e]=x-1,x<<=1,a+=O[e],w.base[e+1]=x-a;w.limit[E+1]=Number.MAX_VALUE,w.limit[E]=x+O[E]-1,w.base[_]=0}var B=s.makeU32Buffer(256);for(e=0;e<256;e++)v[e]=e;var A,R=0,T=0,M=0,F=this.dbuf=s.makeU32Buffer(this.dbufSize);for(k=0;;){for(k--||(k=49,M>=y&&p(f.DATA_ERROR),w=S[b[M++]]),e=w.minLen,t=n.readBits(e);e>w.maxLen&&p(f.DATA_ERROR),!(t<=w.limit[e]);e++)t=t<<1|n.readBits(1);((t-=w.base[e])<0||t>=258)&&p(f.DATA_ERROR);var P=w.permute[t];if(0!==P&&1!==P){if(R)for(R=0,T+a>this.dbufSize&&p(f.DATA_ERROR),B[A=h[v[0]]]+=a;a--;)F[T++]=A;if(P>d)break;T>=this.dbufSize&&p(f.DATA_ERROR),B[A=h[A=l(v,e=P-1)]]++,F[T++]=A}else R||(R=1,a=0),a+=0===P?R:2*R,R<<=1}for((i<0||i>=T)&&p(f.DATA_ERROR),t=0,e=0;e<256;e++)r=t+B[e],B[e]=t,t=r;for(e=0;e<T;e++)F[B[A=255&F[e]]]|=e<<8,B[A]++;var I=0,L=0,N=0;return T&&(L=255&(I=F[i]),I>>=8,N=-1),this.writePos=I,this.writeCurrent=L,this.writeCount=T,this.writeRun=N,!0},m.prototype._read_bunzip=function(e,t){var r,n,o;if(this.writeCount<0)return 0;for(var i=this.dbuf,s=this.writePos,a=this.writeCurrent,c=this.writeCount,u=(this.outputsize,this.writeRun);c;){for(c--,n=a,a=255&(s=i[s]),s>>=8,3===u++?(r=a,o=n,a=-1):(r=1,o=a),this.blockCRC.updateCRCRun(o,r);r--;)this.outputStream.writeByte(o),this.nextoutput++;a!=n&&(u=0)}return this.writeCount=c,this.blockCRC.getCRC()!==this.targetBlockCRC&&p(f.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput},m.Err=f,m.decode=function(e,t,r){for(var n=s.coerceInputStream(e),o=s.coerceOutputStream(t,t),i=o.stream,a=new m(n,i);!("eof"in n)||!n.eof();)if(a._init_block())a._read_bunzip();else{var c=a.reader.readBits(32);if(c!==a.streamCRC&&p(f.DATA_ERROR,"Bad stream CRC (got "+a.streamCRC.toString(16)+" expected "+c.toString(16)+")"),!r||!("eof"in n)||n.eof())break;a._start_bunzip(n,i)}return o.retval},m.decodeBlock=function(e,t,r){var o=s.coerceInputStream(e),i=s.coerceOutputStream(r,r),a=i.stream,c=new m(o,a);return c.reader.seekBit(t),c._get_next_block()&&(c.blockCRC=new n,c.writeCopies=0,c._read_bunzip()),i.retval},m.table=function(e,t,r){var n=new i;n.delegate=s.coerceInputStream(e),n.pos=0,n.readByte=function(){return this.pos++,this.delegate.readByte()},n.tell=function(){return this.pos},n.delegate.eof&&(n.eof=n.delegate.eof.bind(n.delegate));var o=new i;o.pos=0,o.writeByte=function(){this.pos++};for(var a=new m(n,o),c=a.dbufSize;!("eof"in n)||!n.eof();){var u=a.reader.tellBit();if(a._init_block()){var h=o.pos;a._read_bunzip(),t(u,o.pos-h)}else{if(a.reader.readBits(32),!r||!("eof"in n)||n.eof())break;a._start_bunzip(n,o),console.assert(a.dbufSize===c,"shouldn't change block size within multistream file")}}};var g=function(e,t){var r,n=[];for(r=0;r<t;r++)n[r]=e[r]<<9|r;n.sort(function(e,t){return e-t});var i=n.map(function(e){return e>>>9});for(o.allocateHuffmanCodeLengths(i,20),this.codeLengths=s.makeU8Buffer(t),r=0;r<t;r++){var a=511&n[r];this.codeLengths[a]=i[r]}};g.prototype.computeCanonical=function(){var e,t=this.codeLengths.length,r=[];for(e=0;e<t;e++)r[e]=this.codeLengths[e]<<9|e;r.sort(function(e,t){return e-t}),this.code=s.makeU32Buffer(t);var n=0,o=0;for(e=0;e<t;e++){var i=r[e]>>>9,a=511&r[e];console.assert(o<=i),n<<=i-o,this.code[a]=n++,o=i}},g.prototype.cost=function(e,t,r){var n,o=0;for(n=0;n<r;n++)o+=this.codeLengths[e[t+n]];return o},g.prototype.emit=function(e){var t,r=this.codeLengths[0];for(e.writeBits(5,r),t=0;t<this.codeLengths.length;t++){var n,o,i=this.codeLengths[t];for(console.assert(i>0&&i<=20),r<i?(n=2,o=i-r):(n=3,o=r-i);o-- >0;)e.writeBits(2,n);e.writeBit(0),r=i}},g.prototype.encode=function(e,t){e.writeBits(this.codeLengths[t],this.code[t])};var y=function(e,t,r,n){for(var o=0,i=-1,s=0;o<r&&!(4===s&&(t[o++]=0,o>=r));){var a=e.readByte();if(a===h)break;if(n.updateCRC(a),a!==i)i=a,s=1;else if(++s>4){if(s<256){t[o-1]++;continue}s=1}t[o++]=a}return o},v=function(e,t,r){var n,o,i;for(n=0,i=0;n<r.length;n+=a){var s=Math.min(a,r.length-n),c=0,u=t[0].cost(r,n,s);for(o=1;o<t.length;o++){var h=t[o].cost(r,n,s);h<u&&(c=o,u=h)}e[i++]=c}},b=function(e,t,n){var o,i,c,u,h=s.makeU8Buffer(t),f=r.bwtransform2(e,h,t,256);n.writeBit(0),n.writeBits(24,f);var d=[],p=[];for(i=0;i<t;i++)d[o=e[i]]=!0,p[o>>>4]=!0;for(i=0;i<16;i++)n.writeBit(!!p[i]);for(i=0;i<16;i++)if(p[i])for(c=0;c<16;c++)n.writeBit(!!d[i<<4|c]);var m=0;for(i=0;i<256;i++)d[i]&&m++;var y=s.makeU16Buffer(t+1),b=m+1,w=[];for(i=0;i<=b;i++)w[i]=0;var k=s.makeU8Buffer(m);for(i=0,c=0;i<256;i++)d[i]&&(k[c++]=i);d=null,p=null;var S=0,_=0,E=function(e){y[S++]=e,w[e]++},C=function(){for(;0!==_;)1&_?(E(0),_-=1):(E(1),_-=2),_>>>=1};for(i=0;i<h.length;i++){for(o=h[i],c=0;c<m&&k[c]!==o;c++);console.assert(c!==m),l(k,c),0===c?_++:(C(),E(c+1),_=0)}C(),E(b),y=y.subarray(0,S);var O,x=[];for(O=S>=2400?6:S>=1200?5:S>=600?4:S>=200?3:2,x.push(new g(w,b+1)),i=0;i<=b;i++)w[i]=1;x.push(new g(w,b+1)),w=null;var B=s.makeU8Buffer(Math.ceil(S/a));for(function(e,t,r,n,o){for(var i,s,c,u=[];e.length<t;){for(v(n,e,r),i=0;i<e.length;i++)u[i]=0;for(i=0;i<n.length;i++)u[n[i]]++;var h=u.indexOf(Math.max.apply(Math,u)),l=[];for(i=0,s=0;i<n.length;i++)if(n[i]===h){var f=i*a,d=Math.min(f+a,r.length);l.push({index:i,cost:e[h].cost(r,f,d-f)})}for(l.sort(function(e,t){return e.cost-t.cost}),i=l.length>>>1;i<l.length;i++)n[l[i].index]=e.length;e.push(null);var p,m=[];for(i=0;i<e.length;i++)for(p=m[i]=[],s=0;s<o;s++)p[s]=0;for(i=0,s=0;i<r.length;)for(p=m[n[s++]],c=0;c<a&&i<r.length;c++)p[r[i++]]++;for(i=0;i<e.length;i++)e[i]=new g(m[i],o)}}(x,O,y,B,b+1),v(B,x,y),console.assert(x.length>=2&&x.length<=6),n.writeBits(3,x.length),n.writeBits(15,B.length),i=0;i<x.length;i++)k[i]=i;for(i=0;i<B.length;i++){var A=B[i];for(c=0;c<x.length&&k[c]!==A;c++);for(console.assert(c<x.length),l(k,c);c>0;c--)n.writeBit(1);n.writeBit(0)}for(i=0;i<x.length;i++)x[i].emit(n),x[i].computeCanonical();for(i=0,u=0;i<S;){var R=x[B[u++]];for(c=0;c<a&&i<S;c++)R.encode(n,y[i++])}},w=Object.create(null);return w.compressFile=function(e,r,o){e=s.coerceInputStream(e);var i=s.coerceOutputStream(r,r);r=new t(i.stream);var a=9;if("number"==typeof o&&(a=o),a<1||a>9)throw new Error("Invalid block size multiplier");var h=1e5*a;h-=19,r.writeByte("B".charCodeAt(0)),r.writeByte("Z".charCodeAt(0)),r.writeByte("h".charCodeAt(0)),r.writeByte("0".charCodeAt(0)+a);var l,f=s.makeU8Buffer(h),d=0;do{var p=new n;(l=y(e,f,h,p))>0&&(d=((d<<1|d>>>31)^p.getCRC())>>>0,r.writeBits(48,c),r.writeBits(32,p.getCRC()),b(f,l,r))}while(l===h);return r.writeBits(48,u),r.writeBits(32,d),r.flush(),i.retval},w.decompressFile=m.decode,w.decompressBlock=m.decodeBlock,w.table=m.table,w}(r(6956),r(8196),r(9010),r(4064),r(8197),r(3403),r(6015))},4064(e,t,r){var n,o;e.exports=(n=r(6015),o=n.arraycopy(n.makeU32Buffer(256),[0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,1461550545,1406951526,1302016099,1230646740,1142491917,1087903418,2896545431,2825181984,2770861561,2716262478,3215044683,3143675388,3055782693,3001194130,2326604591,2389456536,2200899649,2280525302,2578013683,2640855108,2418763421,2498394922,3769900519,3832873040,3912640137,3992402750,4088425275,4151408268,4197601365,4277358050,3334271071,3263032808,3476998961,3422541446,3585640067,3514407732,3694837229,3640369242,1762451694,1842216281,1619975040,1682949687,2047383090,2127137669,1938468188,2001449195,1325665622,1271206113,1183200824,1111960463,1543535498,1489069629,1434599652,1363369299,622672798,568075817,748617968,677256519,907627842,853037301,1067152940,995781531,51762726,131386257,177728840,240578815,269590778,349224269,429104020,491947555,4046411278,4126034873,4172115296,4234965207,3794477266,3874110821,3953728444,4016571915,3609705398,3555108353,3735388376,3664026991,3290680682,3236090077,3449943556,3378572211,3174993278,3120533705,3032266256,2961025959,2923101090,2868635157,2813903052,2742672763,2604032198,2683796849,2461293480,2524268063,2284983834,2364738477,2175806836,2238787779,1569362073,1498123566,1409854455,1355396672,1317987909,1246755826,1192025387,1137557660,2072149281,2135122070,1912620623,1992383480,1753615357,1816598090,1627664531,1707420964,295390185,358241886,404320391,483945776,43990325,106832002,186451547,266083308,932423249,861060070,1041341759,986742920,613929101,542559546,756411363,701822548,3316196985,3244833742,3425377559,3370778784,3601682597,3530312978,3744426955,3689838204,3819031489,3881883254,3928223919,4007849240,4037393693,4100235434,4180117107,4259748804,2310601993,2373574846,2151335527,2231098320,2596047829,2659030626,2470359227,2550115596,2947551409,2876312838,2788305887,2733848168,3165939309,3094707162,3040238851,2985771188]),function(){var e=4294967295;this.getCRC=function(){return~e>>>0},this.updateCRC=function(t){e=e<<8^o[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^o[255&(e>>>24^t)]}})},4820(e,t,r){var n,o,i,s;e.exports=(n=r(8196),o=r(886),i=r(6015),(s=function(e,t,r){var n;for(this.literalModel=[],n=0;n<t;n++)this.literalModel[n]=e(r)}).prototype.encode=function(e,t){this.literalModel[t].encode(e)},s.prototype.decode=function(e){return this.literalModel[e].decode()},s.MAGIC="ctx1",s.compressFile=i.compressFileHelper(s.MAGIC,function(e,t,r,a){var c=new n(t),u=256;r<0&&u++;var h=o.factory(c,8191),l=new s(h,256,u),f=32,d={encode:function(e){l.encode(e,f),f=e}};i.compressWithModel(e,r,d),c.flush()}),s.decompressFile=i.decompressFileHelper(s.MAGIC,function(e,t,r){var a=new n(e),c=256;r<0&&c++;var u=o.factory(a,8191),h=new s(u,256,c),l=32,f={decode:function(){var e=h.decode(l);return l=e,e}};i.decompressWithModel(t,r,f)}),s)},936(e,t,r){var n,o,i,s;e.exports=(n=r(1249),r(3403),o=r(6015),i=256,(s=function(e,t,r){var n;console.assert(t<300);var s=this.numSyms=t;for(this.coder=e,this.prob=o.makeU16Buffer(t+2),this.escape=o.makeU16Buffer(t+1),this.update=o.makeU16Buffer(t+1),this.prob[s+1]=i,n=0;n<=this.numSyms;n++)this.escape[n]=n;if(this.updateCount=0,this.updateThresh=i-Math.floor(128),r){for(this.probToSym=o.makeU16Buffer(i),this.escProbToSym=o.makeU16Buffer(this.numSyms),n=0;n<i;n++)this.probToSym[n]=s;for(n=0;n<this.numSyms;n++)this.escProbToSym[n]=n}}).factory=function(e,t){return function(r){return new s(e,r,t)}},s.prototype._update=function(e,t){if(e===this.numSyms){if(this.update[e]>=40)return;if(this.updateCount>=this.updateThresh-1)return}if(this.update[e]++,this.updateCount++,!(this.updateCount<this.updateThresh)){var r,n,o,s,a,c;for(this.escape[0]=this.prob[0]=r=n=o=0,s=0;s<this.numSyms+1;s++){var u=(this.prob[s+1]-this.prob[s]>>>1)+this.update[s];u?(this.prob[s]=r,r+=u,1&u&&o++,this.escape[s]=n):(this.prob[s]=r,this.escape[s]=n,n++)}for(this.prob[s]=r,console.assert(r===i),this.updateThresh=i-Math.floor((r-o)/2),s=0;s<this.numSyms+1;s++)this.update[s]=0;if(this.update[this.numSyms]=1,this.updateCount=1,t)for(s=0,a=0,c=0;s<this.numSyms+1;s++){for(var h=this.prob[s+1];a<h;a++)this.probToSym[a]=s;for(var l=this.escape[s+1];c<l;c++)this.escProbToSym[c]=s}}},s.prototype.encode=function(e){var t=this.prob[e],r=this.prob[e+1]-t;if(console.assert(this.prob[this.numSyms+1]===i),r)return this.coder.encodeShift(r,t,8),this._update(e);console.assert(e!==this.numSyms),this.encode(this.numSyms),t=this.escape[e],r=this.escape[e+1]-t;var n=this.escape[this.numSyms];return this.coder.encodeFreq(r,t,n),this._update(e)},s.prototype.decode=function(){var e=this.coder.decodeCulShift(8),t=this.probToSym[e],r=this.prob[t],n=this.prob[t+1]-r;if(this.coder.decodeUpdate(n,r,i),this._update(t,!0),t!==this.numSyms)return t;var o=this.escape[this.numSyms];return e=this.coder.decodeCulFreq(o),t=this.escProbToSym[e],r=this.escape[t],n=this.escape[t+1]-r,this.coder.decodeUpdate(n,r,o),this._update(t,!0),t},s.MAGIC="dfsm",s.compressFile=o.compressFileHelper(s.MAGIC,function(e,t,r,i,a){var c=new n(t);c.encodeStart(a,1);var u=new s(c,r<0?257:256);o.compressWithModel(e,r,u),c.encodeFinish()},!0),s.decompressFile=o.decompressFileHelper(s.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var a=new s(i,r<0?257:256,!0);o.decompressWithModel(t,r,a),i.decodeFinish()}),s)},2139(e,t,r){e.exports=function(e,t,r,n){var o=Object.create(null);o.MAGIC="dmc!";var i=function(t,r,o){this.out=[],this.model=o?o.clone():new e(t,r,65280,256),this.count=n.makeU16Buffer(r),this.sum=0};i.prototype.clone=function(e,t){var r,n=new i(e,t,null);for(r=0;r<t;r++)n.out[r]=this.out[r];return n};var s=function(e,t,r,n){var o,s;for(this.coder=e,this.size=t,this.MIN_CNT1=r||8,this.MIN_CNT2=n||128,this.nodes=[],o=0;o<t;o++)this.nodes[o]=new i(e,t);for(o=0;o<t;o++)for(s=0;s<t;s++)this.nodes[o].out[s]=this.nodes[s];this.current=this.nodes[0]};return s.prototype.maybeSplit=function(e,t,r){var n,o=e.count[t],i=r.sum;if(o<=this.MIN_CNT1||i-o<=this.MIN_CNT2)return r;var s=r.clone(this.coder,this.size);for(this.nodes.push(s),e.out[t]=s,s.sum=r.sum=0,n=0;n<this.size;n++)s.count[n]=r.count[n]*o/i,s.sum+=s.count[n],r.count[n]-=s.count[n],r.sum+=r.count[n];return s},s.prototype.encode=function(e){var t=this.current;t.model.encode(e);var r=t.out[e];65535!==t.count[e]&&(t.count[e]++,t.sum++),this.current=this.maybeSplit(t,e,r)},s.prototype.decode=function(){var e=this.current,t=e.model.decode(),r=e.out[t];return 65535!==e.count[t]&&(e.count[t]++,e.sum++),this.current=this.maybeSplit(e,t,r),t},o.compressFile=n.compressFileHelper(o.MAGIC,function(e,o,i,a){var c=+(a=a||{}).m||8,u=+a.n||128;n.writeUnsignedNumber(o,c),n.writeUnsignedNumber(o,u);var h=new t(o);h.encodeStart(202,0);for(var l=new s(h,i<0?257:256,c,u),f=0;f!==i;){var d=e.readByte();if(d===r.EOF){l.encode(256);break}l.encode(d),f++}h.encodeFinish()}),o.decompressFile=n.decompressFileHelper(o.MAGIC,function(e,r,o){var i=n.readUnsignedNumber(e),a=n.readUnsignedNumber(e),c=new t(e);c.decodeStart();for(var u=new s(c,o<0?257:256,i,a),h=0;h!==o;){var l=u.decode();if(256===l)break;r.writeByte(l),h++}c.decodeFinish()}),o}(r(417),r(1249),r(3403),r(6015))},5623(e,t,r){var n,o,i,s,a,c,u;e.exports=(n=r(1249),r(3403),o=r(6015),i=65535,s=4294901760,a=16,c=4294901758,(u=function(e,t,r,n){var i;for(this.coder=e,this.numSyms=t+1,this.tree=o.makeU32Buffer(2*this.numSyms),this.increment=+n||256,this.max_prob=+r||65280,console.assert(this.max_prob+(this.increment-1)<=65535),console.assert(t<=65535),i=0;i<t;i++)this.tree[this.numSyms+i]=1;this.tree[this.numSyms+i]=0|this.increment<<a,this._sumTree()}).factory=function(e,t,r){return function(n){return new u(e,n,t,r)}},u.prototype.clone=function(){var e,t=new u(this.coder,this.size,this.max_prob,this.increment);for(e=1;e<this.tree.length;e++)t.tree[e]=this.tree[e];return t},u.prototype.encode=function(e){var t=this.numSyms+e,r=this.tree[t],n=s,o=a,c=this.increment<<a;0===(r&s)?(this.encode(this.numSyms-1),n=i,c-=1,o=0):e===this.numSyms-1&&(this.tree[1]&i)>>>0==1&&(c=-this.tree[t]);for(var u=0;t>1;){var h=t>>>1;1&t&&(u+=this.tree[2*h]),this.tree[t]+=c,t=h}var l=this.tree[1];this.tree[1]+=c,r=(r&n)>>>o,u=(u&n)>>>o,l=(l&n)>>>o,this.coder.encodeFreq(r,u,l),(this.tree[1]&s)>>>a>=this.max_prob&&this._rescale()},u.prototype._decode=function(e){var t=s,r=a,n=this.increment<<a;e&&(t=i,n-=1,r=0);for(var o=(this.tree[1]&t)>>>r,c=this.coder.decodeCulFreq(o),u=1,h=0;u<this.numSyms;){this.tree[u]+=n;var l=(this.tree[2*u]&t)>>>r;u*=2,c-h>=l&&(h+=l,u++)}var f=u-this.numSyms,d=(this.tree[u]&t)>>>r;if(this.tree[u]+=n,this.coder.decodeUpdate(d,h,o),f===this.numSyms-1&&(this.tree[1]&i)>>>0==1)for(n=-this.tree[u];u>=1;)this.tree[u]+=n,u>>>=1;return(this.tree[1]&s)>>>a>=this.max_prob&&this._rescale(),f},u.prototype.decode=function(){var e=this._decode(!1);return e===this.numSyms-1&&(e=this._decode(!0)),e},u.prototype._rescale=function(){var e,t,r=!0;for(e=0;e<this.numSyms-1;e++)0===((t=this.tree[this.numSyms+e])&i)?(0==(t=(t&c)>>>1)&&(t=1,r=!1),this.tree[this.numSyms+e]=t):r=!1;t=((t=this.tree[this.numSyms+e])&c)>>>1,r?t=0:0===t&&(t=65536),this.tree[this.numSyms+e]=t,this._sumTree()},u.prototype._sumTree=function(){var e;for(e=this.numSyms-1;e>0;e--)this.tree[e]=this.tree[2*e]+this.tree[2*e+1]},u.MAGIC="fenw",u.compressFile=o.compressFileHelper(u.MAGIC,function(e,t,r,i,s){var a=new n(t);a.encodeStart(s,1);var c=new u(a,r<0?257:256);o.compressWithModel(e,r,c),a.encodeFinish()},!0),u.decompressFile=o.decompressFileHelper(u.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var s=new u(i,r<0?257:256);o.decompressWithModel(t,r,s),i.decodeFinish()}),u)},886(e,t,r){e.exports=function(e,t){var r=function(e,t,r,n){this.up=e,this.down=t,this.symbol=r,this.weight=n};r.prototype.clone=function(){return new r(this.up,this.down,this.symbol,this.weight)},r.prototype.set=function(e){this.up=e.up,this.down=e.down,this.symbol=e.symbol,this.weight=e.weight};var n=function(e,t,n,o){var i;for(console.assert(e&&"number"==typeof e),(!t||t>e)&&(t=e),(t<<=1)&&t--,this.table=[],i=0;i<=t;i++)this.table[i]=new r(0,0,0,0);if(this.map=[],this.size=e)for(i=0;i<e;i++)this.map[i]=0;this.esc=this.root=t,n&&(this.readBit=n.readBit.bind(n),this.writeBit=n.writeBit.bind(n)),this.max_weight=o};return n.factory=function(e,t){return function(r){return new n(r,r,e,t)}},n.prototype.split=function(e){var t,r;return(t=this.esc)?(this.esc--,(r=this.esc)?(this.table[t].down=r,this.table[t].weight=1,this.table[r].up=t,this.esc--):(t=0,r=1),this.table[r].symbol=e,this.table[r].weight=0,this.table[r].down=0,this.map[e]=r,this.table[this.esc].weight=0,this.table[this.esc].down=0,this.table[this.esc].up=t,r):(console.assert(!1),0)},n.prototype.leader=function(e){for(var t,r,n=this.table[e].weight,o=e;n===this.table[o+1].weight;)o++;return o===e?e:(r=this.table[e].symbol,t=this.table[o].symbol,this.table[o].symbol=r,this.table[e].symbol=t,this.map[r]=o,this.map[t]=e,o)},n.prototype.slide=function(e){var t,r=e;if(1&(t=this.table[r++].clone()).weight)for(;t.weight>this.table[r+1].weight;)r++;return this.table[e].set(this.table[r]),this.table[r].set(t),this.table[r].up=this.table[e].up,this.table[e].up=t.up,1&t.weight?(this.table[t.down].up=r,this.table[t.down-1].up=r,this.map[this.table[e].symbol]=e):(this.table[this.table[e].down-1].up=e,this.table[this.table[e].down].up=e,this.map[t.symbol]=r),r},n.prototype.increment=function(e){var t;for(this.table[e].up===e+1?(this.table[e].weight+=2,e++):e=this.leader(e);this.table[e].weight+=2,t=this.table[e].up;){for(;this.table[e].weight>this.table[e+1].weight;)e=this.slide(e);e=1&this.table[e].weight?t:this.table[e].up}this.max_weight&&this.table[this.root].weight>=this.max_weight&&this.scale(1)},n.prototype.scale=function(e){for(var t,r,n=this.esc;++n<=this.root;)for(1&this.table[n].weight?(t=-2&this.table[this.table[n].down].weight)&&(t+=1|this.table[this.table[n].down-1].weight):(t=this.table[n].weight>>e&-2)||(this.map[this.table[n].symbol]=0,this.esc++&&this.esc++),this.table[n].weight=t,r=n;t<this.table[--r].weight;)this.slide(r);this.table[this.esc].down=0},n.prototype.sendid=function(e){for(var t,r=0;e--;)this.map[e]||r++;if(t=this.size-Math.floor((this.root-this.esc)/2)-1)do{this.writeBit(1&r),r>>=1}while(t>>=1)},n.prototype.encode=function(e){var t,r,n,o,i=1;if(e<this.size){if((n=o=this.map[e])||(n=this.esc)){for(;r=this.table[n].up;)i<<=1,i|=1&n,n=r;for(;t=1&i,i>>=1;)this.writeBit(t);o||(this.sendid(e),o=this.split(e)),this.increment(o)}}else console.assert(!1)},n.prototype.readid=function(){var e,t,r=0,n=1;if(e=this.size-Math.floor((this.root-this.esc)/2)-1)do{r|=this.readBit()?n:0,n<<=1}while(e>>=1);for(t=0;t<this.size;t++)if(!this.map[t]&&!r--)return t;return console.assert(!1),0},n.prototype.decode=function(){for(var e,t,r=this.root;t=this.table[r].down;)r=this.readBit()?t-1:t;if(r===this.esc){if(!this.esc)return console.assert(!1),0;e=this.readid(),r=this.split(e)}else e=this.table[r].symbol;return this.increment(r),e},n.MAGIC="huff",n.compressFile=t.compressFileHelper(n.MAGIC,function(r,o,i,s){var a=new e(o),c=256;i<0&&c++;var u=new n(257,c,a,8191);t.compressWithModel(r,i,u),a.flush()}),n.decompressFile=t.decompressFileHelper(n.MAGIC,function(r,o,i){var s=new e(r),a=256;i<0&&a++;var c=new n(257,a,s,8191);t.decompressWithModel(o,i,c)}),n}(r(8196),r(6015))},8197(e,t,r){var n,o,i;e.exports=(n=r(6956),o=r(6015),i=function(e,t,r){for(var n=e.length,o=t,i=e.length-2;t>=r&&e[t]%n>o;)i=t,t-=o-t+1;for(t=Math.max(r-1,t);i>t+1;){var s=t+i>>1;e[s]%n>o?i=s:t=s}return i},n({allocateHuffmanCodeLengths:function(e,t){switch(e.length){case 2:e[1]=1;case 1:return void(e[0]=1)}!function(e){var t,r,n,o,i=e.length;for(e[0]+=e[1],t=0,r=1,n=2;r<i-1;r++)n>=i||e[t]<e[n]?(o=e[t],e[t++]=r):o=e[n++],n>=i||t<r&&e[t]<e[n]?(o+=e[t],e[t++]=r+i):o+=e[n++],e[r]=o}(e);var r=function(e,t){var r,n=e.length-2;for(r=1;r<t-1&&n>1;r++)n=i(e,n-1,0);return n}(e,t);e[0]%e.length>=r?function(e){var t,r,n,o,s=e.length-2,a=e.length-1;for(t=1,r=2;r>0;t++){for(o=r-((n=s)-(s=i(e,n-1,0)));o>0;o--)e[a--]=t;r=n-s<<1}}(e):function(e,t,r){var n,o,s,a,c=e.length-2,u=e.length-1,h=1==r?2:1,l=1==r?t-2:t;for(n=h<<1;n>0;h++){for(o=c,c=c<=t?c:i(e,o-1,t),s=0,h>=r?s=Math.min(l,1<<h-r):h==r-1&&(s=1,e[c]==o&&c++),a=n-(o-c+s);a>0;a--)e[u--]=h;l-=s,n=o-c+s<<1}}(e,r,t-o.fls(r-1))}}))},9461(e,t,r){var n,o;e.exports=(n=r(6015),(o=function(e,t,r,o){var i,s=n.fls(e-1);for(this.extraStates=+t||0,this.lgDistanceModel=r(1+s+t),this.distanceModel=[],i=2;i<=s;i++){var a=i-1;this.distanceModel[i]=o(1<<a)}}).prototype.encode=function(e){if(e<2)this.lgDistanceModel.encode(e+this.extraStates);else{var t=n.fls(e);console.assert(e&1<<t-1),console.assert(t>=2),this.lgDistanceModel.encode(t+this.extraStates);var r=e&(1<<t-1)-1;this.distanceModel[t].encode(r)}},o.prototype.decode=function(){var e=this.lgDistanceModel.decode()-this.extraStates;return e<2?e:(1<<e-1)+this.distanceModel[e].decode()},o)},4845(e,t,r){e.exports=function(e,t){var r=Object.create(null);r.MAGIC="lzjb";var n=1023,o=e.EOF;return r.compressFile=t.compressFileHelper(r.MAGIC,function(e,r,i,s){var a,c,u,h,l,f,d,p=1024,m=1;"number"==typeof s&&(p*=2,s=Math.max(1,Math.min(9,s))-1,m=1<<Math.floor(s/2),1&s&&(m=Math.round(1.5*m)),s>=2&&s<=4&&m++),f=t.makeU16Buffer(p*m);for(var g=t.makeU8Buffer(1024),y=0,v=function(e){return g[y++]=e,y>=g.length&&(y=0),e},b=t.makeU8Buffer(17),w=0,k=function(){var e;for(e=0;e<w;e++)r.writeByte(b[e]);w=0},S=[],_=function(){return S.length?S.pop():e.readByte()},E=function(e){S.push(e)},C=128,O=[];;){var x=_();if(x===o)break;256==(C<<=1)&&(k(),C=1,b[0]=0,w=1);var B=_();if(B===o){b[w++]=v(x);break}var A=_();if(A!==o){for(h=(x<<16)+(B<<8)+A,h^=h>>9,h+=h>>5,l=((h^=x)&p-1)*m,O.length=0,d=0;d<m;d++){u=y-f[l+d]&n,a=g.length+y-u;var R=g[a&n],T=g[a+1&n],M=g[a+2&n];0===u?R=1^x:1==u?(T=x,M=B):2==u&&(M=x),x===R&&B===T&&A===M&&O.push(u)}for(d=m-1;d>0;d--)f[l+d]=f[l+d-1];if(f[l]=y,0===O.length)b[w++]=v(x),E(A),E(B);else{b[0]|=C,v(x),v(B),v(A);var F=_(),P=O[0],I=g.length+y;for(c=3;c<66&&F!==o;c++,I++){for(d=0;d<O.length;)F!==g[I-O[d]&n]?(P=O[d],O.splice(d,1)):d++;if(0===O.length)break;v(F),F=_()}0!==O.length&&(P=O[0]),E(F),b[w++]=c-3<<2|P>>8,b[w++]=255&P}}else b[w++]=v(x),E(B)}k()}),r.decompressFile=t.decompressFileHelper(r.MAGIC,function(e,r,i){for(var s,a,c,u,h=t.makeU8Buffer(1024),l=0,f=128;0!==i&&(u=e.readByte())!==o;)if(256==(f<<=1)&&(f=1,a=u,u=e.readByte()),a&f)for(c=3+(u>>2),(s=l-((u<<8|e.readByte())&n))<0&&(s+=h.length),i>=0&&(i-=c);--c>=0;)u=h[l++]=h[s++],r.writeByte(u),l>=h.length&&(l=0),s>=h.length&&(s=0);else r.writeByte(u),h[l++]=u,l>=h.length&&(l=0),i>=0&&i--}),r}(r(3403),r(6015))},6831(e,t,r){e.exports=function(e,t,r,n,o,i,s){var a=Object.create(null);a.MAGIC="lzjR";var c=1023;return a.compressFile=s.compressFileHelper(a.MAGIC,function(a,u,h,l,f){var d,p,m,g,y,v,b,w=1024,k=1;"number"==typeof l&&(w*=2,l=Math.max(1,Math.min(9,l))-1,k=1<<Math.floor(l/2),1&l&&(k=Math.round(1.5*k)),l>=2&&l<=4&&k++);var S=new o(u);S.encodeStart(f,1),v=s.makeU16Buffer(w*k);for(var _=s.makeU8Buffer(1024),E=0,C=function(e){return _[E++]=e,E>=_.length&&(E=0),e},O=[],x=function(){return O.length?O.pop():a.readByte()},B=function(e){O.push(e)},A=[],R=n.factory(S),T=t.factory(S,65280,256),M=new e(T,256,1+(h<0?257:256)),F=function(e){return e<=32?T(e):R(e)},P=new r(64,0,T,F),I=new r(1024,1,T,F),L=32,N=0;;){var D=E,j=x();if(j===i.EOF)break;var U=x();if(U===i.EOF){M.encode(C(j),L);break}var q=x();if(q!==i.EOF){for(g=(j<<16)+(U<<8)+q,g^=g>>9,g+=g>>5,y=((g^=j)&w-1)*k,A.length=0,b=0;b<k;b++){m=E-v[y+b]&c,d=_.length+E-m;var z=_[d&c],$=_[d+1&c],H=_[d+2&c];1==m?($=j,H=U):2==m&&(H=j),j===z&&U===$&&q===H&&A.push(m)}for(b=k-1;b>0;b--)v[y+b]=v[y+b-1];if(v[y]=E,0===A.length)M.encode(C(j),L),B(q),B(U),L=j;else{M.encode(256,L),C(j),C(U),C(q),L=q;var G=x(),W=A[0],V=_.length+E;for(p=3;p<66&&G!==i.EOF;p++,V++){for(b=0;b<A.length;)G!==_[V-A[b]&c]?(W=A[b],A.splice(b,1)):b++;if(0===A.length)break;C(G),L=G,G=x()}0!==A.length&&(W=A[0]),B(G),P.encode(p-3),(m=D-W&c)===N?I.encode(-1):(I.encode(m),N=m)}}else M.encode(C(j),L),B(U),L=j}h<0&&M.encode(257,L),S.encodeFinish()},!0),a.decompressFile=s.decompressFileHelper(a.MAGIC,function(i,a,c){var u,h,l,f=s.makeU8Buffer(1024),d=0,p=new o(i);p.decodeStart(!0);for(var m=n.factory(p),g=t.factory(p,65280,256),y=new e(g,256,1+(c<0?257:256)),v=function(e){return e<=32?g(e):m(e)},b=new r(64,0,g,v),w=new r(1024,1,g,v),k=32,S=0;0!==c&&257!==(l=y.decode(k));)if(256===l)for(h=b.decode()+3,(u=w.decode())<0?u=S:S=u,c>=0&&(c-=h);--h>=0;)l=k=f[d++]=f[u++],a.writeByte(l),d>=f.length&&(d=0),u>=f.length&&(u=0);else a.writeByte(l),f[d++]=k=l,d>=f.length&&(d=0),c>=0&&c--;p.decodeFinish()}),a}(r(4820),r(5623),r(9461),r(1679),r(1249),r(3403),r(6015))},4416(e,t,r){e.exports=function(e,t,r,n,o,i,s,a,c,u){var h=Object.create(null);h.MAGIC="lzp3";var l=1<<20,f=65535,d=function(e){this.buffer=u.makeU8Buffer(Math.min(e+4,l)),this.pos=0,this.ctxt4=u.makeU32Buffer(65536),this.ctxt3=u.makeU32Buffer(4096),this.ctxt2=u.makeU32Buffer(65536),this.put(99),this.put(83),this.put(97),this.put(32)};return d.prototype.put=function(e){return this.buffer[this.pos++]=e,this.pos>=l&&(this.pos=0),e},d.prototype.get=function(e){return this.buffer[1048575&e]},d.prototype.context=function(e,t){var r,n=0;for(e=e-t&1048575,r=0;r<t;r++)n=n<<8|this.buffer[e++],e>=l&&(e=0);return n},d.prototype.getIndex=function(e,t){var r=this.context(e,4),n=65535&(r>>>15^r),o=4095&(r>>>11^r),i=r&f,s=0;return 0===t&&(0!==(s=this.ctxt4[n])&&r!==this.context(s-1,4)&&(s=0),0===s&&(0!==(s=this.ctxt3[o])&&(16777215&r)!==this.context(s-1,3)&&(s=0),0===s&&0!==(s=this.ctxt2[i])&&(r&&f)!==this.context(s-1,2)&&(s=0))),t&&t--,this.ctxt4[n]=this.ctxt3[o]=this.ctxt2[i]=1+(e|t<<20),s},h.compressFile=u.compressFileHelper(h.MAGIC,function(e,r,o,u){var h,f,p,m=new d(o>=0?o:l),g=new a(r);g.encodeStart(0,0),h=n.factory(g,65280,256);var y=s.factory(g);f=function(e){return e>256?y(e):h(e)},p=function(){g.encodeFinish()};var v,b=new t(h,256,o<0?257:256),w=[];for(v=0;v<16;v++)w[v]=new i(1048576,1,h,f);for(var k,S=0,_=0;S!==o;){var E=e.readByte();k=m.pos;var C=m.getIndex(k,0);if(0!==C){for(var O=(--C>>>20)+1,x=0;m.get(C+x)===E&&x<1048575;)x++,m.put(E),E=e.readByte();O===x?w[15&_].encode(-1):w[15&_].encode(x),m.getIndex(k,x),S+=x,_<<=1,x>0&&(_|=1)}var B=m.get(m.pos-1);if(E===c.EOF){o<0&&b.encode(256,B);break}b.encode(E,B),m.put(E),S++}p&&p()}),h.decompressFile=u.decompressFileHelper(h.MAGIC,function(r,c,u){var h,p,m,g=!!(128&r.readByte()),y=new d(u>=0?u:l);if(g){var v=new e(r);h=o.factory(v,f),p=s.factory(v)}else{var b=new a(r);b.decodeStart(!0),h=n.factory(b,65280,256);var w=s.factory(b);p=function(e){return e>256?w(e):h(e)},m=function(){b.decodeFinish()}}var k,S=new t(h,256,u<0?257:256),_=[];for(k=0;k<16;k++)_[k]=new i(1048576,1,h,p);for(var E,C,O=0,x=0;O!==u;){E=y.pos;var B=y.getIndex(E,0);if(0!==B){var A=(--B>>>20)+1,R=_[15&x].decode();for(R<0&&(R=A),k=0;k<R;k++)C=y.get(B+k),c.writeByte(y.put(C));y.getIndex(E,R),O+=R,x<<=1,R>0&&(x|=1)}if(O===u)break;var T=y.get(y.pos-1);if(256===(C=S.decode(T)))break;c.writeByte(y.put(C)),O++}m&&m()}),h}(r(8196),r(4820),r(936),r(5623),r(886),r(9461),r(1679),r(1249),r(3403),r(6015))},417(e,t,r){var n,o,i,s;e.exports=(n=r(1249),r(3403),o=r(6015),i=function(e,t){return e-t},(s=function(e,t,r,n,i){this.coder=e,this.increment=+n||256,this.max_prob=+r||65280,console.assert(this.max_prob+(this.increment-1)<=65535),this.sym=o.makeU16Buffer(t+1),this.prob=o.makeU16Buffer(t+2),this.sym[0]=t,this.prob[0]=0,this.seenSyms=1,this.prob[this.seenSyms]=this.increment,this.numSyms=t,i&&(this.sortedSeen=[t])}).factory=function(e,t,r,n){return function(o){return new s(e,o,t,r,n)}},s.prototype.clone=function(){var e,t=new s(this.coder,this.numSyms,this.max_prob,this.increment,!!this.sortedSeen);for(e=0;e<this.seenSyms;e++)t.sym[e]=this.sym[e],t.prob[e]=this.prob[e];return t.prob[e]=this.prob[e],t.seenSyms=this.seenSyms,this.sortedSeen&&(t.sortedSeen=this.sortedSeen.slice(0)),t},s.prototype._update=function(e,t,r){var n,o;for(n=t;n<this.seenSyms-1;n++)this.sym[n]=this.sym[n+1],this.prob[n]=this.prob[n+1]-r;t<this.seenSyms?(this.sym[n]=e,this.prob[n]=this.prob[n+1]-r,this.prob[this.seenSyms]=o=this.prob[this.seenSyms]+this.increment,e===this.numSyms&&this.seenSyms>=this.numSyms&&(o=this.prob[--this.seenSyms],this.sortedSeen&&this.sortedSeen.length--)):(o=this.prob[this.seenSyms],this.sym[t]=e,this.prob[t]=o,o+=this.increment,this.prob[++this.seenSyms]=o,this.sortedSeen&&(this.sortedSeen.push(e),this.sortedSeen.sort(i))),o>=this.max_prob&&this._rescale()},s.prototype._rescale=function(){var e,t,r=0,n=!0;for(this.sortedSeen&&(this.sortedSeen.length=0),e=0,t=0;e<this.seenSyms;e++){var o=this.sym[e],s=this.prob[e+1]-this.prob[e];(s>>>=1)>0&&(o===this.numSyms&&(n=!1),this.sym[t]=o,this.prob[t++]=r,r+=s,this.sortedSeen&&this.sortedSeen.push(o))}this.prob[t]=r,this.seenSyms=t,this.sortedSeen&&this.sortedSeen.sort(i),n&&this.seenSyms<this.numSyms&&this._update(this.numSyms,this.seenSyms)},s.prototype.decode=function(){var e,t=this.prob[this.seenSyms],r=this.coder.decodeCulFreq(t);for(e=this.seenSyms-1;e>=0&&!(this.prob[e]<=r);e--);console.assert(e>=0);var n=this.sym[e],o=this.prob[e],i=this.prob[e+1]-o;if(this.coder.decodeUpdate(i,o,t),this._update(n,e,i),n===this.numSyms){if(i=1,t=this.numSyms,this.sortedSeen){var s=this.sortedSeen;for(t=this.numSyms-this.seenSyms,s[s.length-1]===this.numSyms&&t++,n=o=this.coder.decodeCulFreq(t),e=0;e<s.length&&s[e]<=n;e++)n++}else n=o=this.coder.decodeCulFreq(t);this.coder.decodeUpdate(i,o,t),this._update(n,this.seenSyms)}return n},s.prototype.encode=function(e){var t,r,n,o;for(t=this.seenSyms-1;t>=0;t--)if(e===this.sym[t])return n=this.prob[t],r=this.prob[t+1]-n,o=this.prob[this.seenSyms],this.coder.encodeFreq(r,n,o),this._update(e,t,r);if(console.assert(e!==this.numSyms),this.encode(this.numSyms),r=1,n=e,o=this.numSyms,this.sortedSeen){var i=this.sortedSeen;for(o-=this.seenSyms,i[i.length-1]===this.numSyms&&o++,t=0;t<i.length&&i[t]<e;t++)n--}return this.coder.encodeFreq(r,n,o),this._update(e,this.seenSyms)},s.MAGIC="mtfm",s.compressFile=o.compressFileHelper(s.MAGIC,function(e,t,r,i,a){var c=new n(t);c.encodeStart(a,1);var u=new s(c,r<0?257:256);o.compressWithModel(e,r,u),c.encodeFinish()},!0),s.decompressFile=o.decompressFileHelper(s.MAGIC,function(e,t,r){var i=new n(e);i.decodeStart(!0);var a=new s(i,r<0?257:256);o.decompressWithModel(t,r,a),i.decodeFinish()}),s)},1679(e,t,r){var n,o,i;e.exports=(n=r(8196),o=r(6015),(i=function(e,t){this.bitstream=e,this.bits=o.fls(t-1)}).factory=function(e){return function(t){return new i(e,t)}},i.prototype.encode=function(e){var t;for(t=this.bits-1;t>=0;t--){var r=e>>>t&1;this.bitstream.writeBit(r)}},i.prototype.decode=function(){var e,t=0;for(e=this.bits-1;e>=0;e--)t<<=1,this.bitstream.readBit()&&t++;return t},i.MAGIC="nomo",i.compressFile=o.compressFileHelper(i.MAGIC,function(e,t,r,s){var a=new n(t),c=new i(a,r<0?257:256);o.compressWithModel(e,r,c),a.flush()}),i.decompressFile=o.decompressFileHelper(i.MAGIC,function(e,t,r){var s=new n(e),a=new i(s,r<0?257:256);o.decompressWithModel(t,r,a)}),i)},736(e,t,r){e.exports=function(e,t){var r=1<<18,n=function(){this.buffer=t.makeU8Buffer(r),this.pos=0,this.firstPass=!0;for(var e=0;e<5;e++)this.put("cSaCsA".charCodeAt(e%6))};n.prototype.put=function(e){return this.buffer[this.pos++]=e,this.pos>=r&&(this.pos=0,this.firstPass=!1),e},n.prototype.get=function(e){return this.buffer[262143&e]},n.prototype.context=function(e,t){var n,o=[];for(e=e-t&262143,n=0;n<t;n++)o.push(this.buffer[e++]),e>=r&&(e=0);return String.fromCharCode.apply(String,o)};var o=function(e,t){this.window=new n,this.contexts=Object.create(null);var r=function(){};r.prototype.encode=function(r,n){var o,i=0;for(o=0;o<r;o++)n[o]||i++;var s=t-n.total;e.encodeFreq(1,i,s)},r.prototype.decode=function(r){var n,o,i,s=t-r.total;for(o=i=e.decodeCulFreq(s),n=0;n<=o;n++)r[n]&&o++;return e.decodeUpdate(1,i,s),o},this.cm1coder=new r;var o=function(){this.sym=[t],this.prob=[0,256],this.refcount=0};o.prototype._rescale=function(){var e,r,n=this.sym.length,o=0,i=!0;for(e=0,r=0;e<n;e++){var s=this.sym[e],a=this.prob[e+1]-this.prob[e];(a>>>=1)>0&&(s===t&&(i=!1),this.sym[r]=s,this.prob[r++]=o,o+=a)}return this.prob[r]=o,n=this.sym.length=r,this.prob.length=n+1,i&&n<t&&(o=this._update(t,n,0,1)),o},o.prototype.update=function(e,t){var r=0;for(r=0;r<this.sym.length;r++)if(this.sym[r]===e)return this._update(e,r,this.prob[r+1]-this.prob[r],t);return this._update(e,r,0,t)},o.prototype._update=function(e,r,n,o){var i,s,a,c=this.sym.length;for(s=r;s<c-1;s++)this.sym[s]=this.sym[s+1],this.prob[s]=this.prob[s+1]-n;if(r<c)this.sym[s]=e,this.prob[s]=this.prob[s+1]-n,this.prob[c]=a=this.prob[c]+o;else if(a=this.prob[c],this.sym[r]=e,this.prob[r]=a,a+=o,this.prob[++c]=a,this.sym.length>t)for(i=0;i<c;i++)t===this.sym[i]&&(this._update(t,i,this.prob[i+1]-this.prob[i],-1),this.sym.length--,this.prob.length--,a=this.prob[this.prob.length-1]);return a>=65280&&(a=this._rescale()),a},o.prototype.encode=function(r,n){var o,i,s,a,c,u,h=this.sym.length,l=0,f=0,d=0;for(o=h-1;o>=0;o--){if(a=this.prob[o],s=this.prob[o+1]-a,r===this.sym[o]){for(i=o-1;i>=0&&l<n.total;i--)n[this.sym[i]]&&(l+=1,f+=u=this.prob[i+1]-this.prob[i],d+=u);return c=this.prob[h],a-=f,c-=d,e.encodeFreq(s,a,c),r!==t||(this._update(r,o,s,128),!1)}n[this.sym[o]]&&(l+=1,d+=s)}for(this.encode(t,n),console.assert(this.sym[this.sym.length-1]===t),o=0;o<this.sym.length-1;o++)n[this.sym[o]]||(n[this.sym[o]]=!0,n.total++)},o.prototype.decode=function(r){var n,o,i=this.sym.length,s=this.prob[i],a=0,c=0,u=0;for(o=i-1;o>=0&&a<r.total;o--)r[this.sym[o]]&&(a+=1,u+=this.prob[o+1]-this.prob[o]);var h=e.decodeCulFreq(s-u)+u;for(c=u,o=i-1;o>=0;o--)if(r[this.sym[o]])c-=n=this.prob[o+1]-this.prob[o],h-=n;else if(this.prob[o]<=h)break;console.assert(o>=0);var l=this.sym[o],f=this.prob[o],d=this.prob[o+1]-f;if(e.decodeUpdate(d,f-c,s-u),l<t)return l;for(this._update(l,o,d,128),console.assert(this.sym[this.sym.length-1]===t),o=0;o<this.sym.length-1;o++)r[this.sym[o]]||(r[this.sym[o]]=!0,r.total++);return-1},this.newContext=function(e){return new o},this.newExclude=function(){var e=Object.create(null);return e.total=0,e},function(){var e,t;for(e=0;e<5;e++)for(t=0;t<=e;t++){var r=this.window.context(t+(4-e),t);this.contexts[r]||(this.contexts[r]=this.newContext()),this.contexts[r].refcount++}}.call(this)};return o.prototype.update=function(e,t,r){var n,o,i;for(o=0;o<=5;o++)i=t.slice(5-o),(n=this.contexts[i])||(n=this.contexts[i]=this.newContext()),o>=r&&n.update(e,128),n.refcount++;t=this.window.context(this.window.pos+5,5);var s=this.window.firstPass;for(o=5;o>=0&&!s;o--)i=t.slice(0,o),n=this.contexts[i],console.assert(n),--n.refcount<=0&&(console.assert(""!==i),delete this.contexts[i]);this.window.put(e)},o.prototype.decode=function(){var e,t,r,n,o=this.window.context(this.window.pos,5),i=this.newExclude();for(t=5;t>=0;t--)if(r=o.slice(5-t),(e=this.contexts[r])&&(n=e.decode(i))>=0)return this.update(n,o,t),n;return n=this.cm1coder.decode(i),this.update(n,o,t),n},o.prototype.encode=function(e){var t,r=this.window.context(this.window.pos,5),n=this.newExclude();for(t=5;t>=0;t--){var o=r.slice(5-t),i=this.contexts[o];if(i&&i.encode(e,n))return void this.update(e,r,t)}this.cm1coder.encode(e,n),this.update(e,r,t)},o.MAGIC="ppm2",o.compressFile=t.compressFileHelper(o.MAGIC,function(r,n,i,s,a){var c=new e(n);c.encodeStart(a,1);var u=new o(c,i<0?257:256);t.compressWithModel(r,i,u),c.encodeFinish()},!0),o.decompressFile=t.decompressFileHelper(o.MAGIC,function(r,n,i){var s=new e(r);s.decodeStart(!0);var a=new o(s,i<0?257:256);t.decompressWithModel(n,i,a),s.decodeFinish()}),o}(r(1249),r(6015))},1249(e){e.exports=function(){var e=Math.pow(2,31),t=e>>>8,r=Math.pow(2,32)-1,n=function(t){this.low=0,this.range=e,this.buffer=0,this.help=0,this.bytecount=0,this.stream=t},o=function(n,o){for(;n.range<=t;){if(n.low<255<<23){for(o.writeByte(n.buffer);n.help;n.help--)o.writeByte(255);n.buffer=n.low>>>23&255}else if(n.low&e){for(o.writeByte(n.buffer+1);n.help;n.help--)o.writeByte(0);n.buffer=n.low>>>23&255}else if(n.help++,n.help>r)throw new Error("Too many bytes outstanding, file too large!");n.range=n.range<<8>>>0,n.low=(n.low<<8&e-1)>>>0,n.bytecount++}};n.prototype.encodeStart=function(t,r){this.low=0,this.range=e,this.buffer=t,this.help=0,this.bytecount=r},n.prototype.encodeFreq=function(e,t,r){o(this,this.stream);var n=this.range/r>>>0,i=n*t;this.low+=i,t+e<r?this.range=n*e:this.range-=i},n.prototype.encodeShift=function(e,t,r){o(this,this.stream);var n=this.range>>>r,i=n*t;this.low+=i,t+e>>>r?this.range-=i:this.range=n*e},n.prototype.encodeBit=function(e){this.encodeShift(1,e?1:0,1)},n.prototype.encodeByte=function(e){this.encodeShift(1,e,8)},n.prototype.encodeShort=function(e){this.encodeShift(1,e,16)},n.prototype.encodeFinish=function(){var e=this.stream;o(this,e),this.bytecount+=5;var r=this.low>>>23;if((this.low&t-1)>=(16777215&this.bytecount)>>>1&&r++,r>255)for(e.writeByte(this.buffer+1);this.help;this.help--)e.writeByte(0);else for(e.writeByte(this.buffer);this.help;this.help--)e.writeByte(255);return e.writeByte(255&r),e.writeByte(this.bytecount>>>16&255),e.writeByte(this.bytecount>>>8&255),e.writeByte(255&this.bytecount),this.bytecount},n.prototype.decodeStart=function(e){var t=e?0:this.stream.readByte();return"number"!=typeof t||t<0||(this.buffer=this.stream.readByte(),this.low=this.buffer>>>1,this.range=128),t};var i=function(e,r){for(;e.range<=t;)e.low=e.low<<8|e.buffer<<7&255,e.buffer=r.readByte(),e.low|=e.buffer>>>1,e.low=e.low>>>0,e.range=e.range<<8>>>0};return n.prototype.decodeCulFreq=function(e){i(this,this.stream),this.help=this.range/e>>>0;var t=this.low/this.help>>>0;return t>=e?e-1:t},n.prototype.decodeCulShift=function(e){i(this,this.stream),this.help=this.range>>>e;var t=this.low/this.help>>>0;return t>>>e?(1<<e)-1:t},n.prototype.decodeUpdate=function(e,t,r){var n=this.help*t;this.low-=n,t+e<r?this.range=this.help*e:this.range-=n},n.prototype.decodeBit=function(){var e=this.decodeCulShift(1);return this.decodeUpdate(1,e,2),e},n.prototype.decodeByte=function(){var e=this.decodeCulShift(8);return this.decodeUpdate(1,e,256),e},n.prototype.decodeShort=function(){var e=this.decodeCulShift(16);return this.decodeUpdate(1,e,65536),e},n.prototype.decodeFinish=function(){i(this,this.stream)},n.prototype.writeBit=n.prototype.encodeBit,n.prototype.readBit=n.prototype.decodeBit,n.prototype.writeByte=n.prototype.encodeByte,n.prototype.readByte=n.prototype.decodeByte,n}()},1737(e,t,r){var n,o,i,s,a;e.exports=(n=r(1249),o=r(3403),i=r(6015),s=1<<17,(a=Object.create(null)).MAGIC="smpl",a.compressFile=i.compressFileHelper(a.MAGIC,function(e,t,r,a,c){var u=new n(t);u.encodeStart(c,1);for(var h=i.makeU8Buffer(s),l=[],f=0,d=!1,p=function(){var t=0;for(t=0;t<256;t++)l[t]=0;if(d)f=0;else{for(t=0;t<s;){var r=e.readByte();if(r===o.EOF){d=!0;break}if(h[t++]=r,l[r]++,65535===l[r])break}f=t}};;){var m;if(p(),d&&0===f)break;for(u.encodeBit(!0),m=0;m<256;m++)u.encodeShort(l[m]);for(l[256]=f,m=256;m;m--)l[m-1]=l[m]-l[m-1];for(m=0;m<f;m++){var g=h[m];u.encodeFreq(l[g+1]-l[g],l[g],l[256])}}u.encodeBit(!1),u.encodeFinish()},!0),a.decompressFile=i.decompressFileHelper(a.MAGIC,function(e,t,r){var o=new n(e);for(o.decodeStart(!0);o.decodeBit();){var i,s=[];for(i=0;i<256;i++)s[i]=o.decodeShort();var a=0;for(i=0;i<256;i++){var c=s[i];s[i]=a,a+=c}for(s[256]=a,i=0;i<a;i++){var u,h=o.decodeCulFreq(a);for(u=0;u<256&&!(s[u]<=h&&h<s[u+1]);u++);o.decodeUpdate(s[u+1]-s[u],s[u],a),t.writeByte(u)}}o.decodeFinish()}),a)},3403(e,t,r){var n,o;e.exports=(n=r(6956),(o=function(){}).prototype.readByte=function(){var e=[0];return 0===this.read(e,0,1)?(this._eof=!0,-1):e[0]},o.prototype.read=function(e,t,r){for(var n,o=0;o<r;){if(-1===(n=this.readByte())){this._eof=!0;break}e[t+o++]=n}return o},o.prototype.eof=function(){return!!this._eof},o.prototype.seek=function(e){throw new Error("Stream is not seekable.")},o.prototype.tell=function(){throw new Error("Stream is not seekable.")},o.prototype.writeByte=function(e){var t=[e];this.write(t,0,1)},o.prototype.write=function(e,t,r){var n;for(n=0;n<r;n++)this.writeByte(e[t+n]);return r},o.prototype.flush=function(){},o.EOF=-1,n(o))},6015(e,t,r){e.exports=function(e,t){var r=Object.create(null),n=t.EOF;r.coerceInputStream=function(e,r){if("readByte"in e){if(r&&!("read"in e)){var o=e;(e=new t).readByte=function(){var e=o.readByte();return e===n&&(this._eof=!0),e},"size"in o&&(e.size=o.size),"seek"in o&&(e.seek=function(e){o.seek(e),this._eof=!1}),"tell"in o&&(e.tell=o.tell.bind(o))}}else{var i=e;(e=new t).size=i.length,e.pos=0,e.readByte=function(){return this.pos>=this.size?n:i[this.pos++]},e.read=function(e,t,r){for(var n=0;n<r&&this.pos<i.length;)e[t++]=i[this.pos++],n++;return n},e.seek=function(e){this.pos=e},e.tell=function(){return this.pos},e.eof=function(){return this.pos>=i.length}}return e};var o=function(e,t){this.buffer=e,this.resizeOk=t,this.pos=0};(o.prototype=Object.create(t.prototype)).writeByte=function(e){if(this.resizeOk&&this.pos>=this.buffer.length){var t=r.makeU8Buffer(2*this.buffer.length);t.set(this.buffer),this.buffer=t}this.buffer[this.pos++]=e},o.prototype.getBuffer=function(){if(this.pos!==this.buffer.length){if(!this.resizeOk)throw new TypeError("outputsize does not match decoded input");var e=r.makeU8Buffer(this.pos);e.set(this.buffer.subarray(0,this.pos)),this.buffer=e}return this.buffer},r.coerceOutputStream=function(e,t){var n={stream:e,retval:e};if(e){if("object"==typeof e&&"writeByte"in e)return n;"number"==typeof t?(console.assert(t>=0),n.stream=new o(r.makeU8Buffer(t),!1)):n.stream=new o(e,!1)}else n.stream=new o(r.makeU8Buffer(16384),!0);return Object.defineProperty(n,"retval",{get:n.stream.getBuffer.bind(n.stream)}),n},r.compressFileHelper=function(e,t,n){return function(o,i,s){o=r.coerceInputStream(o);var a,c,u=r.coerceOutputStream(i,i);for(i=u.stream,a=0;a<e.length;a++)i.writeByte(e.charCodeAt(a));if(c="size"in o&&o.size>=0?o.size:-1,n){var h=r.coerceOutputStream([]);for(r.writeUnsignedNumber(h.stream,c+1),h=h.retval,a=0;a<h.length-1;a++)i.writeByte(h[a]);n=h[h.length-1]}else r.writeUnsignedNumber(i,c+1);return t(o,i,c,s,n),u.retval}},r.decompressFileHelper=function(e,t){return function(n,o){var i;for(n=r.coerceInputStream(n),i=0;i<e.length;i++)if(e.charCodeAt(i)!==n.readByte())throw new Error("Bad magic");var s=r.readUnsignedNumber(n)-1,a=r.coerceOutputStream(o,s);return o=a.stream,t(n,o,s),a.retval}},r.compressWithModel=function(e,t,r){for(var o=0;o!==t;){var i=e.readByte();if(i===n){r.encode(256);break}r.encode(i),o++}},r.decompressWithModel=function(e,t,r){for(var n=0;n!==t;){var o=r.decode();if(256===o)break;e.writeByte(o),n++}},r.writeUnsignedNumber=function(e,t){console.assert(t>=0);var r,n=[];do{n.push(127&t),t=Math.floor(t/128)}while(0!==t);for(n[0]|=128,r=n.length-1;r>=0;r--)e.writeByte(n[r]);return e},r.readUnsignedNumber=function(e){for(var t,r=0;;){if(128&(t=e.readByte())){r+=127&t;break}r=128*(r+t)}return r};var i=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},s=function(e){return i(new Array(e))},a=function(e){return e};"undefined"!=typeof process&&Array.prototype.some.call(new Uint32Array(128),function(e){return 0!==e})&&(a=i),r.makeU8Buffer="undefined"!=typeof Uint8Array?function(e){return a(new Uint8Array(e))}:"undefined"!=typeof Buffer?function(e){var t=new Buffer(e);return t.fill(0),t}:s,r.makeU16Buffer="undefined"!=typeof Uint16Array?function(e){return a(new Uint16Array(e))}:s,r.makeU32Buffer="undefined"!=typeof Uint32Array?function(e){return a(new Uint32Array(e))}:s,r.makeS32Buffer="undefined"!=typeof Int32Array?function(e){return a(new Int32Array(e))}:s,r.arraycopy=function(e,t){console.assert(e.length>=t.length);for(var r=0,n=t.length;r<n;r++)e[r]=t[r];return e};var c=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];console.assert(256===c.length);var u=r.fls=function(e){return console.assert(e>=0),e>4294967295?32+u(Math.floor(e/4294967296)):4294901760&e?4278190080&e?24+c[e>>>24&255]:16+c[e>>>16]:65280&e?8+c[e>>>8]:c[e]};return r.log2c=function(e){return 0===e?-1:u(e-1)},e(r)}(r(6956),r(3403))},6956(e){e.exports=function(){"use strict";return Object.freeze?Object.freeze:function(e){return e}}()},650(e,t,r){e.exports=function(e,t,r,n,o,i,s,a,c,u,h,l,f,d,p,m,g,y,v){"use strict";return e({version:"0.0.1",BitStream:t,Stream:r,BWT:n,Context1Model:o,DefSumModel:i,FenwickModel:s,MTFModel:a,NoModel:c,Huffman:u,RangeCoder:h,BWTC:l,Bzip2:f,Dmc:d,Lzjb:p,LzjbR:m,Lzp3:g,PPM:y,Simple:v})}(r(6956),r(8196),r(3403),r(9010),r(4820),r(936),r(5623),r(417),r(1679),r(886),r(1249),r(1793),r(7026),r(2139),r(4845),r(6831),r(4416),r(736),r(1737))},181(e){"use strict";e.exports=require("buffer")},6982(e){"use strict";e.exports=require("crypto")},3167(e){"use strict";e.exports=require("domain")},4434(e){"use strict";e.exports=require("events")},9896(e){"use strict";e.exports=require("fs")},8611(e){"use strict";e.exports=require("http")},5692(e){"use strict";e.exports=require("https")},9278(e){"use strict";e.exports=require("net")},857(e){"use strict";e.exports=require("os")},6928(e){"use strict";e.exports=require("path")},2018(e){"use strict";e.exports=require("tty")},7016(e){"use strict";e.exports=require("url")},9023(e){"use strict";e.exports=require("util")},8167(e){"use strict";e.exports=require("worker_threads")},9003(e){"use strict";e.exports={version:"1.0.35"}},8330(e){"use strict";e.exports={rE:"1.0.4"}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const i=t[n]={id:n,loaded:!1,exports:{}};return e[n](i,i.exports,r),i.loaded=!0,i.exports}r.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.cw=e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";const{isMainThread:e}=r(8167);if(e){process.env.UV_THREADPOOL_SIZE||(process.env.UV_THREADPOOL_SIZE="32"),process.removeAllListeners("warning"),process.on("warning",e=>{"DEP0169"!==e.code&&console.error(e.stack||`${e.name}: ${e.message}`)});const{ManagedExtension:e}=r(5482);e(r(8803),{})}else r(3109)})(),module.exports={}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "airdcpp-share-backup",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Hub command /sharebackup [path] that saves a self-verified snapshot of your own share (folder names, file names, sizes, TTH) to a local backup file, with optional bz2 compression.",
5
5
  "main": "dist/main.js",
6
6
  "license": "MIT",