# --- fn_module_data_table ---
# Static lib bundling the data_table module: TQL pipeline + Lua engine +
# viz_render + data_table.cpp entrypoint.
#
# Apps opt-in via:
#   target_link_libraries(<app> PRIVATE fn_module_data_table)
#
# Header access:
#   #include "data_table/data_table.h"
#   #include "core/data_table_types.h"
#
# Replaces former fn_table_viz target (renamed 2026-05-16 as part of the
# modules system rollout — issue 0097 modules).

cmake_minimum_required(VERSION 3.16)

# Module sources: the entrypoint lives here; members live in cpp/functions/.
set(_FN_CPP_ROOT ${CMAKE_SOURCE_DIR}/../cpp)

add_library(fn_module_data_table STATIC
    ${CMAKE_CURRENT_SOURCE_DIR}/data_table.cpp
    # Sub-funciones extraidas (issue 0107c)
    ${_FN_CPP_ROOT}/functions/viz/data_table_drill.cpp
    ${_FN_CPP_ROOT}/functions/viz/data_table_color_rules.cpp
    ${_FN_CPP_ROOT}/functions/viz/data_table_ai_panel.cpp
    ${_FN_CPP_ROOT}/functions/viz/data_table_chips.cpp
    ${_FN_CPP_ROOT}/functions/viz/data_table_grid.cpp
    ${_FN_CPP_ROOT}/functions/viz/data_table_viz_panels.cpp
    ${_FN_CPP_ROOT}/functions/core/compute_stage.cpp
    ${_FN_CPP_ROOT}/functions/core/compute_pipeline.cpp
    ${_FN_CPP_ROOT}/functions/core/tql_emit.cpp
    ${_FN_CPP_ROOT}/functions/core/tql_helpers.cpp
    ${_FN_CPP_ROOT}/functions/core/tql_apply.cpp
    ${_FN_CPP_ROOT}/functions/core/tql_to_sql.cpp
    ${_FN_CPP_ROOT}/functions/core/lua_engine.cpp
    ${_FN_CPP_ROOT}/functions/core/join_tables.cpp
    ${_FN_CPP_ROOT}/functions/core/auto_detect_type.cpp
    ${_FN_CPP_ROOT}/functions/core/compute_column_stats.cpp
    ${_FN_CPP_ROOT}/functions/core/llm_anthropic.cpp
    ${_FN_CPP_ROOT}/functions/viz/viz_render.cpp
)

# PUBLIC: consumers `#include "data_table/data_table.h"` and "core/..." via cpp/functions.
target_include_directories(fn_module_data_table PUBLIC
    ${CMAKE_SOURCE_DIR}/../modules
    ${_FN_CPP_ROOT}/functions
)
target_include_directories(fn_module_data_table PRIVATE
    ${_FN_CPP_ROOT}/framework
)

target_compile_definitions(fn_module_data_table PUBLIC FN_LLM_ANTHROPIC=1)

target_link_libraries(fn_module_data_table PUBLIC
    imgui
    implot
    lua54
)

# fn::local_path() (Ask AI export path + TQL save/load) needs fn_framework.
target_link_libraries(fn_module_data_table PRIVATE fn_framework)
