<?php

namespace GOSP\GravityOps\Core\SuiteCore;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Suite catalog of GravityOps products and their variants.
 */
class SuiteCatalog {

	/**
	 * The url of the docs site.
	 *
	 * @var string
	 */
	private $docs_url = 'https://brightleafdigital.io/bld-docs/';

	/**
	 * Catalog items keyed by slug.
	 *
	 * @var array<string,array<string,mixed>>
	 */
	private array $items;

	/**
	 * Constructor method for initializing the class.
	 *
	 * @return void
	 */
	public function __construct() {
		$this->items = $this->build_items();
	}

	/**
	 * Return all catalog items.
	 *
	 * @return array<int,array<string,mixed>>
	 */
	public function all(): array {
		return array_values( $this->items );
	}

	/**
	 * Find a catalog item by slug.
	 *
	 * @param string $slug Item slug.
	 * @return array<string,mixed>|null
	 */
	public function find( string $slug ): ?array {
		return $this->items[ $slug ] ?? null;
	}

	/**
	 * Build the catalog items.
	 *
	 * @return array<string,array<string,mixed>>
	 */
	private function build_items(): array {
		return [
			'integrate-asana-with-gravity-forms'          => [
				'slug'            => 'integrate-asana-with-gravity-forms',
				'type'            => 'plugin',
				'name'            => 'Integrate Asana with Gravity Forms',
				'description'     => 'Turn form submissions into Asana tasks instantly.',
				'marketing_url'   => 'https://brightleafdigital.io/asana-gravity-forms/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/iawgf-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'iawgf-icon.svg',
				'premium_file'    => 'integrate-asana-with-gravity-forms-premium/integrate-asana-with-gravity-forms.php',
				'free_file'       => 'integrate-asana-with-gravity-forms/integrate-asana-with-gravity-forms.php',
				'freemius_helper' => 'iawgf_fs',
				'wporg_slug'      => 'integrate-asana-with-gravity-forms',
			],
			'mass_email_notifications_for_gf'             => [
				'slug'            => 'mass_email_notifications_for_gf',
				'type'            => 'plugin',
				'name'            => 'Mass Email Notifications',
				'description'     => 'Send bulk emails to Gravity Forms entries.',
				'marketing_url'   => 'https://brightleafdigital.io/mass-email-notifications-for-gravity-forms/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/mass-email-notifications-for-gravity-forms-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'menfgf-icon.svg',
				'premium_file'    => 'mass-email-notifications-for-gravity-forms-premium/mass-email-notifications-for-gf.php',
				'free_file'       => 'mass-email-notifications-for-gravity-forms/mass-email-notifications-for-gf.php',
				'freemius_helper' => 'menfgf_fs',
				'wporg_slug'      => 'mass-email-notifications-for-gravity-forms',
			],
			'folders-4-gravity'                           => [
				'slug'            => 'folders-4-gravity',
				'type'            => 'plugin',
				'name'            => 'Folders 4 Gravity',
				'description'     => 'Organize Gravity Forms and GravityView with folders.',
				'marketing_url'   => 'https://brightleafdigital.io/folders-4-gravity/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/folders4gravity-changelog/',
				'is_free'         => true,
				'icon_filename'   => 'f4g-icon.svg',
				'premium_file'    => '',
				'free_file'       => 'folders-4-gravity/folders-4-gravity.php',
				'freemius_helper' => '',
				'wporg_slug'      => 'folders-4-gravity',
			],
			'gravityops-search'                           => [
				'slug'            => 'gravityops-search',
				'type'            => 'plugin',
				'name'            => 'GravityOps Search',
				'description'     => 'Supercharge search across Gravity Forms entries.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-search/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-search-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'search-icon.svg',
				'premium_file'    => 'gravityops-search-premium/gravityops-search.php',
				'free_file'       => 'gravityops-search/gravityops-search.php',
				'freemius_helper' => 'gosp_fs',
				'wporg_slug'      => 'gravityops-search',
			],
			'gravity_ops_global_variables'                => [
				'slug'            => 'gravity_ops_global_variables',
				'type'            => 'plugin',
				'name'            => 'Global Variables',
				'description'     => 'Create shared variables for GravityMath formulas.',
				'marketing_url'   => 'https://brightleafdigital.io/global-variables-for-gravity-math/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/global-variables-for-gravity-math-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'gv4gm-icon.svg',
				'premium_file'    => 'global-variables-for-gravity-math-premium/global-variables-for-gravity-math.php',
				'free_file'       => '',
				'freemius_helper' => 'gvfgm_fs',
				'wporg_slug'      => '',
			],
			'Recurring_Form_Submissions_For_Gravity_Form' => [
				'slug'            => 'Recurring_Form_Submissions_For_Gravity_Form',
				'type'            => 'plugin',
				'name'            => 'Recurring Form Submissions',
				'description'     => 'Schedule recurring Gravity Forms submissions.',
				'marketing_url'   => 'https://brightleafdigital.io/recurring-form-submissions-for-gravity-forms/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/recurring-form-submissions-for-gravity-forms-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'rfsfgf-icon.svg',
				'premium_file'    => 'recurring-form-submissions-for-gravity-forms-premium/recurring-form-submissions-for-gravity-form.php',
				'free_file'       => '',
				'freemius_helper' => 'rfsfgf_fs',
				'wporg_slug'      => '',
			],
			'kanban-view-for-gravity-view'                => [
				'slug'            => 'kanban-view-for-gravity-view',
				'type'            => 'plugin',
				'name'            => 'Kanban View for GravityView',
				'description'     => 'Turn GravityView into a kanban project board.',
				'marketing_url'   => 'https://brightleafdigital.io/turn-gravityview-into-a-kanban-project-board/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/kanban-view-for-gravityview-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'kv4gv-icon.svg',
				'premium_file'    => 'kanban-view-for-gravity-view-premium/kanban-view-for-gv.php',
				'free_file'       => '',
				'freemius_helper' => 'kvfgv_fs',
				'wporg_slug'      => '',
			],
			'gravityops-forum'                            => [
				'slug'            => 'gravityops-forum',
				'type'            => 'plugin',
				'name'            => 'GravityOps Forum',
				'description'     => 'Turn Gravity Forms entries into a functional forum.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-forum/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-forum-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'forum-icon.svg',
				'premium_file'    => 'gravityops-forum-premium/gravityops-forum.php',
				'free_file'       => 'gravityops-forum/gravityops-forum.php',
				'freemius_helper' => 'gofrm_fs',
				'wporg_slug'      => 'https://wordpress.org/plugins/gravityops-forum/',
			],
			/**'gravityops-code-snippet-manager'             => [
				'slug'            => 'gravityops-code-snippet-manager',
				'type'            => 'plugin',
				'name'            => 'GravityOps Code Snippet Manager',
				'description'     => 'Add, manage, and update PHP, JavaScript, and CSS snippets.',
				'marketing_url'   => 'https://brightleafdigital.io/code-snippet-manager/', // todo
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-code-snippet-manager-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'csm-icon.svg',
				'premium_file'    => 'gravityops-code-snippet-manager/gravityops-code-snippet-manager.php',
				'free_file'       => '',
				'freemius_helper' => 'gocsm_fs',
				'wporg_slug'      => '',
			],*/
			'gravityops-charts'                           => [
				'slug'            => 'gravityops-charts',
				'type'            => 'plugin',
				'name'            => 'GravityOps Charts',
				'description'     => 'Render charts from Gravity Forms entries.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-charts/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-charts-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'charts-icon.svg',
				'premium_file'    => 'gravityops-charts-premium/gravityops-charts.php',
				'free_file'       => '',
				'freemius_helper' => 'gocharts_fs',
				'wporg_slug'      => '',
			],
			'gravityops-multi-media'                      => [
				'slug'            => 'gravityops-multi-media',
				'type'            => 'plugin',
				'name'            => 'GravityOps Multi Media',
				'description'     => 'Embed videos with progress tracking in Gravity Forms.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-multi-media/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-multi-media-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'multimedia-icon.svg',
				'premium_file'    => 'gravityops-multi-media-premium/gravityops-multi-media.php',
				'free_file'       => '',
				'freemius_helper' => 'gomm_fs',
				'wporg_slug'      => '',
			],
			'gravityops-live-field-validation'            => [
				'slug'            => 'gravityops-live-field-validation',
				'type'            => 'plugin',
				'name'            => 'GravityOps Live Field Validation',
				'description'     => 'Real-time AJAX field validation for Gravity Forms.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-live-field-validation/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-live-field-validation-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'lfv-icon.svg',
				'premium_file'    => 'gravityops-live-field-validation-premium/gravityops-live-field-validation.php',
				'free_file'       => '',
				'freemius_helper' => 'golfv_fs',
				'wporg_slug'      => '',
			],
			'gravityops-multi-path-step'                  => [
				'slug'            => 'gravityops-multi-path-step',
				'type'            => 'plugin',
				'name'            => 'GravityOps Multi-Path Step',
				'description'     => 'Add configurable multi-path Gravity Flow decision steps.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-multi-path-step/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-multi-path-step-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'mps-icon.svg',
				'premium_file'    => 'gravityops-multi-path-step-premium/gravityops-multi-path-step.php',
				'free_file'       => '',
				'freemius_helper' => 'gomps_fs',
				'wporg_slug'      => '',
			],
			'gravityops-workflow-step-runner'             => [
				'slug'            => 'gravityops-workflow-step-runner',
				'type'            => 'plugin',
				'name'            => 'GravityOps Workflow Step Runner',
				'description'     => 'Temporarily send Gravity Forms entries through Gravity Flow workflow steps.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-workflow-step-runner/',
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-workflow-step-runner-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'wsr-icon.svg',
				'premium_file'    => 'gravityops-workflow-step-runner-premium/gravityops-workflow-step-runner.php',
				'free_file'       => '',
				'freemius_helper' => 'gowsr_fs',
				'wporg_slug'      => '',
			],
			'gravityops-ai-feed-for-gravity-forms'        => [
				'slug'            => 'gravityops-ai-feed-for-gravity-forms',
				'type'            => 'plugin',
				'name'            => 'GravityOps AI Feed',
				'description'     => 'Run AI text and image generation from Gravity Forms feeds.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-ai-feed-for-gravity-forms/', // TODO
				'docs_url'        => $this->docs_url,
				'changelog_url'   => 'https://brightleafdigital.io/docs/gravityops-ai-feed-for-gravity-forms-changelog/',
				'is_free'         => false,
				'icon_filename'   => 'goaif-icon.svg',
				'premium_file'    => 'gravityops-ai-feed-for-gravity-forms/gravityops-ai-feed-for-gravity-forms.php',
				'free_file'       => '',
				'freemius_helper' => 'goaif_fs',
				'wporg_slug'      => '',
			],
		];
	}
}
