@graphysdk/viz-engine 1.9.0-beta.1790338289848 → 1.9.0-beta.1790339973640

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.
@@ -783,16 +783,36 @@ var Ce = !0, Ei = (e) => {
783
783
  key(e) {
784
784
  return this.singletonKey;
785
785
  }
786
- }, ze = (e) => (Array.isArray(e) ? e : [e]).map((t) => t instanceof Date ? t.toISOString() : String(t ?? "<null>")).join("\0"), wi = (e, t) => e === t ? !0 : Ue(e) && Ue(t) ? e.getTime() === t.getTime() : !1, Ke = (e, t) => e >= 0 && e <= 1 && t >= 0 && t <= 1, La = /* @__PURE__ */ new Set([
786
+ }, ze = (e) => (Array.isArray(e) ? e : [e]).map((t) => t instanceof Date ? t.toISOString() : String(t ?? "<null>")).join("\0"), wi = (e, t) => e === t ? !0 : Ue(e) && Ue(t) ? e.getTime() === t.getTime() : !1, Ke = (e, t) => e >= 0 && e <= 1 && t >= 0 && t <= 1, Si = ["x", "y"], La = /* @__PURE__ */ new Set([
787
+ "x",
788
+ "y",
789
+ "ySecondary"
790
+ ]), or = /* @__PURE__ */ new Set([
791
+ "color",
792
+ "size",
793
+ "alpha",
794
+ "strokeWidth",
795
+ "lineType"
796
+ ]), _a = (e) => La.has(e), Ra = (e) => or.has(e), ki = (e) => _a(e) || Ra(e);
797
+ function Ca(e) {
798
+ return e === "secondary" ? "ySecondary" : "y";
799
+ }
800
+ function Li(e, t) {
801
+ return e === "y" ? Ca(t) : "x";
802
+ }
803
+ function _i(e) {
804
+ return e === "ySecondary" ? "y" : e;
805
+ }
806
+ var Da = /* @__PURE__ */ new Set([
787
807
  "count",
788
808
  "sum",
789
809
  "mean",
790
810
  "median"
791
811
  ]);
792
- function or(e, t) {
793
- return La.has(e) ? "numeric" : t;
812
+ function lr(e, t) {
813
+ return Da.has(e) ? "numeric" : t;
794
814
  }
795
- function lr(e, t, r, a) {
815
+ function cr(e, t, r, a) {
796
816
  if (a !== void 0 && a.type !== "numeric" && (e === "sum" || e === "mean" || e === "median")) throw new oe({
797
817
  code: "INCOMPATIBLE_TYPE",
798
818
  message: `'${e}' requires a numeric variable (got '${a.type}' for '${a.variableName}')`,
@@ -809,7 +829,7 @@ function lr(e, t, r, a) {
809
829
  const c = Fe(t, r, l);
810
830
  Pe(c) && o.push(c);
811
831
  }
812
- return o.length === 0 ? null : e === "median" ? Ca(o) : Da(o);
832
+ return o.length === 0 ? null : e === "median" ? Pa(o) : Oa(o);
813
833
  }
814
834
  if (e === "sum" || e === "mean") {
815
835
  let o = 0, l = 0;
@@ -823,21 +843,21 @@ function lr(e, t, r, a) {
823
843
  let i = null;
824
844
  for (let o = 0; o < n; o++) {
825
845
  const l = Fe(t, r, o);
826
- Pe(l) && (i === null || _a(l, i) === s) && (i = l);
846
+ Pe(l) && (i === null || Ia(l, i) === s) && (i = l);
827
847
  }
828
848
  return i;
829
849
  }
830
- var Fe = (e, t, r) => e[t?.[r] ?? r] ?? null, Pe = (e) => e !== null && !(typeof e == "number" && Number.isNaN(e)), _a = (e, t) => e === null || t === null ? 0 : e < t ? -1 : e > t ? 1 : 0, Ra = (e) => e instanceof Date ? e.getTime() : e ?? null;
831
- function Ca(e) {
850
+ var Fe = (e, t, r) => e[t?.[r] ?? r] ?? null, Pe = (e) => e !== null && !(typeof e == "number" && Number.isNaN(e)), Ia = (e, t) => e === null || t === null ? 0 : e < t ? -1 : e > t ? 1 : 0, Fa = (e) => e instanceof Date ? e.getTime() : e ?? null;
851
+ function Pa(e) {
832
852
  const t = e.map(Number).sort((s, i) => s - i);
833
853
  if (t.length === 1) return t[0] ?? 0;
834
854
  const r = (t.length - 1) / 2, a = Math.floor(r), n = t[a] ?? 0;
835
855
  return n + ((t[a + 1] ?? n) - n) * (r - a);
836
856
  }
837
- function Da(e) {
857
+ function Oa(e) {
838
858
  const t = /* @__PURE__ */ new Map();
839
859
  for (const n of e) {
840
- const s = Ra(n), i = t.get(s);
860
+ const s = Fa(n), i = t.get(s);
841
861
  i === void 0 ? t.set(s, {
842
862
  value: n,
843
863
  count: 1
@@ -847,7 +867,7 @@ function Da(e) {
847
867
  for (const { value: n, count: s } of t.values()) s > a && (a = s, r = n);
848
868
  return r;
849
869
  }
850
- var Ia = (e) => e == null || typeof e == "number" && Number.isNaN(e), Fa = (e) => e instanceof Date ? e.getTime() : e ?? null, Ge = class U {
870
+ var Na = (e) => e == null || typeof e == "number" && Number.isNaN(e), Ba = (e) => e instanceof Date ? e.getTime() : e ?? null, Ge = class U {
851
871
  constructor(t, r, a, n = null) {
852
872
  this.rowShape = null, this.names = t, this.columns = r, this.rowCount = a, this.source = n;
853
873
  }
@@ -910,7 +930,7 @@ var Ia = (e) => e == null || typeof e == "number" && Number.isNaN(e), Fa = (e) =
910
930
  const a = this.values(t);
911
931
  if (a === void 0) return Array.from({ length: this.rowCount }, (o, l) => l);
912
932
  const n = [], s = [];
913
- for (let o = 0; o < this.rowCount; o++) (Ia(a[o]) ? n : s).push(o);
933
+ for (let o = 0; o < this.rowCount; o++) (Na(a[o]) ? n : s).push(o);
914
934
  const i = r === "asc" ? 1 : -1;
915
935
  return s.sort((o, l) => {
916
936
  const c = a[o], u = a[l];
@@ -921,7 +941,7 @@ var Ia = (e) => e == null || typeof e == "number" && Number.isNaN(e), Fa = (e) =
921
941
  const r = t.map((s) => this.values(s)).filter((s) => s !== void 0), a = r.length === 1 ? r[0] : void 0, n = /* @__PURE__ */ new Map();
922
942
  if (a !== void 0) {
923
943
  for (let s = 0; s < this.rowCount; s++) {
924
- const i = Fa(a[s]), o = n.get(i);
944
+ const i = Ba(a[s]), o = n.get(i);
925
945
  o === void 0 ? n.set(i, {
926
946
  key: ze(a[s] ?? null),
927
947
  indices: [s]
@@ -980,7 +1000,7 @@ var Ia = (e) => e == null || typeof e == "number" && Number.isNaN(e), Fa = (e) =
980
1000
  return new U(this.names, new Map(this.columns), this.rowCount);
981
1001
  }
982
1002
  };
983
- var Pa = "value", pe = {
1003
+ var Va = "value", pe = {
984
1004
  numeric: { type: "decimal" },
985
1005
  categorical: { type: "text" },
986
1006
  temporal: { type: "datetime" }
@@ -991,7 +1011,7 @@ var Pa = "value", pe = {
991
1011
  gte: (e, t) => e !== null && t !== null && e >= t,
992
1012
  lt: (e, t) => e !== null && t !== null && e < t,
993
1013
  lte: (e, t) => e !== null && t !== null && e <= t
994
- }, lt = (e) => e === null ? null : e instanceof Date ? e.getTime() : new Date(e).getTime(), cr = (e, t) => e === "count" ? { type: "integer" } : t, ur = (e, t, r) => {
1014
+ }, lt = (e) => e === null ? null : e instanceof Date ? e.getTime() : new Date(e).getTime(), ur = (e, t) => e === "count" ? { type: "integer" } : t, dr = (e, t, r) => {
995
1015
  const a = e.values(t);
996
1016
  if (a !== void 0) return a;
997
1017
  if (r === "count") return new Array(e.rowCount);
@@ -1133,23 +1153,23 @@ var Pa = "value", pe = {
1133
1153
  return null;
1134
1154
  }
1135
1155
  groupBy(...t) {
1136
- return new Oa(t, this.table, this.variableMetadata);
1156
+ return new Wa(t, this.table, this.variableMetadata);
1137
1157
  }
1138
1158
  rollup(t) {
1139
- const r = Ge.from(Object.fromEntries(Object.entries(t).map(([n, { variableName: s, aggregation: i }]) => [n, [lr(i, ur(this.table, s, i), void 0, {
1159
+ const r = Ge.from(Object.fromEntries(Object.entries(t).map(([n, { variableName: s, aggregation: i }]) => [n, [cr(i, dr(this.table, s, i), void 0, {
1140
1160
  type: this.variableMetadata[s]?.type ?? "numeric",
1141
1161
  variableName: s
1142
1162
  })]]))), a = {};
1143
1163
  for (const [n, { variableName: s, aggregation: i }] of Object.entries(t)) {
1144
1164
  const o = this.variableMetadata[s], l = o?.type ?? "numeric", c = o?.valueFormat ?? pe[l];
1145
1165
  a[n] = {
1146
- type: or(i, l),
1147
- valueFormat: cr(i, c)
1166
+ type: lr(i, l),
1167
+ valueFormat: ur(i, c)
1148
1168
  };
1149
1169
  }
1150
1170
  return k.fromTrusted(r, a);
1151
1171
  }
1152
- reshapeFromWideToLong({ keep: t, reshape: r, keyName: a = "key", valueName: n = Pa } = {}) {
1172
+ reshapeFromWideToLong({ keep: t, reshape: r, keyName: a = "key", valueName: n = Va } = {}) {
1153
1173
  const { numeric: s, categorical: i, temporal: o } = this.groupVariableNamesByType(), l = t ?? [...i, ...o], c = r ?? s.filter((d) => !l.includes(d));
1154
1174
  if (l.includes(a) || l.includes(n)) throw new oe({
1155
1175
  code: "INVALID_DATA_SHAPE",
@@ -1189,7 +1209,7 @@ var Pa = "value", pe = {
1189
1209
  valueFormat: { type: "text" }
1190
1210
  }, f[n] = {
1191
1211
  type: "numeric",
1192
- valueFormat: Na(this.variableMetadata, c, a)
1212
+ valueFormat: Ua(this.variableMetadata, c, a)
1193
1213
  }, k.fromTrusted(u, f);
1194
1214
  }
1195
1215
  print() {
@@ -1243,7 +1263,7 @@ var Pa = "value", pe = {
1243
1263
  }
1244
1264
  return s;
1245
1265
  }
1246
- }, Oa = class {
1266
+ }, Wa = class {
1247
1267
  constructor(e, t, r) {
1248
1268
  this.groupedBy = e, this.table = t, this.variableMetadata = r;
1249
1269
  }
@@ -1266,21 +1286,21 @@ var Pa = "value", pe = {
1266
1286
  }];
1267
1287
  }));
1268
1288
  for (const [n, { variableName: s, aggregation: i }] of Object.entries(e)) {
1269
- const o = ur(this.table, s, i), l = this.variableMetadata[s], c = l?.type ?? "numeric";
1270
- r[n] = t.map(({ indices: f }) => lr(i, o, f, {
1289
+ const o = dr(this.table, s, i), l = this.variableMetadata[s], c = l?.type ?? "numeric";
1290
+ r[n] = t.map(({ indices: f }) => cr(i, o, f, {
1271
1291
  type: c,
1272
1292
  variableName: s
1273
1293
  }));
1274
1294
  const u = l?.valueFormat ?? pe[c];
1275
1295
  a[n] = {
1276
- type: or(i, c),
1277
- valueFormat: cr(i, u)
1296
+ type: lr(i, c),
1297
+ valueFormat: ur(i, u)
1278
1298
  };
1279
1299
  }
1280
1300
  return ne.fromTrusted(Ge.from(r), a);
1281
1301
  }
1282
1302
  };
1283
- function Na(e, t, r) {
1303
+ function Ua(e, t, r) {
1284
1304
  const a = t.map((o) => e[o]?.valueFormat ?? { type: "decimal" }), [n, ...s] = a;
1285
1305
  if (!n) return { type: "decimal" };
1286
1306
  for (const o of a) if (o.type === "lookup") throw new oe({
@@ -1300,7 +1320,7 @@ function Na(e, t, r) {
1300
1320
  fallback: n
1301
1321
  };
1302
1322
  }
1303
- var dr = class {
1323
+ var hr = class {
1304
1324
  constructor(e) {
1305
1325
  this.label = e, this.items = /* @__PURE__ */ new Map();
1306
1326
  }
@@ -1329,7 +1349,7 @@ var dr = class {
1329
1349
  has(e) {
1330
1350
  return this.items.has(e);
1331
1351
  }
1332
- }, Ba = (e, t) => {
1352
+ }, Ya = (e, t) => {
1333
1353
  const r = typeof e == "string" ? e.trim() : e;
1334
1354
  if (Q(r)) return { type: "decimal" };
1335
1355
  const a = typeof r == "string" && Kt(r, t);
@@ -1339,39 +1359,39 @@ var dr = class {
1339
1359
  type: "currency",
1340
1360
  iso: Aa(e)
1341
1361
  } : { type: "text" });
1342
- }, Va = {
1362
+ }, za = {
1343
1363
  type: "year",
1344
1364
  dateFormat: "yyyy"
1345
- }, Wa = { type: "text" }, Ua = (e) => {
1346
- const t = e._metadata?.parsingLocale ?? "en-GB", r = {}, a = Ga(e), n = Ya(e), s = a.size > 0;
1365
+ }, Ga = { type: "text" }, ja = (e) => {
1366
+ const t = e._metadata?.parsingLocale ?? "en-GB", r = {}, a = Ka(e), n = Ha(e), s = a.size > 0;
1347
1367
  for (const [i, o] of e.columns.entries()) {
1348
1368
  if (o._metadata?.isHidden) continue;
1349
1369
  const l = a.get(o.key);
1350
1370
  if (le(l) && s) continue;
1351
- const c = o.valueFormat ?? (le(l) ? Wa : i === n ? Va : Ba(l, t)), u = Ut(c);
1352
- r[o.key] = za(o.key, e.rows, c, u, t);
1371
+ const c = o.valueFormat ?? (le(l) ? Ga : i === n ? za : Ya(l, t)), u = Ut(c);
1372
+ r[o.key] = $a(o.key, e.rows, c, u, t);
1353
1373
  }
1354
1374
  return new ne(r);
1355
- }, Si = class extends ka {
1375
+ }, Ri = class extends ka {
1356
1376
  dependencies(e) {
1357
1377
  return [e];
1358
1378
  }
1359
1379
  run(e) {
1360
- return Ua(e);
1380
+ return ja(e);
1361
1381
  }
1362
- }, Ya = (e) => {
1382
+ }, Ha = (e) => {
1363
1383
  if (e.columns.some((r) => r.valueFormat?.type === "year")) return -1;
1364
- const t = ja(e.rows, 5);
1384
+ const t = Xa(e.rows, 5);
1365
1385
  return e.columns.findIndex((r) => {
1366
1386
  if (r.valueFormat) return !1;
1367
1387
  const a = t.map((n) => n[r.key]).filter((n) => !le(n));
1368
1388
  return a.length >= 2 && a.every(ya);
1369
1389
  });
1370
- }, za = (e, t, r, a, n) => ({
1390
+ }, $a = (e, t, r, a, n) => ({
1371
1391
  type: a,
1372
1392
  values: t.reduce((s, i) => (tr(i) || s.push(rr(i[e], r, n)), s), []),
1373
1393
  valueFormat: r
1374
- }), Ga = (e) => {
1394
+ }), Ka = (e) => {
1375
1395
  const t = /* @__PURE__ */ new Map(), r = new Set(e.columns.map((a) => a.key));
1376
1396
  for (const a of e.rows) {
1377
1397
  for (const n of r) {
@@ -1381,38 +1401,18 @@ var dr = class {
1381
1401
  if (r.size === 0) break;
1382
1402
  }
1383
1403
  return t;
1384
- }, ja = (e, t) => {
1404
+ }, Xa = (e, t) => {
1385
1405
  const r = [];
1386
1406
  for (const a of e)
1387
1407
  if (tr(a) || r.push(a), r.length === t) return r;
1388
1408
  return r;
1389
- }, ki = ["x", "y"], Ha = /* @__PURE__ */ new Set([
1390
- "x",
1391
- "y",
1392
- "ySecondary"
1393
- ]), hr = /* @__PURE__ */ new Set([
1394
- "color",
1395
- "size",
1396
- "alpha",
1397
- "strokeWidth",
1398
- "lineType"
1399
- ]), $a = (e) => Ha.has(e), Ka = (e) => hr.has(e), Li = (e) => $a(e) || Ka(e);
1400
- function Xa(e) {
1401
- return e === "secondary" ? "ySecondary" : "y";
1402
- }
1403
- function _i(e, t) {
1404
- return e === "y" ? Xa(t) : "x";
1405
- }
1406
- function Ri(e) {
1407
- return e === "ySecondary" ? "y" : e;
1408
- }
1409
- var qa = (e, t) => {
1409
+ }, qa = (e, t) => {
1410
1410
  if (fe(t.group)) {
1411
1411
  const n = F(t.group);
1412
1412
  if (n !== null) return [n];
1413
1413
  }
1414
1414
  const r = new Set([F(t.x), F(t.y)].filter(fe)), a = /* @__PURE__ */ new Set();
1415
- for (const n of hr) {
1415
+ for (const n of or) {
1416
1416
  const s = F(t[n]);
1417
1417
  fe(s) && (r.has(s) || e.hasVariable(s) && e.getType(s) === "categorical" && a.add(s));
1418
1418
  }
@@ -4168,7 +4168,7 @@ var Ts = (e) => {
4168
4168
  new Vn(),
4169
4169
  new Es(),
4170
4170
  new _s()
4171
- ], ro = class extends dr {
4171
+ ], ro = class extends hr {
4172
4172
  constructor() {
4173
4173
  super("geom");
4174
4174
  for (const e of Rs) this.register(e.type, e);
@@ -4255,7 +4255,7 @@ var Ts = (e) => {
4255
4255
  new Ps(),
4256
4256
  new Os(),
4257
4257
  new Ns()
4258
- ], ao = class extends dr {
4258
+ ], ao = class extends hr {
4259
4259
  constructor() {
4260
4260
  super("transform");
4261
4261
  for (const e of Bs) this.register(e.transformType, e);
@@ -4941,7 +4941,7 @@ var To = { labelCrossPosition: 0.5 }, Mo = {
4941
4941
  export {
4942
4942
  Ae as $,
4943
4943
  Ye as $n,
4944
- dr as $t,
4944
+ Ra as $t,
4945
4945
  so as A,
4946
4946
  mi as An,
4947
4947
  nn as At,
@@ -4963,19 +4963,19 @@ export {
4963
4963
  Xe as Ft,
4964
4964
  Zi as G,
4965
4965
  X as Gn,
4966
- Ri as Gt,
4966
+ Va as Gt,
4967
4967
  Qi as H,
4968
4968
  ui as Hn,
4969
- ki as Ht,
4969
+ Ri as Ht,
4970
4970
  Rs as I,
4971
4971
  yi as In,
4972
4972
  pr as It,
4973
4973
  ns as J,
4974
4974
  z as Jn,
4975
- Ka as Jt,
4975
+ La as Jt,
4976
4976
  eo as K,
4977
4977
  J as Kn,
4978
- $a as Kt,
4978
+ ne as Kt,
4979
4979
  ro as L,
4980
4980
  F as Ln,
4981
4981
  ue as Lt,
@@ -4993,7 +4993,7 @@ export {
4993
4993
  Di as Pt,
4994
4994
  Wn as Q,
4995
4995
  Pt as Qn,
4996
- Ua as Qt,
4996
+ ki as Qt,
4997
4997
  Ms as R,
4998
4998
  fe as Rn,
4999
4999
  Ci as Rt,
@@ -5007,7 +5007,7 @@ export {
5007
5007
  mr as Tt,
5008
5008
  xs as U,
5009
5009
  Xr as Un,
5010
- Ha as Ut,
5010
+ ja as Ut,
5011
5011
  ws as V,
5012
5012
  Bt as Vn,
5013
5013
  fr as Vt,
@@ -5016,13 +5016,13 @@ export {
5016
5016
  hr as Wt,
5017
5017
  zn as X,
5018
5018
  G as Xn,
5019
- Xa as Xt,
5019
+ _i as Xt,
5020
5020
  ss as Y,
5021
5021
  j as Yn,
5022
- _i as Yt,
5022
+ or as Yt,
5023
5023
  Ji as Z,
5024
5024
  $r as Zn,
5025
- Si as Zt,
5025
+ _a as Zt,
5026
5026
  bo as _,
5027
5027
  bi as _n,
5028
5028
  Wr as _r,
@@ -5043,7 +5043,7 @@ export {
5043
5043
  ae as dn,
5044
5044
  si as dr,
5045
5045
  Gi as dt,
5046
- Pa as en,
5046
+ Li as en,
5047
5047
  ii as er,
5048
5048
  Ee as et,
5049
5049
  Ro as f,
@@ -5090,7 +5090,7 @@ export {
5090
5090
  Yi as pt,
5091
5091
  kt as q,
5092
5092
  q as qn,
5093
- Li as qt,
5093
+ Si as qt,
5094
5094
  Lo as r,
5095
5095
  wi as rn,
5096
5096
  Ot as rr,
@@ -5100,7 +5100,7 @@ export {
5100
5100
  jr as sr,
5101
5101
  Oi as st,
5102
5102
  Io as t,
5103
- ne as tn,
5103
+ Ca as tn,
5104
5104
  b as tr,
5105
5105
  Z as tt,
5106
5106
  Mo as u,