<?php
/**
 * Flo Guten Blocks FAQ1 Block.
 *
 * @package FBG
 */

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

if (! class_exists('Flo_Guten_Blocks_Faq1_Block')) {

	/**
	 * Class Flo_Guten_Blocks_Testimonials_Block.
	 */
	final class Flo_Guten_Blocks_Faq1_Block
	{
		/**
		 * Member Variable
		 *
		 * @var instance
		 */
		private static $instance;

		/**
		 *  Initiator
		 */
		public static function get_instance()
		{
			if (! isset(self::$instance)) {
				self::$instance = new self();
			}
			return self::$instance;
		}

		/**
		 * Constructor
		 */
		public function __construct()
		{
			add_action('init', array($this, 'register_block'), 100);
		}

		public function register_block()
		{
			register_block_type('flo-block/faq1', array(
			   'attributes' => $this->get_attributes(),
			   'render_callback' => array($this, 'render_callback')
		   ));
		}

		public function get_attributes()
		{
			return array(
				'title'       => array(
					'type'    => 'string',
					'default' => 'FAQ',
				),
				'titleColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'titleTypography' => array(
					'type'    => 'object',
					'default' => Flo_Guten_Blocks_Helper::get_default_typography_attributes('logo')
				),
				'linkLabel'       => array(
					'type'    => 'string',
					'default' => 'View  More',
				),
				'linkUrl'       => array(
					'type'    => 'string',
					'default' => '#',
				),
				'linkColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'linkTypography' => array(
					'type'    => 'object',
					'default' => Flo_Guten_Blocks_Helper::get_default_typography_attributes('third_level/overline_2')
				),
				'list' => array(
					'type' => 'array',
					'default' => []
				),
				'questionColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'questionTypography' => array(
					'type'    => 'object',
					'default' => Flo_Guten_Blocks_Helper::get_default_typography_attributes('title_4/large')
				),
				'answerColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'answerTypography' => array(
					'type'    => 'object',
					'default' => Flo_Guten_Blocks_Helper::get_default_typography_attributes('title_2/xsmall')
				),
				'lineColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'arrowColor'            => array(
					'type'    => 'object',
					'default' => array(
						'custom' => '',
						'theme' => 'scheme_1/text/default'
					),
				),
				'topMargin' => array(
					'type'    => 'number',
					'default' => 0,
				),
				'bottomMargin' => array(
					'type'    => 'number',
					'default' => 0,
				),
				'mobileTopMargin' => array(
					'type'    => 'number',
					'default' => 0,
				),
				'mobileBottomMargin' => array(
					'type'    => 'number',
					'default' => 0,
				),

				'preview'     => array(
					'type'    => 'boolean',
					'default' => FALSE,
				),
				'anchor'  => array(
					'type'    => 'string',
					'default' => '',
				),
				'className'  => array(
					'type'    => 'string',
					'default' => '',
				),
				'blockKey'  => array(
					'type'    => 'string',
					'default' => '',
				),
			);
		}
		public function render_callback($attributes)
		{
			ob_start();
			include dirname(__FILE__) . '/views/html-faq1.php';
			return ob_get_clean();
		}
	}

	Flo_Guten_Blocks_Faq1_Block::get_instance();
}
