<?php
namespace OxygenApp\Config;
if ( ! defined( 'ABSPATH' ) ) exit;

use OxygenApp\Utils\LanguagesHelper;

class Config {

    private static $instance = null;
    private $config_data = [];

    function __construct() {
        $this->config_data = $this->getData();
    }

    private function getData(): array {
        return [
            'main_settings_page_slug' => 'wp-oxygen-app-settings-page',
            'users_dashboard_page_slug' => 'wp-oxygen-app-users-page',
            'languages_meta_key' => 'langs_metage',
            'app_rest_namespace' => 'oxygen-app/v1',
        ];
    }

    function getSetting(string $key, string $defaultValue = ''): mixed {
        return $this->config_data[$key] ?? $defaultValue;
    }

    public function getFrontendRoutes() {
        $data = [
            'root' => [
                'hash' => '',
                'page_title' => esc_html__('OxygenApp - Working and relaxing', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'signup' => [
                'hash' => 'signup',
                'page_title' => esc_html__('OxygenApp - signup', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'login' => [
                'hash' => 'login',
                'page_title' => esc_html__('OxygenApp - login', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'forgot_password' => [
                'hash' => 'forgot-password',
                'page_title' => esc_html__('OxygenApp - forgot password', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'upgrade' => [
                'hash' => 'upgrade',
                'page_title' => esc_html__('OxygenApp - upgrade', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'my_account' => [
                'hash' => 'my-account',
                'page_title' => esc_html__('OxygenApp - my account', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'error' => [
                'hash' => 'error',
                'page_title' => esc_html__('OxygenApp - Something went wrong', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'success' => [
                'hash' => 'success',
                'page_title' => esc_html__('OxygenApp - success', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'reset_password' => [
                'hash' => 'reset-password',
                'page_title' => esc_html__('OxygenApp - reset password', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'settings' => [
                'hash' => 'settings',
                'page_title' => esc_html__('OxygenApp - settings', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'upgrade' => [
                'hash' => 'upgrade',
                'page_title' => esc_html__('OxygenApp - upgrade', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'my_playlists' => [
                'hash' => 'my-playlists',
                'page_title' => esc_html__('OxygenApp - my playlists', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'new_playlist' => [
                'hash' => 'new-playlist',
                'page_title' => esc_html__('OxygenApp - new playlist', 'oxyleaf-app-working-and-relaxing-app'),
            ],
            'select_background' => [
                'hash' => 'select-background',
                'page_title' => esc_html__('OxygenApp - select background', 'oxyleaf-app-working-and-relaxing-app'),
            ],
        ];
        $routes = apply_filters('oxygen_app_filter_frontend_routes', $data, LanguagesHelper::getInstance()->getCurrentLanguageCode());
        return $routes;
    }

    public static function getInstance() {
        if (self::$instance == null) {
            self::$instance = new Config();
        }
        return self::$instance;
    }
}