@devtable/dashboard 14.57.1 → 14.57.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-caller/index.d.ts +2 -3
- package/dist/api-caller/request.d.ts +4 -5
- package/dist/api-caller/types.d.ts +0 -1
- package/dist/components/filter/custom-default-value-editor.d.ts +1 -2
- package/dist/components/filter/default-value-mode-selector.d.ts +1 -2
- package/dist/components/filter/error-message-or-not-found.d.ts +1 -1
- package/dist/components/filter/filter-checkbox/editor.d.ts +1 -2
- package/dist/components/filter/filter-checkbox/render.d.ts +3 -3
- package/dist/components/filter/filter-date-range/editor.d.ts +2 -2
- package/dist/components/filter/filter-date-range/filter-date-range-for-editor-field.d.ts +1 -2
- package/dist/components/filter/filter-date-range/render.d.ts +1 -2
- package/dist/components/filter/filter-date-range/widget/calendar.d.ts +1 -2
- package/dist/components/filter/filter-date-range/widget/count-days.d.ts +1 -2
- package/dist/components/filter/filter-date-range/widget/hints.d.ts +1 -1
- package/dist/components/filter/filter-date-range/widget/index.d.ts +1 -2
- package/dist/components/filter/filter-date-range/widget/shortcuts/index.d.ts +1 -2
- package/dist/components/filter/filter-date-range/widget/shortcuts/shortcuts.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/editor.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/render.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/calendar.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/day-picker.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/month-picker.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/quarter-picker.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/use-get-day-props.d.ts +0 -1
- package/dist/components/filter/filter-merico-date-range/widget/calendar/utils.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/calendar/week-picker.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/count-days.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/index.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/select-step.d.ts +2 -3
- package/dist/components/filter/filter-merico-date-range/widget/shortcuts/index.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/shortcuts/shortcuts.d.ts +1 -2
- package/dist/components/filter/filter-merico-date-range/widget/utils.d.ts +0 -1
- package/dist/components/filter/filter-multi-select/editor.d.ts +2 -2
- package/dist/components/filter/filter-multi-select/render/index.d.ts +1 -2
- package/dist/components/filter/filter-multi-select/render/widget.d.ts +1 -2
- package/dist/components/filter/filter-multi-select/render/widget.styles.d.ts +1 -2
- package/dist/components/filter/filter-select/editor/editor.d.ts +1 -2
- package/dist/components/filter/filter-select/editor/preset-option-series.d.ts +0 -1
- package/dist/components/filter/filter-select/editor/static-options.d.ts +1 -2
- package/dist/components/filter/filter-select/render.d.ts +1 -2
- package/dist/components/filter/filter-settings/filter-setting.d.ts +1 -2
- package/dist/components/filter/filter-settings/filter-settings.d.ts +2 -2
- package/dist/components/filter/filter-settings/filter-usage-table.d.ts +1 -2
- package/dist/components/filter/filter-settings/index.d.ts +1 -1
- package/dist/components/filter/filter-settings/preview-filter.d.ts +1 -2
- package/dist/components/filter/filter-settings/types.d.ts +0 -1
- package/dist/components/filter/filter-text-input/editor.d.ts +2 -2
- package/dist/components/filter/filter-text-input/render.d.ts +3 -3
- package/dist/components/filter/filter-tree/common/expected-structure.d.ts +1 -1
- package/dist/components/filter/filter-tree/common/query-data-to-tree.d.ts +1 -2
- package/dist/components/filter/filter-tree/common/switcher-icon.d.ts +1 -2
- package/dist/components/filter/filter-tree/common/tree-icon.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-select/editor/filter-tree-select-editor.d.ts +2 -2
- package/dist/components/filter/filter-tree/filter-tree-select/render/filter-tree-select-render.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-select/render/use-select-all.d.ts +0 -1
- package/dist/components/filter/filter-tree/filter-tree-select/render/widget.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-select/render/widget.styles.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-single-select/editor/filter-tree-single-select-editor.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-single-select/render/filter-tree-single-select-render.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-single-select/render/widget.d.ts +1 -2
- package/dist/components/filter/filter-tree/filter-tree-single-select/render/widget.styles.d.ts +1 -2
- package/dist/components/filter/filter.d.ts +1 -2
- package/dist/components/filter/index.d.ts +2 -2
- package/dist/components/filter/pick-query-for-filter/expected-structure-for-select.d.ts +1 -1
- package/dist/components/filter/pick-query-for-filter/index.d.ts +1 -1
- package/dist/components/filter/search-button/index.d.ts +2 -2
- package/dist/components/filter/select-item.d.ts +0 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/delete-panel.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/dropdown-menu-items.d.ts +2 -2
- package/dist/components/panel/panel-editor/dropdown-menu-items/duplicate.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/open-tab-data.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/open-tab-interaction.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/open-tab-panel.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/open-tab-variable.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/open-tab-visualization.d.ts +1 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/query-menu-items.d.ts +1 -2
- package/dist/components/panel/panel-editor/dropdown-menu-items/use-items.d.ts +0 -1
- package/dist/components/panel/panel-editor/dropdown-menu-items/use-query-items.d.ts +1 -2
- package/dist/components/panel/panel-editor/index.d.ts +2 -2
- package/dist/components/panel/panel-render/client-panel-render.d.ts +1 -1
- package/dist/components/panel/panel-render/description-popover/index.d.ts +1 -1
- package/dist/components/panel/panel-render/dropdown-menu-items/download-data.d.ts +1 -1
- package/dist/components/panel/panel-render/dropdown-menu-items/download-schema.d.ts +1 -1
- package/dist/components/panel/panel-render/dropdown-menu-items/download-screenshot.d.ts +1 -1
- package/dist/components/panel/panel-render/dropdown-menu-items/dropdown-menu-items.d.ts +2 -2
- package/dist/components/panel/panel-render/dropdown-menu-items/enter-fullscreen.d.ts +1 -2
- package/dist/components/panel/panel-render/dropdown-menu-items/refresh.d.ts +1 -1
- package/dist/components/panel/panel-render/dropdown-menu-items/use-items.d.ts +0 -1
- package/dist/components/panel/panel-render/full-screen-render/full-screen-panel.d.ts +2 -2
- package/dist/components/panel/panel-render/full-screen-render/use-panel-full-screen.d.ts +0 -1
- package/dist/components/panel/panel-render/panel-addon-context.d.ts +6 -0
- package/dist/components/panel/panel-render/panel-dropdown-menu.d.ts +2 -3
- package/dist/components/panel/panel-render/panel-render-base.d.ts +2 -3
- package/dist/components/panel/panel-render/panel-render.d.ts +1 -2
- package/dist/components/panel/panel-render/panel-viz-features.d.ts +2 -3
- package/dist/components/panel/panel-render/title-bar/index.d.ts +1 -1
- package/dist/components/panel/panel-render/top-right-actions/index.d.ts +10 -0
- package/dist/components/panel/panel-render/use-download-panel-screenshot.d.ts +2 -2
- package/dist/components/panel/panel-render/viz/panel-error-or-state-message.d.ts +1 -2
- package/dist/components/panel/panel-render/viz/panel-viz-section.d.ts +1 -2
- package/dist/components/panel/panel-render/viz/viz.d.ts +3 -3
- package/dist/components/panel/plugin-adaptor.d.ts +3 -4
- package/dist/components/panel/settings/common/aggregation-selector.d.ts +1 -2
- package/dist/components/panel/settings/common/data-field-selector.d.ts +1 -2
- package/dist/components/panel/settings/common/mantine-color-swatches.d.ts +1 -1
- package/dist/components/panel/settings/common/mantine-font-weight.d.ts +1 -2
- package/dist/components/panel/settings/common/mantine-size-selector.d.ts +2 -2
- package/dist/components/panel/settings/common/numbro-format-selector.d.ts +1 -2
- package/dist/components/panel/settings/common/panel-query-selector.d.ts +1 -2
- package/dist/components/panel/settings/common/variable-selector/variable-selector-item.d.ts +2 -2
- package/dist/components/panel/settings/common/variable-selector/variable-selector.d.ts +1 -2
- package/dist/components/panel/use-config-viz-instance-service.d.ts +2 -3
- package/dist/components/plugins/color-manager/color-manager.d.ts +0 -1
- package/dist/components/plugins/color-manager/impl.d.ts +1 -2
- package/dist/components/plugins/color-manager/multi-step-value-mapper.d.ts +0 -1
- package/dist/components/plugins/colors/diverging-color.d.ts +0 -1
- package/dist/components/plugins/colors/index.d.ts +0 -1
- package/dist/components/plugins/colors/sequential-color.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/axis-label-overflow/axis-label-overflow-field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/axis-label-overflow/overflow-field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/axis-label-overflow/overflow-option.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/axis-label-rotate/axis-label-rotate-input.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/label-position/label-position-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/line-area-style/line-area-origin-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/line-area-style/line-area-style-field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/line-area-style/temp-color-input.d.ts +1 -1
- package/dist/components/plugins/common-echarts-fields/line-type/line-type-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/name-text-align/name-text-align-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/field/dynamic-function-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/field/dynamic.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/field/index.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/field/static.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/get-number-or-dynamic-value.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/orientation/orientation-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/reference-area/field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/reference-area/option.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/reference-area/types.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/regression-line/option.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/regression-line/types.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/series-order/series-order-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/series-unit/series-unit-field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/stats-around-viz/stats-around-viz.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/symbol-size/dynamic-size-function-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/symbol-size/dynamic.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/symbol-size/static.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/symbol-size/symbol-size-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/tooltip-metric/types.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/visual-map/types.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/visual-map/utils.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/continuous/gradient-editor.d.ts +1 -1
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/continuous/index.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/continuous/preview-gradient-and-apply-palette.d.ts +1 -1
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/continuous/skip-range-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/index.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/piecewise/index.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/piecewise/interval-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/piecewise/piece-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/piecewise/pieces-editor.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/preview-visual-map.d.ts +1 -2
- package/dist/components/plugins/common-echarts-fields/visual-map/visual-map-editor/types.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/x-axis-label-formatter/function-editor.d.ts +1 -1
- package/dist/components/plugins/common-echarts-fields/x-axis-label-formatter/get-echarts-x-axis-tick-label.d.ts +0 -1
- package/dist/components/plugins/common-echarts-fields/x-axis-label-formatter/x-axis-label-formatter-field.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/x-axis-position/x-axis-position-selector.d.ts +2 -2
- package/dist/components/plugins/common-echarts-fields/y-axis-position/y-axis-position-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/color-interpolation-select/index.d.ts +2 -3
- package/dist/components/plugins/editor-components/color-mapping-editor/index.d.ts +2 -2
- package/dist/components/plugins/editor-components/color-mapping-editor/style.d.ts +1 -1
- package/dist/components/plugins/editor-components/color-type/color-type-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/field-array-tabs/field-array-tabs.d.ts +2 -3
- package/dist/components/plugins/editor-components/field-array-tabs/tab-list.d.ts +2 -3
- package/dist/components/plugins/editor-components/field-array-tabs/types.d.ts +1 -2
- package/dist/components/plugins/editor-components/flex/align-items-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/flex/justify-content-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/horizontal-align-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/vertical-align-selector.d.ts +2 -2
- package/dist/components/plugins/editor-components/viz-config-banner.d.ts +1 -1
- package/dist/components/plugins/hooks/use-channel-event.d.ts +0 -1
- package/dist/components/plugins/hooks/use-current-viz-instance.d.ts +1 -1
- package/dist/components/plugins/hooks/use-handle-chart-render-finished.d.ts +0 -1
- package/dist/components/plugins/hooks/use-row-data-map.d.ts +1 -2
- package/dist/components/plugins/hooks/use-storage-data.d.ts +0 -1
- package/dist/components/plugins/hooks/use-tab-state.d.ts +1 -1
- package/dist/components/plugins/instance-migrator/index.d.ts +1 -2
- package/dist/components/plugins/json-plugin-storage.d.ts +0 -1
- package/dist/components/plugins/message-channels.d.ts +1 -2
- package/dist/components/plugins/panel-addon/index.d.ts +1 -1
- package/dist/components/plugins/panel-addon/panel-addon-manager.d.ts +1 -2
- package/dist/components/plugins/plugin-context.d.ts +5560 -5558
- package/dist/components/plugins/plugin-data-migrator/plugin-data-migrator.d.ts +0 -1
- package/dist/components/plugins/plugin-data-migrator/version-based-migrator.d.ts +0 -1
- package/dist/components/plugins/plugin-manager.d.ts +0 -1
- package/dist/components/plugins/service/service-locator/use-service-locator.d.ts +3 -4
- package/dist/components/plugins/service/use-top-level-services.d.ts +2 -3
- package/dist/components/plugins/sub-tree-json-plugin-storage.d.ts +0 -1
- package/dist/components/plugins/test-utils.d.ts +0 -1
- package/dist/components/plugins/viz-components/bar-3d-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/bar-3d-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/bar-3d-chart/viz-bar-3d-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/bar-3d-chart/viz-bar-3d-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/legend/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/reference-lines/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/reference-lines/reference-line.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/editors/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/option/common.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/dataset.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/index.d.ts +4 -5
- package/dist/components/plugins/viz-components/boxplot-chart/option/legend.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/reference-line.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/custom/box.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/custom/outliers.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/custom/scatter.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/custom/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/custom/utils.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/series/index.d.ts +3 -4
- package/dist/components/plugins/viz-components/boxplot-chart/option/tooltip/additional-metrics.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/tooltip/boxplot.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/tooltip/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/tooltip/outlier.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/option/tooltip/scatter.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/boxplot-chart/triggers/click-boxplot.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/boxplot-chart/viz-boxplot-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/boxplot-chart/viz-boxplot-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/button/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/button/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/button/triggers/click-button.d.ts +1 -2
- package/dist/components/plugins/viz-components/button/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/button/viz-button-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/button/viz-button.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/editors/calendar/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/editors/heat_block/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/option/formatters.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/option/index.d.ts +2 -3
- package/dist/components/plugins/viz-components/calendar-heatmap/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/triggers/click-calendar-date.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/type.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/viz-calendar-heatmap-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/calendar-heatmap/viz-calendar-heatmap.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/echarts-zooming-field/get-echarts-data-zoom-option.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/editors/echarts-zooming-field/index.d.ts +2 -2
- package/dist/components/plugins/viz-components/cartesian/editors/reference-areas/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/reference-areas/reference-area.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/reference-lines/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/reference-lines/reference-line.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/regressions/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/regressions/regression-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/series/fields.bar.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/series/fields.line.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/series/fields.scatter.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/series/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/series/series-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/stats/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/x-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/y-axes/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/editors/y-axes/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/migrators/index.d.ts +2 -3
- package/dist/components/plugins/viz-components/cartesian/option/events.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/legend.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/regression.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/option/series/data.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/option/series/get-echarts-symbol-size.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/series/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/series/reference_areas.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/series/reference_lines.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/option/series/series_items.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/utils/label-formatter.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/utils/variables.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/x-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/option/y-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/cartesian/triggers/click-echart.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/cartesian/viz-cartesian-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/cartesian/viz-cartesian-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/funnel/editors/series/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/funnel/editors/series/series-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/funnel/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/funnel/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/funnel/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/funnel/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/funnel/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/funnel/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/funnel/viz-funnel-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/funnel/viz-funnel-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/heat_block/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/pagination/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/x-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/editors/y-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/heatmap-pagination.d.ts +1 -1
- package/dist/components/plugins/viz-components/heatmap/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/option/formatters.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/option/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/option/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/render/use-heatmap-grouped-data.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/render/use-heatmap-series-data.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/heatmap/triggers/click-heat-block.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/heatmap/viz-heatmap-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/heatmap/viz-heatmap.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/reference-lines/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/reference-lines/reference-line.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/series/fields.bar.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/series/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/series/series-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/stats/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/x-axes/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/x-axes/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/editors/y-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/legend.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/series/data.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/series/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/series/reference_lines.d.ts +2 -3
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/series/series_items.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/utils/label-formatter.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/utils/variables.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/x-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/option/y-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/horizontal-bar-chart/triggers/click-horizontal-bar-chart-series.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/horizontal-bar-chart/viz-horizontal-bar-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/horizontal-bar-chart/viz-horizontal-bar-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/editors/deviation.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/editors/metrics/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/editors/metrics/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/editors/x_axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/data.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/legend.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/series/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/series/series-1.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/series/series-2.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/series/series-3.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/series/series-4.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/option/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/toolbox/basis-metric-selector.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/toolbox/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/toolbox/metric-description.d.ts +1 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-estimation-chart/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/merico-estimation-chart/viz-merico-estimation-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-estimation-chart/viz-merico-estimation-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/heat_block/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/x-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/editors/y-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/migrators/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/render/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/formatters.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-heatmap/triggers/click-heat-block.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-heatmap/type.d.ts +2 -3
- package/dist/components/plugins/viz-components/merico-linear-gauge/editor/sections-editor/add-a-row.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/editor/sections-editor/row-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/editor/sections-editor/sections-editor.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/editor/sections-editor/select-palette.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/editor/viz-merico-linear-gauge-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-linear-gauge/migrator/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/render/chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/render/option.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-linear-gauge/render/viz-merico-linear-gauge.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-linear-gauge/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-linear-gauge/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-panel-groups/editor/add-a-row.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/editor/get-groups-from-yaml.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/editor/groups-editor.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/editor/row-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/editor/viz-merico-panel-groups-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-panel-groups/migrator/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/render/viz-merico-panel-groups.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-panel-groups/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-stats/editors/metrics/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-stats/editors/metrics/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-stats/editors/metrics/postfix-field.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-stats/editors/styles/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-stats/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-stats/migrators/v2.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-stats/render/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-stats/render/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/merico-stats/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-stats/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/merico-stats/viz-merico-stats-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/bar.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/line.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/mark-line.d.ts +2 -3
- package/dist/components/plugins/viz-components/pareto-chart/editors/reference-lines/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/reference-lines/reference-line.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/x-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/editors/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/index.d.ts +2 -3
- package/dist/components/plugins/viz-components/pareto-chart/option/mark-line-and-area.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/reference_lines.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/utils.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/x-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/option/y-axes.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/pareto-chart/triggers/click-pareto.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/type.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/viz-pareto-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/pareto-chart/viz-pareto-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/editors/pie-color-map-editor/add-a-row.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/editors/pie-color-map-editor/pie-color-map-editor.d.ts +2 -2
- package/dist/components/plugins/viz-components/pie-chart/editors/pie-color-map-editor/row-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/editors/pie-color-map-editor/select-palette.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/editors/radius-slider.d.ts +1 -1
- package/dist/components/plugins/viz-components/pie-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/option/dataset.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/option/index.d.ts +2 -3
- package/dist/components/plugins/viz-components/pie-chart/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/triggers/click-pie-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/pie-chart/viz-pie-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/pie-chart/viz-pie-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/editors/additional-series/additional-series-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/editors/additional-series/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/editors/dimensions/dimension.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/editors/dimensions/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/option/formatter.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/option/series.label.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/triggers/click-radar-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/radar-chart/viz-radar-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/radar-chart/viz-radar-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/editors/regression-field.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/render/option/regression-series.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/render/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/render/toolbox/choose-data-keys/choose-data-keys.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/toolbox/data-key-selector/data-key-selector.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/toolbox/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/toolbox/regression-description/desc.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/toolbox/regression-description/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/regression-chart/render/use-data-key.d.ts +1 -1
- package/dist/components/plugins/viz-components/regression-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/regression-chart/viz-regression-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/rich-text/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/rich-text/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/rich-text/viz-rich-text-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/rich-text/viz-rich-text.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/reference-areas/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/reference-lines/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/reference-lines/reference-line.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/label-overflow.d.ts +2 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/series-color-select/dynamic-color-function-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/series-color-select/dynamic.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/series-color-select/get-series-color.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/series-color-select/index.d.ts +2 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/scatter/series-color-select/static.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/stats/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/tooltip/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/tooltip/metric.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/tooltip/metrics.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/x-axis/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/y-axes/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/editors/y-axes/y-axis.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/option/dataset.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/get-echarts-symbol-size.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/option/grid.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/series.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/x-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/option/y-axis.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/scatter-chart/triggers/click-scatter-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/type.d.ts +3 -4
- package/dist/components/plugins/viz-components/scatter-chart/viz-scatter-chart-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/scatter-chart/viz-scatter-chart.d.ts +1 -2
- package/dist/components/plugins/viz-components/stats/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/stats/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/stats/triggers/click-stats.d.ts +1 -2
- package/dist/components/plugins/viz-components/stats/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/stats/update/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/stats/viz-stats-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/stats/viz-stats.d.ts +2 -3
- package/dist/components/plugins/viz-components/sunburst/editors/data-field.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/editors/levels/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/editors/levels/level.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/option/array-to-tree.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/option/data.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/option/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/option/levels.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/option/tooltip.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/option/types.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/sunburst/type.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/viz-sunburst-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/sunburst/viz-sunburst.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/components/background-color-select.d.ts +3 -3
- package/dist/components/plugins/viz-components/table/components/head-cell.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/editors/columns/column.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/editors/columns/func_content-editor.d.ts +1 -1
- package/dist/components/plugins/viz-components/table/editors/columns/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/editors/pagination.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/editors/styling.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/migrators/handlers.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/migrators/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/render/cell-value.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/render/index.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/render/pagination-and-row-count.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/render/table-body.d.ts +2 -2
- package/dist/components/plugins/viz-components/table/render/use-get-cell-context.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/render/viz-table-component.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/table-cell-context.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/triggers/click-cell-content.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/utils.d.ts +0 -1
- package/dist/components/plugins/viz-components/table/value-type-selector.d.ts +2 -2
- package/dist/components/plugins/viz-components/table/viz-table-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/table/viz-table.styles.d.ts +1 -2
- package/dist/components/plugins/viz-components/text/editors/func-content/func-content-editor.d.ts +1 -1
- package/dist/components/plugins/viz-components/text/editors/func-content/index.d.ts +1 -1
- package/dist/components/plugins/viz-components/text/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/text/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/text/type.d.ts +0 -1
- package/dist/components/plugins/viz-components/text/viz-text-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/text/viz-text.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/editor/dashboard-state-variable-selector.d.ts +1 -1
- package/dist/components/plugins/viz-components/viz-dashboard-state/editor/fields.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/editor/viz-viz-dashboard-state-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/checkbox-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/context-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/date-range-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/item-badge.d.ts +2 -3
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/multi-select-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/selection-table.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/single-select-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/state-item.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/text-input-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/tree-select-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/item/tree-single-select-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/state-items.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/render/viz-viz-dashboard-state.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-dashboard-state/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/viz-instance-api.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-merico-gqm/error-figure.d.ts +1 -1
- package/dist/components/plugins/viz-components/viz-merico-gqm/index.d.ts +0 -1
- package/dist/components/plugins/viz-components/viz-merico-gqm/request/call-expert-system.d.ts +0 -1
- package/dist/components/plugins/viz-components/viz-merico-gqm/translation.d.ts +0 -1
- package/dist/components/plugins/viz-components/viz-merico-gqm/viz-merico-gqm-editor.d.ts +1 -2
- package/dist/components/plugins/viz-components/viz-merico-gqm/viz-merico-gqm.d.ts +1 -2
- package/dist/components/plugins/viz-manager/components.d.ts +2 -3
- package/dist/components/plugins/viz-manager/impl.d.ts +0 -1
- package/dist/components/plugins/viz-manager/types.d.ts +0 -1
- package/dist/components/view/layout/edit-layout.d.ts +1 -2
- package/dist/components/view/layout/render-layout.d.ts +1 -2
- package/dist/components/view/view-component/preview/division.d.ts +2 -3
- package/dist/components/view/view-component/preview/index.d.ts +2 -3
- package/dist/components/view/view-component/preview/modal.d.ts +2 -3
- package/dist/components/view/view-component/preview/tabs.d.ts +1 -2
- package/dist/components/view/view-component/render/division.d.ts +3 -4
- package/dist/components/view/view-component/render/index.d.ts +2 -3
- package/dist/components/view/view-component/render/modal.d.ts +3 -4
- package/dist/components/view/view-component/render/tabs.d.ts +1 -2
- package/dist/components/view/view-component/utils/use-download-div-screenshot.d.ts +2 -2
- package/dist/components/view/view-editor.d.ts +2 -2
- package/dist/components/view/view-render.d.ts +2 -2
- package/dist/components/widgets/about-function-utils/index.d.ts +1 -1
- package/dist/components/widgets/color-picker-popover/color-input.d.ts +2 -2
- package/dist/components/widgets/color-picker-popover/color-picker-popover-for-viz.d.ts +1 -1
- package/dist/components/widgets/color-picker-popover/color-picker-popover.d.ts +2 -3
- package/dist/components/widgets/custom-selector-item/index.d.ts +0 -1
- package/dist/components/widgets/function-editor/function-editor.d.ts +1 -2
- package/dist/components/widgets/inline-function-input/index.d.ts +2 -2
- package/dist/components/widgets/minimal-monaco-editor.d.ts +1 -1
- package/dist/components/widgets/modal-function-editor/index.d.ts +2 -3
- package/dist/components/widgets/rich-text-editor/color-mapping-mark/color-mapping-control.d.ts +1 -2
- package/dist/components/widgets/rich-text-editor/color-mapping-mark/color-mapping-form.d.ts +1 -1
- package/dist/components/widgets/rich-text-editor/color-mapping-mark/color-mapping-mark.d.ts +0 -1
- package/dist/components/widgets/rich-text-editor/color-mapping-mark/utils.d.ts +1 -1
- package/dist/components/widgets/rich-text-editor/color-picker-control/color-picker-control.d.ts +1 -2
- package/dist/components/widgets/rich-text-editor/custom-rich-text-editor.d.ts +2 -2
- package/dist/components/widgets/rich-text-editor/dynamic-color-mark/dynamic-color-control.d.ts +1 -2
- package/dist/components/widgets/rich-text-editor/dynamic-color-mark/dynamic-color-mark.d.ts +0 -1
- package/dist/components/widgets/rich-text-editor/dynamic-color-mark/utils.d.ts +0 -1
- package/dist/components/widgets/rich-text-editor/font-size-extension.d.ts +4 -2
- package/dist/components/widgets/rich-text-editor/readonly-rich-text-editor.d.ts +2 -2
- package/dist/components/widgets/rich-text-editor/rich-text-editor-modal.d.ts +1 -1
- package/dist/contexts/additional-panel-menu-items.d.ts +1 -2
- package/dist/contexts/customize-screenshot-context.d.ts +1 -2
- package/dist/contexts/dashboard-action-context.d.ts +1 -2
- package/dist/contexts/dashboard-theme-context.d.ts +1 -2
- package/dist/contexts/dates-provider.d.ts +2 -3
- package/dist/contexts/full-screen-panel-context.d.ts +1 -2
- package/dist/contexts/layout-state-context.d.ts +1 -2
- package/dist/contexts/panel-context.d.ts +11077 -11074
- package/dist/contexts/render-content-model-context.d.ts +0 -1
- package/dist/dashboard-editor/dashboard-editor.d.ts +2 -3
- package/dist/dashboard-editor/model/datasources/datasource.d.ts +62 -63
- package/dist/dashboard-editor/model/datasources/db-info/columns.d.ts +5 -5
- package/dist/dashboard-editor/model/datasources/db-info/db-info.d.ts +27 -28
- package/dist/dashboard-editor/model/datasources/db-info/indexes.d.ts +5 -5
- package/dist/dashboard-editor/model/datasources/db-info/table-data.d.ts +8 -9
- package/dist/dashboard-editor/model/datasources/db-info/tables.d.ts +5 -5
- package/dist/dashboard-editor/model/datasources/index.d.ts +256 -257
- package/dist/dashboard-editor/model/datasources/mm-info/metric-detail.d.ts +16 -17
- package/dist/dashboard-editor/model/datasources/mm-info/metric-detail.utils.d.ts +0 -1
- package/dist/dashboard-editor/model/datasources/mm-info/metrics.d.ts +8 -6
- package/dist/dashboard-editor/model/datasources/mm-info/mm-info.d.ts +28 -29
- package/dist/dashboard-editor/model/editor/index.d.ts +4 -5
- package/dist/dashboard-editor/model/filters/filter-model.d.ts +69 -70
- package/dist/dashboard-editor/model/filters/index.d.ts +648 -649
- package/dist/dashboard-editor/model/layouts/layouts.d.ts +222 -223
- package/dist/dashboard-editor/model/panels/panel.d.ts +2534 -2533
- package/dist/dashboard-editor/model/queries/queries.d.ts +4476 -4294
- package/dist/dashboard-editor/model/queries/query.d.ts +177 -171
- package/dist/dashboard-editor/model/sql-snippets/index.d.ts +21 -22
- package/dist/dashboard-editor/model/views/index.d.ts +2684 -2684
- package/dist/dashboard-editor/model/views/view.d.ts +112 -113
- package/dist/dashboard-editor/ui/header/add-a-panel/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/breakpoint-switcher/edit-breakpoints.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/breakpoint-switcher/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/download-this-view/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/import-with-schema/explain-json-schema.d.ts +1 -2
- package/dist/dashboard-editor/ui/header/import-with-schema/form.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/import-with-schema/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/header/main-header.d.ts +2 -3
- package/dist/dashboard-editor/ui/header/save-changes-or-more.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/spotlight/editor-spotlight.d.ts +1 -2
- package/dist/dashboard-editor/ui/header/spotlight/spotlight-action-component.d.ts +2 -3
- package/dist/dashboard-editor/ui/header/spotlight/spotlight-actions.d.ts +2 -3
- package/dist/dashboard-editor/ui/header/spotlight/spotlight-control.d.ts +1 -1
- package/dist/dashboard-editor/ui/header/sub-header.d.ts +1 -1
- package/dist/dashboard-editor/ui/navbar/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/navbar/view-links.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/data-preview/data-table-with-pagination.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/data-preview/data-table.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/data-preview/data-table.style.d.ts +0 -1
- package/dist/dashboard-editor/ui/settings/content/data-preview/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/data-preview/pagination-control.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/data-preview/query-state-message.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/full-space-loading.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/structure/columns-table.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/structure/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/structure/indexes-table.d.ts +4 -5
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/structure/loading-skeleton.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/structure/tooltip-value.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/table-data/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/table-data/pagination-control.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/db-explorer/table-nav-links.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/db-explorer-modal/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-filter/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-filters/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-mock-context/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/change-view-of-panel.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-panel/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-config/description.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-config/edit-style.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-config/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-config/name.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-config/title.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-editor.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-panel/panel-variables-guide.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-panel/pick-query/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/preview-panel.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-panel/select-viz-type.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-panel/variable-config/model.d.ts +938 -939
- package/dist/dashboard-editor/ui/settings/content/edit-panel/variable-config/variable-editor.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-panel/variable-config/variable-field.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-panel/variable-config/variables-editor.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-panel/viz-conf.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-queries/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/merico-icons/copy.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/merico-icons/delete.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/merico-icons/external-link.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/merico-icons/more.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/merico-icons/play.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/more-actions.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/data-table-with-pagination.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/data-table.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/data-table.style.d.ts +0 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/pagination-control.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/preview-data.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-data/query-state-message.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/preview-query-and-vars/preview-query-and-vars.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/derived-calculations.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/boolean.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/date.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/dimension-icon.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/dimension.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/number.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-icon/string.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/dimension-selector/dimension-selector.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/edit-metric-query.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/link-metrics-to-time-and-step.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/link-metrics-to-variables.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/link-sql-metrics-to-variables.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/run-by-checkbox.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/set-groupby-metrics.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/sql-var-selector/index.d.ts +3 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/time-query-switch.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/variable-selector.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/edit-metric-query/variable-stats.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/query-tabs/query-tabs.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/run-query.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/merico-metric-query-editor-form/select-metric.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/configurations.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/delete-query.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/query-usage.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/select-data-source.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/http/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/sql/edit-sql.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/sql/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/sql/preview-sql-in-monaco-editor.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/sql/preview-sql.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/sql/query-dependency.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-query/query-editor-form/tabs/transform/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-sql-snippet/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-sql-snippet/item-editor.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-sql-snippet/preview-snippet.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-sql-snippets/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/config.division.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/config.tabs.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/modal/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/modal/modal-title-editor/function-editor.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/config-fields/modal/modal-title-editor/index.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/edit-view/edit-view-form/index.d.ts +372 -373
- package/dist/dashboard-editor/ui/settings/content/edit-view/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/utils.d.ts +1 -2
- package/dist/dashboard-editor/ui/settings/content/view-query-vars/global-sql-snippets-table.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/view-query-vars/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/content/view-query-vars/query-variables-guide.d.ts +2 -2
- package/dist/dashboard-editor/ui/settings/content/view-query-vars/query-variables-modal.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/add-a-filter.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/add-a-panel.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/add-a-query.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/add-a-sql-snippet.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/add-a-view.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/filters-settings-button.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/index.d.ts +2 -3
- package/dist/dashboard-editor/ui/settings/navbar/action-button/queries-settings-button.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/action-button/sql-snippets-settings-button.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/index.d.ts +1 -1
- package/dist/dashboard-editor/ui/settings/navbar/nav-links.d.ts +1 -1
- package/dist/dashboard-render/dashboard-render.d.ts +1 -2
- package/dist/dashboard-render/model/types.d.ts +0 -1
- package/dist/dashboard.es.js +1641 -1620
- package/dist/dashboard.umd.js +36 -36
- package/dist/i18n/i18n.d.ts +1 -2
- package/dist/i18n/i18next-context.d.ts +2 -3
- package/dist/index.d.ts +1 -2
- package/dist/interactions/attachment-instance-manager.d.ts +0 -1
- package/dist/interactions/components/interaction-settings.d.ts +2 -3
- package/dist/interactions/components/operation-select.d.ts +1 -2
- package/dist/interactions/components/trigger-config-model.d.ts +0 -1
- package/dist/interactions/components/trigger-select.d.ts +2 -3
- package/dist/interactions/components/variable-list.d.ts +1 -2
- package/dist/interactions/hooks/use-current-interaction-manager.d.ts +0 -1
- package/dist/interactions/hooks/use-watch-triggers.d.ts +0 -1
- package/dist/interactions/interaction-manager.d.ts +0 -1
- package/dist/interactions/interactions-viewer/data/edges.d.ts +1 -2
- package/dist/interactions/interactions-viewer/data/index.d.ts +2 -3
- package/dist/interactions/interactions-viewer/data/nodes.d.ts +0 -1
- package/dist/interactions/interactions-viewer/data/position.d.ts +0 -1
- package/dist/interactions/interactions-viewer/data/types.d.ts +1 -2
- package/dist/interactions/interactions-viewer/index.d.ts +1 -1
- package/dist/interactions/interactions-viewer/node-with-interactions/index.d.ts +3 -3
- package/dist/interactions/interactions-viewer/node-with-interactions/lines.d.ts +1 -2
- package/dist/interactions/interactions-viewer/node-with-interactions/types.d.ts +1 -2
- package/dist/interactions/interactions-viewer/viewer.d.ts +1 -2
- package/dist/interactions/null-interaction-manager.d.ts +0 -1
- package/dist/interactions/operation/operation-manager-impl.d.ts +0 -1
- package/dist/interactions/operation/operations/clear-filter-values.d.ts +0 -1
- package/dist/interactions/operation/operations/console-log.d.ts +0 -1
- package/dist/interactions/operation/operations/index.d.ts +0 -1
- package/dist/interactions/operation/operations/open-link.d.ts +0 -1
- package/dist/interactions/operation/operations/open-view.d.ts +0 -1
- package/dist/interactions/operation/operations/scroll-to-panel.d.ts +0 -1
- package/dist/interactions/operation/operations/set-filter-values.d.ts +0 -1
- package/dist/interactions/operation/operations/switch-tab.d.ts +0 -1
- package/dist/interactions/temp-hack.d.ts +0 -1
- package/dist/interactions/test/helpers.d.ts +0 -1
- package/dist/interactions/trigger/trigger-manager-impl.d.ts +0 -1
- package/dist/model/meta-model/context/context.d.ts +8 -8
- package/dist/model/meta-model/dashboard/content/filter/filter.d.ts +77 -78
- package/dist/model/meta-model/dashboard/content/filter/types.d.ts +1 -1
- package/dist/model/meta-model/dashboard/content/filter/widgets/checkbox.d.ts +11 -12
- package/dist/model/meta-model/dashboard/content/filter/widgets/date-range.d.ts +23 -24
- package/dist/model/meta-model/dashboard/content/filter/widgets/merico-date-range.d.ts +19 -20
- package/dist/model/meta-model/dashboard/content/filter/widgets/multi-select.d.ts +70 -71
- package/dist/model/meta-model/dashboard/content/filter/widgets/select-base.d.ts +14 -15
- package/dist/model/meta-model/dashboard/content/filter/widgets/select.d.ts +65 -66
- package/dist/model/meta-model/dashboard/content/filter/widgets/text-input.d.ts +11 -12
- package/dist/model/meta-model/dashboard/content/filter/widgets/tree-select-base.d.ts +16 -17
- package/dist/model/meta-model/dashboard/content/filter/widgets/tree-select.d.ts +77 -78
- package/dist/model/meta-model/dashboard/content/filter/widgets/tree-single-select.d.ts +76 -77
- package/dist/model/meta-model/dashboard/content/initial-content.d.ts +0 -1
- package/dist/model/meta-model/dashboard/content/layout/layout-item.d.ts +11 -12
- package/dist/model/meta-model/dashboard/content/layout/layout-set.d.ts +37 -38
- package/dist/model/meta-model/dashboard/content/mock-context/mock-context.d.ts +4 -5
- package/dist/model/meta-model/dashboard/content/panel/panel.d.ts +857 -858
- package/dist/model/meta-model/dashboard/content/panel/style/border.d.ts +3 -3
- package/dist/model/meta-model/dashboard/content/panel/style/index.d.ts +6 -7
- package/dist/model/meta-model/dashboard/content/panel/title.d.ts +3 -3
- package/dist/model/meta-model/dashboard/content/panel/variable.d.ts +470 -471
- package/dist/model/meta-model/dashboard/content/panel/viz.d.ts +5 -6
- package/dist/model/meta-model/dashboard/content/query/db-query.d.ts +12 -13
- package/dist/model/meta-model/dashboard/content/query/http-query.d.ts +14 -15
- package/dist/model/meta-model/dashboard/content/query/merico-metric-query.d.ts +146 -129
- package/dist/model/meta-model/dashboard/content/query/query.d.ts +168 -163
- package/dist/model/meta-model/dashboard/content/query/transform-query.d.ts +20 -21
- package/dist/model/meta-model/dashboard/content/sql-snippet/sql-snippet.d.ts +4 -5
- package/dist/model/meta-model/dashboard/content/types.d.ts +0 -1
- package/dist/model/meta-model/dashboard/content/view/view.d.ts +93 -94
- package/dist/model/meta-model/dashboard/content/view/widgets/division.d.ts +7 -8
- package/dist/model/meta-model/dashboard/content/view/widgets/modal.d.ts +25 -26
- package/dist/model/meta-model/dashboard/content/view/widgets/tabs.d.ts +72 -73
- package/dist/model/meta-model/datasources/datasource.d.ts +7 -8
- package/dist/model/meta-model/datasources/datasources.d.ts +16 -17
- package/dist/model/meta-model/global-sql-snippets/global-sql-snippet.d.ts +7 -7
- package/dist/model/meta-model/global-sql-snippets/global-sql-snippets.d.ts +16 -17
- package/dist/model/render-model/dashboard/content/filters/filters.d.ts +503 -504
- package/dist/model/render-model/dashboard/content/filters/utils.d.ts +1 -2
- package/dist/model/render-model/dashboard/content/layouts/layouts.d.ts +227 -228
- package/dist/model/render-model/dashboard/content/panels/panel.d.ts +2532 -2531
- package/dist/model/render-model/dashboard/content/panels/types.d.ts +4 -5
- package/dist/model/render-model/dashboard/content/queries/mute-query.d.ts +163 -157
- package/dist/model/render-model/dashboard/content/queries/queries.d.ts +3597 -3461
- package/dist/model/render-model/dashboard/content/queries/query.d.ts +183 -177
- package/dist/model/render-model/dashboard/content/sql-snippets/sql-snippet.d.ts +5 -6
- package/dist/model/render-model/dashboard/content/sql-snippets/sql-snippets.d.ts +18 -19
- package/dist/model/render-model/dashboard/content/sql-snippets/types.d.ts +0 -1
- package/dist/model/render-model/dashboard/content/sql-snippets/utils.d.ts +1 -2
- package/dist/model/render-model/dashboard/content/views/view.d.ts +114 -115
- package/dist/model/render-model/dashboard/content/views/views.d.ts +2119 -2120
- package/dist/model/utils/draft.d.ts +0 -1
- package/dist/shared/api-client/default-api-client.d.ts +0 -1
- package/dist/shared/api-client/facade-api-client.d.ts +0 -1
- package/dist/shared/api-client/types.d.ts +0 -1
- package/dist/shared/api-client/utils.d.ts +0 -1
- package/dist/stats.html +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/common-html-content-style.d.ts +0 -1
- package/dist/styles/default-echarts-options/index.d.ts +3 -3
- package/dist/styles/default-echarts-options/tooltip.d.ts +0 -1
- package/dist/styles/default-echarts-options/x-axis.d.ts +0 -1
- package/dist/styles/default-echarts-options/y-axis.d.ts +0 -1
- package/dist/styles/viz-box.d.ts +2 -3
- package/dist/types/dashboard.d.ts +2 -3
- package/dist/types/plugin/index.d.ts +2 -3
- package/dist/utils/color-feed.d.ts +0 -1
- package/dist/utils/dashboard-state.d.ts +0 -1
- package/dist/utils/data.d.ts +0 -1
- package/dist/utils/diff-json.d.ts +0 -1
- package/dist/utils/error-boundary.d.ts +3 -4
- package/dist/utils/function-utils.d.ts +5 -6
- package/dist/utils/http-query.d.ts +0 -1
- package/dist/utils/mantine.d.ts +0 -1
- package/dist/utils/rich-text/parse-rich-text-content.d.ts +1 -2
- package/dist/utils/sql.d.ts +0 -1
- package/dist/utils/template/editor/template-input.d.ts +2 -3
- package/dist/utils/template/editor/utils.d.ts +0 -1
- package/dist/utils/template/render/render-jsx.d.ts +0 -1
- package/dist/utils/template/render/render-string.d.ts +2 -2
- package/dist/utils/template/types.d.ts +1 -2
- package/dist/utils/template/utils.d.ts +0 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
- package/dist/components/plugins/panel-addon/panel-addon-context.d.ts +0 -6
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports,require("i18next"),require("react-i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("lodash"),require("mobx"),require("eventemitter2"),require("react/jsx-runtime"),require("react"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("echarts/core"),require("ahooks"),require("@mantine/dates"),require("@mantine/core"),require("@mantine/hooks"),require("popmotion"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("crypto-js"),require("dayjs"),require("numbro"),require("@tabler/icons-react"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("react-hook-form"),require("mobx-react-lite"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("@dnd-kit/react/sortable"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("axios"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("mobx-state-tree"),require("dom-to-image-more"),require("file-saver"),require("jszip"),require("@json2csv/whatwg"),require("js-base64"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-dom"),require("react-grid-layout"),require("@mantine/modals"),require("react-router-dom"),require("@mantine/spotlight"),require("@mantine/spotlight/styles.css"),require("reactflow"),require("reactflow/dist/style.css")):typeof define=="function"&&define.amd?define(["exports","i18next","react-i18next","i18next-browser-languagedetector","intl-pluralrules","lodash","mobx","eventemitter2","react/jsx-runtime","react","chroma-js","echarts-for-react/lib/core","echarts-gl","echarts/core","ahooks","@mantine/dates","@mantine/core","@mantine/hooks","popmotion","d3-array","mathjs","@faker-js/faker","crypto-js","dayjs","numbro","@tabler/icons-react","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@monaco-editor/react","@tiptap/core","d3-scale","react-hook-form","mobx-react-lite","@dnd-kit/helpers","@dnd-kit/react","@dnd-kit/react/sortable","uuid","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","axios","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","mobx-state-tree","dom-to-image-more","file-saver","jszip","@json2csv/whatwg","js-base64","rc-tree-select","performant-array-to-tree","rc-select","react-dom","react-grid-layout","@mantine/modals","react-router-dom","@mantine/spotlight","@mantine/spotlight/styles.css","reactflow","reactflow/dist/style.css"],Ce):(C=typeof globalThis<"u"?globalThis:C||self,Ce(C.dashboard={},C.i18next,C["react-i18next"],C["i18next-browser-languagedetector"],C["intl-pluralrules"],C._,C.mobx,C.eventemitter2,C["react/jsx-runtime"],C.react,C["chroma-js"],C["echarts-for-react/lib/core"],C["echarts-gl"],C["echarts/core"],C.ahooks,C["@mantine/dates"],C["@mantine/core"],C["@mantine/hooks"],C.popmotion,C["d3-array"],C.mathjs,C["@faker-js/faker"],C.CryptoJS,C.dayjs,C.numbro,C["@tabler/icons-react"],C["@mantine/tiptap"],C["@tiptap/extension-color"],C["@tiptap/extension-highlight"],C["@tiptap/extension-placeholder"],C["@tiptap/extension-subscript"],C["@tiptap/extension-superscript"],C["@tiptap/extension-table"],C["@tiptap/extension-table-cell"],C["@tiptap/extension-table-header"],C["@tiptap/extension-table-row"],C["@tiptap/extension-text-align"],C["@tiptap/extension-text-style"],C["@tiptap/extension-underline"],C["@tiptap/react"],C["@tiptap/starter-kit"],C["@monaco-editor/react"],C["@tiptap/core"],C["d3-scale"],C["react-hook-form"],C["mobx-react-lite"],C["@dnd-kit/helpers"],C["@dnd-kit/react"],C["@dnd-kit/react/sortable"],C.uuid,C["echarts/charts"],C["echarts/components"],C["echarts/renderers"],C["constrained-editor-plugin"],C["@mantine/notifications"],C["@mantine/emotion"],C["d3-regression"],C["@mantine/code-highlight"],C["@tanstack/react-table"],C["@tanstack/react-virtual"],C.axios,C["dayjs/plugin/advancedFormat"],C["dayjs/plugin/arraySupport"],C["dayjs/plugin/buddhistEra"],C["dayjs/plugin/calendar"],C["dayjs/plugin/customParseFormat"],C["dayjs/plugin/dayOfYear"],C["dayjs/plugin/duration"],C["dayjs/plugin/isBetween"],C["dayjs/plugin/isLeapYear"],C["dayjs/plugin/isMoment"],C["dayjs/plugin/isoWeek"],C["dayjs/plugin/isoWeeksInYear"],C["dayjs/plugin/isSameOrAfter"],C["dayjs/plugin/isSameOrBefore"],C["dayjs/plugin/isToday"],C["dayjs/plugin/isTomorrow"],C["dayjs/plugin/isYesterday"],C["dayjs/plugin/localeData"],C["dayjs/plugin/localizedFormat"],C["dayjs/plugin/minMax"],C["dayjs/plugin/objectSupport"],C["dayjs/plugin/pluralGetSet"],C["dayjs/plugin/preParsePostFormat"],C["dayjs/plugin/quarterOfYear"],C["dayjs/plugin/relativeTime"],C["dayjs/plugin/timezone"],C["dayjs/plugin/toArray"],C["dayjs/plugin/toObject"],C["dayjs/plugin/updateLocale"],C["dayjs/plugin/utc"],C["dayjs/plugin/weekday"],C["dayjs/plugin/weekOfYear"],C["dayjs/plugin/weekYear"],C["mobx-state-tree"],C["dom-to-image-more"],C["file-saver"],C.jszip,C["@json2csv/whatwg"],C["js-base64"],C["rc-tree-select"],C["performant-array-to-tree"],C["rc-select"],C["react-dom"],C["react-grid-layout"],C["@mantine/modals"],C["react-router-dom"],C["@mantine/spotlight"],C["@mantine/spotlight/styles"].css,C.reactflow))})(this,function(C,Ce,m,Wd,LM,y,G,ys,n,h,Ge,he,NM,vs,O,wt,s,te,dt,jt,Ud,Kd,_s,M,Ee,T,Q,ms,ws,xs,Cs,Ss,Ts,ks,Ds,zs,Ms,Is,Vs,Ps,$s,Se,Wn,Yd,v,k,Un,rn,an,Te,Ze,ut,Xd,Zd,Fe,pt,Jd,Qe,ge,Hd,ke,Rd,eu,tu,nu,ru,au,su,ou,lu,iu,cu,du,uu,pu,hu,gu,fu,bu,yu,vu,_u,mu,wu,xu,Cu,Su,Tu,ku,Du,zu,Mu,Iu,Vu,f,As,sn,Es,Pu,Bs,Kn,$u,qs,Au,on,De,Eu,xt,GM,ie){"use strict";var qM=Object.defineProperty;var OM=(C,Ce,m)=>Ce in C?qM(C,Ce,{enumerable:!0,configurable:!0,writable:!0,value:m}):C[Ce]=m;var V=(C,Ce,m)=>(OM(C,typeof Ce!="symbol"?Ce+"":Ce,m),m);function Ct(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=Ct(vs),Bu=Ct(dt),Os=Ct(jt),je=Ct(Ud),qu=Ct(_s),Ou=Ct(Yd),ht=Ct(Jd),Lu={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",delete:"Delete this filter",show_filters:"Show Filters",hide_filters:"Hide Filters",usage:{label:"Usage",unused_description:"This filter is not used by any query, SQL snippet or view"},field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom default value",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",tree_single_select:"Tree Single Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range",merico_date_range:"Merico Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected",default_value_mode:{label:"When options change",intersect:"Preserve valid entries from current selection",reset:"Use new options"}},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default",preset_options:{apply:"Apply preset options",date_unit:"Date units"}},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},tree_single_select:{select_first_option_by_default:"Select the first option by default"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",step:{label:"Step",day:"Day",week:"Week",bi_week:"Bi-Week",month:"Month",quarter:"Quarter",year:"Year"},shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",m6:"6 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",m6:"last 6 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",layout:{drag_to_move:"Drag to move"},component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},switch_tab:{label:"Switch Tab",view:"View",tab:"Tab"},scroll_to_panel:{label:"Scroll to Panel",panel:"Panel"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{label:"Pagination",page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)",to_previous_page:"To previous page",to_next_page:"To next page",showing_rows:"Showing {{start_row}} - {{end_row}} of {{total}} rows"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",top:"top",center:"center",bottom:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",invalid:"Invalid",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{search:"Search",reload:"Reload",actions:"Actions",open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear:"Clear",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <0>{{name}}</0>",edit_rich_text:"Edit rich text content"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"},guide:{text:`-- You may reference dashboard state & panel variables in rich-text content or custom functions.
|
|
1
|
+
(function(C,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports,require("i18next"),require("react-i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("lodash"),require("mobx"),require("eventemitter2"),require("react/jsx-runtime"),require("react"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("echarts/core"),require("ahooks"),require("@mantine/dates"),require("@mantine/core"),require("@mantine/hooks"),require("popmotion"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("crypto-js"),require("dayjs"),require("numbro"),require("@tabler/icons-react"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("react-hook-form"),require("mobx-react-lite"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("@dnd-kit/react/sortable"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("axios"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("mobx-state-tree"),require("dom-to-image-more"),require("file-saver"),require("jszip"),require("@json2csv/whatwg"),require("js-base64"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-dom"),require("react-grid-layout"),require("@mantine/modals"),require("react-router-dom"),require("@mantine/spotlight"),require("@mantine/spotlight/styles.css"),require("reactflow"),require("reactflow/dist/style.css")):typeof define=="function"&&define.amd?define(["exports","i18next","react-i18next","i18next-browser-languagedetector","intl-pluralrules","lodash","mobx","eventemitter2","react/jsx-runtime","react","chroma-js","echarts-for-react/lib/core","echarts-gl","echarts/core","ahooks","@mantine/dates","@mantine/core","@mantine/hooks","popmotion","d3-array","mathjs","@faker-js/faker","crypto-js","dayjs","numbro","@tabler/icons-react","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@monaco-editor/react","@tiptap/core","d3-scale","react-hook-form","mobx-react-lite","@dnd-kit/helpers","@dnd-kit/react","@dnd-kit/react/sortable","uuid","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","axios","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","mobx-state-tree","dom-to-image-more","file-saver","jszip","@json2csv/whatwg","js-base64","rc-tree-select","performant-array-to-tree","rc-select","react-dom","react-grid-layout","@mantine/modals","react-router-dom","@mantine/spotlight","@mantine/spotlight/styles.css","reactflow","reactflow/dist/style.css"],Ce):(C=typeof globalThis<"u"?globalThis:C||self,Ce(C.dashboard={},C.i18next,C["react-i18next"],C["i18next-browser-languagedetector"],C["intl-pluralrules"],C._,C.mobx,C.eventemitter2,C["react/jsx-runtime"],C.react,C["chroma-js"],C["echarts-for-react/lib/core"],C["echarts-gl"],C["echarts/core"],C.ahooks,C["@mantine/dates"],C["@mantine/core"],C["@mantine/hooks"],C.popmotion,C["d3-array"],C.mathjs,C["@faker-js/faker"],C.CryptoJS,C.dayjs,C.numbro,C["@tabler/icons-react"],C["@mantine/tiptap"],C["@tiptap/extension-color"],C["@tiptap/extension-highlight"],C["@tiptap/extension-placeholder"],C["@tiptap/extension-subscript"],C["@tiptap/extension-superscript"],C["@tiptap/extension-table"],C["@tiptap/extension-table-cell"],C["@tiptap/extension-table-header"],C["@tiptap/extension-table-row"],C["@tiptap/extension-text-align"],C["@tiptap/extension-text-style"],C["@tiptap/extension-underline"],C["@tiptap/react"],C["@tiptap/starter-kit"],C["@monaco-editor/react"],C["@tiptap/core"],C["d3-scale"],C["react-hook-form"],C["mobx-react-lite"],C["@dnd-kit/helpers"],C["@dnd-kit/react"],C["@dnd-kit/react/sortable"],C.uuid,C["echarts/charts"],C["echarts/components"],C["echarts/renderers"],C["constrained-editor-plugin"],C["@mantine/notifications"],C["@mantine/emotion"],C["d3-regression"],C["@mantine/code-highlight"],C["@tanstack/react-table"],C["@tanstack/react-virtual"],C.axios,C["dayjs/plugin/advancedFormat"],C["dayjs/plugin/arraySupport"],C["dayjs/plugin/buddhistEra"],C["dayjs/plugin/calendar"],C["dayjs/plugin/customParseFormat"],C["dayjs/plugin/dayOfYear"],C["dayjs/plugin/duration"],C["dayjs/plugin/isBetween"],C["dayjs/plugin/isLeapYear"],C["dayjs/plugin/isMoment"],C["dayjs/plugin/isoWeek"],C["dayjs/plugin/isoWeeksInYear"],C["dayjs/plugin/isSameOrAfter"],C["dayjs/plugin/isSameOrBefore"],C["dayjs/plugin/isToday"],C["dayjs/plugin/isTomorrow"],C["dayjs/plugin/isYesterday"],C["dayjs/plugin/localeData"],C["dayjs/plugin/localizedFormat"],C["dayjs/plugin/minMax"],C["dayjs/plugin/objectSupport"],C["dayjs/plugin/pluralGetSet"],C["dayjs/plugin/preParsePostFormat"],C["dayjs/plugin/quarterOfYear"],C["dayjs/plugin/relativeTime"],C["dayjs/plugin/timezone"],C["dayjs/plugin/toArray"],C["dayjs/plugin/toObject"],C["dayjs/plugin/updateLocale"],C["dayjs/plugin/utc"],C["dayjs/plugin/weekday"],C["dayjs/plugin/weekOfYear"],C["dayjs/plugin/weekYear"],C["mobx-state-tree"],C["dom-to-image-more"],C["file-saver"],C.jszip,C["@json2csv/whatwg"],C["js-base64"],C["rc-tree-select"],C["performant-array-to-tree"],C["rc-select"],C["react-dom"],C["react-grid-layout"],C["@mantine/modals"],C["react-router-dom"],C["@mantine/spotlight"],C["@mantine/spotlight/styles"].css,C.reactflow))})(this,function(C,Ce,m,Wd,NM,y,G,ys,n,h,Ge,he,GM,vs,O,wt,s,te,dt,jt,Ud,Kd,_s,M,Ee,T,Q,ms,ws,xs,Cs,Ss,Ts,ks,Ds,zs,Ms,Is,Vs,Ps,$s,Se,Un,Yd,v,k,Kn,rn,an,Te,Ze,ut,Xd,Zd,Fe,pt,Jd,Qe,ge,Hd,ke,Rd,eu,tu,nu,ru,au,su,ou,lu,iu,cu,du,uu,pu,hu,gu,fu,bu,yu,vu,_u,mu,wu,xu,Cu,Su,Tu,ku,Du,zu,Mu,Iu,Vu,f,As,sn,Es,Pu,Bs,Yn,$u,qs,Au,on,De,Eu,xt,FM,ie){"use strict";var OM=Object.defineProperty;var LM=(C,Ce,m)=>Ce in C?OM(C,Ce,{enumerable:!0,configurable:!0,writable:!0,value:m}):C[Ce]=m;var V=(C,Ce,m)=>(LM(C,typeof Ce!="symbol"?Ce+"":Ce,m),m);function Ct(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=Ct(vs),Bu=Ct(dt),Os=Ct(jt),je=Ct(Ud),qu=Ct(_s),Ou=Ct(Yd),ht=Ct(Jd),Lu={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",delete:"Delete this filter",show_filters:"Show Filters",hide_filters:"Hide Filters",usage:{label:"Usage",unused_description:"This filter is not used by any query, SQL snippet or view"},field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom default value",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",tree_single_select:"Tree Single Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range",merico_date_range:"Merico Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected",default_value_mode:{label:"When options change",intersect:"Preserve valid entries from current selection",reset:"Use new options"}},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default",preset_options:{apply:"Apply preset options",date_unit:"Date units"}},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},tree_single_select:{select_first_option_by_default:"Select the first option by default"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",step:{label:"Step",day:"Day",week:"Week",bi_week:"Bi-Week",month:"Month",quarter:"Quarter",year:"Year"},shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",m6:"6 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",m6:"last 6 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",layout:{drag_to_move:"Drag to move"},component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},switch_tab:{label:"Switch Tab",view:"View",tab:"Tab"},scroll_to_panel:{label:"Scroll to Panel",panel:"Panel"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{label:"Pagination",page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)",to_previous_page:"To previous page",to_next_page:"To next page",showing_rows:"Showing {{start_row}} - {{end_row}} of {{total}} rows"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",top:"top",center:"center",bottom:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",invalid:"Invalid",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{search:"Search",reload:"Reload",actions:"Actions",open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear:"Clear",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <0>{{name}}</0>",edit_rich_text:"Edit rich text content"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"},guide:{text:`-- You may reference dashboard state & panel variables in rich-text content or custom functions.
|
|
2
2
|
-- use double curly brackets to wrap code in rich-text content.
|
|
3
3
|
Project ID: {{ context.project_id }}
|
|
4
4
|
Keyword: {{ filters.keyword }}
|
|
@@ -6,7 +6,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
6
6
|
-- 在富文本中,要使用双重花括号来包裹代码。
|
|
7
7
|
项目ID:{{ context.project_id }}
|
|
8
8
|
搜索关键字:{{ filters.keyword }}
|
|
9
|
-
我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",unset:"留空则在看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询",data_field:{selector:{options:{unset:"未设置",default:"默认"}}}},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{label:"富文本",content:{label:"内容"},dynamic_color:{label:"动态颜色",edit:"编辑动态颜色",clear:"清除动态颜色"},color_mapping:{label:"颜色映射",edit:"编辑颜色映射",clear:"清除颜色映射",choose_value_var:"选择用于映射颜色的变量",min:{val:"固定最小值",var:"动态最小值(优先)"},max:{val:"固定最大值",var:"动态最大值(优先)"}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},unit:{title:"单位",text:{placeholder:"单位文案"},show_in_tooltip:"在提示框中显示单位",show_in_legend:"在图例中显示单位"},series_order:{label:"排序依据",name:"名称",value:"值",raw:"不排序,保持数据本身的顺序",asc:"升序",desc:"降序"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最小柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",inverse:"反向坐标轴",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见",mirror:{label:"上下镜像"}},stats:{label:"统计内容",template:{above_chart:"统计内容(图表上方)",under_chart:"统计内容(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"逻辑回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}};class ln{constructor(t){V(this,"rootRef");this.rootRef=G.observable({current:t})}async deleteItem(t){G.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?G.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))G.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else G.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,a){return G.reaction(()=>this.getValueFromRoot(t),(o,l)=>{r(o,l)},{requiresObservable:!0,fireImmediately:y.get(a,"fireImmediately",!1)})}}class Gu{constructor(){V(this,"channels",new Map);V(this,"globalChannel",new ys)}getChannel(t){const r=this.channels.get(t);if(r)return r;const a=new ys;return this.channels.set(t,a),a}}class Fu{constructor(t){V(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const a={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Gu,instanceData:new ln(t.viz.conf)};return this.instances.set(t.id,a),a}}function Ls(e,t,r,a){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ln({}),colorPalette:{getColor(){return()=>""}},data:t,variables:a}}const Qu=e=>{const{panel:t,measure:r,vizManager:a,data:o,variables:l}=e,i=a.resolveComponent(t.viz.type),c=a.getOrCreateInstance(t),d={...Ls(c,o,a,l),viewport:{width:r.w,height:r.h}},u=i.viewRender;return n.jsx(u,{context:d,instance:c,...y.omit(e,["panel","vizManager","data"])})},ju=e=>{const{vizManager:t,panel:r,data:a,variables:o}=e,l=t.resolveComponent(r.viz.type),i=t.getOrCreateInstance(r),c={...Ls(i,a,t,o)},d=l.configRender;return n.jsx(d,{context:c,instance:i,...y.omit(e,["panel","vizManager","data"])})},Ns=(e,t)=>{const r=Ge.bezier(e),a=Ge.bezier(t);return function(o){return o<50?r(o*2/100).hex():a((o-50)*2/100).hex()}},cn=e=>{const t=Ge.bezier(e);return function(r){return t(r/100).hex()}},Wu={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Ns(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Uu={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Ns(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Ku={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:cn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yu={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:cn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Xu={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:cn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Zu={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:cn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Ju{constructor(t){this.pluginManager=t}createPanelAddonNode(t){const a=this.pluginManager.installedPlugins.flatMap(o=>o.manifest.panelAddon).filter(o=>!!o).map(o=>h.createElement(o.addonRender,{...t,key:o.name}));return n.jsx(n.Fragment,{children:a})}}const Gs=h.createContext({addonSlotId:null});function Fs({children:e}){const t=`panel-addon-slot-${h.useId()}`;return n.jsxs(Gs.Provider,{value:{addonSlotId:t},children:[n.jsx("div",{style:{position:"static",top:0,left:0},id:t}),e]})}function Hu(){const{addonSlotId:e}=h.useContext(Gs);return e?document.getElementById(e):null}class Ru{constructor(t){V(this,"symbol");this.symbol=Symbol(t)}}function Je(e){return new Ru(e)}class Yn{constructor(){V(this,"parent");V(this,"factoryRegistry",new Map);V(this,"instanceRegistry",new Map)}createScoped(){const t=new Yn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const a=r(this);return this.instanceRegistry.set(t.symbol,a),a}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Qs="14.57.1",ep=Object.freeze(Object.defineProperty({__proto__:null,version:Qs},Symbol.toStringTag,{value:"Module"}));class tp{constructor(t){V(this,"staticColors",new Map);V(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(a=>{this.register(a)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class np{constructor(){V(this,"plugins",new Map);V(this,"vizComponents",new Map);V(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class rp{constructor(){V(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,a){var i;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const o=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),l=y.orderBy(o,"version","asc");if(((i=y.last(l))==null?void 0:i.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return l.reduce((c,d)=>d.handler(c,a),r)}}class J extends rp{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(a,o)=>({version:t,...r(a,o)}))}async migrate({configData:t,panelModel:r}){const a=await t.getItem(null),o=y.get(a,"version",0),l=this.run({from:o,to:this.VERSION},a,{panelModel:r});await t.setItem(null,l)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const q=(e,t)=>{const[r,{setFalse:a}]=O.useBoolean(!0),[o,l]=h.useState();h.useEffect(()=>(e.getItem(t).then(c=>{l(c),a()}),e.watchItem(t,c=>{l(c)})));const i=h.useCallback(async c=>{await e.setItem(t,c),l(c)},[e,t]);return{loading:r,value:o,set:i}},js=h.createContext(null),Xn=js.Provider;function Wt(){const e=h.useContext(js);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const j=()=>Wt(),Ws=()=>Wt(),Us=h.createContext({}),Zn=Us.Provider;function Ks(){return h.useContext(Us)}const Jn=h.createContext(null),Hn=Jn.Provider;function Rn(){const e=h.useContext(Jn);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const F=()=>Rn(),ap={inEditMode:!1},St=h.createContext(ap);function Ys(){const e=h.useContext(St);if(!e)throw new Error("Please use LayoutStateContext.Provider");return e}const Xs=h.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{},getEchartsOptions:()=>null,setEchartsOptions:()=>{}}),er=Xs.Provider;function tr(){const e=h.useContext(Xs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const re=()=>tr(),ae=()=>tr();function Zs(){try{return tr(),!0}catch{return!1}}const Js=()=>Zs(),Hs=()=>Zs(),sp={fullScreenPanelID:"",setFullScreenPanelID:y.noop},nr=h.createContext(sp);function Rs(){const e=h.useContext(nr);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const op={en:"en",zh:"zh-cn"};function rr({children:e}){const{i18n:t}=m.useTranslation(),r=h.useMemo(()=>{const a=t.language;return op[a]??"en"},[t.language]);return n.jsx(wt.DatesProvider,{settings:{locale:r,firstDayOfWeek:1},children:e})}const H=()=>Rn(),lp={items:[]},ar=h.createContext(lp),sr=ar.Provider;function or(){return h.useContext(ar)}h.forwardRef(function({value:t,onChange:r,...a},o){return n.jsx(s.TextInput,{ref:o,value:t,onChange:r,...a})});class ip{constructor({valueRange:t,colorRange:r}){V(this,"mapper");this.mapper=dt.interpolate(t,r)}getColor(t){return this.mapper(t)}}function cp(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{const r=Number(t);if(Number.isNaN(r))throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}, parsed: ${r}`);return new ip(e).getColor(r)}catch(r){return console.error(r),"black"}return"black"}const dp=cp;function $(e){const[t,r]=e.split(".");return{queryID:t,columnKey:r}}function eo(e){return!!e&&!!e.columnKey&&!!e.queryID}function up(e){return e.includes(".")?$(e):{queryID:"",columnKey:e}}function me(e,t){var o;const{queryID:r,columnKey:a}=$(t);return r?a?((o=e[r])==null?void 0:o.map(l=>l[a]))??[]:e[r]:[]}function dn(e,t){const{queryID:r}=$(t);return r?e[r]:[]}function pp(e){return Object.values(e)[0]}function un(e,t){const{queryID:r,columnKey:a}=$(t);return e[a]}const We={CryptoJS:_s,d3Array:Os,dayjs:M,lodash:y,numbro:Ee,mathjs:je,faker:Kd.faker,popmotion:Bu},hp=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.4"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.12.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"},{name:"popmotion",url:"https://popmotion.io/",version:"11.0.3"}],gp=e=>`
|
|
9
|
+
我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",unset:"留空则在看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询",data_field:{selector:{options:{unset:"未设置",default:"默认"}}}},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{label:"富文本",content:{label:"内容"},dynamic_color:{label:"动态颜色",edit:"编辑动态颜色",clear:"清除动态颜色"},color_mapping:{label:"颜色映射",edit:"编辑颜色映射",clear:"清除颜色映射",choose_value_var:"选择用于映射颜色的变量",min:{val:"固定最小值",var:"动态最小值(优先)"},max:{val:"固定最大值",var:"动态最大值(优先)"}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},unit:{title:"单位",text:{placeholder:"单位文案"},show_in_tooltip:"在提示框中显示单位",show_in_legend:"在图例中显示单位"},series_order:{label:"排序依据",name:"名称",value:"值",raw:"不排序,保持数据本身的顺序",asc:"升序",desc:"降序"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最小柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",inverse:"反向坐标轴",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见",mirror:{label:"上下镜像"}},stats:{label:"统计内容",template:{above_chart:"统计内容(图表上方)",under_chart:"统计内容(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"逻辑回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}};class ln{constructor(t){V(this,"rootRef");this.rootRef=G.observable({current:t})}async deleteItem(t){G.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?G.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))G.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else G.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,a){return G.reaction(()=>this.getValueFromRoot(t),(o,l)=>{r(o,l)},{requiresObservable:!0,fireImmediately:y.get(a,"fireImmediately",!1)})}}class Gu{constructor(){V(this,"channels",new Map);V(this,"globalChannel",new ys)}getChannel(t){const r=this.channels.get(t);if(r)return r;const a=new ys;return this.channels.set(t,a),a}}class Fu{constructor(t){V(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const a={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Gu,instanceData:new ln(t.viz.conf)};return this.instances.set(t.id,a),a}}function Ls(e,t,r,a){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ln({}),colorPalette:{getColor(){return()=>""}},data:t,variables:a}}const Qu=e=>{const{panel:t,measure:r,vizManager:a,data:o,variables:l}=e,i=a.resolveComponent(t.viz.type),c=a.getOrCreateInstance(t),d={...Ls(c,o,a,l),viewport:{width:r.w,height:r.h}},u=i.viewRender;return n.jsx(u,{context:d,instance:c,...y.omit(e,["panel","vizManager","data"])})},ju=e=>{const{vizManager:t,panel:r,data:a,variables:o}=e,l=t.resolveComponent(r.viz.type),i=t.getOrCreateInstance(r),c={...Ls(i,a,t,o)},d=l.configRender;return n.jsx(d,{context:c,instance:i,...y.omit(e,["panel","vizManager","data"])})},Ns=(e,t)=>{const r=Ge.bezier(e),a=Ge.bezier(t);return function(o){return o<50?r(o*2/100).hex():a((o-50)*2/100).hex()}},cn=e=>{const t=Ge.bezier(e);return function(r){return t(r/100).hex()}},Wu={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Ns(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Uu={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Ns(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Ku={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:cn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yu={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:cn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Xu={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:cn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Zu={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:cn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Ju{constructor(t){this.pluginManager=t}createPanelAddonNode(t){const a=this.pluginManager.installedPlugins.flatMap(o=>o.manifest.panelAddon).filter(o=>!!o).map(o=>h.createElement(o.addonRender,{...t,key:o.name}));return n.jsx(n.Fragment,{children:a})}}const Gs=h.createContext({addonSlotId:null});function Fs({children:e,addonSlotId:t}){const r=h.useId(),a=t||`panel-addon-slot-${r}`;return n.jsx(Gs.Provider,{value:{addonSlotId:a},children:e})}function Hu(){const{addonSlotId:e}=h.useContext(Gs);return e?document.getElementById(e):null}class Ru{constructor(t){V(this,"symbol");this.symbol=Symbol(t)}}function Je(e){return new Ru(e)}class Xn{constructor(){V(this,"parent");V(this,"factoryRegistry",new Map);V(this,"instanceRegistry",new Map)}createScoped(){const t=new Xn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const a=r(this);return this.instanceRegistry.set(t.symbol,a),a}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Qs="14.57.3",ep=Object.freeze(Object.defineProperty({__proto__:null,version:Qs},Symbol.toStringTag,{value:"Module"}));class tp{constructor(t){V(this,"staticColors",new Map);V(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(a=>{this.register(a)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class np{constructor(){V(this,"plugins",new Map);V(this,"vizComponents",new Map);V(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class rp{constructor(){V(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,a){var i;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const o=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),l=y.orderBy(o,"version","asc");if(((i=y.last(l))==null?void 0:i.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return l.reduce((c,d)=>d.handler(c,a),r)}}class J extends rp{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(a,o)=>({version:t,...r(a,o)}))}async migrate({configData:t,panelModel:r}){const a=await t.getItem(null),o=y.get(a,"version",0),l=this.run({from:o,to:this.VERSION},a,{panelModel:r});await t.setItem(null,l)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const q=(e,t)=>{const[r,{setFalse:a}]=O.useBoolean(!0),[o,l]=h.useState();h.useEffect(()=>(e.getItem(t).then(c=>{l(c),a()}),e.watchItem(t,c=>{l(c)})));const i=h.useCallback(async c=>{await e.setItem(t,c),l(c)},[e,t]);return{loading:r,value:o,set:i}},js=h.createContext(null),Zn=js.Provider;function Wt(){const e=h.useContext(js);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const j=()=>Wt(),Ws=()=>Wt(),Us=h.createContext({}),Jn=Us.Provider;function Ks(){return h.useContext(Us)}const Hn=h.createContext(null),Rn=Hn.Provider;function er(){const e=h.useContext(Hn);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const F=()=>er(),ap={inEditMode:!1},St=h.createContext(ap);function Ys(){const e=h.useContext(St);if(!e)throw new Error("Please use LayoutStateContext.Provider");return e}const Xs=h.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{},getEchartsOptions:()=>null,setEchartsOptions:()=>{}}),tr=Xs.Provider;function nr(){const e=h.useContext(Xs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const re=()=>nr(),ae=()=>nr();function Zs(){try{return nr(),!0}catch{return!1}}const Js=()=>Zs(),Hs=()=>Zs(),sp={fullScreenPanelID:"",setFullScreenPanelID:y.noop},rr=h.createContext(sp);function Rs(){const e=h.useContext(rr);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const op={en:"en",zh:"zh-cn"};function ar({children:e}){const{i18n:t}=m.useTranslation(),r=h.useMemo(()=>{const a=t.language;return op[a]??"en"},[t.language]);return n.jsx(wt.DatesProvider,{settings:{locale:r,firstDayOfWeek:1},children:e})}const H=()=>er(),lp={items:[]},sr=h.createContext(lp),or=sr.Provider;function lr(){return h.useContext(sr)}h.forwardRef(function({value:t,onChange:r,...a},o){return n.jsx(s.TextInput,{ref:o,value:t,onChange:r,...a})});class ip{constructor({valueRange:t,colorRange:r}){V(this,"mapper");this.mapper=dt.interpolate(t,r)}getColor(t){return this.mapper(t)}}function cp(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{const r=Number(t);if(Number.isNaN(r))throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}, parsed: ${r}`);return new ip(e).getColor(r)}catch(r){return console.error(r),"black"}return"black"}const dp=cp;function $(e){const[t,r]=e.split(".");return{queryID:t,columnKey:r}}function eo(e){return!!e&&!!e.columnKey&&!!e.queryID}function up(e){return e.includes(".")?$(e):{queryID:"",columnKey:e}}function me(e,t){var o;const{queryID:r,columnKey:a}=$(t);return r?a?((o=e[r])==null?void 0:o.map(l=>l[a]))??[]:e[r]:[]}function dn(e,t){const{queryID:r}=$(t);return r?e[r]:[]}function pp(e){return Object.values(e)[0]}function un(e,t){const{queryID:r,columnKey:a}=$(t);return e[a]}const We={CryptoJS:_s,d3Array:Os,dayjs:M,lodash:y,numbro:Ee,mathjs:je,faker:Kd.faker,popmotion:Bu},hp=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.4"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.12.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"},{name:"popmotion",url:"https://popmotion.io/",version:"11.0.3"}],gp=e=>`
|
|
10
10
|
<tr>
|
|
11
11
|
<td><code>${e.name}</code></td>
|
|
12
12
|
<td>
|
|
@@ -34,8 +34,8 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
34
34
|
</tbody>
|
|
35
35
|
</table>
|
|
36
36
|
`,to=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
|
|
37
|
-
`),Vt={type:"none",config:{},fallback:"0"};function bp(e){const t=Array.from(e).sort((a,o)=>a-o),r=Math.floor(t.length/2);return t.length%2===0?(t[r-1]+t[r])/2:t[r]}function yp(e,t){switch(t.type){case"sum":return y.sum(e);case"mean":return y.mean(e);case"median":return bp(e);case"max":return y.max(e);case"min":return y.min(e);case"quantile":return jt.quantile(e,t.config.p);case"CV":if(e.length===0)return Number.NaN;const r=je.std(...e),a=je.mean(...e);return a?r/a:Number.NaN;case"std":return e.length===0?Number.NaN:je.std(...e);default:return e}}function
|
|
38
|
-
`)}},Dp=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},zp=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,value:_}=i,w={type:b,value:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,value:b}))},g=()=>{p(lo.dynamic.value)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("chart.number_or_dynamic_value.dynamic.setup")})}),n.jsx(s.Modal,{size:800,title:r("chart.number_or_dynamic_value.dynamic.setup_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-10,label:r("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),n.jsx(Dp,{value:i.value,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"right",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},Mp=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(zp,{value:e,onChange:t}),Ip=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{t({...e,value:typeof a=="string"?"":a})};return n.jsx(s.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:r})},io=h.forwardRef(({label:e="Value",value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=d=>{d!=="static"&&d!=="dynamic"||r({...lo[d]})},c=h.useMemo(()=>[{label:o("chart.number_or_dynamic_value.type.static"),value:"static"},{label:o("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[l.language]);return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e,data:c,value:t.type,onChange:i,sx:{flexGrow:1}}),n.jsx(Ip,{value:t,onChange:r}),n.jsx(Mp,{value:t,onChange:r})]})});function co(e,t,r){if(!e.type)return r;if(e.type==="static"){const{value:o}=e;return Number(o)}const{value:a}=e;try{const o=new Function(`return ${a}`)()({variables:t},{lodash:y,interpolate:dt.interpolate});return Number(o)}catch(o){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${o.message}`),10}}function uo(e){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:e??Object.values(Ue.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function Vp(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[po()],categories:[]}}function rt(){return uo()}function Pp(){return{compared:Object.values(Ue.graphics.compared),level:Object.values(Ue.graphics.level),depth:Object.values(Ue.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function pn(e,t){const{min:r,max:a}=e,o=co(r,t),l=co(a,t);if(e.type==="continuous"){const{skipRange:g,text:b,..._}=e;return{..._,min:o,max:l,text:[...b]}}const{piecewise_mode:i,pieces:c,categories:d,...u}=e,p={...u};return delete p.min,delete p.max,i==="pieces"?p.pieces=c.map(g=>{const b={};g.label&&(b.label=g.label),g.color&&(b.color=g.color);const _=Number(g.lower.value);g.lower.value===""?b[g.lower.symbol]=o:Number.isFinite(_)&&(b[g.lower.symbol]=_);const w=Number(g.upper.value);return g.upper.value===""?b[g.upper.symbol]=l:Number.isFinite(w)&&(b[g.upper.symbol]=w),b}):i==="categories"&&(p.categories=d),p}const Pt=e=>({followVisualMap:!e,color:e});function pr(e,t,r,a){if(a.type!=="continuous")return Pt("");const{skipRange:o}=a;return e===t?Pt(o.min):e===r?Pt(o.max):e<t?Pt(o.lt_min):e>r?Pt(o.gt_max):Pt("")}function po(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const $p=Pp(),Ap=({colors:e,applyPalette:t,zIndex:r=340})=>{const{t:a}=m.useTranslation(),o=`linear-gradient(to right, ${e.join(", ")})`;return n.jsxs(s.Menu,{shadow:"md",width:300,withinPortal:!0,zIndex:r,children:[n.jsx(s.Menu.Target,{children:n.jsxs(s.UnstyledButton,{children:[n.jsx(s.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:a("chart.color.color_gradient")}),n.jsxs(s.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[n.jsx(s.Box,{style:{height:"20px",flexGrow:1,backgroundImage:o,borderRadius:4}}),n.jsx(T.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:a("chart.visual_map.built_in_palettes")}),n.jsx(s.Menu.Divider,{}),Object.entries($p).map(([l,i])=>n.jsx(s.Tooltip,{label:a("chart.visual_map.use_palette_x",{x:l}),children:n.jsx(s.Menu.Item,{children:n.jsx(s.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${i.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{t(i)},title:l})})},l))]})]})},Ep=({color:e,index:t,handleChange:r,handleRemove:a})=>{const[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1),{ref:c,handleRef:d}=an.useSortable({id:e.id,index:t});return n.jsxs(s.Flex,{ref:c,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:l,onMouseLeave:i,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:o?n.jsx(s.ActionIcon,{size:"xs",ref:d,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsx("div",{style:{flex:1},children:n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.value,onChange:r})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},ho=h.forwardRef(({value:e,onChange:t,zIndex:r=340},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>e.map(w=>({id:Te.v4(),value:w})),[e]),i=w=>{t([...e,w])},c=w=>{const x=[...e];x.splice(w,1),t(x)},d=w=>{t([...w])},u=w=>x=>{const S=[...e];S[w]=x,t(S)},[p,g]=h.useState(""),b=()=>{p&&(i(p),g(""))},_=w=>{const{source:x,target:S}=w.operation,D=Un.move(l,x,S);t(D.map(z=>z.value))};return n.jsxs(s.Stack,{ref:a,children:[n.jsx(Ap,{colors:e,applyPalette:d,zIndex:r}),n.jsx(rn.DragDropProvider,{onDragEnd:_,children:l.map((w,x)=>n.jsx(Ep,{color:w,handleChange:u(x),handleRemove:()=>c(x),index:x},w.id))}),n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx("div",{style:{flex:1},children:n.jsx(s.ColorInput,{popoverProps:{withinPortal:!0,zIndex:r},placeholder:o("chart.color.click_to_add_a_color"),value:p,onChange:g,onBlur:b,size:"xs"})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})]})}),Bp=({defaultValues:e,onSubmit:t,unset:r})=>{const{t:a}=m.useTranslation(),o=v.useForm({defaultValues:e}),{control:l,handleSubmit:i,reset:c}=o;h.useEffect(()=>{c(e)},[e]);const d=h.useCallback(()=>c(e),[c,e]);return n.jsxs(s.Box,{children:[n.jsx(s.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),n.jsxs(s.Box,{px:"1rem",children:[n.jsx(v.Controller,{control:l,name:"variable",render:({field:u})=>n.jsx(ur,{label:a("rich_text.color_mapping.choose_value_var"),clearable:!1,preview:"aggregated",zIndex:340,...u})}),n.jsxs(s.Group,{grow:!0,justify:"space-between",children:[n.jsx(v.Controller,{name:"min_var",control:l,render:({field:u})=>n.jsx(ur,{label:a("rich_text.color_mapping.min.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...u})}),n.jsx(v.Controller,{name:"min_val",control:l,render:({field:u})=>n.jsx(s.TextInput,{label:a("rich_text.color_mapping.min.val"),...u,sx:{maxWidth:"120px",flexGrow:0}})})]}),n.jsxs(s.Group,{grow:!0,justify:"space-between",children:[n.jsx(v.Controller,{name:"max_var",control:l,render:({field:u})=>n.jsx(ur,{label:a("rich_text.color_mapping.max.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...u})}),n.jsx(v.Controller,{name:"max_val",control:l,render:({field:u})=>n.jsx(s.TextInput,{label:a("rich_text.color_mapping.max.val"),...u,sx:{maxWidth:"120px",flexGrow:0}})})]}),n.jsx(v.Controller,{control:l,name:"colors",render:({field:u})=>n.jsx(ho,{...u})})]}),n.jsx(s.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),n.jsxs(s.Group,{justify:"space-between",px:"1rem",pb:"0.75rem",children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Button,{color:"red",size:"xs",onClick:r,leftSection:n.jsx(T.IconTrash,{size:18}),children:a("common.actions.clear")}),n.jsx(s.Button,{color:"orange",size:"xs",onClick:d,leftSection:n.jsx(T.IconArrowBackUp,{size:18}),children:a("common.actions.revert")})]}),n.jsx(s.Button,{color:"green",size:"xs",onClick:i(t),leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),children:a("common.actions.save_changes")})]})]})};function qp(e){if(e.length===0)return"";const t=r=>`${r/(e.length-1)*100}%`;return e.map((r,a)=>`${r} ${t(a)}`).join(", ")}function go(e,...t){return`linear-gradient(${e}deg, ${qp(t)})`}const Op=()=>n.jsx("div",{style:{width:"20px",height:"13px",borderRadius:"2px",background:go(90,...Object.values(Ue.graphics.depth))}}),Lp=({disabled:e})=>n.jsx(s.Box,{sx:{width:"16px",height:"10px",borderRadius:"2px",background:go(90,...Object.values(Ue.graphics.depth)),opacity:e?"0.5":1,position:"relative","&:after":{position:"absolute",content:"''",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"15px",height:"15px",background:`
|
|
37
|
+
`),Vt={type:"none",config:{},fallback:"0"};function bp(e){const t=Array.from(e).sort((a,o)=>a-o),r=Math.floor(t.length/2);return t.length%2===0?(t[r-1]+t[r])/2:t[r]}function yp(e,t){switch(t.type){case"sum":return y.sum(e);case"mean":return y.mean(e);case"median":return bp(e);case"max":return y.max(e);case"min":return y.min(e);case"quantile":return jt.quantile(e,t.config.p);case"CV":if(e.length===0)return Number.NaN;const r=je.std(...e),a=je.mean(...e);return a?r/a:Number.NaN;case"std":return e.length===0?Number.NaN:je.std(...e);default:return e}}function ir(e,t){const r=e.map(Number),a=yp(r,t);return typeof a=="number"?Number.isFinite(a)?a:t.fallback:a??t.fallback}function vp(e,t,r){try{const a=dn(e,t);return new Function(`return ${r.config.func}`)()({queryData:a},We)}catch(a){return console.error(a),a.message}}function _p(e,t,r){try{const a=me(e,t),{method:o}=r.config;return y[o](a)}catch(a){return console.error(a),r.fallback}}function cr(e,t,r){try{return r.type==="custom"?vp(e,t,r):r.type==="pick_record"?_p(e,t,r):ir(me(e,t),r)}catch(a){return console.error(a),null}}const dr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:"0 !important"},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}},ur="grad_color_",mp=new RegExp(`^(?!${ur})(.+)$`);function no(e){return e&&e.replace(mp,`${ur}$1`)}const wp=e=>{const r="abcdefghijklmnopqrstuvwxyz",o=`1234567890${r}${r.toUpperCase()}`.split(""),l=new Uint8Array(e);crypto.getRandomValues(l);const i=l.reduce((c,d)=>`${c}${o[d&61]}`,"");return`${ur}${i}`};function xp(e,t,r){try{if(!Number.isFinite(t)||!Number.isFinite(r))throw new Error(`[getColorMappingFunc] invalid interval with min[${t}] max[${r}]`);if(e.length<2)throw new Error("[getColorMappingFunc] expected at least 2 colors");const a=(r-t)/(e.length-1),o=Os.range(t,r+a,a);return Ou.scaleLinear(o,e)}catch(a){return console.error(a),()=>"inherit"}}function ro(e,t,r,a){const o=Number(e.getAttribute(r)),l=e.getAttribute(a);if(!l)return o;const i=Number(t[l]);return Number.isFinite(i)?i:o}function Cp(e,t){const r={};return e.querySelectorAll("color-mapping").forEach(o=>{const l=o.getAttribute(ze.color),i=ro(o,t,ze.min_val,ze.min_var),c=ro(o,t,ze.max_val,ze.max_var),d=o.getAttribute(ze.variable);if(!l||!Number.isFinite(i)||!Number.isFinite(c)||!d)return;const u=Number(t[d]);if(!Number.isFinite(u))return;const p=l.split(","),g=xp(p,i,c);r[`#${no(o.id)}`]={color:g(u)}}),r}function Sp(e){const t=y.get(e,ze.color,[]),r=y.get(e,ze.min_val,""),a=y.get(e,ze.min_var,""),o=y.get(e,ze.max_val,""),l=y.get(e,ze.max_var,""),i=y.get(e,ze.variable,""),c=t.length===0&&[r,a,o,l,i].every(d=>d==="");return{colors:t,min_val:r,min_var:a,max_val:o,max_var:l,variable:i,empty:c}}const le={color:"data-colors",min_val:"data-min-val",min_var:"data-min-var",max_val:"data-max-val",max_var:"data-max-var",variable:"data-var"},ze=le,ao="colorMapping",so=Un.Mark.create({name:ao,addAttributes(){return{id:{default:wp(6),parseHTML:e=>{const t=e.getAttribute("id");return no(t)}},[le.color]:{default:[],parseHTML:e=>{const t=e.getAttribute(le.color);return t?t.split(","):[]}},[le.min_val]:{default:0,parseHTML:e=>e.getAttribute(le.min_val)},[le.min_var]:{default:"",parseHTML:e=>e.getAttribute(le.min_var)},[le.max_val]:{default:100,parseHTML:e=>e.getAttribute(le.max_val)},[le.max_var]:{default:"",parseHTML:e=>e.getAttribute(le.max_var)},[le.variable]:{default:"",parseHTML:e=>e.getAttribute(le.variable)}}},parseHTML(){return[{tag:"color-mapping",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):Object.values(ze).map(t=>e.getAttribute(t))}]},renderHTML({HTMLAttributes:e}){return["color-mapping",e,0]},addCommands(){return{setColorMapping:e=>({commands:t})=>{const{colors:r,min_val:a,min_var:o,max_val:l,max_var:i,variable:c}=e;return t.setMark(this.name,{[le.color]:r,[le.min_val]:a,[le.min_var]:o,[le.max_val]:l,[le.max_var]:i,[le.variable]:c})},unsetColorMapping:()=>({commands:e})=>e.unsetMark(this.name)}}}),Ue={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function Tp(){ce.registerTheme("merico-light",{color:Object.values(Ue.graphics.multiple),visualMap:{color:Object.values(Ue.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function oo(){Tp()}function kp(e){return({option:r,...a})=>{const{aggValue:o,formattedValue:l,label:i}=r,{hovered:c,ref:d}=te.useHover(),u=e==="aggregated"?o:l,p=e==="aggregated"?l:o;return n.jsx(s.Box,{ref:d,...a,children:n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",children:[n.jsx(s.Text,{size:"sm",sx:{flexGrow:1},children:i}),n.jsx(s.Text,{size:"xs",opacity:c?1:.65,sx:{flexShrink:0},children:c?p:u})]})})}}const Z=e=>(t,r)=>{t!==null&&e(t,r)},pr=k.observer(h.forwardRef((e,t)=>{const{label:r,value:a,onChange:o,description:l,required:i,clearable:c=!0,sx:d,preview:u="formatted",zIndex:p=340}=e;m.useTranslation();const{panel:g}=ae(),b=h.useMemo(()=>g.variableOptions(a,c),[a,c]);return b.length===0?n.jsx(s.TextInput,{ref:t,label:r,placeholder:a,readOnly:!0,disabled:!0}):n.jsx(s.Select,{ref:t,label:r,description:l,renderOption:kp(u),data:b,value:a,required:i,sx:d,maxDropdownHeight:500,comboboxProps:{withinPortal:!0,zIndex:p},onChange:Z(o)})})),lo={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
|
|
38
|
+
`)}},Dp=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},zp=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,value:_}=i,w={type:b,value:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,value:b}))},g=()=>{p(lo.dynamic.value)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("chart.number_or_dynamic_value.dynamic.setup")})}),n.jsx(s.Modal,{size:800,title:r("chart.number_or_dynamic_value.dynamic.setup_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-10,label:r("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),n.jsx(Dp,{value:i.value,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"right",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},Mp=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(zp,{value:e,onChange:t}),Ip=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{t({...e,value:typeof a=="string"?"":a})};return n.jsx(s.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:r})},io=h.forwardRef(({label:e="Value",value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=d=>{d!=="static"&&d!=="dynamic"||r({...lo[d]})},c=h.useMemo(()=>[{label:o("chart.number_or_dynamic_value.type.static"),value:"static"},{label:o("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[l.language]);return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e,data:c,value:t.type,onChange:i,sx:{flexGrow:1}}),n.jsx(Ip,{value:t,onChange:r}),n.jsx(Mp,{value:t,onChange:r})]})});function co(e,t,r){if(!e.type)return r;if(e.type==="static"){const{value:o}=e;return Number(o)}const{value:a}=e;try{const o=new Function(`return ${a}`)()({variables:t},{lodash:y,interpolate:dt.interpolate});return Number(o)}catch(o){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${o.message}`),10}}function uo(e){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:e??Object.values(Ue.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function Vp(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[po()],categories:[]}}function rt(){return uo()}function Pp(){return{compared:Object.values(Ue.graphics.compared),level:Object.values(Ue.graphics.level),depth:Object.values(Ue.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function pn(e,t){const{min:r,max:a}=e,o=co(r,t),l=co(a,t);if(e.type==="continuous"){const{skipRange:g,text:b,..._}=e;return{..._,min:o,max:l,text:[...b]}}const{piecewise_mode:i,pieces:c,categories:d,...u}=e,p={...u};return delete p.min,delete p.max,i==="pieces"?p.pieces=c.map(g=>{const b={};g.label&&(b.label=g.label),g.color&&(b.color=g.color);const _=Number(g.lower.value);g.lower.value===""?b[g.lower.symbol]=o:Number.isFinite(_)&&(b[g.lower.symbol]=_);const w=Number(g.upper.value);return g.upper.value===""?b[g.upper.symbol]=l:Number.isFinite(w)&&(b[g.upper.symbol]=w),b}):i==="categories"&&(p.categories=d),p}const Pt=e=>({followVisualMap:!e,color:e});function hr(e,t,r,a){if(a.type!=="continuous")return Pt("");const{skipRange:o}=a;return e===t?Pt(o.min):e===r?Pt(o.max):e<t?Pt(o.lt_min):e>r?Pt(o.gt_max):Pt("")}function po(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const $p=Pp(),Ap=({colors:e,applyPalette:t,zIndex:r=340})=>{const{t:a}=m.useTranslation(),o=`linear-gradient(to right, ${e.join(", ")})`;return n.jsxs(s.Menu,{shadow:"md",width:300,withinPortal:!0,zIndex:r,children:[n.jsx(s.Menu.Target,{children:n.jsxs(s.UnstyledButton,{children:[n.jsx(s.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:a("chart.color.color_gradient")}),n.jsxs(s.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[n.jsx(s.Box,{style:{height:"20px",flexGrow:1,backgroundImage:o,borderRadius:4}}),n.jsx(T.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:a("chart.visual_map.built_in_palettes")}),n.jsx(s.Menu.Divider,{}),Object.entries($p).map(([l,i])=>n.jsx(s.Tooltip,{label:a("chart.visual_map.use_palette_x",{x:l}),children:n.jsx(s.Menu.Item,{children:n.jsx(s.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${i.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{t(i)},title:l})})},l))]})]})},Ep=({color:e,index:t,handleChange:r,handleRemove:a})=>{const[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1),{ref:c,handleRef:d}=an.useSortable({id:e.id,index:t});return n.jsxs(s.Flex,{ref:c,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:l,onMouseLeave:i,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:o?n.jsx(s.ActionIcon,{size:"xs",ref:d,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsx("div",{style:{flex:1},children:n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.value,onChange:r})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},ho=h.forwardRef(({value:e,onChange:t,zIndex:r=340},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>e.map(w=>({id:Te.v4(),value:w})),[e]),i=w=>{t([...e,w])},c=w=>{const x=[...e];x.splice(w,1),t(x)},d=w=>{t([...w])},u=w=>x=>{const S=[...e];S[w]=x,t(S)},[p,g]=h.useState(""),b=()=>{p&&(i(p),g(""))},_=w=>{const{source:x,target:S}=w.operation,D=Kn.move(l,x,S);t(D.map(z=>z.value))};return n.jsxs(s.Stack,{ref:a,children:[n.jsx(Ap,{colors:e,applyPalette:d,zIndex:r}),n.jsx(rn.DragDropProvider,{onDragEnd:_,children:l.map((w,x)=>n.jsx(Ep,{color:w,handleChange:u(x),handleRemove:()=>c(x),index:x},w.id))}),n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx("div",{style:{flex:1},children:n.jsx(s.ColorInput,{popoverProps:{withinPortal:!0,zIndex:r},placeholder:o("chart.color.click_to_add_a_color"),value:p,onChange:g,onBlur:b,size:"xs"})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})]})}),Bp=({defaultValues:e,onSubmit:t,unset:r})=>{const{t:a}=m.useTranslation(),o=v.useForm({defaultValues:e}),{control:l,handleSubmit:i,reset:c}=o;h.useEffect(()=>{c(e)},[e]);const d=h.useCallback(()=>c(e),[c,e]);return n.jsxs(s.Box,{children:[n.jsx(s.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),n.jsxs(s.Box,{px:"1rem",children:[n.jsx(v.Controller,{control:l,name:"variable",render:({field:u})=>n.jsx(pr,{label:a("rich_text.color_mapping.choose_value_var"),clearable:!1,preview:"aggregated",zIndex:340,...u})}),n.jsxs(s.Group,{grow:!0,justify:"space-between",children:[n.jsx(v.Controller,{name:"min_var",control:l,render:({field:u})=>n.jsx(pr,{label:a("rich_text.color_mapping.min.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...u})}),n.jsx(v.Controller,{name:"min_val",control:l,render:({field:u})=>n.jsx(s.TextInput,{label:a("rich_text.color_mapping.min.val"),...u,sx:{maxWidth:"120px",flexGrow:0}})})]}),n.jsxs(s.Group,{grow:!0,justify:"space-between",children:[n.jsx(v.Controller,{name:"max_var",control:l,render:({field:u})=>n.jsx(pr,{label:a("rich_text.color_mapping.max.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...u})}),n.jsx(v.Controller,{name:"max_val",control:l,render:({field:u})=>n.jsx(s.TextInput,{label:a("rich_text.color_mapping.max.val"),...u,sx:{maxWidth:"120px",flexGrow:0}})})]}),n.jsx(v.Controller,{control:l,name:"colors",render:({field:u})=>n.jsx(ho,{...u})})]}),n.jsx(s.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),n.jsxs(s.Group,{justify:"space-between",px:"1rem",pb:"0.75rem",children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Button,{color:"red",size:"xs",onClick:r,leftSection:n.jsx(T.IconTrash,{size:18}),children:a("common.actions.clear")}),n.jsx(s.Button,{color:"orange",size:"xs",onClick:d,leftSection:n.jsx(T.IconArrowBackUp,{size:18}),children:a("common.actions.revert")})]}),n.jsx(s.Button,{color:"green",size:"xs",onClick:i(t),leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),children:a("common.actions.save_changes")})]})]})};function qp(e){if(e.length===0)return"";const t=r=>`${r/(e.length-1)*100}%`;return e.map((r,a)=>`${r} ${t(a)}`).join(", ")}function go(e,...t){return`linear-gradient(${e}deg, ${qp(t)})`}const Op=()=>n.jsx("div",{style:{width:"20px",height:"13px",borderRadius:"2px",background:go(90,...Object.values(Ue.graphics.depth))}}),Lp=({disabled:e})=>n.jsx(s.Box,{sx:{width:"16px",height:"10px",borderRadius:"2px",background:go(90,...Object.values(Ue.graphics.depth)),opacity:e?"0.5":1,position:"relative","&:after":{position:"absolute",content:"''",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"15px",height:"15px",background:`
|
|
39
39
|
linear-gradient(to top right,
|
|
40
40
|
rgba(0,0,0,0) 0%,
|
|
41
41
|
rgba(0,0,0,0) calc(50% - 1.4px),
|
|
@@ -48,25 +48,25 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
48
48
|
rgba(0,0,0,0) 100%)`}}}),Np=({editor:e})=>{const{t}=m.useTranslation(),[r,{set:a,setTrue:o,setFalse:l,toggle:i}]=O.useBoolean(),c=e.getAttributes(ao),{empty:d,...u}=h.useMemo(()=>Sp(c),[c]),p=h.useCallback(b=>{e.chain().focus().setColorMapping(b).run(),l()},[e]),g=h.useCallback(()=>{e.chain().focus().unsetColorMapping().run()},[e]);return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{size:500,opened:r,onClose:l,shadow:"md",withinPortal:!0,zIndex:330,closeOnClickOutside:!1,closeOnEscape:!1,title:t("rich_text.color_mapping.edit"),styles:{header:{paddingBottom:0,minHeight:"unset"},body:{padding:0}},children:n.jsx(Bp,{defaultValues:u,unset:g,onSubmit:p})}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(s.Tooltip,{label:t("rich_text.color_mapping.label"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},onClick:o,children:n.jsx(Op,{})})}),n.jsx(s.Tooltip,{label:t("rich_text.color_mapping.clear"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"},disabled:d,onClick:g,children:n.jsx(Lp,{disabled:d})})})]})]})},hn="function color({ variables }, { filters, context }, utils) {",fo="}",Gp=[hn,' return "red";',fo].join(`
|
|
49
49
|
`);function Fp(e){if(!e)return[];const t=e.split(`
|
|
50
50
|
`),r=t.length+1;let a=1;const o=t[t.length-1];return o&&(a=o.length+1),[{range:[2,1,r,a],label:"body",allowMultiline:!0}]}const Qp=e=>e&&e.replace(hn,"").replace(/(.*)\}$/,"$1"),bo=e=>!e||e.startsWith(hn)?e:[hn,e,fo].join(`
|
|
51
|
-
`),hr="dyn_color_",jp=new RegExp(`^(?!${hr})(.+)$`);function yo(e){return e&&e.replace(jp,`${hr}$1`)}const vo=e=>{const r="abcdefghijklmnopqrstuvwxyz",o=`1234567890${r}${r.toUpperCase()}`.split(""),l=new Uint8Array(e);crypto.getRandomValues(l);const i=l.reduce((c,d)=>`${c}${o[d&61]}`,"");return`${hr}${i}`};function Wp(e,t,r){const a={},o=i=>new Function(`return ${bo(i)}`)()({variables:r},t,We);return e.querySelectorAll("dynamic-color").forEach(i=>{const c=i.getAttribute("data-value");c&&(a[`#${yo(i.id)}`]={color:o(c)})}),a}const Ut="data-value",Up=Ut,_o="dynamicColor",mo=Wn.Mark.create({name:_o,addAttributes(){return{id:{default:vo(6),parseHTML:e=>{const t=e.getAttribute("id");return yo(t)}},[Ut]:{default:null,parseHTML:e=>e.getAttribute(Ut)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(Ut)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>{const r=Qp(e);return t.setMark(this.name,{[Ut]:r})},unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),Kp=({value:e,onChange:t,onMount:r})=>{const a=h.useRef(null),o=h.useRef(null),l=c=>{if(!c){t("");return}t(c)};h.useEffect(()=>{var d;const c=(d=a.current)==null?void 0:d.getModel();c&&(c.getValue()||c.setValue(e))},[e]);const i=(c,d)=>{a.current=c,o.current=d,r==null||r(c,d)};return n.jsx(Se,{className:"function-editor",height:"100%",defaultLanguage:"javascript",defaultValue:e,onChange:l,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:i})},Tt=h.forwardRef(({value:e,onChange:t,label:r,defaultValue:a,restrictions:o=[]},l)=>{const{t:i}=m.useTranslation(),[c,d]=h.useState(e),u=()=>{t(c)},p=()=>{d(e)},g=()=>{d(a)};h.useEffect(()=>{d(e)},[e]);const b=h.useCallback((x,S)=>{if(o.length===0)return;const D=Zd.constrainedEditor(S),z=x.getModel();if(D.initializeIn(x),D.addRestrictionsTo(z,o),!!z&&!z._hasHighlight){D.toggleDevMode(),z.toggleHighlightOfEditableAreas();const I=z.getCurrentEditableRanges(),A=z.getValueInEditableRanges();console.debug({model:z,currentRanges:I,currentValue:A})}},[o]),_=c!==e,w=typeof c=="string"&&c.length===0;return n.jsxs(s.Stack,{gap:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[n.jsxs(s.Group,{mb:6,justify:"space-between",sx:{flexShrink:0,flexGrow:0},children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(xo,{})}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:g,size:"xs",variant:"default",leftSection:n.jsx(T.IconPlayerSkipBack,{size:16}),children:i("common.actions.reset_to_default")}),n.jsx(s.Button,{onClick:p,color:"red",size:"xs",disabled:!_,leftSection:n.jsx(T.IconRecycle,{size:16}),children:i("common.actions.revert_changes")}),n.jsx(s.Button,{color:"green",size:"xs",onClick:u,disabled:!_,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:i("common.actions.save_changes")})]})]}),n.jsx(s.Text,{size:"14px",children:r}),n.jsxs(s.Box,{sx:{position:"relative",flexGrow:1},children:[w&&n.jsx(s.Overlay,{center:!0,color:"#fff",backgroundOpacity:.5,children:n.jsx(s.Button,{color:"blue",radius:"xl",onClick:g,children:i("common.actions.init_with_default")})}),n.jsx(Kp,{value:c,onChange:d,onMount:b})]})]})}),gr=h.forwardRef(({title:e,value:t,onChange:r,label:a,description:o=null,triggerLabel:l="Edit",triggerButtonProps:i={},renderTriggerButton:c,defaultValue:d,zIndex:u=320,restrictions:p},g)=>{const[b,{open:_,close:w}]=te.useDisclosure(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Modal,{opened:b,onClose:w,title:e,withinPortal:!0,zIndex:u,size:"900px",children:[o,n.jsx(s.Box,{h:600,children:n.jsx(Tt,{value:t,onChange:r,defaultValue:d,label:a,restrictions:p})})]}),c==null?void 0:c({onClick:_}),!c&&n.jsx(s.Button,{onClick:_,...i,children:l})]})}),Yp=({onClick:e})=>{const{t}=m.useTranslation();return n.jsx(s.Tooltip,{label:t("rich_text.dynamic_color.label"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:n.jsx(T.IconMathFunction,{stroke:2,size:16})})})},Xp=({editor:e})=>{const{t}=m.useTranslation(),r=e.getAttributes(_o)[Up]??"",a=bo(r),o=Fp(r);return n.jsxs(n.Fragment,{children:[n.jsx(gr,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:a,onChange:l=>{l?e.chain().focus().setDynamicColor(l).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:Gp,renderTriggerButton:Yp,restrictions:o,zIndex:340}),n.jsx(s.Tooltip,{label:t("rich_text.dynamic_color.clear"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},disabled:!r,onClick:()=>e.chain().focus().unsetDynamicColor().run(),children:n.jsx(T.IconMathFunctionOff,{stroke:1.5,size:16})})})]})},wo=Wn.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Zp=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),Jp=[{label:"auto",value:""}].concat(Zp.map(e=>({label:e,value:e}))),Hp={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Rp=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(s.NativeSelect,{size:"xs",leftSection:n.jsx(T.IconTextSize,{stroke:1.5,size:16}),data:Jp,styles:Hp,value:t||"",onChange:r=>{const a=r.currentTarget.value;a?e.chain().focus().setFontSize(a).run():e.chain().focus().unsetFontSize().run()}})})},$t=h.forwardRef(({value:e,styles:t={},sx:r={},dashboardStateValues:a=yr(),variableAggValueMap:o={}},l)=>{const i=Js(),c=h.useMemo(()=>{const _=[$s,Vs,Q.Link,Ss,Cs,ws,Ts.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),zs,Ds,ks,Ms.configure({types:["heading","paragraph"]}),xs.configure({placeholder:"This is placeholder"}),Is,ms.Color,wo,mo];return i&&_.push(so),_},[i]),d=Ps.useEditor({extensions:c,content:e,editable:!1});h.useEffect(()=>{d==null||d.commands.setContent(e)},[e,d]);const u=h.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),p=h.useMemo(()=>Wp(u,a,o),[u,a,o]),g=h.useMemo(()=>Cp(u,o),[u,o]),b=h.useMemo(()=>y.defaultsDeep({},{content:{...cr,...p,...g}},t),[t,p,g]);return n.jsx(Q.RichTextEditor,{editor:d,styles:b,sx:r,children:n.jsx(Q.RichTextEditor.Content,{ref:l})})});function xo(){const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:a,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:n.jsx($t,{value:fp(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),n.jsx(s.Button,{variant:"light",color:"violet",size:"xs",onClick:r,leftSection:n.jsx(T.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const fr=({option:e,checked:t,...r})=>{const{label:a,description:o}=e;return n.jsx("div",{...r,style:{flexGrow:1},children:n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsxs(s.Group,{justify:"flex-start",gap:"0.5em",children:[t&&n.jsx(T.IconCheck,{size:16,color:"green"}),n.jsx(s.Text,{size:"sm",sx:{flexGrow:1},children:a})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:o})]})})},br=({value:e,onChange:t,height:r="200px",defaultLanguage:a="sql",theme:o="vs-dark"})=>{const l=c=>{t==null||t(c??"")},i=!t;return n.jsx(Se,{className:"minimal-monaco-editor",height:r,defaultLanguage:a,value:e,onChange:i?void 0:l,theme:o,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:i||!t,"semanticHighlighting.enabled":!0}})},eh=({color:e})=>h.forwardRef(({onClick:t},r)=>n.jsx(Q.RichTextEditor.Control,{ref:r,onClick:t,children:n.jsx(s.ColorSwatch,{color:e,size:14})})),th=({editor:e})=>{const t=s.useMantineTheme(),r=e.getAttributes("textStyle").color||t.black,a=h.useMemo(()=>To(r),[r]),o=h.useCallback(i=>{e.chain().setColor(i).run()},[e]),l=h.useCallback(()=>{e.chain().focus().unsetColor().run()},[e]);return n.jsx(Do,{value:a,onChange:o,clear:l,Trigger:eh({color:a})})},nh={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"},"color-mapping":{position:"relative"},"color-mapping:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"4px",opacity:.8,background:"linear-gradient(90deg, rgb(255, 225, 225) 0%, rgb(253, 188, 188) 40%, rgb(243, 148, 148) 60%, rgb(250, 66, 66) 80%, rgb(226, 18, 18) 100%)"}};function rh(){const{editor:e}=Q.useRichTextEditorContext();return n.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:n.jsx(T.IconBorderAll,{stroke:1.5,size:16})})}const gn=h.forwardRef(({value:e,onChange:t,styles:r={},label:a,onSubmit:o,onCancel:l},i)=>{const{t:c}=m.useTranslation(),d=Hs(),u=h.useMemo(()=>{const z=[$s,Vs,Q.Link,Ss,Cs,ws,Ts.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),zs,Ds,ks,Ms.configure({types:["heading","paragraph"]}),xs.configure({placeholder:"This is placeholder"}),Is,ms.Color,wo,mo];return d&&z.push(so),z},[d]),[p,g]=h.useState(e),b=()=>{t(p),o==null||o()},_=({editor:z})=>{const I=z.getHTML();g(I)},w=Ps.useEditor({extensions:u,content:e,onUpdate:_,onCreate:({editor:z})=>{z.view.dom.setAttribute("spellcheck","false"),z.view.dom.setAttribute("autocomplete","off"),z.view.dom.setAttribute("autocapitalize","off")}});h.useEffect(()=>{g(e),w==null||w.commands.setContent(e)},[e]);const x=e!==p,S=h.useMemo(()=>y.defaultsDeep({},{content:{...cr,...nh}},r),[r]);if(!w)return null;const D=!!l;return n.jsxs(s.Stack,{gap:4,sx:{flexGrow:1,position:"relative"},children:[n.jsxs(s.Group,{align:"center",children:[n.jsx(s.Text,{size:"14px",fw:500,children:a}),!D&&n.jsx(s.Button,{variant:"filled",color:"blue",size:"compact-xs",disabled:!x,onClick:b,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:c("common.actions.save_changes")})]}),n.jsxs(Q.RichTextEditor,{editor:w,styles:S,children:[n.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[n.jsx(th,{editor:w}),d&&n.jsx(Np,{editor:w}),n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(Xp,{editor:w})}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Bold,{}),n.jsx(Q.RichTextEditor.Italic,{}),n.jsx(Q.RichTextEditor.Underline,{}),n.jsx(Q.RichTextEditor.ClearFormatting,{}),n.jsx(Q.RichTextEditor.Highlight,{}),n.jsx(Q.RichTextEditor.Code,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.H1,{}),n.jsx(Q.RichTextEditor.H2,{}),n.jsx(Q.RichTextEditor.H3,{}),n.jsx(Q.RichTextEditor.H4,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Blockquote,{}),n.jsx(Q.RichTextEditor.Hr,{}),n.jsx(Q.RichTextEditor.BulletList,{}),n.jsx(Q.RichTextEditor.OrderedList,{}),n.jsx(Q.RichTextEditor.Subscript,{}),n.jsx(Q.RichTextEditor.Superscript,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Link,{}),n.jsx(Q.RichTextEditor.Unlink,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.AlignLeft,{}),n.jsx(Q.RichTextEditor.AlignCenter,{}),n.jsx(Q.RichTextEditor.AlignJustify,{}),n.jsx(Q.RichTextEditor.AlignRight,{})]}),n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(rh,{})}),n.jsx(Rp,{editor:w})]}),n.jsx(Q.RichTextEditor.Content,{})]}),D&&n.jsxs(s.Group,{justify:"space-between",pt:"md",children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:l,children:c("common.actions.cancel")}),n.jsx(s.Button,{variant:"filled",color:"blue",size:"xs",disabled:!x,onClick:b,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:c("common.actions.save_changes")})]})]})}),gt=({initialValue:e,onChange:t,label:r})=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Stack,{gap:4,children:[n.jsx(s.Text,{size:"sm",fw:"bold",children:r}),n.jsx(s.Button,{variant:"light",size:"xs",onClick:l,disabled:o,children:a("common.actions.edit_rich_text")})]}),n.jsx(s.Modal,{opened:o,onClose:i,withinPortal:!0,zIndex:400,closeOnEscape:!1,closeOnClickOutside:!1,withCloseButton:!1,size:800,children:o&&n.jsx(gn,{value:e,onChange:t,label:r??"",styles:{root:{flexGrow:1,minHeight:"400px"}},onCancel:i,onSubmit:i})})]})},Co={hex:/^#?([0-9A-F]{3}){1,2}$/i,fullHex:/^#?([0-9A-F]{6})$/i,hexa:/^#?([0-9A-F]{4}){1,2}$/i,rgb:/^rgb\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i,rgba:/^rgba\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i,hsl:/hsl\(\s*(\d+)\s*,\s*(\d+(?:\.\d+)?%)\s*,\s*(\d+(?:\.\d+)?%)\)/i,hsla:/^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*(\d*(?:\.\d+)?)\)$/i},ah=y.pick(Co,"fullHex","rgb","rgba","hsl","hsla"),sh=y.pick(Co,"fullHex","rgb","rgba","hsl","hsla");function oh(e){return Object.values(ah).some(t=>t.test(e))}function So(e){return Object.values(sh).some(t=>t.test(e))}function To(e){return So(e)?e:Ge.valid(e)?Ge(e).css():e}const ko=({value:e})=>So(e)?n.jsx(s.ColorSwatch,{ml:8,size:16,color:e}):n.jsx(s.ColorSwatch,{ml:8,size:16,color:""}),lh=({value:e,onChange:t,shouldPatch:r})=>{const{t:a}=m.useTranslation(),[o,l]=h.useState(e);h.useEffect(()=>{r&&l(e)},[e,r]);const i=h.useCallback(c=>{const d=c.currentTarget.value;l(d),oh(d)&&t(d)},[t]);return n.jsx(s.TextInput,{value:o,onChange:i,leftSection:n.jsx(ko,{value:o}),size:"xs",placeholder:a("chart.color.not_set"),styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center",textTransform:"uppercase"}}})},ih=["gray","red","grape","blue","cyan","green","yellow"],Do=({Trigger:e,value:t,onChange:r,clear:a})=>{const{t:o}=m.useTranslation(),l=s.useMantineTheme(),[i,{set:c,setFalse:d,toggle:u}]=O.useBoolean(),[p,g]=h.useState(!1),b=h.useMemo(()=>{const D=[];return ih.forEach(z=>{const I=l.colors[z];I&&I.forEach(A=>{D.push(A)})}),D},[l.colors]),_=(D,z=!0)=>{r(D),z&&d()},w=h.useCallback(D=>{_(D,!1),g(!1)},[]),x=h.useCallback(D=>{_(D,!1),g(!0)},[]),S=()=>{a(),d()};return n.jsxs(s.Popover,{opened:i,onChange:c,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[n.jsx(s.Popover.Target,{children:n.jsx(e,{onClick:u})}),n.jsx(s.Popover.Dropdown,{children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(lh,{value:t,onChange:w,shouldPatch:p}),n.jsx(s.ActionIcon,{variant:"default",onClick:S,title:o("common.actions.clear"),children:n.jsx(T.IconCircleOff,{stroke:1.5,size:"1rem"})}),n.jsx(s.ActionIcon,{variant:"default",onClick:d,title:o("common.actions.close"),children:n.jsx(T.IconX,{stroke:1.5,size:"1rem"})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.ColorPicker,{format:"hex",swatches:b,value:t,onChange:x,size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),n.jsx(s.ColorPicker,{format:"hex",fullWidth:!0,value:t,onChange:x})]})]})})]})},ch=({color:e,label:t})=>h.forwardRef(({onClick:r},a)=>n.jsx(s.Button,{ref:a,size:"sm",variant:"default",leftSection:n.jsx(ko,{value:e}),onClick:r,children:t})),ye=h.forwardRef(({value:e="",onChange:t,label:r},a)=>{const o=h.useCallback(()=>{t("")},[t]),l=h.useMemo(()=>To(e),[e]);return n.jsx(Do,{value:l,onChange:t,clear:o,Trigger:ch({color:l,label:r})})}),de={mantissa:2,output:"number",trimMantissa:!0,average:!1,absolute:!1},zo=()=>({mantissa:2,output:"number",trimMantissa:!0,average:!1,absolute:!1});function Y(e,{absolute:t,...r}){if(e===null)return String(e);try{let a=Ee(e).value();if(a===void 0||Number.isNaN(a))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(a=Math.abs(a)),Ee(a).format(r)}catch(a){return console.debug(a),String(e)}}function dh(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function He({data_field:e,aggregation:t},r){return ir(r,e,t)}function Be({formatter:e,aggregation:t},r){if(typeof r!="string"&&typeof r!="number")return dh(r);if(t.type==="custom")return r;try{return Y(r,e)}catch(a){return console.error(a),r}}function At(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...a)=>{const o=a[2],l=t.variableStyleMap[o];if(!l)return`{{${o}}}`;const{variable:i,...c}=l,d=Object.entries(c).map(([b,_])=>`${b}:${_}`).join(";"),u=i.color;if(u.type!=="continuous")return`<span style="${d}">{{${o}}}</span>`;const p=vo(6),g=`try {
|
|
51
|
+
`),gr="dyn_color_",jp=new RegExp(`^(?!${gr})(.+)$`);function yo(e){return e&&e.replace(jp,`${gr}$1`)}const vo=e=>{const r="abcdefghijklmnopqrstuvwxyz",o=`1234567890${r}${r.toUpperCase()}`.split(""),l=new Uint8Array(e);crypto.getRandomValues(l);const i=l.reduce((c,d)=>`${c}${o[d&61]}`,"");return`${gr}${i}`};function Wp(e,t,r){const a={},o=i=>new Function(`return ${bo(i)}`)()({variables:r},t,We);return e.querySelectorAll("dynamic-color").forEach(i=>{const c=i.getAttribute("data-value");c&&(a[`#${yo(i.id)}`]={color:o(c)})}),a}const Ut="data-value",Up=Ut,_o="dynamicColor",mo=Un.Mark.create({name:_o,addAttributes(){return{id:{default:vo(6),parseHTML:e=>{const t=e.getAttribute("id");return yo(t)}},[Ut]:{default:null,parseHTML:e=>e.getAttribute(Ut)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(Ut)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>{const r=Qp(e);return t.setMark(this.name,{[Ut]:r})},unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),Kp=({value:e,onChange:t,onMount:r})=>{const a=h.useRef(null),o=h.useRef(null),l=c=>{if(!c){t("");return}t(c)};h.useEffect(()=>{var d;const c=(d=a.current)==null?void 0:d.getModel();c&&(c.getValue()||c.setValue(e))},[e]);const i=(c,d)=>{a.current=c,o.current=d,r==null||r(c,d)};return n.jsx(Se,{className:"function-editor",height:"100%",defaultLanguage:"javascript",defaultValue:e,onChange:l,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:i})},Tt=h.forwardRef(({value:e,onChange:t,label:r,defaultValue:a,restrictions:o=[]},l)=>{const{t:i}=m.useTranslation(),[c,d]=h.useState(e),u=()=>{t(c)},p=()=>{d(e)},g=()=>{d(a)};h.useEffect(()=>{d(e)},[e]);const b=h.useCallback((x,S)=>{if(o.length===0)return;const D=Zd.constrainedEditor(S),z=x.getModel();if(D.initializeIn(x),D.addRestrictionsTo(z,o),!!z&&!z._hasHighlight){D.toggleDevMode(),z.toggleHighlightOfEditableAreas();const I=z.getCurrentEditableRanges(),A=z.getValueInEditableRanges();console.debug({model:z,currentRanges:I,currentValue:A})}},[o]),_=c!==e,w=typeof c=="string"&&c.length===0;return n.jsxs(s.Stack,{gap:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[n.jsxs(s.Group,{mb:6,justify:"space-between",sx:{flexShrink:0,flexGrow:0},children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(xo,{})}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:g,size:"xs",variant:"default",leftSection:n.jsx(T.IconPlayerSkipBack,{size:16}),children:i("common.actions.reset_to_default")}),n.jsx(s.Button,{onClick:p,color:"red",size:"xs",disabled:!_,leftSection:n.jsx(T.IconRecycle,{size:16}),children:i("common.actions.revert_changes")}),n.jsx(s.Button,{color:"green",size:"xs",onClick:u,disabled:!_,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:i("common.actions.save_changes")})]})]}),n.jsx(s.Text,{size:"14px",children:r}),n.jsxs(s.Box,{sx:{position:"relative",flexGrow:1},children:[w&&n.jsx(s.Overlay,{center:!0,color:"#fff",backgroundOpacity:.5,children:n.jsx(s.Button,{color:"blue",radius:"xl",onClick:g,children:i("common.actions.init_with_default")})}),n.jsx(Kp,{value:c,onChange:d,onMount:b})]})]})}),fr=h.forwardRef(({title:e,value:t,onChange:r,label:a,description:o=null,triggerLabel:l="Edit",triggerButtonProps:i={},renderTriggerButton:c,defaultValue:d,zIndex:u=320,restrictions:p},g)=>{const[b,{open:_,close:w}]=te.useDisclosure(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Modal,{opened:b,onClose:w,title:e,withinPortal:!0,zIndex:u,size:"900px",children:[o,n.jsx(s.Box,{h:600,children:n.jsx(Tt,{value:t,onChange:r,defaultValue:d,label:a,restrictions:p})})]}),c==null?void 0:c({onClick:_}),!c&&n.jsx(s.Button,{onClick:_,...i,children:l})]})}),Yp=({onClick:e})=>{const{t}=m.useTranslation();return n.jsx(s.Tooltip,{label:t("rich_text.dynamic_color.label"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:n.jsx(T.IconMathFunction,{stroke:2,size:16})})})},Xp=({editor:e})=>{const{t}=m.useTranslation(),r=e.getAttributes(_o)[Up]??"",a=bo(r),o=Fp(r);return n.jsxs(n.Fragment,{children:[n.jsx(fr,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:a,onChange:l=>{l?e.chain().focus().setDynamicColor(l).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:Gp,renderTriggerButton:Yp,restrictions:o,zIndex:340}),n.jsx(s.Tooltip,{label:t("rich_text.dynamic_color.clear"),children:n.jsx(s.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},disabled:!r,onClick:()=>e.chain().focus().unsetDynamicColor().run(),children:n.jsx(T.IconMathFunctionOff,{stroke:1.5,size:16})})})]})},wo=Un.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Zp=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),Jp=[{label:"auto",value:""}].concat(Zp.map(e=>({label:e,value:e}))),Hp={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Rp=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(s.NativeSelect,{size:"xs",leftSection:n.jsx(T.IconTextSize,{stroke:1.5,size:16}),data:Jp,styles:Hp,value:t||"",onChange:r=>{const a=r.currentTarget.value;a?e.chain().focus().setFontSize(a).run():e.chain().focus().unsetFontSize().run()}})})},$t=h.forwardRef(({value:e,styles:t={},sx:r={},dashboardStateValues:a=vr(),variableAggValueMap:o={}},l)=>{const i=Js(),c=h.useMemo(()=>{const _=[$s,Vs,Q.Link,Ss,Cs,ws,Ts.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),zs,Ds,ks,Ms.configure({types:["heading","paragraph"]}),xs.configure({placeholder:"This is placeholder"}),Is,ms.Color,wo,mo];return i&&_.push(so),_},[i]),d=Ps.useEditor({extensions:c,content:e,editable:!1});h.useEffect(()=>{d==null||d.commands.setContent(e)},[e,d]);const u=h.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),p=h.useMemo(()=>Wp(u,a,o),[u,a,o]),g=h.useMemo(()=>Cp(u,o),[u,o]),b=h.useMemo(()=>y.defaultsDeep({},{content:{...dr,...p,...g}},t),[t,p,g]);return n.jsx(Q.RichTextEditor,{editor:d,styles:b,sx:r,children:n.jsx(Q.RichTextEditor.Content,{ref:l})})});function xo(){const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:a,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:n.jsx($t,{value:fp(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),n.jsx(s.Button,{variant:"light",color:"violet",size:"xs",onClick:r,leftSection:n.jsx(T.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const br=({option:e,checked:t,...r})=>{const{label:a,description:o}=e;return n.jsx("div",{...r,style:{flexGrow:1},children:n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsxs(s.Group,{justify:"flex-start",gap:"0.5em",children:[t&&n.jsx(T.IconCheck,{size:16,color:"green"}),n.jsx(s.Text,{size:"sm",sx:{flexGrow:1},children:a})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:o})]})})},yr=({value:e,onChange:t,height:r="200px",defaultLanguage:a="sql",theme:o="vs-dark"})=>{const l=c=>{t==null||t(c??"")},i=!t;return n.jsx(Se,{className:"minimal-monaco-editor",height:r,defaultLanguage:a,value:e,onChange:i?void 0:l,theme:o,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:i||!t,"semanticHighlighting.enabled":!0}})},eh=({color:e})=>h.forwardRef(({onClick:t},r)=>n.jsx(Q.RichTextEditor.Control,{ref:r,onClick:t,children:n.jsx(s.ColorSwatch,{color:e,size:14})})),th=({editor:e})=>{const t=s.useMantineTheme(),r=e.getAttributes("textStyle").color||t.black,a=h.useMemo(()=>To(r),[r]),o=h.useCallback(i=>{e.chain().setColor(i).run()},[e]),l=h.useCallback(()=>{e.chain().focus().unsetColor().run()},[e]);return n.jsx(Do,{value:a,onChange:o,clear:l,Trigger:eh({color:a})})},nh={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"},"color-mapping":{position:"relative"},"color-mapping:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"4px",opacity:.8,background:"linear-gradient(90deg, rgb(255, 225, 225) 0%, rgb(253, 188, 188) 40%, rgb(243, 148, 148) 60%, rgb(250, 66, 66) 80%, rgb(226, 18, 18) 100%)"}};function rh(){const{editor:e}=Q.useRichTextEditorContext();return n.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:n.jsx(T.IconBorderAll,{stroke:1.5,size:16})})}const gn=h.forwardRef(({value:e,onChange:t,styles:r={},label:a,onSubmit:o,onCancel:l},i)=>{const{t:c}=m.useTranslation(),d=Hs(),u=h.useMemo(()=>{const z=[$s,Vs,Q.Link,Ss,Cs,ws,Ts.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),zs,Ds,ks,Ms.configure({types:["heading","paragraph"]}),xs.configure({placeholder:"This is placeholder"}),Is,ms.Color,wo,mo];return d&&z.push(so),z},[d]),[p,g]=h.useState(e),b=()=>{t(p),o==null||o()},_=({editor:z})=>{const I=z.getHTML();g(I)},w=Ps.useEditor({extensions:u,content:e,onUpdate:_,onCreate:({editor:z})=>{z.view.dom.setAttribute("spellcheck","false"),z.view.dom.setAttribute("autocomplete","off"),z.view.dom.setAttribute("autocapitalize","off")}});h.useEffect(()=>{g(e),w==null||w.commands.setContent(e)},[e]);const x=e!==p,S=h.useMemo(()=>y.defaultsDeep({},{content:{...dr,...nh}},r),[r]);if(!w)return null;const D=!!l;return n.jsxs(s.Stack,{gap:4,sx:{flexGrow:1,position:"relative"},children:[n.jsxs(s.Group,{align:"center",children:[n.jsx(s.Text,{size:"14px",fw:500,children:a}),!D&&n.jsx(s.Button,{variant:"filled",color:"blue",size:"compact-xs",disabled:!x,onClick:b,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:c("common.actions.save_changes")})]}),n.jsxs(Q.RichTextEditor,{editor:w,styles:S,children:[n.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[n.jsx(th,{editor:w}),d&&n.jsx(Np,{editor:w}),n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(Xp,{editor:w})}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Bold,{}),n.jsx(Q.RichTextEditor.Italic,{}),n.jsx(Q.RichTextEditor.Underline,{}),n.jsx(Q.RichTextEditor.ClearFormatting,{}),n.jsx(Q.RichTextEditor.Highlight,{}),n.jsx(Q.RichTextEditor.Code,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.H1,{}),n.jsx(Q.RichTextEditor.H2,{}),n.jsx(Q.RichTextEditor.H3,{}),n.jsx(Q.RichTextEditor.H4,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Blockquote,{}),n.jsx(Q.RichTextEditor.Hr,{}),n.jsx(Q.RichTextEditor.BulletList,{}),n.jsx(Q.RichTextEditor.OrderedList,{}),n.jsx(Q.RichTextEditor.Subscript,{}),n.jsx(Q.RichTextEditor.Superscript,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.Link,{}),n.jsx(Q.RichTextEditor.Unlink,{})]}),n.jsxs(Q.RichTextEditor.ControlsGroup,{children:[n.jsx(Q.RichTextEditor.AlignLeft,{}),n.jsx(Q.RichTextEditor.AlignCenter,{}),n.jsx(Q.RichTextEditor.AlignJustify,{}),n.jsx(Q.RichTextEditor.AlignRight,{})]}),n.jsx(Q.RichTextEditor.ControlsGroup,{children:n.jsx(rh,{})}),n.jsx(Rp,{editor:w})]}),n.jsx(Q.RichTextEditor.Content,{})]}),D&&n.jsxs(s.Group,{justify:"space-between",pt:"md",children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:l,children:c("common.actions.cancel")}),n.jsx(s.Button,{variant:"filled",color:"blue",size:"xs",disabled:!x,onClick:b,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:c("common.actions.save_changes")})]})]})}),gt=({initialValue:e,onChange:t,label:r})=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Stack,{gap:4,children:[n.jsx(s.Text,{size:"sm",fw:"bold",children:r}),n.jsx(s.Button,{variant:"light",size:"xs",onClick:l,disabled:o,children:a("common.actions.edit_rich_text")})]}),n.jsx(s.Modal,{opened:o,onClose:i,withinPortal:!0,zIndex:400,closeOnEscape:!1,closeOnClickOutside:!1,withCloseButton:!1,size:800,children:o&&n.jsx(gn,{value:e,onChange:t,label:r??"",styles:{root:{flexGrow:1,minHeight:"400px"}},onCancel:i,onSubmit:i})})]})},Co={hex:/^#?([0-9A-F]{3}){1,2}$/i,fullHex:/^#?([0-9A-F]{6})$/i,hexa:/^#?([0-9A-F]{4}){1,2}$/i,rgb:/^rgb\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i,rgba:/^rgba\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i,hsl:/hsl\(\s*(\d+)\s*,\s*(\d+(?:\.\d+)?%)\s*,\s*(\d+(?:\.\d+)?%)\)/i,hsla:/^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*(\d*(?:\.\d+)?)\)$/i},ah=y.pick(Co,"fullHex","rgb","rgba","hsl","hsla"),sh=y.pick(Co,"fullHex","rgb","rgba","hsl","hsla");function oh(e){return Object.values(ah).some(t=>t.test(e))}function So(e){return Object.values(sh).some(t=>t.test(e))}function To(e){return So(e)?e:Ge.valid(e)?Ge(e).css():e}const ko=({value:e})=>So(e)?n.jsx(s.ColorSwatch,{ml:8,size:16,color:e}):n.jsx(s.ColorSwatch,{ml:8,size:16,color:""}),lh=({value:e,onChange:t,shouldPatch:r})=>{const{t:a}=m.useTranslation(),[o,l]=h.useState(e);h.useEffect(()=>{r&&l(e)},[e,r]);const i=h.useCallback(c=>{const d=c.currentTarget.value;l(d),oh(d)&&t(d)},[t]);return n.jsx(s.TextInput,{value:o,onChange:i,leftSection:n.jsx(ko,{value:o}),size:"xs",placeholder:a("chart.color.not_set"),styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center",textTransform:"uppercase"}}})},ih=["gray","red","grape","blue","cyan","green","yellow"],Do=({Trigger:e,value:t,onChange:r,clear:a})=>{const{t:o}=m.useTranslation(),l=s.useMantineTheme(),[i,{set:c,setFalse:d,toggle:u}]=O.useBoolean(),[p,g]=h.useState(!1),b=h.useMemo(()=>{const D=[];return ih.forEach(z=>{const I=l.colors[z];I&&I.forEach(A=>{D.push(A)})}),D},[l.colors]),_=(D,z=!0)=>{r(D),z&&d()},w=h.useCallback(D=>{_(D,!1),g(!1)},[]),x=h.useCallback(D=>{_(D,!1),g(!0)},[]),S=()=>{a(),d()};return n.jsxs(s.Popover,{opened:i,onChange:c,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[n.jsx(s.Popover.Target,{children:n.jsx(e,{onClick:u})}),n.jsx(s.Popover.Dropdown,{children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(lh,{value:t,onChange:w,shouldPatch:p}),n.jsx(s.ActionIcon,{variant:"default",onClick:S,title:o("common.actions.clear"),children:n.jsx(T.IconCircleOff,{stroke:1.5,size:"1rem"})}),n.jsx(s.ActionIcon,{variant:"default",onClick:d,title:o("common.actions.close"),children:n.jsx(T.IconX,{stroke:1.5,size:"1rem"})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.ColorPicker,{format:"hex",swatches:b,value:t,onChange:x,size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),n.jsx(s.ColorPicker,{format:"hex",fullWidth:!0,value:t,onChange:x})]})]})})]})},ch=({color:e,label:t})=>h.forwardRef(({onClick:r},a)=>n.jsx(s.Button,{ref:a,size:"sm",variant:"default",leftSection:n.jsx(ko,{value:e}),onClick:r,children:t})),ye=h.forwardRef(({value:e="",onChange:t,label:r},a)=>{const o=h.useCallback(()=>{t("")},[t]),l=h.useMemo(()=>To(e),[e]);return n.jsx(Do,{value:l,onChange:t,clear:o,Trigger:ch({color:l,label:r})})}),de={mantissa:2,output:"number",trimMantissa:!0,average:!1,absolute:!1},zo=()=>({mantissa:2,output:"number",trimMantissa:!0,average:!1,absolute:!1});function Y(e,{absolute:t,...r}){if(e===null)return String(e);try{let a=Ee(e).value();if(a===void 0||Number.isNaN(a))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(a=Math.abs(a)),Ee(a).format(r)}catch(a){return console.debug(a),String(e)}}function dh(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function He({data_field:e,aggregation:t},r){return cr(r,e,t)}function Be({formatter:e,aggregation:t},r){if(typeof r!="string"&&typeof r!="number")return dh(r);if(t.type==="custom")return r;try{return Y(r,e)}catch(a){return console.error(a),r}}function At(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...a)=>{const o=a[2],l=t.variableStyleMap[o];if(!l)return`{{${o}}}`;const{variable:i,...c}=l,d=Object.entries(c).map(([b,_])=>`${b}:${_}`).join(";"),u=i.color;if(u.type!=="continuous")return`<span style="${d}">{{${o}}}</span>`;const p=vo(6),g=`try {
|
|
52
52
|
return utils.popmotion.interpolate(${JSON.stringify(u.valueRange)}, ${JSON.stringify(u.colorRange)})(variables["${o}"]);
|
|
53
53
|
} catch (error) {
|
|
54
54
|
console.error(error);
|
|
55
55
|
return "black";
|
|
56
|
-
}`;return`<span style="${d}"><dynamic-color id="${p}" data-value='${g}'>{{${o}}}</dynamic-color></span>`})}function uh(e,t){const{data_field:r,aggregation:a}=e,o=
|
|
56
|
+
}`;return`<span style="${d}"><dynamic-color id="${p}" data-value='${g}'>{{${o}}}</dynamic-color></span>`})}function uh(e,t){const{data_field:r,aggregation:a}=e,o=cr(t,r,a);return Be(e,o)}function Mo(e,t){const r={};return e.forEach(a=>{r[a.name]=uh(a,t)}),r}function Kt(e,t,r){const a=Mo(t,r),o=/^\{(.+)\}(.*)$/;return e.split("$").map(l=>{const i=o.exec(l);if(!i)return l;const c=a[i[1]];if(!c)return l;const d=i[2]??"";return`${c}${d}`}).join("")}function*ph(e){const t=Ue.graphics[e];if(!t)throw new Error("Invalid palette key provided");const r=Object.values(t);let a=0;for(;;)yield r[a%r.length],a++}function vr(){return{filters:{},context:{}}}function _r(e){const t=vr();if(!e)return vr();const{filters:r=t.filters,context:a=t.context}=e;return{filters:r,context:a}}class ne extends h.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return n.jsxs(s.Box,{children:[n.jsx(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n.jsx(s.Button,{variant:"subtle",mx:"auto",size:"compact-xs",sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}function Io(e,t={handleError:!0}){return r=>n.jsx(ne,{...t,children:n.jsx(e,{...r})})}function hh(e,t){return new Function(`return ${e}`)()(t,We)}function gh(e,t,r){return hh(e,{context:t,filters:r})}function fn(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,We)}catch(r){return console.error(r),t}}function bn(e,t){return new Function(`return ${e.config.processing.post}`)()(t,We)}function Vo(e,t,r){return e?new Function(`return ${e}`)()(t,We,r):t}function Po(){vs.use([Xd.CanvasRenderer,Ze.BarChart,Ze.BoxplotChart,Ze.CustomChart,Ze.FunnelChart,Ze.HeatmapChart,Ze.LineChart,Ze.PieChart,Ze.RadarChart,Ze.ScatterChart,Ze.SunburstChart,ut.CalendarComponent,ut.DataZoomComponent,ut.GridComponent,ut.LegendComponent,ut.TooltipComponent,ut.MarkLineComponent,ut.MarkAreaComponent,ut.VisualMapComponent])}const at=e=>y.cloneDeepWith(e,(t,r)=>{if(r!==void 0&&t)return G.toJS(t)});function mr(e,t){const r=Object.keys(t),a=Object.values(t);try{return new Function(...r,`return \`${e}\`;`)(...a)}catch(o){throw r.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):o}}function wr(e,t){try{return mr(e,t)}catch(r){return console.error(r),r.message}}function fh({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},We)}catch(r){throw console.error(r),r}}function bh(e,t,r){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,We,r)}catch(a){throw console.error(a),a}}const Et={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function yh(e,t){const r={};return e.forEach(a=>{const{name:o,data_field:l,aggregation:i}=a,c=cr(t,l,i);r[o]=Be(a,c)}),r}function vh(e){const t=document.createElement("span");return t.innerHTML=e,t.innerText}function _h(e,t,r){try{return new Function("payload",`
|
|
57
57
|
const filters = payload.filters;
|
|
58
58
|
const context = payload.context;
|
|
59
59
|
${Object.entries(t).map(([a,o])=>`const ${a} = '${o}';`).join(`
|
|
60
60
|
`)}
|
|
61
61
|
return ${e};
|
|
62
|
-
`)(r)}catch(a){return console.error(a),console.log(e),e}}function ft(e,t,r,a){const o=yh(t,a);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...i)=>{const c=i[2];if(!c)return c;const d=o[c];if(d)return d;const u=vh(c);return _h(u,o,r)})}function fe(e,t){e.messageChannels.getChannel("viz").emit("rendered",t)}function mh(e,t){return e.messageChannels.getChannel("viz").on("rendered",t),()=>{e.messageChannels.getChannel("viz").off("rendered",t)}}function $o(e,t,r){const a=H();function o(l){const i=ft(e.top,t.variables,a.payloadForViz,t.data),c=ft(e.bottom,t.variables,a.payloadForViz,t.data);fe(r,{...l,statsAboveViz:i,statsBelowViz:c})}return o}const we={top:16,right:16,bottom:16,left:16},qe=e=>Math.max(0,e-we.left-we.right),Oe=e=>Math.max(0,e-we.top-we.bottom),Yt=(e,t)=>({width:qe(e),height:Oe(t)}),ve=({width:e,height:t,children:r})=>n.jsx(s.Box,{pt:we.top,pr:we.right,pb:we.bottom,pl:we.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),
|
|
62
|
+
`)(r)}catch(a){return console.error(a),console.log(e),e}}function ft(e,t,r,a){const o=yh(t,a);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...i)=>{const c=i[2];if(!c)return c;const d=o[c];if(d)return d;const u=vh(c);return _h(u,o,r)})}function fe(e,t){e.messageChannels.getChannel("viz").emit("rendered",t)}function mh(e,t){return e.messageChannels.getChannel("viz").on("rendered",t),()=>{e.messageChannels.getChannel("viz").off("rendered",t)}}function $o(e,t,r){const a=H();function o(l){const i=ft(e.top,t.variables,a.payloadForViz,t.data),c=ft(e.bottom,t.variables,a.payloadForViz,t.data);fe(r,{...l,statsAboveViz:i,statsBelowViz:c})}return o}const we={top:16,right:16,bottom:16,left:16},qe=e=>Math.max(0,e-we.left-we.right),Oe=e=>Math.max(0,e-we.top-we.bottom),Yt=(e,t)=>({width:qe(e),height:Oe(t)}),ve=({width:e,height:t,children:r})=>n.jsx(s.Box,{pt:we.top,pr:we.right,pb:we.bottom,pl:we.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),xr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function wh({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),a=e.data,{width:o,height:l}=e.viewport,{x_axis_data_key:i,y_axis_data_key:c,z_axis_data_key:d,xAxis3D:u,yAxis3D:p,zAxis3D:g}=y.defaults({},r,xr),b=h.useMemo(()=>dn(a,i),[a,i]),{x:_,y:w,z:x}=h.useMemo(()=>({x:$(i),y:$(c),z:$(d)}),[i,c,d]),{min:S,max:D}=h.useMemo(()=>{const E=y.minBy(b,N=>N[x.columnKey]),U=y.maxBy(b,N=>N[x.columnKey]);return{min:y.get(E,x.columnKey),max:y.get(U,x.columnKey)}},[b,x]),z=h.useRef(null),I=h.useMemo(()=>({finished:()=>{var U;const E=(U=z.current)==null?void 0:U.getEchartsInstance();E&&fe(t,E.getOption())}}),[]),A={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:S,max:D,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:p,zAxis3D:g,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:b.map(E=>[E[_.columnKey],E[w.columnKey],E[x.columnKey]])}]};return r?n.jsx(ve,{width:o,height:l,children:n.jsx(he,{echarts:ce,ref:z,option:A,style:Yt(o,l),notMerge:!0,onEvents:I,theme:"merico-light"})}):null}const L=k.observer(h.forwardRef(({label:e,required:t,description:r,value:a,onChange:o,queryID:l,clearable:i=!1,unsetKey:c="data.data_field.selector.options.unset",sx:d,additional_options:u=[],...p},g)=>{const{t:b}=m.useTranslation(),{panel:_}=ae(),w=h.useMemo(()=>_.dataFieldOptionGroups({selected:a,clearable:i,unsetKey:c,queryID:l,additional_options:u}).map(x=>({...x,items:x.items.map(S=>({...S,label:b(S.label)}))})),[a,i,l,u,b]);if(w.length===0){const x=_.explainDataKey(a);return n.jsxs(s.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Box,{children:n.jsx(s.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsxs(s.Group,{justify:"flex-start",gap:0,children:[n.jsx(s.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),n.jsx(s.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(s.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return n.jsx(s.Select,{ref:g,label:e,description:r,data:w,value:a,onChange:Z(o),required:t,sx:d,maxDropdownHeight:500,...p})}));function xh({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=y.defaults({},t,xr),{control:o,handleSubmit:l,reset:i}=v.useForm({defaultValues:a});return h.useEffect(()=>{i(a)},[t]),t?n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:l(r),children:[n.jsx(s.Text,{size:"sm",children:"X Axis"}),n.jsxs(s.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(v.Controller,{name:"x_axis_data_key",control:o,render:({field:c})=>n.jsx(L,{label:"Data Field",required:!0,...c})}),n.jsx(v.Controller,{name:"xAxis3D.name",control:o,render:({field:c})=>n.jsx(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(s.Text,{mt:"lg",size:"sm",children:"Y Axis"}),n.jsxs(s.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(v.Controller,{name:"y_axis_data_key",control:o,render:({field:c})=>n.jsx(L,{label:"Data Field",required:!0,...c})}),n.jsx(v.Controller,{name:"yAxis3D.name",control:o,render:({field:c})=>n.jsx(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(s.Text,{mt:"lg",size:"sm",children:"Z Axis"}),n.jsxs(s.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(v.Controller,{name:"z_axis_data_key",control:o,render:({field:c})=>n.jsx(L,{label:"Data Field",required:!0,...c})}),n.jsx(v.Controller,{name:"zAxis3D.name",control:o,render:({field:c})=>n.jsx(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(s.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:n.jsxs(s.Button,{color:"blue",type:"submit",children:[n.jsx(T.IconDeviceFloppy,{size:20}),n.jsx(s.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const Ch=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Sh(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:i,...c}=e;return{...c,x_axis_data_key:a(o),y_axis_data_key:a(l),z_axis_data_key:a(i)}}catch(r){throw console.error("[Migration failed]",r),r}}class Th extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>{const{config:o}=r;return{...r,version:2,config:Sh(o,a)}})}}const kh={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Th,name:"bar-3d",viewRender:wh,configRender:xh,createConfig(){return{version:2,config:y.cloneDeep(xr)}},translation:Ch},Dh=({disabled:e,value:t,onChange:r})=>{const a=o=>{o&&r(o)};return n.jsxs(s.Box,{sx:{position:"relative"},children:[e&&n.jsx(s.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:t,onChange:a,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Me({enabled:e,func_content:t}){return(r,a)=>{if(!e)return r;try{return new Function(`return ${t}`)()(r,a)}catch(o){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${o.message}`),r}}}function _e(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
63
63
|
`)}}const Re=h.forwardRef(({value:e,onChange:t,triggerButtonText:r},a)=>{const{t:o}=m.useTranslation(),[l,{setTrue:i,setFalse:c}]=O.useBoolean(),[d,u]=h.useState(e);h.useEffect(()=>{u(e)},[e]);const p=S=>{u({...d,enabled:S})},g=()=>{c();const{enabled:S,func_content:D}=d,z={enabled:S,func_content:D};u(z),t(z)},b=()=>{c(),u(e)},_=S=>{u(D=>({...D,func_content:S}))},w=()=>{_(_e().func_content)},x=r??o("chart.axis.customize_label");return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"filled",color:"grape",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:x}),n.jsx(s.Modal,{size:800,title:x,opened:l,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:l&&n.jsxs(s.Stack,{children:[n.jsx(s.Checkbox,{mt:10,label:o("common.enabled"),checked:d.enabled,onChange:S=>p(S.currentTarget.checked)}),n.jsx(Dh,{value:d.func_content,onChange:_,disabled:!d.enabled}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:w,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:o("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:b,variant:"subtle",children:o("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:g,children:o("common.actions.save")})]})]})]})})]})}),kt={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Ao(){return y.cloneDeep(kt)}const zh=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Eo={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:Ih,configRender:Mh,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Mh(e){return n.jsx(n.Fragment,{})}function Ih(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.boxplot.click_series.label")})}const yn=h.forwardRef(({sectionTitle:e,value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=d=>u=>{const p=y.cloneDeep(t);y.set(p,d,u),r(p)},c=h.useMemo(()=>[{label:o("chart.axis.overflow.truncate"),value:"truncate"},{label:o("chart.axis.overflow.break_line"),value:"break"},{label:o("chart.axis.overflow.break_word"),value:"breakAll"}],[l.language]);return n.jsxs(s.Stack,{gap:0,children:[e&&n.jsx(s.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",styles:{label:{color:"dimmed"}}}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.NumberInput,{label:o("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:i("width")}),n.jsx(s.Select,{label:o("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:i("overflow")}),n.jsx(s.TextInput,{label:o("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),et=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=i=>{t({...e,on_axis:i})},l=i=>{t({...e,in_tooltip:i})};return n.jsxs(s.Stack,{ref:r,gap:0,children:[n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:o}),n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:l})]})});function Ie(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function Le({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],a=e==="truncate"?"nowrap":"initial",o={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
64
64
|
max-width: ${t}px;
|
|
65
65
|
word-break: ${r};
|
|
66
66
|
white-space: ${a};
|
|
67
67
|
overflow: hidden;
|
|
68
68
|
text-overflow: ${o};
|
|
69
|
-
`}function Ke(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}const ue=h.forwardRef(({value:e,onChange:t,hiddenFileds:r},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>new Set(r??[]),[r]),i=c=>d=>{t({...e,[c]:d})};return n.jsxs(s.Stack,{ref:a,gap:"sm",children:[n.jsx(s.Divider,{mb:-10,label:o("chart.unit.title"),labelPosition:"center",variant:"dashed"}),!l.has("text")&&n.jsx(s.TextInput,{size:"xs",placeholder:o("chart.unit.text.placeholder"),value:e.text,onChange:c=>i("text")(c.currentTarget.value)}),n.jsxs(s.Group,{grow:!0,children:[!l.has("show_in_tooltip")&&n.jsx(s.Checkbox,{size:"xs",label:o("chart.unit.show_in_tooltip"),checked:e.show_in_tooltip,onChange:c=>i("show_in_tooltip")(c.currentTarget.checked)}),!l.has("show_in_legend")&&n.jsx(s.Checkbox,{size:"xs",label:o("chart.unit.show_in_legend"),checked:e.show_in_legend,onChange:c=>i("show_in_legend")(c.currentTarget.checked)})]})]})});function K(){return{text:"",show_in_tooltip:!1,show_in_legend:!1}}const xr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:de,unit:K()},tooltip:{metrics:[]},color:"rgba(99, 152, 199, 0.10)",reference_lines:[],legend:{show:!0,top:"10",right:"0",left:"auto",bottom:"auto",orient:"vertical",type:"scroll"},dataZoom:Ao()};function Dt(e,t){return h.useMemo(()=>{const{queryID:r,columnKey:a}=$(t);return y.keyBy(e[r],a)},[e,t])}const Ve=(e,t)=>{const[r,a]=h.useState([]);return h.useEffect(()=>e.watchTriggerSnapshotList(o=>a(o.filter(l=>l.schemaRef===t))),[]),r},Cr=h.createContext(null);function vn(e){const t=h.useContext(Cr),r=O.useCreation(()=>e.configure(t||new Yn),[e.configure]),a=O.usePrevious(r);return a&&a!==r&&a.dispose(),n.jsx(Cr.Provider,{value:r,children:e.children})}function Xt(){return h.useContext(Cr)}const Pe=({})=>Xt().getRequired(ee.instanceScope.interactionManager),Bo=e=>{const{t}=m.useTranslation(),{title:r="Variables",variables:a}=e,o=te.useClipboard(),l=i=>{o.copy(i),Fe.showNotification({color:"green",message:t("common.copied")})};return n.jsxs(s.Paper,{withBorder:!0,p:"sm",children:[n.jsx(s.Text,{size:"xs",c:"dimmed",mb:"sm",children:r}),n.jsx(s.Stack,{style:{maxHeight:"500px"},children:a.map(i=>n.jsxs(s.Text,{size:"sm",children:[n.jsxs(s.Code,{color:"teal",children:["// ",i.description]}),n.jsx("br",{}),n.jsxs(s.Code,{onClick:()=>l(i.name),style:{cursor:"pointer"},children:[i.name," : ",i.valueType]})]},i.name))})]})};class Vh{constructor(t,r){V(this,"operationId");V(this,"operation");V(this,"operationSchema");V(this,"variables",[]);this.operationManager=t,this.instance=r,G.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,r){const a=await this.operationManager.retrieveTrigger(t),o=this.operationManager.getOperationSchemaList().find(l=>l.id===(a==null?void 0:a.schemaRef));G.runInAction(()=>{this.operationId=t,this.operation=a,this.operationSchema=o,this.variables=r})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function Ph(e){return!!e.operationId}const $h=k.observer(({model:e,onClick:t})=>{var o;const{t:r}=m.useTranslation(),a=(o=e.operationSchema)==null?void 0:o.displayName;return n.jsx(s.Button,{variant:"outline",onClick:t,children:r(a)})}),qo=k.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return h.createElement(e.operationSchema.configRender,t)}),Ah=k.observer(({model:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.schemaList,o=h.useMemo(()=>a.map(i=>({label:t(i.displayName),value:i.id})),[a,r.language]);async function l(i){await e.changeSchema(a.find(c=>c.id===i))}return n.jsx(s.Select,{label:t("interactions.operation.label"),data:o,onChange:Z(l),value:e.operationSchema.id,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})}),Eh=k.observer(e=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),{operationManager:l,operationId:i,instance:c,variables:d}=e,u=O.useCreation(()=>new Vh(l,c),[l,c]);return O.useAsyncEffect(async()=>{await u.configOperation(i,d)},[i,u]),Ph(u)?n.jsxs(n.Fragment,{children:[n.jsx($h,{model:u,onClick:a}),n.jsx(s.Modal,{size:600,opened:r,onClose:o,title:t("interactions.operation.setup"),zIndex:320,children:n.jsxs(s.Stack,{children:[n.jsx(Ah,{model:u}),u.variables.length>0?n.jsxs(s.Tabs,{defaultValue:"settings",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"settings",children:t("interactions.operation.settings")}),n.jsx(s.Tabs.Tab,{value:"variables",children:t("interactions.operation.variables")})]}),n.jsx(s.Tabs.Panel,{value:"settings",pt:10,children:n.jsx(qo,{model:u})}),n.jsx(s.Tabs.Panel,{value:"variables",pt:10,children:n.jsx(Bo,{title:t("interactions.operation.variables"),variables:u.variables})})]}):n.jsx(qo,{model:u})]})})]}):null});class Bh{constructor(t,r){V(this,"triggerId");V(this,"trigger");V(this,"triggerSchema");V(this,"sampleData");this.triggerManager=t,this.instance=r,G.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,r){const a=await this.triggerManager.retrieveTrigger(t),o=this.triggerManager.getTriggerSchemaList().find(l=>l.id===(a==null?void 0:a.schemaRef));G.runInAction(()=>{this.triggerId=t,this.trigger=a,this.triggerSchema=o,this.sampleData=r})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return qh(this)}}function qh(e){return!!e.triggerId&&!!e.triggerSchema}function Oh(e,t){return O.useCreation(()=>new Bh(e,t),[e,t])}const Lh=k.observer(({model:e,onClick:t})=>{const r=e.triggerSchema.nameRender,a={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return n.jsx(s.Button,{variant:"outline",onClick:t,children:h.createElement(r,a)})}),Nh=k.observer(({model:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.schemaList,o=h.useMemo(()=>a.map(i=>({label:t(i.displayName),value:i.id})),[a,r.language]);async function l(i){await e.changeSchema(a.find(c=>c.id===i))}return n.jsx(s.Select,{label:t("interactions.trigger.label"),data:o,value:e.triggerSchema.id,onChange:Z(l)})}),Gh=k.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return h.createElement(e.triggerSchema.configRender,t)}),Fh=k.observer(e=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),l=e.model;return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:r,onClose:o,title:t("interactions.trigger.setup"),zIndex:320,children:n.jsxs(s.Stack,{children:[n.jsx(Nh,{model:l}),n.jsx(Gh,{model:l}),n.jsx(Bo,{title:t("interactions.trigger.payload"),variables:l.triggerSchema.payload})]})}),n.jsx(Lh,{onClick:a,model:l})]})});class Bt{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const a=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...a,[t]:r})}return await this.getItem(t)}watchItem(t,r,a){return t===null?this.root.watchItem(this.path,(o,l)=>{r(o,l)},a):this.root.watchItem(this.path,(o,l)=>{const i=y.get(o,t),c=y.get(l,t);i!==c&&r(i,c)},a)}}const Qh={"builtin:op:debug":1,"builtin:op:clear_filter_values":2,"builtin:op:set_filter_values":3,"builtin:op:open_view":4,"builtin:op:open-link":5,"builtin:op:switch_tab":6,"builtin:op:scroll_to_panel":7};class Sr{constructor(t,r,a){V(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=a,this.attachmentStorage=new Bt(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new Bt(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new Bt(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null),r=y.orderBy(y.values(t),a=>Qh[a.schemaRef]??10);return Promise.all(r.map(a=>this.constructInstance(new Bt(this.attachmentStorage,a.id))))}}function jh(e,t){const{value:r,set:a}=q(e.operation.operationData,"config"),[o,l]=h.useState(y.defaults({},r,t)),i=async()=>{await a(o)};return h.useEffect(()=>{l(y.defaults({},r,t))},[r]),{config:o,setConfig:l,commit:i}}function Wh(e){const{t}=m.useTranslation(),{config:r,setConfig:a,commit:o}=jh(e,{urlTemplate:"",openInNewTab:!0});async function l(){await o()}async function i(d){a({...r,openInNewTab:d}),await o()}const c=d=>a({...r,urlTemplate:d.currentTarget.value});return n.jsxs(s.Stack,{children:[n.jsx(s.TextInput,{label:t("interactions.operation.open_link.url"),value:r.urlTemplate,onChange:c,onBlur:l}),n.jsx(s.Switch,{label:t("interactions.operation.open_link.open_in_new_tab"),checked:r.openInNewTab,onChange:d=>i(d.currentTarget.checked)})]})}async function Uh(e,t){const{urlTemplate:r,openInNewTab:a}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:r,openInNewTab:a,payload:e}}))}class Kh extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>r)}}const Yh={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:Wh,run:Uh,migrator:new Kh,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Xh(e){const{value:t,set:r}=q(e.operationData,"config"),a=o=>void r({template:o});return[(t==null?void 0:t.template)||"",a]}function Zh(e){const{t}=m.useTranslation(),[r,a]=Xh(e.operation);return n.jsx(s.TextInput,{defaultValue:r,onBlur:o=>a(o.currentTarget.value),label:t("interactions.operation.console_log.log_content")})}async function Jh(e,t){const r=await t.operationData.getItem("config"),a=y.template(r.template||"");console.log("run with payload",e),console.log(a(e))}const Hh={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:Zh,run:Jh},Rh=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),l=(a==null?void 0:a.viewID)||"",i=c=>void o({viewID:c});return n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(i),label:t("interactions.operation.open_view.view"),data:r.views.options,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})});async function eg(e,t){const a=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:a}}))}const tg={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:Rh,run:eg},ng={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},rg=({value:e="",onChange:t})=>{const[r,a]=h.useState(e);h.useEffect(()=>{a(e)},[e]);const o=()=>{t(r)};return n.jsx(s.TextInput,{size:"xs",label:"",value:r,onChange:l=>a(l.currentTarget.value),sx:{flexGrow:1},rightSection:n.jsx(s.ActionIcon,{color:"green",size:"xs",onClick:o,disabled:r===e,children:n.jsx(T.IconDeviceFloppy,{})})})},ag={dictionary:{}},sg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a=ag,set:o}=q(e.operation.operationData,"config"),{dictionary:l={}}=a;console.log({value:{...a},dictionary:{...l},filters:[...r.filters.keyLabelOptions]});const i=(c,d)=>{if(d===""){const u={...l};delete u[c],o({dictionary:u});return}o({dictionary:{...l,[c]:d}})};return n.jsxs(s.Table,{sx:ng,children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:t("interactions.operation.set_filter_values.set_filter")}),n.jsx(s.Table.Th,{children:t("interactions.operation.set_filter_values.with")})]})}),n.jsx(s.Table.Tbody,{children:[...r.filters.keyLabelOptions].map(c=>{const d=c.value in l;return n.jsxs(s.Table.Tr,{"data-affected":d,children:[n.jsx(s.Table.Td,{children:c.label}),n.jsx(s.Table.Td,{children:n.jsx(rg,{value:l[c.value],onChange:u=>i(c.value,u)})})]},c.value)})})]})});async function og(e,t){const a=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:a,payload:e}}))}const lg={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:sg,run:og},ig={filter_keys:[]},cg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a=ig,set:o}=q(e.operation.operationData,"config"),{filter_keys:l=[]}=a,i=d=>{o({filter_keys:[...d]})},c=h.useMemo(()=>r.filters.current.map(d=>({label:d.label,value:d.key})),[r.filters.values]);return n.jsx(s.Stack,{gap:10,children:n.jsx(s.MultiSelect,{label:t("interactions.operation.clear_filter_values.select_filter"),data:c,value:l,onChange:i})})});async function dg(e,t){const a=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:a,payload:e}}))}const ug={displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:cg,run:dg},pg=({option:e,checked:t})=>{var o;const{t:r}=m.useTranslation(),a=e;return n.jsxs(s.Group,{justify:"space-between",flex:"1",gap:"xs",children:[n.jsx(s.Text,{size:"xs",children:a.label}),n.jsx(s.Text,{size:"xs",children:r((o=ei[a.viz_type])==null?void 0:o.displayName)??a.viz_type})]})},hg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),l=(a==null?void 0:a.panelID)||"",i=c=>void o({panelID:c});return n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(i),label:t("interactions.operation.scroll_to_panel.panel"),data:r.panels.options,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500,renderOption:pg})});async function gg(e,t){const a=(await t.operationData.getItem("config")).panelID;window.dispatchEvent(new CustomEvent("scroll_to_panel",{detail:{panelID:a}}))}const fg={displayName:"interactions.operation.scroll_to_panel.label",id:"builtin:op:scroll_to_panel",configRender:hg,run:gg},bg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),{viewID:l="",tab:i=""}=a??{},c=u=>void o({viewID:u,tab:i}),d=u=>void o({viewID:l,tab:u});return n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(c),label:t("interactions.operation.switch_tab.view"),data:r.views.tabViewOptions,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500}),n.jsx(s.Select,{defaultValue:i,value:i,onChange:Z(d),label:t("interactions.operation.switch_tab.tab"),data:r.views.tabOptions(l),comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})]})});async function yg(e,t){const r=await t.operationData.getItem("config"),{viewID:a,tab:o}=r;window.dispatchEvent(new CustomEvent("switch_tab",{detail:{viewID:a,tab:o}}))}const Tr=[Hh,Yh,tg,fg,lg,{displayName:"interactions.operation.switch_tab.label",id:"builtin:op:switch_tab",configRender:bg,run:yg},ug];class vg{constructor(t,r=Tr){V(this,"attachments");this.operations=r;const a=async o=>{const{id:l,schemaRef:i}=await o.getItem(null);return{id:l,schemaRef:i,operationData:new Bt(o,"data")}};this.attachments=new Sr(t,"__OPERATIONS",a)}async runOperation(t,r){const a=await this.attachments.getInstance(t);if(!a){console.warn(`Operation '${t}' is not defined`);return}const o=this.tryGetSchema(a.schemaRef);if(!o){console.warn(`Operation schema '${a.schemaRef}' is not defined`);return}await o.run(r,a)}tryGetSchema(t){return this.operations.find(r=>r.id===t)}async needMigration(){const r=(await this.attachments.list()).map(async a=>{const o={configData:a.operationData},l=this.tryGetSchema(a.schemaRef),i=l==null?void 0:l.migrator;return i&&await i.needMigration(o)});return(await Promise.all(r)).some(a=>a)}async runMigration(){const r=(await this.attachments.list()).map(async a=>{const o={configData:a.operationData},l=this.tryGetSchema(a.schemaRef),i=l==null?void 0:l.migrator;i&&await i.needMigration(o)&&await i.migrate(o)});await Promise.all(r)}async createOrGetOperation(t,r){var i;if(!this.getOperationSchemaList().some(c=>c.id===r.id))throw new Error(`Operation schema '${r.id}' is not defined`);const o=await this.attachments.getInstance(t);return!o||o.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((i=r.createDefaultConfig)==null?void 0:i.call(r))??{}}):o}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Oo="__TRIGGERS";class _g{constructor(t,r){V(this,"attachments");this.instance=t,this.component=r;const a=async o=>{const{id:l,schemaRef:i}=await o.getItem(null);return{id:l,schemaRef:i,triggerData:new Bt(o,"data")}};this.attachments=new Sr(t,Oo,a)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Oo,r=>{const a=y.values(r).map(o=>({id:y.get(o,"id"),schemaRef:y.get(o,"schemaRef"),config:G.toJS(y.get(o,"data.config"))}));t(a)},{fireImmediately:!0})}async createOrGetTrigger(t,r,a={recreate:!1}){var c;if(!this.getTriggerSchemaList().some(d=>d.id===r.id))throw new Error(`Trigger schema '${r.id}' is not defined in component '${this.component.name}'`);const l=await this.attachments.getInstance(t);return!l||a.recreate||l.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((c=r==null?void 0:r.createDefaultConfig)==null?void 0:c.call(r))||{}}):l}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const r=(await this.getTriggerList()).map(async a=>{const o=this.getTriggerSchemaList().find(c=>c.id===a.schemaRef),l=o==null?void 0:o.migrator,i={configData:a.triggerData};return l&&await l.needMigration(i)?()=>l.migrate(i):null});return Promise.all(r).then(a=>a.filter(o=>o))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(r=>r()))}}class Lo{constructor(t,r,a){V(this,"operationManager");V(this,"triggerManager");V(this,"attachments");this.operationManager=new vg(t,a),this.triggerManager=new _g(t,r);const o=async l=>{const{id:i,triggerRef:c,operationRef:d}=await l.getItem(null);return{id:i,triggerRef:c,operationRef:d}};this.attachments=new Sr(t,"__INTERACTIONS",o)}async addInteraction(t,r){const a=t.id,o=r.id,l=`[${a}]:[${o}]`;await this.attachments.create(l,{id:l,triggerRef:a,operationRef:o})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const r=await this.attachments.getInstance(t);if(!r)return;const{triggerRef:a,operationRef:o}=r;await this.getTriggerRefCount(a)<=1&&await this.triggerManager.removeTrigger(a),await this.getOperationRefCount(o)<=1&&await this.operationManager.removeOperation(o),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(a=>a.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(a=>a.triggerRef===t).length}async runInteraction(t,r){const o=(await this.getInteractionList()).filter(l=>l.triggerRef===t);for(let l of o)try{await this.operationManager.runOperation(l.operationRef,r)}catch(i){console.warn(`Failed to run operation '${l.operationRef}'`,i)}}}function mg(e,t){const[r,a]=h.useState([]);return O.useAsyncEffect(async()=>{const o=await e.getInteractionList();a(o)},[t,e]),r}const wg=k.observer(({item:e,manager:t,instance:r,sampleData:a,variables:o,onRemove:l})=>{const{triggerRef:i,operationRef:c}=e,d=Oh(t.triggerManager,r);if(O.useAsyncEffect(async()=>{await d.configTrigger(i,a)},[d,i,a]),d.isReady()){const u=[...d.triggerSchema.payload,...o];return n.jsxs(s.Group,{children:[n.jsx(Fh,{model:d}),n.jsx(Eh,{instance:r,operationId:c,variables:u,operationManager:t.operationManager}),n.jsx(s.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>l(e),children:n.jsx(T.IconTrash,{size:16})})]})}return null}),xg=e=>{const{t}=m.useTranslation(),[r,a]=h.useState(0),{interactionManager:o,instance:l,sampleData:i,variables:c}=e,d=mg(o,r),u=async()=>{const _=await o.triggerManager.createOrGetTrigger(te.randomId(),o.triggerManager.getTriggerSchemaList()[0]),w=await o.operationManager.createOrGetOperation(te.randomId(),o.operationManager.getOperationSchemaList()[0]);await o.addInteraction(_,w),a(x=>x+1)};async function p(_){await o.removeInteraction(_.id),a(w=>w+1)}const{data:g=0,loading:b}=O.useRequest(async()=>{try{return(await o.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return n.jsxs(s.Stack,{children:[n.jsx(s.LoadingOverlay,{visible:b}),g===0&&n.jsx(s.Alert,{icon:n.jsx(T.IconAlertCircle,{size:16}),title:t("interactions.unavailable"),color:"gray",children:t("interactions.unavailable_reason")}),d.map(_=>n.jsx(wg,{onRemove:p,instance:l,sampleData:i,variables:c,item:_,manager:e.interactionManager},_.id)),n.jsx(s.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:g===0,children:t("interactions.add")})]})},Cg=()=>{const{panel:e,data:t}=re(),r=e.viz,{vizManager:a}=h.useContext(ot),o=e.json,l=O.useCreation(()=>a.getOrCreateInstance(o),[a,o]),i=O.useCreation(()=>new Lo(l,a.resolveComponent(r.type),Tr),[l,r.type]);return h.useEffect(()=>l.instanceData.watchItem(null,y.throttle(c=>{e.viz.setConf(c)},100,{leading:!1,trailing:!0})),[l]),{instance:l,vizManager:a,interactionManager:i,sampleData:t,variables:[]}},Sg=()=>{const e=Cg();return n.jsx(xg,{...e})},No={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function Tg(e){return y.defaultsDeep({},e,No)}const kg=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:Tg,xAxis:No},Symbol.toStringTag,{value:"Module"})),Go={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function Dg(e){return y.defaultsDeep({},e,Go)}const zg=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:Dg,yAxis:Go},Symbol.toStringTag,{value:"Module"})),Fo={confine:!0,appendToBody:!0};function Mg(e){return y.defaultsDeep({},e,Fo)}const X={...kg,...zg,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:Mg,tooltip:Fo},Symbol.toStringTag,{value:"Module"}))};function Ig(e,t){const r=[],a=[];return{boxplotData:Object.entries(e).map(([l,i])=>{const c=i.map(D=>D[t]).sort((D,z)=>D-z),d=jt.quantile(c,.25)??0,u=jt.quantile(c,.5)??0,p=jt.quantile(c,.75)??0,g=p-d,b=d-1.5*g,_=p+1.5*g,w=Math.max(c[0],b),x=Math.min(y.last(c)??0,_);return i.filter(D=>{const z=D[t];return z<w||z>x}).forEach(D=>r.push([l,D[t],D])),i.filter(D=>{const z=D[t];return z>=w&&z<=x}).forEach(D=>a.push([l,D[t],D])),{name:l,min:w,q1:d,median:u,q3:p,max:x}}),outliersData:r,scatterData:a}}function Vg(e,t){const{x_axis:r,y_axis:a}=e;if(!r.data_key||!a.data_key)return[];const o=$(r.data_key),l=$(a.data_key);if(o.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const i=y.groupBy(t[o.queryID],o.columnKey),{boxplotData:c,outliersData:d,scatterData:u}=Ig(i,l.columnKey);return[{source:c},{source:d},{source:u}]}function Pg(e){const t={top:35,left:20,right:15,bottom:25,containLabel:!0};return e.legend.orient==="vertical"&&(t.right=80),e.dataZoom.x_axis_slider&&(t.top=50),t}function $g({config:e,seriesNames:t}){const r={...e.legend,data:[{name:t.Box,icon:"roundRect",itemStyle:{color:e.color}},{name:t.Scatter,icon:"circle",itemStyle:{color:"#ED6A45",opacity:.5}},{name:t.Outlier,icon:"circle",itemStyle:{color:"#ED6A45"}}]};return e.legend.orient==="horizontal"&&e.dataZoom.x_axis_slider&&(r.top=15),r}function Ag(e,t,r){const a=t.reduce((o,l)=>{const i=He(l,r);return o[l.name]=Be(l,i),o},{});return e.map(o=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:o.name,yAxis:Number(a[o.variable_key])}],silent:!0,symbol:["none","triangle"],symbolRotate:90,symbolSize:[10,8],label:{formatter:function(){return Kt(o.template,t,r)},position:"insideEndTop"}}}))}const kr=["max","q3","median","q1","min"],Dr=[10,40];function zr(e){return e.barLayout({barMinWidth:Dr[0],barMaxWidth:Dr[1],count:2})}function Eg(e,t,r){const{itemStyle:{color:a,borderColor:o,borderWidth:l}}=r,i=zr(t),c=t.value(0),d=e.source[c],{min:u,q1:p,median:g,q3:b,max:_}=d,w={min:t.coord([c,u]),q1:t.coord([c,p]),median:t.coord([c,g]),q3:t.coord([c,b]),max:t.coord([c,_])},x={left:i[1].offset,center:(i[1].offset+i[1].width)/2,right:i[1].width},S={type:"group",children:[]},D=[{x1:w.max[0]+x.left,x2:w.max[0]+x.right,y1:w.max[1],y2:w.max[1]},{x1:w.median[0]+x.left,x2:w.median[0]+x.right,y1:w.median[1],y2:w.median[1]},{x1:w.min[0]+x.left,x2:w.min[0]+x.right,y1:w.min[1],y2:w.min[1]},{x1:w.min[0]+x.center,x2:w.min[0]+x.center,y1:w.min[1],y2:w.q1[1]},{x1:w.max[0]+x.center,x2:w.max[0]+x.center,y1:w.max[1],y2:w.q3[1]}],z={stroke:o,lineWidth:l};return D.forEach(I=>{S.children.push({type:"line",shape:I,style:z})}),S.children.push({type:"rect",shape:{x:w.q1[0]+x.left,y:w.q1[1],width:x.right-x.left,height:w.q3[1]-w.q1[1]},style:{fill:a,stroke:o,lineWidth:l}}),S}function Bg(e,t){const{color:r}=t,a={name:"Box",type:"custom",itemStyle:{color:r,borderColor:"#2F8CC0",borderWidth:2},emphasis:{disabled:!0},boxWidth:Dr,datasetIndex:0};return a.renderItem=(o,l)=>Eg(e,l,a),a}function qg(e){const t=zr(e),r=t[0].width,a=e.value(0),o=e.value(1),[l,i]=e.coord([a,o]),d=l+t[0].offset+Math.random()*r;return{type:"circle",transition:["shape"],x:d,y:i,shape:{cx:0,cy:0,r:2},style:{fill:e.visual("color"),opacity:.5}}}function Og(){const e={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return e.renderItem=(t,r)=>qg(r),e}function Lg(e,t){const r=zr(e),a=r[0].width,o=e.value(0),l=e.value(1),[i,c]=e.coord([o,l]),u=i+r[0].offset+Math.random()*a;return{type:"circle",transition:["shape"],x:u,y:c,shape:{cx:0,cy:0,r:3},style:{fill:e.visual("color")}}}function Ng(){const e={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return e.renderItem=(t,r)=>Lg(r),e}function Gg(e,t){const r=t[0],a=Bg(r,e),o=Og(),l=Ng();return[{name:"Placeholder Box",type:"boxplot",ignore:!0,silent:!0,itemStyle:{color:"none",borderColor:"none",opacity:0},boxWidth:[20,80],datasetIndex:0,encode:{y:kr,x:"name",itemName:["name"],tooltip:kr}},{name:"Outlier",type:"scatter",symbolSize:7,itemStyle:{color:"transparent"},ignore:!0,silent:!0,emphasis:{disabled:!0},datasetIndex:1},a,o,l]}const Fg=(e,t)=>{const r=kr.map(l=>`
|
|
69
|
+
`}function Ke(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}const ue=h.forwardRef(({value:e,onChange:t,hiddenFileds:r},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>new Set(r??[]),[r]),i=c=>d=>{t({...e,[c]:d})};return n.jsxs(s.Stack,{ref:a,gap:"sm",children:[n.jsx(s.Divider,{mb:-10,label:o("chart.unit.title"),labelPosition:"center",variant:"dashed"}),!l.has("text")&&n.jsx(s.TextInput,{size:"xs",placeholder:o("chart.unit.text.placeholder"),value:e.text,onChange:c=>i("text")(c.currentTarget.value)}),n.jsxs(s.Group,{grow:!0,children:[!l.has("show_in_tooltip")&&n.jsx(s.Checkbox,{size:"xs",label:o("chart.unit.show_in_tooltip"),checked:e.show_in_tooltip,onChange:c=>i("show_in_tooltip")(c.currentTarget.checked)}),!l.has("show_in_legend")&&n.jsx(s.Checkbox,{size:"xs",label:o("chart.unit.show_in_legend"),checked:e.show_in_legend,onChange:c=>i("show_in_legend")(c.currentTarget.checked)})]})]})});function K(){return{text:"",show_in_tooltip:!1,show_in_legend:!1}}const Cr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:de,unit:K()},tooltip:{metrics:[]},color:"rgba(99, 152, 199, 0.10)",reference_lines:[],legend:{show:!0,top:"10",right:"0",left:"auto",bottom:"auto",orient:"vertical",type:"scroll"},dataZoom:Ao()};function Dt(e,t){return h.useMemo(()=>{const{queryID:r,columnKey:a}=$(t);return y.keyBy(e[r],a)},[e,t])}const Ve=(e,t)=>{const[r,a]=h.useState([]);return h.useEffect(()=>e.watchTriggerSnapshotList(o=>a(o.filter(l=>l.schemaRef===t))),[]),r},Sr=h.createContext(null);function vn(e){const t=h.useContext(Sr),r=O.useCreation(()=>e.configure(t||new Xn),[e.configure]),a=O.usePrevious(r);return a&&a!==r&&a.dispose(),n.jsx(Sr.Provider,{value:r,children:e.children})}function Xt(){return h.useContext(Sr)}const Pe=({})=>Xt().getRequired(ee.instanceScope.interactionManager),Bo=e=>{const{t}=m.useTranslation(),{title:r="Variables",variables:a}=e,o=te.useClipboard(),l=i=>{o.copy(i),Fe.showNotification({color:"green",message:t("common.copied")})};return n.jsxs(s.Paper,{withBorder:!0,p:"sm",children:[n.jsx(s.Text,{size:"xs",c:"dimmed",mb:"sm",children:r}),n.jsx(s.Stack,{style:{maxHeight:"500px"},children:a.map(i=>n.jsxs(s.Text,{size:"sm",children:[n.jsxs(s.Code,{color:"teal",children:["// ",i.description]}),n.jsx("br",{}),n.jsxs(s.Code,{onClick:()=>l(i.name),style:{cursor:"pointer"},children:[i.name," : ",i.valueType]})]},i.name))})]})};class Vh{constructor(t,r){V(this,"operationId");V(this,"operation");V(this,"operationSchema");V(this,"variables",[]);this.operationManager=t,this.instance=r,G.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,r){const a=await this.operationManager.retrieveTrigger(t),o=this.operationManager.getOperationSchemaList().find(l=>l.id===(a==null?void 0:a.schemaRef));G.runInAction(()=>{this.operationId=t,this.operation=a,this.operationSchema=o,this.variables=r})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function Ph(e){return!!e.operationId}const $h=k.observer(({model:e,onClick:t})=>{var o;const{t:r}=m.useTranslation(),a=(o=e.operationSchema)==null?void 0:o.displayName;return n.jsx(s.Button,{variant:"outline",onClick:t,children:r(a)})}),qo=k.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return h.createElement(e.operationSchema.configRender,t)}),Ah=k.observer(({model:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.schemaList,o=h.useMemo(()=>a.map(i=>({label:t(i.displayName),value:i.id})),[a,r.language]);async function l(i){await e.changeSchema(a.find(c=>c.id===i))}return n.jsx(s.Select,{label:t("interactions.operation.label"),data:o,onChange:Z(l),value:e.operationSchema.id,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})}),Eh=k.observer(e=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),{operationManager:l,operationId:i,instance:c,variables:d}=e,u=O.useCreation(()=>new Vh(l,c),[l,c]);return O.useAsyncEffect(async()=>{await u.configOperation(i,d)},[i,u]),Ph(u)?n.jsxs(n.Fragment,{children:[n.jsx($h,{model:u,onClick:a}),n.jsx(s.Modal,{size:600,opened:r,onClose:o,title:t("interactions.operation.setup"),zIndex:320,children:n.jsxs(s.Stack,{children:[n.jsx(Ah,{model:u}),u.variables.length>0?n.jsxs(s.Tabs,{defaultValue:"settings",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"settings",children:t("interactions.operation.settings")}),n.jsx(s.Tabs.Tab,{value:"variables",children:t("interactions.operation.variables")})]}),n.jsx(s.Tabs.Panel,{value:"settings",pt:10,children:n.jsx(qo,{model:u})}),n.jsx(s.Tabs.Panel,{value:"variables",pt:10,children:n.jsx(Bo,{title:t("interactions.operation.variables"),variables:u.variables})})]}):n.jsx(qo,{model:u})]})})]}):null});class Bh{constructor(t,r){V(this,"triggerId");V(this,"trigger");V(this,"triggerSchema");V(this,"sampleData");this.triggerManager=t,this.instance=r,G.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,r){const a=await this.triggerManager.retrieveTrigger(t),o=this.triggerManager.getTriggerSchemaList().find(l=>l.id===(a==null?void 0:a.schemaRef));G.runInAction(()=>{this.triggerId=t,this.trigger=a,this.triggerSchema=o,this.sampleData=r})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return qh(this)}}function qh(e){return!!e.triggerId&&!!e.triggerSchema}function Oh(e,t){return O.useCreation(()=>new Bh(e,t),[e,t])}const Lh=k.observer(({model:e,onClick:t})=>{const r=e.triggerSchema.nameRender,a={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return n.jsx(s.Button,{variant:"outline",onClick:t,children:h.createElement(r,a)})}),Nh=k.observer(({model:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.schemaList,o=h.useMemo(()=>a.map(i=>({label:t(i.displayName),value:i.id})),[a,r.language]);async function l(i){await e.changeSchema(a.find(c=>c.id===i))}return n.jsx(s.Select,{label:t("interactions.trigger.label"),data:o,value:e.triggerSchema.id,onChange:Z(l)})}),Gh=k.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return h.createElement(e.triggerSchema.configRender,t)}),Fh=k.observer(e=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),l=e.model;return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:r,onClose:o,title:t("interactions.trigger.setup"),zIndex:320,children:n.jsxs(s.Stack,{children:[n.jsx(Nh,{model:l}),n.jsx(Gh,{model:l}),n.jsx(Bo,{title:t("interactions.trigger.payload"),variables:l.triggerSchema.payload})]})}),n.jsx(Lh,{onClick:a,model:l})]})});class Bt{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const a=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...a,[t]:r})}return await this.getItem(t)}watchItem(t,r,a){return t===null?this.root.watchItem(this.path,(o,l)=>{r(o,l)},a):this.root.watchItem(this.path,(o,l)=>{const i=y.get(o,t),c=y.get(l,t);i!==c&&r(i,c)},a)}}const Qh={"builtin:op:debug":1,"builtin:op:clear_filter_values":2,"builtin:op:set_filter_values":3,"builtin:op:open_view":4,"builtin:op:open-link":5,"builtin:op:switch_tab":6,"builtin:op:scroll_to_panel":7};class Tr{constructor(t,r,a){V(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=a,this.attachmentStorage=new Bt(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new Bt(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new Bt(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null),r=y.orderBy(y.values(t),a=>Qh[a.schemaRef]??10);return Promise.all(r.map(a=>this.constructInstance(new Bt(this.attachmentStorage,a.id))))}}function jh(e,t){const{value:r,set:a}=q(e.operation.operationData,"config"),[o,l]=h.useState(y.defaults({},r,t)),i=async()=>{await a(o)};return h.useEffect(()=>{l(y.defaults({},r,t))},[r]),{config:o,setConfig:l,commit:i}}function Wh(e){const{t}=m.useTranslation(),{config:r,setConfig:a,commit:o}=jh(e,{urlTemplate:"",openInNewTab:!0});async function l(){await o()}async function i(d){a({...r,openInNewTab:d}),await o()}const c=d=>a({...r,urlTemplate:d.currentTarget.value});return n.jsxs(s.Stack,{children:[n.jsx(s.TextInput,{label:t("interactions.operation.open_link.url"),value:r.urlTemplate,onChange:c,onBlur:l}),n.jsx(s.Switch,{label:t("interactions.operation.open_link.open_in_new_tab"),checked:r.openInNewTab,onChange:d=>i(d.currentTarget.checked)})]})}async function Uh(e,t){const{urlTemplate:r,openInNewTab:a}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:r,openInNewTab:a,payload:e}}))}class Kh extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>r)}}const Yh={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:Wh,run:Uh,migrator:new Kh,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Xh(e){const{value:t,set:r}=q(e.operationData,"config"),a=o=>void r({template:o});return[(t==null?void 0:t.template)||"",a]}function Zh(e){const{t}=m.useTranslation(),[r,a]=Xh(e.operation);return n.jsx(s.TextInput,{defaultValue:r,onBlur:o=>a(o.currentTarget.value),label:t("interactions.operation.console_log.log_content")})}async function Jh(e,t){const r=await t.operationData.getItem("config"),a=y.template(r.template||"");console.log("run with payload",e),console.log(a(e))}const Hh={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:Zh,run:Jh},Rh=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),l=(a==null?void 0:a.viewID)||"",i=c=>void o({viewID:c});return n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(i),label:t("interactions.operation.open_view.view"),data:r.views.options,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})});async function eg(e,t){const a=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:a}}))}const tg={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:Rh,run:eg},ng={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},rg=({value:e="",onChange:t})=>{const[r,a]=h.useState(e);h.useEffect(()=>{a(e)},[e]);const o=()=>{t(r)};return n.jsx(s.TextInput,{size:"xs",label:"",value:r,onChange:l=>a(l.currentTarget.value),sx:{flexGrow:1},rightSection:n.jsx(s.ActionIcon,{color:"green",size:"xs",onClick:o,disabled:r===e,children:n.jsx(T.IconDeviceFloppy,{})})})},ag={dictionary:{}},sg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a=ag,set:o}=q(e.operation.operationData,"config"),{dictionary:l={}}=a;console.log({value:{...a},dictionary:{...l},filters:[...r.filters.keyLabelOptions]});const i=(c,d)=>{if(d===""){const u={...l};delete u[c],o({dictionary:u});return}o({dictionary:{...l,[c]:d}})};return n.jsxs(s.Table,{sx:ng,children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:t("interactions.operation.set_filter_values.set_filter")}),n.jsx(s.Table.Th,{children:t("interactions.operation.set_filter_values.with")})]})}),n.jsx(s.Table.Tbody,{children:[...r.filters.keyLabelOptions].map(c=>{const d=c.value in l;return n.jsxs(s.Table.Tr,{"data-affected":d,children:[n.jsx(s.Table.Td,{children:c.label}),n.jsx(s.Table.Td,{children:n.jsx(rg,{value:l[c.value],onChange:u=>i(c.value,u)})})]},c.value)})})]})});async function og(e,t){const a=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:a,payload:e}}))}const lg={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:sg,run:og},ig={filter_keys:[]},cg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a=ig,set:o}=q(e.operation.operationData,"config"),{filter_keys:l=[]}=a,i=d=>{o({filter_keys:[...d]})},c=h.useMemo(()=>r.filters.current.map(d=>({label:d.label,value:d.key})),[r.filters.values]);return n.jsx(s.Stack,{gap:10,children:n.jsx(s.MultiSelect,{label:t("interactions.operation.clear_filter_values.select_filter"),data:c,value:l,onChange:i})})});async function dg(e,t){const a=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:a,payload:e}}))}const ug={displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:cg,run:dg},pg=({option:e,checked:t})=>{var o;const{t:r}=m.useTranslation(),a=e;return n.jsxs(s.Group,{justify:"space-between",flex:"1",gap:"xs",children:[n.jsx(s.Text,{size:"xs",children:a.label}),n.jsx(s.Text,{size:"xs",children:r((o=ei[a.viz_type])==null?void 0:o.displayName)??a.viz_type})]})},hg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),l=(a==null?void 0:a.panelID)||"",i=c=>void o({panelID:c});return n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(i),label:t("interactions.operation.scroll_to_panel.panel"),data:r.panels.options,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500,renderOption:pg})});async function gg(e,t){const a=(await t.operationData.getItem("config")).panelID;window.dispatchEvent(new CustomEvent("scroll_to_panel",{detail:{panelID:a}}))}const fg={displayName:"interactions.operation.scroll_to_panel.label",id:"builtin:op:scroll_to_panel",configRender:hg,run:gg},bg=k.observer(e=>{const{t}=m.useTranslation(),r=F(),{value:a,set:o}=q(e.operation.operationData,"config"),{viewID:l="",tab:i=""}=a??{},c=u=>void o({viewID:u,tab:i}),d=u=>void o({viewID:l,tab:u});return n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(s.Select,{defaultValue:l,value:l,onChange:Z(c),label:t("interactions.operation.switch_tab.view"),data:r.views.tabViewOptions,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500}),n.jsx(s.Select,{defaultValue:i,value:i,onChange:Z(d),label:t("interactions.operation.switch_tab.tab"),data:r.views.tabOptions(l),comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500})]})});async function yg(e,t){const r=await t.operationData.getItem("config"),{viewID:a,tab:o}=r;window.dispatchEvent(new CustomEvent("switch_tab",{detail:{viewID:a,tab:o}}))}const kr=[Hh,Yh,tg,fg,lg,{displayName:"interactions.operation.switch_tab.label",id:"builtin:op:switch_tab",configRender:bg,run:yg},ug];class vg{constructor(t,r=kr){V(this,"attachments");this.operations=r;const a=async o=>{const{id:l,schemaRef:i}=await o.getItem(null);return{id:l,schemaRef:i,operationData:new Bt(o,"data")}};this.attachments=new Tr(t,"__OPERATIONS",a)}async runOperation(t,r){const a=await this.attachments.getInstance(t);if(!a){console.warn(`Operation '${t}' is not defined`);return}const o=this.tryGetSchema(a.schemaRef);if(!o){console.warn(`Operation schema '${a.schemaRef}' is not defined`);return}await o.run(r,a)}tryGetSchema(t){return this.operations.find(r=>r.id===t)}async needMigration(){const r=(await this.attachments.list()).map(async a=>{const o={configData:a.operationData},l=this.tryGetSchema(a.schemaRef),i=l==null?void 0:l.migrator;return i&&await i.needMigration(o)});return(await Promise.all(r)).some(a=>a)}async runMigration(){const r=(await this.attachments.list()).map(async a=>{const o={configData:a.operationData},l=this.tryGetSchema(a.schemaRef),i=l==null?void 0:l.migrator;i&&await i.needMigration(o)&&await i.migrate(o)});await Promise.all(r)}async createOrGetOperation(t,r){var i;if(!this.getOperationSchemaList().some(c=>c.id===r.id))throw new Error(`Operation schema '${r.id}' is not defined`);const o=await this.attachments.getInstance(t);return!o||o.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((i=r.createDefaultConfig)==null?void 0:i.call(r))??{}}):o}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Oo="__TRIGGERS";class _g{constructor(t,r){V(this,"attachments");this.instance=t,this.component=r;const a=async o=>{const{id:l,schemaRef:i}=await o.getItem(null);return{id:l,schemaRef:i,triggerData:new Bt(o,"data")}};this.attachments=new Tr(t,Oo,a)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Oo,r=>{const a=y.values(r).map(o=>({id:y.get(o,"id"),schemaRef:y.get(o,"schemaRef"),config:G.toJS(y.get(o,"data.config"))}));t(a)},{fireImmediately:!0})}async createOrGetTrigger(t,r,a={recreate:!1}){var c;if(!this.getTriggerSchemaList().some(d=>d.id===r.id))throw new Error(`Trigger schema '${r.id}' is not defined in component '${this.component.name}'`);const l=await this.attachments.getInstance(t);return!l||a.recreate||l.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((c=r==null?void 0:r.createDefaultConfig)==null?void 0:c.call(r))||{}}):l}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const r=(await this.getTriggerList()).map(async a=>{const o=this.getTriggerSchemaList().find(c=>c.id===a.schemaRef),l=o==null?void 0:o.migrator,i={configData:a.triggerData};return l&&await l.needMigration(i)?()=>l.migrate(i):null});return Promise.all(r).then(a=>a.filter(o=>o))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(r=>r()))}}class Lo{constructor(t,r,a){V(this,"operationManager");V(this,"triggerManager");V(this,"attachments");this.operationManager=new vg(t,a),this.triggerManager=new _g(t,r);const o=async l=>{const{id:i,triggerRef:c,operationRef:d}=await l.getItem(null);return{id:i,triggerRef:c,operationRef:d}};this.attachments=new Tr(t,"__INTERACTIONS",o)}async addInteraction(t,r){const a=t.id,o=r.id,l=`[${a}]:[${o}]`;await this.attachments.create(l,{id:l,triggerRef:a,operationRef:o})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const r=await this.attachments.getInstance(t);if(!r)return;const{triggerRef:a,operationRef:o}=r;await this.getTriggerRefCount(a)<=1&&await this.triggerManager.removeTrigger(a),await this.getOperationRefCount(o)<=1&&await this.operationManager.removeOperation(o),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(a=>a.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(a=>a.triggerRef===t).length}async runInteraction(t,r){const o=(await this.getInteractionList()).filter(l=>l.triggerRef===t);for(let l of o)try{await this.operationManager.runOperation(l.operationRef,r)}catch(i){console.warn(`Failed to run operation '${l.operationRef}'`,i)}}}function mg(e,t){const[r,a]=h.useState([]);return O.useAsyncEffect(async()=>{const o=await e.getInteractionList();a(o)},[t,e]),r}const wg=k.observer(({item:e,manager:t,instance:r,sampleData:a,variables:o,onRemove:l})=>{const{triggerRef:i,operationRef:c}=e,d=Oh(t.triggerManager,r);if(O.useAsyncEffect(async()=>{await d.configTrigger(i,a)},[d,i,a]),d.isReady()){const u=[...d.triggerSchema.payload,...o];return n.jsxs(s.Group,{children:[n.jsx(Fh,{model:d}),n.jsx(Eh,{instance:r,operationId:c,variables:u,operationManager:t.operationManager}),n.jsx(s.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>l(e),children:n.jsx(T.IconTrash,{size:16})})]})}return null}),xg=e=>{const{t}=m.useTranslation(),[r,a]=h.useState(0),{interactionManager:o,instance:l,sampleData:i,variables:c}=e,d=mg(o,r),u=async()=>{const _=await o.triggerManager.createOrGetTrigger(te.randomId(),o.triggerManager.getTriggerSchemaList()[0]),w=await o.operationManager.createOrGetOperation(te.randomId(),o.operationManager.getOperationSchemaList()[0]);await o.addInteraction(_,w),a(x=>x+1)};async function p(_){await o.removeInteraction(_.id),a(w=>w+1)}const{data:g=0,loading:b}=O.useRequest(async()=>{try{return(await o.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return n.jsxs(s.Stack,{children:[n.jsx(s.LoadingOverlay,{visible:b}),g===0&&n.jsx(s.Alert,{icon:n.jsx(T.IconAlertCircle,{size:16}),title:t("interactions.unavailable"),color:"gray",children:t("interactions.unavailable_reason")}),d.map(_=>n.jsx(wg,{onRemove:p,instance:l,sampleData:i,variables:c,item:_,manager:e.interactionManager},_.id)),n.jsx(s.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:g===0,children:t("interactions.add")})]})},Cg=()=>{const{panel:e,data:t}=re(),r=e.viz,{vizManager:a}=h.useContext(ot),o=e.json,l=O.useCreation(()=>a.getOrCreateInstance(o),[a,o]),i=O.useCreation(()=>new Lo(l,a.resolveComponent(r.type),kr),[l,r.type]);return h.useEffect(()=>l.instanceData.watchItem(null,y.throttle(c=>{e.viz.setConf(c)},100,{leading:!1,trailing:!0})),[l]),{instance:l,vizManager:a,interactionManager:i,sampleData:t,variables:[]}},Sg=()=>{const e=Cg();return n.jsx(xg,{...e})},No={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function Tg(e){return y.defaultsDeep({},e,No)}const kg=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:Tg,xAxis:No},Symbol.toStringTag,{value:"Module"})),Go={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function Dg(e){return y.defaultsDeep({},e,Go)}const zg=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:Dg,yAxis:Go},Symbol.toStringTag,{value:"Module"})),Fo={confine:!0,appendToBody:!0};function Mg(e){return y.defaultsDeep({},e,Fo)}const X={...kg,...zg,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:Mg,tooltip:Fo},Symbol.toStringTag,{value:"Module"}))};function Ig(e,t){const r=[],a=[];return{boxplotData:Object.entries(e).map(([l,i])=>{const c=i.map(D=>D[t]).sort((D,z)=>D-z),d=jt.quantile(c,.25)??0,u=jt.quantile(c,.5)??0,p=jt.quantile(c,.75)??0,g=p-d,b=d-1.5*g,_=p+1.5*g,w=Math.max(c[0],b),x=Math.min(y.last(c)??0,_);return i.filter(D=>{const z=D[t];return z<w||z>x}).forEach(D=>r.push([l,D[t],D])),i.filter(D=>{const z=D[t];return z>=w&&z<=x}).forEach(D=>a.push([l,D[t],D])),{name:l,min:w,q1:d,median:u,q3:p,max:x}}),outliersData:r,scatterData:a}}function Vg(e,t){const{x_axis:r,y_axis:a}=e;if(!r.data_key||!a.data_key)return[];const o=$(r.data_key),l=$(a.data_key);if(o.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const i=y.groupBy(t[o.queryID],o.columnKey),{boxplotData:c,outliersData:d,scatterData:u}=Ig(i,l.columnKey);return[{source:c},{source:d},{source:u}]}function Pg(e){const t={top:35,left:20,right:15,bottom:25,containLabel:!0};return e.legend.orient==="vertical"&&(t.right=80),e.dataZoom.x_axis_slider&&(t.top=50),t}function $g({config:e,seriesNames:t}){const r={...e.legend,data:[{name:t.Box,icon:"roundRect",itemStyle:{color:e.color}},{name:t.Scatter,icon:"circle",itemStyle:{color:"#ED6A45",opacity:.5}},{name:t.Outlier,icon:"circle",itemStyle:{color:"#ED6A45"}}]};return e.legend.orient==="horizontal"&&e.dataZoom.x_axis_slider&&(r.top=15),r}function Ag(e,t,r){const a=t.reduce((o,l)=>{const i=He(l,r);return o[l.name]=Be(l,i),o},{});return e.map(o=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:o.name,yAxis:Number(a[o.variable_key])}],silent:!0,symbol:["none","triangle"],symbolRotate:90,symbolSize:[10,8],label:{formatter:function(){return Kt(o.template,t,r)},position:"insideEndTop"}}}))}const Dr=["max","q3","median","q1","min"],zr=[10,40];function Mr(e){return e.barLayout({barMinWidth:zr[0],barMaxWidth:zr[1],count:2})}function Eg(e,t,r){const{itemStyle:{color:a,borderColor:o,borderWidth:l}}=r,i=Mr(t),c=t.value(0),d=e.source[c],{min:u,q1:p,median:g,q3:b,max:_}=d,w={min:t.coord([c,u]),q1:t.coord([c,p]),median:t.coord([c,g]),q3:t.coord([c,b]),max:t.coord([c,_])},x={left:i[1].offset,center:(i[1].offset+i[1].width)/2,right:i[1].width},S={type:"group",children:[]},D=[{x1:w.max[0]+x.left,x2:w.max[0]+x.right,y1:w.max[1],y2:w.max[1]},{x1:w.median[0]+x.left,x2:w.median[0]+x.right,y1:w.median[1],y2:w.median[1]},{x1:w.min[0]+x.left,x2:w.min[0]+x.right,y1:w.min[1],y2:w.min[1]},{x1:w.min[0]+x.center,x2:w.min[0]+x.center,y1:w.min[1],y2:w.q1[1]},{x1:w.max[0]+x.center,x2:w.max[0]+x.center,y1:w.max[1],y2:w.q3[1]}],z={stroke:o,lineWidth:l};return D.forEach(I=>{S.children.push({type:"line",shape:I,style:z})}),S.children.push({type:"rect",shape:{x:w.q1[0]+x.left,y:w.q1[1],width:x.right-x.left,height:w.q3[1]-w.q1[1]},style:{fill:a,stroke:o,lineWidth:l}}),S}function Bg(e,t){const{color:r}=t,a={name:"Box",type:"custom",itemStyle:{color:r,borderColor:"#2F8CC0",borderWidth:2},emphasis:{disabled:!0},boxWidth:zr,datasetIndex:0};return a.renderItem=(o,l)=>Eg(e,l,a),a}function qg(e){const t=Mr(e),r=t[0].width,a=e.value(0),o=e.value(1),[l,i]=e.coord([a,o]),d=l+t[0].offset+Math.random()*r;return{type:"circle",transition:["shape"],x:d,y:i,shape:{cx:0,cy:0,r:2},style:{fill:e.visual("color"),opacity:.5}}}function Og(){const e={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return e.renderItem=(t,r)=>qg(r),e}function Lg(e,t){const r=Mr(e),a=r[0].width,o=e.value(0),l=e.value(1),[i,c]=e.coord([o,l]),u=i+r[0].offset+Math.random()*a;return{type:"circle",transition:["shape"],x:u,y:c,shape:{cx:0,cy:0,r:3},style:{fill:e.visual("color")}}}function Ng(){const e={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return e.renderItem=(t,r)=>Lg(r),e}function Gg(e,t){const r=t[0],a=Bg(r,e),o=Og(),l=Ng();return[{name:"Placeholder Box",type:"boxplot",ignore:!0,silent:!0,itemStyle:{color:"none",borderColor:"none",opacity:0},boxWidth:[20,80],datasetIndex:0,encode:{y:Dr,x:"name",itemName:["name"],tooltip:Dr}},{name:"Outlier",type:"scatter",symbolSize:7,itemStyle:{color:"transparent"},ignore:!0,silent:!0,emphasis:{disabled:!0},datasetIndex:1},a,o,l]}const Fg=(e,t)=>{const r=Dr.map(l=>`
|
|
70
70
|
<tr>
|
|
71
71
|
<th style="text-align: right; padding: 0 1em;">${y.capitalize(l)}</th>
|
|
72
72
|
<td style="text-align: left; padding: 0 1em;">
|
|
@@ -116,7 +116,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
116
116
|
${o.join("")}
|
|
117
117
|
</tbody>
|
|
118
118
|
</table>
|
|
119
|
-
`}const Ug=(e,t)=>r=>{const{seriesName:a,value:o}=r;switch(a){case t.Box:return Fg(e,o);case t.Outlier:return jg(e,o);case t.Scatter:return Wg(e,o)}};function Kg({config:e,seriesNames:t}){return X.getTooltip({trigger:"item",formatter:Ug(e,t)})}function _n(e,t){t||(t="none");const r=[];return e.x_axis_scroll&&r.push({type:"inside",xAxisIndex:[0],filterMode:t,minSpan:1}),e.y_axis_scroll&&r.push({type:"inside",yAxisIndex:[0],filterMode:t,minSpan:1}),e.x_axis_slider&&r.push({type:"slider",xAxisIndex:[0],filterMode:t,bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),r}function Yg({min:e,max:t}){if(e<=110)return Math.min(0,e);if(e<=200)return 100;const r=je.floor(je.log10(e)),a=Math.pow(10,r),o=Math.pow(10,r-1);return e/a<=2?y.round(e,-1*(r-1))-o:y.round(e,-1*r)-a}function Xg(e){return{Box:e("viz.boxplot.box"),Scatter:e("viz.boxplot.scatter"),Outlier:e("viz.boxplot.outlier")}}function Zg({config:e,data:t,variables:r,t:a}){const{x_axis:o,y_axis:l,reference_lines:i}=e,c=Vg(e,t),d=Ke(o.axisLabel.overflow.on_axis),u=Xg(a),p=Gg(e,c).map(g=>({...g,name:y.get(u,g.name,g.name)}));return{dataZoom:_n(e.dataZoom,"filter"),grid:Pg(e),dataset:c,legend:$g({config:e,seriesNames:u}),tooltip:Kg({config:e,seriesNames:u}),xAxis:[X.getXAxis({type:"category",name:o.name,nameGap:25,nameLocation:"center",nameTextStyle:{align:"center"},axisLabel:{...o.axisLabel,...d,formatter:Me(o.axisLabel.formatter)}})],yAxis:[X.getYAxis({name:l.name,minInterval:1,axisLabel:{formatter:function(g){return Y(g,l.label_formatter)}},min:Yg})],series:[...p,...Ag(i,r,t)]}}function Jg({context:e,instance:t}){const{t:r}=m.useTranslation(),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=e.data,{width:i,height:c}=e.viewport,d=y.defaults({},a,xr),u=Pe({vizManager:e.vizManager,instance:t}),p=Ve(u.triggerManager,Eo.id),g=Dt(l,d.x_axis.data_key),b=h.useCallback(D=>{const z=y.get(g,D.name,{error:"rowData is not found"});p.forEach(I=>{u.runInteraction(I.id,{...D,rowData:z})})},[g,p,u]),_=h.useRef(null),w=h.useCallback(()=>{var z;const D=(z=_.current)==null?void 0:z.getEchartsInstance();D&&fe(t,D.getOption())},[]),x=h.useMemo(()=>({click:b,finished:w}),[b,w]),S=h.useMemo(()=>Zg({config:d,data:l,variables:o,t:r}),[d,l,o,r]);return!a||!i||!c?null:n.jsx(ve,{width:i,height:c,children:n.jsx(he,{echarts:ce,option:S,ref:_,style:Yt(i,c),onEvents:x,notMerge:!0,theme:"merico-light"})})}function se({canSubmit:e,buttonRef:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Group,{justify:"flex-start",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(s.Text,{size:"sm",children:r("viz.viz_config_banner")}),n.jsx(s.ActionIcon,{ref:t,type:"submit",mr:5,variant:"filled",color:"blue",disabled:!e,children:n.jsx(T.IconDeviceFloppy,{size:20})})]})}const Mr=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("common.align.horizontal.left"),value:"left"},{label:l("common.align.horizontal.center"),value:"center"},{label:l("common.align.horizontal.right"),value:"right"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("common.align.horizontal.label"),data:c,value:t,onChange:Z(r),sx:a})}),jo=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("common.align.vertical.top"),value:"top"},{label:l("common.align.vertical.center"),value:"center"},{label:l("common.align.vertical.bottom"),value:"bottom"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("common.align.vertical.label"),data:c,value:t,onChange:Z(r),sx:a})}),Wo=pt.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Hg=[{from:0,to:0},{from:100,to:100}];class Rg{constructor(){V(this,"steps",new Map);V(this,"interpolation");V(this,"onChange");G.makeAutoObservable(this,{steps:G.observable},{deep:!1}),G.reaction(()=>G.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(t){for(const r of t)this.steps.set(r.to,r.from)}notifyStepChange(){var t;(t=this.onChange)==null||t.call(this,Array.from(this.steps.entries()).map(([r,a])=>({to:r,from:a})).sort((r,a)=>r.to-a.to||r.from-a.from))}fromProps(t){t.steps.length<2?this.setSteps(Hg):this.setSteps(t.steps),this.interpolation=t.interpolation,this.onChange=t.onChange}changeStep(t,r){t==null?this.steps.delete(r):this.steps.set(r,t)}getStepFromValue(t){return this.steps.get(t)}}function Uo(e){if(typeof e=="number")return String(e)}function ef(e){const{t}=m.useTranslation(),{onChange:r,color:a,index:o,value:l}=e,{classes:i}=Wo(),[c,d]=h.useState(Uo(l)),[u,{setTrue:p,setFalse:g}]=O.useBoolean(!1),b=o%2===1,_=b&&l!=null,w=!b&&l!=null,x=`map ${l} to color ${o}`,S=()=>{d(Uo(l)),g()},D=()=>{g(),r==null||r(Number(c))},z=()=>{g(),r==null||r(null)},I=Y(l??null,{output:"number",mantissa:10,trimMantissa:!0,average:!0,absolute:!1}),A=!c||Number.isNaN(Number(c));return n.jsxs("div",{"data-testid":`palette-item-${o}`,className:i.paletteItem,children:[n.jsx(s.Text,{title:x,style:{opacity:_?1:0},c:"dimmed",size:"sm",className:"palette-value--up palette-value",children:I}),n.jsxs(s.Popover,{width:240,trapFocus:!0,opened:u,onClose:g,zIndex:340,withinPortal:!0,children:[n.jsx(s.Popover.Target,{children:n.jsx("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:p,style:{"--shadow-color":Ge(a).alpha(.5).hex(),backgroundColor:a}})}),n.jsxs(s.Popover.Dropdown,{children:[n.jsx(s.Tooltip,{withinPortal:!0,zIndex:340,label:t("common.actions.close"),children:n.jsx(s.CloseButton,{"data-testid":"palette-item-cancel",size:"sm",color:"gray",onClick:S,style:{position:"absolute",top:"0.5em",right:"0.8em"}})}),n.jsxs(s.Stack,{children:[n.jsx(s.TextInput,{size:"xs",label:t("style.color.interpolation.palette.mapping.value_input_label"),value:c,onChange:E=>{const U=E.currentTarget.value;d(U)},error:c&&A}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{variant:"light",color:"red",size:"xs",onClick:z,leftSection:n.jsx(T.IconTrash,{size:16}),children:t("common.actions.delete")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),"data-testid":"palette-item-ok",size:"xs",onClick:D,disabled:A,children:t("common.actions.save")})]})]})]})]}),n.jsx(s.Text,{title:x,style:{opacity:w?1:0},c:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:I})]})}const tf=k.observer(({model:e})=>{const{classes:t}=Wo(),r=y.range(0,13,1).map(a=>100/12*a).map(a=>[e.interpolation.getColor(a),a]);return n.jsx("div",{className:t.palette,children:r.map(([a,o],l)=>n.jsx(ef,{index:l,color:a,value:e.getStepFromValue(o),onChange:i=>e.changeStep(i,o)},a))})}),nf=k.observer(function(t){const r=O.useCreation(()=>new Rg,[]);return h.useEffect(()=>{r.fromProps(t)}),r.interpolation==null?null:n.jsx(tf,{model:r})}),rf=e=>{const{t,i18n:r}=m.useTranslation(),{value:a,onChange:o,colorManager:l}=e,i=l.getColorInterpolations(),[c,d]=h.useState(a),u=l.decodeInterpolation(c.interpolation)||i[0],[p,{setTrue:g,setFalse:b}]=O.useBoolean(),_=h.useMemo(()=>{const z=y.groupBy(i,"category");return Object.entries(z).map(([I,A])=>({group:t(`style.color.interpolation.palette.category.${I}`),items:A.map(E=>({label:t(E.displayName),value:l.encodeColor(E)}))}))},[r.language]);function w(z){z&&d(I=>({...I,interpolation:z}))}const x=()=>{b(),o==null||o(G.toJS(c))};function S(z){d(I=>({...I,steps:z}))}const D=()=>{b(),d(a)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"outline",onClick:g,children:t(u==null?void 0:u.displayName)}),n.jsx(s.Modal,{size:508,title:t("style.color.interpolation.setup"),opened:p,onClose:b,zIndex:320,children:p&&n.jsxs(s.Stack,{"data-testid":"color-interpolation-modal",children:[n.jsx(s.Select,{label:t("style.color.interpolation.palette.label"),value:c.interpolation,data:_,onChange:w,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500}),n.jsx(nf,{steps:c.steps,interpolation:u,onChange:S}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:D,variant:"subtle",children:t("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:x,children:t("common.actions.save")})]})]})})]})},af=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.color.type.static"),value:"static"},{label:l("style.color.type.interpolation"),value:"interpolation"},{label:l("style.color.type.none"),value:"none"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.color.type.label"),data:c,value:t,onChange:Z(r),sx:a})}),sf=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.flex.justify_content.left"),value:"left"},{label:l("style.flex.justify_content.center"),value:"center"},{label:l("style.flex.justify_content.right"),value:"right"},{label:l("style.flex.justify_content.space_between"),value:"space-between"},{label:l("style.flex.justify_content.space_around"),value:"space-around"},{label:l("style.flex.justify_content.space_evenly"),value:"space-evenly"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.flex.justify_content.label"),data:c,value:t,onChange:Z(r),sx:a})}),of=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.flex.align_items.start"),value:"start"},{label:l("style.flex.align_items.center"),value:"center"},{label:l("style.flex.align_items.end"),value:"end"},{label:l("style.flex.align_items.stretch"),value:"stretch"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.flex.align_items.label"),data:c,value:t,onChange:Z(r),sx:a})}),lf=({value:e,index:t,children:r})=>{const[a,{setTrue:o,setFalse:l}]=O.useBoolean(!1),{ref:i,handleRef:c}=an.useSortable({id:e,index:t});return n.jsx(s.Tabs.Tab,{ref:i,value:e,leftSection:n.jsx(T.IconGripHorizontal,{size:14,color:a||t===0?"rgb(34, 139, 230)":"transparent"}),onMouseEnter:o,onMouseLeave:l,children:r})},cf=({fieldArray:e,add:t,addButtonText:r,renderTabName:a,controlledFields:o})=>{const l=i=>{const{source:c,target:d}=i.operation,u=o.findIndex(g=>g.id===c.id),p=d.index;e.move(u,p)};return n.jsxs(s.Tabs.List,{children:[n.jsx(rn.DragDropProvider,{onDragEnd:l,children:o.map((i,c)=>n.jsx(lf,{value:i.id,index:c,children:a(i,c)},i.id))}),n.jsx(s.Tabs.Tab,{onClick:t,value:"add",children:n.jsx(s.Tooltip,{label:r,children:n.jsx(s.Center,{children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})})})]})},df={tab:{paddingTop:"4px",paddingBottom:"4px"},panel:{padding:"0px"}},R=({control:e,watch:t,name:r,getItem:a,children:o,addButtonText:l,deleteButtonText:i,renderTabName:c,deleteDisalbed:d})=>{var A;const u=v.useFieldArray({control:e,name:r}),{fields:p,append:g,remove:b}=u,_=t(r),w=p.map((E,U)=>({...E,..._[U]})),x=((A=y.last(w))==null?void 0:A.id)??null,[S,D]=h.useState(x),z=E=>{E!=="add"&&D(E)};h.useEffect(()=>{D(E=>x===E?E:x)},[x]);const I=()=>{const E=a();u.append(E),D(E.id)};return n.jsxs(s.Tabs,{value:S,onChange:z,styles:df,children:[n.jsx(cf,{fieldArray:u,add:I,addButtonText:l,renderTabName:c,controlledFields:w}),w.map((E,U)=>n.jsx(s.Tabs.Panel,{value:E.id,children:n.jsxs(s.Stack,{children:[o({field:E,index:U}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed"}),n.jsx(s.Button,{leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:()=>b(U),sx:{top:15,right:5},disabled:d==null?void 0:d({field:E,index:U,fields:w}),children:i})]})},E.id))]})},mn=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=l=>i=>{t({...e,[l]:i})};return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{variant:"dashed",label:a("chart.zooming.scroll.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.scroll.x_axis"),checked:e.x_axis_scroll,onChange:l=>o("x_axis_scroll")(l.currentTarget.checked)})}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.scroll.y_axis"),checked:e.y_axis_scroll,onChange:l=>o("y_axis_scroll")(l.currentTarget.checked)})})]}),n.jsx(s.Divider,{variant:"dashed",label:a("chart.zooming.slider.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.slider.x_axis"),checked:e.x_axis_slider,onChange:l=>o("x_axis_slider")(l.currentTarget.checked)})}),n.jsx(s.Tooltip,{label:a("chart.zooming.slider.y_axis_disabled"),children:n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.slider.y_axis"),disabled:!e.y_axis_slider,checked:e.y_axis_slider,onChange:l=>o("y_axis_slider")(l.currentTarget.checked)})})})]})]})}),bt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={},disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>[{label:i("chart.orientation.horizontal"),value:"horizontal"},{label:i("chart.orientation.vertical"),value:"vertical"}],[c.language]);return n.jsx(s.Select,{ref:l,label:e??i("chart.orientation.label"),data:d,value:t,onChange:Z(r),sx:a,disabled:o})}),uf=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=t("legend"),o=(l,i)=>{const c={...a,orient:l};l==="horizontal"?(c.top="0",c.left="auto",c.right="10",c.bottom="auto"):(c.top="10",c.left="auto",c.right="0",c.bottom="auto"),i(c)};return n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",mt:20,children:n.jsx(v.Controller,{name:"legend.show",control:e,render:({field:l})=>n.jsx(s.Switch,{label:r("chart.legend.show_legend"),sx:{flex:1},checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})})}),n.jsx(s.Group,{children:n.jsx(v.Controller,{name:"legend",control:e,render:({field:l})=>n.jsx(bt,{sx:{flex:1},value:l.value.orient,onChange:i=>{o(i,l.onChange)},disabled:!a.show})})})]})};function pf({control:e,index:t,variableOptions:r}){const{t:a}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:o})=>n.jsx(s.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...o})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:o})=>n.jsx(s.Select,{label:a("common.value"),required:!0,data:r,sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:o})=>n.jsx(s.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.placeholder"),required:!0,sx:{flex:1},...o})})]})}function hf({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:""}),l=h.useMemo(()=>r.map(c=>({label:c.name,value:c.name})),[r]),i=(c,d)=>{const u=c.name.trim();return u||d+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:i,children:({field:c,index:d})=>n.jsx(pf,{control:e,index:d,variableOptions:l})})}const gf=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("chart.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},ff=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(gf,{control:e,index:i})})]})};function bf({control:e,watch:t}){return n.jsx(s.Stack,{children:n.jsx(ff,{control:e,watch:t})})}const st=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l}=m.useTranslation();return n.jsx(s.NumberInput,{ref:o,label:e??l("chart.rotate"),hideControls:!0,min:-90,max:90,rightSection:n.jsx(s.Text,{size:"xs",c:"dimmed",children:l("chart.degree")}),sx:a,styles:{section:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},value:t,onChange:i=>{typeof i!="string"&&r(i)}})}),yf=({control:e,watch:t})=>{const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.x_axis_name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})},Ir={root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}},vf=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function _f({format:e}){const{t}=m.useTranslation(),[r,{toggle:a}]=te.useDisclosure(!1);return n.jsxs(s.Box,{children:[n.jsx(s.Button,{variant:"subtle",w:"100%",size:"compact-sm",onClick:a,leftSection:r?n.jsx(T.IconChevronUp,{size:14}):n.jsx(T.IconChevronDown,{size:14}),children:t(r?"numbro.format.preview.close":"numbro.format.preview.open")}),n.jsx(s.Collapse,{in:r,children:r&&n.jsxs(s.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:t("numbro.format.preview.input")}),n.jsx(s.Table.Th,{children:t("numbro.format.preview.output")})]})}),n.jsx(s.Table.Tbody,{children:vf.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:o}),n.jsx(s.Table.Td,{children:n.jsx(ne,{children:Y(o,e)})})]},o))})]})})]})}function mf({value:e,onChange:t,size:r},a){const{t:o}=m.useTranslation(),l=p=>{t({...e,output:p,absolute:!1,average:!1,trimMantissa:!1,mantissa:0})},i=p=>{if(typeof p=="string")return;const g=p===0?!1:e.trimMantissa;t({...e,mantissa:p,trimMantissa:g})},c=p=>{t({...e,trimMantissa:p.currentTarget.checked})},d=p=>{t({...e,average:p.currentTarget.checked})},u=p=>{const g={...e,absolute:p.currentTarget.checked};t(g)};return n.jsxs(s.Stack,{ref:a,children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Select,{label:o("numbro.format.label"),size:r,data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:Z(l),sx:{flexGrow:1}}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.absolute")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.absolute_description")})]}),size:r,checked:e.absolute,onChange:u,sx:{flexGrow:1},styles:Ir}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.abbreviation")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.abbreviation_description")})]}),size:r,checked:e.average,onChange:d,disabled:e.output!=="number",sx:{flexGrow:1},styles:Ir})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{label:o("numbro.format.mantissa"),size:r,defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.trim_mantissa")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.trim_mantissa_description")})]}),size:r,checked:e.trimMantissa,onChange:c,disabled:e.mantissa===0,styles:Ir}),n.jsx(s.Box,{})]}),n.jsx(_f,{format:e})]})}const Ne=h.forwardRef(mf),wf=({control:e,watch:t})=>{const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.y_axis_name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"y_axis.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-15,variant:"dashed",label:r("chart.axis.section_title.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.label_formatter",control:e,render:({field:a})=>n.jsx(Ne,{...a})})]})]})};function xf({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},r,xr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["x_axis","y_axis","reference_lines","color","dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Legend",children:t("chart.legend.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Style",children:t("chart.style.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(yf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(wf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Legend",children:n.jsx(uf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(bf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Style",children:n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"color",control:i,render:({field:g})=>n.jsx(ye,{label:t("chart.color.label"),...g})})})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(hf,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function Cf(e){return y.omit(e,"variables")}function Sf(e){const{label_formatter:t=de,...r}=e.y_axis;return{...e,y_axis:{...r,label_formatter:t}}}function Tf(e){const t={rotate:0,formatter:_e()},{axisLabel:r=t,...a}=e.x_axis;return{...e,x_axis:{...a,axisLabel:r}}}function kf(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function Df(e){delete e.config;const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function zf(e){const t={tooltip:{metrics:[]}};return y.defaultsDeep(t,e)}function Mf(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis:o,y_axis:l,tooltip:i,...c}=e;return{...c,x_axis:{...o,data_key:a(o.data_key)},y_axis:{...l,data_key:a(l.data_key)},tooltip:{...i,metrics:i.metrics.map(d=>({...d,data_key:a(d.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function If(e){const t={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return y.defaultsDeep(t,e)}function Vf(e){const{dataZoom:t,...r}=e;return{...r,dataZoom:t??Ao()}}function Pf(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function $f(e){const{y_axis:t}=e;return{...e,y_axis:{...t,unit:t.unit??K()}}}class Af extends J{constructor(){super(...arguments);V(this,"VERSION",12)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(i=>{a.variables.find(c=>c.name===i.name)||a.addVariable(i)}),{...r,version:2,config:Cf(o)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:Sf(a)}}),this.version(4,r=>{const{config:a}=r;return{...r,version:4,config:Tf(a)}}),this.version(5,r=>{const{config:a}=r;return{...r,version:5,config:kf(a)}}),this.version(6,r=>{const{config:a}=r;return{...r,version:6,config:Df(a)}}),this.version(7,r=>{const{config:a}=r;return{...r,version:7,config:zf(a)}}),this.version(8,(r,a)=>{const{config:o}=r;return{...r,version:8,config:Mf(o,a)}}),this.version(9,r=>{const{config:a}=r;return{...r,version:9,config:If(a)}}),this.version(10,r=>{const{config:a}=r;return{...r,version:10,config:Vf(a)}}),this.version(11,r=>{const{config:a}=r;return{...r,version:11,config:Pf(a)}}),this.version(12,r=>{const{config:a}=r;return{...r,version:12,config:$f(a)}})}}const Ef={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Af,name:"boxplot",viewRender:Jg,configRender:xf,createConfig(){return{version:12,config:y.cloneDeep(xr)}},triggers:[Eo],translation:zh},Ko={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:qf,configRender:Bf,payload:[]};function Bf(e){return n.jsx(n.Fragment,{})}function qf(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.button.click.label")})}const Vr={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},Of={left:"flex-start",center:"center",right:"flex-end"},Lf={top:"flex-start",center:"center",bottom:"flex-end"},Nf=k.observer(({context:e,instance:t})=>{const r=Pe({vizManager:e.vizManager,instance:t}),a=Ve(r.triggerManager,Ko.id),o=H(),{value:l}=q(e.instanceData,"config"),i=h.useMemo(()=>y.defaultsDeep({},l,Vr),[l]),{content:c,horizontal_align:d,vertical_align:u,compact:p,size:g,...b}=i,{width:_,height:w}=e.viewport,x=o.payloadForSQL,S=()=>{a.forEach(z=>{r.runInteraction(z.id,{})})},D=p?`compact-${g}`:g;return n.jsx(s.Center,{sx:{width:_,height:w,justifyContent:Of[d],alignItems:Lf[u]},children:n.jsx(s.Button,{size:D,...b,onClick:S,children:y.template(c)(x)})})}),Gf=({value:e,onChange:t,label:r})=>{const a=s.useMantineTheme(),o=h.useCallback(i=>()=>t(i),[t]),l=i=>e===i;return n.jsxs(s.Stack,{gap:2,children:[n.jsx(s.Text,{size:"14px",fw:500,children:r}),n.jsx(s.Group,{justify:"flex-start",gap:"xs",children:Object.keys(a.colors).map(i=>{const c=a.colors[i][6];return n.jsx(s.ColorSwatch,{color:c,onClick:o(i),radius:4,size:26,sx:{cursor:"pointer"},children:l(i)&&n.jsx(s.CheckIcon,{width:10,color:"white"})},i)})})]})},Ff=["xs","sm","md","lg","xl"],Pr=h.forwardRef(({label:e,value:t,onChange:r,sx:a,disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>Ff.map(u=>({label:i(`style.size.${u}`),value:u})),[c.language]);return n.jsx(s.Select,{ref:l,data:d,label:e,value:t,onChange:Z(r),sx:a,disabled:!0})}),Qf=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}];function jf({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Vr),[t]),o=a;h.useEffect(()=>{!y.isEqual(a,o)&&(console.log("config malformed, resetting to defaults",a,o),r(o))},[a,o]);const{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),c(["content","variant","color","size","compact","horizontal_align","vertical_align"]),n.jsxs("form",{onSubmit:i(r),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{control:l,name:"content",render:({field:p})=>n.jsx(s.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...p,required:!0})}),n.jsx(s.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"variant",render:({field:p})=>n.jsx(s.Select,{label:"Variant",data:Qf,...p})}),n.jsx(v.Controller,{control:l,name:"color",render:({field:p})=>n.jsx(Gf,{label:"Theme",...p})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"size",render:({field:p})=>n.jsx(Pr,{label:"Size",...p})}),n.jsx(v.Controller,{control:l,name:"compact",render:({field:p})=>n.jsx(s.Checkbox,{label:"Compact",checked:p.value,onChange:g=>p.onChange(g.currentTarget.checked),mt:26})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"horizontal_align",render:({field:p})=>n.jsx(Mr,{...p})}),n.jsx(v.Controller,{control:l,name:"vertical_align",render:({field:p})=>n.jsx(jo,{...p})})]})]})]})}const Wf=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class Uf extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{horizontal_align:a="left",vertical_align:o="center",...l}=r.config;return{...r,version:2,config:{...l,horizontal_align:a,vertical_align:o}}})}}const Kf={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new Uf,name:"button",viewRender:Nf,configRender:jf,createConfig(){return{version:2,config:y.cloneDeep(Vr)}},triggers:[Ko],translation:Wf},wn=({label:e,field:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.ColorInput,{label:e,placeholder:r("chart.visual_map.skip_range.follow_visual_map"),size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:t.value?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{t.onChange("")}}):null,...t})},Yf=({form:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.lt_min",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.lt_min")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.min",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.min")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.max",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.max")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.gt_max",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.gt_max")})})]})},Xf=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap"),{type:l,orient:i}=o,c=i==="horizontal",d=u=>p=>{typeof p!="string"&&u(p)};return l!=="continuous"?null:n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.text.1",control:a,render:({field:u})=>n.jsx(s.TextInput,{label:t("chart.visual_map.min_text"),...u})}),n.jsx(v.Controller,{name:"visualMap.text.0",control:a,render:({field:u})=>n.jsx(s.TextInput,{label:t("chart.visual_map.max_text"),...u})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.orient",control:a,render:({field:u})=>n.jsx(bt,{sx:{flex:1},...u})}),n.jsx(v.Controller,{name:"visualMap.calculable",control:a,render:({field:u})=>n.jsx(s.Checkbox,{label:t("chart.visual_map.calculable"),checked:u.value,onChange:p=>u.onChange(p.currentTarget.checked),styles:{root:{transform:"translateY(12px)"}}})})]}),n.jsxs(s.Group,{grow:!0,styles:{root:{flexDirection:c?"row-reverse":"row"}},children:[n.jsx(v.Controller,{name:"visualMap.itemWidth",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t(c?"chart.visual_map.bar_height":"chart.visual_map.bar_width"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.itemHeight",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t(c?"chart.visual_map.bar_width":"chart.visual_map.bar_height"),...u,onChange:d(u.onChange)})})]}),n.jsx(v.Controller,{name:"visualMap.inRange.color",control:a,render:({field:u})=>n.jsx(ho,{...u})}),n.jsx(Yf,{form:e})]})},Zf=({visualMap:e})=>{const{orient:t,itemWidth:r,itemHeight:a}=e,l=t==="horizontal"?r:a,{panel:i}=ae(),c=pn(e,i.variableValueMap);return n.jsx(ne,{children:n.jsx(he,{echarts:ce,option:{visualMap:c},style:{width:"100%",height:`${l+40}px`},notMerge:!0,theme:"merico-light"})})},Yo={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},Xo={gt:"(",gte:"[",lt:")",lte:"]"},Zo=(e,t)=>e===""?t:Number.isNaN(Number(e))?"INVALID VALUE":e,Jf=({form:e,index:t})=>{const{t:r}=m.useTranslation(),{control:a,watch:o}=e,l=o(`visualMap.pieces.${t}`),{lower:i,upper:c}=l,d=[Xo[i.symbol],Zo(i.value,r("chart.visual_map.min_value")),",",Zo(c.value,r("chart.visual_map.max_value")),Xo[c.symbol]].join(""),[u,p]=h.useState(!1);return n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs(s.Popover,{width:400,position:"bottom",withArrow:!0,shadow:"md",opened:u,onChange:p,withinPortal:!0,zIndex:340,children:[n.jsx(s.Popover.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-sm",px:0,onClick:()=>p(g=>!g),fw:"normal",ff:"monospace",children:d})}),n.jsx(s.Popover.Dropdown,{children:n.jsxs(s.Group,{wrap:"nowrap",gap:8,children:[n.jsx(v.Controller,{name:`visualMap.pieces.${t}.lower.value`,control:a,render:({field:g})=>n.jsx(s.TextInput,{...g,placeholder:r("chart.visual_map.min_value"),size:"xs",onChange:b=>g.onChange(b.currentTarget.value),error:g.value!==""&&Number.isNaN(Number(g.value))})}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.lower.symbol`,control:a,render:({field:g})=>n.jsx(s.Select,{size:"xs",data:Yo.lower,...g,onChange:Z(b=>g.onChange(b))})}),n.jsx(s.Text,{c:"dimmed",size:"sm",sx:{userSelect:"none",cursor:"default"},children:r("common.value").toLowerCase()}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.upper.symbol`,control:a,render:({field:g})=>n.jsx(s.Select,{size:"xs",data:Yo.upper,...g,onChange:Z(b=>g.onChange(b))})}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.upper.value`,control:a,render:({field:g})=>n.jsx(s.TextInput,{...g,size:"xs",placeholder:r("chart.visual_map.max_value"),onChange:b=>g.onChange(b.currentTarget.value),error:g.value!==""&&Number.isNaN(Number(g.value))})})]})})]})})},Hf=({form:e,index:t,remove:r})=>{const{control:a}=e,{t:o}=m.useTranslation();return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:(t+1).toString()}),n.jsx(s.Table.Td,{children:n.jsx(Jf,{form:e,index:t})}),n.jsx(s.Table.Td,{children:n.jsx(v.Controller,{name:`visualMap.pieces.${t}.label`,control:a,render:({field:l})=>n.jsx(s.TextInput,{size:"xs",placeholder:"",...l,onChange:i=>l.onChange(i.currentTarget.value)})})}),n.jsx(s.Table.Td,{children:n.jsx(v.Controller,{name:`visualMap.pieces.${t}.color`,control:a,render:({field:l})=>n.jsx(s.ColorInput,{label:o(""),placeholder:o("chart.color.label"),size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:l.value?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{l.onChange("")}}):null,...l})})}),n.jsx(s.Table.Td,{children:n.jsx(s.CloseButton,{size:"sm",onClick:()=>r(t)})})]})},Rf=({form:e})=>{const{t,i18n:r}=m.useTranslation(),{fields:a,append:o,remove:l}=v.useFieldArray({control:e.control,name:"visualMap.pieces"}),i=e.watch("visualMap.pieces"),c=a.map((u,p)=>({...u,...i[p]})),d=()=>{o(po())};return n.jsx(s.Stack,{children:n.jsxs(s.Table,{children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:t("chart.visual_map.piecewise.interval")}),n.jsx(s.Table.Th,{children:t("chart.visual_map.piecewise.piece_label")}),n.jsx(s.Table.Th,{children:t("chart.color.label")}),n.jsx(s.Table.Th,{style:{width:"40px"}})]})}),n.jsx(s.Table.Tbody,{children:c.map((u,p)=>n.jsx(Hf,{index:p,form:e,remove:l},u.id))}),n.jsx(s.Table.Tfoot,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{}),n.jsx(s.Table.Td,{colSpan:3,children:n.jsx(s.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:d,sx:{width:"50%"},mx:"auto",children:t("chart.visual_map.piecewise.add_a_piece")})}),n.jsx(s.Table.Td,{})]})})]})})},eb=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap");h.useMemo(()=>[{label:t("chart.visual_map.piecewise.mode.pieces"),value:"pieces"},{label:t("chart.visual_map.piecewise.mode.categories"),value:"categories"}],[r.language]);const{type:l,orient:i,piecewise_mode:c}=o,d=u=>p=>{typeof p!="string"&&u(p)};return l!=="piecewise"?null:n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"visualMap.precision",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.precision"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.orient",control:a,render:({field:u})=>n.jsx(bt,{sx:{flex:1},...u})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.itemWidth",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.item_width"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.itemHeight",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.item_height"),...u,onChange:d(u.onChange)})})]}),c==="pieces"&&n.jsx(Rf,{form:e})]})},$r=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap"),l=h.useMemo(()=>[{label:t("chart.visual_map.continuous.label"),value:"continuous"},{label:t("chart.visual_map.piecewise.label"),value:"piecewise"}],[r.language]),i=c=>{switch(c){case"continuous":e.setValue("visualMap",uo());break;case"piecewise":e.setValue("visualMap",Vp());break;default:return}};return n.jsx(ne,{children:n.jsxs(s.Stack,{children:[n.jsx(Zf,{visualMap:o}),n.jsx(v.Controller,{name:"visualMap.type",control:a,render:({field:c})=>n.jsx(s.SegmentedControl,{mt:-10,data:l,sx:{flex:1},...c,onChange:i})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.min",control:a,render:({field:c})=>n.jsx(io,{label:t("chart.visual_map.min_value"),...c})}),n.jsx(v.Controller,{name:"visualMap.max",control:a,render:({field:c})=>n.jsx(io,{label:t("chart.visual_map.max_value"),...c})})]}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(Xf,{form:e}),n.jsx(eb,{form:e})]})})};function tb(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{calendar:o,heat_block:l,tooltip:i,...c}=e;return{...c,calendar:{...o,data_key:a(o.data_key)},heat_block:{...l,data_key:a(l.data_key)},tooltip:{...i,metrics:i.metrics.map(d=>({...d,data_key:a(d.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function nb(e){const{heat_block:t}=e;let{min:r,max:a}=t;return typeof r!="number"&&(r=0),typeof a!="number"&&(a=100),{...e,heat_block:{...t,min:{type:"static",value:r},max:{type:"static",value:a}}}}function rb(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function ab(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function sb(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}const ob=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function lb(e){return n.jsx(n.Fragment,{})}function ib(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const Jo={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:ib,configRender:lb,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Ar={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de},tooltip:{metrics:[]},visualMap:rt()};function cb(e,t,r){if(!e)return r[0];try{return[t,M(t).add(1,"year").subtract(1,"day").valueOf()]}catch(a){return console.error(a),r[0]}}function db(e,t,r){const a=cb(e,t,r);return{top:50,left:25,right:5,cellSize:["auto",13],range:a,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function ub(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function pb(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(r=>({name:r,icon:"circle"}))}}function hb(e,t,r){return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:r}:Object.entries(t).map(([a,o])=>({type:"heatmap",name:a,coordinateSystem:"calendar",calendarIndex:0,data:o}))}const gb=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function fb({conf:e,valueFormatters:t,dataDict:r,params:a,metricUnitMap:o}){const{value:l}=a,[i,c]=l,u=[{label:e.heat_block.name,value:t.heat_block(c),unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""}],p=r[i];return p&&e.tooltip.metrics.forEach(g=>{const b=$(g.data_key),_=o[g.name]??"";u.push({label:g.name,value:gb(y.get(p,b.columnKey,"")),unit:_})}),u}function bb(e,t,r){const a=$(e.calendar.data_key),o=y.keyBy(t[a.queryID],a.columnKey),l=e.tooltip.metrics.reduce((i,{unit:c,name:d})=>(c.show_in_tooltip&&(i[d]=c.text),i),{});return X.getTooltip({formatter:function(i){const d=fb({conf:e,valueFormatters:r,dataDict:o,params:i,metricUnitMap:l}).map(g=>`
|
|
119
|
+
`}const Ug=(e,t)=>r=>{const{seriesName:a,value:o}=r;switch(a){case t.Box:return Fg(e,o);case t.Outlier:return jg(e,o);case t.Scatter:return Wg(e,o)}};function Kg({config:e,seriesNames:t}){return X.getTooltip({trigger:"item",formatter:Ug(e,t)})}function _n(e,t){t||(t="none");const r=[];return e.x_axis_scroll&&r.push({type:"inside",xAxisIndex:[0],filterMode:t,minSpan:1}),e.y_axis_scroll&&r.push({type:"inside",yAxisIndex:[0],filterMode:t,minSpan:1}),e.x_axis_slider&&r.push({type:"slider",xAxisIndex:[0],filterMode:t,bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),r}function Yg({min:e,max:t}){if(e<=110)return Math.min(0,e);if(e<=200)return 100;const r=je.floor(je.log10(e)),a=Math.pow(10,r),o=Math.pow(10,r-1);return e/a<=2?y.round(e,-1*(r-1))-o:y.round(e,-1*r)-a}function Xg(e){return{Box:e("viz.boxplot.box"),Scatter:e("viz.boxplot.scatter"),Outlier:e("viz.boxplot.outlier")}}function Zg({config:e,data:t,variables:r,t:a}){const{x_axis:o,y_axis:l,reference_lines:i}=e,c=Vg(e,t),d=Ke(o.axisLabel.overflow.on_axis),u=Xg(a),p=Gg(e,c).map(g=>({...g,name:y.get(u,g.name,g.name)}));return{dataZoom:_n(e.dataZoom,"filter"),grid:Pg(e),dataset:c,legend:$g({config:e,seriesNames:u}),tooltip:Kg({config:e,seriesNames:u}),xAxis:[X.getXAxis({type:"category",name:o.name,nameGap:25,nameLocation:"center",nameTextStyle:{align:"center"},axisLabel:{...o.axisLabel,...d,formatter:Me(o.axisLabel.formatter)}})],yAxis:[X.getYAxis({name:l.name,minInterval:1,axisLabel:{formatter:function(g){return Y(g,l.label_formatter)}},min:Yg})],series:[...p,...Ag(i,r,t)]}}function Jg({context:e,instance:t}){const{t:r}=m.useTranslation(),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=e.data,{width:i,height:c}=e.viewport,d=y.defaults({},a,Cr),u=Pe({vizManager:e.vizManager,instance:t}),p=Ve(u.triggerManager,Eo.id),g=Dt(l,d.x_axis.data_key),b=h.useCallback(D=>{const z=y.get(g,D.name,{error:"rowData is not found"});p.forEach(I=>{u.runInteraction(I.id,{...D,rowData:z})})},[g,p,u]),_=h.useRef(null),w=h.useCallback(()=>{var z;const D=(z=_.current)==null?void 0:z.getEchartsInstance();D&&fe(t,D.getOption())},[]),x=h.useMemo(()=>({click:b,finished:w}),[b,w]),S=h.useMemo(()=>Zg({config:d,data:l,variables:o,t:r}),[d,l,o,r]);return!a||!i||!c?null:n.jsx(ve,{width:i,height:c,children:n.jsx(he,{echarts:ce,option:S,ref:_,style:Yt(i,c),onEvents:x,notMerge:!0,theme:"merico-light"})})}function se({canSubmit:e,buttonRef:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Group,{justify:"flex-start",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(s.Text,{size:"sm",children:r("viz.viz_config_banner")}),n.jsx(s.ActionIcon,{ref:t,type:"submit",mr:5,variant:"filled",color:"blue",disabled:!e,children:n.jsx(T.IconDeviceFloppy,{size:20})})]})}const Ir=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("common.align.horizontal.left"),value:"left"},{label:l("common.align.horizontal.center"),value:"center"},{label:l("common.align.horizontal.right"),value:"right"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("common.align.horizontal.label"),data:c,value:t,onChange:Z(r),sx:a})}),jo=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("common.align.vertical.top"),value:"top"},{label:l("common.align.vertical.center"),value:"center"},{label:l("common.align.vertical.bottom"),value:"bottom"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("common.align.vertical.label"),data:c,value:t,onChange:Z(r),sx:a})}),Wo=pt.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Hg=[{from:0,to:0},{from:100,to:100}];class Rg{constructor(){V(this,"steps",new Map);V(this,"interpolation");V(this,"onChange");G.makeAutoObservable(this,{steps:G.observable},{deep:!1}),G.reaction(()=>G.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(t){for(const r of t)this.steps.set(r.to,r.from)}notifyStepChange(){var t;(t=this.onChange)==null||t.call(this,Array.from(this.steps.entries()).map(([r,a])=>({to:r,from:a})).sort((r,a)=>r.to-a.to||r.from-a.from))}fromProps(t){t.steps.length<2?this.setSteps(Hg):this.setSteps(t.steps),this.interpolation=t.interpolation,this.onChange=t.onChange}changeStep(t,r){t==null?this.steps.delete(r):this.steps.set(r,t)}getStepFromValue(t){return this.steps.get(t)}}function Uo(e){if(typeof e=="number")return String(e)}function ef(e){const{t}=m.useTranslation(),{onChange:r,color:a,index:o,value:l}=e,{classes:i}=Wo(),[c,d]=h.useState(Uo(l)),[u,{setTrue:p,setFalse:g}]=O.useBoolean(!1),b=o%2===1,_=b&&l!=null,w=!b&&l!=null,x=`map ${l} to color ${o}`,S=()=>{d(Uo(l)),g()},D=()=>{g(),r==null||r(Number(c))},z=()=>{g(),r==null||r(null)},I=Y(l??null,{output:"number",mantissa:10,trimMantissa:!0,average:!0,absolute:!1}),A=!c||Number.isNaN(Number(c));return n.jsxs("div",{"data-testid":`palette-item-${o}`,className:i.paletteItem,children:[n.jsx(s.Text,{title:x,style:{opacity:_?1:0},c:"dimmed",size:"sm",className:"palette-value--up palette-value",children:I}),n.jsxs(s.Popover,{width:240,trapFocus:!0,opened:u,onClose:g,zIndex:340,withinPortal:!0,children:[n.jsx(s.Popover.Target,{children:n.jsx("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:p,style:{"--shadow-color":Ge(a).alpha(.5).hex(),backgroundColor:a}})}),n.jsxs(s.Popover.Dropdown,{children:[n.jsx(s.Tooltip,{withinPortal:!0,zIndex:340,label:t("common.actions.close"),children:n.jsx(s.CloseButton,{"data-testid":"palette-item-cancel",size:"sm",color:"gray",onClick:S,style:{position:"absolute",top:"0.5em",right:"0.8em"}})}),n.jsxs(s.Stack,{children:[n.jsx(s.TextInput,{size:"xs",label:t("style.color.interpolation.palette.mapping.value_input_label"),value:c,onChange:E=>{const U=E.currentTarget.value;d(U)},error:c&&A}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{variant:"light",color:"red",size:"xs",onClick:z,leftSection:n.jsx(T.IconTrash,{size:16}),children:t("common.actions.delete")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),"data-testid":"palette-item-ok",size:"xs",onClick:D,disabled:A,children:t("common.actions.save")})]})]})]})]}),n.jsx(s.Text,{title:x,style:{opacity:w?1:0},c:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:I})]})}const tf=k.observer(({model:e})=>{const{classes:t}=Wo(),r=y.range(0,13,1).map(a=>100/12*a).map(a=>[e.interpolation.getColor(a),a]);return n.jsx("div",{className:t.palette,children:r.map(([a,o],l)=>n.jsx(ef,{index:l,color:a,value:e.getStepFromValue(o),onChange:i=>e.changeStep(i,o)},a))})}),nf=k.observer(function(t){const r=O.useCreation(()=>new Rg,[]);return h.useEffect(()=>{r.fromProps(t)}),r.interpolation==null?null:n.jsx(tf,{model:r})}),rf=e=>{const{t,i18n:r}=m.useTranslation(),{value:a,onChange:o,colorManager:l}=e,i=l.getColorInterpolations(),[c,d]=h.useState(a),u=l.decodeInterpolation(c.interpolation)||i[0],[p,{setTrue:g,setFalse:b}]=O.useBoolean(),_=h.useMemo(()=>{const z=y.groupBy(i,"category");return Object.entries(z).map(([I,A])=>({group:t(`style.color.interpolation.palette.category.${I}`),items:A.map(E=>({label:t(E.displayName),value:l.encodeColor(E)}))}))},[r.language]);function w(z){z&&d(I=>({...I,interpolation:z}))}const x=()=>{b(),o==null||o(G.toJS(c))};function S(z){d(I=>({...I,steps:z}))}const D=()=>{b(),d(a)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"outline",onClick:g,children:t(u==null?void 0:u.displayName)}),n.jsx(s.Modal,{size:508,title:t("style.color.interpolation.setup"),opened:p,onClose:b,zIndex:320,children:p&&n.jsxs(s.Stack,{"data-testid":"color-interpolation-modal",children:[n.jsx(s.Select,{label:t("style.color.interpolation.palette.label"),value:c.interpolation,data:_,onChange:w,comboboxProps:{withinPortal:!0,zIndex:340},maxDropdownHeight:500}),n.jsx(nf,{steps:c.steps,interpolation:u,onChange:S}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:D,variant:"subtle",children:t("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:x,children:t("common.actions.save")})]})]})})]})},af=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.color.type.static"),value:"static"},{label:l("style.color.type.interpolation"),value:"interpolation"},{label:l("style.color.type.none"),value:"none"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.color.type.label"),data:c,value:t,onChange:Z(r),sx:a})}),sf=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.flex.justify_content.left"),value:"left"},{label:l("style.flex.justify_content.center"),value:"center"},{label:l("style.flex.justify_content.right"),value:"right"},{label:l("style.flex.justify_content.space_between"),value:"space-between"},{label:l("style.flex.justify_content.space_around"),value:"space-around"},{label:l("style.flex.justify_content.space_evenly"),value:"space-evenly"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.flex.justify_content.label"),data:c,value:t,onChange:Z(r),sx:a})}),of=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("style.flex.align_items.start"),value:"start"},{label:l("style.flex.align_items.center"),value:"center"},{label:l("style.flex.align_items.end"),value:"end"},{label:l("style.flex.align_items.stretch"),value:"stretch"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("style.flex.align_items.label"),data:c,value:t,onChange:Z(r),sx:a})}),lf=({value:e,index:t,children:r})=>{const[a,{setTrue:o,setFalse:l}]=O.useBoolean(!1),{ref:i,handleRef:c}=an.useSortable({id:e,index:t});return n.jsx(s.Tabs.Tab,{ref:i,value:e,leftSection:n.jsx(T.IconGripHorizontal,{size:14,color:a||t===0?"rgb(34, 139, 230)":"transparent"}),onMouseEnter:o,onMouseLeave:l,children:r})},cf=({fieldArray:e,add:t,addButtonText:r,renderTabName:a,controlledFields:o})=>{const l=i=>{const{source:c,target:d}=i.operation,u=o.findIndex(g=>g.id===c.id),p=d.index;e.move(u,p)};return n.jsxs(s.Tabs.List,{children:[n.jsx(rn.DragDropProvider,{onDragEnd:l,children:o.map((i,c)=>n.jsx(lf,{value:i.id,index:c,children:a(i,c)},i.id))}),n.jsx(s.Tabs.Tab,{onClick:t,value:"add",children:n.jsx(s.Tooltip,{label:r,children:n.jsx(s.Center,{children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})})})]})},df={tab:{paddingTop:"4px",paddingBottom:"4px"},panel:{padding:"0px"}},R=({control:e,watch:t,name:r,getItem:a,children:o,addButtonText:l,deleteButtonText:i,renderTabName:c,deleteDisalbed:d})=>{var A;const u=v.useFieldArray({control:e,name:r}),{fields:p,append:g,remove:b}=u,_=t(r),w=p.map((E,U)=>({...E,..._[U]})),x=((A=y.last(w))==null?void 0:A.id)??null,[S,D]=h.useState(x),z=E=>{E!=="add"&&D(E)};h.useEffect(()=>{D(E=>x===E?E:x)},[x]);const I=()=>{const E=a();u.append(E),D(E.id)};return n.jsxs(s.Tabs,{value:S,onChange:z,styles:df,children:[n.jsx(cf,{fieldArray:u,add:I,addButtonText:l,renderTabName:c,controlledFields:w}),w.map((E,U)=>n.jsx(s.Tabs.Panel,{value:E.id,children:n.jsxs(s.Stack,{children:[o({field:E,index:U}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed"}),n.jsx(s.Button,{leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:()=>b(U),sx:{top:15,right:5},disabled:d==null?void 0:d({field:E,index:U,fields:w}),children:i})]})},E.id))]})},mn=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=l=>i=>{t({...e,[l]:i})};return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{variant:"dashed",label:a("chart.zooming.scroll.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.scroll.x_axis"),checked:e.x_axis_scroll,onChange:l=>o("x_axis_scroll")(l.currentTarget.checked)})}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.scroll.y_axis"),checked:e.y_axis_scroll,onChange:l=>o("y_axis_scroll")(l.currentTarget.checked)})})]}),n.jsx(s.Divider,{variant:"dashed",label:a("chart.zooming.slider.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.slider.x_axis"),checked:e.x_axis_slider,onChange:l=>o("x_axis_slider")(l.currentTarget.checked)})}),n.jsx(s.Tooltip,{label:a("chart.zooming.slider.y_axis_disabled"),children:n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.zooming.slider.y_axis"),disabled:!e.y_axis_slider,checked:e.y_axis_slider,onChange:l=>o("y_axis_slider")(l.currentTarget.checked)})})})]})]})}),bt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={},disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>[{label:i("chart.orientation.horizontal"),value:"horizontal"},{label:i("chart.orientation.vertical"),value:"vertical"}],[c.language]);return n.jsx(s.Select,{ref:l,label:e??i("chart.orientation.label"),data:d,value:t,onChange:Z(r),sx:a,disabled:o})}),uf=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=t("legend"),o=(l,i)=>{const c={...a,orient:l};l==="horizontal"?(c.top="0",c.left="auto",c.right="10",c.bottom="auto"):(c.top="10",c.left="auto",c.right="0",c.bottom="auto"),i(c)};return n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",mt:20,children:n.jsx(v.Controller,{name:"legend.show",control:e,render:({field:l})=>n.jsx(s.Switch,{label:r("chart.legend.show_legend"),sx:{flex:1},checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})})}),n.jsx(s.Group,{children:n.jsx(v.Controller,{name:"legend",control:e,render:({field:l})=>n.jsx(bt,{sx:{flex:1},value:l.value.orient,onChange:i=>{o(i,l.onChange)},disabled:!a.show})})})]})};function pf({control:e,index:t,variableOptions:r}){const{t:a}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:o})=>n.jsx(s.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...o})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:o})=>n.jsx(s.Select,{label:a("common.value"),required:!0,data:r,sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:o})=>n.jsx(s.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.placeholder"),required:!0,sx:{flex:1},...o})})]})}function hf({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:""}),l=h.useMemo(()=>r.map(c=>({label:c.name,value:c.name})),[r]),i=(c,d)=>{const u=c.name.trim();return u||d+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:i,children:({field:c,index:d})=>n.jsx(pf,{control:e,index:d,variableOptions:l})})}const gf=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("chart.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},ff=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(gf,{control:e,index:i})})]})};function bf({control:e,watch:t}){return n.jsx(s.Stack,{children:n.jsx(ff,{control:e,watch:t})})}const st=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l}=m.useTranslation();return n.jsx(s.NumberInput,{ref:o,label:e??l("chart.rotate"),hideControls:!0,min:-90,max:90,rightSection:n.jsx(s.Text,{size:"xs",c:"dimmed",children:l("chart.degree")}),sx:a,styles:{section:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},value:t,onChange:i=>{typeof i!="string"&&r(i)}})}),yf=({control:e,watch:t})=>{const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.x_axis_name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})},Vr={root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}},vf=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function _f({format:e}){const{t}=m.useTranslation(),[r,{toggle:a}]=te.useDisclosure(!1);return n.jsxs(s.Box,{children:[n.jsx(s.Button,{variant:"subtle",w:"100%",size:"compact-sm",onClick:a,leftSection:r?n.jsx(T.IconChevronUp,{size:14}):n.jsx(T.IconChevronDown,{size:14}),children:t(r?"numbro.format.preview.close":"numbro.format.preview.open")}),n.jsx(s.Collapse,{in:r,children:r&&n.jsxs(s.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:t("numbro.format.preview.input")}),n.jsx(s.Table.Th,{children:t("numbro.format.preview.output")})]})}),n.jsx(s.Table.Tbody,{children:vf.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:o}),n.jsx(s.Table.Td,{children:n.jsx(ne,{children:Y(o,e)})})]},o))})]})})]})}function mf({value:e,onChange:t,size:r},a){const{t:o}=m.useTranslation(),l=p=>{t({...e,output:p,absolute:!1,average:!1,trimMantissa:!1,mantissa:0})},i=p=>{if(typeof p=="string")return;const g=p===0?!1:e.trimMantissa;t({...e,mantissa:p,trimMantissa:g})},c=p=>{t({...e,trimMantissa:p.currentTarget.checked})},d=p=>{t({...e,average:p.currentTarget.checked})},u=p=>{const g={...e,absolute:p.currentTarget.checked};t(g)};return n.jsxs(s.Stack,{ref:a,children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Select,{label:o("numbro.format.label"),size:r,data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:Z(l),sx:{flexGrow:1}}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.absolute")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.absolute_description")})]}),size:r,checked:e.absolute,onChange:u,sx:{flexGrow:1},styles:Vr}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.abbreviation")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.abbreviation_description")})]}),size:r,checked:e.average,onChange:d,disabled:e.output!=="number",sx:{flexGrow:1},styles:Vr})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{label:o("numbro.format.mantissa"),size:r,defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),n.jsx(s.Switch,{label:n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"sm",children:o("numbro.format.trim_mantissa")}),n.jsx(s.Text,{size:"12px",c:"gray",children:o("numbro.format.trim_mantissa_description")})]}),size:r,checked:e.trimMantissa,onChange:c,disabled:e.mantissa===0,styles:Vr}),n.jsx(s.Box,{})]}),n.jsx(_f,{format:e})]})}const Ne=h.forwardRef(mf),wf=({control:e,watch:t})=>{const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.y_axis_name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"y_axis.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-15,variant:"dashed",label:r("chart.axis.section_title.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.label_formatter",control:e,render:({field:a})=>n.jsx(Ne,{...a})})]})]})};function xf({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},r,Cr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["x_axis","y_axis","reference_lines","color","dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Legend",children:t("chart.legend.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Style",children:t("chart.style.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(yf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(wf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Legend",children:n.jsx(uf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(bf,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Style",children:n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"color",control:i,render:({field:g})=>n.jsx(ye,{label:t("chart.color.label"),...g})})})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(hf,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function Cf(e){return y.omit(e,"variables")}function Sf(e){const{label_formatter:t=de,...r}=e.y_axis;return{...e,y_axis:{...r,label_formatter:t}}}function Tf(e){const t={rotate:0,formatter:_e()},{axisLabel:r=t,...a}=e.x_axis;return{...e,x_axis:{...a,axisLabel:r}}}function kf(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function Df(e){delete e.config;const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function zf(e){const t={tooltip:{metrics:[]}};return y.defaultsDeep(t,e)}function Mf(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis:o,y_axis:l,tooltip:i,...c}=e;return{...c,x_axis:{...o,data_key:a(o.data_key)},y_axis:{...l,data_key:a(l.data_key)},tooltip:{...i,metrics:i.metrics.map(d=>({...d,data_key:a(d.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function If(e){const t={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return y.defaultsDeep(t,e)}function Vf(e){const{dataZoom:t,...r}=e;return{...r,dataZoom:t??Ao()}}function Pf(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function $f(e){const{y_axis:t}=e;return{...e,y_axis:{...t,unit:t.unit??K()}}}class Af extends J{constructor(){super(...arguments);V(this,"VERSION",12)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(i=>{a.variables.find(c=>c.name===i.name)||a.addVariable(i)}),{...r,version:2,config:Cf(o)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:Sf(a)}}),this.version(4,r=>{const{config:a}=r;return{...r,version:4,config:Tf(a)}}),this.version(5,r=>{const{config:a}=r;return{...r,version:5,config:kf(a)}}),this.version(6,r=>{const{config:a}=r;return{...r,version:6,config:Df(a)}}),this.version(7,r=>{const{config:a}=r;return{...r,version:7,config:zf(a)}}),this.version(8,(r,a)=>{const{config:o}=r;return{...r,version:8,config:Mf(o,a)}}),this.version(9,r=>{const{config:a}=r;return{...r,version:9,config:If(a)}}),this.version(10,r=>{const{config:a}=r;return{...r,version:10,config:Vf(a)}}),this.version(11,r=>{const{config:a}=r;return{...r,version:11,config:Pf(a)}}),this.version(12,r=>{const{config:a}=r;return{...r,version:12,config:$f(a)}})}}const Ef={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Af,name:"boxplot",viewRender:Jg,configRender:xf,createConfig(){return{version:12,config:y.cloneDeep(Cr)}},triggers:[Eo],translation:zh},Ko={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:qf,configRender:Bf,payload:[]};function Bf(e){return n.jsx(n.Fragment,{})}function qf(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.button.click.label")})}const Pr={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},Of={left:"flex-start",center:"center",right:"flex-end"},Lf={top:"flex-start",center:"center",bottom:"flex-end"},Nf=k.observer(({context:e,instance:t})=>{const r=Pe({vizManager:e.vizManager,instance:t}),a=Ve(r.triggerManager,Ko.id),o=H(),{value:l}=q(e.instanceData,"config"),i=h.useMemo(()=>y.defaultsDeep({},l,Pr),[l]),{content:c,horizontal_align:d,vertical_align:u,compact:p,size:g,...b}=i,{width:_,height:w}=e.viewport,x=o.payloadForSQL,S=()=>{a.forEach(z=>{r.runInteraction(z.id,{})})},D=p?`compact-${g}`:g;return n.jsx(s.Center,{sx:{width:_,height:w,justifyContent:Of[d],alignItems:Lf[u]},children:n.jsx(s.Button,{size:D,...b,onClick:S,children:y.template(c)(x)})})}),Gf=({value:e,onChange:t,label:r})=>{const a=s.useMantineTheme(),o=h.useCallback(i=>()=>t(i),[t]),l=i=>e===i;return n.jsxs(s.Stack,{gap:2,children:[n.jsx(s.Text,{size:"14px",fw:500,children:r}),n.jsx(s.Group,{justify:"flex-start",gap:"xs",children:Object.keys(a.colors).map(i=>{const c=a.colors[i][6];return n.jsx(s.ColorSwatch,{color:c,onClick:o(i),radius:4,size:26,sx:{cursor:"pointer"},children:l(i)&&n.jsx(s.CheckIcon,{width:10,color:"white"})},i)})})]})},Ff=["xs","sm","md","lg","xl"],$r=h.forwardRef(({label:e,value:t,onChange:r,sx:a,disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>Ff.map(u=>({label:i(`style.size.${u}`),value:u})),[c.language]);return n.jsx(s.Select,{ref:l,data:d,label:e,value:t,onChange:Z(r),sx:a,disabled:!0})}),Qf=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}];function jf({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Pr),[t]),o=a;h.useEffect(()=>{!y.isEqual(a,o)&&(console.log("config malformed, resetting to defaults",a,o),r(o))},[a,o]);const{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),c(["content","variant","color","size","compact","horizontal_align","vertical_align"]),n.jsxs("form",{onSubmit:i(r),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{control:l,name:"content",render:({field:p})=>n.jsx(s.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...p,required:!0})}),n.jsx(s.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"variant",render:({field:p})=>n.jsx(s.Select,{label:"Variant",data:Qf,...p})}),n.jsx(v.Controller,{control:l,name:"color",render:({field:p})=>n.jsx(Gf,{label:"Theme",...p})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"size",render:({field:p})=>n.jsx($r,{label:"Size",...p})}),n.jsx(v.Controller,{control:l,name:"compact",render:({field:p})=>n.jsx(s.Checkbox,{label:"Compact",checked:p.value,onChange:g=>p.onChange(g.currentTarget.checked),mt:26})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{control:l,name:"horizontal_align",render:({field:p})=>n.jsx(Ir,{...p})}),n.jsx(v.Controller,{control:l,name:"vertical_align",render:({field:p})=>n.jsx(jo,{...p})})]})]})]})}const Wf=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class Uf extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{horizontal_align:a="left",vertical_align:o="center",...l}=r.config;return{...r,version:2,config:{...l,horizontal_align:a,vertical_align:o}}})}}const Kf={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new Uf,name:"button",viewRender:Nf,configRender:jf,createConfig(){return{version:2,config:y.cloneDeep(Pr)}},triggers:[Ko],translation:Wf},wn=({label:e,field:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.ColorInput,{label:e,placeholder:r("chart.visual_map.skip_range.follow_visual_map"),size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:t.value?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{t.onChange("")}}):null,...t})},Yf=({form:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.lt_min",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.lt_min")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.min",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.min")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.max",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.max")})}),n.jsx(v.Controller,{control:e.control,name:"visualMap.skipRange.gt_max",render:({field:r})=>n.jsx(wn,{field:r,label:t("chart.visual_map.skip_range.gt_max")})})]})},Xf=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap"),{type:l,orient:i}=o,c=i==="horizontal",d=u=>p=>{typeof p!="string"&&u(p)};return l!=="continuous"?null:n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.text.1",control:a,render:({field:u})=>n.jsx(s.TextInput,{label:t("chart.visual_map.min_text"),...u})}),n.jsx(v.Controller,{name:"visualMap.text.0",control:a,render:({field:u})=>n.jsx(s.TextInput,{label:t("chart.visual_map.max_text"),...u})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.orient",control:a,render:({field:u})=>n.jsx(bt,{sx:{flex:1},...u})}),n.jsx(v.Controller,{name:"visualMap.calculable",control:a,render:({field:u})=>n.jsx(s.Checkbox,{label:t("chart.visual_map.calculable"),checked:u.value,onChange:p=>u.onChange(p.currentTarget.checked),styles:{root:{transform:"translateY(12px)"}}})})]}),n.jsxs(s.Group,{grow:!0,styles:{root:{flexDirection:c?"row-reverse":"row"}},children:[n.jsx(v.Controller,{name:"visualMap.itemWidth",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t(c?"chart.visual_map.bar_height":"chart.visual_map.bar_width"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.itemHeight",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t(c?"chart.visual_map.bar_width":"chart.visual_map.bar_height"),...u,onChange:d(u.onChange)})})]}),n.jsx(v.Controller,{name:"visualMap.inRange.color",control:a,render:({field:u})=>n.jsx(ho,{...u})}),n.jsx(Yf,{form:e})]})},Zf=({visualMap:e})=>{const{orient:t,itemWidth:r,itemHeight:a}=e,l=t==="horizontal"?r:a,{panel:i}=ae(),c=pn(e,i.variableValueMap);return n.jsx(ne,{children:n.jsx(he,{echarts:ce,option:{visualMap:c},style:{width:"100%",height:`${l+40}px`},notMerge:!0,theme:"merico-light"})})},Yo={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},Xo={gt:"(",gte:"[",lt:")",lte:"]"},Zo=(e,t)=>e===""?t:Number.isNaN(Number(e))?"INVALID VALUE":e,Jf=({form:e,index:t})=>{const{t:r}=m.useTranslation(),{control:a,watch:o}=e,l=o(`visualMap.pieces.${t}`),{lower:i,upper:c}=l,d=[Xo[i.symbol],Zo(i.value,r("chart.visual_map.min_value")),",",Zo(c.value,r("chart.visual_map.max_value")),Xo[c.symbol]].join(""),[u,p]=h.useState(!1);return n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs(s.Popover,{width:400,position:"bottom",withArrow:!0,shadow:"md",opened:u,onChange:p,withinPortal:!0,zIndex:340,children:[n.jsx(s.Popover.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-sm",px:0,onClick:()=>p(g=>!g),fw:"normal",ff:"monospace",children:d})}),n.jsx(s.Popover.Dropdown,{children:n.jsxs(s.Group,{wrap:"nowrap",gap:8,children:[n.jsx(v.Controller,{name:`visualMap.pieces.${t}.lower.value`,control:a,render:({field:g})=>n.jsx(s.TextInput,{...g,placeholder:r("chart.visual_map.min_value"),size:"xs",onChange:b=>g.onChange(b.currentTarget.value),error:g.value!==""&&Number.isNaN(Number(g.value))})}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.lower.symbol`,control:a,render:({field:g})=>n.jsx(s.Select,{size:"xs",data:Yo.lower,...g,onChange:Z(b=>g.onChange(b))})}),n.jsx(s.Text,{c:"dimmed",size:"sm",sx:{userSelect:"none",cursor:"default"},children:r("common.value").toLowerCase()}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.upper.symbol`,control:a,render:({field:g})=>n.jsx(s.Select,{size:"xs",data:Yo.upper,...g,onChange:Z(b=>g.onChange(b))})}),n.jsx(v.Controller,{name:`visualMap.pieces.${t}.upper.value`,control:a,render:({field:g})=>n.jsx(s.TextInput,{...g,size:"xs",placeholder:r("chart.visual_map.max_value"),onChange:b=>g.onChange(b.currentTarget.value),error:g.value!==""&&Number.isNaN(Number(g.value))})})]})})]})})},Hf=({form:e,index:t,remove:r})=>{const{control:a}=e,{t:o}=m.useTranslation();return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:(t+1).toString()}),n.jsx(s.Table.Td,{children:n.jsx(Jf,{form:e,index:t})}),n.jsx(s.Table.Td,{children:n.jsx(v.Controller,{name:`visualMap.pieces.${t}.label`,control:a,render:({field:l})=>n.jsx(s.TextInput,{size:"xs",placeholder:"",...l,onChange:i=>l.onChange(i.currentTarget.value)})})}),n.jsx(s.Table.Td,{children:n.jsx(v.Controller,{name:`visualMap.pieces.${t}.color`,control:a,render:({field:l})=>n.jsx(s.ColorInput,{label:o(""),placeholder:o("chart.color.label"),size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:l.value?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{l.onChange("")}}):null,...l})})}),n.jsx(s.Table.Td,{children:n.jsx(s.CloseButton,{size:"sm",onClick:()=>r(t)})})]})},Rf=({form:e})=>{const{t,i18n:r}=m.useTranslation(),{fields:a,append:o,remove:l}=v.useFieldArray({control:e.control,name:"visualMap.pieces"}),i=e.watch("visualMap.pieces"),c=a.map((u,p)=>({...u,...i[p]})),d=()=>{o(po())};return n.jsx(s.Stack,{children:n.jsxs(s.Table,{children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:t("chart.visual_map.piecewise.interval")}),n.jsx(s.Table.Th,{children:t("chart.visual_map.piecewise.piece_label")}),n.jsx(s.Table.Th,{children:t("chart.color.label")}),n.jsx(s.Table.Th,{style:{width:"40px"}})]})}),n.jsx(s.Table.Tbody,{children:c.map((u,p)=>n.jsx(Hf,{index:p,form:e,remove:l},u.id))}),n.jsx(s.Table.Tfoot,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{}),n.jsx(s.Table.Td,{colSpan:3,children:n.jsx(s.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:d,sx:{width:"50%"},mx:"auto",children:t("chart.visual_map.piecewise.add_a_piece")})}),n.jsx(s.Table.Td,{})]})})]})})},eb=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap");h.useMemo(()=>[{label:t("chart.visual_map.piecewise.mode.pieces"),value:"pieces"},{label:t("chart.visual_map.piecewise.mode.categories"),value:"categories"}],[r.language]);const{type:l,orient:i,piecewise_mode:c}=o,d=u=>p=>{typeof p!="string"&&u(p)};return l!=="piecewise"?null:n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"visualMap.precision",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.precision"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.orient",control:a,render:({field:u})=>n.jsx(bt,{sx:{flex:1},...u})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.itemWidth",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.item_width"),...u,onChange:d(u.onChange)})}),n.jsx(v.Controller,{name:"visualMap.itemHeight",control:a,render:({field:u})=>n.jsx(s.NumberInput,{label:t("chart.visual_map.item_height"),...u,onChange:d(u.onChange)})})]}),c==="pieces"&&n.jsx(Rf,{form:e})]})},Ar=({form:e})=>{const{t,i18n:r}=m.useTranslation(),a=e.control,o=e.watch("visualMap"),l=h.useMemo(()=>[{label:t("chart.visual_map.continuous.label"),value:"continuous"},{label:t("chart.visual_map.piecewise.label"),value:"piecewise"}],[r.language]),i=c=>{switch(c){case"continuous":e.setValue("visualMap",uo());break;case"piecewise":e.setValue("visualMap",Vp());break;default:return}};return n.jsx(ne,{children:n.jsxs(s.Stack,{children:[n.jsx(Zf,{visualMap:o}),n.jsx(v.Controller,{name:"visualMap.type",control:a,render:({field:c})=>n.jsx(s.SegmentedControl,{mt:-10,data:l,sx:{flex:1},...c,onChange:i})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"visualMap.min",control:a,render:({field:c})=>n.jsx(io,{label:t("chart.visual_map.min_value"),...c})}),n.jsx(v.Controller,{name:"visualMap.max",control:a,render:({field:c})=>n.jsx(io,{label:t("chart.visual_map.max_value"),...c})})]}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(Xf,{form:e}),n.jsx(eb,{form:e})]})})};function tb(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{calendar:o,heat_block:l,tooltip:i,...c}=e;return{...c,calendar:{...o,data_key:a(o.data_key)},heat_block:{...l,data_key:a(l.data_key)},tooltip:{...i,metrics:i.metrics.map(d=>({...d,data_key:a(d.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function nb(e){const{heat_block:t}=e;let{min:r,max:a}=t;return typeof r!="number"&&(r=0),typeof a!="number"&&(a=100),{...e,heat_block:{...t,min:{type:"static",value:r},max:{type:"static",value:a}}}}function rb(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function ab(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function sb(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}const ob=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function lb(e){return n.jsx(n.Fragment,{})}function ib(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const Jo={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:ib,configRender:lb,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Er={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de},tooltip:{metrics:[]},visualMap:rt()};function cb(e,t,r){if(!e)return r[0];try{return[t,M(t).add(1,"year").subtract(1,"day").valueOf()]}catch(a){return console.error(a),r[0]}}function db(e,t,r){const a=cb(e,t,r);return{top:50,left:25,right:5,cellSize:["auto",13],range:a,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function ub(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function pb(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(r=>({name:r,icon:"circle"}))}}function hb(e,t,r){return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:r}:Object.entries(t).map(([a,o])=>({type:"heatmap",name:a,coordinateSystem:"calendar",calendarIndex:0,data:o}))}const gb=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function fb({conf:e,valueFormatters:t,dataDict:r,params:a,metricUnitMap:o}){const{value:l}=a,[i,c]=l,u=[{label:e.heat_block.name,value:t.heat_block(c),unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""}],p=r[i];return p&&e.tooltip.metrics.forEach(g=>{const b=$(g.data_key),_=o[g.name]??"";u.push({label:g.name,value:gb(y.get(p,b.columnKey,"")),unit:_})}),u}function bb(e,t,r){const a=$(e.calendar.data_key),o=y.keyBy(t[a.queryID],a.columnKey),l=e.tooltip.metrics.reduce((i,{unit:c,name:d})=>(c.show_in_tooltip&&(i[d]=c.text),i),{});return X.getTooltip({formatter:function(i){const d=fb({conf:e,valueFormatters:r,dataDict:o,params:i,metricUnitMap:l}).map(g=>`
|
|
120
120
|
<tr>
|
|
121
121
|
<th style="text-align: right; padding: 0 1em;">
|
|
122
122
|
${g.label}
|
|
@@ -145,7 +145,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
145
145
|
</thead>
|
|
146
146
|
<tbody>${d.join("")}</tbody>
|
|
147
147
|
</table>
|
|
148
|
-
`}})}const yb=e=>M(e).get("year");function vb(e){const t=y.groupBy(e,i=>i.value[2]),r=Object.keys(t),a=e.map(i=>M(i.value[0]).valueOf()),o=y.min(a),l=y.max(a);return{minDate:o??0,maxDate:l??0,dateSpan:M(l).diff(o,"day"),dataByYear:t,years:r}}function _b(e,t,r){const a=r.reduce((D,z)=>{const I=He(z,t);return D[z.name]=Be(z,I),D},{}),o=pn(e.visualMap,a),{min:l,max:i}=o,c=ub(e),d=$(e.calendar.data_key),u=$(e.heat_block.data_key),p=t[d.queryID].map(D=>{const z=y.get(D,d.columnKey),I=y.get(D,u.columnKey),A=yb(D[d.columnKey]),E={value:[z,I,A]},{followVisualMap:U,color:N}=pr(I,l,i,e.visualMap);return U||(E.visualMap=!1,E.itemStyle={color:N}),E}),{dateSpan:g,minDate:b,dataByYear:_,years:w}=vb(p),x=g<=366;return{calendar:db(x,b,w),series:hb(x,_,p),tooltip:bb(e,t,c),visualMap:{...o,orient:"horizontal",left:x?"center":5,dimension:1},legend:pb(x,w),grid:{containLabel:!0}}}function mb({name:e},t){const r=t.getOption();r.calendar.forEach(a=>{a.range=e}),t.setOption(r)}function wb({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=Dt(t,e.calendar.data_key),d=Ve(o.triggerManager,Jo.id),u=h.useCallback(w=>{const[x,S]=w.value,D=y.get(c,x,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...w,rowData:D})})},[c,d,o]),p=h.useRef(null),g=h.useCallback(()=>{var x;const w=(x=p.current)==null?void 0:x.getEchartsInstance();w&&fe(i,w.getOption())},[i]),b=h.useMemo(()=>({click:u,legendselectchanged:mb,finished:g}),[u,g]),_=h.useMemo(()=>_b(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:_,ref:p,style:{width:r,height:a},onEvents:b,notMerge:!0,opts:{locale:e.calendar.locale},theme:"merico-light"})}function xb({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Ar),[a]),i=e.data,{width:c,height:d}=e.viewport;return!l.calendar.data_key||!l.heat_block.data_key||!c||!d?null:n.jsx(ve,{width:c,height:d,children:n.jsx(wb,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,conf:l,interactionManager:r})})}const Cb=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function Sb({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["calendar"]),n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"calendar.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})})}),n.jsx(v.Controller,{name:"calendar.locale",control:e,render:({field:a})=>n.jsx(s.Select,{label:r("viz.calendar_heatmap.calendar.locale"),data:Cb,sx:{flex:1},...a})})]})}function Tb({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["heat_block"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:a})=>n.jsx(Ne,{...a})})]})}const kb=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Db=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(kb,{control:e,index:i})})]})};function zb({control:e,watch:t}){return n.jsx(Db,{control:e,watch:t})}function Mb({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Ar,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:d(a),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Calendar",children:t("viz.calendar_heatmap.calendar.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),n.jsx(s.Tabs.Panel,{value:"Calendar",children:n.jsx(Sb,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx(Tb,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx($r,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(zb,{control:c,watch:u})})]})]})})}class Ib extends J{constructor(){super(...arguments);V(this,"VERSION",6)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>({...r,version:2,config:tb(r.config,a)})),this.version(3,r=>({...r,version:3,config:nb(r.config)})),this.version(4,r=>({...r,version:4,config:rb(r.config)})),this.version(5,r=>({...r,version:5,config:ab(r.config)})),this.version(6,r=>({...r,version:6,config:sb(r.config)}))}}const Vb={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Ib,name:"calendarHeatmap",viewRender:xb,configRender:Mb,createConfig:()=>({version:6,config:Ar}),triggers:[Jo],translation:ob},Pb=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx(s.Box,{...t,children:n.jsxs(s.Stack,{gap:"0",children:[n.jsx(s.Text,{size:"sm",children:r}),n.jsx(s.Text,{size:"xs",opacity:.65,children:a})]})})},$b=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a,i18n:o}=m.useTranslation(),l=h.useMemo(()=>[{label:a("chart.series.line.area_style.origin.auto.label"),description:a("chart.series.line.area_style.origin.auto.description"),value:"auto"},{label:a("chart.series.line.area_style.origin.start.label"),description:a("chart.series.line.area_style.origin.start.description"),value:"start"},{label:a("chart.series.line.area_style.origin.end.label"),description:a("chart.series.line.area_style.origin.end.description"),value:"end"}],[o.language]);return n.jsx(s.Select,{ref:r,label:a("chart.series.line.area_style.origin.label"),data:l,value:e,onChange:Z(t),renderOption:Pb,size:"xs"})}),Ho=h.forwardRef(({value:e,onChange:t,label:r,placeholder:a},o)=>n.jsx(s.ColorInput,{ref:o,label:r,placeholder:a,value:e,onChange:t,size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:e?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{t("")}}):null})),Ab=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=l=>i=>{const c=y.cloneDeep(e);y.set(c,l,i),t(c)};return n.jsxs(s.Stack,{ref:r,children:[n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:n.jsxs(s.Group,{gap:6,children:[n.jsx(T.IconChartAreaLineFilled,{size:14,style:{color:"#999"}}),a("chart.series.line.area_style.label")]}),labelPosition:"center"}),n.jsx(s.Switch,{label:a("chart.series.line.area_style.enabled"),checked:e.enabled,onChange:l=>o("enabled")(l.currentTarget.checked)}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(Ho,{label:a("chart.series.line.area_style.color"),placeholder:a("chart.series.line.area_style.use_series_color"),value:e.color,onChange:o("color")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.opacity"),value:e.opacity,onChange:o("opacity"),step:.1,decimalScale:1,min:0,max:1})]}),n.jsx($b,{value:e.origin,onChange:o("origin")}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(Ho,{label:a("chart.series.line.area_style.shadow_color"),value:e.shadowColor,onChange:o("shadowColor")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_blur"),value:e.shadowBlur,onChange:o("shadowBlur")})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_offset_x"),value:e.shadowOffsetX,onChange:o("shadowOffsetX")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_offset_y"),value:e.shadowOffsetY,onChange:o("shadowOffsetY")})]})]})});function Ro(){return{enabled:!1,color:"",origin:"auto",shadowBlur:0,shadowColor:"",shadowOffsetX:0,shadowOffsetY:0,opacity:.7}}const el=h.forwardRef(({label:e,value:t,onChange:r,hiddenKeys:a},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>{let _=[{label:l("chart.series_order.name"),value:"name"},{label:l("chart.series_order.value"),value:"value"},{label:l("chart.series_order.raw"),value:""}];if(a&&Array.isArray(a)&&a.length>0){const w=new Set(a);_=_.filter(x=>!w.has(x.value))}return _},[i.language,a]),d=h.useMemo(()=>[{label:l("chart.series_order.asc"),value:"asc"},{label:l("chart.series_order.desc"),value:"desc"}],[i.language,a]),{key:u,order:p}=t,g=_=>{_!==null&&r({key:_,order:p})},b=_=>{_&&r({key:u,order:_})};return n.jsxs(s.Group,{gap:"xs",grow:!0,align:"flex-end",children:[n.jsx(s.Select,{ref:o,label:e,data:c,value:u,onChange:g}),u!==""&&n.jsx(s.SegmentedControl,{size:"sm",data:d,value:p,onChange:b})]})}),xn=()=>({key:"",order:"desc"});function Eb(e){const t=y.cloneDeep(y.omit(e,"variables"));return t.stats=y.omit(t.stats,"variables"),t}function Bb(e){const{rotate:t,formatter:r=_e()}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:r}}}}function qb(e){const{dataZoom:t=kt,...r}=e;return{...r,dataZoom:t}}function Ob(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function Lb(e){const t=e.reference_lines.map(r=>{const{lineStyle:a={type:"dashed",width:1,color:Ge.random().css()},show_in_legend:o=!1}=r;return{...r,lineStyle:a,show_in_legend:o}});return{...e,reference_lines:t}}function Nb(e){const t=e.reference_lines.map(r=>{const{yAxisIndex:a=0}=r;return{...r,yAxisIndex:a}});return{...e,reference_lines:t}}function Gb(e){const t=e.series.map(r=>{const{aggregation_on_group:a=Vt}=r;return{...r,aggregation_on_group:a}});return{...e,series:t}}function Fb(e){const t=e.series.map(r=>{const{aggregation_on_value:a=Vt}=r;return{...r,aggregation_on_value:a}});return{...e,series:t}}function Qb(e){delete e.config;const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function jb(e){const{series:t,...r}=e;return{...r,series:t.map(a=>{const{barMinWidth:o,barWidth:l,barMaxWidth:i}=a;return o?{...a,barMinWidth:o,barWidth:"",barMaxWidth:i??l}:{...a,barMinWidth:"",barWidth:l,barMaxWidth:""}})}}function Wb(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{min:o="",max:l=""}=a;return{...a,min:o,max:l}})}}function Ub(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{nameAlignment:o="left"}=a;return{...a,nameAlignment:o}})}}function Kb(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{show:o=!0}=a;return{...a,show:o}})}}function Yb(e){const{regressions:t,...r}=e;return{...r,regressions:t.map(a=>{const{group_by_key:o=""}=a;return{...a,group_by_key:o}})}}function Xb(e){const{series:t,y_axes:r,...a}=e;return{...a,series:t.map(o=>{const{hide_in_legend:l=!1,aggregation_on_value:i=Vt}=o;return{...o,hide_in_legend:l,aggregation_on_value:i}}),y_axes:r.map(o=>{const{min:l="",max:i="",show:c=!0}=o;return{...o,min:l,max:i,show:c}})}}function Zb(e){const{type:t="category",...r}=e.x_axis;return{...e,x_axis:{...r,type:t}}}function Jb(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis_data_key:o,series:l,regressions:i,...c}=e;return{...c,x_axis_data_key:a(o),series:l.map(d=>({...d,y_axis_data_key:a(d.y_axis_data_key),group_by_key:a(d.group_by_key)})),regressions:i.map(d=>({...d,y_axis_data_key:a(d.y_axis_data_key),group_by_key:a(d.group_by_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function Hb(e){const{tooltip:t={metrics:[]},...r}=e;return{...e,tooltip:t}}function Rb(e,t){const{stats:r,...a}=e,o=At(r.templates.top,t),l=At(r.templates.bottom,t);return{stats:{top:o??"",bottom:l??""},...a}}function ey(e){const{series:t,...r}=e,a=t.map(o=>{const{areaStyle:l=Ro(),...i}=o;return{...i,areaStyle:l}});return{...r,series:a}}function ty(e){const{series:t,...r}=e,a=t.map(o=>{const{order_in_group:l=xn(),...i}=o;return{...i,order_in_group:l}});return{...r,series:a}}function ny(e){const{series:t,...r}=e,a=t.map(o=>{const{unit:l=K(),...i}=o;return{...i,unit:l}});return{...r,series:a}}function ry(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}class ay extends J{constructor(){super(...arguments);V(this,"VERSION",24)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(c=>{a.variables.find(d=>d.name===c.name)||a.addVariable(c)}),(y.get(o,"stats.variables")||[]).forEach(c=>{a.variables.find(d=>d.name===c.name)||a.addVariable(c)}),{...r,version:2,config:Eb(o)}}),this.version(3,r=>({...r,version:3,config:Bb(r.config)})),this.version(4,r=>({...r,version:4,config:qb(r.config)})),this.version(5,r=>({...r,version:5,config:Ob(r.config)})),this.version(6,r=>({...r,version:6,config:Lb(r.config)})),this.version(7,r=>({...r,version:7,config:Nb(r.config)})),this.version(8,r=>({...r,version:8,config:Gb(r.config)})),this.version(9,r=>({...r,version:9,config:Fb(r.config)})),this.version(10,r=>({...r,version:10,config:Qb(r.config)})),this.version(11,r=>({...r,version:11,config:jb(r.config)})),this.version(12,r=>({...r,version:12,config:Wb(r.config)})),this.version(13,r=>({...r,version:13,config:Ub(r.config)})),this.version(14,r=>({...r,version:14,config:Kb(r.config)})),this.version(15,r=>({...r,version:15,config:Yb(r.config)})),this.version(16,r=>({...r,version:16,config:Xb(r.config)})),this.version(17,r=>({...r,version:17,config:Zb(r.config)})),this.version(18,(r,a)=>({...r,version:18,config:Jb(r.config,a)})),this.version(19,r=>({...r,version:19,config:Hb(r.config)})),this.version(20,(r,a)=>({...r,version:20,config:Rb(r.config,a.panelModel)})),this.version(21,(r,a)=>({...r,version:21,config:ey(r.config)})),this.version(22,(r,a)=>({...r,version:22,config:ty(r.config)})),this.version(23,(r,a)=>({...r,version:23,config:ny(r.config)})),this.version(24,(r,a)=>({...r,version:24,config:ry(r.config)}))}}const sy=[{lang:"en",resources:{cartesian_chart:{viz_name:"Cartesian Chart",series:{aggregation:{label:"Aggregation on Value"}},click_series:{label:"Click bar, line or scatter"}}}},{lang:"zh",resources:{cartesian_chart:{viz_name:"复合图",series:{aggregation:{label:"聚合数据"}},click_series:{label:"点击柱、线或散点"}}}}],Er={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:ly,configRender:oy,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function oy(e){return n.jsx(n.Fragment,{})}function ly(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.cartesian_chart.click_series.label")})}const tl={regressions:[],series:[],stats:{bottom:"",top:""},x_axis:{type:"category",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},tooltip:{metrics:[]},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:de,mirror:!1}],reference_lines:[],reference_areas:[],dataZoom:kt},zt=k.observer(({value:e,context:t,onHeightChange:r})=>{var g;const{ref:a}=te.useElementSize(),o=H(),{panel:l}=re(),{variables:i,data:c}=t,d=h.useMemo(()=>ft(e,i,o.payloadForViz,c),[e,i,c]),u=((g=a.current)==null?void 0:g.textContent)==="";h.useEffect(()=>{if(!r||!a.current)return;const b=u?0:a.current.offsetHeight;r(b)},[u,a.current]);const p=h.useMemo(()=>u?"none":"block",[u]);return n.jsx(s.Box,{sx:{display:p},children:n.jsx($t,{ref:a,value:d,styles:{root:{margin:"0 8px",border:"none",maxWidth:"100%","&.mantine-RichTextEditor-root":{overflow:"auto !important"}},content:{"&.mantine-RichTextEditor-content .ProseMirror":{padding:0},"&.mantine-RichTextEditor-content .ProseMirror > p":{fontSize:"12px",lineHeight:"20px"}}},dashboardStateValues:o.dashboardStateValues,variableAggValueMap:l.variableAggValueMap})})});function iy(e){const t=e.y_axes.some(o=>!!o.name);let r=15;t&&(r+=20),e.dataZoom.x_axis_slider&&(r+=20);let a=5;return e.x_axis_name&&(a+=15),e.series.some(o=>!o.hide_in_legend)&&(a+=20),{top:r,right:15,bottom:a,left:20,containLabel:!0}}function cy(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function dy(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function uy(e,t){const r=e.series.reduce((o,{unit:l,name:i})=>(l.show_in_legend&&(o[i]=l.text),o),{}),a={show:!0,bottom:0,left:"center",type:"scroll",formatter:o=>{const l=r[o];return l?`${o}(${l})`:o}};return a.data=t.filter(o=>!o.hide_in_legend).map(({name:o,type:l})=>({name:o,icon:dy(l),...cy(l)})),a}function Cn(e,t){switch(e.config.method){case"linear":return[...ht.regressionLinear()(t)];case"exponential":return[...ht.regressionExp()(t)];case"logistic":return[...ht.regressionLog()(t)];case"polynomial":return[...ht.regressionPoly().order(e.config.order)(t)];default:return[]}}function py(e,t,r,a){const{transform:o,plot:l}=e,i={...l,name:t,data:Cn(o,a),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return r&&(i.custom={type:"regression-line",targetSeries:r}),i}function hy({regressions:e=[],x_axis_data_key:t},r){const a=[];if(Object.keys(r).length===0)return a;function o(l,i,c,d){const u=py(l,i,c,d);a.push(u)}return e.forEach(l=>{const{name:i,group_by_key:c}=l;if(!c||c===t){const g=me(r,l.y_axis_data_key).map((b,_)=>[_,Number(b)]);o(l,i,"",g);return}const{columnKey:d}=$(l.y_axis_data_key),u=y.groupBy(dn(r,l.y_axis_data_key),c);Object.entries(u).forEach(([p,g])=>{const b=g.map((w,x)=>[x,Number(w[d])]);o(l,p,p,b)})}),a}function gy(e,t){return e.map(r=>({name:r.name,type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:r.color},data:[[{yAxis:t[r.y_keys.upper]},{yAxis:t[r.y_keys.lower]}]],silent:!0}}))}function fy(e,t,r,a){return t?a==="value"?[[r[0],e]]:[e]:[]}function by(e,t,r,a,o,l){return e.map(i=>{const c=r[i.variable_key],d=i.orientation==="horizontal",u=d?"yAxis":"xAxis",p=d?"insideEndTop":"end",g=fy(c,d,o,l);return{name:i.name,type:"scatter",hide_in_legend:!i.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:i.yAxisIndex,data:g,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:i.name,[u]:c}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?Kt(i.template,t,a):""},position:p}}}})}function Br(e,t,r){const a=me(e,t),o=me(e,r);return y.zip(a,o)}function yy(e,t,r,a){const o=Br(t,r,a);return y.unionBy(o,e,0)}function vy({dataTemplate:e,data:t,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o}){return o?yy(e,t,r,a):me(t,a)}function _y({dataTemplate:e,data:t,aggregation_on_value:r,x_axis_data_key:a,y_axis_data_key:o,valueTypedXAxis:l}){if(!r||r.type==="none")return vy({dataTemplate:e,data:t,x_axis_data_key:a,y_axis_data_key:o,valueTypedXAxis:l});const i=Br(t,a,o),c=y.groupBy(i,"0");return e.map(([u])=>{const g=c[u].map(_=>_[1]),b=lr(g,r);return[u,b]})}function my({group_by_key:e,data:t,x_axis_data_key:r,y_axis_data_key:a}){const{queryID:o,columnKey:l}=$(e),i=y.groupBy(t[o],l);return Object.entries(i).forEach(([c,d])=>{i[c]=Br({[o]:d},r,a)}),i}function wy({type:e,...t},r,a,o){if(!e)return 10;if(e==="static"){const{size:u}=t;return u}const{func_content:l}=t,{queryID:i,columnKey:c}=$(a),d=y.keyBy(dn(r,i),c);return(u,p)=>{let g;p.name?g=d[p.name]:g=r[p.dataIndex];try{return new Function(`return ${l}`)()({rowData:g,params:p,variables:o},{lodash:y,interpolate:dt.interpolate})}catch(b){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${b.message}`),10}}}function xy({x_axis_data_key:e,x_axis:t},{y_axis_data_key:r,yAxisIndex:a,label_position:o,name:l,unit:i,group_by_key:c,order_in_group:d,aggregation_on_value:u,stack:p,color:g,display_name_on_line:b,symbolSize:_,hide_in_legend:w,areaStyle:x,...S},D,z,I,A){const E=t.type!=="category",U={label:{show:!!o,position:o,formatter:A[a??"default"]},name:l,xAxisId:"main-x-axis",yAxisIndex:a,stack:p,color:g,symbolSize:wy(_,z,e,I),hide_in_legend:w,labelLayout:{hideOverlap:!0},...S};if(S.type==="line"&&(U.lineStyle={width:S.lineStyle.width,type:S.lineStyle.type,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:y.clamp(S.lineStyle.width,1,3)},x.enabled)){U.lineStyle.shadowColor="transparent";const{enabled:be,...ct}=x;U.areaStyle={...ct,color:ct.color||g}}if(b&&(U.endLabel={show:!0,formatter:l,offset:[-12,12],align:"right"}),!c||c===e)return U.data=_y({dataTemplate:D,data:z,aggregation_on_value:u,x_axis_data_key:e,y_axis_data_key:r,valueTypedXAxis:E}),U;const N=my({group_by_key:c,data:z,x_axis_data_key:e,y_axis_data_key:r});let oe=Object.entries(N);return d.key==="name"&&(oe=y.orderBy(Object.entries(N),0,[d.order])),oe.map(([be,ct])=>{const mt=y.cloneDeep(U);return mt.name=be,mt.color=void 0,"areaStyle"in mt&&(mt.areaStyle.color=void 0),mt.data=ct,mt})}function Cy(e,t,r,a,o,l){const i=t.map(d=>[d,0]);return e.series.map(d=>xy(e,d,i,r,l,a)).flat().concat(by(e.reference_lines,o,l,r,t,e.x_axis.type)).concat(gy(e.reference_areas,l))}function Sy(e,t){const r=e.find(l=>l.axisDim==="x"&&l.axisId==="main-x-axis");if(!r)return"";const{axisValue:a,axisIndex:o}=r;return Me(t.x_axis.axisLabel.formatter)(a,o)}const Ty=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function ky(e,t,r,a){const o=r.reduce((c,{yAxisIndex:d,name:u})=>(c[u]=d,c),{}),l=e.series.reduce((c,{unit:d,name:u})=>(d.show_in_tooltip&&(c[u]=d.text),c),{}),i=e.tooltip.metrics.reduce((c,{unit:d,name:u})=>(d.show_in_tooltip&&(c[u]=d.text),c),{});return X.getTooltip({trigger:"axis",formatter:function(c){const d=Array.isArray(c)?c:[c];if(d.length===0)return"";const u=d.map(({seriesName:_,marker:w,value:x})=>{if(Array.isArray(x)&&x.length===2&&(x=x[1]),!_)return x;const S=l[_]??"",D=o[_],z=a[D]??a.default;return`
|
|
148
|
+
`}})}const yb=e=>M(e).get("year");function vb(e){const t=y.groupBy(e,i=>i.value[2]),r=Object.keys(t),a=e.map(i=>M(i.value[0]).valueOf()),o=y.min(a),l=y.max(a);return{minDate:o??0,maxDate:l??0,dateSpan:M(l).diff(o,"day"),dataByYear:t,years:r}}function _b(e,t,r){const a=r.reduce((D,z)=>{const I=He(z,t);return D[z.name]=Be(z,I),D},{}),o=pn(e.visualMap,a),{min:l,max:i}=o,c=ub(e),d=$(e.calendar.data_key),u=$(e.heat_block.data_key),p=t[d.queryID].map(D=>{const z=y.get(D,d.columnKey),I=y.get(D,u.columnKey),A=yb(D[d.columnKey]),E={value:[z,I,A]},{followVisualMap:U,color:N}=hr(I,l,i,e.visualMap);return U||(E.visualMap=!1,E.itemStyle={color:N}),E}),{dateSpan:g,minDate:b,dataByYear:_,years:w}=vb(p),x=g<=366;return{calendar:db(x,b,w),series:hb(x,_,p),tooltip:bb(e,t,c),visualMap:{...o,orient:"horizontal",left:x?"center":5,dimension:1},legend:pb(x,w),grid:{containLabel:!0}}}function mb({name:e},t){const r=t.getOption();r.calendar.forEach(a=>{a.range=e}),t.setOption(r)}function wb({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=Dt(t,e.calendar.data_key),d=Ve(o.triggerManager,Jo.id),u=h.useCallback(w=>{const[x,S]=w.value,D=y.get(c,x,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...w,rowData:D})})},[c,d,o]),p=h.useRef(null),g=h.useCallback(()=>{var x;const w=(x=p.current)==null?void 0:x.getEchartsInstance();w&&fe(i,w.getOption())},[i]),b=h.useMemo(()=>({click:u,legendselectchanged:mb,finished:g}),[u,g]),_=h.useMemo(()=>_b(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:_,ref:p,style:{width:r,height:a},onEvents:b,notMerge:!0,opts:{locale:e.calendar.locale},theme:"merico-light"})}function xb({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Er),[a]),i=e.data,{width:c,height:d}=e.viewport;return!l.calendar.data_key||!l.heat_block.data_key||!c||!d?null:n.jsx(ve,{width:c,height:d,children:n.jsx(wb,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,conf:l,interactionManager:r})})}const Cb=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function Sb({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["calendar"]),n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"calendar.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})})}),n.jsx(v.Controller,{name:"calendar.locale",control:e,render:({field:a})=>n.jsx(s.Select,{label:r("viz.calendar_heatmap.calendar.locale"),data:Cb,sx:{flex:1},...a})})]})}function Tb({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["heat_block"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:a})=>n.jsx(Ne,{...a})})]})}const kb=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Db=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(kb,{control:e,index:i})})]})};function zb({control:e,watch:t}){return n.jsx(Db,{control:e,watch:t})}function Mb({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Er,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:d(a),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Calendar",children:t("viz.calendar_heatmap.calendar.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),n.jsx(s.Tabs.Panel,{value:"Calendar",children:n.jsx(Sb,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx(Tb,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx(Ar,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(zb,{control:c,watch:u})})]})]})})}class Ib extends J{constructor(){super(...arguments);V(this,"VERSION",6)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>({...r,version:2,config:tb(r.config,a)})),this.version(3,r=>({...r,version:3,config:nb(r.config)})),this.version(4,r=>({...r,version:4,config:rb(r.config)})),this.version(5,r=>({...r,version:5,config:ab(r.config)})),this.version(6,r=>({...r,version:6,config:sb(r.config)}))}}const Vb={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Ib,name:"calendarHeatmap",viewRender:xb,configRender:Mb,createConfig:()=>({version:6,config:Er}),triggers:[Jo],translation:ob},Pb=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx(s.Box,{...t,children:n.jsxs(s.Stack,{gap:"0",children:[n.jsx(s.Text,{size:"sm",children:r}),n.jsx(s.Text,{size:"xs",opacity:.65,children:a})]})})},$b=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a,i18n:o}=m.useTranslation(),l=h.useMemo(()=>[{label:a("chart.series.line.area_style.origin.auto.label"),description:a("chart.series.line.area_style.origin.auto.description"),value:"auto"},{label:a("chart.series.line.area_style.origin.start.label"),description:a("chart.series.line.area_style.origin.start.description"),value:"start"},{label:a("chart.series.line.area_style.origin.end.label"),description:a("chart.series.line.area_style.origin.end.description"),value:"end"}],[o.language]);return n.jsx(s.Select,{ref:r,label:a("chart.series.line.area_style.origin.label"),data:l,value:e,onChange:Z(t),renderOption:Pb,size:"xs"})}),Ho=h.forwardRef(({value:e,onChange:t,label:r,placeholder:a},o)=>n.jsx(s.ColorInput,{ref:o,label:r,placeholder:a,value:e,onChange:t,size:"xs",popoverProps:{withinPortal:!0,zIndex:340},rightSection:e?n.jsx(s.CloseButton,{size:"sm",onClick:()=>{t("")}}):null})),Ab=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=l=>i=>{const c=y.cloneDeep(e);y.set(c,l,i),t(c)};return n.jsxs(s.Stack,{ref:r,children:[n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:n.jsxs(s.Group,{gap:6,children:[n.jsx(T.IconChartAreaLineFilled,{size:14,style:{color:"#999"}}),a("chart.series.line.area_style.label")]}),labelPosition:"center"}),n.jsx(s.Switch,{label:a("chart.series.line.area_style.enabled"),checked:e.enabled,onChange:l=>o("enabled")(l.currentTarget.checked)}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(Ho,{label:a("chart.series.line.area_style.color"),placeholder:a("chart.series.line.area_style.use_series_color"),value:e.color,onChange:o("color")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.opacity"),value:e.opacity,onChange:o("opacity"),step:.1,decimalScale:1,min:0,max:1})]}),n.jsx($b,{value:e.origin,onChange:o("origin")}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(Ho,{label:a("chart.series.line.area_style.shadow_color"),value:e.shadowColor,onChange:o("shadowColor")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_blur"),value:e.shadowBlur,onChange:o("shadowBlur")})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_offset_x"),value:e.shadowOffsetX,onChange:o("shadowOffsetX")}),n.jsx(s.NumberInput,{size:"xs",label:a("chart.series.line.area_style.shadow_offset_y"),value:e.shadowOffsetY,onChange:o("shadowOffsetY")})]})]})});function Ro(){return{enabled:!1,color:"",origin:"auto",shadowBlur:0,shadowColor:"",shadowOffsetX:0,shadowOffsetY:0,opacity:.7}}const el=h.forwardRef(({label:e,value:t,onChange:r,hiddenKeys:a},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>{let _=[{label:l("chart.series_order.name"),value:"name"},{label:l("chart.series_order.value"),value:"value"},{label:l("chart.series_order.raw"),value:""}];if(a&&Array.isArray(a)&&a.length>0){const w=new Set(a);_=_.filter(x=>!w.has(x.value))}return _},[i.language,a]),d=h.useMemo(()=>[{label:l("chart.series_order.asc"),value:"asc"},{label:l("chart.series_order.desc"),value:"desc"}],[i.language,a]),{key:u,order:p}=t,g=_=>{_!==null&&r({key:_,order:p})},b=_=>{_&&r({key:u,order:_})};return n.jsxs(s.Group,{gap:"xs",grow:!0,align:"flex-end",children:[n.jsx(s.Select,{ref:o,label:e,data:c,value:u,onChange:g}),u!==""&&n.jsx(s.SegmentedControl,{size:"sm",data:d,value:p,onChange:b})]})}),xn=()=>({key:"",order:"desc"});function Eb(e){const t=y.cloneDeep(y.omit(e,"variables"));return t.stats=y.omit(t.stats,"variables"),t}function Bb(e){const{rotate:t,formatter:r=_e()}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:r}}}}function qb(e){const{dataZoom:t=kt,...r}=e;return{...r,dataZoom:t}}function Ob(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function Lb(e){const t=e.reference_lines.map(r=>{const{lineStyle:a={type:"dashed",width:1,color:Ge.random().css()},show_in_legend:o=!1}=r;return{...r,lineStyle:a,show_in_legend:o}});return{...e,reference_lines:t}}function Nb(e){const t=e.reference_lines.map(r=>{const{yAxisIndex:a=0}=r;return{...r,yAxisIndex:a}});return{...e,reference_lines:t}}function Gb(e){const t=e.series.map(r=>{const{aggregation_on_group:a=Vt}=r;return{...r,aggregation_on_group:a}});return{...e,series:t}}function Fb(e){const t=e.series.map(r=>{const{aggregation_on_value:a=Vt}=r;return{...r,aggregation_on_value:a}});return{...e,series:t}}function Qb(e){delete e.config;const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function jb(e){const{series:t,...r}=e;return{...r,series:t.map(a=>{const{barMinWidth:o,barWidth:l,barMaxWidth:i}=a;return o?{...a,barMinWidth:o,barWidth:"",barMaxWidth:i??l}:{...a,barMinWidth:"",barWidth:l,barMaxWidth:""}})}}function Wb(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{min:o="",max:l=""}=a;return{...a,min:o,max:l}})}}function Ub(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{nameAlignment:o="left"}=a;return{...a,nameAlignment:o}})}}function Kb(e){const{y_axes:t,...r}=e;return{...r,y_axes:t.map(a=>{const{show:o=!0}=a;return{...a,show:o}})}}function Yb(e){const{regressions:t,...r}=e;return{...r,regressions:t.map(a=>{const{group_by_key:o=""}=a;return{...a,group_by_key:o}})}}function Xb(e){const{series:t,y_axes:r,...a}=e;return{...a,series:t.map(o=>{const{hide_in_legend:l=!1,aggregation_on_value:i=Vt}=o;return{...o,hide_in_legend:l,aggregation_on_value:i}}),y_axes:r.map(o=>{const{min:l="",max:i="",show:c=!0}=o;return{...o,min:l,max:i,show:c}})}}function Zb(e){const{type:t="category",...r}=e.x_axis;return{...e,x_axis:{...r,type:t}}}function Jb(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis_data_key:o,series:l,regressions:i,...c}=e;return{...c,x_axis_data_key:a(o),series:l.map(d=>({...d,y_axis_data_key:a(d.y_axis_data_key),group_by_key:a(d.group_by_key)})),regressions:i.map(d=>({...d,y_axis_data_key:a(d.y_axis_data_key),group_by_key:a(d.group_by_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function Hb(e){const{tooltip:t={metrics:[]},...r}=e;return{...e,tooltip:t}}function Rb(e,t){const{stats:r,...a}=e,o=At(r.templates.top,t),l=At(r.templates.bottom,t);return{stats:{top:o??"",bottom:l??""},...a}}function ey(e){const{series:t,...r}=e,a=t.map(o=>{const{areaStyle:l=Ro(),...i}=o;return{...i,areaStyle:l}});return{...r,series:a}}function ty(e){const{series:t,...r}=e,a=t.map(o=>{const{order_in_group:l=xn(),...i}=o;return{...i,order_in_group:l}});return{...r,series:a}}function ny(e){const{series:t,...r}=e,a=t.map(o=>{const{unit:l=K(),...i}=o;return{...i,unit:l}});return{...r,series:a}}function ry(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}class ay extends J{constructor(){super(...arguments);V(this,"VERSION",24)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(c=>{a.variables.find(d=>d.name===c.name)||a.addVariable(c)}),(y.get(o,"stats.variables")||[]).forEach(c=>{a.variables.find(d=>d.name===c.name)||a.addVariable(c)}),{...r,version:2,config:Eb(o)}}),this.version(3,r=>({...r,version:3,config:Bb(r.config)})),this.version(4,r=>({...r,version:4,config:qb(r.config)})),this.version(5,r=>({...r,version:5,config:Ob(r.config)})),this.version(6,r=>({...r,version:6,config:Lb(r.config)})),this.version(7,r=>({...r,version:7,config:Nb(r.config)})),this.version(8,r=>({...r,version:8,config:Gb(r.config)})),this.version(9,r=>({...r,version:9,config:Fb(r.config)})),this.version(10,r=>({...r,version:10,config:Qb(r.config)})),this.version(11,r=>({...r,version:11,config:jb(r.config)})),this.version(12,r=>({...r,version:12,config:Wb(r.config)})),this.version(13,r=>({...r,version:13,config:Ub(r.config)})),this.version(14,r=>({...r,version:14,config:Kb(r.config)})),this.version(15,r=>({...r,version:15,config:Yb(r.config)})),this.version(16,r=>({...r,version:16,config:Xb(r.config)})),this.version(17,r=>({...r,version:17,config:Zb(r.config)})),this.version(18,(r,a)=>({...r,version:18,config:Jb(r.config,a)})),this.version(19,r=>({...r,version:19,config:Hb(r.config)})),this.version(20,(r,a)=>({...r,version:20,config:Rb(r.config,a.panelModel)})),this.version(21,(r,a)=>({...r,version:21,config:ey(r.config)})),this.version(22,(r,a)=>({...r,version:22,config:ty(r.config)})),this.version(23,(r,a)=>({...r,version:23,config:ny(r.config)})),this.version(24,(r,a)=>({...r,version:24,config:ry(r.config)}))}}const sy=[{lang:"en",resources:{cartesian_chart:{viz_name:"Cartesian Chart",series:{aggregation:{label:"Aggregation on Value"}},click_series:{label:"Click bar, line or scatter"}}}},{lang:"zh",resources:{cartesian_chart:{viz_name:"复合图",series:{aggregation:{label:"聚合数据"}},click_series:{label:"点击柱、线或散点"}}}}],Br={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:ly,configRender:oy,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function oy(e){return n.jsx(n.Fragment,{})}function ly(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.cartesian_chart.click_series.label")})}const tl={regressions:[],series:[],stats:{bottom:"",top:""},x_axis:{type:"category",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},tooltip:{metrics:[]},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:de,mirror:!1}],reference_lines:[],reference_areas:[],dataZoom:kt},zt=k.observer(({value:e,context:t,onHeightChange:r})=>{var g;const{ref:a}=te.useElementSize(),o=H(),{panel:l}=re(),{variables:i,data:c}=t,d=h.useMemo(()=>ft(e,i,o.payloadForViz,c),[e,i,c]),u=((g=a.current)==null?void 0:g.textContent)==="";h.useEffect(()=>{if(!r||!a.current)return;const b=u?0:a.current.offsetHeight;r(b)},[u,a.current]);const p=h.useMemo(()=>u?"none":"block",[u]);return n.jsx(s.Box,{sx:{display:p},children:n.jsx($t,{ref:a,value:d,styles:{root:{margin:"0 8px",border:"none",maxWidth:"100%","&.mantine-RichTextEditor-root":{overflow:"auto !important"}},content:{"&.mantine-RichTextEditor-content .ProseMirror":{padding:0},"&.mantine-RichTextEditor-content .ProseMirror > p":{fontSize:"12px",lineHeight:"20px"}}},dashboardStateValues:o.dashboardStateValues,variableAggValueMap:l.variableAggValueMap})})});function iy(e){const t=e.y_axes.some(o=>!!o.name);let r=15;t&&(r+=20),e.dataZoom.x_axis_slider&&(r+=20);let a=5;return e.x_axis_name&&(a+=15),e.series.some(o=>!o.hide_in_legend)&&(a+=20),{top:r,right:15,bottom:a,left:20,containLabel:!0}}function cy(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function dy(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function uy(e,t){const r=e.series.reduce((o,{unit:l,name:i})=>(l.show_in_legend&&(o[i]=l.text),o),{}),a={show:!0,bottom:0,left:"center",type:"scroll",formatter:o=>{const l=r[o];return l?`${o}(${l})`:o}};return a.data=t.filter(o=>!o.hide_in_legend).map(({name:o,type:l})=>({name:o,icon:dy(l),...cy(l)})),a}function Cn(e,t){switch(e.config.method){case"linear":return[...ht.regressionLinear()(t)];case"exponential":return[...ht.regressionExp()(t)];case"logistic":return[...ht.regressionLog()(t)];case"polynomial":return[...ht.regressionPoly().order(e.config.order)(t)];default:return[]}}function py(e,t,r,a){const{transform:o,plot:l}=e,i={...l,name:t,data:Cn(o,a),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return r&&(i.custom={type:"regression-line",targetSeries:r}),i}function hy({regressions:e=[],x_axis_data_key:t},r){const a=[];if(Object.keys(r).length===0)return a;function o(l,i,c,d){const u=py(l,i,c,d);a.push(u)}return e.forEach(l=>{const{name:i,group_by_key:c}=l;if(!c||c===t){const g=me(r,l.y_axis_data_key).map((b,_)=>[_,Number(b)]);o(l,i,"",g);return}const{columnKey:d}=$(l.y_axis_data_key),u=y.groupBy(dn(r,l.y_axis_data_key),c);Object.entries(u).forEach(([p,g])=>{const b=g.map((w,x)=>[x,Number(w[d])]);o(l,p,p,b)})}),a}function gy(e,t){return e.map(r=>({name:r.name,type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:r.color},data:[[{yAxis:t[r.y_keys.upper]},{yAxis:t[r.y_keys.lower]}]],silent:!0}}))}function fy(e,t,r,a){return t?a==="value"?[[r[0],e]]:[e]:[]}function by(e,t,r,a,o,l){return e.map(i=>{const c=r[i.variable_key],d=i.orientation==="horizontal",u=d?"yAxis":"xAxis",p=d?"insideEndTop":"end",g=fy(c,d,o,l);return{name:i.name,type:"scatter",hide_in_legend:!i.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:i.yAxisIndex,data:g,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:i.name,[u]:c}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?Kt(i.template,t,a):""},position:p}}}})}function qr(e,t,r){const a=me(e,t),o=me(e,r);return y.zip(a,o)}function yy(e,t,r,a){const o=qr(t,r,a);return y.unionBy(o,e,0)}function vy({dataTemplate:e,data:t,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o}){return o?yy(e,t,r,a):me(t,a)}function _y({dataTemplate:e,data:t,aggregation_on_value:r,x_axis_data_key:a,y_axis_data_key:o,valueTypedXAxis:l}){if(!r||r.type==="none")return vy({dataTemplate:e,data:t,x_axis_data_key:a,y_axis_data_key:o,valueTypedXAxis:l});const i=qr(t,a,o),c=y.groupBy(i,"0");return e.map(([u])=>{const g=c[u].map(_=>_[1]),b=ir(g,r);return[u,b]})}function my({group_by_key:e,data:t,x_axis_data_key:r,y_axis_data_key:a}){const{queryID:o,columnKey:l}=$(e),i=y.groupBy(t[o],l);return Object.entries(i).forEach(([c,d])=>{i[c]=qr({[o]:d},r,a)}),i}function wy({type:e,...t},r,a,o){if(!e)return 10;if(e==="static"){const{size:u}=t;return u}const{func_content:l}=t,{queryID:i,columnKey:c}=$(a),d=y.keyBy(dn(r,i),c);return(u,p)=>{let g;p.name?g=d[p.name]:g=r[p.dataIndex];try{return new Function(`return ${l}`)()({rowData:g,params:p,variables:o},{lodash:y,interpolate:dt.interpolate})}catch(b){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${b.message}`),10}}}function xy({x_axis_data_key:e,x_axis:t},{y_axis_data_key:r,yAxisIndex:a,label_position:o,name:l,unit:i,group_by_key:c,order_in_group:d,aggregation_on_value:u,stack:p,color:g,display_name_on_line:b,symbolSize:_,hide_in_legend:w,areaStyle:x,...S},D,z,I,A){const E=t.type!=="category",U={label:{show:!!o,position:o,formatter:A[a??"default"]},name:l,xAxisId:"main-x-axis",yAxisIndex:a,stack:p,color:g,symbolSize:wy(_,z,e,I),hide_in_legend:w,labelLayout:{hideOverlap:!0},...S};if(S.type==="line"&&(U.lineStyle={width:S.lineStyle.width,type:S.lineStyle.type,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:y.clamp(S.lineStyle.width,1,3)},x.enabled)){U.lineStyle.shadowColor="transparent";const{enabled:be,...ct}=x;U.areaStyle={...ct,color:ct.color||g}}if(b&&(U.endLabel={show:!0,formatter:l,offset:[-12,12],align:"right"}),!c||c===e)return U.data=_y({dataTemplate:D,data:z,aggregation_on_value:u,x_axis_data_key:e,y_axis_data_key:r,valueTypedXAxis:E}),U;const N=my({group_by_key:c,data:z,x_axis_data_key:e,y_axis_data_key:r});let oe=Object.entries(N);return d.key==="name"&&(oe=y.orderBy(Object.entries(N),0,[d.order])),oe.map(([be,ct])=>{const mt=y.cloneDeep(U);return mt.name=be,mt.color=void 0,"areaStyle"in mt&&(mt.areaStyle.color=void 0),mt.data=ct,mt})}function Cy(e,t,r,a,o,l){const i=t.map(d=>[d,0]);return e.series.map(d=>xy(e,d,i,r,l,a)).flat().concat(by(e.reference_lines,o,l,r,t,e.x_axis.type)).concat(gy(e.reference_areas,l))}function Sy(e,t){const r=e.find(l=>l.axisDim==="x"&&l.axisId==="main-x-axis");if(!r)return"";const{axisValue:a,axisIndex:o}=r;return Me(t.x_axis.axisLabel.formatter)(a,o)}const Ty=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function ky(e,t,r,a){const o=r.reduce((c,{yAxisIndex:d,name:u})=>(c[u]=d,c),{}),l=e.series.reduce((c,{unit:d,name:u})=>(d.show_in_tooltip&&(c[u]=d.text),c),{}),i=e.tooltip.metrics.reduce((c,{unit:d,name:u})=>(d.show_in_tooltip&&(c[u]=d.text),c),{});return X.getTooltip({trigger:"axis",formatter:function(c){const d=Array.isArray(c)?c:[c];if(d.length===0)return"";const u=d.map(({seriesName:_,marker:w,value:x})=>{if(Array.isArray(x)&&x.length===2&&(x=x[1]),!_)return x;const S=l[_]??"",D=o[_],z=a[D]??a.default;return`
|
|
149
149
|
<tr>
|
|
150
150
|
<td>${w}</td>
|
|
151
151
|
<th style="text-align: right; padding: 0 1em;">${_}</th>
|
|
@@ -173,8 +173,8 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
173
173
|
${u.join("")}
|
|
174
174
|
</tbody>
|
|
175
175
|
</table>
|
|
176
|
-
`}})}function Dy(e){return e.y_axes.reduce((r,{label_formatter:a},o)=>(r[o]=function(i){let c=i;if(typeof i=="object"&&(Array.isArray(i.value)&&i.value.length===2?c=i.value[1]:c=i.value),!a)return c;try{return Y(c,a)}catch(d){return console.error(d),c}},r),{default:({value:r})=>r})}function qr(e,t){const r={};return t.map(a=>{const o=He(a,e);r[a.name]=Be(a,o)}),r}function zy(e,t){const{overflow:r,...a}=e.x_axis.axisLabel,o=Ke(r.on_axis),l=t.length===0;return[X.getXAxis({data:t,name:e.x_axis_name??"",nameGap:l?5:void 0,id:"main-x-axis",type:e.x_axis.type,axisLabel:{...a,...o,formatter:Me(a.formatter)}})]}function My(e){var t;if(!e)return[];try{return Array.isArray(e[0])&&((t=e[0])==null?void 0:t.length)>=2?e.map(a=>Number(a[1])):[...e]}catch(r){return console.error(r),[...e]}}function Iy(e){if(e.length===0)return{};const t={},r={};return e.forEach(a=>{const o=My(a.data);if(!r[a.yAxisIndex]){r[a.yAxisIndex]=o;return}r[a.yAxisIndex]=r[a.yAxisIndex].concat(o)}),Object.entries(r).forEach(([a,o])=>{const l=y.minBy(o)??0,i=y.maxBy(o)??0;l==0&&i==0&&(t[a]=1)}),t}function nl(e,t,r,a,o){return a?l=>{const i=t&&Number.isFinite(Number(t))?Math.abs(Number(t)):Math.abs(l.min),c=r&&Number.isFinite(Number(r))?Math.abs(Number(r)):Math.abs(l.max),d=Math.max(i,c,0);return o*d}:e||void 0}function Vy(e,t,r){const a=Iy(r);return e.y_axes.map(({nameAlignment:o,min:l,max:i,show:c,mirror:d,...u},p)=>{let g=u.position;return g||(g=p>0?"right":"left"),X.getYAxis({...u,minInterval:a[p]??0,show:c,alignTicks:d,min:nl(l,l,i,d,-1),max:nl(i,l,i,d,1),position:g,axisLabel:{show:c,formatter:t[p]??t.default},nameTextStyle:{align:o},nameLocation:"end",nameGap:c?15:0,splitLine:{show:p===0}})})}const Py={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function $y(e,t,r){const a=qr(t,r),o=Dy(e),l=y.uniq(me(t,e.x_axis_data_key)),i=Cy(e,l,t,o,r,a),c=hy(e,t),d={xAxis:zy(e,l),yAxis:Vy(e,o,i),series:[...i,...c],tooltip:ky(e,t,i,o),grid:iy(e),legend:uy(e,i),dataZoom:_n(e.dataZoom)};return y.defaultsDeep({},d,Py)}function rl(e){const t=e.getModel(),r=t.getSeries().map(a=>{if(!a.option.custom)return a.option;const o=t.getColorFromPalette(a.option.custom.targetSeries,null);return a.option.color=o,a.option});e.setOption({...e.getOption(),series:r})}function Ay({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,onChartRenderFinished:i}){const c=Dt(t,e.x_axis_data_key),d=Ve(o.triggerManager,Er.id),u=h.useCallback(S=>{const D=y.get(c,S.name,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...S,rowData:D})})},[c,d,o]),p=h.useMemo(()=>$y(e,t,l),[e,t]),g=h.useRef(),b=O.useLatest(i),_=h.useCallback(()=>{var S;b.current((S=g.current)==null?void 0:S.getOption())},[]),w=h.useMemo(()=>({click:u,finished:_}),[u]),x=S=>{g.current=S,rl(S)};return h.useEffect(()=>{g.current&&rl(g.current)},[p]),!r||!a?null:n.jsx(he,{echarts:ce,option:p,style:{width:r,height:a},onEvents:w,onChartReady:x,notMerge:!0,theme:"merico-light"})}const Ey=k.observer(({context:e,instance:t})=>{const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,tl),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c),x=$o(l.stats,e,t);return n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx(Ay,{onChartRenderFinished:x,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})});function By({control:e,index:t,variableOptions:r}){const{t:a,i18n:o}=m.useTranslation(),l=h.useMemo(()=>[{label:a("chart.reference_area.type.rectangle"),value:"rectangle"}],[o.language]),i=h.useMemo(()=>[{label:a("chart.reference_area.direction.horizontal"),value:"horizontal"}],[o.language]);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.reference_area.label"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.color`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.color.label"),required:!0,sx:{flex:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.type`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.type.label"),required:!0,data:l,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.direction`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.direction.label"),required:!0,data:i,sx:{flex:1},...c})})]}),n.jsx(s.Divider,{variant:"dashed",label:a("data.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.y_keys.upper`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.boundary.upper"),required:!0,data:r,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.y_keys.lower`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.boundary.lower"),required:!0,data:r,sx:{flex:1},...c})})]})]})}function qy({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",color:"rgba(0,0,0,0.1)",type:"rectangle",direction:"horizontal",y_keys:{upper:"",lower:""}}),l=(c,d)=>{const u=c.name.trim();return u||d+1},i=h.useMemo(()=>r.map(c=>({label:c.name,value:c.name})),[r]);return n.jsx(R,{control:e,watch:t,name:"reference_areas",getItem:o,addButtonText:a("chart.reference_area.add"),deleteButtonText:a("chart.reference_area.delete"),renderTabName:l,children:({field:c,index:d})=>n.jsx(By,{control:e,index:d,variableOptions:i})})}const qt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.series.line.type.solid"),value:"solid"},{label:l("chart.series.line.type.dashed"),value:"dashed"},{label:l("chart.series.line.type.dotted"),value:"dotted"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.series.line.type.label"),data:c,value:t,onChange:Z(r),sx:a})});function Oy({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{label:l("chart.orientation.label"),sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:l("chart.y_axis.label"),data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:l("chart.legend.show_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function Ly({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),l=(u,p)=>{const g=u.name.trim();return g||p+1},i=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),c=t("y_axes"),d=h.useMemo(()=>c.map(({name:u},p)=>({label:u,value:p.toString()})),[c]);return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:l,children:({field:u,index:p})=>n.jsx(Oy,{control:e,index:p,watch:t,variableOptions:i,yAxisOptions:d})})}function Ny({control:e,regressionItem:t,index:r,yAxisOptions:a}){const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("chart.regression_line.method.linear"),value:"linear"},{label:o("chart.regression_line.method.exponential"),value:"exponential"},{label:o("chart.regression_line.method.logistic"),value:"logistic"},{label:o("chart.regression_line.method.polynomial"),value:"polynomial"}],[l.language]),c=t.transform.config.method;return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`regressions.${r}.name`,control:e,render:({field:d})=>n.jsx(s.TextInput,{label:o("common.name"),required:!0,sx:{flex:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.group_by_key`,control:e,render:({field:d})=>n.jsx(L,{label:o("chart.series.group_by.label_line"),clearable:!0,sx:{flex:1},...d})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`regressions.${r}.y_axis_data_key`,control:e,render:({field:d})=>n.jsx(L,{label:o("common.data_field"),required:!0,sx:{flex:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.plot.yAxisIndex`,control:e,render:({field:{value:d,onChange:u,...p}})=>n.jsx(s.Select,{label:o("chart.y_axis.label"),data:a,disabled:a.length===0,...p,value:(d==null?void 0:d.toString())??"",onChange:g=>{if(!g){u(0);return}u(Number(g))},sx:{flex:1}})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`regressions.${r}.transform.config.method`,control:e,render:({field:d})=>n.jsx(s.Select,{label:o("chart.regression_line.method.label"),data:i,sx:{flex:1},...d})}),c==="polynomial"&&n.jsx(v.Controller,{name:`regressions.${r}.transform.config.order`,control:e,render:({field:d})=>n.jsx(s.NumberInput,{label:o("chart.regression_line.method.polynomial_order"),sx:{flex:1},...d})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("chart.series.line.line_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`regressions.${r}.plot.lineStyle.type`,control:e,render:({field:d})=>n.jsx(qt,{sx:{flexGrow:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.plot.lineStyle.width`,control:e,render:({field:d})=>n.jsx(s.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...d})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`regressions.${r}.plot.color`,control:e,render:({field:d})=>n.jsx(ye,{label:o("chart.color.label"),...d})})})]})}function Gy({control:e,watch:t}){const{t:r}=m.useTranslation(),a=t("y_axes"),o=h.useMemo(()=>a.map(({name:c},d)=>({label:c,value:d.toString()})),[a]),l=()=>({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},group_by_key:"",name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666",lineStyle:{type:"solid",width:1}}}),i=(c,d)=>{const u=c.name.trim();return u||d+1};return n.jsx(R,{control:e,watch:t,name:"regressions",getItem:l,addButtonText:r("chart.regression_line.add"),deleteButtonText:r("chart.regression_line.delete"),renderTabName:i,children:({field:c,index:d})=>n.jsx(Ny,{regressionItem:c,control:e,index:d,yAxisOptions:o})})}const Fy=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Or={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
|
|
177
|
-
`)}},Qy=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,func_content:_}=i,w={type:b,func_content:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,func_content:b}))},g=()=>{p(Or.dynamic.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},leftSection:n.jsx(T.IconMathFunction,{size:16}),children:r("chart.symbol_size.setup.label")})}),n.jsx(s.Modal,{size:800,title:r("chart.symbol_size.setup.title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-10,label:r("chart.symbol_size.setup.description"),labelPosition:"center",variant:"dashed"}),n.jsx(Fy,{value:i.func_content,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"right",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},jy=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(Qy,{value:e,onChange:t}),Wy=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{typeof a!="string"&&t({...e,size:a})};return n.jsx(n.Fragment,{children:n.jsx(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:r})})},Lr=h.forwardRef(({label:e,value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("chart.symbol_size.static"),value:"static"},{label:o("chart.symbol_size.dynamic"),value:"dynamic"}],[l.language]),c=d=>{d!=="static"&&d!=="dynamic"||r({...Or[d]})};return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e??o("chart.symbol_size.label"),data:i,value:t.type,onChange:c,sx:{flexGrow:1}}),n.jsx(Wy,{value:t,onChange:r}),n.jsx(jy,{value:t,onChange:r})]})});function Uy({label:e,value:t,onChange:r,pt:a="sm",withFallback:o},l){const{t:i,i18n:c}=m.useTranslation();h.useEffect(()=>{typeof t=="string"&&r({type:t,config:{},fallback:"0"})},[t,r]);const d=w=>{if(w===null)return;const x=w;switch(x){case"quantile":return r({type:"quantile",config:{p:.99},fallback:t.fallback});case"custom":return r({type:"custom",config:{func:to},fallback:t.fallback});case"pick_record":return r({type:"pick_record",config:{method:"first"},fallback:t.fallback});default:return r({type:x,config:{},fallback:t.fallback})}},u=w=>{const x=Number(w);Number.isNaN(x)||r({type:"quantile",config:{p:x},fallback:t.fallback})},p=w=>{r({type:"custom",config:{func:w},fallback:t.fallback})},g=w=>{w!=="first"&&w!=="last"||r({type:"pick_record",config:{method:w},fallback:t.fallback})},b=w=>{r({...t,fallback:w.currentTarget.value})},_=h.useMemo(()=>[{label:i("aggregation.option.none"),value:"none"},{label:i("aggregation.option.sum"),value:"sum"},{label:i("aggregation.option.min"),value:"min"},{label:i("aggregation.option.mean"),value:"mean"},{label:i("aggregation.option.median"),value:"median"},{label:i("aggregation.option.max"),value:"max"},{label:i("aggregation.option.cov"),value:"CV"},{label:i("aggregation.option.std"),value:"std"},{label:i("aggregation.option.quantile.label_with_hint"),value:"quantile"},{label:i("aggregation.option.pick_record.label"),value:"pick_record"},{label:i("aggregation.option.custom.label"),value:"custom"}],[c.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",pt:a,children:[n.jsx(s.Select,{ref:l,label:e,data:_,value:t.type,onChange:d,maxDropdownHeight:600}),t.type==="quantile"&&n.jsx(s.NumberInput,{label:"p",value:t.config.p,onChange:u,decimalScale:2,min:.05,step:.05,max:1}),t.type==="pick_record"&&n.jsx(s.Select,{label:i("aggregation.option.pick_record.method.label"),value:t.config.method,onChange:g,data:[{label:i("aggregation.option.pick_record.method.first"),value:"first"},{label:i("aggregation.option.pick_record.method.last"),value:"last"}]}),t.type==="custom"&&n.jsx(gr,{title:i("aggregation.option.custom.title"),label:"",triggerLabel:i("aggregation.option.custom.label_trigger"),value:t.config.func,onChange:p,defaultValue:to,triggerButtonProps:{size:"xs",sx:{flexGrow:0,alignSelf:"center",marginTop:"22px"},leftSection:n.jsx(T.IconMathFunction,{size:16}),color:"grape"}})]}),o&&n.jsx(s.TextInput,{label:i("panel.variable.aggregation.fallback_value"),description:i("panel.variable.aggregation.fallback_value_description"),value:t.fallback,onChange:b})]})}const Nr=h.forwardRef(Uy),Ot=h.forwardRef(({label:e,value:t,onChange:r,options:a,withOffOption:o=!1},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>{if(a)return a;const u=[{label:i("chart.label_position.top"),value:"top"},{label:i("chart.label_position.left"),value:"left"},{label:i("chart.label_position.right"),value:"right"},{label:i("chart.label_position.bottom"),value:"bottom"},{label:i("chart.label_position.outside"),value:"outside"},{label:i("chart.label_position.inside"),value:"inside"},{label:i("chart.label_position.inside_left"),value:"insideLeft"},{label:i("chart.label_position.inside_right"),value:"insideRight"},{label:i("chart.label_position.inside_top"),value:"insideTop"},{label:i("chart.label_position.inside_bottom"),value:"insideBottom"},{label:i("chart.label_position.inside_top_left"),value:"insideTopLeft"},{label:i("chart.label_position.inside_bottom_left"),value:"insideBottomLeft"},{label:i("chart.label_position.inside_top_right"),value:"insideTopRight"},{label:i("chart.label_position.inside_bottom_right"),value:"insideBottomRight"}];return o&&u.unshift({label:i("chart.label_position.off"),value:""}),u},[c.language,a,o]);return n.jsx(s.Select,{ref:l,label:e,data:d,value:t,onChange:r})});function Ky({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=!!r.barWidth.trim(),i=h.useMemo(()=>[{label:a("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:a("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.bar.bar_gap.label"),data:i,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.min"),disabled:l,sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.max"),disabled:l,sx:{flexGrow:1},...c})})]})]})}function Yy({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=r.showSymbol,i=h.useMemo(()=>[{label:a("chart.series.line.step.off"),value:"false"},{label:a("chart.series.line.step.start"),value:"start"},{label:a("chart.series.line.step.middle"),value:"middle"},{label:a("chart.series.line.step.end"),value:"end"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:a("chart.series.line.line_settings"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`series.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,align:"center",children:[n.jsx(v.Controller,{name:`series.${t}.step`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.line.step.label"),data:i,sx:{flexGrow:1,maxWidth:"48%"},...c,value:String(c.value),onChange:Z(d=>{const u=d==="false"?!1:d;c.onChange(u)})})}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`series.${t}.smooth`,control:e,render:({field:c})=>n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.smooth_line"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})}),n.jsx(v.Controller,{name:`series.${t}.display_name_on_line`,control:e,render:({field:c})=>n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.show_name_on_line"),checked:c.value??!1,onChange:d=>c.onChange(d.currentTarget.checked)})})})]})]}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`series.${t}.showSymbol`,control:e,render:({field:c})=>n.jsx(s.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.show_symbol_on_line"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})}),l&&n.jsx(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:c})=>n.jsx(Lr,{...c})})]}),n.jsx(v.Controller,{name:`series.${t}.areaStyle`,control:e,render:({field:c})=>n.jsx(Ab,{...c})})]})}function Xy({control:e,index:t}){return n.jsx(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:r})=>n.jsx(Lr,{label:"Size",...r})})}function Zy({control:e,index:t,seriesItem:r,yAxisOptions:a}){const{t:o}=m.useTranslation(),l=r.type,i=r.group_by_key;return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:`series.${t}.type`,control:e,render:({field:c})=>n.jsx(s.SegmentedControl,{data:[{label:o("chart.series.line.label"),value:"line"},{label:o("chart.series.bar.label"),value:"bar"},{label:o("chart.series.scatter.label"),value:"scatter"}],...c})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:o("chart.series.name"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:o("chart.series.y_axis"),data:a,disabled:a.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{name:`series.${t}.y_axis_data_key`,control:e,render:({field:c})=>n.jsx(L,{label:o("chart.series.data_field"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:c})=>n.jsx(Nr,{label:o("viz.cartesian_chart.series.aggregation.label"),value:c.value??Vt,onChange:c.onChange,pt:0,withFallback:!1})})]}),n.jsx(s.Group,{grow:!0,children:n.jsx(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:c})=>n.jsx(L,{label:o("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...c})})}),!!i&&n.jsx(v.Controller,{name:`series.${t}.order_in_group`,control:e,render:({field:c})=>n.jsx(el,{label:o("chart.series_order.label"),hiddenKeys:["value"],...c})}),n.jsx(v.Controller,{name:`series.${t}.unit`,control:e,render:({field:c})=>n.jsx(ue,{...c})}),l==="line"&&n.jsx(Yy,{index:t,control:e,seriesItem:r}),l==="bar"&&n.jsx(Ky,{index:t,control:e,seriesItem:r}),l==="scatter"&&n.jsx(Xy,{index:t,control:e}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:c})=>n.jsx(Ot,{label:o("chart.label_position.label"),withOffOption:!0,...c})}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`series.${t}.color`,control:e,render:({field:c})=>n.jsx(ye,{label:o("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:o("chart.legend.hide_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function Jy({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({type:"bar",name:te.randomId(),unit:K(),showSymbol:!1,symbolSize:Or.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:"",order_in_group:xn(),areaStyle:Ro()}),o=(c,d)=>{const u=c.name.trim();return u||d+1},l=t("y_axes"),i=h.useMemo(()=>l.map(({name:c},d)=>({label:c,value:d.toString()})),[l]);return n.jsx(R,{control:e,watch:t,name:"series",getItem:a,addButtonText:r("chart.series.add"),deleteButtonText:r("chart.series.delete"),renderTabName:o,children:({field:c,index:d})=>n.jsx(Zy,{control:e,index:d,seriesItem:c,yAxisOptions:i})})}const Hy=k.observer(({control:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.above_chart")},`${t.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.under_chart")},`${t.id}.stats.bottom`)})]})}),Ry=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},ev=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Ry,{control:e,index:i})})]})};function tv({control:e,watch:t}){return n.jsx(s.Stack,{children:n.jsx(ev,{control:e,watch:t})})}const nv=()=>{const{t:e}=m.useTranslation();return n.jsxs(s.Group,{sx:{display:"inline-flex"},gap:6,mr:14,children:[n.jsx(s.Text,{size:"sm",children:e("chart.x_axis.x_axis_type")}),n.jsxs(s.HoverCard,{width:340,shadow:"md",position:"top",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",sx:{transform:"none !important"},children:n.jsx(T.IconInfoCircle,{})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.Text,{size:"sm",children:n.jsxs(m.Trans,{i18nKey:"chart.axis.type.click_to_learn_more",children:["Click",n.jsx(s.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:3,children:"here"}),"to learn more about these options"]})})})]})]})};function rv({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t(["x_axis_data_key","x_axis_name","x_axis"]);const o=h.useMemo(()=>[{label:r("chart.axis.type.value"),value:"value"},{label:r("chart.axis.type.category"),value:"category"},{label:r("chart.axis.type.time"),value:"time"},{label:r("chart.axis.type.log"),value:"log"}],[a.language]);return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"x_axis_name",control:e,render:({field:l})=>n.jsx(s.TextInput,{label:r("chart.x_axis.x_axis_name"),sx:{flex:1},...l})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis_data_key",control:e,render:({field:l})=>n.jsx(L,{label:r("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:"x_axis.type",control:e,render:({field:l})=>n.jsx(s.Select,{label:n.jsx(nv,{}),required:!0,data:o,sx:{flex:1},...l})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:l})=>n.jsx(st,{sx:{width:"48%"},...l})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:l})=>n.jsx(Re,{...l})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:l})=>n.jsx(et,{...l})})]})}const yt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={},disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>[{label:i("chart.name_text.align.left"),value:"left"},{label:i("chart.name_text.align.center"),value:"center"},{label:i("chart.name_text.align.right"),value:"right"}],[c.language]);return n.jsx(s.Select,{ref:l,label:e??i("chart.name_text.align.label"),data:d,value:t,onChange:Z(r),sx:a,disabled:o})}),al=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.y_axis.position.left"),value:"left"},{label:l("chart.y_axis.position.right"),value:"right"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.y_axis.position.label"),data:c,value:t,onChange:Z(r),sx:a})});function av({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsx(s.Divider,{mb:-15,mt:15,variant:"dashed",label:r("common.name"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.y_axis_name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.layout"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(al,{sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.mirror`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{pt:20,label:r("chart.y_axis.mirror.label"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_max"),...a})})]})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:r("chart.y_axis.behavior"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.show`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{label:r("chart.y_axis.visible"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})}function sv({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({name:"",position:"left",nameAlignment:"left",label_formatter:de,min:"",max:"",show:!0,mirror:!1}),o=(i,c)=>{const d=i.name.trim();return d||c+1},l=({field:i,index:c,fields:d})=>d.length<=1;return n.jsx(R,{control:e,watch:t,name:"y_axes",getItem:a,addButtonText:r("chart.y_axis.add"),deleteButtonText:r("chart.y_axis.delete"),renderTabName:o,deleteDisalbed:l,children:({field:i,index:c})=>n.jsx(av,{control:e,index:c})})}function ov({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),{variables:o}=r,l=h.useMemo(()=>y.defaults({},e),[e]),{control:i,handleSubmit:c,watch:d,reset:u,formState:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{u(l)},[l]),d(["dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(t),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:a("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axes",children:a("chart.y_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Series",children:a("chart.series.label")}),n.jsx(s.Tabs.Tab,{value:"Regression Lines",children:a("chart.regression_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:a("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:a("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:a("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Reference Areas",children:a("chart.reference_area.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:a("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(rv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axes",children:n.jsx(sv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Series",children:n.jsx(Jy,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Regression Lines",children:n.jsx(Gy,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(tv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(Hy,{control:i})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(Ly,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Areas",children:n.jsx(qy,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function lv(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(ov,{conf:t,setConf:r,...e}):null}const iv={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new ay,name:"cartesian",viewRender:Ey,configRender:lv,createConfig(){return{version:24,config:y.cloneDeep(tl)}},triggers:[Er],translation:sy};function cv(e){if(e.enable_value)return e.value}function dv(e){if(e.enable_value)return e.value}function uv(e){const t=e.axisLabel.overflow.on_axis.width,r=e.axisLabel.position,a={top:5,left:5,right:5,bottom:5};return e.orient==="vertical"&&y.get(a,r)&&r===e.funnelAlign&&y.set(a,r,t),a}function pv(e,t){return e.series.map(r=>{const{level_name_data_key:a,level_value_data_key:o,axisLabel:l,min:i,max:c,funnelAlign:d,orient:u,...p}=r;if(!a||!o)return{};const g=$(a),b=$(o),_=t[g.queryID].map(x=>({name:x[g.columnKey],value:x[b.columnKey]})),w=Ke(l.overflow.on_axis);return{type:"funnel",...uv(r),min:cv(i),max:dv(c),minSize:i.size,maxSize:c.size,...p,label:{show:!0,position:l.position,...w},orient:u,funnelAlign:u==="horizontal"?"center":d,data:_}})}function hv({conf:e,params:t,max:r}){const{name:a,value:o}=t.data,l=Y(o/r,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1});return[{label:`${t.marker} ${a}`,value:`${o} (${l})`,style:{label:"",value:""}}]}function gv(e,t){var l;const r=$(e.series[0].level_name_data_key),a=$(e.series[0].level_value_data_key),o=(l=y.maxBy(t[r.queryID],a.columnKey))==null?void 0:l[a.columnKey];return i=>{const d=hv({conf:e,params:i,max:o}).map(p=>`
|
|
176
|
+
`}})}function Dy(e){return e.y_axes.reduce((r,{label_formatter:a},o)=>(r[o]=function(i){let c=i;if(typeof i=="object"&&(Array.isArray(i.value)&&i.value.length===2?c=i.value[1]:c=i.value),!a)return c;try{return Y(c,a)}catch(d){return console.error(d),c}},r),{default:({value:r})=>r})}function Or(e,t){const r={};return t.map(a=>{const o=He(a,e);r[a.name]=Be(a,o)}),r}function zy(e,t){const{overflow:r,...a}=e.x_axis.axisLabel,o=Ke(r.on_axis),l=t.length===0;return[X.getXAxis({data:t,name:e.x_axis_name??"",nameGap:l?5:void 0,id:"main-x-axis",type:e.x_axis.type,axisLabel:{...a,...o,formatter:Me(a.formatter)}})]}function My(e){var t;if(!e)return[];try{return Array.isArray(e[0])&&((t=e[0])==null?void 0:t.length)>=2?e.map(a=>Number(a[1])):[...e]}catch(r){return console.error(r),[...e]}}function Iy(e){if(e.length===0)return{};const t={},r={};return e.forEach(a=>{const o=My(a.data);if(!r[a.yAxisIndex]){r[a.yAxisIndex]=o;return}r[a.yAxisIndex]=r[a.yAxisIndex].concat(o)}),Object.entries(r).forEach(([a,o])=>{const l=y.minBy(o)??0,i=y.maxBy(o)??0;l==0&&i==0&&(t[a]=1)}),t}function nl(e,t,r,a,o){return a?l=>{const i=t&&Number.isFinite(Number(t))?Math.abs(Number(t)):Math.abs(l.min),c=r&&Number.isFinite(Number(r))?Math.abs(Number(r)):Math.abs(l.max),d=Math.max(i,c,0);return o*d}:e||void 0}function Vy(e,t,r){const a=Iy(r);return e.y_axes.map(({nameAlignment:o,min:l,max:i,show:c,mirror:d,...u},p)=>{let g=u.position;return g||(g=p>0?"right":"left"),X.getYAxis({...u,minInterval:a[p]??0,show:c,alignTicks:d,min:nl(l,l,i,d,-1),max:nl(i,l,i,d,1),position:g,axisLabel:{show:c,formatter:t[p]??t.default},nameTextStyle:{align:o},nameLocation:"end",nameGap:c?15:0,splitLine:{show:p===0}})})}const Py={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function $y(e,t,r){const a=Or(t,r),o=Dy(e),l=y.uniq(me(t,e.x_axis_data_key)),i=Cy(e,l,t,o,r,a),c=hy(e,t),d={xAxis:zy(e,l),yAxis:Vy(e,o,i),series:[...i,...c],tooltip:ky(e,t,i,o),grid:iy(e),legend:uy(e,i),dataZoom:_n(e.dataZoom)};return y.defaultsDeep({},d,Py)}function rl(e){const t=e.getModel(),r=t.getSeries().map(a=>{if(!a.option.custom)return a.option;const o=t.getColorFromPalette(a.option.custom.targetSeries,null);return a.option.color=o,a.option});e.setOption({...e.getOption(),series:r})}function Ay({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,onChartRenderFinished:i}){const c=Dt(t,e.x_axis_data_key),d=Ve(o.triggerManager,Br.id),u=h.useCallback(S=>{const D=y.get(c,S.name,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...S,rowData:D})})},[c,d,o]),p=h.useMemo(()=>$y(e,t,l),[e,t]),g=h.useRef(),b=O.useLatest(i),_=h.useCallback(()=>{var S;b.current((S=g.current)==null?void 0:S.getOption())},[]),w=h.useMemo(()=>({click:u,finished:_}),[u]),x=S=>{g.current=S,rl(S)};return h.useEffect(()=>{g.current&&rl(g.current)},[p]),!r||!a?null:n.jsx(he,{echarts:ce,option:p,style:{width:r,height:a},onEvents:w,onChartReady:x,notMerge:!0,theme:"merico-light"})}const Ey=k.observer(({context:e,instance:t})=>{const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,tl),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c),x=$o(l.stats,e,t);return n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx(Ay,{onChartRenderFinished:x,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})});function By({control:e,index:t,variableOptions:r}){const{t:a,i18n:o}=m.useTranslation(),l=h.useMemo(()=>[{label:a("chart.reference_area.type.rectangle"),value:"rectangle"}],[o.language]),i=h.useMemo(()=>[{label:a("chart.reference_area.direction.horizontal"),value:"horizontal"}],[o.language]);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.reference_area.label"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.color`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.color.label"),required:!0,sx:{flex:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.type`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.type.label"),required:!0,data:l,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.direction`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.direction.label"),required:!0,data:i,sx:{flex:1},...c})})]}),n.jsx(s.Divider,{variant:"dashed",label:a("data.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_areas.${t}.y_keys.upper`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.boundary.upper"),required:!0,data:r,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_areas.${t}.y_keys.lower`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.reference_area.boundary.lower"),required:!0,data:r,sx:{flex:1},...c})})]})]})}function qy({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",color:"rgba(0,0,0,0.1)",type:"rectangle",direction:"horizontal",y_keys:{upper:"",lower:""}}),l=(c,d)=>{const u=c.name.trim();return u||d+1},i=h.useMemo(()=>r.map(c=>({label:c.name,value:c.name})),[r]);return n.jsx(R,{control:e,watch:t,name:"reference_areas",getItem:o,addButtonText:a("chart.reference_area.add"),deleteButtonText:a("chart.reference_area.delete"),renderTabName:l,children:({field:c,index:d})=>n.jsx(By,{control:e,index:d,variableOptions:i})})}const qt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.series.line.type.solid"),value:"solid"},{label:l("chart.series.line.type.dashed"),value:"dashed"},{label:l("chart.series.line.type.dotted"),value:"dotted"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.series.line.type.label"),data:c,value:t,onChange:Z(r),sx:a})});function Oy({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{label:l("chart.orientation.label"),sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:l("chart.y_axis.label"),data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:l("chart.legend.show_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function Ly({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),l=(u,p)=>{const g=u.name.trim();return g||p+1},i=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),c=t("y_axes"),d=h.useMemo(()=>c.map(({name:u},p)=>({label:u,value:p.toString()})),[c]);return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:l,children:({field:u,index:p})=>n.jsx(Oy,{control:e,index:p,watch:t,variableOptions:i,yAxisOptions:d})})}function Ny({control:e,regressionItem:t,index:r,yAxisOptions:a}){const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("chart.regression_line.method.linear"),value:"linear"},{label:o("chart.regression_line.method.exponential"),value:"exponential"},{label:o("chart.regression_line.method.logistic"),value:"logistic"},{label:o("chart.regression_line.method.polynomial"),value:"polynomial"}],[l.language]),c=t.transform.config.method;return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`regressions.${r}.name`,control:e,render:({field:d})=>n.jsx(s.TextInput,{label:o("common.name"),required:!0,sx:{flex:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.group_by_key`,control:e,render:({field:d})=>n.jsx(L,{label:o("chart.series.group_by.label_line"),clearable:!0,sx:{flex:1},...d})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`regressions.${r}.y_axis_data_key`,control:e,render:({field:d})=>n.jsx(L,{label:o("common.data_field"),required:!0,sx:{flex:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.plot.yAxisIndex`,control:e,render:({field:{value:d,onChange:u,...p}})=>n.jsx(s.Select,{label:o("chart.y_axis.label"),data:a,disabled:a.length===0,...p,value:(d==null?void 0:d.toString())??"",onChange:g=>{if(!g){u(0);return}u(Number(g))},sx:{flex:1}})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`regressions.${r}.transform.config.method`,control:e,render:({field:d})=>n.jsx(s.Select,{label:o("chart.regression_line.method.label"),data:i,sx:{flex:1},...d})}),c==="polynomial"&&n.jsx(v.Controller,{name:`regressions.${r}.transform.config.order`,control:e,render:({field:d})=>n.jsx(s.NumberInput,{label:o("chart.regression_line.method.polynomial_order"),sx:{flex:1},...d})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("chart.series.line.line_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`regressions.${r}.plot.lineStyle.type`,control:e,render:({field:d})=>n.jsx(qt,{sx:{flexGrow:1},...d})}),n.jsx(v.Controller,{name:`regressions.${r}.plot.lineStyle.width`,control:e,render:({field:d})=>n.jsx(s.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...d})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`regressions.${r}.plot.color`,control:e,render:({field:d})=>n.jsx(ye,{label:o("chart.color.label"),...d})})})]})}function Gy({control:e,watch:t}){const{t:r}=m.useTranslation(),a=t("y_axes"),o=h.useMemo(()=>a.map(({name:c},d)=>({label:c,value:d.toString()})),[a]),l=()=>({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},group_by_key:"",name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666",lineStyle:{type:"solid",width:1}}}),i=(c,d)=>{const u=c.name.trim();return u||d+1};return n.jsx(R,{control:e,watch:t,name:"regressions",getItem:l,addButtonText:r("chart.regression_line.add"),deleteButtonText:r("chart.regression_line.delete"),renderTabName:i,children:({field:c,index:d})=>n.jsx(Ny,{regressionItem:c,control:e,index:d,yAxisOptions:o})})}const Fy=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Lr={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
|
|
177
|
+
`)}},Qy=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,func_content:_}=i,w={type:b,func_content:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,func_content:b}))},g=()=>{p(Lr.dynamic.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},leftSection:n.jsx(T.IconMathFunction,{size:16}),children:r("chart.symbol_size.setup.label")})}),n.jsx(s.Modal,{size:800,title:r("chart.symbol_size.setup.title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:10,mb:-10,label:r("chart.symbol_size.setup.description"),labelPosition:"center",variant:"dashed"}),n.jsx(Fy,{value:i.func_content,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"right",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},jy=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(Qy,{value:e,onChange:t}),Wy=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{typeof a!="string"&&t({...e,size:a})};return n.jsx(n.Fragment,{children:n.jsx(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:r})})},Nr=h.forwardRef(({label:e,value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("chart.symbol_size.static"),value:"static"},{label:o("chart.symbol_size.dynamic"),value:"dynamic"}],[l.language]),c=d=>{d!=="static"&&d!=="dynamic"||r({...Lr[d]})};return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e??o("chart.symbol_size.label"),data:i,value:t.type,onChange:c,sx:{flexGrow:1}}),n.jsx(Wy,{value:t,onChange:r}),n.jsx(jy,{value:t,onChange:r})]})});function Uy({label:e,value:t,onChange:r,pt:a="sm",withFallback:o},l){const{t:i,i18n:c}=m.useTranslation();h.useEffect(()=>{typeof t=="string"&&r({type:t,config:{},fallback:"0"})},[t,r]);const d=w=>{if(w===null)return;const x=w;switch(x){case"quantile":return r({type:"quantile",config:{p:.99},fallback:t.fallback});case"custom":return r({type:"custom",config:{func:to},fallback:t.fallback});case"pick_record":return r({type:"pick_record",config:{method:"first"},fallback:t.fallback});default:return r({type:x,config:{},fallback:t.fallback})}},u=w=>{const x=Number(w);Number.isNaN(x)||r({type:"quantile",config:{p:x},fallback:t.fallback})},p=w=>{r({type:"custom",config:{func:w},fallback:t.fallback})},g=w=>{w!=="first"&&w!=="last"||r({type:"pick_record",config:{method:w},fallback:t.fallback})},b=w=>{r({...t,fallback:w.currentTarget.value})},_=h.useMemo(()=>[{label:i("aggregation.option.none"),value:"none"},{label:i("aggregation.option.sum"),value:"sum"},{label:i("aggregation.option.min"),value:"min"},{label:i("aggregation.option.mean"),value:"mean"},{label:i("aggregation.option.median"),value:"median"},{label:i("aggregation.option.max"),value:"max"},{label:i("aggregation.option.cov"),value:"CV"},{label:i("aggregation.option.std"),value:"std"},{label:i("aggregation.option.quantile.label_with_hint"),value:"quantile"},{label:i("aggregation.option.pick_record.label"),value:"pick_record"},{label:i("aggregation.option.custom.label"),value:"custom"}],[c.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",pt:a,children:[n.jsx(s.Select,{ref:l,label:e,data:_,value:t.type,onChange:d,maxDropdownHeight:600}),t.type==="quantile"&&n.jsx(s.NumberInput,{label:"p",value:t.config.p,onChange:u,decimalScale:2,min:.05,step:.05,max:1}),t.type==="pick_record"&&n.jsx(s.Select,{label:i("aggregation.option.pick_record.method.label"),value:t.config.method,onChange:g,data:[{label:i("aggregation.option.pick_record.method.first"),value:"first"},{label:i("aggregation.option.pick_record.method.last"),value:"last"}]}),t.type==="custom"&&n.jsx(fr,{title:i("aggregation.option.custom.title"),label:"",triggerLabel:i("aggregation.option.custom.label_trigger"),value:t.config.func,onChange:p,defaultValue:to,triggerButtonProps:{size:"xs",sx:{flexGrow:0,alignSelf:"center",marginTop:"22px"},leftSection:n.jsx(T.IconMathFunction,{size:16}),color:"grape"}})]}),o&&n.jsx(s.TextInput,{label:i("panel.variable.aggregation.fallback_value"),description:i("panel.variable.aggregation.fallback_value_description"),value:t.fallback,onChange:b})]})}const Gr=h.forwardRef(Uy),Ot=h.forwardRef(({label:e,value:t,onChange:r,options:a,withOffOption:o=!1},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>{if(a)return a;const u=[{label:i("chart.label_position.top"),value:"top"},{label:i("chart.label_position.left"),value:"left"},{label:i("chart.label_position.right"),value:"right"},{label:i("chart.label_position.bottom"),value:"bottom"},{label:i("chart.label_position.outside"),value:"outside"},{label:i("chart.label_position.inside"),value:"inside"},{label:i("chart.label_position.inside_left"),value:"insideLeft"},{label:i("chart.label_position.inside_right"),value:"insideRight"},{label:i("chart.label_position.inside_top"),value:"insideTop"},{label:i("chart.label_position.inside_bottom"),value:"insideBottom"},{label:i("chart.label_position.inside_top_left"),value:"insideTopLeft"},{label:i("chart.label_position.inside_bottom_left"),value:"insideBottomLeft"},{label:i("chart.label_position.inside_top_right"),value:"insideTopRight"},{label:i("chart.label_position.inside_bottom_right"),value:"insideBottomRight"}];return o&&u.unshift({label:i("chart.label_position.off"),value:""}),u},[c.language,a,o]);return n.jsx(s.Select,{ref:l,label:e,data:d,value:t,onChange:r})});function Ky({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=!!r.barWidth.trim(),i=h.useMemo(()=>[{label:a("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:a("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.bar.bar_gap.label"),data:i,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.min"),disabled:l,sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.max"),disabled:l,sx:{flexGrow:1},...c})})]})]})}function Yy({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=r.showSymbol,i=h.useMemo(()=>[{label:a("chart.series.line.step.off"),value:"false"},{label:a("chart.series.line.step.start"),value:"start"},{label:a("chart.series.line.step.middle"),value:"middle"},{label:a("chart.series.line.step.end"),value:"end"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:a("chart.series.line.line_settings"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`series.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,align:"center",children:[n.jsx(v.Controller,{name:`series.${t}.step`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.line.step.label"),data:i,sx:{flexGrow:1,maxWidth:"48%"},...c,value:String(c.value),onChange:Z(d=>{const u=d==="false"?!1:d;c.onChange(u)})})}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`series.${t}.smooth`,control:e,render:({field:c})=>n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.smooth_line"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})}),n.jsx(v.Controller,{name:`series.${t}.display_name_on_line`,control:e,render:({field:c})=>n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.show_name_on_line"),checked:c.value??!1,onChange:d=>c.onChange(d.currentTarget.checked)})})})]})]}),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`series.${t}.showSymbol`,control:e,render:({field:c})=>n.jsx(s.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:n.jsx(s.Switch,{label:a("chart.series.line.show_symbol_on_line"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})}),l&&n.jsx(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:c})=>n.jsx(Nr,{...c})})]}),n.jsx(v.Controller,{name:`series.${t}.areaStyle`,control:e,render:({field:c})=>n.jsx(Ab,{...c})})]})}function Xy({control:e,index:t}){return n.jsx(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:r})=>n.jsx(Nr,{label:"Size",...r})})}function Zy({control:e,index:t,seriesItem:r,yAxisOptions:a}){const{t:o}=m.useTranslation(),l=r.type,i=r.group_by_key;return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:`series.${t}.type`,control:e,render:({field:c})=>n.jsx(s.SegmentedControl,{data:[{label:o("chart.series.line.label"),value:"line"},{label:o("chart.series.bar.label"),value:"bar"},{label:o("chart.series.scatter.label"),value:"scatter"}],...c})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:o("chart.series.name"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:o("chart.series.y_axis"),data:a,disabled:a.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{name:`series.${t}.y_axis_data_key`,control:e,render:({field:c})=>n.jsx(L,{label:o("chart.series.data_field"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:c})=>n.jsx(Gr,{label:o("viz.cartesian_chart.series.aggregation.label"),value:c.value??Vt,onChange:c.onChange,pt:0,withFallback:!1})})]}),n.jsx(s.Group,{grow:!0,children:n.jsx(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:c})=>n.jsx(L,{label:o("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...c})})}),!!i&&n.jsx(v.Controller,{name:`series.${t}.order_in_group`,control:e,render:({field:c})=>n.jsx(el,{label:o("chart.series_order.label"),hiddenKeys:["value"],...c})}),n.jsx(v.Controller,{name:`series.${t}.unit`,control:e,render:({field:c})=>n.jsx(ue,{...c})}),l==="line"&&n.jsx(Yy,{index:t,control:e,seriesItem:r}),l==="bar"&&n.jsx(Ky,{index:t,control:e,seriesItem:r}),l==="scatter"&&n.jsx(Xy,{index:t,control:e}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:c})=>n.jsx(Ot,{label:o("chart.label_position.label"),withOffOption:!0,...c})}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`series.${t}.color`,control:e,render:({field:c})=>n.jsx(ye,{label:o("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:o("chart.legend.hide_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function Jy({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({type:"bar",name:te.randomId(),unit:K(),showSymbol:!1,symbolSize:Lr.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:"",order_in_group:xn(),areaStyle:Ro()}),o=(c,d)=>{const u=c.name.trim();return u||d+1},l=t("y_axes"),i=h.useMemo(()=>l.map(({name:c},d)=>({label:c,value:d.toString()})),[l]);return n.jsx(R,{control:e,watch:t,name:"series",getItem:a,addButtonText:r("chart.series.add"),deleteButtonText:r("chart.series.delete"),renderTabName:o,children:({field:c,index:d})=>n.jsx(Zy,{control:e,index:d,seriesItem:c,yAxisOptions:i})})}const Hy=k.observer(({control:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.above_chart")},`${t.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.under_chart")},`${t.id}.stats.bottom`)})]})}),Ry=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},ev=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Ry,{control:e,index:i})})]})};function tv({control:e,watch:t}){return n.jsx(s.Stack,{children:n.jsx(ev,{control:e,watch:t})})}const nv=()=>{const{t:e}=m.useTranslation();return n.jsxs(s.Group,{sx:{display:"inline-flex"},gap:6,mr:14,children:[n.jsx(s.Text,{size:"sm",children:e("chart.x_axis.x_axis_type")}),n.jsxs(s.HoverCard,{width:340,shadow:"md",position:"top",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",sx:{transform:"none !important"},children:n.jsx(T.IconInfoCircle,{})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.Text,{size:"sm",children:n.jsxs(m.Trans,{i18nKey:"chart.axis.type.click_to_learn_more",children:["Click",n.jsx(s.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:3,children:"here"}),"to learn more about these options"]})})})]})]})};function rv({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t(["x_axis_data_key","x_axis_name","x_axis"]);const o=h.useMemo(()=>[{label:r("chart.axis.type.value"),value:"value"},{label:r("chart.axis.type.category"),value:"category"},{label:r("chart.axis.type.time"),value:"time"},{label:r("chart.axis.type.log"),value:"log"}],[a.language]);return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"x_axis_name",control:e,render:({field:l})=>n.jsx(s.TextInput,{label:r("chart.x_axis.x_axis_name"),sx:{flex:1},...l})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis_data_key",control:e,render:({field:l})=>n.jsx(L,{label:r("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:"x_axis.type",control:e,render:({field:l})=>n.jsx(s.Select,{label:n.jsx(nv,{}),required:!0,data:o,sx:{flex:1},...l})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:l})=>n.jsx(st,{sx:{width:"48%"},...l})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:l})=>n.jsx(Re,{...l})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:l})=>n.jsx(et,{...l})})]})}const yt=h.forwardRef(({label:e,value:t,onChange:r,sx:a={},disabled:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=h.useMemo(()=>[{label:i("chart.name_text.align.left"),value:"left"},{label:i("chart.name_text.align.center"),value:"center"},{label:i("chart.name_text.align.right"),value:"right"}],[c.language]);return n.jsx(s.Select,{ref:l,label:e??i("chart.name_text.align.label"),data:d,value:t,onChange:Z(r),sx:a,disabled:o})}),al=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.y_axis.position.left"),value:"left"},{label:l("chart.y_axis.position.right"),value:"right"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.y_axis.position.label"),data:c,value:t,onChange:Z(r),sx:a})});function av({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsx(s.Divider,{mb:-15,mt:15,variant:"dashed",label:r("common.name"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.y_axis_name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.layout"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(al,{sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.mirror`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{pt:20,label:r("chart.y_axis.mirror.label"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_max"),...a})})]})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:r("chart.y_axis.behavior"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.show`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{label:r("chart.y_axis.visible"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})}function sv({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({name:"",position:"left",nameAlignment:"left",label_formatter:de,min:"",max:"",show:!0,mirror:!1}),o=(i,c)=>{const d=i.name.trim();return d||c+1},l=({field:i,index:c,fields:d})=>d.length<=1;return n.jsx(R,{control:e,watch:t,name:"y_axes",getItem:a,addButtonText:r("chart.y_axis.add"),deleteButtonText:r("chart.y_axis.delete"),renderTabName:o,deleteDisalbed:l,children:({field:i,index:c})=>n.jsx(av,{control:e,index:c})})}function ov({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),{variables:o}=r,l=h.useMemo(()=>y.defaults({},e),[e]),{control:i,handleSubmit:c,watch:d,reset:u,formState:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{u(l)},[l]),d(["dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(t),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:a("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axes",children:a("chart.y_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Series",children:a("chart.series.label")}),n.jsx(s.Tabs.Tab,{value:"Regression Lines",children:a("chart.regression_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:a("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:a("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:a("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Reference Areas",children:a("chart.reference_area.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:a("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(rv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axes",children:n.jsx(sv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Series",children:n.jsx(Jy,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Regression Lines",children:n.jsx(Gy,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(tv,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(Hy,{control:i})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(Ly,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Areas",children:n.jsx(qy,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function lv(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(ov,{conf:t,setConf:r,...e}):null}const iv={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new ay,name:"cartesian",viewRender:Ey,configRender:lv,createConfig(){return{version:24,config:y.cloneDeep(tl)}},triggers:[Br],translation:sy};function cv(e){if(e.enable_value)return e.value}function dv(e){if(e.enable_value)return e.value}function uv(e){const t=e.axisLabel.overflow.on_axis.width,r=e.axisLabel.position,a={top:5,left:5,right:5,bottom:5};return e.orient==="vertical"&&y.get(a,r)&&r===e.funnelAlign&&y.set(a,r,t),a}function pv(e,t){return e.series.map(r=>{const{level_name_data_key:a,level_value_data_key:o,axisLabel:l,min:i,max:c,funnelAlign:d,orient:u,...p}=r;if(!a||!o)return{};const g=$(a),b=$(o),_=t[g.queryID].map(x=>({name:x[g.columnKey],value:x[b.columnKey]})),w=Ke(l.overflow.on_axis);return{type:"funnel",...uv(r),min:cv(i),max:dv(c),minSize:i.size,maxSize:c.size,...p,label:{show:!0,position:l.position,...w},orient:u,funnelAlign:u==="horizontal"?"center":d,data:_}})}function hv({conf:e,params:t,max:r}){const{name:a,value:o}=t.data,l=Y(o/r,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1});return[{label:`${t.marker} ${a}`,value:`${o} (${l})`,style:{label:"",value:""}}]}function gv(e,t){var l;const r=$(e.series[0].level_name_data_key),a=$(e.series[0].level_value_data_key),o=(l=y.maxBy(t[r.queryID],a.columnKey))==null?void 0:l[a.columnKey];return i=>{const d=hv({conf:e,params:i,max:o}).map(p=>`
|
|
178
178
|
<tr>
|
|
179
179
|
<th style="text-align: right;">
|
|
180
180
|
<div style="${p.style.label}">${p.label}</div>
|
|
@@ -190,7 +190,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
190
190
|
<table style="width: auto">
|
|
191
191
|
<tbody>${d.join("")}</tbody>
|
|
192
192
|
</table>
|
|
193
|
-
`}}function fv(e,t){return X.getTooltip({trigger:"item",formatter:gv(e,t)})}function bv(e,t){return{grid:{top:0,left:0,right:0,bottom:0},tooltip:fv(e,t),series:pv(e,t)}}function yv(e){return e||(e=Date.now().toString()),{id:e,name:e,level_name_data_key:"",level_value_data_key:"",min:{value:0,enable_value:!1,size:"0%"},max:{value:0,enable_value:!1,size:"100%"},gap:2,axisLabel:{show:!0,position:"inside",overflow:Ie()},sort:"descending",orient:"vertical",funnelAlign:"center"}}const Gr={series:[yv("Funnel")]};function vv({conf:e,data:t,width:r,height:a,instance:o}){const l=h.useMemo(()=>bv(e,t),[e,t]),i=h.useRef(null),c=h.useCallback(()=>{var p;const u=(p=i.current)==null?void 0:p.getEchartsInstance();u&&fe(o,u.getOption())},[o]),d=h.useMemo(()=>({finished:c}),[c]);return n.jsx(he,{ref:i,onEvents:d,echarts:ce,option:l,style:{width:r,height:a},notMerge:!0,theme:"merico-light"})}function _v({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},r,Gr),[r]),o=e.data,{width:l,height:i}=e.viewport;return!l||!i?null:n.jsx(ve,{width:l,height:i,children:n.jsx(vv,{instance:t,width:qe(l),height:Oe(i),data:o,conf:a})})}const mv=({item:e,control:t,index:r,remove:a})=>{const{t:o,i18n:l}=m.useTranslation(),i=e.min.enable_value,c=e.max.enable_value,{orient:d}=e,u=h.useMemo(()=>({horizontal:[{label:o("chart.label_position.top"),value:"top"},{label:o("chart.label_position.inside_center"),value:"inside"},{label:o("chart.label_position.bottom"),value:"bottom"}],vertical:[{label:o("chart.label_position.left"),value:"left"},{label:o("chart.label_position.inside_left"),value:"insideLeft"},{label:o("chart.label_position.inside_center"),value:"inside"},{label:o("chart.label_position.inside_right"),value:"insideRight"},{label:o("chart.label_position.right"),value:"right"}]}),[l.language]),p=h.useMemo(()=>[{label:o("viz.funnel_chart.sort.ascending"),value:"ascending"},{label:o("viz.funnel_chart.sort.descending"),value:"descending"},{label:o("viz.funnel_chart.sort.none"),value:"0"}],[l.language]);return n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`series.${r}.name`,control:t,render:({field:g})=>n.jsx(s.TextInput,{label:o("viz.funnel_chart.series_name"),...g})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.level_name_data_key`,control:t,render:({field:g})=>n.jsx(L,{label:o("viz.funnel_chart.level_name_field"),...g})}),n.jsx(v.Controller,{name:`series.${r}.level_value_data_key`,control:t,render:({field:g})=>n.jsx(L,{label:o("viz.funnel_chart.level_value_field"),...g})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("viz.funnel_chart.funnel_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.min.value`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{disabled:!i,labelProps:{display:"block"},label:n.jsxs(s.Group,{justify:"space-between",pr:6,sx:{width:"100%"},children:[n.jsx(s.Text,{size:"sm",children:o("viz.funnel_chart.min_value")}),n.jsx(s.Tooltip,{label:o("viz.funnel_chart.min_value_checkbox_tip"),children:n.jsx(s.Box,{children:n.jsx(v.Controller,{name:`series.${r}.min.enable_value`,control:t,render:({field:b})=>n.jsx(s.Checkbox,{size:"xs",checked:b.value,onChange:_=>b.onChange(_.currentTarget.checked)})})})})]}),...g})}),n.jsx(v.Controller,{name:`series.${r}.min.size`,control:t,render:({field:g})=>n.jsx(s.TextInput,{placeholder:"0%",label:o("viz.funnel_chart.min_size"),...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.max.value`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{disabled:!c,labelProps:{display:"block"},label:n.jsxs(s.Group,{justify:"space-between",pr:6,sx:{width:"100%"},children:[n.jsx(s.Text,{size:"sm",children:o("viz.funnel_chart.max_value")}),n.jsx(s.Tooltip,{label:o("viz.funnel_chart.max_value_checkbox_tip"),children:n.jsx(s.Box,{children:n.jsx(v.Controller,{name:`series.${r}.max.enable_value`,control:t,render:({field:b})=>n.jsx(s.Checkbox,{size:"xs",checked:b.value,onChange:_=>b.onChange(_.currentTarget.checked)})})})})]}),...g})}),n.jsx(v.Controller,{name:`series.${r}.max.size`,control:t,render:({field:g})=>n.jsx(s.TextInput,{placeholder:"100%",label:o("viz.funnel_chart.max_size"),...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.orient`,control:t,render:({field:g})=>n.jsx(bt,{...g})}),n.jsx(v.Controller,{name:`series.${r}.sort`,control:t,render:({field:g})=>n.jsx(s.Select,{label:o("viz.funnel_chart.sort.label"),data:p,...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.funnelAlign`,control:t,render:({field:g})=>n.jsx(yt,{label:o("viz.funnel_chart.align"),disabled:d==="horizontal",...g})}),n.jsx(v.Controller,{name:`series.${r}.gap`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{placeholder:"0, 5, 10...",label:o("viz.funnel_chart.gap"),...g})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.label.label_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.axisLabel.position`,control:t,render:({field:g})=>n.jsx(Ot,{label:o("chart.label_position.label"),options:u[d],...g})}),n.jsx(s.Box,{})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`series.${r}.axisLabel.overflow`,control:t,render:({field:g})=>n.jsx(et,{...g})})})]})},wv=({control:e,watch:t})=>{const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"series"}),l=t("series"),i=r.map((p,g)=>({...p,...l[g]})),c=y.get(i,"0.id"),[d,u]=h.useState(c??null);return h.useEffect(()=>{c&&u(p=>p!==null?p:c)},[c]),n.jsxs(s.Tabs,{value:d,onChange:p=>u(p),styles:{panel:{padding:"0px",paddingTop:"6px"}},children:[n.jsxs(s.Tabs.List,{children:[i.map((p,g)=>n.jsx(s.Tabs.Tab,{value:p.id,children:p.name},p.id)),n.jsx(s.Tabs.Tab,{value:"add",disabled:!0,children:n.jsx(s.Tooltip,{label:"todo",children:n.jsx(s.Center,{children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})})})]}),i.map((p,g)=>n.jsx(s.Tabs.Panel,{value:p.id,children:n.jsx(mv,{item:p,control:e,index:g,remove:o})},p.id))]})};function xv({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Gr),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsx(wv,{control:o,watch:i})]})})}const Cv=[{lang:"en",resources:{funnel_chart:{viz_name:"Funnel Chart",series_name:"Series Name",level_name_field:"Level Name Field",level_value_field:"Level Value Field",funnel_style:"Funnel Style",min_value:"Min Value",min_value_checkbox_tip:"Check to enable specific min value",max_value:"Max Value",max_value_checkbox_tip:"Check to enable specific max value",min_size:"Min Size",max_size:"Max Size",sort:{label:"Sort",ascending:"Ascending",descending:"Descending",none:"Use original data order"},gap:"Gap",align:"Align"}}},{lang:"zh",resources:{funnel_chart:{viz_name:"漏斗图",series_name:"系列名称",level_name_field:"层名字段",level_value_field:"层值字段",funnel_style:"漏斗样式",min_value:"最小值",min_value_checkbox_tip:"勾选以启用最小值设置",max_value:"最大值",max_value_checkbox_tip:"勾选以启用最大值设置",min_size:"最小尺寸",max_size:"最大尺寸",sort:{label:"排序",ascending:"升序",descending:"降序",none:"依原始数据的顺序"},gap:"间距",align:"对齐"}}}];function Sv(e){return{series:e.series.map(t=>{const{min:r,minSize:a,max:o,maxSize:l,...i}=t;return{...i,min:{value:r,use_data_min:!1,size:a},max:{value:o,use_data_max:!1,size:l}}})}}function Tv(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=i=>i&&`${r}.${i}`,{series:o,...l}=e;return{...l,series:o.map(i=>({...i,level_name_data_key:a(i.level_name_data_key),level_value_data_key:a(i.level_value_data_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}class kv extends J{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{config:a}=r;return{...r,version:2,config:Sv(a)}}),this.version(3,(r,a)=>{const{config:o}=r;return{...r,version:3,config:Tv(o,a)}})}}const Dv={displayName:"viz.funnel_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new kv,name:"funnel",viewRender:_v,configRender:xv,createConfig:()=>({version:3,config:Gr}),translation:Cv},zv=({page:e,setPage:t,totalPages:r})=>n.jsx(s.Pagination,{size:"xs",withControls:!1,siblings:1,color:"gray",value:e,onChange:t,total:r}),Mv=({page:e,setPage:t,totalPages:r})=>{const a=h.useMemo(()=>Array.from(new Array(r),(o,l)=>({label:String(l+1),value:String(l+1)})),[r]);return n.jsx(s.NativeSelect,{size:"xs",value:e,onChange:o=>{t(Number(o.currentTarget.value))},data:a})},Iv=e=>e.totalPages<=1?null:n.jsx(s.Box,{sx:{position:"absolute",top:"calc(1rem + 5px)",right:"calc(1rem + 5px)",zIndex:2},children:e.width>600?n.jsx(zv,{...e}):n.jsx(Mv,{...e})});function Vv(e){const t=Me(e.x_axis.axisLabel.formatter),r=Me(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:r}}function Pv(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function $v(e){let t=0;return e.x_axis.name&&(t+=20),{show:!0,top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Av(e,t,r){const{heat_block:a}=e;return{type:"heatmap",name:a.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderColor:"white",borderWidth:r},data:t,label:a.label,labelLayout:{hideOverlap:!0},z:2}}const Ev=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Bv({conf:e,labelFormatters:t,valueFormatters:r,dataDict:a,params:o,metricUnitMap:l}){const{value:i,dataIndex:c}=o,[d,u,p]=i,g={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(d,c),style:{label:"",value:Le(e.x_axis.axisLabel.overflow.in_tooltip)},unit:""},b={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,c),style:{label:"",value:Le(e.y_axis.axisLabel.overflow.in_tooltip)},unit:""},_={label:e.heat_block.name,value:r.heat_block(p),style:{label:"",value:""},unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""},w=[g,b,_],x=a[`${d}---${u}`];return x&&e.tooltip.metrics.forEach(S=>{const D=$(S.data_key),z=l[S.name];w.push({label:S.name,value:Ev(y.get(x,D.columnKey,"")),style:{label:"",value:""},unit:z})}),w}function qv(e,t,r,a){const{x_axis:o,y_axis:l,heat_block:i}=e,c=$(o.data_key),d=$(l.data_key);$(i.data_key);const u=y.keyBy(t[c.queryID],g=>`${g[c.columnKey]}---${g[d.columnKey]}`),p=e.tooltip.metrics.reduce((g,{unit:b,name:_})=>(b.show_in_tooltip&&(g[_]=b.text),g),{});return X.getTooltip({formatter:function(g){const _=Bv({conf:e,labelFormatters:r,valueFormatters:a,dataDict:u,params:g,metricUnitMap:p}).map(x=>`
|
|
193
|
+
`}}function fv(e,t){return X.getTooltip({trigger:"item",formatter:gv(e,t)})}function bv(e,t){return{grid:{top:0,left:0,right:0,bottom:0},tooltip:fv(e,t),series:pv(e,t)}}function yv(e){return e||(e=Date.now().toString()),{id:e,name:e,level_name_data_key:"",level_value_data_key:"",min:{value:0,enable_value:!1,size:"0%"},max:{value:0,enable_value:!1,size:"100%"},gap:2,axisLabel:{show:!0,position:"inside",overflow:Ie()},sort:"descending",orient:"vertical",funnelAlign:"center"}}const Fr={series:[yv("Funnel")]};function vv({conf:e,data:t,width:r,height:a,instance:o}){const l=h.useMemo(()=>bv(e,t),[e,t]),i=h.useRef(null),c=h.useCallback(()=>{var p;const u=(p=i.current)==null?void 0:p.getEchartsInstance();u&&fe(o,u.getOption())},[o]),d=h.useMemo(()=>({finished:c}),[c]);return n.jsx(he,{ref:i,onEvents:d,echarts:ce,option:l,style:{width:r,height:a},notMerge:!0,theme:"merico-light"})}function _v({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},r,Fr),[r]),o=e.data,{width:l,height:i}=e.viewport;return!l||!i?null:n.jsx(ve,{width:l,height:i,children:n.jsx(vv,{instance:t,width:qe(l),height:Oe(i),data:o,conf:a})})}const mv=({item:e,control:t,index:r,remove:a})=>{const{t:o,i18n:l}=m.useTranslation(),i=e.min.enable_value,c=e.max.enable_value,{orient:d}=e,u=h.useMemo(()=>({horizontal:[{label:o("chart.label_position.top"),value:"top"},{label:o("chart.label_position.inside_center"),value:"inside"},{label:o("chart.label_position.bottom"),value:"bottom"}],vertical:[{label:o("chart.label_position.left"),value:"left"},{label:o("chart.label_position.inside_left"),value:"insideLeft"},{label:o("chart.label_position.inside_center"),value:"inside"},{label:o("chart.label_position.inside_right"),value:"insideRight"},{label:o("chart.label_position.right"),value:"right"}]}),[l.language]),p=h.useMemo(()=>[{label:o("viz.funnel_chart.sort.ascending"),value:"ascending"},{label:o("viz.funnel_chart.sort.descending"),value:"descending"},{label:o("viz.funnel_chart.sort.none"),value:"0"}],[l.language]);return n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`series.${r}.name`,control:t,render:({field:g})=>n.jsx(s.TextInput,{label:o("viz.funnel_chart.series_name"),...g})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.level_name_data_key`,control:t,render:({field:g})=>n.jsx(L,{label:o("viz.funnel_chart.level_name_field"),...g})}),n.jsx(v.Controller,{name:`series.${r}.level_value_data_key`,control:t,render:({field:g})=>n.jsx(L,{label:o("viz.funnel_chart.level_value_field"),...g})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("viz.funnel_chart.funnel_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.min.value`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{disabled:!i,labelProps:{display:"block"},label:n.jsxs(s.Group,{justify:"space-between",pr:6,sx:{width:"100%"},children:[n.jsx(s.Text,{size:"sm",children:o("viz.funnel_chart.min_value")}),n.jsx(s.Tooltip,{label:o("viz.funnel_chart.min_value_checkbox_tip"),children:n.jsx(s.Box,{children:n.jsx(v.Controller,{name:`series.${r}.min.enable_value`,control:t,render:({field:b})=>n.jsx(s.Checkbox,{size:"xs",checked:b.value,onChange:_=>b.onChange(_.currentTarget.checked)})})})})]}),...g})}),n.jsx(v.Controller,{name:`series.${r}.min.size`,control:t,render:({field:g})=>n.jsx(s.TextInput,{placeholder:"0%",label:o("viz.funnel_chart.min_size"),...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.max.value`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{disabled:!c,labelProps:{display:"block"},label:n.jsxs(s.Group,{justify:"space-between",pr:6,sx:{width:"100%"},children:[n.jsx(s.Text,{size:"sm",children:o("viz.funnel_chart.max_value")}),n.jsx(s.Tooltip,{label:o("viz.funnel_chart.max_value_checkbox_tip"),children:n.jsx(s.Box,{children:n.jsx(v.Controller,{name:`series.${r}.max.enable_value`,control:t,render:({field:b})=>n.jsx(s.Checkbox,{size:"xs",checked:b.value,onChange:_=>b.onChange(_.currentTarget.checked)})})})})]}),...g})}),n.jsx(v.Controller,{name:`series.${r}.max.size`,control:t,render:({field:g})=>n.jsx(s.TextInput,{placeholder:"100%",label:o("viz.funnel_chart.max_size"),...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.orient`,control:t,render:({field:g})=>n.jsx(bt,{...g})}),n.jsx(v.Controller,{name:`series.${r}.sort`,control:t,render:({field:g})=>n.jsx(s.Select,{label:o("viz.funnel_chart.sort.label"),data:p,...g})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.funnelAlign`,control:t,render:({field:g})=>n.jsx(yt,{label:o("viz.funnel_chart.align"),disabled:d==="horizontal",...g})}),n.jsx(v.Controller,{name:`series.${r}.gap`,control:t,render:({field:g})=>n.jsx(s.NumberInput,{placeholder:"0, 5, 10...",label:o("viz.funnel_chart.gap"),...g})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.label.label_style"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${r}.axisLabel.position`,control:t,render:({field:g})=>n.jsx(Ot,{label:o("chart.label_position.label"),options:u[d],...g})}),n.jsx(s.Box,{})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`series.${r}.axisLabel.overflow`,control:t,render:({field:g})=>n.jsx(et,{...g})})})]})},wv=({control:e,watch:t})=>{const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"series"}),l=t("series"),i=r.map((p,g)=>({...p,...l[g]})),c=y.get(i,"0.id"),[d,u]=h.useState(c??null);return h.useEffect(()=>{c&&u(p=>p!==null?p:c)},[c]),n.jsxs(s.Tabs,{value:d,onChange:p=>u(p),styles:{panel:{padding:"0px",paddingTop:"6px"}},children:[n.jsxs(s.Tabs.List,{children:[i.map((p,g)=>n.jsx(s.Tabs.Tab,{value:p.id,children:p.name},p.id)),n.jsx(s.Tabs.Tab,{value:"add",disabled:!0,children:n.jsx(s.Tooltip,{label:"todo",children:n.jsx(s.Center,{children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})})})]}),i.map((p,g)=>n.jsx(s.Tabs.Panel,{value:p.id,children:n.jsx(mv,{item:p,control:e,index:g,remove:o})},p.id))]})};function xv({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Fr),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsx(wv,{control:o,watch:i})]})})}const Cv=[{lang:"en",resources:{funnel_chart:{viz_name:"Funnel Chart",series_name:"Series Name",level_name_field:"Level Name Field",level_value_field:"Level Value Field",funnel_style:"Funnel Style",min_value:"Min Value",min_value_checkbox_tip:"Check to enable specific min value",max_value:"Max Value",max_value_checkbox_tip:"Check to enable specific max value",min_size:"Min Size",max_size:"Max Size",sort:{label:"Sort",ascending:"Ascending",descending:"Descending",none:"Use original data order"},gap:"Gap",align:"Align"}}},{lang:"zh",resources:{funnel_chart:{viz_name:"漏斗图",series_name:"系列名称",level_name_field:"层名字段",level_value_field:"层值字段",funnel_style:"漏斗样式",min_value:"最小值",min_value_checkbox_tip:"勾选以启用最小值设置",max_value:"最大值",max_value_checkbox_tip:"勾选以启用最大值设置",min_size:"最小尺寸",max_size:"最大尺寸",sort:{label:"排序",ascending:"升序",descending:"降序",none:"依原始数据的顺序"},gap:"间距",align:"对齐"}}}];function Sv(e){return{series:e.series.map(t=>{const{min:r,minSize:a,max:o,maxSize:l,...i}=t;return{...i,min:{value:r,use_data_min:!1,size:a},max:{value:o,use_data_max:!1,size:l}}})}}function Tv(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=i=>i&&`${r}.${i}`,{series:o,...l}=e;return{...l,series:o.map(i=>({...i,level_name_data_key:a(i.level_name_data_key),level_value_data_key:a(i.level_value_data_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}class kv extends J{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{config:a}=r;return{...r,version:2,config:Sv(a)}}),this.version(3,(r,a)=>{const{config:o}=r;return{...r,version:3,config:Tv(o,a)}})}}const Dv={displayName:"viz.funnel_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new kv,name:"funnel",viewRender:_v,configRender:xv,createConfig:()=>({version:3,config:Fr}),translation:Cv},zv=({page:e,setPage:t,totalPages:r})=>n.jsx(s.Pagination,{size:"xs",withControls:!1,siblings:1,color:"gray",value:e,onChange:t,total:r}),Mv=({page:e,setPage:t,totalPages:r})=>{const a=h.useMemo(()=>Array.from(new Array(r),(o,l)=>({label:String(l+1),value:String(l+1)})),[r]);return n.jsx(s.NativeSelect,{size:"xs",value:e,onChange:o=>{t(Number(o.currentTarget.value))},data:a})},Iv=e=>e.totalPages<=1?null:n.jsx(s.Box,{sx:{position:"absolute",top:"calc(1rem + 5px)",right:"calc(1rem + 5px)",zIndex:2},children:e.width>600?n.jsx(zv,{...e}):n.jsx(Mv,{...e})});function Vv(e){const t=Me(e.x_axis.axisLabel.formatter),r=Me(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:r}}function Pv(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function $v(e){let t=0;return e.x_axis.name&&(t+=20),{show:!0,top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Av(e,t,r){const{heat_block:a}=e;return{type:"heatmap",name:a.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderColor:"white",borderWidth:r},data:t,label:a.label,labelLayout:{hideOverlap:!0},z:2}}const Ev=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Bv({conf:e,labelFormatters:t,valueFormatters:r,dataDict:a,params:o,metricUnitMap:l}){const{value:i,dataIndex:c}=o,[d,u,p]=i,g={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(d,c),style:{label:"",value:Le(e.x_axis.axisLabel.overflow.in_tooltip)},unit:""},b={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,c),style:{label:"",value:Le(e.y_axis.axisLabel.overflow.in_tooltip)},unit:""},_={label:e.heat_block.name,value:r.heat_block(p),style:{label:"",value:""},unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""},w=[g,b,_],x=a[`${d}---${u}`];return x&&e.tooltip.metrics.forEach(S=>{const D=$(S.data_key),z=l[S.name];w.push({label:S.name,value:Ev(y.get(x,D.columnKey,"")),style:{label:"",value:""},unit:z})}),w}function qv(e,t,r,a){const{x_axis:o,y_axis:l,heat_block:i}=e,c=$(o.data_key),d=$(l.data_key);$(i.data_key);const u=y.keyBy(t[c.queryID],g=>`${g[c.columnKey]}---${g[d.columnKey]}`),p=e.tooltip.metrics.reduce((g,{unit:b,name:_})=>(b.show_in_tooltip&&(g[_]=b.text),g),{});return X.getTooltip({formatter:function(g){const _=Bv({conf:e,labelFormatters:r,valueFormatters:a,dataDict:u,params:g,metricUnitMap:p}).map(x=>`
|
|
194
194
|
<tr>
|
|
195
195
|
<th style="text-align: right; padding: 0 1em;">
|
|
196
196
|
<div style="${x.style.label}">${x.label}</div>
|
|
@@ -214,7 +214,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
214
214
|
</thead>
|
|
215
215
|
<tbody>${_.join("")}</tbody>
|
|
216
216
|
</table>
|
|
217
|
-
`}})}function Ov(e,t,r,a){const{overflow:o,rotate:l}=e.x_axis.axisLabel,i=Ke(o.on_axis);return X.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...i,formatter:r},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:a>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Lv(e,t,r){const{nameAlignment:a,data_key:o,inverse:l,...i}=e.y_axis,{overflow:c,rotate:d}=e.y_axis.axisLabel,u=Ke(c.on_axis);return X.getYAxis({...i,type:"category",axisLabel:{rotate:d,...u,formatter:t},axisTick:{show:!0,alignWithLabel:!0},axisLine:{show:!0,lineStyle:{width:3}},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:r>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameTextStyle:{fontWeight:"bold",align:a},nameLocation:l?"start":"end",nameGap:15,inverse:l,z:3})}function Nv(e,t,r,a){return r<e*10||a<t*10?0:r<e*20||a<t*20?1:2}function sl(e,t,r,a,o,l){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const i=a.reduce((I,A)=>{const E=He(A,t);return I[A.name]=Be(A,E),I},{}),c=pn(e.visualMap,i),{min:d,max:u}=c,p=Vv(e),g=Pv(e),b=$(e.x_axis.data_key),_=$(e.y_axis.data_key),w=y.uniq(t[b.queryID].map(I=>I[b.columnKey])),x=y.uniq(t[b.queryID].map(I=>I[_.columnKey])),S=r.map(I=>{const A=y.clone(I),{followVisualMap:E,color:U}=pr(A.value[2],d,u,e.visualMap);return E||(A.visualMap=!1,A.itemStyle={color:U}),A}),D=Nv(w.length,x.length,o,l);return{xAxis:Ov(e,w,p.x_axis,D),yAxis:Lv(e,p.y_axis,D),series:Av(e,S,D),tooltip:qv(e,t,p,g),grid:$v(e),visualMap:c}}function Gv(e,t){const r=h.useMemo(()=>$(t.x_axis.data_key),[t.x_axis.data_key]),a=h.useMemo(()=>$(t.y_axis.data_key),[t.y_axis.data_key]),o=h.useMemo(()=>$(t.heat_block.data_key),[t.heat_block.data_key]),l=h.useMemo(()=>{const c=e[r.queryID];if(!c)return{};const d=c.map(u=>{const p=y.get(u,r.columnKey),g=y.get(u,a.columnKey),b=y.get(u,o.columnKey);return{value:[p,g,b]}});return y.groupBy(d,"value.1")},[e,r,a,o]);return{totalPages:h.useMemo(()=>{const c=Object.keys(l).length;return t.pagination.page_size===0?c:y.ceil(c/t.pagination.page_size)},[l,t.pagination.page_size]),groupedFullData:l}}function Fv(e,t,r){return h.useMemo(()=>{const o=Object.values(e);if(t.pagination.page_size===0)return o.flat();const l=(r-1)*t.pagination.page_size,i=r*t.pagination.page_size;return o.slice(l,i).flat()},[e,r,t.pagination.page_size])}function Qv(e){return n.jsx(n.Fragment,{})}function jv(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const ol={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:jv,configRender:Qv,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function ll({page_size:e=20}){return{page_size:e}}const Fr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},y_axis:{name:"Y Axis",inverse:!1,data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:rt(),pagination:ll({page_size:20})};function Wv({conf:e,data:t,seriesData:r,width:a,height:o,interactionManager:l,variables:i}){const c=h.useMemo(()=>{const _=$(e.x_axis.data_key),w=$(e.y_axis.data_key);return y.keyBy(t[_.queryID],x=>`${x[_.columnKey]}---${x[w.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),d=Ve(l.triggerManager,ol.id),u=h.useCallback(_=>{const[w,x]=_.value,S=y.get(c,`${w}---${x}`,{error:"rowData is not found"});d.forEach(D=>{l.runInteraction(D.id,{..._,rowData:S})})},[c,d,l]),p=h.useRef(null),g=h.useMemo(()=>({click:u}),[u]),b=h.useMemo(()=>sl(e,t,r,i,a,o),[e,t,r,a,o]);return n.jsx(he,{echarts:ce,option:b,style:{width:a,height:o},ref:p,onEvents:g,notMerge:!0,theme:"merico-light"})}function Uv({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Fr),[a]),i=e.data,{width:c,height:d}=e.viewport,{totalPages:u,groupedFullData:p}=Gv(i,l);h.useEffect(()=>{const w=y.values(p).flat();fe(t,sl(l,i,w,o,c,d))},[p]);const[g,b]=h.useState(1),_=Fv(p,l,g);return!c||!d?null:n.jsxs(ve,{width:c,height:d,children:[l.pagination.page_size>0&&n.jsx(Iv,{page:g,setPage:b,totalPages:u,width:c}),n.jsx(Wv,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,seriesData:_,conf:l,interactionManager:r})]})}function Kv({control:e,watch:t}){const{t:r}=m.useTranslation();t(["heat_block"]);const a=t("heat_block.label.show");return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:o})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...o})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:o})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:o})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...o})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:o})=>n.jsx(Ne,{...o})}),n.jsx(s.Divider,{mb:-5,variant:"dashed",label:r("chart.label.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.label.show",control:e,render:({field:o})=>n.jsx(s.Switch,{label:r("chart.heatmap.heatblock.show_label"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked),sx:{flexGrow:1}})}),n.jsx(v.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:o})=>n.jsx(s.NumberInput,{size:"xs",leftSection:n.jsx(T.IconTextSize,{size:16}),disabled:!a,...o})})]})]})}function Yv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["pagination"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"pagination.page_size",control:e,render:({field:a})=>n.jsx(s.NumberInput,{label:r("common.pagination.page_size"),description:r("viz.heatmap.pagination.page_size_hint"),sx:{flex:1},...a,onChange:o=>{typeof o!="string"&&a.onChange(o)}})})})}const Xv=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Zv=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Xv,{control:e,index:i})})]})};function Jv({control:e,watch:t}){return n.jsx(Zv,{control:e,watch:t})}function Hv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Rv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})}),n.jsx(v.Controller,{name:"y_axis.inverse",control:e,render:({field:a})=>n.jsx(s.Checkbox,{size:"sm",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked),label:r("chart.y_axis.inverse"),styles:{root:{transform:"translateY(6px)"},label:{cursor:"pointer",userSelect:"none"},input:{cursor:"pointer"}}})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function e_({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Fr,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx("form",{onSubmit:d(a),style:{flexGrow:1},children:n.jsxs(s.Stack,{gap:"xs",sx:{height:"100%"},children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Pagination",children:t("common.pagination.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(Hv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(Rv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx(Kv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx($r,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Jv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Pagination",children:n.jsx(Yv,{control:c,watch:u})})]})]})})}const t_=[{lang:"en",resources:{heatmap:{viz_name:"Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}},pagination:{page_size_hint:"Set 0 to disable pagination"}}}},{lang:"zh",resources:{heatmap:{viz_name:"热力图",click_heatmap:{heatblock:{label:"点击热力块"}},pagination:{page_size_hint:"设为0以禁用分页"}}}}];function n_(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=u=>u&&`${r}.${u}`,{x_axis:o,y_axis:l,heat_block:i,tooltip:c,...d}=e;return{...d,x_axis:{...o,data_key:a(o.data_key)},y_axis:{...l,data_key:a(l.data_key)},heat_block:{...i,data_key:a(i.data_key)},tooltip:{...c,metrics:c.metrics.map(u=>({...u,data_key:a(u.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function r_(e){return y.defaultsDeep({},e,{heat_block:{label:{show:!1,fontSize:10}}})}function a_(e){const{heat_block:t}=e;let{min:r,max:a}=t;return typeof r!="number"&&(r=0),typeof a!="number"&&(a=100),{...e,heat_block:{...t,min:{type:"static",value:r},max:{type:"static",value:a}}}}function s_(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function o_(e){const{pagination:t=ll({page_size:20}),...r}=e;return{...r,pagination:t}}function l_(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function i_(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}class c_ extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>(console.log("🟥 unexpected calling"),{version:1,config:r})),this.version(2,(r,a)=>({...r,version:2,config:n_(r.config,a)})),this.version(3,r=>({...r,version:3,config:r_(r.config)})),this.version(4,r=>({...r,version:4,config:a_(r.config)})),this.version(5,r=>({...r,version:5,config:s_(r.config)})),this.version(6,r=>({...r,version:6,config:o_(r.config)})),this.version(7,r=>({...r,version:7,config:l_(r.config)})),this.version(8,r=>({...r,version:8,config:i_(r.config)}))}}const d_={displayName:"viz.heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new c_,name:"heatmap",viewRender:Uv,configRender:e_,createConfig:()=>({version:8,config:Fr}),triggers:[ol],translation:t_},Qr={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:de,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:_e(),overflow:Ie()},nameAlignment:"center"},series:[],stats:{bottom:"",top:""},tooltip:{metrics:[]},reference_lines:[]};function u_(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:de,show:!0}}function p_(){const e=new Date().getTime().toString();return{id:e,type:"bar",name:e,unit:K(),stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:Vt,xAxisIndex:"0"}}function h_(){const e=new Date().getTime().toString();return{id:e,name:e,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function g_(e){const t=e.x_axes.some(l=>l.position==="top"&&!!l.name&&l.show);let r=0;t&&(r+=15);const a=e.x_axes.some(l=>l.position==="bottom"&&!!l.name&&l.show);let o=0;return a&&(o+=15),e.series.some(l=>!l.hide_in_legend)&&(o+=20),{top:r,right:5,bottom:o,left:5,containLabel:!0}}function f_(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function b_(e,t){const r=e.series.reduce((o,{unit:l,name:i})=>(l.show_in_legend&&(o[i]=l.text),o),{}),a={show:!0,bottom:0,left:"center",type:"scroll",formatter:o=>{const l=r[o];return l?`${o}(${l})`:o}};return a.data=t.filter(o=>!o.hide_in_legend).map(({name:o,type:l})=>({name:o,icon:f_(l)})),a}function y_(e,t,r,a){return e.map(o=>{const l=o.orientation==="horizontal",i=l?"yAxis":"xAxis",c=l?"insideEndTop":"end";return{name:o.name,type:"line",hide_in_legend:!o.show_in_legend,xAxisIndex:o.xAxisIndex,data:[],lineStyle:o.lineStyle,markLine:{data:[{name:o.name,[i]:Number(r[o.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:o.lineStyle,label:{formatter:function(){return o.template?Kt(o.template,t,a):""},position:c}}}})}function Sn(e,t,r){const a=me(e,t),o=me(e,r);return y.zip(o,a)}function v_(e,t,r,a){const o=Sn(t,r,a);return y.unionBy(o,e,0)}function __({dataTemplate:e,data:t,name_data_key:r,value_data_key:a,valueTypedXAxis:o}){return o?v_(e,t,r,a):Sn(t,r,a)}function m_({dataTemplate:e,data:t,aggregation_on_value:r,name_data_key:a,value_data_key:o,valueTypedXAxis:l}){if(!r||r.type==="none")return __({dataTemplate:e,data:t,name_data_key:a,value_data_key:o,valueTypedXAxis:l});const i=Sn(t,a,o),c=y.groupBy(i,"0");return e.map(([u])=>{const g=c[u].map(_=>_[1]),b=lr(g,r);return[u,b]})}function w_({group_by_key:e,data:t,value_data_key:r,name_data_key:a}){const{queryID:o,columnKey:l}=$(e),i=y.groupBy(t[o],l);return Object.entries(i).forEach(([c,d])=>{i[c]=Sn({[o]:d},a,r)}),i}function x_({y_axis:e},{data_key:t,xAxisIndex:r,label_position:a,name:o,group_by_key:l,aggregation_on_value:i,stack:c,color:d,hide_in_legend:u,invisible:p,id:g,...b},_,w,x,S,D){const z={label:{show:!!a,position:a,formatter:D[r??"default"]},name:o,yAxisId:"main-y-axis",xAxisIndex:r,stack:c,color:p?"transparent":d,hide_in_legend:u,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...b};if(!l||l===e.data_key)return z.data=m_({dataTemplate:_,data:x,aggregation_on_value:i,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:w}),z;const I=w_({group_by_key:l,data:x,name_data_key:e.data_key,value_data_key:t});return Object.entries(I).map(([A,E])=>{const U=y.cloneDeep(z);return U.name=A,U.color=void 0,U.data=E,U})}function C_(e,t,r,a,o,l,i){const c=t.map(u=>[u,0]);return e.series.map(u=>x_(e,u,c,r,a,i,o)).flat().concat(y_(e.reference_lines,l,i,a))}function S_(e,t){const r=e.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!r)return"";const{name:a,axisType:o,axisValue:l,axisIndex:i}=r;return o==="yAxis.category"?a:Me(t.y_axis.axisLabel.formatter)(l,i)}function T_(e,t,r){const a=t.reduce((l,{xAxisIndex:i,name:c})=>(l[c]=i,l),{}),o=e.series.reduce((l,{unit:i,name:c})=>(i.show_in_tooltip&&(l[c]=i.text),l),{});return X.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(l){const i=Array.isArray(l)?l:[l];if(i.length===0)return"";const c=i.map(({seriesName:p,marker:g,value:b})=>{if(Array.isArray(b)&&b.length===2&&(b=b[0]),!p)return b;const _=a[p],w=r[_]??r.default;return`
|
|
217
|
+
`}})}function Ov(e,t,r,a){const{overflow:o,rotate:l}=e.x_axis.axisLabel,i=Ke(o.on_axis);return X.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...i,formatter:r},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:a>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Lv(e,t,r){const{nameAlignment:a,data_key:o,inverse:l,...i}=e.y_axis,{overflow:c,rotate:d}=e.y_axis.axisLabel,u=Ke(c.on_axis);return X.getYAxis({...i,type:"category",axisLabel:{rotate:d,...u,formatter:t},axisTick:{show:!0,alignWithLabel:!0},axisLine:{show:!0,lineStyle:{width:3}},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:r>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameTextStyle:{fontWeight:"bold",align:a},nameLocation:l?"start":"end",nameGap:15,inverse:l,z:3})}function Nv(e,t,r,a){return r<e*10||a<t*10?0:r<e*20||a<t*20?1:2}function sl(e,t,r,a,o,l){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const i=a.reduce((I,A)=>{const E=He(A,t);return I[A.name]=Be(A,E),I},{}),c=pn(e.visualMap,i),{min:d,max:u}=c,p=Vv(e),g=Pv(e),b=$(e.x_axis.data_key),_=$(e.y_axis.data_key),w=y.uniq(t[b.queryID].map(I=>I[b.columnKey])),x=y.uniq(t[b.queryID].map(I=>I[_.columnKey])),S=r.map(I=>{const A=y.clone(I),{followVisualMap:E,color:U}=hr(A.value[2],d,u,e.visualMap);return E||(A.visualMap=!1,A.itemStyle={color:U}),A}),D=Nv(w.length,x.length,o,l);return{xAxis:Ov(e,w,p.x_axis,D),yAxis:Lv(e,p.y_axis,D),series:Av(e,S,D),tooltip:qv(e,t,p,g),grid:$v(e),visualMap:c}}function Gv(e,t){const r=h.useMemo(()=>$(t.x_axis.data_key),[t.x_axis.data_key]),a=h.useMemo(()=>$(t.y_axis.data_key),[t.y_axis.data_key]),o=h.useMemo(()=>$(t.heat_block.data_key),[t.heat_block.data_key]),l=h.useMemo(()=>{const c=e[r.queryID];if(!c)return{};const d=c.map(u=>{const p=y.get(u,r.columnKey),g=y.get(u,a.columnKey),b=y.get(u,o.columnKey);return{value:[p,g,b]}});return y.groupBy(d,"value.1")},[e,r,a,o]);return{totalPages:h.useMemo(()=>{const c=Object.keys(l).length;return t.pagination.page_size===0?c:y.ceil(c/t.pagination.page_size)},[l,t.pagination.page_size]),groupedFullData:l}}function Fv(e,t,r){return h.useMemo(()=>{const o=Object.values(e);if(t.pagination.page_size===0)return o.flat();const l=(r-1)*t.pagination.page_size,i=r*t.pagination.page_size;return o.slice(l,i).flat()},[e,r,t.pagination.page_size])}function Qv(e){return n.jsx(n.Fragment,{})}function jv(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const ol={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:jv,configRender:Qv,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function ll({page_size:e=20}){return{page_size:e}}const Qr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},y_axis:{name:"Y Axis",inverse:!1,data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:rt(),pagination:ll({page_size:20})};function Wv({conf:e,data:t,seriesData:r,width:a,height:o,interactionManager:l,variables:i}){const c=h.useMemo(()=>{const _=$(e.x_axis.data_key),w=$(e.y_axis.data_key);return y.keyBy(t[_.queryID],x=>`${x[_.columnKey]}---${x[w.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),d=Ve(l.triggerManager,ol.id),u=h.useCallback(_=>{const[w,x]=_.value,S=y.get(c,`${w}---${x}`,{error:"rowData is not found"});d.forEach(D=>{l.runInteraction(D.id,{..._,rowData:S})})},[c,d,l]),p=h.useRef(null),g=h.useMemo(()=>({click:u}),[u]),b=h.useMemo(()=>sl(e,t,r,i,a,o),[e,t,r,a,o]);return n.jsx(he,{echarts:ce,option:b,style:{width:a,height:o},ref:p,onEvents:g,notMerge:!0,theme:"merico-light"})}function Uv({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Qr),[a]),i=e.data,{width:c,height:d}=e.viewport,{totalPages:u,groupedFullData:p}=Gv(i,l);h.useEffect(()=>{const w=y.values(p).flat();fe(t,sl(l,i,w,o,c,d))},[p]);const[g,b]=h.useState(1),_=Fv(p,l,g);return!c||!d?null:n.jsxs(ve,{width:c,height:d,children:[l.pagination.page_size>0&&n.jsx(Iv,{page:g,setPage:b,totalPages:u,width:c}),n.jsx(Wv,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,seriesData:_,conf:l,interactionManager:r})]})}function Kv({control:e,watch:t}){const{t:r}=m.useTranslation();t(["heat_block"]);const a=t("heat_block.label.show");return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:o})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...o})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:o})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:o})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...o})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:o})=>n.jsx(Ne,{...o})}),n.jsx(s.Divider,{mb:-5,variant:"dashed",label:r("chart.label.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.label.show",control:e,render:({field:o})=>n.jsx(s.Switch,{label:r("chart.heatmap.heatblock.show_label"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked),sx:{flexGrow:1}})}),n.jsx(v.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:o})=>n.jsx(s.NumberInput,{size:"xs",leftSection:n.jsx(T.IconTextSize,{size:16}),disabled:!a,...o})})]})]})}function Yv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["pagination"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"pagination.page_size",control:e,render:({field:a})=>n.jsx(s.NumberInput,{label:r("common.pagination.page_size"),description:r("viz.heatmap.pagination.page_size_hint"),sx:{flex:1},...a,onChange:o=>{typeof o!="string"&&a.onChange(o)}})})})}const Xv=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Zv=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Xv,{control:e,index:i})})]})};function Jv({control:e,watch:t}){return n.jsx(Zv,{control:e,watch:t})}function Hv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Rv({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})}),n.jsx(v.Controller,{name:"y_axis.inverse",control:e,render:({field:a})=>n.jsx(s.Checkbox,{size:"sm",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked),label:r("chart.y_axis.inverse"),styles:{root:{transform:"translateY(6px)"},label:{cursor:"pointer",userSelect:"none"},input:{cursor:"pointer"}}})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function e_({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Qr,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx("form",{onSubmit:d(a),style:{flexGrow:1},children:n.jsxs(s.Stack,{gap:"xs",sx:{height:"100%"},children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Pagination",children:t("common.pagination.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(Hv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(Rv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx(Kv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx(Ar,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Jv,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Pagination",children:n.jsx(Yv,{control:c,watch:u})})]})]})})}const t_=[{lang:"en",resources:{heatmap:{viz_name:"Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}},pagination:{page_size_hint:"Set 0 to disable pagination"}}}},{lang:"zh",resources:{heatmap:{viz_name:"热力图",click_heatmap:{heatblock:{label:"点击热力块"}},pagination:{page_size_hint:"设为0以禁用分页"}}}}];function n_(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=u=>u&&`${r}.${u}`,{x_axis:o,y_axis:l,heat_block:i,tooltip:c,...d}=e;return{...d,x_axis:{...o,data_key:a(o.data_key)},y_axis:{...l,data_key:a(l.data_key)},heat_block:{...i,data_key:a(i.data_key)},tooltip:{...c,metrics:c.metrics.map(u=>({...u,data_key:a(u.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function r_(e){return y.defaultsDeep({},e,{heat_block:{label:{show:!1,fontSize:10}}})}function a_(e){const{heat_block:t}=e;let{min:r,max:a}=t;return typeof r!="number"&&(r=0),typeof a!="number"&&(a=100),{...e,heat_block:{...t,min:{type:"static",value:r},max:{type:"static",value:a}}}}function s_(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function o_(e){const{pagination:t=ll({page_size:20}),...r}=e;return{...r,pagination:t}}function l_(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function i_(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}class c_ extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>(console.log("🟥 unexpected calling"),{version:1,config:r})),this.version(2,(r,a)=>({...r,version:2,config:n_(r.config,a)})),this.version(3,r=>({...r,version:3,config:r_(r.config)})),this.version(4,r=>({...r,version:4,config:a_(r.config)})),this.version(5,r=>({...r,version:5,config:s_(r.config)})),this.version(6,r=>({...r,version:6,config:o_(r.config)})),this.version(7,r=>({...r,version:7,config:l_(r.config)})),this.version(8,r=>({...r,version:8,config:i_(r.config)}))}}const d_={displayName:"viz.heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new c_,name:"heatmap",viewRender:Uv,configRender:e_,createConfig:()=>({version:8,config:Qr}),triggers:[ol],translation:t_},jr={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:de,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:_e(),overflow:Ie()},nameAlignment:"center"},series:[],stats:{bottom:"",top:""},tooltip:{metrics:[]},reference_lines:[]};function u_(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:de,show:!0}}function p_(){const e=new Date().getTime().toString();return{id:e,type:"bar",name:e,unit:K(),stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:Vt,xAxisIndex:"0"}}function h_(){const e=new Date().getTime().toString();return{id:e,name:e,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function g_(e){const t=e.x_axes.some(l=>l.position==="top"&&!!l.name&&l.show);let r=0;t&&(r+=15);const a=e.x_axes.some(l=>l.position==="bottom"&&!!l.name&&l.show);let o=0;return a&&(o+=15),e.series.some(l=>!l.hide_in_legend)&&(o+=20),{top:r,right:5,bottom:o,left:5,containLabel:!0}}function f_(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function b_(e,t){const r=e.series.reduce((o,{unit:l,name:i})=>(l.show_in_legend&&(o[i]=l.text),o),{}),a={show:!0,bottom:0,left:"center",type:"scroll",formatter:o=>{const l=r[o];return l?`${o}(${l})`:o}};return a.data=t.filter(o=>!o.hide_in_legend).map(({name:o,type:l})=>({name:o,icon:f_(l)})),a}function y_(e,t,r,a){return e.map(o=>{const l=o.orientation==="horizontal",i=l?"yAxis":"xAxis",c=l?"insideEndTop":"end";return{name:o.name,type:"line",hide_in_legend:!o.show_in_legend,xAxisIndex:o.xAxisIndex,data:[],lineStyle:o.lineStyle,markLine:{data:[{name:o.name,[i]:Number(r[o.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:o.lineStyle,label:{formatter:function(){return o.template?Kt(o.template,t,a):""},position:c}}}})}function Sn(e,t,r){const a=me(e,t),o=me(e,r);return y.zip(o,a)}function v_(e,t,r,a){const o=Sn(t,r,a);return y.unionBy(o,e,0)}function __({dataTemplate:e,data:t,name_data_key:r,value_data_key:a,valueTypedXAxis:o}){return o?v_(e,t,r,a):Sn(t,r,a)}function m_({dataTemplate:e,data:t,aggregation_on_value:r,name_data_key:a,value_data_key:o,valueTypedXAxis:l}){if(!r||r.type==="none")return __({dataTemplate:e,data:t,name_data_key:a,value_data_key:o,valueTypedXAxis:l});const i=Sn(t,a,o),c=y.groupBy(i,"0");return e.map(([u])=>{const g=c[u].map(_=>_[1]),b=ir(g,r);return[u,b]})}function w_({group_by_key:e,data:t,value_data_key:r,name_data_key:a}){const{queryID:o,columnKey:l}=$(e),i=y.groupBy(t[o],l);return Object.entries(i).forEach(([c,d])=>{i[c]=Sn({[o]:d},a,r)}),i}function x_({y_axis:e},{data_key:t,xAxisIndex:r,label_position:a,name:o,group_by_key:l,aggregation_on_value:i,stack:c,color:d,hide_in_legend:u,invisible:p,id:g,...b},_,w,x,S,D){const z={label:{show:!!a,position:a,formatter:D[r??"default"]},name:o,yAxisId:"main-y-axis",xAxisIndex:r,stack:c,color:p?"transparent":d,hide_in_legend:u,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...b};if(!l||l===e.data_key)return z.data=m_({dataTemplate:_,data:x,aggregation_on_value:i,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:w}),z;const I=w_({group_by_key:l,data:x,name_data_key:e.data_key,value_data_key:t});return Object.entries(I).map(([A,E])=>{const U=y.cloneDeep(z);return U.name=A,U.color=void 0,U.data=E,U})}function C_(e,t,r,a,o,l,i){const c=t.map(u=>[u,0]);return e.series.map(u=>x_(e,u,c,r,a,i,o)).flat().concat(y_(e.reference_lines,l,i,a))}function S_(e,t){const r=e.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!r)return"";const{name:a,axisType:o,axisValue:l,axisIndex:i}=r;return o==="yAxis.category"?a:Me(t.y_axis.axisLabel.formatter)(l,i)}function T_(e,t,r){const a=t.reduce((l,{xAxisIndex:i,name:c})=>(l[c]=i,l),{}),o=e.series.reduce((l,{unit:i,name:c})=>(i.show_in_tooltip&&(l[c]=i.text),l),{});return X.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(l){const i=Array.isArray(l)?l:[l];if(i.length===0)return"";const c=i.map(({seriesName:p,marker:g,value:b})=>{if(Array.isArray(b)&&b.length===2&&(b=b[0]),!p)return b;const _=a[p],w=r[_]??r.default;return`
|
|
218
218
|
<tr>
|
|
219
219
|
<td>${g}</td>
|
|
220
220
|
<th style="text-align: right; padding: 0 1em;">${p}</th>
|
|
@@ -232,7 +232,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
232
232
|
${c.join("")}
|
|
233
233
|
</tbody>
|
|
234
234
|
</table>
|
|
235
|
-
`}})}function k_(e){return e.x_axes.reduce((r,{label_formatter:a},o)=>(r[o]=function(i){let c=i;if(typeof i=="object"&&(Array.isArray(i.value)&&i.value.length===2?c=i.value[0]:c=i.value),!a)return c;try{return Y(c,a)}catch(d){return console.error(d),c}},r),{default:({value:r})=>r})}function D_(e,t){const r={};return t.map(a=>{const o=He(a,e);r[a.name]=Be(a,o)}),r}function z_(e,t){return e.x_axes.map(({min:r,max:a,...o},l)=>{let i=o.position;return i||(i=l>0?"bottom":"top"),X.getYAxis({...o,type:"value",min:r||void 0,max:a||void 0,position:i,axisLabel:{show:!0,margin:2,formatter:t[l]??t.default},nameLocation:"center",nameGap:15})})}function M_(e,t){const r=t.every(i=>!Number.isNaN(Number(i))),{overflow:a,...o}=e.y_axis.axisLabel,l=Ke(a.on_axis);return[X.getXAxis({data:t,name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:r?"value":"category",axisLabel:{...o,...l,formatter:Me(o.formatter)},z:5})]}function I_(e,t,r){if(!e.y_axis.data_key)return{};const a=D_(t,r),o=k_(e),l=$(e.y_axis.data_key),i=y.uniq(t[l.queryID].map(p=>p[l.columnKey])),c=i.every(p=>!Number.isNaN(Number(p))),d=C_(e,i,c,t,o,r,a);return{xAxis:z_(e,o),yAxis:M_(e,i),series:d,tooltip:T_(e,d,o),grid:g_(e),legend:b_(e,d)}}function V_({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,onChartRenderFinished:i}){const c=Dt(t,e.y_axis.data_key),d=Ve(o.triggerManager,Er.id),u=h.useCallback(S=>{const D=y.get(c,S.name,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...S,rowData:D})})},[c,d,o]),p=h.useRef(),g=O.useLatest(i),b=h.useCallback(()=>{var S;g.current((S=p.current)==null?void 0:S.getOption())},[]),_=h.useMemo(()=>({click:u,finished:b}),[u]),w=S=>{p.current=S},x=h.useMemo(()=>I_(e,t,l),[e,t]);return!r||!a?null:n.jsx(he,{echarts:ce,option:x,style:{width:r,height:a},onEvents:_,onChartReady:w,notMerge:!0,theme:"merico-light"})}function P_({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Qr),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c),x=$o(l.stats,e,t);return n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx(V_,{onChartRenderFinished:x,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})}function $_({control:e,index:t,watch:r,variableOptions:a,xAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.xAxisIndex`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("chart.x_axis.label"),data:o,disabled:o.length===0,sx:{flex:1},...c})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:l("chart.legend.show_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function A_({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>h_(),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("x_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>{const g=u.name.trim();return g||p+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx($_,{control:e,index:p,watch:t,variableOptions:l,xAxisOptions:c})})}function E_({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=!!r.barWidth.trim(),i=h.useMemo(()=>[{label:a("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:a("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.bar.bar_gap.label"),data:i,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.min"),disabled:l,sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.max"),disabled:l,sx:{flexGrow:1},...c})})]})]})}function B_({control:e,index:t,seriesItem:r,xAxisOptions:a}){const{t:o}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.name`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("common.name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`series.${t}.xAxisIndex`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("chart.x_axis.label"),data:a,disabled:a.length===0,sx:{flex:1},...l})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{name:`series.${t}.data_key`,control:e,render:({field:l})=>n.jsx(L,{label:o("common.data_field"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:l})=>n.jsx(Nr,{label:o("viz.horizontal_bar_chart.series.aggregation.label"),value:l.value??Vt,onChange:l.onChange,pt:0,withFallback:!1})})]}),n.jsx(s.Group,{grow:!0,children:n.jsx(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:l})=>n.jsx(L,{label:o("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...l})})}),n.jsx(v.Controller,{name:`series.${t}.unit`,control:e,render:({field:l})=>n.jsx(ue,{...l})}),n.jsx(E_,{index:t,control:e,seriesItem:r}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:l})=>n.jsx(Ot,{label:o("chart.label_position.label"),...l,withOffOption:!0,onChange:i=>{l.onChange(i??"")}})}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`series.${t}.color`,control:e,render:({field:l})=>n.jsx(ye,{label:o("chart.color.label"),...l})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:l})=>n.jsx(s.Checkbox,{label:o("chart.legend.hide_in_legend"),checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})}),n.jsx(v.Controller,{name:`series.${t}.invisible`,control:e,render:({field:l})=>n.jsx(s.Checkbox,{label:o("chart.behavior.invisible"),checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})})]})}function q_({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>p_(),o=(c,d)=>{const u=c.name.trim();return u||d+1},l=t("x_axes"),i=h.useMemo(()=>l.map(({name:c},d)=>({label:c,value:d.toString()})),[l]);return n.jsx(R,{control:e,watch:t,name:"series",getItem:a,addButtonText:r("chart.series.add"),deleteButtonText:r("chart.series.delete"),renderTabName:o,children:({field:c,index:d})=>n.jsx(B_,{control:e,index:d,seriesItem:c,xAxisOptions:i})})}const O_=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.x_axis.position.top"),value:"top"},{label:l("chart.x_axis.position.bottom"),value:"bottom"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.x_axis.position.label"),data:c,value:t,onChange:Z(r),sx:a})});function L_({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:10,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`x_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`x_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(O_,{sx:{flex:1},...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.x_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`x_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.x_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`x_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`x_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.value_max"),...a})})]})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:r("chart.x_axis.behavior"),labelPosition:"center"}),n.jsx(v.Controller,{name:`x_axes.${t}.show`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{label:r("chart.x_axis.visible"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})}function N_({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>u_(),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsx(R,{control:e,watch:t,name:"x_axes",getItem:a,addButtonText:r("chart.x_axis.add"),deleteButtonText:r("chart.x_axis.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(L_,{control:e,index:i})})}function G_({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}const F_=k.observer(({control:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.above_chart")},`${t.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.under_chart")},`${t.id}.stats.bottom`)})]})});function Q_({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaultsDeep({},r,Qr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axes",children:t("chart.x_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")})]}),n.jsx(s.Tabs.Panel,{value:"X Axes",children:n.jsx(N_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(G_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Series",children:n.jsx(q_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(F_,{control:i})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(A_,{variables:o,control:i,watch:d})})]})]})})}const j_=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}],W_={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:K_,configRender:U_,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function U_(e){return n.jsx(n.Fragment,{})}function K_(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.cartesian_chart.click_series.label")})}function Y_(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&!d.includes(`${r}.`)?`${r}.${d}`:d,{x_axes:o,y_axis:l,series:i,...c}=e;return{...c,x_axes:o.map(d=>({...d,data_key:a(d.data_key)})),y_axis:{...l,data_key:a(l.data_key)},series:i.map(d=>({...d,data_key:a(d.data_key),group_by_key:a(d.group_by_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function X_(e){const t=e.series.map(r=>({...r,unit:r.unit??K()}));return{...e,series:t}}function Z_(e){const{stats:t={bottom:"",top:""}}=e;return{...e,stats:t}}class J_ extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>{const{config:o}=r;return{...r,version:2,config:Y_(o,a)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:X_(a)}}),this.version(4,r=>{const{config:a}=r;return{...r,version:4,config:Z_(a)}})}}const H_={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new J_,name:"horizontalBarChart",viewRender:P_,configRender:Q_,createConfig:()=>({version:4,config:y.cloneDeep(Qr)}),triggers:[W_],translation:j_},jr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:_e()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function R_(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const il=({value:e})=>{try{return Y(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function em(e,t,r){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:t.map(o=>{const l=r[o].length,d=(y.countBy(r[o],u=>u.level.diff===0).true??0)/l;return[o,"_y",d]}),label:{show:!0,formatter:il},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:o,value:l})=>`
|
|
235
|
+
`}})}function k_(e){return e.x_axes.reduce((r,{label_formatter:a},o)=>(r[o]=function(i){let c=i;if(typeof i=="object"&&(Array.isArray(i.value)&&i.value.length===2?c=i.value[0]:c=i.value),!a)return c;try{return Y(c,a)}catch(d){return console.error(d),c}},r),{default:({value:r})=>r})}function D_(e,t){const r={};return t.map(a=>{const o=He(a,e);r[a.name]=Be(a,o)}),r}function z_(e,t){return e.x_axes.map(({min:r,max:a,...o},l)=>{let i=o.position;return i||(i=l>0?"bottom":"top"),X.getYAxis({...o,type:"value",min:r||void 0,max:a||void 0,position:i,axisLabel:{show:!0,margin:2,formatter:t[l]??t.default},nameLocation:"center",nameGap:15})})}function M_(e,t){const r=t.every(i=>!Number.isNaN(Number(i))),{overflow:a,...o}=e.y_axis.axisLabel,l=Ke(a.on_axis);return[X.getXAxis({data:t,name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:r?"value":"category",axisLabel:{...o,...l,formatter:Me(o.formatter)},z:5})]}function I_(e,t,r){if(!e.y_axis.data_key)return{};const a=D_(t,r),o=k_(e),l=$(e.y_axis.data_key),i=y.uniq(t[l.queryID].map(p=>p[l.columnKey])),c=i.every(p=>!Number.isNaN(Number(p))),d=C_(e,i,c,t,o,r,a);return{xAxis:z_(e,o),yAxis:M_(e,i),series:d,tooltip:T_(e,d,o),grid:g_(e),legend:b_(e,d)}}function V_({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,onChartRenderFinished:i}){const c=Dt(t,e.y_axis.data_key),d=Ve(o.triggerManager,Br.id),u=h.useCallback(S=>{const D=y.get(c,S.name,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...S,rowData:D})})},[c,d,o]),p=h.useRef(),g=O.useLatest(i),b=h.useCallback(()=>{var S;g.current((S=p.current)==null?void 0:S.getOption())},[]),_=h.useMemo(()=>({click:u,finished:b}),[u]),w=S=>{p.current=S},x=h.useMemo(()=>I_(e,t,l),[e,t]);return!r||!a?null:n.jsx(he,{echarts:ce,option:x,style:{width:r,height:a},onEvents:_,onChartReady:w,notMerge:!0,theme:"merico-light"})}function P_({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,jr),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c),x=$o(l.stats,e,t);return n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx(V_,{onChartRenderFinished:x,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})}function $_({control:e,index:t,watch:r,variableOptions:a,xAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.xAxisIndex`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("chart.x_axis.label"),data:o,disabled:o.length===0,sx:{flex:1},...c})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>n.jsx(s.Checkbox,{label:l("chart.legend.show_in_legend"),checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})})]})}function A_({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>h_(),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("x_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>{const g=u.name.trim();return g||p+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx($_,{control:e,index:p,watch:t,variableOptions:l,xAxisOptions:c})})}function E_({control:e,index:t,seriesItem:r}){const{t:a,i18n:o}=m.useTranslation(),l=!!r.barWidth.trim(),i=h.useMemo(()=>[{label:a("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:a("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[o.language]);return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.stack"),placeholder:a("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>n.jsx(s.Select,{label:a("chart.series.bar.bar_gap.label"),data:i,sx:{flexGrow:1},...c})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.min"),disabled:l,sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:a("chart.series.bar.bar_width.max"),disabled:l,sx:{flexGrow:1},...c})})]})]})}function B_({control:e,index:t,seriesItem:r,xAxisOptions:a}){const{t:o}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`series.${t}.name`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("common.name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`series.${t}.xAxisIndex`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("chart.x_axis.label"),data:a,disabled:a.length===0,sx:{flex:1},...l})})]}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(v.Controller,{name:`series.${t}.data_key`,control:e,render:({field:l})=>n.jsx(L,{label:o("common.data_field"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:l})=>n.jsx(Gr,{label:o("viz.horizontal_bar_chart.series.aggregation.label"),value:l.value??Vt,onChange:l.onChange,pt:0,withFallback:!1})})]}),n.jsx(s.Group,{grow:!0,children:n.jsx(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:l})=>n.jsx(L,{label:o("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...l})})}),n.jsx(v.Controller,{name:`series.${t}.unit`,control:e,render:({field:l})=>n.jsx(ue,{...l})}),n.jsx(E_,{index:t,control:e,seriesItem:r}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:l})=>n.jsx(Ot,{label:o("chart.label_position.label"),...l,withOffOption:!0,onChange:i=>{l.onChange(i??"")}})}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`series.${t}.color`,control:e,render:({field:l})=>n.jsx(ye,{label:o("chart.color.label"),...l})})}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:l})=>n.jsx(s.Checkbox,{label:o("chart.legend.hide_in_legend"),checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})}),n.jsx(v.Controller,{name:`series.${t}.invisible`,control:e,render:({field:l})=>n.jsx(s.Checkbox,{label:o("chart.behavior.invisible"),checked:l.value,onChange:i=>l.onChange(i.currentTarget.checked)})})]})}function q_({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>p_(),o=(c,d)=>{const u=c.name.trim();return u||d+1},l=t("x_axes"),i=h.useMemo(()=>l.map(({name:c},d)=>({label:c,value:d.toString()})),[l]);return n.jsx(R,{control:e,watch:t,name:"series",getItem:a,addButtonText:r("chart.series.add"),deleteButtonText:r("chart.series.delete"),renderTabName:o,children:({field:c,index:d})=>n.jsx(B_,{control:e,index:d,seriesItem:c,xAxisOptions:i})})}const O_=h.forwardRef(({label:e,value:t,onChange:r,sx:a={}},o)=>{const{t:l,i18n:i}=m.useTranslation(),c=h.useMemo(()=>[{label:l("chart.x_axis.position.top"),value:"top"},{label:l("chart.x_axis.position.bottom"),value:"bottom"}],[i.language]);return n.jsx(s.Select,{ref:o,label:e??l("chart.x_axis.position.label"),data:c,value:t,onChange:Z(r),sx:a})});function L_({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:10,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`x_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`x_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(O_,{sx:{flex:1},...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.x_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`x_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.x_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`x_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`x_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.x_axis.value_max"),...a})})]})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:r("chart.x_axis.behavior"),labelPosition:"center"}),n.jsx(v.Controller,{name:`x_axes.${t}.show`,control:e,render:({field:a})=>n.jsx(s.Checkbox,{label:r("chart.x_axis.visible"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})}function N_({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>u_(),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsx(R,{control:e,watch:t,name:"x_axes",getItem:a,addButtonText:r("chart.x_axis.add"),deleteButtonText:r("chart.x_axis.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(L_,{control:e,index:i})})}function G_({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}const F_=k.observer(({control:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.above_chart")},`${t.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:a})=>n.jsx(gt,{initialValue:a.value,onChange:a.onChange,label:r("chart.stats.template.under_chart")},`${t.id}.stats.bottom`)})]})});function Q_({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaultsDeep({},r,jr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axes",children:t("chart.x_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")})]}),n.jsx(s.Tabs.Panel,{value:"X Axes",children:n.jsx(N_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(G_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Series",children:n.jsx(q_,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(F_,{control:i})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(A_,{variables:o,control:i,watch:d})})]})]})})}const j_=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}],W_={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:K_,configRender:U_,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function U_(e){return n.jsx(n.Fragment,{})}function K_(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.cartesian_chart.click_series.label")})}function Y_(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&!d.includes(`${r}.`)?`${r}.${d}`:d,{x_axes:o,y_axis:l,series:i,...c}=e;return{...c,x_axes:o.map(d=>({...d,data_key:a(d.data_key)})),y_axis:{...l,data_key:a(l.data_key)},series:i.map(d=>({...d,data_key:a(d.data_key),group_by_key:a(d.group_by_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function X_(e){const t=e.series.map(r=>({...r,unit:r.unit??K()}));return{...e,series:t}}function Z_(e){const{stats:t={bottom:"",top:""}}=e;return{...e,stats:t}}class J_ extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>{const{config:o}=r;return{...r,version:2,config:Y_(o,a)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:X_(a)}}),this.version(4,r=>{const{config:a}=r;return{...r,version:4,config:Z_(a)}})}}const H_={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new J_,name:"horizontalBarChart",viewRender:P_,configRender:Q_,createConfig:()=>({version:4,config:y.cloneDeep(jr)}),triggers:[W_],translation:j_},Wr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:_e()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function R_(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const il=({value:e})=>{try{return Y(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function em(e,t,r){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:t.map(o=>{const l=r[o].length,d=(y.countBy(r[o],u=>u.level.diff===0).true??0)/l;return[o,"_y",d]}),label:{show:!0,formatter:il},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:o,value:l})=>`
|
|
236
236
|
<table style="width: auto">
|
|
237
237
|
<thead>
|
|
238
238
|
<tr colspan="2">
|
|
@@ -311,7 +311,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
311
311
|
</tr>
|
|
312
312
|
</tbody>
|
|
313
313
|
</table>
|
|
314
|
-
`}},show_in_legend:!0}))}function sm(e,t,r,a){const o=$(t.data_key),l=t.name,i=r.map(c=>{const d=y.sumBy(a[c],o.columnKey);return[c,d]});return{type:"line",name:l,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:i,show_in_legend:!1}}function om(e,t,r,a){const i={barMinWidth:5,barMaxWidth:20};return[em(e,r,a),nm(e,r,a,i),...am(e,r,a,i),sm(e,t,r,a)]}function lm(e,t){const{axisLabel:r}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...r,formatter:Me(r.formatter)},axisLine:{show:!1}}]}function im(e){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function Wr(e){return e==1||e==2?1:Wr(e-2)+Wr(e-1)}const cm=Array.from(new Array(20),(e,t)=>Wr(t+1));function dl(e){return e<=1?e:cm.findIndex(t=>e<=t)-1}function dm(e,t){const{x_axis:r,deviation:a}=e,o=$(r.data_key),l=$(a.data_keys.estimated_value),i=$(a.data_keys.actual_value);return t[o.queryID].map(c=>{const d=dl(c[l.columnKey]),u=dl(c[i.columnKey]),p=d-u;return{...c,level:{estimated:d,actual:u,diff:p}}})}function um(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function pm(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(r=>r.show_in_legend).reverse().map(r=>({name:`${r.name}`,color:r.color,itemStyle:um(r.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const hm={tooltip:{trigger:"axis"}};function gm(e,t){const{deviation:r,metrics:a}=e,o=a.find(i=>i.data_key===t);if(o)return o;const l=r.data_keys.actual_value;return{id:l,name:r.name,data_key:l,unit:K()}}function fm(e,t,r){const a=dm(e,r),o=$(e.x_axis.data_key),l=y.uniqBy(r[o.queryID],o.columnKey).map(p=>p[o.columnKey]),i=y.groupBy(a,o.columnKey),c=gm(e,t),d=om(e,c,l,i),u={xAxis:lm(e,l),yAxis:im(c),series:d,grid:R_(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:pm(d)};return y.defaultsDeep({},u,hm)}const bm={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},ym=({conf:e,metricKey:t,setMetricKey:r})=>{const{deviation:a,metrics:o}=e,l=h.useMemo(()=>{const i=o.map(c=>({label:c.name,value:c.data_key}));return i.push({label:a.name?a.name:a.data_keys.actual_value,value:a.data_keys.actual_value}),i},[a,o]);return n.jsxs(s.Group,{gap:1,children:[n.jsx(s.Text,{size:"12px",c:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),n.jsx(s.NativeSelect,{size:"xs",data:l,value:t,onChange:i=>r(i.currentTarget.value),styles:bm})]})},vm={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function _m(){return n.jsxs(s.HoverCard,{width:400,shadow:"md",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconInfoCircle,{size:14}),children:"指标说明"})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.Table,{fz:14,sx:vm,children:n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"估算偏差"}),n.jsx(s.Table.Td,{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"准确估算比例"}),n.jsx(s.Table.Td,{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function mm(e){return n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(_m,{}),n.jsx(ym,{...e})]})}function wm({conf:e,data:t,width:r,height:a,metricKey:o,instance:l}){const i=h.useMemo(()=>fm(e,o,t),[e,t,o]),c=h.useRef(null),d=h.useCallback(()=>{var g;const p=(g=c.current)==null?void 0:g.getEchartsInstance();p&&fe(l,p.getOption())},[l]),u=h.useMemo(()=>({finished:d}),[d]);return n.jsx(he,{ref:c,onEvents:u,echarts:ce,option:i,style:{width:r,height:a},notMerge:!0,theme:"merico-light"})}function xm({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},r,jr),[r]),o=e.data,{width:l,height:i}=e.viewport,{x_axis:c,deviation:d}=a,{estimated_value:u,actual_value:p}=d.data_keys,[g,b]=h.useState(p);if(h.useEffect(()=>{b(x=>x||p)},[p]),!c.data_key||!u||!p||!l||!i)return null;const _=Math.max(qe(l),300),w=Math.max(Oe(i),370);return n.jsxs(s.Box,{pt:we.top,pr:we.right,pb:we.bottom,pl:we.left,sx:{overflow:"hidden",height:i,width:l},children:[n.jsx(mm,{conf:a,metricKey:g,setMetricKey:b}),n.jsx(wm,{instance:t,width:_,height:w-30,data:o,conf:a,metricKey:g})]})}function Cm({control:e,watch:t}){return t(["deviation"]),n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"deviation.name",control:e,render:({field:r})=>n.jsx(s.TextInput,{label:"指标名称",sx:{flex:1},...r})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"deviation.data_keys.estimated_value",control:e,render:({field:r})=>n.jsx(L,{label:"估算值字段",required:!0,sx:{flex:1},...r})}),n.jsx(v.Controller,{name:"deviation.data_keys.actual_value",control:e,render:({field:r})=>n.jsx(L,{label:"实际值字段",required:!0,sx:{flex:1},...r})})]})]})}const Sm=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Stack,{children:n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]})})},Tm=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Sm,{control:e,index:i})})]})};function km({control:e,watch:t}){return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:r})=>n.jsx(L,{label:"数据字段",required:!0,sx:{flex:1},...r})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:r})=>n.jsx(s.TextInput,{label:"X轴名称",sx:{flex:1},...r})})]}),n.jsx(s.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:r})=>n.jsx(st,{sx:{width:"48%"},...r})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:r})=>n.jsx(Re,{...r})})]})]})}function Dm({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,jr),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:"X轴"}),n.jsx(s.Tabs.Tab,{value:"Deviation",children:"偏差"}),n.jsx(s.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(km,{control:o,watch:i})}),n.jsx(s.Tabs.Panel,{value:"Deviation",children:n.jsx(Cm,{control:o,watch:i})}),n.jsx(s.Tabs.Panel,{value:"Additional Metrics",children:n.jsx(Tm,{control:o,watch:i})})]})]})})}const zm=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function Mm(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis:o,deviation:l,metrics:i,...c}=e;return{...c,x_axis:{...o,data_key:a(o.data_key)},deviation:{...l,data_keys:{estimated_value:a(l.data_keys.estimated_value),actual_value:a(l.data_keys.actual_value)}},metrics:i.map(d=>({...d,data_key:a(d.data_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function Im(e){const t=e.metrics;return{...e,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}class Vm extends J{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>{const{config:o}=r;return{...r,version:2,config:Mm(o,a)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:Im(a)}})}}const Pm={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Vm,name:"mericoEstimationChart",viewRender:xm,configRender:Dm,createConfig:()=>({version:3,config:jr}),translation:zm},Ur={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:rt()};function $m({control:e,watch:t}){const{t:r}=m.useTranslation();t(["heat_block"]);const a=t("heat_block.label.show");return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:o})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...o})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:o})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:o})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...o})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:o})=>n.jsx(Ne,{...o})}),n.jsx(s.Divider,{mb:-5,variant:"dashed",label:r("chart.label.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.label.show",control:e,render:({field:o})=>n.jsx(s.Switch,{label:r("chart.heatmap.heatblock.show_label"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked),sx:{flexGrow:1}})}),n.jsx(v.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:o})=>n.jsx(s.NumberInput,{size:"xs",leftSection:n.jsx(T.IconTextSize,{size:16}),disabled:!a,...o})})]})]})}const Am=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Em=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Am,{control:e,index:i})})]})};function Bm({control:e,watch:t}){return n.jsx(Em,{control:e,watch:t})}function qm({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Om({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Lm({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Ur,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx("form",{onSubmit:d(a),style:{flexGrow:1},children:n.jsxs(s.Stack,{gap:"xs",sx:{height:"100%"},children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(qm,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(Om,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx($m,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx($r,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Bm,{control:c,watch:u})})]})]})})}function Nm(e){return n.jsx(n.Fragment,{})}function Gm(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const ul={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:Gm,configRender:Nm,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Fm(e){const t=Me(e.x_axis.axisLabel.formatter),r=Me(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:r}}function Qm(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function jm(e){let t=0;return e.x_axis.name&&(t+=20),{top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Wm(e,t){const{heat_block:r}=e;return{type:"heatmap",name:r.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:t,label:r.label,labelLayout:{hideOverlap:!0},z:2}}const Um=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Km({conf:e,labelFormatters:t,valueFormatters:r,dataDict:a,params:o,metricUnitMap:l}){const{value:i,dataIndex:c}=o,[d,u,p]=i,g={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(d,c),style:{label:"",value:Le(e.x_axis.axisLabel.overflow.in_tooltip)},unit:""},b={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,c),style:{label:"",value:Le(e.y_axis.axisLabel.overflow.in_tooltip)},unit:""},_={label:e.heat_block.name,value:r.heat_block(p),style:{label:"",value:""},unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""},w=[g,b,_],x=a[`${d}---${u}`];return x&&e.tooltip.metrics.forEach(S=>{const D=$(S.data_key),z=l[S.name];w.push({label:S.name,value:Um(y.get(x,D.columnKey,"")),style:{label:"",value:""},unit:z})}),w}function Ym(e,t,r,a){const{x_axis:o,y_axis:l,heat_block:i}=e,c=$(o.data_key),d=$(l.data_key);$(i.data_key);const u=y.keyBy(t[c.queryID],g=>`${g[c.columnKey]}---${g[d.columnKey]}`),p=e.tooltip.metrics.reduce((g,{unit:b,name:_})=>(b.show_in_tooltip&&(g[_]=b.text),g),{});return X.getTooltip({formatter:function(g){const _=Km({conf:e,labelFormatters:r,valueFormatters:a,dataDict:u,params:g,metricUnitMap:p}).map(x=>`
|
|
314
|
+
`}},show_in_legend:!0}))}function sm(e,t,r,a){const o=$(t.data_key),l=t.name,i=r.map(c=>{const d=y.sumBy(a[c],o.columnKey);return[c,d]});return{type:"line",name:l,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:i,show_in_legend:!1}}function om(e,t,r,a){const i={barMinWidth:5,barMaxWidth:20};return[em(e,r,a),nm(e,r,a,i),...am(e,r,a,i),sm(e,t,r,a)]}function lm(e,t){const{axisLabel:r}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...r,formatter:Me(r.formatter)},axisLine:{show:!1}}]}function im(e){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function Ur(e){return e==1||e==2?1:Ur(e-2)+Ur(e-1)}const cm=Array.from(new Array(20),(e,t)=>Ur(t+1));function dl(e){return e<=1?e:cm.findIndex(t=>e<=t)-1}function dm(e,t){const{x_axis:r,deviation:a}=e,o=$(r.data_key),l=$(a.data_keys.estimated_value),i=$(a.data_keys.actual_value);return t[o.queryID].map(c=>{const d=dl(c[l.columnKey]),u=dl(c[i.columnKey]),p=d-u;return{...c,level:{estimated:d,actual:u,diff:p}}})}function um(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function pm(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(r=>r.show_in_legend).reverse().map(r=>({name:`${r.name}`,color:r.color,itemStyle:um(r.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const hm={tooltip:{trigger:"axis"}};function gm(e,t){const{deviation:r,metrics:a}=e,o=a.find(i=>i.data_key===t);if(o)return o;const l=r.data_keys.actual_value;return{id:l,name:r.name,data_key:l,unit:K()}}function fm(e,t,r){const a=dm(e,r),o=$(e.x_axis.data_key),l=y.uniqBy(r[o.queryID],o.columnKey).map(p=>p[o.columnKey]),i=y.groupBy(a,o.columnKey),c=gm(e,t),d=om(e,c,l,i),u={xAxis:lm(e,l),yAxis:im(c),series:d,grid:R_(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:pm(d)};return y.defaultsDeep({},u,hm)}const bm={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},ym=({conf:e,metricKey:t,setMetricKey:r})=>{const{deviation:a,metrics:o}=e,l=h.useMemo(()=>{const i=o.map(c=>({label:c.name,value:c.data_key}));return i.push({label:a.name?a.name:a.data_keys.actual_value,value:a.data_keys.actual_value}),i},[a,o]);return n.jsxs(s.Group,{gap:1,children:[n.jsx(s.Text,{size:"12px",c:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),n.jsx(s.NativeSelect,{size:"xs",data:l,value:t,onChange:i=>r(i.currentTarget.value),styles:bm})]})},vm={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function _m(){return n.jsxs(s.HoverCard,{width:400,shadow:"md",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconInfoCircle,{size:14}),children:"指标说明"})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.Table,{fz:14,sx:vm,children:n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"估算偏差"}),n.jsx(s.Table.Td,{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"准确估算比例"}),n.jsx(s.Table.Td,{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function mm(e){return n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(_m,{}),n.jsx(ym,{...e})]})}function wm({conf:e,data:t,width:r,height:a,metricKey:o,instance:l}){const i=h.useMemo(()=>fm(e,o,t),[e,t,o]),c=h.useRef(null),d=h.useCallback(()=>{var g;const p=(g=c.current)==null?void 0:g.getEchartsInstance();p&&fe(l,p.getOption())},[l]),u=h.useMemo(()=>({finished:d}),[d]);return n.jsx(he,{ref:c,onEvents:u,echarts:ce,option:i,style:{width:r,height:a},notMerge:!0,theme:"merico-light"})}function xm({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},r,Wr),[r]),o=e.data,{width:l,height:i}=e.viewport,{x_axis:c,deviation:d}=a,{estimated_value:u,actual_value:p}=d.data_keys,[g,b]=h.useState(p);if(h.useEffect(()=>{b(x=>x||p)},[p]),!c.data_key||!u||!p||!l||!i)return null;const _=Math.max(qe(l),300),w=Math.max(Oe(i),370);return n.jsxs(s.Box,{pt:we.top,pr:we.right,pb:we.bottom,pl:we.left,sx:{overflow:"hidden",height:i,width:l},children:[n.jsx(mm,{conf:a,metricKey:g,setMetricKey:b}),n.jsx(wm,{instance:t,width:_,height:w-30,data:o,conf:a,metricKey:g})]})}function Cm({control:e,watch:t}){return t(["deviation"]),n.jsxs(s.Stack,{children:[n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"deviation.name",control:e,render:({field:r})=>n.jsx(s.TextInput,{label:"指标名称",sx:{flex:1},...r})})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"deviation.data_keys.estimated_value",control:e,render:({field:r})=>n.jsx(L,{label:"估算值字段",required:!0,sx:{flex:1},...r})}),n.jsx(v.Controller,{name:"deviation.data_keys.actual_value",control:e,render:({field:r})=>n.jsx(L,{label:"实际值字段",required:!0,sx:{flex:1},...r})})]})]})}const Sm=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Stack,{children:n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]})})},Tm=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Sm,{control:e,index:i})})]})};function km({control:e,watch:t}){return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:r})=>n.jsx(L,{label:"数据字段",required:!0,sx:{flex:1},...r})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:r})=>n.jsx(s.TextInput,{label:"X轴名称",sx:{flex:1},...r})})]}),n.jsx(s.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:r})=>n.jsx(st,{sx:{width:"48%"},...r})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:r})=>n.jsx(Re,{...r})})]})]})}function Dm({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Wr),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:"X轴"}),n.jsx(s.Tabs.Tab,{value:"Deviation",children:"偏差"}),n.jsx(s.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(km,{control:o,watch:i})}),n.jsx(s.Tabs.Panel,{value:"Deviation",children:n.jsx(Cm,{control:o,watch:i})}),n.jsx(s.Tabs.Panel,{value:"Additional Metrics",children:n.jsx(Tm,{control:o,watch:i})})]})]})})}const zm=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function Mm(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis:o,deviation:l,metrics:i,...c}=e;return{...c,x_axis:{...o,data_key:a(o.data_key)},deviation:{...l,data_keys:{estimated_value:a(l.data_keys.estimated_value),actual_value:a(l.data_keys.actual_value)}},metrics:i.map(d=>({...d,data_key:a(d.data_key)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function Im(e){const t=e.metrics;return{...e,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}class Vm extends J{constructor(){super(...arguments);V(this,"VERSION",3)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,a)=>{const{config:o}=r;return{...r,version:2,config:Mm(o,a)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:Im(a)}})}}const Pm={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Vm,name:"mericoEstimationChart",viewRender:xm,configRender:Dm,createConfig:()=>({version:3,config:Wr}),translation:zm},Kr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ie(),formatter:_e()}},heat_block:{name:"Value",data_key:"",unit:K(),value_formatter:de,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:rt()};function $m({control:e,watch:t}){const{t:r}=m.useTranslation();t(["heat_block"]);const a=t("heat_block.label.show");return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.data_key",control:e,render:({field:o})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...o})}),n.jsx(v.Controller,{name:"heat_block.name",control:e,render:({field:o})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...o})})]}),n.jsx(v.Controller,{name:"heat_block.unit",control:e,render:({field:o})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...o})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:o})=>n.jsx(Ne,{...o})}),n.jsx(s.Divider,{mb:-5,variant:"dashed",label:r("chart.label.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"heat_block.label.show",control:e,render:({field:o})=>n.jsx(s.Switch,{label:r("chart.heatmap.heatblock.show_label"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked),sx:{flexGrow:1}})}),n.jsx(v.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:o})=>n.jsx(s.NumberInput,{size:"xs",leftSection:n.jsx(T.IconTextSize,{size:16}),disabled:!a,...o})})]})]})}const Am=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},Em=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Am,{control:e,index:i})})]})};function Bm({control:e,watch:t}){return n.jsx(Em,{control:e,watch:t})}function qm({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Om({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["y_axis"]),n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"y_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]})]})}function Lm({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>r?y.defaults({},r):Kr,[r]),l=h.useMemo(()=>y.cloneDeep(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const i=v.useForm({defaultValues:l}),{control:c,handleSubmit:d,watch:u,formState:p,reset:g}=i;return h.useEffect(()=>{g(l)},[l]),n.jsx("form",{onSubmit:d(a),style:{flexGrow:1},children:n.jsxs(s.Stack,{gap:"xs",sx:{height:"100%"},children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),n.jsx(s.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(qm,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(Om,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Heat Block",children:n.jsx($m,{control:c,watch:u})}),n.jsx(s.Tabs.Panel,{value:"Visual Map",children:n.jsx(Ar,{form:i})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Bm,{control:c,watch:u})})]})]})})}function Nm(e){return n.jsx(n.Fragment,{})}function Gm(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const ul={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:Gm,configRender:Nm,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Fm(e){const t=Me(e.x_axis.axisLabel.formatter),r=Me(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:r}}function Qm(e){return{heat_block:function(a){if(!e.heat_block.value_formatter)return a;try{return Y(a,e.heat_block.value_formatter)}catch(o){return console.error(o),a}}}}function jm(e){let t=0;return e.x_axis.name&&(t+=20),{top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Wm(e,t){const{heat_block:r}=e;return{type:"heatmap",name:r.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:t,label:r.label,labelLayout:{hideOverlap:!0},z:2}}const Um=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Km({conf:e,labelFormatters:t,valueFormatters:r,dataDict:a,params:o,metricUnitMap:l}){const{value:i,dataIndex:c}=o,[d,u,p]=i,g={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(d,c),style:{label:"",value:Le(e.x_axis.axisLabel.overflow.in_tooltip)},unit:""},b={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,c),style:{label:"",value:Le(e.y_axis.axisLabel.overflow.in_tooltip)},unit:""},_={label:e.heat_block.name,value:r.heat_block(p),style:{label:"",value:""},unit:e.heat_block.unit.show_in_tooltip?e.heat_block.unit.text:""},w=[g,b,_],x=a[`${d}---${u}`];return x&&e.tooltip.metrics.forEach(S=>{const D=$(S.data_key),z=l[S.name];w.push({label:S.name,value:Um(y.get(x,D.columnKey,"")),style:{label:"",value:""},unit:z})}),w}function Ym(e,t,r,a){const{x_axis:o,y_axis:l,heat_block:i}=e,c=$(o.data_key),d=$(l.data_key);$(i.data_key);const u=y.keyBy(t[c.queryID],g=>`${g[c.columnKey]}---${g[d.columnKey]}`),p=e.tooltip.metrics.reduce((g,{unit:b,name:_})=>(b.show_in_tooltip&&(g[_]=b.text),g),{});return X.getTooltip({formatter:function(g){const _=Km({conf:e,labelFormatters:r,valueFormatters:a,dataDict:u,params:g,metricUnitMap:p}).map(x=>`
|
|
315
315
|
<tr>
|
|
316
316
|
<th style="text-align: right; padding: 0 1em;">
|
|
317
317
|
<div style="${x.style.label}">${x.label}</div>
|
|
@@ -335,7 +335,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
335
335
|
</thead>
|
|
336
336
|
<tbody>${_.join("")}</tbody>
|
|
337
337
|
</table>
|
|
338
|
-
`}})}function Xm(e,t,r){const{overflow:a,rotate:o}=e.x_axis.axisLabel,l=Ke(a.on_axis);return X.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:o,...l,formatter:r},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Zm(e,t){const{nameAlignment:r,data_key:a,...o}=e.y_axis,{overflow:l,rotate:i}=e.y_axis.axisLabel,c=Ke(l.on_axis);return X.getYAxis({...o,type:"category",axisLabel:{rotate:i,...c,formatter:t},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:r},nameLocation:"end",nameGap:15,z:3})}function Jm(e,t,r){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const a=r.reduce((x,S)=>{const D=He(S,t);return x[S.name]=Be(S,D),x},{}),o=Fm(e),l=Qm(e),i=pn(e.visualMap,a),{min:c,max:d}=i,u=$(e.x_axis.data_key),p=$(e.y_axis.data_key),g=$(e.heat_block.data_key),b=y.uniq(t[u.queryID].map(x=>x[u.columnKey])),_=t[u.queryID].map(x=>{const S=y.get(x,u.columnKey),D=y.get(x,p.columnKey),z=y.get(x,g.columnKey),I={value:[S,D,z]},{followVisualMap:A,color:E}=pr(z,c,d,e.visualMap);return A||(I.visualMap=!1,I.itemStyle={color:E}),I});return{xAxis:Xm(e,b,o.x_axis),yAxis:Zm(e,o.y_axis),series:Wm(e,_),tooltip:Ym(e,t,o,l),grid:jm(e),visualMap:i}}function Hm({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=h.useMemo(()=>{const w=$(e.x_axis.data_key),x=$(e.y_axis.data_key);return y.keyBy(t[w.queryID],S=>`${S[w.columnKey]}---${S[x.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),d=Ve(o.triggerManager,ul.id),u=h.useCallback(w=>{const[x,S]=w.value,D=y.get(c,`${x}---${S}`,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...w,rowData:D})})},[c,d,o]),p=h.useRef(null),g=h.useCallback(()=>{var x;const w=(x=p.current)==null?void 0:x.getEchartsInstance();w&&fe(i,w.getOption())},[i]),b=h.useMemo(()=>({click:u,finished:g}),[u,g]),_=h.useMemo(()=>Jm(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:_,ref:p,style:{width:r,height:a},onEvents:b,notMerge:!0,theme:"merico-light"})}function Rm({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Ur),[a]),i=e.data,{width:c,height:d}=e.viewport;return!c||!d?null:n.jsx(ve,{width:c,height:d,children:n.jsx(Hm,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,conf:l,interactionManager:r})})}const ew=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function tw(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function nw(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function rw(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}class aw extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:tw(r.config)})),this.version(3,r=>({...r,version:3,config:nw(r.config)})),this.version(4,r=>({...r,version:4,config:rw(r.config)}))}}const sw={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new aw,name:"merico-heatmap",viewRender:Rm,configRender:Lm,createConfig:()=>({version:4,config:Ur}),triggers:[ul],translation:ew};function ow(e){const{order:t="asc",format:r=zo(),...a}=e;return{...a,order:t,format:r}}class lw extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{config:a}=r;return{...r,version:2,config:ow(a)}})}}const Kr=()=>({value:"",order:"asc",format:zo(),sections:[{name:"较差",color:"#ff0034",minKey:""},{name:"一般",color:"#ffc04d",minKey:""},{name:"良好",color:"#adcfe4",minKey:""},{name:"优秀",color:"#32cb95",minKey:""}],stats:{top:"",bottom:""}});function iw(e,t){if(!t)return 0;switch(t){case"infinity":return Number.POSITIVE_INFINITY;case"negative_infinity":return Number.NEGATIVE_INFINITY;default:return y.get(me(e,t),"0","null")}}const cw=(e,t)=>{const{order:r}=e,a={value:y.get(me(t,e.value),"0","null"),sections:e.sections.map(l=>{const i=iw(t,l.minKey);return{name:l.name,color:l.color,min:i,pointer:!1,pointer_equal:!1}})},o=a.value;if(r==="asc")for(let l=0;l<a.sections.length;l++){const i=a.sections[l].min;if(o<i)break;a.sections[l].pointer=!0,a.sections[l].pointer_equal=o===i,l>0&&(a.sections[l-1].pointer=!1,a.sections[l-1].pointer_equal=!1)}if(r==="desc")for(let l=a.sections.length-1;l>=0;l--){const i=a.sections[l].min;if(a.sections[l].pointer=!0,a.sections[l].pointer_equal=o===i,l<a.sections.length-1&&(a.sections[l+1].pointer=!1,a.sections[l+1].pointer_equal=!1),o<=i)break}return a},Zt={section:"_section_1jopp_1",min:"_min_1jopp_12",name:"_name_1jopp_19",pointer:"_pointer_1jopp_23",pointer_equal:"_pointer_equal_1jopp_30"};function dw({conf:e,data:t,width:r,height:a}){const o=h.useMemo(()=>cw(e,t),[e,t]);return!r||!a?null:n.jsx(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,pt:"sm",mah:a,w:r,children:o.sections.map(l=>n.jsxs(s.Center,{className:Zt.section,style:{backgroundColor:l.color},children:[n.jsx(s.Text,{size:"sm",className:Zt.name,children:l.name}),l.min>0?n.jsx(s.Text,{size:"xs",className:Zt.min,children:Y(l.min,e.format)}):null,l.pointer?n.jsx(T.IconArrowUp,{className:`${Zt.pointer} ${l.pointer_equal?Zt.pointer_equal:""}`,stroke:1.5}):null]},`${l.name}-${l.color}-${l.min}`))})}function uw({context:e}){const{value:t}=q(e.instanceData,"config"),r=h.useMemo(()=>y.defaults({},t,Kr()),[t]),a=e.data,{width:o,height:l}=e.viewport,[i,c]=h.useState(0),[d,u]=h.useState(0),p=Math.max(0,Oe(l)-i-d),g=qe(o);return n.jsxs(ve,{width:o,height:l,children:[n.jsx(zt,{onHeightChange:c,value:r.stats.top,context:e}),n.jsx(dw,{width:g,height:p,data:a,conf:r})]})}const pw=[{lang:"en",resources:{merico_linear_gauge:{viz_name:"Merico Linear Gauge",sections:{label:"Sections",min_key:{placeholder:"Min value",zero:"Zero",infinity:"Infinity",negative_infinity:"Negative Infinity"},add:"Add a section"},value:"Value",order:{label:"Order",asc:"Ascending",desc:"Descending"}}}},{lang:"zh",resources:{merico_linear_gauge:{viz_name:"思码逸线性仪表盘",sections:{label:"配置区间",min_key:{placeholder:"区间最小值",zero:"零",infinity:"正无穷",negative_infinity:"负无穷"},add:"增加一个区间"},value:"值",order:{label:"顺序",asc:"升序",desc:"降序"}}}}],hw=({row:e,index:t,handleChange:r,handleRemove:a,additional_options:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),[d,{setTrue:u,setFalse:p}]=O.useBoolean(!1),{ref:g,handleRef:b}=an.useSortable({id:e.id,index:t}),_=S=>{r({...e,name:S})},w=S=>{r({...e,minKey:S})},x=S=>{r({...e,color:S})};return n.jsxs(s.Flex,{ref:g,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:u,onMouseLeave:p,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:d?n.jsx(s.ActionIcon,{size:"xs",ref:b,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.TextInput,{size:"xs",value:e.name,placeholder:l("viz.pie_chart.color.map.name"),onChange:S=>_(S.currentTarget.value),onClick:c,error:i&&!e.name}),n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.color,onChange:x,onClick:c,error:i&&!e.color}),n.jsx(L,{label:"",placeholder:l("viz.merico_linear_gauge.sections.min_key_placeholder"),onChange:w,value:e.minKey,clearable:!0,unsetKey:"viz.merico_linear_gauge.sections.min_key.zero",size:"xs",additional_options:o})]}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},gw=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",color:"",minKey:""})};return n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.merico_linear_gauge.sections.add")})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})},fw=Object.entries(y.pick(Ue.graphics,["compared","level","depth","multiple"])).map(([e,t])=>({name:e,colors:Object.values(t)}));function bw(e){const t=e.length;if(t===0)return"";const r={output:"percent",mantissa:4,trimMantissa:!0},a=y.divide(1,t),o=[];return e.forEach((i,c)=>{o.push(`${i} ${Ee(c*a).format(r)}`),o.push(`${i} ${Ee((c+1)*a).format(r)}`)}),`linear-gradient(90deg, ${o.join(",")})`}const yw=({value:e,onChange:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=l=>{const i=e.map((c,d)=>({name:c.name,color:l[d],minKey:""}));for(let c=i.length-1;c<l.length;c++)i.push({name:"",color:l[c],minKey:""});t(i)};return n.jsxs(s.Menu,{withArrow:!0,shadow:"md",width:400,styles:{item:{overflowX:"hidden"}},children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",rightSection:n.jsx(s.Combobox.Chevron,{size:"xs"}),children:r("viz.pie_chart.color.map.use_a_palette")})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:r("viz.pie_chart.color.map.click_to_apply_palette")}),n.jsx(s.Menu.Divider,{}),fw.map(l=>n.jsx(s.Menu.Item,{onClick:()=>o(l.colors),children:n.jsx(s.Box,{h:28,style:{backgroundImage:bw(l.colors)}})},l.name))]})]})},vw=h.forwardRef(({value:e,onChange:t,data:r},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>e.map(g=>({id:Te.v4(),...g})),[e]),i=g=>{t([...e,g])},c=g=>{const b=[...e];b.splice(g,1),t(b)},d=g=>b=>{const _=[...e];_[g]=b,t(_)},u=g=>{const{source:b,target:_}=g.operation,w=Un.move(l,b,_);t(w.map(x=>y.omit(x,"id")))},p=h.useMemo(()=>[{label:o("viz.merico_linear_gauge.sections.min_key.infinity"),value:"positive_infinity"},{label:o("viz.merico_linear_gauge.sections.min_key.negative_infinity"),value:"negative_infinity"}],[o]);return n.jsxs(s.Stack,{ref:a,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:o("viz.merico_linear_gauge.sections.label")}),n.jsx(yw,{value:e,onChange:t})]}),n.jsx(rn.DragDropProvider,{onDragEnd:u,children:l.map((g,b)=>n.jsx(hw,{row:g,handleChange:d(b),handleRemove:()=>c(b),index:b,additional_options:p},g.id))}),n.jsx(gw,{append:i})]})});function _w({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),{t:a}=m.useTranslation(),o=e.data,l=h.useMemo(()=>y.defaultsDeep({},t,Kr()),[t]),i=v.useForm({defaultValues:l}),{handleSubmit:c,formState:d,reset:u}=i;h.useEffect(()=>{i.reset(l)},[l]);const p=h.useMemo(()=>[{label:a("viz.merico_linear_gauge.order.asc"),value:"asc"},{label:a("viz.merico_linear_gauge.order.desc"),value:"desc"}],[a]);return n.jsxs("form",{onSubmit:c(r),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{gap:"lg",pt:"xs",px:"xs",children:[n.jsx(v.Controller,{name:"stats.top",control:i.control,render:({field:g})=>n.jsx(gt,{initialValue:g.value,onChange:g.onChange,label:a("chart.stats.template.above_chart")},"stats.top")}),n.jsx(s.Divider,{}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"value",control:i.control,render:({field:g})=>n.jsx(L,{label:a("viz.merico_linear_gauge.value"),size:"xs",...g,clearable:!0})}),n.jsx(v.Controller,{name:"order",control:i.control,render:({field:g})=>n.jsx(s.Select,{label:a("viz.merico_linear_gauge.order.label"),size:"xs",data:p,...g,clearable:!0})})]}),n.jsx(v.Controller,{name:"sections",control:i.control,render:({field:g})=>n.jsx(vw,{...g,data:o})}),n.jsx(s.Divider,{}),n.jsx(v.Controller,{name:"format",control:i.control,render:({field:g})=>n.jsx(Ne,{size:"xs",...g})})]})]})}const mw={displayName:"viz.merico_linear_gauge.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new lw,name:"merico_linear_gauge",viewRender:uw,configRender:_w,createConfig:()=>({version:2,config:Kr()}),translation:pw},Yr={styles:{justify:"space-around",align:"start"},metrics:[]};function ww(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:de,postfix:{type:"text",value:""}}}const pl=({postfix:e})=>e?n.jsxs(n.Fragment,{children:[n.jsx(s.Text,{size:"12px",c:"#818388",sx:{lineHeight:1},children:"/"}),n.jsx(s.Text,{size:"12px",c:"#818388",sx:{lineHeight:1},children:e})]}):null,xw=k.observer(({metric:e,variableValueMap:t})=>{const{names:r,data_keys:a,formatter:o,postfix:l}=e,i=H(),c=h.useMemo(()=>{if(l.type==="text"&&l.value)return l.value;if(l.type==="filter-option-label"&&l.value){const d=i.filters.getSelectOption(l.value);return d?d.label:null}return null},[l,i]);return n.jsxs(s.Stack,{gap:18,children:[n.jsxs(s.Stack,{gap:12,children:[n.jsx(s.Text,{size:"14px",c:"#818388",children:r.value}),n.jsxs(s.Group,{gap:"2px",align:"baseline",children:[n.jsx(s.Text,{size:"24px",fw:"bold",c:"#3D3E45",sx:{lineHeight:1},children:Y(t[a.value],o)}),n.jsx(pl,{postfix:c})]})]}),n.jsxs(s.Stack,{gap:12,children:[n.jsx(s.Text,{size:"14px",c:"#818388",children:r.basis}),n.jsxs(s.Group,{gap:"2px",align:"baseline",children:[n.jsx(s.Text,{size:"12px",c:"#3D3E45",sx:{lineHeight:1},children:Y(t[a.basis],o)}),n.jsx(pl,{postfix:c})]})]})]})}),Cw=k.observer(({context:e,instance:t})=>{const{value:r}=q(e.instanceData,"config"),{variables:a}=e,o=h.useMemo(()=>y.defaults({},r,Yr),[r]),l=e.data,i=h.useMemo(()=>qr(l,a),[a,l]),{width:c,height:d}=e.viewport;return!c||!d||!o?null:n.jsx(s.Flex,{w:`${c}px`,h:`${d}px`,justify:o.styles.justify,align:o.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:o.metrics.map(u=>n.jsx(xw,{metric:u,variableValueMap:i},u.id))})}),Sw=k.observer(h.forwardRef(({value:e,onChange:t},r)=>{const{t:a,i18n:o}=m.useTranslation(),i=F().filters.selects,c=p=>{if(!p)return;t({type:p,value:e.value})},d=p=>{if(p===null)return p;t({type:e.type,value:p})},u=h.useMemo(()=>[{label:a("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:a("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[o.language]);return n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{label:a("viz.merico_stats.metric.postfix_type.label"),data:u,value:e.type,onChange:c}),e.type==="text"&&n.jsx(s.TextInput,{label:a("viz.merico_stats.metric.postfix_content"),value:e.value,onChange:p=>{d(p.currentTarget.value)}}),e.type==="filter-option-label"&&n.jsx(s.Select,{label:a("viz.merico_stats.metric.postfix_filter"),value:e.value,onChange:d,data:i})]})}));function Tw({control:e,index:t,watch:r,variableOptions:a}){const{t:o}=m.useTranslation();return r(`metrics.${t}.postfix`),n.jsxs(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.names.value`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`metrics.${t}.data_keys.value`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("viz.merico_stats.metric.metric_data_field"),required:!0,data:a,sx:{flex:1},...l})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.names.basis`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`metrics.${t}.data_keys.basis`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("viz.merico_stats.metric.basis_data_field"),required:!0,data:a,sx:{flex:1},...l})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`metrics.${t}.formatter`,control:e,render:({field:l})=>n.jsx(Ne,{...l})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("viz.merico_stats.metric.others"),labelPosition:"center"}),n.jsx(v.Controller,{name:`metrics.${t}.postfix`,control:e,render:({field:l})=>n.jsx(Sw,{...l})})]})}const kw=({control:e,watch:t,variables:r})=>{const{t:a}=m.useTranslation(),o=()=>ww(),l=(d,u)=>{const p=d.names.value.trim();return p||u+1},i=({field:d,index:u,fields:p})=>p.length<=1,c=h.useMemo(()=>r.map(d=>({label:d.name,value:d.name})),[r]);return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:15,variant:"dashed",label:a("viz.merico_stats.metric.labels"),labelPosition:"center"}),n.jsx(R,{control:e,watch:t,name:"metrics",getItem:o,addButtonText:a("chart.tooltip.additional_metrics.add"),deleteButtonText:a("chart.tooltip.additional_metrics.delete"),renderTabName:l,deleteDisalbed:i,children:({field:d,index:u})=>n.jsx(Tw,{control:e,index:u,variableOptions:c,watch:t})})]})};function Dw({control:e,watch:t}){const{t:r}=m.useTranslation();return t("styles"),n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:15,variant:"dashed",label:r("style.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(v.Controller,{name:"styles.justify",control:e,render:({field:a})=>n.jsx(sf,{sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"styles.align",control:e,render:({field:a})=>n.jsx(of,{label:r("viz.merico_stats.align_items.label"),sx:{flex:1},...a})})]})]})}function zw({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),{variables:a}=e,o=h.useMemo(()=>y.defaultsDeep({},t,Yr),[t]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),n.jsx("form",{onSubmit:i(r),children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsx(Dw,{control:l,watch:c}),n.jsx(kw,{control:l,watch:c,variables:a})]})})}function Mw(e){const{metrics:t,...r}=e;return{...r,metrics:t.map(a=>({...a,postfix:a.postfix??{type:"text",value:""}}))}}const Iw=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class Vw extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({...r,version:1,config:r.config})),this.version(2,r=>({...r,version:2,config:Mw(r.config)}))}}const Pw={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Vw,name:"merico-stats",viewRender:Cw,configRender:zw,createConfig:()=>({version:2,config:Yr}),translation:Iw},$w=[{lang:"en",resources:{pareto_chart:{viz_name:"Pareto Chart",line_80_20:{label:"80-20 Line",label_template:"Label Template",click_to_see_params:"Click to see params for Label Template",param_section_note_1:"80-20 line stuff",param_section_note_2:"chart configs"},click_series:{label:"Click chart series"}}}},{lang:"zh",resources:{pareto_chart:{viz_name:"帕累托图",line_80_20:{label:"80/20线",label_template:"线上文案模板",click_to_see_params:"点击查看线上文案模板的参数",param_section_note_1:"80-20线相关",param_section_note_2:"图表配置信息"},click_series:{label:"点击柱或线"}}}}],hl={id:"builtin:echarts:click-echart:series",displayName:"viz.pareto_chart.click_series.label",nameRender:Ew,configRender:Aw,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'line' | 'bar'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Aw(e){return n.jsx(n.Fragment,{})}function Ew(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.pareto_chart.click_series.label")})}const gl={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},Xr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},data_key:"value",bar:{name:"Value",nameAlignment:"left",color:"#228be6",label_formatter:de,unit:K()},line:{name:"Value",nameAlignment:"right",color:"red"},dataZoom:kt,markLine:gl,reference_lines:[]};function Tn(e){return Y(e,{output:"percent",mantissa:0,absolute:!1})}function Bw(e){const t=e.value[1];try{return Tn(t)}catch(r){return console.error(r),t}}function qw(e){function t(r){let a=r;if(typeof r=="object"&&(Array.isArray(r.value)&&r.value.length===2?a=r.value[1]:a=r.value),!e.bar.label_formatter)return a;try{return Y(a,e.bar.label_formatter)}catch(o){return console.error(o),a}}return{bar:t,line:Bw,lineValue:Tn}}function Ow(e,t,r){const{label_template:a}=e.markLine;if(!a)return"";const o={...e,percentage:t,count:r},l=Object.keys(o),i=Object.values(o);return new Function(...l,`return \`${a}\`;`)(...i)}function Lw(e){const t=Number(Ee(e).format({output:"number",mantissa:2}));return t<.33?"left":t>.66?"right":"center"}function Nw(e,t){if(t.length===0)return{};const r=t.findIndex(d=>d[1]>=.8);if(r===-1)return{};const a=t[r],o=(r+1)/t.length,l={x:Tn(o),y:Tn(a[1])},i={left:r+1,right:t.length-r-1},c=a[0];return c?{markLine:{name:"",silent:!0,symbol:"triangle",symbolRotate:180,symbolSize:[10,8],data:[{name:"",symbol:"none",xAxis:c,lineStyle:{color:e.markLine.color},label:{formatter:Ow(e,l,i),position:"end",align:Lw(o)}}]},markArea:{name:"",silent:!0,itemStyle:{color:"rgba(47, 140, 192, 0.05)"},data:[[{coord:["min",0]},{xAxis:c}]]}}:{}}function Gw(e,t,r){const a=t.reduce((c,d)=>c+d[1],0),o=t.reduce((c,d,u)=>{const p=u===0?0:c[u-1][1];return c.push([d[0],p+d[1]]),c},[]).map(c=>[c[0],c[1]/a]),{markLine:l,markArea:i}=Nw(e,o);return[{name:e.bar.name,type:"bar",barMaxWidth:20,itemStyle:{color:e.bar.color},label:{show:!1,position:"top",formatter:r.bar},yAxisIndex:0,data:t},{name:e.line.name,type:"line",itemStyle:{color:e.line.color},symbolSize:2,lineStyle:{width:1,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:1},label:{show:!1,position:"top",formatter:r.line},yAxisIndex:1,data:o,markLine:l,markArea:i}]}function Fw(e){const t=e.bar.unit;return t.show_in_tooltip?t.text:""}const Qw=(e,t)=>r=>{const a=Array.isArray(r)?r:[r];if(a.length===0)return"";const o=Fw(e),l=a.map(d=>{const{seriesName:u,componentSubType:p}=d,[g,b]=d.value;return u?p==="bar"?`
|
|
338
|
+
`}})}function Xm(e,t,r){const{overflow:a,rotate:o}=e.x_axis.axisLabel,l=Ke(a.on_axis);return X.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:o,...l,formatter:r},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Zm(e,t){const{nameAlignment:r,data_key:a,...o}=e.y_axis,{overflow:l,rotate:i}=e.y_axis.axisLabel,c=Ke(l.on_axis);return X.getYAxis({...o,type:"category",axisLabel:{rotate:i,...c,formatter:t},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:r},nameLocation:"end",nameGap:15,z:3})}function Jm(e,t,r){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const a=r.reduce((x,S)=>{const D=He(S,t);return x[S.name]=Be(S,D),x},{}),o=Fm(e),l=Qm(e),i=pn(e.visualMap,a),{min:c,max:d}=i,u=$(e.x_axis.data_key),p=$(e.y_axis.data_key),g=$(e.heat_block.data_key),b=y.uniq(t[u.queryID].map(x=>x[u.columnKey])),_=t[u.queryID].map(x=>{const S=y.get(x,u.columnKey),D=y.get(x,p.columnKey),z=y.get(x,g.columnKey),I={value:[S,D,z]},{followVisualMap:A,color:E}=hr(z,c,d,e.visualMap);return A||(I.visualMap=!1,I.itemStyle={color:E}),I});return{xAxis:Xm(e,b,o.x_axis),yAxis:Zm(e,o.y_axis),series:Wm(e,_),tooltip:Ym(e,t,o,l),grid:jm(e),visualMap:i}}function Hm({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=h.useMemo(()=>{const w=$(e.x_axis.data_key),x=$(e.y_axis.data_key);return y.keyBy(t[w.queryID],S=>`${S[w.columnKey]}---${S[x.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),d=Ve(o.triggerManager,ul.id),u=h.useCallback(w=>{const[x,S]=w.value,D=y.get(c,`${x}---${S}`,{error:"rowData is not found"});d.forEach(z=>{o.runInteraction(z.id,{...w,rowData:D})})},[c,d,o]),p=h.useRef(null),g=h.useCallback(()=>{var x;const w=(x=p.current)==null?void 0:x.getEchartsInstance();w&&fe(i,w.getOption())},[i]),b=h.useMemo(()=>({click:u,finished:g}),[u,g]),_=h.useMemo(()=>Jm(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:_,ref:p,style:{width:r,height:a},onEvents:b,notMerge:!0,theme:"merico-light"})}function Rm({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Kr),[a]),i=e.data,{width:c,height:d}=e.viewport;return!c||!d?null:n.jsx(ve,{width:c,height:d,children:n.jsx(Hm,{instance:t,variables:o,width:qe(c),height:Oe(d),data:i,conf:l,interactionManager:r})})}const ew=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function tw(e){const{visualMap:t=rt(),heat_block:{min:r,max:a,...o},...l}=e;return{...l,heat_block:o,visualMap:{...rt(),min:r,max:a}}}function nw(e){const t=e.tooltip.metrics;return{...e,tooltip:{...e.tooltip,metrics:t.map(r=>({...r,unit:r.unit??K()}))}}}function rw(e){const{heat_block:t}=e;return{...e,heat_block:{...t,unit:t.unit??K()}}}class aw extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:tw(r.config)})),this.version(3,r=>({...r,version:3,config:nw(r.config)})),this.version(4,r=>({...r,version:4,config:rw(r.config)}))}}const sw={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new aw,name:"merico-heatmap",viewRender:Rm,configRender:Lm,createConfig:()=>({version:4,config:Kr}),triggers:[ul],translation:ew};function ow(e){const{order:t="asc",format:r=zo(),...a}=e;return{...a,order:t,format:r}}class lw extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{config:a}=r;return{...r,version:2,config:ow(a)}})}}const Yr=()=>({value:"",order:"asc",format:zo(),sections:[{name:"较差",color:"#ff0034",minKey:""},{name:"一般",color:"#ffc04d",minKey:""},{name:"良好",color:"#adcfe4",minKey:""},{name:"优秀",color:"#32cb95",minKey:""}],stats:{top:"",bottom:""}});function iw(e,t){if(!t)return 0;switch(t){case"infinity":return Number.POSITIVE_INFINITY;case"negative_infinity":return Number.NEGATIVE_INFINITY;default:return y.get(me(e,t),"0","null")}}const cw=(e,t)=>{const{order:r}=e,a={value:y.get(me(t,e.value),"0","null"),sections:e.sections.map(l=>{const i=iw(t,l.minKey);return{name:l.name,color:l.color,min:i,pointer:!1,pointer_equal:!1}})},o=a.value;if(r==="asc")for(let l=0;l<a.sections.length;l++){const i=a.sections[l].min;if(o<i)break;a.sections[l].pointer=!0,a.sections[l].pointer_equal=o===i,l>0&&(a.sections[l-1].pointer=!1,a.sections[l-1].pointer_equal=!1)}if(r==="desc")for(let l=a.sections.length-1;l>=0;l--){const i=a.sections[l].min;if(a.sections[l].pointer=!0,a.sections[l].pointer_equal=o===i,l<a.sections.length-1&&(a.sections[l+1].pointer=!1,a.sections[l+1].pointer_equal=!1),o<=i)break}return a},Zt={section:"_section_1jopp_1",min:"_min_1jopp_12",name:"_name_1jopp_19",pointer:"_pointer_1jopp_23",pointer_equal:"_pointer_equal_1jopp_30"};function dw({conf:e,data:t,width:r,height:a}){const o=h.useMemo(()=>cw(e,t),[e,t]);return!r||!a?null:n.jsx(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,pt:"sm",mah:a,w:r,children:o.sections.map(l=>n.jsxs(s.Center,{className:Zt.section,style:{backgroundColor:l.color},children:[n.jsx(s.Text,{size:"sm",className:Zt.name,children:l.name}),l.min>0?n.jsx(s.Text,{size:"xs",className:Zt.min,children:Y(l.min,e.format)}):null,l.pointer?n.jsx(T.IconArrowUp,{className:`${Zt.pointer} ${l.pointer_equal?Zt.pointer_equal:""}`,stroke:1.5}):null]},`${l.name}-${l.color}-${l.min}`))})}function uw({context:e}){const{value:t}=q(e.instanceData,"config"),r=h.useMemo(()=>y.defaults({},t,Yr()),[t]),a=e.data,{width:o,height:l}=e.viewport,[i,c]=h.useState(0),[d,u]=h.useState(0),p=Math.max(0,Oe(l)-i-d),g=qe(o);return n.jsxs(ve,{width:o,height:l,children:[n.jsx(zt,{onHeightChange:c,value:r.stats.top,context:e}),n.jsx(dw,{width:g,height:p,data:a,conf:r})]})}const pw=[{lang:"en",resources:{merico_linear_gauge:{viz_name:"Merico Linear Gauge",sections:{label:"Sections",min_key:{placeholder:"Min value",zero:"Zero",infinity:"Infinity",negative_infinity:"Negative Infinity"},add:"Add a section"},value:"Value",order:{label:"Order",asc:"Ascending",desc:"Descending"}}}},{lang:"zh",resources:{merico_linear_gauge:{viz_name:"思码逸线性仪表盘",sections:{label:"配置区间",min_key:{placeholder:"区间最小值",zero:"零",infinity:"正无穷",negative_infinity:"负无穷"},add:"增加一个区间"},value:"值",order:{label:"顺序",asc:"升序",desc:"降序"}}}}],hw=({row:e,index:t,handleChange:r,handleRemove:a,additional_options:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),[d,{setTrue:u,setFalse:p}]=O.useBoolean(!1),{ref:g,handleRef:b}=an.useSortable({id:e.id,index:t}),_=S=>{r({...e,name:S})},w=S=>{r({...e,minKey:S})},x=S=>{r({...e,color:S})};return n.jsxs(s.Flex,{ref:g,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:u,onMouseLeave:p,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:d?n.jsx(s.ActionIcon,{size:"xs",ref:b,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.TextInput,{size:"xs",value:e.name,placeholder:l("viz.pie_chart.color.map.name"),onChange:S=>_(S.currentTarget.value),onClick:c,error:i&&!e.name}),n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.color,onChange:x,onClick:c,error:i&&!e.color}),n.jsx(L,{label:"",placeholder:l("viz.merico_linear_gauge.sections.min_key_placeholder"),onChange:w,value:e.minKey,clearable:!0,unsetKey:"viz.merico_linear_gauge.sections.min_key.zero",size:"xs",additional_options:o})]}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},gw=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",color:"",minKey:""})};return n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.merico_linear_gauge.sections.add")})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})},fw=Object.entries(y.pick(Ue.graphics,["compared","level","depth","multiple"])).map(([e,t])=>({name:e,colors:Object.values(t)}));function bw(e){const t=e.length;if(t===0)return"";const r={output:"percent",mantissa:4,trimMantissa:!0},a=y.divide(1,t),o=[];return e.forEach((i,c)=>{o.push(`${i} ${Ee(c*a).format(r)}`),o.push(`${i} ${Ee((c+1)*a).format(r)}`)}),`linear-gradient(90deg, ${o.join(",")})`}const yw=({value:e,onChange:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=l=>{const i=e.map((c,d)=>({name:c.name,color:l[d],minKey:""}));for(let c=i.length-1;c<l.length;c++)i.push({name:"",color:l[c],minKey:""});t(i)};return n.jsxs(s.Menu,{withArrow:!0,shadow:"md",width:400,styles:{item:{overflowX:"hidden"}},children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",rightSection:n.jsx(s.Combobox.Chevron,{size:"xs"}),children:r("viz.pie_chart.color.map.use_a_palette")})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:r("viz.pie_chart.color.map.click_to_apply_palette")}),n.jsx(s.Menu.Divider,{}),fw.map(l=>n.jsx(s.Menu.Item,{onClick:()=>o(l.colors),children:n.jsx(s.Box,{h:28,style:{backgroundImage:bw(l.colors)}})},l.name))]})]})},vw=h.forwardRef(({value:e,onChange:t,data:r},a)=>{const{t:o}=m.useTranslation(),l=h.useMemo(()=>e.map(g=>({id:Te.v4(),...g})),[e]),i=g=>{t([...e,g])},c=g=>{const b=[...e];b.splice(g,1),t(b)},d=g=>b=>{const _=[...e];_[g]=b,t(_)},u=g=>{const{source:b,target:_}=g.operation,w=Kn.move(l,b,_);t(w.map(x=>y.omit(x,"id")))},p=h.useMemo(()=>[{label:o("viz.merico_linear_gauge.sections.min_key.infinity"),value:"positive_infinity"},{label:o("viz.merico_linear_gauge.sections.min_key.negative_infinity"),value:"negative_infinity"}],[o]);return n.jsxs(s.Stack,{ref:a,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:o("viz.merico_linear_gauge.sections.label")}),n.jsx(yw,{value:e,onChange:t})]}),n.jsx(rn.DragDropProvider,{onDragEnd:u,children:l.map((g,b)=>n.jsx(hw,{row:g,handleChange:d(b),handleRemove:()=>c(b),index:b,additional_options:p},g.id))}),n.jsx(gw,{append:i})]})});function _w({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),{t:a}=m.useTranslation(),o=e.data,l=h.useMemo(()=>y.defaultsDeep({},t,Yr()),[t]),i=v.useForm({defaultValues:l}),{handleSubmit:c,formState:d,reset:u}=i;h.useEffect(()=>{i.reset(l)},[l]);const p=h.useMemo(()=>[{label:a("viz.merico_linear_gauge.order.asc"),value:"asc"},{label:a("viz.merico_linear_gauge.order.desc"),value:"desc"}],[a]);return n.jsxs("form",{onSubmit:c(r),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{gap:"lg",pt:"xs",px:"xs",children:[n.jsx(v.Controller,{name:"stats.top",control:i.control,render:({field:g})=>n.jsx(gt,{initialValue:g.value,onChange:g.onChange,label:a("chart.stats.template.above_chart")},"stats.top")}),n.jsx(s.Divider,{}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"value",control:i.control,render:({field:g})=>n.jsx(L,{label:a("viz.merico_linear_gauge.value"),size:"xs",...g,clearable:!0})}),n.jsx(v.Controller,{name:"order",control:i.control,render:({field:g})=>n.jsx(s.Select,{label:a("viz.merico_linear_gauge.order.label"),size:"xs",data:p,...g,clearable:!0})})]}),n.jsx(v.Controller,{name:"sections",control:i.control,render:({field:g})=>n.jsx(vw,{...g,data:o})}),n.jsx(s.Divider,{}),n.jsx(v.Controller,{name:"format",control:i.control,render:({field:g})=>n.jsx(Ne,{size:"xs",...g})})]})]})}const mw={displayName:"viz.merico_linear_gauge.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new lw,name:"merico_linear_gauge",viewRender:uw,configRender:_w,createConfig:()=>({version:2,config:Yr()}),translation:pw},Xr={styles:{justify:"space-around",align:"start"},metrics:[]};function ww(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:de,postfix:{type:"text",value:""}}}const pl=({postfix:e})=>e?n.jsxs(n.Fragment,{children:[n.jsx(s.Text,{size:"12px",c:"#818388",sx:{lineHeight:1},children:"/"}),n.jsx(s.Text,{size:"12px",c:"#818388",sx:{lineHeight:1},children:e})]}):null,xw=k.observer(({metric:e,variableValueMap:t})=>{const{names:r,data_keys:a,formatter:o,postfix:l}=e,i=H(),c=h.useMemo(()=>{if(l.type==="text"&&l.value)return l.value;if(l.type==="filter-option-label"&&l.value){const d=i.filters.getSelectOption(l.value);return d?d.label:null}return null},[l,i]);return n.jsxs(s.Stack,{gap:18,children:[n.jsxs(s.Stack,{gap:12,children:[n.jsx(s.Text,{size:"14px",c:"#818388",children:r.value}),n.jsxs(s.Group,{gap:"2px",align:"baseline",children:[n.jsx(s.Text,{size:"24px",fw:"bold",c:"#3D3E45",sx:{lineHeight:1},children:Y(t[a.value],o)}),n.jsx(pl,{postfix:c})]})]}),n.jsxs(s.Stack,{gap:12,children:[n.jsx(s.Text,{size:"14px",c:"#818388",children:r.basis}),n.jsxs(s.Group,{gap:"2px",align:"baseline",children:[n.jsx(s.Text,{size:"12px",c:"#3D3E45",sx:{lineHeight:1},children:Y(t[a.basis],o)}),n.jsx(pl,{postfix:c})]})]})]})}),Cw=k.observer(({context:e,instance:t})=>{const{value:r}=q(e.instanceData,"config"),{variables:a}=e,o=h.useMemo(()=>y.defaults({},r,Xr),[r]),l=e.data,i=h.useMemo(()=>Or(l,a),[a,l]),{width:c,height:d}=e.viewport;return!c||!d||!o?null:n.jsx(s.Flex,{w:`${c}px`,h:`${d}px`,justify:o.styles.justify,align:o.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:o.metrics.map(u=>n.jsx(xw,{metric:u,variableValueMap:i},u.id))})}),Sw=k.observer(h.forwardRef(({value:e,onChange:t},r)=>{const{t:a,i18n:o}=m.useTranslation(),i=F().filters.selects,c=p=>{if(!p)return;t({type:p,value:e.value})},d=p=>{if(p===null)return p;t({type:e.type,value:p})},u=h.useMemo(()=>[{label:a("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:a("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[o.language]);return n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{label:a("viz.merico_stats.metric.postfix_type.label"),data:u,value:e.type,onChange:c}),e.type==="text"&&n.jsx(s.TextInput,{label:a("viz.merico_stats.metric.postfix_content"),value:e.value,onChange:p=>{d(p.currentTarget.value)}}),e.type==="filter-option-label"&&n.jsx(s.Select,{label:a("viz.merico_stats.metric.postfix_filter"),value:e.value,onChange:d,data:i})]})}));function Tw({control:e,index:t,watch:r,variableOptions:a}){const{t:o}=m.useTranslation();return r(`metrics.${t}.postfix`),n.jsxs(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.names.value`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`metrics.${t}.data_keys.value`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("viz.merico_stats.metric.metric_data_field"),required:!0,data:a,sx:{flex:1},...l})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`metrics.${t}.names.basis`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:o("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...l})}),n.jsx(v.Controller,{name:`metrics.${t}.data_keys.basis`,control:e,render:({field:l})=>n.jsx(s.Select,{label:o("viz.merico_stats.metric.basis_data_field"),required:!0,data:a,sx:{flex:1},...l})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("numbro.format.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:`metrics.${t}.formatter`,control:e,render:({field:l})=>n.jsx(Ne,{...l})}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:o("viz.merico_stats.metric.others"),labelPosition:"center"}),n.jsx(v.Controller,{name:`metrics.${t}.postfix`,control:e,render:({field:l})=>n.jsx(Sw,{...l})})]})}const kw=({control:e,watch:t,variables:r})=>{const{t:a}=m.useTranslation(),o=()=>ww(),l=(d,u)=>{const p=d.names.value.trim();return p||u+1},i=({field:d,index:u,fields:p})=>p.length<=1,c=h.useMemo(()=>r.map(d=>({label:d.name,value:d.name})),[r]);return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:15,variant:"dashed",label:a("viz.merico_stats.metric.labels"),labelPosition:"center"}),n.jsx(R,{control:e,watch:t,name:"metrics",getItem:o,addButtonText:a("chart.tooltip.additional_metrics.add"),deleteButtonText:a("chart.tooltip.additional_metrics.delete"),renderTabName:l,deleteDisalbed:i,children:({field:d,index:u})=>n.jsx(Tw,{control:e,index:u,variableOptions:c,watch:t})})]})};function Dw({control:e,watch:t}){const{t:r}=m.useTranslation();return t("styles"),n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:15,variant:"dashed",label:r("style.label"),labelPosition:"center"}),n.jsxs(s.Group,{children:[n.jsx(v.Controller,{name:"styles.justify",control:e,render:({field:a})=>n.jsx(sf,{sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"styles.align",control:e,render:({field:a})=>n.jsx(of,{label:r("viz.merico_stats.align_items.label"),sx:{flex:1},...a})})]})]})}function zw({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),{variables:a}=e,o=h.useMemo(()=>y.defaultsDeep({},t,Xr),[t]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),n.jsx("form",{onSubmit:i(r),children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsx(Dw,{control:l,watch:c}),n.jsx(kw,{control:l,watch:c,variables:a})]})})}function Mw(e){const{metrics:t,...r}=e;return{...r,metrics:t.map(a=>({...a,postfix:a.postfix??{type:"text",value:""}}))}}const Iw=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class Vw extends J{constructor(){super(...arguments);V(this,"VERSION",2)}configVersions(){this.version(1,r=>({...r,version:1,config:r.config})),this.version(2,r=>({...r,version:2,config:Mw(r.config)}))}}const Pw={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Vw,name:"merico-stats",viewRender:Cw,configRender:zw,createConfig:()=>({version:2,config:Xr}),translation:Iw},$w=[{lang:"en",resources:{pareto_chart:{viz_name:"Pareto Chart",line_80_20:{label:"80-20 Line",label_template:"Label Template",click_to_see_params:"Click to see params for Label Template",param_section_note_1:"80-20 line stuff",param_section_note_2:"chart configs"},click_series:{label:"Click chart series"}}}},{lang:"zh",resources:{pareto_chart:{viz_name:"帕累托图",line_80_20:{label:"80/20线",label_template:"线上文案模板",click_to_see_params:"点击查看线上文案模板的参数",param_section_note_1:"80-20线相关",param_section_note_2:"图表配置信息"},click_series:{label:"点击柱或线"}}}}],hl={id:"builtin:echarts:click-echart:series",displayName:"viz.pareto_chart.click_series.label",nameRender:Ew,configRender:Aw,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'line' | 'bar'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Aw(e){return n.jsx(n.Fragment,{})}function Ew(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.pareto_chart.click_series.label")})}const gl={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},Zr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},data_key:"value",bar:{name:"Value",nameAlignment:"left",color:"#228be6",label_formatter:de,unit:K()},line:{name:"Value",nameAlignment:"right",color:"red"},dataZoom:kt,markLine:gl,reference_lines:[]};function Tn(e){return Y(e,{output:"percent",mantissa:0,absolute:!1})}function Bw(e){const t=e.value[1];try{return Tn(t)}catch(r){return console.error(r),t}}function qw(e){function t(r){let a=r;if(typeof r=="object"&&(Array.isArray(r.value)&&r.value.length===2?a=r.value[1]:a=r.value),!e.bar.label_formatter)return a;try{return Y(a,e.bar.label_formatter)}catch(o){return console.error(o),a}}return{bar:t,line:Bw,lineValue:Tn}}function Ow(e,t,r){const{label_template:a}=e.markLine;if(!a)return"";const o={...e,percentage:t,count:r},l=Object.keys(o),i=Object.values(o);return new Function(...l,`return \`${a}\`;`)(...i)}function Lw(e){const t=Number(Ee(e).format({output:"number",mantissa:2}));return t<.33?"left":t>.66?"right":"center"}function Nw(e,t){if(t.length===0)return{};const r=t.findIndex(d=>d[1]>=.8);if(r===-1)return{};const a=t[r],o=(r+1)/t.length,l={x:Tn(o),y:Tn(a[1])},i={left:r+1,right:t.length-r-1},c=a[0];return c?{markLine:{name:"",silent:!0,symbol:"triangle",symbolRotate:180,symbolSize:[10,8],data:[{name:"",symbol:"none",xAxis:c,lineStyle:{color:e.markLine.color},label:{formatter:Ow(e,l,i),position:"end",align:Lw(o)}}]},markArea:{name:"",silent:!0,itemStyle:{color:"rgba(47, 140, 192, 0.05)"},data:[[{coord:["min",0]},{xAxis:c}]]}}:{}}function Gw(e,t,r){const a=t.reduce((c,d)=>c+d[1],0),o=t.reduce((c,d,u)=>{const p=u===0?0:c[u-1][1];return c.push([d[0],p+d[1]]),c},[]).map(c=>[c[0],c[1]/a]),{markLine:l,markArea:i}=Nw(e,o);return[{name:e.bar.name,type:"bar",barMaxWidth:20,itemStyle:{color:e.bar.color},label:{show:!1,position:"top",formatter:r.bar},yAxisIndex:0,data:t},{name:e.line.name,type:"line",itemStyle:{color:e.line.color},symbolSize:2,lineStyle:{width:1,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:1},label:{show:!1,position:"top",formatter:r.line},yAxisIndex:1,data:o,markLine:l,markArea:i}]}function Fw(e){const t=e.bar.unit;return t.show_in_tooltip?t.text:""}const Qw=(e,t)=>r=>{const a=Array.isArray(r)?r:[r];if(a.length===0)return"";const o=Fw(e),l=a.map(d=>{const{seriesName:u,componentSubType:p}=d,[g,b]=d.value;return u?p==="bar"?`
|
|
339
339
|
<tr>
|
|
340
340
|
<th style="text-align: right; padding: 0 1em;">${u}</th>
|
|
341
341
|
<td style="text-align: left; padding: 0 2px 0 1em;">${t.bar(b)}</td>
|
|
@@ -355,7 +355,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
355
355
|
${l.join("")}
|
|
356
356
|
</tbody>
|
|
357
357
|
</table>
|
|
358
|
-
`};function jw(e,t){return X.getTooltip({trigger:"axis",formatter:Qw(e,t)})}function Ww(e,t){const{name:r,axisLabel:a}=e.x_axis,o=Ke(a.overflow.on_axis);return[X.getXAxis({type:"category",id:"main-x-axis",name:r,nameLocation:"middle",nameGap:30,nameTextStyle:{align:"right"},axisLabel:{...a,...o,formatter:Me(a.formatter)},data:t})]}function Uw(e,t){return[X.getYAxis({name:e.bar.name,nameGap:20,minInterval:1,nameTextStyle:{align:e.bar.nameAlignment},position:"left",axisLabel:{show:!0,formatter:t.bar},splitLine:{show:!1}}),X.getYAxis({name:e.line.name,nameGap:20,nameTextStyle:{align:e.line.nameAlignment},position:"right",axisLabel:{show:!0,formatter:t.lineValue}})]}function Kw(e,t){return t?[e]:[]}function Yw(e,t,r,a){return e.map(o=>{const l=r[o.variable_key],i=o.orientation==="horizontal",c=i?"yAxis":"xAxis",d=i?"insideEndTop":"end",u=Kw(l,i);return{name:o.name,type:"scatter",hide_in_legend:!o.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:o.yAxisIndex,data:u,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:o.name,[c]:l}],silent:!0,symbol:["none","none"],lineStyle:o.lineStyle,label:{formatter:function(){return o.template?Kt(o.template,t,a):""},position:d}}}})}const fl=()=>({top:50,left:30,right:15,bottom:5,containLabel:!0});function Xw(e,t,r){const a=
|
|
358
|
+
`};function jw(e,t){return X.getTooltip({trigger:"axis",formatter:Qw(e,t)})}function Ww(e,t){const{name:r,axisLabel:a}=e.x_axis,o=Ke(a.overflow.on_axis);return[X.getXAxis({type:"category",id:"main-x-axis",name:r,nameLocation:"middle",nameGap:30,nameTextStyle:{align:"right"},axisLabel:{...a,...o,formatter:Me(a.formatter)},data:t})]}function Uw(e,t){return[X.getYAxis({name:e.bar.name,nameGap:20,minInterval:1,nameTextStyle:{align:e.bar.nameAlignment},position:"left",axisLabel:{show:!0,formatter:t.bar},splitLine:{show:!1}}),X.getYAxis({name:e.line.name,nameGap:20,nameTextStyle:{align:e.line.nameAlignment},position:"right",axisLabel:{show:!0,formatter:t.lineValue}})]}function Kw(e,t){return t?[e]:[]}function Yw(e,t,r,a){return e.map(o=>{const l=r[o.variable_key],i=o.orientation==="horizontal",c=i?"yAxis":"xAxis",d=i?"insideEndTop":"end",u=Kw(l,i);return{name:o.name,type:"scatter",hide_in_legend:!o.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:o.yAxisIndex,data:u,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:o.name,[c]:l}],silent:!0,symbol:["none","none"],lineStyle:o.lineStyle,label:{formatter:function(){return o.template?Kt(o.template,t,a):""},position:d}}}})}const fl=()=>({top:50,left:30,right:15,bottom:5,containLabel:!0});function Xw(e,t,r){const a=Or(t,r),o=qw(e),{x_axis:l,data_key:i}=e;if(!l.data_key||!i)return{series:[],grid:fl()};const c=$(l.data_key),d=$(i);if(c.queryID!==d.queryID)throw new Error("Please use the same query for X & Y axis");const u=t[c.queryID].map(b=>[b[c.columnKey],Number(b[d.columnKey])]).sort((b,_)=>_[1]-b[1]),p=u.map(b=>b[0]);return{dataZoom:_n(e.dataZoom),tooltip:jw(e,o),xAxis:Ww(e,p),yAxis:Uw(e,o),series:[...Gw(e,u,o),...Yw(e.reference_lines,r,a,t)],grid:fl()}}function Zw({context:e,instance:t}){const{variables:r}=e,{value:a}=q(e.instanceData,"config"),o=e.data,{width:l,height:i}=e.viewport,c=y.defaults({},a,Zr),d=Xw(c,o,r),u=Pe({vizManager:e.vizManager,instance:t}),p=Ve(u.triggerManager,hl.id),g=Dt(o,c.x_axis.data_key),b=h.useCallback(S=>{const D=y.get(g,S.name,{error:"rowData is not found"});p.forEach(z=>{u.runInteraction(z.id,{...S,rowData:D})})},[g,p,u]),_=h.useRef(null),w=h.useCallback(()=>{var D;const S=(D=_.current)==null?void 0:D.getEchartsInstance();S&&fe(t,S.getOption())},[t]),x=h.useMemo(()=>({click:b,finished:w}),[b,w]);return!c||!l||!i?null:n.jsx(ve,{width:l,height:i,children:n.jsx(he,{echarts:ce,option:d,ref:_,style:Yt(l,i),onEvents:x,notMerge:!0,theme:"merico-light"})})}function Jw({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["bar"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"bar.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"bar.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"bar.color",control:e,render:({field:a})=>n.jsx(ye,{label:r("chart.color.label"),...a})})}),n.jsx(v.Controller,{name:"bar.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.label.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:"bar.label_formatter",control:e,render:({field:a})=>n.jsx(Ne,{...a})})]})]})}function Hw({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["line"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"line.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"line.nameAlignment",control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"line.color",control:e,render:({field:a})=>n.jsx(ye,{label:r("chart.color.label"),...a})})})]})}const Rw=(e,t)=>`
|
|
359
359
|
{
|
|
360
360
|
// ${e}
|
|
361
361
|
percentage: {
|
|
@@ -378,7 +378,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
378
378
|
name: string;
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
|
-
`,ex=()=>{const{t:e,i18n:t}=m.useTranslation(),[r,a]=h.useState(!1),o=h.useMemo(()=>Rw(e("viz.pareto_chart.line_80_20.param_section_note_1"),e("viz.pareto_chart.line_80_20.param_section_note_2")),[t.language]);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>a(l=>!l),children:e(r?"common.actions.close":"viz.pareto_chart.line_80_20.click_to_see_params")}),n.jsx(s.Collapse,{in:r,children:n.jsx(Qe.CodeHighlight,{language:"typescript",withCopyButton:!1,code:o})})]})};function tx({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["markLine"]),n.jsxs(s.Stack,{children:[n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"markLine.color",control:e,render:({field:a})=>n.jsx(ye,{label:r("chart.color.label"),...a})})}),n.jsxs(s.Stack,{gap:4,children:[n.jsx(v.Controller,{name:"markLine.label_template",control:e,render:({field:a})=>n.jsx(s.Textarea,{autosize:!0,minRows:2,maxRows:4,label:r("viz.pareto_chart.line_80_20.label_template"),sx:{flex:1},...a})}),n.jsx(ex,{})]})]})}function nx({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{label:l("chart.orientation.label"),sx:{flex:1},...c})})}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:l("chart.y_axis.label"),data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})})]})}function rx({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),l=(u,p)=>{const g=u.name.trim();return g||p+1},i=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),c=t(["bar.name","line.name"]),d=h.useMemo(()=>c.map((u,p)=>({label:u,value:p.toString()})),[c]);return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:l,children:({field:u,index:p})=>n.jsx(nx,{control:e,index:p,watch:t,variableOptions:i,yAxisOptions:d})})}function ax({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}function sx({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["data_key"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...a})})})}function ox({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},r,Xr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["x_axis","data_key","bar","line","dataZoom"]),n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Bar",children:t("chart.series.bar.label")}),n.jsx(s.Tabs.Tab,{value:"Line",children:t("chart.series.line.label")}),n.jsx(s.Tabs.Tab,{value:"80-20 Line",children:t("viz.pareto_chart.line_80_20.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(ax,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(sx,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Bar",children:n.jsx(Jw,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Line",children:n.jsx(Hw,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"80-20 Line",children:n.jsx(tx,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(rx,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})}function lx(e){const{dataZoom:t=kt,...r}=e;return{...r,dataZoom:t}}function ix(e){const{markLine:t=gl,...r}=e;return{...r,markLine:t}}function cx(e){const t=y.defaultsDeep({},e.x_axis.axisLabel,{rotate:0,formatter:_e()});return{...e,x_axis:{...e.x_axis,axisLabel:t}}}function dx(e){const{label_formatter:t=de}=e.bar;return{...e,bar:{...e.bar,label_formatter:t}}}function ux(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function px(e){const t={bar:{nameAlignment:"left"},line:{nameAlignment:"right"}};return y.defaultsDeep(t,e)}function hx(e){console.log(e);const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function gx(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{x_axis:o,data_key:l,...i}=e;return{...i,x_axis:{...o,data_key:a(o.data_key)},data_key:a(l)}}catch(r){throw console.error("[Migration failed]",r),r}}function fx(e){const t=e.bar,{unit:r=K()}=t;return{...e,bar:{...t,unit:r}}}class bx extends J{constructor(){super(...arguments);V(this,"VERSION",10)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:lx(r.config)})),this.version(3,r=>({...r,version:3,config:ix(r.config)})),this.version(4,r=>({...r,version:4,config:cx(r.config)})),this.version(5,r=>({...r,version:5,config:dx(r.config)})),this.version(6,r=>({...r,version:6,config:ux(r.config)})),this.version(7,r=>({...r,version:7,config:px(r.config)})),this.version(8,r=>({...r,version:8,config:hx(r.config)})),this.version(9,(r,a)=>({...r,version:9,config:gx(r.config,a)})),this.version(10,r=>({...r,version:10,config:fx(r.config)}))}}const yx={displayName:"viz.pareto_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new bx,name:"paretoChart",viewRender:Zw,configRender:ox,createConfig(){return{version:10,config:y.cloneDeep(Xr)}},triggers:[hl],translation:$w};function vx(e,t,r,a){const o=a[r];return o||(t?e[t]:void 0)}function _x(e){const t=je.sum(e.map(r=>r.value));return e.map(r=>{const a=je.divide(r.value,t),o=Ee(a).format({output:"percent",mantissa:2,trimMantissa:!0});return{...r,ratio:a,percentage:o}})}function mx(e,t,r){const{label:a,threshold:o}=e;if(!a||!o)return t;const l=Ee(`${o}%`).format({output:"number",mantissa:8,trimMantissa:!0}),i={name:a,value:0,ratio:0,percentage:"",items:[],color:r.next().value},c=[];return t.forEach(d=>{je.larger(d.ratio,l)?c.push(d):(i.value=je.add(i.value,d.value),i.ratio=je.add(i.ratio,d.ratio),i.percentage=Ee(i.ratio).format({output:"percent",mantissa:2,trimMantissa:!0}),i.items.push(d))}),c.push(i),c}const wx=(e,t)=>{const{label_field:r,value_field:a,series_order:o,color_field:l,color:i,others_sector:c}=e;if(!r||!a)return{source:[]};const d=$(r),u=$(a),p=$(l),g=i.map.reduce((w,x)=>{const{name:S,color:D}=x;return!S||!D||(w[S]=D),w},{}),b=ph("multiple");let _=t[d.queryID].map(w=>{const x=w[d.columnKey],S=vx(w,p.columnKey,x,g)||b.next().value;return{name:x,value:Number(w[u.columnKey]),ratio:0,percentage:"",color:S}});return o&&(_=y.orderBy(_,[o.key],[o.order])),_=_x(_),_=mx(c,_,b),{source:_}};function xx(e,t,r){return{type:"pie",name:"pie",radius:e.radius,itemStyle:{color:({data:a})=>a.color},label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
|
|
381
|
+
`,ex=()=>{const{t:e,i18n:t}=m.useTranslation(),[r,a]=h.useState(!1),o=h.useMemo(()=>Rw(e("viz.pareto_chart.line_80_20.param_section_note_1"),e("viz.pareto_chart.line_80_20.param_section_note_2")),[t.language]);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>a(l=>!l),children:e(r?"common.actions.close":"viz.pareto_chart.line_80_20.click_to_see_params")}),n.jsx(s.Collapse,{in:r,children:n.jsx(Qe.CodeHighlight,{language:"typescript",withCopyButton:!1,code:o})})]})};function tx({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["markLine"]),n.jsxs(s.Stack,{children:[n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"markLine.color",control:e,render:({field:a})=>n.jsx(ye,{label:r("chart.color.label"),...a})})}),n.jsxs(s.Stack,{gap:4,children:[n.jsx(v.Controller,{name:"markLine.label_template",control:e,render:({field:a})=>n.jsx(s.Textarea,{autosize:!0,minRows:2,maxRows:4,label:r("viz.pareto_chart.line_80_20.label_template"),sx:{flex:1},...a})}),n.jsx(ex,{})]})]})}function nx({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{label:l("chart.orientation.label"),sx:{flex:1},...c})})}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:l("chart.y_axis.label"),data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})})]})}function rx({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),l=(u,p)=>{const g=u.name.trim();return g||p+1},i=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),c=t(["bar.name","line.name"]),d=h.useMemo(()=>c.map((u,p)=>({label:u,value:p.toString()})),[c]);return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:l,children:({field:u,index:p})=>n.jsx(nx,{control:e,index:p,watch:t,variableOptions:i,yAxisOptions:d})})}function ax({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}function sx({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["data_key"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...a})})})}function ox({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},r,Zr),[r]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["x_axis","data_key","bar","line","dataZoom"]),n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Bar",children:t("chart.series.bar.label")}),n.jsx(s.Tabs.Tab,{value:"Line",children:t("chart.series.line.label")}),n.jsx(s.Tabs.Tab,{value:"80-20 Line",children:t("viz.pareto_chart.line_80_20.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(ax,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axis",children:n.jsx(sx,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Bar",children:n.jsx(Jw,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Line",children:n.jsx(Hw,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"80-20 Line",children:n.jsx(tx,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(rx,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})}function lx(e){const{dataZoom:t=kt,...r}=e;return{...r,dataZoom:t}}function ix(e){const{markLine:t=gl,...r}=e;return{...r,markLine:t}}function cx(e){const t=y.defaultsDeep({},e.x_axis.axisLabel,{rotate:0,formatter:_e()});return{...e,x_axis:{...e.x_axis,axisLabel:t}}}function dx(e){const{label_formatter:t=de}=e.bar;return{...e,bar:{...e.bar,label_formatter:t}}}function ux(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return y.defaultsDeep(t,e)}function px(e){const t={bar:{nameAlignment:"left"},line:{nameAlignment:"right"}};return y.defaultsDeep(t,e)}function hx(e){console.log(e);const{x_axis:t,tooltip:r}=e.x_axis.axisLabel.overflow,a={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:r}}}};return y.defaultsDeep(a,e)}function gx(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{x_axis:o,data_key:l,...i}=e;return{...i,x_axis:{...o,data_key:a(o.data_key)},data_key:a(l)}}catch(r){throw console.error("[Migration failed]",r),r}}function fx(e){const t=e.bar,{unit:r=K()}=t;return{...e,bar:{...t,unit:r}}}class bx extends J{constructor(){super(...arguments);V(this,"VERSION",10)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:lx(r.config)})),this.version(3,r=>({...r,version:3,config:ix(r.config)})),this.version(4,r=>({...r,version:4,config:cx(r.config)})),this.version(5,r=>({...r,version:5,config:dx(r.config)})),this.version(6,r=>({...r,version:6,config:ux(r.config)})),this.version(7,r=>({...r,version:7,config:px(r.config)})),this.version(8,r=>({...r,version:8,config:hx(r.config)})),this.version(9,(r,a)=>({...r,version:9,config:gx(r.config,a)})),this.version(10,r=>({...r,version:10,config:fx(r.config)}))}}const yx={displayName:"viz.pareto_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new bx,name:"paretoChart",viewRender:Zw,configRender:ox,createConfig(){return{version:10,config:y.cloneDeep(Zr)}},triggers:[hl],translation:$w};function vx(e,t,r,a){const o=a[r];return o||(t?e[t]:void 0)}function _x(e){const t=je.sum(e.map(r=>r.value));return e.map(r=>{const a=je.divide(r.value,t),o=Ee(a).format({output:"percent",mantissa:2,trimMantissa:!0});return{...r,ratio:a,percentage:o}})}function mx(e,t,r){const{label:a,threshold:o}=e;if(!a||!o)return t;const l=Ee(`${o}%`).format({output:"number",mantissa:8,trimMantissa:!0}),i={name:a,value:0,ratio:0,percentage:"",items:[],color:r.next().value},c=[];return t.forEach(d=>{je.larger(d.ratio,l)?c.push(d):(i.value=je.add(i.value,d.value),i.ratio=je.add(i.ratio,d.ratio),i.percentage=Ee(i.ratio).format({output:"percent",mantissa:2,trimMantissa:!0}),i.items.push(d))}),c.push(i),c}const wx=(e,t)=>{const{label_field:r,value_field:a,series_order:o,color_field:l,color:i,others_sector:c}=e;if(!r||!a)return{source:[]};const d=$(r),u=$(a),p=$(l),g=i.map.reduce((w,x)=>{const{name:S,color:D}=x;return!S||!D||(w[S]=D),w},{}),b=ph("multiple");let _=t[d.queryID].map(w=>{const x=w[d.columnKey],S=vx(w,p.columnKey,x,g)||b.next().value;return{name:x,value:Number(w[u.columnKey]),ratio:0,percentage:"",color:S}});return o&&(_=y.orderBy(_,[o.key],[o.order])),_=_x(_),_=mx(c,_,b),{source:_}};function xx(e,t,r){return{type:"pie",name:"pie",radius:e.radius,itemStyle:{color:({data:a})=>a.color},label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
|
|
382
382
|
{p|{@percentage}}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{p:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},labelLayout:function(a){const o=a.labelRect.x<r/2,l=a.labelLinePoints;return y.set(l,[2,0],o?a.labelRect.x:a.labelRect.x+a.labelRect.width),{labelLinePoints:l}},top:10,bottom:10,left:10,right:10}}function Cx(e,t){const{name:r,color:a}=t,l=t.data.items.map(c=>`
|
|
383
383
|
<tr>
|
|
384
384
|
<th style="text-align: right; padding: 0 1em;">${c.name}</th>
|
|
@@ -423,7 +423,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
423
423
|
</tr>
|
|
424
424
|
</tbody>
|
|
425
425
|
</table>
|
|
426
|
-
`}}function Tx(e){const t=e.unit.show_in_tooltip?e.unit.text:"";return X.getTooltip({trigger:"item",formatter:Sx(t)})}function kx(e,t,r){return{dataset:wx(e,t),tooltip:Tx(e),series:xx(e,t,r)}}const bl={id:"builtin:echarts:click-pie-chart:series",displayName:"viz.pie_chart.click_series.label",nameRender:zx,configRender:Dx,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Value of the series clicked",valueType:"number"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Dx(e){return n.jsx(n.Fragment,{})}function zx(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.pie_chart.click_series.label")})}const yl=()=>({label:null,threshold:null}),vl={label_field:"",value_field:"",color_field:"",radius:["50%","80%"],color:{map:[]},unit:K(),series_order:xn(),others_sector:yl()};function Mx({conf:e,data:t,width:r,height:a,interactionManager:o,instance:l}){const i=Dt(t,e.label_field),c=Ve(o.triggerManager,bl.id),d=h.useCallback(_=>{const w=y.get(i,_.name,{error:"rowData is not found"});c.forEach(x=>{o.runInteraction(x.id,{..._,rowData:w})})},[i,c,o]),u=h.useRef(null),p=h.useCallback(()=>{var w;const _=(w=u.current)==null?void 0:w.getEchartsInstance();_&&fe(l,_.getOption())},[l]),g=h.useMemo(()=>kx(e,t,r),[e,t,r]),b=h.useMemo(()=>({click:d,finished:p}),[d,p]);return!r||!a||!g.series.name?null:n.jsx(he,{echarts:ce,option:g,ref:u,style:{width:r,height:a},onEvents:b,notMerge:!0,theme:"merico-light"})}function Ix({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaults({},a,vl),[a]),l=e.data,{width:i,height:c}=e.viewport;return!i||!c||!o.label_field||!o.value_field?null:n.jsx(ve,{width:i,height:c,children:n.jsx(Mx,{instance:t,conf:o,width:qe(i),height:Oe(c),data:l,interactionManager:r})})}function Vx(e){const[t,r]=e;return[Number(t.replace("%","")),Number(r.replace("%",""))]}function Px(e){const[t,r]=e;return[Number.isFinite(t)?`${t}%`:"",Number.isFinite(r)?`${r}%`:""]}const $x=h.forwardRef(({label:e,value:t,onChange:r},a)=>{const[o,l]=h.useState(Vx(t)),i=h.useCallback(c=>{r(Px(c))},[r]);return n.jsxs(s.Stack,{gap:4,mt:2,mb:"1rem",children:[n.jsx("label",{className:"form-field-label required",children:e}),n.jsx(s.RangeSlider,{value:o,onChange:l,onChangeEnd:i,label:c=>`${c}%`})]})}),Ax=({row:e,index:t,handleChange:r,handleRemove:a,names:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),[d,{setTrue:u,setFalse:p}]=O.useBoolean(!1),{ref:g,handleRef:b}=an.useSortable({id:e.id,index:t}),_=x=>{r({...e,name:x})},w=x=>{r({...e,color:x})};return n.jsxs(s.Flex,{ref:g,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:u,onMouseLeave:p,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:d?n.jsx(s.ActionIcon,{size:"xs",ref:b,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.Autocomplete,{size:"xs",value:e.name,placeholder:l("viz.pie_chart.color.map.name"),onChange:_,onClick:c,error:i&&!e.name,data:o,maxDropdownHeight:500}),n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.color,onChange:w,onClick:c,error:i&&!e.color})]}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},Ex=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",color:""})};return n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.pie_chart.color.map.add_a_row")})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})},Bx=Object.entries(y.pick(Ue.graphics,["compared","level","depth","multiple"])).map(([e,t])=>({name:e,colors:Object.values(t)}));function qx(e){const t=e.length;if(t===0)return"";const r={output:"percent",mantissa:4,trimMantissa:!0},a=y.divide(1,t),o=[];return e.forEach((i,c)=>{o.push(`${i} ${Ee(c*a).format(r)}`),o.push(`${i} ${Ee((c+1)*a).format(r)}`)}),`linear-gradient(90deg, ${o.join(",")})`}const Ox=({value:e,onChange:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=l=>{const i=e.map((c,d)=>({name:c.name,color:l[d]}));for(let c=i.length-1;c<l.length;c++)i.push({name:"",color:l[c]});t(i)};return n.jsxs(s.Menu,{withArrow:!0,shadow:"md",width:400,styles:{item:{overflowX:"hidden"}},children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",rightSection:n.jsx(s.Combobox.Chevron,{size:"xs"}),children:r("viz.pie_chart.color.map.use_a_palette")})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:r("viz.pie_chart.color.map.click_to_apply_palette")}),n.jsx(s.Menu.Divider,{}),Bx.map(l=>n.jsx(s.Menu.Item,{onClick:()=>o(l.colors),children:n.jsx(s.Box,{h:28,style:{backgroundImage:qx(l.colors)}})},l.name))]})]})},Lx=h.forwardRef(({value:e,onChange:t,zIndex:r=340,names:a},o)=>{const{t:l}=m.useTranslation(),i=h.useMemo(()=>e.map(g=>({id:Te.v4(),...g})),[e]),c=g=>{t([...e,g])},d=g=>{const b=[...e];b.splice(g,1),t(b)},u=g=>b=>{const _=[...e];_[g]=b,t(_)},p=g=>{const{source:b,target:_}=g.operation,w=Un.move(i,b,_);t(w.map(x=>y.omit(x,"id")))};return n.jsxs(s.Stack,{ref:o,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:l("viz.pie_chart.color.map.label")}),n.jsx(Ox,{value:e,onChange:t})]}),n.jsx(rn.DragDropProvider,{onDragEnd:p,children:i.map((g,b)=>n.jsx(Ax,{row:g,handleChange:u(b),handleRemove:()=>d(b),index:b,names:a},g.id))}),n.jsx(Ex,{append:c})]})});function Nx({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),o=h.useMemo(()=>y.defaults({},e),[e]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});h.useEffect(()=>{u(o)},[o]);const[p]=c(["label_field","value_field","color_field","color"]),{panel:g}=ae(),b=h.useMemo(()=>{if(!p)return[];const _=me(g.data,p);return y.uniq(_)},[p,g.data]);return n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:i(t),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{mt:"md",gap:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{control:l,name:"label_field",render:({field:_})=>n.jsx(L,{label:a("common.name_data_field"),required:!0,..._})}),n.jsx(v.Controller,{control:l,name:"value_field",render:({field:_})=>n.jsx(L,{label:a("common.value_data_field"),required:!0,..._})})]}),n.jsx(v.Controller,{name:"unit",control:l,render:({field:_})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],..._})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(v.Controller,{control:l,name:"series_order",render:({field:_})=>n.jsx(el,{label:a("chart.series_order.label"),..._})}),n.jsx(v.Controller,{control:l,name:"radius",render:({field:_})=>n.jsx($x,{label:a("viz.pie_chart.radius.label"),..._})}),n.jsx(s.Divider,{label:a("viz.pie_chart.others_sector.title"),labelPosition:"center",variant:"dashed"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{control:l,name:"others_sector.label",render:({field:_})=>n.jsx(s.TextInput,{size:"xs",label:a("viz.pie_chart.others_sector.label"),..._,value:_.value??""})}),n.jsx(v.Controller,{control:l,name:"others_sector.threshold",render:({field:_})=>n.jsx(s.NumberInput,{size:"xs",label:a("viz.pie_chart.others_sector.threshold"),suffix:"%",..._,value:_.value??""})})]}),n.jsx(s.Divider,{label:a("chart.color.label"),labelPosition:"center",variant:"dashed"}),n.jsx(v.Controller,{control:l,name:"color_field",render:({field:_})=>n.jsx(L,{label:a("common.color_data_field"),clearable:!0,..._})}),n.jsx(v.Controller,{control:l,name:"color.map",render:({field:_})=>n.jsx(Lx,{names:b,..._})})]})]})})}function Gx(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(Nx,{conf:t,setConf:r,...e}):null}const Fx=[{lang:"en",resources:{pie_chart:{viz_name:"Pie Chart",click_series:{label:"Click pie series"},radius:{label:"Radius",inner:"Inner",outer:"Outer"},color:{map:{label:"Color Map",name:"Record name",add_a_row:"Add a mapping rule",use_a_palette:"Use a palette",click_to_apply_palette:"Click to apply palette"}},others_sector:{title:"Sector for small values",label:"Sector name",threshold:"Threshold"}}}},{lang:"zh",resources:{pie_chart:{viz_name:"饼图",click_series:{label:"点击饼瓣"},radius:{label:"内外半径",inner:"内",outer:"外"},color:{map:{label:"颜色映射表",name:"数据名称",add_a_row:"增加一条映射规则",use_a_palette:"使用预设配色方案",click_to_apply_palette:"点击应用配色方案"}},others_sector:{title:"合并小值为一个扇区",label:"扇区名称",threshold:"阈值"}}}}];function Qx(e){const{color_field:t="",...r}=e;return{...r,color_field:t}}function jx(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{label_field:o,value_field:l,color_field:i}=e;return{label_field:a(o),value_field:a(l),color_field:a(i)}}catch(r){throw console.error("[Migration failed]",r),r}}function Wx(e){const{radius:t=["50%","80%"],...r}=e;return{...r,radius:t}}function Ux(e){const{color:t={map:[]},...r}=e;return{...r,color:{...t,map:t.map??[]}}}function Kx(e){const{series_order:t=xn(),...r}=e;return{...r,series_order:t}}function Yx(e){const{others_sector:t=yl(),...r}=e;return{...r,others_sector:t}}function Xx(e){const{unit:t}=e;return{...e,unit:t??K()}}class Zx extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:Qx(r.config)})),this.version(3,(r,a)=>({...r,version:3,config:jx(r.config,a)})),this.version(4,r=>({...r,version:4,config:Wx(r.config)})),this.version(5,r=>({...r,version:5,config:Ux(r.config)})),this.version(6,r=>({...r,version:6,config:Kx(r.config)})),this.version(7,r=>({...r,version:7,config:Yx(r.config)})),this.version(8,r=>({...r,version:8,config:Xx(r.config)}))}}const Jx={displayName:"viz.pie_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Zx,name:"pie",viewRender:Ix,configRender:Gx,createConfig(){return{version:8,config:y.cloneDeep(vl)}},triggers:[bl],translation:Fx};function Hx(e){return n.jsx(n.Fragment,{})}function Rx(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.radar_chart.click_series.label")})}const _l={id:"builtin:echarts:click-radar-chart:series",displayName:"viz.radar_chart.click_series.label",nameRender:Rx,configRender:Hx,payload:[{name:"seriesType",description:"'radar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},kn={series_name_key:"",additional_series:[],background:{enabled:!0},label:{enabled:!0},dimensions:[]};function ml(e){return e?t=>{try{return Y(t,e)}catch(r){return console.error(r),t}}:t=>t}function wl(e){return{show:e.label.enabled,formatter:({dimensionIndex:t,value:r})=>ml(e.dimensions[t].formatter)(r)}}function xl(e,t){return t.map(({data_key:r})=>{const a=$(r);return e[a.columnKey]})}function e0(e,t,r){const a=$(t);return e[a.queryID].map(o=>({value:xl(o,r),name:o[a.columnKey]}))}function t0(e,t){const{series_name_key:r,dimensions:a}=t;return[{type:"radar",name:"main-radar",data:e0(e,r,a),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:wl(t)}]}function n0(e,t){const{additional_series:r,dimensions:a}=t;return r.map(l=>{const i=$(l.name_key),c=$(l.color_key);return{type:"radar",colorBy:"data",data:e[i.queryID].map(p=>{const g=p[i.columnKey],b=p[c.columnKey];return{name:g,value:xl(p,a),itemStyle:{color:b}}}),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:wl(t)}}).flat()}function r0(e,t){return[...t0(e,t),...n0(e,t)]}function a0(e){return({name:t,marker:r,value:a})=>{if(a.length===0)return"";const o=a.map((l,i)=>{const c=e.dimensions[i],d=ml(c.formatter);return`
|
|
426
|
+
`}}function Tx(e){const t=e.unit.show_in_tooltip?e.unit.text:"";return X.getTooltip({trigger:"item",formatter:Sx(t)})}function kx(e,t,r){return{dataset:wx(e,t),tooltip:Tx(e),series:xx(e,t,r)}}const bl={id:"builtin:echarts:click-pie-chart:series",displayName:"viz.pie_chart.click_series.label",nameRender:zx,configRender:Dx,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Value of the series clicked",valueType:"number"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Dx(e){return n.jsx(n.Fragment,{})}function zx(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.pie_chart.click_series.label")})}const yl=()=>({label:null,threshold:null}),vl={label_field:"",value_field:"",color_field:"",radius:["50%","80%"],color:{map:[]},unit:K(),series_order:xn(),others_sector:yl()};function Mx({conf:e,data:t,width:r,height:a,interactionManager:o,instance:l}){const i=Dt(t,e.label_field),c=Ve(o.triggerManager,bl.id),d=h.useCallback(_=>{const w=y.get(i,_.name,{error:"rowData is not found"});c.forEach(x=>{o.runInteraction(x.id,{..._,rowData:w})})},[i,c,o]),u=h.useRef(null),p=h.useCallback(()=>{var w;const _=(w=u.current)==null?void 0:w.getEchartsInstance();_&&fe(l,_.getOption())},[l]),g=h.useMemo(()=>kx(e,t,r),[e,t,r]),b=h.useMemo(()=>({click:d,finished:p}),[d,p]);return!r||!a||!g.series.name?null:n.jsx(he,{echarts:ce,option:g,ref:u,style:{width:r,height:a},onEvents:b,notMerge:!0,theme:"merico-light"})}function Ix({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaults({},a,vl),[a]),l=e.data,{width:i,height:c}=e.viewport;return!i||!c||!o.label_field||!o.value_field?null:n.jsx(ve,{width:i,height:c,children:n.jsx(Mx,{instance:t,conf:o,width:qe(i),height:Oe(c),data:l,interactionManager:r})})}function Vx(e){const[t,r]=e;return[Number(t.replace("%","")),Number(r.replace("%",""))]}function Px(e){const[t,r]=e;return[Number.isFinite(t)?`${t}%`:"",Number.isFinite(r)?`${r}%`:""]}const $x=h.forwardRef(({label:e,value:t,onChange:r},a)=>{const[o,l]=h.useState(Vx(t)),i=h.useCallback(c=>{r(Px(c))},[r]);return n.jsxs(s.Stack,{gap:4,mt:2,mb:"1rem",children:[n.jsx("label",{className:"form-field-label required",children:e}),n.jsx(s.RangeSlider,{value:o,onChange:l,onChangeEnd:i,label:c=>`${c}%`})]})}),Ax=({row:e,index:t,handleChange:r,handleRemove:a,names:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),[d,{setTrue:u,setFalse:p}]=O.useBoolean(!1),{ref:g,handleRef:b}=an.useSortable({id:e.id,index:t}),_=x=>{r({...e,name:x})},w=x=>{r({...e,color:x})};return n.jsxs(s.Flex,{ref:g,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:u,onMouseLeave:p,children:[n.jsx(s.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:d?n.jsx(s.ActionIcon,{size:"xs",ref:b,variant:"subtle",children:n.jsx(T.IconGripVertical,{})}):n.jsx(s.Badge,{size:"sm",variant:"light",children:t+1})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.Autocomplete,{size:"xs",value:e.name,placeholder:l("viz.pie_chart.color.map.name"),onChange:_,onClick:c,error:i&&!e.name,data:o,maxDropdownHeight:500}),n.jsx(s.ColorInput,{styles:{root:{flexGrow:1}},popoverProps:{withinPortal:!0,zIndex:340},size:"xs",value:e.color,onChange:w,onClick:c,error:i&&!e.color})]}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:n.jsx(s.CloseButton,{onClick:a,size:"sm"})})]})},Ex=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",color:""})};return n.jsxs(s.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[n.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.pie_chart.color.map.add_a_row")})}),n.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})},Bx=Object.entries(y.pick(Ue.graphics,["compared","level","depth","multiple"])).map(([e,t])=>({name:e,colors:Object.values(t)}));function qx(e){const t=e.length;if(t===0)return"";const r={output:"percent",mantissa:4,trimMantissa:!0},a=y.divide(1,t),o=[];return e.forEach((i,c)=>{o.push(`${i} ${Ee(c*a).format(r)}`),o.push(`${i} ${Ee((c+1)*a).format(r)}`)}),`linear-gradient(90deg, ${o.join(",")})`}const Ox=({value:e,onChange:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=l=>{const i=e.map((c,d)=>({name:c.name,color:l[d]}));for(let c=i.length-1;c<l.length;c++)i.push({name:"",color:l[c]});t(i)};return n.jsxs(s.Menu,{withArrow:!0,shadow:"md",width:400,styles:{item:{overflowX:"hidden"}},children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",rightSection:n.jsx(s.Combobox.Chevron,{size:"xs"}),children:r("viz.pie_chart.color.map.use_a_palette")})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Label,{children:r("viz.pie_chart.color.map.click_to_apply_palette")}),n.jsx(s.Menu.Divider,{}),Bx.map(l=>n.jsx(s.Menu.Item,{onClick:()=>o(l.colors),children:n.jsx(s.Box,{h:28,style:{backgroundImage:qx(l.colors)}})},l.name))]})]})},Lx=h.forwardRef(({value:e,onChange:t,zIndex:r=340,names:a},o)=>{const{t:l}=m.useTranslation(),i=h.useMemo(()=>e.map(g=>({id:Te.v4(),...g})),[e]),c=g=>{t([...e,g])},d=g=>{const b=[...e];b.splice(g,1),t(b)},u=g=>b=>{const _=[...e];_[g]=b,t(_)},p=g=>{const{source:b,target:_}=g.operation,w=Kn.move(i,b,_);t(w.map(x=>y.omit(x,"id")))};return n.jsxs(s.Stack,{ref:o,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:l("viz.pie_chart.color.map.label")}),n.jsx(Ox,{value:e,onChange:t})]}),n.jsx(rn.DragDropProvider,{onDragEnd:p,children:i.map((g,b)=>n.jsx(Ax,{row:g,handleChange:u(b),handleRemove:()=>d(b),index:b,names:a},g.id))}),n.jsx(Ex,{append:c})]})});function Nx({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),o=h.useMemo(()=>y.defaults({},e),[e]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});h.useEffect(()=>{u(o)},[o]);const[p]=c(["label_field","value_field","color_field","color"]),{panel:g}=ae(),b=h.useMemo(()=>{if(!p)return[];const _=me(g.data,p);return y.uniq(_)},[p,g.data]);return n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:i(t),children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsxs(s.Stack,{mt:"md",gap:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{control:l,name:"label_field",render:({field:_})=>n.jsx(L,{label:a("common.name_data_field"),required:!0,..._})}),n.jsx(v.Controller,{control:l,name:"value_field",render:({field:_})=>n.jsx(L,{label:a("common.value_data_field"),required:!0,..._})})]}),n.jsx(v.Controller,{name:"unit",control:l,render:({field:_})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],..._})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(v.Controller,{control:l,name:"series_order",render:({field:_})=>n.jsx(el,{label:a("chart.series_order.label"),..._})}),n.jsx(v.Controller,{control:l,name:"radius",render:({field:_})=>n.jsx($x,{label:a("viz.pie_chart.radius.label"),..._})}),n.jsx(s.Divider,{label:a("viz.pie_chart.others_sector.title"),labelPosition:"center",variant:"dashed"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{control:l,name:"others_sector.label",render:({field:_})=>n.jsx(s.TextInput,{size:"xs",label:a("viz.pie_chart.others_sector.label"),..._,value:_.value??""})}),n.jsx(v.Controller,{control:l,name:"others_sector.threshold",render:({field:_})=>n.jsx(s.NumberInput,{size:"xs",label:a("viz.pie_chart.others_sector.threshold"),suffix:"%",..._,value:_.value??""})})]}),n.jsx(s.Divider,{label:a("chart.color.label"),labelPosition:"center",variant:"dashed"}),n.jsx(v.Controller,{control:l,name:"color_field",render:({field:_})=>n.jsx(L,{label:a("common.color_data_field"),clearable:!0,..._})}),n.jsx(v.Controller,{control:l,name:"color.map",render:({field:_})=>n.jsx(Lx,{names:b,..._})})]})]})})}function Gx(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(Nx,{conf:t,setConf:r,...e}):null}const Fx=[{lang:"en",resources:{pie_chart:{viz_name:"Pie Chart",click_series:{label:"Click pie series"},radius:{label:"Radius",inner:"Inner",outer:"Outer"},color:{map:{label:"Color Map",name:"Record name",add_a_row:"Add a mapping rule",use_a_palette:"Use a palette",click_to_apply_palette:"Click to apply palette"}},others_sector:{title:"Sector for small values",label:"Sector name",threshold:"Threshold"}}}},{lang:"zh",resources:{pie_chart:{viz_name:"饼图",click_series:{label:"点击饼瓣"},radius:{label:"内外半径",inner:"内",outer:"外"},color:{map:{label:"颜色映射表",name:"数据名称",add_a_row:"增加一条映射规则",use_a_palette:"使用预设配色方案",click_to_apply_palette:"点击应用配色方案"}},others_sector:{title:"合并小值为一个扇区",label:"扇区名称",threshold:"阈值"}}}}];function Qx(e){const{color_field:t="",...r}=e;return{...r,color_field:t}}function jx(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{label_field:o,value_field:l,color_field:i}=e;return{label_field:a(o),value_field:a(l),color_field:a(i)}}catch(r){throw console.error("[Migration failed]",r),r}}function Wx(e){const{radius:t=["50%","80%"],...r}=e;return{...r,radius:t}}function Ux(e){const{color:t={map:[]},...r}=e;return{...r,color:{...t,map:t.map??[]}}}function Kx(e){const{series_order:t=xn(),...r}=e;return{...r,series_order:t}}function Yx(e){const{others_sector:t=yl(),...r}=e;return{...r,others_sector:t}}function Xx(e){const{unit:t}=e;return{...e,unit:t??K()}}class Zx extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:Qx(r.config)})),this.version(3,(r,a)=>({...r,version:3,config:jx(r.config,a)})),this.version(4,r=>({...r,version:4,config:Wx(r.config)})),this.version(5,r=>({...r,version:5,config:Ux(r.config)})),this.version(6,r=>({...r,version:6,config:Kx(r.config)})),this.version(7,r=>({...r,version:7,config:Yx(r.config)})),this.version(8,r=>({...r,version:8,config:Xx(r.config)}))}}const Jx={displayName:"viz.pie_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Zx,name:"pie",viewRender:Ix,configRender:Gx,createConfig(){return{version:8,config:y.cloneDeep(vl)}},triggers:[bl],translation:Fx};function Hx(e){return n.jsx(n.Fragment,{})}function Rx(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.radar_chart.click_series.label")})}const _l={id:"builtin:echarts:click-radar-chart:series",displayName:"viz.radar_chart.click_series.label",nameRender:Rx,configRender:Hx,payload:[{name:"seriesType",description:"'radar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},kn={series_name_key:"",additional_series:[],background:{enabled:!0},label:{enabled:!0},dimensions:[]};function ml(e){return e?t=>{try{return Y(t,e)}catch(r){return console.error(r),t}}:t=>t}function wl(e){return{show:e.label.enabled,formatter:({dimensionIndex:t,value:r})=>ml(e.dimensions[t].formatter)(r)}}function xl(e,t){return t.map(({data_key:r})=>{const a=$(r);return e[a.columnKey]})}function e0(e,t,r){const a=$(t);return e[a.queryID].map(o=>({value:xl(o,r),name:o[a.columnKey]}))}function t0(e,t){const{series_name_key:r,dimensions:a}=t;return[{type:"radar",name:"main-radar",data:e0(e,r,a),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:wl(t)}]}function n0(e,t){const{additional_series:r,dimensions:a}=t;return r.map(l=>{const i=$(l.name_key),c=$(l.color_key);return{type:"radar",colorBy:"data",data:e[i.queryID].map(p=>{const g=p[i.columnKey],b=p[c.columnKey];return{name:g,value:xl(p,a),itemStyle:{color:b}}}),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:wl(t)}}).flat()}function r0(e,t){return[...t0(e,t),...n0(e,t)]}function a0(e){return({name:t,marker:r,value:a})=>{if(a.length===0)return"";const o=a.map((l,i)=>{const c=e.dimensions[i],d=ml(c.formatter);return`
|
|
427
427
|
<tr>
|
|
428
428
|
<td style="padding-left: 18px;">${c.name}</td>
|
|
429
429
|
<td style="text-align: right; "><strong>${d(l)}</strong></td>
|
|
@@ -470,7 +470,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
470
470
|
</tr>
|
|
471
471
|
</tbody>
|
|
472
472
|
</table>
|
|
473
|
-
`}})}const $0={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function A0(e,t,r,a,o){if(!eo(r)||!eo(a))return[];const l=I0(e,t,r,a,o),i=D0(e,l),c={xAxis:X.getXAxis({type:"value",name:r.columnKey,nameLocation:"middle",nameGap:25}),yAxis:X.getYAxis({name:a.columnKey,nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5}),series:[...l,...i],tooltip:P0(r,a),legend:{show:!!o.columnKey&&!!o.queryID,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[8,8,0,140],data:l.map(d=>d.name)}};return y.defaultsDeep({},c,$0)}const Zr=k.observer(h.forwardRef((e,t)=>{const{value:r,onChange:a,queryID:o,clearable:l=!1,unsetKey:i="data.data_field.selector.options.unset",...c}=e,{panel:d}=ae(),u=h.useMemo(()=>d.dataFieldOptionGroups({selected:r,clearable:l,unsetKey:i,queryID:o}),[r,l,o]);if(u.length===0){const p=d.explainDataKey(r);return n.jsxs(s.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Box,{children:n.jsx(s.TextInput,{label:c.label,required:c.required,defaultValue:p.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsxs(s.Group,{justify:"flex-start",gap:0,children:[n.jsx(s.Text,{size:"xs",c:p.queryName?"black":"red",ff:"monospace",children:p.queryName??p.queryID}),n.jsx(s.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(s.Text,{size:"xs",c:"red",ff:"monospace",children:p.columnKey})]})})]})}return n.jsx(s.NativeSelect,{ref:t,...c,data:u,value:r,onChange:p=>a(p.currentTarget.value)})})),E0=({xDataKey:e,yDataKey:t,groupKey:r})=>{const{t:a}=m.useTranslation();return n.jsxs(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconAdjustments,{size:14}),children:a("viz.regression_chart.customize")})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsxs(ne,{children:[n.jsx(Zr,{variant:"unstyled",size:"xs",onChange:e.set,value:e.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("chart.x_axis.label")}),rightSectionWidth:14,w:"auto",miw:"unset"}),n.jsx(Zr,{variant:"unstyled",size:"xs",onChange:t.set,value:t.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("chart.y_axis.label")}),rightSectionWidth:14,w:"auto",miw:"unset"}),n.jsx(Zr,{variant:"unstyled",size:"xs",onChange:r.set,value:r.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("viz.regression_chart.split_by")}),rightSectionWidth:14,w:"auto",miw:"unset",clearable:!0})]})})]})},Tl={output:"number",mantissa:2,trimMantissa:!0,absolute:!1};function Dn(e,t,r){return 1-(1-e)*(t-1)/(t-r-1)}function B0(e,t,r,a,o){const l=ht.regressionLinear()(r),{a:i,b:c,rSquared:d}=l;return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"red",children:Y(c,Tl)}),n.jsx(s.Text,{size:"sm",children:"+"}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"red",children:Y(i,Tl)}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsx(s.Text,{size:"sm",children:a.columnKey})]}),rSquared:d,adjustedRSquared:Dn(d,t.length,1)}}function q0(e,t,r,a,o){const{a:l,b:i,rSquared:c}=ht.regressionExp()(r);return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:l}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsxs(s.Group,{justify:"flex-start",wrap:"nowrap",gap:2,children:[n.jsx(s.Text,{size:"sm",children:"Math.exp("}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:i}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsx(s.Text,{size:"sm",children:a.columnKey}),n.jsx(s.Text,{size:"sm",children:")"})]})]}),rSquared:c,adjustedRSquared:Dn(c,t.length,1)}}function O0(e,t,r,a,o){const{a:l,b:i,rSquared:c}=ht.regressionLog()(r);return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:l}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsxs(s.Group,{justify:"flex-start",wrap:"nowrap",gap:2,children:[n.jsx(s.Text,{size:"sm",children:"Math.log("}),n.jsx(s.Text,{size:"sm",children:a.columnKey}),n.jsx(s.Text,{size:"sm",children:")"}),n.jsx(s.Text,{size:"sm",children:"+"}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:i})]})]}),rSquared:c,adjustedRSquared:Dn(c,t.length,1)}}function L0(e,t,r,a){const{regression:o}=a,l=ht.regressionPoly().order(o.transform.config.order)(r),{rSquared:i}=l;return console.log(l),{name:e,expression:"",rSquared:i,adjustedRSquared:Dn(i,t.length,1)}}function kl(e,t,r,a,o){const{regression:l}=r,i=t.map(c=>[c[a.columnKey],c[o.columnKey]]);return l.transform.config.method==="linear"?B0(e,t,i,a,o):l.transform.config.method==="exponential"?q0(e,t,i,a,o):l.transform.config.method==="logistic"?O0(e,t,i,a,o):l.transform.config.method==="polynomial"?L0(e,t,i,r):{name:e,expression:"",rSquared:0,adjustedRSquared:0}}function N0(e,t,r,a,o){if(!o)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!a.columnKey||!a.queryID)return[kl("",e,o,t,r)];const l=y.groupBy(e,a.columnKey);return Object.entries(l).map(([i,c])=>kl(i,c,o,t,r))}const G0={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Dl({desc:e}){const{t}=m.useTranslation(),{expression:r,rSquared:a,adjustedRSquared:o}=e;return r?n.jsx(s.Table,{fz:14,sx:G0,children:n.jsxs(s.Table.Tbody,{children:[n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{colSpan:2,children:r})}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:t("viz.regression_chart.r_sq")}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:Y(a,{output:"percent",mantissa:1,absolute:!1})})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:t("viz.regression_chart.r_sq_adjusted")}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:Y(o,{output:"percent",mantissa:1,absolute:!1})})]})]})}):n.jsx(s.Text,{size:"sm",children:"Unavailable for this regression method"})}function F0({conf:e,queryData:t,x:r,y:a,g:o}){var i;const l=h.useMemo(()=>N0(t,r,a,o,e),[e,t,r,a,o]);return!o.columnKey||!o.queryID?n.jsx(Dl,{desc:l[0]}):n.jsxs(s.Tabs,{defaultValue:(i=l[0])==null?void 0:i.name,color:"gray",children:[n.jsx(s.Tabs.List,{grow:!0,children:l.map(c=>n.jsx(s.Tabs.Tab,{value:c.name,children:c.name},c.name))}),l.map(c=>n.jsx(s.Tabs.Panel,{value:c.name,children:n.jsx(Dl,{desc:c})},c.name))]})}function Q0({conf:e,queryData:t,x:r,y:a,g:o}){const{t:l}=m.useTranslation();return n.jsxs(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconInfoCircle,{size:14}),children:l("viz.regression_chart.regression_info")})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(ne,{children:n.jsx(F0,{conf:e,queryData:t,x:r,y:a,g:o})})})]})}function j0({conf:e,context:t,xDataKey:r,yDataKey:a,groupKey:o,x:l,y:i,g:c}){const d=h.useMemo(()=>{var w,x;const u=t.data,p=e==null?void 0:e.x_axis.data_key,g=(w=e==null?void 0:e.regression)==null?void 0:w.y_axis_data_key;if(!p||!g)return[];const b=$(p),_=$(g);return(x=u[b.queryID])==null?void 0:x.map(S=>typeof S[_.columnKey]=="number"?S:{...S,[_.columnKey]:Number(S[_.columnKey])})},[r.value,a.value,t.data]);return n.jsxs(s.Group,{justify:"flex-start",sx:{position:"absolute",top:0,left:we.left,right:we.right,height:"22px",zIndex:1},children:[n.jsx(Q0,{conf:e,queryData:d,x:l,y:i,g:c}),n.jsx(E0,{xDataKey:r,yDataKey:a,groupKey:o})]})}const Jr=e=>{const[t,r]=h.useState(e);return{value:t,set:r}},W0=({context:e,instance:t,conf:r,width:a,height:o})=>{const l=Jr(r.x_axis.data_key),i=Jr(r.regression.y_axis_data_key),c=Jr(r.regression.group_by_key),d=$(l.value),u=$(i.value),p=$(c.value),g=h.useMemo(()=>A0(y.defaultsDeep({},r,Cl()),e.data,d,u,p),[r,e.data,d,u,p]),b=h.useRef(null),_=S=>{b.current=S},w=h.useCallback(()=>{const S=b.current;S&&fe(t,S.getOption())},[t]),x=h.useMemo(()=>({finished:w}),[w]);return n.jsxs(n.Fragment,{children:[n.jsx(j0,{conf:r,context:e,xDataKey:l,yDataKey:i,groupKey:c,x:d,y:u,g:p}),n.jsx(he,{echarts:ce,onChartReady:_,option:g,onEvents:x,style:Yt(a,o),notMerge:!0,theme:"merico-light"})]})};function U0({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),{width:a,height:o}=e.viewport;return!a||!o||!r?null:n.jsx(ve,{width:a,height:o,children:n.jsx(W0,{context:e,instance:t,conf:r,width:a,height:o})})}const K0=[{lang:"en",resources:{regression_chart:{viz_name:"Regression Chart",regression_info:"Regression Info",r_sq:"R-Sq",r_sq_adjusted:"R-Sq(Adjusted)",customize:"Customize",split_by:"Split by"}}},{lang:"zh",resources:{regression_chart:{viz_name:"回归分析图",regression_info:"回归信息",r_sq:"R方",r_sq_adjusted:"R方(调整)",customize:"自定义",split_by:"拆分"}}}];function Y0({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t("regression");const o=t("regression.transform.config.method"),l=t("regression.group_by_key"),i=h.useMemo(()=>[{label:r("chart.regression_line.method.linear"),value:"linear"},{label:r("chart.regression_line.method.exponential"),value:"exponential"},{label:r("chart.regression_line.method.logistic"),value:"logistic"},{label:r("chart.regression_line.method.polynomial"),value:"polynomial"}],[a.language]);return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:"regression.group_by_key",control:e,render:({field:c})=>n.jsx(L,{label:"默认拆分字段",description:"按此字段拆分为多个系列",clearable:!0,sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"regression.transform.config.method",control:e,render:({field:c})=>n.jsx(s.Select,{label:r("chart.regression_line.method.label"),data:i,sx:{flex:1},...c})}),o==="polynomial"&&n.jsx(v.Controller,{name:"regression.transform.config.order",control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:r("chart.regression_line.method.polynomial_order"),sx:{flex:1},...c})})]}),!l&&n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"regression.plot.color",control:e,render:({field:c})=>n.jsx(ye,{label:r("chart.color.label"),...c})})})]})}function X0({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},t),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),i(["x_axis","regression"]),t?n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:o,render:({field:u})=>n.jsx(L,{label:"默认X轴数据字段",required:!0,sx:{flex:1},...u})}),n.jsx(v.Controller,{name:"regression.y_axis_data_key",control:o,render:({field:u})=>n.jsx(L,{label:"默认Y轴数据字段",required:!0,sx:{flex:1},...u})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(Y0,{control:o,watch:i})]})]}):null}class Z0 extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:S0(r.config)})),this.version(3,(r,a)=>{const{config:o}=r;return{...r,version:3,config:T0(o,a)}}),this.version(4,(r,a)=>{const{config:o}=r;return{...r,version:4,config:k0(o)}})}}const J0={displayName:"viz.regression_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Z0,name:"regressionChart",viewRender:U0,configRender:X0,createConfig(){return{version:3,config:Cl()}},translation:K0},zn={content:""},H0=k.observer(({context:e})=>{const t=H(),{panel:r}=re(),{value:a}=q(e.instanceData,"config"),{variables:o,data:l}=e,i=h.useMemo(()=>{const c=y.defaults({},a,zn);return c.content?ft(c.content,o,t.payloadForViz,l):""},[l,a,o,t.payloadForViz]);return i?n.jsx($t,{value:i,styles:{root:{border:"none",height:"100%"},content:{padding:0}},dashboardStateValues:t.dashboardStateValues,variableAggValueMap:r.variableAggValueMap}):null}),R0=k.observer(({context:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation(),{value:a,set:o}=q(e.instanceData,"config"),l=h.useMemo(()=>y.defaults({},a,zn),[a]),{control:i,handleSubmit:c,watch:d,reset:u}=v.useForm({defaultValues:l});d("content"),h.useEffect(()=>{u(l)},[l]);const p=h.useRef(null),g=()=>{var b;return(b=p.current)==null?void 0:b.click()};return n.jsx("form",{onSubmit:c(o),style:{flexGrow:1,display:"flex",flexDirection:"column"},children:n.jsxs(s.Stack,{gap:"xs",sx:{flexGrow:1},children:[n.jsxs(s.Group,{justify:"flex-start",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",display:"none"},children:[n.jsx(s.Text,{size:"sm",children:r("rich_text.content.label")}),n.jsx(s.ActionIcon,{ref:p,type:"submit",mr:5,variant:"filled",color:"blue",children:n.jsx(T.IconDeviceFloppy,{size:20})})]}),n.jsx(v.Controller,{name:"content",control:i,render:({field:b})=>h.createElement(gn,{...b,key:t.id,styles:{root:{flexGrow:1}},label:r("rich_text.content.label"),onSubmit:g})})]})})}),e1=[{lang:"en",resources:{rich_text:{viz_name:"Rich Text"}}},{lang:"zh",resources:{rich_text:{viz_name:"富文本"}}}];class t1 extends J{constructor(){super(...arguments);V(this,"VERSION",1)}fixMalformedConfig(r){return y.defaults({},r,zn)}configVersions(){this.version(1,r=>({version:1,config:this.fixMalformedConfig(r)}))}}const n1={displayName:"viz.rich_text.viz_name",displayGroup:"chart.groups.others",migrator:new t1,name:"richText",viewRender:H0,configRender:R0,createConfig(){return{version:1,config:y.cloneDeep(zn)}},translation:e1},Jt={static:{type:"static",color:Ge.random().css()},dynamic:{type:"dynamic",func_content:["function getColor({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here",' // return "blue"',"}"].join(`
|
|
473
|
+
`}})}const $0={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function A0(e,t,r,a,o){if(!eo(r)||!eo(a))return[];const l=I0(e,t,r,a,o),i=D0(e,l),c={xAxis:X.getXAxis({type:"value",name:r.columnKey,nameLocation:"middle",nameGap:25}),yAxis:X.getYAxis({name:a.columnKey,nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5}),series:[...l,...i],tooltip:P0(r,a),legend:{show:!!o.columnKey&&!!o.queryID,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[8,8,0,140],data:l.map(d=>d.name)}};return y.defaultsDeep({},c,$0)}const Jr=k.observer(h.forwardRef((e,t)=>{const{value:r,onChange:a,queryID:o,clearable:l=!1,unsetKey:i="data.data_field.selector.options.unset",...c}=e,{panel:d}=ae(),u=h.useMemo(()=>d.dataFieldOptionGroups({selected:r,clearable:l,unsetKey:i,queryID:o}),[r,l,o]);if(u.length===0){const p=d.explainDataKey(r);return n.jsxs(s.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Box,{children:n.jsx(s.TextInput,{label:c.label,required:c.required,defaultValue:p.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsxs(s.Group,{justify:"flex-start",gap:0,children:[n.jsx(s.Text,{size:"xs",c:p.queryName?"black":"red",ff:"monospace",children:p.queryName??p.queryID}),n.jsx(s.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(s.Text,{size:"xs",c:"red",ff:"monospace",children:p.columnKey})]})})]})}return n.jsx(s.NativeSelect,{ref:t,...c,data:u,value:r,onChange:p=>a(p.currentTarget.value)})})),E0=({xDataKey:e,yDataKey:t,groupKey:r})=>{const{t:a}=m.useTranslation();return n.jsxs(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconAdjustments,{size:14}),children:a("viz.regression_chart.customize")})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsxs(ne,{children:[n.jsx(Jr,{variant:"unstyled",size:"xs",onChange:e.set,value:e.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("chart.x_axis.label")}),rightSectionWidth:14,w:"auto",miw:"unset"}),n.jsx(Jr,{variant:"unstyled",size:"xs",onChange:t.set,value:t.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("chart.y_axis.label")}),rightSectionWidth:14,w:"auto",miw:"unset"}),n.jsx(Jr,{variant:"unstyled",size:"xs",onChange:r.set,value:r.value,leftSection:n.jsx(s.Text,{size:"xs",children:a("viz.regression_chart.split_by")}),rightSectionWidth:14,w:"auto",miw:"unset",clearable:!0})]})})]})},Tl={output:"number",mantissa:2,trimMantissa:!0,absolute:!1};function Dn(e,t,r){return 1-(1-e)*(t-1)/(t-r-1)}function B0(e,t,r,a,o){const l=ht.regressionLinear()(r),{a:i,b:c,rSquared:d}=l;return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"red",children:Y(c,Tl)}),n.jsx(s.Text,{size:"sm",children:"+"}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"red",children:Y(i,Tl)}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsx(s.Text,{size:"sm",children:a.columnKey})]}),rSquared:d,adjustedRSquared:Dn(d,t.length,1)}}function q0(e,t,r,a,o){const{a:l,b:i,rSquared:c}=ht.regressionExp()(r);return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:l}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsxs(s.Group,{justify:"flex-start",wrap:"nowrap",gap:2,children:[n.jsx(s.Text,{size:"sm",children:"Math.exp("}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:i}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsx(s.Text,{size:"sm",children:a.columnKey}),n.jsx(s.Text,{size:"sm",children:")"})]})]}),rSquared:c,adjustedRSquared:Dn(c,t.length,1)}}function O0(e,t,r,a,o){const{a:l,b:i,rSquared:c}=ht.regressionLog()(r);return{name:e,expression:n.jsxs(s.Group,{justify:"center",wrap:"nowrap",gap:10,children:[n.jsx(s.Text,{size:"sm",children:o.columnKey}),n.jsx(s.Text,{size:"sm",children:"="}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:l}),n.jsx(s.Text,{size:"sm",children:"×"}),n.jsxs(s.Group,{justify:"flex-start",wrap:"nowrap",gap:2,children:[n.jsx(s.Text,{size:"sm",children:"Math.log("}),n.jsx(s.Text,{size:"sm",children:a.columnKey}),n.jsx(s.Text,{size:"sm",children:")"}),n.jsx(s.Text,{size:"sm",children:"+"}),n.jsx(s.Text,{size:"sm",fw:"bold",c:"gray",children:i})]})]}),rSquared:c,adjustedRSquared:Dn(c,t.length,1)}}function L0(e,t,r,a){const{regression:o}=a,l=ht.regressionPoly().order(o.transform.config.order)(r),{rSquared:i}=l;return console.log(l),{name:e,expression:"",rSquared:i,adjustedRSquared:Dn(i,t.length,1)}}function kl(e,t,r,a,o){const{regression:l}=r,i=t.map(c=>[c[a.columnKey],c[o.columnKey]]);return l.transform.config.method==="linear"?B0(e,t,i,a,o):l.transform.config.method==="exponential"?q0(e,t,i,a,o):l.transform.config.method==="logistic"?O0(e,t,i,a,o):l.transform.config.method==="polynomial"?L0(e,t,i,r):{name:e,expression:"",rSquared:0,adjustedRSquared:0}}function N0(e,t,r,a,o){if(!o)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!a.columnKey||!a.queryID)return[kl("",e,o,t,r)];const l=y.groupBy(e,a.columnKey);return Object.entries(l).map(([i,c])=>kl(i,c,o,t,r))}const G0={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Dl({desc:e}){const{t}=m.useTranslation(),{expression:r,rSquared:a,adjustedRSquared:o}=e;return r?n.jsx(s.Table,{fz:14,sx:G0,children:n.jsxs(s.Table.Tbody,{children:[n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{colSpan:2,children:r})}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:t("viz.regression_chart.r_sq")}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:Y(a,{output:"percent",mantissa:1,absolute:!1})})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:t("viz.regression_chart.r_sq_adjusted")}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:Y(o,{output:"percent",mantissa:1,absolute:!1})})]})]})}):n.jsx(s.Text,{size:"sm",children:"Unavailable for this regression method"})}function F0({conf:e,queryData:t,x:r,y:a,g:o}){var i;const l=h.useMemo(()=>N0(t,r,a,o,e),[e,t,r,a,o]);return!o.columnKey||!o.queryID?n.jsx(Dl,{desc:l[0]}):n.jsxs(s.Tabs,{defaultValue:(i=l[0])==null?void 0:i.name,color:"gray",children:[n.jsx(s.Tabs.List,{grow:!0,children:l.map(c=>n.jsx(s.Tabs.Tab,{value:c.name,children:c.name},c.name))}),l.map(c=>n.jsx(s.Tabs.Panel,{value:c.name,children:n.jsx(Dl,{desc:c})},c.name))]})}function Q0({conf:e,queryData:t,x:r,y:a,g:o}){const{t:l}=m.useTranslation();return n.jsxs(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{variant:"subtle",size:"compact-xs",leftSection:n.jsx(T.IconInfoCircle,{size:14}),children:l("viz.regression_chart.regression_info")})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(ne,{children:n.jsx(F0,{conf:e,queryData:t,x:r,y:a,g:o})})})]})}function j0({conf:e,context:t,xDataKey:r,yDataKey:a,groupKey:o,x:l,y:i,g:c}){const d=h.useMemo(()=>{var w,x;const u=t.data,p=e==null?void 0:e.x_axis.data_key,g=(w=e==null?void 0:e.regression)==null?void 0:w.y_axis_data_key;if(!p||!g)return[];const b=$(p),_=$(g);return(x=u[b.queryID])==null?void 0:x.map(S=>typeof S[_.columnKey]=="number"?S:{...S,[_.columnKey]:Number(S[_.columnKey])})},[r.value,a.value,t.data]);return n.jsxs(s.Group,{justify:"flex-start",sx:{position:"absolute",top:0,left:we.left,right:we.right,height:"22px",zIndex:1},children:[n.jsx(Q0,{conf:e,queryData:d,x:l,y:i,g:c}),n.jsx(E0,{xDataKey:r,yDataKey:a,groupKey:o})]})}const Hr=e=>{const[t,r]=h.useState(e);return{value:t,set:r}},W0=({context:e,instance:t,conf:r,width:a,height:o})=>{const l=Hr(r.x_axis.data_key),i=Hr(r.regression.y_axis_data_key),c=Hr(r.regression.group_by_key),d=$(l.value),u=$(i.value),p=$(c.value),g=h.useMemo(()=>A0(y.defaultsDeep({},r,Cl()),e.data,d,u,p),[r,e.data,d,u,p]),b=h.useRef(null),_=S=>{b.current=S},w=h.useCallback(()=>{const S=b.current;S&&fe(t,S.getOption())},[t]),x=h.useMemo(()=>({finished:w}),[w]);return n.jsxs(n.Fragment,{children:[n.jsx(j0,{conf:r,context:e,xDataKey:l,yDataKey:i,groupKey:c,x:d,y:u,g:p}),n.jsx(he,{echarts:ce,onChartReady:_,option:g,onEvents:x,style:Yt(a,o),notMerge:!0,theme:"merico-light"})]})};function U0({context:e,instance:t}){const{value:r}=q(e.instanceData,"config"),{width:a,height:o}=e.viewport;return!a||!o||!r?null:n.jsx(ve,{width:a,height:o,children:n.jsx(W0,{context:e,instance:t,conf:r,width:a,height:o})})}const K0=[{lang:"en",resources:{regression_chart:{viz_name:"Regression Chart",regression_info:"Regression Info",r_sq:"R-Sq",r_sq_adjusted:"R-Sq(Adjusted)",customize:"Customize",split_by:"Split by"}}},{lang:"zh",resources:{regression_chart:{viz_name:"回归分析图",regression_info:"回归信息",r_sq:"R方",r_sq_adjusted:"R方(调整)",customize:"自定义",split_by:"拆分"}}}];function Y0({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t("regression");const o=t("regression.transform.config.method"),l=t("regression.group_by_key"),i=h.useMemo(()=>[{label:r("chart.regression_line.method.linear"),value:"linear"},{label:r("chart.regression_line.method.exponential"),value:"exponential"},{label:r("chart.regression_line.method.logistic"),value:"logistic"},{label:r("chart.regression_line.method.polynomial"),value:"polynomial"}],[a.language]);return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:"regression.group_by_key",control:e,render:({field:c})=>n.jsx(L,{label:"默认拆分字段",description:"按此字段拆分为多个系列",clearable:!0,sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"regression.transform.config.method",control:e,render:({field:c})=>n.jsx(s.Select,{label:r("chart.regression_line.method.label"),data:i,sx:{flex:1},...c})}),o==="polynomial"&&n.jsx(v.Controller,{name:"regression.transform.config.order",control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:r("chart.regression_line.method.polynomial_order"),sx:{flex:1},...c})})]}),!l&&n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:"regression.plot.color",control:e,render:({field:c})=>n.jsx(ye,{label:r("chart.color.label"),...c})})})]})}function X0({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaults({},t),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),i(["x_axis","regression"]),t?n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:o,render:({field:u})=>n.jsx(L,{label:"默认X轴数据字段",required:!0,sx:{flex:1},...u})}),n.jsx(v.Controller,{name:"regression.y_axis_data_key",control:o,render:({field:u})=>n.jsx(L,{label:"默认Y轴数据字段",required:!0,sx:{flex:1},...u})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(Y0,{control:o,watch:i})]})]}):null}class Z0 extends J{constructor(){super(...arguments);V(this,"VERSION",4)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:S0(r.config)})),this.version(3,(r,a)=>{const{config:o}=r;return{...r,version:3,config:T0(o,a)}}),this.version(4,(r,a)=>{const{config:o}=r;return{...r,version:4,config:k0(o)}})}}const J0={displayName:"viz.regression_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Z0,name:"regressionChart",viewRender:U0,configRender:X0,createConfig(){return{version:3,config:Cl()}},translation:K0},zn={content:""},H0=k.observer(({context:e})=>{const t=H(),{panel:r}=re(),{value:a}=q(e.instanceData,"config"),{variables:o,data:l}=e,i=h.useMemo(()=>{const c=y.defaults({},a,zn);return c.content?ft(c.content,o,t.payloadForViz,l):""},[l,a,o,t.payloadForViz]);return i?n.jsx($t,{value:i,styles:{root:{border:"none",height:"100%"},content:{padding:0}},dashboardStateValues:t.dashboardStateValues,variableAggValueMap:r.variableAggValueMap}):null}),R0=k.observer(({context:e})=>{const{panel:t}=ae(),{t:r}=m.useTranslation(),{value:a,set:o}=q(e.instanceData,"config"),l=h.useMemo(()=>y.defaults({},a,zn),[a]),{control:i,handleSubmit:c,watch:d,reset:u}=v.useForm({defaultValues:l});d("content"),h.useEffect(()=>{u(l)},[l]);const p=h.useRef(null),g=()=>{var b;return(b=p.current)==null?void 0:b.click()};return n.jsx("form",{onSubmit:c(o),style:{flexGrow:1,display:"flex",flexDirection:"column"},children:n.jsxs(s.Stack,{gap:"xs",sx:{flexGrow:1},children:[n.jsxs(s.Group,{justify:"flex-start",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",display:"none"},children:[n.jsx(s.Text,{size:"sm",children:r("rich_text.content.label")}),n.jsx(s.ActionIcon,{ref:p,type:"submit",mr:5,variant:"filled",color:"blue",children:n.jsx(T.IconDeviceFloppy,{size:20})})]}),n.jsx(v.Controller,{name:"content",control:i,render:({field:b})=>h.createElement(gn,{...b,key:t.id,styles:{root:{flexGrow:1}},label:r("rich_text.content.label"),onSubmit:g})})]})})}),e1=[{lang:"en",resources:{rich_text:{viz_name:"Rich Text"}}},{lang:"zh",resources:{rich_text:{viz_name:"富文本"}}}];class t1 extends J{constructor(){super(...arguments);V(this,"VERSION",1)}fixMalformedConfig(r){return y.defaults({},r,zn)}configVersions(){this.version(1,r=>({version:1,config:this.fixMalformedConfig(r)}))}}const n1={displayName:"viz.rich_text.viz_name",displayGroup:"chart.groups.others",migrator:new t1,name:"richText",viewRender:H0,configRender:R0,createConfig(){return{version:1,config:y.cloneDeep(zn)}},translation:e1},Jt={static:{type:"static",color:Ge.random().css()},dynamic:{type:"dynamic",func_content:["function getColor({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here",' // return "blue"',"}"].join(`
|
|
474
474
|
`)}};function zl(){const{on_axis:e,in_tooltip:t}=Ie();return{label:e,tooltip:t}}const Ml={scatter:{y_data_key:"",name_data_key:"",symbolSize:{type:"static",size:10},unit:K(),color:Jt.static,label_position:"right",label_overflow:zl()},stats:{top:"",bottom:""},x_axis:{name:"",data_key:"",unit:K(),axisLabel:{rotate:0,formatter:_e(),overflow:Ie()}},y_axes:[{name:"Y Axis",position:"left",nameAlignment:"center",label_formatter:de,min:"",max:"",show:!0,mirror:!1}],tooltip:{trigger:"item",metrics:[]},reference_lines:[],reference_areas:[],dataZoom:kt};function r1(e){const{dataZoom:t=kt,...r}=e;return{...r,dataZoom:t}}function a1(e){const t={scatter:{label_overflow:zl()}};return y.defaultsDeep(t,e)}function s1(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...Jt.static,color:t}}}:e}function o1(e){const t=e.reference_lines.map(r=>{const{lineStyle:a={type:"dashed",width:1,color:Ge.random().css()},show_in_legend:o=!1,yAxisIndex:l=0}=r;return{...r,lineStyle:a,show_in_legend:o,yAxisIndex:l}});return{...e,reference_lines:t}}function l1(e){const t={tooltip:{trigger:"item"}};return y.defaultsDeep({},e,t)}function i1(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{x_axis:o,scatter:l,tooltip:i,...c}=e;return{...c,x_axis:{...o,data_key:a(o.data_key)},scatter:{...l,y_data_key:a(l.y_data_key),name_data_key:a(l.name_data_key)},tooltip:{...i,metrics:i.metrics.map(d=>({...d,data_key:a(d.data_key)}))}}}catch(r){throw console.error("[Migration failed]",r),r}}function c1(e){const t={x_axis:{axisLabel:{overflow:Ie()}}};return y.defaultsDeep(t,e)}function d1(e,t){const{stats:r,...a}=e,o=At(r.templates.top,t),l=At(r.templates.bottom,t);return{stats:{top:o??"",bottom:l??""},...a}}function u1(e){const{tooltip:t,...r}=e,a=t.metrics;return{...r,tooltip:{...t,metrics:a.map(o=>({...o,unit:o.unit??K()}))}}}function p1(e){const{scatter:t,x_axis:r}=e;return{...e,x_axis:{...r,unit:r.unit??K()},scatter:{...t,unit:t.unit??K()}}}class h1 extends J{constructor(){super(...arguments);V(this,"VERSION",13)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{tooltip:a={metrics:[]},...o}=r.config;return{...r,version:2,config:{...o,tooltip:a}}}),this.version(3,r=>({...r,version:3,config:r1(r.config)})),this.version(4,r=>{const{config:a}=r;return{...r,version:5,config:a1(a)}}),this.version(6,r=>{const{config:a}=r;return{...r,version:6,config:s1(a)}}),this.version(7,r=>{const{config:a}=r;return{...r,version:7,config:o1(a)}}),this.version(8,r=>{const{config:a}=r;return{...r,version:8,config:l1(a)}}),this.version(9,(r,a)=>{const{config:o}=r;return{...r,version:9,config:i1(o,a)}}),this.version(10,(r,a)=>{const{config:o}=r;return{...r,version:10,config:c1(o)}}),this.version(11,(r,a)=>{const{config:o}=r;return{...r,version:11,config:d1(o,a.panelModel)}}),this.version(12,r=>{const{config:a}=r;return{...r,version:12,config:u1(a)}}),this.version(13,r=>{const{config:a}=r;return{...r,version:13,config:p1(a)}})}}const g1=[{lang:"en",resources:{scatter_chart:{viz_name:"Scatter Chart",color:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic color"}},click_scatter:{trigger:"Click Scatter"}}}},{lang:"zh",resources:{scatter_chart:{viz_name:"散点图",color:{type:{static:"具体颜色",dynamic:"动态计算颜色"},dynamic:{setup:"设置",setup_title:"设置动态计算颜色的逻辑"}},click_scatter:{trigger:"点击散点"}}}}],Il={id:"builtin:echarts:click-scatter-chart:series",displayName:"viz.scatter_chart.click_scatter.trigger",nameRender:b1,configRender:f1,payload:[{name:"seriesType",description:'"scatter"',valueType:"string"},{name:"componentType",description:'"series"',valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function f1(e){return n.jsx(n.Fragment,{})}function b1(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.scatter_chart.click_scatter.trigger")})}function y1(e,t){if(!e.x_axis.data_key)return[];const r=$(e.x_axis.data_key);return[{source:t[r.queryID]}]}function v1(e){const t=e.y_axes.some(o=>!!o.name);let r=15;t&&(r+=20),e.dataZoom.x_axis_slider&&(r+=20);let a=5;return e.x_axis.name&&(a+=15),{top:r,bottom:a}}function _1(){return{show:!1,bottom:0,left:"center",type:"scroll"}}function Mn(e,t){if(e)return t[e]??void 0}function m1({reference_areas:e,variableValueMap:t}){const r=e.map(a=>[{name:a.content.text,value:a.content.text,itemStyle:a.itemStyle,label:a.label,xAxis:Mn(a.leftBottomPoint.x_data_key,t),yAxis:Mn(a.leftBottomPoint.y_data_key,t)},{xAxis:Mn(a.rightTopPoint.x_data_key,t),yAxis:Mn(a.rightTopPoint.y_data_key,t)}]);return{type:"scatter",name:"ref_areas",silent:!0,data:[],markArea:{data:r}}}function w1({type:e,...t},r){if(!e)return 10;if(e==="static"){const{size:o}=t;return o}const{func_content:a}=t;return(o,l)=>{const i=l.data;try{return new Function(`return ${a}`)()({rowData:i,params:l,variables:r},{lodash:y,interpolate:dt.interpolate})}catch(c){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${c.message}`),10}}}function x1({type:e,...t},r){if(!e)return Jt.static.color;if(e==="static"){const{color:o}=t;return o}const{func_content:a}=t;return({value:o})=>{try{return new Function(`return ${a}`)()({rowData:o,variables:r},{lodash:y,interpolate:dt.interpolate})}catch(l){return console.error(`[getSeriesColor] failed parsing custom function, error: ${l.message}`),10}}}function C1(e,t,r,a){return e.map(o=>{const l=o.orientation==="horizontal",i=l?"yAxis":"xAxis",c=l?"insideEndTop":"end";return{name:o.name,type:"line",hide_in_legend:!o.show_in_legend,yAxisIndex:o.yAxisIndex,data:[],lineStyle:o.lineStyle,markLine:{data:[{name:o.name,[i]:Number(r[o.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:o.lineStyle,label:{formatter:function(){return o.template?Kt(o.template,t,a):""},position:c}}}})}function S1({x_axis:e,scatter:t},r){const a=$(e.data_key),o=$(t.y_data_key),l=$(t.name_data_key);return{label:{show:!!t.label_position,position:t.label_position,...Ke(t.label_overflow.label),formatter:({value:i})=>i[l.columnKey]},type:"scatter",name:"",xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{color:x1(t.color,r)},symbolSize:w1(t.symbolSize,r),encode:{x:a.columnKey,y:o.columnKey}}}function T1(e,t,r,a){return[S1(e,a)].concat(C1(e.reference_lines,r,a,t)).concat(m1({reference_areas:e.reference_areas,variableValueMap:a}))}function Vl(e,t,r){const{x_axis:a}=r;return a.axisLabel.formatter.enabled?Me(a.axisLabel.formatter)(e,t):e}function k1(e,t){const{x_axis:r,tooltip:a}=t;if(a.trigger==="item"){const c=un(e[0].data,r.data_key);return Vl(c,0,t)}const o=e.find(c=>c.axisDim==="x"&&c.axisId==="main-x-axis");if(!o)return"";const{axisValue:l,axisIndex:i}=o;return Vl(l,i,t)}const D1=e=>Y(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function z1(e,t){const{scatter:r,x_axis:a,y_axes:o,tooltip:l}=e,i=a.unit.show_in_tooltip?a.unit.text:"",c=r.unit.show_in_tooltip?r.unit.text:"",d=l.metrics.reduce((u,{unit:p,name:g})=>(p.show_in_tooltip&&(u[g]=p.text),u),{});return X.getTooltip({trigger:l.trigger,formatter:function(u){const p=t[0]??t.default,g=Array.isArray(u)?u:[u];if(g.length===0)return"";const b=k1(g,e),_=Le(e.scatter.label_overflow.tooltip),w=g.map(({value:I})=>`
|
|
475
475
|
<th style="text-align: right; padding-right: 1em">
|
|
476
476
|
<div style="${_}">${un(I,r.name_data_key)}</div>
|
|
@@ -504,7 +504,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
504
504
|
<thead><tr>${w.join("")}</tr></thead>
|
|
505
505
|
<tbody>${S.join("")}</tbody>
|
|
506
506
|
</table>
|
|
507
|
-
`}})}function M1(e,t){const r=t.every(c=>!Number.isNaN(Number(c))),{overflow:a,...o}=e.x_axis.axisLabel,l=Ke(a.on_axis),i=t.length===0;return[X.getXAxis({data:t,name:e.x_axis.name??"",nameGap:i?5:void 0,id:"main-x-axis",type:r?"value":"category",axisLabel:{...o,...l,formatter:Me(o.formatter)}})]}function I1(e,t){return e.y_axes.map(({nameAlignment:r,min:a,max:o,...l},i)=>{let c=l.position;return c||(c=i>0?"right":"left"),X.getYAxis({...l,minInterval:1,min:a||void 0,max:o||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:t[i]??t.default},nameTextStyle:{align:r},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const V1={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function P1(e,t,r){const a=r.reduce((d,u)=>{const p=He(u,t);return d[u.name]=Be(u,p),d},{}),o=e.y_axes.reduce((d,{label_formatter:u},p)=>(d[p]=function(b){let _=b;if(typeof b=="object"&&(Array.isArray(b.value)&&b.value.length===2?_=b.value[1]:_=b.value),!u)return _;try{return Y(_,u)}catch(w){return console.error(w),_}},d),{default:({value:d})=>d}),l=y.uniq(me(t,e.x_axis.data_key)),i=T1(e,t,r,a),c={xAxis:M1(e,l),yAxis:I1(e,o),series:i,dataset:y1(e,t),tooltip:z1(e,o),grid:v1(e),legend:_1(),dataZoom:_n(e.dataZoom)};return y.defaultsDeep({},c,V1)}function $1({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=Dt(t,e.x_axis.data_key),d=Ve(o.triggerManager,Il.id),u=h.useCallback(x=>{const S=x.data;d.forEach(D=>{o.runInteraction(D.id,{...x,rowData:S})})},[c,d,o]),p=h.useRef(null),g=H(),b=h.useCallback(()=>{var z;const x=(z=p.current)==null?void 0:z.getEchartsInstance();if(!x)return;const S=ft(e.stats.top,l,g.payloadForViz,t),D=ft(e.stats.bottom,l,g.payloadForViz,t);fe(i,{...x.getOption(),statsAboveViz:S,statsBelowViz:D})},[i]),_=h.useMemo(()=>({click:u,finished:b}),[u,b]),w=h.useMemo(()=>P1(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:w,ref:p,style:{width:r,height:a},onEvents:_,notMerge:!0,theme:"merico-light"})}function A1({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Ml),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c);return!c||!d?null:n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx($1,{instance:t,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})}const E1=h.forwardRef(({value:e,onChange:t,xAxisOptions:r,yAxisOptions:a,variableOptions:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=(u,p)=>{const g=y.cloneDeep(e);y.set(g,u,p),t(g)};return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.reference_area.content.label"),labelPosition:"right"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.TextInput,{label:i("chart.reference_area.content.content_text"),value:e.content.text,onChange:u=>d("content.text",u.currentTarget.value)}),n.jsx(Ot,{label:i("chart.reference_area.content.text_position"),value:e.label.position,onChange:u=>d("label.position",u)})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.reference_area.endpoint.labels"),labelPosition:"right"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[r&&n.jsx(s.Select,{label:i("chart.x_axis.label"),data:r,value:e.xAxisIndex,onChange:u=>d("xAxisIndex",u)}),a&&n.jsx(s.Select,{label:i("chart.y_axis.label"),data:a,value:e.yAxisIndex,onChange:u=>d("xAxisIndex",u)})]}),n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"14px",c:"#212529",fw:500,children:i("chart.reference_area.endpoint.left_bottom_point")}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"x"}),data:o,value:e.leftBottomPoint.x_data_key,onChange:u=>d("leftBottomPoint.x_data_key",u??""),clearable:!0}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"y"}),data:o,value:e.leftBottomPoint.y_data_key,onChange:u=>d("leftBottomPoint.y_data_key",u??""),clearable:!0})]})]}),n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"14px",c:"#212529",fw:500,children:i("chart.reference_area.endpoint.right_top_point")}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"x"}),data:o,value:e.rightTopPoint.x_data_key,onChange:u=>d("rightTopPoint.x_data_key",u??""),clearable:!0}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"y"}),data:o,value:e.rightTopPoint.y_data_key,onChange:u=>d("rightTopPoint.y_data_key",u??""),clearable:!0})]})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.style.label"),labelPosition:"right"}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(ye,{label:i("chart.color.background_color"),value:e.itemStyle.color,onChange:u=>d("itemStyle.color",u)}),n.jsx(ye,{label:i("chart.color.text_color"),value:e.label.color,onChange:u=>d("label.color",u)})]})]})});function B1(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function q1({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>B1(),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("y_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>p+1;return n.jsx(R,{control:e,watch:t,name:"reference_areas",getItem:o,addButtonText:a("chart.reference_area.add"),deleteButtonText:a("chart.reference_area.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx(v.Controller,{name:`reference_areas.${p}`,control:e,render:({field:g})=>n.jsx(s.Stack,{children:n.jsx(E1,{variableOptions:l,yAxisOptions:c,...g})})})})}function O1({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:"Y Axis",data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})})]})}function L1({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Ge.random().css()},show_in_legend:!1,yAxisIndex:0}),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("y_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>{const g=u.name.trim();return g||p+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx(O1,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:c})})}const N1=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},G1=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,func_content:_}=i,w={type:b,func_content:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,func_content:b}))},g=()=>{p(Jt.dynamic.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("viz.scatter_chart.color.dynamic.setup")})}),n.jsx(s.Modal,{size:800,title:r("viz.scatter_chart.color.dynamic.setup_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(N1,{value:i.func_content,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},F1=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(G1,{value:e,onChange:t}),Q1=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{t({...e,color:a})};return n.jsx(s.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:r})},j1=h.forwardRef(({label:e="Color",value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("viz.scatter_chart.color.type.static"),value:"static"},{label:o("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[l.language]),c=d=>{d!=="static"&&d!=="dynamic"||r({...Jt[d]})};return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e,data:i,value:t.type,onChange:c,sx:{flexGrow:1}}),n.jsx(Q1,{value:t,onChange:r}),n.jsx(F1,{value:t,onChange:r})]})}),W1=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=i=>{t({...e,label:i})},l=i=>{t({...e,tooltip:i})};return n.jsxs(s.Stack,{ref:r,gap:0,children:[n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:o}),n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:l})]})});function U1({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["scatter"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"scatter.name_data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.name_data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"scatter.y_data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.value_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"scatter.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"scatter.symbolSize",control:e,render:({field:a})=>n.jsx(Lr,{...a})}),n.jsx(v.Controller,{name:"scatter.color",control:e,render:({field:a})=>n.jsx(j1,{...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.label.label"),labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"scatter.label_position",control:e,render:({field:a})=>n.jsx(Ot,{label:r("chart.label_position.label"),withOffOption:!0,...a,onChange:o=>{a.onChange(o??"")}})})}),n.jsx(v.Controller,{name:"scatter.label_overflow",control:e,render:({field:a})=>n.jsx(W1,{...a})})]})}const K1=k.observer(({control:e,watch:t})=>{const{panel:r}=ae(),{t:a}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:o})=>n.jsx(gt,{initialValue:o.value,onChange:o.onChange,label:a("chart.stats.template.above_chart")},`${r.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:o})=>n.jsx(gt,{initialValue:o.value,onChange:o.onChange,label:a("chart.stats.template.under_chart")},`${r.id}.stats.bottom`)})]})}),Y1=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},X1=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Y1,{control:e,index:i})})]})};function Z1({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t("tooltip.trigger");const o=h.useMemo(()=>[{label:r("chart.tooltip.trigger.scatter_point"),value:"item"},{label:r("chart.tooltip.trigger.x_axis"),value:"axis"}],[a.language]);return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"tooltip.trigger",control:e,render:({field:l})=>n.jsx(s.Select,{label:r("chart.tooltip.trigger.label"),data:o,sx:{flexGrow:1},...l})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(X1,{control:e,watch:t})]})}function J1({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"x_axis.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}function H1({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsx(s.Divider,{mb:-15,mt:15,variant:"dashed",label:r("chart.y_axis.y_axis_name"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.layout"),labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(al,{sx:{flex:1},...a})})}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_max"),...a})})]})]})]})}function R1({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({name:"",label_formatter:de,min:"",max:"",show:!0,position:"right",nameAlignment:"right",mirror:!1}),o=(i,c)=>{const d=i.name.trim();return d||c+1},l=({field:i,index:c,fields:d})=>d.length<=1;return n.jsx(R,{control:e,watch:t,name:"y_axes",getItem:a,addButtonText:r("chart.y_axis.add"),deleteButtonText:r("chart.y_axis.delete"),renderTabName:o,deleteDisalbed:l,children:({field:i,index:c})=>n.jsx(H1,{control:e,index:c})})}function eC({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),{variables:o}=r,l=h.useMemo(()=>y.defaults({},e),[e]),{control:i,handleSubmit:c,watch:d,reset:u,formState:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{u(l)},[l]),d(["dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(t),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:a("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axes",children:a("chart.y_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Scatter",children:a("chart.series.scatter.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:a("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:a("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:a("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Reference Areas",children:a("chart.reference_area.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:a("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(J1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axes",children:n.jsx(R1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Scatter",children:n.jsx(U1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Z1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(K1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(L1,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Areas",children:n.jsx(q1,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function tC(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(eC,{conf:t,setConf:r,...e}):null}const nC={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new h1,name:"scatterChart",viewRender:A1,configRender:tC,createConfig(){return{version:13,config:y.cloneDeep(Ml)}},triggers:[Il],translation:g1},rC={content:"Use double curly brackets to wrap js code: {{ new Date().getTime() }}",vertical_align:"center"};function aC(e){if("variables"in e)return e;const{align:t,size:r,weight:a,color:o,content:{prefix:l="",data_field:i="value",formatter:c={output:"number",mantissa:0},postfix:d=""}={}}=e;return{align:t,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:i,aggregation:{type:"none",config:{}},formatter:c,color:o,weight:a,size:r}]}}function sC(e){return y.omit(e,["variables"])}function oC(e){const{align:t,...r}=e;return{horizontal_align:t,vertical_align:"center",...r}}function lC(e){const t=y.cloneDeep(e),r=y.get(t,"color.valueRange");return r!==void 0&&y.set(t,"color.valueRange",r.map(a=>Number(a))),t}function iC(e,t){return!t||t==="left"?e:`<p style="text-align: ${t}">${e}</p>`}function cC(e,t){const{horizontal_align:r,template:a,...o}=e;let l=At(a,t);return l=iC(l,r),{content:l,...o}}function dC(e,t){const{content:r,...a}=e;return{content:At(r,t),...a}}class uC extends J{constructor(){super(...arguments);V(this,"VERSION",5)}configVersions(){this.version(1,r=>({version:1,config:aC(r)})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(i=>{a.variables.find(c=>c.name===i.name)||a.addVariable(lC(i))}),{...r,version:2,config:sC(o)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:oC(a)}}),this.version(4,(r,{panelModel:a})=>{const{config:o}=r;return{...r,version:4,config:cC(o,a)}}),this.version(5,(r,{panelModel:a})=>{const{config:o}=r;return{...r,version:5,config:dC(o,a)}})}}const Pl={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:hC,configRender:pC,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function pC(e){return n.jsx(n.Fragment,{})}function hC(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.stats.click_stats.trigger")})}const $l={top:"flex-start",center:"center",bottom:"flex-end"},gC={top:"top center",center:"center center",bottom:"bottom center"};function fC(e){const t={flexGrow:1};return e>0&&(t.cursor="pointer",t["&:hover"]={textDecoration:"underline"}),t}const bC=k.observer(({context:e,instance:t})=>{const r=h.useRef(null),a=Pe({vizManager:e.vizManager,instance:t}),o=Ve(a.triggerManager,Pl.id),l=H(),{panel:i}=re(),c=i.viz.conf.config,{data:d,variables:u}=e,{width:p,height:g}=e.viewport,b=h.useMemo(()=>{const w=i.viz.conf.config;return w.content?ft(w.content,u,l.payloadForViz,d):""},[d,i,u,l.payloadForViz]);h.useEffect(()=>{fe(t,{content:b})},[b]);const _=h.useCallback(()=>{o.forEach(w=>{a.runInteraction(w.id,{variables:i.variableValueMap})})},[i.variableValueMap,o,a]);return h.useEffect(()=>{if(!r.current)return;const w=r.current.querySelector(".ProseMirror");if(!w)return;const{offsetWidth:x,offsetHeight:S}=w,D=p/x,z=g/S,I=Math.min(D,z);w.style.transform=`scale(${I})`},[r.current,p,g,b]),n.jsx(s.Flex,{className:"viz-stats",sx:{width:p,height:g},align:$l[c.vertical_align],direction:"row",children:n.jsx(s.Box,{className:"viz-stats--clickable-wrapper",sx:fC(o.length),onClick:_,children:n.jsx($t,{ref:r,value:b,styles:{root:{border:"none",maxWidth:p,maxHeight:g,"&.mantine-RichTextEditor-root":{overflow:"hidden !important"}},content:{height:g,display:"flex",flexDirection:"column",justifyContent:$l[c.vertical_align],"&.mantine-RichTextEditor-content .ProseMirror":{margin:"0 auto",padding:0,display:"table",width:"auto",height:"auto",maxWidth:"100%",maxHeight:"100%",transformOrigin:gC[c.vertical_align]},"&.mantine-RichTextEditor-content .ProseMirror > p":{fontSize:"initial",lineHeight:"initial"}}},dashboardStateValues:l.dashboardStateValues,variableAggValueMap:i.variableAggValueMap})})})}),yC=e=>{const{context:t}=e,{value:r}=q(t.instanceData,"config");return r?n.jsx(bC,{...e}):null},vC=k.observer(({conf:e,setConf:t})=>{const{panel:r}=ae(),{t:a}=m.useTranslation(),o=h.useMemo(()=>y.defaults({},e),[e]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),c(["content","vertical_align"]),n.jsx("form",{onSubmit:i(t),children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsx(v.Controller,{control:l,name:"vertical_align",render:({field:p})=>n.jsx(jo,{...p})}),n.jsx(v.Controller,{name:"content",control:l,render:({field:p})=>n.jsx(gt,{initialValue:p.value,onChange:p.onChange,label:a("rich_text.content.label")},`${r.id}.content.label`)})]})})});function _C(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(vC,{conf:t,setConf:r}):null}const mC=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],wC={createConfig(){return{version:5,config:rC}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new uC,name:"stats",viewRender:yC,configRender:_C,triggers:[Pl],translation:mC},Hr={label_key:"",value_key:"",group_key:"",unit:K(),levels:[]};function xC(e){const t=new Set(e.map(a=>a.parent_id)),r=new Set(e.map(a=>a.id));return t.forEach(a=>{a===null||r.has(a)||e.push({id:a,name:a,parent_id:null})}),e}function CC(e){const t=xC(e).map(o=>({...o,children:[]})),r=y.keyBy(t,o=>o.id),a=[];return t.forEach(o=>{if(!o.parent_id||!r[o.parent_id]){a.push(o);return}r[o.parent_id].children.push(o)}),a}function SC(e,t){const{label_key:r,value_key:a,group_key:o}=e;if(!r||!a)return[];const l=$(r),i=$(a),c=$(o),d=t[l.queryID].map(u=>({...u,id:u[l.columnKey],parent_id:u[c.columnKey],name:u[l.columnKey],value:u[i.columnKey]?Number(u[i.columnKey]):u[i.columnKey]}));return o?CC(d):d}const TC=e=>({treePathInfo:t,name:r,value:a})=>{if(t.length===1||!e)return r;try{const o=t[t.length-2].value;if(a/o<e)return" "}catch{return r}};function kC(e){const{levels:t}=e;return t.map(r=>{const{show_label_tolerance:a,...o}=r.label;return{...r,label:{...o,formatter:TC(a)}}})}function DC(e){return({treePathInfo:t,name:r,value:a,color:o,marker:l,...i})=>{const c=t.slice(0,t.length-1),d=[`<tr>
|
|
507
|
+
`}})}function M1(e,t){const r=t.every(c=>!Number.isNaN(Number(c))),{overflow:a,...o}=e.x_axis.axisLabel,l=Ke(a.on_axis),i=t.length===0;return[X.getXAxis({data:t,name:e.x_axis.name??"",nameGap:i?5:void 0,id:"main-x-axis",type:r?"value":"category",axisLabel:{...o,...l,formatter:Me(o.formatter)}})]}function I1(e,t){return e.y_axes.map(({nameAlignment:r,min:a,max:o,...l},i)=>{let c=l.position;return c||(c=i>0?"right":"left"),X.getYAxis({...l,minInterval:1,min:a||void 0,max:o||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:t[i]??t.default},nameTextStyle:{align:r},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const V1={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function P1(e,t,r){const a=r.reduce((d,u)=>{const p=He(u,t);return d[u.name]=Be(u,p),d},{}),o=e.y_axes.reduce((d,{label_formatter:u},p)=>(d[p]=function(b){let _=b;if(typeof b=="object"&&(Array.isArray(b.value)&&b.value.length===2?_=b.value[1]:_=b.value),!u)return _;try{return Y(_,u)}catch(w){return console.error(w),_}},d),{default:({value:d})=>d}),l=y.uniq(me(t,e.x_axis.data_key)),i=T1(e,t,r,a),c={xAxis:M1(e,l),yAxis:I1(e,o),series:i,dataset:y1(e,t),tooltip:z1(e,o),grid:v1(e),legend:_1(),dataZoom:_n(e.dataZoom)};return y.defaultsDeep({},c,V1)}function $1({conf:e,data:t,width:r,height:a,interactionManager:o,variables:l,instance:i}){const c=Dt(t,e.x_axis.data_key),d=Ve(o.triggerManager,Il.id),u=h.useCallback(x=>{const S=x.data;d.forEach(D=>{o.runInteraction(D.id,{...x,rowData:S})})},[c,d,o]),p=h.useRef(null),g=H(),b=h.useCallback(()=>{var z;const x=(z=p.current)==null?void 0:z.getEchartsInstance();if(!x)return;const S=ft(e.stats.top,l,g.payloadForViz,t),D=ft(e.stats.bottom,l,g.payloadForViz,t);fe(i,{...x.getOption(),statsAboveViz:S,statsBelowViz:D})},[i]),_=h.useMemo(()=>({click:u,finished:b}),[u,b]),w=h.useMemo(()=>P1(e,t,l),[e,t]);return n.jsx(he,{echarts:ce,option:w,ref:p,style:{width:r,height:a},onEvents:_,notMerge:!0,theme:"merico-light"})}function A1({context:e,instance:t}){const r=Pe({vizManager:e.vizManager,instance:t}),{value:a}=q(e.instanceData,"config"),{variables:o}=e,l=h.useMemo(()=>y.defaults({},a,Ml),[a]),i=e.data,{width:c,height:d}=e.viewport,[u,p]=h.useState(0),[g,b]=h.useState(0),_=Math.max(0,Oe(d)-u-g),w=qe(c);return!c||!d?null:n.jsxs(ve,{width:c,height:d,children:[n.jsx(zt,{onHeightChange:p,value:l.stats.top,context:e}),n.jsx($1,{instance:t,variables:o,width:w,height:_,data:i,conf:l,interactionManager:r}),n.jsx(zt,{onHeightChange:b,value:l.stats.bottom,context:e})]})}const E1=h.forwardRef(({value:e,onChange:t,xAxisOptions:r,yAxisOptions:a,variableOptions:o},l)=>{const{t:i,i18n:c}=m.useTranslation(),d=(u,p)=>{const g=y.cloneDeep(e);y.set(g,u,p),t(g)};return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.reference_area.content.label"),labelPosition:"right"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.TextInput,{label:i("chart.reference_area.content.content_text"),value:e.content.text,onChange:u=>d("content.text",u.currentTarget.value)}),n.jsx(Ot,{label:i("chart.reference_area.content.text_position"),value:e.label.position,onChange:u=>d("label.position",u)})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.reference_area.endpoint.labels"),labelPosition:"right"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[r&&n.jsx(s.Select,{label:i("chart.x_axis.label"),data:r,value:e.xAxisIndex,onChange:u=>d("xAxisIndex",u)}),a&&n.jsx(s.Select,{label:i("chart.y_axis.label"),data:a,value:e.yAxisIndex,onChange:u=>d("xAxisIndex",u)})]}),n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"14px",c:"#212529",fw:500,children:i("chart.reference_area.endpoint.left_bottom_point")}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"x"}),data:o,value:e.leftBottomPoint.x_data_key,onChange:u=>d("leftBottomPoint.x_data_key",u??""),clearable:!0}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"y"}),data:o,value:e.leftBottomPoint.y_data_key,onChange:u=>d("leftBottomPoint.y_data_key",u??""),clearable:!0})]})]}),n.jsxs(s.Stack,{gap:0,children:[n.jsx(s.Text,{size:"14px",c:"#212529",fw:500,children:i("chart.reference_area.endpoint.right_top_point")}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"x"}),data:o,value:e.rightTopPoint.x_data_key,onChange:u=>d("rightTopPoint.x_data_key",u??""),clearable:!0}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{size:"sm",children:"y"}),data:o,value:e.rightTopPoint.y_data_key,onChange:u=>d("rightTopPoint.y_data_key",u??""),clearable:!0})]})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:i("chart.style.label"),labelPosition:"right"}),n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(ye,{label:i("chart.color.background_color"),value:e.itemStyle.color,onChange:u=>d("itemStyle.color",u)}),n.jsx(ye,{label:i("chart.color.text_color"),value:e.label.color,onChange:u=>d("label.color",u)})]})]})});function B1(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function q1({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>B1(),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("y_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>p+1;return n.jsx(R,{control:e,watch:t,name:"reference_areas",getItem:o,addButtonText:a("chart.reference_area.add"),deleteButtonText:a("chart.reference_area.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx(v.Controller,{name:`reference_areas.${p}`,control:e,render:({field:g})=>n.jsx(s.Stack,{children:n.jsx(E1,{variableOptions:l,yAxisOptions:c,...g})})})})}function O1({control:e,index:t,watch:r,variableOptions:a,yAxisOptions:o}){const{t:l}=m.useTranslation(),i=r(`reference_lines.${t}.orientation`);return n.jsxs(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("common.name"),placeholder:l("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>n.jsx(s.Select,{label:l("common.data_field"),required:!0,data:a,sx:{flex:1},...c})})]}),n.jsx(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>n.jsx(s.TextInput,{label:l("chart.content_template.label"),placeholder:l("chart.content_template.hint"),sx:{flex:1},...c})}),n.jsxs(s.Group,{grow:!0,children:[n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>n.jsx(bt,{sx:{flex:1},...c})}),i==="vertical"&&n.jsx(s.Text,{mt:-10,c:"dimmed",size:"12px",children:l("chart.reference_line.orientation.vertical_hint")})]}),i==="horizontal"&&n.jsx(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:d,...u}})=>n.jsx(s.Select,{label:"Y Axis",data:o,disabled:o.length===0,...u,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:l("chart.style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>n.jsx(qt,{sx:{flexGrow:1},...c})}),n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>n.jsx(s.NumberInput,{label:l("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),n.jsx(s.SimpleGrid,{cols:2,children:n.jsx(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>n.jsx(ye,{label:l("chart.color.label"),...c})})})]})}function L1({control:e,watch:t,variables:r}){const{t:a}=m.useTranslation(),o=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Ge.random().css()},show_in_legend:!1,yAxisIndex:0}),l=h.useMemo(()=>r.map(u=>({label:u.name,value:u.name})),[r]),i=t("y_axes"),c=h.useMemo(()=>i.map(({name:u},p)=>({label:u,value:p.toString()})),[i]),d=(u,p)=>{const g=u.name.trim();return g||p+1};return n.jsx(R,{control:e,watch:t,name:"reference_lines",getItem:o,addButtonText:a("chart.reference_line.add"),deleteButtonText:a("chart.reference_line.delete"),renderTabName:d,children:({field:u,index:p})=>n.jsx(O1,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:c})})}const N1=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},G1=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e),d=()=>{l();const{type:b,func_content:_}=i,w={type:b,func_content:_};c(w),t(w)},u=()=>{l(),c(e)},p=b=>{c(_=>({..._,func_content:b}))},g=()=>{p(Jt.dynamic.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{sx:{width:"50%"},children:n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("viz.scatter_chart.color.dynamic.setup")})}),n.jsx(s.Modal,{size:800,title:r("viz.scatter_chart.color.dynamic.setup_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(N1,{value:i.func_content,onChange:p}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:u,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})},F1=({value:e,onChange:t})=>e.type!=="dynamic"?null:n.jsx(G1,{value:e,onChange:t}),Q1=({value:e,onChange:t})=>{if(e.type!=="static")return null;const r=a=>{t({...e,color:a})};return n.jsx(s.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:r})},j1=h.forwardRef(({label:e="Color",value:t,onChange:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("viz.scatter_chart.color.type.static"),value:"static"},{label:o("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[l.language]),c=d=>{d!=="static"&&d!=="dynamic"||r({...Jt[d]})};return n.jsxs(s.SimpleGrid,{cols:2,children:[n.jsx(s.Select,{ref:a,label:e,data:i,value:t.type,onChange:c,sx:{flexGrow:1}}),n.jsx(Q1,{value:t,onChange:r}),n.jsx(F1,{value:t,onChange:r})]})}),W1=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),o=i=>{t({...e,label:i})},l=i=>{t({...e,tooltip:i})};return n.jsxs(s.Stack,{ref:r,gap:0,children:[n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:o}),n.jsx(yn,{sectionTitle:a("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:l})]})});function U1({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["scatter"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"scatter.name_data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.name_data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"scatter.y_data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.value_data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"scatter.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"scatter.symbolSize",control:e,render:({field:a})=>n.jsx(Nr,{...a})}),n.jsx(v.Controller,{name:"scatter.color",control:e,render:({field:a})=>n.jsx(j1,{...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.label.label"),labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:"scatter.label_position",control:e,render:({field:a})=>n.jsx(Ot,{label:r("chart.label_position.label"),withOffOption:!0,...a,onChange:o=>{a.onChange(o??"")}})})}),n.jsx(v.Controller,{name:"scatter.label_overflow",control:e,render:({field:a})=>n.jsx(W1,{...a})})]})}const K1=k.observer(({control:e,watch:t})=>{const{panel:r}=ae(),{t:a}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"stats.top",control:e,render:({field:o})=>n.jsx(gt,{initialValue:o.value,onChange:o.onChange,label:a("chart.stats.template.above_chart")},`${r.id}.stats.top`)}),n.jsx(v.Controller,{name:"stats.bottom",control:e,render:({field:o})=>n.jsx(gt,{initialValue:o.value,onChange:o.onChange,label:a("chart.stats.template.under_chart")},`${r.id}.stats.bottom`)})]})}),Y1=({control:e,index:t})=>{const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:`tooltip.metrics.${t}.unit`,control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})},X1=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),data_key:"",name:"",unit:K()}),o=(l,i)=>{const c=l.name.trim();return c||i+1};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("chart.tooltip.additional_metrics.description")})]}),n.jsx(R,{control:e,watch:t,name:"tooltip.metrics",getItem:a,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx(Y1,{control:e,index:i})})]})};function Z1({control:e,watch:t}){const{t:r,i18n:a}=m.useTranslation();t("tooltip.trigger");const o=h.useMemo(()=>[{label:r("chart.tooltip.trigger.scatter_point"),value:"item"},{label:r("chart.tooltip.trigger.x_axis"),value:"axis"}],[a.language]);return n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"tooltip.trigger",control:e,render:({field:l})=>n.jsx(s.Select,{label:r("chart.tooltip.trigger.label"),data:o,sx:{flexGrow:1},...l})}),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(X1,{control:e,watch:t})]})}function J1({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["x_axis"]),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.data_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.data_field"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"x_axis.name",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),sx:{flex:1},...a})})]}),n.jsx(v.Controller,{name:"x_axis.unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})}),n.jsx(s.Divider,{mb:-15,label:r("chart.axis.tick_label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>n.jsx(st,{sx:{width:"48%"},...a})}),n.jsx(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>n.jsx(Re,{...a})})]}),n.jsx(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>n.jsx(et,{...a})})]})}function H1({control:e,index:t}){const{t:r}=m.useTranslation();return n.jsxs(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[n.jsx(s.Divider,{mb:-15,mt:15,variant:"dashed",label:r("chart.y_axis.y_axis_name"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("common.name"),required:!0,sx:{flex:1},...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:a})=>n.jsx(yt,{sx:{flex:1},...a})})]}),n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.layout"),labelPosition:"center"}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:a})=>n.jsx(al,{sx:{flex:1},...a})})}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.label_format"),labelPosition:"center"}),n.jsx(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:a})=>n.jsx(Ne,{...a})})]}),n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mb:-15,variant:"dashed",label:r("chart.y_axis.value_range"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_min"),...a})}),n.jsx(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("chart.y_axis.value_max"),...a})})]})]})]})}function R1({control:e,watch:t}){const{t:r}=m.useTranslation(),a=()=>({name:"",label_formatter:de,min:"",max:"",show:!0,position:"right",nameAlignment:"right",mirror:!1}),o=(i,c)=>{const d=i.name.trim();return d||c+1},l=({field:i,index:c,fields:d})=>d.length<=1;return n.jsx(R,{control:e,watch:t,name:"y_axes",getItem:a,addButtonText:r("chart.y_axis.add"),deleteButtonText:r("chart.y_axis.delete"),renderTabName:o,deleteDisalbed:l,children:({field:i,index:c})=>n.jsx(H1,{control:e,index:c})})}function eC({conf:e,setConf:t,context:r}){const{t:a}=m.useTranslation(),{variables:o}=r,l=h.useMemo(()=>y.defaults({},e),[e]),{control:i,handleSubmit:c,watch:d,reset:u,formState:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{u(l)},[l]),d(["dataZoom"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(t),children:[n.jsx(se,{canSubmit:p.isDirty}),n.jsxs(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"X Axis",children:a("chart.x_axis.label")}),n.jsx(s.Tabs.Tab,{value:"Y Axes",children:a("chart.y_axis.labels")}),n.jsx(s.Tabs.Tab,{value:"Scatter",children:a("chart.series.scatter.label")}),n.jsx(s.Tabs.Tab,{value:"Tooltip",children:a("chart.tooltip.label")}),n.jsx(s.Tabs.Tab,{value:"Stats",children:a("chart.stats.label")}),n.jsx(s.Tabs.Tab,{value:"Reference Lines",children:a("chart.reference_line.labels")}),n.jsx(s.Tabs.Tab,{value:"Reference Areas",children:a("chart.reference_area.labels")}),n.jsx(s.Tabs.Tab,{value:"Zooming",children:a("chart.zooming.label")})]}),n.jsx(s.Tabs.Panel,{value:"X Axis",children:n.jsx(J1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Y Axes",children:n.jsx(R1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Scatter",children:n.jsx(U1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Tooltip",children:n.jsx(Z1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Stats",children:n.jsx(K1,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Lines",children:n.jsx(L1,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Reference Areas",children:n.jsx(q1,{variables:o,control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Zooming",children:n.jsx(v.Controller,{name:"dataZoom",control:i,render:({field:g})=>n.jsx(mn,{...g})})})]})]})})}function tC(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(eC,{conf:t,setConf:r,...e}):null}const nC={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new h1,name:"scatterChart",viewRender:A1,configRender:tC,createConfig(){return{version:13,config:y.cloneDeep(Ml)}},triggers:[Il],translation:g1},rC={content:"Use double curly brackets to wrap js code: {{ new Date().getTime() }}",vertical_align:"center"};function aC(e){if("variables"in e)return e;const{align:t,size:r,weight:a,color:o,content:{prefix:l="",data_field:i="value",formatter:c={output:"number",mantissa:0},postfix:d=""}={}}=e;return{align:t,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:i,aggregation:{type:"none",config:{}},formatter:c,color:o,weight:a,size:r}]}}function sC(e){return y.omit(e,["variables"])}function oC(e){const{align:t,...r}=e;return{horizontal_align:t,vertical_align:"center",...r}}function lC(e){const t=y.cloneDeep(e),r=y.get(t,"color.valueRange");return r!==void 0&&y.set(t,"color.valueRange",r.map(a=>Number(a))),t}function iC(e,t){return!t||t==="left"?e:`<p style="text-align: ${t}">${e}</p>`}function cC(e,t){const{horizontal_align:r,template:a,...o}=e;let l=At(a,t);return l=iC(l,r),{content:l,...o}}function dC(e,t){const{content:r,...a}=e;return{content:At(r,t),...a}}class uC extends J{constructor(){super(...arguments);V(this,"VERSION",5)}configVersions(){this.version(1,r=>({version:1,config:aC(r)})),this.version(2,(r,{panelModel:a})=>{const{config:o}=r;return(o.variables||[]).forEach(i=>{a.variables.find(c=>c.name===i.name)||a.addVariable(lC(i))}),{...r,version:2,config:sC(o)}}),this.version(3,r=>{const{config:a}=r;return{...r,version:3,config:oC(a)}}),this.version(4,(r,{panelModel:a})=>{const{config:o}=r;return{...r,version:4,config:cC(o,a)}}),this.version(5,(r,{panelModel:a})=>{const{config:o}=r;return{...r,version:5,config:dC(o,a)}})}}const Pl={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:hC,configRender:pC,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function pC(e){return n.jsx(n.Fragment,{})}function hC(e){const{t}=m.useTranslation();return n.jsx(s.Text,{size:"sm",children:t("viz.stats.click_stats.trigger")})}const $l={top:"flex-start",center:"center",bottom:"flex-end"},gC={top:"top center",center:"center center",bottom:"bottom center"};function fC(e){const t={flexGrow:1};return e>0&&(t.cursor="pointer",t["&:hover"]={textDecoration:"underline"}),t}const bC=k.observer(({context:e,instance:t})=>{const r=h.useRef(null),a=Pe({vizManager:e.vizManager,instance:t}),o=Ve(a.triggerManager,Pl.id),l=H(),{panel:i}=re(),c=i.viz.conf.config,{data:d,variables:u}=e,{width:p,height:g}=e.viewport,b=h.useMemo(()=>{const w=i.viz.conf.config;return w.content?ft(w.content,u,l.payloadForViz,d):""},[d,i,u,l.payloadForViz]);h.useEffect(()=>{fe(t,{content:b})},[b]);const _=h.useCallback(()=>{o.forEach(w=>{a.runInteraction(w.id,{variables:i.variableValueMap})})},[i.variableValueMap,o,a]);return h.useEffect(()=>{if(!r.current)return;const w=r.current.querySelector(".ProseMirror");if(!w)return;const{offsetWidth:x,offsetHeight:S}=w,D=p/x,z=g/S,I=Math.min(D,z);w.style.transform=`scale(${I})`},[r.current,p,g,b]),n.jsx(s.Flex,{className:"viz-stats",sx:{width:p,height:g},align:$l[c.vertical_align],direction:"row",children:n.jsx(s.Box,{className:"viz-stats--clickable-wrapper",sx:fC(o.length),onClick:_,children:n.jsx($t,{ref:r,value:b,styles:{root:{border:"none",maxWidth:p,maxHeight:g,"&.mantine-RichTextEditor-root":{overflow:"hidden !important"}},content:{height:g,display:"flex",flexDirection:"column",justifyContent:$l[c.vertical_align],"&.mantine-RichTextEditor-content .ProseMirror":{margin:"0 auto",padding:0,display:"table",width:"auto",height:"auto",maxWidth:"100%",maxHeight:"100%",transformOrigin:gC[c.vertical_align]},"&.mantine-RichTextEditor-content .ProseMirror > p":{fontSize:"initial",lineHeight:"initial"}}},dashboardStateValues:l.dashboardStateValues,variableAggValueMap:i.variableAggValueMap})})})}),yC=e=>{const{context:t}=e,{value:r}=q(t.instanceData,"config");return r?n.jsx(bC,{...e}):null},vC=k.observer(({conf:e,setConf:t})=>{const{panel:r}=ae(),{t:a}=m.useTranslation(),o=h.useMemo(()=>y.defaults({},e),[e]),{control:l,handleSubmit:i,watch:c,formState:d,reset:u}=v.useForm({defaultValues:o});return h.useEffect(()=>{u(o)},[o]),c(["content","vertical_align"]),n.jsx("form",{onSubmit:i(t),children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(se,{canSubmit:d.isDirty}),n.jsx(v.Controller,{control:l,name:"vertical_align",render:({field:p})=>n.jsx(jo,{...p})}),n.jsx(v.Controller,{name:"content",control:l,render:({field:p})=>n.jsx(gt,{initialValue:p.value,onChange:p.onChange,label:a("rich_text.content.label")},`${r.id}.content.label`)})]})})});function _C(e){const{value:t,set:r}=q(e.context.instanceData,"config");return t?n.jsx(vC,{conf:t,setConf:r}):null}const mC=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],wC={createConfig(){return{version:5,config:rC}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new uC,name:"stats",viewRender:yC,configRender:_C,triggers:[Pl],translation:mC},Rr={label_key:"",value_key:"",group_key:"",unit:K(),levels:[]};function xC(e){const t=new Set(e.map(a=>a.parent_id)),r=new Set(e.map(a=>a.id));return t.forEach(a=>{a===null||r.has(a)||e.push({id:a,name:a,parent_id:null})}),e}function CC(e){const t=xC(e).map(o=>({...o,children:[]})),r=y.keyBy(t,o=>o.id),a=[];return t.forEach(o=>{if(!o.parent_id||!r[o.parent_id]){a.push(o);return}r[o.parent_id].children.push(o)}),a}function SC(e,t){const{label_key:r,value_key:a,group_key:o}=e;if(!r||!a)return[];const l=$(r),i=$(a),c=$(o),d=t[l.queryID].map(u=>({...u,id:u[l.columnKey],parent_id:u[c.columnKey],name:u[l.columnKey],value:u[i.columnKey]?Number(u[i.columnKey]):u[i.columnKey]}));return o?CC(d):d}const TC=e=>({treePathInfo:t,name:r,value:a})=>{if(t.length===1||!e)return r;try{const o=t[t.length-2].value;if(a/o<e)return" "}catch{return r}};function kC(e){const{levels:t}=e;return t.map(r=>{const{show_label_tolerance:a,...o}=r.label;return{...r,label:{...o,formatter:TC(a)}}})}function DC(e){return({treePathInfo:t,name:r,value:a,color:o,marker:l,...i})=>{const c=t.slice(0,t.length-1),d=[`<tr>
|
|
508
508
|
<th style="text-align: right; padding: 0 1em;">Value</th>
|
|
509
509
|
<td style="text-align: left; padding: 0 2px 0 1em;">${a}</td>
|
|
510
510
|
<th style="text-align: left; padding: 0;">
|
|
@@ -525,10 +525,10 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
525
525
|
<table style="width: auto">
|
|
526
526
|
<tbody>${d.join("")}</tbody>
|
|
527
527
|
</table>
|
|
528
|
-
`}}function zC(e){const t=e.unit.show_in_tooltip?e.unit.text:"";return X.getTooltip({trigger:"item",formatter:DC(t)})}const MC={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function IC(e,t,r){r.reduce((l,i)=>{const c=He(i,t);return l[i.name]=Be(i,c),l},{});const o={series:{data:SC(e,t),levels:kC(e)},tooltip:zC(e)};return y.defaultsDeep({},o,MC)}function VC({context:e,instance:t}){const{variables:r}=e,{value:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaults({},a,
|
|
529
|
-
`),Bl={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px",pagination:Al()};function jC(e){const{columns:t,...r}=e;return{...e,columns:t.map(a=>({...a,align:a.align??"left"}))}}function WC(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{id_field:o,columns:l,...i}=e;return{...i,id_field:a(o),columns:l.map(c=>({...c,value_field:a(c.value_field)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function UC(e){const{columns:t,...r}=e;return{...r,columns:t.map(a=>({...a,align:a.align??"left",cellBackgroundColor:a.cellBackgroundColor??"",width:a.width??""}))}}function KC(e){const{id_field:t,...r}=e,{queryID:a}=$(t);return{...r,query_id:a??""}}function YC(e){const{ignored_column_keys:t,...r}=e;return{...r,ignored_column_keys:t??""}}function XC(e){const{pagination:t=Al(),...r}=e;return{...r,pagination:t}}class ZC extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{columns:a,...o}=r.config;return{...r,version:2,config:{...o,columns:a.map(({id:l,...i})=>({id:l??te.randomId(),...i}))}}}),this.version(3,r=>({...r,version:3,config:jC(r.config)})),this.version(4,(r,a)=>({...r,version:4,config:WC(r.config,a)})),this.version(5,r=>({...r,version:5,config:UC(r.config)})),this.version(6,r=>({...r,version:6,config:KC(r.config)})),this.version(7,r=>({...r,version:7,config:YC(r.config)})),this.version(8,r=>({...r,version:8,config:XC(r.config)}))}}const ql={left:"flex-start",center:"center",right:"flex-end"},JC=({header:e,cx:t})=>{const r=y.get(e.column.columnDef.meta,"align","left");return n.jsxs(s.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),ta:r,sx:{justifyContent:ql[r]},size:"sm",children:[e.isPlaceholder?null:ge.flexRender(e.column.columnDef.header,e.getContext()),n.jsx(HC,{direction:e.column.getIsSorted()})]})},HC=({direction:e})=>{switch(e){case"asc":return n.jsx(T.IconArrowUp,{size:16});case"desc":return n.jsx(T.IconArrowDown,{size:"1em"});default:return null}},RC=pt.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colors.gray[0]}}},thead:{background:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),eS={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},Ol=pt.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:ql[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function tS(e){return e?Ge(e).oklch()[0]>.7?"black":"white":"inherit"}function Ll(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:tS(t)}}function Lt(e){const t=e.tableCellContext.isClickable(),r=Ol({clickable:t,align:e.align});return n.jsx("div",{className:r.classes.content,style:{...Ll(e)},children:n.jsx(s.Text,{size:"sm",className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:n.jsx("span",{title:e.children,children:e.children})})})}function nS(e){return n.jsx(Lt,{...e,children:e.value})}function rS(e){const t=Ol({clickable:!0,align:e.align}),r=e.value;return n.jsx("div",{className:t.classes.content,style:{...Ll(e)},children:n.jsx(s.Anchor,{className:"table-cell-text",href:r,target:"_blank",color:"black",children:r})})}function aS(e){const t=Y(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function sS(e){const t=Y(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function oS(e){const t=Y(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function lS(e){const{value:t,row_data:r,func_content:a}=e;if(!a)return n.jsx(Lt,{...e,children:t});const o=new Function(`return ${a}`)()({value:t,row_data:r},We);return n.jsx(Lt,{...e,children:o})}function iS(e){switch(e.type){case Ye.string:return n.jsx(nS,{...e});case Ye.eloc:return n.jsx(aS,{...e});case Ye.number:return n.jsx(sS,{...e});case Ye.percentage:return n.jsx(oS,{...e});case Ye.url:return n.jsx(rS,{...e});case Ye.custom:return n.jsx(lS,{...e})}}function cS({tableContainerRef:e,rows:t}){var c,d;const r=Hd.useVirtualizer({getScrollElement:()=>e.current,count:t.length,estimateSize:h.useCallback(()=>28,[]),overscan:20}),a=r.getVirtualItems(),o=r.getTotalSize(),l=a.length>0&&((c=a==null?void 0:a[0])==null?void 0:c.start)||0,i=a.length>0?o-(((d=a==null?void 0:a[a.length-1])==null?void 0:d.end)||0):0;return n.jsxs(s.Table.Tbody,{children:[l>0&&n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{style:{height:`${l}px`}})}),a.map(u=>{const p=t[u.index];return n.jsx(s.Table.Tr,{children:p.getVisibleCells().map(g=>n.jsx(s.Table.Td,{children:ge.flexRender(g.column.columnDef.cell,g.getContext())},g.id))},p.id)}),i>0&&n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{style:{height:`${i}px`}})})]})}const Rr={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:hS,configRender:uS,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},dS={column:""};function Nl(e,t){const{value:r}=q(e.instanceData,"config"),a={columnsFromConfig:[],columnsFromData:[]};if(r&&(a.columnsFromConfig=r.columns.map((o,l)=>({label:o.label,value:l.toString()}))),!t)return a;if(r!=null&&r.query_id){const o=t[r.query_id];(o==null?void 0:o.length)>0&&(a.columnsFromData=Object.keys(o[0]).map(l=>({label:l,value:l})))}return a}function Gl(e){const{value:t}=q(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function uS(e){const{t}=m.useTranslation(),{columnsFromConfig:r,columnsFromData:a}=Nl(e.instance,e.sampleData),o=Gl(e.instance),l=r.length>0?r:a,{value:i,set:c}=q(e.trigger.triggerData,"config"),{column:d}=y.defaults({},i,dS),u=p=>{p&&(isNaN(+p)?c({column:p}):c({column:+p}))};return o?n.jsxs(s.Stack,{children:[n.jsx(s.Alert,{icon:n.jsx(T.IconAlertCircle,{size:"1rem"}),color:"gray",children:n.jsxs(m.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",n.jsx(s.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),n.jsx(s.TextInput,{label:t("viz.table.click_cell.column_data_field"),value:d.toString(),onChange:p=>u(p.currentTarget.value)})]}):n.jsx(s.Select,{clearable:!1,data:l,label:t("viz.table.click_cell.choose_a_column"),value:d.toString(),onChange:u,comboboxProps:{zIndex:340},maxDropdownHeight:500})}function pS(e,t,r){const{t:a}=m.useTranslation();if(!e)return a("viz.table.click_cell.click_cell_content");if(y.isNumber(e.column)){if(r)return a("viz.table.click_cell.click_cell_of_x_th",{x:e.column+1});const o=t[e.column];return o?a("viz.table.click_cell.click_cell_of_x",{x:o.label}):a("viz.table.click_cell.click_cell_invalid_config")}return a("viz.table.click_cell.click_cell_of_x",{x:e.column})}function hS(e){const{columnsFromConfig:t}=Nl(e.instance),{value:r}=q(e.trigger.triggerData,"config"),a=Gl(e.instance);return n.jsx(s.Text,{size:"sm",children:pS(r,t,a)})}function Fl(e,t,r){return Math.min(Math.max(e,t),r)}class gS{constructor(t){this.steps=t;const r=[],a=new Set;for(const o of t)a.has(o.to)||(r.push(o),a.add(o.to));if(r.sort((o,l)=>o.from-l.from),r.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=r}getLinearFunction(t,r){const a=(r.to-t.to)/(r.from-t.from),o=t.to-a*t.from;return l=>a*l+o}getStepFunctionForValue(t){let r=y.findLastIndex(this.steps,a=>a.from<=t);return r=Fl(r,0,this.steps.length-2),this.getLinearFunction(this.steps[r],this.steps[r+1])}mapValue(t){return Fl(this.getStepFunctionForValue(t)(t),0,100)}}class fS{constructor(t,r,a,o,l){this.getColIndex=t,this.cell=r,this.triggers=a,this.interactionManager=o,this.colorManager=l}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const r={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const a of t)this.interactionManager.runInteraction(a.id,r)}}getRelatedTrigger(){return this.triggers.filter(r=>r.schemaRef===Rr.id).filter(r=>{const a=this.getColIndex(this.cell),o=y.get(this.cell.column.columnDef.meta,"value_field"),l=y.get(r.config,"column");return l==a||l==o})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(y.isString(t))return t;const r=+this.cell.getValue();if(isFinite(r)){const a=this.colorManager.decodeInterpolation(t.interpolation),l=new gS(t.steps).mapValue(r);return a==null?void 0:a.getColor(l)}}}const bS=e=>{const t=Pe(e),r=Ve(t.triggerManager,Rr.id),{colorManager:a}=h.useContext(ot);return h.useCallback(o=>new fS(e.getColIndex,o,r,t,a),[r,t,e.getColIndex])},yS=({classes:e,pagination:t,setPagination:r,pageCount:a,totalRows:o})=>{const{t:l}=m.useTranslation(),{pageSize:i,pageIndex:c}=t;if(o===0)return null;if(i===0)return n.jsx(s.Box,{className:e.info_bar,sx:{height:22},children:n.jsx(s.Text,{ta:"right",pr:6,size:"14px",c:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:o})})});const d=()=>{r({...t,pageIndex:c-1})},u=()=>{r({...t,pageIndex:c+1})};return n.jsxs(s.Group,{wrap:"nowrap",justify:"flex-end",gap:4,className:e.info_bar,sx:{height:22},children:[n.jsx(s.Text,{ta:"right",pr:6,size:"14px",c:"dimmed",fw:"normal",children:l("common.pagination.showing_rows",{start_row:c*i+1,end_row:(c+1)*i,total:o})}),n.jsx(s.ActionIcon,{variant:"default","aria-label":"to previous page",onClick:d,size:"xs",disabled:c===0,children:n.jsx(T.IconChevronLeft,{})}),n.jsx(s.ActionIcon,{variant:"default","aria-label":"to next page",onClick:u,size:"xs",disabled:c===a-1,children:n.jsx(T.IconChevronRight,{})})]})};function Ql({queryData:e,width:t,height:r,conf:a,context:o,instance:l}){m.useTranslation();const{use_raw_columns:i,ignored_column_keys:c,columns:d,...u}=a,{classes:p,cx:g}=RC(),b=h.useMemo(()=>{if(!i)return d;if(!Array.isArray(e)||e.length===0)return[];let Ae=Object.keys(e[0]);const xe=new Set(c==null?void 0:c.split(/\r?\n|\r|\n/g).filter(pe=>!!pe));return xe.size>0&&(Ae=Ae.filter(pe=>!xe.has(pe))),Ae.map(pe=>({id:pe,label:pe,value_field:pe,value_type:Ye.string,align:"left",width:"",cellBackgroundColor:""}))},[i,c,d,e]),_=bS({getColIndex:h.useCallback(Ae=>b.indexOf(Ae.column.columnDef.meta),[b]),vizManager:o.vizManager,instance:l}),w=h.useMemo(()=>{const Ae=ge.createColumnHelper();return b.map(pe=>{const BM=up(pe.value_field);return Ae.accessor(BM.columnKey,{cell:bs=>n.jsx(iS,{tableCellContext:_(bs.cell),value:bs.getValue(),type:pe.value_type,row_data:bs.row.original,...pe}),header:pe.label,enableSorting:!0,meta:pe,size:typeof pe.width=="number"?pe.width:void 0,minSize:typeof pe.width=="number"?pe.width:void 0})})},[b,_]),[x,S]=h.useState([]),[D,z]=h.useState({pageIndex:0,pageSize:a.pagination.page_size}),I=h.useMemo(()=>{const{pageIndex:Ae,pageSize:xe}=D;return xe===0?e:e.slice(Ae*xe,(Ae+1)*xe)},[e,D]),A=Math.ceil(e.length/D.pageSize),E=ge.useReactTable({data:I,state:{sorting:x},onSortingChange:S,columns:w,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel(),getSortedRowModel:ge.getSortedRowModel()}),{rows:U}=E.getRowModel(),N=h.useRef(null),oe=e.length,be=oe>0,ct=be?r-22:r,mt=be?22:0;return n.jsxs("div",{ref:N,style:{height:r,width:t,padding:"0 5px"},"data-enable-scrollbar":!0,className:g(p.root,{"table-highlight-on-hover":a.highlightOnHover}),children:[n.jsx(yS,{classes:p,pagination:D,totalRows:oe,setPagination:z,pageCount:A}),n.jsxs(s.Table,{sx:{...eS,maxHeight:ct},...u,striped:a.striped,children:[n.jsx(s.Table.Thead,{className:p.thead,style:{top:mt},children:E.getHeaderGroups().map(Ae=>n.jsx(s.Table.Tr,{children:Ae.headers.map(xe=>n.jsxs(s.Table.Th,{style:{width:xe.getSize()},children:[n.jsx(JC,{header:xe,cx:g}),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:xe.getResizeHandler(),onTouchStart:xe.getResizeHandler(),className:`resizer ${xe.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},xe.id))},Ae.id))}),n.jsx(cS,{tableContainerRef:N,rows:U})]})]})}function jl(){const{t:e}=m.useTranslation();return n.jsx(s.Text,{size:"sm",c:"gray",ta:"center",children:e("data.empty_data")})}function vS({data:e,width:t,height:r,conf:a,context:o,instance:l}){const{t:i}=m.useTranslation(),{panel:c}=re(),d=c.firstQueryData??[];if(c.queryIDs.length===0)return n.jsx(s.Text,{size:"sm",c:"gray",ta:"center",children:i("panel.settings.need_to_choose_queries")});const{query_id:u}=a;if(!u)return d.length===0?n.jsx(jl,{}):n.jsx(Ql,{queryData:d,width:t,height:r,conf:{...a,use_raw_columns:!0,columns:[]},context:o,instance:l});const p=e[u];return!Array.isArray(p)||p.length===0?n.jsx(jl,{}):n.jsx(Ql,{queryData:p,width:t,height:r,conf:a,context:o,instance:l})}function _S({context:e,instance:t}){const r=e.data,{height:a,width:o}=e.viewport,{value:l}=q(e.instanceData,"config");return l?n.jsx(vS,{data:r,width:o,height:a,conf:l,context:e,instance:t}):null}const mS=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",add:"Add a column",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",click_cell_invalid_config:"Invalid config",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",add:"加一列",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",click_cell_invalid_config:"配置信息已失效",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}],wS=k.observer(h.forwardRef(({label:e,required:t,description:r,value:a,onChange:o,clearable:l=!1,sx:i,...c},d)=>{const{panel:u}=ae(),p=h.useMemo(()=>u.queryOptions(a,l),[a,l]);return p.length===0?n.jsx(s.Box,{children:n.jsx(s.TextInput,{label:e,required:t,defaultValue:a,readOnly:!0,disabled:!0})}):n.jsx(s.Select,{ref:d,label:e,description:r,data:p,value:a,onChange:Z(o),required:t,sx:i,maxDropdownHeight:500,...c})})),xS=[{from:0,to:0},{from:100,to:100}];function Wl(e){return e?y.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function CS(e,t){var r;return Wl(t)==="static"?t:(r=e.getStaticColors()[0])==null?void 0:r.value}function SS(e,t){return y.isObject(t)?t:{steps:xS,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const TS=h.forwardRef((e,t)=>{const{t:r}=m.useTranslation(),{colorManager:a}=h.useContext(ot),[o,l]=h.useState(Wl(e.value)),[i,c]=h.useState(CS(a,e.value)),d=O.useLatest(i),[u,p]=h.useState(SS(a,e.value)),g=O.useLatest(u),b=x=>{var S,D,z;l(x||"none"),x==="static"?(S=e.onChange)==null||S.call(e,d.current):x==="none"||!x?(D=e.onChange)==null||D.call(e,"none"):(z=e.onChange)==null||z.call(e,g.current)},_=x=>{var S;c(x),(S=e.onChange)==null||S.call(e,x)},w=x=>{var S;p(x),(S=e.onChange)==null||S.call(e,x)};return n.jsxs(s.Stack,{align:"stretch",children:[n.jsx(af,{label:r("viz.table.column.cell_background"),value:o||"none",onChange:b}),o==="static"&&n.jsx(ye,{label:r("chart.color.label"),value:i,onChange:_}),o==="interpolation"&&n.jsx(rf,{colorManager:a,value:u,onChange:w})]})}),kS=h.forwardRef(({value:e,onChange:t,sx:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>Object.values(Ye).map(c=>({label:o(`viz.table.column.value_type.${c}`),value:c})),[l.language]);return n.jsx(s.Select,{ref:a,label:o("viz.table.column.value_type.label"),data:i,value:e,onChange:Z(t),maxDropdownHeight:500,sx:r})}),DS=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(),[c,d]=h.useState(e),u=()=>{i(),t(c)},p=()=>{i(),d(e)},g=()=>{d(El)};return h.useEffect(()=>{d(e)},[e]),n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:a("viz.table.column.custom_cell_content")}),n.jsx(s.Modal,{size:800,title:a("viz.table.column.custom_cell_content"),opened:o,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(s.Stack,{children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(xo,{})}),n.jsx(s.Box,{sx:{position:"relative"},children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:c,onChange:b=>d(b??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:a("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:a("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:u,children:a("common.actions.save")})]})]})]})})]})}),ea=()=>n.jsx(s.Text,{c:"dimmed",size:"12px",children:"px"}),zS=({control:e,index:t,watch:r})=>{const{t:a}=m.useTranslation(),o=r(`columns.${t}.value_type`),l=r("query_id");return n.jsxs(s.Stack,{my:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`columns.${t}.label`,control:e,render:({field:i})=>n.jsx(s.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${t}`,sx:{flex:1},...i})}),n.jsx(v.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:i})=>n.jsx(L,{label:a("common.data_field"),required:!0,queryID:l,...i})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:i})=>n.jsx(kS,{sx:{flex:1},...i})}),o===Ye.custom&&n.jsx(v.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:i})=>n.jsx(DS,{value:i.value??El,onChange:c=>i.onChange(c??"")})})]}),n.jsx(s.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:n.jsx(ea,{}),disabled:!0}),n.jsx(v.Controller,{name:`columns.${t}.width`,control:e,render:({field:i})=>n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:n.jsx(ea,{}),...i})}),n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:n.jsx(ea,{}),disabled:!0})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`columns.${t}.align`,control:e,render:({field:i})=>n.jsx(Mr,{...i})})}),n.jsx(v.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:i})=>n.jsx(TS,{...i})})]})},MS=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>{const i=te.randomId();return{id:i,label:i,align:"center",value_field:"",value_type:Ye.string,width:""}},o=(i,c)=>{const d=i.label.trim();return d||c+1};t(["columns","ignored_column_keys"]);const l=t("use_raw_columns");return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:"use_raw_columns",control:e,render:({field:i})=>n.jsx(s.Switch,{mt:20,mb:20,label:r("viz.table.column.use_original_data_columns"),checked:i.value,onChange:c=>i.onChange(c.currentTarget.checked)})}),l&&n.jsx(v.Controller,{name:"ignored_column_keys",control:e,render:({field:i})=>n.jsx(s.Textarea,{label:r("viz.table.column.ignore_columns_by_these_key"),placeholder:r("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...i})}),!l&&n.jsx(R,{control:e,watch:t,name:"columns",getItem:a,addButtonText:r("viz.table.column.add"),deleteButtonText:r("viz.table.column.delete"),renderTabName:o,children:({field:i,index:c})=>n.jsx(zS,{control:e,watch:t,index:c})})]})};function IS({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),n.jsxs(s.Stack,{gap:"xs",children:[n.jsxs(s.Group,{justify:"space-between",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[n.jsx(v.Controller,{name:"horizontalSpacing",control:e,render:({field:a})=>n.jsx(Pr,{disabled:!0,label:r("viz.table.style.horizontal_spacing"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"verticalSpacing",control:e,render:({field:a})=>n.jsx(Pr,{disabled:!0,label:r("viz.table.style.vertical_spacing"),sx:{flex:1},...a})})]}),n.jsx(s.Group,{justify:"space-between",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:n.jsx(v.Controller,{name:"fontSize",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("style.font_size.label"),placeholder:r("style.font_size.placeholder"),required:!0,sx:{flex:1},...a})})}),n.jsxs(s.Group,{justify:"space-between",grow:!0,children:[n.jsx(v.Controller,{name:"striped",control:e,render:({field:a})=>n.jsx(s.Switch,{label:r("viz.table.style.striped"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})}),n.jsx(v.Controller,{name:"highlightOnHover",control:e,render:({field:a})=>n.jsx(s.Switch,{label:r("viz.table.style.highlight_on_hover"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})]})}function VS({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["pagination"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"pagination.page_size",control:e,render:({field:a})=>n.jsx(s.NumberInput,{label:r("common.pagination.page_size"),description:r("viz.heatmap.pagination.page_size_hint"),size:"xs",sx:{flex:1},...a,onChange:o=>{typeof o!="string"&&a.onChange(o)}})})})}function PS({columns:e,...t}){return{...t,columns:e.map(({id:r,...a})=>({id:r??te.randomId(),...a}))}}function $S({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaultsDeep({},r,Bl),[r]),l=h.useMemo(()=>PS(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["query_id"]),n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Columns",children:t("viz.table.column.labels")}),n.jsx(s.Tabs.Tab,{value:"Style",children:t("style.label")}),n.jsx(s.Tabs.Tab,{value:"Pagination",children:t("common.pagination.label")})]}),n.jsxs(s.Tabs.Panel,{value:"Columns",children:[n.jsx(v.Controller,{name:"query_id",control:i,render:({field:g})=>n.jsx(wS,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...g})}),n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(MS,{control:i,watch:d})]}),n.jsx(s.Tabs.Panel,{value:"Style",children:n.jsx(IS,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Pagination",children:n.jsx(VS,{control:i,watch:d})})]})]})}const Ul=new ZC,ta={createConfig(){return{version:Ul.VERSION,config:y.cloneDeep(Bl)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:Ul,name:"table",viewRender:_S,configRender:$S,triggers:[Rr],translation:mS},Kl=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
530
|
-
`),na={func_content:Kl,horizontal_align:"left",font_size:"14px",font_weight:"normal"},AS=k.observer(({context:e})=>{const t=H(),{value:r=na}=q(e.instanceData,"config"),{variables:a}=e,o=e.data,{func_content:l,horizontal_align:i,font_size:c,font_weight:d}=r,u=h.useMemo(()=>a.reduce((g,b)=>{const _=He(b,o);return g[b.name]=Be(b,_),g},{}),[a,o]),p=h.useMemo(()=>new Function(`return ${l}`)()({data:o,variables:u,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[l,o,u,t.payloadForSQL]);return n.jsx(s.Text,{ta:i,fw:d,sx:{fontSize:c},children:p})}),In=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function ES({label:e,value:t,onChange:r},a){var i;const[o,l]=h.useState(((i=In.find(c=>c.label===t))==null?void 0:i.value)??In[0].value);return h.useEffect(()=>{const c=In.find(d=>d.value===o);c&&r(c.label)},[o]),n.jsxs(s.Stack,{gap:0,mt:"sm",mb:"lg",children:[n.jsx(s.Text,{size:"sm",children:e}),n.jsx(s.Box,{px:"1.5em",children:n.jsx(s.Slider,{label:null,marks:In,value:o,onChange:l,step:25,ref:a})})]})}const BS=h.forwardRef(ES),qS=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{sx:{position:"relative"},children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},OS=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(),[c,d]=h.useState(e),u=()=>{i(),t(c)},p=()=>{i(),d(e)},g=()=>{d(Kl)};return h.useEffect(()=>{d(e)},[e]),n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:a("viz.text.content.edit")}),n.jsx(s.Modal,{size:800,title:a("viz.text.content.label"),opened:o,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(s.Stack,{children:[n.jsx(qS,{value:c,onChange:d}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:a("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:a("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:u,children:a("common.actions.save_changes")})]})]})]})})]})});function LS({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaultsDeep({},r,na),[r]),l=h.useMemo(()=>{const{func_content:g,horizontal_align:b,font_size:_,font_weight:w}=o;return{func_content:g,horizontal_align:b,font_size:_,font_weight:w}},[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["func_content","horizontal_align","font_size","font_weight"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Stack,{gap:10,children:[n.jsx(v.Controller,{name:"func_content",control:i,render:({field:g})=>n.jsx(OS,{...g})}),n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:t("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"horizontal_align",control:i,render:({field:g})=>n.jsx(Mr,{...g})}),n.jsx(v.Controller,{name:"font_size",control:i,render:({field:g})=>n.jsx(s.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...g})}),n.jsx(s.Group,{justify:"space-between",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:n.jsx(v.Controller,{name:"font_weight",control:i,render:({field:g})=>n.jsx(BS,{label:t("style.font_weight.label"),...g})})})]})]})})}const NS=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class GS extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const FS={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new GS,name:"text",viewRender:AS,configRender:LS,createConfig(){return{version:1,config:y.cloneDeep(na)}},translation:NS},ra={item_badge:"_item_badge_l2t3l_1",label:"_label_l2t3l_8",value:"_value_l2t3l_20"},QS=({children:e})=>["string","number"].includes(typeof e)?n.jsx(s.Text,{size:"xs",ff:"monospace",children:e}):e,vt=h.forwardRef(({label:e,value:t,label_description:r,value_description:a},o)=>n.jsxs("div",{ref:o,className:ra.item_badge,children:[n.jsx("div",{className:ra.label,children:e}),n.jsxs(s.HoverCard,{shadow:"md",disabled:!a,children:[n.jsx(s.HoverCard.Target,{children:n.jsx("div",{className:ra.value,"data-with-tooltip":!!a,children:t})}),n.jsx(s.HoverCard.Dropdown,{p:"xs",children:n.jsx(QS,{children:a})})]})]})),jS=({item:e})=>e.type!=="checkbox"?null:n.jsx(vt,{label:e.label,value:n.jsx(s.ThemeIcon,{variant:"white",radius:"xs",color:e.value?"teal":"red",w:12,h:12,miw:12,mih:12,children:e.value?n.jsx(T.IconCheck,{size:12,strokeWidth:3}):n.jsx(T.IconX,{strokeWidth:3})}),label_description:`filters.${e.key}`}),WS=({item:e})=>e.type!=="context"?null:n.jsx(vt,{label:e.key,value:e.value,label_description:`context.${e.key}`}),US=k.observer(({item:e})=>{const{t}=m.useTranslation(),a=e.model.value,[o,l]=a.value,i=h.useMemo(()=>!l&&!o?Number.NaN:M(l).diff(M(o),"days")+1,[o,l]);if(Number.isNaN(i))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const c=i===1?t("filter.widget.date_range.one_day"):t("filter.widget.date_range.x_days",{count:i});return n.jsx(vt,{label:e.label,value:e.value.join(" ~ "),label_description:`filters.${e.key}`,value_description:c})}),KS=({item:e})=>e.type!=="date-range"?null:n.jsx(US,{item:e}),Yl=({selection:e})=>(m.useTranslation(),e.length===0?null:n.jsx(s.Group,{justify:"flex-start",gap:"xs",maw:"80vw",children:e.map(t=>n.jsx(s.Pill,{size:"xs",ff:"monospace",children:t.label},t.value))})),YS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>r.optionsByValues(e.value),[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a.length,label_description:`filters.${e.key}`,value_description:n.jsx(Yl,{selection:a})})}),XS=({item:e})=>e.type!=="multi-select"?null:n.jsx(YS,{item:e}),ZS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>{var o;return((o=r.options.find(l=>l.value===e.value))==null?void 0:o.label)??e.value},[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a,label_description:`filters.${e.key}`})}),JS=({item:e})=>e.type!=="select"?null:n.jsx(ZS,{item:e}),HS=({item:e})=>e.type!=="text-input"?null:n.jsx(vt,{label:e.label,value:n.jsx(s.Text,{maw:200,size:"xs",truncate:"end",ff:"monospace",children:e.value}),value_description:e.value}),RS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>r.optionsByValues(e.value),[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a.length,label_description:`filters.${e.key}`,value_description:n.jsx(Yl,{selection:a})})}),eT=({item:e})=>e.type!=="tree-select"?null:n.jsx(RS,{item:e}),tT=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>{var o;return((o=r.options.find(l=>l.value===e.value))==null?void 0:o.label)??e.value},[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a,label_description:`filters.${e.key}`,value_description:e.value})}),nT=({item:e})=>e.type!=="tree-single-select"?null:n.jsx(tT,{item:e}),aa=({item:e})=>{switch(e.type){case"date-range":return n.jsx(KS,{item:e});case"select":return n.jsx(JS,{item:e});case"tree-single-select":return n.jsx(nT,{item:e});case"multi-select":return n.jsx(XS,{item:e});case"tree-select":return n.jsx(eT,{item:e});case"text-input":return n.jsx(HS,{item:e});case"checkbox":return n.jsx(jS,{item:e});case"context":return n.jsx(WS,{item:e});default:return null}},rT=k.observer(({conf:e})=>{const r=H().dashboardState,{all:a,keys:o}=e;return a?n.jsxs(n.Fragment,{children:[Object.entries(r.context).map(([l,i])=>n.jsx(aa,{item:i},l)),Object.entries(r.filters).map(([l,i])=>n.jsx(aa,{item:i},l))]}):n.jsx(n.Fragment,{children:o.map(l=>{const i=y.get(r,l);return i?n.jsx(aa,{item:i},l):null})})}),aT=k.observer(({context:e})=>{const{value:t}=q(e.instanceData,"config"),{width:r,height:a}=e.viewport;return t?n.jsx(s.Group,{justify:"flex-start",align:"flex-start",wrap:"wrap",px:0,py:0,gap:"xs",w:r,mah:a,style:{overflow:"auto"},"data-enable-scrollbar":!0,children:n.jsx(rT,{conf:t})}):null}),Xl={all:!0,keys:[]},sT={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","tree-single-select":"filter.widget.names.tree_single_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},oT=({option:e,checked:t,...r})=>{const{t:a}=m.useTranslation(),o=e,l=o.type==="filter";return n.jsxs(s.Group,{gap:4,flex:1,children:[n.jsx(T.IconCheck,{size:14,opacity:t?1:0,color:"black"}),n.jsx(s.Stack,{gap:0,py:4,px:8,flex:1,styles:{root:{flexGrow:1,borderRadius:"4px"}},...r,children:n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(s.Text,{size:"xs",children:e.label}),l&&n.jsx(s.Text,{size:"xs",c:t?"rgba(0,0,0,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:a(sT[o.widget])})]})})]})},lT=k.observer(({value:e,onChange:t,disabled:r})=>{const{t:a}=m.useTranslation(),l=F().dashboardStateVariableOptions,i=h.useMemo(()=>{const{optionGroups:c,validValues:d}=l,u=c.map(g=>({group:a(g.group),items:g.items.map(b=>({...b,label:b.label,value:b.value,widget_label:b.label}))})),p=e.filter(g=>!d.has(g)).map(g=>({label:g,value:g,disabled:!0}));return p.length>0&&u.push({group:a("common.invalid"),items:p}),u},[l,a,e]);return n.jsx(s.MultiSelect,{size:"xs",label:a("viz.vizDashboardState.variable_selector.label"),placeholder:e.length===0?a("viz.vizDashboardState.variable_selector.placeholder"):void 0,data:i,renderOption:oT,maxDropdownHeight:600,value:e,onChange:t,disabled:r,clearable:!0})}),iT=({form:e})=>{const{t}=m.useTranslation(),r=e.watch("all");return n.jsxs(s.Stack,{gap:"xs",p:"xs",children:[n.jsx(v.Controller,{name:"all",control:e.control,render:({field:a})=>n.jsx(s.Checkbox,{size:"xs",label:t("viz.vizDashboardState.show_all"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})}),n.jsx(v.Controller,{name:"keys",control:e.control,render:({field:a})=>n.jsx(lT,{disabled:r,...a})})]})};function cT({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Xl),[t]),o=v.useForm({defaultValues:a}),{handleSubmit:l,formState:i,reset:c}=o;return h.useEffect(()=>{c(a)},[a]),n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:i.isDirty}),n.jsx(iT,{form:o})]})}const dT=[{lang:"en",resources:{vizDashboardState:{viz_name:"Dashboard State",show_all:"Show all filters and context entries",variable_selector:{label:"Select filters and context entries to show",placeholder:""}}}},{lang:"zh",resources:{vizDashboardState:{viz_name:"看板状态",show_all:"显示所有筛选器和上下文条目",variable_selector:{label:"选择要展示的筛选器和上下文",placeholder:""}}}}];class uT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const pT={displayName:"viz.vizDashboardState.viz_name",displayGroup:"chart.groups.others",migrator:new uT,name:"vizDashboardState",viewRender:aT,configRender:cT,createConfig:()=>({version:1,config:Xl}),translation:dT},hT=()=>n.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),n.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),n.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function Zl(e,t){const r=y.get(e,t,"");if(r)throw new Error(r)}async function gT(e,t,r,a={}){const o={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",...a.headers},l={baseURL:e,method:"POST",url:t,params:a.params,headers:o};return l.data=a.string?JSON.stringify(r):r,ke(l).then(i=>i.data).catch(i=>Promise.reject(i))}const fT=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:r,path:a,goal:o,question:l}=e;if(!a||!o||!l)return;const i=pp(t);if(!i)return;const c={dashboard:o,panel:l,data:i};try{const d=r.startsWith("http")?r:window.location.origin;return await gT(d,`/expert/v3/devtable/${a}`,c,{})}catch(d){throw Zl(d,"response.data.detail"),Zl(d,"response.data.error"),console.error(d),d}},sa={expertSystemURL:"",path:"",goal:"",question:""},oa={height:"100%",overflowY:"auto",...cr},Jl=({message:e})=>n.jsx(s.Box,{sx:oa,children:n.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),bT=({error:e,width:t,height:r})=>{const a=e.message;if(a.startsWith("<"))return n.jsx(Jl,{message:a});const l=r-25-20-30;return n.jsx(s.Center,{sx:{width:"100%",height:l},children:n.jsxs(s.Stack,{align:"center",gap:20,children:[n.jsx(hT,{}),n.jsx(Jl,{message:a})]})})};function yT({context:e}){const{value:t}=q(e.instanceData,"config"),r=h.useMemo(()=>y.defaultsDeep({},t,sa),[t]),{width:a,height:o}=e.viewport,l=e.data,{data:i,error:c,loading:d}=O.useRequest(fT({conf:r,panelData:l}),{refreshDeps:[l,r]});return!a||!o||!r?null:d?n.jsx(s.Box,{sx:{position:"relative",height:o},children:n.jsx(s.LoadingOverlay,{visible:!0})}):c?n.jsx(s.Box,{sx:oa,"data-enable-scrollbar":!0,children:n.jsx(bT,{error:c,width:a,height:o})}):!i||!Array.isArray(i.replies)||i.replies.length===0?null:n.jsx(s.Box,{sx:oa,"data-enable-scrollbar":!0,children:i.replies.map((u,p)=>n.jsx("div",{dangerouslySetInnerHTML:{__html:u.interpretation.html}},p))})}function vT({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,sa),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),i(["expertSystemURL","goal","path","question"]),n.jsx("form",{onSubmit:l(r),children:n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"expertSystemURL",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Expert System URL",...u})}),n.jsx(v.Controller,{name:"path",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Path",required:!0,...u})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"goal",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Goal",required:!0,...u})}),n.jsx(v.Controller,{name:"question",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Question",required:!0,...u})})]}),n.jsx(s.Divider,{variant:"dashed",mt:16,mb:8}),n.jsx(s.Button,{type:"submit",variant:"filled",color:"blue",leftSection:n.jsx(T.IconDeviceFloppy,{size:20}),disabled:!c.isDirty,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const _T=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class mT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const wT={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new mT,name:"mericoGQM",viewRender:yT,configRender:vT,createConfig(){return{version:1,config:y.cloneDeep(sa)}},translation:_T};class xT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}function CT({context:e}){const{t}=m.useTranslation(),{inEditMode:r}=Ys();if(!r)return null;const{width:a,height:o}=e.viewport;return n.jsx(s.Center,{w:a,h:o,title:t("viz.merico_panel_groups.render"),children:n.jsx(s.Text,{c:"dimmed",size:"xs",children:t("viz.merico_panel_groups.render")})})}const ST=[{lang:"en",resources:{merico_panel_groups:{viz_name:"Merico Panel Groups",render:'"Merico Panel Groups" is a ghost viz, the whole panel will not shown in dashboard',groups:{label:"Groups",add:"Add a group",name:"Name",comment:"Remark",panel_ids:"Panels",yaml:{button:"Import from YAML",modal_title:"Import from YAML",label:"YAML content",submit:"Submit",error_title:"Failed"}}}}},{lang:"zh",resources:{merico_panel_groups:{viz_name:"思码逸卡片组",render:"在使用看板时,思码逸卡片组不会参与渲染",groups:{label:"卡片组",add:"增加一组",name:"名称",comment:"备注",panel_ids:"卡片",yaml:{button:"从YAML导入",modal_title:"从YAML导入",label:"YAML内容",submit:"提交",error_title:"解析失败"}}}}}],Hl=()=>({groups:[]}),TT=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",comment:"",panelIDs:[]})};return n.jsx(s.Flex,{gap:"sm",justify:"center",align:"center",direction:"row",wrap:"nowrap",children:n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.merico_panel_groups.groups.add")})})})},kT=({row:e,index:t,handleChange:r,handleRemove:a,panelOptions:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),d=g=>{r({...e,name:g})},u=g=>{r({...e,comment:g})},p=g=>{r({...e,panelIDs:g})};return n.jsxs(s.Stack,{gap:"xs",p:"xs",style:{border:"1px solid var(--mantine-color-gray-4)",borderRadius:"2px"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.TextInput,{size:"xs",value:e.name,placeholder:l("viz.merico_panel_groups.groups.name"),onChange:g=>d(g.currentTarget.value),onClick:c,error:i&&!e.name}),n.jsx(s.TextInput,{size:"xs",value:e.comment,placeholder:l("viz.merico_panel_groups.groups.comment"),onChange:g=>u(g.currentTarget.value)})]}),n.jsx(s.MultiSelect,{label:"",placeholder:l("viz.merico_panel_groups.groups.panel_ids"),onChange:p,value:e.panelIDs,clearable:!0,size:"xs",data:o,maxDropdownHeight:500,comboboxProps:{width:300,position:"bottom-start"}}),n.jsx(s.Button,{variant:"subtle",color:"red",size:"xs",ml:"auto",mt:"md",leftSection:n.jsx(T.IconTrash,{size:14}),onClick:a,children:"删除这一组"})]})};function DT(e){try{const t=[],r=e.split(`
|
|
531
|
-
`);let a="";for(let o=0;o<r.length;o++){const l=r[o];if(l.includes("#")){const d=l.split("# ")[1].trim();d&&(a=d,console.log({comment:a}));continue}const[i,c]=l.split(": ").map(d=>d.trim());console.log({name:i,panelIDString:c}),t.push({name:i,comment:a,panelIDs:JSON.parse(c)})}return t}catch(t){throw t}}const zT=({onSubmit:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),[l,i]=h.useState("");h.useEffect(()=>{i("")},[r]);const c=()=>{try{const d=DT(l);e(d),o()}catch(d){console.error(d),Fe.showNotification({title:t("viz.merico_panel_groups.groups.yaml.error_title"),message:d.message,color:"red"})}};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{onClick:a,disabled:r,size:"xs",variant:"light",children:t("viz.merico_panel_groups.groups.yaml.button")}),n.jsx(s.Modal,{opened:r,onClose:o,title:t("viz.merico_panel_groups.groups.yaml.modal_title"),zIndex:340,size:800,children:n.jsxs(s.Stack,{gap:"lg",children:[n.jsx(s.Textarea,{label:t("viz.merico_panel_groups.groups.yaml.label"),value:l,onChange:d=>i(d.currentTarget.value),autosize:!0,minRows:10,maxRows:40,styles:{input:{fontFamily:"monospace",fontSize:"12px"}}}),n.jsx(s.Button,{ml:"auto",onClick:c,children:t("viz.merico_panel_groups.groups.yaml.submit")})]})})]})},MT=h.forwardRef(({value:e,onChange:t,data:r},a)=>{const{t:o}=m.useTranslation(),l=F(),i=h.useMemo(()=>e.map(w=>({id:Te.v4(),...w})),[e]),c=w=>{t([...e,w])},d=w=>{t(w)},u=w=>{const x=[...e];x.splice(w,1),t(x)},p=w=>x=>{const S=[...e];S[w]=x,t(S)},g=l.panels.options,b=h.useMemo(()=>new Set(i.map(w=>w.panelIDs).flat()),[i]),_=h.useMemo(()=>g.map(w=>({...w,disabled:b.has(w.value)})),[g,b]);return n.jsxs(s.Stack,{ref:a,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:o("viz.merico_panel_groups.groups.label")}),n.jsx(zT,{onSubmit:d})]}),i.map((w,x)=>n.jsx(kT,{row:w,handleChange:p(x),handleRemove:()=>u(x),index:x,panelOptions:_},w.id)),n.jsx(TT,{append:c})]})});function IT({context:e}){const{value:t,set:r}=q(e.instanceData,"config");m.useTranslation();const a=e.data,o=h.useMemo(()=>y.defaultsDeep({},t,Hl()),[t]),l=v.useForm({defaultValues:o}),{handleSubmit:i,formState:c,reset:d}=l;h.useEffect(()=>{l.reset(o)},[o]);const u=p=>{const g=p;g.groups=g.groups.filter(b=>b.panelIDs.length>0||!!b.name.trim()||!!b.comment.trim()),r(g)};return n.jsxs("form",{onSubmit:i(u),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsx(s.Stack,{gap:"lg",pt:"xs",px:"xs",children:n.jsx(v.Controller,{name:"groups",control:l.control,render:({field:p})=>n.jsx(MT,{...p,data:a})})})]})}const Rl={displayName:"viz.merico_panel_groups.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new xT,name:"merico_panel_groups",viewRender:CT,configRender:IT,createConfig:()=>({version:1,config:Hl()}),translation:ST},VT=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),PT=[Wu,Uu,Xu,Yu,Ku,Zu],la=[ta,wC,FS,n1,QC,Jx,H_,kh,Ef,Dv,d_,Vb,yx,iv,nC,C0,J0,wT,Pm,sw,Pw,Rl,mw,Kf,pT],ei=la.reduce((e,t)=>(e[t.name]={displayName:t.displayName,displayGroup:t.displayGroup},e),{}),ti=()=>({id:"dashboard",version:Qs,manifest:{viz:la,color:[...VT,...PT]}}),Mt=new np,ee={pluginManager:Je("pluginManager"),vizManager:Je("vizManager"),colorManager:Je("colorManager"),panelAddonManager:Je("panelAddonManager"),instanceScope:{panelModel:Je("panelModel"),vizInstance:Je("vizInstance"),interactionManager:Je("interactionManager"),migrator:Je("migrator"),operationManager:Je("operationManager"),triggerManager:Je("triggerManager")}},ia=()=>{try{Mt.install(ti())}catch{}const e=new Fu(Mt),t=new tp(Mt),r=new Ju(Mt);return{pluginManager:Mt,vizManager:e,colorManager:t,panelAddonManager:r}},ot=h.createContext(ia());try{Mt.install(ti())}catch{}const Vn=Ce.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:Lu,zh:Nu}}).use(Wd).use(m.initReactI18next);Vn.init(),la.forEach(e=>{var t;(t=e.translation)==null||t.forEach(r=>{Vn.addResourceBundle(r.lang,"translation",{viz:r.resources},!0,!0)})});function ni({lang:e,children:t}){return h.useEffect(()=>{Vn.changeLanguage(e)},[e]),n.jsx(m.I18nextProvider,{i18n:Vn,children:t})}M.extend(Rd),M.extend(eu),M.extend(tu),M.extend(nu),M.extend(ru),M.extend(au),M.extend(su),M.extend(ou),M.extend(lu),M.extend(iu),M.extend(uu),M.extend(pu),M.extend(hu),M.extend(gu),M.extend(fu),M.extend(cu),M.extend(du),M.extend(bu),M.extend(yu),M.extend(vu),M.extend(_u),M.extend(mu),M.extend(wu),M.extend(xu),M.extend(Cu),M.extend(Su),M.extend(Tu),M.extend(ku),M.extend(Du),M.extend(zu),M.extend(Iu),M.extend(Vu),M.extend(Mu),M.tz.setDefault("UTC"),M.updateLocale("en",{weekStart:1});function $T(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let a=0;a<t.length;a++){const o=t[a];if(o!="authentication"&&e[o])r.push(t[a]+"="+(typeof e[o]=="object"?JSON.stringify(e[o]):e[o]));else{const l=Object.keys(e[o]).sort();for(let i=0;i<l.length;i++){const c=l[i];c!="sign"&&e[o][c]&&r.push(l[i]+"="+(typeof e[o][c]=="object"?JSON.stringify(e[o][c]):e[o][c]))}}}return r.sort().join("&")}function AT(e,t){let r=$T(e);return r+="&key="+t,qu.MD5(r).toString().toUpperCase()}class ri{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const r=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:r,sign:AT({app_id:this.app_id,nonce_str:r,...t},this.app_secret)}}getRequest(t,r){return(a,o,l,i)=>{const c=this.buildHeader(l),d=this.buildAxiosConfig(t,a,o,l,c,r);return ke(d).then(u=>i?u:u.data).catch(u=>{if(ke.isCancel(u))return Promise.reject(u);const p=u,g=y.get(p,"response.data.detail.message",p.message);return Promise.reject(new Error(g))})}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,r,a,o,l,i){const c={baseURL:this.baseURL,method:t,url:r,params:t==="GET"?a:o.params,headers:l,signal:i};return["POST","PUT"].includes(t)&&(c.data=o.string?JSON.stringify(a):a,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(t){const r=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:r?`bearer ${r}`:"",...t.headers}}}class ET{constructor(t){this.implementation=t}getRequest(t,r){return this.implementation.getRequest(t,r)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class ai extends ri{constructor(){super(...arguments);V(this,"makeQueryENV",null)}query(r){return async(a,o={})=>{var l;return a.env||(a.env=((l=this.makeQueryENV)==null?void 0:l.call(this))??{error:"failed to run makeQueryENV"}),this.post(r)("/query",a,o)}}httpDataSourceQuery(r){return async(a,o={})=>{var l;return a.env||(a.env=((l=this.makeQueryENV)==null?void 0:l.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",r)("/query",a,o,!0)}}structure(r){return async(a,o={})=>this.post(r)("/query/structure",a,o)}mericoMetricInfo(r){return async(a,o={})=>this.post(r)("/query/merico_metric_info",a,o,!0)}mericoMetricQuery(r){return async(a,o={})=>this.post(r)("/query",a,o,!0)}}class si{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}mericoMetricInfo(t){return this.implementation.mericoMetricInfo(t)}mericoMetricQuery(t){return this.implementation.mericoMetricQuery(t)}getRequest(t,r){return this.implementation.getRequest(t,r)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Nt=new ai;function ca(e){Nt.baseURL!==e.apiBaseURL&&(Nt.baseURL=e.apiBaseURL),e.app_id&&(Nt.app_id=e.app_id),e.app_secret&&(Nt.app_secret=e.app_secret),e.makeQueryENV&&(Nt.makeQueryENV=e.makeQueryENV)}const oi=new si(Nt),$e=oi,da=f.types.model("MockContextMeta",{current:f.types.optional(f.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,r){e.current[t]=r}}));function ua(e){return{current:e}}const BT=f.types.model("PanelStyleBorderMeta",{enabled:f.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),li=f.types.model("PanelStyleMeta",{border:BT}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),ii=f.types.model("PanelTitleMeta",{show:f.types.optional(f.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),ci=f.types.model("VariableMeta",{name:f.types.string,size:f.types.string,weight:f.types.string,color:f.types.union(f.types.model({type:f.types.literal("static"),staticColor:f.types.string}),f.types.model({type:f.types.literal("continuous"),valueRange:f.types.array(f.types.number),colorRange:f.types.array(f.types.string)}),f.types.model({type:f.types.literal("piecewise")})),formatter:f.types.model({output:f.types.enumeration("Output",["number","percent"]),average:f.types.optional(f.types.boolean,!1),mantissa:f.types.number,trimMantissa:f.types.optional(f.types.boolean,!1),absolute:f.types.optional(f.types.boolean,!1)}),data_field:f.types.string,aggregation:f.types.union(f.types.model({type:f.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:f.types.frozen(),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("quantile"),config:f.types.model({p:f.types.number}),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("pick_record"),config:f.types.model({method:f.types.enumeration("Pick Record Method",["first","last"])}),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("custom"),config:f.types.model({func:f.types.string}),fallback:f.types.optional(f.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:r,weight:a,color:o,formatter:l,data_field:i,aggregation:c}=e;return y.cloneDeep({name:t,size:r,color:o,weight:a,formatter:l,data_field:i,aggregation:c})}})),di=f.types.model("PanelVizMeta",{type:f.types.string,conf:f.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){y.isEqual(e.conf,t)||(e.conf=t)}})),ui=f.types.model({id:f.types.string,name:f.types.optional(f.types.string,""),title:ii,description:f.types.string,queryIDs:f.types.array(f.types.string),viz:di,style:li,variables:f.types.optional(f.types.array(ci),[])}).views(e=>({get json(){const{id:t,name:r,title:a,description:o,queryIDs:l}=e;return{id:t,viz:e.viz.json,name:r,style:e.style.json,title:a.json,queryIDs:[...l],variables:e.variables.map(i=>i.json),description:o}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const r=new Set(e.queryIDSet);r.delete(t),e.queryIDs=f.cast(Array.from(r))},setQueryIDs(t){e.queryIDs=f.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var W=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e.MericoMetricSystem="merico_metric_system",e))(W||{});const pi=f.types.model("DBQueryMeta",{_type:f.types.enumeration([W.MySQL,W.Postgresql]),sql:f.types.string}).views(e=>({get base(){return f.getParent(e)},get valid(){return!!e.sql},get json(){const{sql:t,_type:r}=e;return{sql:t,_type:r}}})).actions(e=>({setSQL(t){e.sql=t}})),qT=e=>pi.create({_type:e,sql:""}),hi=f.types.model("HTTPQueryMeta",{_type:f.types.literal(W.HTTP),react_to:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){return!0},get json(){const{react_to:t,_type:r}=e;return at({react_to:t,_type:r})}})).actions(e=>({setReactTo(t){e.react_to.length=0,e.react_to.push(...t)}})),OT=()=>hi.create({_type:W.HTTP,react_to:[]}),gi=f.types.model("TransformQueryMeta",{_type:f.types.literal(W.Transform),dep_query_ids:f.types.optional(f.types.array(f.types.string),[]),react_to:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){return e.dep_query_ids.length>0},get json(){const{dep_query_ids:t,_type:r,react_to:a}=e;return at({dep_query_ids:t,_type:r,react_to:a})}})).actions(e=>({setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)}})),LT=()=>gi.create({_type:W.Transform,dep_query_ids:[]}),fi=f.types.model("SqlMetricVariableMeta",{sqlVar:f.types.optional(f.types.string,""),variable:f.types.optional(f.types.string,"")}).views(e=>({get allEmpty(){return!e.sqlVar&&!e.variable},get json(){const{sqlVar:t,variable:r}=e;return{sqlVar:t,variable:r}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeSqlVariable(e)},setSqlVar(t){e.sqlVar=t??"",e.allEmpty&&this.removeSelf()},setVariable(t){e.variable=t??"",e.allEmpty&&this.removeSelf()}})),bi=f.types.model("MetricFilterColMeta",{dimension:f.types.optional(f.types.string,""),variable:f.types.optional(f.types.string,"")}).views(e=>({get allEmpty(){return!e.dimension&&!e.variable},get json(){const{dimension:t,variable:r}=e;return{dimension:t,variable:r}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeFilter(e)},setDimension(t){e.dimension=t??"",e.allEmpty&&this.removeSelf()},setVariable(t){e.variable=t??"",e.allEmpty&&this.removeSelf()}})),pa=f.types.model("MericoMetricQueryMeta",{_type:f.types.literal(W.MericoMetricSystem),id:f.types.optional(f.types.string,""),type:f.types.optional(f.types.enumeration("MetricType",["derived","combined","sql"]),"derived"),filters:f.types.optional(f.types.array(bi),[]),groupBys:f.types.optional(f.types.array(f.types.string),[]),sqlVariables:f.types.optional(f.types.array(fi),[]),timeQuery:f.types.model({enabled:f.types.optional(f.types.boolean,!1),range_variable:f.types.optional(f.types.string,""),unit_variable:f.types.optional(f.types.string,""),timezone:f.types.optional(f.types.string,"PRC"),stepKeyFormat:f.types.optional(f.types.string,"YYYY-MM-DD")}),useDefaultValues:f.types.optional(f.types.boolean,!1),extraCalculations:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get query(){return f.getParent(e)},get valid(){return!!e.id},get json(){const{id:t,type:r,filters:a,groupBys:o,timeQuery:l,useDefaultValues:i,extraCalculations:c,_type:d,sqlVariables:u}=e;return at({id:t,type:r,filters:a.map(p=>p.json),groupBys:o,timeQuery:l,useDefaultValues:i,extraCalculations:c,sqlVariables:u,_type:d})},get usedSqlVariables(){return new Set(e.sqlVariables.map(t=>t.sqlVar))},get usedFilterDimensionKeys(){const t=e.filters.map(r=>r.dimension).filter(r=>!!r);return new Set(t)},get usedFilterVariableSet(){const t=[...e.filters.map(r=>r.variable)].filter(r=>!!r);return new Set(t)},get usedTimeQueryVariableSet(){const t=[e.timeQuery.range_variable,e.timeQuery.unit_variable].filter(r=>!!r);return new Set(t)},get groupByValues(){const t=e.groupBys.map(r=>r.replace(/^(.+)\s->\s(.*)/,"$1"));return Array.from(new Set(t))}})).actions(e=>({reset(){e.filters.length=0,e.groupBys.length=0,e.timeQuery.enabled=!1,e.timeQuery.range_variable="",e.timeQuery.unit_variable="",e.useDefaultValues=!1,e.extraCalculations.length=0,e.sqlVariables.length=0,"data"in e.query&&(e.query.setData([]),e.query.setError(null))},setID(t){t!==e.id&&this.reset(),e.id=t},setType(t){t!=="derived"&&t!=="combined"&&t!=="sql"||(e.type=t)},addFilter(t,r){t&&e.usedFilterDimensionKeys.has(t)||e.filters.push(bi.create({dimension:t,variable:r}))},removeFilter(t){f.destroy(t)},addSqlVariable(t,r){e.sqlVariables.push(fi.create({sqlVar:t,variable:r}))},removeSqlVariable(t){f.destroy(t)},setGroupBys(t){e.groupBys.length=0,e.groupBys.push(...t)},setRangeVariable(t){e.timeQuery.range_variable=t??""},setUnitVariable(t){e.timeQuery.unit_variable=t??""},setTimeQueryEnabled(t){e.timeQuery.enabled=t,t?e.groupBys.length>1&&(e.groupBys.length=0):(e.timeQuery.range_variable="",e.timeQuery.unit_variable="")},setUseDefaultValues(t){e.useDefaultValues=t},setExtraCalculations(t){e.extraCalculations.length=0,e.extraCalculations.push(...t)}})),yi=()=>pa.create({_type:W.MericoMetricSystem,id:"",type:"derived",filters:[],groupBys:[],timeQuery:{range_variable:"",unit_variable:"",timezone:"PRC",stepKeyFormat:"YYYY-MM-DD"},useDefaultValues:!1,extraCalculations:[]}),vi=f.types.model("QueryMeta",{id:f.types.string,name:f.types.string,key:f.types.string,type:f.types.enumeration("DataSourceType",[W.Postgresql,W.MySQL,W.HTTP,W.Transform,W.MericoMetricSystem]),config:f.types.union(pi,hi,gi,pa),pre_process:f.types.optional(f.types.string,""),post_process:f.types.optional(f.types.string,""),run_by:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){const{id:t,name:r,key:a,type:o,config:l}=e;return l.valid&&!!t&&!!r&&!!a&&!!o},get json(){const{id:t,name:r,key:a,type:o,config:l,pre_process:i,post_process:c,run_by:d}=e;return at({id:t,name:r,key:a,type:o,config:l.json,pre_process:i,post_process:c,run_by:d})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){switch(e.type=t,t){case W.HTTP:e.config=OT();break;case W.MySQL:case W.Postgresql:e.config=qT(t);break;case W.Transform:e.config=LT();break;case W.MericoMetricSystem:e.config=yi();break;default:throw new Error(`Unexpected query type[${t}]`)}},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),_i=f.types.model("LayoutItemMeta",{id:f.types.identifier,panelID:f.types.string,x:f.types.number,y:f.types.maybeNull(f.types.number),w:f.types.number,h:f.types.number,moved:f.types.optional(f.types.boolean,!1),static:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:r,x:a,y:o,w:l,h:i,moved:c}=e;return{h:i,w:l,x:a,y:o===null?0:o,id:t,moved:c,static:e.static,panelID:r}},get contentModel(){return f.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:r,y:a,w:o,h:l,moved:i}=e;return{id:t,i:t,x:r,y:a===null?1/0:a,w:o,h:l,moved:i,static:e.static}}})).actions(e=>({set(t){const{isDraggable:r,x:a,y:o,w:l,h:i,moved:c}=t;e.x=a,e.y=o,e.w=l,e.h=i,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),mi=f.types.model("LayoutSetMeta",{id:f.types.identifier,name:f.types.string,breakpoint:f.types.number,list:f.types.optional(f.types.array(_i),[])}).views(e=>({get contentModel(){return f.getRoot(e).content},get json(){const{id:t,name:r,breakpoint:a,list:o}=e;return{id:t,name:r,breakpoint:a,list:o.map(l=>at(l.json))}},jsonByPanelIDSet(t){const{id:r,name:a,breakpoint:o,list:l}=e;return{id:r,name:a,breakpoint:o,list:l.filter(i=>t.has(i.panelID)).map(i=>at(i.json))}},findByID(t){return e.list.find(r=>r.id===t)},findByPanelID(t){return e.list.find(r=>r.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:Te.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const r=e.list.findIndex(a=>a.panelID===t);r>=0&&e.list.splice(r,1)},removeByPanelIDs(t){for(;t.length>0;){const r=t.pop();r&&this.removeByPanelID(r)}},updateLayoutItem(t){const r=e.list.find(a=>a.id===t.i);if(!r){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}r.set(t)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>{const t=e.list.length,r=e.contentModel.panels.list.length;return{match:t===r,layoutCount:t,panelCount:r}},({match:t,panelCount:r,layoutCount:a})=>{if(t)return;const o={id:"layout panel count mismatch",title:"Error detected, please don't save changes.",message:`${a} layout items against and ${r} panels.`,color:"red",autoClose:!1};Fe.showNotification(o),Fe.updateNotification(o)},{fireImmediately:!0,delay:0}))}})),wi=f.types.model("SQLSnippetMeta",{key:f.types.string,value:f.types.string}).views(e=>({get json(){const{key:t,value:r}=e;return{key:t,value:r}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var P=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TreeSingleSelect="tree-single-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e.MericoDateRange="merico-date-range",e))(P||{});const ha=f.types.optional(f.types.enumeration(["intersect","reset"]),"intersect"),ga=f.types.model("FilterCheckboxConfigMeta",{_name:f.types.literal("checkbox"),description:f.types.optional(f.types.string,""),default_value:f.types.boolean}).views(e=>({get json(){const{_name:t,description:r,default_value:a}=e;return{_name:t,description:r,default_value:a}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),xi=()=>ga.create({_name:"checkbox",description:"",default_value:!1}),Ci=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"yesterday"}}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"week").startOf("week").toDate(),e.subtract(1,"week").endOf("week").toDate()],shortcut:"last week"}}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last month"}}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(2,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last 2 months"}}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(3,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last 3 months"}}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"year").startOf("year").toDate(),e.subtract(1,"year").endOf("year").toDate()],shortcut:"last year"}}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(7,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 7 days"}}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(30,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 30 days"}}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(60,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 60 days"}}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(90,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 90 days"}}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(180,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 180 days"}}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(365,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 365 days"}}},{key:"d",value:"today",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("day").toDate(),e.endOf("day").toDate()],shortcut:"today"}}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("week").toDate(),e.endOf("week").toDate()],shortcut:"this week"}}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("month").toDate(),e.endOf("month").toDate()],shortcut:"this month"}}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("year").toDate(),e.endOf("year").toDate()],shortcut:"this year"}}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("week").toDate(),e.endOf("day").toDate()],shortcut:"this week so far"}}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("month").toDate(),e.endOf("day").toDate()],shortcut:"this month so far"}}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("year").toDate(),e.endOf("day").toDate()],shortcut:"this year so far"}}}];function Pn(e){if(!e)return null;const r=Ci().find(a=>a.value===e);return r?r.getRange():null}function Si(){return y.groupBy(Ci(),"group")}function Ti(e){try{if(e.default_shortcut){const r=Pn(e.default_shortcut);if(r)return{value:r.value.map(a=>M(a).toDate()),shortcut:e.default_shortcut}}return{value:e.default_value.map(r=>r===null?r:M.tz(r,"UTC").toDate()??r),shortcut:null}}catch(t){return console.error(t),{value:[null,null],shortcut:null}}}function ki(e,t){return e.map(r=>{try{return r?M.tz(r,"UTC").toISOString():null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const NT=f.types.model("FilterDateRangeConfigMeta",{_name:f.types.literal("date-range"),required:f.types.boolean,inputFormat:f.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:f.types.optional(f.types.array(f.types.union(f.types.Date,f.types.null)),[null,null]),default_shortcut:f.types.optional(f.types.string,""),clearable:f.types.boolean,max_days:f.types.optional(f.types.number,0),allowSingleDateInRange:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:r,required:a,clearable:o,inputFormat:l,default_value:i,default_shortcut:c,allowSingleDateInRange:d}=e;return{_name:t,max_days:r,required:a,clearable:o,inputFormat:l,default_value:ki(i),default_shortcut:c,allowSingleDateInRange:d}},truthy(t){try{const{value:r}=t;return Array.isArray(r)&&r.length===2&&r.every(a=>!!a)}catch(r){return console.error(r),!1}},get filter(){return f.getParent(e)},get dateStringsValue(){try{const t=this.filter.value,[r,a]=t.value,o=r?M(r).format(e.inputFormat):"",l=a?M(a).format(e.inputFormat):"";return[o,l]}catch(t){return console.error(t),["",""]}}})).actions(e=>({setFilterValue(t){try{e.filter.setValue(t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){t&&(e.inputFormat=t)},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t.value),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t??"",!t)return;const r=Pn(e.default_shortcut);r&&e.setFilterValue(r)},setMaxDays(t){const r=Number(t);Number.isFinite(r)&&(e.max_days=r,r>0&&(e.clearable=!0))},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),fa=f.types.snapshotProcessor(NT,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:M.tz(r,"UTC").toDate())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:ki(t,r.inputFormat)}}}),Di=()=>fa.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),zi=f.types.model({label:f.types.string,value:f.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),ba=f.types.model("FilterConfigModel_BaseSelect",{static_options:f.types.optional(f.types.array(zi),[]),options_query_id:f.types.optional(f.types.string,""),default_selection_count:f.types.optional(f.types.number,0),required:f.types.optional(f.types.boolean,!1)}).views(e=>({get contentModel(){return f.getRoot(e).content},get filter(){return f.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get optionsLoading(){if(!e.usingQuery)return!1;const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:r}=e.contentModel.getDataStuffByID(e.options_query_id);return r==="error"?[]:Array.isArray(t)?t.filter(a=>"label"in a&&"value"in a):[]},get optionValuesSet(){return new Set(this.options.map(t=>t.value))}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},replaceStaticOptions(t){e.static_options.forEach(a=>f.detach(a));const r=t.map(a=>zi.create(a));e.static_options.replace(r)},setDefaultSelectionCount(t){const r=Number(t);Number.isFinite(r)&&(e.default_selection_count=r)},setOptionsQueryID(t){e.options_query_id=t??""}})),ya=f.types.compose("FilterMultiSelectConfigMeta",f.types.model({_name:f.types.literal("multi-select"),min_width:f.types.optional(f.types.string,""),default_value:f.types.optional(f.types.array(f.types.string),[]),default_value_mode:ha}),ba).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return at({_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,default_value_mode:a,default_selection_count:d})},get defaultSelection(){const t=e.filter.formattedDefaultValue;return Array.isArray(t)&&t.length>0||!e.usingQuery?t:e.options.slice(0,e.default_selection_count).map(r=>r.value)},optionsByValues(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set(t);return e.options.filter(a=>r.has(a.value))},initialSelection(t){return t||this.defaultSelection},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=f.cast(t)},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},setMinWidth(t){e.min_width=t},applyDefaultSelection(){if(e.optionsLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=new Set(e.options.map(o=>o.value)),a=(e.filter.value??[]).filter(o=>t.has(o));a.length>0?e.filter.setValue(a):e.filter.setValue(e.defaultSelection)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.defaultSelection),e.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Mi=()=>ya.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),va=f.types.compose("FilterConfigModel_Select",f.types.model({_name:f.types.literal("select"),default_value:f.types.string,width:f.types.optional(f.types.string,""),clearable:f.types.optional(f.types.boolean,!1)}),ba).views(e=>({get json(){const{_name:t,clearable:r,default_value:a,required:o,width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return at({_name:t,width:l,required:o,clearable:r,default_value:a,static_options:i,options_query_id:c,default_selection_count:d})},truthy(t){return!!t},getSelectOption(t){return e.options.find(r=>r.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){t!==null&&(e.default_value=t)},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var a;const t=e.filter.value,r=(a=e.options.find(o=>o.value===t))==null?void 0:a.value;r?e.filter.setValue(r):e.filter.setValue(e.default_selection)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Ii=()=>va.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),_a=f.types.model("FilterTextInputConfigMeta",{_name:f.types.literal("text-input"),required:f.types.boolean,default_value:f.types.string}).views(e=>({get json(){const{_name:t,required:r,default_value:a}=e;return{_name:t,required:r,default_value:a}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),ma=()=>_a.create({_name:"text-input",required:!1,default_value:""}),GT=`
|
|
528
|
+
`}}function zC(e){const t=e.unit.show_in_tooltip?e.unit.text:"";return X.getTooltip({trigger:"item",formatter:DC(t)})}const MC={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function IC(e,t,r){r.reduce((l,i)=>{const c=He(i,t);return l[i.name]=Be(i,c),l},{});const o={series:{data:SC(e,t),levels:kC(e)},tooltip:zC(e)};return y.defaultsDeep({},o,MC)}function VC({context:e,instance:t}){const{variables:r}=e,{value:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaults({},a,Rr),[a]),l=e.data,{width:i,height:c}=e.viewport,d=h.useRef(null),u=h.useCallback(()=>{var _;const b=(_=d.current)==null?void 0:_.getEchartsInstance();b&&fe(t,b.getOption())},[t]),p=h.useMemo(()=>({finished:u}),[u]),g=h.useMemo(()=>IC(o,l,r),[o,l,r]);return!i||!c?null:n.jsx(ve,{width:i,height:c,children:n.jsx(he,{echarts:ce,option:g,ref:d,onEvents:p,style:Yt(i,c),notMerge:!0,theme:"merico-light"})})}function PC({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["label_key","value_key","group_key"]),n.jsxs(s.Stack,{children:[n.jsx(v.Controller,{name:"label_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.name_data_field"),required:!0,...a})}),n.jsx(v.Controller,{name:"value_key",control:e,render:({field:a})=>n.jsx(L,{label:r("common.value_data_field"),required:!0,...a})}),n.jsx(v.Controller,{name:"group_key",control:e,render:({field:a})=>n.jsx(L,{label:r("viz.sunburst_chart.group_key"),clearable:!0,...a})}),n.jsx(v.Controller,{name:"unit",control:e,render:({field:a})=>n.jsx(ue,{hiddenFileds:["show_in_legend"],...a})})]})}const $C=({control:e,index:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=h.useMemo(()=>[{label:r("viz.sunburst_chart.label.rotate.radial"),value:"radial"},{label:r("viz.sunburst_chart.label.rotate.tangential"),value:"tangential"},{label:r("viz.sunburst_chart.label.rotate.none"),value:"0"}],[a.language]);return n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`levels.${t}.r0`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:r("viz.sunburst_chart.level.inside_radius"),placeholder:"0%",...l})}),n.jsx(v.Controller,{name:`levels.${t}.r`,control:e,render:({field:l})=>n.jsx(s.TextInput,{label:r("viz.sunburst_chart.level.outside_radius"),placeholder:"50%",...l})})]}),n.jsx(s.Divider,{mb:-10,mt:10,variant:"dashed",label:r("chart.label.label_full"),labelPosition:"center"}),n.jsx(v.Controller,{name:`levels.${t}.label.show_label_tolerance`,control:e,render:({field:l})=>n.jsx(s.NumberInput,{label:r("viz.sunburst_chart.label.show_label_tolerance"),decimalScale:4,step:5e-4,min:0,max:1,...l})}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`levels.${t}.label.rotate`,control:e,render:({field:l})=>n.jsx(s.Select,{label:r("viz.sunburst_chart.label.rotate.label"),data:o,...l})}),n.jsx(v.Controller,{name:`levels.${t}.label.align`,control:e,render:({field:l})=>n.jsx(yt,{...l})})]}),n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(v.Controller,{name:`levels.${t}.label.position`,control:e,render:({field:l})=>n.jsx(Ot,{label:r("chart.label_position.label"),...l,onChange:i=>{i&&l.onChange(i)}})}),n.jsx(v.Controller,{name:`levels.${t}.label.padding`,control:e,render:({field:l})=>n.jsx(s.NumberInput,{label:r("chart.padding"),min:0,hideControls:!0,...l})})]})]})},AC=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>({id:Date.now().toString(),r0:"",r:"",label:{show_label_tolerance:.001,rotate:"0",align:"center",position:"inside",padding:0}}),o=(l,i)=>i+1;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{gap:2,sx:{cursor:"default",userSelect:"none"},children:[n.jsx(T.IconInfoCircle,{size:14,color:"#888"}),n.jsx(s.Text,{size:"14px",c:"#888",children:r("viz.sunburst_chart.level.hint")})]}),n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(R,{control:e,watch:t,name:"levels",getItem:a,addButtonText:r("viz.sunburst_chart.level.add"),deleteButtonText:r("viz.sunburst_chart.level.delete"),renderTabName:o,children:({field:l,index:i})=>n.jsx($C,{control:e,index:i})})]})};function EC({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaultsDeep({},r,Rr),[r]),l=h.useMemo(()=>y.clone(o),[o]),{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});h.useEffect(()=>{p(l)},[l]),d(["label_key","value_key","group_key","levels"]);const[g,b]=h.useState("Data");return n.jsx("form",{onSubmit:c(a),children:n.jsxs(s.Stack,{gap:"xs",children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{value:g,onChange:b,orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Data",children:t("data.label")}),n.jsx(s.Tabs.Tab,{value:"Levels",children:t("viz.sunburst_chart.level.labels")})]}),n.jsx(s.Tabs.Panel,{value:"Data",children:n.jsx(PC,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Levels",children:n.jsx(AC,{control:i,watch:d})})]})]})})}const BC=[{lang:"en",resources:{sunburst_chart:{viz_name:"Sunburst Chart",level:{labels:"Levels",hint:"Configure ring style on each level",inside_radius:"Inside Radius",outside_radius:"Outside Radius",add:"Add a level",delete:"Delete this level"},label:{show_label_tolerance:"Hide label when its percentage is less than...",rotate:{label:"Rotate",radial:"Radial",tangential:"Tangential",none:"None"}},group_key:"Group Key"}}},{lang:"zh",resources:{sunburst_chart:{viz_name:"旭日图",level:{labels:"层级",hint:"为每层配置圆环样式",inside_radius:"内径",outside_radius:"外径",add:"增加一层",delete:"删除这一层"},label:{show_label_tolerance:"当百分比低于此值时,隐藏文案",rotate:{label:"旋转",radial:"径向旋转",tangential:"切向旋转",none:"不旋转"}},group_key:"分组字段"}}}];function qC(e){const{label_field:t,value_field:r,...a}=e;return{...a,label_key:t,value_key:r}}function OC(e){const{group_key:t="",...r}=e;return{...r,group_key:t}}function LC(e){const{levels:t=[],...r}=e;return{...r,levels:t}}function NC(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=d=>d&&`${r}.${d}`,{label_key:o,value_key:l,group_key:i,...c}=e;return{...c,label_key:a(o),value_key:a(l),group_key:a(i)}}catch(r){throw console.error("[Migration failed]",r),r}}function GC(e){const{unit:t}=e;return{...e,unit:t??K()}}class FC extends J{constructor(){super(...arguments);V(this,"VERSION",6)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>({...r,version:2,config:qC(r.config)})),this.version(3,r=>({...r,version:3,config:OC(r.config)})),this.version(4,r=>({...r,version:4,config:LC(r.config)})),this.version(5,(r,a)=>({...r,version:5,config:NC(r.config,a)})),this.version(6,r=>({...r,version:6,config:GC(r.config)}))}}const QC={displayName:"viz.sunburst_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new FC,name:"sunburst",viewRender:VC,configRender:EC,createConfig(){return{version:6,config:y.cloneDeep(Rr)}},translation:BC};var Ye=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.url="url",e.custom="custom",e))(Ye||{});function Al(){return{page_size:0}}const El=["function text({ value, row_data }, utils) {"," return value","}"].join(`
|
|
529
|
+
`),Bl={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px",pagination:Al()};function jC(e){const{columns:t,...r}=e;return{...e,columns:t.map(a=>({...a,align:a.align??"left"}))}}function WC(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const a=c=>c&&`${r}.${c}`,{id_field:o,columns:l,...i}=e;return{...i,id_field:a(o),columns:l.map(c=>({...c,value_field:a(c.value_field)}))}}catch(r){throw console.error("[Migration failed]",r),r}}function UC(e){const{columns:t,...r}=e;return{...r,columns:t.map(a=>({...a,align:a.align??"left",cellBackgroundColor:a.cellBackgroundColor??"",width:a.width??""}))}}function KC(e){const{id_field:t,...r}=e,{queryID:a}=$(t);return{...r,query_id:a??""}}function YC(e){const{ignored_column_keys:t,...r}=e;return{...r,ignored_column_keys:t??""}}function XC(e){const{pagination:t=Al(),...r}=e;return{...r,pagination:t}}class ZC extends J{constructor(){super(...arguments);V(this,"VERSION",8)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,r=>{const{columns:a,...o}=r.config;return{...r,version:2,config:{...o,columns:a.map(({id:l,...i})=>({id:l??te.randomId(),...i}))}}}),this.version(3,r=>({...r,version:3,config:jC(r.config)})),this.version(4,(r,a)=>({...r,version:4,config:WC(r.config,a)})),this.version(5,r=>({...r,version:5,config:UC(r.config)})),this.version(6,r=>({...r,version:6,config:KC(r.config)})),this.version(7,r=>({...r,version:7,config:YC(r.config)})),this.version(8,r=>({...r,version:8,config:XC(r.config)}))}}const ql={left:"flex-start",center:"center",right:"flex-end"},JC=({header:e,cx:t})=>{const r=y.get(e.column.columnDef.meta,"align","left");return n.jsxs(s.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),ta:r,sx:{justifyContent:ql[r]},size:"sm",children:[e.isPlaceholder?null:ge.flexRender(e.column.columnDef.header,e.getContext()),n.jsx(HC,{direction:e.column.getIsSorted()})]})},HC=({direction:e})=>{switch(e){case"asc":return n.jsx(T.IconArrowUp,{size:16});case"desc":return n.jsx(T.IconArrowDown,{size:"1em"});default:return null}},RC=pt.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colors.gray[0]}}},thead:{background:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),eS={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},Ol=pt.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:ql[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function tS(e){return e?Ge(e).oklch()[0]>.7?"black":"white":"inherit"}function Ll(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:tS(t)}}function Lt(e){const t=e.tableCellContext.isClickable(),r=Ol({clickable:t,align:e.align});return n.jsx("div",{className:r.classes.content,style:{...Ll(e)},children:n.jsx(s.Text,{size:"sm",className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:n.jsx("span",{title:e.children,children:e.children})})})}function nS(e){return n.jsx(Lt,{...e,children:e.value})}function rS(e){const t=Ol({clickable:!0,align:e.align}),r=e.value;return n.jsx("div",{className:t.classes.content,style:{...Ll(e)},children:n.jsx(s.Anchor,{className:"table-cell-text",href:r,target:"_blank",color:"black",children:r})})}function aS(e){const t=Y(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function sS(e){const t=Y(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function oS(e){const t=Y(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return n.jsx(Lt,{...e,children:t})}function lS(e){const{value:t,row_data:r,func_content:a}=e;if(!a)return n.jsx(Lt,{...e,children:t});const o=new Function(`return ${a}`)()({value:t,row_data:r},We);return n.jsx(Lt,{...e,children:o})}function iS(e){switch(e.type){case Ye.string:return n.jsx(nS,{...e});case Ye.eloc:return n.jsx(aS,{...e});case Ye.number:return n.jsx(sS,{...e});case Ye.percentage:return n.jsx(oS,{...e});case Ye.url:return n.jsx(rS,{...e});case Ye.custom:return n.jsx(lS,{...e})}}function cS({tableContainerRef:e,rows:t}){var c,d;const r=Hd.useVirtualizer({getScrollElement:()=>e.current,count:t.length,estimateSize:h.useCallback(()=>28,[]),overscan:20}),a=r.getVirtualItems(),o=r.getTotalSize(),l=a.length>0&&((c=a==null?void 0:a[0])==null?void 0:c.start)||0,i=a.length>0?o-(((d=a==null?void 0:a[a.length-1])==null?void 0:d.end)||0):0;return n.jsxs(s.Table.Tbody,{children:[l>0&&n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{style:{height:`${l}px`}})}),a.map(u=>{const p=t[u.index];return n.jsx(s.Table.Tr,{children:p.getVisibleCells().map(g=>n.jsx(s.Table.Td,{children:ge.flexRender(g.column.columnDef.cell,g.getContext())},g.id))},p.id)}),i>0&&n.jsx(s.Table.Tr,{children:n.jsx(s.Table.Td,{style:{height:`${i}px`}})})]})}const ea={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:hS,configRender:uS,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},dS={column:""};function Nl(e,t){const{value:r}=q(e.instanceData,"config"),a={columnsFromConfig:[],columnsFromData:[]};if(r&&(a.columnsFromConfig=r.columns.map((o,l)=>({label:o.label,value:l.toString()}))),!t)return a;if(r!=null&&r.query_id){const o=t[r.query_id];(o==null?void 0:o.length)>0&&(a.columnsFromData=Object.keys(o[0]).map(l=>({label:l,value:l})))}return a}function Gl(e){const{value:t}=q(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function uS(e){const{t}=m.useTranslation(),{columnsFromConfig:r,columnsFromData:a}=Nl(e.instance,e.sampleData),o=Gl(e.instance),l=r.length>0?r:a,{value:i,set:c}=q(e.trigger.triggerData,"config"),{column:d}=y.defaults({},i,dS),u=p=>{p&&(isNaN(+p)?c({column:p}):c({column:+p}))};return o?n.jsxs(s.Stack,{children:[n.jsx(s.Alert,{icon:n.jsx(T.IconAlertCircle,{size:"1rem"}),color:"gray",children:n.jsxs(m.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",n.jsx(s.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),n.jsx(s.TextInput,{label:t("viz.table.click_cell.column_data_field"),value:d.toString(),onChange:p=>u(p.currentTarget.value)})]}):n.jsx(s.Select,{clearable:!1,data:l,label:t("viz.table.click_cell.choose_a_column"),value:d.toString(),onChange:u,comboboxProps:{zIndex:340},maxDropdownHeight:500})}function pS(e,t,r){const{t:a}=m.useTranslation();if(!e)return a("viz.table.click_cell.click_cell_content");if(y.isNumber(e.column)){if(r)return a("viz.table.click_cell.click_cell_of_x_th",{x:e.column+1});const o=t[e.column];return o?a("viz.table.click_cell.click_cell_of_x",{x:o.label}):a("viz.table.click_cell.click_cell_invalid_config")}return a("viz.table.click_cell.click_cell_of_x",{x:e.column})}function hS(e){const{columnsFromConfig:t}=Nl(e.instance),{value:r}=q(e.trigger.triggerData,"config"),a=Gl(e.instance);return n.jsx(s.Text,{size:"sm",children:pS(r,t,a)})}function Fl(e,t,r){return Math.min(Math.max(e,t),r)}class gS{constructor(t){this.steps=t;const r=[],a=new Set;for(const o of t)a.has(o.to)||(r.push(o),a.add(o.to));if(r.sort((o,l)=>o.from-l.from),r.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=r}getLinearFunction(t,r){const a=(r.to-t.to)/(r.from-t.from),o=t.to-a*t.from;return l=>a*l+o}getStepFunctionForValue(t){let r=y.findLastIndex(this.steps,a=>a.from<=t);return r=Fl(r,0,this.steps.length-2),this.getLinearFunction(this.steps[r],this.steps[r+1])}mapValue(t){return Fl(this.getStepFunctionForValue(t)(t),0,100)}}class fS{constructor(t,r,a,o,l){this.getColIndex=t,this.cell=r,this.triggers=a,this.interactionManager=o,this.colorManager=l}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const r={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const a of t)this.interactionManager.runInteraction(a.id,r)}}getRelatedTrigger(){return this.triggers.filter(r=>r.schemaRef===ea.id).filter(r=>{const a=this.getColIndex(this.cell),o=y.get(this.cell.column.columnDef.meta,"value_field"),l=y.get(r.config,"column");return l==a||l==o})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(y.isString(t))return t;const r=+this.cell.getValue();if(isFinite(r)){const a=this.colorManager.decodeInterpolation(t.interpolation),l=new gS(t.steps).mapValue(r);return a==null?void 0:a.getColor(l)}}}const bS=e=>{const t=Pe(e),r=Ve(t.triggerManager,ea.id),{colorManager:a}=h.useContext(ot);return h.useCallback(o=>new fS(e.getColIndex,o,r,t,a),[r,t,e.getColIndex])},yS=({classes:e,pagination:t,setPagination:r,pageCount:a,totalRows:o})=>{const{t:l}=m.useTranslation(),{pageSize:i,pageIndex:c}=t;if(o===0)return null;if(i===0)return n.jsx(s.Box,{className:e.info_bar,sx:{height:22},children:n.jsx(s.Text,{ta:"right",pr:6,size:"14px",c:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:o})})});const d=()=>{r({...t,pageIndex:c-1})},u=()=>{r({...t,pageIndex:c+1})};return n.jsxs(s.Group,{wrap:"nowrap",justify:"flex-end",gap:4,className:e.info_bar,sx:{height:22},children:[n.jsx(s.Text,{ta:"right",pr:6,size:"14px",c:"dimmed",fw:"normal",children:l("common.pagination.showing_rows",{start_row:c*i+1,end_row:(c+1)*i,total:o})}),n.jsx(s.ActionIcon,{variant:"default","aria-label":"to previous page",onClick:d,size:"xs",disabled:c===0,children:n.jsx(T.IconChevronLeft,{})}),n.jsx(s.ActionIcon,{variant:"default","aria-label":"to next page",onClick:u,size:"xs",disabled:c===a-1,children:n.jsx(T.IconChevronRight,{})})]})};function Ql({queryData:e,width:t,height:r,conf:a,context:o,instance:l}){m.useTranslation();const{use_raw_columns:i,ignored_column_keys:c,columns:d,...u}=a,{classes:p,cx:g}=RC(),b=h.useMemo(()=>{if(!i)return d;if(!Array.isArray(e)||e.length===0)return[];let Ae=Object.keys(e[0]);const xe=new Set(c==null?void 0:c.split(/\r?\n|\r|\n/g).filter(pe=>!!pe));return xe.size>0&&(Ae=Ae.filter(pe=>!xe.has(pe))),Ae.map(pe=>({id:pe,label:pe,value_field:pe,value_type:Ye.string,align:"left",width:"",cellBackgroundColor:""}))},[i,c,d,e]),_=bS({getColIndex:h.useCallback(Ae=>b.indexOf(Ae.column.columnDef.meta),[b]),vizManager:o.vizManager,instance:l}),w=h.useMemo(()=>{const Ae=ge.createColumnHelper();return b.map(pe=>{const qM=up(pe.value_field);return Ae.accessor(qM.columnKey,{cell:bs=>n.jsx(iS,{tableCellContext:_(bs.cell),value:bs.getValue(),type:pe.value_type,row_data:bs.row.original,...pe}),header:pe.label,enableSorting:!0,meta:pe,size:typeof pe.width=="number"?pe.width:void 0,minSize:typeof pe.width=="number"?pe.width:void 0})})},[b,_]),[x,S]=h.useState([]),[D,z]=h.useState({pageIndex:0,pageSize:a.pagination.page_size}),I=h.useMemo(()=>{const{pageIndex:Ae,pageSize:xe}=D;return xe===0?e:e.slice(Ae*xe,(Ae+1)*xe)},[e,D]),A=Math.ceil(e.length/D.pageSize),E=ge.useReactTable({data:I,state:{sorting:x},onSortingChange:S,columns:w,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel(),getSortedRowModel:ge.getSortedRowModel()}),{rows:U}=E.getRowModel(),N=h.useRef(null),oe=e.length,be=oe>0,ct=be?r-22:r,mt=be?22:0;return n.jsxs("div",{ref:N,style:{height:r,width:t,padding:"0 5px"},"data-enable-scrollbar":!0,className:g(p.root,{"table-highlight-on-hover":a.highlightOnHover}),children:[n.jsx(yS,{classes:p,pagination:D,totalRows:oe,setPagination:z,pageCount:A}),n.jsxs(s.Table,{sx:{...eS,maxHeight:ct},...u,striped:a.striped,children:[n.jsx(s.Table.Thead,{className:p.thead,style:{top:mt},children:E.getHeaderGroups().map(Ae=>n.jsx(s.Table.Tr,{children:Ae.headers.map(xe=>n.jsxs(s.Table.Th,{style:{width:xe.getSize()},children:[n.jsx(JC,{header:xe,cx:g}),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:xe.getResizeHandler(),onTouchStart:xe.getResizeHandler(),className:`resizer ${xe.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},xe.id))},Ae.id))}),n.jsx(cS,{tableContainerRef:N,rows:U})]})]})}function jl(){const{t:e}=m.useTranslation();return n.jsx(s.Text,{size:"sm",c:"gray",ta:"center",children:e("data.empty_data")})}function vS({data:e,width:t,height:r,conf:a,context:o,instance:l}){const{t:i}=m.useTranslation(),{panel:c}=re(),d=c.firstQueryData??[];if(c.queryIDs.length===0)return n.jsx(s.Text,{size:"sm",c:"gray",ta:"center",children:i("panel.settings.need_to_choose_queries")});const{query_id:u}=a;if(!u)return d.length===0?n.jsx(jl,{}):n.jsx(Ql,{queryData:d,width:t,height:r,conf:{...a,use_raw_columns:!0,columns:[]},context:o,instance:l});const p=e[u];return!Array.isArray(p)||p.length===0?n.jsx(jl,{}):n.jsx(Ql,{queryData:p,width:t,height:r,conf:a,context:o,instance:l})}function _S({context:e,instance:t}){const r=e.data,{height:a,width:o}=e.viewport,{value:l}=q(e.instanceData,"config");return l?n.jsx(vS,{data:r,width:o,height:a,conf:l,context:e,instance:t}):null}const mS=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",add:"Add a column",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",click_cell_invalid_config:"Invalid config",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",add:"加一列",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",click_cell_invalid_config:"配置信息已失效",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}],wS=k.observer(h.forwardRef(({label:e,required:t,description:r,value:a,onChange:o,clearable:l=!1,sx:i,...c},d)=>{const{panel:u}=ae(),p=h.useMemo(()=>u.queryOptions(a,l),[a,l]);return p.length===0?n.jsx(s.Box,{children:n.jsx(s.TextInput,{label:e,required:t,defaultValue:a,readOnly:!0,disabled:!0})}):n.jsx(s.Select,{ref:d,label:e,description:r,data:p,value:a,onChange:Z(o),required:t,sx:i,maxDropdownHeight:500,...c})})),xS=[{from:0,to:0},{from:100,to:100}];function Wl(e){return e?y.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function CS(e,t){var r;return Wl(t)==="static"?t:(r=e.getStaticColors()[0])==null?void 0:r.value}function SS(e,t){return y.isObject(t)?t:{steps:xS,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const TS=h.forwardRef((e,t)=>{const{t:r}=m.useTranslation(),{colorManager:a}=h.useContext(ot),[o,l]=h.useState(Wl(e.value)),[i,c]=h.useState(CS(a,e.value)),d=O.useLatest(i),[u,p]=h.useState(SS(a,e.value)),g=O.useLatest(u),b=x=>{var S,D,z;l(x||"none"),x==="static"?(S=e.onChange)==null||S.call(e,d.current):x==="none"||!x?(D=e.onChange)==null||D.call(e,"none"):(z=e.onChange)==null||z.call(e,g.current)},_=x=>{var S;c(x),(S=e.onChange)==null||S.call(e,x)},w=x=>{var S;p(x),(S=e.onChange)==null||S.call(e,x)};return n.jsxs(s.Stack,{align:"stretch",children:[n.jsx(af,{label:r("viz.table.column.cell_background"),value:o||"none",onChange:b}),o==="static"&&n.jsx(ye,{label:r("chart.color.label"),value:i,onChange:_}),o==="interpolation"&&n.jsx(rf,{colorManager:a,value:u,onChange:w})]})}),kS=h.forwardRef(({value:e,onChange:t,sx:r},a)=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>Object.values(Ye).map(c=>({label:o(`viz.table.column.value_type.${c}`),value:c})),[l.language]);return n.jsx(s.Select,{ref:a,label:o("viz.table.column.value_type.label"),data:i,value:e,onChange:Z(t),maxDropdownHeight:500,sx:r})}),DS=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(),[c,d]=h.useState(e),u=()=>{i(),t(c)},p=()=>{i(),d(e)},g=()=>{d(El)};return h.useEffect(()=>{d(e)},[e]),n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:a("viz.table.column.custom_cell_content")}),n.jsx(s.Modal,{size:800,title:a("viz.table.column.custom_cell_content"),opened:o,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(s.Stack,{children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(xo,{})}),n.jsx(s.Box,{sx:{position:"relative"},children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:c,onChange:b=>d(b??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:a("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:a("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:u,children:a("common.actions.save")})]})]})]})})]})}),ta=()=>n.jsx(s.Text,{c:"dimmed",size:"12px",children:"px"}),zS=({control:e,index:t,watch:r})=>{const{t:a}=m.useTranslation(),o=r(`columns.${t}.value_type`),l=r("query_id");return n.jsxs(s.Stack,{my:0,sx:{position:"relative"},children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`columns.${t}.label`,control:e,render:({field:i})=>n.jsx(s.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${t}`,sx:{flex:1},...i})}),n.jsx(v.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:i})=>n.jsx(L,{label:a("common.data_field"),required:!0,queryID:l,...i})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:i})=>n.jsx(kS,{sx:{flex:1},...i})}),o===Ye.custom&&n.jsx(v.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:i})=>n.jsx(DS,{value:i.value??El,onChange:c=>i.onChange(c??"")})})]}),n.jsx(s.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:n.jsx(ta,{}),disabled:!0}),n.jsx(v.Controller,{name:`columns.${t}.width`,control:e,render:({field:i})=>n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:n.jsx(ta,{}),...i})}),n.jsx(s.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:n.jsx(ta,{}),disabled:!0})]}),n.jsx(s.Group,{grow:!0,wrap:"nowrap",children:n.jsx(v.Controller,{name:`columns.${t}.align`,control:e,render:({field:i})=>n.jsx(Ir,{...i})})}),n.jsx(v.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:i})=>n.jsx(TS,{...i})})]})},MS=({control:e,watch:t})=>{const{t:r}=m.useTranslation(),a=()=>{const i=te.randomId();return{id:i,label:i,align:"center",value_field:"",value_type:Ye.string,width:""}},o=(i,c)=>{const d=i.label.trim();return d||c+1};t(["columns","ignored_column_keys"]);const l=t("use_raw_columns");return n.jsxs(n.Fragment,{children:[n.jsx(v.Controller,{name:"use_raw_columns",control:e,render:({field:i})=>n.jsx(s.Switch,{mt:20,mb:20,label:r("viz.table.column.use_original_data_columns"),checked:i.value,onChange:c=>i.onChange(c.currentTarget.checked)})}),l&&n.jsx(v.Controller,{name:"ignored_column_keys",control:e,render:({field:i})=>n.jsx(s.Textarea,{label:r("viz.table.column.ignore_columns_by_these_key"),placeholder:r("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...i})}),!l&&n.jsx(R,{control:e,watch:t,name:"columns",getItem:a,addButtonText:r("viz.table.column.add"),deleteButtonText:r("viz.table.column.delete"),renderTabName:o,children:({field:i,index:c})=>n.jsx(zS,{control:e,watch:t,index:c})})]})};function IS({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),n.jsxs(s.Stack,{gap:"xs",children:[n.jsxs(s.Group,{justify:"space-between",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[n.jsx(v.Controller,{name:"horizontalSpacing",control:e,render:({field:a})=>n.jsx($r,{disabled:!0,label:r("viz.table.style.horizontal_spacing"),sx:{flex:1},...a})}),n.jsx(v.Controller,{name:"verticalSpacing",control:e,render:({field:a})=>n.jsx($r,{disabled:!0,label:r("viz.table.style.vertical_spacing"),sx:{flex:1},...a})})]}),n.jsx(s.Group,{justify:"space-between",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:n.jsx(v.Controller,{name:"fontSize",control:e,render:({field:a})=>n.jsx(s.TextInput,{label:r("style.font_size.label"),placeholder:r("style.font_size.placeholder"),required:!0,sx:{flex:1},...a})})}),n.jsxs(s.Group,{justify:"space-between",grow:!0,children:[n.jsx(v.Controller,{name:"striped",control:e,render:({field:a})=>n.jsx(s.Switch,{label:r("viz.table.style.striped"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})}),n.jsx(v.Controller,{name:"highlightOnHover",control:e,render:({field:a})=>n.jsx(s.Switch,{label:r("viz.table.style.highlight_on_hover"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})]})]})}function VS({control:e,watch:t}){const{t:r}=m.useTranslation();return t(["pagination"]),n.jsx(s.Stack,{children:n.jsx(v.Controller,{name:"pagination.page_size",control:e,render:({field:a})=>n.jsx(s.NumberInput,{label:r("common.pagination.page_size"),description:r("viz.heatmap.pagination.page_size_hint"),size:"xs",sx:{flex:1},...a,onChange:o=>{typeof o!="string"&&a.onChange(o)}})})})}function PS({columns:e,...t}){return{...t,columns:e.map(({id:r,...a})=>({id:r??te.randomId(),...a}))}}function $S({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaultsDeep({},r,Bl),[r]),l=h.useMemo(()=>PS(o),[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["query_id"]),n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Columns",children:t("viz.table.column.labels")}),n.jsx(s.Tabs.Tab,{value:"Style",children:t("style.label")}),n.jsx(s.Tabs.Tab,{value:"Pagination",children:t("common.pagination.label")})]}),n.jsxs(s.Tabs.Panel,{value:"Columns",children:[n.jsx(v.Controller,{name:"query_id",control:i,render:({field:g})=>n.jsx(wS,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...g})}),n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(MS,{control:i,watch:d})]}),n.jsx(s.Tabs.Panel,{value:"Style",children:n.jsx(IS,{control:i,watch:d})}),n.jsx(s.Tabs.Panel,{value:"Pagination",children:n.jsx(VS,{control:i,watch:d})})]})]})}const Ul=new ZC,na={createConfig(){return{version:Ul.VERSION,config:y.cloneDeep(Bl)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:Ul,name:"table",viewRender:_S,configRender:$S,triggers:[ea],translation:mS},Kl=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
530
|
+
`),ra={func_content:Kl,horizontal_align:"left",font_size:"14px",font_weight:"normal"},AS=k.observer(({context:e})=>{const t=H(),{value:r=ra}=q(e.instanceData,"config"),{variables:a}=e,o=e.data,{func_content:l,horizontal_align:i,font_size:c,font_weight:d}=r,u=h.useMemo(()=>a.reduce((g,b)=>{const _=He(b,o);return g[b.name]=Be(b,_),g},{}),[a,o]),p=h.useMemo(()=>new Function(`return ${l}`)()({data:o,variables:u,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[l,o,u,t.payloadForSQL]);return n.jsx(s.Text,{ta:i,fw:d,sx:{fontSize:c},children:p})}),In=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function ES({label:e,value:t,onChange:r},a){var i;const[o,l]=h.useState(((i=In.find(c=>c.label===t))==null?void 0:i.value)??In[0].value);return h.useEffect(()=>{const c=In.find(d=>d.value===o);c&&r(c.label)},[o]),n.jsxs(s.Stack,{gap:0,mt:"sm",mb:"lg",children:[n.jsx(s.Text,{size:"sm",children:e}),n.jsx(s.Box,{px:"1.5em",children:n.jsx(s.Slider,{label:null,marks:In,value:o,onChange:l,step:25,ref:a})})]})}const BS=h.forwardRef(ES),qS=({value:e,onChange:t})=>{const r=a=>{a&&t(a)};return n.jsx(s.Box,{sx:{position:"relative"},children:n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},OS=h.forwardRef(({value:e,onChange:t},r)=>{const{t:a}=m.useTranslation(),[o,{setTrue:l,setFalse:i}]=O.useBoolean(),[c,d]=h.useState(e),u=()=>{i(),t(c)},p=()=>{i(),d(e)},g=()=>{d(Kl)};return h.useEffect(()=>{d(e)},[e]),n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{color:"grape",variant:"filled",leftSection:n.jsx(T.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:a("viz.text.content.edit")}),n.jsx(s.Modal,{size:800,title:a("viz.text.content.label"),opened:o,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(s.Stack,{children:[n.jsx(qS,{value:c,onChange:d}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:g,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:a("common.actions.reset_to_default")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:a("common.actions.cancel")}),n.jsx(s.Button,{color:"green",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:u,children:a("common.actions.save_changes")})]})]})]})})]})});function LS({context:e}){const{t}=m.useTranslation(),{value:r,set:a}=q(e.instanceData,"config"),o=h.useMemo(()=>y.defaultsDeep({},r,ra),[r]),l=h.useMemo(()=>{const{func_content:g,horizontal_align:b,font_size:_,font_weight:w}=o;return{func_content:g,horizontal_align:b,font_size:_,font_weight:w}},[o]);h.useEffect(()=>{!y.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),a(l))},[o,l]);const{control:i,handleSubmit:c,watch:d,formState:u,reset:p}=v.useForm({defaultValues:l});return h.useEffect(()=>{p(l)},[l]),d(["func_content","horizontal_align","font_size","font_weight"]),n.jsx(s.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:c(a),children:[n.jsx(se,{canSubmit:u.isDirty}),n.jsxs(s.Stack,{gap:10,children:[n.jsx(v.Controller,{name:"func_content",control:i,render:({field:g})=>n.jsx(OS,{...g})}),n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:t("chart.style.label"),labelPosition:"center"}),n.jsx(v.Controller,{name:"horizontal_align",control:i,render:({field:g})=>n.jsx(Ir,{...g})}),n.jsx(v.Controller,{name:"font_size",control:i,render:({field:g})=>n.jsx(s.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...g})}),n.jsx(s.Group,{justify:"space-between",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:n.jsx(v.Controller,{name:"font_weight",control:i,render:({field:g})=>n.jsx(BS,{label:t("style.font_weight.label"),...g})})})]})]})})}const NS=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class GS extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const FS={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new GS,name:"text",viewRender:AS,configRender:LS,createConfig(){return{version:1,config:y.cloneDeep(ra)}},translation:NS},aa={item_badge:"_item_badge_l2t3l_1",label:"_label_l2t3l_8",value:"_value_l2t3l_20"},QS=({children:e})=>["string","number"].includes(typeof e)?n.jsx(s.Text,{size:"xs",ff:"monospace",children:e}):e,vt=h.forwardRef(({label:e,value:t,label_description:r,value_description:a},o)=>n.jsxs("div",{ref:o,className:aa.item_badge,children:[n.jsx("div",{className:aa.label,children:e}),n.jsxs(s.HoverCard,{shadow:"md",disabled:!a,children:[n.jsx(s.HoverCard.Target,{children:n.jsx("div",{className:aa.value,"data-with-tooltip":!!a,children:t})}),n.jsx(s.HoverCard.Dropdown,{p:"xs",children:n.jsx(QS,{children:a})})]})]})),jS=({item:e})=>e.type!=="checkbox"?null:n.jsx(vt,{label:e.label,value:n.jsx(s.ThemeIcon,{variant:"white",radius:"xs",color:e.value?"teal":"red",w:12,h:12,miw:12,mih:12,children:e.value?n.jsx(T.IconCheck,{size:12,strokeWidth:3}):n.jsx(T.IconX,{strokeWidth:3})}),label_description:`filters.${e.key}`}),WS=({item:e})=>e.type!=="context"?null:n.jsx(vt,{label:e.key,value:e.value,label_description:`context.${e.key}`}),US=k.observer(({item:e})=>{const{t}=m.useTranslation(),a=e.model.value,[o,l]=a.value,i=h.useMemo(()=>!l&&!o?Number.NaN:M(l).diff(M(o),"days")+1,[o,l]);if(Number.isNaN(i))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const c=i===1?t("filter.widget.date_range.one_day"):t("filter.widget.date_range.x_days",{count:i});return n.jsx(vt,{label:e.label,value:e.value.join(" ~ "),label_description:`filters.${e.key}`,value_description:c})}),KS=({item:e})=>e.type!=="date-range"?null:n.jsx(US,{item:e}),Yl=({selection:e})=>(m.useTranslation(),e.length===0?null:n.jsx(s.Group,{justify:"flex-start",gap:"xs",maw:"80vw",children:e.map(t=>n.jsx(s.Pill,{size:"xs",ff:"monospace",children:t.label},t.value))})),YS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>r.optionsByValues(e.value),[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a.length,label_description:`filters.${e.key}`,value_description:n.jsx(Yl,{selection:a})})}),XS=({item:e})=>e.type!=="multi-select"?null:n.jsx(YS,{item:e}),ZS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>{var o;return((o=r.options.find(l=>l.value===e.value))==null?void 0:o.label)??e.value},[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a,label_description:`filters.${e.key}`})}),JS=({item:e})=>e.type!=="select"?null:n.jsx(ZS,{item:e}),HS=({item:e})=>e.type!=="text-input"?null:n.jsx(vt,{label:e.label,value:n.jsx(s.Text,{maw:200,size:"xs",truncate:"end",ff:"monospace",children:e.value}),value_description:e.value}),RS=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>r.optionsByValues(e.value),[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a.length,label_description:`filters.${e.key}`,value_description:n.jsx(Yl,{selection:a})})}),eT=({item:e})=>e.type!=="tree-select"?null:n.jsx(RS,{item:e}),tT=k.observer(({item:e})=>{m.useTranslation();const r=e.model.config,a=h.useMemo(()=>{var o;return((o=r.options.find(l=>l.value===e.value))==null?void 0:o.label)??e.value},[e.value,r.options]);return n.jsx(vt,{label:e.label,value:a,label_description:`filters.${e.key}`,value_description:e.value})}),nT=({item:e})=>e.type!=="tree-single-select"?null:n.jsx(tT,{item:e}),sa=({item:e})=>{switch(e.type){case"date-range":return n.jsx(KS,{item:e});case"select":return n.jsx(JS,{item:e});case"tree-single-select":return n.jsx(nT,{item:e});case"multi-select":return n.jsx(XS,{item:e});case"tree-select":return n.jsx(eT,{item:e});case"text-input":return n.jsx(HS,{item:e});case"checkbox":return n.jsx(jS,{item:e});case"context":return n.jsx(WS,{item:e});default:return null}},rT=k.observer(({conf:e})=>{const r=H().dashboardState,{all:a,keys:o}=e;return a?n.jsxs(n.Fragment,{children:[Object.entries(r.context).map(([l,i])=>n.jsx(sa,{item:i},l)),Object.entries(r.filters).map(([l,i])=>n.jsx(sa,{item:i},l))]}):n.jsx(n.Fragment,{children:o.map(l=>{const i=y.get(r,l);return i?n.jsx(sa,{item:i},l):null})})}),aT=k.observer(({context:e})=>{const{value:t}=q(e.instanceData,"config"),{width:r,height:a}=e.viewport;return t?n.jsx(s.Group,{justify:"flex-start",align:"flex-start",wrap:"wrap",px:0,py:0,gap:"xs",w:r,mah:a,style:{overflow:"auto"},"data-enable-scrollbar":!0,children:n.jsx(rT,{conf:t})}):null}),Xl={all:!0,keys:[]},sT={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","tree-single-select":"filter.widget.names.tree_single_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},oT=({option:e,checked:t,...r})=>{const{t:a}=m.useTranslation(),o=e,l=o.type==="filter";return n.jsxs(s.Group,{gap:4,flex:1,children:[n.jsx(T.IconCheck,{size:14,opacity:t?1:0,color:"black"}),n.jsx(s.Stack,{gap:0,py:4,px:8,flex:1,styles:{root:{flexGrow:1,borderRadius:"4px"}},...r,children:n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(s.Text,{size:"xs",children:e.label}),l&&n.jsx(s.Text,{size:"xs",c:t?"rgba(0,0,0,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:a(sT[o.widget])})]})})]})},lT=k.observer(({value:e,onChange:t,disabled:r})=>{const{t:a}=m.useTranslation(),l=F().dashboardStateVariableOptions,i=h.useMemo(()=>{const{optionGroups:c,validValues:d}=l,u=c.map(g=>({group:a(g.group),items:g.items.map(b=>({...b,label:b.label,value:b.value,widget_label:b.label}))})),p=e.filter(g=>!d.has(g)).map(g=>({label:g,value:g,disabled:!0}));return p.length>0&&u.push({group:a("common.invalid"),items:p}),u},[l,a,e]);return n.jsx(s.MultiSelect,{size:"xs",label:a("viz.vizDashboardState.variable_selector.label"),placeholder:e.length===0?a("viz.vizDashboardState.variable_selector.placeholder"):void 0,data:i,renderOption:oT,maxDropdownHeight:600,value:e,onChange:t,disabled:r,clearable:!0})}),iT=({form:e})=>{const{t}=m.useTranslation(),r=e.watch("all");return n.jsxs(s.Stack,{gap:"xs",p:"xs",children:[n.jsx(v.Controller,{name:"all",control:e.control,render:({field:a})=>n.jsx(s.Checkbox,{size:"xs",label:t("viz.vizDashboardState.show_all"),checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})}),n.jsx(v.Controller,{name:"keys",control:e.control,render:({field:a})=>n.jsx(lT,{disabled:r,...a})})]})};function cT({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,Xl),[t]),o=v.useForm({defaultValues:a}),{handleSubmit:l,formState:i,reset:c}=o;return h.useEffect(()=>{c(a)},[a]),n.jsxs("form",{onSubmit:l(r),children:[n.jsx(se,{canSubmit:i.isDirty}),n.jsx(iT,{form:o})]})}const dT=[{lang:"en",resources:{vizDashboardState:{viz_name:"Dashboard State",show_all:"Show all filters and context entries",variable_selector:{label:"Select filters and context entries to show",placeholder:""}}}},{lang:"zh",resources:{vizDashboardState:{viz_name:"看板状态",show_all:"显示所有筛选器和上下文条目",variable_selector:{label:"选择要展示的筛选器和上下文",placeholder:""}}}}];class uT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const pT={displayName:"viz.vizDashboardState.viz_name",displayGroup:"chart.groups.others",migrator:new uT,name:"vizDashboardState",viewRender:aT,configRender:cT,createConfig:()=>({version:1,config:Xl}),translation:dT},hT=()=>n.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),n.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),n.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function Zl(e,t){const r=y.get(e,t,"");if(r)throw new Error(r)}async function gT(e,t,r,a={}){const o={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",...a.headers},l={baseURL:e,method:"POST",url:t,params:a.params,headers:o};return l.data=a.string?JSON.stringify(r):r,ke(l).then(i=>i.data).catch(i=>Promise.reject(i))}const fT=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:r,path:a,goal:o,question:l}=e;if(!a||!o||!l)return;const i=pp(t);if(!i)return;const c={dashboard:o,panel:l,data:i};try{const d=r.startsWith("http")?r:window.location.origin;return await gT(d,`/expert/v3/devtable/${a}`,c,{})}catch(d){throw Zl(d,"response.data.detail"),Zl(d,"response.data.error"),console.error(d),d}},oa={expertSystemURL:"",path:"",goal:"",question:""},la={height:"100%",overflowY:"auto",...dr},Jl=({message:e})=>n.jsx(s.Box,{sx:la,children:n.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),bT=({error:e,width:t,height:r})=>{const a=e.message;if(a.startsWith("<"))return n.jsx(Jl,{message:a});const l=r-25-20-30;return n.jsx(s.Center,{sx:{width:"100%",height:l},children:n.jsxs(s.Stack,{align:"center",gap:20,children:[n.jsx(hT,{}),n.jsx(Jl,{message:a})]})})};function yT({context:e}){const{value:t}=q(e.instanceData,"config"),r=h.useMemo(()=>y.defaultsDeep({},t,oa),[t]),{width:a,height:o}=e.viewport,l=e.data,{data:i,error:c,loading:d}=O.useRequest(fT({conf:r,panelData:l}),{refreshDeps:[l,r]});return!a||!o||!r?null:d?n.jsx(s.Box,{sx:{position:"relative",height:o},children:n.jsx(s.LoadingOverlay,{visible:!0})}):c?n.jsx(s.Box,{sx:la,"data-enable-scrollbar":!0,children:n.jsx(bT,{error:c,width:a,height:o})}):!i||!Array.isArray(i.replies)||i.replies.length===0?null:n.jsx(s.Box,{sx:la,"data-enable-scrollbar":!0,children:i.replies.map((u,p)=>n.jsx("div",{dangerouslySetInnerHTML:{__html:u.interpretation.html}},p))})}function vT({context:e}){const{value:t,set:r}=q(e.instanceData,"config"),a=h.useMemo(()=>y.defaultsDeep({},t,oa),[t]),{control:o,handleSubmit:l,watch:i,formState:c,reset:d}=v.useForm({defaultValues:a});return h.useEffect(()=>{d(a)},[a]),i(["expertSystemURL","goal","path","question"]),n.jsx("form",{onSubmit:l(r),children:n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"expertSystemURL",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Expert System URL",...u})}),n.jsx(v.Controller,{name:"path",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Path",required:!0,...u})})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(v.Controller,{name:"goal",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Goal",required:!0,...u})}),n.jsx(v.Controller,{name:"question",control:o,render:({field:u})=>n.jsx(s.TextInput,{label:"Question",required:!0,...u})})]}),n.jsx(s.Divider,{variant:"dashed",mt:16,mb:8}),n.jsx(s.Button,{type:"submit",variant:"filled",color:"blue",leftSection:n.jsx(T.IconDeviceFloppy,{size:20}),disabled:!c.isDirty,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const _T=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class mT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const wT={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new mT,name:"mericoGQM",viewRender:yT,configRender:vT,createConfig(){return{version:1,config:y.cloneDeep(oa)}},translation:_T};class xT extends J{constructor(){super(...arguments);V(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}function CT({context:e}){const{t}=m.useTranslation(),{inEditMode:r}=Ys();if(!r)return null;const{width:a,height:o}=e.viewport;return n.jsx(s.Center,{w:a,h:o,title:t("viz.merico_panel_groups.render"),children:n.jsx(s.Text,{c:"dimmed",size:"xs",children:t("viz.merico_panel_groups.render")})})}const ST=[{lang:"en",resources:{merico_panel_groups:{viz_name:"Merico Panel Groups",render:'"Merico Panel Groups" is a ghost viz, the whole panel will not shown in dashboard',groups:{label:"Groups",add:"Add a group",name:"Name",comment:"Remark",panel_ids:"Panels",yaml:{button:"Import from YAML",modal_title:"Import from YAML",label:"YAML content",submit:"Submit",error_title:"Failed"}}}}},{lang:"zh",resources:{merico_panel_groups:{viz_name:"思码逸卡片组",render:"在使用看板时,思码逸卡片组不会参与渲染",groups:{label:"卡片组",add:"增加一组",name:"名称",comment:"备注",panel_ids:"卡片",yaml:{button:"从YAML导入",modal_title:"从YAML导入",label:"YAML内容",submit:"提交",error_title:"解析失败"}}}}}],Hl=()=>({groups:[]}),TT=({append:e})=>{const{t}=m.useTranslation(),r=()=>{e({name:"",comment:"",panelIDs:[]})};return n.jsx(s.Flex,{gap:"sm",justify:"center",align:"center",direction:"row",wrap:"nowrap",children:n.jsx(s.Group,{wrap:"nowrap",style:{flex:1},children:n.jsx(s.Button,{size:"xs",variant:"subtle",onClick:r,leftSection:n.jsx(T.IconPlus,{size:14}),children:t("viz.merico_panel_groups.groups.add")})})})},kT=({row:e,index:t,handleChange:r,handleRemove:a,panelOptions:o})=>{const{t:l}=m.useTranslation(),[i,{setTrue:c}]=O.useBoolean(!1),d=g=>{r({...e,name:g})},u=g=>{r({...e,comment:g})},p=g=>{r({...e,panelIDs:g})};return n.jsxs(s.Stack,{gap:"xs",p:"xs",style:{border:"1px solid var(--mantine-color-gray-4)",borderRadius:"2px"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",style:{flex:1},children:[n.jsx(s.TextInput,{size:"xs",value:e.name,placeholder:l("viz.merico_panel_groups.groups.name"),onChange:g=>d(g.currentTarget.value),onClick:c,error:i&&!e.name}),n.jsx(s.TextInput,{size:"xs",value:e.comment,placeholder:l("viz.merico_panel_groups.groups.comment"),onChange:g=>u(g.currentTarget.value)})]}),n.jsx(s.MultiSelect,{label:"",placeholder:l("viz.merico_panel_groups.groups.panel_ids"),onChange:p,value:e.panelIDs,clearable:!0,size:"xs",data:o,maxDropdownHeight:500,comboboxProps:{width:300,position:"bottom-start"}}),n.jsx(s.Button,{variant:"subtle",color:"red",size:"xs",ml:"auto",mt:"md",leftSection:n.jsx(T.IconTrash,{size:14}),onClick:a,children:"删除这一组"})]})};function DT(e){try{const t=[],r=e.split(`
|
|
531
|
+
`);let a="";for(let o=0;o<r.length;o++){const l=r[o];if(l.includes("#")){const d=l.split("# ")[1].trim();d&&(a=d,console.log({comment:a}));continue}const[i,c]=l.split(": ").map(d=>d.trim());console.log({name:i,panelIDString:c}),t.push({name:i,comment:a,panelIDs:JSON.parse(c)})}return t}catch(t){throw t}}const zT=({onSubmit:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),[l,i]=h.useState("");h.useEffect(()=>{i("")},[r]);const c=()=>{try{const d=DT(l);e(d),o()}catch(d){console.error(d),Fe.showNotification({title:t("viz.merico_panel_groups.groups.yaml.error_title"),message:d.message,color:"red"})}};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{onClick:a,disabled:r,size:"xs",variant:"light",children:t("viz.merico_panel_groups.groups.yaml.button")}),n.jsx(s.Modal,{opened:r,onClose:o,title:t("viz.merico_panel_groups.groups.yaml.modal_title"),zIndex:340,size:800,children:n.jsxs(s.Stack,{gap:"lg",children:[n.jsx(s.Textarea,{label:t("viz.merico_panel_groups.groups.yaml.label"),value:l,onChange:d=>i(d.currentTarget.value),autosize:!0,minRows:10,maxRows:40,styles:{input:{fontFamily:"monospace",fontSize:"12px"}}}),n.jsx(s.Button,{ml:"auto",onClick:c,children:t("viz.merico_panel_groups.groups.yaml.submit")})]})})]})},MT=h.forwardRef(({value:e,onChange:t,data:r},a)=>{const{t:o}=m.useTranslation(),l=F(),i=h.useMemo(()=>e.map(w=>({id:Te.v4(),...w})),[e]),c=w=>{t([...e,w])},d=w=>{t(w)},u=w=>{const x=[...e];x.splice(w,1),t(x)},p=w=>x=>{const S=[...e];S[w]=x,t(S)},g=l.panels.options,b=h.useMemo(()=>new Set(i.map(w=>w.panelIDs).flat()),[i]),_=h.useMemo(()=>g.map(w=>({...w,disabled:b.has(w.value)})),[g,b]);return n.jsxs(s.Stack,{ref:a,pt:4,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",fw:"500",mb:-4,children:o("viz.merico_panel_groups.groups.label")}),n.jsx(zT,{onSubmit:d})]}),i.map((w,x)=>n.jsx(kT,{row:w,handleChange:p(x),handleRemove:()=>u(x),index:x,panelOptions:_},w.id)),n.jsx(TT,{append:c})]})});function IT({context:e}){const{value:t,set:r}=q(e.instanceData,"config");m.useTranslation();const a=e.data,o=h.useMemo(()=>y.defaultsDeep({},t,Hl()),[t]),l=v.useForm({defaultValues:o}),{handleSubmit:i,formState:c,reset:d}=l;h.useEffect(()=>{l.reset(o)},[o]);const u=p=>{const g=p;g.groups=g.groups.filter(b=>b.panelIDs.length>0||!!b.name.trim()||!!b.comment.trim()),r(g)};return n.jsxs("form",{onSubmit:i(u),children:[n.jsx(se,{canSubmit:c.isDirty}),n.jsx(s.Stack,{gap:"lg",pt:"xs",px:"xs",children:n.jsx(v.Controller,{name:"groups",control:l.control,render:({field:p})=>n.jsx(MT,{...p,data:a})})})]})}const Rl={displayName:"viz.merico_panel_groups.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new xT,name:"merico_panel_groups",viewRender:CT,configRender:IT,createConfig:()=>({version:1,config:Hl()}),translation:ST},VT=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),PT=[Wu,Uu,Xu,Yu,Ku,Zu],ia=[na,wC,FS,n1,QC,Jx,H_,kh,Ef,Dv,d_,Vb,yx,iv,nC,C0,J0,wT,Pm,sw,Pw,Rl,mw,Kf,pT],ei=ia.reduce((e,t)=>(e[t.name]={displayName:t.displayName,displayGroup:t.displayGroup},e),{}),ti=()=>({id:"dashboard",version:Qs,manifest:{viz:ia,color:[...VT,...PT]}}),Mt=new np,ee={pluginManager:Je("pluginManager"),vizManager:Je("vizManager"),colorManager:Je("colorManager"),panelAddonManager:Je("panelAddonManager"),instanceScope:{panelModel:Je("panelModel"),vizInstance:Je("vizInstance"),interactionManager:Je("interactionManager"),migrator:Je("migrator"),operationManager:Je("operationManager"),triggerManager:Je("triggerManager")}},ca=()=>{try{Mt.install(ti())}catch{}const e=new Fu(Mt),t=new tp(Mt),r=new Ju(Mt);return{pluginManager:Mt,vizManager:e,colorManager:t,panelAddonManager:r}},ot=h.createContext(ca());try{Mt.install(ti())}catch{}const Vn=Ce.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:Lu,zh:Nu}}).use(Wd).use(m.initReactI18next);Vn.init(),ia.forEach(e=>{var t;(t=e.translation)==null||t.forEach(r=>{Vn.addResourceBundle(r.lang,"translation",{viz:r.resources},!0,!0)})});function ni({lang:e,children:t}){return h.useEffect(()=>{Vn.changeLanguage(e)},[e]),n.jsx(m.I18nextProvider,{i18n:Vn,children:t})}M.extend(Rd),M.extend(eu),M.extend(tu),M.extend(nu),M.extend(ru),M.extend(au),M.extend(su),M.extend(ou),M.extend(lu),M.extend(iu),M.extend(uu),M.extend(pu),M.extend(hu),M.extend(gu),M.extend(fu),M.extend(cu),M.extend(du),M.extend(bu),M.extend(yu),M.extend(vu),M.extend(_u),M.extend(mu),M.extend(wu),M.extend(xu),M.extend(Cu),M.extend(Su),M.extend(Tu),M.extend(ku),M.extend(Du),M.extend(zu),M.extend(Iu),M.extend(Vu),M.extend(Mu),M.tz.setDefault("UTC"),M.updateLocale("en",{weekStart:1});function $T(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let a=0;a<t.length;a++){const o=t[a];if(o!="authentication"&&e[o])r.push(t[a]+"="+(typeof e[o]=="object"?JSON.stringify(e[o]):e[o]));else{const l=Object.keys(e[o]).sort();for(let i=0;i<l.length;i++){const c=l[i];c!="sign"&&e[o][c]&&r.push(l[i]+"="+(typeof e[o][c]=="object"?JSON.stringify(e[o][c]):e[o][c]))}}}return r.sort().join("&")}function AT(e,t){let r=$T(e);return r+="&key="+t,qu.MD5(r).toString().toUpperCase()}class ri{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const r=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:r,sign:AT({app_id:this.app_id,nonce_str:r,...t},this.app_secret)}}getRequest(t,r){return(a,o,l,i)=>{const c=this.buildHeader(l),d=this.buildAxiosConfig(t,a,o,l,c,r);return ke(d).then(u=>i?u:u.data).catch(u=>{if(ke.isCancel(u))return Promise.reject(u);const p=u,g=y.get(p,"response.data.detail.message",p.message);return Promise.reject(new Error(g))})}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,r,a,o,l,i){const c={baseURL:this.baseURL,method:t,url:r,params:t==="GET"?a:o.params,headers:l,signal:i};return["POST","PUT"].includes(t)&&(c.data=o.string?JSON.stringify(a):a,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(t){const r=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:r?`bearer ${r}`:"",...t.headers}}}class ET{constructor(t){this.implementation=t}getRequest(t,r){return this.implementation.getRequest(t,r)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class ai extends ri{constructor(){super(...arguments);V(this,"makeQueryENV",null)}query(r){return async(a,o={})=>{var l;return a.env||(a.env=((l=this.makeQueryENV)==null?void 0:l.call(this))??{error:"failed to run makeQueryENV"}),this.post(r)("/query",a,o)}}httpDataSourceQuery(r){return async(a,o={})=>{var l;return a.env||(a.env=((l=this.makeQueryENV)==null?void 0:l.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",r)("/query",a,o,!0)}}structure(r){return async(a,o={})=>this.post(r)("/query/structure",a,o)}mericoMetricInfo(r){return async(a,o={})=>this.post(r)("/query/merico_metric_info",a,o,!0)}mericoMetricQuery(r){return async(a,o={})=>this.post(r)("/query",a,o,!0)}}class si{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}mericoMetricInfo(t){return this.implementation.mericoMetricInfo(t)}mericoMetricQuery(t){return this.implementation.mericoMetricQuery(t)}getRequest(t,r){return this.implementation.getRequest(t,r)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Nt=new ai;function da(e){Nt.baseURL!==e.apiBaseURL&&(Nt.baseURL=e.apiBaseURL),e.app_id&&(Nt.app_id=e.app_id),e.app_secret&&(Nt.app_secret=e.app_secret),e.makeQueryENV&&(Nt.makeQueryENV=e.makeQueryENV)}const oi=new si(Nt),$e=oi,ua=f.types.model("MockContextMeta",{current:f.types.optional(f.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,r){e.current[t]=r}}));function pa(e){return{current:e}}const BT=f.types.model("PanelStyleBorderMeta",{enabled:f.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),li=f.types.model("PanelStyleMeta",{border:BT}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),ii=f.types.model("PanelTitleMeta",{show:f.types.optional(f.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),ci=f.types.model("VariableMeta",{name:f.types.string,size:f.types.string,weight:f.types.string,color:f.types.union(f.types.model({type:f.types.literal("static"),staticColor:f.types.string}),f.types.model({type:f.types.literal("continuous"),valueRange:f.types.array(f.types.number),colorRange:f.types.array(f.types.string)}),f.types.model({type:f.types.literal("piecewise")})),formatter:f.types.model({output:f.types.enumeration("Output",["number","percent"]),average:f.types.optional(f.types.boolean,!1),mantissa:f.types.number,trimMantissa:f.types.optional(f.types.boolean,!1),absolute:f.types.optional(f.types.boolean,!1)}),data_field:f.types.string,aggregation:f.types.union(f.types.model({type:f.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:f.types.frozen(),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("quantile"),config:f.types.model({p:f.types.number}),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("pick_record"),config:f.types.model({method:f.types.enumeration("Pick Record Method",["first","last"])}),fallback:f.types.optional(f.types.string,"0")}),f.types.model({type:f.types.literal("custom"),config:f.types.model({func:f.types.string}),fallback:f.types.optional(f.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:r,weight:a,color:o,formatter:l,data_field:i,aggregation:c}=e;return y.cloneDeep({name:t,size:r,color:o,weight:a,formatter:l,data_field:i,aggregation:c})}})),di=f.types.model("PanelVizMeta",{type:f.types.string,conf:f.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){y.isEqual(e.conf,t)||(e.conf=t)}})),ui=f.types.model({id:f.types.string,name:f.types.optional(f.types.string,""),title:ii,description:f.types.string,queryIDs:f.types.array(f.types.string),viz:di,style:li,variables:f.types.optional(f.types.array(ci),[])}).views(e=>({get json(){const{id:t,name:r,title:a,description:o,queryIDs:l}=e;return{id:t,viz:e.viz.json,name:r,style:e.style.json,title:a.json,queryIDs:[...l],variables:e.variables.map(i=>i.json),description:o}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const r=new Set(e.queryIDSet);r.delete(t),e.queryIDs=f.cast(Array.from(r))},setQueryIDs(t){e.queryIDs=f.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var W=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e.MericoMetricSystem="merico_metric_system",e))(W||{});const pi=f.types.model("DBQueryMeta",{_type:f.types.enumeration([W.MySQL,W.Postgresql]),sql:f.types.string}).views(e=>({get base(){return f.getParent(e)},get valid(){return!!e.sql},get json(){const{sql:t,_type:r}=e;return{sql:t,_type:r}}})).actions(e=>({setSQL(t){e.sql=t}})),qT=e=>pi.create({_type:e,sql:""}),hi=f.types.model("HTTPQueryMeta",{_type:f.types.literal(W.HTTP),react_to:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){return!0},get json(){const{react_to:t,_type:r}=e;return at({react_to:t,_type:r})}})).actions(e=>({setReactTo(t){e.react_to.length=0,e.react_to.push(...t)}})),OT=()=>hi.create({_type:W.HTTP,react_to:[]}),gi=f.types.model("TransformQueryMeta",{_type:f.types.literal(W.Transform),dep_query_ids:f.types.optional(f.types.array(f.types.string),[]),react_to:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){return e.dep_query_ids.length>0},get json(){const{dep_query_ids:t,_type:r,react_to:a}=e;return at({dep_query_ids:t,_type:r,react_to:a})}})).actions(e=>({setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)}})),LT=()=>gi.create({_type:W.Transform,dep_query_ids:[]}),fi=f.types.model("SqlMetricVariableMeta",{sqlVar:f.types.optional(f.types.string,""),variable:f.types.optional(f.types.string,"")}).views(e=>({get allEmpty(){return!e.sqlVar&&!e.variable},get json(){const{sqlVar:t,variable:r}=e;return{sqlVar:t,variable:r}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeSqlVariable(e)},setSqlVar(t){e.sqlVar=t??"",e.allEmpty&&this.removeSelf()},setVariable(t){e.variable=t??"",e.allEmpty&&this.removeSelf()}})),bi=f.types.model("MetricFilterColMeta",{dimension:f.types.optional(f.types.string,""),variable:f.types.optional(f.types.string,"")}).views(e=>({get allEmpty(){return!e.dimension&&!e.variable},get json(){const{dimension:t,variable:r}=e;return{dimension:t,variable:r}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeFilter(e)},setDimension(t){e.dimension=t??"",e.allEmpty&&this.removeSelf()},setVariable(t){e.variable=t??"",e.allEmpty&&this.removeSelf()}})),ha=f.types.model("MericoMetricQueryMeta",{_type:f.types.literal(W.MericoMetricSystem),id:f.types.optional(f.types.string,""),type:f.types.optional(f.types.enumeration("MetricType",["derived","combined","sql"]),"derived"),filters:f.types.optional(f.types.array(bi),[]),groupBys:f.types.optional(f.types.array(f.types.string),[]),sqlVariables:f.types.optional(f.types.array(fi),[]),timeQuery:f.types.model({enabled:f.types.optional(f.types.boolean,!1),range_variable:f.types.optional(f.types.string,""),unit_variable:f.types.optional(f.types.string,""),timezone:f.types.optional(f.types.string,"PRC"),stepKeyFormat:f.types.optional(f.types.string,"YYYY-MM-DD")}),useDefaultValues:f.types.optional(f.types.boolean,!1),extraCalculations:f.types.optional(f.types.array(f.types.string),[]),semanticKey:f.types.optional(f.types.string,"")}).views(e=>({get query(){return f.getParent(e)},get valid(){return!!e.id},get json(){const{id:t,type:r,filters:a,groupBys:o,timeQuery:l,useDefaultValues:i,extraCalculations:c,_type:d,sqlVariables:u,semanticKey:p}=e;return at({id:t,type:r,filters:a.map(g=>g.json),groupBys:o,timeQuery:l,useDefaultValues:i,extraCalculations:c,sqlVariables:u,semanticKey:p,_type:d})},get usedSqlVariables(){return new Set(e.sqlVariables.map(t=>t.sqlVar))},get usedFilterDimensionKeys(){const t=e.filters.map(r=>r.dimension).filter(r=>!!r);return new Set(t)},get usedFilterVariableSet(){const t=[...e.filters.map(r=>r.variable)].filter(r=>!!r);return new Set(t)},get usedTimeQueryVariableSet(){const t=[e.timeQuery.range_variable,e.timeQuery.unit_variable].filter(r=>!!r);return new Set(t)},get groupByValues(){const t=e.groupBys.map(r=>r.replace(/^(.+)\s->\s(.*)/,"$1"));return Array.from(new Set(t))}})).actions(e=>({reset(){e.filters.length=0,e.groupBys.length=0,e.timeQuery.enabled=!1,e.timeQuery.range_variable="",e.timeQuery.unit_variable="",e.useDefaultValues=!1,e.extraCalculations.length=0,e.sqlVariables.length=0,e.semanticKey="","data"in e.query&&(e.query.setData([]),e.query.setError(null))},setID(t){t!==e.id&&this.reset(),e.id=t},setSemanticKey(t){e.semanticKey=t},setType(t){t!=="derived"&&t!=="combined"&&t!=="sql"||(e.type=t)},addFilter(t,r){t&&e.usedFilterDimensionKeys.has(t)||e.filters.push(bi.create({dimension:t,variable:r}))},removeFilter(t){f.destroy(t)},addSqlVariable(t,r){e.sqlVariables.push(fi.create({sqlVar:t,variable:r}))},removeSqlVariable(t){f.destroy(t)},setGroupBys(t){e.groupBys.length=0,e.groupBys.push(...t)},setRangeVariable(t){e.timeQuery.range_variable=t??""},setUnitVariable(t){e.timeQuery.unit_variable=t??""},setTimeQueryEnabled(t){e.timeQuery.enabled=t,t?e.groupBys.length>1&&(e.groupBys.length=0):(e.timeQuery.range_variable="",e.timeQuery.unit_variable="")},setUseDefaultValues(t){e.useDefaultValues=t},setExtraCalculations(t){e.extraCalculations.length=0,e.extraCalculations.push(...t)}})),yi=()=>ha.create({_type:W.MericoMetricSystem,id:"",type:"derived",filters:[],groupBys:[],timeQuery:{range_variable:"",unit_variable:"",timezone:"PRC",stepKeyFormat:"YYYY-MM-DD"},useDefaultValues:!1,extraCalculations:[]}),vi=f.types.model("QueryMeta",{id:f.types.string,name:f.types.string,key:f.types.string,type:f.types.enumeration("DataSourceType",[W.Postgresql,W.MySQL,W.HTTP,W.Transform,W.MericoMetricSystem]),config:f.types.union(pi,hi,gi,ha),pre_process:f.types.optional(f.types.string,""),post_process:f.types.optional(f.types.string,""),run_by:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get valid(){const{id:t,name:r,key:a,type:o,config:l}=e;return l.valid&&!!t&&!!r&&!!a&&!!o},get json(){const{id:t,name:r,key:a,type:o,config:l,pre_process:i,post_process:c,run_by:d}=e;return at({id:t,name:r,key:a,type:o,config:l.json,pre_process:i,post_process:c,run_by:d})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){switch(e.type=t,t){case W.HTTP:e.config=OT();break;case W.MySQL:case W.Postgresql:e.config=qT(t);break;case W.Transform:e.config=LT();break;case W.MericoMetricSystem:e.config=yi();break;default:throw new Error(`Unexpected query type[${t}]`)}},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),_i=f.types.model("LayoutItemMeta",{id:f.types.identifier,panelID:f.types.string,x:f.types.number,y:f.types.maybeNull(f.types.number),w:f.types.number,h:f.types.number,moved:f.types.optional(f.types.boolean,!1),static:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:r,x:a,y:o,w:l,h:i,moved:c}=e;return{h:i,w:l,x:a,y:o===null?0:o,id:t,moved:c,static:e.static,panelID:r}},get contentModel(){return f.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:r,y:a,w:o,h:l,moved:i}=e;return{id:t,i:t,x:r,y:a===null?1/0:a,w:o,h:l,moved:i,static:e.static}}})).actions(e=>({set(t){const{isDraggable:r,x:a,y:o,w:l,h:i,moved:c}=t;e.x=a,e.y=o,e.w=l,e.h=i,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),mi=f.types.model("LayoutSetMeta",{id:f.types.identifier,name:f.types.string,breakpoint:f.types.number,list:f.types.optional(f.types.array(_i),[])}).views(e=>({get contentModel(){return f.getRoot(e).content},get json(){const{id:t,name:r,breakpoint:a,list:o}=e;return{id:t,name:r,breakpoint:a,list:o.map(l=>at(l.json))}},jsonByPanelIDSet(t){const{id:r,name:a,breakpoint:o,list:l}=e;return{id:r,name:a,breakpoint:o,list:l.filter(i=>t.has(i.panelID)).map(i=>at(i.json))}},findByID(t){return e.list.find(r=>r.id===t)},findByPanelID(t){return e.list.find(r=>r.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:Te.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const r=e.list.findIndex(a=>a.panelID===t);r>=0&&e.list.splice(r,1)},removeByPanelIDs(t){for(;t.length>0;){const r=t.pop();r&&this.removeByPanelID(r)}},updateLayoutItem(t){const r=e.list.find(a=>a.id===t.i);if(!r){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}r.set(t)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>{const t=e.list.length,r=e.contentModel.panels.list.length;return{match:t===r,layoutCount:t,panelCount:r}},({match:t,panelCount:r,layoutCount:a})=>{if(t)return;const o={id:"layout panel count mismatch",title:"Error detected, please don't save changes.",message:`${a} layout items against and ${r} panels.`,color:"red",autoClose:!1};Fe.showNotification(o),Fe.updateNotification(o)},{fireImmediately:!0,delay:0}))}})),wi=f.types.model("SQLSnippetMeta",{key:f.types.string,value:f.types.string}).views(e=>({get json(){const{key:t,value:r}=e;return{key:t,value:r}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var P=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TreeSingleSelect="tree-single-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e.MericoDateRange="merico-date-range",e))(P||{});const ga=f.types.optional(f.types.enumeration(["intersect","reset"]),"intersect"),fa=f.types.model("FilterCheckboxConfigMeta",{_name:f.types.literal("checkbox"),description:f.types.optional(f.types.string,""),default_value:f.types.boolean}).views(e=>({get json(){const{_name:t,description:r,default_value:a}=e;return{_name:t,description:r,default_value:a}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),xi=()=>fa.create({_name:"checkbox",description:"",default_value:!1}),Ci=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"yesterday"}}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"week").startOf("week").toDate(),e.subtract(1,"week").endOf("week").toDate()],shortcut:"last week"}}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last month"}}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(2,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last 2 months"}}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(3,"month").startOf("month").toDate(),e.subtract(1,"month").endOf("month").toDate()],shortcut:"last 3 months"}}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=M();return{value:[e.subtract(1,"year").startOf("year").toDate(),e.subtract(1,"year").endOf("year").toDate()],shortcut:"last year"}}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(7,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 7 days"}}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(30,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 30 days"}}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(60,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 60 days"}}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(90,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 90 days"}}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(180,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 180 days"}}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=M();return{value:[e.subtract(365,"day").startOf("day").toDate(),e.subtract(1,"day").endOf("day").toDate()],shortcut:"recent 365 days"}}},{key:"d",value:"today",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("day").toDate(),e.endOf("day").toDate()],shortcut:"today"}}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("week").toDate(),e.endOf("week").toDate()],shortcut:"this week"}}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("month").toDate(),e.endOf("month").toDate()],shortcut:"this month"}}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=M();return{value:[e.startOf("year").toDate(),e.endOf("year").toDate()],shortcut:"this year"}}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("week").toDate(),e.endOf("day").toDate()],shortcut:"this week so far"}}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("month").toDate(),e.endOf("day").toDate()],shortcut:"this month so far"}}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=M();return{value:[e.startOf("year").toDate(),e.endOf("day").toDate()],shortcut:"this year so far"}}}];function Pn(e){if(!e)return null;const r=Ci().find(a=>a.value===e);return r?r.getRange():null}function Si(){return y.groupBy(Ci(),"group")}function Ti(e){try{if(e.default_shortcut){const r=Pn(e.default_shortcut);if(r)return{value:r.value.map(a=>M(a).toDate()),shortcut:e.default_shortcut}}return{value:e.default_value.map(r=>r===null?r:M.tz(r,"UTC").toDate()??r),shortcut:null}}catch(t){return console.error(t),{value:[null,null],shortcut:null}}}function ki(e,t){return e.map(r=>{try{return r?M.tz(r,"UTC").toISOString():null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const NT=f.types.model("FilterDateRangeConfigMeta",{_name:f.types.literal("date-range"),required:f.types.boolean,inputFormat:f.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:f.types.optional(f.types.array(f.types.union(f.types.Date,f.types.null)),[null,null]),default_shortcut:f.types.optional(f.types.string,""),clearable:f.types.boolean,max_days:f.types.optional(f.types.number,0),allowSingleDateInRange:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:r,required:a,clearable:o,inputFormat:l,default_value:i,default_shortcut:c,allowSingleDateInRange:d}=e;return{_name:t,max_days:r,required:a,clearable:o,inputFormat:l,default_value:ki(i),default_shortcut:c,allowSingleDateInRange:d}},truthy(t){try{const{value:r}=t;return Array.isArray(r)&&r.length===2&&r.every(a=>!!a)}catch(r){return console.error(r),!1}},get filter(){return f.getParent(e)},get dateStringsValue(){try{const t=this.filter.value,[r,a]=t.value,o=r?M(r).format(e.inputFormat):"",l=a?M(a).format(e.inputFormat):"";return[o,l]}catch(t){return console.error(t),["",""]}}})).actions(e=>({setFilterValue(t){try{e.filter.setValue(t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){t&&(e.inputFormat=t)},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t.value),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t??"",!t)return;const r=Pn(e.default_shortcut);r&&e.setFilterValue(r)},setMaxDays(t){const r=Number(t);Number.isFinite(r)&&(e.max_days=r,r>0&&(e.clearable=!0))},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),ba=f.types.snapshotProcessor(NT,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:M.tz(r,"UTC").toDate())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:ki(t,r.inputFormat)}}}),Di=()=>ba.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),zi=f.types.model({label:f.types.string,value:f.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),ya=f.types.model("FilterConfigModel_BaseSelect",{static_options:f.types.optional(f.types.array(zi),[]),options_query_id:f.types.optional(f.types.string,""),default_selection_count:f.types.optional(f.types.number,0),required:f.types.optional(f.types.boolean,!1)}).views(e=>({get contentModel(){return f.getRoot(e).content},get filter(){return f.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get optionsLoading(){if(!e.usingQuery)return!1;const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:r}=e.contentModel.getDataStuffByID(e.options_query_id);return r==="error"?[]:Array.isArray(t)?t.filter(a=>"label"in a&&"value"in a):[]},get optionValuesSet(){return new Set(this.options.map(t=>t.value))}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},replaceStaticOptions(t){e.static_options.forEach(a=>f.detach(a));const r=t.map(a=>zi.create(a));e.static_options.replace(r)},setDefaultSelectionCount(t){const r=Number(t);Number.isFinite(r)&&(e.default_selection_count=r)},setOptionsQueryID(t){e.options_query_id=t??""}})),va=f.types.compose("FilterMultiSelectConfigMeta",f.types.model({_name:f.types.literal("multi-select"),min_width:f.types.optional(f.types.string,""),default_value:f.types.optional(f.types.array(f.types.string),[]),default_value_mode:ga}),ya).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return at({_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,default_value_mode:a,default_selection_count:d})},get defaultSelection(){const t=e.filter.formattedDefaultValue;return Array.isArray(t)&&t.length>0||!e.usingQuery?t:e.options.slice(0,e.default_selection_count).map(r=>r.value)},optionsByValues(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set(t);return e.options.filter(a=>r.has(a.value))},initialSelection(t){return t||this.defaultSelection},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=f.cast(t)},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},setMinWidth(t){e.min_width=t},applyDefaultSelection(){if(e.optionsLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=new Set(e.options.map(o=>o.value)),a=(e.filter.value??[]).filter(o=>t.has(o));a.length>0?e.filter.setValue(a):e.filter.setValue(e.defaultSelection)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.defaultSelection),e.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Mi=()=>va.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),_a=f.types.compose("FilterConfigModel_Select",f.types.model({_name:f.types.literal("select"),default_value:f.types.string,width:f.types.optional(f.types.string,""),clearable:f.types.optional(f.types.boolean,!1)}),ya).views(e=>({get json(){const{_name:t,clearable:r,default_value:a,required:o,width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return at({_name:t,width:l,required:o,clearable:r,default_value:a,static_options:i,options_query_id:c,default_selection_count:d})},truthy(t){return!!t},getSelectOption(t){return e.options.find(r=>r.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){t!==null&&(e.default_value=t)},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var a;const t=e.filter.value,r=(a=e.options.find(o=>o.value===t))==null?void 0:a.value;r?e.filter.setValue(r):e.filter.setValue(e.default_selection)}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Ii=()=>_a.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),ma=f.types.model("FilterTextInputConfigMeta",{_name:f.types.literal("text-input"),required:f.types.boolean,default_value:f.types.string}).views(e=>({get json(){const{_name:t,required:r,default_value:a}=e;return{_name:t,required:r,default_value:a}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),wa=()=>ma.create({_name:"text-input",required:!1,default_value:""}),GT=`
|
|
532
532
|
// row
|
|
533
533
|
{
|
|
534
534
|
label: string;
|
|
@@ -538,19 +538,19 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
538
538
|
disabled?: boolean;
|
|
539
539
|
}
|
|
540
540
|
`,Vi=()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(a=>!a),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(s.Collapse,{in:t,children:n.jsx(Qe.CodeHighlight,{language:"typescript",withCopyButton:!1,code:GT})})]})},FT={[P.Checkbox]:"true",[P.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[P.MericoDateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[P.MultiSelect]:"[]",[P.Select]:'""',[P.TreeSelect]:"[]",[P.TreeSingleSelect]:'""',[P.TextInput]:'""'},QT=e=>["function getDefaultValue(filter, utils, context) {",` return ${FT[e]};`,"}"].join(`
|
|
541
|
-
`),_t=k.observer(({filter:e})=>{const{t}=m.useTranslation();return n.jsx(gr,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:QT(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftSection:n.jsx(T.IconMathFunction,{size:16})},description:n.jsx(s.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:n.jsxs(s.List,{size:"xs",type:"ordered",children:[n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),$n=k.observer(({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),a=j(),o=F(),l=h.useMemo(()=>o.queries.options,[o.queries.current]),i=l.length===0,c=d=>{a.editor.setPath(["_QUERIES_",d])};return n.jsx(s.Select,{label:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{fw:500,size:"sm",children:r("filter.widget.common.use_query_data_as_options")}),e&&n.jsx(s.Button,{size:"xs",leftSection:n.jsx(T.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:r("query.open")})]}),data:l,value:e,onChange:Z(t),allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:i,error:i?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),Pi={stroke:1.5,color:"currentColor",opacity:1,size:18},$i={intersect:n.jsx(T.IconLayersIntersect,{...Pi}),reset:n.jsx(T.IconLayersSubtract,{...Pi})},jT=({option:e,checked:t})=>n.jsxs(s.Group,{flex:"1",gap:"xs",children:[$i[e.value],e.label]}),wa=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{label:t("filter.widget.common.default_value_mode.intersect"),value:"intersect"},{label:t("filter.widget.common.default_value_mode.reset"),value:"reset"}],[r.language]),{default_value_mode:o}=e;return n.jsx(s.Select,{leftSection:$i[o]??null,label:t("filter.widget.common.default_value_mode.label"),data:a,value:o,onChange:e.setDefaultValueMode,renderOption:jT})}),WT=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:a.required,onChange:o=>a.setRequired(o.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(_t,{filter:t})]}),n.jsx(s.TextInput,{label:r("filter.widget.common.min_width"),value:a.min_width,onChange:o=>a.setMinWidth(o.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:r("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:a.treeCheckStrictly,onChange:o=>a.setTreeCheckStrictly(o.currentTarget.checked),label:r("filter.widget.tree_select.strictly")}),n.jsx($n,{value:a.options_query_id,onChange:a.setOptionsQueryID}),n.jsx(s.NumberInput,{value:a.default_selection_count,onChange:a.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(wa,{config:a}),n.jsx(Vi,{})]})}),xa=({errorMessage:e})=>{const{t}=m.useTranslation();return e?n.jsx(s.Text,{c:"red",size:"12px",children:e}):n.jsx(s.Text,{c:"dimmed",size:"12px",children:t("filter.widget.common.selector_option_empty")})},UT=({rotate:e,onClick:t})=>n.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),Ai=({expanded:e,isLeaf:t,value:r,onClick:a,...o})=>t?n.jsx("span",{style:{width:"14px",display:"inline-block"}}):n.jsx(UT,{rotate:e?"0":"-90",onClick:a,...o}),KT=({onClick:e})=>n.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),Ei=({onClick:e,...t})=>n.jsx(KT,{onClick:e,...t}),YT=pt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,position:"absolute",width:`${r} !important`,backgroundColor:"#fff",border:"1px solid #e9ecef",boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{padding:0},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",width:"100%",padding:"8px 0",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),XT=(e,t,r,a)=>{const o=h.useMemo(()=>{if(!a)return y.cloneDeep(e.filter(g=>!g.disabled));const u=[],p=g=>{g.disabled||u.push(g),g.children.forEach(p)};return e.forEach(p),u},[e,a]),l=h.useMemo(()=>new Set(o.map(u=>u.value)),[o]),i=h.useMemo(()=>new Set(t.map(u=>u.value)),[t]),c=h.useMemo(()=>i.size!==l.size?!1:Array.from(l).every(u=>i.has(u)),[i,l]);return{allValueSet:l,selectedValueSet:i,toggleSelectAll:()=>{if(c){r([]);return}const u=Array.from(o);r(u)},allSelected:c}},ZT={root:{cursor:"pointer",backgroundColor:"#FFF","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},JT=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,treeData:i,errorMessage:c,required:d,treeCheckStrictly:u})=>{const{t:p}=m.useTranslation(),{classes:g,cx:b}=YT({radius:t,width:r.width,name:"FilterTreeSelectWidget"}),[_,w]=h.useState(!1),x=A=>{w(A)},S=_&&(o==null?void 0:o.length)>0,D=XT(i,o,l,u),[z,I]=h.useState("");return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:g.label,size:"sm",children:[a,d&&n.jsx("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),S&&n.jsx(s.Tooltip,{label:p("filter.widget.common.x_selected",{count:o.length}),children:n.jsx(s.Badge,{variant:"light",children:o.length})})]}),n.jsx(Kn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},treeCheckStrictly:u,labelInValue:!0,className:b(g.root,"check-select"),dropdownClassName:b(g.dropdown,""),onDropdownVisibleChange:x,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:Ai,treeIcon:Ei,maxTagTextLength:10,value:o,treeData:i,notFoundContent:n.jsx(xa,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Kn.SHOW_PARENT,onChange:l,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>p("filter.widget.common.x_selected",{count:o.length}),searchValue:z,onSearch:I,dropdownRender:A=>n.jsxs(n.Fragment,{children:[D.allValueSet.size>0&&!z&&n.jsx(s.Group,{px:"xs",pt:8,pb:8,onClick:D.toggleSelectAll,styles:ZT,children:n.jsx(s.Checkbox,{size:"xs",checked:D.allSelected,onChange:y.noop,label:p("common.actions.select_all")})}),n.jsx(s.Divider,{}),A]})})]})},HT=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:o,treeDataLoading:l,errorMessage:i}=t,c=b=>{const _=b.map(w=>w.value);a(_,!1)},d=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,l]),u=t.min_width?t.min_width:"200px",g=!!t.options_query_id?l:!1;return n.jsx(JT,{disabled:g,style:{minWidth:"160px",width:u,maxWidth:g?u:"unset",borderColor:"#e9ecef"},value:[...d],onChange:c,treeData:o,errorMessage:i,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),RT=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(_t,{filter:e})]}),n.jsx(s.TextInput,{label:t("filter.widget.common.min_width"),value:r.min_width,onChange:a=>r.setMinWidth(a.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:t("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx($n,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(s.Checkbox,{checked:r.default_selection_count===1,onChange:a=>r.setDefaultSelectionCount(a.currentTarget.checked?1:0),label:t("filter.widget.tree_single_select.select_first_option_by_default")}),n.jsx(wa,{config:r}),n.jsx(Vi,{})]})}),e2=pt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},"&.rc-tree-select-focused":{".rc-tree-select-selection-item":{color:"#aaa"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"calc(2.25rem / 3)",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",position:"relative"},".rc-tree-select-selection-search":{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,".rc-tree-select-selection-search-input":{height:"36px",paddingLeft:"calc(2.25rem / 3)",textOverflow:"ellipsis"}},".rc-tree-select-selection-item":{position:"absolute",top:0,bottom:0,left:0,paddingLeft:"calc(2.25rem / 3)",color:"#000",lineHeight:"36px",fontSize:"0.875rem",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",transition:"color 200ms ease"},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px",position:"absolute",width:`${r} !important`,"&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden",transition:"background-color 200ms ease","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-selected":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease",width:"100%",padding:"8px 0","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),t2=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,treeData:i,errorMessage:c,required:d})=>{m.useTranslation();const{classes:u,cx:p}=e2({radius:t,width:r.width,name:"FilterTreeSelectWidget"});return n.jsxs(s.Stack,{gap:3,children:[n.jsx(s.Group,{justify:"space-between",children:n.jsxs(s.Text,{className:u.label,size:"sm",children:[a,d&&n.jsx("span",{className:u.required,"aria-hidden":"true",children:"*"})]})}),n.jsx(Kn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},multiple:!1,labelInValue:!0,className:p(u.root,"check-select"),dropdownClassName:p(u.dropdown,""),transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:Ai,treeIcon:Ei,value:o,treeData:i,notFoundContent:n.jsx(xa,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!1,onChange:l,onSelect:console.log,showSearch:!0})]})},n2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:o,treeDataLoading:l,errorMessage:i}=t,c=b=>{a(b?b.value:null,!1)},d=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,t.treeDataLoading]),u=t.min_width?t.min_width:"200px",g=!!t.options_query_id?l:!1;return n.jsx(t2,{disabled:g,style:{width:u,maxWidth:g?u:"unset",borderColor:"#e9ecef"},value:d,onChange:c,treeData:o,errorMessage:i,label:e,required:t.required})});function r2(e){return $u.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function a2(e){return e.map(t=>{const{label:r,description:a,...o}=t,l={...o,filterBasis:`${r}___${a??""}`,description:a,label:r};return a&&(l.label=h.createElement("div",{},[h.createElement(s.Text,{key:0,title:t.label},t.label),h.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),l})}const Bi=f.types.compose("FilterConfigModel_BaseTreeSelect",f.types.model({min_width:f.types.optional(f.types.string,""),default_value_mode:ha}),ba).views(e=>({get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,r=a2(t);return r2(r)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"}})).actions(e=>({setMinWidth(t){e.min_width=t}})),Ca=f.types.compose("FilterTreeSelectConfigMeta",f.types.model({_name:f.types.literal("tree-select"),default_value:f.types.optional(f.types.array(f.types.string),[]),treeCheckStrictly:f.types.optional(f.types.boolean,!1)}),Bi).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d,treeCheckStrictly:u}=e;return{_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,treeCheckStrictly:u,default_value_mode:a,default_selection_count:d}},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:r}=e;return r?e.treeData.slice(0,r).map(o=>o.value):[]},optionsByValues(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set(t);return e.options.filter(a=>r.has(a.value))},valueObjects(t){const r=new Set(t);return e.plainData.filter(a=>r.has(a.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=f.cast(t)},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){if(e.optionsLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=e.filter.value,r=new Set(e.plainData.map(o=>o.value)),a=(t??[]).filter(o=>r.has(o));a.length>0?e.filter.setValue(a):e.filter.setValue(e.defaultSelection)},afterCreate(){f.addDisposer(e,G.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),qi=()=>Ca.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Sa=f.types.compose("FilterTreeSingleSelectConfigMeta",f.types.model({_name:f.types.literal("tree-single-select"),default_value:f.types.optional(f.types.string,"")}),Bi).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return{_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,default_value_mode:a,default_selection_count:d}},get selectFirstByDefault(){return e.default_selection_count===1},get defaultSelection(){if(e.treeDataLoading)return"";const t=e.filter.formattedDefaultValue;return t||(this.selectFirstByDefault&&e.treeData.length>0?e.treeData[0].value:"")},valueObject(t){if(t)return e.plainData.find(r=>r.value===t)},initialSelection(t){if(t)return this.valueObject(t)},truthy(t){return typeof t=="string"&&t!==""}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},applyDefaultSelection(){if(e.treeDataLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=e.filter.value;e.optionValuesSet.has(t)?e.filter.setValue(t):e.filter.setValue(e.defaultSelection)},afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Oi=()=>Sa.create({_name:"tree-single-select",default_value:"",static_options:[],options_query_id:"",default_selection_count:0});function s2(e,t){const r=e.startOf("week");let a=r.add(1,"week").endOf("week");for(;a.isBefore(t);)a=a.add(2,"week");return[r.toDate(),a.toDate()]}function Ht(e,t,r){return!e||!t?[e,t]:Xe(M(e),M(t),r)}function Xe(e,t,r){if(!e||!t)return[(e==null?void 0:e.toDate())??null,(t==null?void 0:t.toDate())??null];switch(r){case"day":return[e.startOf("day").toDate(),t.endOf("day").toDate()];case"week":return[e.startOf("week").toDate(),t.endOf("week").toDate()];case"bi-week":return s2(e,t);case"month":return[e.startOf("month").toDate(),t.endOf("month").toDate()];case"quarter":return[e.startOf("quarter").toDate(),t.endOf("quarter").toDate()];default:throw new Error(`[merico-date-range] unexpected date-range step: ${r}`)}}const o2={day:new Set(["m","m2","m3","m6","y","d30","d60","d90","d180","d365"]),week:new Set(["m","m2","m3","m6","y"]),"bi-week":new Set(["m","m2","m3","m6","y"]),month:new Set(["m","m2","m3","m6","y"]),quarter:new Set(["m","m2","m6","y"])};function tt(e,t){return!o2[e].has(t)}const Li=e=>[{key:"m",value:"last month",group:"last",disabled:tt(e,"m"),getRange:t=>{const r=M();return{value:Xe(r.subtract(1,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last month",step:t}}},{key:"m2",value:"last 2 months",group:"last",disabled:tt(e,"m2"),getRange:t=>{const r=M();return{value:Xe(r.subtract(2,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 2 months",step:t}}},{key:"m3",value:"last 3 months",group:"last",disabled:tt(e,"m3"),getRange:t=>{const r=M();return{value:Xe(r.subtract(3,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 3 months",step:t}}},{key:"m6",value:"last 6 months",group:"last",disabled:tt(e,"m6"),getRange:t=>{const r=M();return{value:Xe(r.subtract(6,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 6 months",step:t}}},{key:"y",value:"last year",group:"last",disabled:tt(e,"y"),getRange:t=>{const r=M();return{value:Xe(r.subtract(1,"year").startOf("year"),r.subtract(1,"year").endOf("year"),t),shortcut:"last year",step:t}}},{key:"d30",value:"recent 30 days",group:"recent",disabled:tt(e,"d30"),getRange:t=>{const r=M();return{value:Xe(r.subtract(30,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 30 days",step:t}}},{key:"d60",value:"recent 60 days",group:"recent",disabled:tt(e,"d60"),getRange:t=>{const r=M();return{value:Xe(r.subtract(60,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 60 days",step:t}}},{key:"d90",value:"recent 90 days",group:"recent",disabled:tt(e,"d90"),getRange:t=>{const r=M();return{value:Xe(r.subtract(90,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 90 days",step:t}}},{key:"d180",value:"recent 180 days",group:"recent",disabled:tt(e,"d180"),getRange:t=>{const r=M();return{value:Xe(r.subtract(180,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 180 days",step:t}}},{key:"d365",value:"recent 365 days",group:"recent",disabled:tt(e,"d365"),getRange:t=>{const r=M();return{value:Xe(r.subtract(365,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 365 days",step:t}}}];function Rt(e,t){if(!e)return null;const a=Li(t).find(o=>o.value===e);return a?a.getRange(t):null}function Ni(e){return y.groupBy(Li(e),"group")}function Gi(e){try{if(e.default_shortcut){const r=Rt(e.default_shortcut,e.default_step);if(r)return{value:r.value.map(a=>M(a).toDate()),shortcut:e.default_shortcut,step:e.default_step}}const t=e.default_value.map(r=>r===null?r:M.tz(r,"UTC").toDate()??r);return{value:Ht(t[0],t[1],e.default_step),shortcut:null,step:e.default_step}}catch(t){return console.error(t),{value:[null,null],shortcut:null,step:e.default_step}}}function Fi(e,t){return e.map(r=>{try{return r?M.tz(r,"UTC").toISOString():null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const l2=f.types.model("FilterMericoDateRangeConfigMeta",{_name:f.types.literal("merico-date-range"),required:f.types.boolean,inputFormat:f.types.enumeration("DateRangeInputFormat",["YYYY/MM/DD"]),default_value:f.types.optional(f.types.array(f.types.union(f.types.Date,f.types.null)),[null,null]),default_shortcut:f.types.optional(f.types.string,""),default_step:f.types.optional(f.types.string,"day")}).views(e=>({get json(){const{_name:t,required:r,inputFormat:a,default_step:o,default_value:l,default_shortcut:i}=e;return{_name:t,required:r,inputFormat:a,default_step:o,default_value:Fi(l),default_shortcut:i}},truthy(t){try{const{value:r}=t;return Array.isArray(r)&&r.length===2&&r.every(a=>!!a)}catch(r){return console.error(r),!1}},get filter(){return f.getParent(e)},get dateStringsValue(){try{const t=this.filter.value,[r,a]=t.value,o=r?M(r).format(e.inputFormat):"",l=a?M(a).format(e.inputFormat):"";return[o,l]}catch(t){return console.error(t),["",""]}}})).actions(e=>({setFilterValue(t){try{e.filter.setValue(t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t.value),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t??"",!t)return;const r=Rt(e.default_shortcut,e.default_step);r&&e.setFilterValue(r)},setDefaultStep(t){e.default_step=t}})),Ta=f.types.snapshotProcessor(l2,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:M.tz(r,"UTC").toDate())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:Fi(t,r.inputFormat)}}}),Qi=()=>Ta.create({_name:"merico-date-range",required:!1,inputFormat:"YYYY/MM/DD",default_value:[null,null],default_shortcut:"",default_step:"day"}),An=f.types.model("FilterMeta",{id:f.types.identifier,key:f.types.string,label:f.types.string,order:f.types.number,visibleInViewsIDs:f.types.array(f.types.string),auto_submit:f.types.optional(f.types.boolean,!1),default_value_func:f.types.optional(f.types.string,""),type:f.types.enumeration("DashboardFilterType",[P.Select,P.MultiSelect,P.TreeSelect,P.TreeSingleSelect,P.TextInput,P.Checkbox,P.DateRange,P.MericoDateRange]),config:f.types.union(va,ya,Ca,Sa,_a,ga,fa,Ta)}).views(e=>({get contentModel(){return f.getRoot(e).content},get filters(){return this.contentModel.filters},get value(){return this.filters.values[e.key]},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==P.TreeSelect&&e.type!==P.TreeSingleSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[P.Select,P.Checkbox,P.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:a,order:o,visibleInViewsIDs:l,default_value_func:i,auto_submit:c,type:d,config:u}=e;return{id:t,key:r,type:d,label:a,order:o,config:u.json,auto_submit:c,visibleInViewsIDs:G.toJS(l),default_value_func:i}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return y.get(e.config,"required",!1)?y.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.filters.setValueByKey(e.key,t)},setLabel(t){e.label=t},setOrder(t){const r=Number(t);Number.isFinite(r)&&(e.order=r)},setType(t){switch(t){case P.Select:e.config=Ii();break;case P.MultiSelect:e.config=Mi();break;case P.TreeSelect:e.config=qi();break;case P.TreeSingleSelect:e.config=Oi();break;case P.TextInput:e.config=ma();break;case P.Checkbox:e.config=xi();break;case P.DateRange:e.config=Di();break;case P.MericoDateRange:e.config=Qi();break;default:return}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var B=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(B||{});const ka=f.types.model("ViewDivisionConfig",{_name:f.types.literal(B.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),ji=()=>ka.create({_name:B.Division}),i2=f.types.model("CustomModalTitleModel",{enabled:f.types.optional(f.types.boolean,!1),func_content:f.types.optional(f.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,a=f.getParent(e,2),o=f.getRoot(e);if(!t)return a.name;try{const l={filters:o.content.filters.valuesForPayload,context:o.context.current};return new Function(`return ${r}`)()(l)}catch(l){return console.error(l),a.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),En={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
542
|
-
`)},Da=f.types.model("ViewModalConfig",{_name:f.types.literal(B.Modal),width:f.types.string,height:f.types.string,custom_modal_title:f.types.optional(i2,En)}).views(e=>({get json(){const{_name:t,width:r,height:a,custom_modal_title:o}=e;return{_name:t,width:r,height:a,custom_modal_title:o.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Wi=()=>Da.create({_name:B.Modal,width:"90vw",height:"90vh"}),c2=f.types.model("ViewTabsTabModel",{id:f.types.identifier,name:f.types.string,view_id:f.types.string,color:f.types.optional(f.types.string,""),order:f.types.optional(f.types.number,0)}).views(e=>({get json(){const{id:t,name:r,view_id:a,color:o,order:l}=e;return{id:t,name:r,color:o,order:l,view_id:a}}})).actions(e=>({setName(t){e.name=t},setViewID(t){t&&(e.view_id=t)},setColor(t){e.color=t},setOrder(t){typeof t!="string"&&(e.order=t)}})),za=f.types.model("ViewTabsConfig",{_name:f.types.literal(B.Modal),tabs:f.types.optional(f.types.array(c2),[]),variant:f.types.optional(f.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:f.types.optional(f.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:a,tabs:o,grow:l}=e;return{grow:l,tabs:o.map(i=>i.json),_name:t,variant:r,orientation:a}},get tabsInOrder(){return y.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){t&&(e.variant=t)},setOrientation(t){t&&(e.orientation=t)},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=f.cast(t)},addTab(){const t=te.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){const r=e.tabs.find(a=>a.id===t);r&&e.tabs.remove(r)}})),Ui=()=>za.create({_name:B.Modal,tabs:[]}),Ki=f.types.model({id:f.types.identifier,name:f.types.string,type:f.types.enumeration("EViewComponentType",[B.Division,B.Modal,B.Tabs]),config:f.types.union(ka,Da,za),panelIDs:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:a,config:o}=e;return{id:t,name:r,type:a,config:o.json,panelIDs:e.panelIDs.map(l=>l)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case B.Division:e.config=ji();break;case B.Modal:e.config=Wi();break;case B.Tabs:e.config=Ui();break;default:return}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const r=e.panelIDs.filter(a=>a!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})),lt="14.32.0",d2={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:B.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:lt,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},Ma=f.types.model("DataSourceMetaModel",{id:f.types.string,type:f.types.enumeration("DataSourceType",[W.HTTP,W.MySQL,W.Postgresql,W.MericoMetricSystem]),key:f.types.string,config:f.types.frozen()}),Yi=f.types.model("DataSourcesMetaModel",{list:f.types.optional(f.types.array(Ma),[])}).views(e=>({find({type:t,key:r}){return e.list.find(a=>a.key===r&&a.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Xi=f.types.model({id:f.types.string,content:f.types.string,create_time:f.types.string,update_time:f.types.string,is_preset:f.types.boolean}),Ia=f.types.model("GlobalSQLSnippetsMeta",{list:f.types.optional(f.types.array(Xi),[])}).views(e=>({find(t){return e.list.find(r=>r.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Bn=f.types.model("ContextMeta",{current:f.types.optional(f.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,r){e.current[t]=r}}));function Va(e){return Bn.create({current:e})}const Pa=f.types.compose("ViewRenderModel",Ki,f.types.model({tab:f.types.optional(f.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(r=>r.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==B.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return f.getParent(e,3)},get panels(){if(e.type!==B.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,r=this.contentModel.views.findByID(t);return(r==null?void 0:r.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===B.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t,r){const a=t.offsetWidth*2+10,o=t.offsetHeight*2+10,l=new Es,i=new Date().getTime(),c=await As.toCanvas(t,{bgcolor:"white",width:a,height:o,style:{transformOrigin:"0 0",transform:"scale(2)"}}).then(d=>(r==null||r(d),new Promise(u=>{d.toBlob(p=>{u(p)})})));l.file(`${e.name}_${i}.png`,c),l.file(`dashboard_state_${i}.json`,JSON.stringify(this.contentModel.dashboardStateValues,null,4)),l.generateAsync({type:"blob"}).then(d=>{sn.saveAs(d,`${e.name}_${i}.zip`)}).catch(d=>{console.error(d),Fe.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:d.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),$a=f.types.model("ViewsRenderModel",{current:f.types.optional(f.types.array(Pa),[]),visibleViewIDs:f.types.array(f.types.string)}).views(e=>({get json(){return e.current.map(t=>at(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===B.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null},get firstVisibleTabsViewActiveTabStr(){return JSON.stringify(this.firstVisibleTabsViewActiveTab)}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(a=>a)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(a=>a===t);r!==-1&&e.visibleViewIDs.splice(r,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const r=e.firstVisibleTabsView;r==null||r.setTabByTabInfo(t)}}));function Zi(e,t){const r=e.length>0?[e[0].id]:[],a=e.map(o=>{const{_name:l=o.type}=o.config,i={...o,tab:"",config:{...o.config,_name:l},panelIDs:o.panelIDs};if(o.type===B.Tabs){let c=y.minBy(o.config.tabs,d=>d.order);!c&&o.config.tabs.length>0&&(c=o.config.tabs[0]),i.tab=(c==null?void 0:c.id)??""}return i});return t&&(a[0].tab=t.id),{current:a,visibleViewIDs:r}}const u2=new Pu.AsyncParser({withBOM:!0});async function Ji(e){return!Array.isArray(e)||e.length===0?"":await u2.parse(e).promise()}async function Hi(e,t){const r=await Ji(t),a=new Blob([r],{type:"text/csv"});sn.saveAs(a,`${e}.csv`)}function Ri(e,t){const r=new Es,a=t.map(async({id:o,data:l})=>{const i=await Ji(l);r.file(`${o}.csv`,i)});Promise.all(a).then(()=>{r.generateAsync({type:"blob"}).then(o=>{sn.saveAs(o,`${e}.zip`)})}).catch(o=>{console.error(o),Fe.notifications.show({color:"red",title:"Failed to download data",message:o.message})})}function Gt(e,t){const r=new Blob([t],{type:"application/json"});sn.saveAs(r,`${e}.json`)}const Aa=ui.views(e=>({get contentModel(){return f.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},get usingGhostViz(){return e.viz.type===Rl.name},queryByID(t){return this.queries.find(r=>r.id===t)},get data(){return this.queries.reduce((t,r)=>(t[r.id]=r.data,t),{})},get variableStrings(){return Mo(e.variables,this.data)},get variableAggValueMap(){const t={},r=this.data;return e.variables.reduce((a,o)=>(a[o.name]=He(o,r),a),t),t},get variableValueMap(){const t={},r=this.variableAggValueMap;return e.variables.reduce((a,o)=>(a[o.name]=Be(o,r[o.name]),a),t),t},get variableStyleMap(){const t=this.variableValueMap,r={};return e.variables.reduce((a,o)=>{const l=dp(o.color,t[o.name]);return a[o.name]={color:l,"font-size":o.size,"font-weight":o.weight,variable:o},a},r),r},get dataLoading(){return this.queries.some(t=>t.isTransform?t.depQueryModelStates.some(r=>r==="loading"):t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(l=>!l.runByConditionsMet);if(t.length===0)return"";const r=new Set,a=new Set;t.forEach(l=>{const i=l.conditionNames;i.context.forEach(c=>r.add(c)),i.filters.forEach(c=>a.add(c))});const o=[];return r.size>0&&o.push(`context: ${Array.from(r).join(", ")}`),a.size>0&&o.push(`filter${a.size>1?"s":""}: ${Array.from(a).join(", ")}`),o.length===2&&o.splice(1,0,"and"),o.unshift("Waiting for"),o.join(" ")},get queryErrors(){return this.queries.map(t=>t.error??t.metricQueryPayloadErrorString).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading},get realDataFieldOptions(){return e.queryIDs.length===0?[]:this.queries.map(t=>{const r=t.data;return r.length===0?[]:Object.keys(r[0]).map(o=>({label:o,value:`${t.id}.${o}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},dataFieldOptions({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l}){let i=[...this.realDataFieldOptions];if(o&&(i=i.filter(c=>c.group_id===o)),l==null||l.forEach(c=>{i.unshift({label:c.label,value:c.value,group:"",group_id:"",disabled:!1})}),t&&!i.find(c=>c.value===t)){const c=$(t),d=this.queryByID(c.queryID);i.unshift({label:c.columnKey,value:t,group:d?d.name:c.queryID,group_id:d?d.id:"",disabled:!0})}return r&&i.unshift({label:a,value:"",group:"",group_id:"",disabled:!1}),i},dataFieldOptionGroups({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l}){const i=this.dataFieldOptions({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l});return Object.entries(y.groupBy(i,"group")).map(([d,u])=>({group:d,items:u.map(p=>({label:p.label,value:p.value,group_id:p.group_id,disabled:p.disabled}))}))}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.name,e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(r=>r.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:r,layouts:a}=this.getSchema(),l=JSON.stringify({panels:[t],definition:{queries:r},layouts:a,version:lt},null,2),i=e.name;Gt(i,l)}}));function ec(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:ta.name,conf:ta.createConfig()},style:{border:{enabled:!0}}}}const Ea=f.types.model("PanelsRenderModel",{list:f.types.optional(f.types.array(Aa),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];return t.forEach(a=>{const o=e.idMap.get(a);o?r.push(o):console.warn(`Panel is not found, id:${a}`)}),r}}));function tc(e){const t=e.config,r=t==null?void 0:t.default_value;return r===void 0?r:t._name==="date-range"?Ti(t):t._name==="merico-date-range"?Gi(t):r}function p2(e,t){const r=e.default_value_func;try{const a=new Function(`return ${r}`)()(e,We,t);return e.config._name==="date-range"&&Array.isArray(a)?{value:a,shortcut:null}:e.config._name==="merico-date-range"&&Array.isArray(a)?{value:a,shortcut:null,step:e.config.step}:a}catch(a){return console.error(a),tc(e)}}function nc(e,t){var r;return(r=e.default_value_func)!=null&&r.trim()?p2(e,t):tc(e)}function rc(e,t){return e.reduce((r,a)=>(r[a.key]=nc(a,t),r),{})}function ac(e,t){const r={};return Object.entries(t).forEach(([a,o])=>{const l=e[a];if(typeof o!="object"||!("shortcut"in o)||!l)return r[a]=l??o,r;if(Array.isArray(l))return console.log("⚪️ adapting legacy date-range value: ",l),r[a]={value:l,shortcut:null},r;const i=l,{shortcut:c}=i;if(!c)return console.log("⚪️ skipping input date range when it has no shortcut",i),r[a]=i,r;if("step"in o){const d=i.step;r[a]=Rt(c,d)}else r[a]=Pn(c);return r}),r}const Ba=f.types.model("FiltersRenderModel",{current:f.types.optional(f.types.array(An),[]),values:f.types.optional(f.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get filter(){return f.getParent(e)},get keysToTypes(){return e.current.reduce((t,r)=>(t[r.key]=r.type,t),{})},keyStateItemMap(t){return e.current.reduce((r,a)=>{const o=t[a.key];return r[a.key]={type:a.type,key:a.key,model:a,label:a.label??a.id,value:o},r},{})},get valuesForPayload(){const t={};return Object.entries(e.values).forEach(([r,a])=>{t[r]=a;const o=this.findByKey(r);o&&o.config._name===P.DateRange&&(t[r]=o.config.dateStringsValue),o&&o.config._name===P.MericoDateRange&&(t[r]={...a,value:o.config.dateStringsValue})}),t},get contentModel(){return f.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:r})=>({default_value_func:t,config:r})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return rc(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByKey(t){return e.current.find(r=>r.key===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get inOrder(){return y.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return y.sortBy(e.current.filter(r=>r.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,r)=>(t[r.key]=r.label,t),{})},get keyIDMap(){return e.current.reduce((t,r)=>(t[r.key]=r.id,t),{})},getSelectOption(t){const r=this.findByID(t);if(!r||!("getSelectOption"in r.config))return null;const a=e.values[r.key];return r.config.getSelectOption(a)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=ac(t,e.values)},setValueByKey(t,r){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(r)),e.values={...e.values,[t]:r}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,r){return{filters:e.findByIDSet(new Set(t)).map(l=>({...l.json,visibleInViewsIDs:r?l.json.visibleInViewsIDs:[]})),version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t,!1),null,2);Gt("Filters",r)}}));function qa(e,t,r,a){const o={...r,...t},l=rc(e,o),i=ac(a,l);return console.groupCollapsed("⚪️ initialValues"),console.log("filters",e),console.log("defaultValues",l),console.log("filterValues ",a),console.log("initialValues ",i),console.groupEnd(),{current:e,values:i}}function h2(e,t){const r=Bs.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function g2({query:e,name:t,payload:r,additionals:a},o){if(!e.sql)return[];const{type:l,key:i,sql:c,pre_process:d,post_process:u}=e,p=_r(c,r),g=fh({sql:p,pre_process:d}),b=Bs.encode(g);h2(g,b);let _=await $e.query(o)({type:l,key:i,query:b,...a},{params:{name:t}});return _=bh(u,_,vr(r)),_}async function f2({type:e,key:t,configString:r,name:a,additionals:o},l){try{return await $e.httpDataSourceQuery(l)({type:e,key:t,query:r,...o},{params:{name:a}})}catch(i){if(ke.isCancel(i))throw i;return console.error(i),i}}async function b2({key:e,configString:t,name:r,additionals:a},o){try{return await $e.mericoMetricQuery(o)({type:"merico_metric_system",key:e,query:t,...a},{params:{name:r}})}catch(l){throw l}}async function Oa(){try{return(await $e.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function sc(){try{return(await $e.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}function y2(e){var t;if("cols"in e){const{cols:r}=e,a=((t=r.find(o=>o.type==="trending_date_col"))==null?void 0:t.metricSourceCol)??null;return{variables:[],filters:r.filter(o=>o.type==="filter").map(o=>o.metricSourceCol),groupBys:r.filter(o=>o.type==="group_by").map(o=>o.metricSourceCol),trendingDateCol:a,supportTrending:!!a}}return"variables"in e?{variables:e.variables,filters:[],groupBys:[],trendingDateCol:null,supportTrending:e.variables.includes("date_range")}:{variables:[],filters:e.filters,groupBys:e.groupBys,trendingDateCol:null,supportTrending:e.supportTrending}}const oc={string:"维度列",number:"数值列",date:"数值列",boolean:"维度列",dimension:"扩展维度"};function lc(e){return y.groupBy(e,r=>{const{dataType:a}=r;return a?oc[a]:r.dimension!==null?oc.dimension:"ERROR"})}function v2(e){if(e.length===0)return[];const t=lc(e);return Object.entries(t).map(([a,o])=>({group:`${a}(${o.length})`,items:o.map(l=>{const{dataType:i,dimension:c}=l;return c?{group:l.name,description:l.description,items:c.fields.map(d=>typeof d=="string"?{label:d,value:`${l.name} -> ${d}`}:{label:d.field,value:`${l.name} -> ${d.field}`,...d})}:{label:l.name,value:l.name,...l}})}))}function _2(e){if(e.length===0)return[];const t=lc(e);return Object.entries(t).map(([a,o])=>({group:`${a}(${o.length})`,items:o.map(l=>({label:l.name,value:l.name,description:l.description,dataType:l.dataType??"dimension",dimension:l.dimension}))}))}const ic=new Map([["accumulate",{name:"累计计算",description:"按指定的聚合方式,依次计算指标值的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["yoyRatio",{name:"年同比率(yoy)",description:"对比当前年份与上一个年份同期指标值的变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepRatio",{name:"环比率",description:"对比当前步长与上一个步长指标值的变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepSpansRatio",{name:"移动计算",description:"按设定的窗口沿时序对指标值进行滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}],["percentage",{name:"总占比",description:"总占比 = 当前值 / 总值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["percentage_accumulate",{name:"累计占比",description:"按聚合规则计算各项占比,再依次计算占比率的累计值,如帕累托的累计占比值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["accumulate_yoyRatio",{name:"累计年同比",description:"按聚合规则累加数据,再与上一年同期累计值对比得出变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["yoyRatio_accumulate",{name:"年同比累计",description:"先计算各步长指标相对上一年同期的同比率,再依次计算同比率的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepRatio_accumulate",{name:"环比累计",description:"先计算各步长指标相对上一步长的环比率,再依次计算环比率的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["percentage_yoyRatio",{name:"占比年同比",description:"按聚合规则计算各项占比,再与去年同期占比对比得出变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["yoyRatio_stepSpansRatio",{name:"年同比移动计算",description:"先计算各步长指标相对上一年同期的同比率,再按移动设置沿时序滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}],["stepRatio_stepSpansRatio",{name:"环比移动计算",description:"先计算各步长指标相对上一步长的环比率,再按移动设置沿时序滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}]]);function cc(e,t){if(t)return e;const r=Array.from(ic.entries()).filter(([a,o])=>o.requireTrendingDateCol).map(([a])=>a);return e.filter(a=>!r.includes(a))}function dc(e,t,r){return Array.isArray(e)&&e.length===2?{start:M(e[0]).tz(t).format(r),end:M(e[1]).tz(t).format(r)}:null}function uc(e,t,r,a,o="PRC",l="YYYY-MM-DD"){const i=t?y.get(a,t):void 0,c=e?y.get(a,e):void 0;let d=t?y.get(r,t,""):"";i===P.MericoDateRange&&t&&(d=y.get(r,`${t}.step`,""));const u={start:"",end:"",unitOfTime:d,unitNumber:1,timezone:o,stepKeyFormat:l};if(e)if(c===P.MericoDateRange){const p=y.get(r,`${e}.value`),g=dc(p,o,l);g&&(u.start=g.start,u.end=g.end)}else{const p=y.get(r,e),g=dc(p,o,l);g&&(u.start=g.start,u.end=g.end)}return u}const pc=vi.views(e=>({get rootModel(){return f.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){return this.contentModel.dashboardStateVariableOptions},getConditionOptionsWithInvalidValue(t){const{optionGroups:r,validValues:a}=this.conditionOptions;if(!t||a.has(t))return this.conditionOptions;const o={group:"common.invalid",items:[{label:t,value:t}]};return{optionGroups:[...r,o],validValues:a}},get conditionOptionsWithInvalidRunbys(){const{optionGroups:t,validValues:r}=this.conditionOptions,a={group:"common.invalid",items:[]};return e.run_by.forEach(o=>{r.has(o)||a.items.push({label:o,value:o})}),{optionGroups:[...t,a],validValues:r}},get unmetRunByConditions(){if(!f.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const r=this.contentModel.payloadForSQL;return t.filter(a=>{const o=y.get(r,a);return Array.isArray(o)?o.length===0:typeof o=="number"?Number.isNaN(o):!o})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){const t=y.get(e,"config.sql","");return mr(t,this.payload)},get httpConfigString(){const{context:t,filters:r}=this.payload,{name:a,pre_process:o}=e.json,l=gh(o,t,r);return console.groupCollapsed(`Request config for: ${a}`),console.log(l),console.groupEnd(),JSON.stringify(l)},get typedAsSQL(){return[W.Postgresql,W.MySQL].includes(e.type)},get typedAsHTTP(){return[W.HTTP].includes(e.type)},get isMericoMetricQuery(){return e.type===W.MericoMetricSystem},get isTransform(){return e.type===W.Transform},get reQueryKey(){const t=y.get(e,"config.react_to",[]);if(t.length===0)return"";const r=e.contentModel.payloadForSQL,a=[...t].reduce((o,l)=>(o[l]=y.get(r,l),o),{});return JSON.stringify(a)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,r=e.unmetRunByConditions.filter(o=>o.startsWith("context.")).map(o=>o.replace("context.","")),a=e.unmetRunByConditions.filter(o=>o.startsWith("filters.")).map(o=>y.get({filters:t},o,o.replace("filters.",""))).filter(o=>!!o);return{context:r,filters:a}},get queries(){return f.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=y.get(e,"config.sql","");if(!t)return[];const r=y.uniq(t.match(Et.sqlSnippet)),a=y.uniq(t.match(Et.filter)),o=y.uniq(t.match(Et.context)),l=[];return r.forEach(i=>{l.push({type:"sql_snippet",key:i,valid:e.contentModel.sqlSnippets.keySet.has(i)})}),a.forEach(i=>{l.push({type:"filter",key:i,valid:e.contentModel.filters.keySet.has(i)})}),o.forEach(i=>{l.push({type:"context",key:i,valid:e.contentModel.mock_context.keySet.has(i)})}),l},get usedFilterKeySet(){const t=new Set,r=i=>{t.add(i.replace(/^filters\./,""))};if(e.run_by.forEach(i=>r(i)),y.get(e.config,"react_to",[]).forEach(i=>r(i)),!this.typedAsSQL)return t;const o=y.get(e,"config.sql","");return o&&y.uniq(o.match(Et.filter)).forEach(i=>r(i)),t},get metricQueryPayload(){if(e.type!==W.MericoMetricSystem)return null;const t=this.payload,r={filters:e.contentModel.filters.keysToTypes},a=e.config,o=y.omit(Object.fromEntries(a.sqlVariables.map(p=>{const g=p.sqlVar,b=p.variable,_=y.get(t,b);return[g,_]})),["date_range","step"]);console.log("MMS var",o);const l=a.filters.reduce((p,g)=>{const b=y.get(t,g.variable),_=y.get(r,g.variable),w=g.dimension;if(_===P.DateRange){const S=b.every(D=>Number.isFinite(Number(D)))?b.map(D=>Number(D)):b;p[w]={between:S}}else if(_===P.MericoDateRange){const S=b.value.every(D=>Number.isFinite(Number(D)))?b.value.map(D=>Number(D)):b;p[w]={between:S}}else Array.isArray(b)?p[w]={in:b}:p[w]={eq:b};return p},{}),i={id:a.id,type:a.type,filters:l,groupBys:a.groupBys,variables:o},c=a.sqlVariables.find(p=>["date_range","step"].includes(p.sqlVar));if(c&&(i.timeQuery=uc(c.variable,c.variable,t,r)),a.extraCalculations&&a.extraCalculations.length>0&&(i.extraCalculations=cc(a.extraCalculations,a.timeQuery.enabled)),a.useDefaultValues&&(i.useDefaultValues=!0),!a.timeQuery.enabled)return i;const{range_variable:d,unit_variable:u}=a.timeQuery;return i.timeQuery=uc(d,u,t,r),i},get metricQueryPayloadString(){return this.metricQueryPayload?JSON.stringify(this.metricQueryPayload,null,2):""},get metricQueryPayloadError(){const t=[];if(!this.metricQueryPayload)return t;const r=e.config,{timeQuery:a}=this.metricQueryPayload;if(!a)return r.groupByValues.length>2&&t.push("分组聚合维度:最多支持两个维度的聚合计算"),t;r.groupByValues.length>1&&t.push("分组聚合维度:按时间序列展示时,仅可选择一个聚合维度");const{start:o,end:l,unitOfTime:i}=a;return(!o||!l)&&t.push("时间维度:时间范围不完整"),i||t.push("步长:必选"),t},get metricQueryPayloadErrorString(){return this.metricQueryPayloadError.join(`
|
|
543
|
-
`)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),La=f.types.compose("QueryRenderModel",pc,f.types.model({state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),data:f.types.optional(f.types.frozen([]),[]),error:f.types.optional(f.types.frozen(),null)})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=y.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const a=[];return t.length>0&&a.push(`context: ${t.join(", ")}`),r.length>0&&a.push(`filter${r.length>1?"s":""}: ${r.join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")}return e.data.length>0?"":"data.empty_data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({setData(t){e.data=t},setError(t){e.error=t}})).actions(e=>({runSQL:f.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,a=e.config;e.data=yield*f.toGenerator(g2({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:a.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runHTTP:f.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:o}=e.json;let l=JSON.parse(e.httpConfigString);l=fn(e.datasource,l);const i=yield*f.toGenerator(f2({type:r,key:a,configString:JSON.stringify(l),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=bn(e.datasource,i),d=Vo(o,c,e.contentModel.dashboardStateValues);e.data=d,e.state="idle",e.error=null}catch(r){if(console.error(r),ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runMericoMetricQuery:f.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:o}=e.json;let l={url:"/api/metric_management/query",method:"POST",data:e.metricQueryPayload};l=fn(e.datasource,l);const i=yield*f.toGenerator(b2({key:a,configString:JSON.stringify(l),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=bn(e.datasource,i),d=Vo(o,c,e.contentModel.dashboardStateValues);e.data=m2(d.data),e.state="idle",e.error=null}catch(r){if(console.error(r),ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(l=>({id:l.id,name:l.name,data:y.cloneDeep(l.data)})),r=e.contentModel.dashboardStateValues,a=e.pre_process,o=new Function(`return ${a}`)()(t,r,We);e.data=o,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>{var r,a;if(e.isTransform){const o=e.config;return[e.inUse,e.id,e.key,e.reQueryKey,o.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${e.metricQueryPayloadString}--${(a=e.datasource)==null?void 0:a.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}}));function m2(e){if("sortedColumns"in e&&"result"in e){const t=new Set(e.sortedColumns);return y.map(e.result,r=>{const a={};for(const o of t)a[o]=r[o];for(const o in r)t.has(o)||(a[o]=r[o]);return a})}return e}const Na=f.types.model("QueriesRenderModel",{current:f.types.optional(f.types.array(La),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get root(){return f.getRoot(e)},get dashboardName(){return this.root.name},get contentModel(){return f.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r}=this.contentModel,a=[];t.visibleViews.forEach(i=>{i.panels.forEach(c=>{a.push(...c.queryIDs)})});const o=y.uniq(t.visibleViews.map(i=>i.renderViewIDs).flat());r.current.forEach(i=>{const c=y.get(i,"config.options_query_id");if(!c)return;o.some(u=>i.visibleInViewsIDSet.has(u))&&a.push(c)}),this.findByIDSet(new Set(a)).forEach(i=>{const c=i.config;!i.isTransform||c.dep_query_ids.length===0||a.push(...c.dep_query_ids)});const l=new Set(a);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)},addTransformDepQueryIDs(t,r){this.findByIDSet(t).forEach(a=>{const o=a.config;!a.isTransform||o.dep_query_ids.length===0||o.dep_query_ids.forEach(l=>{r!=null&&r.has(l)||t.add(l)})})},get querisToForceReload(){const t=new Set,r=new Set,{views:a,filters:o}=this.contentModel,l=y.uniq(a.visibleViews.map(i=>i.renderViewIDs).flat());return o.current.forEach(i=>{const c=y.get(i,"config.options_query_id");if(!c)return;l.some(u=>i.visibleInViewsIDSet.has(u))&&t.add(c)}),this.addTransformDepQueryIDs(t),a.visibleViews.forEach(i=>{i.panels.forEach(c=>{c.queryIDs.forEach(d=>{t.has(d)||r.add(d)})})}),this.addTransformDepQueryIDs(r,t),{filterQueries:this.findByIDSet(t),panelQueries:this.findByIDSet(r)}}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:r,data:a})=>({id:r,data:a}));Ri(e.dashboardName,t)},downloadDataByQueryIDs(t,r){if(r.length===1)return this.downloadDataByQueryID(t,r[0]);const a=new Set(r),o=e.current.filter(l=>a.has(l.id)).map(({name:l,data:i})=>({id:l,data:i}));Ri(t,o)},downloadDataByQueryID(t,r){const a=e.findByID(r);if(!a){console.log("[downloadDataByQueryID] query not found");return}const{data:o}=a,l=t??a.name;Hi(l,o)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(o=>o.json)},version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Gt("Queries",r)},forceReloadVisibleQueries:f.flow(function*(){const{filterQueries:t,panelQueries:r}=e.querisToForceReload;if(console.log("🟡 Force reloading queries"),t.length>0){const a=yield Promise.allSettled(t.map(o=>o.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible filters, skipping");if(r.length>0){const a=yield Promise.allSettled(r.map(o=>o.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible panels, skipping")})}));function hc(e){return{current:e}}function gc({min:e,max:t}){const r=`${e}px`,a=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${a})`}const Ga=f.types.model("LayoutsRenderModel",{list:f.types.array(mi),currentBreakpoint:f.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return f.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return gc(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,a)=>r.min-a.min).forEach((r,a)=>{a!==t.length-1&&(r.max=t[a+1].min)}),t.forEach(r=>{r.text=gc(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const r=new Set(t);return this.currentLayoutSet.list.filter(o=>r.has(o.panelID))},gridLayouts(t){const r=new Set(t),a={};return e.list.forEach(o=>{a[o.id]=o.list.filter(l=>r.has(l.panelID)).map(l=>l.layoutProperies)}),a},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){f.addDisposer(e,G.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),fc=wi.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!f.getParent(e,2).findByKey(t)}})),Fa=f.types.model("SQLSnippetsRenderModel",{current:f.types.optional(f.types.array(fc),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(o=>o.json)},version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Gt("SQL Snippets",r)}}));function bc(e){return{current:e}}function en(e,t,r,a){return e.reduce((o,l)=>{try{o[l[t]]=_r(l[r],a)}catch(i){o[l[t]]=i.message}return o},{})}class yc{constructor(t){V(this,"origin");V(this,"copy");this.origin=t,this.copy=f.clone(t),G.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!y.isEqual(f.getSnapshot(this.origin),f.getSnapshot(this.copy))}commit(){f.applySnapshot(this.origin,f.getSnapshot(this.copy))}reset(){f.applySnapshot(this.copy,f.getSnapshot(this.origin))}update(t){f.applySnapshot(this.copy,t)}}const vc=e=>new yc(e),w2=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(s.Tooltip,{color:"white",label:n.jsx($t,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n.jsx(s.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(T.IconInfoCircle,{size:16,color:"gray"})})}),x2=k.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:a,...o},value:l,onChange:i})=>n.jsxs(s.Box,{children:[n.jsx(s.Text,{size:"sm",children:" "}),n.jsx(s.Checkbox,{label:n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(s.Box,{sx:{flexGrow:1},children:e}),n.jsx(w2,{description:r,isDescriptionEmpty:a})]}),checked:l||!1,onChange:c=>i(c.currentTarget.checked),...o,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),C2=({value:e,onChange:t,onClose:r,max_days:a,allowSingleDateInRange:o})=>{const l=e.value,[i,c]=l,d=h.useMemo(()=>i||new Date,[i]),u=h.useMemo(()=>{if(i&&!c)return i},[i,c]),p=h.useMemo(()=>{if(i&&!c&&a>0)return M(i).add(a-1,"days").toDate()},[i,c,a]),g=b=>{const[_,w]=b;t({value:b,shortcut:null}),_&&w&&r()};return n.jsx(wt.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:l,onChange:g,onNextMonth:console.log,minDate:u,maxDate:p,allowSingleDateInRange:o})},S2=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=h.useMemo(()=>!t&&!e?Number.NaN:M(t).diff(M(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const o=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:o,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},T2=({max_days:e})=>{const{t}=m.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(s.Divider,{variant:"dashed",my:10})]}):null},k2=({onChange:e,onClose:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=c=>()=>{const d=c();e(d),t()},l=h.useMemo(()=>Si(),[]),i=a.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(l).map(([c,d])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:r(`filter.widget.date_range.shortcut.${c}.label`)})}),d.map(({key:u,value:p,getRange:g})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:o(g),children:r(`filter.widget.date_range.shortcut.${c}.${i?"full.":""}${u}`)})},u))]},c))})})]})},_c=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),D2=({label:e,required:t,value:r,onChange:a,max_days:o,allowSingleDateInRange:l,inputFormat:i,disabled:c})=>{const{t:d}=m.useTranslation(),[u,{open:p,close:g}]=te.useDisclosure(!1),[b,_]=r.value,w=b?M(b).format(i):"",x=_?M(_).format(i):"";return n.jsxs(s.Popover,{opened:u,onClose:g,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:d("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:w,onFocus:p,styles:_c(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(s.TextInput,{label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(S2,{begin:b,end:_})}),leftSection:n.jsx(T.IconMinus,{size:16}),placeholder:d("filter.widget.date_range.end_date"),readOnly:!0,disabled:!b||c,value:x,onFocus:p,styles:_c(u),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(T2,{max_days:o}),n.jsx(C2,{value:r,onChange:a,onClose:g,allowSingleDateInRange:l,max_days:o}),n.jsx(k2,{onChange:a,onClose:g})]})]})},mc={value:[null,null],shortcut:null},Qa=e=>{const t=Pn(e.shortcut);return t||(Array.isArray(e.value)?e:mc)},z2=e=>h.useMemo(()=>Qa(e),[e]),wc=k.observer(({label:e,config:t,value:r=mc,onChange:a,disabled:o})=>{const{inputFormat:l,required:i,max_days:c,allowSingleDateInRange:d}=t,u=z2(r);return n.jsx(D2,{label:e,value:u,onChange:a,inputFormat:l,allowSingleDateInRange:d,max_days:c,required:i,disabled:o})}),M2=pt.createStyles((e,{radius:t=4,name:r,...a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...a,"&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}},".rc-select-item-option-state-icon":{lineHeight:"20px"}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),I2={root:{cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},V2=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,options:i,errorMessage:c,required:d})=>{const{t:u}=m.useTranslation(),{classes:p,cx:g}=M2({radius:t,name:"MultiSelectWidget"}),[b,_]=h.useState(!1),w=N=>{_(N)},x=b&&(o==null?void 0:o.length)>0,[S,D]=h.useState(""),z=h.useMemo(()=>{if(!S)return i;const N=S.toLowerCase(),oe=be=>{var ct;return((ct=be.description)==null?void 0:ct.toLowerCase().includes(N))||be.label.toLowerCase().includes(N)};return i.filter(oe)},[S,i]),I=h.useMemo(()=>new Set(i.map(N=>N.value)),[i]),A=h.useMemo(()=>new Set(o),[o]),E=h.useMemo(()=>A.size!==I.size?!1:Array.from(I).every(N=>A.has(N)),[A,I]),U=()=>{if(E){l([]);return}const N=Array.from(I);l(N)};return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:p.label,size:"sm",children:[a,d&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),x&&n.jsx(s.Tooltip,{label:u("filter.widget.common.x_selected",{count:o.length}),children:n.jsx(s.Badge,{variant:"light",children:o.length})})]}),n.jsx(qs,{disabled:e,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(s.CloseButton,{size:"sm"}),value:o,onChange:l,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(xa,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:N=>u("filter.widget.common.x_selected",{count:N.length}),searchValue:S,onSearch:D,filterOption:!1,dropdownRender:N=>n.jsxs(n.Fragment,{children:[I.size>0&&!S&&n.jsx(s.Group,{px:"xs",py:"xs",onClick:U,styles:I2,children:n.jsx(s.Checkbox,{size:"xs",checked:E,onChange:y.noop,label:u("common.actions.select_all")})}),n.jsx(s.Divider,{}),N]}),children:z.map(N=>n.jsxs(qs.Option,{title:N.label,children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},P2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const o=H(),l=!!t.options_query_id,{state:i,error:c}=o.getDataStuffByID(t.options_query_id),d=i==="loading",u=t.min_width?t.min_width:"200px",p=l?d:!1,g=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),b=_=>a(_,!1);return n.jsx(V2,{label:e,options:t.options,style:{minWidth:"160px",width:u,maxWidth:p?u:"unset",borderColor:"#e9ecef"},disabled:p,value:[...g],onChange:b,errorMessage:c,required:t.required})}),$2=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx("div",{...t,children:n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:r}),n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:a})]})})})},A2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{t:o}=m.useTranslation(),l=H(),i=!!t.options_query_id,{state:c,error:d}=l.getDataStuffByID(t.options_query_id),u=c==="loading",p=h.useCallback((g,b)=>{g&&a(g,!1)},[a]);return n.jsx(s.Select,{label:e,data:t.options,disabled:i?u:!1,value:r,onChange:p,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},renderOption:$2,searchable:!d,nothingFoundMessage:d||o("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function E2({label:e,config:t,value:r,onChange:a}){return n.jsx(s.TextInput,{label:e,value:r||"",onChange:o=>a(o.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const B2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M().add(365,"days").toDate(),[]);return n.jsx(wt.DatePicker,{defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,onNextMonth:console.log,minDate:i,maxDate:c,allowSingleDateInRange:!0})};function ja(e,t){if(!e)return null;const r=M(e);switch(t){case"day":case"week":case"month":case"quarter":return r.startOf(t);case"bi-week":return r.startOf("week").subtract(1,"week");default:throw new Error(`[merico-date-range] unexpected date-range step: ${t}`)}}function Wa(e,t){if(!e)return null;const r=M(e);switch(t){case"day":case"week":case"month":case"quarter":return r.endOf(t);case"bi-week":return r.endOf("week");default:throw new Error(`[merico-date-range] unexpected date-range step: ${t}`)}}function q2(e,t){if(!e)return null;const r=ja(e,t),a=Wa(e,t);return{start:r,end:a}}function O2(e,t,r,a){if(!t)return!1;const[o]=r,l=ja(t,a),i=Wa(t,a),c=M(e).isBefore(i);return o?M(e).isAfter(o)&&c:M(e).isAfter(l)&&c}function L2(e,t,r){if(!t)return!1;const[a]=r;return a?e.isSame(a,"day"):e.isSame(t,"day")}function N2(e,t){return t?e.isSame(t,"day"):!1}function G2(e,t){const[r,a]=t;if(!r||!a)return{inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1};const o=e.isSame(r,"day"),l=e.isSame(a,"day");return{inRange:e.isBetween(r,a,"day","[]"),firstInRange:o,lastInRange:l,selected:o||l}}const F2=(e,t,r)=>{const a=e.step,[o,l]=h.useState(null),[i,c]=h.useState(e.value),d=(_,w)=>{if(!_||!w)return;const[x,S]=i,D=_.toDate(),z=w.toDate();if(x===null){c([D,null]);return}const A=D.getTime()<x.getTime()?[D,S]:[x,z];c(A),t(A)};h.useEffect(()=>{c(e.value)},[e]),h.useEffect(()=>{c([null,null])},[r]);const u=h.useMemo(()=>r?null:i[0]?M(i[0]):null,[i,r]),p=h.useMemo(()=>r?null:i[0]?M(i[0]).add(365,"days"):null,[i,r]),g=h.useCallback(_=>{const w=M(_);return G2(w,e.value)},[r,e.value]),b=h.useCallback(_=>{const w=M(_),x=u&&p&&(w.isBefore(u)||w.isAfter(p)),S=!o&&i[0]?i[0]:o,D=q2(S,a);if(!D)return{onMouseEnter:()=>l(_),onMouseLeave:()=>l(null),inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1,disabled:x};if(w.format("MM-DD"),x)return{onMouseEnter:y.noop,onMouseLeave:y.noop,inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1,disabled:!0};const{start:z,end:I}=D,A=L2(w,z,i),E=N2(w,I),U=O2(_,S,i,a),N=U&&A,oe=U&&E,be=w.isBefore(u)||w.isAfter(p);return{onMouseEnter:()=>l(_),onMouseLeave:()=>l(null),inRange:U,firstInRange:N,lastInRange:oe,selected:A||E,onClick:()=>d(z,I),disabled:be}},[o,t,a,r,u,p,i]);return{getDayProps:r?g:b}},Q2=({value:e,onChange:t,handleRangeChange:r})=>{const[a,o]=h.useState(!0),l=e.value,[i,c]=l,d=h.useMemo(()=>i||new Date,[i]),{getDayProps:u}=F2(e,r,a),p=()=>{o(!1)},g=()=>{o(!!i&&!!c)};return n.jsx(wt.Calendar,{defaultDate:d,numberOfColumns:2,withCellSpacing:!1,getDayProps:u,onMouseEnter:p,onMouseLeave:g,hideOutsideDates:!0})},j2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M().add(365,"days").toDate(),[]);return n.jsx(wt.MonthPicker,{defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,minDate:i,maxDate:c,allowSingleDateInRange:!0})},qn={calendar_header:"_calendar_header_xr0sl_1",months_list:"_months_list_xr0sl_5",months_list_row:"_months_list_row_xr0sl_12",months_list_control:"_months_list_control_xr0sl_25"},W2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M(a).add(365,"days").subtract(1,"second").toDate(),[a]),d=h.useMemo(()=>o?M(o):null,[o]),u=h.useCallback(p=>d&&M(p).isSame(d,"quarter")?{lastInRange:!0,selected:!0}:{},[d]);return n.jsx(wt.MonthPicker,{classNames:{calendarHeader:qn.calendar_header,monthsList:qn.months_list,monthsListRow:qn.months_list_row,monthsListControl:qn.months_list_control},defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,minDate:i,maxDate:c,allowSingleDateInRange:!0,maxLevel:"year",monthsListFormat:"Q",getMonthControlProps:u})},U2=({value:e,onChange:t,onClose:r})=>{const a=l=>{const[i,c]=l,d=ja(i,e.step),u=Wa(c,e.step);t([(d==null?void 0:d.toDate())??null,(u==null?void 0:u.toDate())??null]),i&&c&&r()},o=e.step;return o==="day"?n.jsx(B2,{value:e,handleRangeChange:a}):o==="week"||o==="bi-week"?n.jsx(Q2,{value:e,onChange:t,handleRangeChange:a}):o==="month"?n.jsx(j2,{value:e,handleRangeChange:a}):o==="quarter"?n.jsx(W2,{value:e,handleRangeChange:a}):`错误的步长:${o}`},K2=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=h.useMemo(()=>!t&&!e?Number.NaN:M(t).diff(M(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const o=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:o,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},Ua={begin:"_begin_1cder_1",end:"_end_1cder_27",step:"_step_1cder_52"},xc=({label:e,value:t,onChange:r,className:a})=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("filter.widget.date_range.step.day"),value:"day"},{label:o("filter.widget.date_range.step.week"),value:"week"},{label:o("filter.widget.date_range.step.bi_week"),value:"bi-week"},{label:o("filter.widget.date_range.step.month"),value:"month"},{label:o("filter.widget.date_range.step.quarter"),value:"quarter"}],[o]),c=d=>{d&&r(d)};return n.jsx(s.Select,{className:a,label:e,data:i,value:t,onChange:c})},Y2=({onChange:e,step:t,onClose:r})=>{const{t:a,i18n:o}=m.useTranslation(),l=d=>()=>{const u=d(t);e(u),r()},i=h.useMemo(()=>Ni(t),[t]),c=o.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(i).map(([d,u])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{w:80,children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:a(`filter.widget.date_range.shortcut.${d}.label`)})}),u.map(({key:p,value:g,getRange:b})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:l(b),children:a(`filter.widget.date_range.shortcut.${d}.${c?"full.":""}${p}`)})},p))]},d))})})]})},Cc=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),X2=({label:e,required:t,value:r,onChange:a,inputFormat:o,disabled:l})=>{const{t:i}=m.useTranslation(),[c,{open:d,close:u}]=te.useDisclosure(!1),[p,g]=r.value,b=p?M(p).format(o):"",_=g?M(g).format(o):"",w=S=>{a({value:Ht(S[0],S[1],r.step),shortcut:null,step:r.step})},x=S=>{if(r.shortcut)return a(Rt(r.shortcut,S));a({value:Ht(r.value[0],r.value[1],S),shortcut:r.shortcut,step:S})};return n.jsxs(s.Popover,{opened:c,onClose:u,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",align:"text-anchor",wrap:"nowrap",gap:0,sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:i("filter.widget.date_range.start_date"),readOnly:!0,disabled:l,value:b,onFocus:d,styles:Cc(c),className:Ua.begin})}),n.jsx(s.TextInput,{label:n.jsx(s.Box,{children:" "}),leftSection:n.jsx(T.IconMinus,{size:16,onClick:d}),placeholder:i("filter.widget.date_range.end_date"),readOnly:!0,disabled:l,value:_,onFocus:d,styles:Cc(c),className:Ua.end}),n.jsx(xc,{className:Ua.step,value:r.step,onChange:x,label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(K2,{begin:p,end:g})})})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(U2,{value:r,onChange:w,onClose:u}),n.jsx(Y2,{onChange:a,step:r.step,onClose:u})]})]})},Sc={value:[null,null],shortcut:null,step:"day"},Z2=e=>{const t=Rt(e.shortcut,e.step);return t||(Array.isArray(e.value)?e:Sc)},J2=e=>h.useMemo(()=>Z2(e),[e]),H2=k.observer(({label:e,config:t,value:r=Sc,onChange:a,disabled:o})=>{const{inputFormat:l,required:i}=t,c=J2(r);return n.jsx(X2,{label:e,value:c,onChange:a,inputFormat:l,required:i,disabled:o})}),R2=k.observer(({filter:{type:e,config:t,key:r,...a},formFieldProps:o})=>{switch(e){case P.Select:return n.jsx(A2,{...a,...o,config:t});case P.MultiSelect:return n.jsx(P2,{...a,...o,config:t});case P.TreeSelect:return n.jsx(HT,{...a,...o,config:t});case P.TreeSingleSelect:return n.jsx(n2,{...a,...o,config:t});case P.TextInput:return n.jsx(E2,{...a,...o,config:t});case P.DateRange:return n.jsx(wc,{...a,...o,config:t});case P.MericoDateRange:return n.jsx(H2,{...a,...o,config:t});case P.Checkbox:return n.jsx(x2,{...a,...o,config:t});default:return null}}),ek=k.observer(h.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(ne,{children:n.jsx(R2,{filter:e,formFieldProps:t})})}))),tk=({disabled:e,onSubmit:t,stale:r})=>{const{t:a}=m.useTranslation(),{renderSearchButton:o}=Ks();return o?o({disabled:e,onSubmit:t,stale:r}):n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{color:"blue",size:"sm",onClick:()=>t(),disabled:e,"data-stale":r||void 0,children:a("common.actions.search")}),n.jsxs(s.Menu,{trigger:"hover",disabled:e,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{disabled:e,color:"blue",px:"xs","data-stale":r||void 0,style:{borderLeft:`1px solid ${e?"white":"var(--mantine-color-gray-4)"}`},children:n.jsx(T.IconChevronDown,{size:16})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconRefresh,{size:14}),disabled:e,onClick:()=>t({force:!0}),children:a("common.actions.reload")})})]})]})};function nk(e){const t=F();h.useEffect(()=>{var r,a;(a=(r=t.filters).updatePreviewValues)==null||a.call(r,e)},[e])}const Ka="N/A";function rk(){const e=Wt(),[t,r]=h.useState([]);return h.useEffect(()=>{const a=G.computed(()=>e.content.views.visibleViews.map(d=>{var u;return d.type===B.Tabs?(u=d.tabView)==null?void 0:u.view_id:d.id}).filter(Boolean).flatMap(d=>e.content.filters.visibleInView(d)).filter(Boolean).map(d=>ak(d)),{equals:G.comparer.structural}),o=G.autorun(()=>{r(a.get())});return()=>o()},[e]),t}function ak(e){switch(e.type){case P.Select:case P.MultiSelect:case P.TreeSelect:case P.TreeSingleSelect:return{label:e.label,value:sk(e.config,e.value)};case P.TextInput:return{label:e.label,value:e.value};case P.DateRange:return{label:e.label,value:ok(e.config,e.value)};case P.MericoDateRange:return{label:e.label,value:lk(e.config,e.value)};case P.Checkbox:return{label:e.label,value:ik(e.value)};default:return{label:e.label,value:e.value}}}function sk(e,t){const r=new Set;return Array.isArray(t)?t.forEach(a=>r.add(a)):r.add(t),r.size===0?Ka:e.options.filter(a=>r.has(a.value)).map(a=>a.label).join(", ")}function n6(e){return e}function ok(e,t){const a=Qa(t).value.filter(o=>!!o).map(o=>M(o).format(e.inputFormat));return a.length===0?Ka:a.join(" - ")}function lk(e,t){const a=Qa(t).value.filter(o=>!!o).map(o=>M(o).format(e.inputFormat));return a.length===0?Ka:a.join(" - ")}function ik(e){return e?"✔️":"❌"}const ck=({opened:e,toggle:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(T.IconChevronsUp,{size:14}):n.jsx(T.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},Tc=k.observer(function({view:t}){const[r,{toggle:a}]=te.useDisclosure(!0),o=H(),{control:l,handleSubmit:i,reset:c,formState:{isDirty:d}}=v.useForm({defaultValues:o.filters.values,reValidateMode:"onBlur"}),u=v.useWatch({control:l});h.useEffect(()=>{c(o.filters.values)},[o.filters.values,c]),nk(u);const p=o.filters.visibleInView(t.id),g=h.useMemo(()=>p.every(S=>S.should_auto_submit),[p]),b=h.useMemo(()=>p.filter(S=>y.get(S,"config.required",!1)),[p]),_=h.useMemo(()=>b.length===0?!1:b.some(S=>!S.requiredAndPass(u[S.key])),[u,b]),w=(S,D)=>(z,I)=>{D(z),(S.should_auto_submit||I)&&o.filters.setValueByKey(S.key,z)},x=h.useCallback(S=>{const D=y.get(S,"force",!1);i(o.filters.setValues)(),D&&o.queries.forceReloadVisibleQueries()},[i,o.filters.setValues]);return p.length===0?null:n.jsxs("form",{children:[n.jsx(ck,{opened:r,toggle:a}),n.jsx(s.Collapse,{in:r,children:n.jsxs(s.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:g?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(s.Group,{align:"flex-start",children:p.map(S=>n.jsx(v.Controller,{name:S.key,control:l,render:({field:D})=>n.jsx(ek,{filter:S,value:D.value,onChange:w(S,D.onChange)})},S.id))}),!g&&n.jsx(s.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(tk,{disabled:_,onSubmit:x,stale:d})})]})})]})}),kc={withInteraction:!0,withAddon:!0,withPanelTitle:!0},Dc=h.createContext(kc);function dk({children:e,...t}){const r=y.defaults({},t,kc);return n.jsx(Dc.Provider,{value:r,children:e})}function Ya(){return h.useContext(Dc)}function uk(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const pk=k.observer(()=>{const e=H(),{panel:t}=re(),r=h.useMemo(()=>ft(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx($t,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardStateValues:e.dashboardStateValues,variableAggValueMap:t.variableAggValueMap})}),Xa=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1),{panel:a}=re();return uk(a.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:()=>r(!1),title:a.title.show?a.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(pk,{})}),n.jsx(s.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(o=>!o),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(T.IconInfoCircle,{size:20})})})]})}),r6="",hk=k.observer(function(){const{panel:t}=re(),{name:r,title:a}=t;return a.show?n.jsx(s.Group,{"data-testid":"panel-title-bar",grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null}),Za=h.createContext({onScreenshot:y.noop});function gk(e){const t=h.useRef(null),{onScreenshot:r}=h.useContext(Za);return{ref:t,downloadPanelScreenshot:()=>{const o=t.current;if(!o)return;const l=o.offsetWidth*2,i=o.offsetHeight*2;As.toCanvas(t.current,{bgcolor:"white",width:l,height:i,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(c=>(r(c),c)).then(c=>new Promise(d=>{c.toBlob(u=>{d(u)})})).then(c=>{window.saveAs(c,`${e.name?e.name:e.viz.type}.png`)})}}}var zc=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(zc||{}),On=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(On||{});class fk{constructor(t){V(this,"vizInstance");V(this,"operationManager");V(this,"triggerManager");V(this,"vizManager");V(this,"runningMigration");V(this,"panelModel");V(this,"status","notStarted");this.panelModel=t.getRequired(ee.instanceScope.panelModel),this.vizInstance=t.getRequired(ee.instanceScope.vizInstance),this.operationManager=t.getRequired(ee.instanceScope.operationManager),this.triggerManager=t.getRequired(ee.instanceScope.triggerManager),this.vizManager=t.getRequired(ee.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}class bk{getTriggerSchemaList(){return[]}getTriggerList(){return Promise.resolve([])}removeTrigger(){return Promise.resolve()}createOrGetTrigger(){return Promise.resolve(Mc)}retrieveTrigger(){return Promise.resolve(Mc)}watchTriggerSnapshotList(){return()=>{}}needMigration(){return Promise.resolve(!1)}runMigration(){return Promise.resolve()}}class yk{constructor(){V(this,"id","");V(this,"schemaRef","");V(this,"triggerData",new ln({}))}}const Mc=new yk;class vk{getOperationSchemaList(){return[]}getOperationList(){return Promise.resolve([])}removeOperation(){return Promise.resolve()}createOrGetOperation(){return Promise.resolve(Ic)}runOperation(){return Promise.resolve()}retrieveTrigger(){return Promise.resolve(Ic)}runMigration(){return Promise.resolve()}needMigration(){return Promise.resolve(!1)}}class _k{constructor(){V(this,"id","");V(this,"schemaRef","");V(this,"operationData",new ln({}))}}const Ic=new _k,jn=class jn{constructor(){V(this,"triggerManager",new bk);V(this,"operationManager",new vk)}getInteractionList(){return Promise.resolve([])}addInteraction(){return Promise.resolve()}removeInteraction(){return Promise.resolve()}runInteraction(){return Promise.resolve()}};V(jn,"instance",new jn);let Ja=jn;function Vc(e,t=!0){const{panel:r}=re();return h.useCallback(a=>{const o=a.getRequired(ee.vizManager),l=o.resolveComponent(e.viz.type);return a.createScoped().provideFactory(ee.instanceScope.vizInstance,()=>o.getOrCreateInstance(e)).provideFactory(ee.instanceScope.interactionManager,i=>{const c=i.getRequired(ee.instanceScope.vizInstance);return t?new Lo(c,l,Tr):new Ja}).provideFactory(ee.instanceScope.operationManager,i=>i.getRequired(ee.instanceScope.interactionManager).operationManager).provideFactory(ee.instanceScope.triggerManager,i=>i.getRequired(ee.instanceScope.interactionManager).triggerManager).provideValue(ee.instanceScope.panelModel,r).provideFactory(ee.instanceScope.migrator,i=>new fk(i))},[e.viz.type,e.viz.conf,t])}function Pc(e){const[t,r]=h.useState(!1),a=Xt().getRequired(ee.instanceScope.migrator);return O.useAsyncEffect(async()=>{const o=a.status===On.notStarted;r(a.status===On.done),a.status===On.notStarted&&a.runMigration().then(l=>{l===zc.migrated&&o&&(e==null||e())}).finally(()=>{r(!0)})},[a]),t}function $c(e,t){const r=Xt().getRequired(ee.instanceScope.vizInstance);return O.useAsyncEffect(async()=>{y.isEqual(await r.instanceData.getItem(null),t.viz.conf)||await r.instanceData.setItem(null,t.viz.conf)},[r,t.viz.conf]),h.useEffect(()=>r.instanceData.watchItem(null,a=>{e(a)}),[e,t.viz.type]),r}function mk({setVizConf:e,...t}){const{panel:r}=t,a=$c(e,r),o=Pc(()=>{Fe.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return O.useAsyncEffect(async()=>{await a.instanceData.setItem(null,r.viz.conf)},[a,r.viz.type]),o?n.jsx(ju,{...t}):n.jsx(s.Text,{size:"sm",children:"Checking update..."})}function wk(e){const{panel:t,setVizConf:r}=e;$c(r,t);const{inEditMode:a}=h.useContext(St);return Pc(()=>{a&&Fe.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(Qu,{...e}):n.jsx(s.Text,{size:"sm",children:"Checking update"})}const a6="";function xk(e,t){const{vizManager:r}=h.useContext(ot),{panel:{viz:a,title:o,id:l,name:i,description:c,queryIDs:d,variables:u}}=re(),p={id:l,name:i,title:o,description:c,queryIDs:d,viz:a},{withInteraction:g}=Ya(),b=Vc(p,g);try{return r.resolveComponent(a.type),n.jsxs(vn,{configure:b,children:[n.jsx(wk,{setVizConf:a.setConf,panel:p,measure:t,data:e,variables:u,vizManager:r}),n.jsx(Ec,{})]})}catch(_){return console.info(y.get(_,"message")),null}}const Ac=k.observer(function({data:t}){const{ref:r,width:a,height:o}=te.useElementSize(),l=xk(t,{w:a,h:o}),i=a>0&&o>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(s.Box,{sx:{width:a,height:o,overflow:"hidden"},children:i&&n.jsx(ne,{children:l})})})});function Ck(e){const{setEchartsOptions:t}=re();h.useEffect(()=>{const r=o=>{t(o)},a=e.messageChannels.getChannel("viz");return a.on("rendered",r),()=>{a.off("rendered",r)}},[e.messageChannels])}const Ec=()=>{const e=Xt(),t=e.getRequired(ee.instanceScope.vizInstance);Ck(t);const{inEditMode:r}=h.useContext(St),a=e.getRequired(ee.panelAddonManager),{withAddon:o}=Ya(),l=Hu();return!l||!o?null:Au.createPortal(n.jsx(n.Fragment,{children:a.createPanelAddonNode({viz:t,isInEditMode:r})}),l,"addon")},Bc=k.observer(({panel:e})=>n.jsxs(s.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(s.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(s.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),Ha=k.observer(({panel:e})=>n.jsxs(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(s.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(Bc,{panel:e}),e.canRenderViz&&n.jsx(Ac,{data:e.data})]}));function Sk(e){return!["richText","button","vizDashboardState"].includes(e)}const Tk=k.observer(({children:e})=>n.jsx(n.Fragment,{children:n.jsxs(s.Menu,{withinPortal:!0,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle",color:"black",size:"md",pos:"absolute",top:16,right:16,style:{zIndex:410},children:n.jsx(T.IconDotsVertical,{size:14,style:{width:"70%",height:"70%"}})})}),n.jsx(s.Menu.Dropdown,{children:e})]})}));function kk(e){const t=h.useRef(null),r=h.useCallback(a=>{t.current=a},[]);return h.useEffect(()=>{t.current=null},[e]),{getEchartsOptions:()=>t.current,setEchartsOptions:r}}const Dk={border:"1px solid #e9ecef"},Ra=k.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:a,downloadPanelScreenshot:o}=gk(e),{withAddon:l,withPanelTitle:i}=Ya(),c=l?Fs:h.Fragment,{getEchartsOptions:d,setEchartsOptions:u}=kk(e.viz.type),{inEditMode:p}=h.useContext(St),g=p||Sk(e.viz.type);return n.jsx(er,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:o,getEchartsOptions:d,setEchartsOptions:u},children:n.jsx(s.Box,{id:e.id,"data-testid":"panel-root",className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:a,p:0,sx:{...Dk,...t},children:n.jsxs(c,{children:[i&&n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Xa,{})}),g&&n.jsx(Tk,{children:r}),n.jsx(hk,{})]}),n.jsx(Ha,{panel:e})]})})})}),qc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:e("common.actions.download_data")})}),Oc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t,downloadPanelScreenshot:r}=re();return n.jsx(s.Menu.Item,{onClick:r,leftSection:n.jsx(T.IconCamera,{size:14}),children:e("common.actions.download_screenshot")})}),zk=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.downloadSchema,leftSection:n.jsx(T.IconCode,{size:14}),children:e("common.actions.download_schema")})}),Mk={viewPanelInFullScreen:y.noop,inFullScreen:!1},es=h.createContext(Mk),Lc=k.observer(({view:e})=>{const{t}=m.useTranslation(),{panel:r}=re(),a=r.id,{viewPanelInFullScreen:o,inFullScreen:l}=h.useContext(es),i=h.useCallback(()=>{o(a)},[a,o]);return!l&&e.type!==B.Modal?n.jsx(s.Menu.Item,{onClick:i,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),disabled:!0,children:t("common.actions.enter_fullscreen")}):null}),Nc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:e("common.actions.refresh")})}),Ik=e=>{const{items:t}=or();return h.useMemo(()=>[{order:10,render:()=>n.jsx(Nc,{},"refresh")},{order:100,render:()=>n.jsx(qc,{},"download-data")},{order:300,render:()=>n.jsx(Oc,{},"download-screenshot")},{order:400,render:()=>n.jsx(Lc,{view:e},"enter-full-screen")},...t].sort((a,o)=>a.order-o.order),[t])},Vk=k.observer(({view:e})=>{const{getEchartsOptions:t,panel:r}=re();return Ik(e).map(o=>o.render({getEchartsOptions:t,inEditMode:!1,panelID:r.id,viewID:e.id}))}),Pk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Panel"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconAppWindow,{size:14}),children:r("panel.label")})}),$k=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Variables"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconVariable,{size:14}),children:r("panel.variable.labels")})}),Ak=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Visualization"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconChartHistogram,{size:14}),children:r("visualization.label")})}),Ek=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Interactions"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconRoute,{size:14}),children:r("interactions.label")})}),Bk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=De.useModals(),o=F(),l=()=>a.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.removePanelByID(e,t),confirmProps:{color:"red"},zIndex:320});return n.jsx(s.Menu.Item,{color:"red",onClick:l,leftSection:n.jsx(T.IconTrash,{size:14}),children:r("common.actions.delete")})}),qk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=F(),o=()=>{a.duplicatePanelByID(e,t)};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconCopy,{size:14}),children:r("common.actions.duplicate")})}),Ok=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Data"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconDatabase,{size:14}),children:r("data.label")})}),Lk=e=>{const{t}=m.useTranslation(),r=j(),{panel:a}=ae(),o=a.realQueryOptions,l=i=>{r.editor.open(["_QUERIES_",i])};return h.useMemo(()=>o.length===0?[]:[{order:500,render:()=>n.jsx(s.Divider,{label:t(o.length>1?"query.labels":"query.label"),labelPosition:"center"},"data-divider")},{order:501,render:()=>n.jsx(Ok,{panelID:a.id,viewID:e.id},"open-tab-data")},...o.map((i,c)=>({order:502+c,render:()=>n.jsx(s.Menu.Item,{onClick:()=>l(i.value),leftSection:n.jsx(T.IconDatabase,{size:14}),children:i.label},i.value)}))],[o])},Nk=e=>{const{t}=m.useTranslation(),{panel:r}=ae(),a=r.id,o=e.id,{items:l}=or(),i=Lk(e);return h.useMemo(()=>[{order:10,render:()=>n.jsx(Nc,{},"refresh")},{order:100,render:()=>n.jsx(qc,{},"download-data")},{order:200,render:()=>n.jsx(zk,{},"download-schema")},{order:300,render:()=>n.jsx(Oc,{},"download-screenshot")},{order:400,render:()=>n.jsx(Lc,{view:e},"enter-full-screen")},...i,{order:600,render:()=>n.jsx(s.Divider,{label:t("common.actions.edit"),labelPosition:"center"},"edit-divider")},{order:700,render:()=>n.jsx(Pk,{panelID:a,viewID:o},"open-tab-panel")},{order:800,render:()=>n.jsx($k,{panelID:a,viewID:o},"open-tab-variable")},{order:900,render:()=>n.jsx(Ak,{panelID:a,viewID:o},"open-tab-visualization")},{order:1e3,render:()=>n.jsx(Ek,{panelID:a,viewID:o},"open-tab-interaction")},{order:1100,render:()=>n.jsx(s.Divider,{label:t("common.actions.actions"),labelPosition:"center"},"actions-divider")},{order:1200,render:()=>n.jsx(qk,{panelID:a,viewID:o},"duplicate")},{order:1300,render:()=>n.jsx(Bk,{panelID:a,viewID:o},"delete-panel")},...l].sort((d,u)=>d.order-u.order),[i,l])},Gk=k.observer(({view:e})=>{const{getEchartsOptions:t,panel:r}=re();return Nk(e).map(o=>o.render({getEchartsOptions:t,inEditMode:!0,panelID:r.id,viewID:e.id}))}),Fk={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function Qk(e){return e.style.border.enabled?{}:Fk}const Gc=k.observer(function({panel:t,view:r}){const a=Qk(t);return n.jsx(Ra,{panel:t,panelStyle:a,dropdownContent:n.jsx(Gk,{view:r})})});function jk(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const ts=k.observer(({panel:e,view:t})=>{const r=jk(e);return n.jsx(Ra,{panel:e,panelStyle:r,dropdownContent:n.jsx(Vk,{view:t})})}),Wk={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Fc=k.observer(function({view:t,panel:r,exitFullScreen:a}){return n.jsx(s.Modal,{opened:!0,fullScreen:!0,onClose:a,title:n.jsx(s.Button,{color:"blue",size:"xs",onClick:a,leftSection:n.jsx(T.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:Wk,children:n.jsx(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(ts,{view:t,panel:r})})})});function Qc(e,t,r){const{panels:a}=H(),o=e.id==="Main",[l,i]=h.useState(()=>o&&a.findByID(t)?t:null),c=h.useCallback(g=>{i(g),o&&r(g)},[o,r]),d=h.useCallback(()=>{i(null),o&&r("")},[o,r]),u=l?a.findByID(l):null;return{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:!!u,fullScreenPanel:u}}function Uk(e){const t=Wt(),r=h.useMemo(()=>t.content.panels.findByID(e.panelId),[e.panelId]);return r?n.jsx(dk,{withAddon:!1,withPanelTitle:!1,withInteraction:!1,children:n.jsx(Ra,{panel:r,panelStyle:{}})}):null}const s6="",Kk=h.forwardRef(({title:e},t)=>n.jsx(s.Box,{ref:t,className:"react-grid-customDragHandle",title:e,children:n.jsx(s.ActionIcon,{variant:"transparent",color:"gray",children:n.jsx(T.IconMenu2,{size:16})})})),Yk=h.forwardRef(({handleAxis:e,...t},r)=>n.jsx(s.ActionIcon,{ref:r,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:n.jsx(T.IconChevronDownRight,{size:16})})),Xk=on.WidthProvider(on.Responsive),Zk=k.observer(({view:e,className:t="layout"})=>{const{t:r}=m.useTranslation(),o=F().layouts,l=o.items(e.panelIDs),i=o.gridLayouts(e.panelIDs),c=(p,g,b,_)=>{b.h<30&&(b.h=30,_.h=30),b.w<4&&(b.w=4,_.w=4)},d=(p,g,b)=>{console.log("🔴 onResizeStop",{layouts:p,oldItem:g,newItem:b}),o.updateCurrentLayoutItem(b)},u=(p,g,b)=>{console.log("🔴 onDragStop",{layouts:p,oldItem:g,newItem:b}),o.updateCurrentLayoutItems(p)};return n.jsx(Xk,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:o.cols,layouts:i,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(Yk,{}),onResize:c,breakpoints:o.breakpoints,onBreakpointChange:o.setCurrentBreakpoint,onResizeStop:d,onDragStop:u,width:o.currentLayoutPreviewWidth,children:l.map(p=>n.jsxs("div",{"data-grid":p.layoutProperies,className:"panel-grid-item",children:[n.jsx(Kk,{title:r("view.layout.drag_to_move")}),n.jsx(Gc,{view:e,panel:p.panel})]},p.id))})}),Jk=on.WidthProvider(on.Responsive),Hk=k.observer(({view:e,className:t="layout"})=>{const r=H(),a=r.layouts.items(e.panelIDs),o=r.layouts.gridLayouts(e.panelIDs);return n.jsx(Jk,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:o,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:a.map(l=>l.panel.usingGhostViz?null:n.jsx("div",{"data-grid":l.layoutProperies,className:"panel-grid-item",children:n.jsx(ts,{view:e,panel:l.panel})},l.id))})});function ns(e){const t=h.useRef(null),{onScreenshot:r}=h.useContext(Za);return{ref:t,downloadScreenshot:()=>{var l;const o=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");o&&e.downloadScreenshot(o,r)}}}const Rk=k.observer(({downloadScreenshot:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),l=Ws(),i=H(),c=()=>{const d=JSON.stringify(i.contentJSON,null,2),u=`${l.name}__${i.name}`;Gt(u,d)};return n.jsxs(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:a,onMouseLeave:o,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(T.IconShare3,{size:"1rem"})})})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconDownload,{size:14}),onClick:i.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),jc=k.observer(({children:e,view:t,sx:r={}})=>{const{ref:a,downloadScreenshot:o}=ns(t);return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{ref:a,pt:10,pb:10,sx:r,children:e}),n.jsx(Rk,{downloadScreenshot:o})]})}),Wc=k.observer(({downloadScreenshot:e})=>n.jsx(s.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(T.IconCamera,{size:14})})),eD=k.observer(({children:e,view:t})=>{const r=H(),a=t.config,o=r.views.visibleViewIDs.includes(t.id),l=()=>r.views.rmVisibleViewID(t.id),{ref:i,downloadScreenshot:c}=ns(t);return n.jsx(s.Modal,{size:a.width,centered:!0,opened:o,onClose:l,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:a.custom_modal_title.value}),n.jsx(Wc,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:a.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:n.jsx(s.Box,{ref:i,children:e})})}),tD=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},nD=k.observer(({view:e})=>{const t=H(),r=e.config;return n.jsxs(s.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(s.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(a=>n.jsx(s.Tabs.Tab,{value:a.id,sx:tD(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabsInOrder.map(a=>{const o=t.views.findByID(a.view_id);return o?n.jsx(s.Tabs.Panel,{value:a.id,children:n.jsx(Ln,{view:o})},a.id):null})]})}),rD=k.observer(({view:e,children:t})=>{switch(e.type){case B.Modal:return n.jsx(eD,{view:e,children:t});case B.Tabs:return n.jsx(nD,{view:e});case B.Division:default:return n.jsx(jc,{view:e,children:t})}}),aD=k.observer(({children:e,view:t})=>{const a=F().layouts,[o,l]=te.useResizeObserver();return h.useEffect(()=>{a.setCurrentLayoutWrapperWidth(l.width)},[l.width]),n.jsx(s.Box,{sx:{height:"100%"},ref:o,children:n.jsx(s.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:a.currentLayoutPreviewWidth??"100%",transform:`scale(${a.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(jc,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Uc(e){return e.replace(/(vw|vh)/,"%")}const sD=k.observer(({children:e,view:t})=>{const r=t.config,{width:a,height:o}=h.useMemo(()=>({width:Uc(r.width),height:Uc(r.height)}),[r.width,r.height]),{ref:l,downloadScreenshot:i}=ns(t);return n.jsx(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(s.Modal,{size:r.width,opened:!0,onClose:y.noop,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:r.custom_modal_title.value}),n.jsx(Wc,{downloadScreenshot:i})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:a,height:o,maxHeight:o},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:n.jsx(s.Box,{ref:l,children:e})})})}),oD=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},lD=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},iD=k.observer(({view:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=F(),o=h.useMemo(()=>a.views.options.filter(u=>u.type===B.Division),[e.id,a.views.options]),l=e.config,i=u=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{l.removeTab(u),d&&e.setTab(d)},confirmProps:{color:"red"},zIndex:320}),c=l.tabs.length===0,d=l.tabsInOrder.length===0?void 0:l.tabsInOrder[0].id;return n.jsxs(s.Tabs,{className:"preview-view-tabs",variant:l.variant,orientation:l.orientation,value:e.tab||d,onChange:e.setTab,styles:oD(l),children:[n.jsxs(s.Tabs.List,{grow:l.grow,children:[l.tabsInOrder.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,sx:lD(u),children:u.name??u.id},u.id)),n.jsx(s.Tabs.Tab,{onClick:l.addTab,value:"add",className:"add-a-tab",children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})]}),l.tabsInOrder.map((u,p)=>{const g=a.views.findByID(u.view_id);return n.jsxs(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[n.jsxs(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(s.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:b=>u.setName(b.currentTarget.value)}),n.jsx(s.Select,{label:t("view.label"),value:u.view_id,onChange:u.setViewID,data:o}),n.jsx(s.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:b=>u.setOrder(b||0),min:0,max:1e3,step:1}),n.jsx(s.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:l.variant!=="default"}),g&&n.jsx(s.Button,{mt:20,variant:"gradient",leftSection:n.jsx(T.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>a.views.setIDOfVIE(g.id),children:t("view.component.tabs.tab.switch_to_view",{name:g.name})}),n.jsx(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>i(u.id),disabled:c,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),g&&n.jsx(Ln,{view:g})]},u.id)})]})}),cD=k.observer(({view:e,children:t})=>{switch(e.type){case B.Modal:return n.jsx(sD,{view:e,children:t});case B.Tabs:return n.jsx(iD,{view:e});case B.Division:default:return n.jsx(aD,{view:e,children:t})}}),Kc=k.observer(function({view:t}){const a=F().layouts.divisionPreviewScale!==1;return n.jsx(es.Provider,{value:{viewPanelInFullScreen:y.noop,inFullScreen:!1},children:n.jsx(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:a?"transparent":"#efefef"},children:n.jsx(cD,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Tc,{view:t})}),n.jsx(Zk,{view:t})]})})})})}),Ln=k.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:a}=Rs(),{viewPanelInFullScreen:o,exitFullScreen:l,inFullScreen:i,fullScreenPanel:c}=Qc(t,r,a);return n.jsx(es.Provider,{value:{viewPanelInFullScreen:o,inFullScreen:i},children:n.jsxs(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===B.Modal?"0 !important":"100%"},children:[i&&n.jsx(Fc,{view:t,panel:c,exitFullScreen:l}),n.jsx(rD,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[!i&&n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Tc,{view:t})}),!i&&n.jsx(Hk,{view:t})]})})]})})});var Yc=(e=>(e.Use="use",e.Edit="edit",e))(Yc||{});const dD={[B.Division]:"Division",[B.Tabs]:"Tabs",[B.Modal]:"Modal"},Xc={[B.Division]:"rgba(255, 0, 0, 0.2)",[B.Modal]:"rgba(0, 0, 0, 0.2)",[B.Tabs]:"rgba(255, 200, 100, 0.4)"},uD={[B.Division]:"#ff4000",[B.Modal]:"#000",[B.Tabs]:"#ffad18"},Zc=An.views(e=>({get usages(){return e.contentModel.findFilterUsage(e.id)}})).actions(e=>({}));function pD(e,t,r){f.addDisposer(e,f.addMiddleware(e,(a,o)=>{o(a,()=>{f.getType(a.context)===t&&a.type==="action"&&r(a.name,a.context)})}))}const Jc=f.types.compose("FiltersModel",Ba,f.types.model({current:f.types.optional(f.types.array(Zc),[]),previewValues:f.types.optional(f.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===P.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key,widget:t.type}))},get sortedList(){return y.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(a=>a.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){pD(e.current,An,(r,a)=>{if(r==="setType"){const o=nc(a.config.default_value,a.config);e.setValueByKey(a.key,o),e.updatePreviewValues({...e.previewValues,[a.key]:o})}})}return{afterCreate(){t()}}}),Hc=La.views(e=>({get canPreviewData(){return e.isTransform?e.config.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const a=new Set(e.run_by);r?a.add(t):a.delete(t),e.run_by.length=0,e.run_by.push(...a)}})),Rc=f.types.compose("QueriesModel",Na,f.types.model({current:f.types.optional(f.types.array(Hc),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return y.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==W.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return y.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return y.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(a=>a.id===t);r&&(f.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(o=>{r.has(o.id)&&f.detach(o)});const a=[...e.current];y.remove(a,o=>r.has(o.id)),e.current=f.cast(a)},duplicateByID(t){const r=e.current.find(o=>o.id===t);if(!r){console.error(new Error(`[duplicate query] Can't find a query by id[${t}]`));return}const a=Te.v4();return e.current.push({...r.json,name:`${r.name} (${a})`,id:a}),a}})),ed=Fa.views(e=>({get sortedList(){return y.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return y.sortBy(t,r=>r.label.toLowerCase())},get usedFilterKeyMap(){const t=new Map;return e.current.forEach(r=>{const a=y.get(r,"value","");if(!a)return;const o=y.uniq(a.match(Et.filter)),l=new Set;o.forEach(i=>l.add(i)),t.set(r.key,l)}),t}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.keySet.has(a.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(a=>a.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(o=>{r.has(o.key)&&f.detach(o)});const a=[...e.current];y.remove(a,o=>r.has(o.key)),e.current=f.cast(a)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),hD=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),gD=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),fD=f.types.model({page:f.types.optional(f.types.number,1),limit:f.types.optional(f.types.number,20),data:f.types.optional(f.types.frozen(),[]),total:f.types.optional(f.types.number,0),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get keywords(){return f.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=f.getParent(e,1);return`${r}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:r}=e.keywords;return`
|
|
541
|
+
`),_t=k.observer(({filter:e})=>{const{t}=m.useTranslation();return n.jsx(fr,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:QT(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftSection:n.jsx(T.IconMathFunction,{size:16})},description:n.jsx(s.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:n.jsxs(s.List,{size:"xs",type:"ordered",children:[n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),$n=k.observer(({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),a=j(),o=F(),l=h.useMemo(()=>o.queries.options,[o.queries.current]),i=l.length===0,c=d=>{a.editor.setPath(["_QUERIES_",d])};return n.jsx(s.Select,{label:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{fw:500,size:"sm",children:r("filter.widget.common.use_query_data_as_options")}),e&&n.jsx(s.Button,{size:"xs",leftSection:n.jsx(T.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:r("query.open")})]}),data:l,value:e,onChange:Z(t),allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:i,error:i?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),Pi={stroke:1.5,color:"currentColor",opacity:1,size:18},$i={intersect:n.jsx(T.IconLayersIntersect,{...Pi}),reset:n.jsx(T.IconLayersSubtract,{...Pi})},jT=({option:e,checked:t})=>n.jsxs(s.Group,{flex:"1",gap:"xs",children:[$i[e.value],e.label]}),xa=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{label:t("filter.widget.common.default_value_mode.intersect"),value:"intersect"},{label:t("filter.widget.common.default_value_mode.reset"),value:"reset"}],[r.language]),{default_value_mode:o}=e;return n.jsx(s.Select,{leftSection:$i[o]??null,label:t("filter.widget.common.default_value_mode.label"),data:a,value:o,onChange:e.setDefaultValueMode,renderOption:jT})}),WT=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:a.required,onChange:o=>a.setRequired(o.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(_t,{filter:t})]}),n.jsx(s.TextInput,{label:r("filter.widget.common.min_width"),value:a.min_width,onChange:o=>a.setMinWidth(o.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:r("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:a.treeCheckStrictly,onChange:o=>a.setTreeCheckStrictly(o.currentTarget.checked),label:r("filter.widget.tree_select.strictly")}),n.jsx($n,{value:a.options_query_id,onChange:a.setOptionsQueryID}),n.jsx(s.NumberInput,{value:a.default_selection_count,onChange:a.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(xa,{config:a}),n.jsx(Vi,{})]})}),Ca=({errorMessage:e})=>{const{t}=m.useTranslation();return e?n.jsx(s.Text,{c:"red",size:"12px",children:e}):n.jsx(s.Text,{c:"dimmed",size:"12px",children:t("filter.widget.common.selector_option_empty")})},UT=({rotate:e,onClick:t})=>n.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),Ai=({expanded:e,isLeaf:t,value:r,onClick:a,...o})=>t?n.jsx("span",{style:{width:"14px",display:"inline-block"}}):n.jsx(UT,{rotate:e?"0":"-90",onClick:a,...o}),KT=({onClick:e})=>n.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),Ei=({onClick:e,...t})=>n.jsx(KT,{onClick:e,...t}),YT=pt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,position:"absolute",width:`${r} !important`,backgroundColor:"#fff",border:"1px solid #e9ecef",boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{padding:0},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",width:"100%",padding:"8px 0",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),XT=(e,t,r,a)=>{const o=h.useMemo(()=>{if(!a)return y.cloneDeep(e.filter(g=>!g.disabled));const u=[],p=g=>{g.disabled||u.push(g),g.children.forEach(p)};return e.forEach(p),u},[e,a]),l=h.useMemo(()=>new Set(o.map(u=>u.value)),[o]),i=h.useMemo(()=>new Set(t.map(u=>u.value)),[t]),c=h.useMemo(()=>i.size!==l.size?!1:Array.from(l).every(u=>i.has(u)),[i,l]);return{allValueSet:l,selectedValueSet:i,toggleSelectAll:()=>{if(c){r([]);return}const u=Array.from(o);r(u)},allSelected:c}},ZT={root:{cursor:"pointer",backgroundColor:"#FFF","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},JT=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,treeData:i,errorMessage:c,required:d,treeCheckStrictly:u})=>{const{t:p}=m.useTranslation(),{classes:g,cx:b}=YT({radius:t,width:r.width,name:"FilterTreeSelectWidget"}),[_,w]=h.useState(!1),x=A=>{w(A)},S=_&&(o==null?void 0:o.length)>0,D=XT(i,o,l,u),[z,I]=h.useState("");return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:g.label,size:"sm",children:[a,d&&n.jsx("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),S&&n.jsx(s.Tooltip,{label:p("filter.widget.common.x_selected",{count:o.length}),children:n.jsx(s.Badge,{variant:"light",children:o.length})})]}),n.jsx(Yn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},treeCheckStrictly:u,labelInValue:!0,className:b(g.root,"check-select"),dropdownClassName:b(g.dropdown,""),onDropdownVisibleChange:x,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:Ai,treeIcon:Ei,maxTagTextLength:10,value:o,treeData:i,notFoundContent:n.jsx(Ca,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Yn.SHOW_PARENT,onChange:l,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>p("filter.widget.common.x_selected",{count:o.length}),searchValue:z,onSearch:I,dropdownRender:A=>n.jsxs(n.Fragment,{children:[D.allValueSet.size>0&&!z&&n.jsx(s.Group,{px:"xs",pt:8,pb:8,onClick:D.toggleSelectAll,styles:ZT,children:n.jsx(s.Checkbox,{size:"xs",checked:D.allSelected,onChange:y.noop,label:p("common.actions.select_all")})}),n.jsx(s.Divider,{}),A]})})]})},HT=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:o,treeDataLoading:l,errorMessage:i}=t,c=b=>{const _=b.map(w=>w.value);a(_,!1)},d=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,l]),u=t.min_width?t.min_width:"200px",g=!!t.options_query_id?l:!1;return n.jsx(JT,{disabled:g,style:{minWidth:"160px",width:u,maxWidth:g?u:"unset",borderColor:"#e9ecef"},value:[...d],onChange:c,treeData:o,errorMessage:i,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),RT=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(_t,{filter:e})]}),n.jsx(s.TextInput,{label:t("filter.widget.common.min_width"),value:r.min_width,onChange:a=>r.setMinWidth(a.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:t("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx($n,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(s.Checkbox,{checked:r.default_selection_count===1,onChange:a=>r.setDefaultSelectionCount(a.currentTarget.checked?1:0),label:t("filter.widget.tree_single_select.select_first_option_by_default")}),n.jsx(xa,{config:r}),n.jsx(Vi,{})]})}),e2=pt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},"&.rc-tree-select-focused":{".rc-tree-select-selection-item":{color:"#aaa"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"calc(2.25rem / 3)",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",position:"relative"},".rc-tree-select-selection-search":{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,".rc-tree-select-selection-search-input":{height:"36px",paddingLeft:"calc(2.25rem / 3)",textOverflow:"ellipsis"}},".rc-tree-select-selection-item":{position:"absolute",top:0,bottom:0,left:0,paddingLeft:"calc(2.25rem / 3)",color:"#000",lineHeight:"36px",fontSize:"0.875rem",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",transition:"color 200ms ease"},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px",position:"absolute",width:`${r} !important`,"&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden",transition:"background-color 200ms ease","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-selected":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease",width:"100%",padding:"8px 0","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),t2=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,treeData:i,errorMessage:c,required:d})=>{m.useTranslation();const{classes:u,cx:p}=e2({radius:t,width:r.width,name:"FilterTreeSelectWidget"});return n.jsxs(s.Stack,{gap:3,children:[n.jsx(s.Group,{justify:"space-between",children:n.jsxs(s.Text,{className:u.label,size:"sm",children:[a,d&&n.jsx("span",{className:u.required,"aria-hidden":"true",children:"*"})]})}),n.jsx(Yn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},multiple:!1,labelInValue:!0,className:p(u.root,"check-select"),dropdownClassName:p(u.dropdown,""),transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:Ai,treeIcon:Ei,value:o,treeData:i,notFoundContent:n.jsx(Ca,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!1,onChange:l,onSelect:console.log,showSearch:!0})]})},n2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:o,treeDataLoading:l,errorMessage:i}=t,c=b=>{a(b?b.value:null,!1)},d=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,t.treeDataLoading]),u=t.min_width?t.min_width:"200px",g=!!t.options_query_id?l:!1;return n.jsx(t2,{disabled:g,style:{width:u,maxWidth:g?u:"unset",borderColor:"#e9ecef"},value:d,onChange:c,treeData:o,errorMessage:i,label:e,required:t.required})});function r2(e){return $u.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function a2(e){return e.map(t=>{const{label:r,description:a,...o}=t,l={...o,filterBasis:`${r}___${a??""}`,description:a,label:r};return a&&(l.label=h.createElement("div",{},[h.createElement(s.Text,{key:0,title:t.label},t.label),h.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),l})}const Bi=f.types.compose("FilterConfigModel_BaseTreeSelect",f.types.model({min_width:f.types.optional(f.types.string,""),default_value_mode:ga}),ya).views(e=>({get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,r=a2(t);return r2(r)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"}})).actions(e=>({setMinWidth(t){e.min_width=t}})),Sa=f.types.compose("FilterTreeSelectConfigMeta",f.types.model({_name:f.types.literal("tree-select"),default_value:f.types.optional(f.types.array(f.types.string),[]),treeCheckStrictly:f.types.optional(f.types.boolean,!1)}),Bi).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d,treeCheckStrictly:u}=e;return{_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,treeCheckStrictly:u,default_value_mode:a,default_selection_count:d}},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:r}=e;return r?e.treeData.slice(0,r).map(o=>o.value):[]},optionsByValues(t){if(!Array.isArray(t)||t.length===0)return[];const r=new Set(t);return e.options.filter(a=>r.has(a.value))},valueObjects(t){const r=new Set(t);return e.plainData.filter(a=>r.has(a.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=f.cast(t)},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){if(e.optionsLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=e.filter.value,r=new Set(e.plainData.map(o=>o.value)),a=(t??[]).filter(o=>r.has(o));a.length>0?e.filter.setValue(a):e.filter.setValue(e.defaultSelection)},afterCreate(){f.addDisposer(e,G.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),qi=()=>Sa.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Ta=f.types.compose("FilterTreeSingleSelectConfigMeta",f.types.model({_name:f.types.literal("tree-single-select"),default_value:f.types.optional(f.types.string,"")}),Bi).views(e=>({get json(){const{_name:t,default_value:r,default_value_mode:a,required:o,min_width:l,static_options:i,options_query_id:c,default_selection_count:d}=e;return{_name:t,required:!!o,min_width:l,default_value:r,static_options:i,options_query_id:c,default_value_mode:a,default_selection_count:d}},get selectFirstByDefault(){return e.default_selection_count===1},get defaultSelection(){if(e.treeDataLoading)return"";const t=e.filter.formattedDefaultValue;return t||(this.selectFirstByDefault&&e.treeData.length>0?e.treeData[0].value:"")},valueObject(t){if(t)return e.plainData.find(r=>r.value===t)},initialSelection(t){if(t)return this.valueObject(t)},truthy(t){return typeof t=="string"&&t!==""}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDefaultValueMode(t){t!=="intersect"&&t!=="reset"||(e.default_value_mode=t)},applyDefaultSelection(){if(e.treeDataLoading)return;if(e.default_value_mode==="reset"){e.filter.setValue(e.defaultSelection);return}const t=e.filter.value;e.optionValuesSet.has(t)?e.filter.setValue(t):e.filter.setValue(e.defaultSelection)},afterCreate(){f.addDisposer(e,G.reaction(()=>G.toJS(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Oi=()=>Ta.create({_name:"tree-single-select",default_value:"",static_options:[],options_query_id:"",default_selection_count:0});function s2(e,t){const r=e.startOf("week");let a=r.add(1,"week").endOf("week");for(;a.isBefore(t);)a=a.add(2,"week");return[r.toDate(),a.toDate()]}function Ht(e,t,r){return!e||!t?[e,t]:Xe(M(e),M(t),r)}function Xe(e,t,r){if(!e||!t)return[(e==null?void 0:e.toDate())??null,(t==null?void 0:t.toDate())??null];switch(r){case"day":return[e.startOf("day").toDate(),t.endOf("day").toDate()];case"week":return[e.startOf("week").toDate(),t.endOf("week").toDate()];case"bi-week":return s2(e,t);case"month":return[e.startOf("month").toDate(),t.endOf("month").toDate()];case"quarter":return[e.startOf("quarter").toDate(),t.endOf("quarter").toDate()];default:throw new Error(`[merico-date-range] unexpected date-range step: ${r}`)}}const o2={day:new Set(["m","m2","m3","m6","y","d30","d60","d90","d180","d365"]),week:new Set(["m","m2","m3","m6","y"]),"bi-week":new Set(["m","m2","m3","m6","y"]),month:new Set(["m","m2","m3","m6","y"]),quarter:new Set(["m","m2","m6","y"])};function tt(e,t){return!o2[e].has(t)}const Li=e=>[{key:"m",value:"last month",group:"last",disabled:tt(e,"m"),getRange:t=>{const r=M();return{value:Xe(r.subtract(1,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last month",step:t}}},{key:"m2",value:"last 2 months",group:"last",disabled:tt(e,"m2"),getRange:t=>{const r=M();return{value:Xe(r.subtract(2,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 2 months",step:t}}},{key:"m3",value:"last 3 months",group:"last",disabled:tt(e,"m3"),getRange:t=>{const r=M();return{value:Xe(r.subtract(3,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 3 months",step:t}}},{key:"m6",value:"last 6 months",group:"last",disabled:tt(e,"m6"),getRange:t=>{const r=M();return{value:Xe(r.subtract(6,"month").startOf("month"),r.subtract(1,"month").endOf("month"),t),shortcut:"last 6 months",step:t}}},{key:"y",value:"last year",group:"last",disabled:tt(e,"y"),getRange:t=>{const r=M();return{value:Xe(r.subtract(1,"year").startOf("year"),r.subtract(1,"year").endOf("year"),t),shortcut:"last year",step:t}}},{key:"d30",value:"recent 30 days",group:"recent",disabled:tt(e,"d30"),getRange:t=>{const r=M();return{value:Xe(r.subtract(30,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 30 days",step:t}}},{key:"d60",value:"recent 60 days",group:"recent",disabled:tt(e,"d60"),getRange:t=>{const r=M();return{value:Xe(r.subtract(60,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 60 days",step:t}}},{key:"d90",value:"recent 90 days",group:"recent",disabled:tt(e,"d90"),getRange:t=>{const r=M();return{value:Xe(r.subtract(90,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 90 days",step:t}}},{key:"d180",value:"recent 180 days",group:"recent",disabled:tt(e,"d180"),getRange:t=>{const r=M();return{value:Xe(r.subtract(180,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 180 days",step:t}}},{key:"d365",value:"recent 365 days",group:"recent",disabled:tt(e,"d365"),getRange:t=>{const r=M();return{value:Xe(r.subtract(365,"day").startOf("day"),r.subtract(1,"day").endOf("day"),t),shortcut:"recent 365 days",step:t}}}];function Rt(e,t){if(!e)return null;const a=Li(t).find(o=>o.value===e);return a?a.getRange(t):null}function Ni(e){return y.groupBy(Li(e),"group")}function Gi(e){try{if(e.default_shortcut){const r=Rt(e.default_shortcut,e.default_step);if(r)return{value:r.value.map(a=>M(a).toDate()),shortcut:e.default_shortcut,step:e.default_step}}const t=e.default_value.map(r=>r===null?r:M.tz(r,"UTC").toDate()??r);return{value:Ht(t[0],t[1],e.default_step),shortcut:null,step:e.default_step}}catch(t){return console.error(t),{value:[null,null],shortcut:null,step:e.default_step}}}function Fi(e,t){return e.map(r=>{try{return r?M.tz(r,"UTC").toISOString():null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const l2=f.types.model("FilterMericoDateRangeConfigMeta",{_name:f.types.literal("merico-date-range"),required:f.types.boolean,inputFormat:f.types.enumeration("DateRangeInputFormat",["YYYY/MM/DD"]),default_value:f.types.optional(f.types.array(f.types.union(f.types.Date,f.types.null)),[null,null]),default_shortcut:f.types.optional(f.types.string,""),default_step:f.types.optional(f.types.string,"day")}).views(e=>({get json(){const{_name:t,required:r,inputFormat:a,default_step:o,default_value:l,default_shortcut:i}=e;return{_name:t,required:r,inputFormat:a,default_step:o,default_value:Fi(l),default_shortcut:i}},truthy(t){try{const{value:r}=t;return Array.isArray(r)&&r.length===2&&r.every(a=>!!a)}catch(r){return console.error(r),!1}},get filter(){return f.getParent(e)},get dateStringsValue(){try{const t=this.filter.value,[r,a]=t.value,o=r?M(r).format(e.inputFormat):"",l=a?M(a).format(e.inputFormat):"";return[o,l]}catch(t){return console.error(t),["",""]}}})).actions(e=>({setFilterValue(t){try{e.filter.setValue(t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t.value),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t??"",!t)return;const r=Rt(e.default_shortcut,e.default_step);r&&e.setFilterValue(r)},setDefaultStep(t){e.default_step=t}})),ka=f.types.snapshotProcessor(l2,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:M.tz(r,"UTC").toDate())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:Fi(t,r.inputFormat)}}}),Qi=()=>ka.create({_name:"merico-date-range",required:!1,inputFormat:"YYYY/MM/DD",default_value:[null,null],default_shortcut:"",default_step:"day"}),An=f.types.model("FilterMeta",{id:f.types.identifier,key:f.types.string,label:f.types.string,order:f.types.number,visibleInViewsIDs:f.types.array(f.types.string),auto_submit:f.types.optional(f.types.boolean,!1),default_value_func:f.types.optional(f.types.string,""),type:f.types.enumeration("DashboardFilterType",[P.Select,P.MultiSelect,P.TreeSelect,P.TreeSingleSelect,P.TextInput,P.Checkbox,P.DateRange,P.MericoDateRange]),config:f.types.union(_a,va,Sa,Ta,ma,fa,ba,ka)}).views(e=>({get contentModel(){return f.getRoot(e).content},get filters(){return this.contentModel.filters},get value(){return this.filters.values[e.key]},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==P.TreeSelect&&e.type!==P.TreeSingleSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[P.Select,P.Checkbox,P.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:a,order:o,visibleInViewsIDs:l,default_value_func:i,auto_submit:c,type:d,config:u}=e;return{id:t,key:r,type:d,label:a,order:o,config:u.json,auto_submit:c,visibleInViewsIDs:G.toJS(l),default_value_func:i}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return y.get(e.config,"required",!1)?y.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.filters.setValueByKey(e.key,t)},setLabel(t){e.label=t},setOrder(t){const r=Number(t);Number.isFinite(r)&&(e.order=r)},setType(t){switch(t){case P.Select:e.config=Ii();break;case P.MultiSelect:e.config=Mi();break;case P.TreeSelect:e.config=qi();break;case P.TreeSingleSelect:e.config=Oi();break;case P.TextInput:e.config=wa();break;case P.Checkbox:e.config=xi();break;case P.DateRange:e.config=Di();break;case P.MericoDateRange:e.config=Qi();break;default:return}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var B=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(B||{});const Da=f.types.model("ViewDivisionConfig",{_name:f.types.literal(B.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),ji=()=>Da.create({_name:B.Division}),i2=f.types.model("CustomModalTitleModel",{enabled:f.types.optional(f.types.boolean,!1),func_content:f.types.optional(f.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,a=f.getParent(e,2),o=f.getRoot(e);if(!t)return a.name;try{const l={filters:o.content.filters.valuesForPayload,context:o.context.current};return new Function(`return ${r}`)()(l)}catch(l){return console.error(l),a.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),En={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
542
|
+
`)},za=f.types.model("ViewModalConfig",{_name:f.types.literal(B.Modal),width:f.types.string,height:f.types.string,custom_modal_title:f.types.optional(i2,En)}).views(e=>({get json(){const{_name:t,width:r,height:a,custom_modal_title:o}=e;return{_name:t,width:r,height:a,custom_modal_title:o.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Wi=()=>za.create({_name:B.Modal,width:"90vw",height:"90vh"}),c2=f.types.model("ViewTabsTabModel",{id:f.types.identifier,name:f.types.string,view_id:f.types.string,color:f.types.optional(f.types.string,""),order:f.types.optional(f.types.number,0)}).views(e=>({get json(){const{id:t,name:r,view_id:a,color:o,order:l}=e;return{id:t,name:r,color:o,order:l,view_id:a}}})).actions(e=>({setName(t){e.name=t},setViewID(t){t&&(e.view_id=t)},setColor(t){e.color=t},setOrder(t){typeof t!="string"&&(e.order=t)}})),Ma=f.types.model("ViewTabsConfig",{_name:f.types.literal(B.Modal),tabs:f.types.optional(f.types.array(c2),[]),variant:f.types.optional(f.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:f.types.optional(f.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:f.types.optional(f.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:a,tabs:o,grow:l}=e;return{grow:l,tabs:o.map(i=>i.json),_name:t,variant:r,orientation:a}},get tabsInOrder(){return y.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){t&&(e.variant=t)},setOrientation(t){t&&(e.orientation=t)},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=f.cast(t)},addTab(){const t=te.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){const r=e.tabs.find(a=>a.id===t);r&&e.tabs.remove(r)}})),Ui=()=>Ma.create({_name:B.Modal,tabs:[]}),Ki=f.types.model({id:f.types.identifier,name:f.types.string,type:f.types.enumeration("EViewComponentType",[B.Division,B.Modal,B.Tabs]),config:f.types.union(Da,za,Ma),panelIDs:f.types.optional(f.types.array(f.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:a,config:o}=e;return{id:t,name:r,type:a,config:o.json,panelIDs:e.panelIDs.map(l=>l)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case B.Division:e.config=ji();break;case B.Modal:e.config=Wi();break;case B.Tabs:e.config=Ui();break;default:return}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const r=e.panelIDs.filter(a=>a!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})),lt="14.32.0",d2={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:B.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:lt,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},Ia=f.types.model("DataSourceMetaModel",{id:f.types.string,type:f.types.enumeration("DataSourceType",[W.HTTP,W.MySQL,W.Postgresql,W.MericoMetricSystem]),key:f.types.string,config:f.types.frozen()}),Yi=f.types.model("DataSourcesMetaModel",{list:f.types.optional(f.types.array(Ia),[])}).views(e=>({find({type:t,key:r}){return e.list.find(a=>a.key===r&&a.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Xi=f.types.model({id:f.types.string,content:f.types.string,create_time:f.types.string,update_time:f.types.string,is_preset:f.types.boolean}),Va=f.types.model("GlobalSQLSnippetsMeta",{list:f.types.optional(f.types.array(Xi),[])}).views(e=>({find(t){return e.list.find(r=>r.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Bn=f.types.model("ContextMeta",{current:f.types.optional(f.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,r){e.current[t]=r}}));function Pa(e){return Bn.create({current:e})}const $a=f.types.compose("ViewRenderModel",Ki,f.types.model({tab:f.types.optional(f.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(r=>r.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==B.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return f.getParent(e,3)},get panels(){if(e.type!==B.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,r=this.contentModel.views.findByID(t);return(r==null?void 0:r.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===B.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t,r){const a=t.offsetWidth*2+10,o=t.offsetHeight*2+10,l=new Es,i=new Date().getTime(),c=await As.toCanvas(t,{bgcolor:"white",width:a,height:o,style:{transformOrigin:"0 0",transform:"scale(2)"}}).then(d=>(r==null||r(d),new Promise(u=>{d.toBlob(p=>{u(p)})})));l.file(`${e.name}_${i}.png`,c),l.file(`dashboard_state_${i}.json`,JSON.stringify(this.contentModel.dashboardStateValues,null,4)),l.generateAsync({type:"blob"}).then(d=>{sn.saveAs(d,`${e.name}_${i}.zip`)}).catch(d=>{console.error(d),Fe.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:d.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),Aa=f.types.model("ViewsRenderModel",{current:f.types.optional(f.types.array($a),[]),visibleViewIDs:f.types.array(f.types.string)}).views(e=>({get json(){return e.current.map(t=>at(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===B.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null},get firstVisibleTabsViewActiveTabStr(){return JSON.stringify(this.firstVisibleTabsViewActiveTab)}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(a=>a)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(a=>a===t);r!==-1&&e.visibleViewIDs.splice(r,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const r=e.firstVisibleTabsView;r==null||r.setTabByTabInfo(t)}}));function Zi(e,t){const r=e.length>0?[e[0].id]:[],a=e.map(o=>{const{_name:l=o.type}=o.config,i={...o,tab:"",config:{...o.config,_name:l},panelIDs:o.panelIDs};if(o.type===B.Tabs){let c=y.minBy(o.config.tabs,d=>d.order);!c&&o.config.tabs.length>0&&(c=o.config.tabs[0]),i.tab=(c==null?void 0:c.id)??""}return i});return t&&(a[0].tab=t.id),{current:a,visibleViewIDs:r}}const u2=new Pu.AsyncParser({withBOM:!0});async function Ji(e){return!Array.isArray(e)||e.length===0?"":await u2.parse(e).promise()}async function Hi(e,t){const r=await Ji(t),a=new Blob([r],{type:"text/csv"});sn.saveAs(a,`${e}.csv`)}function Ri(e,t){const r=new Es,a=t.map(async({id:o,data:l})=>{const i=await Ji(l);r.file(`${o}.csv`,i)});Promise.all(a).then(()=>{r.generateAsync({type:"blob"}).then(o=>{sn.saveAs(o,`${e}.zip`)})}).catch(o=>{console.error(o),Fe.notifications.show({color:"red",title:"Failed to download data",message:o.message})})}function Gt(e,t){const r=new Blob([t],{type:"application/json"});sn.saveAs(r,`${e}.json`)}const Ea=ui.views(e=>({get contentModel(){return f.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},get usingGhostViz(){return e.viz.type===Rl.name},queryByID(t){return this.queries.find(r=>r.id===t)},get data(){return this.queries.reduce((t,r)=>(t[r.id]=r.data,t),{})},get variableStrings(){return Mo(e.variables,this.data)},get variableAggValueMap(){const t={},r=this.data;return e.variables.reduce((a,o)=>(a[o.name]=He(o,r),a),t),t},get variableValueMap(){const t={},r=this.variableAggValueMap;return e.variables.reduce((a,o)=>(a[o.name]=Be(o,r[o.name]),a),t),t},get variableStyleMap(){const t=this.variableValueMap,r={};return e.variables.reduce((a,o)=>{const l=dp(o.color,t[o.name]);return a[o.name]={color:l,"font-size":o.size,"font-weight":o.weight,variable:o},a},r),r},get dataLoading(){return this.queries.some(t=>t.isTransform?t.depQueryModelStates.some(r=>r==="loading"):t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(l=>!l.runByConditionsMet);if(t.length===0)return"";const r=new Set,a=new Set;t.forEach(l=>{const i=l.conditionNames;i.context.forEach(c=>r.add(c)),i.filters.forEach(c=>a.add(c))});const o=[];return r.size>0&&o.push(`context: ${Array.from(r).join(", ")}`),a.size>0&&o.push(`filter${a.size>1?"s":""}: ${Array.from(a).join(", ")}`),o.length===2&&o.splice(1,0,"and"),o.unshift("Waiting for"),o.join(" ")},get queryErrors(){return this.queries.map(t=>t.error??t.metricQueryPayloadErrorString).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading},get realDataFieldOptions(){return e.queryIDs.length===0?[]:this.queries.map(t=>{const r=t.data;return r.length===0?[]:Object.keys(r[0]).map(o=>({label:o,value:`${t.id}.${o}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},dataFieldOptions({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l}){let i=[...this.realDataFieldOptions];if(o&&(i=i.filter(c=>c.group_id===o)),l==null||l.forEach(c=>{i.unshift({label:c.label,value:c.value,group:"",group_id:"",disabled:!1})}),t&&!i.find(c=>c.value===t)){const c=$(t),d=this.queryByID(c.queryID);i.unshift({label:c.columnKey,value:t,group:d?d.name:c.queryID,group_id:d?d.id:"",disabled:!0})}return r&&i.unshift({label:a,value:"",group:"",group_id:"",disabled:!1}),i},dataFieldOptionGroups({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l}){const i=this.dataFieldOptions({selected:t,clearable:r,unsetKey:a,queryID:o,additional_options:l});return Object.entries(y.groupBy(i,"group")).map(([d,u])=>({group:d,items:u.map(p=>({label:p.label,value:p.value,group_id:p.group_id,disabled:p.disabled}))}))}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.name,e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(r=>r.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:r,layouts:a}=this.getSchema(),l=JSON.stringify({panels:[t],definition:{queries:r},layouts:a,version:lt},null,2),i=e.name;Gt(i,l)}}));function ec(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:na.name,conf:na.createConfig()},style:{border:{enabled:!0}}}}const Ba=f.types.model("PanelsRenderModel",{list:f.types.optional(f.types.array(Ea),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];return t.forEach(a=>{const o=e.idMap.get(a);o?r.push(o):console.warn(`Panel is not found, id:${a}`)}),r}}));function tc(e){const t=e.config,r=t==null?void 0:t.default_value;return r===void 0?r:t._name==="date-range"?Ti(t):t._name==="merico-date-range"?Gi(t):r}function p2(e,t){const r=e.default_value_func;try{const a=new Function(`return ${r}`)()(e,We,t);return e.config._name==="date-range"&&Array.isArray(a)?{value:a,shortcut:null}:e.config._name==="merico-date-range"&&Array.isArray(a)?{value:a,shortcut:null,step:e.config.step}:a}catch(a){return console.error(a),tc(e)}}function nc(e,t){var r;return(r=e.default_value_func)!=null&&r.trim()?p2(e,t):tc(e)}function rc(e,t){return e.reduce((r,a)=>(r[a.key]=nc(a,t),r),{})}function ac(e,t){const r={};return Object.entries(t).forEach(([a,o])=>{const l=e[a];if(typeof o!="object"||!("shortcut"in o)||!l)return r[a]=l??o,r;if(Array.isArray(l))return console.log("⚪️ adapting legacy date-range value: ",l),r[a]={value:l,shortcut:null},r;const i=l,{shortcut:c}=i;if(!c)return console.log("⚪️ skipping input date range when it has no shortcut",i),r[a]=i,r;if("step"in o){const d=i.step;r[a]=Rt(c,d)}else r[a]=Pn(c);return r}),r}const qa=f.types.model("FiltersRenderModel",{current:f.types.optional(f.types.array(An),[]),values:f.types.optional(f.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get filter(){return f.getParent(e)},get keysToTypes(){return e.current.reduce((t,r)=>(t[r.key]=r.type,t),{})},keyStateItemMap(t){return e.current.reduce((r,a)=>{const o=t[a.key];return r[a.key]={type:a.type,key:a.key,model:a,label:a.label??a.id,value:o},r},{})},get valuesForPayload(){const t={};return Object.entries(e.values).forEach(([r,a])=>{t[r]=a;const o=this.findByKey(r);o&&o.config._name===P.DateRange&&(t[r]=o.config.dateStringsValue),o&&o.config._name===P.MericoDateRange&&(t[r]={...a,value:o.config.dateStringsValue})}),t},get contentModel(){return f.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:r})=>({default_value_func:t,config:r})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return rc(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByKey(t){return e.current.find(r=>r.key===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get inOrder(){return y.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return y.sortBy(e.current.filter(r=>r.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,r)=>(t[r.key]=r.label,t),{})},get keyIDMap(){return e.current.reduce((t,r)=>(t[r.key]=r.id,t),{})},getSelectOption(t){const r=this.findByID(t);if(!r||!("getSelectOption"in r.config))return null;const a=e.values[r.key];return r.config.getSelectOption(a)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=ac(t,e.values)},setValueByKey(t,r){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(r)),e.values={...e.values,[t]:r}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,r){return{filters:e.findByIDSet(new Set(t)).map(l=>({...l.json,visibleInViewsIDs:r?l.json.visibleInViewsIDs:[]})),version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t,!1),null,2);Gt("Filters",r)}}));function Oa(e,t,r,a){const o={...r,...t},l=rc(e,o),i=ac(a,l);return console.groupCollapsed("⚪️ initialValues"),console.log("filters",e),console.log("defaultValues",l),console.log("filterValues ",a),console.log("initialValues ",i),console.groupEnd(),{current:e,values:i}}function h2(e,t){const r=Bs.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function g2({query:e,name:t,payload:r,additionals:a},o){if(!e.sql)return[];const{type:l,key:i,sql:c,pre_process:d,post_process:u}=e,p=mr(c,r),g=fh({sql:p,pre_process:d}),b=Bs.encode(g);h2(g,b);let _=await $e.query(o)({type:l,key:i,query:b,...a},{params:{name:t}});return _=bh(u,_,_r(r)),_}async function f2({type:e,key:t,configString:r,name:a,additionals:o},l){try{return await $e.httpDataSourceQuery(l)({type:e,key:t,query:r,...o},{params:{name:a}})}catch(i){if(ke.isCancel(i))throw i;return console.error(i),i}}async function b2({key:e,configString:t,name:r,additionals:a},o){try{return await $e.mericoMetricQuery(o)({type:"merico_metric_system",key:e,query:t,...a},{params:{name:r}})}catch(l){throw l}}async function La(){try{return(await $e.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function sc(){try{return(await $e.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}function y2(e){var t;if("cols"in e){const{cols:r}=e,a=((t=r.find(o=>o.type==="trending_date_col"))==null?void 0:t.metricSourceCol)??null;return{variables:[],filters:r.filter(o=>o.type==="filter").map(o=>o.metricSourceCol),groupBys:r.filter(o=>o.type==="group_by").map(o=>o.metricSourceCol),trendingDateCol:a,supportTrending:!!a}}return"variables"in e?{variables:e.variables,filters:[],groupBys:[],trendingDateCol:null,supportTrending:e.variables.includes("date_range")}:{variables:[],filters:e.filters,groupBys:e.groupBys,trendingDateCol:null,supportTrending:e.supportTrending}}const oc={string:"维度列",number:"数值列",date:"数值列",boolean:"维度列",dimension:"扩展维度"};function lc(e){return y.groupBy(e,r=>{const{dataType:a}=r;return a?oc[a]:r.dimension!==null?oc.dimension:"ERROR"})}function v2(e){if(e.length===0)return[];const t=lc(e);return Object.entries(t).map(([a,o])=>({group:`${a}(${o.length})`,items:o.map(l=>{const{dataType:i,dimension:c}=l;return c?{group:l.name,description:l.description,items:c.fields.map(d=>typeof d=="string"?{label:d,value:`${l.name} -> ${d}`}:{label:d.field,value:`${l.name} -> ${d.field}`,...d})}:{label:l.name,value:l.name,...l}})}))}function _2(e){if(e.length===0)return[];const t=lc(e);return Object.entries(t).map(([a,o])=>({group:`${a}(${o.length})`,items:o.map(l=>({label:l.name,value:l.name,description:l.description,dataType:l.dataType??"dimension",dimension:l.dimension}))}))}const ic=new Map([["accumulate",{name:"累计计算",description:"按指定的聚合方式,依次计算指标值的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["yoyRatio",{name:"年同比率(yoy)",description:"对比当前年份与上一个年份同期指标值的变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepRatio",{name:"环比率",description:"对比当前步长与上一个步长指标值的变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepSpansRatio",{name:"移动计算",description:"按设定的窗口沿时序对指标值进行滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}],["percentage",{name:"总占比",description:"总占比 = 当前值 / 总值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["percentage_accumulate",{name:"累计占比",description:"按聚合规则计算各项占比,再依次计算占比率的累计值,如帕累托的累计占比值。",requireWindowConfig:!1,requireTrendingDateCol:!1}],["accumulate_yoyRatio",{name:"累计年同比",description:"按聚合规则累加数据,再与上一年同期累计值对比得出变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["yoyRatio_accumulate",{name:"年同比累计",description:"先计算各步长指标相对上一年同期的同比率,再依次计算同比率的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["stepRatio_accumulate",{name:"环比累计",description:"先计算各步长指标相对上一步长的环比率,再依次计算环比率的累计值。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["percentage_yoyRatio",{name:"占比年同比",description:"按聚合规则计算各项占比,再与去年同期占比对比得出变化率。",requireWindowConfig:!1,requireTrendingDateCol:!0}],["yoyRatio_stepSpansRatio",{name:"年同比移动计算",description:"先计算各步长指标相对上一年同期的同比率,再按移动设置沿时序滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}],["stepRatio_stepSpansRatio",{name:"环比移动计算",description:"先计算各步长指标相对上一步长的环比率,再按移动设置沿时序滚动计算。",requireWindowConfig:!0,requireTrendingDateCol:!0}]]);function cc(e,t){if(t)return e;const r=Array.from(ic.entries()).filter(([a,o])=>o.requireTrendingDateCol).map(([a])=>a);return e.filter(a=>!r.includes(a))}function dc(e,t,r){return Array.isArray(e)&&e.length===2?{start:M(e[0]).tz(t).format(r),end:M(e[1]).tz(t).format(r)}:null}function uc(e,t,r,a,o="PRC",l="YYYY-MM-DD"){const i=t?y.get(a,t):void 0,c=e?y.get(a,e):void 0;let d=t?y.get(r,t,""):"";i===P.MericoDateRange&&t&&(d=y.get(r,`${t}.step`,""));const u={start:"",end:"",unitOfTime:d,unitNumber:1,timezone:o,stepKeyFormat:l};if(e)if(c===P.MericoDateRange){const p=y.get(r,`${e}.value`),g=dc(p,o,l);g&&(u.start=g.start,u.end=g.end)}else{const p=y.get(r,e),g=dc(p,o,l);g&&(u.start=g.start,u.end=g.end)}return u}const pc=vi.views(e=>({get rootModel(){return f.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){return this.contentModel.dashboardStateVariableOptions},getConditionOptionsWithInvalidValue(t){const{optionGroups:r,validValues:a}=this.conditionOptions;if(!t||a.has(t))return this.conditionOptions;const o={group:"common.invalid",items:[{label:t,value:t}]};return{optionGroups:[...r,o],validValues:a}},get conditionOptionsWithInvalidRunbys(){const{optionGroups:t,validValues:r}=this.conditionOptions,a={group:"common.invalid",items:[]};return e.run_by.forEach(o=>{r.has(o)||a.items.push({label:o,value:o})}),{optionGroups:[...t,a],validValues:r}},get unmetRunByConditions(){if(!f.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const r=this.contentModel.payloadForSQL;return t.filter(a=>{const o=y.get(r,a);return Array.isArray(o)?o.length===0:typeof o=="number"?Number.isNaN(o):!o})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){const t=y.get(e,"config.sql","");return wr(t,this.payload)},get httpConfigString(){const{context:t,filters:r}=this.payload,{name:a,pre_process:o}=e.json,l=gh(o,t,r);return console.groupCollapsed(`Request config for: ${a}`),console.log(l),console.groupEnd(),JSON.stringify(l)},get typedAsSQL(){return[W.Postgresql,W.MySQL].includes(e.type)},get typedAsHTTP(){return[W.HTTP].includes(e.type)},get isMericoMetricQuery(){return e.type===W.MericoMetricSystem},get isTransform(){return e.type===W.Transform},get reQueryKey(){const t=y.get(e,"config.react_to",[]);if(t.length===0)return"";const r=e.contentModel.payloadForSQL,a=[...t].reduce((o,l)=>(o[l]=y.get(r,l),o),{});return JSON.stringify(a)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,r=e.unmetRunByConditions.filter(o=>o.startsWith("context.")).map(o=>o.replace("context.","")),a=e.unmetRunByConditions.filter(o=>o.startsWith("filters.")).map(o=>y.get({filters:t},o,o.replace("filters.",""))).filter(o=>!!o);return{context:r,filters:a}},get queries(){return f.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=y.get(e,"config.sql","");if(!t)return[];const r=y.uniq(t.match(Et.sqlSnippet)),a=y.uniq(t.match(Et.filter)),o=y.uniq(t.match(Et.context)),l=[];return r.forEach(i=>{l.push({type:"sql_snippet",key:i,valid:e.contentModel.sqlSnippets.keySet.has(i)})}),a.forEach(i=>{l.push({type:"filter",key:i,valid:e.contentModel.filters.keySet.has(i)})}),o.forEach(i=>{l.push({type:"context",key:i,valid:e.contentModel.mock_context.keySet.has(i)})}),l},get usedFilterKeySet(){const t=new Set,r=i=>{t.add(i.replace(/^filters\./,""))};if(e.run_by.forEach(i=>r(i)),y.get(e.config,"react_to",[]).forEach(i=>r(i)),!this.typedAsSQL)return t;const o=y.get(e,"config.sql","");return o&&y.uniq(o.match(Et.filter)).forEach(i=>r(i)),t},get metricQueryPayload(){if(e.type!==W.MericoMetricSystem)return null;const t=this.payload,r={filters:e.contentModel.filters.keysToTypes},a=e.config,o=y.omit(Object.fromEntries(a.sqlVariables.map(p=>{const g=p.sqlVar,b=p.variable,_=y.get(t,b);return[g,_]})),["date_range","step"]);console.log("MMS var",o);const l=a.filters.reduce((p,g)=>{const b=y.get(t,g.variable),_=y.get(r,g.variable),w=g.dimension;if(_===P.DateRange){const S=b.every(D=>Number.isFinite(Number(D)))?b.map(D=>Number(D)):b;p[w]={between:S}}else if(_===P.MericoDateRange){const S=b.value.every(D=>Number.isFinite(Number(D)))?b.value.map(D=>Number(D)):b;p[w]={between:S}}else Array.isArray(b)?p[w]={in:b}:p[w]={eq:b};return p},{}),i={id:a.id,type:a.type,filters:l,groupBys:a.groupBys,variables:o,semanticKey:a.semanticKey},c=a.sqlVariables.find(p=>["date_range","step"].includes(p.sqlVar));if(c&&(i.timeQuery=uc(c.variable,c.variable,t,r)),a.extraCalculations&&a.extraCalculations.length>0&&(i.extraCalculations=cc(a.extraCalculations,a.timeQuery.enabled)),a.useDefaultValues&&(i.useDefaultValues=!0),!a.timeQuery.enabled)return i;const{range_variable:d,unit_variable:u}=a.timeQuery;return i.timeQuery=uc(d,u,t,r),i},get metricQueryPayloadString(){return this.metricQueryPayload?JSON.stringify(this.metricQueryPayload,null,2):""},get metricQueryPayloadError(){const t=[];if(!this.metricQueryPayload)return t;const r=e.config,{timeQuery:a}=this.metricQueryPayload;if(!a)return r.groupByValues.length>2&&t.push("分组聚合维度:最多支持两个维度的聚合计算"),t;r.groupByValues.length>1&&t.push("分组聚合维度:按时间序列展示时,仅可选择一个聚合维度");const{start:o,end:l,unitOfTime:i}=a;return(!o||!l)&&t.push("时间维度:时间范围不完整"),i||t.push("步长:必选"),t},get metricQueryPayloadErrorString(){return this.metricQueryPayloadError.join(`
|
|
543
|
+
`)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),Na=f.types.compose("QueryRenderModel",pc,f.types.model({state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),data:f.types.optional(f.types.frozen([]),[]),error:f.types.optional(f.types.frozen(),null)})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=y.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const a=[];return t.length>0&&a.push(`context: ${t.join(", ")}`),r.length>0&&a.push(`filter${r.length>1?"s":""}: ${r.join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")}return e.data.length>0?"":"data.empty_data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({setData(t){e.data=t},setError(t){e.error=t}})).actions(e=>({runSQL:f.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,a=e.config;e.data=yield*f.toGenerator(g2({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:a.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runHTTP:f.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:o}=e.json;let l=JSON.parse(e.httpConfigString);l=fn(e.datasource,l);const i=yield*f.toGenerator(f2({type:r,key:a,configString:JSON.stringify(l),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=bn(e.datasource,i),d=Vo(o,c,e.contentModel.dashboardStateValues);e.data=d,e.state="idle",e.error=null}catch(r){if(console.error(r),ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runMericoMetricQuery:f.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:o}=e.json;let l={url:"/api/metric_management/query",method:"POST",data:e.metricQueryPayload};l=fn(e.datasource,l);const i=yield*f.toGenerator(b2({key:a,configString:JSON.stringify(l),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=bn(e.datasource,i),d=Vo(o,c,e.contentModel.dashboardStateValues);e.data=m2(d.data),e.state="idle",e.error=null}catch(r){if(console.error(r),ke.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(l=>({id:l.id,name:l.name,data:y.cloneDeep(l.data)})),r=e.contentModel.dashboardStateValues,a=e.pre_process,o=new Function(`return ${a}`)()(t,r,We);e.data=o,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>{var r,a;if(e.isTransform){const o=e.config;return[e.inUse,e.id,e.key,e.reQueryKey,o.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${e.metricQueryPayloadString}--${(a=e.datasource)==null?void 0:a.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}}));function m2(e){if("sortedColumns"in e&&"result"in e){const t=new Set(e.sortedColumns);return y.map(e.result,r=>{const a={};for(const o of t)a[o]=r[o];for(const o in r)t.has(o)||(a[o]=r[o]);return a})}return e}const Ga=f.types.model("QueriesRenderModel",{current:f.types.optional(f.types.array(Na),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get root(){return f.getRoot(e)},get dashboardName(){return this.root.name},get contentModel(){return f.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r}=this.contentModel,a=[];t.visibleViews.forEach(i=>{i.panels.forEach(c=>{a.push(...c.queryIDs)})});const o=y.uniq(t.visibleViews.map(i=>i.renderViewIDs).flat());r.current.forEach(i=>{const c=y.get(i,"config.options_query_id");if(!c)return;o.some(u=>i.visibleInViewsIDSet.has(u))&&a.push(c)}),this.findByIDSet(new Set(a)).forEach(i=>{const c=i.config;!i.isTransform||c.dep_query_ids.length===0||a.push(...c.dep_query_ids)});const l=new Set(a);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)},addTransformDepQueryIDs(t,r){this.findByIDSet(t).forEach(a=>{const o=a.config;!a.isTransform||o.dep_query_ids.length===0||o.dep_query_ids.forEach(l=>{r!=null&&r.has(l)||t.add(l)})})},get querisToForceReload(){const t=new Set,r=new Set,{views:a,filters:o}=this.contentModel,l=y.uniq(a.visibleViews.map(i=>i.renderViewIDs).flat());return o.current.forEach(i=>{const c=y.get(i,"config.options_query_id");if(!c)return;l.some(u=>i.visibleInViewsIDSet.has(u))&&t.add(c)}),this.addTransformDepQueryIDs(t),a.visibleViews.forEach(i=>{i.panels.forEach(c=>{c.queryIDs.forEach(d=>{t.has(d)||r.add(d)})})}),this.addTransformDepQueryIDs(r,t),{filterQueries:this.findByIDSet(t),panelQueries:this.findByIDSet(r)}}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:r,data:a})=>({id:r,data:a}));Ri(e.dashboardName,t)},downloadDataByQueryIDs(t,r){if(r.length===1)return this.downloadDataByQueryID(t,r[0]);const a=new Set(r),o=e.current.filter(l=>a.has(l.id)).map(({name:l,data:i})=>({id:l,data:i}));Ri(t,o)},downloadDataByQueryID(t,r){const a=e.findByID(r);if(!a){console.log("[downloadDataByQueryID] query not found");return}const{data:o}=a,l=t??a.name;Hi(l,o)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(o=>o.json)},version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Gt("Queries",r)},forceReloadVisibleQueries:f.flow(function*(){const{filterQueries:t,panelQueries:r}=e.querisToForceReload;if(console.log("🟡 Force reloading queries"),t.length>0){const a=yield Promise.allSettled(t.map(o=>o.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible filters, skipping");if(r.length>0){const a=yield Promise.allSettled(r.map(o=>o.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible panels, skipping")})}));function hc(e){return{current:e}}function gc({min:e,max:t}){const r=`${e}px`,a=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${a})`}const Fa=f.types.model("LayoutsRenderModel",{list:f.types.array(mi),currentBreakpoint:f.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return f.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return gc(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,a)=>r.min-a.min).forEach((r,a)=>{a!==t.length-1&&(r.max=t[a+1].min)}),t.forEach(r=>{r.text=gc(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const r=new Set(t);return this.currentLayoutSet.list.filter(o=>r.has(o.panelID))},gridLayouts(t){const r=new Set(t),a={};return e.list.forEach(o=>{a[o.id]=o.list.filter(l=>r.has(l.panelID)).map(l=>l.layoutProperies)}),a},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){f.addDisposer(e,G.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),fc=wi.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!f.getParent(e,2).findByKey(t)}})),Qa=f.types.model("SQLSnippetsRenderModel",{current:f.types.optional(f.types.array(fc),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(o=>o.json)},version:lt}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Gt("SQL Snippets",r)}}));function bc(e){return{current:e}}function en(e,t,r,a){return e.reduce((o,l)=>{try{o[l[t]]=mr(l[r],a)}catch(i){o[l[t]]=i.message}return o},{})}class yc{constructor(t){V(this,"origin");V(this,"copy");this.origin=t,this.copy=f.clone(t),G.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!y.isEqual(f.getSnapshot(this.origin),f.getSnapshot(this.copy))}commit(){f.applySnapshot(this.origin,f.getSnapshot(this.copy))}reset(){f.applySnapshot(this.copy,f.getSnapshot(this.origin))}update(t){f.applySnapshot(this.copy,t)}}const vc=e=>new yc(e),w2=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(s.Tooltip,{color:"white",label:n.jsx($t,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n.jsx(s.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(T.IconInfoCircle,{size:16,color:"gray"})})}),x2=k.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:a,...o},value:l,onChange:i})=>n.jsxs(s.Box,{children:[n.jsx(s.Text,{size:"sm",children:" "}),n.jsx(s.Checkbox,{label:n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(s.Box,{sx:{flexGrow:1},children:e}),n.jsx(w2,{description:r,isDescriptionEmpty:a})]}),checked:l||!1,onChange:c=>i(c.currentTarget.checked),...o,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),C2=({value:e,onChange:t,onClose:r,max_days:a,allowSingleDateInRange:o})=>{const l=e.value,[i,c]=l,d=h.useMemo(()=>i||new Date,[i]),u=h.useMemo(()=>{if(i&&!c)return i},[i,c]),p=h.useMemo(()=>{if(i&&!c&&a>0)return M(i).add(a-1,"days").toDate()},[i,c,a]),g=b=>{const[_,w]=b;t({value:b,shortcut:null}),_&&w&&r()};return n.jsx(wt.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:l,onChange:g,onNextMonth:console.log,minDate:u,maxDate:p,allowSingleDateInRange:o})},S2=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=h.useMemo(()=>!t&&!e?Number.NaN:M(t).diff(M(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const o=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:o,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},T2=({max_days:e})=>{const{t}=m.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(s.Divider,{variant:"dashed",my:10})]}):null},k2=({onChange:e,onClose:t})=>{const{t:r,i18n:a}=m.useTranslation(),o=c=>()=>{const d=c();e(d),t()},l=h.useMemo(()=>Si(),[]),i=a.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(l).map(([c,d])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:r(`filter.widget.date_range.shortcut.${c}.label`)})}),d.map(({key:u,value:p,getRange:g})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:o(g),children:r(`filter.widget.date_range.shortcut.${c}.${i?"full.":""}${u}`)})},u))]},c))})})]})},_c=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),D2=({label:e,required:t,value:r,onChange:a,max_days:o,allowSingleDateInRange:l,inputFormat:i,disabled:c})=>{const{t:d}=m.useTranslation(),[u,{open:p,close:g}]=te.useDisclosure(!1),[b,_]=r.value,w=b?M(b).format(i):"",x=_?M(_).format(i):"";return n.jsxs(s.Popover,{opened:u,onClose:g,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:d("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:w,onFocus:p,styles:_c(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(s.TextInput,{label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(S2,{begin:b,end:_})}),leftSection:n.jsx(T.IconMinus,{size:16}),placeholder:d("filter.widget.date_range.end_date"),readOnly:!0,disabled:!b||c,value:x,onFocus:p,styles:_c(u),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(T2,{max_days:o}),n.jsx(C2,{value:r,onChange:a,onClose:g,allowSingleDateInRange:l,max_days:o}),n.jsx(k2,{onChange:a,onClose:g})]})]})},mc={value:[null,null],shortcut:null},ja=e=>{const t=Pn(e.shortcut);return t||(Array.isArray(e.value)?e:mc)},z2=e=>h.useMemo(()=>ja(e),[e]),wc=k.observer(({label:e,config:t,value:r=mc,onChange:a,disabled:o})=>{const{inputFormat:l,required:i,max_days:c,allowSingleDateInRange:d}=t,u=z2(r);return n.jsx(D2,{label:e,value:u,onChange:a,inputFormat:l,allowSingleDateInRange:d,max_days:c,required:i,disabled:o})}),M2=pt.createStyles((e,{radius:t=4,name:r,...a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...a,"&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}},".rc-select-item-option-state-icon":{lineHeight:"20px"}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),I2={root:{cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},V2=({disabled:e,radius:t,style:r,label:a,value:o,onChange:l,options:i,errorMessage:c,required:d})=>{const{t:u}=m.useTranslation(),{classes:p,cx:g}=M2({radius:t,name:"MultiSelectWidget"}),[b,_]=h.useState(!1),w=N=>{_(N)},x=b&&(o==null?void 0:o.length)>0,[S,D]=h.useState(""),z=h.useMemo(()=>{if(!S)return i;const N=S.toLowerCase(),oe=be=>{var ct;return((ct=be.description)==null?void 0:ct.toLowerCase().includes(N))||be.label.toLowerCase().includes(N)};return i.filter(oe)},[S,i]),I=h.useMemo(()=>new Set(i.map(N=>N.value)),[i]),A=h.useMemo(()=>new Set(o),[o]),E=h.useMemo(()=>A.size!==I.size?!1:Array.from(I).every(N=>A.has(N)),[A,I]),U=()=>{if(E){l([]);return}const N=Array.from(I);l(N)};return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:p.label,size:"sm",children:[a,d&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),x&&n.jsx(s.Tooltip,{label:u("filter.widget.common.x_selected",{count:o.length}),children:n.jsx(s.Badge,{variant:"light",children:o.length})})]}),n.jsx(qs,{disabled:e,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(s.CloseButton,{size:"sm"}),value:o,onChange:l,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(Ca,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:N=>u("filter.widget.common.x_selected",{count:N.length}),searchValue:S,onSearch:D,filterOption:!1,dropdownRender:N=>n.jsxs(n.Fragment,{children:[I.size>0&&!S&&n.jsx(s.Group,{px:"xs",py:"xs",onClick:U,styles:I2,children:n.jsx(s.Checkbox,{size:"xs",checked:E,onChange:y.noop,label:u("common.actions.select_all")})}),n.jsx(s.Divider,{}),N]}),children:z.map(N=>n.jsxs(qs.Option,{title:N.label,children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},P2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const o=H(),l=!!t.options_query_id,{state:i,error:c}=o.getDataStuffByID(t.options_query_id),d=i==="loading",u=t.min_width?t.min_width:"200px",p=l?d:!1,g=h.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),b=_=>a(_,!1);return n.jsx(V2,{label:e,options:t.options,style:{minWidth:"160px",width:u,maxWidth:p?u:"unset",borderColor:"#e9ecef"},disabled:p,value:[...g],onChange:b,errorMessage:c,required:t.required})}),$2=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx("div",{...t,children:n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:r}),n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:a})]})})})},A2=k.observer(({label:e,config:t,value:r,onChange:a})=>{const{t:o}=m.useTranslation(),l=H(),i=!!t.options_query_id,{state:c,error:d}=l.getDataStuffByID(t.options_query_id),u=c==="loading",p=h.useCallback((g,b)=>{g&&a(g,!1)},[a]);return n.jsx(s.Select,{label:e,data:t.options,disabled:i?u:!1,value:r,onChange:p,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},renderOption:$2,searchable:!d,nothingFoundMessage:d||o("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function E2({label:e,config:t,value:r,onChange:a}){return n.jsx(s.TextInput,{label:e,value:r||"",onChange:o=>a(o.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const B2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M().add(365,"days").toDate(),[]);return n.jsx(wt.DatePicker,{defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,onNextMonth:console.log,minDate:i,maxDate:c,allowSingleDateInRange:!0})};function Wa(e,t){if(!e)return null;const r=M(e);switch(t){case"day":case"week":case"month":case"quarter":return r.startOf(t);case"bi-week":return r.startOf("week").subtract(1,"week");default:throw new Error(`[merico-date-range] unexpected date-range step: ${t}`)}}function Ua(e,t){if(!e)return null;const r=M(e);switch(t){case"day":case"week":case"month":case"quarter":return r.endOf(t);case"bi-week":return r.endOf("week");default:throw new Error(`[merico-date-range] unexpected date-range step: ${t}`)}}function q2(e,t){if(!e)return null;const r=Wa(e,t),a=Ua(e,t);return{start:r,end:a}}function O2(e,t,r,a){if(!t)return!1;const[o]=r,l=Wa(t,a),i=Ua(t,a),c=M(e).isBefore(i);return o?M(e).isAfter(o)&&c:M(e).isAfter(l)&&c}function L2(e,t,r){if(!t)return!1;const[a]=r;return a?e.isSame(a,"day"):e.isSame(t,"day")}function N2(e,t){return t?e.isSame(t,"day"):!1}function G2(e,t){const[r,a]=t;if(!r||!a)return{inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1};const o=e.isSame(r,"day"),l=e.isSame(a,"day");return{inRange:e.isBetween(r,a,"day","[]"),firstInRange:o,lastInRange:l,selected:o||l}}const F2=(e,t,r)=>{const a=e.step,[o,l]=h.useState(null),[i,c]=h.useState(e.value),d=(_,w)=>{if(!_||!w)return;const[x,S]=i,D=_.toDate(),z=w.toDate();if(x===null){c([D,null]);return}const A=D.getTime()<x.getTime()?[D,S]:[x,z];c(A),t(A)};h.useEffect(()=>{c(e.value)},[e]),h.useEffect(()=>{c([null,null])},[r]);const u=h.useMemo(()=>r?null:i[0]?M(i[0]):null,[i,r]),p=h.useMemo(()=>r?null:i[0]?M(i[0]).add(365,"days"):null,[i,r]),g=h.useCallback(_=>{const w=M(_);return G2(w,e.value)},[r,e.value]),b=h.useCallback(_=>{const w=M(_),x=u&&p&&(w.isBefore(u)||w.isAfter(p)),S=!o&&i[0]?i[0]:o,D=q2(S,a);if(!D)return{onMouseEnter:()=>l(_),onMouseLeave:()=>l(null),inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1,disabled:x};if(w.format("MM-DD"),x)return{onMouseEnter:y.noop,onMouseLeave:y.noop,inRange:!1,firstInRange:!1,lastInRange:!1,selected:!1,disabled:!0};const{start:z,end:I}=D,A=L2(w,z,i),E=N2(w,I),U=O2(_,S,i,a),N=U&&A,oe=U&&E,be=w.isBefore(u)||w.isAfter(p);return{onMouseEnter:()=>l(_),onMouseLeave:()=>l(null),inRange:U,firstInRange:N,lastInRange:oe,selected:A||E,onClick:()=>d(z,I),disabled:be}},[o,t,a,r,u,p,i]);return{getDayProps:r?g:b}},Q2=({value:e,onChange:t,handleRangeChange:r})=>{const[a,o]=h.useState(!0),l=e.value,[i,c]=l,d=h.useMemo(()=>i||new Date,[i]),{getDayProps:u}=F2(e,r,a),p=()=>{o(!1)},g=()=>{o(!!i&&!!c)};return n.jsx(wt.Calendar,{defaultDate:d,numberOfColumns:2,withCellSpacing:!1,getDayProps:u,onMouseEnter:p,onMouseLeave:g,hideOutsideDates:!0})},j2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M().add(365,"days").toDate(),[]);return n.jsx(wt.MonthPicker,{defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,minDate:i,maxDate:c,allowSingleDateInRange:!0})},qn={calendar_header:"_calendar_header_xr0sl_1",months_list:"_months_list_xr0sl_5",months_list_row:"_months_list_row_xr0sl_12",months_list_control:"_months_list_control_xr0sl_25"},W2=({value:e,handleRangeChange:t})=>{const r=e.value,[a,o]=r,l=h.useMemo(()=>a||new Date,[a]),i=h.useMemo(()=>{if(a&&!o)return a},[a,o]),c=h.useMemo(()=>M(a).add(365,"days").subtract(1,"second").toDate(),[a]),d=h.useMemo(()=>o?M(o):null,[o]),u=h.useCallback(p=>d&&M(p).isSame(d,"quarter")?{lastInRange:!0,selected:!0}:{},[d]);return n.jsx(wt.MonthPicker,{classNames:{calendarHeader:qn.calendar_header,monthsList:qn.months_list,monthsListRow:qn.months_list_row,monthsListControl:qn.months_list_control},defaultDate:l,numberOfColumns:2,type:"range",value:r,onChange:t,minDate:i,maxDate:c,allowSingleDateInRange:!0,maxLevel:"year",monthsListFormat:"Q",getMonthControlProps:u})},U2=({value:e,onChange:t,onClose:r})=>{const a=l=>{const[i,c]=l,d=Wa(i,e.step),u=Ua(c,e.step);t([(d==null?void 0:d.toDate())??null,(u==null?void 0:u.toDate())??null]),i&&c&&r()},o=e.step;return o==="day"?n.jsx(B2,{value:e,handleRangeChange:a}):o==="week"||o==="bi-week"?n.jsx(Q2,{value:e,onChange:t,handleRangeChange:a}):o==="month"?n.jsx(j2,{value:e,handleRangeChange:a}):o==="quarter"?n.jsx(W2,{value:e,handleRangeChange:a}):`错误的步长:${o}`},K2=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=h.useMemo(()=>!t&&!e?Number.NaN:M(t).diff(M(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const o=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:o,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},Ka={begin:"_begin_1cder_1",end:"_end_1cder_27",step:"_step_1cder_52"},xc=({label:e,value:t,onChange:r,className:a})=>{const{t:o,i18n:l}=m.useTranslation(),i=h.useMemo(()=>[{label:o("filter.widget.date_range.step.day"),value:"day"},{label:o("filter.widget.date_range.step.week"),value:"week"},{label:o("filter.widget.date_range.step.bi_week"),value:"bi-week"},{label:o("filter.widget.date_range.step.month"),value:"month"},{label:o("filter.widget.date_range.step.quarter"),value:"quarter"}],[o]),c=d=>{d&&r(d)};return n.jsx(s.Select,{className:a,label:e,data:i,value:t,onChange:c})},Y2=({onChange:e,step:t,onClose:r})=>{const{t:a,i18n:o}=m.useTranslation(),l=d=>()=>{const u=d(t);e(u),r()},i=h.useMemo(()=>Ni(t),[t]),c=o.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(i).map(([d,u])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{w:80,children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:a(`filter.widget.date_range.shortcut.${d}.label`)})}),u.map(({key:p,value:g,getRange:b})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:l(b),children:a(`filter.widget.date_range.shortcut.${d}.${c?"full.":""}${p}`)})},p))]},d))})})]})},Cc=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),X2=({label:e,required:t,value:r,onChange:a,inputFormat:o,disabled:l})=>{const{t:i}=m.useTranslation(),[c,{open:d,close:u}]=te.useDisclosure(!1),[p,g]=r.value,b=p?M(p).format(o):"",_=g?M(g).format(o):"",w=S=>{a({value:Ht(S[0],S[1],r.step),shortcut:null,step:r.step})},x=S=>{if(r.shortcut)return a(Rt(r.shortcut,S));a({value:Ht(r.value[0],r.value[1],S),shortcut:r.shortcut,step:S})};return n.jsxs(s.Popover,{opened:c,onClose:u,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",align:"text-anchor",wrap:"nowrap",gap:0,sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:i("filter.widget.date_range.start_date"),readOnly:!0,disabled:l,value:b,onFocus:d,styles:Cc(c),className:Ka.begin})}),n.jsx(s.TextInput,{label:n.jsx(s.Box,{children:" "}),leftSection:n.jsx(T.IconMinus,{size:16,onClick:d}),placeholder:i("filter.widget.date_range.end_date"),readOnly:!0,disabled:l,value:_,onFocus:d,styles:Cc(c),className:Ka.end}),n.jsx(xc,{className:Ka.step,value:r.step,onChange:x,label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(K2,{begin:p,end:g})})})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(U2,{value:r,onChange:w,onClose:u}),n.jsx(Y2,{onChange:a,step:r.step,onClose:u})]})]})},Sc={value:[null,null],shortcut:null,step:"day"},Z2=e=>{const t=Rt(e.shortcut,e.step);return t||(Array.isArray(e.value)?e:Sc)},J2=e=>h.useMemo(()=>Z2(e),[e]),H2=k.observer(({label:e,config:t,value:r=Sc,onChange:a,disabled:o})=>{const{inputFormat:l,required:i}=t,c=J2(r);return n.jsx(X2,{label:e,value:c,onChange:a,inputFormat:l,required:i,disabled:o})}),R2=k.observer(({filter:{type:e,config:t,key:r,...a},formFieldProps:o})=>{switch(e){case P.Select:return n.jsx(A2,{...a,...o,config:t});case P.MultiSelect:return n.jsx(P2,{...a,...o,config:t});case P.TreeSelect:return n.jsx(HT,{...a,...o,config:t});case P.TreeSingleSelect:return n.jsx(n2,{...a,...o,config:t});case P.TextInput:return n.jsx(E2,{...a,...o,config:t});case P.DateRange:return n.jsx(wc,{...a,...o,config:t});case P.MericoDateRange:return n.jsx(H2,{...a,...o,config:t});case P.Checkbox:return n.jsx(x2,{...a,...o,config:t});default:return null}}),ek=k.observer(h.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(ne,{children:n.jsx(R2,{filter:e,formFieldProps:t})})}))),tk=({disabled:e,onSubmit:t,stale:r})=>{const{t:a}=m.useTranslation(),{renderSearchButton:o}=Ks();return o?o({disabled:e,onSubmit:t,stale:r}):n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{color:"blue",size:"sm",onClick:()=>t(),disabled:e,"data-stale":r||void 0,children:a("common.actions.search")}),n.jsxs(s.Menu,{trigger:"hover",disabled:e,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{disabled:e,color:"blue",px:"xs","data-stale":r||void 0,style:{borderLeft:`1px solid ${e?"white":"var(--mantine-color-gray-4)"}`},children:n.jsx(T.IconChevronDown,{size:16})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconRefresh,{size:14}),disabled:e,onClick:()=>t({force:!0}),children:a("common.actions.reload")})})]})]})};function nk(e){const t=F();h.useEffect(()=>{var r,a;(a=(r=t.filters).updatePreviewValues)==null||a.call(r,e)},[e])}const Ya="N/A";function rk(){const e=Wt(),[t,r]=h.useState([]);return h.useEffect(()=>{const a=G.computed(()=>e.content.views.visibleViews.map(d=>{var u;return d.type===B.Tabs?(u=d.tabView)==null?void 0:u.view_id:d.id}).filter(Boolean).flatMap(d=>e.content.filters.visibleInView(d)).filter(Boolean).map(d=>ak(d)),{equals:G.comparer.structural}),o=G.autorun(()=>{r(a.get())});return()=>o()},[e]),t}function ak(e){switch(e.type){case P.Select:case P.MultiSelect:case P.TreeSelect:case P.TreeSingleSelect:return{label:e.label,value:sk(e.config,e.value)};case P.TextInput:return{label:e.label,value:e.value};case P.DateRange:return{label:e.label,value:ok(e.config,e.value)};case P.MericoDateRange:return{label:e.label,value:lk(e.config,e.value)};case P.Checkbox:return{label:e.label,value:ik(e.value)};default:return{label:e.label,value:e.value}}}function sk(e,t){const r=new Set;return Array.isArray(t)?t.forEach(a=>r.add(a)):r.add(t),r.size===0?Ya:e.options.filter(a=>r.has(a.value)).map(a=>a.label).join(", ")}function r6(e){return e}function ok(e,t){const a=ja(t).value.filter(o=>!!o).map(o=>M(o).format(e.inputFormat));return a.length===0?Ya:a.join(" - ")}function lk(e,t){const a=ja(t).value.filter(o=>!!o).map(o=>M(o).format(e.inputFormat));return a.length===0?Ya:a.join(" - ")}function ik(e){return e?"✔️":"❌"}const ck=({opened:e,toggle:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(T.IconChevronsUp,{size:14}):n.jsx(T.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},Tc=k.observer(function({view:t}){const[r,{toggle:a}]=te.useDisclosure(!0),o=H(),{control:l,handleSubmit:i,reset:c,formState:{isDirty:d}}=v.useForm({defaultValues:o.filters.values,reValidateMode:"onBlur"}),u=v.useWatch({control:l});h.useEffect(()=>{c(o.filters.values)},[o.filters.values,c]),nk(u);const p=o.filters.visibleInView(t.id),g=h.useMemo(()=>p.every(S=>S.should_auto_submit),[p]),b=h.useMemo(()=>p.filter(S=>y.get(S,"config.required",!1)),[p]),_=h.useMemo(()=>b.length===0?!1:b.some(S=>!S.requiredAndPass(u[S.key])),[u,b]),w=(S,D)=>(z,I)=>{D(z),(S.should_auto_submit||I)&&o.filters.setValueByKey(S.key,z)},x=h.useCallback(S=>{const D=y.get(S,"force",!1);i(o.filters.setValues)(),D&&o.queries.forceReloadVisibleQueries()},[i,o.filters.setValues]);return p.length===0?null:n.jsxs("form",{children:[n.jsx(ck,{opened:r,toggle:a}),n.jsx(s.Collapse,{in:r,children:n.jsxs(s.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:g?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(s.Group,{align:"flex-start",children:p.map(S=>n.jsx(v.Controller,{name:S.key,control:l,render:({field:D})=>n.jsx(ek,{filter:S,value:D.value,onChange:w(S,D.onChange)})},S.id))}),!g&&n.jsx(s.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(tk,{disabled:_,onSubmit:x,stale:d})})]})})]})}),kc={withInteraction:!0,withAddon:!0,withPanelTitle:!0},Dc=h.createContext(kc);function dk({children:e,...t}){const r=y.defaults({},t,kc);return n.jsx(Dc.Provider,{value:r,children:e})}function On(){return h.useContext(Dc)}function uk(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const pk=k.observer(()=>{const e=H(),{panel:t}=re(),r=h.useMemo(()=>ft(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx($t,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardStateValues:e.dashboardStateValues,variableAggValueMap:t.variableAggValueMap})}),Xa=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1),{panel:a}=re();return uk(a.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:()=>r(!1),title:a.title.show?a.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(pk,{})}),n.jsx(s.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(o=>!o),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(T.IconInfoCircle,{size:20})})})]})}),a6="",hk=k.observer(function(){const{panel:t}=re(),{name:r,title:a}=t;return a.show?n.jsx(s.Group,{"data-testid":"panel-title-bar",grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null}),Za=h.createContext({onScreenshot:y.noop});function gk(e){const t=h.useRef(null),{onScreenshot:r}=h.useContext(Za);return{ref:t,downloadPanelScreenshot:()=>{const o=t.current;if(!o)return;const l=o.offsetWidth*2,i=o.offsetHeight*2;As.toCanvas(t.current,{bgcolor:"white",width:l,height:i,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(c=>(r(c),c)).then(c=>new Promise(d=>{c.toBlob(u=>{d(u)})})).then(c=>{window.saveAs(c,`${e.name?e.name:e.viz.type}.png`)})}}}var zc=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(zc||{}),Ln=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(Ln||{});class fk{constructor(t){V(this,"vizInstance");V(this,"operationManager");V(this,"triggerManager");V(this,"vizManager");V(this,"runningMigration");V(this,"panelModel");V(this,"status","notStarted");this.panelModel=t.getRequired(ee.instanceScope.panelModel),this.vizInstance=t.getRequired(ee.instanceScope.vizInstance),this.operationManager=t.getRequired(ee.instanceScope.operationManager),this.triggerManager=t.getRequired(ee.instanceScope.triggerManager),this.vizManager=t.getRequired(ee.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}class bk{getTriggerSchemaList(){return[]}getTriggerList(){return Promise.resolve([])}removeTrigger(){return Promise.resolve()}createOrGetTrigger(){return Promise.resolve(Mc)}retrieveTrigger(){return Promise.resolve(Mc)}watchTriggerSnapshotList(){return()=>{}}needMigration(){return Promise.resolve(!1)}runMigration(){return Promise.resolve()}}class yk{constructor(){V(this,"id","");V(this,"schemaRef","");V(this,"triggerData",new ln({}))}}const Mc=new yk;class vk{getOperationSchemaList(){return[]}getOperationList(){return Promise.resolve([])}removeOperation(){return Promise.resolve()}createOrGetOperation(){return Promise.resolve(Ic)}runOperation(){return Promise.resolve()}retrieveTrigger(){return Promise.resolve(Ic)}runMigration(){return Promise.resolve()}needMigration(){return Promise.resolve(!1)}}class _k{constructor(){V(this,"id","");V(this,"schemaRef","");V(this,"operationData",new ln({}))}}const Ic=new _k,Wn=class Wn{constructor(){V(this,"triggerManager",new bk);V(this,"operationManager",new vk)}getInteractionList(){return Promise.resolve([])}addInteraction(){return Promise.resolve()}removeInteraction(){return Promise.resolve()}runInteraction(){return Promise.resolve()}};V(Wn,"instance",new Wn);let Ja=Wn;function Vc(e,t=!0){const{panel:r}=re();return h.useCallback(a=>{const o=a.getRequired(ee.vizManager),l=o.resolveComponent(e.viz.type);return a.createScoped().provideFactory(ee.instanceScope.vizInstance,()=>o.getOrCreateInstance(e)).provideFactory(ee.instanceScope.interactionManager,i=>{const c=i.getRequired(ee.instanceScope.vizInstance);return t?new Lo(c,l,kr):new Ja}).provideFactory(ee.instanceScope.operationManager,i=>i.getRequired(ee.instanceScope.interactionManager).operationManager).provideFactory(ee.instanceScope.triggerManager,i=>i.getRequired(ee.instanceScope.interactionManager).triggerManager).provideValue(ee.instanceScope.panelModel,r).provideFactory(ee.instanceScope.migrator,i=>new fk(i))},[e.viz.type,e.viz.conf,t])}function Pc(e){const[t,r]=h.useState(!1),a=Xt().getRequired(ee.instanceScope.migrator);return O.useAsyncEffect(async()=>{const o=a.status===Ln.notStarted;r(a.status===Ln.done),a.status===Ln.notStarted&&a.runMigration().then(l=>{l===zc.migrated&&o&&(e==null||e())}).finally(()=>{r(!0)})},[a]),t}function $c(e,t){const r=Xt().getRequired(ee.instanceScope.vizInstance);return O.useAsyncEffect(async()=>{y.isEqual(await r.instanceData.getItem(null),t.viz.conf)||await r.instanceData.setItem(null,t.viz.conf)},[r,t.viz.conf]),h.useEffect(()=>r.instanceData.watchItem(null,a=>{e(a)}),[e,t.viz.type]),r}function mk({setVizConf:e,...t}){const{panel:r}=t,a=$c(e,r),o=Pc(()=>{Fe.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return O.useAsyncEffect(async()=>{await a.instanceData.setItem(null,r.viz.conf)},[a,r.viz.type]),o?n.jsx(ju,{...t}):n.jsx(s.Text,{size:"sm",children:"Checking update..."})}function wk(e){const{panel:t,setVizConf:r}=e;$c(r,t);const{inEditMode:a}=h.useContext(St);return Pc(()=>{a&&Fe.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(Qu,{...e}):n.jsx(s.Text,{size:"sm",children:"Checking update"})}const s6="";function xk(e,t){const{vizManager:r}=h.useContext(ot),{panel:{viz:a,title:o,id:l,name:i,description:c,queryIDs:d,variables:u}}=re(),p={id:l,name:i,title:o,description:c,queryIDs:d,viz:a},{withInteraction:g}=On(),b=Vc(p,g);try{return r.resolveComponent(a.type),n.jsxs(vn,{configure:b,children:[n.jsx(wk,{setVizConf:a.setConf,panel:p,measure:t,data:e,variables:u,vizManager:r}),n.jsx(Ec,{})]})}catch(_){return console.info(y.get(_,"message")),null}}const Ac=k.observer(function({data:t}){const{ref:r,width:a,height:o}=te.useElementSize(),l=xk(t,{w:a,h:o}),i=a>0&&o>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(s.Box,{sx:{width:a,height:o,overflow:"hidden"},children:i&&n.jsx(ne,{children:l})})})});function Ck(e){const{setEchartsOptions:t}=re();h.useEffect(()=>{const r=o=>{t(o)},a=e.messageChannels.getChannel("viz");return a.on("rendered",r),()=>{a.off("rendered",r)}},[e.messageChannels])}const Ec=()=>{const e=Xt(),t=e.getRequired(ee.instanceScope.vizInstance);Ck(t);const{inEditMode:r}=h.useContext(St),a=e.getRequired(ee.panelAddonManager),{withAddon:o}=On(),l=Hu();return!l||!o?null:Au.createPortal(n.jsx(n.Fragment,{children:a.createPanelAddonNode({viz:t,isInEditMode:r})}),l,"addon")},Bc=k.observer(({panel:e})=>n.jsxs(s.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(s.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(s.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),Ha=k.observer(({panel:e})=>n.jsxs(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(s.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(Bc,{panel:e}),e.canRenderViz&&n.jsx(Ac,{data:e.data})]}));function Sk(e){return!["richText","button","vizDashboardState"].includes(e)}const Tk=k.observer(({children:e})=>n.jsx(n.Fragment,{children:n.jsxs(s.Menu,{withinPortal:!0,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle",color:"black",size:"md",style:{zIndex:410},children:n.jsx(T.IconDotsVertical,{size:14,style:{width:"70%",height:"70%"}})})}),n.jsx(s.Menu.Dropdown,{children:e})]})})),kk=k.observer(({dropdownContent:e,showDropdownMenu:t,panelAddonSlotId:r})=>{const{withAddon:a,withPanelTitle:o}=On(),l=o&&t;return n.jsxs(s.Group,{className:"panel-top-right-actions",gap:"xs",wrap:"nowrap",justify:"flex-end",pos:"absolute",sx:{zIndex:410},children:[a&&r&&n.jsx("div",{id:r}),l&&e]})});function Dk(e){const t=h.useRef(null),r=h.useCallback(a=>{t.current=a},[]);return h.useEffect(()=>{t.current=null},[e]),{getEchartsOptions:()=>t.current,setEchartsOptions:r}}const zk={border:"1px solid #e9ecef"},Ra=k.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:a,downloadPanelScreenshot:o}=gk(e),{withAddon:l,withPanelTitle:i}=On(),c=l?`panel-addon-slot-${h.useId()}`:null,{getEchartsOptions:d,setEchartsOptions:u}=Dk(e.viz.type),{inEditMode:p}=h.useContext(St),g=p||Sk(e.viz.type);return n.jsx(tr,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:o,getEchartsOptions:d,setEchartsOptions:u},children:n.jsx(Fs,{addonSlotId:c||void 0,children:n.jsxs(s.Box,{id:e.id,"data-testid":"panel-root",className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:a,p:0,sx:{...zk,...t},children:[i&&n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Xa,{})}),n.jsx(hk,{})]}),n.jsx(kk,{dropdownContent:n.jsx(Tk,{children:r}),showDropdownMenu:g,panelAddonSlotId:c}),n.jsx(Ha,{panel:e})]})})})}),qc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:e("common.actions.download_data")})}),Oc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t,downloadPanelScreenshot:r}=re();return n.jsx(s.Menu.Item,{onClick:r,leftSection:n.jsx(T.IconCamera,{size:14}),children:e("common.actions.download_screenshot")})}),Mk=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.downloadSchema,leftSection:n.jsx(T.IconCode,{size:14}),children:e("common.actions.download_schema")})}),Ik={viewPanelInFullScreen:y.noop,inFullScreen:!1},es=h.createContext(Ik),Lc=k.observer(({view:e})=>{const{t}=m.useTranslation(),{panel:r}=re(),a=r.id,{viewPanelInFullScreen:o,inFullScreen:l}=h.useContext(es),i=h.useCallback(()=>{o(a)},[a,o]);return!l&&e.type!==B.Modal?n.jsx(s.Menu.Item,{onClick:i,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),disabled:!0,children:t("common.actions.enter_fullscreen")}):null}),Nc=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=re();return n.jsx(s.Menu.Item,{onClick:t.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:e("common.actions.refresh")})}),Vk=e=>{const{items:t}=lr();return h.useMemo(()=>[{order:10,render:()=>n.jsx(Nc,{},"refresh")},{order:100,render:()=>n.jsx(qc,{},"download-data")},{order:300,render:()=>n.jsx(Oc,{},"download-screenshot")},{order:400,render:()=>n.jsx(Lc,{view:e},"enter-full-screen")},...t].sort((a,o)=>a.order-o.order),[t])},Pk=k.observer(({view:e})=>{const{getEchartsOptions:t,panel:r}=re();return Vk(e).map(o=>o.render({getEchartsOptions:t,inEditMode:!1,panelID:r.id,viewID:e.id}))}),$k=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Panel"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconAppWindow,{size:14}),children:r("panel.label")})}),Ak=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Variables"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconVariable,{size:14}),children:r("panel.variable.labels")})}),Ek=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Visualization"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconChartHistogram,{size:14}),children:r("visualization.label")})}),Bk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Interactions"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconRoute,{size:14}),children:r("interactions.label")})}),qk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=De.useModals(),o=F(),l=()=>a.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.removePanelByID(e,t),confirmProps:{color:"red"},zIndex:320});return n.jsx(s.Menu.Item,{color:"red",onClick:l,leftSection:n.jsx(T.IconTrash,{size:14}),children:r("common.actions.delete")})}),Ok=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=F(),o=()=>{a.duplicatePanelByID(e,t)};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconCopy,{size:14}),children:r("common.actions.duplicate")})}),Lk=k.observer(({panelID:e,viewID:t})=>{const{t:r}=m.useTranslation(),a=j(),o=()=>{a.editor.open(["_VIEWS_",t,"_PANELS_",e,"_TABS_","Data"])};return n.jsx(s.Menu.Item,{onClick:o,leftSection:n.jsx(T.IconDatabase,{size:14}),children:r("data.label")})}),Nk=e=>{const{t}=m.useTranslation(),r=j(),{panel:a}=ae(),o=a.realQueryOptions,l=i=>{r.editor.open(["_QUERIES_",i])};return h.useMemo(()=>o.length===0?[]:[{order:500,render:()=>n.jsx(s.Divider,{label:t(o.length>1?"query.labels":"query.label"),labelPosition:"center"},"data-divider")},{order:501,render:()=>n.jsx(Lk,{panelID:a.id,viewID:e.id},"open-tab-data")},...o.map((i,c)=>({order:502+c,render:()=>n.jsx(s.Menu.Item,{onClick:()=>l(i.value),leftSection:n.jsx(T.IconDatabase,{size:14}),children:i.label},i.value)}))],[o])},Gk=e=>{const{t}=m.useTranslation(),{panel:r}=ae(),a=r.id,o=e.id,{items:l}=lr(),i=Nk(e);return h.useMemo(()=>[{order:10,render:()=>n.jsx(Nc,{},"refresh")},{order:100,render:()=>n.jsx(qc,{},"download-data")},{order:200,render:()=>n.jsx(Mk,{},"download-schema")},{order:300,render:()=>n.jsx(Oc,{},"download-screenshot")},{order:400,render:()=>n.jsx(Lc,{view:e},"enter-full-screen")},...i,{order:600,render:()=>n.jsx(s.Divider,{label:t("common.actions.edit"),labelPosition:"center"},"edit-divider")},{order:700,render:()=>n.jsx($k,{panelID:a,viewID:o},"open-tab-panel")},{order:800,render:()=>n.jsx(Ak,{panelID:a,viewID:o},"open-tab-variable")},{order:900,render:()=>n.jsx(Ek,{panelID:a,viewID:o},"open-tab-visualization")},{order:1e3,render:()=>n.jsx(Bk,{panelID:a,viewID:o},"open-tab-interaction")},{order:1100,render:()=>n.jsx(s.Divider,{label:t("common.actions.actions"),labelPosition:"center"},"actions-divider")},{order:1200,render:()=>n.jsx(Ok,{panelID:a,viewID:o},"duplicate")},{order:1300,render:()=>n.jsx(qk,{panelID:a,viewID:o},"delete-panel")},...l].sort((d,u)=>d.order-u.order),[i,l])},Fk=k.observer(({view:e})=>{const{getEchartsOptions:t,panel:r}=re();return Gk(e).map(o=>o.render({getEchartsOptions:t,inEditMode:!0,panelID:r.id,viewID:e.id}))}),Qk={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function jk(e){return e.style.border.enabled?{}:Qk}const Gc=k.observer(function({panel:t,view:r}){const a=jk(t);return n.jsx(Ra,{panel:t,panelStyle:a,dropdownContent:n.jsx(Fk,{view:r})})});function Wk(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const ts=k.observer(({panel:e,view:t})=>{const r=Wk(e);return n.jsx(Ra,{panel:e,panelStyle:r,dropdownContent:n.jsx(Pk,{view:t})})}),Uk={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Fc=k.observer(function({view:t,panel:r,exitFullScreen:a}){return n.jsx(s.Modal,{opened:!0,fullScreen:!0,onClose:a,title:n.jsx(s.Button,{color:"blue",size:"xs",onClick:a,leftSection:n.jsx(T.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:Uk,children:n.jsx(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(ts,{view:t,panel:r})})})});function Qc(e,t,r){const{panels:a}=H(),o=e.id==="Main",[l,i]=h.useState(()=>o&&a.findByID(t)?t:null),c=h.useCallback(g=>{i(g),o&&r(g)},[o,r]),d=h.useCallback(()=>{i(null),o&&r("")},[o,r]),u=l?a.findByID(l):null;return{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:!!u,fullScreenPanel:u}}function Kk(e){const t=Wt(),r=h.useMemo(()=>t.content.panels.findByID(e.panelId),[e.panelId]);return r?n.jsx(dk,{withAddon:!1,withPanelTitle:!1,withInteraction:!1,children:n.jsx(Ra,{panel:r,panelStyle:{}})}):null}const o6="",Yk=h.forwardRef(({title:e},t)=>n.jsx(s.Box,{ref:t,className:"react-grid-customDragHandle",title:e,children:n.jsx(s.ActionIcon,{variant:"transparent",color:"gray",children:n.jsx(T.IconMenu2,{size:16})})})),Xk=h.forwardRef(({handleAxis:e,...t},r)=>n.jsx(s.ActionIcon,{ref:r,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:n.jsx(T.IconChevronDownRight,{size:16})})),Zk=on.WidthProvider(on.Responsive),Jk=k.observer(({view:e,className:t="layout"})=>{const{t:r}=m.useTranslation(),o=F().layouts,l=o.items(e.panelIDs),i=o.gridLayouts(e.panelIDs),c=(p,g,b,_)=>{b.h<30&&(b.h=30,_.h=30),b.w<4&&(b.w=4,_.w=4)},d=(p,g,b)=>{console.log("🔴 onResizeStop",{layouts:p,oldItem:g,newItem:b}),o.updateCurrentLayoutItem(b)},u=(p,g,b)=>{console.log("🔴 onDragStop",{layouts:p,oldItem:g,newItem:b}),o.updateCurrentLayoutItems(p)};return n.jsx(Zk,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:o.cols,layouts:i,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(Xk,{}),onResize:c,breakpoints:o.breakpoints,onBreakpointChange:o.setCurrentBreakpoint,onResizeStop:d,onDragStop:u,width:o.currentLayoutPreviewWidth,children:l.map(p=>n.jsxs("div",{"data-grid":p.layoutProperies,className:"panel-grid-item",children:[n.jsx(Yk,{title:r("view.layout.drag_to_move")}),n.jsx(Gc,{view:e,panel:p.panel})]},p.id))})}),Hk=on.WidthProvider(on.Responsive),Rk=k.observer(({view:e,className:t="layout"})=>{const r=H(),a=r.layouts.items(e.panelIDs),o=r.layouts.gridLayouts(e.panelIDs);return n.jsx(Hk,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:o,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:a.map(l=>l.panel.usingGhostViz?null:n.jsx("div",{"data-grid":l.layoutProperies,className:"panel-grid-item",children:n.jsx(ts,{view:e,panel:l.panel})},l.id))})});function ns(e){const t=h.useRef(null),{onScreenshot:r}=h.useContext(Za);return{ref:t,downloadScreenshot:()=>{var l;const o=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");o&&e.downloadScreenshot(o,r)}}}const eD=k.observer(({downloadScreenshot:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:o}]=O.useBoolean(!1),l=Ws(),i=H(),c=()=>{const d=JSON.stringify(i.contentJSON,null,2),u=`${l.name}__${i.name}`;Gt(u,d)};return n.jsxs(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:a,onMouseLeave:o,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(T.IconShare3,{size:"1rem"})})})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconDownload,{size:14}),onClick:i.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),jc=k.observer(({children:e,view:t,sx:r={}})=>{const{ref:a,downloadScreenshot:o}=ns(t);return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{ref:a,pt:10,pb:10,sx:r,children:e}),n.jsx(eD,{downloadScreenshot:o})]})}),Wc=k.observer(({downloadScreenshot:e})=>n.jsx(s.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(T.IconCamera,{size:14})})),tD=k.observer(({children:e,view:t})=>{const r=H(),a=t.config,o=r.views.visibleViewIDs.includes(t.id),l=()=>r.views.rmVisibleViewID(t.id),{ref:i,downloadScreenshot:c}=ns(t);return n.jsx(s.Modal,{size:a.width,centered:!0,opened:o,onClose:l,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:a.custom_modal_title.value}),n.jsx(Wc,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:d=>{d.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:a.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:n.jsx(s.Box,{ref:i,children:e})})}),nD=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},rD=k.observer(({view:e})=>{const t=H(),r=e.config;return n.jsxs(s.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(s.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(a=>n.jsx(s.Tabs.Tab,{value:a.id,sx:nD(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabsInOrder.map(a=>{const o=t.views.findByID(a.view_id);return o?n.jsx(s.Tabs.Panel,{value:a.id,children:n.jsx(Nn,{view:o})},a.id):null})]})}),aD=k.observer(({view:e,children:t})=>{switch(e.type){case B.Modal:return n.jsx(tD,{view:e,children:t});case B.Tabs:return n.jsx(rD,{view:e});case B.Division:default:return n.jsx(jc,{view:e,children:t})}}),sD=k.observer(({children:e,view:t})=>{const a=F().layouts,[o,l]=te.useResizeObserver();return h.useEffect(()=>{a.setCurrentLayoutWrapperWidth(l.width)},[l.width]),n.jsx(s.Box,{sx:{height:"100%"},ref:o,children:n.jsx(s.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:a.currentLayoutPreviewWidth??"100%",transform:`scale(${a.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(jc,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Uc(e){return e.replace(/(vw|vh)/,"%")}const oD=k.observer(({children:e,view:t})=>{const r=t.config,{width:a,height:o}=h.useMemo(()=>({width:Uc(r.width),height:Uc(r.height)}),[r.width,r.height]),{ref:l,downloadScreenshot:i}=ns(t);return n.jsx(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(s.Modal,{size:r.width,opened:!0,onClose:y.noop,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:r.custom_modal_title.value}),n.jsx(Wc,{downloadScreenshot:i})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:a,height:o,maxHeight:o},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:n.jsx(s.Box,{ref:l,children:e})})})}),lD=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},iD=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},cD=k.observer(({view:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=F(),o=h.useMemo(()=>a.views.options.filter(u=>u.type===B.Division),[e.id,a.views.options]),l=e.config,i=u=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{l.removeTab(u),d&&e.setTab(d)},confirmProps:{color:"red"},zIndex:320}),c=l.tabs.length===0,d=l.tabsInOrder.length===0?void 0:l.tabsInOrder[0].id;return n.jsxs(s.Tabs,{className:"preview-view-tabs",variant:l.variant,orientation:l.orientation,value:e.tab||d,onChange:e.setTab,styles:lD(l),children:[n.jsxs(s.Tabs.List,{grow:l.grow,children:[l.tabsInOrder.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,sx:iD(u),children:u.name??u.id},u.id)),n.jsx(s.Tabs.Tab,{onClick:l.addTab,value:"add",className:"add-a-tab",children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})]}),l.tabsInOrder.map((u,p)=>{const g=a.views.findByID(u.view_id);return n.jsxs(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[n.jsxs(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(s.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:b=>u.setName(b.currentTarget.value)}),n.jsx(s.Select,{label:t("view.label"),value:u.view_id,onChange:u.setViewID,data:o}),n.jsx(s.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:b=>u.setOrder(b||0),min:0,max:1e3,step:1}),n.jsx(s.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:l.variant!=="default"}),g&&n.jsx(s.Button,{mt:20,variant:"gradient",leftSection:n.jsx(T.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>a.views.setIDOfVIE(g.id),children:t("view.component.tabs.tab.switch_to_view",{name:g.name})}),n.jsx(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>i(u.id),disabled:c,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),g&&n.jsx(Nn,{view:g})]},u.id)})]})}),dD=k.observer(({view:e,children:t})=>{switch(e.type){case B.Modal:return n.jsx(oD,{view:e,children:t});case B.Tabs:return n.jsx(cD,{view:e});case B.Division:default:return n.jsx(sD,{view:e,children:t})}}),Kc=k.observer(function({view:t}){const a=F().layouts.divisionPreviewScale!==1;return n.jsx(es.Provider,{value:{viewPanelInFullScreen:y.noop,inFullScreen:!1},children:n.jsx(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:a?"transparent":"#efefef"},children:n.jsx(dD,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Tc,{view:t})}),n.jsx(Jk,{view:t})]})})})})}),Nn=k.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:a}=Rs(),{viewPanelInFullScreen:o,exitFullScreen:l,inFullScreen:i,fullScreenPanel:c}=Qc(t,r,a);return n.jsx(es.Provider,{value:{viewPanelInFullScreen:o,inFullScreen:i},children:n.jsxs(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===B.Modal?"0 !important":"100%"},children:[i&&n.jsx(Fc,{view:t,panel:c,exitFullScreen:l}),n.jsx(aD,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[!i&&n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Tc,{view:t})}),!i&&n.jsx(Rk,{view:t})]})})]})})});var Yc=(e=>(e.Use="use",e.Edit="edit",e))(Yc||{});const uD={[B.Division]:"Division",[B.Tabs]:"Tabs",[B.Modal]:"Modal"},Xc={[B.Division]:"rgba(255, 0, 0, 0.2)",[B.Modal]:"rgba(0, 0, 0, 0.2)",[B.Tabs]:"rgba(255, 200, 100, 0.4)"},pD={[B.Division]:"#ff4000",[B.Modal]:"#000",[B.Tabs]:"#ffad18"},Zc=An.views(e=>({get usages(){return e.contentModel.findFilterUsage(e.id)}})).actions(e=>({}));function hD(e,t,r){f.addDisposer(e,f.addMiddleware(e,(a,o)=>{o(a,()=>{f.getType(a.context)===t&&a.type==="action"&&r(a.name,a.context)})}))}const Jc=f.types.compose("FiltersModel",qa,f.types.model({current:f.types.optional(f.types.array(Zc),[]),previewValues:f.types.optional(f.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===P.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key,widget:t.type}))},get sortedList(){return y.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(a=>a.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){hD(e.current,An,(r,a)=>{if(r==="setType"){const o=nc(a.config.default_value,a.config);e.setValueByKey(a.key,o),e.updatePreviewValues({...e.previewValues,[a.key]:o})}})}return{afterCreate(){t()}}}),Hc=Na.views(e=>({get canPreviewData(){return e.isTransform?e.config.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const a=new Set(e.run_by);r?a.add(t):a.delete(t),e.run_by.length=0,e.run_by.push(...a)}})),Rc=f.types.compose("QueriesModel",Ga,f.types.model({current:f.types.optional(f.types.array(Hc),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return y.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==W.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return y.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return y.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(a=>a.id===t);r&&(f.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(o=>{r.has(o.id)&&f.detach(o)});const a=[...e.current];y.remove(a,o=>r.has(o.id)),e.current=f.cast(a)},duplicateByID(t){const r=e.current.find(o=>o.id===t);if(!r){console.error(new Error(`[duplicate query] Can't find a query by id[${t}]`));return}const a=Te.v4();return e.current.push({...r.json,name:`${r.name} (${a})`,id:a}),a}})),ed=Qa.views(e=>({get sortedList(){return y.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return y.sortBy(t,r=>r.label.toLowerCase())},get usedFilterKeyMap(){const t=new Map;return e.current.forEach(r=>{const a=y.get(r,"value","");if(!a)return;const o=y.uniq(a.match(Et.filter)),l=new Set;o.forEach(i=>l.add(i)),t.set(r.key,l)}),t}})).actions(e=>({replace(t){e.current=f.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.keySet.has(a.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(a=>a.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(o=>{r.has(o.key)&&f.detach(o)});const a=[...e.current];y.remove(a,o=>r.has(o.key)),e.current=f.cast(a)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),gD=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),fD=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),bD=f.types.model({page:f.types.optional(f.types.number,1),limit:f.types.optional(f.types.number,20),data:f.types.optional(f.types.frozen(),[]),total:f.types.optional(f.types.number,0),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get keywords(){return f.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=f.getParent(e,1);return`${r}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:r}=e.keywords;return`
|
|
544
544
|
SELECT count(*) AS total
|
|
545
545
|
FROM ${r}.${t}
|
|
546
|
-
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),f.addDisposer(e,G.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),bD=f.types.model({data:f.types.optional(f.types.frozen(),{}),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),yD=f.types.model({tables:f.types.optional(bD,{}),columns:f.types.optional(hD,{}),tableData:f.types.optional(fD,{}),indexes:f.types.optional(gD,{}),table_schema:f.types.optional(f.types.string,""),table_name:f.types.optional(f.types.string,"")}).views(e=>({get dataSource(){return f.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get sqlDataSourceType(){return this.type},get reloadConditionString(){const t=this.type,{table_name:r,table_schema:a}=e;return`${t};${r};${a}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=f.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const a=yield*f.toGenerator($e.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=y.groupBy(a,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(a){if(!ke.isCancel(a)){e.tables.data={};const o=y.get(a,"message","unkown error");e.tables.error=y.get(a,"response.data.detail.message",o),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:f.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*f.toGenerator($e.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(a){if(ke.isCancel(a))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const o=y.get(a,"message","unkown error");e.columns.error=y.get(a,"response.data.detail.message",o),e.columns.state="error"}}}),loadIndexes:f.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*f.toGenerator($e.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(a){if(ke.isCancel(a))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const o=y.get(a,"message","unkown error");e.indexes.error=y.get(a,"response.data.detail.message",o),e.indexes.state="error"}}}),loadTableData:f.flow(function*(){var a;(a=e.controllers.tableData)==null||a.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*f.toGenerator($e.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:r.limit,offset:r.offset},{params:{query_type:"DATA"}}));const[{total:o}]=yield*f.toGenerator($e.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));r.total=Number(o),r.state="idle",r.error=null}catch(o){if(ke.isCancel(o))r.state="idle",r.error=null;else{r.data=[];const l=y.get(o,"message","unkown error");r.error=y.get(o,"response.data.detail.message",l),r.state="error"}}})}}).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),f.addDisposer(e,G.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}}));function vD(e,t){if(!t)throw new Error("Shouldnt run query without ID");if(e==="derived")return`/api/metric_management/derived_metric/${t}`;if(e==="combined")return`/api/metric_management/combined_metric/${t}`;if(e==="sql")return`/api/metric_management/sql_metric/${t}`;throw new Error(`Unexpected metric type[${e}]`)}const _D=f.types.model({data:f.types.optional(f.types.frozen(),null),variables:f.types.optional(f.types.frozen(),[]),filters:f.types.optional(f.types.frozen(),[]),groupBys:f.types.optional(f.types.frozen(),[]),trendingDateCol:f.types.optional(f.types.frozen(),null),supportTrending:f.types.optional(f.types.boolean,!1),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get hasData(){return e.data!==null},get mmInfo(){return f.getParent(e)},get metricID(){return this.mmInfo.metricID},get metric(){return this.mmInfo.metric},get metricType(){var t;return(t=this.metric)==null?void 0:t.type},get filterColOptions(){return v2(e.filters)},get groupByColOptions(){return _2(e.groupBys)},get flatGroupByColOptions(){const t=this.groupByColOptions,r=[];return t.forEach(({group:a,items:o})=>{r.push(...o)}),r},getGroupByOptions(t){const r=new Set(t);return this.flatGroupByColOptions.filter(a=>r.has(a.value))}})).actions(e=>({load:f.flow(function*(){var t;if(e.mmInfo.type===W.MericoMetricSystem&&!(!e.metricID||!e.metricType)){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=vD(e.metricType,e.metricID),a=fn(e.mmInfo.dataSource,{url:r,method:"GET",data:{key:e.mmInfo.key}}),o=yield*f.toGenerator($e.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(a),...e.mmInfo.additionalQueryInfo},e.controller.signal)),l=bn(e.mmInfo.dataSource,o),i=y.cloneDeep(l.data),{filters:c,groupBys:d,trendingDateCol:u,supportTrending:p,variables:g}=y2(l.data);e.data=i,e.variables=g,e.filters=c,e.groupBys=d,e.supportTrending=p,e.trendingDateCol=u,e.state="idle",e.error=null}catch(r){if(!ke.isCancel(r)){e.data=null;const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}})})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.metricID+e.metricType,e.load,{fireImmediately:!0,delay:0}))}})),mD=f.types.model({keyword:f.types.optional(f.types.string,""),data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0},get mmInfo(){return f.getParent(e)}})).actions(e=>({setKeyword(t){e.keyword=t}})).actions(e=>({load:f.flow(function*(){var t;if(e.mmInfo.type===W.MericoMetricSystem){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=fn(e.mmInfo.dataSource,{url:"/api/metric_management/search",method:"POST",data:{key:e.mmInfo.key},params:{search:e.keyword}}),a=yield*f.toGenerator($e.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(r),...e.mmInfo.additionalQueryInfo},e.controller.signal)),l=bn(e.mmInfo.dataSource,a).data;e.data=l,e.state="idle",e.error=null}catch(r){if(!ke.isCancel(r)){e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}})})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>`${e.mmInfo.type}:${e.keyword}`,e.load,{fireImmediately:!0,delay:0}))}})),wD=f.types.model({metrics:f.types.optional(mD,{}),metricDetail:f.types.optional(_D,{}),keyword:f.types.optional(f.types.string,""),metricID:f.types.optional(f.types.string,"")}).views(e=>({get rootModel(){return f.getRoot(e)},get contentModel(){return this.rootModel.content},get additionalQueryInfo(){return this.contentModel.getAdditionalQueryInfo("")},get dataSource(){return f.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get metric(){return e.metricID?e.metrics.data.find(t=>t.id===e.metricID)??null:null}})).actions(e=>({selectMetric(t){e.metricID=t}})),xD=f.types.compose("DataSourceModel",Ma,f.types.model({dbInfo:f.types.optional(yD,{}),mericoMetricInfo:f.types.optional(wD,{})})),CD=f.types.model("DataSourcesModel",{list:f.types.optional(f.types.array(xD),[])}).views(e=>({find({type:t,key:r}){return e.list.find(a=>a.key===r&&a.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function SD(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function TD(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function kD(e){return e.length===1&&e[0]==="_FILTERS_"}function DD(e){return e.length===2&&e[0]==="_FILTERS_"}function zD(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function MD(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function ID(e){return e.length===2&&e[0]==="_QUERIES_"}function VD(e){return e.length===1&&e[0]==="_QUERIES_"}function PD(e){return e.length===2&&e[0]==="_VIEWS_"}function rs(e){return e.length===6&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}function It(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function $D(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value,"_TABS_","Data"]:(console.error("[getPathFromOption] parentID is required"),null)}}const AD=f.types.model("EditorModel",{path:f.types.optional(f.types.frozen(),[]),settings_open:f.types.optional(f.types.boolean,!1)}).views(e=>({get isPanelPath(){return rs(e.path)},get panelTab(){return this.isPanelPath?y.get(e.path,5,"Data"):null},get navOptions(){const{content:t}=f.getRoot(e),{filters:r,views:a,sqlSnippets:o,queries:l}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:T.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:T.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:T.IconFilter,children:[It("_FILTERS_SETTINGS_"),...r.options,It("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:T.IconCopy,children:[It("_SQL_SNIPPETS_SETTINGS_"),...o.options,It("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:T.IconDatabase,children:[It("_QUERIES_SETTINGS_"),...l.options,It("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:T.IconBoxMultiple,children:[...a.editorOptions,It("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,r){return t.length===0?!1:rs(t)?t[3]===r.value:t[t.length-1]===r.value},isOptionOpened(t){const{path:r}=e;return r.length===0||!t.children||t.children.length===0?!1:r.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t},openAndSetPath(t){this.setPath(t),e.settings_open||(e.settings_open=!0)}})).actions(e=>({setPanelTab(t){if(!e.isPanelPath||e.panelTab===t||!t)return;const r=y.clone(e.path);r[5]=t,e.setPath(r)},open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const r=$D(t);r&&e.setPath(r)}})).views(e=>({get spotlightActionGroups(){const{content:t}=f.getRoot(e),{filters:r,views:a,sqlSnippets:o,queries:l}=t,i={group:"spotlight.main_group",actions:[{id:"query_variable.labels",title:"query_variable.labels",onClick:()=>e.openAndSetPath(["_QUERY_VARS_"]),iconKey:"query_variables"},{id:"mock_context.label",title:"mock_context.label",onClick:()=>e.openAndSetPath(["_MOCK_CONTEXT_"]),iconKey:"mock_context"},{id:"filter.labels",title:"filter.labels",onClick:()=>e.openAndSetPath(["_FILTERS_"]),iconKey:"filter"},{id:"sql_snippet.labels",title:"sql_snippet.labels",onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_"]),iconKey:"sql_snippet"},{id:"query.labels",title:"query.labels",onClick:()=>e.openAndSetPath(["_QUERIES_"]),iconKey:"query"}]},c={group:"filter.labels",actions:[]};r.options.forEach(g=>{c.actions.push({id:`_FILTERS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_FILTERS_",g.value]),iconKey:"filter"})});const d={group:"sql_snippet.labels",actions:[]};o.options.forEach(g=>{d.actions.push({id:`_SQL_SNIPPETS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_",g.value]),iconKey:"sql_snippet"})});const u={group:"query.labels",actions:[]};l.options.forEach(g=>{u.actions.push({id:`_QUERIES_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_QUERIES_",g.value]),iconKey:"query"})});const p=[i,c,d,u];return a.editorOptions.forEach(g=>{const b={group:g.label,actions:[]};b.actions.push({id:`_VIEWS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_VIEWS_",g.value]),iconKey:"view",group:g.label}),g.children.forEach(_=>{_._type!=="ACTION"&&b.actions.push({id:`_VIEWS_._PANELS_.${_.value}`,title:_.label,viz:_.viz,onClick:()=>e.openAndSetPath(["_VIEWS_",g.value,"_PANELS_",_.value,"_TABS_","Panel"]),iconKey:"panel",group:g.label})}),p.push(b)}),p}})),ED=f.types.compose("LayoutsModel",Ga,f.types.model({currentLayoutWrapperWidth:f.types.optional(f.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,r=e.currentLayoutWrapperWidth;return!t||!r||t<=r?1:r/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(r=>{r.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,r){e.list.forEach(a=>{const o=a.findByPanelID(t);if(!o){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${a.name}]`);return}a.list.push({...o,id:Te.v4(),panelID:r,y:1/0})})},removeByPanelID(t){e.list.forEach(r=>{r.removeByPanelID(t)})},removeByPanelIDs(t){e.list.forEach(r=>{r.removeByPanelIDs(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,r,a){const o=e.basisLayoutSet,l={id:t,name:r,breakpoint:a,list:o.json.list.map(i=>({...i,id:Te.v4()}))};e.list.push(l)},updateLayoutSetsInfo(t){const r=y.keyBy(e.list,"id");t.forEach(l=>{const i=r[l.id];if(i){i.setName(l.name),i.setBreakpoint(l.breakpoint),delete r[l.id];return}this.addALayoutSet(l.id,l.name,l.breakpoint)});const a=new Set(Object.keys(r)),o=a.size>0;a.forEach(l=>{const i=e.list.findIndex(c=>c.id===l);e.list.splice(i,1)}),o&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(r=>{e.currentLayoutSet.updateLayoutItem(r)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const r=e.list.findIndex(a=>a.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})}})),td=Aa.views(e=>({get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,r){const a=[...this.realQueryOptions];return t&&!a.find(o=>o.value===t)&&a.unshift({label:t,value:t,disabled:!0}),r&&a.unshift({label:"unset",value:"",disabled:!1}),a},get realVariableOptions(){const t=e.variableValueMap;return Object.entries(e.variableAggValueMap).map(([r,a])=>({label:r,value:r,formattedValue:t[r],aggValue:a,disabled:!1}))},variableOptions(t,r){const a=[...this.realVariableOptions];return t&&!a.find(o=>o.value===t)&&a.unshift({label:t,value:t,formattedValue:"",aggValue:"",disabled:!0}),r&&a.unshift({label:"unset",value:"",formattedValue:"",aggValue:"",disabled:!1}),a},explainDataKey(t){const{queryID:r,columnKey:a}=$(t),o=e.queries.find(l=>l.id===r);return o?{queryID:r,queryName:o.name,columnKey:a}:{queryID:r,queryName:null,columnKey:a}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,r){f.getRoot(e).content.views.findByID(t).removePanelID(e.id),f.getRoot(e).content.views.findByID(r).appendPanelID(e.id),f.getRoot(e).editor.setPath(["_VIEWS_",r,"_PANELS_",e.id])}})),nd=f.types.compose("PanelsModel",Ea,f.types.model({list:f.types.optional(f.types.array(td),[])})).views(e=>({get contentModel(){return f.getRoot(e).content},get options(){return e.list.map(t=>({label:t.name,value:t.id,viz_type:t.viz.type}))},editorOptions(t,r){const a=e.panelsByIDs(r);a.length!==r.length&&console.warn(`Unfulfilled panels for View[${t}]`);const o=a.map(i=>({label:i.name,value:i.id,_type:"panel",parentID:t,viz:ei[i.viz.type]})),l="_Add_A_PANEL_";return o.push({label:l,value:l,_type:"ACTION",_action_type:l,parentID:t,Icon:null,children:null}),o}})).actions(e=>({replace(t){e.list=f.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const r=e.list.findIndex(a=>a.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})},duplicateByID(t){const r=e.list.find(o=>o.id===t);if(!r){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const a=new Date().getTime().toString();return e.list.push({...r.json,id:a,title:{...r.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(r.id,a),a},replaceByIndex(t,r){e.list.splice(t,1,r)}})),BD=Pa.actions(e=>({getSchema(){const t=e.json,r=[],a=[];e.panels.forEach(i=>{const c=i.getSchema();r.push(c.panel),c.queries.length>0&&a.push(...c.queries)});const o=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:r,definition:{queries:y.uniqBy(a,i=>i.id)},layouts:o,version:lt}},downloadSchema(){if(e.type===B.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),r=e.name;Gt(r,t)}})),rd=f.types.compose("ViewsModel",$a,f.types.model({current:f.types.optional(f.types.array(BD),[]),idOfVIE:f.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get tabViewOptions(){return this.options.filter(t=>t.type===B.Tabs)},tabOptions(t){const r=e.current.find(a=>a.id===t&&a.type===B.Tabs&&a.tabs.length>0);return r?r.tabs.map(a=>({label:a.name,value:a.id})):[]},get editorOptions(){const t=f.getRoot(e).content.panels;return e.current.map(r=>({label:r.name,value:r.id,_type:"view",children:t.editorOptions(r.id,r.panelIDs)}))},get contentModel(){return f.getRoot(e).content}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},resetIDOfVIE(){this.setIDOfVIE(e.current[0].id)},replace(t){e.current.replace(t)},addANewView(t,r,a,o){e.current.push({id:t,name:r,type:a,config:o,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);if(r===-1)return;const a=e.current[r],o=e.contentModel.panels,l=e.contentModel.layouts;o.removeByIDs(a.panelIDs),l.removeByPanelIDs(a.panelIDs),e.current.splice(r,1),this.resetIDOfVIE()},replaceByIndex(t,r){e.current.splice(t,1,r)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,B.Division,B.Division,{_name:B.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.resetIDOfVIE())}}));function as(e){const t=e.length>0?[e[0].id]:[],r=e.length>0?e[0].id:"";return{current:e.map(o=>{const{_name:l=o.type}=o.config;return{...o,config:{...o.config,_name:l},panelIDs:o.panelIDs}}),visibleViewIDs:t,idOfVIE:r}}const qD=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:Jc,queries:Rc,sqlSnippets:ed,views:rd,panels:nd,layouts:ED,mock_context:da,origin:f.types.maybe(f.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get queriesChanged(){const t="queries.current",r=f.getSnapshot(y.get(e,t)).map(o=>y.pick(o,["id","name","key","type","run_by","pre_process","post_process","config"])),a=y.get(e.origin,t);return!y.isEqual(r,a)},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get viewsChanged(){const t="views.current";return!y.isEqual(e.views.json,y.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!y.isEqual(y.get(e,t),y.get(e.origin,t))},get context(){const t=f.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=f.getParent(e).globalSQLSnippets,r={context:this.context,filters:e.filters.valuesForPayload};return{...r,sql_snippets:en(e.sqlSnippets.current,"key","value",r),global_sql_snippets:en(t.list,"id","content",r)}},get payloadForViz(){return{context:this.context,filters:e.filters.valuesForPayload}},get dashboardState(){const{context:t,filters:r}=this.payloadForViz,a={context:{},filters:e.filters.keyStateItemMap(r)};return Object.entries(t).forEach(([o,l])=>{a.context[o]={key:o,type:"context",value:l}}),a},get dashboardStateValues(){return vr(this.payloadForSQL)},get dashboardStateVariableOptions(){if(!f.isAlive(e))return{optionGroups:[],validValues:new Set};const t=new Set,{context:r}=this.payloadForSQL,a={group:"context.label",items:Object.keys(r).map(i=>{const c=`context.${i}`;return t.add(c),{label:i,value:c,description:void 0,type:"context"}})},o={group:"filter.labels",items:e.filters.keyLabelOptions.map(i=>{const c=`filters.${i.value}`;return t.add(c),{label:i.label,value:c,description:i.value,type:"filter",widget:i.widget}})};return{optionGroups:[a,o],validValues:t}},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardStateValues}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:r,data:a})=>({id:r,data:a})).reduce((r,a)=>(r[a.id]=a.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get filtersUsage(){const t=[],r=e.views.idMap;e.filters.current.forEach(o=>{o.visibleInViewsIDs.forEach(l=>{var i;t.push({filterID:o.id,type:"view",type_label:"view.label",id:l,label:((i=r.get(l))==null?void 0:i.name)??l})})});const a=e.filters.keyIDMap;return e.queries.current.forEach(o=>{o.usedFilterKeySet.forEach(l=>{t.push({filterID:a[l]??l,type:"query",type_label:"query.label",id:o.id,label:o.name})})}),e.sqlSnippets.usedFilterKeyMap.forEach((o,l)=>{o.forEach(i=>{t.push({filterID:a[i]??i,type:"sql_snippet",type_label:"sql_snippet.label",id:l,label:l})})}),y.groupBy(t,"filterID")},findFilterUsage(t){return this.filtersUsage[t]??[]},get queriesUsage(){const t=e.panels.idMap,r=[];e.views.current.forEach(o=>{o.panelIDs.forEach(l=>{const i=t.get(l);if(!i)return;const c="panel",d=i.name,u=[{id:o.id,label:o.name}];i.queryIDs.forEach(p=>{r.push({id:l,queryID:p,type:c,type_label:"panel.label",label:d,views:u})})})});const a=e.views.idMap;return e.filters.current.filter(o=>!!y.get(o,"config.options_query_id")).forEach(o=>{r.push({type:"filter",type_label:"filter.label",id:o.id,queryID:y.get(o,"config.options_query_id"),label:o.label,views:o.visibleInViewsIDs.map(l=>{var i;return{id:l,label:((i=a.get(l))==null?void 0:i.name)??l}})})}),e.queries.current.forEach(o=>{if(!o.isTransform)return;o.config.dep_query_ids.forEach(i=>{r.push({type:"transform-query",type_label:"query.transform.full_label",id:o.id,queryID:i,label:o.name,views:[]})})}),y.groupBy(r,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(r=>{if(!r.typedAsSQL)return;const a=r.config;y.uniq(a.sql.match(Et.sqlSnippet)).forEach(l=>{t.push({queryID:r.id,sqlSnippetKey:l,queryName:r.name})})}),y.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),r=e.queries.current.filter(a=>!t.has(a.id)).map(a=>a.id);e.queries.removeQueries(r)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),r=e.sqlSnippets.current.filter(a=>!t.has(a.key)).map(a=>a.key);e.sqlSnippets.removeByKeys(r)},duplicatePanelByID(t,r){var o;const a=e.panels.duplicateByID(t);a&&((o=e.views.findByID(r))==null||o.appendPanelID(a))},removePanelByID(t,r){var a;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(a=e.views.findByID(r))==null||a.removePanelID(t)},addANewPanel(t){var a;const r=Te.v4();e.panels.append(ec(r)),(a=e.views.findByID(t))==null||a.appendPanelID(r),e.layouts.addALayoutItem(r)},applyJSONSchema(t){var g;const{views:r,panels:a,filters:o,definition:l={},layouts:i}=t,{queries:c,sqlSnippets:d,mock_context:u}=l,p=new Map;if(Array.isArray(a)){const b=a.map(_=>{const w=Te.v4();return p.set(_.id,w),{..._,id:w}});if(e.panels.appendMultiple(b),!Array.isArray(r)||r.length===0){const _=b.map(w=>w.id);(g=e.views.VIE)==null||g.appendPanelIDs(_)}}if(Array.isArray(r)){const b=r.map(_=>{const w=_.panelIDs.map(x=>p.get(x)??x);return{..._,id:Te.v4(),panelIDs:w}});e.views.appendMultiple(b)}if(Array.isArray(i)){const b=(x,S)=>e.layouts.breakpointNameRecord[x]===S;let _=[];const w=i.filter(x=>b(x.name,x.breakpoint));w.forEach(x=>{x.id==="basis"&&(_=x.list),x.list.forEach(S=>{const D=p.get(S.panelID);S.id=Te.v4(),S.panelID=D})}),e.layouts.list.forEach(x=>{const S=w.find(D=>D.name===x.name&&D.breakpoint===x.breakpoint);if(!S){_.forEach(D=>{x.addLayout(D)});return}S.list.forEach(D=>{x.addLayout(D)})})}Array.isArray(o)&&e.filters.appendMultiple(o),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(d)&&e.sqlSnippets.appendMultiple(d),u&&Object.keys(u).length>0&&e.mock_context.defaults(u)}})).actions(e=>({reset(){f.applySnapshot(e.filters.current,e.origin.filters.current),f.applySnapshot(e.queries.current,e.origin.queries.current),f.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),f.applySnapshot(e.views.current,e.origin.views.current),f.applySnapshot(e.panels.list,e.origin.panels.list),f.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){f.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:r,name:a,content:o}=t;if(!o)throw new Error("unexpected null content when updating a content model");const{version:l,filters:i,views:c,panels:d,definition:{queries:u,sqlSnippets:p,mock_context:g={}}}=o;e.id=r,e.name=a,e.version=l,f.applySnapshot(e.filters.current,i),f.applySnapshot(e.views.current,as(c).current),f.applySnapshot(e.panels.list,d),f.applySnapshot(e.queries.current,u),f.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=g}})),ss=f.types.snapshotProcessor(qD,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=f.castToSnapshot(e.queries.current.map(r=>y.pick(r,["id","key","type","sql"])));return y.defaults({},{queries:{current:t}},e)}});function OD(e,t){t.filters&&f.applySnapshot(e.filters.current,t.filters)}function ad({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,content:l},i,c){if(!l)throw new Error("unexpected null content when creating a content model");const{version:d,filters:u,views:p,panels:g,layouts:b,definition:{queries:_,sqlSnippets:w,mock_context:x={}}}=l;return ss.create({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,version:d,filters:qa(u,i,x,c),queries:{current:_},sqlSnippets:{current:w},mock_context:ua(x),views:as(p),panels:{list:g},layouts:{list:b,currentBreakpoint:b[0].id}})}const sd=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:ss,content_id:f.types.string,datasources:CD,globalSQLSnippets:Ia,context:Bn,editor:AD}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}},get queryVariables(){return{context:{...e.content.mock_context.current,...e.context.current},filters:e.content.filters.previewValues}},get queryVariablesString(){return JSON.stringify(this.queryVariables,null,2)}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,r){const{id:a,name:o,group:l,content_id:i}=t;e.id=a,e.name=o,e.group=l,e.content_id=i,this.updateCurrentContent(r)}}));function od({id:e,name:t,group:r,content_id:a},o,l,i,c,d){return sd.create({id:e,name:t,group:r,content_id:a,content:ad(o,c,d),datasources:{list:l},globalSQLSnippets:{list:i},context:Va(c),editor:{}})}function Ft(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function ld(e,t){h.useEffect(()=>{const a=o=>{Ft(o);const{viewID:l}=o.detail;if(!l){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(l),t&&e.views.setIDOfVIE(l)};return window.addEventListener("open-view",a),()=>{window.removeEventListener("open-view",a)}},[e,t]);const r=Eu.useNavigate();h.useEffect(()=>{const a=o=>{Ft(o);const{panelID:l}=o.detail;if(!l){console.error(new Error("[Scroll to Panel] Needs to pick a panel first"));return}r(`#${l}`),setTimeout(()=>{const i=document.getElementById(l);i&&i.scrollIntoView({behavior:"smooth"})},300)};return window.addEventListener("scroll_to_panel",a),()=>{window.removeEventListener("scroll_to_panel",a)}},[r]),h.useEffect(()=>{const a=o=>{Ft(o);const{viewID:l,tab:i}=o.detail;if(!l){console.error(new Error("[Switch Tab] Needs to pick a view and a tab first"));return}const c=e.views.findByID(l);if(!c){console.error(new Error(`[Switch Tab] View by ID[${l}] is not found`));return}c.setTab(i)};return window.addEventListener("switch_tab",a),()=>{window.removeEventListener("switch_tab",a)}},[e,t]),h.useEffect(()=>{const a=o=>{Ft(o);const{dictionary:l,payload:i}=o.detail;if(!i||Object.keys(i).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const c={};Object.entries(l).forEach(([d,u])=>{const p=y.get(i,u);c[d]=p}),e.filters.applyValuesPatch(c)};return window.addEventListener("set-filter-values",a),()=>{window.removeEventListener("set-filter-values",a)}},[e]),h.useEffect(()=>{function a(l){return Array.isArray(l)?[]:typeof l=="object"?{}:typeof l=="boolean"?!1:typeof l=="string"?"":typeof l=="number"?0:l}const o=l=>{Ft(l);const i={},{filter_keys:c}=l.detail;c.forEach(d=>{const u=y.get(e.filters.values,d),p=a(u);i[d]=p}),e.filters.applyValuesPatch(i)};return window.addEventListener("clear-filter-values",o),()=>{window.removeEventListener("clear-filter-values",o)}},[e]),h.useEffect(()=>{const a=o=>{Ft(o);const{urlTemplate:l,openInNewTab:i,enableEncoding:c=!1,payload:d}=o.detail;if(!l){console.error(new Error("[Open Link] URL is empty"));return}function u(b){return y.cloneDeepWith(b,w=>{if(c&&typeof w=="string")return encodeURIComponent(w)})}const g=y.template(l||"")(u({...d,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(g,i?"_blank":"_self","noopener")};return window.addEventListener("open-link",a),()=>{window.removeEventListener("open-link",a)}},[e])}function id(e){return h.useCallback(t=>t.provideValue(ee.pluginManager,e.pluginManager).provideValue(ee.vizManager,e.vizManager).provideValue(ee.panelAddonManager,e.panelAddonManager).provideValue(ee.colorManager,e.colorManager),[e])}const o6="",LD=k.observer(({saveDashboardChanges:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=F(),o=()=>{r.openConfirmModal({title:n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(T.IconAlertTriangle,{size:18,color:"red"}),n.jsx(s.Text,{size:"sm",children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>a.reset(),zIndex:320,withCloseButton:!1})},l=a.changed;return n.jsxs(s.Group,{gap:0,children:[n.jsx(s.Button,{color:"green",variant:"filled",size:"xs",leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),onClick:e,disabled:!l,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),n.jsxs(s.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!l,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"default",disabled:!l,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:n.jsx(T.IconCaretDown,{size:18})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconRecycle,{size:14,color:"red"}),disabled:!l,onClick:o,children:t("common.actions.revert_changes")})})]})]})}),ND=k.observer(({saveDashboardChanges:e,onExit:t,headerSlot:r=null})=>{m.useTranslation();const a=j(),o=a.content.changed,l=()=>{t({hasChanges:o,dashboardId:a.id})};return n.jsx(s.AppShell.Header,{h:60,py:0,px:"md",sx:{zIndex:299},children:n.jsxs(s.Group,{justify:"space-between",sx:{height:60,minWidth:"1000px",position:"relative"},children:[n.jsxs(s.Group,{children:[n.jsx(s.Button,{size:"xs",color:o?"red":"green",leftSection:n.jsx(T.IconArrowLeft,{size:20}),onClick:l,children:n.jsx(s.Group,{gap:4,children:n.jsx(m.Trans,{i18nKey:"common.actions.end_editing",values:{name:a.name},children:n.jsx(s.Text,{td:"underline",size:"xs",children:a.name})})})}),n.jsx(LD,{saveDashboardChanges:e})]}),n.jsx(s.Group,{justify:"flex-end",sx:{flexGrow:1},children:r})]})})}),cd={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},GD=k.observer(()=>{var o;const{t:e}=m.useTranslation(),t=F(),r=((o=t.views.VIE)==null?void 0:o.type)===B.Tabs,a=()=>t.addANewPanel(t.views.idOfVIE);return r?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),sx:{...cd,transform:"none !important"},children:e("panel.add")})}):n.jsx(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:a,leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),sx:{...cd,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),FD=k.observer(({done:e})=>{var E,U;const{t}=m.useTranslation(),a=F().layouts,o=h.useMemo(()=>({list:a.breakpointsInfo}),[a.breakpointsInfo]),{control:l,handleSubmit:i,watch:c,getValues:d,reset:u,formState:p}=v.useForm({defaultValues:o}),{fields:g,append:b,remove:_}=v.useFieldArray({control:l,name:"list",rules:{validate:N=>{if(y.uniqBy(N,"breakpoint").length!==N.length)return"Screen sizes should be unique by min width"}}}),w=c("list"),x=g.map((N,oe)=>({...N,...w[oe]})),S=()=>{b({id:Te.v4(),name:"",breakpoint:""})},D=({list:N})=>{const oe=N.filter(be=>Number.isFinite(be.breakpoint));a.updateLayoutSetsInfo(oe),e()},z=d(),I=h.useMemo(()=>{const N={list:z.list.filter(oe=>!!oe.name&&Number.isFinite(oe.breakpoint))};return!y.isEqual(N,o)},[z,o]),A=(U=(E=p.errors.list)==null?void 0:E.root)==null?void 0:U.message;return n.jsx(n.Fragment,{children:n.jsxs("form",{onSubmit:i(D),children:[n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,withTableBorder:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"340px"},children:t("common.name")}),n.jsx(s.Table.Th,{style:{width:"160px"},children:t("breakpoint.breakpoint")}),n.jsx(s.Table.Th,{})]})}),n.jsxs(s.Table.Tbody,{children:[x.map((N,oe)=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:N.id==="basis"?N.name:n.jsx(v.Controller,{name:`list.${oe}.name`,control:l,render:({field:be})=>n.jsx(s.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...be})})}),n.jsx(s.Table.Td,{children:N.id==="basis"?n.jsxs(s.Text,{size:"sm",ff:"monospace",children:[N.breakpoint,"px"]}):n.jsx(v.Controller,{name:`list.${oe}.breakpoint`,control:l,render:({field:be})=>n.jsx(s.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:n.jsx(s.Text,{size:"sm",c:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1},ff:"monospace",styles:{input:{paddingRight:"30px"}},...be})})}),n.jsx(s.Table.Td,{children:N.id!=="basis"&&n.jsx(s.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>_(oe),children:n.jsx(T.IconTrash,{})})})]},N.id)),n.jsx(s.Table.Tr,{style:{backgroundColor:"transparent"},children:n.jsx(s.Table.Td,{colSpan:3,style:{padding:"0"},children:n.jsx(s.Tooltip,{label:t("breakpoint.add"),children:n.jsx(s.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:S,sx:{width:"100%"},children:n.jsx(T.IconPlus,{size:18})})})})})]})]}),n.jsx(s.Text,{mt:6,ta:"right",size:"xs",c:"red",children:A??" "}),n.jsxs(s.Group,{mt:6,justify:"space-between",children:[n.jsx(s.Button,{color:"orange",size:"xs",onClick:()=>u(),leftSection:n.jsx(T.IconRecycle,{size:18}),disabled:!I,children:t("common.actions.revert")}),n.jsx(s.Button,{color:"green",size:"xs",type:"submit",leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),disabled:!I,children:t("common.actions.save_changes")})]})]})})}),QD=k.observer(()=>{const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1),o=F(),l=o.layouts.currentBreakpoint,i=o.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},d=()=>{a(),c()};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsxs(s.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"xs",variant:"subtle",leftSection:n.jsx(T.IconDevices,{size:16}),sx:{borderRadius:0},children:n.jsxs(s.Group,{gap:6,children:[n.jsx(s.Text,{size:"xs",fw:"normal",children:i.name}),n.jsx(s.Text,{size:"xs",c:"#777",children:o.layouts.currentRangeText})]})})}),n.jsxs(s.Menu.Dropdown,{children:[o.layouts.breakpointRanges.map(u=>n.jsx(s.Menu.Item,{onClick:()=>o.layouts.setCurrentBreakpoint(u.id),disabled:l===u.id,children:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",children:u.name}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:u.text})]})},u.id)),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{color:"blue",leftSection:n.jsx(T.IconSettings,{size:14}),onClick:r,children:n.jsx(s.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),o.layouts.divisionPreviewScale<1&&n.jsx(s.Text,{size:"xs",c:"dimmed",children:Ee(o.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),n.jsx(s.Modal,{opened:t,onClose:d,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:n.jsx(FD,{done:d})})]})}),dd={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},jD=k.observer(()=>{var o;const{t:e}=m.useTranslation(),t=F(),r=((o=t.views.VIE)==null?void 0:o.type)===B.Tabs,a=()=>{var l;return(l=t.views.VIE)==null?void 0:l.downloadSchema()};return r?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconCode,{size:16}),sx:{...dd,transform:"none !important"},children:e("view.download_schema")})}):n.jsx(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:a,leftSection:n.jsx(T.IconCode,{size:16}),sx:{...dd},children:e("view.download_schema")})}),Nn=({headers:e,rows:t})=>n.jsxs(s.Table,{fz:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[n.jsx(s.Table.Thead,{children:e}),n.jsx(s.Table.Tbody,{children:t})]}),WD=({content:e})=>{const{t}=m.useTranslation(),r=e.views;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),n.jsx(Nn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{children:t("common.type")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.name}),n.jsx(s.Table.Td,{children:t(`view.component.${a.type}.label`)})]},a.id))})]})},UD=({content:e})=>{const{t}=m.useTranslation(),r=e.filters;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),n.jsx(Nn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.key")}),n.jsx(s.Table.Th,{children:t("common.label")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.key}),n.jsx(s.Table.Td,{children:a.label})]},a.id))})]})},KD=({content:e})=>{const{t}=m.useTranslation(),r=e.panels;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),n.jsx(Nn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{children:t("visualization.component")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.name}),n.jsx(s.Table.Td,{children:a.viz.type})]},a.id))})]})},YD=({content:e})=>{var a;const{t}=m.useTranslation(),r=(a=e.definition)==null?void 0:a.queries;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),n.jsx(Nn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{style:{width:"140px"},children:t("common.type")}),n.jsx(s.Table.Th,{style:{width:"260px"},children:t("data_source.label")})]}),rows:r.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:o.id}),n.jsx(s.Table.Td,{children:o.name}),n.jsx(s.Table.Td,{children:o.type}),n.jsx(s.Table.Td,{children:o.key})]},o.id))})]})},XD=({content:e})=>{var a;const{t}=m.useTranslation(),r=(a=e.definition)==null?void 0:a.sqlSnippets;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),n.jsx(s.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(T.IconPointFilled,{size:10}),children:r.map(o=>n.jsx(s.List.Item,{children:o.key},o.key))})]})},ZD=({content:e})=>{var a;const{t}=m.useTranslation(),r=Object.keys(((a=e.definition)==null?void 0:a.mock_context)??{});return r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),n.jsx(s.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(T.IconPointFilled,{size:10}),children:r.map(o=>n.jsx(s.List.Item,{children:o},o))})]})},JD=({content:e})=>e?n.jsxs(s.Box,{children:[n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(s.Text,{ta:"left",c:"dimmed",size:"sm",children:"Preview"}),n.jsxs(s.Stack,{children:[n.jsx(WD,{content:e}),n.jsx(UD,{content:e}),n.jsx(KD,{content:e}),n.jsx(YD,{content:e}),n.jsx(XD,{content:e}),n.jsx(ZD,{content:e})]})]}):null;function HD(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==lt)throw new Error("Schema version mismatch");return t}const RD=k.observer(({onSuccess:e,stretchModal:t,shrinkModal:r})=>{var D,z;const{t:a}=m.useTranslation(),o=F(),{handleSubmit:l,formState:{errors:i},setValue:c,watch:d,setError:u,clearErrors:p}=v.useForm({defaultValues:{content:null}}),g=({content:I})=>{try{if(!I)throw new Error("please use a valid json file");o.applyJSONSchema(I),Fe.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(A){console.error(A),Fe.showNotification({title:"Failed",message:A.message,color:"red"})}},[b,_]=h.useState(null);h.useEffect(()=>{if(!b)return;const I=new FileReader;I.readAsText(b,"UTF-8"),I.onload=A=>{try{const E=HD(A);c("content",E),p("content")}catch(E){console.error(E),u("content",{type:"custom",message:E.message})}},I.onabort=()=>console.log("🟨 abort"),I.onerror=()=>{I.error&&(console.error(I.error),u("content",{type:"custom",message:I.error.message}))}},[b]);const[w]=d(["content"]),x=!w,S=(D=i==null?void 0:i.content)==null?void 0:D.message;return h.useEffect(()=>{!w||S?r():t()},[w,S]),n.jsx(s.Box,{mx:"auto",sx:{position:"relative"},children:n.jsxs("form",{onSubmit:l(g),children:[n.jsx(s.FileInput,{label:a("import.json_file"),required:!0,value:b,onChange:_,error:(z=i==null?void 0:i.content)==null?void 0:z.message,sx:{maxWidth:500}}),S?n.jsx(s.Table,{fz:12,mt:10,children:n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:a("import.this_dashboard")}),n.jsx(s.Table.Td,{children:lt})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:a("import.this_file")}),n.jsx(s.Table.Td,{style:{color:"red"},children:w==null?void 0:w.version})]})]})}):n.jsxs(n.Fragment,{children:[n.jsx(JD,{content:w}),n.jsx(s.Group,{justify:"flex-end",my:"md",children:n.jsx(s.Button,{type:"submit",color:"green",disabled:x,children:a("common.actions.confirm")})})]})]})})}),ud={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},ez=k.observer(()=>{var u;const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1),[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1),d=((u=j().content.views.VIE)==null?void 0:u.type)===B.Tabs;return d?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconFileImport,{size:16}),sx:{...ud,transform:"none !important"},children:e("import.label")})}):n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:d||t,onClick:r,leftSection:n.jsx(T.IconFileImport,{size:16}),sx:{...ud},children:e("import.label")}),n.jsx(s.Modal,{opened:t,onClose:a,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:o?"90vw":500,children:n.jsx(RD,{onSuccess:a,stretchModal:l,shrinkModal:i})})]})}),tz=({iconKey:e,...t})=>{switch(e){case"query_variables":return n.jsx(T.IconVariable,{...t});case"mock_context":return n.jsx(T.IconCodeDots,{...t});case"filter":return n.jsx(T.IconFilter,{...t});case"sql_snippet":return n.jsx(T.IconCopy,{...t});case"query":return n.jsx(T.IconDatabase,{...t});case"view":return n.jsx(T.IconBoxMultiple,{...t});case"panel":return n.jsx(T.IconAppWindow,{...t});default:return null}},nz=({action:e})=>{const{t}=m.useTranslation();return e.description?n.jsx(s.Text,{c:"dimmed",size:"xs",children:t(e.description)}):e.viz?n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{c:"dimmed",size:"xs",children:t(e.viz.displayName)}),n.jsx(s.Text,{c:"dimmed",size:"xs",className:"spotlight-action-viz-group",children:t(e.viz.displayGroup)})]}):null},rz=k.observer(({action:e,query:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Box,{className:"spotlight-custom-action-component",children:n.jsxs(s.Group,{wrap:"nowrap",children:[n.jsx(tz,{iconKey:e.iconKey,size:14}),n.jsxs("div",{style:{flex:1},children:[n.jsx(s.Highlight,{highlight:t,size:"sm",children:e.title?r(e.title):""}),n.jsx(nz,{action:e})]})]})})}),az=({groups:e,query:t})=>{const{t:r}=m.useTranslation();return e.length===0?n.jsx(xt.Spotlight.Empty,{children:r("spotlight.not_found")}):n.jsx(n.Fragment,{children:e.map(a=>n.jsx(xt.Spotlight.ActionsGroup,{label:a.group,children:a.actions.map(o=>n.jsx(xt.Spotlight.Action,{onClick:o.onClick,children:n.jsx(rz,{action:o,query:t})},o.id))},a.group))})},sz=k.observer(()=>{const{t:e,i18n:t}=m.useTranslation(),r=s.useMantineTheme(),a=j(),[o,l]=h.useState(""),i=h.useMemo(()=>a.editor.spotlightActionGroups.map(d=>({group:e(d.group),keywords:[d.group,e(d.group)],actions:d.actions.map(u=>{const p=[];return u.title&&(p.push(u.title.toLowerCase()),p.push(e(u.title).toLowerCase())),u.group&&p.push(u.group.toLowerCase()),u.viz&&(p.push(u.viz.displayGroup.toLowerCase()),p.push(u.viz.displayName.toLowerCase())),u.iconKey&&p.push(u.iconKey),{...u,keywords:p}})})),[a.editor.spotlightActionGroups,t.language]),c=h.useMemo(()=>{const d=o.toLowerCase().trim();return d?i.map(p=>{if(p.keywords.some(_=>_.includes(d)))return p;const b=p.actions.filter(_=>_.keywords.some(w=>w.includes(d)));return b.length===0?null:{...p,actions:b}}).filter(p=>p!==null):[i[0]]},[i,o]);return n.jsxs(xt.Spotlight.Root,{onQueryChange:l,shortcut:["mod + P","mod + K"],radius:"md",styles:{search:{border:"none"},action:{position:"relative",display:"block",width:"100%",padding:`${s.rem(10)} ${s.rem(12)}`,borderRadius:r.radius.sm,".spotlight-action-viz-group":{opacity:0},"&:hover, &[data-selected]":{backgroundColor:r.colors.gray[1],".spotlight-action-viz-group":{opacity:1}}}},children:[n.jsx(xt.Spotlight.Search,{placeholder:e("spotlight.placeholder"),leftSection:n.jsx(T.IconSearch,{size:"1.2rem"})}),n.jsx(xt.Spotlight.ActionsList,{children:n.jsx(az,{groups:c,query:o})})]})}),pd=({children:e})=>n.jsx(s.Text,{style:{fontSize:"0.6875rem",lineHeight:1,padding:"0.25rem 0.2375rem",borderRadius:"0.25rem"},children:e}),hd=function(){var t;return(((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform).toLowerCase().includes("mac")}(),oz=()=>{const{t:e}=m.useTranslation();return n.jsx(s.Tooltip,{label:n.jsxs(n.Fragment,{children:[hd&&n.jsx(pd,{children:"⌘ + K"}),!hd&&n.jsx(pd,{children:"Ctrl + K"})]}),children:n.jsx(s.UnstyledButton,{onClick:()=>xt.spotlight.open(),style:{height:"1.875rem",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",paddingLeft:"calc(0.875rem / 1.5)",paddingRight:"1rem"},sx:{color:"#228be6",background:"transparent","&:hover":{background:"rgb(231, 245, 255)"}},children:n.jsxs(s.Group,{gap:"0.625rem",children:[n.jsx(T.IconSearch,{size:"1rem",color:"#228be6"}),n.jsx(s.Text,{fw:500,style:{flexGrow:1,fontWeight:500,fontSize:"0.75rem",lineHeight:1},children:e("spotlight.trigger_text")})]})})})},lz={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},iz=k.observer(()=>n.jsx(s.Box,{sx:lz,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:n.jsxs(s.Group,{justify:"space-between",align:"center",sx:{height:"30px"},children:[n.jsxs(s.Group,{justify:"flex-start",gap:0,children:[n.jsx(GD,{}),n.jsx(ez,{}),n.jsx(oz,{})]}),n.jsx(QD,{}),n.jsx(s.Group,{justify:"flex-end",gap:0,children:n.jsx(jD,{})})]})})),cz=k.observer(e=>n.jsxs(n.Fragment,{children:[n.jsx(ND,{...e}),n.jsx(iz,{})]}));function dz(e,t,r){const a=[];return e.filter(o=>"__INTERACTIONS"in o.viz.conf).forEach((o,l)=>{const i=t[o.id];i.data.interactions=y.get(i,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:d,__TRIGGERS:u}=o.viz.conf;Object.entries(d).forEach(([p,g])=>{const{schemaRef:b,data:_}=g,{config:w}=_;switch(b){case"builtin:op:open-link":let x=w.urlTemplate.substring(0,100);w.urlTemplate.length>=20&&(x+="..."),i.type="interaction",i.data.interactions.push({schemaRef:b,urlTemplate:w.urlTemplate,shortURLTemplate:x});return;case"builtin:op:open_view":a.push({id:`OPERATION--${p}`,source:o.id,target:w.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":i.type="interaction",i.data.interactions.push({schemaRef:b,filters:Object.keys(w.dictionary).map(S=>({key:S,label:r[S]}))});return;case"builtin:op:clear_filter_values":i.type="interaction",i.data.interactions.push({schemaRef:b,filters:w.filter_keys.map(S=>({key:S,label:r[S]}))});return;default:return}})}),a}function uz(e,t){const r=e.filters.keyLabelMap;return{edges:dz(e.panels.list,t,r),edgeNodes:[]}}function gd(e,t,r){return e*t+e*r}function pz(e,t,r){return e*t+(e-1)*r}const Gn=25,os=40,fd=25,ls=350,hz=150,gz=150,bd=150,yd=300,Fn=40,vd=25,fz=300;function bz(e,t){const r=y.keyBy(t,o=>o.id),a=[];return e.current.forEach((o,l)=>{o.panelIDs.forEach((i,c)=>{const d=gd(c,Fn,vd)+os,u=r[i];if(!u){a.push({id:i,_node_type:"panel",parentNode:o.id,data:{label:`!: ${i}`},position:{x:Gn,y:d},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,style:{width:yd,height:Fn}});return}const p=u.name;a.push({id:u.id,_node_type:"panel",parentNode:o.id,data:{label:p},position:{x:Gn,y:d},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,style:{width:yd,height:Fn}})})}),a}const yz={[B.Division]:"Div",[B.Modal]:"Modal",[B.Tabs]:"Tabs"},vz=Xc;function _z(e){return e.current.map((r,a)=>{const o=pz(r.panelIDs.length,Fn,vd)+os+fd;let l=[];return r.type===B.Tabs&&(l=r.config.tabsInOrder.map(c=>c.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:l,data:{label:`${yz[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,className:"light",style:{backgroundColor:vz[r.type],width:ls,height:o}}})}function mz(e){const t=y.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==B.Tabs||r._tab_view_ids.forEach(a=>{t[a].parentNode=r.id})})}function wz(e){const t=_z(e.views);mz(t);const r=bz(e.views,e.panels.list);return[...t,...r]}function xz({nodeMap:e,nodes:t,edges:r}){t.forEach(a=>{a._node_type!=="view-root"||a._view_type!==B.Tabs||(a.sourcePosition=ie.Position.Bottom,a.style.width=ls+Gn*2,a.style.height=fd+a._tab_view_ids.reduce((o,l)=>{const i=e[l];i.position.y=o,i.position.x=Gn;const c=i.style.height;return o+c+20},os))})}function Cz({nodeMap:e,nodes:t,edges:r}){r.filter(a=>a.label==="Open View").forEach(a=>{const o=e[a.source],l=e[a.target];if(!o||!l||!o.parentNode)return;const i=e[o.parentNode];i._node_type!=="view-root"||l._node_type!=="view-root"||(l._view_level+=1+i._view_level,i._sub_view_ids.push(l.id))}),t.sort((a,o)=>a._node_type==="view-root"&&o._node_type==="view-root"?a._view_level-o._view_level:a._node_type!=="view-root"&&o._node_type!=="view-root"?0:a._node_type==="view-root"?-1:1)}function Sz({nodeMap:e,nodes:t,edges:r}){const a={};r.forEach(o=>{if(o.label!=="Open View")return;const l=e[o.source],i=e[o.target];if(l&&i&&l.parentNode){const c=e[l.parentNode],d=c.position.x,u=Number(y.get(i,"style.height",0)),p=Number(c.style.width);i.position.x=d+p+fz,c._view_level===0&&i._sub_view_ids.length===0&&(l.sourcePosition=ie.Position.Left,i.targetPosition=ie.Position.Right,i.position.x*=-1);const b=i.position.x,_=y.get(a,b,0);i.position.y=_,a[b]=_+u+bd}})}function Tz({nodeMap:e,nodes:t,edges:r}){const a=new Set,o=new Set;r.forEach(i=>{a.add(i.source),o.add(i.target)}),t.filter(i=>i._node_type!=="view-root"||i.id==="Main"||i.parentNode?!1:!a.has(i.id)&&!o.has(i.id)).forEach((i,c)=>{i.position.x=gd(c,ls,gz),i.position.y=0-hz-bd})}function kz({nodeMap:e,nodes:t,edges:r}){const a={nodeMap:e,nodes:t,edges:r};return Tz(a),Cz(a),xz(a),Sz(a),{nodes:t,edges:r}}function Dz(e){const t=wz(e),r=y.keyBy(t,d=>d.id),{edges:a,edgeNodes:o}=uz(e,r),l=[...t,...o],i=y.keyBy(l,d=>d.id),c={edges:y.uniqBy(a,d=>d.id),nodes:l,nodeMap:i};return kz(c)}const l6="",is={"builtin:op:open-link":n.jsx(s.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n.jsx(T.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n.jsx(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(T.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n.jsx(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(T.IconCircleOff,{size:14})})};function zz(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:is[r.schemaRef],text:n.jsxs(s.Group,{gap:4,children:[n.jsx(s.Text,{size:"sm",children:"Open: "}),n.jsx(s.Text,{size:"sm",c:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:a,label:o})=>{t.push({key:r.schemaRef+a,icon:is[r.schemaRef],text:n.jsx(s.Group,{gap:4,children:n.jsxs(s.Text,{size:"sm",children:["Set Filter: ",o]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:a,label:o})=>{t.push({key:r.schemaRef+a,icon:is[r.schemaRef],text:n.jsx(s.Group,{gap:4,children:n.jsxs(s.Text,{size:"sm",children:["Clear Filter: ",o]})})})});return}}),t}const Mz=h.memo(({data:e,isConnectable:t,sourcePosition:r=ie.Position.Right,targetPosition:a=ie.Position.Left,...o})=>{const l=h.useMemo(()=>zz(e.interactions),[e.interactions]);return n.jsxs(n.Fragment,{children:[n.jsx(ie.Handle,{type:"target",position:a,isConnectable:t}),n.jsx(s.Box,{sx:{position:"absolute",top:0,right:0},children:n.jsx(T.IconChevronsUpRight,{size:12})}),n.jsxs(s.HoverCard,{shadow:"xl",withinPortal:!0,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Text,{size:"sm",children:e.label})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.List,{spacing:"xs",size:"sm",center:!0,children:l.map(i=>n.jsx(s.List.Item,{icon:i.icon,children:i.text},i.key))})})]}),n.jsx(ie.Handle,{type:"source",position:r,isConnectable:t})]})}),i6="",Iz={interaction:Mz},Vz=k.observer(()=>{const e=H(),{edges:t,nodes:r}=Dz(e);return n.jsxs(ie,{nodes:r,edges:t,onNodesChange:y.noop,onEdgesChange:y.noop,onConnect:y.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Iz,children:[n.jsx(ie.MiniMap,{}),n.jsx(ie.Controls,{}),n.jsx(ie.Background,{})]})}),Pz=k.observer(({opened:e,close:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Modal,{size:"96vw",opened:e,onClose:t,title:r("interactions.interactions_viewer"),trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:n.jsx(Vz,{})})}),$z={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function Az({onClick:e,name:t,active:r,openSettings:a}){return n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.UnstyledButton,{sx:o=>({display:"block",width:"100%",padding:o.spacing.xs,borderRadius:0,position:"relative",color:o.black,"&:hover":{backgroundColor:o.colors.gray[0]},backgroundColor:r?o.colors.gray[2]:"transparent"}),children:n.jsx(s.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n.jsx(s.Text,{size:"sm",children:t})})}),r&&n.jsx(s.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n.jsx(s.ActionIcon,{onClick:a,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n.jsx(T.IconAdjustments,{size:16})})})]})}const Ez=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=F(),a=h.useCallback(l=>()=>r.views.setIDOfVIE(l),[r]),o=l=>{t.editor.open(["_VIEWS_",l])};return n.jsxs(s.Box,{sx:{position:"relative"},children:[r.views.options.map(l=>n.jsx(Az,{active:r.views.idOfVIE===l.value,name:l.label,onClick:a(l.value),openSettings:()=>o(l.value)},l.value)),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:r.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),Bz=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=F(),a=()=>{if(!r.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",r.queries.firstID])},o=()=>{if(!r.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",r.filters.firstID])},[l,i]=h.useState(!1),c=()=>i(!0),d=()=>i(!1);return n.jsxs(s.AppShell.Navbar,{p:0,zIndex:299,children:[n.jsxs(s.AppShell.Section,{children:[n.jsxs(s.Group,{grow:!0,gap:0,sx:{...$z,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n.jsx(s.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:o,children:n.jsx(T.IconFilter,{size:18})})}),n.jsx(s.Tooltip,{label:e("query.labels"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:a,children:n.jsx(T.IconDatabase,{size:18})})}),n.jsx(s.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:n.jsx(T.IconRoute,{size:18})})})]}),n.jsx(Pz,{opened:l,close:d})]}),n.jsx(s.AppShell.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),n.jsx(s.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(Ez,{})}),n.jsx(s.AppShell.Section,{children:n.jsx(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(s.Button,{size:"xs",leftSection:n.jsx(T.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),qz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.default_value,onChange:a=>r.setDefaultValue(a.currentTarget.checked),label:t("filter.widget.checkbox.default_checked")}),n.jsx(_t,{filter:e})]}),n.jsx(gn,{label:t("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}},e.id)]})}),Oz=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],Lz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config,o=h.useMemo(()=>{const i=Si();return Object.entries(i).map(([c,d])=>({group:r(`filter.widget.date_range.shortcut.${c}.label`),items:d.map(({key:u,value:p})=>({label:r(`filter.widget.date_range.shortcut.${c}.full.${u}`),value:p}))}))},[]),l=[...a.default_value];return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsx(s.Checkbox,{checked:a.required,onChange:i=>a.setRequired(i.currentTarget.checked),label:r("filter.widget.date_range.required")}),n.jsx(s.Checkbox,{checked:a.allowSingleDateInRange,onChange:i=>a.setAllowSingleDateInRange(i.currentTarget.checked),label:r("filter.widget.date_range.allow_single_date")})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Select,{data:Oz,label:r("filter.widget.date_range.display_format"),value:a.inputFormat,onChange:a.setInputFormat}),n.jsx(s.NumberInput,{label:r("filter.widget.date_range.max_days"),min:0,value:a.max_days,onChange:a.setMaxDays,hideControls:!0})]}),n.jsxs(s.Group,{children:[n.jsx(wc,{label:r("filter.widget.date_range.default_value"),config:a,value:{value:l,shortcut:null},onChange:a.setDefaultValue,disabled:!!a.default_shortcut}),n.jsx(s.Select,{data:o,label:r("filter.widget.date_range.default_by_shortcut"),value:a.default_shortcut,onChange:a.setDefaultShortcut,placeholder:r("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),n.jsx(_t,{filter:t})]})}),Nz=`
|
|
546
|
+
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),f.addDisposer(e,G.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),yD=f.types.model({data:f.types.optional(f.types.frozen(),{}),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),vD=f.types.model({tables:f.types.optional(yD,{}),columns:f.types.optional(gD,{}),tableData:f.types.optional(bD,{}),indexes:f.types.optional(fD,{}),table_schema:f.types.optional(f.types.string,""),table_name:f.types.optional(f.types.string,"")}).views(e=>({get dataSource(){return f.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get sqlDataSourceType(){return this.type},get reloadConditionString(){const t=this.type,{table_name:r,table_schema:a}=e;return`${t};${r};${a}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=f.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const a=yield*f.toGenerator($e.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=y.groupBy(a,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(a){if(!ke.isCancel(a)){e.tables.data={};const o=y.get(a,"message","unkown error");e.tables.error=y.get(a,"response.data.detail.message",o),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:f.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*f.toGenerator($e.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(a){if(ke.isCancel(a))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const o=y.get(a,"message","unkown error");e.columns.error=y.get(a,"response.data.detail.message",o),e.columns.state="error"}}}),loadIndexes:f.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*f.toGenerator($e.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(a){if(ke.isCancel(a))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const o=y.get(a,"message","unkown error");e.indexes.error=y.get(a,"response.data.detail.message",o),e.indexes.state="error"}}}),loadTableData:f.flow(function*(){var a;(a=e.controllers.tableData)==null||a.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*f.toGenerator($e.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:r.limit,offset:r.offset},{params:{query_type:"DATA"}}));const[{total:o}]=yield*f.toGenerator($e.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));r.total=Number(o),r.state="idle",r.error=null}catch(o){if(ke.isCancel(o))r.state="idle",r.error=null;else{r.data=[];const l=y.get(o,"message","unkown error");r.error=y.get(o,"response.data.detail.message",l),r.state="error"}}})}}).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),f.addDisposer(e,G.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}}));function _D(e,t){if(!t)throw new Error("Shouldnt run query without ID");if(e==="derived")return`/api/metric_management/derived_metric/${t}`;if(e==="combined")return`/api/metric_management/combined_metric/${t}`;if(e==="sql")return`/api/metric_management/sql_metric/${t}`;throw new Error(`Unexpected metric type[${e}]`)}const mD=f.types.model({data:f.types.optional(f.types.frozen(),null),variables:f.types.optional(f.types.frozen(),[]),filters:f.types.optional(f.types.frozen(),[]),groupBys:f.types.optional(f.types.frozen(),[]),trendingDateCol:f.types.optional(f.types.frozen(),null),supportTrending:f.types.optional(f.types.boolean,!1),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get hasData(){return e.data!==null},get mmInfo(){return f.getParent(e)},get metricID(){return this.mmInfo.metricID},get metric(){return this.mmInfo.metric},get metricType(){var t;return(t=this.metric)==null?void 0:t.type},get filterColOptions(){return v2(e.filters)},get groupByColOptions(){return _2(e.groupBys)},get flatGroupByColOptions(){const t=this.groupByColOptions,r=[];return t.forEach(({group:a,items:o})=>{r.push(...o)}),r},getGroupByOptions(t){const r=new Set(t);return this.flatGroupByColOptions.filter(a=>r.has(a.value))}})).actions(e=>({load:f.flow(function*(){var t;if(e.mmInfo.type===W.MericoMetricSystem&&!(!e.metricID||!e.metricType)){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=_D(e.metricType,e.metricID),a=fn(e.mmInfo.dataSource,{url:r,method:"GET",data:{key:e.mmInfo.key}}),o=yield*f.toGenerator($e.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(a),...e.mmInfo.additionalQueryInfo},e.controller.signal)),l=bn(e.mmInfo.dataSource,o),i=y.cloneDeep(l.data),{filters:c,groupBys:d,trendingDateCol:u,supportTrending:p,variables:g}=y2(l.data);e.data=i,e.variables=g,e.filters=c,e.groupBys=d,e.supportTrending=p,e.trendingDateCol=u,e.state="idle",e.error=null}catch(r){if(!ke.isCancel(r)){e.data=null;const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}})})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>e.metricID+e.metricType,e.load,{fireImmediately:!0,delay:0}))}})),wD=f.types.model({keyword:f.types.optional(f.types.string,""),data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0},get mmInfo(){return f.getParent(e)}})).actions(e=>({setKeyword(t){e.keyword=t}})).actions(e=>({load:f.flow(function*(){var t;if(e.mmInfo.type===W.MericoMetricSystem){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=fn(e.mmInfo.dataSource,{url:"/api/metric_management/search",method:"POST",data:{key:e.mmInfo.key},params:{search:e.keyword}}),a=yield*f.toGenerator($e.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(r),...e.mmInfo.additionalQueryInfo},e.controller.signal)),l=bn(e.mmInfo.dataSource,a).data;e.data=l,e.state="idle",e.error=null}catch(r){if(!ke.isCancel(r)){e.data=[];const a=y.get(r,"message","unkown error");e.error=y.get(r,"response.data.detail.message",a),e.state="error"}}}})})).actions(e=>({afterCreate(){f.addDisposer(e,G.reaction(()=>`${e.mmInfo.type}:${e.keyword}`,e.load,{fireImmediately:!0,delay:0}))}})),xD=f.types.model({metrics:f.types.optional(wD,{}),metricDetail:f.types.optional(mD,{}),keyword:f.types.optional(f.types.string,""),metricID:f.types.optional(f.types.string,"")}).views(e=>({get rootModel(){return f.getRoot(e)},get contentModel(){return this.rootModel.content},get additionalQueryInfo(){return this.contentModel.getAdditionalQueryInfo("")},get dataSource(){return f.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get metric(){return e.metricID?e.metrics.data.find(t=>t.id===e.metricID)??null:null}})).actions(e=>({selectMetric(t){e.metricID=t}})),CD=f.types.compose("DataSourceModel",Ia,f.types.model({dbInfo:f.types.optional(vD,{}),mericoMetricInfo:f.types.optional(xD,{})})),SD=f.types.model("DataSourcesModel",{list:f.types.optional(f.types.array(CD),[])}).views(e=>({find({type:t,key:r}){return e.list.find(a=>a.key===r&&a.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function TD(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function kD(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function DD(e){return e.length===1&&e[0]==="_FILTERS_"}function zD(e){return e.length===2&&e[0]==="_FILTERS_"}function MD(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function ID(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function VD(e){return e.length===2&&e[0]==="_QUERIES_"}function PD(e){return e.length===1&&e[0]==="_QUERIES_"}function $D(e){return e.length===2&&e[0]==="_VIEWS_"}function rs(e){return e.length===6&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}function It(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function AD(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value,"_TABS_","Data"]:(console.error("[getPathFromOption] parentID is required"),null)}}const ED=f.types.model("EditorModel",{path:f.types.optional(f.types.frozen(),[]),settings_open:f.types.optional(f.types.boolean,!1)}).views(e=>({get isPanelPath(){return rs(e.path)},get panelTab(){return this.isPanelPath?y.get(e.path,5,"Data"):null},get navOptions(){const{content:t}=f.getRoot(e),{filters:r,views:a,sqlSnippets:o,queries:l}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:T.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:T.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:T.IconFilter,children:[It("_FILTERS_SETTINGS_"),...r.options,It("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:T.IconCopy,children:[It("_SQL_SNIPPETS_SETTINGS_"),...o.options,It("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:T.IconDatabase,children:[It("_QUERIES_SETTINGS_"),...l.options,It("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:T.IconBoxMultiple,children:[...a.editorOptions,It("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,r){return t.length===0?!1:rs(t)?t[3]===r.value:t[t.length-1]===r.value},isOptionOpened(t){const{path:r}=e;return r.length===0||!t.children||t.children.length===0?!1:r.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t},openAndSetPath(t){this.setPath(t),e.settings_open||(e.settings_open=!0)}})).actions(e=>({setPanelTab(t){if(!e.isPanelPath||e.panelTab===t||!t)return;const r=y.clone(e.path);r[5]=t,e.setPath(r)},open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const r=AD(t);r&&e.setPath(r)}})).views(e=>({get spotlightActionGroups(){const{content:t}=f.getRoot(e),{filters:r,views:a,sqlSnippets:o,queries:l}=t,i={group:"spotlight.main_group",actions:[{id:"query_variable.labels",title:"query_variable.labels",onClick:()=>e.openAndSetPath(["_QUERY_VARS_"]),iconKey:"query_variables"},{id:"mock_context.label",title:"mock_context.label",onClick:()=>e.openAndSetPath(["_MOCK_CONTEXT_"]),iconKey:"mock_context"},{id:"filter.labels",title:"filter.labels",onClick:()=>e.openAndSetPath(["_FILTERS_"]),iconKey:"filter"},{id:"sql_snippet.labels",title:"sql_snippet.labels",onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_"]),iconKey:"sql_snippet"},{id:"query.labels",title:"query.labels",onClick:()=>e.openAndSetPath(["_QUERIES_"]),iconKey:"query"}]},c={group:"filter.labels",actions:[]};r.options.forEach(g=>{c.actions.push({id:`_FILTERS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_FILTERS_",g.value]),iconKey:"filter"})});const d={group:"sql_snippet.labels",actions:[]};o.options.forEach(g=>{d.actions.push({id:`_SQL_SNIPPETS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_",g.value]),iconKey:"sql_snippet"})});const u={group:"query.labels",actions:[]};l.options.forEach(g=>{u.actions.push({id:`_QUERIES_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_QUERIES_",g.value]),iconKey:"query"})});const p=[i,c,d,u];return a.editorOptions.forEach(g=>{const b={group:g.label,actions:[]};b.actions.push({id:`_VIEWS_.${g.value}`,title:g.label,onClick:()=>e.openAndSetPath(["_VIEWS_",g.value]),iconKey:"view",group:g.label}),g.children.forEach(_=>{_._type!=="ACTION"&&b.actions.push({id:`_VIEWS_._PANELS_.${_.value}`,title:_.label,viz:_.viz,onClick:()=>e.openAndSetPath(["_VIEWS_",g.value,"_PANELS_",_.value,"_TABS_","Panel"]),iconKey:"panel",group:g.label})}),p.push(b)}),p}})),BD=f.types.compose("LayoutsModel",Fa,f.types.model({currentLayoutWrapperWidth:f.types.optional(f.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,r=e.currentLayoutWrapperWidth;return!t||!r||t<=r?1:r/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(r=>{r.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,r){e.list.forEach(a=>{const o=a.findByPanelID(t);if(!o){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${a.name}]`);return}a.list.push({...o,id:Te.v4(),panelID:r,y:1/0})})},removeByPanelID(t){e.list.forEach(r=>{r.removeByPanelID(t)})},removeByPanelIDs(t){e.list.forEach(r=>{r.removeByPanelIDs(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,r,a){const o=e.basisLayoutSet,l={id:t,name:r,breakpoint:a,list:o.json.list.map(i=>({...i,id:Te.v4()}))};e.list.push(l)},updateLayoutSetsInfo(t){const r=y.keyBy(e.list,"id");t.forEach(l=>{const i=r[l.id];if(i){i.setName(l.name),i.setBreakpoint(l.breakpoint),delete r[l.id];return}this.addALayoutSet(l.id,l.name,l.breakpoint)});const a=new Set(Object.keys(r)),o=a.size>0;a.forEach(l=>{const i=e.list.findIndex(c=>c.id===l);e.list.splice(i,1)}),o&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(r=>{e.currentLayoutSet.updateLayoutItem(r)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const r=e.list.findIndex(a=>a.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})}})),td=Ea.views(e=>({get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,r){const a=[...this.realQueryOptions];return t&&!a.find(o=>o.value===t)&&a.unshift({label:t,value:t,disabled:!0}),r&&a.unshift({label:"unset",value:"",disabled:!1}),a},get realVariableOptions(){const t=e.variableValueMap;return Object.entries(e.variableAggValueMap).map(([r,a])=>({label:r,value:r,formattedValue:t[r],aggValue:a,disabled:!1}))},variableOptions(t,r){const a=[...this.realVariableOptions];return t&&!a.find(o=>o.value===t)&&a.unshift({label:t,value:t,formattedValue:"",aggValue:"",disabled:!0}),r&&a.unshift({label:"unset",value:"",formattedValue:"",aggValue:"",disabled:!1}),a},explainDataKey(t){const{queryID:r,columnKey:a}=$(t),o=e.queries.find(l=>l.id===r);return o?{queryID:r,queryName:o.name,columnKey:a}:{queryID:r,queryName:null,columnKey:a}}})).actions(e=>({removeSelf(){f.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,r){f.getRoot(e).content.views.findByID(t).removePanelID(e.id),f.getRoot(e).content.views.findByID(r).appendPanelID(e.id),f.getRoot(e).editor.setPath(["_VIEWS_",r,"_PANELS_",e.id])}})),nd=f.types.compose("PanelsModel",Ba,f.types.model({list:f.types.optional(f.types.array(td),[])})).views(e=>({get contentModel(){return f.getRoot(e).content},get options(){return e.list.map(t=>({label:t.name,value:t.id,viz_type:t.viz.type}))},editorOptions(t,r){const a=e.panelsByIDs(r);a.length!==r.length&&console.warn(`Unfulfilled panels for View[${t}]`);const o=a.map(i=>({label:i.name,value:i.id,_type:"panel",parentID:t,viz:ei[i.viz.type]})),l="_Add_A_PANEL_";return o.push({label:l,value:l,_type:"ACTION",_action_type:l,parentID:t,Icon:null,children:null}),o}})).actions(e=>({replace(t){e.list=f.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const r=e.list.findIndex(a=>a.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})},duplicateByID(t){const r=e.list.find(o=>o.id===t);if(!r){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const a=new Date().getTime().toString();return e.list.push({...r.json,id:a,title:{...r.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(r.id,a),a},replaceByIndex(t,r){e.list.splice(t,1,r)}})),qD=$a.actions(e=>({getSchema(){const t=e.json,r=[],a=[];e.panels.forEach(i=>{const c=i.getSchema();r.push(c.panel),c.queries.length>0&&a.push(...c.queries)});const o=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:r,definition:{queries:y.uniqBy(a,i=>i.id)},layouts:o,version:lt}},downloadSchema(){if(e.type===B.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),r=e.name;Gt(r,t)}})),rd=f.types.compose("ViewsModel",Aa,f.types.model({current:f.types.optional(f.types.array(qD),[]),idOfVIE:f.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get tabViewOptions(){return this.options.filter(t=>t.type===B.Tabs)},tabOptions(t){const r=e.current.find(a=>a.id===t&&a.type===B.Tabs&&a.tabs.length>0);return r?r.tabs.map(a=>({label:a.name,value:a.id})):[]},get editorOptions(){const t=f.getRoot(e).content.panels;return e.current.map(r=>({label:r.name,value:r.id,_type:"view",children:t.editorOptions(r.id,r.panelIDs)}))},get contentModel(){return f.getRoot(e).content}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},resetIDOfVIE(){this.setIDOfVIE(e.current[0].id)},replace(t){e.current.replace(t)},addANewView(t,r,a,o){e.current.push({id:t,name:r,type:a,config:o,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);if(r===-1)return;const a=e.current[r],o=e.contentModel.panels,l=e.contentModel.layouts;o.removeByIDs(a.panelIDs),l.removeByPanelIDs(a.panelIDs),e.current.splice(r,1),this.resetIDOfVIE()},replaceByIndex(t,r){e.current.splice(t,1,r)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,B.Division,B.Division,{_name:B.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.resetIDOfVIE())}}));function as(e){const t=e.length>0?[e[0].id]:[],r=e.length>0?e[0].id:"";return{current:e.map(o=>{const{_name:l=o.type}=o.config;return{...o,config:{...o.config,_name:l},panelIDs:o.panelIDs}}),visibleViewIDs:t,idOfVIE:r}}const OD=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:Jc,queries:Rc,sqlSnippets:ed,views:rd,panels:nd,layouts:BD,mock_context:ua,origin:f.types.maybe(f.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get queriesChanged(){const t="queries.current",r=f.getSnapshot(y.get(e,t)).map(o=>y.pick(o,["id","name","key","type","run_by","pre_process","post_process","config"])),a=y.get(e.origin,t);return!y.isEqual(r,a)},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get viewsChanged(){const t="views.current";return!y.isEqual(e.views.json,y.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!y.isEqual(f.getSnapshot(y.get(e,t)),y.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!y.isEqual(y.get(e,t),y.get(e.origin,t))},get context(){const t=f.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=f.getParent(e).globalSQLSnippets,r={context:this.context,filters:e.filters.valuesForPayload};return{...r,sql_snippets:en(e.sqlSnippets.current,"key","value",r),global_sql_snippets:en(t.list,"id","content",r)}},get payloadForViz(){return{context:this.context,filters:e.filters.valuesForPayload}},get dashboardState(){const{context:t,filters:r}=this.payloadForViz,a={context:{},filters:e.filters.keyStateItemMap(r)};return Object.entries(t).forEach(([o,l])=>{a.context[o]={key:o,type:"context",value:l}}),a},get dashboardStateValues(){return _r(this.payloadForSQL)},get dashboardStateVariableOptions(){if(!f.isAlive(e))return{optionGroups:[],validValues:new Set};const t=new Set,{context:r}=this.payloadForSQL,a={group:"context.label",items:Object.keys(r).map(i=>{const c=`context.${i}`;return t.add(c),{label:i,value:c,description:void 0,type:"context"}})},o={group:"filter.labels",items:e.filters.keyLabelOptions.map(i=>{const c=`filters.${i.value}`;return t.add(c),{label:i.label,value:c,description:i.value,type:"filter",widget:i.widget}})};return{optionGroups:[a,o],validValues:t}},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardStateValues}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:r,data:a})=>({id:r,data:a})).reduce((r,a)=>(r[a.id]=a.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get filtersUsage(){const t=[],r=e.views.idMap;e.filters.current.forEach(o=>{o.visibleInViewsIDs.forEach(l=>{var i;t.push({filterID:o.id,type:"view",type_label:"view.label",id:l,label:((i=r.get(l))==null?void 0:i.name)??l})})});const a=e.filters.keyIDMap;return e.queries.current.forEach(o=>{o.usedFilterKeySet.forEach(l=>{t.push({filterID:a[l]??l,type:"query",type_label:"query.label",id:o.id,label:o.name})})}),e.sqlSnippets.usedFilterKeyMap.forEach((o,l)=>{o.forEach(i=>{t.push({filterID:a[i]??i,type:"sql_snippet",type_label:"sql_snippet.label",id:l,label:l})})}),y.groupBy(t,"filterID")},findFilterUsage(t){return this.filtersUsage[t]??[]},get queriesUsage(){const t=e.panels.idMap,r=[];e.views.current.forEach(o=>{o.panelIDs.forEach(l=>{const i=t.get(l);if(!i)return;const c="panel",d=i.name,u=[{id:o.id,label:o.name}];i.queryIDs.forEach(p=>{r.push({id:l,queryID:p,type:c,type_label:"panel.label",label:d,views:u})})})});const a=e.views.idMap;return e.filters.current.filter(o=>!!y.get(o,"config.options_query_id")).forEach(o=>{r.push({type:"filter",type_label:"filter.label",id:o.id,queryID:y.get(o,"config.options_query_id"),label:o.label,views:o.visibleInViewsIDs.map(l=>{var i;return{id:l,label:((i=a.get(l))==null?void 0:i.name)??l}})})}),e.queries.current.forEach(o=>{if(!o.isTransform)return;o.config.dep_query_ids.forEach(i=>{r.push({type:"transform-query",type_label:"query.transform.full_label",id:o.id,queryID:i,label:o.name,views:[]})})}),y.groupBy(r,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(r=>{if(!r.typedAsSQL)return;const a=r.config;y.uniq(a.sql.match(Et.sqlSnippet)).forEach(l=>{t.push({queryID:r.id,sqlSnippetKey:l,queryName:r.name})})}),y.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),r=e.queries.current.filter(a=>!t.has(a.id)).map(a=>a.id);e.queries.removeQueries(r)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),r=e.sqlSnippets.current.filter(a=>!t.has(a.key)).map(a=>a.key);e.sqlSnippets.removeByKeys(r)},duplicatePanelByID(t,r){var o;const a=e.panels.duplicateByID(t);a&&((o=e.views.findByID(r))==null||o.appendPanelID(a))},removePanelByID(t,r){var a;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(a=e.views.findByID(r))==null||a.removePanelID(t)},addANewPanel(t){var a;const r=Te.v4();e.panels.append(ec(r)),(a=e.views.findByID(t))==null||a.appendPanelID(r),e.layouts.addALayoutItem(r)},applyJSONSchema(t){var g;const{views:r,panels:a,filters:o,definition:l={},layouts:i}=t,{queries:c,sqlSnippets:d,mock_context:u}=l,p=new Map;if(Array.isArray(a)){const b=a.map(_=>{const w=Te.v4();return p.set(_.id,w),{..._,id:w}});if(e.panels.appendMultiple(b),!Array.isArray(r)||r.length===0){const _=b.map(w=>w.id);(g=e.views.VIE)==null||g.appendPanelIDs(_)}}if(Array.isArray(r)){const b=r.map(_=>{const w=_.panelIDs.map(x=>p.get(x)??x);return{..._,id:Te.v4(),panelIDs:w}});e.views.appendMultiple(b)}if(Array.isArray(i)){const b=(x,S)=>e.layouts.breakpointNameRecord[x]===S;let _=[];const w=i.filter(x=>b(x.name,x.breakpoint));w.forEach(x=>{x.id==="basis"&&(_=x.list),x.list.forEach(S=>{const D=p.get(S.panelID);S.id=Te.v4(),S.panelID=D})}),e.layouts.list.forEach(x=>{const S=w.find(D=>D.name===x.name&&D.breakpoint===x.breakpoint);if(!S){_.forEach(D=>{x.addLayout(D)});return}S.list.forEach(D=>{x.addLayout(D)})})}Array.isArray(o)&&e.filters.appendMultiple(o),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(d)&&e.sqlSnippets.appendMultiple(d),u&&Object.keys(u).length>0&&e.mock_context.defaults(u)}})).actions(e=>({reset(){f.applySnapshot(e.filters.current,e.origin.filters.current),f.applySnapshot(e.queries.current,e.origin.queries.current),f.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),f.applySnapshot(e.views.current,e.origin.views.current),f.applySnapshot(e.panels.list,e.origin.panels.list),f.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){f.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:r,name:a,content:o}=t;if(!o)throw new Error("unexpected null content when updating a content model");const{version:l,filters:i,views:c,panels:d,definition:{queries:u,sqlSnippets:p,mock_context:g={}}}=o;e.id=r,e.name=a,e.version=l,f.applySnapshot(e.filters.current,i),f.applySnapshot(e.views.current,as(c).current),f.applySnapshot(e.panels.list,d),f.applySnapshot(e.queries.current,u),f.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=g}})),ss=f.types.snapshotProcessor(OD,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=f.castToSnapshot(e.queries.current.map(r=>y.pick(r,["id","key","type","sql"])));return y.defaults({},{queries:{current:t}},e)}});function LD(e,t){t.filters&&f.applySnapshot(e.filters.current,t.filters)}function ad({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,content:l},i,c){if(!l)throw new Error("unexpected null content when creating a content model");const{version:d,filters:u,views:p,panels:g,layouts:b,definition:{queries:_,sqlSnippets:w,mock_context:x={}}}=l;return ss.create({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,version:d,filters:Oa(u,i,x,c),queries:{current:_},sqlSnippets:{current:w},mock_context:pa(x),views:as(p),panels:{list:g},layouts:{list:b,currentBreakpoint:b[0].id}})}const sd=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:ss,content_id:f.types.string,datasources:SD,globalSQLSnippets:Va,context:Bn,editor:ED}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}},get queryVariables(){return{context:{...e.content.mock_context.current,...e.context.current},filters:e.content.filters.previewValues}},get queryVariablesString(){return JSON.stringify(this.queryVariables,null,2)}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,r){const{id:a,name:o,group:l,content_id:i}=t;e.id=a,e.name=o,e.group=l,e.content_id=i,this.updateCurrentContent(r)}}));function od({id:e,name:t,group:r,content_id:a},o,l,i,c,d){return sd.create({id:e,name:t,group:r,content_id:a,content:ad(o,c,d),datasources:{list:l},globalSQLSnippets:{list:i},context:Pa(c),editor:{}})}function Ft(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function ld(e,t){h.useEffect(()=>{const a=o=>{Ft(o);const{viewID:l}=o.detail;if(!l){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(l),t&&e.views.setIDOfVIE(l)};return window.addEventListener("open-view",a),()=>{window.removeEventListener("open-view",a)}},[e,t]);const r=Eu.useNavigate();h.useEffect(()=>{const a=o=>{Ft(o);const{panelID:l}=o.detail;if(!l){console.error(new Error("[Scroll to Panel] Needs to pick a panel first"));return}r(`#${l}`),setTimeout(()=>{const i=document.getElementById(l);i&&i.scrollIntoView({behavior:"smooth"})},300)};return window.addEventListener("scroll_to_panel",a),()=>{window.removeEventListener("scroll_to_panel",a)}},[r]),h.useEffect(()=>{const a=o=>{Ft(o);const{viewID:l,tab:i}=o.detail;if(!l){console.error(new Error("[Switch Tab] Needs to pick a view and a tab first"));return}const c=e.views.findByID(l);if(!c){console.error(new Error(`[Switch Tab] View by ID[${l}] is not found`));return}c.setTab(i)};return window.addEventListener("switch_tab",a),()=>{window.removeEventListener("switch_tab",a)}},[e,t]),h.useEffect(()=>{const a=o=>{Ft(o);const{dictionary:l,payload:i}=o.detail;if(!i||Object.keys(i).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const c={};Object.entries(l).forEach(([d,u])=>{const p=y.get(i,u);c[d]=p}),e.filters.applyValuesPatch(c)};return window.addEventListener("set-filter-values",a),()=>{window.removeEventListener("set-filter-values",a)}},[e]),h.useEffect(()=>{function a(l){return Array.isArray(l)?[]:typeof l=="object"?{}:typeof l=="boolean"?!1:typeof l=="string"?"":typeof l=="number"?0:l}const o=l=>{Ft(l);const i={},{filter_keys:c}=l.detail;c.forEach(d=>{const u=y.get(e.filters.values,d),p=a(u);i[d]=p}),e.filters.applyValuesPatch(i)};return window.addEventListener("clear-filter-values",o),()=>{window.removeEventListener("clear-filter-values",o)}},[e]),h.useEffect(()=>{const a=o=>{Ft(o);const{urlTemplate:l,openInNewTab:i,enableEncoding:c=!1,payload:d}=o.detail;if(!l){console.error(new Error("[Open Link] URL is empty"));return}function u(b){return y.cloneDeepWith(b,w=>{if(c&&typeof w=="string")return encodeURIComponent(w)})}const g=y.template(l||"")(u({...d,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(g,i?"_blank":"_self","noopener")};return window.addEventListener("open-link",a),()=>{window.removeEventListener("open-link",a)}},[e])}function id(e){return h.useCallback(t=>t.provideValue(ee.pluginManager,e.pluginManager).provideValue(ee.vizManager,e.vizManager).provideValue(ee.panelAddonManager,e.panelAddonManager).provideValue(ee.colorManager,e.colorManager),[e])}const l6="",ND=k.observer(({saveDashboardChanges:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=F(),o=()=>{r.openConfirmModal({title:n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(T.IconAlertTriangle,{size:18,color:"red"}),n.jsx(s.Text,{size:"sm",children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>a.reset(),zIndex:320,withCloseButton:!1})},l=a.changed;return n.jsxs(s.Group,{gap:0,children:[n.jsx(s.Button,{color:"green",variant:"filled",size:"xs",leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),onClick:e,disabled:!l,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),n.jsxs(s.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!l,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"default",disabled:!l,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:n.jsx(T.IconCaretDown,{size:18})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconRecycle,{size:14,color:"red"}),disabled:!l,onClick:o,children:t("common.actions.revert_changes")})})]})]})}),GD=k.observer(({saveDashboardChanges:e,onExit:t,headerSlot:r=null})=>{m.useTranslation();const a=j(),o=a.content.changed,l=()=>{t({hasChanges:o,dashboardId:a.id})};return n.jsx(s.AppShell.Header,{h:60,py:0,px:"md",sx:{zIndex:299},children:n.jsxs(s.Group,{justify:"space-between",sx:{height:60,minWidth:"1000px",position:"relative"},children:[n.jsxs(s.Group,{children:[n.jsx(s.Button,{size:"xs",color:o?"red":"green",leftSection:n.jsx(T.IconArrowLeft,{size:20}),onClick:l,children:n.jsx(s.Group,{gap:4,children:n.jsx(m.Trans,{i18nKey:"common.actions.end_editing",values:{name:a.name},children:n.jsx(s.Text,{td:"underline",size:"xs",children:a.name})})})}),n.jsx(ND,{saveDashboardChanges:e})]}),n.jsx(s.Group,{justify:"flex-end",sx:{flexGrow:1},children:r})]})})}),cd={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},FD=k.observer(()=>{var o;const{t:e}=m.useTranslation(),t=F(),r=((o=t.views.VIE)==null?void 0:o.type)===B.Tabs,a=()=>t.addANewPanel(t.views.idOfVIE);return r?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),sx:{...cd,transform:"none !important"},children:e("panel.add")})}):n.jsx(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:a,leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),sx:{...cd,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),QD=k.observer(({done:e})=>{var E,U;const{t}=m.useTranslation(),a=F().layouts,o=h.useMemo(()=>({list:a.breakpointsInfo}),[a.breakpointsInfo]),{control:l,handleSubmit:i,watch:c,getValues:d,reset:u,formState:p}=v.useForm({defaultValues:o}),{fields:g,append:b,remove:_}=v.useFieldArray({control:l,name:"list",rules:{validate:N=>{if(y.uniqBy(N,"breakpoint").length!==N.length)return"Screen sizes should be unique by min width"}}}),w=c("list"),x=g.map((N,oe)=>({...N,...w[oe]})),S=()=>{b({id:Te.v4(),name:"",breakpoint:""})},D=({list:N})=>{const oe=N.filter(be=>Number.isFinite(be.breakpoint));a.updateLayoutSetsInfo(oe),e()},z=d(),I=h.useMemo(()=>{const N={list:z.list.filter(oe=>!!oe.name&&Number.isFinite(oe.breakpoint))};return!y.isEqual(N,o)},[z,o]),A=(U=(E=p.errors.list)==null?void 0:E.root)==null?void 0:U.message;return n.jsx(n.Fragment,{children:n.jsxs("form",{onSubmit:i(D),children:[n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,withTableBorder:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"340px"},children:t("common.name")}),n.jsx(s.Table.Th,{style:{width:"160px"},children:t("breakpoint.breakpoint")}),n.jsx(s.Table.Th,{})]})}),n.jsxs(s.Table.Tbody,{children:[x.map((N,oe)=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:N.id==="basis"?N.name:n.jsx(v.Controller,{name:`list.${oe}.name`,control:l,render:({field:be})=>n.jsx(s.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...be})})}),n.jsx(s.Table.Td,{children:N.id==="basis"?n.jsxs(s.Text,{size:"sm",ff:"monospace",children:[N.breakpoint,"px"]}):n.jsx(v.Controller,{name:`list.${oe}.breakpoint`,control:l,render:({field:be})=>n.jsx(s.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:n.jsx(s.Text,{size:"sm",c:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1},ff:"monospace",styles:{input:{paddingRight:"30px"}},...be})})}),n.jsx(s.Table.Td,{children:N.id!=="basis"&&n.jsx(s.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>_(oe),children:n.jsx(T.IconTrash,{})})})]},N.id)),n.jsx(s.Table.Tr,{style:{backgroundColor:"transparent"},children:n.jsx(s.Table.Td,{colSpan:3,style:{padding:"0"},children:n.jsx(s.Tooltip,{label:t("breakpoint.add"),children:n.jsx(s.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:S,sx:{width:"100%"},children:n.jsx(T.IconPlus,{size:18})})})})})]})]}),n.jsx(s.Text,{mt:6,ta:"right",size:"xs",c:"red",children:A??" "}),n.jsxs(s.Group,{mt:6,justify:"space-between",children:[n.jsx(s.Button,{color:"orange",size:"xs",onClick:()=>u(),leftSection:n.jsx(T.IconRecycle,{size:18}),disabled:!I,children:t("common.actions.revert")}),n.jsx(s.Button,{color:"green",size:"xs",type:"submit",leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),disabled:!I,children:t("common.actions.save_changes")})]})]})})}),jD=k.observer(()=>{const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1),o=F(),l=o.layouts.currentBreakpoint,i=o.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},d=()=>{a(),c()};return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsxs(s.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{size:"xs",variant:"subtle",leftSection:n.jsx(T.IconDevices,{size:16}),sx:{borderRadius:0},children:n.jsxs(s.Group,{gap:6,children:[n.jsx(s.Text,{size:"xs",fw:"normal",children:i.name}),n.jsx(s.Text,{size:"xs",c:"#777",children:o.layouts.currentRangeText})]})})}),n.jsxs(s.Menu.Dropdown,{children:[o.layouts.breakpointRanges.map(u=>n.jsx(s.Menu.Item,{onClick:()=>o.layouts.setCurrentBreakpoint(u.id),disabled:l===u.id,children:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{size:"sm",children:u.name}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:u.text})]})},u.id)),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{color:"blue",leftSection:n.jsx(T.IconSettings,{size:14}),onClick:r,children:n.jsx(s.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),o.layouts.divisionPreviewScale<1&&n.jsx(s.Text,{size:"xs",c:"dimmed",children:Ee(o.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),n.jsx(s.Modal,{opened:t,onClose:d,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:n.jsx(QD,{done:d})})]})}),dd={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},WD=k.observer(()=>{var o;const{t:e}=m.useTranslation(),t=F(),r=((o=t.views.VIE)==null?void 0:o.type)===B.Tabs,a=()=>{var l;return(l=t.views.VIE)==null?void 0:l.downloadSchema()};return r?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconCode,{size:16}),sx:{...dd,transform:"none !important"},children:e("view.download_schema")})}):n.jsx(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:a,leftSection:n.jsx(T.IconCode,{size:16}),sx:{...dd},children:e("view.download_schema")})}),Gn=({headers:e,rows:t})=>n.jsxs(s.Table,{fz:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[n.jsx(s.Table.Thead,{children:e}),n.jsx(s.Table.Tbody,{children:t})]}),UD=({content:e})=>{const{t}=m.useTranslation(),r=e.views;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),n.jsx(Gn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{children:t("common.type")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.name}),n.jsx(s.Table.Td,{children:t(`view.component.${a.type}.label`)})]},a.id))})]})},KD=({content:e})=>{const{t}=m.useTranslation(),r=e.filters;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),n.jsx(Gn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.key")}),n.jsx(s.Table.Th,{children:t("common.label")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.key}),n.jsx(s.Table.Td,{children:a.label})]},a.id))})]})},YD=({content:e})=>{const{t}=m.useTranslation(),r=e.panels;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),n.jsx(Gn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{children:t("visualization.component")})]}),rows:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.id}),n.jsx(s.Table.Td,{children:a.name}),n.jsx(s.Table.Td,{children:a.viz.type})]},a.id))})]})},XD=({content:e})=>{var a;const{t}=m.useTranslation(),r=(a=e.definition)==null?void 0:a.queries;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),n.jsx(Gn,{headers:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(s.Table.Th,{children:t("common.name")}),n.jsx(s.Table.Th,{style:{width:"140px"},children:t("common.type")}),n.jsx(s.Table.Th,{style:{width:"260px"},children:t("data_source.label")})]}),rows:r.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:o.id}),n.jsx(s.Table.Td,{children:o.name}),n.jsx(s.Table.Td,{children:o.type}),n.jsx(s.Table.Td,{children:o.key})]},o.id))})]})},ZD=({content:e})=>{var a;const{t}=m.useTranslation(),r=(a=e.definition)==null?void 0:a.sqlSnippets;return!Array.isArray(r)||r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),n.jsx(s.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(T.IconPointFilled,{size:10}),children:r.map(o=>n.jsx(s.List.Item,{children:o.key},o.key))})]})},JD=({content:e})=>{var a;const{t}=m.useTranslation(),r=Object.keys(((a=e.definition)==null?void 0:a.mock_context)??{});return r.length===0?null:n.jsxs(s.Box,{children:[n.jsx(s.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),n.jsx(s.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(T.IconPointFilled,{size:10}),children:r.map(o=>n.jsx(s.List.Item,{children:o},o))})]})},HD=({content:e})=>e?n.jsxs(s.Box,{children:[n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(s.Text,{ta:"left",c:"dimmed",size:"sm",children:"Preview"}),n.jsxs(s.Stack,{children:[n.jsx(UD,{content:e}),n.jsx(KD,{content:e}),n.jsx(YD,{content:e}),n.jsx(XD,{content:e}),n.jsx(ZD,{content:e}),n.jsx(JD,{content:e})]})]}):null;function RD(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==lt)throw new Error("Schema version mismatch");return t}const ez=k.observer(({onSuccess:e,stretchModal:t,shrinkModal:r})=>{var D,z;const{t:a}=m.useTranslation(),o=F(),{handleSubmit:l,formState:{errors:i},setValue:c,watch:d,setError:u,clearErrors:p}=v.useForm({defaultValues:{content:null}}),g=({content:I})=>{try{if(!I)throw new Error("please use a valid json file");o.applyJSONSchema(I),Fe.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(A){console.error(A),Fe.showNotification({title:"Failed",message:A.message,color:"red"})}},[b,_]=h.useState(null);h.useEffect(()=>{if(!b)return;const I=new FileReader;I.readAsText(b,"UTF-8"),I.onload=A=>{try{const E=RD(A);c("content",E),p("content")}catch(E){console.error(E),u("content",{type:"custom",message:E.message})}},I.onabort=()=>console.log("🟨 abort"),I.onerror=()=>{I.error&&(console.error(I.error),u("content",{type:"custom",message:I.error.message}))}},[b]);const[w]=d(["content"]),x=!w,S=(D=i==null?void 0:i.content)==null?void 0:D.message;return h.useEffect(()=>{!w||S?r():t()},[w,S]),n.jsx(s.Box,{mx:"auto",sx:{position:"relative"},children:n.jsxs("form",{onSubmit:l(g),children:[n.jsx(s.FileInput,{label:a("import.json_file"),required:!0,value:b,onChange:_,error:(z=i==null?void 0:i.content)==null?void 0:z.message,sx:{maxWidth:500}}),S?n.jsx(s.Table,{fz:12,mt:10,children:n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:a("import.this_dashboard")}),n.jsx(s.Table.Td,{children:lt})]}),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:a("import.this_file")}),n.jsx(s.Table.Td,{style:{color:"red"},children:w==null?void 0:w.version})]})]})}):n.jsxs(n.Fragment,{children:[n.jsx(HD,{content:w}),n.jsx(s.Group,{justify:"flex-end",my:"md",children:n.jsx(s.Button,{type:"submit",color:"green",disabled:x,children:a("common.actions.confirm")})})]})]})})}),ud={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},tz=k.observer(()=>{var u;const{t:e}=m.useTranslation(),[t,{open:r,close:a}]=te.useDisclosure(!1),[o,{setTrue:l,setFalse:i}]=O.useBoolean(!1),d=((u=j().content.views.VIE)==null?void 0:u.type)===B.Tabs;return d?n.jsx(s.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(s.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(T.IconFileImport,{size:16}),sx:{...ud,transform:"none !important"},children:e("import.label")})}):n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:d||t,onClick:r,leftSection:n.jsx(T.IconFileImport,{size:16}),sx:{...ud},children:e("import.label")}),n.jsx(s.Modal,{opened:t,onClose:a,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:o?"90vw":500,children:n.jsx(ez,{onSuccess:a,stretchModal:l,shrinkModal:i})})]})}),nz=({iconKey:e,...t})=>{switch(e){case"query_variables":return n.jsx(T.IconVariable,{...t});case"mock_context":return n.jsx(T.IconCodeDots,{...t});case"filter":return n.jsx(T.IconFilter,{...t});case"sql_snippet":return n.jsx(T.IconCopy,{...t});case"query":return n.jsx(T.IconDatabase,{...t});case"view":return n.jsx(T.IconBoxMultiple,{...t});case"panel":return n.jsx(T.IconAppWindow,{...t});default:return null}},rz=({action:e})=>{const{t}=m.useTranslation();return e.description?n.jsx(s.Text,{c:"dimmed",size:"xs",children:t(e.description)}):e.viz?n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{c:"dimmed",size:"xs",children:t(e.viz.displayName)}),n.jsx(s.Text,{c:"dimmed",size:"xs",className:"spotlight-action-viz-group",children:t(e.viz.displayGroup)})]}):null},az=k.observer(({action:e,query:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Box,{className:"spotlight-custom-action-component",children:n.jsxs(s.Group,{wrap:"nowrap",children:[n.jsx(nz,{iconKey:e.iconKey,size:14}),n.jsxs("div",{style:{flex:1},children:[n.jsx(s.Highlight,{highlight:t,size:"sm",children:e.title?r(e.title):""}),n.jsx(rz,{action:e})]})]})})}),sz=({groups:e,query:t})=>{const{t:r}=m.useTranslation();return e.length===0?n.jsx(xt.Spotlight.Empty,{children:r("spotlight.not_found")}):n.jsx(n.Fragment,{children:e.map(a=>n.jsx(xt.Spotlight.ActionsGroup,{label:a.group,children:a.actions.map(o=>n.jsx(xt.Spotlight.Action,{onClick:o.onClick,children:n.jsx(az,{action:o,query:t})},o.id))},a.group))})},oz=k.observer(()=>{const{t:e,i18n:t}=m.useTranslation(),r=s.useMantineTheme(),a=j(),[o,l]=h.useState(""),i=h.useMemo(()=>a.editor.spotlightActionGroups.map(d=>({group:e(d.group),keywords:[d.group,e(d.group)],actions:d.actions.map(u=>{const p=[];return u.title&&(p.push(u.title.toLowerCase()),p.push(e(u.title).toLowerCase())),u.group&&p.push(u.group.toLowerCase()),u.viz&&(p.push(u.viz.displayGroup.toLowerCase()),p.push(u.viz.displayName.toLowerCase())),u.iconKey&&p.push(u.iconKey),{...u,keywords:p}})})),[a.editor.spotlightActionGroups,t.language]),c=h.useMemo(()=>{const d=o.toLowerCase().trim();return d?i.map(p=>{if(p.keywords.some(_=>_.includes(d)))return p;const b=p.actions.filter(_=>_.keywords.some(w=>w.includes(d)));return b.length===0?null:{...p,actions:b}}).filter(p=>p!==null):[i[0]]},[i,o]);return n.jsxs(xt.Spotlight.Root,{onQueryChange:l,shortcut:["mod + P","mod + K"],radius:"md",styles:{search:{border:"none"},action:{position:"relative",display:"block",width:"100%",padding:`${s.rem(10)} ${s.rem(12)}`,borderRadius:r.radius.sm,".spotlight-action-viz-group":{opacity:0},"&:hover, &[data-selected]":{backgroundColor:r.colors.gray[1],".spotlight-action-viz-group":{opacity:1}}}},children:[n.jsx(xt.Spotlight.Search,{placeholder:e("spotlight.placeholder"),leftSection:n.jsx(T.IconSearch,{size:"1.2rem"})}),n.jsx(xt.Spotlight.ActionsList,{children:n.jsx(sz,{groups:c,query:o})})]})}),pd=({children:e})=>n.jsx(s.Text,{style:{fontSize:"0.6875rem",lineHeight:1,padding:"0.25rem 0.2375rem",borderRadius:"0.25rem"},children:e}),hd=function(){var t;return(((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform).toLowerCase().includes("mac")}(),lz=()=>{const{t:e}=m.useTranslation();return n.jsx(s.Tooltip,{label:n.jsxs(n.Fragment,{children:[hd&&n.jsx(pd,{children:"⌘ + K"}),!hd&&n.jsx(pd,{children:"Ctrl + K"})]}),children:n.jsx(s.UnstyledButton,{onClick:()=>xt.spotlight.open(),style:{height:"1.875rem",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",paddingLeft:"calc(0.875rem / 1.5)",paddingRight:"1rem"},sx:{color:"#228be6",background:"transparent","&:hover":{background:"rgb(231, 245, 255)"}},children:n.jsxs(s.Group,{gap:"0.625rem",children:[n.jsx(T.IconSearch,{size:"1rem",color:"#228be6"}),n.jsx(s.Text,{fw:500,style:{flexGrow:1,fontWeight:500,fontSize:"0.75rem",lineHeight:1},children:e("spotlight.trigger_text")})]})})})},iz={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},cz=k.observer(()=>n.jsx(s.Box,{sx:iz,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:n.jsxs(s.Group,{justify:"space-between",align:"center",sx:{height:"30px"},children:[n.jsxs(s.Group,{justify:"flex-start",gap:0,children:[n.jsx(FD,{}),n.jsx(tz,{}),n.jsx(lz,{})]}),n.jsx(jD,{}),n.jsx(s.Group,{justify:"flex-end",gap:0,children:n.jsx(WD,{})})]})})),dz=k.observer(e=>n.jsxs(n.Fragment,{children:[n.jsx(GD,{...e}),n.jsx(cz,{})]}));function uz(e,t,r){const a=[];return e.filter(o=>"__INTERACTIONS"in o.viz.conf).forEach((o,l)=>{const i=t[o.id];i.data.interactions=y.get(i,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:d,__TRIGGERS:u}=o.viz.conf;Object.entries(d).forEach(([p,g])=>{const{schemaRef:b,data:_}=g,{config:w}=_;switch(b){case"builtin:op:open-link":let x=w.urlTemplate.substring(0,100);w.urlTemplate.length>=20&&(x+="..."),i.type="interaction",i.data.interactions.push({schemaRef:b,urlTemplate:w.urlTemplate,shortURLTemplate:x});return;case"builtin:op:open_view":a.push({id:`OPERATION--${p}`,source:o.id,target:w.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":i.type="interaction",i.data.interactions.push({schemaRef:b,filters:Object.keys(w.dictionary).map(S=>({key:S,label:r[S]}))});return;case"builtin:op:clear_filter_values":i.type="interaction",i.data.interactions.push({schemaRef:b,filters:w.filter_keys.map(S=>({key:S,label:r[S]}))});return;default:return}})}),a}function pz(e,t){const r=e.filters.keyLabelMap;return{edges:uz(e.panels.list,t,r),edgeNodes:[]}}function gd(e,t,r){return e*t+e*r}function hz(e,t,r){return e*t+(e-1)*r}const Fn=25,os=40,fd=25,ls=350,gz=150,fz=150,bd=150,yd=300,Qn=40,vd=25,bz=300;function yz(e,t){const r=y.keyBy(t,o=>o.id),a=[];return e.current.forEach((o,l)=>{o.panelIDs.forEach((i,c)=>{const d=gd(c,Qn,vd)+os,u=r[i];if(!u){a.push({id:i,_node_type:"panel",parentNode:o.id,data:{label:`!: ${i}`},position:{x:Fn,y:d},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,style:{width:yd,height:Qn}});return}const p=u.name;a.push({id:u.id,_node_type:"panel",parentNode:o.id,data:{label:p},position:{x:Fn,y:d},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,style:{width:yd,height:Qn}})})}),a}const vz={[B.Division]:"Div",[B.Modal]:"Modal",[B.Tabs]:"Tabs"},_z=Xc;function mz(e){return e.current.map((r,a)=>{const o=hz(r.panelIDs.length,Qn,vd)+os+fd;let l=[];return r.type===B.Tabs&&(l=r.config.tabsInOrder.map(c=>c.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:l,data:{label:`${vz[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:ie.Position.Right,targetPosition:ie.Position.Left,className:"light",style:{backgroundColor:_z[r.type],width:ls,height:o}}})}function wz(e){const t=y.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==B.Tabs||r._tab_view_ids.forEach(a=>{t[a].parentNode=r.id})})}function xz(e){const t=mz(e.views);wz(t);const r=yz(e.views,e.panels.list);return[...t,...r]}function Cz({nodeMap:e,nodes:t,edges:r}){t.forEach(a=>{a._node_type!=="view-root"||a._view_type!==B.Tabs||(a.sourcePosition=ie.Position.Bottom,a.style.width=ls+Fn*2,a.style.height=fd+a._tab_view_ids.reduce((o,l)=>{const i=e[l];i.position.y=o,i.position.x=Fn;const c=i.style.height;return o+c+20},os))})}function Sz({nodeMap:e,nodes:t,edges:r}){r.filter(a=>a.label==="Open View").forEach(a=>{const o=e[a.source],l=e[a.target];if(!o||!l||!o.parentNode)return;const i=e[o.parentNode];i._node_type!=="view-root"||l._node_type!=="view-root"||(l._view_level+=1+i._view_level,i._sub_view_ids.push(l.id))}),t.sort((a,o)=>a._node_type==="view-root"&&o._node_type==="view-root"?a._view_level-o._view_level:a._node_type!=="view-root"&&o._node_type!=="view-root"?0:a._node_type==="view-root"?-1:1)}function Tz({nodeMap:e,nodes:t,edges:r}){const a={};r.forEach(o=>{if(o.label!=="Open View")return;const l=e[o.source],i=e[o.target];if(l&&i&&l.parentNode){const c=e[l.parentNode],d=c.position.x,u=Number(y.get(i,"style.height",0)),p=Number(c.style.width);i.position.x=d+p+bz,c._view_level===0&&i._sub_view_ids.length===0&&(l.sourcePosition=ie.Position.Left,i.targetPosition=ie.Position.Right,i.position.x*=-1);const b=i.position.x,_=y.get(a,b,0);i.position.y=_,a[b]=_+u+bd}})}function kz({nodeMap:e,nodes:t,edges:r}){const a=new Set,o=new Set;r.forEach(i=>{a.add(i.source),o.add(i.target)}),t.filter(i=>i._node_type!=="view-root"||i.id==="Main"||i.parentNode?!1:!a.has(i.id)&&!o.has(i.id)).forEach((i,c)=>{i.position.x=gd(c,ls,fz),i.position.y=0-gz-bd})}function Dz({nodeMap:e,nodes:t,edges:r}){const a={nodeMap:e,nodes:t,edges:r};return kz(a),Sz(a),Cz(a),Tz(a),{nodes:t,edges:r}}function zz(e){const t=xz(e),r=y.keyBy(t,d=>d.id),{edges:a,edgeNodes:o}=pz(e,r),l=[...t,...o],i=y.keyBy(l,d=>d.id),c={edges:y.uniqBy(a,d=>d.id),nodes:l,nodeMap:i};return Dz(c)}const i6="",is={"builtin:op:open-link":n.jsx(s.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n.jsx(T.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n.jsx(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(T.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n.jsx(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(T.IconCircleOff,{size:14})})};function Mz(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:is[r.schemaRef],text:n.jsxs(s.Group,{gap:4,children:[n.jsx(s.Text,{size:"sm",children:"Open: "}),n.jsx(s.Text,{size:"sm",c:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:a,label:o})=>{t.push({key:r.schemaRef+a,icon:is[r.schemaRef],text:n.jsx(s.Group,{gap:4,children:n.jsxs(s.Text,{size:"sm",children:["Set Filter: ",o]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:a,label:o})=>{t.push({key:r.schemaRef+a,icon:is[r.schemaRef],text:n.jsx(s.Group,{gap:4,children:n.jsxs(s.Text,{size:"sm",children:["Clear Filter: ",o]})})})});return}}),t}const Iz=h.memo(({data:e,isConnectable:t,sourcePosition:r=ie.Position.Right,targetPosition:a=ie.Position.Left,...o})=>{const l=h.useMemo(()=>Mz(e.interactions),[e.interactions]);return n.jsxs(n.Fragment,{children:[n.jsx(ie.Handle,{type:"target",position:a,isConnectable:t}),n.jsx(s.Box,{sx:{position:"absolute",top:0,right:0},children:n.jsx(T.IconChevronsUpRight,{size:12})}),n.jsxs(s.HoverCard,{shadow:"xl",withinPortal:!0,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Text,{size:"sm",children:e.label})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.List,{spacing:"xs",size:"sm",center:!0,children:l.map(i=>n.jsx(s.List.Item,{icon:i.icon,children:i.text},i.key))})})]}),n.jsx(ie.Handle,{type:"source",position:r,isConnectable:t})]})}),c6="",Vz={interaction:Iz},Pz=k.observer(()=>{const e=H(),{edges:t,nodes:r}=zz(e);return n.jsxs(ie,{nodes:r,edges:t,onNodesChange:y.noop,onEdgesChange:y.noop,onConnect:y.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Vz,children:[n.jsx(ie.MiniMap,{}),n.jsx(ie.Controls,{}),n.jsx(ie.Background,{})]})}),$z=k.observer(({opened:e,close:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Modal,{size:"96vw",opened:e,onClose:t,title:r("interactions.interactions_viewer"),trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:n.jsx(Pz,{})})}),Az={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function Ez({onClick:e,name:t,active:r,openSettings:a}){return n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.UnstyledButton,{sx:o=>({display:"block",width:"100%",padding:o.spacing.xs,borderRadius:0,position:"relative",color:o.black,"&:hover":{backgroundColor:o.colors.gray[0]},backgroundColor:r?o.colors.gray[2]:"transparent"}),children:n.jsx(s.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n.jsx(s.Text,{size:"sm",children:t})})}),r&&n.jsx(s.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n.jsx(s.ActionIcon,{onClick:a,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n.jsx(T.IconAdjustments,{size:16})})})]})}const Bz=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=F(),a=h.useCallback(l=>()=>r.views.setIDOfVIE(l),[r]),o=l=>{t.editor.open(["_VIEWS_",l])};return n.jsxs(s.Box,{sx:{position:"relative"},children:[r.views.options.map(l=>n.jsx(Ez,{active:r.views.idOfVIE===l.value,name:l.label,onClick:a(l.value),openSettings:()=>o(l.value)},l.value)),n.jsx(s.Divider,{variant:"dashed"}),n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:r.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),qz=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=F(),a=()=>{if(!r.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",r.queries.firstID])},o=()=>{if(!r.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",r.filters.firstID])},[l,i]=h.useState(!1),c=()=>i(!0),d=()=>i(!1);return n.jsxs(s.AppShell.Navbar,{p:0,zIndex:299,children:[n.jsxs(s.AppShell.Section,{children:[n.jsxs(s.Group,{grow:!0,gap:0,sx:{...Az,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n.jsx(s.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:o,children:n.jsx(T.IconFilter,{size:18})})}),n.jsx(s.Tooltip,{label:e("query.labels"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:a,children:n.jsx(T.IconDatabase,{size:18})})}),n.jsx(s.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:n.jsx(T.IconRoute,{size:18})})})]}),n.jsx($z,{opened:l,close:d})]}),n.jsx(s.AppShell.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),n.jsx(s.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(Bz,{})}),n.jsx(s.AppShell.Section,{children:n.jsx(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(s.Button,{size:"xs",leftSection:n.jsx(T.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),Oz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.default_value,onChange:a=>r.setDefaultValue(a.currentTarget.checked),label:t("filter.widget.checkbox.default_checked")}),n.jsx(_t,{filter:e})]}),n.jsx(gn,{label:t("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}},e.id)]})}),Lz=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],Nz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config,o=h.useMemo(()=>{const i=Si();return Object.entries(i).map(([c,d])=>({group:r(`filter.widget.date_range.shortcut.${c}.label`),items:d.map(({key:u,value:p})=>({label:r(`filter.widget.date_range.shortcut.${c}.full.${u}`),value:p}))}))},[]),l=[...a.default_value];return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsx(s.Checkbox,{checked:a.required,onChange:i=>a.setRequired(i.currentTarget.checked),label:r("filter.widget.date_range.required")}),n.jsx(s.Checkbox,{checked:a.allowSingleDateInRange,onChange:i=>a.setAllowSingleDateInRange(i.currentTarget.checked),label:r("filter.widget.date_range.allow_single_date")})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.Select,{data:Lz,label:r("filter.widget.date_range.display_format"),value:a.inputFormat,onChange:a.setInputFormat}),n.jsx(s.NumberInput,{label:r("filter.widget.date_range.max_days"),min:0,value:a.max_days,onChange:a.setMaxDays,hideControls:!0})]}),n.jsxs(s.Group,{children:[n.jsx(wc,{label:r("filter.widget.date_range.default_value"),config:a,value:{value:l,shortcut:null},onChange:a.setDefaultValue,disabled:!!a.default_shortcut}),n.jsx(s.Select,{data:o,label:r("filter.widget.date_range.default_by_shortcut"),value:a.default_shortcut,onChange:a.setDefaultShortcut,placeholder:r("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),n.jsx(_t,{filter:t})]})}),Gz=`
|
|
547
547
|
// row
|
|
548
548
|
{
|
|
549
549
|
label: string;
|
|
550
550
|
value: string;
|
|
551
551
|
description?: string; // optional
|
|
552
552
|
}
|
|
553
|
-
`,_d=()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(a=>!a),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(s.Collapse,{in:t,children:n.jsx(Qe.CodeHighlight,{language:"typescript",withCopyButton:!1,code:Nz})})]})},Gz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config,o=()=>{a.addStaticOption({label:"",value:""})},l=a.static_options,i=l.filter(c=>c.value!==""&&c.label!=="");return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:a.required,onChange:c=>a.setRequired(c.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(_t,{filter:t})]}),n.jsx(s.TextInput,{label:r("filter.widget.select.width"),description:r("filter.widget.multi_select.width_description"),value:a.min_width,onChange:c=>a.setMinWidth(c.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:r("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(s.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[a.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(s.Text,{c:"white",size:"16px",children:r("filter.widget.common.using_query")})})]}),i.length>0&&n.jsx(s.MultiSelect,{label:r("filter.widget.select.default_selection"),placeholder:r("filter.widget.select.no_default_selection"),data:i,value:[...a.default_value],onChange:a.setDefaultValue}),l.map((c,d)=>n.jsxs(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(s.TextInput,{label:r("common.label"),required:!0,value:a.static_options[d].label,onChange:u=>{a.static_options[d].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.TextInput,{label:r("common.value"),required:!0,value:a.static_options[d].value,onChange:u=>{a.static_options[d].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>a.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:n.jsx(T.IconTrash,{size:16})})]},d)),n.jsx(s.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:o,sx:{width:"50%"},mx:"auto",children:r("common.actions.add_an_option")})]}),n.jsx(s.Divider,{label:r("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx($n,{value:a.options_query_id,onChange:a.setOptionsQueryID}),n.jsx(s.NumberInput,{value:a.default_selection_count,onChange:a.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(wa,{config:a}),n.jsx(_d,{})]})}),md={date_unit:{zh:[{label:"天",value:"day"},{label:"周",value:"week"},{label:"双周",value:"bi-week"},{label:"月",value:"month"},{label:"季度",value:"quarter"},{label:"年",value:"year"}],en:[{label:"Day",value:"day"},{label:"Week",value:"week"},{label:"Bi-Week",value:"bi-week"},{label:"Month",value:"month"},{label:"Quarter",value:"quarter"},{label:"Year",value:"year"}]}},wd=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=()=>{e.addStaticOption({label:"",value:""})},o=h.useMemo(()=>[{label:t("filter.widget.select.preset_options.date_unit"),value:"date_unit"}],[r.language]),l=i=>{if(!i||!(i in md))return;const c=md[i][r.language];e.replaceStaticOptions(c),c.length>0&&e.setDefaultValue(c[0].value)};return n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:a,children:t("common.actions.add_an_option")}),n.jsx(s.Select,{placeholder:t("filter.widget.select.preset_options.apply"),value:null,onChange:l,data:o,size:"xs"})]})}),Fz=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=[...e.static_options],o=h.useMemo(()=>[{label:t("filter.widget.select.no_default_selection"),value:""},...a.filter(l=>l.value!=="")],[r.language,a]);return a.length===0?n.jsx(wd,{config:e}):n.jsxs(n.Fragment,{children:[n.jsx(s.Select,{label:t("filter.widget.select.default_selection"),data:o,value:e.default_value,onChange:e.setDefaultValue}),a.map((l,i)=>n.jsxs(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(s.TextInput,{label:t("common.label"),required:!0,value:e.static_options[i].label,onChange:c=>{e.static_options[i].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.TextInput,{label:t("common.value"),required:!0,value:e.static_options[i].value,onChange:c=>{e.static_options[i].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(i),sx:{position:"absolute",top:28,right:5},children:n.jsx(T.IconTrash,{size:16})})]},i)),n.jsx(wd,{config:e})]})}),Qz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(s.Checkbox,{checked:r.clearable,onChange:a=>r.setClearable(a.currentTarget.checked),label:t("filter.widget.select.clearable")}),n.jsx(_t,{filter:e})]}),n.jsx(s.TextInput,{label:t("filter.widget.select.width"),value:r.width,onChange:a=>r.setWidth(a.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:t("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(s.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[r.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(s.Text,{c:"white",size:"16px",children:t("filter.widget.common.using_query")})})]}),n.jsx(Fz,{config:r})]}),n.jsx(s.Divider,{label:t("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:r.default_selection_count===1,onChange:a=>r.setDefaultSelectionCount(a.currentTarget.checked?1:0),label:t("filter.widget.select.select_first_option_by_default")}),n.jsx($n,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(_d,{})]})}),jz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsx(s.TextInput,{label:r("filter.widget.text_input.default_value"),value:a.default_value,onChange:o=>{a.setDefaultValue(o.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.Box,{mt:22,children:n.jsx(_t,{filter:t})})]}),n.jsx(s.Checkbox,{checked:a.required,onChange:o=>a.setRequired(o.currentTarget.checked),label:r("filter.widget.text_input.required")})]})}),Wz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=j().editor,a=e.usages,o=l=>{switch(l.type){case"query":r.setPath(["_QUERIES_",l.id]);break;case"sql_snippet":r.setPath(["_SQL_SNIPPETS_",l.id]);break;case"view":r.setPath(["_VIEWS_",l.id]);default:return}};return a.length===0?n.jsx(s.Text,{mt:10,ml:10,size:"sm",children:t("filter.usage.unused_description")}):n.jsxs(s.Table,{highlightOnHover:!0,layout:"fixed",styles:{table:{fontSize:"14px"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:80}}),n.jsx("col",{})]}),n.jsx(s.Table.Tbody,{children:a.map(l=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Text,{size:"xs",children:t(l.type_label)})}),n.jsx(s.Table.Td,{children:n.jsx(s.Anchor,{size:"xs",title:l.label,onClick:()=>o(l),children:n.jsx(s.Text,{truncate:"end",children:l.label})})})]},l.id))})]})}),Uz=k.observer(({filter:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Tabs,{defaultValue:"usage",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"config",children:t("common.titles.config")}),n.jsx(s.Tabs.Tab,{value:"usage",children:t("filter.usage.label")})]}),n.jsx(s.Tabs.Panel,{value:"config",children:n.jsx(s.Box,{sx:{minWidth:"480px"},children:n.jsx(Qe.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(e,null,4)})})}),n.jsx(s.Tabs.Panel,{value:"usage",children:n.jsx(Wz,{filter:e})})]})}),Kz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config,a=h.useMemo(()=>{const p=Ni(r.default_step);return Object.entries(p).map(([g,b])=>({group:t(`filter.widget.date_range.shortcut.${g}.label`),items:b.map(({key:_,value:w})=>({label:t(`filter.widget.date_range.shortcut.${g}.full.${_}`),value:w}))}))},[r.default_step]),o=[...r.default_value],[l,i]=h.useState(o),c=p=>{i(p),!(p[0]===null||p[1]===null)&&(r.setDefaultValue({value:Ht(p[0],p[1],r.default_step),shortcut:null,step:r.default_step}),r.setDefaultShortcut(null))},d=p=>{i([null,null]),r.setDefaultValue({value:[null,null],shortcut:p,step:r.default_step}),r.setDefaultShortcut(p)},u=p=>{r.setDefaultValue({value:r.default_shortcut?[null,null]:Ht(r.default_value[0],r.default_value[1],p),shortcut:r.default_shortcut,step:p}),r.setDefaultStep(p)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{children:n.jsx(s.Checkbox,{checked:r.required,onChange:p=>r.setRequired(p.currentTarget.checked),label:t("filter.widget.date_range.required")})}),n.jsx(xc,{value:r.default_step,onChange:u,label:"默认步长"}),n.jsxs(s.Group,{children:[n.jsx(s.Select,{data:a,label:t("filter.widget.date_range.default_by_shortcut"),value:r.default_shortcut,onChange:d,placeholder:t("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500}),n.jsx(wt.DatePickerInput,{type:"range",label:t("filter.widget.date_range.default_value"),value:l,onChange:c,valueFormat:r.inputFormat,allowSingleDateInRange:!0,numberOfColumns:2,w:"50%",disabled:!!r.default_shortcut})]}),r.required&&!r.default_shortcut&&r.default_value.every(p=>!p)&&n.jsx(s.Text,{size:"xs",mt:-10,ta:"center",children:"快捷方式与具体日期范围二选一,且必填"}),n.jsx(_t,{filter:e})]})}),Yz={[P.Select]:Qz,[P.MultiSelect]:Gz,[P.TreeSelect]:WT,[P.TreeSingleSelect]:RT,[P.TextInput]:jz,[P.Checkbox]:qz,[P.DateRange]:Lz,[P.MericoDateRange]:Kz},nt={[P.Select]:"filter.widget.names.select",[P.MultiSelect]:"filter.widget.names.multi_select",[P.TreeSelect]:"filter.widget.names.tree_select",[P.TreeSingleSelect]:"filter.widget.names.tree_single_select",[P.TextInput]:"filter.widget.names.text_input",[P.Checkbox]:"filter.widget.names.checkbox",[P.DateRange]:"filter.widget.names.date_range",[P.MericoDateRange]:"filter.widget.names.merico_date_range"},Xz=k.observer(({filter:e})=>{const{t,i18n:r}=m.useTranslation(),a=F(),o=h.useMemo(()=>Yz[e.type],[e.type]),l=h.useMemo(()=>[{label:t(nt[P.Select]),value:"select"},{label:t(nt[P.MultiSelect]),value:"multi-select"},{label:t(nt[P.TreeSelect]),value:"tree-select"},{label:t(nt[P.TreeSingleSelect]),value:"tree-single-select"},{label:t(nt[P.TextInput]),value:"text-input"},{label:t(nt[P.Checkbox]),value:"checkbox"},{label:t(nt[P.DateRange]),value:"date-range"},{label:t(nt[P.MericoDateRange]),value:"merico-date-range"}],[r.language]);return n.jsxs(s.Group,{grow:!0,gap:20,align:"top",children:[n.jsxs(s.Box,{w:600,children:[n.jsx(s.Text,{pb:"md",c:"gray",size:"sm",children:t("common.titles.edit")}),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{wrap:"nowrap",children:[n.jsx(s.NumberInput,{label:t("filter.field.order"),required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&n.jsx(s.Checkbox,{label:t("filter.field.auto_submit"),checked:e.auto_submit,onChange:i=>e.setAutoSubmit(i.currentTarget.checked),mt:22})]}),n.jsx(s.MultiSelect,{label:t("filter.field.visible_in"),data:a.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),n.jsx(s.TextInput,{label:t("common.key"),placeholder:t("filter.field.key_placeholder"),required:!0,value:e.key,onChange:i=>{e.setKey(i.currentTarget.value)}}),n.jsx(s.TextInput,{label:t("common.label"),placeholder:t("filter.field.label_placeholder"),required:!0,value:e.label,onChange:i=>{e.setLabel(i.currentTarget.value)}}),n.jsx(s.Select,{label:t("filter.field.widget"),data:l,required:!0,value:e.type,onChange:e.setType,maxDropdownHeight:500}),n.jsx(s.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),n.jsx(o,{filter:e})]})]}),n.jsx(Uz,{filter:e})]})}),Zz=k.observer(({id:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F();if(e==="")return null;const l=o.filters.findByID(e);if(!l)return n.jsxs(s.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const i=()=>{a.editor.setPath(["_FILTERS_",""])},c=()=>{r.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.filters.removeByID(e),i()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{sx:{minWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[n.jsx(s.Group,{justify:"flex-end",pt:10,children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),n.jsx(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(Xz,{filter:l})})]})}),Jz=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=j(),o=u=>{a.editor.setPath(["_FILTERS_",u])},l=()=>{a.content.filters.downloadSchema(t)},i=h.useMemo(()=>a.content.filters.sortedList.map(u=>u.id),[a.content.filters.sortedList]),c=()=>{r(i)},d=()=>{r([])};return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),n.jsx(s.Flex,{justify:"space-between",align:"center",px:12,children:n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:l,children:e("common.actions.download_schema")})]})}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{style:{width:"300px"},children:e("common.label")}),n.jsx(s.Table.Th,{children:e("common.key")}),n.jsx(s.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:a.content.filters.sortedList.map(u=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:u.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:u.label}),n.jsx(s.Table.Td,{children:u.key}),n.jsx(s.Table.Td,{children:e(nt[u.type])}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>o(u.id),children:e("common.actions.open")})})]},u.id))})]})})})]})}),Hz=k.observer(()=>{const{t:e}=m.useTranslation(),t=F(),[r,a]=h.useState(()=>JSON.stringify(t.mock_context.current,null,4)),o=()=>{try{t.mock_context.replace(JSON.parse(r))}catch(i){Fe.showNotification({title:"Failed",message:i.message,color:"red"})}},l=h.useMemo(()=>{try{return JSON.stringify(JSON.parse(r))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[r,t.mock_context.current]);return n.jsxs(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n.jsx(s.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n.jsx(s.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),n.jsx(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:n.jsxs(s.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Text,{size:"sm",children:e("mock_context.hint")}),n.jsx(s.Button,{color:"green",size:"compact-sm",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:o,disabled:!l,children:e("common.actions.save")})]}),n.jsx(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:r,onChange:a,sx:{flexGrow:1}})]})})]})}),Rz=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae();return n.jsx(gn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),e3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae(),r=H().layouts.findItemByPanelID(t.id),{style:a}=t;return n.jsx(n.Fragment,{children:n.jsxs(s.Stack,{gap:20,children:[n.jsxs(s.Group,{grow:!0,align:"top",children:[n.jsx(s.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:n.jsx(s.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:r.w,onChange:o=>{typeof o!="string"&&r.setWidth(o)}}),n.jsx(s.NumberInput,{label:e("panel.style.height"),rightSection:n.jsx(s.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:r.h,onChange:o=>{typeof o!="string"&&r.setHeight(o)}})]}),n.jsx(s.Checkbox,{ml:6,label:e("panel.style.border"),checked:a.border.enabled,onChange:o=>a.border.setEnabled(o.currentTarget.checked)})]})})}),t3=()=>n.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),n3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae(),{name:r}=t,[a,o]=te.useInputState(r),l=r!==a,i=h.useCallback(()=>{l&&t.setName(a)},[l,a]);h.useEffect(()=>{o(r)},[r]);const c=!a.trim();return n.jsxs(s.Stack,{gap:4,children:[n.jsxs(s.Group,{align:"center",children:[n.jsxs(s.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),n.jsx(t3,{})]}),n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!l||c,onClick:i,children:n.jsx(T.IconDeviceFloppy,{size:18})})]}),n.jsx(s.TextInput,{value:a,onChange:o,required:!0})]})}),r3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae();return n.jsx(s.Stack,{gap:6,mb:10,children:n.jsxs(s.Group,{pl:6,justify:"flex-start",gap:20,children:[n.jsx(s.Checkbox,{size:"sm",checked:t.title.show,onChange:r=>t.title.setShow(r.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),n.jsx(s.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function a3(){const{t:e}=m.useTranslation();return n.jsxs(s.Stack,{sx:{height:"100%"},children:[n.jsx(e3,{}),n.jsx(s.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),n.jsx(n3,{}),n.jsx(r3,{}),n.jsx(Rz,{})]})}const s3={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function xd({data:e}){const t=h.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const a=ge.createColumnHelper();return Object.keys(e[0]).map(o=>a.accessor(o,{cell:l=>l.getValue()}))},[e]),r=ge.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel()});return e.length===0?n.jsx(s.Box,{sx:{height:"5em"}}):n.jsx(ne,{children:n.jsxs(s.Table,{sx:s3,children:[n.jsx(s.Table.Thead,{children:r.getHeaderGroups().map(a=>n.jsx(s.Table.Tr,{children:a.headers.map(o=>n.jsxs(s.Table.Th,{style:{width:o.getSize()},children:[o.isPlaceholder?null:ge.flexRender(o.column.columnDef.header,o.getContext()),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:o.getResizeHandler(),onTouchStart:o.getResizeHandler(),className:`resizer ${o.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},o.id))},a.id))}),n.jsx(s.Table.Tbody,{children:r.getRowModel().rows.map(a=>n.jsx(s.Table.Tr,{children:a.getVisibleCells().map(o=>n.jsx(s.Table.Td,{children:n.jsx(ne,{children:typeof o.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(o.getValue(),null,2)}):ge.flexRender(o.column.columnDef.cell,o.getContext())})},o.id))},a.id))})]})})}const o3=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],l3={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},i3=({data:e,page:t,setPage:r,limit:a,setLimit:o})=>{const{t:l}=m.useTranslation(),i=e.length,c=Math.ceil(i/a),d=p=>{p&&(r(1),o(Number(p)))};if(i===0)return null;const u=c===1&&i<=10;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[c>1&&n.jsx(s.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!u&&n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"14px",children:l("common.pagination.page_size")}),size:"xs",styles:l3,data:o3,value:String(a),onChange:d})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:l("common.pagination.total_rows",{total:i})})})]})},c3=Io(({data:e,loading:t})=>{const[r,a]=h.useState(1),[o,l]=h.useState(20),i=h.useMemo(()=>{const c=(r-1)*o,d=c+o;return e.slice(c,d)},[e,r,o]);return n.jsxs(ne,{children:[n.jsx(i3,{data:e,page:r,setPage:a,limit:o,setLimit:l}),n.jsxs(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(xd,{data:i})]})]})}),d3=k.observer(({queryID:e})=>{const{t}=m.useTranslation(),r=H(),a=h.useMemo(()=>r.queries.findByID(e),[r,e]);if(!a||a.state==="loading")return null;const{error:o,metricQueryPayloadErrorString:l,stateMessage:i}=a;return o||l?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:o??l}):i?n.jsx(s.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(i)}):null}),cs=k.observer(({id:e,moreActions:t,refreshOnMount:r})=>{const{t:a}=m.useTranslation(),o=H(),{data:l,state:i}=o.getDataStuffByID(e),c=i==="loading",d=h.useCallback(()=>{o.queries.refetchDataByQueryID(e)},[e,o]),u=()=>{o.queries.downloadDataByQueryID(null,e)};h.useEffect(()=>{r&&d()},[d,r]);const p=!Array.isArray(l)||l.length===0;return n.jsxs(s.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[n.jsxs(s.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(s.Text,{size:"sm",fw:500,children:a("data.preview_data")})}),n.jsxs(s.Group,{pr:15,children:[t,n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:d,children:n.jsx(T.IconRefresh,{size:16})}),n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:u,children:n.jsx(T.IconDownload,{size:16})})]})]}),n.jsxs(s.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[n.jsx(d3,{queryID:e}),n.jsx(c3,{data:l,loading:c})]})]})}),u3=k.observer(function(){const{t}=m.useTranslation(),r=j(),a=F(),{panel:o}=ae(),[l,i]=h.useState(!1),c=u=>{r.editor.setPath(["_QUERIES_",u])},d=o.queryIDs.length;return n.jsxs(n.Fragment,{children:[n.jsx(s.Drawer,{opened:l,onClose:()=>i(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:n.jsx(s.Checkbox.Group,{value:[...o.queryIDs],onChange:o.setQueryIDs,children:n.jsx(s.Stack,{gap:"lg",children:a.queries.options.map(u=>n.jsx(s.Checkbox,{label:u.label,value:u.value},u.value))})})}),n.jsxs(s.Stack,{gap:6,children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(s.Button,{variant:"light",size:"sm",leftSection:n.jsx(T.IconLine,{size:16}),onClick:()=>i(!0),children:t(d===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),d===1&&n.jsx(cs,{id:o.queryIDs[0],moreActions:n.jsx(s.Tooltip,{label:t("query.open"),children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(o.queryIDs[0]),children:n.jsx(T.IconArrowCurveRight,{size:16})})})}),d>1&&n.jsxs(s.Tabs,{defaultValue:o.queryIDs[0],children:[n.jsx(s.Tabs.List,{children:o.queries.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,children:u.name},u.id))}),o.queries.map(u=>n.jsx(s.Tabs.Panel,{value:u.id,children:n.jsx(cs,{id:u.id,moreActions:n.jsx(s.Tooltip,{label:t("query.open"),children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(u.id),children:n.jsx(T.IconArrowCurveRight,{size:16})})})})},u.id))]})]})]})}),p3=k.observer(()=>{const{panel:e}=re();return e.title.show?n.jsx(s.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),h3=k.observer(()=>{const{panel:e}=re();return n.jsx(ne,{children:n.jsx(s.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:n.jsxs(Fs,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Xa,{})}),n.jsx(p3,{}),n.jsx(Ha,{panel:e})]})})})});function g3(){const{t:e}=m.useTranslation(),{vizManager:t}=h.useContext(ot);return h.useMemo(()=>y.orderBy(Object.entries(y.groupBy(t.availableVizList,"displayGroup")),[o=>o[0]],["asc"]).map(([o,l])=>{const i=l.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(o??"ungrouped"),items:y.orderBy(i,[c=>c.label],["asc"])}}),[t])}const f3=k.observer(({value:e,submit:t})=>{const{t:r}=m.useTranslation(),[a,o]=te.useInputState(e);h.useEffect(()=>{o(e)},[e]);const l=g3(),i=e!==a;return n.jsx(s.Select,{label:r("visualization.component"),value:a,searchable:!0,onChange:o,data:l,rightSection:n.jsx(s.ActionIcon,{variant:"filled",color:"green",disabled:!i,onClick:()=>t(a),styles:{root:{pointerEvents:"all"}},children:n.jsx(T.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Cd=[];function b3(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function y3(){const{data:e,panel:{variables:t,viz:r,title:a,name:o,queryIDs:l,description:i,id:c}}=ae(),{vizManager:d}=h.useContext(ot),u={name:o,title:a,description:i,viz:r,queryIDs:l,id:c},p=Vc(u);try{return d.resolveComponent(u.viz.type),n.jsx(vn,{configure:p,children:n.jsx(mk,{variables:t,setVizConf:r.setConf,panel:u,vizManager:d,data:e})})}catch(g){return console.info(y.get(g,"message")),null}}const v3=k.observer(()=>{const{data:e,panel:{viz:t}}=ae(),{vizManager:r}=h.useContext(ot),a=h.useCallback(u=>{if(u===t.type)return;const p=b3(r,u);t.setType(u),t.setConf(p||{})},[t.type]),o=u=>{try{t.setConf(JSON.parse(u))}catch(p){console.error(p)}},l=h.useMemo(()=>{var u;return(u=Cd.find(p=>p.value===t.type))==null?void 0:u.Panel},[t.type,Cd]),i=y3(),c=l?h.createElement(l,{data:e,conf:t.conf,setConf:t.setConf}):null,d=i||c;return n.jsxs(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n.jsx(f3,{submit:a,value:t.type}),n.jsxs(ne,{children:[n.jsx(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:d}),!d&&n.jsx(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:o})]})]})}),_3=k.observer(({panel:e,sourceViewID:t})=>{const{t:r}=m.useTranslation(),a=F(),[o,l]=h.useState(t);h.useEffect(()=>{l(t)},[t]);const[i,{open:c,close:d}]=te.useDisclosure(!1),u=()=>{e.moveToView(t,o),d()};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:n.jsx(T.IconBoxMultiple,{size:14}),children:r("panel.settings.change_view")}),n.jsx(s.Modal,{opened:i,onClose:d,title:r("panel.settings.change_view_title"),zIndex:320,children:n.jsxs(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n.jsx(s.Radio.Group,{value:o,onChange:l,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n.jsx(s.Stack,{gap:"xs",children:a.views.options.map(p=>n.jsx(s.Radio,{value:p.value,label:p.label},p.value))})}),n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconX,{size:14}),onClick:d,children:r("common.actions.cancel")}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconDeviceFloppy,{size:14}),onClick:u,disabled:o===t,children:r("common.actions.confirm")})]})]})})]})}),m3=k.observer(({sx:e={}})=>{const{t}=m.useTranslation(),r=H(),{panel:a}=re(),o=r.dashboardStateValues,l=(()=>{const i={...o,...a.variableStrings};return JSON.stringify(i,null,2)})();return n.jsx(s.Stack,{sx:{overflow:"hidden",...e},children:n.jsxs(s.Tabs,{defaultValue:"vars",keepMounted:!1,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"guide",leftSection:n.jsx(T.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),n.jsx(s.Tabs.Tab,{value:"vars",leftSection:n.jsx(T.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),n.jsx(s.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),n.jsx(s.Tabs.Panel,{value:"vars",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:l})})]})})}),ds={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class w3{constructor(t){V(this,"panel");V(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),G.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(ds.name)).length;this.panel.addVariable(y.cloneDeep({...ds,name:`${ds.name}${t||""}`})),this.selected=y.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const r=this.variables.find(a=>a.name===t);if(!r){console.error(`Variable by name[${t}] not found`);return}this.selected=r}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!y.isEmpty(this.panel.variables)){const a=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[a]}}}function x3(){const{panel:e}=ae();return O.useCreation(()=>new w3(e),[e])}const C3=h.forwardRef(function({value:t,onChange:r,remove:a},o){const{t:l}=m.useTranslation(),i=(c,d)=>{const u=y.cloneDeep(t);y.set(u,c,d),r(u)};return n.jsxs(s.Stack,{ref:o,children:[n.jsxs(s.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.TextInput,{label:l("common.name"),required:!0,value:t.name,onChange:c=>i("name",c.currentTarget.value)}),n.jsx(L,{label:l("common.data_field"),required:!0,value:t.data_field,onChange:c=>i("data_field",c)})]}),n.jsx(Nr,{label:l("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>i("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),n.jsx(Ne,{value:t.formatter,onChange:c=>i("formatter",c)})]})]}),n.jsx(s.Button,{mt:20,leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:a,children:l("panel.variable.delete")})]})}),S3=k.observer(e=>{const{t}=m.useTranslation(),r=O.useCreation(()=>vc(e.variable),[e.variable]),a=()=>e.uiModel.remove(e.variable);return n.jsxs(s.Stack,{"data-testid":"variable-editor",align:"stretch",children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{variant:"subtle",size:"xs",disabled:!r.changed,color:"red",onClick:r.reset,leftSection:n.jsx(T.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),n.jsx(s.Button,{variant:"filled",size:"xs",disabled:!r.changed,color:"green",onClick:r.commit,leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),n.jsx(C3,{value:f.getSnapshot(r.copy),onChange:r.update,remove:a})]})});k.observer(e=>{const{uiModel:t}=e;return n.jsx(s.Stack,{className:"var-list",children:t.variables.map(r=>n.jsx(s.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})});const T3=k.observer(({model:e})=>{const{t}=m.useTranslation();return n.jsx(s.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:n.jsx(s.Button,{variant:"light",size:"xs",leftSection:n.jsx(T.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),k3=k.observer(()=>{var r;const{t:e}=m.useTranslation(),t=x3();return t.variableOptions.length===0?n.jsx(T3,{model:t}):n.jsxs(s.Stack,{pb:20,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(r=t.selected)==null?void 0:r.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),n.jsx(s.Button,{variant:"light",size:"xs",leftSection:n.jsx(T.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),n.jsx(s.Divider,{variant:"dashed"}),t.selected?n.jsx(S3,{uiModel:t,variable:t.selected}):n.jsx("span",{children:"Select or create a new variable on right side"})]})}),D3={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},us=({children:e})=>n.jsxs(s.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[n.jsx(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n.jsxs(s.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[n.jsx(h3,{}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(m3,{})})]})]});function z3(e){return!["richText","button"].includes(e)}const M3=k.observer(({panel:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F(),[l,i]=h.useState(a.editor.panelTab),c=e.queries,u=z3(e.viz.type)&&e.dataLoading,p=u||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,g=a.editor.path[1];h.useEffect(()=>{i(x=>p&&x==="Visualization"?"Data":x)},[e.id,p]);const b=h.useCallback(x=>{i(x),a.editor.setPanelTab(l)},[]),_=()=>{a.editor.setPath(["_VIEWS_",g])},w=()=>r.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removePanelByID(e.id,g),_()},confirmProps:{color:"red"},zIndex:320});return n.jsxs(er,{value:{panel:e,data:e.data,loading:u,errors:e.queryErrors,downloadPanelScreenshot:()=>{},getEchartsOptions:()=>null,setEchartsOptions:()=>{}},children:[n.jsxs(s.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[n.jsx(s.Text,{size:"sm",pt:9,pb:8,children:e.name}),n.jsxs(s.Group,{justify:"flex-end",wrap:"nowrap",children:[n.jsx(_3,{panel:e,sourceViewID:g}),n.jsx(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("panel.delete")})]})]}),n.jsxs(s.Tabs,{value:l,onChange:b,keepMounted:!1,styles:D3,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Data",leftSection:n.jsx(T.IconDatabase,{size:14}),disabled:u,children:t("data.label")}),n.jsx(s.Tabs.Tab,{value:"Panel",leftSection:n.jsx(T.IconAppWindow,{size:14}),children:t("panel.label")}),n.jsx(s.Tabs.Tab,{value:"Variables",leftSection:n.jsx(T.IconVariable,{size:14}),disabled:p,children:n.jsx(s.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(s.Text,{size:"sm",children:t("panel.variable.labels")})})}),n.jsx(s.Tabs.Tab,{value:"Visualization",leftSection:n.jsx(T.IconChartHistogram,{size:14}),disabled:p,children:n.jsx(s.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(s.Text,{size:"sm",children:t("visualization.label")})})}),n.jsx(s.Tabs.Tab,{value:"Interactions",leftSection:n.jsx(T.IconRoute,{size:14}),children:t("interactions.label")})]}),n.jsxs(s.Tabs.Panel,{value:"Data",children:[n.jsx(s.LoadingOverlay,{visible:u,transitionProps:{exitDuration:0}}),n.jsx(u3,{})]}),n.jsx(s.Tabs.Panel,{value:"Panel",children:n.jsx(us,{children:n.jsx(a3,{})})}),n.jsx(s.Tabs.Panel,{value:"Variables",children:n.jsx(us,{children:n.jsx(k3,{})})}),n.jsx(s.Tabs.Panel,{value:"Visualization",children:n.jsx(ne,{children:n.jsx(us,{children:n.jsx(v3,{})})})}),n.jsx(s.Tabs.Panel,{value:"Interactions",children:n.jsx(ne,{children:n.jsx(Sg,{})})})]})]})}),I3=k.observer(({viewID:e,panelID:t})=>{const r=F();if(!r.views.findByID(e))return n.jsxs(s.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const o=r.panels.findByID(t);return o?n.jsx(M3,{panel:o}):n.jsxs(s.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),V3=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=De.useModals(),o=j(),l=b=>{o.editor.setPath(["_QUERIES_",b])},i=()=>{a.openConfirmModal({title:"Delete ununsed queries?",children:n.jsx(s.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{o.content.queries.downloadSchema(t)},d=h.useMemo(()=>o.content.queries.sortedList.map(b=>b.id),[o.content.queries.sortedList]),u=()=>{r(d)},p=()=>{r([])},g=o.content.queriesUsage;return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),n.jsxs(s.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(s.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:14}),disabled:!o.content.hasUnusedQueries,onClick:i,children:e("query.delete_unused")})]}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:e("common.name")}),n.jsx(s.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:o.content.queries.sortedList.map(b=>{var w;const _=((w=g[b.id])==null?void 0:w.length)??0;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:b.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:b.name}),n.jsx(s.Table.Td,{children:b.key}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:b.type}),n.jsx(s.Table.Td,{style:{color:_===0?"#ff0000":"#000",fontWeight:_===0?"bold":"normal",textAlign:"center"},children:_}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>l(b.id),children:e("common.actions.open")})})]},b.id)})})]})})})]})}),P3=e=>{const{t}=m.useTranslation(),{queryModel:r}=e,a=j(),o=F(),i=o.findQueryUsage(r.id).length>0,c=De.useModals(),d=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.queries.removeQuery(r.id),a.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return i?n.jsx(s.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:n.jsx(s.Box,{sx:{alignSelf:"flex-end"},children:n.jsx(s.Button,{disabled:!0,size:"xs",leftSection:n.jsx(T.IconTrash,{size:16}),children:t("query.delete")})})}):n.jsx(s.Button,{color:"red",size:"xs",onClick:d,leftSection:n.jsx(T.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},$3=k.observer(P3),Sd=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:a,spacing:o=16,pl:l=0})=>n.jsxs(s.Stack,{gap:o,mt:6,pl:l,children:[Array.from(new Array(a-1),(i,c)=>n.jsx(s.Skeleton,{width:e,height:r,radius:"xs"},c)),n.jsx(s.Skeleton,{width:t,height:r,radius:"xs"})]}),tn=({value:e})=>e===null||e===""?null:n.jsx(s.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:n.jsx(s.ActionIcon,{variant:"subtle",children:n.jsx(T.IconInfoCircle,{size:14})})}),A3=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n.jsx(s.Tooltip,{label:r,disabled:!r,children:n.jsx(s.Badge,{variant:"light",children:t})}):null},E3=k.observer(({dataSource:e})=>{const{columns:t}=e.dbInfo;return t.loading?n.jsx(Sd,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:50}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:30}}),n.jsx("col",{style:{width:70}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{minWidth:80,width:80}}),n.jsx("col",{style:{minWidth:120,width:120}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"#"}),n.jsx(s.Table.Th,{children:"Column Name"}),n.jsx(s.Table.Th,{}),n.jsx(s.Table.Th,{}),n.jsx(s.Table.Th,{children:"Type"}),n.jsx(s.Table.Th,{children:"Nullable"}),n.jsx(s.Table.Th,{children:"Default Value"})]})}),n.jsx(s.Table.Tbody,{children:t.data.map(r=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:r.ordinal_position}),n.jsx(s.Table.Td,{children:r.column_name}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:r.column_comment})}),n.jsx(s.Table.Td,{children:n.jsx(A3,{column:r})}),n.jsx(s.Table.Td,{children:r.column_type}),n.jsx(s.Table.Td,{children:r.is_nullable}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:r.column_default})})]},r.column_name))})]})}),B3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:250}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Index Length"}),n.jsx(s.Table.Th,{children:"Index Name"}),n.jsx(s.Table.Th,{children:"Index Algorithm"}),n.jsx(s.Table.Th,{children:"Unique"}),n.jsx(s.Table.Th,{children:"Column Name"})]})}),n.jsx(s.Table.Tbody,{children:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.index_length}),n.jsx(s.Table.Td,{children:a.index_name}),n.jsx(s.Table.Td,{children:a.index_algorithm}),n.jsx(s.Table.Td,{children:a.is_unique?"YES":"NO"}),n.jsx(s.Table.Td,{children:a.column_name})]},a.index_name))})]})}),q3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Index Name"}),n.jsx(s.Table.Th,{children:"Index Algorithm"}),n.jsx(s.Table.Th,{children:"Unique"}),n.jsx(s.Table.Th,{children:"Definition"}),n.jsx(s.Table.Th,{children:"Condition"}),n.jsx(s.Table.Th,{children:"Comment"})]})}),n.jsx(s.Table.Tbody,{children:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.index_name}),n.jsx(s.Table.Td,{children:a.index_algorithm}),n.jsx(s.Table.Td,{children:a.is_unique?"YES":"NO"}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.index_definition})}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.condition})}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.comment})})]},a.index_name))})]})}),O3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo;return t.loading||t.empty?null:e.type===W.MySQL?n.jsx(B3,{dataSource:e}):e.type===W.Postgresql?n.jsx(q3,{dataSource:e}):null}),L3=k.observer(({dataSource:e})=>n.jsxs(s.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n.jsx(ne,{children:n.jsx(E3,{dataSource:e})}),n.jsx(ne,{children:n.jsx(O3,{dataSource:e})})]}));function N3({table_type:e}){return e==="VIEW"?n.jsx(T.IconEye,{size:14}):e==="BASE TABLE"?n.jsx(T.IconTable,{size:14}):null}const G3=k.observer(({dataSource:e})=>{const t=e.dbInfo,{tables:r}=t;return r.loading?n.jsx(Sd,{height:"24px",lastWidth:"50%",count:15}):n.jsx(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(r.data).map(([a,o])=>n.jsx(s.NavLink,{label:a,title:a,leftSection:n.jsx(T.IconDatabase,{size:14}),defaultOpened:t.table_schema===a,pl:0,childrenOffset:14,children:o.map(l=>n.jsx(s.NavLink,{label:l.table_name,title:l.table_name,leftSection:n.jsx(N3,{table_type:l.table_type}),onClick:()=>{t.setKeywords(a,l.table_name)},active:t.table_name===l.table_name},l.table_name))},a))})}),F3=({visible:e})=>n.jsx(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n.jsx(s.LoadingOverlay,{visible:e})}),Q3=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],j3={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},W3=k.observer(({dataSource:e})=>{const{t}=m.useTranslation(),{tableData:r}=e.dbInfo;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[r.maxPage>1&&n.jsx(s.Pagination,{size:"sm",value:r.page,onChange:r.setPage,total:r.maxPage,withEdges:r.maxPage>7,styles:{control:{height:"30px"}}}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:j3,data:Q3,value:String(r.limit),onChange:a=>r.setLimit(Number(a)),comboboxProps:{zIndex:340}})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:r.total})})})]})}),U3=k.observer(({dataSource:e})=>{const t=e.dbInfo.tableData;return t.maxPage===0?n.jsx(s.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?n.jsx(s.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?n.jsx(F3,{visible:!0}):n.jsxs(ne,{children:[n.jsx(W3,{dataSource:e}),n.jsxs(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),n.jsx(xd,{data:t.data})]})]})}),K3={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},Y3=k.observer(({dataSource:e})=>{const{t}=m.useTranslation(),r=e.dbInfo;return h.useEffect(()=>{r.loadTablesIfEmpty()},[r]),r.tables.error?n.jsx(s.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:r.tables.error}):n.jsxs(s.Flex,{sx:{height:"100%"},children:[n.jsx(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n.jsx(ne,{children:n.jsx(G3,{dataSource:e})})}),n.jsxs(s.Tabs,{defaultValue:"structure",styles:K3,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"structure",leftSection:n.jsx(T.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),n.jsx(s.Tabs.Tab,{value:"data",leftSection:n.jsx(T.IconDatabase,{size:14}),children:t("data.label")})]}),n.jsx(s.Tabs.Panel,{value:"structure",children:n.jsx(L3,{dataSource:e})}),n.jsx(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n.jsx(U3,{dataSource:e})})]})]})}),X3={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},Td=k.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:r}=m.useTranslation(),[a,o]=h.useState(!1),{type:l}=e;return l==="http"||l==="merico_metric_system"?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:a,onClose:()=>o(!1),title:n.jsxs(s.Group,{justify:"space-between",sx:{flexGrow:1},children:[n.jsx(s.Text,{size:"sm",fw:500,children:r("data_source.explorer")}),n.jsxs(s.Group,{gap:7,children:[n.jsx(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n.jsx(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:X3,children:n.jsx(s.Box,{sx:{height:"calc(100vh - 220px)"},children:n.jsx(Y3,{dataSource:e})})}),n.jsx(s.Button,{variant:"subtle",onClick:()=>o(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:r("data_source.see_table_structure")})]})}),kd={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"指标系统"},Z3=({option:e,...t})=>{const{label:r,type:a}=e;return a===W.Transform?n.jsxs(s.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[n.jsx(T.IconVectorTriangle,{size:14,color:"#228be6"}),n.jsx(s.Text,{size:"sm",c:"blue",children:r})]}):n.jsxs(s.Group,{justify:"space-between",...t,sx:{flexGrow:1},children:[n.jsx(s.Text,{size:"sm",children:r}),n.jsx(s.Text,{size:"sm",children:kd[a]})]})},Dd=k.observer(({queryModel:e,size:t="sm"})=>{const{t:r}=m.useTranslation(),a=j(),{data:o=[],loading:l}=O.useRequest(Oa,{refreshDeps:[]},[]),i=h.useMemo(()=>{const p=o.map(g=>({label:g.key,value:g.key,type:g.type}));return p.push({label:r("query.transform.data_source"),value:W.Transform,type:W.Transform}),p},[o]),c=h.useMemo(()=>i.reduce((p,g)=>(p[g.value]=g.type,p),{}),[i]),d=p=>{p!==null&&(e.setKey(p),e.setType(c[p]))},u=h.useMemo(()=>a.datasources.find({type:e.type,key:e.key}),[a,e.type,e.key]);return n.jsx(s.Select,{size:t,data:i,label:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Box,{children:r("data_source.label")}),u&&n.jsx(Td,{dataSource:u,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:Z3,rightSection:u?n.jsx(s.Text,{size:"xs",c:"dimmed",children:kd[u.type]??u.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1,minWidth:"300px"},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:l,value:e.key,onChange:d})}),J3=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),[r,a]=h.useState(e.name);h.useEffect(()=>{a(e.name)},[e.name]);const o=h.useMemo(()=>e.conditionOptionsWithInvalidRunbys.optionGroups.map(i=>({group:t(i.group),items:i.items})),[e.conditionOptionsWithInvalidRunbys.optionGroups]);return n.jsx(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:n.jsxs(s.Stack,{gap:10,sx:{width:"100%"},children:[n.jsx(s.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),n.jsx(s.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:r,onChange:l=>{a(l.currentTarget.value)},rightSection:n.jsx(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(r),disabled:r===e.name,children:n.jsx(T.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(r)}}),n.jsx(Dd,{queryModel:e}),n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),n.jsx(s.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:o,value:[...e.run_by],onChange:e.setRunBy,renderOption:fr,maxDropdownHeight:500}),e.typedAsHTTP&&n.jsx(s.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:o,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:fr,maxDropdownHeight:500}),e.isTransform&&n.jsx(s.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:o,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:fr,maxDropdownHeight:500}),n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx($3,{queryModel:e})]})})});function H3({content:e}){return n.jsxs(s.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.ActionIcon,{size:16,color:"blue",variant:"subtle",children:n.jsx(T.IconEye,{})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(Qe.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const R3=k.observer(()=>{const t=[...j().globalSQLSnippets.list];return t.length===0?null:n.jsxs(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Key"}),n.jsx(s.Table.Th,{children:"Value"})]})}),n.jsx(s.Table.Tbody,{children:t.map(r=>{const{id:a,content:o}=r;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a}),n.jsx(s.Table.Td,{width:200,children:n.jsx(H3,{content:o})})]},a)})})]})}),e5=`
|
|
553
|
+
`,_d=()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(a=>!a),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(s.Collapse,{in:t,children:n.jsx(Qe.CodeHighlight,{language:"typescript",withCopyButton:!1,code:Gz})})]})},Fz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config,o=()=>{a.addStaticOption({label:"",value:""})},l=a.static_options,i=l.filter(c=>c.value!==""&&c.label!=="");return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:a.required,onChange:c=>a.setRequired(c.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(_t,{filter:t})]}),n.jsx(s.TextInput,{label:r("filter.widget.select.width"),description:r("filter.widget.multi_select.width_description"),value:a.min_width,onChange:c=>a.setMinWidth(c.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:r("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(s.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[a.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(s.Text,{c:"white",size:"16px",children:r("filter.widget.common.using_query")})})]}),i.length>0&&n.jsx(s.MultiSelect,{label:r("filter.widget.select.default_selection"),placeholder:r("filter.widget.select.no_default_selection"),data:i,value:[...a.default_value],onChange:a.setDefaultValue}),l.map((c,d)=>n.jsxs(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(s.TextInput,{label:r("common.label"),required:!0,value:a.static_options[d].label,onChange:u=>{a.static_options[d].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.TextInput,{label:r("common.value"),required:!0,value:a.static_options[d].value,onChange:u=>{a.static_options[d].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>a.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:n.jsx(T.IconTrash,{size:16})})]},d)),n.jsx(s.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:o,sx:{width:"50%"},mx:"auto",children:r("common.actions.add_an_option")})]}),n.jsx(s.Divider,{label:r("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx($n,{value:a.options_query_id,onChange:a.setOptionsQueryID}),n.jsx(s.NumberInput,{value:a.default_selection_count,onChange:a.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(xa,{config:a}),n.jsx(_d,{})]})}),md={date_unit:{zh:[{label:"天",value:"day"},{label:"周",value:"week"},{label:"双周",value:"bi-week"},{label:"月",value:"month"},{label:"季度",value:"quarter"},{label:"年",value:"year"}],en:[{label:"Day",value:"day"},{label:"Week",value:"week"},{label:"Bi-Week",value:"bi-week"},{label:"Month",value:"month"},{label:"Quarter",value:"quarter"},{label:"Year",value:"year"}]}},wd=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=()=>{e.addStaticOption({label:"",value:""})},o=h.useMemo(()=>[{label:t("filter.widget.select.preset_options.date_unit"),value:"date_unit"}],[r.language]),l=i=>{if(!i||!(i in md))return;const c=md[i][r.language];e.replaceStaticOptions(c),c.length>0&&e.setDefaultValue(c[0].value)};return n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconPlaylistAdd,{size:20}),onClick:a,children:t("common.actions.add_an_option")}),n.jsx(s.Select,{placeholder:t("filter.widget.select.preset_options.apply"),value:null,onChange:l,data:o,size:"xs"})]})}),Qz=k.observer(({config:e})=>{const{t,i18n:r}=m.useTranslation(),a=[...e.static_options],o=h.useMemo(()=>[{label:t("filter.widget.select.no_default_selection"),value:""},...a.filter(l=>l.value!=="")],[r.language,a]);return a.length===0?n.jsx(wd,{config:e}):n.jsxs(n.Fragment,{children:[n.jsx(s.Select,{label:t("filter.widget.select.default_selection"),data:o,value:e.default_value,onChange:e.setDefaultValue}),a.map((l,i)=>n.jsxs(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(s.TextInput,{label:t("common.label"),required:!0,value:e.static_options[i].label,onChange:c=>{e.static_options[i].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.TextInput,{label:t("common.value"),required:!0,value:e.static_options[i].value,onChange:c=>{e.static_options[i].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(i),sx:{position:"absolute",top:28,right:5},children:n.jsx(T.IconTrash,{size:16})})]},i)),n.jsx(wd,{config:e})]})}),jz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(s.Checkbox,{checked:r.clearable,onChange:a=>r.setClearable(a.currentTarget.checked),label:t("filter.widget.select.clearable")}),n.jsx(_t,{filter:e})]}),n.jsx(s.TextInput,{label:t("filter.widget.select.width"),value:r.width,onChange:a=>r.setWidth(a.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:t("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(s.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[r.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(s.Text,{c:"white",size:"16px",children:t("filter.widget.common.using_query")})})]}),n.jsx(Qz,{config:r})]}),n.jsx(s.Divider,{label:t("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:r.default_selection_count===1,onChange:a=>r.setDefaultSelectionCount(a.currentTarget.checked?1:0),label:t("filter.widget.select.select_first_option_by_default")}),n.jsx($n,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(_d,{})]})}),Wz=k.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{children:[n.jsx(s.TextInput,{label:r("filter.widget.text_input.default_value"),value:a.default_value,onChange:o=>{a.setDefaultValue(o.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(s.Box,{mt:22,children:n.jsx(_t,{filter:t})})]}),n.jsx(s.Checkbox,{checked:a.required,onChange:o=>a.setRequired(o.currentTarget.checked),label:r("filter.widget.text_input.required")})]})}),Uz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=j().editor,a=e.usages,o=l=>{switch(l.type){case"query":r.setPath(["_QUERIES_",l.id]);break;case"sql_snippet":r.setPath(["_SQL_SNIPPETS_",l.id]);break;case"view":r.setPath(["_VIEWS_",l.id]);default:return}};return a.length===0?n.jsx(s.Text,{mt:10,ml:10,size:"sm",children:t("filter.usage.unused_description")}):n.jsxs(s.Table,{highlightOnHover:!0,layout:"fixed",styles:{table:{fontSize:"14px"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:80}}),n.jsx("col",{})]}),n.jsx(s.Table.Tbody,{children:a.map(l=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Text,{size:"xs",children:t(l.type_label)})}),n.jsx(s.Table.Td,{children:n.jsx(s.Anchor,{size:"xs",title:l.label,onClick:()=>o(l),children:n.jsx(s.Text,{truncate:"end",children:l.label})})})]},l.id))})]})}),Kz=k.observer(({filter:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Tabs,{defaultValue:"usage",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"config",children:t("common.titles.config")}),n.jsx(s.Tabs.Tab,{value:"usage",children:t("filter.usage.label")})]}),n.jsx(s.Tabs.Panel,{value:"config",children:n.jsx(s.Box,{sx:{minWidth:"480px"},children:n.jsx(Qe.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(e,null,4)})})}),n.jsx(s.Tabs.Panel,{value:"usage",children:n.jsx(Uz,{filter:e})})]})}),Yz=k.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config,a=h.useMemo(()=>{const p=Ni(r.default_step);return Object.entries(p).map(([g,b])=>({group:t(`filter.widget.date_range.shortcut.${g}.label`),items:b.map(({key:_,value:w})=>({label:t(`filter.widget.date_range.shortcut.${g}.full.${_}`),value:w}))}))},[r.default_step]),o=[...r.default_value],[l,i]=h.useState(o),c=p=>{i(p),!(p[0]===null||p[1]===null)&&(r.setDefaultValue({value:Ht(p[0],p[1],r.default_step),shortcut:null,step:r.default_step}),r.setDefaultShortcut(null))},d=p=>{i([null,null]),r.setDefaultValue({value:[null,null],shortcut:p,step:r.default_step}),r.setDefaultShortcut(p)},u=p=>{r.setDefaultValue({value:r.default_shortcut?[null,null]:Ht(r.default_value[0],r.default_value[1],p),shortcut:r.default_shortcut,step:p}),r.setDefaultStep(p)};return n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{children:n.jsx(s.Checkbox,{checked:r.required,onChange:p=>r.setRequired(p.currentTarget.checked),label:t("filter.widget.date_range.required")})}),n.jsx(xc,{value:r.default_step,onChange:u,label:"默认步长"}),n.jsxs(s.Group,{children:[n.jsx(s.Select,{data:a,label:t("filter.widget.date_range.default_by_shortcut"),value:r.default_shortcut,onChange:d,placeholder:t("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500}),n.jsx(wt.DatePickerInput,{type:"range",label:t("filter.widget.date_range.default_value"),value:l,onChange:c,valueFormat:r.inputFormat,allowSingleDateInRange:!0,numberOfColumns:2,w:"50%",disabled:!!r.default_shortcut})]}),r.required&&!r.default_shortcut&&r.default_value.every(p=>!p)&&n.jsx(s.Text,{size:"xs",mt:-10,ta:"center",children:"快捷方式与具体日期范围二选一,且必填"}),n.jsx(_t,{filter:e})]})}),Xz={[P.Select]:jz,[P.MultiSelect]:Fz,[P.TreeSelect]:WT,[P.TreeSingleSelect]:RT,[P.TextInput]:Wz,[P.Checkbox]:Oz,[P.DateRange]:Nz,[P.MericoDateRange]:Yz},nt={[P.Select]:"filter.widget.names.select",[P.MultiSelect]:"filter.widget.names.multi_select",[P.TreeSelect]:"filter.widget.names.tree_select",[P.TreeSingleSelect]:"filter.widget.names.tree_single_select",[P.TextInput]:"filter.widget.names.text_input",[P.Checkbox]:"filter.widget.names.checkbox",[P.DateRange]:"filter.widget.names.date_range",[P.MericoDateRange]:"filter.widget.names.merico_date_range"},Zz=k.observer(({filter:e})=>{const{t,i18n:r}=m.useTranslation(),a=F(),o=h.useMemo(()=>Xz[e.type],[e.type]),l=h.useMemo(()=>[{label:t(nt[P.Select]),value:"select"},{label:t(nt[P.MultiSelect]),value:"multi-select"},{label:t(nt[P.TreeSelect]),value:"tree-select"},{label:t(nt[P.TreeSingleSelect]),value:"tree-single-select"},{label:t(nt[P.TextInput]),value:"text-input"},{label:t(nt[P.Checkbox]),value:"checkbox"},{label:t(nt[P.DateRange]),value:"date-range"},{label:t(nt[P.MericoDateRange]),value:"merico-date-range"}],[r.language]);return n.jsxs(s.Group,{grow:!0,gap:20,align:"top",children:[n.jsxs(s.Box,{w:600,children:[n.jsx(s.Text,{pb:"md",c:"gray",size:"sm",children:t("common.titles.edit")}),n.jsxs(s.Stack,{children:[n.jsxs(s.Group,{wrap:"nowrap",children:[n.jsx(s.NumberInput,{label:t("filter.field.order"),required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&n.jsx(s.Checkbox,{label:t("filter.field.auto_submit"),checked:e.auto_submit,onChange:i=>e.setAutoSubmit(i.currentTarget.checked),mt:22})]}),n.jsx(s.MultiSelect,{label:t("filter.field.visible_in"),data:a.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),n.jsx(s.TextInput,{label:t("common.key"),placeholder:t("filter.field.key_placeholder"),required:!0,value:e.key,onChange:i=>{e.setKey(i.currentTarget.value)}}),n.jsx(s.TextInput,{label:t("common.label"),placeholder:t("filter.field.label_placeholder"),required:!0,value:e.label,onChange:i=>{e.setLabel(i.currentTarget.value)}}),n.jsx(s.Select,{label:t("filter.field.widget"),data:l,required:!0,value:e.type,onChange:e.setType,maxDropdownHeight:500}),n.jsx(s.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),n.jsx(o,{filter:e})]})]}),n.jsx(Kz,{filter:e})]})}),Jz=k.observer(({id:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F();if(e==="")return null;const l=o.filters.findByID(e);if(!l)return n.jsxs(s.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const i=()=>{a.editor.setPath(["_FILTERS_",""])},c=()=>{r.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.filters.removeByID(e),i()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{sx:{minWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[n.jsx(s.Group,{justify:"flex-end",pt:10,children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),n.jsx(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(Zz,{filter:l})})]})}),Hz=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=j(),o=u=>{a.editor.setPath(["_FILTERS_",u])},l=()=>{a.content.filters.downloadSchema(t)},i=h.useMemo(()=>a.content.filters.sortedList.map(u=>u.id),[a.content.filters.sortedList]),c=()=>{r(i)},d=()=>{r([])};return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),n.jsx(s.Flex,{justify:"space-between",align:"center",px:12,children:n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:l,children:e("common.actions.download_schema")})]})}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{style:{width:"300px"},children:e("common.label")}),n.jsx(s.Table.Th,{children:e("common.key")}),n.jsx(s.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:a.content.filters.sortedList.map(u=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:u.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:u.label}),n.jsx(s.Table.Td,{children:u.key}),n.jsx(s.Table.Td,{children:e(nt[u.type])}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>o(u.id),children:e("common.actions.open")})})]},u.id))})]})})})]})}),Rz=k.observer(()=>{const{t:e}=m.useTranslation(),t=F(),[r,a]=h.useState(()=>JSON.stringify(t.mock_context.current,null,4)),o=()=>{try{t.mock_context.replace(JSON.parse(r))}catch(i){Fe.showNotification({title:"Failed",message:i.message,color:"red"})}},l=h.useMemo(()=>{try{return JSON.stringify(JSON.parse(r))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[r,t.mock_context.current]);return n.jsxs(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n.jsx(s.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n.jsx(s.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),n.jsx(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:n.jsxs(s.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Text,{size:"sm",children:e("mock_context.hint")}),n.jsx(s.Button,{color:"green",size:"compact-sm",leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),onClick:o,disabled:!l,children:e("common.actions.save")})]}),n.jsx(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:r,onChange:a,sx:{flexGrow:1}})]})})]})}),e3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae();return n.jsx(gn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),t3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae(),r=H().layouts.findItemByPanelID(t.id),{style:a}=t;return n.jsx(n.Fragment,{children:n.jsxs(s.Stack,{gap:20,children:[n.jsxs(s.Group,{grow:!0,align:"top",children:[n.jsx(s.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:n.jsx(s.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:r.w,onChange:o=>{typeof o!="string"&&r.setWidth(o)}}),n.jsx(s.NumberInput,{label:e("panel.style.height"),rightSection:n.jsx(s.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:r.h,onChange:o=>{typeof o!="string"&&r.setHeight(o)}})]}),n.jsx(s.Checkbox,{ml:6,label:e("panel.style.border"),checked:a.border.enabled,onChange:o=>a.border.setEnabled(o.currentTarget.checked)})]})})}),n3=()=>n.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),r3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae(),{name:r}=t,[a,o]=te.useInputState(r),l=r!==a,i=h.useCallback(()=>{l&&t.setName(a)},[l,a]);h.useEffect(()=>{o(r)},[r]);const c=!a.trim();return n.jsxs(s.Stack,{gap:4,children:[n.jsxs(s.Group,{align:"center",children:[n.jsxs(s.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),n.jsx(n3,{})]}),n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!l||c,onClick:i,children:n.jsx(T.IconDeviceFloppy,{size:18})})]}),n.jsx(s.TextInput,{value:a,onChange:o,required:!0})]})}),a3=k.observer(()=>{const{t:e}=m.useTranslation(),{panel:t}=ae();return n.jsx(s.Stack,{gap:6,mb:10,children:n.jsxs(s.Group,{pl:6,justify:"flex-start",gap:20,children:[n.jsx(s.Checkbox,{size:"sm",checked:t.title.show,onChange:r=>t.title.setShow(r.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),n.jsx(s.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function s3(){const{t:e}=m.useTranslation();return n.jsxs(s.Stack,{sx:{height:"100%"},children:[n.jsx(t3,{}),n.jsx(s.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),n.jsx(r3,{}),n.jsx(a3,{}),n.jsx(e3,{})]})}const o3={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function xd({data:e}){const t=h.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const a=ge.createColumnHelper();return Object.keys(e[0]).map(o=>a.accessor(o,{cell:l=>l.getValue()}))},[e]),r=ge.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel()});return e.length===0?n.jsx(s.Box,{sx:{height:"5em"}}):n.jsx(ne,{children:n.jsxs(s.Table,{sx:o3,children:[n.jsx(s.Table.Thead,{children:r.getHeaderGroups().map(a=>n.jsx(s.Table.Tr,{children:a.headers.map(o=>n.jsxs(s.Table.Th,{style:{width:o.getSize()},children:[o.isPlaceholder?null:ge.flexRender(o.column.columnDef.header,o.getContext()),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:o.getResizeHandler(),onTouchStart:o.getResizeHandler(),className:`resizer ${o.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},o.id))},a.id))}),n.jsx(s.Table.Tbody,{children:r.getRowModel().rows.map(a=>n.jsx(s.Table.Tr,{children:a.getVisibleCells().map(o=>n.jsx(s.Table.Td,{children:n.jsx(ne,{children:typeof o.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(o.getValue(),null,2)}):ge.flexRender(o.column.columnDef.cell,o.getContext())})},o.id))},a.id))})]})})}const l3=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],i3={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},c3=({data:e,page:t,setPage:r,limit:a,setLimit:o})=>{const{t:l}=m.useTranslation(),i=e.length,c=Math.ceil(i/a),d=p=>{p&&(r(1),o(Number(p)))};if(i===0)return null;const u=c===1&&i<=10;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[c>1&&n.jsx(s.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!u&&n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"14px",children:l("common.pagination.page_size")}),size:"xs",styles:i3,data:l3,value:String(a),onChange:d})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:l("common.pagination.total_rows",{total:i})})})]})},d3=Io(({data:e,loading:t})=>{const[r,a]=h.useState(1),[o,l]=h.useState(20),i=h.useMemo(()=>{const c=(r-1)*o,d=c+o;return e.slice(c,d)},[e,r,o]);return n.jsxs(ne,{children:[n.jsx(c3,{data:e,page:r,setPage:a,limit:o,setLimit:l}),n.jsxs(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(xd,{data:i})]})]})}),u3=k.observer(({queryID:e})=>{const{t}=m.useTranslation(),r=H(),a=h.useMemo(()=>r.queries.findByID(e),[r,e]);if(!a||a.state==="loading")return null;const{error:o,metricQueryPayloadErrorString:l,stateMessage:i}=a;return o||l?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:o??l}):i?n.jsx(s.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(i)}):null}),cs=k.observer(({id:e,moreActions:t,refreshOnMount:r})=>{const{t:a}=m.useTranslation(),o=H(),{data:l,state:i}=o.getDataStuffByID(e),c=i==="loading",d=h.useCallback(()=>{o.queries.refetchDataByQueryID(e)},[e,o]),u=()=>{o.queries.downloadDataByQueryID(null,e)};h.useEffect(()=>{r&&d()},[d,r]);const p=!Array.isArray(l)||l.length===0;return n.jsxs(s.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[n.jsxs(s.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(s.Text,{size:"sm",fw:500,children:a("data.preview_data")})}),n.jsxs(s.Group,{pr:15,children:[t,n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:d,children:n.jsx(T.IconRefresh,{size:16})}),n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:u,children:n.jsx(T.IconDownload,{size:16})})]})]}),n.jsxs(s.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[n.jsx(u3,{queryID:e}),n.jsx(d3,{data:l,loading:c})]})]})}),p3=k.observer(function(){const{t}=m.useTranslation(),r=j(),a=F(),{panel:o}=ae(),[l,i]=h.useState(!1),c=u=>{r.editor.setPath(["_QUERIES_",u])},d=o.queryIDs.length;return n.jsxs(n.Fragment,{children:[n.jsx(s.Drawer,{opened:l,onClose:()=>i(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:n.jsx(s.Checkbox.Group,{value:[...o.queryIDs],onChange:o.setQueryIDs,children:n.jsx(s.Stack,{gap:"lg",children:a.queries.options.map(u=>n.jsx(s.Checkbox,{label:u.label,value:u.value},u.value))})})}),n.jsxs(s.Stack,{gap:6,children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(s.Button,{variant:"light",size:"sm",leftSection:n.jsx(T.IconLine,{size:16}),onClick:()=>i(!0),children:t(d===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),d===1&&n.jsx(cs,{id:o.queryIDs[0],moreActions:n.jsx(s.Tooltip,{label:t("query.open"),children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(o.queryIDs[0]),children:n.jsx(T.IconArrowCurveRight,{size:16})})})}),d>1&&n.jsxs(s.Tabs,{defaultValue:o.queryIDs[0],children:[n.jsx(s.Tabs.List,{children:o.queries.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,children:u.name},u.id))}),o.queries.map(u=>n.jsx(s.Tabs.Panel,{value:u.id,children:n.jsx(cs,{id:u.id,moreActions:n.jsx(s.Tooltip,{label:t("query.open"),children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(u.id),children:n.jsx(T.IconArrowCurveRight,{size:16})})})})},u.id))]})]})]})}),h3=k.observer(()=>{const{panel:e}=re();return e.title.show?n.jsx(s.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),g3=k.observer(()=>{const{panel:e}=re();return n.jsx(ne,{children:n.jsx(s.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:n.jsxs(Fs,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Xa,{})}),n.jsx(h3,{}),n.jsx(Ha,{panel:e})]})})})});function f3(){const{t:e}=m.useTranslation(),{vizManager:t}=h.useContext(ot);return h.useMemo(()=>y.orderBy(Object.entries(y.groupBy(t.availableVizList,"displayGroup")),[o=>o[0]],["asc"]).map(([o,l])=>{const i=l.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(o??"ungrouped"),items:y.orderBy(i,[c=>c.label],["asc"])}}),[t])}const b3=k.observer(({value:e,submit:t})=>{const{t:r}=m.useTranslation(),[a,o]=te.useInputState(e);h.useEffect(()=>{o(e)},[e]);const l=f3(),i=e!==a;return n.jsx(s.Select,{label:r("visualization.component"),value:a,searchable:!0,onChange:o,data:l,rightSection:n.jsx(s.ActionIcon,{variant:"filled",color:"green",disabled:!i,onClick:()=>t(a),styles:{root:{pointerEvents:"all"}},children:n.jsx(T.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Cd=[];function y3(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function v3(){const{data:e,panel:{variables:t,viz:r,title:a,name:o,queryIDs:l,description:i,id:c}}=ae(),{vizManager:d}=h.useContext(ot),u={name:o,title:a,description:i,viz:r,queryIDs:l,id:c},p=Vc(u);try{return d.resolveComponent(u.viz.type),n.jsx(vn,{configure:p,children:n.jsx(mk,{variables:t,setVizConf:r.setConf,panel:u,vizManager:d,data:e})})}catch(g){return console.info(y.get(g,"message")),null}}const _3=k.observer(()=>{const{data:e,panel:{viz:t}}=ae(),{vizManager:r}=h.useContext(ot),a=h.useCallback(u=>{if(u===t.type)return;const p=y3(r,u);t.setType(u),t.setConf(p||{})},[t.type]),o=u=>{try{t.setConf(JSON.parse(u))}catch(p){console.error(p)}},l=h.useMemo(()=>{var u;return(u=Cd.find(p=>p.value===t.type))==null?void 0:u.Panel},[t.type,Cd]),i=v3(),c=l?h.createElement(l,{data:e,conf:t.conf,setConf:t.setConf}):null,d=i||c;return n.jsxs(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n.jsx(b3,{submit:a,value:t.type}),n.jsxs(ne,{children:[n.jsx(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:d}),!d&&n.jsx(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:o})]})]})}),m3=k.observer(({panel:e,sourceViewID:t})=>{const{t:r}=m.useTranslation(),a=F(),[o,l]=h.useState(t);h.useEffect(()=>{l(t)},[t]);const[i,{open:c,close:d}]=te.useDisclosure(!1),u=()=>{e.moveToView(t,o),d()};return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:n.jsx(T.IconBoxMultiple,{size:14}),children:r("panel.settings.change_view")}),n.jsx(s.Modal,{opened:i,onClose:d,title:r("panel.settings.change_view_title"),zIndex:320,children:n.jsxs(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n.jsx(s.Radio.Group,{value:o,onChange:l,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n.jsx(s.Stack,{gap:"xs",children:a.views.options.map(p=>n.jsx(s.Radio,{value:p.value,label:p.label},p.value))})}),n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconX,{size:14}),onClick:d,children:r("common.actions.cancel")}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconDeviceFloppy,{size:14}),onClick:u,disabled:o===t,children:r("common.actions.confirm")})]})]})})]})}),w3=k.observer(({sx:e={}})=>{const{t}=m.useTranslation(),r=H(),{panel:a}=re(),o=r.dashboardStateValues,l=(()=>{const i={...o,...a.variableStrings};return JSON.stringify(i,null,2)})();return n.jsx(s.Stack,{sx:{overflow:"hidden",...e},children:n.jsxs(s.Tabs,{defaultValue:"vars",keepMounted:!1,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"guide",leftSection:n.jsx(T.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),n.jsx(s.Tabs.Tab,{value:"vars",leftSection:n.jsx(T.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),n.jsx(s.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),n.jsx(s.Tabs.Panel,{value:"vars",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:l})})]})})}),ds={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class x3{constructor(t){V(this,"panel");V(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),G.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(ds.name)).length;this.panel.addVariable(y.cloneDeep({...ds,name:`${ds.name}${t||""}`})),this.selected=y.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const r=this.variables.find(a=>a.name===t);if(!r){console.error(`Variable by name[${t}] not found`);return}this.selected=r}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!y.isEmpty(this.panel.variables)){const a=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[a]}}}function C3(){const{panel:e}=ae();return O.useCreation(()=>new x3(e),[e])}const S3=h.forwardRef(function({value:t,onChange:r,remove:a},o){const{t:l}=m.useTranslation(),i=(c,d)=>{const u=y.cloneDeep(t);y.set(u,c,d),r(u)};return n.jsxs(s.Stack,{ref:o,children:[n.jsxs(s.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[n.jsxs(s.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(s.TextInput,{label:l("common.name"),required:!0,value:t.name,onChange:c=>i("name",c.currentTarget.value)}),n.jsx(L,{label:l("common.data_field"),required:!0,value:t.data_field,onChange:c=>i("data_field",c)})]}),n.jsx(Gr,{label:l("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>i("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),n.jsx(Ne,{value:t.formatter,onChange:c=>i("formatter",c)})]})]}),n.jsx(s.Button,{mt:20,leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:a,children:l("panel.variable.delete")})]})}),T3=k.observer(e=>{const{t}=m.useTranslation(),r=O.useCreation(()=>vc(e.variable),[e.variable]),a=()=>e.uiModel.remove(e.variable);return n.jsxs(s.Stack,{"data-testid":"variable-editor",align:"stretch",children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{variant:"subtle",size:"xs",disabled:!r.changed,color:"red",onClick:r.reset,leftSection:n.jsx(T.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),n.jsx(s.Button,{variant:"filled",size:"xs",disabled:!r.changed,color:"green",onClick:r.commit,leftSection:n.jsx(T.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),n.jsx(S3,{value:f.getSnapshot(r.copy),onChange:r.update,remove:a})]})});k.observer(e=>{const{uiModel:t}=e;return n.jsx(s.Stack,{className:"var-list",children:t.variables.map(r=>n.jsx(s.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})});const k3=k.observer(({model:e})=>{const{t}=m.useTranslation();return n.jsx(s.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:n.jsx(s.Button,{variant:"light",size:"xs",leftSection:n.jsx(T.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),D3=k.observer(()=>{var r;const{t:e}=m.useTranslation(),t=C3();return t.variableOptions.length===0?n.jsx(k3,{model:t}):n.jsxs(s.Stack,{pb:20,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsx(s.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(r=t.selected)==null?void 0:r.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),n.jsx(s.Button,{variant:"light",size:"xs",leftSection:n.jsx(T.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),n.jsx(s.Divider,{variant:"dashed"}),t.selected?n.jsx(T3,{uiModel:t,variable:t.selected}):n.jsx("span",{children:"Select or create a new variable on right side"})]})}),z3={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},us=({children:e})=>n.jsxs(s.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[n.jsx(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n.jsxs(s.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[n.jsx(g3,{}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(w3,{})})]})]});function M3(e){return!["richText","button"].includes(e)}const I3=k.observer(({panel:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F(),[l,i]=h.useState(a.editor.panelTab),c=e.queries,u=M3(e.viz.type)&&e.dataLoading,p=u||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,g=a.editor.path[1];h.useEffect(()=>{i(x=>p&&x==="Visualization"?"Data":x)},[e.id,p]);const b=h.useCallback(x=>{i(x),a.editor.setPanelTab(l)},[]),_=()=>{a.editor.setPath(["_VIEWS_",g])},w=()=>r.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removePanelByID(e.id,g),_()},confirmProps:{color:"red"},zIndex:320});return n.jsxs(tr,{value:{panel:e,data:e.data,loading:u,errors:e.queryErrors,downloadPanelScreenshot:()=>{},getEchartsOptions:()=>null,setEchartsOptions:()=>{}},children:[n.jsxs(s.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[n.jsx(s.Text,{size:"sm",pt:9,pb:8,children:e.name}),n.jsxs(s.Group,{justify:"flex-end",wrap:"nowrap",children:[n.jsx(m3,{panel:e,sourceViewID:g}),n.jsx(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("panel.delete")})]})]}),n.jsxs(s.Tabs,{value:l,onChange:b,keepMounted:!1,styles:z3,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Data",leftSection:n.jsx(T.IconDatabase,{size:14}),disabled:u,children:t("data.label")}),n.jsx(s.Tabs.Tab,{value:"Panel",leftSection:n.jsx(T.IconAppWindow,{size:14}),children:t("panel.label")}),n.jsx(s.Tabs.Tab,{value:"Variables",leftSection:n.jsx(T.IconVariable,{size:14}),disabled:p,children:n.jsx(s.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(s.Text,{size:"sm",children:t("panel.variable.labels")})})}),n.jsx(s.Tabs.Tab,{value:"Visualization",leftSection:n.jsx(T.IconChartHistogram,{size:14}),disabled:p,children:n.jsx(s.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(s.Text,{size:"sm",children:t("visualization.label")})})}),n.jsx(s.Tabs.Tab,{value:"Interactions",leftSection:n.jsx(T.IconRoute,{size:14}),children:t("interactions.label")})]}),n.jsxs(s.Tabs.Panel,{value:"Data",children:[n.jsx(s.LoadingOverlay,{visible:u,transitionProps:{exitDuration:0}}),n.jsx(p3,{})]}),n.jsx(s.Tabs.Panel,{value:"Panel",children:n.jsx(us,{children:n.jsx(s3,{})})}),n.jsx(s.Tabs.Panel,{value:"Variables",children:n.jsx(us,{children:n.jsx(D3,{})})}),n.jsx(s.Tabs.Panel,{value:"Visualization",children:n.jsx(ne,{children:n.jsx(us,{children:n.jsx(_3,{})})})}),n.jsx(s.Tabs.Panel,{value:"Interactions",children:n.jsx(ne,{children:n.jsx(Sg,{})})})]})]})}),V3=k.observer(({viewID:e,panelID:t})=>{const r=F();if(!r.views.findByID(e))return n.jsxs(s.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const o=r.panels.findByID(t);return o?n.jsx(I3,{panel:o}):n.jsxs(s.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),P3=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=De.useModals(),o=j(),l=b=>{o.editor.setPath(["_QUERIES_",b])},i=()=>{a.openConfirmModal({title:"Delete ununsed queries?",children:n.jsx(s.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{o.content.queries.downloadSchema(t)},d=h.useMemo(()=>o.content.queries.sortedList.map(b=>b.id),[o.content.queries.sortedList]),u=()=>{r(d)},p=()=>{r([])},g=o.content.queriesUsage;return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),n.jsxs(s.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(s.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:14}),disabled:!o.content.hasUnusedQueries,onClick:i,children:e("query.delete_unused")})]}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:e("common.name")}),n.jsx(s.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:o.content.queries.sortedList.map(b=>{var w;const _=((w=g[b.id])==null?void 0:w.length)??0;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:b.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:b.name}),n.jsx(s.Table.Td,{children:b.key}),n.jsx(s.Table.Td,{style:{textAlign:"right"},children:b.type}),n.jsx(s.Table.Td,{style:{color:_===0?"#ff0000":"#000",fontWeight:_===0?"bold":"normal",textAlign:"center"},children:_}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>l(b.id),children:e("common.actions.open")})})]},b.id)})})]})})})]})}),$3=e=>{const{t}=m.useTranslation(),{queryModel:r}=e,a=j(),o=F(),i=o.findQueryUsage(r.id).length>0,c=De.useModals(),d=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.queries.removeQuery(r.id),a.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return i?n.jsx(s.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:n.jsx(s.Box,{sx:{alignSelf:"flex-end"},children:n.jsx(s.Button,{disabled:!0,size:"xs",leftSection:n.jsx(T.IconTrash,{size:16}),children:t("query.delete")})})}):n.jsx(s.Button,{color:"red",size:"xs",onClick:d,leftSection:n.jsx(T.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},A3=k.observer($3),Sd=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:a,spacing:o=16,pl:l=0})=>n.jsxs(s.Stack,{gap:o,mt:6,pl:l,children:[Array.from(new Array(a-1),(i,c)=>n.jsx(s.Skeleton,{width:e,height:r,radius:"xs"},c)),n.jsx(s.Skeleton,{width:t,height:r,radius:"xs"})]}),tn=({value:e})=>e===null||e===""?null:n.jsx(s.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:n.jsx(s.ActionIcon,{variant:"subtle",children:n.jsx(T.IconInfoCircle,{size:14})})}),E3=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n.jsx(s.Tooltip,{label:r,disabled:!r,children:n.jsx(s.Badge,{variant:"light",children:t})}):null},B3=k.observer(({dataSource:e})=>{const{columns:t}=e.dbInfo;return t.loading?n.jsx(Sd,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:50}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:30}}),n.jsx("col",{style:{width:70}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{minWidth:80,width:80}}),n.jsx("col",{style:{minWidth:120,width:120}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"#"}),n.jsx(s.Table.Th,{children:"Column Name"}),n.jsx(s.Table.Th,{}),n.jsx(s.Table.Th,{}),n.jsx(s.Table.Th,{children:"Type"}),n.jsx(s.Table.Th,{children:"Nullable"}),n.jsx(s.Table.Th,{children:"Default Value"})]})}),n.jsx(s.Table.Tbody,{children:t.data.map(r=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:r.ordinal_position}),n.jsx(s.Table.Td,{children:r.column_name}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:r.column_comment})}),n.jsx(s.Table.Td,{children:n.jsx(E3,{column:r})}),n.jsx(s.Table.Td,{children:r.column_type}),n.jsx(s.Table.Td,{children:r.is_nullable}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:r.column_default})})]},r.column_name))})]})}),q3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:250}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Index Length"}),n.jsx(s.Table.Th,{children:"Index Name"}),n.jsx(s.Table.Th,{children:"Index Algorithm"}),n.jsx(s.Table.Th,{children:"Unique"}),n.jsx(s.Table.Th,{children:"Column Name"})]})}),n.jsx(s.Table.Tbody,{children:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.index_length}),n.jsx(s.Table.Td,{children:a.index_name}),n.jsx(s.Table.Td,{children:a.index_algorithm}),n.jsx(s.Table.Td,{children:a.is_unique?"YES":"NO"}),n.jsx(s.Table.Td,{children:a.column_name})]},a.index_name))})]})}),O3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(s.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Index Name"}),n.jsx(s.Table.Th,{children:"Index Algorithm"}),n.jsx(s.Table.Th,{children:"Unique"}),n.jsx(s.Table.Th,{children:"Definition"}),n.jsx(s.Table.Th,{children:"Condition"}),n.jsx(s.Table.Th,{children:"Comment"})]})}),n.jsx(s.Table.Tbody,{children:r.map(a=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a.index_name}),n.jsx(s.Table.Td,{children:a.index_algorithm}),n.jsx(s.Table.Td,{children:a.is_unique?"YES":"NO"}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.index_definition})}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.condition})}),n.jsx(s.Table.Td,{children:n.jsx(tn,{value:a.comment})})]},a.index_name))})]})}),L3=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo;return t.loading||t.empty?null:e.type===W.MySQL?n.jsx(q3,{dataSource:e}):e.type===W.Postgresql?n.jsx(O3,{dataSource:e}):null}),N3=k.observer(({dataSource:e})=>n.jsxs(s.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n.jsx(ne,{children:n.jsx(B3,{dataSource:e})}),n.jsx(ne,{children:n.jsx(L3,{dataSource:e})})]}));function G3({table_type:e}){return e==="VIEW"?n.jsx(T.IconEye,{size:14}):e==="BASE TABLE"?n.jsx(T.IconTable,{size:14}):null}const F3=k.observer(({dataSource:e})=>{const t=e.dbInfo,{tables:r}=t;return r.loading?n.jsx(Sd,{height:"24px",lastWidth:"50%",count:15}):n.jsx(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(r.data).map(([a,o])=>n.jsx(s.NavLink,{label:a,title:a,leftSection:n.jsx(T.IconDatabase,{size:14}),defaultOpened:t.table_schema===a,pl:0,childrenOffset:14,children:o.map(l=>n.jsx(s.NavLink,{label:l.table_name,title:l.table_name,leftSection:n.jsx(G3,{table_type:l.table_type}),onClick:()=>{t.setKeywords(a,l.table_name)},active:t.table_name===l.table_name},l.table_name))},a))})}),Q3=({visible:e})=>n.jsx(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n.jsx(s.LoadingOverlay,{visible:e})}),j3=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],W3={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},U3=k.observer(({dataSource:e})=>{const{t}=m.useTranslation(),{tableData:r}=e.dbInfo;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[r.maxPage>1&&n.jsx(s.Pagination,{size:"sm",value:r.page,onChange:r.setPage,total:r.maxPage,withEdges:r.maxPage>7,styles:{control:{height:"30px"}}}),n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:W3,data:j3,value:String(r.limit),onChange:a=>r.setLimit(Number(a)),comboboxProps:{zIndex:340}})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:r.total})})})]})}),K3=k.observer(({dataSource:e})=>{const t=e.dbInfo.tableData;return t.maxPage===0?n.jsx(s.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?n.jsx(s.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?n.jsx(Q3,{visible:!0}):n.jsxs(ne,{children:[n.jsx(U3,{dataSource:e}),n.jsxs(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),n.jsx(xd,{data:t.data})]})]})}),Y3={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},X3=k.observer(({dataSource:e})=>{const{t}=m.useTranslation(),r=e.dbInfo;return h.useEffect(()=>{r.loadTablesIfEmpty()},[r]),r.tables.error?n.jsx(s.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:r.tables.error}):n.jsxs(s.Flex,{sx:{height:"100%"},children:[n.jsx(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n.jsx(ne,{children:n.jsx(F3,{dataSource:e})})}),n.jsxs(s.Tabs,{defaultValue:"structure",styles:Y3,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"structure",leftSection:n.jsx(T.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),n.jsx(s.Tabs.Tab,{value:"data",leftSection:n.jsx(T.IconDatabase,{size:14}),children:t("data.label")})]}),n.jsx(s.Tabs.Panel,{value:"structure",children:n.jsx(N3,{dataSource:e})}),n.jsx(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n.jsx(K3,{dataSource:e})})]})]})}),Z3={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},Td=k.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:r}=m.useTranslation(),[a,o]=h.useState(!1),{type:l}=e;return l==="http"||l==="merico_metric_system"?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:a,onClose:()=>o(!1),title:n.jsxs(s.Group,{justify:"space-between",sx:{flexGrow:1},children:[n.jsx(s.Text,{size:"sm",fw:500,children:r("data_source.explorer")}),n.jsxs(s.Group,{gap:7,children:[n.jsx(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n.jsx(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:Z3,children:n.jsx(s.Box,{sx:{height:"calc(100vh - 220px)"},children:n.jsx(X3,{dataSource:e})})}),n.jsx(s.Button,{variant:"subtle",onClick:()=>o(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:r("data_source.see_table_structure")})]})}),kd={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"指标系统"},J3=({option:e,...t})=>{const{label:r,type:a}=e;return a===W.Transform?n.jsxs(s.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[n.jsx(T.IconVectorTriangle,{size:14,color:"#228be6"}),n.jsx(s.Text,{size:"sm",c:"blue",children:r})]}):n.jsxs(s.Group,{justify:"space-between",...t,sx:{flexGrow:1},children:[n.jsx(s.Text,{size:"sm",children:r}),n.jsx(s.Text,{size:"sm",children:kd[a]})]})},Dd=k.observer(({queryModel:e,size:t="sm"})=>{const{t:r}=m.useTranslation(),a=j(),{data:o=[],loading:l}=O.useRequest(La,{refreshDeps:[]},[]),i=h.useMemo(()=>{const p=o.map(g=>({label:g.key,value:g.key,type:g.type}));return p.push({label:r("query.transform.data_source"),value:W.Transform,type:W.Transform}),p},[o]),c=h.useMemo(()=>i.reduce((p,g)=>(p[g.value]=g.type,p),{}),[i]),d=p=>{p!==null&&(e.setKey(p),e.setType(c[p]))},u=h.useMemo(()=>a.datasources.find({type:e.type,key:e.key}),[a,e.type,e.key]);return n.jsx(s.Select,{size:t,data:i,label:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Box,{children:r("data_source.label")}),u&&n.jsx(Td,{dataSource:u,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:J3,rightSection:u?n.jsx(s.Text,{size:"xs",c:"dimmed",children:kd[u.type]??u.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1,minWidth:"300px"},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:l,value:e.key,onChange:d})}),H3=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),[r,a]=h.useState(e.name);h.useEffect(()=>{a(e.name)},[e.name]);const o=h.useMemo(()=>e.conditionOptionsWithInvalidRunbys.optionGroups.map(i=>({group:t(i.group),items:i.items})),[e.conditionOptionsWithInvalidRunbys.optionGroups]);return n.jsx(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:n.jsxs(s.Stack,{gap:10,sx:{width:"100%"},children:[n.jsx(s.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),n.jsx(s.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:r,onChange:l=>{a(l.currentTarget.value)},rightSection:n.jsx(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(r),disabled:r===e.name,children:n.jsx(T.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(r)}}),n.jsx(Dd,{queryModel:e}),n.jsx(s.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),n.jsx(s.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:o,value:[...e.run_by],onChange:e.setRunBy,renderOption:br,maxDropdownHeight:500}),e.typedAsHTTP&&n.jsx(s.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:o,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:br,maxDropdownHeight:500}),e.isTransform&&n.jsx(s.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:o,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:br,maxDropdownHeight:500}),n.jsx(s.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(A3,{queryModel:e})]})})});function R3({content:e}){return n.jsxs(s.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.ActionIcon,{size:16,color:"blue",variant:"subtle",children:n.jsx(T.IconEye,{})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(Qe.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const e5=k.observer(()=>{const t=[...j().globalSQLSnippets.list];return t.length===0?null:n.jsxs(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:"Key"}),n.jsx(s.Table.Th,{children:"Value"})]})}),n.jsx(s.Table.Tbody,{children:t.map(r=>{const{id:a,content:o}=r;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:a}),n.jsx(s.Table.Td,{width:200,children:n.jsx(R3,{content:o})})]},a)})})]})}),t5=`
|
|
554
554
|
-- You may reference query variables in SQL or VizConfig.
|
|
555
555
|
SELECT *
|
|
556
556
|
FROM commit
|
|
@@ -563,10 +563,10 @@ WHERE
|
|
|
563
563
|
AND \${sql_snippets.author_email_condition}
|
|
564
564
|
-- Global SQL snippets (shared between dashboards)
|
|
565
565
|
AND \${global_sql_snippets.account_condition}
|
|
566
|
-
`,zd=k.observer(function({showSQLSnippets:t=!0,sx:r={}}){const{t:a}=m.useTranslation(),o=j(),l=F(),i=(()=>{const c=o.queryVariables;return t&&(c.sql_snippets=l.sqlSnippets.record),JSON.stringify(c,null,2)})();return n.jsx(s.Stack,{sx:{overflow:"hidden",...r},children:n.jsxs(s.Tabs,{defaultValue:"guide",keepMounted:!1,children:[n.jsxs(s.Tabs.List,{grow:!0,children:[n.jsx(s.Tabs.Tab,{value:"guide",leftSection:n.jsx(T.IconAlertCircle,{size:14}),children:a("query_variable.guide.tabs.guide")}),n.jsx(s.Tabs.Tab,{value:"local_query_vars",leftSection:n.jsx(T.IconVariable,{size:14}),children:a("query_variable.guide.tabs.variables_in_this_dashboard")}),n.jsx(s.Tabs.Tab,{value:"global_sql_snippets",leftSection:n.jsx(T.IconVariablePlus,{size:14}),children:a("query_variable.guide.tabs.global_sql_snippets")})]}),n.jsx(s.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:
|
|
566
|
+
`,zd=k.observer(function({showSQLSnippets:t=!0,sx:r={}}){const{t:a}=m.useTranslation(),o=j(),l=F(),i=(()=>{const c=o.queryVariables;return t&&(c.sql_snippets=l.sqlSnippets.record),JSON.stringify(c,null,2)})();return n.jsx(s.Stack,{sx:{overflow:"hidden",...r},children:n.jsxs(s.Tabs,{defaultValue:"guide",keepMounted:!1,children:[n.jsxs(s.Tabs.List,{grow:!0,children:[n.jsx(s.Tabs.Tab,{value:"guide",leftSection:n.jsx(T.IconAlertCircle,{size:14}),children:a("query_variable.guide.tabs.guide")}),n.jsx(s.Tabs.Tab,{value:"local_query_vars",leftSection:n.jsx(T.IconVariable,{size:14}),children:a("query_variable.guide.tabs.variables_in_this_dashboard")}),n.jsx(s.Tabs.Tab,{value:"global_sql_snippets",leftSection:n.jsx(T.IconVariablePlus,{size:14}),children:a("query_variable.guide.tabs.global_sql_snippets")})]}),n.jsx(s.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t5})}),n.jsx(s.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:i})}),n.jsx(s.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:n.jsxs(s.Stack,{gap:10,children:[n.jsx(s.Alert,{icon:n.jsx(T.IconAlertCircle,{size:16}),title:a("global_sql_snippet.labels"),children:a("global_sql_snippet.description")}),n.jsx(e5,{})]})})]})})}),ps=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:()=>r(!1),title:e("query_variable.labels"),zIndex:320,size:"800px",children:n.jsx(zd,{})}),n.jsx(s.Button,{variant:"subtle",onClick:()=>r(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:e("query_variable.open")})]})}),Md={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
|
|
567
567
|
`),post:["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
568
|
-
`)},
|
|
568
|
+
`)},n5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation();return e.typedAsHTTP?n.jsxs(s.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"pre_process",children:t("query.build_request")}),n.jsx(s.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),n.jsx(ps,{})]}),n.jsx(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n.jsx(Tt,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:Md.pre})}),n.jsx(s.Tabs.Panel,{value:"post_process",p:"sm",children:n.jsx(Tt,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Md.post})})]}):null}),Id=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=j().editor,a=i=>{if(i.type==="filter"){r.setPath(["_FILTERS_",i.id]);return}if(i.type==="panel"){const c=i.views[0].id;r.setPath(["_VIEWS_",c,"_PANELS_",i.id,"_TABS_","Data"]);return}},o=i=>{r.setPath(["_VIEWS_",i])},l=e.usage;return n.jsxs(s.Table,{highlightOnHover:!0,layout:"fixed",styles:{table:{fontSize:"14px"}},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:100},children:t("common.type")}),n.jsx(s.Table.Th,{style:{width:"calc(50% - 50px)"},children:t("common.name")}),n.jsx(s.Table.Th,{children:t("query.usage.in_views")})]})}),n.jsx(s.Table.Tbody,{children:l.map(i=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:t(i.type_label)}),n.jsx(s.Table.Td,{children:n.jsx(s.Anchor,{size:"sm",component:"button",type:"button",onClick:()=>a(i),children:i.label})}),n.jsx(s.Table.Td,{children:n.jsxs(s.Stack,{align:"flex-start",justify:"flex-start",gap:2,children:[i.views.map(c=>n.jsx(s.Anchor,{size:"sm",component:"button",type:"button",onClick:()=>o(c.id),children:n.jsx(s.Box,{children:c.label})},c.id)),i.views.length===0&&n.jsx(s.Box,{children:"--"})]})})]},i.id))})]})}),r5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=h.useMemo(()=>y.groupBy(e.dependencies,"type"),[e.dependencies]),a=h.useMemo(()=>e.dependencies.some(l=>!l.valid),[e.dependencies]),o=e.dependencies.length>0;return o?n.jsxs(s.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!o,children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Button,{size:"xs",variant:"subtle",color:a?"red":"green",disabled:!o,leftSection:a?n.jsx(T.IconAlertTriangle,{size:16}):n.jsx(T.IconDiscountCheckFilled,{size:16}),children:t("query.dependency.label")})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.List,{spacing:"md",size:"sm",listStyleType:"none",children:Object.entries(r).map(([l,i])=>n.jsxs(s.List.Item,{children:[n.jsx(s.Text,{size:"sm",fw:"bold",ff:"monospace",children:t(`${l}.label`)}),n.jsx(s.List,{withPadding:!0,size:"sm",sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:i.map(c=>n.jsx(s.List.Item,{icon:n.jsx(s.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:n.jsx(T.IconPointFilled,{size:12})}),children:c.key},c.key))})]},l))})})]}):n.jsx(s.Tooltip,{label:t("query.dependency.has_none"),children:n.jsx(s.Button,{size:"xs",variant:"subtle",color:"gray",leftSection:n.jsx(T.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:t("query.dependency.label")})})}),a5="SELECT 1",s5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=e.config,[a,o]=h.useState(r.sql),l=()=>{r.setSQL(a)},i=()=>{o(r.sql)},c=()=>{o(a5)};h.useEffect(()=>{o(r.sql)},[r.sql]);const d=a!==r.sql;return n.jsxs(s.Stack,{gap:4,sx:{height:"100%"},children:[n.jsxs(s.Group,{mb:6,justify:"space-between",sx:{flexShrink:0,flexGrow:0},children:[n.jsx(s.Group,{justify:"flex-start",children:n.jsx(r5,{queryModel:e})}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:c,size:"xs",variant:"default",leftSection:n.jsx(T.IconPlayerSkipBack,{size:16}),children:t("common.actions.reset_to_default")}),n.jsx(s.Button,{onClick:i,color:"red",size:"xs",disabled:!d,leftSection:n.jsx(T.IconRecycle,{size:16}),children:t("common.actions.revert_changes")}),n.jsx(s.Button,{color:"green",size:"xs",onClick:l,disabled:!d,leftSection:n.jsx(T.IconDeviceFloppy,{size:16}),children:t("common.actions.save_changes")})]})]}),n.jsx(yr,{height:"100%",value:a,onChange:o,theme:"sql-dark",defaultLanguage:"sql"})]})}),o5=({value:e,height:t="200px",defaultLanguage:r="sql"})=>n.jsx(Se,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:r,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),l5=k.observer(({value:e})=>{const r=H().payloadForSQL,a=h.useMemo(()=>wr(e,r),[e,r]);return n.jsx(o5,{height:"100%",value:a})}),Vd={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
|
|
569
569
|
`),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
|
|
570
|
-
`)},
|
|
571
|
-
`),post:""},c5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=F();if(!e.isTransform)return null;const a=e.config;return n.jsxs(s.Stack,{py:20,px:20,sx:{height:"100%"},children:[n.jsx(s.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),n.jsx(s.MultiSelect,{data:r.queries.optionsWithoutTransform,value:[...a.dep_query_ids],onChange:a.setDependantQueryIDs,maxDropdownHeight:800}),n.jsx(s.Text,{size:"sm",children:t("query.transform.guide.write_function")}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(Tt,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:i5.pre})})]})}),nn={height:"calc(100% - 44px)",padding:0},d5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=F(),a=h.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[o,l]=h.useState(a);h.useEffect(()=>{l(d=>d!=="Configurations"&&a==="Configurations"?"Configurations":d)},[a]);const c=r.findQueryUsage(e.id).length===0;return n.jsxs(s.Tabs,{value:o,onChange:l,defaultValue:a,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[n.jsxs(s.Tabs.List,{grow:!0,children:[n.jsx(s.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&n.jsx(s.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&n.jsx(s.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&n.jsx(s.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),n.jsx(s.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:n.jsx(s.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:n.jsx(s.Text,{size:"sm",children:t("data.preview_data")})})}),n.jsx(s.Tabs.Tab,{value:"Usage",disabled:c,children:n.jsx(s.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:n.jsx(s.Text,{size:"sm",children:t("query.usage.label")})})})]}),n.jsx(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n.jsx(J3,{queryModel:e})}),e.typedAsSQL&&n.jsx(s.Tabs.Panel,{value:"SQL",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(l5,{queryModel:e})})}),e.typedAsHTTP&&n.jsx(s.Tabs.Panel,{value:"HTTP",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(t5,{queryModel:e})})}),e.isTransform&&n.jsx(s.Tabs.Panel,{value:"Transform",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(c5,{queryModel:e})})}),n.jsx(s.Tabs.Panel,{value:"Data",sx:{...nn,overflow:"hidden"},children:n.jsx(cs,{id:e.id,moreActions:null,refreshOnMount:!0})}),n.jsx(s.Tabs.Panel,{value:"Usage",py:"sm",px:"md",sx:{...nn,overflow:"hidden"},children:n.jsx(Id,{queryModel:e})})]})}),u5=({width:e,height:t})=>n.jsxs("svg",{width:e,height:t,viewBox:"0 0 36 36",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 10.5C7.10217 10.5 6.72064 10.658 6.43934 10.9393C6.15804 11.2206 6 11.6022 6 12V28.5C6 28.8978 6.15804 29.2794 6.43934 29.5607C6.72064 29.842 7.10218 30 7.5 30H24C24.3978 30 24.7794 29.842 25.0607 29.5607C25.342 29.2794 25.5 28.8978 25.5 28.5V19.5C25.5 18.6716 26.1716 18 27 18C27.8284 18 28.5 18.6716 28.5 19.5V28.5C28.5 29.6935 28.0259 30.8381 27.182 31.682C26.3381 32.5259 25.1935 33 24 33H7.5C6.30653 33 5.16193 32.5259 4.31802 31.682C3.47411 30.8381 3 29.6935 3 28.5V12C3 10.8065 3.47411 9.66193 4.31802 8.81802C5.16193 7.97411 6.30653 7.5 7.5 7.5H16.5C17.3284 7.5 18 8.17157 18 9C18 9.82843 17.3284 10.5 16.5 10.5H7.5Z",fill:"#3D3E45"}),n.jsx("path",{d:"M32.8862 3.92582C32.8135 3.75021 32.7061 3.5856 32.5638 3.44253C32.5617 3.4404 32.5596 3.43828 32.5575 3.43616C32.2863 3.16658 31.9126 3 31.5 3H22.5C21.6716 3 21 3.67157 21 4.5C21 5.32843 21.6716 6 22.5 6H27.8787L13.9393 19.9393C13.3536 20.5251 13.3536 21.4749 13.9393 22.0607C14.5251 22.6464 15.4749 22.6464 16.0607 22.0607L30 8.12132V13.5C30 14.3284 30.6716 15 31.5 15C32.3284 15 33 14.3284 33 13.5V4.5C33 4.29662 32.9595 4.10268 32.8862 3.92582Z",fill:"#3D3E45"})]}),Pd=({width:e,height:t,color:r="#FFFFFF"})=>n.jsxs("svg",{viewBox:"0 0 36 36",fill:"none",width:e,height:t,children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.6931 20.547C26.1129 19.5516 26.113 17.4483 24.6931 16.4529L16.9351 11.0141C15.2783 9.85255 13 11.0377 13 13.0611L13 23.9389C13 25.9623 15.2783 27.1474 16.9351 25.9859L24.6931 20.547ZM16 14.0223L22.387 18.5L16 22.9777L16 14.0223Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 1.5C8.8873 1.5 1.5 8.8873 1.5 18C1.5 27.1127 8.8873 34.5 18 34.5C27.1127 34.5 34.5 27.1127 34.5 18C34.5 8.8873 27.1127 1.5 18 1.5ZM4.5 18C4.5 10.5442 10.5442 4.5 18 4.5C25.4558 4.5 31.5 10.5442 31.5 18C31.5 25.4558 25.4558 31.5 18 31.5C10.5442 31.5 4.5 25.4558 4.5 18Z",fill:r})]}),$d=({width:e,height:t,color:r="#EB1212"})=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M6.66665 6.66699C7.03484 6.66699 7.33331 6.96547 7.33331 7.33366V11.3337C7.33331 11.7018 7.03484 12.0003 6.66665 12.0003C6.29846 12.0003 5.99998 11.7018 5.99998 11.3337V7.33366C5.99998 6.96547 6.29846 6.66699 6.66665 6.66699Z",fill:r}),n.jsx("path",{d:"M9.99998 11.3337V7.33366C9.99998 6.96547 9.7015 6.66699 9.33331 6.66699C8.96512 6.66699 8.66665 6.96547 8.66665 7.33366V11.3337C8.66665 11.7018 8.96512 12.0003 9.33331 12.0003C9.7015 12.0003 9.99998 11.7018 9.99998 11.3337Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66665 3.33366V2.66699C4.66665 2.13656 4.87736 1.62785 5.25243 1.25278C5.62751 0.877706 6.13621 0.666992 6.66665 0.666992H9.33331C9.86375 0.666992 10.3725 0.877706 10.7475 1.25278C11.1226 1.62785 11.3333 2.13656 11.3333 2.66699V3.33366H14C14.3682 3.33366 14.6666 3.63214 14.6666 4.00033C14.6666 4.36852 14.3682 4.66699 14 4.66699H13.3333V13.3337C13.3333 13.8641 13.1226 14.3728 12.7475 14.7479C12.3725 15.1229 11.8637 15.3337 11.3333 15.3337H4.66665C4.13621 15.3337 3.62751 15.1229 3.25243 14.7479C2.87736 14.3728 2.66665 13.8641 2.66665 13.3337V4.66699H1.99998C1.63179 4.66699 1.33331 4.36852 1.33331 4.00033C1.33331 3.63214 1.63179 3.33366 1.99998 3.33366H4.66665ZM6.19524 2.19559C6.32027 2.07056 6.48984 2.00033 6.66665 2.00033H9.33331C9.51012 2.00033 9.67969 2.07056 9.80472 2.19559C9.92974 2.32061 9.99998 2.49018 9.99998 2.66699V3.33366H5.99998V2.66699C5.99998 2.49018 6.07022 2.32061 6.19524 2.19559ZM3.99998 4.66699V13.3337C3.99998 13.5105 4.07022 13.68 4.19524 13.8051C4.32027 13.9301 4.48984 14.0003 4.66665 14.0003H11.3333C11.5101 14.0003 11.6797 13.9301 11.8047 13.8051C11.9297 13.68 12 13.5105 12 13.3337V4.66699H3.99998Z",fill:r})]}),p5=({width:e,height:t})=>n.jsxs("svg",{viewBox:"0 0 18 18",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M7.5 3.75C7.5 2.92157 8.17157 2.25 9 2.25C9.82843 2.25 10.5 2.92157 10.5 3.75C10.5 4.57843 9.82843 5.25 9 5.25C8.17157 5.25 7.5 4.57843 7.5 3.75Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.5 9C7.5 8.17157 8.17157 7.5 9 7.5C9.82843 7.5 10.5 8.17157 10.5 9C10.5 9.82843 9.82843 10.5 9 10.5C8.17157 10.5 7.5 9.82843 7.5 9Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9 12.75C8.17157 12.75 7.5 13.4216 7.5 14.25C7.5 15.0784 8.17157 15.75 9 15.75C9.82843 15.75 10.5 15.0784 10.5 14.25C10.5 13.4216 9.82843 12.75 9 12.75Z",fill:"#3D3E45"})]}),h5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=j(),a=F(),l=a.findQueryUsage(e.id).length>0,i=De.useModals(),c=()=>{i.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.queries.removeQuery(e.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?n.jsx(s.Tooltip,{label:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"bottom-end",children:n.jsx(s.Button,{leftSection:n.jsx($d,{width:14,height:14,color:"gray"}),variant:"subtle",color:"gray",onClick:d=>{d.stopPropagation()},children:"删除查询"})}):n.jsx(s.Menu.Item,{leftSection:n.jsx($d,{width:14,height:14}),color:"red",onClick:c,children:"删除查询"})}),g5=k.observer(({queryModel:e})=>n.jsxs(s.Menu,{shadow:"md",width:120,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle","aria-label":"Settings",children:n.jsx(p5,{width:18,height:18})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(h5,{queryModel:e})})]})),f5={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function b5({data:e}){const t=h.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const a=ge.createColumnHelper();return Object.keys(e[0]).map(o=>a.accessor(o,{cell:l=>l.getValue()}))},[e]),r=ge.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel()});return e.length===0?n.jsx(s.Box,{sx:{height:"5em"}}):n.jsx(ne,{children:n.jsxs(s.Table,{sx:f5,stickyHeader:!0,stickyHeaderOffset:0,children:[n.jsx(s.Table.Thead,{style:{backgroundColor:"#F9F9FA"},children:r.getHeaderGroups().map(a=>n.jsx(s.Table.Tr,{children:a.headers.map(o=>n.jsxs(s.Table.Th,{style:{width:o.getSize()},children:[o.isPlaceholder?null:ge.flexRender(o.column.columnDef.header,o.getContext()),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:o.getResizeHandler(),onTouchStart:o.getResizeHandler(),className:`resizer ${o.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},o.id))},a.id))}),n.jsx(s.Table.Tbody,{children:r.getRowModel().rows.map(a=>n.jsx(s.Table.Tr,{children:a.getVisibleCells().map(o=>n.jsx(s.Table.Td,{children:n.jsx(ne,{children:typeof o.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(o.getValue(),null,2)}):ge.flexRender(o.column.columnDef.cell,o.getContext())})},o.id))},a.id))})]})})}const y5=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],v5={root:{width:"150px"},section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px",paddingRight:0}},_5=({data:e,page:t,setPage:r,limit:a,setLimit:o})=>{const{t:l}=m.useTranslation(),i=e.length,c=Math.ceil(i/a),d=p=>{p&&(r(1),o(Number(p)))};if(i===0)return null;const u=c===1&&i<=10;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[!u&&n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"xs",children:l("common.pagination.page_size")}),size:"xs",styles:v5,data:y5,value:String(a),onChange:d}),c>1&&n.jsx(s.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}},color:"red"})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:l("common.pagination.total_rows",{total:i})})})]})},m5=Io(({data:e,loading:t})=>{const[r,a]=h.useState(1),[o,l]=h.useState(20),i=h.useMemo(()=>{const c=(r-1)*o,d=c+o;return e.slice(c,d)},[e,r,o]);return n.jsx(ne,{children:n.jsxs(s.Stack,{gap:10,styles:{root:{height:"100%",overflow:"hidden"}},children:[n.jsx(_5,{data:e,page:r,setPage:a,limit:o,setLimit:l}),n.jsxs(s.Box,{sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(b5,{data:i})]})]})})}),w5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),{state:r,error:a,metricQueryPayloadErrorString:o,stateMessage:l}=e;return r==="loading"?null:a?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:a}):o?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:o}):l?n.jsx(s.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(l)}):null}),x5=k.observer(({queryModel:e})=>{m.useTranslation();const{data:t,state:r}=e,a=r==="loading",o=h.useCallback(()=>{e.fetchData(!0)},[e.fetchData]),l=()=>{Hi(e.name,e.data)};h.useEffect(()=>{o()},[o]);const i=!Array.isArray(t)||t.length===0;return n.jsxs(s.Stack,{gap:0,sx:{maxHeight:"calc(50vh - 48px)",flexGrow:1,flexShrink:0,background:"#F9F9FA"},children:[n.jsxs(s.Group,{justify:"space-between",py:7,px:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"查询结果"}),n.jsx(s.Button,{size:"xs",variant:"transparent",color:"gray",leftSection:n.jsx(T.IconDownload,{size:16}),disabled:a||i,onClick:l,children:"下载查询结果"})]}),n.jsxs(s.Box,{sx:{position:"relative",flexGrow:1,overflow:"hidden"},children:[n.jsx(w5,{queryModel:e}),n.jsx(m5,{data:t,loading:a})]})]})}),C5=k.observer(({queryModel:e})=>{const t=j();return n.jsxs(s.Tabs,{defaultValue:"看板变量预览",w:"40%",maw:"600px",styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"},panel:{height:"calc(100% - 36px)"}},color:"red",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"看板变量预览",children:"看板变量预览"}),n.jsx(s.Tabs.Tab,{value:"查询预览",children:"查询预览"})]}),n.jsx(s.Tabs.Panel,{value:"查询预览",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.metricQueryPayloadString})}),n.jsx(s.Tabs.Panel,{value:"看板变量预览",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:t.queryVariablesString})})]})}),S5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.24335 1.62305C7.50108 1.62305 7.71001 1.83198 7.71001 2.08971L7.71001 11.423C7.71001 11.6808 7.50108 11.8897 7.24335 11.8897C6.98561 11.8897 6.77668 11.6808 6.77668 11.423L6.77668 2.08971C6.77668 1.83198 6.98561 1.62305 7.24335 1.62305Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.93845 9.4786C9.80779 9.4786 9.70045 9.43893 9.61645 9.3596C9.53712 9.2756 9.49745 9.17293 9.49745 9.0516L9.49745 5.0056C9.49745 4.88427 9.53712 4.78393 9.61645 4.7046C9.70045 4.6206 9.80312 4.5786 9.92445 4.5786L12.1995 4.5786C12.3208 4.5786 12.4211 4.61827 12.5005 4.6976C12.5845 4.77227 12.6265 4.87027 12.6265 4.9916C12.6265 5.09427 12.5845 5.18527 12.5005 5.2646C12.4211 5.34393 12.3208 5.3836 12.1995 5.3836L10.3725 5.3836V6.6156H11.8845C12.0058 6.6156 12.1061 6.65527 12.1855 6.7346C12.2695 6.80927 12.3115 6.90727 12.3115 7.0286C12.3115 7.13127 12.2695 7.22227 12.1855 7.3016C12.1061 7.38093 12.0058 7.4206 11.8845 7.4206H10.3725L10.3725 9.0516C10.3725 9.17293 10.3281 9.2756 10.2395 9.3596C10.1555 9.43893 10.0551 9.4786 9.93845 9.4786Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.34754 9.4786C3.21687 9.4786 3.10954 9.43893 3.02554 9.3596C2.94154 9.2756 2.89954 9.17293 2.89954 9.0516L2.89954 5.3836H1.80054C1.6792 5.3836 1.57654 5.34627 1.49254 5.2716C1.4132 5.19693 1.37354 5.09893 1.37354 4.9776C1.37354 4.85627 1.4132 4.7606 1.49254 4.6906C1.57654 4.61593 1.6792 4.5786 1.80054 4.5786H4.90854C5.02987 4.5786 5.1302 4.61593 5.20954 4.6906C5.29354 4.76527 5.33554 4.86327 5.33554 4.9846C5.33554 5.10593 5.29354 5.20393 5.20954 5.2786C5.1302 5.3486 5.02987 5.3836 4.90854 5.3836H3.80954L3.80954 9.0516C3.80954 9.17293 3.7652 9.2756 3.67654 9.3596C3.59254 9.43893 3.48287 9.4786 3.34754 9.4786Z",fill:"#3D3E45"})]}),T5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_245_10828)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91663 1.16634C9.91663 0.844175 9.65546 0.583008 9.33329 0.583008C9.01113 0.583008 8.74996 0.844175 8.74996 1.16634V1.74967L5.24996 1.74967V1.16634C5.24996 0.844175 4.98879 0.583008 4.66663 0.583008C4.34446 0.583008 4.08329 0.844175 4.08329 1.16634V1.74967H2.91663C1.95013 1.74967 1.16663 2.53318 1.16663 3.49967L1.16663 11.6663C1.16663 12.6328 1.95013 13.4163 2.91663 13.4163L11.0833 13.4163C12.0498 13.4163 12.8333 12.6328 12.8333 11.6663L12.8333 3.49967C12.8333 2.53318 12.0498 1.74967 11.0833 1.74967H9.91663V1.16634ZM11.6666 5.24967V3.49967C11.6666 3.17751 11.4055 2.91634 11.0833 2.91634H9.91663V3.49967C9.91663 3.82184 9.65546 4.08301 9.33329 4.08301C9.01113 4.08301 8.74996 3.82184 8.74996 3.49967V2.91634L5.24996 2.91634V3.49967C5.24996 3.82184 4.98879 4.08301 4.66663 4.08301C4.34446 4.08301 4.08329 3.82184 4.08329 3.49967V2.91634L2.91663 2.91634C2.59446 2.91634 2.33329 3.17751 2.33329 3.49967L2.33329 5.24967L11.6666 5.24967ZM2.33329 6.41634L11.6666 6.41634L11.6666 11.6663C11.6666 11.9885 11.4055 12.2497 11.0833 12.2497L2.91663 12.2497C2.59446 12.2497 2.33329 11.9885 2.33329 11.6663V6.41634Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_245_10828",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),k5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.11108 2.13932C2.78892 2.13932 2.52775 2.40049 2.52775 2.72266V10.8893C2.52775 11.2115 2.78892 11.4727 3.11108 11.4727H11.2778C11.5999 11.4727 11.8611 11.2115 11.8611 10.8893V2.72266C11.8611 2.40049 11.5999 2.13932 11.2778 2.13932H3.11108ZM1.36108 2.72266C1.36108 1.75616 2.14459 0.972656 3.11108 0.972656H11.2778C12.2442 0.972656 13.0278 1.75616 13.0278 2.72266V10.8893C13.0278 11.8558 12.2442 12.6393 11.2778 12.6393H3.11108C2.14459 12.6393 1.36108 11.8558 1.36108 10.8893V2.72266Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.84418 8.37166C9.94816 8.37166 10.0348 8.40631 10.1041 8.47563C10.1734 8.54494 10.2081 8.63159 10.2081 8.73556C10.2081 8.8352 10.1734 8.91968 10.1041 8.989C10.0348 9.05398 9.94816 9.08647 9.84418 9.08647H7.63475C7.52211 9.08647 7.4333 9.05182 7.36832 8.9825C7.30334 8.91318 7.27084 8.82437 7.27084 8.71607C7.27084 8.60776 7.30983 8.51245 7.38781 8.43014L8.80445 6.91603C8.96474 6.74274 9.09038 6.56512 9.18135 6.38317C9.27666 6.20121 9.32432 6.04309 9.32432 5.90879C9.32432 5.69218 9.2615 5.51889 9.13587 5.38892C9.01023 5.25462 8.84344 5.18747 8.63549 5.18747C8.55318 5.18747 8.4687 5.20697 8.38206 5.24596C8.29541 5.28495 8.21094 5.3391 8.12862 5.40842C8.05064 5.47773 7.977 5.55788 7.90768 5.64885C7.85569 5.71817 7.80371 5.76149 7.75172 5.77882C7.69973 5.79615 7.65208 5.80481 7.60876 5.80481C7.51345 5.80481 7.42464 5.77016 7.34233 5.70084C7.26435 5.62719 7.22536 5.54271 7.22536 5.44741C7.22536 5.37376 7.24918 5.30228 7.29684 5.23296C7.34882 5.16365 7.41164 5.09216 7.48529 5.01852C7.59359 4.91021 7.7149 4.8149 7.8492 4.73259C7.98349 4.65028 8.12213 4.58746 8.26509 4.54414C8.40805 4.49648 8.54668 4.47266 8.68098 4.47266C8.97124 4.47266 9.22251 4.53114 9.43479 4.64811C9.6514 4.76075 9.81819 4.92321 9.93516 5.13549C10.0521 5.34343 10.1106 5.59037 10.1106 5.8763C10.1106 6.11457 10.0391 6.381 9.89617 6.67559C9.75754 6.96585 9.56909 7.23878 9.33081 7.49438L8.50837 8.37166H9.84418Z",fill:"#3D3E45"}),n.jsx("path",{d:"M5.49994 9.08647C5.37864 9.08647 5.279 9.04965 5.20102 8.976C5.12304 8.89802 5.08405 8.80271 5.08405 8.69007V5.62518L4.70065 5.90879C4.64 5.95644 4.56418 5.98027 4.47321 5.98027C4.36923 5.98027 4.27826 5.94128 4.20028 5.8633C4.1223 5.78532 4.08331 5.69218 4.08331 5.58387C4.08331 5.44524 4.15046 5.3326 4.28475 5.24596L5.22051 4.62212C5.26384 4.59179 5.31149 4.57013 5.36348 4.55713C5.4198 4.54414 5.47178 4.53764 5.51944 4.53764C5.64507 4.53764 5.74471 4.57663 5.81836 4.65461C5.89201 4.72826 5.92883 4.8214 5.92883 4.93404V8.69007C5.92883 8.80271 5.88768 8.89802 5.80536 8.976C5.72738 9.04965 5.62558 9.08647 5.49994 9.08647Z",fill:"#3D3E45"})]}),D5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M12.0334 5.64833C12.3099 5.64833 12.55 5.67744 12.7537 5.73565C12.9623 5.79386 13.1224 5.87632 13.2339 5.98303C13.3504 6.0849 13.4086 6.20859 13.4086 6.35412C13.4086 6.45113 13.3795 6.5433 13.3213 6.63061C13.263 6.71307 13.1782 6.7543 13.0666 6.7543C12.989 6.7543 12.9235 6.7446 12.8701 6.7252C12.8216 6.70094 12.778 6.67184 12.7392 6.63788C12.7004 6.60393 12.6543 6.5724 12.6009 6.54329C12.5524 6.51419 12.4772 6.49236 12.3754 6.47781C12.2783 6.45841 12.2056 6.44871 12.1571 6.44871C11.9097 6.44871 11.6987 6.50206 11.5241 6.60878C11.3543 6.7155 11.2233 6.86102 11.1311 7.04535C11.039 7.22482 10.9929 7.43341 10.9929 7.67109C10.9929 7.90393 11.039 8.11251 11.1311 8.29684C11.2282 8.47631 11.3591 8.61941 11.5241 8.72613C11.6938 8.83284 11.8879 8.8862 12.1061 8.8862C12.2274 8.8862 12.3317 8.87893 12.419 8.86437C12.5063 8.84982 12.5791 8.82799 12.6373 8.79889C12.7052 8.76008 12.7658 8.71885 12.8192 8.6752C12.8726 8.63154 12.9526 8.60971 13.0593 8.60971C13.1854 8.60971 13.2824 8.65094 13.3504 8.7334C13.4183 8.81102 13.4522 8.90803 13.4522 9.02445C13.4522 9.14572 13.3843 9.25728 13.2485 9.35915C13.1127 9.45616 12.9332 9.5362 12.7101 9.59926C12.4918 9.65747 12.2541 9.68657 11.997 9.68657C11.6138 9.68657 11.2815 9.59926 11.0002 9.42463C10.7188 9.24516 10.5005 9.00262 10.3453 8.69702C10.1949 8.39143 10.1198 8.04945 10.1198 7.67109C10.1198 7.27333 10.1998 6.92408 10.3599 6.62333C10.5248 6.31774 10.7504 6.08005 11.0366 5.91027C11.3276 5.73565 11.6599 5.64833 12.0334 5.64833Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.74826 5.64833C8.08781 5.64833 8.39099 5.73565 8.65778 5.91027C8.92942 6.08005 9.14285 6.31531 9.29807 6.61606C9.45815 6.9168 9.53819 7.26606 9.53819 7.66382C9.53819 8.06158 9.45815 8.41326 9.29807 8.71885C9.14285 9.0196 8.93184 9.25728 8.66505 9.43191C8.40311 9.60169 8.10722 9.68657 7.77737 9.68657C7.58334 9.68657 7.40143 9.65505 7.23166 9.59199C7.06188 9.52893 6.91151 9.44889 6.78054 9.35187C6.65442 9.25486 6.55498 9.15784 6.48222 9.06083C6.41431 8.95896 6.38035 8.87408 6.38035 8.80617L6.60591 8.71158V9.24273C6.60591 9.36885 6.56468 9.47557 6.48222 9.56288C6.39976 9.64534 6.29547 9.68657 6.16935 9.68657C6.04323 9.68657 5.93894 9.64534 5.85647 9.56288C5.77401 9.48042 5.73278 9.3737 5.73278 9.24273V4.67333C5.73278 4.54722 5.77401 4.44292 5.85647 4.36046C5.93894 4.27315 6.04323 4.22949 6.16935 4.22949C6.29547 4.22949 6.39976 4.27315 6.48222 4.36046C6.56468 4.44292 6.60591 4.54722 6.60591 4.67333V6.52147L6.48222 6.45598C6.48222 6.39292 6.51617 6.31774 6.58408 6.23042C6.652 6.13826 6.74416 6.04852 6.86058 5.96121C6.97699 5.86904 7.11039 5.79386 7.26076 5.73565C7.41599 5.67744 7.57849 5.64833 7.74826 5.64833ZM7.63912 6.44871C7.42569 6.44871 7.23893 6.50206 7.07886 6.60878C6.91879 6.7155 6.79267 6.86102 6.7005 7.04535C6.61319 7.22482 6.56953 7.43098 6.56953 7.66382C6.56953 7.8918 6.61319 8.10038 6.7005 8.28956C6.79267 8.47389 6.91879 8.61941 7.07886 8.72613C7.23893 8.83285 7.42569 8.8862 7.63912 8.8862C7.85255 8.8862 8.03688 8.83285 8.19211 8.72613C8.35218 8.61941 8.47587 8.47389 8.56319 8.28956C8.65535 8.10038 8.70143 7.8918 8.70143 7.66382C8.70143 7.43098 8.65535 7.22482 8.56319 7.04535C8.47587 6.86102 8.35218 6.7155 8.19211 6.60878C8.03688 6.50206 7.85255 6.44871 7.63912 6.44871Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.02845 5.66289L1.45681 9.35915C1.42286 9.45131 1.3695 9.52408 1.29674 9.57743C1.22883 9.62594 1.15364 9.65019 1.07118 9.65019C0.940211 9.65019 0.843196 9.61381 0.780136 9.54105C0.717077 9.46829 0.685547 9.37855 0.685547 9.27184C0.685547 9.22818 0.692823 9.1821 0.707375 9.13359L2.51913 4.78248C2.55793 4.68546 2.61614 4.61028 2.69375 4.55692C2.77622 4.50356 2.86353 4.48173 2.95569 4.49143C3.04301 4.49143 3.12304 4.51811 3.19581 4.57147C3.27342 4.61998 3.3292 4.69031 3.36316 4.78248L5.15308 9.04628C5.17733 9.10934 5.18946 9.16755 5.18946 9.2209C5.18946 9.35187 5.1458 9.45616 5.05849 9.53378C4.97603 9.61139 4.88386 9.65019 4.782 9.65019C4.69468 9.65019 4.61465 9.62352 4.54189 9.57016C4.47398 9.5168 4.42062 9.44404 4.38181 9.35187L2.81745 5.70654L3.02845 5.66289ZM1.68237 8.47146L2.08256 7.63471H4.04711L4.18536 8.47146H1.68237Z",fill:"#3D3E45"})]}),z5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_567_6919)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.00001 1.02051C7.29533 1.02051 7.53473 1.25991 7.53473 1.55523V2.99492L11.3486 5.17429C11.5152 5.2695 11.6181 5.44667 11.6181 5.63856V9.97475L13.0725 10.702C13.3366 10.834 13.4437 11.1552 13.3116 11.4194C13.1795 11.6835 12.8583 11.7906 12.5942 11.6585L11.1002 10.9115L7.26531 13.1028C7.10091 13.1968 6.8991 13.1968 6.73471 13.1028L2.89985 10.9115L1.40581 11.6585C1.14167 11.7906 0.820476 11.6835 0.688405 11.4194C0.556335 11.1552 0.663399 10.834 0.92754 10.702L2.38195 9.97475V5.63856C2.38195 5.44667 2.48477 5.2695 2.65138 5.17429L6.46529 2.99492V1.55523C6.46529 1.25991 6.70469 1.02051 7.00001 1.02051ZM7.00001 3.9211L3.99444 5.63856L7.00001 7.35603L10.0056 5.63856L7.00001 3.9211ZM10.5486 6.55999L7.53473 8.28221V11.7171L10.5486 9.99492V6.55999ZM6.46529 11.7171V8.28221L3.4514 6.55999V9.99492L6.46529 11.7171Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_567_6919",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),hs=({type:e})=>{switch(e){case"boolean":return n.jsx(S5,{});case"date":return n.jsx(T5,{});case"number":return n.jsx(k5,{});case"string":return n.jsx(D5,{});case"dimension":return n.jsx(z5,{});default:return null}},Ad={option:{fontFamily:"monospace","&.sub-option":{position:"relative",marginLeft:"22px"},"&.sub-option::before":{content:'""',width:"1px",height:"100%",position:"absolute",left:"-6px",borderLeft:"1px solid #E7E7E9"}},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},group:{"&.dimension-group":{paddingBottom:"4px",".mantine-Combobox-groupLabel":{color:"#000"},".mantine-Combobox-groupLabel::before":{display:"none"},".mantine-Combobox-groupLabel::after":{display:"none"}}}},Ed={root:{maxWidth:"unset"},option:{fontFamily:"monospace"},input:{paddingInlineStart:"var(--input-padding-inline-start)",height:"auto",color:"black",fontFamily:"monospace"}},Bd=(e,t,r)=>{const a=[];return t&&a.push("sub-option"),r&&a.push("disabled"),n.jsx(s.Combobox.Option,{value:e.value,className:a.join(" "),disabled:r,children:n.jsxs(s.Stack,{gap:1,children:[n.jsxs(s.Group,{gap:4,children:[!!e.dataType&&n.jsx(hs,{type:e.dataType}),n.jsx(s.Text,{size:"xs",children:e.label})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",pl:18,children:e.description})]})},e.value)},qd=k.observer(({mmInfo:e,value:t,onChange:r,usedKeys:a})=>{const o=e.metricDetail,l=e.metrics.loading||o.loading,i=o.error,c=o.filterColOptions,d=s.useCombobox({onDropdownClose:()=>d.resetSelectedOption()}),u=h.useMemo(()=>l?n.jsx(s.Loader,{size:"xs"}):t?n.jsx(s.CloseButton,{size:"xs",onClick:()=>r(null)}):n.jsx(s.Combobox.Chevron,{size:"xs"}),[l,t]),p=n.jsx(s.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:u,rightSectionPointerEvents:!l&&t?"all":"none",onClick:()=>d.toggleDropdown(),disabled:l||c.length===0,styles:Ed,error:!!i,children:t||n.jsx(s.Input.Placeholder,{children:"选择维度"})});return n.jsxs(s.Combobox,{store:d,onOptionSubmit:g=>{r(g),d.closeDropdown()},styles:Ad,children:[n.jsx(s.Combobox.Target,{children:i?n.jsx(s.Tooltip,{label:i,children:p}):p}),n.jsx(s.Combobox.Dropdown,{miw:300,children:n.jsx(s.Combobox.Options,{mah:500,style:{overflowY:"auto"},children:c.map(({group:g,items:b})=>n.jsx(s.Combobox.Group,{label:g,children:b.map(_=>{var w;return"group"in _?n.jsx(s.Combobox.Group,{className:"dimension-group",label:n.jsxs(s.Group,{gap:4,children:[n.jsx(hs,{type:"dimension"}),n.jsx(s.Text,{size:"sm",children:_.group}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:_.description})]}),children:(w=_.items)==null?void 0:w.map(x=>Bd(x,!0,a.has(x.value)))},_.group):Bd(_,!1,a.has(_.value))})},g))})})]})}),gs={tbody:{td:{fontFamily:"monospace"}}},M5={root:{maxWidth:"unset"},option:{fontFamily:"monospace","&[data-checked=true][data-combobox-disabled]":{opacity:1}},input:{fontFamily:"monospace"},groupLabel:{"&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-gray-2)"}}},I5=({option:e,...t})=>{const{t:r}=m.useTranslation(),a=e,o=a.type==="filter";return n.jsxs(s.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsx(s.Group,{flex:"1",gap:4,children:n.jsx(s.Text,{size:"xs",children:e.value})}),o&&n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(s.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:1,flexGrow:1},children:a.widget_label}),n.jsx(s.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:r(nt[a.widget])})]})]})},Qt=k.observer(({queryModel:e,value:t,onChange:r,usedKeys:a})=>{const{t:o}=m.useTranslation();e.config;const l=h.useMemo(()=>e.getConditionOptionsWithInvalidValue(t).optionGroups.map(d=>{const u=d.items.length;return{group:`${o(d.group)}(${u})`,items:d.items.map(g=>({...g,label:g.value,widget_label:g.label,disabled:a==null?void 0:a.has(g.value)}))}}),[e.getConditionOptionsWithInvalidValue,o,t,a]),i=h.useCallback((c,d)=>{r(c,d)},[r]);return n.jsx(s.Select,{size:"xs",variant:"unstyled",placeholder:"选择变量",styles:M5,data:l,renderOption:I5,maxDropdownHeight:600,value:t,onChange:i,clearable:!0})}),Qn=k.observer(({variable:e})=>{const t=j();if(!e)return null;const r=y.has(t.queryVariables,e);return n.jsx(s.ThemeIcon,{variant:"white",size:"xs",color:r?"#88CE98":"#F15050",styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(T.IconPointFilled,{})})}),V5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo;return h.useEffect(()=>{a.selectMetric(t.id)},[t.id,a]),n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"看板变量与指标维度关联"}),n.jsx(s.Tooltip,{label:"将看板的筛选器参数与指标的查询维度关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})})]}),n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"49%"}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:"指标筛选维度"}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[t.filters.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(qd,{mmInfo:a,value:o.dimension,onChange:o.setDimension,usedKeys:t.usedFilterDimensionKeys})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(Qn,{variable:o.variable}),n.jsx(Qt,{queryModel:e,value:o.variable,onChange:o.setVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{size:"xs",checked:e.keyInRunBy(o.variable),onChange:l=>e.changeRunByRecord(o.variable,l.currentTarget.checked),color:"red"})})]},o.dimension)),n.jsxs(s.Table.Tr,{className:"add-a-row",children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(qd,{mmInfo:a,value:null,onChange:o=>o&&t.addFilter(o,""),usedKeys:t.usedFilterDimensionKeys})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsx(Qt,{queryModel:e,value:null,onChange:o=>o&&t.addFilter("",o)})}),n.jsx(s.Table.Td,{})]})]})]})]})}),P5=k.observer(({queryModel:e,variable:t})=>{const r=e.keyInRunBy(t),a=o=>{e.changeRunByRecord(t,o.currentTarget.checked)};return n.jsx(s.Checkbox,{size:"xs",checked:r,onChange:a,color:"red"})}),Od=({queryModel:e,variable:t})=>t?n.jsx(P5,{queryModel:e,variable:t}):null,$5=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail,l=o.trendingDateCol,i=t.timeQuery.enabled;return o.supportTrending?n.jsx(s.Switch,{size:"xs",color:"red",checked:i,onChange:c=>t.setTimeQueryEnabled(c.currentTarget.checked),styles:{track:{cursor:"pointer"}}}):n.jsx(s.Tooltip,{label:"由于指标未设定时序维度,所以不具备时间序列展示功能。",children:n.jsx(s.Box,{children:n.jsx(s.Switch,{size:"xs",color:"red",disabled:!l})})})}),A5=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail,l=o.trendingDateCol;return!t.timeQuery.enabled||!o.supportTrending?null:n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsxs(s.Group,{gap:4,children:[n.jsx(s.Text,{size:"xs",children:"时间维度"}),n.jsx(s.Text,{size:"xs",c:"dimmed",ff:"monospace",children:(l==null?void 0:l.name)??null})]})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Qn,{variable:t.timeQuery.range_variable}),n.jsx(Qt,{queryModel:e,value:t.timeQuery.range_variable,onChange:t.setRangeVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(s.Table.Td,{children:n.jsx(Od,{queryModel:e,variable:t.timeQuery.range_variable})})]},"dimension.time"),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Text,{size:"xs",children:"步长"})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Qn,{variable:t.timeQuery.unit_variable}),n.jsx(Qt,{queryModel:e,value:t.timeQuery.unit_variable,onChange:t.setUnitVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(Od,{queryModel:e,variable:t.timeQuery.unit_variable})})]},"dimension.step")]})]})}),E5=k.observer(({queryModel:e})=>n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"按时间序列展示"}),n.jsx(s.Tooltip,{label:"将看板的时间&步长筛选器与相应的查询维度关联上。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})}),n.jsx($5,{queryModel:e})]}),n.jsx(A5,{queryModel:e})]})),Ld=k.observer(function({mmInfo:t,value:r,onChange:a,usedSqlVariables:o}){const l=t.metricDetail,i=t.metrics.loading||l.loading,c=l.error,d=h.useMemo(()=>(l.variables??[]).map(b=>({label:b,value:b})),[l.variables]),u=s.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),p=h.useMemo(()=>i?n.jsx(s.Loader,{size:"xs"}):r?n.jsx(s.CloseButton,{size:"xs",onClick:()=>a(null)}):n.jsx(s.Combobox.Chevron,{size:"xs"}),[i,r]),g=n.jsx(s.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:p,rightSectionPointerEvents:!i&&r?"all":"none",onClick:()=>u.toggleDropdown(),disabled:i||d.length===0,styles:Ed,error:!!c,children:r||n.jsx(s.Input.Placeholder,{children:"选择变量"})});return n.jsxs(s.Combobox,{store:u,onOptionSubmit:b=>{a(b),u.closeDropdown()},styles:Ad,children:[n.jsx(s.Combobox.Target,{children:c?n.jsx(s.Tooltip,{label:c,children:g}):g}),n.jsx(s.Combobox.Dropdown,{miw:300,children:n.jsx(s.Combobox.Options,{mah:500,style:{overflowY:"auto"},children:d.map(b=>n.jsx(s.Combobox.Option,{value:b.value,disabled:o.has(b.value),children:n.jsx(s.Stack,{gap:1,children:n.jsx(s.Group,{gap:4,children:n.jsx(s.Text,{size:"xs",children:b.label})})})},b.value))})})]})}),B5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo;return h.useEffect(()=>{a.selectMetric(t.id)},[t.id,a]),a.metricDetail.metricType!=="sql"?null:n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"看板变量与 SQL 指标关联"}),n.jsx(s.Tooltip,{label:"将看板的筛选器参数与指标的查询参数关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})})]}),n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"49%"}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:"SQL 查询参数"}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[t.sqlVariables.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(Ld,{mmInfo:a,value:o.sqlVar,onChange:o.setSqlVar,usedSqlVariables:t.usedSqlVariables})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(Qn,{variable:o.variable}),n.jsx(Qt,{queryModel:e,value:o.variable,onChange:o.setVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{size:"xs",checked:e.keyInRunBy(o.variable),onChange:l=>e.changeRunByRecord(o.variable,l.currentTarget.checked),color:"red"})})]},o.sqlVar)),n.jsxs(s.Table.Tr,{className:"add-a-row",children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(Ld,{mmInfo:a,value:null,onChange:o=>o&&t.addSqlVariable(o,""),usedSqlVariables:t.usedSqlVariables})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsx(Qt,{queryModel:e,value:null,onChange:o=>o&&t.addSqlVariable("",o)})}),n.jsx(s.Table.Td,{})]})]})]})]})}),q5={label:{fontWeight:"normal"},input:{fontSize:"12px"},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},option:{fontFamily:"monospace"}},O5=e=>{const t=e.option;return n.jsxs(s.Stack,{gap:1,styles:{root:{flexGrow:1}},children:[n.jsxs(s.Group,{gap:4,children:[n.jsx(hs,{type:t.dataType}),n.jsx(s.Text,{size:"xs",children:t.label})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",pl:18,children:t.description})]})},L5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metricDetail,l=a.metrics.loading||o.loading,i=o.groupByColOptions,c=d=>{const u=o.getGroupByOptions(d),p=[];u.forEach(g=>{g.dimension?g.dimension.fields.forEach(b=>{typeof b=="string"?p.push(`${g.value} -> ${b}`):p.push(`${g.value} -> ${b.field}`)}):p.push(g.value)}),t.setGroupBys(p)};return n.jsxs(n.Fragment,{children:[n.jsx(s.MultiSelect,{size:"sm",label:"分组聚合维度",description:"指标在查询时按照哪些维度进行聚合计算。最多支持两个维度的聚合计算。若选择按时间序列展示,则仅可选择一个聚合维度。",data:i,searchable:!0,styles:q5,renderOption:O5,rightSection:l?n.jsx(s.Loader,{size:"xs"}):null,value:[...t.groupByValues],onChange:c,maxValues:t.timeQuery.enabled?1:2,placeholder:t.timeQuery.enabled?"仅可选一个维度":"最多选两个维度",disabled:l}),n.jsx(s.Switch,{labelPosition:"left",label:"聚合维度为空时,自动补零",size:"sm",color:"red",checked:t.useDefaultValues,onChange:d=>t.setUseDefaultValues(d.currentTarget.checked),disabled:i.length===0})]})}),N5=e=>{if(!e)return null;try{const t=JSON.parse(e);return{calculation:t.calculation,n:t.n,direction:t.direction}}catch{return null}},G5=(e,t,r)=>{const a={max:"最大值",min:"最小值",sum:"总和",avg:"平均值"};return Array.from(ic.entries()).filter(([o])=>e.includes(o)).map(([o,l])=>{const c=!r&&l.requireTrendingDateCol;let d=l.name;if(l.requireWindowConfig&&t){const u=a[t.calculation]||t.calculation,p=t.direction==="forward"?"向前":"向后";d=`${l.name} · ${u} · ${t.n} 个步长 · ${p}`}return{value:o,label:d,description:l.description,disabled:c,disabledReason:c?"需要开启按时序查询":void 0}})},F5=e=>{const t=e.option,r=n.jsx(s.Group,{gap:"xs",wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm",fw:500,children:t.label}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:t.description})]})});return t.disabled&&t.disabledReason?n.jsx(s.Tooltip,{label:t.disabledReason,position:"top",withArrow:!0,children:n.jsx("div",{...e,style:{opacity:.6,cursor:"not-allowed"},children:r})}):n.jsx("div",{...e,children:r})},Q5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metricDetail,l=a.metrics.loading||o.loading,i=o.error,c=h.useRef(t.timeQuery.enabled);if(h.useEffect(()=>{if(c.current&&!t.timeQuery.enabled){const u=G.toJS(t.extraCalculations)||[],p=cc(u,!1);p.length!==u.length&&t.setExtraCalculations(p)}c.current=t.timeQuery.enabled},[t.timeQuery.enabled]),!t.id)return null;if(l)return n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsx(s.Loader,{size:"xs"})]});if(i)return n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsxs(s.Text,{size:"sm",c:"red",children:["加载失败: ",i]})]});const d=o.data;if(o.hasData&&d){const u=d.extraCalculations;if(!u||u.length===0)return null;const p=N5(d.extraCalculationConfig),g=G5(u,p,t.timeQuery.enabled);return g.length===0?null:n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsx(s.MultiSelect,{data:g,value:G.toJS(t.extraCalculations)||[],onChange:b=>t.setExtraCalculations(b),placeholder:"选择要使用的计算方式",searchable:!0,clearable:!0,nothingFoundMessage:"未找到可用的计算方式",renderOption:F5,maxDropdownHeight:300})]})}return null}),j5=k.observer(({queryModel:e})=>{const t=e.config,r=t.id;h.useEffect(()=>{if(e.run_by.length===0)return;const c=[],d=t.usedFilterVariableSet,u=t.usedTimeQueryVariableSet;e.run_by.forEach(p=>{(d.has(p)||u.has(p))&&c.push(p)}),e.setRunBy(c)},[t.usedFilterVariableSet,t.usedTimeQueryVariableSet,e.run_by]);const i=e.datasource.mericoMetricInfo.metricDetail.metricType==="sql";return n.jsxs(s.Stack,{gap:16,pos:"relative",children:[!r&&n.jsx(s.Overlay,{color:"#fff",backgroundOpacity:.5,blur:3,children:n.jsx(s.Center,{h:"100%",children:n.jsx(s.Text,{size:"sm",c:"black",children:"请先选择指标"})})}),i?n.jsx(B5,{queryModel:e}):n.jsxs(n.Fragment,{children:[n.jsx(V5,{queryModel:e}),n.jsx(E5,{queryModel:e}),n.jsx(L5,{queryModel:e}),n.jsx(Q5,{queryModel:e})]})]})}),W5=["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
572
|
-
`),U5={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},K5=k.observer(({queryModel:e})=>{const[t,r]=h.useState("编辑查询");return n.jsxs(s.Tabs,{color:"red",defaultValue:"编辑查询",styles:U5,value:t,onChange:r,w:"60%",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(s.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(s.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"})]}),n.jsx(s.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(j5,{queryModel:e})}),n.jsx(s.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Tt,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:W5})}),n.jsx(s.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Id,{queryModel:e})})]})}),Y5=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(s.HoverCard,{shadow:"md",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Box,{children:n.jsx(s.Button,{size:"xs",leftSection:n.jsx(Pd,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.List,{size:"xs",children:t.map(r=>n.jsx(s.List.Item,{children:r},r))})})]}):n.jsx(s.Button,{size:"xs",leftSection:n.jsx(Pd,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),X5=({option:e,...t})=>{const r=e;return n.jsxs(s.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(s.Group,{flex:"1",gap:4,children:[n.jsx(T.IconHash,{size:12}),n.jsx(s.Text,{size:"xs",children:r.label})]}),n.jsx(s.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},Z5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metrics;h.useEffect(()=>{o.load()},[o]),h.useEffect(()=>{!a.metricID&&t.id&&a.selectMetric(t.id)},[t.id]);const l=h.useMemo(()=>o.data.map(p=>({label:p.name,value:p.id,description:p.description,type:p.type})),[o.data]),i=h.useCallback((p,g)=>{p&&(a.selectMetric(p),t.setID(p),t.setType(g.type))},[a,t]),c=h.useMemo(()=>{const p=window.localStorage.getItem("ee_site_url")??"";let g=`${p}/dashboard/admin/metrics/list`;return t.id&&t.type&&(g=`${p}/dashboard/admin/metrics/details/${t.type}/${t.id}`),g.replace("//dashboard","/dashboard")},[t.id,t.type]),{loading:d,error:u}=o;return n.jsx(ne,{children:n.jsxs(s.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(s.Tooltip,{label:u,children:n.jsx(s.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(s.Select,{size:"xs",label:"指标",data:l,renderOption:X5,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:i,rightSection:d?n.jsx(s.Loader,{size:"xs"}):null}),n.jsx(s.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:d,children:n.jsx(s.Anchor,{size:"md",variant:"subtle",mb:2,href:c,target:"_blank",underline:"never",children:n.jsx(u5,{width:14,height:14})})})]})})}),J5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(s.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(s.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(s.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(Dd,{queryModel:e,size:"xs"}),n.jsx(Z5,{queryModel:e})]}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(Y5,{queryModel:e}),n.jsx(g5,{queryModel:e})]})]}),n.jsxs(s.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(K5,{queryModel:e}),n.jsx(C5,{queryModel:e})]}),n.jsx(x5,{queryModel:e})]})}),H5=k.observer(({id:e})=>{const r=F().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(J5,{queryModel:r}):n.jsx(d5,{queryModel:r}):n.jsx(s.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),R5=k.observer(({value:e})=>{const r=H().payloadForSQL,a=h.useMemo(()=>mr(e,r),[e,r]);return n.jsx(br,{height:"100%",value:a})}),eM=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:a}=m.useTranslation(),[o,l]=h.useState("SQL"),[i,c]=h.useState(e.key),d=()=>{e.setKey(i),r(i)},u=i!==e.key,p=e.isADuplicatedKey(i),[g,b]=h.useState(e.value),_=()=>{e.setValue(g)};h.useEffect(()=>{c(e.key),b(e.value)},[e]);const w=g!==e.value,x=De.useModals(),S=()=>{x.openConfirmModal({title:`${a("sql_snippet.delete")}?`,labels:{confirm:a("common.actions.confirm"),cancel:a("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{p:20,sx:{minWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(s.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(s.TextInput,{label:a(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:i,onChange:D=>{c(D.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(s.ActionIcon,{color:"blue",variant:"subtle",onClick:d,disabled:!u||p,children:n.jsx(T.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(s.Button,{leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:S,children:a("sql_snippet.delete")})]}),n.jsxs(s.Tabs,{value:o,onChange:l,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(s.Tabs.List,{sx:{position:"relative"},children:[n.jsx(s.Tabs.Tab,{value:"SQL",children:a("sql_snippet.edit_snippet")}),n.jsx(s.Tabs.Tab,{value:"Preview",children:a("sql_snippet.preview_snippet")}),n.jsx(ps,{}),n.jsx(s.ActionIcon,{color:"blue",variant:"filled",onClick:_,disabled:!w,sx:{position:"absolute",top:0,right:10},children:n.jsx(T.IconDeviceFloppy,{size:18})})]}),n.jsx(s.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(br,{height:"100%",value:g,onChange:b,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(s.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(R5,{value:g})})]})]})}),tM=k.observer(({id:e})=>{const t=j(),r=F(),a=h.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!a)return n.jsxs(s.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const o=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},l=()=>{r.sqlSnippets.removeByKey(e),o()},i=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(eM,{item:a,remove:l,onKeyChanged:i})}),nM=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=De.useModals(),o=j(),l=b=>{o.editor.setPath(["_SQL_SNIPPETS_",b])},i=()=>{a.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(s.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{o.content.sqlSnippets.downloadSchema(t)},d=h.useMemo(()=>o.content.sqlSnippets.sortedList.map(b=>b.key),[o.content.sqlSnippets.sortedList]),u=()=>{r(d)},p=()=>{r([])},g=o.content.sqlSnippetsUsage;return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(s.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(s.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:14}),disabled:!o.content.hasUnusedSQLSnippets,onClick:i,children:e("sql_snippet.delete_unused")})]}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:e("common.key")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:o.content.sqlSnippets.sortedList.map(b=>{var w;const _=((w=g[b.key])==null?void 0:w.length)??0;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:b.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:b.key}),n.jsx(s.Table.Td,{style:{color:_===0?"#ff0000":"#000",fontWeight:_===0?"bold":"normal",textAlign:"center"},children:_}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>l(b.key),children:e("common.actions.open")})})]},b.key)})})]})})})]})}),rM=k.observer(({view:e})=>!e||e.type!==B.Division?null:n.jsx(s.Stack,{})),aM=k.observer(({view:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[r.language]),o=h.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==B.Tabs)return null;const l=e.config;return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(s.Select,{label:t("common.tabs.variant.label"),value:l.variant,onChange:l.setVariant,data:a}),n.jsx(s.Select,{label:t("common.tabs.orientation.label"),value:l.orientation,onChange:l.setOrientation,data:o}),n.jsx(s.Switch,{label:t("common.tabs.grow_tabs"),checked:l.grow,onChange:i=>l.setGrow(i.currentTarget.checked)})]})}),sM=({disabled:e,value:t,onChange:r})=>{const a=o=>{o&&r(o)};return n.jsxs(s.Box,{sx:{position:"relative"},children:[e&&n.jsx(s.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:t,onChange:a,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},oM=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e??En),d=_=>{c({...i,enabled:_})},u=()=>{l();const{enabled:_,func_content:w}=i,x={enabled:_,func_content:w};c(x),t(x)},p=()=>{l(),c(e)},g=_=>{c(w=>({...w,func_content:_}))},b=()=>{g(En.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:o,sx:{flexGrow:0},children:n.jsx(T.IconSettings,{size:14})}),n.jsx(s.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Checkbox,{mt:10,label:r("common.enabled"),checked:i.enabled,onChange:_=>d(_.currentTarget.checked)}),n.jsx(sM,{value:i.func_content,onChange:g,disabled:!i.enabled}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:b,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{onClick:u,children:r("common.actions.save")})]})]})]})})]})},lM=k.observer(({view:e})=>{const{t}=m.useTranslation();if(!e||e.type!==B.Modal)return null;const r=e.config,a=r.custom_modal_title.value;return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(s.Flex,{gap:10,children:[n.jsx(s.TextInput,{label:t("view.component.modal.title"),value:a,onChange:y.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(oM,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:o=>r.setWidth(o.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(s.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:o=>r.setHeight(o.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),iM=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(rM,{view:e}),n.jsx(lM,{view:e}),n.jsx(aM,{view:e})]})),cM=k.observer(({view:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{label:t("view.component.div.label"),value:B.Division},{label:t("view.component.modal.label"),value:B.Modal},{label:t("view.component.tabs.label"),value:B.Tabs}],[r.language]);return e?n.jsxs(s.Stack,{sx:{position:"relative"},children:[n.jsx(s.TextInput,{label:t("common.name"),value:e.name,onChange:o=>{e.setName(o.currentTarget.value)}}),n.jsx(s.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:a}),n.jsx(iM,{view:e})]}):null}),dM=k.observer(({id:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F();if(e==="")return null;const l=o.views.findByID(e);if(!l)return n.jsxs(s.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=()=>{a.editor.setPath(["_VIEWS_",""])},c=()=>{r.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.views.removeByID(e),i()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(s.Group,{justify:"flex-end",pt:10,children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(cM,{view:l})})]})}),uM=k.observer(()=>n.jsx(s.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(zd,{})})),pM=k.observer(()=>{const e=j().editor,t=e.path;return SD(t)?n.jsx(uM,{}):TD(t)?n.jsx(Hz,{}):kD(t)?n.jsx(Jz,{}):DD(t)?n.jsx(s.Box,{p:"xs",pl:20,children:n.jsx(Zz,{id:t[1]})}):zD(t)?n.jsx(nM,{}):MD(t)?n.jsx(tM,{id:t[1]}):VD(t)?n.jsx(V3,{}):ID(t)?n.jsx(H5,{id:t[1]}):PD(t)?n.jsx(s.Box,{p:"xs",pl:20,children:n.jsx(dM,{id:t[1]})}):rs(t)?n.jsx(I3,{viewID:t[1],panelID:t[3]}):n.jsx(s.Box,{children:e.path})}),hM=k.observer(()=>n.jsx(pM,{})),gM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={id:a,key:a,label:a,order:t.content.filters.current.length+1,type:P.TextInput,config:ma(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(o),t.editor.setPath(["_FILTERS_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),fM=k.observer(({parentID:e})=>{const{t}=m.useTranslation(),r=F();if(!e)return null;const a=r.views.findByID(e);return!a||a.type===B.Tabs?null:n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(a.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),bM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={id:a,name:a,type:W.Postgresql,key:"",config:{_type:W.Postgresql,sql:""}};t.content.queries.append(o),t.editor.setPath(["_QUERIES_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),yM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={key:a,value:""};t.content.sqlSnippets.append(o),t.editor.setPath(["_SQL_SNIPPETS_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),vM=k.observer(()=>{const{t:e}=m.useTranslation(),t=F();return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),_M=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),mM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),wM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),xM=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(gM,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(yM,{}):e==="_Add_A_QUERY_"?n.jsx(bM,{}):e==="_Add_A_VIEW_"?n.jsx(vM,{}):e==="_Add_A_PANEL_"?n.jsx(fM,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(_M,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(mM,{}):e==="_FILTERS_SETTINGS_"?n.jsx(wM,{}):null),Nd={menu_target:"_menu_target_m5ywm_1",query:"_query_m5ywm_12"},Gd=k.observer(({option:e})=>{var b;const{t}=m.useTranslation(),r=F(),a=j().editor,o=a.isOptionActive,l=o(a.path,e),i=a.isOptionOpened,c=a.navigate,d=i(e),[u,p]=h.useState(d);h.useEffect(()=>{p(d)},[d]);const g=e._type==="query";return n.jsx(s.NavLink,{pos:"relative",active:l,defaultOpened:d,opened:u,onChange:p,label:t(e.label),onClick:()=>c(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,rightSection:g?n.jsxs(s.Menu,{trigger:"hover",position:"right",withArrow:!0,shadow:"xl",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle",className:Nd.menu_target,children:n.jsx(T.IconDotsVertical,{size:16})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCopy,{size:16}),onClick:()=>r.queries.duplicateByID(e.value),children:t("common.actions.duplicate")})})]}):null,className:g?Nd.query:"",children:(b=e.children)==null?void 0:b.map(_=>_._type==="ACTION"?n.jsx(xM,{action_type:_._action_type,parentID:_.parentID},`_ADD_${_.value}_`):n.jsx(Gd,{option:_},_.value))},e.label)}),CM=k.observer(()=>{const e=j();return n.jsx(s.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Gd,{option:t},t.value))})}),SM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsxs(s.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(s.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(s.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(s.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(CM,{})}),n.jsx(s.AppShell.Section,{children:n.jsx(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),TM={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},kM=k.observer(()=>{const e=j().editor;return n.jsx(s.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:n.jsxs(s.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:TM,children:[n.jsx(SM,{}),n.jsx(s.AppShell.Main,{children:n.jsx(hM,{})})]})})}),DM=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function zM(e){h.useEffect(()=>{if(Se.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=DM(e);Se.loader.config({paths:{vs:r}}),Se.loader.init().then(a=>console.log("monaco instance:",a))},[])}const MM=e=>{const t=h.useCallback(r=>{const a=r||window.event;return a.preventDefault(),a&&(a.returnValue=""),""},[]);h.useEffect(()=>{if(e)return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}},[e])};oo(),Po();const IM={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},VM=({context:e,dashboard:t,content:r,update:a,className:o="dashboard",config:l,onChange:i,headerSlot:c,filterValues:d,onFilterValuesChange:u,onExit:p,lang:g,additionalPanelMenuItems:b},_)=>{zM(l.monacoPath),ca(l);const{data:w=[]}=O.useRequest(Oa),{data:x=[]}=O.useRequest(sc),S=h.useMemo(()=>od(t,r,w,x,e,d??{}),[t,r]);h.useImperativeHandle(_,()=>S,[S]),ld(S.content,!0),h.useEffect(()=>{S.context.replace(e)},[e]),h.useEffect(()=>{S.datasources.replace(w)},[w]),h.useEffect(()=>{S.globalSQLSnippets.replace(x)},[x]),h.useEffect(()=>{u==null||u(S.content.filters.values)},[u,S.content.filters.values]),h.useEffect(()=>{d&&S.content.filters.patchValues(d)},[d,S.content.filters.patchValues]),h.useEffect(()=>G.reaction(()=>G.toJS(S.json),A=>{i==null||i(A)}),[S]);const D=async()=>{await a(S.json,S.content.json)},z=O.useCreation(ia,[]),I=id(z);return MM(S.content.changed),O.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:a,className:o,config:l,onChange:i,headerSlot:c,filterValues:d,onFilterValuesChange:u,onExit:p,lang:g}),n.jsx(pt.MantineEmotionProvider,{children:n.jsx(ni,{lang:g,children:n.jsx(De.ModalsProvider,{children:n.jsx(rr,{children:n.jsx(Zn,{value:{renderSearchButton:l.renderSearchButton},children:n.jsx(sr,{value:{items:b??[]},children:n.jsx(Xn,{value:S,children:n.jsx(Hn,{value:S.content,children:n.jsxs(St.Provider,{value:{inEditMode:!0},children:[n.jsx(sz,{}),n.jsx(ot.Provider,{value:z,children:n.jsxs(vn,{configure:I,children:[n.jsxs(s.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:IM,children:[n.jsx(cz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(Bz,{}),n.jsx(s.AppShell.Main,{children:n.jsx(s.Box,{className:`${o} dashboard-root`,sx:{position:"relative"},children:S.content.views.visibleViews.map(A=>n.jsx(Kc,{view:A},A.id))})})]}),n.jsx(kM,{})]})})]})})})})})})})})})},PM=k.observer(h.forwardRef(VM)),u6="",fs=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:Ba,queries:Na,sqlSnippets:Fa,views:$a,panels:Ea,layouts:Ga,mock_context:da}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=f.getParent(e).context.current,r=f.getParent(e).globalSQLSnippets,a={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...a,sql_snippets:en(e.sqlSnippets.current,"key","value",a),global_sql_snippets:en(r.list,"id","content",a)}},get payloadForViz(){const t=f.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){const{context:t,filters:r}=this.payloadForViz,a={context:{},filters:e.filters.keyStateItemMap(r)};return Object.entries(t).forEach(([o,l])=>{a.context[o]={type:"context",key:o,value:l}}),a},get dashboardStateValues(){return vr(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardStateValues}},get data(){return e.queries.current.map(({id:r,data:a})=>({id:r,data:a})).reduce((r,a)=>(r[a.id]=a.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function Fd({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,content:l},i,c,d){if(!l)throw new Error("unexpected null content when creating a content model");const{version:u,filters:p,views:g,panels:b,layouts:_,definition:{queries:w,sqlSnippets:x,mock_context:S={}}}=l;return fs.create({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,version:u,filters:qa(p,i,S,c),queries:hc(w),sqlSnippets:bc(x),mock_context:ua(S),views:Zi(g,d),panels:{list:b},layouts:{list:_,currentBreakpoint:_[0].id}})}const Qd=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:fs,content_id:f.types.string,datasources:Yi,globalSQLSnippets:Ia,context:Bn});function jd({id:e,name:t,group:r,content_id:a},o,l,i,c,d,u){return Qd.create({id:e,name:t,group:r,content_id:a,content:Fd(o,c,d,u),datasources:{list:l},globalSQLSnippets:{list:i},context:Va(c)})}oo(),Po();const $M=({context:e,dashboard:t,content:r,className:a="dashboard",config:o,fullScreenPanelID:l,setFullScreenPanelID:i,filterValues:c,onFilterValuesChange:d,activeTab:u,onActiveTabChange:p,lang:g,onScreenshot:b,additionalPanelMenuItems:_})=>{ca(o);const{data:w=[]}=O.useRequest(Oa),{data:x=[]}=O.useRequest(sc),S=h.useMemo(()=>jd(t,r,w,x,e,c??{},u??null),[t,r]);ld(S.content,!1),h.useEffect(()=>{S.context.replace(e)},[e]),h.useEffect(()=>{S.datasources.replace(w)},[w]),h.useEffect(()=>{S.globalSQLSnippets.replace(x)},[x]),h.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",S.content.filters.values),d==null||d(S.content.filters.values)},[d,S.content.filters.valuesString]),h.useEffect(()=>{c&&S.content.filters.patchValues(c)},[c,S.content.filters.patchValues]),h.useEffect(()=>{p==null||p(S.content.views.firstVisibleTabsViewActiveTab)},[p,S.content.views.firstVisibleTabsViewActiveTabStr]),h.useEffect(()=>{u&&S.content.views.setFirstVisibleTabsViewActiveTab(u)},[u,S.content.views.setFirstVisibleTabsViewActiveTab]);const D=O.useCreation(ia,[S]),z=id(D);return O.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:a,config:o,fullScreenPanelID:l,setFullScreenPanelID:i,filterValues:c,onFilterValuesChange:d,activeTab:u,onActiveTabChange:p,lang:g}),n.jsx(Za.Provider,{value:{onScreenshot:b??y.noop},children:n.jsx(pt.MantineEmotionProvider,{children:n.jsx(ni,{lang:g,children:n.jsx(De.ModalsProvider,{children:n.jsx(rr,{children:n.jsx(Zn,{value:{renderSearchButton:o.renderSearchButton},children:n.jsx(sr,{value:{items:_??[]},children:n.jsx(Xn,{value:S,children:n.jsx(Hn,{value:S.content,children:n.jsx(nr.Provider,{value:{fullScreenPanelID:l,setFullScreenPanelID:i},children:n.jsx(St.Provider,{value:{inEditMode:!1},children:n.jsx(s.Box,{className:`${a} dashboard-root`,children:n.jsx(ot.Provider,{value:D,children:n.jsx(vn,{configure:z,children:S.content.views.visibleViews.map(I=>n.jsx(Ln,{view:I},I.id))})})})})})})})})})})})})})})},AM=k.observer($M),EM=()=>Promise.resolve().then(()=>ep).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));C.APIClient=$e,C.AdditionalPanelMenuItemsContext=ar,C.AdditionalPanelMenuItemsContextProvider=sr,C.CURRENT_SCHEMA_VERSION=lt,C.ClientPanelRender=Uk,C.ContentModel=ss,C.ContentModelContext=Jn,C.ContentModelContextProvider=Hn,C.ContentRenderModel=fs,C.ContextMeta=Bn,C.DEFAULT_CUSTOM_MODAL_TITLE=En,C.DashboardApiClient=ai,C.DashboardApiFacadeClient=si,C.DashboardEditor=PM,C.DashboardFilterType=P,C.DashboardMode=Yc,C.DashboardModel=sd,C.DashboardModelContextProvider=Xn,C.DashboardRenderModel=Qd,C.DashboardThemeContextProvider=Zn,C.DashboardViewEditor=Kc,C.DashboardViewRender=Ln,C.DataSourceMetaModel=Ma,C.DataSourceType=W,C.DataSourcesMetaModel=Yi,C.DatesProvider=rr,C.DefaultApiClient=ri,C.DefaultValueModeModelType=ha,C.DescriptionPopover=Xa,C.DraftModel=yc,C.EViewComponentType=B,C.FacadeApiClient=ET,C.FilterCheckboxConfigMeta=ga,C.FilterDateRangeConfigMeta=fa,C.FilterMericoDateRangeConfigMeta=Ta,C.FilterMeta=An,C.FilterModel=Zc,C.FilterMultiSelectConfigMeta=ya,C.FilterSelectConfigMeta=va,C.FilterTextInputConfigMeta=_a,C.FilterTreeSelectConfigMeta=Ca,C.FilterTreeSingleSelectConfigMeta=Sa,C.FiltersModel=Jc,C.FiltersRenderModel=Ba,C.FullScreenPanel=Fc,C.FullScreenPanelContext=nr,C.GlobalSQLSnippetMeta=Xi,C.GlobalSQLSnippetsMeta=Ia,C.LayoutItemMeta=_i,C.LayoutSetMeta=mi,C.LayoutStateContext=St,C.LayoutsRenderModel=Ga,C.MericoMetricQueryMeta=pa,C.MockContextMeta=da,C.MuteQueryModel=pc,C.Panel=Gc,C.PanelContextProvider=er,C.PanelErrorOrStateMessage=Bc,C.PanelMeta=ui,C.PanelModel=td,C.PanelRender=ts,C.PanelRenderModel=Aa,C.PanelStyleMeta=li,C.PanelTitleMeta=ii,C.PanelVizAddons=Ec,C.PanelVizMeta=di,C.PanelVizSection=Ha,C.PanelsModel=nd,C.PanelsRenderModel=Ea,C.QueriesModel=Rc,C.QueriesRenderModel=Na,C.QueryMeta=vi,C.QueryModel=Hc,C.QueryRenderModel=La,C.ReadOnlyDashboard=AM,C.SQLSnippetMeta=wi,C.SQLSnippetRenderModel=fc,C.SQLSnippetsModel=ed,C.SQLSnippetsRenderModel=Fa,C.VariableMeta=ci,C.ViewComponentTypeBackground=Xc,C.ViewComponentTypeColor=uD,C.ViewComponentTypeName=dD,C.ViewDivisionConfig=ka,C.ViewMeta=Ki,C.ViewModalConfig=Da,C.ViewRenderModel=Pa,C.ViewTabsConfig=za,C.ViewsModel=rd,C.ViewsRenderModel=$a,C.Viz=Ac,C.applyPartialDashboard=OD,C.configureAPIClient=ca,C.createContentModel=ad,C.createContentRenderModel=Fd,C.createContextMeta=Va,C.createDashboardModel=od,C.createDashboardRenderModel=jd,C.createDraft=vc,C.createFilterCheckboxConfig=xi,C.createFilterDateRangeConfig=Di,C.createFilterMericoDateRangeConfig=Qi,C.createFilterMultiSelectConfig=Mi,C.createFilterSelectConfig=Ii,C.createFilterTextInputConfig=ma,C.createFilterTreeSelectConfig=qi,C.createFilterTreeSingleSelectConfig=Oi,C.createMericoMetricQueryMetaConfig=yi,C.createViewDivisionConfig=ji,C.createViewModalConfig=Wi,C.createViewTabsConfig=Ui,C.facadeApiClient=oi,C.formatSQLSnippet=en,C.getInitialDashboardViewsModel=as,C.getInitialFiltersConfig=qa,C.getInitialMockContextMeta=ua,C.getInitialQueriesRenderModel=hc,C.getInitialSQLSnippetsRenderModel=bc,C.getInitialViewsRenderModel=Zi,C.getNewPanel=ec,C.getStaticDateRangeDefaultValue=Ti,C.getStaticMericoDateRangeDefaultValue=Gi,C.getVersion=EM,C.initialDashboardContent=d2,C.notifyVizRendered=fe,C.onVizRendered=mh,C.pluginManager=Mt,C.pluginServices=ee,C.useAdditionalPanelMenuItems=or,C.useContentModelContext=Rn,C.useDashboardContext=Wt,C.useDashboardThemeContext=Ks,C.useEditContentModelContext=F,C.useEditDashboardContext=j,C.useEditPanelContext=ae,C.useFullScreenPanelContext=Rs,C.useIsInEditPanelContext=Hs,C.useIsInRenderPanelContext=Js,C.useLayoutStateContext=Ys,C.usePanelFullScreen=Qc,C.useRenderContentModelContext=H,C.useRenderDashboardContext=Ws,C.useRenderPanelContext=re,C.useServiceLocator=Xt,C.useVisibleFilters=rk,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
|
570
|
+
`)},i5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation();if(!e.typedAsSQL)return null;const r=e.config;return n.jsxs(s.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"Edit",children:n.jsx(s.Group,{gap:14,justify:"space-between",children:t("query.edit_sql")})}),n.jsx(s.Tabs.Tab,{value:"Preview",children:t("query.preview_sql")}),n.jsx(s.Tabs.Tab,{value:"pre_process",children:t("query.process_request")}),n.jsx(s.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),n.jsx(ps,{}),e.datasource&&n.jsx(Td,{dataSource:e.datasource})]}),n.jsx(s.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:n.jsx(s5,{queryModel:e})}),n.jsx(s.Tabs.Panel,{value:"Preview",p:0,pl:4,children:n.jsx(l5,{value:r.sql})}),n.jsx(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n.jsx(Tt,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:Vd.pre})}),n.jsx(s.Tabs.Panel,{value:"post_process",p:"sm",children:n.jsx(Tt,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Vd.post})})]})}),c5={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
|
|
571
|
+
`),post:""},d5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=F();if(!e.isTransform)return null;const a=e.config;return n.jsxs(s.Stack,{py:20,px:20,sx:{height:"100%"},children:[n.jsx(s.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),n.jsx(s.MultiSelect,{data:r.queries.optionsWithoutTransform,value:[...a.dep_query_ids],onChange:a.setDependantQueryIDs,maxDropdownHeight:800}),n.jsx(s.Text,{size:"sm",children:t("query.transform.guide.write_function")}),n.jsx(s.Box,{sx:{flexGrow:1},children:n.jsx(Tt,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:c5.pre})})]})}),nn={height:"calc(100% - 44px)",padding:0},u5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=F(),a=h.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[o,l]=h.useState(a);h.useEffect(()=>{l(d=>d!=="Configurations"&&a==="Configurations"?"Configurations":d)},[a]);const c=r.findQueryUsage(e.id).length===0;return n.jsxs(s.Tabs,{value:o,onChange:l,defaultValue:a,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[n.jsxs(s.Tabs.List,{grow:!0,children:[n.jsx(s.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&n.jsx(s.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&n.jsx(s.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&n.jsx(s.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),n.jsx(s.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:n.jsx(s.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:n.jsx(s.Text,{size:"sm",children:t("data.preview_data")})})}),n.jsx(s.Tabs.Tab,{value:"Usage",disabled:c,children:n.jsx(s.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:n.jsx(s.Text,{size:"sm",children:t("query.usage.label")})})})]}),n.jsx(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n.jsx(H3,{queryModel:e})}),e.typedAsSQL&&n.jsx(s.Tabs.Panel,{value:"SQL",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(i5,{queryModel:e})})}),e.typedAsHTTP&&n.jsx(s.Tabs.Panel,{value:"HTTP",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(n5,{queryModel:e})})}),e.isTransform&&n.jsx(s.Tabs.Panel,{value:"Transform",sx:nn,children:n.jsx(s.Stack,{sx:{height:"100%"},children:n.jsx(d5,{queryModel:e})})}),n.jsx(s.Tabs.Panel,{value:"Data",sx:{...nn,overflow:"hidden"},children:n.jsx(cs,{id:e.id,moreActions:null,refreshOnMount:!0})}),n.jsx(s.Tabs.Panel,{value:"Usage",py:"sm",px:"md",sx:{...nn,overflow:"hidden"},children:n.jsx(Id,{queryModel:e})})]})}),p5=({width:e,height:t})=>n.jsxs("svg",{width:e,height:t,viewBox:"0 0 36 36",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 10.5C7.10217 10.5 6.72064 10.658 6.43934 10.9393C6.15804 11.2206 6 11.6022 6 12V28.5C6 28.8978 6.15804 29.2794 6.43934 29.5607C6.72064 29.842 7.10218 30 7.5 30H24C24.3978 30 24.7794 29.842 25.0607 29.5607C25.342 29.2794 25.5 28.8978 25.5 28.5V19.5C25.5 18.6716 26.1716 18 27 18C27.8284 18 28.5 18.6716 28.5 19.5V28.5C28.5 29.6935 28.0259 30.8381 27.182 31.682C26.3381 32.5259 25.1935 33 24 33H7.5C6.30653 33 5.16193 32.5259 4.31802 31.682C3.47411 30.8381 3 29.6935 3 28.5V12C3 10.8065 3.47411 9.66193 4.31802 8.81802C5.16193 7.97411 6.30653 7.5 7.5 7.5H16.5C17.3284 7.5 18 8.17157 18 9C18 9.82843 17.3284 10.5 16.5 10.5H7.5Z",fill:"#3D3E45"}),n.jsx("path",{d:"M32.8862 3.92582C32.8135 3.75021 32.7061 3.5856 32.5638 3.44253C32.5617 3.4404 32.5596 3.43828 32.5575 3.43616C32.2863 3.16658 31.9126 3 31.5 3H22.5C21.6716 3 21 3.67157 21 4.5C21 5.32843 21.6716 6 22.5 6H27.8787L13.9393 19.9393C13.3536 20.5251 13.3536 21.4749 13.9393 22.0607C14.5251 22.6464 15.4749 22.6464 16.0607 22.0607L30 8.12132V13.5C30 14.3284 30.6716 15 31.5 15C32.3284 15 33 14.3284 33 13.5V4.5C33 4.29662 32.9595 4.10268 32.8862 3.92582Z",fill:"#3D3E45"})]}),Pd=({width:e,height:t,color:r="#FFFFFF"})=>n.jsxs("svg",{viewBox:"0 0 36 36",fill:"none",width:e,height:t,children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.6931 20.547C26.1129 19.5516 26.113 17.4483 24.6931 16.4529L16.9351 11.0141C15.2783 9.85255 13 11.0377 13 13.0611L13 23.9389C13 25.9623 15.2783 27.1474 16.9351 25.9859L24.6931 20.547ZM16 14.0223L22.387 18.5L16 22.9777L16 14.0223Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 1.5C8.8873 1.5 1.5 8.8873 1.5 18C1.5 27.1127 8.8873 34.5 18 34.5C27.1127 34.5 34.5 27.1127 34.5 18C34.5 8.8873 27.1127 1.5 18 1.5ZM4.5 18C4.5 10.5442 10.5442 4.5 18 4.5C25.4558 4.5 31.5 10.5442 31.5 18C31.5 25.4558 25.4558 31.5 18 31.5C10.5442 31.5 4.5 25.4558 4.5 18Z",fill:r})]}),$d=({width:e,height:t,color:r="#EB1212"})=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M6.66665 6.66699C7.03484 6.66699 7.33331 6.96547 7.33331 7.33366V11.3337C7.33331 11.7018 7.03484 12.0003 6.66665 12.0003C6.29846 12.0003 5.99998 11.7018 5.99998 11.3337V7.33366C5.99998 6.96547 6.29846 6.66699 6.66665 6.66699Z",fill:r}),n.jsx("path",{d:"M9.99998 11.3337V7.33366C9.99998 6.96547 9.7015 6.66699 9.33331 6.66699C8.96512 6.66699 8.66665 6.96547 8.66665 7.33366V11.3337C8.66665 11.7018 8.96512 12.0003 9.33331 12.0003C9.7015 12.0003 9.99998 11.7018 9.99998 11.3337Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66665 3.33366V2.66699C4.66665 2.13656 4.87736 1.62785 5.25243 1.25278C5.62751 0.877706 6.13621 0.666992 6.66665 0.666992H9.33331C9.86375 0.666992 10.3725 0.877706 10.7475 1.25278C11.1226 1.62785 11.3333 2.13656 11.3333 2.66699V3.33366H14C14.3682 3.33366 14.6666 3.63214 14.6666 4.00033C14.6666 4.36852 14.3682 4.66699 14 4.66699H13.3333V13.3337C13.3333 13.8641 13.1226 14.3728 12.7475 14.7479C12.3725 15.1229 11.8637 15.3337 11.3333 15.3337H4.66665C4.13621 15.3337 3.62751 15.1229 3.25243 14.7479C2.87736 14.3728 2.66665 13.8641 2.66665 13.3337V4.66699H1.99998C1.63179 4.66699 1.33331 4.36852 1.33331 4.00033C1.33331 3.63214 1.63179 3.33366 1.99998 3.33366H4.66665ZM6.19524 2.19559C6.32027 2.07056 6.48984 2.00033 6.66665 2.00033H9.33331C9.51012 2.00033 9.67969 2.07056 9.80472 2.19559C9.92974 2.32061 9.99998 2.49018 9.99998 2.66699V3.33366H5.99998V2.66699C5.99998 2.49018 6.07022 2.32061 6.19524 2.19559ZM3.99998 4.66699V13.3337C3.99998 13.5105 4.07022 13.68 4.19524 13.8051C4.32027 13.9301 4.48984 14.0003 4.66665 14.0003H11.3333C11.5101 14.0003 11.6797 13.9301 11.8047 13.8051C11.9297 13.68 12 13.5105 12 13.3337V4.66699H3.99998Z",fill:r})]}),h5=({width:e,height:t})=>n.jsxs("svg",{viewBox:"0 0 18 18",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M7.5 3.75C7.5 2.92157 8.17157 2.25 9 2.25C9.82843 2.25 10.5 2.92157 10.5 3.75C10.5 4.57843 9.82843 5.25 9 5.25C8.17157 5.25 7.5 4.57843 7.5 3.75Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.5 9C7.5 8.17157 8.17157 7.5 9 7.5C9.82843 7.5 10.5 8.17157 10.5 9C10.5 9.82843 9.82843 10.5 9 10.5C8.17157 10.5 7.5 9.82843 7.5 9Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9 12.75C8.17157 12.75 7.5 13.4216 7.5 14.25C7.5 15.0784 8.17157 15.75 9 15.75C9.82843 15.75 10.5 15.0784 10.5 14.25C10.5 13.4216 9.82843 12.75 9 12.75Z",fill:"#3D3E45"})]}),g5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),r=j(),a=F(),l=a.findQueryUsage(e.id).length>0,i=De.useModals(),c=()=>{i.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.queries.removeQuery(e.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?n.jsx(s.Tooltip,{label:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"bottom-end",children:n.jsx(s.Button,{leftSection:n.jsx($d,{width:14,height:14,color:"gray"}),variant:"subtle",color:"gray",onClick:d=>{d.stopPropagation()},children:"删除查询"})}):n.jsx(s.Menu.Item,{leftSection:n.jsx($d,{width:14,height:14}),color:"red",onClick:c,children:"删除查询"})}),f5=k.observer(({queryModel:e})=>n.jsxs(s.Menu,{shadow:"md",width:120,trigger:"hover",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle","aria-label":"Settings",children:n.jsx(h5,{width:18,height:18})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(g5,{queryModel:e})})]})),b5={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function y5({data:e}){const t=h.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const a=ge.createColumnHelper();return Object.keys(e[0]).map(o=>a.accessor(o,{cell:l=>l.getValue()}))},[e]),r=ge.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:ge.getCoreRowModel()});return e.length===0?n.jsx(s.Box,{sx:{height:"5em"}}):n.jsx(ne,{children:n.jsxs(s.Table,{sx:b5,stickyHeader:!0,stickyHeaderOffset:0,children:[n.jsx(s.Table.Thead,{style:{backgroundColor:"#F9F9FA"},children:r.getHeaderGroups().map(a=>n.jsx(s.Table.Tr,{children:a.headers.map(o=>n.jsxs(s.Table.Th,{style:{width:o.getSize()},children:[o.isPlaceholder?null:ge.flexRender(o.column.columnDef.header,o.getContext()),n.jsx(s.ActionIcon,{variant:"subtle",onMouseDown:o.getResizeHandler(),onTouchStart:o.getResizeHandler(),className:`resizer ${o.column.getIsResizing()?"isResizing":""}`,children:n.jsx(T.IconArrowBarToRight,{})})]},o.id))},a.id))}),n.jsx(s.Table.Tbody,{children:r.getRowModel().rows.map(a=>n.jsx(s.Table.Tr,{children:a.getVisibleCells().map(o=>n.jsx(s.Table.Td,{children:n.jsx(ne,{children:typeof o.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(o.getValue(),null,2)}):ge.flexRender(o.column.columnDef.cell,o.getContext())})},o.id))},a.id))})]})})}const v5=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],_5={root:{width:"150px"},section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px",paddingRight:0}},m5=({data:e,page:t,setPage:r,limit:a,setLimit:o})=>{const{t:l}=m.useTranslation(),i=e.length,c=Math.ceil(i/a),d=p=>{p&&(r(1),o(Number(p)))};if(i===0)return null;const u=c===1&&i<=10;return n.jsxs(s.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(s.Group,{justify:"flex-start",children:[!u&&n.jsx(s.Select,{leftSection:n.jsx(s.Text,{ta:"center",c:"dimmed",size:"xs",children:l("common.pagination.page_size")}),size:"xs",styles:_5,data:v5,value:String(a),onChange:d}),c>1&&n.jsx(s.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}},color:"red"})]}),n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Text,{c:"dimmed",my:0,size:"14px",children:l("common.pagination.total_rows",{total:i})})})]})},w5=Io(({data:e,loading:t})=>{const[r,a]=h.useState(1),[o,l]=h.useState(20),i=h.useMemo(()=>{const c=(r-1)*o,d=c+o;return e.slice(c,d)},[e,r,o]);return n.jsx(ne,{children:n.jsxs(s.Stack,{gap:10,styles:{root:{height:"100%",overflow:"hidden"}},children:[n.jsx(m5,{data:e,page:r,setPage:a,limit:o,setLimit:l}),n.jsxs(s.Box,{sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(s.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(y5,{data:i})]})]})})}),x5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation(),{state:r,error:a,metricQueryPayloadErrorString:o,stateMessage:l}=e;return r==="loading"?null:a?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:a}):o?n.jsx(s.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:o}):l?n.jsx(s.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(l)}):null}),C5=k.observer(({queryModel:e})=>{m.useTranslation();const{data:t,state:r}=e,a=r==="loading",o=h.useCallback(()=>{e.fetchData(!0)},[e.fetchData]),l=()=>{Hi(e.name,e.data)};h.useEffect(()=>{o()},[o]);const i=!Array.isArray(t)||t.length===0;return n.jsxs(s.Stack,{gap:0,sx:{maxHeight:"calc(50vh - 48px)",flexGrow:1,flexShrink:0,background:"#F9F9FA"},children:[n.jsxs(s.Group,{justify:"space-between",py:7,px:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"查询结果"}),n.jsx(s.Button,{size:"xs",variant:"transparent",color:"gray",leftSection:n.jsx(T.IconDownload,{size:16}),disabled:a||i,onClick:l,children:"下载查询结果"})]}),n.jsxs(s.Box,{sx:{position:"relative",flexGrow:1,overflow:"hidden"},children:[n.jsx(x5,{queryModel:e}),n.jsx(w5,{data:t,loading:a})]})]})}),S5=k.observer(({queryModel:e})=>{const t=j();return n.jsxs(s.Tabs,{defaultValue:"看板变量预览",w:"40%",maw:"600px",styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"},panel:{height:"calc(100% - 36px)"}},color:"red",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"看板变量预览",children:"看板变量预览"}),n.jsx(s.Tabs.Tab,{value:"查询预览",children:"查询预览"})]}),n.jsx(s.Tabs.Panel,{value:"查询预览",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.metricQueryPayloadString})}),n.jsx(s.Tabs.Panel,{value:"看板变量预览",children:n.jsx(Qe.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:t.queryVariablesString})})]})}),T5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.24335 1.62305C7.50108 1.62305 7.71001 1.83198 7.71001 2.08971L7.71001 11.423C7.71001 11.6808 7.50108 11.8897 7.24335 11.8897C6.98561 11.8897 6.77668 11.6808 6.77668 11.423L6.77668 2.08971C6.77668 1.83198 6.98561 1.62305 7.24335 1.62305Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.93845 9.4786C9.80779 9.4786 9.70045 9.43893 9.61645 9.3596C9.53712 9.2756 9.49745 9.17293 9.49745 9.0516L9.49745 5.0056C9.49745 4.88427 9.53712 4.78393 9.61645 4.7046C9.70045 4.6206 9.80312 4.5786 9.92445 4.5786L12.1995 4.5786C12.3208 4.5786 12.4211 4.61827 12.5005 4.6976C12.5845 4.77227 12.6265 4.87027 12.6265 4.9916C12.6265 5.09427 12.5845 5.18527 12.5005 5.2646C12.4211 5.34393 12.3208 5.3836 12.1995 5.3836L10.3725 5.3836V6.6156H11.8845C12.0058 6.6156 12.1061 6.65527 12.1855 6.7346C12.2695 6.80927 12.3115 6.90727 12.3115 7.0286C12.3115 7.13127 12.2695 7.22227 12.1855 7.3016C12.1061 7.38093 12.0058 7.4206 11.8845 7.4206H10.3725L10.3725 9.0516C10.3725 9.17293 10.3281 9.2756 10.2395 9.3596C10.1555 9.43893 10.0551 9.4786 9.93845 9.4786Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.34754 9.4786C3.21687 9.4786 3.10954 9.43893 3.02554 9.3596C2.94154 9.2756 2.89954 9.17293 2.89954 9.0516L2.89954 5.3836H1.80054C1.6792 5.3836 1.57654 5.34627 1.49254 5.2716C1.4132 5.19693 1.37354 5.09893 1.37354 4.9776C1.37354 4.85627 1.4132 4.7606 1.49254 4.6906C1.57654 4.61593 1.6792 4.5786 1.80054 4.5786H4.90854C5.02987 4.5786 5.1302 4.61593 5.20954 4.6906C5.29354 4.76527 5.33554 4.86327 5.33554 4.9846C5.33554 5.10593 5.29354 5.20393 5.20954 5.2786C5.1302 5.3486 5.02987 5.3836 4.90854 5.3836H3.80954L3.80954 9.0516C3.80954 9.17293 3.7652 9.2756 3.67654 9.3596C3.59254 9.43893 3.48287 9.4786 3.34754 9.4786Z",fill:"#3D3E45"})]}),k5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_245_10828)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91663 1.16634C9.91663 0.844175 9.65546 0.583008 9.33329 0.583008C9.01113 0.583008 8.74996 0.844175 8.74996 1.16634V1.74967L5.24996 1.74967V1.16634C5.24996 0.844175 4.98879 0.583008 4.66663 0.583008C4.34446 0.583008 4.08329 0.844175 4.08329 1.16634V1.74967H2.91663C1.95013 1.74967 1.16663 2.53318 1.16663 3.49967L1.16663 11.6663C1.16663 12.6328 1.95013 13.4163 2.91663 13.4163L11.0833 13.4163C12.0498 13.4163 12.8333 12.6328 12.8333 11.6663L12.8333 3.49967C12.8333 2.53318 12.0498 1.74967 11.0833 1.74967H9.91663V1.16634ZM11.6666 5.24967V3.49967C11.6666 3.17751 11.4055 2.91634 11.0833 2.91634H9.91663V3.49967C9.91663 3.82184 9.65546 4.08301 9.33329 4.08301C9.01113 4.08301 8.74996 3.82184 8.74996 3.49967V2.91634L5.24996 2.91634V3.49967C5.24996 3.82184 4.98879 4.08301 4.66663 4.08301C4.34446 4.08301 4.08329 3.82184 4.08329 3.49967V2.91634L2.91663 2.91634C2.59446 2.91634 2.33329 3.17751 2.33329 3.49967L2.33329 5.24967L11.6666 5.24967ZM2.33329 6.41634L11.6666 6.41634L11.6666 11.6663C11.6666 11.9885 11.4055 12.2497 11.0833 12.2497L2.91663 12.2497C2.59446 12.2497 2.33329 11.9885 2.33329 11.6663V6.41634Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_245_10828",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),D5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.11108 2.13932C2.78892 2.13932 2.52775 2.40049 2.52775 2.72266V10.8893C2.52775 11.2115 2.78892 11.4727 3.11108 11.4727H11.2778C11.5999 11.4727 11.8611 11.2115 11.8611 10.8893V2.72266C11.8611 2.40049 11.5999 2.13932 11.2778 2.13932H3.11108ZM1.36108 2.72266C1.36108 1.75616 2.14459 0.972656 3.11108 0.972656H11.2778C12.2442 0.972656 13.0278 1.75616 13.0278 2.72266V10.8893C13.0278 11.8558 12.2442 12.6393 11.2778 12.6393H3.11108C2.14459 12.6393 1.36108 11.8558 1.36108 10.8893V2.72266Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.84418 8.37166C9.94816 8.37166 10.0348 8.40631 10.1041 8.47563C10.1734 8.54494 10.2081 8.63159 10.2081 8.73556C10.2081 8.8352 10.1734 8.91968 10.1041 8.989C10.0348 9.05398 9.94816 9.08647 9.84418 9.08647H7.63475C7.52211 9.08647 7.4333 9.05182 7.36832 8.9825C7.30334 8.91318 7.27084 8.82437 7.27084 8.71607C7.27084 8.60776 7.30983 8.51245 7.38781 8.43014L8.80445 6.91603C8.96474 6.74274 9.09038 6.56512 9.18135 6.38317C9.27666 6.20121 9.32432 6.04309 9.32432 5.90879C9.32432 5.69218 9.2615 5.51889 9.13587 5.38892C9.01023 5.25462 8.84344 5.18747 8.63549 5.18747C8.55318 5.18747 8.4687 5.20697 8.38206 5.24596C8.29541 5.28495 8.21094 5.3391 8.12862 5.40842C8.05064 5.47773 7.977 5.55788 7.90768 5.64885C7.85569 5.71817 7.80371 5.76149 7.75172 5.77882C7.69973 5.79615 7.65208 5.80481 7.60876 5.80481C7.51345 5.80481 7.42464 5.77016 7.34233 5.70084C7.26435 5.62719 7.22536 5.54271 7.22536 5.44741C7.22536 5.37376 7.24918 5.30228 7.29684 5.23296C7.34882 5.16365 7.41164 5.09216 7.48529 5.01852C7.59359 4.91021 7.7149 4.8149 7.8492 4.73259C7.98349 4.65028 8.12213 4.58746 8.26509 4.54414C8.40805 4.49648 8.54668 4.47266 8.68098 4.47266C8.97124 4.47266 9.22251 4.53114 9.43479 4.64811C9.6514 4.76075 9.81819 4.92321 9.93516 5.13549C10.0521 5.34343 10.1106 5.59037 10.1106 5.8763C10.1106 6.11457 10.0391 6.381 9.89617 6.67559C9.75754 6.96585 9.56909 7.23878 9.33081 7.49438L8.50837 8.37166H9.84418Z",fill:"#3D3E45"}),n.jsx("path",{d:"M5.49994 9.08647C5.37864 9.08647 5.279 9.04965 5.20102 8.976C5.12304 8.89802 5.08405 8.80271 5.08405 8.69007V5.62518L4.70065 5.90879C4.64 5.95644 4.56418 5.98027 4.47321 5.98027C4.36923 5.98027 4.27826 5.94128 4.20028 5.8633C4.1223 5.78532 4.08331 5.69218 4.08331 5.58387C4.08331 5.44524 4.15046 5.3326 4.28475 5.24596L5.22051 4.62212C5.26384 4.59179 5.31149 4.57013 5.36348 4.55713C5.4198 4.54414 5.47178 4.53764 5.51944 4.53764C5.64507 4.53764 5.74471 4.57663 5.81836 4.65461C5.89201 4.72826 5.92883 4.8214 5.92883 4.93404V8.69007C5.92883 8.80271 5.88768 8.89802 5.80536 8.976C5.72738 9.04965 5.62558 9.08647 5.49994 9.08647Z",fill:"#3D3E45"})]}),z5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M12.0334 5.64833C12.3099 5.64833 12.55 5.67744 12.7537 5.73565C12.9623 5.79386 13.1224 5.87632 13.2339 5.98303C13.3504 6.0849 13.4086 6.20859 13.4086 6.35412C13.4086 6.45113 13.3795 6.5433 13.3213 6.63061C13.263 6.71307 13.1782 6.7543 13.0666 6.7543C12.989 6.7543 12.9235 6.7446 12.8701 6.7252C12.8216 6.70094 12.778 6.67184 12.7392 6.63788C12.7004 6.60393 12.6543 6.5724 12.6009 6.54329C12.5524 6.51419 12.4772 6.49236 12.3754 6.47781C12.2783 6.45841 12.2056 6.44871 12.1571 6.44871C11.9097 6.44871 11.6987 6.50206 11.5241 6.60878C11.3543 6.7155 11.2233 6.86102 11.1311 7.04535C11.039 7.22482 10.9929 7.43341 10.9929 7.67109C10.9929 7.90393 11.039 8.11251 11.1311 8.29684C11.2282 8.47631 11.3591 8.61941 11.5241 8.72613C11.6938 8.83284 11.8879 8.8862 12.1061 8.8862C12.2274 8.8862 12.3317 8.87893 12.419 8.86437C12.5063 8.84982 12.5791 8.82799 12.6373 8.79889C12.7052 8.76008 12.7658 8.71885 12.8192 8.6752C12.8726 8.63154 12.9526 8.60971 13.0593 8.60971C13.1854 8.60971 13.2824 8.65094 13.3504 8.7334C13.4183 8.81102 13.4522 8.90803 13.4522 9.02445C13.4522 9.14572 13.3843 9.25728 13.2485 9.35915C13.1127 9.45616 12.9332 9.5362 12.7101 9.59926C12.4918 9.65747 12.2541 9.68657 11.997 9.68657C11.6138 9.68657 11.2815 9.59926 11.0002 9.42463C10.7188 9.24516 10.5005 9.00262 10.3453 8.69702C10.1949 8.39143 10.1198 8.04945 10.1198 7.67109C10.1198 7.27333 10.1998 6.92408 10.3599 6.62333C10.5248 6.31774 10.7504 6.08005 11.0366 5.91027C11.3276 5.73565 11.6599 5.64833 12.0334 5.64833Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.74826 5.64833C8.08781 5.64833 8.39099 5.73565 8.65778 5.91027C8.92942 6.08005 9.14285 6.31531 9.29807 6.61606C9.45815 6.9168 9.53819 7.26606 9.53819 7.66382C9.53819 8.06158 9.45815 8.41326 9.29807 8.71885C9.14285 9.0196 8.93184 9.25728 8.66505 9.43191C8.40311 9.60169 8.10722 9.68657 7.77737 9.68657C7.58334 9.68657 7.40143 9.65505 7.23166 9.59199C7.06188 9.52893 6.91151 9.44889 6.78054 9.35187C6.65442 9.25486 6.55498 9.15784 6.48222 9.06083C6.41431 8.95896 6.38035 8.87408 6.38035 8.80617L6.60591 8.71158V9.24273C6.60591 9.36885 6.56468 9.47557 6.48222 9.56288C6.39976 9.64534 6.29547 9.68657 6.16935 9.68657C6.04323 9.68657 5.93894 9.64534 5.85647 9.56288C5.77401 9.48042 5.73278 9.3737 5.73278 9.24273V4.67333C5.73278 4.54722 5.77401 4.44292 5.85647 4.36046C5.93894 4.27315 6.04323 4.22949 6.16935 4.22949C6.29547 4.22949 6.39976 4.27315 6.48222 4.36046C6.56468 4.44292 6.60591 4.54722 6.60591 4.67333V6.52147L6.48222 6.45598C6.48222 6.39292 6.51617 6.31774 6.58408 6.23042C6.652 6.13826 6.74416 6.04852 6.86058 5.96121C6.97699 5.86904 7.11039 5.79386 7.26076 5.73565C7.41599 5.67744 7.57849 5.64833 7.74826 5.64833ZM7.63912 6.44871C7.42569 6.44871 7.23893 6.50206 7.07886 6.60878C6.91879 6.7155 6.79267 6.86102 6.7005 7.04535C6.61319 7.22482 6.56953 7.43098 6.56953 7.66382C6.56953 7.8918 6.61319 8.10038 6.7005 8.28956C6.79267 8.47389 6.91879 8.61941 7.07886 8.72613C7.23893 8.83285 7.42569 8.8862 7.63912 8.8862C7.85255 8.8862 8.03688 8.83285 8.19211 8.72613C8.35218 8.61941 8.47587 8.47389 8.56319 8.28956C8.65535 8.10038 8.70143 7.8918 8.70143 7.66382C8.70143 7.43098 8.65535 7.22482 8.56319 7.04535C8.47587 6.86102 8.35218 6.7155 8.19211 6.60878C8.03688 6.50206 7.85255 6.44871 7.63912 6.44871Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.02845 5.66289L1.45681 9.35915C1.42286 9.45131 1.3695 9.52408 1.29674 9.57743C1.22883 9.62594 1.15364 9.65019 1.07118 9.65019C0.940211 9.65019 0.843196 9.61381 0.780136 9.54105C0.717077 9.46829 0.685547 9.37855 0.685547 9.27184C0.685547 9.22818 0.692823 9.1821 0.707375 9.13359L2.51913 4.78248C2.55793 4.68546 2.61614 4.61028 2.69375 4.55692C2.77622 4.50356 2.86353 4.48173 2.95569 4.49143C3.04301 4.49143 3.12304 4.51811 3.19581 4.57147C3.27342 4.61998 3.3292 4.69031 3.36316 4.78248L5.15308 9.04628C5.17733 9.10934 5.18946 9.16755 5.18946 9.2209C5.18946 9.35187 5.1458 9.45616 5.05849 9.53378C4.97603 9.61139 4.88386 9.65019 4.782 9.65019C4.69468 9.65019 4.61465 9.62352 4.54189 9.57016C4.47398 9.5168 4.42062 9.44404 4.38181 9.35187L2.81745 5.70654L3.02845 5.66289ZM1.68237 8.47146L2.08256 7.63471H4.04711L4.18536 8.47146H1.68237Z",fill:"#3D3E45"})]}),M5=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_567_6919)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.00001 1.02051C7.29533 1.02051 7.53473 1.25991 7.53473 1.55523V2.99492L11.3486 5.17429C11.5152 5.2695 11.6181 5.44667 11.6181 5.63856V9.97475L13.0725 10.702C13.3366 10.834 13.4437 11.1552 13.3116 11.4194C13.1795 11.6835 12.8583 11.7906 12.5942 11.6585L11.1002 10.9115L7.26531 13.1028C7.10091 13.1968 6.8991 13.1968 6.73471 13.1028L2.89985 10.9115L1.40581 11.6585C1.14167 11.7906 0.820476 11.6835 0.688405 11.4194C0.556335 11.1552 0.663399 10.834 0.92754 10.702L2.38195 9.97475V5.63856C2.38195 5.44667 2.48477 5.2695 2.65138 5.17429L6.46529 2.99492V1.55523C6.46529 1.25991 6.70469 1.02051 7.00001 1.02051ZM7.00001 3.9211L3.99444 5.63856L7.00001 7.35603L10.0056 5.63856L7.00001 3.9211ZM10.5486 6.55999L7.53473 8.28221V11.7171L10.5486 9.99492V6.55999ZM6.46529 11.7171V8.28221L3.4514 6.55999V9.99492L6.46529 11.7171Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_567_6919",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),hs=({type:e})=>{switch(e){case"boolean":return n.jsx(T5,{});case"date":return n.jsx(k5,{});case"number":return n.jsx(D5,{});case"string":return n.jsx(z5,{});case"dimension":return n.jsx(M5,{});default:return null}},Ad={option:{fontFamily:"monospace","&.sub-option":{position:"relative",marginLeft:"22px"},"&.sub-option::before":{content:'""',width:"1px",height:"100%",position:"absolute",left:"-6px",borderLeft:"1px solid #E7E7E9"}},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},group:{"&.dimension-group":{paddingBottom:"4px",".mantine-Combobox-groupLabel":{color:"#000"},".mantine-Combobox-groupLabel::before":{display:"none"},".mantine-Combobox-groupLabel::after":{display:"none"}}}},Ed={root:{maxWidth:"unset"},option:{fontFamily:"monospace"},input:{paddingInlineStart:"var(--input-padding-inline-start)",height:"auto",color:"black",fontFamily:"monospace"}},Bd=(e,t,r)=>{const a=[];return t&&a.push("sub-option"),r&&a.push("disabled"),n.jsx(s.Combobox.Option,{value:e.value,className:a.join(" "),disabled:r,children:n.jsxs(s.Stack,{gap:1,children:[n.jsxs(s.Group,{gap:4,children:[!!e.dataType&&n.jsx(hs,{type:e.dataType}),n.jsx(s.Text,{size:"xs",children:e.label})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",pl:18,children:e.description})]})},e.value)},qd=k.observer(({mmInfo:e,value:t,onChange:r,usedKeys:a})=>{const o=e.metricDetail,l=e.metrics.loading||o.loading,i=o.error,c=o.filterColOptions,d=s.useCombobox({onDropdownClose:()=>d.resetSelectedOption()}),u=h.useMemo(()=>l?n.jsx(s.Loader,{size:"xs"}):t?n.jsx(s.CloseButton,{size:"xs",onClick:()=>r(null)}):n.jsx(s.Combobox.Chevron,{size:"xs"}),[l,t]),p=n.jsx(s.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:u,rightSectionPointerEvents:!l&&t?"all":"none",onClick:()=>d.toggleDropdown(),disabled:l||c.length===0,styles:Ed,error:!!i,children:t||n.jsx(s.Input.Placeholder,{children:"选择维度"})});return n.jsxs(s.Combobox,{store:d,onOptionSubmit:g=>{r(g),d.closeDropdown()},styles:Ad,children:[n.jsx(s.Combobox.Target,{children:i?n.jsx(s.Tooltip,{label:i,children:p}):p}),n.jsx(s.Combobox.Dropdown,{miw:300,children:n.jsx(s.Combobox.Options,{mah:500,style:{overflowY:"auto"},children:c.map(({group:g,items:b})=>n.jsx(s.Combobox.Group,{label:g,children:b.map(_=>{var w;return"group"in _?n.jsx(s.Combobox.Group,{className:"dimension-group",label:n.jsxs(s.Group,{gap:4,children:[n.jsx(hs,{type:"dimension"}),n.jsx(s.Text,{size:"sm",children:_.group}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:_.description})]}),children:(w=_.items)==null?void 0:w.map(x=>Bd(x,!0,a.has(x.value)))},_.group):Bd(_,!1,a.has(_.value))})},g))})})]})}),gs={tbody:{td:{fontFamily:"monospace"}}},I5={root:{maxWidth:"unset"},option:{fontFamily:"monospace","&[data-checked=true][data-combobox-disabled]":{opacity:1}},input:{fontFamily:"monospace"},groupLabel:{"&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-gray-2)"}}},V5=({option:e,...t})=>{const{t:r}=m.useTranslation(),a=e,o=a.type==="filter";return n.jsxs(s.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsx(s.Group,{flex:"1",gap:4,children:n.jsx(s.Text,{size:"xs",children:e.value})}),o&&n.jsxs(s.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(s.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:1,flexGrow:1},children:a.widget_label}),n.jsx(s.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:r(nt[a.widget])})]})]})},Qt=k.observer(({queryModel:e,value:t,onChange:r,usedKeys:a})=>{const{t:o}=m.useTranslation();e.config;const l=h.useMemo(()=>e.getConditionOptionsWithInvalidValue(t).optionGroups.map(d=>{const u=d.items.length;return{group:`${o(d.group)}(${u})`,items:d.items.map(g=>({...g,label:g.value,widget_label:g.label,disabled:a==null?void 0:a.has(g.value)}))}}),[e.getConditionOptionsWithInvalidValue,o,t,a]),i=h.useCallback((c,d)=>{r(c,d)},[r]);return n.jsx(s.Select,{size:"xs",variant:"unstyled",placeholder:"选择变量",styles:I5,data:l,renderOption:V5,maxDropdownHeight:600,value:t,onChange:i,clearable:!0})}),jn=k.observer(({variable:e})=>{const t=j();if(!e)return null;const r=y.has(t.queryVariables,e);return n.jsx(s.ThemeIcon,{variant:"white",size:"xs",color:r?"#88CE98":"#F15050",styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(T.IconPointFilled,{})})}),P5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo;return h.useEffect(()=>{a.selectMetric(t.id)},[t.id,a]),n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"看板变量与指标维度关联"}),n.jsx(s.Tooltip,{label:"将看板的筛选器参数与指标的查询维度关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})})]}),n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"49%"}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:"指标筛选维度"}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[t.filters.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(qd,{mmInfo:a,value:o.dimension,onChange:o.setDimension,usedKeys:t.usedFilterDimensionKeys})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(jn,{variable:o.variable}),n.jsx(Qt,{queryModel:e,value:o.variable,onChange:o.setVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{size:"xs",checked:e.keyInRunBy(o.variable),onChange:l=>e.changeRunByRecord(o.variable,l.currentTarget.checked),color:"red"})})]},o.dimension)),n.jsxs(s.Table.Tr,{className:"add-a-row",children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(qd,{mmInfo:a,value:null,onChange:o=>o&&t.addFilter(o,""),usedKeys:t.usedFilterDimensionKeys})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsx(Qt,{queryModel:e,value:null,onChange:o=>o&&t.addFilter("",o)})}),n.jsx(s.Table.Td,{})]})]})]})]})}),$5=k.observer(({queryModel:e,variable:t})=>{const r=e.keyInRunBy(t),a=o=>{e.changeRunByRecord(t,o.currentTarget.checked)};return n.jsx(s.Checkbox,{size:"xs",checked:r,onChange:a,color:"red"})}),Od=({queryModel:e,variable:t})=>t?n.jsx($5,{queryModel:e,variable:t}):null,A5=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail,l=o.trendingDateCol,i=t.timeQuery.enabled;return o.supportTrending?n.jsx(s.Switch,{size:"xs",color:"red",checked:i,onChange:c=>t.setTimeQueryEnabled(c.currentTarget.checked),styles:{track:{cursor:"pointer"}}}):n.jsx(s.Tooltip,{label:"由于指标未设定时序维度,所以不具备时间序列展示功能。",children:n.jsx(s.Box,{children:n.jsx(s.Switch,{size:"xs",color:"red",disabled:!l})})})}),E5=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail,l=o.trendingDateCol;return!t.timeQuery.enabled||!o.supportTrending?null:n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsxs(s.Group,{gap:4,children:[n.jsx(s.Text,{size:"xs",children:"时间维度"}),n.jsx(s.Text,{size:"xs",c:"dimmed",ff:"monospace",children:(l==null?void 0:l.name)??null})]})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(jn,{variable:t.timeQuery.range_variable}),n.jsx(Qt,{queryModel:e,value:t.timeQuery.range_variable,onChange:t.setRangeVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(s.Table.Td,{children:n.jsx(Od,{queryModel:e,variable:t.timeQuery.range_variable})})]},"dimension.time"),n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Text,{size:"xs",children:"步长"})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(jn,{variable:t.timeQuery.unit_variable}),n.jsx(Qt,{queryModel:e,value:t.timeQuery.unit_variable,onChange:t.setUnitVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(Od,{queryModel:e,variable:t.timeQuery.unit_variable})})]},"dimension.step")]})]})}),B5=k.observer(({queryModel:e})=>n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"按时间序列展示"}),n.jsx(s.Tooltip,{label:"将看板的时间&步长筛选器与相应的查询维度关联上。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})}),n.jsx(A5,{queryModel:e})]}),n.jsx(E5,{queryModel:e})]})),Ld=k.observer(function({mmInfo:t,value:r,onChange:a,usedSqlVariables:o}){const l=t.metricDetail,i=t.metrics.loading||l.loading,c=l.error,d=h.useMemo(()=>(l.variables??[]).map(b=>({label:b,value:b})),[l.variables]),u=s.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),p=h.useMemo(()=>i?n.jsx(s.Loader,{size:"xs"}):r?n.jsx(s.CloseButton,{size:"xs",onClick:()=>a(null)}):n.jsx(s.Combobox.Chevron,{size:"xs"}),[i,r]),g=n.jsx(s.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:p,rightSectionPointerEvents:!i&&r?"all":"none",onClick:()=>u.toggleDropdown(),disabled:i||d.length===0,styles:Ed,error:!!c,children:r||n.jsx(s.Input.Placeholder,{children:"选择变量"})});return n.jsxs(s.Combobox,{store:u,onOptionSubmit:b=>{a(b),u.closeDropdown()},styles:Ad,children:[n.jsx(s.Combobox.Target,{children:c?n.jsx(s.Tooltip,{label:c,children:g}):g}),n.jsx(s.Combobox.Dropdown,{miw:300,children:n.jsx(s.Combobox.Options,{mah:500,style:{overflowY:"auto"},children:d.map(b=>n.jsx(s.Combobox.Option,{value:b.value,disabled:o.has(b.value),children:n.jsx(s.Stack,{gap:1,children:n.jsx(s.Group,{gap:4,children:n.jsx(s.Text,{size:"xs",children:b.label})})})},b.value))})})]})}),q5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo;return h.useEffect(()=>{a.selectMetric(t.id)},[t.id,a]),a.metricDetail.metricType!=="sql"?null:n.jsxs(s.Stack,{gap:7,children:[n.jsxs(s.Group,{justify:"flex-start",gap:8,children:[n.jsx(s.Text,{size:"sm",children:"看板变量与 SQL 指标关联"}),n.jsx(s.Tooltip,{label:"将看板的筛选器参数与指标的查询参数关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(s.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(T.IconInfoCircle,{})})})]}),n.jsxs(s.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:gs,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"49%"}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:"SQL 查询参数"}),n.jsx(s.Table.Td,{children:"看板变量"}),n.jsx(s.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(s.Table.Tbody,{children:[t.sqlVariables.map(o=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(Ld,{mmInfo:a,value:o.sqlVar,onChange:o.setSqlVar,usedSqlVariables:t.usedSqlVariables})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(jn,{variable:o.variable}),n.jsx(Qt,{queryModel:e,value:o.variable,onChange:o.setVariable})]})}),n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{size:"xs",checked:e.keyInRunBy(o.variable),onChange:l=>e.changeRunByRecord(o.variable,l.currentTarget.checked),color:"red"})})]},o.sqlVar)),n.jsxs(s.Table.Tr,{className:"add-a-row",children:[n.jsx(s.Table.Td,{pr:0,children:n.jsx(Ld,{mmInfo:a,value:null,onChange:o=>o&&t.addSqlVariable(o,""),usedSqlVariables:t.usedSqlVariables})}),n.jsx(s.Table.Td,{colSpan:2,pr:0,children:n.jsx(Qt,{queryModel:e,value:null,onChange:o=>o&&t.addSqlVariable("",o)})}),n.jsx(s.Table.Td,{})]})]})]})]})}),O5={label:{fontWeight:"normal"},input:{fontSize:"12px"},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},option:{fontFamily:"monospace"}},L5=e=>{const t=e.option;return n.jsxs(s.Stack,{gap:1,styles:{root:{flexGrow:1}},children:[n.jsxs(s.Group,{gap:4,children:[n.jsx(hs,{type:t.dataType}),n.jsx(s.Text,{size:"xs",children:t.label})]}),n.jsx(s.Text,{size:"xs",c:"dimmed",pl:18,children:t.description})]})},N5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metricDetail,l=a.metrics.loading||o.loading,i=o.groupByColOptions,c=d=>{const u=o.getGroupByOptions(d),p=[];u.forEach(g=>{g.dimension?g.dimension.fields.forEach(b=>{typeof b=="string"?p.push(`${g.value} -> ${b}`):p.push(`${g.value} -> ${b.field}`)}):p.push(g.value)}),t.setGroupBys(p)};return n.jsxs(n.Fragment,{children:[n.jsx(s.MultiSelect,{size:"sm",label:"分组聚合维度",description:"指标在查询时按照哪些维度进行聚合计算。最多支持两个维度的聚合计算。若选择按时间序列展示,则仅可选择一个聚合维度。",data:i,searchable:!0,styles:O5,renderOption:L5,rightSection:l?n.jsx(s.Loader,{size:"xs"}):null,value:[...t.groupByValues],onChange:c,maxValues:t.timeQuery.enabled?1:2,placeholder:t.timeQuery.enabled?"仅可选一个维度":"最多选两个维度",disabled:l}),n.jsx(s.Switch,{labelPosition:"left",label:"聚合维度为空时,自动补零",size:"sm",color:"red",checked:t.useDefaultValues,onChange:d=>t.setUseDefaultValues(d.currentTarget.checked),disabled:i.length===0})]})}),G5=e=>{if(!e)return null;try{const t=JSON.parse(e);return{calculation:t.calculation,n:t.n,direction:t.direction}}catch{return null}},F5=(e,t,r)=>{const a={max:"最大值",min:"最小值",sum:"总和",avg:"平均值"};return Array.from(ic.entries()).filter(([o])=>e.includes(o)).map(([o,l])=>{const c=!r&&l.requireTrendingDateCol;let d=l.name;if(l.requireWindowConfig&&t){const u=a[t.calculation]||t.calculation,p=t.direction==="forward"?"向前":"向后";d=`${l.name} · ${u} · ${t.n} 个步长 · ${p}`}return{value:o,label:d,description:l.description,disabled:c,disabledReason:c?"需要开启按时序查询":void 0}})},Q5=e=>{const t=e.option,r=n.jsx(s.Group,{gap:"xs",wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm",fw:500,children:t.label}),n.jsx(s.Text,{size:"xs",c:"dimmed",children:t.description})]})});return t.disabled&&t.disabledReason?n.jsx(s.Tooltip,{label:t.disabledReason,position:"top",withArrow:!0,children:n.jsx("div",{...e,style:{opacity:.6,cursor:"not-allowed"},children:r})}):n.jsx("div",{...e,children:r})},j5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metricDetail,l=a.metrics.loading||o.loading,i=o.error,c=h.useRef(t.timeQuery.enabled);if(h.useEffect(()=>{if(c.current&&!t.timeQuery.enabled){const u=G.toJS(t.extraCalculations)||[],p=cc(u,!1);p.length!==u.length&&t.setExtraCalculations(p)}c.current=t.timeQuery.enabled},[t.timeQuery.enabled]),!t.id)return null;if(l)return n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsx(s.Loader,{size:"xs"})]});if(i)return n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsxs(s.Text,{size:"sm",c:"red",children:["加载失败: ",i]})]});const d=o.data;if(o.hasData&&d){const u=d.extraCalculations;if(!u||u.length===0)return null;const p=G5(d.extraCalculationConfig),g=F5(u,p,t.timeQuery.enabled);return g.length===0?null:n.jsxs(s.Stack,{gap:8,children:[n.jsx(s.Text,{size:"sm",fw:500,children:"衍生计算配置"}),n.jsx(s.MultiSelect,{data:g,value:G.toJS(t.extraCalculations)||[],onChange:b=>t.setExtraCalculations(b),placeholder:"选择要使用的计算方式",searchable:!0,clearable:!0,nothingFoundMessage:"未找到可用的计算方式",renderOption:Q5,maxDropdownHeight:300})]})}return null}),W5=k.observer(({queryModel:e})=>{const t=e.config,r=t.id;h.useEffect(()=>{if(e.run_by.length===0)return;const c=[],d=t.usedFilterVariableSet,u=t.usedTimeQueryVariableSet;e.run_by.forEach(p=>{(d.has(p)||u.has(p))&&c.push(p)}),e.setRunBy(c)},[t.usedFilterVariableSet,t.usedTimeQueryVariableSet,e.run_by]);const i=e.datasource.mericoMetricInfo.metricDetail.metricType==="sql";return n.jsxs(s.Stack,{gap:16,pos:"relative",children:[!r&&n.jsx(s.Overlay,{color:"#fff",backgroundOpacity:.5,blur:3,children:n.jsx(s.Center,{h:"100%",children:n.jsx(s.Text,{size:"sm",c:"black",children:"请先选择指标"})})}),i?n.jsx(q5,{queryModel:e}):n.jsxs(n.Fragment,{children:[n.jsx(P5,{queryModel:e}),n.jsx(B5,{queryModel:e}),n.jsx(N5,{queryModel:e}),n.jsx(j5,{queryModel:e})]})]})}),U5=["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
572
|
+
`),K5={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},Y5=k.observer(({queryModel:e})=>{const[t,r]=h.useState("编辑查询");return n.jsxs(s.Tabs,{color:"red",defaultValue:"编辑查询",styles:K5,value:t,onChange:r,w:"60%",children:[n.jsxs(s.Tabs.List,{children:[n.jsx(s.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(s.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(s.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"})]}),n.jsx(s.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(W5,{queryModel:e})}),n.jsx(s.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Tt,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:U5})}),n.jsx(s.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Id,{queryModel:e})})]})}),X5=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(s.HoverCard,{shadow:"md",children:[n.jsx(s.HoverCard.Target,{children:n.jsx(s.Box,{children:n.jsx(s.Button,{size:"xs",leftSection:n.jsx(Pd,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(s.HoverCard.Dropdown,{children:n.jsx(s.List,{size:"xs",children:t.map(r=>n.jsx(s.List.Item,{children:r},r))})})]}):n.jsx(s.Button,{size:"xs",leftSection:n.jsx(Pd,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),Z5=({option:e,...t})=>{const r=e;return n.jsxs(s.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(s.Group,{flex:"1",gap:4,children:[n.jsx(T.IconHash,{size:12}),n.jsx(s.Text,{size:"xs",children:r.label})]}),n.jsx(s.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},J5=k.observer(({queryModel:e})=>{const t=e.config,a=e.datasource.mericoMetricInfo,o=a.metrics;h.useEffect(()=>{o.load()},[o]),h.useEffect(()=>{!a.metricID&&t.id&&a.selectMetric(t.id)},[t.id]);const l=h.useMemo(()=>o.data.map(p=>({label:p.name,value:p.id,description:p.description,type:p.type,semanticKey:p.semanticKey,isPreset:p.isPreset})),[o.data]),i=h.useCallback((p,g)=>{p&&(a.selectMetric(p),t.setID(p),t.setType(g.type),g.isPreset&&t.setSemanticKey(g.semanticKey))},[a,t]),c=h.useMemo(()=>{const p=window.localStorage.getItem("ee_site_url")??"";let g=`${p}/dashboard/admin/metrics/list`;return t.id&&t.type&&(g=`${p}/dashboard/admin/metrics/details/${t.type}/${t.id}`),g.replace("//dashboard","/dashboard")},[t.id,t.type]),{loading:d,error:u}=o;return n.jsx(ne,{children:n.jsxs(s.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(s.Tooltip,{label:u,children:n.jsx(s.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(s.Select,{size:"xs",label:"指标",data:l,renderOption:Z5,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:i,rightSection:d?n.jsx(s.Loader,{size:"xs"}):null}),n.jsx(s.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:d,children:n.jsx(s.Anchor,{size:"md",variant:"subtle",mb:2,href:c,target:"_blank",underline:"never",children:n.jsx(p5,{width:14,height:14})})})]})})}),H5=k.observer(({queryModel:e})=>{const{t}=m.useTranslation();return n.jsxs(s.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(s.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(s.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(s.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(Dd,{queryModel:e,size:"xs"}),n.jsx(J5,{queryModel:e})]}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(X5,{queryModel:e}),n.jsx(f5,{queryModel:e})]})]}),n.jsxs(s.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(Y5,{queryModel:e}),n.jsx(S5,{queryModel:e})]}),n.jsx(C5,{queryModel:e})]})}),R5=k.observer(({id:e})=>{const r=F().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(H5,{queryModel:r}):n.jsx(u5,{queryModel:r}):n.jsx(s.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),eM=k.observer(({value:e})=>{const r=H().payloadForSQL,a=h.useMemo(()=>wr(e,r),[e,r]);return n.jsx(yr,{height:"100%",value:a})}),tM=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:a}=m.useTranslation(),[o,l]=h.useState("SQL"),[i,c]=h.useState(e.key),d=()=>{e.setKey(i),r(i)},u=i!==e.key,p=e.isADuplicatedKey(i),[g,b]=h.useState(e.value),_=()=>{e.setValue(g)};h.useEffect(()=>{c(e.key),b(e.value)},[e]);const w=g!==e.value,x=De.useModals(),S=()=>{x.openConfirmModal({title:`${a("sql_snippet.delete")}?`,labels:{confirm:a("common.actions.confirm"),cancel:a("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{p:20,sx:{minWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(s.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(s.TextInput,{label:a(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:i,onChange:D=>{c(D.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(s.ActionIcon,{color:"blue",variant:"subtle",onClick:d,disabled:!u||p,children:n.jsx(T.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(s.Button,{leftSection:n.jsx(T.IconTrash,{size:16}),color:"red",variant:"light",onClick:S,children:a("sql_snippet.delete")})]}),n.jsxs(s.Tabs,{value:o,onChange:l,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(s.Tabs.List,{sx:{position:"relative"},children:[n.jsx(s.Tabs.Tab,{value:"SQL",children:a("sql_snippet.edit_snippet")}),n.jsx(s.Tabs.Tab,{value:"Preview",children:a("sql_snippet.preview_snippet")}),n.jsx(ps,{}),n.jsx(s.ActionIcon,{color:"blue",variant:"filled",onClick:_,disabled:!w,sx:{position:"absolute",top:0,right:10},children:n.jsx(T.IconDeviceFloppy,{size:18})})]}),n.jsx(s.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(yr,{height:"100%",value:g,onChange:b,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(s.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(eM,{value:g})})]})]})}),nM=k.observer(({id:e})=>{const t=j(),r=F(),a=h.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!a)return n.jsxs(s.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const o=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},l=()=>{r.sqlSnippets.removeByKey(e),o()},i=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(tM,{item:a,remove:l,onKeyChanged:i})}),rM=k.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=h.useState([]),a=De.useModals(),o=j(),l=b=>{o.editor.setPath(["_SQL_SNIPPETS_",b])},i=()=>{a.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(s.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>o.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{o.content.sqlSnippets.downloadSchema(t)},d=h.useMemo(()=>o.content.sqlSnippets.sortedList.map(b=>b.key),[o.content.sqlSnippets.sortedList]),u=()=>{r(d)},p=()=>{r([])},g=o.content.sqlSnippetsUsage;return n.jsxs(s.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(s.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(s.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(s.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(s.Group,{justify:"flex-start",children:[n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.select_all")}),n.jsx(s.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(s.Button,{size:"xs",color:"blue",leftSection:n.jsx(T.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(s.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:14}),disabled:!o.content.hasUnusedSQLSnippets,onClick:i,children:e("sql_snippet.delete_unused")})]}),n.jsx(s.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(s.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(s.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(s.Table.Thead,{children:n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{style:{width:"40px"}}),n.jsx(s.Table.Th,{children:e("common.key")}),n.jsx(s.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(s.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(s.Table.Tbody,{children:o.content.sqlSnippets.sortedList.map(b=>{var w;const _=((w=g[b.key])==null?void 0:w.length)??0;return n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Td,{children:n.jsx(s.Checkbox,{value:b.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(s.Table.Td,{children:b.key}),n.jsx(s.Table.Td,{style:{color:_===0?"#ff0000":"#000",fontWeight:_===0?"bold":"normal",textAlign:"center"},children:_}),n.jsx(s.Table.Td,{children:n.jsx(s.Button,{variant:"subtle",size:"xs",onClick:()=>l(b.key),children:e("common.actions.open")})})]},b.key)})})]})})})]})}),aM=k.observer(({view:e})=>!e||e.type!==B.Division?null:n.jsx(s.Stack,{})),sM=k.observer(({view:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[r.language]),o=h.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==B.Tabs)return null;const l=e.config;return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(s.Select,{label:t("common.tabs.variant.label"),value:l.variant,onChange:l.setVariant,data:a}),n.jsx(s.Select,{label:t("common.tabs.orientation.label"),value:l.orientation,onChange:l.setOrientation,data:o}),n.jsx(s.Switch,{label:t("common.tabs.grow_tabs"),checked:l.grow,onChange:i=>l.setGrow(i.currentTarget.checked)})]})}),oM=({disabled:e,value:t,onChange:r})=>{const a=o=>{o&&r(o)};return n.jsxs(s.Box,{sx:{position:"relative"},children:[e&&n.jsx(s.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(Se,{height:"500px",defaultLanguage:"javascript",value:t,onChange:a,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},lM=({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),[a,{setTrue:o,setFalse:l}]=O.useBoolean(),[i,c]=h.useState(e??En),d=_=>{c({...i,enabled:_})},u=()=>{l();const{enabled:_,func_content:w}=i,x={enabled:_,func_content:w};c(x),t(x)},p=()=>{l(),c(e)},g=_=>{c(w=>({...w,func_content:_}))},b=()=>{g(En.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:o,sx:{flexGrow:0},children:n.jsx(T.IconSettings,{size:14})}),n.jsx(s.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&n.jsxs(s.Stack,{children:[n.jsx(s.Checkbox,{mt:10,label:r("common.enabled"),checked:i.enabled,onChange:_=>d(_.currentTarget.checked)}),n.jsx(oM,{value:i.func_content,onChange:g,disabled:!i.enabled}),n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Button,{onClick:b,color:"red",leftSection:n.jsx(T.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(s.Group,{justify:"flex-end",children:[n.jsx(s.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(s.Button,{onClick:u,children:r("common.actions.save")})]})]})]})})]})},iM=k.observer(({view:e})=>{const{t}=m.useTranslation();if(!e||e.type!==B.Modal)return null;const r=e.config,a=r.custom_modal_title.value;return n.jsxs(s.Stack,{children:[n.jsx(s.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(s.Flex,{gap:10,children:[n.jsx(s.TextInput,{label:t("view.component.modal.title"),value:a,onChange:y.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(lM,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(s.Group,{grow:!0,children:[n.jsx(s.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:o=>r.setWidth(o.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(s.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:o=>r.setHeight(o.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),cM=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(aM,{view:e}),n.jsx(iM,{view:e}),n.jsx(sM,{view:e})]})),dM=k.observer(({view:e})=>{const{t,i18n:r}=m.useTranslation(),a=h.useMemo(()=>[{label:t("view.component.div.label"),value:B.Division},{label:t("view.component.modal.label"),value:B.Modal},{label:t("view.component.tabs.label"),value:B.Tabs}],[r.language]);return e?n.jsxs(s.Stack,{sx:{position:"relative"},children:[n.jsx(s.TextInput,{label:t("common.name"),value:e.name,onChange:o=>{e.setName(o.currentTarget.value)}}),n.jsx(s.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:a}),n.jsx(cM,{view:e})]}):null}),uM=k.observer(({id:e})=>{const{t}=m.useTranslation(),r=De.useModals(),a=j(),o=F();if(e==="")return null;const l=o.views.findByID(e);if(!l)return n.jsxs(s.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=()=>{a.editor.setPath(["_VIEWS_",""])},c=()=>{r.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.views.removeByID(e),i()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(s.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(s.Group,{justify:"flex-end",pt:10,children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(dM,{view:l})})]})}),pM=k.observer(()=>n.jsx(s.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(zd,{})})),hM=k.observer(()=>{const e=j().editor,t=e.path;return TD(t)?n.jsx(pM,{}):kD(t)?n.jsx(Rz,{}):DD(t)?n.jsx(Hz,{}):zD(t)?n.jsx(s.Box,{p:"xs",pl:20,children:n.jsx(Jz,{id:t[1]})}):MD(t)?n.jsx(rM,{}):ID(t)?n.jsx(nM,{id:t[1]}):PD(t)?n.jsx(P3,{}):VD(t)?n.jsx(R5,{id:t[1]}):$D(t)?n.jsx(s.Box,{p:"xs",pl:20,children:n.jsx(uM,{id:t[1]})}):rs(t)?n.jsx(V3,{viewID:t[1],panelID:t[3]}):n.jsx(s.Box,{children:e.path})}),gM=k.observer(()=>n.jsx(hM,{})),fM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={id:a,key:a,label:a,order:t.content.filters.current.length+1,type:P.TextInput,config:wa(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(o),t.editor.setPath(["_FILTERS_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),bM=k.observer(({parentID:e})=>{const{t}=m.useTranslation(),r=F();if(!e)return null;const a=r.views.findByID(e);return!a||a.type===B.Tabs?null:n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(a.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),yM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={id:a,name:a,type:W.Postgresql,key:"",config:{_type:W.Postgresql,sql:""}};t.content.queries.append(o),t.editor.setPath(["_QUERIES_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),vM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j(),r=()=>{const a=new Date().getTime().toString(),o={key:a,value:""};t.content.sqlSnippets.append(o),t.editor.setPath(["_SQL_SNIPPETS_",a])};return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),_M=k.observer(()=>{const{t:e}=m.useTranslation(),t=F();return n.jsx(s.Button,{variant:"subtle",leftSection:n.jsx(T.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),mM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),wM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),xM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsx(s.Button,{variant:"subtle",rightSection:n.jsx(T.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),CM=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(fM,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(vM,{}):e==="_Add_A_QUERY_"?n.jsx(yM,{}):e==="_Add_A_VIEW_"?n.jsx(_M,{}):e==="_Add_A_PANEL_"?n.jsx(bM,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(mM,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(wM,{}):e==="_FILTERS_SETTINGS_"?n.jsx(xM,{}):null),Nd={menu_target:"_menu_target_m5ywm_1",query:"_query_m5ywm_12"},Gd=k.observer(({option:e})=>{var b;const{t}=m.useTranslation(),r=F(),a=j().editor,o=a.isOptionActive,l=o(a.path,e),i=a.isOptionOpened,c=a.navigate,d=i(e),[u,p]=h.useState(d);h.useEffect(()=>{p(d)},[d]);const g=e._type==="query";return n.jsx(s.NavLink,{pos:"relative",active:l,defaultOpened:d,opened:u,onChange:p,label:t(e.label),onClick:()=>c(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,rightSection:g?n.jsxs(s.Menu,{trigger:"hover",position:"right",withArrow:!0,shadow:"xl",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.ActionIcon,{variant:"subtle",className:Nd.menu_target,children:n.jsx(T.IconDotsVertical,{size:16})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCopy,{size:16}),onClick:()=>r.queries.duplicateByID(e.value),children:t("common.actions.duplicate")})})]}):null,className:g?Nd.query:"",children:(b=e.children)==null?void 0:b.map(_=>_._type==="ACTION"?n.jsx(CM,{action_type:_._action_type,parentID:_.parentID},`_ADD_${_.value}_`):n.jsx(Gd,{option:_},_.value))},e.label)}),SM=k.observer(()=>{const e=j();return n.jsx(s.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Gd,{option:t},t.value))})}),TM=k.observer(()=>{const{t:e}=m.useTranslation(),t=j();return n.jsxs(s.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(s.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(s.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(s.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(SM,{})}),n.jsx(s.AppShell.Section,{children:n.jsx(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(s.Button,{size:"xs",color:"red",leftSection:n.jsx(T.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),kM={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},DM=k.observer(()=>{const e=j().editor;return n.jsx(s.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:n.jsxs(s.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:kM,children:[n.jsx(TM,{}),n.jsx(s.AppShell.Main,{children:n.jsx(gM,{})})]})})}),zM=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function MM(e){h.useEffect(()=>{if(Se.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=zM(e);Se.loader.config({paths:{vs:r}}),Se.loader.init().then(a=>console.log("monaco instance:",a))},[])}const IM=e=>{const t=h.useCallback(r=>{const a=r||window.event;return a.preventDefault(),a&&(a.returnValue=""),""},[]);h.useEffect(()=>{if(e)return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}},[e])};oo(),Po();const VM={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},PM=({context:e,dashboard:t,content:r,update:a,className:o="dashboard",config:l,onChange:i,headerSlot:c,filterValues:d,onFilterValuesChange:u,onExit:p,lang:g,additionalPanelMenuItems:b},_)=>{MM(l.monacoPath),da(l);const{data:w=[]}=O.useRequest(La),{data:x=[]}=O.useRequest(sc),S=h.useMemo(()=>od(t,r,w,x,e,d??{}),[t,r]);h.useImperativeHandle(_,()=>S,[S]),ld(S.content,!0),h.useEffect(()=>{S.context.replace(e)},[e]),h.useEffect(()=>{S.datasources.replace(w)},[w]),h.useEffect(()=>{S.globalSQLSnippets.replace(x)},[x]),h.useEffect(()=>{u==null||u(S.content.filters.values)},[u,S.content.filters.values]),h.useEffect(()=>{d&&S.content.filters.patchValues(d)},[d,S.content.filters.patchValues]),h.useEffect(()=>G.reaction(()=>G.toJS(S.json),A=>{i==null||i(A)}),[S]);const D=async()=>{await a(S.json,S.content.json)},z=O.useCreation(ca,[]),I=id(z);return IM(S.content.changed),O.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:a,className:o,config:l,onChange:i,headerSlot:c,filterValues:d,onFilterValuesChange:u,onExit:p,lang:g}),n.jsx(pt.MantineEmotionProvider,{children:n.jsx(ni,{lang:g,children:n.jsx(De.ModalsProvider,{children:n.jsx(ar,{children:n.jsx(Jn,{value:{renderSearchButton:l.renderSearchButton},children:n.jsx(or,{value:{items:b??[]},children:n.jsx(Zn,{value:S,children:n.jsx(Rn,{value:S.content,children:n.jsxs(St.Provider,{value:{inEditMode:!0},children:[n.jsx(oz,{}),n.jsx(ot.Provider,{value:z,children:n.jsxs(vn,{configure:I,children:[n.jsxs(s.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:VM,children:[n.jsx(dz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(qz,{}),n.jsx(s.AppShell.Main,{children:n.jsx(s.Box,{className:`${o} dashboard-root`,sx:{position:"relative"},children:S.content.views.visibleViews.map(A=>n.jsx(Kc,{view:A},A.id))})})]}),n.jsx(DM,{})]})})]})})})})})})})})})},$M=k.observer(h.forwardRef(PM)),p6="",fs=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:qa,queries:Ga,sqlSnippets:Qa,views:Aa,panels:Ba,layouts:Fa,mock_context:ua}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=f.getParent(e).context.current,r=f.getParent(e).globalSQLSnippets,a={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...a,sql_snippets:en(e.sqlSnippets.current,"key","value",a),global_sql_snippets:en(r.list,"id","content",a)}},get payloadForViz(){const t=f.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){const{context:t,filters:r}=this.payloadForViz,a={context:{},filters:e.filters.keyStateItemMap(r)};return Object.entries(t).forEach(([o,l])=>{a.context[o]={type:"context",key:o,value:l}}),a},get dashboardStateValues(){return _r(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardStateValues}},get data(){return e.queries.current.map(({id:r,data:a})=>({id:r,data:a})).reduce((r,a)=>(r[a.id]=a.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function Fd({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,content:l},i,c,d){if(!l)throw new Error("unexpected null content when creating a content model");const{version:u,filters:p,views:g,panels:b,layouts:_,definition:{queries:w,sqlSnippets:x,mock_context:S={}}}=l;return fs.create({id:e,name:t,dashboard_id:r,create_time:a,update_time:o,version:u,filters:Oa(p,i,S,c),queries:hc(w),sqlSnippets:bc(x),mock_context:pa(S),views:Zi(g,d),panels:{list:b},layouts:{list:_,currentBreakpoint:_[0].id}})}const Qd=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:fs,content_id:f.types.string,datasources:Yi,globalSQLSnippets:Va,context:Bn});function jd({id:e,name:t,group:r,content_id:a},o,l,i,c,d,u){return Qd.create({id:e,name:t,group:r,content_id:a,content:Fd(o,c,d,u),datasources:{list:l},globalSQLSnippets:{list:i},context:Pa(c)})}oo(),Po();const AM=({context:e,dashboard:t,content:r,className:a="dashboard",config:o,fullScreenPanelID:l,setFullScreenPanelID:i,filterValues:c,onFilterValuesChange:d,activeTab:u,onActiveTabChange:p,lang:g,onScreenshot:b,additionalPanelMenuItems:_})=>{da(o);const{data:w=[]}=O.useRequest(La),{data:x=[]}=O.useRequest(sc),S=h.useMemo(()=>jd(t,r,w,x,e,c??{},u??null),[t,r]);ld(S.content,!1),h.useEffect(()=>{S.context.replace(e)},[e]),h.useEffect(()=>{S.datasources.replace(w)},[w]),h.useEffect(()=>{S.globalSQLSnippets.replace(x)},[x]),h.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",S.content.filters.values),d==null||d(S.content.filters.values)},[d,S.content.filters.valuesString]),h.useEffect(()=>{c&&S.content.filters.patchValues(c)},[c,S.content.filters.patchValues]),h.useEffect(()=>{p==null||p(S.content.views.firstVisibleTabsViewActiveTab)},[p,S.content.views.firstVisibleTabsViewActiveTabStr]),h.useEffect(()=>{u&&S.content.views.setFirstVisibleTabsViewActiveTab(u)},[u,S.content.views.setFirstVisibleTabsViewActiveTab]);const D=O.useCreation(ca,[S]),z=id(D);return O.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:a,config:o,fullScreenPanelID:l,setFullScreenPanelID:i,filterValues:c,onFilterValuesChange:d,activeTab:u,onActiveTabChange:p,lang:g}),n.jsx(Za.Provider,{value:{onScreenshot:b??y.noop},children:n.jsx(pt.MantineEmotionProvider,{children:n.jsx(ni,{lang:g,children:n.jsx(De.ModalsProvider,{children:n.jsx(ar,{children:n.jsx(Jn,{value:{renderSearchButton:o.renderSearchButton},children:n.jsx(or,{value:{items:_??[]},children:n.jsx(Zn,{value:S,children:n.jsx(Rn,{value:S.content,children:n.jsx(rr.Provider,{value:{fullScreenPanelID:l,setFullScreenPanelID:i},children:n.jsx(St.Provider,{value:{inEditMode:!1},children:n.jsx(s.Box,{className:`${a} dashboard-root`,children:n.jsx(ot.Provider,{value:D,children:n.jsx(vn,{configure:z,children:S.content.views.visibleViews.map(I=>n.jsx(Nn,{view:I},I.id))})})})})})})})})})})})})})})},EM=k.observer(AM),BM=()=>Promise.resolve().then(()=>ep).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));C.APIClient=$e,C.AdditionalPanelMenuItemsContext=sr,C.AdditionalPanelMenuItemsContextProvider=or,C.CURRENT_SCHEMA_VERSION=lt,C.ClientPanelRender=Kk,C.ContentModel=ss,C.ContentModelContext=Hn,C.ContentModelContextProvider=Rn,C.ContentRenderModel=fs,C.ContextMeta=Bn,C.DEFAULT_CUSTOM_MODAL_TITLE=En,C.DashboardApiClient=ai,C.DashboardApiFacadeClient=si,C.DashboardEditor=$M,C.DashboardFilterType=P,C.DashboardMode=Yc,C.DashboardModel=sd,C.DashboardModelContextProvider=Zn,C.DashboardRenderModel=Qd,C.DashboardThemeContextProvider=Jn,C.DashboardViewEditor=Kc,C.DashboardViewRender=Nn,C.DataSourceMetaModel=Ia,C.DataSourceType=W,C.DataSourcesMetaModel=Yi,C.DatesProvider=ar,C.DefaultApiClient=ri,C.DefaultValueModeModelType=ga,C.DescriptionPopover=Xa,C.DraftModel=yc,C.EViewComponentType=B,C.FacadeApiClient=ET,C.FilterCheckboxConfigMeta=fa,C.FilterDateRangeConfigMeta=ba,C.FilterMericoDateRangeConfigMeta=ka,C.FilterMeta=An,C.FilterModel=Zc,C.FilterMultiSelectConfigMeta=va,C.FilterSelectConfigMeta=_a,C.FilterTextInputConfigMeta=ma,C.FilterTreeSelectConfigMeta=Sa,C.FilterTreeSingleSelectConfigMeta=Ta,C.FiltersModel=Jc,C.FiltersRenderModel=qa,C.FullScreenPanel=Fc,C.FullScreenPanelContext=rr,C.GlobalSQLSnippetMeta=Xi,C.GlobalSQLSnippetsMeta=Va,C.LayoutItemMeta=_i,C.LayoutSetMeta=mi,C.LayoutStateContext=St,C.LayoutsRenderModel=Fa,C.MericoMetricQueryMeta=ha,C.MockContextMeta=ua,C.MuteQueryModel=pc,C.Panel=Gc,C.PanelContextProvider=tr,C.PanelErrorOrStateMessage=Bc,C.PanelMeta=ui,C.PanelModel=td,C.PanelRender=ts,C.PanelRenderModel=Ea,C.PanelStyleMeta=li,C.PanelTitleMeta=ii,C.PanelVizAddons=Ec,C.PanelVizMeta=di,C.PanelVizSection=Ha,C.PanelsModel=nd,C.PanelsRenderModel=Ba,C.QueriesModel=Rc,C.QueriesRenderModel=Ga,C.QueryMeta=vi,C.QueryModel=Hc,C.QueryRenderModel=Na,C.ReadOnlyDashboard=EM,C.SQLSnippetMeta=wi,C.SQLSnippetRenderModel=fc,C.SQLSnippetsModel=ed,C.SQLSnippetsRenderModel=Qa,C.VariableMeta=ci,C.ViewComponentTypeBackground=Xc,C.ViewComponentTypeColor=pD,C.ViewComponentTypeName=uD,C.ViewDivisionConfig=Da,C.ViewMeta=Ki,C.ViewModalConfig=za,C.ViewRenderModel=$a,C.ViewTabsConfig=Ma,C.ViewsModel=rd,C.ViewsRenderModel=Aa,C.Viz=Ac,C.applyPartialDashboard=LD,C.configureAPIClient=da,C.createContentModel=ad,C.createContentRenderModel=Fd,C.createContextMeta=Pa,C.createDashboardModel=od,C.createDashboardRenderModel=jd,C.createDraft=vc,C.createFilterCheckboxConfig=xi,C.createFilterDateRangeConfig=Di,C.createFilterMericoDateRangeConfig=Qi,C.createFilterMultiSelectConfig=Mi,C.createFilterSelectConfig=Ii,C.createFilterTextInputConfig=wa,C.createFilterTreeSelectConfig=qi,C.createFilterTreeSingleSelectConfig=Oi,C.createMericoMetricQueryMetaConfig=yi,C.createViewDivisionConfig=ji,C.createViewModalConfig=Wi,C.createViewTabsConfig=Ui,C.facadeApiClient=oi,C.formatSQLSnippet=en,C.getInitialDashboardViewsModel=as,C.getInitialFiltersConfig=Oa,C.getInitialMockContextMeta=pa,C.getInitialQueriesRenderModel=hc,C.getInitialSQLSnippetsRenderModel=bc,C.getInitialViewsRenderModel=Zi,C.getNewPanel=ec,C.getStaticDateRangeDefaultValue=Ti,C.getStaticMericoDateRangeDefaultValue=Gi,C.getVersion=BM,C.initialDashboardContent=d2,C.notifyVizRendered=fe,C.onVizRendered=mh,C.pluginManager=Mt,C.pluginServices=ee,C.useAdditionalPanelMenuItems=lr,C.useContentModelContext=er,C.useDashboardContext=Wt,C.useDashboardThemeContext=Ks,C.useEditContentModelContext=F,C.useEditDashboardContext=j,C.useEditPanelContext=ae,C.useFullScreenPanelContext=Rs,C.useIsInEditPanelContext=Hs,C.useIsInRenderPanelContext=Js,C.useLayoutStateContext=Ys,C.usePanelFullScreen=Qc,C.useRenderContentModelContext=H,C.useRenderDashboardContext=Ws,C.useRenderPanelContext=re,C.useServiceLocator=Xt,C.useVisibleFilters=rk,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|