@vitessce/dev 3.8.13 → 3.9.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.
@@ -301,6 +301,7 @@ const CoordinationType$2 = {
301
301
  OBS_SET_HIGHLIGHT: "obsSetHighlight",
302
302
  OBS_SET_EXPANSION: "obsSetExpansion",
303
303
  OBS_SET_COLOR: "obsSetColor",
304
+ FEATURE_COLOR: "featureColor",
304
305
  FEATURE_HIGHLIGHT: "featureHighlight",
305
306
  FEATURE_SELECTION: "featureSelection",
306
307
  FEATURE_SET_SELECTION: "featureSetSelection",
@@ -907,6 +908,8 @@ const COMPONENT_COORDINATION_TYPES = {
907
908
  CoordinationType$2.OBS_SET_FILTER,
908
909
  CoordinationType$2.OBS_SET_HIGHLIGHT,
909
910
  CoordinationType$2.OBS_SET_COLOR,
911
+ CoordinationType$2.FEATURE_COLOR,
912
+ CoordinationType$2.FEATURE_FILTER_MODE,
910
913
  CoordinationType$2.FEATURE_HIGHLIGHT,
911
914
  CoordinationType$2.FEATURE_SELECTION,
912
915
  CoordinationType$2.FEATURE_VALUE_COLORMAP,
@@ -1121,6 +1124,8 @@ const COMPONENT_COORDINATION_TYPES = {
1121
1124
  CoordinationType$2.SPATIAL_SPOT_STROKE_WIDTH,
1122
1125
  CoordinationType$2.SPATIAL_LAYER_COLOR,
1123
1126
  CoordinationType$2.OBS_COLOR_ENCODING,
1127
+ CoordinationType$2.FEATURE_COLOR,
1128
+ CoordinationType$2.FEATURE_FILTER_MODE,
1124
1129
  CoordinationType$2.FEATURE_VALUE_COLORMAP,
1125
1130
  CoordinationType$2.FEATURE_VALUE_COLORMAP_RANGE,
1126
1131
  CoordinationType$2.FEATURE_SELECTION,
@@ -1340,7 +1345,7 @@ const COMPONENT_COORDINATION_TYPES = {
1340
1345
  CoordinationType$2.HIERARCHY_LEVELS
1341
1346
  ]
1342
1347
  };
1343
- const version$6 = "3.8.13";
1348
+ const version$6 = "3.9.1";
1344
1349
  const META_VERSION = {
1345
1350
  version: version$6
1346
1351
  };
@@ -29569,7 +29574,7 @@ var _span$3;
29569
29574
  const useUtilityClasses$1l = (ownerState) => {
29570
29575
  const {
29571
29576
  classes: classes2,
29572
- contained,
29577
+ contained: contained2,
29573
29578
  size: size2,
29574
29579
  disabled,
29575
29580
  error: error2,
@@ -29578,7 +29583,7 @@ const useUtilityClasses$1l = (ownerState) => {
29578
29583
  required: required2
29579
29584
  } = ownerState;
29580
29585
  const slots = {
29581
- root: ["root", disabled && "disabled", error2 && "error", size2 && `size${capitalize$1(size2)}`, contained && "contained", focused && "focused", filled && "filled", required2 && "required"]
29586
+ root: ["root", disabled && "disabled", error2 && "error", size2 && `size${capitalize$1(size2)}`, contained2 && "contained", focused && "focused", filled && "filled", required2 && "required"]
29582
29587
  };
29583
29588
  return composeClasses(slots, getFormHelperTextUtilityClasses, classes2);
29584
29589
  };
@@ -31352,6 +31357,90 @@ ListItemText.propTypes = {
31352
31357
  */
31353
31358
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
31354
31359
  };
31360
+ function getListItemIconUtilityClass(slot) {
31361
+ return generateUtilityClass("MuiListItemIcon", slot);
31362
+ }
31363
+ const listItemIconClasses = generateUtilityClasses("MuiListItemIcon", ["root", "alignItemsFlexStart"]);
31364
+ const useUtilityClasses$1e = (ownerState) => {
31365
+ const {
31366
+ alignItems,
31367
+ classes: classes2
31368
+ } = ownerState;
31369
+ const slots = {
31370
+ root: ["root", alignItems === "flex-start" && "alignItemsFlexStart"]
31371
+ };
31372
+ return composeClasses(slots, getListItemIconUtilityClass, classes2);
31373
+ };
31374
+ const ListItemIconRoot = styled("div", {
31375
+ name: "MuiListItemIcon",
31376
+ slot: "Root",
31377
+ overridesResolver: (props, styles2) => {
31378
+ const {
31379
+ ownerState
31380
+ } = props;
31381
+ return [styles2.root, ownerState.alignItems === "flex-start" && styles2.alignItemsFlexStart];
31382
+ }
31383
+ })(memoTheme(({
31384
+ theme
31385
+ }) => ({
31386
+ minWidth: 56,
31387
+ color: (theme.vars || theme).palette.action.active,
31388
+ flexShrink: 0,
31389
+ display: "inline-flex",
31390
+ variants: [{
31391
+ props: {
31392
+ alignItems: "flex-start"
31393
+ },
31394
+ style: {
31395
+ marginTop: 8
31396
+ }
31397
+ }]
31398
+ })));
31399
+ const ListItemIcon = /* @__PURE__ */ React.forwardRef(function ListItemIcon2(inProps, ref2) {
31400
+ const props = useDefaultProps({
31401
+ props: inProps,
31402
+ name: "MuiListItemIcon"
31403
+ });
31404
+ const {
31405
+ className,
31406
+ ...other
31407
+ } = props;
31408
+ const context2 = React.useContext(ListContext);
31409
+ const ownerState = {
31410
+ ...props,
31411
+ alignItems: context2.alignItems
31412
+ };
31413
+ const classes2 = useUtilityClasses$1e(ownerState);
31414
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ListItemIconRoot, {
31415
+ className: clsx$1(classes2.root, className),
31416
+ ownerState,
31417
+ ref: ref2,
31418
+ ...other
31419
+ });
31420
+ });
31421
+ ListItemIcon.propTypes = {
31422
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
31423
+ // │ These PropTypes are generated from the TypeScript type definitions. │
31424
+ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
31425
+ // └─────────────────────────────────────────────────────────────────────┘
31426
+ /**
31427
+ * The content of the component, normally `Icon`, `SvgIcon`,
31428
+ * or a `@mui/icons-material` SVG icon element.
31429
+ */
31430
+ children: PropTypes.node,
31431
+ /**
31432
+ * Override or extend the styles applied to the component.
31433
+ */
31434
+ classes: PropTypes.object,
31435
+ /**
31436
+ * @ignore
31437
+ */
31438
+ className: PropTypes.string,
31439
+ /**
31440
+ * The system prop that allows defining system overrides as well as additional CSS styles.
31441
+ */
31442
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
31443
+ };
31355
31444
  function getScrollbarSize$1(win2 = window) {
31356
31445
  const documentWidth = win2.document.documentElement.clientWidth;
31357
31446
  return win2.innerWidth - documentWidth;
@@ -31603,7 +31692,7 @@ function getDividerUtilityClass(slot) {
31603
31692
  return generateUtilityClass("MuiDivider", slot);
31604
31693
  }
31605
31694
  const dividerClasses = generateUtilityClasses("MuiDivider", ["root", "absolute", "fullWidth", "inset", "middle", "flexItem", "light", "vertical", "withChildren", "withChildrenVertical", "textAlignRight", "textAlignLeft", "wrapper", "wrapperVertical"]);
31606
- const useUtilityClasses$1e = (ownerState) => {
31695
+ const useUtilityClasses$1d = (ownerState) => {
31607
31696
  const {
31608
31697
  absolute: absolute2,
31609
31698
  children: children3,
@@ -31817,7 +31906,7 @@ const Divider$1 = /* @__PURE__ */ React.forwardRef(function Divider2(inProps, re
31817
31906
  textAlign: textAlign2,
31818
31907
  variant
31819
31908
  };
31820
- const classes2 = useUtilityClasses$1e(ownerState);
31909
+ const classes2 = useUtilityClasses$1d(ownerState);
31821
31910
  return /* @__PURE__ */ jsxRuntimeExports.jsx(DividerRoot, {
31822
31911
  as: component,
31823
31912
  className: clsx$1(classes2.root, className),
@@ -31899,90 +31988,6 @@ Divider$1.propTypes = {
31899
31988
  */
31900
31989
  variant: PropTypes.oneOfType([PropTypes.oneOf(["fullWidth", "inset", "middle"]), PropTypes.string])
31901
31990
  };
31902
- function getListItemIconUtilityClass(slot) {
31903
- return generateUtilityClass("MuiListItemIcon", slot);
31904
- }
31905
- const listItemIconClasses = generateUtilityClasses("MuiListItemIcon", ["root", "alignItemsFlexStart"]);
31906
- const useUtilityClasses$1d = (ownerState) => {
31907
- const {
31908
- alignItems,
31909
- classes: classes2
31910
- } = ownerState;
31911
- const slots = {
31912
- root: ["root", alignItems === "flex-start" && "alignItemsFlexStart"]
31913
- };
31914
- return composeClasses(slots, getListItemIconUtilityClass, classes2);
31915
- };
31916
- const ListItemIconRoot = styled("div", {
31917
- name: "MuiListItemIcon",
31918
- slot: "Root",
31919
- overridesResolver: (props, styles2) => {
31920
- const {
31921
- ownerState
31922
- } = props;
31923
- return [styles2.root, ownerState.alignItems === "flex-start" && styles2.alignItemsFlexStart];
31924
- }
31925
- })(memoTheme(({
31926
- theme
31927
- }) => ({
31928
- minWidth: 56,
31929
- color: (theme.vars || theme).palette.action.active,
31930
- flexShrink: 0,
31931
- display: "inline-flex",
31932
- variants: [{
31933
- props: {
31934
- alignItems: "flex-start"
31935
- },
31936
- style: {
31937
- marginTop: 8
31938
- }
31939
- }]
31940
- })));
31941
- const ListItemIcon = /* @__PURE__ */ React.forwardRef(function ListItemIcon2(inProps, ref2) {
31942
- const props = useDefaultProps({
31943
- props: inProps,
31944
- name: "MuiListItemIcon"
31945
- });
31946
- const {
31947
- className,
31948
- ...other
31949
- } = props;
31950
- const context2 = React.useContext(ListContext);
31951
- const ownerState = {
31952
- ...props,
31953
- alignItems: context2.alignItems
31954
- };
31955
- const classes2 = useUtilityClasses$1d(ownerState);
31956
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ListItemIconRoot, {
31957
- className: clsx$1(classes2.root, className),
31958
- ownerState,
31959
- ref: ref2,
31960
- ...other
31961
- });
31962
- });
31963
- ListItemIcon.propTypes = {
31964
- // ┌────────────────────────────── Warning ──────────────────────────────┐
31965
- // │ These PropTypes are generated from the TypeScript type definitions. │
31966
- // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
31967
- // └─────────────────────────────────────────────────────────────────────┘
31968
- /**
31969
- * The content of the component, normally `Icon`, `SvgIcon`,
31970
- * or a `@mui/icons-material` SVG icon element.
31971
- */
31972
- children: PropTypes.node,
31973
- /**
31974
- * Override or extend the styles applied to the component.
31975
- */
31976
- classes: PropTypes.object,
31977
- /**
31978
- * @ignore
31979
- */
31980
- className: PropTypes.string,
31981
- /**
31982
- * The system prop that allows defining system overrides as well as additional CSS styles.
31983
- */
31984
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
31985
- };
31986
31991
  function getMenuItemUtilityClass(slot) {
31987
31992
  return generateUtilityClass("MuiMenuItem", slot);
31988
31993
  }
@@ -82351,7 +82356,9 @@ const obsSegmentationsSpatialdataSchema = z.object({
82351
82356
  const obsPointsSpatialdataSchema = z.object({
82352
82357
  path: z.string().describe("The path to the point data."),
82353
82358
  tablePath: z.string().optional().describe("The path to a table which annotates the points. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected."),
82354
- coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.')
82359
+ coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.'),
82360
+ featureIndexColumn: z.string().optional().describe("The name of the column in the table which contains the feature (e.g., gene) indices associated with each point (aligned with the table var.index dataframe column)."),
82361
+ mortonCodeColumn: z.string().optional().describe('The name of the column in the table which contains the Morton codes for each point, used for efficient spatial querying. If not provided, Vitessce will assume the default column name "morton_code_2d".')
82355
82362
  });
82356
82363
  z.object({
82357
82364
  path: z.string(),
@@ -83649,7 +83656,7 @@ const AUXILIARY_COORDINATION_TYPES_MAP = {
83649
83656
  spatialImageLayer: ["imageLayerCallbacks", "areLoadingImageChannels"],
83650
83657
  spatialSegmentationLayer: ["segmentationLayerCallbacks", "areLoadingSegmentationChannels"],
83651
83658
  spatialAcceleratedVolumeLoadingProgress: ["volumeLoadingProgress"],
83652
- layerControllerBeta: ["volumeLoadingProgress"]
83659
+ spatialTiledPointsLoadingProgress: ["tiledPointsLoadingProgress"]
83653
83660
  };
83654
83661
  const mapCoordinationScopes = (coordinationScopes) => {
83655
83662
  const newCoordinationScopes = {};
@@ -91520,7 +91527,7 @@ function initialize$2(config3, jointFileTypes, coordinationTypes, viewTypes) {
91520
91527
  return assignViewUids(newConfig);
91521
91528
  }
91522
91529
  function VitS(props) {
91523
- const { config: config3, stores, rowHeight, height: height2, theme, onWarn, onConfigChange, onLoaderChange, validateConfig = true, validateOnConfigChange = false, isBounded = false, uid: uid2 = null, styleContainer, remountOnUidChange = true, viewTypes: viewTypesProp, fileTypes: fileTypesProp, jointFileTypes: jointFileTypesProp, coordinationTypes: coordinationTypesProp, asyncFunctions: asyncFunctionsProp, warning: warning2, pageMode = false, children: children3, debugMode = DEFAULT_DEBUG_MODE, logLevel = DEFAULT_LOG_LEVEL } = props;
91530
+ const { config: config3, stores: storesProp, rowHeight, height: height2, theme, onWarn, onConfigChange, onLoaderChange, validateConfig = true, validateOnConfigChange = false, isBounded = false, uid: uid2 = null, styleContainer, remountOnUidChange = true, viewTypes: viewTypesProp, fileTypes: fileTypesProp, jointFileTypes: jointFileTypesProp, coordinationTypes: coordinationTypesProp, asyncFunctions: asyncFunctionsProp, warning: warning2, pageMode = false, children: children3, debugMode = DEFAULT_DEBUG_MODE, logLevel = DEFAULT_LOG_LEVEL } = props;
91524
91531
  const [debugErrors, setDebugErrors] = useState([]);
91525
91532
  const viewTypes = useMemo$1(() => viewTypesProp || [], [viewTypesProp]);
91526
91533
  const fileTypes = useMemo$1(() => fileTypesProp || [], [fileTypesProp]);
@@ -91540,6 +91547,30 @@ function VitS(props) {
91540
91547
  return JSON.stringify(config3);
91541
91548
  }, [config3]);
91542
91549
  const pluginSpecificConfigSchema = useMemo$1(() => buildConfigSchema(fileTypes, jointFileTypes, coordinationTypes, viewTypes), [viewTypes, fileTypes, jointFileTypes, coordinationTypes]);
91550
+ const mergedStores = useMemo$1(() => {
91551
+ const result = storesProp ?? {};
91552
+ const urlMap = /* @__PURE__ */ new Map();
91553
+ if (Array.isArray(config3.datasets)) {
91554
+ config3.datasets.forEach((dataset) => {
91555
+ dataset.files?.forEach((file) => {
91556
+ if (file.fileType?.endsWith(".zip") && file.url) {
91557
+ if (!urlMap.has(file.url)) {
91558
+ urlMap.set(file.url, file.requestInit);
91559
+ }
91560
+ }
91561
+ });
91562
+ });
91563
+ }
91564
+ urlMap.forEach((requestInit2, url) => {
91565
+ if (!result[url]) {
91566
+ result[url] = ZipFileStore.fromUrl(url, {
91567
+ overrides: requestInit2,
91568
+ transformEntries: transformEntriesForZipFileStore
91569
+ });
91570
+ }
91571
+ });
91572
+ return result;
91573
+ }, [configKey]);
91543
91574
  const [configOrWarning, success] = useMemo$1(() => {
91544
91575
  if (warning2) {
91545
91576
  return [warning2, false];
@@ -91622,7 +91653,7 @@ function VitS(props) {
91622
91653
  }, [success, configKey, configOrWarning, onConfigChange]);
91623
91654
  const createViewConfigStoreClosure = useCallback(() => {
91624
91655
  if (success) {
91625
- const loaders = createLoaders(configOrWarning.datasets, configOrWarning.description, fileTypes, coordinationTypes, stores, queryClient);
91656
+ const loaders = createLoaders(configOrWarning.datasets, configOrWarning.description, fileTypes, coordinationTypes, mergedStores, queryClient);
91626
91657
  return createViewConfigStore(loaders, configOrWarning);
91627
91658
  }
91628
91659
  return createViewConfigStore(null, null);
@@ -91630,7 +91661,7 @@ function VitS(props) {
91630
91661
  if (debugMode && debugErrors.length > 0) {
91631
91662
  return jsxRuntimeExports.jsx(CacheProvider, { value: muiCache, children: jsxRuntimeExports.jsx(ThemeProvider, { theme: muiTheme[theme], children: jsxRuntimeExports.jsx(DebugWindow, { debugErrors }) }) });
91632
91663
  }
91633
- return success ? jsxRuntimeExports.jsx(CacheProvider, { value: muiCache, children: jsxRuntimeExports.jsx(ThemeProvider, { theme: muiTheme[theme], children: jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient, children: jsxRuntimeExports.jsx(ViewConfigProvider, { createStore: createViewConfigStoreClosure, children: jsxRuntimeExports.jsx(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: jsxRuntimeExports.jsxs(AsyncFunctionsContext.Provider, { value: asyncFunctions, children: [jsxRuntimeExports.jsx(VitessceGrid, { pageMode, success, configKey, viewTypes, fileTypes, coordinationTypes, config: configOrWarning, rowHeight, height: height2, theme, isBounded, stores, queryClient, children: children3 }), jsxRuntimeExports.jsx(CallbackPublisher, { onWarn, onConfigChange, onLoaderChange, validateOnConfigChange, pluginSpecificConfigSchema })] }) }) }, remountOnUidChange ? configKey : void 0) }) }) }) : jsxRuntimeExports.jsx(CacheProvider, { value: muiCache, children: jsxRuntimeExports.jsx(ThemeProvider, { theme: muiTheme[theme], children: jsxRuntimeExports.jsx(Warning, { ...configOrWarning }) }) });
91664
+ return success ? jsxRuntimeExports.jsx(CacheProvider, { value: muiCache, children: jsxRuntimeExports.jsx(ThemeProvider, { theme: muiTheme[theme], children: jsxRuntimeExports.jsx(QueryClientProvider, { client: queryClient, children: jsxRuntimeExports.jsx(ViewConfigProvider, { createStore: createViewConfigStoreClosure, children: jsxRuntimeExports.jsx(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: jsxRuntimeExports.jsxs(AsyncFunctionsContext.Provider, { value: asyncFunctions, children: [jsxRuntimeExports.jsx(VitessceGrid, { pageMode, success, configKey, viewTypes, fileTypes, coordinationTypes, config: configOrWarning, rowHeight, height: height2, theme, isBounded, stores: mergedStores, queryClient, children: children3 }), jsxRuntimeExports.jsx(CallbackPublisher, { onWarn, onConfigChange, onLoaderChange, validateOnConfigChange, pluginSpecificConfigSchema })] }) }) }, remountOnUidChange ? configKey : void 0) }) }) }) : jsxRuntimeExports.jsx(CacheProvider, { value: muiCache, children: jsxRuntimeExports.jsx(ThemeProvider, { theme: muiTheme[theme], children: jsxRuntimeExports.jsx(Warning, { ...configOrWarning }) }) });
91634
91665
  }
91635
91666
  function FallbackForVitS(props) {
91636
91667
  const {
@@ -92642,6 +92673,23 @@ function usePointMultiObsLabels(coordinationScopes, coordinationScopesBy, loader
92642
92673
  const [indicesData, indicesDataStatus, indicesDataErrors] = useObsLabelsMultiLevel(loaders, dataset, false, matchOnObj, 1);
92643
92674
  return [indicesData, indicesDataStatus, indicesDataErrors];
92644
92675
  }
92676
+ function usePointMultiObsFeatureMatrixIndices(coordinationScopes, coordinationScopesBy, loaders, dataset) {
92677
+ const obsFeatureMatrixCoordination = useComplexCoordination([
92678
+ // We currently do not specify obsType or featureValueType here,
92679
+ // since for points we are only interested in the var table
92680
+ // to get the info about each feature (gene).
92681
+ CoordinationType$2.FEATURE_TYPE
92682
+ ], coordinationScopes, coordinationScopesBy, CoordinationType$2.POINT_LAYER);
92683
+ const matchOnObj = useMemo$1(
92684
+ () => obsFeatureMatrixCoordination[0],
92685
+ // imageCoordination reference changes each render,
92686
+ // use coordinationScopes and coordinationScopesBy which are
92687
+ // indirect dependencies here.
92688
+ [coordinationScopes, coordinationScopesBy]
92689
+ );
92690
+ const [indicesData, indicesDataStatus, indicesDataErrors] = useObsFeatureMatrixIndicesMultiLevel(loaders, dataset, false, matchOnObj, 1);
92691
+ return [indicesData, indicesDataStatus, indicesDataErrors];
92692
+ }
92645
92693
  function useSegmentationMultiObsLocations(coordinationScopes, coordinationScopesBy, loaders, dataset) {
92646
92694
  const obsTypeCoordination = useComplexCoordinationSecondary([
92647
92695
  CoordinationType$2.OBS_TYPE
@@ -189810,14 +189858,14 @@ class RBush {
189810
189858
  search(bbox2) {
189811
189859
  let node2 = this.data;
189812
189860
  const result = [];
189813
- if (!intersects$3(bbox2, node2)) return result;
189861
+ if (!intersects$4(bbox2, node2)) return result;
189814
189862
  const toBBox = this.toBBox;
189815
189863
  const nodesToSearch = [];
189816
189864
  while (node2) {
189817
189865
  for (let i2 = 0; i2 < node2.children.length; i2++) {
189818
189866
  const child = node2.children[i2];
189819
189867
  const childBBox = node2.leaf ? toBBox(child) : child;
189820
- if (intersects$3(bbox2, childBBox)) {
189868
+ if (intersects$4(bbox2, childBBox)) {
189821
189869
  if (node2.leaf) result.push(child);
189822
189870
  else if (contains$3(bbox2, childBBox)) this._all(child, result);
189823
189871
  else nodesToSearch.push(child);
@@ -189829,13 +189877,13 @@ class RBush {
189829
189877
  }
189830
189878
  collides(bbox2) {
189831
189879
  let node2 = this.data;
189832
- if (!intersects$3(bbox2, node2)) return false;
189880
+ if (!intersects$4(bbox2, node2)) return false;
189833
189881
  const nodesToSearch = [];
189834
189882
  while (node2) {
189835
189883
  for (let i2 = 0; i2 < node2.children.length; i2++) {
189836
189884
  const child = node2.children[i2];
189837
189885
  const childBBox = node2.leaf ? this.toBBox(child) : child;
189838
- if (intersects$3(bbox2, childBBox)) {
189886
+ if (intersects$4(bbox2, childBBox)) {
189839
189887
  if (node2.leaf || contains$3(bbox2, childBBox)) return true;
189840
189888
  nodesToSearch.push(child);
189841
189889
  }
@@ -190147,7 +190195,7 @@ function intersectionArea(a2, b2) {
190147
190195
  function contains$3(a2, b2) {
190148
190196
  return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
190149
190197
  }
190150
- function intersects$3(a2, b2) {
190198
+ function intersects$4(a2, b2) {
190151
190199
  return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
190152
190200
  }
190153
190201
  function createNode(children3) {
@@ -229014,22 +229062,22 @@ async function getDecoder(fileDirectory) {
229014
229062
  const Decoder = await importFn();
229015
229063
  return new Decoder(fileDirectory);
229016
229064
  }
229017
- addDecoder([void 0, 1], () => import("./raw-_5jEXNrG.js").then((m2) => m2.default));
229018
- addDecoder(5, () => import("./lzw-DegoPRcq.js").then((m2) => m2.default));
229065
+ addDecoder([void 0, 1], () => import("./raw-B9C7wwCT.js").then((m2) => m2.default));
229066
+ addDecoder(5, () => import("./lzw-BLhuO_Wm.js").then((m2) => m2.default));
229019
229067
  addDecoder(6, () => {
229020
229068
  throw new Error("old style JPEG compression is not supported.");
229021
229069
  });
229022
- addDecoder(7, () => import("./jpeg-4T1eMJjT.js").then((m2) => m2.default));
229023
- addDecoder([8, 32946], () => import("./deflate-D2hQqXWv.js").then((m2) => m2.default));
229024
- addDecoder(32773, () => import("./packbits-D8TtRGBA.js").then((m2) => m2.default));
229070
+ addDecoder(7, () => import("./jpeg-Bm_SJrtp.js").then((m2) => m2.default));
229071
+ addDecoder([8, 32946], () => import("./deflate-CB3_OBbG.js").then((m2) => m2.default));
229072
+ addDecoder(32773, () => import("./packbits-BJBaYgcY.js").then((m2) => m2.default));
229025
229073
  addDecoder(
229026
229074
  34887,
229027
- () => import("./lerc-CYc2rNzh.js").then(async (m2) => {
229075
+ () => import("./lerc-dsrFlWfH.js").then(async (m2) => {
229028
229076
  await m2.zstd.init();
229029
229077
  return m2;
229030
229078
  }).then((m2) => m2.default)
229031
229079
  );
229032
- addDecoder(50001, () => import("./webimage-CsMD6Fde.js").then((m2) => m2.default));
229080
+ addDecoder(50001, () => import("./webimage-DgSczDFu.js").then((m2) => m2.default));
229033
229081
  function copyNewSize(array2, width2, height2, samplesPerPixel = 1) {
229034
229082
  return new (Object.getPrototypeOf(array2)).constructor(width2 * height2 * samplesPerPixel);
229035
229083
  }
@@ -250955,6 +251003,7 @@ function Legend(props) {
250955
251003
  positionRelative = false,
250956
251004
  highContrast = false,
250957
251005
  obsType,
251006
+ isPointsLayer = false,
250958
251007
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
250959
251008
  featureType: _featureType = void 0,
250960
251009
  // Unused but accepted for API compatibility
@@ -250962,6 +251011,9 @@ function Legend(props) {
250962
251011
  considerSelections = true,
250963
251012
  obsColorEncoding,
250964
251013
  featureSelection,
251014
+ featureFilterMode,
251015
+ featureColor,
251016
+ featureIndex,
250965
251017
  featureLabelsMap,
250966
251018
  featureValueColormap,
250967
251019
  featureValueColormapRange,
@@ -251005,15 +251057,94 @@ function Legend(props) {
251005
251057
  debouncedSetRange(rangeValue);
251006
251058
  }
251007
251059
  }, [debouncedSetRange]);
251060
+ const obsLabel = capitalize$3(obsType ?? null);
251008
251061
  const isDarkTheme = theme === "dark";
251009
- const isStaticColor = obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor";
251010
- const isSetColor = obsColorEncoding === "cellSetSelection";
251062
+ const isStaticColor = !isPointsLayer && (obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor");
251063
+ const isSetColor = !isPointsLayer && obsColorEncoding === "cellSetSelection";
251011
251064
  const layerColor = Array.isArray(spatialLayerColor) && spatialLayerColor.length === 3 ? spatialLayerColor : getDefaultColor(theme ?? "light");
251012
251065
  const channelColor = Array.isArray(spatialChannelColor) && spatialChannelColor.length === 3 ? spatialChannelColor : getDefaultColor(theme ?? "light");
251013
251066
  const staticColor = obsColorEncoding === "spatialChannelColor" ? channelColor : layerColor;
251014
- const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && (obsSetSelection?.length ?? 0) > 0 && (obsSetColor?.length ?? 0) > 0 || isStaticColor);
251067
+ const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && (obsSetSelection?.length ?? 0) > 0 && (obsSetColor?.length ?? 0) > 0 || isStaticColor || isPointsLayer);
251068
+ const pointsLegendElements = [];
251069
+ if (isPointsLayer) {
251070
+ const MAX_NUM_COLORS = 10;
251071
+ const hasFeatureSelection = Array.isArray(featureSelection) && featureSelection.length > 0;
251072
+ const showUnselected = featureFilterMode !== "featureSelection";
251073
+ if (obsColorEncoding === "spatialLayerColor") {
251074
+ if (!hasFeatureSelection) {
251075
+ pointsLegendElements.push({
251076
+ name: obsLabel,
251077
+ color: staticColor
251078
+ });
251079
+ } else {
251080
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
251081
+ limitedFeatureSelection.forEach((featureName) => {
251082
+ pointsLegendElements.push({
251083
+ name: featureName,
251084
+ color: staticColor
251085
+ });
251086
+ });
251087
+ }
251088
+ } else if (obsColorEncoding === "geneSelection") {
251089
+ if (!hasFeatureSelection) {
251090
+ pointsLegendElements.push({
251091
+ name: obsLabel,
251092
+ color: staticColor
251093
+ });
251094
+ } else {
251095
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
251096
+ limitedFeatureSelection.forEach((featureName) => {
251097
+ const featureColorMatch = Array.isArray(featureColor) ? featureColor.find((fc) => fc.name === featureName)?.color : null;
251098
+ pointsLegendElements.push({
251099
+ name: featureName,
251100
+ // If no color is specified for this feature, use staticColor.
251101
+ color: featureColorMatch ?? staticColor
251102
+ });
251103
+ });
251104
+ }
251105
+ } else if (obsColorEncoding === "randomByFeature") {
251106
+ if (!hasFeatureSelection) {
251107
+ pointsLegendElements.push({
251108
+ name: obsLabel,
251109
+ // For now, using black and white for this.
251110
+ // (It should not match any color in PALETTE)
251111
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
251112
+ });
251113
+ } else {
251114
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
251115
+ limitedFeatureSelection.forEach((featureName) => {
251116
+ const varIndex = (featureIndex ?? []).indexOf(featureName);
251117
+ const featureColorMatch = varIndex >= 0 ? PALETTE[varIndex % PALETTE.length] : null;
251118
+ pointsLegendElements.push({
251119
+ name: featureName,
251120
+ // If no color is specified for this feature, use staticColor.
251121
+ color: featureColorMatch ?? staticColor
251122
+ });
251123
+ });
251124
+ }
251125
+ } else if (obsColorEncoding === "random") {
251126
+ pointsLegendElements.push({
251127
+ name: obsLabel,
251128
+ // For now, using black and white for this.
251129
+ // (It should not match any color in PALETTE)
251130
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
251131
+ });
251132
+ }
251133
+ if (showUnselected) {
251134
+ pointsLegendElements.push({
251135
+ name: "Unselected",
251136
+ color: getDefaultColor(theme ?? "light")
251137
+ });
251138
+ }
251139
+ }
251015
251140
  const levelZeroNames = useMemo$1(() => Array.from(new Set(obsSetSelection?.map((setPath) => setPath[0]) || [])), [obsSetSelection]);
251016
- const dynamicHeight = isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + (obsSetSelection?.length ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0);
251141
+ const dynamicHeight = isPointsLayer ? (
251142
+ // Height logic for points layers.
251143
+ pointsLegendElements.length * (rectHeight + rectMarginY) + titleHeight
251144
+ ) : (
251145
+ // Height logic for non-points layers.
251146
+ isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + (obsSetSelection?.length ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0)
251147
+ );
251017
251148
  const availHeight = maxHeight2 !== null ? Math.max(0, maxHeight2 - 4) : Infinity;
251018
251149
  const needsScroll = Number.isFinite(availHeight) && dynamicHeight > availHeight + 1;
251019
251150
  useEffect(() => {
@@ -251025,8 +251156,8 @@ function Legend(props) {
251025
251156
  svg2.selectAll("g").remove();
251026
251157
  svg2.attr("width", width2).attr("height", dynamicHeight);
251027
251158
  const g2 = svg2.append("g").attr("width", width2).attr("height", dynamicHeight);
251028
- const showInteractiveSlider2 = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
251029
- if (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "")) {
251159
+ const showInteractiveSlider2 = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
251160
+ if (!isPointsLayer && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? ""))) {
251030
251161
  const combinedExtent = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null) || [0, 1];
251031
251162
  const [xMin, xMax] = combinedExtent;
251032
251163
  if (featureValueColormap && pointsVisible) {
@@ -251086,10 +251217,10 @@ function Legend(props) {
251086
251217
  });
251087
251218
  }
251088
251219
  }
251089
- if (isStaticColor) {
251220
+ if (!isPointsLayer && isStaticColor) {
251090
251221
  g2.append("rect").attr("x", 0).attr("y", titleHeight).attr("width", width2 - 4).attr("height", rectHeight).attr("fill", `rgb(${staticColor[0]},${staticColor[1]},${staticColor[2]})`);
251091
251222
  }
251092
- if (isSetColor && obsSetSelection && obsSetColor) {
251223
+ if (!isPointsLayer && isSetColor && obsSetSelection && obsSetColor) {
251093
251224
  const obsSetSelectionByLevelZero = {};
251094
251225
  obsSetSelection.forEach((setPath) => {
251095
251226
  const levelZeroName = setPath[0];
@@ -251110,6 +251241,16 @@ function Legend(props) {
251110
251241
  });
251111
251242
  });
251112
251243
  }
251244
+ if (isPointsLayer) {
251245
+ let y2 = 0;
251246
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", 0).attr("y", y2).text("Points").style("font-size", "9px").style("fill", foregroundColor);
251247
+ y2 += titleHeight;
251248
+ pointsLegendElements.forEach(({ name: name2, color: color2 }) => {
251249
+ g2.append("rect").attr("x", 0).attr("y", y2).attr("width", rectHeight).attr("height", rectHeight).attr("fill", `rgb(${color2[0]},${color2[1]},${color2[2]})`);
251250
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", rectHeight + rectMarginX).attr("y", y2).text(name2).style("font-size", "9px").style("fill", foregroundColor);
251251
+ y2 += rectHeight + rectMarginY;
251252
+ });
251253
+ }
251113
251254
  const featureSelectionLabelRaw = featureSelection && featureSelection.length >= 1 && !isStaticColor ? featureSelection.map((geneName) => featureLabelsMap?.get(geneName) || featureLabelsMap?.get(cleanFeatureId(geneName)) || geneName) : null;
251114
251255
  let featureSelectionLabelRawStr = "";
251115
251256
  if (featureAggregationStrategy === "first") {
@@ -251136,12 +251277,11 @@ function Legend(props) {
251136
251277
  }
251137
251278
  const combinedMissing = combineMissings(missing ?? null, featureAggregationStrategy ?? null);
251138
251279
  const featureSelectionLabel = combinedMissing ? `${featureSelectionLabelRawStr} (${Math.round(combinedMissing * 100)}% NaN)` : featureSelectionLabelRawStr;
251139
- const obsLabel = capitalize$3(obsType ?? null);
251140
251280
  const featureLabel = considerSelections ? featureSelectionLabel || capitalize$3(featureValueType ?? null) : capitalize$3(featureValueType ?? null);
251141
251281
  const mainLabel = showObsLabel ? obsLabel : featureLabel;
251142
251282
  const subLabel = showObsLabel ? featureLabel : null;
251143
251283
  const hasSubLabel = subLabel !== null;
251144
- if (!isSetColor) {
251284
+ if (!isPointsLayer && !isSetColor) {
251145
251285
  g2.append("text").attr("text-anchor", hasSubLabel ? "start" : "end").attr("dominant-baseline", "hanging").attr("x", hasSubLabel ? 0 : width2 - 4).attr("y", 0).text(mainLabel ?? "").style("font-size", "10px").style("fill", foregroundColor);
251146
251286
  if (hasSubLabel) {
251147
251287
  g2.append("text").attr("text-anchor", "end").attr("dominant-baseline", "hanging").attr("x", width2 - 5).attr("y", titleHeight + rectHeight).text(subLabel ?? "").style("font-size", "9px").style("fill", foregroundColor);
@@ -251180,7 +251320,7 @@ function Legend(props) {
251180
251320
  showObsLabel,
251181
251321
  staticColor
251182
251322
  ]);
251183
- const showInteractiveSlider = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
251323
+ const showInteractiveSlider = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
251184
251324
  const globalExtent = useMemo$1(() => {
251185
251325
  const combined = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null);
251186
251326
  return combined || [0, 1];
@@ -251253,7 +251393,8 @@ function MultiLegend(props) {
251253
251393
  spotMultiFeatureLabels,
251254
251394
  // Points
251255
251395
  pointLayerScopes,
251256
- pointLayerCoordination
251396
+ pointLayerCoordination,
251397
+ pointMultiIndicesData
251257
251398
  } = props;
251258
251399
  const { classes: classes2 } = useStyles$o();
251259
251400
  const reversedSegmentationLayerScopes = useMemo$1(() => [...segmentationLayerScopes || []].reverse(), [segmentationLayerScopes]);
@@ -251264,7 +251405,8 @@ function MultiLegend(props) {
251264
251405
  const layerSetters = pointLayerCoordination?.[1]?.[layerScope];
251265
251406
  if (!layerCoordination)
251266
251407
  return null;
251267
- const { spatialLayerVisible, obsColorEncoding, obsType, featureType, featureValueType, featureSelection, featureValueColormap, featureValueColormapRange, spatialLayerColor, legendVisible } = layerCoordination;
251408
+ const { spatialLayerVisible, obsColorEncoding, obsType, featureType, featureValueType, featureSelection, featureColor, featureFilterMode, featureValueColormap, featureValueColormapRange, spatialLayerColor, legendVisible } = layerCoordination;
251409
+ const pointIndicesData = pointMultiIndicesData?.[layerScope];
251268
251410
  const { setFeatureValueColormapRange } = layerSetters || {};
251269
251411
  const isStaticColor = obsColorEncoding === "spatialLayerColor";
251270
251412
  const height2 = isStaticColor ? 20 : 36;
@@ -251281,6 +251423,10 @@ function MultiLegend(props) {
251281
251423
  obsColorEncoding,
251282
251424
  spatialLayerColor,
251283
251425
  featureSelection,
251426
+ featureFilterMode,
251427
+ featureColor,
251428
+ featureIndex: pointIndicesData?.featureIndex,
251429
+ isPointsLayer: true,
251284
251430
  // featureLabelsMap={featureLabelsMap} // TODO
251285
251431
  featureValueColormap: featureValueColormap || "viridis",
251286
251432
  featureValueColormapRange: featureValueColormapRange || [0, 1],
@@ -268915,6 +269061,7 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
268915
269061
  this.obsSpotsQuadTree = {};
268916
269062
  this.obsPointsData = {};
268917
269063
  this.obsPointsQuadTree = {};
269064
+ this.obsPointsLoadingStatus = {};
268918
269065
  this.imageLayers = [];
268919
269066
  this.obsSegmentationsLayers = [];
268920
269067
  this.obsSpotsLayers = [];
@@ -269095,10 +269242,131 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
269095
269242
  });
269096
269243
  }
269097
269244
  createPointLayer(layerScope, layerCoordination, layerObsPoints) {
269098
- const { theme, delegateHover, targetZ } = this.props;
269099
- const { spatialLayerVisible, spatialLayerOpacity, obsColorEncoding, spatialLayerColor } = layerCoordination;
269100
- const isStaticColor = obsColorEncoding === "spatialLayerColor";
269245
+ const { theme, delegateHover, targetZ, pointMatrixIndices, setTiledPointsLoadingProgress } = this.props;
269246
+ const { spatialLayerVisible, spatialLayerOpacity, obsColorEncoding, spatialLayerColor, featureSelection, featureFilterMode, featureColor } = layerCoordination;
269247
+ const pointFeatureIndex = pointMatrixIndices?.[layerScope]?.featureIndex;
269248
+ let featureIndices = [];
269249
+ if (Array.isArray(featureSelection) && featureSelection.length >= 1) {
269250
+ if (pointFeatureIndex) {
269251
+ featureIndices = featureSelection.map((geneName) => pointFeatureIndex.indexOf(geneName)).filter((i2) => i2 >= 0);
269252
+ }
269253
+ }
269101
269254
  const staticColor = Array.isArray(spatialLayerColor) && spatialLayerColor.length === 3 ? spatialLayerColor : getDefaultColor(theme);
269255
+ const defaultColor = getDefaultColor(theme);
269256
+ let getFillColor = null;
269257
+ const hasFeatureSelection = Array.isArray(featureSelection) && featureSelection.length > 0;
269258
+ const showUnselected = featureFilterMode !== "featureSelection";
269259
+ const hasMultipleFeaturesSelected = Array.isArray(featureIndices) && featureIndices.length > 1;
269260
+ if (obsColorEncoding === "spatialLayerColor") {
269261
+ getFillColor = (object2, { index: index2, data: data2, target: target2 }) => {
269262
+ if (!hasFeatureSelection || featureIndices.includes(data2.src.featureIndices[index2])) {
269263
+ target2[0] = staticColor[0];
269264
+ target2[1] = staticColor[1];
269265
+ target2[2] = staticColor[2];
269266
+ target2[3] = 255;
269267
+ return target2;
269268
+ }
269269
+ if (!showUnselected) {
269270
+ if (hasMultipleFeaturesSelected) {
269271
+ target2[3] = 0;
269272
+ }
269273
+ return target2;
269274
+ }
269275
+ target2[0] = defaultColor[0];
269276
+ target2[1] = defaultColor[1];
269277
+ target2[2] = defaultColor[2];
269278
+ target2[3] = 255;
269279
+ return target2;
269280
+ };
269281
+ } else if (obsColorEncoding === "geneSelection") {
269282
+ getFillColor = (object2, { index: index2, data: data2, target: target2 }) => {
269283
+ if (!hasFeatureSelection) {
269284
+ target2[0] = staticColor[0];
269285
+ target2[1] = staticColor[1];
269286
+ target2[2] = staticColor[2];
269287
+ target2[3] = 255;
269288
+ return target2;
269289
+ }
269290
+ const isSelected = featureIndices.includes(data2.src.featureIndices[index2]);
269291
+ if (isSelected) {
269292
+ const featureName = pointFeatureIndex?.[data2.src.featureIndices[index2]];
269293
+ const featureColorMatch = Array.isArray(featureColor) ? featureColor.find((fc) => fc.name === featureName)?.color : null;
269294
+ if (featureColorMatch) {
269295
+ target2[0] = featureColorMatch[0];
269296
+ target2[1] = featureColorMatch[1];
269297
+ target2[2] = featureColorMatch[2];
269298
+ target2[3] = 255;
269299
+ return target2;
269300
+ }
269301
+ target2[0] = staticColor[0];
269302
+ target2[1] = staticColor[1];
269303
+ target2[2] = staticColor[2];
269304
+ target2[3] = 255;
269305
+ return target2;
269306
+ }
269307
+ if (!showUnselected) {
269308
+ if (hasMultipleFeaturesSelected) {
269309
+ target2[3] = 0;
269310
+ }
269311
+ return target2;
269312
+ }
269313
+ target2[0] = defaultColor[0];
269314
+ target2[1] = defaultColor[1];
269315
+ target2[2] = defaultColor[2];
269316
+ target2[3] = 255;
269317
+ return target2;
269318
+ };
269319
+ } else if (obsColorEncoding === "randomByFeature") {
269320
+ {
269321
+ getFillColor = (object2, { index: index2, data: data2, target: target2 }) => {
269322
+ if (!hasFeatureSelection || featureIndices.includes(data2.src.featureIndices[index2])) {
269323
+ const varIndex = data2.src.featureIndices[index2];
269324
+ const color2 = PALETTE[varIndex % PALETTE.length];
269325
+ target2[0] = color2[0];
269326
+ target2[1] = color2[1];
269327
+ target2[2] = color2[2];
269328
+ target2[3] = 255;
269329
+ return target2;
269330
+ }
269331
+ if (!showUnselected) {
269332
+ if (hasMultipleFeaturesSelected) {
269333
+ target2[3] = 0;
269334
+ }
269335
+ return target2;
269336
+ }
269337
+ target2[0] = defaultColor[0];
269338
+ target2[1] = defaultColor[1];
269339
+ target2[2] = defaultColor[2];
269340
+ target2[3] = 255;
269341
+ return target2;
269342
+ };
269343
+ }
269344
+ } else if (obsColorEncoding === "random") {
269345
+ {
269346
+ getFillColor = (object2, { index: index2, data: data2, target: target2 }) => {
269347
+ if (!hasFeatureSelection || featureIndices.includes(data2.src.featureIndices[index2])) {
269348
+ const color2 = PALETTE[index2 % PALETTE.length];
269349
+ target2[0] = color2[0];
269350
+ target2[1] = color2[1];
269351
+ target2[2] = color2[2];
269352
+ target2[3] = 255;
269353
+ return target2;
269354
+ }
269355
+ if (!showUnselected) {
269356
+ if (hasMultipleFeaturesSelected) {
269357
+ target2[3] = 0;
269358
+ }
269359
+ return target2;
269360
+ }
269361
+ target2[0] = defaultColor[0];
269362
+ target2[1] = defaultColor[1];
269363
+ target2[2] = defaultColor[2];
269364
+ target2[3] = 255;
269365
+ return target2;
269366
+ };
269367
+ }
269368
+ }
269369
+ const isStaticColor = obsColorEncoding === "spatialLayerColor";
269102
269370
  const getMoleculeColor = (object2, { data: data2, index: index2, target: target2 }) => {
269103
269371
  const obsId = data2.src.obsIndex[index2];
269104
269372
  if (data2.src.obsLabelsMap && data2.src.uniqueObsLabels && data2.src.PALETTE) {
@@ -269110,11 +269378,131 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
269110
269378
  }
269111
269379
  return target2;
269112
269380
  };
269113
- const { obsPointsModelMatrix, obsPoints } = this.obsPointsData?.[layerScope]?.src ?? {};
269114
- const hasZ = obsPoints?.shape?.[0] === 3;
269381
+ const { obsPointsModelMatrix, obsPoints, obsPointsTilingType, loadPointsInRect } = this.obsPointsData?.[layerScope]?.src ?? {};
269382
+ obsPoints?.shape?.[0] === 3;
269115
269383
  const modelMatrix2 = obsPointsModelMatrix?.clone();
269116
- if (hasZ && typeof targetZ !== "number") {
269117
- log$c.warn("Spatial: targetZ is not a number, so the point layer will not be filtered by Z.");
269384
+ if (obsPointsTilingType === "tiled") {
269385
+ return new TileLayer({
269386
+ id: `Tiled-${POINT_LAYER_PREFIX}${layerScope}`,
269387
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
269388
+ // NOTE: picking is not working due to https://github.com/vitessce/vitessce/issues/2039
269389
+ modelMatrix: modelMatrix2,
269390
+ pickable: true,
269391
+ autoHighlight: true,
269392
+ onHover: (info2) => delegateHover(info2, "point", layerScope),
269393
+ opacity: spatialLayerOpacity,
269394
+ visible: spatialLayerVisible,
269395
+ // Since points are tiled but not multi-resolution,
269396
+ // it provides no benefit to request tiles at different zoom levels.
269397
+ // TODO: Should this value be the same for
269398
+ // every dataset, or do we need to
269399
+ // adjust based on the extent/density of the
269400
+ // point data (and/or account for modelMatrix, etc)?
269401
+ maxZoom: -1,
269402
+ minZoom: -1,
269403
+ tileSize: 512,
269404
+ // refinementStrategy: 'no-overlap',
269405
+ getTileData: async (tileInfo) => {
269406
+ const { index: index2, signal, bbox: bbox2, zoom: zoom2 } = tileInfo;
269407
+ const { z: z2, x: x2, y: y2 } = index2;
269408
+ this.obsPointsLoadingStatus = {
269409
+ ...this.obsPointsLoadingStatus,
269410
+ [`${layerScope}-${z2}-${x2}-${y2}`]: "loading"
269411
+ };
269412
+ setTiledPointsLoadingProgress(this.obsPointsLoadingStatus);
269413
+ signal.addEventListener("abort", () => {
269414
+ this.obsPointsLoadingStatus = {
269415
+ ...this.obsPointsLoadingStatus,
269416
+ [`${layerScope}-${z2}-${x2}-${y2}`]: "aborted"
269417
+ };
269418
+ setTiledPointsLoadingProgress(this.obsPointsLoadingStatus);
269419
+ });
269420
+ const pointsInTile = await loadPointsInRect(bbox2, signal);
269421
+ this.obsPointsLoadingStatus = {
269422
+ ...this.obsPointsLoadingStatus,
269423
+ [`${layerScope}-${z2}-${x2}-${y2}`]: "success"
269424
+ };
269425
+ setTiledPointsLoadingProgress(this.obsPointsLoadingStatus);
269426
+ return {
269427
+ src: pointsInTile.data,
269428
+ length: pointsInTile.shape?.[1] || 0
269429
+ };
269430
+ },
269431
+ renderSubLayers: (subLayerProps) => {
269432
+ const { bbox: bbox2, content: tileData } = subLayerProps.tile;
269433
+ const { left: left2, top: top2, right: right2, bottom: bottom2 } = bbox2;
269434
+ const hasFeatureIndicesMinMax = !showUnselected && Array.isArray(featureIndices) && featureIndices.length === 1;
269435
+ const FILTER_PLACEHOLDER = 0;
269436
+ const featureIndicesMinMax = hasFeatureIndicesMinMax ? [featureIndices[0], featureIndices[0]] : [FILTER_PLACEHOLDER, FILTER_PLACEHOLDER];
269437
+ return new ScatterplotLayer(subLayerProps, {
269438
+ bounds: [left2, top2, right2, bottom2],
269439
+ data: tileData,
269440
+ getRadius: 5,
269441
+ radiusMaxPixels: 3,
269442
+ // getPosition: d => d,
269443
+ // getFillColor: [255, 0, 0],
269444
+ getPosition: (object2, { data: data2, index: index2, target: target2 }) => {
269445
+ target2[0] = data2.src.x[index2];
269446
+ target2[1] = data2.src.y[index2];
269447
+ target2[2] = 0;
269448
+ return target2;
269449
+ },
269450
+ getFillColor,
269451
+ // TODO: Is the picking stuff needed here in the Sublayer, or in the parent TileLayer?
269452
+ pickable: true,
269453
+ autoHighlight: true,
269454
+ onHover: (info2) => delegateHover(info2, "point", layerScope),
269455
+ // Use GPU filtering to filter to only the points in the tile bounding box,
269456
+ // since the row groups may contain points from other tiles.
269457
+ // Note: this can be improved using filterCategories,
269458
+ // but it is not available until post-v9 deck.gl/extensions.
269459
+ filterRange: [[left2, right2], [top2, bottom2], featureIndicesMinMax],
269460
+ getFilterValue: hasFeatureIndicesMinMax ? (object2, { data: data2, index: index2 }) => [
269461
+ data2.src.x[index2],
269462
+ data2.src.y[index2],
269463
+ data2.src.featureIndices[index2]
269464
+ ] : (object2, { data: data2, index: index2 }) => [
269465
+ data2.src.x[index2],
269466
+ data2.src.y[index2],
269467
+ FILTER_PLACEHOLDER
269468
+ ],
269469
+ extensions: [
269470
+ new DataFilterExtension({ filterSize: 3 })
269471
+ ],
269472
+ updateTriggers: {
269473
+ getFillColor: [
269474
+ showUnselected,
269475
+ featureColor,
269476
+ obsColorEncoding,
269477
+ spatialLayerColor,
269478
+ featureSelection,
269479
+ hasMultipleFeaturesSelected
269480
+ ],
269481
+ getFilterValue: [hasFeatureIndicesMinMax, showUnselected, featureSelection],
269482
+ filterRange: [hasFeatureIndicesMinMax, showUnselected, featureSelection]
269483
+ }
269484
+ });
269485
+ },
269486
+ updateTriggers: {
269487
+ getTileData: [
269488
+ showUnselected,
269489
+ featureColor,
269490
+ obsColorEncoding,
269491
+ spatialLayerColor,
269492
+ featureSelection,
269493
+ hasMultipleFeaturesSelected
269494
+ ]
269495
+ }
269496
+ /*
269497
+ onTileError: (error) => {
269498
+
269499
+ },
269500
+ onViewportLoad: (loadedTiles) => {
269501
+ // Called when all tiles in the current viewport are loaded.
269502
+ // An array of loaded Tile instances are passed as argument to this function.
269503
+ },
269504
+ */
269505
+ });
269118
269506
  }
269119
269507
  return new ScatterplotLayer({
269120
269508
  id: `${POINT_LAYER_PREFIX}${layerScope}`,
@@ -269141,16 +269529,7 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
269141
269529
  getFillColor: [obsColorEncoding, staticColor],
269142
269530
  getLineColor: [obsColorEncoding, staticColor]
269143
269531
  },
269144
- ...hasZ && typeof targetZ === "number" ? {
269145
- // TODO: support targetT filtering as well.
269146
- // TODO: allow filtering by Z coordinate (rather than slice index)
269147
- // Reference: https://github.com/vitessce/vitessce/issues/2194
269148
- filterRange: [targetZ, targetZ],
269149
- getFilterValue: (object2, { data: data2, index: index2 }) => data2.src.obsPoints.data[2][index2],
269150
- extensions: [
269151
- new DataFilterExtension({ filterSize: 1 })
269152
- ]
269153
- } : {}
269532
+ ...{}
269154
269533
  });
269155
269534
  }
269156
269535
  createSelectionLayer() {
@@ -269690,28 +270069,45 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
269690
270069
  }
269691
270070
  onUpdatePointsData(layerScope) {
269692
270071
  const { obsPoints, pointMultiObsLabels } = this.props;
269693
- const { obsIndex, obsPoints: layerObsPoints, obsPointsModelMatrix } = obsPoints?.[layerScope] || {};
270072
+ const { obsIndex, obsPoints: layerObsPoints, obsPointsModelMatrix, loadPointsInRect, obsPointsTilingType } = obsPoints?.[layerScope] || {};
269694
270073
  const { obsIndex: obsLabelsIndex, obsLabels } = pointMultiObsLabels?.[layerScope] || {};
269695
- if (layerObsPoints) {
269696
- const getCellCoords = makeDefaultGetObsCoords(layerObsPoints);
269697
- this.obsPointsQuadTree[layerScope] = createQuadTree(layerObsPoints, getCellCoords);
270074
+ if (obsPointsTilingType === "tiled") {
269698
270075
  this.obsPointsData[layerScope] = {
269699
270076
  src: {
269700
- obsIndex,
269701
- obsPoints: layerObsPoints,
270077
+ obsPointsTilingType,
270078
+ obsIndex: null,
270079
+ obsPoints: null,
269702
270080
  obsPointsModelMatrix,
269703
270081
  obsLabelsMap: null,
269704
270082
  uniqueObsLabels: null,
269705
- PALETTE: null
270083
+ PALETTE: null,
270084
+ loadPointsInRect
269706
270085
  },
269707
- length: layerObsPoints.shape[1]
270086
+ length: null
269708
270087
  };
269709
- if (obsLabels) {
269710
- const obsLabelsMap = new Map(obsLabelsIndex.map((key2, i2) => [key2, obsLabels[i2]]));
269711
- const uniqueObsLabels = Array.from(new Set(obsLabels));
269712
- this.obsPointsData[layerScope].src.obsLabelsMap = obsLabelsMap;
269713
- this.obsPointsData[layerScope].src.uniqueObsLabels = uniqueObsLabels;
269714
- this.obsPointsData[layerScope].src.PALETTE = PALETTE;
270088
+ } else {
270089
+ if (layerObsPoints) {
270090
+ const getCellCoords = makeDefaultGetObsCoords(layerObsPoints);
270091
+ this.obsPointsQuadTree[layerScope] = createQuadTree(layerObsPoints, getCellCoords);
270092
+ this.obsPointsData[layerScope] = {
270093
+ src: {
270094
+ obsPointsTilingType,
270095
+ obsIndex,
270096
+ obsPoints: layerObsPoints,
270097
+ obsPointsModelMatrix,
270098
+ obsLabelsMap: null,
270099
+ uniqueObsLabels: null,
270100
+ PALETTE: null
270101
+ },
270102
+ length: layerObsPoints.shape[1]
270103
+ };
270104
+ if (obsLabels) {
270105
+ const obsLabelsMap = new Map(obsLabelsIndex.map((key2, i2) => [key2, obsLabels[i2]]));
270106
+ const uniqueObsLabels = Array.from(new Set(obsLabels));
270107
+ this.obsPointsData[layerScope].src.obsLabelsMap = obsLabelsMap;
270108
+ this.obsPointsData[layerScope].src.uniqueObsLabels = uniqueObsLabels;
270109
+ this.obsPointsData[layerScope].src.PALETTE = PALETTE;
270110
+ }
269715
270111
  }
269716
270112
  }
269717
270113
  }
@@ -269920,6 +270316,7 @@ class Spatial2 extends AbstractSpatialOrScatterplot {
269920
270316
  // Data props.
269921
270317
  "obsPoints",
269922
270318
  "pointMultiObsLabels",
270319
+ "pointMatrixIndices",
269923
270320
  // Coordination props.
269924
270321
  "pointLayerScopes",
269925
270322
  "pointLayerCoordination"
@@ -270074,12 +270471,12 @@ class ErrorBoundary2 extends React__default.Component {
270074
270471
  }
270075
270472
  }
270076
270473
  const LazySpatialThree = React__default.lazy(async () => {
270077
- const { SpatialWrapper: SpatialWrapper2 } = await import("./index-DAHRuzlP.js");
270474
+ const { SpatialWrapper: SpatialWrapper2 } = await import("./index-Rt4Kn4Ra.js");
270078
270475
  return { default: SpatialWrapper2 };
270079
270476
  });
270080
270477
  const SpatialThreeAdapter = React__default.forwardRef((props, ref2) => jsxRuntimeExports.jsx("div", { ref: ref2, style: { width: "100%", height: "100%" }, children: jsxRuntimeExports.jsx(ErrorBoundary2, { children: jsxRuntimeExports.jsx(Suspense, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(LazySpatialThree, { ...props }) }) }) }));
270081
270478
  const LazySpatialAccelerated = React__default.lazy(async () => {
270082
- const { SpatialWrapper: SpatialWrapper2 } = await import("./index-hfBQsjWd.js");
270479
+ const { SpatialWrapper: SpatialWrapper2 } = await import("./index-ByJRcSWV.js");
270083
270480
  return { default: SpatialWrapper2 };
270084
270481
  });
270085
270482
  const SpatialAcceleratedAdapter = React__default.forwardRef((props, ref2) => jsxRuntimeExports.jsx("div", { ref: ref2, style: { width: "100%", height: "100%" }, children: jsxRuntimeExports.jsx(ErrorBoundary2, { children: jsxRuntimeExports.jsx(Suspense, { fallback: jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: jsxRuntimeExports.jsx(LazySpatialAccelerated, { ...props }) }) }) }));
@@ -270194,12 +270591,22 @@ const DEFAULT_VIEW_STATE = {
270194
270591
  const SET_VIEW_STATE_NOOP = () => {
270195
270592
  };
270196
270593
  function getHoverData(hoverInfo, layerType) {
270197
- const { coordinate, sourceLayer: layer, tile } = hoverInfo;
270198
- if (layerType === "segmentation-bitmask" || layerType === "image") {
270594
+ const { coordinate, sourceLayer: layer, tile, index: pointIndex } = hoverInfo;
270595
+ if (layerType === "segmentation-bitmask" || layerType === "image" || layerType === "point") {
270199
270596
  if (coordinate && layer) {
270200
270597
  if (layer.id.startsWith("Tiled") && tile) {
270201
270598
  const { content: content2, bbox: bbox2, index: { z: z2 } } = tile;
270202
270599
  if (content2) {
270600
+ if (layerType === "point" && pointIndex >= 0) {
270601
+ const { src } = content2 || {};
270602
+ const { x: x2, y: y2, featureIndices } = src || {};
270603
+ return {
270604
+ pointIndex,
270605
+ x: x2?.[pointIndex],
270606
+ y: y2?.[pointIndex],
270607
+ featureIndex: featureIndices?.[pointIndex]
270608
+ };
270609
+ }
270203
270610
  const { data: data2, width: width2, height: height2 } = content2;
270204
270611
  const { left: left2, right: right2, top: top2, bottom: bottom2 } = bbox2;
270205
270612
  const bounds2 = [
@@ -270377,6 +270784,8 @@ function SpatialSubscriber(props) {
270377
270784
  CoordinationType$2.SPATIAL_LAYER_VISIBLE,
270378
270785
  CoordinationType$2.SPATIAL_LAYER_OPACITY,
270379
270786
  CoordinationType$2.OBS_COLOR_ENCODING,
270787
+ CoordinationType$2.FEATURE_COLOR,
270788
+ CoordinationType$2.FEATURE_FILTER_MODE,
270380
270789
  CoordinationType$2.FEATURE_SELECTION,
270381
270790
  CoordinationType$2.FEATURE_VALUE_COLORMAP,
270382
270791
  CoordinationType$2.FEATURE_VALUE_COLORMAP_RANGE,
@@ -270387,7 +270796,10 @@ function SpatialSubscriber(props) {
270387
270796
  CoordinationType$2.LEGEND_VISIBLE
270388
270797
  ], coordinationScopes, coordinationScopesBy, CoordinationType$2.POINT_LAYER);
270389
270798
  const [volumeLoadingStatus, setVolumeLoadingStatus] = useState(null);
270390
- const [{ volumeLoadingProgress }, { setVolumeLoadingProgress }] = useAuxiliaryCoordination(["spatialAcceleratedVolumeLoadingProgress"], coordinationScopes);
270799
+ const [{ volumeLoadingProgress, tiledPointsLoadingProgress }, { setVolumeLoadingProgress, setTiledPointsLoadingProgress }] = useAuxiliaryCoordination([
270800
+ "spatialAcceleratedVolumeLoadingProgress",
270801
+ "spatialTiledPointsLoadingProgress"
270802
+ ], coordinationScopes);
270391
270803
  useEffect(() => {
270392
270804
  if (volumeLoadingStatus && volumeLoadingStatus.loadingProgress) {
270393
270805
  setVolumeLoadingProgress(volumeLoadingStatus);
@@ -270404,6 +270816,7 @@ function SpatialSubscriber(props) {
270404
270816
  const height2 = threeFor3d && deckHeight === void 0 ? threeHeight : deckHeight;
270405
270817
  const [obsPointsData, obsPointsDataStatus, obsPointsUrls, obsPointsErrors] = useMultiObsPoints(coordinationScopes, coordinationScopesBy, loaders, dataset, mergeCoordination, uuid2);
270406
270818
  const [pointMultiObsLabelsData, pointMultiObsLabelsDataStatus, pointMultiObsLabelsErrors] = usePointMultiObsLabels(coordinationScopes, coordinationScopesBy, loaders, dataset);
270819
+ const [pointMultiIndicesData, pointMultiIndicesDataStatus, pointMultiIndicesDataErrors] = usePointMultiObsFeatureMatrixIndices(coordinationScopes, coordinationScopesBy, loaders, dataset);
270407
270820
  const [obsSpotsData, obsSpotsDataStatus, obsSpotsUrls, obsSpotsErrors] = useMultiObsSpots(coordinationScopes, coordinationScopesBy, loaders, dataset, mergeCoordination, uuid2);
270408
270821
  const [obsSpotsSetsData, obsSpotsSetsDataStatus, obsSpotSetsUrls, obsSpotsSetsErrors] = useSpotMultiObsSets(coordinationScopes, coordinationScopesBy, loaders, dataset);
270409
270822
  const [obsSpotsFeatureLabelsData, obsSpotsFeatureLabelsDataStatus, obsSpotsFeatureLabelsUrls, obsSpotsFeatureLabelsErrors] = useSpotMultiFeatureLabels(coordinationScopes, coordinationScopesBy, loaders, dataset);
@@ -270437,6 +270850,7 @@ function SpatialSubscriber(props) {
270437
270850
  ...spotMultiFeatureSelectionErrors,
270438
270851
  ...spotMultiIndicesDataErrors,
270439
270852
  ...pointMultiObsLabelsErrors,
270853
+ ...pointMultiIndicesDataErrors,
270440
270854
  ...segmentationMultiFeatureSelectionErrors,
270441
270855
  ...segmentationMultiIndicesDataErrors,
270442
270856
  ...obsSegmentationsLocationsDataErrors
@@ -270456,6 +270870,7 @@ function SpatialSubscriber(props) {
270456
270870
  // Points
270457
270871
  obsPointsDataStatus,
270458
270872
  pointMultiObsLabelsDataStatus,
270873
+ pointMultiIndicesDataStatus,
270459
270874
  // Segmentations
270460
270875
  obsSegmentationsDataStatus,
270461
270876
  obsSegmentationsSetsDataStatus,
@@ -270643,14 +271058,19 @@ function SpatialSubscriber(props) {
270643
271058
  pointLayerScopes?.forEach((pointLayerScope) => {
270644
271059
  const { setObsHighlight } = pointLayerCoordination?.[1]?.[pointLayerScope] || {};
270645
271060
  if (hoverData && layerType === "point" && layerScope === pointLayerScope) {
270646
- const obsI = hoverData;
270647
- const { obsIndex } = obsPointsData?.[pointLayerScope] || {};
270648
- const obsId = obsIndex?.[obsI];
270649
- if (obsIndex && obsId) {
271061
+ if (typeof hoverData === "object" && hoverData?.pointIndex) {
270650
271062
  showAnyTooltip = true;
270651
- setObsHighlight(obsId);
271063
+ setObsHighlight(hoverData.pointIndex);
270652
271064
  } else {
270653
- setObsHighlight(null);
271065
+ const obsI = hoverData;
271066
+ const { obsIndex } = obsPointsData?.[pointLayerScope] || {};
271067
+ const obsId = obsIndex?.[obsI];
271068
+ if (obsIndex && obsId) {
271069
+ showAnyTooltip = true;
271070
+ setObsHighlight(obsId);
271071
+ } else {
271072
+ setObsHighlight(null);
271073
+ }
270654
271074
  }
270655
271075
  } else {
270656
271076
  setObsHighlight(null);
@@ -270692,7 +271112,7 @@ function SpatialSubscriber(props) {
270692
271112
  target: [targetX2, targetY2, targetZ],
270693
271113
  rotationX,
270694
271114
  rotationOrbit
270695
- } : DEFAULT_VIEW_STATE, orbitAxis, spatialAxisFixed, setViewState: isValidViewState ? setViewState : SET_VIEW_STATE_NOOP, originalViewState, spatialRenderingMode, updateViewInfo: setComponentViewInfo, delegateHover, obsPoints: obsPointsData, pointLayerScopes, pointLayerCoordination, pointMultiObsLabels: pointMultiObsLabelsData, obsSpots: obsSpotsData, spotLayerScopes, spotLayerCoordination, obsSpotsSets: obsSpotsSetsData, spotMatrixIndices: spotMultiIndicesData, spotMultiExpressionData: spotMultiExpressionNormDataAggregated || spotMultiExpressionNormData, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, obsSegmentations: obsSegmentationsData, obsSegmentationsLocations: obsSegmentationsLocationsData, obsSegmentationsSets: obsSegmentationsSetsData, segmentationMatrixIndices: segmentationMultiIndicesData, segmentationMultiExpressionData: segmentationMultiExpressionNormDataAggregated || segmentationMultiExpressionNormData, bitmaskValueIsIndex, images: imageData, imageLayerScopes, imageLayerCoordination, imageChannelScopesByLayer, imageChannelCoordination }), !disableTooltip && jsxRuntimeExports.jsx(SpatialTooltipSubscriber, {
271115
+ } : DEFAULT_VIEW_STATE, orbitAxis, spatialAxisFixed, setViewState: isValidViewState ? setViewState : SET_VIEW_STATE_NOOP, originalViewState, spatialRenderingMode, updateViewInfo: setComponentViewInfo, delegateHover, obsPoints: obsPointsData, pointLayerScopes, pointLayerCoordination, pointMultiObsLabels: pointMultiObsLabelsData, pointMatrixIndices: pointMultiIndicesData, obsSpots: obsSpotsData, spotLayerScopes, spotLayerCoordination, obsSpotsSets: obsSpotsSetsData, spotMatrixIndices: spotMultiIndicesData, spotMultiExpressionData: spotMultiExpressionNormDataAggregated || spotMultiExpressionNormData, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, obsSegmentations: obsSegmentationsData, obsSegmentationsLocations: obsSegmentationsLocationsData, obsSegmentationsSets: obsSegmentationsSetsData, segmentationMatrixIndices: segmentationMultiIndicesData, segmentationMultiExpressionData: segmentationMultiExpressionNormDataAggregated || segmentationMultiExpressionNormData, bitmaskValueIsIndex, images: imageData, imageLayerScopes, imageLayerCoordination, imageChannelScopesByLayer, imageChannelCoordination, setTiledPointsLoadingProgress }), !disableTooltip && jsxRuntimeExports.jsx(SpatialTooltipSubscriber, {
270696
271116
  parentUuid: uuid2,
270697
271117
  width: width2,
270698
271118
  height: height2,
@@ -270733,7 +271153,8 @@ function SpatialSubscriber(props) {
270733
271153
  spotMultiFeatureLabels: obsSpotsFeatureLabelsData,
270734
271154
  // Points
270735
271155
  pointLayerScopes,
270736
- pointLayerCoordination
271156
+ pointLayerCoordination,
271157
+ pointMultiIndicesData
270737
271158
  }
270738
271159
  ), jsxRuntimeExports.jsx(
270739
271160
  ChannelNamesLegend,
@@ -279695,17 +280116,35 @@ function SpotLayerController(props) {
279695
280116
  return jsxRuntimeExports.jsx(Grid$1, { className: lcClasses.layerControllerGrid, children: jsxRuntimeExports.jsx(Paper, { elevation: 4, className: lcClasses.layerControllerRoot, children: jsxRuntimeExports.jsxs(Grid$1, { container: true, direction: "row", justifyContent: "space-between", children: [jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(Button, { onClick: handleVisibleChange, className: menuClasses.imageLayerVisibleButton, "aria-label": "Toggle spot layer visibility", children: jsxRuntimeExports.jsx(Visibility, {}) }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(ChannelColorPickerMenu, { theme, color: color2, setColor: setColor2, palette, isStaticColor, isColormap, featureValueColormap, visible }) }), jsxRuntimeExports.jsx(Grid$1, { size: 6, children: jsxRuntimeExports.jsx(Typography, { className: menuClasses.imageLayerName, children: label2 }) }), jsxRuntimeExports.jsx(Grid$1, { size: 2, children: jsxRuntimeExports.jsx(Slider, { value: opacity2, min: 0, max: 1, step: 1e-3, onChange: handleOpacityChange, className: menuClasses.imageLayerOpacitySlider, orientation: "horizontal", "aria-label": `Adjust opacity for layer ${label2}` }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(SpotLayerEllipsisMenu, { filled, setFilled, strokeWidth, setStrokeWidth, featureSelection, obsColorEncoding, setObsColorEncoding, featureValueColormap, setFeatureValueColormap, featureValueColormapRange, setFeatureValueColormapRange, tooltipsVisible, setTooltipsVisible, tooltipCrosshairsVisible, setTooltipCrosshairsVisible, legendVisible, setLegendVisible }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(SvgSpots, { className: classes2.layerTypeSpotIcon }) })] }) }) });
279696
280117
  }
279697
280118
  const useStyles$e = makeStyles()(() => ({
280119
+ pointLayerButton: {
280120
+ borderStyle: "dashed",
280121
+ marginTop: "10px",
280122
+ marginBottom: "10px",
280123
+ fontWeight: 400
280124
+ },
280125
+ pointFeatureControllerGrid: {
280126
+ padding: "0",
280127
+ flexWrap: "nowrap"
280128
+ },
280129
+ pointFeatureExpansionButton: {
280130
+ display: "inline-block",
280131
+ margin: 0,
280132
+ padding: 0,
280133
+ minWidth: 0,
280134
+ lineHeight: 1,
280135
+ width: "50%"
280136
+ },
279698
280137
  layerTypePointIcon: {
279699
280138
  height: "100%",
279700
- marginLeft: "1px",
280139
+ paddingLeft: "2px",
279701
280140
  fill: "currentColor",
279702
- fontSize: "20px",
280141
+ fontSize: "14px",
279703
280142
  width: "50%",
279704
- maxWidth: "20px"
280143
+ maxWidth: "16px"
279705
280144
  }
279706
280145
  }));
279707
280146
  function PointLayerEllipsisMenu(props) {
279708
- const { featureSelection, obsColorEncoding, setObsColorEncoding, featureValueColormapRange, setFeatureValueColormapRange, tooltipsVisible, setTooltipsVisible, tooltipCrosshairsVisible, setTooltipCrosshairsVisible, legendVisible, setLegendVisible } = props;
280147
+ const { featureSelection, featureFilterMode, setFeatureFilterMode, obsColorEncoding, setObsColorEncoding, featureValueColormapRange, setFeatureValueColormapRange, tooltipsVisible, setTooltipsVisible, tooltipCrosshairsVisible, setTooltipCrosshairsVisible, legendVisible, setLegendVisible } = props;
279709
280148
  const [open2, setOpen] = useState(false);
279710
280149
  const { classes: selectClasses2 } = useSelectStyles();
279711
280150
  const { classes: menuClasses } = useEllipsisMenuStyles();
@@ -279714,17 +280153,84 @@ function PointLayerEllipsisMenu(props) {
279714
280153
  const tooltipsVisibleId = $bdb11010cef70236$export$f680877a34711e37();
279715
280154
  const crosshairsVisibleId = $bdb11010cef70236$export$f680877a34711e37();
279716
280155
  const legendVisibleId = $bdb11010cef70236$export$f680877a34711e37();
279717
- return jsxRuntimeExports.jsxs(PopperMenu, { open: open2, setOpen, buttonIcon: jsxRuntimeExports.jsx(MoreVertIcon, {}), buttonClassName: menuClasses.imageLayerMenuButton, containerClassName: menuClasses.imageLayerPopperContainer, withPaper: true, "aria-label": "Open point layer options menu", children: [jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: quantitativeColormapId, children: "Color Encoding: " }), jsxRuntimeExports.jsxs(NativeSelect, { onChange: (e3) => setObsColorEncoding(e3.target.value), value: obsColorEncoding, inputProps: { id: quantitativeColormapId, "aria-label": "Color encoding selector" }, classes: { root: selectClasses2.selectRoot }, children: [jsxRuntimeExports.jsx("option", { value: "spatialLayerColor", children: "Static Color" }), jsxRuntimeExports.jsx("option", { value: "obsLabels", children: "Label Value" })] })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: colormapRangeId, children: "Colormap Range: " }), jsxRuntimeExports.jsx(Slider, { disabled: obsColorEncoding !== "geneSelection", value: featureValueColormapRange, min: 0, max: 1, step: 0.01, onChange: (e3, v) => setFeatureValueColormapRange(v), className: menuClasses.menuItemSlider, orientation: "horizontal", id: colormapRangeId, getAriaLabel: (index2) => index2 === 0 ? "Low value colormap range slider" : "High value colormap range slider" })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: tooltipsVisibleId, children: "Tooltips Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: tooltipsVisible, onChange: (e3, v) => setTooltipsVisible(v), slotProps: { input: { id: tooltipsVisibleId, "aria-label": "Toggle tooltip visibility" } } })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: crosshairsVisibleId, children: "Tooltip Crosshairs Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: tooltipCrosshairsVisible, onChange: (e3, v) => setTooltipCrosshairsVisible(v), slotProps: { input: { id: crosshairsVisibleId, "aria-label": "Toggle tooltip crosshair visibility" } } })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: legendVisibleId, children: "Legend Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: legendVisible, onChange: (e3, v) => setLegendVisible(v), slotProps: { input: { id: legendVisibleId, "aria-label": "Toggle legend visibility" } } })] })] });
280156
+ const featureFilterModeId = $bdb11010cef70236$export$f680877a34711e37();
280157
+ return jsxRuntimeExports.jsxs(PopperMenu, { open: open2, setOpen, buttonIcon: jsxRuntimeExports.jsx(MoreVertIcon, {}), buttonClassName: menuClasses.imageLayerMenuButton, containerClassName: menuClasses.imageLayerPopperContainer, withPaper: true, "aria-label": "Open point layer options menu", children: [jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: quantitativeColormapId, children: "Color Encoding: " }), jsxRuntimeExports.jsxs(NativeSelect, { onChange: (e3) => setObsColorEncoding(e3.target.value), value: obsColorEncoding, inputProps: { id: quantitativeColormapId, "aria-label": "Color encoding selector" }, classes: { root: selectClasses2.selectRoot }, children: [jsxRuntimeExports.jsx("option", { value: "spatialLayerColor", children: "Static Color" }), jsxRuntimeExports.jsx("option", { value: "geneSelection", children: "Feature Color" }), jsxRuntimeExports.jsx("option", { value: "randomByFeature", children: "Random Color per Feature" }), jsxRuntimeExports.jsx("option", { value: "random", children: "Random Color per Point" })] })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: featureFilterModeId, children: "Filter to Feature Selection: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: featureFilterMode === "featureSelection", onChange: (e3, v) => setFeatureFilterMode(v ? "featureSelection" : null), slotProps: { input: { id: featureFilterModeId, "aria-label": "Toggle feature filter mode" } } })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: colormapRangeId, children: "Colormap Range: " }), jsxRuntimeExports.jsx(Slider, { disabled: obsColorEncoding !== "geneSelection", value: featureValueColormapRange, min: 0, max: 1, step: 0.01, onChange: (e3, v) => setFeatureValueColormapRange(v), className: menuClasses.menuItemSlider, orientation: "horizontal", id: colormapRangeId, getAriaLabel: (index2) => index2 === 0 ? "Low value colormap range slider" : "High value colormap range slider" })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: tooltipsVisibleId, children: "Tooltips Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: tooltipsVisible, onChange: (e3, v) => setTooltipsVisible(v), slotProps: { input: { id: tooltipsVisibleId, "aria-label": "Toggle tooltip visibility" } } })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: crosshairsVisibleId, children: "Tooltip Crosshairs Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: tooltipCrosshairsVisible, onChange: (e3, v) => setTooltipCrosshairsVisible(v), slotProps: { input: { id: crosshairsVisibleId, "aria-label": "Toggle tooltip crosshair visibility" } } })] }), jsxRuntimeExports.jsxs(MenuItem, { dense: true, disableGutters: true, children: [jsxRuntimeExports.jsx("label", { className: menuClasses.imageLayerMenuLabel, htmlFor: legendVisibleId, children: "Legend Visible: " }), jsxRuntimeExports.jsx(Checkbox$1, { color: "primary", className: menuClasses.menuItemCheckbox, checked: legendVisible, onChange: (e3, v) => setLegendVisible(v), slotProps: { input: { id: legendVisibleId, "aria-label": "Toggle legend visibility" } } })] })] });
279718
280158
  }
279719
280159
  function PointLayerController(props) {
279720
- const { theme, layerScope, layerCoordination, setLayerCoordination, palette = null } = props;
279721
- const { obsType, spatialLayerVisible: visible, spatialLayerOpacity: opacity2, obsColorEncoding, featureSelection, featureValueColormap, featureValueColormapRange, spatialLayerColor: color2, tooltipsVisible, tooltipCrosshairsVisible, legendVisible } = layerCoordination;
279722
- const { setSpatialLayerVisible: setVisible, setSpatialLayerOpacity: setOpacity2, setObsColorEncoding, setFeatureSelection, setFeatureValueColormap, setFeatureValueColormapRange, setSpatialLayerColor: setColor2, setTooltipsVisible, setTooltipCrosshairsVisible, setLegendVisible } = setLayerCoordination;
280160
+ const { theme, layerScope, layerCoordination, setLayerCoordination, palette = null, pointMatrixIndicesData, tiledPointsLoadingProgress } = props;
280161
+ const [open2, setOpen] = useState(false);
280162
+ const loadingDoneFraction = useMemo$1(() => {
280163
+ if (tiledPointsLoadingProgress && typeof tiledPointsLoadingProgress === "object") {
280164
+ return 1 - Object.values(tiledPointsLoadingProgress).filter((status) => status === "loading").length / Object.values(tiledPointsLoadingProgress).length;
280165
+ }
280166
+ return 1;
280167
+ }, [tiledPointsLoadingProgress]);
280168
+ const { obsType, spatialLayerVisible: visible, spatialLayerOpacity: opacity2, obsColorEncoding, featureColor, featureFilterMode, featureSelection, featureValueColormap, featureValueColormapRange, spatialLayerColor, tooltipsVisible, tooltipCrosshairsVisible, legendVisible } = layerCoordination;
280169
+ const { setSpatialLayerVisible: setVisible, setSpatialLayerOpacity: setOpacity2, setObsColorEncoding, setFeatureColor, setFeatureFilterMode, setFeatureSelection, setFeatureValueColormap, setFeatureValueColormapRange, setSpatialLayerColor, setTooltipsVisible, setTooltipCrosshairsVisible, setLegendVisible } = setLayerCoordination;
279723
280170
  const label2 = capitalize$3(obsType);
279724
280171
  const visibleSetting = typeof visible === "boolean" ? visible : true;
279725
280172
  const Visibility = useMemo$1(() => visibleSetting ? VisibilityIcon : VisibilityOffIcon, [visibleSetting]);
279726
- const isStaticColor = obsColorEncoding === "spatialLayerColor";
279727
- const isColormap = obsColorEncoding === "geneSelection";
280173
+ const hasUnspecifiedFeatureColors = useMemo$1(() => {
280174
+ if (Array.isArray(featureSelection)) {
280175
+ if (Array.isArray(featureColor)) {
280176
+ return featureSelection.some((featureName) => {
280177
+ const colorForFeature = featureColor.find((fc) => fc.name === featureName);
280178
+ return !colorForFeature;
280179
+ });
280180
+ }
280181
+ return featureSelection.length > 0;
280182
+ }
280183
+ return true;
280184
+ }, [featureColor, featureSelection]);
280185
+ const isStaticColor = obsColorEncoding === "spatialLayerColor" || obsColorEncoding === "geneSelection";
280186
+ const showStaticColor = obsColorEncoding === "spatialLayerColor" || obsColorEncoding === "geneSelection" && hasUnspecifiedFeatureColors;
280187
+ const isColormap = false;
280188
+ const hasSingleSelectedFeature = obsColorEncoding === "geneSelection" && Array.isArray(featureSelection) && featureSelection.length === 1;
280189
+ const color2 = useMemo$1(() => {
280190
+ if (showStaticColor) {
280191
+ return spatialLayerColor;
280192
+ }
280193
+ if (hasSingleSelectedFeature) {
280194
+ const selectedFeatureColor = featureColor?.find((fc) => fc.name === featureSelection[0])?.color;
280195
+ if (selectedFeatureColor) {
280196
+ return selectedFeatureColor;
280197
+ }
280198
+ }
280199
+ return null;
280200
+ }, [
280201
+ hasSingleSelectedFeature,
280202
+ spatialLayerColor,
280203
+ featureColor,
280204
+ featureSelection,
280205
+ showStaticColor
280206
+ ]);
280207
+ const setColor2 = useCallback((newColor) => {
280208
+ if (showStaticColor) {
280209
+ setSpatialLayerColor(newColor);
280210
+ } else if (hasSingleSelectedFeature) {
280211
+ const featureColorIndex = featureColor?.findIndex((fc) => fc.name === featureSelection[0]);
280212
+ if (featureColorIndex !== void 0 && featureColorIndex >= 0) {
280213
+ const newFeatureColor = [...featureColor];
280214
+ newFeatureColor[featureColorIndex] = {
280215
+ name: featureSelection[0],
280216
+ color: newColor
280217
+ };
280218
+ setFeatureColor(newFeatureColor);
280219
+ } else {
280220
+ setFeatureColor([
280221
+ ...featureColor,
280222
+ { name: featureSelection[0], color: newColor }
280223
+ ]);
280224
+ }
280225
+ }
280226
+ }, [
280227
+ hasSingleSelectedFeature,
280228
+ setSpatialLayerColor,
280229
+ featureColor,
280230
+ setFeatureColor,
280231
+ featureSelection,
280232
+ showStaticColor
280233
+ ]);
279728
280234
  const { classes: classes2 } = useStyles$e();
279729
280235
  const { classes: lcClasses } = useControllerSectionStyles();
279730
280236
  const { classes: menuClasses } = useEllipsisMenuStyles();
@@ -279733,7 +280239,10 @@ function PointLayerController(props) {
279733
280239
  setVisible(nextVisible);
279734
280240
  }, [visible, setVisible]);
279735
280241
  const handleOpacityChange = useCallback((e3, v) => setOpacity2(v), [setOpacity2]);
279736
- return jsxRuntimeExports.jsx(Grid$1, { className: lcClasses.layerControllerGrid, children: jsxRuntimeExports.jsx(Paper, { elevation: 4, className: lcClasses.layerControllerRoot, children: jsxRuntimeExports.jsxs(Grid$1, { container: true, direction: "row", justifyContent: "space-between", children: [jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(Button, { onClick: handleVisibleChange, className: menuClasses.imageLayerVisibleButton, "aria-label": "Toggle layer visibility", children: jsxRuntimeExports.jsx(Visibility, {}) }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(ChannelColorPickerMenu, { theme, color: color2, setColor: setColor2, palette, isStaticColor, isColormap, featureValueColormap, visible }) }), jsxRuntimeExports.jsx(Grid$1, { size: 6, children: jsxRuntimeExports.jsx(Typography, { className: menuClasses.imageLayerName, children: label2 }) }), jsxRuntimeExports.jsx(Grid$1, { size: 2, children: jsxRuntimeExports.jsx(Slider, { value: opacity2, min: 0, max: 1, step: 1e-3, onChange: handleOpacityChange, className: menuClasses.imageLayerOpacitySlider, orientation: "horizontal", "aria-label": `Adjust opacity for layer ${label2}` }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(PointLayerEllipsisMenu, { featureSelection, obsColorEncoding, setObsColorEncoding, featureValueColormapRange, setFeatureValueColormapRange, tooltipsVisible, setTooltipsVisible, tooltipCrosshairsVisible, setTooltipCrosshairsVisible, legendVisible, setLegendVisible }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(SvgPoints, { className: classes2.layerTypePointIcon }) })] }) }) });
280242
+ useCallback(() => setOpen((prev2) => !prev2), []);
280243
+ const [coloringTabIndex, setColoringTabIndex] = useState(0);
280244
+ const { featureIndex } = pointMatrixIndicesData || {};
280245
+ return jsxRuntimeExports.jsx(Grid$1, { className: lcClasses.layerControllerGrid, children: jsxRuntimeExports.jsxs(Paper, { elevation: 4, className: lcClasses.layerControllerRoot, children: [jsxRuntimeExports.jsxs(Grid$1, { container: true, direction: "row", justifyContent: "space-between", children: [jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(Button, { onClick: handleVisibleChange, className: menuClasses.imageLayerVisibleButton, "aria-label": "Toggle layer visibility", children: jsxRuntimeExports.jsx(Visibility, {}) }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(ChannelColorPickerMenu, { theme, color: color2, setColor: setColor2, palette, isStaticColor, isColormap, featureValueColormap, visible }) }), jsxRuntimeExports.jsx(Grid$1, { size: 6, children: jsxRuntimeExports.jsx(Typography, { className: menuClasses.imageLayerName, children: label2 }) }), jsxRuntimeExports.jsx(Grid$1, { size: 2, children: jsxRuntimeExports.jsx(Slider, { value: opacity2, min: 0, max: 1, step: 1e-3, onChange: handleOpacityChange, className: menuClasses.imageLayerOpacitySlider, orientation: "horizontal", "aria-label": `Adjust opacity for layer ${label2}` }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(PointLayerEllipsisMenu, { featureSelection, obsColorEncoding, setObsColorEncoding, featureValueColormapRange, setFeatureValueColormapRange, tooltipsVisible, setTooltipsVisible, tooltipCrosshairsVisible, setTooltipCrosshairsVisible, legendVisible, setLegendVisible, featureFilterMode, setFeatureFilterMode }) }), jsxRuntimeExports.jsxs(Grid$1, { size: 1, container: true, direction: "row", children: [jsxRuntimeExports.jsx(SvgPoints, { className: classes2.layerTypePointIcon }), null] })] }), loadingDoneFraction < 1 ? jsxRuntimeExports.jsx(Grid$1, { size: 12, container: true, direction: "column", justifyContent: "space-between", className: classes2.pointFeatureControllerGrid, children: jsxRuntimeExports.jsx(LinearProgress, { variant: loadingDoneFraction === 0 ? "indeterminate" : "determinate", value: loadingDoneFraction * 100 }) }) : null, null] }) });
279737
280246
  }
279738
280247
  const useStyles$d = makeStyles()(() => ({
279739
280248
  layerTypeSegmentationIcon: {
@@ -280045,7 +280554,7 @@ function ImageLayerEllipsisMenu(props) {
280045
280554
  const { classes: selectClasses2 } = useSelectStyles();
280046
280555
  const { classes: menuClasses } = useEllipsisMenuStyles();
280047
280556
  const [localLodSliderValue, setLocalLodSliderValue] = useState(convertLodFactorToLogarithmicSliderValue(spatialLodFactor || 1));
280048
- React__default.useEffect(() => {
280557
+ useEffect(() => {
280049
280558
  setLocalLodSliderValue(convertLodFactorToLogarithmicSliderValue(spatialLodFactor || 1));
280050
280559
  }, [spatialLodFactor]);
280051
280560
  const is3dMode = spatialRenderingMode === "3D";
@@ -280181,7 +280690,7 @@ function GlobalDimensionSlider(props) {
280181
280690
  return jsxRuntimeExports.jsx(Grid$1, { className: lcClasses.layerControllerGrid, children: jsxRuntimeExports.jsx(Paper, { elevation: 4, className: lcClasses.layerControllerRoot, children: jsxRuntimeExports.jsxs(Grid$1, { container: true, direction: "row", justifyContent: "space-between", children: [jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(SvgDimensions, { className: classes2.dimensionsIcon }) }), jsxRuntimeExports.jsx(Grid$1, { size: 1, children: jsxRuntimeExports.jsx(Typography, { className: classes2.dimensionLabel, children: label2 }) }), jsxRuntimeExports.jsx(Grid$1, { size: 8, children: jsxRuntimeExports.jsx(Slider, { value: targetValue, min: min2, max: max2, step: 1, onChange: (e3, v) => setTargetValue(v), className: classes2.dimensionSlider, valueLabelDisplay: "auto", orientation: "horizontal", disabled: spatialRenderingMode === "3D", "aria-label": `${label2}-slice slider` }) }), jsxRuntimeExports.jsx(Grid$1, { size: 2, children: isForZ ? jsxRuntimeExports.jsx(FormGroup, { row: true, className: classes2.switchFormGroup, children: jsxRuntimeExports.jsx(FormControlLabel$1, { control: jsxRuntimeExports.jsx(Switch, { color: "primary", checked: spatialRenderingMode === "3D", onChange: handleRenderingModeChange, name: "is3dMode" }), label: "3D" }) }) : null })] }) }) });
280182
280691
  }
280183
280692
  function LayerController(props) {
280184
- const { theme, coordinationScopesRaw, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, images, imageLayerScopes, imageLayerCoordination, targetT, targetZ, setTargetT, setTargetZ, spatialRenderingMode, setSpatialRenderingMode, imageChannelScopesByLayer, imageChannelCoordination, spotLayerScopes, spotLayerCoordination, pointLayerScopes, pointLayerCoordination, volumeLoadingStatus } = props;
280693
+ const { theme, coordinationScopesRaw, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, images, imageLayerScopes, imageLayerCoordination, targetT, targetZ, setTargetT, setTargetZ, spatialRenderingMode, setSpatialRenderingMode, imageChannelScopesByLayer, imageChannelCoordination, spotLayerScopes, spotLayerCoordination, pointLayerScopes, pointLayerCoordination, pointMultiIndicesData, volumeLoadingStatus, tiledPointsLoadingProgress } = props;
280185
280694
  const anyLayerHasT = Object.values(images || {}).some((image2) => image2?.image?.instance.hasTStack());
280186
280695
  const anyLayerHasZ = Object.values(images || {}).some((image2) => image2?.image?.instance.hasZStack());
280187
280696
  const maxT = Object.values(images || {}).reduce((a2, h2) => Math.max(a2, h2?.image?.instance.getNumT()), 1) - 1;
@@ -280190,7 +280699,7 @@ function LayerController(props) {
280190
280699
  const reversedSegmentationLayerScopes = useMemo$1(() => [...segmentationLayerScopes || []].reverse(), [segmentationLayerScopes]);
280191
280700
  const reversedSpotLayerScopes = useMemo$1(() => [...spotLayerScopes || []].reverse(), [spotLayerScopes]);
280192
280701
  const reversedPointLayerScopes = useMemo$1(() => [...pointLayerScopes || []].reverse(), [pointLayerScopes]);
280193
- return jsxRuntimeExports.jsxs("div", { children: [anyLayerHasZ ? jsxRuntimeExports.jsx(GlobalDimensionSlider, { label: "Z", targetValue: targetZ, setTargetValue: setTargetZ, max: maxZ, spatialRenderingMode, setSpatialRenderingMode }) : null, anyLayerHasT ? jsxRuntimeExports.jsx(GlobalDimensionSlider, { label: "T", targetValue: targetT, setTargetValue: setTargetT, max: maxT }) : null, pointLayerScopes && reversedPointLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(PointLayerController, { theme, layerScope, layerCoordination: pointLayerCoordination[0][layerScope], setLayerCoordination: pointLayerCoordination[1][layerScope] }, layerScope)), spotLayerScopes && reversedSpotLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(SpotLayerController, { theme, layerScope, layerCoordination: spotLayerCoordination[0][layerScope], setLayerCoordination: spotLayerCoordination[1][layerScope] }, layerScope)), segmentationLayerScopes && reversedSegmentationLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(SegmentationLayerController, { theme, layerScope, layerCoordination: segmentationLayerCoordination[0][layerScope], setLayerCoordination: segmentationLayerCoordination[1][layerScope], channelScopes: segmentationChannelScopesByLayer[layerScope], channelCoordination: segmentationChannelCoordination[0][layerScope], setChannelCoordination: segmentationChannelCoordination[1][layerScope] }, layerScope)), imageLayerScopes && reversedImageLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(ImageLayerController, { theme, coordinationScopesRaw, layerScope, layerCoordination: imageLayerCoordination[0][layerScope], setLayerCoordination: imageLayerCoordination[1][layerScope], channelScopes: imageChannelScopesByLayer[layerScope], channelCoordination: imageChannelCoordination[0][layerScope], setChannelCoordination: imageChannelCoordination[1][layerScope], image: images[layerScope]?.image?.instance, featureIndex: images[layerScope]?.featureIndex, targetT, targetZ, spatialRenderingMode, volumeLoadingProgress: volumeLoadingStatus?.loadingProgress, onStopVolumeLoading: volumeLoadingStatus?.onStopLoading, onRestartVolumeLoading: volumeLoadingStatus?.onRestartLoading, volumeStillRef: volumeLoadingStatus?.stillRef }, layerScope))] });
280702
+ return jsxRuntimeExports.jsxs("div", { children: [anyLayerHasZ ? jsxRuntimeExports.jsx(GlobalDimensionSlider, { label: "Z", targetValue: targetZ, setTargetValue: setTargetZ, max: maxZ, spatialRenderingMode, setSpatialRenderingMode }) : null, anyLayerHasT ? jsxRuntimeExports.jsx(GlobalDimensionSlider, { label: "T", targetValue: targetT, setTargetValue: setTargetT, max: maxT }) : null, pointLayerScopes && reversedPointLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(PointLayerController, { theme, layerScope, layerCoordination: pointLayerCoordination[0][layerScope], setLayerCoordination: pointLayerCoordination[1][layerScope], pointMatrixIndicesData: pointMultiIndicesData?.[layerScope], tiledPointsLoadingProgress }, layerScope)), spotLayerScopes && reversedSpotLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(SpotLayerController, { theme, layerScope, layerCoordination: spotLayerCoordination[0][layerScope], setLayerCoordination: spotLayerCoordination[1][layerScope] }, layerScope)), segmentationLayerScopes && reversedSegmentationLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(SegmentationLayerController, { theme, layerScope, layerCoordination: segmentationLayerCoordination[0][layerScope], setLayerCoordination: segmentationLayerCoordination[1][layerScope], channelScopes: segmentationChannelScopesByLayer[layerScope], channelCoordination: segmentationChannelCoordination[0][layerScope], setChannelCoordination: segmentationChannelCoordination[1][layerScope] }, layerScope)), imageLayerScopes && reversedImageLayerScopes.map((layerScope) => jsxRuntimeExports.jsx(ImageLayerController, { theme, coordinationScopesRaw, layerScope, layerCoordination: imageLayerCoordination[0][layerScope], setLayerCoordination: imageLayerCoordination[1][layerScope], channelScopes: imageChannelScopesByLayer[layerScope], channelCoordination: imageChannelCoordination[0][layerScope], setChannelCoordination: imageChannelCoordination[1][layerScope], image: images[layerScope]?.image?.instance, featureIndex: images[layerScope]?.featureIndex, targetT, targetZ, spatialRenderingMode, volumeLoadingProgress: volumeLoadingStatus?.loadingProgress, onStopVolumeLoading: volumeLoadingStatus?.onStopLoading, onRestartVolumeLoading: volumeLoadingStatus?.onRestartLoading, volumeStillRef: volumeLoadingStatus?.stillRef }, layerScope))] });
280194
280703
  }
280195
280704
  function LayerControllerSubscriber(props) {
280196
280705
  const { coordinationScopes: coordinationScopesRaw, coordinationScopesBy: coordinationScopesByRaw, closeButtonVisible, downloadButtonVisible, removeGridComponent, theme, title: title2 = "Spatial Layers", uuid: uuid2 } = props;
@@ -280274,6 +280783,8 @@ function LayerControllerSubscriber(props) {
280274
280783
  CoordinationType$2.SPATIAL_LAYER_OPACITY,
280275
280784
  CoordinationType$2.SPATIAL_SPOT_RADIUS,
280276
280785
  CoordinationType$2.OBS_COLOR_ENCODING,
280786
+ CoordinationType$2.FEATURE_COLOR,
280787
+ CoordinationType$2.FEATURE_FILTER_MODE,
280277
280788
  CoordinationType$2.FEATURE_SELECTION,
280278
280789
  CoordinationType$2.FEATURE_VALUE_COLORMAP,
280279
280790
  CoordinationType$2.FEATURE_VALUE_COLORMAP_RANGE,
@@ -280282,7 +280793,10 @@ function LayerControllerSubscriber(props) {
280282
280793
  CoordinationType$2.TOOLTIP_CROSSHAIRS_VISIBLE,
280283
280794
  CoordinationType$2.LEGEND_VISIBLE
280284
280795
  ], coordinationScopes, coordinationScopesBy, CoordinationType$2.POINT_LAYER);
280285
- const [{ volumeLoadingProgress: volumeLoadingStatus }] = useAuxiliaryCoordination(["spatialAcceleratedVolumeLoadingProgress"], coordinationScopes);
280796
+ const [{ volumeLoadingProgress: volumeLoadingStatus, tiledPointsLoadingProgress }] = useAuxiliaryCoordination([
280797
+ "spatialAcceleratedVolumeLoadingProgress",
280798
+ "spatialTiledPointsLoadingProgress"
280799
+ ], coordinationScopes);
280286
280800
  const [spatialLayout] = useComponentLayout("spatial", ["spatialImageLayer"], coordinationScopes);
280287
280801
  const layerControllerRef = useRef();
280288
280802
  useClosestVitessceContainerSize(layerControllerRef);
@@ -280291,19 +280805,22 @@ function LayerControllerSubscriber(props) {
280291
280805
  const [imageData, imageDataStatus, imageUrls, imageErrors] = useMultiImages(coordinationScopes, coordinationScopesBy, loaders, dataset, mergeCoordination, uuid2);
280292
280806
  const [obsSpotsData, obsSpotsDataStatus, obsSpotsUrls, obsSpotsErrors] = useMultiObsSpots(coordinationScopes, coordinationScopesBy, loaders, dataset, mergeCoordination, uuid2);
280293
280807
  const [obsPointsData, obsPointsDataStatus, obsPointsUrls, obsPointsErrors] = useMultiObsPoints(coordinationScopes, coordinationScopesBy, loaders, dataset, mergeCoordination, uuid2);
280808
+ const [pointMultiIndicesData, pointMultiIndicesDataStatus, pointMultiIndicesDataErrors] = usePointMultiObsFeatureMatrixIndices(coordinationScopes, coordinationScopesBy, loaders, dataset);
280294
280809
  const errors = [
280295
280810
  ...obsSegmentationsErrors,
280296
280811
  ...imageErrors,
280297
280812
  ...obsSpotsErrors,
280298
- ...obsPointsErrors
280813
+ ...obsPointsErrors,
280814
+ ...pointMultiIndicesDataErrors
280299
280815
  ];
280300
280816
  const isReady = useReady([
280301
280817
  obsSpotsDataStatus,
280302
280818
  obsPointsDataStatus,
280303
280819
  obsSegmentationsDataStatus,
280304
- imageDataStatus
280820
+ imageDataStatus,
280821
+ pointMultiIndicesDataStatus
280305
280822
  ]);
280306
- return jsxRuntimeExports.jsx(TitleInfo, { title: title2, isScroll: true, closeButtonVisible, downloadButtonVisible, removeGridComponent, theme, isReady, errors, children: jsxRuntimeExports.jsx(LayerController, { theme, coordinationScopesRaw, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, images: imageData, imageLayerScopes, imageLayerCoordination, targetT, targetZ, setTargetT, setTargetZ, spatialRenderingMode, setSpatialRenderingMode, imageChannelScopesByLayer, imageChannelCoordination, spotLayerScopes, spotLayerCoordination, pointLayerScopes, pointLayerCoordination, volumeLoadingStatus }) });
280823
+ return jsxRuntimeExports.jsx(TitleInfo, { title: title2, isScroll: true, closeButtonVisible, downloadButtonVisible, removeGridComponent, theme, isReady, errors, children: jsxRuntimeExports.jsx(LayerController, { theme, coordinationScopesRaw, segmentationLayerScopes, segmentationLayerCoordination, segmentationChannelScopesByLayer, segmentationChannelCoordination, images: imageData, imageLayerScopes, imageLayerCoordination, targetT, targetZ, setTargetT, setTargetZ, spatialRenderingMode, setSpatialRenderingMode, imageChannelScopesByLayer, imageChannelCoordination, spotLayerScopes, spotLayerCoordination, pointLayerScopes, pointLayerCoordination, pointMultiIndicesData, volumeLoadingStatus, tiledPointsLoadingProgress }) });
280307
280824
  }
280308
280825
  function LinkController(props) {
280309
280826
  const { linkIDInit, authToken, linkEndpoint, websocketEndpoint, fileTypes, coordinationTypes, stores } = props;
@@ -282203,7 +282720,7 @@ function HiglassGlobalStyles(props) {
282203
282720
  }
282204
282721
  register({ dataFetcher: ZarrMultivecDataFetcher_default, config: ZarrMultivecDataFetcher_default.config }, { pluginType: "dataFetcher" });
282205
282722
  const LazyHiGlassComponent = React__default.lazy(async () => {
282206
- const { HiGlassComponent } = await import("./higlass-B7N72_I4.js");
282723
+ const { HiGlassComponent } = await import("./higlass-C-cVw2J8.js");
282207
282724
  return { default: HiGlassComponent };
282208
282725
  });
282209
282726
  const HG_SIZE = 800;
@@ -285150,7 +285667,7 @@ function NeuroglancerGlobalStyles(props) {
285150
285667
  const { classes: classes2 } = props;
285151
285668
  return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(GlobalStyles$3, { styles: globalNeuroglancerCss }), jsxRuntimeExports.jsx(ScopedGlobalStyles, { styles: globalNeuroglancerStyles, parentClassName: classes2.neuroglancerWrapper })] });
285152
285669
  }
285153
- const LazyReactNeuroglancer = React__default.lazy(() => import("./ReactNeuroglancer-BkPfN_Gu.js"));
285670
+ const LazyReactNeuroglancer = React__default.lazy(() => import("./ReactNeuroglancer-C8BcA6uO.js"));
285154
285671
  function createWorker() {
285155
285672
  return new WorkerFactory();
285156
285673
  }
@@ -306324,7 +306841,7 @@ function cureLocalIntersections(start2, triangles, dim) {
306324
306841
  let p = start2;
306325
306842
  do {
306326
306843
  const a2 = p.prev, b2 = p.next.next;
306327
- if (!equals$1(a2, b2) && intersects$2(a2, p, p.next, b2) && locallyInside(a2, b2) && locallyInside(b2, a2)) {
306844
+ if (!equals$1(a2, b2) && intersects$3(a2, p, p.next, b2) && locallyInside(a2, b2) && locallyInside(b2, a2)) {
306328
306845
  triangles.push(a2.i / dim | 0);
306329
306846
  triangles.push(p.i / dim | 0);
306330
306847
  triangles.push(b2.i / dim | 0);
@@ -306502,7 +307019,7 @@ function area$3(p, q, r3) {
306502
307019
  function equals$1(p1, p2) {
306503
307020
  return p1.x === p2.x && p1.y === p2.y;
306504
307021
  }
306505
- function intersects$2(p1, q1, p2, q2) {
307022
+ function intersects$3(p1, q1, p2, q2) {
306506
307023
  const o1 = sign$2(area$3(p1, q1, p2));
306507
307024
  const o2 = sign$2(area$3(p1, q1, q2));
306508
307025
  const o3 = sign$2(area$3(p2, q2, p1));
@@ -306523,7 +307040,7 @@ function sign$2(num) {
306523
307040
  function intersectsPolygon(a2, b2) {
306524
307041
  let p = a2;
306525
307042
  do {
306526
- if (p.i !== a2.i && p.next.i !== a2.i && p.i !== b2.i && p.next.i !== b2.i && intersects$2(p, p.next, a2, b2)) return true;
307043
+ if (p.i !== a2.i && p.next.i !== a2.i && p.i !== b2.i && p.next.i !== b2.i && intersects$3(p, p.next, a2, b2)) return true;
306527
307044
  p = p.next;
306528
307045
  } while (p !== a2);
306529
307046
  return false;
@@ -335534,7 +336051,7 @@ function place(b2, a2, c2) {
335534
336051
  c2.y = a2.y;
335535
336052
  }
335536
336053
  }
335537
- function intersects$1(a2, b2) {
336054
+ function intersects$2(a2, b2) {
335538
336055
  var dr = a2.r + b2.r - 1e-6, dx = b2.x - a2.x, dy = b2.y - a2.y;
335539
336056
  return dr > 0 && dr * dr > dx * dx + dy * dy;
335540
336057
  }
@@ -335564,13 +336081,13 @@ function packSiblingsRandom(circles, random2) {
335564
336081
  j = b2.next, k = a2.previous, sj = b2._.r, sk = a2._.r;
335565
336082
  do {
335566
336083
  if (sj <= sk) {
335567
- if (intersects$1(j._, c2._)) {
336084
+ if (intersects$2(j._, c2._)) {
335568
336085
  b2 = j, a2.next = b2, b2.previous = a2, --i2;
335569
336086
  continue pack;
335570
336087
  }
335571
336088
  sj += j._.r, j = j.next;
335572
336089
  } else {
335573
- if (intersects$1(k._, c2._)) {
336090
+ if (intersects$2(k._, c2._)) {
335574
336091
  a2 = k, a2.next = b2, b2.previous = a2, --i2;
335575
336092
  continue pack;
335576
336093
  }
@@ -370040,7 +370557,7 @@ class ObsPointsCsvLoader extends CsvLoader {
370040
370557
  data: [obsLocationsX, obsLocationsY],
370041
370558
  shape: [2, obsLocationsX.length]
370042
370559
  };
370043
- this.cachedResult = { obsIndex, obsPoints };
370560
+ this.cachedResult = { obsIndex, obsPoints, obsPointsTilingType: "full" };
370044
370561
  return this.cachedResult;
370045
370562
  }
370046
370563
  async load() {
@@ -371672,7 +372189,7 @@ class ObsPointsAnndataLoader extends AbstractTwoStepLoader {
371672
372189
  this.dataSource.loadObsIndex(path2),
371673
372190
  this.loadPoints()
371674
372191
  ]);
371675
- return new LoaderResult({ obsIndex, obsPoints }, null, coordinationValues);
372192
+ return new LoaderResult({ obsIndex, obsPoints, obsPointsTilingType: "full" }, null, coordinationValues);
371676
372193
  }
371677
372194
  }
371678
372195
  class ObsLocationsAnndataLoader extends AbstractTwoStepLoader {
@@ -373293,20 +373810,31 @@ class SpatialDataObsPointsLoader extends AbstractTwoStepLoader {
373293
373810
  * @returns {Promise} A promise for an array of columns.
373294
373811
  */
373295
373812
  async loadPoints() {
373296
- const { path: path2 } = this.options;
373813
+ const { path: path2, featureIndexColumn } = this.options;
373297
373814
  if (this.locations) {
373298
373815
  return this.locations;
373299
373816
  }
373300
373817
  let locations;
373301
373818
  const formatVersion = await this.dataSource.getPointsFormatVersion(path2);
373302
373819
  if (formatVersion === "0.1") {
373303
- locations = await this.dataSource.loadPoints(path2);
373820
+ locations = await this.dataSource.loadPoints(path2, featureIndexColumn);
373304
373821
  } else {
373305
373822
  throw new UnknownSpatialDataFormatError("Only points format version 0.1 is supported.");
373306
373823
  }
373307
373824
  this.locations = locations;
373308
373825
  return this.locations;
373309
373826
  }
373827
+ async loadPointsInRect(bounds2, signal) {
373828
+ const { path: path2, featureIndexColumn, mortonCodeColumn } = this.options;
373829
+ let locations;
373830
+ const formatVersion = await this.dataSource.getPointsFormatVersion(path2);
373831
+ if (formatVersion === "0.1") {
373832
+ locations = await this.dataSource.loadPointsInRect(path2, bounds2, signal, featureIndexColumn, mortonCodeColumn);
373833
+ } else {
373834
+ throw new UnknownSpatialDataFormatError("Only points format version 0.1 is supported.");
373835
+ }
373836
+ return locations;
373837
+ }
373310
373838
  async loadObsIndex() {
373311
373839
  const { tablePath, path: path2 } = this.options;
373312
373840
  if (tablePath) {
@@ -373319,11 +373847,28 @@ class SpatialDataObsPointsLoader extends AbstractTwoStepLoader {
373319
373847
  }
373320
373848
  return null;
373321
373849
  }
373850
+ async supportsTiling() {
373851
+ const { path: path2, featureIndexColumn: featureIndexColumnNameFromOptions, mortonCodeColumn } = this.options;
373852
+ const zattrs = await this.dataSource.loadSpatialDataElementAttrs(path2);
373853
+ const { spatialdata_attrs: spatialDataAttrs } = zattrs;
373854
+ const { feature_key: featureKey } = spatialDataAttrs;
373855
+ const featureIndexColumnName = featureIndexColumnNameFromOptions ?? `${featureKey}_codes`;
373856
+ const [formatVersion, hasRequiredColumnsAndRowGroupSize] = await Promise.all([
373857
+ // Check the points format version.
373858
+ this.dataSource.getPointsFormatVersion(path2),
373859
+ // Check the size of parquet row groups,
373860
+ // and for the presence of morton_code_2d and feature_index columns.
373861
+ this.dataSource.supportsLoadPointsInRect(path2, featureIndexColumnName, mortonCodeColumn)
373862
+ ]);
373863
+ const isSupportedVersion = formatVersion === "0.1";
373864
+ const boundingBox = zattrs?.bounding_box;
373865
+ const hasBoundingBox2D = typeof boundingBox?.x_max === "number" && typeof boundingBox?.x_min === "number" && typeof boundingBox?.y_max === "number" && typeof boundingBox?.y_min === "number";
373866
+ return isSupportedVersion && hasBoundingBox2D && hasRequiredColumnsAndRowGroupSize;
373867
+ }
373322
373868
  async load() {
373323
- const [obsIndex, obsPoints, modelMatrix2] = await Promise.all([
373324
- this.loadObsIndex(),
373325
- this.loadPoints(),
373326
- this.loadModelMatrix()
373869
+ const [modelMatrix2, supportsTiling] = await Promise.all([
373870
+ this.loadModelMatrix(),
373871
+ this.supportsTiling()
373327
373872
  ]);
373328
373873
  const coordinationValues = {
373329
373874
  pointLayer: CL({
@@ -373339,7 +373884,36 @@ class SpatialDataObsPointsLoader extends AbstractTwoStepLoader {
373339
373884
  // additionalObsSets: null,
373340
373885
  })
373341
373886
  };
373342
- return new LoaderResult({ obsIndex, obsPoints, obsPointsModelMatrix: modelMatrix2 }, null, coordinationValues);
373887
+ let obsIndex = null;
373888
+ let obsPoints = null;
373889
+ const featureIndices = null;
373890
+ if (!supportsTiling) {
373891
+ [obsIndex, obsPoints] = await Promise.all([
373892
+ this.loadObsIndex(),
373893
+ this.loadPoints()
373894
+ ]);
373895
+ }
373896
+ return new LoaderResult({
373897
+ /* obsIndex: ["1"], // TEMP
373898
+ obsPoints: { // TEMP
373899
+ shape: [2, 1],
373900
+ data: [[0], [0]],
373901
+ }, */
373902
+ // These will be null if tiling is supported.
373903
+ obsIndex,
373904
+ obsPoints,
373905
+ featureIndices,
373906
+ obsPointsModelMatrix: modelMatrix2,
373907
+ // Return 'tiled' if the morton_code_2d column
373908
+ // and bounding_box metadata are present,
373909
+ // and the row group size is small enough.
373910
+ // Otherwise, return 'full'.
373911
+ obsPointsTilingType: supportsTiling ? "tiled" : "full",
373912
+ // TEMPORARY: probably makes more sense to pass the loader instance all the way down.
373913
+ // Caller can then decide whether to use loader.load vs. loader.loadPointsInRect.
373914
+ // May need another function such as loader.supportsPointInRect() true/false.
373915
+ loadPointsInRect: this.loadPointsInRect.bind(this)
373916
+ }, null, coordinationValues);
373343
373917
  }
373344
373918
  }
373345
373919
  class SpatialDataObsSetsLoader extends ObsSetsAnndataLoader {
@@ -382734,13 +383308,470 @@ function tableFromIPC(input) {
382734
383308
  }
382735
383309
  return new Table(reader.readAll());
382736
383310
  }
383311
+ const MORTON_CODE_NUM_BITS = 32;
383312
+ const MORTON_CODE_VALUE_MAX = 2 ** (MORTON_CODE_NUM_BITS / 2) - 1;
383313
+ function origCoordToNormCoord(origCoord, origXMin, origXMax, origYMin, origYMax) {
383314
+ const [origX, origY] = origCoord;
383315
+ const origXRange = origXMax - origXMin;
383316
+ const origYRange = origYMax - origYMin;
383317
+ return [
383318
+ // Clamp to zero at low end, since using unsigned ints.
383319
+ Math.max(Math.floor((origX - origXMin) / origXRange * MORTON_CODE_VALUE_MAX), 0),
383320
+ Math.max(Math.floor((origY - origYMin) / origYRange * MORTON_CODE_VALUE_MAX), 0)
383321
+ ];
383322
+ }
383323
+ function intersects$1(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1) {
383324
+ return !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
383325
+ }
383326
+ function contained(ix0, iy0, ix1, iy1, ox0, oy0, ox1, oy1) {
383327
+ return ox0 <= ix0 && ix0 <= ix1 && ix1 <= ox1 && (oy0 <= iy0 && iy0 <= iy1 && iy1 <= oy1);
383328
+ }
383329
+ function pointInside(x2, y2, rx0, ry0, rx1, ry1) {
383330
+ return rx0 <= x2 && x2 <= rx1 && (ry0 <= y2 && y2 <= ry1);
383331
+ }
383332
+ function cellRange(prefix2, level, bits) {
383333
+ const shift2 = 2 * (bits - level);
383334
+ const power = 2 ** shift2;
383335
+ const lo = prefix2 * power;
383336
+ const hi = (prefix2 + 1) * power - 1;
383337
+ return [lo, hi];
383338
+ }
383339
+ function mergeAdjacent(intervals2) {
383340
+ if (intervals2.length === 0) {
383341
+ return [];
383342
+ }
383343
+ intervals2.sort((a2, b2) => a2[0] - b2[0]);
383344
+ const merged = [intervals2[0]];
383345
+ for (let i2 = 1; i2 < intervals2.length; i2++) {
383346
+ const [lo, hi] = intervals2[i2];
383347
+ const [mlo, mhi] = merged[merged.length - 1];
383348
+ if (lo <= mhi + 1) {
383349
+ merged[merged.length - 1] = [mlo, Math.max(mhi, hi)];
383350
+ } else {
383351
+ merged.push([lo, hi]);
383352
+ }
383353
+ }
383354
+ return merged;
383355
+ }
383356
+ function zcoverRectangle(rx0, ry0, rx1, ry1, bits, stopLevel = null, merge2 = true) {
383357
+ const maxCoord = (1 << bits) - 1;
383358
+ if (!(rx0 >= 0 && rx0 <= rx1 && rx1 <= maxCoord && ry0 >= 0 && ry0 <= ry1 && ry1 <= maxCoord)) {
383359
+ throw new Error("Rectangle out of bounds for given bits.");
383360
+ }
383361
+ const intervals2 = [];
383362
+ const stack2 = [[0, 0, 0, 0, maxCoord, maxCoord]];
383363
+ while (stack2.length > 0) {
383364
+ const [prefix2, level, xmin, ymin, xmax, ymax] = stack2.pop();
383365
+ if (!intersects$1(xmin, ymin, xmax, ymax, rx0, ry0, rx1, ry1)) {
383366
+ continue;
383367
+ }
383368
+ if (stopLevel !== null && level === stopLevel) {
383369
+ intervals2.push(cellRange(prefix2, level, bits));
383370
+ continue;
383371
+ }
383372
+ if (contained(xmin, ymin, xmax, ymax, rx0, ry0, rx1, ry1)) {
383373
+ intervals2.push(cellRange(prefix2, level, bits));
383374
+ continue;
383375
+ }
383376
+ if (level === bits) {
383377
+ if (pointInside(xmin, ymin, rx0, ry0, rx1, ry1)) {
383378
+ intervals2.push(cellRange(prefix2, level, bits));
383379
+ }
383380
+ continue;
383381
+ }
383382
+ const midx = Math.floor((xmin + xmax) / 2);
383383
+ const midy = Math.floor((ymin + ymax) / 2);
383384
+ stack2.push([prefix2 << 2 | 0, level + 1, xmin, ymin, midx, midy]);
383385
+ stack2.push([prefix2 << 2 | 1, level + 1, midx + 1, ymin, xmax, midy]);
383386
+ stack2.push([prefix2 << 2 | 2, level + 1, xmin, midy + 1, midx, ymax]);
383387
+ stack2.push([prefix2 << 2 | 3, level + 1, midx + 1, midy + 1, xmax, ymax]);
383388
+ }
383389
+ return merge2 ? mergeAdjacent(intervals2) : intervals2;
383390
+ }
383391
+ function sdataMortonQueryRectAux(boundingBox, origRect) {
383392
+ const xMin = boundingBox.x_min;
383393
+ const xMax = boundingBox.x_max;
383394
+ const yMin = boundingBox.y_min;
383395
+ const yMax = boundingBox.y_max;
383396
+ const normRect = [
383397
+ origCoordToNormCoord(origRect[0], xMin, xMax, yMin, yMax),
383398
+ origCoordToNormCoord(origRect[1], xMin, xMax, yMin, yMax)
383399
+ ];
383400
+ const mortonIntervals = zcoverRectangle(normRect[0][0], normRect[0][1], normRect[1][0], normRect[1][1], 16, null, true);
383401
+ return mortonIntervals;
383402
+ }
382737
383403
  async function getParquetModule() {
382738
383404
  const module2 = await import(
382739
383405
  /* webpackIgnore: true */
382740
- "https://unpkg.com/parquet-wasm@0.6.1/esm/parquet_wasm.js"
383406
+ "https://cdn.vitessce.io/parquet-wasm@2c23652/esm/parquet_wasm.js"
382741
383407
  );
382742
383408
  await module2.default();
382743
- return { readParquet: module2.readParquet, readSchema: module2.readSchema };
383409
+ return {
383410
+ readParquet: module2.readParquet,
383411
+ readSchema: module2.readSchema,
383412
+ readMetadata: module2.readMetadata,
383413
+ // Added in fork
383414
+ readParquetRowGroup: module2.readParquetRowGroup
383415
+ // Added in fork
383416
+ };
383417
+ }
383418
+ async function _getParquetModule({ queryClient }) {
383419
+ return queryClient.fetchQuery({
383420
+ queryKey: ["parquetModule"],
383421
+ staleTime: Infinity,
383422
+ queryFn: getParquetModule,
383423
+ meta: { queryClient }
383424
+ });
383425
+ }
383426
+ async function _loadParquetBytes({ queryClient, store }, parquetPath, rangeQuery = void 0, partIndex = void 0) {
383427
+ return queryClient.fetchQuery({
383428
+ queryKey: ["SpatialDataTableSource", "_loadParquetBytes", parquetPath, rangeQuery, partIndex],
383429
+ staleTime: Infinity,
383430
+ queryFn: async (ctx) => {
383431
+ const store2 = ctx.meta?.store;
383432
+ const rangeQuery2 = ctx.queryKey[3];
383433
+ const { offset: offset2, length: length2, suffixLength } = rangeQuery2 || {};
383434
+ let getter2 = (path2) => store2.get(path2);
383435
+ if (rangeQuery2 !== void 0 && store2.getRange) {
383436
+ if (suffixLength !== void 0) {
383437
+ getter2 = (path2) => store2.getRange(path2, {
383438
+ suffixLength
383439
+ });
383440
+ } else {
383441
+ getter2 = (path2) => store2.getRange(path2, {
383442
+ offset: offset2,
383443
+ length: length2
383444
+ });
383445
+ }
383446
+ }
383447
+ let parquetBytes;
383448
+ if (partIndex === void 0) {
383449
+ parquetBytes = await getter2(`/${parquetPath}`);
383450
+ }
383451
+ if (!parquetBytes) {
383452
+ const part0Path = `${parquetPath}/part.${partIndex ?? 0}.parquet`;
383453
+ parquetBytes = await getter2(`/${part0Path}`);
383454
+ }
383455
+ return parquetBytes;
383456
+ },
383457
+ meta: { store }
383458
+ });
383459
+ }
383460
+ async function _loadParquetSchemaBytes({ queryClient, store }, parquetPath, partIndex = void 0) {
383461
+ return queryClient.fetchQuery({
383462
+ queryKey: ["SpatialDataTableSource", "_loadParquetSchemaBytes", parquetPath, partIndex],
383463
+ staleTime: Infinity,
383464
+ queryFn: async (ctx) => {
383465
+ const store2 = ctx.meta?.store;
383466
+ if (store2.getRange) {
383467
+ const TAIL_LENGTH = 8;
383468
+ let partZeroPath = parquetPath;
383469
+ let tailBytes = await store2.getRange(`/${partZeroPath}`, {
383470
+ suffixLength: TAIL_LENGTH
383471
+ });
383472
+ if (!tailBytes) {
383473
+ partZeroPath = `${parquetPath}/part.${partIndex ?? 0}.parquet`;
383474
+ tailBytes = await store2.getRange(`/${partZeroPath}`, {
383475
+ suffixLength: TAIL_LENGTH
383476
+ });
383477
+ }
383478
+ if (!tailBytes || tailBytes.length < TAIL_LENGTH) {
383479
+ throw new Error(`Failed to load parquet footerLength for ${partZeroPath}`);
383480
+ }
383481
+ const footerLength = new DataView(tailBytes.buffer).getInt32(0, true);
383482
+ const magic = new TextDecoder().decode(tailBytes.slice(4, 8));
383483
+ if (magic !== "PAR1") {
383484
+ throw new Error("Invalid Parquet file: missing PAR1 magic number");
383485
+ }
383486
+ const footerBytes = await store2.getRange(`/${partZeroPath}`, {
383487
+ suffixLength: footerLength + TAIL_LENGTH
383488
+ });
383489
+ if (!footerBytes || footerBytes.length !== footerLength + TAIL_LENGTH) {
383490
+ throw new Error(`Failed to load parquet footer bytes for ${parquetPath}`);
383491
+ }
383492
+ return footerBytes;
383493
+ }
383494
+ return null;
383495
+ },
383496
+ meta: { queryClient, store }
383497
+ });
383498
+ }
383499
+ async function _loadParquetMetadataByPart({ queryClient, store }, parquetPath) {
383500
+ return queryClient.fetchQuery({
383501
+ queryKey: ["SpatialDataTableSource", "_loadParquetMetadataByPart", parquetPath],
383502
+ staleTime: Infinity,
383503
+ queryFn: async (ctx) => {
383504
+ const queryClient2 = (
383505
+ /** @type {QueryClient} */
383506
+ ctx.meta?.queryClient
383507
+ );
383508
+ const { readSchema, readMetadata } = await _getParquetModule({ queryClient: queryClient2 });
383509
+ let partIndex = 0;
383510
+ let numParts;
383511
+ const allMetadata = [];
383512
+ do {
383513
+ try {
383514
+ const schemaBytes = await _loadParquetSchemaBytes({ queryClient: queryClient2, store }, parquetPath, partIndex);
383515
+ if (schemaBytes) {
383516
+ const wasmSchema = readSchema(schemaBytes);
383517
+ const arrowTableForSchema = tableFromIPC(wasmSchema.intoIPCStream());
383518
+ const partMetadata = readMetadata(schemaBytes);
383519
+ const partInfo = {
383520
+ schema: arrowTableForSchema,
383521
+ schemaBytes,
383522
+ metadata: partMetadata
383523
+ };
383524
+ allMetadata.push(partInfo);
383525
+ partIndex += 1;
383526
+ }
383527
+ } catch (error2) {
383528
+ if (error2.message.includes("Failed to load parquet footerLength")) {
383529
+ numParts = partIndex;
383530
+ }
383531
+ }
383532
+ } while (numParts === void 0);
383533
+ const metadata2 = {
383534
+ numRows: 0,
383535
+ numRowGroups: 0,
383536
+ numRowsPerGroup: 0,
383537
+ schema: null
383538
+ };
383539
+ if (allMetadata.length > 0) {
383540
+ const firstPart = allMetadata[0];
383541
+ metadata2.numRows = allMetadata.reduce((sum2, part) => sum2 + part.metadata.fileMetadata().numRows(), 0);
383542
+ metadata2.numRowGroups = allMetadata.reduce((sum2, part) => sum2 + part.metadata.numRowGroups(), 0);
383543
+ metadata2.numRowsPerGroup = firstPart.metadata.rowGroup(0).numRows();
383544
+ metadata2.schema = firstPart.schema.schema;
383545
+ }
383546
+ const result = {
383547
+ ...metadata2,
383548
+ // TODO: extract metadata per part and rowGroup into plain objects that match the hyparquet parquetMetadata() return value?
383549
+ // This will also make it easier to test.
383550
+ parts: allMetadata
383551
+ };
383552
+ return result;
383553
+ },
383554
+ meta: { queryClient }
383555
+ });
383556
+ }
383557
+ async function _loadParquetRowGroupByGroupIndex({ queryClient, store }, parquetPath, rowGroupIndex) {
383558
+ return queryClient.fetchQuery({
383559
+ queryKey: ["SpatialDataTableSource", "_loadParquetRowGroupByGroupIndex", parquetPath, rowGroupIndex],
383560
+ staleTime: Infinity,
383561
+ queryFn: async (ctx) => {
383562
+ const queryClient2 = (
383563
+ /** @type {QueryClient} */
383564
+ ctx.meta?.queryClient
383565
+ );
383566
+ const store2 = ctx.meta?.store;
383567
+ const { readParquetRowGroup } = await _getParquetModule({ queryClient: queryClient2 });
383568
+ const allMetadata = await _loadParquetMetadataByPart({ queryClient: queryClient2, store: store2 }, parquetPath);
383569
+ if (rowGroupIndex < 0 || rowGroupIndex >= allMetadata.numRowGroups) {
383570
+ throw new Error(`Row group index ${rowGroupIndex} is out of bounds for parquet table with ${allMetadata.numRowGroups} row groups.`);
383571
+ }
383572
+ let partIndex;
383573
+ let cumulativeRowGroups = 0;
383574
+ for (let i2 = 0; i2 < allMetadata.parts.length; i2++) {
383575
+ const part = allMetadata.parts[i2];
383576
+ const numRowGroupsInPart = part.metadata.numRowGroups();
383577
+ if (rowGroupIndex < cumulativeRowGroups + numRowGroupsInPart) {
383578
+ partIndex = i2;
383579
+ break;
383580
+ }
383581
+ cumulativeRowGroups += numRowGroupsInPart;
383582
+ }
383583
+ if (partIndex === void 0) {
383584
+ throw new Error(`Failed to find part containing row group index ${rowGroupIndex}.`);
383585
+ }
383586
+ const partMetadata = allMetadata.parts[partIndex].metadata;
383587
+ const { schemaBytes } = allMetadata.parts[partIndex];
383588
+ const rowGroupIndexRelativeToPart = rowGroupIndex - cumulativeRowGroups;
383589
+ const rowGroupMetadata = partMetadata.rowGroup(rowGroupIndexRelativeToPart);
383590
+ const rowGroupFileOffset = rowGroupMetadata.fileOffset();
383591
+ const rowGroupCompressedSize = rowGroupMetadata.compressedSize();
383592
+ const rowGroupBytes = await _loadParquetBytes({ queryClient: queryClient2, store: store2 }, parquetPath, { offset: rowGroupFileOffset, length: rowGroupCompressedSize }, partIndex);
383593
+ const rowGroupIPC = readParquetRowGroup(schemaBytes, rowGroupBytes, rowGroupIndexRelativeToPart).intoIPCStream();
383594
+ const rowGroupTable = tableFromIPC(rowGroupIPC);
383595
+ return rowGroupTable;
383596
+ },
383597
+ meta: { queryClient, store }
383598
+ });
383599
+ }
383600
+ async function _loadParquetRowGroupColumnExtent({ queryClient, store }, parquetPath, columnName, rowGroupIndex) {
383601
+ return queryClient.fetchQuery({
383602
+ queryKey: ["SpatialDataTableSource", "_loadParquetRowGroupColumnExtent", parquetPath, columnName, rowGroupIndex],
383603
+ staleTime: Infinity,
383604
+ queryFn: async (ctx) => {
383605
+ const queryClient2 = (
383606
+ /** @type {QueryClient} */
383607
+ ctx.meta?.queryClient
383608
+ );
383609
+ const store2 = ctx.meta?.store;
383610
+ const rowGroupTable = await _loadParquetRowGroupByGroupIndex({ queryClient: queryClient2, store: store2 }, parquetPath, rowGroupIndex);
383611
+ const column2 = rowGroupTable.getChild(columnName);
383612
+ if (!column2) {
383613
+ throw new Error(`Column ${columnName} not found in row group ${rowGroupIndex} of parquet table at ${parquetPath}.`);
383614
+ }
383615
+ if (column2.length === 0) {
383616
+ return { min: null, max: null };
383617
+ }
383618
+ return { min: column2.get(0), max: column2.get(column2.length - 1) };
383619
+ },
383620
+ meta: { queryClient, store }
383621
+ });
383622
+ }
383623
+ function getCachedInRangeSync(queryClient, parquetPath, columnName, lo, hi) {
383624
+ const queryCache = queryClient.getQueryCache();
383625
+ const prevQueries = queryCache.findAll({
383626
+ // Note: Must (manually) keep in sync with queryKey used in _loadParquetRowGroupColumnExtent.
383627
+ queryKey: ["SpatialDataTableSource", "_loadParquetRowGroupColumnExtent", parquetPath, columnName],
383628
+ exact: false
383629
+ });
383630
+ const cachedRowGroupInfo = prevQueries.map((q) => {
383631
+ if (!(q.state.status === "success" && !q.state.isInvalidated)) {
383632
+ return null;
383633
+ }
383634
+ return {
383635
+ queryKey: q.queryKey,
383636
+ index: q.queryKey[4],
383637
+ status: q.state.status,
383638
+ min: q.state.data?.min,
383639
+ max: q.state.data?.max
383640
+ };
383641
+ }).filter((v) => v !== null).toSorted((a2, b2) => a2.index - b2.index);
383642
+ return cachedRowGroupInfo.filter((c2) => c2.index >= lo && c2.index < hi);
383643
+ }
383644
+ async function getCachedInRange(queryClient, parquetPath, columnName, lo, hi) {
383645
+ const queryCache = queryClient.getQueryCache();
383646
+ const prevQueries = queryCache.findAll({
383647
+ // Note: Must (manually) keep in sync with queryKey used in _loadParquetRowGroupColumnExtent.
383648
+ queryKey: ["SpatialDataTableSource", "_loadParquetRowGroupColumnExtent", parquetPath, columnName],
383649
+ exact: false
383650
+ });
383651
+ const cachedRowGroupInfo = prevQueries.map((q) => ({
383652
+ queryKey: q.queryKey,
383653
+ index: q.queryKey[4],
383654
+ status: q.state.status,
383655
+ min: q.state.data?.min,
383656
+ max: q.state.data?.max
383657
+ })).filter((v) => v !== null).toSorted((a2, b2) => a2.index - b2.index);
383658
+ const cachedInRange = cachedRowGroupInfo.filter((c2) => c2.index >= lo && c2.index < hi);
383659
+ const pendingQueries = cachedInRange.filter((c2) => c2.status !== "success");
383660
+ if (pendingQueries.length === 0) {
383661
+ return cachedInRange;
383662
+ }
383663
+ const pendingPromises = pendingQueries.map((c2) => queryClient.ensureQueryData({
383664
+ queryKey: c2.queryKey
383665
+ }));
383666
+ await Promise.all(pendingPromises);
383667
+ return getCachedInRangeSync(queryClient, parquetPath, columnName, lo, hi);
383668
+ }
383669
+ async function _bisectRowGroupsRight({ queryClient, store }, parquetPath, columnName, targetValue) {
383670
+ return queryClient.fetchQuery({
383671
+ queryKey: ["SpatialDataTableSource", "_bisectRowGroupsRight", parquetPath, columnName, targetValue],
383672
+ staleTime: Infinity,
383673
+ queryFn: async (ctx) => {
383674
+ const queryClient2 = (
383675
+ /** @type {QueryClient} */
383676
+ ctx.meta?.queryClient
383677
+ );
383678
+ const store2 = ctx.meta?.store;
383679
+ const allMetadata = await _loadParquetMetadataByPart({ queryClient: queryClient2, store: store2 }, parquetPath);
383680
+ const { numRowGroups } = allMetadata;
383681
+ let lo = 0;
383682
+ let hi = numRowGroups;
383683
+ while (lo < hi) {
383684
+ const cachedInRange = await getCachedInRange(queryClient2, parquetPath, columnName, lo, hi);
383685
+ const betterLo = cachedInRange.slice().reverse().find((c2) => c2.index > lo && targetValue >= c2.max);
383686
+ if (betterLo) {
383687
+ lo = Math.min(hi, betterLo.index + 1);
383688
+ }
383689
+ const betterHi = cachedInRange.find((c2) => targetValue < c2.min);
383690
+ if (betterHi) {
383691
+ hi = Math.max(lo, betterHi.index - 1);
383692
+ }
383693
+ if (lo >= hi) {
383694
+ break;
383695
+ }
383696
+ const mid = Math.floor((lo + hi) / 2);
383697
+ const { max: midVal } = await _loadParquetRowGroupColumnExtent({ queryClient: queryClient2, store: store2 }, parquetPath, columnName, mid);
383698
+ if (midVal === null || targetValue <= midVal) {
383699
+ hi = mid;
383700
+ } else {
383701
+ lo = mid + 1;
383702
+ }
383703
+ }
383704
+ return lo;
383705
+ },
383706
+ meta: { queryClient, store }
383707
+ });
383708
+ }
383709
+ async function _rectToRowGroupIndices({ queryClient, store }, parquetPath, tileBbox, allPointsBbox, mortonCodeColumnName) {
383710
+ return queryClient.fetchQuery({
383711
+ queryKey: ["SpatialDataTableSource", "_rectToRowGroupIndices", parquetPath, tileBbox, allPointsBbox],
383712
+ staleTime: Infinity,
383713
+ queryFn: async (ctx) => {
383714
+ const queryClient2 = (
383715
+ /** @type {QueryClient} */
383716
+ ctx.meta?.queryClient
383717
+ );
383718
+ const store2 = ctx.meta?.store;
383719
+ const mortonIntervals = sdataMortonQueryRectAux(allPointsBbox, [
383720
+ [tileBbox.left, tileBbox.top],
383721
+ // TODO: is this backwards (bottom/top)?
383722
+ [tileBbox.right, tileBbox.bottom]
383723
+ ]);
383724
+ let coveredRowGroupIndices = [];
383725
+ const intervalsSpanMultipleRowGroups = async (startIndex, endIndex) => {
383726
+ if (startIndex > endIndex) {
383727
+ return [false, null];
383728
+ }
383729
+ const [startMin, startMax] = mortonIntervals[startIndex];
383730
+ const [endMin, endMax] = mortonIntervals[endIndex];
383731
+ const [rowGroupIndexMin, rowGroupIndexMax] = await Promise.all([
383732
+ _bisectRowGroupsRight({ queryClient: queryClient2, store: store2 }, parquetPath, mortonCodeColumnName, startMin),
383733
+ _bisectRowGroupsRight({ queryClient: queryClient2, store: store2 }, parquetPath, mortonCodeColumnName, endMax)
383734
+ ]);
383735
+ if (rowGroupIndexMin === rowGroupIndexMax) {
383736
+ return [false, [rowGroupIndexMin]];
383737
+ }
383738
+ if (rowGroupIndexMin + 1 === rowGroupIndexMax || rowGroupIndexMin - 1 === rowGroupIndexMax) {
383739
+ return [false, [rowGroupIndexMin, rowGroupIndexMax]];
383740
+ }
383741
+ return [true, null];
383742
+ };
383743
+ const intervalIndicesToCheck = [[0, mortonIntervals.length - 1]];
383744
+ while (intervalIndicesToCheck.length > 0) {
383745
+ const [startIndex, endIndex] = intervalIndicesToCheck.pop();
383746
+ const [spansMultipleRowGroups, rowGroupIndices] = await intervalsSpanMultipleRowGroups(startIndex, endIndex);
383747
+ if (!spansMultipleRowGroups) {
383748
+ if (rowGroupIndices !== null) {
383749
+ coveredRowGroupIndices = coveredRowGroupIndices.concat(rowGroupIndices);
383750
+ }
383751
+ } else {
383752
+ if (startIndex === endIndex) {
383753
+ const [intervalMin, intervalMax] = mortonIntervals[startIndex];
383754
+ const [rowGroupIndexMin, rowGroupIndexMax] = await Promise.all([
383755
+ _bisectRowGroupsRight({ queryClient: queryClient2, store: store2 }, parquetPath, mortonCodeColumnName, intervalMin),
383756
+ _bisectRowGroupsRight({ queryClient: queryClient2, store: store2 }, parquetPath, mortonCodeColumnName, intervalMax)
383757
+ ]);
383758
+ if (rowGroupIndexMin <= rowGroupIndexMax) {
383759
+ coveredRowGroupIndices = coveredRowGroupIndices.concat(range$b(rowGroupIndexMin, rowGroupIndexMax + 1));
383760
+ } else {
383761
+ coveredRowGroupIndices = coveredRowGroupIndices.concat(range$b(rowGroupIndexMax, rowGroupIndexMin + 1));
383762
+ }
383763
+ } else {
383764
+ const midIndex = Math.floor((startIndex + endIndex) / 2);
383765
+ intervalIndicesToCheck.push([startIndex, midIndex]);
383766
+ intervalIndicesToCheck.push([midIndex + 1, endIndex]);
383767
+ }
383768
+ }
383769
+ }
383770
+ const uniqueCoveredRowGroupIndices = Array.from(new Set(coveredRowGroupIndices));
383771
+ return uniqueCoveredRowGroupIndices;
383772
+ },
383773
+ meta: { queryClient, store }
383774
+ });
382744
383775
  }
382745
383776
  function tableToIndexColumnName(arrowTable) {
382746
383777
  const pandasMetadata = arrowTable.schema.metadata.get("pandas");
@@ -382794,14 +383825,17 @@ function getVarPath(arrPath) {
382794
383825
  class SpatialDataTableSource extends AnnDataSource {
382795
383826
  /**
382796
383827
  *
382797
- * @param {DataSourceParams} params
383828
+ * @param {DataSourceParams & { queryClient: QueryClient }} params
382798
383829
  */
382799
383830
  constructor(params2) {
382800
383831
  super(params2);
383832
+ const { queryClient } = params2;
383833
+ this.queryClient = queryClient;
382801
383834
  this.parquetModulePromise = getParquetModule();
382802
383835
  this.rootAttrs = null;
382803
383836
  this.elementAttrs = {};
382804
383837
  this.parquetTableBytes = {};
383838
+ this.parquetTableIsDirectory = {};
382805
383839
  this.obsIndices = {};
382806
383840
  this.varIndices = {};
382807
383841
  this.varAliases = {};
@@ -382855,17 +383889,19 @@ class SpatialDataTableSource extends AnnDataSource {
382855
383889
  * relative to the store root.
382856
383890
  * @returns {Promise<Uint8Array|undefined>} The parquet file bytes.
382857
383891
  */
382858
- async loadParquetBytes(parquetPath) {
382859
- if (this.parquetTableBytes[parquetPath]) {
382860
- return this.parquetTableBytes[parquetPath];
383892
+ async loadParquetBytes(parquetPath, offset2 = void 0, length2 = void 0, partIndex = void 0) {
383893
+ const { store } = this.storeRoot;
383894
+ let getter2 = (path2) => store.get(path2);
383895
+ if (offset2 !== void 0 && length2 !== void 0 && store.getRange) {
383896
+ getter2 = (path2) => store.getRange(path2, {
383897
+ offset: offset2,
383898
+ length: length2
383899
+ });
382861
383900
  }
382862
- let parquetBytes = await this.storeRoot.store.get(`/${parquetPath}`);
383901
+ let parquetBytes = await getter2(`/${parquetPath}`);
382863
383902
  if (!parquetBytes) {
382864
- const part0Path = `${parquetPath}/part.0.parquet`;
382865
- parquetBytes = await this.storeRoot.store.get(`/${part0Path}`);
382866
- }
382867
- if (parquetBytes) {
382868
- this.parquetTableBytes[parquetPath] = parquetBytes;
383903
+ const part0Path = `${parquetPath}/part.${partIndex ?? 0}.parquet`;
383904
+ parquetBytes = await getter2(`/${part0Path}`);
382869
383905
  }
382870
383906
  return parquetBytes;
382871
383907
  }
@@ -382884,7 +383920,7 @@ class SpatialDataTableSource extends AnnDataSource {
382884
383920
  * @returns {Promise<Uint8Array|null>} The parquet file bytes,
382885
383921
  * or null if the store does not support getRange.
382886
383922
  */
382887
- async loadParquetSchemaBytes(parquetPath) {
383923
+ async loadParquetSchemaBytes(parquetPath, partIndex = void 0) {
382888
383924
  const { store } = this.storeRoot;
382889
383925
  if (store.getRange) {
382890
383926
  const TAIL_LENGTH = 8;
@@ -382892,12 +383928,10 @@ class SpatialDataTableSource extends AnnDataSource {
382892
383928
  let tailBytes = await store.getRange(`/${partZeroPath}`, {
382893
383929
  suffixLength: TAIL_LENGTH
382894
383930
  });
382895
- if (!tailBytes) {
382896
- partZeroPath = `${parquetPath}/part.0.parquet`;
382897
- tailBytes = await store.getRange(`/${partZeroPath}`, {
382898
- suffixLength: TAIL_LENGTH
382899
- });
382900
- }
383931
+ partZeroPath = `${parquetPath}/part.${partIndex ?? 0}.parquet`;
383932
+ tailBytes = await store.getRange(`/${partZeroPath}`, {
383933
+ suffixLength: TAIL_LENGTH
383934
+ });
382901
383935
  if (!tailBytes || tailBytes.length < TAIL_LENGTH) {
382902
383936
  throw new Error(`Failed to load parquet footerLength for ${parquetPath}`);
382903
383937
  }
@@ -382959,7 +383993,7 @@ class SpatialDataTableSource extends AnnDataSource {
382959
383993
  const schemaBytes = await this.loadParquetSchemaBytes(parquetPath);
382960
383994
  if (schemaBytes) {
382961
383995
  const wasmSchema = readSchema(schemaBytes);
382962
- const arrowTableForSchema = await tableFromIPC(wasmSchema.intoIPCStream());
383996
+ const arrowTableForSchema = tableFromIPC(wasmSchema.intoIPCStream());
382963
383997
  indexColumnName = tableToIndexColumnName(arrowTableForSchema);
382964
383998
  }
382965
383999
  } catch (e3) {
@@ -382975,14 +384009,14 @@ class SpatialDataTableSource extends AnnDataSource {
382975
384009
  }
382976
384010
  if (columns2 && !indexColumnName) {
382977
384011
  const wasmSchema = readSchema(parquetBytes);
382978
- const arrowTableForSchema = await tableFromIPC(wasmSchema.intoIPCStream());
384012
+ const arrowTableForSchema = tableFromIPC(wasmSchema.intoIPCStream());
382979
384013
  indexColumnName = tableToIndexColumnName(arrowTableForSchema);
382980
384014
  }
382981
384015
  if (options.columns && indexColumnName) {
382982
384016
  options.columns = [...options.columns, indexColumnName];
382983
384017
  }
382984
384018
  const wasmTable = readParquet(parquetBytes, options);
382985
- const arrowTable = await tableFromIPC(wasmTable.intoIPCStream());
384019
+ const arrowTable = tableFromIPC(wasmTable.intoIPCStream());
382986
384020
  return arrowTable;
382987
384021
  }
382988
384022
  // TABLE-SPECIFIC METHODS
@@ -383046,6 +384080,95 @@ class SpatialDataTableSource extends AnnDataSource {
383046
384080
  this.varAliases[varPath] = this.varAliases[varPath].map((val, ind) => val ? val.concat(` (${index2[ind]})`) : index2[ind]);
383047
384081
  return this.varAliases[varPath];
383048
384082
  }
384083
+ async _supportsTiledPoints(parquetPath, featureIndexColumnName, mortonCodeColumn) {
384084
+ const { queryClient } = this;
384085
+ const { store } = this.storeRoot;
384086
+ const allMetadata = await _loadParquetMetadataByPart({ queryClient, store }, parquetPath);
384087
+ const { numRowsPerGroup } = allMetadata;
384088
+ const numRowsTotal = allMetadata.numRows;
384089
+ if (numRowsPerGroup >= 1e5) {
384090
+ if (numRowsTotal > 5e6) {
384091
+ throw new Error(`The Parquet table at ${parquetPath} has ${numRowsTotal} total rows, which necessitates tiled loading, but it was not possible because the row group size is too large (${numRowsPerGroup}). See the Vitessce documentation at Data Troubleshooting -> Points for more details.`);
384092
+ }
384093
+ return false;
384094
+ }
384095
+ const mortonCodeColumnName = mortonCodeColumn ?? "morton_code_2d";
384096
+ const requiredColumns = ["x", "y", featureIndexColumnName, mortonCodeColumnName];
384097
+ const hasColumns = allMetadata?.schema?.fields?.map((f2) => f2.name);
384098
+ if (!hasColumns) {
384099
+ return false;
384100
+ }
384101
+ const hasRequiredColumns = requiredColumns.every((col) => hasColumns.includes(col));
384102
+ if (!hasRequiredColumns && numRowsTotal > 5e6) {
384103
+ throw new Error(`The Parquet table at ${parquetPath} has ${numRowsTotal} total rows, which necessitates tiled loading, but it was not possible because the required columns are missing. Required columns: ${requiredColumns.join(", ")}. Found columns: ${hasColumns.join(", ")}. See the Vitessce documentation at Data Troubleshooting -> Points for more details.`);
384104
+ }
384105
+ return hasRequiredColumns;
384106
+ }
384107
+ /**
384108
+ * Load point data using a tiled approach.
384109
+ * @param {string} parquetPath A path to a parquet file (or directory).
384110
+ * @param {{ left: number, top: number, right: number, bottom: number }} tileBbox
384111
+ * @param {{ x_min: number, y_min: number, x_max: number, y_max: number }} allPointsBbox
384112
+ * @param {string[]|undefined} columns An optional list of column names to load.
384113
+ * @returns
384114
+ */
384115
+ async loadParquetTableInRect(parquetPath, tileBbox, allPointsBbox, signal, featureIndexColumnName, mortonCodeColumn) {
384116
+ const { queryClient } = this;
384117
+ const { store } = this.storeRoot;
384118
+ const mortonCodeColumnName = mortonCodeColumn ?? "morton_code_2d";
384119
+ const TILE_SIZE2 = 256;
384120
+ let tileBboxes = [];
384121
+ if (tileBbox.right - tileBbox.left > TILE_SIZE2 || tileBbox.bottom - tileBbox.top > TILE_SIZE2) {
384122
+ const xSteps = Math.ceil((tileBbox.right - tileBbox.left) / TILE_SIZE2);
384123
+ const ySteps = Math.ceil((tileBbox.bottom - tileBbox.top) / TILE_SIZE2);
384124
+ const xStepSize = (tileBbox.right - tileBbox.left) / xSteps;
384125
+ const yStepSize = (tileBbox.bottom - tileBbox.top) / ySteps;
384126
+ for (let i2 = 0; i2 < xSteps; i2++) {
384127
+ for (let j = 0; j < ySteps; j++) {
384128
+ const subTileBbox = {
384129
+ left: tileBbox.left + i2 * xStepSize,
384130
+ right: Math.min(tileBbox.left + (i2 + 1) * xStepSize, tileBbox.right),
384131
+ top: tileBbox.top + j * yStepSize,
384132
+ bottom: Math.min(tileBbox.top + (j + 1) * yStepSize, tileBbox.bottom)
384133
+ };
384134
+ tileBboxes.push(subTileBbox);
384135
+ }
384136
+ }
384137
+ } else {
384138
+ tileBboxes = [tileBbox];
384139
+ }
384140
+ const rowGroupIndicesPerTile = await Promise.all(tileBboxes.map(async (subTileBbox) => _rectToRowGroupIndices({ queryClient, store }, parquetPath, subTileBbox, allPointsBbox, mortonCodeColumnName)));
384141
+ const uniqueCoveredRowGroupIndices = Array.from(new Set(rowGroupIndicesPerTile.flat())).toSorted((a2, b2) => a2 - b2);
384142
+ const allMetadata = await _loadParquetMetadataByPart({ queryClient, store }, parquetPath);
384143
+ const { numRowsPerGroup } = allMetadata;
384144
+ const numRowGroups = uniqueCoveredRowGroupIndices.length;
384145
+ const totalNumRows = numRowsPerGroup * numRowGroups;
384146
+ const xArr = new Float32Array(totalNumRows);
384147
+ const yArr = new Float32Array(totalNumRows);
384148
+ const featureIndexArr = new Uint32Array(totalNumRows);
384149
+ const rowGroupTables = await Promise.all(uniqueCoveredRowGroupIndices.map(async (rowGroupIndex) => _loadParquetRowGroupByGroupIndex({ queryClient, store }, parquetPath, rowGroupIndex)));
384150
+ let rowOffset = 0;
384151
+ rowGroupTables.forEach((table2) => {
384152
+ const xColumn = table2.getChild("x");
384153
+ const yColumn = table2.getChild("y");
384154
+ const featureIndexColumn = table2.getChild(featureIndexColumnName);
384155
+ if (!xColumn || !yColumn || !featureIndexColumn) {
384156
+ throw new Error(`Missing required column in parquet table at ${parquetPath}. Required columns: x, y, feature_index`);
384157
+ }
384158
+ xArr.set(xColumn.toArray(), rowOffset);
384159
+ yArr.set(yColumn.toArray(), rowOffset);
384160
+ featureIndexArr.set(featureIndexColumn.toArray(), rowOffset);
384161
+ rowOffset += numRowsPerGroup;
384162
+ });
384163
+ return {
384164
+ data: {
384165
+ x: xArr,
384166
+ y: yArr,
384167
+ featureIndices: featureIndexArr
384168
+ },
384169
+ shape: [3, totalNumRows]
384170
+ };
384171
+ }
383049
384172
  }
383050
384173
  class BaseEvent {
383051
384174
  /**
@@ -389180,7 +390303,7 @@ class SpatialDataPointsSource extends SpatialDataTableSource {
389180
390303
  * shape: [number, number],
389181
390304
  * }>} A promise for a zarr array containing the data.
389182
390305
  */
389183
- async loadPoints(elementPath) {
390306
+ async loadPoints(elementPath, featureIndexColumnNameFromOptions) {
389184
390307
  const parquetPath = getParquetPath(elementPath);
389185
390308
  const zattrs = await this.loadSpatialDataElementAttrs(elementPath);
389186
390309
  const { axes, spatialdata_attrs: spatialDataAttrs } = zattrs;
@@ -389201,6 +390324,35 @@ class SpatialDataPointsSource extends SpatialDataTableSource {
389201
390324
  data: axisColumnArrs
389202
390325
  };
389203
390326
  }
390327
+ /**
390328
+ *
390329
+ * @param {string} elementPath
390330
+ * @param {{ left: number, top: number, right: number, bottom: number }} tileBbox
390331
+ * @returns {Promise<{
390332
+ * data: [ZarrTypedArray<any>, ZarrTypedArray<any>],
390333
+ * shape: [number, number],
390334
+ * }>} A promise for a zarr array containing the data.
390335
+ */
390336
+ async loadPointsInRect(elementPath, tileBbox, signal, featureIndexColumnNameFromOptions, mortonCodeColumn) {
390337
+ const parquetPath = getParquetPath(elementPath);
390338
+ const zattrs = await this.loadSpatialDataElementAttrs(elementPath);
390339
+ const {
390340
+ // axes,
390341
+ spatialdata_attrs: spatialDataAttrs,
390342
+ // The bounding box (extent) of all points.
390343
+ // Required for un-normalization from uints back to floats.
390344
+ // TODO: decide whether these will be stored here or somewhere else.
390345
+ // Reference: https://github.com/vitessce/vitessce-python/pull/476#issuecomment-3362656956
390346
+ bounding_box: allPointsBbox
390347
+ } = zattrs;
390348
+ const { feature_key: featureKey } = spatialDataAttrs;
390349
+ const featureIndexColumnName = featureIndexColumnNameFromOptions ?? `${featureKey}_codes`;
390350
+ return this.loadParquetTableInRect(parquetPath, tileBbox, allPointsBbox, signal, featureIndexColumnName, mortonCodeColumn);
390351
+ }
390352
+ async supportsLoadPointsInRect(elementPath, featureIndexColumnName, mortonCodeColumn) {
390353
+ const parquetPath = getParquetPath(elementPath);
390354
+ return this._supportsTiledPoints(parquetPath, featureIndexColumnName, mortonCodeColumn);
390355
+ }
389204
390356
  }
389205
390357
  class OmeTiffSource {
389206
390358
  constructor({ url, requestInit: requestInit2 }) {
@@ -395307,7 +396459,20 @@ const baseCoordinationTypes = [
395307
396459
  path: obsSetPath,
395308
396460
  color: rgbArray
395309
396461
  })).nullable()),
395310
- new PluginCoordinationType(CoordinationType$2.OBS_COLOR_ENCODING, "cellSetSelection", z.enum(["geneSelection", "cellSetSelection", "spatialChannelColor", "spatialLayerColor", "obsLabels"])),
396462
+ new PluginCoordinationType(CoordinationType$2.FEATURE_COLOR, null, z.array(z.object({
396463
+ name: z.string(),
396464
+ color: rgbArray
396465
+ })).nullable()),
396466
+ new PluginCoordinationType(CoordinationType$2.OBS_COLOR_ENCODING, "cellSetSelection", z.enum([
396467
+ "geneSelection",
396468
+ "cellSetSelection",
396469
+ "spatialChannelColor",
396470
+ "spatialLayerColor",
396471
+ "obsLabels",
396472
+ // For point coloring.
396473
+ "random",
396474
+ "randomByFeature"
396475
+ ])),
395311
396476
  new PluginCoordinationType(CoordinationType$2.FEATURE_FILTER, null, z.array(z.string()).nullable()),
395312
396477
  new PluginCoordinationType(CoordinationType$2.FEATURE_HIGHLIGHT, null, z.string().nullable()),
395313
396478
  new PluginCoordinationType(CoordinationType$2.FEATURE_SELECTION, null, z.array(z.string()).nullable()),
@@ -395325,7 +396490,7 @@ const baseCoordinationTypes = [
395325
396490
  new PluginCoordinationType(CoordinationType$2.FEATURE_SET_SELECTION, null, z.array(obsSetPath).nullable()),
395326
396491
  new PluginCoordinationType(CoordinationType$2.FEATURE_SELECTION_MODE, null, z.enum(["featureSelection", "featureSetSelection"]).nullable()),
395327
396492
  new PluginCoordinationType(CoordinationType$2.FEATURE_SET_FILTER, null, z.array(obsSetPath).nullable()),
395328
- new PluginCoordinationType(CoordinationType$2.FEATURE_FILTER_MODE, null, z.enum(["featureFilter", "featureSetFilter"]).nullable()),
396493
+ new PluginCoordinationType(CoordinationType$2.FEATURE_FILTER_MODE, null, z.enum(["featureFilter", "featureSetFilter", "featureSelection"]).nullable()),
395329
396494
  new PluginCoordinationType(CoordinationType$2.FEATURE_VALUE_TRANSFORM, null, z.enum(["log1p", "arcsinh"]).nullable()),
395330
396495
  new PluginCoordinationType(CoordinationType$2.FEATURE_VALUE_TRANSFORM_COEFFICIENT, 1, z.number()),
395331
396496
  new PluginCoordinationType(CoordinationType$2.FEATURE_VALUE_POSITIVITY_THRESHOLD, 0, z.number()),