@vitessce/dev 2.0.0-beta.1 → 2.0.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.
package/dist/index.umd.js CHANGED
@@ -552,6 +552,18 @@ var __publicField = (obj, key, value) => {
552
552
  CoordinationType$2.FEATURE_SELECTION
553
553
  ]
554
554
  };
555
+ const note = "This file is regenerated by push-demo.sh.";
556
+ const version$6 = "2.0.1";
557
+ const branch = "release-v2.0.1";
558
+ const date$3 = "2022-11-30";
559
+ const hash$1 = "0327a9c6";
560
+ const META_VERSION = {
561
+ note,
562
+ version: version$6,
563
+ branch,
564
+ date: date$3,
565
+ hash: hash$1
566
+ };
555
567
  const ViewType$1 = {
556
568
  GENES: [
557
569
  "genes",
@@ -10130,7 +10142,11 @@ ${oldObj[prop][1]}`);
10130
10142
  grayLight: "#D3D3D3",
10131
10143
  grayMid: "#808080",
10132
10144
  grayDark: "#555555",
10133
- black: "#000000"
10145
+ black: "#000000",
10146
+ grayDarkL5: "rgb(98, 98, 98)",
10147
+ grayDarkD15: "rgb(47, 47, 47)",
10148
+ grayMidL10: "rgb(154, 154, 154)",
10149
+ grayLightL10: "rgb(237, 237, 237)"
10134
10150
  };
10135
10151
  const muiTheme = {
10136
10152
  dark: createTheme({
@@ -10144,6 +10160,9 @@ ${oldObj[prop][1]}`);
10144
10160
  primaryBackgroundDim: "#333333",
10145
10161
  primaryBackgroundLight: "#757575",
10146
10162
  primaryForeground: "#D3D3D3",
10163
+ primaryForegroundL5: "rgb(224, 224, 224)",
10164
+ primaryForegroundL10: "rgb(237, 237, 237)",
10165
+ primaryForegroundD15: "rgb(173, 173, 173)",
10147
10166
  primaryForegroundDim: "#000000",
10148
10167
  primaryForegroundActive: "#9bb7d6",
10149
10168
  secondaryBackground: "#000000",
@@ -10170,6 +10189,9 @@ ${oldObj[prop][1]}`);
10170
10189
  primaryBackgroundDim: "#8A8A8A",
10171
10190
  primaryBackgroundLight: "#e0e0e0",
10172
10191
  primaryForeground: "#333333",
10192
+ primaryForegroundL5: "rgb(64, 64, 64)",
10193
+ primaryForegroundL10: "rgb(77, 77, 77)",
10194
+ primaryForegroundD15: "rgb(13, 13, 13)",
10173
10195
  primaryForegroundDim: "#808080",
10174
10196
  primaryForegroundActive: "#0074D9",
10175
10197
  secondaryBackground: "#F1F1F1",
@@ -10442,13 +10464,10 @@ ${oldObj[prop][1]}`);
10442
10464
  };
10443
10465
  }),
10444
10466
  changeLayout: (newComponentProps) => set2((state) => {
10445
- const newLayout = state.viewConfig.layout.slice();
10446
- newComponentProps.forEach(([i2, newProps]) => {
10447
- newLayout[i2] = {
10448
- ...newLayout[i2],
10449
- ...newProps
10450
- };
10451
- });
10467
+ const newLayout = state.viewConfig.layout.slice().map((componentProps) => ({
10468
+ ...componentProps,
10469
+ ...newComponentProps[componentProps.uid]
10470
+ }));
10452
10471
  return {
10453
10472
  viewConfig: {
10454
10473
  ...state.viewConfig,
@@ -15188,7 +15207,6 @@ ${oldObj[prop][1]}`);
15188
15207
  module3.exports.Responsive.utils = responsiveUtils;
15189
15208
  module3.exports.WidthProvider = WidthProvider.default;
15190
15209
  })(reactGridLayoutWithLodash);
15191
- const COMPONENT_ID_PREFIX = "i";
15192
15210
  function sum$7(a2) {
15193
15211
  return a2.reduce((x2, y2) => x2 + y2, 0);
15194
15212
  }
@@ -15275,12 +15293,11 @@ ${oldObj[prop][1]}`);
15275
15293
  const [lastValidGridLayouts, setLastValidGridLayouts] = React$i.useState(gridLayouts);
15276
15294
  const onValidLayoutChange = (newLayout) => {
15277
15295
  if (newLayout.length === Object.entries(gridComponents).length) {
15278
- const newComponentProps = [];
15296
+ const newComponentProps = {};
15279
15297
  newLayout.forEach((nextC) => {
15280
15298
  const id2 = nextC.i;
15281
15299
  const prevC = gridComponents[id2];
15282
15300
  if (prevC) {
15283
- const i2 = parseInt(id2.substring(id2.indexOf(COMPONENT_ID_PREFIX) + 1), 10);
15284
15301
  const nextProps = {
15285
15302
  x: nextC.x,
15286
15303
  y: nextC.y,
@@ -15294,11 +15311,11 @@ ${oldObj[prop][1]}`);
15294
15311
  h: prevC.h
15295
15312
  };
15296
15313
  if (!isEqual_1(nextProps, prevProps)) {
15297
- newComponentProps.push([i2, nextProps]);
15314
+ newComponentProps[id2] = nextProps;
15298
15315
  }
15299
15316
  }
15300
15317
  });
15301
- if (newComponentProps.length > 0) {
15318
+ if (Object.keys(newComponentProps).length > 0) {
15302
15319
  onLayoutChangeProp(newComponentProps);
15303
15320
  }
15304
15321
  }
@@ -27738,7 +27755,10 @@ After: ${JSON.stringify(coordinationValuesWithDefaults)}`);
27738
27755
  const removeComponent = useRemoveComponent();
27739
27756
  const changeLayout = useChangeLayout();
27740
27757
  const layout = useLayout();
27741
- const changeLayoutPostMount = React$i.useCallback(() => componentWidth > 0 ? changeLayout : () => {
27758
+ const changeLayoutPostMount = React$i.useCallback((newComponentProps) => {
27759
+ if (componentWidth > 0) {
27760
+ changeLayout(newComponentProps);
27761
+ }
27742
27762
  }, [changeLayout, componentWidth]);
27743
27763
  React$i.useEffect(() => {
27744
27764
  if (config2) {
@@ -49860,12 +49880,11 @@ If these are plugin file types, ensure that they have been properly registered.`
49860
49880
  } while (upgradeFunction);
49861
49881
  return [nextConfig, true];
49862
49882
  }
49863
- const packageJson$1 = { version: "unk" };
49864
49883
  const generateClassName = createGenerateClassName({
49865
49884
  disableGlobal: true
49866
49885
  });
49867
49886
  function logConfig(config2, name2) {
49868
- console.groupCollapsed(`\u{1F684} Vitessce (${packageJson$1.version}) ${name2}`);
49887
+ console.groupCollapsed(`\u{1F684} Vitessce (${META_VERSION.version}) ${name2}`);
49869
49888
  console.info(`data:,${JSON.stringify(config2)}`);
49870
49889
  console.info(JSON.stringify(config2, null, 2));
49871
49890
  console.groupEnd();
@@ -61023,11 +61042,19 @@ If these are plugin file types, ensure that they have been properly registered.`
61023
61042
  return true;
61024
61043
  }
61025
61044
  };
61026
- var _descriptors = !_fails(function() {
61027
- return Object.defineProperty({}, "a", { get: function() {
61028
- return 7;
61029
- } }).a != 7;
61030
- });
61045
+ var _descriptors;
61046
+ var hasRequired_descriptors;
61047
+ function require_descriptors() {
61048
+ if (hasRequired_descriptors)
61049
+ return _descriptors;
61050
+ hasRequired_descriptors = 1;
61051
+ _descriptors = !_fails(function() {
61052
+ return Object.defineProperty({}, "a", { get: function() {
61053
+ return 7;
61054
+ } }).a != 7;
61055
+ });
61056
+ return _descriptors;
61057
+ }
61031
61058
  var _domCreate;
61032
61059
  var hasRequired_domCreate;
61033
61060
  function require_domCreate() {
@@ -61042,11 +61069,19 @@ If these are plugin file types, ensure that they have been properly registered.`
61042
61069
  };
61043
61070
  return _domCreate;
61044
61071
  }
61045
- var _ie8DomDefine = !_descriptors && !_fails(function() {
61046
- return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
61047
- return 7;
61048
- } }).a != 7;
61049
- });
61072
+ var _ie8DomDefine;
61073
+ var hasRequired_ie8DomDefine;
61074
+ function require_ie8DomDefine() {
61075
+ if (hasRequired_ie8DomDefine)
61076
+ return _ie8DomDefine;
61077
+ hasRequired_ie8DomDefine = 1;
61078
+ _ie8DomDefine = !require_descriptors() && !_fails(function() {
61079
+ return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
61080
+ return 7;
61081
+ } }).a != 7;
61082
+ });
61083
+ return _ie8DomDefine;
61084
+ }
61050
61085
  var isObject$f = _isObject;
61051
61086
  var _toPrimitive = function(it, S) {
61052
61087
  if (!isObject$f(it))
@@ -61060,25 +61095,32 @@ If these are plugin file types, ensure that they have been properly registered.`
61060
61095
  return val;
61061
61096
  throw TypeError("Can't convert object to primitive value");
61062
61097
  };
61063
- var anObject$3 = _anObject;
61064
- var IE8_DOM_DEFINE$1 = _ie8DomDefine;
61065
- var toPrimitive$2 = _toPrimitive;
61066
- var dP$3 = Object.defineProperty;
61067
- _objectDp.f = _descriptors ? Object.defineProperty : function defineProperty2(O, P2, Attributes2) {
61068
- anObject$3(O);
61069
- P2 = toPrimitive$2(P2, true);
61070
- anObject$3(Attributes2);
61071
- if (IE8_DOM_DEFINE$1)
61072
- try {
61073
- return dP$3(O, P2, Attributes2);
61074
- } catch (e3) {
61075
- }
61076
- if ("get" in Attributes2 || "set" in Attributes2)
61077
- throw TypeError("Accessors not supported!");
61078
- if ("value" in Attributes2)
61079
- O[P2] = Attributes2.value;
61080
- return O;
61081
- };
61098
+ var hasRequired_objectDp;
61099
+ function require_objectDp() {
61100
+ if (hasRequired_objectDp)
61101
+ return _objectDp;
61102
+ hasRequired_objectDp = 1;
61103
+ var anObject2 = _anObject;
61104
+ var IE8_DOM_DEFINE2 = require_ie8DomDefine();
61105
+ var toPrimitive2 = _toPrimitive;
61106
+ var dP2 = Object.defineProperty;
61107
+ _objectDp.f = require_descriptors() ? Object.defineProperty : function defineProperty2(O, P2, Attributes2) {
61108
+ anObject2(O);
61109
+ P2 = toPrimitive2(P2, true);
61110
+ anObject2(Attributes2);
61111
+ if (IE8_DOM_DEFINE2)
61112
+ try {
61113
+ return dP2(O, P2, Attributes2);
61114
+ } catch (e3) {
61115
+ }
61116
+ if ("get" in Attributes2 || "set" in Attributes2)
61117
+ throw TypeError("Accessors not supported!");
61118
+ if ("value" in Attributes2)
61119
+ O[P2] = Attributes2.value;
61120
+ return O;
61121
+ };
61122
+ return _objectDp;
61123
+ }
61082
61124
  var _propertyDesc = function(bitmap, value2) {
61083
61125
  return {
61084
61126
  enumerable: !(bitmap & 1),
@@ -61087,9 +61129,9 @@ If these are plugin file types, ensure that they have been properly registered.`
61087
61129
  value: value2
61088
61130
  };
61089
61131
  };
61090
- var dP$2 = _objectDp;
61132
+ var dP$2 = require_objectDp();
61091
61133
  var createDesc$2 = _propertyDesc;
61092
- var _hide = _descriptors ? function(object2, key2, value2) {
61134
+ var _hide = require_descriptors() ? function(object2, key2, value2) {
61093
61135
  return dP$2.f(object2, key2, createDesc$2(1, value2));
61094
61136
  } : function(object2, key2, value2) {
61095
61137
  object2[key2] = value2;
@@ -61292,7 +61334,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61292
61334
  if (hasRequired_objectAssign)
61293
61335
  return _objectAssign;
61294
61336
  hasRequired_objectAssign = 1;
61295
- var DESCRIPTORS2 = _descriptors;
61337
+ var DESCRIPTORS2 = require_descriptors();
61296
61338
  var getKeys2 = _objectKeys$1;
61297
61339
  var gOPS2 = _objectGops;
61298
61340
  var pIE2 = require_objectPie();
@@ -61355,7 +61397,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61355
61397
  };
61356
61398
  var defineProperty$6 = { exports: {} };
61357
61399
  var $export$4 = _export;
61358
- $export$4($export$4.S + $export$4.F * !_descriptors, "Object", { defineProperty: _objectDp.f });
61400
+ $export$4($export$4.S + $export$4.F * !require_descriptors(), "Object", { defineProperty: require_objectDp().f });
61359
61401
  var $Object$1 = _core.exports.Object;
61360
61402
  var defineProperty$5 = function defineProperty2(it, key2, desc) {
61361
61403
  return $Object$1.defineProperty(it, key2, desc);
@@ -61431,10 +61473,10 @@ If these are plugin file types, ensure that they have been properly registered.`
61431
61473
  module3.exports = _hide;
61432
61474
  })(_redefine);
61433
61475
  var _iterators = {};
61434
- var dP$1 = _objectDp;
61476
+ var dP$1 = require_objectDp();
61435
61477
  var anObject$2 = _anObject;
61436
61478
  var getKeys$1 = _objectKeys$1;
61437
- var _objectDps = _descriptors ? Object.defineProperties : function defineProperties2(O, Properties) {
61479
+ var _objectDps = require_descriptors() ? Object.defineProperties : function defineProperties2(O, Properties) {
61438
61480
  anObject$2(O);
61439
61481
  var keys2 = getKeys$1(Properties);
61440
61482
  var length2 = keys2.length;
@@ -61499,7 +61541,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61499
61541
  return store[name2] || (store[name2] = USE_SYMBOL && Symbol$7[name2] || (USE_SYMBOL ? Symbol$7 : uid$2)("Symbol." + name2));
61500
61542
  };
61501
61543
  $exports.store = store;
61502
- var def$1 = _objectDp.f;
61544
+ var def$1 = require_objectDp().f;
61503
61545
  var has$8 = _has$2;
61504
61546
  var TAG = _wks.exports("toStringTag");
61505
61547
  var _setToStringTag = function(it, tag2, stat) {
@@ -61669,7 +61711,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61669
61711
  var META$1 = _uid("meta");
61670
61712
  var isObject$e = _isObject;
61671
61713
  var has$6 = _has$2;
61672
- var setDesc = _objectDp.f;
61714
+ var setDesc = require_objectDp().f;
61673
61715
  var id$2 = 0;
61674
61716
  var isExtensible = Object.isExtensible || function() {
61675
61717
  return true;
@@ -61719,7 +61761,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61719
61761
  };
61720
61762
  var core$1 = _core.exports;
61721
61763
  var wksExt$1 = _wksExt;
61722
- var defineProperty$4 = _objectDp.f;
61764
+ var defineProperty$4 = require_objectDp().f;
61723
61765
  var _wksDefine = function(name2) {
61724
61766
  var $Symbol2 = core$1.Symbol || (core$1.Symbol = {});
61725
61767
  if (name2.charAt(0) != "_" && !(name2 in $Symbol2))
@@ -61773,9 +61815,9 @@ If these are plugin file types, ensure that they have been properly registered.`
61773
61815
  var toIObject$1 = _toIobject;
61774
61816
  var toPrimitive$1 = _toPrimitive;
61775
61817
  var has$5 = _has$2;
61776
- var IE8_DOM_DEFINE = _ie8DomDefine;
61818
+ var IE8_DOM_DEFINE = require_ie8DomDefine();
61777
61819
  var gOPD$4 = Object.getOwnPropertyDescriptor;
61778
- _objectGopd.f = _descriptors ? gOPD$4 : function getOwnPropertyDescriptor2(O, P2) {
61820
+ _objectGopd.f = require_descriptors() ? gOPD$4 : function getOwnPropertyDescriptor2(O, P2) {
61779
61821
  O = toIObject$1(O);
61780
61822
  P2 = toPrimitive$1(P2, true);
61781
61823
  if (IE8_DOM_DEFINE)
@@ -61788,7 +61830,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61788
61830
  };
61789
61831
  var global$2 = _global.exports;
61790
61832
  var has$4 = _has$2;
61791
- var DESCRIPTORS = _descriptors;
61833
+ var DESCRIPTORS = require_descriptors();
61792
61834
  var $export$2 = _export;
61793
61835
  var redefine = _redefine.exports;
61794
61836
  var META = _meta$3.exports.KEY;
@@ -61811,7 +61853,7 @@ If these are plugin file types, ensure that they have been properly registered.`
61811
61853
  var gOPNExt = _objectGopnExt;
61812
61854
  var $GOPD = _objectGopd;
61813
61855
  var $GOPS = _objectGops;
61814
- var $DP = _objectDp;
61856
+ var $DP = require_objectDp();
61815
61857
  var $keys = _objectKeys$1;
61816
61858
  var gOPD$3 = $GOPD.f;
61817
61859
  var dP = $DP.f;
@@ -64026,7 +64068,7 @@ If these are plugin file types, ensure that they have been properly registered.`
64026
64068
  module3.exports = reactJsxDevRuntime_development;
64027
64069
  }
64028
64070
  })(jsxDevRuntime);
64029
- var _jsxFileName$1 = "/Users/mkeller/research/dbmi/vitessce/vitessce/node_modules/.pnpm/rc-tree@2.1.0_biqbaboplfbrettd7655fr4n2y/node_modules/rc-tree/es/util.js";
64071
+ var _jsxFileName$1 = "/home/runner/work/vitessce/vitessce/node_modules/.pnpm/rc-tree@2.1.0_biqbaboplfbrettd7655fr4n2y/node_modules/rc-tree/es/util.js";
64030
64072
  var DRAG_SIDE_RANGE = 0.25;
64031
64073
  var DRAG_MIN_GAP = 2;
64032
64074
  var onlyTreeNodeWarned = false;
@@ -71778,7 +71820,7 @@ If these are plugin file types, ensure that they have been properly registered.`
71778
71820
  cursor: "pointer",
71779
71821
  border: "0",
71780
71822
  backgroundColor: "transparent",
71781
- color: theme.palette.grayDark,
71823
+ color: theme.palette.grayDarkL5,
71782
71824
  "&[disabled]": {
71783
71825
  pointerEvents: "none",
71784
71826
  "& svg": {
@@ -71792,8 +71834,8 @@ If these are plugin file types, ensure that they have been properly registered.`
71792
71834
  marginTop: "1px"
71793
71835
  },
71794
71836
  "&:hover,:hover path": {
71795
- color: theme.palette.grayDark,
71796
- fill: theme.palette.grayDark
71837
+ color: theme.palette.grayDarkD15,
71838
+ fill: theme.palette.grayDarkD15
71797
71839
  }
71798
71840
  }
71799
71841
  },
@@ -71812,7 +71854,7 @@ If these are plugin file types, ensure that they have been properly registered.`
71812
71854
  border: "1px solid transparent"
71813
71855
  },
71814
71856
  "@global .level-0-treenode > .rc-tree-switcher i svg path": {
71815
- fill: theme.palette.primaryForeground
71857
+ fill: theme.palette.primaryForegroundL5
71816
71858
  },
71817
71859
  "@global .rc-tree-focused:not(.rc-tree-active-focused)": {
71818
71860
  borderColor: "cyan"
@@ -71973,7 +72015,7 @@ If these are plugin file types, ensure that they have been properly registered.`
71973
72015
  plusButton: {
71974
72016
  border: "0",
71975
72017
  backgroundColor: "transparent",
71976
- color: theme.palette.primaryForeground,
72018
+ color: theme.palette.primaryForegroundL5,
71977
72019
  padding: "0",
71978
72020
  fontSize: "18px",
71979
72021
  marginBottom: "2rem",
@@ -71988,12 +72030,12 @@ If these are plugin file types, ensure that they have been properly registered.`
71988
72030
  width: `${nodeHeight}px`,
71989
72031
  top: "5.5px",
71990
72032
  "&:hover": {
71991
- fill: theme.palette.grayMid
72033
+ fill: theme.palette.grayMidL10
71992
72034
  }
71993
72035
  },
71994
72036
  nodeSizeLabel: {
71995
72037
  fontSize: "12px",
71996
- color: theme.palette.primaryForeground
72038
+ color: theme.palette.primaryForegroundD15
71997
72039
  },
71998
72040
  levelButtonsContainer: {
71999
72041
  height: "20px",
@@ -72009,8 +72051,8 @@ If these are plugin file types, ensure that they have been properly registered.`
72009
72051
  height: "12px",
72010
72052
  padding: "5px",
72011
72053
  backgroundClip: "content-box",
72012
- border: `2px solid ${theme.palette.primaryForeground}`,
72013
- backgroundColor: theme.palette.primaryForeground,
72054
+ border: `2px solid ${theme.palette.primaryForegroundL10}`,
72055
+ backgroundColor: theme.palette.primaryForegroundL10,
72014
72056
  borderRadius: "6px",
72015
72057
  position: "relative",
72016
72058
  top: "3px",
@@ -72030,7 +72072,7 @@ If these are plugin file types, ensure that they have been properly registered.`
72030
72072
  height: `${nodeHeight - 8}px`,
72031
72073
  lineHeight: `${nodeHeight - 8}px`,
72032
72074
  border: "1px solid transparent",
72033
- color: theme.palette.primaryForeground,
72075
+ color: theme.palette.primaryForegroundL5,
72034
72076
  background: "transparent",
72035
72077
  backgroundColor: "transparent",
72036
72078
  verticalAlign: "top",
@@ -72073,8 +72115,8 @@ If these are plugin file types, ensure that they have been properly registered.`
72073
72115
  margin: 0,
72074
72116
  padding: 0,
72075
72117
  "&:hover": {
72076
- backgroundColor: theme.palette.grayDark,
72077
- border: `1px solid ${theme.palette.grayDark}`
72118
+ backgroundColor: theme.palette.grayDarkL5,
72119
+ border: `1px solid ${theme.palette.grayDarkL5}`
72078
72120
  }
72079
72121
  },
72080
72122
  "@global .vitessce-tooltip .ant-tooltip-content .ant-tooltip-inner": {
@@ -72224,7 +72266,7 @@ If these are plugin file types, ensure that they have been properly registered.`
72224
72266
  backgroundColor: "transparent",
72225
72267
  borderRadius: "2px",
72226
72268
  "&:hover": {
72227
- backgroundColor: theme.palette.grayLight
72269
+ backgroundColor: theme.palette.grayLightL10
72228
72270
  }
72229
72271
  },
72230
72272
  "& li:not(:last-child)": {
@@ -72281,7 +72323,7 @@ If these are plugin file types, ensure that they have been properly registered.`
72281
72323
  mouseLeaveDelay: 0,
72282
72324
  destroyTooltipOnHide: true
72283
72325
  };
72284
- var _jsxFileName = "/Users/mkeller/research/dbmi/vitessce/vitessce/node_modules/.pnpm/react-color-with-lodash@2.19.5_react@18.2.0/node_modules/react-color-with-lodash/dist/index.mjs";
72326
+ var _jsxFileName = "/home/runner/work/vitessce/vitessce/node_modules/.pnpm/react-color-with-lodash@2.19.5_react@18.2.0/node_modules/react-color-with-lodash/dist/index.mjs";
72285
72327
  var __defProp2 = Object.defineProperty;
72286
72328
  var __defNormalProp2 = (obj, key2, value2) => key2 in obj ? __defProp2(obj, key2, {
72287
72329
  enumerable: true,
@@ -192608,6 +192650,7 @@ attribute float isSelected;
192608
192650
  }
192609
192651
  };
192610
192652
  MinimumIntensityProjectionExtension.extensionName = "MinimumIntensityProjectionExtension";
192653
+ const AdditiveColormap3DExtensions = { BaseExtension, AdditiveBlendExtension, MaximumIntensityProjectionExtension, MinimumIntensityProjectionExtension };
192611
192654
  const defaultProps$5 = { pickable: { type: "boolean", value: true, compare: true }, coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, contrastLimits: { type: "array", value: [], compare: true }, channelsVisible: { type: "array", value: [], compare: true }, selections: { type: "array", value: [], compare: true }, domain: { type: "array", value: [], compare: true }, viewportId: { type: "string", value: "", compare: true }, loader: { type: "object", value: { getRaster: async () => ({ data: [], height: 0, width: 0 }), dtype: "Uint16" }, compare: true }, onClick: { type: "function", value: null, compare: true }, onViewportLoad: { type: "function", value: null, compare: true }, interpolation: { type: "number", value: GL$1.NEAREST, compare: true }, extensions: { type: "array", value: [new ColorPaletteExtension()], compare: true } };
192612
192655
  const ImageLayer = class extends CompositeLayer {
192613
192656
  finalizeState() {
@@ -193640,370 +193683,1521 @@ void main() {
193640
193683
  }
193641
193684
  BitmaskLayer.layerName = "BitmaskLayer";
193642
193685
  BitmaskLayer.defaultProps = defaultProps;
193643
- var _extends$1 = { exports: {} };
193644
- var hasRequired_extends;
193645
- function require_extends() {
193646
- if (hasRequired_extends)
193647
- return _extends$1.exports;
193648
- hasRequired_extends = 1;
193649
- (function(module3) {
193650
- function _extends2() {
193651
- module3.exports = _extends2 = Object.assign ? Object.assign.bind() : function(target2) {
193652
- for (var i2 = 1; i2 < arguments.length; i2++) {
193653
- var source2 = arguments[i2];
193654
- for (var key2 in source2) {
193655
- if (Object.prototype.hasOwnProperty.call(source2, key2)) {
193656
- target2[key2] = source2[key2];
193686
+ const useStyles$8 = makeStyles(() => ({
193687
+ tool: {
193688
+ position: "absolute",
193689
+ display: "inline",
193690
+ zIndex: "1000",
193691
+ opacity: ".65",
193692
+ color: "black",
193693
+ "&:hover": {
193694
+ opacity: ".90"
193695
+ }
193696
+ },
193697
+ iconButton: {
193698
+ padding: "0",
193699
+ height: "2em",
193700
+ width: "2em",
193701
+ backgroundColor: "white",
193702
+ display: "inline-block",
193703
+ fontWeight: "400",
193704
+ textAlign: "center",
193705
+ verticalAlign: "middle",
193706
+ cursor: "pointer",
193707
+ userSelect: "none",
193708
+ border: "1px solid #6c757d",
193709
+ fontSize: "1rem",
193710
+ lineHeight: "1.5",
193711
+ borderRadius: "0.25rem",
193712
+ transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out",
193713
+ color: "#6c757d",
193714
+ marginRight: "0.5rem",
193715
+ "& > svg": {
193716
+ verticalAlign: "middle"
193717
+ }
193718
+ },
193719
+ iconButtonActive: {
193720
+ color: "#fff",
193721
+ backgroundColor: "#6c757d",
193722
+ borderColor: "#6c757d",
193723
+ boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
193724
+ }
193725
+ }));
193726
+ function IconButton(props2) {
193727
+ const { alt, onClick, isActive: isActive2, children: children2 } = props2;
193728
+ const classes = useStyles$8();
193729
+ return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children2 });
193730
+ }
193731
+ function ToolMenu(props2) {
193732
+ const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
193733
+ const classes = useStyles$8();
193734
+ return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
193735
+ }
193736
+ const getCursorWithTool = () => "crosshair";
193737
+ const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
193738
+ function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
193739
+ return (info2) => {
193740
+ if (setComponentHover) {
193741
+ setComponentHover();
193742
+ }
193743
+ if (info2.index) {
193744
+ const obsId = obsIndex[info2.index];
193745
+ if (setObsHighlight) {
193746
+ setObsHighlight(obsId);
193747
+ }
193748
+ } else if (setObsHighlight) {
193749
+ setObsHighlight(null);
193750
+ }
193751
+ };
193752
+ }
193753
+ class AbstractSpatialOrScatterplot extends React$i.PureComponent {
193754
+ constructor(props2) {
193755
+ super(props2);
193756
+ this.state = {
193757
+ gl: null,
193758
+ tool: null
193759
+ };
193760
+ this.viewport = null;
193761
+ this.onViewStateChange = this.onViewStateChange.bind(this);
193762
+ this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
193763
+ this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
193764
+ this.onToolChange = this.onToolChange.bind(this);
193765
+ this.onHover = this.onHover.bind(this);
193766
+ }
193767
+ onViewStateChange({ viewState: nextViewState }) {
193768
+ const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
193769
+ const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
193770
+ setViewState({
193771
+ ...nextViewState,
193772
+ target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
193773
+ });
193774
+ }
193775
+ onInitializeViewInfo({ viewport }) {
193776
+ this.viewport = viewport;
193777
+ }
193778
+ onWebGLInitialized(gl) {
193779
+ this.setState({ gl });
193780
+ }
193781
+ onToolChange(tool) {
193782
+ const { onToolChange: onToolChangeProp } = this.props;
193783
+ this.setState({ tool });
193784
+ if (onToolChangeProp) {
193785
+ onToolChangeProp(tool);
193786
+ }
193787
+ }
193788
+ getLayers() {
193789
+ return [];
193790
+ }
193791
+ onHover(info2) {
193792
+ const { coordinate, sourceLayer: layer, tile } = info2;
193793
+ const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
193794
+ const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
193795
+ if (!setCellHighlight || !tile) {
193796
+ return null;
193797
+ }
193798
+ if (!layer || !coordinate) {
193799
+ if (cellHighlight && hasBitmask) {
193800
+ setCellHighlight(null);
193801
+ }
193802
+ return null;
193803
+ }
193804
+ const { content: content2, bbox: bbox2, z } = tile;
193805
+ if (!content2) {
193806
+ if (cellHighlight && hasBitmask) {
193807
+ setCellHighlight(null);
193808
+ }
193809
+ return null;
193810
+ }
193811
+ const { data: data2, width: width2, height: height2 } = content2;
193812
+ const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
193813
+ const bounds2 = [
193814
+ left2,
193815
+ data2.height < layer.tileSize ? height2 : bottom2,
193816
+ data2.width < layer.tileSize ? width2 : right2,
193817
+ top2
193818
+ ];
193819
+ if (!data2) {
193820
+ if (cellHighlight && hasBitmask) {
193821
+ setCellHighlight(null);
193822
+ }
193823
+ return null;
193824
+ }
193825
+ if (layer.id.includes("bitmask")) {
193826
+ const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
193827
+ const dataCoords = [
193828
+ Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
193829
+ Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
193830
+ ];
193831
+ const coords = dataCoords[1] * width2 + dataCoords[0];
193832
+ const hoverData = data2.map((d) => d[coords]);
193833
+ const cellId = hoverData.find((i2) => i2 > 0);
193834
+ if (cellId !== Number(cellHighlight)) {
193835
+ if (setComponentHover) {
193836
+ setComponentHover();
193837
+ }
193838
+ setCellHighlight(cellId ? String(cellId) : null);
193839
+ }
193840
+ }
193841
+ }
193842
+ viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
193843
+ const { updateViewInfo, uuid } = this.props;
193844
+ const { viewport } = this;
193845
+ if (updateViewInfo && viewport) {
193846
+ updateViewInfo({
193847
+ uuid,
193848
+ project: (obsId) => {
193849
+ try {
193850
+ if (obsIndex && obsLocations) {
193851
+ const getObsCoords = makeGetObsCoords(obsLocations);
193852
+ const obsIdx = obsIndex.indexOf(obsId);
193853
+ const obsCoord = getObsCoords(obsIdx);
193854
+ return viewport.project(obsCoord);
193657
193855
  }
193856
+ return [null, null];
193857
+ } catch (e3) {
193858
+ return [null, null];
193658
193859
  }
193659
193860
  }
193660
- return target2;
193661
- }, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
193662
- return _extends2.apply(this, arguments);
193861
+ });
193663
193862
  }
193664
- module3.exports = _extends2, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
193665
- })(_extends$1);
193666
- return _extends$1.exports;
193667
- }
193668
- var _extendsExports = require_extends();
193669
- var DEFAULT_CONFIG = {
193670
- epsilon: 1e-12,
193671
- matrix: "Matrix",
193672
- number: "number",
193673
- precision: 64,
193674
- predictable: false,
193675
- randomSeed: null
193676
- };
193677
- function isNumber$2(x2) {
193678
- return typeof x2 === "number";
193679
- }
193680
- function isBigNumber(x2) {
193681
- if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
193682
- return false;
193683
193863
  }
193684
- if (x2.isBigNumber === true && typeof x2.constructor.prototype === "object" && x2.constructor.prototype.isBigNumber === true) {
193685
- return true;
193864
+ componentDidUpdate() {
193686
193865
  }
193687
- if (typeof x2.constructor.isDecimal === "function" && x2.constructor.isDecimal(x2) === true) {
193688
- return true;
193866
+ use3d() {
193867
+ return false;
193868
+ }
193869
+ render() {
193870
+ var _a3, _b2, _c, _d;
193871
+ const { deckRef, viewState, uuid, hideTools } = this.props;
193872
+ const { gl, tool } = this.state;
193873
+ const layers = this.getLayers();
193874
+ const use3d = this.use3d();
193875
+ const showCellSelectionTools = this.obsSegmentationsData !== null;
193876
+ const showPanTool = layers.length > 0;
193877
+ const useDevicePixels = !use3d && (((_b2 = (_a3 = this.obsSegmentationsData) == null ? void 0 : _a3.shape) == null ? void 0 : _b2[0]) < 1e5 || ((_d = (_c = this.obsLocationsData) == null ? void 0 : _c.shape) == null ? void 0 : _d[1]) < 1e5);
193878
+ return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
193879
+ pan: showPanTool && !hideTools,
193880
+ selectRectangle: showCellSelectionTools && !hideTools,
193881
+ selectLasso: showCellSelectionTools && !hideTools
193882
+ } }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
193883
+ use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
193884
+ id: "ortho"
193885
+ })
193886
+ ], layers: gl && viewState.target.slice(0, 2).every((i2) => typeof i2 === "number") ? layers : [], glOptions: DEFAULT_GL_OPTIONS, onWebGLInitialized: this.onWebGLInitialized, onViewStateChange: this.onViewStateChange, viewState, useDevicePixels, controller: tool ? { dragPan: false } : true, getCursor: tool ? getCursorWithTool : getCursor, onHover: this.onHover, children: this.onInitializeViewInfo })] });
193689
193887
  }
193690
- return false;
193691
- }
193692
- function isComplex(x2) {
193693
- return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
193694
- }
193695
- function isFraction(x2) {
193696
- return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
193697
- }
193698
- function isUnit(x2) {
193699
- return x2 && x2.constructor.prototype.isUnit === true || false;
193700
- }
193701
- function isString$1(x2) {
193702
- return typeof x2 === "string";
193703
- }
193704
- var isArray$1 = Array.isArray;
193705
- function isMatrix(x2) {
193706
- return x2 && x2.constructor.prototype.isMatrix === true || false;
193707
- }
193708
- function isCollection(x2) {
193709
- return Array.isArray(x2) || isMatrix(x2);
193710
- }
193711
- function isDenseMatrix(x2) {
193712
- return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
193713
- }
193714
- function isSparseMatrix(x2) {
193715
- return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
193716
- }
193717
- function isRange(x2) {
193718
- return x2 && x2.constructor.prototype.isRange === true || false;
193719
- }
193720
- function isIndex(x2) {
193721
- return x2 && x2.constructor.prototype.isIndex === true || false;
193722
- }
193723
- function isBoolean$3(x2) {
193724
- return typeof x2 === "boolean";
193725
- }
193726
- function isResultSet(x2) {
193727
- return x2 && x2.constructor.prototype.isResultSet === true || false;
193728
- }
193729
- function isHelp(x2) {
193730
- return x2 && x2.constructor.prototype.isHelp === true || false;
193731
- }
193732
- function isFunction$2(x2) {
193733
- return typeof x2 === "function";
193734
- }
193735
- function isDate$2(x2) {
193736
- return x2 instanceof Date;
193737
- }
193738
- function isRegExp$1(x2) {
193739
- return x2 instanceof RegExp;
193740
- }
193741
- function isObject$1(x2) {
193742
- return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
193743
- }
193744
- function isNull(x2) {
193745
- return x2 === null;
193746
- }
193747
- function isUndefined(x2) {
193748
- return x2 === void 0;
193749
- }
193750
- function isAccessorNode(x2) {
193751
- return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
193752
- }
193753
- function isArrayNode(x2) {
193754
- return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
193755
- }
193756
- function isAssignmentNode(x2) {
193757
- return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
193758
- }
193759
- function isBlockNode(x2) {
193760
- return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
193761
- }
193762
- function isConditionalNode(x2) {
193763
- return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
193764
- }
193765
- function isConstantNode(x2) {
193766
- return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
193767
- }
193768
- function isFunctionAssignmentNode(x2) {
193769
- return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
193770
- }
193771
- function isFunctionNode(x2) {
193772
- return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
193773
- }
193774
- function isIndexNode(x2) {
193775
- return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
193776
193888
  }
193777
- function isNode(x2) {
193778
- return x2 && x2.isNode === true && x2.constructor.prototype.isNode === true || false;
193889
+ function createQuadTree(obsEmbedding, getCellCoords) {
193890
+ if (!obsEmbedding) {
193891
+ return null;
193892
+ }
193893
+ const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
193894
+ return tree2;
193779
193895
  }
193780
- function isObjectNode(x2) {
193781
- return x2 && x2.isObjectNode === true && x2.constructor.prototype.isNode === true || false;
193896
+ function constant$5(v) {
193897
+ return () => v;
193782
193898
  }
193783
- function isOperatorNode(x2) {
193784
- return x2 && x2.isOperatorNode === true && x2.constructor.prototype.isNode === true || false;
193899
+ function jiggle$1(v) {
193900
+ return v + (Math.random() - 0.5) * 1e-6;
193785
193901
  }
193786
- function isParenthesisNode(x2) {
193787
- return x2 && x2.isParenthesisNode === true && x2.constructor.prototype.isNode === true || false;
193902
+ function forceCollideRects() {
193903
+ let nodes;
193904
+ let masses;
193905
+ let strength = 1;
193906
+ let iterations2 = 1;
193907
+ let sizes;
193908
+ let size2 = constant$5([0, 0]);
193909
+ function xCenter(d) {
193910
+ return d.x + d.vx + sizes[d.index][0] / 2;
193911
+ }
193912
+ function yCenter(d) {
193913
+ return d.y + d.vy + sizes[d.index][1] / 2;
193914
+ }
193915
+ function prepare2(quad2) {
193916
+ if (quad2.data) {
193917
+ quad2.size = sizes[quad2.data.index];
193918
+ } else {
193919
+ quad2.size = [0, 0];
193920
+ for (let i2 = 0; i2 < 4; i2++) {
193921
+ if (quad2[i2] && quad2[i2].size) {
193922
+ quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
193923
+ quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
193924
+ }
193925
+ }
193926
+ }
193927
+ }
193928
+ function force2() {
193929
+ let node;
193930
+ let nodeSize;
193931
+ let nodeMass;
193932
+ let xi;
193933
+ let yi;
193934
+ const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
193935
+ function apply2(quad2, x02, y02, x12, y12) {
193936
+ const { data: data2 } = quad2;
193937
+ const xSize = (nodeSize[0] + quad2.size[0]) / 2;
193938
+ const ySize = (nodeSize[1] + quad2.size[1]) / 2;
193939
+ if (data2 && data2.index > node.index) {
193940
+ let x2 = jiggle$1(xi - xCenter(data2));
193941
+ let y2 = jiggle$1(yi - yCenter(data2));
193942
+ const xd = Math.abs(x2) - xSize;
193943
+ const yd = Math.abs(y2) - ySize;
193944
+ if (xd < 0 && yd < 0) {
193945
+ const l2 = Math.sqrt(x2 * x2 + y2 * y2);
193946
+ const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
193947
+ if (Math.abs(xd) < Math.abs(yd)) {
193948
+ node.vx -= (x2 *= xd / l2 * strength) * m2;
193949
+ data2.vx += x2 * (1 - m2);
193950
+ } else {
193951
+ node.vy -= (y2 *= yd / l2 * strength) * m2;
193952
+ data2.vy += y2 * (1 - m2);
193953
+ }
193954
+ }
193955
+ return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
193956
+ }
193957
+ return false;
193958
+ }
193959
+ function iterate2() {
193960
+ for (let j2 = 0; j2 < nodes.length; j2++) {
193961
+ node = nodes[j2];
193962
+ nodeSize = sizes[j2];
193963
+ nodeMass = masses[j2];
193964
+ xi = xCenter(node);
193965
+ yi = yCenter(node);
193966
+ tree2.visit(apply2);
193967
+ }
193968
+ }
193969
+ for (let i2 = 0; i2 < iterations2; i2++) {
193970
+ iterate2();
193971
+ }
193972
+ }
193973
+ force2.initialize = (v) => {
193974
+ nodes = v;
193975
+ sizes = nodes.map(size2);
193976
+ masses = sizes.map((d) => d[0] + d[1]);
193977
+ };
193978
+ force2.iterations = (...v) => {
193979
+ if (v.length) {
193980
+ iterations2 = +v[0];
193981
+ return force2;
193982
+ }
193983
+ return iterations2;
193984
+ };
193985
+ force2.strength = (...v) => {
193986
+ if (v.length) {
193987
+ strength = +v[0];
193988
+ return force2;
193989
+ }
193990
+ return strength;
193991
+ };
193992
+ force2.size = (...v) => {
193993
+ if (v.length) {
193994
+ size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
193995
+ return force2;
193996
+ }
193997
+ return size2;
193998
+ };
193999
+ return force2;
193788
194000
  }
193789
- function isRangeNode(x2) {
193790
- return x2 && x2.isRangeNode === true && x2.constructor.prototype.isNode === true || false;
194001
+ function baseClamp$1(number2, lower, upper) {
194002
+ if (number2 === number2) {
194003
+ if (upper !== void 0) {
194004
+ number2 = number2 <= upper ? number2 : upper;
194005
+ }
194006
+ if (lower !== void 0) {
194007
+ number2 = number2 >= lower ? number2 : lower;
194008
+ }
194009
+ }
194010
+ return number2;
193791
194011
  }
193792
- function isSymbolNode(x2) {
193793
- return x2 && x2.isSymbolNode === true && x2.constructor.prototype.isNode === true || false;
194012
+ var _baseClamp = baseClamp$1;
194013
+ var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
194014
+ function clamp$2(number2, lower, upper) {
194015
+ if (upper === void 0) {
194016
+ upper = lower;
194017
+ lower = void 0;
194018
+ }
194019
+ if (upper !== void 0) {
194020
+ upper = toNumber$1(upper);
194021
+ upper = upper === upper ? upper : 0;
194022
+ }
194023
+ if (lower !== void 0) {
194024
+ lower = toNumber$1(lower);
194025
+ lower = lower === lower ? lower : 0;
194026
+ }
194027
+ return baseClamp(toNumber$1(number2), lower, upper);
193794
194028
  }
193795
- function isChain(x2) {
193796
- return x2 && x2.constructor.prototype.isChain === true || false;
194029
+ var clamp_1 = clamp$2;
194030
+ function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
194031
+ const pointSize = 5e-4;
194032
+ const pointScreenSizeMax = 10;
194033
+ const pointScreenSizeMin = 1 / devicePixelRatio2;
194034
+ const scaleFactor = 2 ** zoom2;
194035
+ const xAxisRange = 2 / (xRange * scaleFactor / width2);
194036
+ const yAxisRange = 2 / (yRange * scaleFactor / height2);
194037
+ const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
194038
+ const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
194039
+ const diagonalFraction = pointSize / diagonalAxisRange;
194040
+ const deviceSize = diagonalFraction * diagonalScreenSize;
194041
+ const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
194042
+ return pointSizeDevicePixels;
193797
194043
  }
193798
- function typeOf(x2) {
193799
- var t4 = typeof x2;
193800
- if (t4 === "object") {
193801
- if (x2 === null)
193802
- return "null";
193803
- if (Array.isArray(x2))
193804
- return "Array";
193805
- if (x2 instanceof Date)
193806
- return "Date";
193807
- if (x2 instanceof RegExp)
193808
- return "RegExp";
193809
- if (isBigNumber(x2))
193810
- return "BigNumber";
193811
- if (isComplex(x2))
193812
- return "Complex";
193813
- if (isFraction(x2))
193814
- return "Fraction";
193815
- if (isMatrix(x2))
193816
- return "Matrix";
193817
- if (isUnit(x2))
193818
- return "Unit";
193819
- if (isIndex(x2))
193820
- return "Index";
193821
- if (isRange(x2))
193822
- return "Range";
193823
- if (isResultSet(x2))
193824
- return "ResultSet";
193825
- if (isNode(x2))
193826
- return x2.type;
193827
- if (isChain(x2))
193828
- return "Chain";
193829
- if (isHelp(x2))
193830
- return "Help";
193831
- return "Object";
194044
+ function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
194045
+ const N2 = numCells;
194046
+ const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
194047
+ height: height2,
194048
+ width: width2,
194049
+ viewState: { zoom: zoom2, target: [0, 0, 0] }
194050
+ }).getBounds();
194051
+ const X3 = maxY2 - minY;
194052
+ const Y3 = maxX - minX;
194053
+ const X02 = xRange;
194054
+ const Y02 = yRange;
194055
+ const W = width2;
194056
+ const H = height2;
194057
+ let rho = avgFillDensity;
194058
+ if (!rho) {
194059
+ rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
193832
194060
  }
193833
- if (t4 === "function")
193834
- return "Function";
193835
- return t4;
194061
+ const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
194062
+ const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
194063
+ return pointOpacity;
193836
194064
  }
193837
- function clone$2(x2) {
193838
- var type2 = typeof x2;
193839
- if (type2 === "number" || type2 === "string" || type2 === "boolean" || x2 === null || x2 === void 0) {
193840
- return x2;
193841
- }
193842
- if (typeof x2.clone === "function") {
193843
- return x2.clone();
194065
+ const CELLS_LAYER_ID$1 = "scatterplot";
194066
+ const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
194067
+ const NUM_FORCE_SIMULATION_TICKS = 100;
194068
+ const LABEL_UPDATE_ZOOM_DELTA = 0.25;
194069
+ const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
194070
+ const [r2, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
194071
+ return [r2, g2, b2, 255 * (a2 || 1)];
194072
+ };
194073
+ const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
194074
+ obsEmbedding.data[0][i2],
194075
+ obsEmbedding.data[1][i2],
194076
+ 0
194077
+ ];
194078
+ const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
194079
+ obsEmbedding.data[0][i2],
194080
+ -obsEmbedding.data[1][i2],
194081
+ 0
194082
+ ];
194083
+ const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
194084
+ target2[0] = data2.src.obsEmbedding.data[0][index2];
194085
+ target2[1] = -data2.src.obsEmbedding.data[1][index2];
194086
+ target2[2] = 0;
194087
+ return target2;
194088
+ };
194089
+ class Scatterplot extends AbstractSpatialOrScatterplot {
194090
+ constructor(props2) {
194091
+ super(props2);
194092
+ this.cellsQuadTree = null;
194093
+ this.cellsLayer = null;
194094
+ this.cellsData = null;
194095
+ this.cellSetsForceSimulation = forceCollideRects();
194096
+ this.cellSetsLabelPrevZoom = null;
194097
+ this.cellSetsLayers = [];
194098
+ this.onUpdateCellsData();
194099
+ this.onUpdateCellsLayer();
194100
+ this.onUpdateCellSetsLayers();
193844
194101
  }
193845
- if (Array.isArray(x2)) {
193846
- return x2.map(function(value2) {
193847
- return clone$2(value2);
194102
+ createCellsLayer() {
194103
+ const {
194104
+ obsEmbeddingIndex: obsIndex,
194105
+ theme,
194106
+ cellRadius = 1,
194107
+ cellOpacity = 1,
194108
+ cellSelection,
194109
+ setCellHighlight,
194110
+ setComponentHover,
194111
+ getCellIsSelected,
194112
+ cellColors,
194113
+ getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
194114
+ getExpressionValue,
194115
+ onCellClick,
194116
+ geneExpressionColormap,
194117
+ geneExpressionColormapRange = [0, 1],
194118
+ cellColorEncoding
194119
+ } = this.props;
194120
+ return new ScatterplotLayer({
194121
+ id: CELLS_LAYER_ID$1,
194122
+ data: this.cellsData,
194123
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
194124
+ visible: true,
194125
+ pickable: true,
194126
+ autoHighlight: true,
194127
+ filled: true,
194128
+ stroked: true,
194129
+ backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
194130
+ getCellIsSelected,
194131
+ opacity: cellOpacity,
194132
+ radiusScale: cellRadius,
194133
+ radiusMinPixels: 1,
194134
+ radiusMaxPixels: 30,
194135
+ radiusUnits: "pixels",
194136
+ lineWidthUnits: "pixels",
194137
+ getPosition,
194138
+ getFillColor: getCellColor,
194139
+ getLineColor: getCellColor,
194140
+ getRadius: 1,
194141
+ getExpressionValue,
194142
+ getLineWidth: 0,
194143
+ extensions: [
194144
+ new ScaledExpressionExtension(),
194145
+ new SelectionExtension({ instanced: true })
194146
+ ],
194147
+ colorScaleLo: geneExpressionColormapRange[0],
194148
+ colorScaleHi: geneExpressionColormapRange[1],
194149
+ isExpressionMode: cellColorEncoding === "geneSelection",
194150
+ colormap: geneExpressionColormap,
194151
+ onClick: (info2) => {
194152
+ if (onCellClick) {
194153
+ onCellClick(info2);
194154
+ }
194155
+ },
194156
+ onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
194157
+ updateTriggers: {
194158
+ getExpressionValue,
194159
+ getFillColor: [cellColorEncoding, cellSelection, cellColors],
194160
+ getLineColor: [cellColorEncoding, cellSelection, cellColors],
194161
+ getCellIsSelected
194162
+ }
193848
194163
  });
193849
194164
  }
193850
- if (x2 instanceof Date)
193851
- return new Date(x2.valueOf());
193852
- if (isBigNumber(x2))
193853
- return x2;
193854
- if (x2 instanceof RegExp)
193855
- throw new TypeError("Cannot clone " + x2);
193856
- return mapObject(x2, clone$2);
193857
- }
193858
- function mapObject(object2, callback) {
193859
- var clone2 = {};
193860
- for (var key2 in object2) {
193861
- if (hasOwnProperty$2(object2, key2)) {
193862
- clone2[key2] = callback(object2[key2]);
194165
+ createCellSetsLayers() {
194166
+ const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
194167
+ const result = [];
194168
+ if (cellSetPolygonsVisible) {
194169
+ result.push(new PolygonLayer({
194170
+ id: "cell-sets-polygon-layer",
194171
+ data: cellSetPolygons,
194172
+ stroked: true,
194173
+ filled: false,
194174
+ wireframe: true,
194175
+ lineWidthMaxPixels: 1,
194176
+ getPolygon: (d) => d.hull,
194177
+ getLineColor: (d) => d.color,
194178
+ getLineWidth: 1
194179
+ }));
193863
194180
  }
193864
- }
193865
- return clone2;
193866
- }
193867
- function extend$2(a2, b2) {
193868
- for (var prop in b2) {
193869
- if (hasOwnProperty$2(b2, prop)) {
193870
- a2[prop] = b2[prop];
194181
+ if (cellSetLabelsVisible) {
194182
+ const { zoom: zoom2 } = viewState;
194183
+ const nodes = cellSetPolygons.map((p) => ({
194184
+ x: p.centroid[0],
194185
+ y: p.centroid[1],
194186
+ label: p.name
194187
+ }));
194188
+ const collisionForce = this.cellSetsForceSimulation.size((d) => [
194189
+ cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
194190
+ cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
194191
+ ]);
194192
+ forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
194193
+ result.push(new TextLayer({
194194
+ id: "cell-sets-text-layer",
194195
+ data: nodes,
194196
+ getPosition: (d) => [d.x, d.y],
194197
+ getText: (d) => d.label,
194198
+ getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
194199
+ getSize: cellSetLabelSize,
194200
+ getAngle: 0,
194201
+ getTextAnchor: "middle",
194202
+ getAlignmentBaseline: "center",
194203
+ fontFamily: LABEL_FONT_FAMILY,
194204
+ fontWeight: "normal"
194205
+ }));
193871
194206
  }
194207
+ return result;
193872
194208
  }
193873
- return a2;
193874
- }
193875
- function deepStrictEqual(a2, b2) {
193876
- var prop, i2, len2;
193877
- if (Array.isArray(a2)) {
193878
- if (!Array.isArray(b2)) {
193879
- return false;
194209
+ createSelectionLayers() {
194210
+ const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
194211
+ const { tool } = this.state;
194212
+ const { cellsQuadTree } = this;
194213
+ const flipYTooltip = true;
194214
+ const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
194215
+ return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
194216
+ }
194217
+ getLayers() {
194218
+ const { cellsLayer, cellSetsLayers } = this;
194219
+ return [
194220
+ cellsLayer,
194221
+ ...cellSetsLayers,
194222
+ ...this.createSelectionLayers()
194223
+ ];
194224
+ }
194225
+ onUpdateCellsData() {
194226
+ const { obsEmbedding } = this.props;
194227
+ if (obsEmbedding) {
194228
+ const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
194229
+ this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
194230
+ this.cellsData = {
194231
+ src: {
194232
+ obsEmbedding
194233
+ },
194234
+ length: obsEmbedding.shape[1]
194235
+ };
193880
194236
  }
193881
- if (a2.length !== b2.length) {
193882
- return false;
194237
+ }
194238
+ onUpdateCellsLayer() {
194239
+ const { obsEmbeddingIndex, obsEmbedding } = this.props;
194240
+ if (obsEmbeddingIndex && obsEmbedding) {
194241
+ this.cellsLayer = this.createCellsLayer();
194242
+ } else {
194243
+ this.cellsLayer = null;
193883
194244
  }
193884
- for (i2 = 0, len2 = a2.length; i2 < len2; i2++) {
193885
- if (!deepStrictEqual(a2[i2], b2[i2])) {
193886
- return false;
194245
+ }
194246
+ onUpdateCellSetsLayers(onlyViewStateChange) {
194247
+ if (onlyViewStateChange) {
194248
+ const { viewState, cellSetLabelsVisible } = this.props;
194249
+ const { zoom: zoom2 } = viewState;
194250
+ const { cellSetsLabelPrevZoom } = this;
194251
+ if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
194252
+ this.cellSetsLayers = this.createCellSetsLayers();
194253
+ this.cellSetsLabelPrevZoom = zoom2;
193887
194254
  }
194255
+ } else {
194256
+ this.cellSetsLayers = this.createCellSetsLayers();
193888
194257
  }
193889
- return true;
193890
- } else if (typeof a2 === "function") {
193891
- return a2 === b2;
193892
- } else if (a2 instanceof Object) {
193893
- if (Array.isArray(b2) || !(b2 instanceof Object)) {
193894
- return false;
194258
+ }
194259
+ viewInfoDidUpdate() {
194260
+ const { obsEmbeddingIndex, obsEmbedding } = this.props;
194261
+ super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
194262
+ }
194263
+ componentDidUpdate(prevProps) {
194264
+ this.viewInfoDidUpdate();
194265
+ const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
194266
+ let forceUpdate = false;
194267
+ if (["obsEmbedding"].some(shallowDiff)) {
194268
+ this.onUpdateCellsData();
194269
+ forceUpdate = true;
193895
194270
  }
193896
- for (prop in a2) {
193897
- if (!(prop in b2) || !deepStrictEqual(a2[prop], b2[prop])) {
193898
- return false;
193899
- }
194271
+ if ([
194272
+ "obsEmbeddingIndex",
194273
+ "obsEmbedding",
194274
+ "cellFilter",
194275
+ "cellSelection",
194276
+ "cellColors",
194277
+ "cellRadius",
194278
+ "cellOpacity",
194279
+ "cellRadiusMode",
194280
+ "geneExpressionColormap",
194281
+ "geneExpressionColormapRange",
194282
+ "geneSelection",
194283
+ "cellColorEncoding"
194284
+ ].some(shallowDiff)) {
194285
+ this.onUpdateCellsLayer();
194286
+ forceUpdate = true;
193900
194287
  }
193901
- for (prop in b2) {
193902
- if (!(prop in a2)) {
193903
- return false;
193904
- }
194288
+ if ([
194289
+ "cellSetPolygons",
194290
+ "cellSetPolygonsVisible",
194291
+ "cellSetLabelsVisible",
194292
+ "cellSetLabelSize"
194293
+ ].some(shallowDiff)) {
194294
+ this.onUpdateCellSetsLayers(false);
194295
+ forceUpdate = true;
194296
+ }
194297
+ if (shallowDiff("viewState")) {
194298
+ this.onUpdateCellSetsLayers(true);
194299
+ forceUpdate = true;
194300
+ }
194301
+ if (forceUpdate) {
194302
+ this.forceUpdate();
193905
194303
  }
193906
- return true;
193907
- } else {
193908
- return a2 === b2;
193909
194304
  }
193910
194305
  }
193911
- function hasOwnProperty$2(object2, property2) {
193912
- return object2 && Object.hasOwnProperty.call(object2, property2);
194306
+ const ScatterplotWrapper = React$i.forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
194307
+ function ScatterplotOptions(props2) {
194308
+ const { children: children2, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
194309
+ const observationsLabelNice = capitalize$2(observationsLabel);
194310
+ const classes = useStyles$b();
194311
+ function handleCellRadiusModeChange(event2) {
194312
+ setCellRadiusMode(event2.target.value);
194313
+ }
194314
+ function handleCellOpacityModeChange(event2) {
194315
+ setCellOpacityMode(event2.target.value);
194316
+ }
194317
+ function handleRadiusChange(event2, value2) {
194318
+ setCellRadius(value2);
194319
+ }
194320
+ function handleOpacityChange(event2, value2) {
194321
+ setCellOpacity(value2);
194322
+ }
194323
+ function handleLabelVisibilityChange(event2) {
194324
+ setCellSetLabelsVisible(event2.target.checked);
194325
+ }
194326
+ function handleLabelSizeChange(event2, value2) {
194327
+ setCellSetLabelSize(value2);
194328
+ }
194329
+ function handlePolygonVisibilityChange(event2) {
194330
+ setCellSetPolygonsVisible(event2.target.checked);
194331
+ }
194332
+ function handleGeneExpressionColormapChange(event2) {
194333
+ setGeneExpressionColormap(event2.target.value);
194334
+ }
194335
+ function handleColormapRangeChange(event2, value2) {
194336
+ setGeneExpressionColormapRange(value2);
194337
+ }
194338
+ const handleColormapRangeChangeDebounced = React$i.useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
194339
+ return jsxs(OptionsContainer, { children: [children2, jsx(CellColorEncodingOption, { observationsLabel, cellColorEncoding, setCellColorEncoding }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Labels Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetLabelsVisible, onChange: handleLabelVisibilityChange, name: "scatterplot-option-cell-set-labels", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Label Size"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: !cellSetLabelsVisible, classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellSetLabelSize, onChange: handleLabelSizeChange, "aria-labelledby": "cell-set-label-size-slider", valueLabelDisplay: "auto", step: 1, min: 8, max: 36 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Polygons Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetPolygonsVisible, onChange: handlePolygonVisibilityChange, name: "scatterplot-option-cell-set-polygons", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-radius-mode-select", children: [observationsLabelNice, " Radius Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellRadiusMode, onChange: handleCellRadiusModeChange, inputProps: {
194340
+ id: "cell-radius-mode-select"
194341
+ }, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Radius"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellRadiusMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellRadius, onChange: handleRadiusChange, "aria-labelledby": "cell-radius-slider", valueLabelDisplay: "auto", step: 0.01, min: 0.01, max: 10 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-opacity-mode-select", children: [observationsLabelNice, " Opacity Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellOpacityMode, onChange: handleCellOpacityModeChange, inputProps: {
194342
+ id: "cell-opacity-mode-select"
194343
+ }, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Opacity"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellOpacityMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellOpacity, onChange: handleOpacityChange, "aria-labelledby": "cell-opacity-slider", valueLabelDisplay: "auto", step: 0.05, min: 0, max: 1 }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, htmlFor: "gene-expression-colormap-select", children: "Gene Expression Colormap" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: geneExpressionColormap, onChange: handleGeneExpressionColormapChange, inputProps: {
194344
+ id: "gene-expression-colormap-select"
194345
+ }, children: GLSL_COLORMAPS.map((cmap) => jsx("option", { value: cmap, children: cmap }, cmap)) }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Gene Expression Colormap Range" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: geneExpressionColormapRange, onChange: handleColormapRangeChangeDebounced, "aria-labelledby": "gene-expression-colormap-range-slider", valueLabelDisplay: "auto", step: 5e-3, min: 0, max: 1 }) })] })] });
193913
194346
  }
193914
- function pickShallow(object2, properties2) {
193915
- var copy2 = {};
193916
- for (var i2 = 0; i2 < properties2.length; i2++) {
193917
- var key2 = properties2[i2];
193918
- var value2 = object2[key2];
193919
- if (value2 !== void 0) {
193920
- copy2[key2] = value2;
194347
+ const styles = makeStyles(() => ({
194348
+ tooltipAnchor: {
194349
+ position: "relative",
194350
+ width: "0px",
194351
+ height: "0px",
194352
+ pointerEvents: "none",
194353
+ userSelect: "none"
194354
+ },
194355
+ tooltipContent: {
194356
+ opacity: 0.9,
194357
+ padding: "5px",
194358
+ pointerEvents: "none",
194359
+ "& table > tbody > tr > th, & table > tbody > tr > td": {
194360
+ fontSize: "80%",
194361
+ opacity: 0.8,
194362
+ outline: 0,
194363
+ padding: "0 2px"
194364
+ },
194365
+ "& table": {
194366
+ borderCollapse: "collapse"
193921
194367
  }
193922
194368
  }
193923
- return copy2;
194369
+ }));
194370
+ function Tooltip(props2) {
194371
+ const { x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
194372
+ const ref2 = React$i.useRef();
194373
+ const classes = styles();
194374
+ const [placementX, setPlacementX] = React$i.useState("start");
194375
+ const [placementY, setPlacementY] = React$i.useState("bottom");
194376
+ const getTooltipContainer = useVitessceContainer(ref2);
194377
+ React$i.useEffect(() => {
194378
+ if (ref2 && ref2.current) {
194379
+ const flipX = x2 > parentWidth / 2;
194380
+ const flipY = y2 > parentHeight / 2;
194381
+ setPlacementX(flipX ? "end" : "start");
194382
+ setPlacementY(flipY ? "top" : "bottom");
194383
+ ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
194384
+ ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
194385
+ }
194386
+ }, [x2, y2, parentWidth, parentHeight]);
194387
+ return jsx("div", { ref: ref2, className: classes.tooltipAnchor, children: ref2 && ref2.current ? jsx(Popper$1, { open: true, anchorEl: ref2.current, container: getTooltipContainer, transition: true, placement: `${placementY}-${placementX}`, children: jsx(Paper$1, { elevation: 4, className: classes.tooltipContent, children: children2 }) }) : null });
193924
194388
  }
193925
- var MATRIX_OPTIONS = ["Matrix", "Array"];
193926
- var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
193927
- var config$1 = function config2(options) {
193928
- if (options) {
193929
- throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");
194389
+ function Tooltip2D(props2) {
194390
+ const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
194391
+ if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
194392
+ return null;
193930
194393
  }
193931
- return Object.freeze(DEFAULT_CONFIG);
193932
- };
193933
- _extendsExports(config$1, DEFAULT_CONFIG, {
193934
- MATRIX_OPTIONS,
193935
- NUMBER_OPTIONS
193936
- });
193937
- var typedFunction$1 = { exports: {} };
193938
- (function(module3, exports3) {
193939
- (function(root2, factory2) {
193940
- {
193941
- module3.exports = factory2();
193942
- }
193943
- })(commonjsGlobal$1, function() {
193944
- function ok() {
193945
- return true;
193946
- }
193947
- function notOk() {
193948
- return false;
193949
- }
193950
- function undef() {
193951
- return void 0;
193952
- }
193953
- function create2() {
193954
- var _types = [
193955
- { name: "number", test: function(x2) {
193956
- return typeof x2 === "number";
193957
- } },
193958
- { name: "string", test: function(x2) {
193959
- return typeof x2 === "string";
193960
- } },
193961
- { name: "boolean", test: function(x2) {
193962
- return typeof x2 === "boolean";
193963
- } },
193964
- { name: "Function", test: function(x2) {
193965
- return typeof x2 === "function";
193966
- } },
193967
- { name: "Array", test: Array.isArray },
193968
- { name: "Date", test: function(x2) {
193969
- return x2 instanceof Date;
193970
- } },
193971
- { name: "RegExp", test: function(x2) {
193972
- return x2 instanceof RegExp;
193973
- } },
193974
- { name: "Object", test: function(x2) {
193975
- return typeof x2 === "object" && x2 !== null && x2.constructor === Object;
193976
- } },
193977
- { name: "null", test: function(x2) {
193978
- return x2 === null;
193979
- } },
193980
- { name: "undefined", test: function(x2) {
193981
- return x2 === void 0;
193982
- } }
193983
- ];
193984
- var anyType = {
193985
- name: "any",
193986
- test: ok
193987
- };
193988
- var _ignore = [];
193989
- var _conversions = [];
193990
- var typed2 = {
193991
- types: _types,
193992
- conversions: _conversions,
193993
- ignore: _ignore
193994
- };
193995
- function findTypeByName(typeName) {
193996
- var entry2 = findInArray2(typed2.types, function(entry3) {
193997
- return entry3.name === typeName;
193998
- });
193999
- if (entry2) {
194000
- return entry2;
194001
- }
194002
- if (typeName === "any") {
194003
- return anyType;
194004
- }
194005
- var hint2 = findInArray2(typed2.types, function(entry3) {
194006
- return entry3.name.toLowerCase() === typeName.toLowerCase();
194394
+ const isTooltipVisible = parentUuid === sourceUuid;
194395
+ const crosshairWidth = 1;
194396
+ return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip, { x: x2, y: y2, parentWidth, parentHeight, children: children2 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
194397
+ left: `${x2 - crosshairWidth / 2}px`,
194398
+ top: 0,
194399
+ width: `${crosshairWidth}px`,
194400
+ height: `${parentHeight}px`
194401
+ } }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
194402
+ left: 0,
194403
+ top: `${y2 - crosshairWidth / 2}px`,
194404
+ width: `${parentWidth}px`,
194405
+ height: `${crosshairWidth}px`
194406
+ } }) : null] }) });
194407
+ }
194408
+ function TooltipContent(props2) {
194409
+ const { info: info2 } = props2;
194410
+ return jsx("table", { children: jsx("tbody", { children: Object.entries(info2).map(([key2, value2]) => jsxs("tr", { children: [jsx("th", { children: key2 }), jsx("td", { children: value2 })] }, key2)) }) });
194411
+ }
194412
+ function ScatterplotTooltipSubscriber(props2) {
194413
+ const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
194414
+ const sourceUuid = useComponentHover();
194415
+ const viewInfo = useComponentViewInfo(parentUuid);
194416
+ const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
194417
+ getObsInfo(obsHighlight),
194418
+ ...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
194419
+ ] : [null, null, null];
194420
+ return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
194421
+ }
194422
+ function EmptyMessage(props2) {
194423
+ const { visible, message } = props2;
194424
+ return visible ? jsx("div", { children: message }) : null;
194425
+ }
194426
+ function EmbeddingScatterplotSubscriber(props2) {
194427
+ const {
194428
+ uuid,
194429
+ coordinationScopes,
194430
+ removeGridComponent,
194431
+ theme,
194432
+ disableTooltip = false,
194433
+ observationsLabelOverride,
194434
+ title: titleOverride,
194435
+ averageFillDensity
194436
+ } = props2;
194437
+ const loaders = useLoaders();
194438
+ const setComponentHover = useSetComponentHover();
194439
+ const setComponentViewInfo = useSetComponentViewInfo(uuid);
194440
+ const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, embeddingType: mapping, obsFilter: cellFilter, obsHighlight: cellHighlight, featureSelection: geneSelection, obsSetSelection: cellSetSelection, obsSetColor: cellSetColor, obsColorEncoding: cellColorEncoding, additionalObsSets: additionalCellSets, embeddingObsSetPolygonsVisible: cellSetPolygonsVisible, embeddingObsSetLabelsVisible: cellSetLabelsVisible, embeddingObsSetLabelSize: cellSetLabelSize, embeddingObsRadius: cellRadiusFixed, embeddingObsRadiusMode: cellRadiusMode, embeddingObsOpacity: cellOpacityFixed, embeddingObsOpacityMode: cellOpacityMode, featureValueColormap: geneExpressionColormap, featureValueColormapRange: geneExpressionColormapRange }, { setEmbeddingZoom: setZoom, setEmbeddingTargetX: setTargetX, setEmbeddingTargetY: setTargetY, setEmbeddingTargetZ: setTargetZ, setObsFilter: setCellFilter, setObsSetSelection: setCellSetSelection, setObsHighlight: setCellHighlight, setObsSetColor: setCellSetColor, setObsColorEncoding: setCellColorEncoding, setAdditionalObsSets: setAdditionalCellSets, setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible, setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible, setEmbeddingObsSetLabelSize: setCellSetLabelSize, setEmbeddingObsRadius: setCellRadiusFixed, setEmbeddingObsRadiusMode: setCellRadiusMode, setEmbeddingObsOpacity: setCellOpacityFixed, setEmbeddingObsOpacityMode: setCellOpacityMode, setFeatureValueColormap: setGeneExpressionColormap, setFeatureValueColormapRange: setGeneExpressionColormapRange }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT], coordinationScopes);
194441
+ const observationsLabel = observationsLabelOverride || obsType;
194442
+ const [urls2, addUrl2] = useUrls(loaders, dataset);
194443
+ const [width2, height2, deckRef] = useDeckCanvasSize();
194444
+ const title2 = titleOverride || `Scatterplot (${mapping})`;
194445
+ const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
194446
+ const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
194447
+ const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
194448
+ const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
194449
+ const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
194450
+ const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
194451
+ const isReady = useReady([
194452
+ obsEmbeddingStatus,
194453
+ obsSetsStatus,
194454
+ featureSelectionStatus,
194455
+ matrixIndicesStatus
194456
+ ]);
194457
+ const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
194458
+ const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
194459
+ const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
194460
+ const setCellSelectionProp = React$i.useCallback((v) => {
194461
+ setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
194462
+ }, [
194463
+ additionalCellSets,
194464
+ cellSetColor,
194465
+ setCellColorEncoding,
194466
+ setAdditionalCellSets,
194467
+ setCellSetColor,
194468
+ setCellSetSelection
194469
+ ]);
194470
+ const cellColors = React$i.useMemo(() => getCellColors({
194471
+ cellColorEncoding,
194472
+ expressionData: expressionData && expressionData[0],
194473
+ geneSelection,
194474
+ cellSets: mergedCellSets,
194475
+ cellSetSelection,
194476
+ cellSetColor,
194477
+ obsIndex: matrixObsIndex,
194478
+ theme
194479
+ }), [
194480
+ cellColorEncoding,
194481
+ geneSelection,
194482
+ mergedCellSets,
194483
+ theme,
194484
+ cellSetSelection,
194485
+ cellSetColor,
194486
+ expressionData,
194487
+ matrixObsIndex
194488
+ ]);
194489
+ const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
194490
+ const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
194491
+ const cacheGet = (cache2, key2) => {
194492
+ var _a3;
194493
+ return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
194494
+ };
194495
+ const cellSetPolygons = React$i.useMemo(() => {
194496
+ var _a3;
194497
+ if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsEmbedding && obsEmbeddingIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
194498
+ const newCellSetPolygons = getCellSetPolygons({
194499
+ obsIndex: obsEmbeddingIndex,
194500
+ obsEmbedding,
194501
+ cellSets: mergedCellSets,
194502
+ cellSetSelection,
194503
+ cellSetColor,
194504
+ theme
194505
+ });
194506
+ setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
194507
+ return newCellSetPolygons;
194508
+ }
194509
+ return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
194510
+ }, [
194511
+ cellSetPolygonsVisible,
194512
+ cellSetPolygonCache,
194513
+ cellSetLabelsVisible,
194514
+ theme,
194515
+ obsEmbeddingIndex,
194516
+ obsEmbedding,
194517
+ mergedCellSets,
194518
+ cellSetSelection,
194519
+ cellSetColor
194520
+ ]);
194521
+ const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
194522
+ const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
194523
+ if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
194524
+ const cellCount = obsEmbedding.shape[1];
194525
+ const xE = extent$2(obsEmbedding.data[0]);
194526
+ const yE = extent$2(obsEmbedding.data[1]);
194527
+ const xR = xE[1] - xE[0];
194528
+ const yR = yE[1] - yE[0];
194529
+ return [xR, yR, xE, yE, cellCount];
194530
+ }
194531
+ return [null, null, null, null, null];
194532
+ }, [obsEmbedding]);
194533
+ React$i.useEffect(() => {
194534
+ if (xRange && yRange) {
194535
+ const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
194536
+ setDynamicCellRadius(pointSizeDevicePixels);
194537
+ const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
194538
+ setDynamicCellOpacity(nextCellOpacityScale);
194539
+ if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
194540
+ const newTargetX = xExtent[0] + xRange / 2;
194541
+ const newTargetY = yExtent[0] + yRange / 2;
194542
+ const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
194543
+ setTargetX(newTargetX);
194544
+ setTargetY(-newTargetY);
194545
+ setZoom(newZoom);
194546
+ }
194547
+ }
194548
+ }, [
194549
+ xRange,
194550
+ yRange,
194551
+ xExtent,
194552
+ yExtent,
194553
+ numCells,
194554
+ width2,
194555
+ height2,
194556
+ zoom2,
194557
+ averageFillDensity
194558
+ ]);
194559
+ const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
194560
+ const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
194561
+ const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
194562
+ const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
194563
+ const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
194564
+ const getExpressionValue = useExpressionValueGetter({
194565
+ instanceObsIndex: obsEmbeddingIndex,
194566
+ matrixObsIndex,
194567
+ expressionData
194568
+ });
194569
+ return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(observationsLabel, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange }), children: [jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
194570
+ setZoom(newZoom);
194571
+ setTargetX(target2[0]);
194572
+ setTargetY(target2[1]);
194573
+ setTargetZ(target2[2] || 0);
194574
+ }, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
194575
+ setComponentHover(uuid);
194576
+ }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
194577
+ }
194578
+ function register$c() {
194579
+ registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
194580
+ }
194581
+ function GatingScatterplotOptions(props2) {
194582
+ const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
194583
+ const classes = useStyles$b();
194584
+ const handleGeneSelectChange = (event2) => {
194585
+ const { options } = event2.target;
194586
+ const newValues = [];
194587
+ for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
194588
+ if (options[i2].selected) {
194589
+ newValues.push(options[i2].value);
194590
+ }
194591
+ }
194592
+ if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
194593
+ setGatingFeatureSelectionY(newValues[0]);
194594
+ } else if (newValues.length <= 2) {
194595
+ setGatingFeatureSelectionX(newValues[0]);
194596
+ setGatingFeatureSelectionY(newValues[1]);
194597
+ }
194598
+ };
194599
+ const handleTransformChange = (event2) => {
194600
+ setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
194601
+ };
194602
+ const handleTransformCoefficientChange = (event2) => {
194603
+ const { value: value2 } = event2.target;
194604
+ if (!value2) {
194605
+ setGatingFeatureValueTransformCoefficient(value2);
194606
+ } else {
194607
+ const newCoefficient = Number(value2);
194608
+ if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
194609
+ setGatingFeatureValueTransformCoefficient(value2);
194610
+ }
194611
+ }
194612
+ };
194613
+ return jsxs(Fragment, { children: [jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: capitalize$2(plur(featureType, geneSelectOptions == null ? void 0 : geneSelectOptions.length)) }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { multiple: true, className: classes.select, value: [gatingFeatureSelectionX, gatingFeatureSelectionY].filter((v) => v), onChange: handleGeneSelectChange, inputProps: {
194614
+ id: "scatterplot-gene-select"
194615
+ }, children: geneSelectOptions.map((name2) => jsx("option", { value: name2, children: name2 }, name2)) }, "gating-gene-select") })] }, "gene-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: gatingFeatureValueTransform === null ? "" : gatingFeatureValueTransform, onChange: handleTransformChange, inputProps: {
194616
+ id: "scatterplot-transform-select"
194617
+ }, children: transformOptions.map((opt) => jsx("option", { value: opt.value === null ? "" : opt.value, children: opt.name }, opt.name)) }, "gating-transform-select") })] }, "transform-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform Coefficient" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(TextField$1, { label: "Number", type: "number", onChange: handleTransformCoefficientChange, value: gatingFeatureValueTransformCoefficient, InputLabelProps: {
194618
+ shrink: true
194619
+ } }) })] }, "transform-coefficient-option-row")] });
194620
+ }
194621
+ function GatingSubscriber(props2) {
194622
+ const {
194623
+ uuid,
194624
+ coordinationScopes,
194625
+ removeGridComponent,
194626
+ theme,
194627
+ disableTooltip = false,
194628
+ title: titleOverride,
194629
+ averageFillDensity
194630
+ } = props2;
194631
+ const loaders = useLoaders();
194632
+ const setComponentHover = useSetComponentHover();
194633
+ const setComponentViewInfo = useSetComponentViewInfo(uuid);
194634
+ const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, obsFilter: cellFilter, obsHighlight: cellHighlight, obsSetSelection: cellSetSelection, obsSetColor: cellSetColor, obsColorEncoding: cellColorEncoding, additionalObsSets: additionalCellSets, embeddingObsSetPolygonsVisible: cellSetPolygonsVisible, embeddingObsSetLabelsVisible: cellSetLabelsVisible, embeddingObsSetLabelSize: cellSetLabelSize, embeddingObsRadius: cellRadiusFixed, embeddingObsRadiusMode: cellRadiusMode, embeddingObsOpacity: cellOpacityFixed, embeddingObsOpacityMode: cellOpacityMode, featureValueColormap: geneExpressionColormap, featureValueColormapRange: geneExpressionColormapRange, featureSelection: gatingFeatureSelectionColor, featureValueTransform, featureValueTransformCoefficient, gatingFeatureSelectionX, gatingFeatureSelectionY }, { setEmbeddingZoom: setZoom, setEmbeddingTargetX: setTargetX, setEmbeddingTargetY: setTargetY, setEmbeddingTargetZ: setTargetZ, setObsFilter: setCellFilter, setObsSetSelection: setCellSetSelection, setObsHighlight: setCellHighlight, setObsSetColor: setCellSetColor, setObsColorEncoding: setCellColorEncoding, setAdditionalObsSets: setAdditionalCellSets, setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible, setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible, setEmbeddingObsSetLabelSize: setCellSetLabelSize, setEmbeddingObsRadius: setCellRadiusFixed, setEmbeddingObsRadiusMode: setCellRadiusMode, setEmbeddingObsOpacity: setCellOpacityFixed, setEmbeddingObsOpacityMode: setCellOpacityMode, setFeatureValueColormap: setGeneExpressionColormap, setFeatureValueColormapRange: setGeneExpressionColormapRange, setFeatureValueTransform, setFeatureValueTransformCoefficient, setGatingFeatureSelectionX, setGatingFeatureSelectionY }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.GATING], coordinationScopes);
194635
+ const [urls2, addUrl2] = useUrls(loaders, dataset);
194636
+ const [width2, height2, deckRef] = useDeckCanvasSize();
194637
+ const title2 = React$i.useMemo(() => {
194638
+ if (titleOverride) {
194639
+ return titleOverride;
194640
+ }
194641
+ if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
194642
+ return "Gating";
194643
+ }
194644
+ return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
194645
+ }, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
194646
+ const featureSelectionX = React$i.useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
194647
+ const featureSelectionY = React$i.useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
194648
+ const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
194649
+ const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
194650
+ const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
194651
+ const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
194652
+ const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
194653
+ const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
194654
+ const isReady = useReady([
194655
+ obsSetsStatus,
194656
+ featureSelectionColorStatus,
194657
+ featureSelectionXStatus,
194658
+ featureSelectionYStatus,
194659
+ matrixIndicesStatus
194660
+ ]);
194661
+ const obsXY = React$i.useMemo(() => {
194662
+ if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
194663
+ return null;
194664
+ }
194665
+ let coefficient = 1;
194666
+ const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
194667
+ if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
194668
+ coefficient = parsedTransformCoefficient;
194669
+ }
194670
+ const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
194671
+ const obsX = new Float32Array(cellsCount);
194672
+ const obsY = new Float32Array(cellsCount);
194673
+ for (let i2 = 0; i2 < cellsCount; i2 += 1) {
194674
+ obsX[i2] = transformFunction(expressionDataX[0][i2]);
194675
+ obsY[i2] = transformFunction(expressionDataY[0][i2]);
194676
+ }
194677
+ return {
194678
+ data: [obsX, obsY],
194679
+ shape: [2, cellsCount]
194680
+ };
194681
+ }, [
194682
+ cellsCount,
194683
+ expressionDataX,
194684
+ expressionDataY,
194685
+ featureValueTransform,
194686
+ featureValueTransformCoefficient,
194687
+ featureSelectionX,
194688
+ featureSelectionY
194689
+ ]);
194690
+ const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
194691
+ const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
194692
+ const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
194693
+ const setCellSelectionProp = React$i.useCallback((v) => {
194694
+ setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
194695
+ }, [
194696
+ additionalCellSets,
194697
+ cellSetColor,
194698
+ setCellColorEncoding,
194699
+ setAdditionalCellSets,
194700
+ setCellSetColor,
194701
+ setCellSetSelection
194702
+ ]);
194703
+ const cellColors = React$i.useMemo(() => getCellColors({
194704
+ cellColorEncoding,
194705
+ expressionData: expressionDataColor && expressionDataColor[0],
194706
+ geneSelection: gatingFeatureSelectionColor,
194707
+ cellSets: mergedCellSets,
194708
+ cellSetSelection,
194709
+ cellSetColor,
194710
+ obsIndex,
194711
+ theme
194712
+ }), [
194713
+ cellColorEncoding,
194714
+ gatingFeatureSelectionColor,
194715
+ mergedCellSets,
194716
+ theme,
194717
+ cellSetSelection,
194718
+ cellSetColor,
194719
+ expressionDataColor,
194720
+ obsIndex
194721
+ ]);
194722
+ const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
194723
+ const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
194724
+ const cacheGet = (cache2, key2) => {
194725
+ var _a3;
194726
+ return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
194727
+ };
194728
+ const cellSetPolygons = React$i.useMemo(() => {
194729
+ var _a3;
194730
+ if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsXY && obsIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
194731
+ const newCellSetPolygons = getCellSetPolygons({
194732
+ obsIndex,
194733
+ obsEmbedding: obsXY,
194734
+ cellSets: mergedCellSets,
194735
+ cellSetSelection,
194736
+ cellSetColor,
194737
+ theme
194738
+ });
194739
+ setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
194740
+ return newCellSetPolygons;
194741
+ }
194742
+ return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
194743
+ }, [
194744
+ cellSetPolygonsVisible,
194745
+ cellSetPolygonCache,
194746
+ cellSetLabelsVisible,
194747
+ theme,
194748
+ obsIndex,
194749
+ obsXY,
194750
+ mergedCellSets,
194751
+ cellSetSelection,
194752
+ cellSetColor
194753
+ ]);
194754
+ const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
194755
+ const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
194756
+ if (obsXY && obsXY.data && obsXY.shape) {
194757
+ const cellCount = obsXY.shape[1];
194758
+ const xE = extent$2(obsXY.data[0]);
194759
+ const yE = extent$2(obsXY.data[1]);
194760
+ const xR = xE[1] - xE[0];
194761
+ const yR = yE[1] - yE[0];
194762
+ return [xR, yR, xE, yE, cellCount];
194763
+ }
194764
+ return [null, null, null, null, null];
194765
+ }, [obsXY]);
194766
+ React$i.useEffect(() => {
194767
+ if (xRange && yRange) {
194768
+ const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
194769
+ setDynamicCellRadius(pointSizeDevicePixels);
194770
+ const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
194771
+ setDynamicCellOpacity(nextCellOpacityScale);
194772
+ if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
194773
+ const newTargetX = xExtent[0] + xRange / 2;
194774
+ const newTargetY = yExtent[0] + yRange / 2;
194775
+ const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
194776
+ setTargetX(newTargetX);
194777
+ setTargetY(-newTargetY);
194778
+ setZoom(newZoom);
194779
+ }
194780
+ }
194781
+ }, [
194782
+ xRange,
194783
+ yRange,
194784
+ xExtent,
194785
+ yExtent,
194786
+ numCells,
194787
+ width2,
194788
+ height2,
194789
+ zoom2,
194790
+ averageFillDensity
194791
+ ]);
194792
+ const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
194793
+ const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
194794
+ const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
194795
+ const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
194796
+ const getExpressionValue = useExpressionValueGetter({
194797
+ instanceObsIndex: obsIndex,
194798
+ matrixObsIndex: obsIndex,
194799
+ expressionData: expressionDataColor
194800
+ });
194801
+ const getObsInfo = React$i.useCallback((obsId) => {
194802
+ var _a3;
194803
+ const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
194804
+ const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
194805
+ const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
194806
+ const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
194807
+ if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
194808
+ obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
194809
+ obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
194810
+ }
194811
+ return obsInfo;
194812
+ }, [
194813
+ obsXY,
194814
+ obsIndex,
194815
+ featureValueTransform,
194816
+ gatingFeatureSelectionX,
194817
+ gatingFeatureSelectionY,
194818
+ obsType
194819
+ ]);
194820
+ return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(obsType, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel: obsType, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, children: jsx(GatingScatterplotOptions, { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform: featureValueTransform, setGatingFeatureValueTransform: (newValue) => {
194821
+ setFeatureValueTransform(newValue);
194822
+ setTargetX(null);
194823
+ setTargetY(null);
194824
+ setZoom(null);
194825
+ }, gatingFeatureValueTransformCoefficient: featureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient: setFeatureValueTransformCoefficient, geneSelectOptions: featureIndex, transformOptions: VALUE_TRANSFORM_OPTIONS }) }), children: [jsx(EmptyMessage, { visible: !(gatingFeatureSelectionX && gatingFeatureSelectionY), message: `Select two ${plur(featureType, 2)} in the plot settings.` }), jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, hideTools: !(gatingFeatureSelectionX && gatingFeatureSelectionY), viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
194826
+ setZoom(newZoom);
194827
+ setTargetX(target2[0]);
194828
+ setTargetY(target2[1]);
194829
+ setTargetZ(target2[2] || 0);
194830
+ }, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
194831
+ setComponentHover(uuid);
194832
+ }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
194833
+ }
194834
+ function register$b() {
194835
+ registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
194836
+ }
194837
+ var _extends$1 = { exports: {} };
194838
+ var hasRequired_extends;
194839
+ function require_extends() {
194840
+ if (hasRequired_extends)
194841
+ return _extends$1.exports;
194842
+ hasRequired_extends = 1;
194843
+ (function(module3) {
194844
+ function _extends2() {
194845
+ module3.exports = _extends2 = Object.assign ? Object.assign.bind() : function(target2) {
194846
+ for (var i2 = 1; i2 < arguments.length; i2++) {
194847
+ var source2 = arguments[i2];
194848
+ for (var key2 in source2) {
194849
+ if (Object.prototype.hasOwnProperty.call(source2, key2)) {
194850
+ target2[key2] = source2[key2];
194851
+ }
194852
+ }
194853
+ }
194854
+ return target2;
194855
+ }, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
194856
+ return _extends2.apply(this, arguments);
194857
+ }
194858
+ module3.exports = _extends2, module3.exports.__esModule = true, module3.exports["default"] = module3.exports;
194859
+ })(_extends$1);
194860
+ return _extends$1.exports;
194861
+ }
194862
+ var _extendsExports = require_extends();
194863
+ var DEFAULT_CONFIG = {
194864
+ epsilon: 1e-12,
194865
+ matrix: "Matrix",
194866
+ number: "number",
194867
+ precision: 64,
194868
+ predictable: false,
194869
+ randomSeed: null
194870
+ };
194871
+ function isNumber$2(x2) {
194872
+ return typeof x2 === "number";
194873
+ }
194874
+ function isBigNumber(x2) {
194875
+ if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
194876
+ return false;
194877
+ }
194878
+ if (x2.isBigNumber === true && typeof x2.constructor.prototype === "object" && x2.constructor.prototype.isBigNumber === true) {
194879
+ return true;
194880
+ }
194881
+ if (typeof x2.constructor.isDecimal === "function" && x2.constructor.isDecimal(x2) === true) {
194882
+ return true;
194883
+ }
194884
+ return false;
194885
+ }
194886
+ function isComplex(x2) {
194887
+ return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
194888
+ }
194889
+ function isFraction(x2) {
194890
+ return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
194891
+ }
194892
+ function isUnit(x2) {
194893
+ return x2 && x2.constructor.prototype.isUnit === true || false;
194894
+ }
194895
+ function isString$1(x2) {
194896
+ return typeof x2 === "string";
194897
+ }
194898
+ var isArray$1 = Array.isArray;
194899
+ function isMatrix(x2) {
194900
+ return x2 && x2.constructor.prototype.isMatrix === true || false;
194901
+ }
194902
+ function isCollection(x2) {
194903
+ return Array.isArray(x2) || isMatrix(x2);
194904
+ }
194905
+ function isDenseMatrix(x2) {
194906
+ return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
194907
+ }
194908
+ function isSparseMatrix(x2) {
194909
+ return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
194910
+ }
194911
+ function isRange(x2) {
194912
+ return x2 && x2.constructor.prototype.isRange === true || false;
194913
+ }
194914
+ function isIndex(x2) {
194915
+ return x2 && x2.constructor.prototype.isIndex === true || false;
194916
+ }
194917
+ function isBoolean$3(x2) {
194918
+ return typeof x2 === "boolean";
194919
+ }
194920
+ function isResultSet(x2) {
194921
+ return x2 && x2.constructor.prototype.isResultSet === true || false;
194922
+ }
194923
+ function isHelp(x2) {
194924
+ return x2 && x2.constructor.prototype.isHelp === true || false;
194925
+ }
194926
+ function isFunction$2(x2) {
194927
+ return typeof x2 === "function";
194928
+ }
194929
+ function isDate$2(x2) {
194930
+ return x2 instanceof Date;
194931
+ }
194932
+ function isRegExp$1(x2) {
194933
+ return x2 instanceof RegExp;
194934
+ }
194935
+ function isObject$1(x2) {
194936
+ return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
194937
+ }
194938
+ function isNull(x2) {
194939
+ return x2 === null;
194940
+ }
194941
+ function isUndefined(x2) {
194942
+ return x2 === void 0;
194943
+ }
194944
+ function isAccessorNode(x2) {
194945
+ return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
194946
+ }
194947
+ function isArrayNode(x2) {
194948
+ return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
194949
+ }
194950
+ function isAssignmentNode(x2) {
194951
+ return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
194952
+ }
194953
+ function isBlockNode(x2) {
194954
+ return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
194955
+ }
194956
+ function isConditionalNode(x2) {
194957
+ return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
194958
+ }
194959
+ function isConstantNode(x2) {
194960
+ return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
194961
+ }
194962
+ function isFunctionAssignmentNode(x2) {
194963
+ return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
194964
+ }
194965
+ function isFunctionNode(x2) {
194966
+ return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
194967
+ }
194968
+ function isIndexNode(x2) {
194969
+ return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
194970
+ }
194971
+ function isNode(x2) {
194972
+ return x2 && x2.isNode === true && x2.constructor.prototype.isNode === true || false;
194973
+ }
194974
+ function isObjectNode(x2) {
194975
+ return x2 && x2.isObjectNode === true && x2.constructor.prototype.isNode === true || false;
194976
+ }
194977
+ function isOperatorNode(x2) {
194978
+ return x2 && x2.isOperatorNode === true && x2.constructor.prototype.isNode === true || false;
194979
+ }
194980
+ function isParenthesisNode(x2) {
194981
+ return x2 && x2.isParenthesisNode === true && x2.constructor.prototype.isNode === true || false;
194982
+ }
194983
+ function isRangeNode(x2) {
194984
+ return x2 && x2.isRangeNode === true && x2.constructor.prototype.isNode === true || false;
194985
+ }
194986
+ function isSymbolNode(x2) {
194987
+ return x2 && x2.isSymbolNode === true && x2.constructor.prototype.isNode === true || false;
194988
+ }
194989
+ function isChain(x2) {
194990
+ return x2 && x2.constructor.prototype.isChain === true || false;
194991
+ }
194992
+ function typeOf(x2) {
194993
+ var t4 = typeof x2;
194994
+ if (t4 === "object") {
194995
+ if (x2 === null)
194996
+ return "null";
194997
+ if (Array.isArray(x2))
194998
+ return "Array";
194999
+ if (x2 instanceof Date)
195000
+ return "Date";
195001
+ if (x2 instanceof RegExp)
195002
+ return "RegExp";
195003
+ if (isBigNumber(x2))
195004
+ return "BigNumber";
195005
+ if (isComplex(x2))
195006
+ return "Complex";
195007
+ if (isFraction(x2))
195008
+ return "Fraction";
195009
+ if (isMatrix(x2))
195010
+ return "Matrix";
195011
+ if (isUnit(x2))
195012
+ return "Unit";
195013
+ if (isIndex(x2))
195014
+ return "Index";
195015
+ if (isRange(x2))
195016
+ return "Range";
195017
+ if (isResultSet(x2))
195018
+ return "ResultSet";
195019
+ if (isNode(x2))
195020
+ return x2.type;
195021
+ if (isChain(x2))
195022
+ return "Chain";
195023
+ if (isHelp(x2))
195024
+ return "Help";
195025
+ return "Object";
195026
+ }
195027
+ if (t4 === "function")
195028
+ return "Function";
195029
+ return t4;
195030
+ }
195031
+ function clone$2(x2) {
195032
+ var type2 = typeof x2;
195033
+ if (type2 === "number" || type2 === "string" || type2 === "boolean" || x2 === null || x2 === void 0) {
195034
+ return x2;
195035
+ }
195036
+ if (typeof x2.clone === "function") {
195037
+ return x2.clone();
195038
+ }
195039
+ if (Array.isArray(x2)) {
195040
+ return x2.map(function(value2) {
195041
+ return clone$2(value2);
195042
+ });
195043
+ }
195044
+ if (x2 instanceof Date)
195045
+ return new Date(x2.valueOf());
195046
+ if (isBigNumber(x2))
195047
+ return x2;
195048
+ if (x2 instanceof RegExp)
195049
+ throw new TypeError("Cannot clone " + x2);
195050
+ return mapObject(x2, clone$2);
195051
+ }
195052
+ function mapObject(object2, callback) {
195053
+ var clone2 = {};
195054
+ for (var key2 in object2) {
195055
+ if (hasOwnProperty$2(object2, key2)) {
195056
+ clone2[key2] = callback(object2[key2]);
195057
+ }
195058
+ }
195059
+ return clone2;
195060
+ }
195061
+ function extend$2(a2, b2) {
195062
+ for (var prop in b2) {
195063
+ if (hasOwnProperty$2(b2, prop)) {
195064
+ a2[prop] = b2[prop];
195065
+ }
195066
+ }
195067
+ return a2;
195068
+ }
195069
+ function deepStrictEqual(a2, b2) {
195070
+ var prop, i2, len2;
195071
+ if (Array.isArray(a2)) {
195072
+ if (!Array.isArray(b2)) {
195073
+ return false;
195074
+ }
195075
+ if (a2.length !== b2.length) {
195076
+ return false;
195077
+ }
195078
+ for (i2 = 0, len2 = a2.length; i2 < len2; i2++) {
195079
+ if (!deepStrictEqual(a2[i2], b2[i2])) {
195080
+ return false;
195081
+ }
195082
+ }
195083
+ return true;
195084
+ } else if (typeof a2 === "function") {
195085
+ return a2 === b2;
195086
+ } else if (a2 instanceof Object) {
195087
+ if (Array.isArray(b2) || !(b2 instanceof Object)) {
195088
+ return false;
195089
+ }
195090
+ for (prop in a2) {
195091
+ if (!(prop in b2) || !deepStrictEqual(a2[prop], b2[prop])) {
195092
+ return false;
195093
+ }
195094
+ }
195095
+ for (prop in b2) {
195096
+ if (!(prop in a2)) {
195097
+ return false;
195098
+ }
195099
+ }
195100
+ return true;
195101
+ } else {
195102
+ return a2 === b2;
195103
+ }
195104
+ }
195105
+ function hasOwnProperty$2(object2, property2) {
195106
+ return object2 && Object.hasOwnProperty.call(object2, property2);
195107
+ }
195108
+ function pickShallow(object2, properties2) {
195109
+ var copy2 = {};
195110
+ for (var i2 = 0; i2 < properties2.length; i2++) {
195111
+ var key2 = properties2[i2];
195112
+ var value2 = object2[key2];
195113
+ if (value2 !== void 0) {
195114
+ copy2[key2] = value2;
195115
+ }
195116
+ }
195117
+ return copy2;
195118
+ }
195119
+ var MATRIX_OPTIONS = ["Matrix", "Array"];
195120
+ var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
195121
+ var config$1 = function config2(options) {
195122
+ if (options) {
195123
+ throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");
195124
+ }
195125
+ return Object.freeze(DEFAULT_CONFIG);
195126
+ };
195127
+ _extendsExports(config$1, DEFAULT_CONFIG, {
195128
+ MATRIX_OPTIONS,
195129
+ NUMBER_OPTIONS
195130
+ });
195131
+ var typedFunction$1 = { exports: {} };
195132
+ (function(module3, exports3) {
195133
+ (function(root2, factory2) {
195134
+ {
195135
+ module3.exports = factory2();
195136
+ }
195137
+ })(commonjsGlobal$1, function() {
195138
+ function ok() {
195139
+ return true;
195140
+ }
195141
+ function notOk() {
195142
+ return false;
195143
+ }
195144
+ function undef() {
195145
+ return void 0;
195146
+ }
195147
+ function create2() {
195148
+ var _types = [
195149
+ { name: "number", test: function(x2) {
195150
+ return typeof x2 === "number";
195151
+ } },
195152
+ { name: "string", test: function(x2) {
195153
+ return typeof x2 === "string";
195154
+ } },
195155
+ { name: "boolean", test: function(x2) {
195156
+ return typeof x2 === "boolean";
195157
+ } },
195158
+ { name: "Function", test: function(x2) {
195159
+ return typeof x2 === "function";
195160
+ } },
195161
+ { name: "Array", test: Array.isArray },
195162
+ { name: "Date", test: function(x2) {
195163
+ return x2 instanceof Date;
195164
+ } },
195165
+ { name: "RegExp", test: function(x2) {
195166
+ return x2 instanceof RegExp;
195167
+ } },
195168
+ { name: "Object", test: function(x2) {
195169
+ return typeof x2 === "object" && x2 !== null && x2.constructor === Object;
195170
+ } },
195171
+ { name: "null", test: function(x2) {
195172
+ return x2 === null;
195173
+ } },
195174
+ { name: "undefined", test: function(x2) {
195175
+ return x2 === void 0;
195176
+ } }
195177
+ ];
195178
+ var anyType = {
195179
+ name: "any",
195180
+ test: ok
195181
+ };
195182
+ var _ignore = [];
195183
+ var _conversions = [];
195184
+ var typed2 = {
195185
+ types: _types,
195186
+ conversions: _conversions,
195187
+ ignore: _ignore
195188
+ };
195189
+ function findTypeByName(typeName) {
195190
+ var entry2 = findInArray2(typed2.types, function(entry3) {
195191
+ return entry3.name === typeName;
195192
+ });
195193
+ if (entry2) {
195194
+ return entry2;
195195
+ }
195196
+ if (typeName === "any") {
195197
+ return anyType;
195198
+ }
195199
+ var hint2 = findInArray2(typed2.types, function(entry3) {
195200
+ return entry3.name.toLowerCase() === typeName.toLowerCase();
194007
195201
  });
194008
195202
  throw new TypeError('Unknown type "' + typeName + '"' + (hint2 ? '. Did you mean "' + hint2.name + '"?' : ""));
194009
195203
  }
@@ -197807,7 +199001,7 @@ void main() {
197807
199001
  function ceil$2(x2) {
197808
199002
  return finalise(x2 = new this(x2), x2.e + 1, 2);
197809
199003
  }
197810
- function clamp$2(x2, min2, max2) {
199004
+ function clamp$1(x2, min2, max2) {
197811
199005
  return new this(x2).clamp(min2, max2);
197812
199006
  }
197813
199007
  function config(obj) {
@@ -197976,7 +199170,7 @@ void main() {
197976
199170
  Decimal2.atan2 = atan2$2;
197977
199171
  Decimal2.cbrt = cbrt;
197978
199172
  Decimal2.ceil = ceil$2;
197979
- Decimal2.clamp = clamp$2;
199173
+ Decimal2.clamp = clamp$1;
197980
199174
  Decimal2.cos = cos$3;
197981
199175
  Decimal2.cosh = cosh$1;
197982
199176
  Decimal2.div = div;
@@ -208393,1157 +209587,6 @@ void main() {
208393
209587
  const autoImageLayerDefs = await Promise.all(autoImageLayerDefPromises);
208394
209588
  return [autoImageLayerDefs, nextImageLoaders, nextImageMetaAndLayers];
208395
209589
  }
208396
- const useStyles$8 = makeStyles(() => ({
208397
- tool: {
208398
- position: "absolute",
208399
- display: "inline",
208400
- zIndex: "1000",
208401
- opacity: ".65",
208402
- color: "black",
208403
- "&:hover": {
208404
- opacity: ".90"
208405
- }
208406
- },
208407
- iconButton: {
208408
- padding: "0",
208409
- height: "2em",
208410
- width: "2em",
208411
- backgroundColor: "white",
208412
- display: "inline-block",
208413
- fontWeight: "400",
208414
- textAlign: "center",
208415
- verticalAlign: "middle",
208416
- cursor: "pointer",
208417
- userSelect: "none",
208418
- border: "1px solid #6c757d",
208419
- fontSize: "1rem",
208420
- lineHeight: "1.5",
208421
- borderRadius: "0.25rem",
208422
- transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out",
208423
- color: "#6c757d",
208424
- marginRight: "0.5rem",
208425
- "& > svg": {
208426
- verticalAlign: "middle"
208427
- }
208428
- },
208429
- iconButtonActive: {
208430
- color: "#fff",
208431
- backgroundColor: "#6c757d",
208432
- borderColor: "#6c757d",
208433
- boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
208434
- }
208435
- }));
208436
- function IconButton(props2) {
208437
- const { alt, onClick, isActive: isActive2, children: children2 } = props2;
208438
- const classes = useStyles$8();
208439
- return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children2 });
208440
- }
208441
- function ToolMenu(props2) {
208442
- const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
208443
- const classes = useStyles$8();
208444
- return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
208445
- }
208446
- const getCursorWithTool = () => "crosshair";
208447
- const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
208448
- function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
208449
- return (info2) => {
208450
- if (setComponentHover) {
208451
- setComponentHover();
208452
- }
208453
- if (info2.index) {
208454
- const obsId = obsIndex[info2.index];
208455
- if (setObsHighlight) {
208456
- setObsHighlight(obsId);
208457
- }
208458
- } else if (setObsHighlight) {
208459
- setObsHighlight(null);
208460
- }
208461
- };
208462
- }
208463
- class AbstractSpatialOrScatterplot extends React$i.PureComponent {
208464
- constructor(props2) {
208465
- super(props2);
208466
- this.state = {
208467
- gl: null,
208468
- tool: null
208469
- };
208470
- this.viewport = null;
208471
- this.onViewStateChange = this.onViewStateChange.bind(this);
208472
- this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
208473
- this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
208474
- this.onToolChange = this.onToolChange.bind(this);
208475
- this.onHover = this.onHover.bind(this);
208476
- }
208477
- onViewStateChange({ viewState: nextViewState }) {
208478
- const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
208479
- const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
208480
- setViewState({
208481
- ...nextViewState,
208482
- target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
208483
- });
208484
- }
208485
- onInitializeViewInfo({ viewport }) {
208486
- this.viewport = viewport;
208487
- }
208488
- onWebGLInitialized(gl) {
208489
- this.setState({ gl });
208490
- }
208491
- onToolChange(tool) {
208492
- const { onToolChange: onToolChangeProp } = this.props;
208493
- this.setState({ tool });
208494
- if (onToolChangeProp) {
208495
- onToolChangeProp(tool);
208496
- }
208497
- }
208498
- getLayers() {
208499
- return [];
208500
- }
208501
- onHover(info2) {
208502
- const { coordinate, sourceLayer: layer, tile } = info2;
208503
- const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
208504
- const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
208505
- if (!setCellHighlight || !tile) {
208506
- return null;
208507
- }
208508
- if (!layer || !coordinate) {
208509
- if (cellHighlight && hasBitmask) {
208510
- setCellHighlight(null);
208511
- }
208512
- return null;
208513
- }
208514
- const { content: content2, bbox: bbox2, z } = tile;
208515
- if (!content2) {
208516
- if (cellHighlight && hasBitmask) {
208517
- setCellHighlight(null);
208518
- }
208519
- return null;
208520
- }
208521
- const { data: data2, width: width2, height: height2 } = content2;
208522
- const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
208523
- const bounds2 = [
208524
- left2,
208525
- data2.height < layer.tileSize ? height2 : bottom2,
208526
- data2.width < layer.tileSize ? width2 : right2,
208527
- top2
208528
- ];
208529
- if (!data2) {
208530
- if (cellHighlight && hasBitmask) {
208531
- setCellHighlight(null);
208532
- }
208533
- return null;
208534
- }
208535
- if (layer.id.includes("bitmask")) {
208536
- const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
208537
- const dataCoords = [
208538
- Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
208539
- Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
208540
- ];
208541
- const coords = dataCoords[1] * width2 + dataCoords[0];
208542
- const hoverData = data2.map((d) => d[coords]);
208543
- const cellId = hoverData.find((i2) => i2 > 0);
208544
- if (cellId !== Number(cellHighlight)) {
208545
- if (setComponentHover) {
208546
- setComponentHover();
208547
- }
208548
- setCellHighlight(cellId ? String(cellId) : null);
208549
- }
208550
- }
208551
- }
208552
- viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
208553
- const { updateViewInfo, uuid } = this.props;
208554
- const { viewport } = this;
208555
- if (updateViewInfo && viewport) {
208556
- updateViewInfo({
208557
- uuid,
208558
- project: (obsId) => {
208559
- try {
208560
- if (obsIndex && obsLocations) {
208561
- const getObsCoords = makeGetObsCoords(obsLocations);
208562
- const obsIdx = obsIndex.indexOf(obsId);
208563
- const obsCoord = getObsCoords(obsIdx);
208564
- return viewport.project(obsCoord);
208565
- }
208566
- return [null, null];
208567
- } catch (e3) {
208568
- return [null, null];
208569
- }
208570
- }
208571
- });
208572
- }
208573
- }
208574
- componentDidUpdate() {
208575
- }
208576
- use3d() {
208577
- return false;
208578
- }
208579
- render() {
208580
- var _a3, _b2, _c, _d;
208581
- const { deckRef, viewState, uuid, hideTools } = this.props;
208582
- const { gl, tool } = this.state;
208583
- const layers = this.getLayers();
208584
- const use3d = this.use3d();
208585
- const showCellSelectionTools = this.obsSegmentationsData !== null;
208586
- const showPanTool = layers.length > 0;
208587
- const useDevicePixels = !use3d && (((_b2 = (_a3 = this.obsSegmentationsData) == null ? void 0 : _a3.shape) == null ? void 0 : _b2[0]) < 1e5 || ((_d = (_c = this.obsLocationsData) == null ? void 0 : _c.shape) == null ? void 0 : _d[1]) < 1e5);
208588
- return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
208589
- pan: showPanTool && !hideTools,
208590
- selectRectangle: showCellSelectionTools && !hideTools,
208591
- selectLasso: showCellSelectionTools && !hideTools
208592
- } }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
208593
- use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
208594
- id: "ortho"
208595
- })
208596
- ], layers: gl && viewState.target.slice(0, 2).every((i2) => typeof i2 === "number") ? layers : [], glOptions: DEFAULT_GL_OPTIONS, onWebGLInitialized: this.onWebGLInitialized, onViewStateChange: this.onViewStateChange, viewState, useDevicePixels, controller: tool ? { dragPan: false } : true, getCursor: tool ? getCursorWithTool : getCursor, onHover: this.onHover, children: this.onInitializeViewInfo })] });
208597
- }
208598
- }
208599
- function createQuadTree(obsEmbedding, getCellCoords) {
208600
- if (!obsEmbedding) {
208601
- return null;
208602
- }
208603
- const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
208604
- return tree2;
208605
- }
208606
- function constant$5(v) {
208607
- return () => v;
208608
- }
208609
- function jiggle$1(v) {
208610
- return v + (Math.random() - 0.5) * 1e-6;
208611
- }
208612
- function forceCollideRects() {
208613
- let nodes;
208614
- let masses;
208615
- let strength = 1;
208616
- let iterations2 = 1;
208617
- let sizes;
208618
- let size2 = constant$5([0, 0]);
208619
- function xCenter(d) {
208620
- return d.x + d.vx + sizes[d.index][0] / 2;
208621
- }
208622
- function yCenter(d) {
208623
- return d.y + d.vy + sizes[d.index][1] / 2;
208624
- }
208625
- function prepare2(quad2) {
208626
- if (quad2.data) {
208627
- quad2.size = sizes[quad2.data.index];
208628
- } else {
208629
- quad2.size = [0, 0];
208630
- for (let i2 = 0; i2 < 4; i2++) {
208631
- if (quad2[i2] && quad2[i2].size) {
208632
- quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
208633
- quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
208634
- }
208635
- }
208636
- }
208637
- }
208638
- function force2() {
208639
- let node;
208640
- let nodeSize;
208641
- let nodeMass;
208642
- let xi;
208643
- let yi;
208644
- const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
208645
- function apply2(quad2, x02, y02, x12, y12) {
208646
- const { data: data2 } = quad2;
208647
- const xSize = (nodeSize[0] + quad2.size[0]) / 2;
208648
- const ySize = (nodeSize[1] + quad2.size[1]) / 2;
208649
- if (data2 && data2.index > node.index) {
208650
- let x2 = jiggle$1(xi - xCenter(data2));
208651
- let y2 = jiggle$1(yi - yCenter(data2));
208652
- const xd = Math.abs(x2) - xSize;
208653
- const yd = Math.abs(y2) - ySize;
208654
- if (xd < 0 && yd < 0) {
208655
- const l2 = Math.sqrt(x2 * x2 + y2 * y2);
208656
- const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
208657
- if (Math.abs(xd) < Math.abs(yd)) {
208658
- node.vx -= (x2 *= xd / l2 * strength) * m2;
208659
- data2.vx += x2 * (1 - m2);
208660
- } else {
208661
- node.vy -= (y2 *= yd / l2 * strength) * m2;
208662
- data2.vy += y2 * (1 - m2);
208663
- }
208664
- }
208665
- return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
208666
- }
208667
- return false;
208668
- }
208669
- function iterate2() {
208670
- for (let j2 = 0; j2 < nodes.length; j2++) {
208671
- node = nodes[j2];
208672
- nodeSize = sizes[j2];
208673
- nodeMass = masses[j2];
208674
- xi = xCenter(node);
208675
- yi = yCenter(node);
208676
- tree2.visit(apply2);
208677
- }
208678
- }
208679
- for (let i2 = 0; i2 < iterations2; i2++) {
208680
- iterate2();
208681
- }
208682
- }
208683
- force2.initialize = (v) => {
208684
- nodes = v;
208685
- sizes = nodes.map(size2);
208686
- masses = sizes.map((d) => d[0] + d[1]);
208687
- };
208688
- force2.iterations = (...v) => {
208689
- if (v.length) {
208690
- iterations2 = +v[0];
208691
- return force2;
208692
- }
208693
- return iterations2;
208694
- };
208695
- force2.strength = (...v) => {
208696
- if (v.length) {
208697
- strength = +v[0];
208698
- return force2;
208699
- }
208700
- return strength;
208701
- };
208702
- force2.size = (...v) => {
208703
- if (v.length) {
208704
- size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
208705
- return force2;
208706
- }
208707
- return size2;
208708
- };
208709
- return force2;
208710
- }
208711
- function baseClamp$1(number2, lower, upper) {
208712
- if (number2 === number2) {
208713
- if (upper !== void 0) {
208714
- number2 = number2 <= upper ? number2 : upper;
208715
- }
208716
- if (lower !== void 0) {
208717
- number2 = number2 >= lower ? number2 : lower;
208718
- }
208719
- }
208720
- return number2;
208721
- }
208722
- var _baseClamp = baseClamp$1;
208723
- var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
208724
- function clamp$1(number2, lower, upper) {
208725
- if (upper === void 0) {
208726
- upper = lower;
208727
- lower = void 0;
208728
- }
208729
- if (upper !== void 0) {
208730
- upper = toNumber$1(upper);
208731
- upper = upper === upper ? upper : 0;
208732
- }
208733
- if (lower !== void 0) {
208734
- lower = toNumber$1(lower);
208735
- lower = lower === lower ? lower : 0;
208736
- }
208737
- return baseClamp(toNumber$1(number2), lower, upper);
208738
- }
208739
- var clamp_1 = clamp$1;
208740
- function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
208741
- const pointSize = 5e-4;
208742
- const pointScreenSizeMax = 10;
208743
- const pointScreenSizeMin = 1 / devicePixelRatio2;
208744
- const scaleFactor = 2 ** zoom2;
208745
- const xAxisRange = 2 / (xRange * scaleFactor / width2);
208746
- const yAxisRange = 2 / (yRange * scaleFactor / height2);
208747
- const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
208748
- const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
208749
- const diagonalFraction = pointSize / diagonalAxisRange;
208750
- const deviceSize = diagonalFraction * diagonalScreenSize;
208751
- const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
208752
- return pointSizeDevicePixels;
208753
- }
208754
- function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
208755
- const N2 = numCells;
208756
- const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
208757
- height: height2,
208758
- width: width2,
208759
- viewState: { zoom: zoom2, target: [0, 0, 0] }
208760
- }).getBounds();
208761
- const X3 = maxY2 - minY;
208762
- const Y3 = maxX - minX;
208763
- const X02 = xRange;
208764
- const Y02 = yRange;
208765
- const W = width2;
208766
- const H = height2;
208767
- let rho = avgFillDensity;
208768
- if (!rho) {
208769
- rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
208770
- }
208771
- const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
208772
- const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
208773
- return pointOpacity;
208774
- }
208775
- const CELLS_LAYER_ID$1 = "scatterplot";
208776
- const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
208777
- const NUM_FORCE_SIMULATION_TICKS = 100;
208778
- const LABEL_UPDATE_ZOOM_DELTA = 0.25;
208779
- const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
208780
- const [r2, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
208781
- return [r2, g2, b2, 255 * (a2 || 1)];
208782
- };
208783
- const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
208784
- obsEmbedding.data[0][i2],
208785
- obsEmbedding.data[1][i2],
208786
- 0
208787
- ];
208788
- const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
208789
- obsEmbedding.data[0][i2],
208790
- -obsEmbedding.data[1][i2],
208791
- 0
208792
- ];
208793
- const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
208794
- target2[0] = data2.src.obsEmbedding.data[0][index2];
208795
- target2[1] = -data2.src.obsEmbedding.data[1][index2];
208796
- target2[2] = 0;
208797
- return target2;
208798
- };
208799
- class Scatterplot extends AbstractSpatialOrScatterplot {
208800
- constructor(props2) {
208801
- super(props2);
208802
- this.cellsQuadTree = null;
208803
- this.cellsLayer = null;
208804
- this.cellsData = null;
208805
- this.cellSetsForceSimulation = forceCollideRects();
208806
- this.cellSetsLabelPrevZoom = null;
208807
- this.cellSetsLayers = [];
208808
- this.onUpdateCellsData();
208809
- this.onUpdateCellsLayer();
208810
- this.onUpdateCellSetsLayers();
208811
- }
208812
- createCellsLayer() {
208813
- const {
208814
- obsEmbeddingIndex: obsIndex,
208815
- theme,
208816
- cellRadius = 1,
208817
- cellOpacity = 1,
208818
- cellSelection,
208819
- setCellHighlight,
208820
- setComponentHover,
208821
- getCellIsSelected,
208822
- cellColors,
208823
- getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
208824
- getExpressionValue,
208825
- onCellClick,
208826
- geneExpressionColormap,
208827
- geneExpressionColormapRange = [0, 1],
208828
- cellColorEncoding
208829
- } = this.props;
208830
- return new ScatterplotLayer({
208831
- id: CELLS_LAYER_ID$1,
208832
- data: this.cellsData,
208833
- coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
208834
- visible: true,
208835
- pickable: true,
208836
- autoHighlight: true,
208837
- filled: true,
208838
- stroked: true,
208839
- backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
208840
- getCellIsSelected,
208841
- opacity: cellOpacity,
208842
- radiusScale: cellRadius,
208843
- radiusMinPixels: 1,
208844
- radiusMaxPixels: 30,
208845
- radiusUnits: "pixels",
208846
- lineWidthUnits: "pixels",
208847
- getPosition,
208848
- getFillColor: getCellColor,
208849
- getLineColor: getCellColor,
208850
- getRadius: 1,
208851
- getExpressionValue,
208852
- getLineWidth: 0,
208853
- extensions: [
208854
- new ScaledExpressionExtension(),
208855
- new SelectionExtension({ instanced: true })
208856
- ],
208857
- colorScaleLo: geneExpressionColormapRange[0],
208858
- colorScaleHi: geneExpressionColormapRange[1],
208859
- isExpressionMode: cellColorEncoding === "geneSelection",
208860
- colormap: geneExpressionColormap,
208861
- onClick: (info2) => {
208862
- if (onCellClick) {
208863
- onCellClick(info2);
208864
- }
208865
- },
208866
- onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
208867
- updateTriggers: {
208868
- getExpressionValue,
208869
- getFillColor: [cellColorEncoding, cellSelection, cellColors],
208870
- getLineColor: [cellColorEncoding, cellSelection, cellColors],
208871
- getCellIsSelected
208872
- }
208873
- });
208874
- }
208875
- createCellSetsLayers() {
208876
- const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
208877
- const result = [];
208878
- if (cellSetPolygonsVisible) {
208879
- result.push(new PolygonLayer({
208880
- id: "cell-sets-polygon-layer",
208881
- data: cellSetPolygons,
208882
- stroked: true,
208883
- filled: false,
208884
- wireframe: true,
208885
- lineWidthMaxPixels: 1,
208886
- getPolygon: (d) => d.hull,
208887
- getLineColor: (d) => d.color,
208888
- getLineWidth: 1
208889
- }));
208890
- }
208891
- if (cellSetLabelsVisible) {
208892
- const { zoom: zoom2 } = viewState;
208893
- const nodes = cellSetPolygons.map((p) => ({
208894
- x: p.centroid[0],
208895
- y: p.centroid[1],
208896
- label: p.name
208897
- }));
208898
- const collisionForce = this.cellSetsForceSimulation.size((d) => [
208899
- cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
208900
- cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
208901
- ]);
208902
- forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
208903
- result.push(new TextLayer({
208904
- id: "cell-sets-text-layer",
208905
- data: nodes,
208906
- getPosition: (d) => [d.x, d.y],
208907
- getText: (d) => d.label,
208908
- getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
208909
- getSize: cellSetLabelSize,
208910
- getAngle: 0,
208911
- getTextAnchor: "middle",
208912
- getAlignmentBaseline: "center",
208913
- fontFamily: LABEL_FONT_FAMILY,
208914
- fontWeight: "normal"
208915
- }));
208916
- }
208917
- return result;
208918
- }
208919
- createSelectionLayers() {
208920
- const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
208921
- const { tool } = this.state;
208922
- const { cellsQuadTree } = this;
208923
- const flipYTooltip = true;
208924
- const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
208925
- return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
208926
- }
208927
- getLayers() {
208928
- const { cellsLayer, cellSetsLayers } = this;
208929
- return [
208930
- cellsLayer,
208931
- ...cellSetsLayers,
208932
- ...this.createSelectionLayers()
208933
- ];
208934
- }
208935
- onUpdateCellsData() {
208936
- const { obsEmbedding } = this.props;
208937
- if (obsEmbedding) {
208938
- const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
208939
- this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
208940
- this.cellsData = {
208941
- src: {
208942
- obsEmbedding
208943
- },
208944
- length: obsEmbedding.shape[1]
208945
- };
208946
- }
208947
- }
208948
- onUpdateCellsLayer() {
208949
- const { obsEmbeddingIndex, obsEmbedding } = this.props;
208950
- if (obsEmbeddingIndex && obsEmbedding) {
208951
- this.cellsLayer = this.createCellsLayer();
208952
- } else {
208953
- this.cellsLayer = null;
208954
- }
208955
- }
208956
- onUpdateCellSetsLayers(onlyViewStateChange) {
208957
- if (onlyViewStateChange) {
208958
- const { viewState, cellSetLabelsVisible } = this.props;
208959
- const { zoom: zoom2 } = viewState;
208960
- const { cellSetsLabelPrevZoom } = this;
208961
- if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
208962
- this.cellSetsLayers = this.createCellSetsLayers();
208963
- this.cellSetsLabelPrevZoom = zoom2;
208964
- }
208965
- } else {
208966
- this.cellSetsLayers = this.createCellSetsLayers();
208967
- }
208968
- }
208969
- viewInfoDidUpdate() {
208970
- const { obsEmbeddingIndex, obsEmbedding } = this.props;
208971
- super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
208972
- }
208973
- componentDidUpdate(prevProps) {
208974
- this.viewInfoDidUpdate();
208975
- const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
208976
- let forceUpdate = false;
208977
- if (["obsEmbedding"].some(shallowDiff)) {
208978
- this.onUpdateCellsData();
208979
- forceUpdate = true;
208980
- }
208981
- if ([
208982
- "obsEmbeddingIndex",
208983
- "obsEmbedding",
208984
- "cellFilter",
208985
- "cellSelection",
208986
- "cellColors",
208987
- "cellRadius",
208988
- "cellOpacity",
208989
- "cellRadiusMode",
208990
- "geneExpressionColormap",
208991
- "geneExpressionColormapRange",
208992
- "geneSelection",
208993
- "cellColorEncoding"
208994
- ].some(shallowDiff)) {
208995
- this.onUpdateCellsLayer();
208996
- forceUpdate = true;
208997
- }
208998
- if ([
208999
- "cellSetPolygons",
209000
- "cellSetPolygonsVisible",
209001
- "cellSetLabelsVisible",
209002
- "cellSetLabelSize"
209003
- ].some(shallowDiff)) {
209004
- this.onUpdateCellSetsLayers(false);
209005
- forceUpdate = true;
209006
- }
209007
- if (shallowDiff("viewState")) {
209008
- this.onUpdateCellSetsLayers(true);
209009
- forceUpdate = true;
209010
- }
209011
- if (forceUpdate) {
209012
- this.forceUpdate();
209013
- }
209014
- }
209015
- }
209016
- const ScatterplotWrapper = React$i.forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
209017
- function ScatterplotOptions(props2) {
209018
- const { children: children2, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
209019
- const observationsLabelNice = capitalize$2(observationsLabel);
209020
- const classes = useStyles$b();
209021
- function handleCellRadiusModeChange(event2) {
209022
- setCellRadiusMode(event2.target.value);
209023
- }
209024
- function handleCellOpacityModeChange(event2) {
209025
- setCellOpacityMode(event2.target.value);
209026
- }
209027
- function handleRadiusChange(event2, value2) {
209028
- setCellRadius(value2);
209029
- }
209030
- function handleOpacityChange(event2, value2) {
209031
- setCellOpacity(value2);
209032
- }
209033
- function handleLabelVisibilityChange(event2) {
209034
- setCellSetLabelsVisible(event2.target.checked);
209035
- }
209036
- function handleLabelSizeChange(event2, value2) {
209037
- setCellSetLabelSize(value2);
209038
- }
209039
- function handlePolygonVisibilityChange(event2) {
209040
- setCellSetPolygonsVisible(event2.target.checked);
209041
- }
209042
- function handleGeneExpressionColormapChange(event2) {
209043
- setGeneExpressionColormap(event2.target.value);
209044
- }
209045
- function handleColormapRangeChange(event2, value2) {
209046
- setGeneExpressionColormapRange(value2);
209047
- }
209048
- const handleColormapRangeChangeDebounced = React$i.useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
209049
- return jsxs(OptionsContainer, { children: [children2, jsx(CellColorEncodingOption, { observationsLabel, cellColorEncoding, setCellColorEncoding }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Labels Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetLabelsVisible, onChange: handleLabelVisibilityChange, name: "scatterplot-option-cell-set-labels", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Label Size"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: !cellSetLabelsVisible, classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellSetLabelSize, onChange: handleLabelSizeChange, "aria-labelledby": "cell-set-label-size-slider", valueLabelDisplay: "auto", step: 1, min: 8, max: 36 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Set Polygons Visible"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Checkbox$1, { className: classes.checkbox, checked: cellSetPolygonsVisible, onChange: handlePolygonVisibilityChange, name: "scatterplot-option-cell-set-polygons", color: "default" }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-radius-mode-select", children: [observationsLabelNice, " Radius Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellRadiusMode, onChange: handleCellRadiusModeChange, inputProps: {
209050
- id: "cell-radius-mode-select"
209051
- }, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Radius"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellRadiusMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellRadius, onChange: handleRadiusChange, "aria-labelledby": "cell-radius-slider", valueLabelDisplay: "auto", step: 0.01, min: 0.01, max: 10 }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, htmlFor: "cell-opacity-mode-select", children: [observationsLabelNice, " Opacity Mode"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsxs(OptionSelect, { className: classes.select, value: cellOpacityMode, onChange: handleCellOpacityModeChange, inputProps: {
209052
- id: "cell-opacity-mode-select"
209053
- }, children: [jsx("option", { value: "auto", children: "Auto" }), jsx("option", { value: "manual", children: "Manual" })] }) })] }), jsxs(TableRow$1, { children: [jsxs(TableCell$1, { className: classes.labelCell, children: [observationsLabelNice, " Opacity"] }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { disabled: cellOpacityMode !== "manual", classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: cellOpacity, onChange: handleOpacityChange, "aria-labelledby": "cell-opacity-slider", valueLabelDisplay: "auto", step: 0.05, min: 0, max: 1 }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, htmlFor: "gene-expression-colormap-select", children: "Gene Expression Colormap" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: geneExpressionColormap, onChange: handleGeneExpressionColormapChange, inputProps: {
209054
- id: "gene-expression-colormap-select"
209055
- }, children: GLSL_COLORMAPS.map((cmap) => jsx("option", { value: cmap, children: cmap }, cmap)) }) })] }), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Gene Expression Colormap Range" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(Slider$1, { classes: { root: classes.slider, valueLabel: classes.sliderValueLabel }, value: geneExpressionColormapRange, onChange: handleColormapRangeChangeDebounced, "aria-labelledby": "gene-expression-colormap-range-slider", valueLabelDisplay: "auto", step: 5e-3, min: 0, max: 1 }) })] })] });
209056
- }
209057
- const styles = makeStyles(() => ({
209058
- tooltipAnchor: {
209059
- position: "relative",
209060
- width: "0px",
209061
- height: "0px",
209062
- pointerEvents: "none",
209063
- userSelect: "none"
209064
- },
209065
- tooltipContent: {
209066
- opacity: 0.9,
209067
- padding: "5px",
209068
- pointerEvents: "none",
209069
- "& table > tbody > tr > th, & table > tbody > tr > td": {
209070
- fontSize: "80%",
209071
- opacity: 0.8,
209072
- outline: 0,
209073
- padding: "0 2px"
209074
- },
209075
- "& table": {
209076
- borderCollapse: "collapse"
209077
- }
209078
- }
209079
- }));
209080
- function Tooltip(props2) {
209081
- const { x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
209082
- const ref2 = React$i.useRef();
209083
- const classes = styles();
209084
- const [placementX, setPlacementX] = React$i.useState("start");
209085
- const [placementY, setPlacementY] = React$i.useState("bottom");
209086
- const getTooltipContainer = useVitessceContainer(ref2);
209087
- React$i.useEffect(() => {
209088
- if (ref2 && ref2.current) {
209089
- const flipX = x2 > parentWidth / 2;
209090
- const flipY = y2 > parentHeight / 2;
209091
- setPlacementX(flipX ? "end" : "start");
209092
- setPlacementY(flipY ? "top" : "bottom");
209093
- ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
209094
- ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
209095
- }
209096
- }, [x2, y2, parentWidth, parentHeight]);
209097
- return jsx("div", { ref: ref2, className: classes.tooltipAnchor, children: ref2 && ref2.current ? jsx(Popper$1, { open: true, anchorEl: ref2.current, container: getTooltipContainer, transition: true, placement: `${placementY}-${placementX}`, children: jsx(Paper$1, { elevation: 4, className: classes.tooltipContent, children: children2 }) }) : null });
209098
- }
209099
- function Tooltip2D(props2) {
209100
- const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children2 } = props2;
209101
- if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
209102
- return null;
209103
- }
209104
- const isTooltipVisible = parentUuid === sourceUuid;
209105
- const crosshairWidth = 1;
209106
- return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip, { x: x2, y: y2, parentWidth, parentHeight, children: children2 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
209107
- left: `${x2 - crosshairWidth / 2}px`,
209108
- top: 0,
209109
- width: `${crosshairWidth}px`,
209110
- height: `${parentHeight}px`
209111
- } }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
209112
- left: 0,
209113
- top: `${y2 - crosshairWidth / 2}px`,
209114
- width: `${parentWidth}px`,
209115
- height: `${crosshairWidth}px`
209116
- } }) : null] }) });
209117
- }
209118
- function TooltipContent(props2) {
209119
- const { info: info2 } = props2;
209120
- return jsx("table", { children: jsx("tbody", { children: Object.entries(info2).map(([key2, value2]) => jsxs("tr", { children: [jsx("th", { children: key2 }), jsx("td", { children: value2 })] }, key2)) }) });
209121
- }
209122
- function ScatterplotTooltipSubscriber(props2) {
209123
- const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
209124
- const sourceUuid = useComponentHover();
209125
- const viewInfo = useComponentViewInfo(parentUuid);
209126
- const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
209127
- getObsInfo(obsHighlight),
209128
- ...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
209129
- ] : [null, null, null];
209130
- return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
209131
- }
209132
- function EmptyMessage(props2) {
209133
- const { visible, message } = props2;
209134
- return visible ? jsx("div", { children: message }) : null;
209135
- }
209136
- function EmbeddingScatterplotSubscriber(props2) {
209137
- const {
209138
- uuid,
209139
- coordinationScopes,
209140
- removeGridComponent,
209141
- theme,
209142
- disableTooltip = false,
209143
- observationsLabelOverride,
209144
- title: titleOverride,
209145
- averageFillDensity
209146
- } = props2;
209147
- const loaders = useLoaders();
209148
- const setComponentHover = useSetComponentHover();
209149
- const setComponentViewInfo = useSetComponentViewInfo(uuid);
209150
- const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, embeddingType: mapping, obsFilter: cellFilter, obsHighlight: cellHighlight, featureSelection: geneSelection, obsSetSelection: cellSetSelection, obsSetColor: cellSetColor, obsColorEncoding: cellColorEncoding, additionalObsSets: additionalCellSets, embeddingObsSetPolygonsVisible: cellSetPolygonsVisible, embeddingObsSetLabelsVisible: cellSetLabelsVisible, embeddingObsSetLabelSize: cellSetLabelSize, embeddingObsRadius: cellRadiusFixed, embeddingObsRadiusMode: cellRadiusMode, embeddingObsOpacity: cellOpacityFixed, embeddingObsOpacityMode: cellOpacityMode, featureValueColormap: geneExpressionColormap, featureValueColormapRange: geneExpressionColormapRange }, { setEmbeddingZoom: setZoom, setEmbeddingTargetX: setTargetX, setEmbeddingTargetY: setTargetY, setEmbeddingTargetZ: setTargetZ, setObsFilter: setCellFilter, setObsSetSelection: setCellSetSelection, setObsHighlight: setCellHighlight, setObsSetColor: setCellSetColor, setObsColorEncoding: setCellColorEncoding, setAdditionalObsSets: setAdditionalCellSets, setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible, setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible, setEmbeddingObsSetLabelSize: setCellSetLabelSize, setEmbeddingObsRadius: setCellRadiusFixed, setEmbeddingObsRadiusMode: setCellRadiusMode, setEmbeddingObsOpacity: setCellOpacityFixed, setEmbeddingObsOpacityMode: setCellOpacityMode, setFeatureValueColormap: setGeneExpressionColormap, setFeatureValueColormapRange: setGeneExpressionColormapRange }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT], coordinationScopes);
209151
- const observationsLabel = observationsLabelOverride || obsType;
209152
- const [urls2, addUrl2] = useUrls(loaders, dataset);
209153
- const [width2, height2, deckRef] = useDeckCanvasSize();
209154
- const title2 = titleOverride || `Scatterplot (${mapping})`;
209155
- const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
209156
- const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
209157
- const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
209158
- const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
209159
- const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
209160
- const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
209161
- const isReady = useReady([
209162
- obsEmbeddingStatus,
209163
- obsSetsStatus,
209164
- featureSelectionStatus,
209165
- matrixIndicesStatus
209166
- ]);
209167
- const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
209168
- const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
209169
- const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
209170
- const setCellSelectionProp = React$i.useCallback((v) => {
209171
- setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
209172
- }, [
209173
- additionalCellSets,
209174
- cellSetColor,
209175
- setCellColorEncoding,
209176
- setAdditionalCellSets,
209177
- setCellSetColor,
209178
- setCellSetSelection
209179
- ]);
209180
- const cellColors = React$i.useMemo(() => getCellColors({
209181
- cellColorEncoding,
209182
- expressionData: expressionData && expressionData[0],
209183
- geneSelection,
209184
- cellSets: mergedCellSets,
209185
- cellSetSelection,
209186
- cellSetColor,
209187
- obsIndex: matrixObsIndex,
209188
- theme
209189
- }), [
209190
- cellColorEncoding,
209191
- geneSelection,
209192
- mergedCellSets,
209193
- theme,
209194
- cellSetSelection,
209195
- cellSetColor,
209196
- expressionData,
209197
- matrixObsIndex
209198
- ]);
209199
- const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
209200
- const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
209201
- const cacheGet = (cache2, key2) => {
209202
- var _a3;
209203
- return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
209204
- };
209205
- const cellSetPolygons = React$i.useMemo(() => {
209206
- var _a3;
209207
- if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsEmbedding && obsEmbeddingIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
209208
- const newCellSetPolygons = getCellSetPolygons({
209209
- obsIndex: obsEmbeddingIndex,
209210
- obsEmbedding,
209211
- cellSets: mergedCellSets,
209212
- cellSetSelection,
209213
- cellSetColor,
209214
- theme
209215
- });
209216
- setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
209217
- return newCellSetPolygons;
209218
- }
209219
- return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
209220
- }, [
209221
- cellSetPolygonsVisible,
209222
- cellSetPolygonCache,
209223
- cellSetLabelsVisible,
209224
- theme,
209225
- obsEmbeddingIndex,
209226
- obsEmbedding,
209227
- mergedCellSets,
209228
- cellSetSelection,
209229
- cellSetColor
209230
- ]);
209231
- const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
209232
- const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
209233
- if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
209234
- const cellCount = obsEmbedding.shape[1];
209235
- const xE = extent$2(obsEmbedding.data[0]);
209236
- const yE = extent$2(obsEmbedding.data[1]);
209237
- const xR = xE[1] - xE[0];
209238
- const yR = yE[1] - yE[0];
209239
- return [xR, yR, xE, yE, cellCount];
209240
- }
209241
- return [null, null, null, null, null];
209242
- }, [obsEmbedding]);
209243
- React$i.useEffect(() => {
209244
- if (xRange && yRange) {
209245
- const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
209246
- setDynamicCellRadius(pointSizeDevicePixels);
209247
- const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
209248
- setDynamicCellOpacity(nextCellOpacityScale);
209249
- if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
209250
- const newTargetX = xExtent[0] + xRange / 2;
209251
- const newTargetY = yExtent[0] + yRange / 2;
209252
- const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
209253
- setTargetX(newTargetX);
209254
- setTargetY(-newTargetY);
209255
- setZoom(newZoom);
209256
- }
209257
- }
209258
- }, [
209259
- xRange,
209260
- yRange,
209261
- xExtent,
209262
- yExtent,
209263
- numCells,
209264
- width2,
209265
- height2,
209266
- zoom2,
209267
- averageFillDensity
209268
- ]);
209269
- const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
209270
- const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
209271
- const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
209272
- const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
209273
- const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
209274
- const getExpressionValue = useExpressionValueGetter({
209275
- instanceObsIndex: obsEmbeddingIndex,
209276
- matrixObsIndex,
209277
- expressionData
209278
- });
209279
- return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(observationsLabel, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange }), children: [jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
209280
- setZoom(newZoom);
209281
- setTargetX(target2[0]);
209282
- setTargetY(target2[1]);
209283
- setTargetZ(target2[2] || 0);
209284
- }, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
209285
- setComponentHover(uuid);
209286
- }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
209287
- }
209288
- function register$c() {
209289
- registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
209290
- }
209291
- function GatingScatterplotOptions(props2) {
209292
- const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
209293
- const classes = useStyles$b();
209294
- const handleGeneSelectChange = (event2) => {
209295
- const { options } = event2.target;
209296
- const newValues = [];
209297
- for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
209298
- if (options[i2].selected) {
209299
- newValues.push(options[i2].value);
209300
- }
209301
- }
209302
- if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
209303
- setGatingFeatureSelectionY(newValues[0]);
209304
- } else if (newValues.length <= 2) {
209305
- setGatingFeatureSelectionX(newValues[0]);
209306
- setGatingFeatureSelectionY(newValues[1]);
209307
- }
209308
- };
209309
- const handleTransformChange = (event2) => {
209310
- setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
209311
- };
209312
- const handleTransformCoefficientChange = (event2) => {
209313
- const { value: value2 } = event2.target;
209314
- if (!value2) {
209315
- setGatingFeatureValueTransformCoefficient(value2);
209316
- } else {
209317
- const newCoefficient = Number(value2);
209318
- if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
209319
- setGatingFeatureValueTransformCoefficient(value2);
209320
- }
209321
- }
209322
- };
209323
- return jsxs(Fragment, { children: [jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: capitalize$2(plur(featureType, geneSelectOptions == null ? void 0 : geneSelectOptions.length)) }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { multiple: true, className: classes.select, value: [gatingFeatureSelectionX, gatingFeatureSelectionY].filter((v) => v), onChange: handleGeneSelectChange, inputProps: {
209324
- id: "scatterplot-gene-select"
209325
- }, children: geneSelectOptions.map((name2) => jsx("option", { value: name2, children: name2 }, name2)) }, "gating-gene-select") })] }, "gene-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(OptionSelect, { className: classes.select, value: gatingFeatureValueTransform === null ? "" : gatingFeatureValueTransform, onChange: handleTransformChange, inputProps: {
209326
- id: "scatterplot-transform-select"
209327
- }, children: transformOptions.map((opt) => jsx("option", { value: opt.value === null ? "" : opt.value, children: opt.name }, opt.name)) }, "gating-transform-select") })] }, "transform-option-row"), jsxs(TableRow$1, { children: [jsx(TableCell$1, { className: classes.labelCell, children: "Transform Coefficient" }), jsx(TableCell$1, { className: classes.inputCell, children: jsx(TextField$1, { label: "Number", type: "number", onChange: handleTransformCoefficientChange, value: gatingFeatureValueTransformCoefficient, InputLabelProps: {
209328
- shrink: true
209329
- } }) })] }, "transform-coefficient-option-row")] });
209330
- }
209331
- function GatingSubscriber(props2) {
209332
- const {
209333
- uuid,
209334
- coordinationScopes,
209335
- removeGridComponent,
209336
- theme,
209337
- disableTooltip = false,
209338
- title: titleOverride,
209339
- averageFillDensity
209340
- } = props2;
209341
- const loaders = useLoaders();
209342
- const setComponentHover = useSetComponentHover();
209343
- const setComponentViewInfo = useSetComponentViewInfo(uuid);
209344
- const [{ dataset, obsType, featureType, featureValueType, embeddingZoom: zoom2, embeddingTargetX: targetX2, embeddingTargetY: targetY2, embeddingTargetZ: targetZ, obsFilter: cellFilter, obsHighlight: cellHighlight, obsSetSelection: cellSetSelection, obsSetColor: cellSetColor, obsColorEncoding: cellColorEncoding, additionalObsSets: additionalCellSets, embeddingObsSetPolygonsVisible: cellSetPolygonsVisible, embeddingObsSetLabelsVisible: cellSetLabelsVisible, embeddingObsSetLabelSize: cellSetLabelSize, embeddingObsRadius: cellRadiusFixed, embeddingObsRadiusMode: cellRadiusMode, embeddingObsOpacity: cellOpacityFixed, embeddingObsOpacityMode: cellOpacityMode, featureValueColormap: geneExpressionColormap, featureValueColormapRange: geneExpressionColormapRange, featureSelection: gatingFeatureSelectionColor, featureValueTransform, featureValueTransformCoefficient, gatingFeatureSelectionX, gatingFeatureSelectionY }, { setEmbeddingZoom: setZoom, setEmbeddingTargetX: setTargetX, setEmbeddingTargetY: setTargetY, setEmbeddingTargetZ: setTargetZ, setObsFilter: setCellFilter, setObsSetSelection: setCellSetSelection, setObsHighlight: setCellHighlight, setObsSetColor: setCellSetColor, setObsColorEncoding: setCellColorEncoding, setAdditionalObsSets: setAdditionalCellSets, setEmbeddingObsSetPolygonsVisible: setCellSetPolygonsVisible, setEmbeddingObsSetLabelsVisible: setCellSetLabelsVisible, setEmbeddingObsSetLabelSize: setCellSetLabelSize, setEmbeddingObsRadius: setCellRadiusFixed, setEmbeddingObsRadiusMode: setCellRadiusMode, setEmbeddingObsOpacity: setCellOpacityFixed, setEmbeddingObsOpacityMode: setCellOpacityMode, setFeatureValueColormap: setGeneExpressionColormap, setFeatureValueColormapRange: setGeneExpressionColormapRange, setFeatureValueTransform, setFeatureValueTransformCoefficient, setGatingFeatureSelectionX, setGatingFeatureSelectionY }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$2.GATING], coordinationScopes);
209345
- const [urls2, addUrl2] = useUrls(loaders, dataset);
209346
- const [width2, height2, deckRef] = useDeckCanvasSize();
209347
- const title2 = React$i.useMemo(() => {
209348
- if (titleOverride) {
209349
- return titleOverride;
209350
- }
209351
- if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
209352
- return "Gating";
209353
- }
209354
- return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
209355
- }, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
209356
- const featureSelectionX = React$i.useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
209357
- const featureSelectionY = React$i.useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
209358
- const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
209359
- const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
209360
- const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
209361
- const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
209362
- const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
209363
- const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
209364
- const isReady = useReady([
209365
- obsSetsStatus,
209366
- featureSelectionColorStatus,
209367
- featureSelectionXStatus,
209368
- featureSelectionYStatus,
209369
- matrixIndicesStatus
209370
- ]);
209371
- const obsXY = React$i.useMemo(() => {
209372
- if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
209373
- return null;
209374
- }
209375
- let coefficient = 1;
209376
- const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
209377
- if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
209378
- coefficient = parsedTransformCoefficient;
209379
- }
209380
- const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
209381
- const obsX = new Float32Array(cellsCount);
209382
- const obsY = new Float32Array(cellsCount);
209383
- for (let i2 = 0; i2 < cellsCount; i2 += 1) {
209384
- obsX[i2] = transformFunction(expressionDataX[0][i2]);
209385
- obsY[i2] = transformFunction(expressionDataY[0][i2]);
209386
- }
209387
- return {
209388
- data: [obsX, obsY],
209389
- shape: [2, cellsCount]
209390
- };
209391
- }, [
209392
- cellsCount,
209393
- expressionDataX,
209394
- expressionDataY,
209395
- featureValueTransform,
209396
- featureValueTransformCoefficient,
209397
- featureSelectionX,
209398
- featureSelectionY
209399
- ]);
209400
- const [dynamicCellRadius, setDynamicCellRadius] = React$i.useState(cellRadiusFixed);
209401
- const [dynamicCellOpacity, setDynamicCellOpacity] = React$i.useState(cellOpacityFixed);
209402
- const mergedCellSets = React$i.useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
209403
- const setCellSelectionProp = React$i.useCallback((v) => {
209404
- setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
209405
- }, [
209406
- additionalCellSets,
209407
- cellSetColor,
209408
- setCellColorEncoding,
209409
- setAdditionalCellSets,
209410
- setCellSetColor,
209411
- setCellSetSelection
209412
- ]);
209413
- const cellColors = React$i.useMemo(() => getCellColors({
209414
- cellColorEncoding,
209415
- expressionData: expressionDataColor && expressionDataColor[0],
209416
- geneSelection: gatingFeatureSelectionColor,
209417
- cellSets: mergedCellSets,
209418
- cellSetSelection,
209419
- cellSetColor,
209420
- obsIndex,
209421
- theme
209422
- }), [
209423
- cellColorEncoding,
209424
- gatingFeatureSelectionColor,
209425
- mergedCellSets,
209426
- theme,
209427
- cellSetSelection,
209428
- cellSetColor,
209429
- expressionDataColor,
209430
- obsIndex
209431
- ]);
209432
- const [cellSetPolygonCache, setCellSetPolygonCache] = React$i.useState([]);
209433
- const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
209434
- const cacheGet = (cache2, key2) => {
209435
- var _a3;
209436
- return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
209437
- };
209438
- const cellSetPolygons = React$i.useMemo(() => {
209439
- var _a3;
209440
- if ((cellSetLabelsVisible || cellSetPolygonsVisible) && !cacheHas2(cellSetPolygonCache, cellSetSelection) && ((_a3 = mergedCellSets == null ? void 0 : mergedCellSets.tree) == null ? void 0 : _a3.length) && obsXY && obsIndex && (cellSetColor == null ? void 0 : cellSetColor.length)) {
209441
- const newCellSetPolygons = getCellSetPolygons({
209442
- obsIndex,
209443
- obsEmbedding: obsXY,
209444
- cellSets: mergedCellSets,
209445
- cellSetSelection,
209446
- cellSetColor,
209447
- theme
209448
- });
209449
- setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
209450
- return newCellSetPolygons;
209451
- }
209452
- return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
209453
- }, [
209454
- cellSetPolygonsVisible,
209455
- cellSetPolygonCache,
209456
- cellSetLabelsVisible,
209457
- theme,
209458
- obsIndex,
209459
- obsXY,
209460
- mergedCellSets,
209461
- cellSetSelection,
209462
- cellSetColor
209463
- ]);
209464
- const cellSelection = React$i.useMemo(() => Array.from(cellColors.keys()), [cellColors]);
209465
- const [xRange, yRange, xExtent, yExtent, numCells] = React$i.useMemo(() => {
209466
- if (obsXY && obsXY.data && obsXY.shape) {
209467
- const cellCount = obsXY.shape[1];
209468
- const xE = extent$2(obsXY.data[0]);
209469
- const yE = extent$2(obsXY.data[1]);
209470
- const xR = xE[1] - xE[0];
209471
- const yR = yE[1] - yE[0];
209472
- return [xR, yR, xE, yE, cellCount];
209473
- }
209474
- return [null, null, null, null, null];
209475
- }, [obsXY]);
209476
- React$i.useEffect(() => {
209477
- if (xRange && yRange) {
209478
- const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
209479
- setDynamicCellRadius(pointSizeDevicePixels);
209480
- const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
209481
- setDynamicCellOpacity(nextCellOpacityScale);
209482
- if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
209483
- const newTargetX = xExtent[0] + xRange / 2;
209484
- const newTargetY = yExtent[0] + yRange / 2;
209485
- const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
209486
- setTargetX(newTargetX);
209487
- setTargetY(-newTargetY);
209488
- setZoom(newZoom);
209489
- }
209490
- }
209491
- }, [
209492
- xRange,
209493
- yRange,
209494
- xExtent,
209495
- yExtent,
209496
- numCells,
209497
- width2,
209498
- height2,
209499
- zoom2,
209500
- averageFillDensity
209501
- ]);
209502
- const cellSelectionSet = React$i.useMemo(() => new Set(cellSelection), [cellSelection]);
209503
- const getCellIsSelected = React$i.useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
209504
- const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
209505
- const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
209506
- const getExpressionValue = useExpressionValueGetter({
209507
- instanceObsIndex: obsIndex,
209508
- matrixObsIndex: obsIndex,
209509
- expressionData: expressionDataColor
209510
- });
209511
- const getObsInfo = React$i.useCallback((obsId) => {
209512
- var _a3;
209513
- const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
209514
- const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
209515
- const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
209516
- const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
209517
- if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
209518
- obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
209519
- obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
209520
- }
209521
- return obsInfo;
209522
- }, [
209523
- obsXY,
209524
- obsIndex,
209525
- featureValueTransform,
209526
- gatingFeatureSelectionX,
209527
- gatingFeatureSelectionY,
209528
- obsType
209529
- ]);
209530
- return jsxs(TitleInfo, { title: title2, info: `${commaNumber(cellsCount)} ${plur(obsType, cellsCount)}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(ScatterplotOptions, { observationsLabel: obsType, cellRadius: cellRadiusFixed, setCellRadius: setCellRadiusFixed, cellRadiusMode, setCellRadiusMode, cellOpacity: cellOpacityFixed, setCellOpacity: setCellOpacityFixed, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, children: jsx(GatingScatterplotOptions, { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform: featureValueTransform, setGatingFeatureValueTransform: (newValue) => {
209531
- setFeatureValueTransform(newValue);
209532
- setTargetX(null);
209533
- setTargetY(null);
209534
- setZoom(null);
209535
- }, gatingFeatureValueTransformCoefficient: featureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient: setFeatureValueTransformCoefficient, geneSelectOptions: featureIndex, transformOptions: VALUE_TRANSFORM_OPTIONS }) }), children: [jsx(EmptyMessage, { visible: !(gatingFeatureSelectionX && gatingFeatureSelectionY), message: `Select two ${plur(featureType, 2)} in the plot settings.` }), jsx(ScatterplotWrapper, { ref: deckRef, uuid, theme, hideTools: !(gatingFeatureSelectionX && gatingFeatureSelectionY), viewState: { zoom: zoom2, target: [targetX2, targetY2, targetZ] }, setViewState: ({ zoom: newZoom, target: target2 }) => {
209536
- setZoom(newZoom);
209537
- setTargetX(target2[0]);
209538
- setTargetY(target2[1]);
209539
- setTargetZ(target2[2] || 0);
209540
- }, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
209541
- setComponentHover(uuid);
209542
- }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
209543
- }
209544
- function register$b() {
209545
- registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
209546
- }
209547
209590
  var shortNumber$1 = { exports: {} };
209548
209591
  (function(module3, exports3) {
209549
209592
  (function(global2, factory2) {
@@ -209716,20 +209759,20 @@ void main() {
209716
209759
  if (use3d) {
209717
209760
  if (colormap) {
209718
209761
  if (renderingMode === "Minimum Intensity Projection") {
209719
- return [new (void 0)()];
209762
+ return [new AdditiveColormap3DExtensions.MinimumIntensityProjectionExtension()];
209720
209763
  }
209721
209764
  if (renderingMode === "Maximum Intensity Projection") {
209722
- return [new (void 0)()];
209765
+ return [new AdditiveColormap3DExtensions.MaximumIntensityProjectionExtension()];
209723
209766
  }
209724
- return [new (void 0)()];
209767
+ return [new AdditiveColormap3DExtensions.AdditiveBlendExtension()];
209725
209768
  }
209726
209769
  if (renderingMode === "Minimum Intensity Projection") {
209727
- return [new (void 0)()];
209770
+ return [new ColorPalette3DExtensions.MinimumIntensityProjectionExtension()];
209728
209771
  }
209729
209772
  if (renderingMode === "Maximum Intensity Projection") {
209730
- return [new (void 0)()];
209773
+ return [new ColorPalette3DExtensions.MaximumIntensityProjectionExtension()];
209731
209774
  }
209732
- return [new (void 0)()];
209775
+ return [new ColorPalette3DExtensions.AdditiveBlendExtension()];
209733
209776
  }
209734
209777
  if (colormap) {
209735
209778
  return [new AdditiveColormapExtension()];
@@ -209966,7 +210009,8 @@ void main() {
209966
210009
  ySlice: layerDef.ySlice,
209967
210010
  zSlice: layerDef.zSlice,
209968
210011
  callback: layerDef.callback,
209969
- visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible)
210012
+ visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible),
210013
+ excludeBackground: useTransparentColor
209970
210014
  };
209971
210015
  if (!loader2 || !layerProps)
209972
210016
  return null;
@@ -210022,6 +210066,7 @@ void main() {
210022
210066
  ySlice: layerProps.ySlice,
210023
210067
  zSlice: layerProps.zSlice,
210024
210068
  onViewportLoad: layerProps.callback,
210069
+ excludeBackground: layerProps.excludeBackground,
210025
210070
  extensions
210026
210071
  });
210027
210072
  }
@@ -210289,7 +210334,8 @@ void main() {
210289
210334
  const [width2, height2, deckRef] = useDeckCanvasSize();
210290
210335
  const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
210291
210336
  const hasExpressionData = useHasLoader(loaders, dataset, DataType$3.OBS_FEATURE_MATRIX, { obsType, featureType, featureValueType });
210292
- const hasCellsData = useHasLoader(loaders, dataset, DataType$3.OBS_SEGMENTATIONS, { obsType });
210337
+ const hasSegmentationsData = useHasLoader(loaders, dataset, DataType$3.OBS_SEGMENTATIONS, { obsType });
210338
+ const hasLocationsData = useHasLoader(loaders, dataset, DataType$3.OBS_LOCATIONS, { obsType });
210293
210339
  const hasImageData = useHasLoader(loaders, dataset, DataType$3.IMAGE, {});
210294
210340
  const [{ obsIndex: obsLocationsIndex, obsLocations }, obsLocationsStatus] = useObsLocationsData(loaders, dataset, addUrl2, false, { setSpatialPointLayer: setMoleculesLayer }, { spatialPointLayer: moleculesLayer }, { obsType: "molecule" });
210295
210341
  const [{ obsLabels: obsLocationsLabels }, obsLabelsStatus] = useObsLabelsData(loaders, dataset, addUrl2, false, {}, {}, { obsType: "molecule" });
@@ -210411,7 +210457,7 @@ void main() {
210411
210457
  locationsCount
210412
210458
  });
210413
210459
  const getExpressionValue = useExpressionValueGetter({
210414
- instanceObsIndex: obsSegmentationsIndex,
210460
+ instanceObsIndex: obsSegmentationsIndex ? obsSegmentationsIndex : obsCentroidsIndex,
210415
210461
  matrixObsIndex,
210416
210462
  expressionData
210417
210463
  });
@@ -210421,7 +210467,7 @@ void main() {
210421
210467
  const canShow3DOptions = canLoad3DLayers && !((disable3d == null ? void 0 : disable3d.length) === imageLayerLoaders.length) && !globalDisable3d;
210422
210468
  const options = React$i.useMemo(() => {
210423
210469
  if (canShow3DOptions || hasExpressionData) {
210424
- return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption: hasCellsData && hasExpressionData, canShow3DOptions });
210470
+ return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption: (hasLocationsData || hasSegmentationsData) && hasExpressionData, canShow3DOptions });
210425
210471
  }
210426
210472
  return null;
210427
210473
  }, [
@@ -210430,7 +210476,8 @@ void main() {
210430
210476
  geneExpressionColormap,
210431
210477
  geneExpressionColormapRange,
210432
210478
  setGeneExpressionColormap,
210433
- hasCellsData,
210479
+ hasLocationsData,
210480
+ hasSegmentationsData,
210434
210481
  hasExpressionData,
210435
210482
  observationsLabel,
210436
210483
  setCellColorEncoding,
@@ -210440,11 +210487,11 @@ void main() {
210440
210487
  use3d
210441
210488
  ]);
210442
210489
  React$i.useEffect(() => {
210443
- if (!hasCellsData && cellsLayer && !obsSegmentations && !obsSegmentationsIndex && obsCentroids && obsCentroidsIndex) {
210490
+ if (!hasSegmentationsData && cellsLayer && !obsSegmentations && !obsSegmentationsIndex && obsCentroids && obsCentroidsIndex) {
210444
210491
  console.warn("Rendering cell segmentation diamonds for backwards compatibility.");
210445
210492
  }
210446
210493
  }, [
210447
- hasCellsData,
210494
+ hasSegmentationsData,
210448
210495
  cellsLayer,
210449
210496
  obsSegmentations,
210450
210497
  obsSegmentationsIndex,
@@ -210459,7 +210506,7 @@ void main() {
210459
210506
  rotationZ,
210460
210507
  rotationOrbit,
210461
210508
  orbitAxis
210462
- }, setViewState, imageLayerDefs: imageLayers, obsSegmentationsLayerDefs: cellsLayer, obsLocationsLayerDefs: moleculesLayer, neighborhoodLayerDefs: neighborhoodsLayer, obsLocationsIndex, obsSegmentationsIndex, obsLocations, obsLocationsLabels, obsLocationsFeatureIndex, hasSegmentations: hasCellsData, obsSegmentations, obsSegmentationsType, obsCentroids, obsCentroidsIndex, cellFilter, cellSelection, cellHighlight, cellColors, neighborhoods, imageLayerLoaders, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, setMoleculeHighlight, setComponentHover: () => {
210509
+ }, setViewState, imageLayerDefs: imageLayers, obsSegmentationsLayerDefs: cellsLayer, obsLocationsLayerDefs: moleculesLayer, neighborhoodLayerDefs: neighborhoodsLayer, obsLocationsIndex, obsSegmentationsIndex, obsLocations, obsLocationsLabels, obsLocationsFeatureIndex, hasSegmentations: hasSegmentationsData, obsSegmentations, obsSegmentationsType, obsCentroids, obsCentroidsIndex, cellFilter, cellSelection, cellHighlight, cellColors, neighborhoods, imageLayerLoaders, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, setMoleculeHighlight, setComponentHover: () => {
210463
210510
  setComponentHover(uuid);
210464
210511
  }, updateViewInfo: setComponentViewInfo, imageLayerCallbacks, segmentationLayerCallbacks, spatialAxisFixed, geneExpressionColormap, geneExpressionColormapRange, expressionData: shiftedExpressionDataForBitmask, cellColorEncoding, getExpressionValue, theme }), !disableTooltip && jsx(SpatialTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
210465
210512
  }
@@ -271773,7 +271820,7 @@ void main() {
271773
271820
  orient: "left",
271774
271821
  scale: "yscale",
271775
271822
  zindex: 1,
271776
- title: featureValueTransformName ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
271823
+ title: featureValueTransformName && featureValueTransformName !== "None" ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
271777
271824
  },
271778
271825
  {
271779
271826
  orient: "bottom",
@@ -271937,15 +271984,17 @@ void main() {
271937
271984
  const [urls2, addUrl2] = useUrls(loaders, dataset);
271938
271985
  const transformOptions = VALUE_TRANSFORM_OPTIONS;
271939
271986
  const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
271987
+ const [{ featureLabelsMap }, featureLabelsStatus] = useFeatureLabelsData(loaders, dataset, addUrl2, false, {}, {}, { featureType });
271940
271988
  const [{ obsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
271941
271989
  const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, true, {}, {}, { obsType });
271942
271990
  const isReady = useReady([
271943
271991
  featureSelectionStatus,
271944
271992
  matrixIndicesStatus,
271945
- obsSetsStatus
271993
+ obsSetsStatus,
271994
+ featureLabelsStatus
271946
271995
  ]);
271947
271996
  const [expressionArr, setArr, expressionMax] = useExpressionByCellSet(expressionData, obsIndex, cellSets, additionalCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient, theme);
271948
- const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? geneSelection[0] : null;
271997
+ const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneSelection[0])) || geneSelection[0] : null;
271949
271998
  const selectedTransformName = (_a3 = transformOptions.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
271950
271999
  return jsx(TitleInfo, { title: `Expression by ${capitalize$2(obsType)} Set${firstGeneSelected ? ` (${firstGeneSelected})` : ""}`, removeGridComponent, urls: urls2, theme, isReady, options: jsx(CellSetExpressionPlotOptions, { featureValueTransform, setFeatureValueTransform, featureValueTransformCoefficient, setFeatureValueTransformCoefficient, transformOptions }), children: jsx("div", { ref: containerRef, className: classes.vegaContainer, children: expressionArr ? jsx(CellSetExpressionPlot, { domainMax: expressionMax, colors: setArr, data: expressionArr, theme, width: width2, height: height2, obsType, featureValueType, featureValueTransformName: selectedTransformName }) : jsxs("span", { children: ["Select a ", featureType, "."] }) }) });
271951
272000
  }