@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.
@@ -529,6 +529,18 @@ const COMPONENT_COORDINATION_TYPES = {
529
529
  CoordinationType$2.FEATURE_SELECTION
530
530
  ]
531
531
  };
532
+ const note = "This file is regenerated by push-demo.sh.";
533
+ const version$6 = "2.0.1";
534
+ const branch = "release-v2.0.1";
535
+ const date$3 = "2022-11-30";
536
+ const hash$1 = "0327a9c6";
537
+ const META_VERSION = {
538
+ note,
539
+ version: version$6,
540
+ branch,
541
+ date: date$3,
542
+ hash: hash$1
543
+ };
532
544
  const ViewType$1 = {
533
545
  GENES: [
534
546
  "genes",
@@ -10107,7 +10119,11 @@ const globalColors = {
10107
10119
  grayLight: "#D3D3D3",
10108
10120
  grayMid: "#808080",
10109
10121
  grayDark: "#555555",
10110
- black: "#000000"
10122
+ black: "#000000",
10123
+ grayDarkL5: "rgb(98, 98, 98)",
10124
+ grayDarkD15: "rgb(47, 47, 47)",
10125
+ grayMidL10: "rgb(154, 154, 154)",
10126
+ grayLightL10: "rgb(237, 237, 237)"
10111
10127
  };
10112
10128
  const muiTheme = {
10113
10129
  dark: createTheme({
@@ -10121,6 +10137,9 @@ const muiTheme = {
10121
10137
  primaryBackgroundDim: "#333333",
10122
10138
  primaryBackgroundLight: "#757575",
10123
10139
  primaryForeground: "#D3D3D3",
10140
+ primaryForegroundL5: "rgb(224, 224, 224)",
10141
+ primaryForegroundL10: "rgb(237, 237, 237)",
10142
+ primaryForegroundD15: "rgb(173, 173, 173)",
10124
10143
  primaryForegroundDim: "#000000",
10125
10144
  primaryForegroundActive: "#9bb7d6",
10126
10145
  secondaryBackground: "#000000",
@@ -10147,6 +10166,9 @@ const muiTheme = {
10147
10166
  primaryBackgroundDim: "#8A8A8A",
10148
10167
  primaryBackgroundLight: "#e0e0e0",
10149
10168
  primaryForeground: "#333333",
10169
+ primaryForegroundL5: "rgb(64, 64, 64)",
10170
+ primaryForegroundL10: "rgb(77, 77, 77)",
10171
+ primaryForegroundD15: "rgb(13, 13, 13)",
10150
10172
  primaryForegroundDim: "#808080",
10151
10173
  primaryForegroundActive: "#0074D9",
10152
10174
  secondaryBackground: "#F1F1F1",
@@ -10419,13 +10441,10 @@ const createViewConfigStore = () => create$c((set3) => ({
10419
10441
  };
10420
10442
  }),
10421
10443
  changeLayout: (newComponentProps) => set3((state) => {
10422
- const newLayout = state.viewConfig.layout.slice();
10423
- newComponentProps.forEach(([i2, newProps]) => {
10424
- newLayout[i2] = {
10425
- ...newLayout[i2],
10426
- ...newProps
10427
- };
10428
- });
10444
+ const newLayout = state.viewConfig.layout.slice().map((componentProps) => ({
10445
+ ...componentProps,
10446
+ ...newComponentProps[componentProps.uid]
10447
+ }));
10429
10448
  return {
10430
10449
  viewConfig: {
10431
10450
  ...state.viewConfig,
@@ -15165,7 +15184,6 @@ function WidthProvideRGL(ComposedComponent) {
15165
15184
  module2.exports.Responsive.utils = responsiveUtils;
15166
15185
  module2.exports.WidthProvider = WidthProvider.default;
15167
15186
  })(reactGridLayoutWithLodash);
15168
- const COMPONENT_ID_PREFIX = "i";
15169
15187
  function sum$7(a2) {
15170
15188
  return a2.reduce((x2, y2) => x2 + y2, 0);
15171
15189
  }
@@ -15252,12 +15270,11 @@ function VitessceGridLayout(props2) {
15252
15270
  const [lastValidGridLayouts, setLastValidGridLayouts] = useState(gridLayouts);
15253
15271
  const onValidLayoutChange = (newLayout) => {
15254
15272
  if (newLayout.length === Object.entries(gridComponents).length) {
15255
- const newComponentProps = [];
15273
+ const newComponentProps = {};
15256
15274
  newLayout.forEach((nextC) => {
15257
15275
  const id2 = nextC.i;
15258
15276
  const prevC = gridComponents[id2];
15259
15277
  if (prevC) {
15260
- const i2 = parseInt(id2.substring(id2.indexOf(COMPONENT_ID_PREFIX) + 1), 10);
15261
15278
  const nextProps = {
15262
15279
  x: nextC.x,
15263
15280
  y: nextC.y,
@@ -15271,11 +15288,11 @@ function VitessceGridLayout(props2) {
15271
15288
  h: prevC.h
15272
15289
  };
15273
15290
  if (!isEqual_1(nextProps, prevProps)) {
15274
- newComponentProps.push([i2, nextProps]);
15291
+ newComponentProps[id2] = nextProps;
15275
15292
  }
15276
15293
  }
15277
15294
  });
15278
- if (newComponentProps.length > 0) {
15295
+ if (Object.keys(newComponentProps).length > 0) {
15279
15296
  onLayoutChangeProp(newComponentProps);
15280
15297
  }
15281
15298
  }
@@ -27715,7 +27732,10 @@ function VitessceGrid(props2) {
27715
27732
  const removeComponent = useRemoveComponent();
27716
27733
  const changeLayout = useChangeLayout();
27717
27734
  const layout2 = useLayout();
27718
- const changeLayoutPostMount = useCallback(() => componentWidth > 0 ? changeLayout : () => {
27735
+ const changeLayoutPostMount = useCallback((newComponentProps) => {
27736
+ if (componentWidth > 0) {
27737
+ changeLayout(newComponentProps);
27738
+ }
27719
27739
  }, [changeLayout, componentWidth]);
27720
27740
  useEffect(() => {
27721
27741
  if (config3) {
@@ -49837,12 +49857,11 @@ function upgradeAndValidate(oldConfig, onConfigUpgrade = null) {
49837
49857
  } while (upgradeFunction);
49838
49858
  return [nextConfig, true];
49839
49859
  }
49840
- const packageJson$1 = { version: "unk" };
49841
49860
  const generateClassName = createGenerateClassName({
49842
49861
  disableGlobal: true
49843
49862
  });
49844
49863
  function logConfig(config3, name2) {
49845
- console.groupCollapsed(`\u{1F684} Vitessce (${packageJson$1.version}) ${name2}`);
49864
+ console.groupCollapsed(`\u{1F684} Vitessce (${META_VERSION.version}) ${name2}`);
49846
49865
  console.info(`data:,${JSON.stringify(config3)}`);
49847
49866
  console.info(JSON.stringify(config3, null, 2));
49848
49867
  console.groupEnd();
@@ -61000,11 +61019,19 @@ var _fails = function(exec) {
61000
61019
  return true;
61001
61020
  }
61002
61021
  };
61003
- var _descriptors = !_fails(function() {
61004
- return Object.defineProperty({}, "a", { get: function() {
61005
- return 7;
61006
- } }).a != 7;
61007
- });
61022
+ var _descriptors;
61023
+ var hasRequired_descriptors;
61024
+ function require_descriptors() {
61025
+ if (hasRequired_descriptors)
61026
+ return _descriptors;
61027
+ hasRequired_descriptors = 1;
61028
+ _descriptors = !_fails(function() {
61029
+ return Object.defineProperty({}, "a", { get: function() {
61030
+ return 7;
61031
+ } }).a != 7;
61032
+ });
61033
+ return _descriptors;
61034
+ }
61008
61035
  var _domCreate;
61009
61036
  var hasRequired_domCreate;
61010
61037
  function require_domCreate() {
@@ -61019,11 +61046,19 @@ function require_domCreate() {
61019
61046
  };
61020
61047
  return _domCreate;
61021
61048
  }
61022
- var _ie8DomDefine = !_descriptors && !_fails(function() {
61023
- return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
61024
- return 7;
61025
- } }).a != 7;
61026
- });
61049
+ var _ie8DomDefine;
61050
+ var hasRequired_ie8DomDefine;
61051
+ function require_ie8DomDefine() {
61052
+ if (hasRequired_ie8DomDefine)
61053
+ return _ie8DomDefine;
61054
+ hasRequired_ie8DomDefine = 1;
61055
+ _ie8DomDefine = !require_descriptors() && !_fails(function() {
61056
+ return Object.defineProperty(require_domCreate()("div"), "a", { get: function() {
61057
+ return 7;
61058
+ } }).a != 7;
61059
+ });
61060
+ return _ie8DomDefine;
61061
+ }
61027
61062
  var isObject$f = _isObject;
61028
61063
  var _toPrimitive = function(it, S) {
61029
61064
  if (!isObject$f(it))
@@ -61037,25 +61072,32 @@ var _toPrimitive = function(it, S) {
61037
61072
  return val;
61038
61073
  throw TypeError("Can't convert object to primitive value");
61039
61074
  };
61040
- var anObject$3 = _anObject;
61041
- var IE8_DOM_DEFINE$1 = _ie8DomDefine;
61042
- var toPrimitive$2 = _toPrimitive;
61043
- var dP$3 = Object.defineProperty;
61044
- _objectDp.f = _descriptors ? Object.defineProperty : function defineProperty(O, P2, Attributes2) {
61045
- anObject$3(O);
61046
- P2 = toPrimitive$2(P2, true);
61047
- anObject$3(Attributes2);
61048
- if (IE8_DOM_DEFINE$1)
61049
- try {
61050
- return dP$3(O, P2, Attributes2);
61051
- } catch (e3) {
61052
- }
61053
- if ("get" in Attributes2 || "set" in Attributes2)
61054
- throw TypeError("Accessors not supported!");
61055
- if ("value" in Attributes2)
61056
- O[P2] = Attributes2.value;
61057
- return O;
61058
- };
61075
+ var hasRequired_objectDp;
61076
+ function require_objectDp() {
61077
+ if (hasRequired_objectDp)
61078
+ return _objectDp;
61079
+ hasRequired_objectDp = 1;
61080
+ var anObject2 = _anObject;
61081
+ var IE8_DOM_DEFINE2 = require_ie8DomDefine();
61082
+ var toPrimitive2 = _toPrimitive;
61083
+ var dP2 = Object.defineProperty;
61084
+ _objectDp.f = require_descriptors() ? Object.defineProperty : function defineProperty4(O, P2, Attributes2) {
61085
+ anObject2(O);
61086
+ P2 = toPrimitive2(P2, true);
61087
+ anObject2(Attributes2);
61088
+ if (IE8_DOM_DEFINE2)
61089
+ try {
61090
+ return dP2(O, P2, Attributes2);
61091
+ } catch (e3) {
61092
+ }
61093
+ if ("get" in Attributes2 || "set" in Attributes2)
61094
+ throw TypeError("Accessors not supported!");
61095
+ if ("value" in Attributes2)
61096
+ O[P2] = Attributes2.value;
61097
+ return O;
61098
+ };
61099
+ return _objectDp;
61100
+ }
61059
61101
  var _propertyDesc = function(bitmap, value2) {
61060
61102
  return {
61061
61103
  enumerable: !(bitmap & 1),
@@ -61064,9 +61106,9 @@ var _propertyDesc = function(bitmap, value2) {
61064
61106
  value: value2
61065
61107
  };
61066
61108
  };
61067
- var dP$2 = _objectDp;
61109
+ var dP$2 = require_objectDp();
61068
61110
  var createDesc$2 = _propertyDesc;
61069
- var _hide = _descriptors ? function(object2, key2, value2) {
61111
+ var _hide = require_descriptors() ? function(object2, key2, value2) {
61070
61112
  return dP$2.f(object2, key2, createDesc$2(1, value2));
61071
61113
  } : function(object2, key2, value2) {
61072
61114
  object2[key2] = value2;
@@ -61269,7 +61311,7 @@ function require_objectAssign() {
61269
61311
  if (hasRequired_objectAssign)
61270
61312
  return _objectAssign;
61271
61313
  hasRequired_objectAssign = 1;
61272
- var DESCRIPTORS2 = _descriptors;
61314
+ var DESCRIPTORS2 = require_descriptors();
61273
61315
  var getKeys2 = _objectKeys$1;
61274
61316
  var gOPS2 = _objectGops;
61275
61317
  var pIE2 = require_objectPie();
@@ -61332,9 +61374,9 @@ var _default$i = _assign2.default || function(target2) {
61332
61374
  };
61333
61375
  var defineProperty$6 = { exports: {} };
61334
61376
  var $export$4 = _export;
61335
- $export$4($export$4.S + $export$4.F * !_descriptors, "Object", { defineProperty: _objectDp.f });
61377
+ $export$4($export$4.S + $export$4.F * !require_descriptors(), "Object", { defineProperty: require_objectDp().f });
61336
61378
  var $Object$1 = _core.exports.Object;
61337
- var defineProperty$5 = function defineProperty2(it, key2, desc) {
61379
+ var defineProperty$5 = function defineProperty(it, key2, desc) {
61338
61380
  return $Object$1.defineProperty(it, key2, desc);
61339
61381
  };
61340
61382
  (function(module2) {
@@ -61408,10 +61450,10 @@ var _redefine = { exports: {} };
61408
61450
  module2.exports = _hide;
61409
61451
  })(_redefine);
61410
61452
  var _iterators = {};
61411
- var dP$1 = _objectDp;
61453
+ var dP$1 = require_objectDp();
61412
61454
  var anObject$2 = _anObject;
61413
61455
  var getKeys$1 = _objectKeys$1;
61414
- var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
61456
+ var _objectDps = require_descriptors() ? Object.defineProperties : function defineProperties(O, Properties) {
61415
61457
  anObject$2(O);
61416
61458
  var keys4 = getKeys$1(Properties);
61417
61459
  var length2 = keys4.length;
@@ -61476,7 +61518,7 @@ var $exports = _wks.exports = function(name2) {
61476
61518
  return store[name2] || (store[name2] = USE_SYMBOL && Symbol$7[name2] || (USE_SYMBOL ? Symbol$7 : uid$2)("Symbol." + name2));
61477
61519
  };
61478
61520
  $exports.store = store;
61479
- var def$1 = _objectDp.f;
61521
+ var def$1 = require_objectDp().f;
61480
61522
  var has$8 = _has$1;
61481
61523
  var TAG = _wks.exports("toStringTag");
61482
61524
  var _setToStringTag = function(it, tag2, stat) {
@@ -61646,7 +61688,7 @@ var _meta$3 = { exports: {} };
61646
61688
  var META$1 = _uid("meta");
61647
61689
  var isObject$e = _isObject;
61648
61690
  var has$6 = _has$1;
61649
- var setDesc = _objectDp.f;
61691
+ var setDesc = require_objectDp().f;
61650
61692
  var id$2 = 0;
61651
61693
  var isExtensible = Object.isExtensible || function() {
61652
61694
  return true;
@@ -61696,7 +61738,7 @@ var meta$6 = _meta$3.exports = {
61696
61738
  };
61697
61739
  var core$1 = _core.exports;
61698
61740
  var wksExt$1 = _wksExt;
61699
- var defineProperty$4 = _objectDp.f;
61741
+ var defineProperty$4 = require_objectDp().f;
61700
61742
  var _wksDefine = function(name2) {
61701
61743
  var $Symbol2 = core$1.Symbol || (core$1.Symbol = {});
61702
61744
  if (name2.charAt(0) != "_" && !(name2 in $Symbol2))
@@ -61750,9 +61792,9 @@ var createDesc$1 = _propertyDesc;
61750
61792
  var toIObject$1 = _toIobject;
61751
61793
  var toPrimitive$1 = _toPrimitive;
61752
61794
  var has$5 = _has$1;
61753
- var IE8_DOM_DEFINE = _ie8DomDefine;
61795
+ var IE8_DOM_DEFINE = require_ie8DomDefine();
61754
61796
  var gOPD$4 = Object.getOwnPropertyDescriptor;
61755
- _objectGopd.f = _descriptors ? gOPD$4 : function getOwnPropertyDescriptor2(O, P2) {
61797
+ _objectGopd.f = require_descriptors() ? gOPD$4 : function getOwnPropertyDescriptor2(O, P2) {
61756
61798
  O = toIObject$1(O);
61757
61799
  P2 = toPrimitive$1(P2, true);
61758
61800
  if (IE8_DOM_DEFINE)
@@ -61765,7 +61807,7 @@ _objectGopd.f = _descriptors ? gOPD$4 : function getOwnPropertyDescriptor2(O, P2
61765
61807
  };
61766
61808
  var global$2 = _global.exports;
61767
61809
  var has$4 = _has$1;
61768
- var DESCRIPTORS = _descriptors;
61810
+ var DESCRIPTORS = require_descriptors();
61769
61811
  var $export$2 = _export;
61770
61812
  var redefine = _redefine.exports;
61771
61813
  var META = _meta$3.exports.KEY;
@@ -61788,7 +61830,7 @@ var _create$1 = _objectCreate;
61788
61830
  var gOPNExt = _objectGopnExt;
61789
61831
  var $GOPD = _objectGopd;
61790
61832
  var $GOPS = _objectGops;
61791
- var $DP = _objectDp;
61833
+ var $DP = require_objectDp();
61792
61834
  var $keys = _objectKeys$1;
61793
61835
  var gOPD$3 = $GOPD.f;
61794
61836
  var dP = $DP.f;
@@ -61831,7 +61873,7 @@ var isSymbol$6 = USE_NATIVE && typeof $Symbol$1.iterator == "symbol" ? function(
61831
61873
  } : function(it) {
61832
61874
  return it instanceof $Symbol$1;
61833
61875
  };
61834
- var $defineProperty$1 = function defineProperty3(it, key2, D2) {
61876
+ var $defineProperty$1 = function defineProperty2(it, key2, D2) {
61835
61877
  if (it === ObjectProto)
61836
61878
  $defineProperty$1(OPSymbols, key2, D2);
61837
61879
  anObject(it);
@@ -64003,7 +64045,7 @@ var reactJsxDevRuntime_development = {};
64003
64045
  module2.exports = reactJsxDevRuntime_development;
64004
64046
  }
64005
64047
  })(jsxDevRuntime);
64006
- 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";
64048
+ var _jsxFileName$1 = "/home/runner/work/vitessce/vitessce/node_modules/.pnpm/rc-tree@2.1.0_biqbaboplfbrettd7655fr4n2y/node_modules/rc-tree/es/util.js";
64007
64049
  var DRAG_SIDE_RANGE = 0.25;
64008
64050
  var DRAG_MIN_GAP = 2;
64009
64051
  var onlyTreeNodeWarned = false;
@@ -71755,7 +71797,7 @@ const useStyles$9 = makeStyles((theme) => ({
71755
71797
  cursor: "pointer",
71756
71798
  border: "0",
71757
71799
  backgroundColor: "transparent",
71758
- color: theme.palette.grayDark,
71800
+ color: theme.palette.grayDarkL5,
71759
71801
  "&[disabled]": {
71760
71802
  pointerEvents: "none",
71761
71803
  "& svg": {
@@ -71769,8 +71811,8 @@ const useStyles$9 = makeStyles((theme) => ({
71769
71811
  marginTop: "1px"
71770
71812
  },
71771
71813
  "&:hover,:hover path": {
71772
- color: theme.palette.grayDark,
71773
- fill: theme.palette.grayDark
71814
+ color: theme.palette.grayDarkD15,
71815
+ fill: theme.palette.grayDarkD15
71774
71816
  }
71775
71817
  }
71776
71818
  },
@@ -71789,7 +71831,7 @@ const useStyles$9 = makeStyles((theme) => ({
71789
71831
  border: "1px solid transparent"
71790
71832
  },
71791
71833
  "@global .level-0-treenode > .rc-tree-switcher i svg path": {
71792
- fill: theme.palette.primaryForeground
71834
+ fill: theme.palette.primaryForegroundL5
71793
71835
  },
71794
71836
  "@global .rc-tree-focused:not(.rc-tree-active-focused)": {
71795
71837
  borderColor: "cyan"
@@ -71950,7 +71992,7 @@ const useStyles$9 = makeStyles((theme) => ({
71950
71992
  plusButton: {
71951
71993
  border: "0",
71952
71994
  backgroundColor: "transparent",
71953
- color: theme.palette.primaryForeground,
71995
+ color: theme.palette.primaryForegroundL5,
71954
71996
  padding: "0",
71955
71997
  fontSize: "18px",
71956
71998
  marginBottom: "2rem",
@@ -71965,12 +72007,12 @@ const useStyles$9 = makeStyles((theme) => ({
71965
72007
  width: `${nodeHeight}px`,
71966
72008
  top: "5.5px",
71967
72009
  "&:hover": {
71968
- fill: theme.palette.grayMid
72010
+ fill: theme.palette.grayMidL10
71969
72011
  }
71970
72012
  },
71971
72013
  nodeSizeLabel: {
71972
72014
  fontSize: "12px",
71973
- color: theme.palette.primaryForeground
72015
+ color: theme.palette.primaryForegroundD15
71974
72016
  },
71975
72017
  levelButtonsContainer: {
71976
72018
  height: "20px",
@@ -71986,8 +72028,8 @@ const useStyles$9 = makeStyles((theme) => ({
71986
72028
  height: "12px",
71987
72029
  padding: "5px",
71988
72030
  backgroundClip: "content-box",
71989
- border: `2px solid ${theme.palette.primaryForeground}`,
71990
- backgroundColor: theme.palette.primaryForeground,
72031
+ border: `2px solid ${theme.palette.primaryForegroundL10}`,
72032
+ backgroundColor: theme.palette.primaryForegroundL10,
71991
72033
  borderRadius: "6px",
71992
72034
  position: "relative",
71993
72035
  top: "3px",
@@ -72007,7 +72049,7 @@ const useStyles$9 = makeStyles((theme) => ({
72007
72049
  height: `${nodeHeight - 8}px`,
72008
72050
  lineHeight: `${nodeHeight - 8}px`,
72009
72051
  border: "1px solid transparent",
72010
- color: theme.palette.primaryForeground,
72052
+ color: theme.palette.primaryForegroundL5,
72011
72053
  background: "transparent",
72012
72054
  backgroundColor: "transparent",
72013
72055
  verticalAlign: "top",
@@ -72050,8 +72092,8 @@ const useStyles$9 = makeStyles((theme) => ({
72050
72092
  margin: 0,
72051
72093
  padding: 0,
72052
72094
  "&:hover": {
72053
- backgroundColor: theme.palette.grayDark,
72054
- border: `1px solid ${theme.palette.grayDark}`
72095
+ backgroundColor: theme.palette.grayDarkL5,
72096
+ border: `1px solid ${theme.palette.grayDarkL5}`
72055
72097
  }
72056
72098
  },
72057
72099
  "@global .vitessce-tooltip .ant-tooltip-content .ant-tooltip-inner": {
@@ -72201,7 +72243,7 @@ const useHelpTooltipStyles = makeStyles((theme) => ({
72201
72243
  backgroundColor: "transparent",
72202
72244
  borderRadius: "2px",
72203
72245
  "&:hover": {
72204
- backgroundColor: theme.palette.grayLight
72246
+ backgroundColor: theme.palette.grayLightL10
72205
72247
  }
72206
72248
  },
72207
72249
  "& li:not(:last-child)": {
@@ -72258,7 +72300,7 @@ HelpTooltip.defaultProps = {
72258
72300
  mouseLeaveDelay: 0,
72259
72301
  destroyTooltipOnHide: true
72260
72302
  };
72261
- 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";
72303
+ 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";
72262
72304
  var __defProp2 = Object.defineProperty;
72263
72305
  var __defNormalProp2 = (obj, key2, value2) => key2 in obj ? __defProp2(obj, key2, {
72264
72306
  enumerable: true,
@@ -180605,16 +180647,16 @@ async function getDecoder(fileDirectory) {
180605
180647
  const Decoder = await importFn();
180606
180648
  return new Decoder(fileDirectory);
180607
180649
  }
180608
- addDecoder([void 0, 1], () => import("./raw.61eaecb4.mjs").then((m2) => m2.default));
180609
- addDecoder(5, () => import("./lzw.3bf56bd2.mjs").then((m2) => m2.default));
180650
+ addDecoder([void 0, 1], () => import("./raw.741ddabe.mjs").then((m2) => m2.default));
180651
+ addDecoder(5, () => import("./lzw.e9257ec2.mjs").then((m2) => m2.default));
180610
180652
  addDecoder(6, () => {
180611
180653
  throw new Error("old style JPEG compression is not supported.");
180612
180654
  });
180613
- addDecoder(7, () => import("./jpeg.2cba0391.mjs").then((m2) => m2.default));
180614
- addDecoder([8, 32946], () => import("./deflate.628654fc.mjs").then((m2) => m2.default));
180615
- addDecoder(32773, () => import("./packbits.cf4e19b0.mjs").then((m2) => m2.default));
180616
- addDecoder(34887, () => import("./lerc.7110c4d8.mjs").then((m2) => m2.default));
180617
- addDecoder(50001, () => import("./webimage.e4333f12.mjs").then((m2) => m2.default));
180655
+ addDecoder(7, () => import("./jpeg.21d1374d.mjs").then((m2) => m2.default));
180656
+ addDecoder([8, 32946], () => import("./deflate.199a1acc.mjs").then((m2) => m2.default));
180657
+ addDecoder(32773, () => import("./packbits.ab2ecbac.mjs").then((m2) => m2.default));
180658
+ addDecoder(34887, () => import("./lerc.c99fbca0.mjs").then((m2) => m2.default));
180659
+ addDecoder(50001, () => import("./webimage.0fa273e8.mjs").then((m2) => m2.default));
180618
180660
  function copyNewSize(array2, width2, height2, samplesPerPixel = 1) {
180619
180661
  return new (Object.getPrototypeOf(array2)).constructor(width2 * height2 * samplesPerPixel);
180620
180662
  }
@@ -192585,6 +192627,7 @@ const MinimumIntensityProjectionExtension = class extends BaseExtension {
192585
192627
  }
192586
192628
  };
192587
192629
  MinimumIntensityProjectionExtension.extensionName = "MinimumIntensityProjectionExtension";
192630
+ const AdditiveColormap3DExtensions = { BaseExtension, AdditiveBlendExtension, MaximumIntensityProjectionExtension, MinimumIntensityProjectionExtension };
192588
192631
  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 } };
192589
192632
  const ImageLayer = class extends CompositeLayer {
192590
192633
  finalizeState() {
@@ -193617,370 +193660,1521 @@ class BitmaskLayer extends XRLayer {
193617
193660
  }
193618
193661
  BitmaskLayer.layerName = "BitmaskLayer";
193619
193662
  BitmaskLayer.defaultProps = defaultProps;
193620
- var _extends$1 = { exports: {} };
193621
- var hasRequired_extends;
193622
- function require_extends() {
193623
- if (hasRequired_extends)
193624
- return _extends$1.exports;
193625
- hasRequired_extends = 1;
193626
- (function(module2) {
193627
- function _extends2() {
193628
- module2.exports = _extends2 = Object.assign ? Object.assign.bind() : function(target2) {
193629
- for (var i2 = 1; i2 < arguments.length; i2++) {
193630
- var source2 = arguments[i2];
193631
- for (var key2 in source2) {
193632
- if (Object.prototype.hasOwnProperty.call(source2, key2)) {
193633
- target2[key2] = source2[key2];
193663
+ const useStyles$8 = makeStyles(() => ({
193664
+ tool: {
193665
+ position: "absolute",
193666
+ display: "inline",
193667
+ zIndex: "1000",
193668
+ opacity: ".65",
193669
+ color: "black",
193670
+ "&:hover": {
193671
+ opacity: ".90"
193672
+ }
193673
+ },
193674
+ iconButton: {
193675
+ padding: "0",
193676
+ height: "2em",
193677
+ width: "2em",
193678
+ backgroundColor: "white",
193679
+ display: "inline-block",
193680
+ fontWeight: "400",
193681
+ textAlign: "center",
193682
+ verticalAlign: "middle",
193683
+ cursor: "pointer",
193684
+ userSelect: "none",
193685
+ border: "1px solid #6c757d",
193686
+ fontSize: "1rem",
193687
+ lineHeight: "1.5",
193688
+ borderRadius: "0.25rem",
193689
+ 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",
193690
+ color: "#6c757d",
193691
+ marginRight: "0.5rem",
193692
+ "& > svg": {
193693
+ verticalAlign: "middle"
193694
+ }
193695
+ },
193696
+ iconButtonActive: {
193697
+ color: "#fff",
193698
+ backgroundColor: "#6c757d",
193699
+ borderColor: "#6c757d",
193700
+ boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
193701
+ }
193702
+ }));
193703
+ function IconButton2(props2) {
193704
+ const { alt, onClick, isActive: isActive2, children: children3 } = props2;
193705
+ const classes = useStyles$8();
193706
+ return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children3 });
193707
+ }
193708
+ function ToolMenu(props2) {
193709
+ const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
193710
+ const classes = useStyles$8();
193711
+ return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton2, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton2, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton2, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
193712
+ }
193713
+ const getCursorWithTool = () => "crosshair";
193714
+ const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
193715
+ function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
193716
+ return (info2) => {
193717
+ if (setComponentHover) {
193718
+ setComponentHover();
193719
+ }
193720
+ if (info2.index) {
193721
+ const obsId = obsIndex[info2.index];
193722
+ if (setObsHighlight) {
193723
+ setObsHighlight(obsId);
193724
+ }
193725
+ } else if (setObsHighlight) {
193726
+ setObsHighlight(null);
193727
+ }
193728
+ };
193729
+ }
193730
+ class AbstractSpatialOrScatterplot extends PureComponent {
193731
+ constructor(props2) {
193732
+ super(props2);
193733
+ this.state = {
193734
+ gl: null,
193735
+ tool: null
193736
+ };
193737
+ this.viewport = null;
193738
+ this.onViewStateChange = this.onViewStateChange.bind(this);
193739
+ this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
193740
+ this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
193741
+ this.onToolChange = this.onToolChange.bind(this);
193742
+ this.onHover = this.onHover.bind(this);
193743
+ }
193744
+ onViewStateChange({ viewState: nextViewState }) {
193745
+ const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
193746
+ const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
193747
+ setViewState({
193748
+ ...nextViewState,
193749
+ target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
193750
+ });
193751
+ }
193752
+ onInitializeViewInfo({ viewport }) {
193753
+ this.viewport = viewport;
193754
+ }
193755
+ onWebGLInitialized(gl) {
193756
+ this.setState({ gl });
193757
+ }
193758
+ onToolChange(tool) {
193759
+ const { onToolChange: onToolChangeProp } = this.props;
193760
+ this.setState({ tool });
193761
+ if (onToolChangeProp) {
193762
+ onToolChangeProp(tool);
193763
+ }
193764
+ }
193765
+ getLayers() {
193766
+ return [];
193767
+ }
193768
+ onHover(info2) {
193769
+ const { coordinate, sourceLayer: layer, tile } = info2;
193770
+ const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
193771
+ const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
193772
+ if (!setCellHighlight || !tile) {
193773
+ return null;
193774
+ }
193775
+ if (!layer || !coordinate) {
193776
+ if (cellHighlight && hasBitmask) {
193777
+ setCellHighlight(null);
193778
+ }
193779
+ return null;
193780
+ }
193781
+ const { content: content2, bbox: bbox2, z } = tile;
193782
+ if (!content2) {
193783
+ if (cellHighlight && hasBitmask) {
193784
+ setCellHighlight(null);
193785
+ }
193786
+ return null;
193787
+ }
193788
+ const { data: data2, width: width2, height: height2 } = content2;
193789
+ const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
193790
+ const bounds2 = [
193791
+ left2,
193792
+ data2.height < layer.tileSize ? height2 : bottom2,
193793
+ data2.width < layer.tileSize ? width2 : right2,
193794
+ top2
193795
+ ];
193796
+ if (!data2) {
193797
+ if (cellHighlight && hasBitmask) {
193798
+ setCellHighlight(null);
193799
+ }
193800
+ return null;
193801
+ }
193802
+ if (layer.id.includes("bitmask")) {
193803
+ const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
193804
+ const dataCoords = [
193805
+ Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
193806
+ Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
193807
+ ];
193808
+ const coords = dataCoords[1] * width2 + dataCoords[0];
193809
+ const hoverData = data2.map((d) => d[coords]);
193810
+ const cellId = hoverData.find((i2) => i2 > 0);
193811
+ if (cellId !== Number(cellHighlight)) {
193812
+ if (setComponentHover) {
193813
+ setComponentHover();
193814
+ }
193815
+ setCellHighlight(cellId ? String(cellId) : null);
193816
+ }
193817
+ }
193818
+ }
193819
+ viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
193820
+ const { updateViewInfo, uuid } = this.props;
193821
+ const { viewport } = this;
193822
+ if (updateViewInfo && viewport) {
193823
+ updateViewInfo({
193824
+ uuid,
193825
+ project: (obsId) => {
193826
+ try {
193827
+ if (obsIndex && obsLocations) {
193828
+ const getObsCoords = makeGetObsCoords(obsLocations);
193829
+ const obsIdx = obsIndex.indexOf(obsId);
193830
+ const obsCoord = getObsCoords(obsIdx);
193831
+ return viewport.project(obsCoord);
193634
193832
  }
193833
+ return [null, null];
193834
+ } catch (e3) {
193835
+ return [null, null];
193635
193836
  }
193636
193837
  }
193637
- return target2;
193638
- }, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
193639
- return _extends2.apply(this, arguments);
193838
+ });
193640
193839
  }
193641
- module2.exports = _extends2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
193642
- })(_extends$1);
193643
- return _extends$1.exports;
193644
- }
193645
- var _extendsExports = require_extends();
193646
- var DEFAULT_CONFIG = {
193647
- epsilon: 1e-12,
193648
- matrix: "Matrix",
193649
- number: "number",
193650
- precision: 64,
193651
- predictable: false,
193652
- randomSeed: null
193653
- };
193654
- function isNumber$2(x2) {
193655
- return typeof x2 === "number";
193656
- }
193657
- function isBigNumber(x2) {
193658
- if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
193659
- return false;
193660
193840
  }
193661
- if (x2.isBigNumber === true && typeof x2.constructor.prototype === "object" && x2.constructor.prototype.isBigNumber === true) {
193662
- return true;
193841
+ componentDidUpdate() {
193663
193842
  }
193664
- if (typeof x2.constructor.isDecimal === "function" && x2.constructor.isDecimal(x2) === true) {
193665
- return true;
193843
+ use3d() {
193844
+ return false;
193845
+ }
193846
+ render() {
193847
+ var _a3, _b2, _c, _d;
193848
+ const { deckRef, viewState, uuid, hideTools } = this.props;
193849
+ const { gl, tool } = this.state;
193850
+ const layers = this.getLayers();
193851
+ const use3d = this.use3d();
193852
+ const showCellSelectionTools = this.obsSegmentationsData !== null;
193853
+ const showPanTool = layers.length > 0;
193854
+ 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);
193855
+ return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
193856
+ pan: showPanTool && !hideTools,
193857
+ selectRectangle: showCellSelectionTools && !hideTools,
193858
+ selectLasso: showCellSelectionTools && !hideTools
193859
+ } }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
193860
+ use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
193861
+ id: "ortho"
193862
+ })
193863
+ ], 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 })] });
193666
193864
  }
193667
- return false;
193668
- }
193669
- function isComplex(x2) {
193670
- return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
193671
- }
193672
- function isFraction(x2) {
193673
- return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
193674
- }
193675
- function isUnit(x2) {
193676
- return x2 && x2.constructor.prototype.isUnit === true || false;
193677
- }
193678
- function isString$1(x2) {
193679
- return typeof x2 === "string";
193680
- }
193681
- var isArray$1 = Array.isArray;
193682
- function isMatrix(x2) {
193683
- return x2 && x2.constructor.prototype.isMatrix === true || false;
193684
- }
193685
- function isCollection(x2) {
193686
- return Array.isArray(x2) || isMatrix(x2);
193687
- }
193688
- function isDenseMatrix(x2) {
193689
- return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
193690
- }
193691
- function isSparseMatrix(x2) {
193692
- return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
193693
- }
193694
- function isRange(x2) {
193695
- return x2 && x2.constructor.prototype.isRange === true || false;
193696
- }
193697
- function isIndex(x2) {
193698
- return x2 && x2.constructor.prototype.isIndex === true || false;
193699
- }
193700
- function isBoolean$3(x2) {
193701
- return typeof x2 === "boolean";
193702
- }
193703
- function isResultSet(x2) {
193704
- return x2 && x2.constructor.prototype.isResultSet === true || false;
193705
- }
193706
- function isHelp(x2) {
193707
- return x2 && x2.constructor.prototype.isHelp === true || false;
193708
- }
193709
- function isFunction$2(x2) {
193710
- return typeof x2 === "function";
193711
- }
193712
- function isDate$2(x2) {
193713
- return x2 instanceof Date;
193714
- }
193715
- function isRegExp$1(x2) {
193716
- return x2 instanceof RegExp;
193717
- }
193718
- function isObject$1(x2) {
193719
- return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
193720
- }
193721
- function isNull(x2) {
193722
- return x2 === null;
193723
- }
193724
- function isUndefined(x2) {
193725
- return x2 === void 0;
193726
- }
193727
- function isAccessorNode(x2) {
193728
- return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
193729
- }
193730
- function isArrayNode(x2) {
193731
- return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
193732
- }
193733
- function isAssignmentNode(x2) {
193734
- return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
193735
- }
193736
- function isBlockNode(x2) {
193737
- return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
193738
- }
193739
- function isConditionalNode(x2) {
193740
- return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
193741
- }
193742
- function isConstantNode(x2) {
193743
- return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
193744
- }
193745
- function isFunctionAssignmentNode(x2) {
193746
- return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
193747
- }
193748
- function isFunctionNode(x2) {
193749
- return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
193750
- }
193751
- function isIndexNode(x2) {
193752
- return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
193753
193865
  }
193754
- function isNode(x2) {
193755
- return x2 && x2.isNode === true && x2.constructor.prototype.isNode === true || false;
193866
+ function createQuadTree(obsEmbedding, getCellCoords) {
193867
+ if (!obsEmbedding) {
193868
+ return null;
193869
+ }
193870
+ const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
193871
+ return tree2;
193756
193872
  }
193757
- function isObjectNode(x2) {
193758
- return x2 && x2.isObjectNode === true && x2.constructor.prototype.isNode === true || false;
193873
+ function constant$5(v) {
193874
+ return () => v;
193759
193875
  }
193760
- function isOperatorNode(x2) {
193761
- return x2 && x2.isOperatorNode === true && x2.constructor.prototype.isNode === true || false;
193876
+ function jiggle$1(v) {
193877
+ return v + (Math.random() - 0.5) * 1e-6;
193762
193878
  }
193763
- function isParenthesisNode(x2) {
193764
- return x2 && x2.isParenthesisNode === true && x2.constructor.prototype.isNode === true || false;
193879
+ function forceCollideRects() {
193880
+ let nodes;
193881
+ let masses;
193882
+ let strength = 1;
193883
+ let iterations2 = 1;
193884
+ let sizes;
193885
+ let size2 = constant$5([0, 0]);
193886
+ function xCenter(d) {
193887
+ return d.x + d.vx + sizes[d.index][0] / 2;
193888
+ }
193889
+ function yCenter(d) {
193890
+ return d.y + d.vy + sizes[d.index][1] / 2;
193891
+ }
193892
+ function prepare2(quad2) {
193893
+ if (quad2.data) {
193894
+ quad2.size = sizes[quad2.data.index];
193895
+ } else {
193896
+ quad2.size = [0, 0];
193897
+ for (let i2 = 0; i2 < 4; i2++) {
193898
+ if (quad2[i2] && quad2[i2].size) {
193899
+ quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
193900
+ quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
193901
+ }
193902
+ }
193903
+ }
193904
+ }
193905
+ function force2() {
193906
+ let node;
193907
+ let nodeSize;
193908
+ let nodeMass;
193909
+ let xi;
193910
+ let yi;
193911
+ const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
193912
+ function apply2(quad2, x02, y02, x12, y12) {
193913
+ const { data: data2 } = quad2;
193914
+ const xSize = (nodeSize[0] + quad2.size[0]) / 2;
193915
+ const ySize = (nodeSize[1] + quad2.size[1]) / 2;
193916
+ if (data2 && data2.index > node.index) {
193917
+ let x2 = jiggle$1(xi - xCenter(data2));
193918
+ let y2 = jiggle$1(yi - yCenter(data2));
193919
+ const xd = Math.abs(x2) - xSize;
193920
+ const yd = Math.abs(y2) - ySize;
193921
+ if (xd < 0 && yd < 0) {
193922
+ const l2 = Math.sqrt(x2 * x2 + y2 * y2);
193923
+ const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
193924
+ if (Math.abs(xd) < Math.abs(yd)) {
193925
+ node.vx -= (x2 *= xd / l2 * strength) * m2;
193926
+ data2.vx += x2 * (1 - m2);
193927
+ } else {
193928
+ node.vy -= (y2 *= yd / l2 * strength) * m2;
193929
+ data2.vy += y2 * (1 - m2);
193930
+ }
193931
+ }
193932
+ return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
193933
+ }
193934
+ return false;
193935
+ }
193936
+ function iterate2() {
193937
+ for (let j = 0; j < nodes.length; j++) {
193938
+ node = nodes[j];
193939
+ nodeSize = sizes[j];
193940
+ nodeMass = masses[j];
193941
+ xi = xCenter(node);
193942
+ yi = yCenter(node);
193943
+ tree2.visit(apply2);
193944
+ }
193945
+ }
193946
+ for (let i2 = 0; i2 < iterations2; i2++) {
193947
+ iterate2();
193948
+ }
193949
+ }
193950
+ force2.initialize = (v) => {
193951
+ nodes = v;
193952
+ sizes = nodes.map(size2);
193953
+ masses = sizes.map((d) => d[0] + d[1]);
193954
+ };
193955
+ force2.iterations = (...v) => {
193956
+ if (v.length) {
193957
+ iterations2 = +v[0];
193958
+ return force2;
193959
+ }
193960
+ return iterations2;
193961
+ };
193962
+ force2.strength = (...v) => {
193963
+ if (v.length) {
193964
+ strength = +v[0];
193965
+ return force2;
193966
+ }
193967
+ return strength;
193968
+ };
193969
+ force2.size = (...v) => {
193970
+ if (v.length) {
193971
+ size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
193972
+ return force2;
193973
+ }
193974
+ return size2;
193975
+ };
193976
+ return force2;
193765
193977
  }
193766
- function isRangeNode(x2) {
193767
- return x2 && x2.isRangeNode === true && x2.constructor.prototype.isNode === true || false;
193978
+ function baseClamp$1(number2, lower, upper) {
193979
+ if (number2 === number2) {
193980
+ if (upper !== void 0) {
193981
+ number2 = number2 <= upper ? number2 : upper;
193982
+ }
193983
+ if (lower !== void 0) {
193984
+ number2 = number2 >= lower ? number2 : lower;
193985
+ }
193986
+ }
193987
+ return number2;
193768
193988
  }
193769
- function isSymbolNode(x2) {
193770
- return x2 && x2.isSymbolNode === true && x2.constructor.prototype.isNode === true || false;
193989
+ var _baseClamp = baseClamp$1;
193990
+ var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
193991
+ function clamp$2(number2, lower, upper) {
193992
+ if (upper === void 0) {
193993
+ upper = lower;
193994
+ lower = void 0;
193995
+ }
193996
+ if (upper !== void 0) {
193997
+ upper = toNumber$1(upper);
193998
+ upper = upper === upper ? upper : 0;
193999
+ }
194000
+ if (lower !== void 0) {
194001
+ lower = toNumber$1(lower);
194002
+ lower = lower === lower ? lower : 0;
194003
+ }
194004
+ return baseClamp(toNumber$1(number2), lower, upper);
193771
194005
  }
193772
- function isChain(x2) {
193773
- return x2 && x2.constructor.prototype.isChain === true || false;
194006
+ var clamp_1 = clamp$2;
194007
+ function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
194008
+ const pointSize = 5e-4;
194009
+ const pointScreenSizeMax = 10;
194010
+ const pointScreenSizeMin = 1 / devicePixelRatio2;
194011
+ const scaleFactor = 2 ** zoom2;
194012
+ const xAxisRange = 2 / (xRange * scaleFactor / width2);
194013
+ const yAxisRange = 2 / (yRange * scaleFactor / height2);
194014
+ const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
194015
+ const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
194016
+ const diagonalFraction = pointSize / diagonalAxisRange;
194017
+ const deviceSize = diagonalFraction * diagonalScreenSize;
194018
+ const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
194019
+ return pointSizeDevicePixels;
193774
194020
  }
193775
- function typeOf(x2) {
193776
- var t4 = typeof x2;
193777
- if (t4 === "object") {
193778
- if (x2 === null)
193779
- return "null";
193780
- if (Array.isArray(x2))
193781
- return "Array";
193782
- if (x2 instanceof Date)
193783
- return "Date";
193784
- if (x2 instanceof RegExp)
193785
- return "RegExp";
193786
- if (isBigNumber(x2))
193787
- return "BigNumber";
193788
- if (isComplex(x2))
193789
- return "Complex";
193790
- if (isFraction(x2))
193791
- return "Fraction";
193792
- if (isMatrix(x2))
193793
- return "Matrix";
193794
- if (isUnit(x2))
193795
- return "Unit";
193796
- if (isIndex(x2))
193797
- return "Index";
193798
- if (isRange(x2))
193799
- return "Range";
193800
- if (isResultSet(x2))
193801
- return "ResultSet";
193802
- if (isNode(x2))
193803
- return x2.type;
193804
- if (isChain(x2))
193805
- return "Chain";
193806
- if (isHelp(x2))
193807
- return "Help";
193808
- return "Object";
194021
+ function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
194022
+ const N2 = numCells;
194023
+ const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
194024
+ height: height2,
194025
+ width: width2,
194026
+ viewState: { zoom: zoom2, target: [0, 0, 0] }
194027
+ }).getBounds();
194028
+ const X3 = maxY2 - minY;
194029
+ const Y3 = maxX - minX;
194030
+ const X02 = xRange;
194031
+ const Y02 = yRange;
194032
+ const W = width2;
194033
+ const H = height2;
194034
+ let rho = avgFillDensity;
194035
+ if (!rho) {
194036
+ rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
193809
194037
  }
193810
- if (t4 === "function")
193811
- return "Function";
193812
- return t4;
194038
+ const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
194039
+ const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
194040
+ return pointOpacity;
193813
194041
  }
193814
- function clone$2(x2) {
193815
- var type3 = typeof x2;
193816
- if (type3 === "number" || type3 === "string" || type3 === "boolean" || x2 === null || x2 === void 0) {
193817
- return x2;
193818
- }
193819
- if (typeof x2.clone === "function") {
193820
- return x2.clone();
194042
+ const CELLS_LAYER_ID$1 = "scatterplot";
194043
+ const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
194044
+ const NUM_FORCE_SIMULATION_TICKS = 100;
194045
+ const LABEL_UPDATE_ZOOM_DELTA = 0.25;
194046
+ const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
194047
+ const [r3, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
194048
+ return [r3, g2, b2, 255 * (a2 || 1)];
194049
+ };
194050
+ const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
194051
+ obsEmbedding.data[0][i2],
194052
+ obsEmbedding.data[1][i2],
194053
+ 0
194054
+ ];
194055
+ const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
194056
+ obsEmbedding.data[0][i2],
194057
+ -obsEmbedding.data[1][i2],
194058
+ 0
194059
+ ];
194060
+ const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
194061
+ target2[0] = data2.src.obsEmbedding.data[0][index2];
194062
+ target2[1] = -data2.src.obsEmbedding.data[1][index2];
194063
+ target2[2] = 0;
194064
+ return target2;
194065
+ };
194066
+ class Scatterplot extends AbstractSpatialOrScatterplot {
194067
+ constructor(props2) {
194068
+ super(props2);
194069
+ this.cellsQuadTree = null;
194070
+ this.cellsLayer = null;
194071
+ this.cellsData = null;
194072
+ this.cellSetsForceSimulation = forceCollideRects();
194073
+ this.cellSetsLabelPrevZoom = null;
194074
+ this.cellSetsLayers = [];
194075
+ this.onUpdateCellsData();
194076
+ this.onUpdateCellsLayer();
194077
+ this.onUpdateCellSetsLayers();
193821
194078
  }
193822
- if (Array.isArray(x2)) {
193823
- return x2.map(function(value2) {
193824
- return clone$2(value2);
194079
+ createCellsLayer() {
194080
+ const {
194081
+ obsEmbeddingIndex: obsIndex,
194082
+ theme,
194083
+ cellRadius = 1,
194084
+ cellOpacity = 1,
194085
+ cellSelection,
194086
+ setCellHighlight,
194087
+ setComponentHover,
194088
+ getCellIsSelected,
194089
+ cellColors,
194090
+ getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
194091
+ getExpressionValue,
194092
+ onCellClick,
194093
+ geneExpressionColormap,
194094
+ geneExpressionColormapRange = [0, 1],
194095
+ cellColorEncoding
194096
+ } = this.props;
194097
+ return new ScatterplotLayer({
194098
+ id: CELLS_LAYER_ID$1,
194099
+ data: this.cellsData,
194100
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
194101
+ visible: true,
194102
+ pickable: true,
194103
+ autoHighlight: true,
194104
+ filled: true,
194105
+ stroked: true,
194106
+ backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
194107
+ getCellIsSelected,
194108
+ opacity: cellOpacity,
194109
+ radiusScale: cellRadius,
194110
+ radiusMinPixels: 1,
194111
+ radiusMaxPixels: 30,
194112
+ radiusUnits: "pixels",
194113
+ lineWidthUnits: "pixels",
194114
+ getPosition,
194115
+ getFillColor: getCellColor,
194116
+ getLineColor: getCellColor,
194117
+ getRadius: 1,
194118
+ getExpressionValue,
194119
+ getLineWidth: 0,
194120
+ extensions: [
194121
+ new ScaledExpressionExtension(),
194122
+ new SelectionExtension({ instanced: true })
194123
+ ],
194124
+ colorScaleLo: geneExpressionColormapRange[0],
194125
+ colorScaleHi: geneExpressionColormapRange[1],
194126
+ isExpressionMode: cellColorEncoding === "geneSelection",
194127
+ colormap: geneExpressionColormap,
194128
+ onClick: (info2) => {
194129
+ if (onCellClick) {
194130
+ onCellClick(info2);
194131
+ }
194132
+ },
194133
+ onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
194134
+ updateTriggers: {
194135
+ getExpressionValue,
194136
+ getFillColor: [cellColorEncoding, cellSelection, cellColors],
194137
+ getLineColor: [cellColorEncoding, cellSelection, cellColors],
194138
+ getCellIsSelected
194139
+ }
193825
194140
  });
193826
194141
  }
193827
- if (x2 instanceof Date)
193828
- return new Date(x2.valueOf());
193829
- if (isBigNumber(x2))
193830
- return x2;
193831
- if (x2 instanceof RegExp)
193832
- throw new TypeError("Cannot clone " + x2);
193833
- return mapObject(x2, clone$2);
193834
- }
193835
- function mapObject(object2, callback) {
193836
- var clone3 = {};
193837
- for (var key2 in object2) {
193838
- if (hasOwnProperty$2(object2, key2)) {
193839
- clone3[key2] = callback(object2[key2]);
194142
+ createCellSetsLayers() {
194143
+ const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
194144
+ const result = [];
194145
+ if (cellSetPolygonsVisible) {
194146
+ result.push(new PolygonLayer({
194147
+ id: "cell-sets-polygon-layer",
194148
+ data: cellSetPolygons,
194149
+ stroked: true,
194150
+ filled: false,
194151
+ wireframe: true,
194152
+ lineWidthMaxPixels: 1,
194153
+ getPolygon: (d) => d.hull,
194154
+ getLineColor: (d) => d.color,
194155
+ getLineWidth: 1
194156
+ }));
193840
194157
  }
193841
- }
193842
- return clone3;
193843
- }
193844
- function extend$2(a2, b2) {
193845
- for (var prop in b2) {
193846
- if (hasOwnProperty$2(b2, prop)) {
193847
- a2[prop] = b2[prop];
194158
+ if (cellSetLabelsVisible) {
194159
+ const { zoom: zoom2 } = viewState;
194160
+ const nodes = cellSetPolygons.map((p) => ({
194161
+ x: p.centroid[0],
194162
+ y: p.centroid[1],
194163
+ label: p.name
194164
+ }));
194165
+ const collisionForce = this.cellSetsForceSimulation.size((d) => [
194166
+ cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
194167
+ cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
194168
+ ]);
194169
+ forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
194170
+ result.push(new TextLayer({
194171
+ id: "cell-sets-text-layer",
194172
+ data: nodes,
194173
+ getPosition: (d) => [d.x, d.y],
194174
+ getText: (d) => d.label,
194175
+ getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
194176
+ getSize: cellSetLabelSize,
194177
+ getAngle: 0,
194178
+ getTextAnchor: "middle",
194179
+ getAlignmentBaseline: "center",
194180
+ fontFamily: LABEL_FONT_FAMILY,
194181
+ fontWeight: "normal"
194182
+ }));
193848
194183
  }
194184
+ return result;
193849
194185
  }
193850
- return a2;
193851
- }
193852
- function deepStrictEqual(a2, b2) {
193853
- var prop, i2, len2;
193854
- if (Array.isArray(a2)) {
193855
- if (!Array.isArray(b2)) {
193856
- return false;
194186
+ createSelectionLayers() {
194187
+ const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
194188
+ const { tool } = this.state;
194189
+ const { cellsQuadTree } = this;
194190
+ const flipYTooltip = true;
194191
+ const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
194192
+ return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
194193
+ }
194194
+ getLayers() {
194195
+ const { cellsLayer, cellSetsLayers } = this;
194196
+ return [
194197
+ cellsLayer,
194198
+ ...cellSetsLayers,
194199
+ ...this.createSelectionLayers()
194200
+ ];
194201
+ }
194202
+ onUpdateCellsData() {
194203
+ const { obsEmbedding } = this.props;
194204
+ if (obsEmbedding) {
194205
+ const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
194206
+ this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
194207
+ this.cellsData = {
194208
+ src: {
194209
+ obsEmbedding
194210
+ },
194211
+ length: obsEmbedding.shape[1]
194212
+ };
193857
194213
  }
193858
- if (a2.length !== b2.length) {
193859
- return false;
194214
+ }
194215
+ onUpdateCellsLayer() {
194216
+ const { obsEmbeddingIndex, obsEmbedding } = this.props;
194217
+ if (obsEmbeddingIndex && obsEmbedding) {
194218
+ this.cellsLayer = this.createCellsLayer();
194219
+ } else {
194220
+ this.cellsLayer = null;
193860
194221
  }
193861
- for (i2 = 0, len2 = a2.length; i2 < len2; i2++) {
193862
- if (!deepStrictEqual(a2[i2], b2[i2])) {
193863
- return false;
194222
+ }
194223
+ onUpdateCellSetsLayers(onlyViewStateChange) {
194224
+ if (onlyViewStateChange) {
194225
+ const { viewState, cellSetLabelsVisible } = this.props;
194226
+ const { zoom: zoom2 } = viewState;
194227
+ const { cellSetsLabelPrevZoom } = this;
194228
+ if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
194229
+ this.cellSetsLayers = this.createCellSetsLayers();
194230
+ this.cellSetsLabelPrevZoom = zoom2;
193864
194231
  }
194232
+ } else {
194233
+ this.cellSetsLayers = this.createCellSetsLayers();
193865
194234
  }
193866
- return true;
193867
- } else if (typeof a2 === "function") {
193868
- return a2 === b2;
193869
- } else if (a2 instanceof Object) {
193870
- if (Array.isArray(b2) || !(b2 instanceof Object)) {
193871
- return false;
194235
+ }
194236
+ viewInfoDidUpdate() {
194237
+ const { obsEmbeddingIndex, obsEmbedding } = this.props;
194238
+ super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
194239
+ }
194240
+ componentDidUpdate(prevProps) {
194241
+ this.viewInfoDidUpdate();
194242
+ const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
194243
+ let forceUpdate = false;
194244
+ if (["obsEmbedding"].some(shallowDiff)) {
194245
+ this.onUpdateCellsData();
194246
+ forceUpdate = true;
193872
194247
  }
193873
- for (prop in a2) {
193874
- if (!(prop in b2) || !deepStrictEqual(a2[prop], b2[prop])) {
193875
- return false;
193876
- }
194248
+ if ([
194249
+ "obsEmbeddingIndex",
194250
+ "obsEmbedding",
194251
+ "cellFilter",
194252
+ "cellSelection",
194253
+ "cellColors",
194254
+ "cellRadius",
194255
+ "cellOpacity",
194256
+ "cellRadiusMode",
194257
+ "geneExpressionColormap",
194258
+ "geneExpressionColormapRange",
194259
+ "geneSelection",
194260
+ "cellColorEncoding"
194261
+ ].some(shallowDiff)) {
194262
+ this.onUpdateCellsLayer();
194263
+ forceUpdate = true;
193877
194264
  }
193878
- for (prop in b2) {
193879
- if (!(prop in a2)) {
193880
- return false;
193881
- }
194265
+ if ([
194266
+ "cellSetPolygons",
194267
+ "cellSetPolygonsVisible",
194268
+ "cellSetLabelsVisible",
194269
+ "cellSetLabelSize"
194270
+ ].some(shallowDiff)) {
194271
+ this.onUpdateCellSetsLayers(false);
194272
+ forceUpdate = true;
194273
+ }
194274
+ if (shallowDiff("viewState")) {
194275
+ this.onUpdateCellSetsLayers(true);
194276
+ forceUpdate = true;
194277
+ }
194278
+ if (forceUpdate) {
194279
+ this.forceUpdate();
193882
194280
  }
193883
- return true;
193884
- } else {
193885
- return a2 === b2;
193886
194281
  }
193887
194282
  }
193888
- function hasOwnProperty$2(object2, property2) {
193889
- return object2 && Object.hasOwnProperty.call(object2, property2);
194283
+ const ScatterplotWrapper = forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
194284
+ function ScatterplotOptions(props2) {
194285
+ const { children: children3, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
194286
+ const observationsLabelNice = capitalize$2(observationsLabel);
194287
+ const classes = useStyles$b();
194288
+ function handleCellRadiusModeChange(event2) {
194289
+ setCellRadiusMode(event2.target.value);
194290
+ }
194291
+ function handleCellOpacityModeChange(event2) {
194292
+ setCellOpacityMode(event2.target.value);
194293
+ }
194294
+ function handleRadiusChange(event2, value2) {
194295
+ setCellRadius(value2);
194296
+ }
194297
+ function handleOpacityChange(event2, value2) {
194298
+ setCellOpacity(value2);
194299
+ }
194300
+ function handleLabelVisibilityChange(event2) {
194301
+ setCellSetLabelsVisible(event2.target.checked);
194302
+ }
194303
+ function handleLabelSizeChange(event2, value2) {
194304
+ setCellSetLabelSize(value2);
194305
+ }
194306
+ function handlePolygonVisibilityChange(event2) {
194307
+ setCellSetPolygonsVisible(event2.target.checked);
194308
+ }
194309
+ function handleGeneExpressionColormapChange(event2) {
194310
+ setGeneExpressionColormap(event2.target.value);
194311
+ }
194312
+ function handleColormapRangeChange(event2, value2) {
194313
+ setGeneExpressionColormapRange(value2);
194314
+ }
194315
+ const handleColormapRangeChangeDebounced = useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
194316
+ return jsxs(OptionsContainer, { children: [children3, 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: {
194317
+ id: "cell-radius-mode-select"
194318
+ }, 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: {
194319
+ id: "cell-opacity-mode-select"
194320
+ }, 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: {
194321
+ id: "gene-expression-colormap-select"
194322
+ }, 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 }) })] })] });
193890
194323
  }
193891
- function pickShallow(object2, properties2) {
193892
- var copy2 = {};
193893
- for (var i2 = 0; i2 < properties2.length; i2++) {
193894
- var key2 = properties2[i2];
193895
- var value2 = object2[key2];
193896
- if (value2 !== void 0) {
193897
- copy2[key2] = value2;
194324
+ const styles34 = makeStyles(() => ({
194325
+ tooltipAnchor: {
194326
+ position: "relative",
194327
+ width: "0px",
194328
+ height: "0px",
194329
+ pointerEvents: "none",
194330
+ userSelect: "none"
194331
+ },
194332
+ tooltipContent: {
194333
+ opacity: 0.9,
194334
+ padding: "5px",
194335
+ pointerEvents: "none",
194336
+ "& table > tbody > tr > th, & table > tbody > tr > td": {
194337
+ fontSize: "80%",
194338
+ opacity: 0.8,
194339
+ outline: 0,
194340
+ padding: "0 2px"
194341
+ },
194342
+ "& table": {
194343
+ borderCollapse: "collapse"
193898
194344
  }
193899
194345
  }
193900
- return copy2;
194346
+ }));
194347
+ function Tooltip2(props2) {
194348
+ const { x: x2, y: y2, parentWidth, parentHeight, children: children3 } = props2;
194349
+ const ref2 = useRef();
194350
+ const classes = styles34();
194351
+ const [placementX, setPlacementX] = useState("start");
194352
+ const [placementY, setPlacementY] = useState("bottom");
194353
+ const getTooltipContainer = useVitessceContainer(ref2);
194354
+ useEffect(() => {
194355
+ if (ref2 && ref2.current) {
194356
+ const flipX = x2 > parentWidth / 2;
194357
+ const flipY = y2 > parentHeight / 2;
194358
+ setPlacementX(flipX ? "end" : "start");
194359
+ setPlacementY(flipY ? "top" : "bottom");
194360
+ ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
194361
+ ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
194362
+ }
194363
+ }, [x2, y2, parentWidth, parentHeight]);
194364
+ 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: children3 }) }) : null });
193901
194365
  }
193902
- var MATRIX_OPTIONS = ["Matrix", "Array"];
193903
- var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
193904
- var config$1 = function config(options) {
193905
- if (options) {
193906
- 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");
194366
+ function Tooltip2D(props2) {
194367
+ const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children3 } = props2;
194368
+ if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
194369
+ return null;
193907
194370
  }
193908
- return Object.freeze(DEFAULT_CONFIG);
193909
- };
193910
- _extendsExports(config$1, DEFAULT_CONFIG, {
193911
- MATRIX_OPTIONS,
193912
- NUMBER_OPTIONS
193913
- });
193914
- var typedFunction$1 = { exports: {} };
193915
- (function(module2, exports) {
193916
- (function(root2, factory2) {
193917
- {
193918
- module2.exports = factory2();
193919
- }
193920
- })(commonjsGlobal$1, function() {
193921
- function ok() {
193922
- return true;
193923
- }
193924
- function notOk() {
193925
- return false;
193926
- }
193927
- function undef() {
193928
- return void 0;
193929
- }
193930
- function create6() {
193931
- var _types = [
193932
- { name: "number", test: function(x2) {
193933
- return typeof x2 === "number";
193934
- } },
193935
- { name: "string", test: function(x2) {
193936
- return typeof x2 === "string";
193937
- } },
193938
- { name: "boolean", test: function(x2) {
193939
- return typeof x2 === "boolean";
193940
- } },
193941
- { name: "Function", test: function(x2) {
193942
- return typeof x2 === "function";
193943
- } },
193944
- { name: "Array", test: Array.isArray },
193945
- { name: "Date", test: function(x2) {
193946
- return x2 instanceof Date;
193947
- } },
193948
- { name: "RegExp", test: function(x2) {
193949
- return x2 instanceof RegExp;
193950
- } },
193951
- { name: "Object", test: function(x2) {
193952
- return typeof x2 === "object" && x2 !== null && x2.constructor === Object;
193953
- } },
193954
- { name: "null", test: function(x2) {
193955
- return x2 === null;
193956
- } },
193957
- { name: "undefined", test: function(x2) {
193958
- return x2 === void 0;
193959
- } }
193960
- ];
193961
- var anyType = {
193962
- name: "any",
193963
- test: ok
193964
- };
193965
- var _ignore = [];
193966
- var _conversions = [];
193967
- var typed2 = {
193968
- types: _types,
193969
- conversions: _conversions,
193970
- ignore: _ignore
193971
- };
193972
- function findTypeByName(typeName) {
193973
- var entry2 = findInArray2(typed2.types, function(entry3) {
193974
- return entry3.name === typeName;
193975
- });
193976
- if (entry2) {
193977
- return entry2;
193978
- }
193979
- if (typeName === "any") {
193980
- return anyType;
193981
- }
193982
- var hint2 = findInArray2(typed2.types, function(entry3) {
193983
- return entry3.name.toLowerCase() === typeName.toLowerCase();
194371
+ const isTooltipVisible = parentUuid === sourceUuid;
194372
+ const crosshairWidth = 1;
194373
+ return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip2, { x: x2, y: y2, parentWidth, parentHeight, children: children3 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
194374
+ left: `${x2 - crosshairWidth / 2}px`,
194375
+ top: 0,
194376
+ width: `${crosshairWidth}px`,
194377
+ height: `${parentHeight}px`
194378
+ } }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
194379
+ left: 0,
194380
+ top: `${y2 - crosshairWidth / 2}px`,
194381
+ width: `${parentWidth}px`,
194382
+ height: `${crosshairWidth}px`
194383
+ } }) : null] }) });
194384
+ }
194385
+ function TooltipContent(props2) {
194386
+ const { info: info2 } = props2;
194387
+ 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)) }) });
194388
+ }
194389
+ function ScatterplotTooltipSubscriber(props2) {
194390
+ const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
194391
+ const sourceUuid = useComponentHover();
194392
+ const viewInfo = useComponentViewInfo(parentUuid);
194393
+ const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
194394
+ getObsInfo(obsHighlight),
194395
+ ...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
194396
+ ] : [null, null, null];
194397
+ return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
194398
+ }
194399
+ function EmptyMessage(props2) {
194400
+ const { visible, message } = props2;
194401
+ return visible ? jsx("div", { children: message }) : null;
194402
+ }
194403
+ function EmbeddingScatterplotSubscriber(props2) {
194404
+ const {
194405
+ uuid,
194406
+ coordinationScopes,
194407
+ removeGridComponent,
194408
+ theme,
194409
+ disableTooltip = false,
194410
+ observationsLabelOverride,
194411
+ title: titleOverride,
194412
+ averageFillDensity
194413
+ } = props2;
194414
+ const loaders = useLoaders();
194415
+ const setComponentHover = useSetComponentHover();
194416
+ const setComponentViewInfo = useSetComponentViewInfo(uuid);
194417
+ 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);
194418
+ const observationsLabel = observationsLabelOverride || obsType;
194419
+ const [urls2, addUrl2] = useUrls(loaders, dataset);
194420
+ const [width2, height2, deckRef] = useDeckCanvasSize();
194421
+ const title2 = titleOverride || `Scatterplot (${mapping})`;
194422
+ const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
194423
+ const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
194424
+ const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
194425
+ const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
194426
+ const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
194427
+ const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
194428
+ const isReady = useReady([
194429
+ obsEmbeddingStatus,
194430
+ obsSetsStatus,
194431
+ featureSelectionStatus,
194432
+ matrixIndicesStatus
194433
+ ]);
194434
+ const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
194435
+ const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
194436
+ const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
194437
+ const setCellSelectionProp = useCallback((v) => {
194438
+ setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
194439
+ }, [
194440
+ additionalCellSets,
194441
+ cellSetColor,
194442
+ setCellColorEncoding,
194443
+ setAdditionalCellSets,
194444
+ setCellSetColor,
194445
+ setCellSetSelection
194446
+ ]);
194447
+ const cellColors = useMemo(() => getCellColors({
194448
+ cellColorEncoding,
194449
+ expressionData: expressionData && expressionData[0],
194450
+ geneSelection,
194451
+ cellSets: mergedCellSets,
194452
+ cellSetSelection,
194453
+ cellSetColor,
194454
+ obsIndex: matrixObsIndex,
194455
+ theme
194456
+ }), [
194457
+ cellColorEncoding,
194458
+ geneSelection,
194459
+ mergedCellSets,
194460
+ theme,
194461
+ cellSetSelection,
194462
+ cellSetColor,
194463
+ expressionData,
194464
+ matrixObsIndex
194465
+ ]);
194466
+ const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
194467
+ const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
194468
+ const cacheGet = (cache2, key2) => {
194469
+ var _a3;
194470
+ return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
194471
+ };
194472
+ const cellSetPolygons = useMemo(() => {
194473
+ var _a3;
194474
+ 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)) {
194475
+ const newCellSetPolygons = getCellSetPolygons({
194476
+ obsIndex: obsEmbeddingIndex,
194477
+ obsEmbedding,
194478
+ cellSets: mergedCellSets,
194479
+ cellSetSelection,
194480
+ cellSetColor,
194481
+ theme
194482
+ });
194483
+ setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
194484
+ return newCellSetPolygons;
194485
+ }
194486
+ return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
194487
+ }, [
194488
+ cellSetPolygonsVisible,
194489
+ cellSetPolygonCache,
194490
+ cellSetLabelsVisible,
194491
+ theme,
194492
+ obsEmbeddingIndex,
194493
+ obsEmbedding,
194494
+ mergedCellSets,
194495
+ cellSetSelection,
194496
+ cellSetColor
194497
+ ]);
194498
+ const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
194499
+ const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
194500
+ if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
194501
+ const cellCount = obsEmbedding.shape[1];
194502
+ const xE = extent$2(obsEmbedding.data[0]);
194503
+ const yE = extent$2(obsEmbedding.data[1]);
194504
+ const xR = xE[1] - xE[0];
194505
+ const yR = yE[1] - yE[0];
194506
+ return [xR, yR, xE, yE, cellCount];
194507
+ }
194508
+ return [null, null, null, null, null];
194509
+ }, [obsEmbedding]);
194510
+ useEffect(() => {
194511
+ if (xRange && yRange) {
194512
+ const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
194513
+ setDynamicCellRadius(pointSizeDevicePixels);
194514
+ const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
194515
+ setDynamicCellOpacity(nextCellOpacityScale);
194516
+ if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
194517
+ const newTargetX = xExtent[0] + xRange / 2;
194518
+ const newTargetY = yExtent[0] + yRange / 2;
194519
+ const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
194520
+ setTargetX(newTargetX);
194521
+ setTargetY(-newTargetY);
194522
+ setZoom(newZoom);
194523
+ }
194524
+ }
194525
+ }, [
194526
+ xRange,
194527
+ yRange,
194528
+ xExtent,
194529
+ yExtent,
194530
+ numCells,
194531
+ width2,
194532
+ height2,
194533
+ zoom2,
194534
+ averageFillDensity
194535
+ ]);
194536
+ const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
194537
+ const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
194538
+ const getCellIsSelected = useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
194539
+ const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
194540
+ const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
194541
+ const getExpressionValue = useExpressionValueGetter({
194542
+ instanceObsIndex: obsEmbeddingIndex,
194543
+ matrixObsIndex,
194544
+ expressionData
194545
+ });
194546
+ 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 }) => {
194547
+ setZoom(newZoom);
194548
+ setTargetX(target2[0]);
194549
+ setTargetY(target2[1]);
194550
+ setTargetZ(target2[2] || 0);
194551
+ }, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
194552
+ setComponentHover(uuid);
194553
+ }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
194554
+ }
194555
+ function register$c() {
194556
+ registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
194557
+ }
194558
+ function GatingScatterplotOptions(props2) {
194559
+ const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
194560
+ const classes = useStyles$b();
194561
+ const handleGeneSelectChange = (event2) => {
194562
+ const { options } = event2.target;
194563
+ const newValues = [];
194564
+ for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
194565
+ if (options[i2].selected) {
194566
+ newValues.push(options[i2].value);
194567
+ }
194568
+ }
194569
+ if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
194570
+ setGatingFeatureSelectionY(newValues[0]);
194571
+ } else if (newValues.length <= 2) {
194572
+ setGatingFeatureSelectionX(newValues[0]);
194573
+ setGatingFeatureSelectionY(newValues[1]);
194574
+ }
194575
+ };
194576
+ const handleTransformChange = (event2) => {
194577
+ setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
194578
+ };
194579
+ const handleTransformCoefficientChange = (event2) => {
194580
+ const { value: value2 } = event2.target;
194581
+ if (!value2) {
194582
+ setGatingFeatureValueTransformCoefficient(value2);
194583
+ } else {
194584
+ const newCoefficient = Number(value2);
194585
+ if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
194586
+ setGatingFeatureValueTransformCoefficient(value2);
194587
+ }
194588
+ }
194589
+ };
194590
+ 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: {
194591
+ id: "scatterplot-gene-select"
194592
+ }, 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: {
194593
+ id: "scatterplot-transform-select"
194594
+ }, 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: {
194595
+ shrink: true
194596
+ } }) })] }, "transform-coefficient-option-row")] });
194597
+ }
194598
+ function GatingSubscriber(props2) {
194599
+ const {
194600
+ uuid,
194601
+ coordinationScopes,
194602
+ removeGridComponent,
194603
+ theme,
194604
+ disableTooltip = false,
194605
+ title: titleOverride,
194606
+ averageFillDensity
194607
+ } = props2;
194608
+ const loaders = useLoaders();
194609
+ const setComponentHover = useSetComponentHover();
194610
+ const setComponentViewInfo = useSetComponentViewInfo(uuid);
194611
+ 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);
194612
+ const [urls2, addUrl2] = useUrls(loaders, dataset);
194613
+ const [width2, height2, deckRef] = useDeckCanvasSize();
194614
+ const title2 = useMemo(() => {
194615
+ if (titleOverride) {
194616
+ return titleOverride;
194617
+ }
194618
+ if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
194619
+ return "Gating";
194620
+ }
194621
+ return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
194622
+ }, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
194623
+ const featureSelectionX = useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
194624
+ const featureSelectionY = useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
194625
+ const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
194626
+ const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
194627
+ const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
194628
+ const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
194629
+ const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
194630
+ const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
194631
+ const isReady = useReady([
194632
+ obsSetsStatus,
194633
+ featureSelectionColorStatus,
194634
+ featureSelectionXStatus,
194635
+ featureSelectionYStatus,
194636
+ matrixIndicesStatus
194637
+ ]);
194638
+ const obsXY = useMemo(() => {
194639
+ if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
194640
+ return null;
194641
+ }
194642
+ let coefficient = 1;
194643
+ const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
194644
+ if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
194645
+ coefficient = parsedTransformCoefficient;
194646
+ }
194647
+ const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
194648
+ const obsX = new Float32Array(cellsCount);
194649
+ const obsY = new Float32Array(cellsCount);
194650
+ for (let i2 = 0; i2 < cellsCount; i2 += 1) {
194651
+ obsX[i2] = transformFunction(expressionDataX[0][i2]);
194652
+ obsY[i2] = transformFunction(expressionDataY[0][i2]);
194653
+ }
194654
+ return {
194655
+ data: [obsX, obsY],
194656
+ shape: [2, cellsCount]
194657
+ };
194658
+ }, [
194659
+ cellsCount,
194660
+ expressionDataX,
194661
+ expressionDataY,
194662
+ featureValueTransform,
194663
+ featureValueTransformCoefficient,
194664
+ featureSelectionX,
194665
+ featureSelectionY
194666
+ ]);
194667
+ const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
194668
+ const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
194669
+ const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
194670
+ const setCellSelectionProp = useCallback((v) => {
194671
+ setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
194672
+ }, [
194673
+ additionalCellSets,
194674
+ cellSetColor,
194675
+ setCellColorEncoding,
194676
+ setAdditionalCellSets,
194677
+ setCellSetColor,
194678
+ setCellSetSelection
194679
+ ]);
194680
+ const cellColors = useMemo(() => getCellColors({
194681
+ cellColorEncoding,
194682
+ expressionData: expressionDataColor && expressionDataColor[0],
194683
+ geneSelection: gatingFeatureSelectionColor,
194684
+ cellSets: mergedCellSets,
194685
+ cellSetSelection,
194686
+ cellSetColor,
194687
+ obsIndex,
194688
+ theme
194689
+ }), [
194690
+ cellColorEncoding,
194691
+ gatingFeatureSelectionColor,
194692
+ mergedCellSets,
194693
+ theme,
194694
+ cellSetSelection,
194695
+ cellSetColor,
194696
+ expressionDataColor,
194697
+ obsIndex
194698
+ ]);
194699
+ const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
194700
+ const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
194701
+ const cacheGet = (cache2, key2) => {
194702
+ var _a3;
194703
+ return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
194704
+ };
194705
+ const cellSetPolygons = useMemo(() => {
194706
+ var _a3;
194707
+ 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)) {
194708
+ const newCellSetPolygons = getCellSetPolygons({
194709
+ obsIndex,
194710
+ obsEmbedding: obsXY,
194711
+ cellSets: mergedCellSets,
194712
+ cellSetSelection,
194713
+ cellSetColor,
194714
+ theme
194715
+ });
194716
+ setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
194717
+ return newCellSetPolygons;
194718
+ }
194719
+ return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
194720
+ }, [
194721
+ cellSetPolygonsVisible,
194722
+ cellSetPolygonCache,
194723
+ cellSetLabelsVisible,
194724
+ theme,
194725
+ obsIndex,
194726
+ obsXY,
194727
+ mergedCellSets,
194728
+ cellSetSelection,
194729
+ cellSetColor
194730
+ ]);
194731
+ const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
194732
+ const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
194733
+ if (obsXY && obsXY.data && obsXY.shape) {
194734
+ const cellCount = obsXY.shape[1];
194735
+ const xE = extent$2(obsXY.data[0]);
194736
+ const yE = extent$2(obsXY.data[1]);
194737
+ const xR = xE[1] - xE[0];
194738
+ const yR = yE[1] - yE[0];
194739
+ return [xR, yR, xE, yE, cellCount];
194740
+ }
194741
+ return [null, null, null, null, null];
194742
+ }, [obsXY]);
194743
+ useEffect(() => {
194744
+ if (xRange && yRange) {
194745
+ const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
194746
+ setDynamicCellRadius(pointSizeDevicePixels);
194747
+ const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
194748
+ setDynamicCellOpacity(nextCellOpacityScale);
194749
+ if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
194750
+ const newTargetX = xExtent[0] + xRange / 2;
194751
+ const newTargetY = yExtent[0] + yRange / 2;
194752
+ const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
194753
+ setTargetX(newTargetX);
194754
+ setTargetY(-newTargetY);
194755
+ setZoom(newZoom);
194756
+ }
194757
+ }
194758
+ }, [
194759
+ xRange,
194760
+ yRange,
194761
+ xExtent,
194762
+ yExtent,
194763
+ numCells,
194764
+ width2,
194765
+ height2,
194766
+ zoom2,
194767
+ averageFillDensity
194768
+ ]);
194769
+ const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
194770
+ const getCellIsSelected = useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
194771
+ const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
194772
+ const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
194773
+ const getExpressionValue = useExpressionValueGetter({
194774
+ instanceObsIndex: obsIndex,
194775
+ matrixObsIndex: obsIndex,
194776
+ expressionData: expressionDataColor
194777
+ });
194778
+ const getObsInfo = useCallback((obsId) => {
194779
+ var _a3;
194780
+ const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
194781
+ const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
194782
+ const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
194783
+ const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
194784
+ if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
194785
+ obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
194786
+ obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
194787
+ }
194788
+ return obsInfo;
194789
+ }, [
194790
+ obsXY,
194791
+ obsIndex,
194792
+ featureValueTransform,
194793
+ gatingFeatureSelectionX,
194794
+ gatingFeatureSelectionY,
194795
+ obsType
194796
+ ]);
194797
+ 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) => {
194798
+ setFeatureValueTransform(newValue);
194799
+ setTargetX(null);
194800
+ setTargetY(null);
194801
+ setZoom(null);
194802
+ }, 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 }) => {
194803
+ setZoom(newZoom);
194804
+ setTargetX(target2[0]);
194805
+ setTargetY(target2[1]);
194806
+ setTargetZ(target2[2] || 0);
194807
+ }, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
194808
+ setComponentHover(uuid);
194809
+ }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
194810
+ }
194811
+ function register$b() {
194812
+ registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
194813
+ }
194814
+ var _extends$1 = { exports: {} };
194815
+ var hasRequired_extends;
194816
+ function require_extends() {
194817
+ if (hasRequired_extends)
194818
+ return _extends$1.exports;
194819
+ hasRequired_extends = 1;
194820
+ (function(module2) {
194821
+ function _extends2() {
194822
+ module2.exports = _extends2 = Object.assign ? Object.assign.bind() : function(target2) {
194823
+ for (var i2 = 1; i2 < arguments.length; i2++) {
194824
+ var source2 = arguments[i2];
194825
+ for (var key2 in source2) {
194826
+ if (Object.prototype.hasOwnProperty.call(source2, key2)) {
194827
+ target2[key2] = source2[key2];
194828
+ }
194829
+ }
194830
+ }
194831
+ return target2;
194832
+ }, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
194833
+ return _extends2.apply(this, arguments);
194834
+ }
194835
+ module2.exports = _extends2, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
194836
+ })(_extends$1);
194837
+ return _extends$1.exports;
194838
+ }
194839
+ var _extendsExports = require_extends();
194840
+ var DEFAULT_CONFIG = {
194841
+ epsilon: 1e-12,
194842
+ matrix: "Matrix",
194843
+ number: "number",
194844
+ precision: 64,
194845
+ predictable: false,
194846
+ randomSeed: null
194847
+ };
194848
+ function isNumber$2(x2) {
194849
+ return typeof x2 === "number";
194850
+ }
194851
+ function isBigNumber(x2) {
194852
+ if (!x2 || typeof x2 !== "object" || typeof x2.constructor !== "function") {
194853
+ return false;
194854
+ }
194855
+ if (x2.isBigNumber === true && typeof x2.constructor.prototype === "object" && x2.constructor.prototype.isBigNumber === true) {
194856
+ return true;
194857
+ }
194858
+ if (typeof x2.constructor.isDecimal === "function" && x2.constructor.isDecimal(x2) === true) {
194859
+ return true;
194860
+ }
194861
+ return false;
194862
+ }
194863
+ function isComplex(x2) {
194864
+ return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isComplex === true || false;
194865
+ }
194866
+ function isFraction(x2) {
194867
+ return x2 && typeof x2 === "object" && Object.getPrototypeOf(x2).isFraction === true || false;
194868
+ }
194869
+ function isUnit(x2) {
194870
+ return x2 && x2.constructor.prototype.isUnit === true || false;
194871
+ }
194872
+ function isString$1(x2) {
194873
+ return typeof x2 === "string";
194874
+ }
194875
+ var isArray$1 = Array.isArray;
194876
+ function isMatrix(x2) {
194877
+ return x2 && x2.constructor.prototype.isMatrix === true || false;
194878
+ }
194879
+ function isCollection(x2) {
194880
+ return Array.isArray(x2) || isMatrix(x2);
194881
+ }
194882
+ function isDenseMatrix(x2) {
194883
+ return x2 && x2.isDenseMatrix && x2.constructor.prototype.isMatrix === true || false;
194884
+ }
194885
+ function isSparseMatrix(x2) {
194886
+ return x2 && x2.isSparseMatrix && x2.constructor.prototype.isMatrix === true || false;
194887
+ }
194888
+ function isRange(x2) {
194889
+ return x2 && x2.constructor.prototype.isRange === true || false;
194890
+ }
194891
+ function isIndex(x2) {
194892
+ return x2 && x2.constructor.prototype.isIndex === true || false;
194893
+ }
194894
+ function isBoolean$3(x2) {
194895
+ return typeof x2 === "boolean";
194896
+ }
194897
+ function isResultSet(x2) {
194898
+ return x2 && x2.constructor.prototype.isResultSet === true || false;
194899
+ }
194900
+ function isHelp(x2) {
194901
+ return x2 && x2.constructor.prototype.isHelp === true || false;
194902
+ }
194903
+ function isFunction$2(x2) {
194904
+ return typeof x2 === "function";
194905
+ }
194906
+ function isDate$2(x2) {
194907
+ return x2 instanceof Date;
194908
+ }
194909
+ function isRegExp$1(x2) {
194910
+ return x2 instanceof RegExp;
194911
+ }
194912
+ function isObject$1(x2) {
194913
+ return !!(x2 && typeof x2 === "object" && x2.constructor === Object && !isComplex(x2) && !isFraction(x2));
194914
+ }
194915
+ function isNull(x2) {
194916
+ return x2 === null;
194917
+ }
194918
+ function isUndefined(x2) {
194919
+ return x2 === void 0;
194920
+ }
194921
+ function isAccessorNode(x2) {
194922
+ return x2 && x2.isAccessorNode === true && x2.constructor.prototype.isNode === true || false;
194923
+ }
194924
+ function isArrayNode(x2) {
194925
+ return x2 && x2.isArrayNode === true && x2.constructor.prototype.isNode === true || false;
194926
+ }
194927
+ function isAssignmentNode(x2) {
194928
+ return x2 && x2.isAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
194929
+ }
194930
+ function isBlockNode(x2) {
194931
+ return x2 && x2.isBlockNode === true && x2.constructor.prototype.isNode === true || false;
194932
+ }
194933
+ function isConditionalNode(x2) {
194934
+ return x2 && x2.isConditionalNode === true && x2.constructor.prototype.isNode === true || false;
194935
+ }
194936
+ function isConstantNode(x2) {
194937
+ return x2 && x2.isConstantNode === true && x2.constructor.prototype.isNode === true || false;
194938
+ }
194939
+ function isFunctionAssignmentNode(x2) {
194940
+ return x2 && x2.isFunctionAssignmentNode === true && x2.constructor.prototype.isNode === true || false;
194941
+ }
194942
+ function isFunctionNode(x2) {
194943
+ return x2 && x2.isFunctionNode === true && x2.constructor.prototype.isNode === true || false;
194944
+ }
194945
+ function isIndexNode(x2) {
194946
+ return x2 && x2.isIndexNode === true && x2.constructor.prototype.isNode === true || false;
194947
+ }
194948
+ function isNode(x2) {
194949
+ return x2 && x2.isNode === true && x2.constructor.prototype.isNode === true || false;
194950
+ }
194951
+ function isObjectNode(x2) {
194952
+ return x2 && x2.isObjectNode === true && x2.constructor.prototype.isNode === true || false;
194953
+ }
194954
+ function isOperatorNode(x2) {
194955
+ return x2 && x2.isOperatorNode === true && x2.constructor.prototype.isNode === true || false;
194956
+ }
194957
+ function isParenthesisNode(x2) {
194958
+ return x2 && x2.isParenthesisNode === true && x2.constructor.prototype.isNode === true || false;
194959
+ }
194960
+ function isRangeNode(x2) {
194961
+ return x2 && x2.isRangeNode === true && x2.constructor.prototype.isNode === true || false;
194962
+ }
194963
+ function isSymbolNode(x2) {
194964
+ return x2 && x2.isSymbolNode === true && x2.constructor.prototype.isNode === true || false;
194965
+ }
194966
+ function isChain(x2) {
194967
+ return x2 && x2.constructor.prototype.isChain === true || false;
194968
+ }
194969
+ function typeOf(x2) {
194970
+ var t4 = typeof x2;
194971
+ if (t4 === "object") {
194972
+ if (x2 === null)
194973
+ return "null";
194974
+ if (Array.isArray(x2))
194975
+ return "Array";
194976
+ if (x2 instanceof Date)
194977
+ return "Date";
194978
+ if (x2 instanceof RegExp)
194979
+ return "RegExp";
194980
+ if (isBigNumber(x2))
194981
+ return "BigNumber";
194982
+ if (isComplex(x2))
194983
+ return "Complex";
194984
+ if (isFraction(x2))
194985
+ return "Fraction";
194986
+ if (isMatrix(x2))
194987
+ return "Matrix";
194988
+ if (isUnit(x2))
194989
+ return "Unit";
194990
+ if (isIndex(x2))
194991
+ return "Index";
194992
+ if (isRange(x2))
194993
+ return "Range";
194994
+ if (isResultSet(x2))
194995
+ return "ResultSet";
194996
+ if (isNode(x2))
194997
+ return x2.type;
194998
+ if (isChain(x2))
194999
+ return "Chain";
195000
+ if (isHelp(x2))
195001
+ return "Help";
195002
+ return "Object";
195003
+ }
195004
+ if (t4 === "function")
195005
+ return "Function";
195006
+ return t4;
195007
+ }
195008
+ function clone$2(x2) {
195009
+ var type3 = typeof x2;
195010
+ if (type3 === "number" || type3 === "string" || type3 === "boolean" || x2 === null || x2 === void 0) {
195011
+ return x2;
195012
+ }
195013
+ if (typeof x2.clone === "function") {
195014
+ return x2.clone();
195015
+ }
195016
+ if (Array.isArray(x2)) {
195017
+ return x2.map(function(value2) {
195018
+ return clone$2(value2);
195019
+ });
195020
+ }
195021
+ if (x2 instanceof Date)
195022
+ return new Date(x2.valueOf());
195023
+ if (isBigNumber(x2))
195024
+ return x2;
195025
+ if (x2 instanceof RegExp)
195026
+ throw new TypeError("Cannot clone " + x2);
195027
+ return mapObject(x2, clone$2);
195028
+ }
195029
+ function mapObject(object2, callback) {
195030
+ var clone3 = {};
195031
+ for (var key2 in object2) {
195032
+ if (hasOwnProperty$2(object2, key2)) {
195033
+ clone3[key2] = callback(object2[key2]);
195034
+ }
195035
+ }
195036
+ return clone3;
195037
+ }
195038
+ function extend$2(a2, b2) {
195039
+ for (var prop in b2) {
195040
+ if (hasOwnProperty$2(b2, prop)) {
195041
+ a2[prop] = b2[prop];
195042
+ }
195043
+ }
195044
+ return a2;
195045
+ }
195046
+ function deepStrictEqual(a2, b2) {
195047
+ var prop, i2, len2;
195048
+ if (Array.isArray(a2)) {
195049
+ if (!Array.isArray(b2)) {
195050
+ return false;
195051
+ }
195052
+ if (a2.length !== b2.length) {
195053
+ return false;
195054
+ }
195055
+ for (i2 = 0, len2 = a2.length; i2 < len2; i2++) {
195056
+ if (!deepStrictEqual(a2[i2], b2[i2])) {
195057
+ return false;
195058
+ }
195059
+ }
195060
+ return true;
195061
+ } else if (typeof a2 === "function") {
195062
+ return a2 === b2;
195063
+ } else if (a2 instanceof Object) {
195064
+ if (Array.isArray(b2) || !(b2 instanceof Object)) {
195065
+ return false;
195066
+ }
195067
+ for (prop in a2) {
195068
+ if (!(prop in b2) || !deepStrictEqual(a2[prop], b2[prop])) {
195069
+ return false;
195070
+ }
195071
+ }
195072
+ for (prop in b2) {
195073
+ if (!(prop in a2)) {
195074
+ return false;
195075
+ }
195076
+ }
195077
+ return true;
195078
+ } else {
195079
+ return a2 === b2;
195080
+ }
195081
+ }
195082
+ function hasOwnProperty$2(object2, property2) {
195083
+ return object2 && Object.hasOwnProperty.call(object2, property2);
195084
+ }
195085
+ function pickShallow(object2, properties2) {
195086
+ var copy2 = {};
195087
+ for (var i2 = 0; i2 < properties2.length; i2++) {
195088
+ var key2 = properties2[i2];
195089
+ var value2 = object2[key2];
195090
+ if (value2 !== void 0) {
195091
+ copy2[key2] = value2;
195092
+ }
195093
+ }
195094
+ return copy2;
195095
+ }
195096
+ var MATRIX_OPTIONS = ["Matrix", "Array"];
195097
+ var NUMBER_OPTIONS = ["number", "BigNumber", "Fraction"];
195098
+ var config$1 = function config(options) {
195099
+ if (options) {
195100
+ 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");
195101
+ }
195102
+ return Object.freeze(DEFAULT_CONFIG);
195103
+ };
195104
+ _extendsExports(config$1, DEFAULT_CONFIG, {
195105
+ MATRIX_OPTIONS,
195106
+ NUMBER_OPTIONS
195107
+ });
195108
+ var typedFunction$1 = { exports: {} };
195109
+ (function(module2, exports) {
195110
+ (function(root2, factory2) {
195111
+ {
195112
+ module2.exports = factory2();
195113
+ }
195114
+ })(commonjsGlobal$1, function() {
195115
+ function ok() {
195116
+ return true;
195117
+ }
195118
+ function notOk() {
195119
+ return false;
195120
+ }
195121
+ function undef() {
195122
+ return void 0;
195123
+ }
195124
+ function create6() {
195125
+ var _types = [
195126
+ { name: "number", test: function(x2) {
195127
+ return typeof x2 === "number";
195128
+ } },
195129
+ { name: "string", test: function(x2) {
195130
+ return typeof x2 === "string";
195131
+ } },
195132
+ { name: "boolean", test: function(x2) {
195133
+ return typeof x2 === "boolean";
195134
+ } },
195135
+ { name: "Function", test: function(x2) {
195136
+ return typeof x2 === "function";
195137
+ } },
195138
+ { name: "Array", test: Array.isArray },
195139
+ { name: "Date", test: function(x2) {
195140
+ return x2 instanceof Date;
195141
+ } },
195142
+ { name: "RegExp", test: function(x2) {
195143
+ return x2 instanceof RegExp;
195144
+ } },
195145
+ { name: "Object", test: function(x2) {
195146
+ return typeof x2 === "object" && x2 !== null && x2.constructor === Object;
195147
+ } },
195148
+ { name: "null", test: function(x2) {
195149
+ return x2 === null;
195150
+ } },
195151
+ { name: "undefined", test: function(x2) {
195152
+ return x2 === void 0;
195153
+ } }
195154
+ ];
195155
+ var anyType = {
195156
+ name: "any",
195157
+ test: ok
195158
+ };
195159
+ var _ignore = [];
195160
+ var _conversions = [];
195161
+ var typed2 = {
195162
+ types: _types,
195163
+ conversions: _conversions,
195164
+ ignore: _ignore
195165
+ };
195166
+ function findTypeByName(typeName) {
195167
+ var entry2 = findInArray2(typed2.types, function(entry3) {
195168
+ return entry3.name === typeName;
195169
+ });
195170
+ if (entry2) {
195171
+ return entry2;
195172
+ }
195173
+ if (typeName === "any") {
195174
+ return anyType;
195175
+ }
195176
+ var hint2 = findInArray2(typed2.types, function(entry3) {
195177
+ return entry3.name.toLowerCase() === typeName.toLowerCase();
193984
195178
  });
193985
195179
  throw new TypeError('Unknown type "' + typeName + '"' + (hint2 ? '. Did you mean "' + hint2.name + '"?' : ""));
193986
195180
  }
@@ -197784,7 +198978,7 @@ function cbrt(x2) {
197784
198978
  function ceil$2(x2) {
197785
198979
  return finalise(x2 = new this(x2), x2.e + 1, 2);
197786
198980
  }
197787
- function clamp$2(x2, min2, max2) {
198981
+ function clamp$1(x2, min2, max2) {
197788
198982
  return new this(x2).clamp(min2, max2);
197789
198983
  }
197790
198984
  function config2(obj) {
@@ -197953,7 +199147,7 @@ function clone$1(obj) {
197953
199147
  Decimal2.atan2 = atan2$2;
197954
199148
  Decimal2.cbrt = cbrt;
197955
199149
  Decimal2.ceil = ceil$2;
197956
- Decimal2.clamp = clamp$2;
199150
+ Decimal2.clamp = clamp$1;
197957
199151
  Decimal2.cos = cos$3;
197958
199152
  Decimal2.cosh = cosh$1;
197959
199153
  Decimal2.div = div;
@@ -203210,11 +204404,11 @@ var createPow = /* @__PURE__ */ factory(name$g, dependencies$f, (_ref3) => {
203210
204404
  return matrix2(_powArray(x2.valueOf(), y2));
203211
204405
  }
203212
204406
  });
203213
- var defineProperty4 = { exports: {} };
204407
+ var defineProperty3 = { exports: {} };
203214
204408
  var hasRequiredDefineProperty;
203215
204409
  function requireDefineProperty() {
203216
204410
  if (hasRequiredDefineProperty)
203217
- return defineProperty4.exports;
204411
+ return defineProperty3.exports;
203218
204412
  hasRequiredDefineProperty = 1;
203219
204413
  (function(module2) {
203220
204414
  function _defineProperty3(obj, key2, value2) {
@@ -203231,8 +204425,8 @@ function requireDefineProperty() {
203231
204425
  return obj;
203232
204426
  }
203233
204427
  module2.exports = _defineProperty3, module2.exports.__esModule = true, module2.exports["default"] = module2.exports;
203234
- })(defineProperty4);
203235
- return defineProperty4.exports;
204428
+ })(defineProperty3);
204429
+ return defineProperty3.exports;
203236
204430
  }
203237
204431
  var definePropertyExports = requireDefineProperty();
203238
204432
  function ownKeys$3(object2, enumerableOnly) {
@@ -208370,1157 +209564,6 @@ async function initializeRasterLayersAndChannels(rasterLayers, rasterRenderLayer
208370
209564
  const autoImageLayerDefs = await Promise.all(autoImageLayerDefPromises);
208371
209565
  return [autoImageLayerDefs, nextImageLoaders, nextImageMetaAndLayers];
208372
209566
  }
208373
- const useStyles$8 = makeStyles(() => ({
208374
- tool: {
208375
- position: "absolute",
208376
- display: "inline",
208377
- zIndex: "1000",
208378
- opacity: ".65",
208379
- color: "black",
208380
- "&:hover": {
208381
- opacity: ".90"
208382
- }
208383
- },
208384
- iconButton: {
208385
- padding: "0",
208386
- height: "2em",
208387
- width: "2em",
208388
- backgroundColor: "white",
208389
- display: "inline-block",
208390
- fontWeight: "400",
208391
- textAlign: "center",
208392
- verticalAlign: "middle",
208393
- cursor: "pointer",
208394
- userSelect: "none",
208395
- border: "1px solid #6c757d",
208396
- fontSize: "1rem",
208397
- lineHeight: "1.5",
208398
- borderRadius: "0.25rem",
208399
- 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",
208400
- color: "#6c757d",
208401
- marginRight: "0.5rem",
208402
- "& > svg": {
208403
- verticalAlign: "middle"
208404
- }
208405
- },
208406
- iconButtonActive: {
208407
- color: "#fff",
208408
- backgroundColor: "#6c757d",
208409
- borderColor: "#6c757d",
208410
- boxShadow: "0 0 0 0.2rem rgba(108, 117, 125, 0.5)"
208411
- }
208412
- }));
208413
- function IconButton2(props2) {
208414
- const { alt, onClick, isActive: isActive2, children: children3 } = props2;
208415
- const classes = useStyles$8();
208416
- return jsx("button", { className: clsx(classes.iconButton, { [classes.iconButtonActive]: isActive2 }), onClick, type: "button", title: alt, children: children3 });
208417
- }
208418
- function ToolMenu(props2) {
208419
- const { setActiveTool, activeTool, visibleTools = { pan: true, selectRectangle: true, selectLasso: true } } = props2;
208420
- const classes = useStyles$8();
208421
- return jsxs("div", { className: classes.tool, children: [visibleTools.pan && jsx(IconButton2, { alt: "pointer tool", onClick: () => setActiveTool(null), isActive: activeTool === null, children: jsx(SvgNearMe, {}) }), visibleTools.selectRectangle ? jsx(IconButton2, { alt: "select rectangle", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.RECTANGLE), isActive: activeTool === distEs6$2.SELECTION_TYPE.RECTANGLE, children: jsx(SvgSelectionRectangle, {}) }) : null, visibleTools.selectLasso ? jsx(IconButton2, { alt: "select lasso", onClick: () => setActiveTool(distEs6$2.SELECTION_TYPE.POLYGON), isActive: activeTool === distEs6$2.SELECTION_TYPE.POLYGON, children: jsx(SvgSelectionLasso, {}) }) : null] });
208422
- }
208423
- const getCursorWithTool = () => "crosshair";
208424
- const getCursor = (interactionState) => interactionState.isDragging ? "grabbing" : "default";
208425
- function getOnHoverCallback(obsIndex, setObsHighlight, setComponentHover) {
208426
- return (info2) => {
208427
- if (setComponentHover) {
208428
- setComponentHover();
208429
- }
208430
- if (info2.index) {
208431
- const obsId = obsIndex[info2.index];
208432
- if (setObsHighlight) {
208433
- setObsHighlight(obsId);
208434
- }
208435
- } else if (setObsHighlight) {
208436
- setObsHighlight(null);
208437
- }
208438
- };
208439
- }
208440
- class AbstractSpatialOrScatterplot extends PureComponent {
208441
- constructor(props2) {
208442
- super(props2);
208443
- this.state = {
208444
- gl: null,
208445
- tool: null
208446
- };
208447
- this.viewport = null;
208448
- this.onViewStateChange = this.onViewStateChange.bind(this);
208449
- this.onInitializeViewInfo = this.onInitializeViewInfo.bind(this);
208450
- this.onWebGLInitialized = this.onWebGLInitialized.bind(this);
208451
- this.onToolChange = this.onToolChange.bind(this);
208452
- this.onHover = this.onHover.bind(this);
208453
- }
208454
- onViewStateChange({ viewState: nextViewState }) {
208455
- const { setViewState, viewState, layers, spatialAxisFixed } = this.props;
208456
- const use3d = layers == null ? void 0 : layers.some((l2) => l2.use3d);
208457
- setViewState({
208458
- ...nextViewState,
208459
- target: spatialAxisFixed && use3d ? viewState.target : nextViewState.target
208460
- });
208461
- }
208462
- onInitializeViewInfo({ viewport }) {
208463
- this.viewport = viewport;
208464
- }
208465
- onWebGLInitialized(gl) {
208466
- this.setState({ gl });
208467
- }
208468
- onToolChange(tool) {
208469
- const { onToolChange: onToolChangeProp } = this.props;
208470
- this.setState({ tool });
208471
- if (onToolChangeProp) {
208472
- onToolChangeProp(tool);
208473
- }
208474
- }
208475
- getLayers() {
208476
- return [];
208477
- }
208478
- onHover(info2) {
208479
- const { coordinate, sourceLayer: layer, tile } = info2;
208480
- const { setCellHighlight, cellHighlight, setComponentHover, layers } = this.props;
208481
- const hasBitmask = (layers || []).some((l2) => l2.type === "bitmask");
208482
- if (!setCellHighlight || !tile) {
208483
- return null;
208484
- }
208485
- if (!layer || !coordinate) {
208486
- if (cellHighlight && hasBitmask) {
208487
- setCellHighlight(null);
208488
- }
208489
- return null;
208490
- }
208491
- const { content: content2, bbox: bbox2, z } = tile;
208492
- if (!content2) {
208493
- if (cellHighlight && hasBitmask) {
208494
- setCellHighlight(null);
208495
- }
208496
- return null;
208497
- }
208498
- const { data: data2, width: width2, height: height2 } = content2;
208499
- const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
208500
- const bounds2 = [
208501
- left2,
208502
- data2.height < layer.tileSize ? height2 : bottom2,
208503
- data2.width < layer.tileSize ? width2 : right2,
208504
- top2
208505
- ];
208506
- if (!data2) {
208507
- if (cellHighlight && hasBitmask) {
208508
- setCellHighlight(null);
208509
- }
208510
- return null;
208511
- }
208512
- if (layer.id.includes("bitmask")) {
208513
- const layerZoomScale = Math.max(1, 2 ** Math.round(-z));
208514
- const dataCoords = [
208515
- Math.floor((coordinate[0] - bounds2[0]) / layerZoomScale),
208516
- Math.floor((coordinate[1] - bounds2[3]) / layerZoomScale)
208517
- ];
208518
- const coords = dataCoords[1] * width2 + dataCoords[0];
208519
- const hoverData = data2.map((d) => d[coords]);
208520
- const cellId = hoverData.find((i2) => i2 > 0);
208521
- if (cellId !== Number(cellHighlight)) {
208522
- if (setComponentHover) {
208523
- setComponentHover();
208524
- }
208525
- setCellHighlight(cellId ? String(cellId) : null);
208526
- }
208527
- }
208528
- }
208529
- viewInfoDidUpdate(obsIndex, obsLocations, makeGetObsCoords) {
208530
- const { updateViewInfo, uuid } = this.props;
208531
- const { viewport } = this;
208532
- if (updateViewInfo && viewport) {
208533
- updateViewInfo({
208534
- uuid,
208535
- project: (obsId) => {
208536
- try {
208537
- if (obsIndex && obsLocations) {
208538
- const getObsCoords = makeGetObsCoords(obsLocations);
208539
- const obsIdx = obsIndex.indexOf(obsId);
208540
- const obsCoord = getObsCoords(obsIdx);
208541
- return viewport.project(obsCoord);
208542
- }
208543
- return [null, null];
208544
- } catch (e3) {
208545
- return [null, null];
208546
- }
208547
- }
208548
- });
208549
- }
208550
- }
208551
- componentDidUpdate() {
208552
- }
208553
- use3d() {
208554
- return false;
208555
- }
208556
- render() {
208557
- var _a3, _b2, _c, _d;
208558
- const { deckRef, viewState, uuid, hideTools } = this.props;
208559
- const { gl, tool } = this.state;
208560
- const layers = this.getLayers();
208561
- const use3d = this.use3d();
208562
- const showCellSelectionTools = this.obsSegmentationsData !== null;
208563
- const showPanTool = layers.length > 0;
208564
- 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);
208565
- return jsxs(Fragment, { children: [jsx(ToolMenu, { activeTool: tool, setActiveTool: this.onToolChange, visibleTools: {
208566
- pan: showPanTool && !hideTools,
208567
- selectRectangle: showCellSelectionTools && !hideTools,
208568
- selectLasso: showCellSelectionTools && !hideTools
208569
- } }), jsx(DeckGL$1, { id: `deckgl-overlay-${uuid}`, ref: deckRef, views: [
208570
- use3d ? new OrbitView({ id: "orbit", controller: true, orbitAxis: "Y" }) : new OrthographicView({
208571
- id: "ortho"
208572
- })
208573
- ], 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 })] });
208574
- }
208575
- }
208576
- function createQuadTree(obsEmbedding, getCellCoords) {
208577
- if (!obsEmbedding) {
208578
- return null;
208579
- }
208580
- const tree2 = quadtree$1().x((i2) => getCellCoords(i2)[0]).y((i2) => getCellCoords(i2)[1]).addAll(range_1(obsEmbedding.shape[1]));
208581
- return tree2;
208582
- }
208583
- function constant$5(v) {
208584
- return () => v;
208585
- }
208586
- function jiggle$1(v) {
208587
- return v + (Math.random() - 0.5) * 1e-6;
208588
- }
208589
- function forceCollideRects() {
208590
- let nodes;
208591
- let masses;
208592
- let strength = 1;
208593
- let iterations2 = 1;
208594
- let sizes;
208595
- let size2 = constant$5([0, 0]);
208596
- function xCenter(d) {
208597
- return d.x + d.vx + sizes[d.index][0] / 2;
208598
- }
208599
- function yCenter(d) {
208600
- return d.y + d.vy + sizes[d.index][1] / 2;
208601
- }
208602
- function prepare2(quad2) {
208603
- if (quad2.data) {
208604
- quad2.size = sizes[quad2.data.index];
208605
- } else {
208606
- quad2.size = [0, 0];
208607
- for (let i2 = 0; i2 < 4; i2++) {
208608
- if (quad2[i2] && quad2[i2].size) {
208609
- quad2.size[0] = Math.max(quad2.size[0], quad2[i2].size[0]);
208610
- quad2.size[1] = Math.max(quad2.size[1], quad2[i2].size[1]);
208611
- }
208612
- }
208613
- }
208614
- }
208615
- function force2() {
208616
- let node;
208617
- let nodeSize;
208618
- let nodeMass;
208619
- let xi;
208620
- let yi;
208621
- const tree2 = quadtree$1(nodes, xCenter, yCenter).visitAfter(prepare2);
208622
- function apply2(quad2, x02, y02, x12, y12) {
208623
- const { data: data2 } = quad2;
208624
- const xSize = (nodeSize[0] + quad2.size[0]) / 2;
208625
- const ySize = (nodeSize[1] + quad2.size[1]) / 2;
208626
- if (data2 && data2.index > node.index) {
208627
- let x2 = jiggle$1(xi - xCenter(data2));
208628
- let y2 = jiggle$1(yi - yCenter(data2));
208629
- const xd = Math.abs(x2) - xSize;
208630
- const yd = Math.abs(y2) - ySize;
208631
- if (xd < 0 && yd < 0) {
208632
- const l2 = Math.sqrt(x2 * x2 + y2 * y2);
208633
- const m2 = masses[data2.index] / (nodeMass + masses[data2.index]);
208634
- if (Math.abs(xd) < Math.abs(yd)) {
208635
- node.vx -= (x2 *= xd / l2 * strength) * m2;
208636
- data2.vx += x2 * (1 - m2);
208637
- } else {
208638
- node.vy -= (y2 *= yd / l2 * strength) * m2;
208639
- data2.vy += y2 * (1 - m2);
208640
- }
208641
- }
208642
- return x02 > xi + xSize || x12 < xi - xSize || y02 > yi + ySize || y12 < yi - ySize;
208643
- }
208644
- return false;
208645
- }
208646
- function iterate2() {
208647
- for (let j = 0; j < nodes.length; j++) {
208648
- node = nodes[j];
208649
- nodeSize = sizes[j];
208650
- nodeMass = masses[j];
208651
- xi = xCenter(node);
208652
- yi = yCenter(node);
208653
- tree2.visit(apply2);
208654
- }
208655
- }
208656
- for (let i2 = 0; i2 < iterations2; i2++) {
208657
- iterate2();
208658
- }
208659
- }
208660
- force2.initialize = (v) => {
208661
- nodes = v;
208662
- sizes = nodes.map(size2);
208663
- masses = sizes.map((d) => d[0] + d[1]);
208664
- };
208665
- force2.iterations = (...v) => {
208666
- if (v.length) {
208667
- iterations2 = +v[0];
208668
- return force2;
208669
- }
208670
- return iterations2;
208671
- };
208672
- force2.strength = (...v) => {
208673
- if (v.length) {
208674
- strength = +v[0];
208675
- return force2;
208676
- }
208677
- return strength;
208678
- };
208679
- force2.size = (...v) => {
208680
- if (v.length) {
208681
- size2 = typeof v[0] === "function" ? v[0] : constant$5(v[0]);
208682
- return force2;
208683
- }
208684
- return size2;
208685
- };
208686
- return force2;
208687
- }
208688
- function baseClamp$1(number2, lower, upper) {
208689
- if (number2 === number2) {
208690
- if (upper !== void 0) {
208691
- number2 = number2 <= upper ? number2 : upper;
208692
- }
208693
- if (lower !== void 0) {
208694
- number2 = number2 >= lower ? number2 : lower;
208695
- }
208696
- }
208697
- return number2;
208698
- }
208699
- var _baseClamp = baseClamp$1;
208700
- var baseClamp = _baseClamp, toNumber$1 = toNumber_1$1;
208701
- function clamp$1(number2, lower, upper) {
208702
- if (upper === void 0) {
208703
- upper = lower;
208704
- lower = void 0;
208705
- }
208706
- if (upper !== void 0) {
208707
- upper = toNumber$1(upper);
208708
- upper = upper === upper ? upper : 0;
208709
- }
208710
- if (lower !== void 0) {
208711
- lower = toNumber$1(lower);
208712
- lower = lower === lower ? lower : 0;
208713
- }
208714
- return baseClamp(toNumber$1(number2), lower, upper);
208715
- }
208716
- var clamp_1 = clamp$1;
208717
- function getPointSizeDevicePixels(devicePixelRatio2, zoom2, xRange, yRange, width2, height2) {
208718
- const pointSize = 5e-4;
208719
- const pointScreenSizeMax = 10;
208720
- const pointScreenSizeMin = 1 / devicePixelRatio2;
208721
- const scaleFactor = 2 ** zoom2;
208722
- const xAxisRange = 2 / (xRange * scaleFactor / width2);
208723
- const yAxisRange = 2 / (yRange * scaleFactor / height2);
208724
- const diagonalScreenSize = Math.sqrt(width2 ** 2 + height2 ** 2);
208725
- const diagonalAxisRange = Math.sqrt(xAxisRange ** 2 + yAxisRange ** 2);
208726
- const diagonalFraction = pointSize / diagonalAxisRange;
208727
- const deviceSize = diagonalFraction * diagonalScreenSize;
208728
- const pointSizeDevicePixels = clamp_1(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
208729
- return pointSizeDevicePixels;
208730
- }
208731
- function getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, avgFillDensity) {
208732
- const N2 = numCells;
208733
- const [minX, minY, maxX, maxY2] = new OrthographicView({ zoom: zoom2 }).makeViewport({
208734
- height: height2,
208735
- width: width2,
208736
- viewState: { zoom: zoom2, target: [0, 0, 0] }
208737
- }).getBounds();
208738
- const X3 = maxY2 - minY;
208739
- const Y3 = maxX - minX;
208740
- const X02 = xRange;
208741
- const Y02 = yRange;
208742
- const W = width2;
208743
- const H = height2;
208744
- let rho = avgFillDensity;
208745
- if (!rho) {
208746
- rho = Math.min(1, 1 / 10 ** (Math.log10(N2) - 3));
208747
- }
208748
- const alpha2 = rho * W * H / N2 * (Y02 / Y3) * (X02 / X3);
208749
- const pointOpacity = clamp_1(alpha2, 1.01 / 255, 1);
208750
- return pointOpacity;
208751
- }
208752
- const CELLS_LAYER_ID$1 = "scatterplot";
208753
- const LABEL_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
208754
- const NUM_FORCE_SIMULATION_TICKS = 100;
208755
- const LABEL_UPDATE_ZOOM_DELTA = 0.25;
208756
- const makeDefaultGetCellColors$1 = (cellColors, obsIndex, theme) => (object2, { index: index2 }) => {
208757
- const [r3, g2, b2, a2] = cellColors && obsIndex && cellColors.get(obsIndex[index2]) || getDefaultColor(theme);
208758
- return [r3, g2, b2, 255 * (a2 || 1)];
208759
- };
208760
- const makeDefaultGetObsCoords$1 = (obsEmbedding) => (i2) => [
208761
- obsEmbedding.data[0][i2],
208762
- obsEmbedding.data[1][i2],
208763
- 0
208764
- ];
208765
- const makeFlippedGetObsCoords = (obsEmbedding) => (i2) => [
208766
- obsEmbedding.data[0][i2],
208767
- -obsEmbedding.data[1][i2],
208768
- 0
208769
- ];
208770
- const getPosition = (object2, { index: index2, data: data2, target: target2 }) => {
208771
- target2[0] = data2.src.obsEmbedding.data[0][index2];
208772
- target2[1] = -data2.src.obsEmbedding.data[1][index2];
208773
- target2[2] = 0;
208774
- return target2;
208775
- };
208776
- class Scatterplot extends AbstractSpatialOrScatterplot {
208777
- constructor(props2) {
208778
- super(props2);
208779
- this.cellsQuadTree = null;
208780
- this.cellsLayer = null;
208781
- this.cellsData = null;
208782
- this.cellSetsForceSimulation = forceCollideRects();
208783
- this.cellSetsLabelPrevZoom = null;
208784
- this.cellSetsLayers = [];
208785
- this.onUpdateCellsData();
208786
- this.onUpdateCellsLayer();
208787
- this.onUpdateCellSetsLayers();
208788
- }
208789
- createCellsLayer() {
208790
- const {
208791
- obsEmbeddingIndex: obsIndex,
208792
- theme,
208793
- cellRadius = 1,
208794
- cellOpacity = 1,
208795
- cellSelection,
208796
- setCellHighlight,
208797
- setComponentHover,
208798
- getCellIsSelected,
208799
- cellColors,
208800
- getCellColor = makeDefaultGetCellColors$1(cellColors, obsIndex, theme),
208801
- getExpressionValue,
208802
- onCellClick,
208803
- geneExpressionColormap,
208804
- geneExpressionColormapRange = [0, 1],
208805
- cellColorEncoding
208806
- } = this.props;
208807
- return new ScatterplotLayer({
208808
- id: CELLS_LAYER_ID$1,
208809
- data: this.cellsData,
208810
- coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
208811
- visible: true,
208812
- pickable: true,
208813
- autoHighlight: true,
208814
- filled: true,
208815
- stroked: true,
208816
- backgroundColor: theme === "dark" ? [0, 0, 0] : [241, 241, 241],
208817
- getCellIsSelected,
208818
- opacity: cellOpacity,
208819
- radiusScale: cellRadius,
208820
- radiusMinPixels: 1,
208821
- radiusMaxPixels: 30,
208822
- radiusUnits: "pixels",
208823
- lineWidthUnits: "pixels",
208824
- getPosition,
208825
- getFillColor: getCellColor,
208826
- getLineColor: getCellColor,
208827
- getRadius: 1,
208828
- getExpressionValue,
208829
- getLineWidth: 0,
208830
- extensions: [
208831
- new ScaledExpressionExtension(),
208832
- new SelectionExtension({ instanced: true })
208833
- ],
208834
- colorScaleLo: geneExpressionColormapRange[0],
208835
- colorScaleHi: geneExpressionColormapRange[1],
208836
- isExpressionMode: cellColorEncoding === "geneSelection",
208837
- colormap: geneExpressionColormap,
208838
- onClick: (info2) => {
208839
- if (onCellClick) {
208840
- onCellClick(info2);
208841
- }
208842
- },
208843
- onHover: getOnHoverCallback(obsIndex, setCellHighlight, setComponentHover),
208844
- updateTriggers: {
208845
- getExpressionValue,
208846
- getFillColor: [cellColorEncoding, cellSelection, cellColors],
208847
- getLineColor: [cellColorEncoding, cellSelection, cellColors],
208848
- getCellIsSelected
208849
- }
208850
- });
208851
- }
208852
- createCellSetsLayers() {
208853
- const { theme, cellSetPolygons, viewState, cellSetPolygonsVisible, cellSetLabelsVisible, cellSetLabelSize } = this.props;
208854
- const result = [];
208855
- if (cellSetPolygonsVisible) {
208856
- result.push(new PolygonLayer({
208857
- id: "cell-sets-polygon-layer",
208858
- data: cellSetPolygons,
208859
- stroked: true,
208860
- filled: false,
208861
- wireframe: true,
208862
- lineWidthMaxPixels: 1,
208863
- getPolygon: (d) => d.hull,
208864
- getLineColor: (d) => d.color,
208865
- getLineWidth: 1
208866
- }));
208867
- }
208868
- if (cellSetLabelsVisible) {
208869
- const { zoom: zoom2 } = viewState;
208870
- const nodes = cellSetPolygons.map((p) => ({
208871
- x: p.centroid[0],
208872
- y: p.centroid[1],
208873
- label: p.name
208874
- }));
208875
- const collisionForce = this.cellSetsForceSimulation.size((d) => [
208876
- cellSetLabelSize * 1 / 2 ** zoom2 * 4 * d.label.length,
208877
- cellSetLabelSize * 1 / 2 ** zoom2 * 1.5
208878
- ]);
208879
- forceSimulation$1().nodes(nodes).force("collision", collisionForce).tick(NUM_FORCE_SIMULATION_TICKS);
208880
- result.push(new TextLayer({
208881
- id: "cell-sets-text-layer",
208882
- data: nodes,
208883
- getPosition: (d) => [d.x, d.y],
208884
- getText: (d) => d.label,
208885
- getColor: theme === "dark" ? [255, 255, 255] : [0, 0, 0],
208886
- getSize: cellSetLabelSize,
208887
- getAngle: 0,
208888
- getTextAnchor: "middle",
208889
- getAlignmentBaseline: "center",
208890
- fontFamily: LABEL_FONT_FAMILY,
208891
- fontWeight: "normal"
208892
- }));
208893
- }
208894
- return result;
208895
- }
208896
- createSelectionLayers() {
208897
- const { obsEmbeddingIndex: obsIndex, obsEmbedding, viewState, setCellSelection } = this.props;
208898
- const { tool } = this.state;
208899
- const { cellsQuadTree } = this;
208900
- const flipYTooltip = true;
208901
- const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
208902
- return getSelectionLayers(tool, viewState.zoom, CELLS_LAYER_ID$1, getCellCoords, obsIndex, setCellSelection, cellsQuadTree, flipYTooltip);
208903
- }
208904
- getLayers() {
208905
- const { cellsLayer, cellSetsLayers } = this;
208906
- return [
208907
- cellsLayer,
208908
- ...cellSetsLayers,
208909
- ...this.createSelectionLayers()
208910
- ];
208911
- }
208912
- onUpdateCellsData() {
208913
- const { obsEmbedding } = this.props;
208914
- if (obsEmbedding) {
208915
- const getCellCoords = makeDefaultGetObsCoords$1(obsEmbedding);
208916
- this.cellsQuadTree = createQuadTree(obsEmbedding, getCellCoords);
208917
- this.cellsData = {
208918
- src: {
208919
- obsEmbedding
208920
- },
208921
- length: obsEmbedding.shape[1]
208922
- };
208923
- }
208924
- }
208925
- onUpdateCellsLayer() {
208926
- const { obsEmbeddingIndex, obsEmbedding } = this.props;
208927
- if (obsEmbeddingIndex && obsEmbedding) {
208928
- this.cellsLayer = this.createCellsLayer();
208929
- } else {
208930
- this.cellsLayer = null;
208931
- }
208932
- }
208933
- onUpdateCellSetsLayers(onlyViewStateChange) {
208934
- if (onlyViewStateChange) {
208935
- const { viewState, cellSetLabelsVisible } = this.props;
208936
- const { zoom: zoom2 } = viewState;
208937
- const { cellSetsLabelPrevZoom } = this;
208938
- if (cellSetLabelsVisible && (cellSetsLabelPrevZoom === null || Math.abs(cellSetsLabelPrevZoom - zoom2) > LABEL_UPDATE_ZOOM_DELTA)) {
208939
- this.cellSetsLayers = this.createCellSetsLayers();
208940
- this.cellSetsLabelPrevZoom = zoom2;
208941
- }
208942
- } else {
208943
- this.cellSetsLayers = this.createCellSetsLayers();
208944
- }
208945
- }
208946
- viewInfoDidUpdate() {
208947
- const { obsEmbeddingIndex, obsEmbedding } = this.props;
208948
- super.viewInfoDidUpdate(obsEmbeddingIndex, obsEmbedding, makeFlippedGetObsCoords);
208949
- }
208950
- componentDidUpdate(prevProps) {
208951
- this.viewInfoDidUpdate();
208952
- const shallowDiff = (propName) => prevProps[propName] !== this.props[propName];
208953
- let forceUpdate = false;
208954
- if (["obsEmbedding"].some(shallowDiff)) {
208955
- this.onUpdateCellsData();
208956
- forceUpdate = true;
208957
- }
208958
- if ([
208959
- "obsEmbeddingIndex",
208960
- "obsEmbedding",
208961
- "cellFilter",
208962
- "cellSelection",
208963
- "cellColors",
208964
- "cellRadius",
208965
- "cellOpacity",
208966
- "cellRadiusMode",
208967
- "geneExpressionColormap",
208968
- "geneExpressionColormapRange",
208969
- "geneSelection",
208970
- "cellColorEncoding"
208971
- ].some(shallowDiff)) {
208972
- this.onUpdateCellsLayer();
208973
- forceUpdate = true;
208974
- }
208975
- if ([
208976
- "cellSetPolygons",
208977
- "cellSetPolygonsVisible",
208978
- "cellSetLabelsVisible",
208979
- "cellSetLabelSize"
208980
- ].some(shallowDiff)) {
208981
- this.onUpdateCellSetsLayers(false);
208982
- forceUpdate = true;
208983
- }
208984
- if (shallowDiff("viewState")) {
208985
- this.onUpdateCellSetsLayers(true);
208986
- forceUpdate = true;
208987
- }
208988
- if (forceUpdate) {
208989
- this.forceUpdate();
208990
- }
208991
- }
208992
- }
208993
- const ScatterplotWrapper = forwardRef((props2, deckRef) => jsx(Scatterplot, { ...props2, deckRef }));
208994
- function ScatterplotOptions(props2) {
208995
- const { children: children3, observationsLabel, cellRadius, setCellRadius, cellRadiusMode, setCellRadiusMode, cellOpacity, setCellOpacity, cellOpacityMode, setCellOpacityMode, cellSetLabelsVisible, setCellSetLabelsVisible, cellSetLabelSize, setCellSetLabelSize, cellSetPolygonsVisible, setCellSetPolygonsVisible, cellColorEncoding, setCellColorEncoding, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange } = props2;
208996
- const observationsLabelNice = capitalize$2(observationsLabel);
208997
- const classes = useStyles$b();
208998
- function handleCellRadiusModeChange(event2) {
208999
- setCellRadiusMode(event2.target.value);
209000
- }
209001
- function handleCellOpacityModeChange(event2) {
209002
- setCellOpacityMode(event2.target.value);
209003
- }
209004
- function handleRadiusChange(event2, value2) {
209005
- setCellRadius(value2);
209006
- }
209007
- function handleOpacityChange(event2, value2) {
209008
- setCellOpacity(value2);
209009
- }
209010
- function handleLabelVisibilityChange(event2) {
209011
- setCellSetLabelsVisible(event2.target.checked);
209012
- }
209013
- function handleLabelSizeChange(event2, value2) {
209014
- setCellSetLabelSize(value2);
209015
- }
209016
- function handlePolygonVisibilityChange(event2) {
209017
- setCellSetPolygonsVisible(event2.target.checked);
209018
- }
209019
- function handleGeneExpressionColormapChange(event2) {
209020
- setGeneExpressionColormap(event2.target.value);
209021
- }
209022
- function handleColormapRangeChange(event2, value2) {
209023
- setGeneExpressionColormapRange(value2);
209024
- }
209025
- const handleColormapRangeChangeDebounced = useCallback(debounce_1$1(handleColormapRangeChange, 5, { trailing: true }), [handleColormapRangeChange]);
209026
- return jsxs(OptionsContainer, { children: [children3, 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: {
209027
- id: "cell-radius-mode-select"
209028
- }, 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: {
209029
- id: "cell-opacity-mode-select"
209030
- }, 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: {
209031
- id: "gene-expression-colormap-select"
209032
- }, 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 }) })] })] });
209033
- }
209034
- const styles34 = makeStyles(() => ({
209035
- tooltipAnchor: {
209036
- position: "relative",
209037
- width: "0px",
209038
- height: "0px",
209039
- pointerEvents: "none",
209040
- userSelect: "none"
209041
- },
209042
- tooltipContent: {
209043
- opacity: 0.9,
209044
- padding: "5px",
209045
- pointerEvents: "none",
209046
- "& table > tbody > tr > th, & table > tbody > tr > td": {
209047
- fontSize: "80%",
209048
- opacity: 0.8,
209049
- outline: 0,
209050
- padding: "0 2px"
209051
- },
209052
- "& table": {
209053
- borderCollapse: "collapse"
209054
- }
209055
- }
209056
- }));
209057
- function Tooltip2(props2) {
209058
- const { x: x2, y: y2, parentWidth, parentHeight, children: children3 } = props2;
209059
- const ref2 = useRef();
209060
- const classes = styles34();
209061
- const [placementX, setPlacementX] = useState("start");
209062
- const [placementY, setPlacementY] = useState("bottom");
209063
- const getTooltipContainer = useVitessceContainer(ref2);
209064
- useEffect(() => {
209065
- if (ref2 && ref2.current) {
209066
- const flipX = x2 > parentWidth / 2;
209067
- const flipY = y2 > parentHeight / 2;
209068
- setPlacementX(flipX ? "end" : "start");
209069
- setPlacementY(flipY ? "top" : "bottom");
209070
- ref2.current.style.left = `${x2 + (flipX ? -20 : 5)}px`;
209071
- ref2.current.style.top = `${y2 + (flipY ? -20 : 5)}px`;
209072
- }
209073
- }, [x2, y2, parentWidth, parentHeight]);
209074
- 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: children3 }) }) : null });
209075
- }
209076
- function Tooltip2D(props2) {
209077
- const { parentUuid, sourceUuid, x: x2, y: y2, parentWidth, parentHeight, children: children3 } = props2;
209078
- if (x2 < 0 || x2 > parentWidth || y2 < 0 || y2 > parentHeight) {
209079
- return null;
209080
- }
209081
- const isTooltipVisible = parentUuid === sourceUuid;
209082
- const crosshairWidth = 1;
209083
- return jsx(Fragment, { children: isTooltipVisible ? jsx(Tooltip2, { x: x2, y: y2, parentWidth, parentHeight, children: children3 }) : jsxs(Fragment, { children: [x2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
209084
- left: `${x2 - crosshairWidth / 2}px`,
209085
- top: 0,
209086
- width: `${crosshairWidth}px`,
209087
- height: `${parentHeight}px`
209088
- } }) : null, y2 !== null ? jsx("div", { className: "cell-emphasis-crosshair", style: {
209089
- left: 0,
209090
- top: `${y2 - crosshairWidth / 2}px`,
209091
- width: `${parentWidth}px`,
209092
- height: `${crosshairWidth}px`
209093
- } }) : null] }) });
209094
- }
209095
- function TooltipContent(props2) {
209096
- const { info: info2 } = props2;
209097
- 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)) }) });
209098
- }
209099
- function ScatterplotTooltipSubscriber(props2) {
209100
- const { parentUuid, obsHighlight, width: width2, height: height2, getObsInfo } = props2;
209101
- const sourceUuid = useComponentHover();
209102
- const viewInfo = useComponentViewInfo(parentUuid);
209103
- const [cellInfo, x2, y2] = obsHighlight && getObsInfo ? [
209104
- getObsInfo(obsHighlight),
209105
- ...viewInfo && viewInfo.project ? viewInfo.project(obsHighlight) : [null, null]
209106
- ] : [null, null, null];
209107
- return cellInfo ? jsx(Tooltip2D, { x: x2, y: y2, parentUuid, sourceUuid, parentWidth: width2, parentHeight: height2, children: jsx(TooltipContent, { info: cellInfo }) }) : null;
209108
- }
209109
- function EmptyMessage(props2) {
209110
- const { visible, message } = props2;
209111
- return visible ? jsx("div", { children: message }) : null;
209112
- }
209113
- function EmbeddingScatterplotSubscriber(props2) {
209114
- const {
209115
- uuid,
209116
- coordinationScopes,
209117
- removeGridComponent,
209118
- theme,
209119
- disableTooltip = false,
209120
- observationsLabelOverride,
209121
- title: titleOverride,
209122
- averageFillDensity
209123
- } = props2;
209124
- const loaders = useLoaders();
209125
- const setComponentHover = useSetComponentHover();
209126
- const setComponentViewInfo = useSetComponentViewInfo(uuid);
209127
- 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);
209128
- const observationsLabel = observationsLabelOverride || obsType;
209129
- const [urls2, addUrl2] = useUrls(loaders, dataset);
209130
- const [width2, height2, deckRef] = useDeckCanvasSize();
209131
- const title2 = titleOverride || `Scatterplot (${mapping})`;
209132
- const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
209133
- const [{ obsIndex: obsEmbeddingIndex, obsEmbedding }, obsEmbeddingStatus] = useObsEmbeddingData(loaders, dataset, addUrl2, true, {}, {}, { obsType, embeddingType: mapping });
209134
- const cellsCount = (obsEmbeddingIndex == null ? void 0 : obsEmbeddingIndex.length) || 0;
209135
- const [{ obsSets: cellSets, obsSetsMembership }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
209136
- const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
209137
- const [{ obsIndex: matrixObsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
209138
- const isReady = useReady([
209139
- obsEmbeddingStatus,
209140
- obsSetsStatus,
209141
- featureSelectionStatus,
209142
- matrixIndicesStatus
209143
- ]);
209144
- const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
209145
- const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
209146
- const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
209147
- const setCellSelectionProp = useCallback((v) => {
209148
- setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
209149
- }, [
209150
- additionalCellSets,
209151
- cellSetColor,
209152
- setCellColorEncoding,
209153
- setAdditionalCellSets,
209154
- setCellSetColor,
209155
- setCellSetSelection
209156
- ]);
209157
- const cellColors = useMemo(() => getCellColors({
209158
- cellColorEncoding,
209159
- expressionData: expressionData && expressionData[0],
209160
- geneSelection,
209161
- cellSets: mergedCellSets,
209162
- cellSetSelection,
209163
- cellSetColor,
209164
- obsIndex: matrixObsIndex,
209165
- theme
209166
- }), [
209167
- cellColorEncoding,
209168
- geneSelection,
209169
- mergedCellSets,
209170
- theme,
209171
- cellSetSelection,
209172
- cellSetColor,
209173
- expressionData,
209174
- matrixObsIndex
209175
- ]);
209176
- const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
209177
- const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
209178
- const cacheGet = (cache2, key2) => {
209179
- var _a3;
209180
- return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
209181
- };
209182
- const cellSetPolygons = useMemo(() => {
209183
- var _a3;
209184
- 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)) {
209185
- const newCellSetPolygons = getCellSetPolygons({
209186
- obsIndex: obsEmbeddingIndex,
209187
- obsEmbedding,
209188
- cellSets: mergedCellSets,
209189
- cellSetSelection,
209190
- cellSetColor,
209191
- theme
209192
- });
209193
- setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
209194
- return newCellSetPolygons;
209195
- }
209196
- return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
209197
- }, [
209198
- cellSetPolygonsVisible,
209199
- cellSetPolygonCache,
209200
- cellSetLabelsVisible,
209201
- theme,
209202
- obsEmbeddingIndex,
209203
- obsEmbedding,
209204
- mergedCellSets,
209205
- cellSetSelection,
209206
- cellSetColor
209207
- ]);
209208
- const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
209209
- const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
209210
- if (obsEmbedding && obsEmbedding.data && obsEmbedding.shape) {
209211
- const cellCount = obsEmbedding.shape[1];
209212
- const xE = extent$2(obsEmbedding.data[0]);
209213
- const yE = extent$2(obsEmbedding.data[1]);
209214
- const xR = xE[1] - xE[0];
209215
- const yR = yE[1] - yE[0];
209216
- return [xR, yR, xE, yE, cellCount];
209217
- }
209218
- return [null, null, null, null, null];
209219
- }, [obsEmbedding]);
209220
- useEffect(() => {
209221
- if (xRange && yRange) {
209222
- const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
209223
- setDynamicCellRadius(pointSizeDevicePixels);
209224
- const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
209225
- setDynamicCellOpacity(nextCellOpacityScale);
209226
- if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
209227
- const newTargetX = xExtent[0] + xRange / 2;
209228
- const newTargetY = yExtent[0] + yRange / 2;
209229
- const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
209230
- setTargetX(newTargetX);
209231
- setTargetY(-newTargetY);
209232
- setZoom(newZoom);
209233
- }
209234
- }
209235
- }, [
209236
- xRange,
209237
- yRange,
209238
- xExtent,
209239
- yExtent,
209240
- numCells,
209241
- width2,
209242
- height2,
209243
- zoom2,
209244
- averageFillDensity
209245
- ]);
209246
- const getObsInfo = useGetObsInfo(observationsLabel, obsLabelsTypes, obsLabelsData, obsSetsMembership);
209247
- const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
209248
- const getCellIsSelected = useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsEmbeddingIndex[index2]) ? 1 : 0, [cellSelectionSet, obsEmbeddingIndex]);
209249
- const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
209250
- const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
209251
- const getExpressionValue = useExpressionValueGetter({
209252
- instanceObsIndex: obsEmbeddingIndex,
209253
- matrixObsIndex,
209254
- expressionData
209255
- });
209256
- 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 }) => {
209257
- setZoom(newZoom);
209258
- setTargetX(target2[0]);
209259
- setTargetY(target2[1]);
209260
- setTargetZ(target2[2] || 0);
209261
- }, obsEmbeddingIndex, obsEmbedding, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
209262
- setComponentHover(uuid);
209263
- }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
209264
- }
209265
- function register$c() {
209266
- registerPluginViewType(ViewType$2.SCATTERPLOT, EmbeddingScatterplotSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.SCATTERPLOT]);
209267
- }
209268
- function GatingScatterplotOptions(props2) {
209269
- const { featureType, gatingFeatureSelectionX, setGatingFeatureSelectionX, gatingFeatureSelectionY, setGatingFeatureSelectionY, gatingFeatureValueTransform, setGatingFeatureValueTransform, gatingFeatureValueTransformCoefficient, setGatingFeatureValueTransformCoefficient, geneSelectOptions, transformOptions } = props2;
209270
- const classes = useStyles$b();
209271
- const handleGeneSelectChange = (event2) => {
209272
- const { options } = event2.target;
209273
- const newValues = [];
209274
- for (let i2 = 0, l2 = options.length; i2 < l2; i2 += 1) {
209275
- if (options[i2].selected) {
209276
- newValues.push(options[i2].value);
209277
- }
209278
- }
209279
- if (newValues.length === 1 && gatingFeatureSelectionX && !gatingFeatureSelectionY && newValues[0] !== gatingFeatureSelectionX) {
209280
- setGatingFeatureSelectionY(newValues[0]);
209281
- } else if (newValues.length <= 2) {
209282
- setGatingFeatureSelectionX(newValues[0]);
209283
- setGatingFeatureSelectionY(newValues[1]);
209284
- }
209285
- };
209286
- const handleTransformChange = (event2) => {
209287
- setGatingFeatureValueTransform(event2.target.value === "" ? null : event2.target.value);
209288
- };
209289
- const handleTransformCoefficientChange = (event2) => {
209290
- const { value: value2 } = event2.target;
209291
- if (!value2) {
209292
- setGatingFeatureValueTransformCoefficient(value2);
209293
- } else {
209294
- const newCoefficient = Number(value2);
209295
- if (!Number.isNaN(newCoefficient) && newCoefficient >= 0) {
209296
- setGatingFeatureValueTransformCoefficient(value2);
209297
- }
209298
- }
209299
- };
209300
- 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: {
209301
- id: "scatterplot-gene-select"
209302
- }, 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: {
209303
- id: "scatterplot-transform-select"
209304
- }, 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: {
209305
- shrink: true
209306
- } }) })] }, "transform-coefficient-option-row")] });
209307
- }
209308
- function GatingSubscriber(props2) {
209309
- const {
209310
- uuid,
209311
- coordinationScopes,
209312
- removeGridComponent,
209313
- theme,
209314
- disableTooltip = false,
209315
- title: titleOverride,
209316
- averageFillDensity
209317
- } = props2;
209318
- const loaders = useLoaders();
209319
- const setComponentHover = useSetComponentHover();
209320
- const setComponentViewInfo = useSetComponentViewInfo(uuid);
209321
- 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);
209322
- const [urls2, addUrl2] = useUrls(loaders, dataset);
209323
- const [width2, height2, deckRef] = useDeckCanvasSize();
209324
- const title2 = useMemo(() => {
209325
- if (titleOverride) {
209326
- return titleOverride;
209327
- }
209328
- if (!(gatingFeatureSelectionX && gatingFeatureSelectionY)) {
209329
- return "Gating";
209330
- }
209331
- return `Gating (${gatingFeatureSelectionX} vs ${gatingFeatureSelectionY})`;
209332
- }, [titleOverride, gatingFeatureSelectionX, gatingFeatureSelectionY]);
209333
- const featureSelectionX = useMemo(() => gatingFeatureSelectionX ? [gatingFeatureSelectionX] : null, [gatingFeatureSelectionX]);
209334
- const featureSelectionY = useMemo(() => gatingFeatureSelectionY ? [gatingFeatureSelectionY] : null, [gatingFeatureSelectionY]);
209335
- const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, false, { setObsSetSelection: setCellSetSelection, setObsSetColor: setCellSetColor }, { obsSetSelection: cellSetSelection, obsSetColor: cellSetColor }, { obsType });
209336
- const [expressionDataColor, loadedColor, featureSelectionColorStatus] = useFeatureSelection(loaders, dataset, false, gatingFeatureSelectionColor, { obsType, featureType, featureValueType });
209337
- const [expressionDataX, loadedX, featureSelectionXStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionX, { obsType, featureType, featureValueType });
209338
- const [expressionDataY, loadedY, featureSelectionYStatus] = useFeatureSelection(loaders, dataset, false, featureSelectionY, { obsType, featureType, featureValueType });
209339
- const [{ obsIndex, featureIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
209340
- const cellsCount = (obsIndex == null ? void 0 : obsIndex.length) || 0;
209341
- const isReady = useReady([
209342
- obsSetsStatus,
209343
- featureSelectionColorStatus,
209344
- featureSelectionXStatus,
209345
- featureSelectionYStatus,
209346
- matrixIndicesStatus
209347
- ]);
209348
- const obsXY = useMemo(() => {
209349
- if (!(cellsCount && (expressionDataX == null ? void 0 : expressionDataX[0]) && (expressionDataY == null ? void 0 : expressionDataY[0]) && featureSelectionX && featureSelectionY)) {
209350
- return null;
209351
- }
209352
- let coefficient = 1;
209353
- const parsedTransformCoefficient = Number(featureValueTransformCoefficient);
209354
- if (!Number.isNaN(parsedTransformCoefficient) && parsedTransformCoefficient > 0) {
209355
- coefficient = parsedTransformCoefficient;
209356
- }
209357
- const transformFunction = getValueTransformFunction(featureValueTransform, coefficient);
209358
- const obsX = new Float32Array(cellsCount);
209359
- const obsY = new Float32Array(cellsCount);
209360
- for (let i2 = 0; i2 < cellsCount; i2 += 1) {
209361
- obsX[i2] = transformFunction(expressionDataX[0][i2]);
209362
- obsY[i2] = transformFunction(expressionDataY[0][i2]);
209363
- }
209364
- return {
209365
- data: [obsX, obsY],
209366
- shape: [2, cellsCount]
209367
- };
209368
- }, [
209369
- cellsCount,
209370
- expressionDataX,
209371
- expressionDataY,
209372
- featureValueTransform,
209373
- featureValueTransformCoefficient,
209374
- featureSelectionX,
209375
- featureSelectionY
209376
- ]);
209377
- const [dynamicCellRadius, setDynamicCellRadius] = useState(cellRadiusFixed);
209378
- const [dynamicCellOpacity, setDynamicCellOpacity] = useState(cellOpacityFixed);
209379
- const mergedCellSets = useMemo(() => mergeObsSets(cellSets, additionalCellSets), [cellSets, additionalCellSets]);
209380
- const setCellSelectionProp = useCallback((v) => {
209381
- setObsSelection(v, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding);
209382
- }, [
209383
- additionalCellSets,
209384
- cellSetColor,
209385
- setCellColorEncoding,
209386
- setAdditionalCellSets,
209387
- setCellSetColor,
209388
- setCellSetSelection
209389
- ]);
209390
- const cellColors = useMemo(() => getCellColors({
209391
- cellColorEncoding,
209392
- expressionData: expressionDataColor && expressionDataColor[0],
209393
- geneSelection: gatingFeatureSelectionColor,
209394
- cellSets: mergedCellSets,
209395
- cellSetSelection,
209396
- cellSetColor,
209397
- obsIndex,
209398
- theme
209399
- }), [
209400
- cellColorEncoding,
209401
- gatingFeatureSelectionColor,
209402
- mergedCellSets,
209403
- theme,
209404
- cellSetSelection,
209405
- cellSetColor,
209406
- expressionDataColor,
209407
- obsIndex
209408
- ]);
209409
- const [cellSetPolygonCache, setCellSetPolygonCache] = useState([]);
209410
- const cacheHas2 = (cache2, key2) => cache2.findIndex((el2) => isEqual_1(el2[0], key2)) !== -1;
209411
- const cacheGet = (cache2, key2) => {
209412
- var _a3;
209413
- return (_a3 = cache2.find((el2) => isEqual_1(el2[0], key2))) == null ? void 0 : _a3[1];
209414
- };
209415
- const cellSetPolygons = useMemo(() => {
209416
- var _a3;
209417
- 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)) {
209418
- const newCellSetPolygons = getCellSetPolygons({
209419
- obsIndex,
209420
- obsEmbedding: obsXY,
209421
- cellSets: mergedCellSets,
209422
- cellSetSelection,
209423
- cellSetColor,
209424
- theme
209425
- });
209426
- setCellSetPolygonCache((cache2) => [...cache2, [cellSetSelection, newCellSetPolygons]]);
209427
- return newCellSetPolygons;
209428
- }
209429
- return cacheGet(cellSetPolygonCache, cellSetSelection) || [];
209430
- }, [
209431
- cellSetPolygonsVisible,
209432
- cellSetPolygonCache,
209433
- cellSetLabelsVisible,
209434
- theme,
209435
- obsIndex,
209436
- obsXY,
209437
- mergedCellSets,
209438
- cellSetSelection,
209439
- cellSetColor
209440
- ]);
209441
- const cellSelection = useMemo(() => Array.from(cellColors.keys()), [cellColors]);
209442
- const [xRange, yRange, xExtent, yExtent, numCells] = useMemo(() => {
209443
- if (obsXY && obsXY.data && obsXY.shape) {
209444
- const cellCount = obsXY.shape[1];
209445
- const xE = extent$2(obsXY.data[0]);
209446
- const yE = extent$2(obsXY.data[1]);
209447
- const xR = xE[1] - xE[0];
209448
- const yR = yE[1] - yE[0];
209449
- return [xR, yR, xE, yE, cellCount];
209450
- }
209451
- return [null, null, null, null, null];
209452
- }, [obsXY]);
209453
- useEffect(() => {
209454
- if (xRange && yRange) {
209455
- const pointSizeDevicePixels = getPointSizeDevicePixels(window.devicePixelRatio, zoom2, xRange, yRange, width2, height2);
209456
- setDynamicCellRadius(pointSizeDevicePixels);
209457
- const nextCellOpacityScale = getPointOpacity(zoom2, xRange, yRange, width2, height2, numCells, averageFillDensity);
209458
- setDynamicCellOpacity(nextCellOpacityScale);
209459
- if (typeof targetX2 !== "number" || typeof targetY2 !== "number") {
209460
- const newTargetX = xExtent[0] + xRange / 2;
209461
- const newTargetY = yExtent[0] + yRange / 2;
209462
- const newZoom = Math.log2(Math.min(width2 / xRange, height2 / yRange));
209463
- setTargetX(newTargetX);
209464
- setTargetY(-newTargetY);
209465
- setZoom(newZoom);
209466
- }
209467
- }
209468
- }, [
209469
- xRange,
209470
- yRange,
209471
- xExtent,
209472
- yExtent,
209473
- numCells,
209474
- width2,
209475
- height2,
209476
- zoom2,
209477
- averageFillDensity
209478
- ]);
209479
- const cellSelectionSet = useMemo(() => new Set(cellSelection), [cellSelection]);
209480
- const getCellIsSelected = useCallback((object2, { index: index2 }) => (cellSelectionSet || /* @__PURE__ */ new Set([])).has(obsIndex[index2]) ? 1 : 0, [cellSelectionSet, obsIndex]);
209481
- const cellRadius = cellRadiusMode === "manual" ? cellRadiusFixed : dynamicCellRadius;
209482
- const cellOpacity = cellOpacityMode === "manual" ? cellOpacityFixed : dynamicCellOpacity;
209483
- const getExpressionValue = useExpressionValueGetter({
209484
- instanceObsIndex: obsIndex,
209485
- matrixObsIndex: obsIndex,
209486
- expressionData: expressionDataColor
209487
- });
209488
- const getObsInfo = useCallback((obsId) => {
209489
- var _a3;
209490
- const selectedTransformName = (_a3 = VALUE_TRANSFORM_OPTIONS.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
209491
- const genePrefix = featureValueTransform ? `${selectedTransformName} ` : "";
209492
- const obsIdx = obsIndex == null ? void 0 : obsIndex.indexOf(obsId);
209493
- const obsInfo = { [`${capitalize$2(obsType)} ID`]: obsId };
209494
- if (gatingFeatureSelectionX && gatingFeatureSelectionY) {
209495
- obsInfo[genePrefix + gatingFeatureSelectionX] = obsXY.data[0][obsIdx];
209496
- obsInfo[genePrefix + gatingFeatureSelectionY] = obsXY.data[1][obsIdx];
209497
- }
209498
- return obsInfo;
209499
- }, [
209500
- obsXY,
209501
- obsIndex,
209502
- featureValueTransform,
209503
- gatingFeatureSelectionX,
209504
- gatingFeatureSelectionY,
209505
- obsType
209506
- ]);
209507
- 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) => {
209508
- setFeatureValueTransform(newValue);
209509
- setTargetX(null);
209510
- setTargetY(null);
209511
- setZoom(null);
209512
- }, 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 }) => {
209513
- setZoom(newZoom);
209514
- setTargetX(target2[0]);
209515
- setTargetY(target2[1]);
209516
- setTargetZ(target2[2] || 0);
209517
- }, obsEmbeddingIndex: obsIndex, obsEmbedding: obsXY, cellFilter, cellSelection, cellHighlight, cellColors, cellSetPolygons, cellSetLabelSize, cellSetLabelsVisible, cellSetPolygonsVisible, setCellFilter, setCellSelection: setCellSelectionProp, setCellHighlight, cellRadius, cellOpacity, cellColorEncoding, geneExpressionColormap, geneExpressionColormapRange, setComponentHover: () => {
209518
- setComponentHover(uuid);
209519
- }, updateViewInfo: setComponentViewInfo, getExpressionValue, getCellIsSelected }), !disableTooltip && jsx(ScatterplotTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
209520
- }
209521
- function register$b() {
209522
- registerPluginViewType(ViewType$2.GATING, GatingSubscriber, COMPONENT_COORDINATION_TYPES[ViewType$2.GATING]);
209523
- }
209524
209567
  var shortNumber$1 = { exports: {} };
209525
209568
  (function(module2, exports) {
209526
209569
  (function(global2, factory2) {
@@ -209693,20 +209736,20 @@ function getVivLayerExtensions(use3d, colormap, renderingMode) {
209693
209736
  if (use3d) {
209694
209737
  if (colormap) {
209695
209738
  if (renderingMode === "Minimum Intensity Projection") {
209696
- return [new (void 0)()];
209739
+ return [new AdditiveColormap3DExtensions.MinimumIntensityProjectionExtension()];
209697
209740
  }
209698
209741
  if (renderingMode === "Maximum Intensity Projection") {
209699
- return [new (void 0)()];
209742
+ return [new AdditiveColormap3DExtensions.MaximumIntensityProjectionExtension()];
209700
209743
  }
209701
- return [new (void 0)()];
209744
+ return [new AdditiveColormap3DExtensions.AdditiveBlendExtension()];
209702
209745
  }
209703
209746
  if (renderingMode === "Minimum Intensity Projection") {
209704
- return [new (void 0)()];
209747
+ return [new ColorPalette3DExtensions.MinimumIntensityProjectionExtension()];
209705
209748
  }
209706
209749
  if (renderingMode === "Maximum Intensity Projection") {
209707
- return [new (void 0)()];
209750
+ return [new ColorPalette3DExtensions.MaximumIntensityProjectionExtension()];
209708
209751
  }
209709
- return [new (void 0)()];
209752
+ return [new ColorPalette3DExtensions.AdditiveBlendExtension()];
209710
209753
  }
209711
209754
  if (colormap) {
209712
209755
  return [new AdditiveColormapExtension()];
@@ -209943,7 +209986,8 @@ class Spatial extends AbstractSpatialOrScatterplot {
209943
209986
  ySlice: layerDef.ySlice,
209944
209987
  zSlice: layerDef.zSlice,
209945
209988
  callback: layerDef.callback,
209946
- visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible)
209989
+ visibilities: layerDef.channels.map((c2) => !layerDef.visible && typeof layerDef.visible === "boolean" ? false : c2.visible),
209990
+ excludeBackground: useTransparentColor
209947
209991
  };
209948
209992
  if (!loader2 || !layerProps)
209949
209993
  return null;
@@ -209999,6 +210043,7 @@ class Spatial extends AbstractSpatialOrScatterplot {
209999
210043
  ySlice: layerProps.ySlice,
210000
210044
  zSlice: layerProps.zSlice,
210001
210045
  onViewportLoad: layerProps.callback,
210046
+ excludeBackground: layerProps.excludeBackground,
210002
210047
  extensions
210003
210048
  });
210004
210049
  }
@@ -210266,7 +210311,8 @@ function SpatialSubscriber(props2) {
210266
210311
  const [width2, height2, deckRef] = useDeckCanvasSize();
210267
210312
  const [obsLabelsTypes, obsLabelsData] = useMultiObsLabels(coordinationScopes, obsType, loaders, dataset, addUrl2);
210268
210313
  const hasExpressionData = useHasLoader(loaders, dataset, DataType$3.OBS_FEATURE_MATRIX, { obsType, featureType, featureValueType });
210269
- const hasCellsData = useHasLoader(loaders, dataset, DataType$3.OBS_SEGMENTATIONS, { obsType });
210314
+ const hasSegmentationsData = useHasLoader(loaders, dataset, DataType$3.OBS_SEGMENTATIONS, { obsType });
210315
+ const hasLocationsData = useHasLoader(loaders, dataset, DataType$3.OBS_LOCATIONS, { obsType });
210270
210316
  const hasImageData = useHasLoader(loaders, dataset, DataType$3.IMAGE, {});
210271
210317
  const [{ obsIndex: obsLocationsIndex, obsLocations }, obsLocationsStatus] = useObsLocationsData(loaders, dataset, addUrl2, false, { setSpatialPointLayer: setMoleculesLayer }, { spatialPointLayer: moleculesLayer }, { obsType: "molecule" });
210272
210318
  const [{ obsLabels: obsLocationsLabels }, obsLabelsStatus] = useObsLabelsData(loaders, dataset, addUrl2, false, {}, {}, { obsType: "molecule" });
@@ -210388,7 +210434,7 @@ function SpatialSubscriber(props2) {
210388
210434
  locationsCount
210389
210435
  });
210390
210436
  const getExpressionValue = useExpressionValueGetter({
210391
- instanceObsIndex: obsSegmentationsIndex,
210437
+ instanceObsIndex: obsSegmentationsIndex ? obsSegmentationsIndex : obsCentroidsIndex,
210392
210438
  matrixObsIndex,
210393
210439
  expressionData
210394
210440
  });
@@ -210398,7 +210444,7 @@ function SpatialSubscriber(props2) {
210398
210444
  const canShow3DOptions = canLoad3DLayers && !((disable3d == null ? void 0 : disable3d.length) === imageLayerLoaders.length) && !globalDisable3d;
210399
210445
  const options = useMemo(() => {
210400
210446
  if (canShow3DOptions || hasExpressionData) {
210401
- return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption: hasCellsData && hasExpressionData, canShow3DOptions });
210447
+ return jsx(SpatialOptions, { observationsLabel, cellColorEncoding, setCellColorEncoding, setSpatialAxisFixed, spatialAxisFixed, use3d, geneExpressionColormap, setGeneExpressionColormap, geneExpressionColormapRange, setGeneExpressionColormapRange, canShowExpressionOptions: hasExpressionData, canShowColorEncodingOption: (hasLocationsData || hasSegmentationsData) && hasExpressionData, canShow3DOptions });
210402
210448
  }
210403
210449
  return null;
210404
210450
  }, [
@@ -210407,7 +210453,8 @@ function SpatialSubscriber(props2) {
210407
210453
  geneExpressionColormap,
210408
210454
  geneExpressionColormapRange,
210409
210455
  setGeneExpressionColormap,
210410
- hasCellsData,
210456
+ hasLocationsData,
210457
+ hasSegmentationsData,
210411
210458
  hasExpressionData,
210412
210459
  observationsLabel,
210413
210460
  setCellColorEncoding,
@@ -210417,11 +210464,11 @@ function SpatialSubscriber(props2) {
210417
210464
  use3d
210418
210465
  ]);
210419
210466
  useEffect(() => {
210420
- if (!hasCellsData && cellsLayer && !obsSegmentations && !obsSegmentationsIndex && obsCentroids && obsCentroidsIndex) {
210467
+ if (!hasSegmentationsData && cellsLayer && !obsSegmentations && !obsSegmentationsIndex && obsCentroids && obsCentroidsIndex) {
210421
210468
  console.warn("Rendering cell segmentation diamonds for backwards compatibility.");
210422
210469
  }
210423
210470
  }, [
210424
- hasCellsData,
210471
+ hasSegmentationsData,
210425
210472
  cellsLayer,
210426
210473
  obsSegmentations,
210427
210474
  obsSegmentationsIndex,
@@ -210436,7 +210483,7 @@ function SpatialSubscriber(props2) {
210436
210483
  rotationZ,
210437
210484
  rotationOrbit,
210438
210485
  orbitAxis
210439
- }, 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: () => {
210486
+ }, 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: () => {
210440
210487
  setComponentHover(uuid);
210441
210488
  }, updateViewInfo: setComponentViewInfo, imageLayerCallbacks, segmentationLayerCallbacks, spatialAxisFixed, geneExpressionColormap, geneExpressionColormapRange, expressionData: shiftedExpressionDataForBitmask, cellColorEncoding, getExpressionValue, theme }), !disableTooltip && jsx(SpatialTooltipSubscriber, { parentUuid: uuid, obsHighlight: cellHighlight, width: width2, height: height2, getObsInfo })] });
210442
210489
  }
@@ -271750,7 +271797,7 @@ function CellSetExpressionPlot(props2) {
271750
271797
  orient: "left",
271751
271798
  scale: "yscale",
271752
271799
  zindex: 1,
271753
- title: featureValueTransformName ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
271800
+ title: featureValueTransformName && featureValueTransformName !== "None" ? [`${featureValueTransformName}-Transformed`, `Normalized ${capitalize$2(featureValueType)} Values`] : `Normalized ${capitalize$2(featureValueType)} Values`
271754
271801
  },
271755
271802
  {
271756
271803
  orient: "bottom",
@@ -271914,15 +271961,17 @@ function CellSetExpressionPlotSubscriber(props2) {
271914
271961
  const [urls2, addUrl2] = useUrls(loaders, dataset);
271915
271962
  const transformOptions = VALUE_TRANSFORM_OPTIONS;
271916
271963
  const [expressionData, loadedFeatureSelection, featureSelectionStatus] = useFeatureSelection(loaders, dataset, false, geneSelection, { obsType, featureType, featureValueType });
271964
+ const [{ featureLabelsMap }, featureLabelsStatus] = useFeatureLabelsData(loaders, dataset, addUrl2, false, {}, {}, { featureType });
271917
271965
  const [{ obsIndex }, matrixIndicesStatus] = useObsFeatureMatrixIndices(loaders, dataset, addUrl2, false, { obsType, featureType, featureValueType });
271918
271966
  const [{ obsSets: cellSets }, obsSetsStatus] = useObsSetsData(loaders, dataset, addUrl2, true, {}, {}, { obsType });
271919
271967
  const isReady = useReady([
271920
271968
  featureSelectionStatus,
271921
271969
  matrixIndicesStatus,
271922
- obsSetsStatus
271970
+ obsSetsStatus,
271971
+ featureLabelsStatus
271923
271972
  ]);
271924
271973
  const [expressionArr, setArr, expressionMax] = useExpressionByCellSet(expressionData, obsIndex, cellSets, additionalCellSets, geneSelection, cellSetSelection, cellSetColor, featureValueTransform, featureValueTransformCoefficient, theme);
271925
- const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? geneSelection[0] : null;
271974
+ const firstGeneSelected = geneSelection && geneSelection.length >= 1 ? (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneSelection[0])) || geneSelection[0] : null;
271926
271975
  const selectedTransformName = (_a3 = transformOptions.find((o2) => o2.value === featureValueTransform)) == null ? void 0 : _a3.name;
271927
271976
  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, "."] }) }) });
271928
271977
  }