import { getDefaultEntitySettings } from "../../discussions/api/settings/getDefaultEntitySettings";
import { fetchSettingV2 } from "../../discussions/api/settings/settings";
import { fetchModelFromItem } from "../../models/fetchModelFromItem";
import { modelToHubEditableContent } from "../modelToHubEditableContent";
/**
 * Convert an Item to an editable Hub Content object,
 * fetch any additional information that may be required
 */
export const convertItemToContentHubIndex = async (item, requestOptions, enrichments) => {
    const [model, entitySettings] = await Promise.all([
        fetchModelFromItem(item, requestOptions),
        !requestOptions.isPortal
            ? fetchSettingV2(Object.assign({ id: item.id }, requestOptions)).catch(() => (Object.assign({ id: null }, getDefaultEntitySettings("content"))))
            : null, // non-hub-indexer path
    ]);
    model.entitySettings = entitySettings;
    const content = modelToHubEditableContent(model, requestOptions, enrichments);
    return content;
};
//# sourceMappingURL=convertItemToContentHubIndex.js.map