@moonbase.sh/gorilla-engine 0.2.1 → 0.3.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/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ __export(src_exports, {
43
43
  module.exports = __toCommonJS(src_exports);
44
44
 
45
45
  // src/moonbase.ts
46
- var import_node_buffer = require("buffer");
46
+ var import_node_buffer2 = require("buffer");
47
47
  var import_node_child_process = require("child_process");
48
48
  var import_node_fs2 = __toESM(require("fs"), 1);
49
49
  var import_promises = __toESM(require("fs/promises"), 1);
@@ -53,7 +53,7 @@ var import_node_process = __toESM(require("process"), 1);
53
53
  var import_licensing = require("@moonbase.sh/licensing");
54
54
 
55
55
  // package.json
56
- var version = "0.2.1";
56
+ var version = "0.3.0";
57
57
 
58
58
  // src/download.ts
59
59
  var import_node_fs = __toESM(require("fs"), 1);
@@ -78,6 +78,296 @@ function uniquePath(dir, name) {
78
78
  }
79
79
  }
80
80
 
81
+ // src/icons.ts
82
+ var import_node_buffer = require("buffer");
83
+ var import_node_zlib = require("zlib");
84
+ var ICON_PATHS = {
85
+ check: "M4.5 12.75l6 6 9-13.5",
86
+ cross: "M6 18 18 6M6 6l12 12",
87
+ lock: "M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25z",
88
+ back: "M15.75 19.5 8.25 12l7.5-7.5",
89
+ chevron: "m8.25 4.5 7.5 7.5-7.5 7.5",
90
+ signal: "M9.348 14.652a3.75 3.75 0 010-5.304m5.304 0a3.75 3.75 0 010 5.304m-7.425 2.121a6.75 6.75 0 010-9.546m9.546 0a6.75 6.75 0 010 9.546M5.106 18.894c-3.808-3.807-3.808-9.98 0-13.788m13.788 0c3.808 3.807 3.808 9.98 0 13.788M12 12h.008v.008H12V12z",
91
+ computer: "M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25",
92
+ fileDown: "M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9z",
93
+ upload: "M7.5 7.5h-.75A2.25 2.25 0 0 0 4.5 9.75v7.5a2.25 2.25 0 0 0 2.25 2.25h7.5a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75m-6 3.75 3-3m0 0 3 3m-3-3v11.25m6-2.25h.75a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75",
94
+ okCircle: "M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",
95
+ warning: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",
96
+ blocked: "M18.364 18.364A9 9 0 0 0 5.636 5.636m12.728 12.728A9 9 0 0 1 5.636 5.636m12.728 12.728L5.636 5.636",
97
+ copy: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375",
98
+ download: "M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3",
99
+ puzzle: "M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.4 48.4 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.04 48.04 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.4 48.4 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0z",
100
+ external: "M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25",
101
+ sparkles: "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"
102
+ };
103
+ function polylines(d) {
104
+ const lines = [];
105
+ let at = 0;
106
+ let command = "";
107
+ let x = 0;
108
+ let y = 0;
109
+ let startX = 0;
110
+ let startY = 0;
111
+ let control = null;
112
+ let line = [];
113
+ const skip = () => {
114
+ while (at < d.length && /[\s,]/.test(d[at]))
115
+ at++;
116
+ };
117
+ const isCommand = (character) => !!character && /[MLHVCSQTAZ]/i.test(character);
118
+ const number = () => {
119
+ skip();
120
+ const match = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/i.exec(d.slice(at));
121
+ if (!match)
122
+ throw new Error(`Expected a number at ${at} in ${d}`);
123
+ at += match[0].length;
124
+ return Number(match[0]);
125
+ };
126
+ const flag = () => {
127
+ skip();
128
+ const character = d[at++];
129
+ if (character !== "0" && character !== "1")
130
+ throw new Error(`Expected an arc flag at ${at - 1} in ${d}`);
131
+ return character === "1";
132
+ };
133
+ const to = (nextX, nextY) => {
134
+ x = nextX;
135
+ y = nextY;
136
+ line.push([x, y]);
137
+ };
138
+ const cubic = (x1, y1, x2, y2, endX, endY) => {
139
+ const [x0, y0] = [x, y];
140
+ for (let step = 1; step <= 16; step++) {
141
+ const t = step / 16;
142
+ const u = 1 - t;
143
+ line.push([
144
+ u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * endX,
145
+ u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * endY
146
+ ]);
147
+ }
148
+ x = endX;
149
+ y = endY;
150
+ control = [x2, y2];
151
+ };
152
+ for (; ; ) {
153
+ skip();
154
+ if (at >= d.length)
155
+ break;
156
+ if (isCommand(d[at]))
157
+ command = d[at++];
158
+ else if (!command)
159
+ throw new Error(`Expected a command at ${at} in ${d}`);
160
+ const relative = command === command.toLowerCase();
161
+ const ox = relative ? x : 0;
162
+ const oy = relative ? y : 0;
163
+ const smooth = control;
164
+ control = null;
165
+ switch (command.toUpperCase()) {
166
+ case "M": {
167
+ x = number() + ox;
168
+ y = number() + oy;
169
+ startX = x;
170
+ startY = y;
171
+ line = [[x, y]];
172
+ lines.push(line);
173
+ command = relative ? "l" : "L";
174
+ break;
175
+ }
176
+ case "L": {
177
+ const nextX = number() + ox;
178
+ to(nextX, number() + oy);
179
+ break;
180
+ }
181
+ case "H":
182
+ to(number() + ox, y);
183
+ break;
184
+ case "V":
185
+ to(x, number() + oy);
186
+ break;
187
+ case "C": {
188
+ const x1 = number() + ox;
189
+ const y1 = number() + oy;
190
+ const x2 = number() + ox;
191
+ const y2 = number() + oy;
192
+ const endX = number() + ox;
193
+ cubic(x1, y1, x2, y2, endX, number() + oy);
194
+ break;
195
+ }
196
+ case "S": {
197
+ const [x1, y1] = smooth ? [2 * x - smooth[0], 2 * y - smooth[1]] : [x, y];
198
+ const x2 = number() + ox;
199
+ const y2 = number() + oy;
200
+ const endX = number() + ox;
201
+ cubic(x1, y1, x2, y2, endX, number() + oy);
202
+ break;
203
+ }
204
+ case "Q": {
205
+ const qx = number() + ox;
206
+ const qy = number() + oy;
207
+ const endX = number() + ox;
208
+ const endY = number() + oy;
209
+ cubic(x + 2 / 3 * (qx - x), y + 2 / 3 * (qy - y), endX + 2 / 3 * (qx - endX), endY + 2 / 3 * (qy - endY), endX, endY);
210
+ break;
211
+ }
212
+ case "A": {
213
+ const rx = number();
214
+ const ry = number();
215
+ const rotation = number();
216
+ const large = flag();
217
+ const sweep = flag();
218
+ const endX = number() + ox;
219
+ const endY = number() + oy;
220
+ for (const point of arc(x, y, rx, ry, rotation, large, sweep, endX, endY))
221
+ line.push(point);
222
+ x = endX;
223
+ y = endY;
224
+ break;
225
+ }
226
+ case "Z":
227
+ to(startX, startY);
228
+ line = [[x, y]];
229
+ lines.push(line);
230
+ skip();
231
+ if (at < d.length && !isCommand(d[at]))
232
+ throw new Error(`Expected a command after Z at ${at} in ${d}`);
233
+ break;
234
+ default:
235
+ throw new Error(`Unsupported command ${command} in ${d}`);
236
+ }
237
+ }
238
+ return lines;
239
+ }
240
+ function arc(x1, y1, rx, ry, rotation, large, sweep, x2, y2) {
241
+ if (rx === 0 || ry === 0)
242
+ return [[x2, y2]];
243
+ rx = Math.abs(rx);
244
+ ry = Math.abs(ry);
245
+ const phi = rotation * Math.PI / 180;
246
+ const cos = Math.cos(phi);
247
+ const sin = Math.sin(phi);
248
+ const dx = (x1 - x2) / 2;
249
+ const dy = (y1 - y2) / 2;
250
+ const x1p = cos * dx + sin * dy;
251
+ const y1p = -sin * dx + cos * dy;
252
+ const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
253
+ if (lambda > 1) {
254
+ rx *= Math.sqrt(lambda);
255
+ ry *= Math.sqrt(lambda);
256
+ }
257
+ const numerator = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
258
+ const denominator = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
259
+ let coefficient = Math.sqrt(Math.max(0, numerator / denominator));
260
+ if (large === sweep)
261
+ coefficient = -coefficient;
262
+ const cxp = coefficient * rx * y1p / ry;
263
+ const cyp = -coefficient * ry * x1p / rx;
264
+ const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
265
+ const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
266
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
267
+ const start = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
268
+ let delta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
269
+ if (!sweep && delta > 0)
270
+ delta -= 2 * Math.PI;
271
+ else if (sweep && delta < 0)
272
+ delta += 2 * Math.PI;
273
+ const steps = Math.max(2, Math.ceil(Math.abs(delta) / (Math.PI / 24)));
274
+ const points = [];
275
+ for (let step = 1; step <= steps; step++) {
276
+ const t = start + delta * step / steps;
277
+ points.push([cos * rx * Math.cos(t) - sin * ry * Math.sin(t) + cx, sin * rx * Math.cos(t) + cos * ry * Math.sin(t) + cy]);
278
+ }
279
+ return points;
280
+ }
281
+ function coverage(d, pixels, strokeWidth) {
282
+ const scale = pixels / 24;
283
+ const half = strokeWidth * scale / 2;
284
+ const segments = [];
285
+ for (const line of polylines(d)) {
286
+ const points = line.map(([px, py]) => [px * scale, py * scale]);
287
+ if (points.length === 1)
288
+ segments.push([points[0][0], points[0][1], points[0][0], points[0][1]]);
289
+ for (let index = 1; index < points.length; index++)
290
+ segments.push([points[index - 1][0], points[index - 1][1], points[index][0], points[index][1]]);
291
+ }
292
+ const reach = half + 1;
293
+ const out = new Float32Array(pixels * pixels);
294
+ for (const [ax, ay, bx, by] of segments) {
295
+ const left = Math.max(0, Math.floor(Math.min(ax, bx) - reach));
296
+ const right = Math.min(pixels - 1, Math.ceil(Math.max(ax, bx) + reach));
297
+ const top = Math.max(0, Math.floor(Math.min(ay, by) - reach));
298
+ const bottom = Math.min(pixels - 1, Math.ceil(Math.max(ay, by) + reach));
299
+ const vx = bx - ax;
300
+ const vy = by - ay;
301
+ const length = vx * vx + vy * vy;
302
+ for (let py = top; py <= bottom; py++) {
303
+ for (let px = left; px <= right; px++) {
304
+ const cx = px + 0.5;
305
+ const cy = py + 0.5;
306
+ const t = length === 0 ? 0 : Math.max(0, Math.min(1, ((cx - ax) * vx + (cy - ay) * vy) / length));
307
+ const distance = Math.hypot(cx - (ax + t * vx), cy - (ay + t * vy));
308
+ const value = Math.max(0, Math.min(1, half + 0.5 - distance));
309
+ const index = py * pixels + px;
310
+ if (value > out[index])
311
+ out[index] = value;
312
+ }
313
+ }
314
+ }
315
+ return out;
316
+ }
317
+ var CRC_TABLE = (() => {
318
+ const table = new Uint32Array(256);
319
+ for (let n = 0; n < 256; n++) {
320
+ let c = n;
321
+ for (let k = 0; k < 8; k++)
322
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
323
+ table[n] = c >>> 0;
324
+ }
325
+ return table;
326
+ })();
327
+ function crc32(bytes) {
328
+ let c = 4294967295;
329
+ for (const byte of bytes)
330
+ c = CRC_TABLE[(c ^ byte) & 255] ^ c >>> 8;
331
+ return (c ^ 4294967295) >>> 0;
332
+ }
333
+ function chunk(type, data) {
334
+ const length = import_node_buffer.Buffer.alloc(4);
335
+ length.writeUInt32BE(data.length);
336
+ const body = import_node_buffer.Buffer.concat([import_node_buffer.Buffer.from(type, "ascii"), data]);
337
+ const crc = import_node_buffer.Buffer.alloc(4);
338
+ crc.writeUInt32BE(crc32(body));
339
+ return import_node_buffer.Buffer.concat([length, body, crc]);
340
+ }
341
+ function encodePng(width, height, rgba) {
342
+ const header = import_node_buffer.Buffer.alloc(13);
343
+ header.writeUInt32BE(width, 0);
344
+ header.writeUInt32BE(height, 4);
345
+ header[8] = 8;
346
+ header[9] = 6;
347
+ const raw = import_node_buffer.Buffer.alloc((width * 4 + 1) * height);
348
+ for (let row = 0; row < height; row++)
349
+ import_node_buffer.Buffer.from(rgba.buffer, rgba.byteOffset + row * width * 4, width * 4).copy(raw, row * (width * 4 + 1) + 1);
350
+ return import_node_buffer.Buffer.concat([
351
+ import_node_buffer.Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
352
+ chunk("IHDR", header),
353
+ chunk("IDAT", (0, import_node_zlib.deflateSync)(raw)),
354
+ chunk("IEND", import_node_buffer.Buffer.alloc(0))
355
+ ]);
356
+ }
357
+ function iconPng(name, colour, pixels, strokeWidth) {
358
+ const argb = Number.parseInt(colour, 16);
359
+ const alpha = (argb >>> 24 & 255) / 255;
360
+ const cover = coverage(ICON_PATHS[name], pixels, strokeWidth);
361
+ const rgba = new Uint8Array(pixels * pixels * 4);
362
+ for (let index = 0; index < cover.length; index++) {
363
+ rgba[index * 4] = argb >>> 16 & 255;
364
+ rgba[index * 4 + 1] = argb >>> 8 & 255;
365
+ rgba[index * 4 + 2] = argb & 255;
366
+ rgba[index * 4 + 3] = Math.round(cover[index] * alpha * 255);
367
+ }
368
+ return encodePng(pixels, pixels, rgba);
369
+ }
370
+
81
371
  // src/mark.ts
82
372
  var MARK_PNG = "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAB8klEQVR4nIxSTUhUURQ+3503P07jrk1Bf7QIhsioqRCpiOiHcCIolIQKhvYFQa0Cly3atIgicJ5CGLUoZl5QRPBslfFeRVGbFjWBuFFReT4ddeYez3v6dBRED7z77rnn3O873znXoAYz7X8p9sbuKtBgpf3wx25A0zqGaNNbcto08CwGdfNG/tBn2sCMYOmznKOa6RNAVzZzKWS0bduoeJk/DFQL+VyWNmnqv5+5QMAeIh5sDLyyf2Ua/T7rW6tZdn8ULbeXmWFIiZfAPCNq/Sip33K3dpzaP9rNrHaX3VYdj43Xa/WXAHYQ88/i2+8HDDDtFcYmEO8yS84ZBqWNmbkPAUB24HfaB1qoVn8gqrwldQ5Yn1TCNB+4TDgLxIcF1fSbEtPFsuv5U1VP4o+laQPybWfiIdLJN3J2XEm575loWuaS1Ji/r0GXA1+C1ah0yTnBTJNQRp7U7ENhqahMc+qpbCbCIgidMUa2zjgt6ZYkDwvICIFfS0OOka7dE+YOhnoePgCz7LwTneeXGQJGoiehnkAKc5scXhXkbQL2onAx1xU+gCRwbZboq2x3LjJTWn53QgiOJh4i9hjJ+K1wjsHSlc+NJpA4GKCt6KIva2b+aEtz6vb1cy1+hLPKekrOPulsJ8Bqqds10dhfaD/ytzFvAQAA///wPXGEAAAABklEQVQDACqdwnQigg9+AAAAAElFTkSuQmCC";
83
373
  var MARK_PNG_2X = "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAEk0lEQVR4nLRVbUybVRQ+977vgNJWIX47w2SG+AFztOuME2ZcIsaJLU6zojPTFVQSl2xG4x8z4+IPh8ZkiskiP2gpWdTxx9BC3aaOTP8Q+lJAmV/4MUOmzpHBRvnue8/OLbSjH5SFsSdp773n3vucc+75eFVYAvsReYFfq2bAygViw5DDNrifMQHLBMu06fYFn6PhHTo1y0B92mW3DMJVQk0nbPH1F+ps1kvTzYDYOKbk7d3zRNE0rABSPPR09Jai0I/Txk207HDZbU/CCiLBQ29bz/26rn/PGJgA4Q+jOedZWGHw2KTlWP/NOsdvo8oIgrE3nVtKwrDCiCuMzMw00DPeKOcIMBy5DdvhGiCq0B0I3UdpXx2XIjTX2WyzcA0QjSHTxWsLhYxjT6ZLzb7gMxfVvPZMmdvkD63nIHaT8RVC4dtrK61alNvT+VcOjg3/zxgzx08j2+RybOiCZaAhMJhtjozWA2NxJxBxh2nK1vrTdkAVx4fLpTIE/Iae9VF5gAP+cyXkjZq2Kutf/NRoMuyVCdbU9ouZR0a/ImVlCQcZF1LZnR0hC2fILVHZvDKJCKIhmVy2OG9b0LJQljV2g0LDkJwfDnRdx3m4ExlwREhofeTAyJqjfQUC8AHm9msfUna+kcDO2Vbj+PTJidysVyOqwfPS48XnIQPcPs3KGDaR2aW0PE5xe4Q8yIofUJVCFsG7BOpbKGkwO6Xh6GKz0/nQUY8vWK3MTLzv8WknSOoHhj/KbZwrn7V0r4hWxXR70wKOxxLpsNu11XKaOKrpqc0ySyeSLUbGnqdA7/P4tYMU389IVDH3m2NKNC9j/5dkh+cGfIW4mul52bnkM0Sxxtuh2WscGz+neCQ0AFpfIGOGUu6gWkK7fYnK4AfjVE5jc0foYcoRehE8w7nCu9MZJpDVt7YOZDFd2UkXT8eJmex6sCrVkUhgPoYxw+Qnbcd/pmwmdP0jKeOo/MwxN7+bSuLP5MwiL+8dN0wdcG2zjHKmlpNXvfNb+bR7axobCy47Bn8zUMp2OUpPmfXRQ/SUMrtHDJOWbq5fPH9HoSl8NyloSUPyOiXOQQERs2nK8CARHSDFY7AYECfp/2OTKafEOFUaokSpJ+Nq5o3wO51MZ0RApdFTRgpP0lPxdDwyPvQKuS6HJdjaOWAKhyd3UUyKiWZ1tBEinqHx1KwBvHUVtgtNbaHbORdfgPyAx8AVi6vS0hdPMaqlI6TQubjxFBMGhwRwT63d2p/ujLs9uJYD2yYEvE1nr798GT5xOWx7osbHZJ4ve/NA1QdouhqWxgj9+smKX6mEZAO3EpGMkzGNob8jmqy1VfeMJSic99JKQ1e6LFwOSFlYUdQNL1aW/haTJcSsxmELUYt6ip5gFK4SFPMPyPsXFipLUSjhsm8MkHA9mfcdLB/j9HZfRwCPJW8s2pdk9nrbtZ0IbB8tixL2AN6ii++l3pHFjm6Byru1Vda0n7glGuGcYuqpDiqD3VQf62TRk+wsFfMtMSXEcoKsCOiYfeTlqnVnM/EtqTAZjX4tVwVexEHPZ1wR00JodXbbxJXevwQAAP//kVVCeAAAAAZJREFUAwDo79Or7AZ5mAAAAABJRU5ErkJggg==";
@@ -193,6 +483,9 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
193
483
  this.stopFocus = null;
194
484
  /** Aborts the update download when the instance is disposed. */
195
485
  this.aborts = new AbortController();
486
+ /** Each icon's file, by name, colour, size and stroke; null when it couldn't be written. */
487
+ this.iconFiles = /* @__PURE__ */ new Map();
488
+ this.iconsFailed = false;
196
489
  this.ui = { ...ui, productName };
197
490
  this.endpoint = options.endpoint;
198
491
  this.host = host;
@@ -266,8 +559,8 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
266
559
  const file = import_node_path2.default.join(import_node_path2.default.dirname(this.licenseFile), "moonbase-mark.png");
267
560
  try {
268
561
  import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
269
- writeIfChanged(file, import_node_buffer.Buffer.from(MARK_PNG, "base64"));
270
- writeIfChanged(file.replace(/\.png$/, "@2x.png"), import_node_buffer.Buffer.from(MARK_PNG_2X, "base64"));
562
+ writeIfChanged(file, import_node_buffer2.Buffer.from(MARK_PNG, "base64"));
563
+ writeIfChanged(file.replace(/\.png$/, "@2x.png"), import_node_buffer2.Buffer.from(MARK_PNG_2X, "base64"));
271
564
  this.markFile = file;
272
565
  } catch (err) {
273
566
  this.reportError("moonbaseMark", err);
@@ -275,6 +568,33 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
275
568
  }
276
569
  return this.markFile;
277
570
  }
571
+ /**
572
+ * One of the overlay's icons, in a colour (`AARRGGBB`) and size (points), as
573
+ * an image file, with its `@2x`: drawn the first time it is asked for, into
574
+ * `moonbase-icons` beside the license, for the same reason as the mark. Null
575
+ * when it can't be written, and the overlay goes without it.
576
+ */
577
+ icon(name, colour, size, stroke = 1.8) {
578
+ const key = `${name}-${colour}-${size}-${stroke}`;
579
+ const known = this.iconFiles.get(key);
580
+ if (known !== void 0)
581
+ return known;
582
+ const file = import_node_path2.default.join(import_node_path2.default.dirname(this.licenseFile), "moonbase-icons", `${name}-${colour.toLowerCase()}-${size}-${Math.round(stroke * 10)}.png`);
583
+ let result = file;
584
+ try {
585
+ import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
586
+ writeIfChanged(file, iconPng(name, colour, Math.round(size), stroke));
587
+ writeIfChanged(file.replace(/\.png$/, "@2x.png"), iconPng(name, colour, Math.round(size * 2), stroke));
588
+ } catch (err) {
589
+ if (!this.iconsFailed) {
590
+ this.iconsFailed = true;
591
+ this.reportError("icons", err);
592
+ }
593
+ result = null;
594
+ }
595
+ this.iconFiles.set(key, result);
596
+ return result;
597
+ }
278
598
  /**
279
599
  * Hand a failure to `onError`: the overlay does with every action that
280
600
  * fails, and the module with the host's.
@@ -478,6 +798,7 @@ function createMoonbase(options) {
478
798
  }
479
799
 
480
800
  // src/MoonbaseActivation.ts
801
+ var import_node_os2 = __toESM(require("os"), 1);
481
802
  var import_node_process2 = __toESM(require("process"), 1);
482
803
  var React3 = __toESM(require("react"), 1);
483
804
 
@@ -635,6 +956,64 @@ function describeAddOn(entry, license, state) {
635
956
  // src/elements.ts
636
957
  var React2 = __toESM(require("react"), 1);
637
958
 
959
+ // src/metrics.ts
960
+ var SIZE = 500;
961
+ var CHARACTERS = (() => {
962
+ let characters = "";
963
+ for (let code = 32; code < 127; code++)
964
+ characters += String.fromCharCode(code);
965
+ for (let code = 160; code < 256; code++)
966
+ characters += String.fromCharCode(code);
967
+ return `${characters}\u2026\xB7\u2018\u2019\u201C\u201D\u2013\u20AC`;
968
+ })();
969
+ var advances = /* @__PURE__ */ new Map();
970
+ var measuring = /* @__PURE__ */ new Map();
971
+ function measurer() {
972
+ var _a;
973
+ return (_a = globalThis.GorillaEngine) != null ? _a : null;
974
+ }
975
+ function measureFont(font) {
976
+ var _a;
977
+ const existing = measuring.get(font);
978
+ if (existing)
979
+ return existing;
980
+ const measure = (_a = measurer()) == null ? void 0 : _a.calculateTextWidth;
981
+ if (typeof measure !== "function")
982
+ return Promise.resolve(false);
983
+ const promise = (async () => {
984
+ const table = /* @__PURE__ */ new Map();
985
+ const widths = await Promise.all([...CHARACTERS].map((character) => measure(character, font, SIZE, 0)));
986
+ widths.forEach((width, index) => {
987
+ if (typeof width === "number" && Number.isFinite(width))
988
+ table.set(CHARACTERS[index], width);
989
+ });
990
+ if (!table.has("n"))
991
+ return false;
992
+ advances.set(font, table);
993
+ return true;
994
+ })().catch(() => false);
995
+ measuring.set(font, promise);
996
+ return promise;
997
+ }
998
+ async function measureFonts(fonts) {
999
+ const results = await Promise.all([...new Set(fonts.map((font) => font != null ? font : ""))].map(measureFont));
1000
+ return results.some(Boolean);
1001
+ }
1002
+ function measuredWidth(text2, font, size, kerning = 0) {
1003
+ var _a;
1004
+ const table = advances.get(font != null ? font : "");
1005
+ if (!table)
1006
+ return null;
1007
+ const fallback = table.get("n");
1008
+ let width = 0;
1009
+ let count = 0;
1010
+ for (const character of text2) {
1011
+ width += (_a = table.get(character)) != null ? _a : fallback;
1012
+ count++;
1013
+ }
1014
+ return width * size / SIZE + kerning * size * count;
1015
+ }
1016
+
638
1017
  // src/motion.ts
639
1018
  var React = __toESM(require("react"), 1);
640
1019
  var FRAME = 16;
@@ -785,27 +1164,68 @@ function fontFor(theme, weight, mono = false) {
785
1164
  return medium != null ? medium : regular;
786
1165
  return regular;
787
1166
  }
788
- function textWidth(text2, size, weight = 400) {
789
- return Math.ceil(text2.length * size * (weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52));
1167
+ function textWidth(theme, text2, size, weight = 400, options = {}) {
1168
+ return Math.ceil(exactWidth(theme, text2, size, weight, options));
790
1169
  }
791
- function textHeight(text2, size, width, lineHeight = 1.5) {
1170
+ function exactWidth(theme, text2, size, weight, options = {}) {
1171
+ var _a;
1172
+ const measured = measuredWidth(text2, fontFor(theme, weight, options.mono), size, options.kerning);
1173
+ if (measured !== null)
1174
+ return measured * 1.03;
1175
+ return text2.length * size * ((weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52) + ((_a = options.kerning) != null ? _a : 0));
1176
+ }
1177
+ function lineCount(theme, text2, size, width, weight = 400, mono = false) {
1178
+ const space2 = exactWidth(theme, " ", size, weight, { mono });
792
1179
  let lines = 0;
793
1180
  for (const paragraph2 of text2.split("\n")) {
794
1181
  let line = 0;
795
1182
  lines++;
796
1183
  for (const word of paragraph2.split(" ")) {
797
- const length = textWidth(`${word} `, size);
798
- if (line > 0 && line + length > width) {
1184
+ const length = exactWidth(theme, word, size, weight, { mono });
1185
+ if (line > 0 && line + space2 + length > width) {
799
1186
  lines++;
800
- line = 0;
1187
+ line = length;
1188
+ } else {
1189
+ line += (line > 0 ? space2 : 0) + length;
801
1190
  }
802
- line += length;
803
1191
  }
804
1192
  }
805
- return Math.ceil(lines * size * lineHeight);
1193
+ return lines;
806
1194
  }
1195
+ function textHeight(theme, text2, size, width, lineHeight = 1.5, weight = 400, mono = false) {
1196
+ return Math.ceil(lineCount(theme, text2, size, width, weight, mono) * size * lineHeight);
1197
+ }
1198
+ function fitText(theme, text2, size, width, options = {}) {
1199
+ const fits = (value) => textWidth(theme, value, size, options.weight, { mono: options.mono }) <= width;
1200
+ if (fits(text2))
1201
+ return text2;
1202
+ const characters = [...text2];
1203
+ let keep = characters.length - 1;
1204
+ while (keep > 1) {
1205
+ const value = options.end ? `${characters.slice(0, keep).join("").trimEnd()}\u2026` : `${characters.slice(0, Math.ceil(keep / 2)).join("")}\u2026${characters.slice(characters.length - Math.floor(keep / 2)).join("")}`;
1206
+ if (fits(value))
1207
+ return value;
1208
+ keep--;
1209
+ }
1210
+ return "\u2026";
1211
+ }
1212
+ var BLANK = {
1213
+ text: "",
1214
+ backgroundColor: "00000000",
1215
+ cornerRadius: 0,
1216
+ border: { width: 0, color: "00000000" },
1217
+ alpha: 1,
1218
+ interceptsMouseClicks: false,
1219
+ mouseCursorType: "normal"
1220
+ };
807
1221
  function label(props, ...children) {
808
- return h("geLabel", { interceptsMouseClicks: false, ...props }, ...children);
1222
+ return h("geLabel", { ...BLANK, ...props }, ...children);
1223
+ }
1224
+ function icon(theme, name, x, y, size, colour, stroke = 1.8) {
1225
+ const file = theme.icon(name, colour, size, stroke);
1226
+ if (!file)
1227
+ return null;
1228
+ return h("geLabel", { ...BLANK, key: `icon-${name}`, x, y, width: size, height: size, backgroundImage: file });
809
1229
  }
810
1230
  function each(node) {
811
1231
  return Array.isArray(node) ? node : [node];
@@ -813,7 +1233,7 @@ function each(node) {
813
1233
  function text(theme, value, x, y, width, options = {}) {
814
1234
  var _a, _b, _c, _d, _e, _f;
815
1235
  const size = (_a = options.size) != null ? _a : 14;
816
- const height = textHeight(value, size, width, options.lineHeight);
1236
+ const height = textHeight(theme, value, size, width, options.lineHeight, options.weight, options.mono);
817
1237
  const multiLine = height > size * ((_b = options.lineHeight) != null ? _b : 1.5) * 1.2;
818
1238
  return label({
819
1239
  x,
@@ -847,7 +1267,7 @@ function paragraph(theme, value, width, options = {}) {
847
1267
  var _a, _b, _c;
848
1268
  const size = (_a = options.size) != null ? _a : 14;
849
1269
  const boxWidth = Math.min(width, (_b = options.maxWidth) != null ? _b : width);
850
- const height = Math.max(textHeight(value, size, boxWidth, options.lineHeight), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
1270
+ const height = Math.max(textHeight(theme, value, size, boxWidth, options.lineHeight, options.weight, options.mono), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
851
1271
  return {
852
1272
  height,
853
1273
  render: (x, y, available) => {
@@ -859,8 +1279,16 @@ function paragraph(theme, value, width, options = {}) {
859
1279
  function heading(theme, value, width, options = {}) {
860
1280
  return paragraph(theme, value, width, { size: options.large ? 27 : 24, weight: 600, textColor: palette.textPrimary, lineHeight: 1.25, align: options.align });
861
1281
  }
1282
+ function iconBeside(theme, value, size, weight, width, iconSize, gap) {
1283
+ if (iconSize === null)
1284
+ return { iconX: 0, margin: { left: 0, right: 0, top: 0, bottom: 0 } };
1285
+ if (!value)
1286
+ return { iconX: Math.round((width - iconSize) / 2), margin: { left: 0, right: 0, top: 0, bottom: 0 } };
1287
+ const shift = iconSize + gap;
1288
+ return { iconX: Math.round((width - textWidth(theme, value, size, weight) - shift) / 2), margin: { left: shift, right: 0, top: 0, bottom: 0 } };
1289
+ }
862
1290
  function Button(props) {
863
- var _a, _b, _c;
1291
+ var _a, _b, _c, _d;
864
1292
  const [hovered, setHovered] = React2.useState(false);
865
1293
  const kind = (_a = props.kind) != null ? _a : "primary";
866
1294
  const accent = props.theme.accent;
@@ -874,6 +1302,9 @@ function Button(props) {
874
1302
  };
875
1303
  const look = looks[kind];
876
1304
  const small = kind.startsWith("small") || kind === "danger" || kind === "quiet";
1305
+ const fontSize = (_b = props.size) != null ? _b : small ? 12.5 : 14;
1306
+ const iconSize = props.icon ? (_c = props.iconSize) != null ? _c : small ? 14 : 16 : null;
1307
+ const { iconX, margin } = iconBeside(props.theme, props.label, fontSize, look.weight, props.width, iconSize, small ? 6 : 8);
877
1308
  return label({
878
1309
  x: props.x,
879
1310
  y: props.y,
@@ -881,12 +1312,13 @@ function Button(props) {
881
1312
  height: props.height,
882
1313
  text: props.label,
883
1314
  font: fontFor(props.theme, look.weight),
884
- fontSize: (_b = props.size) != null ? _b : small ? 12.5 : 14,
1315
+ fontSize,
885
1316
  textColor: look.textColor,
886
1317
  textAlign: "center",
1318
+ margin,
887
1319
  backgroundColor: hovered && !props.disabled ? look.hover : look.background,
888
1320
  cornerRadius: small ? 8 : 9,
889
- border: { width: look.border ? 1 : 0, color: (_c = look.border) != null ? _c : palette.transparent },
1321
+ border: { width: look.border ? 1 : 0, color: (_d = look.border) != null ? _d : palette.transparent },
890
1322
  alpha: props.disabled ? 0.5 : 1,
891
1323
  interceptsMouseClicks: true,
892
1324
  mouseCursorType: props.disabled ? "normal" : "pointing hand",
@@ -896,7 +1328,7 @@ function Button(props) {
896
1328
  if (!props.disabled)
897
1329
  props.onClick();
898
1330
  }
899
- });
1331
+ }, props.icon && iconSize && icon(props.theme, props.icon, iconX, Math.round((props.height - iconSize) / 2), iconSize, look.textColor, 1.8));
900
1332
  }
901
1333
  function buttonBlock(theme, value, onClick, options = {}) {
902
1334
  var _a;
@@ -907,27 +1339,35 @@ function buttonBlock(theme, value, onClick, options = {}) {
907
1339
  var _a2;
908
1340
  const width = Math.min(available, (_a2 = options.width) != null ? _a2 : available);
909
1341
  const left = options.align === "center" ? x + (available - width) / 2 : x;
910
- return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, onClick });
1342
+ return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, icon: options.icon, onClick });
911
1343
  }
912
1344
  };
913
1345
  }
1346
+ var LINK_ICON = 14;
1347
+ var LINK_GAP = 6;
1348
+ function linkWidth(theme, value, size = 12.5, withIcon = false) {
1349
+ return textWidth(theme, value, size, 500) + 8 + (withIcon ? LINK_ICON + LINK_GAP : 0);
1350
+ }
914
1351
  function Link(props) {
915
- var _a, _b;
1352
+ var _a, _b, _c;
916
1353
  const [hovered, setHovered] = React2.useState(false);
917
1354
  const size = (_a = props.size) != null ? _a : 12.5;
918
- const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
1355
+ const width = (_b = props.width) != null ? _b : linkWidth(props.theme, props.label, size, !!props.icon);
1356
+ const height = Math.ceil(size * 1.6);
919
1357
  const base = props.link ? palette.link : palette.textSecondary;
920
1358
  const hover = props.link ? palette.linkHover : palette.textBright;
1359
+ const shown = hovered && !props.disabled ? hover : base;
921
1360
  return label({
922
1361
  x: props.x,
923
1362
  y: props.y,
924
1363
  width,
925
- height: Math.ceil(size * 1.6),
1364
+ height,
926
1365
  text: props.label,
927
1366
  font: fontFor(props.theme, 500),
928
1367
  fontSize: size,
929
- textColor: hovered && !props.disabled ? hover : base,
1368
+ textColor: shown,
930
1369
  textAlign: props.align === "center" ? "center" : "centered left",
1370
+ margin: { left: props.icon ? LINK_ICON + LINK_GAP : 0, right: 0, top: 0, bottom: 0 },
931
1371
  alpha: props.disabled ? 0.55 : 1,
932
1372
  interceptsMouseClicks: true,
933
1373
  mouseCursorType: props.disabled ? "normal" : "pointing hand",
@@ -937,7 +1377,7 @@ function Link(props) {
937
1377
  if (!props.disabled)
938
1378
  props.onClick();
939
1379
  }
940
- });
1380
+ }, props.icon && icon(props.theme, props.icon, 0, Math.round((height - LINK_ICON) / 2), LINK_ICON, (_c = props.iconColour) != null ? _c : shown, 1.7));
941
1381
  }
942
1382
  function linksBlock(theme, links, options = {}) {
943
1383
  var _a;
@@ -950,23 +1390,26 @@ function linksBlock(theme, links, options = {}) {
950
1390
  return {
951
1391
  height: marginTop + Math.ceil(size * 1.6),
952
1392
  render: (x, y, width) => {
953
- const widths = items.map((item) => textWidth(item.label, size, 500) + 12);
1393
+ const widths = items.map((item) => linkWidth(theme, item.label, size, !!item.icon));
954
1394
  const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
955
1395
  let left = options.align === "left" ? x : x + (width - total) / 2;
956
1396
  return items.map((item, index) => {
957
- const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], onClick: item.onClick });
1397
+ const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], icon: item.icon, iconColour: item.iconColour, onClick: item.onClick });
958
1398
  left += widths[index] + gap;
959
1399
  return node;
960
1400
  });
961
1401
  }
962
1402
  };
963
1403
  }
964
- function pill(theme, tone, value, x, y, onClick) {
1404
+ function pill(theme, tone, value, x, y, onClick, withIcon) {
965
1405
  const upper = tone === "trial" || tone === "expired" || tone === "upgrade";
966
1406
  const shown = upper ? value.toUpperCase() : value;
967
1407
  const size = upper ? 10.5 : 11.5;
1408
+ const kerning = upper ? 0.08 : 0.02;
968
1409
  const dot = tone === "expired" || tone === "upgrade" || tone === "active";
969
- const width = Math.ceil(textWidth(shown, size, 700) * (upper ? 1.18 : 1) + (upper ? shown.length * size * 0.08 : 0)) + 24 + (dot ? 12 : 0);
1410
+ const lead = dot ? 12 : withIcon ? 19 : 0;
1411
+ const textBox = textWidth(theme, shown, size, 700, { kerning }) + 4;
1412
+ const width = textBox + 22 + lead;
970
1413
  const height = 24;
971
1414
  const looks = {
972
1415
  trial: { background: color(palette.trial), border: palette.transparent, textColor: color("#131519") },
@@ -988,15 +1431,15 @@ function pill(theme, tone, value, x, y, onClick) {
988
1431
  interceptsMouseClicks: !!onClick,
989
1432
  mouseCursorType: onClick ? "pointing hand" : "normal",
990
1433
  ...onClick && { onClick }
991
- }, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), label({
992
- x: dot ? 22 : 10,
1434
+ }, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), withIcon && icon(theme, withIcon, 10, (height - 13) / 2, 13, color(theme.accent), 1.9), label({
1435
+ x: 11 + lead,
993
1436
  y: 0,
994
- width: width - (dot ? 32 : 20),
1437
+ width: textBox,
995
1438
  height,
996
1439
  text: shown,
997
1440
  font: fontFor(theme, 700),
998
1441
  fontSize: size,
999
- fontKerning: upper ? 0.08 : 0.02,
1442
+ fontKerning: kerning,
1000
1443
  textColor: look.textColor,
1001
1444
  textAlign: "center"
1002
1445
  }));
@@ -1004,6 +1447,8 @@ function pill(theme, tone, value, x, y, onClick) {
1004
1447
  }
1005
1448
  function card(props, ...children) {
1006
1449
  var _a, _b, _c;
1450
+ if (props.onClick)
1451
+ return h(ClickableCard, { ...props, onClick: props.onClick }, ...children);
1007
1452
  return label({
1008
1453
  x: props.x,
1009
1454
  y: props.y,
@@ -1011,11 +1456,27 @@ function card(props, ...children) {
1011
1456
  height: props.height,
1012
1457
  backgroundColor: (_a = props.background) != null ? _a : palette.card,
1013
1458
  cornerRadius: (_b = props.radius) != null ? _b : 12,
1014
- border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
1015
- interceptsMouseClicks: !!props.onClick,
1016
- ...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
1459
+ border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
1017
1460
  }, ...children);
1018
1461
  }
1462
+ function ClickableCard(props) {
1463
+ var _a, _b, _c;
1464
+ const [hovered, setHovered] = React2.useState(false);
1465
+ return label({
1466
+ x: props.x,
1467
+ y: props.y,
1468
+ width: props.width,
1469
+ height: props.height,
1470
+ backgroundColor: hovered ? color("#ffffff", 0.05) : (_a = props.background) != null ? _a : palette.card,
1471
+ cornerRadius: (_b = props.radius) != null ? _b : 12,
1472
+ border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
1473
+ interceptsMouseClicks: true,
1474
+ mouseCursorType: "pointing hand",
1475
+ onMouseEnter: () => setHovered(true),
1476
+ onMouseExit: () => setHovered(false),
1477
+ onClick: props.onClick
1478
+ }, ...React2.Children.toArray(props.children));
1479
+ }
1019
1480
  var SCROLLBAR = 6;
1020
1481
  function scrollView(props, contentHeight, ...children) {
1021
1482
  return h("geScrollView", {
@@ -1215,6 +1676,24 @@ function useUiState(moonbase) {
1215
1676
  }, [moonbase]);
1216
1677
  return ui;
1217
1678
  }
1679
+ function useFontMetrics(ui) {
1680
+ var _a;
1681
+ const [measured, setMeasured] = React3.useState(0);
1682
+ const { regular, medium, semibold, mono } = (_a = ui.fonts) != null ? _a : {};
1683
+ React3.useEffect(() => {
1684
+ var _a2;
1685
+ let live = true;
1686
+ measureFonts([regular, medium != null ? medium : regular, (_a2 = semibold != null ? semibold : medium) != null ? _a2 : regular, mono != null ? mono : regular]).then((known) => {
1687
+ if (live && known)
1688
+ setMeasured((count) => count + 1);
1689
+ }, () => {
1690
+ });
1691
+ return () => {
1692
+ live = false;
1693
+ };
1694
+ }, [regular, medium, semibold, mono]);
1695
+ return measured;
1696
+ }
1218
1697
  function statusView(state) {
1219
1698
  switch (state.status) {
1220
1699
  case "unlicensed":
@@ -1233,6 +1712,28 @@ function statusView(state) {
1233
1712
  return "loading";
1234
1713
  }
1235
1714
  }
1715
+ function requestedView(screen, state) {
1716
+ const next = screen === "license" ? "details" : screen;
1717
+ if ((next === "details" || next === "addons") && !state.license)
1718
+ return null;
1719
+ return next;
1720
+ }
1721
+ function followState(view, before, state) {
1722
+ var _a;
1723
+ let next = view;
1724
+ const activated = before.status === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a = before.license) == null ? void 0 : _a.activationId);
1725
+ if (activated)
1726
+ next = "success";
1727
+ if ((next === "details" || next === "addons" || next === "update") && !state.license)
1728
+ next = null;
1729
+ if (state.status === "activating")
1730
+ next = null;
1731
+ if (state.status === "notCovered" && before.status !== "notCovered")
1732
+ next = null;
1733
+ if (next === "success" && !state.license)
1734
+ next = null;
1735
+ return next;
1736
+ }
1236
1737
  function droppedFiles(dropped) {
1237
1738
  if (typeof dropped === "string")
1238
1739
  return [dropped];
@@ -1241,22 +1742,30 @@ function droppedFiles(dropped) {
1241
1742
  const files = dropped == null ? void 0 : dropped.files;
1242
1743
  return Array.isArray(files) ? files.filter((file) => typeof file === "string") : [];
1243
1744
  }
1745
+ function displayPath(file) {
1746
+ const home = import_node_os2.default.homedir();
1747
+ return home && file.startsWith(home) ? `~${file.slice(home.length)}` : file;
1748
+ }
1244
1749
  function Panel({ moonbase, state, screen, request, download, width: areaWidth, height: areaHeight }) {
1245
1750
  var _a, _b, _c, _d, _e;
1246
1751
  const ui = moonbase.ui;
1247
- const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {} };
1752
+ const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {}, icon: (name2, colour, size, stroke) => moonbase.icon(name2, colour, size, stroke) };
1248
1753
  const product = (_c = ui.productName) != null ? _c : "the plugin";
1249
1754
  const account = ui.manufacturerName || "Moonbase";
1250
1755
  const strings = (_d = ui.strings) != null ? _d : {};
1251
1756
  const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
1252
1757
  const width = cardWidth - PAD_X * 2;
1253
1758
  const still = !!ui.reduceMotion;
1254
- const [view, setView] = React3.useState(null);
1759
+ const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
1760
+ const footer = showBadge ? 30 + 18 + 18 : 8;
1761
+ const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
1762
+ const [view, setView] = React3.useState(() => requestedView(screen, state));
1255
1763
  const [update, setUpdate] = React3.useState(null);
1256
1764
  const [cameFromDetails, setCameFromDetails] = React3.useState(false);
1257
1765
  const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
1258
1766
  const [copied, setCopied] = React3.useState(null);
1259
- const previous = React3.useRef(null);
1767
+ const [seen, setSeen] = React3.useState({ state, request });
1768
+ const previous = React3.useRef(state);
1260
1769
  const run2 = (name2, action) => {
1261
1770
  action().catch((err) => moonbase.reportError(name2, err));
1262
1771
  };
@@ -1279,38 +1788,38 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1279
1788
  };
1280
1789
  const flashCopied = (what) => {
1281
1790
  setCopied(what);
1282
- setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
1791
+ setTimeout(() => setCopied((current2) => current2 === what ? null : current2), 2e3);
1283
1792
  };
1793
+ let current = view;
1794
+ if (seen.request !== request || seen.state !== state) {
1795
+ let next = view;
1796
+ if (seen.request !== request) {
1797
+ next = requestedView(screen, state);
1798
+ if (screen === "update") {
1799
+ setCameFromDetails(false);
1800
+ setUpdate(null);
1801
+ }
1802
+ }
1803
+ if (seen.state !== state)
1804
+ next = followState(next, seen.state, state);
1805
+ setSeen({ state, request });
1806
+ if (next !== view)
1807
+ setView(next);
1808
+ current = next;
1809
+ }
1284
1810
  React3.useEffect(() => {
1285
1811
  if (screen === "update")
1286
- return openUpdate(false);
1287
- let next = screen === "license" ? "details" : screen;
1288
- if ((next === "details" || next === "addons") && !moonbase.state().license)
1289
- next = null;
1290
- go(next);
1812
+ loadUpdate();
1813
+ else if (requestedView(screen, moonbase.state()) === "addons")
1814
+ run2("loadAddOns", () => moonbase.loadAddOns());
1291
1815
  }, [request]);
1292
1816
  React3.useEffect(() => {
1293
- var _a2;
1294
1817
  const before = previous.current;
1295
1818
  previous.current = state;
1296
- let next = view;
1297
- const activated = (before == null ? void 0 : before.status) === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a2 = before.license) == null ? void 0 : _a2.activationId);
1298
- if (activated)
1299
- next = "success";
1300
- if ((next === "details" || next === "addons" || next === "update") && !state.license)
1301
- next = null;
1302
- if (state.status === "activating")
1303
- next = null;
1304
- if (state.status === "notCovered" && (before == null ? void 0 : before.status) !== "notCovered")
1305
- next = null;
1306
- if (next === "success" && !state.license)
1307
- next = null;
1308
- if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
1819
+ if (current === "addons" && state.license && state.addOns.phase === "idle" && before.addOns.phase !== "idle")
1309
1820
  run2("loadAddOns", () => moonbase.loadAddOns());
1310
- if (next !== view)
1311
- setView(next);
1312
1821
  }, [state]);
1313
- const name = view != null ? view : statusView(state);
1822
+ const name = current != null ? current : statusView(state);
1314
1823
  const lockup = (options = {}) => {
1315
1824
  const size = options.large ? 38 : 34;
1316
1825
  return {
@@ -1324,9 +1833,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1324
1833
  const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
1325
1834
  let right = x + available - (canClose ? 40 : 0);
1326
1835
  for (const each2 of [...pills].reverse()) {
1327
- const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
1836
+ const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick, each2.icon);
1328
1837
  right -= drawn.width;
1329
- nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
1838
+ nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick, each2.icon).node);
1330
1839
  right -= 8;
1331
1840
  }
1332
1841
  return nodes;
@@ -1335,12 +1844,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1335
1844
  const errorLine = (message) => {
1336
1845
  if (!message)
1337
1846
  return null;
1338
- const body = paragraph(theme, `\u26A0 ${message}`, width, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
1339
- return { height: 14 + body.height, render: (x, y, available) => body.render(x, y + 14, available) };
1847
+ const body = paragraph(theme, message, width - 22, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
1848
+ return {
1849
+ height: 14 + body.height,
1850
+ render: (x, y, available) => [icon(theme, "warning", x, y + 16, 15, palette.warningText), body.render(x + 22, y + 14, available - 22)]
1851
+ };
1340
1852
  };
1341
1853
  const backLink = (value, onClick) => ({
1342
1854
  height: 20 + 12,
1343
- render: (x, y) => h(LinkNode, { key: "back", theme, x, y, value: `\u2039 ${value}`, onClick })
1855
+ render: (x, y) => h(Link, { key: "back", theme, x, y, label: value, icon: "back", onClick })
1344
1856
  });
1345
1857
  const notice = (value, tone) => {
1346
1858
  const body = paragraph(theme, value, width - 58, { size: 13, textColor: palette.textBody, lineHeight: 1.5 });
@@ -1348,7 +1860,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1348
1860
  const tint = tone === "upgrade" ? palette.trial : palette.errorStrong;
1349
1861
  return {
1350
1862
  height: height + 24,
1351
- render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, text(theme, tone === "upgrade" ? "\u26A0" : "\u2298", 15, 12, 20, { size: 15, textColor: color(tone === "upgrade" ? palette.trial : palette.error) }), body.render(44, 13, width - 58))
1863
+ render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, icon(theme, tone === "upgrade" ? "warning" : "blocked", 15, 13, 18, color(tone === "upgrade" ? palette.trial : palette.error)), body.render(44, 13, width - 58))
1352
1864
  };
1353
1865
  };
1354
1866
  const features = () => {
@@ -1358,10 +1870,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1358
1870
  return null;
1359
1871
  return {
1360
1872
  height: list.length * 30 - 11 + 26,
1361
- render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, text(theme, feature.included ? "\u2713" : "\xD7", 0, 0, 20, { size: 14, weight: 700, textColor: feature.included ? color(palette.success) : palette.textMuted }), text(theme, feature.label, 28, 0, width - 28, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted })))
1873
+ render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, icon(theme, feature.included ? "check" : "cross", 0, 1, 17, feature.included ? color(palette.success) : palette.textMuted, 2), text(theme, feature.label, 27, 0, width - 27, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted, height: 20 })))
1362
1874
  };
1363
1875
  };
1364
- const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()));
1876
+ const below = (top2, block) => ({ height: top2 + block.height, render: (x, y, available) => block.render(x, y + top2, available) });
1877
+ const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()), { icon: "lock" });
1365
1878
  const screens = {
1366
1879
  loading: () => [
1367
1880
  { height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
@@ -1381,7 +1894,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1381
1894
  space(28),
1382
1895
  buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
1383
1896
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1384
- linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
1897
+ linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", icon: "signal", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
1385
1898
  ];
1386
1899
  },
1387
1900
  browser: () => {
@@ -1407,20 +1920,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1407
1920
  space(8),
1408
1921
  paragraph(theme, body, width, { align: "center", maxWidth: 420 }),
1409
1922
  space(22),
1410
- failed && buttonBlock(theme, linkCopied ? "\u2713 Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center" }),
1923
+ failed && buttonBlock(theme, linkCopied ? "Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center", icon: linkCopied ? "check" : "copy" }),
1411
1924
  failed && space(18),
1412
1925
  !!url && {
1413
1926
  height: 50,
1414
1927
  render: (x, y, available) => {
1415
1928
  const value = `${moonbase.deviceName} \xB7 ${osLabel()}`;
1416
- const chipWidth = Math.min(available, textWidth(value, 12.5) + 30);
1417
- return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, text(theme, value, 0, 0, chipWidth, { size: 12.5, textColor: palette.textBright, align: "center", height: 34 }));
1929
+ const textBox = Math.min(available - 54, textWidth(theme, value, 12.5));
1930
+ const chipWidth = textBox + 15 + 9 + 30;
1931
+ return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, icon(theme, "computer", 15, 9, 15, palette.textSecondary, 1.6), text(theme, fitText(theme, value, 12.5, textBox, { end: true }), 39, 0, textBox, { size: 12.5, textColor: palette.textBright, height: 34 }));
1418
1932
  }
1419
1933
  },
1420
1934
  buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
1421
1935
  !!url && !failed && linksBlock(theme, [
1422
1936
  { label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
1423
- { label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
1937
+ { label: linkCopied ? "Link copied" : "Browser didn't open? Copy the link", link: true, icon: linkCopied ? "check" : "copy", iconColour: linkCopied ? color(palette.success) : void 0, onClick: copyLink }
1424
1938
  ]),
1425
1939
  errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
1426
1940
  ];
@@ -1429,7 +1943,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1429
1943
  const license = state.license;
1430
1944
  if (!license)
1431
1945
  return screens[statusView(state)]();
1432
- const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]];
1946
+ const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]].filter(([, value]) => !!value);
1433
1947
  return [
1434
1948
  {
1435
1949
  height: 66 + 6,
@@ -1444,7 +1958,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1444
1958
  height: rows.length * 34 + 32 + 26,
1445
1959
  render: (x, y, available) => {
1446
1960
  const cardWidth2 = Math.min(380, available);
1447
- return card({ x: x + (available - cardWidth2) / 2, y, width: cardWidth2, height: rows.length * 34 + 32 }, ...rows.map(([key, value], index) => label({ key, x: 18, y: 16 + index * 34, width: cardWidth2 - 36, height: 34 }, text(theme, key, 0, 0, 120, { size: 12.5, height: 34 }), text(theme, value, 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
1961
+ return card({ x: x + (available - cardWidth2) / 2, y, width: cardWidth2, height: rows.length * 34 + 32 }, ...rows.map(([key, value], index) => label({ key, x: 18, y: 16 + index * 34, width: cardWidth2 - 36, height: 34 }, text(theme, key, 0, 0, 120, { size: 12.5, height: 34 }), text(theme, fitText(theme, value, 13, cardWidth2 - 156, { weight: 500, end: true }), 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
1448
1962
  }
1449
1963
  },
1450
1964
  buttonBlock(theme, `Open ${product}`, close, { width: 380, align: "center" }),
@@ -1452,24 +1966,25 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1452
1966
  ];
1453
1967
  },
1454
1968
  offline: () => {
1455
- const saveSub = offline.saved ? `Saved to ${offline.saved}` : "Choose where to save it";
1456
1969
  const requestFile = `${(product || "license").replace(/[\\/:*?"<>|]/g, "-")}.dt`;
1970
+ const textBox = width - 16 - 22 - 12 - 76;
1971
+ const saveSub = offline.saved ? fitText(theme, `Saved to ${displayPath(offline.saved)}`, 11.5, textBox) : "Choose where to save it";
1457
1972
  const saveRequest = () => {
1458
- setOffline((current) => ({ ...current, error: "" }));
1973
+ setOffline((current2) => ({ ...current2, error: "" }));
1459
1974
  moonbase.saveMachineFile().then(
1460
- (saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
1975
+ (saved) => setOffline((current2) => ({ ...current2, saved: saved != null ? saved : current2.saved })),
1461
1976
  (err) => {
1462
1977
  moonbase.reportError("saveMachineFile", err);
1463
- setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }));
1978
+ setOffline((current2) => ({ ...current2, error: err instanceof Error ? err.message : String(err) }));
1464
1979
  }
1465
1980
  );
1466
1981
  };
1467
1982
  const useFile = (pick) => {
1468
1983
  pick.then(
1469
- (file) => file && setOffline((current) => ({ ...current, file, error: "" })),
1984
+ (file) => file && setOffline((current2) => ({ ...current2, file, error: "" })),
1470
1985
  (err) => {
1471
1986
  moonbase.reportError("readLicenseFile", err);
1472
- setOffline((current) => ({ ...current, error: "Couldn't read that file." }));
1987
+ setOffline((current2) => ({ ...current2, error: "Couldn't read that file." }));
1473
1988
  }
1474
1989
  );
1475
1990
  };
@@ -1477,24 +1992,28 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1477
1992
  if (offline.busy)
1478
1993
  return;
1479
1994
  if (!offline.file) {
1480
- setOffline((current) => ({ ...current, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
1995
+ setOffline((current2) => ({ ...current2, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
1481
1996
  return;
1482
1997
  }
1483
- setOffline((current) => ({ ...current, busy: true, error: "" }));
1998
+ setOffline((current2) => ({ ...current2, busy: true, error: "" }));
1484
1999
  moonbase.activateOffline(offline.file.text).then(() => {
1485
2000
  setOffline({ saved: null, file: null, busy: false, error: "" });
1486
2001
  setView("success");
1487
2002
  }, () => {
1488
- setOffline((current) => {
2003
+ setOffline((current2) => {
1489
2004
  var _a2;
1490
- return { ...current, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
2005
+ return { ...current2, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
1491
2006
  });
1492
2007
  });
1493
2008
  };
1494
2009
  const step = (n, value) => ({
1495
2010
  height: 20 + 10,
1496
- render: (x, y) => label({ key: `step-${n}`, x, y, width, height: 20 }, label({ x: 0, y: 0, width: 20, height: 20, cornerRadius: 10, backgroundColor: color(theme.accent), text: n, fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
2011
+ render: (x, y) => label({ key: `step-${n}`, x, y, width, height: 20 }, label({ x: 0, y: 0, width: 20, height: 20, cornerRadius: 10, backgroundColor: color(theme.accent), text: n, font: fontFor(theme, 600), fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
1497
2012
  });
2013
+ const dropTitle = offline.file ? fitText(theme, offline.file.name, 13, width - 120, { mono: true }) : "Drop your license file here";
2014
+ const dropSub = offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb";
2015
+ const dropText = Math.max(textWidth(theme, dropTitle, 13, offline.file ? 400 : 500, { mono: !!offline.file }), textWidth(theme, dropSub, 11.5));
2016
+ const dropLeft = Math.round((width - 24 - 12 - dropText) / 2);
1498
2017
  return [
1499
2018
  backLink("Back", () => go(null)),
1500
2019
  heading(theme, "Offline activation", width),
@@ -1504,7 +2023,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1504
2023
  step("1", "Save your request file"),
1505
2024
  {
1506
2025
  height: 52 + 16,
1507
- render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, text(theme, requestFile, 16, 7, width - 120, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 16, 27, width - 120, { size: 11.5, textColor: palette.textSecondary }), text(theme, offline.saved ? "\u2713" : "Save\u2026", width - 80, 0, 64, { size: offline.saved ? 18 : 12.5, weight: 600, textColor: offline.saved ? color(palette.success) : palette.link, align: "right", height: 52 }))
2026
+ render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, icon(theme, "fileDown", 16, 15, 22, palette.glow, 1.6), text(theme, requestFile, 50, 7, textBox, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 50, 27, textBox, { size: 11.5, textColor: palette.textSecondary, height: 18 }), offline.saved ? icon(theme, "check", width - 16 - 20, 16, 20, color(palette.success), 2) : text(theme, "Save\u2026", width - 80, 0, 64, { size: 12, weight: 500, textColor: palette.glow, align: "right", height: 52 }))
1508
2027
  },
1509
2028
  step("2", "Add the license file"),
1510
2029
  {
@@ -1520,7 +2039,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1520
2039
  if (file)
1521
2040
  useFile(moonbase.readLicenseFile(file));
1522
2041
  }
1523
- }, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, text(theme, offline.file ? offline.file.name : "Drop your license file here", 0, 15, width, { size: 13, weight: 600, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody, align: "center" }), text(theme, offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb", 0, 38, width, { size: 11.5, textColor: palette.textSecondary, align: "center" })))
2042
+ }, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, offline.file ? icon(theme, "okCircle", dropLeft, 24, 24, color(palette.success), 1.7) : icon(theme, "upload", dropLeft, 24, 24, palette.textSecondary, 1.6), text(theme, dropTitle, dropLeft + 36, 15, dropText + 4, { size: 13, weight: offline.file ? 400 : 500, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody }), text(theme, dropSub, dropLeft + 36, 38, dropText + 4, { size: 11.5, textColor: palette.textSecondary })))
1524
2043
  },
1525
2044
  errorLine(offline.error),
1526
2045
  space(16),
@@ -1576,7 +2095,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1576
2095
  paragraph(theme, body, width),
1577
2096
  space(22),
1578
2097
  notice(`${product} is locked. Your license still works with the versions it covers, so you can go back to one of those, or upgrade to use this one.`, "upgrade"),
1579
- buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
2098
+ buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }),
1580
2099
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1581
2100
  linksBlock(theme, [offlineLicense ? { label: "Load an upgraded license file", onClick: () => go("offline") } : { label: state.refreshing ? "Checking your license\u2026" : renewal ? "Already renewed? Check again" : "Already upgraded? Check again", disabled: state.refreshing, onClick: () => run2("refresh", () => moonbase.refresh()) }])
1582
2101
  ];
@@ -1590,7 +2109,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1590
2109
  ["Licensed to", license.issuedTo.name || license.issuedTo.email],
1591
2110
  ["Email", license.issuedTo.email],
1592
2111
  ["Plan", `${planName(license)} \xB7 ${license.expiresAt ? `until ${formatDate(license.expiresAt)}` : "perpetual"}`]
1593
- ];
2112
+ ].filter(([, value]) => !!value);
1594
2113
  const seatCount = license.seatCount;
1595
2114
  const used = license.seatsUsed;
1596
2115
  const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
@@ -1598,14 +2117,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1598
2117
  const seatsTitle = seatCount ? `Activations \xB7 ${used != null ? used : "?"} of ${seatCount} ${seatCount === 1 ? "device" : "devices"}` : license.activationMethod === "Offline" ? "Activated offline on this device" : "Activated on this device";
1599
2118
  const idCopied = copied === license.id;
1600
2119
  const rowHeight = 44;
2120
+ const valueWidth = width - 172;
1601
2121
  return [
1602
2122
  header([
1603
- ...state.update ? [{ tone: "update", text: "\u2193 Update", onClick: () => openUpdate(true) }] : [],
2123
+ ...state.update ? [{ tone: "update", text: "Update", icon: "download", onClick: () => openUpdate(true) }] : [],
1604
2124
  { tone: "active", text: license.trial ? "Trial" : "Active" }
1605
2125
  ]),
1606
2126
  {
1607
2127
  height: (rows.length + 1) * rowHeight + 2 + 18,
1608
- render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, value, 140, 0, width - 172, { size: 13, weight: 500, textColor: index === 1 ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 84, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 74, y: 7, width: 74, height: 30, label: idCopied ? "\u2713 Copied" : "Copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
2128
+ render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, fitText(theme, value, 13, valueWidth, { weight: 500, end: key !== "Email" }), 140, 0, valueWidth, { size: 13, weight: 500, textColor: key === "Email" ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 96, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 86, y: 7, width: 86, height: 30, label: idCopied ? "Copied" : "Copy", icon: idCopied ? "check" : "copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
1609
2129
  },
1610
2130
  {
1611
2131
  height: 64 + 22,
@@ -1625,7 +2145,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1625
2145
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1626
2146
  ui.showAddOns && !license.trial && {
1627
2147
  height: 62 + (state.error ? 14 : 0),
1628
- render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, text(theme, "Add-ons", 16, 12, width - 80, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 16, 32, width - 80, { size: 12, textColor: palette.textSecondary }), text(theme, "\u203A", width - 36, 0, 20, { size: 22, textColor: palette.textSecondary, align: "center", height: 62 }))
2148
+ render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, icon(theme, "puzzle", 16, 21, 20, color(theme.accent), 1.7), text(theme, "Add-ons", 49, 12, width - 100, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 49, 32, width - 100, { size: 12, textColor: palette.textSecondary }), icon(theme, "chevron", width - 16 - 18, 22, 18, palette.textSecondary, 2))
1629
2149
  }
1630
2150
  ];
1631
2151
  },
@@ -1655,7 +2175,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1655
2175
  }
1656
2176
  };
1657
2177
  } else if (info.phase !== "ready") {
1658
- list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight })) };
2178
+ list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight }, label({ x: 16, y: 13, width: 38, height: 38, cornerRadius: 10, backgroundColor: color("#ffffff", 0.05) }), label({ x: 68, y: 21, width: Math.round(width * 0.34), height: 10, cornerRadius: 5, backgroundColor: color("#ffffff", 0.07) }), label({ x: 68, y: 40, width: Math.round(width * 0.52), height: 8, cornerRadius: 4, backgroundColor: color("#ffffff", 0.07) }))) };
1659
2179
  } else if (failed) {
1660
2180
  list = (_a2 = errorLine(info.error)) != null ? _a2 : space(0);
1661
2181
  } else {
@@ -1674,7 +2194,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1674
2194
  link: true,
1675
2195
  disabled: loading || waiting,
1676
2196
  onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1677
- }], { align: "left" })
2197
+ }], { align: "left", marginTop: 18 })
1678
2198
  ];
1679
2199
  },
1680
2200
  update: () => {
@@ -1702,41 +2222,30 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1702
2222
  const notCovered = update.covered === false || download.phase === "notCovered";
1703
2223
  const access = (_a2 = download.releaseAccess) != null ? _a2 : update.releaseAccess;
1704
2224
  const upgradeUrl = (_b2 = download.upgradeUrl) != null ? _b2 : update.upgradeUrl;
1705
- const noteBlocks = notes.map((note) => paragraph(theme, note, width - 70, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
1706
- const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
1707
2225
  let action;
1708
2226
  if (download.phase === "done")
1709
- action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
2227
+ action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()), { icon: "download" });
1710
2228
  else if (notCovered)
1711
- action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
2229
+ action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }) : null;
1712
2230
  else if (update.canDownload)
1713
- action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
2231
+ action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading, icon: downloading ? void 0 : "download" });
1714
2232
  else
1715
2233
  action = update.hasDownloads ? unlock() : null;
1716
2234
  const standing = notCovered ? ", which your license doesn't cover." : !update.hasDownloads ? ", which has no download for this computer yet." : update.canDownload ? ", included in your license." : ", which your license doesn't include yet.";
1717
- return [
2235
+ const above = [
1718
2236
  lockup(),
1719
2237
  space(24),
1720
- { height: 24 + 14, render: (x, y) => pill(theme, "update", "\u2193 Update available", x, y).node },
2238
+ { height: 24 + 14, render: (x, y) => pill(theme, "update", "Update available", x, y, void 0, "download").node },
1721
2239
  heading(theme, `${product} ${update.latestVersion} is ready`, width),
1722
2240
  space(8),
1723
2241
  paragraph(theme, `You're on ${update.currentVersion || "an earlier version"}. The latest is ${update.latestVersion}${standing}`, width),
1724
- space(20),
1725
- notes.length > 0 && {
1726
- height: notesHeight + 20,
1727
- render: (x, y) => {
1728
- let top2 = 44;
1729
- return card({ x, y, width, height: notesHeight }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), ...noteBlocks.map((block, index) => {
1730
- const node = label({ key: `note-${index}`, x: 18, y: top2, width: width - 36, height: block.height }, text(theme, "\u2713", 0, 0, 18, { size: 13, weight: 700, textColor: color(theme.accent) }), block.render(28, 0, width - 70));
1731
- top2 += block.height + 8;
1732
- return node;
1733
- }));
1734
- }
1735
- },
2242
+ space(20)
2243
+ ];
2244
+ const after = [
1736
2245
  downloading && barBlock(percent !== null ? percent / 100 : 0.08, color(theme.accent), { marginTop: 0, marginBottom: 14 }),
1737
2246
  action,
1738
- download.phase === "done" && !!download.path && { ...paragraph(theme, `Saved to ${download.path}`, width, { size: 12.5, align: "center" }), height: 12 + 20 },
1739
- notCovered && paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted }),
2247
+ download.phase === "done" && !!download.path && below(12, paragraph(theme, fitText(theme, `Saved to ${displayPath(download.path)}`, 12.5, width), width, { size: 12.5, align: "center" })),
2248
+ notCovered && below(16, paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted })),
1740
2249
  errorLine(download.phase === "failed" ? download.error : null),
1741
2250
  linksBlock(theme, [
1742
2251
  { label: "Remind me later", onClick: back },
@@ -1746,6 +2255,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1746
2255
  } }
1747
2256
  ])
1748
2257
  ];
2258
+ const noteWidth = width - 36 - 26 - SCROLLBAR - 4;
2259
+ const noteBlocks = notes.map((note) => paragraph(theme, note, noteWidth, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
2260
+ const listNatural = noteBlocks.reduce((sum, block) => sum + block.height, 0) + Math.max(0, noteBlocks.length - 1) * 10;
2261
+ const chrome = 16 + 17 + 12 + 16 + 22;
2262
+ const taken = [...above, ...after].reduce((sum, block) => sum + (block ? block.height : 0), 0);
2263
+ const listHeight = Math.min(listNatural, 190, Math.max(Math.min(listNatural, 40), room - taken - chrome));
2264
+ const listScrolls = listHeight < listNatural;
2265
+ const notesBlock = notes.length > 0 && {
2266
+ height: listHeight + chrome,
2267
+ render: (x, y) => {
2268
+ let top2 = 0;
2269
+ const rowWidth = width - 36 - (listScrolls ? SCROLLBAR + 4 : 0);
2270
+ const rows = noteBlocks.map((block, index) => {
2271
+ const node = label({ key: `note-${index}`, x: 0, y: top2, width: rowWidth, height: block.height }, icon(theme, "check", 0, 2, 16, color(theme.accent), 2), block.render(26, 0, rowWidth - 26));
2272
+ top2 += block.height + 10;
2273
+ return node;
2274
+ });
2275
+ return card({ x, y, width, height: listHeight + chrome - 22 }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), listScrolls ? scrollView({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, listNatural, ...rows) : label({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, ...rows));
2276
+ }
2277
+ };
2278
+ return [...above, notesBlock, ...after];
1749
2279
  }
1750
2280
  };
1751
2281
  const addOnActions = {
@@ -1762,19 +2292,16 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1762
2292
  const buttons = actions.reverse().map((action) => {
1763
2293
  const primary = action === row.primary;
1764
2294
  const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
1765
- const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
2295
+ const buttonWidth = Math.max(76, textWidth(theme, value, 13, 600) + 32);
1766
2296
  right -= buttonWidth;
1767
2297
  const node = h(Button, { key: action, theme, x: right, y: (rowHeight - 34) / 2, width: buttonWidth, height: 34, size: 13, label: value, kind: primary ? "small-primary" : "small-ghost", disabled: anyBusy, onClick: () => run2(action, () => addOnActions[action].run(row.id)) });
1768
2298
  right -= 8;
1769
2299
  return node;
1770
2300
  });
1771
- return card({ x, y, width: rowWidth, height: rowHeight, background: tint ? color(tint, 0.04) : palette.card, border: tint ? color(tint, 0.25) : palette.cardBorder }, label({ x: 16, y: (rowHeight - 38) / 2, width: 38, height: 38, cornerRadius: 10, backgroundColor: tint ? color(tint, 0.12) : color("#ffffff", 0.05), text: row.tone === "success" ? "\u2713" : "\u2726", fontSize: 16, textColor: tint ? color(tint) : palette.textSecondary, textAlign: "center" }), text(theme, row.name, 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, row.status, 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
2301
+ return card({ x, y, width: rowWidth, height: rowHeight, background: tint ? color(tint, 0.04) : palette.card, border: tint ? color(tint, 0.25) : palette.cardBorder }, label({ x: 16, y: (rowHeight - 38) / 2, width: 38, height: 38, cornerRadius: 10, backgroundColor: tint ? color(tint, 0.12) : color("#ffffff", 0.05) }, icon(theme, row.tone === "success" ? "check" : "sparkles", 9, 9, 20, tint ? color(tint) : palette.textSecondary, 1.7)), text(theme, fitText(theme, row.name, 14, right - 76, { weight: 600, end: true }), 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, fitText(theme, row.status, 12.5, right - 76, { end: true }), 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
1772
2302
  }
1773
2303
  const blocks = screens[name]();
1774
- const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
1775
- const footer = showBadge ? 30 + 18 + 18 : 8;
1776
2304
  const screenHeight = blocks.reduce((sum, block) => sum + (block ? block.height : 0), 0);
1777
- const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
1778
2305
  const scrolls = screenHeight > room;
1779
2306
  let content;
1780
2307
  if (scrolls) {
@@ -1795,7 +2322,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1795
2322
  screen: name,
1796
2323
  contentHeight: content.height,
1797
2324
  content: content.nodes,
1798
- closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }),
2325
+ closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "", icon: "cross", iconSize: 18, kind: "quiet", onClick: close }),
1799
2326
  // Kept to the card's bottom edge as it resizes.
1800
2327
  footer: showBadge ? (height) => {
1801
2328
  const divider = height - footer - PAD_BOTTOM + 30;
@@ -1819,39 +2346,23 @@ function PanelCard(props) {
1819
2346
  return card(
1820
2347
  { x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
1821
2348
  h(Glow, { key: "glow", width: props.width, still: props.still }),
1822
- label({ key: "screen", x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
2349
+ label({ key: `screen-${props.screen}`, x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
1823
2350
  props.closeButton,
1824
2351
  ...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
1825
2352
  );
1826
2353
  }
1827
- function LinkNode(props) {
1828
- const [hovered, setHovered] = React3.useState(false);
1829
- return label({
1830
- x: props.x,
1831
- y: props.y,
1832
- width: textWidth(props.value, 12.5, 500) + 8,
1833
- height: 20,
1834
- text: props.value,
1835
- fontSize: 12.5,
1836
- textColor: hovered ? palette.textBright : palette.textSecondary,
1837
- textAlign: "centered left",
1838
- interceptsMouseClicks: true,
1839
- mouseCursorType: "pointing hand",
1840
- onMouseEnter: () => setHovered(true),
1841
- onMouseExit: () => setHovered(false),
1842
- onClick: props.onClick
1843
- });
1844
- }
1845
2354
  function Badge(props) {
1846
2355
  const [hovered, setHovered] = React3.useState(false);
1847
2356
  const lead = "Licensing secured by";
1848
2357
  const gap = 7;
1849
2358
  const size = props.mark ? 14 : 0;
1850
2359
  const markGap = props.mark ? gap : 0;
1851
- const wordmark = textWidth("moonbase", 12, 500) + 16;
1852
- const start = Math.round((props.width - (textWidth(lead, 11) + gap + size + markGap + wordmark)) / 2);
1853
- const linkX = start + textWidth(lead, 11) + gap;
1854
- return label({ x: props.x, y: props.y, width: props.width, height: 20 }, text(props.theme, lead, 0, 0, linkX - gap, { size: 11, textColor: palette.textMuted, align: "right", height: 20 }), label({
2360
+ const lock = 14;
2361
+ const leadWidth = textWidth(props.theme, lead, 11);
2362
+ const wordmark = textWidth(props.theme, "moonbase", 12, 500, { kerning: 0.06 }) + 4;
2363
+ const start = Math.round((props.width - (lock + gap + leadWidth + gap + size + markGap + wordmark)) / 2);
2364
+ const linkX = start + lock + gap + leadWidth + gap;
2365
+ return label({ x: props.x, y: props.y, width: props.width, height: 20 }, icon(props.theme, "lock", start, 3, lock, palette.textMuted, 1.5), text(props.theme, lead, start + lock + gap, 0, leadWidth + 2, { size: 11, textColor: palette.textMuted, height: 20 }), label({
1855
2366
  x: linkX,
1856
2367
  y: 0,
1857
2368
  width: size + markGap + wordmark,
@@ -1887,6 +2398,7 @@ function MoonbaseActivation(props) {
1887
2398
  const { moonbase, width, height } = props;
1888
2399
  const state = useMoonbaseState(moonbase);
1889
2400
  const ui = useUiState(moonbase);
2401
+ const metrics = useFontMetrics(moonbase.ui);
1890
2402
  const shown = ui.visible ? 1 : 0;
1891
2403
  const [scrim, rise] = useTween([
1892
2404
  { to: shown, duration: 250, ease: EASE_CSS },
@@ -1909,7 +2421,7 @@ function MoonbaseActivation(props) {
1909
2421
  // the front, after the customer bought an add-on in the browser.
1910
2422
  onMouseEnter: () => moonbase.onFocusChanged(true),
1911
2423
  onMouseExit: () => moonbase.onFocusChanged(false)
1912
- }, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height })));
2424
+ }, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height, metrics })));
1913
2425
  }
1914
2426
 
1915
2427
  // src/index.ts