<?php
use Elementor\Utils;

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

list($animate_class, $animation_attr) = tfl_get_animation_atts($settings['widget_animation']);
$bgImg = $settings['bg_image'];
?>

<div class="tfl-iconbox tfl-<?php echo $settings['style']; ?> tfl-align<?php echo $settings['align']; ?> <?php echo $animate_class; ?>" <?php echo $animation_attr; ?> style="background-image: url(<?php echo $bgImg['url']; ?>)">
    <div class="d-flex">
        <div class="tfl-image-wrapper">

            <?php 
                $icon = $settings['icon']; 
                $icon_output = "";
                if ( !empty( $settings['icon']['value']['url'] ) ) {
                    $icon_output .= sprintf(
                       '<img class="logo_svg" src="%1$s" alt="%2$s"/>',
                         $icon['value']['url'],
                         $icon['value']['id']
                        
                     ); 
                } else {
                    $icon_output .= sprintf(
                         '<i class="%1$s"></i>',
                        $icon['value']
                    );  
                }
            ?>

            <?php if (!empty($icon)): ?>

                <?php echo $icon_output; ?>

            <?php endif; ?>

        </div>

        <div class="tfl-content-wrapper">
            <<?php echo Utils::validate_html_tag($settings['title_tag']); ?>
            class="tfl-title">

            <?php if(isset($settings['link']['url']) && !empty($settings['link']['url'])): ?><a href="<?php echo $settings['link']['url']; ?>"><?php endif; ?>

            <?php echo wp_kses_post($settings['iconbox']); ?>


            <?php if(isset($settings['link']['url']) && !empty($settings['link']['url'])): ?></a><?php endif; ?>

        </<?php echo Utils::validate_html_tag($settings['title_tag']); ?>
        >

        <?php if (!empty($settings['short_text'])): ?>

            <p class="tfl-text"><?php echo wp_kses_post($settings['short_text']); ?></p>
            <a class="readmore" href="<?php echo $settings['link']['url']; ?>"><?php echo $settings['button_text']; ?><i class="fas fa-arrow-right"></i></a>
        <?php endif; ?>

    </div>
</div>

</div><!-- .tfl-iconbox -->