HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/self/cwd/wp-content/plugins/wpforms-lite/assets/js/integrations/ai/modules/helpers-text.js
/* global WPFormsAIChatHTMLElement */

/**
 * The WPForms AI chat element.
 *
 * Choices helpers module.
 *
 * @since 1.9.1
 *
 * @param {WPFormsAIChatHTMLElement} chat The chat element.
 *
 * @return {Function} The app cloning function.
 */
export default function( chat ) { // eslint-disable-line no-unused-vars
	/**
	 * The default `text` mode helpers object.
	 *
	 * @since 1.9.1
	 */
	return {
		/**
		 * Get the `text` answer based on AI response data.
		 *
		 * @since 1.9.1
		 *
		 * @param {Object} response The AI response data.
		 *
		 * @return {string} HTML markup.
		 */
		getAnswer( response ) {
			return `
				<h4>${ response?.heading ?? '' }</h4>
				<p>${ response?.text ?? '' }</p>
				<span>${ response?.footer ?? '' }</span>
			`;
		},

		/**
		 * Get the answer pre-buttons HTML markup.
		 *
		 * @since 1.9.1
		 *
		 * @return {string} The answer pre-buttons HTML markup.
		 */
		getAnswerButtonsPre() {
			return '';
		},

		/**
		 * Added answer callback.
		 *
		 * @since 1.9.1
		 */
		addedAnswer() {},

		/**
		 * Determine whether the Welcome Screen should be displayed.
		 *
		 * @since 1.9.2
		 *
		 * @return {boolean} Display the Welcome Screen or not.
		 */
		isWelcomeScreen() {
			return true;
		},
	};
}