import { MessageTypeConstants, goalType } from "../constants/UIKitConstants";
import { CardMessage, CustomInteractiveMessage, FormMessage, SchedulerMessage } from "../modals/InteractiveData";
export class InteractiveMessageUtils {
    static convertInteractiveMessage(item) {
        if (item.getDeletedBy() != null) {
            return item;
        }
        switch (item.getType()) {
            case MessageTypeConstants.form:
                return FormMessage.fromJSON(item);
            case MessageTypeConstants.scheduler:
                return SchedulerMessage.fromJSON(item);
            case MessageTypeConstants.card:
                return CardMessage.fromJSON(item);
            default:
                return CustomInteractiveMessage.fromJSON(item);
        }
    }
    static checkHasInteractionCompleted = ({ interactionGoal, interactedElements }) => {
        let completed = false;
        let neededInteractionElement = interactionGoal?.getElementIds() || [];
        let neededInteractionElementCondition = interactionGoal?.getType() || "";
        let _interactedElements = [...interactedElements] || [];
        switch (neededInteractionElementCondition) {
            case goalType.anyOf:
                completed = _interactedElements.find((element) => neededInteractionElement.includes(element.getElementId()))
                    ? true
                    : false;
                break;
            case goalType.anyAction:
                completed = _interactedElements.length > 0 ? true : false;
                break;
            case goalType.allOf:
                completed = neededInteractionElement.every((element) => _interactedElements.find((interaction) => interaction.getElementId() === element))
                    ? true
                    : false;
                break;
            case goalType.none:
                completed = false;
                break;
            default:
                completed = false;
                break;
        }
        return completed;
    };
}
//# sourceMappingURL=InteractiveMessageUtils.js.map