<?php

namespace Limb_Chatbot\Includes\Widgets\Data;

class Chats_Widget_Config extends Abstract_Widget_Config {
	public function sanitize( $data ): array {
		$data = is_array( $data ) ? $data : [];

		return [
			'section_title' => $this->sanitize_string( $data['section_title'] ?? '' ),
			'max_items'     => max( 1, $this->sanitize_int( $data['max_items'] ?? 3, 3 ) ),
		];
	}

	public function validate( $data ): bool {
		return is_array( $data );
	}

	public function get_translatable_fields(): array {
		return [
			[ 'path' => 'section_title', 'type' => 'string' ],
		];
	}
}
