import { resolveFeishuAccount } from "../state/accounts.js";
import { createFeishuClient } from "../transport/client/client.js";
//#region extensions/feishu/src/directory/directory-adapter.ts
function createFeishuDirectoryAdapter() {
	return { resolveDisplayName: async (params) => {
		const id = params.id.trim();
		if (!id) return void 0;
		if (!id.startsWith("ou_") && !id.startsWith("on_")) return;
		const account = resolveFeishuAccount(params.cfg, "default");
		if (!account.configured) return void 0;
		const { api } = createFeishuClient(account);
		try {
			const res = await api.contact.user.get({
				path: { user_id: id },
				params: { user_id_type: "open_id" }
			});
			const name = res?.data?.user?.name ?? res?.data?.name;
			return typeof name === "string" && name.trim() ? name.trim() : void 0;
		} catch {
			return;
		}
	} };
}
//#endregion
export { createFeishuDirectoryAdapter };

//# sourceMappingURL=directory-adapter.js.map