import { getUser } from "@esri/arcgis-rest-portal";
import { computeLinks } from "../../../events/_internal/computeLinks";
import { getLocationFromEvent } from "../../../events/_internal/getLocationFromEvent";
/**
 * Resolves an IHubSearchResult for the given IEvent record
 * @param event An IEvent record
 * @param options An IHubSearchOptions object
 * @returns a IHubSearchResult for the given IEvent record
 */
export async function eventToSearchResult(event, options) {
    var _a;
    let ownerUser;
    if ((_a = options.include) === null || _a === void 0 ? void 0 : _a.includes("ownerUser")) {
        ownerUser = await getUser(Object.assign({ username: event.creator.username }, options.requestOptions));
    }
    const result = {
        access: event.access.toLowerCase(),
        id: event.id,
        location: getLocationFromEvent(event),
        type: "Event",
        name: event.title,
        owner: event.creator.username,
        ownerUser,
        summary: event.summary || event.description,
        createdDate: new Date(event.createdAt),
        createdDateSource: "event.createdAt",
        updatedDate: new Date(event.updatedAt),
        updatedDateSource: "event.updatedAt",
        family: "event",
        links: computeLinks(event),
        tags: event.tags,
        categories: event.categories,
        rawResult: event,
    };
    return result;
}
//# sourceMappingURL=eventToSearchResult.js.map