<?php 

if ( ! defined( "ABSPATH" ) ) exit;

function docuchat_script_styles_files() {
    $token = get_option( DOCUCHAT_TOKEN ) ?  get_option( DOCUCHAT_TOKEN ) : false; 
    $email = get_option( DOCUCHAT_EMAIL ) ?  get_option( DOCUCHAT_EMAIL ) : false;

    wp_enqueue_media();
    wp_enqueue_style( "docuchat_styles_for_backend", plugins_url( "../src/styles/docuchat_backend.css", __FILE__ ), array(), "1.0.0" );
    wp_enqueue_script( "docuchat_script_for_backend", plugins_url( "../src/docuchat_backend.js", __FILE__ ), array(), "1.0.0", true );  
     
    wp_localize_script( "docuchat_script_for_backend", "docuchat_ajax", array(
      "url"                           => admin_url( "admin-ajax.php" ), 
      "adminUrl"                      => admin_url('options-general.php?page=DocuChat'),  
      "partialDelete_nonce"           => wp_create_nonce("partialDelete"), 
      "emailRegistred"                =>  $email,
      "token"                         =>  $token, 
    ));
  } 

  function docuchat_script_styles_files_front(){
    $token = get_option( DOCUCHAT_TOKEN ) ?  get_option( DOCUCHAT_TOKEN ) : false;
    wp_enqueue_script('jquery');
    wp_enqueue_style( "docuchat_styles_for_frontend", plugins_url( "../src/styles/docuchat_front.css", __FILE__ ), array(), "1.0.0" );
    wp_enqueue_script( "docuchat_script_for_frontend", plugins_url( "../src/docuchat_front.js", __FILE__ ), array(), "1.0.0", true );
    wp_localize_script( "docuchat_script_for_frontend", "docuchat_ajax", array( 
      "token"           =>  $token, 
      "url"             => admin_url( "admin-ajax.php" ), 
      "nonce"           => wp_create_nonce("llmChat"), 
      "initialMessage"  =>  "Welcome to Docuchat, I'm here to help you, please let me know how I can help you",
    ));
  } 