<?php
/**
 * KimaAI Plugin
 *
 * @package KimaAI
 * @copyright Copyright (C) 2025, KimaAI - support@kimaai.com
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 or higher
 *
 * @wordpress-plugin
 * Plugin Name: KimaAI | AI Chatbot, ChatGPT content writer and more
 * Version: 1.4.9
 * Plugin URI: https://kimaai.com
 * Description: The first true all-in-one AI plugin for WordPress, including chatbot, (the following features are on the way: ChatGPT, Content Writer, Auto Content Writer, ChatBot, Product Writer, Image Generator, AutoGPT, ChatPDF, AI Training, Embeddings and more).
 * Author: KimaAI Team
 * Author URI: https://kimaai.com/about
 * Text Domain: kimaai
 * Domain Path: /languages
 * License: GPL v3
 * Requires at least: 6.0
 * Requires PHP: 8.0
 * @fs_premium_only /premium/
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

declare(strict_types=1);

namespace KimaAI;

defined('ABSPATH') || exit;

register_activation_hook(__FILE__, __NAMESPACE__ . '\Schema::activate');
register_deactivation_hook(__FILE__, __NAMESPACE__ . '\Schema::deactivate');
register_uninstall_hook(__FILE__, __NAMESPACE__ . '\Schema::uninstall');

if (!class_exists(KimaAI::class) && is_readable(__DIR__ . '/vendor/autoload.php')) {
  require_once __DIR__ . '/vendor/autoload.php';
}

if (!function_exists('as_schedule_single_action')) {
  $as = __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
  if (is_readable($as)) {
    require_once $as;
  }
}

require_once __DIR__ . '/app/functions.php';

if (!function_exists(__NAMESPACE__ . '\kimaai_fs')) {
  // Create a helper function for easy SDK access.
  function kimaai_fs() {
    global $kimaai_fs;

    if (!isset($kimaai_fs)) {
      // Include Freemius SDK.
      // SDK is auto-loaded through composer
      $kimaai_fs = fs_dynamic_init([
        'id' => '19071',
        'slug' => 'kimaai',
        'premium_slug' => 'kimaai-pro',
        'type' => 'plugin',
        'public_key' => 'pk_46b5efaa6b4315e6719eca711e104',
        'is_premium' => false,
        'premium_suffix' => 'Pro',
        // If your plugin is a serviceware, set this option to false.
        'has_premium_version' => true,
        'has_addons' => true,
        'has_paid_plans' => true,
        'menu' => [
          'slug' => 'kimaai',
          'support' => false,
          'first-path' => 'admin.php?page=kimaai-wizard',
        ],
      ]);
    }

    return $kimaai_fs;
  }

  // Init Freemius.
  kimaai_fs();
  // Signal that SDK was initiated.
  do_action('kimaai_fs_loaded');
}
else {
  kimaai_fs()->set_basename(true, __FILE__);
}

define('KIMAAI_PLUGIN_FILE', __FILE__);
define('KIMAAI_PLUGIN_PATH', plugin_dir_path(KIMAAI_PLUGIN_FILE));
define('KIMAAI_PLUGIN_URL', plugin_dir_url(KIMAAI_PLUGIN_FILE));
define('KIMAAI_PLUGIN_ADMIN_ASSETS', KIMAAI_PLUGIN_URL . 'build/admin/');
define('KIMAAI_PLUGIN_CHATBOT_ASSETS', KIMAAI_PLUGIN_URL . 'build/chatbot/');
define('KIMAAI_PLUGIN_BASENAME', plugin_basename(KIMAAI_PLUGIN_FILE));
define('KIMAAI_VERSION', '1.4.9');

class_exists(KimaAI::class) && KimaAI::instance();
