@ni/nimble-components 15.5.5 → 15.5.7

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.
@@ -1323,7 +1323,7 @@
1323
1323
 
1324
1324
  // A singleton Range instance used to efficiently remove ranges of DOM nodes.
1325
1325
  // See the implementation of HTMLView below for further details.
1326
- const range = document.createRange();
1326
+ const range$1 = document.createRange();
1327
1327
  /**
1328
1328
  * The standard View implementation, which also implements ElementView and SyntheticView.
1329
1329
  * @public
@@ -1465,9 +1465,9 @@
1465
1465
  if (views.length === 0) {
1466
1466
  return;
1467
1467
  }
1468
- range.setStartBefore(views[0].firstChild);
1469
- range.setEndAfter(views[views.length - 1].lastChild);
1470
- range.deleteContents();
1468
+ range$1.setStartBefore(views[0].firstChild);
1469
+ range$1.setEndAfter(views[views.length - 1].lastChild);
1470
+ range$1.deleteContents();
1471
1471
  for (let i = 0, ii = views.length; i < ii; ++i) {
1472
1472
  const view = views[i];
1473
1473
  const behaviors = view.behaviors;
@@ -25932,11 +25932,2824 @@ Instead styling against the role which is more general and likely a better appro
25932
25932
  left: 'left',
25933
25933
  right: 'right'
25934
25934
  };
25935
- const WaferMapColorsScaleMode = {
25935
+ const WaferMapColorScaleMode = {
25936
25936
  linear: 'linear',
25937
25937
  ordinal: 'ordinal'
25938
25938
  };
25939
25939
 
25940
+ function ascending(a, b) {
25941
+ return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
25942
+ }
25943
+
25944
+ function descending(a, b) {
25945
+ return a == null || b == null ? NaN
25946
+ : b < a ? -1
25947
+ : b > a ? 1
25948
+ : b >= a ? 0
25949
+ : NaN;
25950
+ }
25951
+
25952
+ function bisector(f) {
25953
+ let compare1, compare2, delta;
25954
+
25955
+ // If an accessor is specified, promote it to a comparator. In this case we
25956
+ // can test whether the search value is (self-) comparable. We can’t do this
25957
+ // for a comparator (except for specific, known comparators) because we can’t
25958
+ // tell if the comparator is symmetric, and an asymmetric comparator can’t be
25959
+ // used to test whether a single value is comparable.
25960
+ if (f.length !== 2) {
25961
+ compare1 = ascending;
25962
+ compare2 = (d, x) => ascending(f(d), x);
25963
+ delta = (d, x) => f(d) - x;
25964
+ } else {
25965
+ compare1 = f === ascending || f === descending ? f : zero$1;
25966
+ compare2 = f;
25967
+ delta = f;
25968
+ }
25969
+
25970
+ function left(a, x, lo = 0, hi = a.length) {
25971
+ if (lo < hi) {
25972
+ if (compare1(x, x) !== 0) return hi;
25973
+ do {
25974
+ const mid = (lo + hi) >>> 1;
25975
+ if (compare2(a[mid], x) < 0) lo = mid + 1;
25976
+ else hi = mid;
25977
+ } while (lo < hi);
25978
+ }
25979
+ return lo;
25980
+ }
25981
+
25982
+ function right(a, x, lo = 0, hi = a.length) {
25983
+ if (lo < hi) {
25984
+ if (compare1(x, x) !== 0) return hi;
25985
+ do {
25986
+ const mid = (lo + hi) >>> 1;
25987
+ if (compare2(a[mid], x) <= 0) lo = mid + 1;
25988
+ else hi = mid;
25989
+ } while (lo < hi);
25990
+ }
25991
+ return lo;
25992
+ }
25993
+
25994
+ function center(a, x, lo = 0, hi = a.length) {
25995
+ const i = left(a, x, lo, hi - 1);
25996
+ return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
25997
+ }
25998
+
25999
+ return {left, center, right};
26000
+ }
26001
+
26002
+ function zero$1() {
26003
+ return 0;
26004
+ }
26005
+
26006
+ function number$1(x) {
26007
+ return x === null ? NaN : +x;
26008
+ }
26009
+
26010
+ const ascendingBisect = bisector(ascending);
26011
+ const bisectRight = ascendingBisect.right;
26012
+ bisector(number$1).center;
26013
+ var bisect = bisectRight;
26014
+
26015
+ class InternMap extends Map {
26016
+ constructor(entries, key = keyof) {
26017
+ super();
26018
+ Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
26019
+ if (entries != null) for (const [key, value] of entries) this.set(key, value);
26020
+ }
26021
+ get(key) {
26022
+ return super.get(intern_get(this, key));
26023
+ }
26024
+ has(key) {
26025
+ return super.has(intern_get(this, key));
26026
+ }
26027
+ set(key, value) {
26028
+ return super.set(intern_set(this, key), value);
26029
+ }
26030
+ delete(key) {
26031
+ return super.delete(intern_delete(this, key));
26032
+ }
26033
+ }
26034
+
26035
+ function intern_get({_intern, _key}, value) {
26036
+ const key = _key(value);
26037
+ return _intern.has(key) ? _intern.get(key) : value;
26038
+ }
26039
+
26040
+ function intern_set({_intern, _key}, value) {
26041
+ const key = _key(value);
26042
+ if (_intern.has(key)) return _intern.get(key);
26043
+ _intern.set(key, value);
26044
+ return value;
26045
+ }
26046
+
26047
+ function intern_delete({_intern, _key}, value) {
26048
+ const key = _key(value);
26049
+ if (_intern.has(key)) {
26050
+ value = _intern.get(key);
26051
+ _intern.delete(key);
26052
+ }
26053
+ return value;
26054
+ }
26055
+
26056
+ function keyof(value) {
26057
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
26058
+ }
26059
+
26060
+ var e10 = Math.sqrt(50),
26061
+ e5 = Math.sqrt(10),
26062
+ e2 = Math.sqrt(2);
26063
+
26064
+ function ticks(start, stop, count) {
26065
+ var reverse,
26066
+ i = -1,
26067
+ n,
26068
+ ticks,
26069
+ step;
26070
+
26071
+ stop = +stop, start = +start, count = +count;
26072
+ if (start === stop && count > 0) return [start];
26073
+ if (reverse = stop < start) n = start, start = stop, stop = n;
26074
+ if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
26075
+
26076
+ if (step > 0) {
26077
+ let r0 = Math.round(start / step), r1 = Math.round(stop / step);
26078
+ if (r0 * step < start) ++r0;
26079
+ if (r1 * step > stop) --r1;
26080
+ ticks = new Array(n = r1 - r0 + 1);
26081
+ while (++i < n) ticks[i] = (r0 + i) * step;
26082
+ } else {
26083
+ step = -step;
26084
+ let r0 = Math.round(start * step), r1 = Math.round(stop * step);
26085
+ if (r0 / step < start) ++r0;
26086
+ if (r1 / step > stop) --r1;
26087
+ ticks = new Array(n = r1 - r0 + 1);
26088
+ while (++i < n) ticks[i] = (r0 + i) / step;
26089
+ }
26090
+
26091
+ if (reverse) ticks.reverse();
26092
+
26093
+ return ticks;
26094
+ }
26095
+
26096
+ function tickIncrement(start, stop, count) {
26097
+ var step = (stop - start) / Math.max(0, count),
26098
+ power = Math.floor(Math.log(step) / Math.LN10),
26099
+ error = step / Math.pow(10, power);
26100
+ return power >= 0
26101
+ ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
26102
+ : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
26103
+ }
26104
+
26105
+ function tickStep(start, stop, count) {
26106
+ var step0 = Math.abs(stop - start) / Math.max(0, count),
26107
+ step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
26108
+ error = step0 / step1;
26109
+ if (error >= e10) step1 *= 10;
26110
+ else if (error >= e5) step1 *= 5;
26111
+ else if (error >= e2) step1 *= 2;
26112
+ return stop < start ? -step1 : step1;
26113
+ }
26114
+
26115
+ function range(start, stop, step) {
26116
+ start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
26117
+
26118
+ var i = -1,
26119
+ n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
26120
+ range = new Array(n);
26121
+
26122
+ while (++i < n) {
26123
+ range[i] = start + i * step;
26124
+ }
26125
+
26126
+ return range;
26127
+ }
26128
+
26129
+ function initRange(domain, range) {
26130
+ switch (arguments.length) {
26131
+ case 0: break;
26132
+ case 1: this.range(domain); break;
26133
+ default: this.range(range).domain(domain); break;
26134
+ }
26135
+ return this;
26136
+ }
26137
+
26138
+ const implicit = Symbol("implicit");
26139
+
26140
+ function ordinal() {
26141
+ var index = new InternMap(),
26142
+ domain = [],
26143
+ range = [],
26144
+ unknown = implicit;
26145
+
26146
+ function scale(d) {
26147
+ let i = index.get(d);
26148
+ if (i === undefined) {
26149
+ if (unknown !== implicit) return unknown;
26150
+ index.set(d, i = domain.push(d) - 1);
26151
+ }
26152
+ return range[i % range.length];
26153
+ }
26154
+
26155
+ scale.domain = function(_) {
26156
+ if (!arguments.length) return domain.slice();
26157
+ domain = [], index = new InternMap();
26158
+ for (const value of _) {
26159
+ if (index.has(value)) continue;
26160
+ index.set(value, domain.push(value) - 1);
26161
+ }
26162
+ return scale;
26163
+ };
26164
+
26165
+ scale.range = function(_) {
26166
+ return arguments.length ? (range = Array.from(_), scale) : range.slice();
26167
+ };
26168
+
26169
+ scale.unknown = function(_) {
26170
+ return arguments.length ? (unknown = _, scale) : unknown;
26171
+ };
26172
+
26173
+ scale.copy = function() {
26174
+ return ordinal(domain, range).unknown(unknown);
26175
+ };
26176
+
26177
+ initRange.apply(scale, arguments);
26178
+
26179
+ return scale;
26180
+ }
26181
+
26182
+ function band() {
26183
+ var scale = ordinal().unknown(undefined),
26184
+ domain = scale.domain,
26185
+ ordinalRange = scale.range,
26186
+ r0 = 0,
26187
+ r1 = 1,
26188
+ step,
26189
+ bandwidth,
26190
+ round = false,
26191
+ paddingInner = 0,
26192
+ paddingOuter = 0,
26193
+ align = 0.5;
26194
+
26195
+ delete scale.unknown;
26196
+
26197
+ function rescale() {
26198
+ var n = domain().length,
26199
+ reverse = r1 < r0,
26200
+ start = reverse ? r1 : r0,
26201
+ stop = reverse ? r0 : r1;
26202
+ step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
26203
+ if (round) step = Math.floor(step);
26204
+ start += (stop - start - step * (n - paddingInner)) * align;
26205
+ bandwidth = step * (1 - paddingInner);
26206
+ if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
26207
+ var values = range(n).map(function(i) { return start + step * i; });
26208
+ return ordinalRange(reverse ? values.reverse() : values);
26209
+ }
26210
+
26211
+ scale.domain = function(_) {
26212
+ return arguments.length ? (domain(_), rescale()) : domain();
26213
+ };
26214
+
26215
+ scale.range = function(_) {
26216
+ return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1];
26217
+ };
26218
+
26219
+ scale.rangeRound = function(_) {
26220
+ return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale();
26221
+ };
26222
+
26223
+ scale.bandwidth = function() {
26224
+ return bandwidth;
26225
+ };
26226
+
26227
+ scale.step = function() {
26228
+ return step;
26229
+ };
26230
+
26231
+ scale.round = function(_) {
26232
+ return arguments.length ? (round = !!_, rescale()) : round;
26233
+ };
26234
+
26235
+ scale.padding = function(_) {
26236
+ return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
26237
+ };
26238
+
26239
+ scale.paddingInner = function(_) {
26240
+ return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
26241
+ };
26242
+
26243
+ scale.paddingOuter = function(_) {
26244
+ return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
26245
+ };
26246
+
26247
+ scale.align = function(_) {
26248
+ return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
26249
+ };
26250
+
26251
+ scale.copy = function() {
26252
+ return band(domain(), [r0, r1])
26253
+ .round(round)
26254
+ .paddingInner(paddingInner)
26255
+ .paddingOuter(paddingOuter)
26256
+ .align(align);
26257
+ };
26258
+
26259
+ return initRange.apply(rescale(), arguments);
26260
+ }
26261
+
26262
+ function define(constructor, factory, prototype) {
26263
+ constructor.prototype = factory.prototype = prototype;
26264
+ prototype.constructor = constructor;
26265
+ }
26266
+
26267
+ function extend(parent, definition) {
26268
+ var prototype = Object.create(parent.prototype);
26269
+ for (var key in definition) prototype[key] = definition[key];
26270
+ return prototype;
26271
+ }
26272
+
26273
+ function Color() {}
26274
+
26275
+ var darker = 0.7;
26276
+ var brighter = 1 / darker;
26277
+
26278
+ var reI = "\\s*([+-]?\\d+)\\s*",
26279
+ reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
26280
+ reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
26281
+ reHex = /^#([0-9a-f]{3,8})$/,
26282
+ reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
26283
+ reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
26284
+ reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
26285
+ reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
26286
+ reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
26287
+ reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
26288
+
26289
+ var named = {
26290
+ aliceblue: 0xf0f8ff,
26291
+ antiquewhite: 0xfaebd7,
26292
+ aqua: 0x00ffff,
26293
+ aquamarine: 0x7fffd4,
26294
+ azure: 0xf0ffff,
26295
+ beige: 0xf5f5dc,
26296
+ bisque: 0xffe4c4,
26297
+ black: 0x000000,
26298
+ blanchedalmond: 0xffebcd,
26299
+ blue: 0x0000ff,
26300
+ blueviolet: 0x8a2be2,
26301
+ brown: 0xa52a2a,
26302
+ burlywood: 0xdeb887,
26303
+ cadetblue: 0x5f9ea0,
26304
+ chartreuse: 0x7fff00,
26305
+ chocolate: 0xd2691e,
26306
+ coral: 0xff7f50,
26307
+ cornflowerblue: 0x6495ed,
26308
+ cornsilk: 0xfff8dc,
26309
+ crimson: 0xdc143c,
26310
+ cyan: 0x00ffff,
26311
+ darkblue: 0x00008b,
26312
+ darkcyan: 0x008b8b,
26313
+ darkgoldenrod: 0xb8860b,
26314
+ darkgray: 0xa9a9a9,
26315
+ darkgreen: 0x006400,
26316
+ darkgrey: 0xa9a9a9,
26317
+ darkkhaki: 0xbdb76b,
26318
+ darkmagenta: 0x8b008b,
26319
+ darkolivegreen: 0x556b2f,
26320
+ darkorange: 0xff8c00,
26321
+ darkorchid: 0x9932cc,
26322
+ darkred: 0x8b0000,
26323
+ darksalmon: 0xe9967a,
26324
+ darkseagreen: 0x8fbc8f,
26325
+ darkslateblue: 0x483d8b,
26326
+ darkslategray: 0x2f4f4f,
26327
+ darkslategrey: 0x2f4f4f,
26328
+ darkturquoise: 0x00ced1,
26329
+ darkviolet: 0x9400d3,
26330
+ deeppink: 0xff1493,
26331
+ deepskyblue: 0x00bfff,
26332
+ dimgray: 0x696969,
26333
+ dimgrey: 0x696969,
26334
+ dodgerblue: 0x1e90ff,
26335
+ firebrick: 0xb22222,
26336
+ floralwhite: 0xfffaf0,
26337
+ forestgreen: 0x228b22,
26338
+ fuchsia: 0xff00ff,
26339
+ gainsboro: 0xdcdcdc,
26340
+ ghostwhite: 0xf8f8ff,
26341
+ gold: 0xffd700,
26342
+ goldenrod: 0xdaa520,
26343
+ gray: 0x808080,
26344
+ green: 0x008000,
26345
+ greenyellow: 0xadff2f,
26346
+ grey: 0x808080,
26347
+ honeydew: 0xf0fff0,
26348
+ hotpink: 0xff69b4,
26349
+ indianred: 0xcd5c5c,
26350
+ indigo: 0x4b0082,
26351
+ ivory: 0xfffff0,
26352
+ khaki: 0xf0e68c,
26353
+ lavender: 0xe6e6fa,
26354
+ lavenderblush: 0xfff0f5,
26355
+ lawngreen: 0x7cfc00,
26356
+ lemonchiffon: 0xfffacd,
26357
+ lightblue: 0xadd8e6,
26358
+ lightcoral: 0xf08080,
26359
+ lightcyan: 0xe0ffff,
26360
+ lightgoldenrodyellow: 0xfafad2,
26361
+ lightgray: 0xd3d3d3,
26362
+ lightgreen: 0x90ee90,
26363
+ lightgrey: 0xd3d3d3,
26364
+ lightpink: 0xffb6c1,
26365
+ lightsalmon: 0xffa07a,
26366
+ lightseagreen: 0x20b2aa,
26367
+ lightskyblue: 0x87cefa,
26368
+ lightslategray: 0x778899,
26369
+ lightslategrey: 0x778899,
26370
+ lightsteelblue: 0xb0c4de,
26371
+ lightyellow: 0xffffe0,
26372
+ lime: 0x00ff00,
26373
+ limegreen: 0x32cd32,
26374
+ linen: 0xfaf0e6,
26375
+ magenta: 0xff00ff,
26376
+ maroon: 0x800000,
26377
+ mediumaquamarine: 0x66cdaa,
26378
+ mediumblue: 0x0000cd,
26379
+ mediumorchid: 0xba55d3,
26380
+ mediumpurple: 0x9370db,
26381
+ mediumseagreen: 0x3cb371,
26382
+ mediumslateblue: 0x7b68ee,
26383
+ mediumspringgreen: 0x00fa9a,
26384
+ mediumturquoise: 0x48d1cc,
26385
+ mediumvioletred: 0xc71585,
26386
+ midnightblue: 0x191970,
26387
+ mintcream: 0xf5fffa,
26388
+ mistyrose: 0xffe4e1,
26389
+ moccasin: 0xffe4b5,
26390
+ navajowhite: 0xffdead,
26391
+ navy: 0x000080,
26392
+ oldlace: 0xfdf5e6,
26393
+ olive: 0x808000,
26394
+ olivedrab: 0x6b8e23,
26395
+ orange: 0xffa500,
26396
+ orangered: 0xff4500,
26397
+ orchid: 0xda70d6,
26398
+ palegoldenrod: 0xeee8aa,
26399
+ palegreen: 0x98fb98,
26400
+ paleturquoise: 0xafeeee,
26401
+ palevioletred: 0xdb7093,
26402
+ papayawhip: 0xffefd5,
26403
+ peachpuff: 0xffdab9,
26404
+ peru: 0xcd853f,
26405
+ pink: 0xffc0cb,
26406
+ plum: 0xdda0dd,
26407
+ powderblue: 0xb0e0e6,
26408
+ purple: 0x800080,
26409
+ rebeccapurple: 0x663399,
26410
+ red: 0xff0000,
26411
+ rosybrown: 0xbc8f8f,
26412
+ royalblue: 0x4169e1,
26413
+ saddlebrown: 0x8b4513,
26414
+ salmon: 0xfa8072,
26415
+ sandybrown: 0xf4a460,
26416
+ seagreen: 0x2e8b57,
26417
+ seashell: 0xfff5ee,
26418
+ sienna: 0xa0522d,
26419
+ silver: 0xc0c0c0,
26420
+ skyblue: 0x87ceeb,
26421
+ slateblue: 0x6a5acd,
26422
+ slategray: 0x708090,
26423
+ slategrey: 0x708090,
26424
+ snow: 0xfffafa,
26425
+ springgreen: 0x00ff7f,
26426
+ steelblue: 0x4682b4,
26427
+ tan: 0xd2b48c,
26428
+ teal: 0x008080,
26429
+ thistle: 0xd8bfd8,
26430
+ tomato: 0xff6347,
26431
+ turquoise: 0x40e0d0,
26432
+ violet: 0xee82ee,
26433
+ wheat: 0xf5deb3,
26434
+ white: 0xffffff,
26435
+ whitesmoke: 0xf5f5f5,
26436
+ yellow: 0xffff00,
26437
+ yellowgreen: 0x9acd32
26438
+ };
26439
+
26440
+ define(Color, color, {
26441
+ copy(channels) {
26442
+ return Object.assign(new this.constructor, this, channels);
26443
+ },
26444
+ displayable() {
26445
+ return this.rgb().displayable();
26446
+ },
26447
+ hex: color_formatHex, // Deprecated! Use color.formatHex.
26448
+ formatHex: color_formatHex,
26449
+ formatHex8: color_formatHex8,
26450
+ formatHsl: color_formatHsl,
26451
+ formatRgb: color_formatRgb,
26452
+ toString: color_formatRgb
26453
+ });
26454
+
26455
+ function color_formatHex() {
26456
+ return this.rgb().formatHex();
26457
+ }
26458
+
26459
+ function color_formatHex8() {
26460
+ return this.rgb().formatHex8();
26461
+ }
26462
+
26463
+ function color_formatHsl() {
26464
+ return hslConvert(this).formatHsl();
26465
+ }
26466
+
26467
+ function color_formatRgb() {
26468
+ return this.rgb().formatRgb();
26469
+ }
26470
+
26471
+ function color(format) {
26472
+ var m, l;
26473
+ format = (format + "").trim().toLowerCase();
26474
+ return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
26475
+ : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
26476
+ : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
26477
+ : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
26478
+ : null) // invalid hex
26479
+ : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
26480
+ : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
26481
+ : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
26482
+ : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
26483
+ : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
26484
+ : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
26485
+ : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
26486
+ : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
26487
+ : null;
26488
+ }
26489
+
26490
+ function rgbn(n) {
26491
+ return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
26492
+ }
26493
+
26494
+ function rgba(r, g, b, a) {
26495
+ if (a <= 0) r = g = b = NaN;
26496
+ return new Rgb(r, g, b, a);
26497
+ }
26498
+
26499
+ function rgbConvert(o) {
26500
+ if (!(o instanceof Color)) o = color(o);
26501
+ if (!o) return new Rgb;
26502
+ o = o.rgb();
26503
+ return new Rgb(o.r, o.g, o.b, o.opacity);
26504
+ }
26505
+
26506
+ function rgb$1(r, g, b, opacity) {
26507
+ return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
26508
+ }
26509
+
26510
+ function Rgb(r, g, b, opacity) {
26511
+ this.r = +r;
26512
+ this.g = +g;
26513
+ this.b = +b;
26514
+ this.opacity = +opacity;
26515
+ }
26516
+
26517
+ define(Rgb, rgb$1, extend(Color, {
26518
+ brighter(k) {
26519
+ k = k == null ? brighter : Math.pow(brighter, k);
26520
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
26521
+ },
26522
+ darker(k) {
26523
+ k = k == null ? darker : Math.pow(darker, k);
26524
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
26525
+ },
26526
+ rgb() {
26527
+ return this;
26528
+ },
26529
+ clamp() {
26530
+ return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
26531
+ },
26532
+ displayable() {
26533
+ return (-0.5 <= this.r && this.r < 255.5)
26534
+ && (-0.5 <= this.g && this.g < 255.5)
26535
+ && (-0.5 <= this.b && this.b < 255.5)
26536
+ && (0 <= this.opacity && this.opacity <= 1);
26537
+ },
26538
+ hex: rgb_formatHex, // Deprecated! Use color.formatHex.
26539
+ formatHex: rgb_formatHex,
26540
+ formatHex8: rgb_formatHex8,
26541
+ formatRgb: rgb_formatRgb,
26542
+ toString: rgb_formatRgb
26543
+ }));
26544
+
26545
+ function rgb_formatHex() {
26546
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
26547
+ }
26548
+
26549
+ function rgb_formatHex8() {
26550
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
26551
+ }
26552
+
26553
+ function rgb_formatRgb() {
26554
+ const a = clampa(this.opacity);
26555
+ return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
26556
+ }
26557
+
26558
+ function clampa(opacity) {
26559
+ return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
26560
+ }
26561
+
26562
+ function clampi(value) {
26563
+ return Math.max(0, Math.min(255, Math.round(value) || 0));
26564
+ }
26565
+
26566
+ function hex(value) {
26567
+ value = clampi(value);
26568
+ return (value < 16 ? "0" : "") + value.toString(16);
26569
+ }
26570
+
26571
+ function hsla(h, s, l, a) {
26572
+ if (a <= 0) h = s = l = NaN;
26573
+ else if (l <= 0 || l >= 1) h = s = NaN;
26574
+ else if (s <= 0) h = NaN;
26575
+ return new Hsl(h, s, l, a);
26576
+ }
26577
+
26578
+ function hslConvert(o) {
26579
+ if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
26580
+ if (!(o instanceof Color)) o = color(o);
26581
+ if (!o) return new Hsl;
26582
+ if (o instanceof Hsl) return o;
26583
+ o = o.rgb();
26584
+ var r = o.r / 255,
26585
+ g = o.g / 255,
26586
+ b = o.b / 255,
26587
+ min = Math.min(r, g, b),
26588
+ max = Math.max(r, g, b),
26589
+ h = NaN,
26590
+ s = max - min,
26591
+ l = (max + min) / 2;
26592
+ if (s) {
26593
+ if (r === max) h = (g - b) / s + (g < b) * 6;
26594
+ else if (g === max) h = (b - r) / s + 2;
26595
+ else h = (r - g) / s + 4;
26596
+ s /= l < 0.5 ? max + min : 2 - max - min;
26597
+ h *= 60;
26598
+ } else {
26599
+ s = l > 0 && l < 1 ? 0 : h;
26600
+ }
26601
+ return new Hsl(h, s, l, o.opacity);
26602
+ }
26603
+
26604
+ function hsl(h, s, l, opacity) {
26605
+ return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
26606
+ }
26607
+
26608
+ function Hsl(h, s, l, opacity) {
26609
+ this.h = +h;
26610
+ this.s = +s;
26611
+ this.l = +l;
26612
+ this.opacity = +opacity;
26613
+ }
26614
+
26615
+ define(Hsl, hsl, extend(Color, {
26616
+ brighter(k) {
26617
+ k = k == null ? brighter : Math.pow(brighter, k);
26618
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
26619
+ },
26620
+ darker(k) {
26621
+ k = k == null ? darker : Math.pow(darker, k);
26622
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
26623
+ },
26624
+ rgb() {
26625
+ var h = this.h % 360 + (this.h < 0) * 360,
26626
+ s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
26627
+ l = this.l,
26628
+ m2 = l + (l < 0.5 ? l : 1 - l) * s,
26629
+ m1 = 2 * l - m2;
26630
+ return new Rgb(
26631
+ hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
26632
+ hsl2rgb(h, m1, m2),
26633
+ hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
26634
+ this.opacity
26635
+ );
26636
+ },
26637
+ clamp() {
26638
+ return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
26639
+ },
26640
+ displayable() {
26641
+ return (0 <= this.s && this.s <= 1 || isNaN(this.s))
26642
+ && (0 <= this.l && this.l <= 1)
26643
+ && (0 <= this.opacity && this.opacity <= 1);
26644
+ },
26645
+ formatHsl() {
26646
+ const a = clampa(this.opacity);
26647
+ return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
26648
+ }
26649
+ }));
26650
+
26651
+ function clamph(value) {
26652
+ value = (value || 0) % 360;
26653
+ return value < 0 ? value + 360 : value;
26654
+ }
26655
+
26656
+ function clampt(value) {
26657
+ return Math.max(0, Math.min(1, value || 0));
26658
+ }
26659
+
26660
+ /* From FvD 13.37, CSS Color Module Level 3 */
26661
+ function hsl2rgb(h, m1, m2) {
26662
+ return (h < 60 ? m1 + (m2 - m1) * h / 60
26663
+ : h < 180 ? m2
26664
+ : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
26665
+ : m1) * 255;
26666
+ }
26667
+
26668
+ var constant = x => () => x;
26669
+
26670
+ function linear$1(a, d) {
26671
+ return function(t) {
26672
+ return a + t * d;
26673
+ };
26674
+ }
26675
+
26676
+ function exponential(a, b, y) {
26677
+ return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
26678
+ return Math.pow(a + t * b, y);
26679
+ };
26680
+ }
26681
+
26682
+ function gamma(y) {
26683
+ return (y = +y) === 1 ? nogamma : function(a, b) {
26684
+ return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
26685
+ };
26686
+ }
26687
+
26688
+ function nogamma(a, b) {
26689
+ var d = b - a;
26690
+ return d ? linear$1(a, d) : constant(isNaN(a) ? b : a);
26691
+ }
26692
+
26693
+ var rgb = (function rgbGamma(y) {
26694
+ var color = gamma(y);
26695
+
26696
+ function rgb(start, end) {
26697
+ var r = color((start = rgb$1(start)).r, (end = rgb$1(end)).r),
26698
+ g = color(start.g, end.g),
26699
+ b = color(start.b, end.b),
26700
+ opacity = nogamma(start.opacity, end.opacity);
26701
+ return function(t) {
26702
+ start.r = r(t);
26703
+ start.g = g(t);
26704
+ start.b = b(t);
26705
+ start.opacity = opacity(t);
26706
+ return start + "";
26707
+ };
26708
+ }
26709
+
26710
+ rgb.gamma = rgbGamma;
26711
+
26712
+ return rgb;
26713
+ })(1);
26714
+
26715
+ function numberArray(a, b) {
26716
+ if (!b) b = [];
26717
+ var n = a ? Math.min(b.length, a.length) : 0,
26718
+ c = b.slice(),
26719
+ i;
26720
+ return function(t) {
26721
+ for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
26722
+ return c;
26723
+ };
26724
+ }
26725
+
26726
+ function isNumberArray(x) {
26727
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
26728
+ }
26729
+
26730
+ function genericArray(a, b) {
26731
+ var nb = b ? b.length : 0,
26732
+ na = a ? Math.min(nb, a.length) : 0,
26733
+ x = new Array(na),
26734
+ c = new Array(nb),
26735
+ i;
26736
+
26737
+ for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
26738
+ for (; i < nb; ++i) c[i] = b[i];
26739
+
26740
+ return function(t) {
26741
+ for (i = 0; i < na; ++i) c[i] = x[i](t);
26742
+ return c;
26743
+ };
26744
+ }
26745
+
26746
+ function date(a, b) {
26747
+ var d = new Date;
26748
+ return a = +a, b = +b, function(t) {
26749
+ return d.setTime(a * (1 - t) + b * t), d;
26750
+ };
26751
+ }
26752
+
26753
+ function interpolateNumber(a, b) {
26754
+ return a = +a, b = +b, function(t) {
26755
+ return a * (1 - t) + b * t;
26756
+ };
26757
+ }
26758
+
26759
+ function object(a, b) {
26760
+ var i = {},
26761
+ c = {},
26762
+ k;
26763
+
26764
+ if (a === null || typeof a !== "object") a = {};
26765
+ if (b === null || typeof b !== "object") b = {};
26766
+
26767
+ for (k in b) {
26768
+ if (k in a) {
26769
+ i[k] = interpolate(a[k], b[k]);
26770
+ } else {
26771
+ c[k] = b[k];
26772
+ }
26773
+ }
26774
+
26775
+ return function(t) {
26776
+ for (k in i) c[k] = i[k](t);
26777
+ return c;
26778
+ };
26779
+ }
26780
+
26781
+ var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
26782
+ reB = new RegExp(reA.source, "g");
26783
+
26784
+ function zero(b) {
26785
+ return function() {
26786
+ return b;
26787
+ };
26788
+ }
26789
+
26790
+ function one(b) {
26791
+ return function(t) {
26792
+ return b(t) + "";
26793
+ };
26794
+ }
26795
+
26796
+ function string(a, b) {
26797
+ var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
26798
+ am, // current match in a
26799
+ bm, // current match in b
26800
+ bs, // string preceding current number in b, if any
26801
+ i = -1, // index in s
26802
+ s = [], // string constants and placeholders
26803
+ q = []; // number interpolators
26804
+
26805
+ // Coerce inputs to strings.
26806
+ a = a + "", b = b + "";
26807
+
26808
+ // Interpolate pairs of numbers in a & b.
26809
+ while ((am = reA.exec(a))
26810
+ && (bm = reB.exec(b))) {
26811
+ if ((bs = bm.index) > bi) { // a string precedes the next number in b
26812
+ bs = b.slice(bi, bs);
26813
+ if (s[i]) s[i] += bs; // coalesce with previous string
26814
+ else s[++i] = bs;
26815
+ }
26816
+ if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
26817
+ if (s[i]) s[i] += bm; // coalesce with previous string
26818
+ else s[++i] = bm;
26819
+ } else { // interpolate non-matching numbers
26820
+ s[++i] = null;
26821
+ q.push({i: i, x: interpolateNumber(am, bm)});
26822
+ }
26823
+ bi = reB.lastIndex;
26824
+ }
26825
+
26826
+ // Add remains of b.
26827
+ if (bi < b.length) {
26828
+ bs = b.slice(bi);
26829
+ if (s[i]) s[i] += bs; // coalesce with previous string
26830
+ else s[++i] = bs;
26831
+ }
26832
+
26833
+ // Special optimization for only a single match.
26834
+ // Otherwise, interpolate each of the numbers and rejoin the string.
26835
+ return s.length < 2 ? (q[0]
26836
+ ? one(q[0].x)
26837
+ : zero(b))
26838
+ : (b = q.length, function(t) {
26839
+ for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
26840
+ return s.join("");
26841
+ });
26842
+ }
26843
+
26844
+ function interpolate(a, b) {
26845
+ var t = typeof b, c;
26846
+ return b == null || t === "boolean" ? constant(b)
26847
+ : (t === "number" ? interpolateNumber
26848
+ : t === "string" ? ((c = color(b)) ? (b = c, rgb) : string)
26849
+ : b instanceof color ? rgb
26850
+ : b instanceof Date ? date
26851
+ : isNumberArray(b) ? numberArray
26852
+ : Array.isArray(b) ? genericArray
26853
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
26854
+ : interpolateNumber)(a, b);
26855
+ }
26856
+
26857
+ function interpolateRound(a, b) {
26858
+ return a = +a, b = +b, function(t) {
26859
+ return Math.round(a * (1 - t) + b * t);
26860
+ };
26861
+ }
26862
+
26863
+ function constants(x) {
26864
+ return function() {
26865
+ return x;
26866
+ };
26867
+ }
26868
+
26869
+ function number(x) {
26870
+ return +x;
26871
+ }
26872
+
26873
+ var unit = [0, 1];
26874
+
26875
+ function identity$1(x) {
26876
+ return x;
26877
+ }
26878
+
26879
+ function normalize$1(a, b) {
26880
+ return (b -= (a = +a))
26881
+ ? function(x) { return (x - a) / b; }
26882
+ : constants(isNaN(b) ? NaN : 0.5);
26883
+ }
26884
+
26885
+ function clamper(a, b) {
26886
+ var t;
26887
+ if (a > b) t = a, a = b, b = t;
26888
+ return function(x) { return Math.max(a, Math.min(b, x)); };
26889
+ }
26890
+
26891
+ // normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
26892
+ // interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
26893
+ function bimap(domain, range, interpolate) {
26894
+ var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
26895
+ if (d1 < d0) d0 = normalize$1(d1, d0), r0 = interpolate(r1, r0);
26896
+ else d0 = normalize$1(d0, d1), r0 = interpolate(r0, r1);
26897
+ return function(x) { return r0(d0(x)); };
26898
+ }
26899
+
26900
+ function polymap(domain, range, interpolate) {
26901
+ var j = Math.min(domain.length, range.length) - 1,
26902
+ d = new Array(j),
26903
+ r = new Array(j),
26904
+ i = -1;
26905
+
26906
+ // Reverse descending domains.
26907
+ if (domain[j] < domain[0]) {
26908
+ domain = domain.slice().reverse();
26909
+ range = range.slice().reverse();
26910
+ }
26911
+
26912
+ while (++i < j) {
26913
+ d[i] = normalize$1(domain[i], domain[i + 1]);
26914
+ r[i] = interpolate(range[i], range[i + 1]);
26915
+ }
26916
+
26917
+ return function(x) {
26918
+ var i = bisect(domain, x, 1, j) - 1;
26919
+ return r[i](d[i](x));
26920
+ };
26921
+ }
26922
+
26923
+ function copy(source, target) {
26924
+ return target
26925
+ .domain(source.domain())
26926
+ .range(source.range())
26927
+ .interpolate(source.interpolate())
26928
+ .clamp(source.clamp())
26929
+ .unknown(source.unknown());
26930
+ }
26931
+
26932
+ function transformer() {
26933
+ var domain = unit,
26934
+ range = unit,
26935
+ interpolate$1 = interpolate,
26936
+ transform,
26937
+ untransform,
26938
+ unknown,
26939
+ clamp = identity$1,
26940
+ piecewise,
26941
+ output,
26942
+ input;
26943
+
26944
+ function rescale() {
26945
+ var n = Math.min(domain.length, range.length);
26946
+ if (clamp !== identity$1) clamp = clamper(domain[0], domain[n - 1]);
26947
+ piecewise = n > 2 ? polymap : bimap;
26948
+ output = input = null;
26949
+ return scale;
26950
+ }
26951
+
26952
+ function scale(x) {
26953
+ return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x)));
26954
+ }
26955
+
26956
+ scale.invert = function(y) {
26957
+ return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
26958
+ };
26959
+
26960
+ scale.domain = function(_) {
26961
+ return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice();
26962
+ };
26963
+
26964
+ scale.range = function(_) {
26965
+ return arguments.length ? (range = Array.from(_), rescale()) : range.slice();
26966
+ };
26967
+
26968
+ scale.rangeRound = function(_) {
26969
+ return range = Array.from(_), interpolate$1 = interpolateRound, rescale();
26970
+ };
26971
+
26972
+ scale.clamp = function(_) {
26973
+ return arguments.length ? (clamp = _ ? true : identity$1, rescale()) : clamp !== identity$1;
26974
+ };
26975
+
26976
+ scale.interpolate = function(_) {
26977
+ return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1;
26978
+ };
26979
+
26980
+ scale.unknown = function(_) {
26981
+ return arguments.length ? (unknown = _, scale) : unknown;
26982
+ };
26983
+
26984
+ return function(t, u) {
26985
+ transform = t, untransform = u;
26986
+ return rescale();
26987
+ };
26988
+ }
26989
+
26990
+ function continuous() {
26991
+ return transformer()(identity$1, identity$1);
26992
+ }
26993
+
26994
+ function formatDecimal(x) {
26995
+ return Math.abs(x = Math.round(x)) >= 1e21
26996
+ ? x.toLocaleString("en").replace(/,/g, "")
26997
+ : x.toString(10);
26998
+ }
26999
+
27000
+ // Computes the decimal coefficient and exponent of the specified number x with
27001
+ // significant digits p, where x is positive and p is in [1, 21] or undefined.
27002
+ // For example, formatDecimalParts(1.23) returns ["123", 0].
27003
+ function formatDecimalParts(x, p) {
27004
+ if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
27005
+ var i, coefficient = x.slice(0, i);
27006
+
27007
+ // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
27008
+ // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
27009
+ return [
27010
+ coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
27011
+ +x.slice(i + 1)
27012
+ ];
27013
+ }
27014
+
27015
+ function exponent(x) {
27016
+ return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
27017
+ }
27018
+
27019
+ function formatGroup(grouping, thousands) {
27020
+ return function(value, width) {
27021
+ var i = value.length,
27022
+ t = [],
27023
+ j = 0,
27024
+ g = grouping[0],
27025
+ length = 0;
27026
+
27027
+ while (i > 0 && g > 0) {
27028
+ if (length + g + 1 > width) g = Math.max(1, width - length);
27029
+ t.push(value.substring(i -= g, i + g));
27030
+ if ((length += g + 1) > width) break;
27031
+ g = grouping[j = (j + 1) % grouping.length];
27032
+ }
27033
+
27034
+ return t.reverse().join(thousands);
27035
+ };
27036
+ }
27037
+
27038
+ function formatNumerals(numerals) {
27039
+ return function(value) {
27040
+ return value.replace(/[0-9]/g, function(i) {
27041
+ return numerals[+i];
27042
+ });
27043
+ };
27044
+ }
27045
+
27046
+ // [[fill]align][sign][symbol][0][width][,][.precision][~][type]
27047
+ var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
27048
+
27049
+ function formatSpecifier(specifier) {
27050
+ if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
27051
+ var match;
27052
+ return new FormatSpecifier({
27053
+ fill: match[1],
27054
+ align: match[2],
27055
+ sign: match[3],
27056
+ symbol: match[4],
27057
+ zero: match[5],
27058
+ width: match[6],
27059
+ comma: match[7],
27060
+ precision: match[8] && match[8].slice(1),
27061
+ trim: match[9],
27062
+ type: match[10]
27063
+ });
27064
+ }
27065
+
27066
+ formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
27067
+
27068
+ function FormatSpecifier(specifier) {
27069
+ this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
27070
+ this.align = specifier.align === undefined ? ">" : specifier.align + "";
27071
+ this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
27072
+ this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
27073
+ this.zero = !!specifier.zero;
27074
+ this.width = specifier.width === undefined ? undefined : +specifier.width;
27075
+ this.comma = !!specifier.comma;
27076
+ this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
27077
+ this.trim = !!specifier.trim;
27078
+ this.type = specifier.type === undefined ? "" : specifier.type + "";
27079
+ }
27080
+
27081
+ FormatSpecifier.prototype.toString = function() {
27082
+ return this.fill
27083
+ + this.align
27084
+ + this.sign
27085
+ + this.symbol
27086
+ + (this.zero ? "0" : "")
27087
+ + (this.width === undefined ? "" : Math.max(1, this.width | 0))
27088
+ + (this.comma ? "," : "")
27089
+ + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
27090
+ + (this.trim ? "~" : "")
27091
+ + this.type;
27092
+ };
27093
+
27094
+ // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
27095
+ function formatTrim(s) {
27096
+ out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
27097
+ switch (s[i]) {
27098
+ case ".": i0 = i1 = i; break;
27099
+ case "0": if (i0 === 0) i0 = i; i1 = i; break;
27100
+ default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
27101
+ }
27102
+ }
27103
+ return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
27104
+ }
27105
+
27106
+ var prefixExponent;
27107
+
27108
+ function formatPrefixAuto(x, p) {
27109
+ var d = formatDecimalParts(x, p);
27110
+ if (!d) return x + "";
27111
+ var coefficient = d[0],
27112
+ exponent = d[1],
27113
+ i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
27114
+ n = coefficient.length;
27115
+ return i === n ? coefficient
27116
+ : i > n ? coefficient + new Array(i - n + 1).join("0")
27117
+ : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
27118
+ : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
27119
+ }
27120
+
27121
+ function formatRounded(x, p) {
27122
+ var d = formatDecimalParts(x, p);
27123
+ if (!d) return x + "";
27124
+ var coefficient = d[0],
27125
+ exponent = d[1];
27126
+ return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
27127
+ : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
27128
+ : coefficient + new Array(exponent - coefficient.length + 2).join("0");
27129
+ }
27130
+
27131
+ var formatTypes = {
27132
+ "%": (x, p) => (x * 100).toFixed(p),
27133
+ "b": (x) => Math.round(x).toString(2),
27134
+ "c": (x) => x + "",
27135
+ "d": formatDecimal,
27136
+ "e": (x, p) => x.toExponential(p),
27137
+ "f": (x, p) => x.toFixed(p),
27138
+ "g": (x, p) => x.toPrecision(p),
27139
+ "o": (x) => Math.round(x).toString(8),
27140
+ "p": (x, p) => formatRounded(x * 100, p),
27141
+ "r": formatRounded,
27142
+ "s": formatPrefixAuto,
27143
+ "X": (x) => Math.round(x).toString(16).toUpperCase(),
27144
+ "x": (x) => Math.round(x).toString(16)
27145
+ };
27146
+
27147
+ function identity(x) {
27148
+ return x;
27149
+ }
27150
+
27151
+ var map = Array.prototype.map,
27152
+ prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
27153
+
27154
+ function formatLocale(locale) {
27155
+ var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""),
27156
+ currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
27157
+ currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
27158
+ decimal = locale.decimal === undefined ? "." : locale.decimal + "",
27159
+ numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)),
27160
+ percent = locale.percent === undefined ? "%" : locale.percent + "",
27161
+ minus = locale.minus === undefined ? "−" : locale.minus + "",
27162
+ nan = locale.nan === undefined ? "NaN" : locale.nan + "";
27163
+
27164
+ function newFormat(specifier) {
27165
+ specifier = formatSpecifier(specifier);
27166
+
27167
+ var fill = specifier.fill,
27168
+ align = specifier.align,
27169
+ sign = specifier.sign,
27170
+ symbol = specifier.symbol,
27171
+ zero = specifier.zero,
27172
+ width = specifier.width,
27173
+ comma = specifier.comma,
27174
+ precision = specifier.precision,
27175
+ trim = specifier.trim,
27176
+ type = specifier.type;
27177
+
27178
+ // The "n" type is an alias for ",g".
27179
+ if (type === "n") comma = true, type = "g";
27180
+
27181
+ // The "" type, and any invalid type, is an alias for ".12~g".
27182
+ else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
27183
+
27184
+ // If zero fill is specified, padding goes after sign and before digits.
27185
+ if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
27186
+
27187
+ // Compute the prefix and suffix.
27188
+ // For SI-prefix, the suffix is lazily computed.
27189
+ var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
27190
+ suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
27191
+
27192
+ // What format function should we use?
27193
+ // Is this an integer type?
27194
+ // Can this type generate exponential notation?
27195
+ var formatType = formatTypes[type],
27196
+ maybeSuffix = /[defgprs%]/.test(type);
27197
+
27198
+ // Set the default precision if not specified,
27199
+ // or clamp the specified precision to the supported range.
27200
+ // For significant precision, it must be in [1, 21].
27201
+ // For fixed precision, it must be in [0, 20].
27202
+ precision = precision === undefined ? 6
27203
+ : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
27204
+ : Math.max(0, Math.min(20, precision));
27205
+
27206
+ function format(value) {
27207
+ var valuePrefix = prefix,
27208
+ valueSuffix = suffix,
27209
+ i, n, c;
27210
+
27211
+ if (type === "c") {
27212
+ valueSuffix = formatType(value) + valueSuffix;
27213
+ value = "";
27214
+ } else {
27215
+ value = +value;
27216
+
27217
+ // Determine the sign. -0 is not less than 0, but 1 / -0 is!
27218
+ var valueNegative = value < 0 || 1 / value < 0;
27219
+
27220
+ // Perform the initial formatting.
27221
+ value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
27222
+
27223
+ // Trim insignificant zeros.
27224
+ if (trim) value = formatTrim(value);
27225
+
27226
+ // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
27227
+ if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
27228
+
27229
+ // Compute the prefix and suffix.
27230
+ valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
27231
+ valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
27232
+
27233
+ // Break the formatted value into the integer “value” part that can be
27234
+ // grouped, and fractional or exponential “suffix” part that is not.
27235
+ if (maybeSuffix) {
27236
+ i = -1, n = value.length;
27237
+ while (++i < n) {
27238
+ if (c = value.charCodeAt(i), 48 > c || c > 57) {
27239
+ valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
27240
+ value = value.slice(0, i);
27241
+ break;
27242
+ }
27243
+ }
27244
+ }
27245
+ }
27246
+
27247
+ // If the fill character is not "0", grouping is applied before padding.
27248
+ if (comma && !zero) value = group(value, Infinity);
27249
+
27250
+ // Compute the padding.
27251
+ var length = valuePrefix.length + value.length + valueSuffix.length,
27252
+ padding = length < width ? new Array(width - length + 1).join(fill) : "";
27253
+
27254
+ // If the fill character is "0", grouping is applied after padding.
27255
+ if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
27256
+
27257
+ // Reconstruct the final output based on the desired alignment.
27258
+ switch (align) {
27259
+ case "<": value = valuePrefix + value + valueSuffix + padding; break;
27260
+ case "=": value = valuePrefix + padding + value + valueSuffix; break;
27261
+ case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
27262
+ default: value = padding + valuePrefix + value + valueSuffix; break;
27263
+ }
27264
+
27265
+ return numerals(value);
27266
+ }
27267
+
27268
+ format.toString = function() {
27269
+ return specifier + "";
27270
+ };
27271
+
27272
+ return format;
27273
+ }
27274
+
27275
+ function formatPrefix(specifier, value) {
27276
+ var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
27277
+ e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
27278
+ k = Math.pow(10, -e),
27279
+ prefix = prefixes[8 + e / 3];
27280
+ return function(value) {
27281
+ return f(k * value) + prefix;
27282
+ };
27283
+ }
27284
+
27285
+ return {
27286
+ format: newFormat,
27287
+ formatPrefix: formatPrefix
27288
+ };
27289
+ }
27290
+
27291
+ var locale;
27292
+ var format;
27293
+ var formatPrefix;
27294
+
27295
+ defaultLocale({
27296
+ thousands: ",",
27297
+ grouping: [3],
27298
+ currency: ["$", ""]
27299
+ });
27300
+
27301
+ function defaultLocale(definition) {
27302
+ locale = formatLocale(definition);
27303
+ format = locale.format;
27304
+ formatPrefix = locale.formatPrefix;
27305
+ return locale;
27306
+ }
27307
+
27308
+ function precisionFixed(step) {
27309
+ return Math.max(0, -exponent(Math.abs(step)));
27310
+ }
27311
+
27312
+ function precisionPrefix(step, value) {
27313
+ return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
27314
+ }
27315
+
27316
+ function precisionRound(step, max) {
27317
+ step = Math.abs(step), max = Math.abs(max) - step;
27318
+ return Math.max(0, exponent(max) - exponent(step)) + 1;
27319
+ }
27320
+
27321
+ function tickFormat(start, stop, count, specifier) {
27322
+ var step = tickStep(start, stop, count),
27323
+ precision;
27324
+ specifier = formatSpecifier(specifier == null ? ",f" : specifier);
27325
+ switch (specifier.type) {
27326
+ case "s": {
27327
+ var value = Math.max(Math.abs(start), Math.abs(stop));
27328
+ if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
27329
+ return formatPrefix(specifier, value);
27330
+ }
27331
+ case "":
27332
+ case "e":
27333
+ case "g":
27334
+ case "p":
27335
+ case "r": {
27336
+ if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
27337
+ break;
27338
+ }
27339
+ case "f":
27340
+ case "%": {
27341
+ if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
27342
+ break;
27343
+ }
27344
+ }
27345
+ return format(specifier);
27346
+ }
27347
+
27348
+ function linearish(scale) {
27349
+ var domain = scale.domain;
27350
+
27351
+ scale.ticks = function(count) {
27352
+ var d = domain();
27353
+ return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
27354
+ };
27355
+
27356
+ scale.tickFormat = function(count, specifier) {
27357
+ var d = domain();
27358
+ return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
27359
+ };
27360
+
27361
+ scale.nice = function(count) {
27362
+ if (count == null) count = 10;
27363
+
27364
+ var d = domain();
27365
+ var i0 = 0;
27366
+ var i1 = d.length - 1;
27367
+ var start = d[i0];
27368
+ var stop = d[i1];
27369
+ var prestep;
27370
+ var step;
27371
+ var maxIter = 10;
27372
+
27373
+ if (stop < start) {
27374
+ step = start, start = stop, stop = step;
27375
+ step = i0, i0 = i1, i1 = step;
27376
+ }
27377
+
27378
+ while (maxIter-- > 0) {
27379
+ step = tickIncrement(start, stop, count);
27380
+ if (step === prestep) {
27381
+ d[i0] = start;
27382
+ d[i1] = stop;
27383
+ return domain(d);
27384
+ } else if (step > 0) {
27385
+ start = Math.floor(start / step) * step;
27386
+ stop = Math.ceil(stop / step) * step;
27387
+ } else if (step < 0) {
27388
+ start = Math.ceil(start * step) / step;
27389
+ stop = Math.floor(stop * step) / step;
27390
+ } else {
27391
+ break;
27392
+ }
27393
+ prestep = step;
27394
+ }
27395
+
27396
+ return scale;
27397
+ };
27398
+
27399
+ return scale;
27400
+ }
27401
+
27402
+ function linear() {
27403
+ var scale = continuous();
27404
+
27405
+ scale.copy = function() {
27406
+ return copy(scale, linear());
27407
+ };
27408
+
27409
+ initRange.apply(scale, arguments);
27410
+
27411
+ return linearish(scale);
27412
+ }
27413
+
27414
+ /**
27415
+ * Computations calculates and stores different measures which are used in the Wafermap
27416
+ */
27417
+ class Computations {
27418
+ constructor(dies, axisLocation, canvasDimensions) {
27419
+ this.baseMargin = {
27420
+ top: 20,
27421
+ right: 20,
27422
+ bottom: 20,
27423
+ left: 20
27424
+ };
27425
+ this.dieSizeFactor = 1.5;
27426
+ this.defaultAlign = 0.5;
27427
+ this.margin = this.baseMargin;
27428
+ const gridMapDimensions = this.calculateMapDimensions(dies);
27429
+ this.containerDimensions = this.calculateContainerDimensions(canvasDimensions, this.margin);
27430
+ this.horizontalScale = this.createHorizontalScale(axisLocation, gridMapDimensions, this.containerDimensions.width);
27431
+ this.dieDimensions = {
27432
+ width: this.calculateGridWidth(gridMapDimensions.cols, this.containerDimensions.width),
27433
+ height: 0
27434
+ };
27435
+ this.radius = this.containerDimensions.width / 2
27436
+ + this.dieDimensions.width * this.dieSizeFactor;
27437
+ if (this.radius > canvasDimensions.width / 2) {
27438
+ this.margin = this.calculateMarginWithAddition(this.radius - canvasDimensions.width / 2);
27439
+ this.containerDimensions = this.calculateContainerDimensions(canvasDimensions, this.margin);
27440
+ this.horizontalScale = this.createHorizontalScale(axisLocation, gridMapDimensions, this.containerDimensions.width);
27441
+ this.dieDimensions = {
27442
+ width: this.calculateGridWidth(gridMapDimensions.cols, this.containerDimensions.width),
27443
+ height: 0
27444
+ };
27445
+ this.radius = this.containerDimensions.width / 2
27446
+ + this.dieDimensions.width * this.dieSizeFactor;
27447
+ }
27448
+ this.verticalScale = this.createVerticalScale(axisLocation, gridMapDimensions, this.containerDimensions.height);
27449
+ this.dieDimensions = {
27450
+ width: this.dieDimensions.width,
27451
+ height: this.calculateGridHeight(gridMapDimensions.rows, this.containerDimensions.height)
27452
+ };
27453
+ }
27454
+ calculateMapDimensions(dies) {
27455
+ if (dies.length === 0 || dies[0] === undefined)
27456
+ return { origin: { x: 0, y: 0 }, rows: 0, cols: 0 };
27457
+ const minPoint = { x: dies[0].x, y: dies[0].y };
27458
+ const maxPoint = { x: dies[0].x, y: dies[0].y };
27459
+ for (const die of dies) {
27460
+ if (die.x < minPoint.x)
27461
+ minPoint.x = die.x;
27462
+ if (die.y < minPoint.y)
27463
+ minPoint.y = die.y;
27464
+ if (die.x > maxPoint.x)
27465
+ maxPoint.x = die.x;
27466
+ if (die.y > maxPoint.y)
27467
+ maxPoint.y = die.y;
27468
+ }
27469
+ return {
27470
+ origin: minPoint,
27471
+ rows: maxPoint.y - minPoint.y + 1,
27472
+ cols: maxPoint.x - minPoint.x + 1
27473
+ };
27474
+ }
27475
+ calculateContainerDimensions(canvasDimensions, margin) {
27476
+ return {
27477
+ width: canvasDimensions.width - margin.left - margin.right,
27478
+ height: canvasDimensions.height - margin.top - margin.bottom
27479
+ };
27480
+ }
27481
+ createHorizontalScale(axisLocation, grid, containerWidth) {
27482
+ if (axisLocation === WaferMapQuadrant.bottomLeft
27483
+ || axisLocation === WaferMapQuadrant.topLeft) {
27484
+ return linear()
27485
+ .domain([grid.origin.x, grid.origin.x + grid.cols])
27486
+ .range([0, containerWidth]);
27487
+ }
27488
+ return linear()
27489
+ .domain([grid.origin.x - 1, grid.origin.x + grid.cols - 1])
27490
+ .range([containerWidth, 0]);
27491
+ }
27492
+ createVerticalScale(axisLocation, grid, containerHeight) {
27493
+ if (axisLocation === WaferMapQuadrant.bottomLeft
27494
+ || axisLocation === WaferMapQuadrant.bottomRight) {
27495
+ return linear()
27496
+ .domain([grid.origin.y - 1, grid.origin.y + grid.rows - 1])
27497
+ .range([containerHeight, 0]);
27498
+ }
27499
+ return linear()
27500
+ .domain([grid.origin.y, grid.origin.y + grid.rows])
27501
+ .range([0, containerHeight]);
27502
+ }
27503
+ calculateGridWidth(cols, containerWidth) {
27504
+ return band()
27505
+ .align(this.defaultAlign)
27506
+ .padding(0)
27507
+ .domain(this.horizontalScale.ticks(cols))
27508
+ .range([0, containerWidth])
27509
+ .bandwidth();
27510
+ }
27511
+ calculateGridHeight(rows, containerHeight) {
27512
+ return band()
27513
+ .align(this.defaultAlign)
27514
+ .padding(0)
27515
+ .domain(this.verticalScale.ticks(rows))
27516
+ .range([0, containerHeight])
27517
+ .bandwidth();
27518
+ }
27519
+ calculateMarginWithAddition(baseAddition = 0) {
27520
+ return {
27521
+ top: this.baseMargin.top + baseAddition,
27522
+ right: this.baseMargin.right + baseAddition,
27523
+ bottom: this.baseMargin.bottom + baseAddition,
27524
+ left: this.baseMargin.top + baseAddition
27525
+ };
27526
+ }
27527
+ }
27528
+
27529
+ /**
27530
+ * Ensures that an input number does not exceed a max value and is not less than a min value.
27531
+ * @param i - the number to clamp
27532
+ * @param min - the maximum (inclusive) value
27533
+ * @param max - the minimum (inclusive) value
27534
+ * @public
27535
+ */
27536
+ function clamp(i, min, max) {
27537
+ if (isNaN(i) || i <= min) {
27538
+ return min;
27539
+ }
27540
+ else if (i >= max) {
27541
+ return max;
27542
+ }
27543
+ return i;
27544
+ }
27545
+ /**
27546
+ * Scales an input to a number between 0 and 1
27547
+ * @param i - a number between min and max
27548
+ * @param min - the max value
27549
+ * @param max - the min value
27550
+ * @public
27551
+ */
27552
+ function normalize(i, min, max) {
27553
+ if (isNaN(i) || i <= min) {
27554
+ return 0.0;
27555
+ }
27556
+ else if (i >= max) {
27557
+ return 1.0;
27558
+ }
27559
+ return i / (max - min);
27560
+ }
27561
+ /**
27562
+ * Scales a number between 0 and 1
27563
+ * @param i - the number to denormalize
27564
+ * @param min - the min value
27565
+ * @param max - the max value
27566
+ * @public
27567
+ */
27568
+ function denormalize(i, min, max) {
27569
+ if (isNaN(i)) {
27570
+ return min;
27571
+ }
27572
+ return min + i * (max - min);
27573
+ }
27574
+ /**
27575
+ * Converts a number between 0 and 255 to a hex string.
27576
+ * @param i - the number to convert to a hex string
27577
+ * @public
27578
+ */
27579
+ function getHexStringForByte(i) {
27580
+ const s = Math.round(clamp(i, 0.0, 255.0)).toString(16);
27581
+ if (s.length === 1) {
27582
+ return "0" + s;
27583
+ }
27584
+ return s;
27585
+ }
27586
+ /**
27587
+ *
27588
+ * Will return infinity if i*10^(precision) overflows number
27589
+ * note that floating point rounding rules come into play here
27590
+ * so values that end up rounding on a .5 round to the nearest
27591
+ * even not always up so 2.5 rounds to 2
27592
+ * @param i - the number to round
27593
+ * @param precision - the precision to round to
27594
+ *
27595
+ * @public
27596
+ */
27597
+ function roundToPrecisionSmall(i, precision) {
27598
+ const factor = Math.pow(10, precision);
27599
+ return Math.round(i * factor) / factor;
27600
+ }
27601
+
27602
+ /**
27603
+ * A RGBA color with 64 bit channels.
27604
+ *
27605
+ * @example
27606
+ * ```ts
27607
+ * new ColorRGBA64(1, 0, 0, 1) // red
27608
+ * ```
27609
+ * @public
27610
+ */
27611
+ class ColorRGBA64 {
27612
+ /**
27613
+ *
27614
+ * @param red - the red value
27615
+ * @param green - the green value
27616
+ * @param blue - the blue value
27617
+ * @param alpha - the alpha value
27618
+ */
27619
+ constructor(red, green, blue, alpha) {
27620
+ this.r = red;
27621
+ this.g = green;
27622
+ this.b = blue;
27623
+ this.a = typeof alpha === "number" && !isNaN(alpha) ? alpha : 1;
27624
+ }
27625
+ /**
27626
+ * Construct a {@link ColorRGBA64} from a {@link ColorRGBA64Config}
27627
+ * @param data - the config object
27628
+ */
27629
+ static fromObject(data) {
27630
+ return data && !isNaN(data.r) && !isNaN(data.g) && !isNaN(data.b)
27631
+ ? new ColorRGBA64(data.r, data.g, data.b, data.a)
27632
+ : null;
27633
+ }
27634
+ /**
27635
+ * Determines if one color is equal to another.
27636
+ * @param rhs - the color to compare
27637
+ */
27638
+ equalValue(rhs) {
27639
+ return (this.r === rhs.r && this.g === rhs.g && this.b === rhs.b && this.a === rhs.a);
27640
+ }
27641
+ /**
27642
+ * Returns the color formatted as a string; #RRGGBB
27643
+ */
27644
+ toStringHexRGB() {
27645
+ return "#" + [this.r, this.g, this.b].map(this.formatHexValue).join("");
27646
+ }
27647
+ /**
27648
+ * Returns the color formatted as a string; #RRGGBBAA
27649
+ */
27650
+ toStringHexRGBA() {
27651
+ return this.toStringHexRGB() + this.formatHexValue(this.a);
27652
+ }
27653
+ /**
27654
+ * Returns the color formatted as a string; #AARRGGBB
27655
+ */
27656
+ toStringHexARGB() {
27657
+ return "#" + [this.a, this.r, this.g, this.b].map(this.formatHexValue).join("");
27658
+ }
27659
+ /**
27660
+ * Returns the color formatted as a string; "rgb(0xRR, 0xGG, 0xBB)"
27661
+ */
27662
+ toStringWebRGB() {
27663
+ return `rgb(${Math.round(denormalize(this.r, 0.0, 255.0))},${Math.round(denormalize(this.g, 0.0, 255.0))},${Math.round(denormalize(this.b, 0.0, 255.0))})`;
27664
+ }
27665
+ /**
27666
+ * Returns the color formatted as a string; "rgba(0xRR, 0xGG, 0xBB, a)"
27667
+ * @remarks
27668
+ * Note that this follows the convention of putting alpha in the range [0.0,1.0] while the other three channels are [0,255]
27669
+ */
27670
+ toStringWebRGBA() {
27671
+ return `rgba(${Math.round(denormalize(this.r, 0.0, 255.0))},${Math.round(denormalize(this.g, 0.0, 255.0))},${Math.round(denormalize(this.b, 0.0, 255.0))},${clamp(this.a, 0, 1)})`;
27672
+ }
27673
+ /**
27674
+ * Returns a new {@link ColorRGBA64} rounded to the provided precision
27675
+ * @param precision - the precision to round to
27676
+ */
27677
+ roundToPrecision(precision) {
27678
+ return new ColorRGBA64(roundToPrecisionSmall(this.r, precision), roundToPrecisionSmall(this.g, precision), roundToPrecisionSmall(this.b, precision), roundToPrecisionSmall(this.a, precision));
27679
+ }
27680
+ /**
27681
+ * Returns a new {@link ColorRGBA64} with channel values clamped between 0 and 1.
27682
+ */
27683
+ clamp() {
27684
+ return new ColorRGBA64(clamp(this.r, 0, 1), clamp(this.g, 0, 1), clamp(this.b, 0, 1), clamp(this.a, 0, 1));
27685
+ }
27686
+ /**
27687
+ * Converts the {@link ColorRGBA64} to a {@link ColorRGBA64Config}.
27688
+ */
27689
+ toObject() {
27690
+ return { r: this.r, g: this.g, b: this.b, a: this.a };
27691
+ }
27692
+ formatHexValue(value) {
27693
+ return getHexStringForByte(denormalize(value, 0.0, 255.0));
27694
+ }
27695
+ }
27696
+
27697
+ const namedColorsConfigs = {
27698
+ aliceblue: {
27699
+ r: 0.941176,
27700
+ g: 0.972549,
27701
+ b: 1,
27702
+ },
27703
+ antiquewhite: {
27704
+ r: 0.980392,
27705
+ g: 0.921569,
27706
+ b: 0.843137,
27707
+ },
27708
+ aqua: {
27709
+ r: 0,
27710
+ g: 1,
27711
+ b: 1,
27712
+ },
27713
+ aquamarine: {
27714
+ r: 0.498039,
27715
+ g: 1,
27716
+ b: 0.831373,
27717
+ },
27718
+ azure: {
27719
+ r: 0.941176,
27720
+ g: 1,
27721
+ b: 1,
27722
+ },
27723
+ beige: {
27724
+ r: 0.960784,
27725
+ g: 0.960784,
27726
+ b: 0.862745,
27727
+ },
27728
+ bisque: {
27729
+ r: 1,
27730
+ g: 0.894118,
27731
+ b: 0.768627,
27732
+ },
27733
+ black: {
27734
+ r: 0,
27735
+ g: 0,
27736
+ b: 0,
27737
+ },
27738
+ blanchedalmond: {
27739
+ r: 1,
27740
+ g: 0.921569,
27741
+ b: 0.803922,
27742
+ },
27743
+ blue: {
27744
+ r: 0,
27745
+ g: 0,
27746
+ b: 1,
27747
+ },
27748
+ blueviolet: {
27749
+ r: 0.541176,
27750
+ g: 0.168627,
27751
+ b: 0.886275,
27752
+ },
27753
+ brown: {
27754
+ r: 0.647059,
27755
+ g: 0.164706,
27756
+ b: 0.164706,
27757
+ },
27758
+ burlywood: {
27759
+ r: 0.870588,
27760
+ g: 0.721569,
27761
+ b: 0.529412,
27762
+ },
27763
+ cadetblue: {
27764
+ r: 0.372549,
27765
+ g: 0.619608,
27766
+ b: 0.627451,
27767
+ },
27768
+ chartreuse: {
27769
+ r: 0.498039,
27770
+ g: 1,
27771
+ b: 0,
27772
+ },
27773
+ chocolate: {
27774
+ r: 0.823529,
27775
+ g: 0.411765,
27776
+ b: 0.117647,
27777
+ },
27778
+ coral: {
27779
+ r: 1,
27780
+ g: 0.498039,
27781
+ b: 0.313725,
27782
+ },
27783
+ cornflowerblue: {
27784
+ r: 0.392157,
27785
+ g: 0.584314,
27786
+ b: 0.929412,
27787
+ },
27788
+ cornsilk: {
27789
+ r: 1,
27790
+ g: 0.972549,
27791
+ b: 0.862745,
27792
+ },
27793
+ crimson: {
27794
+ r: 0.862745,
27795
+ g: 0.078431,
27796
+ b: 0.235294,
27797
+ },
27798
+ cyan: {
27799
+ r: 0,
27800
+ g: 1,
27801
+ b: 1,
27802
+ },
27803
+ darkblue: {
27804
+ r: 0,
27805
+ g: 0,
27806
+ b: 0.545098,
27807
+ },
27808
+ darkcyan: {
27809
+ r: 0,
27810
+ g: 0.545098,
27811
+ b: 0.545098,
27812
+ },
27813
+ darkgoldenrod: {
27814
+ r: 0.721569,
27815
+ g: 0.52549,
27816
+ b: 0.043137,
27817
+ },
27818
+ darkgray: {
27819
+ r: 0.662745,
27820
+ g: 0.662745,
27821
+ b: 0.662745,
27822
+ },
27823
+ darkgreen: {
27824
+ r: 0,
27825
+ g: 0.392157,
27826
+ b: 0,
27827
+ },
27828
+ darkgrey: {
27829
+ r: 0.662745,
27830
+ g: 0.662745,
27831
+ b: 0.662745,
27832
+ },
27833
+ darkkhaki: {
27834
+ r: 0.741176,
27835
+ g: 0.717647,
27836
+ b: 0.419608,
27837
+ },
27838
+ darkmagenta: {
27839
+ r: 0.545098,
27840
+ g: 0,
27841
+ b: 0.545098,
27842
+ },
27843
+ darkolivegreen: {
27844
+ r: 0.333333,
27845
+ g: 0.419608,
27846
+ b: 0.184314,
27847
+ },
27848
+ darkorange: {
27849
+ r: 1,
27850
+ g: 0.54902,
27851
+ b: 0,
27852
+ },
27853
+ darkorchid: {
27854
+ r: 0.6,
27855
+ g: 0.196078,
27856
+ b: 0.8,
27857
+ },
27858
+ darkred: {
27859
+ r: 0.545098,
27860
+ g: 0,
27861
+ b: 0,
27862
+ },
27863
+ darksalmon: {
27864
+ r: 0.913725,
27865
+ g: 0.588235,
27866
+ b: 0.478431,
27867
+ },
27868
+ darkseagreen: {
27869
+ r: 0.560784,
27870
+ g: 0.737255,
27871
+ b: 0.560784,
27872
+ },
27873
+ darkslateblue: {
27874
+ r: 0.282353,
27875
+ g: 0.239216,
27876
+ b: 0.545098,
27877
+ },
27878
+ darkslategray: {
27879
+ r: 0.184314,
27880
+ g: 0.309804,
27881
+ b: 0.309804,
27882
+ },
27883
+ darkslategrey: {
27884
+ r: 0.184314,
27885
+ g: 0.309804,
27886
+ b: 0.309804,
27887
+ },
27888
+ darkturquoise: {
27889
+ r: 0,
27890
+ g: 0.807843,
27891
+ b: 0.819608,
27892
+ },
27893
+ darkviolet: {
27894
+ r: 0.580392,
27895
+ g: 0,
27896
+ b: 0.827451,
27897
+ },
27898
+ deeppink: {
27899
+ r: 1,
27900
+ g: 0.078431,
27901
+ b: 0.576471,
27902
+ },
27903
+ deepskyblue: {
27904
+ r: 0,
27905
+ g: 0.74902,
27906
+ b: 1,
27907
+ },
27908
+ dimgray: {
27909
+ r: 0.411765,
27910
+ g: 0.411765,
27911
+ b: 0.411765,
27912
+ },
27913
+ dimgrey: {
27914
+ r: 0.411765,
27915
+ g: 0.411765,
27916
+ b: 0.411765,
27917
+ },
27918
+ dodgerblue: {
27919
+ r: 0.117647,
27920
+ g: 0.564706,
27921
+ b: 1,
27922
+ },
27923
+ firebrick: {
27924
+ r: 0.698039,
27925
+ g: 0.133333,
27926
+ b: 0.133333,
27927
+ },
27928
+ floralwhite: {
27929
+ r: 1,
27930
+ g: 0.980392,
27931
+ b: 0.941176,
27932
+ },
27933
+ forestgreen: {
27934
+ r: 0.133333,
27935
+ g: 0.545098,
27936
+ b: 0.133333,
27937
+ },
27938
+ fuchsia: {
27939
+ r: 1,
27940
+ g: 0,
27941
+ b: 1,
27942
+ },
27943
+ gainsboro: {
27944
+ r: 0.862745,
27945
+ g: 0.862745,
27946
+ b: 0.862745,
27947
+ },
27948
+ ghostwhite: {
27949
+ r: 0.972549,
27950
+ g: 0.972549,
27951
+ b: 1,
27952
+ },
27953
+ gold: {
27954
+ r: 1,
27955
+ g: 0.843137,
27956
+ b: 0,
27957
+ },
27958
+ goldenrod: {
27959
+ r: 0.854902,
27960
+ g: 0.647059,
27961
+ b: 0.12549,
27962
+ },
27963
+ gray: {
27964
+ r: 0.501961,
27965
+ g: 0.501961,
27966
+ b: 0.501961,
27967
+ },
27968
+ green: {
27969
+ r: 0,
27970
+ g: 0.501961,
27971
+ b: 0,
27972
+ },
27973
+ greenyellow: {
27974
+ r: 0.678431,
27975
+ g: 1,
27976
+ b: 0.184314,
27977
+ },
27978
+ grey: {
27979
+ r: 0.501961,
27980
+ g: 0.501961,
27981
+ b: 0.501961,
27982
+ },
27983
+ honeydew: {
27984
+ r: 0.941176,
27985
+ g: 1,
27986
+ b: 0.941176,
27987
+ },
27988
+ hotpink: {
27989
+ r: 1,
27990
+ g: 0.411765,
27991
+ b: 0.705882,
27992
+ },
27993
+ indianred: {
27994
+ r: 0.803922,
27995
+ g: 0.360784,
27996
+ b: 0.360784,
27997
+ },
27998
+ indigo: {
27999
+ r: 0.294118,
28000
+ g: 0,
28001
+ b: 0.509804,
28002
+ },
28003
+ ivory: {
28004
+ r: 1,
28005
+ g: 1,
28006
+ b: 0.941176,
28007
+ },
28008
+ khaki: {
28009
+ r: 0.941176,
28010
+ g: 0.901961,
28011
+ b: 0.54902,
28012
+ },
28013
+ lavender: {
28014
+ r: 0.901961,
28015
+ g: 0.901961,
28016
+ b: 0.980392,
28017
+ },
28018
+ lavenderblush: {
28019
+ r: 1,
28020
+ g: 0.941176,
28021
+ b: 0.960784,
28022
+ },
28023
+ lawngreen: {
28024
+ r: 0.486275,
28025
+ g: 0.988235,
28026
+ b: 0,
28027
+ },
28028
+ lemonchiffon: {
28029
+ r: 1,
28030
+ g: 0.980392,
28031
+ b: 0.803922,
28032
+ },
28033
+ lightblue: {
28034
+ r: 0.678431,
28035
+ g: 0.847059,
28036
+ b: 0.901961,
28037
+ },
28038
+ lightcoral: {
28039
+ r: 0.941176,
28040
+ g: 0.501961,
28041
+ b: 0.501961,
28042
+ },
28043
+ lightcyan: {
28044
+ r: 0.878431,
28045
+ g: 1,
28046
+ b: 1,
28047
+ },
28048
+ lightgoldenrodyellow: {
28049
+ r: 0.980392,
28050
+ g: 0.980392,
28051
+ b: 0.823529,
28052
+ },
28053
+ lightgray: {
28054
+ r: 0.827451,
28055
+ g: 0.827451,
28056
+ b: 0.827451,
28057
+ },
28058
+ lightgreen: {
28059
+ r: 0.564706,
28060
+ g: 0.933333,
28061
+ b: 0.564706,
28062
+ },
28063
+ lightgrey: {
28064
+ r: 0.827451,
28065
+ g: 0.827451,
28066
+ b: 0.827451,
28067
+ },
28068
+ lightpink: {
28069
+ r: 1,
28070
+ g: 0.713725,
28071
+ b: 0.756863,
28072
+ },
28073
+ lightsalmon: {
28074
+ r: 1,
28075
+ g: 0.627451,
28076
+ b: 0.478431,
28077
+ },
28078
+ lightseagreen: {
28079
+ r: 0.12549,
28080
+ g: 0.698039,
28081
+ b: 0.666667,
28082
+ },
28083
+ lightskyblue: {
28084
+ r: 0.529412,
28085
+ g: 0.807843,
28086
+ b: 0.980392,
28087
+ },
28088
+ lightslategray: {
28089
+ r: 0.466667,
28090
+ g: 0.533333,
28091
+ b: 0.6,
28092
+ },
28093
+ lightslategrey: {
28094
+ r: 0.466667,
28095
+ g: 0.533333,
28096
+ b: 0.6,
28097
+ },
28098
+ lightsteelblue: {
28099
+ r: 0.690196,
28100
+ g: 0.768627,
28101
+ b: 0.870588,
28102
+ },
28103
+ lightyellow: {
28104
+ r: 1,
28105
+ g: 1,
28106
+ b: 0.878431,
28107
+ },
28108
+ lime: {
28109
+ r: 0,
28110
+ g: 1,
28111
+ b: 0,
28112
+ },
28113
+ limegreen: {
28114
+ r: 0.196078,
28115
+ g: 0.803922,
28116
+ b: 0.196078,
28117
+ },
28118
+ linen: {
28119
+ r: 0.980392,
28120
+ g: 0.941176,
28121
+ b: 0.901961,
28122
+ },
28123
+ magenta: {
28124
+ r: 1,
28125
+ g: 0,
28126
+ b: 1,
28127
+ },
28128
+ maroon: {
28129
+ r: 0.501961,
28130
+ g: 0,
28131
+ b: 0,
28132
+ },
28133
+ mediumaquamarine: {
28134
+ r: 0.4,
28135
+ g: 0.803922,
28136
+ b: 0.666667,
28137
+ },
28138
+ mediumblue: {
28139
+ r: 0,
28140
+ g: 0,
28141
+ b: 0.803922,
28142
+ },
28143
+ mediumorchid: {
28144
+ r: 0.729412,
28145
+ g: 0.333333,
28146
+ b: 0.827451,
28147
+ },
28148
+ mediumpurple: {
28149
+ r: 0.576471,
28150
+ g: 0.439216,
28151
+ b: 0.858824,
28152
+ },
28153
+ mediumseagreen: {
28154
+ r: 0.235294,
28155
+ g: 0.701961,
28156
+ b: 0.443137,
28157
+ },
28158
+ mediumslateblue: {
28159
+ r: 0.482353,
28160
+ g: 0.407843,
28161
+ b: 0.933333,
28162
+ },
28163
+ mediumspringgreen: {
28164
+ r: 0,
28165
+ g: 0.980392,
28166
+ b: 0.603922,
28167
+ },
28168
+ mediumturquoise: {
28169
+ r: 0.282353,
28170
+ g: 0.819608,
28171
+ b: 0.8,
28172
+ },
28173
+ mediumvioletred: {
28174
+ r: 0.780392,
28175
+ g: 0.082353,
28176
+ b: 0.521569,
28177
+ },
28178
+ midnightblue: {
28179
+ r: 0.098039,
28180
+ g: 0.098039,
28181
+ b: 0.439216,
28182
+ },
28183
+ mintcream: {
28184
+ r: 0.960784,
28185
+ g: 1,
28186
+ b: 0.980392,
28187
+ },
28188
+ mistyrose: {
28189
+ r: 1,
28190
+ g: 0.894118,
28191
+ b: 0.882353,
28192
+ },
28193
+ moccasin: {
28194
+ r: 1,
28195
+ g: 0.894118,
28196
+ b: 0.709804,
28197
+ },
28198
+ navajowhite: {
28199
+ r: 1,
28200
+ g: 0.870588,
28201
+ b: 0.678431,
28202
+ },
28203
+ navy: {
28204
+ r: 0,
28205
+ g: 0,
28206
+ b: 0.501961,
28207
+ },
28208
+ oldlace: {
28209
+ r: 0.992157,
28210
+ g: 0.960784,
28211
+ b: 0.901961,
28212
+ },
28213
+ olive: {
28214
+ r: 0.501961,
28215
+ g: 0.501961,
28216
+ b: 0,
28217
+ },
28218
+ olivedrab: {
28219
+ r: 0.419608,
28220
+ g: 0.556863,
28221
+ b: 0.137255,
28222
+ },
28223
+ orange: {
28224
+ r: 1,
28225
+ g: 0.647059,
28226
+ b: 0,
28227
+ },
28228
+ orangered: {
28229
+ r: 1,
28230
+ g: 0.270588,
28231
+ b: 0,
28232
+ },
28233
+ orchid: {
28234
+ r: 0.854902,
28235
+ g: 0.439216,
28236
+ b: 0.839216,
28237
+ },
28238
+ palegoldenrod: {
28239
+ r: 0.933333,
28240
+ g: 0.909804,
28241
+ b: 0.666667,
28242
+ },
28243
+ palegreen: {
28244
+ r: 0.596078,
28245
+ g: 0.984314,
28246
+ b: 0.596078,
28247
+ },
28248
+ paleturquoise: {
28249
+ r: 0.686275,
28250
+ g: 0.933333,
28251
+ b: 0.933333,
28252
+ },
28253
+ palevioletred: {
28254
+ r: 0.858824,
28255
+ g: 0.439216,
28256
+ b: 0.576471,
28257
+ },
28258
+ papayawhip: {
28259
+ r: 1,
28260
+ g: 0.937255,
28261
+ b: 0.835294,
28262
+ },
28263
+ peachpuff: {
28264
+ r: 1,
28265
+ g: 0.854902,
28266
+ b: 0.72549,
28267
+ },
28268
+ peru: {
28269
+ r: 0.803922,
28270
+ g: 0.521569,
28271
+ b: 0.247059,
28272
+ },
28273
+ pink: {
28274
+ r: 1,
28275
+ g: 0.752941,
28276
+ b: 0.796078,
28277
+ },
28278
+ plum: {
28279
+ r: 0.866667,
28280
+ g: 0.627451,
28281
+ b: 0.866667,
28282
+ },
28283
+ powderblue: {
28284
+ r: 0.690196,
28285
+ g: 0.878431,
28286
+ b: 0.901961,
28287
+ },
28288
+ purple: {
28289
+ r: 0.501961,
28290
+ g: 0,
28291
+ b: 0.501961,
28292
+ },
28293
+ red: {
28294
+ r: 1,
28295
+ g: 0,
28296
+ b: 0,
28297
+ },
28298
+ rosybrown: {
28299
+ r: 0.737255,
28300
+ g: 0.560784,
28301
+ b: 0.560784,
28302
+ },
28303
+ royalblue: {
28304
+ r: 0.254902,
28305
+ g: 0.411765,
28306
+ b: 0.882353,
28307
+ },
28308
+ saddlebrown: {
28309
+ r: 0.545098,
28310
+ g: 0.270588,
28311
+ b: 0.07451,
28312
+ },
28313
+ salmon: {
28314
+ r: 0.980392,
28315
+ g: 0.501961,
28316
+ b: 0.447059,
28317
+ },
28318
+ sandybrown: {
28319
+ r: 0.956863,
28320
+ g: 0.643137,
28321
+ b: 0.376471,
28322
+ },
28323
+ seagreen: {
28324
+ r: 0.180392,
28325
+ g: 0.545098,
28326
+ b: 0.341176,
28327
+ },
28328
+ seashell: {
28329
+ r: 1,
28330
+ g: 0.960784,
28331
+ b: 0.933333,
28332
+ },
28333
+ sienna: {
28334
+ r: 0.627451,
28335
+ g: 0.321569,
28336
+ b: 0.176471,
28337
+ },
28338
+ silver: {
28339
+ r: 0.752941,
28340
+ g: 0.752941,
28341
+ b: 0.752941,
28342
+ },
28343
+ skyblue: {
28344
+ r: 0.529412,
28345
+ g: 0.807843,
28346
+ b: 0.921569,
28347
+ },
28348
+ slateblue: {
28349
+ r: 0.415686,
28350
+ g: 0.352941,
28351
+ b: 0.803922,
28352
+ },
28353
+ slategray: {
28354
+ r: 0.439216,
28355
+ g: 0.501961,
28356
+ b: 0.564706,
28357
+ },
28358
+ slategrey: {
28359
+ r: 0.439216,
28360
+ g: 0.501961,
28361
+ b: 0.564706,
28362
+ },
28363
+ snow: {
28364
+ r: 1,
28365
+ g: 0.980392,
28366
+ b: 0.980392,
28367
+ },
28368
+ springgreen: {
28369
+ r: 0,
28370
+ g: 1,
28371
+ b: 0.498039,
28372
+ },
28373
+ steelblue: {
28374
+ r: 0.27451,
28375
+ g: 0.509804,
28376
+ b: 0.705882,
28377
+ },
28378
+ tan: {
28379
+ r: 0.823529,
28380
+ g: 0.705882,
28381
+ b: 0.54902,
28382
+ },
28383
+ teal: {
28384
+ r: 0,
28385
+ g: 0.501961,
28386
+ b: 0.501961,
28387
+ },
28388
+ thistle: {
28389
+ r: 0.847059,
28390
+ g: 0.74902,
28391
+ b: 0.847059,
28392
+ },
28393
+ tomato: {
28394
+ r: 1,
28395
+ g: 0.388235,
28396
+ b: 0.278431,
28397
+ },
28398
+ transparent: {
28399
+ r: 0,
28400
+ g: 0,
28401
+ b: 0,
28402
+ a: 0,
28403
+ },
28404
+ turquoise: {
28405
+ r: 0.25098,
28406
+ g: 0.878431,
28407
+ b: 0.815686,
28408
+ },
28409
+ violet: {
28410
+ r: 0.933333,
28411
+ g: 0.509804,
28412
+ b: 0.933333,
28413
+ },
28414
+ wheat: {
28415
+ r: 0.960784,
28416
+ g: 0.870588,
28417
+ b: 0.701961,
28418
+ },
28419
+ white: {
28420
+ r: 1,
28421
+ g: 1,
28422
+ b: 1,
28423
+ },
28424
+ whitesmoke: {
28425
+ r: 0.960784,
28426
+ g: 0.960784,
28427
+ b: 0.960784,
28428
+ },
28429
+ yellow: {
28430
+ r: 1,
28431
+ g: 1,
28432
+ b: 0,
28433
+ },
28434
+ yellowgreen: {
28435
+ r: 0.603922,
28436
+ g: 0.803922,
28437
+ b: 0.196078,
28438
+ },
28439
+ };
28440
+
28441
+ // Matches rgb(R, G, B) where R, G, and B are integers [0 - 255]
28442
+ const webRGBRegex = /^rgb\(\s*((?:(?:25[0-5]|2[0-4]\d|1\d\d|\d{1,2})\s*,\s*){2}(?:25[0-5]|2[0-4]\d|1\d\d|\d{1,2})\s*)\)$/i;
28443
+ // Matches rgb(R, G, B, A) where R, G, and B are integers [0 - 255] and A is [0-1] floating
28444
+ const webRGBARegex = /^rgba\(\s*((?:(?:25[0-5]|2[0-4]\d|1\d\d|\d{1,2})\s*,\s*){3}(?:0|1|0?\.\d*)\s*)\)$/i;
28445
+ // Matches #RGB and #RRGGBB, where R, G, and B are [0-9] or [A-F]
28446
+ const hexRGBRegex = /^#((?:[0-9a-f]{6}|[0-9a-f]{3}))$/i;
28447
+ // Matches #RGB and #RRGGBBAA, where R, G, B, and A are [0-9] or [A-F]
28448
+ const hexRGBARegex = /^#((?:[0-9a-f]{8}|[0-9a-f]{4}))$/i;
28449
+ /**
28450
+ * Test if a color matches #RRGGBB or #RGB
28451
+ * @public
28452
+ */
28453
+ function isColorStringHexRGB(raw) {
28454
+ return hexRGBRegex.test(raw);
28455
+ }
28456
+ /**
28457
+ * Test if a color matches #AARRGGBB or #ARGB
28458
+ * @public
28459
+ */
28460
+ function isColorStringHexARGB(raw) {
28461
+ return hexRGBARegex.test(raw);
28462
+ }
28463
+ /**
28464
+ * Test if a color matches #RRGGBBAA or #RGBA
28465
+ * @public
28466
+ */
28467
+ function isColorStringHexRGBA(raw) {
28468
+ return isColorStringHexARGB(raw); // No way to differentiate these two formats, so just use the same test
28469
+ }
28470
+ /**
28471
+ * Test if a color matches rgb(rr, gg, bb)
28472
+ * @public
28473
+ */
28474
+ function isColorStringWebRGB(raw) {
28475
+ return webRGBRegex.test(raw);
28476
+ }
28477
+ /**
28478
+ * Test if a color matches rgba(rr, gg, bb, aa)
28479
+ *
28480
+ * @public
28481
+ */
28482
+ function isColorStringWebRGBA(raw) {
28483
+ return webRGBARegex.test(raw);
28484
+ }
28485
+ /**
28486
+ * Tests whether a color is in {@link @microsoft/fast-colors#NamedColors}.
28487
+ * @param raw - the color name to test
28488
+ * @public
28489
+ */
28490
+ function isColorNamed(raw) {
28491
+ return namedColorsConfigs.hasOwnProperty(raw);
28492
+ }
28493
+ /**
28494
+ * Converts a hexadecimal color string to a {@link @microsoft/fast-colors#ColorRGBA64}.
28495
+ * @param raw - a color string in the form of "#RRGGBB" or "#RGB"
28496
+ * @example
28497
+ * ```ts
28498
+ * parseColorHexRGBA("#FF0000");
28499
+ * parseColorHexRGBA("#F00");
28500
+ * ```
28501
+ * @public
28502
+ */
28503
+ function parseColorHexRGB(raw) {
28504
+ const result = hexRGBRegex.exec(raw);
28505
+ if (result === null) {
28506
+ return null;
28507
+ }
28508
+ let digits = result[1];
28509
+ if (digits.length === 3) {
28510
+ const r = digits.charAt(0);
28511
+ const g = digits.charAt(1);
28512
+ const b = digits.charAt(2);
28513
+ digits = r.concat(r, g, g, b, b);
28514
+ }
28515
+ const rawInt = parseInt(digits, 16);
28516
+ if (isNaN(rawInt)) {
28517
+ return null;
28518
+ }
28519
+ // Note the use of >>> rather than >> as we want JS to manipulate these as unsigned numbers
28520
+ return new ColorRGBA64(normalize((rawInt & 0xff0000) >>> 16, 0, 255), normalize((rawInt & 0x00ff00) >>> 8, 0, 255), normalize(rawInt & 0x0000ff, 0, 255), 1);
28521
+ }
28522
+ /**
28523
+ * Converts a hexadecimal color string to a {@link @microsoft/fast-colors#ColorRGBA64}.
28524
+ * @param raw - a color string in the form of "#AARRGGBB" or "#ARGB"
28525
+ * @example
28526
+ * ```ts
28527
+ * parseColorHexRGBA("#AAFF0000");
28528
+ * parseColorHexRGBA("#AF00");
28529
+ * ```
28530
+ * @public
28531
+ */
28532
+ function parseColorHexARGB(raw) {
28533
+ const result = hexRGBARegex.exec(raw);
28534
+ if (result === null) {
28535
+ return null;
28536
+ }
28537
+ let digits = result[1];
28538
+ if (digits.length === 4) {
28539
+ const a = digits.charAt(0);
28540
+ const r = digits.charAt(1);
28541
+ const g = digits.charAt(2);
28542
+ const b = digits.charAt(3);
28543
+ digits = a.concat(a, r, r, g, g, b, b);
28544
+ }
28545
+ const rawInt = parseInt(digits, 16);
28546
+ if (isNaN(rawInt)) {
28547
+ return null;
28548
+ }
28549
+ // Note the use of >>> rather than >> as we want JS to manipulate these as unsigned numbers
28550
+ return new ColorRGBA64(normalize((rawInt & 0x00ff0000) >>> 16, 0, 255), normalize((rawInt & 0x0000ff00) >>> 8, 0, 255), normalize(rawInt & 0x000000ff, 0, 255), normalize((rawInt & 0xff000000) >>> 24, 0, 255));
28551
+ }
28552
+ /**
28553
+ * Converts a rgb color string to a {@link @microsoft/fast-colors#ColorRGBA64}.
28554
+ * @param raw - a color string format "rgba(RR,GG,BB)" where RR,GG,BB are [0,255]
28555
+ * @example
28556
+ * ```ts
28557
+ * parseColorWebRGB("rgba(255, 0, 0");
28558
+ * ```
28559
+ * @public
28560
+ */
28561
+ function parseColorWebRGB(raw) {
28562
+ const result = webRGBRegex.exec(raw);
28563
+ if (result === null) {
28564
+ return null;
28565
+ }
28566
+ const split = result[1].split(",");
28567
+ return new ColorRGBA64(normalize(Number(split[0]), 0, 255), normalize(Number(split[1]), 0, 255), normalize(Number(split[2]), 0, 255), 1);
28568
+ }
28569
+ /**
28570
+ * Converts a rgba color string to a {@link @microsoft/fast-colors#ColorRGBA64}.
28571
+ * @param raw - a color string format "rgba(RR,GG,BB,a)" where RR,GG,BB are [0,255] and a is [0,1]
28572
+ * @example
28573
+ * ```ts
28574
+ * parseColorWebRGBA("rgba(255, 0, 0, 1");
28575
+ * ```
28576
+ * @public
28577
+ */
28578
+ function parseColorWebRGBA(raw) {
28579
+ const result = webRGBARegex.exec(raw);
28580
+ if (result === null) {
28581
+ return null;
28582
+ }
28583
+ const split = result[1].split(",");
28584
+ if (split.length === 4) {
28585
+ return new ColorRGBA64(normalize(Number(split[0]), 0, 255), normalize(Number(split[1]), 0, 255), normalize(Number(split[2]), 0, 255), Number(split[3]));
28586
+ }
28587
+ return null;
28588
+ }
28589
+ /**
28590
+ * Converts a named color to a {@link @microsoft/fast-colors#ColorRGBA64}.
28591
+ * @param raw - a {@link https://www.w3schools.com/colors/colors_names.asp | CSS color name}.
28592
+ * @example
28593
+ * ```ts
28594
+ * parseColorNamed("red");
28595
+ * ```
28596
+ * @public
28597
+ */
28598
+ function parseColorNamed(raw) {
28599
+ // const rawLower: typeof raw = raw.toLowerCase() : raw.toString();
28600
+ const config = namedColorsConfigs[raw.toLowerCase()];
28601
+ return config
28602
+ ? new ColorRGBA64(config.r, config.g, config.b, config.hasOwnProperty("a") ? config.a : void 0)
28603
+ : null;
28604
+ }
28605
+ /**
28606
+ *
28607
+ Expects any of the following and attempts to determine which is being used
28608
+ * #RRGGBB, #AARRGGBB, rgb(RR,GG,BB) rgba(RR,GG,BB,a),
28609
+ * or any of the {@link https://www.w3schools.com/colors/colors_names.asp | CSS color names}.
28610
+ * @param raw - the color string to parse
28611
+ * @public
28612
+ */
28613
+ function parseColor(raw) {
28614
+ const rawLower = raw.toLowerCase();
28615
+ return isColorStringHexRGB(rawLower)
28616
+ ? parseColorHexRGB(rawLower)
28617
+ : isColorStringHexRGBA(rawLower)
28618
+ ? parseColorHexARGB(rawLower)
28619
+ : isColorStringWebRGB(rawLower)
28620
+ ? parseColorWebRGB(rawLower)
28621
+ : isColorStringWebRGBA(rawLower)
28622
+ ? parseColorWebRGBA(rawLower)
28623
+ : isColorNamed(rawLower)
28624
+ ? parseColorNamed(rawLower)
28625
+ : null;
28626
+ }
28627
+
28628
+ /**
28629
+ * Prerendering prepares render-ready dies data to be used by the rendering module
28630
+ */
28631
+ class Prerendering {
28632
+ constructor(dies, colorScale, highlightedValues, horizontalScale, verticalScale, colorScaleMode, dieLabelsHidden, dieLabelsSuffix, maxCharacters, dieDimensions, margin) {
28633
+ this.fontSizeFactor = 0.8;
28634
+ this.nonHighlightedOpacity = 0.3;
28635
+ this.emptyDieColor = 'rgba(218,223,236,1)';
28636
+ this.nanDieColor = 'rgba(122,122,122,1)';
28637
+ this.d3ColorScale = this.createD3ColorScale(colorScale, colorScaleMode);
28638
+ this.labelsFontSize = this.calculateLabelsFontSize(dieDimensions, maxCharacters);
28639
+ this.diesRenderInfo = [];
28640
+ for (const die of dies) {
28641
+ this.diesRenderInfo.push({
28642
+ x: horizontalScale(die.x) + margin.right,
28643
+ y: verticalScale(die.y) + margin.top,
28644
+ fillStyle: this.calculateFillStyle(die.value, colorScaleMode, highlightedValues),
28645
+ text: this.buildLabel(die.value, maxCharacters, dieLabelsHidden, dieLabelsSuffix)
28646
+ });
28647
+ }
28648
+ }
28649
+ calculateLabelsFontSize(dieDimensions, maxCharacters) {
28650
+ return Math.min(dieDimensions.height, (dieDimensions.width / (Math.max(2, maxCharacters) * 0.5))
28651
+ * this.fontSizeFactor);
28652
+ }
28653
+ createD3ColorScale(colorScale, colorScaleMode) {
28654
+ if (this.isColorScaleLinear(colorScaleMode)) {
28655
+ return linear()
28656
+ .domain(colorScale.values.map(item => +item))
28657
+ .range(colorScale.colors);
28658
+ }
28659
+ return ordinal()
28660
+ .domain(colorScale.values)
28661
+ .range(colorScale.colors);
28662
+ }
28663
+ dieHasData(dieData) {
28664
+ return dieData !== null && dieData !== undefined && dieData !== '';
28665
+ }
28666
+ buildLabel(value, maxCharacters, dieLabelsHidden, dieLabelsSuffix) {
28667
+ if (dieLabelsHidden || !this.dieHasData(value)) {
28668
+ return '';
28669
+ }
28670
+ const label = `${value}${dieLabelsSuffix}`;
28671
+ if (label.length > maxCharacters) {
28672
+ return `${label.substring(0, maxCharacters)}…`;
28673
+ }
28674
+ return label;
28675
+ }
28676
+ calculateOpacity(selectedValue, highlightedValues) {
28677
+ return highlightedValues.length > 0
28678
+ && !highlightedValues.some(dieValue => dieValue === selectedValue)
28679
+ ? this.nonHighlightedOpacity
28680
+ : 1;
28681
+ }
28682
+ isColorScaleLinear(colorScaleMode) {
28683
+ return colorScaleMode === WaferMapColorScaleMode.linear;
28684
+ }
28685
+ isColorScaleOrdinal(colorScaleMode) {
28686
+ return colorScaleMode === WaferMapColorScaleMode.ordinal;
28687
+ }
28688
+ calculateFillStyle(value, colorScaleMode, highlightedValues) {
28689
+ let colorValue = this.emptyDieColor;
28690
+ if (this.dieHasData(value)) {
28691
+ if (isNaN(+value)) {
28692
+ colorValue = this.nanDieColor;
28693
+ }
28694
+ else if (this.isColorScaleLinear(colorScaleMode)) {
28695
+ colorValue = this.d3ColorScale(+value);
28696
+ }
28697
+ else if (this.isColorScaleOrdinal(colorScaleMode)) {
28698
+ colorValue = this.d3ColorScale(value);
28699
+ }
28700
+ }
28701
+ if (colorValue === undefined) {
28702
+ return this.emptyDieColor;
28703
+ }
28704
+ let rgbColor = parseColor(colorValue);
28705
+ if (rgbColor === null) {
28706
+ return this.emptyDieColor;
28707
+ }
28708
+ rgbColor = new ColorRGBA64(rgbColor.r, rgbColor.g, rgbColor.b, this.calculateOpacity(value, highlightedValues));
28709
+ return rgbColor.toStringWebRGBA();
28710
+ }
28711
+ }
28712
+
28713
+ /**
28714
+ * Data Manager uses Computations and Prerendering modules in order and exposes the results
28715
+ */
28716
+ class DataManager {
28717
+ constructor(dies, axisLocation, canvasDimensions, colorScale, highlightedValues, colorScaleMode, dieLabelsHidden, dieLabelsSuffix, maxCharacters) {
28718
+ this.computations = new Computations(dies, axisLocation, canvasDimensions);
28719
+ this.prerendering = new Prerendering(dies, colorScale, highlightedValues, this.computations.horizontalScale, this.computations.verticalScale, colorScaleMode, dieLabelsHidden, dieLabelsSuffix, maxCharacters, this.computations.dieDimensions, this.computations.margin);
28720
+ }
28721
+ get containerDimensions() {
28722
+ return this.computations.containerDimensions;
28723
+ }
28724
+ get dieDimensions() {
28725
+ return this.computations.dieDimensions;
28726
+ }
28727
+ get radius() {
28728
+ return this.computations.radius;
28729
+ }
28730
+ get margin() {
28731
+ return this.computations.margin;
28732
+ }
28733
+ get horizontalScale() {
28734
+ return this.computations.horizontalScale;
28735
+ }
28736
+ get verticalScale() {
28737
+ return this.computations.verticalScale;
28738
+ }
28739
+ get labelsFontSize() {
28740
+ return this.prerendering.labelsFontSize;
28741
+ }
28742
+ get diesRenderInfo() {
28743
+ return this.prerendering.diesRenderInfo;
28744
+ }
28745
+ get mainCircleLocation() {
28746
+ return {
28747
+ x: this.computations.containerDimensions.width / 2,
28748
+ y: this.computations.containerDimensions.height / 2
28749
+ };
28750
+ }
28751
+ }
28752
+
25940
28753
  /**
25941
28754
  * A nimble-styled WaferMap
25942
28755
  */
@@ -25948,13 +28761,54 @@ Instead styling against the role which is more general and likely a better appro
25948
28761
  this.maxCharacters = 4;
25949
28762
  this.dieLabelsHidden = false;
25950
28763
  this.dieLabelsSuffix = '';
25951
- this.colorsScaleMode = WaferMapColorsScaleMode.linear;
28764
+ this.colorScaleMode = WaferMapColorScaleMode.linear;
25952
28765
  this.highlightedValues = [];
25953
28766
  this.dies = [];
25954
28767
  this.colorScale = {
25955
28768
  colors: [],
25956
28769
  values: []
25957
28770
  };
28771
+ this.renderQueued = false;
28772
+ }
28773
+ /**
28774
+ * @internal
28775
+ */
28776
+ render() {
28777
+ this.renderQueued = false;
28778
+ this.dataManager = new DataManager(this.dies, this.quadrant, { width: this.offsetWidth, height: this.offsetHeight }, this.colorScale, this.highlightedValues, this.colorScaleMode, this.dieLabelsHidden, this.dieLabelsSuffix, this.maxCharacters);
28779
+ }
28780
+ quadrantChanged() {
28781
+ this.queueRender();
28782
+ }
28783
+ orientationChanged() {
28784
+ this.queueRender();
28785
+ }
28786
+ maxCharactersChanged() {
28787
+ this.queueRender();
28788
+ }
28789
+ dieLabelsHiddenChanged() {
28790
+ this.queueRender();
28791
+ }
28792
+ dieLabelsSuffixChanged() {
28793
+ this.queueRender();
28794
+ }
28795
+ colorScaleModeChanged() {
28796
+ this.queueRender();
28797
+ }
28798
+ highlightedValuesChanged() {
28799
+ this.queueRender();
28800
+ }
28801
+ diesChanged() {
28802
+ this.queueRender();
28803
+ }
28804
+ colorScaleChanged() {
28805
+ this.queueRender();
28806
+ }
28807
+ queueRender() {
28808
+ if (!this.renderQueued) {
28809
+ this.renderQueued = true;
28810
+ DOM.queueUpdate(() => this.render());
28811
+ }
25958
28812
  }
25959
28813
  }
25960
28814
  __decorate([
@@ -25982,9 +28836,9 @@ Instead styling against the role which is more general and likely a better appro
25982
28836
  ], WaferMap.prototype, "dieLabelsSuffix", void 0);
25983
28837
  __decorate([
25984
28838
  attr({
25985
- attribute: 'colors-scale-mode'
28839
+ attribute: 'color-scale-mode'
25986
28840
  })
25987
- ], WaferMap.prototype, "colorsScaleMode", void 0);
28841
+ ], WaferMap.prototype, "colorScaleMode", void 0);
25988
28842
  __decorate([
25989
28843
  observable
25990
28844
  ], WaferMap.prototype, "highlightedValues", void 0);