const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_utils = require("./utils.js");
//#region src/components/table/serve.ts
const defaultUrl = {
	export: "/shop/form/data/export",
	import: "/shop/form/data/import",
	export_file: "/shop/form/data/task?type=export",
	import_log: "/shop/form/data/task?type=import",
	template: "/shop/form/data/download-template"
};
/**
* @title: 格式化接口地址参数
* @description: 
* @param {any} params
* @return {*}
* @Author: WangHan
* @Date: 2024-09-05 12:01
*/
const formatApiParams = (params, type) => {
	if (params instanceof FormData) {
		let url = params.get("url");
		params.delete("url");
		return {
			url: url || (defaultUrl === null || defaultUrl === void 0 ? void 0 : defaultUrl[type]),
			params
		};
	}
	const _url = (params === null || params === void 0 ? void 0 : params.url) || (defaultUrl === null || defaultUrl === void 0 ? void 0 : defaultUrl[type]);
	let _params = require_objectSpread2._objectSpread2({}, params);
	delete _params.url;
	if (type !== "export") {
		_params === null || _params === void 0 || delete _params.shipping_status;
		_params === null || _params === void 0 || delete _params.payment_status;
		_params === null || _params === void 0 || delete _params.status;
	}
	return {
		url: _url,
		params: require_objectSpread2._objectSpread2({}, _params)
	};
};
const exportData = (params) => {
	const _params = formatApiParams(params, "export");
	return require_utils.request.getRequest().post(_params === null || _params === void 0 ? void 0 : _params.url, _params === null || _params === void 0 ? void 0 : _params.params);
};
const batchImport = (params) => {
	const _params = formatApiParams(params, "import");
	return require_utils.request.getRequest().post(_params === null || _params === void 0 ? void 0 : _params.url, params);
};
const importTemplate = (params) => {
	const _params = formatApiParams(params, "template");
	return require_utils.request.getRequest().post(_params === null || _params === void 0 ? void 0 : _params.url, _params === null || _params === void 0 ? void 0 : _params.params);
};
const getExportFile = function() {
	var _ref = require_asyncToGenerator._asyncToGenerator(function* (params) {
		const _params = formatApiParams(params, "export_file");
		return yield require_utils.request.getRequest().get(_params === null || _params === void 0 ? void 0 : _params.url, _params === null || _params === void 0 ? void 0 : _params.params);
	});
	return function getExportFile(_x) {
		return _ref.apply(this, arguments);
	};
}();
const getImportLog = function() {
	var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (params) {
		const _params = formatApiParams(params, "import_log");
		return yield require_utils.request.getRequest().get(_params === null || _params === void 0 ? void 0 : _params.url, _params === null || _params === void 0 ? void 0 : _params.params);
	});
	return function getImportLog(_x2) {
		return _ref2.apply(this, arguments);
	};
}();
//#endregion
exports.batchImport = batchImport;
exports.exportData = exportData;
exports.getExportFile = getExportFile;
exports.getImportLog = getImportLog;
exports.importTemplate = importTemplate;
