import { defineStore } from 'pinia';
import { ref } from 'vue';

export const chatbotStore = defineStore('chatbot', () => {
  const messages = ref([]);

  const addMessage = (role, text) => {
    messages.value.push({
      role,
      text,
      time: new Date().toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' }),
    });
  };

  const clear = () => {
    messages.value = [];
  };

  return { messages, addMessage, clear };
});
