@gen3/frontend 0.12.62 → 0.12.63

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