<?php
/**
 * Declare block type elements
 *
 * @since 1.0.0
 * @version 1.0.0
 */

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

use ThimPress\ThimBlocks\Gutenberg\Blocks\Breadcrumb\BreadcrumbBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Countdown\CountdownBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Counter\CounterBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\AccordionItem\AccordionItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Icon\IconBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Accordion\AccordionBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\GoogleMaps\GoogleMapsBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\IconItem\IconItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\IconList\IconListBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\LoginForm\LoginFormBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\LoginIcon\LoginIconBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\PostCarousel\PostCarouselBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Team\TeamBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\SlideItem\SlideItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Slider\SliderBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\SocialShare\SocialShareBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\SocialShareItem\SocialShareItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\TabItem\TabItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Tabs\TabsBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\TeamItem\TeamItemBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\VideoPopup\VideoPopupBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\ProgressBar\ProgressBarBlockType;
use ThimPress\ThimBlocks\Gutenberg\Blocks\Courses\CoursesBlockType;

// Remove ancestor constraint from LearnPress course-item-template block
if ( class_exists( 'LearnPress' ) ) {
	add_filter(
		'block_type_metadata',
		function ( $metadata ) {
			if ( isset( $metadata['name'] ) && $metadata['name'] === 'learnpress/course-item-template' ) {
				unset( $metadata['ancestor'] );
			}
			return $metadata;
		}
	);
}


$blocks = array(
	new BreadcrumbBlockType(),
	new IconBlockType(),
	new SlideItemBlockType(),
	new SliderBlockType(),
	new VideoPopupBlockType(),
	new LoginFormBlockType(),
	new LoginIconBlockType(),
	new AccordionItemBlockType(),
	new AccordionBlockType(),
	new TeamItemBlockType(),
	new TeamBlockType(),
	new TabItemBlockType(),
	new TabsBlockType(),
	new CounterBlockType(),
	new CountdownBlockType(),
	new GoogleMapsBlockType(),
	new PostCarouselBlockType(),
	new SocialShareBlockType(),
	new SocialShareItemBlockType(),
	new IconItemBlockType(),
	new IconListBlockType(),
	new ProgressBarBlockType(),
);

if ( class_exists( 'LearnPress' ) ) {
	$blocks[] = new CoursesBlockType();
}

return apply_filters(
	'thim-blocks/config/block-elements',
	$blocks
);
