@gadgetinc/ggt 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +392 -307
- package/dist/action-CF6zatIh.js +64 -0
- package/dist/action-CF6zatIh.js.map +1 -0
- package/dist/action-CrDCeX3F.js +8 -0
- package/dist/action-CrDCeX3F.js.map +1 -0
- package/dist/add-Basu3Gyf.js +1 -0
- package/dist/agent-plugin-CqgwTOk-.js +15 -0
- package/dist/agent-plugin-CqgwTOk-.js.map +1 -0
- package/dist/agent-plugin-DU9G5B1d.js +9 -0
- package/dist/agent-plugin-DU9G5B1d.js.map +1 -0
- package/dist/assert-Bu1E126Z.js +2 -0
- package/dist/assert-Bu1E126Z.js.map +1 -0
- package/dist/chunk-BjEoQXZ0.js +1 -0
- package/dist/collection-C2TCeYqY.js +2 -0
- package/dist/collection-C2TCeYqY.js.map +1 -0
- package/dist/collection-aM0fpch0.js +1 -0
- package/dist/command-2iNTc5dV.js +118 -0
- package/dist/command-2iNTc5dV.js.map +1 -0
- package/dist/completion-D96nxD5n.js +37 -0
- package/dist/completion-D96nxD5n.js.map +1 -0
- package/dist/configure-C8ge-2cK.js +15 -0
- package/dist/configure-C8ge-2cK.js.map +1 -0
- package/dist/debugger-BkYgApKn.js +22 -0
- package/dist/debugger-BkYgApKn.js.map +1 -0
- package/dist/defaults-B_eD7Pia.js +2 -0
- package/dist/defaults-B_eD7Pia.js.map +1 -0
- package/dist/deploy-Da6P2HXS.js +15 -0
- package/dist/deploy-Da6P2HXS.js.map +1 -0
- package/dist/dev-DWMSNcLl.js +32 -0
- package/dist/dev-DWMSNcLl.js.map +1 -0
- package/dist/dev-lock-BFanZSu1.js +10 -0
- package/dist/dev-lock-BFanZSu1.js.map +1 -0
- package/dist/directory-CNL03L6c.js +9 -0
- package/dist/directory-CNL03L6c.js.map +1 -0
- package/dist/env-DoWNvHzW.js +62 -0
- package/dist/env-DoWNvHzW.js.map +1 -0
- package/dist/esm-B25i6Etq.js +12 -0
- package/dist/esm-B25i6Etq.js.map +1 -0
- package/dist/esm-CJocZrdd.js +2 -0
- package/dist/esm-CJocZrdd.js.map +1 -0
- package/dist/eval-BceZMSd5.js +27 -0
- package/dist/eval-BceZMSd5.js.map +1 -0
- package/dist/execAsync-DrhcEHLd.js +2 -0
- package/dist/execAsync-DrhcEHLd.js.map +1 -0
- package/dist/filesync-De6asZeR.js +61 -0
- package/dist/filesync-De6asZeR.js.map +1 -0
- package/dist/getMachineId-bsd-Cch8Z6pV.js +2 -0
- package/dist/getMachineId-bsd-Cch8Z6pV.js.map +1 -0
- package/dist/getMachineId-darwin-kbQWK54o.js +3 -0
- package/dist/getMachineId-darwin-kbQWK54o.js.map +1 -0
- package/dist/getMachineId-linux-DdIel6zr.js +2 -0
- package/dist/getMachineId-linux-DdIel6zr.js.map +1 -0
- package/dist/getMachineId-unsupported-Bvmsh30k.js +2 -0
- package/dist/getMachineId-unsupported-Bvmsh30k.js.map +1 -0
- package/dist/getMachineId-win-BteHZe8j.js +2 -0
- package/dist/getMachineId-win-BteHZe8j.js.map +1 -0
- package/dist/ggt-B3HQjQRM.js +3 -0
- package/dist/ggt-B3HQjQRM.js.map +1 -0
- package/dist/handler-DZyG8Sel.js +4 -0
- package/dist/handler-DZyG8Sel.js.map +1 -0
- package/dist/http-CY3lPMkt.js +320 -0
- package/dist/http-CY3lPMkt.js.map +1 -0
- package/dist/indent-string-BVm-4tyL.js +2 -0
- package/dist/indent-string-BVm-4tyL.js.map +1 -0
- package/dist/list-lQKWZ6ZI.js +10 -0
- package/dist/list-lQKWZ6ZI.js.map +1 -0
- package/dist/login-Ce0tByNd.js +1 -0
- package/dist/logout-_sTWeaiQ.js +5 -0
- package/dist/logout-_sTWeaiQ.js.map +1 -0
- package/dist/logs-DbhJzz4M.js +9 -0
- package/dist/logs-DbhJzz4M.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -7
- package/dist/model-CBiMKY0P.js +11 -0
- package/dist/model-CBiMKY0P.js.map +1 -0
- package/dist/ms-B7sMc0pR.js +2 -0
- package/dist/ms-B7sMc0pR.js.map +1 -0
- package/dist/open-CSsA4B-l.js +38 -0
- package/dist/open-CSsA4B-l.js.map +1 -0
- package/dist/p-map-DE0acmRv.js +2 -0
- package/dist/p-map-DE0acmRv.js.map +1 -0
- package/dist/problems-BMLsmxd4.js +11 -0
- package/dist/problems-BMLsmxd4.js.map +1 -0
- package/dist/prompt-C9nwJW0G.js +2 -0
- package/dist/prompt-C9nwJW0G.js.map +1 -0
- package/dist/pull-DpizmJGk.js +12 -0
- package/dist/pull-DpizmJGk.js.map +1 -0
- package/dist/push-67KBCw6c.js +12 -0
- package/dist/push-67KBCw6c.js.map +1 -0
- package/dist/root-D_UnUsp7.js +28 -0
- package/dist/root-D_UnUsp7.js.map +1 -0
- package/dist/select-Dey_sjjd.js +4 -0
- package/dist/select-Dey_sjjd.js.map +1 -0
- package/dist/session-BmzGF1t7.js +2 -0
- package/dist/session-BmzGF1t7.js.map +1 -0
- package/dist/spinner-BVmbgIil.js +8 -0
- package/dist/spinner-BVmbgIil.js.map +1 -0
- package/dist/src-DxCC1MV4.js +6 -0
- package/dist/src-DxCC1MV4.js.map +1 -0
- package/dist/status-P_RFQ7J0.js +13 -0
- package/dist/status-P_RFQ7J0.js.map +1 -0
- package/dist/subscribeToEnvironmentLogs-CUicaiw_.js +2 -0
- package/dist/subscribeToEnvironmentLogs-CUicaiw_.js.map +1 -0
- package/dist/sync-json-V52OzeCz.js +112 -0
- package/dist/sync-json-V52OzeCz.js.map +1 -0
- package/dist/table-MrBbxMay.js +11 -0
- package/dist/table-MrBbxMay.js.map +1 -0
- package/dist/update-CfxiL08e.js +12 -0
- package/dist/update-CfxiL08e.js.map +1 -0
- package/dist/update-iyhnL9-M.js +1 -0
- package/dist/var-ByWcufFt.js +59 -0
- package/dist/var-ByWcufFt.js.map +1 -0
- package/dist/version-B_9GB4u3.js +9 -0
- package/dist/version-B_9GB4u3.js.map +1 -0
- package/dist/whoami-BNcXIfz7.js +5 -0
- package/dist/whoami-BNcXIfz7.js.map +1 -0
- package/package.json +19 -23
- package/assets/favicon-128@4x.png +0 -0
- package/dist/add-TWLGKL2T.js +0 -82
- package/dist/add-TWLGKL2T.js.map +0 -7
- package/dist/agent-plugin-TN24O7FB.js +0 -10
- package/dist/agent-plugin-TN24O7FB.js.map +0 -7
- package/dist/chunk-2742UPMB.js +0 -10
- package/dist/chunk-2742UPMB.js.map +0 -7
- package/dist/chunk-3OM5WM7E.js +0 -2
- package/dist/chunk-3OM5WM7E.js.map +0 -7
- package/dist/chunk-442CSROP.js +0 -66
- package/dist/chunk-442CSROP.js.map +0 -7
- package/dist/chunk-7DYQUG5M.js +0 -2
- package/dist/chunk-7DYQUG5M.js.map +0 -7
- package/dist/chunk-DR4CXBD6.js +0 -11
- package/dist/chunk-DR4CXBD6.js.map +0 -7
- package/dist/chunk-F255O64V.js +0 -2
- package/dist/chunk-F255O64V.js.map +0 -7
- package/dist/chunk-GFQYFEEH.js +0 -2
- package/dist/chunk-GFQYFEEH.js.map +0 -7
- package/dist/chunk-GJGBTM5Y.js +0 -2
- package/dist/chunk-GJGBTM5Y.js.map +0 -7
- package/dist/chunk-HCULGPBH.js +0 -2
- package/dist/chunk-HCULGPBH.js.map +0 -7
- package/dist/chunk-J232VCIM.js +0 -2
- package/dist/chunk-J232VCIM.js.map +0 -7
- package/dist/chunk-JG2QCDK2.js +0 -118
- package/dist/chunk-JG2QCDK2.js.map +0 -7
- package/dist/chunk-JKZNSRLU.js +0 -8
- package/dist/chunk-JKZNSRLU.js.map +0 -7
- package/dist/chunk-JYE5LLIF.js +0 -9
- package/dist/chunk-JYE5LLIF.js.map +0 -7
- package/dist/chunk-KKIL22RY.js +0 -2
- package/dist/chunk-KKIL22RY.js.map +0 -7
- package/dist/chunk-L2XBSR7G.js +0 -2
- package/dist/chunk-L2XBSR7G.js.map +0 -7
- package/dist/chunk-MW6MXMSN.js +0 -2
- package/dist/chunk-MW6MXMSN.js.map +0 -7
- package/dist/chunk-OUIZQC4D.js +0 -12
- package/dist/chunk-OUIZQC4D.js.map +0 -7
- package/dist/chunk-R6KJLEKY.js +0 -28
- package/dist/chunk-R6KJLEKY.js.map +0 -7
- package/dist/chunk-SIR6HLN3.js +0 -69
- package/dist/chunk-SIR6HLN3.js.map +0 -7
- package/dist/chunk-SVWK2NXG.js +0 -2
- package/dist/chunk-SVWK2NXG.js.map +0 -7
- package/dist/chunk-T6UHSWMT.js +0 -2
- package/dist/chunk-T6UHSWMT.js.map +0 -7
- package/dist/chunk-WB6O2V5D.js +0 -11
- package/dist/chunk-WB6O2V5D.js.map +0 -7
- package/dist/chunk-XC4F2TLW.js +0 -113
- package/dist/chunk-XC4F2TLW.js.map +0 -7
- package/dist/chunk-YFUOXDPK.js +0 -10
- package/dist/chunk-YFUOXDPK.js.map +0 -7
- package/dist/chunk-ZSREFZXV.js +0 -211
- package/dist/chunk-ZSREFZXV.js.map +0 -7
- package/dist/chunk-ZYDMXS5R.js +0 -6
- package/dist/chunk-ZYDMXS5R.js.map +0 -7
- package/dist/configure-UJS7V2JX.js +0 -12
- package/dist/configure-UJS7V2JX.js.map +0 -7
- package/dist/debugger-QN2MCLBL.js +0 -41
- package/dist/debugger-QN2MCLBL.js.map +0 -7
- package/dist/deploy-J74PHPQA.js +0 -25
- package/dist/deploy-J74PHPQA.js.map +0 -7
- package/dist/dev-GGUSOOYP.js +0 -59
- package/dist/dev-GGUSOOYP.js.map +0 -7
- package/dist/esm-D77XRR65.js +0 -38
- package/dist/esm-D77XRR65.js.map +0 -7
- package/dist/eval-L6WHUFLU.js +0 -54
- package/dist/eval-L6WHUFLU.js.map +0 -7
- package/dist/getMachineId-bsd-QUXN4NKS.js +0 -2
- package/dist/getMachineId-bsd-QUXN4NKS.js.map +0 -7
- package/dist/getMachineId-darwin-TCXBAX22.js +0 -3
- package/dist/getMachineId-darwin-TCXBAX22.js.map +0 -7
- package/dist/getMachineId-linux-IJ3LYIOX.js +0 -2
- package/dist/getMachineId-linux-IJ3LYIOX.js.map +0 -7
- package/dist/getMachineId-unsupported-IKXBUCYY.js +0 -2
- package/dist/getMachineId-unsupported-IKXBUCYY.js.map +0 -7
- package/dist/getMachineId-win-6CX7VSFF.js +0 -2
- package/dist/getMachineId-win-6CX7VSFF.js.map +0 -7
- package/dist/ggt-5XNRJZSW.js +0 -44
- package/dist/ggt-5XNRJZSW.js.map +0 -7
- package/dist/list-756D46N5.js +0 -11
- package/dist/list-756D46N5.js.map +0 -7
- package/dist/login-GMWQRH7V.js +0 -2
- package/dist/login-GMWQRH7V.js.map +0 -7
- package/dist/logout-LQABTJFD.js +0 -7
- package/dist/logout-LQABTJFD.js.map +0 -7
- package/dist/logs-AQZB272X.js +0 -28
- package/dist/logs-AQZB272X.js.map +0 -7
- package/dist/open-OMZWPQ66.js +0 -74
- package/dist/open-OMZWPQ66.js.map +0 -7
- package/dist/problems-FZJKH52E.js +0 -14
- package/dist/problems-FZJKH52E.js.map +0 -7
- package/dist/pull-XYCYN7QN.js +0 -28
- package/dist/pull-XYCYN7QN.js.map +0 -7
- package/dist/push-3QM7ZFTC.js +0 -2
- package/dist/push-3QM7ZFTC.js.map +0 -7
- package/dist/status-PWAXNK5G.js +0 -14
- package/dist/status-PWAXNK5G.js.map +0 -7
- package/dist/update-QIQFJFRQ.js +0 -2
- package/dist/update-QIQFJFRQ.js.map +0 -7
- package/dist/var-N4WGGJXZ.js +0 -159
- package/dist/var-N4WGGJXZ.js.map +0 -7
- package/dist/version-AJKSJJDC.js +0 -11
- package/dist/version-AJKSJJDC.js.map +0 -7
- package/dist/whoami-KJYDSQSD.js +0 -7
- package/dist/whoami-KJYDSQSD.js.map +0 -7
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-BjEoQXZ0.js";import{t as r}from"./ms-B7sMc0pR.js";import{a as i,r as a,t as o}from"./prompt-C9nwJW0G.js";import{A as s,At as c,C as l,D as u,Dt as d,E as f,G as p,H as m,Lt as h,Mt as g,Nt as _,O as v,Ot as y,Rt as b,S as x,T as S,Tt as C,V as w,at as T,bt as E,c as D,ct as ee,d as O,dt as te,ft as ne,g as re,h as k,it as ie,j as A,jt as ae,k as j,kt as oe,l as se,m as M,mt as ce,n as le,ot as ue,s as N,st as de,vt as fe,w as pe,wt as me,x as he,xt as ge,yt as P}from"./command-2iNTc5dV.js";import{a as _e,r as F,t as ve}from"./collection-C2TCeYqY.js";import{n as ye,r as be,t as xe}from"./session-BmzGF1t7.js";import Se from"process";import Ce,{execFile as we}from"node:child_process";import Te from"node:os";import Ee from"node:path";import{promisify as De}from"node:util";import Oe,{Agent as ke}from"node:http";import{Agent as Ae}from"node:https";import je from"node:net";import I from"node:process";import Me from"node:tty";import{setTimeout as Ne}from"node:timers/promises";import{Buffer as Pe}from"node:buffer";import{randomUUID as Fe}from"node:crypto";import{fileURLToPath as Ie}from"node:url";import Le from"node:assert";import Re,{constants as ze}from"node:fs/promises";function L(e,t=globalThis.Deno?globalThis.Deno.args:I.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:R}=I;let Be;L(`no-color`)||L(`no-colors`)||L(`color=false`)||L(`color=never`)?Be=0:(L(`color`)||L(`colors`)||L(`color=true`)||L(`color=always`))&&(Be=1);function Ve(){if(!(`FORCE_COLOR`in R))return;if(R.FORCE_COLOR===`true`)return 1;if(R.FORCE_COLOR===`false`)return 0;if(R.FORCE_COLOR.length===0)return 1;let e=Math.min(Number.parseInt(R.FORCE_COLOR,10),3);if([0,1,2,3].includes(e))return e}function He(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Ue(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Ve();r!==void 0&&(Be=r);let i=n?Be:r;if(i===0)return 0;if(n){if(L(`color=16m`)||L(`color=full`)||L(`color=truecolor`))return 3;if(L(`color=256`))return 2}if(`TF_BUILD`in R&&`AGENT_NAME`in R)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(R.TERM===`dumb`)return a;if(I.platform===`win32`){let e=Te.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in R)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in R)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in R)||R.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in R)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(R.TEAMCITY_VERSION)?1:0;if(R.COLORTERM===`truecolor`||R.TERM===`xterm-kitty`||R.TERM===`xterm-ghostty`||R.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in R){let e=Number.parseInt((R.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(R.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(R.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(R.TERM)||`COLORTERM`in R?1:a}function We(e,t={}){return He(Ue(e,{streamIsTTY:e&&e.isTTY,...t}))}We({isTTY:Me.isatty(1)}),We({isTTY:Me.isatty(2)});function z(e,t=Se.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}function Ge(e=``){if(/^\d{3,4}$/.test(e)){let t=/(\d{1,2})(\d{2})/.exec(e)??[];return{major:0,minor:Number.parseInt(t[1],10),patch:Number.parseInt(t[2],10)}}let t=(e??``).split(`.`).map(e=>Number.parseInt(e,10));return{major:t[0],minor:t[1],patch:t[2]}}function Ke(e){let{CI:t,CURSOR_TRACE_ID:n,FORCE_HYPERLINK:r,NETLIFY:i,TEAMCITY_VERSION:a,TERM_PROGRAM:o,TERM_PROGRAM_VERSION:s,VTE_VERSION:c,TERM:l}=I.env;if(r)return!(r.length>0&&Number.parseInt(r,10)===0);if(z(`no-hyperlink`)||z(`no-hyperlinks`)||z(`hyperlink=false`)||z(`hyperlink=never`))return!1;if(z(`hyperlink=true`)||z(`hyperlink=always`)||i)return!0;if(!We(e)||e&&!e.isTTY)return!1;if(`WT_SESSION`in I.env)return!0;if(I.platform===`win32`||t||a)return!1;if(o){let e=Ge(s);switch(o){case`iTerm.app`:return e.major===3?e.minor>=1:e.major>3;case`WezTerm`:return/^0-unstable-\d{4}-\d{2}-\d{2}$/.test(s)?s.slice(11)>=`2020-06-20`:e.major>=20200620;case`vscode`:return n?!0:e.major>1||e.major===1&&e.minor>=72;case`ghostty`:return!0}}if(c){if(c===`0.50.0`)return!1;let e=Ge(c);return e.major>0||e.minor>=50}switch(l){case`alacritty`:return!0;case`xterm-kitty`:return!0}return!1}const qe={stdout:Ke(I.stdout),stderr:Ke(I.stderr)};function B(e,t,{target:n=`stdout`,...r}={}){return qe[n]?i(e,t):r.fallback===!1?e:typeof r.fallback==`function`?r.fallback(e,t):`${e} ${t}`}B.isSupported=qe.stdout,B.stderr=(e,t,n={})=>B(e,t,{target:`stderr`,...n}),B.stderr.isSupported=qe.stderr;const Je=new Map,Ye=e=>{if(!e)return;let t=Je.get(e);return t===void 0?(t=/(?:query|mutation|subscription)\s+(\w+)/.exec(e)?.[1],t&&Je.set(e,t),t):t},Xe=f(`
|
|
2
|
+
subscription EnvironmentLogs($query: String!, $start: DateTime, $limit: Int) {
|
|
3
|
+
logsSearchV2(query: $query, start: $start, limit: $limit) {
|
|
4
|
+
status
|
|
5
|
+
data
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`),Ze=f(`
|
|
9
|
+
subscription RemoteFileSyncEvents($localFilesVersion: String!) {
|
|
10
|
+
remoteFileSyncEvents(localFilesVersion: $localFilesVersion, encoding: base64) {
|
|
11
|
+
remoteFilesVersion
|
|
12
|
+
changed {
|
|
13
|
+
path
|
|
14
|
+
mode
|
|
15
|
+
content
|
|
16
|
+
encoding
|
|
17
|
+
}
|
|
18
|
+
deleted {
|
|
19
|
+
path
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`);f(`
|
|
24
|
+
query RemoteFilesVersion {
|
|
25
|
+
remoteFilesVersion
|
|
26
|
+
}
|
|
27
|
+
`);const Qe=f(`
|
|
28
|
+
mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
|
|
29
|
+
publishFileSyncEvents(input: $input) {
|
|
30
|
+
remoteFilesVersion
|
|
31
|
+
problems {
|
|
32
|
+
level
|
|
33
|
+
message
|
|
34
|
+
path
|
|
35
|
+
type
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`),$e=f(`
|
|
40
|
+
query FileSyncFiles($paths: [String!]!, $filesVersion: String, $encoding: FileSyncEncoding) {
|
|
41
|
+
fileSyncFiles(paths: $paths, filesVersion: $filesVersion, encoding: $encoding) {
|
|
42
|
+
filesVersion
|
|
43
|
+
files {
|
|
44
|
+
path
|
|
45
|
+
mode
|
|
46
|
+
content
|
|
47
|
+
encoding
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`),et=f(`
|
|
52
|
+
query FileSyncHashes($filesVersion: String) {
|
|
53
|
+
fileSyncHashes(filesVersion: $filesVersion) {
|
|
54
|
+
filesVersion
|
|
55
|
+
hashes
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`),tt=f(`
|
|
59
|
+
query FileSyncComparisonHashes($filesVersion: String!) {
|
|
60
|
+
fileSyncComparisonHashes(filesVersion: $filesVersion) {
|
|
61
|
+
filesVersionHashes {
|
|
62
|
+
filesVersion
|
|
63
|
+
hashes
|
|
64
|
+
}
|
|
65
|
+
latestFilesVersionHashes {
|
|
66
|
+
filesVersion
|
|
67
|
+
hashes
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`),nt=f(`
|
|
72
|
+
subscription PublishStatus($localFilesVersion: String!, $force: Boolean, $allowCharges: Boolean, $allowDeletedData: Boolean) {
|
|
73
|
+
publishStatus(localFilesVersion: $localFilesVersion, force: $force, allowCharges: $allowCharges, allowDeletedData: $allowDeletedData) {
|
|
74
|
+
publishStarted
|
|
75
|
+
remoteFilesVersion
|
|
76
|
+
progress
|
|
77
|
+
issues {
|
|
78
|
+
severity
|
|
79
|
+
message
|
|
80
|
+
node {
|
|
81
|
+
type
|
|
82
|
+
key
|
|
83
|
+
apiIdentifier
|
|
84
|
+
name
|
|
85
|
+
fieldType
|
|
86
|
+
parentKey
|
|
87
|
+
parentApiIdentifier
|
|
88
|
+
}
|
|
89
|
+
nodeLabels {
|
|
90
|
+
type
|
|
91
|
+
identifier
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
deletedModelsAndFields {
|
|
95
|
+
deletedModels
|
|
96
|
+
deletedModelFields {
|
|
97
|
+
modelIdentifier
|
|
98
|
+
fields
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
status {
|
|
102
|
+
code
|
|
103
|
+
message
|
|
104
|
+
output
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`),rt=f(`
|
|
109
|
+
mutation createModel($path: String!, $fields: [CreateModelFieldsInput!]) {
|
|
110
|
+
createModel(path: $path, fields: $fields) {
|
|
111
|
+
remoteFilesVersion
|
|
112
|
+
changed {
|
|
113
|
+
path
|
|
114
|
+
mode
|
|
115
|
+
content
|
|
116
|
+
encoding
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`),it=f(`
|
|
121
|
+
mutation createAction($path: String!) {
|
|
122
|
+
createAction(path: $path) {
|
|
123
|
+
remoteFilesVersion
|
|
124
|
+
changed {
|
|
125
|
+
path
|
|
126
|
+
mode
|
|
127
|
+
content
|
|
128
|
+
encoding
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`),at=f(`
|
|
133
|
+
mutation createRoute($method: String!, $path: String!) {
|
|
134
|
+
createRoute(method: $method, path: $path) {
|
|
135
|
+
remoteFilesVersion
|
|
136
|
+
changed {
|
|
137
|
+
path
|
|
138
|
+
mode
|
|
139
|
+
content
|
|
140
|
+
encoding
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`),ot=f(`
|
|
145
|
+
mutation createModelFields($path: String!, $fields: [CreateModelFieldsInput!]!) {
|
|
146
|
+
createModelFields(path: $path, fields: $fields) {
|
|
147
|
+
remoteFilesVersion
|
|
148
|
+
changed {
|
|
149
|
+
path
|
|
150
|
+
mode
|
|
151
|
+
content
|
|
152
|
+
encoding
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`),st=f(`
|
|
157
|
+
mutation CreateEnvironment($environment: EnvironmentInput!) {
|
|
158
|
+
createEnvironment(environment: $environment) {
|
|
159
|
+
slug
|
|
160
|
+
status
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`),ct=f(`
|
|
164
|
+
mutation UnpauseEnvironment {
|
|
165
|
+
unpauseEnvironment {
|
|
166
|
+
success
|
|
167
|
+
alreadyActive
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`),lt=f(`
|
|
171
|
+
mutation DeleteEnvironment($slug: String!) {
|
|
172
|
+
deleteEnvironment(slug: $slug)
|
|
173
|
+
}
|
|
174
|
+
`),ut=f(`
|
|
175
|
+
query PublishIssues {
|
|
176
|
+
publishIssues {
|
|
177
|
+
severity
|
|
178
|
+
message
|
|
179
|
+
node {
|
|
180
|
+
type
|
|
181
|
+
key
|
|
182
|
+
apiIdentifier
|
|
183
|
+
name
|
|
184
|
+
fieldType
|
|
185
|
+
parentKey
|
|
186
|
+
parentApiIdentifier
|
|
187
|
+
}
|
|
188
|
+
nodeLabels {
|
|
189
|
+
type
|
|
190
|
+
identifier
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`),dt=f(`
|
|
195
|
+
query EnvironmentVariables {
|
|
196
|
+
environmentVariables {
|
|
197
|
+
key
|
|
198
|
+
value
|
|
199
|
+
isSecret
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
`),ft=f(`
|
|
203
|
+
mutation SetEnvironmentVariable($input: SetEnvironmentVariableInput!) {
|
|
204
|
+
setEnvironmentVariable(input: $input) {
|
|
205
|
+
remoteFilesVersion
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`),pt=f(`
|
|
209
|
+
mutation DeleteEnvironmentVariable($key: String!) {
|
|
210
|
+
deleteEnvironmentVariable(key: $key) {
|
|
211
|
+
remoteFilesVersion
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
`);var mt=n(((t,n)=>{(function(r,i){typeof e==`function`&&typeof t==`object`&&typeof n==`object`?n.exports=i():typeof define==`function`&&define.amd?define(function(){return i()}):r.pluralize=i()})(t,function(){var e=[],t=[],n={},r={},i={};function a(e){return typeof e==`string`?RegExp(`^`+e+`$`,`i`):e}function o(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||``})}function c(e,t){return e.replace(t[0],function(n,r){var i=s(t[1],arguments);return o(n===``?e[r-1]:n,i)})}function l(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var a=r[i];if(a[0].test(t))return c(t,a)}return t}function u(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?o(r,i):e.hasOwnProperty(i)?o(r,e[i]):l(i,r,n)}}function d(e,t,n,r){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?!0:e.hasOwnProperty(i)?!1:l(i,i,n)===i}}function f(e,t,n){var r=t===1?f.singular(e):f.plural(e);return(n?t+` `:``)+r}return f.plural=u(i,r,e),f.isPlural=d(i,r,e),f.singular=u(r,i,t),f.isSingular=d(r,i,t),f.addPluralRule=function(t,n){e.push([a(t),n])},f.addSingularRule=function(e,n){t.push([a(e),n])},f.addUncountableRule=function(e){if(typeof e==`string`){n[e.toLowerCase()]=!0;return}f.addPluralRule(e,`$0`),f.addSingularRule(e,`$0`)},f.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[[`I`,`we`],[`me`,`us`],[`he`,`they`],[`she`,`they`],[`them`,`them`],[`myself`,`ourselves`],[`yourself`,`yourselves`],[`itself`,`themselves`],[`herself`,`themselves`],[`himself`,`themselves`],[`themself`,`themselves`],[`is`,`are`],[`was`,`were`],[`has`,`have`],[`this`,`these`],[`that`,`those`],[`echo`,`echoes`],[`dingo`,`dingoes`],[`volcano`,`volcanoes`],[`tornado`,`tornadoes`],[`torpedo`,`torpedoes`],[`genus`,`genera`],[`viscus`,`viscera`],[`stigma`,`stigmata`],[`stoma`,`stomata`],[`dogma`,`dogmata`],[`lemma`,`lemmata`],[`schema`,`schemata`],[`anathema`,`anathemata`],[`ox`,`oxen`],[`axe`,`axes`],[`die`,`dice`],[`yes`,`yeses`],[`foot`,`feet`],[`eave`,`eaves`],[`goose`,`geese`],[`tooth`,`teeth`],[`quiz`,`quizzes`],[`human`,`humans`],[`proof`,`proofs`],[`carve`,`carves`],[`valve`,`valves`],[`looey`,`looies`],[`thief`,`thieves`],[`groove`,`grooves`],[`pickaxe`,`pickaxes`],[`passerby`,`passersby`]].forEach(function(e){return f.addIrregularRule(e[0],e[1])}),[[/s?$/i,`s`],[/[^\u0000-\u007F]$/i,`$0`],[/([^aeiou]ese)$/i,`$1`],[/(ax|test)is$/i,`$1es`],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,`$1es`],[/(e[mn]u)s?$/i,`$1s`],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,`$1`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1i`],[/(alumn|alg|vertebr)(?:a|ae)$/i,`$1ae`],[/(seraph|cherub)(?:im)?$/i,`$1im`],[/(her|at|gr)o$/i,`$1oes`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,`$1a`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,`$1a`],[/sis$/i,`ses`],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,`$1$2ves`],[/([^aeiouy]|qu)y$/i,`$1ies`],[/([^ch][ieo][ln])ey$/i,`$1ies`],[/(x|ch|ss|sh|zz)$/i,`$1es`],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,`$1ices`],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,`$1ice`],[/(pe)(?:rson|ople)$/i,`$1ople`],[/(child)(?:ren)?$/i,`$1ren`],[/eaux$/i,`$0`],[/m[ae]n$/i,`men`],[`thou`,`you`]].forEach(function(e){return f.addPluralRule(e[0],e[1])}),[[/s$/i,``],[/(ss)$/i,`$1`],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,`$1fe`],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,`$1f`],[/ies$/i,`y`],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,`$1ie`],[/\b(mon|smil)ies$/i,`$1ey`],[/\b((?:tit)?m|l)ice$/i,`$1ouse`],[/(seraph|cherub)im$/i,`$1`],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,`$1`],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,`$1sis`],[/(movie|twelve|abuse|e[mn]u)s$/i,`$1`],[/(test)(?:is|es)$/i,`$1is`],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,`$1us`],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,`$1um`],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,`$1on`],[/(alumn|alg|vertebr)ae$/i,`$1a`],[/(cod|mur|sil|vert|ind)ices$/i,`$1ex`],[/(matr|append)ices$/i,`$1ix`],[/(pe)(rson|ople)$/i,`$1rson`],[/(child)ren$/i,`$1`],[/(eau)x?$/i,`$1`],[/men$/i,`man`]].forEach(function(e){return f.addSingularRule(e[0],e[1])}),[`adulthood`,`advice`,`agenda`,`aid`,`aircraft`,`alcohol`,`ammo`,`analytics`,`anime`,`athletics`,`audio`,`bison`,`blood`,`bream`,`buffalo`,`butter`,`carp`,`cash`,`chassis`,`chess`,`clothing`,`cod`,`commerce`,`cooperation`,`corps`,`debris`,`diabetes`,`digestion`,`elk`,`energy`,`equipment`,`excretion`,`expertise`,`firmware`,`flounder`,`fun`,`gallows`,`garbage`,`graffiti`,`hardware`,`headquarters`,`health`,`herpes`,`highjinks`,`homework`,`housework`,`information`,`jeans`,`justice`,`kudos`,`labour`,`literature`,`machinery`,`mackerel`,`mail`,`media`,`mews`,`moose`,`music`,`mud`,`manga`,`news`,`only`,`personnel`,`pike`,`plankton`,`pliers`,`police`,`pollution`,`premises`,`rain`,`research`,`rice`,`salmon`,`scissors`,`series`,`sewage`,`shambles`,`shrimp`,`software`,`species`,`staff`,`swine`,`tennis`,`traffic`,`transportation`,`trout`,`tuna`,`wealth`,`welfare`,`whiting`,`wildebeest`,`wildlife`,`you`,/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})})),ht=t(r(),1);const gt=[`ETIMEDOUT`,`ECONNRESET`,`EADDRINUSE`,`ECONNREFUSED`,`EPIPE`,`ENOTFOUND`,`ENETUNREACH`,`EAI_AGAIN`,`EAI_FAIL`,`EADDRNOTAVAIL`,`EHOSTUNREACH`,`ERR_SSL_SSL/TLS_ALERT_BAD_RECORD_MAC`,`EPROTO`],_t=(0,ht.default)(`5s`),vt=[`GET`,`PUT`,`HEAD`,`DELETE`,`OPTIONS`,`TRACE`],yt=[408,413,429,500,502,503,504,521,522,524],bt=(e,t=_t,n=100)=>{let r=Math.min(2**e*100,t);return Math.max(0,r+(Math.random()*n*2-n))},xt=e=>!P(e)||!(`code`in e)?!1:gt.includes(e.code),St=[/unauthenticated/i,/unauthorized/i,/forbidden/i,/not allowed/i,/permission denied/i],Ct=[1e3,1008,4401,4403],wt=e=>xt(e.error),Tt=e=>!Ct.includes(e.code),Et=e=>!e.some(e=>{let t=e.extensions?.code;return t===`UNAUTHENTICATED`||t===`FORBIDDEN`||t===`UNAUTHORIZED`?!0:St.some(t=>t.test(e.message))}),Dt=e=>ee(e)?Tt(e):ne(e)?wt(e):te(e)?xt(e):ce(e)?Et(e):typeof e==`string`?!St.some(t=>t.test(e)):ge(e)?!e.some(e=>St.some(t=>t.test(e))):!1;let V;const Ot=async(e,t)=>{t[`--telemetry`]&&(V=await import(`./esm-B25i6Etq.js`),V.init({dsn:`https://0c26e0d8afd94e77a88ee1c3aa9e7065@o250689.ingest.sentry.io/6703266`,enabled:S.productionLike&&(t[`--telemetry`]??!1),release:A.version,environment:A.version.includes(`experimental`)?`experimental`:`production`}))},kt=async e=>{V&&(V.captureException(e,{event_id:e.id,captureContext:{tags:{arch:O.arch,bug:e.isBug,environment:S.value,platform:O.platform,shell:O.shell,version:A.version},contexts:{ctx:{argv:process.argv},cause:e.cause?j(e.cause):void 0,app:{app_name:A.name,app_version:A.version},device:{name:Te.hostname(),family:Te.type(),arch:Te.arch()},runtime:{name:process.release.name,version:process.version}}}}),await V.flush((0,ht.default)(`2s`)))},At=e=>{V&&V.addBreadcrumb(e)},jt=e=>{V&&V.setUser(e)},Mt=e=>{V&&V.setTags(e)},Nt=async(e,t)=>{if(ue(t))return e.log.debug(`aborting without reporting error`,{error:t}),process.exit(1);e.log.error(`reporting error and exiting`,{error:t});try{let e=U.from(t);if(e.print(),e.isBug===H.NO)return;await kt(e)}finally{process.exit(1)}},Pt=async(e,t)=>{e.log.debug(`installing error handlers`),await Ot(e,t);let n=t=>void Nt(e,t);process.once(`uncaughtException`,n),process.once(`unhandledRejection`,n)},H=Object.freeze({YES:`yes`,NO:`no`,MAYBE:`maybe`});var U=class e extends Error{id=S.testLike?`00000000-0000-0000-0000-000000000000`:Fe();cause;stack;constructor(e){super(e),Error.captureStackTrace(this,this.constructor),this.stack=T(this.stack,{pretty:!0,basePath:s})}static from(t){return t instanceof e?t:xt(t)||P(t)&&`cause`in t&&xt(t.cause)?new It(t):new Ft(t)}sprint(){let e=this.render();if(this.isBug!==H.NO){e=u(e);let t=this.isBug===H.YES?`This is a bug`:`If you think this is a bug`,n=`https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.id}`;B.isSupported?e+=u({ensureEmptyLineAbove:!0,content:f`
|
|
215
|
+
${t}, ${B(`click here`,n)} to create an issue on GitHub.
|
|
216
|
+
`}):e+=u({ensureEmptyLineAbove:!0,content:f`
|
|
217
|
+
${t}, use the link below to create an issue on GitHub.
|
|
218
|
+
|
|
219
|
+
${n}
|
|
220
|
+
`})}return e}print(e){D({ensureEmptyLineAbove:!0,...e,content:this.sprint()})}},Ft=class extends U{isBug=H.YES;constructor(e){super(`An unexpected error occurred`),this.cause=e}render(){let e=j(this.cause),t=e.stack||e.message||this.stack;return f`
|
|
221
|
+
${this.message}.
|
|
222
|
+
|
|
223
|
+
${t}
|
|
224
|
+
`}},It=class extends U{isBug=H.MAYBE;constructor(e){super(`A network error occurred`),this.cause=e}render(){return f`
|
|
225
|
+
A network error occurred while communicating with Gadget.
|
|
226
|
+
|
|
227
|
+
Please check your internet connection and try again.
|
|
228
|
+
`}},Lt=class extends U{isBug=H.MAYBE;cause;constructor(e,t){super(e),this.cause=t}render(){return this.message}},Rt=t(mt(),1),W=class extends U{isBug;operationName;cause;constructor(e,t,n){super(`An error occurred while communicating with Gadget`),this.operationName=Ye(e),n?this.isBug=n:this.isBug=H.MAYBE,ne(t)?this.cause={type:t.type,message:t.message,error:j(t.error)}:ee(t)?this.cause={type:t.type,code:t.code,reason:t.reason,wasClean:t.wasClean}:(Le(E(t)||ge(t)||te(t)||ce(t),`cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent`),this.cause=t)}render(){let e;switch(!0){case ce(this.cause):{let t=_e(this.cause.map(e=>e.message));e=f`
|
|
229
|
+
Gadget responded with the following ${(0,Rt.default)(`error`,t.length,!1)}:
|
|
230
|
+
|
|
231
|
+
${t.map(e=>`• ${e}`).join(`
|
|
232
|
+
`)}
|
|
233
|
+
`;break}case ee(this.cause):e=`The connection to Gadget closed unexpectedly.`;break;case te(this.cause)&&xt(this.cause)||ne(this.cause)&&xt(this.cause.error):e=`Please check your internet connection and try again.`;break;case ne(this.cause)||te(this.cause):e=this.cause.message;break;case ge(this.cause):e=this.cause.length===1?String(this.cause[0]):this.cause.join(`, `);break;default:e=this.cause;break}return f`
|
|
234
|
+
${this.message}${this.operationName?` (running "${this.operationName}")`:``}
|
|
235
|
+
|
|
236
|
+
${e}
|
|
237
|
+
`}},zt=class extends W{constructor(e){super(e,`Request authentication failed due to the session expiring while running the command. Please sign-in again.`,H.NO)}},Bt=t(n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),Vt=class e extends Error{name=`TimeoutError`;constructor(t,n){super(t,n),Error.captureStackTrace?.(this,e)}};const Ht=e=>e.reason??new DOMException(`This operation was aborted.`,`AbortError`);function Ut(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout},signal:o}=t,s,c,l=new Promise((t,l)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(o?.aborted){l(Ht(o));return}if(o&&(c=()=>{l(Ht(o))},o.addEventListener(`abort`,c,{once:!0})),e.then(t,l),n===1/0)return;let u=new Vt;s=a.setTimeout.call(void 0,()=>{if(r){try{t(r())}catch(e){l(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?t():i instanceof Error?l(i):(u.message=i??`Promise timed out after ${n} milliseconds`,l(u))},n)}).finally(()=>{l.clear(),c&&o&&o.removeEventListener(`abort`,c)});return l.clear=()=>{a.clearTimeout.call(void 0,s),s=void 0},l}function Wt(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var Gt=class{#e=[];enqueue(e,t){let{priority:n=0,id:r}=t??{},i={priority:n,id:r,run:e};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(i);return}let a=Wt(this.#e,i,(e,t)=>t.priority-e.priority);this.#e.splice(a,0,i)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}},Kt=class extends Bt.default{#e;#t;#n=0;#r;#i=!1;#a=!1;#o;#s=0;#c=0;#l;#u;#d;#f=[];#p=0;#m;#h;#g=0;#_;#v;#y=1n;#b=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Gt,strict:!1,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);if(e.strict&&e.interval===0)throw TypeError("The `strict` option requires a non-zero `interval`");if(e.strict&&e.intervalCap===1/0)throw TypeError("The `strict` option requires a finite `intervalCap`");if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#o=e.interval,this.#d=e.strict,this.#m=new e.queueClass,this.#h=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#v=e.autoStart===!1,this.#R()}#x(e){for(;this.#p<this.#f.length;){let t=this.#f[this.#p];if(t!==void 0&&e-t>=this.#o)this.#p++;else break}(this.#p>100&&this.#p>this.#f.length/2||this.#p===this.#f.length)&&(this.#f=this.#f.slice(this.#p),this.#p=0)}#S(e){this.#d?this.#f.push(e):this.#n++}#C(){this.#d?this.#f.length>this.#p&&this.#f.pop():this.#n>0&&this.#n--}#w(){return this.#f.length-this.#p}get#T(){return this.#t?!0:this.#d?this.#w()<this.#r:this.#n<this.#r}get#E(){return this.#g<this.#_}#D(){this.#g--,this.#g===0&&this.emit(`pendingZero`),this.#N(),this.emit(`next`)}#O(){this.#u=void 0,this.#F(),this.#P()}#k(e){if(this.#d){if(this.#x(e),this.#w()>=this.#r){let t=this.#f[this.#p],n=this.#o-(e-t);return this.#A(n),!0}return!1}if(this.#l===void 0){let t=this.#s-e;if(t<0){if(this.#c>0){let t=e-this.#c;if(t<this.#o)return this.#A(this.#o-t),!0}this.#n=this.#e?this.#g:0}else return this.#A(t),!0}return!1}#A(e){this.#u===void 0&&(this.#u=setTimeout(()=>{this.#O()},e))}#j(){this.#l&&=(clearInterval(this.#l),void 0)}#M(){this.#u&&=(clearTimeout(this.#u),void 0)}#N(){if(this.#m.size===0){if(this.#j(),this.emit(`empty`),this.#g===0){if(this.#M(),this.#d&&this.#p>0){let e=Date.now();this.#x(e)}this.emit(`idle`)}return!1}let e=!1;if(!this.#v){let t=Date.now(),n=!this.#k(t);if(this.#T&&this.#E){let r=this.#m.dequeue();this.#t||(this.#S(t),this.#z()),this.emit(`active`),r(),n&&this.#P(),e=!0}}return e}#P(){this.#t||this.#l!==void 0||this.#d||(this.#l=setInterval(()=>{this.#F()},this.#o),this.#s=Date.now()+this.#o)}#F(){this.#d||(this.#n===0&&this.#g===0&&this.#l&&this.#j(),this.#n=this.#e?this.#g:0),this.#I(),this.#z()}#I(){for(;this.#N(););}get concurrency(){return this.#_}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#_=e,this.#I()}setPriority(e,t){if(typeof t!=`number`||!Number.isFinite(t))throw TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#m.setPriority(e,t)}async add(e,t={}){return t={timeout:this.timeout,...t,id:t.id??(this.#y++).toString()},new Promise((n,r)=>{let i=Symbol(`task-${t.id}`);this.#m.enqueue(async()=>{this.#g++,this.#b.set(i,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});let a;try{try{t.signal?.throwIfAborted()}catch(e){throw this.#B(),this.#b.delete(i),e}this.#c=Date.now();let r=e({signal:t.signal});if(t.timeout&&(r=Ut(Promise.resolve(r),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#g} running, ${this.#m.size} waiting)`})),t.signal){let{signal:e}=t;r=Promise.race([r,new Promise((t,n)=>{a=()=>{n(e.reason)},e.addEventListener(`abort`,a,{once:!0})})])}let o=await r;n(o),this.emit(`completed`,o)}catch(e){r(e),this.emit(`error`,e)}finally{a&&t.signal?.removeEventListener(`abort`,a),this.#b.delete(i),queueMicrotask(()=>{this.#D()})}},t),this.emit(`add`),this.#N()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#v?(this.#v=!1,this.#I(),this):this}pause(){this.#v=!0}clear(){this.#m=new this.#h,this.#j(),this.#V(),this.emit(`empty`),this.#g===0&&(this.#M(),this.emit(`idle`)),this.emit(`next`)}async onEmpty(){this.#m.size!==0&&await this.#L(`empty`)}async onSizeLessThan(e){this.#m.size<e||await this.#L(`next`,()=>this.#m.size<e)}async onIdle(){this.#g===0&&this.#m.size===0||await this.#L(`idle`)}async onPendingZero(){this.#g!==0&&await this.#L(`pendingZero`)}async onRateLimit(){this.isRateLimited||await this.#L(`rateLimit`)}async onRateLimitCleared(){this.isRateLimited&&await this.#L(`rateLimitCleared`)}onError(){return new Promise((e,t)=>{let n=e=>{this.off(`error`,n),t(e)};this.on(`error`,n)})}async#L(e,t){return new Promise(n=>{let r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)})}get size(){return this.#m.size}sizeBy(e){return this.#m.filter(e).length}get pending(){return this.#g}get isPaused(){return this.#v}#R(){this.#t||(this.on(`add`,()=>{this.#m.size>0&&this.#z()}),this.on(`next`,()=>{this.#z()}))}#z(){this.#t||this.#a||(this.#a=!0,queueMicrotask(()=>{this.#a=!1,this.#V()}))}#B(){this.#t||(this.#C(),this.#z())}#V(){let e=this.#i;if(this.#t||this.#m.size===0){e&&(this.#i=!1,this.emit(`rateLimitCleared`));return}let t;if(this.#d){let e=Date.now();this.#x(e),t=this.#w()}else t=this.#n;let n=t>=this.#r;n!==e&&(this.#i=n,this.emit(n?`rateLimit`:`rateLimitCleared`))}get isRateLimited(){return this.#i}get isSaturated(){return this.#g===this.#_&&this.#m.size>0||this.isRateLimited&&this.#m.size>0}get runningTasks(){return[...this.#b.values()].map(e=>({...e}))}},qt={decodeValues:!0,map:!1,silent:!1,split:`auto`};function Jt(e){return typeof e!=`string`||e in{}}function Yt(){return Object.create(null)}function Xt(e){return typeof e==`string`&&!!e.trim()}function Zt(e,t){var n=e.split(`;`).filter(Xt),r=Qt(n.shift()),i=r.name,a=r.value;if(t=t?Object.assign({},qt,t):qt,Jt(i))return null;try{a=t.decodeValues?decodeURIComponent(a):a}catch(e){console.error(`set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.`,e)}var o=Yt();return o.name=i,o.value=a,n.forEach(function(e){var t=e.split(`=`),n=t.shift().trimLeft().toLowerCase();if(!Jt(n)){var r=t.join(`=`);if(n===`expires`)o.expires=new Date(r);else if(n===`max-age`){var i=parseInt(r,10);Number.isNaN(i)||(o.maxAge=i)}else n===`secure`?o.secure=!0:n===`httponly`?o.httpOnly=!0:n===`samesite`?o.sameSite=r:n===`partitioned`?o.partitioned=!0:n&&(o[n]=r)}}),o}function Qt(e){var t=``,n=``,r=e.split(`=`);return r.length>1?(t=r.shift(),n=r.join(`=`)):n=e,{name:t,value:n}}function $t(e,t){if(t=t?Object.assign({},qt,t):qt,!e)return t.map?Yt():[];if(e.headers)if(typeof e.headers.getSetCookie==`function`)e=e.headers.getSetCookie();else if(e.headers[`set-cookie`])e=e.headers[`set-cookie`];else{var n=e.headers[Object.keys(e.headers).find(function(e){return e.toLowerCase()===`set-cookie`})];!n&&e.headers.cookie&&!t.silent&&console.warn(`Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.`),e=n}var r=t.split,i=Array.isArray(e);if(r===`auto`&&(r=!i),i||(e=[e]),e=e.filter(Xt),r&&(e=e.map(en).flat()),t.map){var a=Yt();return e.reduce(function(e,n){var r=Zt(n,t);return r&&!Jt(r.name)&&(e[r.name]=r),e},a)}else return e.map(function(e){return Zt(e,t)}).filter(Boolean)}function en(e){if(Array.isArray(e))return e;if(typeof e!=`string`)return[];var t=[],n=0,r,i,a,o,s;function c(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function l(){return i=e.charAt(n),i!==`=`&&i!==`;`&&i!==`,`}for(;n<e.length;){for(r=n,s=!1;c();)if(i=e.charAt(n),i===`,`){for(a=n,n+=1,c(),o=n;n<e.length&&l();)n+=1;n<e.length&&e.charAt(n)===`=`?(s=!0,n=o,t.push(e.substring(r,a)),r=n):n=a+1}else n+=1;(!s||n>=e.length)&&t.push(e.substring(r,e.length))}return t}$t.parseSetCookie=$t,$t.parse=$t,$t.parseString=Zt,$t.splitCookiesString=en;var tn=n(((e,t)=>{let n=Symbol(`arg flag`);var r=class e extends Error{constructor(t,n){super(t),this.name=`ArgError`,this.code=n,Object.setPrototypeOf(this,e.prototype)}};function i(e,{argv:t=process.argv.slice(2),permissive:i=!1,stopAtPositional:a=!1}={}){if(!e)throw new r(`argument specification object is required`,`ARG_CONFIG_NO_SPEC`);let o={_:[]},s={},c={};for(let t of Object.keys(e)){if(!t)throw new r(`argument key cannot be an empty string`,`ARG_CONFIG_EMPTY_KEY`);if(t[0]!==`-`)throw new r(`argument key must start with '-' but found: '${t}'`,`ARG_CONFIG_NONOPT_KEY`);if(t.length===1)throw new r(`argument key must have a name; singular '-' keys are not allowed: ${t}`,`ARG_CONFIG_NONAME_KEY`);if(typeof e[t]==`string`){s[t]=e[t];continue}let i=e[t],a=!1;if(Array.isArray(i)&&i.length===1&&typeof i[0]==`function`){let[e]=i;i=(t,n,r=[])=>(r.push(e(t,n,r[r.length-1])),r),a=e===Boolean||e[n]===!0}else if(typeof i==`function`)a=i===Boolean||i[n]===!0;else throw new r(`type missing or not a function or valid array type: ${t}`,`ARG_CONFIG_VAD_TYPE`);if(t[1]!==`-`&&t.length>2)throw new r(`short argument keys (with a single hyphen) must have only one character: ${t}`,`ARG_CONFIG_SHORTOPT_TOOLONG`);c[t]=[i,a]}for(let e=0,n=t.length;e<n;e++){let n=t[e];if(a&&o._.length>0){o._=o._.concat(t.slice(e));break}if(n===`--`){o._=o._.concat(t.slice(e+1));break}if(n.length>1&&n[0]===`-`){let a=n[1]===`-`||n.length===2?[n]:n.slice(1).split(``).map(e=>`-${e}`);for(let n=0;n<a.length;n++){let l=a[n],[u,d]=l[1]===`-`?l.split(/=(.*)/,2):[l,void 0],f=u;for(;f in s;)f=s[f];if(!(f in c))if(i){o._.push(l);continue}else throw new r(`unknown or unexpected option: ${u}`,`ARG_UNKNOWN_OPTION`);let[p,m]=c[f];if(!m&&n+1<a.length)throw new r(`option requires argument (but was followed by another short argument): ${u}`,`ARG_MISSING_REQUIRED_SHORTARG`);if(m)o[f]=p(!0,f,o[f]);else if(d===void 0){if(t.length<e+2||t[e+1].length>1&&t[e+1][0]===`-`&&!(t[e+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(p===Number||typeof BigInt<`u`&&p===BigInt)))throw new r(`option requires argument: ${u}${u===f?``:` (alias for ${f})`}`,`ARG_MISSING_REQUIRED_LONGARG`);o[f]=p(t[e+1],f,o[f]),++e}else o[f]=p(d,f,o[f])}}else o._.push(n)}return o}i.flag=e=>(e[n]=!0,e),i.COUNT=i.flag((e,t,n)=>(n||0)+1),i.ArgError=r,t.exports=i})),nn=t(tn(),1);const rn=e=>({name:e,hidden:!0}),an=e=>e?Array.isArray(e)?e:[e]:[],on=e=>typeof e==`string`?e:e.name,sn=(e,t)=>[e,...an(t.alias).map(on)],cn=e=>typeof e==`string`,ln=(e,t)=>{let n={},r={};for(let[t,i]of Object.entries(e)){n[t]=i.type,r[t]=i.default;for(let e of an(i.alias))n[on(e)]=t}try{let e=(0,nn.default)(n,t);for(let[t,n]of Object.entries(r))fe(e[t])&&(e[t]=n);return e}catch(e){throw e instanceof nn.default.ArgError&&(e=new G(e.message)),e instanceof U?e:new Ft(e)}};var G=class extends U{isBug=H.NO;usageHint;usageHintText;constructor(e,t){super(e),this.usageHint=t?.usageHint??!0}attachUsageHint(e){this.usageHintText||=e}render(){let e=`${h.redBright(a.cross)} `+this.message;return this.usageHintText&&(e+=`
|
|
238
|
+
|
|
239
|
+
`+this.usageHintText),e}};const un=e=>e===Boolean?`boolean`:e===String?`string`:e===Number?`number`:e===nn.default.COUNT?`count`:`string`,dn=e=>{let t=[];for(let[n,r]of Object.entries(e)){let e={name:n,aliases:an(r.alias).filter(cn).map(on),type:un(r.type),description:r.description??``};r.details!==void 0&&(e.details=r.details),r.valueName!==void 0&&(e.valueName=r.valueName),r.hidden!==void 0&&(e.hidden=r.hidden),r.brief!==void 0&&(e.brief=r.brief),typeof r.complete==`function`&&(e.hasCompleter=!0),t.push(e)}return t},fn=e=>{let t=[];for(let n of e){t.push(n.name);for(let e of n.aliases)t.push(e)}return t},pn=(e,t,n,r)=>(n=n?b(n).trim():``,JSON.stringify({level:e,name:t,msg:n,fields:mn(r)})+`
|
|
240
|
+
`),mn=e=>{let t={};for(let[n,r]of Object.entries(e))t[n]=hn(r);return t},hn=e=>(e instanceof Set&&(e=Array.from(e)),Array.isArray(e)?e.map(hn):(e instanceof Map&&(e=Object.fromEntries(e.entries())),P(e)?mn(e):E(e)?b(e).trim():e));var gn=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}));const _n=c({application:g(),environment:g(),environments:ae(g(),c({filesVersion:g()}))}),vn=e=>{let t=xe(e);return t&&`session=${encodeURIComponent(t)};`},yn=e=>{let t=bn(e);return Le(t,`missing auth headers`),t},bn=e=>{let t=vn(e);if(t)return e.log.trace(`using cookie as auth header`,{},{cookie:t}),{cookie:t};let n=ye(e);if(n)return e.log.trace(`using token as auth header`,{},{token:n}),{"x-platform-access-token":n}},xn=e=>e instanceof ie&&e.response.statusCode===401,Sn=(e,t)=>{if(xn(t)){e.log.warn(`swallowing unauthorized error`,{error:t});return}throw t};function K(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function q(e){return K(e)===`object`}function Cn(e){return Array.isArray(e)&&e.length>0&&e.every(e=>`message`in e)}function wn(e,t){return e.length<124?e:t}var J=(e=>(e[e.InternalServerError=4500]=`InternalServerError`,e[e.InternalClientError=4005]=`InternalClientError`,e[e.BadRequest=4400]=`BadRequest`,e[e.BadResponse=4004]=`BadResponse`,e[e.Unauthorized=4401]=`Unauthorized`,e[e.Forbidden=4403]=`Forbidden`,e[e.SubprotocolNotAcceptable=4406]=`SubprotocolNotAcceptable`,e[e.ConnectionInitialisationTimeout=4408]=`ConnectionInitialisationTimeout`,e[e.ConnectionAcknowledgementTimeout=4504]=`ConnectionAcknowledgementTimeout`,e[e.SubscriberAlreadyExists=4409]=`SubscriberAlreadyExists`,e[e.TooManyInitialisationRequests=4429]=`TooManyInitialisationRequests`,e))(J||{}),Y=(e=>(e.ConnectionInit=`connection_init`,e.ConnectionAck=`connection_ack`,e.Ping=`ping`,e.Pong=`pong`,e.Subscribe=`subscribe`,e.Next=`next`,e.Error=`error`,e.Complete=`complete`,e))(Y||{});function Tn(e){if(!q(e))throw Error(`Message is expected to be an object, but got ${K(e)}`);if(!e.type)throw Error(`Message is missing the 'type' property`);if(typeof e.type!=`string`)throw Error(`Message is expects the 'type' property to be a string, but got ${K(e.type)}`);switch(e.type){case`connection_init`:case`connection_ack`:case`ping`:case`pong`:if(e.payload!=null&&!q(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case`subscribe`:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${K(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!q(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${K(e.payload)}`);if(typeof e.payload.query!=`string`)throw Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${K(e.payload.query)}`);if(e.payload.variables!=null&&!q(e.payload.variables))throw Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${K(e.payload.variables)}`);if(e.payload.operationName!=null&&K(e.payload.operationName)!==`string`)throw Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${K(e.payload.operationName)}`);if(e.payload.extensions!=null&&!q(e.payload.extensions))throw Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${K(e.payload.extensions)}`);break;case`next`:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${K(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!q(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${K(e.payload)}`);break;case`error`:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${K(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!Cn(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case`complete`:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${K(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw Error(`Invalid message 'type' property "${e.type}"`)}return e}function En(e,t){return Tn(typeof e==`string`?JSON.parse(e,t):e)}function Dn(e,t){return Tn(e),JSON.stringify(e,t)}function On(e){let{url:t,connectionParams:n,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:a=0,keepAlive:o=0,disablePong:s,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(e){let t=2**e;await new Promise(e=>setTimeout(e,t*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:d=An,on:f,webSocketImpl:p,generateID:m=function(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==`x`?t:t&3|8).toString(16)})},jsonMessageReplacer:h,jsonMessageReviver:g}=e,_;if(p){if(!Mn(p))throw Error(`Invalid WebSocket implementation provided`);_=p}else typeof WebSocket<`u`?_=WebSocket:typeof global<`u`?_=global.WebSocket||global.MozWebSocket:typeof window<`u`&&(_=window.WebSocket||window.MozWebSocket);if(!_)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let v=_,y=(()=>{let e=(()=>{let e={};return{on(t,n){return e[t]=n,()=>{delete e[t]}},emit(t){`id`in t&&e[t.id]?.(t)}}})(),t={connecting:f?.connecting?[f.connecting]:[],opened:f?.opened?[f.opened]:[],connected:f?.connected?[f.connected]:[],ping:f?.ping?[f.ping]:[],pong:f?.pong?[f.pong]:[],message:f?.message?[e.emit,f.message]:[e.emit],closed:f?.closed?[f.closed]:[],error:f?.error?[f.error]:[]};return{onMessage:e.on,on(e,n){let r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e,...n){for(let r of[...t[e]])r(...n)}}})();function b(e){let t=[y.on(`error`,n=>{t.forEach(e=>e()),e(n)}),y.on(`closed`,n=>{t.forEach(e=>e()),e(n)})]}let x,S=0,C,w=!1,T=0,E=!1;async function D(){clearTimeout(C);let[e,r]=await(x??=new Promise((e,r)=>(async()=>{if(w){if(await u(T),!S)return x=void 0,r({code:1e3,reason:`All Subscriptions Gone`});T++}y.emit(`connecting`,w);let i=new v(typeof t==`function`?await t():t,`graphql-transport-ws`),a,l;function d(){isFinite(o)&&o>0&&(clearTimeout(l),l=setTimeout(()=>{i.readyState===v.OPEN&&(i.send(Dn({type:Y.Ping})),y.emit(`ping`,!1,void 0))},o))}b(e=>{x=void 0,clearTimeout(a),clearTimeout(l),r(e),e instanceof kn&&(i.close(4499,`Terminated`),i.onerror=null,i.onclose=null)}),i.onerror=e=>y.emit(`error`,e),i.onclose=e=>y.emit(`closed`,e),i.onopen=async()=>{try{y.emit(`opened`,i);let e=typeof n==`function`?await n():n;if(i.readyState!==v.OPEN)return;i.send(Dn(e?{type:Y.ConnectionInit,payload:e}:{type:Y.ConnectionInit},h)),isFinite(c)&&c>0&&(a=setTimeout(()=>{i.close(J.ConnectionAcknowledgementTimeout,`Connection acknowledgement timeout`)},c)),d()}catch(e){y.emit(`error`,e),i.close(J.InternalClientError,wn(e instanceof Error?e.message:String(e),`Internal client error`))}};let f=!1;i.onmessage=({data:t})=>{try{let n=En(t,g);if(y.emit(`message`,n),n.type===`ping`||n.type===`pong`){y.emit(n.type,!0,n.payload),n.type===`pong`?d():s||(i.send(Dn(n.payload?{type:Y.Pong,payload:n.payload}:{type:Y.Pong})),y.emit(`pong`,!1,n.payload));return}if(f)return;if(n.type!==Y.ConnectionAck)throw Error(`First message cannot be of type ${n.type}`);clearTimeout(a),f=!0,y.emit(`connected`,i,n.payload,w),w=!1,T=0,e([i,new Promise((e,t)=>b(t))])}catch(e){i.onmessage=null,y.emit(`error`,e),i.close(J.BadResponse,wn(e instanceof Error?e.message:String(e),`Bad response`))}}})()));e.readyState===v.CLOSING&&await r;let i=()=>{},l=new Promise(e=>i=e);return[e,i,Promise.race([l.then(()=>{if(!S){let t=()=>e.close(1e3,`Normal Closure`);isFinite(a)&&a>0?C=setTimeout(()=>{e.readyState===v.OPEN&&t()},a):t()}}),r])]}function ee(e){if(An(e)&&(jn(e.code)||[J.InternalServerError,J.InternalClientError,J.BadRequest,J.BadResponse,J.Unauthorized,J.SubprotocolNotAcceptable,J.SubscriberAlreadyExists,J.TooManyInitialisationRequests].includes(e.code)))throw e;if(E)return!1;if(An(e)&&e.code===1e3)return S>0;if(!l||T>=l||!d(e))throw e;return w=!0}r||(async()=>{for(S++;;)try{let[,,e]=await D();await e}catch(e){try{if(!ee(e))return}catch(e){return i?.(e)}}})();function O(e,t){let n=m(e),r=!1,i=!1,a=()=>{S--,r=!0};return(async()=>{for(S++;;)try{let[o,s,c]=await D();if(r)return s();let l=y.onMessage(n,e=>{switch(e.type){case Y.Next:t.next(e.payload);return;case Y.Error:i=!0,r=!0,t.error(e.payload),a();return;case Y.Complete:r=!0,a();return}});o.send(Dn({id:n,type:Y.Subscribe,payload:e},h)),a=()=>{!r&&o.readyState===v.OPEN&&o.send(Dn({id:n,type:Y.Complete},h)),S--,r=!0,s()},await c.finally(l);return}catch(e){if(!ee(e))return}})().then(()=>{i||t.complete()}).catch(e=>{t.error(e)}),()=>{r||a()}}return{on:y.on,subscribe:O,iterate(e){let t=[],n={done:!1,error:null,resolve:()=>{}},r=O(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),i=async function*(){for(;;){for(t.length||await new Promise(e=>n.resolve=e);t.length;)yield t.shift();if(n.error)throw n.error;if(n.done)return}}();return i.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),i.return=async()=>(r(),{done:!0,value:void 0}),i},async dispose(){if(E=!0,x){let[e]=await x;e.close(1e3,`Normal Closure`)}},terminate(){x&&y.emit(`closed`,new kn)}}}var kn=class extends Error{name=`TerminatedCloseEvent`;message=`4499: Terminated`;code=4499;reason=`Terminated`;wasClean=!1};function An(e){return q(e)&&`code`in e&&`reason`in e}function jn(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function Mn(e){return typeof e==`function`&&`constructor`in e&&`CLOSED`in e&&`CLOSING`in e&&`CONNECTING`in e&&`OPEN`in e}var X=n(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),Nn=n(((t,n)=>{let{EMPTY_BUFFER:r}=X(),i=Buffer[Symbol.species];function a(e,t){if(e.length===0)return r;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let r=e[t];n.set(r,a),a+=r.length}return a<t?new i(n.buffer,n.byteOffset,a):n}function o(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function s(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function c(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function l(e){if(l.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),l.readOnly=!1),t}if(n.exports={concat:a,mask:o,toArrayBuffer:c,toBuffer:l,unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{let t=e(`bufferutil`);n.exports.mask=function(e,n,r,i,a){a<48?o(e,n,r,i,a):t.mask(e,n,r,i,a)},n.exports.unmask=function(e,n){e.length<32?s(e,n):t.unmask(e,n)}}catch{}})),Pn=n(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),Fn=n(((t,n)=>{let r=e(`zlib`),i=Nn(),a=Pn(),{kStatusCode:o}=X(),s=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),l=Symbol(`permessage-deflate`),u=Symbol(`total-length`),d=Symbol(`callback`),f=Symbol(`buffers`),p=Symbol(`error`),m;n.exports=class{constructor(e,t,n){this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,m||=new a(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){m.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){m.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,n){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[l]=this,this._inflate[u]=0,this._inflate[f]=[],this._inflate.on(`error`,_),this._inflate.on(`data`,g)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{let e=this._inflate[p];if(e){this._inflate.close(),this._inflate=null,n(e);return}let r=i.concat(this._inflate[f],this._inflate[u]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[u]=0,this._inflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),n(null,r)})}_compress(e,t,n){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[u]=0,this._deflate[f]=[],this._deflate.on(`data`,h)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=i.concat(this._deflate[f],this._deflate[u]);t&&(e=new s(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[u]=0,this._deflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}};function h(e){this[f].push(e),this[u]+=e.length}function g(e){if(this[u]+=e.length,this[l]._maxPayload<1||this[u]<=this[l]._maxPayload){this[f].push(e);return}this[p]=RangeError(`Max payload size exceeded`),this[p].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[p][o]=1009,this.removeListener(`data`,g),this.reset()}function _(e){if(this[l]._inflate=null,this[p]){this[d](this[p]);return}e[o]=1007,this[d](e)}})),In=n(((t,n)=>{let{isUtf8:r}=e(`buffer`),{hasBlob:i}=X(),a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function o(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function s(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function c(e){return i&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(n.exports={isBlob:c,isValidStatusCode:o,isValidUTF8:s,tokenChars:a},r)n.exports.isValidUTF8=function(e){return e.length<24?s(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=e(`utf-8-validate`);n.exports.isValidUTF8=function(e){return e.length<32?s(e):t(e)}}catch{}})),Ln=n(((t,n)=>{let{Writable:r}=e(`stream`),i=Fn(),{BINARY_TYPES:a,EMPTY_BUFFER:o,kStatusCode:s,kWebSocket:c}=X(),{concat:l,toArrayBuffer:u,unmask:d}=Nn(),{isValidStatusCode:f,isValidUTF8:p}=In(),m=Buffer[Symbol.species];n.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||a[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new m(t.buffer,t.byteOffset+e,t.length-e),new m(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new m(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[i.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&d(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?l(n,t):this._binaryType===`arraybuffer`?u(l(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=l(n,t);if(!this._skipUTF8Validation&&!p(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,o),this.end();else{let n=e.readUInt16BE(0);if(!f(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new m(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!p(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[s]=r,a}}})),Rn=n(((t,n)=>{let{Duplex:r}=e(`stream`),{randomFillSync:i}=e(`crypto`),a=Fn(),{EMPTY_BUFFER:o,kWebSocket:s,NOOP:c}=X(),{isBlob:l,isValidStatusCode:u}=In(),{mask:d,toBuffer:f}=Nn(),p=Symbol(`kByteLength`),m=Buffer.alloc(4),h=8*1024,g,_=h;n.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[s]=void 0}static frame(e,t){let n,r=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||m,t.generateMask?t.generateMask(n):(_===h&&(g===void 0&&(g=Buffer.alloc(h)),i(g,0,h),_=0),n[0]=g[_++],n[1]=g[_++],n[2]=g[_++],n[3]=g[_++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[p]!==void 0?s=t[p]:(e=Buffer.from(e),s=e.length):(s=e.length,r=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(r?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:r?(d(e,n,l,a,s),[l]):(d(e,n,e,0,s),[l,e])}close(t,n,r,i){let a;if(t===void 0)a=o;else if(typeof t!=`number`||!u(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)a=Buffer.allocUnsafe(2),a.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);a=Buffer.allocUnsafe(2+e),a.writeUInt16BE(t,0),typeof n==`string`?a.write(n,2):a.set(n,2)}let s={[p]:a.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(a,s),i):this.enqueue([this.dispatch,a,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):l(t)?(i=t.size,a=!1):(t=f(t),i=t.length,a=f.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[p]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};l(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):l(t)?(i=t.size,a=!1):(t=f(t),i=t.length,a=f.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[p]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};l(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[a.extensionName],i=t.binary?2:1,o=t.compress,s,c;typeof e==`string`?(s=Buffer.byteLength(e),c=!1):l(e)?(s=e.size,c=!1):(e=f(e),s=e.length,c=f.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,i=0),t.fin&&(this._firstFragment=!0);let u={[p]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};l(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[p],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(v,this,e,i);return}this._bufferedBytes-=r[p];let a=f(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(y,this,e,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let o=this._extensions[a.extensionName];this._bufferedBytes+=r[p],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){v(this,Error(`The socket was closed while data was being compressed`),i);return}this._bufferedBytes-=r[p],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),i),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][p],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][p],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function v(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function y(e,t,n){v(e,t,n),e.onerror(t)}})),zn=n(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=X(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),Bn=n(((e,t)=>{let{tokenChars:n}=In();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),Vn=n(((t,n)=>{let r=e(`events`),i=e(`https`),a=e(`http`),o=e(`net`),s=e(`tls`),{randomBytes:c,createHash:l}=e(`crypto`),{Duplex:u,Readable:d}=e(`stream`),{URL:f}=e(`url`),p=Fn(),m=Ln(),h=Rn(),{isBlob:g}=In(),{BINARY_TYPES:_,CLOSE_TIMEOUT:v,EMPTY_BUFFER:y,GUID:b,kForOnEventAttribute:x,kListener:S,kStatusCode:C,kWebSocket:w,NOOP:T}=X(),{EventTarget:{addEventListener:E,removeEventListener:D}}=zn(),{format:ee,parse:O}=Bn(),{toBuffer:te}=Nn(),ne=Symbol(`kAborted`),re=[8,13],k=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ie=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var A=class e extends r{constructor(t,n,r){super(),this._binaryType=_[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=y,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),ae(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){_.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new m({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new h(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[w]=this,a[w]=this,t[w]=this,i.on(`conclude`,le),i.on(`drain`,ue),i.on(`error`,N),i.on(`message`,fe),i.on(`ping`,pe),i.on(`pong`,me),a.onerror=ge,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,_e),t.on(`data`,F),t.on(`end`,ve),t.on(`error`,ye),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[p.extensionName]&&this._extensions[p.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){M(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),P(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ce(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||y,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ce(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||y,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ce(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[p.extensionName]||(i.compress=!1),this._sender.send(t||y,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){M(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(A,`CONNECTING`,{enumerable:!0,value:k.indexOf(`CONNECTING`)}),Object.defineProperty(A.prototype,`CONNECTING`,{enumerable:!0,value:k.indexOf(`CONNECTING`)}),Object.defineProperty(A,`OPEN`,{enumerable:!0,value:k.indexOf(`OPEN`)}),Object.defineProperty(A.prototype,`OPEN`,{enumerable:!0,value:k.indexOf(`OPEN`)}),Object.defineProperty(A,`CLOSING`,{enumerable:!0,value:k.indexOf(`CLOSING`)}),Object.defineProperty(A.prototype,`CLOSING`,{enumerable:!0,value:k.indexOf(`CLOSING`)}),Object.defineProperty(A,`CLOSED`,{enumerable:!0,value:k.indexOf(`CLOSED`)}),Object.defineProperty(A.prototype,`CLOSED`,{enumerable:!0,value:k.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(A.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(A.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[x])return t[S];return null},set(t){for(let t of this.listeners(e))if(t[x]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[x]:!0})}})}),A.prototype.addEventListener=E,A.prototype.removeEventListener=D,n.exports=A;function ae(e,t,n,r){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:v,protocolVersion:re[1],maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!re.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${re.join(`, `)})`);let s;if(t instanceof f)s=t;else try{s=new f(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}s.protocol===`http:`?s.protocol=`ws:`:s.protocol===`https:`&&(s.protocol=`wss:`),e._url=s.href;let u=s.protocol===`wss:`,d=s.protocol===`ws+unix:`,m;if(s.protocol!==`ws:`&&!u&&!d?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:d&&!s.pathname?m=`The URL's pathname is empty`:s.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;j(e,t);return}let h=u?443:80,g=c(16).toString(`base64`),_=u?i.request:a.request,y=new Set,x;if(o.createConnection=o.createConnection||(u?se:oe),o.defaultPort=o.defaultPort||h,o.port=s.port||h,o.host=s.hostname.startsWith(`[`)?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new p(o.perMessageDeflate===!0?{}:o.perMessageDeflate,!1,o.maxPayload),o.headers[`Sec-WebSocket-Extensions`]=ee({[p.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!ie.test(e)||y.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);y.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),d){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=d,e._originalSecure=u,e._originalHostOrSocketPath=d?o.socketPath:s.host;let t=r&&r.headers;if(r={...r,headers:{}},t)for(let[e,n]of Object.entries(t))r.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=d?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=_(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=_(o);o.timeout&&S.on(`timeout`,()=>{M(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[ne]||(S=e._req=null,j(e,t))}),S.on(`response`,i=>{let a=i.headers.location,s=i.statusCode;if(a&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){M(e,S,`Maximum redirects exceeded`);return}S.abort();let i;try{i=new f(a,t)}catch{j(e,SyntaxError(`Invalid URL: ${a}`));return}ae(e,i,n,r)}else e.emit(`unexpected-response`,S,i)||M(e,S,`Unexpected server response: ${i.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==A.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){M(e,n,`Invalid Upgrade header`);return}let a=l(`sha1`).update(g+b).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){M(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],c;if(s===void 0?y.size&&(c=`Server sent no subprotocol`):y.size?y.has(s)||(c=`Server sent an invalid subprotocol`):c=`Server sent a subprotocol but none was requested`,c){M(e,n,c);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){M(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=O(u)}catch{M(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==p.extensionName){M(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[p.extensionName])}catch{M(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[p.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function j(e,t){e._readyState=A.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function oe(e){return e.path=e.socketPath,o.connect(e)}function se(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=o.isIP(e.host)?``:e.host),s.connect(e)}function M(e,t,n){e._readyState=A.CLOSING;let r=Error(n);Error.captureStackTrace(r,M),t.setHeader?(t[ne]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(j,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function ce(e,t,n){if(t){let n=g(t)?t.size:te(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${k[e.readyState]})`);process.nextTick(n,t)}}function le(e,t){let n=this[w];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[w]!==void 0&&(n._socket.removeListener(`data`,F),process.nextTick(he,n._socket),e===1005?n.close():n.close(e,t))}function ue(){let e=this[w];e.isPaused||e._socket.resume()}function N(e){let t=this[w];t._socket[w]!==void 0&&(t._socket.removeListener(`data`,F),process.nextTick(he,t._socket),t.close(e[C])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function de(){this[w].emitClose()}function fe(e,t){this[w].emit(`message`,e,t)}function pe(e){let t=this[w];t._autoPong&&t.pong(e,!this._isServer,T),t.emit(`ping`,e)}function me(e){this[w].emit(`pong`,e)}function he(e){e.resume()}function ge(e){let t=this[w];t.readyState!==A.CLOSED&&(t.readyState===A.OPEN&&(t._readyState=A.CLOSING,P(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function P(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function _e(){let e=this[w];if(this.removeListener(`close`,_e),this.removeListener(`data`,F),this.removeListener(`end`,ve),e._readyState=A.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[w]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,de),e._receiver.on(`finish`,de))}function F(e){this[w]._receiver.write(e)||this.pause()}function ve(){let e=this[w];e._readyState=A.CLOSING,e._receiver.end(),this.end()}function ye(){let e=this[w];this.removeListener(`error`,ye),this.on(`error`,T),e&&(e._readyState=A.CLOSING,this.destroy())}})),Hn=n(((t,n)=>{Vn();let{Duplex:r}=e(`stream`);function i(e){e.emit(`close`)}function a(){!this.destroyed&&this._writableState.finished&&this.destroy()}function o(e){this.removeListener(`error`,o),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function s(e,t){let n=!0,s=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,s);return}let a=!1;e.once(`error`,function(e){a=!0,r(e)}),e.once(`close`,function(){a||r(t),process.nextTick(i,s)}),n&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,a),s.on(`error`,o),s}n.exports=s})),Un=n(((e,t)=>{let{tokenChars:n}=In();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),Wn=n(((t,n)=>{let r=e(`events`),i=e(`http`),{Duplex:a}=e(`stream`),{createHash:o}=e(`crypto`),s=Bn(),c=Fn(),l=Un(),u=Vn(),{CLOSE_TIMEOUT:d,GUID:f,kWebSocket:p}=X(),m=/^[+/0-9A-Za-z]{22}==$/;n.exports=class extends r{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:u,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=i.createServer((e,t)=>{let n=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=h(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(g,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(g,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{g(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,_);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,o=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){y(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){y(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!m.test(i)){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(o!==13&&o!==8){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){v(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=l.parse(u)}catch{y(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],p={};if(this.options.perMessageDeflate&&f!==void 0){let n=new c(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let e=s.parse(f);e[c.extensionName]&&(n.accept(e[c.extensionName]),p[c.extensionName]=n)}catch{y(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${o===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return v(t,o||401,s,c);this.completeUpgrade(p,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return v(t,401)}this.completeUpgrade(p,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,a,l){if(!i.readable||!i.writable)return i.destroy();if(i[p])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return v(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${o(`sha1`).update(t+f).digest(`base64`)}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[c.extensionName]){let t=e[c.extensionName].params,n=s.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
|
|
241
|
+
`).join(`\r
|
|
242
|
+
`)),i.removeListener(`error`,_),d.setSocket(i,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on(`close`,()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(g,this)})),l(d,r)}};function h(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function g(e){e._state=2,e.emit(`close`)}function _(){this.destroy()}function v(e,t,n,r){n||=i.STATUS_CODES[t],r={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...r},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r\n`+Object.keys(r).map(e=>`${e}: ${r[e]}`).join(`\r
|
|
243
|
+
`)+`\r
|
|
244
|
+
\r
|
|
245
|
+
`+n)}function y(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,y),e.emit(`wsClientError`,r,n,t)}else v(n,r,i,a)}}));Hn(),Ln(),Rn();var Gn=t(Vn(),1),Kn=t(Wn(),1),qn=Gn.default,Jn=class extends Error{constructor(e){super(`${e} is locked`)}};const Yn={old:new Set,young:new Set};let Xn;const Zn=()=>{let e=Te.networkInterfaces(),t=new Set([void 0,`0.0.0.0`]);for(let n of Object.values(e))for(let e of n)t.add(e.address);return t},Qn=e=>new Promise((t,n)=>{let r=je.createServer();r.unref(),r.on(`error`,n),r.listen(e,()=>{let{port:e}=r.address();r.close(()=>{t(e)})})}),$n=async(e,t)=>{if(e.host||e.port===0)return Qn(e);for(let n of t)try{await Qn({port:e.port,host:n})}catch(e){if(![`EADDRNOTAVAIL`,`EINVAL`].includes(e.code))throw e}return e.port},er=function*(e){e&&(yield*e),yield 0};async function tr(e){let t,n=new Set;if(e&&(e.port&&(t=typeof e.port==`number`?[e.port]:e.port),e.exclude)){let t=e.exclude;if(typeof t[Symbol.iterator]!=`function`)throw TypeError("The `exclude` option must be an iterable.");for(let e of t){if(typeof e!=`number`)throw TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(e))throw TypeError(`Number ${e} in the exclude option is not a safe integer and can't be used`)}n=new Set(t)}Xn===void 0&&(Xn=setTimeout(()=>{Xn=void 0,Yn.old=Yn.young,Yn.young=new Set},15e3),Xn.unref&&Xn.unref());let r=Zn();for(let i of er(t))try{if(n.has(i))continue;let t=await $n({...e,port:i},r);for(;Yn.old.has(t)||Yn.young.has(t);){if(i!==0)throw new Jn(i);t=await $n({...e,port:i},r)}return Yn.young.add(t),t}catch(e){if(![`EADDRINUSE`,`EACCES`].includes(e.code)&&!(e instanceof Jn))throw e}throw Error(`No available ports found`)}const nr=De(Ce.execFile),rr=()=>`${I.env.SYSTEMROOT||I.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,Z=async(e,t={})=>{let{powerShellPath:n,...r}=t,i=Z.encodeCommand(e);return nr(n??rr(),[...Z.argumentsPrefix,i],{encoding:`utf8`,...r})};Z.argumentsPrefix=[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`],Z.encodeCommand=e=>Pe.from(e,`utf16le`).toString(`base64`),Z.escapeArgument=e=>`'${String(e).replaceAll(`'`,`''`)}'`;const ir=De(Ce.execFile),ar=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await Re.access(n,ze.F_OK),r=!0}catch{}if(!r)return e;let i=await Re.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),or=l?async()=>`${await ar()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:rr;let sr;const cr=async()=>(sr??=(async()=>{try{let e=await or();return await Re.access(e,ze.X_OK),!0}catch{return!1}})(),sr),lr=async()=>{let e=await or(),{stdout:t}=await Z(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{powerShellPath:e});return t.trim()},ur=async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await ir(`wslpath`,[`-aw`,e],{encoding:`utf8`});return t.trim()}catch{return e}};function dr(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}const fr=De(we);async function pr(){if(I.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await fr(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}const mr=De(we);async function hr(e,{humanReadableOutput:t=!0,signal:n}={}){if(I.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await mr(`osascript`,[`-e`,e,r],i);return a.trim()}async function gr(e){return hr(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const _r=De(we),vr={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},yr=new Map(Object.entries(vr));var br=class extends Error{};async function xr(e=_r){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new br(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=vr[r];if(!i)throw new br(`Unknown browser ID: ${r}`);return i}const Sr=De(we),Cr=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function wr(){if(I.platform===`darwin`){let e=await pr();return{name:await gr(e),id:e}}if(I.platform===`linux`){let{stdout:e}=await Sr(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:Cr(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(I.platform===`win32`)return xr();throw Error(`Only macOS, Linux, and Windows are supported`)}const Tr=!!(I.env.SSH_CONNECTION||I.env.SSH_CLIENT||I.env.SSH_TTY),Er=Symbol(`fallbackAttempt`),Dr=import.meta.url?Ee.dirname(Ie(import.meta.url)):``,Or=Ee.join(Dr,`xdg-open`),{platform:kr,arch:Ar}=I,jr=async(e,t)=>{if(e.length===0)return;let n=[];for(let r of e)try{return await t(r)}catch(e){n.push(e)}throw AggregateError(n,`Failed to open in all supported apps`)},Mr=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[Er]===!0;if(delete e[Er],Array.isArray(e.app))return jr(e.app,t=>Mr({...e,app:t,[Er]:!0}));let{name:n,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(n))return jr(n,t=>Mr({...e,app:{name:t,arguments:r},[Er]:!0}));if(n===`browser`||n===`browserPrivate`){let t={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`,"com.apple.safari":`safari`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a;if(l){let e=await lr();a=yr.get(e)??{}}else a=await wr();if(a.id in t){let o=t[a.id.toLowerCase()];if(n===`browserPrivate`){if(o===`safari`)throw Error(`Safari doesn't support opening in private mode via command line`);r.push(i[o])}return Mr({...e,app:{name:Ir[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let i,a=[],o={},s=!1;if(l&&!pe()&&!Tr&&!n&&(s=await cr()),kr===`darwin`)i=`open`,e.wait&&a.push(`--wait-apps`),e.background&&a.push(`--background`),e.newInstance&&a.push(`--new`),n&&a.push(`-a`,n);else if(kr===`win32`||s){i=await or(),a.push(...Z.argumentsPrefix),l||(o.windowsVerbatimArguments=!0),l&&e.target&&(e.target=await ur(e.target));let t=[`$ProgressPreference = 'SilentlyContinue';`,`Start`];e.wait&&t.push(`-Wait`),n?(t.push(Z.escapeArgument(n)),e.target&&r.push(e.target)):e.target&&t.push(Z.escapeArgument(e.target)),r.length>0&&(r=r.map(e=>Z.escapeArgument(e)),t.push(`-ArgumentList`,r.join(`,`))),e.target=Z.encodeCommand(t.join(` `)),e.wait||(o.stdio=`ignore`)}else{if(n)i=n;else{let e=!Dr||Dr===`/`,t=!1;try{await Re.access(Or,ze.X_OK),t=!0}catch{}i=I.versions.electron??(kr===`android`||e||!t)?`xdg-open`:Or}r.length>0&&a.push(...r),e.wait||(o.stdio=`ignore`,o.detached=!0)}kr===`darwin`&&r.length>0&&a.push(`--args`,...r),e.target&&a.push(e.target);let c=Ce.spawn(i,a,o);return e.wait?new Promise((t,n)=>{c.once(`error`,n),c.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r!==0){n(Error(`Exited with code ${r}`));return}t(c)})}):t?new Promise((e,t)=>{c.once(`error`,t),c.once(`spawn`,()=>{c.once(`close`,n=>{if(c.off(`error`,t),n!==0){t(Error(`Exited with code ${n}`));return}c.unref(),e(c)})})}):(c.unref(),new Promise((e,t)=>{c.once(`error`,t),c.once(`spawn`,()=>{c.off(`error`,t),e(c)})}))},Nr=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return Mr({...t,target:e})};function Pr(e){if(typeof e==`string`||Array.isArray(e))return e;let{[Ar]:t}=e;if(!t)throw Error(`${Ar} is not supported`);return t}function Fr({[kr]:e},{wsl:t}={}){if(t&&l)return Pr(t);if(!e)throw Error(`${kr} is not supported`);return Pr(e)}const Ir={browser:`browser`,browserPrivate:`browserPrivate`};dr(Ir,`chrome`,()=>Fr({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`,`chromium-browser`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),dr(Ir,`brave`,()=>Fr({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),dr(Ir,`firefox`,()=>Fr({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),dr(Ir,`edge`,()=>Fr({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),dr(Ir,`safari`,()=>Fr({darwin:`Safari`}));var Lr=le({name:`login`,description:`Log in to Gadget`,details:f`
|
|
246
|
+
Opens the Gadget login page in your default browser. After you authenticate,
|
|
247
|
+
the session token is stored locally so subsequent commands can use it. If the
|
|
248
|
+
browser cannot be opened, a URL is printed for you to visit manually.
|
|
249
|
+
`,examples:[`ggt login`],run:async e=>{let t;try{let n=await tr(),r=new Promise((r,i)=>{t=Oe.createServer(async(t,a)=>{let o=t.url?new URL(t.url,`http://localhost:${n}`).searchParams.get(`session`):null;if(!o){a.writeHead(404),a.end();return}let s=new URL(`https://${O.domains.services}/auth/cli`);try{be(e,o);let t=await Ci(e);Le(t,`missing user after successful login`),t.name?D({ensureEmptyLineAbove:!0,content:f`Hello, ${t.name} ${N.subdued(`(${t.email})`)}`}):D({ensureEmptyLineAbove:!0,content:`Hello, ${t.email}`}),s.searchParams.set(`success`,`true`),r()}catch(t){be(e,void 0),s.searchParams.set(`success`,`false`),i(t)}finally{a.writeHead(303,{Location:s.toString()}),a.end()}}),e.log.info(`starting login server`,{port:n}),t.listen(n)}),i=new URL(`https://${O.domains.services}/auth/login`);i.searchParams.set(`returnTo`,`https://${O.domains.services}/auth/cli/callback?port=${n}`);try{e.log.info(`opening browser`,{url:i.toString()}),await Nr(i.toString()),D({ensureEmptyLineAbove:!0,content:f`
|
|
250
|
+
We've opened Gadget's login page using your default browser.
|
|
251
|
+
|
|
252
|
+
Please log in and then return to this terminal.
|
|
253
|
+
`})}catch(t){e.log.error(`failed to open browser`,{error:t}),D({ensureEmptyLineAbove:!0,content:f`
|
|
254
|
+
Please open the following URL in your browser and log in:
|
|
255
|
+
|
|
256
|
+
${N.hint(i.toString())}
|
|
257
|
+
|
|
258
|
+
Once logged in, return to this terminal.
|
|
259
|
+
`})}await r}finally{t?.close()}}});const Rr=e=>Object.keys(e).filter(e=>e.startsWith(`--allow-`)),zr=e=>Rr(e).length===0?e:{...e,...Br},Br={"--allow":{type:String,description:`Enable allow flags (comma-separated)`,valueName:`flag,...`,brief:!1},"--allow-all":{type:Boolean,description:`Enable all --allow-* flags`,brief:!1}},Vr=(e,t)=>{if(t.length===0)return{cleanedArgv:e,allowAll:!1,allowValues:[]};let n=[],r=[],i=!1,a=0,o=!1;for(;a<e.length;){let t=e[a]??``;if(t===`--`){o=!0,n.push(t),a++;continue}if(!o){if(t===`--allow-all`){i=!0,a++;continue}if(t===`--allow`){if(a+1>=e.length)throw new G(`Flag "--allow" requires a value`);r.push(e[a+1]),a+=2;continue}if(t.startsWith(`--allow=`)){r.push(t.slice(8)),a++;continue}}n.push(t),a++}return{cleanedArgv:n,allowAll:i,allowValues:r}},Hr=(e,t,n)=>{let r=new Map;for(let e of t)r.set(e.slice(8),e);let i=[],a=n.allowAll;for(let e of n.allowValues)for(let t of e.split(`,`)){let e=t.trim();e!==``&&(e===`all`?a=!0:i.push(e))}if(a)for(let n of t)e[n]=!0;for(let t of i){let n=r.get(t);if(!n){let e=[...r.keys()],n=e.length>0?ve(t,e):void 0,i=[`Unknown allow flag "${t}".`];throw n&&i.push(`Did you mean "${n}"?`),i.push(`Available: ${e.join(`, `)}`),new G(i.join(` `))}e[n]=!0}},Ur=` `.repeat(8),Wr=(e,t,n)=>{let r=n-t.length,i=[];for(let[n,a]of e.split(/\n\n+/).entries()){if(n>0&&i.push(``),!a.trim())continue;let e=a.replace(/\n/g,` `).split(/\s+/).filter(Boolean),o=``;for(let n of e)o?n.length>r?(i.push(`${t}${o}`),o=``,i.push(`${t}${n}`)):o.length+1+n.length<=r?o+=` ${n}`:(i.push(`${t}${o}`),o=n):(o=n,n.length>r&&(i.push(`${t}${o}`),o=``));o&&i.push(`${t}${o}`)}return i},Gr=(e,t)=>t?e?`${e.endsWith(`.`)?e:`${e}.`} ${t}`:t:e,Kr=e=>e.type===`boolean`||e.type===`count`?``:` <${e.valueName??`value`}>`,qr=e=>{let t=e=>/^-[^-]/.test(e),n=[...e.aliases.filter(t),...t(e.name)?[e.name]:[]].sort((e,t)=>e.length-t.length),r=[...e.name.startsWith(`--`)?[e.name]:[],...e.aliases.filter(e=>e.startsWith(`--`))],i=t=>t.startsWith(e.name)||e.name.startsWith(t),a=r.filter(i).sort((e,t)=>e.length-t.length),o=r.filter(e=>!i(e)).sort((e,t)=>e.length-t.length),s=[...n,...a,...o];return`${n.length>0?``:` `}${s.join(`, `)}`},Jr=e=>`${qr(e)}${Kr(e)}`,Yr=(e,t=24,n=2)=>{let r=qr(e),i=Kr(e),a=r.length+i.length,o=` `.repeat(Math.max(0,t-a)),s=N.identifier.bold(r),c=i?N.placeholder(i):``;return`${` `.repeat(n)}${s}${c}${o}${e.description}`},Xr=e=>[...e].sort((e,t)=>{let n=e.aliases.find(e=>/^-[^-]/.test(e))??(e.name.length===2&&e.name.startsWith(`-`)?e.name:null),r=t.aliases.find(e=>/^-[^-]/.test(e))??(t.name.length===2&&t.name.startsWith(`-`)?t.name:null);return n&&!r?-1:!n&&r?1:n&&r?n.localeCompare(r):e.name.localeCompare(t.name)}),Zr=(e,t)=>{e.push(t.description),e.push(``);let n=t.details;if(n){for(let t of n.split(`
|
|
260
|
+
`))e.push(t||``);e.push(``)}},Qr=e=>e.placeholder?e.placeholder:e.required?`<${e.name}>`:`[${e.name}]`,$r=(e,t,n,r)=>{let i=n.subcommands&&Object.keys(n.subcommands).length>0?` <command>`:``,a=n.positionals?.map(e=>Qr(e)).join(` `),o=a?` ${a}`:``,s=r.length>0?` [flags]`:``;e.push(N.header(`USAGE`)),e.push(` ggt ${t}${i}${o}${s}`)},ei=(e,t,n)=>{let r=t.positionals;if(!(!r||r.length===0))if(e.push(``),e.push(N.header(`ARGUMENTS`)),n.expanded)for(let[t,n]of r.entries()){t>0&&e.push(``),e.push(` ${N.identifier.bold(n.name)}`);let r=Gr(n.description??``,n.details);for(let t of Wr(r,Ur,80))e.push(t)}else{let t=Math.max(12,...r.map(e=>e.name.length+4));for(let n of r){let r=` `.repeat(Math.max(0,t-n.name.length));e.push(` ${N.identifier.bold(n.name)}${r}${n.description??``}`)}}},ti=(e,t)=>{if(!t.subcommands)return;let n=Object.entries(t.subcommands);if(n.length===0)return;let r=Math.max(...n.map(([e])=>e.length))+4;e.push(``),e.push(N.header(`COMMANDS`));for(let[t,i]of n){let n=` `.repeat(Math.max(0,r-t.length));e.push(` ${N.identifier.bold(t)}${n}${i.description}`)}},ni=(e,t,n)=>{if(t.length!==0)if(e.push(``),e.push(N.header(n.heading??`FLAGS`)),n.expanded)for(let[n,r]of t.entries()){n>0&&e.push(``);let t=qr(r),i=Kr(r),a=`${N.identifier.bold(t)}${i?N.placeholder(i):``}`;e.push(` ${a}`);let o=Gr(r.description,r.details);for(let t of Wr(o,Ur,80))e.push(t)}else{let n=Math.max(24,...t.map(e=>Jr(e).length+2));for(let r of t)e.push(Yr(r,n))}},ri=(e,t)=>{if(!(!t.examples||t.examples.length===0)){e.push(``),e.push(N.header(`EXAMPLES`));for(let n of t.examples)e.push(` ${N.prompt(`$`)} ${n}`)}},ii=(e,t,n)=>{let r=[],i=n?.flags??(t.flags?dn(t.flags):[]);Zr(r,{description:t.description});let a=Xr(i.filter(e=>!e.hidden)),o=a.filter(e=>e.brief!==!1);return $r(r,e,t,a),ei(r,t,{expanded:!1}),ti(r,t),ni(r,o,{expanded:!1}),ri(r,t),n?.footer!==!1&&ai(t,a)&&(r.push(``),r.push(`Run ${N.hint(`ggt ${e} --help`)} for more information.`)),r.join(`
|
|
261
|
+
`)},ai=(e,t)=>{let n=t??(e.flags?dn(e.flags):[]);return!!(e.details||e.sections?.length||n.some(e=>e.details)||n.some(e=>e.brief===!1)||e.positionals?.some(e=>e.details))},oi=(e,t)=>{let n=Xr((t.flags?dn(t.flags):[]).filter(e=>!e.hidden)),r=[];return $r(r,e,t,n),r.push(``),r.push(`Run ${N.hint(`ggt ${e} -h`)} for more information.`),r.join(`
|
|
262
|
+
`)},si=(e,t)=>{let n=t.flags?dn(t.flags):[],r=Xr(n.filter(e=>!e.hidden));if(!ai(t,r))return ii(e,t,{footer:!1,flags:n});let i=r.filter(e=>e.brief!==!1),a=r.filter(e=>e.brief===!1),o=[];if(Zr(o,t),$r(o,e,t,r),ei(o,t,{expanded:!0}),ti(o,t),ni(o,i,{expanded:!0}),ni(o,a,{expanded:!0,heading:`ADDITIONAL FLAGS`}),ri(o,t),t.sections)for(let e of t.sections){o.push(``),o.push(N.header(e.title.toUpperCase()));for(let t of e.content.split(`
|
|
263
|
+
`))o.push(t?` ${t}`:``)}return o.join(`
|
|
264
|
+
`)},ci=async(e,t,...n)=>{t.subcommands?await mi(e,t,n):await pi(e,t,n)},li=(e,t,n)=>{D((n===`--help`?si:ii)(e,t)),process.exit(0)},ui=(e,t)=>{if(gi(e,`--help`,t))return`--help`;if(gi(e,`-h`,t))return`-h`},di=(e,t)=>{if(e){for(let[n,r]of e.entries())if(r.required&&n>=t.length)throw new G(`Missing required argument: ${r.name}`)}},fi=async(e,t,n)=>{try{await e()}catch(e){throw e instanceof G&&e.usageHint&&e.attachUsageHint(oi(t,n)),e}},pi=async(e,t,n)=>{let{flagsDef:r,allowFlags:i,helpMod:a}=yi(t.flags??{},t),o=ui(n,hi(r));o&&li(t.name,a,o),await fi(async()=>{let r=Vr(n,i),a=ln(t.flags??{},{argv:r.cleanedArgv,...t.parseOptions});Hr(a,i,r),di(t.positionals,a._),await t.run(e,a)},t.name,a)},mi=async(e,t,n)=>{let{subcommands:r}=t,{flagsDef:i,helpMod:a}=yi(t.flags??{},t),o=_i(n,hi(i)),s=o?[...n.slice(0,o.index),...n.slice(o.index+1)]:[...n],c=o?vi(o.token,r)??o.token:void 0,l=c!==void 0&&Object.prototype.hasOwnProperty.call(r,c)?r[c]:void 0,u=l?{...t.flags,...l.flags}:t.flags??{},{flagsDef:d,allowFlags:f,helpMod:p}=yi(u,l?{...l,flags:u}:t),m=ui(s,hi(d));if(m&&(l&&li(`${t.name} ${c}`,p,m),li(t.name,a,m)),!c)return li(t.name,a,`-h`);if(!l){let e=Object.keys(r),n=e.length>0?ve(c,e):void 0,i=[`Unknown subcommand ${c}`];throw n&&i.push(`Did you mean ${n}?`),i.push(oi(t.name,a)),new G(i.join(`
|
|
265
|
+
|
|
266
|
+
`),{usageHint:!1})}await fi(async()=>{let n=Vr(s,f),r=ln(u,{argv:n.cleanedArgv,...t.parseOptions});Hr(r,f,n),di(l.positionals,r._),await l.run(e,r)},`${t.name} ${c}`,p)},hi=e=>{let t=new Set;for(let[n,r]of Object.entries(e))if(r.type!==Boolean&&r.type!==nn.default.COUNT){t.add(n);for(let e of an(r.alias))t.add(on(e))}return t},gi=(e,t,n)=>{let r=0;for(;r<e.length;){let i=e[r];if(i===`--`)return!1;if(i===t)return!0;i.startsWith(`-`)&&!i.includes(`=`)&&n.has(i)&&r++,r++}return!1},_i=(e,t)=>{let n=0;for(;n<e.length;){let r=e[n];if(r===`--`)return;if(!r.startsWith(`-`))return{token:r,index:n};!r.includes(`=`)&&t.has(r)&&n++,n++}},vi=(e,t)=>{if(Object.prototype.hasOwnProperty.call(t,e))return e;for(let[n,r]of Object.entries(t))if(r.aliases?.includes(e))return n},yi=(e,t)=>{let n=Rr(e);if(n.length===0)return{flagsDef:e,allowFlags:n,helpMod:t};let r={...e,...Br};return{flagsDef:r,allowFlags:n,helpMod:{...t,flags:r}}},bi=async e=>{let t;if(t=typeof e==`string`?{content:e}:e,t=v(t,{ensureEmptyLineAbove:!0,ensureNewLine:!0,exitWhenNo:!0}),!se.isInteractive){let e=t.whenNotInteractive??(()=>{D(t),D({ensureEmptyLineAbove:!0,content:`Aborting because ggt is not running in an interactive terminal.`}),I.exit(1)});return Promise.resolve(e()).then(()=>!1)}return new Promise(e=>{let n=new xi(t);n.on(`submit`,t=>e(!!t)),n.on(`exit`,()=>I.exit(0)),n.on(`abort`,()=>I.exit(1))})};var xi=class extends o{value=void 0;defaultValue=!1;options;constructor(e){super(),this.options=v(e,{exitWhenNo:!0,ensureEmptyLineAbove:!0}),this.render()}reset(){this.value=this.defaultValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=!1,this.done=this.aborted=!0,this.fire(),this.render(!1),this.close(),this.options.exitWhenNo&&I.exit(0)}submit(){this.value=this.value??!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.close(),this.options.exitWhenNo&&!this.value&&I.exit(0)}_(e,t){if(e.toLowerCase()===`y`){this.value=!0,this.submit();return}if(e.toLowerCase()===`n`){this.value=!1,this.submit();return}this.bell()}render(e=this.value){if(super.render(),this.done){se.persistPrompt(u({...this.options,content:`${this.options.content} ${e?h.bold.greenBright(`Yes.`):h.bold.redBright(`No.`)}`}));return}se.updatePrompt(u({...this.options,content:`${this.options.content} ${this.defaultValue?h.blueBright(`[Y/n] `):h.blueBright(`[y/N] `)}`}))}};const Si=c({id:_([g(),oe()]).transform(Number),name:g().nullish(),email:g()}),Ci=async e=>{let t=bn(e);if(t)try{let n=await _a({context:{ctx:e},url:`https://${O.domains.services}/auth/api/current-user`,headers:t,responseType:`json`,resolveBodyOnly:!0}),r=Si.parse(n);return e.log.info(`loaded user`,{user:{id:r.id}},{user:r}),jt(r),r}catch(t){Sn(e,t);return}},wi=async(e,t)=>{let n=await Ci(e);return n||(e.log.info(`prompting user to log in`),D({ensureEmptyLineAbove:!0,content:`You must be logged in to use "ggt ${t}".`}),await bi({ensureEmptyLineAbove:!0,content:`Would you like to log in?`}),await ci(e,Lr),n=await Ci(e),Le(n,`missing user after successful login`),n)},Q={CONNECTED:0,DISCONNECTED:1,RECONNECTING:2};var Ti=class{status=Q.CONNECTED;ctx;environment;endpoint;_graphqlWsClient;_sessionUpdateInterval;constructor(e,t,n){this.ctx=e.child({name:`client`}),this.environment=t,this.endpoint=n,this._graphqlWsClient=On({url:`wss://${t.application.slug}.${O.domains.app}/edit/api/graphql-ws`,keepAlive:(0,ht.default)(`10s`),shouldRetry:()=>!0,connectionParams:{environment:t.name},webSocketImpl:class extends qn{constructor(t,n,r){let i=de(r?.headers)?Object.fromEntries(r.headers.map(e=>e.split(`: `,2))):r?.headers;super(t,n,{signal:e.signal,...r,headers:{...i,"user-agent":O.versionFull,...yn(e)}})}},on:{opened:()=>{this.ctx.log.trace(`opened`)},ping:e=>{this.ctx.log.trace(`ping`,{received:e})},pong:e=>{this.ctx.log.trace(`pong`,{received:e})},connecting:()=>{switch(this.status){case Q.DISCONNECTED:this.status=Q.RECONNECTING,this.ctx.log.info(`reconnecting`);break;case Q.RECONNECTING:this.ctx.log.info(`retrying`);break;default:this.ctx.log.debug(`connecting`);break}},connected:()=>{this.status===Q.RECONNECTING?this.ctx.log.info(`reconnected`):this.ctx.log.debug(`connected`),setImmediate(()=>this.status=Q.CONNECTED)},closed:()=>{this.status=Q.DISCONNECTED,this.ctx.log.debug(`disconnected`)},error:e=>{this.status===Q.RECONNECTING?this.ctx.log.error(`failed to reconnect`,{error:e}):this.ctx.log.error(`connection error`,{error:e})}}})}subscribe(e,{subscription:t,variables:n,onData:r,onError:i,onComplete:a=he,retry:o}){let s=o?.maxAttempts??10,c=0,l,u=n,d=e,f={query:t,variables:x(u)},p=()=>this._graphqlWsClient.on(`connected`,()=>{this.status===Q.RECONNECTING&&(f.variables=x(u),d.log.info(`re-subscribing to graphql subscription`)),this._sessionUpdateInterval&&clearInterval(this._sessionUpdateInterval),this._sessionUpdateInterval=setInterval(()=>{Ci(this.ctx).catch(e=>this.ctx.abort(e)).then(e=>{e||this.ctx.abort(new zt(void 0))})},(0,ht.default)(`30m`)).unref(),this.ctx.done.finally(()=>{this._sessionUpdateInterval&&clearInterval(this._sessionUpdateInterval)})}),m=p(),h=new Kt({concurrency:1}),g=(e,t)=>{if(!o||!Dt(e.cause)||c>=s)return!1;l||c++;let n=bt(c);return d.log.warn(`subscription error, retrying...`,{retryCount:c,maxAttempts:s,delayMs:Math.round(n),error:t}),o.onRetry?.(c,e),l&&clearTimeout(l),l=setTimeout(()=>{l=void 0,C.resubscribe()},n),!0},_=async e=>{if(e.errors){let n=new W(t,e.errors);if(g(n,e.errors))return;S(),await i(n);return}if(!e.data){S(),await i(new W(t,`Subscription response did not contain data`));return}c>0&&(l&&=(clearTimeout(l),void 0),d.log.info(`subscription recovered`,{retriesNeeded:c}),c=0),await r(e.data)},v=async e=>{g(e,e.cause)||(S(),await i(e))},y=async()=>{l&&=(clearTimeout(l),void 0),await a()},b=this._graphqlWsClient.subscribe(f,{next:e=>void h.add(()=>_(e)).catch(e=>v(new W(t,e))),error:e=>void h.add(()=>v(new W(t,e))),complete:()=>void h.add(()=>y()).catch(e=>v(new W(t,e)))}),S=()=>{l&&=(clearTimeout(l),void 0),d.log.trace(`unsubscribing from graphql subscription`),m(),h.clear(),b()},C={unsubscribe:()=>{l&&=(clearTimeout(l),void 0),S()},resubscribe:e=>{l&&=(clearTimeout(l),void 0),m(),h.clear(),b(),e!==void 0&&(u=e),f.variables=x(u),d.log.info(`re-subscribing to graphql subscription`),m=p(),b=this._graphqlWsClient.subscribe(f,{next:e=>void h.add(()=>_(e)).catch(e=>v(new W(t,e))),error:e=>void h.add(()=>v(new W(t,e))),complete:()=>void h.add(()=>y()).catch(e=>v(new W(t,e)))})}};return C}async execute(e,t){let n=this.environment.application.slug;this.environment.type!==`production`&&(n+=`--${this.environment.name}`);try{let r=await _a({context:{ctx:e},method:`POST`,url:`https://${n}.${O.domains.app}${this.endpoint}`,headers:{...yn(e),"x-gadget-environment":this.environment.name},json:{query:t.operation,variables:x(t.variables)},responseType:`json`,resolveBodyOnly:!0,throwHttpErrors:!1,...t.http});if(!P(r)||!(`data`in r)&&!(`errors`in r))throw e.log.error(`received invalid graphql response`,{error:r}),r;return r}catch(e){throw new W(t.operation,e)}}async dispose(){await this._graphqlWsClient.dispose()}},Ei=class{ctx;#e;constructor(e,t){this.ctx=e.child({name:`api`}),this.#e=new Ti(this.ctx,t,`/api/graphql`)}async query({query:e,variables:t,...n}){let r=Ye(e),i=this.ctx.child({name:`api`,fields:{edit:{query:r}},devFields:{edit:{query:r,variables:x(t)}}});i.log.info(`executing graphql query`);let a=await this.#e.execute(i,{operation:e,variables:t,...n,http:{retry:{methods:[`POST`]},...n.http}});if(a.errors)throw new W(e,a.errors);if(!a.data)throw new W(e,`Query response did not contain data`);return a.data}async dispose(){await this.#e.dispose()}};const Di=f(`
|
|
267
|
+
query GadgetMetaModels {
|
|
268
|
+
gadgetMeta {
|
|
269
|
+
models {
|
|
270
|
+
apiIdentifier
|
|
271
|
+
namespace
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
`),Oi=f(`
|
|
276
|
+
query GadgetMetaGlobalActions {
|
|
277
|
+
gadgetMeta {
|
|
278
|
+
globalActions {
|
|
279
|
+
apiIdentifier
|
|
280
|
+
namespace
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
`),ki=(e,t)=>{let n=/^(https:\/\/)?(?<slug>[\w-]+?)(--development)?(\..*)?$/.exec(e)?.groups?.slug;if(n)return n;throw new G(f`
|
|
285
|
+
${t} must be the application's ${N.identifier(`slug`)} or ${N.identifier(`URL`)}
|
|
286
|
+
|
|
287
|
+
${N.header(`EXAMPLES:`)}
|
|
288
|
+
${t} my-app
|
|
289
|
+
${t} my-app.gadget.app
|
|
290
|
+
${t} https://my-app.gadget.app
|
|
291
|
+
${t} https://my-app.gadget.app/edit
|
|
292
|
+
${t} https://my-app--development.gadget.app/edit
|
|
293
|
+
`)};var Ai=t(w(),1);const ji=Object.freeze({Development:`development`,Production:`production`,Test:`test`}),Mi=c({id:_([g(),oe(),C()]).transform(e=>BigInt(e)),name:g().transform(e=>e.toLowerCase()),type:d(ji),nodeVersion:g().optional()}),Ni=c({id:_([g(),oe(),C()]).transform(e=>BigInt(e)),slug:g(),primaryDomain:g(),environments:me(Mi),team:c({id:_([g(),oe(),C()]).transform(e=>BigInt(e)),name:g()})});c({apiIdentifier:g(),namespace:y(me(g())).optional()}),c({apiIdentifier:g(),namespace:y(me(g())).optional()});const Pi={type:ki,alias:[`-a`,`--app`],description:`Gadget app to use`,valueName:`app`,complete:async(e,t,n)=>{try{return F((await Ii(e)).map(e=>e.slug),t)}catch{return[]}},details:f`
|
|
294
|
+
The app slug is the subdomain portion of your app URL (e.g., my-app from
|
|
295
|
+
my-app.gadget.app). Can be omitted when .gadget/sync.json already records
|
|
296
|
+
the app.
|
|
297
|
+
`},Fi={type:String,alias:[`-e`,`--env`],description:`Environment to use`,valueName:`env`,complete:async(e,t,n)=>{try{let r=await Ii(e);if(r.length===0)return[];let i=Bi(r,n);return i||=await Vi(r),F(i?i.environments.map(e=>e.name):_e(r.flatMap(e=>e.environments.map(e=>e.name))),t)}catch{return[]}},details:f`
|
|
298
|
+
Defaults to the development environment. Production is read-only for most
|
|
299
|
+
commands.
|
|
300
|
+
`},Ii=async e=>{let t=bn(e);if(!t)return[];let n=await _a({context:{ctx:e},url:`https://${O.domains.services}/auth/api/apps`,headers:{...t},responseType:`json`,resolveBodyOnly:!0});return me(Ni).parse(n)},Li=e=>{let t=new Map;for(let n of e){let e=n.team.name,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},Ri=async(e,t)=>{if(!bn(e))return[];let{gadgetMeta:n}=await new Ei(e,t).query({query:Di});return n.models},zi=new Set(sn(`--application`,Pi)),Bi=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(zi.has(r)){let r=t[++n];if(r){let t=e.find(e=>e.slug===r);if(t)return t}continue}let i=r.indexOf(`=`);if(i>0&&zi.has(r.slice(0,i))){let t=r.slice(i+1);if(t){let n=e.find(e=>e.slug===t);if(n)return n}}}},Vi=async e=>{try{let t=await m(`.gadget/sync.json`);if(!t)return;let n=await Ai.default.readFile(t,`utf8`),r=_n.parse(JSON.parse(n));return e.find(e=>e.slug===r.application)}catch{}},Hi=async(e,t)=>{if(!bn(e))return[];let{gadgetMeta:n}=await new Ei(e,t).query({query:Oi});return n.globalActions};var Ui=n(((e,t)=>{var n=12,r=0,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function a(e){var t=e.indexOf(`%`);if(t===-1)return e;for(var a=e.length,o=``,c=0,l=0,u=t,d=n;t>-1&&t<a;){var f=s(e[t+1],4)|s(e[t+2],0),p=i[f];if(d=i[256+d+p],l=l<<6|f&i[364+p],d===n)o+=e.slice(c,u),o+=l<=65535?String.fromCharCode(l):String.fromCharCode(55232+(l>>10),56320+(l&1023)),l=0,c=t+3,t=u=e.indexOf(`%`,c);else if(d===r)return null;else{if(t+=3,t<a&&e.charCodeAt(t)===37)continue;return null}}return o+e.slice(c)}var o={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function s(e,t){var n=o[e];return n===void 0?255:n<<t}t.exports=a})),Wi=n(((e,t)=>{let n=Ui(),r=/\+/g,i=function(){};i.prototype=Object.create(null);function a(e){let t=new i;if(typeof e!=`string`)return t;let a=e.length,o=``,s=``,c=-1,l=-1,u=!1,d=!1,f=!1,p=!1,m=!1,h=0;for(let i=0;i<a+1;i++)if(h=i===a?38:e.charCodeAt(i),h===38){if(m=l>c,m||(l=i),o=e.slice(c+1,l),m||o.length>0){f&&(o=o.replace(r,` `)),u&&(o=n(o)||o),m&&(s=e.slice(l+1,i),p&&(s=s.replace(r,` `)),d&&(s=n(s)||s));let a=t[o];a===void 0?t[o]=s:a.pop?a.push(s):t[o]=[a,s]}s=``,c=i,l=i,u=!1,d=!1,f=!1,p=!1}else h===61?l<=c?l=i:d=!0:h===43?l>c?p=!0:f=!0:h===37&&(l>c?d=!0:u=!0);return t}t.exports=a})),Gi=n(((e,t)=>{let n=Array.from({length:256},(e,t)=>`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase()),r=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0]);function i(e){let t=e.length;if(t===0)return``;let i=``,a=0,o=0;outer:for(;o<t;o++){let s=e.charCodeAt(o);for(;s<128;){if(r[s]!==1&&(a<o&&(i+=e.slice(a,o)),a=o+1,i+=n[s]),++o===t)break outer;s=e.charCodeAt(o)}if(a<o&&(i+=e.slice(a,o)),s<2048){a=o+1,i+=n[192|s>>6]+n[128|s&63];continue}if(s<55296||s>=57344){a=o+1,i+=n[224|s>>12]+n[128|s>>6&63]+n[128|s&63];continue}if(++o,o>=t)throw Error(`URI malformed`);let c=e.charCodeAt(o)&1023;a=o+1,s=65536+((s&1023)<<10|c),i+=n[240|s>>18]+n[128|s>>12&63]+n[128|s>>6&63]+n[128|s&63]}return a===0?e:a<t?i+e.slice(a):i}t.exports={encodeString:i}})),Ki=n(((e,t)=>{let{encodeString:n}=Gi();function r(e){let t=typeof e;return t===`string`?n(e):t===`bigint`?e.toString():t===`boolean`?e?`true`:`false`:t===`number`&&Number.isFinite(e)?e<1e21?``+e:n(``+e):``}function i(e){let t=``;if(typeof e!=`object`||!e)return t;let i=Object.keys(e),a=i.length,o=0;for(let s=0;s<a;s++){let a=i[s],c=e[a],l=n(a)+`=`;if(s&&(t+=`&`),Array.isArray(c)){o=c.length;for(let e=0;e<o;e++)e&&(t+=`&`),t+=l,t+=r(c[e])}else t+=l,t+=r(c)}return t}t.exports=i})),qi=t(n(((e,t)=>{let n=Wi(),r=Ki(),i={parse:n,stringify:r};t.exports=i,t.exports.default=i,t.exports.parse=n,t.exports.stringify=r}))(),1);const Ji=e=>{let t=qi.default.stringify(e);return t?`?${t}`:``};var Yi=t(gn(),1);const Xi=(e,t,n,r,i,a)=>`${na(i)} ${ra(e)} ${ia(t)}:${aa(n)}${ta(r,{indent:2,timestamp:i,environment:a})}${Zi}`,Zi=`
|
|
301
|
+
`,Qi=(e,t)=>{let n=e===`error`?N.error:N.subdued,r=[];r.push(`
|
|
302
|
+
`);for(let e=0;e<t;e++)r.push(` `);return r.push(n(e)),r.push(n(`:`)),r.join(``)},$=(e,t,n)=>{if(!e)return``;let r=e.split(`
|
|
303
|
+
`);if(r.length===0)return``;let i=[],a=r.shift();Le(!fe(a),`first line is nil`),i.push(t(a));for(let e of r)if(e){i.push(`
|
|
304
|
+
`);for(let e=0;e<n;e++)i.push(` `);i.push(t(e))}return i.join(``)},$i=(e,t)=>{let n=``;return t&&(n=Ji(t)),`https://${e.application.primaryDomain}/edit/${e.name}/logs${n}`},ea=e=>e?`{environment_id="${e.id.toString()}"} | json | level=~"info|warn|error"`:`{environment_id=~".+"} | json | level=~"info|warn|error"`,ta=(e,t)=>{let{indent:n,environment:r,timestamp:i}=t;if(Object.keys(e).length===0)return``;let o=[];`trace_id`in e&&(o.push(Qi(`trace_id`,n)),o.push(` `),r&&i&&B.isSupported?o.push(B(N.link(e.trace_id),$i(r,{timeRange:`${i.toISOString()} to now`,logql:`${ea(r)} | trace_id="${e.trace_id}"`}))):o.push(N.link(e.trace_id)));for(let[t,i]of Object.entries(e))if(t!==`trace_id`){if(o.push(Qi(t,n)),i instanceof Set&&(i=Array.from(i)),Array.isArray(i)){if(i.length===0){o.push($(` []`,N.subdued,n));continue}i=Object.fromEntries(i.entries())}if(i instanceof Map&&(i=Object.fromEntries(i)),P(i)){let e=Object.entries(i);if(e.length===0){o.push($(` {}`,N.subdued,n));continue}e.length>10&&O.logLevel>M.TRACE&&!r&&(i=Object.fromEntries([...e.slice(0,10),[a.ellipsis,`${e.length-10} more`]])),o.push(ta(i,{indent:n+2,environment:r}));continue}if(o.push(` `),r)o.push($(String(i),N.plain,n));else switch(typeof i){case`string`:o.push($(`'`+i.replaceAll(`
|
|
305
|
+
`,`
|
|
306
|
+
`+` `.repeat(n+t.length))+`'`,N.plain,n));break;case`number`:o.push($(String(i),N.number,n));break;case`bigint`:o.push($(String(i)+`n`,N.number,n));break;case`boolean`:o.push($(String(i),N.boolean,n));break;default:o.push($(String(i),N.plain,n));break}}return o.join(``)},na=e=>(e?(0,Yi.default)(e):(0,Yi.default)()).format(`hh:mm:ss`),ra=e=>{switch(e){case M.PRINT:return N.levelPrint(N.levelBadgeText(` PRINT `));case M.TRACE:return N.levelTrace(N.levelBadgeText(` TRACE `));case M.DEBUG:return N.levelDebug(N.levelBadgeText(` DEBUG `));case M.INFO:return N.levelInfo(N.levelBadgeText(` INFO `));case M.WARN:return N.levelWarn(N.levelBadgeText(` WARN `));case M.ERROR:return N.levelError(N.levelBadgeText(` ERROR `))}},ia=e=>N.logName(e),aa=e=>{if(e==null)return``;let t=typeof e==`string`?e:String(e);if(t===``)return``;let n=t.split(`
|
|
307
|
+
`);return n.length===1?` `+t:`
|
|
308
|
+
`+n.map(e=>` `+e).join(`
|
|
309
|
+
`)},oa={pretty:Xi,json:pn},sa={"--log-level":{type:e=>re(e,M.INFO),alias:[`-l`,rn(`-ll`)],default:M.INFO,description:`Minimum log level to display`,valueName:`level`,details:f`
|
|
310
|
+
One of: trace, debug, info, warn, error. Defaults to info. Use trace or
|
|
311
|
+
debug for verbose troubleshooting output.
|
|
312
|
+
`,complete:async(e,t)=>F(k,t)},"--my-logs":{type:Boolean,alias:`-m`,description:`Show only logs emitted by your code`,details:`Filters out built-in platform logs, showing only logs sourced from your own code.`}},ca={trace:M.TRACE,debug:M.DEBUG,info:M.INFO,warn:M.WARN,error:M.ERROR},la=e=>(t,n,r,i,a)=>{let o={...i};`error`in o&&(o.error=j(o.error)),`reason`in o&&(o.reason=j(o.reason));let s=oa[O.logFormat],c=ca[t.toLowerCase()]??M.INFO;se.writeStdout(s(c,n,r,o,a,e))},ua=({name:e,fields:t={},devFields:n={}})=>{let r=r=>(i,a,o)=>{let s=r>=O.logLevel,c=r>=M.INFO;if(!s&&!c)return;let l={...x(t),...a};if(S.developmentOrTestLike&&Object.assign(l,x(n),o),`error`in l&&(l.error=j(l.error)),`reason`in l&&(l.reason=j(l.reason)),s){let t=oa[O.logFormat];se.writeStderr(t(r,e,i,l))}c&&At({level:`log`,message:i,data:l})};return{trace:r(M.TRACE),debug:r(M.DEBUG),info:r(M.INFO),warn:r(M.WARN),error:r(M.ERROR)}},da=({name:e,fields:t,devFields:n})=>({...ua({name:e,fields:t,devFields:n}),child:({name:r,fields:i,devFields:a})=>da({name:r||e,fields:()=>({...x(t),...x(i)}),devFields:{...x(n),...x(a)}})}),fa=(e,t)=>Ne((0,ht.default)(e),void 0,t);var pa=class{resolution;rejection;pendingPromise;constructor(e){this.pendingPromise=e,e.then(e=>(this.resolution=e,e)).catch(e=>{this.rejection=e}).finally(()=>{delete this.pendingPromise})}async unwrap(){if(this.pendingPromise)return await this.pendingPromise;if(this.rejection)throw this.rejection;return this.resolution}},ma=class{[Symbol.toStringTag];resolve;reject;_promise;constructor(){this._promise=new pa(new Promise((e,t)=>{this.resolve=e,this.reject=t})),this[Symbol.toStringTag]=String(this._promise.pendingPromise)}then(e,t){return this._promise.unwrap().then(e,t)}catch(e){return this._promise.unwrap().catch(e)}finally(e){return this._promise.unwrap().finally(e)}},ha=class e extends AbortController{done=new ma;#e;#t=[];constructor({log:e}){super(),this.#e=e,this.abort=this.abort.bind(this),this.child=this.child.bind(this),this.onAbort=this.onAbort.bind(this),this.signal.addEventListener(`abort`,async()=>{let e;for(let t of this.#t.reverse())try{await t(this.signal.reason)}catch(t){e??=t,this.log.error(`error during abort`,{error:e})}e?this.done.reject(e):this.done.resolve()})}get log(){return this.#e}static init(t){return new e({log:da(t)})}child(t){let n=new e({log:this.log.child(t)});return this.onAbort(()=>{n.abort()}),n}onAbort(e){this.#t.push(e)}};const ga=e=>(Le(e.context?.ctx instanceof ha,f(`
|
|
313
|
+
ctx must be provided to http requests:
|
|
314
|
+
|
|
315
|
+
const response = await http({
|
|
316
|
+
context: { ctx },
|
|
317
|
+
...options,
|
|
318
|
+
});
|
|
319
|
+
`)),e.context.ctx),_a=p.extend({agent:{http:new ke({keepAlive:!0}),https:new Ae({keepAlive:!0,minVersion:`TLSv1.1`})},retry:{limit:10,methods:[...vt],statusCodes:[...yt],errorCodes:[...gt],maxRetryAfter:void 0,calculateDelay:({computedValue:e})=>e,backoffLimit:_t,noise:100},hooks:{beforeRequest:[e=>{let t=ga(e);e.signal=t.signal,e.headers[`user-agent`]=O.versionFull,t.log.debug(`http request`,{http:{request:{method:e.method,url:e.url?.toString()}}})}],beforeRetry:[(e,t)=>{ga(e.request?.options??e.options.context).log.warn(`http request failed, retrying...`,{http:{retryCount:t,error:j(e),request:e.request&&{method:e.request.options.method,url:e.request.options.url?.toString()},response:e.response&&{statusCode:e.response.statusCode,traceId:e.response.headers[`x-trace-id`],durationMs:e.response.timings.phases.total}}})}],afterResponse:[e=>{let t=ga(e.request.options);if(t.log.debug(`http response`,{http:{request:{method:e.request.options.method,url:e.request.options.url?.toString()},response:{statusCode:e.statusCode,traceId:e.headers[`x-trace-id`],durationMs:e.timings.phases.total}}}),e.statusCode===401&&be(t,void 0),e.headers[`set-cookie`]){let n=e.headers[`set-cookie`];(Array.isArray(n)?n:[n]).forEach(e=>{let n=Zt(e);n.name===`session`&&(n.domain===`gadget.dev`||n.domain===`ggt.dev`)&&be(t,n.value)})}return e}]}});export{ot as $,gn as A,zt as B,zr as C,Kn as D,Gn as E,rn as F,Ft as G,Lt as H,ln as I,Mt as J,Pt as K,an as L,on as M,dn as N,yn as O,fn as P,st as Q,tn as R,Wr as S,Nr as T,U,W as V,H as W,mt as X,gt as Y,it as Z,ci as _,la as a,dt as at,Kr as b,ji as c,et as ct,Ri as d,nt as dt,rt as et,Li as f,Ze as ft,bi as g,B as gt,wi as h,Ye as ht,sa as i,Xe as it,G as j,_n as k,Ii as l,Qe as lt,Ci as m,ct as mt,ha as n,lt as nt,Pi as o,tt as ot,Ti as p,ft as pt,Nt as q,fa as r,pt as rt,Fi as s,$e as st,_a as t,at as tt,Hi as u,ut,Jr as v,Lr as w,Yr as x,qr as y,Kt as z};
|
|
320
|
+
//# sourceMappingURL=http-CY3lPMkt.js.map
|