/**
 * DevExtreme (cjs/exporter.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.export = _export;
Object.defineProperty(exports, "fileSaver", {
    enumerable: true,
    get: function() {
        return _file_saver.fileSaver
    }
});
exports.svg = exports.pdf = exports.image = void 0;
var _file_saver = require("./exporter/file_saver");
var _image_creator = require("./exporter/image_creator");
var _svg_creator = require("./exporter/svg_creator");
var _type = require("./core/utils/type");
var _deferred = require("./core/utils/deferred");
var _pdf_creator = require("./exporter/pdf_creator");

function _export(data, options, getData) {
    if (!data) {
        return (new _deferred.Deferred).resolve()
    }
    const exportingAction = options.exportingAction;
    const exportedAction = options.exportedAction;
    const fileSavingAction = options.fileSavingAction;
    const eventArgs = {
        fileName: options.fileName,
        format: options.format,
        cancel: false
    };
    if ((0, _type.isBoolean)(options.selectedRowsOnly)) {
        eventArgs.selectedRowsOnly = options.selectedRowsOnly
    }(0, _type.isFunction)(exportingAction) && exportingAction(eventArgs);
    if (!eventArgs.cancel) {
        return getData(data, options).then(blob => {
            (0, _type.isFunction)(exportedAction) && exportedAction();
            if ((0, _type.isFunction)(fileSavingAction)) {
                eventArgs.data = blob;
                fileSavingAction(eventArgs)
            }
            if (!eventArgs.cancel) {
                const format = "xlsx" === options.format ? "EXCEL" : options.format;
                _file_saver.fileSaver.saveAs(eventArgs.fileName, format, blob)
            }
        })
    }
    return (new _deferred.Deferred).resolve()
}
const image = {
    creator: _image_creator.imageCreator,
    getData: _image_creator.getData,
    testFormats: _image_creator.testFormats
};
exports.image = image;
const pdf = {
    getData: _pdf_creator.getData
};
exports.pdf = pdf;
const svg = {
    creator: _svg_creator.svgCreator,
    getData: _svg_creator.getData
};
exports.svg = svg;
