airdcpp-sample-proof-checker 1.2.10-beta

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.
Files changed (3) hide show
  1. package/README.md +203 -0
  2. package/dist/main.js +1 -0
  3. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # airdcpp-sample-proof-checker
2
+
3
+ Checks release folders for a missing Sample (with an mkv present) or
4
+ Proof subfolder, and searches for and redownloads just that subfolder
5
+ when needed -- not the whole release.
6
+
7
+ ## Detects
8
+
9
+ Via a manual scan (context menu), `/sampleproofcheck [path]`, and
10
+ automatically on every completed download:
11
+
12
+ - Release folders split into `.rar`/`.r00`-style files, but only if the
13
+ folder also contains at least one `.sfv` file (a release with no SFV
14
+ at all -- DIRFIX, PROOFFIX and similar repacks typically have neither
15
+ -- is skipped entirely rather than flagged for a missing Sample/Proof,
16
+ since those legitimately ship without one; see "Notes (1.2.3-beta)"
17
+ below).
18
+ - Within those: is the Sample folder missing, or does it contain no
19
+ `.mkv`?
20
+ - Within those: is the Proof folder missing?
21
+
22
+ ## Takes action on
23
+
24
+ - Sample missing/empty -> searches specifically for `<release name>
25
+ Sample`, and if a match is found, downloads only that subfolder into
26
+ the existing release folder.
27
+ - Proof missing -> same approach, searches specifically for `<release
28
+ name> Proof`.
29
+ - Both present -> nothing to do, moves straight on to the next folder.
30
+
31
+ ## Automatic (post-download) retry
32
+
33
+ Only checks triggered by the completed-download hook use retry logic;
34
+ `/sampleproofcheck` and the context menu items still search immediately,
35
+ once, no waiting.
36
+
37
+ - `retry_interval_minutes` (default 60) -- minutes to wait before the
38
+ first automatic search, and between retries.
39
+ - `retry_max_hours` (default 24, 0-168) -- how long to keep retrying
40
+ before giving up. 0 = try exactly once, immediately, no wait.
41
+ - `search_pause_seconds` (default 20) -- wait after starting a search
42
+ before reading results.
43
+ - `overflow_backoff_seconds` (default 60) -- extra pause automatically
44
+ applied after a "Search queue overflow" error.
45
+ - `restrict_to_share_folder` -- only run the automatic (post-download)
46
+ check within these virtual share folders (comma-separated, e.g.
47
+ `FiLMS,Series`). Leave empty to check the whole share.
48
+ - Retries cancel themselves as soon as the release folder itself is gone
49
+ (user removed the download), rather than continuing to search for a
50
+ Sample/Proof folder that no longer matters -- see "Notes (1.2.4-beta)"
51
+ below.
52
+
53
+ ## Smart features
54
+
55
+ - Background searches use the lowest search priority (1), so manual
56
+ searches/downloads always get sent to the hub first.
57
+ - One-at-a-time queue -- prevents overloading/hanging AirDC++.
58
+ - A Sample/Proof folder is never itself treated as a release folder, so
59
+ it can't trigger a search for its own Sample/Proof.
60
+ - Subs/Sub/SUBPACK folders are skipped.
61
+ - Excluded release groups configurable (default: `CyTSuNee`,
62
+ `SHiTSoNy`).
63
+ - Right-click "Check Sample/Proof for this folder" on your own filelist,
64
+ resolving to the exact real disk subfolder even when several real
65
+ folders are merged under one virtual share name.
66
+ - Right-click "Check Sample/Proof for this folder" on a bundle in the
67
+ Download Queue screen too -- no detour via Own filelist needed for
68
+ something you just downloaded. The Queue already reports a bundle's
69
+ real disk path directly, so this skips the virtual-path resolution the
70
+ filelist version needs. A single-file download (nothing to check) or
71
+ an already-removed queue item logs a warning instead of doing nothing
72
+ silently.
73
+ - Logs to the system log at startup whether each context menu item
74
+ registered.
75
+
76
+ ## Notes (1.2.10-beta)
77
+
78
+ Two changes, both purely to how help text is shown -- no scan/check
79
+ logic changed (confirmed by comparing the built extension bundle
80
+ before and after: byte-for-byte identical apart from the help-related
81
+ lines):
82
+
83
+ - `/sampleproofcheck help` and `/sampleproofcheckhelp` now reply in the
84
+ same hub or private-chat window the command was typed in, instead of
85
+ the general system log -- matching how `/rvalidator help` already
86
+ behaved in airdcpp-release-fixxer.
87
+ - The help text itself is now a short list of commands, one per line,
88
+ instead of a single long sentence.
89
+
90
+ Also: the source code for this extension has been reformatted for
91
+ readability (statements one per line instead of comma-chained), with
92
+ no functional change -- verified by comparing the built bundle before
93
+ and after the reformat.
94
+
95
+ ## Notes (1.2.9-beta)
96
+
97
+ Fixed a bug where `/sampleproofcheck help` was silently treated as a
98
+ literal folder path (`help`) to scan, instead of showing usage -- since
99
+ there's essentially never a real share folder actually named "help",
100
+ this just failed quietly rather than doing anything useful. The
101
+ separate `/sampleproofcheckhelp` command already worked correctly and
102
+ is unchanged; this just also catches the more natural `<command> help`
103
+ typing pattern (only when "help" is the entire argument -- a real path
104
+ is still free to contain the word). Same class of bug found and fixed
105
+ at the same time in airdcpp-sfv-folder-checker and airdcpp-share-backup.
106
+
107
+ ## Notes (1.2.7-beta)
108
+
109
+ Reverted the 1.2.6-beta rename: back to `airdcpp-sample-proof-checker`.
110
+ Turns out the official "name must start with airdcpp-" requirement is
111
+ real after all, just narrower than a quick test had suggested -- a
112
+ minimal test extension with no settings (`dce-hello-fixxer`) loaded,
113
+ ran, and handled chat commands fine under a non-`airdcpp-`-prefixed
114
+ name, which looked like proof the whole requirement was obsolete. But
115
+ every real extension in this family uses settings, and AirDC++ rejects
116
+ the settings-registration API call (`POST extensions/<name>/settings/
117
+ definitions`) for a non-`airdcpp-`-prefixed name -- confirmed with an
118
+ isolated one-line diff (only `name`/`version` changed, nothing else)
119
+ that reproduced a clean crash: a 400 on that endpoint, silently
120
+ swallowed by the settings library, followed by a hard crash the moment
121
+ any setting was read. Confirmed consistent even after a full AirDC++
122
+ restart, so not a one-time registration race either. Back to
123
+ `airdcpp-` for good. No functional change otherwise.
124
+
125
+ ## Notes (1.2.6-beta)
126
+
127
+ Renamed the package from `airdcpp-sample-proof-checker` to
128
+ `airdcpp-sample-proof-checker`. AirDC++'s official extension spec says a
129
+ package name "must start with airdcpp-", but that turned out to only
130
+ apply to extensions published through npm's own registry and picked up
131
+ via AirDC++'s in-app update checker -- a locally-installed or
132
+ FulDC++-catalogue extension with a non-`airdcpp-`-prefixed name loads
133
+ and runs identically (confirmed with a small purpose-built test
134
+ extension, installed manually and via `dce-tiny-fileserver`'s
135
+ auto-install, in real AirDC++ 4.30). Since this whole family is only
136
+ ever installed that way, `dce-` (Direct Connect Extension) reads better
137
+ than a name implying it only works with one specific client. No
138
+ functional change otherwise.
139
+
140
+ ## Notes (1.2.5-beta)
141
+
142
+ Added `repository` and `bugs` fields to `package.json` (placeholder
143
+ GitHub URL -- replace `YOUR-USERNAME-HERE` with the real account/repo
144
+ before actually running `npm publish`), and flipped `private` from
145
+ `true` back to `false` in preparation for an eventual real npm publish.
146
+ Until that publish actually happens, this brings back the npmjs.org
147
+ update-check 404 that `private: true` had deliberately silenced --
148
+ harmless, just a log line, and easy to re-suppress by setting `private`
149
+ back to `true` for anyone installing from source/zip rather than a real
150
+ npm publish. Also added this file -- earlier releases shipped without an
151
+ `EXTENSION_README.md`, unlike the other extensions in this family.
152
+
153
+ ## Notes (1.2.4-beta)
154
+
155
+ Fixed a bug where the automatic retry loop kept searching for a missing
156
+ Sample/Proof folder on schedule even after the user deleted the entire
157
+ release folder from disk -- the retry only checked whether the
158
+ Sample/Proof *sub*folder existed (naturally always false once the parent
159
+ is gone), never whether the release folder itself still existed, so it
160
+ kept trying until `retry_max_hours` ran out regardless. Each retry
161
+ attempt now checks the release folder's own existence first; if it's
162
+ gone, the retry is canceled immediately and a system log line explains
163
+ why.
164
+
165
+ ## Notes (1.2.3-beta)
166
+
167
+ A release folder with no `.sfv` file at all (DIRFIX, PROOFFIX and
168
+ similar repack folders typically have neither) is now skipped entirely
169
+ instead of being flagged for a missing Sample/Proof. Fixed after a real
170
+ DIRFIX folder triggered a false "Sample folder missing" warning
171
+ immediately after being added to share -- these repacks legitimately
172
+ ship without a Sample or Proof of their own (a PROOFFIX folder is often
173
+ effectively the proof), so there was nothing to search for in the first
174
+ place.
175
+
176
+ ## Notes (1.2.2-beta)
177
+
178
+ Added the "Check Sample/Proof for this folder" context menu item to the
179
+ Download Queue screen, alongside the existing Own filelist item -- no
180
+ detour via Own filelist needed for something you just downloaded.
181
+
182
+ ## A note on variable names
183
+
184
+ This project was originally developed directly against the minified
185
+ webpack bundle (edited in place across many sessions before a readable
186
+ source tree existed), so `src/main.js` still uses short/single-letter
187
+ local variable names in places rather than fully descriptive ones.
188
+ Renaming them all safely would need an AST-aware refactoring tool to
189
+ avoid mixing up variables that reuse the same letter in different,
190
+ unrelated scopes, so they were deliberately left as-is. The file's own
191
+ top-of-file comment includes a map of what each short name does --
192
+ follow the comments and structure rather than the variable names.
193
+
194
+ ## Building from source
195
+
196
+ ```
197
+ npm install
198
+ npm run build
199
+ ```
200
+
201
+ Produces `dist/main.js`. Copy this project's folder (with `dist/main.js`
202
+ and `package.json`) into your AirDC++ extensions folder, or zip it up the
203
+ way the packaged release is structured.
package/dist/main.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{var e={3605(e,t,n){const r=n(7927),o=n(7074);e.exports=function(e,t){const{extensionName:i,configVersion:s,definitions:a}=t;r(s,"Settings version should be a positive integer"),r(Array.isArray(a),"Setting definitions should be an array");const c=((e,t)=>({postDefinitions:n=>e.post(`extensions/${t}/settings/definitions`,n),getSettings:()=>e.get(`extensions/${t}/settings`),updateSettings:n=>e.patch(`extensions/${t}/settings`,n),addSettingUpdateListener:n=>e.addListener("extensions","extension_settings_updated",n,t)}))(e,i);return o(t,e.logger,n(9896),c)}},7074(e,t,n){const r=n(7927),o=(e,t)=>Object.keys(e).reduce((n,r)=>{const o=t.find(e=>e.key===r);return o?(e[r]===o.default_value||(n[r]=e[r]),n):n},{});e.exports=function(e,t,n,i){const{configFile:s,configVersion:a,definitions:c}=e;let l,u;const h=e=>{l={...l,...e},u&&u(e),t.verbose(`Writing settings to ${s}...`);const r={version:a,settings:o(l,c)};n.writeFile(s,JSON.stringify(r,null,2),e=>{e&&t.error(`Failed to save settings to ${s}: ${e}`)})},f=e=>!!c.find(t=>t.key===e);return{getValue:e=>(r(f(e),`Definition for key ${e} was not found`),l[e]),setValue:(e,t)=>(r(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(n.readFileSync(s,"utf8"));if(i&&(!i.version||!i.settings))throw"Invalid settings format";i.version!==a&&e?(l=e(i.version,i.settings),r(l,"Migration handler should return the new settings")):l=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(l).reduce((e,t)=>(f(t)&&(e[t]=l[t]),e),{});await i.updateSettings(e)}l=await i.getSettings(),i.addSettingUpdateListener(h)})(o)}catch(e){t.error("Failed to register settings: "+e.message)}u&&u(l)},set onValuesUpdated(e){u=e},getValues:()=>({...l})}}},5482(e,t,n){"use strict";n.d(t,{ManagedExtension:()=>G});var r=n.cw(function(e,t){const r=n(4083),{stdout:s,stderr:a}=u(),{stringReplaceAll:c,stringEncaseCRLFWithFirstIndex:l}=i(),{isArray:h}=Array,f=["ansi","ansi","ansi256","ansi16m"],d=Object.create(null);class p{constructor(e){return g(e)}}const g=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 n=s?s.level:0;e.level=void 0===t.level?n:t.level})(t,e),t.template=(...e)=>S(t.template,...e),Object.setPrototypeOf(t,m.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 m(e){return g(e)}for(const[e,t]of Object.entries(r))d[e]={get(){const n=w(this,b(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:n}),n}};d.visible={get(){const e=w(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};const v=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(const e of v)d[e]={get(){const{level:t}=this;return function(...n){const o=b(r.color[f[t]][e](...n),r.color.close,this._styler);return w(this,o,this._isEmpty)}}};for(const e of v)d["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const o=b(r.bgColor[f[t]][e](...n),r.bgColor.close,this._styler);return w(this,o,this._isEmpty)}}};const y=Object.defineProperties(()=>{},{...d,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),b=(e,t,n)=>{let r,o;return void 0===n?(r=e,o=t):(r=n.openAll+e,o=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:o,parent:n}},w=(e,t,n)=>{const r=(...e)=>h(e[0])&&h(e[0].raw)?k(r,S(r,...e)):k(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,y),r._generator=e,r._styler=t,r._isEmpty=n,r},k=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t;let n=e._styler;if(void 0===n)return t;const{openAll:r,closeAll:o}=n;if(-1!==t.indexOf(""))for(;void 0!==n;)t=c(t,n.close,n.open),n=n.parent;const i=t.indexOf("\n");return-1!==i&&(t=l(t,o,r,i)),r+t+o};let _;const S=(e,...t)=>{const[n]=t;if(!h(n)||!h(n.raw))return t.join(" ");const r=t.slice(1),i=[n.raw[0]];for(let e=1;e<n.length;e++)i.push(String(r[e-1]).replace(/[{}\\]/g,"\\$&"),String(n.raw[e]));return void 0===_&&(_=o()),_(e,i.join(""))};Object.defineProperties(m.prototype,d);const E=m();E.supportsColor=s,E.stderr=m({level:a?a.level:0}),E.stderr.supportsColor=a,e.exports=E}),o=()=>n(2991),i=n.cw(function(e,t){e.exports={stringReplaceAll:(e,t,n)=>{let r=e.indexOf(t);if(-1===r)return e;const o=t.length;let i=0,s="";do{s+=e.substr(i,r-i)+t+n,i=r+o,r=e.indexOf(t,i)}while(-1!==r);return s+=e.substr(i),s},stringEncaseCRLFWithFirstIndex:(e,t,n,r)=>{let o=0,i="";do{const s="\r"===e[r-1];i+=e.substr(o,(s?r-1:r)-o)+t+(s?"\r\n":"\n")+n,o=r+1,r=e.indexOf("\n",o)}while(-1!==r);return i+=e.substr(o),i}}}),s=n.cw(function(e,t){e.exports=(e,t=process.argv)=>{const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),o=t.indexOf("--");return-1!==r&&(-1===o||r<o)}}),a=n.cw(function(e,t){function n(e){return"number"==typeof e||!!/^0x[0-9a-f]+$/i.test(e)||/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function r(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 l(e,t,n){for(var i=e,s=0;s<t.length-1;s++){var a=t[s];if(r(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];r(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]=n:Array.isArray(i[c])?i[c].push(n):i[c]=[i[c],n])}function u(e,t,r){if(!r||!o.unknownFn||function(e,t){return o.allBools&&/^--[^=]+$/.test(t)||o.strings[e]||o.bools[e]||i[e]}(e,r)||!1!==o.unknownFn(r)){var s=!o.strings[e]&&n(t)?Number(t):t;l(c,e.split("."),s),(i[e]||[]).forEach(function(e){l(c,e.split("."),s)})}}Object.keys(o.bools).forEach(function(e){u(e,void 0!==a[e]&&a[e])});var h=[];-1!==e.indexOf("--")&&(h=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var f=0;f<e.length;f++){var d,p,g=e[f];if(/^--.+=/.test(g)){var m=g.match(/^--([^=]+)=([\s\S]*)$/);d=m[1];var v=m[2];o.bools[d]&&(v="false"!==v),u(d,v,g)}else if(/^--no-.+/.test(g))u(d=g.match(/^--no-(.+)/)[1],!1,g);else if(/^--.+/.test(g))d=g.match(/^--(.+)/)[1],void 0===(p=e[f+1])||/^(-|--)[^-]/.test(p)||o.bools[d]||o.allBools||i[d]&&s(d)?/^(true|false)$/.test(p)?(u(d,"true"===p,g),f+=1):u(d,!o.strings[d]||"",g):(u(d,p,g),f+=1);else if(/^-[^-]+/.test(g)){for(var y=g.slice(1,-1).split(""),b=!1,w=0;w<y.length;w++)if("-"!==(p=g.slice(w+2))){if(/[A-Za-z]/.test(y[w])&&"="===p[0]){u(y[w],p.slice(1),g),b=!0;break}if(/[A-Za-z]/.test(y[w])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){u(y[w],p,g),b=!0;break}if(y[w+1]&&y[w+1].match(/\W/)){u(y[w],g.slice(w+2),g),b=!0;break}u(y[w],!o.strings[y[w]]||"",g)}else u(y[w],p,g);d=g.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])?(u(d,"true"===e[f+1],g),f+=1):u(d,!o.strings[d]||"",g):(u(d,e[f+1],g),f+=1))}else if(o.unknownFn&&!1===o.unknownFn(g)||c._.push(o.strings._||!n(g)?g:Number(g)),t.stopEarly){c._.push.apply(c._,e.slice(f+1));break}}return Object.keys(a).forEach(function(e){var t,n,r;t=c,n=e.split("."),r=t,n.slice(0,-1).forEach(function(e){r=r[e]||{}}),n[n.length-1]in r||(l(c,e.split("."),a[e]),(i[e]||[]).forEach(function(t){l(c,t.split("."),a[e])}))}),t["--"]?c["--"]=h.slice():h.forEach(function(e){c._.push(e)}),c}}),c=n.cw(function(e,t){e.exports=l()}),l=()=>n(7706),u=n.cw(function(e,t){const n=h(),r=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 l(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 r=a||0;if("dumb"===i.TERM)return r;if("win32"===process.platform){const e=n.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:r;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:r}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(l(!0,r.isatty(1))),stderr:c(l(!0,r.isatty(2)))}}),h=()=>n(857),f=()=>n(2018);const d="sessions/authorize";function p(){return p.c||(p.c=n.n(h()))}function g(){return g.c||(g.c=n.n(r()))}h(),r(),"object"==typeof navigator&&navigator.userAgent&&navigator.userAgent.includes("jsdom"),"object"==typeof process&&process.versions&&process.versions.node;const m="object"==typeof window&&"object"==typeof document&&9===document.nodeType;var v,y=n(7927),b=n.n(y),w=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},k="error",_="warn",S="info",E="verbose",C=((v={}).none=-1,v[k]=0,v[_]=1,v[S]=2,v[E]=3,v),O=!m||!!global.process&&!!global.process.env&&"test"===global.process.env.NODE_ENV;var x,R=n(4434),A=function(e,t){return!!t&&(Array.isArray(t)?-1!==t.indexOf(e):t.test(e))};x="undefined"!=typeof Promise?Promise:c();var P=Object.assign(x,{pending:function(){var e,t,n=new x(function(){e=arguments[0],t=arguments[1]});return{resolve:e,reject:t,promise:n}}});const T=P;var L=function(){return L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},L.apply(this,arguments)},j=function(e,t,n){var r=n.ignoredListenerEvents,o=void 0===r?[]:r,i=function(e,t){return b()(0!==t,'Entity ID "0" is not allowed'),t?e+t:e},s={},a=new R.EventEmitter,c={},l=function(n,r,o,i){r(o,function(r){e().post(n+"/"+i+"/resolve",r).catch(function(e){return t.error("Failed to complete hook action",n,e)})},function(r,o){e().post(n+"/"+i+"/reject",{reject_id:r,message:o}).catch(function(e){return t.error("Failed to complete failed hook action",n,e)})})},u=function(e){var t=c[e];t.forEach(function(e){return e.resolver.resolve(e.removeHandler)}),s[e]=t.length,delete c[e]},h=function(e,t){c[e].forEach(function(e){return e.resolver.reject(t)}),delete c[e]},f=function(n,r,o,i){var l=function(i){return void 0===i&&(i=!0),function(n,r,o,i){e().isConnected()&&(s[r]--,a.removeListener(r,o),0===s[r]&&(i&&e().isConnected()&&e().delete(n).catch(function(e){t.error("Failed to remove socket listener",n,e)}),delete s[r]))}(n,r,o,i)};if(!s[r]){c[r]||(c[r]=[],e().post(n,i).then(u.bind(j,r),h.bind(j,r)));var f=T.pending();return c[r].push({resolver:f,removeHandler:l}),f.promise}return s[r]++,T.resolve(l)},d={addViewUpdateListener:function(e,t,n){var r=i(e+"_updated",n);return a.on(r,t),function(){return function(e,t){a.removeListener(e,t)}(r,t)}},addListener:function(t,n,r,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(n,o),c=function(e,t,n){return t?e+"/"+t+"/listeners/"+n:e+"/listeners/"+n}(t,o,n);return a.on(s,r),f(c,s,r)},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,n,r,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=n;if(s[i]||c[i])throw"Hook exists";var u=t+"/hooks/"+n;return r=l.bind(j,u,r),a.on(i,r),f(u,i,r,o)},getPendingSubscriptionCount:function(){return Object.keys(c).length}};return L(L({},{onSocketDisconnected:function(){a.removeAllListeners(),s={}},handleMessage:function(e){var n=A(e.event,o);e.completion_id?(n||t.verbose(e.event,"(completion id "+e.completion_id+")",e.data),a.emit(e.event,e.data,e.completion_id)):(n||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 I=j;var N=function(){return N=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},N.apply(this,arguments)};var D=function(){return D=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},D.apply(this,arguments)},M={autoReconnect:!0,reconnectInterval:10,userSession:!1};const F=function(e,t){var n,r=D(D({},M),e),o=null,i=null,s=null,a=!0,c=null,l=null,u=null,h=function(e){var t=e.logLevel,n=void 0===t?E:t,r=e.logOutput,o=void 0===r?console:r,i=C[n];b()(o.log&&o.info&&o.warn&&o.error,"Invalid logOutput provided");var s=function(e,t,n){var r,i=w([],Array.prototype.slice.call(e),!0);O&&n&&(i=w([g()().magenta((r=new Date,"["+r.toLocaleDateString()+" "+r.toLocaleTimeString()+":"+r.getMilliseconds()+"]"))],i.map(function(e){return n("object"==typeof e?JSON.stringify(e,null," "):e)}),!0)),t.apply(o,i)},a={verbose:function(){i<C[E]||s(arguments,o.log,g()().gray)},info:function(){i<C[S]||s(arguments,o.info,g()().white.bold)},warn:function(){i<C[_]||s(arguments,o.warn,g()().yellow.bold)},error:function(){i<C[k]||s(arguments,o.error,g()().red.bold)}};return a}(r),f=I(function(){return s},h,r),p=function(e,t,n){var r,o=n.requestTimeout,i=void 0===o?30:o,s=n.ignoredRequestPaths,a={},c=0,l=function(n,r,o,i){if(void 0===i&&(i=!1),!i&&!e().isConnected())return t.warn("Attempting to send request on a non-authenticated socket: "+r),T.reject("Not authorized");if(!e().nativeSocket)return t.warn("Attempting to send request without a socket: "+r),T.reject("No socket");var l=(c>1e5&&(c=0),c+=1);b()(r,"Attempting socket request without a path");var u=A(r,s);u||t.verbose(g()().white.bold(l.toString()),n,r,o?function(e){return e&&e.hasOwnProperty("password")?N(N({},e),{password:"(hidden)"}):e}(o):"(no data)");var h=T.pending();a[l]={time:Date.now(),resolver:h,ignored:u};var f={path:r,method:n,data:o,callback_id:l};return e().nativeSocket.send(JSON.stringify(f)),h.promise},u=function(){var e=Date.now();Object.keys(a).forEach(function(n){a[n].time+1e3*i<e&&t.warn("Request "+n+" timed out")})},h={put:function(e,t){return l("PUT",e,t)},patch:function(e,t){return l("PATCH",e,t)},post:function(e,t){return l("POST",e,t)},delete:function(e){return l("DELETE",e)},get:function(e){return l("GET",e)},getPendingRequestCount:function(){return Object.keys(a).length}};return Object.assign(h,{reportRequestTimeouts:u}),N(N({},{onSocketConnected:function(){r=setInterval(u,3e4)},onSocketDisconnected:function(){var e;void 0===(e="Socket disconnected")&&(e="Request cancelled"),Object.keys(a).forEach(function(n){t.verbose("Canceling a pending request "+n+" ("+e+")"),a[n].resolver.reject(e)}),a={},clearTimeout(r)},handleMessage:function(e){var n=e.callback_id;if(a.hasOwnProperty(n)){if(e.code>=200&&e.code<=204){var r=e.data;a[n].ignored||t.verbose(g()().green(n.toString()),"SUCCEEDED",r||"(no data)"),a[n].resolver.resolve(r)}else{var o=e;o.error||t.warn("Error message missing from the response (this is an API bug that should be reported)",n,e);var i=o.code,s=o.error||{message:"(no error description)"};t.warn(n,i,s.message,function(e){return e.field&&e.code?e.field+" ("+e.code+")":""}(s)),a[n].resolver.reject({message:s.message,code:i,json:s})}delete a[n]}else t.warn("No pending request for an API response",n,e)},postAuthenticate:function(e,t){return l("POST",e,t,!0)}}),{socket:h})}(function(){return s},h,r);b()(e.url,'"url" must be defined in settings object');var m=function(){i&&(l&&l(),i=null)},v=function(e){e.wasClean?h.info("Websocket was closed normally"):h.error("Websocket failed: "+e.reason+" (code: "+e.code+")"),p.onSocketDisconnected(),f.onSocketDisconnected(),o=null,u&&u(e.reason,e.code,e.wasClean),i&&r.autoReconnect&&!a&&setTimeout(function(){a||s.reconnect().catch(function(e){h.error("Reconnect failed for a closed socket",e.message)})})},y=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=r.username),void 0===t&&(t=r.password),!e)throw'"username" option was not supplied for authentication';if(!t)throw'"password" option was not supplied for authentication';var n={username:e,password:t,grant_type:"password"};return p.postAuthenticate(d,n)},R=function(){var e={auth_token:i};return p.postAuthenticate("sessions/socket",e)},P=function(e,t,n,o){n().then(function(t){!function(e){if(i?h.info("Socket associated with an existing session"):(h.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(n){return n.code?i&&400===n.code&&r.autoReconnect?(h.info("Session lost, re-sending credentials"),m(),void P(e,t,x,o)):(401===n.code&&m(),s.disconnect(void 0,"Authentication failed"),void t(n)):(h.info("Socket disconnected during authentication, reconnecting"),void o())})},L=function(e,i,s,a){void 0===a&&(a=!0),o=new t(r.url);var c=function(){o=null,a?n=setTimeout(function(){h.info("Socket reconnecting"),L(e,i,s,a)},1e3*r.reconnectInterval):i("Cannot connect to the server")};o.onopen=function(){h.info("Socket connected"),o.onerror=function(e){h.error("Websocket failed: "+e.reason)},o.onclose=v,o.onmessage=y,P(e,i,s,c)},o.onerror=function(e){h.error("Connecting socket failed"),c()}},j=function(e,t){return a=!1,new T(function(n,r){h.info("Starting socket connect"),L(n,r,e,t)})},F=function(){return!(!o||o.readyState!==(o.OPEN||1)||!i)},B=function(){return!!o},q=function(){clearTimeout(n),a=!0},$=function(e,t){void 0===e&&(e=!1),void 0===t&&(t="Manually disconnected by the client"),o?(h.info("Disconnecting socket"),e||q(),o.close(1e3,t)):a?h.warn("Attempting to disconnect a closed socket (ignore)"):e?h.verbose("Attempting to disconnect a closed socket with auto reconnect enabled (continue connecting)"):(h.verbose("Disconnecting a closed socket with auto reconnect enabled (cancel reconnect)"),q())};return s=D(D({connect:function(e,t,n){if(void 0===n&&(n=!0),B())throw"Connect may only be used for a closed socket";return m(),j(function(){return x(e,t)},n)},connectRefreshToken:function(e,t){if(void 0===t&&(t=!0),B())throw"Connect may only be used for a closed socket";return m(),j(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),B())throw"Reconnect may only be used for a closed socket";if(e&&(i=e),!i)throw"No session token available for reconnecting";return h.info("Reconnecting socket"),j(R,t)},logout:function(){var e=T.pending();return s.delete("sessions/self").then(function(t){h.info("Logout succeed"),m(),e.resolve(t),$(void 0,"Logged out")}).catch(function(t){h.error("Logout failed",t),e.reject(t)}),e.promise},disconnect:$,isConnecting:function(){return!(!o||F())},isConnected:F,isActive:B,logger:h,waitDisconnected:function(e){void 0===e&&(e=2e3);var t=e>0?e/50:0;return new T(function(n,r){var o=0,i=function(){B()?o>=t?(h.error("Socket disconnect timed out after "+e+" ms"),r("Socket disconnect timed out")):(setTimeout(i,50),o++):n()};i()})},set onConnected(e){c=e},set onSessionReset(e){l=e},set onDisconnected(e){u=e},get onConnected(){return c},get onSessionReset(){return l},get onDisconnected(){return u},get nativeSocket(){return o}},f.socket),p.socket)};function B(){return B.c||(B.c=n.n(a()))}a();const q={autoReconnect:!1,ignoredRequestPaths:["sessions/activity"]},$={minSleepDetectTimeout:3e4,aliveCheckInterval:5e3},U=(e,t)=>{const r=B()()(process.argv.slice(2)),o=`ws://${r.apiUrl}`,i=F(Object.assign(Object.assign(Object.assign({logLevel:r.debug?"verbose":"info"},q),e),{url:o}),n(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,r);return{argv:r,socket:i,connectUrl:o,api:s,options:Object.assign(Object.assign({},$),t)}},H=(e,t)=>e.argv.appPid?((e,{socket:t,api:n,options:r},o)=>{let i,s=Date.now(),a=r.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:()=>{n.getSettingValues(["ping_timeout"]).then(e=>{const n=1e3*e.ping_timeout;n>a&&(a=n,t.logger.info(`Alive check timeout adjusted to match the API ping timeout (${n} ms)`)),i=setInterval(c,r.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},n)=>{let r,o=Date.now()+9999;const i=()=>{if(o+1e4<Date.now())return e.logger.error("Socket timed out, requesting restart..."),n(),void process.exit(124);t.activity().then(e=>{o=Date.now()}).catch(t=>{e.logger.error(`Ping failed: ${t.message}`)})};return{start:()=>{r=setInterval(i,4e3)},stop:()=>{clearInterval(r)},getStats:()=>({sleepDetectTimeoutMs:1e4})}})(e,t);var V=n(7016);const z=e=>{const t=new V.URL(e);return{address:t.host,secure:"wss"===t.protocol}},G=(e,t={},n={},r=U)=>{const o=r(t,n),{argv:i,socket:s,connectUrl:a,api:c}=o;let l,u;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 h=()=>{u&&u()},f=H(o,h);s.onConnected=e=>{setTimeout(()=>{f.start(),l&&Promise.resolve(l(e)).then(()=>{i.signalReady&&c.ready().catch(e=>s.logger.error(`Failed to signal ready state: ${e.message}`))})},10)},s.onDisconnected=(e,t,n)=>{h(),n?(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",h),process.on("SIGINT",d),process.on("SIGTERM",d);const g="function"==typeof e?e:e.default;if(!g)throw"Extension entry is not a function ";return g(s,{name:i.name,configPath:i.settingsPath,logPath:i.logPath,debugMode:i.debug,server:z(a),set onStart(e){l=e},set onStop(e){u=e}}),s.reconnect(i.authToken,!1).catch(e=>{s.logger.error(`Failed to connect to server ${i.apiUrl}, exiting...`),h(),process.exit(1)}),{stop:()=>{f.stop()},getStats:()=>f.getStats()}};n(9896),n(3480),n(6928)},4083(e,t,n){"use strict";e=n.nmd(e);const r=(e,t)=>(...n)=>`[${e(...n)+t}m`,o=(e,t)=>(...n)=>{const r=e(...n);return`[${38+t};5;${r}m`},i=(e,t)=>(...n)=>{const r=e(...n);return`[${38+t};2;${r[0]};${r[1]};${r[2]}m`},s=e=>e,a=(e,t,n)=>[e,t,n],c=(e,t,n)=>{Object.defineProperty(e,t,{get:()=>{const r=n();return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0}),r},enumerable:!0,configurable:!0})};let l;const u=(e,t,r,o)=>{void 0===l&&(l=n(734));const i=o?10:0,s={};for(const[n,o]of Object.entries(l)){const a="ansi16"===n?"ansi":n;n===t?s[a]=e(r,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[n,r]of Object.entries(t)){for(const[n,o]of Object.entries(r))t[n]={open:`[${o[0]}m`,close:`[${o[1]}m`},r[n]=t[n],e.set(o[0],o[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="",t.bgColor.close="",c(t.color,"ansi",()=>u(r,"ansi16",s,!1)),c(t.color,"ansi256",()=>u(o,"ansi256",s,!1)),c(t.color,"ansi16m",()=>u(i,"rgb",a,!1)),c(t.bgColor,"ansi",()=>u(r,"ansi16",s,!0)),c(t.bgColor,"ansi256",()=>u(o,"ansi256",s,!0)),c(t.bgColor,"ansi16m",()=>u(i,"rgb",a,!0)),t}})},983(e,t,n){"use strict";var r=n(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,r(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&&r.requestFlush(),this.task=null,this.domain=null,o.push(this)}}},7342(e,t,n){"use strict";var r,o="function"==typeof setImmediate;function i(e){s.length||(u(),a=!0),s[s.length]=e}e.exports=i;var s=[],a=!1,c=0;function l(){for(;c<s.length;){var e=c;if(c+=1,s[e].call(),c>1024){for(var t=0,n=s.length-c;t<n;t++)s[t]=s[t+c];s.length-=c,c=0}}s.length=0,c=0,a=!1}function u(){var e=process.domain;e&&(r||(r=n(3167)),r.active=process.domain=null),a&&o?setImmediate(l):process.nextTick(l),e&&(r.active=process.domain=e)}i.requestFlush=u},6489(e){"use strict";e.exports={mask:(e,t,n,r,o)=>{for(var i=0;i<o;i++)n[r+i]=e[i]^t[3&i]},unmask:(e,t)=>{const n=e.length;for(var r=0;r<n;r++)e[r]^=t[3&r]}}},2627(e,t,n){"use strict";try{e.exports=n(8169)(__dirname)}catch(t){e.exports=n(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,n=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,r=/^(['"])((?:\\.|(?!\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],n="{"===e[1];return t&&!n&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(parseInt(e.slice(2,-1),16)):i.get(e)||e}function a(e,t){const n=[],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(r)))throw new Error(`Invalid Chalk template style argument: ${t} (in style '${e}')`);n.push(a[2].replace(o,(e,t,n)=>t?s(t):n))}else n.push(i)}return n}function c(e){n.lastIndex=0;const t=[];let r;for(;null!==(r=n.exec(e));){const e=r[1];if(r[2]){const n=a(e,r[2]);t.push([e].concat(n))}else t.push([e])}return t}function l(e,t){const n={};for(const e of t)for(const t of e.styles)n[t[0]]=e.inverse?null:t.slice(1);let r=e;for(const[e,t]of Object.entries(n))if(Array.isArray(t)){if(!(e in r))throw new Error(`Unknown Chalk style: ${e}`);r=t.length>0?r[e](...t):r[e]}return r}e.exports=(e,n)=>{const r=[],o=[];let i=[];if(n.replace(t,(t,n,a,u,h,f)=>{if(n)i.push(s(n));else if(u){const t=i.join("");i=[],o.push(0===r.length?t:l(e,r)(t)),r.push({inverse:a,styles:c(u)})}else if(h){if(0===r.length)throw new Error("Found extraneous } in Chalk template literal");o.push(l(e,r)(i.join(""))),i=[],r.pop()}else i.push(f)}),o.push(i.join("")),r.length>0){const e=`Chalk template literal is missing ${r.length} closing bracket${1===r.length?"":"s"} (\`}\`)`;throw new Error(e)}return o.join("")}},5659(e,t,n){const r=n(8156),o={};for(const e of Object.keys(r))o[r[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:n}=i[e];delete i[e].channels,delete i[e].labels,Object.defineProperty(i[e],"channels",{value:t}),Object.defineProperty(i[e],"labels",{value:n})}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,n=e[1]/255,r=e[2]/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=i-o;let a,c;i===o?a=0:t===i?a=(n-r)/s:n===i?a=2+(r-t)/s:r===i&&(a=4+(t-n)/s),a=Math.min(60*a,360),a<0&&(a+=360);const l=(o+i)/2;return c=i===o?0:l<=.5?s/(i+o):s/(2-i-o),[a,100*c,100*l]},i.rgb.hsv=function(e){let t,n,r,o,i;const s=e[0]/255,a=e[1]/255,c=e[2]/255,l=Math.max(s,a,c),u=l-Math.min(s,a,c),h=function(e){return(l-e)/6/u+.5};return 0===u?(o=0,i=0):(i=u/l,t=h(s),n=h(a),r=h(c),s===l?o=r-n:a===l?o=1/3+t-r:c===l&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*i,100*l]},i.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=i.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,100*s,100*r]},i.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(1-t,1-n,1-r);return[100*((1-t-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*((1-r-o)/(1-o)||0),100*o]},i.rgb.keyword=function(e){const t=o[e];if(t)return t;let n,i=1/0;for(const t of Object.keys(r)){const o=s(e,r[t]);o<i&&(i=o,n=t)}return n},i.keyword.rgb=function(e){return r[e]},i.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;return t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,[100*(.4124*t+.3576*n+.1805*r),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];return n/=95.047,r/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,[116*r-16,500*(n-r),200*(r-o)]},i.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let o,i,s;if(0===n)return s=255*r,[s,s,s];o=r<.5?r*(1+n):r+n-r*n;const a=2*r-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 n=e[1]/100,r=e[2]/100,o=n;const i=Math.max(r,.01);return r*=2,n*=r<=1?r:2-r,o*=i<=1?i:2-i,[t,100*(0===r?2*o/(i+o):2*n/(r+n)),(r+n)/2*100]},i.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const o=Math.floor(t)%6,i=t-Math.floor(t),s=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,o){case 0:return[r,c,s];case 1:return[a,r,s];case 2:return[s,r,c];case 3:return[s,a,r];case 4:return[c,s,r];case 5:return[r,s,a]}},i.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,o=Math.max(r,.01);let i,s;s=(2-n)*r;const a=(2-n)*o;return i=n*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 n=e[1]/100,r=e[2]/100;const o=n+r;let i;o>1&&(n/=o,r/=o);const s=Math.floor(6*t),a=1-r;i=6*t-s,1&s&&(i=1-i);const c=n+i*(a-n);let l,u,h;switch(s){default:case 6:case 0:l=a,u=c,h=n;break;case 1:l=c,u=a,h=n;break;case 2:l=n,u=a,h=c;break;case 3:l=n,u=c,h=a;break;case 4:l=c,u=n,h=a;break;case 5:l=a,u=n,h=c}return[255*l,255*u,255*h]},i.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o)),255*(1-Math.min(1,r*(1-o)+o))]},i.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let o,i,s;return o=3.2406*t+-1.5372*n+-.4986*r,i=-.9689*t+1.8758*n+.0415*r,s=.0557*t+-.204*n+1.057*r,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],n=e[1],r=e[2];return t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,[116*n-16,500*(t-n),200*(n-r)]},i.lab.xyz=function(e){let t,n,r;n=(e[0]+16)/116,t=e[1]/500+n,r=n-e[2]/200;const o=n**3,i=t**3,s=r**3;return n=o>.008856?o:(n-16/116)/7.787,t=i>.008856?i:(t-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},i.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let o;return o=360*Math.atan2(r,n)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(n*n+r*r),o]},i.lch.lab=function(e){const t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},i.rgb.ansi16=function(e,t=null){const[n,r,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(r/255)<<1|Math.round(n/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],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/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 n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*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 n=t[0];3===t[0].length&&(n=n.split("").map(e=>e+e).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},i.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.max(Math.max(t,n),r),i=Math.min(Math.min(t,n),r),s=o-i;let a,c;return a=s<1?i/(1-s):0,c=s<=0?0:o===t?(n-r)/s%6:o===n?2+(r-t)/s:4+(t-n)/s,c/=6,c%=1,[360*c,100*s,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let o=0;return r<1&&(o=(n-.5*r)/(1-r)),[e[0],100*r,100*o]},i.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],100*r,100*o]},i.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];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-n)*r,[255*(n*o[0]+c),255*(n*o[1]+c),255*(n*o[2]+c)]},i.hcg.hsv=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);let r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},i.hcg.hsl=function(e){const t=e[1]/100,n=e[2]/100*(1-t)+.5*t;let r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},i.hcg.hwb=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},i.hwb.hcg=function(e){const t=e[1]/100,n=1-e[2]/100,r=n-t;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],100*r,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),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},734(e,t,n){const r=n(5659),o=n(8507),i={};Object.keys(r).forEach(e=>{i[e]={},Object.defineProperty(i[e],"channels",{value:r[e].channels}),Object.defineProperty(i[e],"labels",{value:r[e].labels});const t=o(e);Object.keys(t).forEach(n=>{const r=t[n];i[e][n]=function(e){const t=function(...t){const n=t[0];if(null==n)return n;n.length>1&&(t=n);const r=e(t);if("object"==typeof r)for(let e=r.length,t=0;t<e;t++)r[t]=Math.round(r[t]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}(r),i[e][n].raw=function(e){const t=function(...t){const n=t[0];return null==n?n:(n.length>1&&(t=n),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)})}),e.exports=i},8507(e,t,n){const r=n(5659);function o(e,t){return function(n){return t(e(n))}}function i(e,t){const n=[t[e].parent,e];let i=r[t[e].parent][e],s=t[e].parent;for(;t[s].parent;)n.unshift(t[s].parent),i=o(r[t[s].parent][s],i),s=t[s].parent;return i.conversion=n,i}e.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(r);for(let n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}(),n=[e];for(t[e].distance=0;n.length;){const e=n.pop(),o=Object.keys(r[e]);for(let r=o.length,i=0;i<r;i++){const r=o[i],s=t[r];-1===s.distance&&(s.distance=t[e].distance+1,s.parent=e,n.unshift(r))}}return t}(e),n={},o=Object.keys(t);for(let e=o.length,r=0;r<e;r++){const e=o[r];null!==t[e].parent&&(n[e]=i(e,t))}return n}},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,n){function r(){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=n(9910)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"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,r)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=r,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(r())},9910(e,t,n){var r;function o(e){function n(){if(n.enabled){var e=n,o=+new Date,i=o-(r||o);e.diff=i,e.prev=r,e.curr=o,r=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(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n}),t.formatArgs.call(e,s),(n.log||t.log||console.log.bind(console)).apply(e,s)}}return n.namespace=e,n.enabled=t.enabled(e),n.useColors=t.useColors(),n.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),"function"==typeof t.init&&t.init(n),n}(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 n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length,o=0;o<r;o++)n[o]&&("-"===(e=n[o].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(6585),t.names=[],t.skips=[],t.formatters={}},5753(e,t,n){"undefined"!=typeof process&&"renderer"===process.type?e.exports=n(7833):e.exports=n(6033)},6033(e,t,n){var r=n(2018),o=n(9023);(t=e.exports=n(9910)).init=function(e){e.inspectOpts={};for(var n=Object.keys(t.inspectOpts),r=0;r<n.length;r++)e.inspectOpts[n[r]]=t.inspectOpts[n[r]]},t.log=function(){return s.write(o.format.apply(o,arguments)+"\n")},t.formatArgs=function(e){var n=this.namespace;if(this.useColors){var r=this.color,o=" [3"+r+";1m"+n+" ";e[0]=o+e[0].split("\n").join("\n"+o),e.push("[3"+r+"m+"+t.humanize(this.diff)+"")}else e[0]=(new Date).toUTCString()+" "+n+" "+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):r.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 n=t.substring(6).toLowerCase().replace(/_([a-z])/g,function(e,t){return t.toUpperCase()}),r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,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 r.WriteStream(e))._type="tty",t._handle&&t._handle.unref&&t._handle.unref();break;case"FILE":(t=new(n(9896).SyncWriteStream)(e,{autoClose:!1}))._type="fs";break;case"PIPE":case"TCP":(t=new(n(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,n,r,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 l=[n,r,o,i,s,a],u=0;(c=new Error(t.replace(/%s/g,function(){return l[u++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},9225(e){e.exports=r,r.strict=o,r.loose=i;var t=Object.prototype.toString,n={"[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 r(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 n[t.call(e)]}},3480(e,t,n){const r=n(5737),o=n(1276),{mkdirpNative:i,mkdirpNativeSync:s}=n(3831),{mkdirpManual:a,mkdirpManualSync:c}=n(6990),{useNative:l,useNativeSync:u}=n(4443),h=(e,t)=>(e=o(e),t=r(t),l(t)?i(e,t):a(e,t));h.sync=(e,t)=>(e=o(e),t=r(t),u(t)?s(e,t):c(e,t)),h.native=(e,t)=>i(o(e),r(t)),h.manual=(e,t)=>a(o(e),r(t)),h.nativeSync=(e,t)=>s(o(e),r(t)),h.manualSync=(e,t)=>c(o(e),r(t)),e.exports=h},4523(e,t,n){const{dirname:r}=n(6928),o=(e,t,n=void 0)=>n===t?Promise.resolve():e.statAsync(t).then(e=>e.isDirectory()?n:void 0,n=>"ENOENT"===n.code?o(e,r(t),t):void 0),i=(e,t,n=void 0)=>{if(n!==t)try{return e.statSync(t).isDirectory()?n:void 0}catch(n){return"ENOENT"===n.code?i(e,r(t),t):void 0}};e.exports={findMade:o,findMadeSync:i}},6990(e,t,n){const{dirname:r}=n(6928),o=(e,t,n)=>{t.recursive=!1;const i=r(e);return i===e?t.mkdirAsync(e,t).catch(e=>{if("EISDIR"!==e.code)throw e}):t.mkdirAsync(e,t).then(()=>n||e,r=>{if("ENOENT"===r.code)return o(i,t).then(n=>o(e,t,n));if("EEXIST"!==r.code&&"EROFS"!==r.code)throw r;return t.statAsync(e).then(e=>{if(e.isDirectory())return n;throw r},()=>{throw r})})},i=(e,t,n)=>{const o=r(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),n||e}catch(r){if("ENOENT"===r.code)return i(e,t,i(o,t,n));if("EEXIST"!==r.code&&"EROFS"!==r.code)throw r;try{if(!t.statSync(e).isDirectory())throw r}catch(e){throw r}}};e.exports={mkdirpManual:o,mkdirpManualSync:i}},3831(e,t,n){const{dirname:r}=n(6928),{findMade:o,findMadeSync:i}=n(4523),{mkdirpManual:s,mkdirpManualSync:a}=n(6990);e.exports={mkdirpNative:(e,t)=>(t.recursive=!0,r(e)===e?t.mkdirAsync(e,t):o(t,e).then(n=>t.mkdirAsync(e,t).then(()=>n).catch(n=>{if("ENOENT"===n.code)return s(e,t);throw n}))),mkdirpNativeSync:(e,t)=>{if(t.recursive=!0,r(e)===e)return t.mkdirSync(e,t);const n=i(t,e);try{return t.mkdirSync(e,t),n}catch(n){if("ENOENT"===n.code)return a(e,t);throw n}}}},5737(e,t,n){const{promisify:r}=n(9023),o=n(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=r(e.mkdir),e.stat=e.stat||e.fs.stat||o.stat,e.statAsync=r(e.stat),e.statSync=e.statSync||e.fs.statSync||o.statSync,e.mkdirSync=e.mkdirSync||e.fs.mkdirSync||o.mkdirSync,e}},1276(e,t,n){const r=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:o,parse:i}=n(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"===r){const t=/[*|"<>?:]/,{root:n}=i(e);if(t.test(e.substr(n.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e}},4443(e,t,n){const r=n(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===r.mkdir:()=>!1,a=i?e=>e.mkdirSync===r.mkdirSync:()=>!1;e.exports={useNative:s,useNativeSync:a}},6585(e){var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"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*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;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,r,"hour")||i(a,n,"minute")||i(a,t,"second")||a+" ms":function(e){return e>=o?Math.round(e/o)+"d":e>=r?Math.round(e/r)+"h":e>=n?Math.round(e/n)+"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,n){const r=require;"function"==typeof r.addon?e.exports=r.addon.bind(r):e.exports=n(1381)},1381(e,t,n){var r=n(9896),o=n(6928),i=n(857),s=require,a=process.config&&process.config.variables||{},c=!!process.env.PREBUILDS_ONLY,l=process.versions.modules,u=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",h=process.env.npm_config_arch||i.arch(),f=process.env.npm_config_platform||i.platform(),d=process.env.LIBC||(function(e){return"linux"===e&&r.existsSync("/etc/alpine-release")}(f)?"musl":"glibc"),p=process.env.ARM_VERSION||("arm64"===h?"8":a.arm_version)||"",g=(process.versions.uv||"").split(".")[0];function m(e){return s(m.resolve(e))}function v(e){try{return r.readdirSync(e)}catch(e){return[]}}function y(e,t){var n=v(e).filter(t);return n[0]&&o.join(e,n[0])}function b(e){return/\.node$/.test(e)}function w(e){var t=e.split("-");if(2===t.length){var n=t[0],r=t[1].split("+");if(n&&r.length&&r.every(Boolean))return{name:e,platform:n,architectures:r}}}function k(e,t){return function(n){return null!=n&&n.platform===e&&n.architectures.includes(t)}}function _(e,t){return e.architectures.length-t.architectures.length}function S(e){var t=e.split("."),n={file:e,specificity:0};if("node"===t.pop()){for(var r=0;r<t.length;r++){var o=t[r];if("node"===o||"electron"===o||"node-webkit"===o)n.runtime=o;else if("napi"===o)n.napi=!0;else if("abi"===o.slice(0,3))n.abi=o.slice(3);else if("uv"===o.slice(0,2))n.uv=o.slice(2);else if("armv"===o.slice(0,4))n.armv=o.slice(4);else{if("glibc"!==o&&"musl"!==o)continue;n.libc=o}n.specificity++}return n}}function E(e,t){return function(n){return!(null==n||n.runtime&&n.runtime!==e&&!function(e){return"node"===e.runtime&&e.napi}(n)||n.abi&&n.abi!==t&&!n.napi||n.uv&&n.uv!==g||n.armv&&n.armv!==p||n.libc&&n.libc!==d)}}function C(e){return function(t,n){return t.runtime!==n.runtime?t.runtime===e?-1:1:t.abi!==n.abi?t.abi?-1:1:t.specificity!==n.specificity?t.specificity>n.specificity?-1:1:0}}e.exports=m,m.resolve=m.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 n=y(o.join(e,"build/Release"),b);if(n)return n;var r=y(o.join(e,"build/Debug"),b);if(r)return r}var i=O(e);if(i)return i;var a=O(o.dirname(process.execPath));if(a)return a;var m=["platform="+f,"arch="+h,"runtime="+u,"abi="+l,"uv="+g,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 "+m+"\n loaded from: "+e+"\n");function O(e){var t=v(o.join(e,"prebuilds")).map(w).filter(k(f,h)).sort(_)[0];if(t){var n=o.join(e,"prebuilds",t.name),r=v(n).map(S).filter(E(u,l)).sort(C(u))[0];return r?o.join(n,r.file):void 0}}},m.parseTags=S,m.matchTags=E,m.compareTags=C,m.parseTuple=w,m.matchTuple=k,m.compareTuples=_},9551(e,t,n){"use strict";var r=n(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){r(function(){var n=1===e._y?t.onFulfilled:t.onRejected;if(null!==n){var r=function(e,t){try{return e(t)}catch(e){return i=e,s}}(n,e._z);r===s?u(t.promise,i):l(t.promise,r)}else 1===e._y?l(t.promise,e._z):u(t.promise,e._z)})}(e,t)}function l(e,t){if(t===e)return u(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){var n=function(e){try{return e.then}catch(e){return i=e,s}}(t);if(n===s)return u(e,i);if(n===e.then&&t instanceof a)return e._y=3,e._z=t,void h(e);if("function"==typeof n)return void d(n.bind(t),e)}e._y=1,e._z=t,h(e)}function u(e,t){e._y=2,e._z=t,a._C&&a._C(e,t),h(e)}function h(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,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function d(e,t){var n=!1,r=function(e){try{e(function(e){n||(n=!0,l(t,e))},function(e){n||(n=!0,u(t,e))})}catch(e){return i=e,s}}(e);n||r!==s||(n=!0,u(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,n){return new e.constructor(function(r,i){var s=new a(o);s.then(r,i),c(e,new f(t,n,s))})}(this,e,t);var n=new a(o);return c(this,new f(e,t,n)),n}},5556(e,t,n){"use strict";var r=n(9551);e.exports=r,r.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,n){"use strict";var r=n(9551);e.exports=r;var o=u(!0),i=u(!1),s=u(null),a=u(void 0),c=u(0),l=u("");function u(e){var t=new r(r._D);return t._y=1,t._z=e,t}r.resolve=function(e){if(e instanceof r)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 l;if("object"==typeof e||"function"==typeof e)try{var t=e.then;if("function"==typeof t)return new r(t.bind(e))}catch(e){return new r(function(t,n){n(e)})}return u(e)};var h=function(e){return"function"==typeof Array.from?(h=Array.from,Array.from(e)):(h=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 r&&e.then===r.prototype.then)return e.then(f,d);var t=e.then;if("function"==typeof t)return new r(t.bind(e)).then(f,d)}return f(e)}function g(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}r.all=function(e){var t=h(e);return new r(function(e,n){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 r&&a.then===r.prototype.then){for(;3===a._y;)a=a._z;return 1===a._y?i(s,a._z):(2===a._y&&n(a._z),void a.then(function(e){i(s,e)},n))}var c=a.then;if("function"==typeof c)return void new r(c.bind(a)).then(function(e){i(s,e)},n)}t[s]=a,0===--o&&e(t)}for(var s=0;s<t.length;s++)i(s,t[s])})},r.allSettled=function(e){return r.all(h(e).map(p))},r.reject=function(e){return new r(function(t,n){n(e)})},r.race=function(e){return new r(function(t,n){h(e).forEach(function(e){r.resolve(e).then(t,n)})})},r.prototype.catch=function(e){return this.then(null,e)},r.any=function(e){return new r(function(t,n){var o=h(e),i=!1,s=[];function a(e){i||(i=!0,t(e))}function c(e){s.push(e),s.length===o.length&&n(g(s))}0===o.length?n(g(s)):o.forEach(function(e){r.resolve(e).then(a,c)})})}},4293(e,t,n){"use strict";var r=n(9551);e.exports=r,r.prototype.finally=function(e){return this.then(function(t){return r.resolve(e()).then(function(){return t})},function(t){return r.resolve(e()).then(function(){throw t})})}},7706(e,t,n){"use strict";e.exports=n(9551),n(5556),n(4293),n(8635),n(9791),n(1727)},9791(e,t,n){"use strict";var r=n(9551),o=n(983);e.exports=r,r.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?function(e,t){for(var n=[],o=0;o<t;o++)n.push("a"+o);var s=["return function ("+n.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(n).concat([i]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],s)(r,e)}(e,t):function(e){for(var t=Math.max(e.length-1,3),n=[],o=0;o<t;o++)n.push("a"+o);var s=["return function ("+n.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) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.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)(r,e)}(e)};var i="function (err, res) {if (err) { rj(err); } else { rs(res); }}";r.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,i=this;try{return e.apply(this,arguments).nodeify(n,i)}catch(e){if(null==n)return new r(function(t,n){n(e)});o(function(){n.call(i,e)})}}},r.prototype.nodeify=function(e,t){if("function"!=typeof e)return this;this.then(function(n){o(function(){e.call(t,null,n)})},function(n){o(function(){e.call(t,n)})})}},1727(e,t,n){"use strict";var r=n(9551);e.exports=r,r.enableSynchronous=function(){r.prototype.isPending=function(){return 0==this.getState()},r.prototype.isFulfilled=function(){return 1==this.getState()},r.prototype.isRejected=function(){return 2==this.getState()},r.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},r.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},r.prototype.getState=function(){return 3===this._y?this._z.getState():-1===this._y||-2===this._y?0:this._y}},r.disableSynchronous=function(){r.prototype.isPending=void 0,r.prototype.isFulfilled=void 0,r.prototype.isRejected=void 0,r.prototype.getValue=void 0,r.prototype.getReason=void 0,r.prototype.getState=void 0}},4527(e,t,n){var r=n(9225).strict;e.exports=function(e){if(r(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 n=0;for(;n<t;)if(128&e[n])if(192==(224&e[n])){if(n+1===t||128!=(192&e[n+1])||192==(254&e[n]))return!1;n+=2}else if(224==(240&e[n])){if(n+2>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||224===e[n]&&128==(224&e[n+1])||237===e[n]&&160==(224&e[n+1]))return!1;n+=3}else{if(240!=(248&e[n]))return!1;if(n+3>=t||128!=(192&e[n+1])||128!=(192&e[n+2])||128!=(192&e[n+3])||240===e[n]&&128==(240&e[n+1])||244===e[n]&&e[n+1]>143||e[n]>244)return!1;n+=4}else n++;return!0}},3148(e,t,n){"use strict";try{e.exports=n(8169)(__dirname)}catch(t){e.exports=n(6556)}},5488(e,t,n){e.exports=n(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,n){var r=n(4552),o=n(4527),i=n(1909);const s=0,a=1,c=2,l=3;function u(e,t,n,o,a,c){i.EventTarget.call(this),(c=c||{}).assembleFragments=!0;var l=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 r(c),this._client.on("connect",function(e){d.call(l,e)}),this._client.on("connectFailed",function(){p.call(l)}),this._client.connect(e,t,n,o,a)}function h(e,t){var n=new i.Event("close");return n.code=e,n.reason=t,n.wasClean=void 0===e||1e3===e,n}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,n){g.call(t,e,n)}),this._connection.on("message",function(e){m.call(t,e)}),this.dispatchEvent(new i.Event("open"))}function p(){v.call(this),this._readyState=l;try{this.dispatchEvent(new i.Event("error"))}finally{this.dispatchEvent(h(1006,"connection failed"))}}function g(e,t){v.call(this),this._readyState=l,this.dispatchEvent(h(e,t||""))}function m(e){if(e.utf8Data)this.dispatchEvent(f(e.utf8Data));else if(e.binaryData&&"arraybuffer"===this.binaryType){for(var t=e.binaryData,n=new ArrayBuffer(t.length),r=new Uint8Array(n),o=0,i=t.length;o<i;++o)r[o]=t[o];this.dispatchEvent(f(n))}}function v(){this._client.removeAllListeners(),this._connection&&this._connection.removeAllListeners()}e.exports=u,Object.defineProperties(u.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(u.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",l]].forEach(function(e){Object.defineProperty(u.prototype,e[0],{get:function(){return e[1]}})}),[["CONNECTING",s],["OPEN",a],["CLOSING",c],["CLOSED",l]].forEach(function(e){Object.defineProperty(u,e[0],{get:function(){return e[1]}})}),u.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)}},u.prototype.close=function(e,t){switch(this._readyState){case s:p.call(this),this._client.on("connect",function(n){e?n.close(e,t):n.close()});break;case a:this._readyState=c,e?this._connection.close(e,t):this._connection.close()}}},4552(e,t,n){var r=n(5237),o=r.extend,i=n(9023),s=n(4434).EventEmitter,a=n(8611),c=n(5692),l=n(7016),u=n(6982),h=n(2819),f=r.bufferAllocUnsafe,d=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],p=["hostname","port","method","path","headers"];function g(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(g,s),g.prototype.connect=function(e,t,n,i,s){var u=this;if("string"==typeof t&&(t=t.length>0?[t]:[]),t instanceof Array||(t=[]),this.protocols=t,this.origin=n,this.url="string"==typeof e?l.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 n=e.charCodeAt(t),r=e.charAt(t);if(n<33||n>126||-1!==d.indexOf(r))throw new Error('Protocol list contains invalid character "'+String.fromCharCode(n)+'"')}}),this.url.port||(this.url.port={"ws:":"80","wss:":"443"}[this.url.protocol]);for(var h=f(16),g=0;g<16;g++)h[g]=Math.round(255*Math.random());this.base64nonce=h.toString("base64");var m=this.url.hostname;("ws:"===this.url.protocol&&"80"!==this.url.port||"wss:"===this.url.protocol&&"443"!==this.url.port)&&(m+=":"+this.url.port);var v,y={};function b(e){u._req=null,u.emit("connectFailed",e)}this.secure&&this.config.tlsOptions.hasOwnProperty("headers")&&o(y,this.config.tlsOptions.headers),i&&o(y,i),o(y,{Upgrade:"websocket",Connection:"Upgrade","Sec-WebSocket-Version":this.config.webSocketVersion.toString(10),"Sec-WebSocket-Key":this.base64nonce,Host:y.Host||m}),this.protocols.length>0&&(y["Sec-WebSocket-Protocol"]=this.protocols.join(", ")),this.origin&&(13===this.config.webSocketVersion?y.Origin=this.origin:8===this.config.webSocketVersion&&(y["Sec-WebSocket-Origin"]=this.origin)),v=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:v,headers:y}),this.secure){var k=this.config.tlsOptions;for(var _ in k)k.hasOwnProperty(_)&&-1===p.indexOf(_)&&(w[_]=k[_])}var S=this._req=(this.secure?c:a).request(w);S.on("upgrade",function(e,t,n){u._req=null,S.removeListener("error",b),u.socket=t,u.response=e,u.firstDataChunk=n,u.validateHandshake()}),S.on("error",b),S.on("response",function(e){if(u._req=null,r.eventEmitterListenerCount(u,"httpResponse")>0)u.emit("httpResponse",e,u),e.socket&&e.socket.end();else{var t=[];for(var n in e.headers)t.push(n+": "+e.headers[n]);u.failHandshake("Server responded with a non-101 status: "+e.statusCode+" "+e.statusMessage+"\nResponse Headers Follow:\n"+t.join("\n")+"\n")}}),S.end()},g.prototype.validateHandshake=function(){var e=this.response.headers;if(this.protocols.length>0){if(this.protocol=e["sec-websocket-protocol"],!this.protocol)return void this.failHandshake("Expected a Sec-WebSocket-Protocol header.");if(-1===this.protocols.indexOf(this.protocol))return void this.failHandshake("Server did not respond with a requested protocol.")}if(e.connection&&"upgrade"===e.connection.toLocaleLowerCase())if(e.upgrade&&"websocket"===e.upgrade.toLocaleLowerCase()){var t=u.createHash("sha1");t.update(this.base64nonce+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var n=t.digest("base64");e["sec-websocket-accept"]?e["sec-websocket-accept"]===n?this.succeedHandshake():this.failHandshake("Sec-WebSocket-Accept header from server didn't match expected value of "+n):this.failHandshake("Expected Sec-WebSocket-Accept header from server")}else this.failHandshake("Expected an Upgrade: websocket header from the server");else this.failHandshake("Expected a Connection: Upgrade header from the server")},g.prototype.failHandshake=function(e){this.socket&&this.socket.writable&&this.socket.end(),this.emit("connectFailed",new Error(e))},g.prototype.succeedHandshake=function(){var e=new h(this.socket,[],this.protocol,!0,this.config);e.webSocketVersion=this.config.webSocketVersion,e._addSocketEventListeners(),this.emit("connect",e),this.firstDataChunk.length>0&&e.handleSocketData(this.firstDataChunk),this.firstDataChunk=null},g.prototype.abort=function(){this._req&&this._req.abort()},e.exports=g},2819(e,t,n){var r=n(9023),o=n(5237),i=n(4434).EventEmitter,s=n(1338),a=n(3603),c=n(3148),l=o.bufferAllocUnsafe,u=o.bufferFromString;const h="open",f="peer_requested_close",d="ending",p="closed";var g="setImmediate"in global?global.setImmediate.bind(global):process.nextTick.bind(process),m=0;function v(e,t,n,r,c){if(this._debug=o.BufferingLogger("websocket:connection",++m),this._debug("constructor"),this._debug.enabled&&function(e,t){if(e._debug.enabled){var n=t.emit;for(var r in t.emit=function(t){e._debug("||| Socket Event '%s'",t),n.apply(this,arguments)},t)"function"==typeof t[r]&&-1===["emit"].indexOf(r)&&function(n){var r=t[n];t[n]="on"!==n?function(){return e._debug("||| Socket method called: %s",n),r.apply(this,arguments)}:function(){return e._debug("||| Socket method called: %s (%s)",n,arguments[0]),r.apply(this,arguments)}}(r)}}(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=n,this.extensions=t,this.remoteAddress=e.remoteAddress,this.closeReasonCode=-1,this.closeDescription=null,this.closeEventEmitted=!1,this.maskOutgoingPackets=r,this.maskBytes=l(4),this.frameHeader=l(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=h,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 y(e){return!(e<1e3)&&(e>=1e3&&e<=2999?-1!==[1e3,1001,1002,1003,1007,1008,1009,1010,1011,1012,1013,1014,1015].indexOf(e):e>=3e3&&e<=3999||e>=4e3&&e<=4999||!(e>=5e3)&&void 0)}v.CLOSE_REASON_NORMAL=1e3,v.CLOSE_REASON_GOING_AWAY=1001,v.CLOSE_REASON_PROTOCOL_ERROR=1002,v.CLOSE_REASON_UNPROCESSABLE_INPUT=1003,v.CLOSE_REASON_RESERVED=1004,v.CLOSE_REASON_NOT_PROVIDED=1005,v.CLOSE_REASON_ABNORMAL=1006,v.CLOSE_REASON_INVALID_DATA=1007,v.CLOSE_REASON_POLICY_VIOLATION=1008,v.CLOSE_REASON_MESSAGE_TOO_BIG=1009,v.CLOSE_REASON_EXTENSION_REQUIRED=1010,v.CLOSE_REASON_INTERNAL_SERVER_ERROR=1011,v.CLOSE_REASON_TLS_HANDSHAKE_FAILED=1015,v.CLOSE_DESCRIPTIONS={1e3:"Normal connection closure",1001:"Remote peer is going away",1002:"Protocol error",1003:"Unprocessable input",1004:"Reserved",1005:"Reason not provided",1006:"Abnormal closure, no further detail available",1007:"Invalid data received",1008:"Policy violation",1009:"Message too big",1010:"Extension requested by client is required",1011:"Internal Server Error",1015:"TLS Handshake Failed"},r.inherits(v,i),v.prototype._addSocketEventListeners=function(){this.socket.on("error",this.handleSocketError.bind(this)),this.socket.on("end",this.handleSocketEnd.bind(this)),this.socket.on("close",this.handleSocketClose.bind(this)),this.socket.on("drain",this.handleSocketDrain.bind(this)),this.socket.on("pause",this.handleSocketPause.bind(this)),this.socket.on("resume",this.handleSocketResume.bind(this)),this.socket.on("data",this.handleSocketData.bind(this))},v.prototype.setKeepaliveTimer=function(){this._debug("setKeepaliveTimer"),this.config.keepalive&&!this.config.useNativeKeepalive&&(this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this._keepaliveTimeoutID=setTimeout(this._keepaliveTimerHandler,this.config.keepaliveInterval))},v.prototype.clearKeepaliveTimer=function(){this._keepaliveTimeoutID&&clearTimeout(this._keepaliveTimeoutID)},v.prototype.handleKeepaliveTimer=function(){this._debug("handleKeepaliveTimer"),this._keepaliveTimeoutID=null,this.ping(),this.config.dropConnectionOnKeepaliveTimeout?this.setGracePeriodTimer():this.setKeepaliveTimer()},v.prototype.setGracePeriodTimer=function(){this._debug("setGracePeriodTimer"),this.clearGracePeriodTimer(),this._gracePeriodTimeoutID=setTimeout(this._gracePeriodTimerHandler,this.config.keepaliveGracePeriod)},v.prototype.clearGracePeriodTimer=function(){this._gracePeriodTimeoutID&&clearTimeout(this._gracePeriodTimeoutID)},v.prototype.handleGracePeriodTimer=function(){this._debug("handleGracePeriodTimer"),this._gracePeriodTimeoutID=null,this.drop(v.CLOSE_REASON_ABNORMAL,"Peer not responding.",!0)},v.prototype.handleSocketData=function(e){this._debug("handleSocketData"),this.setKeepaliveTimer(),this.bufferList.write(e),this.processReceivedData()},v.prototype.processReceivedData=function(){if(this._debug("processReceivedData"),this.connected&&!this.inputPaused){var e=this.currentFrame;if(e.addData(this.bufferList)){var t=this;if(e.protocolError)return this._debug("-- protocol error"),void process.nextTick(function(){t.drop(v.CLOSE_REASON_PROTOCOL_ERROR,e.dropReason)});if(e.frameTooLarge)return this._debug("-- frame too large"),void process.nextTick(function(){t.drop(v.CLOSE_REASON_MESSAGE_TOO_BIG,e.dropReason)});if(e.rsv1||e.rsv2||e.rsv3)return this._debug("-- illegal rsv flag"),void process.nextTick(function(){t.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unsupported usage of rsv bits without negotiated extension.")});this.assembleFragments||(this._debug("-- emitting frame"),process.nextTick(function(){t.emit("frame",e)})),process.nextTick(function(){t.processFrame(e)}),this.currentFrame=new s(this.maskBytes,this.frameHeader,this.config),this.bufferList.length>0&&g(this.receivedDataHandler)}else this._debug("-- insufficient data for frame")}},v.prototype.handleSocketError=function(e){this._debug("handleSocketError: %j",e),this.state!==p?(this.closeReasonCode=v.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'")},v.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'")},v.prototype.handleSocketClose=function(e){this._debug("handleSocketClose: received socket close"),this.socketHadError=e,this.connected=!1,this.state=p,-1===this.closeReasonCode&&(this.closeReasonCode=v.CLOSE_REASON_ABNORMAL,this.closeDescription="Connection dropped by remote peer."),this.clearCloseTimer(),this.clearKeepaliveTimer(),this.clearGracePeriodTimer(),this.closeEventEmitted||(this.closeEventEmitted=!0,this._debug("-- Emitting WebSocketConnection close event"),this.emit("close",this.closeReasonCode,this.closeDescription))},v.prototype.handleSocketDrain=function(){this._debug("handleSocketDrain: socket drain event"),this.outputBufferFull=!1,this.emit("drain")},v.prototype.handleSocketPause=function(){this._debug("handleSocketPause: socket pause event"),this.inputPaused=!0,this.emit("pause")},v.prototype.handleSocketResume=function(){this._debug("handleSocketResume: socket resume event"),this.inputPaused=!1,this.emit("resume"),this.processReceivedData()},v.prototype.pause=function(){this._debug("pause: pause requested"),this.socket.pause()},v.prototype.resume=function(){this._debug("resume: resume requested"),this.socket.resume()},v.prototype.close=function(e,t){if(this.connected){if(this._debug("close: Initating clean WebSocket close sequence."),"number"!=typeof e&&(e=v.CLOSE_REASON_NORMAL),!y(e))throw new Error("Close code "+e+" is not valid.");"string"!=typeof t&&(t=v.CLOSE_DESCRIPTIONS[e]),this.closeReasonCode=e,this.closeDescription=t,this.setCloseTimer(),this.sendCloseFrame(this.closeReasonCode,this.closeDescription),this.state=d,this.connected=!1}},v.prototype.drop=function(e,t,n){this._debug("drop"),"number"!=typeof e&&(e=v.CLOSE_REASON_PROTOCOL_ERROR),"string"!=typeof t&&(t=v.CLOSE_DESCRIPTIONS[e]),this._debug("Forcefully dropping connection. skipCloseFrame: %s, code: %d, description: %s",n,e,t),this.closeReasonCode=e,this.closeDescription=t,this.frameQueue=[],this.fragmentationSize=0,n||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()},v.prototype.setCloseTimer=function(){this._debug("setCloseTimer"),this.clearCloseTimer(),this._debug("Setting close timer"),this.waitingForCloseResponse=!0,this.closeTimer=setTimeout(this._closeTimerHandler,this.closeTimeout)},v.prototype.clearCloseTimer=function(){this._debug("clearCloseTimer"),this.closeTimer&&(this._debug("Clearing close timer"),clearTimeout(this.closeTimer),this.waitingForCloseResponse=!1,this.closeTimer=null)},v.prototype.handleCloseTimer=function(){this._debug("handleCloseTimer"),this.closeTimer=null,this.waitingForCloseResponse&&(this._debug("Close response not received from client. Forcing socket end."),this.waitingForCloseResponse=!1,this.state=p,this.socket.end())},v.prototype.processFrame=function(e){if(this._debug("processFrame"),this._debug(" -- frame: %s",e),0!==this.frameQueue.length&&e.opcode>0&&e.opcode<8)this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Illegal frame opcode 0x"+e.opcode.toString(16)+" received in middle of fragmented message.");else switch(e.opcode){case 2:this._debug("-- Binary Frame"),this.assembleFragments&&(e.fin?(this._debug("---- Emitting 'message' event"),this.emit("message",{type:"binary",binaryData:e.binaryPayload})):(this.frameQueue.push(e),this.fragmentationSize=e.length));break;case 1:if(this._debug("-- Text Frame"),this.assembleFragments)if(e.fin){if(!c(e.binaryPayload))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this._debug("---- Emitting 'message' event"),this.emit("message",{type:"utf8",utf8Data:e.binaryPayload.toString("utf8")})}else this.frameQueue.push(e),this.fragmentationSize=e.length;break;case 0:if(this._debug("-- Continuation Frame"),this.assembleFragments){if(0===this.frameQueue.length)return void this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected Continuation Frame");if(this.fragmentationSize+=e.length,this.fragmentationSize>this.maxReceivedMessageSize)return void this.drop(v.CLOSE_REASON_MESSAGE_TOO_BIG,"Maximum message size exceeded.");if(this.frameQueue.push(e),e.fin){var t=0,n=l(this.fragmentationSize),r=this.frameQueue[0].opcode;switch(this.frameQueue.forEach(function(e){e.binaryPayload.copy(n,t),t+=e.binaryPayload.length}),this.frameQueue=[],this.fragmentationSize=0,r){case 2:this.emit("message",{type:"binary",binaryData:n});break;case 1:if(!c(n))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.emit("message",{type:"utf8",utf8Data:n.toString("utf8")});break;default:return void this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unexpected first opcode in fragmentation sequence: 0x"+r.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=v.CLOSE_REASON_PROTOCOL_ERROR):-1===e.closeStatus||y(e.closeStatus)?(this.closeReasonCode=e.closeStatus,i=v.CLOSE_REASON_NORMAL):(this.closeReasonCode=e.closeStatus,i=v.CLOSE_REASON_PROTOCOL_ERROR),e.binaryPayload.length>1){if(!c(e.binaryPayload))return void this.drop(v.CLOSE_REASON_INVALID_DATA,"Invalid UTF-8 Data Received");this.closeDescription=e.binaryPayload.toString("utf8")}else this.closeDescription=v.CLOSE_DESCRIPTIONS[this.closeReasonCode];this._debug("------ Remote peer %s - code: %d - %s - close frame payload length: %d",this.remoteAddress,this.closeReasonCode,this.closeDescription,e.length),this._debug("------ responding to remote peer's close request."),this.sendCloseFrame(i,null),this.connected=!1;break;default:this._debug("-- Unrecognized Opcode %d",e.opcode),this.drop(v.CLOSE_REASON_PROTOCOL_ERROR,"Unrecognized Opcode: 0x"+e.opcode.toString(16))}},v.prototype.send=function(e,t){if(this._debug("send"),Buffer.isBuffer(e))this.sendBytes(e,t);else{if("function"!=typeof e.toString)throw new Error("Data provided must either be a Node Buffer or implement toString()");this.sendUTF(e,t)}},v.prototype.sendUTF=function(e,t){e=u(e.toString(),"utf8"),this._debug("sendUTF: %d bytes",e.length);var n=new s(this.maskBytes,this.frameHeader,this.config);n.opcode=1,n.binaryPayload=e,this.fragmentAndSend(n,t)},v.prototype.sendBytes=function(e,t){if(this._debug("sendBytes"),!Buffer.isBuffer(e))throw new Error("You must pass a Node Buffer object to WebSocketConnection.prototype.sendBytes()");var n=new s(this.maskBytes,this.frameHeader,this.config);n.opcode=2,n.binaryPayload=e,this.fragmentAndSend(n,t)},v.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=u(e.toString(),"utf8")),e.length>125&&(this._debug("WebSocket: Data for ping is longer than 125 bytes. Truncating."),e=e.slice(0,124)),t.binaryPayload=e),this.sendFrame(t)},v.prototype.pong=function(e){this._debug("pong");var t=new 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)},v.prototype.fragmentAndSend=function(e,t){if(this._debug("fragmentAndSend"),e.opcode>7)throw new Error("You cannot fragment control frames.");var n=this.config.fragmentationThreshold,r=e.binaryPayload.length;if(!this.config.fragmentOutgoingMessages||e.binaryPayload&&r<=n)return e.fin=!0,void this.sendFrame(e,t);for(var o=Math.ceil(r/n),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 l=new s(this.maskBytes,this.frameHeader,this.config);l.opcode=1===c?e.opcode:0,l.fin=c===o;var u=c===o?r-n*(c-1):n,h=n*(c-1);l.binaryPayload=e.binaryPayload.slice(h,h+u),this.sendFrame(l,a)}},v.prototype.sendCloseFrame=function(e,t,n){if("number"!=typeof e&&(e=v.CLOSE_REASON_NORMAL),this._debug("sendCloseFrame state: %s, reasonCode: %d, description: %s",this.state,e,t),this.state===h||this.state===f){var r=new s(this.maskBytes,this.frameHeader,this.config);r.fin=!0,r.opcode=8,r.closeStatus=e,"string"==typeof t&&(r.binaryPayload=u(t,"utf8")),this.sendFrame(r,n),this.socket.end()}},v.prototype.sendFrame=function(e,t){this._debug("sendFrame"),e.mask=this.maskOutgoingPackets;var n=this.socket.write(e.toBuffer(),t);return this.outputBufferFull=!n,n},e.exports=v},1338(e,t,n){var r=n(2627),o=n(5237).bufferAllocUnsafe;function i(e,t,n){this.maskBytes=e,this.frameHeader=t,this.config=n,this.maxReceivedFrameSize=n.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],n=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&n),this.opcode=15&t,this.length=127&n,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&&r.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,n,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),(n=o(this.length)).writeUInt16BE(this.closeStatus,0),this.length>2&&this.binaryPayload.copy(n,2)):this.binaryPayload?(n=this.binaryPayload,this.length=n.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 l=o(this.length+s+(this.mask?4:0));return l[0]=a,l[1]=c,i=2,this.length>125&&this.length<=65535?(l.writeUInt16BE(this.length,i),i+=2):this.length>65535&&(l.writeUInt32BE(0,i),l.writeUInt32BE(this.length,i+4),i+=8),this.mask?(t=e?0:4294967295*Math.random()>>>0,this.maskBytes.writeUInt32BE(t,0),this.maskBytes.copy(l,i),i+=4,n&&r.mask(n,this.maskBytes,l,i,this.length)):n&&n.copy(l,i),l},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,n){for(var r=n(6982),o=n(9023),i=n(7016),s=n(4434).EventEmitter,a=n(2819),c=/,\s*/,l=/;\s*/,u=/[\r\n]/g,h=/,\s*/,f=["(",")","<",">","@",",",";",":","\\",'"',"/","[","]","?","=","{","}"," ",String.fromCharCode(9)],d=[String.fromCharCode(127)],p=0;p<31;p++)d.push(String.fromCharCode(p));var g=/([\x00-\x20\x22\x28\x29\x2c\x2f\x3a-\x3f\x40\x5b-\x5e\x7b\x7d\x7f])/,m=/[^\x21\x23-\x2b\x2d-\x3a\x3c-\x5b\x5d-\x7e]/,v=/^"[^"]*"$/,y=/[\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,n){s.call(this),this.socket=e,this.httpRequest=t,this.resource=t.url,this.remoteAddress=e.remoteAddress,this.remoteAddresses=[this.remoteAddress],this.serverConfig=n,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 _(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 n=new Error("Unsupported websocket client version: "+this.webSocketVersion+"Only versions 8 and 13 are supported.");throw n.httpCode=426,n.headers={"Sec-WebSocket-Version":"13"},n}13===this.webSocketVersion?this.origin=t.headers.origin:8===this.webSocketVersion&&(this.origin=t.headers["sec-websocket-origin"]);var r=t.headers["sec-websocket-protocol"];if(this.protocolFullCaseMap={},this.requestedProtocols=[],r&&r.split(c).forEach(function(t){var n=t.toLocaleLowerCase();e.requestedProtocols.push(n),e.protocolFullCaseMap[n]=t}),!this.serverConfig.ignoreXForwardedFor&&t.headers["x-forwarded-for"]){var o=this.remoteAddress;this.remoteAddresses=t.headers["x-forwarded-for"].split(h),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,n){var r=e.split(l),o=r[0],i=r.slice(1);i.forEach(function(e,t,n){var r=e.split("="),o={name:r[0],value:r[1]};n.splice(t,1,o)});var s={name:o,params:i};n.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 n=e.indexOf("=");if(-1!==n){var r=e.substr(0,n).trim(),o=e.substr(++n,e.length).trim();'"'===o[0]&&(o=o.slice(1,-1)),t.push({name:r,value:decodeURIComponent(o)})}else t.push({name:e,value:null})}),t},k.prototype.accept=function(e,t,n){var o;this._verifyResolution(),e?void 0===(o=this.protocolFullCaseMap[e.toLocaleLowerCase()])&&(o=e):o=e,this.protocolFullCaseMap=null;var i=r.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 l=o.charCodeAt(c),h=o.charAt(c);if(l<33||l>126||-1!==f.indexOf(h))throw this.reject(500),new Error('Illegal character "'+String.fromCharCode(h)+'" 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(u,""),s+="Sec-WebSocket-Protocol: "+o+"\r\n"}if(this.requestedProtocols=null,t&&(t=t.replace(u,""),13===this.webSocketVersion?s+="Origin: "+t+"\r\n":8===this.webSocketVersion&&(s+="Sec-WebSocket-Origin: "+t+"\r\n")),n){if(!Array.isArray(n))throw this.reject(500),new Error('Value supplied for "cookies" argument must be an array.');var d={};n.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(y,""),e.value=e.value.replace(y,""),d[e.name])throw this.reject(500),new Error("You may not specify the same cookie name twice.");d[e.name]=!0;var t=e.name.match(g);if(t)throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie name");if(t=e.value.match(v)?e.value.slice(1,-1).match(m):e.value.match(m))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie value");var n=[e.name+"="+e.value];if(e.path){if(t=e.path.match(y))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie path");n.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(y))throw this.reject(500),new Error("Illegal character "+t[0]+" in cookie domain");n.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');n.push("Expires="+e.expires.toGMTString())}if(e.maxage){var r=e.maxage;if("string"==typeof r&&(r=parseInt(r,10)),isNaN(r)||r<=0)throw this.reject(500),new Error('Value supplied for cookie "maxage" must be a non-zero number');r=Math.round(r),n.push("Max-Age="+r.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');n.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');n.push("HttpOnly")}s+="Set-Cookie: "+n.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?_(p):this.socket.write(s,"ascii",function(e){e?_(p):(b._removeSocketCloseListeners(),p._addSocketEventListeners())}),this.emit("requestAccepted",p),p},k.prototype.reject=function(e,t,n){this._verifyResolution(),this._resolved=!0,this.emit("requestResolved",this),"number"!=typeof e&&(e=403);var r="HTTP/1.1 "+e+" "+w[e]+"\r\nConnection: close\r\n";if(t&&(r+="X-WebSocket-Reject-Reason: "+(t=t.replace(u,""))+"\r\n"),n)for(var o in n){var i=n[o].toString().replace(u,"");r+=o.replace(u,"")+": "+i+"\r\n"}r+="\r\n",this.socket.end(r,"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,n){var r=n(5237).extend,o=n(9023),i=n(4434).EventEmitter,s=n(7705);function a(e){i.call(this),this.config={server:null},e&&r(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,n){if(!e)throw new Error("You must specify a path for this handler.");if(t||(t="____no_protocol____"),!n)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 r=e.toString();if(t=t.toLocaleLowerCase(),-1!==this.findHandlerIndex(r,t))throw new Error("You may only mount one handler per path/protocol combination.");this.handlers.push({path:e,pathString:r,protocol:t,callback:n})},a.prototype.unmount=function(e,t){var n=this.findHandlerIndex(this.pathToRegExp(e).toString(),t);if(-1===n)throw new Error("Unable to find a route matching the specified path and protocol.");this.handlers.splice(n,1)},a.prototype.findHandlerIndex=function(e,t){t=t.toLocaleLowerCase();for(var n=0,r=this.handlers.length;n<r;n++){var o=this.handlers[n];if(o.pathString===e&&o.protocol===t)return n}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 n=0;n<t.length;n++)for(var r=t[n].toLocaleLowerCase(),o=0,i=this.handlers.length;o<i;o++){var a=this.handlers[o];if(a.path.test(e.resourceURL.pathname)&&(r===a.protocol||"*"===a.protocol)){var c=new s(e,r);return void a.callback(c)}}e.reject(404,"No handler is available for the given request.")},e.exports=a},7705(e,t,n){var r=n(9023),o=n(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}r.inherits(i,o),i.prototype.accept=function(e,t){var n=this.webSocketRequest.accept(this.protocol,e,t);return this.emit("requestAccepted",n),n},i.prototype.reject=function(e,t,n){this.webSocketRequest.reject(e,t,n),this.emit("requestRejected",this)},e.exports=i},7788(e,t,n){var r=n(5237).extend,o=n(5237),i=n(9023),s=n(5753)("websocket:server"),a=n(4434).EventEmitter,c=n(5334),l=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(l,a),l.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},r(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)})},l.prototype.unmount=function(){var e=this._handlers.upgrade;this.config.httpServer.forEach(function(t){t.removeListener("upgrade",e)})},l.prototype.closeAllConnections=function(){this.connections.forEach(function(e){e.close()}),this.pendingRequests.forEach(function(e){process.nextTick(function(){e.reject(503)})})},l.prototype.broadcast=function(e){Buffer.isBuffer(e)?this.broadcastBytes(e):"function"==typeof e.toString&&this.broadcastUTF(e)},l.prototype.broadcastUTF=function(e){this.connections.forEach(function(t){t.sendUTF(e)})},l.prototype.broadcastBytes=function(e){this.connections.forEach(function(t){t.sendBytes(e)})},l.prototype.shutDown=function(){this.unmount(),this.closeAllConnections()},l.prototype.handleUpgrade=function(e,t){var n=this,r=new c(t,e,this.config);try{r.readHandshake()}catch(e){return r.reject(e.httpCode?e.httpCode:400,e.message,e.headers),s("Invalid handshake: %s",e.message),void this.emit("upgradeError",e)}this.pendingRequests.push(r),r.once("requestAccepted",this._handlers.requestAccepted),r.once("requestResolved",this._handlers.requestResolved),t.once("close",function(){n._handlers.requestResolved(r)}),!this.config.autoAcceptConnections&&o.eventEmitterListenerCount(this,"request")>0?this.emit("request",r):this.config.autoAcceptConnections?r.accept(r.requestedProtocols[0],r.origin):r.reject(404,"No handler is configured to accept the connection.")},l.prototype.handleRequestAccepted=function(e){var t=this;e.once("close",function(n,r){t.handleConnectionClose(e,n,r)}),this.connections.push(e),this.emit("connect",e)},l.prototype.handleConnectionClose=function(e,t,n){var r=this.connections.indexOf(e);-1!==r&&this.connections.splice(r,1),this.emit("close",e,t,n)},l.prototype.handleRequestResolved=function(e){var t=this.pendingRequests.indexOf(e);-1!==t&&this.pendingRequests.splice(t,1)},e.exports=l},5237(e,t,n){var r=t.noop=function(){};function o(e,t,n){this.logFunction=n,this.identifier=e,this.uniqueID=t,this.buffer=[]}t.extend=function(e,t){for(var n in t)e[n]=t[n]},t.eventEmitterListenerCount=n(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=n(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=r,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(n){var r=n[0].toLocaleString(),o=n[1].slice(),i=o[0];null!=i&&(i="%s - %s - "+i.toString(),o.splice(0,1,i,r,t),e.apply(global,o))})}},9840(e,t,n){e.exports=n(9003).version},907(e,t,n){e.exports={...void n(7788),...void n(4552),...void n(9834),...void n(1338),...void n(5334),...void n(2819),w3cwebsocket:n(8828),...void n(4194),...void n(9840)}},3603(e,t,n){var r=n(181).Buffer,o=n(4434).EventEmitter,i=n(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 n={next:null,buffer:null},a={next:null,buffer:null},c=0;t.__defineGetter__("length",function(){return c});var l=0;t.write=function(e){return n.buffer?(a.next={next:null,buffer:e},a=a.next):(n.buffer=e,a=n),c+=e.length,t.emit("write",e),!0},t.end=function(e){r.isBuffer(e)&&t.write(e)},t.push=function(){return[].concat.apply([],arguments).forEach(t.write),t},t.forEach=function(e){if(!n.buffer)return i(0);if(n.buffer.length-l<=0)return t;for(var r={buffer:n.buffer.slice(l),next:n.next};r&&r.buffer&&!e(r.buffer);)r=r.next;return t},t.join=function(e,r){if(!n.buffer)return i(0);null==e&&(e=0),null==r&&(r=t.length);var o=i(r-e),s=0;return t.forEach(function(t){if(e<s+t.length&&s<r&&t.copy(o,Math.max(0,s-e),Math.max(0,e-s),Math.min(t.length,r-s)),(s+=t.length)>r)return!0}),o},t.joinInto=function(e,r,o,s){if(!n.buffer)return new i(0);null==o&&(o=0),null==s&&(s=t.length);var a=e;if(a.length-r<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(r,r+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(l+=e,c-=e;n.buffer&&l>=n.buffer.length;)l-=n.buffer.length,n=n.next?n.next:{buffer:null,next:null};return null===n.buffer&&(a={next:null,buffer:null}),t.emit("advance",e),t},t.take=function(e,n){if(null==e?e=t.length:"number"!=typeof e&&(n=e,e=t.length),n||(n=t.encoding),n){var r="";return t.forEach(function(t){if(e<=0)return!0;r+=t.toString(n,0,Math.min(e,t.length)),e-=t.length}),r}return t.join(0,e)},t.toString=function(){return t.take("binary")}}e.exports=s,e.exports.BufferList=s,n(9023).inherits(s,o)},1909(e,t,n){e.exports={EventTarget:n(5384),Event:n(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=n,this.removeEventListener=r,this.dispatchEvent=o)}function n(e,t){var n,r,o;if(e&&t){for(void 0===(n=this._listeners[e])&&(this._listeners[e]=n=[]),r=0;o=n[r];r++)if(o===t)return;n.push(t)}}function r(e,t){var n,r,o;if(e&&t&&void 0!==(n=this._listeners[e])){for(r=0;o=n[r];r++)if(o===t){n.splice(r,1);break}0===n.length&&delete this._listeners[e]}}function o(e){var t,n,r,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,n=this._listeners[t]||[],"function"==typeof(r=this["on"+t])&&r.call(this,e),o=0;(i=n[o])&&!s;o++)i.call(this,e);return!e.defaultPrevented}e.exports=t,Object.defineProperties(t.prototype,{listeners:{get:function(){return this._listeners}}})},8803(e,t,n){"use strict";const r=n(9896),o=n(6928),i=r.promises,s=[{key:"check_sample",title:"Check for missing Sample folder (with mkv)",default_value:!0,type:"boolean"},{key:"check_proof",title:"Check for missing Proof folder",default_value:!0,type:"boolean"},{key:"redownload",title:"Automatically search for and redownload incomplete release folders",default_value:!0,type:"boolean"},{key:"log_events",title:"Show messages in the system log",default_value:!0,type:"boolean"},{key:"excluded_groups",title:"Excluded release groups (comma-separated)",help:"No Sample/Proof check for these groups. Leave empty to check every group.",default_value:"CyTSuNee,SHiTSoNy",type:"string",optional:!0},{key:"retry_interval_minutes",title:"Minutes between automatic Sample/Proof retries",help:"Minutes to wait before the first automatic search after a completed download, and between retries after that.",default_value:60,type:"number",min:5,max:1440},{key:"retry_max_hours",title:"Maximum hours to keep retrying (0 = try once)",help:"How long to keep retrying an automatic Sample/Proof search before giving up. 0 = try only once, no retries.",default_value:24,type:"number",min:0,max:168},{key:"search_pause_seconds",title:"Seconds to wait before reading search results",help:"Wait time after starting a search before reading results. Increase if you see 'Search queue overflow' errors.",default_value:20,type:"number",min:10,max:120},{key:"overflow_backoff_seconds",title:"Extra pause (seconds) after a search queue overflow",help:"Extra seconds to pause after a 'Search queue overflow' error before the next automatic search.",default_value:60,type:"number",min:20,max:600},{key:"restrict_to_share_folder",title:"Limit the automatic check to these virtual folders (comma-separated)",help:"Only applies to the AUTOMATIC (post-download) check, e.g. FiLMS,Series. Leave empty to check the whole share.",default_value:"",type:"string",optional:!0}],a=n(3605),c=/\.(rar|r\d{2})$/i,l=/\.mkv$/i,u=/\.sfv$/i;e.exports=function(e,t){const n=a(e,{extensionName:t.name,configFile:t.configPath+"config.json",configVersion:1,definitions:s}),h=new Map,f=[],d=new Set;let p=!1;const g=new Map,m={at:0,roots:null};async function v(e,t,i,s){const a=e.replace(/[\\/]+$/,"")+"::"+t.toLowerCase()+"::retry";if(g.has(a))return;const c=Math.max(1,n.getValue("retry_interval_minutes")||60),l=Math.max(0,n.getValue("retry_max_hours")||0),u=l>0?Math.max(1,Math.round(60*l/c)):1,h=6e4*c,f=l>0?h:0,d=async()=>{const n=g.get(a);if(!n)return;let c=!0;try{await r.promises.access(e)}catch(e){c=!1}if(!c)return g.delete(a),void await y(`[Sample/Proof-check] Release folder no longer exists -- canceling ${t} redownload retry for: ${o.basename(e)}`,"info");let f=!1;try{f=await s()}catch(e){f=!1}if(f)g.delete(a);else{if(n.attempts++,k(e,t,i),n.attempts>=u)return g.delete(a),void await y(`[Sample/Proof-check] Gave up looking for ${t} after ${n.attempts} attempt(s) (~${l}h) for: ${o.basename(e)}`,"warning");n.timer=setTimeout(d,h)}};g.set(a,{attempts:0,timer:setTimeout(d,f)})}const y=async(t,r)=>{if(n.getValue("log_events"))try{await e.post("events",{text:t,severity:r||"info"})}catch(e){console.error(`Could not send event message: ${e.message}`)}},b=async(t,n,r,o)=>{if(t&&n)try{await e.post(`${t}/${n}/status_message`,{text:r,severity:o||"info"})}catch(e){console.error(`Could not send status message: ${e.message}`)}else await y(r,o)},w=async(t,r,i)=>{const s=o.basename(t);let a;await y(`[Sample/Proof-check] Searching for ${r} folder for: ${s}...`,"info");try{a=await e.post("search")}catch(e){return void await y(`[Sample/Proof-check] Could not start search for ${s}\\${r}: ${e.message}`,"error")}try{try{await e.post(`search/${a.id}/hub_search`,{query:{pattern:`${s} ${r}`,file_type:"directory"},priority:1})}finally{await new Promise(e=>setTimeout(e,1e3*n.getValue("search_pause_seconds")))}const c=(await e.get(`search/${a.id}/results/0/10`)||[]).find(e=>e.name&&e.name.toLowerCase()===r.toLowerCase());if(!c)return void(i||await y(`[Sample/Proof-check] No ${r} folder found for: ${s}`,"warning"));await e.post(`search/${a.id}/results/${c.id}/download`,{target_name:c.name,target_directory:t+o.sep}),await y(`[Sample/Proof-check] ${r} folder re-queued for: ${s}`,"info")}catch(e){if(await y(`[Sample/Proof-check] Search/download failed for ${s}\\${r}: ${e.message}`,"error"),e&&e.message&&/overflow/i.test(e.message)){const e=1e3*n.getValue("overflow_backoff_seconds");await y(`[Sample/Proof-check] Pausing ${Math.round(e/1e3)}s after a search queue overflow...`,"warning"),await new Promise(t=>setTimeout(t,e))}}finally{try{await e.delete(`search/${a.id}`)}catch(e){}}},k=(e,t,n)=>{const r=e.replace(/[\\/]+$/,""),o=`${r}::${t.toLowerCase()}`,i=Date.now(),s=h.get(o);s&&i-s<3e5||d.has(o)||(d.add(o),f.push({key:o,releaseDir:r,subFolderName:t,silentIfNotFound:n}),(async()=>{if(!p){for(p=!0;f.length>0;){const e=f.shift();d.delete(e.key),h.set(e.key,Date.now());try{await w(e.releaseDir,e.subFolderName,e.silentIfNotFound)}catch(t){await y(`[Sample/Proof-check] Unexpected error processing queue item ${e.key}: ${t&&t.message?t.message:t}`,"error")}}p=!1}})())},_=async(e,t)=>{let n;try{n=await r.promises.readdir(e,{withFileTypes:!0})}catch(e){return null}for(const r of n)if(r.isDirectory()&&r.name.toLowerCase()===t)return o.join(e,r.name);return null},S=async e=>{let t;try{t=await r.promises.readdir(e,{withFileTypes:!0})}catch(e){return!1}for(const n of t){const t=o.join(e,n.name);if(n.isFile()&&l.test(n.name))return!0;if(n.isDirectory()&&await S(t))return!0}return!1},E=async(e,t)=>{const i=o.basename(e).toLowerCase();if("sample"!==i&&"proof"!==i&&await(async e=>{let t;try{t=await r.promises.readdir(e,{withFileTypes:!0})}catch(e){return!1}return t.some(e=>e.isFile()&&u.test(e.name))})(e)&&!(e=>{const t=o.basename(e).toLowerCase();return"subs"===t||"sub"===t||t.includes("subpack")})(e)&&!(e=>{const t=(n.getValue("excluded_groups")||"").split(",").map(e=>e.trim().toLowerCase()).filter(Boolean);if(0===t.length)return!1;const r=o.basename(e).match(/-([A-Za-z0-9]+)$/);return!!r&&t.includes(r[1].toLowerCase())})(e)){if(n.getValue("check_sample")){const r=await _(e,"sample");r&&await S(r)||(await y(`[Sample/Proof-check] Sample folder missing or contains no mkv: ${e}`,"warning"),n.getValue("redownload")&&(t?v(e,"Sample",!1,async()=>{const t=await _(e,"sample");return!(!t||!await S(t))}):k(e,"Sample",!1)))}n.getValue("check_proof")&&(await _(e,"proof")||n.getValue("redownload")&&(t?v(e,"Proof",!0,async()=>!!await _(e,"proof")):k(e,"Proof",!0)))}},C=async e=>{let t;try{t=await r.promises.readdir(e,{withFileTypes:!0})}catch(e){return}t.some(e=>e.isFile()&&c.test(e.name))&&await E(e);for(const n of t)n.isDirectory()&&await C(o.join(e,n.name))},O=async(t,r)=>{if(r(),!t||!t.target)return;const o=t.target.replace(/[\\/]+$/,"");await async function(t){const r=(n.getValue("restrict_to_share_folder")||"").trim();if(!r)return!0;const o=r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean);if(0===o.length)return!0;try{(!m.roots||Date.now()-m.at>6e4)&&(m.roots=await e.get("share_roots"),m.at=Date.now());const n=e=>(e||"").replace(/[\\/]+$/,"").toLowerCase(),r=n(t),i=(m.roots||[]).find(e=>e.path&&r.startsWith(n(e.path)));return i?o.includes((i.virtual_name||"").toLowerCase()):(await y(`[Sample/Proof-check] Automatic check skipped: could not determine the virtual share folder for ${t}`,"warning"),!1)}catch(e){return await y(`[Sample/Proof-check] Automatic check skipped: could not check restrict_to_share_folder (${e.message})`,"error"),!1}}(o)&&E(o,!0)};function x(e,t){return!!t&&-1!==t.indexOf(e)}async function R(e,t){const{selected_ids:n,entity_id:r,permissions:o,supports:i}=t;return!(e.urls&&!x("urls",i))&&(!(e.filter&&!await e.filter(n,r,o,i))&&function(e,t){return!e.access||-1!==t.indexOf("admin")||-1!==t.indexOf(e.access)}(e,o))}async function A(e,t){const{selected_ids:n,entity_id:r,permissions:o,supports:i}=t;return e.urls&&e.urls.length?{urls:"function"==typeof e.urls?await e.urls(n,r,o,i):e.urls}:e.formDefinitions&&x("form",i)?{form_definitions:"function"==typeof e.formDefinitions?await e.formDefinitions(n,r,o,i):e.formDefinitions}:{}}async function P(e,t){if(!t)return[];const n=t.split("/").filter(Boolean);if(n.length<=1)return[];const r=n.slice(1).join(o.sep);let s;try{s=await e.get("share_roots")}catch(e){return[]}const a=new Set,c=[];for(const e of s||[]){if(!e||!e.path)continue;const t=(e.path.endsWith(o.sep)||e.path.endsWith("/")?e.path:e.path+o.sep)+r;if(!a.has(t)){a.add(t);try{(await i.stat(t)).isDirectory()&&c.push(t)}catch(e){}}}return c}async function T(e,t){let n;try{n=await e.get(`queue/bundles/${t}`)}catch(e){return null}const r=n&&n.target&&n.target.replace(/[\\/]+$/,"");if(!r)return null;try{return(await i.stat(r)).isDirectory()?r:null}catch(e){return null}}async function L(e,t,n,r){const o=await e.addListener("menus",`${n}_menuitem_selected`,async e=>{if(e.hook_id!==r.id)return;const n=t.find(t=>e.menuitem_id===t.id);if(n&&await R(n,e)&&n.onClick){const{selected_ids:t,entity_id:r,permissions:o,supports:i,form_values:s}=e;n.onClick(t,r,o,i,s)}}),i=await e.addHook("menus",`${n}_list_menuitems`,async(e,n,r)=>{const o=[];for(const n of t){if(!await R(n,e))continue;const t=await A(n,e),{onClick:r,id:i,title:s,icon:a}=n;(r||t.urls&&t.urls.length)&&o.push(Object.assign({id:i,title:s,icon:a},t))}n({menuitems:o})},r);return()=>{i(),o()}}t.onStart=async r=>{await n.load();try{await e.addHook("queue","queue_bundle_finished_hook",O,{id:"sample_proof_bundle_finished",name:"Sample/Proof check on completed download"})}catch(e){console.error(`Could not register hook: ${e.message}`)}const o="\nSample/Proof-check commands\n\n/sampleproofcheck - Scan the entire share\n/sampleproofcheck <path> - Scan only that folder (real disk path, not the share name)",i=async(t,n,r)=>{const i=(n.command||"").toLowerCase(),s=n.args||[];if("sampleproofcheck"===i){const n=s.join(" ").trim();if("help"===n.toLowerCase())await b(t,r,o,"info");else if(n)await y(`[Sample/Proof-check] Scan started for folder: ${n}...`,"info"),await C(n),await y(`[Sample/Proof-check] Scan of "${n}" complete.`,"info");else{let t;await y("[Sample/Proof-check] Scan started...","info");try{t=await e.get("share_roots")}catch(e){return void await y(`[Sample/Proof-check] Could not retrieve share folders: ${e.message}`,"error")}for(const e of t)await C(e.path);await y("[Sample/Proof-check] Scan complete.","info")}}else"sampleproofcheckhelp"===i&&await b(t,r,o,"info")};try{await e.addListener("hubs","hub_text_command",(e,t)=>i("hubs",e,t)),await e.addListener("private_chat","private_chat_text_command",(e,t)=>i("private_chat",e,t))}catch(e){console.error(`Could not register command listener: ${e.message}`)}if(r.system_info.api_feature_level>=4&&await L(e,[{id:"scan_sample_proof",title:"Scan share for missing Sample/Proof folders",icon:{semantic:"yellow search"},onClick:()=>{(async()=>{let t;await y("[Sample/Proof-check] Scan started...","info");try{t=await e.get("share_roots")}catch(e){return void await y(`[Sample/Proof-check] Could not retrieve share folders: ${e.message}`,"error")}for(const e of t)await C(e.path);await y("[Sample/Proof-check] Scan complete.","info")})()},access:"settings_edit",filter:e=>-1!==e.indexOf(t.name)}],"extension",{id:t.name,name:"Sample/Proof-check"}),r&&r.system_info&&r.system_info.api_feature_level>=8)try{await L(e,[{id:"sample_proof_check_folder",title:"Check Sample/Proof for this folder",icon:{semantic:"yellow search"},filter:(e,t)=>t===r.system_info.cid,access:"settings_edit",onClick:async(t,n)=>{for(const r of t){let t;try{t=await e.get(`filelists/${n}/items/${r}`)}catch(e){continue}if(!t||"directory"!==t.type.id)continue;let o=[];try{o=await P(e,t.path||"")}catch(e){o=[]}if(0===o.length&&t.dupe&&t.dupe.paths&&t.dupe.paths.length&&(o=t.dupe.paths),0!==o.length)for(const e of o)await y(`[Sample/Proof-check] Scan started for folder: ${e}...`,"info"),await C(e),await y(`[Sample/Proof-check] Scan of "${e}" complete.`,"info");else await y(`[Sample/Proof-check] Context menu: could not resolve a real disk path for "${t.name}" (virtual path: ${t.path}).`,"warning")}}}],"filelist_item",{id:t.name,name:t.name}),await y('[Sample/Proof-check] Context menu item "Check Sample/Proof for this folder" registered for Own filelist.',"info")}catch(e){await y(`[Sample/Proof-check] Could not register context menu item: ${e.message}`,"error"),console.error(`Could not register context menu item: ${e.message}`)}else await y(`[Sample/Proof-check] Context menu item skipped: api_feature_level is ${r&&r.system_info?r.system_info.api_feature_level:"unknown"} (needs >= 8).`,"warning");if(r&&r.system_info&&r.system_info.api_feature_level>=8)try{await L(e,[{id:"sample_proof_check_bundle",title:"Check Sample/Proof for this folder",icon:{semantic:"yellow search"},access:"settings_edit",onClick:async t=>{for(const n of t){const t=await T(e,n);t?(await y(`[Sample/Proof-check] Scan started for folder: ${t}...`,"info"),await C(t),await y(`[Sample/Proof-check] Scan of "${t}" complete.`,"info")):await y(`[Sample/Proof-check] Context menu: could not resolve a real disk folder for queue item ${n} (may be a single-file download, or already removed).`,"warning")}}}],"queue_bundle",{id:t.name,name:t.name}),await y('[Sample/Proof-check] Context menu item "Check Sample/Proof for this folder" registered for the Download Queue.',"info")}catch(e){await y(`[Sample/Proof-check] Could not register queue context menu item: ${e.message}`,"error"),console.error(`Could not register queue context menu item: ${e.message}`)}else await y(`[Sample/Proof-check] Queue context menu item skipped: api_feature_level is ${r&&r.system_info?r.system_info.api_feature_level:"unknown"} (needs >= 8).`,"warning");await y("[Sample/Proof-check] Extension started, command /sampleproofcheck [path] is active. Type /sampleproofcheckhelp for help.","info")},t.onStop=()=>{}}},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")},9003(e){"use strict";e.exports={version:"1.0.35"}}};const t={};function n(r){const o=t[r];if(void 0!==o)return o.exports;const i=t[r]={id:r,loaded:!1,exports:{}};return e[r](i,i.exports,n),i.loaded=!0,i.exports}n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.cw=e=>{var t;return()=>{if(e){var n=e;e=0,t={exports:{}},n.call(t.exports,t,t.exports)}return t.exports}},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";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}=n(5482);e(n(8803),{})})(),module.exports={}})();
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "airdcpp-sample-proof-checker",
3
+ "version": "1.2.10-beta",
4
+ "description": "Checks release folders for missing Sample (with mkv) or Proof subfolders, and searches/redownloads just that subfolder if needed.",
5
+ "keywords": [
6
+ "airdcpp",
7
+ "airdcpp-extensions",
8
+ "airdcpp-extensions-public"
9
+ ],
10
+ "homepage": "https://github.com/sharefixxers/airdcpp-sample-proof-checker#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/sharefixxers/airdcpp-sample-proof-checker/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/sharefixxers/airdcpp-sample-proof-checker.git",
17
+ "directory": "airdcpp-sample-proof-checker"
18
+ },
19
+ "license": "MIT",
20
+ "author": "ShareFixxers",
21
+ "type": "commonjs",
22
+ "main": "dist/main.js",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "webpack"
28
+ },
29
+ "dependencies": {
30
+ "airdcpp-extension": "^1.5.1",
31
+ "airdcpp-extension-settings": "^1.2.1"
32
+ },
33
+ "devDependencies": {
34
+ "webpack": "^5.94.0",
35
+ "webpack-cli": "^5.1.4"
36
+ },
37
+ "airdcpp": {
38
+ "apiVersion": 1,
39
+ "minApiFeatureLevel": 4,
40
+ "signalReady": false
41
+ },
42
+ "allowScripts": {
43
+ "bufferutil@4.1.0": true,
44
+ "es5-ext@0.10.64": true,
45
+ "utf-8-validate@5.0.10": true
46
+ }
47
+ }