@liquidmetal-ai/raindrop 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +408 -73
  2. package/bin/cjs-shims.js +7 -0
  3. package/bin/run.js +20 -2
  4. package/bundle/chunk-5GH4FS6C.js +12148 -0
  5. package/bundle/chunk-6B4I2CKP.js +231 -0
  6. package/bundle/chunk-6UE75KX2.js +4481 -0
  7. package/bundle/chunk-AU3EGGJP.js +44 -0
  8. package/bundle/chunk-CDQRD3JA.js +75 -0
  9. package/bundle/chunk-CMCEP64V.js +380 -0
  10. package/bundle/chunk-CW5ZHVPX.js +292 -0
  11. package/bundle/chunk-G6NE675D.js +238720 -0
  12. package/bundle/chunk-GLIYVKQA.js +48 -0
  13. package/bundle/chunk-KXEV6E63.js +133 -0
  14. package/bundle/chunk-MCRKUPJY.js +4515 -0
  15. package/bundle/chunk-MGM2L2T3.js +805 -0
  16. package/bundle/chunk-MVQYQJHI.js +502 -0
  17. package/bundle/chunk-NG7CZTTE.js +147 -0
  18. package/bundle/chunk-PU4RCSXF.js +22452 -0
  19. package/bundle/chunk-VXAZKB3J.js +292 -0
  20. package/bundle/chunk-W2L3MYN6.js +4480 -0
  21. package/bundle/chunk-XYJACVNA.js +231 -0
  22. package/bundle/commands/annotation/get.js +153 -0
  23. package/bundle/commands/annotation/list.js +226 -0
  24. package/bundle/commands/annotation/put.js +177 -0
  25. package/bundle/commands/auth/list.js +75 -0
  26. package/bundle/commands/auth/login.js +1654 -0
  27. package/bundle/commands/auth/logout.js +27 -0
  28. package/bundle/commands/auth/select.js +53 -0
  29. package/bundle/commands/bucket/create-credential.js +173 -0
  30. package/bundle/commands/bucket/delete-credential.js +140 -0
  31. package/bundle/commands/bucket/get-credential.js +151 -0
  32. package/bundle/commands/bucket/list-credentials.js +148 -0
  33. package/bundle/commands/build/branch.js +126 -0
  34. package/bundle/commands/build/checkout.js +198 -0
  35. package/bundle/commands/build/clone.js +153 -0
  36. package/bundle/commands/build/delete.js +227 -0
  37. package/bundle/commands/build/deploy.js +160 -0
  38. package/bundle/commands/build/env/get.js +105 -0
  39. package/bundle/commands/build/env/set.js +115 -0
  40. package/bundle/commands/build/find.js +333 -0
  41. package/bundle/commands/build/generate.js +75 -0
  42. package/bundle/commands/build/init.js +76 -0
  43. package/bundle/commands/build/list.js +11 -0
  44. package/bundle/commands/build/sandbox.js +65 -0
  45. package/bundle/commands/build/start.js +84 -0
  46. package/bundle/commands/build/status.js +1839 -0
  47. package/bundle/commands/build/stop.js +84 -0
  48. package/bundle/commands/build/tools/check.js +32 -0
  49. package/bundle/commands/build/tools/fmt.js +49 -0
  50. package/bundle/commands/build/unsandbox.js +65 -0
  51. package/bundle/commands/build/upload.js +83 -0
  52. package/bundle/commands/build/validate.js +71 -0
  53. package/bundle/commands/build/workos/delete.js +86 -0
  54. package/bundle/commands/build/workos/env/attach.js +134 -0
  55. package/bundle/commands/build/workos/env/create.js +176 -0
  56. package/bundle/commands/build/workos/env/delete.js +84 -0
  57. package/bundle/commands/build/workos/env/detach.js +115 -0
  58. package/bundle/commands/build/workos/env/get.js +117 -0
  59. package/bundle/commands/build/workos/env/list.js +139 -0
  60. package/bundle/commands/build/workos/env/set.js +138 -0
  61. package/bundle/commands/build/workos/invite.js +91 -0
  62. package/bundle/commands/build/workos/setup.js +124 -0
  63. package/bundle/commands/build/workos/status.js +93 -0
  64. package/bundle/commands/dns/create.js +128 -0
  65. package/bundle/commands/dns/delete.js +80 -0
  66. package/bundle/commands/dns/get.js +167 -0
  67. package/bundle/commands/dns/list.js +193 -0
  68. package/bundle/commands/dns/records/create.js +150 -0
  69. package/bundle/commands/dns/records/delete.js +76 -0
  70. package/bundle/commands/dns/records/get.js +118 -0
  71. package/bundle/commands/dns/records/list.js +153 -0
  72. package/bundle/commands/dns/records/update.js +146 -0
  73. package/bundle/commands/logs/query.js +237 -0
  74. package/bundle/commands/logs/tail.js +155 -0
  75. package/bundle/commands/mcp/install-claude.js +220 -0
  76. package/bundle/commands/mcp/install-gemini.js +220 -0
  77. package/bundle/commands/mcp/install-goose.js +232 -0
  78. package/bundle/commands/mcp/status.js +153 -0
  79. package/bundle/commands/object/delete.js +180 -0
  80. package/bundle/commands/object/get.js +209 -0
  81. package/bundle/commands/object/list.js +206 -0
  82. package/bundle/commands/object/put.js +211 -0
  83. package/bundle/commands/query/chunk-search.js +123 -0
  84. package/bundle/commands/query/document.js +126 -0
  85. package/bundle/commands/query/events.js +98 -0
  86. package/bundle/commands/query/reindex.js +147 -0
  87. package/bundle/commands/query/search.js +169 -0
  88. package/bundle/commands/tail.js +31 -0
  89. package/bundle/index.js +51 -0
  90. package/dist/base-command.d.ts +6 -0
  91. package/dist/base-command.d.ts.map +1 -1
  92. package/dist/base-command.js +14 -1
  93. package/dist/build.d.ts +2 -1
  94. package/dist/build.d.ts.map +1 -1
  95. package/dist/build.js +169 -51
  96. package/dist/codegen.d.ts +1 -1
  97. package/dist/codegen.d.ts.map +1 -1
  98. package/dist/codegen.js +17 -3
  99. package/dist/codegen.test.js +44 -0
  100. package/dist/commands/build/checkout.d.ts.map +1 -1
  101. package/dist/commands/build/checkout.js +4 -0
  102. package/dist/commands/build/delete.d.ts.map +1 -1
  103. package/dist/commands/build/delete.js +6 -3
  104. package/dist/commands/build/deploy.d.ts.map +1 -1
  105. package/dist/commands/build/deploy.js +10 -2
  106. package/dist/commands/build/find.d.ts +1 -0
  107. package/dist/commands/build/find.d.ts.map +1 -1
  108. package/dist/commands/build/find.js +33 -2
  109. package/dist/commands/build/validate.d.ts.map +1 -1
  110. package/dist/commands/build/validate.js +0 -1
  111. package/dist/commands/build/workos/delete.d.ts +18 -0
  112. package/dist/commands/build/workos/delete.d.ts.map +1 -0
  113. package/dist/commands/build/workos/delete.js +72 -0
  114. package/dist/commands/build/workos/env/attach.d.ts +24 -0
  115. package/dist/commands/build/workos/env/attach.d.ts.map +1 -0
  116. package/dist/commands/build/workos/env/attach.js +111 -0
  117. package/dist/commands/build/workos/env/create.d.ts +26 -0
  118. package/dist/commands/build/workos/env/create.d.ts.map +1 -0
  119. package/dist/commands/build/workos/env/create.js +156 -0
  120. package/dist/commands/build/workos/env/delete.d.ts +20 -0
  121. package/dist/commands/build/workos/env/delete.d.ts.map +1 -0
  122. package/dist/commands/build/workos/env/delete.js +61 -0
  123. package/dist/commands/build/workos/env/detach.d.ts +21 -0
  124. package/dist/commands/build/workos/env/detach.d.ts.map +1 -0
  125. package/dist/commands/build/workos/env/detach.js +94 -0
  126. package/dist/commands/build/workos/env/get.d.ts +20 -0
  127. package/dist/commands/build/workos/env/get.d.ts.map +1 -0
  128. package/dist/commands/build/workos/env/get.js +94 -0
  129. package/dist/commands/build/workos/env/list.d.ts +18 -0
  130. package/dist/commands/build/workos/env/list.d.ts.map +1 -0
  131. package/dist/commands/build/workos/env/list.js +114 -0
  132. package/dist/commands/build/workos/env/set.d.ts +27 -0
  133. package/dist/commands/build/workos/env/set.d.ts.map +1 -0
  134. package/dist/commands/build/workos/env/set.js +115 -0
  135. package/dist/commands/build/workos/invite.d.ts +21 -0
  136. package/dist/commands/build/workos/invite.d.ts.map +1 -0
  137. package/dist/commands/build/workos/invite.js +68 -0
  138. package/dist/commands/build/workos/setup.d.ts +20 -0
  139. package/dist/commands/build/workos/setup.d.ts.map +1 -0
  140. package/dist/commands/build/workos/setup.js +106 -0
  141. package/dist/commands/build/workos/status.d.ts +18 -0
  142. package/dist/commands/build/workos/status.d.ts.map +1 -0
  143. package/dist/commands/build/workos/status.js +70 -0
  144. package/dist/commands/mcp/install-claude.d.ts.map +1 -1
  145. package/dist/commands/mcp/install-claude.js +0 -2
  146. package/dist/commands/mcp/install-gemini.d.ts.map +1 -1
  147. package/dist/commands/mcp/install-gemini.js +0 -2
  148. package/dist/commands/mcp/install-goose.d.ts.map +1 -1
  149. package/dist/commands/mcp/install-goose.js +0 -2
  150. package/dist/deploy.d.ts.map +1 -1
  151. package/dist/deploy.js +2 -2
  152. package/dist/index.d.ts +2 -0
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +4 -0
  155. package/oclif.manifest.json +4544 -2466
  156. package/package.json +8 -5
  157. package/templates/claude-code/debug-raindrop-app.md +89 -0
  158. package/templates/claude-code/new-raindrop-app.md +10 -6
  159. package/templates/claude-code/reattach-raindrop-session.md +50 -12
  160. package/templates/claude-code/update-raindrop-app.md +61 -9
  161. package/templates/db/node_modules/.bin/prisma +2 -2
  162. package/templates/db/node_modules/.bin/prisma-kysely +2 -2
  163. package/templates/db/node_modules/.bin/tsc +2 -2
  164. package/templates/db/node_modules/.bin/tsserver +2 -2
  165. package/templates/db/node_modules/.bin/zx +2 -2
  166. package/templates/gemini-code/debug-raindrop-app.toml +86 -0
  167. package/templates/gemini-code/new-raindrop-app.toml +9 -5
  168. package/templates/gemini-code/reattach-raindrop-session.toml +9 -11
  169. package/templates/gemini-code/update-raindrop-app.toml +55 -10
  170. package/templates/goose/debug-raindrop-app.yaml +91 -0
  171. package/templates/goose/new-raindrop-app.yaml +12 -7
  172. package/templates/goose/reattach-raindrop-session.yaml +11 -4
  173. package/templates/goose/update-raindrop-app.yaml +57 -5
  174. package/templates/init/src/_app/auth.ts +18 -0
  175. package/templates/init/src/_app/cors.ts +64 -0
  176. package/dist/tsconfig.tsbuildinfo +0 -1
  177. package/templates/claude-code/raindrop-guidelines.md +0 -322
  178. package/templates/gemini-code/raindrop-guidelines.md +0 -322
@@ -0,0 +1,1654 @@
1
+ import {
2
+ spinner
3
+ } from "../../chunk-PU4RCSXF.js";
4
+ import {
5
+ BaseCommand
6
+ } from "../../chunk-MCRKUPJY.js";
7
+ import {
8
+ __commonJS,
9
+ __toESM,
10
+ init_cjs_shims,
11
+ readState,
12
+ replaceState,
13
+ require_lib,
14
+ timestampDate
15
+ } from "../../chunk-G6NE675D.js";
16
+
17
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
18
+ var require_QRMode = __commonJS({
19
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports, module) {
20
+ init_cjs_shims();
21
+ module.exports = {
22
+ MODE_NUMBER: 1 << 0,
23
+ MODE_ALPHA_NUM: 1 << 1,
24
+ MODE_8BIT_BYTE: 1 << 2,
25
+ MODE_KANJI: 1 << 3
26
+ };
27
+ }
28
+ });
29
+
30
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js
31
+ var require_QR8bitByte = __commonJS({
32
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js"(exports, module) {
33
+ init_cjs_shims();
34
+ var QRMode = require_QRMode();
35
+ function QR8bitByte(data) {
36
+ this.mode = QRMode.MODE_8BIT_BYTE;
37
+ this.data = data;
38
+ }
39
+ QR8bitByte.prototype = {
40
+ getLength: function() {
41
+ return this.data.length;
42
+ },
43
+ write: function(buffer) {
44
+ for (var i = 0; i < this.data.length; i++) {
45
+ buffer.put(this.data.charCodeAt(i), 8);
46
+ }
47
+ }
48
+ };
49
+ module.exports = QR8bitByte;
50
+ }
51
+ });
52
+
53
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js
54
+ var require_QRMath = __commonJS({
55
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js"(exports, module) {
56
+ init_cjs_shims();
57
+ var QRMath = {
58
+ glog: function(n) {
59
+ if (n < 1) {
60
+ throw new Error("glog(" + n + ")");
61
+ }
62
+ return QRMath.LOG_TABLE[n];
63
+ },
64
+ gexp: function(n) {
65
+ while (n < 0) {
66
+ n += 255;
67
+ }
68
+ while (n >= 256) {
69
+ n -= 255;
70
+ }
71
+ return QRMath.EXP_TABLE[n];
72
+ },
73
+ EXP_TABLE: new Array(256),
74
+ LOG_TABLE: new Array(256)
75
+ };
76
+ for (i = 0; i < 8; i++) {
77
+ QRMath.EXP_TABLE[i] = 1 << i;
78
+ }
79
+ var i;
80
+ for (i = 8; i < 256; i++) {
81
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
82
+ }
83
+ var i;
84
+ for (i = 0; i < 255; i++) {
85
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
86
+ }
87
+ var i;
88
+ module.exports = QRMath;
89
+ }
90
+ });
91
+
92
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js
93
+ var require_QRPolynomial = __commonJS({
94
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js"(exports, module) {
95
+ init_cjs_shims();
96
+ var QRMath = require_QRMath();
97
+ function QRPolynomial(num, shift) {
98
+ if (num.length === void 0) {
99
+ throw new Error(num.length + "/" + shift);
100
+ }
101
+ var offset = 0;
102
+ while (offset < num.length && num[offset] === 0) {
103
+ offset++;
104
+ }
105
+ this.num = new Array(num.length - offset + shift);
106
+ for (var i = 0; i < num.length - offset; i++) {
107
+ this.num[i] = num[i + offset];
108
+ }
109
+ }
110
+ QRPolynomial.prototype = {
111
+ get: function(index) {
112
+ return this.num[index];
113
+ },
114
+ getLength: function() {
115
+ return this.num.length;
116
+ },
117
+ multiply: function(e) {
118
+ var num = new Array(this.getLength() + e.getLength() - 1);
119
+ for (var i = 0; i < this.getLength(); i++) {
120
+ for (var j = 0; j < e.getLength(); j++) {
121
+ num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
122
+ }
123
+ }
124
+ return new QRPolynomial(num, 0);
125
+ },
126
+ mod: function(e) {
127
+ if (this.getLength() - e.getLength() < 0) {
128
+ return this;
129
+ }
130
+ var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
131
+ var num = new Array(this.getLength());
132
+ for (var i = 0; i < this.getLength(); i++) {
133
+ num[i] = this.get(i);
134
+ }
135
+ for (var x = 0; x < e.getLength(); x++) {
136
+ num[x] ^= QRMath.gexp(QRMath.glog(e.get(x)) + ratio);
137
+ }
138
+ return new QRPolynomial(num, 0).mod(e);
139
+ }
140
+ };
141
+ module.exports = QRPolynomial;
142
+ }
143
+ });
144
+
145
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js
146
+ var require_QRMaskPattern = __commonJS({
147
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js"(exports, module) {
148
+ init_cjs_shims();
149
+ module.exports = {
150
+ PATTERN000: 0,
151
+ PATTERN001: 1,
152
+ PATTERN010: 2,
153
+ PATTERN011: 3,
154
+ PATTERN100: 4,
155
+ PATTERN101: 5,
156
+ PATTERN110: 6,
157
+ PATTERN111: 7
158
+ };
159
+ }
160
+ });
161
+
162
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js
163
+ var require_QRUtil = __commonJS({
164
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js"(exports, module) {
165
+ init_cjs_shims();
166
+ var QRMode = require_QRMode();
167
+ var QRPolynomial = require_QRPolynomial();
168
+ var QRMath = require_QRMath();
169
+ var QRMaskPattern = require_QRMaskPattern();
170
+ var QRUtil = {
171
+ PATTERN_POSITION_TABLE: [
172
+ [],
173
+ [6, 18],
174
+ [6, 22],
175
+ [6, 26],
176
+ [6, 30],
177
+ [6, 34],
178
+ [6, 22, 38],
179
+ [6, 24, 42],
180
+ [6, 26, 46],
181
+ [6, 28, 50],
182
+ [6, 30, 54],
183
+ [6, 32, 58],
184
+ [6, 34, 62],
185
+ [6, 26, 46, 66],
186
+ [6, 26, 48, 70],
187
+ [6, 26, 50, 74],
188
+ [6, 30, 54, 78],
189
+ [6, 30, 56, 82],
190
+ [6, 30, 58, 86],
191
+ [6, 34, 62, 90],
192
+ [6, 28, 50, 72, 94],
193
+ [6, 26, 50, 74, 98],
194
+ [6, 30, 54, 78, 102],
195
+ [6, 28, 54, 80, 106],
196
+ [6, 32, 58, 84, 110],
197
+ [6, 30, 58, 86, 114],
198
+ [6, 34, 62, 90, 118],
199
+ [6, 26, 50, 74, 98, 122],
200
+ [6, 30, 54, 78, 102, 126],
201
+ [6, 26, 52, 78, 104, 130],
202
+ [6, 30, 56, 82, 108, 134],
203
+ [6, 34, 60, 86, 112, 138],
204
+ [6, 30, 58, 86, 114, 142],
205
+ [6, 34, 62, 90, 118, 146],
206
+ [6, 30, 54, 78, 102, 126, 150],
207
+ [6, 24, 50, 76, 102, 128, 154],
208
+ [6, 28, 54, 80, 106, 132, 158],
209
+ [6, 32, 58, 84, 110, 136, 162],
210
+ [6, 26, 54, 82, 110, 138, 166],
211
+ [6, 30, 58, 86, 114, 142, 170]
212
+ ],
213
+ G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
214
+ G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
215
+ G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
216
+ getBCHTypeInfo: function(data) {
217
+ var d = data << 10;
218
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
219
+ d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
220
+ }
221
+ return (data << 10 | d) ^ QRUtil.G15_MASK;
222
+ },
223
+ getBCHTypeNumber: function(data) {
224
+ var d = data << 12;
225
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
226
+ d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
227
+ }
228
+ return data << 12 | d;
229
+ },
230
+ getBCHDigit: function(data) {
231
+ var digit = 0;
232
+ while (data !== 0) {
233
+ digit++;
234
+ data >>>= 1;
235
+ }
236
+ return digit;
237
+ },
238
+ getPatternPosition: function(typeNumber) {
239
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
240
+ },
241
+ getMask: function(maskPattern, i, j) {
242
+ switch (maskPattern) {
243
+ case QRMaskPattern.PATTERN000:
244
+ return (i + j) % 2 === 0;
245
+ case QRMaskPattern.PATTERN001:
246
+ return i % 2 === 0;
247
+ case QRMaskPattern.PATTERN010:
248
+ return j % 3 === 0;
249
+ case QRMaskPattern.PATTERN011:
250
+ return (i + j) % 3 === 0;
251
+ case QRMaskPattern.PATTERN100:
252
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
253
+ case QRMaskPattern.PATTERN101:
254
+ return i * j % 2 + i * j % 3 === 0;
255
+ case QRMaskPattern.PATTERN110:
256
+ return (i * j % 2 + i * j % 3) % 2 === 0;
257
+ case QRMaskPattern.PATTERN111:
258
+ return (i * j % 3 + (i + j) % 2) % 2 === 0;
259
+ default:
260
+ throw new Error("bad maskPattern:" + maskPattern);
261
+ }
262
+ },
263
+ getErrorCorrectPolynomial: function(errorCorrectLength) {
264
+ var a = new QRPolynomial([1], 0);
265
+ for (var i = 0; i < errorCorrectLength; i++) {
266
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
267
+ }
268
+ return a;
269
+ },
270
+ getLengthInBits: function(mode, type) {
271
+ if (1 <= type && type < 10) {
272
+ switch (mode) {
273
+ case QRMode.MODE_NUMBER:
274
+ return 10;
275
+ case QRMode.MODE_ALPHA_NUM:
276
+ return 9;
277
+ case QRMode.MODE_8BIT_BYTE:
278
+ return 8;
279
+ case QRMode.MODE_KANJI:
280
+ return 8;
281
+ default:
282
+ throw new Error("mode:" + mode);
283
+ }
284
+ } else if (type < 27) {
285
+ switch (mode) {
286
+ case QRMode.MODE_NUMBER:
287
+ return 12;
288
+ case QRMode.MODE_ALPHA_NUM:
289
+ return 11;
290
+ case QRMode.MODE_8BIT_BYTE:
291
+ return 16;
292
+ case QRMode.MODE_KANJI:
293
+ return 10;
294
+ default:
295
+ throw new Error("mode:" + mode);
296
+ }
297
+ } else if (type < 41) {
298
+ switch (mode) {
299
+ case QRMode.MODE_NUMBER:
300
+ return 14;
301
+ case QRMode.MODE_ALPHA_NUM:
302
+ return 13;
303
+ case QRMode.MODE_8BIT_BYTE:
304
+ return 16;
305
+ case QRMode.MODE_KANJI:
306
+ return 12;
307
+ default:
308
+ throw new Error("mode:" + mode);
309
+ }
310
+ } else {
311
+ throw new Error("type:" + type);
312
+ }
313
+ },
314
+ getLostPoint: function(qrCode) {
315
+ var moduleCount = qrCode.getModuleCount();
316
+ var lostPoint = 0;
317
+ var row = 0;
318
+ var col = 0;
319
+ for (row = 0; row < moduleCount; row++) {
320
+ for (col = 0; col < moduleCount; col++) {
321
+ var sameCount = 0;
322
+ var dark = qrCode.isDark(row, col);
323
+ for (var r = -1; r <= 1; r++) {
324
+ if (row + r < 0 || moduleCount <= row + r) {
325
+ continue;
326
+ }
327
+ for (var c = -1; c <= 1; c++) {
328
+ if (col + c < 0 || moduleCount <= col + c) {
329
+ continue;
330
+ }
331
+ if (r === 0 && c === 0) {
332
+ continue;
333
+ }
334
+ if (dark === qrCode.isDark(row + r, col + c)) {
335
+ sameCount++;
336
+ }
337
+ }
338
+ }
339
+ if (sameCount > 5) {
340
+ lostPoint += 3 + sameCount - 5;
341
+ }
342
+ }
343
+ }
344
+ for (row = 0; row < moduleCount - 1; row++) {
345
+ for (col = 0; col < moduleCount - 1; col++) {
346
+ var count = 0;
347
+ if (qrCode.isDark(row, col)) count++;
348
+ if (qrCode.isDark(row + 1, col)) count++;
349
+ if (qrCode.isDark(row, col + 1)) count++;
350
+ if (qrCode.isDark(row + 1, col + 1)) count++;
351
+ if (count === 0 || count === 4) {
352
+ lostPoint += 3;
353
+ }
354
+ }
355
+ }
356
+ for (row = 0; row < moduleCount; row++) {
357
+ for (col = 0; col < moduleCount - 6; col++) {
358
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
359
+ lostPoint += 40;
360
+ }
361
+ }
362
+ }
363
+ for (col = 0; col < moduleCount; col++) {
364
+ for (row = 0; row < moduleCount - 6; row++) {
365
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
366
+ lostPoint += 40;
367
+ }
368
+ }
369
+ }
370
+ var darkCount = 0;
371
+ for (col = 0; col < moduleCount; col++) {
372
+ for (row = 0; row < moduleCount; row++) {
373
+ if (qrCode.isDark(row, col)) {
374
+ darkCount++;
375
+ }
376
+ }
377
+ }
378
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
379
+ lostPoint += ratio * 10;
380
+ return lostPoint;
381
+ }
382
+ };
383
+ module.exports = QRUtil;
384
+ }
385
+ });
386
+
387
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js
388
+ var require_QRErrorCorrectLevel = __commonJS({
389
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js"(exports, module) {
390
+ init_cjs_shims();
391
+ module.exports = {
392
+ L: 1,
393
+ M: 0,
394
+ Q: 3,
395
+ H: 2
396
+ };
397
+ }
398
+ });
399
+
400
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js
401
+ var require_QRRSBlock = __commonJS({
402
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js"(exports, module) {
403
+ init_cjs_shims();
404
+ var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
405
+ function QRRSBlock(totalCount, dataCount) {
406
+ this.totalCount = totalCount;
407
+ this.dataCount = dataCount;
408
+ }
409
+ QRRSBlock.RS_BLOCK_TABLE = [
410
+ // L
411
+ // M
412
+ // Q
413
+ // H
414
+ // 1
415
+ [1, 26, 19],
416
+ [1, 26, 16],
417
+ [1, 26, 13],
418
+ [1, 26, 9],
419
+ // 2
420
+ [1, 44, 34],
421
+ [1, 44, 28],
422
+ [1, 44, 22],
423
+ [1, 44, 16],
424
+ // 3
425
+ [1, 70, 55],
426
+ [1, 70, 44],
427
+ [2, 35, 17],
428
+ [2, 35, 13],
429
+ // 4
430
+ [1, 100, 80],
431
+ [2, 50, 32],
432
+ [2, 50, 24],
433
+ [4, 25, 9],
434
+ // 5
435
+ [1, 134, 108],
436
+ [2, 67, 43],
437
+ [2, 33, 15, 2, 34, 16],
438
+ [2, 33, 11, 2, 34, 12],
439
+ // 6
440
+ [2, 86, 68],
441
+ [4, 43, 27],
442
+ [4, 43, 19],
443
+ [4, 43, 15],
444
+ // 7
445
+ [2, 98, 78],
446
+ [4, 49, 31],
447
+ [2, 32, 14, 4, 33, 15],
448
+ [4, 39, 13, 1, 40, 14],
449
+ // 8
450
+ [2, 121, 97],
451
+ [2, 60, 38, 2, 61, 39],
452
+ [4, 40, 18, 2, 41, 19],
453
+ [4, 40, 14, 2, 41, 15],
454
+ // 9
455
+ [2, 146, 116],
456
+ [3, 58, 36, 2, 59, 37],
457
+ [4, 36, 16, 4, 37, 17],
458
+ [4, 36, 12, 4, 37, 13],
459
+ // 10
460
+ [2, 86, 68, 2, 87, 69],
461
+ [4, 69, 43, 1, 70, 44],
462
+ [6, 43, 19, 2, 44, 20],
463
+ [6, 43, 15, 2, 44, 16],
464
+ // 11
465
+ [4, 101, 81],
466
+ [1, 80, 50, 4, 81, 51],
467
+ [4, 50, 22, 4, 51, 23],
468
+ [3, 36, 12, 8, 37, 13],
469
+ // 12
470
+ [2, 116, 92, 2, 117, 93],
471
+ [6, 58, 36, 2, 59, 37],
472
+ [4, 46, 20, 6, 47, 21],
473
+ [7, 42, 14, 4, 43, 15],
474
+ // 13
475
+ [4, 133, 107],
476
+ [8, 59, 37, 1, 60, 38],
477
+ [8, 44, 20, 4, 45, 21],
478
+ [12, 33, 11, 4, 34, 12],
479
+ // 14
480
+ [3, 145, 115, 1, 146, 116],
481
+ [4, 64, 40, 5, 65, 41],
482
+ [11, 36, 16, 5, 37, 17],
483
+ [11, 36, 12, 5, 37, 13],
484
+ // 15
485
+ [5, 109, 87, 1, 110, 88],
486
+ [5, 65, 41, 5, 66, 42],
487
+ [5, 54, 24, 7, 55, 25],
488
+ [11, 36, 12],
489
+ // 16
490
+ [5, 122, 98, 1, 123, 99],
491
+ [7, 73, 45, 3, 74, 46],
492
+ [15, 43, 19, 2, 44, 20],
493
+ [3, 45, 15, 13, 46, 16],
494
+ // 17
495
+ [1, 135, 107, 5, 136, 108],
496
+ [10, 74, 46, 1, 75, 47],
497
+ [1, 50, 22, 15, 51, 23],
498
+ [2, 42, 14, 17, 43, 15],
499
+ // 18
500
+ [5, 150, 120, 1, 151, 121],
501
+ [9, 69, 43, 4, 70, 44],
502
+ [17, 50, 22, 1, 51, 23],
503
+ [2, 42, 14, 19, 43, 15],
504
+ // 19
505
+ [3, 141, 113, 4, 142, 114],
506
+ [3, 70, 44, 11, 71, 45],
507
+ [17, 47, 21, 4, 48, 22],
508
+ [9, 39, 13, 16, 40, 14],
509
+ // 20
510
+ [3, 135, 107, 5, 136, 108],
511
+ [3, 67, 41, 13, 68, 42],
512
+ [15, 54, 24, 5, 55, 25],
513
+ [15, 43, 15, 10, 44, 16],
514
+ // 21
515
+ [4, 144, 116, 4, 145, 117],
516
+ [17, 68, 42],
517
+ [17, 50, 22, 6, 51, 23],
518
+ [19, 46, 16, 6, 47, 17],
519
+ // 22
520
+ [2, 139, 111, 7, 140, 112],
521
+ [17, 74, 46],
522
+ [7, 54, 24, 16, 55, 25],
523
+ [34, 37, 13],
524
+ // 23
525
+ [4, 151, 121, 5, 152, 122],
526
+ [4, 75, 47, 14, 76, 48],
527
+ [11, 54, 24, 14, 55, 25],
528
+ [16, 45, 15, 14, 46, 16],
529
+ // 24
530
+ [6, 147, 117, 4, 148, 118],
531
+ [6, 73, 45, 14, 74, 46],
532
+ [11, 54, 24, 16, 55, 25],
533
+ [30, 46, 16, 2, 47, 17],
534
+ // 25
535
+ [8, 132, 106, 4, 133, 107],
536
+ [8, 75, 47, 13, 76, 48],
537
+ [7, 54, 24, 22, 55, 25],
538
+ [22, 45, 15, 13, 46, 16],
539
+ // 26
540
+ [10, 142, 114, 2, 143, 115],
541
+ [19, 74, 46, 4, 75, 47],
542
+ [28, 50, 22, 6, 51, 23],
543
+ [33, 46, 16, 4, 47, 17],
544
+ // 27
545
+ [8, 152, 122, 4, 153, 123],
546
+ [22, 73, 45, 3, 74, 46],
547
+ [8, 53, 23, 26, 54, 24],
548
+ [12, 45, 15, 28, 46, 16],
549
+ // 28
550
+ [3, 147, 117, 10, 148, 118],
551
+ [3, 73, 45, 23, 74, 46],
552
+ [4, 54, 24, 31, 55, 25],
553
+ [11, 45, 15, 31, 46, 16],
554
+ // 29
555
+ [7, 146, 116, 7, 147, 117],
556
+ [21, 73, 45, 7, 74, 46],
557
+ [1, 53, 23, 37, 54, 24],
558
+ [19, 45, 15, 26, 46, 16],
559
+ // 30
560
+ [5, 145, 115, 10, 146, 116],
561
+ [19, 75, 47, 10, 76, 48],
562
+ [15, 54, 24, 25, 55, 25],
563
+ [23, 45, 15, 25, 46, 16],
564
+ // 31
565
+ [13, 145, 115, 3, 146, 116],
566
+ [2, 74, 46, 29, 75, 47],
567
+ [42, 54, 24, 1, 55, 25],
568
+ [23, 45, 15, 28, 46, 16],
569
+ // 32
570
+ [17, 145, 115],
571
+ [10, 74, 46, 23, 75, 47],
572
+ [10, 54, 24, 35, 55, 25],
573
+ [19, 45, 15, 35, 46, 16],
574
+ // 33
575
+ [17, 145, 115, 1, 146, 116],
576
+ [14, 74, 46, 21, 75, 47],
577
+ [29, 54, 24, 19, 55, 25],
578
+ [11, 45, 15, 46, 46, 16],
579
+ // 34
580
+ [13, 145, 115, 6, 146, 116],
581
+ [14, 74, 46, 23, 75, 47],
582
+ [44, 54, 24, 7, 55, 25],
583
+ [59, 46, 16, 1, 47, 17],
584
+ // 35
585
+ [12, 151, 121, 7, 152, 122],
586
+ [12, 75, 47, 26, 76, 48],
587
+ [39, 54, 24, 14, 55, 25],
588
+ [22, 45, 15, 41, 46, 16],
589
+ // 36
590
+ [6, 151, 121, 14, 152, 122],
591
+ [6, 75, 47, 34, 76, 48],
592
+ [46, 54, 24, 10, 55, 25],
593
+ [2, 45, 15, 64, 46, 16],
594
+ // 37
595
+ [17, 152, 122, 4, 153, 123],
596
+ [29, 74, 46, 14, 75, 47],
597
+ [49, 54, 24, 10, 55, 25],
598
+ [24, 45, 15, 46, 46, 16],
599
+ // 38
600
+ [4, 152, 122, 18, 153, 123],
601
+ [13, 74, 46, 32, 75, 47],
602
+ [48, 54, 24, 14, 55, 25],
603
+ [42, 45, 15, 32, 46, 16],
604
+ // 39
605
+ [20, 147, 117, 4, 148, 118],
606
+ [40, 75, 47, 7, 76, 48],
607
+ [43, 54, 24, 22, 55, 25],
608
+ [10, 45, 15, 67, 46, 16],
609
+ // 40
610
+ [19, 148, 118, 6, 149, 119],
611
+ [18, 75, 47, 31, 76, 48],
612
+ [34, 54, 24, 34, 55, 25],
613
+ [20, 45, 15, 61, 46, 16]
614
+ ];
615
+ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
616
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
617
+ if (rsBlock === void 0) {
618
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
619
+ }
620
+ var length = rsBlock.length / 3;
621
+ var list = [];
622
+ for (var i = 0; i < length; i++) {
623
+ var count = rsBlock[i * 3 + 0];
624
+ var totalCount = rsBlock[i * 3 + 1];
625
+ var dataCount = rsBlock[i * 3 + 2];
626
+ for (var j = 0; j < count; j++) {
627
+ list.push(new QRRSBlock(totalCount, dataCount));
628
+ }
629
+ }
630
+ return list;
631
+ };
632
+ QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
633
+ switch (errorCorrectLevel) {
634
+ case QRErrorCorrectLevel.L:
635
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
636
+ case QRErrorCorrectLevel.M:
637
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
638
+ case QRErrorCorrectLevel.Q:
639
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
640
+ case QRErrorCorrectLevel.H:
641
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
642
+ default:
643
+ return void 0;
644
+ }
645
+ };
646
+ module.exports = QRRSBlock;
647
+ }
648
+ });
649
+
650
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js
651
+ var require_QRBitBuffer = __commonJS({
652
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js"(exports, module) {
653
+ init_cjs_shims();
654
+ function QRBitBuffer() {
655
+ this.buffer = [];
656
+ this.length = 0;
657
+ }
658
+ QRBitBuffer.prototype = {
659
+ get: function(index) {
660
+ var bufIndex = Math.floor(index / 8);
661
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
662
+ },
663
+ put: function(num, length) {
664
+ for (var i = 0; i < length; i++) {
665
+ this.putBit((num >>> length - i - 1 & 1) == 1);
666
+ }
667
+ },
668
+ getLengthInBits: function() {
669
+ return this.length;
670
+ },
671
+ putBit: function(bit) {
672
+ var bufIndex = Math.floor(this.length / 8);
673
+ if (this.buffer.length <= bufIndex) {
674
+ this.buffer.push(0);
675
+ }
676
+ if (bit) {
677
+ this.buffer[bufIndex] |= 128 >>> this.length % 8;
678
+ }
679
+ this.length++;
680
+ }
681
+ };
682
+ module.exports = QRBitBuffer;
683
+ }
684
+ });
685
+
686
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/index.js
687
+ var require_QRCode = __commonJS({
688
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/index.js"(exports, module) {
689
+ init_cjs_shims();
690
+ var QR8bitByte = require_QR8bitByte();
691
+ var QRUtil = require_QRUtil();
692
+ var QRPolynomial = require_QRPolynomial();
693
+ var QRRSBlock = require_QRRSBlock();
694
+ var QRBitBuffer = require_QRBitBuffer();
695
+ function QRCode(typeNumber, errorCorrectLevel) {
696
+ this.typeNumber = typeNumber;
697
+ this.errorCorrectLevel = errorCorrectLevel;
698
+ this.modules = null;
699
+ this.moduleCount = 0;
700
+ this.dataCache = null;
701
+ this.dataList = [];
702
+ }
703
+ QRCode.prototype = {
704
+ addData: function(data) {
705
+ var newData = new QR8bitByte(data);
706
+ this.dataList.push(newData);
707
+ this.dataCache = null;
708
+ },
709
+ isDark: function(row, col) {
710
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
711
+ throw new Error(row + "," + col);
712
+ }
713
+ return this.modules[row][col];
714
+ },
715
+ getModuleCount: function() {
716
+ return this.moduleCount;
717
+ },
718
+ make: function() {
719
+ if (this.typeNumber < 1) {
720
+ var typeNumber = 1;
721
+ for (typeNumber = 1; typeNumber < 40; typeNumber++) {
722
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
723
+ var buffer = new QRBitBuffer();
724
+ var totalDataCount = 0;
725
+ for (var i = 0; i < rsBlocks.length; i++) {
726
+ totalDataCount += rsBlocks[i].dataCount;
727
+ }
728
+ for (var x = 0; x < this.dataList.length; x++) {
729
+ var data = this.dataList[x];
730
+ buffer.put(data.mode, 4);
731
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
732
+ data.write(buffer);
733
+ }
734
+ if (buffer.getLengthInBits() <= totalDataCount * 8)
735
+ break;
736
+ }
737
+ this.typeNumber = typeNumber;
738
+ }
739
+ this.makeImpl(false, this.getBestMaskPattern());
740
+ },
741
+ makeImpl: function(test, maskPattern) {
742
+ this.moduleCount = this.typeNumber * 4 + 17;
743
+ this.modules = new Array(this.moduleCount);
744
+ for (var row = 0; row < this.moduleCount; row++) {
745
+ this.modules[row] = new Array(this.moduleCount);
746
+ for (var col = 0; col < this.moduleCount; col++) {
747
+ this.modules[row][col] = null;
748
+ }
749
+ }
750
+ this.setupPositionProbePattern(0, 0);
751
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
752
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
753
+ this.setupPositionAdjustPattern();
754
+ this.setupTimingPattern();
755
+ this.setupTypeInfo(test, maskPattern);
756
+ if (this.typeNumber >= 7) {
757
+ this.setupTypeNumber(test);
758
+ }
759
+ if (this.dataCache === null) {
760
+ this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
761
+ }
762
+ this.mapData(this.dataCache, maskPattern);
763
+ },
764
+ setupPositionProbePattern: function(row, col) {
765
+ for (var r = -1; r <= 7; r++) {
766
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
767
+ for (var c = -1; c <= 7; c++) {
768
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
769
+ if (0 <= r && r <= 6 && (c === 0 || c === 6) || 0 <= c && c <= 6 && (r === 0 || r === 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
770
+ this.modules[row + r][col + c] = true;
771
+ } else {
772
+ this.modules[row + r][col + c] = false;
773
+ }
774
+ }
775
+ }
776
+ },
777
+ getBestMaskPattern: function() {
778
+ var minLostPoint = 0;
779
+ var pattern = 0;
780
+ for (var i = 0; i < 8; i++) {
781
+ this.makeImpl(true, i);
782
+ var lostPoint = QRUtil.getLostPoint(this);
783
+ if (i === 0 || minLostPoint > lostPoint) {
784
+ minLostPoint = lostPoint;
785
+ pattern = i;
786
+ }
787
+ }
788
+ return pattern;
789
+ },
790
+ createMovieClip: function(target_mc, instance_name, depth) {
791
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
792
+ var cs = 1;
793
+ this.make();
794
+ for (var row = 0; row < this.modules.length; row++) {
795
+ var y = row * cs;
796
+ for (var col = 0; col < this.modules[row].length; col++) {
797
+ var x = col * cs;
798
+ var dark = this.modules[row][col];
799
+ if (dark) {
800
+ qr_mc.beginFill(0, 100);
801
+ qr_mc.moveTo(x, y);
802
+ qr_mc.lineTo(x + cs, y);
803
+ qr_mc.lineTo(x + cs, y + cs);
804
+ qr_mc.lineTo(x, y + cs);
805
+ qr_mc.endFill();
806
+ }
807
+ }
808
+ }
809
+ return qr_mc;
810
+ },
811
+ setupTimingPattern: function() {
812
+ for (var r = 8; r < this.moduleCount - 8; r++) {
813
+ if (this.modules[r][6] !== null) {
814
+ continue;
815
+ }
816
+ this.modules[r][6] = r % 2 === 0;
817
+ }
818
+ for (var c = 8; c < this.moduleCount - 8; c++) {
819
+ if (this.modules[6][c] !== null) {
820
+ continue;
821
+ }
822
+ this.modules[6][c] = c % 2 === 0;
823
+ }
824
+ },
825
+ setupPositionAdjustPattern: function() {
826
+ var pos = QRUtil.getPatternPosition(this.typeNumber);
827
+ for (var i = 0; i < pos.length; i++) {
828
+ for (var j = 0; j < pos.length; j++) {
829
+ var row = pos[i];
830
+ var col = pos[j];
831
+ if (this.modules[row][col] !== null) {
832
+ continue;
833
+ }
834
+ for (var r = -2; r <= 2; r++) {
835
+ for (var c = -2; c <= 2; c++) {
836
+ if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
837
+ this.modules[row + r][col + c] = true;
838
+ } else {
839
+ this.modules[row + r][col + c] = false;
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+ },
846
+ setupTypeNumber: function(test) {
847
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
848
+ var mod;
849
+ for (var i = 0; i < 18; i++) {
850
+ mod = !test && (bits >> i & 1) === 1;
851
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
852
+ }
853
+ for (var x = 0; x < 18; x++) {
854
+ mod = !test && (bits >> x & 1) === 1;
855
+ this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
856
+ }
857
+ },
858
+ setupTypeInfo: function(test, maskPattern) {
859
+ var data = this.errorCorrectLevel << 3 | maskPattern;
860
+ var bits = QRUtil.getBCHTypeInfo(data);
861
+ var mod;
862
+ for (var v = 0; v < 15; v++) {
863
+ mod = !test && (bits >> v & 1) === 1;
864
+ if (v < 6) {
865
+ this.modules[v][8] = mod;
866
+ } else if (v < 8) {
867
+ this.modules[v + 1][8] = mod;
868
+ } else {
869
+ this.modules[this.moduleCount - 15 + v][8] = mod;
870
+ }
871
+ }
872
+ for (var h = 0; h < 15; h++) {
873
+ mod = !test && (bits >> h & 1) === 1;
874
+ if (h < 8) {
875
+ this.modules[8][this.moduleCount - h - 1] = mod;
876
+ } else if (h < 9) {
877
+ this.modules[8][15 - h - 1 + 1] = mod;
878
+ } else {
879
+ this.modules[8][15 - h - 1] = mod;
880
+ }
881
+ }
882
+ this.modules[this.moduleCount - 8][8] = !test;
883
+ },
884
+ mapData: function(data, maskPattern) {
885
+ var inc = -1;
886
+ var row = this.moduleCount - 1;
887
+ var bitIndex = 7;
888
+ var byteIndex = 0;
889
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
890
+ if (col === 6) col--;
891
+ while (true) {
892
+ for (var c = 0; c < 2; c++) {
893
+ if (this.modules[row][col - c] === null) {
894
+ var dark = false;
895
+ if (byteIndex < data.length) {
896
+ dark = (data[byteIndex] >>> bitIndex & 1) === 1;
897
+ }
898
+ var mask = QRUtil.getMask(maskPattern, row, col - c);
899
+ if (mask) {
900
+ dark = !dark;
901
+ }
902
+ this.modules[row][col - c] = dark;
903
+ bitIndex--;
904
+ if (bitIndex === -1) {
905
+ byteIndex++;
906
+ bitIndex = 7;
907
+ }
908
+ }
909
+ }
910
+ row += inc;
911
+ if (row < 0 || this.moduleCount <= row) {
912
+ row -= inc;
913
+ inc = -inc;
914
+ break;
915
+ }
916
+ }
917
+ }
918
+ }
919
+ };
920
+ QRCode.PAD0 = 236;
921
+ QRCode.PAD1 = 17;
922
+ QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
923
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
924
+ var buffer = new QRBitBuffer();
925
+ for (var i = 0; i < dataList.length; i++) {
926
+ var data = dataList[i];
927
+ buffer.put(data.mode, 4);
928
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
929
+ data.write(buffer);
930
+ }
931
+ var totalDataCount = 0;
932
+ for (var x = 0; x < rsBlocks.length; x++) {
933
+ totalDataCount += rsBlocks[x].dataCount;
934
+ }
935
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
936
+ throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
937
+ }
938
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
939
+ buffer.put(0, 4);
940
+ }
941
+ while (buffer.getLengthInBits() % 8 !== 0) {
942
+ buffer.putBit(false);
943
+ }
944
+ while (true) {
945
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
946
+ break;
947
+ }
948
+ buffer.put(QRCode.PAD0, 8);
949
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
950
+ break;
951
+ }
952
+ buffer.put(QRCode.PAD1, 8);
953
+ }
954
+ return QRCode.createBytes(buffer, rsBlocks);
955
+ };
956
+ QRCode.createBytes = function(buffer, rsBlocks) {
957
+ var offset = 0;
958
+ var maxDcCount = 0;
959
+ var maxEcCount = 0;
960
+ var dcdata = new Array(rsBlocks.length);
961
+ var ecdata = new Array(rsBlocks.length);
962
+ for (var r = 0; r < rsBlocks.length; r++) {
963
+ var dcCount = rsBlocks[r].dataCount;
964
+ var ecCount = rsBlocks[r].totalCount - dcCount;
965
+ maxDcCount = Math.max(maxDcCount, dcCount);
966
+ maxEcCount = Math.max(maxEcCount, ecCount);
967
+ dcdata[r] = new Array(dcCount);
968
+ for (var i = 0; i < dcdata[r].length; i++) {
969
+ dcdata[r][i] = 255 & buffer.buffer[i + offset];
970
+ }
971
+ offset += dcCount;
972
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
973
+ var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
974
+ var modPoly = rawPoly.mod(rsPoly);
975
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
976
+ for (var x = 0; x < ecdata[r].length; x++) {
977
+ var modIndex = x + modPoly.getLength() - ecdata[r].length;
978
+ ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
979
+ }
980
+ }
981
+ var totalCodeCount = 0;
982
+ for (var y = 0; y < rsBlocks.length; y++) {
983
+ totalCodeCount += rsBlocks[y].totalCount;
984
+ }
985
+ var data = new Array(totalCodeCount);
986
+ var index = 0;
987
+ for (var z = 0; z < maxDcCount; z++) {
988
+ for (var s = 0; s < rsBlocks.length; s++) {
989
+ if (z < dcdata[s].length) {
990
+ data[index++] = dcdata[s][z];
991
+ }
992
+ }
993
+ }
994
+ for (var xx = 0; xx < maxEcCount; xx++) {
995
+ for (var t = 0; t < rsBlocks.length; t++) {
996
+ if (xx < ecdata[t].length) {
997
+ data[index++] = ecdata[t][xx];
998
+ }
999
+ }
1000
+ }
1001
+ return data;
1002
+ };
1003
+ module.exports = QRCode;
1004
+ }
1005
+ });
1006
+
1007
+ // ../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/lib/main.js
1008
+ var require_main = __commonJS({
1009
+ "../../node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/lib/main.js"(exports, module) {
1010
+ init_cjs_shims();
1011
+ var QRCode = require_QRCode();
1012
+ var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
1013
+ var black = "\x1B[40m \x1B[0m";
1014
+ var white = "\x1B[47m \x1B[0m";
1015
+ var toCell = function(isBlack) {
1016
+ return isBlack ? black : white;
1017
+ };
1018
+ var repeat = function(color) {
1019
+ return {
1020
+ times: function(count) {
1021
+ return new Array(count).join(color);
1022
+ }
1023
+ };
1024
+ };
1025
+ var fill = function(length, value) {
1026
+ var arr = new Array(length);
1027
+ for (var i = 0; i < length; i++) {
1028
+ arr[i] = value;
1029
+ }
1030
+ return arr;
1031
+ };
1032
+ module.exports = {
1033
+ error: QRErrorCorrectLevel.L,
1034
+ generate: function(input, opts, cb) {
1035
+ if (typeof opts === "function") {
1036
+ cb = opts;
1037
+ opts = {};
1038
+ }
1039
+ var qrcode2 = new QRCode(-1, this.error);
1040
+ qrcode2.addData(input);
1041
+ qrcode2.make();
1042
+ var output = "";
1043
+ if (opts && opts.small) {
1044
+ var BLACK = true, WHITE = false;
1045
+ var moduleCount = qrcode2.getModuleCount();
1046
+ var moduleData = qrcode2.modules.slice();
1047
+ var oddRow = moduleCount % 2 === 1;
1048
+ if (oddRow) {
1049
+ moduleData.push(fill(moduleCount, WHITE));
1050
+ }
1051
+ var platte = {
1052
+ WHITE_ALL: "\u2588",
1053
+ WHITE_BLACK: "\u2580",
1054
+ BLACK_WHITE: "\u2584",
1055
+ BLACK_ALL: " "
1056
+ };
1057
+ var borderTop = repeat(platte.BLACK_WHITE).times(moduleCount + 3);
1058
+ var borderBottom = repeat(platte.WHITE_BLACK).times(moduleCount + 3);
1059
+ output += borderTop + "\n";
1060
+ for (var row = 0; row < moduleCount; row += 2) {
1061
+ output += platte.WHITE_ALL;
1062
+ for (var col = 0; col < moduleCount; col++) {
1063
+ if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === WHITE) {
1064
+ output += platte.WHITE_ALL;
1065
+ } else if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === BLACK) {
1066
+ output += platte.WHITE_BLACK;
1067
+ } else if (moduleData[row][col] === BLACK && moduleData[row + 1][col] === WHITE) {
1068
+ output += platte.BLACK_WHITE;
1069
+ } else {
1070
+ output += platte.BLACK_ALL;
1071
+ }
1072
+ }
1073
+ output += platte.WHITE_ALL + "\n";
1074
+ }
1075
+ if (!oddRow) {
1076
+ output += borderBottom;
1077
+ }
1078
+ } else {
1079
+ var border = repeat(white).times(qrcode2.getModuleCount() + 3);
1080
+ output += border + "\n";
1081
+ qrcode2.modules.forEach(function(row2) {
1082
+ output += white;
1083
+ output += row2.map(toCell).join("");
1084
+ output += white + "\n";
1085
+ });
1086
+ output += border;
1087
+ }
1088
+ if (cb) cb(output);
1089
+ else console.log(output);
1090
+ },
1091
+ setErrorLevel: function(error) {
1092
+ this.error = QRErrorCorrectLevel[error] || this.error;
1093
+ }
1094
+ };
1095
+ }
1096
+ });
1097
+
1098
+ // src/commands/auth/login.ts
1099
+ init_cjs_shims();
1100
+ var import_core = __toESM(require_lib(), 1);
1101
+
1102
+ // ../../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js
1103
+ init_cjs_shims();
1104
+ import process5 from "node:process";
1105
+ import { Buffer } from "node:buffer";
1106
+ import path from "node:path";
1107
+ import { fileURLToPath } from "node:url";
1108
+ import util from "node:util";
1109
+ import childProcess from "node:child_process";
1110
+ import fs4, { constants as fsConstants } from "node:fs/promises";
1111
+
1112
+ // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
1113
+ init_cjs_shims();
1114
+ import process from "node:process";
1115
+ import os from "node:os";
1116
+ import fs3 from "node:fs";
1117
+
1118
+ // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
1119
+ init_cjs_shims();
1120
+ import fs2 from "node:fs";
1121
+
1122
+ // ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
1123
+ init_cjs_shims();
1124
+ import fs from "node:fs";
1125
+ var isDockerCached;
1126
+ function hasDockerEnv() {
1127
+ try {
1128
+ fs.statSync("/.dockerenv");
1129
+ return true;
1130
+ } catch {
1131
+ return false;
1132
+ }
1133
+ }
1134
+ function hasDockerCGroup() {
1135
+ try {
1136
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
1137
+ } catch {
1138
+ return false;
1139
+ }
1140
+ }
1141
+ function isDocker() {
1142
+ if (isDockerCached === void 0) {
1143
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
1144
+ }
1145
+ return isDockerCached;
1146
+ }
1147
+
1148
+ // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
1149
+ var cachedResult;
1150
+ var hasContainerEnv = () => {
1151
+ try {
1152
+ fs2.statSync("/run/.containerenv");
1153
+ return true;
1154
+ } catch {
1155
+ return false;
1156
+ }
1157
+ };
1158
+ function isInsideContainer() {
1159
+ if (cachedResult === void 0) {
1160
+ cachedResult = hasContainerEnv() || isDocker();
1161
+ }
1162
+ return cachedResult;
1163
+ }
1164
+
1165
+ // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
1166
+ var isWsl = () => {
1167
+ if (process.platform !== "linux") {
1168
+ return false;
1169
+ }
1170
+ if (os.release().toLowerCase().includes("microsoft")) {
1171
+ if (isInsideContainer()) {
1172
+ return false;
1173
+ }
1174
+ return true;
1175
+ }
1176
+ try {
1177
+ return fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
1178
+ } catch {
1179
+ return false;
1180
+ }
1181
+ };
1182
+ var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
1183
+
1184
+ // ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
1185
+ init_cjs_shims();
1186
+ function defineLazyProperty(object, propertyName, valueGetter) {
1187
+ const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
1188
+ Object.defineProperty(object, propertyName, {
1189
+ configurable: true,
1190
+ enumerable: true,
1191
+ get() {
1192
+ const result = valueGetter();
1193
+ define(result);
1194
+ return result;
1195
+ },
1196
+ set(value) {
1197
+ define(value);
1198
+ }
1199
+ });
1200
+ return object;
1201
+ }
1202
+
1203
+ // ../../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/index.js
1204
+ init_cjs_shims();
1205
+ import { promisify as promisify4 } from "node:util";
1206
+ import process4 from "node:process";
1207
+ import { execFile as execFile4 } from "node:child_process";
1208
+
1209
+ // ../../node_modules/.pnpm/default-browser-id@5.0.0/node_modules/default-browser-id/index.js
1210
+ init_cjs_shims();
1211
+ import { promisify } from "node:util";
1212
+ import process2 from "node:process";
1213
+ import { execFile } from "node:child_process";
1214
+ var execFileAsync = promisify(execFile);
1215
+ async function defaultBrowserId() {
1216
+ if (process2.platform !== "darwin") {
1217
+ throw new Error("macOS only");
1218
+ }
1219
+ const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
1220
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
1221
+ return match?.groups.id ?? "com.apple.Safari";
1222
+ }
1223
+
1224
+ // ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
1225
+ init_cjs_shims();
1226
+
1227
+ // ../../node_modules/.pnpm/run-applescript@7.0.0/node_modules/run-applescript/index.js
1228
+ init_cjs_shims();
1229
+ import process3 from "node:process";
1230
+ import { promisify as promisify2 } from "node:util";
1231
+ import { execFile as execFile2, execFileSync } from "node:child_process";
1232
+ var execFileAsync2 = promisify2(execFile2);
1233
+ async function runAppleScript(script, { humanReadableOutput = true } = {}) {
1234
+ if (process3.platform !== "darwin") {
1235
+ throw new Error("macOS only");
1236
+ }
1237
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
1238
+ const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments]);
1239
+ return stdout.trim();
1240
+ }
1241
+
1242
+ // ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
1243
+ async function bundleName(bundleId) {
1244
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
1245
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
1246
+ }
1247
+
1248
+ // ../../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/windows.js
1249
+ init_cjs_shims();
1250
+ import { promisify as promisify3 } from "node:util";
1251
+ import { execFile as execFile3 } from "node:child_process";
1252
+ var execFileAsync3 = promisify3(execFile3);
1253
+ var windowsBrowserProgIds = {
1254
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
1255
+ MSEdgeDHTML: { name: "Edge", id: "com.microsoft.edge" },
1256
+ // On macOS, it's "com.microsoft.edgemac"
1257
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
1258
+ // Newer Edge/Win10 releases
1259
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" },
1260
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
1261
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
1262
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
1263
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
1264
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" }
1265
+ };
1266
+ var UnknownBrowserError = class extends Error {
1267
+ };
1268
+ async function defaultBrowser(_execFileAsync = execFileAsync3) {
1269
+ const { stdout } = await _execFileAsync("reg", [
1270
+ "QUERY",
1271
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
1272
+ "/v",
1273
+ "ProgId"
1274
+ ]);
1275
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
1276
+ if (!match) {
1277
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
1278
+ }
1279
+ const { id } = match.groups;
1280
+ const browser = windowsBrowserProgIds[id];
1281
+ if (!browser) {
1282
+ throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
1283
+ }
1284
+ return browser;
1285
+ }
1286
+
1287
+ // ../../node_modules/.pnpm/default-browser@5.2.1/node_modules/default-browser/index.js
1288
+ var execFileAsync4 = promisify4(execFile4);
1289
+ var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
1290
+ async function defaultBrowser2() {
1291
+ if (process4.platform === "darwin") {
1292
+ const id = await defaultBrowserId();
1293
+ const name = await bundleName(id);
1294
+ return { name, id };
1295
+ }
1296
+ if (process4.platform === "linux") {
1297
+ const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
1298
+ const id = stdout.trim();
1299
+ const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
1300
+ return { name, id };
1301
+ }
1302
+ if (process4.platform === "win32") {
1303
+ return defaultBrowser();
1304
+ }
1305
+ throw new Error("Only macOS, Linux, and Windows are supported");
1306
+ }
1307
+
1308
+ // ../../node_modules/.pnpm/open@10.1.2/node_modules/open/index.js
1309
+ var execFile5 = util.promisify(childProcess.execFile);
1310
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
1311
+ var localXdgOpenPath = path.join(__dirname, "xdg-open");
1312
+ var { platform, arch } = process5;
1313
+ var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
1314
+ const defaultMountPoint = "/mnt/";
1315
+ let mountPoint;
1316
+ return async function() {
1317
+ if (mountPoint) {
1318
+ return mountPoint;
1319
+ }
1320
+ const configFilePath = "/etc/wsl.conf";
1321
+ let isConfigFileExists = false;
1322
+ try {
1323
+ await fs4.access(configFilePath, fsConstants.F_OK);
1324
+ isConfigFileExists = true;
1325
+ } catch {
1326
+ }
1327
+ if (!isConfigFileExists) {
1328
+ return defaultMountPoint;
1329
+ }
1330
+ const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
1331
+ const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
1332
+ if (!configMountPoint) {
1333
+ return defaultMountPoint;
1334
+ }
1335
+ mountPoint = configMountPoint.groups.mountPoint.trim();
1336
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
1337
+ return mountPoint;
1338
+ };
1339
+ })();
1340
+ var getPowershellPathFromWsl = async () => {
1341
+ const mountPoint = await getWslDrivesMountPoint();
1342
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
1343
+ };
1344
+ async function getWindowsDefaultBrowserFromWsl() {
1345
+ const powershellPath = await getPowershellPathFromWsl();
1346
+ const rawCommand = '(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId';
1347
+ const encodedCommand = Buffer.from(rawCommand, "utf16le").toString("base64");
1348
+ const { stdout } = await execFile5(
1349
+ powershellPath,
1350
+ [
1351
+ "-NoProfile",
1352
+ "-NonInteractive",
1353
+ "-ExecutionPolicy",
1354
+ "Bypass",
1355
+ "-EncodedCommand",
1356
+ encodedCommand
1357
+ ],
1358
+ { encoding: "utf8" }
1359
+ );
1360
+ const progId = stdout.trim();
1361
+ const browserMap = {
1362
+ ChromeHTML: "com.google.chrome",
1363
+ MSEdgeHTM: "com.microsoft.edge",
1364
+ FirefoxURL: "org.mozilla.firefox"
1365
+ };
1366
+ return browserMap[progId] ? { id: browserMap[progId] } : {};
1367
+ }
1368
+ var pTryEach = async (array, mapper) => {
1369
+ let latestError;
1370
+ for (const item of array) {
1371
+ try {
1372
+ return await mapper(item);
1373
+ } catch (error) {
1374
+ latestError = error;
1375
+ }
1376
+ }
1377
+ throw latestError;
1378
+ };
1379
+ var baseOpen = async (options) => {
1380
+ options = {
1381
+ wait: false,
1382
+ background: false,
1383
+ newInstance: false,
1384
+ allowNonzeroExitCode: false,
1385
+ ...options
1386
+ };
1387
+ if (Array.isArray(options.app)) {
1388
+ return pTryEach(options.app, (singleApp) => baseOpen({
1389
+ ...options,
1390
+ app: singleApp
1391
+ }));
1392
+ }
1393
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
1394
+ appArguments = [...appArguments];
1395
+ if (Array.isArray(app)) {
1396
+ return pTryEach(app, (appName) => baseOpen({
1397
+ ...options,
1398
+ app: {
1399
+ name: appName,
1400
+ arguments: appArguments
1401
+ }
1402
+ }));
1403
+ }
1404
+ if (app === "browser" || app === "browserPrivate") {
1405
+ const ids = {
1406
+ "com.google.chrome": "chrome",
1407
+ "google-chrome.desktop": "chrome",
1408
+ "org.mozilla.firefox": "firefox",
1409
+ "firefox.desktop": "firefox",
1410
+ "com.microsoft.msedge": "edge",
1411
+ "com.microsoft.edge": "edge",
1412
+ "com.microsoft.edgemac": "edge",
1413
+ "microsoft-edge.desktop": "edge"
1414
+ };
1415
+ const flags = {
1416
+ chrome: "--incognito",
1417
+ firefox: "--private-window",
1418
+ edge: "--inPrivate"
1419
+ };
1420
+ const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
1421
+ if (browser.id in ids) {
1422
+ const browserName = ids[browser.id];
1423
+ if (app === "browserPrivate") {
1424
+ appArguments.push(flags[browserName]);
1425
+ }
1426
+ return baseOpen({
1427
+ ...options,
1428
+ app: {
1429
+ name: apps[browserName],
1430
+ arguments: appArguments
1431
+ }
1432
+ });
1433
+ }
1434
+ throw new Error(`${browser.name} is not supported as a default browser`);
1435
+ }
1436
+ let command;
1437
+ const cliArguments = [];
1438
+ const childProcessOptions = {};
1439
+ if (platform === "darwin") {
1440
+ command = "open";
1441
+ if (options.wait) {
1442
+ cliArguments.push("--wait-apps");
1443
+ }
1444
+ if (options.background) {
1445
+ cliArguments.push("--background");
1446
+ }
1447
+ if (options.newInstance) {
1448
+ cliArguments.push("--new");
1449
+ }
1450
+ if (app) {
1451
+ cliArguments.push("-a", app);
1452
+ }
1453
+ } else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
1454
+ command = is_wsl_default ? await getPowershellPathFromWsl() : `${process5.env.SYSTEMROOT || process5.env.windir || "C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
1455
+ cliArguments.push(
1456
+ "-NoProfile",
1457
+ "-NonInteractive",
1458
+ "-ExecutionPolicy",
1459
+ "Bypass",
1460
+ "-EncodedCommand"
1461
+ );
1462
+ if (!is_wsl_default) {
1463
+ childProcessOptions.windowsVerbatimArguments = true;
1464
+ }
1465
+ const encodedArguments = ["Start"];
1466
+ if (options.wait) {
1467
+ encodedArguments.push("-Wait");
1468
+ }
1469
+ if (app) {
1470
+ encodedArguments.push(`"\`"${app}\`""`);
1471
+ if (options.target) {
1472
+ appArguments.push(options.target);
1473
+ }
1474
+ } else if (options.target) {
1475
+ encodedArguments.push(`"${options.target}"`);
1476
+ }
1477
+ if (appArguments.length > 0) {
1478
+ appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
1479
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
1480
+ }
1481
+ options.target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
1482
+ } else {
1483
+ if (app) {
1484
+ command = app;
1485
+ } else {
1486
+ const isBundled = !__dirname || __dirname === "/";
1487
+ let exeLocalXdgOpen = false;
1488
+ try {
1489
+ await fs4.access(localXdgOpenPath, fsConstants.X_OK);
1490
+ exeLocalXdgOpen = true;
1491
+ } catch {
1492
+ }
1493
+ const useSystemXdgOpen = process5.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
1494
+ command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
1495
+ }
1496
+ if (appArguments.length > 0) {
1497
+ cliArguments.push(...appArguments);
1498
+ }
1499
+ if (!options.wait) {
1500
+ childProcessOptions.stdio = "ignore";
1501
+ childProcessOptions.detached = true;
1502
+ }
1503
+ }
1504
+ if (platform === "darwin" && appArguments.length > 0) {
1505
+ cliArguments.push("--args", ...appArguments);
1506
+ }
1507
+ if (options.target) {
1508
+ cliArguments.push(options.target);
1509
+ }
1510
+ const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
1511
+ if (options.wait) {
1512
+ return new Promise((resolve, reject) => {
1513
+ subprocess.once("error", reject);
1514
+ subprocess.once("close", (exitCode) => {
1515
+ if (!options.allowNonzeroExitCode && exitCode > 0) {
1516
+ reject(new Error(`Exited with code ${exitCode}`));
1517
+ return;
1518
+ }
1519
+ resolve(subprocess);
1520
+ });
1521
+ });
1522
+ }
1523
+ subprocess.unref();
1524
+ return subprocess;
1525
+ };
1526
+ var open = (target, options) => {
1527
+ if (typeof target !== "string") {
1528
+ throw new TypeError("Expected a `target`");
1529
+ }
1530
+ return baseOpen({
1531
+ ...options,
1532
+ target
1533
+ });
1534
+ };
1535
+ function detectArchBinary(binary) {
1536
+ if (typeof binary === "string" || Array.isArray(binary)) {
1537
+ return binary;
1538
+ }
1539
+ const { [arch]: archBinary } = binary;
1540
+ if (!archBinary) {
1541
+ throw new Error(`${arch} is not supported`);
1542
+ }
1543
+ return archBinary;
1544
+ }
1545
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
1546
+ if (wsl && is_wsl_default) {
1547
+ return detectArchBinary(wsl);
1548
+ }
1549
+ if (!platformBinary) {
1550
+ throw new Error(`${platform} is not supported`);
1551
+ }
1552
+ return detectArchBinary(platformBinary);
1553
+ }
1554
+ var apps = {};
1555
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
1556
+ darwin: "google chrome",
1557
+ win32: "chrome",
1558
+ linux: ["google-chrome", "google-chrome-stable", "chromium"]
1559
+ }, {
1560
+ wsl: {
1561
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
1562
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
1563
+ }
1564
+ }));
1565
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
1566
+ darwin: "firefox",
1567
+ win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
1568
+ linux: "firefox"
1569
+ }, {
1570
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
1571
+ }));
1572
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
1573
+ darwin: "microsoft edge",
1574
+ win32: "msedge",
1575
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
1576
+ }, {
1577
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
1578
+ }));
1579
+ defineLazyProperty(apps, "browser", () => "browser");
1580
+ defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
1581
+ var open_default = open;
1582
+
1583
+ // src/commands/auth/login.ts
1584
+ var import_qrcode_terminal = __toESM(require_main(), 1);
1585
+ function sleep(dur) {
1586
+ const ms = dur.nanos / 1e6 + Number(dur.seconds * 1000n);
1587
+ return new Promise((resolve) => setTimeout(resolve, ms));
1588
+ }
1589
+ var Login = class extends BaseCommand {
1590
+ static args = {};
1591
+ static description = "Logs a user into the LiquidMetal platform. Supports browser-based authentication.";
1592
+ static flags = {
1593
+ rainbowAuthService: import_core.Flags.string({
1594
+ default: "https://liquidmetal.run/api/connect",
1595
+ hidden: true,
1596
+ env: "LIQUIDMETAL_RAINBOW_AUTH_SERVICE"
1597
+ })
1598
+ };
1599
+ async run() {
1600
+ const { client: rainbowAuth } = await this.rainbowAuthService();
1601
+ const clientId = `raindrop@${this.config.version}`;
1602
+ const {
1603
+ deviceCode,
1604
+ verificationUriComplete,
1605
+ expiresAt,
1606
+ interval: initialInterval
1607
+ } = await rainbowAuth.deviceAuthorization({
1608
+ clientId
1609
+ });
1610
+ if (!expiresAt || !initialInterval) {
1611
+ throw new Error(`expected expiresAt and interval to be set`);
1612
+ }
1613
+ import_qrcode_terminal.default.generate(verificationUriComplete, { small: true });
1614
+ console.log(`Scan the QR code or, using a browser visit: ${verificationUriComplete}`);
1615
+ console.log("\n\nopening url...");
1616
+ void open_default(verificationUriComplete);
1617
+ await spinner("Waiting for session...", async () => {
1618
+ let interval = initialInterval;
1619
+ let done = false;
1620
+ while (!done) {
1621
+ if (/* @__PURE__ */ new Date() > timestampDate(expiresAt)) {
1622
+ console.error("failed to authenticate in time");
1623
+ this.exit(1);
1624
+ }
1625
+ await sleep(interval);
1626
+ const { response } = await rainbowAuth.deviceAccessToken({
1627
+ deviceCode
1628
+ });
1629
+ switch (response.case) {
1630
+ case "authorizationPending":
1631
+ if (response.value.interval) {
1632
+ interval = response.value.interval;
1633
+ }
1634
+ break;
1635
+ case "bearerToken":
1636
+ {
1637
+ const state = await readState(this.config.configDir);
1638
+ state.currentOrganizationId = response.value.organizationId;
1639
+ state.organizationIdToBearerToken[response.value.organizationId] = response.value;
1640
+ await replaceState(this.config.configDir, state);
1641
+ console.log(`Logged in as ${response.value.userEmail} to ${response.value.organizationName}`);
1642
+ }
1643
+ done = true;
1644
+ break;
1645
+ default:
1646
+ console.error(`unhandled device access token response case=${response.case}`);
1647
+ }
1648
+ }
1649
+ });
1650
+ }
1651
+ };
1652
+ export {
1653
+ Login as default
1654
+ };