@gen3/frontend 0.12.45 → 0.12.46

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.
Files changed (54) hide show
  1. package/dist/dts/features/Workspace/WorkspaceNotebook.d.ts +1 -1
  2. package/dist/dts/features/Workspace/WorkspaceNotebook.d.ts.map +1 -1
  3. package/dist/dts/features/Workspace/WorkspaceNotebook.js +69 -5
  4. package/dist/dts/features/Workspace/WorkspaceNotebook.js.map +1 -1
  5. package/dist/dts/index.d.ts +2 -1
  6. package/dist/dts/index.d.ts.map +1 -1
  7. package/dist/dts/index.js +2 -1
  8. package/dist/dts/index.js.map +1 -1
  9. package/dist/dts/lib/session/constants.d.ts +2 -0
  10. package/dist/dts/lib/session/constants.d.ts.map +1 -0
  11. package/dist/dts/lib/session/constants.js +2 -0
  12. package/dist/dts/lib/session/constants.js.map +1 -0
  13. package/dist/dts/lib/session/session.d.ts.map +1 -1
  14. package/dist/dts/lib/session/session.js +1 -1
  15. package/dist/dts/lib/session/session.js.map +1 -1
  16. package/dist/index/cjs/QueryPanel-C6_EtaDO.js +39 -0
  17. package/dist/index/cjs/QueryPanel-C6_EtaDO.js.map +1 -0
  18. package/dist/index/cjs/QueryPanel-Dpn_GGDU.js +39 -0
  19. package/dist/index/cjs/QueryPanel-Dpn_GGDU.js.map +1 -0
  20. package/dist/index/cjs/index-CSXtX5eA.js +38902 -0
  21. package/dist/index/cjs/index-CSXtX5eA.js.map +1 -0
  22. package/dist/index/cjs/index-rCd246Nh.js +38893 -0
  23. package/dist/index/cjs/index-rCd246Nh.js.map +1 -0
  24. package/dist/index/cjs/index.js +2 -1
  25. package/dist/index/cjs/index.js.map +1 -1
  26. package/dist/index/esm/QueryPanel-BFecvXaF.js +37 -0
  27. package/dist/index/esm/QueryPanel-BFecvXaF.js.map +1 -0
  28. package/dist/index/esm/QueryPanel-DZ_DkGW8.js +37 -0
  29. package/dist/index/esm/QueryPanel-DZ_DkGW8.js.map +1 -0
  30. package/dist/index/esm/index-C2wxUU0I.js +38645 -0
  31. package/dist/index/esm/index-C2wxUU0I.js.map +1 -0
  32. package/dist/index/esm/index-XWpB4JSs.js +38636 -0
  33. package/dist/index/esm/index-XWpB4JSs.js.map +1 -0
  34. package/dist/index/esm/index.js +1 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/pages/cjs/CohortBuilder-DSb4NbaV.js +570 -0
  37. package/dist/pages/cjs/CohortBuilder-DSb4NbaV.js.map +1 -0
  38. package/dist/pages/cjs/CohortBuilder-DZfy_UsD.js +570 -0
  39. package/dist/pages/cjs/CohortBuilder-DZfy_UsD.js.map +1 -0
  40. package/dist/pages/cjs/index-BoO7NZz4.js +29027 -0
  41. package/dist/pages/cjs/index-BoO7NZz4.js.map +1 -0
  42. package/dist/pages/cjs/index-LxlqqT9v.js +29018 -0
  43. package/dist/pages/cjs/index-LxlqqT9v.js.map +1 -0
  44. package/dist/pages/cjs/index.js +1 -1
  45. package/dist/pages/esm/CohortBuilder-BtRdgox5.js +567 -0
  46. package/dist/pages/esm/CohortBuilder-BtRdgox5.js.map +1 -0
  47. package/dist/pages/esm/CohortBuilder-CRvBOJOa.js +567 -0
  48. package/dist/pages/esm/CohortBuilder-CRvBOJOa.js.map +1 -0
  49. package/dist/pages/esm/index-BM37HQIq.js +28942 -0
  50. package/dist/pages/esm/index-BM37HQIq.js.map +1 -0
  51. package/dist/pages/esm/index-CaxiVweb.js +28933 -0
  52. package/dist/pages/esm/index-CaxiVweb.js.map +1 -0
  53. package/dist/pages/esm/index.js +1 -1
  54. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-DtF9MMkl.js');
3
+ var index = require('./index-BoO7NZz4.js');
4
4
  require('react/jsx-runtime');
5
5
  require('react');
6
6
  require('next/navigation');
@@ -0,0 +1,567 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useState, useEffect, useMemo, useCallback } from 'react';
3
+ import { useDeepCompareMemo, useDeepCompareCallback, useDeepCompareEffect } from 'use-deep-compare';
4
+ import { Tabs } from '@mantine/core';
5
+ import { capitalize, partial } from 'lodash';
6
+ import { useLazyGetMultipleSowerJobStatusQuery, Accessibility, useCoreSelector, selectSharedFilters, useCoreDispatch, selectIndexFilters, selectCurrentCohortId, selectAllCohortFiltersCollapsed, clearCohortFilters, useGetAggsQuery, isIntersection, extractEnumFilterValue, useGetCountsQuery, useSubmitSowerJobMutation, toggleCohortBuilderAllFilters, setSharedFilters } from '@gen3/core';
7
+ import { g as getAllFieldsFromFilterConfigs, r as removeIntersectionFromEnum, p as processBucketData, e as extractRangeValues, a as processRangeData, u as useFieldNameToLabel, b as useToggleExpandFilter, c as useFilterExpandedState, d as useClearFilters, f as useGetFacetFilters, h as useUpdateFilters, i as useSetCohortFilterCombineState, j as useCohortFilterCombineState, k as classifyFacets, E as ErrorCard, Q as QueryExpression, D as DropdownPanel, l as DownloadsPanel, C as CountsValue, m as CollapsableCharts, n as Charts, o as ExplorerTable, q as CohortManager } from './index-BM37HQIq.js';
8
+ import 'echarts';
9
+ import { useMediaQuery } from '@mantine/hooks';
10
+ import 'victory';
11
+ import 'react-icons/bs';
12
+ import 'react-icons/io';
13
+ import '@mantine/form';
14
+ import 'react-icons/md';
15
+ import 'react-icons/ri';
16
+ import 'react-icons/fa';
17
+ import 'react-icons/pi';
18
+ import '@iconify-icon/react';
19
+ import '@mantine/modals';
20
+ import 'tailwind-merge';
21
+ import 'next/navigation';
22
+ import 'next/image';
23
+ import 'next/link';
24
+ import 'next/router';
25
+ import 'cookies-next';
26
+ import 'swr';
27
+ import 'jose';
28
+ import 'cookie';
29
+ import '@gen3/core/server';
30
+ import '@mantine/notifications';
31
+ import 'react-markdown';
32
+ import 'react-icons/ai';
33
+ import 'next/head';
34
+ import 'remark-gfm';
35
+ import 'rehype-sanitize';
36
+ import 'fs';
37
+ import 'path';
38
+ import 'mantine-react-table-open';
39
+ import 'react-icons/ti';
40
+ import 'react-icons/fi';
41
+ import 'react-minisearch';
42
+ import 'minisearch';
43
+ import 'file-saver';
44
+ import 'tailwind-styled-components';
45
+ import 'jsonpath-plus';
46
+ import 'react-icons/lu';
47
+ import 'react-dom';
48
+ import 'lodash/uniq';
49
+ import 'lodash/sum';
50
+ import 'react-icons/fa6';
51
+ import '@tanstack/react-table';
52
+ import '@theothergothamdev/pluralize-ts';
53
+ import 'next/dynamic';
54
+ import 'react-cookie';
55
+ import 'default-composer';
56
+ import 'filesize';
57
+ import '@dnd-kit/core';
58
+ import '@dnd-kit/sortable';
59
+ import '@dnd-kit/utilities';
60
+ import '@dnd-kit/modifiers';
61
+ import 'universal-cookie';
62
+
63
+ const toDisplayName = (field)=>{
64
+ const parsed = field.split('.');
65
+ const fieldName = parsed.at(-1);
66
+ if (!fieldName) return 'NotSet';
67
+ return fieldName.split('_').map((w)=>capitalize(w)).join(' ');
68
+ };
69
+
70
+ /**
71
+ * Hook that sets up an event bus for components to subscribe to and fire off events
72
+ * when an active Sower job is completed.
73
+ */ const useSowerJobEventBus = ()=>{
74
+ const [listeners, setListeners] = useState({});
75
+ const [pollers, setPollers] = useState(new Set());
76
+ const [trigger, statusResult] = useLazyGetMultipleSowerJobStatusQuery({
77
+ pollingInterval: 10000,
78
+ skipPollingIfUnfocused: true
79
+ });
80
+ /**
81
+ * Function for component to subscribe to sower job updates
82
+ * @param listenerKey unique key for component
83
+ * @param newPollers list of jobs to poll the status of
84
+ * @param callback function to call when a job completes
85
+ */ const on = (listenerKey, newPollers, callback)=>{
86
+ setListeners({
87
+ ...listeners,
88
+ [listenerKey]: callback
89
+ });
90
+ setPollers(new Set([
91
+ ...pollers,
92
+ ...newPollers
93
+ ]));
94
+ };
95
+ /**
96
+ * Function for component to unsubscribe to updates
97
+ * @param listenerKey unique key for component
98
+ */ const off = (listenerKey)=>{
99
+ setListeners(Object.fromEntries(Object.entries(listeners).filter(([key])=>key === listenerKey)));
100
+ };
101
+ /**
102
+ * Function to update the jobs that are polling
103
+ * @param job new job to add to pollers
104
+ */ const update = (job)=>{
105
+ setPollers(new Set([
106
+ ...pollers,
107
+ job
108
+ ]));
109
+ };
110
+ useEffect(()=>{
111
+ trigger(Array.from(pollers));
112
+ }, [
113
+ pollers
114
+ ]);
115
+ useEffect(()=>{
116
+ if (statusResult.isSuccess) {
117
+ Object.entries(statusResult.currentData || {}).map(([job, response])=>{
118
+ if (response.status === 'Completed') {
119
+ Object.values(listeners).forEach((callback)=>callback(job));
120
+ // Remove job from pollers after it has completed
121
+ setPollers(new Set([
122
+ ...pollers
123
+ ].filter((poller)=>poller !== job)));
124
+ }
125
+ });
126
+ }
127
+ }, [
128
+ statusResult
129
+ ]);
130
+ return {
131
+ on,
132
+ off,
133
+ update
134
+ };
135
+ };
136
+
137
+ const EmptyData = {};
138
+ /**
139
+ * CohortPanel is a React component that provides an interactive interface for cohort exploration and filtering.
140
+ * It integrates with data services and facilitates visualization, filtering, and analysis tasks.
141
+ *
142
+ * @param {Object} props The properties required to configure the CohortPanel component.
143
+ * @param {Object} props.guppyConfig Configuration object for Guppy, including field mappings and data type information.
144
+ * @param {Object} props.filters Configuration for filter tabs, including filter fields and layout.
145
+ * @param {Object} [props.charts={}] Optional set of chart configuration objects for rendering summaries.
146
+ * @param {Object} [props.chartsSection] Optional configuration for an additional section of charts.
147
+ * @param {Object} props.table Reference to the table configuration or component for displaying data.
148
+ * @param {string} props.tabTitle Title for the filter tab section.
149
+ * @param {Object[]|undefined} props.dropdowns Dropdown menu configuration, allowing for additional filter options or actions.
150
+ * @param {Object[]|undefined} props.buttons List of button configurations for actions such as downloads.
151
+ * @param {boolean} props.loginForDownload Determines whether login is required to enable download functionality.
152
+ * @param {boolean} [props.showAccessLevel=false] Indicates if the user access level should be displayed on the panel.
153
+ *
154
+ * @returns {JSX.Element} Returns a JSX element rendering the CohortPanel. This includes filter options,
155
+ * summary charts, cohort manager, and data display components.
156
+ */ const CohortPanel = ({ guppyConfig, filters, charts = {}, chartsSection = undefined, table, tabTitle, dropdowns, buttons, loginForDownload, showAccessLevel = false })=>{
157
+ const isSm = useMediaQuery('(min-width: 639px)');
158
+ const isMd = useMediaQuery('(min-width: 1373px)');
159
+ const isXl = useMediaQuery('(min-width: 1600px)');
160
+ const [accessLevel, setAccessLevel] = useState(Accessibility.ALL);
161
+ const sharedFiltersMap = useCoreSelector((state)=>selectSharedFilters(state));
162
+ const defaultDropdowns = useMemo(()=>dropdowns ?? {}, [
163
+ dropdowns
164
+ ]);
165
+ const defaultButtons = useMemo(()=>buttons ?? [], [
166
+ buttons
167
+ ]);
168
+ const numCols = useMemo(()=>{
169
+ if (isSm) return 1;
170
+ if (isMd) return 2;
171
+ if (isXl) return 4;
172
+ return 3;
173
+ }, [
174
+ isSm,
175
+ isMd,
176
+ isXl
177
+ ]);
178
+ const index = guppyConfig.dataType;
179
+ const indexPrefix = guppyConfig?.indexPrefix ?? '';
180
+ const fields = useMemo(()=>getAllFieldsFromFilterConfigs(filters?.tabs ?? []), [
181
+ filters?.tabs
182
+ ]);
183
+ const coreDispatch = useCoreDispatch();
184
+ const [facetDefinitions, setFacetDefinitions] = useState({});
185
+ const [summaryCharts, setSummaryCharts] = useState({});
186
+ const cohortFilters = useCoreSelector((state)=>selectIndexFilters(state, index));
187
+ const cohortId = useCoreSelector((state)=>selectCurrentCohortId(state));
188
+ const allFiltersCollapsed = useCoreSelector((state)=>selectAllCohortFiltersCollapsed(state, index));
189
+ const toggleAllFiltersExpanded = (expand)=>{
190
+ coreDispatch(toggleCohortBuilderAllFilters({
191
+ expand,
192
+ index
193
+ }));
194
+ };
195
+ const clearAllFilters = useCallback(()=>{
196
+ coreDispatch(clearCohortFilters({
197
+ index
198
+ }));
199
+ }, [
200
+ coreDispatch,
201
+ index
202
+ ]);
203
+ const { data, isSuccess, isFetching: isAggsQueryFetching, isError: isAggsQueryError } = useGetAggsQuery({
204
+ type: index,
205
+ fields: fields,
206
+ filters: cohortFilters,
207
+ accessibility: accessLevel,
208
+ queryId: cohortId,
209
+ indexPrefix: indexPrefix
210
+ });
211
+ const chartKeys = useDeepCompareMemo(()=>[
212
+ ...Object.keys(chartsSection?.charts ?? {}),
213
+ ...Object.keys(charts)
214
+ ], [
215
+ chartsSection?.charts,
216
+ charts
217
+ ]);
218
+ const { data: chartData, isSuccess: isChartSuccess, isFetching: isChartFetching, isError: isChartError } = useGetAggsQuery({
219
+ type: index,
220
+ fields: chartKeys,
221
+ filters: cohortFilters,
222
+ accessibility: accessLevel,
223
+ filterSelf: true,
224
+ queryId: cohortId,
225
+ indexPrefix: indexPrefix
226
+ }, {
227
+ skip: chartKeys.length === 0
228
+ });
229
+ const cleanChartData = useDeepCompareMemo(()=>{
230
+ if (isChartSuccess && chartData) {
231
+ const cleanedData = {};
232
+ const totalCount = chartData._totalCount[0]?.count;
233
+ Object.keys(summaryCharts).forEach((key)=>{
234
+ if (!(key in chartData)) {
235
+ return;
236
+ } // handle missing key in data
237
+ // remove empty keys
238
+ cleanedData[key] = chartData[key].filter((x)=>typeof x.key !== 'string' ? true : x.key !== '');
239
+ const facetDef = facetDefinitions?.[key];
240
+ if (facetDef?.excludeValues) {
241
+ cleanedData[key] = cleanedData[key].filter((x)=>typeof x.key !== 'string' ? true : facetDef?.excludeValues?.includes(String(x.key)) === false);
242
+ }
243
+ if (cleanedData[key].length === 0 && totalCount) {
244
+ // if no keys adds back no data
245
+ cleanedData[key] = [
246
+ {
247
+ key: 'no data',
248
+ count: totalCount
249
+ }
250
+ ];
251
+ }
252
+ });
253
+ return cleanedData;
254
+ }
255
+ return chartData;
256
+ }, [
257
+ chartData,
258
+ isChartSuccess,
259
+ summaryCharts
260
+ ]);
261
+ const getEnumFacetData = useDeepCompareCallback((field)=>{
262
+ let filters = undefined;
263
+ let combineMode = 'or';
264
+ if (field in cohortFilters.root) {
265
+ if (isIntersection(cohortFilters.root[field])) {
266
+ const intersectionFilters = removeIntersectionFromEnum(cohortFilters.root[field]);
267
+ if (intersectionFilters) {
268
+ filters = extractEnumFilterValue(intersectionFilters);
269
+ combineMode = 'and';
270
+ }
271
+ } else {
272
+ filters = extractEnumFilterValue(cohortFilters.root[field]);
273
+ }
274
+ }
275
+ return {
276
+ data: processBucketData(data?.[field]),
277
+ enumFilters: filters,
278
+ combineMode: combineMode,
279
+ isSuccess: isSuccess
280
+ };
281
+ }, [
282
+ cohortFilters.root,
283
+ data,
284
+ isSuccess
285
+ ]);
286
+ const getRangeFacetData = useDeepCompareCallback((field)=>{
287
+ return {
288
+ data: processRangeData(data?.[field]),
289
+ filters: extractRangeValues(cohortFilters.root[field]),
290
+ isSuccess: isSuccess
291
+ };
292
+ }, [
293
+ data,
294
+ cohortFilters.root,
295
+ isSuccess
296
+ ]);
297
+ // Set up the hooks for the facet components to use based on the required index
298
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
299
+ // @ts-ignore
300
+ const facetDataHooks = useDeepCompareMemo(()=>{
301
+ return {
302
+ // TODO: see if there a better way to do this
303
+ enum: {
304
+ useGetFacetData: getEnumFacetData,
305
+ useUpdateFacetFilters: partial(useUpdateFilters, index),
306
+ useGetFacetFilters: partial(useGetFacetFilters, index),
307
+ useClearFilter: partial(useClearFilters, index),
308
+ useFilterExpanded: partial(useFilterExpandedState, index),
309
+ useToggleExpandFilter: partial(useToggleExpandFilter, index),
310
+ useGetCombineMode: partial(useCohortFilterCombineState, index),
311
+ useSetCombineMode: partial(useSetCohortFilterCombineState, index),
312
+ useFieldNameToLabel: useFieldNameToLabel,
313
+ useTotalCounts: undefined
314
+ },
315
+ exact: {
316
+ useGetFacetData: getEnumFacetData,
317
+ useUpdateFacetFilters: partial(useUpdateFilters, index),
318
+ useGetFacetFilters: partial(useGetFacetFilters, index),
319
+ useClearFilter: partial(useClearFilters, index),
320
+ useFilterExpanded: partial(useFilterExpandedState, index),
321
+ useToggleExpandFilter: partial(useToggleExpandFilter, index),
322
+ useFieldNameToLabel: useFieldNameToLabel,
323
+ useTotalCounts: undefined
324
+ },
325
+ multiselect: {
326
+ useGetFacetData: getEnumFacetData,
327
+ useUpdateFacetFilters: partial(useUpdateFilters, index),
328
+ useGetFacetFilters: partial(useGetFacetFilters, index),
329
+ useClearFilter: partial(useClearFilters, index),
330
+ useFilterExpanded: partial(useFilterExpandedState, index),
331
+ useToggleExpandFilter: partial(useToggleExpandFilter, index),
332
+ useFieldNameToLabel: useFieldNameToLabel,
333
+ useTotalCounts: undefined
334
+ },
335
+ range: {
336
+ useGetFacetData: getRangeFacetData,
337
+ useUpdateFacetFilters: partial(useUpdateFilters, index),
338
+ useGetFacetFilters: partial(useGetFacetFilters, index),
339
+ useClearFilter: partial(useClearFilters, index),
340
+ useFilterExpanded: partial(useFilterExpandedState, index),
341
+ useToggleExpandFilter: partial(useToggleExpandFilter, index),
342
+ useFieldNameToLabel: useFieldNameToLabel,
343
+ useTotalCounts: undefined
344
+ }
345
+ };
346
+ }, [
347
+ getEnumFacetData,
348
+ getRangeFacetData,
349
+ index
350
+ ]);
351
+ // Set the facet definitions based on the data only the first time the data is loaded
352
+ useDeepCompareEffect(()=>{
353
+ if (isSuccess && Object.keys(facetDefinitions).length === 0) {
354
+ const configFacetDefs = filters?.tabs.reduce((acc, tab)=>{
355
+ return {
356
+ ...tab.fieldsConfig,
357
+ ...acc
358
+ };
359
+ }, {});
360
+ const facetDefs = classifyFacets(data, index, guppyConfig?.fieldMapping ?? [], configFacetDefs ?? {}, sharedFiltersMap);
361
+ setFacetDefinitions(facetDefs);
362
+ // setup summary charts since nested fields can be listed by the split field name
363
+ const chartDefinitions = chartsSection?.charts ?? charts;
364
+ const summaryCharts = Object.keys(chartDefinitions).reduce((acc, field)=>{
365
+ let chartField = field;
366
+ if (facetDefs?.[field] === undefined) {
367
+ const res = Object.values(facetDefs).filter((def)=>{
368
+ return def.dataField === field;
369
+ });
370
+ if (res.length > 0) {
371
+ chartField = res[0].field;
372
+ }
373
+ }
374
+ return {
375
+ ...acc,
376
+ [chartField]: chartDefinitions[field]
377
+ };
378
+ }, {});
379
+ setSummaryCharts(summaryCharts);
380
+ }
381
+ }, [
382
+ isSuccess,
383
+ data,
384
+ facetDefinitions,
385
+ index,
386
+ guppyConfig.fieldMapping,
387
+ charts,
388
+ chartsSection
389
+ ]);
390
+ const { data: counts, isFetching: isCountsFetching, isError: isCountsError } = useGetCountsQuery({
391
+ type: index,
392
+ filters: cohortFilters,
393
+ accessibility: accessLevel,
394
+ queryId: cohortId
395
+ });
396
+ const [submitJob, result] = useSubmitSowerJobMutation();
397
+ const { update } = useSowerJobEventBus();
398
+ useEffect(()=>{
399
+ if (result?.data) {
400
+ update(result.data?.uid);
401
+ }
402
+ }, [
403
+ result
404
+ ]);
405
+ if (isCountsError || isAggsQueryError) {
406
+ return /*#__PURE__*/ jsx(ErrorCard, {
407
+ message: "Unable to fetch data from server"
408
+ }); // TODO: replace with configurable message
409
+ }
410
+ return /*#__PURE__*/ jsxs("div", {
411
+ className: "flex flex-col mt-3 relative px-4 bg-base-lightest w-full",
412
+ children: [
413
+ /*#__PURE__*/ jsx(QueryExpression, {
414
+ index: index
415
+ }),
416
+ /*#__PURE__*/ jsxs("div", {
417
+ className: "flex w-full",
418
+ children: [
419
+ /*#__PURE__*/ jsx("div", {
420
+ id: "cohort-builder-filters",
421
+ className: "flex-shrink-0 md:w-1/4 lg:w-1/5",
422
+ children: filters?.tabs && /*#__PURE__*/ jsx(DropdownPanel, {
423
+ filters: filters,
424
+ tabTitle: tabTitle,
425
+ facetDefinitions: facetDefinitions,
426
+ facetDataHooks: facetDataHooks,
427
+ onAccessChange: setAccessLevel,
428
+ accessLevel: accessLevel,
429
+ showAccessLevel: showAccessLevel,
430
+ allFiltersCollapsed: allFiltersCollapsed,
431
+ toggleAllFiltersExpanded: toggleAllFiltersExpanded,
432
+ clearAllFilters: clearAllFilters
433
+ })
434
+ }),
435
+ /*#__PURE__*/ jsxs("div", {
436
+ id: "cohort-builder-content",
437
+ className: "flex flex-col md:w-3/4 lg:w-4/5 pl-4",
438
+ children: [
439
+ /*#__PURE__*/ jsxs("div", {
440
+ className: "flex justify-between mb-2 ml-2",
441
+ children: [
442
+ /*#__PURE__*/ jsx(DownloadsPanel, {
443
+ dropdowns: defaultDropdowns,
444
+ buttons: defaultButtons,
445
+ loginForDownload: loginForDownload,
446
+ index: index,
447
+ totalCount: counts ?? 0,
448
+ fields: table?.fields ?? [],
449
+ filter: cohortFilters
450
+ }),
451
+ /*#__PURE__*/ jsx(CountsValue, {
452
+ label: guppyConfig?.nodeCountTitle || toDisplayName(index),
453
+ counts: counts,
454
+ isFetching: isCountsFetching,
455
+ isError: isCountsError
456
+ })
457
+ ]
458
+ }),
459
+ chartsSection?.enabled ? /*#__PURE__*/ jsx(CollapsableCharts, {
460
+ config: {
461
+ ...chartsSection,
462
+ charts: summaryCharts
463
+ },
464
+ data: cleanChartData ?? EmptyData,
465
+ isSuccess: isChartSuccess,
466
+ isFetching: isChartFetching,
467
+ isError: isChartError
468
+ }) : /*#__PURE__*/ jsx(Charts, {
469
+ charts: summaryCharts,
470
+ data: cleanChartData ?? EmptyData,
471
+ counts: counts,
472
+ isSuccess: isChartSuccess,
473
+ isError: isChartError,
474
+ numCols: numCols
475
+ }),
476
+ table?.enabled && /*#__PURE__*/ jsx(Fragment, {
477
+ children: /*#__PURE__*/ jsx("div", {
478
+ className: "mt-2 flex flex-col",
479
+ children: /*#__PURE__*/ jsx(ExplorerTable, {
480
+ index: index,
481
+ tableConfig: table,
482
+ accessibility: accessLevel
483
+ })
484
+ })
485
+ })
486
+ ]
487
+ })
488
+ ]
489
+ })
490
+ ]
491
+ });
492
+ };
493
+
494
+ const TabsLayoutToComponentProp = (tabsLayout)=>{
495
+ if (!tabsLayout) {
496
+ return 'flex-start';
497
+ }
498
+ switch(tabsLayout){
499
+ case 'left':
500
+ {
501
+ return 'flex-start';
502
+ }
503
+ case 'right':
504
+ {
505
+ return 'flex-end';
506
+ }
507
+ case 'center':
508
+ {
509
+ return 'center';
510
+ }
511
+ default:
512
+ {
513
+ return 'flex-start';
514
+ }
515
+ }
516
+ };
517
+
518
+ const useGetCurrentCohort = ()=>{
519
+ return useCoreSelector((state)=>selectCurrentCohortId(state));
520
+ };
521
+ const CohortBuilder = ({ explorerConfig, sharedFiltersMap = null, tabsLayout = 'left', enableCohortManager = true, activeTab })=>{
522
+ const dispatch = useCoreDispatch();
523
+ dispatch(setSharedFilters(sharedFiltersMap ?? {}));
524
+ const configuration = useDeepCompareMemo(()=>explorerConfig, [
525
+ explorerConfig
526
+ ]);
527
+ return /*#__PURE__*/ jsxs("div", {
528
+ className: "flex flex-col w-full mt-2",
529
+ children: [
530
+ enableCohortManager ? /*#__PURE__*/ jsx(CohortManager, {}) : null,
531
+ /*#__PURE__*/ jsxs(Tabs, {
532
+ color: "primary.5",
533
+ variant: explorerConfig[0]?.tabType,
534
+ keepMounted: true,
535
+ defaultValue: activeTab ?? explorerConfig[0].tabTitle,
536
+ children: [
537
+ /*#__PURE__*/ jsx(Tabs.List, {
538
+ className: "w-full",
539
+ justify: TabsLayoutToComponentProp(tabsLayout),
540
+ children: configuration.map((panelConfig)=>/*#__PURE__*/ jsx(Tabs.Tab, {
541
+ value: panelConfig.tabTitle,
542
+ children: panelConfig.tabTitle
543
+ }, `${panelConfig.tabTitle}-tabList`))
544
+ }),
545
+ configuration.map((panelConfig)=>/*#__PURE__*/ jsx(Tabs.Panel, {
546
+ value: panelConfig.tabTitle,
547
+ children: /*#__PURE__*/ jsx(CohortPanel, {
548
+ guppyConfig: panelConfig.guppyConfig,
549
+ chartsSection: panelConfig?.chartsSection,
550
+ charts: panelConfig?.charts,
551
+ filters: panelConfig.filters,
552
+ tabTitle: panelConfig.tabTitle,
553
+ table: panelConfig.table,
554
+ dropdowns: panelConfig.dropdowns,
555
+ buttons: panelConfig.buttons,
556
+ loginForDownload: panelConfig.loginForDownload,
557
+ sharedFiltersMap: panelConfig.sharedFiltersMap
558
+ }, `${panelConfig.tabTitle}-CohortPanel`)
559
+ }, `${panelConfig.tabTitle}-tabPanel`))
560
+ ]
561
+ })
562
+ ]
563
+ });
564
+ };
565
+
566
+ export { CohortBuilder as default, useGetCurrentCohort };
567
+ //# sourceMappingURL=CohortBuilder-BtRdgox5.js.map