<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Table – Pricing Comparison
 *
 * @package AxcelersBlocks
 */

$axcelersblocks_responsive_value = static function ( $desktop, $tablet = null, $mobile = null ) {
	return array(
		'desktop' => $desktop,
		'tablet'  => null === $tablet ? $desktop : $tablet,
		'mobile'  => null === $mobile ? ( null === $tablet ? $desktop : $tablet ) : $mobile,
	);
};

$axcelersblocks_spacing = static function ( $top, $right, $bottom, $left, $linked = false ) {
	return array(
		'desktop' => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
		'tablet'  => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
		'mobile'  => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
	);
};

$axcelersblocks_border = static function ( $sides ) {
	return array(
		'desktop' => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
		'tablet'  => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
		'mobile'  => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
	);
};

$axcelersblocks_cell_border = $axcelersblocks_border(
	array(
		'right'  => array(
			'width' => '1px',
			'style' => 'solid',
			'color' => '#E5E7EB',
		),
		'bottom' => array(
			'width' => '1px',
			'style' => 'solid',
			'color' => '#E5E7EB',
		),
	)
);

$axcelersblocks_zero_margin = $axcelersblocks_spacing( '0px', '0px', '0px', '0px', true );

$axcelersblocks_bodycopy = static function ( $class, $content, $options = array() ) use ( $axcelersblocks_responsive_value, $axcelersblocks_zero_margin ) {
	$attrs = array_merge(
		array(
			'content'    => $content,
			'tagName'    => 'p',
			'uniqueClass'=> $class,
			'margin'     => $axcelersblocks_zero_margin,
			'fontSize'   => $axcelersblocks_responsive_value( '15px', '15px', '14px' ),
			'lineHeight' => $axcelersblocks_responsive_value( '1.45', '1.45', '1.5' ),
			'fontWeight' => $axcelersblocks_responsive_value( '400' ),
			'textColor'  => $axcelersblocks_responsive_value( '#475467' ),
		),
		$options
	);

	return '<!-- wp:axcelersblocks/bodycopy ' . wp_json_encode( $attrs ) . ' /-->';
};

$axcelersblocks_cell = static function ( $class, $content, $options = array() ) use ( $axcelersblocks_responsive_value, $axcelersblocks_spacing, $axcelersblocks_cell_border, $axcelersblocks_bodycopy ) {
	$is_header  = ! empty( $options['header'] );
	$is_feature = ! empty( $options['feature'] );

	$cell_attrs = array(
		'uniqueClass'     => $class,
		'tagName'         => $is_header ? 'th' : 'td',
		'padding'         => $options['padding'] ?? $axcelersblocks_spacing( '18px', '18px', '18px', '18px' ),
		'backgroundColor' => $options['backgroundColor'] ?? $axcelersblocks_responsive_value( '#FFFFFF' ),
		'border'          => $axcelersblocks_cell_border,
		'verticalAlign'   => $axcelersblocks_responsive_value( 'middle' ),
		'textAlign'       => $options['textAlign'] ?? $axcelersblocks_responsive_value( $is_feature ? 'left' : 'center' ),
	);

	if ( $is_header ) {
		$cell_attrs['scope'] = $options['scope'] ?? 'col';
	}

	$text_attrs = array(
		'fontWeight' => $axcelersblocks_responsive_value( $options['fontWeight'] ?? ( $is_header || $is_feature ? '700' : '500' ) ),
		'textColor'  => $axcelersblocks_responsive_value( $options['textColor'] ?? ( $is_header ? '#111827' : '#344054' ) ),
		'fontSize'   => $axcelersblocks_responsive_value( $options['fontSize'] ?? ( $is_header ? '14px' : '15px' ), $options['fontSize'] ?? ( $is_header ? '14px' : '15px' ), $options['mobileFontSize'] ?? '14px' ),
		'lineHeight' => $axcelersblocks_responsive_value( $options['lineHeight'] ?? '1.45' ),
	);

	return '<!-- wp:axcelersblocks/table-cell ' . wp_json_encode( $cell_attrs ) . ' -->' .
		$axcelersblocks_bodycopy( $class . '-text', $content, $text_attrs ) .
	'<!-- /wp:axcelersblocks/table-cell -->';
};

$axcelersblocks_row = static function ( $class, $cells ) {
	return '<!-- wp:axcelersblocks/table-row {"uniqueClass":"' . esc_attr( $class ) . '"} -->' .
		implode( '', $cells ) .
	'<!-- /wp:axcelersblocks/table-row -->';
};

$axcelersblocks_section = static function ( $class, $tag_name, $rows ) {
	return '<!-- wp:axcelersblocks/table-section {"uniqueClass":"' . esc_attr( $class ) . '","tagName":"' . esc_attr( $tag_name ) . '"} -->' .
		implode( '', $rows ) .
	'<!-- /wp:axcelersblocks/table-section -->';
};

return array(
	'title'         => __( 'AXB: Table – Pricing Comparison', 'axcelersblocks' ),
	'description'   => __( 'A clean pricing comparison table with a highlighted recommended plan column.', 'axcelersblocks' ),
	'categories'    => array( 'axcelersblocks-table' ),
	'keywords'      => array( 'table', 'pricing', 'comparison', 'plans', 'features', 'axcelersblocks' ),
	'viewportWidth' => 1200,
	'content'       =>

	'<!-- wp:axcelersblocks/box {"tagName":"section","align":"full","uniqueClass":"axb-table-01","padding":{"desktop":{"top":"88px","right":"24px","bottom":"88px","left":"24px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"72px","right":"20px","bottom":"72px","left":"20px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"56px","right":"16px","bottom":"56px","left":"16px","isVHActive":false,"isSidesAllActive":true}},"backgroundColor":{"desktop":"#F8FAFC","tablet":"#F8FAFC","mobile":"#F8FAFC"}} -->' .

		'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-01__container","maxWidth":{"desktop":"1040px","tablet":"1040px","mobile":"1040px"},"margin":{"desktop":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false},"tablet":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false},"mobile":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false}},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}},"display":{"desktop":"flex","tablet":"flex","mobile":"flex"},"flexDirection":{"desktop":"column","tablet":"column","mobile":"column"},"rowGap":{"desktop":"26px","tablet":"24px","mobile":"20px"}} -->' .

			'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-01__intro","maxWidth":{"desktop":"720px","tablet":"720px","mobile":"100%"},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}},"display":{"desktop":"flex","tablet":"flex","mobile":"flex"},"flexDirection":{"desktop":"column","tablet":"column","mobile":"column"},"rowGap":{"desktop":"12px","tablet":"12px","mobile":"10px"}} -->' .
				'<!-- wp:axcelersblocks/heading {"content":"Compare plans","tagName":"h2","textAlign":{"desktop":"left","tablet":"left","mobile":"left"},"fontSize":{"desktop":"36px","tablet":"30px","mobile":"26px"},"lineHeight":{"desktop":"1.16","tablet":"1.2","mobile":"1.22"},"fontWeight":{"desktop":"700","tablet":"700","mobile":"700"},"textColor":{"desktop":"#111827","tablet":"#111827","mobile":"#111827"}} /-->' .
				'<!-- wp:axcelersblocks/bodycopy {"content":"A practical pricing table for comparing plan limits, support levels, and launch-ready features.","fontSize":{"desktop":"16px","tablet":"16px","mobile":"15px"},"lineHeight":{"desktop":"1.65","tablet":"1.65","mobile":"1.6"},"textColor":{"desktop":"#475467","tablet":"#475467","mobile":"#475467"},"margin":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}}} /-->' .
			'<!-- /wp:axcelersblocks/box -->' .

			'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-01__scroll","overflowX":{"desktop":"auto","tablet":"auto","mobile":"auto"},"overflowY":{"desktop":"hidden","tablet":"hidden","mobile":"hidden"},"backgroundColor":{"desktop":"#FFFFFF","tablet":"#FFFFFF","mobile":"#FFFFFF"},"borderRadius":{"desktop":{"value":"8px","corners":{},"isLinkActive":true},"tablet":{"value":"8px","corners":{},"isLinkActive":true},"mobile":{"value":"8px","corners":{},"isLinkActive":true}},"effect":{"desktop":{"boxShadow":{"xOffset":"0px","yOffset":"18px","blurRadius":"48px","spreadRadius":"-30px","color":"rgba(15,23,42,0.32)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""},"tablet":{"boxShadow":{"xOffset":"0px","yOffset":"14px","blurRadius":"36px","spreadRadius":"-24px","color":"rgba(15,23,42,0.26)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""},"mobile":{"boxShadow":{"xOffset":"0px","yOffset":"10px","blurRadius":"28px","spreadRadius":"-20px","color":"rgba(15,23,42,0.22)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""}},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}}} -->' .

				'<!-- wp:axcelersblocks/table {"uniqueClass":"axb-table-01__table","cols":[{"width":"28%"},{"width":"24%"},{"width":"24%","backgroundColor":"#F6FEF9"},{"width":"24%"}],"borderSpacing":{"desktop":"0","tablet":"0","mobile":"0"},"width":{"desktop":"100%","tablet":"100%","mobile":"100%"},"minWidth":{"desktop":"760px","tablet":"760px","mobile":"720px"},"backgroundColor":{"desktop":"#FFFFFF","tablet":"#FFFFFF","mobile":"#FFFFFF"},"border":{"desktop":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false},"tablet":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false},"mobile":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false}}} -->' .

					$axcelersblocks_section(
						'axb-table-01__head',
						'thead',
						array(
							$axcelersblocks_row(
								'axb-table-01__head-row',
								array(
									$axcelersblocks_cell( 'axb-table-01__h-feature', 'Feature', array( 'header' => true, 'feature' => true, 'backgroundColor' => $axcelersblocks_responsive_value( '#F9FAFB' ), 'textAlign' => $axcelersblocks_responsive_value( 'left' ) ) ),
									$axcelersblocks_cell( 'axb-table-01__h-starter', 'Starter', array( 'header' => true, 'backgroundColor' => $axcelersblocks_responsive_value( '#F9FAFB' ) ) ),
									$axcelersblocks_cell( 'axb-table-01__h-growth', 'Growth', array( 'header' => true, 'backgroundColor' => $axcelersblocks_responsive_value( '#ECFDF3' ), 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__h-scale', 'Scale', array( 'header' => true, 'backgroundColor' => $axcelersblocks_responsive_value( '#F9FAFB' ) ) ),
								)
							),
						)
					) .

					$axcelersblocks_section(
						'axb-table-01__body',
						'tbody',
						array(
							$axcelersblocks_row(
								'axb-table-01__row-price',
								array(
									$axcelersblocks_cell( 'axb-table-01__price-label', 'Monthly price', array( 'feature' => true ) ),
									$axcelersblocks_cell( 'axb-table-01__price-starter', '$19', array( 'fontSize' => '20px', 'mobileFontSize' => '18px', 'fontWeight' => '700', 'textColor' => '#111827' ) ),
									$axcelersblocks_cell( 'axb-table-01__price-growth', '$49', array( 'backgroundColor' => $axcelersblocks_responsive_value( '#F6FEF9' ), 'fontSize' => '20px', 'mobileFontSize' => '18px', 'fontWeight' => '700', 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__price-scale', '$99', array( 'fontSize' => '20px', 'mobileFontSize' => '18px', 'fontWeight' => '700', 'textColor' => '#111827' ) ),
								)
							),
							$axcelersblocks_row(
								'axb-table-01__row-sites',
								array(
									$axcelersblocks_cell( 'axb-table-01__sites-label', 'Websites', array( 'feature' => true ) ),
									$axcelersblocks_cell( 'axb-table-01__sites-starter', '1 site' ),
									$axcelersblocks_cell( 'axb-table-01__sites-growth', '5 sites', array( 'backgroundColor' => $axcelersblocks_responsive_value( '#F6FEF9' ), 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__sites-scale', 'Unlimited' ),
								)
							),
							$axcelersblocks_row(
								'axb-table-01__row-blocks',
								array(
									$axcelersblocks_cell( 'axb-table-01__blocks-label', 'Premium blocks', array( 'feature' => true ) ),
									$axcelersblocks_cell( 'axb-table-01__blocks-starter', 'Core set' ),
									$axcelersblocks_cell( 'axb-table-01__blocks-growth', 'All blocks', array( 'backgroundColor' => $axcelersblocks_responsive_value( '#F6FEF9' ), 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__blocks-scale', 'All blocks' ),
								)
							),
							$axcelersblocks_row(
								'axb-table-01__row-patterns',
								array(
									$axcelersblocks_cell( 'axb-table-01__patterns-label', 'Pattern library', array( 'feature' => true ) ),
									$axcelersblocks_cell( 'axb-table-01__patterns-starter', '25 patterns' ),
									$axcelersblocks_cell( 'axb-table-01__patterns-growth', '100+ patterns', array( 'backgroundColor' => $axcelersblocks_responsive_value( '#F6FEF9' ), 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__patterns-scale', 'Unlimited' ),
								)
							),
							$axcelersblocks_row(
								'axb-table-01__row-support',
								array(
									$axcelersblocks_cell( 'axb-table-01__support-label', 'Support', array( 'feature' => true ) ),
									$axcelersblocks_cell( 'axb-table-01__support-starter', 'Email' ),
									$axcelersblocks_cell( 'axb-table-01__support-growth', 'Priority email', array( 'backgroundColor' => $axcelersblocks_responsive_value( '#F6FEF9' ), 'textColor' => '#166534' ) ),
									$axcelersblocks_cell( 'axb-table-01__support-scale', 'Priority + onboarding' ),
								)
							),
						)
					) .

				'<!-- /wp:axcelersblocks/table -->' .

			'<!-- /wp:axcelersblocks/box -->' .

		'<!-- /wp:axcelersblocks/box -->' .

	'<!-- /wp:axcelersblocks/box -->',
);
