<?php
/**
 * Class Noesia Cs Feature Service.
 *
 * @package Noesia_Commerce_Suite
 */

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

/**
 * Class implementation.
 */
class Noesia_CS_Feature_Service {
	/**
	 * Runtime dependency or state value.
	 *
	 * @var mixed
	 */
	private $catalog = array();

	/**
	 * Handles the related plugin operation.
	 */
	public function __construct() {
		$this->catalog = array(
			'operations_home' => array(
				'title'       => __( 'Operations Home', 'noesia-commerce-suite' ),
				'description' => __( 'Explore one Pro Edition home for live checkout, customer care, QR Studio, Doctor workflows and store control.', 'noesia-commerce-suite' ),
				'area'        => __( 'Pro Operations', 'noesia-commerce-suite' ),
			),
			'checkout_confidence_analytics' => array(
				'title'       => __( 'Checkout Confidence Analytics', 'noesia-commerce-suite' ),
				'description' => __( 'See the sales signals that explain where orders come from and where confidence can improve.', 'noesia-commerce-suite' ),
				'area'        => __( 'Checkout Confidence Pro', 'noesia-commerce-suite' ),
			),
			'checkout_confidence_live_radar' => array(
				'title'       => __( 'Live Checkout Radar', 'noesia-commerce-suite' ),
				'description' => __( 'See real buying intent while the shopper is still on your store: active carts, checkout stage, cart value and hesitation moments.', 'noesia-commerce-suite' ),
				'area'        => __( 'Checkout Confidence Pro', 'noesia-commerce-suite' ),
			),
			'checkout_confidence_live_assist' => array(
				'title'       => __( 'Manual Live Assist', 'noesia-commerce-suite' ),
				'description' => __( 'Send a clear on-screen help message or offer to one active shopper before the sale is lost.', 'noesia-commerce-suite' ),
				'area'        => __( 'Checkout Confidence Pro', 'noesia-commerce-suite' ),
			),
			'checkout_confidence_ai_suggestion' => array(
				'title'       => __( 'AI Magic Suggestion', 'noesia-commerce-suite' ),
				'description' => __( 'Let AI draft a helpful offer or reassurance message, then approve it yourself before it reaches the shopper.', 'noesia-commerce-suite' ),
				'area'        => __( 'Checkout Confidence Pro', 'noesia-commerce-suite' ),
			),
			'live_radar_header_badge' => array(
				'title'       => __( '🔴 Live Radar Header Badge', 'noesia-commerce-suite' ),
				'description' => __( 'Add a visible live activity badge in the Noesia header so active checkout sessions are never hidden.', 'noesia-commerce-suite' ),
				'area'        => __( 'Checkout Confidence Pro', 'noesia-commerce-suite' ),
			),
			'care_templates' => array(
				'title'       => __( 'Care Hub Templates', 'noesia-commerce-suite' ),
				'description' => __( 'Give the customer care page a more premium visual style for warranty, support, reviews and reorders.', 'noesia-commerce-suite' ),
				'area'        => __( 'Care Experience Pro', 'noesia-commerce-suite' ),
			),
			'qr_email_branding' => array(
				'title'       => __( 'Branded QR & Care Emails', 'noesia-commerce-suite' ),
				'description' => __( 'Make customer QR cards, care emails and reminder buttons match your store brand.', 'noesia-commerce-suite' ),
				'area'        => __( 'Care Experience Pro', 'noesia-commerce-suite' ),
			),
			'product_category_warranty_rules' => array(
				'title'       => __( 'Product & Category Warranty Rules', 'noesia-commerce-suite' ),
				'description' => __( 'Set different warranty durations for specific products, SKUs or product categories.', 'noesia-commerce-suite' ),
				'area'        => __( 'Care Experience Pro', 'noesia-commerce-suite' ),
			),
			'customer_qr_studio' => array(
				'title'       => __( 'Customer QR Studio', 'noesia-commerce-suite' ),
				'description' => __( 'Create printable QR cards, labels, stickers and package inserts that bring customers back to care, support and reorders.', 'noesia-commerce-suite' ),
				'area'        => __( 'Customer QR Studio', 'noesia-commerce-suite' ),
			),
			'doctor_deep_scan' => array(
				'title'       => __( 'Doctor Pro Deep Store Scan', 'noesia-commerce-suite' ),
				'description' => __( 'Check large WooCommerce catalogs safely and find product issues that can hurt trust, SEO, stock clarity and sales.', 'noesia-commerce-suite' ),
				'area'        => __( 'Ecommerce Doctor Pro', 'noesia-commerce-suite' ),
			),
			'doctor_action_plan' => array(
				'title'       => __( 'Doctor Pro Action Plan', 'noesia-commerce-suite' ),
				'description' => __( 'Turn the scan into a clear fix list with priorities and direct product edit links.', 'noesia-commerce-suite' ),
				'area'        => __( 'Ecommerce Doctor Pro', 'noesia-commerce-suite' ),
			),
			'doctor_csv_export' => array(
				'title'       => __( 'Doctor Pro CSV Fix Report', 'noesia-commerce-suite' ),
				'description' => __( 'Download the Doctor Pro fix list as CSV so you or your team can work through it.', 'noesia-commerce-suite' ),
				'area'        => __( 'Ecommerce Doctor Pro', 'noesia-commerce-suite' ),
			),
			'woo_admin_skin' => array(
				'title'       => __( 'Woo Admin Skin Pro', 'noesia-commerce-suite' ),
				'description' => __( 'Make selected WooCommerce admin pages cleaner, calmer and easier to work with every day.', 'noesia-commerce-suite' ),
				'area'        => __( 'Woo Admin Skin Pro', 'noesia-commerce-suite' ),
			),
		);
	}

	/**
	 * Handles the related plugin operation.
	 */
	public function is_pro_active() {
		/**
		 * Allows a future license adapter or premium add-on to mark the Pro layer active.
		 * The free package does not include premium logic.
		 */
		return (bool) apply_filters( 'noesia_cs_is_pro_active', false );
	}

	/**
	 * Handles the related plugin operation.
	 *
	 * @param mixed $feature Feature.
	 */
	public function can_use( $feature ) {
		$feature  = sanitize_key( $feature );
		$default  = $this->is_pro_active();
		return (bool) apply_filters( 'noesia_cs_can_use_feature', $default, $feature );
	}

	/**
	 * Handles the related plugin operation.
	 */
	public function get_upgrade_url() {
		$default_url = is_admin() ? admin_url( 'admin.php?page=noesia-commerce-suite&tab=upgrade-pro' ) : home_url( '/' );
		$url         = apply_filters( 'noesia_cs_upgrade_url', $default_url );
		return esc_url_raw( $url );
	}

	/**
	 * Handles the related plugin operation.
	 */
	public function get_plan_label() {
		return $this->is_pro_active() ? __( 'Pro Edition', 'noesia-commerce-suite' ) : __( 'Free Core', 'noesia-commerce-suite' );
	}

	/**
	 * Handles the related plugin operation.
	 */
	public function get_plan_description() {
		if ( $this->is_pro_active() ) {
			return __( 'The Pro commerce layer is active for this store.', 'noesia-commerce-suite' );
		}
		return __( 'Free Core is active. Explore the separate Pro Edition for live checkout workflows, AI-assisted suggestions, QR care tools, advanced customer care, recovery contacts and extended store operations.', 'noesia-commerce-suite' );
	}

	/**
	 * Handles the related plugin operation.
	 */
	public function get_catalog() {
		return $this->catalog;
	}
}
