import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { request } from "../../table/utils.js";
//#region src/components/dataSourceComponents/dataSourceForm/urlUtils.ts
/**
* URL参数处理工具方法
*/
/**
* 从浏览器URL获取查询参数
* @returns Record<string, string> URL查询参数对象
*/
const getUrlParams = () => {
	const urlSearchParams = new URLSearchParams(window.location.search);
	const urlParams = {};
	urlSearchParams.forEach((value, key) => {
		urlParams[key] = value;
	});
	return urlParams;
};
/**
* 从URL参数中提取formSettingMeta相关的参数
* @param urlParams URL查询参数对象，如果不传则自动从浏览器获取
* @returns 包含business_code、channel_code和isBoard参数的对象
*/
const getFormSettingParams = (urlParams) => {
	const params = urlParams || getUrlParams();
	return {
		businessCode: params.businessCode || params.business_code,
		channelCode: params.channelCode || params.channel_code,
		isBoard: params.is_board === "1"
	};
};
(function() {
	var _ref = _asyncToGenerator(function* (data) {
		debugger;
		const urlParams = getFormSettingParams();
		const businessCode = urlParams.businessCode;
		const channelCode = urlParams.channelCode;
		const boardCode = urlParams.isBoard && businessCode && channelCode ? `${businessCode}+${channelCode}` : void 0;
		const requestBody = {
			business_code: businessCode || "",
			channel_code: channelCode || "",
			board_code: boardCode || "",
			data
		};
		return request.getRequest().put("/tenant/setting", requestBody, { headers: { "Content-Type": "application/json" } });
	});
	return function updateTenantSettingFromUrl(_x) {
		return _ref.apply(this, arguments);
	};
})();
//#endregion
export { getUrlParams };
