@jam-comments/server-utilities 1.0.0 → 1.0.2

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.es.js CHANGED
@@ -1,22 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  const getBaseUrl = () => {
21
2
  var _a;
22
3
  if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.JAM_COMMENTS_BASE_URL)) {
@@ -28,12 +9,13 @@ const markupFetcher = (platform) => {
28
9
  return async ({
29
10
  path,
30
11
  domain,
31
- apiKey
12
+ apiKey,
13
+ embedScript = false
32
14
  }) => {
33
15
  const params = new URLSearchParams({
34
16
  path,
35
17
  domain,
36
- force_embed: "1"
18
+ forced_embed_js: embedScript ? "1" : "0"
37
19
  });
38
20
  const response = await fetch(`${getBaseUrl()}/api/markup?${params}`, {
39
21
  method: "GET",
@@ -44,16 +26,24 @@ const markupFetcher = (platform) => {
44
26
  }
45
27
  });
46
28
  if (response.status === 401) {
47
- throw `Unauthorized! Are your domain and API key set correctly?`;
29
+ throw `JamComments: Unauthorized! Are your domain and API key set correctly?`;
48
30
  }
49
31
  if (!response.ok) {
50
- throw `Request failed! Status code: ${response.status}, message: ${response.statusText}`;
32
+ throw `JamComments request failed! Status code: ${response.status}, message: ${response.statusText}`;
51
33
  }
52
34
  return await response.text();
53
35
  };
54
36
  };
55
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
56
- var ansiStyles$1 = { exports: {} };
37
+ var chalk$1 = { exports: {} };
38
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
39
+ var escapeStringRegexp = function(str) {
40
+ if (typeof str !== "string") {
41
+ throw new TypeError("Expected a string");
42
+ }
43
+ return str.replace(matchOperatorsRe, "\\$&");
44
+ };
45
+ var ansiStyles = { exports: {} };
46
+ var conversions$2 = { exports: {} };
57
47
  var colorName = {
58
48
  "aliceblue": [240, 248, 255],
59
49
  "antiquewhite": [250, 235, 215],
@@ -204,12 +194,14 @@ var colorName = {
204
194
  "yellow": [255, 255, 0],
205
195
  "yellowgreen": [154, 205, 50]
206
196
  };
207
- const cssKeywords = colorName;
208
- const reverseKeywords = {};
209
- for (const key of Object.keys(cssKeywords)) {
210
- reverseKeywords[cssKeywords[key]] = key;
197
+ var cssKeywords = colorName;
198
+ var reverseKeywords = {};
199
+ for (var key in cssKeywords) {
200
+ if (cssKeywords.hasOwnProperty(key)) {
201
+ reverseKeywords[cssKeywords[key]] = key;
202
+ }
211
203
  }
212
- const convert$1 = {
204
+ var convert$1 = conversions$2.exports = {
213
205
  rgb: { channels: 3, labels: "rgb" },
214
206
  hsl: { channels: 3, labels: "hsl" },
215
207
  hsv: { channels: 3, labels: "hsv" },
@@ -226,32 +218,35 @@ const convert$1 = {
226
218
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
227
219
  gray: { channels: 1, labels: ["gray"] }
228
220
  };
229
- var conversions$2 = convert$1;
230
- for (const model of Object.keys(convert$1)) {
231
- if (!("channels" in convert$1[model])) {
232
- throw new Error("missing channels property: " + model);
233
- }
234
- if (!("labels" in convert$1[model])) {
235
- throw new Error("missing channel labels property: " + model);
236
- }
237
- if (convert$1[model].labels.length !== convert$1[model].channels) {
238
- throw new Error("channel and label counts mismatch: " + model);
221
+ for (var model in convert$1) {
222
+ if (convert$1.hasOwnProperty(model)) {
223
+ if (!("channels" in convert$1[model])) {
224
+ throw new Error("missing channels property: " + model);
225
+ }
226
+ if (!("labels" in convert$1[model])) {
227
+ throw new Error("missing channel labels property: " + model);
228
+ }
229
+ if (convert$1[model].labels.length !== convert$1[model].channels) {
230
+ throw new Error("channel and label counts mismatch: " + model);
231
+ }
232
+ var channels = convert$1[model].channels;
233
+ var labels = convert$1[model].labels;
234
+ delete convert$1[model].channels;
235
+ delete convert$1[model].labels;
236
+ Object.defineProperty(convert$1[model], "channels", { value: channels });
237
+ Object.defineProperty(convert$1[model], "labels", { value: labels });
239
238
  }
240
- const { channels, labels } = convert$1[model];
241
- delete convert$1[model].channels;
242
- delete convert$1[model].labels;
243
- Object.defineProperty(convert$1[model], "channels", { value: channels });
244
- Object.defineProperty(convert$1[model], "labels", { value: labels });
245
239
  }
246
240
  convert$1.rgb.hsl = function(rgb) {
247
- const r = rgb[0] / 255;
248
- const g = rgb[1] / 255;
249
- const b = rgb[2] / 255;
250
- const min = Math.min(r, g, b);
251
- const max = Math.max(r, g, b);
252
- const delta = max - min;
253
- let h;
254
- let s;
241
+ var r = rgb[0] / 255;
242
+ var g = rgb[1] / 255;
243
+ var b = rgb[2] / 255;
244
+ var min = Math.min(r, g, b);
245
+ var max = Math.max(r, g, b);
246
+ var delta = max - min;
247
+ var h;
248
+ var s;
249
+ var l;
255
250
  if (max === min) {
256
251
  h = 0;
257
252
  } else if (r === max) {
@@ -265,7 +260,7 @@ convert$1.rgb.hsl = function(rgb) {
265
260
  if (h < 0) {
266
261
  h += 360;
267
262
  }
268
- const l = (min + max) / 2;
263
+ l = (min + max) / 2;
269
264
  if (max === min) {
270
265
  s = 0;
271
266
  } else if (l <= 0.5) {
@@ -276,22 +271,21 @@ convert$1.rgb.hsl = function(rgb) {
276
271
  return [h, s * 100, l * 100];
277
272
  };
278
273
  convert$1.rgb.hsv = function(rgb) {
279
- let rdif;
280
- let gdif;
281
- let bdif;
282
- let h;
283
- let s;
284
- const r = rgb[0] / 255;
285
- const g = rgb[1] / 255;
286
- const b = rgb[2] / 255;
287
- const v = Math.max(r, g, b);
288
- const diff = v - Math.min(r, g, b);
289
- const diffc = function(c) {
274
+ var rdif;
275
+ var gdif;
276
+ var bdif;
277
+ var h;
278
+ var s;
279
+ var r = rgb[0] / 255;
280
+ var g = rgb[1] / 255;
281
+ var b = rgb[2] / 255;
282
+ var v = Math.max(r, g, b);
283
+ var diff = v - Math.min(r, g, b);
284
+ var diffc = function(c) {
290
285
  return (v - c) / 6 / diff + 1 / 2;
291
286
  };
292
287
  if (diff === 0) {
293
- h = 0;
294
- s = 0;
288
+ h = s = 0;
295
289
  } else {
296
290
  s = diff / v;
297
291
  rdif = diffc(r);
@@ -317,40 +311,46 @@ convert$1.rgb.hsv = function(rgb) {
317
311
  ];
318
312
  };
319
313
  convert$1.rgb.hwb = function(rgb) {
320
- const r = rgb[0];
321
- const g = rgb[1];
322
- let b = rgb[2];
323
- const h = convert$1.rgb.hsl(rgb)[0];
324
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
314
+ var r = rgb[0];
315
+ var g = rgb[1];
316
+ var b = rgb[2];
317
+ var h = convert$1.rgb.hsl(rgb)[0];
318
+ var w = 1 / 255 * Math.min(r, Math.min(g, b));
325
319
  b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
326
320
  return [h, w * 100, b * 100];
327
321
  };
328
322
  convert$1.rgb.cmyk = function(rgb) {
329
- const r = rgb[0] / 255;
330
- const g = rgb[1] / 255;
331
- const b = rgb[2] / 255;
332
- const k = Math.min(1 - r, 1 - g, 1 - b);
333
- const c = (1 - r - k) / (1 - k) || 0;
334
- const m = (1 - g - k) / (1 - k) || 0;
335
- const y = (1 - b - k) / (1 - k) || 0;
323
+ var r = rgb[0] / 255;
324
+ var g = rgb[1] / 255;
325
+ var b = rgb[2] / 255;
326
+ var c;
327
+ var m;
328
+ var y;
329
+ var k;
330
+ k = Math.min(1 - r, 1 - g, 1 - b);
331
+ c = (1 - r - k) / (1 - k) || 0;
332
+ m = (1 - g - k) / (1 - k) || 0;
333
+ y = (1 - b - k) / (1 - k) || 0;
336
334
  return [c * 100, m * 100, y * 100, k * 100];
337
335
  };
338
336
  function comparativeDistance(x, y) {
339
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
337
+ return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
340
338
  }
341
339
  convert$1.rgb.keyword = function(rgb) {
342
- const reversed = reverseKeywords[rgb];
340
+ var reversed = reverseKeywords[rgb];
343
341
  if (reversed) {
344
342
  return reversed;
345
343
  }
346
- let currentClosestDistance = Infinity;
347
- let currentClosestKeyword;
348
- for (const keyword of Object.keys(cssKeywords)) {
349
- const value = cssKeywords[keyword];
350
- const distance = comparativeDistance(rgb, value);
351
- if (distance < currentClosestDistance) {
352
- currentClosestDistance = distance;
353
- currentClosestKeyword = keyword;
344
+ var currentClosestDistance = Infinity;
345
+ var currentClosestKeyword;
346
+ for (var keyword in cssKeywords) {
347
+ if (cssKeywords.hasOwnProperty(keyword)) {
348
+ var value = cssKeywords[keyword];
349
+ var distance = comparativeDistance(rgb, value);
350
+ if (distance < currentClosestDistance) {
351
+ currentClosestDistance = distance;
352
+ currentClosestKeyword = keyword;
353
+ }
354
354
  }
355
355
  }
356
356
  return currentClosestKeyword;
@@ -359,40 +359,45 @@ convert$1.keyword.rgb = function(keyword) {
359
359
  return cssKeywords[keyword];
360
360
  };
361
361
  convert$1.rgb.xyz = function(rgb) {
362
- let r = rgb[0] / 255;
363
- let g = rgb[1] / 255;
364
- let b = rgb[2] / 255;
365
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
366
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
367
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
368
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
369
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
370
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
362
+ var r = rgb[0] / 255;
363
+ var g = rgb[1] / 255;
364
+ var b = rgb[2] / 255;
365
+ r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
366
+ g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
367
+ b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
368
+ var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
369
+ var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
370
+ var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
371
371
  return [x * 100, y * 100, z * 100];
372
372
  };
373
373
  convert$1.rgb.lab = function(rgb) {
374
- const xyz = convert$1.rgb.xyz(rgb);
375
- let x = xyz[0];
376
- let y = xyz[1];
377
- let z = xyz[2];
374
+ var xyz = convert$1.rgb.xyz(rgb);
375
+ var x = xyz[0];
376
+ var y = xyz[1];
377
+ var z = xyz[2];
378
+ var l;
379
+ var a;
380
+ var b;
378
381
  x /= 95.047;
379
382
  y /= 100;
380
383
  z /= 108.883;
381
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
382
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
383
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
384
- const l = 116 * y - 16;
385
- const a = 500 * (x - y);
386
- const b = 200 * (y - z);
384
+ x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
385
+ y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
386
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
387
+ l = 116 * y - 16;
388
+ a = 500 * (x - y);
389
+ b = 200 * (y - z);
387
390
  return [l, a, b];
388
391
  };
389
392
  convert$1.hsl.rgb = function(hsl) {
390
- const h = hsl[0] / 360;
391
- const s = hsl[1] / 100;
392
- const l = hsl[2] / 100;
393
- let t2;
394
- let t3;
395
- let val;
393
+ var h = hsl[0] / 360;
394
+ var s = hsl[1] / 100;
395
+ var l = hsl[2] / 100;
396
+ var t1;
397
+ var t2;
398
+ var t3;
399
+ var rgb;
400
+ var val;
396
401
  if (s === 0) {
397
402
  val = l * 255;
398
403
  return [val, val, val];
@@ -402,9 +407,9 @@ convert$1.hsl.rgb = function(hsl) {
402
407
  } else {
403
408
  t2 = l + s - l * s;
404
409
  }
405
- const t1 = 2 * l - t2;
406
- const rgb = [0, 0, 0];
407
- for (let i = 0; i < 3; i++) {
410
+ t1 = 2 * l - t2;
411
+ rgb = [0, 0, 0];
412
+ for (var i = 0; i < 3; i++) {
408
413
  t3 = h + 1 / 3 * -(i - 1);
409
414
  if (t3 < 0) {
410
415
  t3++;
@@ -426,27 +431,29 @@ convert$1.hsl.rgb = function(hsl) {
426
431
  return rgb;
427
432
  };
428
433
  convert$1.hsl.hsv = function(hsl) {
429
- const h = hsl[0];
430
- let s = hsl[1] / 100;
431
- let l = hsl[2] / 100;
432
- let smin = s;
433
- const lmin = Math.max(l, 0.01);
434
+ var h = hsl[0];
435
+ var s = hsl[1] / 100;
436
+ var l = hsl[2] / 100;
437
+ var smin = s;
438
+ var lmin = Math.max(l, 0.01);
439
+ var sv;
440
+ var v;
434
441
  l *= 2;
435
442
  s *= l <= 1 ? l : 2 - l;
436
443
  smin *= lmin <= 1 ? lmin : 2 - lmin;
437
- const v = (l + s) / 2;
438
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
444
+ v = (l + s) / 2;
445
+ sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
439
446
  return [h, sv * 100, v * 100];
440
447
  };
441
448
  convert$1.hsv.rgb = function(hsv) {
442
- const h = hsv[0] / 60;
443
- const s = hsv[1] / 100;
444
- let v = hsv[2] / 100;
445
- const hi = Math.floor(h) % 6;
446
- const f = h - Math.floor(h);
447
- const p = 255 * v * (1 - s);
448
- const q = 255 * v * (1 - s * f);
449
- const t = 255 * v * (1 - s * (1 - f));
449
+ var h = hsv[0] / 60;
450
+ var s = hsv[1] / 100;
451
+ var v = hsv[2] / 100;
452
+ var hi = Math.floor(h) % 6;
453
+ var f = h - Math.floor(h);
454
+ var p = 255 * v * (1 - s);
455
+ var q = 255 * v * (1 - s * f);
456
+ var t = 255 * v * (1 - s * (1 - f));
450
457
  v *= 255;
451
458
  switch (hi) {
452
459
  case 0:
@@ -464,14 +471,15 @@ convert$1.hsv.rgb = function(hsv) {
464
471
  }
465
472
  };
466
473
  convert$1.hsv.hsl = function(hsv) {
467
- const h = hsv[0];
468
- const s = hsv[1] / 100;
469
- const v = hsv[2] / 100;
470
- const vmin = Math.max(v, 0.01);
471
- let sl;
472
- let l;
474
+ var h = hsv[0];
475
+ var s = hsv[1] / 100;
476
+ var v = hsv[2] / 100;
477
+ var vmin = Math.max(v, 0.01);
478
+ var lmin;
479
+ var sl;
480
+ var l;
473
481
  l = (2 - s) * v;
474
- const lmin = (2 - s) * vmin;
482
+ lmin = (2 - s) * vmin;
475
483
  sl = s * vmin;
476
484
  sl /= lmin <= 1 ? lmin : 2 - lmin;
477
485
  sl = sl || 0;
@@ -479,25 +487,28 @@ convert$1.hsv.hsl = function(hsv) {
479
487
  return [h, sl * 100, l * 100];
480
488
  };
481
489
  convert$1.hwb.rgb = function(hwb) {
482
- const h = hwb[0] / 360;
483
- let wh = hwb[1] / 100;
484
- let bl = hwb[2] / 100;
485
- const ratio = wh + bl;
486
- let f;
490
+ var h = hwb[0] / 360;
491
+ var wh = hwb[1] / 100;
492
+ var bl = hwb[2] / 100;
493
+ var ratio = wh + bl;
494
+ var i;
495
+ var v;
496
+ var f;
497
+ var n;
487
498
  if (ratio > 1) {
488
499
  wh /= ratio;
489
500
  bl /= ratio;
490
501
  }
491
- const i = Math.floor(6 * h);
492
- const v = 1 - bl;
502
+ i = Math.floor(6 * h);
503
+ v = 1 - bl;
493
504
  f = 6 * h - i;
494
505
  if ((i & 1) !== 0) {
495
506
  f = 1 - f;
496
507
  }
497
- const n = wh + f * (v - wh);
498
- let r;
499
- let g;
500
- let b;
508
+ n = wh + f * (v - wh);
509
+ var r;
510
+ var g;
511
+ var b;
501
512
  switch (i) {
502
513
  default:
503
514
  case 6:
@@ -535,61 +546,67 @@ convert$1.hwb.rgb = function(hwb) {
535
546
  return [r * 255, g * 255, b * 255];
536
547
  };
537
548
  convert$1.cmyk.rgb = function(cmyk) {
538
- const c = cmyk[0] / 100;
539
- const m = cmyk[1] / 100;
540
- const y = cmyk[2] / 100;
541
- const k = cmyk[3] / 100;
542
- const r = 1 - Math.min(1, c * (1 - k) + k);
543
- const g = 1 - Math.min(1, m * (1 - k) + k);
544
- const b = 1 - Math.min(1, y * (1 - k) + k);
549
+ var c = cmyk[0] / 100;
550
+ var m = cmyk[1] / 100;
551
+ var y = cmyk[2] / 100;
552
+ var k = cmyk[3] / 100;
553
+ var r;
554
+ var g;
555
+ var b;
556
+ r = 1 - Math.min(1, c * (1 - k) + k);
557
+ g = 1 - Math.min(1, m * (1 - k) + k);
558
+ b = 1 - Math.min(1, y * (1 - k) + k);
545
559
  return [r * 255, g * 255, b * 255];
546
560
  };
547
561
  convert$1.xyz.rgb = function(xyz) {
548
- const x = xyz[0] / 100;
549
- const y = xyz[1] / 100;
550
- const z = xyz[2] / 100;
551
- let r;
552
- let g;
553
- let b;
562
+ var x = xyz[0] / 100;
563
+ var y = xyz[1] / 100;
564
+ var z = xyz[2] / 100;
565
+ var r;
566
+ var g;
567
+ var b;
554
568
  r = x * 3.2406 + y * -1.5372 + z * -0.4986;
555
569
  g = x * -0.9689 + y * 1.8758 + z * 0.0415;
556
570
  b = x * 0.0557 + y * -0.204 + z * 1.057;
557
- r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
558
- g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
559
- b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
571
+ r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92;
572
+ g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92;
573
+ b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92;
560
574
  r = Math.min(Math.max(0, r), 1);
561
575
  g = Math.min(Math.max(0, g), 1);
562
576
  b = Math.min(Math.max(0, b), 1);
563
577
  return [r * 255, g * 255, b * 255];
564
578
  };
565
579
  convert$1.xyz.lab = function(xyz) {
566
- let x = xyz[0];
567
- let y = xyz[1];
568
- let z = xyz[2];
580
+ var x = xyz[0];
581
+ var y = xyz[1];
582
+ var z = xyz[2];
583
+ var l;
584
+ var a;
585
+ var b;
569
586
  x /= 95.047;
570
587
  y /= 100;
571
588
  z /= 108.883;
572
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
573
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
574
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
575
- const l = 116 * y - 16;
576
- const a = 500 * (x - y);
577
- const b = 200 * (y - z);
589
+ x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
590
+ y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
591
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
592
+ l = 116 * y - 16;
593
+ a = 500 * (x - y);
594
+ b = 200 * (y - z);
578
595
  return [l, a, b];
579
596
  };
580
597
  convert$1.lab.xyz = function(lab) {
581
- const l = lab[0];
582
- const a = lab[1];
583
- const b = lab[2];
584
- let x;
585
- let y;
586
- let z;
598
+ var l = lab[0];
599
+ var a = lab[1];
600
+ var b = lab[2];
601
+ var x;
602
+ var y;
603
+ var z;
587
604
  y = (l + 16) / 116;
588
605
  x = a / 500 + y;
589
606
  z = y - b / 200;
590
- const y2 = y ** 3;
591
- const x2 = x ** 3;
592
- const z2 = z ** 3;
607
+ var y2 = Math.pow(y, 3);
608
+ var x2 = Math.pow(x, 3);
609
+ var z2 = Math.pow(z, 3);
593
610
  y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
594
611
  x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
595
612
  z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
@@ -599,35 +616,42 @@ convert$1.lab.xyz = function(lab) {
599
616
  return [x, y, z];
600
617
  };
601
618
  convert$1.lab.lch = function(lab) {
602
- const l = lab[0];
603
- const a = lab[1];
604
- const b = lab[2];
605
- let h;
606
- const hr = Math.atan2(b, a);
619
+ var l = lab[0];
620
+ var a = lab[1];
621
+ var b = lab[2];
622
+ var hr;
623
+ var h;
624
+ var c;
625
+ hr = Math.atan2(b, a);
607
626
  h = hr * 360 / 2 / Math.PI;
608
627
  if (h < 0) {
609
628
  h += 360;
610
629
  }
611
- const c = Math.sqrt(a * a + b * b);
630
+ c = Math.sqrt(a * a + b * b);
612
631
  return [l, c, h];
613
632
  };
614
633
  convert$1.lch.lab = function(lch) {
615
- const l = lch[0];
616
- const c = lch[1];
617
- const h = lch[2];
618
- const hr = h / 360 * 2 * Math.PI;
619
- const a = c * Math.cos(hr);
620
- const b = c * Math.sin(hr);
634
+ var l = lch[0];
635
+ var c = lch[1];
636
+ var h = lch[2];
637
+ var a;
638
+ var b;
639
+ var hr;
640
+ hr = h / 360 * 2 * Math.PI;
641
+ a = c * Math.cos(hr);
642
+ b = c * Math.sin(hr);
621
643
  return [l, a, b];
622
644
  };
623
- convert$1.rgb.ansi16 = function(args, saturation = null) {
624
- const [r, g, b] = args;
625
- let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation;
645
+ convert$1.rgb.ansi16 = function(args) {
646
+ var r = args[0];
647
+ var g = args[1];
648
+ var b = args[2];
649
+ var value = 1 in arguments ? arguments[1] : convert$1.rgb.hsv(args)[2];
626
650
  value = Math.round(value / 50);
627
651
  if (value === 0) {
628
652
  return 30;
629
653
  }
630
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
654
+ var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
631
655
  if (value === 2) {
632
656
  ansi += 60;
633
657
  }
@@ -637,9 +661,9 @@ convert$1.hsv.ansi16 = function(args) {
637
661
  return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
638
662
  };
639
663
  convert$1.rgb.ansi256 = function(args) {
640
- const r = args[0];
641
- const g = args[1];
642
- const b = args[2];
664
+ var r = args[0];
665
+ var g = args[1];
666
+ var b = args[2];
643
667
  if (r === g && g === b) {
644
668
  if (r < 8) {
645
669
  return 16;
@@ -649,11 +673,11 @@ convert$1.rgb.ansi256 = function(args) {
649
673
  }
650
674
  return Math.round((r - 8) / 247 * 24) + 232;
651
675
  }
652
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
676
+ var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
653
677
  return ansi;
654
678
  };
655
679
  convert$1.ansi16.rgb = function(args) {
656
- let color = args % 10;
680
+ var color = args % 10;
657
681
  if (color === 0 || color === 7) {
658
682
  if (args > 50) {
659
683
  color += 3.5;
@@ -661,55 +685,55 @@ convert$1.ansi16.rgb = function(args) {
661
685
  color = color / 10.5 * 255;
662
686
  return [color, color, color];
663
687
  }
664
- const mult = (~~(args > 50) + 1) * 0.5;
665
- const r = (color & 1) * mult * 255;
666
- const g = (color >> 1 & 1) * mult * 255;
667
- const b = (color >> 2 & 1) * mult * 255;
688
+ var mult = (~~(args > 50) + 1) * 0.5;
689
+ var r = (color & 1) * mult * 255;
690
+ var g = (color >> 1 & 1) * mult * 255;
691
+ var b = (color >> 2 & 1) * mult * 255;
668
692
  return [r, g, b];
669
693
  };
670
694
  convert$1.ansi256.rgb = function(args) {
671
695
  if (args >= 232) {
672
- const c = (args - 232) * 10 + 8;
696
+ var c = (args - 232) * 10 + 8;
673
697
  return [c, c, c];
674
698
  }
675
699
  args -= 16;
676
- let rem;
677
- const r = Math.floor(args / 36) / 5 * 255;
678
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
679
- const b = rem % 6 / 5 * 255;
700
+ var rem;
701
+ var r = Math.floor(args / 36) / 5 * 255;
702
+ var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
703
+ var b = rem % 6 / 5 * 255;
680
704
  return [r, g, b];
681
705
  };
682
706
  convert$1.rgb.hex = function(args) {
683
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
684
- const string = integer.toString(16).toUpperCase();
707
+ var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
708
+ var string = integer.toString(16).toUpperCase();
685
709
  return "000000".substring(string.length) + string;
686
710
  };
687
711
  convert$1.hex.rgb = function(args) {
688
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
712
+ var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
689
713
  if (!match) {
690
714
  return [0, 0, 0];
691
715
  }
692
- let colorString = match[0];
716
+ var colorString = match[0];
693
717
  if (match[0].length === 3) {
694
- colorString = colorString.split("").map((char) => {
718
+ colorString = colorString.split("").map(function(char) {
695
719
  return char + char;
696
720
  }).join("");
697
721
  }
698
- const integer = parseInt(colorString, 16);
699
- const r = integer >> 16 & 255;
700
- const g = integer >> 8 & 255;
701
- const b = integer & 255;
722
+ var integer = parseInt(colorString, 16);
723
+ var r = integer >> 16 & 255;
724
+ var g = integer >> 8 & 255;
725
+ var b = integer & 255;
702
726
  return [r, g, b];
703
727
  };
704
728
  convert$1.rgb.hcg = function(rgb) {
705
- const r = rgb[0] / 255;
706
- const g = rgb[1] / 255;
707
- const b = rgb[2] / 255;
708
- const max = Math.max(Math.max(r, g), b);
709
- const min = Math.min(Math.min(r, g), b);
710
- const chroma = max - min;
711
- let grayscale;
712
- let hue;
729
+ var r = rgb[0] / 255;
730
+ var g = rgb[1] / 255;
731
+ var b = rgb[2] / 255;
732
+ var max = Math.max(Math.max(r, g), b);
733
+ var min = Math.min(Math.min(r, g), b);
734
+ var chroma = max - min;
735
+ var grayscale;
736
+ var hue;
713
737
  if (chroma < 1) {
714
738
  grayscale = min / (1 - chroma);
715
739
  } else {
@@ -722,44 +746,49 @@ convert$1.rgb.hcg = function(rgb) {
722
746
  } else if (max === g) {
723
747
  hue = 2 + (b - r) / chroma;
724
748
  } else {
725
- hue = 4 + (r - g) / chroma;
749
+ hue = 4 + (r - g) / chroma + 4;
726
750
  }
727
751
  hue /= 6;
728
752
  hue %= 1;
729
753
  return [hue * 360, chroma * 100, grayscale * 100];
730
754
  };
731
755
  convert$1.hsl.hcg = function(hsl) {
732
- const s = hsl[1] / 100;
733
- const l = hsl[2] / 100;
734
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
735
- let f = 0;
756
+ var s = hsl[1] / 100;
757
+ var l = hsl[2] / 100;
758
+ var c = 1;
759
+ var f = 0;
760
+ if (l < 0.5) {
761
+ c = 2 * s * l;
762
+ } else {
763
+ c = 2 * s * (1 - l);
764
+ }
736
765
  if (c < 1) {
737
766
  f = (l - 0.5 * c) / (1 - c);
738
767
  }
739
768
  return [hsl[0], c * 100, f * 100];
740
769
  };
741
770
  convert$1.hsv.hcg = function(hsv) {
742
- const s = hsv[1] / 100;
743
- const v = hsv[2] / 100;
744
- const c = s * v;
745
- let f = 0;
771
+ var s = hsv[1] / 100;
772
+ var v = hsv[2] / 100;
773
+ var c = s * v;
774
+ var f = 0;
746
775
  if (c < 1) {
747
776
  f = (v - c) / (1 - c);
748
777
  }
749
778
  return [hsv[0], c * 100, f * 100];
750
779
  };
751
780
  convert$1.hcg.rgb = function(hcg) {
752
- const h = hcg[0] / 360;
753
- const c = hcg[1] / 100;
754
- const g = hcg[2] / 100;
781
+ var h = hcg[0] / 360;
782
+ var c = hcg[1] / 100;
783
+ var g = hcg[2] / 100;
755
784
  if (c === 0) {
756
785
  return [g * 255, g * 255, g * 255];
757
786
  }
758
- const pure = [0, 0, 0];
759
- const hi = h % 1 * 6;
760
- const v = hi % 1;
761
- const w = 1 - v;
762
- let mg = 0;
787
+ var pure = [0, 0, 0];
788
+ var hi = h % 1 * 6;
789
+ var v = hi % 1;
790
+ var w = 1 - v;
791
+ var mg = 0;
763
792
  switch (Math.floor(hi)) {
764
793
  case 0:
765
794
  pure[0] = 1;
@@ -799,20 +828,20 @@ convert$1.hcg.rgb = function(hcg) {
799
828
  ];
800
829
  };
801
830
  convert$1.hcg.hsv = function(hcg) {
802
- const c = hcg[1] / 100;
803
- const g = hcg[2] / 100;
804
- const v = c + g * (1 - c);
805
- let f = 0;
831
+ var c = hcg[1] / 100;
832
+ var g = hcg[2] / 100;
833
+ var v = c + g * (1 - c);
834
+ var f = 0;
806
835
  if (v > 0) {
807
836
  f = c / v;
808
837
  }
809
838
  return [hcg[0], f * 100, v * 100];
810
839
  };
811
840
  convert$1.hcg.hsl = function(hcg) {
812
- const c = hcg[1] / 100;
813
- const g = hcg[2] / 100;
814
- const l = g * (1 - c) + 0.5 * c;
815
- let s = 0;
841
+ var c = hcg[1] / 100;
842
+ var g = hcg[2] / 100;
843
+ var l = g * (1 - c) + 0.5 * c;
844
+ var s = 0;
816
845
  if (l > 0 && l < 0.5) {
817
846
  s = c / (2 * l);
818
847
  } else if (l >= 0.5 && l < 1) {
@@ -821,17 +850,17 @@ convert$1.hcg.hsl = function(hcg) {
821
850
  return [hcg[0], s * 100, l * 100];
822
851
  };
823
852
  convert$1.hcg.hwb = function(hcg) {
824
- const c = hcg[1] / 100;
825
- const g = hcg[2] / 100;
826
- const v = c + g * (1 - c);
853
+ var c = hcg[1] / 100;
854
+ var g = hcg[2] / 100;
855
+ var v = c + g * (1 - c);
827
856
  return [hcg[0], (v - c) * 100, (1 - v) * 100];
828
857
  };
829
858
  convert$1.hwb.hcg = function(hwb) {
830
- const w = hwb[1] / 100;
831
- const b = hwb[2] / 100;
832
- const v = 1 - b;
833
- const c = v - w;
834
- let g = 0;
859
+ var w = hwb[1] / 100;
860
+ var b = hwb[2] / 100;
861
+ var v = 1 - b;
862
+ var c = v - w;
863
+ var g = 0;
835
864
  if (c < 1) {
836
865
  g = (v - c) / (1 - c);
837
866
  }
@@ -846,10 +875,9 @@ convert$1.rgb.apple = function(rgb) {
846
875
  convert$1.gray.rgb = function(args) {
847
876
  return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
848
877
  };
849
- convert$1.gray.hsl = function(args) {
878
+ convert$1.gray.hsl = convert$1.gray.hsv = function(args) {
850
879
  return [0, 0, args[0]];
851
880
  };
852
- convert$1.gray.hsv = convert$1.gray.hsl;
853
881
  convert$1.gray.hwb = function(gray) {
854
882
  return [0, 100, gray[0]];
855
883
  };
@@ -860,20 +888,20 @@ convert$1.gray.lab = function(gray) {
860
888
  return [gray[0], 0, 0];
861
889
  };
862
890
  convert$1.gray.hex = function(gray) {
863
- const val = Math.round(gray[0] / 100 * 255) & 255;
864
- const integer = (val << 16) + (val << 8) + val;
865
- const string = integer.toString(16).toUpperCase();
891
+ var val = Math.round(gray[0] / 100 * 255) & 255;
892
+ var integer = (val << 16) + (val << 8) + val;
893
+ var string = integer.toString(16).toUpperCase();
866
894
  return "000000".substring(string.length) + string;
867
895
  };
868
896
  convert$1.rgb.gray = function(rgb) {
869
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
897
+ var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
870
898
  return [val / 255 * 100];
871
899
  };
872
- const conversions$1 = conversions$2;
900
+ var conversions$1 = conversions$2.exports;
873
901
  function buildGraph() {
874
- const graph = {};
875
- const models2 = Object.keys(conversions$1);
876
- for (let len = models2.length, i = 0; i < len; i++) {
902
+ var graph = {};
903
+ var models2 = Object.keys(conversions$1);
904
+ for (var len = models2.length, i = 0; i < len; i++) {
877
905
  graph[models2[i]] = {
878
906
  distance: -1,
879
907
  parent: null
@@ -882,15 +910,15 @@ function buildGraph() {
882
910
  return graph;
883
911
  }
884
912
  function deriveBFS(fromModel) {
885
- const graph = buildGraph();
886
- const queue = [fromModel];
913
+ var graph = buildGraph();
914
+ var queue = [fromModel];
887
915
  graph[fromModel].distance = 0;
888
916
  while (queue.length) {
889
- const current = queue.pop();
890
- const adjacents = Object.keys(conversions$1[current]);
891
- for (let len = adjacents.length, i = 0; i < len; i++) {
892
- const adjacent = adjacents[i];
893
- const node = graph[adjacent];
917
+ var current = queue.pop();
918
+ var adjacents = Object.keys(conversions$1[current]);
919
+ for (var len = adjacents.length, i = 0; i < len; i++) {
920
+ var adjacent = adjacents[i];
921
+ var node = graph[adjacent];
894
922
  if (node.distance === -1) {
895
923
  node.distance = graph[current].distance + 1;
896
924
  node.parent = current;
@@ -906,9 +934,9 @@ function link(from, to) {
906
934
  };
907
935
  }
908
936
  function wrapConversion(toModel, graph) {
909
- const path = [graph[toModel].parent, toModel];
910
- let fn = conversions$1[graph[toModel].parent][toModel];
911
- let cur = graph[toModel].parent;
937
+ var path = [graph[toModel].parent, toModel];
938
+ var fn = conversions$1[graph[toModel].parent][toModel];
939
+ var cur = graph[toModel].parent;
912
940
  while (graph[cur].parent) {
913
941
  path.unshift(graph[cur].parent);
914
942
  fn = link(conversions$1[graph[cur].parent][cur], fn);
@@ -918,12 +946,12 @@ function wrapConversion(toModel, graph) {
918
946
  return fn;
919
947
  }
920
948
  var route$1 = function(fromModel) {
921
- const graph = deriveBFS(fromModel);
922
- const conversion = {};
923
- const models2 = Object.keys(graph);
924
- for (let len = models2.length, i = 0; i < len; i++) {
925
- const toModel = models2[i];
926
- const node = graph[toModel];
949
+ var graph = deriveBFS(fromModel);
950
+ var conversion = {};
951
+ var models2 = Object.keys(graph);
952
+ for (var len = models2.length, i = 0; i < len; i++) {
953
+ var toModel = models2[i];
954
+ var node = graph[toModel];
927
955
  if (node.parent === null) {
928
956
  continue;
929
957
  }
@@ -931,18 +959,17 @@ var route$1 = function(fromModel) {
931
959
  }
932
960
  return conversion;
933
961
  };
934
- const conversions = conversions$2;
935
- const route = route$1;
936
- const convert = {};
937
- const models = Object.keys(conversions);
962
+ var conversions = conversions$2.exports;
963
+ var route = route$1;
964
+ var convert = {};
965
+ var models = Object.keys(conversions);
938
966
  function wrapRaw(fn) {
939
- const wrappedFn = function(...args) {
940
- const arg0 = args[0];
941
- if (arg0 === void 0 || arg0 === null) {
942
- return arg0;
967
+ var wrappedFn = function(args) {
968
+ if (args === void 0 || args === null) {
969
+ return args;
943
970
  }
944
- if (arg0.length > 1) {
945
- args = arg0;
971
+ if (arguments.length > 1) {
972
+ args = Array.prototype.slice.call(arguments);
946
973
  }
947
974
  return fn(args);
948
975
  };
@@ -952,17 +979,16 @@ function wrapRaw(fn) {
952
979
  return wrappedFn;
953
980
  }
954
981
  function wrapRounded(fn) {
955
- const wrappedFn = function(...args) {
956
- const arg0 = args[0];
957
- if (arg0 === void 0 || arg0 === null) {
958
- return arg0;
982
+ var wrappedFn = function(args) {
983
+ if (args === void 0 || args === null) {
984
+ return args;
959
985
  }
960
- if (arg0.length > 1) {
961
- args = arg0;
986
+ if (arguments.length > 1) {
987
+ args = Array.prototype.slice.call(arguments);
962
988
  }
963
- const result = fn(args);
989
+ var result = fn(args);
964
990
  if (typeof result === "object") {
965
- for (let len = result.length, i = 0; i < len; i++) {
991
+ for (var len = result.length, i = 0; i < len; i++) {
966
992
  result[i] = Math.round(result[i]);
967
993
  }
968
994
  }
@@ -973,69 +999,36 @@ function wrapRounded(fn) {
973
999
  }
974
1000
  return wrappedFn;
975
1001
  }
976
- models.forEach((fromModel) => {
1002
+ models.forEach(function(fromModel) {
977
1003
  convert[fromModel] = {};
978
1004
  Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
979
1005
  Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
980
- const routes = route(fromModel);
981
- const routeModels = Object.keys(routes);
982
- routeModels.forEach((toModel) => {
983
- const fn = routes[toModel];
1006
+ var routes = route(fromModel);
1007
+ var routeModels = Object.keys(routes);
1008
+ routeModels.forEach(function(toModel) {
1009
+ var fn = routes[toModel];
984
1010
  convert[fromModel][toModel] = wrapRounded(fn);
985
1011
  convert[fromModel][toModel].raw = wrapRaw(fn);
986
1012
  });
987
1013
  });
988
1014
  var colorConvert = convert;
989
1015
  (function(module) {
990
- const wrapAnsi16 = (fn, offset) => (...args) => {
991
- const code = fn(...args);
1016
+ const colorConvert$1 = colorConvert;
1017
+ const wrapAnsi16 = (fn, offset) => function() {
1018
+ const code = fn.apply(colorConvert$1, arguments);
992
1019
  return `\x1B[${code + offset}m`;
993
1020
  };
994
- const wrapAnsi256 = (fn, offset) => (...args) => {
995
- const code = fn(...args);
1021
+ const wrapAnsi256 = (fn, offset) => function() {
1022
+ const code = fn.apply(colorConvert$1, arguments);
996
1023
  return `\x1B[${38 + offset};5;${code}m`;
997
1024
  };
998
- const wrapAnsi16m = (fn, offset) => (...args) => {
999
- const rgb = fn(...args);
1025
+ const wrapAnsi16m = (fn, offset) => function() {
1026
+ const rgb = fn.apply(colorConvert$1, arguments);
1000
1027
  return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1001
1028
  };
1002
- const ansi2ansi = (n) => n;
1003
- const rgb2rgb = (r, g, b) => [r, g, b];
1004
- const setLazyProperty = (object, property, get) => {
1005
- Object.defineProperty(object, property, {
1006
- get: () => {
1007
- const value = get();
1008
- Object.defineProperty(object, property, {
1009
- value,
1010
- enumerable: true,
1011
- configurable: true
1012
- });
1013
- return value;
1014
- },
1015
- enumerable: true,
1016
- configurable: true
1017
- });
1018
- };
1019
- let colorConvert$1;
1020
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1021
- if (colorConvert$1 === void 0) {
1022
- colorConvert$1 = colorConvert;
1023
- }
1024
- const offset = isBackground ? 10 : 0;
1025
- const styles2 = {};
1026
- for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
1027
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1028
- if (sourceSpace === targetSpace) {
1029
- styles2[name] = wrap(identity, offset);
1030
- } else if (typeof suite === "object") {
1031
- styles2[name] = wrap(suite[targetSpace], offset);
1032
- }
1033
- }
1034
- return styles2;
1035
- };
1036
1029
  function assembleStyles() {
1037
1030
  const codes = /* @__PURE__ */ new Map();
1038
- const styles2 = {
1031
+ const styles = {
1039
1032
  modifier: {
1040
1033
  reset: [0, 0],
1041
1034
  bold: [1, 22],
@@ -1055,7 +1048,7 @@ var colorConvert = convert;
1055
1048
  magenta: [35, 39],
1056
1049
  cyan: [36, 39],
1057
1050
  white: [37, 39],
1058
- blackBright: [90, 39],
1051
+ gray: [90, 39],
1059
1052
  redBright: [91, 39],
1060
1053
  greenBright: [92, 39],
1061
1054
  yellowBright: [93, 39],
@@ -1083,83 +1076,85 @@ var colorConvert = convert;
1083
1076
  bgWhiteBright: [107, 49]
1084
1077
  }
1085
1078
  };
1086
- styles2.color.gray = styles2.color.blackBright;
1087
- styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
1088
- styles2.color.grey = styles2.color.blackBright;
1089
- styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
1090
- for (const [groupName, group] of Object.entries(styles2)) {
1091
- for (const [styleName, style] of Object.entries(group)) {
1092
- styles2[styleName] = {
1079
+ styles.color.grey = styles.color.gray;
1080
+ for (const groupName of Object.keys(styles)) {
1081
+ const group = styles[groupName];
1082
+ for (const styleName of Object.keys(group)) {
1083
+ const style = group[styleName];
1084
+ styles[styleName] = {
1093
1085
  open: `\x1B[${style[0]}m`,
1094
1086
  close: `\x1B[${style[1]}m`
1095
1087
  };
1096
- group[styleName] = styles2[styleName];
1088
+ group[styleName] = styles[styleName];
1097
1089
  codes.set(style[0], style[1]);
1098
1090
  }
1099
- Object.defineProperty(styles2, groupName, {
1091
+ Object.defineProperty(styles, groupName, {
1100
1092
  value: group,
1101
1093
  enumerable: false
1102
1094
  });
1095
+ Object.defineProperty(styles, "codes", {
1096
+ value: codes,
1097
+ enumerable: false
1098
+ });
1103
1099
  }
1104
- Object.defineProperty(styles2, "codes", {
1105
- value: codes,
1106
- enumerable: false
1107
- });
1108
- styles2.color.close = "\x1B[39m";
1109
- styles2.bgColor.close = "\x1B[49m";
1110
- setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1111
- setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1112
- setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1113
- setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1114
- setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1115
- setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1116
- return styles2;
1100
+ const ansi2ansi = (n) => n;
1101
+ const rgb2rgb = (r, g, b) => [r, g, b];
1102
+ styles.color.close = "\x1B[39m";
1103
+ styles.bgColor.close = "\x1B[49m";
1104
+ styles.color.ansi = {
1105
+ ansi: wrapAnsi16(ansi2ansi, 0)
1106
+ };
1107
+ styles.color.ansi256 = {
1108
+ ansi256: wrapAnsi256(ansi2ansi, 0)
1109
+ };
1110
+ styles.color.ansi16m = {
1111
+ rgb: wrapAnsi16m(rgb2rgb, 0)
1112
+ };
1113
+ styles.bgColor.ansi = {
1114
+ ansi: wrapAnsi16(ansi2ansi, 10)
1115
+ };
1116
+ styles.bgColor.ansi256 = {
1117
+ ansi256: wrapAnsi256(ansi2ansi, 10)
1118
+ };
1119
+ styles.bgColor.ansi16m = {
1120
+ rgb: wrapAnsi16m(rgb2rgb, 10)
1121
+ };
1122
+ for (let key of Object.keys(colorConvert$1)) {
1123
+ if (typeof colorConvert$1[key] !== "object") {
1124
+ continue;
1125
+ }
1126
+ const suite = colorConvert$1[key];
1127
+ if (key === "ansi16") {
1128
+ key = "ansi";
1129
+ }
1130
+ if ("ansi16" in suite) {
1131
+ styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
1132
+ styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
1133
+ }
1134
+ if ("ansi256" in suite) {
1135
+ styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
1136
+ styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
1137
+ }
1138
+ if ("rgb" in suite) {
1139
+ styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
1140
+ styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
1141
+ }
1142
+ }
1143
+ return styles;
1117
1144
  }
1118
1145
  Object.defineProperty(module, "exports", {
1119
1146
  enumerable: true,
1120
1147
  get: assembleStyles
1121
1148
  });
1122
- })(ansiStyles$1);
1149
+ })(ansiStyles);
1123
1150
  var browser = {
1124
1151
  stdout: false,
1125
1152
  stderr: false
1126
1153
  };
1127
- const stringReplaceAll$1 = (string, substring, replacer) => {
1128
- let index = string.indexOf(substring);
1129
- if (index === -1) {
1130
- return string;
1131
- }
1132
- const substringLength = substring.length;
1133
- let endIndex = 0;
1134
- let returnValue = "";
1135
- do {
1136
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1137
- endIndex = index + substringLength;
1138
- index = string.indexOf(substring, endIndex);
1139
- } while (index !== -1);
1140
- returnValue += string.substr(endIndex);
1141
- return returnValue;
1142
- };
1143
- const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
1144
- let endIndex = 0;
1145
- let returnValue = "";
1146
- do {
1147
- const gotCR = string[index - 1] === "\r";
1148
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1149
- endIndex = index + 1;
1150
- index = string.indexOf("\n", endIndex);
1151
- } while (index !== -1);
1152
- returnValue += string.substr(endIndex);
1153
- return returnValue;
1154
- };
1155
- var util = {
1156
- stringReplaceAll: stringReplaceAll$1,
1157
- stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
1158
- };
1159
- const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1154
+ const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1160
1155
  const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1161
1156
  const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1162
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1157
+ const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
1163
1158
  const ESCAPES = /* @__PURE__ */ new Map([
1164
1159
  ["n", "\n"],
1165
1160
  ["r", "\r"],
@@ -1172,27 +1167,21 @@ const ESCAPES = /* @__PURE__ */ new Map([
1172
1167
  ["e", "\x1B"],
1173
1168
  ["a", "\x07"]
1174
1169
  ]);
1175
- function unescape$1(c) {
1176
- const u = c[0] === "u";
1177
- const bracket = c[1] === "{";
1178
- if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1170
+ function unescape(c) {
1171
+ if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) {
1179
1172
  return String.fromCharCode(parseInt(c.slice(1), 16));
1180
1173
  }
1181
- if (u && bracket) {
1182
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1183
- }
1184
1174
  return ESCAPES.get(c) || c;
1185
1175
  }
1186
- function parseArguments(name, arguments_) {
1176
+ function parseArguments(name, args) {
1187
1177
  const results = [];
1188
- const chunks = arguments_.trim().split(/\s*,\s*/g);
1178
+ const chunks = args.trim().split(/\s*,\s*/g);
1189
1179
  let matches;
1190
1180
  for (const chunk of chunks) {
1191
- const number = Number(chunk);
1192
- if (!Number.isNaN(number)) {
1193
- results.push(number);
1181
+ if (!isNaN(chunk)) {
1182
+ results.push(Number(chunk));
1194
1183
  } else if (matches = chunk.match(STRING_REGEX)) {
1195
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape$1(escape) : character));
1184
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
1196
1185
  } else {
1197
1186
  throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1198
1187
  }
@@ -1214,622 +1203,225 @@ function parseStyle(style) {
1214
1203
  }
1215
1204
  return results;
1216
1205
  }
1217
- function buildStyle(chalk2, styles2) {
1206
+ function buildStyle(chalk2, styles) {
1218
1207
  const enabled = {};
1219
- for (const layer of styles2) {
1208
+ for (const layer of styles) {
1220
1209
  for (const style of layer.styles) {
1221
1210
  enabled[style[0]] = layer.inverse ? null : style.slice(1);
1222
1211
  }
1223
1212
  }
1224
1213
  let current = chalk2;
1225
- for (const [styleName, styles3] of Object.entries(enabled)) {
1226
- if (!Array.isArray(styles3)) {
1227
- continue;
1228
- }
1229
- if (!(styleName in current)) {
1230
- throw new Error(`Unknown Chalk style: ${styleName}`);
1214
+ for (const styleName of Object.keys(enabled)) {
1215
+ if (Array.isArray(enabled[styleName])) {
1216
+ if (!(styleName in current)) {
1217
+ throw new Error(`Unknown Chalk style: ${styleName}`);
1218
+ }
1219
+ if (enabled[styleName].length > 0) {
1220
+ current = current[styleName].apply(current, enabled[styleName]);
1221
+ } else {
1222
+ current = current[styleName];
1223
+ }
1231
1224
  }
1232
- current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
1233
1225
  }
1234
1226
  return current;
1235
1227
  }
1236
- var templates = (chalk2, temporary) => {
1237
- const styles2 = [];
1228
+ var templates = (chalk2, tmp) => {
1229
+ const styles = [];
1238
1230
  const chunks = [];
1239
1231
  let chunk = [];
1240
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1241
- if (escapeCharacter) {
1242
- chunk.push(unescape$1(escapeCharacter));
1232
+ tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
1233
+ if (escapeChar) {
1234
+ chunk.push(unescape(escapeChar));
1243
1235
  } else if (style) {
1244
- const string = chunk.join("");
1236
+ const str = chunk.join("");
1245
1237
  chunk = [];
1246
- chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
1247
- styles2.push({ inverse, styles: parseStyle(style) });
1238
+ chunks.push(styles.length === 0 ? str : buildStyle(chalk2, styles)(str));
1239
+ styles.push({ inverse, styles: parseStyle(style) });
1248
1240
  } else if (close) {
1249
- if (styles2.length === 0) {
1241
+ if (styles.length === 0) {
1250
1242
  throw new Error("Found extraneous } in Chalk template literal");
1251
1243
  }
1252
- chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
1244
+ chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
1253
1245
  chunk = [];
1254
- styles2.pop();
1246
+ styles.pop();
1255
1247
  } else {
1256
- chunk.push(character);
1248
+ chunk.push(chr);
1257
1249
  }
1258
1250
  });
1259
1251
  chunks.push(chunk.join(""));
1260
- if (styles2.length > 0) {
1261
- const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
1262
- throw new Error(errMessage);
1252
+ if (styles.length > 0) {
1253
+ const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1254
+ throw new Error(errMsg);
1263
1255
  }
1264
1256
  return chunks.join("");
1265
1257
  };
1266
- const ansiStyles = ansiStyles$1.exports;
1267
- const { stdout: stdoutColor, stderr: stderrColor } = browser;
1268
- const {
1269
- stringReplaceAll,
1270
- stringEncaseCRLFWithFirstIndex
1271
- } = util;
1272
- const { isArray } = Array;
1273
- const levelMapping = [
1274
- "ansi",
1275
- "ansi",
1276
- "ansi256",
1277
- "ansi16m"
1278
- ];
1279
- const styles = /* @__PURE__ */ Object.create(null);
1280
- const applyOptions = (object, options = {}) => {
1281
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1282
- throw new Error("The `level` option should be an integer from 0 to 3");
1283
- }
1284
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1285
- object.level = options.level === void 0 ? colorLevel : options.level;
1286
- };
1287
- class ChalkClass {
1288
- constructor(options) {
1289
- return chalkFactory(options);
1290
- }
1291
- }
1292
- const chalkFactory = (options) => {
1293
- const chalk2 = {};
1294
- applyOptions(chalk2, options);
1295
- chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
1296
- Object.setPrototypeOf(chalk2, Chalk.prototype);
1297
- Object.setPrototypeOf(chalk2.template, chalk2);
1298
- chalk2.template.constructor = () => {
1299
- throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1300
- };
1301
- chalk2.template.Instance = ChalkClass;
1302
- return chalk2.template;
1303
- };
1304
- function Chalk(options) {
1305
- return chalkFactory(options);
1306
- }
1307
- for (const [styleName, style] of Object.entries(ansiStyles)) {
1308
- styles[styleName] = {
1309
- get() {
1310
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1311
- Object.defineProperty(this, styleName, { value: builder });
1312
- return builder;
1313
- }
1314
- };
1315
- }
1316
- styles.visible = {
1317
- get() {
1318
- const builder = createBuilder(this, this._styler, true);
1319
- Object.defineProperty(this, "visible", { value: builder });
1320
- return builder;
1321
- }
1322
- };
1323
- const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1324
- for (const model of usedModels) {
1325
- styles[model] = {
1326
- get() {
1327
- const { level } = this;
1328
- return function(...arguments_) {
1329
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1330
- return createBuilder(this, styler, this._isEmpty);
1331
- };
1332
- }
1333
- };
1334
- }
1335
- for (const model of usedModels) {
1336
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1337
- styles[bgModel] = {
1338
- get() {
1339
- const { level } = this;
1340
- return function(...arguments_) {
1341
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1342
- return createBuilder(this, styler, this._isEmpty);
1258
+ (function(module) {
1259
+ const escapeStringRegexp$1 = escapeStringRegexp;
1260
+ const ansiStyles$1 = ansiStyles.exports;
1261
+ const stdoutColor = browser.stdout;
1262
+ const template = templates;
1263
+ const isSimpleWindowsTerm = process.platform === "win32" && !({}.TERM || "").toLowerCase().startsWith("xterm");
1264
+ const levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
1265
+ const skipModels = /* @__PURE__ */ new Set(["gray"]);
1266
+ const styles = /* @__PURE__ */ Object.create(null);
1267
+ function applyOptions(obj, options) {
1268
+ options = options || {};
1269
+ const scLevel = 0;
1270
+ obj.level = options.level === void 0 ? scLevel : options.level;
1271
+ obj.enabled = "enabled" in options ? options.enabled : obj.level > 0;
1272
+ }
1273
+ function Chalk(options) {
1274
+ if (!this || !(this instanceof Chalk) || this.template) {
1275
+ const chalk2 = {};
1276
+ applyOptions(chalk2, options);
1277
+ chalk2.template = function() {
1278
+ const args = [].slice.call(arguments);
1279
+ return chalkTag.apply(null, [chalk2.template].concat(args));
1343
1280
  };
1281
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
1282
+ Object.setPrototypeOf(chalk2.template, chalk2);
1283
+ chalk2.template.constructor = Chalk;
1284
+ return chalk2.template;
1344
1285
  }
1345
- };
1346
- }
1347
- const proto = Object.defineProperties(() => {
1348
- }, __spreadProps(__spreadValues({}, styles), {
1349
- level: {
1350
- enumerable: true,
1351
- get() {
1352
- return this._generator.level;
1353
- },
1354
- set(level) {
1355
- this._generator.level = level;
1356
- }
1357
- }
1358
- }));
1359
- const createStyler = (open, close, parent) => {
1360
- let openAll;
1361
- let closeAll;
1362
- if (parent === void 0) {
1363
- openAll = open;
1364
- closeAll = close;
1365
- } else {
1366
- openAll = parent.openAll + open;
1367
- closeAll = close + parent.closeAll;
1286
+ applyOptions(this, options);
1368
1287
  }
1369
- return {
1370
- open,
1371
- close,
1372
- openAll,
1373
- closeAll,
1374
- parent
1375
- };
1376
- };
1377
- const createBuilder = (self2, _styler, _isEmpty) => {
1378
- const builder = (...arguments_) => {
1379
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1380
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1381
- }
1382
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1383
- };
1384
- Object.setPrototypeOf(builder, proto);
1385
- builder._generator = self2;
1386
- builder._styler = _styler;
1387
- builder._isEmpty = _isEmpty;
1388
- return builder;
1389
- };
1390
- const applyStyle = (self2, string) => {
1391
- if (self2.level <= 0 || !string) {
1392
- return self2._isEmpty ? "" : string;
1288
+ if (isSimpleWindowsTerm) {
1289
+ ansiStyles$1.blue.open = "\x1B[94m";
1393
1290
  }
1394
- let styler = self2._styler;
1395
- if (styler === void 0) {
1396
- return string;
1291
+ for (const key of Object.keys(ansiStyles$1)) {
1292
+ ansiStyles$1[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1[key].close), "g");
1293
+ styles[key] = {
1294
+ get() {
1295
+ const codes = ansiStyles$1[key];
1296
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
1297
+ }
1298
+ };
1397
1299
  }
1398
- const { openAll, closeAll } = styler;
1399
- if (string.indexOf("\x1B") !== -1) {
1400
- while (styler !== void 0) {
1401
- string = stringReplaceAll(string, styler.close, styler.open);
1402
- styler = styler.parent;
1300
+ styles.visible = {
1301
+ get() {
1302
+ return build.call(this, this._styles || [], true, "visible");
1403
1303
  }
1404
- }
1405
- const lfIndex = string.indexOf("\n");
1406
- if (lfIndex !== -1) {
1407
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1408
- }
1409
- return openAll + string + closeAll;
1410
- };
1411
- let template;
1412
- const chalkTag = (chalk2, ...strings) => {
1413
- const [firstString] = strings;
1414
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1415
- return strings.join(" ");
1416
- }
1417
- const arguments_ = strings.slice(1);
1418
- const parts = [firstString.raw[0]];
1419
- for (let i = 1; i < firstString.length; i++) {
1420
- parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
1421
- }
1422
- if (template === void 0) {
1423
- template = templates;
1424
- }
1425
- return template(chalk2, parts.join(""));
1426
- };
1427
- Object.defineProperties(Chalk.prototype, styles);
1428
- const chalk = Chalk();
1429
- chalk.supportsColor = stdoutColor;
1430
- chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1431
- chalk.stderr.supportsColor = stderrColor;
1432
- var source = chalk;
1433
- const log = (message) => {
1434
- console.log(`${source.magenta("JamComments:")} ${message}`);
1435
- };
1436
- const logError = (message) => {
1437
- console.error(`JamComments: ${message}`);
1438
- };
1439
- var requiresPort = function required(port2, protocol) {
1440
- protocol = protocol.split(":")[0];
1441
- port2 = +port2;
1442
- if (!port2)
1443
- return false;
1444
- switch (protocol) {
1445
- case "http":
1446
- case "ws":
1447
- return port2 !== 80;
1448
- case "https":
1449
- case "wss":
1450
- return port2 !== 443;
1451
- case "ftp":
1452
- return port2 !== 21;
1453
- case "gopher":
1454
- return port2 !== 70;
1455
- case "file":
1456
- return false;
1457
- }
1458
- return port2 !== 0;
1459
- };
1460
- var querystringify$1 = {};
1461
- var has = Object.prototype.hasOwnProperty, undef;
1462
- function decode(input) {
1463
- try {
1464
- return decodeURIComponent(input.replace(/\+/g, " "));
1465
- } catch (e) {
1466
- return null;
1467
- }
1468
- }
1469
- function encode(input) {
1470
- try {
1471
- return encodeURIComponent(input);
1472
- } catch (e) {
1473
- return null;
1474
- }
1475
- }
1476
- function querystring(query) {
1477
- var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
1478
- while (part = parser.exec(query)) {
1479
- var key = decode(part[1]), value = decode(part[2]);
1480
- if (key === null || value === null || key in result)
1304
+ };
1305
+ ansiStyles$1.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.color.close), "g");
1306
+ for (const model of Object.keys(ansiStyles$1.color.ansi)) {
1307
+ if (skipModels.has(model)) {
1481
1308
  continue;
1482
- result[key] = value;
1483
- }
1484
- return result;
1485
- }
1486
- function querystringify(obj, prefix) {
1487
- prefix = prefix || "";
1488
- var pairs = [], value, key;
1489
- if (typeof prefix !== "string")
1490
- prefix = "?";
1491
- for (key in obj) {
1492
- if (has.call(obj, key)) {
1493
- value = obj[key];
1494
- if (!value && (value === null || value === undef || isNaN(value))) {
1495
- value = "";
1496
- }
1497
- key = encode(key);
1498
- value = encode(value);
1499
- if (key === null || value === null)
1500
- continue;
1501
- pairs.push(key + "=" + value);
1502
1309
  }
1310
+ styles[model] = {
1311
+ get() {
1312
+ const level = this.level;
1313
+ return function() {
1314
+ const open = ansiStyles$1.color[levelMapping[level]][model].apply(null, arguments);
1315
+ const codes = {
1316
+ open,
1317
+ close: ansiStyles$1.color.close,
1318
+ closeRe: ansiStyles$1.color.closeRe
1319
+ };
1320
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
1321
+ };
1322
+ }
1323
+ };
1503
1324
  }
1504
- return pairs.length ? prefix + pairs.join("&") : "";
1505
- }
1506
- querystringify$1.stringify = querystringify;
1507
- querystringify$1.parse = querystring;
1508
- var required2 = requiresPort, qs = querystringify$1, controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, CRHTLF = /[\n\r\t]/g, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, port = /:\d+$/, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, windowsDriveLetter = /^[a-zA-Z]:/;
1509
- function trimLeft(str) {
1510
- return (str ? str : "").toString().replace(controlOrWhitespace, "");
1511
- }
1512
- var rules = [
1513
- ["#", "hash"],
1514
- ["?", "query"],
1515
- function sanitize(address, url) {
1516
- return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
1517
- },
1518
- ["/", "pathname"],
1519
- ["@", "auth", 1],
1520
- [NaN, "host", void 0, 1, 1],
1521
- [/:(\d*)$/, "port", void 0, 1],
1522
- [NaN, "hostname", void 0, 1, 1]
1523
- ];
1524
- var ignore = { hash: 1, query: 1 };
1525
- function lolcation(loc) {
1526
- var globalVar;
1527
- if (typeof window !== "undefined")
1528
- globalVar = window;
1529
- else if (typeof commonjsGlobal !== "undefined")
1530
- globalVar = commonjsGlobal;
1531
- else if (typeof self !== "undefined")
1532
- globalVar = self;
1533
- else
1534
- globalVar = {};
1535
- var location = globalVar.location || {};
1536
- loc = loc || location;
1537
- var finaldestination = {}, type = typeof loc, key;
1538
- if (loc.protocol === "blob:") {
1539
- finaldestination = new Url(unescape(loc.pathname), {});
1540
- } else if (type === "string") {
1541
- finaldestination = new Url(loc, {});
1542
- for (key in ignore)
1543
- delete finaldestination[key];
1544
- } else if (type === "object") {
1545
- for (key in loc) {
1546
- if (key in ignore)
1547
- continue;
1548
- finaldestination[key] = loc[key];
1549
- }
1550
- if (finaldestination.slashes === void 0) {
1551
- finaldestination.slashes = slashes.test(loc.href);
1325
+ ansiStyles$1.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.bgColor.close), "g");
1326
+ for (const model of Object.keys(ansiStyles$1.bgColor.ansi)) {
1327
+ if (skipModels.has(model)) {
1328
+ continue;
1552
1329
  }
1330
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1331
+ styles[bgModel] = {
1332
+ get() {
1333
+ const level = this.level;
1334
+ return function() {
1335
+ const open = ansiStyles$1.bgColor[levelMapping[level]][model].apply(null, arguments);
1336
+ const codes = {
1337
+ open,
1338
+ close: ansiStyles$1.bgColor.close,
1339
+ closeRe: ansiStyles$1.bgColor.closeRe
1340
+ };
1341
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
1342
+ };
1343
+ }
1344
+ };
1553
1345
  }
1554
- return finaldestination;
1555
- }
1556
- function isSpecial(scheme) {
1557
- return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
1558
- }
1559
- function extractProtocol(address, location) {
1560
- address = trimLeft(address);
1561
- address = address.replace(CRHTLF, "");
1562
- location = location || {};
1563
- var match = protocolre.exec(address);
1564
- var protocol = match[1] ? match[1].toLowerCase() : "";
1565
- var forwardSlashes = !!match[2];
1566
- var otherSlashes = !!match[3];
1567
- var slashesCount = 0;
1568
- var rest;
1569
- if (forwardSlashes) {
1570
- if (otherSlashes) {
1571
- rest = match[2] + match[3] + match[4];
1572
- slashesCount = match[2].length + match[3].length;
1573
- } else {
1574
- rest = match[2] + match[4];
1575
- slashesCount = match[2].length;
1576
- }
1577
- } else {
1578
- if (otherSlashes) {
1579
- rest = match[3] + match[4];
1580
- slashesCount = match[3].length;
1581
- } else {
1582
- rest = match[4];
1583
- }
1346
+ const proto = Object.defineProperties(() => {
1347
+ }, styles);
1348
+ function build(_styles, _empty, key) {
1349
+ const builder = function() {
1350
+ return applyStyle.apply(builder, arguments);
1351
+ };
1352
+ builder._styles = _styles;
1353
+ builder._empty = _empty;
1354
+ const self = this;
1355
+ Object.defineProperty(builder, "level", {
1356
+ enumerable: true,
1357
+ get() {
1358
+ return self.level;
1359
+ },
1360
+ set(level) {
1361
+ self.level = level;
1362
+ }
1363
+ });
1364
+ Object.defineProperty(builder, "enabled", {
1365
+ enumerable: true,
1366
+ get() {
1367
+ return self.enabled;
1368
+ },
1369
+ set(enabled) {
1370
+ self.enabled = enabled;
1371
+ }
1372
+ });
1373
+ builder.hasGrey = this.hasGrey || key === "gray" || key === "grey";
1374
+ builder.__proto__ = proto;
1375
+ return builder;
1584
1376
  }
1585
- if (protocol === "file:") {
1586
- if (slashesCount >= 2) {
1587
- rest = rest.slice(2);
1377
+ function applyStyle() {
1378
+ const args = arguments;
1379
+ const argsLen = args.length;
1380
+ let str = String(arguments[0]);
1381
+ if (argsLen === 0) {
1382
+ return "";
1588
1383
  }
1589
- } else if (isSpecial(protocol)) {
1590
- rest = match[4];
1591
- } else if (protocol) {
1592
- if (forwardSlashes) {
1593
- rest = rest.slice(2);
1384
+ if (argsLen > 1) {
1385
+ for (let a = 1; a < argsLen; a++) {
1386
+ str += " " + args[a];
1387
+ }
1594
1388
  }
1595
- } else if (slashesCount >= 2 && isSpecial(location.protocol)) {
1596
- rest = match[4];
1597
- }
1598
- return {
1599
- protocol,
1600
- slashes: forwardSlashes || isSpecial(protocol),
1601
- slashesCount,
1602
- rest
1603
- };
1604
- }
1605
- function resolve(relative, base) {
1606
- if (relative === "")
1607
- return base;
1608
- var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
1609
- while (i--) {
1610
- if (path[i] === ".") {
1611
- path.splice(i, 1);
1612
- } else if (path[i] === "..") {
1613
- path.splice(i, 1);
1614
- up++;
1615
- } else if (up) {
1616
- if (i === 0)
1617
- unshift = true;
1618
- path.splice(i, 1);
1619
- up--;
1389
+ if (!this.enabled || this.level <= 0 || !str) {
1390
+ return this._empty ? "" : str;
1620
1391
  }
1621
- }
1622
- if (unshift)
1623
- path.unshift("");
1624
- if (last === "." || last === "..")
1625
- path.push("");
1626
- return path.join("/");
1627
- }
1628
- function Url(address, location, parser) {
1629
- address = trimLeft(address);
1630
- address = address.replace(CRHTLF, "");
1631
- if (!(this instanceof Url)) {
1632
- return new Url(address, location, parser);
1633
- }
1634
- var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
1635
- if (type !== "object" && type !== "string") {
1636
- parser = location;
1637
- location = null;
1638
- }
1639
- if (parser && typeof parser !== "function")
1640
- parser = qs.parse;
1641
- location = lolcation(location);
1642
- extracted = extractProtocol(address || "", location);
1643
- relative = !extracted.protocol && !extracted.slashes;
1644
- url.slashes = extracted.slashes || relative && location.slashes;
1645
- url.protocol = extracted.protocol || location.protocol || "";
1646
- address = extracted.rest;
1647
- if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
1648
- instructions[3] = [/(.*)/, "pathname"];
1649
- }
1650
- for (; i < instructions.length; i++) {
1651
- instruction = instructions[i];
1652
- if (typeof instruction === "function") {
1653
- address = instruction(address, url);
1654
- continue;
1392
+ const originalDim = ansiStyles$1.dim.open;
1393
+ if (isSimpleWindowsTerm && this.hasGrey) {
1394
+ ansiStyles$1.dim.open = "";
1655
1395
  }
1656
- parse = instruction[0];
1657
- key = instruction[1];
1658
- if (parse !== parse) {
1659
- url[key] = address;
1660
- } else if (typeof parse === "string") {
1661
- index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
1662
- if (~index) {
1663
- if (typeof instruction[2] === "number") {
1664
- url[key] = address.slice(0, index);
1665
- address = address.slice(index + instruction[2]);
1666
- } else {
1667
- url[key] = address.slice(index);
1668
- address = address.slice(0, index);
1669
- }
1670
- }
1671
- } else if (index = parse.exec(address)) {
1672
- url[key] = index[1];
1673
- address = address.slice(0, index.index);
1396
+ for (const code of this._styles.slice().reverse()) {
1397
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
1398
+ str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
1674
1399
  }
1675
- url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
1676
- if (instruction[4])
1677
- url[key] = url[key].toLowerCase();
1400
+ ansiStyles$1.dim.open = originalDim;
1401
+ return str;
1678
1402
  }
1679
- if (parser)
1680
- url.query = parser(url.query);
1681
- if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
1682
- url.pathname = resolve(url.pathname, location.pathname);
1683
- }
1684
- if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
1685
- url.pathname = "/" + url.pathname;
1686
- }
1687
- if (!required2(url.port, url.protocol)) {
1688
- url.host = url.hostname;
1689
- url.port = "";
1690
- }
1691
- url.username = url.password = "";
1692
- if (url.auth) {
1693
- index = url.auth.indexOf(":");
1694
- if (~index) {
1695
- url.username = url.auth.slice(0, index);
1696
- url.username = encodeURIComponent(decodeURIComponent(url.username));
1697
- url.password = url.auth.slice(index + 1);
1698
- url.password = encodeURIComponent(decodeURIComponent(url.password));
1699
- } else {
1700
- url.username = encodeURIComponent(decodeURIComponent(url.auth));
1403
+ function chalkTag(chalk2, strings) {
1404
+ if (!Array.isArray(strings)) {
1405
+ return [].slice.call(arguments, 1).join(" ");
1701
1406
  }
1702
- url.auth = url.password ? url.username + ":" + url.password : url.username;
1703
- }
1704
- url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
1705
- url.href = url.toString();
1706
- }
1707
- function set(part, value, fn) {
1708
- var url = this;
1709
- switch (part) {
1710
- case "query":
1711
- if (typeof value === "string" && value.length) {
1712
- value = (fn || qs.parse)(value);
1713
- }
1714
- url[part] = value;
1715
- break;
1716
- case "port":
1717
- url[part] = value;
1718
- if (!required2(value, url.protocol)) {
1719
- url.host = url.hostname;
1720
- url[part] = "";
1721
- } else if (value) {
1722
- url.host = url.hostname + ":" + value;
1723
- }
1724
- break;
1725
- case "hostname":
1726
- url[part] = value;
1727
- if (url.port)
1728
- value += ":" + url.port;
1729
- url.host = value;
1730
- break;
1731
- case "host":
1732
- url[part] = value;
1733
- if (port.test(value)) {
1734
- value = value.split(":");
1735
- url.port = value.pop();
1736
- url.hostname = value.join(":");
1737
- } else {
1738
- url.hostname = value;
1739
- url.port = "";
1740
- }
1741
- break;
1742
- case "protocol":
1743
- url.protocol = value.toLowerCase();
1744
- url.slashes = !fn;
1745
- break;
1746
- case "pathname":
1747
- case "hash":
1748
- if (value) {
1749
- var char = part === "pathname" ? "/" : "#";
1750
- url[part] = value.charAt(0) !== char ? char + value : value;
1751
- } else {
1752
- url[part] = value;
1753
- }
1754
- break;
1755
- case "username":
1756
- case "password":
1757
- url[part] = encodeURIComponent(value);
1758
- break;
1759
- case "auth":
1760
- var index = value.indexOf(":");
1761
- if (~index) {
1762
- url.username = value.slice(0, index);
1763
- url.username = encodeURIComponent(decodeURIComponent(url.username));
1764
- url.password = value.slice(index + 1);
1765
- url.password = encodeURIComponent(decodeURIComponent(url.password));
1766
- } else {
1767
- url.username = encodeURIComponent(decodeURIComponent(value));
1768
- }
1769
- }
1770
- for (var i = 0; i < rules.length; i++) {
1771
- var ins = rules[i];
1772
- if (ins[4])
1773
- url[ins[1]] = url[ins[1]].toLowerCase();
1774
- }
1775
- url.auth = url.password ? url.username + ":" + url.password : url.username;
1776
- url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
1777
- url.href = url.toString();
1778
- return url;
1779
- }
1780
- function toString(stringify) {
1781
- if (!stringify || typeof stringify !== "function")
1782
- stringify = qs.stringify;
1783
- var query, url = this, host = url.host, protocol = url.protocol;
1784
- if (protocol && protocol.charAt(protocol.length - 1) !== ":")
1785
- protocol += ":";
1786
- var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
1787
- if (url.username) {
1788
- result += url.username;
1789
- if (url.password)
1790
- result += ":" + url.password;
1791
- result += "@";
1792
- } else if (url.password) {
1793
- result += ":" + url.password;
1794
- result += "@";
1795
- } else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
1796
- result += "@";
1797
- }
1798
- if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) {
1799
- host += ":";
1800
- }
1801
- result += host + url.pathname;
1802
- query = typeof url.query === "object" ? stringify(url.query) : url.query;
1803
- if (query)
1804
- result += query.charAt(0) !== "?" ? "?" + query : query;
1805
- if (url.hash)
1806
- result += url.hash;
1807
- return result;
1808
- }
1809
- Url.prototype = { set, toString };
1810
- Url.extractProtocol = extractProtocol;
1811
- Url.location = lolcation;
1812
- Url.trimLeft = trimLeft;
1813
- Url.qs = qs;
1814
- var urlParse = Url;
1815
- const parsePath = (urlOrPath) => {
1816
- const pathName = new urlParse(urlOrPath)["pathname"] || "";
1817
- return pathName.replace(/^(\/{1,})|\/{1,}$/g, "");
1818
- };
1819
- const filterByUrl = (comments, urlOrPath) => {
1820
- const pagePath = parsePath(urlOrPath);
1821
- return comments.filter((comment) => {
1822
- if (!comment.path) {
1823
- return false;
1407
+ const args = [].slice.call(arguments, 2);
1408
+ const parts = [strings.raw[0]];
1409
+ for (let i = 1; i < strings.length; i++) {
1410
+ parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&"));
1411
+ parts.push(String(strings.raw[i]));
1824
1412
  }
1825
- const commentPath = parsePath(comment.path);
1826
- return commentPath === pagePath;
1827
- });
1413
+ return template(chalk2, parts.join(""));
1414
+ }
1415
+ Object.defineProperties(Chalk.prototype, styles);
1416
+ module.exports = Chalk();
1417
+ module.exports.supportsColor = stdoutColor;
1418
+ module.exports.default = module.exports;
1419
+ })(chalk$1);
1420
+ var chalk = chalk$1.exports;
1421
+ const log = (message) => {
1422
+ console.log(`${chalk.magenta("JamComments:")} ${message}`);
1828
1423
  };
1829
- const makeHtmlReady = (content) => {
1830
- if (/(^<[a-z]+>)(.*)(<\/[a-z]+>)$/.test(content)) {
1831
- return content;
1832
- }
1833
- return content.split(/(?:\r\n|\r|\n)/).filter((text) => !!text).map((text) => `<p>${text.trim()}</p>`).join("");
1424
+ const logError = (message) => {
1425
+ console.error(`JamComments: ${message}`);
1834
1426
  };
1835
- export { filterByUrl, log, logError, makeHtmlReady, markupFetcher, parsePath };
1427
+ export { log, logError, markupFetcher };