<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template files receive local context variables from their controller.
namespace SPAATG;
use SPAATG\ShortPixelLogger\ShortPixelLogger as Log;

if ( ! defined( 'ABSPATH' ) ) {
 exit; // Exit if accessed directly.
}
?>
<div id='spaatg-data-<?php echo( esc_attr($view->id) );?>' class='column-spaatg view-edit-media'
  data-imagewidth="<?php echo esc_attr($view->image['width']); ?>" data-imageheight="<?php echo esc_attr($view->image['height']); ?>"
  data-extension="<?php echo esc_attr($view->image['extension']); ?>"
>
<?php // Debug Data
if (! is_null($view->debugInfo) && is_array($view->debugInfo) && count($view->debugInfo) > 0 ):  ?>
      <div class='debugInfo' id='debugInfo'>

        <a class='debugModal' data-modal="debugInfo" ><?php esc_html_e('Debug Window', 'shortpixel-ai-alt-text-generator') ?></a>
        <div class='content wrapper'>

          <?php
          foreach($view->debugInfo as $index => $item):

        ?>
          <ul class="debug-<?php echo esc_attr($index) ?>">
            <li><strong><?php echo esc_html($item[0]); ?></strong>
              <?php
              if (is_array($item[1]) || is_object($item[1]))
              {
                echo '<pre>' . esc_html(wp_json_encode($item[1], JSON_PRETTY_PRINT)) . '</pre>';
              }
              else
                echo esc_html($item[1]);
              ?>
            </li>
          </ul>
          <?php endforeach; ?>
          <p>&nbsp;</p>
       </div>
    </div>
  <?php endif; ?>

  <div class='sp-column-info generated-alt-box' data-spaatg-generated-alt="<?php echo esc_attr($view->id); ?>">
    <p class='generated-alt-label'><?php esc_html_e('Alt Text', 'shortpixel-ai-alt-text-generator'); ?></p>
	    <p class='shortpixel-generated-alt-content <?php echo $view->hasAltText ? '' : 'is-empty'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Static class names only. ?>'>
      <?php
      if ($view->hasAltText) {
          echo esc_html($view->altText);
      } else {
          esc_html_e('No alt text available yet.', 'shortpixel-ai-alt-text-generator');
      }
      ?>
    </p>
  </div>

	  <?php if (property_exists($view, 'aiSnippet') && strlen($view->aiSnippet) > 0): ?>
	  <div class='spaatg-edit-media-ai-interface shortpixel-ai-interface' data-spaatg-ai-actions="<?php echo esc_attr($view->id); ?>">
	    <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- AI snippet is an internal admin template fragment. ?>
	    <?php echo $view->aiSnippet; ?>
	  </div>
  <?php endif; ?>

</div>

  <div id="sp-message-<?php echo( esc_attr($this->view->id) ); ?>" class='spaatg-message'>
  <?php if (! is_null($view->status_message)): ?>
  <?php echo esc_html($view->status_message); ?>
  <?php endif; ?>
  </div>

  <div id='shortpixel-errorbox' class="errorbox">&nbsp;</div>
