import { getUser } from "@esri/arcgis-rest-portal";
import { getUserHomeUrl } from "../../../urls/getUserHomeUrl";
import { getUserThumbnailUrl } from "../../utils";
/**
 * Transforms a given event attendee into a IHubSearchResult
 * @param attendee
 * @returns
 */
export async function eventAttendeeToSearchResult(attendee, options) {
    var _a;
    const [user, creator] = await Promise.all([
        getUser(Object.assign({ username: attendee.userId }, options.requestOptions)),
        getUser(Object.assign({ username: attendee.createdById }, options.requestOptions)),
    ]);
    return {
        id: attendee.id.toString(),
        access: user.access,
        name: user.fullName,
        createdDate: new Date(attendee.createdAt),
        createdDateSource: "attendee.createdAt",
        updatedDate: new Date(attendee.updatedAt),
        updatedDateSource: "attendee.updatedAt",
        type: "Event Attendee",
        family: "eventAttendee",
        owner: creator.username,
        rawResult: attendee,
        links: {
            self: getUserHomeUrl(user.username, options.requestOptions),
            siteRelative: `/people/${user.username}`,
            thumbnail: user.thumbnail
                ? getUserThumbnailUrl(options.requestOptions.portal, user, (_a = options.requestOptions.authentication) === null || _a === void 0 ? void 0 : _a.token)
                : null,
        },
    };
}
//# sourceMappingURL=eventAttendeeToSearchResult.js.map