@uwdata/mosaic-spec 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12884,6 +12884,15 @@ var Query = class _Query {
12884
12884
  static except(...queries) {
12885
12885
  return new SetOperation("EXCEPT", queries.flat());
12886
12886
  }
12887
+ static describe(query) {
12888
+ const q = query.clone();
12889
+ const { clone, toString } = q;
12890
+ return Object.assign(q, {
12891
+ describe: true,
12892
+ clone: () => _Query.describe(clone.call(q)),
12893
+ toString: () => `DESCRIBE ${toString.call(q)}`
12894
+ });
12895
+ }
12887
12896
  constructor() {
12888
12897
  this.query = {
12889
12898
  with: [],
@@ -13118,6 +13127,7 @@ var Query = class _Query {
13118
13127
  }
13119
13128
  toString() {
13120
13129
  const {
13130
+ with: cte,
13121
13131
  select: select2,
13122
13132
  distinct: distinct2,
13123
13133
  from: from2,
@@ -13129,8 +13139,7 @@ var Query = class _Query {
13129
13139
  qualify,
13130
13140
  orderby,
13131
13141
  limit,
13132
- offset: offset2,
13133
- with: cte
13142
+ offset: offset2
13134
13143
  } = this.query;
13135
13144
  const sql2 = [];
13136
13145
  if (cte.length) {
@@ -13252,6 +13261,9 @@ var SetOperation = class _SetOperation {
13252
13261
  function isQuery(value) {
13253
13262
  return value instanceof Query || value instanceof SetOperation;
13254
13263
  }
13264
+ function isDescribeQuery(value) {
13265
+ return isQuery(value) && value.describe;
13266
+ }
13255
13267
  function unquote(s2) {
13256
13268
  return isDoubleQuoted(s2) ? s2.slice(1, -1) : s2;
13257
13269
  }
@@ -13433,131 +13445,6 @@ function toDuckDBValue(value) {
13433
13445
  }
13434
13446
  }
13435
13447
 
13436
- // ../core/src/util/js-type.js
13437
- function jsType(type2) {
13438
- switch (type2) {
13439
- case "BIGINT":
13440
- case "HUGEINT":
13441
- case "INTEGER":
13442
- case "SMALLINT":
13443
- case "TINYINT":
13444
- case "UBIGINT":
13445
- case "UINTEGER":
13446
- case "USMALLINT":
13447
- case "UTINYINT":
13448
- case "DOUBLE":
13449
- case "FLOAT":
13450
- case "REAL":
13451
- case "DECIMAL":
13452
- return "number";
13453
- case "DATE":
13454
- case "TIMESTAMP":
13455
- case "TIMESTAMPTZ":
13456
- case "TIMESTAMP WITH TIME ZONE":
13457
- case "TIME":
13458
- case "TIMESTAMP_NS":
13459
- return "date";
13460
- case "BOOLEAN":
13461
- return "boolean";
13462
- case "VARCHAR":
13463
- case "UUID":
13464
- return "string";
13465
- case "LIST":
13466
- return "array";
13467
- case "BLOB":
13468
- case "STRUCT":
13469
- case "MAP":
13470
- return "object";
13471
- default:
13472
- throw new Error(`Unsupported type: ${type2}`);
13473
- }
13474
- }
13475
-
13476
- // ../core/src/util/summarize.js
13477
- var Count = "count";
13478
- var Nulls = "nulls";
13479
- var Max = "max";
13480
- var Min = "min";
13481
- var Distinct = "distinct";
13482
- var statMap = {
13483
- [Count]: count,
13484
- [Distinct]: (column3) => count(column3).distinct(),
13485
- [Max]: max,
13486
- [Min]: min,
13487
- [Nulls]: (column3) => count().where(isNull(column3))
13488
- };
13489
- function summarize({ table: table3, column: column3 }, stats) {
13490
- return Query.from(table3).select(stats.map((s2) => [s2, statMap[s2](column3)]));
13491
- }
13492
-
13493
- // ../core/src/Catalog.js
13494
- var object = () => /* @__PURE__ */ Object.create(null);
13495
- var Catalog = class {
13496
- constructor(coordinator2) {
13497
- this.mc = coordinator2;
13498
- this.clear();
13499
- }
13500
- clear() {
13501
- this.tables = object();
13502
- }
13503
- tableInfo(table3) {
13504
- const cache = this.tables;
13505
- if (cache[table3]) {
13506
- return cache[table3];
13507
- }
13508
- const infoPromise = getTableInfo(this.mc, table3).catch((err) => {
13509
- cache[table3] = null;
13510
- throw err;
13511
- });
13512
- return cache[table3] = infoPromise;
13513
- }
13514
- async fieldInfo({ table: table3, column: column3, stats }) {
13515
- const tableInfo = await this.tableInfo(table3);
13516
- const colInfo = tableInfo[column3];
13517
- if (colInfo == null)
13518
- return;
13519
- if (!stats?.length)
13520
- return colInfo;
13521
- const result = await this.mc.query(
13522
- summarize(colInfo, stats),
13523
- { persist: true }
13524
- );
13525
- const info = { ...colInfo, ...Array.from(result)[0] };
13526
- for (const key in info) {
13527
- const value = info[key];
13528
- if (typeof value === "bigint") {
13529
- info[key] = Number(value);
13530
- }
13531
- }
13532
- return info;
13533
- }
13534
- async queryFields(fields) {
13535
- const list = await resolveFields(this, fields);
13536
- const data = await Promise.all(list.map((f) => this.fieldInfo(f)));
13537
- return data.filter((x3) => x3);
13538
- }
13539
- };
13540
- async function getTableInfo(mc, table3) {
13541
- const result = await mc.query(
13542
- `DESCRIBE ${asRelation(table3)}`,
13543
- { type: "json", cache: false }
13544
- );
13545
- const columns = object();
13546
- for (const entry of result) {
13547
- columns[entry.column_name] = {
13548
- table: table3,
13549
- column: entry.column_name,
13550
- sqlType: entry.column_type,
13551
- type: jsType(entry.column_type),
13552
- nullable: entry.null === "YES"
13553
- };
13554
- }
13555
- return columns;
13556
- }
13557
- async function resolveFields(catalog, list) {
13558
- return list.length === 1 && list[0].column === "*" ? Object.values(await catalog.tableInfo(list[0].table)) : list;
13559
- }
13560
-
13561
13448
  // ../core/src/util/hash.js
13562
13449
  function fnv_hash(v2) {
13563
13450
  let a2 = 2166136261;
@@ -13917,7 +13804,7 @@ function consolidate(group3, enqueue, record) {
13917
13804
  type: "arrow",
13918
13805
  cache: false,
13919
13806
  record: false,
13920
- query: consolidatedQuery(group3, record)
13807
+ query: group3.query = consolidatedQuery(group3, record)
13921
13808
  },
13922
13809
  result: group3.result = queryResult()
13923
13810
  });
@@ -13965,7 +13852,7 @@ function consolidatedQuery(group3, record) {
13965
13852
  return query.$select(Array.from(fields.values()));
13966
13853
  }
13967
13854
  async function processResults(group3, cache) {
13968
- const { maps, result } = group3;
13855
+ const { maps, query, result } = group3;
13969
13856
  if (!maps)
13970
13857
  return;
13971
13858
  let data;
@@ -13977,25 +13864,33 @@ async function processResults(group3, cache) {
13977
13864
  }
13978
13865
  return;
13979
13866
  }
13867
+ const describe = isDescribeQuery(query);
13980
13868
  group3.forEach(({ entry }, index2) => {
13981
13869
  const { request, result: result2 } = entry;
13982
- const projected = projectResult(data, maps[index2]);
13870
+ const map4 = maps[index2];
13871
+ const extract = describe && map4 ? filterResult(data, map4) : map4 ? projectResult(data, map4) : data;
13983
13872
  if (request.cache) {
13984
- cache.set(String(request.query), projected);
13873
+ cache.set(String(request.query), extract);
13985
13874
  }
13986
- result2.fulfill(projected);
13875
+ result2.fulfill(extract);
13987
13876
  });
13988
13877
  }
13989
13878
  function projectResult(data, map4) {
13990
- if (map4) {
13991
- const cols = {};
13992
- for (const [name2, as] of map4) {
13993
- cols[as] = data.getChild(name2);
13879
+ const cols = {};
13880
+ for (const [name2, as] of map4) {
13881
+ cols[as] = data.getChild(name2);
13882
+ }
13883
+ return new data.constructor(cols);
13884
+ }
13885
+ function filterResult(data, map4) {
13886
+ const lookup = new Map(map4);
13887
+ const result = [];
13888
+ for (const d of data) {
13889
+ if (lookup.has(d.column_name)) {
13890
+ result.push({ ...d, column_name: lookup.get(d.column_name) });
13994
13891
  }
13995
- return new data.constructor(cols);
13996
- } else {
13997
- return data;
13998
13892
  }
13893
+ return result;
13999
13894
  }
14000
13895
 
14001
13896
  // ../core/src/util/cache.js
@@ -14242,6 +14137,197 @@ function QueryManager() {
14242
14137
  };
14243
14138
  }
14244
14139
 
14140
+ // ../core/src/util/js-type.js
14141
+ function jsType(type2) {
14142
+ switch (type2) {
14143
+ case "BIGINT":
14144
+ case "HUGEINT":
14145
+ case "INTEGER":
14146
+ case "SMALLINT":
14147
+ case "TINYINT":
14148
+ case "UBIGINT":
14149
+ case "UINTEGER":
14150
+ case "USMALLINT":
14151
+ case "UTINYINT":
14152
+ case "DOUBLE":
14153
+ case "FLOAT":
14154
+ case "REAL":
14155
+ return "number";
14156
+ case "DATE":
14157
+ case "TIMESTAMP":
14158
+ case "TIMESTAMPTZ":
14159
+ case "TIMESTAMP WITH TIME ZONE":
14160
+ case "TIME":
14161
+ case "TIMESTAMP_NS":
14162
+ return "date";
14163
+ case "BOOLEAN":
14164
+ return "boolean";
14165
+ case "VARCHAR":
14166
+ case "UUID":
14167
+ return "string";
14168
+ case "ARRAY":
14169
+ case "LIST":
14170
+ return "array";
14171
+ case "BLOB":
14172
+ case "STRUCT":
14173
+ case "MAP":
14174
+ case "GEOMETRY":
14175
+ return "object";
14176
+ default:
14177
+ if (type2.startsWith("DECIMAL")) {
14178
+ return "number";
14179
+ } else if (type2.startsWith("STRUCT") || type2.startsWith("MAP")) {
14180
+ return "object";
14181
+ } else if (type2.endsWith("]")) {
14182
+ return "array";
14183
+ }
14184
+ throw new Error(`Unsupported type: ${type2}`);
14185
+ }
14186
+ }
14187
+
14188
+ // ../core/src/util/convert-arrow.js
14189
+ var INTEGER = 2;
14190
+ var FLOAT = 3;
14191
+ var DECIMAL = 7;
14192
+ var TIMESTAMP = 10;
14193
+ function isArrowTable(values2) {
14194
+ return typeof values2?.getChild === "function";
14195
+ }
14196
+ function convertArrowArrayType(type2) {
14197
+ switch (type2.typeId) {
14198
+ case INTEGER:
14199
+ case FLOAT:
14200
+ case DECIMAL:
14201
+ return Float64Array;
14202
+ default:
14203
+ return Array;
14204
+ }
14205
+ }
14206
+ function convertArrowValue(type2) {
14207
+ const { typeId } = type2;
14208
+ if (typeId === TIMESTAMP) {
14209
+ return (v2) => v2 == null ? v2 : new Date(v2);
14210
+ }
14211
+ if (typeId === INTEGER && type2.bitWidth >= 64) {
14212
+ return (v2) => v2 == null ? v2 : Number(v2);
14213
+ }
14214
+ if (typeId === DECIMAL) {
14215
+ const scale3 = 1 / Math.pow(10, type2.scale);
14216
+ return (v2) => v2 == null ? v2 : decimalToNumber(v2, scale3);
14217
+ }
14218
+ return (v2) => v2;
14219
+ }
14220
+ function convertArrowColumn(column3) {
14221
+ const { type: type2 } = column3;
14222
+ const { typeId } = type2;
14223
+ if (typeId === TIMESTAMP) {
14224
+ const size = column3.length;
14225
+ const array3 = new Array(size);
14226
+ for (let row = 0; row < size; ++row) {
14227
+ const v2 = column3.get(row);
14228
+ array3[row] = v2 == null ? null : new Date(v2);
14229
+ }
14230
+ return array3;
14231
+ }
14232
+ if (typeId === INTEGER && type2.bitWidth >= 64) {
14233
+ const size = column3.length;
14234
+ const array3 = new Float64Array(size);
14235
+ for (let row = 0; row < size; ++row) {
14236
+ const v2 = column3.get(row);
14237
+ array3[row] = v2 == null ? NaN : Number(v2);
14238
+ }
14239
+ return array3;
14240
+ }
14241
+ if (typeId === DECIMAL) {
14242
+ const scale3 = 1 / Math.pow(10, type2.scale);
14243
+ const size = column3.length;
14244
+ const array3 = new Float64Array(size);
14245
+ for (let row = 0; row < size; ++row) {
14246
+ const v2 = column3.get(row);
14247
+ array3[row] = v2 == null ? NaN : decimalToNumber(v2, scale3);
14248
+ }
14249
+ return array3;
14250
+ }
14251
+ return column3.toArray();
14252
+ }
14253
+ var BASE32 = Array.from(
14254
+ { length: 8 },
14255
+ (_, i) => Math.pow(2, i * 32)
14256
+ );
14257
+ function decimalToNumber(v2, scale3) {
14258
+ const n = v2.length;
14259
+ let x3 = 0;
14260
+ if (v2.signed && (v2[n - 1] | 0) < 0) {
14261
+ for (let i = 0; i < n; ++i) {
14262
+ x3 += ~v2[i] * BASE32[i];
14263
+ }
14264
+ x3 = -(x3 + 1);
14265
+ } else {
14266
+ for (let i = 0; i < n; ++i) {
14267
+ x3 += v2[i] * BASE32[i];
14268
+ }
14269
+ }
14270
+ return x3 * scale3;
14271
+ }
14272
+
14273
+ // ../core/src/util/field-info.js
14274
+ var Count = "count";
14275
+ var Nulls = "nulls";
14276
+ var Max = "max";
14277
+ var Min = "min";
14278
+ var Distinct = "distinct";
14279
+ var statMap = {
14280
+ [Count]: count,
14281
+ [Distinct]: (column3) => count(column3).distinct(),
14282
+ [Max]: max,
14283
+ [Min]: min,
14284
+ [Nulls]: (column3) => count().where(isNull(column3))
14285
+ };
14286
+ function summarize(table3, column3, stats) {
14287
+ return Query.from(table3).select(Array.from(stats, (s2) => [s2, statMap[s2](column3)]));
14288
+ }
14289
+ async function queryFieldInfo(mc, fields) {
14290
+ if (fields.length === 1 && `${fields[0].column}` === "*") {
14291
+ return getTableInfo(mc, fields[0].table);
14292
+ } else {
14293
+ return (await Promise.all(fields.map((f) => getFieldInfo(mc, f)))).filter((x3) => x3);
14294
+ }
14295
+ }
14296
+ async function getFieldInfo(mc, { table: table3, column: column3, stats }) {
14297
+ const q = Query.from({ source: table3 }).select({ column: column3 }).groupby(column3.aggregate ? sql`ALL` : []);
14298
+ const [desc2] = Array.from(await mc.query(Query.describe(q)));
14299
+ const info = {
14300
+ table: table3,
14301
+ column: `${column3}`,
14302
+ sqlType: desc2.column_type,
14303
+ type: jsType(desc2.column_type),
14304
+ nullable: desc2.null === "YES"
14305
+ };
14306
+ if (!(stats?.length || stats?.size))
14307
+ return info;
14308
+ const result = await mc.query(
14309
+ summarize(table3, column3, stats),
14310
+ { persist: true }
14311
+ );
14312
+ for (let i = 0; i < result.numCols; ++i) {
14313
+ const { name: name2 } = result.schema.fields[i];
14314
+ const child = result.getChildAt(i);
14315
+ const convert = convertArrowValue(child.type);
14316
+ info[name2] = convert(child.get(0));
14317
+ }
14318
+ return info;
14319
+ }
14320
+ async function getTableInfo(mc, table3) {
14321
+ const result = await mc.query(`DESCRIBE ${asRelation(table3)}`);
14322
+ return Array.from(result).map((desc2) => ({
14323
+ table: table3,
14324
+ column: desc2.column_name,
14325
+ sqlType: desc2.column_type,
14326
+ type: jsType(desc2.column_type),
14327
+ nullable: desc2.null === "YES"
14328
+ }));
14329
+ }
14330
+
14245
14331
  // ../core/src/util/void-logger.js
14246
14332
  function voidLogger() {
14247
14333
  return {
@@ -14274,7 +14360,6 @@ var Coordinator = class {
14274
14360
  logger = console,
14275
14361
  manager = QueryManager()
14276
14362
  } = options;
14277
- this.catalog = new Catalog(this);
14278
14363
  this.manager = manager;
14279
14364
  this.logger(logger);
14280
14365
  this.configure(options);
@@ -14293,7 +14378,7 @@ var Coordinator = class {
14293
14378
  this.manager.consolidate(consolidate2);
14294
14379
  this.indexes = indexes2;
14295
14380
  }
14296
- clear({ clients = true, cache = true, catalog = false } = {}) {
14381
+ clear({ clients = true, cache = true } = {}) {
14297
14382
  this.manager.clear();
14298
14383
  if (clients) {
14299
14384
  this.clients?.forEach((client) => this.disconnect(client));
@@ -14303,8 +14388,6 @@ var Coordinator = class {
14303
14388
  }
14304
14389
  if (cache)
14305
14390
  this.manager.cache().clear();
14306
- if (catalog)
14307
- this.catalog.clear();
14308
14391
  }
14309
14392
  databaseConnector(db) {
14310
14393
  return this.manager.connector(db);
@@ -14357,7 +14440,7 @@ var Coordinator = class {
14357
14440
  * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
14358
14441
  */
14359
14442
  async connect(client) {
14360
- const { catalog, clients, filterGroups, indexes: indexes2 } = this;
14443
+ const { clients, filterGroups, indexes: indexes2 } = this;
14361
14444
  if (clients.has(client)) {
14362
14445
  throw new Error("Client already connected.");
14363
14446
  }
@@ -14365,7 +14448,7 @@ var Coordinator = class {
14365
14448
  client.coordinator = this;
14366
14449
  const fields = client.fields();
14367
14450
  if (fields?.length) {
14368
- client.fieldInfo(await catalog.queryFields(fields));
14451
+ client.fieldInfo(await queryFieldInfo(this, fields));
14369
14452
  }
14370
14453
  const filter3 = client.filterBy;
14371
14454
  if (filter3) {
@@ -22040,46 +22123,46 @@ function streamGeometry(geometry, stream) {
22040
22123
  }
22041
22124
  }
22042
22125
  var streamObjectType = {
22043
- Feature: function(object2, stream) {
22044
- streamGeometry(object2.geometry, stream);
22126
+ Feature: function(object, stream) {
22127
+ streamGeometry(object.geometry, stream);
22045
22128
  },
22046
- FeatureCollection: function(object2, stream) {
22047
- var features = object2.features, i = -1, n = features.length;
22129
+ FeatureCollection: function(object, stream) {
22130
+ var features = object.features, i = -1, n = features.length;
22048
22131
  while (++i < n)
22049
22132
  streamGeometry(features[i].geometry, stream);
22050
22133
  }
22051
22134
  };
22052
22135
  var streamGeometryType = {
22053
- Sphere: function(object2, stream) {
22136
+ Sphere: function(object, stream) {
22054
22137
  stream.sphere();
22055
22138
  },
22056
- Point: function(object2, stream) {
22057
- object2 = object2.coordinates;
22058
- stream.point(object2[0], object2[1], object2[2]);
22139
+ Point: function(object, stream) {
22140
+ object = object.coordinates;
22141
+ stream.point(object[0], object[1], object[2]);
22059
22142
  },
22060
- MultiPoint: function(object2, stream) {
22061
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
22143
+ MultiPoint: function(object, stream) {
22144
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
22062
22145
  while (++i < n)
22063
- object2 = coordinates[i], stream.point(object2[0], object2[1], object2[2]);
22146
+ object = coordinates[i], stream.point(object[0], object[1], object[2]);
22064
22147
  },
22065
- LineString: function(object2, stream) {
22066
- streamLine(object2.coordinates, stream, 0);
22148
+ LineString: function(object, stream) {
22149
+ streamLine(object.coordinates, stream, 0);
22067
22150
  },
22068
- MultiLineString: function(object2, stream) {
22069
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
22151
+ MultiLineString: function(object, stream) {
22152
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
22070
22153
  while (++i < n)
22071
22154
  streamLine(coordinates[i], stream, 0);
22072
22155
  },
22073
- Polygon: function(object2, stream) {
22074
- streamPolygon(object2.coordinates, stream);
22156
+ Polygon: function(object, stream) {
22157
+ streamPolygon(object.coordinates, stream);
22075
22158
  },
22076
- MultiPolygon: function(object2, stream) {
22077
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
22159
+ MultiPolygon: function(object, stream) {
22160
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
22078
22161
  while (++i < n)
22079
22162
  streamPolygon(coordinates[i], stream);
22080
22163
  },
22081
- GeometryCollection: function(object2, stream) {
22082
- var geometries = object2.geometries, i = -1, n = geometries.length;
22164
+ GeometryCollection: function(object, stream) {
22165
+ var geometries = object.geometries, i = -1, n = geometries.length;
22083
22166
  while (++i < n)
22084
22167
  streamGeometry(geometries[i], stream);
22085
22168
  }
@@ -22098,11 +22181,11 @@ function streamPolygon(coordinates, stream) {
22098
22181
  streamLine(coordinates[i], stream, 1);
22099
22182
  stream.polygonEnd();
22100
22183
  }
22101
- function stream_default(object2, stream) {
22102
- if (object2 && streamObjectType.hasOwnProperty(object2.type)) {
22103
- streamObjectType[object2.type](object2, stream);
22184
+ function stream_default(object, stream) {
22185
+ if (object && streamObjectType.hasOwnProperty(object.type)) {
22186
+ streamObjectType[object.type](object, stream);
22104
22187
  } else {
22105
- streamGeometry(object2, stream);
22188
+ streamGeometry(object, stream);
22106
22189
  }
22107
22190
  }
22108
22191
 
@@ -22226,12 +22309,12 @@ function centroidRingPoint(lambda, phi) {
22226
22309
  Z1 += w * (z0 + (z0 = z));
22227
22310
  centroidPointCartesian(x0, y0, z0);
22228
22311
  }
22229
- function centroid_default(object2) {
22312
+ function centroid_default(object) {
22230
22313
  W0 = W1 = X0 = Y0 = Z0 = X1 = Y1 = Z1 = 0;
22231
22314
  X2 = new Adder();
22232
22315
  Y2 = new Adder();
22233
22316
  Z2 = new Adder();
22234
- stream_default(object2, centroidStream);
22317
+ stream_default(object, centroidStream);
22235
22318
  var x3 = +X2, y3 = +Y2, z = +Z2, m = hypot(x3, y3, z);
22236
22319
  if (m < epsilon22) {
22237
22320
  x3 = X1, y3 = Y1, z = Z1;
@@ -23415,28 +23498,28 @@ function appendRound2(digits) {
23415
23498
  // ../../node_modules/d3-geo/src/path/index.js
23416
23499
  function path_default(projection3, context) {
23417
23500
  let digits = 3, pointRadius = 4.5, projectionStream, contextStream;
23418
- function path2(object2) {
23419
- if (object2) {
23501
+ function path2(object) {
23502
+ if (object) {
23420
23503
  if (typeof pointRadius === "function")
23421
23504
  contextStream.pointRadius(+pointRadius.apply(this, arguments));
23422
- stream_default(object2, projectionStream(contextStream));
23505
+ stream_default(object, projectionStream(contextStream));
23423
23506
  }
23424
23507
  return contextStream.result();
23425
23508
  }
23426
- path2.area = function(object2) {
23427
- stream_default(object2, projectionStream(area_default2));
23509
+ path2.area = function(object) {
23510
+ stream_default(object, projectionStream(area_default2));
23428
23511
  return area_default2.result();
23429
23512
  };
23430
- path2.measure = function(object2) {
23431
- stream_default(object2, projectionStream(measure_default));
23513
+ path2.measure = function(object) {
23514
+ stream_default(object, projectionStream(measure_default));
23432
23515
  return measure_default.result();
23433
23516
  };
23434
- path2.bounds = function(object2) {
23435
- stream_default(object2, projectionStream(bounds_default));
23517
+ path2.bounds = function(object) {
23518
+ stream_default(object, projectionStream(bounds_default));
23436
23519
  return bounds_default.result();
23437
23520
  };
23438
- path2.centroid = function(object2) {
23439
- stream_default(object2, projectionStream(centroid_default2));
23521
+ path2.centroid = function(object) {
23522
+ stream_default(object, projectionStream(centroid_default2));
23440
23523
  return centroid_default2.result();
23441
23524
  };
23442
23525
  path2.projection = function(_) {
@@ -23517,37 +23600,37 @@ TransformStream.prototype = {
23517
23600
  };
23518
23601
 
23519
23602
  // ../../node_modules/d3-geo/src/projection/fit.js
23520
- function fit(projection3, fitBounds, object2) {
23603
+ function fit(projection3, fitBounds, object) {
23521
23604
  var clip = projection3.clipExtent && projection3.clipExtent();
23522
23605
  projection3.scale(150).translate([0, 0]);
23523
23606
  if (clip != null)
23524
23607
  projection3.clipExtent(null);
23525
- stream_default(object2, projection3.stream(bounds_default));
23608
+ stream_default(object, projection3.stream(bounds_default));
23526
23609
  fitBounds(bounds_default.result());
23527
23610
  if (clip != null)
23528
23611
  projection3.clipExtent(clip);
23529
23612
  return projection3;
23530
23613
  }
23531
- function fitExtent(projection3, extent4, object2) {
23614
+ function fitExtent(projection3, extent4, object) {
23532
23615
  return fit(projection3, function(b) {
23533
23616
  var w = extent4[1][0] - extent4[0][0], h = extent4[1][1] - extent4[0][1], k2 = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x3 = +extent4[0][0] + (w - k2 * (b[1][0] + b[0][0])) / 2, y3 = +extent4[0][1] + (h - k2 * (b[1][1] + b[0][1])) / 2;
23534
23617
  projection3.scale(150 * k2).translate([x3, y3]);
23535
- }, object2);
23618
+ }, object);
23536
23619
  }
23537
- function fitSize(projection3, size, object2) {
23538
- return fitExtent(projection3, [[0, 0], size], object2);
23620
+ function fitSize(projection3, size, object) {
23621
+ return fitExtent(projection3, [[0, 0], size], object);
23539
23622
  }
23540
- function fitWidth(projection3, width2, object2) {
23623
+ function fitWidth(projection3, width2, object) {
23541
23624
  return fit(projection3, function(b) {
23542
23625
  var w = +width2, k2 = w / (b[1][0] - b[0][0]), x3 = (w - k2 * (b[1][0] + b[0][0])) / 2, y3 = -k2 * b[0][1];
23543
23626
  projection3.scale(150 * k2).translate([x3, y3]);
23544
- }, object2);
23627
+ }, object);
23545
23628
  }
23546
- function fitHeight(projection3, height2, object2) {
23629
+ function fitHeight(projection3, height2, object) {
23547
23630
  return fit(projection3, function(b) {
23548
23631
  var h = +height2, k2 = h / (b[1][1] - b[0][1]), x3 = -k2 * b[0][0], y3 = (h - k2 * (b[1][1] + b[0][1])) / 2;
23549
23632
  projection3.scale(150 * k2).translate([x3, y3]);
23550
- }, object2);
23633
+ }, object);
23551
23634
  }
23552
23635
 
23553
23636
  // ../../node_modules/d3-geo/src/projection/resample.js
@@ -23719,17 +23802,17 @@ function projectionMutator(projectAt) {
23719
23802
  projection3.precision = function(_) {
23720
23803
  return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
23721
23804
  };
23722
- projection3.fitExtent = function(extent4, object2) {
23723
- return fitExtent(projection3, extent4, object2);
23805
+ projection3.fitExtent = function(extent4, object) {
23806
+ return fitExtent(projection3, extent4, object);
23724
23807
  };
23725
- projection3.fitSize = function(size, object2) {
23726
- return fitSize(projection3, size, object2);
23808
+ projection3.fitSize = function(size, object) {
23809
+ return fitSize(projection3, size, object);
23727
23810
  };
23728
- projection3.fitWidth = function(width2, object2) {
23729
- return fitWidth(projection3, width2, object2);
23811
+ projection3.fitWidth = function(width2, object) {
23812
+ return fitWidth(projection3, width2, object);
23730
23813
  };
23731
- projection3.fitHeight = function(height2, object2) {
23732
- return fitHeight(projection3, height2, object2);
23814
+ projection3.fitHeight = function(height2, object) {
23815
+ return fitHeight(projection3, height2, object);
23733
23816
  };
23734
23817
  function recenter() {
23735
23818
  var center2 = scaleTranslateRotate(k2, 0, 0, sx, sy, alpha).apply(null, project2(lambda, phi)), transform3 = scaleTranslateRotate(k2, x3 - center2[0], y3 - center2[1], sx, sy, alpha);
@@ -23870,17 +23953,17 @@ function albersUsa_default() {
23870
23953
  hawaiiPoint = hawaii.translate([x3 - 0.205 * k2, y3 + 0.212 * k2]).clipExtent([[x3 - 0.214 * k2 + epsilon6, y3 + 0.166 * k2 + epsilon6], [x3 - 0.115 * k2 - epsilon6, y3 + 0.234 * k2 - epsilon6]]).stream(pointStream);
23871
23954
  return reset();
23872
23955
  };
23873
- albersUsa.fitExtent = function(extent4, object2) {
23874
- return fitExtent(albersUsa, extent4, object2);
23956
+ albersUsa.fitExtent = function(extent4, object) {
23957
+ return fitExtent(albersUsa, extent4, object);
23875
23958
  };
23876
- albersUsa.fitSize = function(size, object2) {
23877
- return fitSize(albersUsa, size, object2);
23959
+ albersUsa.fitSize = function(size, object) {
23960
+ return fitSize(albersUsa, size, object);
23878
23961
  };
23879
- albersUsa.fitWidth = function(width2, object2) {
23880
- return fitWidth(albersUsa, width2, object2);
23962
+ albersUsa.fitWidth = function(width2, object) {
23963
+ return fitWidth(albersUsa, width2, object);
23881
23964
  };
23882
- albersUsa.fitHeight = function(height2, object2) {
23883
- return fitHeight(albersUsa, height2, object2);
23965
+ albersUsa.fitHeight = function(height2, object) {
23966
+ return fitHeight(albersUsa, height2, object);
23884
23967
  };
23885
23968
  function reset() {
23886
23969
  cache = cacheStream = null;
@@ -26355,6 +26438,9 @@ var Accent_default = colors_default("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b176
26355
26438
  // ../../node_modules/d3-scale-chromatic/src/categorical/Dark2.js
26356
26439
  var Dark2_default = colors_default("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666");
26357
26440
 
26441
+ // ../../node_modules/d3-scale-chromatic/src/categorical/observable10.js
26442
+ var observable10_default = colors_default("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0");
26443
+
26358
26444
  // ../../node_modules/d3-scale-chromatic/src/categorical/Paired.js
26359
26445
  var Paired_default = colors_default("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");
26360
26446
 
@@ -28565,6 +28651,15 @@ function parse(string2, fallback) {
28565
28651
  return new Date(string2);
28566
28652
  }
28567
28653
 
28654
+ // ../../node_modules/@observablehq/plot/src/order.js
28655
+ function orderof(values2) {
28656
+ if (values2 == null)
28657
+ return;
28658
+ const first3 = values2[0];
28659
+ const last2 = values2[values2.length - 1];
28660
+ return descending(first3, last2);
28661
+ }
28662
+
28568
28663
  // ../../node_modules/@observablehq/plot/src/time.js
28569
28664
  var durationSecond2 = 1e3;
28570
28665
  var durationMinute2 = durationSecond2 * 60;
@@ -29158,13 +29253,6 @@ function maybeAnchor(value, name2) {
29158
29253
  function maybeFrameAnchor(value = "middle") {
29159
29254
  return maybeAnchor(value, "frameAnchor");
29160
29255
  }
29161
- function orderof(values2) {
29162
- if (values2 == null)
29163
- return;
29164
- const first3 = values2[0];
29165
- const last2 = values2[values2.length - 1];
29166
- return descending(first3, last2);
29167
- }
29168
29256
  function inherit2(options = {}, ...rest) {
29169
29257
  let o = options;
29170
29258
  for (const defaults23 of rest) {
@@ -29201,6 +29289,15 @@ function named2(things) {
29201
29289
  function maybeNamed(things) {
29202
29290
  return isIterable2(things) ? named2(things) : things;
29203
29291
  }
29292
+ function maybeClip(clip) {
29293
+ if (clip === true)
29294
+ clip = "frame";
29295
+ else if (clip === false)
29296
+ clip = null;
29297
+ else if (clip != null)
29298
+ clip = keyword(clip, "clip", ["frame", "sphere"]);
29299
+ return clip;
29300
+ }
29204
29301
 
29205
29302
  // ../../node_modules/@observablehq/plot/src/scales/index.js
29206
29303
  var position = Symbol("position");
@@ -29520,6 +29617,8 @@ function groupn(x3, y3, {
29520
29617
  extent4.x = x4;
29521
29618
  if (Y3)
29522
29619
  extent4.y = y4;
29620
+ if (G)
29621
+ extent4.z = f;
29523
29622
  if (filter3 && !filter3.reduce(g, extent4))
29524
29623
  continue;
29525
29624
  groupFacet.push(i++);
@@ -29618,10 +29717,7 @@ function maybeEvaluator(name2, reduce, inputs, asReduce = maybeReduce) {
29618
29717
  };
29619
29718
  }
29620
29719
  function maybeGroup(I, X3) {
29621
- return X3 ? sort(
29622
- group(I, (i) => X3[i]),
29623
- first2
29624
- ) : [[, I]];
29720
+ return X3 ? group(I, (i) => X3[i]) : [[, I]];
29625
29721
  }
29626
29722
  function maybeReduce(reduce, value, fallback = invalidReduce) {
29627
29723
  if (reduce == null)
@@ -29693,6 +29789,8 @@ function maybeGroupReduceFallback(reduce) {
29693
29789
  return reduceX;
29694
29790
  case "y":
29695
29791
  return reduceY;
29792
+ case "z":
29793
+ return reduceZ;
29696
29794
  }
29697
29795
  throw new Error(`invalid group reduce: ${reduce}`);
29698
29796
  }
@@ -29803,6 +29901,11 @@ var reduceY = {
29803
29901
  return y3;
29804
29902
  }
29805
29903
  };
29904
+ var reduceZ = {
29905
+ reduceIndex(I, X3, { z }) {
29906
+ return z;
29907
+ }
29908
+ };
29806
29909
  function find2(test) {
29807
29910
  if (typeof test !== "function")
29808
29911
  throw new Error(`invalid test function: ${test}`);
@@ -29979,48 +30082,14 @@ function getSource(channels, key) {
29979
30082
  return channel.source === null ? null : channel;
29980
30083
  }
29981
30084
 
29982
- // ../../node_modules/@observablehq/plot/src/memoize.js
29983
- function memoize1(compute) {
29984
- let cacheValue, cacheKeys;
29985
- return (...keys) => {
29986
- if (cacheKeys?.length !== keys.length || cacheKeys.some((k2, i) => k2 !== keys[i])) {
29987
- cacheKeys = keys;
29988
- cacheValue = compute(...keys);
29989
- }
29990
- return cacheValue;
29991
- };
29992
- }
29993
-
29994
- // ../../node_modules/@observablehq/plot/src/format.js
29995
- var numberFormat = memoize1((locale3) => {
29996
- return new Intl.NumberFormat(locale3);
29997
- });
29998
- var monthFormat = memoize1((locale3, month) => {
29999
- return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...month && { month } });
30000
- });
30001
- var weekdayFormat = memoize1((locale3, weekday) => {
30002
- return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...weekday && { weekday } });
30003
- });
30004
- function formatNumber(locale3 = "en-US") {
30005
- const format3 = numberFormat(locale3);
30006
- return (i) => i != null && !isNaN(i) ? format3.format(i) : void 0;
30007
- }
30008
- function formatMonth(locale3 = "en-US", format3 = "short") {
30009
- const fmt = monthFormat(locale3, format3);
30010
- return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? fmt.format(i) : void 0;
30011
- }
30012
- function formatWeekday(locale3 = "en-US", format3 = "short") {
30013
- const fmt = weekdayFormat(locale3, format3);
30014
- return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? fmt.format(i) : void 0;
30015
- }
30016
- function formatIsoDate(date2) {
30017
- return format2(date2, "Invalid Date");
30085
+ // ../../node_modules/@observablehq/plot/src/context.js
30086
+ function createContext(options = {}) {
30087
+ const { document: document2 = typeof window !== "undefined" ? window.document : void 0, clip } = options;
30088
+ return { document: document2, clip: maybeClip(clip) };
30018
30089
  }
30019
- function formatAuto(locale3 = "en-US") {
30020
- const number7 = formatNumber(locale3);
30021
- return (v2) => (v2 instanceof Date ? formatIsoDate : typeof v2 === "number" ? number7 : string)(v2);
30090
+ function create3(name2, { document: document2 }) {
30091
+ return select_default2(creator_default(name2).call(document2.documentElement));
30022
30092
  }
30023
- var formatDefault = formatAuto();
30024
30093
 
30025
30094
  // ../../node_modules/@observablehq/plot/src/warnings.js
30026
30095
  var warnings = 0;
@@ -30039,1787 +30108,1800 @@ function warn(message) {
30039
30108
  ++warnings;
30040
30109
  }
30041
30110
 
30042
- // ../../node_modules/@observablehq/plot/src/style.js
30043
- var offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5;
30044
- var nextClipId = 0;
30045
- function getClipId() {
30046
- return `plot-clip-${++nextClipId}`;
30047
- }
30048
- function styles(mark2, {
30049
- title,
30050
- href,
30051
- ariaLabel: variaLabel,
30052
- ariaDescription,
30053
- ariaHidden,
30054
- target,
30055
- fill,
30056
- fillOpacity,
30057
- stroke,
30058
- strokeWidth,
30059
- strokeOpacity,
30060
- strokeLinejoin,
30061
- strokeLinecap,
30062
- strokeMiterlimit,
30063
- strokeDasharray,
30064
- strokeDashoffset,
30065
- opacity: opacity2,
30066
- mixBlendMode,
30067
- imageFilter,
30068
- paintOrder,
30069
- pointerEvents,
30070
- shapeRendering,
30071
- channels
30072
- }, {
30073
- ariaLabel: cariaLabel,
30074
- fill: defaultFill = "currentColor",
30075
- fillOpacity: defaultFillOpacity,
30076
- stroke: defaultStroke = "none",
30077
- strokeOpacity: defaultStrokeOpacity,
30078
- strokeWidth: defaultStrokeWidth,
30079
- strokeLinecap: defaultStrokeLinecap,
30080
- strokeLinejoin: defaultStrokeLinejoin,
30081
- strokeMiterlimit: defaultStrokeMiterlimit,
30082
- paintOrder: defaultPaintOrder
30083
- }) {
30084
- if (defaultFill === null) {
30085
- fill = null;
30086
- fillOpacity = null;
30087
- }
30088
- if (defaultStroke === null) {
30089
- stroke = null;
30090
- strokeOpacity = null;
30091
- }
30092
- if (isNoneish(defaultFill)) {
30093
- if (!isNoneish(defaultStroke) && (!isNoneish(fill) || channels?.fill))
30094
- defaultStroke = "none";
30095
- } else {
30096
- if (isNoneish(defaultStroke) && (!isNoneish(stroke) || channels?.stroke))
30097
- defaultFill = "none";
30111
+ // ../../node_modules/@observablehq/plot/src/projection.js
30112
+ var pi4 = Math.PI;
30113
+ var tau5 = 2 * pi4;
30114
+ var defaultAspectRatio = 0.618;
30115
+ function createProjection({
30116
+ projection: projection3,
30117
+ inset: globalInset = 0,
30118
+ insetTop = globalInset,
30119
+ insetRight = globalInset,
30120
+ insetBottom = globalInset,
30121
+ insetLeft = globalInset
30122
+ } = {}, dimensions) {
30123
+ if (projection3 == null)
30124
+ return;
30125
+ if (typeof projection3.stream === "function")
30126
+ return projection3;
30127
+ let options;
30128
+ let domain;
30129
+ let clip = "frame";
30130
+ if (isObject2(projection3)) {
30131
+ let inset2;
30132
+ ({
30133
+ type: projection3,
30134
+ domain,
30135
+ inset: inset2,
30136
+ insetTop = inset2 !== void 0 ? inset2 : insetTop,
30137
+ insetRight = inset2 !== void 0 ? inset2 : insetRight,
30138
+ insetBottom = inset2 !== void 0 ? inset2 : insetBottom,
30139
+ insetLeft = inset2 !== void 0 ? inset2 : insetLeft,
30140
+ clip = clip,
30141
+ ...options
30142
+ } = projection3);
30143
+ if (projection3 == null)
30144
+ return;
30098
30145
  }
30099
- const [vfill, cfill] = maybeColorChannel(fill, defaultFill);
30100
- const [vfillOpacity, cfillOpacity] = maybeNumberChannel(fillOpacity, defaultFillOpacity);
30101
- const [vstroke, cstroke] = maybeColorChannel(stroke, defaultStroke);
30102
- const [vstrokeOpacity, cstrokeOpacity] = maybeNumberChannel(strokeOpacity, defaultStrokeOpacity);
30103
- const [vopacity, copacity] = maybeNumberChannel(opacity2);
30104
- if (!isNone(cstroke)) {
30105
- if (strokeWidth === void 0)
30106
- strokeWidth = defaultStrokeWidth;
30107
- if (strokeLinecap === void 0)
30108
- strokeLinecap = defaultStrokeLinecap;
30109
- if (strokeLinejoin === void 0)
30110
- strokeLinejoin = defaultStrokeLinejoin;
30111
- if (strokeMiterlimit === void 0 && !isRound(strokeLinejoin))
30112
- strokeMiterlimit = defaultStrokeMiterlimit;
30113
- if (!isNone(cfill) && paintOrder === void 0)
30114
- paintOrder = defaultPaintOrder;
30146
+ if (typeof projection3 !== "function")
30147
+ ({ type: projection3 } = namedProjection(projection3));
30148
+ const { width: width2, height: height2, marginLeft: marginLeft2, marginRight: marginRight2, marginTop: marginTop2, marginBottom: marginBottom2 } = dimensions;
30149
+ const dx = width2 - marginLeft2 - marginRight2 - insetLeft - insetRight;
30150
+ const dy = height2 - marginTop2 - marginBottom2 - insetTop - insetBottom;
30151
+ projection3 = projection3?.({ width: dx, height: dy, clip, ...options });
30152
+ if (projection3 == null)
30153
+ return;
30154
+ clip = maybePostClip(clip, marginLeft2, marginTop2, width2 - marginRight2, height2 - marginBottom2);
30155
+ let tx = marginLeft2 + insetLeft;
30156
+ let ty = marginTop2 + insetTop;
30157
+ let transform3;
30158
+ if (domain != null) {
30159
+ const [[x06, y06], [x12, y12]] = path_default(projection3).bounds(domain);
30160
+ const k2 = Math.min(dx / (x12 - x06), dy / (y12 - y06));
30161
+ if (k2 > 0) {
30162
+ tx -= (k2 * (x06 + x12) - dx) / 2;
30163
+ ty -= (k2 * (y06 + y12) - dy) / 2;
30164
+ transform3 = transform_default({
30165
+ point(x3, y3) {
30166
+ this.stream.point(x3 * k2 + tx, y3 * k2 + ty);
30167
+ }
30168
+ });
30169
+ } else {
30170
+ warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
30171
+ }
30115
30172
  }
30116
- const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);
30117
- if (defaultFill !== null) {
30118
- mark2.fill = impliedString(cfill, "currentColor");
30119
- mark2.fillOpacity = impliedNumber(cfillOpacity, 1);
30173
+ transform3 ??= tx === 0 && ty === 0 ? identity8() : transform_default({
30174
+ point(x3, y3) {
30175
+ this.stream.point(x3 + tx, y3 + ty);
30176
+ }
30177
+ });
30178
+ return { stream: (s2) => projection3.stream(transform3.stream(clip(s2))) };
30179
+ }
30180
+ function namedProjection(projection3) {
30181
+ switch (`${projection3}`.toLowerCase()) {
30182
+ case "albers-usa":
30183
+ return scaleProjection(albersUsa_default, 0.7463, 0.4673);
30184
+ case "albers":
30185
+ return conicProjection2(albers_default, 0.7463, 0.4673);
30186
+ case "azimuthal-equal-area":
30187
+ return scaleProjection(azimuthalEqualArea_default, 4, 4);
30188
+ case "azimuthal-equidistant":
30189
+ return scaleProjection(azimuthalEquidistant_default, tau5, tau5);
30190
+ case "conic-conformal":
30191
+ return conicProjection2(conicConformal_default, tau5, tau5);
30192
+ case "conic-equal-area":
30193
+ return conicProjection2(conicEqualArea_default, 6.1702, 2.9781);
30194
+ case "conic-equidistant":
30195
+ return conicProjection2(conicEquidistant_default, 7.312, 3.6282);
30196
+ case "equal-earth":
30197
+ return scaleProjection(equalEarth_default, 5.4133, 2.6347);
30198
+ case "equirectangular":
30199
+ return scaleProjection(equirectangular_default, tau5, pi4);
30200
+ case "gnomonic":
30201
+ return scaleProjection(gnomonic_default, 3.4641, 3.4641);
30202
+ case "identity":
30203
+ return { type: identity8 };
30204
+ case "reflect-y":
30205
+ return { type: reflectY };
30206
+ case "mercator":
30207
+ return scaleProjection(mercator_default, tau5, tau5);
30208
+ case "orthographic":
30209
+ return scaleProjection(orthographic_default, 2, 2);
30210
+ case "stereographic":
30211
+ return scaleProjection(stereographic_default, 2, 2);
30212
+ case "transverse-mercator":
30213
+ return scaleProjection(transverseMercator_default, tau5, tau5);
30214
+ default:
30215
+ throw new Error(`unknown projection type: ${projection3}`);
30120
30216
  }
30121
- if (defaultStroke !== null) {
30122
- mark2.stroke = impliedString(cstroke, "none");
30123
- mark2.strokeWidth = impliedNumber(cstrokeWidth, 1);
30124
- mark2.strokeOpacity = impliedNumber(cstrokeOpacity, 1);
30125
- mark2.strokeLinejoin = impliedString(strokeLinejoin, "miter");
30126
- mark2.strokeLinecap = impliedString(strokeLinecap, "butt");
30127
- mark2.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
30128
- mark2.strokeDasharray = impliedString(strokeDasharray, "none");
30129
- mark2.strokeDashoffset = impliedString(strokeDashoffset, "0");
30217
+ }
30218
+ function maybePostClip(clip, x12, y12, x22, y22) {
30219
+ if (clip === false || clip == null || typeof clip === "number")
30220
+ return (s2) => s2;
30221
+ if (clip === true)
30222
+ clip = "frame";
30223
+ switch (`${clip}`.toLowerCase()) {
30224
+ case "frame":
30225
+ return clipRectangle(x12, y12, x22, y22);
30226
+ default:
30227
+ throw new Error(`unknown projection clip type: ${clip}`);
30130
30228
  }
30131
- mark2.target = string(target);
30132
- mark2.ariaLabel = string(cariaLabel);
30133
- mark2.ariaDescription = string(ariaDescription);
30134
- mark2.ariaHidden = string(ariaHidden);
30135
- mark2.opacity = impliedNumber(copacity, 1);
30136
- mark2.mixBlendMode = impliedString(mixBlendMode, "normal");
30137
- mark2.imageFilter = impliedString(imageFilter, "none");
30138
- mark2.paintOrder = impliedString(paintOrder, "normal");
30139
- mark2.pointerEvents = impliedString(pointerEvents, "auto");
30140
- mark2.shapeRendering = impliedString(shapeRendering, "auto");
30141
- return {
30142
- title: { value: title, optional: true, filter: null },
30143
- href: { value: href, optional: true, filter: null },
30144
- ariaLabel: { value: variaLabel, optional: true, filter: null },
30145
- fill: { value: vfill, scale: "auto", optional: true },
30146
- fillOpacity: { value: vfillOpacity, scale: "auto", optional: true },
30147
- stroke: { value: vstroke, scale: "auto", optional: true },
30148
- strokeOpacity: { value: vstrokeOpacity, scale: "auto", optional: true },
30149
- strokeWidth: { value: vstrokeWidth, optional: true },
30150
- opacity: { value: vopacity, scale: "auto", optional: true }
30151
- };
30152
30229
  }
30153
- function applyTitle(selection2, L) {
30154
- if (L)
30155
- selection2.filter((i) => nonempty(L[i])).append("title").call(applyText, L);
30156
- }
30157
- function applyTitleGroup(selection2, L) {
30158
- if (L)
30159
- selection2.filter(([i]) => nonempty(L[i])).append("title").call(applyTextGroup, L);
30160
- }
30161
- function applyText(selection2, T) {
30162
- if (T)
30163
- selection2.text((i) => formatDefault(T[i]));
30164
- }
30165
- function applyTextGroup(selection2, T) {
30166
- if (T)
30167
- selection2.text(([i]) => formatDefault(T[i]));
30168
- }
30169
- function applyChannelStyles(selection2, { target, tip: tip2 }, {
30170
- ariaLabel: AL,
30171
- title: T,
30172
- fill: F,
30173
- fillOpacity: FO,
30174
- stroke: S,
30175
- strokeOpacity: SO,
30176
- strokeWidth: SW,
30177
- opacity: O,
30178
- href: H
30179
- }) {
30180
- if (AL)
30181
- applyAttr(selection2, "aria-label", (i) => AL[i]);
30182
- if (F)
30183
- applyAttr(selection2, "fill", (i) => F[i]);
30184
- if (FO)
30185
- applyAttr(selection2, "fill-opacity", (i) => FO[i]);
30186
- if (S)
30187
- applyAttr(selection2, "stroke", (i) => S[i]);
30188
- if (SO)
30189
- applyAttr(selection2, "stroke-opacity", (i) => SO[i]);
30190
- if (SW)
30191
- applyAttr(selection2, "stroke-width", (i) => SW[i]);
30192
- if (O)
30193
- applyAttr(selection2, "opacity", (i) => O[i]);
30194
- if (H)
30195
- applyHref(selection2, (i) => H[i], target);
30196
- if (!tip2)
30197
- applyTitle(selection2, T);
30198
- }
30199
- function applyGroupedChannelStyles(selection2, { target, tip: tip2 }, {
30200
- ariaLabel: AL,
30201
- title: T,
30202
- fill: F,
30203
- fillOpacity: FO,
30204
- stroke: S,
30205
- strokeOpacity: SO,
30206
- strokeWidth: SW,
30207
- opacity: O,
30208
- href: H
30209
- }) {
30210
- if (AL)
30211
- applyAttr(selection2, "aria-label", ([i]) => AL[i]);
30212
- if (F)
30213
- applyAttr(selection2, "fill", ([i]) => F[i]);
30214
- if (FO)
30215
- applyAttr(selection2, "fill-opacity", ([i]) => FO[i]);
30216
- if (S)
30217
- applyAttr(selection2, "stroke", ([i]) => S[i]);
30218
- if (SO)
30219
- applyAttr(selection2, "stroke-opacity", ([i]) => SO[i]);
30220
- if (SW)
30221
- applyAttr(selection2, "stroke-width", ([i]) => SW[i]);
30222
- if (O)
30223
- applyAttr(selection2, "opacity", ([i]) => O[i]);
30224
- if (H)
30225
- applyHref(selection2, ([i]) => H[i], target);
30226
- if (!tip2)
30227
- applyTitleGroup(selection2, T);
30228
- }
30229
- function groupAesthetics({
30230
- ariaLabel: AL,
30231
- title: T,
30232
- fill: F,
30233
- fillOpacity: FO,
30234
- stroke: S,
30235
- strokeOpacity: SO,
30236
- strokeWidth: SW,
30237
- opacity: O,
30238
- href: H
30239
- }, { tip: tip2 }) {
30240
- return [AL, tip2 ? void 0 : T, F, FO, S, SO, SW, O, H].filter((c4) => c4 !== void 0);
30241
- }
30242
- function groupZ2(I, Z, z) {
30243
- const G = group(I, (i) => Z[i]);
30244
- if (z === void 0 && G.size > 1 + I.length >> 1) {
30245
- warn(
30246
- `Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null.`
30247
- );
30248
- }
30249
- return G.values();
30230
+ function scaleProjection(createProjection2, kx2, ky2) {
30231
+ return {
30232
+ type: ({ width: width2, height: height2, rotate, precision = 0.15, clip }) => {
30233
+ const projection3 = createProjection2();
30234
+ if (precision != null)
30235
+ projection3.precision?.(precision);
30236
+ if (rotate != null)
30237
+ projection3.rotate?.(rotate);
30238
+ if (typeof clip === "number")
30239
+ projection3.clipAngle?.(clip);
30240
+ projection3.scale(Math.min(width2 / kx2, height2 / ky2));
30241
+ projection3.translate([width2 / 2, height2 / 2]);
30242
+ return projection3;
30243
+ },
30244
+ aspectRatio: ky2 / kx2
30245
+ };
30250
30246
  }
30251
- function* groupIndex(I, position3, mark2, channels) {
30252
- const { z } = mark2;
30253
- const { z: Z } = channels;
30254
- const A5 = groupAesthetics(channels, mark2);
30255
- const C3 = [...position3, ...A5];
30256
- for (const G of Z ? groupZ2(I, Z, z) : [I]) {
30257
- let Ag;
30258
- let Gg;
30259
- out:
30260
- for (const i of G) {
30261
- for (const c4 of C3) {
30262
- if (!defined(c4[i])) {
30263
- if (Gg)
30264
- Gg.push(-1);
30265
- continue out;
30266
- }
30267
- }
30268
- if (Ag === void 0) {
30269
- if (Gg)
30270
- yield Gg;
30271
- Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
30272
- continue;
30273
- }
30274
- Gg.push(i);
30275
- for (let j = 0; j < A5.length; ++j) {
30276
- const k2 = keyof2(A5[j][i]);
30277
- if (k2 !== Ag[j]) {
30278
- yield Gg;
30279
- Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
30280
- continue out;
30281
- }
30247
+ function conicProjection2(createProjection2, kx2, ky2) {
30248
+ const { type: type2, aspectRatio: aspectRatio2 } = scaleProjection(createProjection2, kx2, ky2);
30249
+ return {
30250
+ type: (options) => {
30251
+ const { parallels, domain, width: width2, height: height2 } = options;
30252
+ const projection3 = type2(options);
30253
+ if (parallels != null) {
30254
+ projection3.parallels(parallels);
30255
+ if (domain === void 0) {
30256
+ projection3.fitSize([width2, height2], { type: "Sphere" });
30282
30257
  }
30283
30258
  }
30284
- if (Gg)
30285
- yield Gg;
30286
- }
30287
- }
30288
- function maybeClip(clip) {
30289
- if (clip === true)
30290
- clip = "frame";
30291
- else if (clip === false)
30292
- clip = null;
30293
- else if (clip != null)
30294
- clip = keyword(clip, "clip", ["frame", "sphere"]);
30295
- return clip;
30259
+ return projection3;
30260
+ },
30261
+ aspectRatio: aspectRatio2
30262
+ };
30296
30263
  }
30297
- function applyClip(selection2, mark2, dimensions, context) {
30298
- let clipUrl;
30299
- const { clip = context.clip } = mark2;
30300
- switch (clip) {
30301
- case "frame": {
30302
- const { width: width2, height: height2, marginLeft: marginLeft2, marginRight: marginRight2, marginTop: marginTop2, marginBottom: marginBottom2 } = dimensions;
30303
- const id2 = getClipId();
30304
- clipUrl = `url(#${id2})`;
30305
- selection2 = create3("svg:g", context).call(
30306
- (g) => g.append("svg:clipPath").attr("id", id2).append("rect").attr("x", marginLeft2).attr("y", marginTop2).attr("width", width2 - marginRight2 - marginLeft2).attr("height", height2 - marginTop2 - marginBottom2)
30307
- ).each(function() {
30308
- this.appendChild(selection2.node());
30309
- selection2.node = () => this;
30310
- });
30311
- break;
30264
+ var identity8 = constant({ stream: (stream) => stream });
30265
+ var reflectY = constant(
30266
+ transform_default({
30267
+ point(x3, y3) {
30268
+ this.stream.point(x3, -y3);
30312
30269
  }
30313
- case "sphere": {
30314
- const { projection: projection3 } = context;
30315
- if (!projection3)
30316
- throw new Error(`the "sphere" clip option requires a projection`);
30317
- const id2 = getClipId();
30318
- clipUrl = `url(#${id2})`;
30319
- selection2.append("clipPath").attr("id", id2).append("path").attr("d", path_default(projection3)({ type: "Sphere" }));
30320
- break;
30270
+ })
30271
+ );
30272
+ function project(cx, cy, values2, projection3) {
30273
+ const x3 = values2[cx];
30274
+ const y3 = values2[cy];
30275
+ const n = x3.length;
30276
+ const X3 = values2[cx] = new Float64Array(n).fill(NaN);
30277
+ const Y3 = values2[cy] = new Float64Array(n).fill(NaN);
30278
+ let i;
30279
+ const stream = projection3.stream({
30280
+ point(x4, y4) {
30281
+ X3[i] = x4;
30282
+ Y3[i] = y4;
30321
30283
  }
30284
+ });
30285
+ for (i = 0; i < n; ++i) {
30286
+ stream.point(x3[i], y3[i]);
30322
30287
  }
30323
- applyAttr(selection2, "aria-label", mark2.ariaLabel);
30324
- applyAttr(selection2, "aria-description", mark2.ariaDescription);
30325
- applyAttr(selection2, "aria-hidden", mark2.ariaHidden);
30326
- applyAttr(selection2, "clip-path", clipUrl);
30327
30288
  }
30328
- function applyIndirectStyles(selection2, mark2, dimensions, context) {
30329
- applyClip(selection2, mark2, dimensions, context);
30330
- applyAttr(selection2, "fill", mark2.fill);
30331
- applyAttr(selection2, "fill-opacity", mark2.fillOpacity);
30332
- applyAttr(selection2, "stroke", mark2.stroke);
30333
- applyAttr(selection2, "stroke-width", mark2.strokeWidth);
30334
- applyAttr(selection2, "stroke-opacity", mark2.strokeOpacity);
30335
- applyAttr(selection2, "stroke-linejoin", mark2.strokeLinejoin);
30336
- applyAttr(selection2, "stroke-linecap", mark2.strokeLinecap);
30337
- applyAttr(selection2, "stroke-miterlimit", mark2.strokeMiterlimit);
30338
- applyAttr(selection2, "stroke-dasharray", mark2.strokeDasharray);
30339
- applyAttr(selection2, "stroke-dashoffset", mark2.strokeDashoffset);
30340
- applyAttr(selection2, "shape-rendering", mark2.shapeRendering);
30341
- applyAttr(selection2, "filter", mark2.imageFilter);
30342
- applyAttr(selection2, "paint-order", mark2.paintOrder);
30343
- const { pointerEvents = context.pointerSticky === false ? "none" : void 0 } = mark2;
30344
- applyAttr(selection2, "pointer-events", pointerEvents);
30289
+ function hasProjection({ projection: projection3 } = {}) {
30290
+ if (projection3 == null)
30291
+ return false;
30292
+ if (typeof projection3.stream === "function")
30293
+ return true;
30294
+ if (isObject2(projection3))
30295
+ projection3 = projection3.type;
30296
+ return projection3 != null;
30345
30297
  }
30346
- function applyDirectStyles(selection2, mark2) {
30347
- applyStyle(selection2, "mix-blend-mode", mark2.mixBlendMode);
30348
- applyAttr(selection2, "opacity", mark2.opacity);
30298
+ function projectionAspectRatio(projection3) {
30299
+ if (typeof projection3?.stream === "function")
30300
+ return defaultAspectRatio;
30301
+ if (isObject2(projection3))
30302
+ projection3 = projection3.type;
30303
+ if (projection3 == null)
30304
+ return;
30305
+ if (typeof projection3 !== "function") {
30306
+ const { aspectRatio: aspectRatio2 } = namedProjection(projection3);
30307
+ if (aspectRatio2)
30308
+ return aspectRatio2;
30309
+ }
30310
+ return defaultAspectRatio;
30349
30311
  }
30350
- function applyHref(selection2, href, target) {
30351
- selection2.each(function(i) {
30352
- const h = href(i);
30353
- if (h != null) {
30354
- const a2 = this.ownerDocument.createElementNS(namespaces_default.svg, "a");
30355
- a2.setAttribute("fill", "inherit");
30356
- a2.setAttributeNS(namespaces_default.xlink, "href", h);
30357
- if (target != null)
30358
- a2.setAttribute("target", target);
30359
- this.parentNode.insertBefore(a2, this).appendChild(this);
30360
- }
30361
- });
30362
- }
30363
- function applyAttr(selection2, name2, value) {
30364
- if (value != null)
30365
- selection2.attr(name2, value);
30312
+ function applyPosition(channels, scales2, { projection: projection3 }) {
30313
+ const { x: x3, y: y3 } = channels;
30314
+ let position3 = {};
30315
+ if (x3)
30316
+ position3.x = x3;
30317
+ if (y3)
30318
+ position3.y = y3;
30319
+ position3 = valueObject(position3, scales2);
30320
+ if (projection3 && x3?.scale === "x" && y3?.scale === "y")
30321
+ project("x", "y", position3, projection3);
30322
+ if (x3)
30323
+ position3.x = coerceNumbers(position3.x);
30324
+ if (y3)
30325
+ position3.y = coerceNumbers(position3.y);
30326
+ return position3;
30366
30327
  }
30367
- function applyStyle(selection2, name2, value) {
30368
- if (value != null)
30369
- selection2.style(name2, value);
30328
+ function getGeometryChannels(channel) {
30329
+ const X3 = [];
30330
+ const Y3 = [];
30331
+ const x3 = { scale: "x", value: X3 };
30332
+ const y3 = { scale: "y", value: Y3 };
30333
+ const sink = {
30334
+ point(x4, y4) {
30335
+ X3.push(x4);
30336
+ Y3.push(y4);
30337
+ },
30338
+ lineStart() {
30339
+ },
30340
+ lineEnd() {
30341
+ },
30342
+ polygonStart() {
30343
+ },
30344
+ polygonEnd() {
30345
+ },
30346
+ sphere() {
30347
+ }
30348
+ };
30349
+ for (const object of channel.value)
30350
+ stream_default(object, sink);
30351
+ return [x3, y3];
30370
30352
  }
30371
- function applyTransform(selection2, mark2, { x: x3, y: y3 }, tx = offset, ty = offset) {
30372
- tx += mark2.dx;
30373
- ty += mark2.dy;
30374
- if (x3?.bandwidth)
30375
- tx += x3.bandwidth() / 2;
30376
- if (y3?.bandwidth)
30377
- ty += y3.bandwidth() / 2;
30378
- if (tx || ty)
30379
- selection2.attr("transform", `translate(${tx},${ty})`);
30353
+
30354
+ // ../../node_modules/@observablehq/plot/src/scales/schemes.js
30355
+ var categoricalSchemes = /* @__PURE__ */ new Map([
30356
+ ["accent", Accent_default],
30357
+ ["category10", category10_default],
30358
+ ["dark2", Dark2_default],
30359
+ ["observable10", observable10_default],
30360
+ ["paired", Paired_default],
30361
+ ["pastel1", Pastel1_default],
30362
+ ["pastel2", Pastel2_default],
30363
+ ["set1", Set1_default],
30364
+ ["set2", Set2_default],
30365
+ ["set3", Set3_default],
30366
+ ["tableau10", Tableau10_default]
30367
+ ]);
30368
+ function isCategoricalScheme(scheme28) {
30369
+ return scheme28 != null && categoricalSchemes.has(`${scheme28}`.toLowerCase());
30380
30370
  }
30381
- function impliedString(value, impliedValue) {
30382
- if ((value = string(value)) !== impliedValue)
30383
- return value;
30371
+ var ordinalSchemes = new Map([
30372
+ ...categoricalSchemes,
30373
+ // diverging
30374
+ ["brbg", scheme112(scheme, BrBG_default)],
30375
+ ["prgn", scheme112(scheme2, PRGn_default)],
30376
+ ["piyg", scheme112(scheme3, PiYG_default)],
30377
+ ["puor", scheme112(scheme4, PuOr_default)],
30378
+ ["rdbu", scheme112(scheme5, RdBu_default)],
30379
+ ["rdgy", scheme112(scheme6, RdGy_default)],
30380
+ ["rdylbu", scheme112(scheme7, RdYlBu_default)],
30381
+ ["rdylgn", scheme112(scheme8, RdYlGn_default)],
30382
+ ["spectral", scheme112(scheme9, Spectral_default)],
30383
+ // reversed diverging (for temperature data)
30384
+ ["burd", scheme11r(scheme5, RdBu_default)],
30385
+ ["buylrd", scheme11r(scheme7, RdYlBu_default)],
30386
+ // sequential (single-hue)
30387
+ ["blues", scheme92(scheme22, Blues_default)],
30388
+ ["greens", scheme92(scheme23, Greens_default)],
30389
+ ["greys", scheme92(scheme24, Greys_default)],
30390
+ ["oranges", scheme92(scheme27, Oranges_default)],
30391
+ ["purples", scheme92(scheme25, Purples_default)],
30392
+ ["reds", scheme92(scheme26, Reds_default)],
30393
+ // sequential (multi-hue)
30394
+ ["turbo", schemei(turbo_default)],
30395
+ ["viridis", schemei(viridis_default)],
30396
+ ["magma", schemei(magma)],
30397
+ ["inferno", schemei(inferno)],
30398
+ ["plasma", schemei(plasma)],
30399
+ ["cividis", schemei(cividis_default)],
30400
+ ["cubehelix", schemei(cubehelix_default2)],
30401
+ ["warm", schemei(warm)],
30402
+ ["cool", schemei(cool)],
30403
+ ["bugn", scheme92(scheme10, BuGn_default)],
30404
+ ["bupu", scheme92(scheme11, BuPu_default)],
30405
+ ["gnbu", scheme92(scheme12, GnBu_default)],
30406
+ ["orrd", scheme92(scheme13, OrRd_default)],
30407
+ ["pubu", scheme92(scheme15, PuBu_default)],
30408
+ ["pubugn", scheme92(scheme14, PuBuGn_default)],
30409
+ ["purd", scheme92(scheme16, PuRd_default)],
30410
+ ["rdpu", scheme92(scheme17, RdPu_default)],
30411
+ ["ylgn", scheme92(scheme19, YlGn_default)],
30412
+ ["ylgnbu", scheme92(scheme18, YlGnBu_default)],
30413
+ ["ylorbr", scheme92(scheme20, YlOrBr_default)],
30414
+ ["ylorrd", scheme92(scheme21, YlOrRd_default)],
30415
+ // cyclical
30416
+ ["rainbow", schemeicyclical(rainbow_default)],
30417
+ ["sinebow", schemeicyclical(sinebow_default)]
30418
+ ]);
30419
+ function scheme92(scheme28, interpolate) {
30420
+ return ({ length: n }) => {
30421
+ if (n === 1)
30422
+ return [scheme28[3][1]];
30423
+ if (n === 2)
30424
+ return [scheme28[3][1], scheme28[3][2]];
30425
+ n = Math.max(3, Math.floor(n));
30426
+ return n > 9 ? quantize_default(interpolate, n) : scheme28[n];
30427
+ };
30384
30428
  }
30385
- function impliedNumber(value, impliedValue) {
30386
- if ((value = number5(value)) !== impliedValue)
30387
- return value;
30429
+ function scheme112(scheme28, interpolate) {
30430
+ return ({ length: n }) => {
30431
+ if (n === 2)
30432
+ return [scheme28[3][0], scheme28[3][2]];
30433
+ n = Math.max(3, Math.floor(n));
30434
+ return n > 11 ? quantize_default(interpolate, n) : scheme28[n];
30435
+ };
30388
30436
  }
30389
- var validClassName = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;
30390
- function maybeClassName(name2) {
30391
- if (name2 === void 0)
30392
- return "plot-d6a7b5";
30393
- name2 = `${name2}`;
30394
- if (!validClassName.test(name2))
30395
- throw new Error(`invalid class name: ${name2}`);
30396
- return name2;
30437
+ function scheme11r(scheme28, interpolate) {
30438
+ return ({ length: n }) => {
30439
+ if (n === 2)
30440
+ return [scheme28[3][2], scheme28[3][0]];
30441
+ n = Math.max(3, Math.floor(n));
30442
+ return n > 11 ? quantize_default((t) => interpolate(1 - t), n) : scheme28[n].slice().reverse();
30443
+ };
30397
30444
  }
30398
- function applyInlineStyles(selection2, style2) {
30399
- if (typeof style2 === "string") {
30400
- selection2.property("style", style2);
30401
- } else if (style2 != null) {
30402
- for (const element of selection2) {
30403
- Object.assign(element.style, style2);
30404
- }
30405
- }
30445
+ function schemei(interpolate) {
30446
+ return ({ length: n }) => quantize_default(interpolate, Math.max(2, Math.floor(n)));
30406
30447
  }
30407
- function applyFrameAnchor({ frameAnchor }, { width: width2, height: height2, marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2 }) {
30408
- return [
30409
- /left$/.test(frameAnchor) ? marginLeft2 : /right$/.test(frameAnchor) ? width2 - marginRight2 : (marginLeft2 + width2 - marginRight2) / 2,
30410
- /^top/.test(frameAnchor) ? marginTop2 : /^bottom/.test(frameAnchor) ? height2 - marginBottom2 : (marginTop2 + height2 - marginBottom2) / 2
30411
- ];
30448
+ function schemeicyclical(interpolate) {
30449
+ return ({ length: n }) => quantize_default(interpolate, Math.floor(n) + 1).slice(0, -1);
30412
30450
  }
30413
-
30414
- // ../../node_modules/@observablehq/plot/src/context.js
30415
- function createContext(options = {}) {
30416
- const { document: document2 = typeof window !== "undefined" ? window.document : void 0, clip } = options;
30417
- return { document: document2, clip: maybeClip(clip) };
30451
+ function ordinalScheme(scheme28) {
30452
+ const s2 = `${scheme28}`.toLowerCase();
30453
+ if (!ordinalSchemes.has(s2))
30454
+ throw new Error(`unknown ordinal scheme: ${s2}`);
30455
+ return ordinalSchemes.get(s2);
30418
30456
  }
30419
- function create3(name2, { document: document2 }) {
30420
- return select_default2(creator_default(name2).call(document2.documentElement));
30457
+ function ordinalRange(scheme28, length4) {
30458
+ const s2 = ordinalScheme(scheme28);
30459
+ const r = typeof s2 === "function" ? s2({ length: length4 }) : s2;
30460
+ return r.length !== length4 ? r.slice(0, length4) : r;
30421
30461
  }
30422
-
30423
- // ../../node_modules/@observablehq/plot/src/projection.js
30424
- var pi4 = Math.PI;
30425
- var tau5 = 2 * pi4;
30426
- var defaultAspectRatio = 0.618;
30427
- function createProjection({
30428
- projection: projection3,
30429
- inset: globalInset = 0,
30430
- insetTop = globalInset,
30431
- insetRight = globalInset,
30432
- insetBottom = globalInset,
30433
- insetLeft = globalInset
30434
- } = {}, dimensions) {
30435
- if (projection3 == null)
30436
- return;
30437
- if (typeof projection3.stream === "function")
30438
- return projection3;
30439
- let options;
30440
- let domain;
30441
- let clip = "frame";
30442
- if (isObject2(projection3)) {
30443
- let inset2;
30444
- ({
30445
- type: projection3,
30446
- domain,
30447
- inset: inset2,
30448
- insetTop = inset2 !== void 0 ? inset2 : insetTop,
30449
- insetRight = inset2 !== void 0 ? inset2 : insetRight,
30450
- insetBottom = inset2 !== void 0 ? inset2 : insetBottom,
30451
- insetLeft = inset2 !== void 0 ? inset2 : insetLeft,
30452
- clip = clip,
30453
- ...options
30454
- } = projection3);
30455
- if (projection3 == null)
30462
+ function maybeBooleanRange(domain, scheme28 = "greys") {
30463
+ const range3 = /* @__PURE__ */ new Set();
30464
+ const [f, t] = ordinalRange(scheme28, 2);
30465
+ for (const value of domain) {
30466
+ if (value == null)
30467
+ continue;
30468
+ if (value === true)
30469
+ range3.add(t);
30470
+ else if (value === false)
30471
+ range3.add(f);
30472
+ else
30456
30473
  return;
30457
30474
  }
30458
- if (typeof projection3 !== "function")
30459
- ({ type: projection3 } = namedProjection(projection3));
30460
- const { width: width2, height: height2, marginLeft: marginLeft2, marginRight: marginRight2, marginTop: marginTop2, marginBottom: marginBottom2 } = dimensions;
30461
- const dx = width2 - marginLeft2 - marginRight2 - insetLeft - insetRight;
30462
- const dy = height2 - marginTop2 - marginBottom2 - insetTop - insetBottom;
30463
- projection3 = projection3?.({ width: dx, height: dy, clip, ...options });
30464
- if (projection3 == null)
30465
- return;
30466
- clip = maybePostClip(clip, marginLeft2, marginTop2, width2 - marginRight2, height2 - marginBottom2);
30467
- let tx = marginLeft2 + insetLeft;
30468
- let ty = marginTop2 + insetTop;
30469
- let transform3;
30470
- if (domain != null) {
30471
- const [[x06, y06], [x12, y12]] = path_default(projection3).bounds(domain);
30472
- const k2 = Math.min(dx / (x12 - x06), dy / (y12 - y06));
30473
- if (k2 > 0) {
30474
- tx -= (k2 * (x06 + x12) - dx) / 2;
30475
- ty -= (k2 * (y06 + y12) - dy) / 2;
30476
- transform3 = transform_default({
30477
- point(x3, y3) {
30478
- this.stream.point(x3 * k2 + tx, y3 * k2 + ty);
30479
- }
30480
- });
30481
- } else {
30482
- warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
30475
+ return [...range3];
30476
+ }
30477
+ var quantitativeSchemes = /* @__PURE__ */ new Map([
30478
+ // diverging
30479
+ ["brbg", BrBG_default],
30480
+ ["prgn", PRGn_default],
30481
+ ["piyg", PiYG_default],
30482
+ ["puor", PuOr_default],
30483
+ ["rdbu", RdBu_default],
30484
+ ["rdgy", RdGy_default],
30485
+ ["rdylbu", RdYlBu_default],
30486
+ ["rdylgn", RdYlGn_default],
30487
+ ["spectral", Spectral_default],
30488
+ // reversed diverging (for temperature data)
30489
+ ["burd", (t) => RdBu_default(1 - t)],
30490
+ ["buylrd", (t) => RdYlBu_default(1 - t)],
30491
+ // sequential (single-hue)
30492
+ ["blues", Blues_default],
30493
+ ["greens", Greens_default],
30494
+ ["greys", Greys_default],
30495
+ ["purples", Purples_default],
30496
+ ["reds", Reds_default],
30497
+ ["oranges", Oranges_default],
30498
+ // sequential (multi-hue)
30499
+ ["turbo", turbo_default],
30500
+ ["viridis", viridis_default],
30501
+ ["magma", magma],
30502
+ ["inferno", inferno],
30503
+ ["plasma", plasma],
30504
+ ["cividis", cividis_default],
30505
+ ["cubehelix", cubehelix_default2],
30506
+ ["warm", warm],
30507
+ ["cool", cool],
30508
+ ["bugn", BuGn_default],
30509
+ ["bupu", BuPu_default],
30510
+ ["gnbu", GnBu_default],
30511
+ ["orrd", OrRd_default],
30512
+ ["pubugn", PuBuGn_default],
30513
+ ["pubu", PuBu_default],
30514
+ ["purd", PuRd_default],
30515
+ ["rdpu", RdPu_default],
30516
+ ["ylgnbu", YlGnBu_default],
30517
+ ["ylgn", YlGn_default],
30518
+ ["ylorbr", YlOrBr_default],
30519
+ ["ylorrd", YlOrRd_default],
30520
+ // cyclical
30521
+ ["rainbow", rainbow_default],
30522
+ ["sinebow", sinebow_default]
30523
+ ]);
30524
+ function quantitativeScheme(scheme28) {
30525
+ const s2 = `${scheme28}`.toLowerCase();
30526
+ if (!quantitativeSchemes.has(s2))
30527
+ throw new Error(`unknown quantitative scheme: ${s2}`);
30528
+ return quantitativeSchemes.get(s2);
30529
+ }
30530
+ var divergingSchemes = /* @__PURE__ */ new Set([
30531
+ "brbg",
30532
+ "prgn",
30533
+ "piyg",
30534
+ "puor",
30535
+ "rdbu",
30536
+ "rdgy",
30537
+ "rdylbu",
30538
+ "rdylgn",
30539
+ "spectral",
30540
+ "burd",
30541
+ "buylrd"
30542
+ ]);
30543
+ function isDivergingScheme(scheme28) {
30544
+ return scheme28 != null && divergingSchemes.has(`${scheme28}`.toLowerCase());
30545
+ }
30546
+
30547
+ // ../../node_modules/@observablehq/plot/src/scales/quantitative.js
30548
+ var flip = (i) => (t) => i(1 - t);
30549
+ var unit2 = [0, 1];
30550
+ var interpolators = /* @__PURE__ */ new Map([
30551
+ // numbers
30552
+ ["number", number_default],
30553
+ // color spaces
30554
+ ["rgb", rgb_default],
30555
+ ["hsl", hsl_default],
30556
+ ["hcl", hcl_default],
30557
+ ["lab", lab2]
30558
+ ]);
30559
+ function maybeInterpolator(interpolate) {
30560
+ const i = `${interpolate}`.toLowerCase();
30561
+ if (!interpolators.has(i))
30562
+ throw new Error(`unknown interpolator: ${i}`);
30563
+ return interpolators.get(i);
30564
+ }
30565
+ function createScaleQ(key, scale3, channels, {
30566
+ type: type2,
30567
+ nice: nice3,
30568
+ clamp,
30569
+ zero: zero3,
30570
+ domain = inferAutoDomain(key, channels),
30571
+ unknown,
30572
+ round: round3,
30573
+ scheme: scheme28,
30574
+ interval: interval2,
30575
+ range: range3 = registry.get(key) === radius ? inferRadialRange(channels, domain) : registry.get(key) === length3 ? inferLengthRange(channels, domain) : registry.get(key) === opacity ? unit2 : void 0,
30576
+ interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : type2 === "cyclical" ? "rainbow" : "turbo") : round3 ? round_default : number_default,
30577
+ reverse: reverse3
30578
+ }) {
30579
+ interval2 = maybeRangeInterval(interval2, type2);
30580
+ if (type2 === "cyclical" || type2 === "sequential")
30581
+ type2 = "linear";
30582
+ if (typeof interpolate !== "function")
30583
+ interpolate = maybeInterpolator(interpolate);
30584
+ reverse3 = !!reverse3;
30585
+ if (range3 !== void 0) {
30586
+ const n = (domain = arrayify2(domain)).length;
30587
+ const m = (range3 = arrayify2(range3)).length;
30588
+ if (n !== m) {
30589
+ if (interpolate.length === 1)
30590
+ throw new Error("invalid piecewise interpolator");
30591
+ interpolate = piecewise(interpolate, range3);
30592
+ range3 = void 0;
30483
30593
  }
30484
30594
  }
30485
- transform3 ??= tx === 0 && ty === 0 ? identity8() : transform_default({
30486
- point(x3, y3) {
30487
- this.stream.point(x3 + tx, y3 + ty);
30595
+ if (interpolate.length === 1) {
30596
+ if (reverse3) {
30597
+ interpolate = flip(interpolate);
30598
+ reverse3 = false;
30488
30599
  }
30489
- });
30490
- return { stream: (s2) => projection3.stream(transform3.stream(clip(s2))) };
30491
- }
30492
- function namedProjection(projection3) {
30493
- switch (`${projection3}`.toLowerCase()) {
30494
- case "albers-usa":
30495
- return scaleProjection(albersUsa_default, 0.7463, 0.4673);
30496
- case "albers":
30497
- return conicProjection2(albers_default, 0.7463, 0.4673);
30498
- case "azimuthal-equal-area":
30499
- return scaleProjection(azimuthalEqualArea_default, 4, 4);
30500
- case "azimuthal-equidistant":
30501
- return scaleProjection(azimuthalEquidistant_default, tau5, tau5);
30502
- case "conic-conformal":
30503
- return conicProjection2(conicConformal_default, tau5, tau5);
30504
- case "conic-equal-area":
30505
- return conicProjection2(conicEqualArea_default, 6.1702, 2.9781);
30506
- case "conic-equidistant":
30507
- return conicProjection2(conicEquidistant_default, 7.312, 3.6282);
30508
- case "equal-earth":
30509
- return scaleProjection(equalEarth_default, 5.4133, 2.6347);
30510
- case "equirectangular":
30511
- return scaleProjection(equirectangular_default, tau5, pi4);
30512
- case "gnomonic":
30513
- return scaleProjection(gnomonic_default, 3.4641, 3.4641);
30514
- case "identity":
30515
- return { type: identity8 };
30516
- case "reflect-y":
30517
- return { type: reflectY };
30518
- case "mercator":
30519
- return scaleProjection(mercator_default, tau5, tau5);
30520
- case "orthographic":
30521
- return scaleProjection(orthographic_default, 2, 2);
30522
- case "stereographic":
30523
- return scaleProjection(stereographic_default, 2, 2);
30524
- case "transverse-mercator":
30525
- return scaleProjection(transverseMercator_default, tau5, tau5);
30526
- default:
30527
- throw new Error(`unknown projection type: ${projection3}`);
30600
+ if (range3 === void 0) {
30601
+ range3 = Float64Array.from(domain, (_, i) => i / (domain.length - 1));
30602
+ if (range3.length === 2)
30603
+ range3 = unit2;
30604
+ }
30605
+ scale3.interpolate((range3 === unit2 ? constant : interpolatePiecewise)(interpolate));
30606
+ } else {
30607
+ scale3.interpolate(interpolate);
30528
30608
  }
30529
- }
30530
- function maybePostClip(clip, x12, y12, x22, y22) {
30531
- if (clip === false || clip == null || typeof clip === "number")
30532
- return (s2) => s2;
30533
- if (clip === true)
30534
- clip = "frame";
30535
- switch (`${clip}`.toLowerCase()) {
30536
- case "frame":
30537
- return clipRectangle(x12, y12, x22, y22);
30538
- default:
30539
- throw new Error(`unknown projection clip type: ${clip}`);
30609
+ if (zero3) {
30610
+ const [min5, max4] = extent(domain);
30611
+ if (min5 > 0 || max4 < 0) {
30612
+ domain = slice3(domain);
30613
+ if (orderof(domain) !== Math.sign(min5))
30614
+ domain[domain.length - 1] = 0;
30615
+ else
30616
+ domain[0] = 0;
30617
+ }
30540
30618
  }
30619
+ if (reverse3)
30620
+ domain = reverse(domain);
30621
+ scale3.domain(domain).unknown(unknown);
30622
+ if (nice3)
30623
+ scale3.nice(maybeNice(nice3, type2)), domain = scale3.domain();
30624
+ if (range3 !== void 0)
30625
+ scale3.range(range3);
30626
+ if (clamp)
30627
+ scale3.clamp(clamp);
30628
+ return { type: type2, domain, range: range3, scale: scale3, interpolate, interval: interval2 };
30541
30629
  }
30542
- function scaleProjection(createProjection2, kx2, ky2) {
30543
- return {
30544
- type: ({ width: width2, height: height2, rotate, precision = 0.15, clip }) => {
30545
- const projection3 = createProjection2();
30546
- if (precision != null)
30547
- projection3.precision?.(precision);
30548
- if (rotate != null)
30549
- projection3.rotate?.(rotate);
30550
- if (typeof clip === "number")
30551
- projection3.clipAngle?.(clip);
30552
- projection3.scale(Math.min(width2 / kx2, height2 / ky2));
30553
- projection3.translate([width2 / 2, height2 / 2]);
30554
- return projection3;
30555
- },
30556
- aspectRatio: ky2 / kx2
30557
- };
30630
+ function maybeNice(nice3, type2) {
30631
+ return nice3 === true ? void 0 : typeof nice3 === "number" ? nice3 : maybeNiceInterval(nice3, type2);
30558
30632
  }
30559
- function conicProjection2(createProjection2, kx2, ky2) {
30560
- const { type: type2, aspectRatio: aspectRatio2 } = scaleProjection(createProjection2, kx2, ky2);
30561
- return {
30562
- type: (options) => {
30563
- const { parallels, domain, width: width2, height: height2 } = options;
30564
- const projection3 = type2(options);
30565
- if (parallels != null) {
30566
- projection3.parallels(parallels);
30567
- if (domain === void 0) {
30568
- projection3.fitSize([width2, height2], { type: "Sphere" });
30569
- }
30570
- }
30571
- return projection3;
30572
- },
30573
- aspectRatio: aspectRatio2
30574
- };
30633
+ function createScaleLinear(key, channels, options) {
30634
+ return createScaleQ(key, linear2(), channels, options);
30575
30635
  }
30576
- var identity8 = constant({ stream: (stream) => stream });
30577
- var reflectY = constant(
30578
- transform_default({
30579
- point(x3, y3) {
30580
- this.stream.point(x3, -y3);
30581
- }
30582
- })
30583
- );
30584
- function project(cx, cy, values2, projection3) {
30585
- const x3 = values2[cx];
30586
- const y3 = values2[cy];
30587
- const n = x3.length;
30588
- const X3 = values2[cx] = new Float64Array(n).fill(NaN);
30589
- const Y3 = values2[cy] = new Float64Array(n).fill(NaN);
30590
- let i;
30591
- const stream = projection3.stream({
30592
- point(x4, y4) {
30593
- X3[i] = x4;
30594
- Y3[i] = y4;
30595
- }
30596
- });
30597
- for (i = 0; i < n; ++i) {
30598
- stream.point(x3[i], y3[i]);
30599
- }
30636
+ function createScaleSqrt(key, channels, options) {
30637
+ return createScalePow(key, channels, { ...options, exponent: 0.5 });
30600
30638
  }
30601
- function hasProjection({ projection: projection3 } = {}) {
30602
- if (projection3 == null)
30603
- return false;
30604
- if (typeof projection3.stream === "function")
30605
- return true;
30606
- if (isObject2(projection3))
30607
- projection3 = projection3.type;
30608
- return projection3 != null;
30639
+ function createScalePow(key, channels, { exponent = 1, ...options }) {
30640
+ return createScaleQ(key, pow3().exponent(exponent), channels, { ...options, type: "pow" });
30609
30641
  }
30610
- function projectionAspectRatio(projection3) {
30611
- if (typeof projection3?.stream === "function")
30612
- return defaultAspectRatio;
30613
- if (isObject2(projection3))
30614
- projection3 = projection3.type;
30615
- if (projection3 == null)
30616
- return;
30617
- if (typeof projection3 !== "function") {
30618
- const { aspectRatio: aspectRatio2 } = namedProjection(projection3);
30619
- if (aspectRatio2)
30620
- return aspectRatio2;
30642
+ function createScaleLog(key, channels, { base = 10, domain = inferLogDomain(channels), ...options }) {
30643
+ return createScaleQ(key, log2().base(base), channels, { ...options, domain });
30644
+ }
30645
+ function createScaleSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30646
+ return createScaleQ(key, symlog().constant(constant2), channels, options);
30647
+ }
30648
+ function createScaleQuantile(key, channels, {
30649
+ range: range3,
30650
+ quantiles = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30651
+ // deprecated; use n instead
30652
+ n = quantiles,
30653
+ scheme: scheme28 = "rdylbu",
30654
+ domain = inferQuantileDomain(channels),
30655
+ unknown,
30656
+ interpolate,
30657
+ reverse: reverse3
30658
+ }) {
30659
+ if (range3 === void 0) {
30660
+ range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30621
30661
  }
30622
- return defaultAspectRatio;
30662
+ if (domain.length > 0) {
30663
+ domain = quantile3(domain, range3 === void 0 ? { length: n } : range3).quantiles();
30664
+ }
30665
+ return createScaleThreshold(key, channels, { domain, range: range3, reverse: reverse3, unknown });
30623
30666
  }
30624
- function applyPosition(channels, scales2, { projection: projection3 }) {
30625
- const { x: x3, y: y3 } = channels;
30626
- let position3 = {};
30627
- if (x3)
30628
- position3.x = x3;
30629
- if (y3)
30630
- position3.y = y3;
30631
- position3 = valueObject(position3, scales2);
30632
- if (projection3 && x3?.scale === "x" && y3?.scale === "y")
30633
- project("x", "y", position3, projection3);
30634
- if (x3)
30635
- position3.x = coerceNumbers(position3.x);
30636
- if (y3)
30637
- position3.y = coerceNumbers(position3.y);
30638
- return position3;
30667
+ function createScaleQuantize(key, channels, {
30668
+ range: range3,
30669
+ n = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30670
+ scheme: scheme28 = "rdylbu",
30671
+ domain = inferAutoDomain(key, channels),
30672
+ unknown,
30673
+ interpolate,
30674
+ reverse: reverse3
30675
+ }) {
30676
+ const [min5, max4] = extent(domain);
30677
+ let thresholds;
30678
+ if (range3 === void 0) {
30679
+ thresholds = ticks(min5, max4, n);
30680
+ if (thresholds[0] <= min5)
30681
+ thresholds.splice(0, 1);
30682
+ if (thresholds[thresholds.length - 1] >= max4)
30683
+ thresholds.pop();
30684
+ n = thresholds.length + 1;
30685
+ range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30686
+ } else {
30687
+ thresholds = quantize_default(number_default(min5, max4), n + 1).slice(1, -1);
30688
+ if (min5 instanceof Date)
30689
+ thresholds = thresholds.map((x3) => new Date(x3));
30690
+ }
30691
+ if (orderof(arrayify2(domain)) < 0)
30692
+ thresholds.reverse();
30693
+ return createScaleThreshold(key, channels, { domain: thresholds, range: range3, reverse: reverse3, unknown });
30639
30694
  }
30640
- function getGeometryChannels(channel) {
30641
- const X3 = [];
30642
- const Y3 = [];
30643
- const x3 = { scale: "x", value: X3 };
30644
- const y3 = { scale: "y", value: Y3 };
30645
- const sink = {
30646
- point(x4, y4) {
30647
- X3.push(x4);
30648
- Y3.push(y4);
30649
- },
30650
- lineStart() {
30651
- },
30652
- lineEnd() {
30653
- },
30654
- polygonStart() {
30655
- },
30656
- polygonEnd() {
30657
- },
30658
- sphere() {
30659
- }
30695
+ function createScaleThreshold(key, channels, {
30696
+ domain = [0],
30697
+ // explicit thresholds in ascending order
30698
+ unknown,
30699
+ scheme: scheme28 = "rdylbu",
30700
+ interpolate,
30701
+ range: range3 = interpolate !== void 0 ? quantize_default(interpolate, domain.length + 1) : registry.get(key) === color2 ? ordinalRange(scheme28, domain.length + 1) : void 0,
30702
+ reverse: reverse3
30703
+ }) {
30704
+ domain = arrayify2(domain);
30705
+ const sign3 = orderof(domain);
30706
+ if (!isNaN(sign3) && !isOrdered(domain, sign3))
30707
+ throw new Error(`the ${key} scale has a non-monotonic domain`);
30708
+ if (reverse3)
30709
+ range3 = reverse(range3);
30710
+ return {
30711
+ type: "threshold",
30712
+ scale: threshold(sign3 < 0 ? reverse(domain) : domain, range3 === void 0 ? [] : range3).unknown(unknown),
30713
+ domain,
30714
+ range: range3
30660
30715
  };
30661
- for (const object2 of channel.value)
30662
- stream_default(object2, sink);
30663
- return [x3, y3];
30664
30716
  }
30665
-
30666
- // ../../node_modules/@observablehq/plot/src/scales/schemes.js
30667
- var schemeObservable10 = [
30668
- "#4269d0",
30669
- "#efb118",
30670
- "#ff725c",
30671
- "#6cc5b0",
30672
- "#3ca951",
30673
- "#ff8ab7",
30674
- "#a463f2",
30675
- "#97bbf5",
30676
- "#9c6b4e",
30677
- "#9498a0"
30678
- ];
30679
- var categoricalSchemes = /* @__PURE__ */ new Map([
30680
- ["accent", Accent_default],
30681
- ["category10", category10_default],
30682
- ["dark2", Dark2_default],
30683
- ["observable10", schemeObservable10],
30684
- ["paired", Paired_default],
30685
- ["pastel1", Pastel1_default],
30686
- ["pastel2", Pastel2_default],
30687
- ["set1", Set1_default],
30688
- ["set2", Set2_default],
30689
- ["set3", Set3_default],
30690
- ["tableau10", Tableau10_default]
30691
- ]);
30692
- function isCategoricalScheme(scheme28) {
30693
- return scheme28 != null && categoricalSchemes.has(`${scheme28}`.toLowerCase());
30717
+ function isOrdered(domain, sign3) {
30718
+ for (let i = 1, n = domain.length, d = domain[0]; i < n; ++i) {
30719
+ const s2 = descending(d, d = domain[i]);
30720
+ if (s2 !== 0 && s2 !== sign3)
30721
+ return false;
30722
+ }
30723
+ return true;
30694
30724
  }
30695
- var ordinalSchemes = new Map([
30696
- ...categoricalSchemes,
30697
- // diverging
30698
- ["brbg", scheme112(scheme, BrBG_default)],
30699
- ["prgn", scheme112(scheme2, PRGn_default)],
30700
- ["piyg", scheme112(scheme3, PiYG_default)],
30701
- ["puor", scheme112(scheme4, PuOr_default)],
30702
- ["rdbu", scheme112(scheme5, RdBu_default)],
30703
- ["rdgy", scheme112(scheme6, RdGy_default)],
30704
- ["rdylbu", scheme112(scheme7, RdYlBu_default)],
30705
- ["rdylgn", scheme112(scheme8, RdYlGn_default)],
30706
- ["spectral", scheme112(scheme9, Spectral_default)],
30707
- // reversed diverging (for temperature data)
30708
- ["burd", scheme11r(scheme5, RdBu_default)],
30709
- ["buylrd", scheme11r(scheme7, RdYlBu_default)],
30710
- // sequential (single-hue)
30711
- ["blues", scheme92(scheme22, Blues_default)],
30712
- ["greens", scheme92(scheme23, Greens_default)],
30713
- ["greys", scheme92(scheme24, Greys_default)],
30714
- ["oranges", scheme92(scheme27, Oranges_default)],
30715
- ["purples", scheme92(scheme25, Purples_default)],
30716
- ["reds", scheme92(scheme26, Reds_default)],
30717
- // sequential (multi-hue)
30718
- ["turbo", schemei(turbo_default)],
30719
- ["viridis", schemei(viridis_default)],
30720
- ["magma", schemei(magma)],
30721
- ["inferno", schemei(inferno)],
30722
- ["plasma", schemei(plasma)],
30723
- ["cividis", schemei(cividis_default)],
30724
- ["cubehelix", schemei(cubehelix_default2)],
30725
- ["warm", schemei(warm)],
30726
- ["cool", schemei(cool)],
30727
- ["bugn", scheme92(scheme10, BuGn_default)],
30728
- ["bupu", scheme92(scheme11, BuPu_default)],
30729
- ["gnbu", scheme92(scheme12, GnBu_default)],
30730
- ["orrd", scheme92(scheme13, OrRd_default)],
30731
- ["pubu", scheme92(scheme15, PuBu_default)],
30732
- ["pubugn", scheme92(scheme14, PuBuGn_default)],
30733
- ["purd", scheme92(scheme16, PuRd_default)],
30734
- ["rdpu", scheme92(scheme17, RdPu_default)],
30735
- ["ylgn", scheme92(scheme19, YlGn_default)],
30736
- ["ylgnbu", scheme92(scheme18, YlGnBu_default)],
30737
- ["ylorbr", scheme92(scheme20, YlOrBr_default)],
30738
- ["ylorrd", scheme92(scheme21, YlOrRd_default)],
30739
- // cyclical
30740
- ["rainbow", schemeicyclical(rainbow_default)],
30741
- ["sinebow", schemeicyclical(sinebow_default)]
30742
- ]);
30743
- function scheme92(scheme28, interpolate) {
30744
- return ({ length: n }) => {
30745
- if (n === 1)
30746
- return [scheme28[3][1]];
30747
- if (n === 2)
30748
- return [scheme28[3][1], scheme28[3][2]];
30749
- n = Math.max(3, Math.floor(n));
30750
- return n > 9 ? quantize_default(interpolate, n) : scheme28[n];
30751
- };
30725
+ function createScaleIdentity(key) {
30726
+ return { type: "identity", scale: hasNumericRange(registry.get(key)) ? identity5() : (d) => d };
30752
30727
  }
30753
- function scheme112(scheme28, interpolate) {
30754
- return ({ length: n }) => {
30755
- if (n === 2)
30756
- return [scheme28[3][0], scheme28[3][2]];
30757
- n = Math.max(3, Math.floor(n));
30758
- return n > 11 ? quantize_default(interpolate, n) : scheme28[n];
30759
- };
30728
+ function inferDomain(channels, f = finite2) {
30729
+ return channels.length ? [
30730
+ min2(channels, ({ value }) => value === void 0 ? value : min2(value, f)),
30731
+ max2(channels, ({ value }) => value === void 0 ? value : max2(value, f))
30732
+ ] : [0, 1];
30760
30733
  }
30761
- function scheme11r(scheme28, interpolate) {
30762
- return ({ length: n }) => {
30763
- if (n === 2)
30764
- return [scheme28[3][2], scheme28[3][0]];
30765
- n = Math.max(3, Math.floor(n));
30766
- return n > 11 ? quantize_default((t) => interpolate(1 - t), n) : scheme28[n].slice().reverse();
30767
- };
30734
+ function inferAutoDomain(key, channels) {
30735
+ const type2 = registry.get(key);
30736
+ return (type2 === radius || type2 === opacity || type2 === length3 ? inferZeroDomain : inferDomain)(channels);
30768
30737
  }
30769
- function schemei(interpolate) {
30770
- return ({ length: n }) => quantize_default(interpolate, Math.max(2, Math.floor(n)));
30738
+ function inferZeroDomain(channels) {
30739
+ return [0, channels.length ? max2(channels, ({ value }) => value === void 0 ? value : max2(value, finite2)) : 1];
30771
30740
  }
30772
- function schemeicyclical(interpolate) {
30773
- return ({ length: n }) => quantize_default(interpolate, Math.floor(n) + 1).slice(0, -1);
30741
+ function inferRadialRange(channels, domain) {
30742
+ const hint = channels.find(({ radius: radius2 }) => radius2 !== void 0);
30743
+ if (hint !== void 0)
30744
+ return [0, hint.radius];
30745
+ const h25 = quantile2(channels, 0.5, ({ value }) => value === void 0 ? NaN : quantile2(value, 0.25, positive));
30746
+ const range3 = domain.map((d) => 3 * Math.sqrt(d / h25));
30747
+ const k2 = 30 / max2(range3);
30748
+ return k2 < 1 ? range3.map((r) => r * k2) : range3;
30774
30749
  }
30775
- function ordinalScheme(scheme28) {
30776
- const s2 = `${scheme28}`.toLowerCase();
30777
- if (!ordinalSchemes.has(s2))
30778
- throw new Error(`unknown ordinal scheme: ${s2}`);
30779
- return ordinalSchemes.get(s2);
30750
+ function inferLengthRange(channels, domain) {
30751
+ const h50 = median2(channels, ({ value }) => value === void 0 ? NaN : median2(value, Math.abs));
30752
+ const range3 = domain.map((d) => 12 * d / h50);
30753
+ const k2 = 60 / max2(range3);
30754
+ return k2 < 1 ? range3.map((r) => r * k2) : range3;
30780
30755
  }
30781
- function ordinalRange(scheme28, length4) {
30782
- const s2 = ordinalScheme(scheme28);
30783
- const r = typeof s2 === "function" ? s2({ length: length4 }) : s2;
30784
- return r.length !== length4 ? r.slice(0, length4) : r;
30756
+ function inferLogDomain(channels) {
30757
+ for (const { value } of channels) {
30758
+ if (value !== void 0) {
30759
+ for (let v2 of value) {
30760
+ if (v2 > 0)
30761
+ return inferDomain(channels, positive);
30762
+ if (v2 < 0)
30763
+ return inferDomain(channels, negative);
30764
+ }
30765
+ }
30766
+ }
30767
+ return [1, 10];
30785
30768
  }
30786
- function maybeBooleanRange(domain, scheme28 = "greys") {
30787
- const range3 = /* @__PURE__ */ new Set();
30788
- const [f, t] = ordinalRange(scheme28, 2);
30789
- for (const value of domain) {
30790
- if (value == null)
30769
+ function inferQuantileDomain(channels) {
30770
+ const domain = [];
30771
+ for (const { value } of channels) {
30772
+ if (value === void 0)
30791
30773
  continue;
30792
- if (value === true)
30793
- range3.add(t);
30794
- else if (value === false)
30795
- range3.add(f);
30796
- else
30797
- return;
30774
+ for (const v2 of value)
30775
+ domain.push(v2);
30798
30776
  }
30799
- return [...range3];
30800
- }
30801
- var quantitativeSchemes = /* @__PURE__ */ new Map([
30802
- // diverging
30803
- ["brbg", BrBG_default],
30804
- ["prgn", PRGn_default],
30805
- ["piyg", PiYG_default],
30806
- ["puor", PuOr_default],
30807
- ["rdbu", RdBu_default],
30808
- ["rdgy", RdGy_default],
30809
- ["rdylbu", RdYlBu_default],
30810
- ["rdylgn", RdYlGn_default],
30811
- ["spectral", Spectral_default],
30812
- // reversed diverging (for temperature data)
30813
- ["burd", (t) => RdBu_default(1 - t)],
30814
- ["buylrd", (t) => RdYlBu_default(1 - t)],
30815
- // sequential (single-hue)
30816
- ["blues", Blues_default],
30817
- ["greens", Greens_default],
30818
- ["greys", Greys_default],
30819
- ["purples", Purples_default],
30820
- ["reds", Reds_default],
30821
- ["oranges", Oranges_default],
30822
- // sequential (multi-hue)
30823
- ["turbo", turbo_default],
30824
- ["viridis", viridis_default],
30825
- ["magma", magma],
30826
- ["inferno", inferno],
30827
- ["plasma", plasma],
30828
- ["cividis", cividis_default],
30829
- ["cubehelix", cubehelix_default2],
30830
- ["warm", warm],
30831
- ["cool", cool],
30832
- ["bugn", BuGn_default],
30833
- ["bupu", BuPu_default],
30834
- ["gnbu", GnBu_default],
30835
- ["orrd", OrRd_default],
30836
- ["pubugn", PuBuGn_default],
30837
- ["pubu", PuBu_default],
30838
- ["purd", PuRd_default],
30839
- ["rdpu", RdPu_default],
30840
- ["ylgnbu", YlGnBu_default],
30841
- ["ylgn", YlGn_default],
30842
- ["ylorbr", YlOrBr_default],
30843
- ["ylorrd", YlOrRd_default],
30844
- // cyclical
30845
- ["rainbow", rainbow_default],
30846
- ["sinebow", sinebow_default]
30847
- ]);
30848
- function quantitativeScheme(scheme28) {
30849
- const s2 = `${scheme28}`.toLowerCase();
30850
- if (!quantitativeSchemes.has(s2))
30851
- throw new Error(`unknown quantitative scheme: ${s2}`);
30852
- return quantitativeSchemes.get(s2);
30777
+ return domain;
30853
30778
  }
30854
- var divergingSchemes = /* @__PURE__ */ new Set([
30855
- "brbg",
30856
- "prgn",
30857
- "piyg",
30858
- "puor",
30859
- "rdbu",
30860
- "rdgy",
30861
- "rdylbu",
30862
- "rdylgn",
30863
- "spectral",
30864
- "burd",
30865
- "buylrd"
30866
- ]);
30867
- function isDivergingScheme(scheme28) {
30868
- return scheme28 != null && divergingSchemes.has(`${scheme28}`.toLowerCase());
30779
+ function interpolatePiecewise(interpolate) {
30780
+ return (i, j) => (t) => interpolate(i + t * (j - i));
30869
30781
  }
30870
30782
 
30871
- // ../../node_modules/@observablehq/plot/src/scales/quantitative.js
30872
- var flip = (i) => (t) => i(1 - t);
30873
- var unit2 = [0, 1];
30874
- var interpolators = /* @__PURE__ */ new Map([
30875
- // numbers
30876
- ["number", number_default],
30877
- // color spaces
30878
- ["rgb", rgb_default],
30879
- ["hsl", hsl_default],
30880
- ["hcl", hcl_default],
30881
- ["lab", lab2]
30882
- ]);
30883
- function maybeInterpolator(interpolate) {
30884
- const i = `${interpolate}`.toLowerCase();
30885
- if (!interpolators.has(i))
30886
- throw new Error(`unknown interpolator: ${i}`);
30887
- return interpolators.get(i);
30888
- }
30889
- function createScaleQ(key, scale3, channels, {
30783
+ // ../../node_modules/@observablehq/plot/src/scales/diverging.js
30784
+ function createScaleD(key, scale3, transform3, channels, {
30890
30785
  type: type2,
30891
30786
  nice: nice3,
30892
30787
  clamp,
30893
- zero: zero3,
30894
- domain = inferAutoDomain(key, channels),
30788
+ domain = inferDomain(channels),
30895
30789
  unknown,
30896
- round: round3,
30790
+ pivot = 0,
30897
30791
  scheme: scheme28,
30898
- interval: interval2,
30899
- range: range3 = registry.get(key) === radius ? inferRadialRange(channels, domain) : registry.get(key) === length3 ? inferLengthRange(channels, domain) : registry.get(key) === opacity ? unit2 : void 0,
30900
- interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : type2 === "cyclical" ? "rainbow" : "turbo") : round3 ? round_default : number_default,
30792
+ range: range3,
30793
+ symmetric = true,
30794
+ interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : "rdbu") : number_default,
30901
30795
  reverse: reverse3
30902
30796
  }) {
30903
- interval2 = maybeRangeInterval(interval2, type2);
30904
- if (type2 === "cyclical" || type2 === "sequential")
30905
- type2 = "linear";
30906
- if (typeof interpolate !== "function")
30797
+ pivot = +pivot;
30798
+ domain = arrayify2(domain);
30799
+ let [min5, max4] = domain;
30800
+ if (domain.length > 2)
30801
+ warn(`Warning: the diverging ${key} scale domain contains extra elements.`);
30802
+ if (descending(min5, max4) < 0)
30803
+ [min5, max4] = [max4, min5], reverse3 = !reverse3;
30804
+ min5 = Math.min(min5, pivot);
30805
+ max4 = Math.max(max4, pivot);
30806
+ if (typeof interpolate !== "function") {
30907
30807
  interpolate = maybeInterpolator(interpolate);
30908
- reverse3 = !!reverse3;
30808
+ }
30909
30809
  if (range3 !== void 0) {
30910
- const n = (domain = arrayify2(domain)).length;
30911
- const m = (range3 = arrayify2(range3)).length;
30912
- if (n !== m) {
30913
- if (interpolate.length === 1)
30914
- throw new Error("invalid piecewise interpolator");
30915
- interpolate = piecewise(interpolate, range3);
30916
- range3 = void 0;
30917
- }
30810
+ interpolate = interpolate.length === 1 ? interpolatePiecewise(interpolate)(...range3) : piecewise(interpolate, range3);
30918
30811
  }
30919
- if (interpolate.length === 1) {
30920
- if (reverse3) {
30921
- interpolate = flip(interpolate);
30922
- reverse3 = false;
30923
- }
30924
- if (range3 === void 0) {
30925
- range3 = Float64Array.from(domain, (_, i) => i / (domain.length - 1));
30926
- if (range3.length === 2)
30927
- range3 = unit2;
30928
- }
30929
- scale3.interpolate((range3 === unit2 ? constant : interpolatePiecewise)(interpolate));
30930
- } else {
30931
- scale3.interpolate(interpolate);
30812
+ if (reverse3)
30813
+ interpolate = flip(interpolate);
30814
+ if (symmetric) {
30815
+ const mid2 = transform3.apply(pivot);
30816
+ const mindelta = mid2 - transform3.apply(min5);
30817
+ const maxdelta = transform3.apply(max4) - mid2;
30818
+ if (mindelta < maxdelta)
30819
+ min5 = transform3.invert(mid2 - maxdelta);
30820
+ else if (mindelta > maxdelta)
30821
+ max4 = transform3.invert(mid2 + mindelta);
30932
30822
  }
30933
- if (zero3) {
30934
- const [min5, max4] = extent(domain);
30935
- if (min5 > 0 || max4 < 0) {
30936
- domain = slice3(domain);
30937
- if (orderof(domain) !== Math.sign(min5))
30938
- domain[domain.length - 1] = 0;
30939
- else
30940
- domain[0] = 0;
30941
- }
30823
+ scale3.domain([min5, pivot, max4]).unknown(unknown).interpolator(interpolate);
30824
+ if (clamp)
30825
+ scale3.clamp(clamp);
30826
+ if (nice3)
30827
+ scale3.nice(nice3);
30828
+ return { type: type2, domain: [min5, max4], pivot, interpolate, scale: scale3 };
30829
+ }
30830
+ function createScaleDiverging(key, channels, options) {
30831
+ return createScaleD(key, diverging(), transformIdentity, channels, options);
30832
+ }
30833
+ function createScaleDivergingSqrt(key, channels, options) {
30834
+ return createScaleDivergingPow(key, channels, { ...options, exponent: 0.5 });
30835
+ }
30836
+ function createScaleDivergingPow(key, channels, { exponent = 1, ...options }) {
30837
+ return createScaleD(key, divergingPow().exponent(exponent = +exponent), transformPow2(exponent), channels, {
30838
+ ...options,
30839
+ type: "diverging-pow"
30840
+ });
30841
+ }
30842
+ function createScaleDivergingLog(key, channels, { base = 10, pivot = 1, domain = inferDomain(channels, pivot < 0 ? negative : positive), ...options }) {
30843
+ return createScaleD(key, divergingLog().base(base = +base), transformLog2, channels, {
30844
+ domain,
30845
+ pivot,
30846
+ ...options
30847
+ });
30848
+ }
30849
+ function createScaleDivergingSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30850
+ return createScaleD(
30851
+ key,
30852
+ divergingSymlog().constant(constant2 = +constant2),
30853
+ transformSymlog2(constant2),
30854
+ channels,
30855
+ options
30856
+ );
30857
+ }
30858
+ var transformIdentity = {
30859
+ apply(x3) {
30860
+ return x3;
30861
+ },
30862
+ invert(x3) {
30863
+ return x3;
30864
+ }
30865
+ };
30866
+ var transformLog2 = {
30867
+ apply: Math.log,
30868
+ invert: Math.exp
30869
+ };
30870
+ var transformSqrt2 = {
30871
+ apply(x3) {
30872
+ return Math.sign(x3) * Math.sqrt(Math.abs(x3));
30873
+ },
30874
+ invert(x3) {
30875
+ return Math.sign(x3) * (x3 * x3);
30942
30876
  }
30877
+ };
30878
+ function transformPow2(exponent) {
30879
+ return exponent === 0.5 ? transformSqrt2 : {
30880
+ apply(x3) {
30881
+ return Math.sign(x3) * Math.pow(Math.abs(x3), exponent);
30882
+ },
30883
+ invert(x3) {
30884
+ return Math.sign(x3) * Math.pow(Math.abs(x3), 1 / exponent);
30885
+ }
30886
+ };
30887
+ }
30888
+ function transformSymlog2(constant2) {
30889
+ return {
30890
+ apply(x3) {
30891
+ return Math.sign(x3) * Math.log1p(Math.abs(x3 / constant2));
30892
+ },
30893
+ invert(x3) {
30894
+ return Math.sign(x3) * Math.expm1(Math.abs(x3)) * constant2;
30895
+ }
30896
+ };
30897
+ }
30898
+
30899
+ // ../../node_modules/@observablehq/plot/src/scales/temporal.js
30900
+ function createScaleT(key, scale3, channels, options) {
30901
+ return createScaleQ(key, scale3, channels, options);
30902
+ }
30903
+ function createScaleTime(key, channels, options) {
30904
+ return createScaleT(key, time(), channels, options);
30905
+ }
30906
+ function createScaleUtc(key, channels, options) {
30907
+ return createScaleT(key, utcTime(), channels, options);
30908
+ }
30909
+
30910
+ // ../../node_modules/@observablehq/plot/src/scales/ordinal.js
30911
+ var ordinalImplicit = Symbol("ordinal");
30912
+ function createScaleO(key, scale3, channels, { type: type2, interval: interval2, domain, range: range3, reverse: reverse3, hint }) {
30913
+ interval2 = maybeRangeInterval(interval2, type2);
30914
+ if (domain === void 0)
30915
+ domain = inferDomain2(channels, interval2, key);
30916
+ if (type2 === "categorical" || type2 === ordinalImplicit)
30917
+ type2 = "ordinal";
30943
30918
  if (reverse3)
30944
30919
  domain = reverse(domain);
30945
- scale3.domain(domain).unknown(unknown);
30946
- if (nice3)
30947
- scale3.nice(maybeNice(nice3, type2)), domain = scale3.domain();
30948
- if (range3 !== void 0)
30920
+ domain = scale3.domain(domain).domain();
30921
+ if (range3 !== void 0) {
30922
+ if (typeof range3 === "function")
30923
+ range3 = range3(domain);
30949
30924
  scale3.range(range3);
30950
- if (clamp)
30951
- scale3.clamp(clamp);
30952
- return { type: type2, domain, range: range3, scale: scale3, interpolate, interval: interval2 };
30953
- }
30954
- function maybeNice(nice3, type2) {
30955
- return nice3 === true ? void 0 : typeof nice3 === "number" ? nice3 : maybeNiceInterval(nice3, type2);
30956
- }
30957
- function createScaleLinear(key, channels, options) {
30958
- return createScaleQ(key, linear2(), channels, options);
30925
+ }
30926
+ return { type: type2, domain, range: range3, scale: scale3, hint, interval: interval2 };
30959
30927
  }
30960
- function createScaleSqrt(key, channels, options) {
30961
- return createScalePow(key, channels, { ...options, exponent: 0.5 });
30928
+ function createScaleOrdinal(key, channels, { type: type2, interval: interval2, domain, range: range3, scheme: scheme28, unknown, ...options }) {
30929
+ interval2 = maybeRangeInterval(interval2, type2);
30930
+ if (domain === void 0)
30931
+ domain = inferDomain2(channels, interval2, key);
30932
+ let hint;
30933
+ if (registry.get(key) === symbol) {
30934
+ hint = inferSymbolHint(channels);
30935
+ range3 = range3 === void 0 ? inferSymbolRange(hint) : map2(range3, maybeSymbol);
30936
+ } else if (registry.get(key) === color2) {
30937
+ if (range3 === void 0 && (type2 === "ordinal" || type2 === ordinalImplicit)) {
30938
+ range3 = maybeBooleanRange(domain, scheme28);
30939
+ if (range3 !== void 0)
30940
+ scheme28 = void 0;
30941
+ }
30942
+ if (scheme28 === void 0 && range3 === void 0) {
30943
+ scheme28 = type2 === "ordinal" ? "turbo" : "observable10";
30944
+ }
30945
+ if (scheme28 !== void 0) {
30946
+ if (range3 !== void 0) {
30947
+ const interpolate = quantitativeScheme(scheme28);
30948
+ const t03 = range3[0], d = range3[1] - range3[0];
30949
+ range3 = ({ length: n }) => quantize_default((t) => interpolate(t03 + d * t), n);
30950
+ } else {
30951
+ range3 = ordinalScheme(scheme28);
30952
+ }
30953
+ }
30954
+ }
30955
+ if (unknown === implicit) {
30956
+ throw new Error(`implicit unknown on ${key} scale is not supported`);
30957
+ }
30958
+ return createScaleO(key, ordinal().unknown(unknown), channels, { ...options, type: type2, domain, range: range3, hint });
30962
30959
  }
30963
- function createScalePow(key, channels, { exponent = 1, ...options }) {
30964
- return createScaleQ(key, pow3().exponent(exponent), channels, { ...options, type: "pow" });
30960
+ function createScalePoint(key, channels, { align: align2 = 0.5, padding: padding2 = 0.5, ...options }) {
30961
+ return maybeRound(point().align(align2).padding(padding2), channels, options, key);
30965
30962
  }
30966
- function createScaleLog(key, channels, { base = 10, domain = inferLogDomain(channels), ...options }) {
30967
- return createScaleQ(key, log2().base(base), channels, { ...options, domain });
30963
+ function createScaleBand(key, channels, {
30964
+ align: align2 = 0.5,
30965
+ padding: padding2 = 0.1,
30966
+ paddingInner = padding2,
30967
+ paddingOuter = key === "fx" || key === "fy" ? 0 : padding2,
30968
+ ...options
30969
+ }) {
30970
+ return maybeRound(
30971
+ band().align(align2).paddingInner(paddingInner).paddingOuter(paddingOuter),
30972
+ channels,
30973
+ options,
30974
+ key
30975
+ );
30968
30976
  }
30969
- function createScaleSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30970
- return createScaleQ(key, symlog().constant(constant2), channels, options);
30977
+ function maybeRound(scale3, channels, options, key) {
30978
+ let { round: round3 } = options;
30979
+ if (round3 !== void 0)
30980
+ scale3.round(round3 = !!round3);
30981
+ scale3 = createScaleO(key, scale3, channels, options);
30982
+ scale3.round = round3;
30983
+ return scale3;
30971
30984
  }
30972
- function createScaleQuantile(key, channels, {
30973
- range: range3,
30974
- quantiles = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30975
- // deprecated; use n instead
30976
- n = quantiles,
30977
- scheme: scheme28 = "rdylbu",
30978
- domain = inferQuantileDomain(channels),
30979
- unknown,
30980
- interpolate,
30981
- reverse: reverse3
30982
- }) {
30983
- if (range3 === void 0) {
30984
- range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30985
+ function inferDomain2(channels, interval2, key) {
30986
+ const values2 = new InternSet();
30987
+ for (const { value, domain } of channels) {
30988
+ if (domain !== void 0)
30989
+ return domain();
30990
+ if (value === void 0)
30991
+ continue;
30992
+ for (const v2 of value)
30993
+ values2.add(v2);
30985
30994
  }
30986
- if (domain.length > 0) {
30987
- domain = quantile3(domain, range3 === void 0 ? { length: n } : range3).quantiles();
30995
+ if (interval2 !== void 0) {
30996
+ const [min5, max4] = extent(values2).map(interval2.floor, interval2);
30997
+ return interval2.range(min5, interval2.offset(max4));
30988
30998
  }
30989
- return createScaleThreshold(key, channels, { domain, range: range3, reverse: reverse3, unknown });
30999
+ if (values2.size > 1e4 && registry.get(key) === position) {
31000
+ throw new Error(`implicit ordinal domain of ${key} scale has more than 10,000 values`);
31001
+ }
31002
+ return sort(values2, ascendingDefined2);
30990
31003
  }
30991
- function createScaleQuantize(key, channels, {
30992
- range: range3,
30993
- n = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30994
- scheme: scheme28 = "rdylbu",
30995
- domain = inferAutoDomain(key, channels),
30996
- unknown,
30997
- interpolate,
30998
- reverse: reverse3
30999
- }) {
31000
- const [min5, max4] = extent(domain);
31001
- let thresholds;
31002
- if (range3 === void 0) {
31003
- thresholds = ticks(min5, max4, n);
31004
- if (thresholds[0] <= min5)
31005
- thresholds.splice(0, 1);
31006
- if (thresholds[thresholds.length - 1] >= max4)
31007
- thresholds.pop();
31008
- n = thresholds.length + 1;
31009
- range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
31010
- } else {
31011
- thresholds = quantize_default(number_default(min5, max4), n + 1).slice(1, -1);
31012
- if (min5 instanceof Date)
31013
- thresholds = thresholds.map((x3) => new Date(x3));
31004
+ function inferHint(channels, key) {
31005
+ let value;
31006
+ for (const { hint } of channels) {
31007
+ const candidate = hint?.[key];
31008
+ if (candidate === void 0)
31009
+ continue;
31010
+ if (value === void 0)
31011
+ value = candidate;
31012
+ else if (value !== candidate)
31013
+ return;
31014
31014
  }
31015
- if (orderof(arrayify2(domain)) < 0)
31016
- thresholds.reverse();
31017
- return createScaleThreshold(key, channels, { domain: thresholds, range: range3, reverse: reverse3, unknown });
31015
+ return value;
31018
31016
  }
31019
- function createScaleThreshold(key, channels, {
31020
- domain = [0],
31021
- // explicit thresholds in ascending order
31022
- unknown,
31023
- scheme: scheme28 = "rdylbu",
31024
- interpolate,
31025
- range: range3 = interpolate !== void 0 ? quantize_default(interpolate, domain.length + 1) : registry.get(key) === color2 ? ordinalRange(scheme28, domain.length + 1) : void 0,
31026
- reverse: reverse3
31027
- }) {
31028
- domain = arrayify2(domain);
31029
- const sign3 = orderof(domain);
31030
- if (!isNaN(sign3) && !isOrdered(domain, sign3))
31031
- throw new Error(`the ${key} scale has a non-monotonic domain`);
31032
- if (reverse3)
31033
- range3 = reverse(range3);
31017
+ function inferSymbolHint(channels) {
31034
31018
  return {
31035
- type: "threshold",
31036
- scale: threshold(sign3 < 0 ? reverse(domain) : domain, range3 === void 0 ? [] : range3).unknown(unknown),
31037
- domain,
31038
- range: range3
31019
+ fill: inferHint(channels, "fill"),
31020
+ stroke: inferHint(channels, "stroke")
31039
31021
  };
31040
31022
  }
31041
- function isOrdered(domain, sign3) {
31042
- for (let i = 1, n = domain.length, d = domain[0]; i < n; ++i) {
31043
- const s2 = descending(d, d = domain[i]);
31044
- if (s2 !== 0 && s2 !== sign3)
31045
- return false;
31046
- }
31047
- return true;
31048
- }
31049
- function createScaleIdentity(key) {
31050
- return { type: "identity", scale: hasNumericRange(registry.get(key)) ? identity5() : (d) => d };
31051
- }
31052
- function inferDomain(channels, f = finite2) {
31053
- return channels.length ? [
31054
- min2(channels, ({ value }) => value === void 0 ? value : min2(value, f)),
31055
- max2(channels, ({ value }) => value === void 0 ? value : max2(value, f))
31056
- ] : [0, 1];
31057
- }
31058
- function inferAutoDomain(key, channels) {
31059
- const type2 = registry.get(key);
31060
- return (type2 === radius || type2 === opacity || type2 === length3 ? inferZeroDomain : inferDomain)(channels);
31061
- }
31062
- function inferZeroDomain(channels) {
31063
- return [0, channels.length ? max2(channels, ({ value }) => value === void 0 ? value : max2(value, finite2)) : 1];
31064
- }
31065
- function inferRadialRange(channels, domain) {
31066
- const hint = channels.find(({ radius: radius2 }) => radius2 !== void 0);
31067
- if (hint !== void 0)
31068
- return [0, hint.radius];
31069
- const h25 = quantile2(channels, 0.5, ({ value }) => value === void 0 ? NaN : quantile2(value, 0.25, positive));
31070
- const range3 = domain.map((d) => 3 * Math.sqrt(d / h25));
31071
- const k2 = 30 / max2(range3);
31072
- return k2 < 1 ? range3.map((r) => r * k2) : range3;
31073
- }
31074
- function inferLengthRange(channels, domain) {
31075
- const h50 = median2(channels, ({ value }) => value === void 0 ? NaN : median2(value, Math.abs));
31076
- const range3 = domain.map((d) => 12 * d / h50);
31077
- const k2 = 60 / max2(range3);
31078
- return k2 < 1 ? range3.map((r) => r * k2) : range3;
31023
+ function inferSymbolRange(hint) {
31024
+ return isNoneish(hint.fill) ? symbolsStroke : symbolsFill;
31079
31025
  }
31080
- function inferLogDomain(channels) {
31081
- for (const { value } of channels) {
31082
- if (value !== void 0) {
31083
- for (let v2 of value) {
31084
- if (v2 > 0)
31085
- return inferDomain(channels, positive);
31086
- if (v2 < 0)
31087
- return inferDomain(channels, negative);
31026
+
31027
+ // ../../node_modules/@observablehq/plot/src/scales.js
31028
+ function createScales(channelsByScale, {
31029
+ label: globalLabel,
31030
+ inset: globalInset = 0,
31031
+ insetTop: globalInsetTop = globalInset,
31032
+ insetRight: globalInsetRight = globalInset,
31033
+ insetBottom: globalInsetBottom = globalInset,
31034
+ insetLeft: globalInsetLeft = globalInset,
31035
+ round: round3,
31036
+ nice: nice3,
31037
+ clamp,
31038
+ zero: zero3,
31039
+ align: align2,
31040
+ padding: padding2,
31041
+ projection: projection3,
31042
+ facet: { label: facetLabel2 = globalLabel } = {},
31043
+ ...options
31044
+ } = {}) {
31045
+ const scales2 = {};
31046
+ for (const [key, channels] of channelsByScale) {
31047
+ const scaleOptions = options[key];
31048
+ const scale3 = createScale(key, channels, {
31049
+ round: registry.get(key) === position ? round3 : void 0,
31050
+ // only for position
31051
+ nice: nice3,
31052
+ clamp,
31053
+ zero: zero3,
31054
+ align: align2,
31055
+ padding: padding2,
31056
+ projection: projection3,
31057
+ ...scaleOptions
31058
+ });
31059
+ if (scale3) {
31060
+ let {
31061
+ label: label2 = key === "fx" || key === "fy" ? facetLabel2 : globalLabel,
31062
+ percent,
31063
+ transform: transform3,
31064
+ inset: inset2,
31065
+ insetTop = inset2 !== void 0 ? inset2 : key === "y" ? globalInsetTop : 0,
31066
+ // not fy
31067
+ insetRight = inset2 !== void 0 ? inset2 : key === "x" ? globalInsetRight : 0,
31068
+ // not fx
31069
+ insetBottom = inset2 !== void 0 ? inset2 : key === "y" ? globalInsetBottom : 0,
31070
+ // not fy
31071
+ insetLeft = inset2 !== void 0 ? inset2 : key === "x" ? globalInsetLeft : 0
31072
+ // not fx
31073
+ } = scaleOptions || {};
31074
+ if (transform3 == null)
31075
+ transform3 = void 0;
31076
+ else if (typeof transform3 !== "function")
31077
+ throw new Error("invalid scale transform; not a function");
31078
+ scale3.percent = !!percent;
31079
+ scale3.label = label2 === void 0 ? inferScaleLabel(channels, scale3) : label2;
31080
+ scale3.transform = transform3;
31081
+ if (key === "x" || key === "fx") {
31082
+ scale3.insetLeft = +insetLeft;
31083
+ scale3.insetRight = +insetRight;
31084
+ } else if (key === "y" || key === "fy") {
31085
+ scale3.insetTop = +insetTop;
31086
+ scale3.insetBottom = +insetBottom;
31088
31087
  }
31088
+ scales2[key] = scale3;
31089
31089
  }
31090
31090
  }
31091
- return [1, 10];
31091
+ return scales2;
31092
31092
  }
31093
- function inferQuantileDomain(channels) {
31094
- const domain = [];
31095
- for (const { value } of channels) {
31096
- if (value === void 0)
31097
- continue;
31098
- for (const v2 of value)
31099
- domain.push(v2);
31093
+ function createScaleFunctions(descriptors) {
31094
+ const scales2 = {};
31095
+ const scaleFunctions = { scales: scales2 };
31096
+ for (const [key, descriptor] of Object.entries(descriptors)) {
31097
+ const { scale: scale3, type: type2, interval: interval2, label: label2 } = descriptor;
31098
+ scales2[key] = exposeScale(descriptor);
31099
+ scaleFunctions[key] = scale3;
31100
+ scale3.type = type2;
31101
+ if (interval2 != null)
31102
+ scale3.interval = interval2;
31103
+ if (label2 != null)
31104
+ scale3.label = label2;
31100
31105
  }
31101
- return domain;
31106
+ return scaleFunctions;
31102
31107
  }
31103
- function interpolatePiecewise(interpolate) {
31104
- return (i, j) => (t) => interpolate(i + t * (j - i));
31108
+ function autoScaleRange(scales2, dimensions) {
31109
+ const { x: x3, y: y3, fx, fy } = scales2;
31110
+ const superdimensions = fx || fy ? outerDimensions(dimensions) : dimensions;
31111
+ if (fx)
31112
+ autoScaleRangeX(fx, superdimensions);
31113
+ if (fy)
31114
+ autoScaleRangeY(fy, superdimensions);
31115
+ const subdimensions = fx || fy ? innerDimensions(scales2, dimensions) : dimensions;
31116
+ if (x3)
31117
+ autoScaleRangeX(x3, subdimensions);
31118
+ if (y3)
31119
+ autoScaleRangeY(y3, subdimensions);
31105
31120
  }
31106
-
31107
- // ../../node_modules/@observablehq/plot/src/scales/diverging.js
31108
- function createScaleD(key, scale3, transform3, channels, {
31109
- type: type2,
31110
- nice: nice3,
31111
- clamp,
31112
- domain = inferDomain(channels),
31113
- unknown,
31114
- pivot = 0,
31115
- scheme: scheme28,
31116
- range: range3,
31117
- symmetric = true,
31118
- interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : "rdbu") : number_default,
31119
- reverse: reverse3
31120
- }) {
31121
- pivot = +pivot;
31122
- domain = arrayify2(domain);
31123
- let [min5, max4] = domain;
31124
- if (domain.length > 2)
31125
- warn(`Warning: the diverging ${key} scale domain contains extra elements.`);
31126
- if (descending(min5, max4) < 0)
31127
- [min5, max4] = [max4, min5], reverse3 = !reverse3;
31128
- min5 = Math.min(min5, pivot);
31129
- max4 = Math.max(max4, pivot);
31130
- if (typeof interpolate !== "function") {
31131
- interpolate = maybeInterpolator(interpolate);
31132
- }
31133
- if (range3 !== void 0) {
31134
- interpolate = interpolate.length === 1 ? interpolatePiecewise(interpolate)(...range3) : piecewise(interpolate, range3);
31135
- }
31136
- if (reverse3)
31137
- interpolate = flip(interpolate);
31138
- if (symmetric) {
31139
- const mid2 = transform3.apply(pivot);
31140
- const mindelta = mid2 - transform3.apply(min5);
31141
- const maxdelta = transform3.apply(max4) - mid2;
31142
- if (mindelta < maxdelta)
31143
- min5 = transform3.invert(mid2 - maxdelta);
31144
- else if (mindelta > maxdelta)
31145
- max4 = transform3.invert(mid2 + mindelta);
31121
+ function inferScaleLabel(channels = [], scale3) {
31122
+ let label2;
31123
+ for (const { label: l } of channels) {
31124
+ if (l === void 0)
31125
+ continue;
31126
+ if (label2 === void 0)
31127
+ label2 = l;
31128
+ else if (label2 !== l)
31129
+ return;
31146
31130
  }
31147
- scale3.domain([min5, pivot, max4]).unknown(unknown).interpolator(interpolate);
31148
- if (clamp)
31149
- scale3.clamp(clamp);
31150
- if (nice3)
31151
- scale3.nice(nice3);
31152
- return { type: type2, domain: [min5, max4], pivot, interpolate, scale: scale3 };
31153
- }
31154
- function createScaleDiverging(key, channels, options) {
31155
- return createScaleD(key, diverging(), transformIdentity, channels, options);
31156
- }
31157
- function createScaleDivergingSqrt(key, channels, options) {
31158
- return createScaleDivergingPow(key, channels, { ...options, exponent: 0.5 });
31159
- }
31160
- function createScaleDivergingPow(key, channels, { exponent = 1, ...options }) {
31161
- return createScaleD(key, divergingPow().exponent(exponent = +exponent), transformPow2(exponent), channels, {
31162
- ...options,
31163
- type: "diverging-pow"
31164
- });
31165
- }
31166
- function createScaleDivergingLog(key, channels, { base = 10, pivot = 1, domain = inferDomain(channels, pivot < 0 ? negative : positive), ...options }) {
31167
- return createScaleD(key, divergingLog().base(base = +base), transformLog2, channels, {
31168
- domain,
31169
- pivot,
31170
- ...options
31171
- });
31131
+ if (label2 === void 0)
31132
+ return;
31133
+ if (!isOrdinalScale(scale3) && scale3.percent)
31134
+ label2 = `${label2} (%)`;
31135
+ return { inferred: true, toString: () => label2 };
31172
31136
  }
31173
- function createScaleDivergingSymlog(key, channels, { constant: constant2 = 1, ...options }) {
31174
- return createScaleD(
31175
- key,
31176
- divergingSymlog().constant(constant2 = +constant2),
31177
- transformSymlog2(constant2),
31178
- channels,
31179
- options
31180
- );
31137
+ function inferScaleOrder(scale3) {
31138
+ return Math.sign(orderof(scale3.domain())) * Math.sign(orderof(scale3.range()));
31181
31139
  }
31182
- var transformIdentity = {
31183
- apply(x3) {
31184
- return x3;
31185
- },
31186
- invert(x3) {
31187
- return x3;
31188
- }
31189
- };
31190
- var transformLog2 = {
31191
- apply: Math.log,
31192
- invert: Math.exp
31193
- };
31194
- var transformSqrt2 = {
31195
- apply(x3) {
31196
- return Math.sign(x3) * Math.sqrt(Math.abs(x3));
31197
- },
31198
- invert(x3) {
31199
- return Math.sign(x3) * (x3 * x3);
31200
- }
31201
- };
31202
- function transformPow2(exponent) {
31203
- return exponent === 0.5 ? transformSqrt2 : {
31204
- apply(x3) {
31205
- return Math.sign(x3) * Math.pow(Math.abs(x3), exponent);
31206
- },
31207
- invert(x3) {
31208
- return Math.sign(x3) * Math.pow(Math.abs(x3), 1 / exponent);
31140
+ function outerDimensions(dimensions) {
31141
+ const {
31142
+ marginTop: marginTop2,
31143
+ marginRight: marginRight2,
31144
+ marginBottom: marginBottom2,
31145
+ marginLeft: marginLeft2,
31146
+ width: width2,
31147
+ height: height2,
31148
+ facet: {
31149
+ marginTop: facetMarginTop2,
31150
+ marginRight: facetMarginRight2,
31151
+ marginBottom: facetMarginBottom2,
31152
+ marginLeft: facetMarginLeft2
31209
31153
  }
31154
+ } = dimensions;
31155
+ return {
31156
+ marginTop: Math.max(marginTop2, facetMarginTop2),
31157
+ marginRight: Math.max(marginRight2, facetMarginRight2),
31158
+ marginBottom: Math.max(marginBottom2, facetMarginBottom2),
31159
+ marginLeft: Math.max(marginLeft2, facetMarginLeft2),
31160
+ width: width2,
31161
+ height: height2
31210
31162
  };
31211
31163
  }
31212
- function transformSymlog2(constant2) {
31164
+ function innerDimensions({ fx, fy }, dimensions) {
31165
+ const { marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2, width: width2, height: height2 } = outerDimensions(dimensions);
31213
31166
  return {
31214
- apply(x3) {
31215
- return Math.sign(x3) * Math.log1p(Math.abs(x3 / constant2));
31216
- },
31217
- invert(x3) {
31218
- return Math.sign(x3) * Math.expm1(Math.abs(x3)) * constant2;
31219
- }
31167
+ marginTop: marginTop2,
31168
+ marginRight: marginRight2,
31169
+ marginBottom: marginBottom2,
31170
+ marginLeft: marginLeft2,
31171
+ width: fx ? fx.scale.bandwidth() + marginLeft2 + marginRight2 : width2,
31172
+ height: fy ? fy.scale.bandwidth() + marginTop2 + marginBottom2 : height2,
31173
+ facet: { width: width2, height: height2 }
31220
31174
  };
31221
31175
  }
31222
-
31223
- // ../../node_modules/@observablehq/plot/src/scales/temporal.js
31224
- function createScaleT(key, scale3, channels, options) {
31225
- return createScaleQ(key, scale3, channels, options);
31176
+ function autoScaleRangeX(scale3, dimensions) {
31177
+ if (scale3.range === void 0) {
31178
+ const { insetLeft, insetRight } = scale3;
31179
+ const { width: width2, marginLeft: marginLeft2 = 0, marginRight: marginRight2 = 0 } = dimensions;
31180
+ const left2 = marginLeft2 + insetLeft;
31181
+ const right2 = width2 - marginRight2 - insetRight;
31182
+ scale3.range = [left2, Math.max(left2, right2)];
31183
+ if (!isOrdinalScale(scale3))
31184
+ scale3.range = piecewiseRange(scale3);
31185
+ scale3.scale.range(scale3.range);
31186
+ }
31187
+ autoScaleRound(scale3);
31188
+ }
31189
+ function autoScaleRangeY(scale3, dimensions) {
31190
+ if (scale3.range === void 0) {
31191
+ const { insetTop, insetBottom } = scale3;
31192
+ const { height: height2, marginTop: marginTop2 = 0, marginBottom: marginBottom2 = 0 } = dimensions;
31193
+ const top2 = marginTop2 + insetTop;
31194
+ const bottom2 = height2 - marginBottom2 - insetBottom;
31195
+ scale3.range = [Math.max(top2, bottom2), top2];
31196
+ if (!isOrdinalScale(scale3))
31197
+ scale3.range = piecewiseRange(scale3);
31198
+ else
31199
+ scale3.range.reverse();
31200
+ scale3.scale.range(scale3.range);
31201
+ }
31202
+ autoScaleRound(scale3);
31203
+ }
31204
+ function autoScaleRound(scale3) {
31205
+ if (scale3.round === void 0 && isBandScale(scale3) && roundError(scale3) <= 30) {
31206
+ scale3.scale.round(true);
31207
+ }
31208
+ }
31209
+ function roundError({ scale: scale3 }) {
31210
+ const n = scale3.domain().length;
31211
+ const [start2, stop] = scale3.range();
31212
+ const paddingInner = scale3.paddingInner ? scale3.paddingInner() : 1;
31213
+ const paddingOuter = scale3.paddingOuter ? scale3.paddingOuter() : scale3.padding();
31214
+ const m = n - paddingInner;
31215
+ const step = Math.abs(stop - start2) / Math.max(1, m + paddingOuter * 2);
31216
+ return (step - Math.floor(step)) * m;
31226
31217
  }
31227
- function createScaleTime(key, channels, options) {
31228
- return createScaleT(key, time(), channels, options);
31218
+ function piecewiseRange(scale3) {
31219
+ const length4 = scale3.scale.domain().length + isThresholdScale(scale3);
31220
+ if (!(length4 > 2))
31221
+ return scale3.range;
31222
+ const [start2, end] = scale3.range;
31223
+ return Array.from({ length: length4 }, (_, i) => start2 + i / (length4 - 1) * (end - start2));
31229
31224
  }
31230
- function createScaleUtc(key, channels, options) {
31231
- return createScaleT(key, utcTime(), channels, options);
31225
+ function normalizeScale(key, scale3, hint) {
31226
+ return createScale(key, hint === void 0 ? void 0 : [{ hint }], { ...scale3 });
31232
31227
  }
31233
-
31234
- // ../../node_modules/@observablehq/plot/src/scales/ordinal.js
31235
- var ordinalImplicit = Symbol("ordinal");
31236
- function createScaleO(key, scale3, channels, { type: type2, interval: interval2, domain, range: range3, reverse: reverse3, hint }) {
31237
- interval2 = maybeRangeInterval(interval2, type2);
31238
- if (domain === void 0)
31239
- domain = inferDomain2(channels, interval2, key);
31240
- if (type2 === "categorical" || type2 === ordinalImplicit)
31241
- type2 = "ordinal";
31242
- if (reverse3)
31243
- domain = reverse(domain);
31244
- domain = scale3.domain(domain).domain();
31245
- if (range3 !== void 0) {
31246
- if (typeof range3 === "function")
31247
- range3 = range3(domain);
31248
- scale3.range(range3);
31228
+ function createScale(key, channels = [], options = {}) {
31229
+ const type2 = inferScaleType(key, channels, options);
31230
+ if (options.type === void 0 && options.domain === void 0 && options.range === void 0 && options.interval == null && key !== "fx" && key !== "fy" && isOrdinalScale({ type: type2 })) {
31231
+ const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31232
+ if (values2.some(isTemporal))
31233
+ warn(
31234
+ `Warning: some data associated with the ${key} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31235
+ type2
31236
+ )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31237
+ type2
31238
+ )}".`
31239
+ );
31240
+ else if (values2.some(isTemporalString))
31241
+ warn(
31242
+ `Warning: some data associated with the ${key} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31243
+ type2
31244
+ )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31245
+ type2
31246
+ )}".`
31247
+ );
31248
+ else if (values2.some(isNumericString))
31249
+ warn(
31250
+ `Warning: some data associated with the ${key} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${formatScaleType(
31251
+ type2
31252
+ )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31253
+ type2
31254
+ )}".`
31255
+ );
31249
31256
  }
31250
- return { type: type2, domain, range: range3, scale: scale3, hint, interval: interval2 };
31251
- }
31252
- function createScaleOrdinal(key, channels, { type: type2, interval: interval2, domain, range: range3, scheme: scheme28, unknown, ...options }) {
31253
- interval2 = maybeRangeInterval(interval2, type2);
31254
- if (domain === void 0)
31255
- domain = inferDomain2(channels, interval2, key);
31256
- let hint;
31257
- if (registry.get(key) === symbol) {
31258
- hint = inferSymbolHint(channels);
31259
- range3 = range3 === void 0 ? inferSymbolRange(hint) : map2(range3, maybeSymbol);
31260
- } else if (registry.get(key) === color2) {
31261
- if (range3 === void 0 && (type2 === "ordinal" || type2 === ordinalImplicit)) {
31262
- range3 = maybeBooleanRange(domain, scheme28);
31263
- if (range3 !== void 0)
31264
- scheme28 = void 0;
31265
- }
31266
- if (scheme28 === void 0 && range3 === void 0) {
31267
- scheme28 = type2 === "ordinal" ? "turbo" : "observable10";
31268
- }
31269
- if (scheme28 !== void 0) {
31270
- if (range3 !== void 0) {
31271
- const interpolate = quantitativeScheme(scheme28);
31272
- const t03 = range3[0], d = range3[1] - range3[0];
31273
- range3 = ({ length: n }) => quantize_default((t) => interpolate(t03 + d * t), n);
31274
- } else {
31275
- range3 = ordinalScheme(scheme28);
31257
+ options.type = type2;
31258
+ switch (type2) {
31259
+ case "diverging":
31260
+ case "diverging-sqrt":
31261
+ case "diverging-pow":
31262
+ case "diverging-log":
31263
+ case "diverging-symlog":
31264
+ case "cyclical":
31265
+ case "sequential":
31266
+ case "linear":
31267
+ case "sqrt":
31268
+ case "threshold":
31269
+ case "quantile":
31270
+ case "pow":
31271
+ case "log":
31272
+ case "symlog":
31273
+ options = coerceType(channels, options, coerceNumbers);
31274
+ break;
31275
+ case "identity":
31276
+ switch (registry.get(key)) {
31277
+ case position:
31278
+ options = coerceType(channels, options, coerceNumbers);
31279
+ break;
31280
+ case symbol:
31281
+ options = coerceType(channels, options, coerceSymbols);
31282
+ break;
31276
31283
  }
31277
- }
31284
+ break;
31285
+ case "utc":
31286
+ case "time":
31287
+ options = coerceType(channels, options, coerceDates);
31288
+ break;
31278
31289
  }
31279
- if (unknown === implicit) {
31280
- throw new Error(`implicit unknown on ${key} scale is not supported`);
31290
+ switch (type2) {
31291
+ case "diverging":
31292
+ return createScaleDiverging(key, channels, options);
31293
+ case "diverging-sqrt":
31294
+ return createScaleDivergingSqrt(key, channels, options);
31295
+ case "diverging-pow":
31296
+ return createScaleDivergingPow(key, channels, options);
31297
+ case "diverging-log":
31298
+ return createScaleDivergingLog(key, channels, options);
31299
+ case "diverging-symlog":
31300
+ return createScaleDivergingSymlog(key, channels, options);
31301
+ case "categorical":
31302
+ case "ordinal":
31303
+ case ordinalImplicit:
31304
+ return createScaleOrdinal(key, channels, options);
31305
+ case "cyclical":
31306
+ case "sequential":
31307
+ case "linear":
31308
+ return createScaleLinear(key, channels, options);
31309
+ case "sqrt":
31310
+ return createScaleSqrt(key, channels, options);
31311
+ case "threshold":
31312
+ return createScaleThreshold(key, channels, options);
31313
+ case "quantile":
31314
+ return createScaleQuantile(key, channels, options);
31315
+ case "quantize":
31316
+ return createScaleQuantize(key, channels, options);
31317
+ case "pow":
31318
+ return createScalePow(key, channels, options);
31319
+ case "log":
31320
+ return createScaleLog(key, channels, options);
31321
+ case "symlog":
31322
+ return createScaleSymlog(key, channels, options);
31323
+ case "utc":
31324
+ return createScaleUtc(key, channels, options);
31325
+ case "time":
31326
+ return createScaleTime(key, channels, options);
31327
+ case "point":
31328
+ return createScalePoint(key, channels, options);
31329
+ case "band":
31330
+ return createScaleBand(key, channels, options);
31331
+ case "identity":
31332
+ return createScaleIdentity(key);
31333
+ case void 0:
31334
+ return;
31335
+ default:
31336
+ throw new Error(`unknown scale type: ${type2}`);
31281
31337
  }
31282
- return createScaleO(key, ordinal().unknown(unknown), channels, { ...options, type: type2, domain, range: range3, hint });
31283
31338
  }
31284
- function createScalePoint(key, channels, { align: align2 = 0.5, padding: padding2 = 0.5, ...options }) {
31285
- return maybeRound(point().align(align2).padding(padding2), channels, options, key);
31286
- }
31287
- function createScaleBand(key, channels, {
31288
- align: align2 = 0.5,
31289
- padding: padding2 = 0.1,
31290
- paddingInner = padding2,
31291
- paddingOuter = key === "fx" || key === "fy" ? 0 : padding2,
31292
- ...options
31293
- }) {
31294
- return maybeRound(
31295
- band().align(align2).paddingInner(paddingInner).paddingOuter(paddingOuter),
31296
- channels,
31297
- options,
31298
- key
31299
- );
31339
+ function formatScaleType(type2) {
31340
+ return typeof type2 === "symbol" ? type2.description : type2;
31300
31341
  }
31301
- function maybeRound(scale3, channels, options, key) {
31302
- let { round: round3 } = options;
31303
- if (round3 !== void 0)
31304
- scale3.round(round3 = !!round3);
31305
- scale3 = createScaleO(key, scale3, channels, options);
31306
- scale3.round = round3;
31307
- return scale3;
31342
+ function maybeScaleType(type2) {
31343
+ return typeof type2 === "string" ? `${type2}`.toLowerCase() : type2;
31308
31344
  }
31309
- function inferDomain2(channels, interval2, key) {
31310
- const values2 = new InternSet();
31311
- for (const { value, domain } of channels) {
31312
- if (domain !== void 0)
31313
- return domain();
31314
- if (value === void 0)
31345
+ var typeProjection = { toString: () => "projection" };
31346
+ function inferScaleType(key, channels, { type: type2, domain, range: range3, scheme: scheme28, pivot, projection: projection3 }) {
31347
+ type2 = maybeScaleType(type2);
31348
+ if (key === "fx" || key === "fy")
31349
+ return "band";
31350
+ if ((key === "x" || key === "y") && projection3 != null)
31351
+ type2 = typeProjection;
31352
+ for (const channel of channels) {
31353
+ const t = maybeScaleType(channel.type);
31354
+ if (t === void 0)
31315
31355
  continue;
31316
- for (const v2 of value)
31317
- values2.add(v2);
31356
+ else if (type2 === void 0)
31357
+ type2 = t;
31358
+ else if (type2 !== t)
31359
+ throw new Error(`scale incompatible with channel: ${type2} !== ${t}`);
31360
+ }
31361
+ if (type2 === typeProjection)
31362
+ return;
31363
+ if (type2 !== void 0)
31364
+ return type2;
31365
+ if (domain === void 0 && !channels.some(({ value }) => value !== void 0))
31366
+ return;
31367
+ const kind = registry.get(key);
31368
+ if (kind === radius)
31369
+ return "sqrt";
31370
+ if (kind === opacity || kind === length3)
31371
+ return "linear";
31372
+ if (kind === symbol)
31373
+ return "ordinal";
31374
+ if ((domain || range3 || []).length > 2)
31375
+ return asOrdinalType(kind);
31376
+ if (domain !== void 0) {
31377
+ if (isOrdinal(domain))
31378
+ return asOrdinalType(kind);
31379
+ if (isTemporal(domain))
31380
+ return "utc";
31381
+ } else {
31382
+ const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31383
+ if (values2.some(isOrdinal))
31384
+ return asOrdinalType(kind);
31385
+ if (values2.some(isTemporal))
31386
+ return "utc";
31387
+ }
31388
+ if (kind === color2) {
31389
+ if (pivot != null || isDivergingScheme(scheme28))
31390
+ return "diverging";
31391
+ if (isCategoricalScheme(scheme28))
31392
+ return "categorical";
31393
+ }
31394
+ return "linear";
31395
+ }
31396
+ function asOrdinalType(kind) {
31397
+ switch (kind) {
31398
+ case position:
31399
+ return "point";
31400
+ case color2:
31401
+ return ordinalImplicit;
31402
+ default:
31403
+ return "ordinal";
31318
31404
  }
31319
- if (interval2 !== void 0) {
31320
- const [min5, max4] = extent(values2).map(interval2.floor, interval2);
31321
- return interval2.range(min5, interval2.offset(max4));
31405
+ }
31406
+ function isOrdinalScale({ type: type2 }) {
31407
+ return type2 === "ordinal" || type2 === "point" || type2 === "band" || type2 === ordinalImplicit;
31408
+ }
31409
+ function isThresholdScale({ type: type2 }) {
31410
+ return type2 === "threshold";
31411
+ }
31412
+ function isBandScale({ type: type2 }) {
31413
+ return type2 === "point" || type2 === "band";
31414
+ }
31415
+ function isCollapsed(scale3) {
31416
+ if (scale3 === void 0)
31417
+ return true;
31418
+ const domain = scale3.domain();
31419
+ const value = scale3(domain[0]);
31420
+ for (let i = 1, n = domain.length; i < n; ++i) {
31421
+ if (scale3(domain[i]) - value) {
31422
+ return false;
31423
+ }
31322
31424
  }
31323
- if (values2.size > 1e4 && registry.get(key) === position) {
31324
- throw new Error(`implicit ordinal domain of ${key} scale has more than 10,000 values`);
31425
+ return true;
31426
+ }
31427
+ function coerceType(channels, { domain, ...options }, coerceValues) {
31428
+ for (const c4 of channels) {
31429
+ if (c4.value !== void 0) {
31430
+ if (domain === void 0)
31431
+ domain = c4.value?.domain;
31432
+ c4.value = coerceValues(c4.value);
31433
+ }
31325
31434
  }
31326
- return sort(values2, ascendingDefined2);
31435
+ return {
31436
+ domain: domain === void 0 ? domain : coerceValues(domain),
31437
+ ...options
31438
+ };
31327
31439
  }
31328
- function inferHint(channels, key) {
31329
- let value;
31330
- for (const { hint } of channels) {
31331
- const candidate = hint?.[key];
31332
- if (candidate === void 0)
31440
+ function coerceSymbols(values2) {
31441
+ return map2(values2, maybeSymbol);
31442
+ }
31443
+ function scale2(options = {}) {
31444
+ let scale3;
31445
+ for (const key in options) {
31446
+ if (!registry.has(key))
31333
31447
  continue;
31334
- if (value === void 0)
31335
- value = candidate;
31336
- else if (value !== candidate)
31337
- return;
31448
+ if (!isScaleOptions(options[key]))
31449
+ continue;
31450
+ if (scale3 !== void 0)
31451
+ throw new Error("ambiguous scale definition; multiple scales found");
31452
+ scale3 = exposeScale(normalizeScale(key, options[key]));
31338
31453
  }
31339
- return value;
31454
+ if (scale3 === void 0)
31455
+ throw new Error("invalid scale definition; no scale found");
31456
+ return scale3;
31340
31457
  }
31341
- function inferSymbolHint(channels) {
31342
- return {
31343
- fill: inferHint(channels, "fill"),
31344
- stroke: inferHint(channels, "stroke")
31458
+ function exposeScales(scales2) {
31459
+ return (key) => {
31460
+ if (!registry.has(key = `${key}`))
31461
+ throw new Error(`unknown scale: ${key}`);
31462
+ return scales2[key];
31345
31463
  };
31346
31464
  }
31347
- function inferSymbolRange(hint) {
31348
- return isNoneish(hint.fill) ? symbolsStroke : symbolsFill;
31465
+ function exposeScale({ scale: scale3, type: type2, domain, range: range3, interpolate, interval: interval2, transform: transform3, percent, pivot }) {
31466
+ if (type2 === "identity")
31467
+ return { type: "identity", apply: (d) => d, invert: (d) => d };
31468
+ const unknown = scale3.unknown ? scale3.unknown() : void 0;
31469
+ return {
31470
+ type: type2,
31471
+ domain: slice3(domain),
31472
+ // defensive copy
31473
+ ...range3 !== void 0 && { range: slice3(range3) },
31474
+ // defensive copy
31475
+ ...transform3 !== void 0 && { transform: transform3 },
31476
+ ...percent && { percent },
31477
+ // only exposed if truthy
31478
+ ...unknown !== void 0 && { unknown },
31479
+ ...interval2 !== void 0 && { interval: interval2 },
31480
+ // quantitative
31481
+ ...interpolate !== void 0 && { interpolate },
31482
+ ...scale3.clamp && { clamp: scale3.clamp() },
31483
+ // diverging (always asymmetric; we never want to apply the symmetric transform twice)
31484
+ ...pivot !== void 0 && { pivot, symmetric: false },
31485
+ // log, diverging-log
31486
+ ...scale3.base && { base: scale3.base() },
31487
+ // pow, diverging-pow
31488
+ ...scale3.exponent && { exponent: scale3.exponent() },
31489
+ // symlog, diverging-symlog
31490
+ ...scale3.constant && { constant: scale3.constant() },
31491
+ // band, point
31492
+ ...scale3.align && { align: scale3.align(), round: scale3.round() },
31493
+ ...scale3.padding && (scale3.paddingInner ? { paddingInner: scale3.paddingInner(), paddingOuter: scale3.paddingOuter() } : { padding: scale3.padding() }),
31494
+ ...scale3.bandwidth && { bandwidth: scale3.bandwidth(), step: scale3.step() },
31495
+ // utilities
31496
+ apply: (t) => scale3(t),
31497
+ ...scale3.invert && { invert: (t) => scale3.invert(t) }
31498
+ };
31349
31499
  }
31350
31500
 
31351
- // ../../node_modules/@observablehq/plot/src/scales.js
31352
- function createScales(channelsByScale, {
31353
- label: globalLabel,
31354
- inset: globalInset = 0,
31355
- insetTop: globalInsetTop = globalInset,
31356
- insetRight: globalInsetRight = globalInset,
31357
- insetBottom: globalInsetBottom = globalInset,
31358
- insetLeft: globalInsetLeft = globalInset,
31359
- round: round3,
31360
- nice: nice3,
31361
- clamp,
31362
- zero: zero3,
31363
- align: align2,
31364
- padding: padding2,
31365
- projection: projection3,
31366
- facet: { label: facetLabel2 = globalLabel } = {},
31367
- ...options
31368
- } = {}) {
31369
- const scales2 = {};
31370
- for (const [key, channels] of channelsByScale) {
31371
- const scaleOptions = options[key];
31372
- const scale3 = createScale(key, channels, {
31373
- round: registry.get(key) === position ? round3 : void 0,
31374
- // only for position
31375
- nice: nice3,
31376
- clamp,
31377
- zero: zero3,
31378
- align: align2,
31379
- padding: padding2,
31380
- projection: projection3,
31381
- ...scaleOptions
31382
- });
31383
- if (scale3) {
31384
- let {
31385
- label: label2 = key === "fx" || key === "fy" ? facetLabel2 : globalLabel,
31386
- percent,
31387
- transform: transform3,
31388
- inset: inset2,
31389
- insetTop = inset2 !== void 0 ? inset2 : key === "y" ? globalInsetTop : 0,
31390
- // not fy
31391
- insetRight = inset2 !== void 0 ? inset2 : key === "x" ? globalInsetRight : 0,
31392
- // not fx
31393
- insetBottom = inset2 !== void 0 ? inset2 : key === "y" ? globalInsetBottom : 0,
31394
- // not fy
31395
- insetLeft = inset2 !== void 0 ? inset2 : key === "x" ? globalInsetLeft : 0
31396
- // not fx
31397
- } = scaleOptions || {};
31398
- if (transform3 == null)
31399
- transform3 = void 0;
31400
- else if (typeof transform3 !== "function")
31401
- throw new Error("invalid scale transform; not a function");
31402
- scale3.percent = !!percent;
31403
- scale3.label = label2 === void 0 ? inferScaleLabel(channels, scale3) : label2;
31404
- scale3.transform = transform3;
31405
- if (key === "x" || key === "fx") {
31406
- scale3.insetLeft = +insetLeft;
31407
- scale3.insetRight = +insetRight;
31408
- } else if (key === "y" || key === "fy") {
31409
- scale3.insetTop = +insetTop;
31410
- scale3.insetBottom = +insetBottom;
31411
- }
31412
- scales2[key] = scale3;
31501
+ // ../../node_modules/@observablehq/plot/src/memoize.js
31502
+ function memoize1(compute) {
31503
+ let cacheValue, cacheKeys;
31504
+ return (...keys) => {
31505
+ if (cacheKeys?.length !== keys.length || cacheKeys.some((k2, i) => k2 !== keys[i])) {
31506
+ cacheKeys = keys;
31507
+ cacheValue = compute(...keys);
31413
31508
  }
31509
+ return cacheValue;
31510
+ };
31511
+ }
31512
+
31513
+ // ../../node_modules/@observablehq/plot/src/format.js
31514
+ var numberFormat = memoize1((locale3) => {
31515
+ return new Intl.NumberFormat(locale3);
31516
+ });
31517
+ var monthFormat = memoize1((locale3, month) => {
31518
+ return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...month && { month } });
31519
+ });
31520
+ var weekdayFormat = memoize1((locale3, weekday) => {
31521
+ return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...weekday && { weekday } });
31522
+ });
31523
+ function formatNumber(locale3 = "en-US") {
31524
+ const format3 = numberFormat(locale3);
31525
+ return (i) => i != null && !isNaN(i) ? format3.format(i) : void 0;
31526
+ }
31527
+ function formatMonth(locale3 = "en-US", format3 = "short") {
31528
+ const fmt = monthFormat(locale3, format3);
31529
+ return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? fmt.format(i) : void 0;
31530
+ }
31531
+ function formatWeekday(locale3 = "en-US", format3 = "short") {
31532
+ const fmt = weekdayFormat(locale3, format3);
31533
+ return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? fmt.format(i) : void 0;
31534
+ }
31535
+ function formatIsoDate(date2) {
31536
+ return format2(date2, "Invalid Date");
31537
+ }
31538
+ function formatAuto(locale3 = "en-US") {
31539
+ const number7 = formatNumber(locale3);
31540
+ return (v2) => (v2 instanceof Date ? formatIsoDate : typeof v2 === "number" ? number7 : string)(v2);
31541
+ }
31542
+ var formatDefault = formatAuto();
31543
+
31544
+ // ../../node_modules/@observablehq/plot/src/style.js
31545
+ var offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5;
31546
+ var nextClipId = 0;
31547
+ function getClipId() {
31548
+ return `plot-clip-${++nextClipId}`;
31549
+ }
31550
+ function styles(mark2, {
31551
+ title,
31552
+ href,
31553
+ ariaLabel: variaLabel,
31554
+ ariaDescription,
31555
+ ariaHidden,
31556
+ target,
31557
+ fill,
31558
+ fillOpacity,
31559
+ stroke,
31560
+ strokeWidth,
31561
+ strokeOpacity,
31562
+ strokeLinejoin,
31563
+ strokeLinecap,
31564
+ strokeMiterlimit,
31565
+ strokeDasharray,
31566
+ strokeDashoffset,
31567
+ opacity: opacity2,
31568
+ mixBlendMode,
31569
+ imageFilter,
31570
+ paintOrder,
31571
+ pointerEvents,
31572
+ shapeRendering,
31573
+ channels
31574
+ }, {
31575
+ ariaLabel: cariaLabel,
31576
+ fill: defaultFill = "currentColor",
31577
+ fillOpacity: defaultFillOpacity,
31578
+ stroke: defaultStroke = "none",
31579
+ strokeOpacity: defaultStrokeOpacity,
31580
+ strokeWidth: defaultStrokeWidth,
31581
+ strokeLinecap: defaultStrokeLinecap,
31582
+ strokeLinejoin: defaultStrokeLinejoin,
31583
+ strokeMiterlimit: defaultStrokeMiterlimit,
31584
+ paintOrder: defaultPaintOrder
31585
+ }) {
31586
+ if (defaultFill === null) {
31587
+ fill = null;
31588
+ fillOpacity = null;
31414
31589
  }
31415
- return scales2;
31416
- }
31417
- function createScaleFunctions(descriptors) {
31418
- const scales2 = {};
31419
- const scaleFunctions = { scales: scales2 };
31420
- for (const [key, descriptor] of Object.entries(descriptors)) {
31421
- const { scale: scale3, type: type2, interval: interval2, label: label2 } = descriptor;
31422
- scales2[key] = exposeScale(descriptor);
31423
- scaleFunctions[key] = scale3;
31424
- scale3.type = type2;
31425
- if (interval2 != null)
31426
- scale3.interval = interval2;
31427
- if (label2 != null)
31428
- scale3.label = label2;
31590
+ if (defaultStroke === null) {
31591
+ stroke = null;
31592
+ strokeOpacity = null;
31429
31593
  }
31430
- return scaleFunctions;
31431
- }
31432
- function autoScaleRange(scales2, dimensions) {
31433
- const { x: x3, y: y3, fx, fy } = scales2;
31434
- const superdimensions = fx || fy ? outerDimensions(dimensions) : dimensions;
31435
- if (fx)
31436
- autoScaleRangeX(fx, superdimensions);
31437
- if (fy)
31438
- autoScaleRangeY(fy, superdimensions);
31439
- const subdimensions = fx || fy ? innerDimensions(scales2, dimensions) : dimensions;
31440
- if (x3)
31441
- autoScaleRangeX(x3, subdimensions);
31442
- if (y3)
31443
- autoScaleRangeY(y3, subdimensions);
31444
- }
31445
- function inferScaleLabel(channels = [], scale3) {
31446
- let label2;
31447
- for (const { label: l } of channels) {
31448
- if (l === void 0)
31449
- continue;
31450
- if (label2 === void 0)
31451
- label2 = l;
31452
- else if (label2 !== l)
31453
- return;
31594
+ if (isNoneish(defaultFill)) {
31595
+ if (!isNoneish(defaultStroke) && (!isNoneish(fill) || channels?.fill))
31596
+ defaultStroke = "none";
31597
+ } else {
31598
+ if (isNoneish(defaultStroke) && (!isNoneish(stroke) || channels?.stroke))
31599
+ defaultFill = "none";
31454
31600
  }
31455
- if (label2 === void 0)
31456
- return;
31457
- if (!isOrdinalScale(scale3) && scale3.percent)
31458
- label2 = `${label2} (%)`;
31459
- return { inferred: true, toString: () => label2 };
31460
- }
31461
- function inferScaleOrder(scale3) {
31462
- return Math.sign(orderof(scale3.domain())) * Math.sign(orderof(scale3.range()));
31463
- }
31464
- function outerDimensions(dimensions) {
31465
- const {
31466
- marginTop: marginTop2,
31467
- marginRight: marginRight2,
31468
- marginBottom: marginBottom2,
31469
- marginLeft: marginLeft2,
31470
- width: width2,
31471
- height: height2,
31472
- facet: {
31473
- marginTop: facetMarginTop2,
31474
- marginRight: facetMarginRight2,
31475
- marginBottom: facetMarginBottom2,
31476
- marginLeft: facetMarginLeft2
31477
- }
31478
- } = dimensions;
31601
+ const [vfill, cfill] = maybeColorChannel(fill, defaultFill);
31602
+ const [vfillOpacity, cfillOpacity] = maybeNumberChannel(fillOpacity, defaultFillOpacity);
31603
+ const [vstroke, cstroke] = maybeColorChannel(stroke, defaultStroke);
31604
+ const [vstrokeOpacity, cstrokeOpacity] = maybeNumberChannel(strokeOpacity, defaultStrokeOpacity);
31605
+ const [vopacity, copacity] = maybeNumberChannel(opacity2);
31606
+ if (!isNone(cstroke)) {
31607
+ if (strokeWidth === void 0)
31608
+ strokeWidth = defaultStrokeWidth;
31609
+ if (strokeLinecap === void 0)
31610
+ strokeLinecap = defaultStrokeLinecap;
31611
+ if (strokeLinejoin === void 0)
31612
+ strokeLinejoin = defaultStrokeLinejoin;
31613
+ if (strokeMiterlimit === void 0 && !isRound(strokeLinejoin))
31614
+ strokeMiterlimit = defaultStrokeMiterlimit;
31615
+ if (!isNone(cfill) && paintOrder === void 0)
31616
+ paintOrder = defaultPaintOrder;
31617
+ }
31618
+ const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);
31619
+ if (defaultFill !== null) {
31620
+ mark2.fill = impliedString(cfill, "currentColor");
31621
+ mark2.fillOpacity = impliedNumber(cfillOpacity, 1);
31622
+ }
31623
+ if (defaultStroke !== null) {
31624
+ mark2.stroke = impliedString(cstroke, "none");
31625
+ mark2.strokeWidth = impliedNumber(cstrokeWidth, 1);
31626
+ mark2.strokeOpacity = impliedNumber(cstrokeOpacity, 1);
31627
+ mark2.strokeLinejoin = impliedString(strokeLinejoin, "miter");
31628
+ mark2.strokeLinecap = impliedString(strokeLinecap, "butt");
31629
+ mark2.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
31630
+ mark2.strokeDasharray = impliedString(strokeDasharray, "none");
31631
+ mark2.strokeDashoffset = impliedString(strokeDashoffset, "0");
31632
+ }
31633
+ mark2.target = string(target);
31634
+ mark2.ariaLabel = string(cariaLabel);
31635
+ mark2.ariaDescription = string(ariaDescription);
31636
+ mark2.ariaHidden = string(ariaHidden);
31637
+ mark2.opacity = impliedNumber(copacity, 1);
31638
+ mark2.mixBlendMode = impliedString(mixBlendMode, "normal");
31639
+ mark2.imageFilter = impliedString(imageFilter, "none");
31640
+ mark2.paintOrder = impliedString(paintOrder, "normal");
31641
+ mark2.pointerEvents = impliedString(pointerEvents, "auto");
31642
+ mark2.shapeRendering = impliedString(shapeRendering, "auto");
31479
31643
  return {
31480
- marginTop: Math.max(marginTop2, facetMarginTop2),
31481
- marginRight: Math.max(marginRight2, facetMarginRight2),
31482
- marginBottom: Math.max(marginBottom2, facetMarginBottom2),
31483
- marginLeft: Math.max(marginLeft2, facetMarginLeft2),
31484
- width: width2,
31485
- height: height2
31644
+ title: { value: title, optional: true, filter: null },
31645
+ href: { value: href, optional: true, filter: null },
31646
+ ariaLabel: { value: variaLabel, optional: true, filter: null },
31647
+ fill: { value: vfill, scale: "auto", optional: true },
31648
+ fillOpacity: { value: vfillOpacity, scale: "auto", optional: true },
31649
+ stroke: { value: vstroke, scale: "auto", optional: true },
31650
+ strokeOpacity: { value: vstrokeOpacity, scale: "auto", optional: true },
31651
+ strokeWidth: { value: vstrokeWidth, optional: true },
31652
+ opacity: { value: vopacity, scale: "auto", optional: true }
31486
31653
  };
31487
31654
  }
31488
- function innerDimensions({ fx, fy }, dimensions) {
31489
- const { marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2, width: width2, height: height2 } = outerDimensions(dimensions);
31490
- return {
31491
- marginTop: marginTop2,
31492
- marginRight: marginRight2,
31493
- marginBottom: marginBottom2,
31494
- marginLeft: marginLeft2,
31495
- width: fx ? fx.scale.bandwidth() + marginLeft2 + marginRight2 : width2,
31496
- height: fy ? fy.scale.bandwidth() + marginTop2 + marginBottom2 : height2,
31497
- facet: { width: width2, height: height2 }
31498
- };
31655
+ function applyTitle(selection2, L) {
31656
+ if (L)
31657
+ selection2.filter((i) => nonempty(L[i])).append("title").call(applyText, L);
31499
31658
  }
31500
- function autoScaleRangeX(scale3, dimensions) {
31501
- if (scale3.range === void 0) {
31502
- const { insetLeft, insetRight } = scale3;
31503
- const { width: width2, marginLeft: marginLeft2 = 0, marginRight: marginRight2 = 0 } = dimensions;
31504
- const left2 = marginLeft2 + insetLeft;
31505
- const right2 = width2 - marginRight2 - insetRight;
31506
- scale3.range = [left2, Math.max(left2, right2)];
31507
- if (!isOrdinalScale(scale3))
31508
- scale3.range = piecewiseRange(scale3);
31509
- scale3.scale.range(scale3.range);
31510
- }
31511
- autoScaleRound(scale3);
31659
+ function applyTitleGroup(selection2, L) {
31660
+ if (L)
31661
+ selection2.filter(([i]) => nonempty(L[i])).append("title").call(applyTextGroup, L);
31512
31662
  }
31513
- function autoScaleRangeY(scale3, dimensions) {
31514
- if (scale3.range === void 0) {
31515
- const { insetTop, insetBottom } = scale3;
31516
- const { height: height2, marginTop: marginTop2 = 0, marginBottom: marginBottom2 = 0 } = dimensions;
31517
- const top2 = marginTop2 + insetTop;
31518
- const bottom2 = height2 - marginBottom2 - insetBottom;
31519
- scale3.range = [Math.max(top2, bottom2), top2];
31520
- if (!isOrdinalScale(scale3))
31521
- scale3.range = piecewiseRange(scale3);
31522
- else
31523
- scale3.range.reverse();
31524
- scale3.scale.range(scale3.range);
31525
- }
31526
- autoScaleRound(scale3);
31663
+ function applyText(selection2, T) {
31664
+ if (T)
31665
+ selection2.text((i) => formatDefault(T[i]));
31527
31666
  }
31528
- function autoScaleRound(scale3) {
31529
- if (scale3.round === void 0 && isBandScale(scale3) && roundError(scale3) <= 30) {
31530
- scale3.scale.round(true);
31531
- }
31667
+ function applyTextGroup(selection2, T) {
31668
+ if (T)
31669
+ selection2.text(([i]) => formatDefault(T[i]));
31532
31670
  }
31533
- function roundError({ scale: scale3 }) {
31534
- const n = scale3.domain().length;
31535
- const [start2, stop] = scale3.range();
31536
- const paddingInner = scale3.paddingInner ? scale3.paddingInner() : 1;
31537
- const paddingOuter = scale3.paddingOuter ? scale3.paddingOuter() : scale3.padding();
31538
- const m = n - paddingInner;
31539
- const step = Math.abs(stop - start2) / Math.max(1, m + paddingOuter * 2);
31540
- return (step - Math.floor(step)) * m;
31671
+ function applyChannelStyles(selection2, { target, tip: tip2 }, {
31672
+ ariaLabel: AL,
31673
+ title: T,
31674
+ fill: F,
31675
+ fillOpacity: FO,
31676
+ stroke: S,
31677
+ strokeOpacity: SO,
31678
+ strokeWidth: SW,
31679
+ opacity: O,
31680
+ href: H
31681
+ }) {
31682
+ if (AL)
31683
+ applyAttr(selection2, "aria-label", (i) => AL[i]);
31684
+ if (F)
31685
+ applyAttr(selection2, "fill", (i) => F[i]);
31686
+ if (FO)
31687
+ applyAttr(selection2, "fill-opacity", (i) => FO[i]);
31688
+ if (S)
31689
+ applyAttr(selection2, "stroke", (i) => S[i]);
31690
+ if (SO)
31691
+ applyAttr(selection2, "stroke-opacity", (i) => SO[i]);
31692
+ if (SW)
31693
+ applyAttr(selection2, "stroke-width", (i) => SW[i]);
31694
+ if (O)
31695
+ applyAttr(selection2, "opacity", (i) => O[i]);
31696
+ if (H)
31697
+ applyHref(selection2, (i) => H[i], target);
31698
+ if (!tip2)
31699
+ applyTitle(selection2, T);
31541
31700
  }
31542
- function piecewiseRange(scale3) {
31543
- const length4 = scale3.scale.domain().length + isThresholdScale(scale3);
31544
- if (!(length4 > 2))
31545
- return scale3.range;
31546
- const [start2, end] = scale3.range;
31547
- return Array.from({ length: length4 }, (_, i) => start2 + i / (length4 - 1) * (end - start2));
31701
+ function applyGroupedChannelStyles(selection2, { target, tip: tip2 }, {
31702
+ ariaLabel: AL,
31703
+ title: T,
31704
+ fill: F,
31705
+ fillOpacity: FO,
31706
+ stroke: S,
31707
+ strokeOpacity: SO,
31708
+ strokeWidth: SW,
31709
+ opacity: O,
31710
+ href: H
31711
+ }) {
31712
+ if (AL)
31713
+ applyAttr(selection2, "aria-label", ([i]) => AL[i]);
31714
+ if (F)
31715
+ applyAttr(selection2, "fill", ([i]) => F[i]);
31716
+ if (FO)
31717
+ applyAttr(selection2, "fill-opacity", ([i]) => FO[i]);
31718
+ if (S)
31719
+ applyAttr(selection2, "stroke", ([i]) => S[i]);
31720
+ if (SO)
31721
+ applyAttr(selection2, "stroke-opacity", ([i]) => SO[i]);
31722
+ if (SW)
31723
+ applyAttr(selection2, "stroke-width", ([i]) => SW[i]);
31724
+ if (O)
31725
+ applyAttr(selection2, "opacity", ([i]) => O[i]);
31726
+ if (H)
31727
+ applyHref(selection2, ([i]) => H[i], target);
31728
+ if (!tip2)
31729
+ applyTitleGroup(selection2, T);
31548
31730
  }
31549
- function normalizeScale(key, scale3, hint) {
31550
- return createScale(key, hint === void 0 ? void 0 : [{ hint }], { ...scale3 });
31731
+ function groupAesthetics({
31732
+ ariaLabel: AL,
31733
+ title: T,
31734
+ fill: F,
31735
+ fillOpacity: FO,
31736
+ stroke: S,
31737
+ strokeOpacity: SO,
31738
+ strokeWidth: SW,
31739
+ opacity: O,
31740
+ href: H
31741
+ }, { tip: tip2 }) {
31742
+ return [AL, tip2 ? void 0 : T, F, FO, S, SO, SW, O, H].filter((c4) => c4 !== void 0);
31551
31743
  }
31552
- function createScale(key, channels = [], options = {}) {
31553
- const type2 = inferScaleType(key, channels, options);
31554
- if (options.type === void 0 && options.domain === void 0 && options.range === void 0 && options.interval == null && key !== "fx" && key !== "fy" && isOrdinalScale({ type: type2 })) {
31555
- const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31556
- if (values2.some(isTemporal))
31557
- warn(
31558
- `Warning: some data associated with the ${key} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31559
- type2
31560
- )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31561
- type2
31562
- )}".`
31563
- );
31564
- else if (values2.some(isTemporalString))
31565
- warn(
31566
- `Warning: some data associated with the ${key} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31567
- type2
31568
- )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31569
- type2
31570
- )}".`
31571
- );
31572
- else if (values2.some(isNumericString))
31573
- warn(
31574
- `Warning: some data associated with the ${key} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${formatScaleType(
31575
- type2
31576
- )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31577
- type2
31578
- )}".`
31579
- );
31744
+ function groupZ2(I, Z, z) {
31745
+ const G = group(I, (i) => Z[i]);
31746
+ if (z === void 0 && G.size > 1 + I.length >> 1) {
31747
+ warn(
31748
+ `Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null.`
31749
+ );
31580
31750
  }
31581
- options.type = type2;
31582
- switch (type2) {
31583
- case "diverging":
31584
- case "diverging-sqrt":
31585
- case "diverging-pow":
31586
- case "diverging-log":
31587
- case "diverging-symlog":
31588
- case "cyclical":
31589
- case "sequential":
31590
- case "linear":
31591
- case "sqrt":
31592
- case "threshold":
31593
- case "quantile":
31594
- case "pow":
31595
- case "log":
31596
- case "symlog":
31597
- options = coerceType(channels, options, coerceNumbers);
31598
- break;
31599
- case "identity":
31600
- switch (registry.get(key)) {
31601
- case position:
31602
- options = coerceType(channels, options, coerceNumbers);
31603
- break;
31604
- case symbol:
31605
- options = coerceType(channels, options, coerceSymbols);
31606
- break;
31751
+ return G.values();
31752
+ }
31753
+ function* groupIndex(I, position3, mark2, channels) {
31754
+ const { z } = mark2;
31755
+ const { z: Z } = channels;
31756
+ const A5 = groupAesthetics(channels, mark2);
31757
+ const C3 = [...position3, ...A5];
31758
+ for (const G of Z ? groupZ2(I, Z, z) : [I]) {
31759
+ let Ag;
31760
+ let Gg;
31761
+ out:
31762
+ for (const i of G) {
31763
+ for (const c4 of C3) {
31764
+ if (!defined(c4[i])) {
31765
+ if (Gg)
31766
+ Gg.push(-1);
31767
+ continue out;
31768
+ }
31769
+ }
31770
+ if (Ag === void 0) {
31771
+ if (Gg)
31772
+ yield Gg;
31773
+ Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
31774
+ continue;
31775
+ }
31776
+ Gg.push(i);
31777
+ for (let j = 0; j < A5.length; ++j) {
31778
+ const k2 = keyof2(A5[j][i]);
31779
+ if (k2 !== Ag[j]) {
31780
+ yield Gg;
31781
+ Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
31782
+ continue out;
31783
+ }
31784
+ }
31607
31785
  }
31786
+ if (Gg)
31787
+ yield Gg;
31788
+ }
31789
+ }
31790
+ function applyClip(selection2, mark2, dimensions, context) {
31791
+ let clipUrl;
31792
+ const { clip = context.clip } = mark2;
31793
+ switch (clip) {
31794
+ case "frame": {
31795
+ const { width: width2, height: height2, marginLeft: marginLeft2, marginRight: marginRight2, marginTop: marginTop2, marginBottom: marginBottom2 } = dimensions;
31796
+ const id2 = getClipId();
31797
+ clipUrl = `url(#${id2})`;
31798
+ selection2 = create3("svg:g", context).call(
31799
+ (g) => g.append("svg:clipPath").attr("id", id2).append("rect").attr("x", marginLeft2).attr("y", marginTop2).attr("width", width2 - marginRight2 - marginLeft2).attr("height", height2 - marginTop2 - marginBottom2)
31800
+ ).each(function() {
31801
+ this.appendChild(selection2.node());
31802
+ selection2.node = () => this;
31803
+ });
31608
31804
  break;
31609
- case "utc":
31610
- case "time":
31611
- options = coerceType(channels, options, coerceDates);
31805
+ }
31806
+ case "sphere": {
31807
+ const { projection: projection3 } = context;
31808
+ if (!projection3)
31809
+ throw new Error(`the "sphere" clip option requires a projection`);
31810
+ const id2 = getClipId();
31811
+ clipUrl = `url(#${id2})`;
31812
+ selection2.append("clipPath").attr("id", id2).append("path").attr("d", path_default(projection3)({ type: "Sphere" }));
31612
31813
  break;
31814
+ }
31613
31815
  }
31614
- switch (type2) {
31615
- case "diverging":
31616
- return createScaleDiverging(key, channels, options);
31617
- case "diverging-sqrt":
31618
- return createScaleDivergingSqrt(key, channels, options);
31619
- case "diverging-pow":
31620
- return createScaleDivergingPow(key, channels, options);
31621
- case "diverging-log":
31622
- return createScaleDivergingLog(key, channels, options);
31623
- case "diverging-symlog":
31624
- return createScaleDivergingSymlog(key, channels, options);
31625
- case "categorical":
31626
- case "ordinal":
31627
- case ordinalImplicit:
31628
- return createScaleOrdinal(key, channels, options);
31629
- case "cyclical":
31630
- case "sequential":
31631
- case "linear":
31632
- return createScaleLinear(key, channels, options);
31633
- case "sqrt":
31634
- return createScaleSqrt(key, channels, options);
31635
- case "threshold":
31636
- return createScaleThreshold(key, channels, options);
31637
- case "quantile":
31638
- return createScaleQuantile(key, channels, options);
31639
- case "quantize":
31640
- return createScaleQuantize(key, channels, options);
31641
- case "pow":
31642
- return createScalePow(key, channels, options);
31643
- case "log":
31644
- return createScaleLog(key, channels, options);
31645
- case "symlog":
31646
- return createScaleSymlog(key, channels, options);
31647
- case "utc":
31648
- return createScaleUtc(key, channels, options);
31649
- case "time":
31650
- return createScaleTime(key, channels, options);
31651
- case "point":
31652
- return createScalePoint(key, channels, options);
31653
- case "band":
31654
- return createScaleBand(key, channels, options);
31655
- case "identity":
31656
- return createScaleIdentity(key);
31657
- case void 0:
31658
- return;
31659
- default:
31660
- throw new Error(`unknown scale type: ${type2}`);
31661
- }
31662
- }
31663
- function formatScaleType(type2) {
31664
- return typeof type2 === "symbol" ? type2.description : type2;
31665
- }
31666
- function maybeScaleType(type2) {
31667
- return typeof type2 === "string" ? `${type2}`.toLowerCase() : type2;
31816
+ applyAttr(selection2, "aria-label", mark2.ariaLabel);
31817
+ applyAttr(selection2, "aria-description", mark2.ariaDescription);
31818
+ applyAttr(selection2, "aria-hidden", mark2.ariaHidden);
31819
+ applyAttr(selection2, "clip-path", clipUrl);
31668
31820
  }
31669
- var typeProjection = { toString: () => "projection" };
31670
- function inferScaleType(key, channels, { type: type2, domain, range: range3, scheme: scheme28, pivot, projection: projection3 }) {
31671
- type2 = maybeScaleType(type2);
31672
- if (key === "fx" || key === "fy")
31673
- return "band";
31674
- if ((key === "x" || key === "y") && projection3 != null)
31675
- type2 = typeProjection;
31676
- for (const channel of channels) {
31677
- const t = maybeScaleType(channel.type);
31678
- if (t === void 0)
31679
- continue;
31680
- else if (type2 === void 0)
31681
- type2 = t;
31682
- else if (type2 !== t)
31683
- throw new Error(`scale incompatible with channel: ${type2} !== ${t}`);
31684
- }
31685
- if (type2 === typeProjection)
31686
- return;
31687
- if (type2 !== void 0)
31688
- return type2;
31689
- if (domain === void 0 && !channels.some(({ value }) => value !== void 0))
31690
- return;
31691
- const kind = registry.get(key);
31692
- if (kind === radius)
31693
- return "sqrt";
31694
- if (kind === opacity || kind === length3)
31695
- return "linear";
31696
- if (kind === symbol)
31697
- return "ordinal";
31698
- if ((domain || range3 || []).length > 2)
31699
- return asOrdinalType(kind);
31700
- if (domain !== void 0) {
31701
- if (isOrdinal(domain))
31702
- return asOrdinalType(kind);
31703
- if (isTemporal(domain))
31704
- return "utc";
31705
- } else {
31706
- const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31707
- if (values2.some(isOrdinal))
31708
- return asOrdinalType(kind);
31709
- if (values2.some(isTemporal))
31710
- return "utc";
31711
- }
31712
- if (kind === color2) {
31713
- if (pivot != null || isDivergingScheme(scheme28))
31714
- return "diverging";
31715
- if (isCategoricalScheme(scheme28))
31716
- return "categorical";
31717
- }
31718
- return "linear";
31821
+ function applyIndirectStyles(selection2, mark2, dimensions, context) {
31822
+ applyClip(selection2, mark2, dimensions, context);
31823
+ applyAttr(selection2, "fill", mark2.fill);
31824
+ applyAttr(selection2, "fill-opacity", mark2.fillOpacity);
31825
+ applyAttr(selection2, "stroke", mark2.stroke);
31826
+ applyAttr(selection2, "stroke-width", mark2.strokeWidth);
31827
+ applyAttr(selection2, "stroke-opacity", mark2.strokeOpacity);
31828
+ applyAttr(selection2, "stroke-linejoin", mark2.strokeLinejoin);
31829
+ applyAttr(selection2, "stroke-linecap", mark2.strokeLinecap);
31830
+ applyAttr(selection2, "stroke-miterlimit", mark2.strokeMiterlimit);
31831
+ applyAttr(selection2, "stroke-dasharray", mark2.strokeDasharray);
31832
+ applyAttr(selection2, "stroke-dashoffset", mark2.strokeDashoffset);
31833
+ applyAttr(selection2, "shape-rendering", mark2.shapeRendering);
31834
+ applyAttr(selection2, "filter", mark2.imageFilter);
31835
+ applyAttr(selection2, "paint-order", mark2.paintOrder);
31836
+ const { pointerEvents = context.pointerSticky === false ? "none" : void 0 } = mark2;
31837
+ applyAttr(selection2, "pointer-events", pointerEvents);
31719
31838
  }
31720
- function asOrdinalType(kind) {
31721
- switch (kind) {
31722
- case position:
31723
- return "point";
31724
- case color2:
31725
- return ordinalImplicit;
31726
- default:
31727
- return "ordinal";
31728
- }
31839
+ function applyDirectStyles(selection2, mark2) {
31840
+ applyStyle(selection2, "mix-blend-mode", mark2.mixBlendMode);
31841
+ applyAttr(selection2, "opacity", mark2.opacity);
31729
31842
  }
31730
- function isOrdinalScale({ type: type2 }) {
31731
- return type2 === "ordinal" || type2 === "point" || type2 === "band" || type2 === ordinalImplicit;
31843
+ function applyHref(selection2, href, target) {
31844
+ selection2.each(function(i) {
31845
+ const h = href(i);
31846
+ if (h != null) {
31847
+ const a2 = this.ownerDocument.createElementNS(namespaces_default.svg, "a");
31848
+ a2.setAttribute("fill", "inherit");
31849
+ a2.setAttributeNS(namespaces_default.xlink, "href", h);
31850
+ if (target != null)
31851
+ a2.setAttribute("target", target);
31852
+ this.parentNode.insertBefore(a2, this).appendChild(this);
31853
+ }
31854
+ });
31732
31855
  }
31733
- function isThresholdScale({ type: type2 }) {
31734
- return type2 === "threshold";
31856
+ function applyAttr(selection2, name2, value) {
31857
+ if (value != null)
31858
+ selection2.attr(name2, value);
31735
31859
  }
31736
- function isBandScale({ type: type2 }) {
31737
- return type2 === "point" || type2 === "band";
31860
+ function applyStyle(selection2, name2, value) {
31861
+ if (value != null)
31862
+ selection2.style(name2, value);
31738
31863
  }
31739
- function isCollapsed(scale3) {
31740
- if (scale3 === void 0)
31741
- return true;
31742
- const domain = scale3.domain();
31743
- const value = scale3(domain[0]);
31744
- for (let i = 1, n = domain.length; i < n; ++i) {
31745
- if (scale3(domain[i]) - value) {
31746
- return false;
31747
- }
31748
- }
31749
- return true;
31864
+ function applyTransform(selection2, mark2, { x: x3, y: y3 }, tx = offset, ty = offset) {
31865
+ tx += mark2.dx;
31866
+ ty += mark2.dy;
31867
+ if (x3?.bandwidth)
31868
+ tx += x3.bandwidth() / 2;
31869
+ if (y3?.bandwidth)
31870
+ ty += y3.bandwidth() / 2;
31871
+ if (tx || ty)
31872
+ selection2.attr("transform", `translate(${tx},${ty})`);
31750
31873
  }
31751
- function coerceType(channels, { domain, ...options }, coerceValues) {
31752
- for (const c4 of channels) {
31753
- if (c4.value !== void 0) {
31754
- if (domain === void 0)
31755
- domain = c4.value?.domain;
31756
- c4.value = coerceValues(c4.value);
31757
- }
31758
- }
31759
- return {
31760
- domain: domain === void 0 ? domain : coerceValues(domain),
31761
- ...options
31762
- };
31874
+ function impliedString(value, impliedValue) {
31875
+ if ((value = string(value)) !== impliedValue)
31876
+ return value;
31763
31877
  }
31764
- function coerceSymbols(values2) {
31765
- return map2(values2, maybeSymbol);
31878
+ function impliedNumber(value, impliedValue) {
31879
+ if ((value = number5(value)) !== impliedValue)
31880
+ return value;
31766
31881
  }
31767
- function scale2(options = {}) {
31768
- let scale3;
31769
- for (const key in options) {
31770
- if (!registry.has(key))
31771
- continue;
31772
- if (!isScaleOptions(options[key]))
31773
- continue;
31774
- if (scale3 !== void 0)
31775
- throw new Error("ambiguous scale definition; multiple scales found");
31776
- scale3 = exposeScale(normalizeScale(key, options[key]));
31777
- }
31778
- if (scale3 === void 0)
31779
- throw new Error("invalid scale definition; no scale found");
31780
- return scale3;
31882
+ var validClassName = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;
31883
+ function maybeClassName(name2) {
31884
+ if (name2 === void 0)
31885
+ return "plot-d6a7b5";
31886
+ name2 = `${name2}`;
31887
+ if (!validClassName.test(name2))
31888
+ throw new Error(`invalid class name: ${name2}`);
31889
+ return name2;
31781
31890
  }
31782
- function exposeScales(scales2) {
31783
- return (key) => {
31784
- if (!registry.has(key = `${key}`))
31785
- throw new Error(`unknown scale: ${key}`);
31786
- return scales2[key];
31787
- };
31891
+ function applyInlineStyles(selection2, style2) {
31892
+ if (typeof style2 === "string") {
31893
+ selection2.property("style", style2);
31894
+ } else if (style2 != null) {
31895
+ for (const element of selection2) {
31896
+ Object.assign(element.style, style2);
31897
+ }
31898
+ }
31788
31899
  }
31789
- function exposeScale({ scale: scale3, type: type2, domain, range: range3, interpolate, interval: interval2, transform: transform3, percent, pivot }) {
31790
- if (type2 === "identity")
31791
- return { type: "identity", apply: (d) => d, invert: (d) => d };
31792
- const unknown = scale3.unknown ? scale3.unknown() : void 0;
31793
- return {
31794
- type: type2,
31795
- domain: slice3(domain),
31796
- // defensive copy
31797
- ...range3 !== void 0 && { range: slice3(range3) },
31798
- // defensive copy
31799
- ...transform3 !== void 0 && { transform: transform3 },
31800
- ...percent && { percent },
31801
- // only exposed if truthy
31802
- ...unknown !== void 0 && { unknown },
31803
- ...interval2 !== void 0 && { interval: interval2 },
31804
- // quantitative
31805
- ...interpolate !== void 0 && { interpolate },
31806
- ...scale3.clamp && { clamp: scale3.clamp() },
31807
- // diverging (always asymmetric; we never want to apply the symmetric transform twice)
31808
- ...pivot !== void 0 && { pivot, symmetric: false },
31809
- // log, diverging-log
31810
- ...scale3.base && { base: scale3.base() },
31811
- // pow, diverging-pow
31812
- ...scale3.exponent && { exponent: scale3.exponent() },
31813
- // symlog, diverging-symlog
31814
- ...scale3.constant && { constant: scale3.constant() },
31815
- // band, point
31816
- ...scale3.align && { align: scale3.align(), round: scale3.round() },
31817
- ...scale3.padding && (scale3.paddingInner ? { paddingInner: scale3.paddingInner(), paddingOuter: scale3.paddingOuter() } : { padding: scale3.padding() }),
31818
- ...scale3.bandwidth && { bandwidth: scale3.bandwidth(), step: scale3.step() },
31819
- // utilities
31820
- apply: (t) => scale3(t),
31821
- ...scale3.invert && { invert: (t) => scale3.invert(t) }
31822
- };
31900
+ function applyFrameAnchor({ frameAnchor }, { width: width2, height: height2, marginTop: marginTop2, marginRight: marginRight2, marginBottom: marginBottom2, marginLeft: marginLeft2 }) {
31901
+ return [
31902
+ /left$/.test(frameAnchor) ? marginLeft2 : /right$/.test(frameAnchor) ? width2 - marginRight2 : (marginLeft2 + width2 - marginRight2) / 2,
31903
+ /^top/.test(frameAnchor) ? marginTop2 : /^bottom/.test(frameAnchor) ? height2 - marginBottom2 : (marginTop2 + height2 - marginBottom2) / 2
31904
+ ];
31823
31905
  }
31824
31906
 
31825
31907
  // ../../node_modules/@observablehq/plot/src/dimensions.js
@@ -33565,19 +33647,28 @@ function axisTickKy(k2, anchor, data, {
33565
33647
  y: y3 = k2 === "y" ? void 0 : null,
33566
33648
  ...options
33567
33649
  }) {
33568
- return axisMark(vectorY, k2, anchor, `${k2}-axis tick`, data, {
33569
- strokeWidth,
33570
- strokeLinecap,
33571
- strokeLinejoin,
33572
- facetAnchor,
33573
- frameAnchor,
33574
- y: y3,
33575
- ...options,
33576
- dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
33577
- anchor: "start",
33578
- length: tickSize,
33579
- shape: anchor === "left" ? shapeTickLeft : shapeTickRight
33580
- });
33650
+ return axisMark(
33651
+ vectorY,
33652
+ k2,
33653
+ data,
33654
+ {
33655
+ ariaLabel: `${k2}-axis tick`,
33656
+ ariaHidden: true
33657
+ },
33658
+ {
33659
+ strokeWidth,
33660
+ strokeLinecap,
33661
+ strokeLinejoin,
33662
+ facetAnchor,
33663
+ frameAnchor,
33664
+ y: y3,
33665
+ ...options,
33666
+ dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
33667
+ anchor: "start",
33668
+ length: tickSize,
33669
+ shape: anchor === "left" ? shapeTickLeft : shapeTickRight
33670
+ }
33671
+ );
33581
33672
  }
33582
33673
  function axisTickKx(k2, anchor, data, {
33583
33674
  strokeWidth = 1,
@@ -33593,19 +33684,28 @@ function axisTickKx(k2, anchor, data, {
33593
33684
  x: x3 = k2 === "x" ? void 0 : null,
33594
33685
  ...options
33595
33686
  }) {
33596
- return axisMark(vectorX, k2, anchor, `${k2}-axis tick`, data, {
33597
- strokeWidth,
33598
- strokeLinejoin,
33599
- strokeLinecap,
33600
- facetAnchor,
33601
- frameAnchor,
33602
- x: x3,
33603
- ...options,
33604
- dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
33605
- anchor: "start",
33606
- length: tickSize,
33607
- shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
33608
- });
33687
+ return axisMark(
33688
+ vectorX,
33689
+ k2,
33690
+ data,
33691
+ {
33692
+ ariaLabel: `${k2}-axis tick`,
33693
+ ariaHidden: true
33694
+ },
33695
+ {
33696
+ strokeWidth,
33697
+ strokeLinejoin,
33698
+ strokeLinecap,
33699
+ facetAnchor,
33700
+ frameAnchor,
33701
+ x: x3,
33702
+ ...options,
33703
+ dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
33704
+ anchor: "start",
33705
+ length: tickSize,
33706
+ shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
33707
+ }
33708
+ );
33609
33709
  }
33610
33710
  function axisTextKy(k2, anchor, data, {
33611
33711
  facetAnchor = anchor + (k2 === "y" ? "-empty" : ""),
@@ -33627,9 +33727,8 @@ function axisTextKy(k2, anchor, data, {
33627
33727
  return axisMark(
33628
33728
  textY,
33629
33729
  k2,
33630
- anchor,
33631
- `${k2}-axis tick label`,
33632
33730
  data,
33731
+ { ariaLabel: `${k2}-axis tick label` },
33633
33732
  {
33634
33733
  facetAnchor,
33635
33734
  frameAnchor,
@@ -33670,9 +33769,8 @@ function axisTextKx(k2, anchor, data, {
33670
33769
  return axisMark(
33671
33770
  textX,
33672
33771
  k2,
33673
- anchor,
33674
- `${k2}-axis tick label`,
33675
33772
  data,
33773
+ { ariaLabel: `${k2}-axis tick label` },
33676
33774
  {
33677
33775
  facetAnchor,
33678
33776
  frameAnchor,
@@ -33716,7 +33814,7 @@ function gridKy(k2, anchor, data, {
33716
33814
  x2: x22 = anchor === "right" ? x3 : null,
33717
33815
  ...options
33718
33816
  }) {
33719
- return axisMark(ruleY, k2, anchor, `${k2}-grid`, data, { y: y3, x1: x12, x2: x22, ...gridDefaults(options) });
33817
+ return axisMark(ruleY, k2, data, { ariaLabel: `${k2}-grid`, ariaHidden: true }, { y: y3, x1: x12, x2: x22, ...gridDefaults(options) });
33720
33818
  }
33721
33819
  function gridKx(k2, anchor, data, {
33722
33820
  x: x3 = k2 === "x" ? void 0 : null,
@@ -33725,7 +33823,7 @@ function gridKx(k2, anchor, data, {
33725
33823
  y2: y22 = anchor === "bottom" ? y3 : null,
33726
33824
  ...options
33727
33825
  }) {
33728
- return axisMark(ruleX, k2, anchor, `${k2}-grid`, data, { x: x3, y1: y12, y2: y22, ...gridDefaults(options) });
33826
+ return axisMark(ruleX, k2, data, { ariaLabel: `${k2}-grid`, ariaHidden: true }, { x: x3, y1: y12, y2: y22, ...gridDefaults(options) });
33729
33827
  }
33730
33828
  function gridDefaults({
33731
33829
  color: color3 = "currentColor",
@@ -33770,7 +33868,7 @@ function labelOptions({
33770
33868
  initializer: initializer2
33771
33869
  };
33772
33870
  }
33773
- function axisMark(mark2, k2, anchor, ariaLabel, data, options, initialize) {
33871
+ function axisMark(mark2, k2, data, properties, options, initialize) {
33774
33872
  let channels;
33775
33873
  function axisInitializer(data2, facets, _channels, scales2, dimensions, context) {
33776
33874
  const initializeFacets = data2 == null && (k2 === "fx" || k2 === "fy");
@@ -33842,7 +33940,8 @@ function axisMark(mark2, k2, anchor, ariaLabel, data, options, initialize) {
33842
33940
  } else {
33843
33941
  channels = {};
33844
33942
  }
33845
- m.ariaLabel = ariaLabel;
33943
+ if (properties !== void 0)
33944
+ Object.assign(m, properties);
33846
33945
  if (m.clip === void 0)
33847
33946
  m.clip = false;
33848
33947
  return m;
@@ -35271,6 +35370,8 @@ function binn(bx, by, gx, gy, {
35271
35370
  for (const [f, I] of maybeGroup(facet, G)) {
35272
35371
  for (const [k3, g] of maybeGroup(I, K2)) {
35273
35372
  for (const [b, extent4] of bin3(g)) {
35373
+ if (G)
35374
+ extent4.z = f;
35274
35375
  if (filter3 && !filter3.reduce(b, extent4))
35275
35376
  continue;
35276
35377
  groupFacet.push(i++);
@@ -35290,7 +35391,7 @@ function binn(bx, by, gx, gy, {
35290
35391
  for (const o of outputs)
35291
35392
  o.reduce(b, extent4);
35292
35393
  if (sort3)
35293
- sort3.reduce(b);
35394
+ sort3.reduce(b, extent4);
35294
35395
  }
35295
35396
  }
35296
35397
  }
@@ -35457,6 +35558,8 @@ function maybeBinReduceFallback(reduce) {
35457
35558
  return reduceY1;
35458
35559
  case "y2":
35459
35560
  return reduceY22;
35561
+ case "z":
35562
+ return reduceZ;
35460
35563
  }
35461
35564
  throw new Error(`invalid bin reduce: ${reduce}`);
35462
35565
  }
@@ -40127,13 +40230,13 @@ var attributeMap = /* @__PURE__ */ new Map([
40127
40230
  ["projectionInsetBottom", "projection.insetBottom"],
40128
40231
  ["projectionClip", "projection.clip"]
40129
40232
  ]);
40130
- function setProperty(object2, path2, value) {
40233
+ function setProperty(object, path2, value) {
40131
40234
  for (let i = 0; i < path2.length; ++i) {
40132
40235
  const key = path2[i];
40133
40236
  if (i === path2.length - 1) {
40134
- object2[key] = value;
40237
+ object[key] = value;
40135
40238
  } else {
40136
- object2 = object2[key] || (object2[key] = {});
40239
+ object = object[key] || (object[key] = {});
40137
40240
  }
40138
40241
  }
40139
40242
  }
@@ -40203,16 +40306,16 @@ function setSymbolAttributes(plot3, svg, attributes2, symbols3) {
40203
40306
  }
40204
40307
  function inferLabels(spec, plot3) {
40205
40308
  const { marks: marks2 } = plot3;
40206
- inferLabel("x", spec, marks2, ["x", "x1", "x2"]);
40207
- inferLabel("y", spec, marks2, ["y", "y1", "y2"]);
40309
+ inferLabel("x", spec, marks2);
40310
+ inferLabel("y", spec, marks2);
40208
40311
  inferLabel("fx", spec, marks2);
40209
40312
  inferLabel("fy", spec, marks2);
40210
40313
  }
40211
- function inferLabel(key, spec, marks2, channels = [key]) {
40314
+ function inferLabel(key, spec, marks2) {
40212
40315
  const scale3 = spec[key] || {};
40213
40316
  if (scale3.axis === null || scale3.label !== void 0)
40214
40317
  return;
40215
- const fields = marks2.map((mark2) => mark2.channelField(channels)?.field);
40318
+ const fields = marks2.map((mark2) => mark2.channelField(key)?.field);
40216
40319
  if (fields.every((x3) => x3 == null))
40217
40320
  return;
40218
40321
  let candCol;
@@ -40225,7 +40328,7 @@ function inferLabel(key, spec, marks2, channels = [key]) {
40225
40328
  } else if (candCol === void 0 && candLabel === void 0) {
40226
40329
  candCol = column3;
40227
40330
  candLabel = label2;
40228
- type2 = getType(marks2[i].data, channels) || "number";
40331
+ type2 = getType(marks2[i].data, key) || "number";
40229
40332
  } else if (candLabel !== label2) {
40230
40333
  candLabel = void 0;
40231
40334
  } else if (candCol !== column3) {
@@ -40267,13 +40370,11 @@ function annotateMarks(svg, indices) {
40267
40370
  }
40268
40371
  }
40269
40372
  }
40270
- function getType(data, channels) {
40373
+ function getType(data, channel) {
40271
40374
  for (const row of data) {
40272
- for (let j = 0; j < channels.length; ++j) {
40273
- const v2 = row[channels[j]];
40274
- if (v2 != null) {
40275
- return v2 instanceof Date ? "date" : typeof v2;
40276
- }
40375
+ const v2 = row[channel] ?? row[channel + "1"] ?? row[channel + "2"];
40376
+ if (v2 != null) {
40377
+ return v2 instanceof Date ? "date" : typeof v2;
40277
40378
  }
40278
40379
  }
40279
40380
  }
@@ -40476,49 +40577,6 @@ function isSymbol2(value) {
40476
40577
  return symbols2.has(`${value}`.toLowerCase());
40477
40578
  }
40478
40579
 
40479
- // ../plot/src/marks/util/arrow.js
40480
- var INTEGER = 2;
40481
- var FLOAT = 3;
40482
- var DECIMAL = 7;
40483
- var TIMESTAMP = 10;
40484
- function isArrowTable(values2) {
40485
- return typeof values2?.getChild === "function";
40486
- }
40487
- function convertArrowType(type2) {
40488
- switch (type2.typeId) {
40489
- case INTEGER:
40490
- case FLOAT:
40491
- case DECIMAL:
40492
- return Float64Array;
40493
- default:
40494
- return Array;
40495
- }
40496
- }
40497
- function convertArrow(type2) {
40498
- const { typeId } = type2;
40499
- if (typeId === TIMESTAMP) {
40500
- return (v2) => v2 == null ? v2 : new Date(v2);
40501
- }
40502
- if (typeId === INTEGER && type2.bitWidth >= 64) {
40503
- return (v2) => v2 == null ? v2 : Number(v2);
40504
- }
40505
- return (v2) => v2;
40506
- }
40507
- function convertArrowColumn(column3) {
40508
- const { type: type2 } = column3;
40509
- const { typeId } = type2;
40510
- if (typeId === INTEGER && type2.bitWidth >= 64) {
40511
- const size = column3.length;
40512
- const array3 = new Float64Array(size);
40513
- for (let row = 0; row < size; ++row) {
40514
- const v2 = column3.get(row);
40515
- array3[row] = v2 == null ? NaN : Number(v2);
40516
- }
40517
- return array3;
40518
- }
40519
- return column3.toArray();
40520
- }
40521
-
40522
40580
  // ../plot/src/marks/util/to-data-array.js
40523
40581
  function toDataArray(data) {
40524
40582
  return isArrowTable(data) ? arrowToObjects(data) : data;
@@ -40534,7 +40592,7 @@ function arrowToObjects(data) {
40534
40592
  for (let j = 0; j < numCols; ++j) {
40535
40593
  const child = batch.getChildAt(j);
40536
40594
  const { name: name2, type: type2 } = schema.fields[j];
40537
- const valueOf = convertArrow(type2);
40595
+ const valueOf = convertArrowValue(type2);
40538
40596
  for (let o = k2, i = 0; i < numRows; ++i, ++o) {
40539
40597
  objects[o][name2] = valueOf(child.get(i));
40540
40598
  }
@@ -40619,17 +40677,15 @@ var Mark2 = class extends MosaicClient {
40619
40677
  hasOwnData() {
40620
40678
  return this.source == null || isDataArray(this.source);
40621
40679
  }
40680
+ hasFieldInfo() {
40681
+ return !!this._fieldInfo;
40682
+ }
40622
40683
  channel(channel) {
40623
40684
  return this.channels.find((c4) => c4.channel === channel);
40624
40685
  }
40625
- channelField(...channels) {
40626
- const list = channels.flat();
40627
- for (const channel of list) {
40628
- const c4 = this.channel(channel);
40629
- if (c4?.field)
40630
- return c4;
40631
- }
40632
- return null;
40686
+ channelField(channel, { exact } = {}) {
40687
+ const c4 = exact ? this.channel(channel) : this.channels.find((c5) => c5.channel.startsWith(channel));
40688
+ return c4?.field ? c4 : null;
40633
40689
  }
40634
40690
  fields() {
40635
40691
  if (this.hasOwnData())
@@ -40637,26 +40693,25 @@ var Mark2 = class extends MosaicClient {
40637
40693
  const { source: { table: table3 }, channels, reqs } = this;
40638
40694
  const fields = /* @__PURE__ */ new Map();
40639
40695
  for (const { channel, field: field2 } of channels) {
40640
- const column3 = field2?.column;
40641
- if (!column3) {
40696
+ if (!field2)
40642
40697
  continue;
40643
- } else if (field2.stats?.length || reqs[channel]) {
40644
- if (!fields.has(column3))
40645
- fields.set(column3, /* @__PURE__ */ new Set());
40646
- const entry = fields.get(column3);
40647
- reqs[channel]?.forEach((s2) => entry.add(s2));
40648
- field2.stats?.forEach((s2) => entry.add(s2));
40649
- }
40698
+ const stats = field2.stats?.stats || [];
40699
+ const key = field2.stats?.column ?? field2;
40700
+ const entry = fields.get(key) ?? fields.set(key, /* @__PURE__ */ new Set()).get(key);
40701
+ stats.forEach((s2) => entry.add(s2));
40702
+ reqs[channel]?.forEach((s2) => entry.add(s2));
40650
40703
  }
40651
- return Array.from(fields, ([column3, stats]) => {
40652
- return { table: table3, column: column3, stats: Array.from(stats) };
40653
- });
40704
+ return Array.from(fields, ([c4, s2]) => ({ table: table3, column: c4, stats: s2 }));
40654
40705
  }
40655
40706
  fieldInfo(info) {
40656
- this.stats = info.reduce(
40657
- (o, d) => (o[d.column] = d, o),
40658
- /* @__PURE__ */ Object.create(null)
40659
- );
40707
+ const lookup = Object.fromEntries(info.map((x3) => [x3.column, x3]));
40708
+ for (const entry of this.channels) {
40709
+ const { field: field2 } = entry;
40710
+ if (field2) {
40711
+ Object.assign(entry, lookup[field2.stats?.column ?? field2]);
40712
+ }
40713
+ }
40714
+ this._fieldInfo = true;
40660
40715
  return this;
40661
40716
  }
40662
40717
  query(filter3 = []) {
@@ -40724,8 +40779,7 @@ function channelScale(mark2, channel) {
40724
40779
  const { plot: plot3 } = mark2;
40725
40780
  let scaleType = plot3.getAttribute(`${channel}Scale`);
40726
40781
  if (!scaleType) {
40727
- const { field: field2 } = mark2.channelField(channel, `${channel}1`, `${channel}2`);
40728
- const { type: type2 } = mark2.stats[field2.column];
40782
+ const { type: type2 } = mark2.channelField(channel);
40729
40783
  scaleType = type2 === "date" ? "time" : "linear";
40730
40784
  }
40731
40785
  const options = { type: scaleType };
@@ -40763,15 +40817,13 @@ var xext = { x: ["min", "max"] };
40763
40817
  var yext = { y: ["min", "max"] };
40764
40818
  var xyext = { ...xext, ...yext };
40765
40819
  function plotExtent(mark2, filter3, channel, domainAttr, niceAttr) {
40766
- const { plot: plot3, stats } = mark2;
40820
+ const { plot: plot3 } = mark2;
40767
40821
  const domain = plot3.getAttribute(domainAttr);
40768
40822
  const nice3 = plot3.getAttribute(niceAttr);
40769
40823
  if (Array.isArray(domain) && !domain[Transient]) {
40770
40824
  return domain;
40771
40825
  } else {
40772
- const { field: field2 } = mark2.channelField(channel);
40773
- const { column: column3 } = field2;
40774
- const { min: min5, max: max4 } = stats[column3];
40826
+ const { column: column3, min: min5, max: max4 } = mark2.channelField(channel);
40775
40827
  const dom = filteredExtent(filter3, column3) || (nice3 ? linear2().domain([min5, max4]).nice().domain() : [min5, max4]);
40776
40828
  if (domain !== Fixed)
40777
40829
  dom[Transient] = true;
@@ -40791,7 +40843,7 @@ function filteredExtent(filter3, column3) {
40791
40843
  let lo;
40792
40844
  let hi;
40793
40845
  const visitor = (type2, clause) => {
40794
- if (type2 === "BETWEEN" && clause.field.column === column3) {
40846
+ if (type2 === "BETWEEN" && `${clause.field}` === column3) {
40795
40847
  const { range: range3 } = clause;
40796
40848
  if (range3 && (lo == null || range3[0] < lo))
40797
40849
  lo = range3[0];
@@ -40811,26 +40863,23 @@ function filteredExtent(filter3, column3) {
40811
40863
  var ConnectedMark = class extends Mark2 {
40812
40864
  constructor(type2, source, encodings) {
40813
40865
  const dim = type2.endsWith("X") ? "y" : type2.endsWith("Y") ? "x" : null;
40814
- const req = { [dim]: ["min", "max"] };
40866
+ const req = dim ? { [dim]: ["min", "max"] } : void 0;
40815
40867
  super(type2, source, encodings, req);
40816
40868
  this.dim = dim;
40817
40869
  }
40818
40870
  query(filter3 = []) {
40819
- const { plot: plot3, dim, source, stats } = this;
40871
+ const { plot: plot3, dim, source } = this;
40820
40872
  const { optimize = true } = source.options || {};
40821
40873
  const q = super.query(filter3);
40822
40874
  if (!dim)
40823
40875
  return q;
40824
40876
  const ortho = dim === "x" ? "y" : "x";
40825
- const value = this.channelField(ortho)?.as;
40826
- const { field: field2, as } = this.channelField(dim);
40827
- const { type: type2 } = stats[field2.column];
40877
+ const value = this.channelField(ortho, { exact: true })?.as;
40878
+ const { field: field2, as, type: type2, min: min5, max: max4 } = this.channelField(dim);
40828
40879
  const isContinuous = type2 === "date" || type2 === "number";
40829
40880
  if (optimize && isContinuous && value) {
40830
- const { column: column3 } = field2;
40831
- const { max: max4, min: min5 } = stats[column3];
40832
40881
  const size = dim === "x" ? plot3.innerWidth() : plot3.innerHeight();
40833
- const [lo, hi] = filteredExtent(filter3, column3) || [min5, max4];
40882
+ const [lo, hi] = filteredExtent(filter3, field2) || [min5, max4];
40834
40883
  const [expr] = binExpr(this, dim, size, [lo, hi], 1, as);
40835
40884
  const cols = q.select().map((c4) => c4.as).filter((c4) => c4 !== as && c4 !== value);
40836
40885
  return m4(q, expr, as, value, cols);
@@ -40852,17 +40901,10 @@ function m4(input3, bin3, x3, y3, cols = []) {
40852
40901
 
40853
40902
  // ../plot/src/marks/util/grid.js
40854
40903
  function arrayType(values2, name2 = "density") {
40855
- if (isArrowTable(values2)) {
40856
- return convertArrowType(values2.getChild(name2).type);
40857
- } else {
40858
- return typeof values2[0][name2] === "number" ? Float64Array : Array;
40859
- }
40904
+ return isArrowTable(values2) ? convertArrowArrayType(values2.getChild(name2).type) : typeof values2[0]?.[name2] === "number" ? Float64Array : Array;
40860
40905
  }
40861
- function grid1d(n, values2) {
40862
- const Type3 = arrayType(values2);
40863
- return valuesToGrid(new Type3(n), values2);
40864
- }
40865
- function valuesToGrid(grid2, values2, name2 = "density") {
40906
+ function grid1d(n, values2, name2 = "density") {
40907
+ const grid2 = new (arrayType(values2))(n);
40866
40908
  if (isArrowTable(values2)) {
40867
40909
  const numRows = values2.numRows;
40868
40910
  if (numRows === 0)
@@ -41361,7 +41403,7 @@ var Grid2DMark = class extends Mark2 {
41361
41403
  }
41362
41404
  setPlot(plot3, index2) {
41363
41405
  const update2 = () => {
41364
- if (this.stats)
41406
+ if (this.hasFieldInfo())
41365
41407
  this.requestUpdate();
41366
41408
  };
41367
41409
  plot3.addAttributeListener("domainX", update2);
@@ -41706,7 +41748,7 @@ var RasterMark = class extends Grid2DMark {
41706
41748
  }
41707
41749
  setPlot(plot3, index2) {
41708
41750
  const update2 = () => {
41709
- if (this.stats)
41751
+ if (this.hasFieldInfo())
41710
41752
  this.rasterize();
41711
41753
  };
41712
41754
  plot3.addAttributeListener("schemeColor", update2);
@@ -41907,9 +41949,12 @@ var DenseLineMark = class extends RasterMark {
41907
41949
  function stripXY(mark2, filter3) {
41908
41950
  if (Array.isArray(filter3) && !filter3.length)
41909
41951
  return filter3;
41910
- const xc = mark2.channelField("x").field.column;
41911
- const yc = mark2.channelField("y").field.column;
41912
- const test = (p) => p.op !== "BETWEEN" || p.field.column !== xc && p.field.column !== yc;
41952
+ const { column: xc } = mark2.channelField("x");
41953
+ const { column: yc } = mark2.channelField("y");
41954
+ const test = (p) => {
41955
+ const col = `${p.field}`;
41956
+ return p.op !== "BETWEEN" || col !== xc && col !== yc;
41957
+ };
41913
41958
  const filterAnd = (p) => p.op === "AND" ? and(p.children.filter((c4) => test(c4))) : p;
41914
41959
  return Array.isArray(filter3) ? filter3.filter((p) => test(p)).map((p) => filterAnd(p)) : filterAnd(filter3);
41915
41960
  }
@@ -42198,7 +42243,7 @@ var RasterTileMark = class extends Grid2DMark {
42198
42243
  }
42199
42244
  setPlot(plot3, index2) {
42200
42245
  const update2 = () => {
42201
- if (this.stats)
42246
+ if (this.hasFieldInfo())
42202
42247
  this.rasterize();
42203
42248
  };
42204
42249
  plot3.addAttributeListener("schemeColor", update2);
@@ -42747,8 +42792,8 @@ function closeTo(a2, b) {
42747
42792
  }
42748
42793
 
42749
42794
  // ../plot/src/interactors/util/get-field.js
42750
- function getField(mark2, channels) {
42751
- const field2 = mark2.channelField(channels)?.field;
42795
+ function getField(mark2, channel) {
42796
+ const field2 = mark2.channelField(channel)?.field;
42752
42797
  return field2?.basis || field2;
42753
42798
  }
42754
42799
 
@@ -42782,7 +42827,7 @@ var Interval1D = class {
42782
42827
  this.pixelSize = pixelSize || 1;
42783
42828
  this.selection = selection2;
42784
42829
  this.peers = peers;
42785
- this.field = field2 || getField(mark2, [channel, channel + "1", channel + "2"]);
42830
+ this.field = field2 || getField(mark2, channel);
42786
42831
  this.style = style2 && sanitizeStyles(style2);
42787
42832
  this.brush = channel === "y" ? brushY2() : brushX2();
42788
42833
  this.brush.on("brush end", ({ selection: selection3 }) => this.publish(selection3));
@@ -42850,8 +42895,8 @@ var Interval2D = class {
42850
42895
  this.pixelSize = pixelSize || 1;
42851
42896
  this.selection = selection2;
42852
42897
  this.peers = peers;
42853
- this.xfield = xfield || getField(mark2, ["x", "x1", "x2"]);
42854
- this.yfield = yfield || getField(mark2, ["y", "y1", "y2"]);
42898
+ this.xfield = xfield || getField(mark2, "x");
42899
+ this.yfield = yfield || getField(mark2, "y");
42855
42900
  this.style = style2 && sanitizeStyles(style2);
42856
42901
  this.brush = brush2();
42857
42902
  this.brush.on("brush end", ({ selection: selection3 }) => this.publish(selection3));
@@ -42987,8 +43032,8 @@ var PanZoom = class {
42987
43032
  this.mark = mark2;
42988
43033
  this.xsel = x3;
42989
43034
  this.ysel = y3;
42990
- this.xfield = xfield || getField(mark2, ["x", "x1", "x2"]);
42991
- this.yfield = yfield || getField(mark2, ["y", "y1", "y2"]);
43035
+ this.xfield = xfield || getField(mark2, "x");
43036
+ this.yfield = yfield || getField(mark2, "y");
42992
43037
  this.zoom = extent3(zoom2, [0, Infinity], [1, 1]);
42993
43038
  this.panx = this.xsel && panx;
42994
43039
  this.pany = this.ysel && pany;
@@ -43217,8 +43262,10 @@ function findMark({ marks: marks2 }, channel) {
43217
43262
  if (channels == null)
43218
43263
  return null;
43219
43264
  for (let i = marks2.length - 1; i > -1; --i) {
43220
- if (marks2[i].channelField(channels)) {
43221
- return marks2[i];
43265
+ for (const channel2 of channels) {
43266
+ if (marks2[i].channelField(channel2, { exact: true })) {
43267
+ return marks2[i];
43268
+ }
43222
43269
  }
43223
43270
  }
43224
43271
  return null;
@@ -43247,7 +43294,7 @@ function binField(mark2, channel, column3, options) {
43247
43294
  column: column3,
43248
43295
  label: column3,
43249
43296
  get stats() {
43250
- return ["min", "max"];
43297
+ return { column: column3, stats: ["min", "max"] };
43251
43298
  },
43252
43299
  get columns() {
43253
43300
  return [column3];
@@ -43257,7 +43304,7 @@ function binField(mark2, channel, column3, options) {
43257
43304
  },
43258
43305
  toString() {
43259
43306
  const { apply: apply2, sqlApply, sqlInvert } = channelScale(mark2, channel);
43260
- const { min: min5, max: max4 } = mark2.stats[column3];
43307
+ const { min: min5, max: max4 } = mark2.channelField(channel);
43261
43308
  const b = bins(apply2(min5), apply2(max4), options);
43262
43309
  const col = sqlApply(column3);
43263
43310
  const base = b.min === 0 ? col : `(${col} - ${b.min})`;
@@ -44126,8 +44173,8 @@ function attributes(values2) {
44126
44173
  }
44127
44174
  };
44128
44175
  }
44129
- function margins(object2) {
44130
- const { top: top2, bottom: bottom2, left: left2, right: right2 } = object2;
44176
+ function margins(object) {
44177
+ const { top: top2, bottom: bottom2, left: left2, right: right2 } = object;
44131
44178
  const attr = {};
44132
44179
  if (top2 !== void 0)
44133
44180
  attr.marginTop = top2;
@@ -45025,8 +45072,10 @@ async function astToDOM(ast, options) {
45025
45072
  await ctx.coordinator.exec(queries);
45026
45073
  }
45027
45074
  for (const [name2, node] of Object.entries(params)) {
45028
- const param = node.instantiate(ctx);
45029
- ctx.activeParams.set(name2, param);
45075
+ if (!ctx.activeParams.has(name2)) {
45076
+ const param = node.instantiate(ctx);
45077
+ ctx.activeParams.set(name2, param);
45078
+ }
45030
45079
  }
45031
45080
  return {
45032
45081
  element: ast.root.instantiate(ctx),
@@ -45037,12 +45086,12 @@ var InstantiateContext = class {
45037
45086
  constructor({
45038
45087
  api = createAPIContext(),
45039
45088
  plotDefaults = [],
45040
- activeParams = /* @__PURE__ */ new Map(),
45089
+ params = /* @__PURE__ */ new Map(),
45041
45090
  baseURL = null
45042
45091
  } = {}) {
45043
45092
  this.api = api;
45044
45093
  this.plotDefaults = plotDefaults;
45045
- this.activeParams = activeParams;
45094
+ this.activeParams = params;
45046
45095
  this.baseURL = baseURL;
45047
45096
  this.coordinator = api.context.coordinator;
45048
45097
  }