import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import { memo, useCallback } from "react";
import cx from "classnames";
import { usePropState } from "@gooddata/sdk-ui";
import { Checkbox } from "../Form/Checkbox.js";
import { useIdPrefixed } from "../utils/useId.js";
import { ConfirmDialogBase } from "./ConfirmDialogBase.js";
/**
 * @internal
 */
export const ExportDialogBase = memo(function ExportDialogBase({ className, displayCloseButton = true, isPositive = true, isSubmitDisabled = false, headline = "Export to XLSX", cancelButtonText = "Cancel", submitButtonText = "Export", onCancel = () => { }, onSubmit = () => { }, filterContextText = "Include applied filters", filterContextTitle = "INSIGHT CONTEXT", filterContextVisible = true, mergeHeadersDisabled = false, mergeHeadersText = "Keep attribute cells merged", mergeHeadersTitle = "CELLS", includeFilterContext = true, mergeHeaders = true, }) {
    const effectiveIncludeFilterContext = filterContextVisible ? includeFilterContext : false;
    const [isFilterContextIncluded, setIsFilterContextIncluded] = usePropState(effectiveIncludeFilterContext);
    const [shouldMergeHeaders, setShouldMergeHeaders] = usePropState(mergeHeaders);
    const dialogId = useIdPrefixed("exportDialog");
    const mergeHeadersId = useIdPrefixed("mergeHeaders");
    const filterContextId = useIdPrefixed("filterContext");
    const handleSubmit = useCallback(() => {
        onSubmit({
            includeFilterContext: isFilterContextIncluded,
            mergeHeaders: shouldMergeHeaders,
        });
    }, [isFilterContextIncluded, onSubmit, shouldMergeHeaders]);
    return (_jsxs(ConfirmDialogBase, { className: cx("gd-export-dialog", className), displayCloseButton: displayCloseButton, isPositive: isPositive, isSubmitDisabled: isSubmitDisabled, headline: headline, cancelButtonText: cancelButtonText, submitButtonText: submitButtonText, onCancel: onCancel, onSubmit: handleSubmit, autofocusOnOpen: true, accessibilityConfig: {
            dialogId,
        }, children: [
            _jsxs("div", { className: "gd-export-dialog-item", children: [mergeHeadersTitle ? _jsx("h4", { children: mergeHeadersTitle }) : null, _jsx(Checkbox, { id: mergeHeadersId, disabled: mergeHeadersDisabled, name: "gs.dialog.export.checkbox.mergeHeaders", text: mergeHeadersText, value: shouldMergeHeaders, onChange: setShouldMergeHeaders, labelSize: "normal" })
                ] }), filterContextVisible ? (_jsxs("div", { className: "gd-export-dialog-item", children: [filterContextTitle ? _jsx("h4", { children: filterContextTitle }) : null, _jsx(Checkbox, { id: filterContextId, name: "gs.dialog.export.checkbox.includeFilterContext", text: filterContextText, value: isFilterContextIncluded, onChange: setIsFilterContextIncluded, labelSize: "normal" })
                ] })) : null] }));
});
