<?php

namespace BWDK\Support;

class Constant
{

    const META_BWDK_UUID = '_bwdk_order_uuid';
    const META_BWDK_ASSIGN_URL = '_bwdk_order_assign_url';
    const META_BWDK_CB_URL = '_bwdk_order_callback_url';
    const META_BWDK_JSON_CB = '_bwdk_order_json_cb';
    const META_BWDK_WOO_ORDER_UUID = '_bwdk_woo_order_uuid';
    const META_BWDK_REFUND_STATUS = '_bwdk_refund_status';
    const BWDK_OPTION_NAME = 'bwdk_options';
    const BWDK_CB_URL = '/bwdk-callback/';

    const RIAL = "IRR";
    const TOMAN = "IRT";


    public function __construct()
    {
        $this->defineConstants();
    }

    protected function defineConstants(): void
    {
        $path = trailingslashit(plugin_dir_path(dirname(__FILE__, 2)));
        $url = trailingslashit(plugin_dir_url(dirname(__FILE__, 2)));

        $this->define('BWDK_PATH', $path);
        $this->define('BWDK_URL', $url);

        // Assets - Admin
        $this->define('BWDK_ADMIN_CSS', $url . 'assets/admin/css/');
        $this->define('BWDK_ADMIN_JS', $url . 'assets/admin/js/');
        $this->define('BWDK_ADMIN_IMG', $url . 'assets/admin/img/');
        $this->define('BWDK_ADMIN_FONTS', $url . 'assets/admin/fonts/');

        // Assets - Public
        $this->define('BWDK_PUBLIC_CSS', $url . 'assets/public/css/');
        $this->define('BWDK_PUBLIC_JS', $url . 'assets/public/js/');
        $this->define('BWDK_PUBLIC_IMG', $url . 'assets/public/img/');
        $this->define('BWDK_PUBLIC_FONTS', $url . 'assets/public/fonts/');

        // Template paths (PHP files)
        $this->define('BWDK_ADMIN_TEMPLATE', $path . 'src/Admin/Views/');
        $this->define('BWDK_FRONT_TEMPLATE', $path . 'src/Front/Views/');



        if(!defined('BWDK_STORE_CURRENCY')){
            define('BWDK_STORE_CURRENCY', get_woocommerce_currency());
        }

        if(!defined('BWDK_STORE_GET_PRICE_DECIMALS')){
            define('BWDK_STORE_GET_PRICE_DECIMALS', wc_get_price_decimals());
        }


    }

    protected function define(string $name, string $value): void
    {
        if (!defined($name)) {
            define($name, $value);
        }
    }
}
