import { IGXE } from "@intelligentgraphics/igd.core";
/**
 * Checks wether the specified target exists inside the session. Throws an error if it doesn't
 *
 * @param {(ArticleQuery | Session)} articleQuery
 * @param {string | Article} target
 */
export const getArticleOrThrow = (articleQuery, target) => {
    const comId = typeof target === "string" ? target : target.comId;
    const article = articleQuery.getArticleByComId(comId);
    if (article === undefined) {
        throw new Error(`Could not find an article for comId "${comId}"`);
    }
    return article;
};
export const getPropertyValue = (article, property, value) => {
    const propertyDefinition = IGXE.findProperty(article.properties, property);
    if (propertyDefinition === undefined) {
        return undefined;
    }
    const valueDefinition = IGXE.findValueDefinition(propertyDefinition, value);
    return valueDefinition;
};
