use serde::Deserialize;
use serde::Serialize;

use super::ast_node::WasmAstNode;
use super::headline::Noop;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
use crate::types::Entity;
use crate::wasm::to_wasm::ToWasmStandardProperties;

#[derive(Debug, Serialize, Deserialize)]
pub struct WasmEntity {
    pub(crate) name: String,
    pub(crate) latex: String,
    #[serde(rename = "latex-math-p")]
    pub(crate) latex_math_mode: bool,
    pub(crate) html: String,
    pub(crate) ascii: String,
    pub(crate) latin1: Noop,
    #[serde(rename = "utf-8")]
    pub(crate) utf8: String,
    #[serde(rename = "use-brackets-p")]
    pub(crate) use_brackets: bool,
}

to_wasm!(
    WasmEntity,
    Entity<'s>,
    original,
    wasm_context,
    { WasmAstNode::Entity(original) },
    { "entity".into() },
    {
        Ok((
            Vec::new(),
            WasmEntity {
                name: original.name.to_owned(),
                latex: original.latex.to_owned(),
                latex_math_mode: original.latex_math_mode,
                html: original.html.to_owned(),
                ascii: original.ascii.to_owned(),
                latin1: Noop {},
                utf8: original.utf8.to_owned(),
                use_brackets: original.use_brackets,
            },
        ))
    }
);