<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
/**
 * Comments loop for Email Templates.
 */
?>
<table class="comment-list" style="width:100%;">
	<?php
	if ((is_array($this->list_of_comments) && !empty($this->list_of_comments)) || (is_object($this->list_of_comments) && !empty((array)$this->list_of_comments))) {
		foreach ( $this->list_of_comments as $multicollab_comment_row ) {
			if ( isset( $multicollab_comment_row['status'] ) && 'publish' === $multicollab_comment_row['status'] ) {
				$multicollab_user_info = ! empty( $multicollab_comment_row['userData'] ) ? get_userdata( $multicollab_comment_row['userData'] ) : '';
				$multicollab_user_role = ! empty( $multicollab_user_info->roles ) ? implode( ', ', $multicollab_user_info->roles ) : '';
				$multicollab_username  = ! empty( $multicollab_user_info->display_name ) ? $multicollab_user_info->display_name : '';
				$this->users_emails[]  = ! empty( $multicollab_user_info->user_email ) ? $multicollab_user_info->user_email : ''; // phpcs:ignore
				$multicollab_profile_url = ! empty( $multicollab_user_info->user_email ) ? get_avatar_url( $multicollab_user_info->user_email ) : '';
				?>
				<tr>
					<td style="padding-bottom:20px">
						<table class="comment-box-wrap" style="width:100%;font-family:Roboto,serif;font-size:14px;color:#4C5056;">
							<tr valign="top">
								<td class="avatar" style="width:32px;padding-right:5px;">
									<img src="<?php echo esc_url_raw( $multicollab_profile_url ); ?>" alt="avatar" style="max-width:100%;border-radius:50%;" />
								</td>
								<td class="comment-details">
									<table class="commenter-name-role" valign="middle" style="width:100%;font-family:Roboto,sans-serif;">
										<tr>
											<th align="left">
												<span class="commenter-name" style="font-size:16px;font-family:Roboto,sans-serif;padding-right:5px;color:#1D2327;font-weight:500;text-transform:capitalize;"><?php echo esc_html( $multicollab_username ); ?></span>
												<span class="commenter-role" style="font-weight:400;color:#50575E;font-size:14px;    font-family: Roboto,sans-serif;">(<?php echo esc_html( translate_user_role( ucwords( $multicollab_user_role ) ) ); ?>)</span>
											</th>
										</tr>
										<tr>
											<td align="left" class="comment"><?php echo ! empty( $multicollab_comment_row['thread'] ) ? wp_kses( $multicollab_comment_row['thread'], wp_kses_allowed_html( 'post' ) ) : ''; ?></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<?php
			}
		}
	}
	?>
</table>
