react-semaphor 0.1.503 → 0.1.505
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +10 -10
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +5 -5
- package/dist/chunks/{calculated-field-identity-BC2NViZZ.js → calculated-field-identity-BTpUqfEu.js} +4 -4
- package/dist/chunks/{calculated-field-identity-CtYhhZoG.cjs → calculated-field-identity-rMuXuzEY.cjs} +1 -1
- package/dist/chunks/{constants-CTRduy1g.js → constants-NUleP4DY.js} +5 -5
- package/dist/chunks/{constants-DNgpRMaX.cjs → constants-vtu7_IUo.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-COqlnnQ2.js → dashboard-briefing-launcher-BBVlEuJl.js} +9 -9
- package/dist/chunks/{dashboard-briefing-launcher-CHMQi0pU.cjs → dashboard-briefing-launcher-R-CLgW59.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-D8z05ZfX.cjs → dashboard-controls-Dn0c-Jgk.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-Bp6XzVvx.js → dashboard-controls-XHwfYtUp.js} +11 -11
- package/dist/chunks/{dashboard-date-comparison-definition-C1vJshiP.js → dashboard-date-comparison-definition-BX0ltXzm.js} +1 -1
- package/dist/chunks/{dashboard-date-comparison-definition-CWz_Yte8.cjs → dashboard-date-comparison-definition-C_w-GO_5.cjs} +1 -1
- package/dist/chunks/{dashboard-json-Dw7kHCe5.js → dashboard-json-C9De0xQW.js} +7 -7
- package/dist/chunks/{dashboard-json-DcvkxkL3.cjs → dashboard-json-DU9vM9ea.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-D5vvLzkS.js → edit-dashboard-visual-DBrMclKq.js} +5068 -5089
- package/dist/chunks/edit-dashboard-visual-tNmK5bv7.cjs +172 -0
- package/dist/chunks/{editor-action-buttons-DYiJr5u3.js → editor-action-buttons-CQLAY7ew.js} +6 -6
- package/dist/chunks/{editor-action-buttons-BsWibSiV.cjs → editor-action-buttons-DdL6ijh_.cjs} +1 -1
- package/dist/chunks/{field-aggregations-tLaXZ2VJ.js → field-aggregations-BU_3gHKR.js} +5 -5
- package/dist/chunks/{field-aggregations-mlkON_QA.cjs → field-aggregations-CDCamEsQ.cjs} +1 -1
- package/dist/chunks/{field-dependencies-ZE2klbHO.js → field-dependencies-DVl2p1Nm.js} +1 -1
- package/dist/chunks/{field-dependencies-R7MrlW6D.cjs → field-dependencies-r_U0CGQ-.cjs} +1 -1
- package/dist/chunks/{index-C3rUIii0.cjs → index-2ahqRcel.cjs} +173 -173
- package/dist/chunks/{index-BVIet238.js → index-BVr4fcCB.js} +11 -11
- package/dist/chunks/{index-Bh3SlWJS.cjs → index-BlYf8gNa.cjs} +1 -1
- package/dist/chunks/{index-ZKSLtc9_.js → index-DfVIKxCM.js} +15830 -15735
- package/dist/chunks/{matrix-analytical-definition-wIEDXvV5.cjs → matrix-analytical-definition-Ct5Tu8np.cjs} +1 -1
- package/dist/chunks/{matrix-analytical-definition-CIVFNNnF.js → matrix-analytical-definition-xesmc3Qa.js} +1 -1
- package/dist/chunks/{matrix-card-Dh0J0_Of.cjs → matrix-card-CRXcmAjp.cjs} +1 -1
- package/dist/chunks/{matrix-card-BVvKHL7s.js → matrix-card-DACDwdTq.js} +2 -2
- package/dist/chunks/{matrix-control-sources-a67fwoOO.cjs → matrix-control-sources-CeC5EMyq.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-CjnsBREg.js → matrix-control-sources-ClQzIk7E.js} +5 -5
- package/dist/chunks/{matrix-definition-CKVi4VVg.cjs → matrix-definition-CBJW_4ii.cjs} +1 -1
- package/dist/chunks/{matrix-definition-BEXCfZAe.js → matrix-definition-RyU0cpLX.js} +1 -1
- package/dist/chunks/{matrix-formatter-CWtdnbfv.cjs → matrix-formatter-7GLTcBuy.cjs} +1 -1
- package/dist/chunks/{matrix-formatter-BTPfthsa.js → matrix-formatter-xsq7n_e6.js} +4 -4
- package/dist/chunks/{matrix-member-presentation-e_KZoZOx.cjs → matrix-member-presentation-E2B4k3ws.cjs} +1 -1
- package/dist/chunks/{matrix-member-presentation-DiDUvZts.js → matrix-member-presentation-qiHxv67e.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-CPgckXxm.js → matrix-operation-contract-Cqy4EW2H.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-thtFuUYf.cjs → matrix-operation-contract-D9dLX-Wr.cjs} +1 -1
- package/dist/chunks/{metric-comparison-Dgyq1I3d.js → metric-comparison-C-sYqv0g.js} +1 -1
- package/dist/chunks/{metric-comparison-CAqV6VnZ.cjs → metric-comparison-DBQ3EJTz.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-DUXM-VOP.cjs → pivot-header-presentation-3wqWChFd.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-DcCO8-Ij.js → pivot-header-presentation-D44ODZGn.js} +3 -3
- package/dist/chunks/{pivot-result-identity-Be1zm0AV.js → pivot-result-identity-BSudrDLN.js} +1 -1
- package/dist/chunks/{pivot-result-identity-DJyF4I2K.cjs → pivot-result-identity-uTiylUNr.cjs} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-DpSZOMOZ.js → pivot-result-lifecycle-BSmqVkVG.js} +7 -7
- package/dist/chunks/{pivot-result-lifecycle-E_huAPev.cjs → pivot-result-lifecycle-DZ0ZSMoM.cjs} +1 -1
- package/dist/chunks/{raw-temporal-DYoPBY6B.cjs → raw-temporal-BUeTpG76.cjs} +1 -1
- package/dist/chunks/{raw-temporal-DfnRBxQn.js → raw-temporal-CUJ86xHI.js} +2 -2
- package/dist/chunks/{raw-temporal-contract-D1_n2pBj.cjs → raw-temporal-contract-DECbTuzA.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-CNwYygW2.js → raw-temporal-contract-Eyr5U8DK.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-BZvi_3DV.cjs → report-preferences-dialog-Bt6UB734.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-BXaILrOK.js → report-preferences-dialog-DVuwK7P1.js} +6 -6
- package/dist/chunks/{report-runtime-context-Dln1qvGS.js → report-runtime-context-DWvUf1HT.js} +1 -1
- package/dist/chunks/{report-runtime-context-CqFbgZq9.cjs → report-runtime-context-DzvHBPxl.cjs} +1 -1
- package/dist/chunks/{semantic-format-C7Goni6h.cjs → semantic-format-BhIL1PXP.cjs} +1 -1
- package/dist/chunks/{semantic-format-PKQt2EAz.js → semantic-format-C3amkGmY.js} +2 -2
- package/dist/chunks/{source-entity-resolution-BMKxwdKN.cjs → source-entity-resolution-CjbgnwyX.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-BSZ07Sl6.js → source-entity-resolution-DZhUckix.js} +1 -1
- package/dist/chunks/{switch-Dej7zCoP.cjs → switch-BytP6QY8.cjs} +26 -26
- package/dist/chunks/{switch-DWM8d-UR.js → switch-DHGiC0aU.js} +1810 -1785
- package/dist/chunks/{temporal-bucket-contract-_WCvDnvn.js → temporal-bucket-contract-D5QlJbmm.js} +1 -1
- package/dist/chunks/{temporal-bucket-contract-CSdspcYj.cjs → temporal-bucket-contract-ZctiyXYk.cjs} +1 -1
- package/dist/chunks/{update-policy-BESKAspa.cjs → update-policy-Cc9h57pA.cjs} +1 -1
- package/dist/chunks/{update-policy-BWbXhkk-.js → update-policy-eTcz52jO.js} +2 -2
- package/dist/chunks/{validators-CHlnnHuS.js → validators-BDYzZFgs.js} +177 -177
- package/dist/chunks/validators-DVYAnnX0.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +9 -9
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +189 -171
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +5 -5
- package/dist/format-utils/index.cjs +1 -1
- package/dist/format-utils/index.js +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +2 -69099
- package/dist/types/appearance/index.d.ts +4 -0
- package/dist/types/appearance/runtime.d.ts +2 -0
- package/dist/types/appearance-runtime.d.ts +2 -152
- package/dist/types/appearance.d.ts +2 -177
- package/dist/types/brand-studio/brand-studio-draft.d.ts +81 -0
- package/dist/types/brand-studio/brand-studio-editor.d.ts +14 -0
- package/dist/types/brand-studio/index.d.ts +2 -0
- package/dist/types/brand-studio.d.ts +2 -246
- package/dist/types/briefings/attachments.d.ts +15 -0
- package/dist/types/briefings/capabilities.d.ts +5 -0
- package/dist/types/briefings/creation.d.ts +6 -0
- package/dist/types/briefings/display.d.ts +21 -0
- package/dist/types/briefings/index.d.ts +362 -0
- package/dist/types/briefings/presentation-contract.d.ts +64 -0
- package/dist/types/briefings/schedule.d.ts +18 -0
- package/dist/types/briefings.d.ts +2 -17437
- package/dist/types/components/ai/assistant-context-entity-controls.d.ts +25 -0
- package/dist/types/components/ai/assistant-message-components.d.ts +59 -0
- package/dist/types/components/ai/assistant-message.d.ts +10 -0
- package/dist/types/components/ai/assistant-virtualized-messages.d.ts +21 -0
- package/dist/types/components/ai/chat-custom-visual.d.ts +21 -0
- package/dist/types/components/ai/chat-input-with-context.d.ts +16 -0
- package/dist/types/components/ai/chat-input.d.ts +11 -0
- package/dist/types/components/ai/chat-visual-query-utils.d.ts +95 -0
- package/dist/types/components/ai/chat-visual.d.ts +12 -0
- package/dist/types/components/ai/clarification-card.d.ts +20 -0
- package/dist/types/components/ai/context-entity-display.d.ts +10 -0
- package/dist/types/components/ai/dashboard-assistant.d.ts +30 -0
- package/dist/types/components/ai/debug-message-array.d.ts +1 -0
- package/dist/types/components/ai/dynamic-visual-host.d.ts +23 -0
- package/dist/types/components/ai/editor-assistant.d.ts +7 -0
- package/dist/types/components/ai/entity-mention-dropdown.d.ts +15 -0
- package/dist/types/components/ai/file-upload/file-preview.d.ts +14 -0
- package/dist/types/components/ai/file-upload/file-upload-button.d.ts +9 -0
- package/dist/types/components/ai/file-upload/file-upload-zone.d.ts +11 -0
- package/dist/types/components/ai/file-upload/file-utils.d.ts +63 -0
- package/dist/types/components/ai/highlighted-input.d.ts +22 -0
- package/dist/types/components/ai/message-feedback-buttons.d.ts +9 -0
- package/dist/types/components/ai/pending-messages-display.d.ts +7 -0
- package/dist/types/components/ai/persisted-dynamic-visual.d.ts +15 -0
- package/dist/types/components/ai/placeholders.d.ts +8 -0
- package/dist/types/components/ai/pre-block.d.ts +30 -0
- package/dist/types/components/ai/quick-replies.d.ts +8 -0
- package/dist/types/components/ai/reasoning-effort-slider.d.ts +7 -0
- package/dist/types/components/ai/seed-questions.d.ts +6 -0
- package/dist/types/components/ai/tool-call-error.d.ts +8 -0
- package/dist/types/components/ai/tool-call.d.ts +12 -0
- package/dist/types/components/ai/tool-output-errors.d.ts +2 -0
- package/dist/types/components/ai/tool-part-renderer.d.ts +32 -0
- package/dist/types/components/appearance/dashboard-appearance-adapter.d.ts +17 -0
- package/dist/types/components/appearance/surface-appearance-adapter.d.ts +21 -0
- package/dist/types/components/briefings/attachments/briefing-attachment-list.d.ts +9 -0
- package/dist/types/components/briefings/attachments/briefing-attachment-selector.d.ts +27 -0
- package/dist/types/components/briefings/attachments/briefing-attachment-settings-dialog.d.ts +16 -0
- package/dist/types/components/briefings/briefing-author/attachment-section.d.ts +20 -0
- package/dist/types/components/briefings/briefing-author/author-actions.d.ts +25 -0
- package/dist/types/components/briefings/briefing-author/content-composers.d.ts +9 -0
- package/dist/types/components/briefings/briefing-author/defaults.d.ts +1 -0
- package/dist/types/components/briefings/briefing-author/delivery-section.d.ts +56 -0
- package/dist/types/components/briefings/briefing-author/form-primitives.d.ts +20 -0
- package/dist/types/components/briefings/briefing-author/output.d.ts +2 -0
- package/dist/types/components/briefings/briefing-author/policy.d.ts +40 -0
- package/dist/types/components/briefings/briefing-author/presentation-vocabulary.d.ts +17 -0
- package/dist/types/components/briefings/briefing-author/run-model.d.ts +49 -0
- package/dist/types/components/briefings/briefing-author/run-ui.d.ts +81 -0
- package/dist/types/components/briefings/briefing-author/schedule-model.d.ts +3 -0
- package/dist/types/components/briefings/briefing-author/schedule-section.d.ts +5 -0
- package/dist/types/components/briefings/briefing-author/schedule.d.ts +8 -0
- package/dist/types/components/briefings/briefing-author/scope-picker.d.ts +14 -0
- package/dist/types/components/briefings/briefing-author/slack-channel-picker.d.ts +22 -0
- package/dist/types/components/briefings/briefing-author/styles.d.ts +4 -0
- package/dist/types/components/briefings/briefing-author-dialog.d.ts +24 -0
- package/dist/types/components/briefings/briefing-author.d.ts +72 -0
- package/dist/types/components/briefings/briefing-html-frame.d.ts +5 -0
- package/dist/types/components/briefings/briefing-recipient-field.d.ts +17 -0
- package/dist/types/components/briefings/briefing-tones.d.ts +30 -0
- package/dist/types/components/briefings/briefing-ui-capabilities.d.ts +16 -0
- package/dist/types/components/briefings/dashboard-briefing-launcher-list.d.ts +25 -0
- package/dist/types/components/briefings/dashboard-briefing-launcher-model.d.ts +14 -0
- package/dist/types/components/briefings/dashboard-briefing-launcher.d.ts +25 -0
- package/dist/types/components/briefings/dashboard-schedule-report-menu-item.d.ts +11 -0
- package/dist/types/components/briefings/index.d.ts +9 -0
- package/dist/types/components/briefings/use-briefing-run-polling.d.ts +34 -0
- package/dist/types/components/briefings/watch-dashboard-button.d.ts +7 -0
- package/dist/types/components/calculated-fields/ai-compose-panel.d.ts +19 -0
- package/dist/types/components/calculated-fields/calculated-field-editor-utils.d.ts +44 -0
- package/dist/types/components/calculated-fields/calculated-field-editor.d.ts +26 -0
- package/dist/types/components/calculated-fields/domain-definition-notice.d.ts +4 -0
- package/dist/types/components/calculated-fields/expression-validator.d.ts +8 -0
- package/dist/types/components/calculated-fields/field-picker-panel.d.ts +16 -0
- package/dist/types/components/calculated-fields/field-type-toggle.d.ts +7 -0
- package/dist/types/components/calculated-fields/index.d.ts +10 -0
- package/dist/types/components/calculated-fields/insert-field-popover.d.ts +18 -0
- package/dist/types/components/calculated-fields/summary-ribbon.d.ts +23 -0
- package/dist/types/components/calculated-fields/templates-menu.d.ts +14 -0
- package/dist/types/components/calculated-fields/validation-results.d.ts +4 -0
- package/dist/types/components/calculated-fields/validation-tooltip-content.d.ts +4 -0
- package/dist/types/components/chart-selector/chart-icon.d.ts +36 -0
- package/dist/types/components/chart-selector/chart-selector-item.d.ts +19 -0
- package/dist/types/components/chart-selector/chart-selector.d.ts +19 -0
- package/dist/types/components/chart-selector/chart-type-picker.d.ts +12 -0
- package/dist/types/components/chart-selector/index.d.ts +5 -0
- package/dist/types/components/chart-selector/star-button.d.ts +13 -0
- package/dist/types/components/chart-selector/use-chart-selector-model.d.ts +18 -0
- package/dist/types/components/dashboard/ai-dashboard-create-dialog.d.ts +38 -0
- package/dist/types/components/dashboard/card-actions-menu.d.ts +10 -0
- package/dist/types/components/dashboard/card-summary.d.ts +8 -0
- package/dist/types/components/dashboard/comparison-badge-state.d.ts +3 -0
- package/dist/types/components/dashboard/comparison-metadata-badge.d.ts +11 -0
- package/dist/types/components/dashboard/dashboard-card.d.ts +17 -0
- package/dist/types/components/dashboard/dashboard-container.d.ts +9 -0
- package/dist/types/components/dashboard/dashboard-create-template.d.ts +10 -0
- package/dist/types/components/dashboard/dashboard-error-state.d.ts +9 -0
- package/dist/types/components/dashboard/dashboard-export-dialog.d.ts +5 -0
- package/dist/types/components/dashboard/dashboard-frame-expand-dialog.d.ts +5 -0
- package/dist/types/components/dashboard/dashboard-frame.d.ts +14 -0
- package/dist/types/components/dashboard/dashboard-hub-row.d.ts +18 -0
- package/dist/types/components/dashboard/dashboard-hub-sort.d.ts +8 -0
- package/dist/types/components/dashboard/dashboard-hub.d.ts +5 -0
- package/dist/types/components/dashboard/dashboard-tabs.d.ts +1 -0
- package/dist/types/components/dashboard/dashboard-visual-error-state.d.ts +14 -0
- package/dist/types/components/dashboard/dashboard-web-component.d.ts +1 -0
- package/dist/types/components/dashboard/dashboard.d.ts +2 -0
- package/dist/types/components/dashboard/download-pdf.d.ts +10 -0
- package/dist/types/components/dashboard/drill-breadcrumb.d.ts +6 -0
- package/dist/types/components/dashboard/drill-navigation-controls.d.ts +13 -0
- package/dist/types/components/dashboard/index.d.ts +3 -0
- package/dist/types/components/dashboard/inline-filter-bar.d.ts +16 -0
- package/dist/types/components/dashboard/inline-filter-component.d.ts +29 -0
- package/dist/types/components/dashboard/kpi-header.d.ts +2 -0
- package/dist/types/components/dashboard/semaphor-style-wrapper.d.ts +3 -0
- package/dist/types/components/dashboard/sheet/delete-sheet-alert.d.ts +6 -0
- package/dist/types/components/dashboard/sheet/layout-change-guard.d.ts +6 -0
- package/dist/types/components/dashboard/sheet/sheet-empty-state.d.ts +5 -0
- package/dist/types/components/dashboard/sheet/sheet-layout.d.ts +4 -0
- package/dist/types/components/dashboard/sheet/sheet-layout_backup.d.ts +0 -0
- package/dist/types/components/dashboard/summary-card.d.ts +16 -0
- package/dist/types/components/dashboard/summary-number-formatter.d.ts +12 -0
- package/dist/types/components/dashboard/summary-warning-utils.d.ts +6 -0
- package/dist/types/components/dashboard/unconfigured-card-state.d.ts +21 -0
- package/dist/types/components/data-app-runtime/published-data-app-runtime.d.ts +7 -0
- package/dist/types/components/document-sheet/document-control-options-resolver.d.ts +9 -0
- package/dist/types/components/document-sheet/document-control-toolbar-actions.d.ts +12 -0
- package/dist/types/components/document-sheet/document-controls-settings.d.ts +7 -0
- package/dist/types/components/document-sheet/document-input-bar.d.ts +32 -0
- package/dist/types/components/document-sheet/document-inspector-primitives.d.ts +10 -0
- package/dist/types/components/document-sheet/document-outline.d.ts +15 -0
- package/dist/types/components/document-sheet/document-page.d.ts +64 -0
- package/dist/types/components/document-sheet/document-sheet.d.ts +10 -0
- package/dist/types/components/document-sheet/document-table-section.d.ts +32 -0
- package/dist/types/components/document-sheet/document-text-editor.d.ts +8 -0
- package/dist/types/components/editor/dashboard-json.d.ts +1 -0
- package/dist/types/components/editor/dynamic-visualization-menu-items.d.ts +3 -0
- package/dist/types/components/editor/editable.d.ts +14 -0
- package/dist/types/components/editor/editor-aside/utils.d.ts +28 -0
- package/dist/types/components/editor/editor-main/advanced-mode-toggle.d.ts +21 -0
- package/dist/types/components/editor/editor-main/card-display-options-dropdown.d.ts +7 -0
- package/dist/types/components/editor/editor-main/card-tabs.d.ts +16 -0
- package/dist/types/components/editor/editor-main/chart-configuration-options.d.ts +1 -0
- package/dist/types/components/editor/editor-main/clear-card-utils.d.ts +2 -0
- package/dist/types/components/editor/editor-main/code-editors/expanded-query-editor-dialog.d.ts +14 -0
- package/dist/types/components/editor/editor-main/code-editors/json-editor-readonly.d.ts +3 -0
- package/dist/types/components/editor/editor-main/code-editors/python-editor.d.ts +2 -0
- package/dist/types/components/editor/editor-main/code-editors/sql-editor.d.ts +6 -0
- package/dist/types/components/editor/editor-main/code-editors/use-query-editor-session-transfer.d.ts +17 -0
- package/dist/types/components/editor/editor-main/content-editable-text.d.ts +10 -0
- package/dist/types/components/editor/editor-main/context-hover-card.d.ts +1 -0
- package/dist/types/components/editor/editor-main/customize-visual/customize-chart-config.d.ts +7 -0
- package/dist/types/components/editor/editor-main/customize-visual/customize-visual-dialog.d.ts +7 -0
- package/dist/types/components/editor/editor-main/dashboard-filter-subscription-status.d.ts +6 -0
- package/dist/types/components/editor/editor-main/dashboard-variable-node.d.ts +25 -0
- package/dist/types/components/editor/editor-main/data-label-settings.d.ts +5 -0
- package/dist/types/components/editor/editor-main/dynamic-visual-editor.d.ts +13 -0
- package/dist/types/components/editor/editor-main/edit-dashboard-visual.d.ts +1 -0
- package/dist/types/components/editor/editor-main/editor-action-buttons.d.ts +28 -0
- package/dist/types/components/editor/editor-main/editor-actions-biz-mode.d.ts +1 -0
- package/dist/types/components/editor/editor-main/editor-card.d.ts +4 -0
- package/dist/types/components/editor/editor-main/editor-chart-config-execution.d.ts +6 -0
- package/dist/types/components/editor/editor-main/editor-main-component.d.ts +1 -0
- package/dist/types/components/editor/editor-main/editor-query-section.d.ts +10 -0
- package/dist/types/components/editor/editor-main/editor-visual-dropdown.d.ts +0 -0
- package/dist/types/components/editor/editor-main/editor-visual-section.d.ts +28 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer-constants.d.ts +7 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer-prompts.d.ts +19 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer-telemetry.d.ts +2 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer-types.d.ts +48 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer-utils.d.ts +11 -0
- package/dist/types/components/editor/editor-main/inline-query-writer/inline-query-writer.d.ts +2 -0
- package/dist/types/components/editor/editor-main/legend-popover.d.ts +1 -0
- package/dist/types/components/editor/editor-main/raw-output-table.d.ts +14 -0
- package/dist/types/components/editor/editor-main/realtime-popover.d.ts +1 -0
- package/dist/types/components/editor/editor-main/table-type-switcher.d.ts +5 -0
- package/dist/types/components/editor/editor-main/text-card-rich-editor.d.ts +21 -0
- package/dist/types/components/editor/editor-main/text-card.d.ts +9 -0
- package/dist/types/components/editor/editor-main/use-editor-clear-action.d.ts +1 -0
- package/dist/types/components/editor/editor-main/visual-aside.d.ts +5 -0
- package/dist/types/components/editor/editor-main/visual-editing-controls.d.ts +6 -0
- package/dist/types/components/editor/editor-main/visual-save-as-dialog.d.ts +17 -0
- package/dist/types/components/editor/editor-main/visual-settings.d.ts +9 -0
- package/dist/types/components/editor/editor.d.ts +8 -0
- package/dist/types/components/editor/mode-toggle.d.ts +13 -0
- package/dist/types/components/editor/query-feedback/query-card-details.d.ts +14 -0
- package/dist/types/components/editor/query-feedback/query-error.d.ts +42 -0
- package/dist/types/components/editor/query-feedback/query-feedback-layout.d.ts +10 -0
- package/dist/types/components/editor/query-feedback/query-info-clipboard.d.ts +3 -0
- package/dist/types/components/editor/query-feedback/query-info.d.ts +21 -0
- package/dist/types/components/editor/query-feedback/query-sql-preview.d.ts +23 -0
- package/dist/types/components/editor/query-feedback/use-query-error-feedback.d.ts +7 -0
- package/dist/types/components/editor/query-feedback/use-query-error.d.ts +16 -0
- package/dist/types/components/editor/query-feedback/visual-query-error-state.d.ts +5 -0
- package/dist/types/components/editor/utils/utils.d.ts +2 -0
- package/dist/types/components/error-fallbacks/delivery-render-error.d.ts +7 -0
- package/dist/types/components/error-fallbacks/fallback.d.ts +19 -0
- package/dist/types/components/explorer/chart-configuration/area-series-config-section.d.ts +5 -0
- package/dist/types/components/explorer/chart-configuration/axis-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/bar-series-config-section.d.ts +5 -0
- package/dist/types/components/explorer/chart-configuration/bar-style-config-section.d.ts +7 -0
- package/dist/types/components/explorer/chart-configuration/bubble-scatter-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/bullet-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/chart-config-sections.d.ts +15 -0
- package/dist/types/components/explorer/chart-configuration/chart-configuration-panel.d.ts +18 -0
- package/dist/types/components/explorer/chart-configuration/chart-fields-configuration.d.ts +22 -0
- package/dist/types/components/explorer/chart-configuration/chart-quick-selector.d.ts +19 -0
- package/dist/types/components/explorer/chart-configuration/chart-type-row.d.ts +25 -0
- package/dist/types/components/explorer/chart-configuration/color-config-section.d.ts +18 -0
- package/dist/types/components/explorer/chart-configuration/combo-series-config-section.d.ts +6 -0
- package/dist/types/components/explorer/chart-configuration/comparison-config-section.d.ts +7 -0
- package/dist/types/components/explorer/chart-configuration/custom-color-picker.d.ts +7 -0
- package/dist/types/components/explorer/chart-configuration/data-labels-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/data-labels-fields.d.ts +21 -0
- package/dist/types/components/explorer/chart-configuration/funnel-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/heatmap-color-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/kpi-format-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/legend-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/line-series-config-section.d.ts +5 -0
- package/dist/types/components/explorer/chart-configuration/line-style-config-section.d.ts +7 -0
- package/dist/types/components/explorer/chart-configuration/matrix-authoring-controls.d.ts +36 -0
- package/dist/types/components/explorer/chart-configuration/matrix-authoring-panel.d.ts +21 -0
- package/dist/types/components/explorer/chart-configuration/matrix-editor-settings.d.ts +5 -0
- package/dist/types/components/explorer/chart-configuration/metric-format-editor.d.ts +12 -0
- package/dist/types/components/explorer/chart-configuration/number-format-config.d.ts +17 -0
- package/dist/types/components/explorer/chart-configuration/number-format-config.utils.d.ts +11 -0
- package/dist/types/components/explorer/chart-configuration/stacked-sort-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/summary-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/tooltip-format-config-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/treemap-color-mode-section.d.ts +1 -0
- package/dist/types/components/explorer/chart-configuration/use-effective-card-type.d.ts +1 -0
- package/dist/types/components/explorer/data-source/add-data-picker.d.ts +23 -0
- package/dist/types/components/explorer/data-source/data-source-panel.d.ts +6 -0
- package/dist/types/components/explorer/data-source/dataset-selector-popover.d.ts +11 -0
- package/dist/types/components/explorer/data-source/db-schema-selector.d.ts +8 -0
- package/dist/types/components/explorer/data-source/direct-source-tree.d.ts +10 -0
- package/dist/types/components/explorer/data-source/entity-tooltip.d.ts +14 -0
- package/dist/types/components/explorer/data-source/file-upload-manager.d.ts +1 -0
- package/dist/types/components/explorer/data-source/select-data-dialog.d.ts +6 -0
- package/dist/types/components/explorer/data-source/selected-entities-summary.d.ts +15 -0
- package/dist/types/components/explorer/data-source/semantic-domain-access-utils.d.ts +10 -0
- package/dist/types/components/explorer/data-source/semantic-domain-selection.d.ts +9 -0
- package/dist/types/components/explorer/data-source/semantic-domain-tree.d.ts +22 -0
- package/dist/types/components/explorer/data-source/url-source-manager.d.ts +1 -0
- package/dist/types/components/explorer/data-source/utils.d.ts +11 -0
- package/dist/types/components/explorer/drag-and-drop/attribute-filter-dialog.d.ts +11 -0
- package/dist/types/components/explorer/drag-and-drop/data-concept-tooltip.d.ts +17 -0
- package/dist/types/components/explorer/drag-and-drop/drag-overlay.d.ts +12 -0
- package/dist/types/components/explorer/drag-and-drop/draggable-field-shell.d.ts +15 -0
- package/dist/types/components/explorer/drag-and-drop/draggable-field.d.ts +13 -0
- package/dist/types/components/explorer/drag-and-drop/droppable-zone.d.ts +13 -0
- package/dist/types/components/explorer/drag-and-drop/inline-edit-field.d.ts +9 -0
- package/dist/types/components/explorer/drag-and-drop/matrix-draggable-field.d.ts +5 -0
- package/dist/types/components/explorer/drag-and-drop/pivot-alias-template-editor.d.ts +6 -0
- package/dist/types/components/explorer/drag-and-drop/pivot-member-order-visibility.d.ts +3 -0
- package/dist/types/components/explorer/drag-and-drop/pivot-value-aliases-editor.d.ts +6 -0
- package/dist/types/components/explorer/fields/field-expression-annotation.d.ts +15 -0
- package/dist/types/components/explorer/fields/field-group.d.ts +0 -0
- package/dist/types/components/explorer/fields/field-hover-preview.d.ts +10 -0
- package/dist/types/components/explorer/fields/field-option-list.d.ts +52 -0
- package/dist/types/components/explorer/fields/field-row.d.ts +39 -0
- package/dist/types/components/explorer/fields/fields-list.d.ts +10 -0
- package/dist/types/components/explorer/fields/fields-section.d.ts +6 -0
- package/dist/types/components/explorer/fields/filterable-fields-panel.d.ts +11 -0
- package/dist/types/components/explorer/fields/icon-for-field-type.d.ts +3 -0
- package/dist/types/components/explorer/fields/numeric-popover.d.ts +6 -0
- package/dist/types/components/explorer/fields/source-field.d.ts +28 -0
- package/dist/types/components/explorer/fields/type-glyph.d.ts +14 -0
- package/dist/types/components/explorer/filters/card-date-filter.d.ts +12 -0
- package/dist/types/components/explorer/filters/card-filter-builder.d.ts +10 -0
- package/dist/types/components/explorer/filters/card-filter-manager.d.ts +12 -0
- package/dist/types/components/explorer/filters/field-multi-select.d.ts +15 -0
- package/dist/types/components/explorer/filters/field-single-select.d.ts +15 -0
- package/dist/types/components/explorer/filters/searchable-field-combobox.d.ts +16 -0
- package/dist/types/components/explorer/filters/utils.d.ts +2 -0
- package/dist/types/components/explorer/join-configuration/auto-join-info.d.ts +16 -0
- package/dist/types/components/explorer/join-configuration/join-conditions-builder.d.ts +10 -0
- package/dist/types/components/explorer/join-configuration/join-dialog.d.ts +14 -0
- package/dist/types/components/explorer/join-configuration/join-manager.d.ts +10 -0
- package/dist/types/components/explorer/join-configuration/join-tooltip-content.d.ts +9 -0
- package/dist/types/components/explorer/main/explorer.d.ts +1 -0
- package/dist/types/components/explorer/main/view-tabs.d.ts +17 -0
- package/dist/types/components/explorer/spreadsheet/column-header.d.ts +11 -0
- package/dist/types/components/explorer/spreadsheet/editor-panel.d.ts +7 -0
- package/dist/types/components/explorer/spreadsheet/formula-bar.d.ts +11 -0
- package/dist/types/components/explorer/spreadsheet/index.d.ts +5 -0
- package/dist/types/components/explorer/spreadsheet/spreadsheet-table.d.ts +10 -0
- package/dist/types/components/explorer/spreadsheet/spreadsheet-view.d.ts +5 -0
- package/dist/types/components/explorer/visualization/chart-settings-panel.d.ts +6 -0
- package/dist/types/components/explorer/visualization/chart-split-view.d.ts +18 -0
- package/dist/types/components/explorer/visualization/feedback-dialog.d.ts +10 -0
- package/dist/types/components/explorer/visualization/row-limit-selector.d.ts +1 -0
- package/dist/types/components/explorer/visualization/visualization-panel.d.ts +18 -0
- package/dist/types/components/icons/bullet-chart-icon.d.ts +2 -0
- package/dist/types/components/index.d.ts +69 -0
- package/dist/types/components/interactions/applied-filters-display.d.ts +35 -0
- package/dist/types/components/interactions/card-renderer.d.ts +17 -0
- package/dist/types/components/interactions/configuration-popover.d.ts +1 -0
- package/dist/types/components/interactions/drill-config/hierarchy-steps-display.d.ts +9 -0
- package/dist/types/components/interactions/drill-config/hierarchy-templates.d.ts +5 -0
- package/dist/types/components/interactions/drill-config/sortable-hierarchy.d.ts +15 -0
- package/dist/types/components/interactions/drill-config/sortable-step.d.ts +14 -0
- package/dist/types/components/interactions/drill-config/step-configuration-popup.d.ts +13 -0
- package/dist/types/components/interactions/drill-hierarchy-modal.d.ts +43 -0
- package/dist/types/components/interactions/drill-to-url-modal.d.ts +26 -0
- package/dist/types/components/interactions/filter-badge-tooltip.d.ts +13 -0
- package/dist/types/components/interactions/hooks/use-drill-hierarchy.d.ts +15 -0
- package/dist/types/components/interactions/hooks/use-hierarchy-templates.d.ts +5 -0
- package/dist/types/components/interactions/hooks/use-step-reordering.d.ts +6 -0
- package/dist/types/components/interactions/insight-modal.d.ts +39 -0
- package/dist/types/components/interactions/insight-viewer.d.ts +28 -0
- package/dist/types/components/interactions/interaction-card.d.ts +59 -0
- package/dist/types/components/interactions/interaction-event-handler.d.ts +11 -0
- package/dist/types/components/interactions/interactions-list.d.ts +50 -0
- package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +24 -0
- package/dist/types/components/interactions/panels/drill-down-panel.d.ts +43 -0
- package/dist/types/components/interactions/panels/drill-to-dashboard-panel.d.ts +24 -0
- package/dist/types/components/interactions/panels/drill-to-insight-panel.d.ts +24 -0
- package/dist/types/components/interactions/panels/drill-to-url-panel-v2.d.ts +9 -0
- package/dist/types/components/interactions/panels/dynamic-drill-panel.d.ts +24 -0
- package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +24 -0
- package/dist/types/components/interactions/panels/panel-field.d.ts +29 -0
- package/dist/types/components/interactions/pickers/dashboard-picker.d.ts +36 -0
- package/dist/types/components/interactions/pickers/insight-picker.d.ts +36 -0
- package/dist/types/components/interactions/replaced-card-wrapper.d.ts +13 -0
- package/dist/types/components/interactions/reusable/field-combobox.d.ts +21 -0
- package/dist/types/components/interactions/reusable/field-selector.d.ts +15 -0
- package/dist/types/components/interactions/reusable/inline-field-selector.d.ts +11 -0
- package/dist/types/components/interactions/reusable/interaction-selection-popover.d.ts +107 -0
- package/dist/types/components/interactions/selectors/action-selector.d.ts +31 -0
- package/dist/types/components/interactions/selectors/trigger-selector.d.ts +38 -0
- package/dist/types/components/kpi-visual-v2/country-selector.d.ts +11 -0
- package/dist/types/components/kpi-visual-v2/kpi-card-explorer.d.ts +12 -0
- package/dist/types/components/kpi-visual-v2/kpi-settings.d.ts +1 -0
- package/dist/types/components/kpi-visual-v2/kpi-tooltip-components.d.ts +25 -0
- package/dist/types/components/kpi-visual-v2/kpi-tooltip-utils.d.ts +8 -0
- package/dist/types/components/kpi-visual-v2/kpi-tooltip.d.ts +14 -0
- package/dist/types/components/kpi-visual-v2/metric-comparison-indicator.d.ts +16 -0
- package/dist/types/components/kpi-visual-v2/metric-comparison-kpi.d.ts +11 -0
- package/dist/types/components/notifications/export-notification-item.d.ts +23 -0
- package/dist/types/components/notifications/export-notification-list.d.ts +7 -0
- package/dist/types/components/notifications/index.d.ts +3 -0
- package/dist/types/components/notifications/notification-bell.d.ts +12 -0
- package/dist/types/components/providers/appearance-context.d.ts +23 -0
- package/dist/types/components/providers/appearance-provider.d.ts +4 -0
- package/dist/types/components/providers/appearance-runtime-provider.d.ts +19 -0
- package/dist/types/components/providers/brand-studio-preview-context.d.ts +5 -0
- package/dist/types/components/providers/dashboard-matrix-execution-provider.d.ts +10 -0
- package/dist/types/components/providers/dashboard-preferences-provider.d.ts +12 -0
- package/dist/types/components/providers/display-preferences-provider.d.ts +10 -0
- package/dist/types/components/providers/semaphor-context-provider.d.ts +13 -0
- package/dist/types/components/providers/semaphor-query-provider.d.ts +3 -0
- package/dist/types/components/providers/theme-provider-context.d.ts +7 -0
- package/dist/types/components/providers/theme-provider.d.ts +8 -0
- package/dist/types/components/providers/ux-provider.d.ts +6 -0
- package/dist/types/components/semaphor/code-block.d.ts +20 -0
- package/dist/types/components/semaphor/code-editor.d.ts +86 -0
- package/dist/types/components/semaphor/code-highlight.d.ts +15 -0
- package/dist/types/components/shared/unsaved-changes/index.d.ts +2 -0
- package/dist/types/components/shared/unsaved-changes/unsaved-changes-alert.d.ts +14 -0
- package/dist/types/components/shared/unsaved-changes/use-pristine-snapshot-initializer.d.ts +6 -0
- package/dist/types/components/sharing-and-management/common-loading-skeleton.d.ts +1 -0
- package/dist/types/components/sharing-and-management/create-dashboard-dialog.d.ts +11 -0
- package/dist/types/components/sharing-and-management/create-visual-dialog.d.ts +11 -0
- package/dist/types/components/sharing-and-management/dashboard-actions-menu.d.ts +19 -0
- package/dist/types/components/sharing-and-management/group-management-dialog.d.ts +6 -0
- package/dist/types/components/sharing-and-management/hooks/use-current-user-info.d.ts +41 -0
- package/dist/types/components/sharing-and-management/hooks/use-group-management.d.ts +30 -0
- package/dist/types/components/sharing-and-management/hooks/use-groups.d.ts +26 -0
- package/dist/types/components/sharing-and-management/hooks/use-resource-management.d.ts +235 -0
- package/dist/types/components/sharing-and-management/hooks/use-resource-share-data.d.ts +27 -0
- package/dist/types/components/sharing-and-management/hooks/use-unified-users.d.ts +53 -0
- package/dist/types/components/sharing-and-management/hooks/use-visual-utils.d.ts +33 -0
- package/dist/types/components/sharing-and-management/resource-edit-dialog.d.ts +14 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/index.d.ts +10 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/access-list.d.ts +14 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/adapter.d.ts +33 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/configs.d.ts +28 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/invite-combobox.d.ts +17 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/primitives.d.ts +33 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/share-shape.d.ts +13 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/shell.d.ts +17 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/status-bar.d.ts +5 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/submission.d.ts +38 -0
- package/dist/types/components/sharing-and-management/resource-share-dialog/unified/types.d.ts +60 -0
- package/dist/types/components/sharing-and-management/utils/group-types.d.ts +105 -0
- package/dist/types/components/sharing-and-management/utils/resource-query-keys.d.ts +14 -0
- package/dist/types/components/sharing-and-management/utils/shares-types.d.ts +122 -0
- package/dist/types/components/sharing-and-management/utils/types.d.ts +86 -0
- package/dist/types/components/sharing-and-management/visuals-library-dialog.d.ts +6 -0
- package/dist/types/components/surfboard/card-controls-toolbar.d.ts +17 -0
- package/dist/types/components/surfboard/controls/card-runtime-controls.d.ts +6 -0
- package/dist/types/components/surfboard/controls/control-authoring-utils.d.ts +182 -0
- package/dist/types/components/surfboard/controls/control-binding-list-editor.d.ts +21 -0
- package/dist/types/components/surfboard/controls/control-definition-editor-helpers.d.ts +43 -0
- package/dist/types/components/surfboard/controls/control-definition-editor-sections.d.ts +65 -0
- package/dist/types/components/surfboard/controls/control-definition-list-editor.d.ts +29 -0
- package/dist/types/components/surfboard/controls/control-select-ui-utils.d.ts +13 -0
- package/dist/types/components/surfboard/controls/control-toolbar-item.d.ts +22 -0
- package/dist/types/components/surfboard/controls/control-toolbar-settings-form.d.ts +30 -0
- package/dist/types/components/surfboard/controls/control-toolbar-settings-shell.d.ts +37 -0
- package/dist/types/components/surfboard/controls/control-usage-utils.d.ts +22 -0
- package/dist/types/components/surfboard/controls/control-validation-message-utils.d.ts +5 -0
- package/dist/types/components/surfboard/controls/dashboard-control-delete-dialog.d.ts +7 -0
- package/dist/types/components/surfboard/controls/dashboard-control-toolbar-popover.d.ts +9 -0
- package/dist/types/components/surfboard/controls/dashboard-controls-settings.d.ts +10 -0
- package/dist/types/components/surfboard/controls/dashboard-filter-controls-button.d.ts +34 -0
- package/dist/types/components/surfboard/controls/dashboard-filter-controls-launcher.d.ts +26 -0
- package/dist/types/components/surfboard/controls/dashboard-runtime-controls.d.ts +1 -0
- package/dist/types/components/surfboard/controls/matrix-structural-targets.d.ts +10 -0
- package/dist/types/components/surfboard/controls/presentation-currency-binding-editor.d.ts +15 -0
- package/dist/types/components/surfboard/controls/runtime-control-input.d.ts +16 -0
- package/dist/types/components/surfboard/controls/runtime-control-utils.d.ts +16 -0
- package/dist/types/components/surfboard/controls/runtime-controls-group.d.ts +12 -0
- package/dist/types/components/surfboard/controls/sortable-control-toolbar-item.d.ts +9 -0
- package/dist/types/components/surfboard/controls/use-create-flow-overlay-state.d.ts +32 -0
- package/dist/types/components/surfboard/controls/use-dashboard-structural-participants.d.ts +14 -0
- package/dist/types/components/surfboard/controls/use-resolved-control-toolbar-options.d.ts +26 -0
- package/dist/types/components/surfboard/dashboard-controls.d.ts +1 -0
- package/dist/types/components/surfboard/dashboard-plus-main.d.ts +1 -0
- package/dist/types/components/surfboard/dashboard-plus.d.ts +7 -0
- package/dist/types/components/surfboard/expanded-card-view.d.ts +10 -0
- package/dist/types/components/surfboard/export-dialog.d.ts +15 -0
- package/dist/types/components/surfboard/filter/apply-filters-check-box.d.ts +7 -0
- package/dist/types/components/surfboard/filter/click-filter-section.d.ts +5 -0
- package/dist/types/components/surfboard/filter/custom-filter/custom-filter-selector.d.ts +12 -0
- package/dist/types/components/surfboard/filter/custom-filter/custom-filter-types.d.ts +45 -0
- package/dist/types/components/surfboard/filter/custom-filter/dashboard-custom-filter.d.ts +19 -0
- package/dist/types/components/surfboard/filter/custom-filter-popover.d.ts +75 -0
- package/dist/types/components/surfboard/filter/dashboard-filter-info-group.d.ts +21 -0
- package/dist/types/components/surfboard/filter/dashboard-filter-mapping-panel.d.ts +13 -0
- package/dist/types/components/surfboard/filter/date-comparison-controls.d.ts +8 -0
- package/dist/types/components/surfboard/filter/date-comparison-label.d.ts +2 -0
- package/dist/types/components/surfboard/filter/date-range-filter-v2.d.ts +38 -0
- package/dist/types/components/surfboard/filter/date-range-filter.d.ts +7 -0
- package/dist/types/components/surfboard/filter/day-picker.d.ts +29 -0
- package/dist/types/components/surfboard/filter/field-date-comparison-scope-message.d.ts +2 -0
- package/dist/types/components/surfboard/filter/field-date-filter.d.ts +9 -0
- package/dist/types/components/surfboard/filter/filter-actions-popover-content.d.ts +9 -0
- package/dist/types/components/surfboard/filter/filter-aside.d.ts +1 -0
- package/dist/types/components/surfboard/filter/filter-component.d.ts +12 -0
- package/dist/types/components/surfboard/filter/filter-configuration-panel.d.ts +102 -0
- package/dist/types/components/surfboard/filter/filter-default-values-picker.d.ts +29 -0
- package/dist/types/components/surfboard/filter/filter-error-state.d.ts +7 -0
- package/dist/types/components/surfboard/filter/filter-header.d.ts +4 -0
- package/dist/types/components/surfboard/filter/filter-info.d.ts +17 -0
- package/dist/types/components/surfboard/filter/filter-option-dependencies-settings.d.ts +33 -0
- package/dist/types/components/surfboard/filter/filter-option-list.d.ts +39 -0
- package/dist/types/components/surfboard/filter/filter-option-source-settings.d.ts +14 -0
- package/dist/types/components/surfboard/filter/filter-picker-popover-content.d.ts +1 -0
- package/dist/types/components/surfboard/filter/filter-popover-parts.d.ts +37 -0
- package/dist/types/components/surfboard/filter/filter-scope-config.d.ts +8 -0
- package/dist/types/components/surfboard/filter/filter-settings-popover-delete.d.ts +0 -0
- package/dist/types/components/surfboard/filter/filter-settings-popover.d.ts +5 -0
- package/dist/types/components/surfboard/filter/filter-toolbar-item.d.ts +21 -0
- package/dist/types/components/surfboard/filter/filter-toolbar-order-utils.d.ts +3 -0
- package/dist/types/components/surfboard/filter/filter-toolbar.d.ts +7 -0
- package/dist/types/components/surfboard/filter/global-date-comparison-footer.d.ts +14 -0
- package/dist/types/components/surfboard/filter/global-date-filter.d.ts +9 -0
- package/dist/types/components/surfboard/filter/hidden-filters.d.ts +1 -0
- package/dist/types/components/surfboard/filter/month-picker.d.ts +18 -0
- package/dist/types/components/surfboard/filter/multi-select-filter.d.ts +16 -0
- package/dist/types/components/surfboard/filter/multi-select-inline-content.d.ts +39 -0
- package/dist/types/components/surfboard/filter/numeric-filter-input.d.ts +8 -0
- package/dist/types/components/surfboard/filter/radio-button-filter.d.ts +8 -0
- package/dist/types/components/surfboard/filter/sortable-filter-toolbar-item.d.ts +24 -0
- package/dist/types/components/surfboard/filter/tabs-filter.d.ts +8 -0
- package/dist/types/components/surfboard/filter/types.d.ts +245 -0
- package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +74 -0
- package/dist/types/components/surfboard/filter/use-filter-header-width.d.ts +12 -0
- package/dist/types/components/surfboard/filter/utils.d.ts +4 -0
- package/dist/types/components/surfboard/index.d.ts +5 -0
- package/dist/types/components/surfboard/inline-options-error-state.d.ts +6 -0
- package/dist/types/components/surfboard/input-chip-row.d.ts +21 -0
- package/dist/types/components/surfboard/json-to-csv.d.ts +7 -0
- package/dist/types/components/surfboard/lens/add-lens-dialog.d.ts +9 -0
- package/dist/types/components/surfboard/lens/default-lens-checkbox.d.ts +1 -0
- package/dist/types/components/surfboard/lens/lens-dropdown.d.ts +10 -0
- package/dist/types/components/surfboard/lens/lens-utils.d.ts +21 -0
- package/dist/types/components/surfboard/preferences/calendar-preferences-panel.d.ts +6 -0
- package/dist/types/components/surfboard/preferences/display-format-preferences-fields.d.ts +9 -0
- package/dist/types/components/surfboard/preferences/display-format-preferences-panel.d.ts +6 -0
- package/dist/types/components/surfboard/preferences/report-preferences-dialog.d.ts +6 -0
- package/dist/types/components/surfboard/toolbar-item-shell.d.ts +17 -0
- package/dist/types/components/ui/accordion.d.ts +7 -0
- package/dist/types/components/ui/alert-dialog.d.ts +20 -0
- package/dist/types/components/ui/alert.d.ts +8 -0
- package/dist/types/components/ui/audience-type-badge.d.ts +9 -0
- package/dist/types/components/ui/avatar.d.ts +6 -0
- package/dist/types/components/ui/badge.d.ts +9 -0
- package/dist/types/components/ui/button.d.ts +11 -0
- package/dist/types/components/ui/calendar.d.ts +8 -0
- package/dist/types/components/ui/card.d.ts +8 -0
- package/dist/types/components/ui/checkbox.d.ts +4 -0
- package/dist/types/components/ui/collapsible.d.ts +5 -0
- package/dist/types/components/ui/command.d.ts +82 -0
- package/dist/types/components/ui/context-menu.d.ts +27 -0
- package/dist/types/components/ui/dialog.d.ts +28 -0
- package/dist/types/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/types/components/ui/hover-card.d.ts +6 -0
- package/dist/types/components/ui/input.d.ts +9 -0
- package/dist/types/components/ui/label.d.ts +5 -0
- package/dist/types/components/ui/popover.d.ts +7 -0
- package/dist/types/components/ui/portal-scope.d.ts +6 -0
- package/dist/types/components/ui/progress.d.ts +4 -0
- package/dist/types/components/ui/radio-group.d.ts +5 -0
- package/dist/types/components/ui/resizable.d.ts +23 -0
- package/dist/types/components/ui/scroll-area.d.ts +5 -0
- package/dist/types/components/ui/select.d.ts +16 -0
- package/dist/types/components/ui/separator.d.ts +4 -0
- package/dist/types/components/ui/sheet.d.ts +39 -0
- package/dist/types/components/ui/skeleton.d.ts +2 -0
- package/dist/types/components/ui/slider.d.ts +4 -0
- package/dist/types/components/ui/sonner.d.ts +4 -0
- package/dist/types/components/ui/switch.d.ts +10 -0
- package/dist/types/components/ui/table.d.ts +13 -0
- package/dist/types/components/ui/tabs.d.ts +14 -0
- package/dist/types/components/ui/textarea.d.ts +9 -0
- package/dist/types/components/ui/toggle.d.ts +12 -0
- package/dist/types/components/ui/tooltip.d.ts +8 -0
- package/dist/types/components/ui-custom/color-field.d.ts +30 -0
- package/dist/types/components/ui-custom/column-search.d.ts +41 -0
- package/dist/types/components/ui-custom/combo-box-2.d.ts +40 -0
- package/dist/types/components/ui-custom/combo-box.d.ts +16 -0
- package/dist/types/components/ui-custom/command-input-custom.d.ts +9 -0
- package/dist/types/components/ui-custom/copy-button.d.ts +15 -0
- package/dist/types/components/ui-custom/copy-on-click.d.ts +11 -0
- package/dist/types/components/ui-custom/custom-scroll-area.d.ts +6 -0
- package/dist/types/components/ui-custom/date-range-picker.d.ts +57 -0
- package/dist/types/components/ui-custom/date-range-popover.d.ts +14 -0
- package/dist/types/components/ui-custom/date-range-presets.d.ts +47 -0
- package/dist/types/components/ui-custom/details.d.ts +7 -0
- package/dist/types/components/ui-custom/dev-mode-switch.d.ts +8 -0
- package/dist/types/components/ui-custom/editable-text.d.ts +21 -0
- package/dist/types/components/ui-custom/grip-reveal.d.ts +4 -0
- package/dist/types/components/ui-custom/icon-button.d.ts +13 -0
- package/dist/types/components/ui-custom/load-on-scroll-status.d.ts +8 -0
- package/dist/types/components/ui-custom/load-on-scroll-utils.d.ts +1 -0
- package/dist/types/components/ui-custom/loading-dots.d.ts +7 -0
- package/dist/types/components/ui-custom/local-blur-input.d.ts +9 -0
- package/dist/types/components/ui-custom/option-search-input.d.ts +16 -0
- package/dist/types/components/ui-custom/overflow-div.d.ts +5 -0
- package/dist/types/components/ui-custom/overflow-span.d.ts +5 -0
- package/dist/types/components/ui-custom/popover-content-custom.d.ts +4 -0
- package/dist/types/components/ui-custom/pre-tag.d.ts +4 -0
- package/dist/types/components/ui-custom/radio-indicator.d.ts +13 -0
- package/dist/types/components/ui-custom/resizable-handle-custom.d.ts +7 -0
- package/dist/types/components/ui-custom/reusable-select.d.ts +16 -0
- package/dist/types/components/ui-custom/visual-badge.d.ts +9 -0
- package/dist/types/components/visual/aggregated-table/aggregate-table.d.ts +2 -0
- package/dist/types/components/visual/aggregated-table/columns/aggregate-columns.d.ts +4 -0
- package/dist/types/components/visual/aggregated-table/columns/column-cell-components.d.ts +16 -0
- package/dist/types/components/visual/aggregated-table/columns/column-definitions.d.ts +29 -0
- package/dist/types/components/visual/aggregated-table/columns/column-header-components.d.ts +31 -0
- package/dist/types/components/visual/aggregated-table/components/aggregate-table-body.d.ts +18 -0
- package/dist/types/components/visual/aggregated-table/components/grand-total-footer.d.ts +22 -0
- package/dist/types/components/visual/aggregated-table/hooks/use-aggregate-table.d.ts +15 -0
- package/dist/types/components/visual/aggregated-table/types/aggregate-table.d.ts +68 -0
- package/dist/types/components/visual/aggregated-table/utils/cell-formatters.d.ts +6 -0
- package/dist/types/components/visual/aggregated-table/utils/data-organizer.d.ts +12 -0
- package/dist/types/components/visual/aggregated-table/utils/export-utils.d.ts +31 -0
- package/dist/types/components/visual/aggregated-table/utils/metric-format-resolver.d.ts +66 -0
- package/dist/types/components/visual/aggregated-table/utils/temporal-presentation.d.ts +17 -0
- package/dist/types/components/visual/chart-utils.d.ts +15 -0
- package/dist/types/components/visual/chartjs-visual.d.ts +9 -0
- package/dist/types/components/visual/column-display-utils.d.ts +2 -0
- package/dist/types/components/visual/custom-visual/build-inline-filter-nodes.d.ts +21 -0
- package/dist/types/components/visual/custom-visual/build-multi-input-props.d.ts +48 -0
- package/dist/types/components/visual/custom-visual/component-combo-box.d.ts +10 -0
- package/dist/types/components/visual/custom-visual/custom-card-theme-adapter.d.ts +3 -0
- package/dist/types/components/visual/custom-visual/custom-visual-settings.d.ts +1 -0
- package/dist/types/components/visual/custom-visual/custom-visual-temporal-presentation.d.ts +35 -0
- package/dist/types/components/visual/custom-visual/custom-visual-types.d.ts +171 -0
- package/dist/types/components/visual/custom-visual/custom-visual-utils.d.ts +57 -0
- package/dist/types/components/visual/custom-visual/dashboard-custom-visual.d.ts +7 -0
- package/dist/types/components/visual/custom-visual/editor-custom-visual.d.ts +6 -0
- package/dist/types/components/visual/custom-visual/hooks/use-ensure-react-globals.d.ts +10 -0
- package/dist/types/components/visual/custom-visual/hooks/use-remote-chart-store.d.ts +9 -0
- package/dist/types/components/visual/custom-visual/multi-input-empty-renderer.d.ts +8 -0
- package/dist/types/components/visual/custom-visual/use-custom-visual.d.ts +16 -0
- package/dist/types/components/visual/data-table/column-def.d.ts +54 -0
- package/dist/types/components/visual/data-table/column-resize-handle.d.ts +8 -0
- package/dist/types/components/visual/data-table/copyable-cell.d.ts +9 -0
- package/dist/types/components/visual/data-table/data-table-column-settings.d.ts +2 -0
- package/dist/types/components/visual/data-table/data-table-conditional-formatting-settings.d.ts +21 -0
- package/dist/types/components/visual/data-table/data-table-pagination.d.ts +2 -0
- package/dist/types/components/visual/data-table/data-table-toolbar.d.ts +2 -0
- package/dist/types/components/visual/data-table/data-table.d.ts +2 -0
- package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +97 -0
- package/dist/types/components/visual/data-table/hooks/use-sql-raw-temporal-format-draft.d.ts +15 -0
- package/dist/types/components/visual/data-table/hooks/use-table-query-state.d.ts +30 -0
- package/dist/types/components/visual/data-table/overflow-cell.d.ts +9 -0
- package/dist/types/components/visual/data-table/table-conditional-formatting-authoring.d.ts +17 -0
- package/dist/types/components/visual/data-table/table-conditional-formatting-rule-model.d.ts +33 -0
- package/dist/types/components/visual/data-table/table-settings-toolbar-button.d.ts +9 -0
- package/dist/types/components/visual/data-table/table-skeleton.d.ts +6 -0
- package/dist/types/components/visual/data-table/table-visual.d.ts +39 -0
- package/dist/types/components/visual/data-table/types/data-table.d.ts +286 -0
- package/dist/types/components/visual/data-table/utils/data-table-utils.d.ts +74 -0
- package/dist/types/components/visual/data-table/utils/export-utils.d.ts +31 -0
- package/dist/types/components/visual/data-table/utils/pagination-utils.d.ts +39 -0
- package/dist/types/components/visual/data-table/utils/sort-conversion.d.ts +5 -0
- package/dist/types/components/visual/data-table/utils/table-behavior.d.ts +33 -0
- package/dist/types/components/visual/data-table/utils/utils.d.ts +4 -0
- package/dist/types/components/visual/info-hover.d.ts +6 -0
- package/dist/types/components/visual/kpi-visual/format-number-setting.d.ts +1 -0
- package/dist/types/components/visual/kpi-visual/kpi-bulb-utils.d.ts +3 -0
- package/dist/types/components/visual/kpi-visual/kpi-card-with-info.d.ts +9 -0
- package/dist/types/components/visual/kpi-visual/kpi-card.d.ts +28 -0
- package/dist/types/components/visual/kpi-visual/kpi-editor-ownership-badge.d.ts +4 -0
- package/dist/types/components/visual/kpi-visual/kpi-utils.d.ts +12 -0
- package/dist/types/components/visual/matrix-table/matrix-axis-menu.d.ts +21 -0
- package/dist/types/components/visual/matrix-table/matrix-card-view.d.ts +16 -0
- package/dist/types/components/visual/matrix-table/matrix-interaction-actions.d.ts +12 -0
- package/dist/types/components/visual/matrix-table/matrix-loading-skeleton.d.ts +14 -0
- package/dist/types/components/visual/matrix-table/matrix-tabular-boundary.d.ts +8 -0
- package/dist/types/components/visual/matrix-table/matrix-viewer-geometry.d.ts +21 -0
- package/dist/types/components/visual/matrix-table/matrix-window-viewer.d.ts +26 -0
- package/dist/types/components/visual/pivot-table/aggregation-menu.d.ts +23 -0
- package/dist/types/components/visual/pivot-table/columns/data-columns.d.ts +26 -0
- package/dist/types/components/visual/pivot-table/columns/row-header-columns.d.ts +20 -0
- package/dist/types/components/visual/pivot-table/columns/row-total-column.d.ts +12 -0
- package/dist/types/components/visual/pivot-table/components/pivot-table-body.d.ts +23 -0
- package/dist/types/components/visual/pivot-table/components/pivot-table-footer.d.ts +29 -0
- package/dist/types/components/visual/pivot-table/hooks/use-pivot-column-headers.d.ts +28 -0
- package/dist/types/components/visual/pivot-table/hooks/use-pivot-pagination.d.ts +29 -0
- package/dist/types/components/visual/pivot-table/hooks/use-pivot-sorting.d.ts +21 -0
- package/dist/types/components/visual/pivot-table/hooks/use-pivot-table-settings.d.ts +15 -0
- package/dist/types/components/visual/pivot-table/pivot-table-tanstack.d.ts +41 -0
- package/dist/types/components/visual/pivot-table/pivot-table.d.ts +100 -0
- package/dist/types/components/visual/pivot-table/types.d.ts +80 -0
- package/dist/types/components/visual/pivot-table/utils/cell-value-formatter.d.ts +14 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-field-identity.d.ts +8 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-formatting-utils.d.ts +24 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-metric-formatting.d.ts +18 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-physical-schema.d.ts +14 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-table-aggregation-helpers.d.ts +21 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-table-data-processor.d.ts +35 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-table-export-utils.d.ts +23 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-table-response.d.ts +50 -0
- package/dist/types/components/visual/pivot-table/utils/pivot-table-sorter.d.ts +7 -0
- package/dist/types/components/visual/pivot-table/utils/row-span-calculator.d.ts +14 -0
- package/dist/types/components/visual/settings/axis-mapping.d.ts +9 -0
- package/dist/types/components/visual/settings/chart-documentation.d.ts +28 -0
- package/dist/types/components/visual/settings/chart-orientation.d.ts +1 -0
- package/dist/types/components/visual/settings/color-format.d.ts +7 -0
- package/dist/types/components/visual/settings/controls-settings.d.ts +7 -0
- package/dist/types/components/visual/settings/dataset-label-popover.d.ts +3 -0
- package/dist/types/components/visual/settings/display-labels.d.ts +1 -0
- package/dist/types/components/visual/settings/filter-on-click-columns.d.ts +1 -0
- package/dist/types/components/visual/settings/frame-filters.d.ts +6 -0
- package/dist/types/components/visual/settings/inline-filters-settings.d.ts +11 -0
- package/dist/types/components/visual/settings/kpi-settings.d.ts +1 -0
- package/dist/types/components/visual/settings/map-chart-settings.d.ts +1 -0
- package/dist/types/components/visual/settings/scale-options.d.ts +1 -0
- package/dist/types/components/visual/settings/table-column-visibility-settings.d.ts +16 -0
- package/dist/types/components/visual/settings/table-presentation-settings.d.ts +27 -0
- package/dist/types/components/visual/settings/table-visual-settings.d.ts +8 -0
- package/dist/types/components/visual/settings/text-settings.d.ts +1 -0
- package/dist/types/components/visual/settings/text-type-radio.d.ts +1 -0
- package/dist/types/components/visual/shared/hooks/use-column-resizing.d.ts +15 -0
- package/dist/types/components/visual/shared/utils/column-type-detector.d.ts +25 -0
- package/dist/types/components/visual/shared/utils/table-column-order.d.ts +45 -0
- package/dist/types/components/visual/shared/utils/table-render-policy.d.ts +20 -0
- package/dist/types/components/visual/table-appearance/table-appearance-adapter.d.ts +41 -0
- package/dist/types/components/visual/table-appearance/table-appearance-primitives.d.ts +32 -0
- package/dist/types/components/visual/visual-error-state.d.ts +13 -0
- package/dist/types/components/visual/visual-utils.d.ts +33 -0
- package/dist/types/components/visual/visual.d.ts +7 -0
- package/dist/types/dashboard-assistant/index.d.ts +101 -0
- package/dist/types/dashboard-assistant.d.ts +2 -13074
- package/dist/types/dashboard-authoring.d.ts +2 -15283
- package/dist/types/dashboard.d.ts +2 -10878
- package/dist/types/data-app-builder/browser-runtime.d.ts +174 -0
- package/dist/types/data-app-builder/constants.d.ts +14 -0
- package/dist/types/data-app-builder/data-app-builder.d.ts +14 -0
- package/dist/types/data-app-builder/index.d.ts +1 -0
- package/dist/types/data-app-builder/lib/api.d.ts +36 -0
- package/dist/types/data-app-builder/lib/context-select.d.ts +3 -0
- package/dist/types/data-app-builder/lib/diagnostics.d.ts +12 -0
- package/dist/types/data-app-builder/lib/file-tree.d.ts +2 -0
- package/dist/types/data-app-builder/types.d.ts +558 -0
- package/dist/types/data-app-builder-browser-runtime.d.ts +2 -185
- package/dist/types/data-app-builder.d.ts +2 -4830
- package/dist/types/data-app-codegen/generate-contract.d.ts +26 -0
- package/dist/types/data-app-codegen/generated-contract-files.d.ts +7 -0
- package/dist/types/data-app-codegen/generated-contract-validation.d.ts +13 -0
- package/dist/types/data-app-codegen/index.d.ts +6 -0
- package/dist/types/data-app-codegen/live-execution.d.ts +42 -0
- package/dist/types/data-app-codegen/node.d.ts +2 -0
- package/dist/types/data-app-codegen/update-policy.d.ts +25 -0
- package/dist/types/data-app-codegen/validation.d.ts +8 -0
- package/dist/types/data-app-codegen-node.d.ts +2 -7263
- package/dist/types/data-app-codegen.d.ts +2 -7235
- package/dist/types/data-app-sdk/adapters.d.ts +34 -0
- package/dist/types/data-app-sdk/analysis-payload.d.ts +2 -0
- package/dist/types/data-app-sdk/builders.d.ts +61 -0
- package/dist/types/data-app-sdk/contracts.d.ts +523 -0
- package/dist/types/data-app-sdk/devtools/index.d.ts +49 -0
- package/dist/types/data-app-sdk/devtools/issues.d.ts +21 -0
- package/dist/types/data-app-sdk/devtools/labels.d.ts +4 -0
- package/dist/types/data-app-sdk/devtools/result-preview.d.ts +8 -0
- package/dist/types/data-app-sdk/devtools/styles.d.ts +15 -0
- package/dist/types/data-app-sdk/devtools/window-snapshot.d.ts +3 -0
- package/dist/types/data-app-sdk/devtools.d.ts +1 -0
- package/dist/types/data-app-sdk/executor.d.ts +5 -0
- package/dist/types/data-app-sdk/field-catalog-validation.d.ts +29 -0
- package/dist/types/data-app-sdk/hooks.d.ts +11 -0
- package/dist/types/data-app-sdk/index.d.ts +10 -0
- package/dist/types/data-app-sdk/matrix-filter-validation.d.ts +12 -0
- package/dist/types/data-app-sdk/provider.d.ts +8 -0
- package/dist/types/data-app-sdk/query-request.d.ts +27 -0
- package/dist/types/data-app-sdk/relationship-aware-field-policy.d.ts +21 -0
- package/dist/types/data-app-sdk/runtime.d.ts +21 -0
- package/dist/types/data-app-sdk/validation.d.ts +58 -0
- package/dist/types/data-app-sdk-adapters.d.ts +2 -6874
- package/dist/types/data-app-sdk-validation.d.ts +2 -10410
- package/dist/types/data-app-sdk.d.ts +2 -35142
- package/dist/types/format-utils.d.ts +2 -12162
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/layouts.d.ts +2 -33
- package/dist/types/lib/actions/data-point-click-action.d.ts +12 -0
- package/dist/types/lib/ai/dynamic-visual-card-utils.d.ts +70 -0
- package/dist/types/lib/ai/dynamic-visual-theme.d.ts +11 -0
- package/dist/types/lib/ai-utils.d.ts +16 -0
- package/dist/types/lib/api/briefings-api.d.ts +51 -0
- package/dist/types/lib/api/exports-api.d.ts +152 -0
- package/dist/types/lib/api/index.d.ts +2 -0
- package/dist/types/lib/appearance/chart-style-adapter.d.ts +4 -0
- package/dist/types/lib/appearance/color.d.ts +13 -0
- package/dist/types/lib/appearance/compiler.d.ts +9 -0
- package/dist/types/lib/appearance/defaults.d.ts +3 -0
- package/dist/types/lib/appearance/dom.d.ts +3 -0
- package/dist/types/lib/appearance/fonts.d.ts +9 -0
- package/dist/types/lib/appearance/index.d.ts +7 -0
- package/dist/types/lib/appearance/merge.d.ts +3 -0
- package/dist/types/lib/appearance/resolver.d.ts +2 -0
- package/dist/types/lib/appearance/schema.d.ts +3 -0
- package/dist/types/lib/appearance/types.d.ts +163 -0
- package/dist/types/lib/briefings/briefing-attachment-model.d.ts +106 -0
- package/dist/types/lib/briefings/briefing-form-model.d.ts +55 -0
- package/dist/types/lib/charts/area-chart.d.ts +5 -0
- package/dist/types/lib/charts/bar-chart.d.ts +5 -0
- package/dist/types/lib/charts/bubble-scatter-chart.d.ts +28 -0
- package/dist/types/lib/charts/bullet-chart.d.ts +17 -0
- package/dist/types/lib/charts/chart-availability.d.ts +7 -0
- package/dist/types/lib/charts/chart-axis-policy.d.ts +20 -0
- package/dist/types/lib/charts/chart-config.d.ts +9 -0
- package/dist/types/lib/charts/chart-documentation.d.ts +23 -0
- package/dist/types/lib/charts/chart-font.d.ts +10 -0
- package/dist/types/lib/charts/chart-selector.d.ts +2 -0
- package/dist/types/lib/charts/chart-utils.d.ts +255 -0
- package/dist/types/lib/charts/color-utils.d.ts +29 -0
- package/dist/types/lib/charts/combo-chart.d.ts +5 -0
- package/dist/types/lib/charts/configuration/axis-configurator.d.ts +36 -0
- package/dist/types/lib/charts/configuration/combo-config.d.ts +36 -0
- package/dist/types/lib/charts/configuration/data-labels-config.d.ts +36 -0
- package/dist/types/lib/charts/configuration/legend-config.d.ts +18 -0
- package/dist/types/lib/charts/create-chart.d.ts +30 -0
- package/dist/types/lib/charts/custom-config-utils.d.ts +0 -0
- package/dist/types/lib/charts/funnel-chart.d.ts +13 -0
- package/dist/types/lib/charts/heatmap-chart.d.ts +15 -0
- package/dist/types/lib/charts/heatmap-constants.d.ts +7 -0
- package/dist/types/lib/charts/line-chart.d.ts +5 -0
- package/dist/types/lib/charts/range-chart.d.ts +12 -0
- package/dist/types/lib/charts/shared/dataset-utils.d.ts +36 -0
- package/dist/types/lib/charts/tornado-chart.d.ts +13 -0
- package/dist/types/lib/charts/treemap-chart.d.ts +15 -0
- package/dist/types/lib/charts/types.d.ts +64 -0
- package/dist/types/lib/charts/utils.d.ts +12 -0
- package/dist/types/lib/class-utils.d.ts +2 -0
- package/dist/types/lib/constants/summary.d.ts +2 -0
- package/dist/types/lib/constants/tool-status-messages.d.ts +12 -0
- package/dist/types/lib/constants.d.ts +30 -0
- package/dist/types/lib/contexts/dashboard-preferences-context.d.ts +7 -0
- package/dist/types/lib/contexts/display-preferences-context.d.ts +6 -0
- package/dist/types/lib/contexts/interactions-popover-context.d.ts +21 -0
- package/dist/types/lib/controls/control-authoring-types.d.ts +28 -0
- package/dist/types/lib/countries.d.ts +8 -0
- package/dist/types/lib/dashboard/duplicate-sheet.d.ts +11 -0
- package/dist/types/lib/dashboard/global-date-filter-utils.d.ts +22 -0
- package/dist/types/lib/dashboard/normalize-dashboard-for-dirty-check.d.ts +18 -0
- package/dist/types/lib/dashboard/semantic-dataset-references.d.ts +24 -0
- package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +41 -0
- package/dist/types/lib/dashboard-inputs/card-compat-adapter.d.ts +9 -0
- package/dist/types/lib/dashboard-inputs/dashboard-control-compat-adapter.d.ts +7 -0
- package/dist/types/lib/dashboard-inputs/dashboard-date-comparison-plan.d.ts +61 -0
- package/dist/types/lib/dashboard-inputs/dashboard-date-comparison.d.ts +42 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-authoring-policy.d.ts +21 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-compat-adapter.d.ts +10 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +142 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +104 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +75 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-ownership.d.ts +13 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-value-identity.d.ts +36 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-authoring-aliases.d.ts +13 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-edit-validation.d.ts +20 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-helpers.d.ts +15 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +58 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +120 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-text.d.ts +11 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +43 -0
- package/dist/types/lib/dashboard-inputs/dashboard-option-dependency-context.d.ts +40 -0
- package/dist/types/lib/dashboard-inputs/document-input-prototype-normalizer.d.ts +2 -0
- package/dist/types/lib/dashboard-inputs/filter-authoring-capabilities.d.ts +39 -0
- package/dist/types/lib/dashboard-inputs/find-normalized-dashboard-filter-input.d.ts +4 -0
- package/dist/types/lib/dashboard-inputs/index.d.ts +11 -0
- package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +57 -0
- package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +17 -0
- package/dist/types/lib/dashboard-inputs/text-card-rich-content.d.ts +5 -0
- package/dist/types/lib/dashboard-inputs/use-effective-dashboard-filter-storage.d.ts +7 -0
- package/dist/types/lib/dnd-utils.d.ts +5 -0
- package/dist/types/lib/document/document-dashboard-inputs.d.ts +48 -0
- package/dist/types/lib/document/document-definition.d.ts +14 -0
- package/dist/types/lib/document/document-input-order.d.ts +5 -0
- package/dist/types/lib/document/document-input-runtime.d.ts +25 -0
- package/dist/types/lib/document/document-inputs.d.ts +30 -0
- package/dist/types/lib/document/document-page-metrics.d.ts +34 -0
- package/dist/types/lib/document/document-pagination.d.ts +57 -0
- package/dist/types/lib/document/document-render-mode.d.ts +8 -0
- package/dist/types/lib/document/document-section-editor.d.ts +8 -0
- package/dist/types/lib/document/document-section-utils.d.ts +11 -0
- package/dist/types/lib/document/document-sheet-utils.d.ts +4 -0
- package/dist/types/lib/document/document-table-data-policy.d.ts +15 -0
- package/dist/types/lib/document/document-table-dom.d.ts +31 -0
- package/dist/types/lib/document/document-table-pagination-model.d.ts +67 -0
- package/dist/types/lib/document/document-table-print-model.d.ts +52 -0
- package/dist/types/lib/document/document-table-result-columns.d.ts +10 -0
- package/dist/types/lib/document/document-table-style.d.ts +33 -0
- package/dist/types/lib/document/document-table-totals.d.ts +8 -0
- package/dist/types/lib/document/document-variables.d.ts +59 -0
- package/dist/types/lib/document/document-visual-render-contract.d.ts +8 -0
- package/dist/types/lib/document/use-document-table-rows.d.ts +21 -0
- package/dist/types/lib/download-pdf.d.ts +104 -0
- package/dist/types/lib/drag-and-drop-utils.d.ts +2 -0
- package/dist/types/lib/editor-draft-sync.d.ts +2 -0
- package/dist/types/lib/encrypt-utils.d.ts +9 -0
- package/dist/types/lib/explorer-utils.d.ts +11 -0
- package/dist/types/lib/export-utils.d.ts +45 -0
- package/dist/types/lib/exports/export-status.d.ts +17 -0
- package/dist/types/lib/fields/field-display.d.ts +35 -0
- package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +18 -0
- package/dist/types/lib/filter-values/build-filter-values-request-payload.d.ts +116 -0
- package/dist/types/lib/filter-values/filter-option-dependency-feedback.d.ts +43 -0
- package/dist/types/lib/filter-values/filter-option-identity.d.ts +10 -0
- package/dist/types/lib/filter-values/filter-option-selection-relevance.d.ts +27 -0
- package/dist/types/lib/filter-values/filter-record-value.d.ts +9 -0
- package/dist/types/lib/filter-values/merge-additional-filter-values.d.ts +12 -0
- package/dist/types/lib/formatters/active-numeric-presentation.d.ts +25 -0
- package/dist/types/lib/formatters/canonical-format-adapter.d.ts +34 -0
- package/dist/types/lib/formatters/card-format-context.d.ts +14 -0
- package/dist/types/lib/formatters/cartesian-temporal-presentation.d.ts +75 -0
- package/dist/types/lib/formatters/chart-numeric-presentation.d.ts +25 -0
- package/dist/types/lib/formatters/currency-presentation-binding.d.ts +72 -0
- package/dist/types/lib/formatters/dashboard-temporal-presentation.d.ts +10 -0
- package/dist/types/lib/formatters/dashboard-temporal-snapshot.d.ts +28 -0
- package/dist/types/lib/formatters/grouped-temporal-activation.d.ts +36 -0
- package/dist/types/lib/formatters/grouped-temporal-authoring.d.ts +33 -0
- package/dist/types/lib/formatters/grouped-temporal-presentation.d.ts +124 -0
- package/dist/types/lib/formatters/kpi-number-formatter.d.ts +24 -0
- package/dist/types/lib/formatters/kpi-result-columns.d.ts +3 -0
- package/dist/types/lib/formatters/metric-formatting.d.ts +197 -0
- package/dist/types/lib/formatters/numeric-presentation.d.ts +10 -0
- package/dist/types/lib/formatters/numeric-value-coercion.d.ts +10 -0
- package/dist/types/lib/formatters/pivot-result-lifecycle-config.d.ts +15 -0
- package/dist/types/lib/formatters/raw-temporal-on-demand-delivery.d.ts +63 -0
- package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +155 -0
- package/dist/types/lib/formatters/regular-table-temporal-presentation.d.ts +9 -0
- package/dist/types/lib/formatters/result-column-identity.d.ts +3 -0
- package/dist/types/lib/formatters/saved-temporal-bucket-format.d.ts +43 -0
- package/dist/types/lib/formatters/semantic-column-presentation.d.ts +9 -0
- package/dist/types/lib/formatters/value-formatter.d.ts +64 -0
- package/dist/types/lib/hooks/ai/assistant-context-entity-utils.d.ts +6 -0
- package/dist/types/lib/hooks/ai/assistant-session.d.ts +3 -0
- package/dist/types/lib/hooks/ai/dashboard-assistant-context.d.ts +35 -0
- package/dist/types/lib/hooks/ai/dashboard-context.d.ts +34 -0
- package/dist/types/lib/hooks/ai/use-active-tool-status.d.ts +10 -0
- package/dist/types/lib/hooks/ai/use-assistant-context-entities.d.ts +19 -0
- package/dist/types/lib/hooks/ai/use-assistant-profile.d.ts +6 -0
- package/dist/types/lib/hooks/ai/use-assistant-scroll.d.ts +8 -0
- package/dist/types/lib/hooks/ai/use-auto-submit-queue.d.ts +13 -0
- package/dist/types/lib/hooks/ai/use-dashboard-assistant.d.ts +36 -0
- package/dist/types/lib/hooks/ai/use-editor-assistant.d.ts +33 -0
- package/dist/types/lib/hooks/ai/use-entity-mentions.d.ts +36 -0
- package/dist/types/lib/hooks/ai/use-local-storage-state.d.ts +1 -0
- package/dist/types/lib/hooks/ai/utils.d.ts +64 -0
- package/dist/types/lib/hooks/calculated-fields/use-ai-expression.d.ts +23 -0
- package/dist/types/lib/hooks/calculated-fields/use-available-fields.d.ts +111 -0
- package/dist/types/lib/hooks/calculated-fields/use-expression-validation.d.ts +18 -0
- package/dist/types/lib/hooks/calculated-fields/use-promote-to-domain.d.ts +17 -0
- package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +6 -0
- package/dist/types/lib/hooks/control-values-query-utils.d.ts +6 -0
- package/dist/types/lib/hooks/explorer/column-catalog.d.ts +4 -0
- package/dist/types/lib/hooks/explorer/column-native-datatype.d.ts +8 -0
- package/dist/types/lib/hooks/explorer/field-management-utils.d.ts +2 -0
- package/dist/types/lib/hooks/explorer/use-card-filter-option-browse.d.ts +10 -0
- package/dist/types/lib/hooks/explorer/use-columns.d.ts +11 -0
- package/dist/types/lib/hooks/explorer/use-data-models.d.ts +8 -0
- package/dist/types/lib/hooks/explorer/use-database-entities.d.ts +15 -0
- package/dist/types/lib/hooks/explorer/use-databases.d.ts +12 -0
- package/dist/types/lib/hooks/explorer/use-datasets.d.ts +53 -0
- package/dist/types/lib/hooks/explorer/use-dev-mode-actions.d.ts +10 -0
- package/dist/types/lib/hooks/explorer/use-domain-calculated-fields.d.ts +6 -0
- package/dist/types/lib/hooks/explorer/use-drag-and-drop.d.ts +22 -0
- package/dist/types/lib/hooks/explorer/use-field-availability-context.d.ts +16 -0
- package/dist/types/lib/hooks/explorer/use-field-management.d.ts +42 -0
- package/dist/types/lib/hooks/explorer/use-files.d.ts +13 -0
- package/dist/types/lib/hooks/explorer/use-filter-builder.d.ts +24 -0
- package/dist/types/lib/hooks/explorer/use-filterable-fields.d.ts +61 -0
- package/dist/types/lib/hooks/explorer/use-join-conditions-builder.d.ts +27 -0
- package/dist/types/lib/hooks/explorer/use-schemas.d.ts +8 -0
- package/dist/types/lib/hooks/explorer/use-scoped-fields.d.ts +53 -0
- package/dist/types/lib/hooks/explorer/use-semantic-domains.d.ts +17 -0
- package/dist/types/lib/hooks/explorer/use-sync-legacy-editor-state.d.ts +20 -0
- package/dist/types/lib/hooks/index.d.ts +14 -0
- package/dist/types/lib/hooks/interactions/use-event-engine.d.ts +65 -0
- package/dist/types/lib/hooks/query-context/use-card-query-context.d.ts +3 -0
- package/dist/types/lib/hooks/query-context/use-dashboard-card-execution-snapshot.d.ts +4 -0
- package/dist/types/lib/hooks/semaphor-ready-indicator.d.ts +17 -0
- package/dist/types/lib/hooks/summary/create-summary-action-handler.d.ts +15 -0
- package/dist/types/lib/hooks/use-add-new-frame.d.ts +8 -0
- package/dist/types/lib/hooks/use-assign-filter.d.ts +5 -0
- package/dist/types/lib/hooks/use-attribute-values.d.ts +20 -0
- package/dist/types/lib/hooks/use-auth-token.d.ts +1 -0
- package/dist/types/lib/hooks/use-authorization-scope.d.ts +2 -0
- package/dist/types/lib/hooks/use-calendar-context.d.ts +13 -0
- package/dist/types/lib/hooks/use-calendar-preferences.d.ts +16 -0
- package/dist/types/lib/hooks/use-card-filter-values.d.ts +19 -0
- package/dist/types/lib/hooks/use-card-numeric-presentation.d.ts +11 -0
- package/dist/types/lib/hooks/use-card-summary.d.ts +17 -0
- package/dist/types/lib/hooks/use-chart-numeric-presentation.d.ts +3 -0
- package/dist/types/lib/hooks/use-click-outside.d.ts +21 -0
- package/dist/types/lib/hooks/use-column-sizing.d.ts +27 -0
- package/dist/types/lib/hooks/use-connection-type.d.ts +0 -0
- package/dist/types/lib/hooks/use-connections.d.ts +27 -0
- package/dist/types/lib/hooks/use-control-values-query.d.ts +48 -0
- package/dist/types/lib/hooks/use-copy-paste-frame.d.ts +2 -0
- package/dist/types/lib/hooks/use-custom-visuals-query.d.ts +30 -0
- package/dist/types/lib/hooks/use-dashboard-authoring.d.ts +49 -0
- package/dist/types/lib/hooks/use-dashboard-card-query.d.ts +4 -0
- package/dist/types/lib/hooks/use-dashboard-card.d.ts +41 -0
- package/dist/types/lib/hooks/use-dashboard-creation.d.ts +17 -0
- package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +22 -0
- package/dist/types/lib/hooks/use-dashboard-filter-option-fields.d.ts +15 -0
- package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +44 -0
- package/dist/types/lib/hooks/use-dashboard-frame.d.ts +0 -0
- package/dist/types/lib/hooks/use-dashboard-input-target-context.d.ts +24 -0
- package/dist/types/lib/hooks/use-dashboard-interaction-mode.d.ts +1 -0
- package/dist/types/lib/hooks/use-dashboard-kpi-actions.d.ts +11 -0
- package/dist/types/lib/hooks/use-dashboard-preferences.d.ts +5 -0
- package/dist/types/lib/hooks/use-dashboard-query.d.ts +28 -0
- package/dist/types/lib/hooks/use-dashboard-summary.d.ts +13 -0
- package/dist/types/lib/hooks/use-dashboard-unsaved-changes-check.d.ts +3 -0
- package/dist/types/lib/hooks/use-dashboard.d.ts +49 -0
- package/dist/types/lib/hooks/use-data-columns.d.ts +8 -0
- package/dist/types/lib/hooks/use-date-filter.d.ts +36 -0
- package/dist/types/lib/hooks/use-date-range-for-filter.d.ts +7 -0
- package/dist/types/lib/hooks/use-debounce.d.ts +1 -0
- package/dist/types/lib/hooks/use-debounced-dirty-check.d.ts +17 -0
- package/dist/types/lib/hooks/use-debounced-editor-value.d.ts +28 -0
- package/dist/types/lib/hooks/use-default-dashboard-mutation.d.ts +9 -0
- package/dist/types/lib/hooks/use-default-sheet-preference.d.ts +9 -0
- package/dist/types/lib/hooks/use-display-preferences.d.ts +4 -0
- package/dist/types/lib/hooks/use-document-section-editor.d.ts +3 -0
- package/dist/types/lib/hooks/use-draggable-button.d.ts +20 -0
- package/dist/types/lib/hooks/use-draggable-corner.d.ts +22 -0
- package/dist/types/lib/hooks/use-dynamic-fallback-render-context.d.ts +12 -0
- package/dist/types/lib/hooks/use-dynamic-icon.d.ts +1 -0
- package/dist/types/lib/hooks/use-edit-visual.d.ts +6 -0
- package/dist/types/lib/hooks/use-editor-aside.d.ts +52 -0
- package/dist/types/lib/hooks/use-editor-setup.d.ts +45 -0
- package/dist/types/lib/hooks/use-export-polling.d.ts +24 -0
- package/dist/types/lib/hooks/use-export-recovery.d.ts +11 -0
- package/dist/types/lib/hooks/use-feedback.d.ts +12 -0
- package/dist/types/lib/hooks/use-filter-aside-setup.d.ts +13 -0
- package/dist/types/lib/hooks/use-filter-option-browse.d.ts +83 -0
- package/dist/types/lib/hooks/use-filter-option-labels.d.ts +12 -0
- package/dist/types/lib/hooks/use-filter-query.d.ts +79 -0
- package/dist/types/lib/hooks/use-filter-search.d.ts +49 -0
- package/dist/types/lib/hooks/use-frame-semantic-execution-payload.d.ts +15 -0
- package/dist/types/lib/hooks/use-has-dashboard-id.d.ts +6 -0
- package/dist/types/lib/hooks/use-insight-card-info.d.ts +30 -0
- package/dist/types/lib/hooks/use-interactions-popover.d.ts +14 -0
- package/dist/types/lib/hooks/use-is-dashboard-ready.d.ts +11 -0
- package/dist/types/lib/hooks/use-joinability-map.d.ts +24 -0
- package/dist/types/lib/hooks/use-kpi.d.ts +6 -0
- package/dist/types/lib/hooks/use-metric-keys-visual.d.ts +6 -0
- package/dist/types/lib/hooks/use-plugin-query.d.ts +6 -0
- package/dist/types/lib/hooks/use-previous.d.ts +1 -0
- package/dist/types/lib/hooks/use-query-feedback.d.ts +45 -0
- package/dist/types/lib/hooks/use-query-key.d.ts +8 -0
- package/dist/types/lib/hooks/use-role-aware-display-preferences.d.ts +29 -0
- package/dist/types/lib/hooks/use-selected-column.d.ts +29 -0
- package/dist/types/lib/hooks/use-semaphor-context.d.ts +4 -0
- package/dist/types/lib/hooks/use-split-view-preference.d.ts +1 -0
- package/dist/types/lib/hooks/use-stable-value.d.ts +38 -0
- package/dist/types/lib/hooks/use-starred-charts.d.ts +1 -0
- package/dist/types/lib/hooks/use-text-filter.d.ts +66 -0
- package/dist/types/lib/hooks/use-theme.d.ts +1 -0
- package/dist/types/lib/hooks/use-topojson.d.ts +7 -0
- package/dist/types/lib/hooks/use-user-preferences.d.ts +24 -0
- package/dist/types/lib/hooks/use-value-format-preferences.d.ts +15 -0
- package/dist/types/lib/hooks/use-visual-editing-status.d.ts +6 -0
- package/dist/types/lib/hooks/use-visual-save-as.d.ts +9 -0
- package/dist/types/lib/hooks/visuals/use-pivot-table-config.d.ts +6 -0
- package/dist/types/lib/interactions/build-interaction-event.d.ts +25 -0
- package/dist/types/lib/interactions/click-filter-display.d.ts +13 -0
- package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +10 -0
- package/dist/types/lib/interactions/execute-interaction-event.d.ts +80 -0
- package/dist/types/lib/interactions/field-utils.d.ts +11 -0
- package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +21 -0
- package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +37 -0
- package/dist/types/lib/interactions/get-click-context-from-pivot-table.d.ts +12 -0
- package/dist/types/lib/interactions/get-click-context-from-table.d.ts +35 -0
- package/dist/types/lib/interactions/handle-chart-click.d.ts +75 -0
- package/dist/types/lib/interactions/interaction-utils.d.ts +16 -0
- package/dist/types/lib/interactions/interaction-validation-utils.d.ts +9 -0
- package/dist/types/lib/interactions/interpolate-url-parameters.d.ts +73 -0
- package/dist/types/lib/interactions/linked-interaction-utils.d.ts +14 -0
- package/dist/types/lib/interactions/source-card-filter-utils.d.ts +9 -0
- package/dist/types/lib/internal-print-report-context.d.ts +5 -0
- package/dist/types/lib/matrix-table/matrix-application-adapter.d.ts +64 -0
- package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +488 -0
- package/dist/types/lib/matrix-table/matrix-card-draft.d.ts +350 -0
- package/dist/types/lib/matrix-table/matrix-card-fields.d.ts +14 -0
- package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +5 -0
- package/dist/types/lib/matrix-table/matrix-clipboard.d.ts +45 -0
- package/dist/types/lib/matrix-table/matrix-conditional-formatting.d.ts +36 -0
- package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +27 -0
- package/dist/types/lib/matrix-table/matrix-delivery.d.ts +751 -0
- package/dist/types/lib/matrix-table/matrix-editor.d.ts +40 -0
- package/dist/types/lib/matrix-table/matrix-execution-context.d.ts +18 -0
- package/dist/types/lib/matrix-table/matrix-execution-provider.d.ts +7 -0
- package/dist/types/lib/matrix-table/matrix-failure-copy.d.ts +16 -0
- package/dist/types/lib/matrix-table/matrix-field-metadata.d.ts +3 -0
- package/dist/types/lib/matrix-table/matrix-label-boundary.d.ts +6 -0
- package/dist/types/lib/matrix-table/matrix-layout.d.ts +18 -0
- package/dist/types/lib/matrix-table/matrix-measure-presentation.d.ts +8 -0
- package/dist/types/lib/matrix-table/matrix-operation-queue.d.ts +8 -0
- package/dist/types/lib/matrix-table/matrix-query-transport.d.ts +3 -0
- package/dist/types/lib/matrix-table/matrix-row-labels.d.ts +13 -0
- package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +117 -0
- package/dist/types/lib/matrix-table/matrix-runtime.d.ts +76 -0
- package/dist/types/lib/matrix-table/matrix-selection.d.ts +20 -0
- package/dist/types/lib/matrix-table/submit-matrix-delivery.d.ts +19 -0
- package/dist/types/lib/matrix-table/use-matrix-card-catalog.d.ts +20 -0
- package/dist/types/lib/matrix-table/use-matrix-delivery-capture.d.ts +6 -0
- package/dist/types/lib/matrix-table/use-matrix-editor-catalog.d.ts +5 -0
- package/dist/types/lib/matrix-table/use-matrix-editor-refresh.d.ts +15 -0
- package/dist/types/lib/matrix-table/use-matrix-selection.d.ts +59 -0
- package/dist/types/lib/matrix-table/use-matrix.d.ts +68 -0
- package/dist/types/lib/mock-data.d.ts +0 -0
- package/dist/types/lib/object-utils.d.ts +4 -0
- package/dist/types/lib/pdf-execution-snapshot.d.ts +12 -0
- package/dist/types/lib/pdf-fast-path/aggregate-metric-semantics.d.ts +1 -0
- package/dist/types/lib/pdf-fast-path/builders.d.ts +46 -0
- package/dist/types/lib/pdf-fast-path/candidate-eligibility.d.ts +17 -0
- package/dist/types/lib/pdf-fast-path/extract-table-structure.d.ts +5 -0
- package/dist/types/lib/pdf-fast-path/index.d.ts +27 -0
- package/dist/types/lib/pdf-fast-path/pivot-fast-path-utils.d.ts +12 -0
- package/dist/types/lib/pdf-fast-path/prepare-server-table-pdf-export.d.ts +37 -0
- package/dist/types/lib/print-state/capture-expanded-state.d.ts +38 -0
- package/dist/types/lib/print-state/use-expose-print-state.d.ts +30 -0
- package/dist/types/lib/python/default-code.d.ts +1 -0
- package/dist/types/lib/query-context/build-card-control-context.d.ts +16 -0
- package/dist/types/lib/query-context/build-card-query-context.d.ts +45 -0
- package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +67 -0
- package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +54 -0
- package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +50 -0
- package/dist/types/lib/query-context/build-global-date-comparison-context.d.ts +9 -0
- package/dist/types/lib/query-context/build-query-relevant-card-config.d.ts +15 -0
- package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +72 -0
- package/dist/types/lib/query-context/control-contract-serialization.d.ts +11 -0
- package/dist/types/lib/query-context/dashboard-card-query-key.d.ts +28 -0
- package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +36 -0
- package/dist/types/lib/query-context/dashboard-query-result-context.d.ts +17 -0
- package/dist/types/lib/query-context/global-date-filter-materialization.d.ts +65 -0
- package/dist/types/lib/query-context/normalize-dashboard-card-execution.d.ts +7 -0
- package/dist/types/lib/query-context/resolve-card-primary-date-field.d.ts +35 -0
- package/dist/types/lib/query-context/resolve-render-card-config.d.ts +16 -0
- package/dist/types/lib/query-context/temporal-context-preview.d.ts +14 -0
- package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
- package/dist/types/lib/resize-observer-utils.d.ts +10 -0
- package/dist/types/lib/stores/ai-interaction-store.d.ts +97 -0
- package/dist/types/lib/stores/assistant-layout-store.d.ts +17 -0
- package/dist/types/lib/stores/chartjs-store.d.ts +36 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +321 -0
- package/dist/types/lib/stores/drill-actions.d.ts +139 -0
- package/dist/types/lib/stores/editor-store.d.ts +222 -0
- package/dist/types/lib/stores/explorer-actions.d.ts +45 -0
- package/dist/types/lib/stores/explorer-empty-states.d.ts +8 -0
- package/dist/types/lib/stores/export-store.d.ts +51 -0
- package/dist/types/lib/stores/index.d.ts +10 -0
- package/dist/types/lib/stores/interaction-store.d.ts +113 -0
- package/dist/types/lib/stores/management-store.d.ts +31 -0
- package/dist/types/lib/stores/mount-store-devtool.d.ts +2 -0
- package/dist/types/lib/stores/pointer-interaction-store.d.ts +18 -0
- package/dist/types/lib/stores/starred-charts-store.d.ts +27 -0
- package/dist/types/lib/stores/store-events.d.ts +35 -0
- package/dist/types/lib/stores/table-actions.d.ts +28 -0
- package/dist/types/lib/stores/utils.d.ts +40 -0
- package/dist/types/lib/table-formatting/index.d.ts +11 -0
- package/dist/types/lib/table-formatting/table-base-formatting-resolver.d.ts +7 -0
- package/dist/types/lib/table-formatting/table-column-visibility.d.ts +5 -0
- package/dist/types/lib/table-formatting/table-conditional-formatting-columns.d.ts +14 -0
- package/dist/types/lib/table-formatting/table-conditional-formatting-evaluator.d.ts +9 -0
- package/dist/types/lib/table-formatting/table-conditional-formatting-range-source.d.ts +8 -0
- package/dist/types/lib/table-formatting/table-conditional-formatting-range.d.ts +9 -0
- package/dist/types/lib/table-formatting/table-formatting-css.d.ts +10 -0
- package/dist/types/lib/table-formatting/table-formatting-normalize.d.ts +3 -0
- package/dist/types/lib/table-formatting/table-formatting-render-model.d.ts +16 -0
- package/dist/types/lib/table-formatting/table-formatting-schemas.d.ts +1101 -0
- package/dist/types/lib/table-formatting/table-formatting-types.d.ts +220 -0
- package/dist/types/lib/table-formatting/table-formatting-utils.d.ts +30 -0
- package/dist/types/lib/table-formatting/table-formatting-validation.d.ts +12 -0
- package/dist/types/lib/table-formatting/table-presentation-fields.d.ts +21 -0
- package/dist/types/lib/table-formatting/table-presentation-style.d.ts +45 -0
- package/dist/types/lib/table-formatting/table-result-bindings.d.ts +12 -0
- package/dist/types/lib/table-formatting/table-text-flow.d.ts +26 -0
- package/dist/types/lib/table-formatting/table-totals-settings.d.ts +23 -0
- package/dist/types/lib/temporal-filter/temporal-filter-utils.d.ts +41 -0
- package/dist/types/lib/types/assistant-types.d.ts +127 -0
- package/dist/types/lib/types/briefing-types.d.ts +216 -0
- package/dist/types/lib/types/calculated-field-domain-payloads.d.ts +36 -0
- package/dist/types/lib/types/calculated-field-editor-types.d.ts +64 -0
- package/dist/types/lib/types/common-types.d.ts +1621 -0
- package/dist/types/lib/types/dropdown-types.d.ts +11 -0
- package/dist/types/lib/types/explorer-types.d.ts +736 -0
- package/dist/types/lib/types/feedback-types.d.ts +60 -0
- package/dist/types/lib/types/index.d.ts +10 -0
- package/dist/types/lib/types/interaction-types.d.ts +483 -0
- package/dist/types/lib/types/query-types.d.ts +81 -0
- package/dist/types/lib/types/semantic-runtime-types.d.ts +14 -0
- package/dist/types/lib/types/semantic-types.d.ts +118 -0
- package/dist/types/lib/types/summary-types.d.ts +74 -0
- package/dist/types/lib/types/token-types.d.ts +312 -0
- package/dist/types/lib/ui/tenancy-ui.d.ts +25 -0
- package/dist/types/lib/utils/aggregate-expression-utils.d.ts +6 -0
- package/dist/types/lib/utils/app-url-utils.d.ts +7 -0
- package/dist/types/lib/utils/assistant-visibility.d.ts +9 -0
- package/dist/types/lib/utils/async-export-visible-columns.d.ts +12 -0
- package/dist/types/lib/utils/authored-card-fields.d.ts +17 -0
- package/dist/types/lib/utils/briefings-visibility.d.ts +9 -0
- package/dist/types/lib/utils/build-card-export-request.d.ts +30 -0
- package/dist/types/lib/utils/calculate-card-filter-values.d.ts +23 -0
- package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +37 -0
- package/dist/types/lib/utils/calculated-date-dimension-defaults.d.ts +9 -0
- package/dist/types/lib/utils/calculated-dimension-utils.d.ts +2 -0
- package/dist/types/lib/utils/calculated-field-identity-utils.d.ts +20 -0
- package/dist/types/lib/utils/calculated-field-normalization.d.ts +2 -0
- package/dist/types/lib/utils/calculated-field-operations.d.ts +40 -0
- package/dist/types/lib/utils/calculated-field-permissions.d.ts +12 -0
- package/dist/types/lib/utils/calculated-field-scope-utils.d.ts +20 -0
- package/dist/types/lib/utils/calculated-field-token-utils.d.ts +11 -0
- package/dist/types/lib/utils/calculated-field-transition-utils.d.ts +113 -0
- package/dist/types/lib/utils/calculated-field-utils.d.ts +37 -0
- package/dist/types/lib/utils/card-calculated-field-utils.d.ts +12 -0
- package/dist/types/lib/utils/card-config-utils.d.ts +24 -0
- package/dist/types/lib/utils/card-definition.d.ts +387 -0
- package/dist/types/lib/utils/card-loading-state.d.ts +17 -0
- package/dist/types/lib/utils/card-utils.d.ts +52 -0
- package/dist/types/lib/utils/chart-icon-utils.d.ts +26 -0
- package/dist/types/lib/utils/chart-type-field-validation.d.ts +25 -0
- package/dist/types/lib/utils/comparison-export-utils.d.ts +31 -0
- package/dist/types/lib/utils/comparison-output-keys.d.ts +37 -0
- package/dist/types/lib/utils/comparison-period-utils.d.ts +6 -0
- package/dist/types/lib/utils/comparison-validation-utils.d.ts +16 -0
- package/dist/types/lib/utils/comparison-window-caption.d.ts +12 -0
- package/dist/types/lib/utils/connection-capabilities.d.ts +26 -0
- package/dist/types/lib/utils/control-default-value-utils.d.ts +46 -0
- package/dist/types/lib/utils/control-placeholder-utils.d.ts +14 -0
- package/dist/types/lib/utils/control-reference-utils.d.ts +18 -0
- package/dist/types/lib/utils/copy-control-bindings.d.ts +3 -0
- package/dist/types/lib/utils/custom-visual-inputs.d.ts +43 -0
- package/dist/types/lib/utils/dashboard-controls-visibility.d.ts +24 -0
- package/dist/types/lib/utils/dashboard-date-filter-utils.d.ts +16 -0
- package/dist/types/lib/utils/dashboard-interaction-mode.d.ts +12 -0
- package/dist/types/lib/utils/data-source-semantic-domain.d.ts +12 -0
- package/dist/types/lib/utils/data-source-utils.d.ts +22 -0
- package/dist/types/lib/utils/date-filter-column-utils.d.ts +2 -0
- package/dist/types/lib/utils/date-format-utils.d.ts +8 -0
- package/dist/types/lib/utils/date-granularity-utils.d.ts +5 -0
- package/dist/types/lib/utils/date-hierarchy-utils.d.ts +73 -0
- package/dist/types/lib/utils/date-timezone-utils.d.ts +99 -0
- package/dist/types/lib/utils/drag-and-drop-utils.d.ts +8 -0
- package/dist/types/lib/utils/drill-context-utils.d.ts +32 -0
- package/dist/types/lib/utils/entity-consistency-utils.d.ts +48 -0
- package/dist/types/lib/utils/entity-icon-utils.d.ts +17 -0
- package/dist/types/lib/utils/explorer-derived-field.d.ts +4 -0
- package/dist/types/lib/utils/explorer-field-identity.d.ts +15 -0
- package/dist/types/lib/utils/export-result-source.d.ts +20 -0
- package/dist/types/lib/utils/export-utils.d.ts +26 -0
- package/dist/types/lib/utils/expression-field-classification.d.ts +12 -0
- package/dist/types/lib/utils/fetch-export-data.d.ts +14 -0
- package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
- package/dist/types/lib/utils/field-dependencies.d.ts +87 -0
- package/dist/types/lib/utils/field-icon-utils.d.ts +10 -0
- package/dist/types/lib/utils/field-state-calculator.d.ts +159 -0
- package/dist/types/lib/utils/filter-default-value-utils.d.ts +24 -0
- package/dist/types/lib/utils/filter-formatter.d.ts +19 -0
- package/dist/types/lib/utils/filter-metadata-utils.d.ts +28 -0
- package/dist/types/lib/utils/filter-name-utils.d.ts +27 -0
- package/dist/types/lib/utils/filter-scoping-utils.d.ts +64 -0
- package/dist/types/lib/utils/filter-search-sql.d.ts +17 -0
- package/dist/types/lib/utils/format-config-extractor.d.ts +21 -0
- package/dist/types/lib/utils/frame-utils.d.ts +27 -0
- package/dist/types/lib/utils/inline-expression-utils.d.ts +11 -0
- package/dist/types/lib/utils/inline-filter-utils.d.ts +15 -0
- package/dist/types/lib/utils/interaction-display-utils.d.ts +30 -0
- package/dist/types/lib/utils/interaction-icons.d.ts +10 -0
- package/dist/types/lib/utils/is-safari-browser.d.ts +6 -0
- package/dist/types/lib/utils/join-plan-entity-matching.d.ts +26 -0
- package/dist/types/lib/utils/kpi-comparison-utils.d.ts +12 -0
- package/dist/types/lib/utils/kpi-field-cleanup-utils.d.ts +19 -0
- package/dist/types/lib/utils/kpi-format-migration.d.ts +2 -0
- package/dist/types/lib/utils/metric-comparison-config.d.ts +9 -0
- package/dist/types/lib/utils/physical-source-identity.d.ts +12 -0
- package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
- package/dist/types/lib/utils/resolve-selected-sheet-id.d.ts +11 -0
- package/dist/types/lib/utils/role-display-mappings.d.ts +44 -0
- package/dist/types/lib/utils/semantic-metric-format-defaults.d.ts +3 -0
- package/dist/types/lib/utils/slot-validation.d.ts +12 -0
- package/dist/types/lib/utils/stable-serialize.d.ts +1 -0
- package/dist/types/lib/utils/summary-eligibility.d.ts +7 -0
- package/dist/types/lib/utils/summary-filter-utils.d.ts +2 -0
- package/dist/types/lib/utils/table-comparison-utils.d.ts +9 -0
- package/dist/types/lib/utils/text-card-runtime-utils.d.ts +6 -0
- package/dist/types/lib/utils/url-parameter-utils.d.ts +60 -0
- package/dist/types/lib/utils/window-transform-utils.d.ts +41 -0
- package/dist/types/lib/utils.d.ts +58 -0
- package/dist/types/lib/visuals/frame-object.d.ts +4 -0
- package/dist/types/main.d.ts +2 -27074
- package/dist/types/pdf-export-policy.d.ts +2 -28
- package/dist/types/report-runtime-context.d.ts +2 -102
- package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +2354 -0
- package/dist/types/shared/analytics-protocol/analyze-result-contract.d.ts +5 -0
- package/dist/types/shared/analytics-protocol/analyze-result-types.d.ts +105 -0
- package/dist/types/shared/analytics-protocol/catalog-field-grounding.d.ts +60 -0
- package/dist/types/shared/analytics-protocol/catalog-source-address.d.ts +27 -0
- package/dist/types/shared/analytics-protocol/contracts.d.ts +845 -0
- package/dist/types/shared/analytics-protocol/dashboard-date-comparison-definition.d.ts +24 -0
- package/dist/types/shared/analytics-protocol/dashboard-input-contract.d.ts +8 -0
- package/dist/types/shared/analytics-protocol/data-app-codegen-summary.d.ts +418 -0
- package/dist/types/shared/analytics-protocol/exact-decimal.d.ts +15 -0
- package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +1927 -0
- package/dist/types/shared/analytics-protocol/explorer-input-schemas.d.ts +5 -0
- package/dist/types/shared/analytics-protocol/field-validation.d.ts +15 -0
- package/dist/types/shared/analytics-protocol/fixtures.d.ts +249 -0
- package/dist/types/shared/analytics-protocol/index.d.ts +30 -0
- package/dist/types/shared/analytics-protocol/matrix-analytical-definition.d.ts +253 -0
- package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +7409 -0
- package/dist/types/shared/analytics-protocol/matrix-member-presentation.d.ts +20 -0
- package/dist/types/shared/analytics-protocol/matrix-operation-contract.d.ts +759 -0
- package/dist/types/shared/analytics-protocol/matrix-operation-request.d.ts +743 -0
- package/dist/types/shared/analytics-protocol/matrix-path-contract.d.ts +427 -0
- package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +404 -0
- package/dist/types/shared/analytics-protocol/metric-comparison.d.ts +183 -0
- package/dist/types/shared/analytics-protocol/operators.d.ts +10 -0
- package/dist/types/shared/analytics-protocol/option-predicate.d.ts +43 -0
- package/dist/types/shared/analytics-protocol/option-relevance.d.ts +19 -0
- package/dist/types/shared/analytics-protocol/physical-source-resolution.d.ts +54 -0
- package/dist/types/shared/analytics-protocol/qualified-identity.d.ts +3 -0
- package/dist/types/shared/analytics-protocol/raw-temporal-contract.d.ts +14 -0
- package/dist/types/shared/analytics-protocol/runtime-schemas.d.ts +3373 -0
- package/dist/types/shared/analytics-protocol/scalar-value.d.ts +55 -0
- package/dist/types/shared/analytics-protocol/source-capabilities.d.ts +64 -0
- package/dist/types/shared/analytics-protocol/source-entity-resolution.d.ts +80 -0
- package/dist/types/shared/analytics-protocol/source-identity.d.ts +36 -0
- package/dist/types/shared/analytics-protocol/temporal-bucket-contract.d.ts +39 -0
- package/dist/types/shared/analytics-protocol/temporal-context.d.ts +35 -0
- package/dist/types/shared/analytics-protocol/validators.d.ts +21 -0
- package/dist/types/shared/dashboard-authoring/artifact-compiler.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +22 -0
- package/dist/types/shared/dashboard-authoring/calculated-field-placement.d.ts +16 -0
- package/dist/types/shared/dashboard-authoring/canonical-result-keys.d.ts +25 -0
- package/dist/types/shared/dashboard-authoring/card-reference-remapping.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/comparison-document-migration.d.ts +36 -0
- package/dist/types/shared/dashboard-authoring/contracts.d.ts +153 -0
- package/dist/types/shared/dashboard-authoring/control-value-resolution.d.ts +51 -0
- package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +37 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-automatic-target.d.ts +37 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +32 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-types.d.ts +46 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-sql-subscription.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-sql-target.d.ts +20 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-value-compatibility.d.ts +9 -0
- package/dist/types/shared/dashboard-authoring/dashboard-option-dependencies.d.ts +81 -0
- package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +29 -0
- package/dist/types/shared/dashboard-authoring/filter-defaults.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +29 -0
- package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/matrix-authoring.d.ts +59 -0
- package/dist/types/shared/dashboard-authoring/matrix-card.d.ts +25 -0
- package/dist/types/shared/dashboard-authoring/matrix-control-resolution.d.ts +19 -0
- package/dist/types/shared/dashboard-authoring/matrix-control-sources.d.ts +14 -0
- package/dist/types/shared/dashboard-authoring/matrix-definition.d.ts +15 -0
- package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +1453 -0
- package/dist/types/shared/dashboard-authoring/protocol-adapter.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/source-matching.d.ts +34 -0
- package/dist/types/shared/dashboard-authoring/temporal-bucket-authoring.d.ts +19 -0
- package/dist/types/shared/dashboard-authoring/temporal-result-owner.d.ts +25 -0
- package/dist/types/shared/dashboard-authoring/validators.d.ts +3 -0
- package/dist/types/shared/dirty-check/index.d.ts +2 -0
- package/dist/types/shared/filter-native-data-type.d.ts +59 -0
- package/dist/types/shared/format-utils/aggregate-table-row-presentation.d.ts +85 -0
- package/dist/types/shared/format-utils/export-policy.d.ts +19 -0
- package/dist/types/shared/format-utils/exporters/csv-utils.d.ts +23 -0
- package/dist/types/shared/format-utils/exporters/index.d.ts +3 -0
- package/dist/types/shared/format-utils/exporters/pivot-exporter.d.ts +13 -0
- package/dist/types/shared/format-utils/exporters/table-exporter.d.ts +10 -0
- package/dist/types/shared/format-utils/flat-table-export-totals.d.ts +25 -0
- package/dist/types/shared/format-utils/formatters/cell-formatter.d.ts +22 -0
- package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +62 -0
- package/dist/types/shared/format-utils/formatters/duration-formatter.d.ts +2 -0
- package/dist/types/shared/format-utils/formatters/exact-number.d.ts +1 -0
- package/dist/types/shared/format-utils/formatters/index.d.ts +6 -0
- package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +35 -0
- package/dist/types/shared/format-utils/formatters/metric-comparison-formatter.d.ts +22 -0
- package/dist/types/shared/format-utils/formatters/number-formatter.d.ts +47 -0
- package/dist/types/shared/format-utils/grouped-table-presentation.d.ts +15 -0
- package/dist/types/shared/format-utils/index.d.ts +38 -0
- package/dist/types/shared/format-utils/json-record.d.ts +6 -0
- package/dist/types/shared/format-utils/matrix-continuation.d.ts +195 -0
- package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +22 -0
- package/dist/types/shared/format-utils/numeric-presentation.d.ts +36 -0
- package/dist/types/shared/format-utils/pdf-delivery.d.ts +25 -0
- package/dist/types/shared/format-utils/pdf-export-policy.d.ts +20 -0
- package/dist/types/shared/format-utils/pivot-header-presentation.d.ts +28 -0
- package/dist/types/shared/format-utils/pivot-result-contract-expectations.d.ts +28 -0
- package/dist/types/shared/format-utils/pivot-result-identity.d.ts +52 -0
- package/dist/types/shared/format-utils/pivot-result-lifecycle.d.ts +55 -0
- package/dist/types/shared/format-utils/presentation-execution.d.ts +88 -0
- package/dist/types/shared/format-utils/raw-temporal.d.ts +89 -0
- package/dist/types/shared/format-utils/semantic-format.d.ts +44 -0
- package/dist/types/shared/format-utils/table-structure.d.ts +43 -0
- package/dist/types/shared/format-utils/temporal-bucket-format-policy.d.ts +41 -0
- package/dist/types/shared/format-utils/temporal-bucket.d.ts +77 -0
- package/dist/types/shared/format-utils/types/format-types.d.ts +233 -0
- package/dist/types/shared/format-utils/types/index.d.ts +1 -0
- package/dist/types/shared/index.d.ts +1 -0
- package/dist/types/shared/layouts/create-frame-layouts.d.ts +27 -0
- package/dist/types/shared/layouts/index.d.ts +1 -0
- package/dist/types/shared/report-runtime-context/calendar-validation.d.ts +2 -0
- package/dist/types/shared/report-runtime-context/index.d.ts +2 -0
- package/dist/types/shared/report-runtime-context/report-runtime-context.d.ts +58 -0
- package/dist/types/shared/value-format-preferences/index.d.ts +1 -0
- package/dist/types/shared/value-format-preferences/value-format-preferences.d.ts +102 -0
- package/dist/types/shared.d.ts +2 -9998
- package/dist/types/surfboard.d.ts +2 -10910
- package/dist/types/types.d.ts +2 -12279
- package/dist/types/value-format-preferences.d.ts +2 -129
- package/package.json +3 -2
- package/dist/chunks/edit-dashboard-visual-olfXEK5D.cjs +0 -172
- package/dist/chunks/validators-D2F_uxxP.cjs +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("react"),a=require("./index-2ahqRcel.cjs"),le=require("./x-B6ghREd2.cjs"),t=require("./switch-BytP6QY8.cjs"),ye=require("./constants-vtu7_IUo.cjs"),st=require("./validators-DVYAnnX0.cjs");require("./matrix-operation-contract-D9dLX-Wr.cjs");const $t=require("../value-format-preferences/index.cjs"),Ze=require("./field-aggregations-CDCamEsQ.cjs"),qe=require("./search-BqqhaMx9.cjs"),gt=require("./editor-action-buttons-DdL6ijh_.cjs"),It=require("./calculated-field-identity-rMuXuzEY.cjs");require("zod");const he=require("./index-BlYf8gNa.cjs"),dr=require("react-dom");require("./appearance-runtime-provider-Ca8rxO86.cjs");const ur=require("./appearance-context-tNjvTJj3.cjs");require("./index-C8XCKzB6.cjs");require("./matrix-continuation-6nhDy-lF.cjs");require("./color-CyB5o13F.cjs");const mr=require("./matrix-control-sources-CeC5EMyq.cjs"),ft=require("./matrix-definition-CBJW_4ii.cjs"),ea=require("./raw-temporal-BUeTpG76.cjs"),Tn=require("./metric-comparison-DBQ3EJTz.cjs"),ta=require("./matrix-formatter-7GLTcBuy.cjs"),xr=require("./semantic-format-BhIL1PXP.cjs"),hr=require("./palette-BN-jYtaK.cjs");function pr(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>s[r]})}}return n.default=s,Object.freeze(n)}const ss=pr(v);/**
|
|
2
|
+
* @license lucide-react v0.453.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const fr=le.createLucideIcon("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const gr=le.createLucideIcon("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const sa=le.createLucideIcon("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const na=le.createLucideIcon("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
|
|
22
|
+
* @license lucide-react v0.453.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Ds=le.createLucideIcon("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
|
|
27
|
+
* @license lucide-react v0.453.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const br=le.createLucideIcon("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/**
|
|
32
|
+
* @license lucide-react v0.453.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const jr=le.createLucideIcon("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
|
|
37
|
+
* @license lucide-react v0.453.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const vr=le.createLucideIcon("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
|
|
42
|
+
* @license lucide-react v0.453.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const yr=le.createLucideIcon("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/**
|
|
47
|
+
* @license lucide-react v0.453.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Cr=le.createLucideIcon("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/**
|
|
52
|
+
* @license lucide-react v0.453.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const Nr=le.createLucideIcon("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/**
|
|
57
|
+
* @license lucide-react v0.453.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Sr=le.createLucideIcon("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/**
|
|
62
|
+
* @license lucide-react v0.453.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const En=le.createLucideIcon("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
|
|
67
|
+
* @license lucide-react v0.453.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const wr=le.createLucideIcon("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/**
|
|
72
|
+
* @license lucide-react v0.453.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Tr=le.createLucideIcon("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/**
|
|
77
|
+
* @license lucide-react v0.453.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const xs=le.createLucideIcon("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/**
|
|
82
|
+
* @license lucide-react v0.453.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const hs=le.createLucideIcon("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
|
|
87
|
+
* @license lucide-react v0.453.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Er=le.createLucideIcon("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/**
|
|
92
|
+
* @license lucide-react v0.453.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Ir=le.createLucideIcon("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/**
|
|
97
|
+
* @license lucide-react v0.453.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const Dr=le.createLucideIcon("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
|
|
102
|
+
* @license lucide-react v0.453.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const Ts=le.createLucideIcon("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
|
|
107
|
+
* @license lucide-react v0.453.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const kr=le.createLucideIcon("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
|
|
112
|
+
* @license lucide-react v0.453.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const Mr=le.createLucideIcon("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/**
|
|
117
|
+
* @license lucide-react v0.453.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const Ar=le.createLucideIcon("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
|
|
122
|
+
* @license lucide-react v0.453.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const Lr=le.createLucideIcon("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/**
|
|
127
|
+
* @license lucide-react v0.453.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Fr=le.createLucideIcon("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
|
|
132
|
+
* @license lucide-react v0.453.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const Rr=le.createLucideIcon("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/**
|
|
137
|
+
* @license lucide-react v0.453.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const Pr=le.createLucideIcon("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function Or({open:s,onOpenChange:n}){const[r,o]=v.useState([]),{updateDataSource:i}=t.useEditorActions(),{selectedEntities:d}=a.useAssistantContextEntities("dashboard");v.useEffect(()=>{s&&o([])},[s]);const c=p=>{o(j=>j.some(f=>a.areContextEntitiesEqual(f,p))?j.filter(f=>!a.areContextEntitiesEqual(f,p)):[...j,p])},l=()=>{o([...d])},u=()=>{o([])},x=()=>{if(r.length===0)return;const p=r[0],j=p.connectionId||"",N=p.connectionType||"",g=r.some(D=>D.type==="dataset")?"semanticDomain":"database";i({connectionId:j,connectionType:N,mode:g,selectedEntities:r}),n(!1)},m=p=>"label"in p&&p.label?p.label:p.name,b=p=>{if("description"in p&&p.description)return p.description;const j=[];return p.database&&j.push(p.database),p.schema&&j.push(p.schema),p.name&&j.push(p.name),j.join(".")},h=p=>r.some(j=>a.areContextEntitiesEqual(j,p));return d.length===0?e.jsx(a.Dialog,{open:s,onOpenChange:n,children:e.jsxs(a.DialogContent,{className:"max-w-md",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"No Data Available"}),e.jsx(a.DialogDescription,{children:"No entities are currently available in the AI context. Please add some data sources to the dashboard first."})]}),e.jsx(a.DialogFooter,{children:e.jsx(t.Button,{onClick:()=>n(!1),children:"Close"})})]})}):e.jsx(a.Dialog,{open:s,onOpenChange:n,children:e.jsxs(a.DialogContent,{className:"flex max-w-2xl flex-col",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Select Data to Analyze"}),e.jsx(a.DialogDescription,{children:"Choose entities from the dashboard's context"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"outline",size:"sm",onClick:l,disabled:r.length===d.length,children:"Select All"}),e.jsx(t.Button,{variant:"outline",size:"sm",onClick:u,disabled:r.length===0,children:"Clear All"})]}),e.jsxs(a.Badge,{variant:"secondary",children:[r.length," of ",d.length," selected"]})]}),e.jsx(t.Separator,{}),e.jsx(t.ScrollArea,{className:"h-64",children:e.jsx("div",{className:"space-y-2",children:d.map((p,j)=>e.jsxs("div",{className:t.cn("flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-muted/50",h(p)&&"border-primary bg-primary/5"),children:[e.jsx(a.Checkbox,{checked:h(p),onCheckedChange:()=>c(p)}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:a.getEntityIcon(p.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:m(p)}),e.jsx("div",{className:"truncate text-sm text-muted-foreground",children:b(p)})]}),e.jsx(a.Badge,{variant:"outline",className:"text-xs",children:p.type})]},`${p.type}-${p.name}-${j}`))})})]}),e.jsx(a.DialogFooter,{children:e.jsx("div",{className:"flex w-full justify-between",children:e.jsxs("div",{className:"flex grow justify-end gap-2",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsxs(t.Button,{onClick:x,disabled:r.length===0,children:["Select"," ",r.length>0?`(${r.length})`:""]})]})})})]})})}function In(){return{id:"group-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),operator:"AND",keys:[]}}function Br({initialJoinPlan:s,availableDataSources:n}){const[r,o]=v.useState(()=>Ze.normalizeJoinPlanEntityReferences(s,n)),[i,d]=v.useState(new Set),c=()=>{const L=r.joins.length>0?Math.max(...r.joins.map(F=>F.sequence))+1:1,A={id:`join-${Date.now()}`,source:{type:"table",name:"",database:"",schema:""},target:{type:"table",name:"",database:"",schema:""},joinType:"INNER",sequence:L,joinKeyGroups:[{id:"group-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),operator:"AND",keys:[]}]};o({...r,joins:[...r.joins,A]}),d(new Set([...i,A.id]))},l=L=>{o({...r,joins:r.joins.filter(A=>A.id!==L)}),d(new Set([...i].filter(A=>A!==L)))},u=(L,A)=>{var M,T,R,C,V;const F=r.joins.find(P=>P.id===L);if(!F)return;const I={...F,...A};if((M=I.source)!=null&&M.name&&((T=I.target)!=null&&T.name)&&I.source.name===I.target.name){t.ue.error("Self-joins are not yet supported",{description:`Joining ${I.source.name} to itself is not currently supported. Please select a different target table.`});return}const y=r.joins.filter(P=>{var O;return P.id!==L&&P.target.name===((O=I.target)==null?void 0:O.name)});if((R=I.target)!=null&&R.name&&y.length>0){t.ue.error("Duplicate join targets are not supported",{description:`The table ${I.target.name} is already used as a target in another join. Each table can only be joined once.`});return}const E=r.joins.map(P=>P.id===L?I:P);if((C=I.source)!=null&&C.name&&((V=I.target)!=null&&V.name)&&I.joinKeyGroups[0].keys.length===0){const P=n.find(z=>{var q;return z.name===((q=I.source)==null?void 0:q.name)}),O=n.find(z=>{var q;return z.name===((q=I.target)==null?void 0:q.name)}),B={id:`key-${Date.now()}`,source:{id:`source-${Date.now()}`,name:"",dataType:"",label:"",qualifiedFieldName:"",entityId:(P==null?void 0:P.name)||"",entityName:(P==null?void 0:P.name)||"",entityType:(P==null?void 0:P.type)||"table"},target:{id:`target-${Date.now()}`,name:"",dataType:"",label:"",qualifiedFieldName:"",entityId:(O==null?void 0:O.name)||"",entityName:(O==null?void 0:O.name)||"",entityType:(O==null?void 0:O.type)||"table"},operator:"="},_=[...I.joinKeyGroups];_[0]={..._[0],keys:[B]},I.joinKeyGroups=_,E[E.findIndex(z=>z.id===L)]=I}o({...r,joins:E})};return{joinPlan:r,expandedJoins:i,setJoinPlan:o,addJoin:c,removeJoin:l,updateJoin:u,moveJoinUp:L=>{const A=r.joins.findIndex(F=>F.id===L);if(A>0){const F=[...r.joins],I={...F[A]},y={...F[A-1]};F[A]=y,F[A-1]=I,F.forEach((M,T)=>{M.sequence=T+1});const E={...r,joins:F};o(E)}},moveJoinDown:L=>{const A=r.joins.findIndex(F=>F.id===L);if(A<r.joins.length-1){const F=[...r.joins],I={...F[A]},y={...F[A+1]};F[A]=y,F[A+1]=I,F.forEach((M,T)=>{M.sequence=T+1});const E={...r,joins:F};o(E)}},toggleJoinExpansion:L=>{const A=new Set(i);A.has(L)?A.delete(L):A.add(L),d(A)},getAvailableSourceEntities:L=>{if(r.joins.length===0)return n;const A=r.joins.findIndex(I=>I.id===L);if(A===0)return n.filter(I=>I.name===r.baseEntity.name);const F=new Set;return r.baseEntity.name&&F.add(r.baseEntity.name),r.joins.slice(0,A).forEach(I=>{F.add(I.source.name),F.add(I.target.name)}),n.filter(I=>F.has(I.name))},getAvailableTargetEntities:L=>n.filter(A=>A.name!==L),addJoinKeyGroup:L=>{const A=r.joins.find(I=>I.id===L);if(!A)return;const F=[...A.joinKeyGroups,In()];u(L,{joinKeyGroups:F})},updateGroupOperator:(L,A,F)=>{const I=r.joins.find(E=>E.id===L);if(!I)return;const y=[...I.joinKeyGroups];y[A]={...y[A],operator:F},u(L,{joinKeyGroups:y})},removeJoinKeyGroup:(L,A)=>{const F=r.joins.find(y=>y.id===L);if(!F)return;const I=[...F.joinKeyGroups];I.splice(A,1),u(L,{joinKeyGroups:I})},addJoinKey:(L,A)=>{const F=r.joins.find(T=>T.id===L);if(!F)return;const I=n.find(T=>T.name===F.source.name),y=n.find(T=>T.name===F.target.name),E=[...F.joinKeyGroups];E[A]||(E[A]=In());const M={id:`key-${Date.now()}`,source:{id:`source-${Date.now()}`,name:"",dataType:"",label:"",qualifiedFieldName:"",entityId:(I==null?void 0:I.name)||"",entityName:(I==null?void 0:I.name)||"",entityType:(I==null?void 0:I.type)||"table"},target:{id:`target-${Date.now()}`,name:"",dataType:"",label:"",qualifiedFieldName:"",entityId:(y==null?void 0:y.name)||"",entityName:(y==null?void 0:y.name)||"",entityType:(y==null?void 0:y.type)||"table"},operator:"="};E[A]={...E[A],keys:[...E[A].keys,M]},u(L,{joinKeyGroups:E})},updateJoinKey:(L,A,F,I,y)=>{const E=r.joins.find(V=>V.id===L);if(!E)return;const M=n.find(V=>V.name===E.source.name),T=n.find(V=>V.name===E.target.name),R=[...E.joinKeyGroups],C=R[A].keys[F];I==="sourceColumnName"&&M?R[A].keys[F]={...C,source:{...C.source,name:y}}:I==="targetColumnName"&&T?R[A].keys[F]={...C,target:{...C.target,name:y}}:I==="operator"&&(R[A].keys[F]={...C,operator:y}),u(L,{joinKeyGroups:R})},removeJoinKey:(L,A,F)=>{const I=r.joins.find(E=>E.id===L);if(!I)return;const y=[...I.joinKeyGroups];y[A].keys.splice(F,1),u(L,{joinKeyGroups:y})},generateSQLPreview:()=>{const L=[...r.joins].sort((I,y)=>I.sequence-y.sequence),A=r.baseEntity;if(!A.name)return"SELECT * FROM table -- Please select a base entity";let F=`SELECT *
|
|
142
|
+
FROM ${A.name}`;return L.forEach(I=>{const y=n.find(T=>T.name===I.target.name);if(!y)return;const E=I.joinKeyGroups.filter(T=>T.keys&&T.keys.length>0).map(T=>{const R=T.keys.filter(C=>{var V,P,O,B;return((V=C.source)==null?void 0:V.name)&&((P=C.target)==null?void 0:P.name)&&((O=C.source)==null?void 0:O.entityName)&&((B=C.target)==null?void 0:B.entityName)}).map(C=>`${C.source.entityName}.${C.source.name} ${C.operator} ${C.target.entityName}.${C.target.name}`);return R.length>1?`(${R.join(` ${T.operator} `)})`:R[0]}).filter(Boolean),M=E.length>1?E.join(" OR "):E[0]||"condition_here";F+=`
|
|
143
|
+
${I.joinType} JOIN ${y.name}
|
|
144
|
+
ON ${M}`}),F},isValidConfiguration:()=>!(!r.baseEntity.name||r.joins.some(I=>!I.source.name||!I.target.name)||r.joins.some(I=>I.joinKeyGroups.some(y=>y.keys.length===0))||r.joins.some(I=>I.joinKeyGroups.some(y=>y.keys.some(E=>!E.source.name||!E.target.name||!E.operator))))}}const Vr=[{value:"LEFT",label:"Keep rows without a match"},{value:"INNER",label:"Only matching rows"},{value:"RIGHT",label:"Keep all target rows"},{value:"FULL",label:"Keep all rows"}],_r={one_to_one:"One to one",one_to_many:"One to many",many_to_one:"Many to one",many_to_many:"Many to many"},Yr={one_to_one:"1 : 1",one_to_many:"1 : N",many_to_one:"N : 1",many_to_many:"N : N"},zr=["=","<",">","<=",">="];function qr({joinPlan:s,availableDataSources:n,onSave:r,onRemove:o,onCancel:i}){const{columnGroups:d}=a.useColumns(),c=d.filter(O=>O.entityName!==ye.CALCULATED_FIELDS_GROUP_NAME),{joinPlan:l,expandedJoins:u,setJoinPlan:x,addJoin:m,removeJoin:b,updateJoin:h,moveJoinUp:p,moveJoinDown:j,toggleJoinExpansion:N,getAvailableSourceEntities:f,getAvailableTargetEntities:g,addJoinKeyGroup:k,updateGroupOperator:D,removeJoinKeyGroup:w,addJoinKey:S,updateJoinKey:L,removeJoinKey:A,generateSQLPreview:F,isValidConfiguration:I}=Br({initialJoinPlan:s,availableDataSources:n}),[y,E]=v.useState(new Set),[M,T]=v.useState(!1),R=O=>{const B=c.find(_=>_.entityName===O);return(B==null?void 0:B.columns)||[]},C=O=>E(B=>{const _=new Set(B);return _.has(O)?_.delete(O):_.add(O),_}),V=[];l.baseEntity.name&&V.push(l.baseEntity.name);for(const O of[...l.joins].sort((B,_)=>B.sequence-_.sequence))O.target.name&&!V.includes(O.target.name)&&V.push(O.target.name);const P=O=>{const B=O.joinKeyGroups.flatMap(q=>q.keys),_=B.find(q=>{var Y,$;return((Y=q.source)==null?void 0:Y.name)&&(($=q.target)==null?void 0:$.name)});if(!_)return null;const z=B.length>1?` +${B.length-1}`:"";return`${_.source.name} ${_.operator||"="} ${_.target.name}${z}`};return e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Start from"}),e.jsxs(t.Select,{value:l.baseEntity.name,onValueChange:O=>{const B=n.find(_=>_.name===O);x({...l,baseEntity:{connectionId:(B==null?void 0:B.connectionId)||"",connectionType:(B==null?void 0:B.connectionType)||"none",type:(B==null?void 0:B.type)||"table",name:O,database:B==null?void 0:B.database,schema:B==null?void 0:B.schema}})},children:[e.jsx(t.SelectTrigger,{className:"h-8 text-[12px]",children:e.jsx(t.SelectValue,{placeholder:"Select the dataset to start from..."})}),e.jsx(t.SelectContent,{children:n.map(O=>e.jsx(t.SelectItem,{value:O.name,className:"text-[12px]",children:O.name},O.name))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Every other dataset connects back to this one."})]}),V.length>0&&e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Join path"}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:V.map((O,B)=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[B>0&&e.jsx(a.ArrowRight,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:`inline-flex max-w-[220px] items-center gap-1.5 rounded-[4px] border px-2 py-1 leading-none ${B===0?"border-border bg-muted font-medium text-foreground":"border-border/60 text-muted-foreground"}`,children:[e.jsx(a.Database,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 truncate text-[11.5px] leading-none",children:O}),B===0&&e.jsx("span",{className:"shrink-0 text-[9.5px] uppercase leading-none tracking-[0.06em] text-muted-foreground",children:"BASE"})]})]},O))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["How datasets connect (",l.joins.length,")"]}),e.jsxs(t.Button,{variant:"outline",size:"xs",className:"gap-1.5",onClick:m,children:[e.jsx(a.Plus,{className:"h-3.5 w-3.5"}),"Add join"]})]}),l.joins.length===0?e.jsxs("div",{className:"rounded-[6px] border border-dashed border-border px-4 py-8 text-center",children:[e.jsx("p",{className:"text-[12.5px] font-medium text-foreground",children:"No joins yet"}),e.jsxs("p",{className:"mx-auto mt-1 max-w-[360px] text-[11.5px] leading-relaxed text-muted-foreground",children:["Add a join to connect another dataset to"," ",l.baseEntity.name||"your base dataset","."]})]}):e.jsx("div",{className:"max-h-[340px] space-y-1.5 overflow-y-auto",children:l.joins.map(O=>{var Q;const B=n.find(U=>U.name===O.source.name),_=n.find(U=>U.name===O.target.name),z=u.has(O.id),q=y.has(O.id)||O.joinKeyGroups.length>1||O.joinKeyGroups.some(U=>U.operator!=="AND"),Y=P(O),$=O.relationshipCardinality;return e.jsxs("div",{className:`rounded-[6px] border ${z?"border-border":"border-border/60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>N(O.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[z?e.jsx(le.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(qe.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium text-foreground",children:[e.jsx("span",{className:"truncate",children:O.source.name||"source"}),e.jsx(a.ArrowRight,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:O.target.name||"target"})]}),Y&&e.jsx("code",{className:"hidden max-w-[180px] shrink-0 truncate rounded-[4px] bg-muted px-1.5 py-0.5 font-mono text-[10.5px] text-muted-foreground lg:inline-block",children:Y})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>p(O.id),disabled:O.sequence===1,"aria-label":"Move join earlier",children:e.jsx($r,{})}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(O.id),disabled:O.sequence===l.joins.length,"aria-label":"Move join later",children:e.jsx(Kr,{})}),e.jsxs(t.Button,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-1.5 text-[11px] font-medium text-muted-foreground",onClick:()=>N(O.id),children:[e.jsx(a.Pencil,{className:"h-3 w-3"}),z?"Editing":"Edit"]}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground",onClick:()=>b(O.id),"aria-label":"Remove join",children:e.jsx(le.X,{className:"h-3.5 w-3.5"})})]})]}),z&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 pb-4 pt-3",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"From"}),e.jsxs(t.Select,{value:O.source.name,onValueChange:U=>{const J=n.find(X=>X.name===U);h(O.id,{source:{connectionId:(J==null?void 0:J.connectionId)||"",connectionType:(J==null?void 0:J.connectionType)||"none",type:(J==null?void 0:J.type)||"table",name:U,database:J==null?void 0:J.database,schema:J==null?void 0:J.schema}})},children:[e.jsx(t.SelectTrigger,{className:"h-8 text-[12px]",children:e.jsx(t.SelectValue,{placeholder:"Select source..."})}),e.jsx(t.SelectContent,{children:f(O.id).map(U=>e.jsx(t.SelectItem,{value:U.name,className:"text-[12px]",children:U.name},U.name))})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"To"}),e.jsxs(t.Select,{value:O.target.name,onValueChange:U=>{const J=n.find(X=>X.name===U);h(O.id,{target:{connectionId:(J==null?void 0:J.connectionId)||"",connectionType:(J==null?void 0:J.connectionType)||"none",type:(J==null?void 0:J.type)||"table",name:U,database:J==null?void 0:J.database,schema:J==null?void 0:J.schema}})},disabled:!O.source.name,children:[e.jsx(t.SelectTrigger,{className:"h-8 text-[12px]",children:e.jsx(t.SelectValue,{placeholder:"Select target..."})}),e.jsx(t.SelectContent,{children:O.source.name?g(O.source.name).map(U=>e.jsx(t.SelectItem,{value:U.name,className:"text-[12px]",children:U.name},U.name)):null})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"When a row has no match"}),e.jsxs(t.Select,{value:O.joinType,onValueChange:U=>h(O.id,{joinType:U}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-[12px]",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Vr.map(U=>e.jsx(t.SelectItem,{value:U.value,className:"text-[12px]",children:e.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:U.label}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] tracking-[0.04em] text-muted-foreground",children:U.value})]})},U.value))})]})]})]}),$&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-[5px] border border-border/60 bg-muted/40 px-2.5 py-1.5 text-[11.5px]",children:[e.jsx("span",{className:"shrink-0 rounded-[3px] bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:Yr[$]}),e.jsx("span",{className:"text-muted-foreground",children:_r[$]}),e.jsxs("span",{className:"truncate text-muted-foreground/70",children:["(",O.source.name||"source"," →"," ",O.target.name||"target",")"]})]}),O.source.name&&O.target.name&&B&&_&&e.jsx("div",{className:"space-y-2",children:q?e.jsx(Ur,{join:O,getColumnsForEntity:R,addJoinKey:S,addJoinKeyGroup:k,updateGroupOperator:D,removeJoinKeyGroup:w,updateJoinKey:L,removeJoinKey:A,canCollapse:O.joinKeyGroups.length<=1&&O.joinKeyGroups.every(U=>U.operator==="AND"),onCollapse:()=>C(O.id)}):e.jsxs(e.Fragment,{children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Match on"}),(Q=O.joinKeyGroups[0])!=null&&Q.keys.length?e.jsx("div",{className:"min-w-0 space-y-1.5",children:O.joinKeyGroups[0].keys.map((U,J)=>e.jsx(aa,{join:O,groupIndex:0,keyIndex:J,conditionKey:U,getColumnsForEntity:R,updateJoinKey:L,removeJoinKey:A,showRemove:O.joinKeyGroups[0].keys.length>1},U.id||J))}):e.jsx("p",{className:"rounded-[5px] border border-border/60 px-3 py-2 text-[11.5px] text-muted-foreground",children:"No match condition yet. Add one to define how these connect."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",className:"gap-1.5",onClick:()=>S(O.id,0),children:[e.jsx(a.Plus,{className:"h-3 w-3"})," Add condition"]}),e.jsxs("button",{type:"button",onClick:()=>C(O.id),className:"inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground hover:text-foreground",children:[e.jsx(a.Settings2,{className:"h-3 w-3"}),"Advanced"]})]})]})})]})]},O.id)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>T(O=>!O),className:"inline-flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground",children:[M?e.jsx(le.ChevronDown,{className:"h-3 w-3"}):e.jsx(qe.ChevronRight,{className:"h-3 w-3"}),"View SQL"]}),M&&e.jsx("div",{className:"rounded-[5px] border border-border/60 bg-muted/40 p-3",children:e.jsx("code",{className:"block whitespace-pre-wrap break-all font-mono text-[11px] text-muted-foreground",children:F()})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border pt-4",children:[e.jsxs(t.Button,{variant:"ghost",size:"xs",className:"gap-1.5 text-muted-foreground",onClick:()=>{o(),i()},children:[e.jsx(a.Trash2,{className:"h-3.5 w-3.5"}),"Remove all"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"outline",size:"xs",onClick:i,children:"Cancel"}),e.jsxs(t.Button,{size:"xs",className:"gap-1.5",onClick:()=>r(l),disabled:!I(),children:["Save joins",e.jsx(a.ArrowRight,{className:"h-3.5 w-3.5"})]})]})]})]})}function $r(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m18 15-6-6-6 6"})})}function Kr(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}function aa({join:s,groupIndex:n,keyIndex:r,conditionKey:o,getColumnsForEntity:i,updateJoinKey:d,removeJoinKey:c,showRemove:l,showOperator:u=!1}){const x=u||(o.operator||"=")!=="=";return e.jsxs("div",{className:"flex items-center gap-2 rounded-[5px] border border-border/60 p-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs(t.Select,{value:o.source.name,onValueChange:m=>d(s.id,n,r,"sourceColumnName",m),children:[e.jsx(t.SelectTrigger,{className:"h-7 font-mono text-[11px]",children:e.jsx(t.SelectValue,{placeholder:"Source column"})}),e.jsx(t.SelectContent,{children:i(s.source.name).map(m=>e.jsx(t.SelectItem,{value:m.name,children:e.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{className:"font-mono",children:m.name}),m.dataType&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:m.dataType})]})},m.name))})]})}),x?e.jsx("div",{className:"w-16 shrink-0",children:e.jsxs(t.Select,{value:o.operator,onValueChange:m=>d(s.id,n,r,"operator",m),children:[e.jsx(t.SelectTrigger,{className:"h-7 justify-center px-1 font-mono text-[11px]",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:zr.map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))})]})}):e.jsx("span",{className:"shrink-0 px-1 font-mono text-[12px] text-muted-foreground",children:"="}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs(t.Select,{value:o.target.name,onValueChange:m=>d(s.id,n,r,"targetColumnName",m),children:[e.jsx(t.SelectTrigger,{className:"h-7 font-mono text-[11px]",children:e.jsx(t.SelectValue,{placeholder:"Target column"})}),e.jsx(t.SelectContent,{children:i(s.target.name).map(m=>e.jsx(t.SelectItem,{value:m.name,children:e.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{className:"font-mono",children:m.name}),m.dataType&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:m.dataType})]})},m.name))})]})}),l&&e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>c(s.id,n,r),"aria-label":"Remove condition",children:e.jsx(le.X,{className:"h-3.5 w-3.5"})})]})}function Ur({join:s,getColumnsForEntity:n,addJoinKey:r,addJoinKeyGroup:o,updateGroupOperator:i,removeJoinKeyGroup:d,updateJoinKey:c,removeJoinKey:l,canCollapse:u,onCollapse:x}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(t.Label,{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(a.Settings2,{className:"h-3 w-3"}),"Advanced conditions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("button",{type:"button",onClick:x,className:"text-[11px] font-medium text-muted-foreground hover:text-foreground",children:"Use simple"}),e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",className:"gap-1.5",onClick:()=>o(s.id),children:[e.jsx(a.Plus,{className:"h-3 w-3"})," Add OR group"]})]})]}),s.joinKeyGroups.map((m,b)=>e.jsxs("div",{className:"space-y-2 rounded-[5px] border border-border/60 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11px] font-medium text-foreground",children:["Group ",b+1]}),b>0&&e.jsx("span",{className:"rounded-[3px] bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"OR with previous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:"within group"}),e.jsxs(t.Select,{value:m.operator,onValueChange:h=>i(s.id,b,h),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-[76px] text-[11px]",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"AND",children:"AND"}),e.jsx(t.SelectItem,{value:"OR",children:"OR"})]})]}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground",onClick:()=>d(s.id,b),"aria-label":"Remove group",children:e.jsx(a.Trash2,{className:"h-3.5 w-3.5"})})]})]}),m.keys.length===0?e.jsx("p",{className:"rounded-[5px] border border-dashed border-border/60 px-3 py-2 text-center text-[11.5px] text-muted-foreground",children:"No conditions in this group."}):e.jsx("div",{className:"min-w-0 space-y-1.5",children:m.keys.map((h,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[p>0&&e.jsx("span",{className:"w-9 shrink-0 text-center text-[10px] font-medium text-muted-foreground",children:m.operator}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(aa,{join:s,groupIndex:b,keyIndex:p,conditionKey:h,getColumnsForEntity:n,updateJoinKey:c,removeJoinKey:l,showRemove:!0,showOperator:!0})})]},h.id||p))}),e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",className:"gap-1.5",onClick:()=>r(s.id,b),children:[e.jsx(a.Plus,{className:"h-3 w-3"})," Add condition"]})]},m.id))]})}function ra({children:s,open:n,onOpenChange:r,joinPlan:o,availableDataSources:i,onRemove:d,onSave:c,onCancel:l}){return e.jsxs(a.Dialog,{open:n,onOpenChange:r,children:[e.jsxs(a.DialogContent,{className:"max-h-[88vh] w-[calc(100vw-2rem)] max-w-4xl overflow-y-auto overflow-x-hidden",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"How datasets connect"}),e.jsx(a.DialogDescription,{className:"text-[12px] text-muted-foreground",children:"Datasets joined together so a card can use fields from all of them."})]}),e.jsx(qr,{joinPlan:o,availableDataSources:i,onSave:c,onCancel:l,onRemove:d})]}),s]})}function Gr({joins:s,baseEntityId:n,availableDataSources:r,generateSQLPreview:o}){return e.jsxs("div",{className:"my-2 max-h-[400px] divide-y divide-border overflow-y-auto",children:[s.length>0&&e.jsxs("div",{className:"px-4 py-2",children:[e.jsx("h3",{className:"mb-3 text-left font-semibold",children:"Join Chain"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:(()=>{const i=[...s].sort((c,l)=>c.sequence-l.sequence),d=r.find(c=>c.name===n);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(a.Badge,{variant:"secondary",className:"text-xs",children:d==null?void 0:d.type}),e.jsx("span",{className:"text-xs font-medium",children:d==null?void 0:d.name}),e.jsx(a.Badge,{variant:"outline",className:"text-xs text-green-600",children:"BASE"})]}),i.map(c=>{const l=r.find(u=>u.name===c.target.name);return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"mx-1 flex items-center gap-1",children:[e.jsx(a.Badge,{variant:"outline",className:"text-xs",children:c.joinType}),e.jsx("span",{className:"text-muted-foreground",children:"→"})]}),e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(a.Badge,{variant:"secondary",className:"text-xs",children:l==null?void 0:l.type}),e.jsx("span",{className:"text-xs font-medium",children:l==null?void 0:l.name})]})]},c.id)})]})})()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"mb-3 text-left text-sm font-medium",children:["Configured Joins (",s.length,")"]}),e.jsx("div",{className:"space-y-2",children:[...s].sort((i,d)=>i.sequence-d.sequence).map((i,d)=>{const c=r.find(x=>x.name===i.source.name),l=r.find(x=>x.name===i.target.name),u=i.joinKeyGroups.reduce((x,m)=>x+m.keys.length,0);return e.jsxs("div",{className:"rounded-md bg-muted p-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Badge,{variant:"secondary",className:"shrink-0 text-xs",children:d+1}),e.jsx(a.Badge,{variant:"outline",className:"shrink-0 text-xs",children:i.joinType}),e.jsxs(a.Badge,{variant:"outline",className:"ml-auto shrink-0 text-xs",children:[u," condition",u>1?"s":""]})]}),e.jsxs("div",{className:"mt-1 truncate pl-1 text-xs text-muted-foreground",children:[c==null?void 0:c.name," → ",l==null?void 0:l.name]})]},i.id)})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"mb-3 text-left text-sm font-medium",children:"SQL Query"}),e.jsx("div",{className:"overflow-x-auto rounded-md border bg-muted p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-left font-mono text-xs text-muted-foreground",children:o()})})]})]})}function Hr({open:s,onOpenChange:n,variant:r="button"}={}){var k;const o=t.useEditorStore(D=>D.card),{autoJoinMetadata:i}=a.useEditorCardQuery(o),d=t.useEditorStore(D=>D.actions.updateCardConfig),c=ye.getAuthoredCardJoinPlan(o)||{baseEntity:{type:"table",name:"",database:"",schema:"",connectionId:"",connectionType:"none",dialect:"none"},joins:[]},[l,u]=v.useState(!1),x=s!==void 0,m=x?s:l,b=x?n:u,h=((k=o==null?void 0:o.dataSource)==null?void 0:k.selectedEntities)||[],p=D=>{d(o.id,ye.withAuthoredCardJoinPlan(o,D)),b(!1)},j=()=>{d(o.id,ye.withAuthoredCardJoinPlan(o,void 0))},N=()=>{b(!1)},f=()=>{const D=[...c.joins].sort((L,A)=>L.sequence-A.sequence),w=c.baseEntity;if(!w.name)return"SELECT * FROM table -- Please select a base entity";let S=`SELECT *
|
|
145
|
+
FROM ${w.name}`;return D.forEach(L=>{const A=h.find(y=>y.name===L.target.name);if(!A)return;const F=L.joinKeyGroups.filter(y=>y.keys&&y.keys.length>0).map(y=>{const E=y.keys.filter(M=>{var T,R,C,V;return((T=M.source)==null?void 0:T.name)&&((R=M.target)==null?void 0:R.name)&&((C=M.source)==null?void 0:C.entityName)&&((V=M.target)==null?void 0:V.entityName)}).map(M=>`${M.source.entityName}.${M.source.name} ${M.operator} ${M.target.entityName}.${M.target.name}`);return E.length>1?`(${E.join(` ${y.operator} `)})`:E[0]}).filter(Boolean),I=F.length>1?F.join(" OR "):F[0]||"condition_here";S+=`
|
|
146
|
+
${L.joinType} JOIN ${A.name}
|
|
147
|
+
ON ${I}`}),S};if(h.length<2)return null;const g=c.joins.length>0&&e.jsx(t.TooltipContent,{side:"bottom",className:"ml-4 max-w-md overflow-hidden p-0",children:e.jsx(Gr,{joins:c.joins,baseEntityId:c.baseEntity.name,availableDataSources:h,generateSQLPreview:f})});return e.jsxs(e.Fragment,{children:[e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:r==="badge"?e.jsxs(a.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:D=>{D.stopPropagation(),b(!0)},children:[e.jsx(a.Link,{className:"h-3 w-3"}),c.joins.length]}):e.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex h-7 w-full items-center gap-2 rounded-control border border-input bg-background px-2 text-left transition-colors hover:bg-muted focus:outline-none focus-visible:border-ring",children:[e.jsx(a.Link,{className:"h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:c.joins.length===0?"Configure joins":`${c.joins.length} ${c.joins.length===1?"join":"joins"}`}),(i==null?void 0:i.autoResolved)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx(a.Sparkles,{className:"h-3 w-3",strokeWidth:1.75}),"Auto"]})]})}),g]})}),e.jsx(ra,{open:m,onOpenChange:b,joinPlan:c,availableDataSources:h,onSave:p,onCancel:N,onRemove:j,children:e.jsx("div",{})})]})}function Qr(){var V,P,O,B;const[s,n]=v.useState(!1),[r,o]=v.useState(!1),[i,d]=v.useState(!1),c=t.useEditorStore(_=>_.card.dataSource),l=t.useEditorStore(_=>_.card),u=t.useEditorStore(_=>_.isDevMode),{updateCardConfig:x,updateDataSource:m}=t.useEditorActions(),{autoJoinMetadata:b}=a.useEditorCardQuery(l),{semanticDomains:h}=a.useSemanticDomains(),p=v.useMemo(()=>new Map(h.map(_=>[_.id,_.label||_.name])),[h]),N={...{connectionId:"",connectionType:"",mode:"database",selectedEntities:[]},...c,selectedEntities:(c==null?void 0:c.selectedEntities)||[]},f=a.toEntityArray(N.selectedEntities),g=f.length,k=a.useFieldAvailabilityContext(l),D=v.useMemo(()=>t.getAuthoredCardFieldList(l),[l]),w=v.useMemo(()=>a.describeDataSourceConnections({...k,selectedFields:D,dataSourceEntities:f}),[k,D,f]),S=g===0?"Choose dataset":g===1?Jr(f[0],p):`${g} datasets`,L=ye.getAuthoredCardJoinPlan(l),A=((V=L==null?void 0:L.joins)==null?void 0:V.length)??0,F=Ze.findOrphanedJoinPlanEntities(L,f),I=F.length>0,y=!u&&(g>1||A>0),E=!!(b!=null&&b.autoResolved);((O=(P=b==null?void 0:b.resolvedJoinPlan)==null?void 0:P.joins)==null?void 0:O.length)??((B=b==null?void 0:b.relationshipsUsed)==null||B.length);const M=A>0?`${A} join${A===1?"":"s"}`:g<2?null:E?"auto":null,T=_=>{const z=f.filter(q=>!a.areContextEntitiesEqual(q,_));l&&Ze.findOrphanedJoinPlanEntities(L,z).length>0&&x(l.id,ye.withAuthoredCardJoinPlan(l,void 0)),m({...N,...N.mode==="semanticDomain"?{semanticDomainId:a.inferSemanticDomainIdFromSelectedEntities(z)}:{},selectedEntities:z})},R=()=>{l&&x(l.id,ye.withAuthoredCardJoinPlan(l,void 0))},C=()=>{m({...N,selectedEntities:a.dedupeContextEntities([...f,...F])})};return e.jsxs(e.Fragment,{children:[e.jsxs(t.Popover,{open:s,onOpenChange:n,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex h-7 w-full items-center gap-2 rounded-control border border-input bg-background px-2 text-left transition-colors hover:bg-muted focus:outline-none focus-visible:border-ring",children:[e.jsx(a.Database,{className:"h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:S}),M&&e.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",M]}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",s&&"rotate-180")})]})}),e.jsx(t.PopoverContent,{align:"start",sideOffset:4,className:"w-[320px] overflow-hidden rounded-control border border-border bg-popover p-0 shadow-[0_4px_16px_rgba(0,0,0,0.08)]",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 pb-1.5 pt-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Datasets"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground/70",children:g})]}),g===0?e.jsx("div",{className:"px-3 pb-2 text-[12px] text-muted-foreground",children:"No datasets selected."}):e.jsx("ul",{className:"mb-1",children:f.map((_,z)=>{const q=w[z],$=(q?a.isBlockedFieldState(q.state):!1)?a.getFieldStateCopy(q==null?void 0:q.state).tag:null;return e.jsxs("li",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-muted/50",children:[e.jsx(a.Database,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[13px] text-foreground",children:ks(_)}),e.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:Xr(_,p)}),$&&q&&e.jsx("p",{title:[q.reason,q.action].filter(Boolean).join(" "),className:"text-[10px] font-medium leading-[1.4] text-destructive",children:$})]}),e.jsx("button",{type:"button",onClick:()=>T(_),"aria-label":`Remove ${Wr(_,p)}`,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:e.jsx(le.X,{className:"h-3 w-3"})})]},`${_.connectionId}-${_.name}-${z}`)})}),e.jsxs("button",{type:"button",onClick:()=>{n(!1),o(!0)},className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-[12px] text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx(a.Plus,{className:"h-3 w-3"}),"Add dataset"]})]}),y&&e.jsxs("div",{className:"border-t border-border/60 px-3 py-2.5",children:[e.jsx("div",{className:"mb-1.5 flex items-center justify-between",children:e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Join"})}),I?e.jsxs("div",{className:"space-y-2 rounded-control border border-amber-300/70 bg-amber-50/70 p-2.5 text-[11px] text-amber-950 dark:border-amber-700/70 dark:bg-amber-950/20 dark:text-amber-100",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.TriangleAlert,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium",children:[A," saved"," ",A===1?"join":"joins"," need attention"]}),e.jsxs("p",{className:"mt-0.5 leading-relaxed text-amber-900/80 dark:text-amber-100/80",children:[F.map(_=>_.name).join(", ")," ","is no longer selected, but the saved join still affects this card."]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:R,className:"rounded-control border border-amber-500/60 bg-background px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-amber-100 dark:bg-background dark:hover:bg-amber-950/60",children:"Remove saved join"}),e.jsx("button",{type:"button",onClick:C,className:"rounded-control px-1 py-1 text-[11px] font-medium text-amber-900 transition-colors hover:underline dark:text-amber-100",children:"Re-add dataset"})]})]}):e.jsxs("button",{type:"button",onClick:()=>{n(!1),d(!0)},className:"flex h-7 w-full items-center gap-2 rounded-control border border-input bg-background px-2 text-left transition-colors hover:bg-muted focus:outline-none focus-visible:border-ring",children:[e.jsx(a.Link,{className:"h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:A>0?`${A} ${A===1?"join":"joins"}`:"Configure joins"}),E&&A===0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx(a.Sparkles,{className:"h-3 w-3",strokeWidth:1.75}),"Auto"]})]})]}),e.jsx("div",{className:"flex items-center justify-end border-t border-border/60 px-2 py-1.5",children:e.jsx("button",{type:"button",onClick:()=>n(!1),className:"inline-flex h-6 items-center rounded-control px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Done"})})]})})]}),e.jsx(a.AddDataPicker,{incomingSelectedEntities:(c==null?void 0:c.selectedEntities)||[],dialogMode:"dataSource",open:r,onOpenChange:o,dataSource:N}),y&&!I&&e.jsx("div",{className:"hidden",children:e.jsx(Hr,{open:i,onOpenChange:d})})]})}function ks(s){return"label"in s&&s.label?s.label:s.name||"Dataset"}function Jr(s,n){const r=ks(s),o=a.getSemanticDomainLabel(s,n);return o?`${r} · ${o}`:r}function Wr(s,n){const r=ks(s),o=a.getSemanticDomainLabel(s,n);return o?`${r} from ${o}`:r}function Xr(s,n){const r=a.getSemanticDomainLabel(s,n);if(r)return r;const o=[];return s.connectionType&&o.push(String(s.connectionType)),s.database&&o.push(s.database),s.schema&&o.push(s.schema),o.join(" · ")}function oa({isVisible:s}){gt.useSyncLegacyEditorState();const[n,r]=v.useState(!1);return e.jsxs("div",{className:t.cn("flex shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-all duration-300 ease-in-out",{"w-[290px]":s,"min-w-[290px]":s,"w-0 border-r-0":!s,"min-w-0":!s}),children:[e.jsx("div",{className:"px-4 pt-4",children:e.jsx(Qr,{})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(a.FieldsSection,{})}),e.jsx(Or,{open:n,onOpenChange:r})]})}function Zr(s){const{request:n,mode:r="draft",currentSql:o,selectedTableName:i,selectedSchemaName:d,selectedDatabaseName:c}=s,l=[c?`Database: ${c}`:"",d?`Schema: ${d}`:"",i?`Table: ${i}`:""].filter(Boolean);return["You are an expert SQL writing assistant embedded in a query editor.",`Write SQL only. You may call only read-only tools when needed: ${a.INLINE_ALLOWED_TOOL_LIST}.`,"Do not call mutation tools or chart-creation tools; those require Full Assistant.","Return exactly one SQL statement inside a single ```sql fenced block.","After the code block, optionally include one short sentence.",r==="refine"&&o?"Mode: Refine existing SQL. Keep the current query structure and only apply the requested changes unless the current query is invalid.":"Mode: Draft new SQL from the request.",l.length>0?`Context:
|
|
148
|
+
${l.join(`
|
|
149
|
+
`)}`:"",o?r==="refine"?`Current SQL (must refine):
|
|
150
|
+
${o}`:`Current SQL (revise if useful):
|
|
151
|
+
${o}`:"",`User request:
|
|
152
|
+
${n}`].filter(Boolean).join(`
|
|
153
|
+
|
|
154
|
+
`)}function eo(s){const{request:n,failedSql:r,errorMessage:o,errorCode:i,selectedDatabaseName:d,selectedSchemaName:c,selectedTableName:l,contextEntityLabels:u}=s,x=[d?`Database: ${d}`:"",c?`Schema: ${c}`:"",l?`Table: ${l}`:"",u.length>0?`Selected context entities: ${u.join(", ")}`:""].filter(Boolean);return["You are fixing SQL after validation failed.","Return one read-only SQL statement in a single ```sql fenced block.","Do not call mutation tools.",x.length>0?`Context:
|
|
155
|
+
${x.join(`
|
|
156
|
+
`)}`:"",`Original user request:
|
|
157
|
+
${n}`,`Previous SQL draft:
|
|
158
|
+
${r}`,`Validation failure${i?` (${i})`:""}:
|
|
159
|
+
${o}`].filter(Boolean).join(`
|
|
160
|
+
|
|
161
|
+
`)}function to(s,n){typeof window>"u"||window.dispatchEvent(new CustomEvent("semaphor:inline-query-writer",{detail:{event:s,...n,timestamp:Date.now()}}))}const ps={runId:0,phase:"idle",attempt:0,activeStep:"",timelineSteps:[],lastValidation:null,finalOutcome:"idle",hasTools:!1};function so(s){if(typeof s=="string"&&(s==="SQL_EMPTY"||s==="SQL_PARSE_ERROR"||s==="SQL_MULTI_STATEMENT"||s==="SQL_READ_ONLY_VIOLATION"||s==="SQL_EXPLAIN_ERROR"||s==="SQL_CONNECTION_ERROR"))return s}function Dn(s){let n=0;for(let r=0;r<s.length;r+=1)n=(n<<5)-n+s.charCodeAt(r),n|=0;return String(n)}function kn(s){return s==="getTableColumns"?"Discovering columns":s==="getDomainRelationships"?"Resolving relationships":s==="getChartSQLSyntax"?"Reviewing SQL syntax":s==="getUserSql"?"Inspecting current query":"Analyzing context"}function no(s,n){return s===a.SELF_HEAL_TIMELINE_STEP&&n>0?`${a.SELF_HEAL_TIMELINE_STEP} ${n}/${a.MAX_SELF_HEAL_ATTEMPTS}`:s}function es(s){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${s}-${crypto.randomUUID()}`:`${s}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Mn(s){var n;for(let r=s.length-1;r>=0;r-=1){const o=s[r];if(o.role!=="user")continue;const i=(n=o.metadata)==null?void 0:n.inlineRunToken;if(typeof i=="string"&&i.length>0)return i}}function ao(s){if(!s)return"";const n=s.trim(),r=s.match(/```sql\s*([\s\S]*?)```/i);if(r!=null&&r[1])return r[1].trim();const o=s.match(/```[\w-]*\s*([\s\S]*?)```/i);return o!=null&&o[1]?o[1].trim():/^(select|with|insert|update|delete)\b/i.test(n)?n:""}function An(s){for(let n=s.length-1;n>=0;n-=1){const r=s[n];if(!(r.role!=="assistant"||!Array.isArray(r.parts)))for(let o=r.parts.length-1;o>=0;o-=1){const i=r.parts[o];if((i==null?void 0:i.type)!=="text"||typeof(i==null?void 0:i.text)!="string")continue;const d=ao(i.text);if(d)return d}}return""}function ro({currentSql:s,currentPython:n,selectedDatabaseName:r,selectedSchemaName:o,selectedTableName:i,onApplySql:d,onOpenFullAssistant:c}){var lt,Qe;const{authToken:l,tokenProps:u}=a.useSemaphorContext(),x=(lt=a.useDashboardQuery().data)==null?void 0:lt.assistantProfileId,m=t.useEditorStore(H=>H.isDevMode),b=t.useEditorStore(H=>H.selectedConnectionId),h=t.useEditorStore(H=>{var ne;return(ne=H.card.dataSource)==null?void 0:ne.selectedEntities}),p=t.useAIInteractionStore(H=>H.currentAIContext.selectedEntities),j=p.length,{setCurrentAIContext:N}=t.useAIActions(),[f,g]=v.useState(""),[k,D]=v.useState(""),[w,S]=v.useState(""),[L,A]=v.useState("draft"),[F,I]=v.useState("draft"),[y,E]=v.useState(""),[M,T]=v.useState(!1),[R,C]=v.useState({status:"idle"}),[V,P]=v.useState(ps),[O,B]=v.useState(!1),[_,z]=v.useState(()=>es("inline-query-session")),q=v.useRef(null),Y=v.useRef(null),$=v.useRef(null),Q=v.useRef(0),U=v.useRef(0),J=v.useRef(es("inline-run-token")),X=v.useRef(_),ee=v.useRef(new Set),me=v.useRef(new Map),be=v.useRef(0),ve=v.useRef(""),je=v.useRef(!1),Re=v.useRef(!1),Pe=v.useRef(ps),Me=v.useRef(!1),Ee=v.useRef(null),Be=v.useRef(()=>{}),_e=(Qe=u.apiServiceUrl)==null?void 0:Qe.replace(/\/$/,""),Oe=_e?`${_e}/v1/sql/validate`:"/v1/sql/validate",Ae=v.useCallback(H=>{P(ne=>{const se=H(ne);return Pe.current=se,se})},[]),De=v.useCallback((H,ne)=>{Ae(se=>se.runId===H?ne(se):se)},[Ae]),ae=v.useCallback(H=>U.current===H&&!ee.current.has(H),[]),K=v.useCallback((H,ne,se)=>{De(H,Te=>{const ce=Te.timelineSteps.includes(ne)?Te.timelineSteps:[...Te.timelineSteps,ne];return{...Te,phase:(se==null?void 0:se.phase)||Te.phase,attempt:typeof(se==null?void 0:se.attempt)=="number"?se.attempt:Te.attempt,activeStep:ne,timelineSteps:ce,finalOutcome:(se==null?void 0:se.finalOutcome)||Te.finalOutcome,hasTools:se!=null&&se.hasTools?!0:Te.hasTools}})},[De]),ie=v.useCallback(()=>{const H=U.current+1,ne=es("inline-run-token"),se=es("inline-query-session");return U.current=H,J.current=ne,X.current=se,z(se),ee.current=new Set,me.current=new Map,be.current=0,ve.current="",Me.current=!1,Ae(()=>({runId:H,phase:"drafting",attempt:0,activeStep:"Drafting SQL",timelineSteps:["Drafting SQL"],lastValidation:null,finalOutcome:"drafting",hasTools:!1})),{runId:H,runToken:ne,chatSessionId:se}},[Ae]),Se=v.useCallback(()=>{if(je.current||Re.current||j>0)return;const H=h||[];if(H.length===0)return;const ne=t.useAIInteractionStore.getState().currentAIContext;N({...ne,selectedEntities:H}),Re.current=!0},[j,h,N]),re=v.useCallback(()=>{je.current=!0},[]),pe=v.useCallback((H,ne,se)=>{to(H,{runId:ne,attemptCount:typeof(se==null?void 0:se.attemptCount)=="number"?se.attemptCount:be.current,errorCode:se==null?void 0:se.errorCode,hasTools:typeof(se==null?void 0:se.hasTools)=="boolean"?se.hasTools:V.hasTools,entityCount:j,finalOutcome:(se==null?void 0:se.finalOutcome)||V.finalOutcome})},[j,V.finalOutcome,V.hasTools]),Ye=v.useCallback((H,ne)=>{const se=$.current;if(!se)return;const Te={inlineRunToken:ne};se({role:"user",parts:[{type:"text",text:H}],metadata:Te},{metadata:Te})},[]);v.useEffect(()=>{const H=Ee.current;!H||H.sessionId!==_||(Ee.current=null,Ye(H.message,H.runToken))},[_,Ye]);const Z=_,Fe=v.useCallback(async({toolCall:H})=>{var Ve,Ge,ht,it,Je,nt;if(Z!==X.current)return;const ne=String(H.toolName||"").trim();if(!ne)return;const se=U.current;if(!ae(se)){(Ve=Y.current)==null||Ve.call(Y,{tool:ne,toolCallId:H.toolCallId,output:{status:"error",message:"Inline run is no longer active; ignoring tool output."}});return}if(ne==="getUserSql"){K(se,kn(ne),{hasTools:!0}),pe("inline_tool_step",se,{hasTools:!0}),(Ge=Y.current)==null||Ge.call(Y,{tool:ne,toolCallId:H.toolCallId,output:{status:"success",sql:s||"",python:n||""}});return}const Te=a.INLINE_BLOCKED_MUTATING_TOOLS.has(ne),ce=a.INLINE_ALLOWED_READ_ONLY_TOOLS.has(ne);if(Te||!ce){(ht=Y.current)==null||ht.call(Y,{tool:ne,toolCallId:H.toolCallId,output:{status:"error",message:"This action is unavailable in inline draft mode. Open Full Assistant for this action."}});return}const ge=kn(ne);K(se,ge,{phase:V.phase==="self-healing"?"self-healing":"drafting",hasTools:!0}),pe("inline_tool_step",se,{hasTools:!0});const Ke=((it=H.input)==null?void 0:it.sql)??((Je=H.args)==null?void 0:Je.sql);typeof Ke=="string"&&Ke.trim().length>0&&(Me.current=!1,S(Ke.trim())),(nt=Y.current)==null||nt.call(Y,{tool:ne,toolCallId:H.toolCallId,output:{status:"success",message:"Read-only tool result received."}})},[n,s,pe,V.phase,ae,Z,K]),xe=v.useCallback(({message:H,messages:ne})=>{if(Z!==X.current)return;const se=Mn(ne);if(!se||se!==J.current)return;const Te=U.current;if(!ae(Te))return;const ce=An([H])||An(ne);if(ce){Me.current=!1,S(ce.trim());return}Me.current&&Pe.current.phase==="self-healing"&&Be.current(Te)},[ae,Z]),ze=v.useCallback(H=>{if(Z!==X.current)return;const ne=U.current;ae(ne)&&Me.current&&Pe.current.phase==="self-healing"&&Be.current(ne)},[ae,Z]),{setMessages:Le,sendMessage:$e,addToolResult:we,status:oe,stop:te,error:ue,clearError:Ce}=a.useChat({id:_,transport:new a.DefaultChatTransport({api:`${u.apiServiceUrl}/v1/assistant`,headers:()=>({Authorization:`Bearer ${l==null?void 0:l.accessToken}`}),body:()=>{const H=t.useAIInteractionStore.getState();return{assistantId:"editor-assistant",assistantProfileId:x,isDevMode:m,aiContext:H.currentAIContext,reasoningEffort:H.reasoningEffort,showReasoning:!1}},credentials:"omit",prepareSendMessagesRequest:({messages:H,body:ne,requestMetadata:se})=>{const Te=se==null?void 0:se.inlineRunToken,ce=Mn(H);return{body:{...ne,inlineRunToken:Te||ce,messages:t.cleanupIncompleteMessages(H)}}}}),onToolCall:Fe,onFinish:xe,onError:ze,sendAutomaticallyWhen:a.lastAssistantMessageIsCompleteWithToolCalls});Y.current=we,$.current=$e;const fe=!["ready","error"].includes(oe),He=(ue==null?void 0:ue.message)||"Unable to generate a SQL draft right now. Try again.",ke=v.useCallback(H=>{const ne=U.current,se=Pe.current.phase;if(!(se==="drafting"||se==="self-healing"||se==="validating")){H==="stopped"&&fe&&te();return}ee.current.add(ne),Me.current=!1,Q.current+=1,ve.current="",C({status:"idle"}),S(""),Ce(),Le([]),De(ne,ce=>({...ce,phase:"idle",activeStep:"",finalOutcome:"cancelled"})),pe("inline_self_heal_stopped",ne,{finalOutcome:"cancelled"}),(fe||H==="stopped")&&te()},[Ce,pe,fe,Le,te,De]),bt=v.useCallback(async(H,ne)=>{var Te;if(!ae(ne))return null;const se=Q.current+1;Q.current=se,K(ne,"Validating SQL",{phase:"validating"}),C({status:"validating"});try{const ce=await t.postRequestRegular(Oe,(l==null?void 0:l.accessToken)||"",{sql:H,connectionId:b||void 0});if(Q.current!==se||!ae(ne))return null;if((ce==null?void 0:ce.valid)===!0)return C({status:"valid",message:"SQL validation passed."}),De(ne,Ve=>({...Ve,phase:"ready",finalOutcome:"validated",lastValidation:{valid:!0}})),pe("inline_draft_validated",ne,{finalOutcome:"validated"}),{status:"valid"};const ge=so(ce==null?void 0:ce.errorCode)||"UNKNOWN",Ke=typeof(ce==null?void 0:ce.error)=="string"&&ce.error||typeof((Te=ce==null?void 0:ce.details)==null?void 0:Te.error)=="string"&&ce.details.error||"SQL validation failed. Please revise the query draft.";return C({status:"invalid",message:Ke,errorCode:ge}),De(ne,Ve=>({...Ve,lastValidation:{valid:!1,error:Ke,errorCode:ge}})),pe("inline_validation_failed",ne,{errorCode:ge,finalOutcome:"validation_failed"}),{status:"invalid",error:Ke,errorCode:ge}}catch(ce){if(Q.current!==se||!ae(ne))return null;const ge=t.getRequestErrorMessage(ce,"Validation service unavailable. You can still replace and run.");return C({status:"error",message:ge,errorCode:"SQL_CONNECTION_ERROR"}),De(ne,Ke=>({...Ke,phase:"error",finalOutcome:"error",lastValidation:{valid:!1,error:ge,errorCode:"SQL_CONNECTION_ERROR"}})),{status:"error",error:ge,errorCode:"SQL_CONNECTION_ERROR"}}},[l==null?void 0:l.accessToken,pe,ae,b,Oe,De,K]),ut=v.useCallback((H,ne,se,Te)=>{let ce=se,ge="validation_failed",Ke="Validating SQL";ne==="attempt_limit"?(ce=`Couldn't auto-fix after ${a.MAX_SELF_HEAL_ATTEMPTS} attempts. ${se}`,ge="self_heal_exhausted",Ke=`Auto-fix stopped (${a.MAX_SELF_HEAL_ATTEMPTS} attempts)`):ne==="duplicate"&&(ce=`Auto-fix stopped (repeated validation failure). ${se}`,ge="self_heal_duplicate_stopped",Ke="Auto-fix stopped (repeated failure)"),C({status:"invalid",message:ce,errorCode:Te}),K(H,Ke,{phase:"error",finalOutcome:ge}),De(H,Ve=>({...Ve,phase:"error",finalOutcome:ge,lastValidation:{valid:!1,error:ce,errorCode:Te}})),ne!=="terminal"&&pe("inline_self_heal_stopped",H,{errorCode:Te,finalOutcome:ge}),Me.current=!1},[pe,De,K]),Ut=v.useCallback(H=>{const ne="Auto-fix stopped (no SQL returned). Open Full Assistant to continue.",se="self_heal_no_draft";C({status:"invalid",message:ne,errorCode:"UNKNOWN"}),K(H,"Auto-fix stopped (no SQL returned)",{phase:"error",finalOutcome:se}),De(H,Te=>({...Te,phase:"error",finalOutcome:se,lastValidation:{valid:!1,error:ne,errorCode:"UNKNOWN"}})),pe("inline_self_heal_stopped",H,{errorCode:"UNKNOWN",finalOutcome:se}),Me.current=!1},[pe,De,K]);Be.current=Ut,v.useEffect(()=>{const H=w.trim(),ne=U.current;if(!H){if(Q.current+=1,ve.current="",Pe.current.phase==="error")return;C({status:"idle"});return}if(!ae(ne)||fe)return;const se=`${ne}:${be.current}:${Dn(H)}`;if(ve.current===se)return;ve.current=se;let Te=!1;return(async()=>{const ge=await bt(H,ne);if(!ge||Te||!ae(ne)||ge.status!=="invalid")return;if(!a.RECOVERABLE_SQL_ERROR_CODES.has(ge.errorCode)){ut(ne,"terminal",ge.error,ge.errorCode);return}const Ke=`${Dn(H)}::${ge.errorCode}`,Ve=(me.current.get(Ke)||0)+1;if(me.current.set(Ke,Ve),Ve>=2){ut(ne,"duplicate",ge.error,ge.errorCode);return}if(be.current>=a.MAX_SELF_HEAL_ATTEMPTS){ut(ne,"attempt_limit",ge.error,ge.errorCode);return}const Ge=be.current+1;be.current=Ge,K(ne,a.SELF_HEAL_TIMELINE_STEP,{phase:"self-healing",attempt:Ge}),pe("inline_self_heal_attempt",ne,{attemptCount:Ge,errorCode:ge.errorCode}),Me.current=!0,Ce(),Le([]),S("");const ht=p.map(Je=>{const nt=Je!=null&&Je.database?`${Je.database}.`:"",ds=Je!=null&&Je.schema?`${Je.schema}.`:"",Xt=(Je==null?void 0:Je.name)||"unknown";return`${nt}${ds}${Xt}`}),it=eo({request:k,failedSql:H,errorMessage:ge.error,errorCode:ge.errorCode,selectedDatabaseName:r||"",selectedSchemaName:o||"",selectedTableName:i||"",contextEntityLabels:ht});Ye(it,J.current)})(),()=>{Te=!0}},[Ce,p,pe,fe,ae,k,w,r,o,i,Ye,Le,ut,K,bt]);const ot=(s==null?void 0:s.trim())||"",Dt=v.useCallback((H="draft")=>{if(fe)return;const ne=f.trim();if(!ne)return;const se=H==="refine"&&ot?"refine":"draft",Te=se==="refine"?ot:"",ce=ot,{runId:ge,runToken:Ke,chatSessionId:Ve}=ie();pe("inline_draft_started",ge,{attemptCount:0,hasTools:!1,finalOutcome:"drafting"}),Se(),Ce(),D(ne),S(""),A(se),E(Te),T(!1),C({status:"idle"}),Q.current+=1,Le([]),B(!0);const Ge=Zr({request:ne,mode:se,currentSql:ce,selectedTableName:i||"",selectedSchemaName:o||"",selectedDatabaseName:r||""});Ee.current={sessionId:Ve,message:Ge,runToken:Ke}},[ie,Ce,ot,pe,fe,f,Se,r,o,i,Le]),tt=v.useCallback(H=>{const ne=w.trim();ne&&(d(ne,H),H||B(!1))},[d,w]),jt=w.trim().length>0,Gt=["valid","invalid","error"].includes(R.status),ct=jt&&Gt,Ht=R.status==="invalid",mt=R.status==="validating",vt=jt&&k.length>0&&k===f.trim(),Ot=ot.length>0,kt=f.trim().length>0,Bt=vt&&L==="draft",yt=vt&&L==="refine"&&y===ot,xt=F==="refine"&&!Ot?"draft":F,Mt=(xt==="refine"?yt:Bt)?"Open composer preview":"Generate composer SQL",Jt=f.trim().length>0||k.trim().length>0||jt||R.status!=="idle"||V.timelineSteps.length>0,dt=v.useCallback((H="draft")=>{if(fe)return;if((H==="refine"?yt:Bt)&&!O){Se(),B(!0);return}Dt(H)},[Bt,yt,Dt,fe,O,Se]),Ct=v.useCallback(()=>{Se(),B(!0)},[Se]),At=v.useCallback(H=>{ke("cancelled"),g(H)},[ke]),Vt=v.useCallback(()=>{fe||(ke("cancelled"),Me.current=!1,Q.current+=1,ve.current="",be.current=0,g(""),D(""),S(""),A("draft"),I("draft"),E(""),T(!1),C({status:"idle"}),Ce(),Le([]),Ae(H=>({...ps,runId:H.runId})))},[ke,Ce,fe,Le,Ae]),is=v.useCallback(H=>{H||ke("cancelled"),B(H)},[ke]),Wt=V.timelineSteps.findIndex(H=>H===V.activeStep),cs=V.phase==="self-healing"?"Fixing validation issue":V.phase==="validating"?"Validating SQL":V.activeStep||"Drafting SQL",Nt=R.status==="valid"?{label:"Validation passed",className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700",detail:R.message}:R.status==="invalid"?{label:"Validation failed",className:"border-destructive/40 bg-destructive/10 text-destructive",detail:R.message}:R.status==="error"?{label:"Validation unavailable",className:"border-border/60 bg-muted/20 text-muted-foreground",detail:R.message}:null;return e.jsxs("div",{ref:q,className:"relative flex h-7 min-w-0 flex-1 items-center",children:[e.jsx(t.Input,{value:f,onChange:H=>At(H.target.value),onFocus:Ct,onClick:Ct,onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),dt(xt))},placeholder:"Ask AI to generate SQL…","aria-label":"Ask AI to generate SQL",className:["h-7 rounded-[5px] border border-border/60 bg-background pl-3 text-[12px] shadow-none placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-0",kt?"pr-[56px]":"pr-3"].join(" ")}),e.jsxs(t.Popover,{open:O,onOpenChange:is,children:[e.jsx(t.PopoverAnchor,{asChild:!0,children:e.jsx("div",{className:"pointer-events-none absolute inset-0"})}),e.jsxs("div",{className:"absolute right-1 flex items-center gap-1",children:[kt&&e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0",onClick:H=>{H.preventDefault(),ke("cancelled"),g("")},disabled:fe,"aria-label":"Clear input",title:"Clear input",children:e.jsx(le.X,{className:"size-3.5"})}),kt&&e.jsx(t.Button,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0",onClick:H=>{if(H.preventDefault(),fe){ke("stopped");return}dt(xt)},"aria-label":fe?"Stop AI generation":Mt,title:fe?"Stop AI generation":Mt,children:fe?e.jsx(a.Square,{className:"size-3 fill-current"}):e.jsx(a.SendHorizontal,{className:"size-3.5"})})]}),e.jsx(t.PopoverContent,{align:"start",alignOffset:0,side:"bottom",sideOffset:8,className:"w-[min(92vw,var(--radix-popover-trigger-width))] max-w-[760px] p-2.5",onOpenAutoFocus:H=>{H.preventDefault()},onInteractOutside:H=>{var se;const ne=H.target;ne&&((se=q.current)!=null&&se.contains(ne))&&H.preventDefault()},children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"inline-flex h-7 items-center rounded-[5px] border border-border/60 bg-background p-0.5",children:[e.jsx(t.Button,{type:"button",variant:"ghost",className:["h-6 rounded-[4px] px-2 text-[12px]",xt==="draft"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"].join(" "),onClick:()=>{I("draft"),T(!1)},children:"Draft New"}),e.jsx(t.Button,{type:"button",variant:"ghost",className:["h-6 rounded-[4px] px-2 text-[12px]",xt==="refine"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"].join(" "),onClick:()=>I("refine"),disabled:!Ot,children:"Refine"})]}),e.jsx(a.AssistantContextEntityControls,{mode:"full",compact:!0,inlineLayout:!0,inlineTriggerFirst:!0,triggerVariant:"outline",triggerIconOnly:!1,triggerLabel:"Context",onSelectionChange:re})]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[fe&&e.jsx(t.Button,{variant:"ghost",size:"xs",onClick:()=>{ke("stopped")},children:"Stop"}),!fe&&e.jsx(t.Button,{variant:"ghost",size:"xs",onClick:Vt,disabled:!Jt,children:"Clear"})]})]}),V.timelineSteps.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[V.timelineSteps.map((H,ne)=>{const se=H===V.activeStep&&["drafting","validating","self-healing"].includes(V.phase),Te=!se&&Wt>=0&&ne<Wt;return e.jsx("span",{className:["rounded-full border px-2 py-0.5 text-[11px]",se?"border-foreground/30 bg-foreground/10 text-foreground":Te?"border-border/60 bg-muted/20 text-muted-foreground":"border-border/50 bg-background text-muted-foreground/80"].join(" "),children:no(H,V.attempt)},`${H}-${ne}`)}),Nt&&e.jsx(t.TooltipProvider,{delayDuration:150,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:["rounded-full border px-2 py-0.5 text-[11px]",Nt.className].join(" "),children:Nt.label})}),e.jsx(t.TooltipContent,{side:"top",align:"start",className:"max-w-[680px] whitespace-pre-wrap break-words text-xs",children:Nt.detail})]})})]}),(fe||V.phase==="self-healing"||R.status==="validating")&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[e.jsx(t.LoaderCircle,{className:"size-3.5 animate-spin"}),cs]}),ue&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:He}),L==="refine"&&y&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-[5px] border border-border/60 bg-muted/20 px-2.5 py-1.5 text-[11px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Refining editor SQL"}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>T(H=>!H),children:M?"Hide base SQL":"View base SQL"})]}),M&&e.jsx("div",{className:"max-h-[120px] overflow-auto rounded-[5px] border border-border/60",children:e.jsx(t.CodeEditor,{value:y,onValueChange:()=>{},language:"sql",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Base SQL"})})]}),ct?e.jsxs("div",{className:"space-y-1",children:[L==="refine"&&e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Refined SQL"}),e.jsx("div",{className:"max-h-[200px] overflow-auto rounded-[5px] border border-border/60",children:e.jsx(t.CodeEditor,{value:w,onValueChange:()=>{},language:"sql",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Drafted SQL"})})]}):jt?e.jsx("div",{className:"rounded-[5px] border border-dashed border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:"Validating SQL draft before preview."}):!fe&&e.jsx("div",{className:"rounded-[5px] border border-dashed border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:Ot?"Choose Draft New or Refine Current, then press Enter or click send.":"Describe what you want to query, then press Enter or click send to generate a SQL preview."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx(t.Button,{variant:"outline",size:"xs",onClick:c,children:"Open Full Assistant"}),e.jsx(t.Button,{variant:"secondary",size:"xs",disabled:fe||!ct,onClick:()=>tt(!1),children:"Replace SQL"}),e.jsx(t.Button,{size:"xs",disabled:fe||!ct||mt||Ht,onClick:()=>tt(!0),children:"Replace & Run"})]})]})})]})]})}function oo({activeEditor:s,showPythonEditor:n,isRunning:r,sqlEditor:o,pythonEditor:i,onActiveEditorChange:d,onOpenChange:c,onRun:l}){const u=s??"sql";return e.jsx(a.Dialog,{open:s!==null,onOpenChange:c,children:e.jsx(a.DialogContent,{showCloseButton:!1,className:"flex h-[min(88vh,860px)] w-[min(1280px,calc(100vw-2rem))] max-w-none flex-col gap-0 overflow-hidden p-0",children:e.jsxs(t.Tabs,{value:u,onValueChange:x=>d(x),className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs(a.DialogHeader,{className:"flex-row items-center justify-between space-y-0 border-b border-border/60 px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[e.jsx(a.DialogTitle,{className:"shrink-0 text-sm",children:"Query editor"}),e.jsxs(t.TabsList,{size:"xs",children:[e.jsx(t.TabsTrigger,{value:"sql",children:"SQL"}),n?e.jsx(t.TabsTrigger,{value:"python",children:"Python"}):null]}),e.jsx(a.DialogDescription,{className:"sr-only",children:"Expanded SQL and Python query editor"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(t.Button,{type:"button",size:"xs",onClick:l,disabled:r,children:[r?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(a.Play,{className:"h-3.5 w-3.5"}),"Run"]}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!1),"aria-label":"Collapse query editor",title:"Collapse editor",children:e.jsx(qe.Minimize2,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(t.TabsContent,{value:"sql",forceMount:!0,className:"mt-0 min-h-0 flex-1 data-[state=inactive]:hidden",children:o}),n?e.jsx(t.TabsContent,{value:"python",forceMount:!0,className:"mt-0 min-h-0 flex-1 data-[state=inactive]:hidden",children:i}):null]})})})}function Ln(s,n){return s.current.cardId!==n&&(s.current={cardId:n,snapshots:{}}),s.current}function lo({cardId:s,expandedEditor:n,showPythonEditor:r}){const o=v.useRef(null),i=v.useRef(null),d=v.useRef(null),c=v.useRef(null),l=v.useRef({cardId:s,snapshots:{}}),u=v.useCallback(x=>{var N,f;const m=x==="inline"?o:d,b=x==="inline"?i:c,h=(N=m.current)==null?void 0:N.captureSession(),p=(f=b.current)==null?void 0:f.captureSession(),j=Ln(l,s);h&&(j.snapshots.sql=h),p&&(j.snapshots.python=p)},[s]);return v.useEffect(()=>{var j,N;const x=Ln(l,s),m=n===null?o:d,b=n===null?i:c,{sql:h,python:p}=x.snapshots;h&&((j=m.current)==null||j.restoreSession(h)),r&&p&&((N=b.current)==null||N.restoreSession(p))},[s,n,r]),{inlineSqlEditorRef:o,inlinePythonEditorRef:i,expandedSqlEditorRef:d,expandedPythonEditorRef:c,captureEditorSessions:u}}function io({value:s}){const[n,r]=v.useState(!1),o=v.useRef(null);v.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const i=async()=>{var d;try{if(!((d=navigator.clipboard)!=null&&d.writeText))throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(s),r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),1200)}catch{t.ue.error("Failed to copy")}};return e.jsxs("button",{type:"button","aria-label":`Copy ${s}`,onClick:i,className:"group inline-flex w-full cursor-pointer items-center justify-start rounded-[3px] bg-muted/35 px-2 py-1.5 text-left font-mono text-[11px] text-foreground transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{children:s}),n?e.jsx(t.Check,{"aria-hidden":"true",className:"ml-auto size-3.5 shrink-0 text-emerald-600/80 dark:text-emerald-400/80",strokeWidth:1.75}):e.jsx(a.Copy,{"aria-hidden":"true",className:"ml-auto size-3.5 shrink-0 text-muted-foreground/60 transition-colors group-hover:text-muted-foreground group-focus-visible:text-muted-foreground",strokeWidth:1.75}),e.jsx("span",{className:"sr-only","aria-live":"polite",children:n?"Copied to clipboard":""})]})}function co({hint:s}){const[n,r]=v.useState(!1),o=v.useRef(null),i=v.useRef(null),d=()=>{o.current&&(clearTimeout(o.current),o.current=null)},c=()=>{i.current&&(clearTimeout(i.current),i.current=null)};v.useEffect(()=>()=>{d(),c()},[]);const l=x=>{x.pointerType!=="touch"&&(c(),!n&&(d(),o.current=setTimeout(()=>r(!0),200)))},u=x=>{x.pointerType!=="touch"&&(d(),c(),i.current=setTimeout(()=>r(!1),150))};return e.jsxs(t.Popover,{open:n,onOpenChange:r,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{type:"button",variant:"ghost",size:"xs","aria-label":"Dashboard filters off",onPointerEnter:l,onPointerLeave:u,onFocus:()=>{d(),c(),r(!0)},className:"h-7 w-7 shrink-0 gap-1.5 border border-amber-300/60 bg-amber-50/60 px-0 text-amber-800 hover:bg-amber-100/70 hover:text-amber-900 @[1550px]:w-auto @[1550px]:px-2 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 dark:hover:bg-amber-500/15 dark:hover:text-amber-200",children:[e.jsx(gt.FilterX,{className:"h-3.5 w-3.5",strokeWidth:1.75}),e.jsx("span",{className:"hidden @[1550px]:inline",children:"Dashboard filters off"})]})}),e.jsxs(t.PopoverContent,{align:"start",collisionPadding:8,onPointerEnter:x=>{x.pointerType!=="touch"&&c()},onPointerLeave:u,onOpenAutoFocus:x=>x.preventDefault(),className:"w-72 space-y-2.5 p-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[13px] font-medium",children:"Dashboard filters aren’t applied"}),e.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:s.description})]}),e.jsx(io,{value:s.helper}),e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/filters",target:"_blank",rel:"noreferrer",className:"inline-flex text-[12px] font-medium text-foreground underline-offset-4 hover:underline",children:"Learn more ↗"})]})]})}function uo({renderCommandBarEnd:s}={}){var pe,Ye;const n=a.useQueryClient(),[r,o]=v.useState(!1),[i,d]=v.useState(!1),c=gt.useEditorClearAction(),[l,u]=v.useState(null),x=t.useEditorStore(Z=>Z.frame),m=t.useEditorStore(Z=>Z.card),{inlineSqlEditorRef:b,inlinePythonEditorRef:h,expandedSqlEditorRef:p,expandedPythonEditorRef:j,captureEditorSessions:N}=lo({cardId:m.id,expandedEditor:l,showPythonEditor:r});t.useEditorStore(Z=>Z.isShowingVisual),t.useEditorStore(Z=>Z.selectedConnectionId),t.useEditorStore(Z=>Z.tempQueryData);const f=t.useEditorStore(Z=>Z.selectedDatabaseName);t.useEditorStore(Z=>Z.selectedDatamodelId);const g=t.useEditorStore(Z=>Z.selectedSchemaName);t.useEditorStore(Z=>Z.showAIDialog);const k=t.useEditorStore(Z=>Z.selectedTableName),D=t.useDashboardStore(Z=>{var Fe,xe;return((xe=(Fe=Z.dashboard)==null?void 0:Fe.filters)==null?void 0:xe.length)??0}),w=t.useEditorStore(Z=>Z.inlineFilterValuesMap[(m==null?void 0:m.id)??""]),S=v.useMemo(()=>he.findCustomVisualConfigCard(x,m),[x,m]),{manifest:L}=a.useCustomVisual(((pe=S==null?void 0:S.customCardPreferences)==null?void 0:pe.url)||""),A=v.useMemo(()=>{var Z;return(Z=L==null?void 0:L.visuals)==null?void 0:Z.find(Fe=>{var xe;return Fe.name===((xe=S==null?void 0:S.customCardPreferences)==null?void 0:xe.componentName)})},[L,(Ye=S==null?void 0:S.customCardPreferences)==null?void 0:Ye.componentName]),F=he.resolveMultiInputType(S,A),I=v.useMemo(()=>he.getCustomVisualInputCards({frame:x,configCard:S,isMultiInputVisual:F==="multiple"}),[x,S,F]),y=v.useMemo(()=>{const Z=I.findIndex(Fe=>(Fe==null?void 0:Fe.id)===(m==null?void 0:m.id));return Z<0?-1:he.getSlotIndexForCard(m,Z)},[I,m]),E=v.useMemo(()=>!S||F!=="multiple"||y<0?m.type:he.getEffectiveCardTypeForSlot(m,y,A==null?void 0:A.slots)??m.type,[S,F,y,m,A==null?void 0:A.slots]),M=v.useMemo(()=>E!==m.type?{...m,type:E}:m,[m,E]),T=v.useMemo(()=>D===0?null:It.getDashboardFilterSubscriptionHint(m==null?void 0:m.sql),[m==null?void 0:m.sql,D]),R=v.useRef(!0),{setCardCustomCfg:C,setQueryResultColumns:V,setCardSql:P,setTempQueryData:O,setPythonStdOut:B,setCardPreferences:_,setCardType:z,setCardPython:q,setShowAIDialog:Y,setCard:$,updateCardInFrame:Q}=t.useEditorActions();t.useEditorStore(Z=>Z.onSave),t.useEditorStore(Z=>Z.onClose),t.useEditorStore(Z=>Z.actions.setSqlGen);const U=t.useEditorStore(Z=>Z.runSql),J=t.useEditorStore(Z=>Z.actions.setRunSql),X=t.useEditorStore(Z=>Z.actions.setIsSqlRunning),{data:ee,isLoading:me,isFetching:be,isSuccess:ve,isError:je,error:Re,errorSql:Pe,queryKey:Me,refetch:Ee,errorMessage:Be}=a.useEditorCardQuery(M),_e=v.useRef(Me);_e.current=Me,v.useEffect(()=>{if(ee)if(ee.rowLimitExceeded&&t.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),B((ee==null?void 0:ee.output)||""),ee.records.length>0){const{keys:Z}=a.getKeys(ee.records);V(m.type==="kpi"?a.getDisplayedKpiResultColumnKeys(ee.records).slice(0,1):Z,ee.columnKeyMap)}else V([])},[m.type,ee,V,B]),v.useEffect(()=>{(me||be)&&(X(!0),V([])),(je||ve)&&X(!1),je&&(V([]),B(""))},[me,be,ee,B,je,ve,X,V,Re]),v.useEffect(()=>{U&&(n.getQueryData(Me)||Ee(),J(!1))},[U,Ee,J,Me,n]);const Oe=v.useRef(Ee);Oe.current=Ee,v.useEffect(()=>{if(R.current){R.current=!1;return}Oe.current()},[w]);function Ae(Z,Fe){P(Z),Fe&&J(!0)}function De(){a.flushPendingEditorDrafts(),setTimeout(()=>{n.removeQueries({queryKey:_e.current,exact:!0}),J(!0)},0)}function ae(Z){a.flushPendingEditorDrafts(),N("inline"),u(Z)}function K(Z){a.flushPendingEditorDrafts(),N("expanded"),u(Z)}function ie(Z){Z||(a.flushPendingEditorDrafts(),N("expanded"),u(null))}function Se(){return e.jsxs(a.ResizablePanelGroup,{className:"flex grow gap-2",direction:"vertical",role:"editor-resizable-group",children:[e.jsx(a.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:e.jsx("div",{id:"sql-container",className:"relative flex w-full overflow-hidden bg-background",children:l===null?e.jsx(a.SqlEditor,{ref:b,onExpand:()=>ae("sql")},`inline-sql-${m.id}`):null})}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(a.PanelResizeHandle,{className:"group/divider relative my-1 flex h-6 w-full shrink-0 cursor-row-resize items-center gap-3 px-1 outline-none",children:[e.jsx("span",{className:"h-px flex-1 bg-border transition-colors group-hover/divider:bg-foreground/30"}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[10px] text-muted-foreground",children:[e.jsx(a.ArrowDown,{className:"h-3 w-3",strokeWidth:1.75}),e.jsx("span",{className:"font-medium uppercase tracking-[0.08em]",children:"Post-process with Python"}),e.jsx("span",{"aria-hidden":!0,className:"text-border",children:"·"}),e.jsx("code",{className:"hidden font-mono text-[10px] tracking-normal text-foreground/80 sm:inline",children:"def process(df) → df"}),e.jsx("span",{"aria-hidden":!0,className:"hidden text-border md:inline",children:"·"}),e.jsx("span",{className:"hidden font-mono text-[10px] uppercase tracking-[0.08em] md:inline",children:"Python 3.11"})]}),e.jsx("span",{className:"h-px flex-1 bg-border transition-colors group-hover/divider:bg-foreground/30"}),e.jsx("button",{type:"button","aria-label":"Expand Python editor",title:"Expand Python editor",onClick:Z=>{Z.stopPropagation(),ae("python")},onPointerDown:Z=>Z.stopPropagation(),className:"inline-flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-none",children:e.jsx(qe.Maximize2,{className:"h-3 w-3",strokeWidth:1.75})}),e.jsx("button",{type:"button","aria-label":"Close Python editor",onClick:Z=>{Z.stopPropagation(),o(!1)},onPointerDown:Z=>Z.stopPropagation(),className:"inline-flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:e.jsx(le.X,{className:"h-3 w-3",strokeWidth:1.75})})]}),e.jsx(a.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:e.jsx("div",{id:"python-container",className:"relative flex w-full flex-col overflow-hidden bg-background",children:e.jsx("div",{className:"relative flex flex-1",children:l===null?e.jsx(a.PythonEditor,{ref:h},`inline-python-${m.id}`):null})})})]})]})}function re(){const Z={query:e.jsx(a.DropdownMenuCheckboxItem,{checked:r,onCheckedChange:Fe=>o(Fe===!0),children:"Python post-processor"}),reset:e.jsxs(a.DropdownMenuItem,{onSelect:c,children:[e.jsx(t.RotateCcw,{className:"h-3.5 w-3.5"}),"Reset editor"]})};return e.jsx("div",{role:"editor-controls",className:"flex w-full flex-wrap items-center gap-2 px-4 pb-2 pt-3 @container",children:e.jsxs("div",{className:"flex w-full min-w-0 flex-nowrap items-center gap-2 overflow-hidden",children:[e.jsxs(t.Button,{title:"Shift + Enter",disabled:me||be,onClick:De,className:"shrink-0",size:"xs",children:[me||be?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(a.Play,{className:"h-3.5 w-3.5"}),"Run"]}),e.jsxs(a.Toggle,{pressed:r,onPressedChange:Fe=>o(Fe),title:r?"Remove Python post-processor":"Add a Python step to post-process the SQL result",className:"h-7 w-7 shrink-0 gap-1.5 rounded-control px-0 text-[12px] @[1450px]:w-auto @[1450px]:px-2.5",size:"sm",variant:"outline",children:[e.jsx("span",{className:"inline-flex h-3 w-3 items-center justify-center rounded-[2px] bg-muted font-mono text-[8px] font-bold text-muted-foreground",children:"Py"}),e.jsx("span",{className:"hidden @[1450px]:inline",children:"Python"}),r?e.jsx(t.Check,{className:"hidden h-3 w-3 @[1450px]:block",strokeWidth:1.75}):e.jsx(a.Plus,{className:"hidden h-3 w-3 text-muted-foreground @[1450px]:block",strokeWidth:1.75})]}),T&&e.jsx(co,{hint:T}),e.jsx("div",{className:"hidden min-w-[220px] flex-1 @[950px]:flex",children:e.jsx(ro,{currentSql:m==null?void 0:m.sql,currentPython:m==null?void 0:m.python,selectedDatabaseName:f,selectedSchemaName:g,selectedTableName:k,onApplySql:Ae,onOpenFullAssistant:()=>Y(!0)})}),e.jsx(t.Button,{variant:"outline",size:"xs",className:"min-w-0 shrink @[950px]:hidden",onClick:()=>Y(!0),children:e.jsx("span",{className:"truncate",children:"Generate SQL"})}),s==null?void 0:s(Z)]})})}return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-1.5 px-4 pb-3 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:t.cn("min-w-0",i&&"flex-1"),children:e.jsx(a.EditableText,{value:m.title,onSave:Z=>$({...m,title:Z}),onEditingChange:d,isEditable:!0,placeholder:"Add title",displayClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]",inputClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]"})}),e.jsx(a.InfoHover,{card:m})]}),e.jsx(a.EditableText,{value:(m.description||"").trim(),onSave:Z=>$({...m,description:Z.trim()}),isEditable:!0,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})]}),e.jsx("div",{className:"relative flex grow overflow-y-scroll",children:Se()}),re(),e.jsx(oo,{activeEditor:l,showPythonEditor:r,isRunning:me||be,sqlEditor:e.jsx(a.SqlEditor,{ref:p},`expanded-sql-${m.id}`),pythonEditor:e.jsx(a.PythonEditor,{ref:j},`expanded-python-${m.id}`),onActiveEditorChange:K,onOpenChange:ie,onRun:De})]})}function mo(s){const n=t.useDashboardStore(f=>f.dashboard),r=t.useDashboardStore(f=>f.dashboard.filters),o=t.useDashboardStore(f=>f.filterValues),i=t.useDashboardStore(f=>f.selectedSheetId),d=t.useDashboardStore(f=>f.dashboardInputValues),c=t.useDashboardStore(f=>f.controlValues),l=t.useDashboardStore(f=>f.inlineFilterValuesMap),u=t.useDashboardStore(f=>f.cardControlValuesMap),x=t.useDashboardStore(f=>f.actions.getCard(s)),m=t.useEditorStore(f=>f.editorContext),b=t.useEditorStore(f=>f.card),p=(m==null?void 0:m.type)==="documentSection"&&m.cardId===s?m:void 0,j=p?b:x;if(t.requiresDashboardInputResolution({dashboard:n,dashboardInputValues:d})&&j){const f=t.resolveDashboardInputContext({dashboard:n,sheetId:p?p.sheetId:i,sheetKind:p?"document":void 0,sectionId:p?p.sectionId:void 0,card:j,runtimeValues:{dashboardInputValues:d,filterValues:o,controlValues:c,inlineFilterValuesMap:l,cardControlValuesMap:u},mode:p?"editor":"interactive"}),g=xo(f.inputs);return{cardFilters:f.inputs.flatMap(k=>k.kind==="filter"&&!g.has(k.filter.id)?[k.filter]:[]),cardFilterValues:f.activeFilters.filter(k=>!g.has(k.filterId))}}return p?{cardFilters:[],cardFilterValues:p.documentFilterValues||[]}:a.calculateCardFilterValues(r,o,i,s)}function xo(s){return new Set(s.flatMap(n=>{var r;return n.kind==="filter"&&((r=n.compatibility)==null?void 0:r.source)==="cardInlineFilter"?[n.filter.id]:[]}))}function ho(s,n){var d;let r=0,o=0;const i=Math.min(s.length,50);for(let c=0;c<i;c++){const l=(d=s[c])==null?void 0:d[n];if(!(l==null||l==="")){if(o++,typeof l=="number"||typeof l=="bigint")r++;else if(typeof l=="boolean")return"boolean"}}return o===0?"null":r/o>.7?"number":"text"}function po(s){if(s===null)return"null";if(s===void 0)return"";if(typeof s=="number"||typeof s=="bigint"||typeof s=="boolean")return String(s);if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}function fo({data:s,card:n,paginationMetadata:r,onPaginationChange:o,onPageSizePreferenceChange:i,onSortChange:d,isLoading:c}){var T,R,C,V,P,O;const{updateEnableDevModePagination:l,setRunSql:u}=t.useEditorActions(),x=v.useMemo(()=>Object.keys(s[0]??{}),[s]),m=n.sql&&!((R=(T=n.preferences)==null?void 0:T.tablePrefs)!=null&&R.enableDevModePagination)?(V=(C=n.preferences)==null?void 0:C.tablePrefs)==null?void 0:V.pageSize:void 0,b=v.useMemo(()=>{var B;return a.sortByColumnsToSortState((B=n.config)==null?void 0:B.sortByColumns)},[(P=n.config)==null?void 0:P.sortByColumns]),{canSort:h,canUseLocalSorting:p,handlePaginationChange:j,handleSortChange:N,pagination:f,paginationMode:g,sorting:k}=a.useTableQueryState({card:n,dataLength:s.length,onPaginationChange:o,onSortChange:d,pageSize:m,paginationMetadata:r,sortState:b}),D=v.useMemo(()=>k.filter(B=>x.includes(B.id)),[k,x]),w=v.useMemo(()=>{const B={};for(const _ of x)B[_]=ho(s,_);return B},[x,s]),S=v.useMemo(()=>x.map(B=>{const z=w[B]==="number";return{accessorKey:B,enableSorting:h,header:({column:q})=>{const Y=q.getIsSorted();return e.jsxs("div",{className:t.cn("flex min-w-0 select-none items-center gap-1.5 transition-colors",q.getCanSort()&&"cursor-pointer hover:text-foreground",z&&"justify-end"),onClick:()=>q.getCanSort()&&q.toggleSorting(q.getIsSorted()==="asc"),children:[e.jsx("span",{className:"min-w-0 truncate",title:B,children:B}),Y==="asc"?e.jsx(a.ArrowUpIcon,{className:"h-3.5 w-3.5 shrink-0 text-foreground"}):Y==="desc"?e.jsx(a.ArrowDownIcon,{className:"h-3.5 w-3.5 shrink-0 text-foreground"}):q.getCanSort()?e.jsx(a.ChevronsUpDown,{className:"h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover/header:opacity-50"}):null]})},cell:({getValue:q})=>{const Y=q(),$=Y===null;return e.jsx("div",{className:t.cn("overflow-hidden truncate whitespace-nowrap leading-5",z&&"text-right tabular-nums",$&&"italic text-muted-foreground/50"),children:po(Y)})}}}),[h,w,x]),L=Math.max(S.length,1),A=a.useReactTable({data:s,columns:S,getCoreRowModel:a.getCoreRowModel(),getPaginationRowModel:g==="client"?a.getPaginationRowModel():void 0,onSortingChange:N,getSortedRowModel:p?a.getSortedRowModel():void 0,onPaginationChange:g==="disabled"?void 0:j,manualPagination:g==="server"||g==="disabled",manualSorting:!p,pageCount:g==="server"&&r?r.pageCount:void 0,state:{sorting:D,pagination:f}}),F=g==="server"&&r?r.totalCount:s.length,I=a.isDevPaginationSwitchableCard(n),y=g!=="disabled"&&(g==="server"||I||F>10),E=g==="server"||F>10,M=x.length>0?`${x.length*144}px`:"100%";return e.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col",children:[c&&e.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/50",children:e.jsx(t.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),e.jsxs(a.CustomScrollArea,{className:"relative min-h-0 w-full grow overflow-auto rounded-none border-0 bg-transparent text-foreground",children:[e.jsxs("table",{className:"w-full text-sm [border-spacing:0]",style:{minWidth:M},children:[e.jsx(a.TableHeader,{className:"sticky top-0 z-10 bg-muted [&_tr]:border-b-0",children:A.getHeaderGroups().map(B=>e.jsx(a.TableRow,{className:"border-b-0 hover:bg-transparent",children:B.headers.map(_=>{const q=w[_.id]==="number";return e.jsx(a.TableHead,{className:t.cn("group/header relative h-auto border-b border-transparent bg-muted/95 px-4 py-2 align-middle text-[10px] font-medium tracking-[0.08em] text-muted-foreground after:absolute after:bottom-0 after:left-0 after:right-0 after:h-px after:bg-border/60",q&&"text-right"),children:_.isPlaceholder?null:a.flexRender(_.column.columnDef.header,_.getContext())},_.id)})},B.id))}),e.jsx(a.TableBody,{children:(O=A.getRowModel().rows)!=null&&O.length?A.getRowModel().rows.map(B=>e.jsx(a.TableRow,{className:"border-b border-border/40 transition-colors","data-state":B.getIsSelected()&&"selected",children:B.getVisibleCells().map(_=>{const q=w[_.column.id]==="number";return e.jsx(a.TableCell,{className:t.cn("overflow-hidden px-4 py-2 text-[13px] text-foreground/90",q&&"text-right"),children:a.flexRender(_.column.columnDef.cell,_.getContext())},_.id)})},B.id)):e.jsx(a.TableRow,{children:e.jsx(a.TableCell,{colSpan:L,className:"h-auto py-12 text-center text-[13px] text-muted-foreground",children:"No results."})})})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]}),e.jsx("div",{className:"shrink-0 border-t border-border/60 bg-background text-[13px]",children:y?e.jsx(a.DataTablePagination,{totalColumns:x.length,pageCount:g==="server"&&r?r.pageCount:A.getPageCount(),pageIndex:A.getState().pagination.pageIndex,pageSize:A.getState().pagination.pageSize,rowCount:F,selectedRowCount:0,setPageIndex:A.setPageIndex,setPageSize:A.setPageSize,canPreviousPage:g==="server"&&r?r.hasPrevPage:A.getCanPreviousPage(),canNextPage:g==="server"&&r?r.hasNextPage:A.getCanNextPage(),previousPage:A.previousPage,nextPage:A.nextPage,onPageSizePreferenceChange:i,onClearSelection:()=>{},paginationMode:g,showPaginationControls:E,onPaginationModeChange:I?B=>{A.setPageIndex(0),l(B==="server"),u(!0)}:void 0,showExport:!1}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[F.toLocaleString()," ",F===1?"row":"rows"," · ",x.length," ",x.length===1?"column":"columns"]}),D.length>0&&e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["Sorted by"," ",e.jsx("span",{className:"font-medium text-foreground/70",children:D[0].id})," ",D[0].desc?"↓":"↑"]})]})})]})}const Fn=[{value:"table",label:"Table"},{value:"aggregateTable",label:"Hierarchical"},{value:"pivotTable",label:"Pivot"},{value:"detailTable",label:"Detail"}];function go({className:s}){const n=t.useEditorStore(p=>p.card),r=t.useEditorStore(p=>p.frame),o=t.useEditorStore(p=>p.editorContext),i=a.useEffectiveEditorCardType(),{setCard:d,updateCardInFrame:c}=t.useEditorActions(),l=(o==null?void 0:o.type)==="documentSection"?Fn.filter(p=>["table","pivotTable"].includes(p.value)):Fn,u=["table","aggregateTable","pivotTable","detailTable"].includes(i),x=ye.hasValidCardConfig(n.config,n.type),m=he.isCustomVisualConfigCard(n,r.cards);if(!u||!x||m)return e.jsx("div",{"aria-hidden":"true",className:t.cn("invisible flex items-center gap-5",s),children:e.jsx("span",{className:"-mb-px flex h-9 items-center border-b-2 border-transparent text-[12px]",children:"Placeholder"})});const b=p=>{if(p===i||m)return;const j=p,N=n.config??{},f=h(i,j,N),g={...n,type:j,config:f};d(g),c(g)},h=(p,j,N)=>{var g;if(p===j)return N;if(j==="detailTable"){const k=L=>L==null?void 0:L.toLowerCase().replace(/\s+/g,"").trim(),D=(L,A)=>{const F=[k(L.label),k(L.qualifiedFieldName),k(L.name)].filter(Boolean),I=[k(A.label),k(A.qualifiedFieldName),k(A.name)].filter(Boolean);return F.some(y=>I.includes(y))},w=(N.groupByColumns||[]).map(L=>({...L,role:"detail"})),S=((g=N.sortByColumns)==null?void 0:g.filter(L=>w.some(A=>D(L,A))))??[];return{...N,detailTableBackup:{groupByColumns:N.groupByColumns,metricColumns:N.metricColumns,pivotByColumns:N.pivotByColumns,sortByColumns:N.sortByColumns,rowAggregates:N.rowAggregates,columnAggregates:N.columnAggregates},detailColumns:w,groupByColumns:[],metricColumns:[],pivotByColumns:[],sortByColumns:S,rowAggregates:[],columnAggregates:[]}}let f=N;if(p==="detailTable")if(N.detailTableBackup)f={...N,...N.detailTableBackup,detailColumns:[],detailTableBackup:void 0};else{const k=(N.detailColumns||[]).map(D=>({...D,role:"groupby"}));f={...N,groupByColumns:k,detailColumns:[]}}return j==="aggregateTable"?{...f,pivotByColumns:[]}:f};return e.jsx("div",{role:"tablist",className:t.cn("flex items-center gap-5",s),children:l.map(p=>{const j=i===p.value;return e.jsx("button",{type:"button",role:"tab","aria-selected":j,onClick:()=>b(p.value),className:t.cn("-mb-px flex h-9 items-center border-b-2 text-[12px] transition-colors",j?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:p.label},p.value)})})}const bo=1200;function jo(s){var o;const n=s.target;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n.selectionStart!==n.selectionEnd;const r=(o=s.currentTarget.ownerDocument.defaultView)==null?void 0:o.getSelection();return!!(r&&!r.isCollapsed)}function Ms({text:s,children:n,className:r,as:o="button",disabled:i,onClick:d,onCopy:c,...l}){const[u,x]=v.useState(!1),m=v.useRef(void 0);v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const b=()=>{m.current&&(clearTimeout(m.current),m.current=void 0),x(!1)},h=()=>{m.current&&clearTimeout(m.current),x(!0),m.current=setTimeout(()=>{x(!1),m.current=void 0},bo)},p=async()=>{try{let g=!1;c?g=await c():typeof s=="string"&&navigator.clipboard&&(await navigator.clipboard.writeText(s),g=!0),g&&h()}catch(g){console.error("Failed to copy text",g)}},j=g=>{d==null||d(g),!(g.defaultPrevented||jo(g))&&p()},N=t.cn("group/copy-on-click relative block w-full cursor-pointer rounded-control text-left transition-[background-color,box-shadow] duration-150","hover:bg-muted/30 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring motion-reduce:transition-none",i&&"cursor-default opacity-60",r),f=o==="div"?e.jsx("div",{...l,"aria-disabled":i||void 0,className:N,onClick:i?void 0:j,onBlur:b,onMouseLeave:b,children:n}):e.jsx("button",{type:"button",className:N,disabled:i,onClick:j,onBlur:b,onMouseLeave:b,...l,children:n});return e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Tooltip,{open:u,onOpenChange:g=>{g||b()},children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:f}),e.jsx(t.TooltipContent,{side:"top",children:"Copied!"})]})})}const Rn={async writeTextToClipboard(s){return typeof navigator>"u"||!navigator.clipboard?!1:(await navigator.clipboard.writeText(s),!0)}},Pt="h-6 gap-1 px-2 text-[11px] [&_svg]:h-3 [&_svg]:w-3";function la({children:s,className:n}){return e.jsx("div",{className:t.cn("flex max-h-full min-h-0 flex-1 flex-col pt-3",n),children:s})}function ia({children:s,className:n}){return e.jsx("div",{className:t.cn("flex min-h-7 shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-1 px-3",n),children:s})}function ca({children:s,className:n}){return e.jsx("div",{className:t.cn("ml-auto flex min-w-0 flex-wrap items-center justify-end gap-1.5",n),children:s})}const ts=50;function vo(s){return`Copy ${s}`}const yo=[{target:"queryRequest",label:"Query request"},{target:"queryResponse",label:"Query response"},{target:"cardConfig",label:"Card config"},{target:"dataSource",label:"Data source"},{target:"columns",label:"Columns"},{target:"dashboardFilters",label:"Dashboard filters"},{target:"cardMetadata",label:"Card metadata"}];function Pn(s){try{return JSON.stringify(s,null,2)}catch(n){return console.error("Unable to stringify debug payload",n),null}}function Lt(s){switch(s){case"queryRequest":return"Query request";case"queryResponse":return"Query response";case"cardConfig":return"Card config";case"dataSource":return"Data source";case"cardMetadata":return"Card metadata";case"columns":return"Columns";case"dashboardFilters":return"Dashboard filters";default:return"Payload"}}function Co(s){if(!s||typeof s!="object")return{value:s};const n=s.records;return!Array.isArray(n)||n.length<=ts?{value:s}:{value:{...s,records:n.slice(0,ts),previewMeta:{truncatedRecords:!0,displayedRecords:ts,totalRecords:n.length}},truncationMessage:`Preview showing first ${ts} records of ${n.length}. Copy actions include full payload.`}}function da({isOpen:s,onClick:n}){return e.jsxs(t.Button,{onClick:n,variant:"outline",size:"xs",className:Pt,"aria-expanded":s,children:[e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 transition-transform",s&&"rotate-180")}),s?"Hide card details":"Card details"]})}function ua({debugPayloads:s,className:n}){const[r,o]=v.useState(null),i=t.useEditorStore(D=>D.card),d=t.useEditorStore(D=>D.frame),c=t.useDashboardStore(D=>D.selectedSheetId),l=t.useDashboardStore(D=>{var w;return(w=D.dashboard)==null?void 0:w.id}),u=v.useMemo(()=>({cardId:i.id||null,frameId:d.id||null,sheetId:c||null,dashboardId:l||null}),[i.id,d.id,c,l]),x=v.useMemo(()=>({queryRequest:s==null?void 0:s.queryRequest,queryResponse:s==null?void 0:s.queryResponse,cardConfig:i.config,dataSource:i.dataSource,columns:s==null?void 0:s.columns,dashboardFilters:s==null?void 0:s.dashboardFilters,cardMetadata:u}),[s==null?void 0:s.queryRequest,s==null?void 0:s.queryResponse,s==null?void 0:s.columns,s==null?void 0:s.dashboardFilters,i.config,i.dataSource,u]),m=!!s,b=v.useMemo(()=>[{label:"Card ID",value:i.id||""},{label:"Frame ID",value:d.id||""},{label:"Sheet ID",value:c||""},{label:"Dashboard ID",value:l||""}],[i.id,d.id,c,l]),h=D=>x[D]!==void 0,p=v.useMemo(()=>{if(!r)return null;const D=x[r];if(D===void 0)return null;const w=r==="queryResponse"?Co(D):{value:D},S=Pn(w.value);return S?{target:r,title:Lt(r),json:S,truncationMessage:w.truncationMessage}:null},[r,x]),j=p?p.title:"Inspect payload",N=async D=>{const w=x[D];if(w===void 0)return t.ue.error(`No ${Lt(D).toLowerCase()} available`),!1;const S=Pn(w);if(!S)return t.ue.error(`Unable to serialize ${Lt(D).toLowerCase()}`),!1;try{return await Rn.writeTextToClipboard(S)?(t.ue.success(`${Lt(D)} copied`),!0):(t.ue.error("Clipboard is not available"),!1)}catch(L){return console.error("Failed to copy debug payload",L),t.ue.error(`Unable to copy ${Lt(D).toLowerCase()}`),!1}},f=async()=>p?N(p.target):!1,g=async D=>{if(!D.value)return!1;try{return await Rn.writeTextToClipboard(D.value)?!0:(t.ue.error("Clipboard is not available"),!1)}catch(w){return console.error("Failed to copy card detail",w),t.ue.error(`Unable to copy ${D.label}`),!1}},k=D=>{if(x[D]===void 0){t.ue.error(`No ${Lt(D).toLowerCase()} available`);return}o(D)};return e.jsxs("div",{className:t.cn("mb-2 min-w-0 px-3",n),children:[e.jsx("div",{className:"grid grid-cols-1 gap-x-6 gap-y-1 md:grid-cols-2",children:b.map(D=>e.jsxs(Ms,{text:D.value,"aria-label":vo(D.label),title:D.value?`Copy ${D.label}`:"N/A",disabled:!D.value,onCopy:()=>g(D),className:"min-w-0 py-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:D.label}),e.jsx("code",{className:"mt-1 block truncate font-mono text-[12px] leading-5 text-foreground",children:D.value||"N/A"})]},D.label))}),m&&e.jsxs("div",{className:"mt-2 border-t border-border/60 pt-2",children:[e.jsxs("div",{className:"flex min-h-7 items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Diagnostics"}),e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"xs",className:Pt,children:[e.jsx(qe.Eye,{}),j,e.jsx(le.ChevronDown,{})]})}),e.jsx(a.DropdownMenuContent,{align:"end",className:"w-48 p-1",children:yo.map(D=>e.jsx(a.DropdownMenuItem,{disabled:!h(D.target),onSelect:()=>k(D.target),className:t.cn("h-7 rounded-control px-2 text-[12px] font-normal leading-4",r===D.target&&"bg-accent"),children:D.label},`preview-${D.target}`))})]})]}),p&&e.jsxs("div",{className:"mt-2 space-y-2 border-t border-border/60 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"truncate text-[12px] font-medium text-foreground",children:p.title}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(a.CopyButton,{text:p.json,className:"h-6 w-6 rounded-control px-0 text-muted-foreground",ariaLabel:"Copy diagnostics payload",onCopy:f}),e.jsx(t.Button,{variant:"ghost",size:"xs",className:"h-6 px-2 text-[11px]",onClick:()=>o(null),children:"Close"})]})]}),p.truncationMessage&&e.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:p.truncationMessage}),e.jsx("div",{className:"max-h-80 overflow-auto rounded-[5px] border border-border/60 bg-background p-1",children:e.jsx(t.CodeEditor,{value:p.json,language:"json",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:`${p.title} JSON`})})]})]})]})}const No=()=>{};function ma({sql:s,label:n,ariaLabel:r,copyAriaLabel:o,headerActions:i,trailingHeaderActions:d,collapsible:c=!1,defaultOpen:l=!1,children:u,className:x,headerClassName:m,bodyClassName:b}){const h=v.useId(),[p,j]=v.useState(l),N=!c||p;return e.jsxs("div",{className:t.cn("flex min-h-0 flex-col overflow-hidden",x),children:[e.jsxs(ia,{className:m,children:[c?e.jsxs("button",{type:"button",onClick:()=>j(f=>!f),"aria-expanded":p,"aria-controls":N?h:void 0,className:"-ml-1 flex min-w-0 items-center gap-1 rounded-control px-1 py-0.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-3 w-3 shrink-0 transition-transform",p&&"rotate-90")}),e.jsx("span",{className:"truncate",children:n})]}):e.jsx("span",{className:"text-[12px] text-muted-foreground",children:n}),N?e.jsxs(ca,{children:[i,d]}):null]}),N?e.jsxs("div",{id:h,className:t.cn("min-h-[80px] overflow-auto px-1 py-1",b),children:[u,e.jsx(Ms,{as:"div",text:s,title:o,className:"min-h-[80px] [&_pre]:!cursor-pointer [&_textarea]:!cursor-pointer",children:e.jsx(t.CodeEditor,{value:s,onValueChange:No,language:"sql",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:r})})]}):null]})}function xa({error:s,errorSql:n,errorTitle:r="Error details",errorMessageClassName:o,fillAvailableSqlHeight:i=!1,onOpenInEditor:d,onDebugWithAssistant:c,onSendFeedback:l,showFeedbackButton:u=!0,showCardDetails:x=!1,defaultSqlExpanded:m=!1,debugPayloads:b,className:h,embedded:p=!1}){const j=v.useId(),[N,f]=v.useState(!1),g=p?"px-3":"px-0",k=!!c,D=!!(d&&n),w=x,S=!!(u&&l),L=k||D||w?e.jsxs(e.Fragment,{children:[c?e.jsx(t.Button,{variant:"ghost",size:"xs",className:Pt,onClick:c,children:"Debug with Assistant"}):null,d&&n?e.jsx(t.Button,{variant:"outline",size:"xs",className:Pt,onClick:d,children:"Open in SQL editor"}):null,x?e.jsx(da,{isOpen:N,onClick:()=>f(F=>!F)}):null]}):null,A=S?e.jsx(t.Button,{type:"button",variant:"ghost",size:"xs",className:t.cn(Pt,"text-muted-foreground"),onClick:l,children:"Report issue"}):null;return e.jsxs(la,{className:t.cn("w-full",h),children:[e.jsxs(ia,{className:g,children:[e.jsx("span",{id:j,className:"min-w-0 truncate text-[13px] font-medium text-foreground",children:r}),L||A?e.jsxs(ca,{children:[L,A]}):null]}),e.jsx(Ms,{text:s,"aria-label":"Copy error message",title:"Copy error message",className:t.cn("max-h-60 overflow-auto",g,o),children:e.jsx("span",{role:"alert","aria-labelledby":j,children:e.jsx("p",{className:"whitespace-pre-wrap break-all text-[12px] leading-[1.55] text-muted-foreground",children:s})})}),x&&N?e.jsx(ua,{debugPayloads:b,className:"mt-2"}):null,n?e.jsx(ma,{sql:n,label:"Failed query",ariaLabel:"Failed SQL query",copyAriaLabel:"Copy failed query",collapsible:!0,defaultOpen:m,headerClassName:g,className:t.cn("mt-1",i&&"min-h-7 flex-1"),bodyClassName:t.cn("max-h-80",i&&"min-h-0 max-h-none flex-1")}):null]})}function rs({className:s,...n}){return e.jsx(xa,{...n,className:t.cn("!pt-0",s)})}function So(s){const{className:n,...r}=s;return e.jsx(xa,{...r,embedded:!0,className:t.cn("overflow-auto",n)})}function As(s,n){const r=t.useEditorStore(x=>x.card),o=t.useEditorStore(x=>x.isDevMode),{switchEditorMode:i,setRunSql:d,runAssistant:c}=t.useEditorActions(),l=()=>{const x=n||r.sql||r.python||"";i("dev",{sqlToLoad:x}),setTimeout(()=>{d(!0)},100)},u=()=>{const x=`Can you help me debug this query?
|
|
162
|
+
|
|
163
|
+
Error:
|
|
164
|
+
|
|
165
|
+
${s}
|
|
166
|
+
|
|
167
|
+
Error SQL:
|
|
168
|
+
|
|
169
|
+
${n||r.sql||r.python}
|
|
170
|
+
|
|
171
|
+
`;c(x)};return{isDevMode:o,handleOpenInEditor:!o&&ye.supportsSqlEditor(r.type)?l:void 0,handleDebugWithAssistant:o?u:void 0}}function ha(s,n){const[r,o]=v.useState(!1),i=t.useEditorStore(m=>m.card),d=t.useDashboardStore(m=>m.dashboard.filters),{currentUser:c}=a.useCurrentUserInfo(),{tokenProps:l}=v.useContext(a.SemaphorContext),u=v.useCallback(()=>{o(!0)},[]),x=v.useMemo(()=>{const m=typeof window<"u"?window.location.href:"",b=typeof navigator<"u"?navigator.userAgent:"",h=typeof window<"u"?`${window.innerWidth}x${window.innerHeight}`:"";return{category:a.FeedbackCategory.QUERY_GENERATION,user:c,tokenContext:l,systemState:{cardConfig:i.config,dataSource:i.dataSource,dashboardFilters:d,errorMessage:s||void 0,errorSql:n||i.sql||i.python,generatedSql:n||i.sql},metadata:{url:m,userAgent:b,timestamp:new Date().toISOString(),viewport:h}}},[c,l,i,d,s,n]);return{feedbackDialogOpen:r,setFeedbackDialogOpen:o,handleSendFeedback:u,feedbackPayload:x}}const wo="__editor_sql__",To="__editor_python__";function Eo(s){var r;const n=he.normalizeDashboardCardPythonCode(s.python||"");return{sql:(r=s.sql)!=null&&r.trim()?wo:"",python:n.trim()?To:""}}function pa({className:s,style:n,...r}){var Z,Fe,xe,ze,Le,$e,we;const o=t.useEditorStore(oe=>oe.card),i=a.useDashboardAppearance(),c=t.useEditorStore(oe=>oe.isDevMode)?!1:((Z=o.customCardPreferences)==null?void 0:Z.showCardHeader)??!0,l=((xe=(Fe=o.preferences)==null?void 0:Fe.displayOptions)==null?void 0:xe.showInlineFilterBar)??!0,u=t.useEditorStore(oe=>oe.frame),x=t.useEditorStore(oe=>oe.inlineFilterValuesMap[o.id]),m=t.useDashboardStore(oe=>oe.dashboard.filters),b=t.useDashboardStore(oe=>oe.selectedSheetId),h=t.useEditorStore(oe=>oe.actions.setRunSql),p=t.useEditorStore(oe=>oe.actions.setCardInlineFilterValue),j=t.useEditorStore(oe=>oe.actions.removeCardInlineFilterValue),{updateFilter:N}=t.useDashboardActions(),f=m==null?void 0:m.find(oe=>oe.id===u.filterId),g=v.useMemo(()=>he.findCustomVisualConfigCard(u,o),[u,o]),{manifest:k}=a.useCustomVisual(((ze=g==null?void 0:g.customCardPreferences)==null?void 0:ze.url)||""),D=v.useMemo(()=>{var oe;return(oe=k==null?void 0:k.visuals)==null?void 0:oe.find(te=>{var ue;return te.name===((ue=g==null?void 0:g.customCardPreferences)==null?void 0:ue.componentName)})},[k,(Le=g==null?void 0:g.customCardPreferences)==null?void 0:Le.componentName]),w=he.resolveMultiInputType(g,D),S=v.useMemo(()=>he.getCustomVisualInputCards({frame:u,configCard:g,isMultiInputVisual:w==="multiple"}),[u,g,w]),L=v.useMemo(()=>{const oe=S.findIndex(te=>(te==null?void 0:te.id)===(o==null?void 0:o.id));return oe<0?-1:he.getSlotIndexForCard(o,oe)},[S,o]),A=v.useMemo(()=>!g||w!=="multiple"||L<0?o.type:he.getEffectiveCardTypeForSlot(o,L,D==null?void 0:D.slots)??o.type,[g,w,L,o,D==null?void 0:D.slots]),F=A??o.type,I=v.useMemo(()=>F===o.type?o:{...o,type:F},[o,F]),y=I.type==="table"||I.type==="matrixTable"||I.type==="pivotTable"||I.type==="aggregateTable"||I.type==="detailTable",E=v.useMemo(()=>A!==o.type?{...o,type:A}:o,[o,A]),{data:M,isLoading:T,isFetching:R,errorMessage:C,errorSql:V,pagination:P}=a.useEditorCardQuery(E),O=!!C,{handleOpenInEditor:B,handleDebugWithAssistant:_}=As(C,V||o.sql||o.python),{feedbackDialogOpen:z,setFeedbackDialogOpen:q,handleSendFeedback:Y,feedbackPayload:$}=ha(C,V||o.sql||o.python),Q=v.useMemo(()=>(M==null?void 0:M.records)||[],[M==null?void 0:M.records]),{setCard:U,updateCardInFrame:J}=t.useEditorActions(),{data:X}=a.useTopoJson(I),ee=I.id,me=I.config,be=I.interactionConfig,ve=I.controls,je=I.controlBindings,Re=I.customCfg,Pe=I.preferences,Me=I.queryConfig,Ee=Eo({sql:I.sql,python:I.python}),Be=Ee.sql,_e=Ee.python,Oe=M==null?void 0:M.records,Ae=v.useMemo(()=>({id:ee,type:F,config:me,interactionConfig:be,preferences:Pe,controls:ve,controlBindings:je,sql:Be,python:_e}),[ee,F,me,be,Pe,ve,je,Be,_e]),De=v.useMemo(()=>F==="pivotTable"?a.resolvePendingPivotTableResultState({data:M,card:I,isPending:T||R}):{kind:"not_loaded"},[I,F,M,R,T]),ae=a.usePivotTableConfig(I,De,($e=M==null?void 0:M.metadata)==null?void 0:$e.comparisonMetadata),K=(oe,te)=>{var Ce,fe;const ue={...o,paginationConfig:{page:oe+1,pageSize:te}};U(ue),J(ue),o.sql&&((fe=(Ce=o.preferences)==null?void 0:Ce.tablePrefs)!=null&&fe.enableDevModePagination)&&h(!0)},ie=oe=>{var Ce,fe,He,ke,bt;const te=a.sortStateToSortByColumns(oe,(Ce=o.config)==null?void 0:Ce.metricColumns,(fe=o.config)==null?void 0:fe.groupByColumns,(He=o.config)==null?void 0:He.detailColumns),ue={...o,config:{...o.config||{},sortByColumns:te}};U(ue),J(ue),o.sql&&((bt=(ke=o.preferences)==null?void 0:ke.tablePrefs)!=null&&bt.enableDevModePagination)&&h(!0)},Se=a.useChartNumericPresentation(Ae,Oe||void 0),re=v.useMemo(()=>{var oe;return!ee||!Oe?null:a.createChartConfig({card:Ae,data:Oe,cardType:F,queryConfig:Me,customCfg:Re,preferences:Pe,topoJson:X,comparisonMetadata:(oe=M==null?void 0:M.metadata)==null?void 0:oe.comparisonMetadata,numericPresentation:Se,resultColumns:M==null?void 0:M.columns,columnKeyMap:M==null?void 0:M.columnKeyMap})},[Ae,ee,Re,Pe,Me,Oe,M==null?void 0:M.columns,M==null?void 0:M.columnKeyMap,(we=M==null?void 0:M.metadata)==null?void 0:we.comparisonMetadata,F,Se,X]);function pe(oe){return e.jsx(a.ErrorBoundary,{FallbackComponent:a.FallbackVisual,children:e.jsx(a.EditorCustomVisual,{card:oe})})}function Ye(){var oe;if(I.type==="matrixTable")return e.jsx(a.MatrixCardView,{card:I,frame:u,mode:"editor"});if(M!=null&&M.records&&(M==null?void 0:M.records.length)===0&&!T&&!R&&F!=="pivotTable")return C?e.jsx("div",{className:"flex h-full flex-col items-start justify-start overflow-auto",children:e.jsx(rs,{error:C,errorSql:V||o.sql||o.python,onOpenInEditor:B,onDebugWithAssistant:_,onSendFeedback:Y,showFeedbackButton:!0})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(a.Inbox,{className:"h-8 w-8 text-muted-foreground/40"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No results to display"})]});if((T||R)&&(!(M!=null&&M.records)||M.records.length===0))return F==="table"||F==="detailTable"?e.jsx("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:e.jsx(a.TableSkeleton,{})}):e.jsx("div",{className:"z-50 flex h-full items-center justify-center",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})});if(!I.id)return null;if(F==="custom")return pe(o);if(!["table","matrixTable","pivotTable","aggregateTable","detailTable","custom"].includes(F)&&re)return e.jsx("div",{className:"relative h-full min-h-0 w-full flex-1 grow basis-0",children:T||R?e.jsx(e.Fragment,{}):e.jsx(a.ChartJsVisual,{cfg:re})});if(F==="table"||F==="detailTable")return e.jsx("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:e.jsx(a.TableVisual,{card:I,data:Q,resultColumns:M==null?void 0:M.columns,columnKeyMap:M==null?void 0:M.columnKeyMap,totalsByColumnId:M==null?void 0:M.tableTotalsByColumnId,comparisonMetadata:(oe=M==null?void 0:M.metadata)==null?void 0:oe.comparisonMetadata,paginationMetadata:P,onPaginationChange:K,onSortChange:ie,isLoading:T||R})});if(F==="pivotTable"&&ae)return e.jsx("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:e.jsx(a.PivotTableTanstack,{card:I,data:ae.data,options:ae.options,onAggregationChange:te=>{const ue=a.handleAggregationChange(te,o.config),Ce={...o,config:ue};U(Ce),J(Ce)},onAggregationLabelChange:te=>{const ue=a.handleAggregationLabelChange(te,o.config),Ce={...o,config:ue};U(Ce),J(Ce)}})});if(F==="aggregateTable")return e.jsx("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:e.jsx(a.AggregateTable,{card:I,data:(M==null?void 0:M.records)||[],resultColumns:M==null?void 0:M.columns,columnKeyMap:M==null?void 0:M.columnKeyMap,groupByColumns:M==null?void 0:M.groupByColumns,pivotSchema:M==null?void 0:M.pivotSchema,paginationMetadata:P,onPaginationChange:K,onAggregationChange:te=>{const ue=a.handleAggregationChange(te,o.config),Ce={...o,config:ue};U(Ce),J(Ce)},isLoading:T||R})})}return e.jsxs(a.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none bg-card text-card-foreground",s),style:{...i.cardFrameStyle,...n},...r,children:[(T||R)&&(M==null?void 0:M.records)&&M.records.length>0&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}),c&&e.jsxs(a.CardHeader,{className:t.cn("flex flex-row items-start justify-between gap-4 px-4 pb-3 pt-3"),style:i.cardGutterStyle,children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.CardTitle,{className:"min-w-0 text-[17px] font-semibold leading-tight tracking-[-0.005em]",children:e.jsx(a.EditableText,{value:o.title,onSave:oe=>U({...o,title:oe}),isEditable:!0,placeholder:"Add title",displayClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]",inputClassName:"text-[17px] font-semibold leading-tight tracking-[-0.005em]"})}),e.jsx(a.InfoHover,{card:o}),e.jsx(gt.VisualBadge,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(go,{})})]}),e.jsx("div",{className:"min-w-0",children:e.jsx(a.EditableText,{value:(o.description||"").trim(),onSave:oe=>U({...o,description:oe.trim()}),isEditable:!0,placeholder:"Add description",displayClassName:"text-[12px] leading-snug text-muted-foreground",inputClassName:"text-[12px] leading-snug"})})]}),f&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Label,{className:"my-1",children:e.jsx(a.EditableText,{value:f.title||f.column,onSave:oe=>N({...f,title:oe}),isEditable:!0,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),e.jsx(a.FilterComponent,{filter:f})]})]}),l&&o.inlineFilters&&o.inlineFilters.length>0&&e.jsx("div",{className:"px-4 pb-2",style:i.cardGutterStyle,children:e.jsx(a.InlineFilterBar,{card:o,sheetId:b||"",inlineFilterValues:x,setInlineFilterValue:oe=>p(o.id,oe),removeInlineFilterValue:oe=>j(o.id,oe)})}),e.jsxs(a.CardContent,{className:t.cn("flex min-h-0 grow flex-col",y?O?"px-4 pb-0 pt-2":"p-0 [&_.data-table-scroll-container]:border-0 [&_.data-table-scroll-container]:bg-transparent":O?"px-4 py-0":"px-4"),style:y&&!O?void 0:i.cardGutterStyle,children:[e.jsx("div",{className:"min-h-0 flex-1 grow basis-0",children:Ye()}),a.isCardSummaryVisibleOnCard(I)&&e.jsx("div",{className:t.cn("pt-3",y&&"px-4"),children:e.jsx(a.CardSummary,{card:I,mode:"editor",records:M==null?void 0:M.records})})]}),e.jsx(a.FeedbackDialog,{open:z,onOpenChange:q,feedbackData:$,showDebugInfo:!0})]})}function On(s){var n,r;return JSON.stringify({...s,data:{...s.data,datasets:(r=(n=s.data)==null?void 0:n.datasets)==null?void 0:r.map(o=>{const i={...o};return Object.keys(i).forEach(d=>{d.startsWith("semaphor")&&delete i[d]}),{...i,data:[]}})}},null,2)}const fs=({language:s,value:n,onChange:r,readonly:o})=>e.jsx(t.CodeEditor,{className:"h-full w-full text-xs",language:s,value:n,onValueChange:r,readOnly:o,embedded:!0}),Io=()=>e.jsxs(a.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a.DialogTitle,{children:"Customize Card"})}),e.jsxs(a.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),Do=({customCode:s,cardCustomCfgString:n,mergedConfig:r,onConfigChange:o,onCodeChange:i})=>e.jsxs(t.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(t.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(t.TabsTrigger,{value:"custom-config",children:"Changes"}),e.jsx(t.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(t.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(fs,{language:"json",value:r,onChange:o})}),e.jsx(t.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(fs,{readonly:!0,language:"json",value:n,onChange:()=>{}})}),e.jsx(t.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(fs,{language:"javascript",value:s,onChange:i})})]}),ko=({error:s,hasCardCustomConfig:n,onReset:r,onApply:o,onClose:i})=>e.jsxs(a.DialogFooter,{className:"flex items-center",children:[e.jsx(t.Label,{className:"mr-2 text-red-500",children:s}),e.jsx(t.Button,{disabled:!n,onClick:r,variant:"outline",children:"Reset"}),e.jsx(t.Button,{onClick:o,variant:"outline",children:"Apply"}),e.jsx(t.Button,{onClick:i,variant:"outline",children:"Close"})]});function Mo({triggerVariant:s="icon",className:n,label:r="Customize Visual"}={}){const[o,i]=v.useState(!1),[d,c]=v.useState(""),[l,u]=v.useState(""),[x,m]=v.useState(""),[b,h]=v.useState(""),p=t.useEditorStore(y=>y.card),j=a.useEffectiveEditorCardType(),N=t.useEditorStore(y=>y.card.customCfg),f=N?JSON.stringify(N,null,2):"",g=v.useMemo(()=>j!==p.type?{...p,type:j}:p,[p,j]),{data:k}=a.useEditorCardQuery(g),{data:D}=a.useTopoJson(p),w=a.useChartNumericPresentation(p,k==null?void 0:k.records),{setCardCustomCfg:S,setCustomVisualCode:L}=t.useEditorActions(),A=()=>{var E,M,T;if(!((E=k==null?void 0:k.records)!=null&&E.length))return;const y=a.createChartConfig({card:p,data:k.records,cardType:p.type,queryConfig:p.queryConfig,preferences:p.preferences,topoJson:D,comparisonMetadata:(M=k==null?void 0:k.metadata)==null?void 0:M.comparisonMetadata,numericPresentation:w,resultColumns:k==null?void 0:k.columns,columnKeyMap:k==null?void 0:k.columnKeyMap});if(y){c(On(y)),m(((T=p.preferences)==null?void 0:T.customVisualCode)||"");const R=a.merge(y,N);u(On(R))}},F=()=>{try{if(x&&L(x),l){const y=JSON.parse(l),E=It.getObjectDiff(JSON.parse(d),y);S(E),h("")}}catch{h("Invalid JSON configuration")}},I=Object.keys(N||{}).length===0;return e.jsxs(a.Dialog,{open:o,onOpenChange:i,children:[e.jsx(a.DialogTrigger,{asChild:!0,children:s==="menu"?e.jsxs(t.Button,{variant:"ghost",onClick:A,className:t.cn("h-7 w-full justify-start gap-2 px-2 text-[13px] font-normal",I?"":"text-green-600 hover:text-green-700",n),children:[e.jsx(a.Settings,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:r})]}):e.jsx(a.IconButton,{tooltip:"Customize Visual",onClick:A,className:t.cn(I?"":"text-green-600 hover:text-green-700",n),children:e.jsx(a.Settings,{className:"h-4 w-4"})})}),e.jsxs(a.DialogContent,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(Io,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(a.ErrorBoundary,{FallbackComponent:a.FallbackVisual,children:e.jsx(pa,{className:"w-1/2 rounded shadow-none"})}),e.jsx(Do,{customCode:x,cardCustomCfgString:f,mergedConfig:l,onConfigChange:y=>u(y??""),onCodeChange:y=>m(y??"")})]}),e.jsx(ko,{error:b,hasCardCustomConfig:!!N,onReset:()=>{u(d),S(null)},onApply:F,onClose:()=>i(!1)})]})]})}function Ao(s){let n=0;for(let o=0;o<s.length;o++)n=s.charCodeAt(o)+((n<<5)-n);return`hsl(${Math.abs(n%360)}, 65%, 45%)`}function Lo(s){const n=s.trim().split(/\s+/);return n.length>1?(n[0][0]+n[1][0]).toUpperCase():s.slice(0,2).toUpperCase()}function Ls({chartType:s,chartName:n,isCustom:r=!1,className:o="h-6 w-6"}){if(!r&&s)return a.getChartIconByType(s,o);const i=a.getAutoDetectedChartIcon(n);if(i)return v.cloneElement(i,{className:o});const d=Lo(n),c=Ao(n);return e.jsx("div",{className:t.cn("flex items-center justify-center rounded text-white font-semibold text-xs",o),style:{backgroundColor:c},children:d})}function Fo({isStarred:s,onClick:n,className:r}){const o=i=>{i.stopPropagation(),i.preventDefault(),n(i)};return e.jsx("button",{type:"button",onClick:o,className:t.cn("flex items-center justify-center rounded-control p-0.5 transition-all","hover:bg-muted/80",r),"aria-label":s?"Remove from favorites":"Add to favorites",children:e.jsx(a.Star,{className:t.cn("h-3.5 w-3.5 transition-colors",s?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-foreground")})})}function Bn({chartType:s,chartName:n,isCustom:r=!1,pluginName:o,isStarred:i,showStar:d=!0,isSelected:c=!1,onSelect:l,onToggleStar:u}){return e.jsxs("div",{className:"group relative",children:[d&&e.jsx("div",{className:t.cn("absolute left-1 top-1 z-10 transition-opacity",i?"opacity-100":"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100"),children:e.jsx(Fo,{isStarred:i,onClick:()=>u()})}),r&&o&&e.jsx("div",{className:"absolute right-1 top-1 z-10",children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:"flex items-center justify-center",children:e.jsx(t.Info,{className:"h-3 w-3 text-muted-foreground"})})}),e.jsx(t.TooltipContent,{side:"top",children:o})]})}),e.jsxs("button",{type:"button",onClick:l,"aria-pressed":c,className:t.cn("flex w-full flex-col items-center justify-center gap-1.5 rounded-control border border-input bg-background px-2 py-2.5 transition-colors","hover:border-foreground/30 hover:bg-muted/40",c&&"border-foreground/50 bg-muted/50 hover:border-foreground/50"),children:[e.jsx(Ls,{chartType:s,chartName:n,isCustom:r,className:"h-4 w-4 text-foreground/80"}),e.jsx("span",{title:n,className:"line-clamp-2 text-center text-[11px] text-foreground/80",children:n})]})]})}function fa(s,n){return s==="matrixTable"?!n.isDevMode:!0}function zt(s,n){return s==="matrixTable"?!1:fa(s,n)}const Ro=[{id:"table",name:"Table"},{id:"bar",name:"Bar Chart"},{id:"line",name:"Line Chart"},{id:"area",name:"Area Chart"},{id:"combo",name:"Combo Chart"},{id:"stackedBar",name:"Stacked Bar"},{id:"stackedArea",name:"Stacked Area"},{id:"stackedLine",name:"Stacked Line"},{id:"scatter",name:"Scatter"},{id:"bubble",name:"Bubble"},{id:"pie",name:"Pie Chart"},{id:"doughnut",name:"Doughnut"},{id:"funnel",name:"Funnel"},{id:"radar",name:"Radar"},{id:"polarArea",name:"Polar Area"},{id:"tornado",name:"Tornado"},{id:"range",name:"Range"},{id:"bullet",name:"Bullet Chart"},{id:"treemap",name:"Treemap"},{id:"heatmap",name:"Heatmap"},{id:"kpi",name:"KPI"},{id:"text",name:"Text"},{id:"map",name:"Map"},{id:"matrixTable",name:"Matrix Table"}];function Po(s){return Ro.filter(n=>fa(n.id,s))}function ga({onChartSelect:s,onClose:n}){const[r,o]=v.useState(""),{starredCharts:i,isStarred:d,toggleStar:c}=a.useStarredChartsStore(),{data:l=[],isLoading:u}=a.useCustomVisualsQuery(),{setCardType:x,setCardPreferences:m,setIsDevMode:b}=t.useEditorStore(E=>E.actions),h=t.useEditorStore(E=>E.card),p=t.useEditorStore(E=>E.isDevMode),{setCardCustomCfg:j,setCustomCardPreferences:N,setVisualizationMode:f,setQueryConfig:g,replaceFrameCards:k,clearModeDrafts:D,initializeModeDrafts:w}=t.useEditorActions(),S=v.useMemo(()=>{const E=Po({isDevMode:p});if(!r)return E;const M=r.toLowerCase();return E.filter(T=>T.name.toLowerCase().includes(M))},[p,r]),L=v.useMemo(()=>{const E=l.filter(T=>T.componentType==="chart"&&T.pluginType!=="standard");if(!r)return E;const M=r.toLowerCase();return E.filter(T=>T.name.toLowerCase().includes(M))},[l,r]),A=E=>{j(null),m({}),f("builtin"),x(E),["custom","text","map"].includes(E)&&(b(!0),g(void 0)),s==null||s(E),n==null||n()},F=E=>{j(null),m({}),f("builtin"),g(void 0);const M=he.resolveMultiInputTypeFromVisual(E);if(M==="multiple"&&E.slots&&E.slots.length>0){D();const R=he.createCardsFromSlots(E.slots,E,h);k(R),R[0]&&w(R[0]),n==null||n();return}else x("custom"),N({type:"component",visualType:M,url:E.url,componentName:E.name,icon:E.icon,pluginChartType:E.chartType,minInputs:E.minInputs,maxInputs:E.maxInputs});s==null||s("custom",E),n==null||n()},I=E=>{const M={type:"default",id:E.id,name:E.name};c(M)},y=E=>{const M={type:"custom",id:E.name,url:E.url,icon:E.icon,name:E.name};c(M)};return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"mb-2 flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[e.jsx(qe.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search charts",value:r,onChange:E=>o(E.target.value),className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"})]}),e.jsxs("div",{className:"max-h-[360px] overflow-y-auto pr-1",children:[S.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:S.map(E=>e.jsx(Bn,{chartType:E.id,chartName:E.name,isCustom:!1,isStarred:d("default",E.id),onSelect:()=>A(E.id),onToggleStar:()=>I(E)},E.id))}),L.length>0&&e.jsxs(e.Fragment,{children:[S.length>0&&e.jsxs("div",{className:"my-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom charts"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-muted-foreground/70",children:L.length})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:L.map((E,M)=>e.jsx(Bn,{chartName:E.name,isCustom:!0,pluginName:E.pluginName,isStarred:d("custom",E.name),onSelect:()=>F(E),onToggleStar:()=>y(E)},`${E.url}-${E.name}-${M}`))})]}),u&&e.jsx("div",{className:"mt-3 py-4 text-center text-[11px] text-muted-foreground",children:"Loading custom charts…"}),S.length===0&&L.length===0&&!u&&e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"No charts found"})]})]})}function Oo({selectedChart:s,onChartChange:n}){var L,A,F,I;const r=t.useEditorStore(y=>y.card),o=t.useEditorStore(y=>y.frame),i=t.useEditorStore(y=>y.isDevMode),{replaceFrameCards:d,clearModeDrafts:c,initializeModeDrafts:l,setIsDevMode:u}=t.useEditorActions(),x=v.useMemo(()=>he.findCustomVisualConfigCard(o,r),[o,r]),{manifest:m}=a.useCustomVisual(((L=x==null?void 0:x.customCardPreferences)==null?void 0:L.url)||""),b=v.useMemo(()=>{var y;return(y=m==null?void 0:m.visuals)==null?void 0:y.find(E=>{var M;return E.name===((M=x==null?void 0:x.customCardPreferences)==null?void 0:M.componentName)})},[m,(A=x==null?void 0:x.customCardPreferences)==null?void 0:A.componentName]),h=he.resolveMultiInputType(x,b)==="multiple",p=a.useEffectiveEditorCardType(),j=h?p:s??r.type,N=(F=r==null?void 0:r.customCardPreferences)==null?void 0:F.componentName,f=(I=x==null?void 0:x.customCardPreferences)==null?void 0:I.componentName,g=h&&!!f,k=v.useMemo(()=>{const y=a.chartTypes.find(E=>E.id===j);return y?y.label:j==="custom"?N||"Custom Visual":"Select chart type"},[j,N]),D=v.useMemo(()=>{const y=a.chartTypes.find(E=>E.id===j);if(y){const E=y.icon;return e.jsx(E,{className:"h-4 w-4"})}if(j==="custom"&&N){const E=a.getAutoDetectedChartIcon(N);return E||e.jsx(Ls,{chartName:N,isCustom:!0,className:"h-4 w-4"})}return e.jsx(kr,{className:"h-4 w-4"})},[j,N]);return{displayChartType:j,displayLabel:k,displayIcon:D,showBadge:g,badgeLabel:f,isMultiInputContext:h,handleChartSelect:y=>{n==null||n(y)},handleClearCustomVisual:y=>{y.stopPropagation();const E={...r,type:"bar",sql:"",python:"",config:void 0,queryConfig:void 0,customCfg:void 0,preferences:{},customCardPreferences:void 0,title:"Chart",tabTitle:"Chart",description:void 0,info:void 0};d([E]),c(),l(E),i&&u(!0),n==null||n("bar")}}}function Bo({selectedChart:s,onChartChange:n,variant:r="ghost",className:o}){const[i,d]=v.useState(!1),{displayLabel:c,displayIcon:l,showBadge:u,badgeLabel:x,handleChartSelect:m,handleClearCustomVisual:b}=Oo({selectedChart:s,onChartChange:n}),h=r==="header";return e.jsxs("div",{className:t.cn("relative w-full",o),children:[e.jsxs(t.Popover,{open:i,onOpenChange:d,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:h?e.jsxs("button",{type:"button",role:"combobox","aria-expanded":i,className:"flex h-9 w-full items-center justify-between gap-2 border-b border-border bg-card px-3 text-left transition-colors hover:bg-muted/50 focus:outline-none focus-visible:bg-muted/50",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l,e.jsx("span",{className:"truncate text-[12px] font-medium text-foreground",children:c})]}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180")})]}):e.jsxs(t.Button,{size:"xs",variant:r,role:"combobox","aria-expanded":i,className:t.cn("w-full justify-between gap-2",r==="ghost"&&"border border-border/70 bg-background text-foreground/90",r==="outline"&&"border-border/70 bg-background text-foreground/90",r==="secondary"&&"text-foreground"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l,e.jsx("span",{className:"truncate",children:c})]}),e.jsx(le.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-70"})]})}),e.jsx(t.PopoverContent,{className:"w-[360px] p-3",align:"start",onOpenAutoFocus:p=>p.preventDefault(),children:e.jsx(ga,{onChartSelect:p=>m(p),onClose:()=>d(!1)})})]}),u&&e.jsxs("div",{className:"absolute right-10 top-1/2 z-10 flex max-w-[140px] -translate-y-1/2 items-center gap-1 rounded-full border bg-background py-0.5 pl-2 pr-1 text-[10px] text-muted-foreground shadow-sm",title:x,children:[e.jsx(a.Layers,{className:"h-2.5 w-2.5 shrink-0"}),e.jsx("span",{className:"truncate",children:x}),e.jsx("button",{onClick:b,className:"rounded-full p-0.5 hover:bg-muted",title:"Clear custom visual",children:e.jsx(le.X,{className:"h-2.5 w-2.5"})})]})]})}const Rt={table:t.Table2,matrixTable:a.Grid3x3,bar:a.ChartColumnIncreasing,line:a.ChartLine,stackedBar:a.ChartColumnStacked,stackedLine:a.MdStackedLineChart,scatter:a.ChartScatter,bubble:a.TbChartBubble,pie:a.ChartPie,doughnut:a.Donut,kpi:a.TiSortNumerically,treemap:a.TbChartTreemap,bullet:a.BulletChartIcon,funnel:a.TbChartFunnel,tornado:a.Tornado,heatmap:a.Grid3x3,range:a.ChartNoAxesGantt,radar:a.Radar,polarArea:a.PiChartPolar,text:a.BookType,map:a.Map},qt={table:"Table",matrixTable:"Matrix Table",bar:"Bar Chart",line:"Line Chart",stackedBar:"Stacked Bar",stackedLine:"Stacked Line",scatter:"Scatter",bubble:"Bubble",pie:"Pie Chart",doughnut:"Donut",kpi:"KPI",treemap:"Treemap",bullet:"Bullet",funnel:"Funnel",tornado:"Tornado",heatmap:"Heatmap",range:"Range",radar:"Radar",polarArea:"Polar Area",text:"Text",map:"Map"},ba=[{id:"table"},{id:"bar"},{id:"line"},{id:"pie"},{id:"kpi"},{id:"doughnut"}],ja=6;function Vo({selectedChart:s,onChartChange:n}){var D,w;const[r,o]=v.useState(!1),i=t.useEditorStore(S=>S.card),{setCardType:d,setCardPreferences:c}=t.useEditorStore(S=>S.actions),{setCardCustomCfg:l,setCustomCardPreferences:u,setQueryConfig:x,replaceFrameCards:m,clearModeDrafts:b,initializeModeDrafts:h}=t.useEditorActions(),{starredCharts:p}=a.useStarredChartsStore(),{data:j=[]}=a.useCustomVisualsQuery(),N=t.useEditorStore(S=>S.isDevMode),f=v.useMemo(()=>{const S=p.filter(I=>I.type==="default"?zt(I.id,{isDevMode:N}):j.some(y=>y.name===I.id)),L=new Set(S.map(I=>I.id)),A=ba.filter(I=>!L.has(I.id)&&zt(I.id,{isDevMode:N}));return[...S.map(I=>({id:I.id,label:I.name,icon:I.type==="default"?Rt[I.id]:void 0,isCustom:I.type==="custom",url:I.url})),...A.map(I=>({id:I.id,label:qt[I.id]??I.id,icon:Rt[I.id],isCustom:!1}))].slice(0,ja)},[p,j,N]),g=s==="custom"&&((D=i==null?void 0:i.customCardPreferences)==null?void 0:D.componentName);return f.some(S=>{var L;return S.isCustom?g&&((L=i==null?void 0:i.customCardPreferences)==null?void 0:L.componentName)===S.id:s===S.id})||(s==="custom"?(w=i==null?void 0:i.customCardPreferences)!=null&&w.componentName:qt[s]),e.jsxs("div",{className:"px-4 pb-3 pt-4",children:[e.jsx("p",{className:"pb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Chart type"}),e.jsx(va,{selectedChart:s,onChartChange:n,compactMore:!0})]})}function va({selectedChart:s,onChartChange:n,compactMore:r=!1,responsiveCompact:o=!1}){var F,I;const[i,d]=v.useState(!1),c=t.useEditorStore(y=>y.card),{setCardType:l,setCardPreferences:u}=t.useEditorStore(y=>y.actions),{setCardCustomCfg:x,setCustomCardPreferences:m,setQueryConfig:b,replaceFrameCards:h,clearModeDrafts:p,initializeModeDrafts:j}=t.useEditorActions(),{starredCharts:N}=a.useStarredChartsStore(),{data:f=[]}=a.useCustomVisualsQuery(),g=t.useEditorStore(y=>y.isDevMode),k=((F=c==null?void 0:c.customCardPreferences)==null?void 0:F.componentName)??null,D=v.useMemo(()=>{const y=N.filter(C=>C.type==="default"?zt(C.id,{isDevMode:g}):f.some(V=>V.name===C.id)),E=new Set(y.map(C=>C.id)),M=ba.filter(C=>!E.has(C.id)&&zt(C.id,{isDevMode:g})),T=[...y.map(C=>({id:C.id,label:C.name,icon:C.type==="default"?Rt[C.id]:void 0,isCustom:C.type==="custom",url:C.url})),...M.map(C=>({id:C.id,label:qt[C.id]??C.id,icon:Rt[C.id],isCustom:!1}))];if(!T.some(C=>C.isCustom?s==="custom"&&C.id===k:C.id===s))if(s==="custom"&&k){const C=f.find(V=>V.name===k);C&&T.unshift({id:C.name,label:C.name,icon:void 0,isCustom:!0,url:C.url})}else s&&Rt[s]&&zt(s,{isDevMode:g})&&T.unshift({id:s,label:qt[s]??s,icon:Rt[s],isCustom:!1});return T.slice(0,ja)},[N,f,s,k,g]),w=s==="custom"&&k,S=y=>{if(y.isCustom){const E=f.find(R=>R.name===y.id);if(!E)return;x(null),u({}),b(void 0);const M=he.resolveMultiInputTypeFromVisual(E);if(M==="multiple"&&E.slots&&E.slots.length>0){p();const R=he.createCardsFromSlots(E.slots,E,c);h(R),R[0]&&j(R[0]);return}l("custom"),m({type:"component",visualType:M,url:E.url,componentName:E.name,icon:E.icon,pluginChartType:E.chartType,minInputs:E.minInputs,maxInputs:E.maxInputs}),n("custom");return}n(y.id)},L=D.some(y=>{var E;return y.isCustom?w&&((E=c==null?void 0:c.customCardPreferences)==null?void 0:E.componentName)===y.id:s===y.id}),A=L?"More":s==="custom"?((I=c==null?void 0:c.customCardPreferences)==null?void 0:I.componentName)||"Custom":qt[s]||"More";return e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"inline-flex h-7 items-center overflow-hidden rounded-control border border-input bg-background",children:[D.map(y=>{var T;const E=y.icon,M=y.isCustom?w&&((T=c==null?void 0:c.customCardPreferences)==null?void 0:T.componentName)===y.id:s===y.id;return e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:()=>S(y),"aria-label":y.label,"aria-pressed":!!M,className:t.cn("flex h-full w-7 items-center justify-center text-foreground/65 transition-colors hover:bg-muted/50 hover:text-foreground",o&&!M&&"hidden @[800px]:flex",M&&"bg-foreground/[0.08] font-medium text-foreground"),children:[E?e.jsx(E,{className:"h-3.5 w-3.5"}):e.jsx(Ls,{chartName:y.label,isCustom:!0,className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:y.label})]})}),e.jsx(t.TooltipContent,{side:"bottom",children:y.label})]},`${y.isCustom?"custom":"default"}-${y.id}`)}),e.jsxs(t.Popover,{open:i,onOpenChange:d,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs("button",{type:"button","aria-label":r?"More chart types":A,className:t.cn("inline-flex h-full items-center gap-1 border-l border-input transition-colors hover:bg-muted/50",r?"w-7 justify-center":"px-2 text-[12px]",!r&&(L?"text-muted-foreground":"text-foreground")),children:[!r&&e.jsx("span",{className:"truncate",children:A}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",i&&"rotate-180"),strokeWidth:1.75})]})}),e.jsx(t.PopoverContent,{className:"w-[360px] p-3",align:"end",onOpenAutoFocus:y=>y.preventDefault(),children:e.jsx(ga,{onChartSelect:y=>{n(y),d(!1)},onClose:()=>d(!1)})})]})]})})}function _o(){const s=t.useEditorStore(u=>{var x,m;return(m=(x=u.card.preferences)==null?void 0:x.chartOptions)==null?void 0:m.indexAxis}),n=t.useEditorStore(u=>u.card.type),{setChartOrientation:r,setCardPreferences:o}=t.useEditorStore(u=>u.actions),i=u=>{if(r(u),n!=="bullet")return;const x=u==="y"?"horizontal":"vertical",m=t.useEditorStore.getState().card.preferences,b={...m||{},bulletConfig:{...(m==null?void 0:m.bulletConfig)||{},orientation:x}};o(b)};function d(){const u=s??"x",x=()=>{i(u==="x"?"y":"x")};return e.jsx(a.IconButton,{onClick:x,tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:u==="x"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(xs,{className:"h-3.5 w-3.5"})})}function c(){const u=()=>{i(s==="y"||s===void 0?"x":"y")};return e.jsx(a.IconButton,{onClick:u,tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:s==="y"||s===void 0?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(xs,{className:"h-3.5 w-3.5"})})}function l(){const u=s??"y",x=()=>{i(u==="y"?"x":"y")};return e.jsx(a.IconButton,{onClick:x,tooltip:"Chart Orientation",className:"h-7 w-7 px-0",children:u==="y"?e.jsx(xs,{className:"h-3.5 w-3.5"}):e.jsx(hs,{className:"h-3.5 w-3.5"})})}return e.jsx(e.Fragment,{children:n==="funnel"?c():n==="bullet"?l():d()})}function Fs({className:s,triggerVariant:n="icon",label:r="Display options"}){var f,g,k,D,w,S,L,A,F,I;const o=t.useEditorStore(y=>y.card),{setCardPreferences:i,updateCardInFrame:d,setCard:c}=t.useEditorActions(),[l,u]=v.useState(!1),x=((g=(f=o.preferences)==null?void 0:f.displayOptions)==null?void 0:g.showFilterInfo)??!0,m=((D=(k=o.preferences)==null?void 0:k.displayOptions)==null?void 0:D.showCardToolbar)??!0,b=((S=(w=o.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showChrome)??!0,h=((A=(L=o.preferences)==null?void 0:L.displayOptions)==null?void 0:A.allowScroll)??!0,p=((I=(F=o.preferences)==null?void 0:F.displayOptions)==null?void 0:I.showInlineFilterBar)??!0,j=(y,E)=>{var R;const M={...o.preferences,displayOptions:{...(R=o.preferences)==null?void 0:R.displayOptions,[y]:E}};i(M);const T={...o,preferences:M};c(T),d(T)},N=[{option:"showFilterInfo",label:"Filter info",hint:"Badge",checked:x},{option:"showCardToolbar",label:"Card toolbar",hint:"Hover actions",checked:m},{option:"showChrome",label:"Card chrome",hint:"Frame and padding",checked:b},{option:"allowScroll",label:"Allow scroll",hint:"Content scroll",checked:h},{option:"showInlineFilterBar",label:"Inline filter bar",hint:"On-card filters",checked:p}];return e.jsx("div",{className:t.cn("flex items-center",s),children:e.jsxs(a.DropdownMenu,{modal:!1,open:l,onOpenChange:u,children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:n==="menu"?e.jsxs(t.Button,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[e.jsx(qe.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:r})]}):e.jsx(a.IconButton,{className:"h-7 w-7 p-0",tooltip:"Display Options",children:e.jsx(t.SlidersHorizontal,{className:"h-3.5 w-3.5"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"w-64",children:[e.jsx("p",{className:"px-2 pb-1.5 pt-1 text-[11px] text-muted-foreground",children:"Changes apply to dashboard view only"}),N.map(y=>e.jsxs(a.DropdownMenuCheckboxItem,{checked:y.checked,onCheckedChange:E=>j(y.option,E),onSelect:E=>E.preventDefault(),className:"[&_svg]:h-3.5 [&_svg]:w-3.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.label}),e.jsx("span",{className:"ml-3 shrink-0 text-[11px] text-muted-foreground",children:y.hint})]},y.option))]})]})})}function ya(s,n){var u,x;const r=s.qualifiedFieldName||s.name,o=s.qualifiedFieldName?s.qualifiedFieldName.split(".").slice(0,-1).join("."):s.qualifiedEntityName||s.entityName,i=n.connectionId||((u=n.dataSource)==null?void 0:u.connectionId)||"",d=a.buildFilterFieldMeta(s),c=a.buildFilterSemanticContext(n.dataSource,{connectionId:i,connectionType:(x=n.dataSource)==null?void 0:x.connectionType},s),l=a.getFilterSourceDatabase(n.dataSource,c,s)||"";return{column:r,title:a.getFieldDisplayLabel(s),dataType:s.dataType,...s.nativeDataType?{nativeDataType:s.nativeDataType}:{},table:s.entityName||"",database:l,qualifiedTableName:o,connectionId:i,operation:"in",sql:"",fieldMeta:d,semanticContext:c}}function Rs({className:s,triggerVariant:n="icon",label:r="Inline filters"}){const[o,i]=v.useState(!1),d=t.useEditorStore(S=>S.card),c=t.useEditorStore(S=>S.selectedConnectionId),{tokenProps:l}=a.useSemaphorContext(),{setCard:u}=t.useEditorActions(),x=t.useDashboardStore(S=>S.actions.removeCardInlineFilterValue),m=t.useDashboardStore(S=>S.actions.setCardInlineFilterValue),b=t.useEditorStore(S=>S.actions.removeCardInlineFilterValue),h=t.useEditorStore(S=>S.actions.setCardInlineFilterValue),p=t.useDashboardStore(S=>S.isVisualEditing),j=(d==null?void 0:d.inlineFilters)||[],N=a.useTimezone()??void 0;function f(S){if(j.find(F=>a.doesStoredFilterMatchField(F,S)))return;const A={id:ye.v4(),...ya(S,{dataSource:d==null?void 0:d.dataSource,connectionId:c}),width:250};u({...d,inlineFilters:[...j,A]})}function g(S){const L=j.filter(A=>A.id!==S);u({...d,inlineFilters:L}),p?b(d.id,S):x(d.id,S)}function k(S,L){const A=j.map(E=>E.id===S?{...E,...L}:E);if(u({...d,inlineFilters:A}),!(Object.prototype.hasOwnProperty.call(L,"defaultValues")||Object.prototype.hasOwnProperty.call(L,"defaultDateFilter")))return;const I=A.find(E=>E.id===S);if(!I)return;const y=t.buildFilterValueFromDefaults(I,N);y?p?h(d.id,y):m(d.id,y):p?b(d.id,S):x(d.id,S)}if(!["bar","line","pie","doughnut","table","detailTable","stackedBar","stackedLine","horizontalBar","radar","polarArea","scatter","bubble","funnel","aggregateTable","custom"].includes(d==null?void 0:d.type))return null;const w=n==="menu";return e.jsx("div",{className:t.cn("flex items-center gap-1",w&&"w-full",s),children:e.jsxs(t.Popover,{open:o,onOpenChange:i,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:w?e.jsxs(t.Button,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[e.jsx(En,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:r}),j.length>0&&e.jsx("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:j.length})]}):e.jsxs(a.IconButton,{tooltip:"Add Inline Filter",className:t.cn("relative h-7 w-7 px-0",{"text-primary":j.length>0}),children:[e.jsx(En,{className:"h-3.5 w-3.5"}),j.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] font-medium text-primary-foreground",children:j.length})]})}),e.jsx(t.PopoverContent,{align:"end",className:t.cn("w-80 p-0",w&&"z-[60]"),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"border-b px-4 py-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Inline Filters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"On-card filters for fast, focused exploration."})]}),e.jsx("div",{className:"flex h-[320px] min-h-0 flex-col overflow-hidden",children:e.jsx(a.DndContext,{collisionDetection:a.closestCenter,children:e.jsx(a.SortableContext,{items:[],strategy:a.verticalListSortingStrategy,children:e.jsx(a.FieldsList,{context:"inline-filter",onFieldSelect:f,inlineFilters:j})})})}),j.length>0&&e.jsxs("div",{className:"border-t px-4 py-3",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Active Filters"}),e.jsx("div",{className:"space-y-1",children:j.map(S=>e.jsx(Yo,{filter:S,onUpdate:L=>k(S.id,L),onRemove:()=>g(S.id)},S.id))})]})]})})]})})}function Yo({filter:s,onUpdate:n,onRemove:r}){return e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-muted px-2 py-1.5 text-sm",children:[e.jsx("span",{className:"truncate",title:s.column,children:s.title}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(a.CustomFilterPopover,{filter:s,variant:"inline",onAccept:o=>n(o),trigger:e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",title:"Configure filter",children:e.jsx(a.Settings2,{className:"h-3 w-3"})})}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 hover:bg-destructive/10 hover:text-destructive",onClick:r,children:e.jsx(le.X,{className:"h-3 w-3"})})]})]})}const zo={metric_selector:"Displayed metric",field_selector:"Group by field",aggregation_selector:"Aggregation",grain_selector:"Time grain"};function qo(s,n){return s&&typeof s=="object"&&"label"in s&&typeof s.label=="string"&&s.label.trim().length>0?s.label:n||null}const $o={metric_selector:"config_metric_selector",field_selector:"config_field_selector",aggregation_selector:"config_aggregation",grain_selector:"config_grain"};function ns(s,n){return`${s}:${n}`}function Ko(s,n,r,o,i){const d=new Set(r.filter(l=>l.target!=="sql_param"&&l.target!=="presentation_currency").map(l=>ns(l.controlId,l.target))),c=n.map(l=>{const u=t.getCompatibleBindingTargetOptions({card:s,control:l,matrixSpec:o,resolveDataType:i}).map(h=>h.value),x=$o[l.type],b=[...x&&u.includes(x)?[x]:[],...u.filter(h=>h!==x)].find(h=>!d.has(ns(l.id,h)));return b?{controlId:l.id,target:b}:null}).find(Boolean);return c?{controlId:c.controlId,target:c.target,mapping:{}}:null}function Uo({card:s,dashboardControls:n,bindings:r,onChange:o,availableFieldChoices:i,matrixFieldCatalog:d=[],availableMetricChoices:c,suppressTransientStaleState:l=!1,matrixSpec:u,matrixPresentation:x}){const m=v.useMemo(()=>x??(u?ft.createMatrixConfig(u).presentation:void 0),[u,x]);function b(I){return!u||!m?[]:It.getMatrixBindingTargets(u,I,f).map(y=>({id:y.id,label:y.kind==="measure"?`${ft.getMatrixMeasureLabel(y.measure,m)} (${y.measure.aggregate})`:`${y.axis==="rows"?"Rows":"Columns"}: ${ft.getMatrixLevelLabel(y.level,m)}`}))}const h=[...n,...s.controls||[]],[p,j]=v.useState({}),N=It.extractSqlParamReferences({sql:s.sql,controlBindings:s.controlBindings});function f(I){return u?ye.matrixAuthoringDataType(I,u.source,d):I.dataType}const g=t.getBindingTargetSuggestions(s,u,f),k=new Set(r.map(I=>ns(I.controlId,I.target))),D=h.some(I=>t.getCompatibleBindingTargetOptions({card:s,control:I,matrixSpec:u,resolveDataType:f}).some(y=>!k.has(ns(I.id,y.value)))),w=l?0:r.reduce((I,y)=>{const E=S(y.target),M=Object.values(y.mapping).filter(T=>{const R=y.target==="config_metric_selector"||y.target==="config_field_selector"?typeof T=="string"?T:T==null?void 0:T.id:typeof T=="string"?T:void 0;return typeof R=="string"&&!E.some(C=>C.value===R)}).length;return I+M},0);function S(I){var y,E,M,T;switch(I){case"config_metric_selector":return c?c.filter(R=>!!R.target).map(R=>({value:R.target.id,label:R.target.label||R.option.label,target:R.target})):u&&m?b(I).map(R=>({value:R.id,label:R.label,target:{kind:"matrix_instance",id:R.id}})):((E=(y=s.config)==null?void 0:y.metricColumns)==null?void 0:E.map(R=>({value:R.id,label:R.label||R.id,target:R})))||[];case"config_field_selector":return i?i.filter(R=>!!R.target).map(R=>({value:R.target.id,label:R.target.label||R.option.label,target:R.target})):u&&m?b(I).map(R=>({value:R.id,label:R.label,target:{kind:"matrix_instance",id:R.id}})):((T=(M=s.config)==null?void 0:M.groupByColumns)==null?void 0:T.map(R=>({value:R.id,label:R.label||R.id,target:R})))||[];case"config_aggregation":return(g.config_aggregation||[]).map(R=>({value:R,label:R}));case"config_grain":return(g.config_grain||[]).map(R=>({value:R,label:R.charAt(0).toUpperCase()+R.slice(1)}));default:return[]}}const L=(I,y)=>{o(r.map((E,M)=>M!==I?E:y(E)))},A=I=>{o(r.filter((y,E)=>E!==I))},F=()=>{const I=Ko(s,h,r,u,f);I&&o([...r,I])};if(typeof s.sql=="string"&&s.sql.trim().length>0){const I=N.map(({controlId:y,paramId:E})=>{const M=h.find(T=>T.id===y);return M?{id:y,paramId:E,label:M.label,reference:`[[param.${E}]]`}:{id:y,paramId:E,label:y,reference:`[[param.${E}]]`}});return e.jsx("div",{className:"space-y-2",children:I.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"This card is currently using raw SQL. Reference a control directly in the SQL editor with syntax like `[[param.metric]]`."}):I.map(y=>e.jsx("div",{className:"rounded-md border p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:y.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referenced in SQL"})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted/40 px-2 py-1",children:[e.jsx("code",{className:"text-xs",children:y.reference}),e.jsx(a.CopyButton,{text:y.reference,ariaLabel:`Copy ${y.reference}`})]})]})},`${y.id}:${y.paramId}`))})}return e.jsxs("div",{className:"space-y-4",children:[w>0?e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950",children:[e.jsx(a.CircleAlert,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{children:[w," ",w===1?"mapping needs":"mappings need"," attention before save. Replace each missing target or choose Not mapped."]})]}):null,r.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"This card is not using any controls yet."}):r.map((I,y)=>{const E=g[I.target]||[],M=h.find(Y=>Y.id===I.controlId),T=M?t.ensureManualSource(M):null,R=(T==null?void 0:T.source.kind)==="manual"?T.source.options:[],C=S(I.target),V=b(I.target),P=I.matrixTargetId!==void 0&&!V.some(Y=>Y.id===I.matrixTargetId),O=Array.from(new Set([...R.map(Y=>Y.value),...Object.keys(I.mapping)])).map(Y=>{const $=R.find(Q=>Q.value===Y);return{value:Y,label:($==null?void 0:$.label)||Y}}),B=`${I.controlId}-${I.target}-${y}`,_=p[B]??y===0,z=Object.keys(I.mapping).length,q=M!=null&&M.type?zo[M.type]||M.type:null;return e.jsxs(a.Collapsible,{open:_,onOpenChange:Y=>j($=>({...$,[B]:Y})),className:"rounded-md border",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 text-left",children:[_?e.jsx(le.ChevronDown,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(qe.ChevronRight,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:(M==null?void 0:M.label)||"Control"}),q?e.jsx(a.Badge,{variant:"secondary",className:"shrink-0 text-[11px] font-normal text-muted-foreground",children:q}):null]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:z>0?`${z} mapped`:"No mappings yet"})]})]})}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>A(y),children:e.jsx(a.Trash2,{className:"h-4 w-4"})})]}),e.jsxs(a.CollapsibleContent,{className:"space-y-3 border-t px-3 pb-3 pt-2",children:[u?e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",htmlFor:`matrix-target-${B}`,children:"Matrix target"}),e.jsxs(t.Select,{value:I.matrixTargetId??"__none__",onValueChange:Y=>L(y,$=>{const{matrixTargetId:Q,...U}=$;return Y==="__none__"?U:{...U,matrixTargetId:Y}}),children:[e.jsx(t.SelectTrigger,{id:`matrix-target-${B}`,"aria-label":"Matrix target",children:e.jsx(t.SelectValue,{placeholder:"Choose target"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"__none__",children:V.length===1?`Automatic: ${V[0].label}`:"Choose target"}),P?e.jsx(t.SelectItem,{value:I.matrixTargetId,disabled:!0,children:"Missing target"}):null,V.map(Y=>e.jsx(t.SelectItem,{value:Y.id,children:Y.label},Y.id))]})]}),P?e.jsx("p",{role:"alert",className:"text-xs text-amber-700",children:"The saved Matrix target is no longer available."}):V.length===0?e.jsx("p",{role:"alert",className:"text-xs text-muted-foreground",children:"No eligible Matrix target."}):!I.matrixTargetId&&V.length>1?e.jsx("p",{role:"alert",className:"text-xs text-amber-700",children:"Select a Matrix target."}):null]}):null,O.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"Add choices to this control first so you can decide what each choice changes in the card."}):C.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:"No matching targets are available for this binding yet."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs",children:"Map each choice"}),e.jsx("div",{className:"space-y-2",children:O.map(Y=>{const $=I.mapping[Y.value],Q=I.target==="config_metric_selector"||I.target==="config_field_selector"?typeof $=="string"?$:$==null?void 0:$.id:typeof $=="string"?$:void 0,U=!l&&typeof Q=="string"&&!C.some(ee=>ee.value===Q),J=qo($,Q),X=Q&&U?[...C,{value:Q,label:"Needs remap",target:$}]:C;return e.jsxs("div",{className:"grid gap-2 rounded-md border p-2 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-[11px] text-muted-foreground",children:"Viewer picks"}),e.jsx("div",{className:"rounded-md bg-muted/50 px-3 py-2 text-sm",children:Y.label})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-[11px] text-muted-foreground",children:"Switch to"}),e.jsxs(t.Select,{value:Q||"__none__",onValueChange:ee=>L(y,me=>{if(me.target==="config_metric_selector"){const ve={...me.mapping};if(ee==="__none__")delete ve[Y.value];else{const je=X.find(Re=>Re.value===ee);je!=null&&je.target?ve[Y.value]=je.target:delete ve[Y.value]}return{...me,mapping:ve}}if(me.target==="config_field_selector"){const ve={...me.mapping};if(ee==="__none__")delete ve[Y.value];else{const je=X.find(Re=>Re.value===ee);je!=null&&je.target?ve[Y.value]=je.target:delete ve[Y.value]}return{...me,mapping:ve}}const be={...me.mapping};return ee==="__none__"?delete be[Y.value]:be[Y.value]=ee,{...me,mapping:be}}),children:[e.jsx(t.SelectTrigger,{children:e.jsx(t.SelectValue,{placeholder:"Choose what this should use"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"__none__",children:"Not mapped"}),X.map(ee=>e.jsx(t.SelectItem,{value:ee.value,children:ee.label},ee.value))]})]}),U?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-amber-700",children:[e.jsx(a.CircleAlert,{className:"h-3 w-3 shrink-0"}),e.jsxs("span",{children:["Needs remap",J?` · Previously: ${J}`:""]})]}):null]})]},`${I.controlId}-${I.target}-${Y.value}`)})}),E.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Available choices for this card: ",E.join(", ")]})]})]})]},B)}),D?e.jsxs(t.Button,{type:"button",variant:"outline",size:"sm",onClick:F,children:[e.jsx(a.Plus,{className:"mr-2 h-4 w-4"}),"Add another control response"]}):null]})}function Go(s,n,r){const{eligibleTargets:o}=a.getCardCurrencyPresentationTargets(s,n,r),i=a.getCardCurrencyPresentationFields(s),d=new Map(i.map(l=>[l.id,l])),c=new Map(a.resolveMatrixCardMeasures(s,r).map(l=>[l.measureId,l.label]));return o.map(l=>{var u;return{key:a.currencyPresentationTargetKey(l),label:l.kind==="metric"?((u=d.get(l.metricId))==null?void 0:u.label)||l.metricId:l.kind==="column"?l.columnKey:c.get(l.measureId)||l.measureId,target:l}})}function Ho(s){return s?s.kind==="metric"?s.metricId:s.kind==="column"?s.columnKey:s.measureId:"invalid target"}function Qo({matrixCatalog:s,card:n,dashboardControls:r,resultColumnKeys:o=[],bindings:i,onChange:d}){const c=[...r,...n.controls||[]],l=c.filter(a.isCurrencyPresentationControl),u=v.useMemo(()=>Go(n,o,s),[n,o,s]),x=v.useMemo(()=>a.getCardCurrencyPresentationTargets(n,o,s),[n,o,s]),m=a.diagnoseCurrencyPresentationBindings({bindings:i,controls:c,...x}),{preferences:b,resolveBoundCurrency:h}=a.useCardNumericPresentation(n,o,s),[p,j]=v.useState(""),[N,f]=v.useState(""),g=u.find(w=>w.key===N),k=!!(p&&g)&&!i.some(w=>w.presentationTarget&&g&&a.currencyPresentationTargetKey(w.presentationTarget)===g.key),D=w=>{if(!b)return;const S=a.resolveCurrencyPresentationTargetFormat({card:n,target:w,resultColumnKeys:o,valueFormatPreferences:b,boundCurrency:h(w),matrixCatalog:s});if(S)return ea.formatNumericCanonical(1e3,S)};return l.length===0&&i.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a manual enum whose options are ISO currency codes to enable presentation currency bindings."}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h5",{className:"text-xs font-medium",children:"Currency presentation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Change only the display currency for an explicit metric or column."})]}),i.map((w,S)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-control border border-border/60 px-2 py-1.5 text-xs",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[w.controlId," →"," ",Ho(w.presentationTarget),w.presentationTarget?` · ${D(w.presentationTarget)??"unavailable"}`:null]}),e.jsx(t.Button,{variant:"ghost",size:"xs",onClick:()=>d(i.filter((L,A)=>A!==S)),children:e.jsx(a.Trash2,{className:"h-3.5 w-3.5"})})]},`${w.controlId}:${JSON.stringify(w.presentationTarget)}`)),m.length>0?e.jsx("div",{className:"space-y-1 text-xs text-destructive",children:m.map((w,S)=>e.jsxs("p",{children:[w.controlId?`${w.controlId}: `:"",w.code.split("_").join(" ")]},`${w.controlId||"binding"}:${w.code}:${S}`))}):null,e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_auto] gap-2",children:[e.jsxs(t.Select,{value:p,onValueChange:j,children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{placeholder:"Currency control"})}),e.jsx(t.SelectContent,{children:l.map(w=>e.jsx(t.SelectItem,{value:w.id,children:w.label},w.id))})]}),e.jsxs(t.Select,{value:N,onValueChange:f,children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{placeholder:"Target"})}),e.jsx(t.SelectContent,{children:u.map(w=>e.jsx(t.SelectItem,{value:w.key,children:w.label},w.key))})]}),e.jsx(t.Button,{variant:"outline",size:"xs",disabled:!k,onClick:()=>{g&&(d([...i,{controlId:p,target:"presentation_currency",presentationTarget:g.target}]),f(""))},children:e.jsx(a.Plus,{className:"h-3.5 w-3.5"})})]})]})}const Jo=[];function Ps({className:s,triggerVariant:n="icon",label:r="Controls"}){var B,_,z;const{handleOpenChange:o,preventPassiveDismissDuringCreate:i,resolvedOpen:d,setIsCreateFlowActive:c}=gt.useCreateFlowOverlayState({}),l=t.useEditorStore(q=>q.card),u=t.useEditorStore(q=>q.frame),x=t.useEditorStore(q=>q.queryResultColumns),m=t.useDashboardStore(q=>q.dashboard),h=t.useDashboardStore(q=>q.dashboard.controls)||Jo,{setCard:p,updateCardInFrame:j}=t.useEditorActions(),[N,f]=v.useState(null);v.useEffect(()=>{d&&!N&&(l!=null&&l.id)&&f(l.id)},[l==null?void 0:l.id,d,N]),v.useEffect(()=>{!d&&N!==null&&f(null)},[d,N]);const g=v.useMemo(()=>N?(u==null?void 0:u.cards.find(q=>q.id===N))||((l==null?void 0:l.id)===N?l:void 0):l,[l,u==null?void 0:u.cards,N]),k=(g==null?void 0:g.type)==="matrixTable"?(B=g.config)==null?void 0:B.matrix:void 0,D=v.useMemo(()=>d&&k?mr.matrixCatalogSources(k.spec,g==null?void 0:g.controlBindings):[],[d,k,g==null?void 0:g.controlBindings]),w=a.useMatrixSourceCatalog(D),S=v.useMemo(()=>w.catalog.map(q=>({...q.field,dataType:st.normalizeAnalyticsCatalogDataType(q.resolvedField.dataType)})),[w.catalog]),L=(g==null?void 0:g.controls)||[],A=g?t.collectDashboardControlIds(m,{excludeCardId:g.id}):h.map(q=>q.id),F=((g==null?void 0:g.controlBindings)||[]).filter(a.isStructuralControlBinding),I=((g==null?void 0:g.controlBindings)||[]).filter(a.isPresentationCurrencyBinding),y=a.buildCardControlUsageById({card:g,controls:L}),E={choices:t.getFieldSelectorChoicesForCard(g),targetMap:Object.fromEntries((((_=g==null?void 0:g.config)==null?void 0:_.groupByColumns)||[]).map(q=>[q.id,q]))},M={choices:t.getMetricSelectorChoicesForCard(g),targetMap:Object.fromEntries((((z=g==null?void 0:g.config)==null?void 0:z.metricColumns)||[]).map(q=>[q.id,q]))},T=E.choices.map(q=>({option:q,target:E.targetMap[q.value]})),R=M.choices.map(q=>({option:q,target:M.targetMap[q.value]})),C=(q,Y)=>{if(!g)return;const $=(Y==null?void 0:Y.type)==="rename"?t.applyControlMutationToCard(g,{type:"rename",oldId:Y.oldId,newId:Y.newId}):(Y==null?void 0:Y.type)==="remove"?t.applyControlMutationToCard(g,{type:"remove",controlId:Y.controlId}):g,Q={...$,controls:q,controlBindings:t.syncStructuralBindingsWithControls($.controlBindings,q)};j(Q),(l==null?void 0:l.id)===Q.id&&p(Q)},V=q=>{if(!g)return;const Y={...g,controlBindings:[...t.mergeConfigBindingsWithSqlParamBindings(q,(g.controlBindings||[]).filter($=>!a.isPresentationCurrencyBinding($))),...I]};j(Y),(l==null?void 0:l.id)===Y.id&&p(Y)},P=q=>{if(!g)return;const Y={...g,controlBindings:[...(g.controlBindings||[]).filter($=>!a.isPresentationCurrencyBinding($)),...q]};j(Y),(l==null?void 0:l.id)===Y.id&&p(Y)},O=n==="menu";return e.jsx("div",{className:t.cn("flex items-center gap-1",O&&"w-full",s),children:e.jsxs(t.Popover,{modal:!0,open:d,onOpenChange:o,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:O?e.jsxs(t.Button,{variant:"ghost",className:"h-auto w-full justify-start gap-2 rounded-sm px-2 py-1.5 text-[13px] font-normal",children:[e.jsx(t.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:r}),L.length+F.length>0&&e.jsx("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:L.length+F.length})]}):e.jsxs(a.IconButton,{tooltip:"Configure Controls",className:t.cn("relative h-7 w-7 px-0",{"text-primary":L.length>0||F.length>0}),children:[e.jsx(t.SlidersHorizontal,{className:"h-3.5 w-3.5"}),L.length+F.length>0&&e.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground",children:L.length+F.length})]})}),e.jsxs(t.PopoverContent,{className:t.cn("flex max-h-[85vh] w-[560px] max-w-[95vw] flex-col",O&&"z-[60]"),align:"end",onEscapeKeyDown:i,onPointerDownOutside:i,children:[e.jsxs("div",{className:"space-y-1 border-b pb-4",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Card-only controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add controls that belong only to this card, or decide how this card should respond to shared dashboard controls."}),g!=null&&g.sql?e.jsx("p",{className:"text-xs text-muted-foreground",children:"SQL cards reference controls explicitly with syntax like `[[param.wac_type]]`."}):null]}),e.jsx("div",{className:"flex-1 overflow-y-auto pt-5",children:e.jsxs("div",{className:"space-y-5 pr-1",children:[e.jsx(gt.ControlDefinitionListEditor,{scope:"card",card:g,controls:L,reservedControlIds:A,usageByControlId:y,availableFieldChoices:T,availableMetricChoices:R,onCreateFlowActiveChange:c,onChange:(q,Y,$)=>C(q,$),emptyMessage:"No card-scoped controls yet."}),e.jsxs("div",{className:"space-y-1 border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-medium",children:"How this card uses controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what each control changes in this card."})]}),g?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{card:g,dashboardControls:h,bindings:F,onChange:V,availableFieldChoices:k?void 0:T,availableMetricChoices:k?void 0:R,matrixSpec:k==null?void 0:k.spec,matrixPresentation:k==null?void 0:k.presentation,matrixFieldCatalog:S,suppressTransientStaleState:!!(k&&w.pending)}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Qo,{matrixCatalog:w.catalog,card:g,dashboardControls:h,resultColumnKeys:x,bindings:I,onChange:P})})]}):null]})})]})]})})}function Ca({showOrientation:s=!0,showGridStyle:n=!0,showInlineFilters:r=!0,showControls:o=!0,showDisplayOptions:i=!0}={}){const d=t.useEditorStore(p=>p.card),c=t.useEditorStore(p=>{var j,N;return(N=(j=p.card)==null?void 0:j.preferences)==null?void 0:N.chartOptions}),l=a.getChartGridStyle(c),{setChartGrid:u}=t.useEditorActions();function x(){const p=["xy","none","x","y"],N=(p.indexOf(l)+1)%p.length;u(p[N])}const m=s&&["line","bar","range","stackedBar","stackedLine","horizontalBar","funnel","bullet"].includes(d.type),b=n&&!["pie","doughnut","funnel","radar","polarArea","table","aggregateTable","pivotTable","detailTable","custom","kpi","text","map"].includes(d.type);return m||b||r||o||i?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center gap-2",children:[m&&e.jsx(e.Fragment,{children:e.jsx(_o,{})}),b&&e.jsxs(a.IconButton,{tooltip:"Grid Style",onClick:x,className:"h-7 w-7 px-0",children:[(l==="xy"||!l)&&e.jsx(a.Grid3x3,{className:"h-3.5 w-3.5"}),l==="x"&&e.jsx(Ds,{className:"h-3.5 w-3.5"}),l==="y"&&e.jsx(a.Rows3,{className:"h-3.5 w-3.5"}),l==="none"&&e.jsx(a.Square,{className:"h-3.5 w-3.5"})]}),r&&e.jsx(Rs,{}),o&&e.jsx(Ps,{}),i&&e.jsx(Fs,{})]}):null}function Wo({errorMessage:s,errorSql:n,onOpenInEditor:r,onDebugWithAssistant:o}){const{feedbackDialogOpen:i,setFeedbackDialogOpen:d,handleSendFeedback:c,feedbackPayload:l}=ha(s,n);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto px-4 py-0",children:e.jsx(rs,{error:s,errorSql:n,errorMessageClassName:"max-h-40",fillAvailableSqlHeight:!0,className:"max-h-none",onOpenInEditor:r,onDebugWithAssistant:o,onSendFeedback:c,showFeedbackButton:!0})}),e.jsx(a.FeedbackDialog,{open:i,onOpenChange:d,feedbackData:l,showDebugInfo:!0})]})}function Xo({isPreviewMode:s,onPreviewToggle:n,configCard:r}){var V,P,O,B,_;const o=t.useEditorStore(z=>z.frame),i=t.useEditorStore(z=>z.card),d=t.useEditorStore(z=>z.editorContext),c=(d==null?void 0:d.type)==="documentSection",{setFrame:l,setActiveTabCardId:u,setCard:x,updateCardInFrame:m,clearModeDrafts:b,initializeModeDrafts:h}=t.useEditorActions(),{manifest:p}=a.useCustomVisual(((V=r==null?void 0:r.customCardPreferences)==null?void 0:V.url)||""),j=(P=p==null?void 0:p.visuals)==null?void 0:P.find(z=>{var q;return z.name===((q=r==null?void 0:r.customCardPreferences)==null?void 0:q.componentName)}),f=he.resolveMultiInputType(r,j)==="multiple",g=(j==null?void 0:j.minInputs)??((O=r==null?void 0:r.customCardPreferences)==null?void 0:O.minInputs)??1,k=(j==null?void 0:j.maxInputs)??((B=r==null?void 0:r.customCardPreferences)==null?void 0:B.maxInputs),D=v.useMemo(()=>he.getCustomVisualInputCards({frame:o,configCard:r,isMultiInputVisual:f}),[o,r,f]),w=f?D.filter(Boolean).length:o.cards.length,S=c?!1:k?w<k:!0,L=w>Math.max(g||1,1),A=!!((_=r==null?void 0:r.customCardPreferences)!=null&&_.dataInputCardIds),F=(z,q)=>{z.dataTransfer.setData("tabIndex",q.toString())},I=z=>{z.preventDefault()},y=(z,q)=>{const Y=z.dataTransfer.getData("tabIndex");if(Y===q.toString())return;const $=Array.from(o.cards),[Q]=$.splice(parseInt(Y),1);$.splice(q,0,Q),l({...o,cards:$})};function E(z){const q=(r==null?void 0:r.id)===z;if(!(A&&q?o.cards.length>1:L))return;let $=o.cards.filter(X=>X.id!==z);f&&!A&&($=he.reindexSlotCards($));const Q=$[0],U={...o,cards:$,activeCardId:Q.id},J=z===i.id;J&&b(),l(U),u(Q.id),x(Q),J&&h(Q)}function M(z,q){if(!S)return;const Y={...o,cards:[...o.cards,q],activeCardId:z.id};l(Y),u(q.id)}function T(){if(c)return;if(f&&(r==null?void 0:r.id)===i.id){R(i);return}const z={...i,id:ye.v4(),title:`${i.title} Copy`,tabTitle:`${i.tabTitle||i.title} Copy`,customCardPreferences:i.customCardPreferences?{...i.customCardPreferences,slotIndex:f?Math.max(-1,...D.map((q,Y)=>he.getSlotIndexForCard(q,Y)))+1:i.customCardPreferences.slotIndex}:void 0};M(i,z)}function R(z){var J;if(c||!S)return;let q=f?"table":"bar",Y="Title",$="";const Q=f?Math.max(-1,...D.map((X,ee)=>he.getSlotIndexForCard(X,ee)))+1:w;if(f&&((J=j==null?void 0:j.slots)!=null&&J.length)){const X=he.getSlotDefinitionForIndex(j.slots,Q);X&&(q=he.getSlotExpectedChartType(X),Y=X.label||`Tab ${Q+1}`,$=X.description||"")}const U={dataSource:z.dataSource,connectionId:z.connectionId,lastSelectedDatabase:z.lastSelectedDatabase,lastSelectedSchema:z.lastSelectedSchema,lastSelectedTable:z.lastSelectedTable,lastSelectedDatamodelId:z.lastSelectedDatamodelId,id:ye.v4(),title:Y,tabTitle:Y,description:$,preferences:{onClickFilter:[{columnIndex:0,expression:""}],...q==="text"?{textVisualOptions:{richContent:t.createEmptyRichContent()}}:{}},type:q,sql:"",data:[],mode:"explorer",...f&&{customCardPreferences:{slotIndex:Q}}};M(z,U)}function C(z,q){return z.cards.length===1&&(q.displayTab===!0||q.displayTab===void 0)||z.activeCardId!==q.id&&(q.displayTab===!0||q.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const Y=q.displayTab===void 0?!1:!q.displayTab;x({...q,displayTab:Y}),m({...q,displayTab:Y})},children:q.displayTab===!0||q.displayTab===void 0?e.jsx(qe.Eye,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"}):e.jsx(a.EyeOff,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})}return e.jsx(t.TabsList,{variant:"underline",className:"group flex h-9 shrink-0 items-center justify-start gap-1 overflow-x-auto rounded-none border-b-0 border-t border-border bg-background px-4",children:e.jsxs("div",{className:"flex items-center gap-1",children:[o.cards.map((z,q)=>{var J,X;const Y=f?he.getSlotIndexForCard(z,q):-1,$=f&&((J=j==null?void 0:j.slots)!=null&&J.length)&&Y>=0?he.getSlotDefinitionForIndex(j.slots,Y):null,Q=$?(Array.isArray($.expectedType)?$.expectedType[0]:$.expectedType)||"table":z.type,U=f&&((X=j==null?void 0:j.slots)==null?void 0:X.length)&&j.slots.every(ee=>typeof ee.position=="number"||typeof ee.position=="string"&&!ee.position.includes("+"));return e.jsxs(t.TabsTrigger,{draggable:!f&&!c,onDragStart:f||c?void 0:ee=>F(ee,q),onDragOver:f||c?void 0:I,onDrop:f||c?void 0:ee=>y(ee,q),className:t.cn("inline-flex h-6 shrink-0 items-center gap-1.5 rounded-[5px] border px-2 text-[12px] font-normal text-muted-foreground transition-colors","mb-0 border-transparent pb-0","hover:bg-muted/40 hover:text-foreground","data-[state=active]:border-border data-[state=active]:bg-card data-[state=active]:text-foreground"),value:z.id,children:[f&&$?e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:a.getChartIconByType(Q,"size-3.5")}),e.jsx("span",{children:$.label||`Tab ${Y+1}`})]})}),e.jsx(t.TooltipContent,{side:"bottom",className:"w-64 p-3 text-left",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium",children:$.label}),$.description&&e.jsx("p",{className:"whitespace-normal break-words text-xs text-muted-foreground",children:$.description}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[$.expectedType&&e.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:Array.isArray($.expectedType)?$.expectedType.join(" / "):$.expectedType}),$.required&&e.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"Required"})]})]})})]})}):e.jsxs(e.Fragment,{children:[C(o,z),e.jsx(a.Editable,{enabled:o.activeCardId===z.id,text:z.tabTitle||z.title,onSave:ee=>{x({...i,tabTitle:ee}),m({...i,tabTitle:ee})},children:z.tabTitle||z.title},z.id)]}),!c&&o.activeCardId===z.id&&!U&&e.jsx(a.CopyPlus,{className:"h-3 w-3 text-muted-foreground hover:text-foreground",onClick:ee=>{ee.stopPropagation(),T()}}),!c&&o.activeCardId===z.id&&(A&&(r==null?void 0:r.id)===z.id?o.cards.length>1:L)&&e.jsx(le.X,{className:"h-3 w-3 text-muted-foreground hover:text-foreground",onClick:()=>E(z.id)})]},z.id)}),!c&&e.jsx(a.IconButton,{tooltip:"Add Card",className:"h-6 w-6 rounded-[5px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>R(i),disabled:!S,children:e.jsx(a.Plus,{className:"h-3 w-3"})}),f&&e.jsxs(a.Toggle,{pressed:s,onPressedChange:n,size:"sm",className:"ml-1 h-6 gap-1 rounded-[5px] px-2 text-[11px] data-[state=on]:bg-muted data-[state=on]:text-foreground","aria-label":"Toggle preview",children:[s?e.jsx(a.EyeOff,{className:"h-3 w-3"}):e.jsx(qe.Eye,{className:"h-3 w-3"}),e.jsx("span",{children:"Preview"})]})]})})}function Et({renderCardOverride:s,alwaysRenderOverride:n=!1}={}){var ze,Le,$e,we,oe;const r=a.useResolvedTemporalStylePreferences(),o=t.useEditorStore(te=>te.frame),i=t.useEditorStore(te=>te.card),[d,c]=v.useState(!1),l=v.useMemo(()=>he.findCustomVisualConfigCard(o,i),[o,i]),u=t.useEditorStore(te=>te.isSqlRunning);t.useEditorStore(te=>te.isDevMode);const{setFrame:x,setActiveTabCardId:m,setCard:b,setRunSql:h,mergeDraftsIntoCard:p,clearModeDrafts:j,initializeModeDrafts:N}=t.useEditorActions(),[f,g]=v.useState({}),[k,D]=v.useState(()=>new Set),{authToken:w}=a.useSemaphorContext(),S=t.getTokenParams(w==null?void 0:w.accessToken),{compiledAppearance:L}=ur.useAppearance(),A=v.useMemo(()=>a.buildCustomCardTheme(L),[L]),{getCard:F,manifest:I,isLoading:y}=a.useCustomVisual(((ze=l==null?void 0:l.customCardPreferences)==null?void 0:ze.url)||""),E=(Le=l==null?void 0:l.customCardPreferences)==null?void 0:Le.componentName,M=E?F(E):null,T=($e=I==null?void 0:I.visuals)==null?void 0:$e.find(te=>te.name===E),R=he.resolveMultiInputType(l,T),C=d&&R==="multiple"&&!!l,V=v.useMemo(()=>he.getCustomVisualInputCards({frame:o,configCard:l,isMultiInputVisual:!0}).map(ue=>(ue==null?void 0:ue.id)===i.id?i:ue),[o,l,i]),P=v.useMemo(()=>he.buildSlotOrderedCards(V),[V]),O=v.useMemo(()=>{const te=V.findIndex(ue=>(ue==null?void 0:ue.id)===i.id);return te<0?-1:he.getSlotIndexForCard(i,te)},[V,i]),B=v.useMemo(()=>!l||R!=="multiple"||O<0?i.type:he.getEffectiveCardTypeForSlot(i,O,T==null?void 0:T.slots)??i.type,[l,R,O,i,T==null?void 0:T.slots]),_=v.useMemo(()=>C?{...i,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:B!==i.type?{...i,type:B}:i,[i,B,C]),{data:z,dataUpdatedAt:q,isLoading:Y,isFetching:$,isError:Q,errorMessage:U,errorSql:J,queryKey:X}=a.useEditorCardQuery(_),ee=JSON.stringify(X),{handleOpenInEditor:me,handleDebugWithAssistant:be}=As(U,J||i.sql||i.python),ve=i.type==="text"&&((oe=(we=i.preferences)==null?void 0:we.textVisualOptions)==null?void 0:oe.isDynamicText)===!0&&!!U,je=v.useCallback((te,ue)=>{const Ce=he.normalizeMultiInputPayload(ue);g(fe=>({...fe,[te]:Ce}))},[]),Re=v.useCallback((te,ue)=>{D(Ce=>{const fe=new Set(Ce);return ue?fe.add(te):fe.delete(te),fe})},[]),Pe=k.size>0,Me=v.useMemo(()=>P.map((te,ue)=>he.getEffectiveCardTypeForSlot(te,ue,T==null?void 0:T.slots)),[P,T==null?void 0:T.slots]),Ee=v.useMemo(()=>a.createCustomVisualTemporalBucketFormatter(a.buildMultiInputTemporalPresentationInputs({slotOrderedCards:P,multiInputData:f,valueFormatPreferences:r})),[f,P,r]),Be=t.useInteractionStore(te=>te.interactionStates),_e=t.useDashboardStore(te=>{var ue;return(ue=te.dashboard)==null?void 0:ue.id}),Oe=t.useDashboardStore(te=>te.dashboard.filters),Ae=t.useDashboardStore(te=>te.filterValues),De=t.useDashboardStore(te=>te.selectedSheetId),ae=t.useEditorStore(te=>te.inlineFilterValuesMap[(l==null?void 0:l.id)||""]),K=t.useEditorStore(te=>te.actions.setCardInlineFilterValue),ie=t.useEditorStore(te=>te.actions.removeCardInlineFilterValue),Se=v.useMemo(()=>l?a.buildInlineFilterNodes({card:l,sheetId:De||"",inlineFilterValues:ae,setInlineFilterValue:te=>K(l.id,te),removeInlineFilterValue:te=>ie(l.id,te)}):[],[l,De,ae,K,ie]),{cardFilters:re,cardFilterValues:pe}=v.useMemo(()=>l?a.calculateContextAwareFilters({card:l,interactionStates:Be,currentDashboardId:_e,filters:Oe,filterValues:Ae,selectedSheetId:De}):{cardFilters:[],cardFilterValues:[]},[l,Be,_e,Oe,Ae,De]);function Ye(te){const ue=o.cards.find(Ce=>Ce.id===te);ue&&(a.flushPendingEditorDrafts(),p(),Z(te),m(te),j(),N(ue))}function Z(te){const ue=t.useEditorStore.getState().card,Ce=t.useEditorStore.getState().frame,fe={...Ce,cards:Ce.cards.map(ke=>ke.id===ue.id?ue:ke),activeCardId:te};x(fe);const He=fe.cards.find(ke=>ke.id===te);He.sql&&h(!0),b(He)}function Fe(){return y?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading manifest"})}):M?e.jsxs("div",{className:"relative flex h-full flex-col pl-2 pr-4",children:[V.map((ue,Ce)=>{if(!ue)return null;const fe=he.getSlotIndexForCard(ue,Ce),He=he.getEffectiveCardTypeForSlot(ue,fe,T==null?void 0:T.slots);return e.jsx(a.MultiInputEmptyRenderer,{onLoadingStatus:Re,onDataChange:je,card:ue,effectiveCardType:He},`${ue.id}-${fe}`)}),Pe&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading preview"})}),e.jsx("div",{className:t.cn("flex h-full min-h-0 flex-1 flex-col gap-2",Pe&&"opacity-50"),children:e.jsx(v.Suspense,{fallback:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(a.LoadingDots,{size:"md",color:"muted"})}),children:e.jsx(M,{editing:!0,...a.buildMultiInputCustomVisualProps({configCard:l,slotOrderedCards:P,slotTypes:Me,multiInputData:f,params:S,theme:A,filters:re,filterValues:[...pe||[],...ae||[]],inlineFilters:Se,formatTemporalBucketValue:Ee})})})})]}):e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a component to preview the multi-input visual."})}function xe(){var te;return C?Fe():s&&(n||!Y&&!$&&!Q&&!U)?s({card:i,data:z,isLoading:Y,isFetching:$,isError:Q}):i.type==="kpi"?Y||$?e.jsx("div",{className:"z-50 flex h-full items-center justify-center",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}):U?e.jsx(Wo,{errorMessage:U,errorSql:J||i.sql||i.python,onOpenInEditor:me,onDebugWithAssistant:be}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"w-1/2 space-y-3",children:[e.jsx("div",{className:"rounded-md border border-border",children:e.jsx(a.KPICard,{card:i,data:z==null?void 0:z.records,isPending:Y||$,isError:Q,comparisonMetadata:(te=z==null?void 0:z.metadata)==null?void 0:te.comparisonMetadata})}),a.isCardSummaryVisibleOnCard(i)&&e.jsx(a.CardSummary,{card:i,mode:"editor",records:z==null?void 0:z.records})]})}):i.type==="text"?Y||$?e.jsx("div",{className:"z-50 flex h-full items-center justify-center",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}):ve?e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto px-4 py-0",children:e.jsx(rs,{error:U,errorSql:J||i.sql||i.python,onOpenInEditor:me,onDebugWithAssistant:be,showFeedbackButton:!1})}):e.jsx("div",{className:"flex h-full min-h-0 flex-col px-4 py-4",children:e.jsx(a.TextCard,{isLoading:u,card:i,data:z==null?void 0:z.records})}):e.jsx(a.ErrorBoundary,{FallbackComponent:a.FallbackVisual,resetKeys:[ee,q,$],children:e.jsx(pa,{className:"grow border-none shadow-none"})})}return e.jsxs(t.Tabs,{onValueChange:Ye,value:o.activeCardId,className:"flex min-h-0 flex-1 flex-col",children:[C?e.jsx("div",{className:"mt-0 min-h-0 flex-1 overflow-hidden",children:xe()}):o.cards.map(te=>e.jsx(t.TabsContent,{className:"mt-0 min-h-0 flex-1 overflow-hidden focus-visible:ring-0 focus-visible:ring-offset-0",value:te.id,children:xe()},te.id)),e.jsx(Xo,{isPreviewMode:C,onPreviewToggle:c,configCard:l})]})}function Zo({onClick:s,className:n}){return e.jsxs(t.Button,{type:"button",size:"sm",variant:"outline",className:t.cn("h-8 gap-1.5 px-3 text-xs",n),onClick:s,children:[e.jsx(t.SlidersHorizontal,{className:"h-3.5 w-3.5 shrink-0"}),"Customize"]})}function Na({fallbackPreview:s,records:n,title:r,isInspectorOpen:o,onInspectorOpenChange:i}){var T;const d=t.useEditorStore(R=>R.card),c=t.useEditorStore(R=>R.actions.setCard),l=t.useEditorStore(R=>R.actions.updateCardInFrame),u=t.normalizeDynamicRendererSource((T=d.dynamicCardPreferences)==null?void 0:T.rendererCode),[x,m]=v.useState(u),[b,h]=v.useState(u);v.useEffect(()=>{m(u),h(u)},[u,d.id]);const p=v.useMemo(()=>t.normalizeDynamicRendererSource(x),[x]),j=v.useMemo(()=>t.validateDynamicRendererSource(p),[p]),N=!!u,f=v.useMemo(()=>{var R;return t.buildCardWithVisualizationMode(d,b?"dynamic":"builtin",{rendererCode:b||void 0,artifactId:((R=d.dynamicCardPreferences)==null?void 0:R.artifactId)||d.id,title:r||d.title})},[d,b,r]),g=!!b,k=p!==b,D=b!==u,w=!p||!j.valid||k||D,S=p?j.valid?k?"Unapplied changes":"Pending save":"Needs attention":"Draft",L=!p||k||D?"outline":"destructive",A=p?j.valid?k?"The preview still reflects the last applied code until you apply this draft.":D?"Preview reflects pending changes. Accept changes to save them.":"":j.error||"Visual code is invalid.":"Paste visual code or generate one before saving this card.";function F(){if(!j.valid){t.ue.error(j.error||"Visual code is invalid.");return}h(p),t.ue.success("Dynamic preview updated.")}function I(){m(b)}function y(){var C;const R=t.buildCardWithVisualizationMode(d,b?"dynamic":"builtin",{rendererCode:b||void 0,artifactId:((C=d.dynamicCardPreferences)==null?void 0:C.artifactId)||ye.v4(),title:r||d.title});c(R),l(R),i(!1),t.ue.success(b?"Dynamic visual changes saved.":"Dynamic visual cleared.")}function E(){m(u),h(u),i(!1)}function M(){m(""),h("")}return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"min-h-0 flex-1 bg-background px-2",children:N?e.jsx(a.PersistedDynamicVisual,{card:d,records:n,title:r,layoutMode:"fill",fallback:s},u||"applied-empty"):e.jsxs("div",{className:"flex h-full min-h-[280px] flex-col items-center justify-center gap-3 rounded-md border border-dashed border-border/70 bg-muted/20 px-6 text-center",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-full border bg-background",children:e.jsx(a.CodeXml,{className:"text-muted-foreground"})}),e.jsxs("div",{className:"flex max-w-md flex-col gap-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"No applied dynamic visual yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open Customize, paste visual code, and apply it to preview the renderer here."})]}),e.jsx(Zo,{onClick:()=>i(!0)})]})}),e.jsx(a.Dialog,{open:o,onOpenChange:R=>{if(!R){E();return}i(!0)},children:e.jsxs(a.DialogContent,{className:"flex h-[min(88vh,860px)] max-w-[min(1280px,calc(100vw-2rem))] flex-col gap-0 overflow-hidden p-0",children:[e.jsx(a.DialogHeader,{className:"border-b px-6 py-4 pr-20 text-left",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 pr-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx(a.DialogTitle,{children:"Dynamic Visual Editor"}),e.jsx(a.DialogDescription,{children:"Adjust the preview and visual code here. Query editing stays in the normal editor controls."})]}),w&&e.jsx(a.Badge,{className:"mr-4 shrink-0",variant:L,children:S})]})}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsxs(a.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(a.ResizablePanel,{defaultSize:54,minSize:38,children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx("div",{className:"min-h-0 flex-1 bg-background p-4",children:g?e.jsx(a.PersistedDynamicVisual,{card:f,records:n,title:r,layoutMode:"fill",fallback:s},b||"preview-empty"):e.jsx("div",{className:"flex h-full min-h-[280px] items-center justify-center rounded-md border border-dashed border-border/70 bg-muted/20 px-6 text-center text-sm text-muted-foreground",children:"Apply valid visual code to preview the dynamic visual here."})})})}),e.jsx(a.ResizableHandle,{withHandle:!0}),e.jsx(a.ResizablePanel,{defaultSize:46,minSize:30,children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(a.CodeXml,{className:"h-4 w-4 text-muted-foreground"}),"Visual Code"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.AlertDialog,{children:[e.jsx(a.AlertDialogTrigger,{asChild:!0,children:e.jsxs(t.Button,{type:"button",size:"sm",variant:"ghost",className:"h-8 gap-1.5 px-2.5 text-xs",disabled:!N&&!p,children:[e.jsx(le.X,{className:"h-3.5 w-3.5 shrink-0"}),"Clear"]})}),e.jsxs(a.AlertDialogContent,{children:[e.jsxs(a.AlertDialogHeader,{children:[e.jsx(a.AlertDialogTitle,{children:"Clear dynamic visual?"}),e.jsx(a.AlertDialogDescription,{children:"This removes the saved dynamic renderer and switches the card back to built-in mode. The underlying query and built-in chart type will remain."})]}),e.jsxs(a.AlertDialogFooter,{children:[e.jsx(a.AlertDialogCancel,{children:"Cancel"}),e.jsx(a.AlertDialogAction,{className:"bg-foreground text-background hover:bg-foreground/90",onClick:M,children:"Clear"})]})]})]}),e.jsxs(t.Button,{type:"button",size:"sm",variant:"outline",className:"h-8 gap-1.5 px-2.5 text-xs",onClick:I,disabled:!k,children:[e.jsx(t.RotateCcw,{className:"h-3.5 w-3.5 shrink-0"}),"Reset"]}),e.jsxs(t.Button,{type:"button",size:"sm",className:"h-8 gap-1.5 px-3 text-xs",onClick:F,disabled:!k||!j.valid,children:[e.jsx(a.Play,{className:"h-3.5 w-3.5 shrink-0"}),"Apply to Preview"]})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 p-4",children:[A&&e.jsx("p",{className:t.cn("text-xs",j.valid?"text-muted-foreground":"text-destructive"),children:A}),e.jsx("div",{className:t.cn("min-h-0 flex-1 overflow-hidden rounded-md border",!j.valid&&p&&"border-destructive"),children:e.jsx(t.CodeEditor,{value:x,onValueChange:R=>m(R||""),language:"javascript",embedded:!0})})]})]})})]})}),e.jsxs(a.DialogFooter,{className:"border-t px-6 py-4 sm:justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:A||"Preview changes here before saving them."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{type:"button",variant:"outline",size:"sm",className:"h-8 px-3 text-xs",onClick:E,children:"Cancel"}),e.jsx(t.Button,{type:"button",size:"sm",className:"h-8 px-3 text-xs",onClick:y,disabled:!D,children:"Accept changes"})]})]})]})})]})}function Sa({onCustomize:s}){const n=t.useEditorStore(x=>x.card),r=t.useEditorStore(x=>x.frame),o=t.useEditorStore(x=>x.actions.setIsShowingVisual),{setVisualizationMode:i,setDynamicCardPreferences:d}=t.useEditorActions(),l=t.getVisualizationMode(n)==="dynamic";if(r.cards.length!==1||t.isCustomVisualizationCard(n))return null;const u=x=>{var m;x==="dynamic"&&!n.dynamicCardPreferences&&d(t.createEmptyDynamicCardPreferences(n.type,(m=n.preferences)==null?void 0:m.displayOptions)),i(x),o(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(a.DropdownMenuItem,{onSelect:x=>{x.preventDefault(),u(l?"builtin":"dynamic")},className:"justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.CodeXml,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:"Dynamic"})]}),e.jsx(t.Switch,{size:"xs",checked:l,onCheckedChange:x=>u(x?"dynamic":"builtin"),onClick:x=>x.stopPropagation()})]}),l&&s?e.jsxs(a.DropdownMenuItem,{onSelect:x=>{x.preventDefault(),s()},children:[e.jsx(t.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Customize visual"]}):null]})}function wa({sql:s,showCardDetails:n=!1,debugPayloads:r,className:o}){const[i,d]=v.useState(!1),c=t.useEditorStore(b=>b.isDevMode),l=t.useEditorStore(b=>b.card.type),{switchEditorMode:u,setRunSql:x}=t.useEditorActions(),m=()=>{u("dev",{sqlToLoad:s}),setTimeout(()=>{x(!0)},100)};return e.jsx(la,{className:t.cn("overflow-hidden",o),children:e.jsx(ma,{sql:s,label:"Generated query",ariaLabel:"Executed SQL",copyAriaLabel:"Copy generated query",headerActions:c?void 0:e.jsxs(e.Fragment,{children:[ye.supportsSqlEditor(l)&&e.jsx(t.Button,{onClick:m,variant:"outline",size:"xs",className:Pt,children:"Open in SQL editor"}),n&&e.jsx(da,{isOpen:i,onClick:()=>d(b=>!b)})]}),className:"min-h-0",bodyClassName:"max-h-[min(420px,calc(var(--radix-hover-card-content-available-height,100vh)-3rem))]",children:i&&n&&e.jsx(ua,{debugPayloads:r})})})}function gs({children:s,visualAsideControl:n,mode:r="both",inlineToolbar:o=!1,overflowActions:i,isDynamicInspectorOpen:d,onDynamicInspectorOpenChange:c}){var Fe;const l=a.useQueryClient(),u=t.useEditorStore(xe=>xe.frame),x=t.useEditorStore(xe=>xe.card),m=t.useEditorStore(xe=>xe.isDevMode),b=t.useEditorStore(xe=>xe.editorContext),h=(b==null?void 0:b.type)==="documentSection",p=t.useEditorStore(xe=>xe.isShowingVisual),j=t.useEditorStore(xe=>xe.actions.setIsShowingVisual),N=t.useDashboardStore(xe=>xe.isVisualEditing),{isConsoleMode:f}=a.useDashboardPreferences(),g=t.useEditorStore(xe=>xe.pythonStdOut),k=t.useEditorStore(xe=>xe.actions.setRunSql),D=a.useEffectiveEditorCardType(),w=D==="table"||D==="detailTable"||D==="matrixTable",L=t.supportsRegularTableSettings(D)&&!!(n!=null&&n.onOpen),F=t.getVisualizationMode(x)==="dynamic",[I,y]=v.useState(!1),E=d??I,M=c??y,{setFrame:T,setCard:R,setActiveTabCardId:C,mergeDraftsIntoCard:V,clearModeDrafts:P,initializeModeDrafts:O,updatePageSize:B,updateCardInFrame:_,setCardType:z}=t.useEditorActions(),q=v.useMemo(()=>D!==x.type?{...x,type:D}:x,[x,D]),{data:Y,isLoading:$,isFetching:Q,errorMessage:U,errorSql:J,refetch:X,queryKey:ee,pagination:me}=a.useEditorCardQuery(q),be=v.useRef(ee);be.current=ee;const{handleDebugWithAssistant:ve}=As(U,J),je=v.useMemo(()=>(Y==null?void 0:Y.records)||[],[Y==null?void 0:Y.records]),{cardFilterValues:Re}=mo((x==null?void 0:x.id)??""),[Pe,Me]=v.useState(!1),Ee=a.useMatrixEditorRefresh(x),[Be,_e]=v.useState();v.useEffect(()=>{Q||Me(!1)},[Q]);const Oe=()=>{var xe;if(Ee){(xe=Ee.refresh)==null||xe.call(Ee);return}if(Me(!0),m){a.flushPendingEditorDrafts(),setTimeout(()=>{l.removeQueries({queryKey:be.current,exact:!0}),k(!0)},0);return}X()};v.useEffect(()=>{w&&!p&&!m&&!f&&j(!0)},[f,m,w,p,j]);function Ae(xe,ze){var we,oe;const Le={...x,paginationConfig:{page:xe+1,pageSize:ze}};R(Le);const $e={...u,cards:u.cards.map(te=>te.id===x.id?Le:te)};T($e),x.sql&&((oe=(we=x.preferences)==null?void 0:we.tablePrefs)!=null&&oe.enableDevModePagination)&&k(!0)}function De(xe){var we,oe,te,ue,Ce;const ze=a.sortStateToSortByColumns(xe,(we=x.config)==null?void 0:we.metricColumns,(oe=x.config)==null?void 0:oe.groupByColumns,(te=x.config)==null?void 0:te.detailColumns),Le={...x,config:{...x.config||{},sortByColumns:ze}};R(Le);const $e={...u,cards:u.cards.map(fe=>fe.id===x.id?Le:fe)};T($e),x.sql&&((Ce=(ue=x.preferences)==null?void 0:ue.tablePrefs)!=null&&Ce.enableDevModePagination)&&k(!0)}const ae=Array.isArray(Y==null?void 0:Y.records)?Y.records:[],K=ae.length>0;function ie(){var ze;if(!K)return;const xe=JSON.stringify(ae,null,2);typeof navigator>"u"||!((ze=navigator.clipboard)!=null&&ze.writeText)||navigator.clipboard.writeText(xe).catch(Le=>{console.error("Failed to copy JSON",Le)})}function Se(){if(!K)return;const xe=JSON.stringify(ae,null,2),ze=new Blob([xe],{type:"application/json"}),Le=URL.createObjectURL(ze),$e=document.createElement("a");$e.href=Le,$e.download=`${x.title}.json`,$e.click()}function re(){if(!K)return;const ze=[Object.keys(ae.reduce((oe,te)=>({...oe,...te}),{})).join(","),...ae.map(oe=>Object.values(oe).join(","))].join(`
|
|
172
|
+
`),Le=new Blob([ze],{type:"text/csv"}),$e=URL.createObjectURL(Le),we=document.createElement("a");we.href=$e,we.download=`${x.title}.csv`,we.click()}if(!x)return e.jsx(e.Fragment,{children:"No Active Card"});const pe=r==="both"||r==="toolbar",Ye=r==="both"||r==="canvas",Z=!$&&!Q&&!U&&(Y!=null&&Y.sql)?e.jsx("div",{className:"inline-flex shrink-0 items-center text-[11px] text-muted-foreground",children:e.jsxs(a.HoverCard,{openDelay:200,children:[e.jsx(a.HoverCardTrigger,{asChild:!0,children:o?e.jsx(a.IconButton,{className:"h-7 w-7 shrink-0 px-0",buttonProps:{"aria-label":"View executed SQL"},children:e.jsx(jr,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):e.jsx("button",{type:"button",className:"cursor-pointer text-[11px] underline-offset-4 hover:text-foreground hover:underline",children:"Executed SQL"})}),e.jsx(a.HoverCardContent,{align:"end",collisionPadding:16,className:"w-[500px] overflow-hidden p-0",children:e.jsx(wa,{sql:Y.sql})})]})}):null;return e.jsxs("div",{className:t.cn("relative isolate flex flex-col",o?"ml-auto min-w-0 shrink-0":r==="toolbar"?"h-auto pb-1":t.cn("h-full",!w&&"pt-2")),children:[pe&&e.jsxs("div",{className:t.cn("z-10 mb-0 flex items-center",o?"min-w-0 shrink-0 gap-1.5":"min-h-10 gap-2 px-4"),children:[o?Z:null,p&&e.jsx("div",{className:t.cn("flex items-center",o?"shrink-0":"grow gap-4"),children:e.jsx("div",{className:"flex items-center gap-3",children:!h&&!F&&e.jsx(va,{selectedChart:x.type,onChartChange:xe=>z(xe),compactMore:!0,responsiveCompact:o})})}),!p&&!o&&e.jsx("div",{className:"grow"}),e.jsxs("div",{className:t.cn("flex items-center text-muted-foreground",o?"gap-1.5":"gap-2"),children:[s,o?null:Z,Re&&Re.length>0&&e.jsxs(a.HoverCard,{openDelay:200,children:[e.jsx(a.HoverCardTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"xs",className:"h-7 gap-1.5 px-2",children:[e.jsx(a.Filter,{className:"h-3.5 w-3.5",strokeWidth:1.75}),e.jsx(a.Badge,{variant:"secondary",className:"h-4 min-w-4 rounded-[4px] px-1 text-[10px] font-medium",children:Re.length})]})}),e.jsxs(a.HoverCardContent,{align:"end",className:"flex max-h-[400px] w-[500px] flex-col overflow-hidden p-0",children:[e.jsx("div",{className:"shrink-0 border-b border-border px-3 py-2 text-[13px] font-medium",children:"Active Dashboard Filters"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(t.CodeEditor,{value:JSON.stringify(Re,null,2),onValueChange:()=>{},language:"json",readOnly:!0,embedded:!0,wrapLines:!0,dense:!0,hideLineNumbers:!0,ariaLabel:"Active dashboard filters JSON"})})]})]}),!F&&e.jsx("div",{className:o?"hidden @[1250px]:flex":"",children:e.jsx(Ca,{showInlineFilters:!1,showControls:!1,showDisplayOptions:!1})}),(n==null?void 0:n.show)&&e.jsxs(t.Button,{type:"button",variant:"ghost",size:"xs","aria-pressed":n.isOpen,onClick:n.onToggle,className:t.cn("h-7 shrink-0 gap-1.5 text-[12px]",o?"hidden w-7 px-0 @[850px]:inline-flex @[1350px]:w-auto @[1350px]:px-2":"px-2",n.isOpen&&"bg-accent text-accent-foreground"),children:[e.jsx(a.Settings2,{className:"h-3.5 w-3.5",strokeWidth:1.75}),e.jsx("span",{className:o?"hidden @[1350px]:inline":"",children:"Settings"})]}),e.jsx(a.IconButton,{tooltip:"Refresh",disabled:$||Q,className:t.cn("h-7 w-7 px-0",o&&"hidden @[1150px]:inline-flex"),onClick:Oe,children:e.jsx(Ts,{className:t.cn("h-3.5 w-3.5",{"animate-spin":(Ee==null?void 0:Ee.isFetching)??Pe})})}),e.jsxs(a.DropdownMenu,{modal:!1,children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsx(a.IconButton,{tooltip:"More Options",className:"h-7 w-7 px-0","aria-label":"More options",children:e.jsx(a.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",collisionPadding:8,className:"max-h-[var(--radix-dropdown-menu-content-available-height)] w-56 overflow-y-auto overscroll-contain",children:[(o||(i==null?void 0:i.reset))&&e.jsxs(e.Fragment,{children:[o&&e.jsxs(a.DropdownMenuItem,{disabled:$||Q,onSelect:Oe,children:[e.jsx(Ts,{className:"h-3.5 w-3.5"}),"Refresh result"]}),i==null?void 0:i.reset,e.jsx(a.DropdownMenuSeparator,{})]}),e.jsx(a.DropdownMenuLabel,{children:"Export"}),Ee?e.jsxs(a.DropdownMenuItem,{disabled:$||Q||!Ee.hasDelivery,title:Ee.hasDelivery?void 0:"Available once the preview has loaded.",onSelect:()=>_e(Ee.readDelivery()),className:"gap-2 text-[13px]",children:[e.jsx(a.Download,{className:"h-3.5 w-3.5"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsxs(a.DropdownMenuItem,{disabled:!K,onSelect:re,className:"gap-2 text-[13px]",children:[e.jsx(a.Download,{className:"h-3.5 w-3.5"}),"Download CSV"]}),e.jsxs(a.DropdownMenuItem,{disabled:!K,onSelect:Se,className:"gap-2 text-[13px]",children:[e.jsx(vr,{className:"h-3.5 w-3.5"}),"Download JSON"]}),e.jsxs(a.DropdownMenuItem,{disabled:!K,onSelect:ie,className:"gap-2 text-[13px]",children:[e.jsx(a.Copy,{className:"h-3.5 w-3.5"}),"Copy JSON"]})]}),e.jsx(a.DropdownMenuSeparator,{}),(i==null?void 0:i.query)&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuLabel,{children:"Query"}),i.query,e.jsx(a.DropdownMenuSeparator,{})]}),(o&&(n==null?void 0:n.show)||m||f)&&e.jsxs(e.Fragment,{children:[e.jsx(a.DropdownMenuLabel,{children:"Output"}),o&&(n==null?void 0:n.show)&&e.jsx(a.DropdownMenuCheckboxItem,{checked:n.isOpen,onCheckedChange:()=>n.onToggle(),children:"Settings"}),(m||f)&&e.jsx(a.DropdownMenuCheckboxItem,{checked:!p,onCheckedChange:xe=>j(xe!==!0),children:"Show raw results"}),e.jsx(a.DropdownMenuSeparator,{})]}),e.jsx(a.DropdownMenuLabel,{children:"Customize"}),!F&&!["table","detailTable","custom"].includes(x.type)&&N&&e.jsx(Mo,{triggerVariant:"menu",className:"w-full"}),e.jsx(Rs,{triggerVariant:"menu",className:"w-full"}),e.jsx(Ps,{triggerVariant:"menu",className:"w-full"}),e.jsx(Fs,{triggerVariant:"menu",className:"w-full"}),L&&e.jsxs(a.DropdownMenuItem,{onSelect:()=>{var xe;return(xe=n==null?void 0:n.onOpen)==null?void 0:xe.call(n,"style")},className:"gap-2 text-[13px]",children:[e.jsx(Er,{className:"h-3.5 w-3.5"}),"Table settings"]}),e.jsx(a.DropdownMenuSeparator,{}),e.jsx(Sa,{onCustomize:()=>M(!0)})]})]}),Be&&e.jsx(a.ExportDialog,{isOpen:!0,onClose:()=>_e(void 0),card:x,frame:u,matrix:Be})]})]}),Ye&&(p?F?e.jsx(Et,{alwaysRenderOverride:!0,renderCardOverride:()=>e.jsx(Na,{fallbackPreview:e.jsx(Et,{}),records:je,title:x.title,isInspectorOpen:E,onInspectorOpenChange:M})}):e.jsx(Et,{}):e.jsxs(a.ResizablePanelGroup,{className:t.cn(g&&"py-2 pl-2 pr-6"),direction:"horizontal",children:[g&&e.jsxs(e.Fragment,{children:[e.jsx(a.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:g&&e.jsx(el,{})}),e.jsx(a.ResizableHandle,{})]}),e.jsxs(a.ResizablePanel,{id:"2",order:2,minSize:10,className:t.cn("relative flex h-full min-h-0 w-full flex-1 basis-0",{"py-2 pl-2 pr-6":g}),children:[Array.isArray(Y==null?void 0:Y.records)&&!U&&(m?e.jsx(fo,{data:Y.records,card:q,paginationMetadata:me,onPaginationChange:Ae,onPageSizePreferenceChange:B,onSortChange:De,isLoading:$||Q}):Y.records.length>0?e.jsx(a.TableVisual,{card:x,data:je,resultColumns:Y==null?void 0:Y.columns,columnKeyMap:Y==null?void 0:Y.columnKeyMap,totalsByColumnId:Y==null?void 0:Y.tableTotalsByColumnId,comparisonMetadata:(Fe=Y==null?void 0:Y.metadata)==null?void 0:Fe.comparisonMetadata,paginationMetadata:me,onPaginationChange:Ae,onSortChange:De,isLoading:$||Q}):null),U&&e.jsx("div",{className:"flex h-full flex-col items-start justify-start overflow-auto",children:e.jsx(rs,{error:U,errorSql:J||x.sql||x.python,onDebugWithAssistant:ve,showFeedbackButton:!1})})]})]}))]})}function el(){const s=t.useEditorStore(r=>r.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col",children:[e.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxs(t.ScrollArea,{className:"overflow-y-auto pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:n}}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function et({value:s,onCommit:n,type:r="text",placeholder:o,className:i}){const[d,c]=v.useState(s),l=v.useRef(!1);v.useEffect(()=>{c(s)},[s]);const u=()=>{if(l.current){l.current=!1;return}d!==s&&n(d)},x=m=>{if(m.key==="Enter"){m.currentTarget.blur();return}m.key==="Escape"&&(l.current=!0,c(s),m.currentTarget.blur())};return e.jsx(t.Input,{type:r,placeholder:o,value:d,onChange:m=>c(m.target.value),onBlur:u,onKeyDown:x,className:i})}function pt({defaultValue:s,label:n,options:r,value:o,onValueChange:i,className:d,icon:c,showPlaceholderLabel:l=!0}){return e.jsxs(t.Select,{defaultValue:s,value:o,onValueChange:i,children:[e.jsx(t.SelectTrigger,{className:t.cn("w-full focus:ring-0 focus:ring-offset-0",d),children:e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsx("span",{children:c}),l&&e.jsx(t.SelectValue,{placeholder:n})]})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:n}),r.map(u=>e.jsx(t.SelectItem,{value:u.value,children:u.label},u.value))]})})]})}function tl(s,n){return he.getSlotDefinitionForIndex(s,n)||null}function _t(s){if(typeof s=="number")return`Tab ${s+1}`;const n=s.match(/^(\d+)-(\d+)$/);if(n){const[,o,i]=n;return`Tabs ${Number(o)+1}-${Number(i)+1}`}const r=s.match(/^(\d+)\+$/);return r?`Tabs ${Number(r[1])+1}+`:`Tab ${s}`}function sl(s){return s?Array.isArray(s)?s:[s]:[]}function bs(s){var o,i;if(!s)return!1;if(s.type==="text")return!!((o=s.description)!=null&&o.trim());const n=!!((i=s.sql)!=null&&i.trim()),r=ye.hasValidCardConfig(s.config);return n||r}function nl({slots:s,cards:n,minInputs:r}){const o=[],i=n.filter(Boolean).length;return r&&i<r&&o.push({type:"too-few-inputs",message:`This visual requires at least ${r} tab${r===1?"":"s"}.`}),!s||s.length===0||(s.forEach(d=>{if(!d.required)return;if(typeof d.position=="number"){const u=n[d.position];bs(u)||o.push({type:"missing-required",message:`${_t(d.position)} ("${d.label}") is required but has no data configured.`});return}const c=d.position.match(/^(\d+)-(\d+)$/);if(c){const[,u,x]=c.map(Number);for(let m=u;m<=x;m+=1){const b=n[m];if(!bs(b)){o.push({type:"missing-required",message:`${_t(m)} ("${d.label}") is required but has no data configured.`});break}}return}const l=d.position.match(/^(\d+)\+$/);if(l){const u=Number(l[1]);if(n.length<=u){o.push({type:"missing-required",message:`${_t(u)} ("${d.label}") is required but has no data configured.`});return}for(let x=u;x<n.length;x+=1){const m=n[x];if(!bs(m)){o.push({type:"missing-required",message:`${_t(x)} ("${d.label}") is required but has no data configured.`});break}}}}),n.forEach((d,c)=>{if(!d)return;const l=tl(s,c);if(!l||!l.expectedType)return;const u=sl(l.expectedType);u.length!==0&&(u.includes(d.type)||o.push({type:"wrong-type",message:`${_t(c)} ("${l.label}") expects ${u.join(", ")}, but is configured as ${d.type}.`}))})),o}const al={table:({children:s})=>e.jsx("table",{className:"my-3 w-full border-collapse overflow-hidden rounded-md border border-border text-sm",children:s}),thead:({children:s})=>e.jsx("thead",{className:"bg-muted",children:s}),th:({children:s})=>e.jsx("th",{className:"border border-border px-3 py-2 text-left font-medium",children:s}),td:({children:s})=>e.jsx("td",{className:"border border-border px-3 py-2",children:s}),code:({children:s,className:n})=>(n==null?void 0:n.includes("language-"))?e.jsx("pre",{className:"my-3 overflow-x-auto rounded-md bg-muted p-3 text-xs",children:e.jsx("code",{children:s})}):e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:s}),pre:({children:s})=>e.jsx(e.Fragment,{children:s})};function Ta(){var M,T,R;const s=t.useEditorStore(C=>C.card.customCardPreferences),{data:n}=a.usePluginQuery(),r=(n==null?void 0:n.plugins)||[],o=t.useEditorStore(C=>C.card),i=t.useEditorStore(C=>C.frame),{setCustomCardPreferences:d}=t.useEditorActions(),c=v.useMemo(()=>he.findCustomVisualConfigCard(i,o),[i,o]),l=c==null?void 0:c.customCardPreferences,{components:u,manifest:x}=a.useCustomVisual((l==null?void 0:l.url)||(s==null?void 0:s.url)||""),m=(M=x==null?void 0:x.visuals)==null?void 0:M.find(C=>C.name===((l==null?void 0:l.componentName)||(s==null?void 0:s.componentName))),h=he.resolveMultiInputType(c||o,m)==="multiple",p=!!c&&c.id===o.id,j=(m==null?void 0:m.minInputs)??((T=c==null?void 0:c.customCardPreferences)==null?void 0:T.minInputs),N=(m==null?void 0:m.maxInputs)??((R=c==null?void 0:c.customCardPreferences)==null?void 0:R.maxInputs),f=v.useMemo(()=>he.getCustomVisualInputCards({frame:i,configCard:c||o,isMultiInputVisual:h}),[i,c,o,h]),g=v.useMemo(()=>he.buildSlotOrderedCards(f),[f]),k=v.useMemo(()=>g.map((C,V)=>{if(!C)return null;const P=he.getSlotIndexForCard(C,V),O=he.getEffectiveCardTypeForSlot(C,P,m==null?void 0:m.slots);return{...C,type:O??C.type}}),[g,m==null?void 0:m.slots]),D=v.useMemo(()=>nl({slots:m==null?void 0:m.slots,cards:k,minInputs:j}),[m==null?void 0:m.slots,k,j]),w=v.useMemo(()=>{const C=f.findIndex(V=>(V==null?void 0:V.id)===o.id);return C<0?-1:he.getSlotIndexForCard(o,C)},[f,o]);function S(C){if(typeof C=="number")return`Tab ${C+1}`;const V=C.match(/^(\d+)-(\d+)$/);if(V){const[,O,B]=V;return`Tabs ${Number(O)+1}-${Number(B)+1}`}const P=C.match(/^(\d+)\+$/);return P?`Tabs ${Number(P[1])+1}+`:`Tab ${C}`}function L(C){return C?(Array.isArray(C)?C:[C]).join(", "):null}function A(C,V,P=[],O="",B,_,z){const q=F({key:V,defaultValue:O,settingsValue:_,sourceCard:z});return C==="input"?e.jsx(et,{className:`h-8 w-full ${t.removeRing}`,value:String(q??""),onCommit:Y=>{I({key:V,value:Y,settingsField:B,settingsValue:_,sourceCard:z})}},V):C==="select"?e.jsx(pt,{className:"h-8 w-full",label:"",options:P,value:String(q!==void 0?q:O??""),onValueChange:Y=>{I({key:V,value:Y,settingsField:B,settingsValue:_,sourceCard:z})}}):null}function F({key:C,defaultValue:V,settingsValue:P,sourceCard:O}){const B=P==null?void 0:P[C];return B!==void 0?B:C==="title"&&(O==null?void 0:O.title)!==void 0?O.title:C==="description"&&(O==null?void 0:O.description)!==void 0?O.description:V}function I({key:C,value:V,settingsField:P,settingsValue:O,sourceCard:B}){const _={...O||{}},z=C==="title"&&(B==null?void 0:B.title)!==void 0,q=C==="description"&&(B==null?void 0:B.description)!==void 0;z&&V===String((B==null?void 0:B.title)??"")||q&&V===String((B==null?void 0:B.description)??"")?delete _[C]:_[C]=V,d({...s||{},[P]:_})}function y({settingsSchema:C,settingsField:V,settingsValue:P,sourceCard:O,headerLabel:B}){const _=Object.entries(C||{});return e.jsxs("div",{className:"space-y-3",children:[B&&e.jsx(t.Label,{children:B}),_.map(([z,q])=>{var Y;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{children:q.title}),((Y=q.docs)==null?void 0:Y.description)&&e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx(t.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),e.jsx(t.TooltipContent,{side:"right",className:"max-w-xs",children:e.jsx("p",{className:"text-xs",children:q.docs.description})})]})})]}),A(q.ui,z,q.options,q.defaultValue,V,P,O)]},z)})]})}function E(){return e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Slot Guide"}),e.jsx("div",{className:"space-y-3 rounded-md border border-border bg-muted/40 px-3 py-2 text-xs",children:m!=null&&m.slots&&m.slots.length>0?e.jsx("div",{className:"space-y-3",children:m.slots.map((C,V)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[e.jsx("span",{className:"font-medium",children:S(C.position)}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{className:"font-medium",children:C.label})]}),C.description&&e.jsx("p",{className:"text-muted-foreground",children:C.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-muted-foreground",children:[L(C.expectedType)&&e.jsxs("span",{children:["Expected: ",L(C.expectedType)]}),C.required&&e.jsx("span",{children:"Required"})]})]},`${C.label}-${V}`))}):e.jsxs("div",{className:"space-y-1 text-muted-foreground",children:[e.jsx("p",{children:"This visual renders all tabs in a flexible layout. Add as many tabs as needed."}),(j||N)&&e.jsxs("p",{children:[j?`Min ${j} tabs`:"",j&&N?" • ":"",N?`Max ${N} tabs`:""]})]})})]}),h&&D.length>0&&e.jsx(a.Alert,{className:"mt-3 border-yellow-500/40 bg-yellow-500/10 text-yellow-900 dark:text-yellow-100",children:e.jsx(a.AlertDescription,{children:e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs",children:D.map((C,V)=>e.jsx("li",{children:C.message},`${C.type}-${V}`))})})}),m&&!h&&m.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:y({settingsSchema:m.settings,settingsField:"settings",settingsValue:s==null?void 0:s.settings,sourceCard:o})})}),m&&h&&(m.settings||m.slotSettings)&&e.jsxs("div",{className:"mt-4 space-y-4",children:[p&&m.settings&&e.jsx("div",{className:"px-2",children:y({settingsSchema:m.settings,settingsField:"settings",settingsValue:s==null?void 0:s.settings,sourceCard:c||o,headerLabel:"Global Settings"})}),m.slotSettings&&e.jsx("div",{className:"px-2",children:y({settingsSchema:m.slotSettings,settingsField:"slotSettings",settingsValue:s==null?void 0:s.slotSettings,sourceCard:o,headerLabel:(()=>{const C=o.tabTitle||o.title,V=w>=0?w:0,P=p?"Slot 0":`Slot ${V}`;return C?`${P}: ${C} Settings`:`${P} Settings`})()})})]})]})}return e.jsxs(a.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"",children:[e.jsxs(a.AccordionItem,{value:"plugin-settings",children:[e.jsx(a.AccordionTrigger,{children:"Plugin"}),e.jsx(a.AccordionContent,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-4",children:[(!h||p)&&e.jsx(pt,{icon:e.jsx(na,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:r,value:(l==null?void 0:l.url)||"",onValueChange:C=>d({...s||{url:"",componentName:""},url:C})}),h&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Switch to the config tab to change the plugin or component."})]})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&(!h||p)&&e.jsx(e.Fragment,{children:u&&e.jsx(pt,{icon:e.jsx(br,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(u==null?void 0:u.map(C=>({value:C.name,label:C.name})))||[],value:s.componentName||"",onValueChange:C=>{var O;const V=(O=x==null?void 0:x.visuals)==null?void 0:O.find(B=>B.name===C),P=u==null?void 0:u.find(B=>B.name===C);d({...s,componentName:C,visualType:(V==null?void 0:V.visualType)||(P==null?void 0:P.type)||"single",minInputs:V==null?void 0:V.minInputs,maxInputs:V==null?void 0:V.maxInputs,pluginChartType:V==null?void 0:V.chartType})}})})]})})]}),((l==null?void 0:l.componentName)||(s==null?void 0:s.componentName))&&e.jsxs(a.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(a.AccordionTrigger,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:(m==null?void 0:m.name)||"Settings"}),(m==null?void 0:m.docs)&&e.jsxs(a.HoverCard,{openDelay:0,closeDelay:100,children:[e.jsx(a.HoverCardTrigger,{asChild:!0,onClick:C=>C.stopPropagation(),children:e.jsx(t.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground transition-colors hover:text-foreground"})}),e.jsx(a.HoverCardContent,{side:"right",align:"start",className:"max-h-[40vh] w-[500px] overflow-y-auto text-left",children:e.jsxs("div",{className:"space-y-4 text-left",children:[m.docs.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:m.docs.description}),m.docs.dataSchema&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Data Schema"}),e.jsx("div",{className:"prose prose-sm dark:prose-invert prose-pre:bg-muted prose-pre:text-xs max-w-none",children:e.jsx(a.Markdown,{remarkPlugins:[a.remarkGfm],components:al,children:m.docs.dataSchema})})]}),(()=>{var V;const C=(V=m.docs)==null?void 0:V.useCases;return!C||C.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Use Cases"}),e.jsx("ul",{className:"space-y-1 text-sm",children:C.map((P,O)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1 text-primary",children:"•"}),e.jsx("span",{children:P})]},O))})]})})()]})})]})]})}),e.jsx(a.AccordionContent,{children:E()})]})]})}function as(s){return s==="currency"?2:s==="percent"?1:s==="scientific"?2:0}function Ea(s,n,r){if(!n||n==="auto")return{type:"auto"};if(n==="duration")return{type:"duration",multiplyBy:void 0,percentValueMode:void 0,durationInputUnit:s.durationInputUnit||"second",durationDisplayStyle:s.durationDisplayStyle||"compact",durationLargestUnit:s.durationLargestUnit||"day",durationSmallestUnit:s.durationSmallestUnit||"second",durationMaxUnits:s.durationMaxUnits};const o={...s,type:n,multiplyBy:n==="percent"?s.multiplyBy:void 0,percentValueMode:n==="percent"?s.percentValueMode:void 0,durationInputUnit:void 0,durationDisplayStyle:void 0,durationLargestUnit:void 0,durationSmallestUnit:void 0,durationMaxUnits:void 0};return n&&["number","currency","percent","scientific"].includes(n)&&s.decimalPlaces===void 0&&s.minimumFractionDigits===void 0&&s.maximumFractionDigits===void 0&&!(n==="currency"&&(r!=null&&r.preserveSparseCurrency))?Ia(o,as(n)):o}function rl(s,n){return{...s,decimalPlaces:void 0,minimumFractionDigits:n,maximumFractionDigits:n}}function Vn(s){const n=s.decimalPlaces;return{...s,currency:void 0,decimalPlaces:void 0,minimumFractionDigits:s.minimumFractionDigits??n,maximumFractionDigits:s.maximumFractionDigits??n}}function ol(s,n){const r=s.type||"auto";return r==="auto"?s:r==="duration"?{type:"duration",prefix:s.prefix,suffix:s.suffix,negativeInParentheses:s.negativeInParentheses,durationInputUnit:s.durationInputUnit||"second",durationDisplayStyle:s.durationDisplayStyle||"compact",durationLargestUnit:s.durationLargestUnit||"day",durationSmallestUnit:s.durationSmallestUnit||"second",durationMaxUnits:s.durationMaxUnits}:Ea(s,r,n)}function Ia(s,n){return{...s,decimalPlaces:n,minimumFractionDigits:n,maximumFractionDigits:n}}const Ft="__report_default__",ll=["auto","number","currency","percent","scientific","date","duration"],_n=[{value:"USD",label:"USD - US Dollar"},{value:"EUR",label:"EUR - Euro"},{value:"JPY",label:"JPY - Japanese Yen"},{value:"GBP",label:"GBP - British Pound"},{value:"CNY",label:"CNY - Chinese Yuan"},{value:"CHF",label:"CHF - Swiss Franc"},{value:"CAD",label:"CAD - Canadian Dollar"},{value:"AUD",label:"AUD - Australian Dollar"},{value:"HKD",label:"HKD - Hong Kong Dollar"},{value:"SGD",label:"SGD - Singapore Dollar"},{value:"NZD",label:"NZD - New Zealand Dollar"},{value:"SEK",label:"SEK - Swedish Krona"},{value:"NOK",label:"NOK - Norwegian Krone"},{value:"DKK",label:"DKK - Danish Krone"},{value:"KRW",label:"KRW - South Korean Won"},{value:"INR",label:"INR - Indian Rupee"},{value:"RUB",label:"RUB - Russian Ruble"},{value:"BRL",label:"BRL - Brazilian Real"},{value:"MXN",label:"MXN - Mexican Peso"},{value:"TRY",label:"TRY - Turkish Lira"},{value:"ZAR",label:"ZAR - South African Rand"},{value:"SAR",label:"SAR - Saudi Riyal"},{value:"AED",label:"AED - UAE Dirham"},{value:"ARS",label:"ARS - Argentine Peso"},{value:"CLP",label:"CLP - Chilean Peso"},{value:"COP",label:"COP - Colombian Peso"},{value:"THB",label:"THB - Thai Baht"},{value:"IDR",label:"IDR - Indonesian Rupiah"},{value:"MYR",label:"MYR - Malaysian Ringgit"},{value:"PHP",label:"PHP - Philippine Peso"},{value:"PLN",label:"PLN - Polish Zloty"},{value:"NGN",label:"NGN - Nigerian Naira"},{value:"KES",label:"KES - Kenyan Shilling"},{value:"GHS",label:"GHS - Ghanaian Cedi"},{value:"ZMW",label:"ZMW - Zambian Kwacha"},{value:"ZWL",label:"ZWL - Zimbabwean Dollar"},{value:"EGP",label:"EGP - Egyptian Pound"},{value:"MAD",label:"MAD - Moroccan Dirham"},{value:"UAH",label:"UAH - Ukrainian Hryvnia"},{value:"HUF",label:"HUF - Hungarian Forint"},{value:"CZK",label:"CZK - Czech Koruna"},{value:"RON",label:"RON - Romanian Leu"},{value:"PKR",label:"PKR - Pakistani Rupee"},{value:"BDT",label:"BDT - Bangladeshi Taka"},{value:"VND",label:"VND - Vietnamese Dong"},{value:"TWD",label:"TWD - New Taiwan Dollar"},{value:"ILS",label:"ILS - Israeli New Shekel"}],Yn=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"en-IN",label:"English (India)"},{value:"de-DE",label:"German"},{value:"fr-FR",label:"French"},{value:"es-ES",label:"Spanish"},{value:"it-IT",label:"Italian"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"zh-CN",label:"Chinese (Simplified)"},{value:"ja-JP",label:"Japanese"},{value:"ko-KR",label:"Korean"},{value:"ru-RU",label:"Russian"},{value:"ar-SA",label:"Arabic"},{value:"hi-IN",label:"Hindi"},{value:"nl-NL",label:"Dutch"},{value:"sv-SE",label:"Swedish"}],js=[{value:"millisecond",label:"Milliseconds"},{value:"second",label:"Seconds"},{value:"minute",label:"Minutes"},{value:"hour",label:"Hours"},{value:"day",label:"Days"}],il=[{value:"compact",label:"Compact (6min 32s)"},{value:"digital",label:"Digital (6:32)"},{value:"long",label:"Long (6 minutes 32 seconds)"}],cl=s=>s.charAt(0).toUpperCase()+s.slice(1);function dl(s,n){try{return ea.resolveCurrencyFractionDigits(s,n).maximumFractionDigits??as("currency")}catch{return as("currency")}}function Kt({formatOptions:s={},onFormatOptionsChange:n,showTitle:r=!0,title:o="NUMBER FORMAT",maxDecimalPlaces:i=10,reportDefaults:d,showAutoFormat:c=!0,showLocaleOverride:l=!0}){var E,M;const u=s.type||"auto",x=ol(s,{preserveSparseCurrency:!!d}),m=T=>{T.stopPropagation()},b=(T,R)=>{n({...x,[T]:R})},h=x.decimalPlaces??x.maximumFractionDigits??x.minimumFractionDigits,p=s.currency??(d==null?void 0:d.currency)??"USD",j=s.locale??(d==null?void 0:d.locale)??"en-US",N=u==="currency"?dl(j,p):void 0,f=h??N??as(u),g=u==="currency"&&x.decimalPlaces===void 0&&x.minimumFractionDigits===void 0&&x.maximumFractionDigits===void 0,[k,D]=v.useState(()=>String(f)),[w,S]=v.useState(()=>x.multiplyBy!==void 0?String(x.multiplyBy):""),L=T=>{const R=Ea(s,T,{preserveSparseCurrency:!!d});n(d&&T==="currency"&&s.type!=="currency"?Vn(R):R)},A=T=>d&&u==="currency"?rl(x,T):Ia(x,T),F=((E=_n.find(T=>T.value===(d==null?void 0:d.currency)))==null?void 0:E.label)??(d==null?void 0:d.currency),I=((M=Yn.find(T=>T.value===(d==null?void 0:d.locale)))==null?void 0:M.label)??(d==null?void 0:d.locale),y=u==="number"||u==="currency"||u==="percent"||u==="scientific";return v.useEffect(()=>{D(String(f))},[f]),v.useEffect(()=>{S(x.multiplyBy!==void 0?String(x.multiplyBy):"")},[x.multiplyBy]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[r&&e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),e.jsxs(t.Select,{value:u,onValueChange:T=>L(T),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:ll.filter(T=>c||T!=="auto").map(T=>e.jsx(t.SelectItem,{value:T,className:"text-xs",children:T==="auto"?"Auto (Default)":cl(T)},T))})]})]}),u!=="auto"&&e.jsxs("div",{className:"space-y-2 border-l-2 border-muted pl-4",children:[["number","currency","percent","scientific"].includes(u)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Decimals"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(t.Input,{type:"text",inputMode:"numeric",min:"0",max:i,placeholder:"0",value:k,onClick:m,onPointerDown:m,onKeyDown:m,onChange:T=>{const R=T.target.value.replace(/[^\d]/g,"");D(R),R!==""&&n(A(Math.max(0,Math.min(i,parseInt(R,10)))))},onBlur:()=>{if(k!=="")return;const T=f;D(String(T)),n(A(T))},className:"h-8 text-xs"}),g&&e.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"Currency default"})]})]}),u==="currency"&&e.jsx("div",{className:"space-y-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Currency"}),e.jsxs(t.Select,{value:s.currency||(d?Ft:"USD"),onValueChange:T=>{if(T===Ft){n(Vn(x));return}b("currency",T)},children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[d&&e.jsxs(t.SelectItem,{value:Ft,className:"text-xs",children:["Report default — ",F]}),_n.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))]})]})]})}),["number","currency"].includes(u)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Abbreviate (K, M, B)"}),e.jsx(t.Switch,{size:"sm",checked:s.useSuffix??!1,onClick:T=>T.stopPropagation(),onCheckedChange:T=>b("useSuffix",T)})]}),l&&u!=="duration"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Locale"}),e.jsxs(t.Select,{value:s.locale||(d&&y?Ft:"en-US"),onValueChange:T=>b("locale",T===Ft?void 0:T),children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[d&&y&&e.jsxs(t.SelectItem,{value:Ft,className:"text-xs",children:["Report default — ",I]}),Yn.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))]})]})]}),u==="number"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Prefix"}),e.jsx("div",{className:"flex-1",children:e.jsx(t.Input,{placeholder:"e.g., $",value:s.prefix||"",onClick:m,onPointerDown:m,onKeyDown:m,onChange:T=>b("prefix",T.target.value),className:"h-8 text-xs"})})]}),u==="number"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Suffix"}),e.jsx("div",{className:"flex-1",children:e.jsx(t.Input,{placeholder:"e.g., units",value:s.suffix||"",onClick:m,onPointerDown:m,onKeyDown:m,onChange:T=>b("suffix",T.target.value),className:"h-8 text-xs"})})]}),["number","currency"].includes(u)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Negative in ()"}),e.jsx(t.Switch,{size:"sm",checked:s.negativeInParentheses??!1,onClick:T=>T.stopPropagation(),onCheckedChange:T=>b("negativeInParentheses",T)})]}),u==="percent"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Multiply By"}),e.jsx("div",{className:"flex-1",children:e.jsx(t.Input,{type:"text",inputMode:"decimal",placeholder:"100",value:w,onClick:m,onPointerDown:m,onKeyDown:m,onChange:T=>{const R=T.target.value.replace(/[^0-9.]/g,"");S(R),b("multiplyBy",R?parseFloat(R):void 0)},className:"h-8 text-xs"})})]}),u==="date"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Format"}),e.jsx("div",{className:"flex-1",children:e.jsx(t.Input,{type:"text",placeholder:"MM/DD/YYYY",value:s.dateFormat||"",onClick:m,onPointerDown:m,onKeyDown:m,onChange:T=>b("dateFormat",T.target.value),className:"h-8 text-xs"})})]}),u==="duration"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Value Is"}),e.jsxs(t.Select,{value:s.durationInputUnit||"second",onValueChange:T=>b("durationInputUnit",T),children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:js.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Display"}),e.jsxs(t.Select,{value:s.durationDisplayStyle||"compact",onValueChange:T=>b("durationDisplayStyle",T),children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:il.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Smallest"}),e.jsxs(t.Select,{value:s.durationSmallestUnit||"second",onValueChange:T=>b("durationSmallestUnit",T),children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:js.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-20 text-xs text-muted-foreground",children:"Largest"}),e.jsxs(t.Select,{value:s.durationLargestUnit||"day",onValueChange:T=>b("durationLargestUnit",T),children:[e.jsx(t.SelectTrigger,{className:"h-8 flex-1 text-xs",onClick:m,onPointerDown:m,onKeyDown:m,children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:js.map(T=>e.jsx(t.SelectItem,{value:T.value,className:"text-xs",children:T.label},T.value))})]})]})]})]})]})}function zn({colorRanges:s,setColorRanges:n}){const r={start:-1/0,end:100,color:""};function o(c,l,u){const x=[...s];x[c]={...x[c],[l]:u},n(x)}function i(c){const l=[...s];l.splice(c,1),n(l)}function d(){n([...s,r])}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{children:"Color Range"}),e.jsx(t.Button,{onClick:d,variant:"secondary",className:"h-5 p-1 text-muted-foreground",children:e.jsx(a.Plus,{className:"size-3"})})]}),s.map((c,l)=>e.jsxs("div",{className:"flex items-center gap-2 px-2",children:[e.jsx(t.Input,{onChange:u=>o(l,"start",u.target.value),value:c.start,className:t.cn(`h-7 ${t.removeRing}`)}),e.jsx("span",{children:"-"}),e.jsx(t.Input,{value:c.end,onChange:u=>o(l,"end",u.target.value),className:t.cn(`h-7 ${t.removeRing}`)}),e.jsx(t.Input,{onChange:u=>o(l,"color",u.target.value),value:c.color,className:t.cn(`h-7 min-w-14 p-0 ${t.removeRing}`),type:"color",list:"presetColors"}),e.jsxs("datalist",{id:"presetColors",children:[e.jsx("option",{children:ye.colors.green[600]}),e.jsx("option",{children:ye.colors.red[500]}),e.jsx("option",{children:ye.colors.yellow[400]}),e.jsx("option",{children:ye.colors.orange[500]})]}),e.jsx(t.Button,{onClick:()=>i(l),variant:"secondary",className:"h-5 p-1 text-muted-foreground",children:e.jsx(le.X,{className:"size-3"})})]},l))]})}const ul=[];function ml(s){return(s==null?void 0:s.enabled)===!1||typeof(s==null?void 0:s.enabled)=="string"&&s.enabled.trim().toLowerCase()==="false"}function xl(s){var r;const n=t.fromPersistedKpiFormatOptions((r=s==null?void 0:s.kpiVisualOptions)==null?void 0:r.formatOptions)||(s!=null&&s.formatNumber?t.fromLegacyFormatNumber(s==null?void 0:s.formatNumber):void 0);return t.toTFormatOptions(n,{preserveOmittedProperties:!0})||{type:"number",minimumFractionDigits:0,maximumFractionDigits:0}}function qn(s){return{enabled:!0,colorRanges:s==null?void 0:s.colorRanges}}function hl(){var h,p,j,N;const s=t.useEditorStore(f=>f.card),n=t.useEditorStore(f=>f.actions.setCardPreferences),r=t.useEditorStore(f=>{var g,k;return((k=(g=f.card.preferences)==null?void 0:g.formatNumber)==null?void 0:k.colorRanges)??ul}),o=t.useEditorStore(f=>f.actions.setColorRanges),i=a.useResolvedValueFormatLocale()??$t.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,d=a.useResolvedDefaultCurrency()??$t.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.defaultCurrency,c=!a.isSqlBackedKpi(s)&&ye.hasValidCardConfig(s.config),l=xl(s.preferences),u=!!t.fromPersistedKpiFormatOptions((p=(h=s.preferences)==null?void 0:h.kpiVisualOptions)==null?void 0:p.formatOptions),x=!ml((j=s.preferences)==null?void 0:j.formatNumber)&&(u||!!((N=s.preferences)!=null&&N.formatNumber)),m=f=>{const g=t.useEditorStore.getState().card.preferences??{};n({...g,formatNumber:qn(g.formatNumber),kpiVisualOptions:{...g.kpiVisualOptions,formatOptions:f}})},b=f=>{const g=t.useEditorStore.getState().card.preferences??{};if(f){n({...g,formatNumber:qn(g.formatNumber),kpiVisualOptions:{...g.kpiVisualOptions,formatOptions:l}});return}n({...g,formatNumber:{...g.formatNumber,enabled:!1}})};return c?e.jsx(zn,{colorRanges:r,setColorRanges:o}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(a.Checkbox,{id:"query-kpi-format-number",checked:x,onCheckedChange:f=>b(f===!0)}),e.jsx(t.Label,{htmlFor:"query-kpi-format-number",className:"text-xs",children:"Format number"})]}),x&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Kt,{formatOptions:l,onFormatOptionsChange:m,showTitle:!1,showAutoFormat:!1,reportDefaults:{currency:d,locale:i}}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(zn,{colorRanges:r,setColorRanges:o})]})]})}const pl={combo:{label:"Combo Chart",query:"SELECT x-axis, metric-1, metric-2, ... FROM table",fields:[{name:"x-axis",type:"category",description:"dimension"},{name:"metric-1, metric-2",type:"number",description:"can be bar, line, or area"}],description:"Combo charts allow mixing bar and line series with optional dual Y-axis for metrics with different scales.",docsUrl:"https://docs.semaphor.cloud/docs/charts/combo"},area:{label:"Area Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, city"},{name:"Y-axis",type:"number",description:"e.g., sales, population"}],description:"Area charts display quantitative data with filled areas under the line.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},stackedArea:{label:"Stacked Area Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, city"},{name:"Y-axis",type:"number",description:"e.g., sales, population"}],description:"Stacked area charts show how multiple series contribute to a total over time.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},bar:{label:"Bar Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., city, product"},{name:"Y-axis",type:"number",description:"e.g., sales, count"}],description:"Bar charts compare values across categories using horizontal or vertical bars.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},line:{label:"Line Chart",query:"SELECT x-axis, y-axis-1, y-axis-2, ... FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date, month"},{name:"Y-axis",type:"number",description:"e.g., revenue, count"}],description:"Line charts show trends over time or continuous data.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bar-line-area"},stackedBar:{label:"Stacked Bar Chart",query:"SELECT x-axis, stack-by, y-axis FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., month"},{name:"Stack-by",type:"category",description:"e.g., product type"},{name:"Y-axis",type:"number",description:"e.g., sales"}],description:"Stacked bar charts show how parts contribute to a whole across categories.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},stackedLine:{label:"Stacked Line Chart",query:"SELECT x-axis, stack-by, y-axis FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., date"},{name:"Stack-by",type:"category",description:"e.g., region"},{name:"Y-axis",type:"number",description:"e.g., revenue"}],description:"Stacked line charts show cumulative trends over time.",docsUrl:"https://docs.semaphor.cloud/docs/charts/stacked"},pie:{label:"Pie Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., product, region"},{name:"Measure",type:"number",description:"e.g., sales, count"}],description:"Pie charts show proportions of a whole.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},doughnut:{label:"Doughnut Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., product, region"},{name:"Measure",type:"number",description:"e.g., sales, count"}],description:"Doughnut charts show proportions with a hollow center.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},polarArea:{label:"Polar Area Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., skill, metric"},{name:"Measure",type:"number",description:"e.g., score, value"}],description:"Polar area charts compare values using sectors of equal angle but varying radius.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},radar:{label:"Radar Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., attribute, skill"},{name:"Measure",type:"number",description:"e.g., score, rating"}],description:"Radar charts display multivariate data on axes starting from the same point.",docsUrl:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar"},funnel:{label:"Funnel Chart",query:"SELECT label, measure FROM table",fields:[{name:"Label",type:"category",description:"e.g., stage name"},{name:"Measure",type:"number",description:"e.g., count, value"}],description:"Funnel charts visualize progressive reduction of data through stages.",docsUrl:"https://docs.semaphor.cloud/docs/charts/funnel"},bubble:{label:"Bubble Chart",query:"SELECT label, [group], x-axis, y-axis, radius FROM table",fields:[{name:"Label",type:"category",description:"e.g., city"},{name:"Group",type:"category",description:"e.g., region",optional:!0},{name:"X-axis",type:"number",description:"e.g., population"},{name:"Y-axis",type:"number",description:"e.g., income"},{name:"Radius",type:"number",description:"e.g., area"}],description:"Bubble charts display three dimensions of data using position and size.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bubble"},scatter:{label:"Scatter Chart",query:"SELECT label, [group], x-axis, y-axis FROM table",fields:[{name:"Label",type:"category",description:"e.g., item name"},{name:"Group",type:"category",description:"e.g., type",optional:!0},{name:"X-axis",type:"number",description:"e.g., price"},{name:"Y-axis",type:"number",description:"e.g., quantity"}],description:"Scatter charts show relationships between two numeric variables.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bubble"},tornado:{label:"Tornado Chart",query:"SELECT dimension, cohort, metric FROM table",fields:[{name:"Dimension",type:"category",description:"e.g., age group"},{name:"Cohort",type:"category",description:"e.g., gender"},{name:"Metric",type:"number",description:"e.g., population"}],description:"Tornado charts compare two groups across categories using back-to-back bars.",docsUrl:"https://docs.semaphor.cloud/docs/charts/tornado"},pyramid:{label:"Pyramid Chart",query:"SELECT dimension, cohort, metric FROM table",fields:[{name:"Dimension",type:"category",description:"e.g., age group"},{name:"Cohort",type:"category",description:"e.g., gender"},{name:"Metric",type:"number",description:"e.g., population"}],description:"Population pyramids show age and gender distribution.",docsUrl:"https://docs.semaphor.cloud/docs/charts/tornado"},range:{label:"Range Chart",query:"SELECT y-axis, label, range-from, range-to, range-value FROM table",fields:[{name:"Y-axis",type:"category",description:"e.g., category"},{name:"Label",type:"category",description:"e.g., range name"},{name:"Range-from",type:"number",description:"start value"},{name:"Range-to",type:"number",description:"end value"},{name:"Range-value",type:"number",description:"e.g., midpoint"}],description:"Range charts display data ranges with start and end values.",docsUrl:"https://docs.semaphor.cloud/docs/charts/range"},heatmap:{label:"Heatmap",query:"SELECT x-axis, y-axis, value FROM table",fields:[{name:"X-axis",type:"category",description:"e.g., day"},{name:"Y-axis",type:"category",description:"e.g., hour"},{name:"Value",type:"number",description:"e.g., count, intensity"}],description:"Heatmaps visualize data density using color intensity.",docsUrl:"https://docs.semaphor.cloud/docs/charts/heatmap"},bullet:{label:"Bullet Chart",query:"SELECT label, actual, target, [ranges] FROM table",fields:[{name:"Label",type:"category",description:"e.g., metric name"},{name:"Actual",type:"number",description:"current value"},{name:"Target",type:"number",description:"goal value"},{name:"Ranges",type:"number",description:"threshold values",optional:!0}],description:"Bullet charts compare actual performance against targets.",docsUrl:"https://docs.semaphor.cloud/docs/charts/bullet"},text:{label:"Text Visual",query:"SELECT text FROM table LIMIT 1",fields:[{name:"Text",type:"string",description:"content to display"}],description:"Text visuals display dynamic text content from your data.",docsUrl:"https://docs.semaphor.cloud/docs/charts/text"},kpi:{label:"KPI",query:"SELECT current, previous FROM table",fields:[{name:"Current",type:"number",description:"current value"},{name:"Previous",type:"number",description:"comparison value"}],description:"KPI visuals display key performance indicators with comparison values.",docsUrl:"https://docs.semaphor.cloud/docs/charts/kpi"},map:{label:"Map Chart",query:"SELECT country, value FROM table",fields:[{name:"Country/Region",type:"category",description:"geographic identifier"},{name:"Value",type:"number",description:"e.g., population, sales"}],description:"Map charts visualize geographic data using color intensity.",docsUrl:"https://docs.semaphor.cloud/docs/charts/map"},table:{label:"Table",query:"SELECT column1, column2, ... FROM table",fields:[{name:"Columns",type:"category",description:"any data columns"}],description:"Tables display data in rows and columns.",docsUrl:"https://docs.semaphor.cloud/docs/charts/table"},detailTable:{label:"Detail Table",query:"SELECT column1, column2, ... FROM table ORDER BY column1 DESC",fields:[{name:"Columns",type:"category",description:"columns to display (no aggregation)"}],description:"Detail tables display raw records without aggregation. Ideal for event logs, transaction history, and audit trails.",docsUrl:"https://docs.semaphor.cloud/docs/charts/detail-table"}};function Da(s){return pl[s]}function fl({chartType:s,showDocsLink:n=!0}){const r=Da(s);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Query Format"}),e.jsx("code",{className:"block rounded-md bg-muted/50 px-3 py-2 font-mono text-xs text-foreground",children:r.query})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("div",{className:"rounded-md border",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Field"}),e.jsx("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Description"})]})}),e.jsx("tbody",{children:r.fields.map((o,i)=>e.jsxs("tr",{className:i<r.fields.length-1?"border-b":"",children:[e.jsxs("td",{className:"px-2.5 py-1.5 font-medium text-foreground",children:[o.name,o.optional&&e.jsx("span",{className:"ml-1 text-muted-foreground",children:"?"})]}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-muted-foreground",children:o.type}),e.jsx("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:o.description||"—"})]},o.name))})]})})]}),e.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:r.description}),n&&r.docsUrl&&e.jsxs("a",{href:r.docsUrl,target:"_blank",rel:"noopener noreferrer",onClick:o=>o.stopPropagation(),className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline",children:["View documentation",e.jsx(a.ExternalLink,{className:"h-3 w-3"})]})]}):null}function gl({chartType:s}){return Da(s)?e.jsxs(a.HoverCard,{openDelay:200,children:[e.jsx(a.HoverCardTrigger,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded bg-muted px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground",children:"SQL"})}),e.jsx(a.HoverCardContent,{className:"w-80 p-4",side:"left",align:"start",sideOffset:8,children:e.jsx(fl,{chartType:s})})]}):null}function Os({chartType:s,suffix:n="Configuration"}){return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-medium",children:n}),e.jsx(gl,{chartType:s})]})}function bl(){const s=t.useEditorStore(i=>!ye.hasValidCardConfig(i.card.config)),n=t.useEditorStore(i=>{var d,c;return((c=(d=i.card.preferences)==null?void 0:d.kpiVisualOptions)==null?void 0:c.queryComparisonPolarity)??Tn.DEFAULT_METRIC_COMPARISON_POLARITY}),r=t.useEditorStore(i=>i.actions.setCardPreferences),o=i=>{const d=t.useEditorStore.getState().card.preferences??{},c={...d.kpiVisualOptions,queryComparisonPolarity:i===Tn.DEFAULT_METRIC_COMPARISON_POLARITY?void 0:i};r({...d,kpiVisualOptions:c})};return e.jsxs("div",{className:"space-y-6 px-6 py-4",children:[e.jsx(Os,{chartType:"kpi"}),e.jsx("section",{children:e.jsx(hl,{})}),s&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx(t.Label,{htmlFor:"query-kpi-favorable-direction",className:"text-xs",children:"Favorable direction"}),e.jsxs(t.Select,{value:n,onValueChange:i=>o(i),children:[e.jsx(t.SelectTrigger,{id:"query-kpi-favorable-direction",className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"higher_is_better",children:"Higher is better"}),e.jsx(t.SelectItem,{value:"lower_is_better",children:"Lower is better"}),e.jsx(t.SelectItem,{value:"neutral",children:"Neutral"})]})]}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Applies when the query returns current and comparison values."})]})]})}function $n({children:s,summary:n,open:r,className:o}){return e.jsxs("details",{open:r,className:t.cn("space-y-4 [&_summary>svg]:open:-rotate-180",o),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(t.Label,{children:n}),e.jsx(t.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function jl(){const[s,n]=v.useState([]),r=t.useEditorStore(x=>x.card.preferences),{setFilterOnClickColumnIndex:o,setCardPreferences:i}=t.useEditorStore(x=>x.actions),d=t.useEditorStore(x=>x.queryResultColumns);t.useEditorStore(x=>{var m;return(m=x.card.preferences)==null?void 0:m.filterOnClickColumnIndex}),v.useEffect(()=>{d&&n(new Array(d.length).fill(!1))},[d]);function c(x,m){var b,h;m?r!=null&&r.onClickFilter&&((b=r==null?void 0:r.onClickFilter)==null?void 0:b.length)>0?i({...r,onClickFilter:[...r.onClickFilter,{columnIndex:x,expression:""}]}):i({...r,onClickFilter:[{columnIndex:x,expression:""}]}):(i({...r,onClickFilter:(h=r==null?void 0:r.onClickFilter)==null?void 0:h.filter(p=>p.columnIndex!==x)}),n(p=>{const j=[...p];return j[x]=!1,j}))}function l(x,m){var h;const b=(h=r==null?void 0:r.onClickFilter)==null?void 0:h.map(p=>p.columnIndex===x?{...p,expression:m.target.value}:p);i({...r,onClickFilter:b})}function u(x){var m,b,h,p;if(s!=null&&s[x]||(b=(m=r==null?void 0:r.onClickFilter)==null?void 0:m.find(j=>j.columnIndex===x))!=null&&b.expression)return e.jsx(t.Input,{value:(p=(h=r==null?void 0:r.onClickFilter)==null?void 0:h.find(j=>j.columnIndex===x))==null?void 0:p.expression,onChange:j=>l(x,j),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsx("div",{className:"max-h-[150px] space-y-2 overflow-y-auto",children:d==null?void 0:d.map((x,m)=>{var b,h;return e.jsx("div",{className:"group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(a.Checkbox,{checked:!!((b=r==null?void 0:r.onClickFilter)!=null&&b.find(p=>p.columnIndex===m)),onCheckedChange:p=>c(m,p)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),e.jsx("div",{className:"flex items-center gap-2",children:((h=r==null?void 0:r.onClickFilter)==null?void 0:h.find(p=>p.columnIndex===m))&&e.jsx(a.Pencil,{onClick:()=>{n(p=>{const j=[...p];return j[m]=!p[m],j})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),u(m)]})},x)})})}const vl=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],yl=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Cl=yl.map(s=>({label:s,value:s}));function Nl(){var u,x,m,b,h,p,j,N,f,g,k,D,w,S,L,A,F,I;const s=t.useEditorStore(y=>y.card),n=(x=(u=s==null?void 0:s.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.topoJsonUrl,[r,o]=v.useState(((b=(m=s==null?void 0:s.preferences)==null?void 0:m.mapVisualOptions)==null?void 0:b.customTopoJsonUrl)||""),{setCardPreferences:i}=t.useEditorActions(),{data:d}=a.useTopoJson(s),c=Object.keys((d==null?void 0:d.objects)||{}).map(y=>({label:y,value:y}))||[],l=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxs("div",{className:"space-y-4 px-6 py-4",children:[e.jsx(Os,{chartType:"map"}),e.jsx($n,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(pt,{className:"h-9",options:l,onValueChange:y=>{console.log("value",y),i({...s.preferences,mapVisualOptions:{topoJsonUrl:y}})},value:n||"",label:"Select Map"}),n==="custom"&&e.jsx(t.Input,{onChange:y=>{o(y.target.value)},onBlur:()=>{var y;console.log("onBlur",r),i({...s.preferences,mapVisualOptions:{...(y=s.preferences)==null?void 0:y.mapVisualOptions,customTopoJsonUrl:r}})},value:r,className:`h-9 w-full ${t.removeRing}`,placeholder:"Custom URL"}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Map Object"}),e.jsx(pt,{className:"h-9",options:c,value:((p=(h=s.preferences)==null?void 0:h.mapVisualOptions)==null?void 0:p.objectKey)||"",label:"Map Object",onValueChange:y=>{var E;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,objectKey:y}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(pt,{className:"h-9",options:vl,value:((N=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:N.projection)||"",label:"Projection",onValueChange:y=>{var E;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,projection:y}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(pt,{className:"h-9",options:Cl,value:((g=(f=s.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:y=>{var E;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,colorScale:y}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx($n,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:.1,value:((D=(k=s.preferences)==null?void 0:k.mapVisualOptions)==null?void 0:D.projectionScale)||1,onChange:y=>{var E;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,projectionScale:Number(y.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((L=(S=(w=s.preferences)==null?void 0:w.mapVisualOptions)==null?void 0:S.projectionOffset)==null?void 0:L[0])||0,onChange:y=>{var E,M,T,R;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,projectionOffset:[Number(y.target.value),((R=(T=(M=s.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:T.projectionOffset)==null?void 0:R[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((I=(F=(A=s.preferences)==null?void 0:A.mapVisualOptions)==null?void 0:F.projectionOffset)==null?void 0:I[1])||0,onChange:y=>{var E,M,T,R;i({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,projectionOffset:[((R=(T=(M=s.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:T.projectionOffset)==null?void 0:R[0])||0,Number(y.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(jl,{})]})}function We({label:s,value:n,options:r,onChange:o,disabled:i}){const d=v.useId();return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(t.Label,{htmlFor:d,className:"text-xs",children:s}),e.jsxs(t.Select,{value:n,onValueChange:o,disabled:i,children:[e.jsx(t.SelectTrigger,{id:d,"aria-label":s,className:"h-8 min-w-0 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:r.map(c=>e.jsx(t.SelectItem,{value:c.value,className:"text-xs",children:c.label},c.value))})]})]})}function Tt({label:s,value:n,onChange:r,type:o="text",min:i,max:d}){const c=v.useId();return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(t.Label,{htmlFor:c,className:"text-xs",children:s}),e.jsx(t.Input,{id:c,className:"h-8 text-xs",type:o,min:i,max:d,value:n,onChange:l=>r(l.target.value)})]})}function Bs({label:s,checked:n,onChange:r}){const o=v.useId();return e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 py-1",children:[e.jsx(t.Label,{className:"text-xs",htmlFor:o,children:s}),e.jsx(t.Switch,{id:o,size:"xs",checked:n,onCheckedChange:r})]})}function Sl({label:s,disabled:n,onClick:r,children:o}){return e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":s,title:s,disabled:n,onClick:r,children:o})}function Kn({label:s,value:n,onChange:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Bs,{label:s,checked:n.visible,onChange:o=>r({...n,visible:o})}),e.jsx(We,{label:`${s} position`,value:n.position,options:[{value:"before",label:"Before"},{value:"after",label:"After"}],onChange:o=>r({...n,position:o})}),e.jsx(Tt,{label:`${s} label`,value:n.label??"",onChange:o=>r({...n,label:o||void 0})})]})}function Es({value:s,onChange:n,cardType:r,showTitle:o=!0,title:i="NUMBER FORMAT",showLocaleOverride:d=!0}){const c=a.supportsLiveNumericPresentation(r),l=a.useResolvedValueFormatLocale(),u=a.useResolvedDefaultCurrency(),x=t.toTFormatOptions(xr.fromSemanticFormat(s,{preserveOmittedProperties:!0}),{preserveOmittedProperties:!0})||{},m=b=>{const h=t.fromTFormatOptions(b,{preserveOmittedProperties:!0});if(!d&&h&&"locale"in h){const{locale:p,...j}=h;n(j)}else n(h)};return e.jsx(Kt,{formatOptions:x,onFormatOptionsChange:m,showTitle:o,title:i,showLocaleOverride:d,reportDefaults:c?{currency:u??$t.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.defaultCurrency,locale:l??$t.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale}:void 0})}function wl(s){switch(s==null?void 0:s.type){case"date":case"datetime":return{...s,type:"date"};case"number":case"currency":case"percent":case"percentage":case"scientific":case"duration":case"string":return s;default:return}}function ka(s,n,r){const o=(r==null?void 0:r.length)&&r.every((i,d)=>{var c;return((c=s[d])==null?void 0:c.id)===i.levelId&&i.member.kind==="value"});return new Map([...n!=null&&n.length?[[st.matrixPathKey(n),n]]:[],...o?[[st.matrixPathKey(r),r]]:[]])}function Tl({axis:s,level:n,value:r,change:o,scopeSelection:i}){const d=r.spec.sorts.find(h=>h.axis===s&&h.levelId===n.id&&h.scope.kind==="level"),c=r.spec.rankings.find(h=>h.axis===s&&h.levelId===n.id),l=s==="rows"?"columns":"rows",u=ka(r.spec[l],c==null?void 0:c.oppositePath,l==="rows"?i==null?void 0:i.rowPath:i==null?void 0:i.columnPath),x=r.spec.measures.map(h=>({value:h.id,label:ft.getMatrixMeasureLabel(h,r.presentation)})),m=h=>{const p=r.spec.sorts.filter(j=>!(j.axis===s&&j.levelId===n.id&&j.scope.kind==="level"));o({kind:"sorts",sorts:h?[...p,{axis:s,levelId:n.id,scope:{kind:"level"},target:{kind:"member"},direction:"asc",nulls:"last",...d,...h}]:p})},b=h=>{if(h&&!r.spec.measures.length)return;const p=r.spec.rankings.filter(j=>!(j.axis===s&&j.levelId===n.id));o({kind:"rankings",rankings:h?[...p,{id:ye.v4(),axis:s,levelId:n.id,direction:"top",count:10,measureId:r.spec.measures[0].id,oppositePath:[],others:!1,...c,...h}]:p})};return e.jsxs("div",{className:"space-y-2 border-t pt-2",children:[e.jsx(We,{label:"Sort by",value:d?d.target.kind==="member"?"member":d.target.measureId:"default",options:[{value:"default",label:"Default"},{value:"member",label:"Member"},...x],onChange:h=>m(h==="default"?void 0:{target:h==="member"?{kind:"member"}:{kind:"measure",measureId:h,oppositePath:[]}})}),d&&e.jsxs(e.Fragment,{children:[e.jsx(We,{label:"Sort direction",value:d.direction,options:[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],onChange:h=>m({direction:h})}),e.jsx(We,{label:"Null order",value:d.nulls,options:[{value:"first",label:"First"},{value:"last",label:"Last"}],onChange:h=>m({nulls:h})})]}),e.jsx(We,{label:"Ranking",disabled:!r.spec.measures.length,value:(c==null?void 0:c.direction)??"none",options:[{value:"none",label:"None"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"}],onChange:h=>b(h==="none"?void 0:{direction:h})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(Tt,{label:"Ranking count",type:"number",min:1,value:c.count,onChange:h=>{h&&Number.isSafeInteger(Number(h))&&Number(h)>0&&b({count:Number(h)})}}),e.jsx(We,{label:"Rank by measure",value:c.measureId,options:x,onChange:h=>b({measureId:h})}),e.jsx(Bs,{label:"Include Others",checked:c.others,onChange:h=>b({others:h})}),e.jsx(We,{label:"Ranking context",value:c.oppositePath.length?st.matrixPathKey(c.oppositePath):"total",options:[{value:"total",label:"Grand total"},...[...u].map(([h,p])=>({value:h,label:p.map((j,N)=>ta.matrixMemberLabel(p.slice(0,N+1))).join(" / ")}))],onChange:h=>b({oppositePath:h==="total"?[]:[...u.get(h)]})})]})]})}function El({value:s,change:n,scopeSelection:r}){var f,g,k;const[o,i]=v.useState(((f=s.presentation.conditionalFormatting)==null?void 0:f.rules)??[]),[d,c]=v.useState(s.spec),[l,u]=v.useState(""),x=JSON.stringify(s.presentation.conditionalFormatting??{version:1,rules:[]}),m=v.useRef(x);x!==m.current&&(m.current=x,JSON.stringify(st.matrixConditionalFormattingSchema.safeParse({version:1,rules:o}).data??null)!==x&&i(((g=s.presentation.conditionalFormatting)==null?void 0:g.rules)??[]));const b=o.filter(a.isRuleReadyToApply);v.useEffect(()=>{const D=st.matrixConditionalFormattingSchema.safeParse({version:1,rules:b});if(!D.success)return;const w=JSON.stringify(D.data);w!==m.current&&(m.current=w,n({kind:"presentation",presentation:{...s.presentation,conditionalFormatting:D.data}}))},[b,n,s.presentation]);const h=o.find(D=>!a.isRuleReadyToApply(D)),p=st.matrixConditionalFormattingSchema.safeParse({version:1,rules:b}),j=h?`${h.name||"the new rule"} is incomplete`:p.success?"":((k=p.error.issues[0])==null?void 0:k.message)??"the rule is incomplete";if(d!==s.spec){const D=[],w=It.retainMatrixConditionalFormatting(d,s.spec,{version:1,rules:o},D);c(s.spec),D.length&&(i((w==null?void 0:w.rules)??[]),u("Removed rules whose measure, level or member path changed."))}const N=s.spec.measures[0];return N?e.jsxs("div",{className:"min-w-0 space-y-2",children:[l&&e.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:l}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Not applied yet: ",j]}),e.jsx(a.DataTableConditionalFormattingSettings,{columnId:N.id,availableColumns:s.spec.measures.map(D=>({value:D.id,label:ft.getMatrixMeasureLabel(D,s.presentation)})),conditionalRules:o,onConditionalRulesChange:i,capabilities:{ruleKinds:["comparison","colorScale","dataBar"],automaticRanges:!1,separateApplyTargets:!0,targetScope:{defaultRowRoles:["member"]}}}),o.map((D,w)=>{var y;const S=D.target.matrix,L=(S==null?void 0:S.axis)==="columns"?"rows":"columns",A=L==="rows"?r==null?void 0:r.rowPath:r==null?void 0:r.columnPath,F=ka(s.spec[L],S==null?void 0:S.oppositePath,A),I=E=>i(M=>M.map(T=>T.id===D.id?{...T,target:{...T.target,matrix:E}}:T));return e.jsxs("fieldset",{className:"min-w-0 space-y-2 border-t pt-2",children:[e.jsxs("legend",{className:"text-xs font-medium",children:[D.name||`Rule ${w+1}`," scope"]}),e.jsx(We,{label:"Cell role",value:((y=D.target.rowRoles)==null?void 0:y.length)===1?D.target.rowRoles[0]:"all",options:[{value:"all",label:"All roles"},{value:"member",label:"Detail"},{value:"subtotal",label:"Subtotal"},{value:"grand_total",label:"Grand total"},{value:"others",label:"Others"}],onChange:E=>i(M=>M.map(T=>{if(T.id!==D.id)return T;const{tableParts:R,includeTotals:C,includeSubtotals:V,...P}=T.target;return{...T,target:{...P,rowRoles:E==="all"?void 0:[E]}}}))}),e.jsx(We,{label:"Rule axis",value:(S==null?void 0:S.axis)??"all",options:[{value:"all",label:"All cells"},{value:"rows",label:"Rows"},{value:"columns",label:"Columns"}],onChange:E=>I(E==="all"?void 0:{axis:E})}),S&&e.jsxs(e.Fragment,{children:[e.jsx(We,{label:"Rule level",value:S.levelId??"all",options:[{value:"all",label:"All levels"},...s.spec[S.axis].map(E=>({value:E.id,label:ft.getMatrixLevelLabel(E,s.presentation)}))],onChange:E=>I({...S,levelId:E==="all"?void 0:E})}),e.jsx(We,{label:"Opposite members",value:S.oppositePath===void 0?"all":S.oppositePath.length?st.matrixPathKey(S.oppositePath):"total",options:[{value:"all",label:"All members"},{value:"total",label:"Grand total"},...[...F].map(([E,M])=>({value:E,label:M.map((T,R)=>ta.matrixMemberLabel(M.slice(0,R+1))).join(" / ")}))],onChange:E=>I({...S,oppositePath:E==="all"?void 0:E==="total"?[]:[...F.get(E)]})})]})]},D.id)})]}):e.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"No metrics available"})}function Il({section:s,value:n,availableFields:r,bindings:o,scopeSelection:i,onChange:d}){const[c,l]=v.useState([]),[u,x]=v.useState(""),m=N=>ye.matrixAuthoringDataType(N,n.spec.source,r),b=N=>{try{const f=It.updateMatrixConfig(n,N,o,m,!0);x(""),l(f.notices),d(f.config,f.notices,f.removedBindings,f.bindings)}catch(f){x(f instanceof Error?f.message:"Invalid Matrix settings.")}},h=N=>b({kind:"presentation",presentation:{...n.presentation,...N}}),p=(N,f,g)=>{const k={...n.presentation[N]};if(g===void 0)delete k[f];else{const D=st.semaphorValueFormatSchema.safeParse(g);if(!D.success){x(D.error.message);return}k[f]=D.data}h({[N]:k})},j=(N,f)=>{const g=n.presentation[f][N];return e.jsx(Es,{showLocaleOverride:!1,cardType:"matrixTable",value:wl(g),onChange:k=>p(f,N,k)})};return e.jsxs("aside",{"aria-label":"Matrix authoring",className:"min-w-0 text-foreground",children:[u&&e.jsx("p",{role:"alert",className:"break-words p-3 text-xs text-destructive",children:u}),c.length>0&&e.jsxs("div",{role:"status",className:"border-b p-3 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("strong",{children:"Updated references"}),e.jsx(Sl,{label:"Dismiss cleanup notices",onClick:()=>l([]),children:e.jsx(le.X,{className:"size-3.5"})})]}),e.jsx("ul",{className:"space-y-1",children:c.map((N,f)=>e.jsx("li",{children:N.message},`${N.kind}-${N.id}-${f}`))})]}),s.kind!=="conditional-formatting"&&["rows","columns"].filter(N=>s.kind!=="field"||n.spec[N].some(f=>f.id===s.id)).map(N=>e.jsxs("section",{"aria-label":s.kind==="field"?`Field ${s.id}`:N==="rows"?"Rows":"Columns",className:(s==null?void 0:s.kind)==="field"?"space-y-2":"space-y-2 border-b p-3",children:[(s==null?void 0:s.kind)!=="field"&&e.jsx("h2",{className:"text-xs font-semibold",children:N==="rows"?"Rows":"Columns"}),n.spec[N].filter(f=>s.kind==="field"&&f.id===s.id).map(f=>{const g=ft.getMatrixLevelLabel(f,n.presentation),k=F=>b({kind:"structure",[N]:n.spec[N].map(I=>I.id===f.id?F:I)}),D=m(f.field),w=D==="date"||D==="datetime",S=n.presentation.levelFormats[f.id],L=(S==null?void 0:S.type)==="temporal_bucket"?S:Ze.AUTOMATIC_TEMPORAL_BUCKET_FORMAT,A=f.grain?Ze.getTemporalBucketAuthoringSelection(L,f.grain):void 0;return e.jsxs("div",{className:(s==null?void 0:s.kind)==="field"?"min-w-0":"min-w-0 border-b pb-2",children:[e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-1",children:e.jsx("span",{className:"truncate text-xs font-medium",title:g,children:g})}),e.jsxs("details",{open:(s==null?void 0:s.kind)==="field"?!0:void 0,children:[e.jsxs("summary",{className:`cursor-pointer py-1 text-xs text-muted-foreground ${(s==null?void 0:s.kind)==="field"?"hidden":""}`,children:[g," settings"]}),e.jsxs("div",{className:(s==null?void 0:s.kind)==="field"?"space-y-2 pt-2":"space-y-2 py-2",children:[e.jsx(Tt,{label:"Level label",value:n.presentation.levelLabels[f.id]??"",onChange:F=>{const I={...n.presentation.levelLabels};F?I[f.id]=F:delete I[f.id],h({levelLabels:I})}}),e.jsx(We,{label:"Axis",value:N,options:[{value:"rows",label:"Rows"},{value:"columns",label:"Columns"}],onChange:F=>{F!==N&&b(It.moveMatrixLevel(n.spec,f.id,F))}}),w&&e.jsx(We,{label:"Time grain",value:f.grain??"none",options:[{value:"none",label:"No grouping"},...a.getGranularityOptionsForFieldType(D).map(F=>({value:F,label:F}))],onChange:F=>k({...f,grain:F==="none"?void 0:F})}),f.grain?e.jsxs(e.Fragment,{children:[e.jsx(We,{label:"Date format",value:A.value,options:Ze.getTemporalBucketAuthoringOptions(f.grain,L),onChange:F=>p("levelFormats",f.id,F==="auto"?void 0:Ze.resolveTemporalBucketAuthoringFormat(f.grain,F,A.customPattern))}),A.value==="custom"&&e.jsx(Tt,{label:"Date pattern",value:A.customPattern,onChange:F=>{F.trim()&&p("levelFormats",f.id,{type:"temporal_bucket",presentation:{mode:"pattern",pattern:F}})}})]}):j(f.id,"levelFormats"),e.jsx(Kn,{label:"Subtotal",value:n.presentation.totals[N].levels[f.id],onChange:F=>h({totals:{...n.presentation.totals,[N]:{...n.presentation.totals[N],levels:{...n.presentation.totals[N].levels,[f.id]:F}}}})}),e.jsx(Tl,{axis:N,level:f,value:n,change:b,scopeSelection:i})]})]})]},f.id)}),(s==null?void 0:s.kind)!=="field"&&e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer py-1 text-xs text-muted-foreground",children:[N==="rows"?"Row":"Column"," totals and expansion"]}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Kn,{label:"Grand total",value:n.presentation.totals[N].grand,onChange:f=>h({totals:{...n.presentation.totals,[N]:{...n.presentation.totals[N],grand:f}}})}),e.jsx(We,{label:"Default expanded levels",value:String(Math.min(n.defaultView[N].depth,Math.max(0,n.spec[N].length-1))),options:Array.from({length:Math.max(1,n.spec[N].length)},(f,g)=>({value:String(g),label:g===0?"Collapsed":String(g)})),onChange:f=>b({kind:"defaults",defaultView:{...n.defaultView,[N]:{...n.defaultView[N],depth:Number(f)}}})})]})]})]},N)),s.kind==="field"&&n.spec.measures.some(N=>N.id===s.id)&&e.jsx("section",{"aria-label":"Values",className:"space-y-2",children:n.spec.measures.filter(N=>N.id===s.id).map(N=>{const f=ft.getMatrixMeasureLabel(N,n.presentation);return e.jsxs("div",{className:(s==null?void 0:s.kind)==="field"?"min-w-0":"min-w-0 border-b pb-2",children:[e.jsx("div",{className:"flex min-w-0 items-center justify-between gap-1",children:e.jsxs("span",{className:"truncate text-xs font-medium",title:f,children:[f,N.kind==="aggregate"?` (${N.aggregate})`:""]})}),e.jsxs("details",{open:(s==null?void 0:s.kind)==="field"?!0:void 0,children:[e.jsxs("summary",{className:`cursor-pointer py-1 text-xs text-muted-foreground ${(s==null?void 0:s.kind)==="field"?"hidden":""}`,children:[f," settings"]}),e.jsxs("div",{className:(s==null?void 0:s.kind)==="field"?"space-y-2 pt-2":"space-y-2 py-2",children:[e.jsx(Tt,{label:"Measure label",value:n.presentation.measureLabels[N.id]??"",onChange:g=>{const k={...n.presentation.measureLabels};g?k[N.id]=g:delete k[N.id],h({measureLabels:k})}}),N.kind==="aggregate"&&e.jsx(We,{label:"Aggregation",value:N.aggregate,options:Ze.getFieldAggregationOptions(m(N.field)).filter(g=>st.matrixAggregateSchema.safeParse(g.value).success).map(({value:g})=>({value:g,label:g})),onChange:g=>b({kind:"structure",measures:n.spec.measures.map(k=>k.id===N.id?{...N,aggregate:st.matrixAggregateSchema.parse(g)}:k)})}),j(N.id,"measureFormats")]})]})]},N.id)})}),s.kind==="table"&&e.jsxs("section",{"aria-label":"Presentation",className:"space-y-2 border-b p-3",children:[e.jsx("h2",{className:"text-xs font-semibold",children:"Presentation"}),e.jsx(We,{label:"Row layout",value:n.presentation.layout.kind,options:[{value:"compact",label:"Compact"},{value:"tabular",label:"Tabular"}],onChange:N=>h({layout:N==="compact"?{kind:"compact"}:{kind:"tabular",repeatLabels:!1}})}),n.presentation.layout.kind==="tabular"&&e.jsx(Bs,{label:"Repeat row labels",checked:n.presentation.layout.repeatLabels,onChange:N=>h({layout:{kind:"tabular",repeatLabels:N}})}),e.jsx(Tt,{label:"Empty cell text",value:n.presentation.absence.emptyText,onChange:N=>h({absence:{...n.presentation.absence,emptyText:N}})}),e.jsx(Tt,{label:"Null cell text",value:n.presentation.absence.nullText,onChange:N=>h({absence:{...n.presentation.absence,nullText:N}})})]}),s.kind==="conditional-formatting"&&e.jsxs("section",{"aria-label":"Conditional formatting",className:"min-w-0 space-y-2 p-3",children:[e.jsx("h2",{className:"text-xs font-semibold",children:"Conditional formatting"}),e.jsx(El,{value:n,change:b,scopeSelection:i})]})]})}function Is({fieldId:s,section:n="table"}){const r=t.useEditorStore(l=>l.card),o=t.useEditorStore(l=>l.actions.updateCard),i=t.useEditorStore(l=>l.matrixSelection),d=a.useMatrixEditorCatalog(r),c=ye.readMatrixEditorConfig(r);return c.status==="invalid"?e.jsx("div",{role:"alert",className:"p-3 text-xs text-destructive",children:"Invalid Matrix configuration. Repair or reset the card definition."}):c.status==="absent"?e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"No fields selected"}):e.jsx(Il,{value:c.config,section:s?{kind:"field",id:s}:{kind:n},scopeSelection:(i==null?void 0:i.cardId)===r.id?i.coordinate:void 0,bindings:r.controlBindings,availableFields:d.catalog.map(l=>({...l.field,dataType:st.normalizeAnalyticsCatalogDataType(l.resolvedField.dataType)})),onChange:(l,u,x,m)=>{const b=a.applyMatrixEditorResult(r,{config:l,notices:u,bindings:m});o(r.id,b.card)}})}const Dl={green:"#16a34a",red:"#dc2626",neutral:"#6b7280"};function kl(s){return s&&(Dl[s]??s)}function Ma({value:s,onChange:n,showPosition:r=!1}){const o=s.colors||{};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Calculated as"}),e.jsxs(t.Select,{value:s.displayMode||"difference",onValueChange:i=>n({displayMode:i}),children:[e.jsx(t.SelectTrigger,{className:"h-7 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"difference",children:"Difference"}),e.jsx(t.SelectItem,{value:"percent_change",children:"Percent change"}),e.jsx(t.SelectItem,{value:"both",children:"Both"}),e.jsx(t.SelectItem,{value:"ratio",children:"Ratio (current ÷ comparison)"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(t.Label,{htmlFor:"comparison-precision",className:"text-xs",children:"Percent/ratio precision"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"0 through 6 decimals"})]}),e.jsx(t.Input,{id:"comparison-precision",type:"number",min:0,max:6,step:1,value:s.precision??"",placeholder:"Default",onChange:i=>{if(i.target.value===""){n({precision:void 0});return}const d=Number(i.target.value);Number.isInteger(d)&&d>=0&&d<=6&&n({precision:d})},className:"h-7 w-16 text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Indicator"}),e.jsxs(t.Select,{value:s.indicatorStyle||"arrow_badge",onValueChange:i=>n({indicatorStyle:i}),children:[e.jsx(t.SelectTrigger,{className:"h-7 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"arrow_badge",children:"Arrow + badge"}),e.jsx(t.SelectItem,{value:"arrow",children:"Arrow"}),e.jsx(t.SelectItem,{value:"badge",children:"Badge"}),e.jsx(t.SelectItem,{value:"none",children:"None"})]})]})]}),r&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Position"}),e.jsxs(t.Select,{value:s.position||"right",onValueChange:i=>n({position:i}),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-24 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"right",children:"Right"}),e.jsx(t.SelectItem,{value:"left",children:"Left"}),e.jsx(t.SelectItem,{value:"top",children:"Top"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{htmlFor:"comparison-color",className:"text-xs",children:"Use sentiment color"}),e.jsx(t.Switch,{id:"comparison-color",size:"xs",checked:s.showColor!==!1,onCheckedChange:i=>n({showColor:i})})]}),s.showColor!==!1&&e.jsx("div",{className:"space-y-1.5",children:[["increase","Increase","#16a34a"],["decrease","Decrease","#dc2626"],["neutral","No change","#6b7280"]].map(([i,d,c])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-24 shrink-0 text-xs text-muted-foreground",children:d}),e.jsx(a.ColorField,{value:kl(o[i]||c),onChange:l=>n({colors:{...o,[i]:l||c}}),defaultValue:c,ariaLabel:`${d} color`,allowEmpty:!1})]},i))}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{htmlFor:"comparison-conditional-label",className:"text-xs",children:"Different label per direction"}),e.jsx(t.Switch,{id:"comparison-conditional-label",size:"xs",checked:s.conditionalLabel===!0,onCheckedChange:i=>n({conditionalLabel:i})})]}),s.conditionalLabel?e.jsx("div",{className:"space-y-1.5",children:[["increase","Increase"],["decrease","Decrease"],["neutral","No change"]].map(([i,d])=>{var c;return e.jsx(t.Input,{"aria-label":`${d} label`,value:((c=s.conditionalLabels)==null?void 0:c[i])||d,onChange:l=>n({conditionalLabels:{...s.conditionalLabels,[i]:l.target.value}}),className:"h-7 text-xs"},i)})}):e.jsx(t.Input,{"aria-label":"Comparison label",value:s.labelName||"",onChange:i=>n({labelName:i.target.value}),placeholder:"Previous",className:"h-7 text-xs"})]})}function Ml(){var b,h,p,j,N;const s=t.useEditorStore(f=>f.card),{setCardPreferences:n}=t.useEditorActions(),r=a.useEffectiveEditorCardType(),o=((b=s.config)==null?void 0:b.metricColumns)||[],i=o.length===2&&(((h=s.config)==null?void 0:h.groupByColumns)||[]).length===0,d=o.some(f=>{var g;return((g=f.comparison)==null?void 0:g.mode)==="explicit"});if(!t.COMPARISON_PRESENTATION_SUPPORTED_CHART_TYPES.includes(r))return null;const l=((p=s.preferences)==null?void 0:p.comparisonPresentation)||{},u=f=>n({...s.preferences,comparisonPresentation:{...l,...f}}),x=r==="kpi"&&((j=s.preferences)==null?void 0:j.metricPairComparisonEnabled)===!0,m=d||x;return e.jsxs(a.AccordionItem,{value:"comparison",className:"border-none",children:[e.jsx(a.AccordionTrigger,{className:"flex items-center gap-2 py-2 text-[12px] hover:no-underline [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cr,{className:"h-3.5 w-3.5 text-foreground/60"}),e.jsx("span",{children:"Comparison"})]})}),e.jsxs(a.AccordionContent,{className:"space-y-4 pb-4 pt-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(t.Label,{htmlFor:"inherit-global-date-comparison",className:"text-xs",children:"Inherit Global Date comparison"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Author-set metric comparisons still take precedence."})]}),e.jsx(t.Switch,{id:"inherit-global-date-comparison",size:"xs",checked:((N=s.preferences)==null?void 0:N.inheritGlobalComparison)!==!1,onCheckedChange:f=>{const g={...s.preferences};f?delete g.inheritGlobalComparison:g.inheritGlobalComparison=!1,n(g)}})]}),r==="kpi"&&i&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{htmlFor:"enable-metric-pair-comparison",className:"text-xs",children:"Enable metric comparison"}),e.jsx(t.Switch,{id:"enable-metric-pair-comparison",size:"xs",checked:x,onCheckedChange:f=>n({...s.preferences,metricPairComparisonEnabled:f})})]}),d&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{htmlFor:"show-explicit-comparison",className:"text-xs",children:"Show comparison"}),e.jsx(t.Switch,{id:"show-explicit-comparison",size:"xs",checked:l.showComparison!==!1,onCheckedChange:f=>u({showComparison:f})})]}),m&&e.jsx(Ma,{value:l,onChange:u,showPosition:r==="kpi"&&i})]})]})}function Aa({cardType:s,queryResultColumns:n,focusSection:r,focusRequestId:o}){var Y,$,Q;const i=t.useEditorStore(U=>U.card),d=t.useEditorStore(U=>U.queryResultColumns),c=t.useEditorStore(U=>U.queryResultColumnKeyMap),l=t.useEditorStore(U=>{var J;return(J=U.card)==null?void 0:J.preferences}),u=l==null?void 0:l.tablePrefs,x=t.useEditorStore(U=>U.actions.setCardPreferences),m=t.useEditorStore(U=>U.actions.updateTableConditionalFormatting),b=((Y=i.config)==null?void 0:Y.metricColumns)||[],h=s??i.type,p=n??d,j=i.type===h?i:{...i,type:h},N=a.getTableConditionalFormattingColumnOptions(j,p,c),f=a.getTableOutputColumnOptions(j,p),g=h==="matrixTable"||a.supportsTableConditionalFormatting(h),k=h==="table",D=h==="table",w=(($=N[0])==null?void 0:$.value)||"",S=a.resolveTableConditionalFormatting(a.normalizeConditionalFormatting((Q=l==null?void 0:l.tablePrefs)==null?void 0:Q.conditionalFormatting),a.resolveTableFormattingColumns(j,p,c)),L=a.resolveTablePresentationStyle(u),A=a.isEligibleFlatTableTotalsCard(j),F=a.hasFlatTableTotalsBehavior(j),[I,y]=v.useState("style");v.useEffect(()=>{if(r==="style"){y("style");return}if(r==="columns"&&D){y("columns");return}r==="conditional-formatting"&&g&&y("conditional-formatting")},[D,g,o,r]);const E=b.some(U=>{var J;return((J=U.comparison)==null?void 0:J.mode)==="explicit"}),M=(l==null?void 0:l.comparisonPresentation)||{},T=U=>{x({...l,comparisonPresentation:{...M,...U}})},R=U=>{m({version:1,rules:U})},C=U=>{x({...l,tablePrefs:{...u,density:U}})},V=U=>{x({...l,tablePrefs:{...u,tableStyle:{...u==null?void 0:u.tableStyle,...U}}})},P=U=>{var J;V({totals:{...(J=u==null?void 0:u.tableStyle)==null?void 0:J.totals,...U}})},O=U=>{var J;x({...l,tablePrefs:{...u,tableStyle:{...u==null?void 0:u.tableStyle,totals:{...(J=u==null?void 0:u.tableStyle)==null?void 0:J.totals,enabled:U}}}})},B=(U,J)=>{x({...l,tablePrefs:{...u,columnVisibility:a.setTableColumnVisibility(u==null?void 0:u.columnVisibility,U,J)}})},_=()=>{x({...l,tablePrefs:{...u,columnVisibility:a.showAllTableColumns()}})},z=()=>{x({...l,tablePrefs:{...u,density:a.TABLE_PRESENTATION_DEFAULT_STYLE.density,tableStyle:{headerStyle:a.TABLE_PRESENTATION_DEFAULT_STYLE.headerStyle,headerWrapText:a.TABLE_PRESENTATION_DEFAULT_STYLE.headerWrapText,stripedRows:a.TABLE_PRESENTATION_DEFAULT_STYLE.stripedRows,wrapText:a.TABLE_PRESENTATION_DEFAULT_STYLE.wrapText,totals:{enabled:A?F:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.enabled,backgroundColor:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.backgroundColor,textColor:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.textColor,fontWeight:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.fontWeight,borderTop:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.borderTop,borderTopStyle:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.borderTopStyle,borderTopColor:a.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE.borderTopColor}}}})},q=E?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Comparison"}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(t.Label,{htmlFor:"show-table-comparison",className:"text-xs",children:"Show comparison"}),e.jsx(t.Switch,{id:"show-table-comparison",size:"xs",checked:M.showComparison!==!1,onCheckedChange:U=>T({showComparison:U})})]}),e.jsx(Ma,{value:M,onChange:T})]}):null;return e.jsx("div",{className:"px-4 py-3",children:e.jsxs(t.Tabs,{value:I,onValueChange:U=>y(U),className:"space-y-4",children:[e.jsxs(t.TabsList,{variant:"underline",children:[e.jsx(t.TabsTrigger,{value:"style",children:"Appearance"}),D?e.jsx(t.TabsTrigger,{value:"columns",children:"Columns"}):null,e.jsx(t.TabsTrigger,{value:"conditional-formatting",disabled:!g,children:"Conditional formatting"})]}),e.jsxs(t.TabsContent,{value:"style",className:"mt-0",children:[e.jsx(a.TablePresentationSettings,{style:L,onDensityChange:C,onStyleChange:V,showFullStyle:k,showBorderStyle:!1,totals:k&&A?{enabled:F,onEnabledChange:O,onStyleChange:P}:void 0,extraSection:q,onReset:k?z:void 0}),h==="matrixTable"&&e.jsx(Is,{section:"table"})]}),e.jsx(t.TabsContent,{value:"columns",className:"mt-0",children:D?e.jsx(a.TableColumnVisibilitySettings,{columns:f,columnVisibility:u==null?void 0:u.columnVisibility,onColumnVisibilityChange:B,onShowAllColumns:_}):e.jsx("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:"Column visibility is available for table cards."})}),e.jsx(t.TabsContent,{value:"conditional-formatting",className:"mt-0",children:h==="matrixTable"?e.jsx(Is,{section:"conditional-formatting"}):g?w?e.jsx(a.DataTableConditionalFormattingSettings,{columnId:w,availableColumns:N,conditionalRules:S.rules,onConditionalRulesChange:R,startRulesWithNoTrigger:!0}):e.jsx("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:"Run the query to configure conditional formatting."}):e.jsx("p",{className:"py-6 text-center text-[12px] text-muted-foreground",children:"Conditional formatting is available for table cards."})})]})})}function Al(){var i;const s=t.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=t.useEditorStore(d=>d.actions),r=(i=s==null?void 0:s.textVisualOptions)!=null&&i.isDynamicText?"dynamic":"static";function o(d){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:d==="dynamic"}})}return e.jsx(t.Tabs,{value:r,onValueChange:o,children:e.jsxs(t.TabsList,{variant:"underline",children:[e.jsx(t.TabsTrigger,{value:"static",children:"Static"}),e.jsx(t.TabsTrigger,{value:"dynamic",children:"Dynamic"})]})})}function Ll(){return e.jsxs("div",{className:"space-y-2 px-6 py-4",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Text mode"}),e.jsx(Al,{}),e.jsx("p",{className:"pt-1 text-[12px] leading-[1.55] text-muted-foreground",children:"Static text is authored inline. Dynamic text reads from the first cell of the card's query."})]})}function Fl({color:s,onColorChange:n,onClose:r}){const[o,i]=v.useState(0),[d,c]=v.useState(100),[l,u]=v.useState(50),[x,m]=v.useState(s);v.useEffect(()=>{const f=Un(s);if(f){const g=Gn(f.r,f.g,f.b);i(g.h),c(g.s),u(g.l),m(s)}},[s]);const b=f=>{i(f),p(f,d,l)},h=f=>{const g=f.currentTarget.getBoundingClientRect(),k=Math.max(0,Math.min(1,(f.clientX-g.left)/g.width)),D=Math.max(0,Math.min(1,(f.clientY-g.top)/g.height)),w=k*100,S=(1-D)*100;c(w),u(S),p(o,w,S)},p=(f,g,k)=>{const D=Pl(f,g,k),w=Rl(D.r,D.g,D.b);m(w)},j=f=>{if(m(f),/^#[0-9A-Fa-f]{6}$/.test(f)){const g=Un(f);if(g){const k=Gn(g.r,g.g,g.b);i(k.h),c(k.s),u(k.l)}}},N=()=>{/^#[0-9A-Fa-f]{6}$/.test(x)&&(n(x),r())};return e.jsxs("div",{className:"p-4 space-y-4 w-[320px]",children:[e.jsxs("div",{className:"relative h-[200px] rounded cursor-crosshair",style:{background:`hsl(${o}, 100%, 50%)`},onClick:h,onMouseMove:f=>{f.buttons===1&&h(f)},children:[e.jsx("div",{className:"absolute inset-0 rounded",style:{background:"linear-gradient(to right, white, transparent)"}}),e.jsx("div",{className:"absolute inset-0 rounded",style:{background:"linear-gradient(to bottom, transparent, black)"}}),e.jsx("div",{className:"absolute w-4 h-4 -ml-2 -mt-2 rounded-full border-2 border-white shadow-md",style:{left:`${d}%`,top:`${100-l}%`,backgroundColor:x}})]}),e.jsx("div",{className:"space-y-2",children:e.jsx("input",{type:"range",min:"0",max:"360",value:o,onChange:f=>b(Number(f.target.value)),className:"w-full h-4 rounded-lg appearance-none cursor-pointer",style:{background:"linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)"}})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"HEX"}),e.jsx(t.Input,{value:x,onChange:f=>j(f.target.value),placeholder:"#000000",className:"font-mono"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border shadow-sm",style:{backgroundColor:s}}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"CURRENT"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-full border shadow-sm",style:{backgroundColor:x}}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"NEW"})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(t.Button,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(t.Button,{onClick:N,children:"OK"})]})]})}function Un(s){const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null}function Rl(s,n,r){return"#"+((1<<24)+(s<<16)+(n<<8)+r).toString(16).slice(1)}function Gn(s,n,r){s/=255,n/=255,r/=255;const o=Math.max(s,n,r),i=Math.min(s,n,r);let d=0,c=0;const l=(o+i)/2;if(o!==i){const u=o-i;switch(c=l>.5?u/(2-o-i):u/(o+i),o){case s:d=((n-r)/u+(n<r?6:0))/6;break;case n:d=((r-s)/u+2)/6;break;case r:d=((s-n)/u+4)/6;break}}return{h:Math.round(d*360),s:Math.round(c*100),l:Math.round(l*100)}}function Pl(s,n,r){s/=360,n/=100,r/=100;let o,i,d;if(n===0)o=i=d=r;else{const c=(x,m,b)=>(b<0&&(b+=1),b>1&&(b-=1),b<.16666666666666666?x+(m-x)*6*b:b<.5?m:b<.6666666666666666?x+(m-x)*(.6666666666666666-b)*6:x),l=r<.5?r*(1+n):r+n-r*n,u=2*r-l;o=c(u,l,s+1/3),i=c(u,l,s),d=c(u,l,s-1/3)}return{r:Math.round(o*255),g:Math.round(i*255),b:Math.round(d*255)}}const Ol=["#000000","#ffffff","#6b7280","#dc2626","#ea580c","#ca8a04","#16a34a","#0891b2","#2563eb","#7c3aed","#c026d3","#e11d48","#0f172a","#f3f4f6","#fbbf24"];function Bl(){var S,L,A,F,I,y,E,M,T,R;const s=t.useEditorStore(C=>C.card),n=t.useEditorStore(C=>{var V;return(V=C.card)==null?void 0:V.preferences}),r=a.useEffectiveEditorCardType(),{setCardPreferences:o,updateCardInFrame:i}=t.useEditorActions(),d=v.useMemo(()=>r!==s.type?{...s,type:r}:s,[s,r]),{data:c}=a.useEditorCardQuery(d),[l,u]=v.useState({}),[x,m]=v.useState(null),[b,h]=v.useState(null),p=v.useMemo(()=>{var O,B,_,z,q,Y,$;if(!(c!=null&&c.records)||c.records.length===0)return[];const C=r==="stackedBar"||r==="stackedLine",V=r==="bar"||r==="line"||r==="horizontalBar"||r==="bullet"||r==="combo"||r==="area"||r==="stackedArea",P=((O=s==null?void 0:s.config)==null?void 0:O.pivotByColumns)&&s.config.pivotByColumns.length>0;if((C||V)&&P){if(c.pivotSchema&&Array.isArray(c.pivotSchema)){const Q=new Set;return c.pivotSchema.forEach(U=>{U.alias&&Q.add(U.alias)}),Array.from(Q)}if(c.records.length>0){const Q=c.records[0],U=Object.keys(Q),J=new Set;(B=s==null?void 0:s.config)!=null&&B.groupByColumns&&s.config.groupByColumns.forEach(me=>{J.add(me.label||me.name),J.add(me.alias||me.name)});const X=new Set;return(_=s==null?void 0:s.config)!=null&&_.metricColumns&&s.config.metricColumns.forEach(me=>{const be=me.alias||me.name;X.add(be),X.add(`${be}_count`),X.add(`${be}_sum`),X.add(`${be}_avg`),X.add(`${be}_min`),X.add(`${be}_max`);const ve=me.entityName||me.qualifiedEntityName;ve&&(X.add(`${ve}_${be}`),X.add(`${ve}_${be}_count`))}),U.filter(me=>!J.has(me)&&!X.has(me))}}if((V||C)&&!P&&((q=(z=s==null?void 0:s.config)==null?void 0:z.metricColumns)!=null&&q.length))return s.config.metricColumns.map(Q=>Q.alias||Q.label||Q.name);if(($=(Y=s==null?void 0:s.config)==null?void 0:Y.groupByColumns)!=null&&$.length){const Q=s.config.groupByColumns[0],U=Q.label||Q.name,J=new Set;return c.records.forEach(X=>{const ee=X[U];ee!=null&&J.add(String(ee))}),Array.from(J)}return[]},[c,(S=s==null?void 0:s.config)==null?void 0:S.groupByColumns,(L=s==null?void 0:s.config)==null?void 0:L.pivotByColumns,(A=s==null?void 0:s.config)==null?void 0:A.metricColumns,r]),j=v.useMemo(()=>a.getDefaultChartColors(),[]);v.useEffect(()=>{const C={};p.forEach((V,P)=>{C[V]=a.getColorForValue(V,P,n==null?void 0:n.colorConfig)}),u(C)},[p,n==null?void 0:n.colorConfig,j]);const N=(C,V)=>{const P={...l,[C]:V};u(P);const O={...n||{},colorConfig:{segments:P}};o(O);const B={...s,preferences:O};i(B)},f=(C,V)=>{var q;const P=j[V%j.length],{[C]:O,...B}=((q=n==null?void 0:n.colorConfig)==null?void 0:q.segments)||{},_={...n||{},colorConfig:{segments:B}};o(_);const z={...s,preferences:_};i(z),u(Y=>({...Y,[C]:P}))};if(!p.length||!((s==null?void 0:s.type)==="stackedBar"||(s==null?void 0:s.type)==="stackedLine"?((I=(F=s==null?void 0:s.config)==null?void 0:F.groupByColumns)==null?void 0:I.length)||((E=(y=s==null?void 0:s.config)==null?void 0:y.pivotByColumns)==null?void 0:E.length):(T=(M=s==null?void 0:s.config)==null?void 0:M.groupByColumns)==null?void 0:T.length)||["table","kpi","text","custom","heatmap"].includes(r))return null;const D=()=>{const C={...n||{},colorConfig:{segments:{}}};o(C);const V={...s,preferences:C};i(V);const P={};p.forEach((O,B)=>{P[O]=a.getColorForValue(O,B,void 0)}),u(P)},w=Object.keys(((R=n==null?void 0:n.colorConfig)==null?void 0:R.segments)||{}).length>0;return e.jsxs(a.AccordionItem,{value:"colors",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr.Palette,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Colors"})]})}),e.jsx(a.AccordionContent,{className:"",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"flex items-center justify-between",children:w&&e.jsxs("button",{className:"ml-auto flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:D,children:[e.jsx(t.RotateCcw,{className:"h-3 w-3"}),"Reset All"]})})}),e.jsx("div",{className:"max-h-[200px] space-y-2 overflow-y-auto pr-1",children:p.map((C,V)=>{const P=a.isDefaultColor(l[C],V),O=!P;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Popover,{open:x===C,onOpenChange:B=>m(B?C:null),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx("button",{className:"h-5 w-5 shrink-0 rounded border border-input shadow-sm transition-colors hover:border-gray-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",style:{backgroundColor:l[C]}})}),e.jsx(t.PopoverContent,{align:"start",className:"w-auto p-3",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Theme Colors"}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:j.slice(0,10).map((B,_)=>e.jsxs("button",{className:t.cn("relative h-5 w-5 rounded border-2 transition-all hover:scale-110",l[C]===B?"border-gray-900":"border-transparent"),style:{backgroundColor:B},onClick:()=>{N(C,B),m(null)},children:[_===V%j.length&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"rounded-full bg-white/90 px-0.5 text-[8px] font-bold text-gray-900 shadow-sm",children:"D"})}),e.jsx("span",{className:"sr-only",children:B})]},`default-${_}`))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Popular Colors"}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Ol.map((B,_)=>e.jsx("button",{className:t.cn("h-5 w-5 rounded border transition-all hover:scale-110",l[C]===B?"border-2 border-gray-900":B==="#ffffff"?"border border-gray-300":"border border-transparent"),style:{backgroundColor:B},onClick:()=>{N(C,B),m(null)},children:e.jsx("span",{className:"sr-only",children:B})},`preset-${_}`))})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[e.jsx("button",{className:"text-sm font-medium text-blue-600 hover:text-blue-700",onClick:()=>{h({value:C,color:l[C]}),m(null)},children:"Custom color"}),!P&&e.jsxs("button",{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",onClick:()=>{f(C,V),m(null)},children:[e.jsx(t.RotateCcw,{className:"h-3 w-3"}),"Reset"]})]})]})})]}),e.jsx("span",{className:"flex-1 truncate text-sm",children:C}),O&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"(custom)"})]},C)})}),b&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>h(null)}),e.jsx("div",{className:"relative rounded-lg bg-white shadow-lg",children:e.jsx(Fl,{color:b.color,onColorChange:C=>{N(b.value,C),h(null)},onClose:()=>h(null)})})]})]})})]})}function rt({value:s,onSave:n,placeholder:r="",type:o="text",className:i=""}){const[d,c]=v.useState(s??""),[l,u]=v.useState(!1);v.useEffect(()=>{c(s??"")},[s]);const x=()=>{n(d),u(!1)},m=()=>{c(s??""),u(!1)};return e.jsxs("div",{className:`flex items-center gap-2 ${i}`,children:[e.jsx(t.Input,{placeholder:r,type:o,value:l?d:s??"",onChange:b=>{c(b.target.value),u(!0)},onFocus:()=>u(!0),onClick:b=>b.stopPropagation(),className:"h-8 text-xs",onPointerDown:b=>b.stopPropagation(),onKeyDown:b=>{b.stopPropagation(),b.key==="Enter"&&l&&d!==s?x():b.key==="Escape"&&m()},"aria-label":r||"Edit field"}),l&&d!==s&&e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Confirm edit",onClick:x,children:e.jsx(t.Check,{className:"h-4 w-4 text-green-600"})}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Cancel edit",onClick:m,children:e.jsx(le.X,{className:"h-4 w-4 text-muted-foreground"})})]})]})}function vs({axis:s,label:n,type:r,config:o,onChange:i,defaultTitle:d,hidePosition:c}){var j,N,f,g,k,D,w,S,L,A,F,I,y,E;const l=a.normalizeContextFormatMode({formatMode:o==null?void 0:o.formatMode,formatOptions:o==null?void 0:o.formatOptions}),u=(M,T)=>{i({...o??{},[M]:T})},x=(M,T)=>{var P,O,B,_;const R=M==="enabled"&&T===!0,C=(P=o==null?void 0:o.name)==null?void 0:P.text,V=R&&!C&&d;i({...o??{},name:{...o==null?void 0:o.name,enabled:M==="enabled"?T:((O=o==null?void 0:o.name)==null?void 0:O.enabled)??!1,text:M==="text"?T:V?d:C,fontSize:M==="fontSize"?T:(B=o==null?void 0:o.name)==null?void 0:B.fontSize,fontWeight:M==="fontWeight"?T:(_=o==null?void 0:o.name)==null?void 0:_.fontWeight}})},m=(M,T)=>{var R,C;i({...o??{},labels:{enabled:M==="enabled"?T:((R=o==null?void 0:o.labels)==null?void 0:R.enabled)??!0,rotation:M==="rotation"?T:(C=o==null?void 0:o.labels)==null?void 0:C.rotation}})},b=(M,T)=>{i({...o??{},scale:{...o==null?void 0:o.scale,[M]:T===""?"auto":Number(T)}})},h=s==="x"?["auto","top","bottom"]:["auto","left","right"],p=["auto","0","45","90","-45","-90"];return e.jsxs(a.AccordionItem,{value:`${s}-axis`,className:"border-b-0",children:[e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx(a.AccordionTrigger,{className:"flex grow items-center justify-between gap-3 py-2 text-[12px] font-medium hover:no-underline",children:e.jsx("div",{className:"flex grow items-center justify-between gap-2",children:e.jsx("span",{children:n})})}),e.jsx(t.Switch,{size:"sm",checked:(o==null?void 0:o.enabled)!==!1,onCheckedChange:M=>u("enabled",M),onClick:M=>M.stopPropagation()})]}),e.jsxs(a.AccordionContent,{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Checkbox,{id:`${s}-title-enabled`,checked:((j=o==null?void 0:o.name)==null?void 0:j.enabled)??!1,onCheckedChange:M=>x("enabled",M===!0)}),e.jsx(t.Label,{htmlFor:`${s}-title-enabled`,className:"text-xs font-medium cursor-pointer",children:"TITLE"})]}),((N=o==null?void 0:o.name)==null?void 0:N.enabled)&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(rt,{placeholder:`${n} title`,value:((f=o==null?void 0:o.name)==null?void 0:f.text)||"",onSave:M=>x("text",M),className:""}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Size"}),e.jsx("div",{className:"w-14",children:e.jsx(rt,{type:"number",placeholder:"12",value:String(((g=o==null?void 0:o.name)==null?void 0:g.fontSize)||12),onSave:M=>x("fontSize",Number(M)||12),className:""})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Weight"}),e.jsxs(t.Select,{value:((k=o==null?void 0:o.name)==null?void 0:k.fontWeight)||"normal",onValueChange:M=>x("fontWeight",M),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-20 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"normal",className:"text-xs",children:"Normal"}),e.jsx(t.SelectItem,{value:"bold",className:"text-xs",children:"Bold"})]})]})]})]})]})]}),!c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"POSITION"}),e.jsxs(t.Select,{value:(o==null?void 0:o.position)||"auto",onValueChange:M=>u("position",M),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:h.map(M=>e.jsx(t.SelectItem,{value:M,className:"text-xs",children:M==="auto"?"Auto (Default)":t.titleCase(M)},M))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"LABELS"}),e.jsx(t.Switch,{size:"sm",checked:((D=o==null?void 0:o.labels)==null?void 0:D.enabled)!==!1,onCheckedChange:M=>m("enabled",M)})]}),((w=o==null?void 0:o.labels)==null?void 0:w.enabled)!==!1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Rotation"}),e.jsxs(t.Select,{value:String(((S=o==null?void 0:o.labels)==null?void 0:S.rotation)||"auto"),onValueChange:M=>m("rotation",M==="auto"?"auto":Number(M)),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:p.map(M=>e.jsx(t.SelectItem,{value:M,className:"text-xs",children:M==="auto"?"Auto (Default)":`${M}°`},M))})]})]})]}),r==="value"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"FORMAT"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Inherit from the bound metric by default."})]}),e.jsx(t.Switch,{size:"sm",checked:l==="override",onCheckedChange:M=>i({...o,formatMode:M?"override":"inherit"})})]}),l==="override"&&e.jsx(Kt,{formatOptions:(o==null?void 0:o.formatOptions)||{},onFormatOptionsChange:M=>i({...o,formatMode:"override",formatOptions:M}),showTitle:!1})]}),r==="value"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"SCALE"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-8 text-xs text-muted-foreground",children:"Min"}),e.jsx("div",{className:"flex-1",children:e.jsx(rt,{type:"number",placeholder:"auto",value:((L=o==null?void 0:o.scale)==null?void 0:L.min)==="auto"||((A=o==null?void 0:o.scale)==null?void 0:A.min)===void 0?"":String(o.scale.min),onSave:M=>b("min",M),className:""})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-8 text-xs text-muted-foreground",children:"Max"}),e.jsx("div",{className:"flex-1",children:e.jsx(rt,{type:"number",placeholder:"auto",value:((F=o==null?void 0:o.scale)==null?void 0:F.max)==="auto"||((I=o==null?void 0:o.scale)==null?void 0:I.max)===void 0?"":String(o.scale.max),onSave:M=>b("max",M),className:""})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"w-8 text-xs text-muted-foreground",children:"Step"}),e.jsx("div",{className:"flex-1",children:e.jsx(rt,{type:"number",placeholder:"auto",value:((y=o==null?void 0:o.scale)==null?void 0:y.stepSize)==="auto"||((E=o==null?void 0:o.scale)==null?void 0:E.stepSize)===void 0?"":String(o.scale.stepSize),onSave:M=>b("stepSize",M),className:""})})]})]})]})]})]})}function ys(s,n,r){var d,c,l;if(s==="x"){const u=(c=(d=n==null?void 0:n.config)==null?void 0:d.groupByColumns)==null?void 0:c[0];return(u==null?void 0:u.label)||(u==null?void 0:u.name)||""}const o=((l=n==null?void 0:n.config)==null?void 0:l.metricColumns)||[],i=(r==null?void 0:r.datasetOptions)||[];if(s==="y"){const u=o.filter((x,m)=>{const b=i.find(h=>h.idx===m);return!b||b.yAxisId!=="y2"});return u.length===1&&(u[0].label||u[0].name)||""}if(s==="y2"){const u=o.filter((x,m)=>{const b=i.find(h=>h.idx===m);return(b==null?void 0:b.yAxisId)==="y2"});return u.length===1&&(u[0].label||u[0].name)||""}return""}function Vl(){const s=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),{setCardPreferences:r,updateCardInFrame:o}=t.useEditorActions(),i=a.useEffectiveEditorCardType();if(!s||["tornado","pyramid","kpi","treemap"].includes(i))return null;const d=a.AxisConfigurator.getAxisInfo(i,n);if(!d.hasXAxis&&!d.hasYAxis)return null;const c=(u,x)=>{let m;u==="x"?m="xAxisConfig":u==="y"?m="yAxisConfig":m="secondaryYAxisConfig";const b={...n||{},[m]:x};r(b);const h={...s,preferences:b};o(h)},l=d.hasY2Axis&&i==="combo";return e.jsxs(a.AccordionItem,{value:"axes",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.SlidersHorizontal,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Axes"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsxs(a.Accordion,{type:"single",collapsible:!0,className:"w-full",children:[d.hasXAxis&&e.jsx(vs,{axis:"x",label:"X-Axis",type:d.xAxisType,config:a.mergeAxisConfig(a.getDefaultAxisConfig(i,"x"),n==null?void 0:n.xAxisConfig),onChange:u=>c("x",u),defaultTitle:ys("x",s,n)}),d.hasYAxis&&e.jsx(vs,{axis:"y",label:l?"Y-Axis (Left)":"Y-Axis",type:d.yAxisType,config:a.mergeAxisConfig(a.getDefaultAxisConfig(i,"y"),n==null?void 0:n.yAxisConfig),onChange:u=>c("y",u),defaultTitle:ys("y",s,n)}),l&&e.jsx(vs,{axis:"y2",label:"Y2-Axis (Right)",type:"value",config:a.mergeAxisConfig({enabled:!0,position:"right"},n==null?void 0:n.secondaryYAxisConfig),onChange:u=>c("y2",u),defaultTitle:ys("y2",s,n),hidePosition:!0})]})})]})}function _l(){const s=t.useEditorStore(b=>b.card),n=a.useEffectiveEditorCardType(),r=t.useEditorStore(b=>{var h,p,j,N;return(N=(j=(p=(h=b.card)==null?void 0:h.preferences)==null?void 0:p.chartOptions)==null?void 0:j.plugins)==null?void 0:N.legend}),{setLegendOptions:o}=t.useEditorActions();if(!s||!a.chartSupportsLegend(n))return null;const i=a.getDefaultLegendConfig(n),d=(i==null?void 0:i.display)??!0,c=(i==null?void 0:i.position)??"top",l=(i==null?void 0:i.align)??"center",u=(b,h)=>{const p={...r,[b]:h};o(p)},x=["top","bottom","left","right"],m=["start","center","end"];return e.jsxs(a.AccordionItem,{value:"legend",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Legend"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Display"}),e.jsx(t.Switch,{size:"sm",checked:(r==null?void 0:r.display)??d,onCheckedChange:b=>u("display",b)})]}),((r==null?void 0:r.display)??d)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Position"}),e.jsxs(t.Select,{value:(r==null?void 0:r.position)||c,onValueChange:b=>u("position",b),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:x.map(b=>e.jsx(t.SelectItem,{value:b,className:"text-xs",children:t.titleCase(b)},b))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Alignment"}),e.jsxs(t.Select,{value:(r==null?void 0:r.align)||l,onValueChange:b=>u("align",b),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:m.map(b=>e.jsx(t.SelectItem,{value:b,className:"text-xs",children:t.titleCase(b)},b))})]})]})]})]})})]})}function Yl(){var T,R,C,V,P,O,B;const s=t.useEditorStore(_=>_.card),n=a.useEffectiveEditorCardType(),r=t.useEditorStore(_=>{var z,q;return(q=(z=_.card)==null?void 0:z.preferences)==null?void 0:q.dataLabelsConfig}),o=t.useEditorStore(_=>{var z;return(z=_.card)==null?void 0:z.preferences}),{setCardPreferences:i,updateCardInFrame:d}=t.useEditorActions();if(!s||!a.chartSupportsDataLabels(n))return null;const c=n==="bullet"?((T=o==null?void 0:o.bulletConfig)==null?void 0:T.orientation)??(((R=o==null?void 0:o.chartOptions)==null?void 0:R.indexAxis)==="x"?"vertical":"horizontal"):void 0,l=c!=null?c==="horizontal":((C=o==null?void 0:o.chartOptions)==null?void 0:C.indexAxis)==="y",u=n==="stackedBar"||n==="stackedLine",x=n==="pie"||n==="doughnut"||n==="polarArea"||n==="funnel",m=n==="bubble"||n==="scatter",b=(P=(V=o==null?void 0:o.chartOptions)==null?void 0:V.plugins)==null?void 0:P.datalabels,h=(b==null?void 0:b.display)!==!1&&((b==null?void 0:b.anchor)||(b==null?void 0:b.align)),p=a.getDefaultDataLabelsConfig(n,s.preferences),j=r??p,N=(p==null?void 0:p.enabled)??h??!1,f=(r==null?void 0:r.enabled)!==void 0?r.enabled:N,g=(_,z)=>{const $={...p??{},...r??{},[_]:z};_==="enabled"&&($.display=z,z&&m&&!$.position&&($.position="bottom")),_==="position"&&m&&($.position="bottom"),_==="formatMode"&&z==="inherit"&&($.format=void 0,$.formatOptions=void 0);const Q={...s.preferences||{},dataLabelsConfig:$};i(Q);const U={...s,preferences:Q};d(U)},k=(_,z)=>{const q=r??{},$={...p??{},...q,font:{...q.font||{},[_]:z}},Q={...s.preferences||{},dataLabelsConfig:$};i(Q);const U={...s,preferences:Q};d(U)},D=()=>{const _=n;return _==="stackedBar"||_==="stackedLine"||_==="pie"||_==="doughnut"?"center":l?"right":"top"},w=n!=="treemap"&&n!=="heatmap",S=n!=="treemap",L=D();let A=[];if(w)if(m)A=["bottom"];else if(u||x)A=["center"];else{const _=l?["center","left","right"]:["center","top","bottom"];A=["auto",...n==="bullet"?_:_.filter(q=>q!==L),"custom"]}const F=()=>t.titleCase(L),I=["center","start","end"],y=["center","start","end","top","bottom"],E=(j==null?void 0:j.formatMode)||(j!=null&&j.format&&!["auto"].includes(j.format)?"override":"inherit"),M=(j==null?void 0:j.format)==="none";return e.jsxs(a.AccordionItem,{value:"data-labels",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Data Labels"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Display"}),e.jsx(t.Switch,{size:"sm",checked:f,onCheckedChange:_=>g("enabled",_)})]}),f&&e.jsxs(e.Fragment,{children:[w&&!u&&!x&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Position"}),e.jsxs(t.Select,{value:m?(j==null?void 0:j.position)||"bottom":(j==null?void 0:j.position)||"auto",onValueChange:_=>g("position",_),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:A.map(_=>e.jsx(t.SelectItem,{value:_,className:"text-xs",children:_==="auto"?F():_==="custom"?"Custom (Advanced)":t.titleCase(_)},_))})]})]}),u&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Show Total"}),e.jsx(t.Switch,{size:"sm",checked:(r==null?void 0:r.showTotal)??!1,onCheckedChange:_=>g("showTotal",_)})]}),(j==null?void 0:j.position)==="custom"&&e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-16",children:"Anchor"}),e.jsxs(t.Select,{value:(j==null?void 0:j.anchor)||"center",onValueChange:_=>g("anchor",_),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs flex-1",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:I.map(_=>e.jsx(t.SelectItem,{value:_,className:"text-xs",children:t.titleCase(_)},_))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-16",children:"Align"}),e.jsxs(t.Select,{value:String((j==null?void 0:j.align)||"center"),onValueChange:_=>g("align",_),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs flex-1",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:y.map(_=>e.jsx(t.SelectItem,{value:_,className:"text-xs",children:t.titleCase(_)},_))})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Format"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Keep this off to inherit from the bound metric."})]}),e.jsx(t.Switch,{size:"sm",checked:E==="override",onCheckedChange:_=>g("formatMode",_?"override":"inherit")})]}),E==="override"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Raw Value"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Show the unformatted numeric value."})]}),e.jsx(t.Switch,{size:"sm",checked:M,onCheckedChange:_=>{const z=r??{},Y={...p??{},...z,formatMode:"override",format:_?"none":void 0,formatOptions:_?void 0:z.formatOptions},$={...s.preferences||{},dataLabelsConfig:Y};i($),d({...s,preferences:$})}})]}),!M&&e.jsx(Kt,{formatOptions:(j==null?void 0:j.formatOptions)||{},onFormatOptionsChange:_=>{const Y={...p??{},...r??{},formatMode:"override",format:_.type&&_.type!=="auto"?_.type:void 0,formatOptions:_},$={...s.preferences||{},dataLabelsConfig:Y};i($),d({...s,preferences:$})},showTitle:!1})]})]}),S&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Appearance"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-20",children:"Size"}),e.jsx("div",{className:"flex-1",children:e.jsx(rt,{type:"number",placeholder:"12",value:String(((O=j==null?void 0:j.font)==null?void 0:O.size)||12),onSave:_=>k("size",Number(_)),className:""})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-20",children:"Weight"}),e.jsxs(t.Select,{value:((B=j==null?void 0:j.font)==null?void 0:B.weight)||"normal",onValueChange:_=>k("weight",_),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs flex-1",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"normal",className:"text-xs",children:"Normal"}),e.jsx(t.SelectItem,{value:"bold",className:"text-xs",children:"Bold"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-20",children:"Color"}),e.jsxs(t.Select,{value:(j==null?void 0:j.color)==="auto"||!(j!=null&&j.color)?"auto":"custom",onValueChange:_=>{_==="auto"&&g("color","auto")},children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs flex-1",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"auto",className:"text-xs",children:"Auto (Smart Contrast)"}),e.jsx(t.SelectItem,{value:"custom",disabled:!0,className:"text-xs",children:"Custom (Coming Soon)"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground w-20",children:"Rotation"}),e.jsx("div",{className:"flex-1",children:e.jsx(rt,{type:"number",placeholder:"0",value:String((j==null?void 0:j.rotation)||0),onSave:_=>g("rotation",Number(_)),className:""})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"degrees"})]})]})]})]})})]})}function zl(){var d;const s=t.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.type}),n=t.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),{setCardPreferences:r}=t.useEditorActions();if(s!=="treemap")return null;const o=((d=n==null?void 0:n.chartOptions)==null?void 0:d.treemapColorMode)??"branch",i=c=>{const l={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,treemapColorMode:c}};r(l)};return e.jsxs(a.AccordionItem,{value:"treemap-color-mode",className:"border-none",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.TbChartTreemap,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Treemap Colors"})]})}),e.jsx(a.AccordionContent,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:e.jsxs(a.RadioGroup,{value:o,onValueChange:c=>i(c??"branch"),className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[e.jsx(a.RadioGroupItem,{id:"treemap-color-branch",value:"branch"}),e.jsxs(t.Label,{htmlFor:"treemap-color-branch",className:"flex flex-col text-sm font-normal leading-tight",children:[e.jsx("span",{className:"font-medium",children:"Shade by value (default)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Keeps parent hue and adjusts lightness based on the node's share within the branch."})]})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[e.jsx(a.RadioGroupItem,{id:"treemap-color-category",value:"category"}),e.jsxs(t.Label,{htmlFor:"treemap-color-category",className:"flex flex-col text-sm font-normal leading-tight",children:[e.jsx("span",{className:"font-medium",children:"Single color per category"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Applies the top-level color to all descendants without lightening/darkening."})]})]})]})})]})}const ql=Object.keys(a.HEATMAP_PRESET_PALETTES);function $l(){const s=t.useEditorStore(h=>h.card),n=t.useEditorStore(h=>{var p;return(p=h.card)==null?void 0:p.preferences}),{setCardPreferences:r}=t.useEditorActions(),o=(s==null?void 0:s.type)==="heatmap",i=(n==null?void 0:n.heatmapConfig)||{},d=i.colorPalette??"green",c=i.legendPosition??"bottom",l=v.useMemo(()=>i.colorRange&&i.colorRange[0]&&i.colorRange[1]?[i.colorRange[0],i.colorRange[1]]:[...a.DEFAULT_HEATMAP_CUSTOM_RANGE],[i.colorRange]),u=h=>{const p={...i,...h};p.colorPalette!=="custom"?delete p.colorRange:(!p.colorRange||!p.colorRange[0]||!p.colorRange[1])&&(p.colorRange=[...a.DEFAULT_HEATMAP_CUSTOM_RANGE]),r({...n||{},heatmapConfig:p})},x=h=>{u({colorPalette:h,colorRange:h==="custom"?i.colorRange??[...a.DEFAULT_HEATMAP_CUSTOM_RANGE]:void 0})},m=(h,p)=>{const j=[...l];j[h]=p,u({colorPalette:"custom",colorRange:j})},b=h=>{u({legendPosition:h})};return o?e.jsxs(a.AccordionItem,{value:"heatmap-color-config",className:"border-none",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Grid3x3,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Heatmap Settings"})]})}),e.jsxs(a.AccordionContent,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:[e.jsxs(a.RadioGroup,{value:d,onValueChange:h=>x(h??"blue"),className:"space-y-3",children:[ql.map(h=>{const p=a.HEATMAP_PRESET_PALETTES[h];return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2",children:[e.jsx(a.RadioGroupItem,{id:`heatmap-${h}`,value:h}),e.jsxs(t.Label,{htmlFor:`heatmap-${h}`,className:"flex w-full flex-col gap-1 text-sm font-normal",children:[e.jsx("span",{className:"font-medium",children:p.label}),e.jsx("span",{className:"h-2 rounded-full",style:{background:`linear-gradient(90deg, ${p.start}, ${p.end})`}})]})]},h)}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-border px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.RadioGroupItem,{id:"heatmap-custom",value:"custom"}),e.jsx(t.Label,{htmlFor:"heatmap-custom",className:"text-sm font-medium",children:"Custom colors"})]}),d==="custom"&&e.jsxs("div",{className:"flex flex-col gap-2 pl-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.ColorField,{value:l[0],onChange:h=>m(0,h??"#000000"),ariaLabel:"Start color",allowEmpty:!1}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Start color"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.ColorField,{value:l[1],onChange:h=>m(1,h??"#000000"),ariaLabel:"End color",allowEmpty:!1}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"End color"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Color scale position"}),e.jsxs(t.Select,{value:c,onValueChange:h=>b(h??"bottom"),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:["top","bottom","left","right"].map(h=>e.jsx(t.SelectItem,{value:h,className:"text-xs",children:h[0].toUpperCase()+h.slice(1)},h))})]})]})]})]}):null}const Hn=["poor","satisfactory","good"];function Qn(s){if(!s)return;const n={...s};return n.targetMetricKey||delete n.targetMetricKey,n.comparativeMetricKey||delete n.comparativeMetricKey,!n.targetValue&&n.targetValue!==0&&delete n.targetValue,(!n.rangeKeys||Object.keys(n.rangeKeys).length===0)&&delete n.rangeKeys,(!n.ranges||Object.keys(n.ranges).length===0)&&delete n.ranges,(!n.rangeLabels||Object.keys(n.rangeLabels).length===0)&&delete n.rangeLabels,n}function Kl(){var T,R;const s=t.useEditorStore(C=>C.card.preferences),n=t.useEditorStore(C=>C.card),r=t.useEditorStore(C=>C.isDevMode),{setCardPreferences:o,setChartOrientation:i}=t.useEditorActions(),d=v.useMemo(()=>(s==null?void 0:s.bulletConfig)||{},[s==null?void 0:s.bulletConfig]),l=ye.hasValidCardConfig(n==null?void 0:n.config)&&!r,[u,x]=v.useState(d.showRanges??!1),[m,b]=v.useState(d.rangesArePercentages??!1),h=d.disableAutoComparative?!1:d.comparativeMetricKey!==void 0||!l,[p,j]=v.useState(h);v.useEffect(()=>{x(d.showRanges??!1)},[d.showRanges]),v.useEffect(()=>{b(d.rangesArePercentages??!1)},[d.rangesArePercentages]);const N=d.targetValue===void 0?"":String(d.targetValue);v.useEffect(()=>{const C=d.disableAutoComparative?!1:d.comparativeMetricKey!==void 0||!l;j(C)},[d.disableAutoComparative,d.comparativeMetricKey,l]);const f=v.useMemo(()=>{var C,V;return((V=(C=n==null?void 0:n.config)==null?void 0:C.metricColumns)==null?void 0:V.map(P=>{const O=P.label||P.name||P.alias||"";return{value:O,label:O}}))||[]},[(T=n==null?void 0:n.config)==null?void 0:T.metricColumns]);v.useEffect(()=>{var q,Y;if(!s||f.length===0)return;const C={};let V=!1;const P=(q=f[1])==null?void 0:q.value;!d.targetMetricKey&&P&&(C.targetMetricKey=P,V=!0);const O=(Y=f[2])==null?void 0:Y.value;!d.comparativeMetricKey&&!d.disableAutoComparative&&O&&(C.comparativeMetricKey=O,V=!0);const B=f.slice(3),_={...d.rangeKeys||{}};let z=!1;if(Hn.forEach(($,Q)=>{!_[$]&&B[Q]&&(_[$]=B[Q].value,z=!0)}),z&&(C.rangeKeys=_,V=!0,d.showRanges===void 0&&(C.showRanges=!0)),V){const $=Qn({...d,...C});o({...s,bulletConfig:$})}},[f,d,s,o]);const g=C=>{const V=Qn({...d,...C});o({...s,bulletConfig:V})},k=(C,V)=>{const P={...d.rangeKeys||{},[C]:V.trim()};V.trim()||delete P[C],g({rangeKeys:Object.keys(P).length>0?P:void 0})},D=(C,V)=>{const P=V===""?void 0:Number(V),O={...d.ranges||{}};P===void 0||Number.isNaN(P)?delete O[C]:O[C]=P,g({ranges:Object.keys(O).length?O:void 0})},w=C=>{if(C===""){g({targetValue:void 0});return}const V=Number(C);g({targetValue:Number.isNaN(V)?void 0:V})},S=(C,V)=>{const P=V.trim(),O={...d.rangeLabels||{}};P?O[C]=P:delete O[C],g({rangeLabels:Object.keys(O).length>0?O:void 0})},L=C=>{x(C),g({showRanges:C})},A=C=>{b(C),g({rangesArePercentages:C})},F=d.orientation||(((R=s==null?void 0:s.chartOptions)==null?void 0:R.indexAxis)==="y"?"horizontal":"vertical"),I=C=>{g({orientation:C}),i(C==="horizontal"?"y":"x")},y=[{value:"__none",label:"None"},...f.map(C=>({value:C.value,label:C.label}))],E=y,M=C=>{if(j(C),!C){g({comparativeMetricKey:void 0,disableAutoComparative:!0});return}if(!l){g({disableAutoComparative:!1});return}if(d.comparativeMetricKey)g({disableAutoComparative:!1});else{const V=f.find(P=>P.value!==d.targetMetricKey);g({comparativeMetricKey:V==null?void 0:V.value,disableAutoComparative:!1})}};return e.jsxs(a.AccordionItem,{value:"bullet-config",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.BulletChartIcon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Bullet Chart"})]})}),e.jsxs(a.AccordionContent,{className:"space-y-6 border-t border-border/50 py-4",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"ORIENTATION"}),e.jsxs(t.Select,{value:F,onValueChange:C=>I(C),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"horizontal",className:"text-xs",children:"Horizontal"}),e.jsx(t.SelectItem,{value:"vertical",className:"text-xs",children:"Vertical"})]})]})]}),l&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"TARGET METRIC"}),e.jsxs(t.Select,{value:d.targetMetricKey||"__none",onValueChange:C=>g({targetMetricKey:C==="__none"?void 0:C}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select metric"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"__none",className:"text-xs",children:"None"}),f.map(C=>e.jsx(t.SelectItem,{value:C.value,className:"text-xs",children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"COMPARATIVE METRIC"}),l?e.jsxs(t.Select,{value:d.comparativeMetricKey||"__none",onValueChange:C=>g({comparativeMetricKey:C==="__none"?void 0:C,disableAutoComparative:C==="__none"}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select metric"})}),e.jsx(t.SelectContent,{children:y.map(C=>e.jsx(t.SelectItem,{value:C.value,className:"text-xs",children:C.label},C.value))})]}):e.jsxs("div",{className:"space-y-2 rounded-md border border-border/50 p-3 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between font-medium",children:[e.jsx("span",{children:"Show comparative"}),e.jsx(t.Switch,{size:"sm",checked:p,onCheckedChange:C=>M(C)})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comparative values are auto-detected from the third metric in your results."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"TARGET VALUE (FALLBACK)"}),e.jsx(et,{type:"number",className:"h-8 text-xs",value:N,onCommit:w,placeholder:"Optional numeric fallback"})]})]}),e.jsxs("section",{className:"space-y-4 rounded-md border border-border/60 p-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"QUALITATIVE RANGES"}),e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:200,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(t.Info,{className:"h-3.5 w-3.5"})})}),e.jsx(t.TooltipContent,{side:"top",children:"Use columns or static values for Poor / Average / Good."})]})})]}),e.jsx("div",{className:"flex items-center gap-2 text-xs font-medium",children:e.jsx(t.Switch,{size:"sm",checked:u,onCheckedChange:L})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[e.jsx("input",{type:"checkbox",checked:m,disabled:!u,onChange:C=>A(C.target.checked),className:"h-3.5 w-3.5 accent-primary disabled:opacity-50"}),e.jsx("span",{children:"Use % of value"})]})]}),u&&e.jsx("div",{className:"space-y-3",children:Hn.map(C=>{var V,P,O,B,_;return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/60 bg-muted/40 p-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(t.Label,{className:"text-[11px] font-medium uppercase tracking-wide",children:[C," LABEL"]}),e.jsx(et,{placeholder:`Display label (${C})`,value:((V=d.rangeLabels)==null?void 0:V[C])||"",onCommit:z=>S(C,z),className:"h-8 text-xs"})]}),l?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(t.Label,{className:"text-[11px] font-medium uppercase tracking-wide",children:[C," COLUMN"]}),e.jsxs(t.Select,{value:((P=d.rangeKeys)==null?void 0:P[C])||"__none",onValueChange:z=>{z==="__none"?k(C,""):k(C,z)},children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select column"})}),e.jsx(t.SelectContent,{children:E.map(z=>e.jsx(t.SelectItem,{value:z.value,className:"text-xs",children:z.label},z.value))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(t.Label,{className:"text-[11px] font-medium uppercase tracking-wide",children:[C," COLUMN KEY"]}),e.jsx(et,{placeholder:"Column key",value:((O=d.rangeKeys)==null?void 0:O[C])||"",onCommit:z=>k(C,z),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(t.Label,{className:"text-[11px] font-medium uppercase tracking-wide",children:[C," VALUE"]}),e.jsx(et,{type:"number",placeholder:m?"0.80":"Static value",value:((B=d.ranges)==null?void 0:B[C])===void 0?"":String((_=d.ranges)==null?void 0:_[C]),onCommit:z=>D(C,z),className:"h-8 text-xs"})]})]},C)})})]})]})]})}function Jn(s){if(!s)return;const n={...s};if(n.xMetricKey||delete n.xMetricKey,n.yMetricKey||delete n.yMetricKey,n.radiusMetricKey||delete n.radiusMetricKey,n.labelKey||delete n.labelKey,n.groupKey||delete n.groupKey,n.enableGrouping===void 0&&delete n.enableGrouping,n.radiusScale||delete n.radiusScale,n.fixedRadius===void 0&&delete n.fixedRadius,n.minRadius===void 0&&delete n.minRadius,n.maxRadius===void 0&&delete n.maxRadius,Object.keys(n).length!==0)return n}function Ul(){var S,L,A,F,I,y,E,M,T,R,C,V;const s=t.useEditorStore(P=>P.card.preferences),n=t.useEditorStore(P=>P.card),r=a.useEffectiveEditorCardType(),o=t.useEditorStore(P=>P.isDevMode),{setCardPreferences:i,updateCardInFrame:d}=t.useEditorActions(),c=r==="bubble",l=r==="scatter",u=v.useMemo(()=>(s==null?void 0:s.bubbleScatterConfig)||{},[s==null?void 0:s.bubbleScatterConfig]),m=ye.hasValidCardConfig(n==null?void 0:n.config)&&!o,b=v.useMemo(()=>{var P,O;return((O=(P=n==null?void 0:n.config)==null?void 0:P.metricColumns)==null?void 0:O.map(B=>{const _=B.label||B.name||B.alias||"";return{value:_,label:_}}))||[]},[(S=n==null?void 0:n.config)==null?void 0:S.metricColumns]),h=v.useMemo(()=>{var P,O;return((O=(P=n==null?void 0:n.config)==null?void 0:P.groupByColumns)==null?void 0:O.map(B=>{const _=B.label||B.name||B.alias||"";return{value:_,label:_}}))||[]},[(L=n==null?void 0:n.config)==null?void 0:L.groupByColumns]),p=v.useMemo(()=>u.enableGrouping!==void 0?u.enableGrouping:!o&&h.length>=2,[u.enableGrouping,o,h.length]),[j,N]=v.useState(p);v.useEffect(()=>{N(p)},[p]);const f=P=>{const O={...s||{},bubbleScatterConfig:P};i(O),n&&d({...n,preferences:O})},g=P=>{i(P),n&&d({...n,preferences:P})};v.useEffect(()=>{if(!s||b.length===0)return;const P={};let O=!1;if(!u.xMetricKey&&b[0]&&(P.xMetricKey=b[0].value,O=!0),!u.yMetricKey&&b[1]&&(P.yMetricKey=b[1].value,O=!0),c&&!u.radiusMetricKey&&b[2]&&(P.radiusMetricKey=b[2].value,O=!0),!u.labelKey&&h[0]&&(P.labelKey=h[0].value,O=!0),p&&!u.groupKey&&h[1]&&(P.groupKey=h[1].value,P.enableGrouping=!0,O=!0),O){const B=Jn({...u,...P});f(B)}},[b,h,u,s,i,c,p]);const k=P=>{const O=Jn({...u,...P});f(O)},D=P=>{N(P),k({enableGrouping:P,groupKey:P?u.groupKey:void 0})};if(!c&&!l)return null;const w=c?a.Circle:a.ChartScatter;return e.jsxs(a.AccordionItem,{value:"bubble-scatter-config",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-3.5 w-3.5 text-foreground/60"}),e.jsxs("span",{children:[c?"Bubble":"Scatter"," Configuration"]})]})}),e.jsxs(a.AccordionContent,{className:"space-y-4 px-1 pb-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:["Dimensions",e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{children:e.jsx(t.Info,{className:"h-3 w-3"})}),e.jsx(t.TooltipContent,{side:"right",className:"max-w-xs",children:e.jsx("p",{children:"Label identifies each point. Group creates separate series in the legend."})})]})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Label Column"}),m?e.jsxs(t.Select,{value:u.labelKey||"",onValueChange:P=>k({labelKey:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select label column"})}),e.jsx(t.SelectContent,{children:h.map(P=>e.jsx(t.SelectItem,{value:P.value,children:P.label},P.value))})]}):e.jsx(et,{className:"h-8 text-xs",placeholder:"Column name for labels",value:u.labelKey||"",onCommit:P=>k({labelKey:P})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Group points into series"}),e.jsx(t.Switch,{size:"sm",checked:j,onCheckedChange:D})]}),j&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Group By"}),m?e.jsxs(t.Select,{value:u.groupKey||"",onValueChange:P=>k({groupKey:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select group column"})}),e.jsx(t.SelectContent,{children:h.map(P=>e.jsx(t.SelectItem,{value:P.value,children:P.label},P.value))})]}):e.jsx(et,{className:"h-8 text-xs",placeholder:"Column name for grouping",value:u.groupKey||"",onCommit:P=>k({groupKey:P})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Metrics"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"X Axis"}),m?e.jsxs(t.Select,{value:u.xMetricKey||"",onValueChange:P=>k({xMetricKey:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select X metric"})}),e.jsx(t.SelectContent,{children:b.map(P=>e.jsx(t.SelectItem,{value:P.value,children:P.label},P.value))})]}):e.jsx(et,{className:"h-8 text-xs",placeholder:"Column name for X axis",value:u.xMetricKey||"",onCommit:P=>k({xMetricKey:P})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Y Axis"}),m?e.jsxs(t.Select,{value:u.yMetricKey||"",onValueChange:P=>k({yMetricKey:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select Y metric"})}),e.jsx(t.SelectContent,{children:b.map(P=>e.jsx(t.SelectItem,{value:P.value,children:P.label},P.value))})]}):e.jsx(et,{className:"h-8 text-xs",placeholder:"Column name for Y axis",value:u.yMetricKey||"",onCommit:P=>k({yMetricKey:P})})]}),c&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Radius"}),m?e.jsxs(t.Select,{value:u.radiusMetricKey||"",onValueChange:P=>k({radiusMetricKey:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select radius metric"})}),e.jsx(t.SelectContent,{children:b.map(P=>e.jsx(t.SelectItem,{value:P.value,children:P.label},P.value))})]}):e.jsx(et,{className:"h-8 text-xs",placeholder:"Column name for radius",value:u.radiusMetricKey||"",onCommit:P=>k({radiusMetricKey:P})})]})]}),c&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Radius Settings"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Scale Mode"}),e.jsxs(t.Select,{value:u.radiusScale||"sqrt",onValueChange:P=>k({radiusScale:P}),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"sqrt",children:"Square Root (area-proportional)"}),e.jsx(t.SelectItem,{value:"linear",children:"Linear"}),e.jsx(t.SelectItem,{value:"fixed",children:"Fixed Size"})]})]})]}),u.radiusScale!=="fixed"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Min Radius"}),e.jsx(et,{className:"h-8 text-xs",type:"number",placeholder:"5",value:((A=u.minRadius)==null?void 0:A.toString())||"",onCommit:P=>k({minRadius:P?Number(P):void 0})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Max Radius"}),e.jsx(et,{className:"h-8 text-xs",type:"number",placeholder:"30",value:((F=u.maxRadius)==null?void 0:F.toString())||"",onCommit:P=>k({maxRadius:P?Number(P):void 0})})]})]}),u.radiusScale==="fixed"&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs(t.Label,{className:"text-xs",children:["Fixed Radius: ",u.fixedRadius||10]}),e.jsx(a.Slider,{value:[u.fixedRadius||10],onValueChange:([P])=>k({fixedRadius:P}),min:3,max:30,step:1,className:"py-2"})]})]}),l&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Point Settings"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(t.Label,{className:"text-xs",children:["Point Size: ",u.fixedRadius||5]}),e.jsx(a.Slider,{value:[u.fixedRadius||5],onValueChange:([P])=>k({fixedRadius:P}),min:2,max:15,step:1,className:"py-2"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Axis Titles"}),e.jsx(t.Switch,{size:"sm",checked:((y=(I=s==null?void 0:s.xAxisConfig)==null?void 0:I.name)==null?void 0:y.enabled)??!1,onCheckedChange:P=>{var _,z,q,Y;const O=u.xMetricKey||"X Axis",B=u.yMetricKey||"Y Axis";g({...s??{},xAxisConfig:{...s==null?void 0:s.xAxisConfig,name:{enabled:P,text:((z=(_=s==null?void 0:s.xAxisConfig)==null?void 0:_.name)==null?void 0:z.text)||O}},yAxisConfig:{...s==null?void 0:s.yAxisConfig,name:{enabled:P,text:((Y=(q=s==null?void 0:s.yAxisConfig)==null?void 0:q.name)==null?void 0:Y.text)||B}}})}})]}),((M=(E=s==null?void 0:s.xAxisConfig)==null?void 0:E.name)==null?void 0:M.enabled)&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"X Title"}),e.jsx(et,{className:"h-8 text-xs",placeholder:u.xMetricKey||"X Axis",value:((R=(T=s==null?void 0:s.xAxisConfig)==null?void 0:T.name)==null?void 0:R.text)||"",onCommit:P=>{var O;g({...s??{},xAxisConfig:{...s==null?void 0:s.xAxisConfig,name:{...(O=s==null?void 0:s.xAxisConfig)==null?void 0:O.name,enabled:!0,text:P||u.xMetricKey||"X Axis"}}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs",children:"Y Title"}),e.jsx(et,{className:"h-8 text-xs",placeholder:u.yMetricKey||"Y Axis",value:((V=(C=s==null?void 0:s.yAxisConfig)==null?void 0:C.name)==null?void 0:V.text)||"",onCommit:P=>{var O;g({...s??{},yAxisConfig:{...s==null?void 0:s.yAxisConfig,name:{...(O=s==null?void 0:s.yAxisConfig)==null?void 0:O.name,enabled:!0,text:P||u.yMetricKey||"Y Axis"}}})}})]})]})]})]})]})}const Gl=[{value:"percentOfTotal",label:"% of Total",description:"Each stage shows percentage of the sum of all values"},{value:"percentOfFirst",label:"% of Stage 1",description:"First stage = 100%, others relative to first stage"}];function Hl(){const s=t.useEditorStore(h=>h.card),n=t.useEditorStore(h=>{var p;return(p=h.card)==null?void 0:p.preferences}),{setCardPreferences:r}=t.useEditorActions(),o=(s==null?void 0:s.type)==="funnel",i=(n==null?void 0:n.funnelConfig)||{},d=i.percentMode??"percentOfTotal",c=i.shrinkFraction??1,l=i.labelThreshold??0,u=h=>{const p={...i,...h};r({...n||{},funnelConfig:p})},x=h=>{u({percentMode:h})},m=h=>{u({shrinkFraction:h[0]})},b=h=>{u({labelThreshold:h[0]})};return o?e.jsxs(a.AccordionItem,{value:"funnel-config",className:"border-none",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-3 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Filter,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Funnel Settings"})]})}),e.jsxs(a.AccordionContent,{className:"space-y-4 border-t border-border bg-background/50 px-3 py-4 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"PERCENTAGE MODE"}),e.jsx(a.RadioGroup,{value:d,onValueChange:h=>x(h),className:"space-y-2",children:Gl.map(h=>e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border px-3 py-2",children:[e.jsx(a.RadioGroupItem,{id:`funnel-${h.value}`,value:h.value,className:"mt-0.5"}),e.jsxs(t.Label,{htmlFor:`funnel-${h.value}`,className:"flex flex-col gap-0.5 text-sm font-normal",children:[e.jsx("span",{className:"font-medium",children:h.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:h.description})]})]},h.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"SEGMENT SHRINK"}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsx("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Same Width"}),e.jsx(a.Slider,{value:[c],onValueChange:m,min:0,max:1,step:.1,className:"flex-1"}),e.jsx("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Full Shrink"})]}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["Current: ",Math.round(c*100),"%"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"LABEL VISIBILITY THRESHOLD"}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsx("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Show All"}),e.jsx(a.Slider,{value:[l],onValueChange:b,min:0,max:25,step:1,className:"flex-1"}),e.jsx("span",{className:"whitespace-nowrap text-xs text-muted-foreground",children:"Hide Small"})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:l===0?"Showing all labels":`Hide labels below ${l}%`})]})]})]}):null}function os(){const s=t.useEditorStore(c=>c.card),{data:n,comparisonMetadata:r}=a.useEditorCardQuery(s),{keys:o}=a.getKeys((n==null?void 0:n.records)||[],r),i=o.slice(1).filter(c=>!ye.METADATA_KEYS.includes(c));let d=i;if(["stackedBar","stackedLine"].includes(s.type)){const c=a.pivotData({dataArray:(n==null?void 0:n.records)||[],groupKey:o[0],pivotKey:o[1],valueKey:o[2]}),{keys:l}=a.getKeys(c);d=l.slice(1)}return{transformedMetricKeys:d,dimensionKeys:o.slice(0,1),keys:o,defaultMetricKeys:i}}const Ql=[{value:"USD",label:"USD - US Dollar"},{value:"EUR",label:"EUR - Euro"},{value:"GBP",label:"GBP - British Pound"},{value:"JPY",label:"JPY - Japanese Yen"},{value:"CNY",label:"CNY - Chinese Yuan"},{value:"INR",label:"INR - Indian Rupee"},{value:"CAD",label:"CAD - Canadian Dollar"},{value:"AUD",label:"AUD - Australian Dollar"}],Jl=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"de-DE",label:"German"},{value:"fr-FR",label:"French"},{value:"es-ES",label:"Spanish"},{value:"it-IT",label:"Italian"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"zh-CN",label:"Chinese (Simplified)"}],Wl=["center","start","end"],Xl=["center","start","end","top","bottom"];function ls({config:s,onChange:n,isHorizontal:r=!1,showAutoFormat:o=!0,positionOptions:i,showAppearance:d=!0}){var j,N,f,g,k,D;const c=i??(r?["auto","center","left","right","custom"]:["auto","center","top","bottom","custom"]),l=o?["auto","number","currency","percent","none"]:["number","currency","percent","none"],u=(w,S)=>{const L={...s,[w]:S};n(L)},x=(w,S)=>{const L={...s,font:{...(s==null?void 0:s.font)||{},[w]:S}};n(L)},m=(w,S)=>{const L={...s,formatOptions:{...(s==null?void 0:s.formatOptions)||{},[w]:S}};n(L)},b=()=>r?"Right":"Top",h=s||{},p=h.format||(o?"auto":"number");return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Position"}),e.jsxs(t.Select,{value:h.position||"auto",onValueChange:w=>u("position",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:c.map(w=>e.jsx(t.SelectItem,{value:w,className:"text-xs",children:w==="auto"?b():w==="custom"?"Custom (Advanced)":t.titleCase(w)},w))})]})]}),h.position==="custom"&&e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Anchor"}),e.jsxs(t.Select,{value:h.anchor||"center",onValueChange:w=>u("anchor",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-24 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Wl.map(w=>e.jsx(t.SelectItem,{value:w,className:"text-xs",children:t.titleCase(w)},w))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Align"}),e.jsxs(t.Select,{value:String(h.align||"center"),onValueChange:w=>u("align",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-24 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Xl.map(w=>e.jsx(t.SelectItem,{value:w,className:"text-xs",children:t.titleCase(w)},w))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Format"}),e.jsxs(t.Select,{value:p,onValueChange:w=>u("format",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:l.map(w=>e.jsx(t.SelectItem,{value:w,className:"text-xs",children:w==="auto"&&o?"Auto (Use Axis)":w==="none"?"None (Raw Value)":t.titleCase(w)},w))})]})]}),!["auto","none"].includes(p)&&e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[["number","currency","percent"].includes(p)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Decimals"}),e.jsx("div",{className:"w-16",children:e.jsx(rt,{type:"number",placeholder:"0",value:String(((j=h.formatOptions)==null?void 0:j.decimalPlaces)??(p==="currency"?2:p==="percent"?1:0)),onSave:w=>m("decimalPlaces",Number(w)),className:""})})]}),p==="currency"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Currency"}),e.jsxs(t.Select,{value:((N=h.formatOptions)==null?void 0:N.currency)||"USD",onValueChange:w=>m("currency",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-28 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ql.map(w=>e.jsx(t.SelectItem,{value:w.value,className:"text-xs",children:w.label},w.value))})]})]}),["number","currency"].includes(p)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Abbreviate (K, M, B)"}),e.jsx(t.Switch,{size:"sm",checked:((f=h.formatOptions)==null?void 0:f.useSuffix)??!1,onCheckedChange:w=>m("useSuffix",w)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Locale"}),e.jsxs(t.Select,{value:((g=h.formatOptions)==null?void 0:g.locale)||"en-US",onValueChange:w=>m("locale",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-28 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Jl.map(w=>e.jsx(t.SelectItem,{value:w.value,className:"text-xs",children:w.label},w.value))})]})]})]}),d&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Appearance"}),e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-background p-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Size"}),e.jsx("div",{className:"w-16",children:e.jsx(rt,{type:"number",placeholder:"12",value:String(((k=h.font)==null?void 0:k.size)||12),onSave:w=>x("size",Number(w)),className:""})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Weight"}),e.jsxs(t.Select,{value:((D=h.font)==null?void 0:D.weight)||"normal",onValueChange:w=>x("weight",w),children:[e.jsx(t.SelectTrigger,{className:"h-7 w-24 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"normal",className:"text-xs",children:"Normal"}),e.jsx(t.SelectItem,{value:"bold",className:"text-xs",children:"Bold"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Color"}),e.jsxs(t.Select,{value:h.color==="auto"||!h.color?"auto":"custom",onValueChange:w=>{w==="auto"&&u("color","auto")},children:[e.jsx(t.SelectTrigger,{className:"h-7 w-28 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"auto",className:"text-xs",children:"Auto (Contrast)"}),e.jsx(t.SelectItem,{value:"custom",disabled:!0,className:"text-xs",children:"Custom"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs",children:"Rotation"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-12",children:e.jsx(rt,{type:"number",placeholder:"0",value:String(h.rotation||0),onSave:w=>u("rotation",Number(w)),className:""})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"°"})]})]})]})]})]})}const Zl=[{type:"bar",icon:a.ChartColumnIncreasing,label:"Bar"},{type:"line",icon:a.ChartLine,label:"Line"}],ei=[0,1,2,3,4,5,6,8,10],ti=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],si=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function ni(){return t.useEditorStore(n=>{var r;return(r=n.card)==null?void 0:r.type})!=="combo"?null:e.jsxs(a.AccordionItem,{value:"combo-series",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Layers,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Series"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsx(ai,{})})]})}function ai(){const{transformedMetricKeys:s}=os();return s.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):e.jsx("div",{className:"space-y-3",children:s.map((n,r)=>e.jsx(ri,{metricKey:n,idx:r},n))})}function ri({metricKey:s,idx:n}){var g;const[r,o]=v.useState(!1),i=t.useEditorStore(k=>{var D;return(D=k.card)==null?void 0:D.preferences}),d=t.useEditorStore(k=>{var D,w;return(w=(D=k.card)==null?void 0:D.preferences)==null?void 0:w.datasetOptions}),c=d==null?void 0:d.find(k=>k.idx===n),{setCardPreferences:l}=t.useEditorStore(k=>k.actions),u=(c==null?void 0:c.type)||"bar",x=(c==null?void 0:c.yAxisId)||"y",m=((g=c==null?void 0:c.dataLabels)==null?void 0:g.enabled)??!1,b=u==="line"?a.ChartLine:a.ChartColumnIncreasing;function h(k){const D={idx:n,type:u,yAxisId:x,dataLabels:c==null?void 0:c.dataLabels,...k};if(!c)l({...i||{},datasetOptions:[...d||[],D]});else{const w=d==null?void 0:d.map(S=>S.idx===n?{...S,...D}:S);l({...i||{},datasetOptions:w})}}function p(k){h({type:k})}function j(k){h({yAxisId:k})}function N(k){h({dataLabels:{...c==null?void 0:c.dataLabels,enabled:k}})}function f(k){h({dataLabels:k})}return e.jsx(a.Collapsible,{open:r,onOpenChange:o,children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-90")}),e.jsx("span",{className:"max-w-[100px] truncate text-xs font-medium",title:s,children:s})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("span",{className:t.cn("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[e.jsx(b,{className:"h-3 w-3"}),u==="line"?"Line":"Bar"]}),e.jsx("span",{className:t.cn("rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:x==="y2"?"Y2":"Y1"})]})]})}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-4 p-3",children:[e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Chart Type"}),e.jsx("div",{className:"flex gap-2",children:Zl.map(({type:k,icon:D,label:w})=>{const S=u===k;return e.jsxs("button",{onClick:()=>p(k),className:t.cn("flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs transition-colors",S?"border-primary bg-primary/10 text-primary":"border-border bg-background text-muted-foreground hover:bg-muted"),children:[e.jsx(D,{className:"h-3.5 w-3.5 text-foreground/60"}),e.jsx("span",{children:w})]},k)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Axis"}),e.jsxs(t.Select,{value:x,onValueChange:k=>j(k),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-20 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"y",className:"text-xs",children:"Y1 (Left)"}),e.jsx(t.SelectItem,{value:"y2",className:"text-xs",children:"Y2 (Right)"})]})]})]})]}),u==="line"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Line Style"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Pattern"}),e.jsxs(t.Select,{value:(c==null?void 0:c.lineStyle)||"solid",onValueChange:k=>h({lineStyle:k}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:si.map(({value:k,label:D})=>e.jsx(t.SelectItem,{value:k,className:"text-xs",children:D},k))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Size"}),e.jsxs(t.Select,{value:String((c==null?void 0:c.pointRadius)??3),onValueChange:k=>h({pointRadius:Number(k)}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:ei.map(k=>e.jsx(t.SelectItem,{value:String(k),className:"text-xs",children:k===0?"None":k},k))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Shape"}),e.jsxs(t.Select,{value:(c==null?void 0:c.pointStyle)||"circle",onValueChange:k=>h({pointStyle:k}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:ti.map(({value:k,label:D})=>e.jsx(t.SelectItem,{value:k,className:"text-xs",children:D},k))})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Data Labels"}),e.jsx(t.Switch,{size:"sm",checked:m,onCheckedChange:N})]}),m&&e.jsx("div",{className:"rounded-md border border-border bg-background p-2",children:e.jsx(ls,{config:c==null?void 0:c.dataLabels,onChange:f,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})})}const Cs=[{value:"origin",label:"Origin (X-axis)",description:"Fill to the X-axis (y=0)"},{value:"start",label:"Start (Top)",description:"Fill to the top of chart area"},{value:"end",label:"End (Bottom)",description:"Fill to the bottom of chart area"},{value:"-1",label:"Previous Series",description:"Fill to the series below"},{value:"+1",label:"Next Series",description:"Fill to the series above"},{value:"false",label:"No Fill (Line)",description:"Show as line without fill"}],oi=[0,1,2,3,4,5,6,8,10],li=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],ii=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function ci(s){return s==null?"origin":s===!1?"false":s}function di(){const s=t.useEditorStore(n=>{var r;return(r=n.card)==null?void 0:r.type});return s!=="area"&&s!=="stackedArea"?null:e.jsxs(a.AccordionItem,{value:"area-series",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Layers,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Series"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsx(ui,{})})]})}function ui(){const{transformedMetricKeys:s}=os();return s.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):e.jsx("div",{className:"space-y-3",children:s.map((n,r)=>e.jsx(mi,{metricKey:n,idx:r},n))})}function mi({metricKey:s,idx:n}){var N;const[r,o]=v.useState(!1),i=t.useEditorStore(f=>{var g;return(g=f.card)==null?void 0:g.preferences}),d=t.useEditorStore(f=>{var g,k;return(k=(g=f.card)==null?void 0:g.preferences)==null?void 0:k.datasetOptions}),c=d==null?void 0:d.find(f=>f.idx===n),{setCardPreferences:l}=t.useEditorStore(f=>f.actions),u=ci(c==null?void 0:c.fill),x=((N=c==null?void 0:c.dataLabels)==null?void 0:N.enabled)??!1,m=Cs.find(f=>f.value===u)||Cs[0];function b(f){const g={idx:n,fill:u,dataLabels:c==null?void 0:c.dataLabels,...f};if(!c)l({...i||{},datasetOptions:[...d||[],g]});else{const k=d==null?void 0:d.map(D=>D.idx===n?{...D,...g}:D);l({...i||{},datasetOptions:k})}}function h(f){b({fill:f==="false"?!1:f})}function p(f){b({dataLabels:{...c==null?void 0:c.dataLabels,enabled:f}})}function j(f){b({dataLabels:f})}return e.jsx(a.Collapsible,{open:r,onOpenChange:o,children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-90")}),e.jsx("span",{className:"max-w-[100px] truncate text-xs font-medium",title:s,children:s})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.jsxs("span",{className:t.cn("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[e.jsx(a.ChartArea,{className:"h-3 w-3"}),m.label.split(" ")[0]]})})]})}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-4 p-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Fill Target"}),e.jsxs(t.Select,{value:u,onValueChange:f=>h(f),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Cs.map(f=>e.jsx(t.SelectItem,{value:f.value,className:"text-xs",children:e.jsx("div",{className:"flex flex-col",children:e.jsx("span",{children:f.label})})},f.value))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Line Style"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Pattern"}),e.jsxs(t.Select,{value:(c==null?void 0:c.lineStyle)||"solid",onValueChange:f=>b({lineStyle:f}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:ii.map(({value:f,label:g})=>e.jsx(t.SelectItem,{value:f,className:"text-xs",children:g},f))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Size"}),e.jsxs(t.Select,{value:String((c==null?void 0:c.pointRadius)??3),onValueChange:f=>b({pointRadius:Number(f)}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:oi.map(f=>e.jsx(t.SelectItem,{value:String(f),className:"text-xs",children:f===0?"None":f},f))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Shape"}),e.jsxs(t.Select,{value:(c==null?void 0:c.pointStyle)||"circle",onValueChange:f=>b({pointStyle:f}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:li.map(({value:f,label:g})=>e.jsx(t.SelectItem,{value:f,className:"text-xs",children:g},f))})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Data Labels"}),e.jsx(t.Switch,{size:"sm",checked:x,onCheckedChange:p})]}),x&&e.jsx("div",{className:"rounded-md border border-border bg-background p-2",children:e.jsx(ls,{config:c==null?void 0:c.dataLabels,onChange:j,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})})}const xi=[0,1,2,3,4,5,6,8,10],hi=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],Ns=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function pi(){return t.useEditorStore(n=>{var r;return(r=n.card)==null?void 0:r.type})!=="line"?null:e.jsxs(a.AccordionItem,{value:"line-series",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Layers,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Series"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsx(fi,{})})]})}function fi(){const{transformedMetricKeys:s}=os();return s.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):e.jsx("div",{className:"space-y-3",children:s.map((n,r)=>e.jsx(gi,{metricKey:n,idx:r},n))})}function gi({metricKey:s,idx:n}){var f;const[r,o]=v.useState(!1),i=t.useEditorStore(g=>{var k;return(k=g.card)==null?void 0:k.preferences}),d=t.useEditorStore(g=>{var k,D;return(D=(k=g.card)==null?void 0:k.preferences)==null?void 0:D.datasetOptions}),c=d==null?void 0:d.find(g=>g.idx===n),{setCardPreferences:l}=t.useEditorStore(g=>g.actions),u=(c==null?void 0:c.lineStyle)||"solid",x=(c==null?void 0:c.pointRadius)??3,m=(c==null?void 0:c.pointStyle)||"circle",b=((f=c==null?void 0:c.dataLabels)==null?void 0:f.enabled)??!1,h=Ns.find(g=>g.value===u)||Ns[0];function p(g){const k={idx:n,lineStyle:u,pointRadius:x,pointStyle:m,dataLabels:c==null?void 0:c.dataLabels,...g};if(!c)l({...i||{},datasetOptions:[...d||[],k]});else{const D=d==null?void 0:d.map(w=>w.idx===n?{...w,...k}:w);l({...i||{},datasetOptions:D})}}function j(g){p({dataLabels:{...c==null?void 0:c.dataLabels,enabled:g}})}function N(g){p({dataLabels:g})}return e.jsx(a.Collapsible,{open:r,onOpenChange:o,children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-90")}),e.jsx("span",{className:"max-w-[100px] truncate text-xs font-medium",title:s,children:s})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.jsxs("span",{className:t.cn("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[e.jsx(Pr,{className:"h-3 w-3"}),h.label.split(" ")[0]]})})]})}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-4 p-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Line Style"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Pattern"}),e.jsxs(t.Select,{value:u,onValueChange:g=>p({lineStyle:g}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ns.map(({value:g,label:k})=>e.jsx(t.SelectItem,{value:g,className:"text-xs",children:k},g))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Size"}),e.jsxs(t.Select,{value:String(x),onValueChange:g=>p({pointRadius:Number(g)}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:xi.map(g=>e.jsx(t.SelectItem,{value:String(g),className:"text-xs",children:g===0?"None":g},g))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Point Shape"}),e.jsxs(t.Select,{value:m,onValueChange:g=>p({pointStyle:g}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:hi.map(({value:g,label:k})=>e.jsx(t.SelectItem,{value:g,className:"text-xs",children:k},g))})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Data Labels"}),e.jsx(t.Switch,{size:"sm",checked:b,onCheckedChange:j})]}),b&&e.jsx("div",{className:"rounded-md border border-border bg-background p-2",children:e.jsx(ls,{config:c==null?void 0:c.dataLabels,onChange:N,isHorizontal:!1,showAutoFormat:!0,showAppearance:!0})})]})]})})})]})})}const bi=[0,2,4,6,8,10,12,16,20];function ji(){const s=t.useEditorStore(n=>{var r;return(r=n.card)==null?void 0:r.type});return!s||!["bar","horizontalBar","stackedBar"].includes(s)?null:e.jsxs(a.AccordionItem,{value:"bar-series",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Layers,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Series"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsx(vi,{})})]})}function vi(){const{transformedMetricKeys:s}=os();return s.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground",children:"Add metrics to configure series"}):e.jsx("div",{className:"space-y-3",children:s.map((n,r)=>e.jsx(yi,{metricKey:n,idx:r},n))})}function yi({metricKey:s,idx:n}){var j;const[r,o]=v.useState(!1),i=t.useEditorStore(N=>{var f;return(f=N.card)==null?void 0:f.type}),d=t.useEditorStore(N=>{var f;return(f=N.card)==null?void 0:f.preferences}),c=t.useEditorStore(N=>{var f,g;return(g=(f=N.card)==null?void 0:f.preferences)==null?void 0:g.datasetOptions}),l=c==null?void 0:c.find(N=>N.idx===n),{setCardPreferences:u}=t.useEditorStore(N=>N.actions),x=(l==null?void 0:l.borderRadius)??0,m=((j=l==null?void 0:l.dataLabels)==null?void 0:j.enabled)??!1;function b(N){const f={idx:n,borderRadius:x,dataLabels:l==null?void 0:l.dataLabels,...N};if(!l)u({...d||{},datasetOptions:[...c||[],f]});else{const g=c==null?void 0:c.map(k=>k.idx===n?{...k,...f}:k);u({...d||{},datasetOptions:g})}}function h(N){b({dataLabels:{...l==null?void 0:l.dataLabels,enabled:N}})}function p(N){b({dataLabels:N})}return e.jsx(a.Collapsible,{open:r,onOpenChange:o,children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between gap-3 overflow-hidden px-3 py-2 text-left hover:bg-muted/50",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-90")}),e.jsx("span",{className:"max-w-[100px] truncate text-xs font-medium",title:s,children:s})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:x>0&&e.jsxs("span",{className:t.cn("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs","border border-border bg-background text-muted-foreground"),children:[e.jsx(t.ChartColumn,{className:"h-3 w-3"}),"r:",x]})})]})}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-4 p-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Bar Style"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Corner Radius"}),e.jsxs(t.Select,{value:String(x),onValueChange:N=>b({borderRadius:Number(N)}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:bi.map(N=>e.jsx(t.SelectItem,{value:String(N),className:"text-xs",children:N===0?"None":`${N}px`},N))})]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-xs text-muted-foreground",children:"Data Labels"}),e.jsx(t.Switch,{size:"sm",checked:m,onCheckedChange:h})]}),m&&e.jsx("div",{className:"rounded-md border border-border bg-background p-2",children:e.jsx(ls,{config:l==null?void 0:l.dataLabels,onChange:p,isHorizontal:i==="horizontalBar",showAutoFormat:!0,showAppearance:!0})})]})]})})})]})})}const Ci=[0,1,2,3,4,5,6,8,10],Ni=[{value:"circle",label:"Circle ●"},{value:"rect",label:"Square ■"},{value:"rectRounded",label:"Rounded ▢"},{value:"rectRot",label:"Diamond ◆"},{value:"triangle",label:"Triangle ▲"},{value:"cross",label:"Cross +"},{value:"crossRot",label:"X ×"},{value:"star",label:"Star ★"},{value:"dash",label:"Dash —"},{value:"line",label:"Line │"}],Si=[{value:"solid",label:"Solid ───"},{value:"dashed",label:"Dashed - - -"},{value:"dotted",label:"Dotted ···"},{value:"dash-dot",label:"Dash-Dot -·-·"}];function wi(){const s=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>{var u;return(u=l.card)==null?void 0:u.preferences}),r=a.useEffectiveEditorCardType(),o=n==null?void 0:n.lineStyleConfig,{setCardPreferences:i,updateCardInFrame:d}=t.useEditorActions();if(!s||!["line","area","stackedArea"].includes(r))return null;const c=(l,u)=>{const x={...n||{},lineStyleConfig:{...o,[l]:u}};i(x),d({...s,preferences:x})};return e.jsxs(a.AccordionItem,{value:"line-style",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ar,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Line Style"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Default styles for all series. Override per-series in the Series section."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Line Pattern"}),e.jsxs(t.Select,{value:(o==null?void 0:o.lineStyle)||"solid",onValueChange:l=>c("lineStyle",l),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Si.map(({value:l,label:u})=>e.jsx(t.SelectItem,{value:l,className:"text-xs",children:u},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Point Size"}),e.jsxs(t.Select,{value:String((o==null?void 0:o.pointRadius)??3),onValueChange:l=>c("pointRadius",Number(l)),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ci.map(l=>e.jsx(t.SelectItem,{value:String(l),className:"text-xs",children:l===0?"None":l},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Point Shape"}),e.jsxs(t.Select,{value:(o==null?void 0:o.pointStyle)||"circle",onValueChange:l=>c("pointStyle",l),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ni.map(({value:l,label:u})=>e.jsx(t.SelectItem,{value:l,className:"text-xs",children:u},l))})]})]})]})})]})}const Ti=[0,2,4,6,8,10,12,16,20],Ei=[{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70%"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"1",label:"100%"}],Ii=[{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70%"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"1",label:"100%"}];function Di(){const s=t.useEditorStore(l=>l.card),n=t.useEditorStore(l=>{var u;return(u=l.card)==null?void 0:u.preferences}),r=a.useEffectiveEditorCardType(),o=n==null?void 0:n.barStyleConfig,{setCardPreferences:i,updateCardInFrame:d}=t.useEditorActions();if(!s||!["bar","horizontalBar","stackedBar"].includes(r))return null;const c=(l,u)=>{const x={...n||{},barStyleConfig:{...o,[l]:u}};i(x),d({...s,preferences:x})};return e.jsxs(a.AccordionItem,{value:"bar-style",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.ChartColumn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Bar Style"})]})}),e.jsx(a.AccordionContent,{className:"pt-2",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Default styles for all bars. Override per-series in the Series section."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Corner Radius"}),e.jsxs(t.Select,{value:String((o==null?void 0:o.borderRadius)??0),onValueChange:l=>c("borderRadius",Number(l)),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ti.map(l=>e.jsx(t.SelectItem,{value:String(l),className:"text-xs",children:l===0?"None":`${l}px`},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Bar Width"}),e.jsxs(t.Select,{value:String((o==null?void 0:o.barPercentage)??.9),onValueChange:l=>c("barPercentage",Number(l)),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ei.map(({value:l,label:u})=>e.jsx(t.SelectItem,{value:l,className:"text-xs",children:u},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(t.Label,{className:"text-xs font-medium",children:"Category Width"}),e.jsxs(t.Select,{value:String((o==null?void 0:o.categoryPercentage)??.8),onValueChange:l=>c("categoryPercentage",Number(l)),children:[e.jsx(t.SelectTrigger,{className:"h-8 text-xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Ii.map(({value:l,label:u})=>e.jsx(t.SelectItem,{value:l,className:"text-xs",children:u},l))})]})]})]})})]})}function ki(){const s=t.useEditorStore(r=>{var o,i;return(i=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:n}=t.useEditorActions();return e.jsxs(a.AccordionItem,{value:"stacked-sort",children:[e.jsx(a.AccordionTrigger,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-3.5 w-3.5 text-foreground/60"}),"Sort"]})}),e.jsx(a.AccordionContent,{className:"space-y-4 px-1",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Sort Order"}),e.jsx(pt,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"Ascending",value:"asc"},{label:"Descending",value:"desc"}],value:s||"none",onValueChange:r=>{n(r)}})]})})]})}const Mi=["kpi"],Ss=2;function wt(s){return typeof s=="string"?s.trim().toLowerCase():((s==null?void 0:s.id)||(s==null?void 0:s.qualifiedFieldName)||(s==null?void 0:s.name)||(s==null?void 0:s.label)||"").trim().toLowerCase()}function Ai(s){if(!(s!=null&&s.name)||!(s!=null&&s.dataType)||s.role==="metric")return!1;const n=t.getDataType(s.dataType);return["date","string","boolean"].includes(n)}function Li(s){return{...s,role:"groupby"}}function Fi(){var k,D;const s=t.useEditorStore(w=>w.card),n=t.useEditorStore(w=>w.actions.updateCardConfig),r=a.useEffectiveEditorCardType(),{scopedFields:o}=a.useScopedFields(),i=((k=s.config)==null?void 0:k.metricColumns)||[],d=((D=s.config)==null?void 0:D.summary)||{},c=d.breakdownDimensions||[],l=c.length>0,u=Mi.includes(r),x=i.length>0,m=d.enabled===!0,b=u&&x,h=Array.from(new Map(o.filter(Ai).map(w=>[wt(w),Li(w)])).values()),p=new Set(h.map(w=>wt(w))),j=new Set(c.map(w=>wt(w)).filter(w=>w&&p.has(w)));if(!u)return null;const N=w=>{n(s.id,{summary:{...d,...w}})},f=(w,S)=>{const L=wt(w),A=h.filter(I=>j.has(wt(I))),F=S?j.has(L)?A:[...A,w].slice(0,Ss):A.filter(I=>wt(I)!==L);N({breakdownDimensions:F,...F.length>0?{showOnCard:!0}:{}})},g=w=>{if(!w){N({enabled:!1,showOnCard:!1,includeInDashboardSummary:!1});return}N({enabled:!0,showOnCard:d.showOnCard??!0,includeInDashboardSummary:d.includeInDashboardSummary??!0})};return e.jsxs(a.AccordionItem,{value:"summary",className:"border-none",children:[e.jsxs(a.AccordionTrigger,{className:"flex items-center gap-2 py-2 text-[12px] hover:no-underline [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[e.jsx(a.FileText,{className:"h-3.5 w-3.5 text-foreground/60"}),e.jsx("span",{children:"Summary"})]}),e.jsx(t.Switch,{size:"xs",checked:m,disabled:!b,onClick:w=>w.stopPropagation(),onPointerDown:w=>w.stopPropagation(),onCheckedChange:g,"aria-label":"Enable summary"})]}),e.jsx(a.AccordionContent,{className:"pb-4 pt-2",children:e.jsxs("div",{className:t.cn("space-y-3 transition-opacity",!m&&"opacity-60"),children:[!b&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:x?"Summary is not supported for this card type.":"Add at least one metric to enable summary."}),!l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Checkbox,{id:"summary-show-on-card",checked:d.showOnCard===!0,disabled:!m,onCheckedChange:w=>N({showOnCard:w===!0})}),e.jsx(t.Label,{htmlFor:"summary-show-on-card",className:"cursor-pointer text-xs",children:"Show summary on card"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Checkbox,{id:"summary-include-rollup",checked:d.includeInDashboardSummary===!0,disabled:!m,onCheckedChange:w=>N({includeInDashboardSummary:w===!0})}),e.jsx(t.Label,{htmlFor:"summary-include-rollup",className:"cursor-pointer text-xs",children:"Include in dashboard summary"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Breakdown Dimensions"}),e.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[c.length,"/",Ss]})]}),h.length===0?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"No dimension fields available for breakdown."}):e.jsx("ul",{className:"max-h-40 space-y-1 overflow-y-auto",children:h.map(w=>{const S=wt(w),L=j.has(S),A=j.size>=Ss,F=!m||!L&&A;return e.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[e.jsx(a.Checkbox,{id:`summary-breakdown-${S}`,checked:L,disabled:F,onCheckedChange:I=>f(w,I===!0)}),e.jsx(t.Label,{htmlFor:`summary-breakdown-${S}`,className:"cursor-pointer text-xs",children:w.label||w.name})]},S)})})]})]})})]})}const Ri=new Set(["area","bar","bubble","bullet","combo","doughnut","funnel","horizontalBar","line","pie","polarArea","radar","scatter","stackedArea","stackedBar","stackedLine","tornado"]);function Pi(){const s=t.useEditorStore(u=>u.card),n=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),r=a.useEffectiveEditorCardType(),{setCardPreferences:o,updateCardInFrame:i}=t.useEditorActions();if(!s||!Ri.has(r||""))return null;const d=n==null?void 0:n.tooltipConfig,c=(d==null?void 0:d.formatMode)||(d==null?void 0:d.mode)||"inherit",l=u=>{const x={...n||{},tooltipConfig:{...d||{},...u}};o(x),i({...s,preferences:x})};return e.jsxs(a.AccordionItem,{value:"tooltip-format",className:"border-b-0",children:[e.jsx(a.AccordionTrigger,{className:"flex w-full items-center gap-2 py-2 text-[12px] font-medium hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Info,{className:"h-3.5 w-3.5 text-foreground/60"}),e.jsx("span",{children:"Tooltip Format"})]})}),e.jsxs(a.AccordionContent,{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Override metric format"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Keep this off to inherit from each metric."})]}),e.jsx(t.Switch,{size:"sm",checked:c==="override",onCheckedChange:u=>l({formatMode:u?"override":"inherit",mode:u?"override":"inherit"})})]}),c==="override"&&e.jsx(Kt,{formatOptions:(d==null?void 0:d.formatOptions)||{},onFormatOptionsChange:u=>l({formatMode:"override",mode:"override",formatOptions:u}),showTitle:!1})]})]})}function La({mode:s}){const n=t.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.type});return t.isTableChartType(n)?null:e.jsxs(e.Fragment,{children:[n==="combo"&&e.jsx(ni,{}),(n==="area"||n==="stackedArea")&&e.jsx(di,{}),n==="line"&&e.jsx(pi,{}),(n==="bar"||n==="horizontalBar"||n==="stackedBar")&&e.jsx(ji,{}),e.jsx(wi,{}),e.jsx(Di,{}),e.jsx(zl,{}),s==="config"&&e.jsx(Ml,{}),s==="config"&&e.jsx(Fi,{}),e.jsx($l,{}),n==="bullet"&&e.jsx(Kl,{}),n==="funnel"&&e.jsx(Hl,{}),(n==="bubble"||n==="scatter")&&e.jsx(Ul,{}),(n==="stackedBar"||n==="stackedLine")&&e.jsx(ki,{}),e.jsx(Bl,{}),e.jsx(Vl,{}),e.jsx(_l,{}),e.jsx(Yl,{}),e.jsx(Pi,{})]})}function Oi(){const s=t.useEditorStore(r=>r.card),n=s==null?void 0:s.type;return n?e.jsxs("div",{className:"space-y-4 px-6 py-4",children:[e.jsx(Os,{chartType:n}),e.jsx(a.Accordion,{type:"single",collapsible:!0,className:"w-full px-2",children:e.jsx(La,{mode:"dev"})})]}):null}function Bi({focusSection:s,focusRequestId:n}){const r=t.useEditorStore(c=>c.card),o=r.type;if(t.getVisualizationMode(r)==="dynamic")return e.jsx("div",{className:"p-6",children:e.jsxs(a.Alert,{children:[e.jsx(t.Info,{className:"h-4 w-4"}),e.jsx(a.AlertTitle,{children:"Dynamic mode manages presentation"}),e.jsx(a.AlertDescription,{children:"Built-in chart settings are hidden while this card is in dynamic mode. Query and data edits still apply, and the dynamic visual editor in the main panel controls the rendered output."})]})});function d(){if(t.supportsRegularTableSettings(o))return e.jsx(Aa,{cardType:o,focusSection:s,focusRequestId:n});switch(o){case"kpi":return e.jsx(bl,{});case"map":return e.jsx(Nl,{});case"custom":return e.jsx("div",{className:"px-6 py-2",children:e.jsx(Ta,{})});case"text":return e.jsx(Ll,{});default:return e.jsx(Oi,{})}}return e.jsxs(t.ScrollArea,{className:"h-full w-full text-sm",children:[d(),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}const Wn=32;function Vi(){const s=v.useRef(null),n=v.useRef(null),r=t.useEditorStore(g=>g.isShowingVisual),o=t.useEditorStore(g=>g.isDevMode),i=t.useEditorStore(g=>g.showAIDialog),[d,c]=v.useState(!1),[l,u]=v.useState({section:null,id:0}),x=r&&!i,m=x&&(!o||d),b=o&&x,h=()=>c(g=>!g),p=g=>{g&&u(k=>({section:g,id:k.id+1})),o&&c(!0)};v.useEffect(()=>{var g,k,D,w;i?((g=s.current)==null||g.resize(0),(k=n.current)==null||k.resize(0)):((D=s.current)==null||D.resize(Wn),(w=n.current)==null||w.resize(25))},[i]);const[j,N]=v.useState(!1),f=x?{show:b,isOpen:m,onToggle:h,onOpen:p}:void 0;return e.jsxs(a.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsx(a.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:50,children:e.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(uo,{renderCommandBarEnd:g=>e.jsx(gs,{mode:"toolbar",inlineToolbar:!0,overflowActions:g,visualAsideControl:f,isDynamicInspectorOpen:j,onDynamicInspectorOpenChange:N})})})})}),e.jsx(a.ResizableHandle,{}),e.jsx(a.ResizablePanel,{role:"visual-section",minSize:0,defaultSize:50,children:m?e.jsxs(a.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(a.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(gs,{mode:"canvas",visualAsideControl:f,isDynamicInspectorOpen:j,onDynamicInspectorOpenChange:N})}),!i&&e.jsx(a.ResizableHandle,{}),e.jsx(a.ResizablePanel,{ref:s,className:"flex",defaultSize:Wn,maxSize:45,children:e.jsx(Bi,{focusSection:l.section,focusRequestId:l.id})})]}):e.jsx(gs,{mode:"canvas",visualAsideControl:f,isDynamicInspectorOpen:j,onDynamicInspectorOpenChange:N})})]})}function _i(s){var ae;t.useAIInteractionStore(K=>K.currentAIContext);const[n,r]=v.useState(""),[o,i]=v.useState(null),{authToken:d,tokenProps:c}=a.useSemaphorContext(),l=t.useEditorStore(K=>K.card.id),u=t.useEditorStore(K=>{var ie;return(ie=K==null?void 0:K.card)==null?void 0:ie.sql}),x=t.useEditorStore(K=>K.isDevMode),m=t.useEditorStore(K=>{var ie;return(ie=K==null?void 0:K.card)==null?void 0:ie.python}),{setCardPython:b,setCardSql:h,setRunSql:p,switchCardType:j,setQueryConfig:N}=t.useEditorActions(),f=t.useEditorStore(K=>K.currentAssitantScope)||[],g=t.useEditorStore(K=>K.userInputForAI),k=t.useEditorStore(K=>K.triggerAIRun),D=t.useEditorStore(K=>K.card),w=t.useEditorStore(K=>K.selectedDatabaseName),S=t.useEditorStore(K=>K.selectedTableName),L=t.useEditorStore(K=>K.selectedConnectionId),A=t.useEditorStore(K=>K.selectedSchemaName),F=t.useDashboardStore(K=>K.dashboard.aiScopeTables),{errorMessage:I,refetch:y,data:E}=a.useEditorCardQuery(D),{setTriggerAIRun:M,setCurrentAssitantScope:T,setCardConfig:R}=t.useEditorActions(),{selectedDatamodelName:C,connectionType:V,selectedDatamodelId:P}=a.useEditorAside(),O=(ae=a.useDashboardQuery().data)==null?void 0:ae.assistantProfileId,B=v.useRef(a.createAssistantConversationId()),_=v.useRef(null),z=v.useRef(l),q=v.useRef(!1),Y=()=>{const K=_.current;K&&(_.current=null,B.current=a.createAssistantConversationId(),K==="clear"&&Q([]))},{messages:$,setMessages:Q,regenerate:U,error:J,sendMessage:X,status:ee,addToolResult:me,stop:be,clearError:ve}=a.useChat({transport:new a.DefaultChatTransport({api:`${c.apiServiceUrl}/v1/assistant`,headers:()=>({Authorization:`Bearer ${d==null?void 0:d.accessToken}`}),body:()=>{const K=t.useAIInteractionStore.getState();return{random:Math.random(),assistantId:"editor-assistant",assistantProfileId:O,conversationId:B.current,assistantRequestId:a.createAssistantRequestId(),isDevMode:x,aiContext:K.currentAIContext,reasoningEffort:K.reasoningEffort,showReasoning:K.showReasoning}},credentials:"omit",prepareSendMessagesRequest:({messages:K,body:ie})=>({body:{...ie,messages:t.cleanupIncompleteMessages(K)}})}),onError:K=>{var ie;if(q.current=!1,K.name==="AbortError"||(ie=K.message)!=null&&ie.includes("aborted")){console.log("[Editor Assistant] Stream aborted (expected)"),Y();return}console.error("[Editor Assistant] Stream error:",K),Y()},onToolCall:Me,onFinish({isAbort:K,isDisconnect:ie,isError:Se}){q.current=!1,r(""),console.log(K?"[Editor Assistant] Stream aborted by user":ie?"[Editor Assistant] Stream disconnected (network error)":Se?"[Editor Assistant] Stream error occurred":"[Editor Assistant] Stream completed successfully"),Y()}}),je=v.useCallback(K=>{q.current=!0;try{const ie=X(K);return a.isPromiseLike(ie)?ie.catch(Se=>{throw q.current=!1,Se}):ie}catch(ie){throw q.current=!1,ie}},[X]),Re=v.useCallback(()=>{q.current=!0;try{const K=U();return a.isPromiseLike(K)?K.catch(ie=>{throw q.current=!1,ie}):K}catch(K){throw q.current=!1,K}},[U]),Pe=K=>{let ie=!1;Q(Se=>{const re=typeof K=="function"?K(Se):K;if(re.length===0){if(q.current)return _.current="clear",ie=!0,Se;_.current=null,B.current=a.createAssistantConversationId()}return re}),ie&&be()};v.useEffect(()=>{if(z.current!==l){if(z.current=l,q.current){_.current!=="clear"&&(_.current="rotate"),be();return}_.current=null,B.current=a.createAssistantConversationId()}},[l,be]),v.useEffect(()=>{k&&g&&(je({role:"user",parts:[{type:"text",text:g}]}),M(!1))},[k,g,je,M]);async function Me({toolCall:K}){var ie,Se,re,pe,Ye,Z,Fe,xe,ze,Le,$e,we,oe,te,ue,Ce;if(["createChartFromSql","createForecast"].includes(K.toolName)){const fe=((ie=K.input)==null?void 0:ie.sql)??((Se=K.args)==null?void 0:Se.sql),He=((re=K.input)==null?void 0:re.python)??((pe=K.args)==null?void 0:pe.python),ke=((Ye=K.input)==null?void 0:Ye.chartType)??((Z=K.args)==null?void 0:Z.chartType);j(ke),h(fe),b(He),p(!0),me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"success",message:"Let the user know that chart is created"}})}else if(K.toolName==="getUserSql"){if(!u){me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"error",message:"No SQL found"}});return}me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"success",sql:u,python:m||""}})}else if(K.toolName==="generateQueryConfig"){r("Generating query config...");const fe=((Fe=K.input)==null?void 0:Fe.chartType)??((xe=K.args)==null?void 0:xe.chartType),He=((ze=K.input)==null?void 0:ze.queryConfig)??((Le=K.args)==null?void 0:Le.queryConfig);(($e=K.input)==null?void 0:$e.cardConfig)??((we=K.args)==null||we.cardConfig),j(fe),R(He),h(void 0),b(void 0);const ke=await y();if((oe=ke==null?void 0:ke.data)!=null&&oe.error){me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"error",queryConfig:He,message:(te=ke==null?void 0:ke.data)==null?void 0:te.error.message}});return}if((ue=ke==null?void 0:ke.data)!=null&&ue.records){me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"success",queryConfig:He,message:"The data has been visualized"}});return}me({tool:K.toolName,toolCallId:K.toolCallId,output:{status:"success",queryConfig:He,message:"The data has been visualized",records:(Ce=ke==null?void 0:ke.data)==null?void 0:Ce.records}})}else r("Analyzing...")}function Ee(K){const ie=a.removeFromScopeArray(f,K);Be(ie)}function Be(K){const ie=a.sanitizeAIScope(K);T(ie),Q(Se=>[...Se,{id:crypto.randomUUID(),role:"system",parts:[{type:"text",text:`Current scope of tables. Always use the table reference format when generating SQL | ${JSON.stringify(ie)}`}]}])}function _e(){const K={databaseName:w||"",schemaName:A||"",tableName:S||"",datamodelId:P||"",datamodelName:t.resolveDatamodelName(C),connectionId:L||"",connectionType:V||""},ie=a.dedup([...f,K]);Be(ie)}function Oe(){const K={databaseName:w||"",schemaName:A||"",tableName:S||"",datamodelName:t.resolveDatamodelName(C),connectionId:L||"",connectionType:V||"",datamodelId:P||""};if(!a.isInAiScopeArray([...F||[],...f],K)||f.length===0){const Se=a.dedup([...F||[],...f,K]).filter(re=>re.connectionId===K.connectionId);Be(Se)}}const Ae=!["ready","error"].includes(ee),De=a.getErrorMessage(J);return{messages:$,setMessages:Pe,sendMessage:je,regenerate:Re,isLoading:Ae,handleSetAIScope:Oe,handleAddCurrentTableToScope:_e,removeFromCurrentSelections:Ee,currentAssitantScope:f,setCurrentAssitantScope:T,stop:be,status:ee,toolStatus:n,llmUsage:o,onFinish:s,errorMessage:De,clearError:ve}}const Yi=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function Xn({isFullscreen:s,onFullscreenChange:n,fullscreenContainer:r}){const o=v.useRef(null),i=v.useRef(!1),[d,c]=v.useState(!1),[l,u]=v.useState(ye.isDevEnv),[x,m]=v.useState(!1),[b,h]=v.useState(!1),[p,j]=v.useState(!1),[N,f]=v.useState(0),g=s??p,k=t.useCurrentAIContext(),{setCurrentAIContext:D,setHasEditorEntitySelectionOverride:w}=t.useAIActions(),{clearQueue:S}=t.useQueueActions(),{clearFileAttachments:L}=t.useFileActions(),A=t.useFileAttachments("editor"),{selectedEntities:F}=a.useAssistantContextEntities("editor"),I=t.useEditorStore(re=>re.card.id),y=t.useEditorStore(re=>re.card.dataSource),E=t.useEditorStore(re=>{var pe;return(pe=re.card.dataSource)==null?void 0:pe.selectedEntities}),M=t.useEditorStore(re=>re.actions.setCardSql),T=t.useEditorStore(re=>re.actions.setRunSql),R=t.useEditorStore(re=>re.showAIDialog),C=t.useDashboardStore(re=>re.handleOpenAssistantProfile),{setShowAIDialog:V,setCardPython:P}=t.useEditorActions(),{assistantProfile:O}=a.useAssistantProfile(),{messages:B,setMessages:_,sendMessage:z,isLoading:q,stop:Y,status:$,llmUsage:Q,errorMessage:U,clearError:J}=_i(),[X,ee]=v.useState(""),me=re=>{ee(re.target.value)},be=re=>{re.preventDefault();const pe=X.trim();if(!pe&&A.length===0)return;const Ye=[];pe&&Ye.push({type:"text",text:pe}),A.forEach(Z=>{Z.data&&Ye.push({type:"file",mediaType:Z.type,filename:Z.name,url:`data:${Z.type};base64,${Z.data}`})}),z({role:"user",parts:Ye}),ee(""),L("editor"),ve()},ve=v.useCallback(()=>{f(re=>re+1)},[]);v.useEffect(()=>{var re;R&&!i.current&&((re=o.current)==null||re.focus()),i.current=R},[R]),v.useEffect(()=>{R&&(w(!1),D({selectedEntities:E||[]}))},[I,E,D,w,R]),a.useAutoSubmitQueue({assistantType:"editor",status:$,isLoading:q,sendMessage:z});const{hasActiveTools:je,activeToolText:Re}=a.useActiveToolStatus(B),Pe=v.useCallback(re=>{n==null||n(re),s===void 0&&j(re)},[s,n]);v.useEffect(()=>{if(!g)return;function re(pe){pe.key==="Escape"&&Pe(!1)}return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[g,Pe]);const Me=v.useCallback(re=>{z({role:"user",parts:[{type:"text",text:re}]}),ve()},[ve,z]),Ee=v.useCallback(async()=>{const re=JSON.stringify(B??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(re),t.ue.success("Conversation copied")}catch(pe){console.error("Failed to copy conversation",pe),t.ue.error("Unable to copy conversation")}},[B]),Be=v.useCallback(()=>{Pe(!g)},[g,Pe]);function _e(re,pe){pe==="sql"?(M(re),T(!0)):pe==="python"&&(P(re),T(!0))}function Oe(){k.selectedEntities.length===0&&D({selectedEntities:F})}function Ae(re){Oe();const pe={role:"user",parts:[{type:"text",text:re.title+" "+re.subtitle}]};z(pe),ve()}function De(re){Oe(),z({role:"user",parts:[{type:"text",text:re}]}),ve()}function ae(){return e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",size:"xs",variant:"ghost","aria-label":"Assistant options",children:e.jsx(a.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",children:[e.jsx(a.DropdownMenuLabel,{children:"Options"}),e.jsx(a.DropdownMenuSeparator,{}),e.jsx(a.DropdownMenuCheckboxItem,{checked:d,onCheckedChange:c,children:"Token usage"}),e.jsx(a.DropdownMenuCheckboxItem,{checked:l,onCheckedChange:u,children:"Tool invocations"}),e.jsx(a.DropdownMenuCheckboxItem,{checked:x,onCheckedChange:m,children:"System message"})]})]})}function K(){return e.jsx("div",{"data-role":"header",className:"flex min-w-0 items-center",children:e.jsx("div",{className:"truncate text-[13px] font-medium",children:"Assistant"})})}const ie=(X==null?void 0:X.length)===0&&(B==null?void 0:B.filter(re=>re.role==="user").length)===0,Se=e.jsxs("div",{"data-role":"editor-assistant",className:t.cn("flex h-full w-full flex-col justify-between px-6 py-4",g&&"rounded-card border border-border/60 bg-background px-8 pb-6 pt-6 shadow-xl"),children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-center justify-between gap-2",children:[K(),C&&e.jsx(t.Button,{variant:"outline",size:"xs",className:"min-w-0 shrink",onClick:C,children:e.jsx("span",{className:"truncate",children:(O==null?void 0:O.name)||"Default profile"})}),e.jsxs("div",{"data-role":"header-actions",className:"flex shrink-0 items-center gap-1.5",children:[ae(),l&&e.jsx(t.Button,{variant:"ghost",size:"xs",className:"text-muted-foreground hover:text-foreground",onClick:Ee,children:"Copy conversation"}),e.jsx(a.IconButton,{tooltip:g?"Exit fullscreen":"Expand",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:Be,children:g?e.jsx(qe.Minimize2,{className:"h-3.5 w-3.5"}):e.jsx(qe.Maximize2,{className:"h-3.5 w-3.5"})}),e.jsx(a.IconButton,{className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",tooltip:"New chat",onClick:()=>{_([]),S("editor"),J()},children:e.jsx(a.SquarePen,{className:"h-3.5 w-3.5"})}),e.jsx(a.IconButton,{tooltip:"Close",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:()=>{V(!1)},children:e.jsx(le.X,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(a.AssistantVirtualizedMessages,{messages:B,showTools:l,handleRun:_e,showSystemMessage:x,onQuickReply:Me,disableQuickReplies:q,status:$,errorMessage:U,activeToolText:q&&je?Re:void 0,className:"mt-2 w-full grow px-0 py-2 pr-3",latestButtonClassName:R?"bottom-24 right-8":"hidden",scrollToEndSignal:N}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[ie&&!O&&e.jsx(a.Placeholders,{onClick:Ae,placeholders:Yi}),e.jsx("div",{children:ie&&O&&e.jsx(a.SeedQuestions,{seedQuestions:O.seedQuestions||[],handleSeedQuestionClick:De})})]}),e.jsx(a.PendingMessagesDisplay,{assistantType:"editor",className:"mb-3"}),e.jsx(a.ChatInputWithContext,{ref:o,setInput:ee,stop:Y,input:X,handleInputChange:me,handleSubmit:re=>{Oe(),be(re)},isLoading:q,status:$,assistantType:"editor",onFocus:()=>{}})]}),Q&&d&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",Q.inputTokens," prompt tokens, ",Q.outputTokens," ","completion tokens, ",Q.totalTokens," total tokens"]})}),e.jsx(a.AddDataPicker,{incomingSelectedEntities:F,open:b,onOpenChange:h,dataSource:y||a.EMPTY_DATA_SOURCE,dialogMode:"aiContext",onSaveSelectedEntities:re=>{w(!0),D({...k,selectedEntities:re})}})]});return g&&r?dr.createPortal(e.jsx(a.SemaphorStyleWrapper,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background px-6 pb-6 pt-[calc(var(--app-header-height,15px)+1rem)]",children:e.jsx("div",{className:"flex h-full w-full",children:Se})}),r):Se}function Vs({children:s,className:n,delayDuration:r}){return e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:r,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:t.cn("overflow-hidden text-ellipsis whitespace-nowrap",n),children:s})}),e.jsx(t.TooltipContent,{children:s})]})})}function Fa({id:s,label:n,dataType:r,calculated:o,open:i,onOpenChange:d,onRemove:c,sortDirection:l,onSortDirectionChange:u,badge:x,children:m}){const{attributes:b,listeners:h,setNodeRef:p,transform:j,transition:N,isDragging:f}=a.useSortable({id:s});return e.jsxs(t.Popover,{modal:!0,open:i,onOpenChange:d,children:[e.jsxs("div",{ref:p,style:{transform:a.CSS.Transform.toString(j),transition:N},className:t.cn("group flex h-7 w-full items-center gap-1.5 rounded-control border bg-background px-1.5 transition-colors",i?"border-foreground/30 bg-muted/40":"border-border hover:bg-muted/40",f&&"z-50 scale-95 opacity-50"),children:[e.jsx("button",{type:"button",...b,...h,"aria-label":`Drag ${n}`,className:t.cn(a.GRIP_REVEAL_CLASS,"text-muted-foreground hover:text-foreground"),onClick:g=>g.stopPropagation(),children:e.jsx(a.GripVertical,{className:"h-3 w-3"})}),e.jsx(a.TypeGlyph,{dataType:r,calculated:o}),e.jsx(Vs,{className:"block w-0 min-w-0 flex-1 text-[12px] text-foreground",children:n}),x,u&&e.jsx("button",{type:"button","aria-label":l==="asc"?"Switch to descending":"Switch to ascending",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",onClick:g=>{g.stopPropagation(),u(l==="asc"?"desc":"asc")},children:l==="asc"?e.jsx(a.ArrowUp,{className:"h-3 w-3"}):e.jsx(a.ArrowDown,{className:"h-3 w-3"})}),m&&e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Field configuration",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground data-[state=open]:bg-muted",onClick:g=>g.stopPropagation(),children:e.jsx(a.Ellipsis,{className:"h-3 w-3"})})}),e.jsx("button",{type:"button","aria-label":"Remove",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 hover:bg-muted hover:text-foreground group-focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onClick:g=>{g.stopPropagation(),c()},children:e.jsx(le.X,{className:"h-3 w-3"})})]}),m&&e.jsx(t.PopoverContent,{align:"start",sideOffset:6,className:"w-[320px] p-0",children:e.jsx("div",{className:"max-h-[480px] space-y-3 overflow-y-auto p-3",children:m})})]})}function zi(s,n){var o;if(n.status==="blocked"||(o=s.sql)!=null&&o.trim())return!1;const r=new Set(n.mappingDispositions.flatMap(i=>i.status==="apply"?[i.filterValue.filterId]:[]));return n.cardFilterValues.some(i=>{const d=n.queryFilterDefinitions.find(u=>u.id===i.filterId);if(!t.hasFiniteDateComparisonRange(i))return!1;if(!(r.has(i.filterId)||(d==null?void 0:d.kind)==="global-date"))return!!(d&&qi([d],n.resolvedPrimaryDateField,[i]));const l=t.buildExecutedDateFilterDefinition(i);return!!(l&&t.resolveFieldDateComparisonCandidate({card:s,filter:l,filterValue:i,effectiveFilterValue:i,temporalBinding:n.resolvedPrimaryDateField}).status==="eligible")})}function qi(s,n,r){if(!n)return!1;const o=n.qualifiedFieldName,i=n.qualifiedEntityName,d=i&&n.name?`${i}.${n.name}`:o;return s.some(c=>{if(!(t.getDataType(c.dataType||"")==="date"))return!1;const u=a.getSelectedDateFilterColumn(c,r),x=u.split("."),m=x[x.length-1]||u,b=x.length>1?x.slice(0,-1).join("."):void 0,h=c.qualifiedTableName||b,p=h?`${h}.${m}`:void 0;return o?p?p===d||p.endsWith(`.${o}`):m===n.name:p?p===d:m===n.name})}function $i(s){switch(s){case"day":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"YYYY-MM-DD HH:mm",label:"2024-01-15 14:30 (YYYY-MM-DD HH:mm)"},{value:"YYYY-MM-DD HH:mm:ss",label:"2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"},{value:"YYYY-MM-DD HH:mm Z",label:"2024-01-15 14:30 +00:00 (YYYY-MM-DD HH:mm Z)"},{value:"YYYY-MM-DD HH:mm:ss Z",label:"2024-01-15 14:30:45 +00:00 (YYYY-MM-DD HH:mm:ss Z)"},{value:"custom",label:"Custom Format..."}];case"week":return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"Week of MMM DD, YYYY",label:"Week of Jan 15, 2024"},{value:"Week of MMMM DD, YYYY",label:"Week of January 15, 2024"},{value:"YYYY-WW",label:"2024-W03 (YYYY-WW)"},{value:"custom",label:"Custom Format..."}];case"month":return[{value:"MMM YYYY",label:"Jan 2024 (MMM YYYY)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MM/YYYY",label:"01/2024 (MM/YYYY)"},{value:"YYYY MMM",label:"2024 Jan (YYYY MMM)"},{value:"custom",label:"Custom Format..."}];case"quarter":return[{value:"Q1 YYYY",label:"Q1 2024 (Q1 YYYY)"},{value:"YYYY Q1",label:"2024 Q1 (YYYY Q1)"},{value:"1st Quarter YYYY",label:"1st Quarter 2024"},{value:"YYYY-Q1",label:"2024-Q1 (YYYY-Q1)"},{value:"Quarter 1, YYYY",label:"Quarter 1, 2024"},{value:"custom",label:"Custom Format..."}];case"year":return[{value:"YYYY",label:"2024 (YYYY)"},{value:"YY",label:"24 (YY)"},{value:"custom",label:"Custom Format..."}];case"hour":return[{value:"YYYY-MM-DD HH:mm",label:"2024-01-15 14:00 (YYYY-MM-DD HH:mm)"},{value:"YYYY-MM-DD HH:mm Z",label:"2024-01-15 14:00 +00:00 (YYYY-MM-DD HH:mm Z)"},{value:"custom",label:"Custom Format..."}];case"minute":return[{value:"YYYY-MM-DD HH:mm",label:"2024-01-15 14:30 (YYYY-MM-DD HH:mm)"},{value:"YYYY-MM-DD HH:mm:ss",label:"2024-01-15 14:30:00 (YYYY-MM-DD HH:mm:ss)"},{value:"YYYY-MM-DD HH:mm Z",label:"2024-01-15 14:30 +00:00 (YYYY-MM-DD HH:mm Z)"},{value:"custom",label:"Custom Format..."}];case"second":return[{value:"YYYY-MM-DD HH:mm:ss",label:"2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"},{value:"YYYY-MM-DD HH:mm:ss Z",label:"2024-01-15 14:30:45 +00:00 (YYYY-MM-DD HH:mm:ss Z)"},{value:"custom",label:"Custom Format..."}];default:return[{value:"MM-DD-YYYY",label:"01-15-2024 (MM-DD-YYYY)"},{value:"YYYY-MM-DD",label:"2024-01-15 (YYYY-MM-DD)"},{value:"MM/DD/YYYY",label:"01/15/2024 (MM/DD/YYYY)"},{value:"DD/MM/YYYY",label:"15/01/2024 (DD/MM/YYYY)"},{value:"MMMM DD, YYYY",label:"January 15, 2024 (MMMM DD, YYYY)"},{value:"MMM DD, YYYY",label:"Jan 15, 2024 (MMM DD, YYYY)"},{value:"DD MMM YYYY",label:"15 Jan 2024 (DD MMM YYYY)"},{value:"YYYY-MM-DD HH:mm",label:"2024-01-15 14:30 (YYYY-MM-DD HH:mm)"},{value:"YYYY-MM-DD HH:mm:ss",label:"2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"},{value:"YYYY-MM-DD HH:mm Z",label:"2024-01-15 14:30 +00:00 (YYYY-MM-DD HH:mm Z)"},{value:"YYYY-MM-DD HH:mm:ss Z",label:"2024-01-15 14:30:45 +00:00 (YYYY-MM-DD HH:mm:ss Z)"},{value:"YYYY-MM",label:"2024-01 (YYYY-MM)"},{value:"MMMM YYYY",label:"January 2024 (MMMM YYYY)"},{value:"custom",label:"Custom Format..."}]}}function Ki({aliasTemplate:s,onAliasTemplateChange:n}){var u;const[r,o]=v.useState(s),[i,d]=v.useState(!1),c=(u=t.useEditorStore(x=>{var m;return(m=x.card.config)==null?void 0:m.pivotByColumns}))==null?void 0:u[0],l=c?`e.g. Min Sales in {{${c.name}}}`:"e.g. Min Sales in {{region}}";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-gray-600",children:"Pivot Alias Template"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Input,{placeholder:l,value:i?r:s,onChange:x=>{o(x.target.value),d(!0)},onFocus:()=>d(!0),onPointerDown:x=>x.stopPropagation(),className:"h-8 text-xs",onKeyDown:x=>{x.key==="Enter"&&i&&r!==s?(n(r),d(!1)):x.key==="Escape"&&(o(s),d(!1))},"aria-label":"Edit alias template"}),i&&r!==s&&e.jsxs(e.Fragment,{children:[e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Confirm alias template",onClick:()=>{n(r),d(!1)},children:e.jsx(t.Check,{className:"h-4 w-4 text-green-600"})}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Cancel alias template edit",onClick:()=>{o(s),d(!1)},children:e.jsx(le.X,{className:"h-4 w-4 text-gray-400"})})]})]})]})}function Ui({valueAliases:s,onValueAliasesChange:n}){const[r,o]=v.useState(null),[i,d]=v.useState(""),[c,l]=v.useState(""),u=()=>{n({...s,"":""})},x=b=>{const h={...s};delete h[b],n(h)},m=b=>{const h={...s};delete h[b],h[i]=c,n(h),o(null)};return e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Pivot Value Aliases"}),e.jsxs("div",{className:"space-y-2",children:[Object.entries(s).map(([b,h],p)=>e.jsx("div",{className:"flex items-center gap-2",children:r===b?e.jsxs(e.Fragment,{children:[e.jsx(t.Input,{placeholder:"Value key",value:i,onChange:j=>d(j.target.value),className:"h-8 w-24 text-xs",onPointerDown:j=>j.stopPropagation(),onKeyDown:j=>{j.key==="Enter"?m(b):j.key==="Escape"&&o(null)},"aria-label":"Edit value alias key"}),e.jsx(t.Input,{placeholder:"Alias label",value:c,onChange:j=>l(j.target.value),className:"h-8 w-24 text-xs",onPointerDown:j=>j.stopPropagation(),onKeyDown:j=>{j.key==="Enter"?m(b):j.key==="Escape"&&o(null)},"aria-label":"Edit value alias label"}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Confirm value alias edit",onClick:()=>m(b),children:e.jsx(t.Check,{className:"h-4 w-4 text-green-600"})}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0","aria-label":"Cancel value alias edit",onClick:()=>o(null),children:e.jsx(le.X,{className:"h-4 w-4 text-muted-foreground"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Input,{placeholder:"Value key",value:b,className:"h-8 w-24 text-xs",readOnly:!0,onClick:()=>{o(b),d(b),l(h)},"aria-label":"Edit value alias key"}),e.jsx(t.Input,{placeholder:"Alias label",value:h,className:"h-8 w-24 text-xs",readOnly:!0,onClick:()=>{o(b),d(b),l(h)},"aria-label":"Edit value alias label"}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>x(b),"aria-label":"Remove value alias",children:e.jsx(le.X,{className:"h-3 w-3"})})]})},b+p)),e.jsxs(t.Button,{variant:"outline",size:"sm",className:"mt-1 h-8 text-xs",onClick:u,children:[e.jsx(a.Plus,{className:"mr-1 h-3 w-3"})," Add Value Alias"]})]})]})}function Gi({idx:s}){var l;const n=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),r=t.useEditorStore(u=>{var x;return(x=u.card.preferences)==null?void 0:x.datasetOptions}),o=t.useEditorStore(u=>u.actions.setCardPreferences),i=(l=n==null?void 0:n.chartOptions)==null?void 0:l.indexAxis,d=r==null?void 0:r.find(u=>u.idx===s);function c(u,x){(u==="end"||u==="start")&&ye.getContrastColor(ye.getCanvasBackgroundColor());const m={display:u!=="none",align:u,anchor:u,clamp:!0};if(!d)o({...n,datasetOptions:[...r||[],{idx:x,datalabels:m}]});else{const b={...d};b.datalabels=m;const h=r==null?void 0:r.map(p=>p.idx===x?b:p);o({...n,datasetOptions:h})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(a.Tag,{className:"size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(t.PopoverContent,{className:"w-fit px-2 py-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>c("none",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(le.X,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>c("start",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Sr,{className:t.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsx("button",{onClick:()=>c("center",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Tr,{className:t.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsx("button",{onClick:()=>c("end",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(wr,{className:t.cn("h-4 w-4",{"rotate-90":i==="y"})})})]})})]})}function Hi(s,n=30){return s.length>n?s.slice(0,n)+"...":s}function Qi({col:s,idx:n,className:r,iconClassName:o,children:i}){const d=t.useEditorStore(m=>{var b;return(b=m.card)==null?void 0:b.preferences}),c=t.useEditorStore(m=>{var b,h;return(h=(b=m.card)==null?void 0:b.preferences)==null?void 0:h.datasetOptions}),l=c==null?void 0:c.find(m=>m.idx===n),{setCardPreferences:u}=t.useEditorStore(m=>m.actions);function x(m){if(!l)u({...d,datasetOptions:[...c||[],{idx:n,type:m==="area"?"line":m,fill:m==="area"?"origin":""}]});else{const b={...l};b.type=m==="area"?"line":m,b.fill=m==="area"?"origin":"";const h=c==null?void 0:c.map(p=>p.idx===n?b:p);u({...d,datasetOptions:h})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-2 rounded-md",r),children:[i||e.jsx(Vs,{className:"max-w-[100px]",title:s,children:Hi(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a.ChartColumnIncreasing,{onClick:()=>x("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",o)}),e.jsx(a.ChartLine,{onClick:()=>x("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",o)}),e.jsx(a.ChartArea,{onClick:()=>x("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",o)}),e.jsx(Gi,{idx:n})]})]})}function Ji(){const s=t.useEditorStore(l=>l.card.type),n=t.useEditorStore(l=>l.isDevMode),r=t.useEditorStore(l=>l.card.preferences),{setCardPreferences:o}=t.useEditorStore(l=>l.actions);function i(l){var m;const u={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},x={...r,chartOptions:{...r==null?void 0:r.chartOptions,plugins:{...(m=r==null?void 0:r.chartOptions)==null?void 0:m.plugins,...u}}};o(x)}function d(){var l,u,x;return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(t.Select,{value:((x=(u=(l=r==null?void 0:r.chartOptions)==null?void 0:l.plugins)==null?void 0:u.datalabels)==null?void 0:x.anchor)||"none",onValueChange:i,defaultValue:"none",children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Data Labels"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function c(){var l,u,x;return e.jsx("div",{children:e.jsxs(t.Select,{value:((x=(u=(l=r==null?void 0:r.chartOptions)==null?void 0:l.plugins)==null?void 0:u.datalabels)==null?void 0:x.anchor)||"none",onValueChange:i,defaultValue:"none",children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectItem,{className:"text-xs",value:"none",children:"None"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{className:"text-xs",value:"start",children:"Start"}),e.jsx(t.SelectItem,{className:"text-xs",value:"center",children:"Center"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{className:"text-xs",value:"end",children:"End"})]})})]})})}return e.jsx(e.Fragment,{children:n?d():c()})}function Wi({column:s}){const n=t.useEditorStore(u=>u.card.type),r=t.useEditorStore(u=>{var x,m;return(m=(x=u.card)==null?void 0:x.config)==null?void 0:m.metricColumns}),o=(r==null?void 0:r.map(u=>u.label))||[],i=o==null?void 0:o.find(u=>u===s.label||u===s.name),d=i?o.indexOf(i):-1;function c(){return e.jsx("div",{className:"pr-1",children:i&&e.jsx(Qi,{idx:d,col:i,children:e.jsx("div",{className:"w-[130px] text-xs text-muted-foreground",children:"Display Series As"})})})}function l(){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Data Labels"}),e.jsx(Ji,{})]})}return e.jsxs("div",{className:"space-y-1",children:[["stackedBar","stackedLine","bar","line"].includes(n)&&c(),["pie","doughnut"].includes(n)&&l()]})}function Xi({field:s,searchQuery:n="",limit:r=500}){const{authToken:o,tokenProps:i}=a.useSemaphorContext(),d=t.useDashboardStore(m=>{var b;return((b=m.reportContext)==null?void 0:b.calendar)??null}),c=t.useEditorStore(m=>m.card),l=c==null?void 0:c.dataSource,u=["attribute-values",s.entityName,s.name,n,r,d],x=a.useQuery({queryKey:u,queryFn:async()=>{if(!(l!=null&&l.connectionId))return console.warn("No connection ID available for attribute values query"),[];try{const m={groupByColumns:[{...s,role:"groupby"}],metricColumns:[],filters:n?{id:"search-filter",logicalOperator:"AND",negate:!1,conditions:[{id:"search-condition",field:s,operator:"contains",value:n}],groups:[]}:void 0,rowLimit:r},b={connection_id:l.connectionId,cardConfig:m,cardDataSource:l,cache_config:t.getCacheConfig({card:c}),calendarContext:d};console.log("requestBody",b);const h=await t.postRequestRegular(`${i.apiServiceUrl}/v1/query`,(o==null?void 0:o.accessToken)||"",b);if(h!=null&&h.error)return console.error("Error fetching attribute values:",h.error),[];const p=s.name;return((h==null?void 0:h.records)||[]).map(N=>{const f=N[p]||N[s.alias||p]||N[s.label];return{id:f||"",value:f||"",label:String(f||"(empty)")}})}catch(m){return console.error("Error fetching attribute values:",m),[]}},enabled:!!s&&!!(l!=null&&l.connectionId)&&!!d,staleTime:5*60*1e3,gcTime:10*60*1e3});return{values:x.data||[],isLoading:x.isLoading,isFetching:x.isFetching,isError:x.isError,error:x.error,refetch:x.refetch}}const Zi=new Set;function Ra({open:s,onOpenChange:n,availableFields:r,existingFilters:o,editingCondition:i,onSave:d}){const c=!!i,[l,u]=v.useState(c?"values":"fields"),[x,m]=v.useState(""),[b,h]=v.useState({id:(i==null?void 0:i.id)||ye.v4(),field:(i==null?void 0:i.field)||null,selectedValues:i?Array.isArray(i.value)?i.value:[i.value]:[]}),p=r.filter(D=>{var S;return c?!1:!((S=o==null?void 0:o.conditions)==null?void 0:S.some(L=>L.field.id===D.id))}),j=D=>{h({...b,field:D}),u("values")},N=()=>{if(b.field&&b.selectedValues.length>0){const D={id:b.id,field:b.field,operator:"in",value:b.selectedValues};let w;if(c){const S=((o==null?void 0:o.conditions)||[]).map(L=>L.id===i.id?D:L);w={...o,conditions:S}}else{const S=(o==null?void 0:o.conditions)||[];w={id:(o==null?void 0:o.id)||ye.v4(),logicalOperator:"AND",negate:!1,conditions:[...S,D],groups:[]}}d(w),n(!1)}},f=()=>{if(!c||!i)return;const D=((o==null?void 0:o.conditions)||[]).filter(w=>w.id!==i.id);if(D.length>0){const w={...o,conditions:D};d(w)}else d(void 0);n(!1)},g=D=>{h({...b,selectedValues:D})},k=()=>{c&&i?(h({id:i.id,field:i.field,selectedValues:Array.isArray(i.value)?i.value:[i.value]}),u("values")):(h({id:ye.v4(),field:null,selectedValues:[]}),u("fields")),m("")};return v.useEffect(()=>{s&&k()},[s,c,i]),e.jsx(a.Dialog,{open:s,onOpenChange:n,children:e.jsxs(a.DialogContent,{className:"max-w-2xl",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:c?`Edit Filter: ${b.field?a.getFieldDisplayLabel(b.field):""}`:l==="fields"?"Select Field to Filter":`Select Values for ${b.field?a.getFieldDisplayLabel(b.field):""}`})}),e.jsxs("div",{className:"space-y-4",children:[!c&&(o==null?void 0:o.conditions)&&o.conditions.length>0&&l==="fields"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Current Filters:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:o.conditions.map(D=>e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted rounded-md text-xs",children:[e.jsxs("span",{className:"font-medium",children:[a.getFieldDisplayLabel(D.field),":"]}),e.jsx("span",{className:"text-muted-foreground",children:Array.isArray(D.value)?`${D.value.length} values`:String(D.value)})]},D.id))})]}),l==="fields"&&!c?e.jsx("div",{className:"flex flex-col",children:e.jsx(a.FieldOptionList,{fields:p,selectedIds:Zi,onSelect:j,query:x,onQueryChange:m,density:"compact",listLabel:"Filterable fields",listClassName:"max-h-[400px]",autoFocusSearch:!0,emptyMessage:x?`No fields found matching "${x}"`:r.length>0?"All available fields are already filtered":void 0})}):e.jsx(ec,{field:b.field,selectedValues:b.selectedValues,onValuesChange:g,onBack:c?void 0:()=>u("fields")}),e.jsxs("div",{className:"flex justify-between pt-4 border-t",children:[e.jsx("div",{children:c?e.jsx(t.Button,{variant:"destructive",onClick:f,children:"Delete Filter"}):e.jsx(t.Button,{variant:"outline",onClick:k,children:"Reset"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(t.Button,{onClick:N,disabled:!b.field||b.selectedValues.length===0,children:"Apply"})]})]})]})]})})}function ec({field:s,selectedValues:n,onValuesChange:r,onBack:o}){const[i,d]=v.useState(""),{values:c,isLoading:l,isFetching:u}=Xi({field:s,searchQuery:i,limit:500}),x=i?c.filter(h=>String(h.value).toLowerCase().includes(i.toLowerCase())):c,m=h=>{const p=n.includes(h);r(p?n.filter(j=>j!==h):[...n,h])},b=()=>{n.length===x.length&&x.length>0?r([]):r(x.map(h=>h.value))};return e.jsxs("div",{className:"space-y-4",children:[o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",onClick:o,children:"← Back"}),e.jsxs(t.Label,{className:"text-sm font-medium",children:["Select values for ",a.getFieldDisplayLabel(s)]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(qe.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(t.Input,{placeholder:"Search values...",value:i,onChange:h=>d(h.target.value),className:"pl-10"})]}),l||u?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(t.LoaderCircle,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b",children:[e.jsx(a.Checkbox,{checked:n.length===x.length&&x.length>0,onCheckedChange:b}),e.jsxs(t.Label,{className:"text-sm",children:["Select All (",x.length,")"]})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-1",children:x.map(h=>e.jsxs("div",{className:"flex items-center gap-2 p-2 hover:bg-muted/50 rounded cursor-pointer",onClick:()=>m(h.value),children:[e.jsx(a.Checkbox,{checked:n.includes(h.value),onCheckedChange:()=>m(h.value)}),e.jsx(Vs,{className:"text-sm",children:h.label})]},h.id))})]})]})}function tc(s,n){return s==="pivotBy"&&(n==="table"||n==="pivotTable")}const sc=[];function nc({field:s,zone:n,index:r,sortDirection:o,onSortDirectionChange:i,hasPivotColumns:d=!1,cardType:c}){var Us,Gs,Hs,Qs,Js,Ws,Xs,Zs,en,tn,sn,nn,an,rn,on,ln,cn,dn,un,mn,xn,hn,pn,fn,gn,bn,jn,vn,yn,Cn,Nn,Sn,wn;const l=t.useEditorStore(G=>G.card),u=t.useEditorStore(G=>G.frame),x=t.useDashboardStore(G=>G.isVisualEditing),m=t.useDashboardStore(G=>G.selectedSheetId),b=t.useDashboardStore(G=>G.actions.updateSheetCalculatedFields),h=t.useDashboardStore(G=>G.actions.updateDashboardCalculatedFields),j=t.useDashboardStore(G=>{var Ie;return G.visualEditPendingDashboardCalculatedFields??((Ie=G.dashboard)==null?void 0:Ie.calculatedFields)})??sc,{scopedFields:N,valuePickFilterableFields:f,isLoading:g,hasError:k}=a.useFilterableFields(),{userContext:D}=a.useCurrentUserInfo(),{tokenProps:w}=a.useSemaphorContext(),S=a.canEditLocalCalculatedFields(D),L=a.useTimezone()??void 0,A=a.useResolvedTemporalStylePreferences()??$t.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES,{updateLabel:F,handleAggregationChange:I,handleDetailDateFormatChange:y,handleDimensionFormatChange:E,handleTemporalBucketFormatChange:M,handleGranularityChange:T,handleAliasTemplateChange:R,handlePivotMemberOrderChange:C,handleValueAliasesChange:V,handleMetricFormatChange:P,removeField:O,handleMetricComparisonChange:B,handleMetricComparisonSpecChange:_,handleMetricComparisonPolarityChange:z,handleMetricWindowTransformChange:q,handleMetricWindowOrderByChange:Y,handleMetricWindowDirectionChange:$,handleMetricWindowPartitionToggle:Q,handleMetricMovingAverageWindowSizeChange:U,handleMetricMovingAverageMinPeriodsChange:J,handleMetricPreviousPeriodDeltaModeChange:X,handleMetricPercentOfTotalScopeChange:ee,handleMetricPercentOfTotalOutputChange:me,handleMetricTargetValueChange:be}=a.useFieldManagement(l),[ve,je]=v.useState(!1),[Re,Pe]=v.useState(()=>{var G;return!!((G=s.parameters)!=null&&G.windowTransform)}),[Me,Ee]=v.useState(!1),[Be,_e]=v.useState(!1),[Oe,Ae]=v.useState(null),De=v.useMemo(()=>{const G=de=>de!=null&&de.startsWith("card-source-")?de.replace("card-source-",""):de,Ie=G(s.id),W=N.find(de=>{if(s.qualifiedFieldName&&de.qualifiedFieldName&&de.qualifiedFieldName===s.qualifiedFieldName||s.qualifiedEntityName&&de.qualifiedEntityName&&de.qualifiedEntityName===s.qualifiedEntityName&&de.name===s.name)return!0;const Ne=G(de.id);return!!(Ie&&Ne&&Ie===Ne)});return{dataType:(W==null?void 0:W.dataType)||s.dataType,resolvedFromScopedField:!!W}},[s.dataType,s.id,s.name,s.qualifiedEntityName,s.qualifiedFieldName,N]),ae=a.getGranularityOptionsForFieldType(De.dataType),K=v.useMemo(()=>t.readTemporalBucketAuthoringState({fieldId:s.id,dataType:s.dataType,granularity:s.granularity,format:s.format,dateFormat:s.dateFormat,customFormat:s.customFormat,semanticTemporalPresentation:s.semanticTemporalPresentation}),[s.customFormat,s.dataType,s.dateFormat,s.format,s.id,s.granularity,s.semanticTemporalPresentation]),ie=n==="groupBy"?K.ok&&ae.includes(K.granularity)?K.granularity:void 0:ae.includes(s.granularity)?s.granularity:"day",Se=K.ok?K.selection:{value:"auto",customPattern:"",format:Ze.AUTOMATIC_TEMPORAL_BUCKET_FORMAT},[re,pe]=v.useState(n==="groupBy"?Se.value:s.dateFormat||"YYYY-MM-DD"),[Ye,Z]=v.useState(n==="groupBy"?Se.customPattern:s.customFormat||""),Fe=re==="custom",[xe,ze]=v.useState(s.aliasTemplate||""),[Le,$e]=v.useState(s.valueAliases||{}),[we,oe]=v.useState((Us=s.parameters)==null?void 0:Us.filters),te=G=>{var W;if(n==="groupBy"&&!ie)return;const Ie=ie??"day";if(G==="custom"){const de=n==="groupBy"?Ze.getTemporalBucketAuthoringOptions(Ie,Se.format,A).find(Ue=>Ue.value==="custom"):void 0,Ne=n==="groupBy"?Ye||(((W=de==null?void 0:de.format)==null?void 0:W.presentation.mode)==="pattern"?de.format.presentation.pattern:""):Ye;pe(G),Z(Ne),n==="groupBy"&&M(r,Ze.resolveTemporalBucketAuthoringFormat(Ie,G,Ne))}else pe(G),n==="groupBy"?M(r,Ze.resolveTemporalBucketAuthoringFormat(Ie,G)):n==="detailColumns"&&y(r,G,"")},ue=G=>{if(n==="groupBy"&&!ie)return;const Ie=ie??"day";Z(G),n==="groupBy"?M(r,Ze.resolveTemporalBucketAuthoringFormat(Ie,"custom",G)):n==="detailColumns"&&y(r,"custom",G)},Ce=G=>{if(n==="groupBy"){const Ie=Ze.reconcileTemporalBucketAuthoringFormat(Se.format,G),W=t.readTemporalBucketAuthoringSelection({fieldId:s.id,dataType:s.dataType,granularity:G,format:Ie,semanticTemporalPresentation:s.semanticTemporalPresentation});pe(W.value),Z(W.customPattern),T(r,G)}},fe=G=>{ze(G),n==="metrics"&&R(r,G)},He=G=>{n==="pivotBy"&&C(r,G)},ke=G=>{$e(G),n==="metrics"&&V(r,G)},bt=G=>{F(n,r,G)},ut=a.getExpressionFieldKind(s);a.getFieldExpressionAnnotation(s);const Ut=a.isManagedCalculatedExpressionField(s),ot=s.role==="metric"&&Ut,Dt=Ut&&(ut==="user_calculated"||ut==="inline_expression"&&s.fieldScope!=="domain"),tt=Dt?t.resolveLocalCalculatedFieldScope({field:s,sheetFields:(u==null?void 0:u.calculatedFields)||[],dashboardFields:j}):void 0,jt=Dt&&(tt==null?void 0:tt.scope)==="sheet",Gt=Dt&&(tt==null?void 0:tt.scope)==="dashboard",ct=ut==="domain_calculated"||s.fieldScope==="domain",Ht=ct?a.resolveDomainCalculatedFieldForEdit(s,N):void 0,mt=ct?"domain":jt?"sheet":Gt?"dashboard":"card",vt=ct?Ht||s:(jt||Gt)&&(tt!=null&&tt.matchedField)?tt.matchedField:s,Ot=ct?Ht?"effective":g?"loading":k?"unavailable":"unverified":void 0,kt=G=>{var Ie;if(oe(G),n==="metrics"){const W={...s,parameters:{...s.parameters,filters:G}},de=[...((Ie=l.config)==null?void 0:Ie.metricColumns)||[]];de[r]=W,t.useEditorStore.getState().actions.updateCardConfig(l.id,{metricColumns:de})}Ee(!1)},Bt=()=>{O(n,r)},yt=t.getDataType(De.dataType||s.dataType),xt=yt==="date",Qt=c==="kpi",Mt=n==="detailColumns",Jt=(Gs=l.config)==null?void 0:Gs.metricColumns,dt=(Hs=l.config)==null?void 0:Hs.groupByColumns,Ct=a.useCardQueryContext(l),At=t.useDashboardStore(G=>G.semanticExecutionPayload),Vt=n==="groupBy"&&ie?Ze.getTemporalBucketAuthoringOptions(ie,Se.format,A):n==="detailColumns"?$i(ie??"day"):[],is=Fe?"custom":!ie&&n==="groupBy"?void 0:Vt.some(G=>G.value===re)?re:((Qs=Vt[0])==null?void 0:Qs.value)??"YYYY-MM-DD",Wt=!!c&&t.COMPARISON_SUPPORTED_CHART_TYPES.includes(c),cs=!!c&&t.COMPARISON_TARGET_SUPPORTED_CHART_TYPES.includes(c),Nt=v.useMemo(()=>dt==null?void 0:dt.find(G=>t.getDataType(G.dataType||"")==="date"),[dt]),lt=v.useMemo(()=>t.resolveCardPrimaryDateField({card:l,cardConfig:l.config||{},semanticExecutionPayload:At}),[l,At]),Qe=v.useMemo(()=>Nt||(lt?{...lt,id:`semantic-primary:${lt.entityId}:${lt.name}`,label:lt.name,role:"groupby",granularity:lt.defaultGranularity||"day"}:void 0),[Nt,lt]),H=ye.getAuthoredCardFilters(l),ne=v.useMemo(()=>{if(!Qe)return!1;const G=H;if(!G)return!1;const Ie=de=>{const Ne=de.field;return Ne?Qe.id&&Ne.id===Qe.id||Qe.qualifiedFieldName&&Ne.qualifiedFieldName===Qe.qualifiedFieldName?!0:Ne.name===Qe.name:!1},W=de=>de.conditions.some(Ue=>t.getDataType(Ue.field.dataType||"")==="date"&&Ie(Ue))?!0:de.groups.some(Ue=>W(Ue));return W(G)},[H,Qe]),se=v.useMemo(()=>zi(l,a.compileDashboardCardFilters({card:l,cardConfig:Ct.queryRelevantConfig,input:Ct.filterCompilationInput,resolvedFields:Ct.resolvedDateFields,semanticExecutionPayload:At,timezone:L})),[l,Ct,At,L]),Te=ne||se,ce=s,ge=((Js=ce.comparison)==null?void 0:Js.mode)==="explicit"?ce.comparison.spec:void 0,Ke=((Xs=(Ws=ce.parameters)==null?void 0:Ws.windowTransform)==null?void 0:Xs.function)||"none",Ve=a.isMetricTransformEnabled(ce),Ge=Ve?Ke:null,ht=a.supportsMetricTransformForMetric({cardType:c||"table",cardConfig:l.config||{},metric:ce,transformMode:Ge||"running_total"}),it=((Zs=ce.comparison)==null?void 0:Zs.mode)==="explicit",Je=a.getRunningTotalOrderByCandidates(dt||[]),nt=((sn=(tn=(en=ce.parameters)==null?void 0:en.windowTransform)==null?void 0:tn.orderBy)==null?void 0:sn.fieldId)||"",ds=((rn=(an=(nn=ce.parameters)==null?void 0:nn.windowTransform)==null?void 0:an.orderBy)==null?void 0:rn.direction)||"asc",Xt=Je.find(G=>G.id===nt),us=Ge==="running_total"||Ge==="moving_average"||Ge==="previous_period_delta",Ya=Ve&&us&&!!Xt&&t.getDataType(Xt.dataType||"")!=="date",za=a.getDefaultRunningTotalPartitionByFieldIds({cardType:c||"table",cardConfig:l.config||{},orderByFieldId:nt||void 0}),qa=new Set(((ln=(on=ce.parameters)==null?void 0:on.windowTransform)==null?void 0:ln.partitionByFieldIds)||za),$a=c==="pivotTable"||a.isSubtotalEnabledAggregateTable(c||"table",l.config||{}),zs=[...(dt||[]).filter(G=>G.id&&(!us||G.id!==nt)),...$a?(((cn=l.config)==null?void 0:cn.pivotByColumns)||[]).filter(G=>G.id):[]],qs=((mn=(un=(dn=ce.parameters)==null?void 0:dn.windowTransform)==null?void 0:un.movingAverage)==null?void 0:mn.windowSize)||7,Ka=((pn=(hn=(xn=ce.parameters)==null?void 0:xn.windowTransform)==null?void 0:hn.movingAverage)==null?void 0:pn.minPeriods)||1,Ua=((bn=(gn=(fn=ce.parameters)==null?void 0:fn.windowTransform)==null?void 0:gn.previousPeriodDelta)==null?void 0:bn.mode)||"absolute",$s=((yn=(vn=(jn=ce.parameters)==null?void 0:jn.windowTransform)==null?void 0:vn.percentOfTotal)==null?void 0:yn.scope)||"grand_total",Ga=((Sn=(Nn=(Cn=ce.parameters)==null?void 0:Cn.windowTransform)==null?void 0:Nn.percentOfTotal)==null?void 0:Sn.output)||"percent",Ha=v.useMemo(()=>(Jt||[]).some(()=>!1),[Jt]);v.useEffect(()=>{Ve&&Pe(!0)},[Ve]);const Qa=n!=="pivotBy"&&n!=="sortBy",Ja=tc(n,c),Wa=s.memberOrder??"auto",Xa=xt&&n==="groupBy"&&(!Qt||Ha),Za=!Qt&&xt&&(n==="groupBy"||Mt),er=n==="metrics",tr=!Qt&&yt==="number"&&(n==="groupBy"||Mt)&&a.isTableNumericPresentationCardType(c),Zt=Wt&&!l.sql&&!l.python&&n==="metrics",sr=()=>{const G=s,Ie=n==="metrics"&&ot;return e.jsxs("div",{className:"space-y-1",children:[!Ie&&e.jsx("div",{title:`${s.entityName}.${s.name}`,onPointerDown:W=>{W.stopPropagation()},className:"max-w-[270px] cursor-default overflow-hidden text-ellipsis whitespace-nowrap px-0.5 text-xs text-muted-foreground/80",children:`${s.entityName}.${s.name}`}),Ie&&G.calculatedFormula&&e.jsxs("div",{title:a.formatDisplayFormula(G.calculatedFormula),onPointerDown:W=>{W.stopPropagation()},className:"max-w-[270px] cursor-default overflow-hidden text-ellipsis whitespace-nowrap rounded bg-muted/50 px-1.5 py-0.5 font-mono text-xs text-primary",children:["= ",a.formatDisplayFormula(G.calculatedFormula)]})]})},nr=()=>Qa?e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Label"}),e.jsx(rt,{value:s.label??"",onSave:bt,placeholder:"Display label...",type:"text"})]}):null,ar=()=>n!=="sortBy"?null:e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Order"}),e.jsxs(t.Select,{value:o||"asc",onValueChange:G=>i(G),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"text-xs",value:"asc",children:"Ascending"}),e.jsx(t.SelectItem,{className:"text-xs",value:"desc",children:"Descending"})]})]})]}),rr=()=>Ja?e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Pivot column order"}),e.jsxs(t.Select,{value:Wa,onValueChange:G=>He(G),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"text-xs",value:"auto",children:"Auto"}),e.jsx(t.SelectItem,{className:"text-xs",value:"asc",children:"Ascending"}),e.jsx(t.SelectItem,{className:"text-xs",value:"desc",children:"Descending"})]})]})]}):null,Ks=()=>Xa?e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Granularity"}),e.jsxs(t.Select,{value:ie,onValueChange:Ce,children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select granularity..."})}),e.jsx(t.SelectContent,{children:ae.map(G=>e.jsx(t.SelectItem,{className:"text-xs",value:G,children:t.toTitleCase(G)},G))})]})]}):null,or=()=>Za?e.jsxs(e.Fragment,{children:[Ks(),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Date Format"}),e.jsxs(t.Select,{value:is,onValueChange:te,disabled:n==="groupBy"&&!ie,children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select date format..."})}),e.jsx(t.SelectContent,{children:Vt.map(G=>e.jsx(t.SelectItem,{className:"text-xs",value:G.value,children:G.label},G.value))})]}),Fe&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx(t.Input,{placeholder:"Enter custom format (e.g., YYYY-MM-DD HH:mm)",value:Ye,onChange:G=>{G.stopPropagation(),ue(G.target.value)},onClick:G=>G.stopPropagation(),className:"h-8 text-xs"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Examples: YYYY-MM-DD, MM/DD/YY, DD-MMM-YYYY HH:mm"})]})]})]}):null,lr=()=>tr?e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Number Format"}),e.jsx(Es,{value:s.format,onChange:G=>E(Mt?"detailColumns":"groupBy",r,G),cardType:c,showTitle:!1})]}):null,ir=()=>{var Ie;if(!er)return null;const G=ot;return e.jsxs(e.Fragment,{children:[G&&S&&!ct&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Formula"}),e.jsxs(t.Button,{variant:"outline",size:"sm",className:"h-8 w-full justify-start text-xs",onClick:()=>_e(!0),children:[e.jsx(a.Pencil,{className:"mr-2 h-3 w-3"}),"Edit Formula"]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Aggregation"}),e.jsxs(t.Select,{value:s.aggregate,onValueChange:W=>{I(r,W)},disabled:G,children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select function..."})}),e.jsx(t.SelectContent,{children:Ze.getFieldAggregationOptions(s.dataType).map(W=>e.jsx(t.SelectItem,{className:"text-xs",value:W.value,children:W.label},W.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Number Format"}),e.jsx(Es,{value:ce.format,onChange:W=>P(r,W),cardType:c,showTitle:!1})]}),e.jsx(a.Collapsible,{open:Re,onOpenChange:Pe,children:e.jsxs("div",{className:"space-y-2 rounded-md border border-border/60 bg-muted/20 p-2.5",children:[e.jsx(a.CollapsibleTrigger,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between rounded-sm px-0.5 py-0.5 text-left",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Metric Transform"}),e.jsxs("div",{className:"flex items-center text-[11px] text-muted-foreground",children:[!Re&&e.jsx("span",{className:"mr-2",children:Ve?t.toTitleCase(Ke.replace(/_/g," ")):"None"}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 transition-transform",Re?"rotate-180":"")})]})]})}),e.jsxs(a.CollapsibleContent,{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Transform"}),e.jsxs(t.Select,{value:Ve?Ke:"none",onValueChange:W=>q(r,W),disabled:!ht.supported&&!Ve,children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select transform..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"none",children:"None"}),e.jsx(t.SelectItem,{value:"running_total",disabled:it,children:"Running Total"}),e.jsx(t.SelectItem,{value:"moving_average",disabled:it,children:"Moving Average"}),e.jsx(t.SelectItem,{value:"previous_period_delta",disabled:it,children:"Previous Period Delta"}),e.jsx(t.SelectItem,{value:"percent_of_total",disabled:it,children:"Percent of Total"})]})]}),!ht.supported&&!Ve&&e.jsx("div",{className:"text-xs text-muted-foreground",children:ht.reason}),it&&!Ve&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Disable comparison to enable metric transforms."})]}),Ve&&e.jsxs(e.Fragment,{children:[us&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Order By"}),e.jsxs(t.Select,{value:nt,onValueChange:W=>Y(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select order field..."})}),e.jsx(t.SelectContent,{children:Je.filter(W=>!!W.id).map(W=>e.jsx(t.SelectItem,{value:W.id,className:"text-xs",children:W.label||W.name},W.id))})]}),!nt&&e.jsx("div",{className:"text-xs text-amber-700",children:"No date trend detected. Select an order field."}),Ya&&e.jsx("div",{className:"text-xs text-amber-700",children:"No date trend detected. The transform will follow the selected order field."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Direction"}),e.jsxs(t.Select,{value:ds,onValueChange:W=>$(r,W),disabled:!nt,children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select direction..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{className:"text-xs",value:"asc",children:"Ascending"}),e.jsx(t.SelectItem,{className:"text-xs",value:"desc",children:"Descending"})]})]})]})]}),Ge==="moving_average"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Window Size"}),e.jsx(t.Input,{type:"number",min:1,className:"h-8 text-xs",value:qs,onChange:W=>U(r,Number(W.target.value))}),e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Min Periods"}),e.jsx(t.Input,{type:"number",min:1,max:qs,className:"h-8 text-xs",value:Ka,onChange:W=>J(r,Number(W.target.value))})]}),Ge==="previous_period_delta"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Output"}),e.jsxs(t.Select,{value:Ua,onValueChange:W=>X(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select output..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"absolute",children:"Absolute Delta"}),e.jsx(t.SelectItem,{value:"percent",children:"Percent Delta"})]})]})]}),Ge==="percent_of_total"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Scope"}),e.jsxs(t.Select,{value:$s,onValueChange:W=>ee(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select scope..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"grand_total",children:"Grand Total"}),e.jsx(t.SelectItem,{value:"partition_total",children:"Partition Total"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Output"}),e.jsxs(t.Select,{value:Ga,onValueChange:W=>me(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select output..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"percent",children:"Percent"}),e.jsx(t.SelectItem,{value:"fraction",children:"Fraction"})]})]})]})]}),(Ge==="running_total"||Ge==="moving_average"||Ge==="previous_period_delta"||Ge==="percent_of_total"&&$s==="partition_total")&&zs.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Reset By"}),e.jsx("div",{className:"space-y-1",children:zs.map(W=>{const de=!!W.id&&qa.has(W.id);return e.jsxs("button",{type:"button",onClick:()=>W.id&&Q(r,W.id),className:t.cn("flex h-7 w-full items-center justify-between rounded border px-2 text-xs",de?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground"),children:[e.jsx("span",{children:W.label||W.name}),de?e.jsx(t.Check,{className:"h-3 w-3"}):null]},W.id)})})]})]})]})]})}),Zt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Comparison Type"}),e.jsxs(t.Select,{value:ce.comparison?ce.comparison.mode==="off"?"off":ce.comparison.spec.kind:"inherit",disabled:Ve,onValueChange:W=>B(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{placeholder:"Select comparison type..."})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"inherit",children:"Inherit dashboard comparison (default)"}),e.jsx(t.SelectItem,{value:"off",children:"Off"}),(()=>{const W=!Qe||!Te,de=Qe?Te?void 0:"Add a date filter to enable":"Configure a semantic primary date or add a date axis",Ne=(Ue,Xe)=>e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx(t.SelectItem,{value:Ue,disabled:W,title:de,children:Xe})}),W&&de&&e.jsx(t.TooltipContent,{side:"right",children:de})]})});return e.jsxs(e.Fragment,{children:[Ne("previous_period","Previous Period"),Ne("previous_year","Previous Year")]})})(),cs&&e.jsx(t.SelectItem,{value:"target",children:"Target"})]})]}),!ce.comparison&&e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Dashboard comparison is not available yet. This metric will follow it when a viewer sets it."})]}),Zt&&ge&&(ge.kind==="previous_period"||ge.kind==="previous_year")&&e.jsxs("div",{className:"space-y-2 rounded border border-border/60 p-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:ge.kind==="previous_year"?"Years back":"Periods back"}),e.jsx(t.Input,{type:"number",min:1,step:1,value:ge.kind==="previous_year"?ge.offsetYears||1:ge.offsetPeriods||1,onChange:W=>{const de=Number(W.target.value);!Number.isSafeInteger(de)||de<=0||(ge.kind==="previous_year"?_(r,{...ge,offsetYears:de===1?void 0:de}):_(r,{...ge,offsetPeriods:de===1?void 0:de}))},className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Alignment"}),e.jsxs(t.Select,{value:ge.alignment||"calendar",onValueChange:W=>_(r,{...ge,alignment:W==="calendar"?void 0:W}),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"calendar",children:"Calendar"}),e.jsx(t.SelectItem,{value:"weekday",children:"Match weekdays"})]})]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"To date"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Match the elapsed portion of an incomplete current window."})]}),e.jsx(t.Switch,{size:"xs",checked:ge.toDate===!0,onCheckedChange:W=>_(r,{...ge,toDate:W?!0:void 0})})]}),e.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:["Anchored to"," ",e.jsx("span",{className:"text-foreground",children:(Qe==null?void 0:Qe.label)||(Qe==null?void 0:Qe.name)}),". The resolved comparison dates appear after the card runs."]})]}),Zt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Favorable direction"}),e.jsxs(t.Select,{value:t.getMetricComparisonPolarity(ce),disabled:!!ce.semanticComparisonPolarity,onValueChange:W=>z(r,W),children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full text-xs",children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"higher_is_better",children:"Higher is better"}),e.jsx(t.SelectItem,{value:"lower_is_better",children:"Lower is better"}),e.jsx(t.SelectItem,{value:"neutral",children:"Neutral"})]})]}),ce.semanticComparisonPolarity&&e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Governed by this metric's semantic definition."})]}),Zt&&((Ie=ce.comparison)==null?void 0:Ie.mode)==="explicit"&&ce.comparison.spec.kind==="target"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Target Value"}),e.jsx(t.Input,{type:"number",value:ce.comparison.spec.targetValue!==void 0&&ce.comparison.spec.targetValue!==null?String(ce.comparison.spec.targetValue):"",onChange:W=>{const de=W.target.value;if(de===""){be(r,void 0);return}const Ne=Number(de);be(r,Number.isFinite(Ne)?Ne:void 0)},className:"h-8 text-xs",placeholder:"Enter target value..."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{className:"text-xs font-medium text-muted-foreground",children:"Attribute Filters"}),(we==null?void 0:we.conditions)&&we.conditions.length>0&&e.jsx("div",{className:"mb-2 space-y-1",children:we.conditions.map(W=>e.jsxs("div",{className:"flex cursor-pointer items-center gap-2 rounded bg-muted/50 p-2 text-xs transition-colors hover:bg-muted/70",onClick:()=>{Ae(W),Ee(!0)},children:[e.jsxs("span",{className:"font-medium",children:[W.field.label,":"]}),e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:"cursor-help text-muted-foreground",children:Array.isArray(W.value)?W.value.length===1?String(W.value[0]):W.value.length<=2?W.value.join(", "):`${W.value.slice(0,2).join(", ")} +${W.value.length-2}`:String(W.value)})}),Array.isArray(W.value)&&W.value.length>1&&e.jsx(t.TooltipContent,{side:"top",className:"max-w-[300px]",children:e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"mb-1 font-medium",children:["Selected values (",W.value.length,"):"]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:W.value.map((de,Ne)=>e.jsx("div",{children:String(de)},Ne))})]})})]})}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"ml-auto h-4 w-4 p-0",onClick:de=>{var Ue;de.stopPropagation();const Ne=we.conditions.filter(Xe=>Xe.id!==W.id);if(Ne.length>0){const Xe={...we,conditions:Ne};kt(Xe)}else if(oe(void 0),n==="metrics"){const Xe={...s,parameters:{...s.parameters,filters:void 0}},at=[...((Ue=l.config)==null?void 0:Ue.metricColumns)||[]];at[r]=Xe,t.useEditorStore.getState().actions.updateCardConfig(l.id,{metricColumns:at})}},children:e.jsx(le.X,{className:"h-3 w-3"})})]},W.id))}),e.jsxs(t.Button,{variant:"outline",size:"sm",className:"h-8 w-full justify-start text-xs",onClick:()=>{Ae(null),Ee(!0)},children:[e.jsx(a.Filter,{className:"mr-2 h-3 w-3"}),"Add attribute filter"]})]}),e.jsx(Wi,{column:s}),d&&e.jsxs(e.Fragment,{children:[e.jsx(Ki,{aliasTemplate:xe,onAliasTemplateChange:fe}),e.jsx(Ui,{valueAliases:Le,onValueAliasesChange:ke})]})]})};we!=null&&we.conditions&&we.conditions.length>0;const cr=n!=="sortBy";return e.jsxs(e.Fragment,{children:[e.jsx(Fa,{id:s.id,label:a.getMetricDisplayLabel(s),dataType:yt,calculated:a.getCalculatedGlyphKind(s),open:ve,onOpenChange:je,onRemove:Bt,sortDirection:o,onSortDirectionChange:n==="sortBy"?i:void 0,badge:e.jsx(e.Fragment,{children:n==="metrics"&&((wn=we==null?void 0:we.conditions)==null?void 0:wn.length)&&!ve&&e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 items-center gap-1 rounded-[3px] bg-primary/10 px-1 text-[10px] tabular-nums text-primary/90",children:[e.jsx(a.Filter,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:we.conditions.length})]})}),e.jsx(t.TooltipContent,{side:"top",children:e.jsx("div",{className:"text-xs",children:we.conditions.map(G=>e.jsxs("div",{children:[G.field.label,":"," ",Array.isArray(G.value)?`${G.value.length} values`:String(G.value)]},G.id))})})]})})}),children:cr&&e.jsxs(e.Fragment,{children:[sr(),ar(),rr(),nr(),c==="kpi"&&Ks(),or(),lr(),ir()]})}),Me&&e.jsx(Ra,{open:Me,onOpenChange:G=>{Ee(G),G||Ae(null)},availableFields:f,existingFilters:we,editingCondition:Oe,onSave:G=>{var Ie;if(G)kt(G);else if(oe(void 0),n==="metrics"){const W={...s,parameters:{...s.parameters,filters:void 0}},de=[...((Ie=l.config)==null?void 0:Ie.metricColumns)||[]];de[r]=W,t.useEditorStore.getState().actions.updateCardConfig(l.id,{metricColumns:de})}Ae(null)}}),Be&&n==="metrics"&&ot&&e.jsx(a.CalculatedFieldEditor,{open:Be,onOpenChange:_e,availableFields:N,existingField:vt,existingFieldScope:mt,domainDefinitionStatus:Ot,initialFieldType:"metric",allowedFieldTypes:["metric"],onSave:G=>{if(G.role!=="metric")return;const{card:Ie,frame:W,actions:de}=t.useEditorStore.getState(),Ne=mt==="dashboard"?j:W.calculatedFields||[],{cardConfigPatch:Ue,nextStoredFields:Xe,nextSharedFields:at}=a.saveCalculatedFieldToCardScope({cardConfig:Ie.config,storedFields:Ie.calculatedFields||[],sharedFields:Ne,updatedField:G,editingField:vt,previousScope:mt});Object.keys(Ue).length&&de.updateCardConfig(l.id,Ue),de.updateCard(l.id,{calculatedFields:Xe}),mt==="dashboard"&&at!==Ne?h(at):at!==Ne&&a.commitSharedCalculatedFields({nextSharedFields:at,currentSharedFields:Ne,isVisualEditing:x,selectedSheetId:m,updateFrame:de.updateFrame,updateSheetCalculatedFields:b})},onSaveToSheet:G=>{if(G.role!=="metric")return;const{card:Ie,frame:W,actions:de}=t.useEditorStore.getState(),Ne=s,Ue=W.calculatedFields||[],{cardConfigPatch:Xe,nextStoredFields:at,nextSheetFields:ms,nextDashboardFields:St}=a.saveCalculatedFieldToSheetScope({cardConfig:Ie.config,storedFields:Ie.calculatedFields||[],sheetFields:Ue,dashboardFields:j,updatedField:{...G,id:Ne.id,aliasTemplate:Ne.aliasTemplate,valueAliases:Ne.valueAliases,parameters:Ne.parameters,customFormat:Ne.customFormat},editingField:vt,previousScope:mt});a.commitSharedCalculatedFields({nextSharedFields:ms,currentSharedFields:Ue,isVisualEditing:x,selectedSheetId:m,updateFrame:de.updateFrame,updateSheetCalculatedFields:b}),St&&St!==j&&h(St),Object.keys(Xe).length&&de.updateCardConfig(l.id,Xe),de.updateCard(l.id,{calculatedFields:at})},onSaveToDashboard:G=>{if(G.role!=="metric")return;const{card:Ie,frame:W,actions:de}=t.useEditorStore.getState(),Ne=s,Ue=W.calculatedFields||[],{cardConfigPatch:Xe,nextStoredFields:at,nextSharedFields:ms,nextSheetFields:St}=a.saveCalculatedFieldToSharedScope({cardConfig:Ie.config,storedFields:Ie.calculatedFields||[],sharedFields:j,sheetFields:Ue,updatedField:{...G,id:Ne.id,aliasTemplate:Ne.aliasTemplate,valueAliases:Ne.valueAliases,parameters:Ne.parameters,customFormat:Ne.customFormat},editingField:vt,previousScope:mt});h(ms),St&&St!==Ue&&a.commitSharedCalculatedFields({nextSharedFields:St,currentSharedFields:Ue,isVisualEditing:x,selectedSheetId:m,updateFrame:de.updateFrame,updateSheetCalculatedFields:b}),Object.keys(Xe).length&&de.updateCardConfig(l.id,Xe),de.updateCard(l.id,{calculatedFields:at})},cardId:l.id})]})}function ac({field:s,onRemove:n}){const[r,o]=v.useState(!1);return e.jsx(Fa,{id:s.id,label:a.getMetricDisplayLabel(s),dataType:s.dataType,calculated:a.getCalculatedGlyphKind(s),open:r,onOpenChange:o,onRemove:n,children:e.jsx(Is,{fieldId:s.id})})}function rc({concept:s}){const{title:n,description:r}=oc[s];return e.jsxs(a.HoverCard,{openDelay:150,closeDelay:50,children:[e.jsx(a.HoverCardTrigger,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`What does ${n} mean?`,className:"inline-flex h-3 w-3 shrink-0 items-center justify-center text-muted-foreground/70 transition-colors hover:text-foreground",children:e.jsx(a.CircleHelp,{className:"h-3 w-3"})})}),e.jsxs(a.HoverCardContent,{side:"right",align:"start",sideOffset:8,className:"w-[260px] space-y-2 rounded-control border border-border bg-popover p-3 shadow-[0_4px_16px_rgba(0,0,0,0.08)]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[12px] font-semibold text-foreground",children:n}),e.jsx("p",{className:"text-[11px] leading-[1.45] text-muted-foreground",children:r})]}),s!=="detailColumns"&&e.jsx(lc,{highlight:s})]})]})}const oc={groupBy:{title:"Rows",description:"Each unique value becomes a row. Use for the dimensions you want stacked vertically."},pivotBy:{title:"Pivot Columns",description:"Each unique value spreads across as a column, splitting your metrics horizontally."},metrics:{title:"Metrics",description:"The aggregated numbers (sum, count, avg…) that fill the cells of your chart or table."},detailColumns:{title:"Columns",description:"Raw column values with no aggregation — the underlying detail rows from the database."}};function lc({highlight:s}){const n=s==="pivotBy",r=s==="groupBy",o=s==="metrics",i="bg-foreground/[0.06] font-medium text-foreground dark:bg-foreground/[0.12]";return e.jsx("div",{className:"overflow-hidden rounded-control border border-border",children:e.jsxs("table",{className:"w-full text-[10px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-muted/40",children:[e.jsx("th",{className:"px-1.5 py-1 text-left font-normal text-muted-foreground"}),["North","South","East"].map(d=>e.jsx("th",{className:t.cn("px-1.5 py-1 text-center font-normal text-muted-foreground",n&&i),children:d},d))]})}),e.jsx("tbody",{children:Zn.map((d,c)=>e.jsxs("tr",{className:t.cn(c!==Zn.length-1&&"border-b border-border/60"),children:[e.jsx("td",{className:t.cn("px-1.5 py-1 text-left text-muted-foreground",r&&i),children:d.label}),d.values.map((l,u)=>e.jsx("td",{className:t.cn("px-1.5 py-1 text-right font-mono tabular-nums text-muted-foreground",o&&i),children:l},u))]},d.label))})]})})}const Zn=[{label:"Electronics",values:["2,300","1,800","3,400"]},{label:"Clothing",values:["1,300","620","480"]}],ic={groupBy:a.Rows3,pivotBy:Ds,metrics:Mr,detailColumns:t.Table2,sortBy:sa};function Yt({onRemoveField:s,zone:n,fields:r,label:o,placeholder:i,shouldShow:d,hasPivotColumns:c=!1,activeField:l=null}){const{isOver:u,setNodeRef:x}=a.useDroppable({id:n}),{updateSortByColumn:m}=t.useEditorActions(),b=t.useEditorStore(k=>k.card),h=t.useEditorStore(k=>k.card.type),p=r.length>0,j=v.useMemo(()=>!l||!u?!0:a.validateFieldForChartType(l,n,h).isValid,[l,u,n,h]),N=(k,D)=>{var S;!((S=b.config)!=null&&S.sortByColumns)||b.config.sortByColumns.findIndex(L=>L.id===k)===-1||m(b.id,k,{direction:D})};if(n==="sortBy"&&d===!1)return null;const f=n!=="sortBy"&&h!=="kpi",g=ic[n]||a.Plus;return e.jsxs("div",{className:"w-full",role:"group","aria-label":o,children:[e.jsx(t.Label,{className:"mb-1 block text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),e.jsx("div",{ref:x,className:t.cn("rounded-control transition-colors",{"border border-foreground/40 bg-muted/50":u&&j,"border border-destructive/40 bg-destructive/5":u&&!j,"border border-dashed border-border/50 bg-background":!u&&!p}),children:r.length===0?e.jsxs("div",{className:"flex h-9 items-center justify-center gap-1.5 text-[11px] text-muted-foreground/80",children:[e.jsx(g,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"}),e.jsx("span",{children:i}),f&&e.jsx(rc,{concept:n})]}):e.jsx(a.SortableContext,{id:n,items:r.map(k=>k.id),strategy:a.verticalListSortingStrategy,children:e.jsx("div",{className:"space-y-1",children:r.map((k,D)=>{const S=k.direction;return h==="matrixTable"?e.jsx(ac,{field:k,onRemove:()=>s(n,D)},k.id):e.jsx(nc,{field:k,zone:n,index:D,sortDirection:S,onSortDirectionChange:L=>N(k.id,L),hasPivotColumns:c,cardType:h},k.id)})})})})]})}const cc=[];function dc({onRemoveField:s,onResetFields:n,groupByFields:r,pivotByFields:o,metricsFields:i,sortByFields:d,detailFields:c,activeField:l}){var Q,U,J;const[u,x]=v.useState(!1);t.useEditorStore(X=>{var ee;return!!((ee=X.card.customCardPreferences)!=null&&ee.url)});const m=t.useEditorStore(X=>X.card),b=t.useEditorStore(X=>X.frame),h=he.findCustomVisualConfigCard(b,m),{manifest:p}=a.useCustomVisual(((Q=h==null?void 0:h.customCardPreferences)==null?void 0:Q.url)||""),j=(U=p==null?void 0:p.visuals)==null?void 0:U.find(X=>{var ee;return X.name===((ee=h==null?void 0:h.customCardPreferences)==null?void 0:ee.componentName)}),N=he.resolveMultiInputType(h,j)==="multiple";N&&((J=h==null?void 0:h.customCardPreferences)!=null&&J.url);const f=he.getConfigSlotExpectedType(j==null?void 0:j.slots);t.useEditorStore(X=>X.actions.updateCardConfig);const g=t.useEditorStore(X=>X.actions.updateCard),k=t.useEditorStore(X=>X.actions.updateFrame),D=t.useDashboardStore(X=>X.isVisualEditing),w=t.useDashboardStore(X=>X.selectedSheetId),S=t.useDashboardStore(X=>X.actions.updateSheetCalculatedFields),L=t.useDashboardStore(X=>X.actions.updateDashboardCalculatedFields),F=t.useDashboardStore(X=>{var ee;return X.visualEditPendingDashboardCalculatedFields??((ee=X.dashboard)==null?void 0:ee.calculatedFields)})??cc,{scopedFields:I}=a.useScopedFields(),{userContext:y}=a.useCurrentUserInfo(),E=N&&(h==null?void 0:h.id)===m.id&&f?f:m==null?void 0:m.type,M=E==="detailTable",T=r.length>0||i.length>0||c.length>0,R=!M&&(E!=="kpi"||i.length<=2),C=!M,V=!M&&E!=="kpi",P=E!=="kpi"&&E!=="matrixTable"&&T,O=M,B="Drop sort fields here",_=a.canEditLocalCalculatedFields(y),z=["pie","doughnut","polar","funnel","aggregateTable","bubble","scatter"].includes(E),q=V&&!z,Y=()=>E==="kpi"?{label:"Trend By",placeholder:"Drop trend field here"}:{label:"Rows",placeholder:"Drop dimensions here"},$=()=>E==="kpi"?{label:"Metric",placeholder:"Drop metric here"}:{label:"Metrics",placeholder:"Drop metrics here"};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between bg-background px-4 py-2",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:"Fields"}),T&&e.jsx("button",{type:"button","aria-label":"Reset all field selections",onClick:n,className:"text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:"Reset"})]}),e.jsxs("div",{className:"space-y-3 px-4 pb-6 pt-3",children:[R&&e.jsx(Yt,{zone:"groupBy",onRemoveField:s,fields:r,label:Y().label,placeholder:Y().placeholder,activeField:l}),q&&e.jsx(Yt,{zone:"pivotBy",onRemoveField:s,fields:o,label:"Pivot Columns",placeholder:"Drop pivot fields here",activeField:l}),C&&e.jsx(Yt,{zone:"metrics",onRemoveField:s,fields:i,label:$().label,placeholder:$().placeholder,hasPivotColumns:o.length>0,activeField:l}),O&&e.jsx(Yt,{zone:"detailColumns",onRemoveField:s,fields:c,label:"Columns",placeholder:"Drop columns here"}),i.length>=1&&_&&e.jsxs(t.Button,{variant:"outline",size:"sm",onClick:()=>x(!0),className:"mt-1.5 w-full justify-start border-border/60 border-dashed bg-background text-xs text-foreground/70 hover:bg-muted/40 hover:text-foreground",children:[e.jsx(a.Calculator,{className:"mr-2 h-4 w-4"}),"Create Metric"]}),P&&e.jsx(Yt,{zone:"sortBy",onRemoveField:s,fields:d,label:"Sort By",placeholder:B,activeField:l})]}),e.jsx(a.CalculatedFieldEditor,{open:u,onOpenChange:x,availableFields:I,initialFieldType:"metric",allowedFieldTypes:["metric"],onSave:X=>{if(X.role!=="metric")return;const{nextStoredFields:ee}=a.saveCalculatedFieldToCardScope({storedFields:m.calculatedFields||[],sharedFields:b.calculatedFields||[],updatedField:X,previousScope:"card"});g(m.id,{calculatedFields:ee})},onSaveToSheet:X=>{if(X.role!=="metric")return;const ee=b.calculatedFields||[],{nextSheetFields:me}=a.saveCalculatedFieldToSheetScope({storedFields:m.calculatedFields||[],sheetFields:ee,updatedField:X,previousScope:"sheet"});a.commitSharedCalculatedFields({nextSharedFields:me,currentSharedFields:ee,isVisualEditing:D,selectedSheetId:w,updateFrame:k,updateSheetCalculatedFields:S})},onSaveToDashboard:X=>{if(X.role!=="metric")return;const{nextSharedFields:ee}=a.saveCalculatedFieldToSharedScope({storedFields:m.calculatedFields||[],sharedFields:F,updatedField:X,previousScope:"dashboard"});L(ee)},cardId:m.id})]})}function uc(){var k,D,w;const s=t.useEditorStore(S=>{var L;return(L=S.card)==null?void 0:L.type}),n=s==="kpi",[r,o]=v.useState(n),[i,d]=v.useState(!1),c=t.useEditorStore(S=>{var L;return!!((L=S.card.customCardPreferences)!=null&&L.url)}),l=t.useEditorStore(S=>S.card),u=t.useEditorStore(S=>S.frame),x=he.findCustomVisualConfigCard(u,l),{manifest:m}=a.useCustomVisual(((k=x==null?void 0:x.customCardPreferences)==null?void 0:k.url)||""),b=(D=m==null?void 0:m.visuals)==null?void 0:D.find(S=>{var L;return S.name===((L=x==null?void 0:x.customCardPreferences)==null?void 0:L.componentName)}),p=he.resolveMultiInputType(x,b)==="multiple"&&!!((w=x==null?void 0:x.customCardPreferences)!=null&&w.url),j=!c||p,N=c||p,f=n?"KPI Settings":"Chart Settings",g=j&&!t.isTableChartType(s);return v.useEffect(()=>{n&&o(!0)},[n]),!g&&!N?null:e.jsxs("div",{className:"shrink-0 border-t border-border bg-background",children:[g&&r&&e.jsx("div",{className:t.cn("overflow-y-auto border-b border-border px-4",n?"max-h-[72vh]":"max-h-[50vh]"),children:e.jsx(a.Accordion,{type:"single",collapsible:!0,className:"w-full divide-y divide-border/60 [&_h3]:sticky [&_h3]:top-0 [&_h3]:z-10 [&_h3]:bg-background",children:e.jsx(La,{mode:"config"})})}),g&&e.jsxs("button",{type:"button",onClick:()=>o(S=>!S),className:"flex w-full items-center justify-between px-4 py-2.5 text-left transition-colors hover:bg-muted/50",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(a.Settings2,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:f})]}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 text-muted-foreground transition-transform",r&&"rotate-180"),strokeWidth:1.75})]}),N&&i&&e.jsx("div",{className:"max-h-[40vh] overflow-y-auto border-b border-t border-border px-4",children:e.jsx(Ta,{})}),N&&e.jsxs("button",{type:"button",onClick:()=>d(S=>!S),className:t.cn("flex w-full items-center justify-between px-4 py-2.5 text-left transition-colors hover:bg-muted/50",g&&"border-t border-border"),children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(na,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-foreground/70",children:"Component settings"})]}),e.jsx(le.ChevronDown,{className:t.cn("h-3 w-3 text-muted-foreground transition-transform",i&&"rotate-180"),strokeWidth:1.75})]})]})}function mc({onEditJoins:s}){const n=t.useEditorStore(u=>u.card),{autoJoinMetadata:r}=a.useEditorCardQuery(n);if(!(r!=null&&r.autoResolved))return null;const{resolvedJoinPlan:o}=r,i=(o==null?void 0:o.joins)||[];if(i.length===0)return null;const d=u=>!u||u.length===0?"No conditions":u.map(x=>{var p,j,N,f;const m=`${(p=x.source)==null?void 0:p.entityName}.${(j=x.source)==null?void 0:j.name}`,b=`${(N=x.target)==null?void 0:N.entityName}.${(f=x.target)==null?void 0:f.name}`,h=x.operator||"=";return`${m} ${h} ${b}`}).join(" AND "),c=u=>!u.joinKeyGroups||u.joinKeyGroups.length===0?"No conditions defined":u.joinKeyGroups.length===1?d(u.joinKeyGroups[0].keys):u.joinKeyGroups.map((x,m)=>({id:m,operator:x.operator,condition:d(x.keys)})),l=e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("button",{type:"button",className:"shrink-0 cursor-help rounded-control px-1 font-mono text-[10px] tabular-nums text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground","aria-label":`${i.length} resolved ${i.length===1?"join":"joins"}`,children:i.length})}),e.jsx(t.TooltipContent,{side:"bottom",align:"start",className:"max-w-md border border-border bg-popover p-2 text-popover-foreground shadow-[0_4px_16px_rgba(0,0,0,0.08)]",children:e.jsx("div",{className:"space-y-2",children:i.map((u,x)=>{const m=c(u),b=Array.isArray(m);return e.jsxs("div",{className:"rounded-md border border-border bg-background p-2 text-foreground",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium text-foreground",children:u.source.name}),e.jsx(a.ArrowRight,{className:"size-3 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:u.target.name})]}),e.jsx("span",{className:"shrink-0 rounded-[3px] border border-border px-1 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:u.joinType})]}),e.jsx("div",{className:"mt-1 space-y-1",children:b?m.map(h=>e.jsxs("div",{className:"rounded bg-muted/30 px-2 py-1",children:[e.jsx("code",{className:"block break-all text-xs text-muted-foreground",children:h.condition}),h.operator&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",h.operator,")"]})]},h.id)):e.jsx("div",{className:"rounded bg-muted/30 px-2 py-1",children:e.jsx("code",{className:"block break-all text-xs text-muted-foreground",children:m})})})]},u.id||x)})})})]})});return e.jsxs("div",{className:"flex h-7 w-full items-center gap-2 rounded-control border border-input bg-background px-2 text-left transition-colors hover:bg-muted",children:[e.jsx(a.Link,{className:"h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:"Resolved joins"}),l,s&&e.jsx("button",{type:"button",onClick:s,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:border-ring","aria-label":"Edit resolved joins",children:e.jsx(a.SquarePen,{className:"h-3 w-3",strokeWidth:1.75})})]})}function xc({onRemoveField:s,onResetFields:n,selectedChart:r,onChartChange:o,isVisible:i=!0,onToggleVisibility:d,groupByFields:c,pivotByFields:l,metricsFields:u,sortByFields:x,detailFields:m,activeField:b}){var I;const[h,p]=v.useState(!1),j=t.useEditorStore(y=>y.card),N=t.useEditorStore(y=>y.editorContext),f=t.useEditorStore(y=>y.actions.updateCardConfig),g=(N==null?void 0:N.type)==="documentSection",{autoJoinMetadata:k}=a.useEditorCardQuery(j),D=ye.getAuthoredCardJoinPlan(j)||(k!=null&&k.autoResolved?k.resolvedJoinPlan:{baseEntity:{type:"table",name:"",database:"",schema:"",connectionId:"",connectionType:"none",dialect:"none"},joins:[]}),w=((I=j==null?void 0:j.dataSource)==null?void 0:I.selectedEntities)||[],S=y=>{f(j.id,ye.withAuthoredCardJoinPlan(j,y)),p(!1)},L=()=>{f(j.id,ye.withAuthoredCardJoinPlan(j,void 0)),p(!1)},A=()=>{p(!1)},F=()=>{p(!0)};return i?e.jsxs("div",{"data-content":"Chart Configuration Panel",className:"flex w-[325px] min-w-[325px] shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-all duration-300 ease-in-out",children:[!g&&e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Vo,{selectedChart:r,onChartChange:o})}),d&&e.jsx("div",{className:"px-2 pt-4",children:e.jsx(a.IconButton,{tooltip:"Hide chart configuration","aria-label":"Hide chart configuration",onClick:d,className:"h-7 w-7 rounded-[5px] p-0 text-muted-foreground hover:text-foreground",children:e.jsx(a.ChevronLeft,{className:"h-4 w-4",strokeWidth:1.75})})})]}),e.jsxs(t.ScrollArea,{className:"min-h-0 w-full flex-1 basis-0 border-t border-border [&>[data-radix-scroll-area-viewport]]:overscroll-none [&>[data-radix-scroll-area-viewport]>div]:!block [&>[data-radix-scroll-area-viewport]>div]:w-full",children:[e.jsx("div",{className:"px-4 pt-4 empty:hidden",children:e.jsx(mc,{onEditJoins:F})}),e.jsx(dc,{onRemoveField:s,onResetFields:n,groupByFields:c,pivotByFields:l,metricsFields:u,sortByFields:x,detailFields:m,activeField:b})]}),e.jsx(uc,{}),e.jsx(ra,{open:h,onOpenChange:p,joinPlan:D,availableDataSources:w,onSave:S,onCancel:A,onRemove:L,children:e.jsx("div",{})})]}):e.jsx("div",{"data-content":"Chart Configuration Panel (collapsed)",className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-background transition-all duration-300 ease-in-out",children:d&&e.jsx(a.IconButton,{tooltip:"Show chart configuration","aria-label":"Show chart configuration",onClick:d,className:"mt-3 h-7 w-7 rounded-[5px] p-0 text-muted-foreground hover:text-foreground",children:e.jsx(qe.ChevronRight,{className:"h-4 w-4",strokeWidth:1.75})})})}function hc({initialFilters:s,availableFields:n}={}){const[r,o]=v.useState(s||{id:`group-${Date.now()}`,logicalOperator:"AND",negate:!1,conditions:[],groups:[]});t.useEditorStore(w=>w.card.dataSource);const{filterableFields:i,isLoading:d}=a.useFilterableFields(),c=n||i||[],l={id:"default",qualifiedFieldName:"default",name:"default",dataType:"string",label:"Default",entityId:"default",entityName:"Default",entityType:"table"},u=w=>{const S=L=>{if(L.id===w){const A=c[0]||l,F=t.getDataType(A.dataType)==="date";return{...L,conditions:[...L.conditions,{id:`condition-${Date.now()}`,field:A,operator:F?"between":"=",value:F?[]:""}]}}return{...L,groups:L.groups.map(S)}};o(S(r))},x=w=>{const S=L=>{if(L.id===w){const A=c[0]||l,F=t.getDataType(A.dataType)==="date";return{...L,groups:[...L.groups,{id:`group-${Date.now()}`,logicalOperator:"AND",negate:!1,conditions:[{id:`condition-${Date.now()}`,field:A,operator:F?"between":"=",value:F?[]:""}],groups:[]}]}}return{...L,groups:L.groups.map(S)}};o(S(r))},m=(w,S)=>{const L=A=>A.id===w?{...A,conditions:A.conditions.filter(F=>F.id!==S)}:{...A,groups:A.groups.map(L)};o(L(r))},b=(w,S)=>{const L=A=>A.id===w?{...A,groups:A.groups.filter(F=>F.id!==S)}:{...A,groups:A.groups.map(L)};o(L(r))},h=(w,S,L,A)=>{if(L==="field")throw new Error("Use a dedicated method to update the field property with a Field object");const F=I=>I.id===w?{...I,conditions:I.conditions.map(y=>y.id===S?{...y,[L]:A}:y)}:{...I,groups:I.groups.map(F)};o(F(r))},p=(w,S,L)=>{const A=F=>F.id===w?{...F,conditions:F.conditions.map(I=>I.id===S?{...I,...L}:I)}:{...F,groups:F.groups.map(A)};o(A(r))},j=(w,S)=>{const L=A=>A.id===w?{...A,logicalOperator:S}:{...A,groups:A.groups.map(L)};o(L(r))},N=(w,S)=>{const L=A=>A.id===w?{...A,negate:S}:{...A,groups:A.groups.map(L)};o(L(r))},f=(w,S,L)=>{const A=F=>F.id===w?{...F,conditions:a.arrayMove(F.conditions,S,L)}:{...F,groups:F.groups.map(A)};o(A(r))},g=(w,S,L)=>{const A=F=>F.id===w?{...F,groups:a.arrayMove(F.groups,S,L)}:{...F,groups:F.groups.map(A)};o(A(r))},k=w=>{if(!w||w.conditions.length===0&&w.groups.length===0)return"-- No filters defined";const S=A=>{let F="";typeof A.field=="object"?F=A.field.entityName?`${A.field.entityName}.${A.field.name}`:A.field.name:F=String(A.field);const I=A.operator;let y=A.value;if(A.field.dataType==="string"&&!["in","not in"].includes(A.operator))typeof y=="string"?y=`'${y}'`:Array.isArray(y)&&(y=`'${y.join(", ")}'`);else if(A.field.dataType==="date"||A.field.dataType==="datetime"||A.field.dataType==="timestamp")if(A.operator==="between"&&Array.isArray(y)&&y.length===2){const E=y[0]?`'${y[0]}'`:"NULL",M=y[1]?`'${y[1]}'`:"NULL";return`${F} BETWEEN ${E} AND ${M}`}else if((A.operator==="in"||A.operator==="not in")&&Array.isArray(y)){const E=y.map(M=>M?`'${M}'`:"NULL").join(", ");return`${F} ${I} (${E})`}else typeof y=="string"||y instanceof Date?y=`'${y}'`:Array.isArray(y)&&y.length>0&&(y=`'${y[0]}'`);else if(["in","not in"].includes(A.operator)){let E=[];Array.isArray(y)?E=y.map(M=>typeof M=="string"?`'${M}'`:String(M)):typeof y=="string"?E=y.split(",").map(M=>{const T=M.trim();return A.field.dataType==="string"?`'${T}'`:T}):typeof y=="number"&&(E=[String(y)]),y=`(${E.join(", ")})`}switch(I){case"contains":return typeof y=="string"?`${F} LIKE '%${y.replace(/'/g,"")}'`:`${F} LIKE '%${String(y)}'`;case"startsWith":return typeof y=="string"?`${F} LIKE '${y.replace(/'/g,"")}%'`:`${F} LIKE '${String(y)}%'`;case"endsWith":return typeof y=="string"?`${F} LIKE '%${y.replace(/'/g,"")}'`:`${F} LIKE '%${String(y)}'`;case"isNull":return`${F} IS NULL`;case"isNotNull":return`${F} IS NOT NULL`;default:return`${F} ${I} ${y}`}},L=A=>{const F=A.conditions.map(S),I=A.groups.map(T=>L(T)),y=[...F,...I].filter(Boolean);if(y.length===0)return"";const E=y.join(` ${A.logicalOperator} `),M=y.length>1?`(${E})`:E;return A.negate?`NOT ${M}`:M};return L(w)},D=r.conditions.length>0||r.groups.length>0;return{currentFilters:r,setCurrentFilters:o,availableFields:c,isLoading:d,addCondition:u,addGroup:x,removeCondition:m,removeGroup:b,updateCondition:h,updateConditionFields:p,updateGroupOperator:j,updateGroupNegate:N,reorderConditions:f,reorderGroups:g,generateSQLPreview:k,hasAnyFilters:D}}function pc({children:s,className:n,delayDuration:r}){return e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:r,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:t.cn("w-[200px] overflow-hidden text-ellipsis whitespace-nowrap text-sm",n),children:s})}),e.jsx(t.TooltipContent,{children:s})]})})}function fc({value:s,onValueChange:n,availableFields:r,placeholder:o="Select field",className:i}){const[d,c]=v.useState(!1),l=v.useMemo(()=>new Set(s?[s.id]:[]),[s]),u=s?a.getFieldDisplayLabel(s):null;return e.jsxs(t.Popover,{modal:!0,open:d,onOpenChange:c,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":d,title:s?`${s.entityName}.${s.name}`:void 0,className:t.cn("min-w-0 justify-between gap-1.5 font-normal",!s&&"text-muted-foreground",i),children:[u?e.jsx(pc,{className:"w-auto min-w-0 flex-1 text-left text-[12px]",children:u}):e.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:o}),e.jsx(a.ChevronsUpDown,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"flex w-80 flex-col rounded-control p-1.5",align:"start",onOpenAutoFocus:x=>{var m,b;x.preventDefault(),(b=(m=x.currentTarget)==null?void 0:m.querySelector('input[type="text"]'))==null||b.focus()},children:e.jsx(a.FieldOptionList,{fields:r,selectedIds:l,onSelect:x=>{n(x),c(!1)},density:"compact",listLabel:"Fields",listClassName:"max-h-80"})})]})}function Pa(s){const n=t.useEditorStore(c=>c.card.dataSource),r=t.useEditorStore(c=>c.card.connectionId),o=t.useEditorStore(c=>c.selectedConnectionId),i=v.useMemo(()=>({id:`card-filter-option:${s.id}`,...ya(s,{dataSource:n,connectionId:o||(n==null?void 0:n.connectionId)||r})}),[r,n,s,o]),d=v.useMemo(()=>a.createExplicitDashboardInputTargetContext({filter:i}),[i]);return a.useFilterOptionBrowse(i,{inputContext:d,currentSelectionPolicy:"exclude"})}function gc({field:s,selected:n,onChange:r,placeholder:o="Select values…",className:i}){const[d,c]=ss.useState(!1),l=Pa(s),u=ss.useMemo(()=>new Set(n.map(h=>a.getFilterOptionValueIdentity(h))),[n]),x=h=>{var p,j;return((j=(p=l.allRecords.find(N=>a.getFilterOptionValueIdentity(N.value)===a.getFilterOptionValueIdentity(h)))==null?void 0:p.label)==null?void 0:j.toString())??h},m=h=>{r(n.filter(p=>p!==h))},b=h=>{c(h),!h&&l.query&&l.setQuery("")};return e.jsx("div",{className:t.cn("w-full",i),children:e.jsxs(t.Popover,{open:d,onOpenChange:b,modal:!0,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":d,className:"h-auto min-h-7 w-full justify-between gap-1.5 px-2 py-0.5 font-normal",children:[e.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap gap-1",children:n.length>0?n.map(h=>{const p=x(h);return e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-[4px] border border-border/70 bg-muted/40 px-1.5 py-0.5 text-[11px] leading-[14px] text-foreground",children:[e.jsx("span",{className:"truncate",children:p}),e.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remove ${p}`,className:"shrink-0 rounded-[2px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring",onKeyDown:j=>{j.key==="Enter"&&m(h)},onMouseDown:j=>{j.preventDefault(),j.stopPropagation()},onClick:j=>{j.stopPropagation(),m(h)},children:e.jsx(le.X,{className:"h-3 w-3"})})]},h)}):e.jsx("span",{className:"truncate text-muted-foreground",children:o})}),e.jsx(le.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] min-w-[240px] rounded-control p-1.5",align:"start",onOpenAutoFocus:h=>{var p,j;h.preventDefault(),(j=(p=h.currentTarget)==null?void 0:p.querySelector('input[type="text"]'))==null||j.focus()},children:e.jsx(a.FilterOptionList,{records:l.displayRecords,selectedIdentities:u,onToggle:h=>{const p=String(h.value);n.includes(p)?m(p):r([...n,p])},browse:l,searchPlaceholder:`Search ${(s.label||s.name).toLowerCase()}`,listLabel:s.label||s.name,density:"compact"})})]})})}function bc({field:s,value:n,onChange:r,placeholder:o="Select value…",className:i}){var b,h;const[d,c]=ss.useState(!1),l=Pa(s),u=ss.useMemo(()=>new Set(n?[a.getFilterOptionValueIdentity(n)]:[]),[n]),x=n?((h=(b=l.allRecords.find(p=>a.getFilterOptionValueIdentity(p.value)===a.getFilterOptionValueIdentity(n)))==null?void 0:b.label)==null?void 0:h.toString())??n:"",m=p=>{c(p),!p&&l.query&&l.setQuery("")};return e.jsxs(t.Popover,{open:d,onOpenChange:m,modal:!0,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":d,className:t.cn("min-w-0 flex-1 justify-between gap-1.5 px-2 font-normal",i),children:[e.jsx("span",{className:t.cn("truncate",!n&&"text-muted-foreground"),children:n?x:o}),e.jsx(le.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] min-w-[240px] rounded-control p-1.5",align:"start",onOpenAutoFocus:p=>{var j,N;p.preventDefault(),(N=(j=p.currentTarget)==null?void 0:j.querySelector('input[type="text"]'))==null||N.focus()},children:e.jsx(a.FilterOptionList,{records:l.displayRecords,selectedIdentities:u,onToggle:p=>{r(String(p.value)),m(!1)},selectionMode:"single",browse:l,searchPlaceholder:`Search ${(s.label||s.name).toLowerCase()}`,listLabel:s.label||s.name,density:"compact"})})]})}function jc({value:s,operator:n,onChange:r,className:o}){const i=a.useTimezone(),d=n==="between"||n==="not between",c=v.useMemo(()=>{if(!(!s||!d)&&Array.isArray(s)&&s.length===2){const b=s[0]?new Date(s[0]):void 0,h=s[1]?new Date(s[1]):void 0;if(b&&h)return{from:b,to:h}}},[s,d]),l=v.useMemo(()=>{if(!s||d)return;const b=Array.isArray(s)?s[0]:s;if(!b)return;const h=new Date(b);if(!isNaN(h.getTime()))return h},[s,d]),u=b=>n==="<="||n===">"?t.endOfDayInTimezone(b,i):t.startOfDayInTimezone(b,i),x=b=>{if(!b){r([]);return}if(b.from&&b.to){r([b.from.toISOString(),b.to.toISOString()]);return}r([])},m=b=>{if(!b){r("");return}const h=u(b);r(h.toISOString())};return e.jsx(a.DateRangePicker,{value:d?c:void 0,selectionMode:d?"range":"single",singleValue:d?void 0:l,onChange:x,onSingleChange:m,timezone:i,showRelativeTab:d,className:t.cn("min-w-0",o),buttonClassName:"h-7 text-[12px] [&>span]:text-[12px]",placeholder:"Select date…"})}const _s=["contains","startsWith","endsWith","like","not like"],vc=["=","!=",">",">=","<","<=",..._s,"in","not in","isNull","isNotNull"],yc=["=","!=",..._s,"in","not in","isNull","isNotNull"],Cc=["=","!=",">",">=","<","<=","in","not in","isNull","isNotNull"],Nc=["=","!=","isNull","isNotNull"],Sc=["between","=","!=","<","<=",">",">=","isNull","isNotNull"],wc={"=":"Equals","!=":"Not equals",">":"Greater than",">=":"Greater than or equal","<":"Less than","<=":"Less than or equal",contains:"Contains",startsWith:"Starts with",endsWith:"Ends with",like:"Like","not like":"Not like",in:"In","not in":"Not in",between:"Between",isNull:"Is null",isNotNull:"Is not null","not between":"Not between"};function ws(s){return wc[s]||t.titleCase(s)}function Tc(s){switch(s){case"string":return yc;case"number":return Cc;case"boolean":return Nc;case"date":return Sc;default:return vc}}const Oa="w-[68px] shrink-0",Ys="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Ba({value:s,onValueChange:n,"aria-label":r}){return e.jsxs(t.Select,{value:s,onValueChange:o=>n(o),children:[e.jsx(t.SelectTrigger,{size:"xs","aria-label":r,className:t.cn(Oa,"font-medium"),children:e.jsx(t.SelectValue,{})}),e.jsxs(t.SelectContent,{className:"min-w-[var(--radix-select-trigger-width)]",children:[e.jsx(t.SelectItem,{value:"AND",className:"text-[12px] font-medium",children:"AND"}),e.jsx(t.SelectItem,{value:"OR",className:"text-[12px] font-medium",children:"OR"})]})]})}function Va({condition:s,index:n,groupId:r,groupLogicalOperator:o,onUpdateCondition:i,onRemoveCondition:d,onUpdateGroupOperator:c,availableFields:l,updateConditionFields:u}){const{attributes:x,listeners:m,setNodeRef:b,transform:h,transition:p,isDragging:j}=a.useSortable({id:s.id}),N={transform:a.CSS.Transform.toString(h),transition:p},f=t.getDataType(s.field.dataType),g=s.operator==="isNull"||s.operator==="isNotNull",k=s.operator==="in"||s.operator==="not in";return e.jsxs("div",{ref:b,style:N,className:t.cn("flex items-center gap-2 rounded-control px-1.5 py-1 transition-colors hover:bg-muted/40",j&&"z-50 opacity-50"),children:[e.jsx("button",{type:"button",...x,...m,"aria-label":"Drag to reorder condition",className:"flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded-control text-muted-foreground/60 hover:text-foreground focus-visible:outline-none active:cursor-grabbing",children:e.jsx(a.GripVertical,{className:"h-3.5 w-3.5"})}),n>0?e.jsx(Ba,{value:o,onValueChange:D=>c(r,D),"aria-label":"Logical operator"}):e.jsx("span",{className:t.cn(Oa,"text-center",Ys),children:"Where"}),e.jsx(fc,{value:s.field,onValueChange:D=>{const w=D,S=t.getDataType(w.dataType)==="date";u(r,s.id,{field:w,value:"",operator:S?"between":"="})},availableFields:l,placeholder:"Select field",className:"w-60 shrink-0"}),e.jsxs(t.Select,{value:s.operator,onValueChange:D=>{D==="in"||D==="not in"?u(r,s.id,{operator:D,value:[]}):D==="isNull"||D==="isNotNull"?u(r,s.id,{operator:D,value:null}):D==="between"||D==="not between"?u(r,s.id,{operator:D,value:[]}):u(r,s.id,{operator:D,value:""})},children:[e.jsx(t.SelectTrigger,{size:"xs","aria-label":"Operator",className:"w-40 shrink-0",children:e.jsx(t.SelectValue,{children:s.operator?ws(s.operator):""})}),e.jsx(t.SelectContent,{children:Tc(f).map(D=>e.jsx(t.SelectItem,{value:D,children:ws(D)},D))})]}),g?e.jsx("div",{className:"min-w-0 flex-1"}):f==="string"?k?e.jsx(gc,{field:s.field,selected:Array.isArray(s.value)&&s.value.every(D=>typeof D=="string")?s.value:[],onChange:D=>u(r,s.id,{value:D}),placeholder:"Select values…",className:"min-w-0 flex-1"}):_s.includes(s.operator)?e.jsx(t.Input,{size:"xs",value:typeof s.value=="string"?s.value:"",onChange:D=>u(r,s.id,{value:D.target.value}),className:"min-w-0 flex-1",placeholder:`${ws(s.operator)}…`}):e.jsx(bc,{field:s.field,value:typeof s.value=="string"?s.value:"",onChange:D=>u(r,s.id,{value:D}),placeholder:"Select value…",className:"min-w-0 flex-1"}):f==="boolean"?e.jsxs(t.Select,{value:typeof s.value=="boolean"?String(s.value):"",onValueChange:D=>u(r,s.id,{value:D==="true"}),children:[e.jsx(t.SelectTrigger,{size:"xs",className:"min-w-0 flex-1",children:e.jsx(t.SelectValue,{placeholder:"Select value…"})}),e.jsxs(t.SelectContent,{children:[e.jsx(t.SelectItem,{value:"true",children:"True"}),e.jsx(t.SelectItem,{value:"false",children:"False"})]})]}):f==="date"?e.jsx(jc,{value:s.value,operator:s.operator,onChange:D=>u(r,s.id,{value:D}),className:"min-w-0 flex-1"}):e.jsx(t.Input,{size:"xs",value:typeof s.value=="string"||typeof s.value=="number"?s.value:"",onChange:D=>i(r,s.id,"value",D.target.value),className:"min-w-0 flex-1",placeholder:k?"value1, value2, value3":"Value"}),e.jsx(t.Button,{variant:"ghost",size:"xs","aria-label":"Remove condition",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground hover:text-foreground",onClick:()=>d(r,s.id),children:e.jsx(le.X,{className:"h-3.5 w-3.5"})})]})}function _a({onAddCondition:s,onAddGroup:n}){return e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(t.Button,{type:"button",size:"xs",variant:"outline",className:"gap-1.5",onClick:s,children:[e.jsx(a.Plus,{className:"h-3 w-3"}),"Add condition"]}),n&&e.jsxs(t.Button,{type:"button",size:"xs",variant:"ghost",className:"gap-1.5 text-muted-foreground hover:text-foreground",onClick:n,children:[e.jsx(a.Plus,{className:"h-3 w-3"}),"Add group"]})]})}function Ec({group:s,depth:n,parentGroupId:r,onUpdateGroupOperator:o,onUpdateGroupNegate:i,onRemoveGroup:d,onUpdateCondition:c,onUpdateField:l,onRemoveCondition:u,onReorderConditions:x,onReorderGroups:m,onAddCondition:b,onAddGroup:h,availableFields:p,renderFilterGroup:j,updateConditionFields:N}){const{attributes:f,listeners:g,setNodeRef:k,transform:D,transition:w,isDragging:S}=a.useSortable({id:s.id}),L={transform:a.CSS.Transform.toString(D),transition:w},A=I=>{const{active:y,over:E}=I;if(E&&y.id!==E.id){const M=s.conditions.findIndex(R=>R.id===y.id),T=s.conditions.findIndex(R=>R.id===E.id);M!==-1&&T!==-1&&x(s.id,M,T)}},F=I=>{const{active:y,over:E}=I;if(E&&y.id!==E.id&&r){const M=s.groups.findIndex(R=>R.id===y.id),T=s.groups.findIndex(R=>R.id===E.id);M!==-1&&T!==-1&&m(r,M,T)}};return e.jsxs("div",{ref:k,style:L,className:t.cn(n>0&&"mt-2 overflow-hidden rounded-[6px] border border-border/60",S&&"z-50 opacity-50"),children:[n>0&&e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 bg-muted/40 px-2 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",...f,...g,"aria-label":"Drag to reorder group",className:"flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded-control text-muted-foreground/60 hover:text-foreground focus-visible:outline-none active:cursor-grabbing",children:e.jsx(a.GripVertical,{className:"h-3.5 w-3.5"})}),e.jsx(t.Button,{type:"button",variant:s.negate?"default":"outline",size:"xs","aria-pressed":s.negate,className:"px-2",onClick:()=>i(s.id,!s.negate),children:"NOT"}),e.jsx(Ba,{value:s.logicalOperator,onValueChange:I=>o(s.id,I),"aria-label":"Group logical operator"}),e.jsx("span",{className:Ys,children:"Group"})]}),e.jsx(t.Button,{type:"button",variant:"ghost",size:"xs","aria-label":"Remove group",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:()=>r&&d(r,s.id),children:e.jsx(a.Trash2,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:t.cn(n>0&&"p-2"),children:[e.jsx(a.DndContext,{sensors:a.useSensors(a.useSensor(a.PointerSensor),a.useSensor(a.KeyboardSensor,{coordinateGetter:a.sortableKeyboardCoordinates})),collisionDetection:a.closestCenter,onDragEnd:A,children:e.jsx(a.SortableContext,{items:s.conditions.map(I=>I.id),strategy:a.verticalListSortingStrategy,children:e.jsx("div",{className:"space-y-0.5",children:s.conditions.map((I,y)=>e.jsx(Va,{condition:I,index:y,groupId:s.id,groupLogicalOperator:s.logicalOperator,onUpdateCondition:c,onUpdateField:l,onRemoveCondition:u,onUpdateGroupOperator:o,availableFields:p,updateConditionFields:N},I.id))})})}),e.jsx(a.DndContext,{sensors:a.useSensors(a.useSensor(a.PointerSensor),a.useSensor(a.KeyboardSensor,{coordinateGetter:a.sortableKeyboardCoordinates})),collisionDetection:a.closestCenter,onDragEnd:F,children:e.jsx(a.SortableContext,{items:s.groups.map(I=>I.id),strategy:a.verticalListSortingStrategy,children:s.groups.map(I=>j(I,n+1,s.id))})}),s.conditions.length===0&&s.groups.length===0&&e.jsx("p",{className:"rounded-control border border-dashed border-border/60 px-3 py-2 text-center text-[11.5px] text-muted-foreground",children:"No conditions in this group."}),e.jsx(_a,{onAddCondition:()=>b(s.id),onAddGroup:()=>h(s.id)})]})]})}function Ic({filters:s,availableFields:n,onSave:r,onClearAll:o,onCancel:i}){const{currentFilters:d,availableFields:c,isLoading:l,addCondition:u,addGroup:x,removeCondition:m,removeGroup:b,updateCondition:h,updateConditionFields:p,updateGroupOperator:j,updateGroupNegate:N,reorderConditions:f,reorderGroups:g,generateSQLPreview:k,hasAnyFilters:D,setCurrentFilters:w}=hc({initialFilters:s,availableFields:n}),S=a.useSensors(a.useSensor(a.PointerSensor),a.useSensor(a.KeyboardSensor,{coordinateGetter:a.sortableKeyboardCoordinates})),[L,A]=v.useState(!1),F=(E,M,T)=>{const R=C=>C.id===E?{...C,conditions:C.conditions.map(V=>V.id===M?{...V,field:T,dataType:T.dataType}:V)}:{...C,groups:C.groups.map(R)};w(R(d))},I=(E,M=0,T)=>{if(M===0){const R=E.conditions.length===0&&E.groups.length===0;return e.jsxs("div",{children:[e.jsx(a.DndContext,{sensors:S,collisionDetection:a.closestCenter,onDragEnd:C=>{const{active:V,over:P}=C;if(P&&V.id!==P.id){const O=E.conditions.findIndex(_=>_.id===V.id),B=E.conditions.findIndex(_=>_.id===P.id);O!==-1&&B!==-1&&f(E.id,O,B)}},children:e.jsx(a.SortableContext,{items:E.conditions.map(C=>C.id),strategy:a.verticalListSortingStrategy,children:e.jsx("div",{className:"space-y-0.5",children:E.conditions.map((C,V)=>e.jsx(Va,{condition:C,index:V,groupId:E.id,groupLogicalOperator:E.logicalOperator,onUpdateCondition:h,onUpdateField:F,onRemoveCondition:m,onUpdateGroupOperator:j,availableFields:c,updateConditionFields:p},C.id))})})}),e.jsx(a.DndContext,{sensors:S,collisionDetection:a.closestCenter,onDragEnd:C=>{const{active:V,over:P}=C;if(P&&V.id!==P.id){const O=E.groups.findIndex(_=>_.id===V.id),B=E.groups.findIndex(_=>_.id===P.id);O!==-1&&B!==-1&&g(E.id,O,B)}},children:e.jsx(a.SortableContext,{items:E.groups.map(C=>C.id),strategy:a.verticalListSortingStrategy,children:E.groups.map(C=>I(C,M+1,E.id))})}),R&&e.jsx("p",{className:"rounded-control border border-dashed border-border/60 px-3 py-2 text-center text-[11.5px] text-muted-foreground",children:"No filters yet. Add a condition to limit the rows this card shows."}),e.jsx(_a,{onAddCondition:()=>u(E.id),onAddGroup:L?()=>x(E.id):void 0})]},E.id)}return e.jsx(Ec,{group:E,depth:M,parentGroupId:T,onUpdateGroupOperator:j,onUpdateGroupNegate:N,onRemoveGroup:b,onUpdateCondition:h,onUpdateField:F,onRemoveCondition:m,onReorderConditions:f,onReorderGroups:g,onAddCondition:u,onAddGroup:x,availableFields:c,renderFilterGroup:I,updateConditionFields:p},E.id)},y=a.getFilterCount(s);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:[l?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-[12px] text-muted-foreground",children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Loading columns…"]}):I(d),e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-border/60 pt-3",children:[e.jsx(t.Switch,{size:"xs",id:"advanced-mode",checked:L,onCheckedChange:E=>A(E)}),e.jsx(t.Label,{htmlFor:"advanced-mode",className:"text-[12px] font-normal leading-none text-foreground",children:"Advanced mode"}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Nest conditions in groups"})]}),D&&e.jsxs("div",{className:"mt-3 border-t border-border/60 pt-3",children:[e.jsx("div",{className:t.cn("mb-1.5",Ys),children:"Where clause"}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-[6px] border border-border bg-muted/40 px-3 py-2 font-mono text-[12px] leading-[1.55] text-foreground",children:k(d)})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border px-3 py-2.5",children:[e.jsx("div",{children:y>0&&e.jsx(t.Button,{size:"xs",variant:"ghost",className:"text-muted-foreground hover:text-foreground",onClick:o,children:"Clear all"})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.Button,{size:"xs",variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(t.Button,{size:"xs",onClick:()=>r(D?d:null),children:"Apply filters"})]})]})]})}function Dc({cardId:s,filters:n,onFiltersChange:r,onClearFilters:o,availableFields:i,isOpen:d,onOpenChange:c}){const l=x=>{r(s,x),c(!1)},u=()=>{o(s),c(!1)};return e.jsxs(a.Dialog,{modal:!1,open:d,onOpenChange:c,children:[d&&e.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-zinc-950/40 backdrop-blur-sm"}),e.jsxs(a.DialogContent,{className:"flex max-h-[80vh] w-[min(880px,92vw)] max-w-none flex-col gap-0 overflow-hidden p-0 [&>button:last-child]:top-3",onInteractOutside:x=>{x.preventDefault()},children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-border pl-3 pr-10",children:[e.jsx(a.Filter,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(a.DialogTitle,{className:"truncate text-[13px] font-medium",children:"Card filters"}),e.jsx(a.DialogDescription,{className:"sr-only",children:"Add filters to the card to limit the data that is displayed."})]}),e.jsx(Ic,{filters:n,availableFields:i,onSave:l,onCancel:()=>c(!1),onClearAll:u})]})]})}function kc({activeCardId:s,sourceFields:n,getFieldsForContainer:r,setFieldsForContainer:o,moveField:i}){const[d,c]=v.useState(null),l=t.useEditorStore(f=>f.card),u=t.useEditorStore(f=>f.actions.updateCardConfig),x=t.useEditorStore(f=>f.actions.setCardPreferences),m=a.useFieldAvailabilityContext(l),b=[...n,...r("groupBy"),...r("pivotBy"),...r("metrics"),...r("sortBy"),...r("detailColumns")],h=v.useCallback(f=>f.startsWith("card-source-")?"source":f.startsWith("card-")?null:f.startsWith("source-")||n.find(g=>g.id===f)?"source":r("groupBy").find(g=>g.id===f)?"groupBy":r("metrics").find(g=>g.id===f)?"metrics":r("pivotBy").find(g=>g.id===f)?"pivotBy":r("sortBy").find(g=>g.id===f)?"sortBy":r("detailColumns").find(g=>g.id===f)?"detailColumns":null,[n,r]),p=v.useCallback(f=>{c(f.active.id)},[]),j=v.useCallback(f=>{const{active:g,over:k}=f;if(!k||!s){c(null);return}const D=g.id,w=k.id,S=h(D),L=h(w)||w;if(D===w){c(null);return}const A=S==="source"?n.find(F=>F.id===D):S?r(S).find(F=>F.id===D):void 0;if(A&&S&&(i!=null&&i({field:A,from:S,to:L,...w!==L?{beforeId:w}:{}}))){c(null);return}if(L==="sortBy"){if(S==="source"){const F=n.find(y=>y.id===D);if(!F){c(null);return}if(!(r("groupBy").some(y=>y.name===F.name&&y.qualifiedEntityName===F.qualifiedEntityName)||r("metrics").some(y=>y.name===F.name&&y.qualifiedEntityName===F.qualifiedEntityName)||r("detailColumns").some(y=>y.name===F.name&&y.qualifiedEntityName===F.qualifiedEntityName))){c(null);return}}else if(S==="pivotBy"){c(null);return}else if(S!=="groupBy"&&S!=="metrics"&&S!=="sortBy"&&S!=="detailColumns"){c(null);return}}if(S==="source"&&L==="sortBy"){const F=[...n].find(M=>M.id===D);if(!F){c(null);return}const I=r("sortBy");if(a.fieldAlreadyExists(F,I)){c(null);return}const y=a.validateFieldForChartType(F,"sortBy",l.type);if(!y.isValid){t.ue.error("Invalid Field Type",{description:y.reason,position:"top-center",duration:3e3}),c(null);return}const E=a.getNewField(F,"sortBy",I);c(null),o("sortBy",[...I,E]);return}if(S==="source"&&L!=="source"&&L!=="sortBy"){const F=[...n].find(C=>C.id===D);if(!F){c(null);return}const I=[...r("groupBy"),...r("pivotBy"),...r("metrics"),...r("sortBy"),...r("detailColumns")],y=a.validateEntityConsistency(F,I,m);if(!y.isValid){y.showError&&a.showJoinRequiredNotification(y.fieldState),c(null);return}const E=r(L);if(a.fieldAlreadyExists(F,E)){c(null);return}const M=a.validateFieldForChartType(F,L,l.type);if(!M.isValid){t.ue.error("Invalid Field Type",{description:M.reason,position:"top-center",duration:3e3}),c(null);return}const T=a.getNewField(F,L,E),R=[...E,T];if(c(null),o(L,R),L==="metrics"&&s){const C=a.seedSemanticMetricFormatDefaults(l,T,l.preferences);C&&x(C),a.cleanupKpiMetricComparisonMode(l.type,l.config,u,s,R)}return}if(S&&L&&S!=="source"&&L!=="source"&&S!==L){const F=r(S),I=r(L),y=F.find(C=>C.id===D);if(!y){c(null);return}const E=a.validateFieldForChartType(y,L,l.type);if(!E.isValid){t.ue.error("Invalid Field Type",{description:E.reason,position:"top-center",duration:3e3}),c(null);return}const M=a.getNewField(y,L,I);if(c(null),L==="sortBy"){a.fieldAlreadyExists(y,I)||o(L,[...I,M]);return}const T=F.filter(C=>C.id!==D),R=[...I,M];if(o(S,T),o(L,R),L==="metrics"&&s){const C=a.seedSemanticMetricFormatDefaults(l,M,l.preferences);C&&x(C),a.cleanupKpiMetricComparisonMode(l.type,l.config,u,s,R)}return}if(S&&L&&S===L&&S!=="source"){const F=r(S),I=F.findIndex(E=>E.id===D),y=F.findIndex(E=>E.id===w);if(I!==y){const E=a.arrayMove(F,I,y);o(S,E)}}c(null)},[s,n,r,o,i,h,m,l,u,x]),N=d?b.find(f=>f.id===d):null;return{activeId:d,activeField:N,handleDragStart:p,handleDragEnd:j}}function Mc({activeView:s,onViewChange:n,splitViewEnabled:r,hasQueryError:o=!1}){const i=t.useEditorStore(x=>x.card),{config:d}=v.useContext(a.SemaphorContext).tokenProps,c=(d==null?void 0:d.showInfoTab)!==!1,l=()=>r?!1:t.getVisualizationMode(i)==="dynamic"?!0:!["table","pivotTable","aggregateTable","detailTable"].includes(i.type),u=[{id:"chart",label:"Chart"}];return l()&&u.push({id:"table",label:"Results"}),c&&u.push({id:"info",label:o?"Error":"Info",isError:o}),e.jsx(t.Tabs,{value:s,onValueChange:x=>n(x),children:e.jsx(t.TabsList,{variant:"underline",className:"gap-5 border-b-0",children:u.map(x=>e.jsx(t.TabsTrigger,{value:x.id,className:t.cn("px-0 text-[13px]",x.isError&&"text-destructive hover:text-destructive focus-visible:text-destructive data-[state=active]:border-destructive data-[state=active]:text-destructive"),children:x.label},x.id))})})}const Ac=[{value:"10",label:"Top 10"},{value:"20",label:"Top 20"},{value:"50",label:"Top 50"},{value:"100",label:"Top 100"},{value:"200",label:"Top 200"},{value:"500",label:"Top 500"},{value:"1000",label:"Top 1000"}];function Lc(){var u,x;const s=t.useEditorStore(m=>m.card),{updateRowLimit:n}=t.useEditorActions(),[r,o]=v.useState(!1),[i,d]=v.useState(""),c=m=>{if(m==="custom"){o(!0);return}o(!1),n(s.id,parseInt(m))},l=m=>{const b=m.target.value;d(b),b&&!isNaN(parseInt(b))&&n(s.id,parseInt(b))};return e.jsx("div",{className:"flex items-center gap-2",children:r?e.jsx(t.Input,{type:"number",value:i,onChange:l,className:"h-7 w-24",placeholder:"Enter limit",min:1}):e.jsxs(t.Select,{value:((x=(u=s.config)==null?void 0:u.rowLimit)==null?void 0:x.toString())||"100",onValueChange:c,children:[e.jsxs(t.SelectTrigger,{className:"mb-0.5 h-auto w-auto gap-1.5 border-none bg-transparent px-0.5 pb-2.5 pt-0 text-[13px] font-normal text-muted-foreground shadow-none transition-colors hover:text-foreground focus:ring-0 focus:ring-offset-0 [&>svg]:hidden",children:[e.jsx(a.Filter,{className:"h-3 w-3",strokeWidth:1.75}),e.jsx(t.SelectValue,{placeholder:"Select limit"})]}),e.jsx(t.SelectContent,{children:Ac.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})})}function Fc({card:s,queryData:n,isLoading:r,isFetching:o,pagination:i,onPaginationChange:d,onSortChange:c,sortState:l,splitViewEnabled:u,isDynamicInspectorOpen:x,onDynamicInspectorOpenChange:m}){var j,N;const b=v.useMemo(()=>(n==null?void 0:n.records)||[],[n==null?void 0:n.records]),h=t.getVisualizationMode(s)==="dynamic",p=e.jsx(Et,{alwaysRenderOverride:!0,renderCardOverride:()=>e.jsx(Na,{fallbackPreview:e.jsx(Et,{}),records:b,title:s.title,isInspectorOpen:x,onInspectorOpenChange:m})});return h?u?e.jsxs(a.ResizablePanelGroup,{direction:"vertical",className:"h-full min-h-0 w-full",children:[e.jsx(a.ResizablePanel,{defaultSize:60,minSize:30,role:"chart-section",className:"flex flex-col pb-3",children:p}),e.jsx(a.ResizableHandle,{withHandle:!0}),e.jsx(a.ResizablePanel,{defaultSize:40,minSize:20,role:"results-section",className:"flex flex-col",children:e.jsxs("div",{className:"relative flex h-full min-h-0 max-w-full flex-1 grow basis-0 px-4 py-4",children:[(r||o)&&(n==null?void 0:n.records)&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}),(n==null?void 0:n.records)&&e.jsx(a.TableVisual,{card:s,data:b,resultColumns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,totalsByColumnId:n==null?void 0:n.tableTotalsByColumnId,comparisonMetadata:(j=n==null?void 0:n.metadata)==null?void 0:j.comparisonMetadata,paginationMetadata:i,onPaginationChange:d,isLoading:r||o,onSortChange:c,sortState:l})]})})]}):p:!u||["table","pivotTable","aggregateTable","detailTable"].includes(s.type)?e.jsx(Et,{}):e.jsxs(a.ResizablePanelGroup,{direction:"vertical",className:"h-full min-h-0 w-full",children:[e.jsx(a.ResizablePanel,{defaultSize:60,minSize:30,role:"chart-section",className:"flex flex-col pb-3",children:e.jsx(Et,{})}),e.jsx(a.ResizableHandle,{withHandle:!0}),e.jsx(a.ResizablePanel,{defaultSize:40,minSize:20,role:"results-section",className:"flex flex-col",children:e.jsxs("div",{className:"relative flex h-full min-h-0 max-w-full flex-1 grow basis-0 py-4 pl-2 pr-4",children:[(r||o)&&(n==null?void 0:n.records)&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}),(n==null?void 0:n.records)&&e.jsx(a.TableVisual,{card:s,data:b,resultColumns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,totalsByColumnId:n==null?void 0:n.tableTotalsByColumnId,comparisonMetadata:(N=n==null?void 0:n.metadata)==null?void 0:N.comparisonMetadata,paginationMetadata:i,onPaginationChange:d,isLoading:r||o,onSortChange:c,sortState:l})]})})]})}function Rc(s,n){const[r,o]=v.useState(()=>{const i=localStorage.getItem(s);return i?JSON.parse(i):n});return v.useEffect(()=>{localStorage.setItem(s,JSON.stringify(r))},[r,s]),[r,o]}const Pc="semaphor-split-view-enabled";function Oc(){return Rc(Pc,!0)}function Bc({showInfoTab:s}){return e.jsx(a.VisualErrorState,{className:"min-h-[240px]",description:s?"See the Error tab for details and troubleshooting options.":"Contact your administrator for help resolving this issue."})}function Vc({card:s,effectiveCardType:n=s.type,queryResultColumns:r}){return t.supportsRegularTableSettings(n)?e.jsxs(a.Sheet,{modal:!1,children:[e.jsx(a.SheetTrigger,{asChild:!0,children:e.jsx(a.IconButton,{tooltip:"Table settings",className:"h-7 w-7 rounded-[5px] p-0",buttonProps:{type:"button","aria-label":"Table settings"},children:e.jsx(a.Settings2,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),e.jsxs(a.SheetContent,{side:"right",hideOverlay:!0,className:"flex w-[420px] flex-col gap-0 p-0 sm:max-w-[420px]",children:[e.jsx(a.SheetTitle,{className:"sr-only",children:"Table settings"}),e.jsx(a.SheetDescription,{className:"sr-only",children:"Configure table presentation and conditional formatting."}),e.jsxs("div",{className:"border-b px-4 py-3",children:[e.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:"Table settings"}),e.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Settings apply to this table and document exports that reuse it."})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(Aa,{cardType:n,queryResultColumns:r,focusSection:"style"})})]})]}):null}function _c({className:s,visible:n}){const r=t.useDashboardStore(l=>l.selectedFrameId),o=a.useManagementStore(l=>l.selectedVisual),i=t.useEditorStore(l=>l.frame),c=!!!(i!=null&&i.visualId||o!=null&&o.id)&&!!r;return!n||c?null:e.jsx("div",{className:t.cn("flex",s),children:e.jsx(gt.VisualBadge,{showLabel:!0,className:"h-6 w-fit px-2 py-0.5 text-[11px]"})})}function Yc({activeView:s,onViewChange:n,onFiltersClick:r,activeCard:o,columns:i}){var De;const d=t.useEditorStore(ae=>ae.card),c=t.useEditorStore(ae=>ae.editorContext),l=t.useEditorStore(ae=>ae.inlineFilterValuesMap[(o==null?void 0:o.id)||""]),u=t.useEditorStore(ae=>ae.actions.removeCardInlineFilterValue),x=t.useDashboardStore(ae=>ae.filterValues),m=t.useDashboardStore(ae=>ae.selectedSheetId),{updateCardConfig:b,setCard:h,updateCardInFrame:p,setShowAIDialog:j}=t.useEditorActions(),N=t.useEditorStore(ae=>ae.showAIDialog),f=t.useEditorStore(ae=>ae.isDevMode),g=t.useDashboardStore(ae=>ae.isVisualEditing),[k,D]=v.useState(!1),[w,S]=v.useState(!1),[L,A]=v.useState(!1),[F,I]=v.useState(null),{config:y}=v.useContext(a.SemaphorContext).tokenProps,E=(y==null?void 0:y.showInfoTab)!==!1,M=(y==null?void 0:y.showQueryDebugTools)!==!1,[T,R]=Oc();t.useEditorStore(ae=>{var K;return!!((K=ae.card.customCardPreferences)!=null&&K.url)});const V=t.getVisualizationMode(d)==="dynamic",P=(c==null?void 0:c.type)==="documentSection",O=a.useEffectiveEditorCardType(),{data:B,errorMessage:_,isLoading:z,isFetching:q,errorSql:Y,pagination:$,refetch:Q,comparisonMetadata:U,queryRequestPayload:J,resolvedPrimaryDateField:X}=a.useEditorCardQuery(o),ee=v.useMemo(()=>(B==null?void 0:B.records)||[],[B==null?void 0:B.records]),me=v.useMemo(()=>!q&&ee.length>0?Object.keys(ee[0]):[],[q,ee]),[be,ve]=v.useState(!1),je=a.useMatrixEditorRefresh(o),Re=t.useEditorStore(ae=>ae.frame),[Pe,Me]=v.useState();v.useEffect(()=>{q||ve(!1)},[q]);const Ee=()=>{const ae=!T;ae&&s==="table"&&n("chart"),R(ae)},Be=(ae,K)=>{const ie={...o,paginationConfig:{page:ae+1,pageSize:K}};h(ie),p(ie)},_e=ae=>{if(!d.config)return;const K=a.sortStateToSortByColumns(ae,d.config.metricColumns,d.config.groupByColumns,d.config.detailColumns);b(d.id,{...d.config,sortByColumns:K})},Oe=v.useMemo(()=>{var ae;return a.sortByColumnsToSortState((ae=d.config)==null?void 0:ae.sortByColumns)},[(De=d.config)==null?void 0:De.sortByColumns]),Ae=a.getFilterCount(ye.getAuthoredCardFilters(o)||null);return e.jsx("div",{className:t.cn("relative flex w-0 grow flex-col",{"border-l":N&&g}),children:e.jsxs("div",{className:"group/visualization relative flex h-full max-w-full grow flex-col",children:[e.jsxs("div",{className:"flex h-11 items-center gap-3 border-b border-border px-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s==="chart"&&N&&!P&&!V&&e.jsx("div",{className:"w-[200px]",children:e.jsx(Bo,{variant:f?"secondary":"ghost"})}),e.jsxs("div",{className:"flex h-11 items-end gap-5 self-stretch",children:[e.jsx(Mc,{activeView:s,onViewChange:n,splitViewEnabled:T,hasQueryError:!!_}),!a.isTableType(O)&&e.jsx(Lc,{})]}),O==="kpi"&&e.jsx(_c,{visible:!0,className:"self-center"}),U&&d.type!=="table"&&e.jsx(a.ComparisonMetadataBadge,{metadata:U,variant:"compact"}),N&&e.jsx(gt.EditorClearButton,{})]}),e.jsxs("div",{className:"flex grow items-center justify-end gap-1",children:[e.jsx(a.FilterInfo,{cardId:o.id,cardFilters:ye.getAuthoredCardFilters(o),cardFilterCount:Ae,onFiltersClick:r,inlineFilters:o.inlineFilters,inlineFilterValues:l,sheetId:m||"",removeInlineFilterValue:ae=>u(o.id,ae),resolvedPrimaryDateField:X}),s==="chart"&&e.jsx(Vc,{card:o,effectiveCardType:O,queryResultColumns:me}),s==="chart"&&!V&&e.jsx(Ca,{showInlineFilters:!1,showControls:!1,showDisplayOptions:!1}),e.jsx(a.IconButton,{tooltip:"Refresh",className:"h-7 w-7 rounded-[5px] p-0",disabled:z||q,onClick:()=>{var ae;if(je){(ae=je.refresh)==null||ae.call(je);return}ve(!0),Q()},children:e.jsx(Ts,{className:t.cn("h-3.5 w-3.5",{"animate-spin":(je==null?void 0:je.isFetching)??be})})}),s==="chart"&&e.jsxs(a.DropdownMenu,{modal:!1,children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsx(a.IconButton,{tooltip:"More Options",className:"h-7 w-7 rounded-[5px] p-0","aria-label":"More options",children:e.jsx(a.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(a.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsxs(a.DropdownMenuItem,{onSelect:r,children:[e.jsx(a.Filter,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Card filters",Ae>0&&e.jsx("span",{className:"ml-auto text-[11px] tabular-nums text-muted-foreground",children:Ae})]}),e.jsx(Rs,{triggerVariant:"menu",className:"w-full"}),e.jsx(Ps,{triggerVariant:"menu",className:"w-full"}),e.jsx(Fs,{triggerVariant:"menu",className:"w-full"}),e.jsxs(a.DropdownMenuItem,{onClick:Ee,children:[T?e.jsx(yr,{className:"h-3.5 w-3.5 text-muted-foreground"}):e.jsx(Fr,{className:"h-3.5 w-3.5 text-muted-foreground"}),T?"Hide results table":"Show results table"]}),je&&e.jsxs(a.DropdownMenuItem,{disabled:je.isFetching||!je.hasDelivery,title:je.hasDelivery?void 0:"Available once the preview has loaded.",onClick:()=>Me(je.readDelivery()),children:[e.jsx(a.Download,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Download"]}),e.jsx(Sa,{onCustomize:()=>A(!0)})]})]})]})]}),e.jsxs("div",{className:"flex min-h-0 grow flex-col",children:[s==="chart"?_?e.jsx(Bc,{showInfoTab:E}):e.jsx("div",{className:"flex grow flex-col",children:e.jsx(Fc,{card:o,queryData:B,isLoading:z,isFetching:q,pagination:$,onPaginationChange:Be,onSortChange:_e,sortState:Oe,splitViewEnabled:T,isDynamicInspectorOpen:L,onDynamicInspectorOpenChange:A})}):null,s==="table"&&(B==null?void 0:B.records)&&e.jsxs("div",{className:"relative flex h-full min-h-0 max-w-full flex-1 grow basis-0 px-4 py-4",children:[(z||q)&&(B==null?void 0:B.records)&&e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/50",children:e.jsx(a.LoadingDots,{size:"md",color:"muted","aria-label":"Loading data"})}),e.jsx(a.TableVisual,{card:o,data:ee,resultColumns:B.columns,columnKeyMap:B.columnKeyMap,totalsByColumnId:B==null?void 0:B.tableTotalsByColumnId,comparisonMetadata:U,paginationMetadata:$,onPaginationChange:Be,isLoading:z||q,onSortChange:_e,sortState:Oe})]}),s==="info"&&E&&e.jsx("div",{className:"flex min-h-0 flex-1 flex-col pb-2",children:e.jsx("div",{className:"flex min-h-0 flex-1 flex-col rounded-md bg-background px-1",children:_?e.jsx(So,{error:_,errorSql:Y,showCardDetails:!0,defaultSqlExpanded:!0,debugPayloads:M?{queryRequest:J,queryResponse:B,columns:i,dashboardFilters:x}:void 0,onSendFeedback:()=>{const ae=a.prepareFeedbackData(a.FeedbackCategory.QUERY_GENERATION,{cardConfig:d.config,dataSource:o.dataSource,dashboardFilters:x,errorMessage:_,errorSql:Y,generatedSql:B==null?void 0:B.sql});I(ae),S(!0)},onOpenInEditor:()=>{j(!0),setTimeout(()=>{const ae=t.useEditorStore.getState().actions;ae.setIsDevMode(!0),ae.setCardSql(Y||""),setTimeout(()=>{ae.setRunSql(!0)},100)},100)}}):(B==null?void 0:B.sql)&&e.jsx(wa,{sql:B.sql,showCardDetails:!0,debugPayloads:M?{queryRequest:J,queryResponse:B,columns:i,dashboardFilters:x}:void 0})})})]}),Pe&&o&&Re&&e.jsx(a.ExportDialog,{isOpen:!0,onClose:()=>Me(void 0),card:o,frame:Re,matrix:Pe}),F&&e.jsx(a.FeedbackDialog,{open:w,onOpenChange:S,feedbackData:F})]})})}function zc({activeField:s}){const[n,r]=v.useState(!0);if(v.useEffect(()=>{s&&r(!0)},[s]),!s)return null;const o=a.getCalculatedGlyphKind(s);return e.jsxs("div",{className:`flex h-7 max-w-[300px] items-center gap-2 rounded-[5px] border border-border bg-popover px-3 text-[13px] text-foreground/90 shadow-[0_4px_12px_rgba(0,0,0,0.08)] transition-all duration-150 ${n?"scale-100 opacity-100":"scale-95 opacity-0"}`,children:[e.jsx(a.TypeGlyph,{dataType:s.dataType,calculated:o}),e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:s.label||s.name})]})}const qc=()=>{const s=console.error;console.error=(...o)=>{o.length>0&&typeof o[0]=="string"&&o[0].includes("ResizeObserver loop completed with undelivered notifications")||s.apply(console,o)};const n=o=>{if(o.message&&(o.message.includes("ResizeObserver loop completed with undelivered notifications")||o.message.includes("ResizeObserver loop limit exceeded")))return o.preventDefault(),o.stopPropagation(),!1},r=o=>{var i;if((i=o.reason)!=null&&i.message&&(o.reason.message.includes("ResizeObserver loop completed with undelivered notifications")||o.reason.message.includes("ResizeObserver loop limit exceeded")))return o.preventDefault(),!1};return window.addEventListener("error",n,!0),window.addEventListener("unhandledrejection",r,!0),()=>{console.error=s,window.removeEventListener("error",n,!0),window.removeEventListener("unhandledrejection",r,!0)}};function $c({column:s,isSelected:n,onSelect:r,availableFields:o,width:i,onWidthChange:d}){var B,_;const c=t.useEditorStore(z=>z.card),{updateCardConfig:l,removeGroupByColumn:u,removeMetricColumn:x,updateFilters:m}=t.useEditorActions(),[b,h]=v.useState(!1),[p,j]=v.useState(!1),N=v.useRef(null),f=v.useCallback(z=>{z.preventDefault(),z.stopPropagation(),j(!0),N.current={startX:z.clientX,startWidth:i||150};const q=$=>{if(!N.current)return;const Q=$.clientX-N.current.startX,U=Math.max(80,N.current.startWidth+Q);d==null||d(s.id,U)},Y=()=>{j(!1),N.current=null,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Y)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",Y)},[i,s.id,d]),g=ye.getAuthoredCardFilters(c),k=(B=g==null?void 0:g.conditions)==null?void 0:B.some(z=>z.field.name===s.name&&z.field.qualifiedEntityName===s.qualifiedEntityName),D=z=>{z?m(c.id,z):l(c.id,{filters:void 0})},{attributes:w,listeners:S,setNodeRef:L,transform:A,transition:F,isDragging:I}=a.useSortable({id:s.id}),y={transform:a.CSS.Transform.toString(A),transition:F},E=t.getDataType(s.dataType),M=Kc(E),T=()=>{var Y;const z=((Y=c==null?void 0:c.config)==null?void 0:Y.sortByColumns)||[],q=z.findIndex($=>$.name===s.name);if(q!==-1){const $=[...z];$[q]={...$[q],direction:"asc"},l(c.id,{sortByColumns:$})}else l(c.id,{sortByColumns:[...z,{...s,id:`sort-${s.id}`,role:"sortby",direction:"asc"}]})},R=()=>{var Y;const z=((Y=c==null?void 0:c.config)==null?void 0:Y.sortByColumns)||[],q=z.findIndex($=>$.name===s.name);if(q!==-1){const $=[...z];$[q]={...$[q],direction:"desc"},l(c.id,{sortByColumns:$})}else l(c.id,{sortByColumns:[...z,{...s,id:`sort-${s.id}`,role:"sortby",direction:"desc"}]})},C=()=>{var Y;const z=((Y=c==null?void 0:c.config)==null?void 0:Y.groupByColumns)||[];if(!z.some($=>$.name===s.name)){const $={...s,id:`groupby-${s.id}-${Date.now()}`,role:"groupby"};l(c.id,{groupByColumns:[...z,$]})}},V=z=>{var $;const q=(($=c==null?void 0:c.config)==null?void 0:$.metricColumns)||[];if(!q.some(Q=>Q.name===s.name&&Q.aggregate===z)){const Q={...s,id:`metric-${s.id}-${z}-${Date.now()}`,label:`${z} of ${s.label||s.name}`,role:"metric",aggregate:z,aggregateOrigin:"explicit"};l(c.id,{metricColumns:[...q,Q]})}},P=()=>{s.role==="groupby"?u(c.id,s.id):s.role==="metric"&&x(c.id,s.id)},O={...y,width:i?`${i}px`:void 0,minWidth:i?`${i}px`:"120px"};return e.jsxs("th",{ref:L,style:O,className:t.cn("group relative border-r border-border bg-background px-1 py-0",I&&"opacity-50",n&&"bg-primary/10",p&&"select-none"),children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{...w,...S,className:"cursor-grab p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 active:cursor-grabbing",children:e.jsx(a.GripVertical,{className:"h-3 w-3"})}),e.jsxs(a.DropdownMenu,{children:[e.jsx(a.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("button",{onClick:r,className:t.cn("flex flex-1 items-center justify-between gap-1 rounded px-2 py-2 text-left text-sm font-medium transition-colors hover:bg-muted/50",n&&"bg-primary/10"),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(M,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:s.label||s.name}),s.role==="metric"&&s.aggregate&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.aggregate,")"]}),k&&e.jsx(a.Filter,{className:"h-3 w-3 text-primary"})]}),e.jsx(le.ChevronDown,{className:"h-3 w-3 text-muted-foreground"})]})}),e.jsxs(a.DropdownMenuContent,{align:"start",className:"w-48",children:[e.jsxs(a.DropdownMenuItem,{onClick:()=>h(!0),children:[e.jsx(a.Filter,{className:t.cn("mr-2 h-4 w-4",k&&"text-primary")}),k?"Edit Filter":"Filter"]}),e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:T,children:[e.jsx(gr,{className:"mr-2 h-4 w-4"}),"Sort A → Z"]}),e.jsxs(a.DropdownMenuItem,{onClick:R,children:[e.jsx(fr,{className:"mr-2 h-4 w-4"}),"Sort Z → A"]}),e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuSub,{children:[e.jsxs(a.DropdownMenuSubTrigger,{children:[e.jsx(a.Calculator,{className:"mr-2 h-4 w-4"}),"Summarize"]}),e.jsxs(a.DropdownMenuSubContent,{children:[e.jsx(a.DropdownMenuItem,{onClick:()=>V("SUM"),children:"Sum"}),e.jsx(a.DropdownMenuItem,{onClick:()=>V("AVG"),children:"Average"}),e.jsx(a.DropdownMenuItem,{onClick:()=>V("COUNT"),children:"Count"}),e.jsx(a.DropdownMenuItem,{onClick:()=>V("DISTINCT"),children:"Count Distinct"}),e.jsx(a.DropdownMenuItem,{onClick:()=>V("MIN"),children:"Min"}),e.jsx(a.DropdownMenuItem,{onClick:()=>V("MAX"),children:"Max"})]})]}),e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{onClick:C,children:[e.jsx(a.Rows3,{className:"mr-2 h-4 w-4"}),"Group by this column"]}),e.jsxs(a.DropdownMenuItem,{disabled:!0,children:[e.jsx(Ds,{className:"mr-2 h-4 w-4"}),"Pivot by this column"]}),e.jsx(a.DropdownMenuSeparator,{}),e.jsxs(a.DropdownMenuItem,{disabled:!0,children:[e.jsx(a.EyeOff,{className:"mr-2 h-4 w-4"}),"Hide column"]}),e.jsxs(a.DropdownMenuItem,{onClick:P,className:"text-destructive focus:text-destructive",children:[e.jsx(a.Trash2,{className:"mr-2 h-4 w-4"}),"Remove column"]})]})]})]}),e.jsx("div",{onMouseDown:f,className:t.cn("absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent hover:bg-primary/50",p&&"bg-primary")}),e.jsx(Ra,{open:b,onOpenChange:h,availableFields:o.length>0?o:[s],existingFilters:g,editingCondition:k?(_=g==null?void 0:g.conditions)==null?void 0:_.find(z=>z.field.name===s.name&&z.field.qualifiedEntityName===s.qualifiedEntityName):void 0,onSave:D})]})}function Kc(s){switch(s){case"number":return a.Hash;case"date":return a.Calendar;case"string":default:return t.Type}}function Uc({selectedColumn:s,onColumnSelect:n,isLoading:r=!1,sourceFields:o=[],filterableFields:i=o}){var I,y,E,M;const d=t.useEditorStore(T=>T.card),{updateCardConfig:c}=t.useEditorActions(),[l,u]=v.useState(null),[x,m]=v.useState({}),[b,h]=v.useState(!1),p=v.useMemo(()=>{var C,V;const T=((C=d==null?void 0:d.config)==null?void 0:C.groupByColumns)||[],R=((V=d==null?void 0:d.config)==null?void 0:V.metricColumns)||[];return[...T,...R]},[(I=d==null?void 0:d.config)==null?void 0:I.groupByColumns,(y=d==null?void 0:d.config)==null?void 0:y.metricColumns]),j=v.useMemo(()=>{const T=new Set(p.map(R=>`${R.qualifiedEntityName}.${R.name}`));return o.filter(R=>!T.has(`${R.qualifiedEntityName}.${R.name}`))},[o,p]),{data:N,isLoading:f}=a.useEditorCardQuery(d),g=(N==null?void 0:N.records)||[],k=v.useCallback((T,R)=>{m(C=>({...C,[T]:R}))},[]),D=v.useCallback(T=>{var P,O;const R=t.getDataType(T.dataType),C=((P=d==null?void 0:d.config)==null?void 0:P.groupByColumns)||[],V=((O=d==null?void 0:d.config)==null?void 0:O.metricColumns)||[];if(R==="number"){const B=a.getNewField(T,"metrics",[...C,...V]);c(d.id,{metricColumns:[...V,B]})}else{const B=a.getNewField(T,"groupBy",[...C,...V]);c(d.id,{groupByColumns:[...C,B]})}h(!1)},[(E=d==null?void 0:d.config)==null?void 0:E.groupByColumns,(M=d==null?void 0:d.config)==null?void 0:M.metricColumns,d.id,c]),w=a.useSensors(a.useSensor(a.PointerSensor,{activationConstraint:{distance:8}})),S=T=>{u(T.active.id)},L=T=>{const{active:R,over:C}=T;if(u(null),!C||R.id===C.id)return;const V=p.findIndex(O=>O.id===R.id),P=p.findIndex(O=>O.id===C.id);if(V!==-1&&P!==-1){const O=a.arrayMove(p,V,P),B=O.filter(z=>z.role==="groupby"),_=O.filter(z=>z.role==="metric");c(d.id,{groupByColumns:B,metricColumns:_})}},A=l?p.find(T=>T.id===l):null,F=T=>{let R="";for(;T>=0;)R=String.fromCharCode(T%26+65)+R,T=Math.floor(T/26)-1;return R};return r?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(t.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"})}):p.length===0?e.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8 text-center",children:e.jsxs("div",{className:"rounded-lg border-2 border-dashed border-muted-foreground/25 p-12",children:[e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No columns selected"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground/75",children:"Select columns from the panel on the right to build your table"})]})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs(a.DndContext,{sensors:w,collisionDetection:a.closestCenter,onDragStart:S,onDragEnd:L,children:[e.jsxs("table",{className:"w-full border-collapse",children:[e.jsxs("thead",{children:[e.jsxs("tr",{className:"border-b border-border bg-muted/30",children:[e.jsx("th",{className:"sticky left-0 z-20 w-12 border-r border-border bg-muted/50 px-2 py-1 text-center text-xs font-medium text-muted-foreground"}),e.jsx(a.SortableContext,{items:p.map(T=>T.id),strategy:a.horizontalListSortingStrategy,children:p.map((T,R)=>e.jsx("th",{style:{width:x[T.id]?`${x[T.id]}px`:void 0,minWidth:x[T.id]?`${x[T.id]}px`:"120px"},className:"border-r border-border bg-muted/30 px-2 py-1 text-center text-xs font-medium text-muted-foreground",children:F(R)},`letter-${T.id}`))}),e.jsx("th",{className:"w-10 border-r border-border bg-muted/30 px-2 py-1"})]}),e.jsxs("tr",{className:"border-b-2 border-border bg-background",children:[e.jsx("th",{className:"sticky left-0 z-20 w-12 border-r border-border bg-muted/50 px-2 py-2 text-center text-xs font-medium text-muted-foreground",children:"#"}),e.jsx(a.SortableContext,{items:p.map(T=>T.id),strategy:a.horizontalListSortingStrategy,children:p.map(T=>e.jsx($c,{column:T,isSelected:(s==null?void 0:s.id)===T.id,onSelect:()=>n(T),availableFields:i,width:x[T.id],onWidthChange:k},T.id))}),e.jsx("th",{className:"w-10 border-r border-border bg-background px-1 py-2",children:e.jsxs(t.Popover,{open:b,onOpenChange:h,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",title:"Add column",children:e.jsx(a.Plus,{className:"h-4 w-4"})})}),e.jsx(t.PopoverContent,{className:"w-[280px] p-0",align:"start",children:e.jsxs(a.Command,{children:[e.jsx(a.CommandInput,{placeholder:"Search columns..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No columns available."}),e.jsx(a.CommandGroup,{heading:"Available Columns",children:j.map(T=>{const R=t.getDataType(T.dataType),C=R==="number"?a.Hash:R==="date"?a.Calendar:t.Type;return e.jsxs(a.CommandItem,{value:T.label||T.name,onSelect:()=>D(T),children:[e.jsx(C,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm",children:T.label||T.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T.entityName})]})]},T.id)})})]})]})})]})})]})]}),e.jsx("tbody",{children:f?e.jsx("tr",{children:e.jsx("td",{colSpan:p.length+2,className:"h-32 text-center",children:e.jsx(t.LoaderCircle,{className:"mx-auto h-6 w-6 animate-spin text-muted-foreground"})})}):g.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:p.length+2,className:"h-32 text-center text-muted-foreground",children:"No data available"})}):g.slice(0,100).map((T,R)=>e.jsxs("tr",{className:t.cn("border-b border-border transition-colors hover:bg-muted/50",R%2===0?"bg-background":"bg-muted/20"),children:[e.jsx("td",{className:"sticky left-0 z-10 w-12 border-r border-border bg-muted/50 px-2 py-2 text-center text-xs font-medium text-muted-foreground",children:R+1}),p.map(C=>{const V=T[C.name]??T[C.label??""];return e.jsx("td",{style:{width:x[C.id]?`${x[C.id]}px`:void 0,minWidth:x[C.id]?`${x[C.id]}px`:"120px"},className:t.cn("border-r border-border px-3 py-2 text-sm",(s==null?void 0:s.id)===C.id&&"bg-primary/5"),children:e.jsx("span",{className:"block truncate",children:Gc(V,C)})},`${R}-${C.id}`)}),e.jsx("td",{className:"w-10 border-r border-border"})]},R))})]}),e.jsx(a.DragOverlay,{children:A&&e.jsx("div",{className:"rounded border border-primary bg-background px-3 py-2 text-sm font-medium shadow-lg",children:A.label||A.name})})]})}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-muted/30 px-4 py-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",Math.min(g.length,100)," of ",g.length," rows"]}),e.jsxs("span",{children:[p.length," columns"]})]})]})}function Gc(s,n){if(s==null)return"—";if(typeof s=="number")return n.role==="metric"?new Intl.NumberFormat("en-US",{minimumFractionDigits:0,maximumFractionDigits:2}).format(s):s.toString();if(s instanceof Date||typeof s=="string"&&!isNaN(Date.parse(s))){const r=new Date(s);if(!isNaN(r.getTime()))return r.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}return String(s)}function Hc({entityGroups:s,isLoading:n=!1}){var D,w;const r=t.useEditorStore(S=>S.card),{updateCardConfig:o,removeGroupByColumn:i,removeMetricColumn:d}=t.useEditorActions(),[c,l]=v.useState(!0),[u,x]=v.useState(""),[m,b]=v.useState(new Set),h=((D=r==null?void 0:r.config)==null?void 0:D.groupByColumns)||[],p=((w=r==null?void 0:r.config)==null?void 0:w.metricColumns)||[],j=S=>{const L=new Set(m);L.has(S)?L.delete(S):L.add(S),b(L)},N=S=>h.some(L=>L.name===S.name&&L.qualifiedEntityName===S.qualifiedEntityName)||p.some(L=>L.name===S.name&&L.qualifiedEntityName===S.qualifiedEntityName),f=(S,L)=>{if(L)if(t.getDataType(S.dataType)==="number"){const F=a.getNewField(S,"metrics",[...h,...p]);o(r.id,{metricColumns:[...p,F]})}else{const F=a.getNewField(S,"groupBy",[...h,...p]);o(r.id,{groupByColumns:[...h,F]})}else{const A=h.findIndex(I=>I.name===S.name&&I.qualifiedEntityName===S.qualifiedEntityName),F=p.findIndex(I=>I.name===S.name&&I.qualifiedEntityName===S.qualifiedEntityName);A!==-1&&i(r.id,h[A].id),F!==-1&&d(r.id,p[F].id)}},g=S=>{if(!u)return S;const L=u.toLowerCase();return S.filter(A=>A.name.toLowerCase().includes(L)||A.label&&A.label.toLowerCase().includes(L))},k=S=>{switch(t.getDataType(S)){case"number":return a.Hash;case"date":return a.Calendar;default:return t.Type}};return c?e.jsxs("div",{className:"flex h-full w-72 flex-col border-l border-border bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Columns"}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:()=>l(!1),title:"Close panel",children:e.jsx(Ir,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"border-b border-border p-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(qe.Search,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(t.Input,{placeholder:"Search columns...",value:u,onChange:S=>x(S.target.value),className:"h-8 pl-8 text-sm"})]})}),(h.length>0||p.length>0)&&e.jsxs("div",{className:"border-b border-border",children:[h.length>0&&e.jsxs(a.Collapsible,{defaultOpen:!0,children:[e.jsxs(a.CollapsibleTrigger,{className:"flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-muted/50",children:[e.jsx(qe.ChevronRight,{className:"h-3.5 w-3.5 transition-transform duration-200 [[data-state=open]>&]:rotate-90"}),e.jsx(a.Rows3,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsx("span",{children:"Groupings"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:h.length})]}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"space-y-0.5 px-3 pb-2",children:h.map(S=>{const L=k(S.dataType);return e.jsxs("div",{className:"group flex items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[e.jsx(a.GripVertical,{className:"h-3 w-3 cursor-grab text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100"}),e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate",children:S.label||S.name}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>i(r.id,S.id),children:e.jsx(le.X,{className:"h-3 w-3"})})]},S.id)})})})]}),p.length>0&&e.jsxs(a.Collapsible,{defaultOpen:!0,children:[e.jsxs(a.CollapsibleTrigger,{className:"flex w-full items-center gap-2 px-3 py-2 text-sm font-medium hover:bg-muted/50",children:[e.jsx(qe.ChevronRight,{className:"h-3.5 w-3.5 transition-transform duration-200 [[data-state=open]>&]:rotate-90"}),e.jsx(a.Calculator,{className:"h-3.5 w-3.5 text-green-500"}),e.jsx("span",{children:"Metrics"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:p.length})]}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"space-y-0.5 px-3 pb-2",children:p.map(S=>{const L=k(S.dataType);return e.jsxs("div",{className:"group flex items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/50",children:[e.jsx(a.GripVertical,{className:"h-3 w-3 cursor-grab text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100"}),e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate",children:S.label||S.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:S.aggregate}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>d(r.id,S.id),children:e.jsx(le.X,{className:"h-3 w-3"})})]},S.id)})})})]})]}),e.jsx(t.ScrollArea,{className:"flex-1",children:e.jsx("div",{className:"p-2",children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}):s.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No columns available"}):s.map(S=>{const L=g(S.columns);if(L.length===0)return null;const A=m.has(S.entityId)||u.length>0;return e.jsxs(a.Collapsible,{open:A,onOpenChange:()=>j(S.entityId),children:[e.jsxs(a.CollapsibleTrigger,{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm font-medium hover:bg-muted/50",children:[e.jsx(qe.ChevronRight,{className:t.cn("h-3.5 w-3.5 transition-transform duration-200",A&&"rotate-90")}),e.jsx(t.Table2,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-left",children:S.label||S.entityName}),e.jsx("span",{className:"text-xs text-muted-foreground",children:L.length})]}),e.jsx(a.CollapsibleContent,{children:e.jsx("div",{className:"ml-4 space-y-0.5 border-l border-border pl-2",children:L.map(F=>{const I=k(F.dataType),y=N(F);return e.jsxs("label",{className:t.cn("flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm transition-colors hover:bg-muted/50",y&&"bg-primary/5"),children:[e.jsx(a.Checkbox,{checked:y,onCheckedChange:E=>f(F,E),className:"h-3.5 w-3.5"}),e.jsx(I,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate",children:F.label||F.name})]},F.id)})})})]},S.entityId)})})})]}):e.jsx("div",{className:"flex h-full items-start border-l border-border bg-muted/30 p-2",children:e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>l(!0),title:"Open panel",children:e.jsx(Dr,{className:"h-4 w-4"})})})}const Qc=[{name:"SUM",description:"Sum of values",syntax:"SUM([column])"},{name:"AVG",description:"Average of values",syntax:"AVG([column])"},{name:"COUNT",description:"Count of rows",syntax:"COUNT([column])"},{name:"COUNTD",description:"Count distinct values",syntax:"COUNTD([column])"},{name:"MIN",description:"Minimum value",syntax:"MIN([column])"},{name:"MAX",description:"Maximum value",syntax:"MAX([column])"},{name:"IF",description:"Conditional logic",syntax:"IF(condition, then, else)"},{name:"CASE",description:"Multiple conditions",syntax:"CASE WHEN ... THEN ... END"},{name:"CONCAT",description:"Concatenate text",syntax:"CONCAT([col1], [col2])"},{name:"ROUND",description:"Round number",syntax:"ROUND([column], decimals)"},{name:"FLOOR",description:"Round down",syntax:"FLOOR([column])"},{name:"CEIL",description:"Round up",syntax:"CEIL([column])"},{name:"ABS",description:"Absolute value",syntax:"ABS([column])"},{name:"DATEPART",description:"Extract date part",syntax:"DATEPART(year, [date])"},{name:"DATEDIFF",description:"Difference between dates",syntax:"DATEDIFF(day, [date1], [date2])"}];function Jc({value:s,onChange:n,onSubmit:r,onCancel:o,selectedColumn:i,availableColumns:d}){const[c,l]=v.useState(!1),[u,x]=v.useState("column"),m=v.useRef(null);v.useEffect(()=>{const j=N=>{N.key==="Escape"&&s?o():N.key==="Enter"&&s&&!c&&r(s)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[s,o,r,c]);const b=j=>{const N=`[${j.label||j.name}]`,f=m.current;if(f){const g=f.selectionStart||0,k=f.selectionEnd||0,D=s.slice(0,g)+N+s.slice(k);n(D),setTimeout(()=>{f.setSelectionRange(g+N.length,g+N.length),f.focus()},0)}else n(s+N);l(!1)},h=j=>{const N=m.current;if(N){const f=N.selectionStart||0,g=N.selectionEnd||0,k=s.slice(0,f)+j.syntax+s.slice(g);n(k),setTimeout(()=>{N.setSelectionRange(f+j.name.length+1,f+j.syntax.length-1),N.focus()},0)}else n(s+j.syntax);l(!1)},p=j=>{switch(t.getDataType(j)){case"number":return a.Hash;case"date":return a.Calendar;default:return t.Type}};return e.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5",children:[e.jsx("div",{className:"flex min-w-[100px] items-center justify-center rounded border border-border bg-background px-2 py-1 text-xs font-medium text-muted-foreground",children:i?e.jsx("span",{className:"truncate",children:i.label||i.name}):e.jsx("span",{children:"—"})}),e.jsxs(t.Popover,{open:c&&u==="function",onOpenChange:j=>{l(j),j&&x("function")},children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",title:"Insert function",children:e.jsx(Lr,{className:"h-4 w-4"})})}),e.jsx(t.PopoverContent,{className:"w-[300px] p-0",align:"start",children:e.jsxs(a.Command,{children:[e.jsx(a.CommandInput,{placeholder:"Search functions..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No functions found."}),e.jsx(a.CommandGroup,{heading:"Functions",children:Qc.map(j=>e.jsx(a.CommandItem,{value:j.name,onSelect:()=>h(j),children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:j.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j.description})]}),e.jsx("span",{className:"font-mono text-xs text-muted-foreground/75",children:j.syntax})]})},j.name))})]})]})})]}),e.jsxs(t.Popover,{open:c&&u==="column",onOpenChange:j=>{l(j),j&&x("column")},children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs text-muted-foreground hover:text-foreground",title:"Insert column reference",children:[e.jsx("span",{children:"Columns"}),e.jsx(le.ChevronDown,{className:"h-3 w-3"})]})}),e.jsx(t.PopoverContent,{className:"w-[250px] p-0",align:"start",children:e.jsxs(a.Command,{children:[e.jsx(a.CommandInput,{placeholder:"Search columns..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No columns found."}),e.jsx(a.CommandGroup,{heading:"Available Columns",children:d.map(j=>{const N=p(j.dataType);return e.jsxs(a.CommandItem,{value:j.label||j.name,onSelect:()=>b(j),children:[e.jsx(N,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:j.label||j.name})]},j.id)})})]})]})})]}),e.jsx("div",{className:"relative flex-1",children:e.jsx(t.Input,{ref:m,value:s,onChange:j=>n(j.target.value),placeholder:"Enter a formula or select a column...",className:"h-7 border-border bg-background font-mono text-sm"})}),s&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:o,title:"Cancel (Esc)",children:e.jsx(le.X,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-green-600 hover:bg-green-600/10 hover:text-green-600",onClick:()=>r(s),title:"Apply (Enter)",children:e.jsx(t.Check,{className:"h-4 w-4"})})]})]})}function Wc({className:s}){var p,j,N,f;const n=t.useEditorStore(g=>g.card),[r,o]=v.useState(null),[i,d]=v.useState(""),{columns:c=[],columnGroups:l=[],isLoading:u}=a.useColumns(),{valuePickFilterableFields:x=[]}=a.useFilterableFields();(p=n==null?void 0:n.config)!=null&&p.groupByColumns,(j=n==null?void 0:n.config)!=null&&j.metricColumns,(N=n==null?void 0:n.config)!=null&&N.groupByColumns,(f=n==null?void 0:n.config)!=null&&f.pivotByColumns;const m=g=>{o(g),d(g?`[${g.label||g.name}]`:"")},b=g=>{console.log("Formula submitted:",g),d(""),o(null)},h=()=>{d(""),o(null)};return e.jsxs("div",{className:t.cn("flex h-full w-full flex-col",s),children:[e.jsx(Jc,{value:i,onChange:d,onSubmit:b,onCancel:h,selectedColumn:r,availableColumns:c}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(Uc,{selectedColumn:r,onColumnSelect:m,isLoading:u,sourceFields:c,filterableFields:x})}),e.jsx(Hc,{entityGroups:l,isLoading:u})]})]})}function Xc(){const[s,n]=v.useState("chart"),[r,o]=v.useState(!1),[i,d]=v.useState(!0),[c,l]=v.useState(!0),u=t.useEditorStore(Y=>Y.showAIDialog),x=t.useDashboardStore(Y=>Y.isVisualEditing),{setCardType:m}=t.useEditorActions(),b=t.useEditorStore(Y=>Y.card.type);v.useEffect(()=>qc(),[]);const h=Y=>{m(Y)},p=t.useEditorStore(Y=>Y.frame),j=t.useEditorStore(Y=>Y.card);t.useEditorStore(Y=>Y.activeTabCardId),t.useEditorStore(Y=>Y.actions.getAvailableFields);const{addCard:N,removeCard:f,updateCard:g,setActiveCard:k,updateFilters:D,clearFilters:w}=t.useEditorActions(),{columnFields:S=[],scopedFields:L=[],filterableFields:A=[]}=a.useFilterableFields(),F=a.useSensors(a.useSensor(a.PointerSensor,{activationConstraint:{distance:8}})),I=j,{getFieldsForContainer:y,setFieldsForContainer:E,moveField:M,removeField:T,resetFields:R}=a.useFieldManagement(I,L),{activeField:C,handleDragStart:V,handleDragEnd:P}=kc({activeCardId:p.activeCardId,sourceFields:L,getFieldsForContainer:y,setFieldsForContainer:E,moveField:M}),O=(Y,$)=>{$&&D(Y,$)},B=Y=>{w(Y)},_=A,z=Y=>{if(!Y)return 0;let $=Y.conditions.length;return Y.groups.forEach(Q=>{$+=z(Q)}),$},q=z(ye.getAuthoredCardFilters(I)||null);return e.jsxs(a.DndContext,{sensors:F,collisionDetection:a.closestCenter,onDragStart:V,onDragEnd:P,children:[e.jsxs("div",{className:"flex h-full grow",children:[e.jsx(oa,{isVisible:i,onToggleVisibility:()=>d(!i)}),e.jsx("div",{className:"flex flex-1 transition-all duration-300 ease-in-out",children:b==="tableBuilder"?e.jsx(Wc,{className:"flex-1"}):e.jsxs(e.Fragment,{children:[!u&&e.jsx(xc,{onRemoveField:T,onResetFields:R,selectedChart:b,onChartChange:h,groupByFields:y("groupBy"),pivotByFields:y("pivotBy"),metricsFields:y("metrics"),sortByFields:y("sortBy"),detailFields:y("detailColumns"),activeField:C,isVisible:c,onToggleVisibility:()=>l(!c)}),e.jsx(Yc,{selectedChart:b,activeView:s,onViewChange:n,onFiltersClick:()=>o(!0),filterCount:q,activeCard:I,columns:S,getFieldsForContainer:y,cards:p.cards,activeCardId:p.activeCardId,addCard:N,setActiveCard:k})]})}),!i&&x&&e.jsx("div",{className:"fixed left-6 top-[105px] z-50",children:e.jsx(t.Button,{size:"sm",variant:"outline",className:"h-10 w-10 rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted",onClick:()=>d(!0),title:"Show Data Source Panel",children:e.jsx(a.Database,{className:"h-4 w-4"})})})]}),I&&e.jsx(Dc,{cardId:I.id,filters:ye.getAuthoredCardFilters(I)||null,onFiltersChange:O,onClearFilters:B,availableFields:_,isOpen:r,onOpenChange:o}),e.jsx(a.DragOverlay,{dropAnimation:null,children:e.jsx(zc,{activeField:C||null})})]})}function Zc({authToken:s,onSave:n,onClose:r}){const o=v.useRef(null),i=t.useEditorStore(A=>A.showAIDialog),d=t.useEditorStore(A=>A.isDevMode),c=a.useAssistantLayoutStore(A=>A.setFullscreen),l=a.useAssistantLayoutStore(A=>A.setPanelOpen),u=a.useAssistantLayoutStore(A=>A.setContainer),x=a.useAssistantPanel("editor"),m=a.useFullscreenAssistant(),b=a.useAssistantContainer("editor"),h=m==="editor",p=a.useDashboardAppearance(),j=v.useCallback(A=>{u("editor",A)},[u]),{setAuthToken:N}=t.useDashboardActions(),{setShowAIDialog:f,setOnSave:g,setOnClose:k}=t.useEditorActions(),{setActiveAssistantType:D}=t.useAIActions();v.useEffect(()=>{n&&g(n),r&&k(r)},[n,g,r,k]),v.useEffect(()=>{s&&s.accessToken&&N(s)},[s,N]),v.useEffect(()=>{var A,F;i?((A=o.current)==null||A.resize(40),l("editor",!0),D("editor")):((F=o.current)==null||F.resize(0),l("editor",!1),m==="editor"&&c(null),D(null))},[i,l,D,c,m]);function w(A){var F;A<1?(f(!1),l("editor",!1),m==="editor"&&c(null),D(null),(F=o.current)==null||F.resize(0)):(i||(f(!0),D("editor")),x.isOpen||l("editor",!0))}function S(){return e.jsxs(e.Fragment,{children:[e.jsx(oa,{isVisible:!0,onToggleVisibility:()=>{}}),e.jsxs("div",{className:"relative flex grow",children:[e.jsxs(a.ResizablePanelGroup,{"data-content":"editor-main",className:t.cn("grow transition-opacity",h&&"pointer-events-none opacity-0"),direction:"horizontal",children:[e.jsx(a.ResizablePanel,{className:"min-w-[510px] rounded-none",children:e.jsx(Vi,{})}),e.jsx(a.ResizableHandle,{disabled:!i}),e.jsx(a.ResizablePanel,{"data-role":"editor-assistant-panel",ref:o,onResize:w,defaultSize:x.isOpen?40:0,className:"flex",children:e.jsx("div",{className:"grow overflow-y-auto",children:e.jsx(Xn,{isFullscreen:h,onFullscreenChange:A=>c(A?"editor":null),fullscreenContainer:b})})})]}),e.jsx("div",{ref:j,className:t.cn("absolute inset-0",!h&&"pointer-events-none")})]})]})}function L(){return e.jsxs("div",{className:"relative flex h-full grow",children:[e.jsxs(a.ResizablePanelGroup,{"data-content":"explorer",className:t.cn("flex grow transition-opacity",h&&"pointer-events-none opacity-0"),direction:"horizontal",children:[e.jsx(a.ResizablePanel,{className:"min-w-[510px] grow rounded-none",children:e.jsx(Xc,{})}),e.jsx(a.ResizableHandle,{disabled:!i}),e.jsx(a.ResizablePanel,{"data-role":"editor-assistant-panel",ref:o,onResize:w,defaultSize:x.isOpen?40:0,className:"flex",children:e.jsx("div",{className:"grow overflow-y-auto",children:e.jsx(Xn,{isFullscreen:h,onFullscreenChange:A=>c(A?"editor":null),fullscreenContainer:b})})})]}),e.jsx("div",{ref:j,className:t.cn("absolute inset-0",!h&&"pointer-events-none")})]})}return e.jsx(a.ErrorBoundary,{FallbackComponent:a.Fallback,children:d?e.jsx("section",{className:"isolate flex h-full grow","data-content":"editor-panel",style:p.dashboardContainerStyle,children:S()}):e.jsx("section",{className:"isolate flex h-full grow","data-content":"editor-panel",style:p.dashboardContainerStyle,children:L()})})}function ed(){t.useDashboardStore(p=>p.selectedCardId);const s=t.useDashboardStore(p=>p.selectedSheetId),n=t.useDashboardStore(p=>p.dashboard),{setIsVisualEditing:r,setSelectedSheetId:o}=t.useDashboardStore(p=>p.actions),i=t.useEditorStore(p=>p.editorContext),{clearEditorContext:d}=t.useEditorStore(p=>p.actions),c=a.useDashboardAppearance(),l=t.useDashboardStore(p=>p.isVisualEditing),u=t.useDashboardStore(p=>p.actions.updateFrame),x=t.useDashboardStore(p=>p.actions.updateDocumentSectionCard),m=a.useResolveExistingFrameSemanticExecutionPayload();async function b(p){var k,D,w;if((i==null?void 0:i.type)==="documentSection"){const S=a.getDocumentSectionEditorCard(p,i.cardId);if(!S){t.ue.error("No document section card found");return}if(!a.isSupportedDocumentTableCardType(S)){t.ue.error("Document table sections support Table and Pivot Table");return}x(i.sheetId,i.sectionId,S,{calculatedFields:p.calculatedFields}),d(),r(!1);return}const j=s?(k=n==null?void 0:n.sheets)==null?void 0:k.some(S=>{var L;return S.id===s&&((L=S.frames)==null?void 0:L.some(A=>A.id===p.id))}):!1,N=(w=(D=n==null?void 0:n.sheets)==null?void 0:D.find(S=>{var L;return(L=S.frames)==null?void 0:L.some(A=>A.id===p.id)}))==null?void 0:w.id,f=j?s:N||null;if(!f)return;const g=t.findDashboardFrameById(n,p.id);try{const S=await m(p,{previousFrame:g});u(f,p,{semanticExecutionPayload:S}),s!==f&&o(f),r(!1)}catch(S){console.error("Failed to resolve semantic metadata on save:",S),t.ue.error(S instanceof Error?S.message:"Failed to resolve semantic metadata for this visual")}}function h(){d(),r(!1)}return e.jsx("div",{role:"editor-container",className:t.cn("flex-1 grow basis-0 overflow-auto",{"max-h-0 overflow-hidden":!l}),style:c.dashboardContainerStyle,children:e.jsx(Zc,{onSave:b,onClose:h})})}exports.default=ed;
|