import { resolveFeishuAccount } from "../state/accounts.js";
import { createFeishuClient } from "../transport/client/client.js";
//#region extensions/feishu/src/outbound/actions.ts
async function editMessageFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	await api.im.v1.message.update({
		path: { message_id: params.messageId },
		data: {
			msg_type: "text",
			content: JSON.stringify({ text: params.text })
		}
	});
	return { ok: true };
}
async function getMessageFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	const res = await api.im.message.get({ path: { message_id: params.messageId } });
	return res?.data ?? res;
}
async function addReactionFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.messageReaction.create({
		path: { message_id: params.messageId },
		data: { reaction_type: { emoji_type: params.emojiType } }
	});
}
async function listReactionsFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.messageReaction.list({
		path: { message_id: params.messageId },
		params: params.emojiType ? { reaction_type: params.emojiType } : {}
	});
}
async function removeReactionFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.messageReaction.delete({ path: {
		message_id: params.messageId,
		reaction_id: params.reactionId
	} });
}
async function pinMessageFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.pin.create({ data: { message_id: params.messageId } });
}
async function unpinMessageFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.pin.delete({ path: { message_id: params.messageId } });
}
async function listPinsFeishu(params) {
	const { api } = createFeishuClient(resolveFeishuAccount(params.cfg, params.accountId ?? "default"));
	return await api.im.v1.pin.list({ params: {
		chat_id: params.chatId,
		...params.startTime ? { start_time: params.startTime } : {},
		...params.endTime ? { end_time: params.endTime } : {},
		...params.pageSize ? { page_size: params.pageSize } : {},
		...params.pageToken ? { page_token: params.pageToken } : {}
	} });
}
//#endregion
export { addReactionFeishu, editMessageFeishu, getMessageFeishu, listPinsFeishu, listReactionsFeishu, pinMessageFeishu, removeReactionFeishu, unpinMessageFeishu };

//# sourceMappingURL=actions.js.map