import {
  chatMachineSetup,
  chatRootStateConfig,
} from "./machine/session-flow";
import { createInitialChatState } from "./chat-state";

export type { ChatState } from "./chat-state";
export { initialState } from "./chat-state";
export type { ChatEvent } from "./chat-events";

export const chatMachine = chatMachineSetup.createMachine({
  id: "chat",
  context: ({ input }) =>
    createInitialChatState(
      input.characterId,
      input.emptyChatGreeting,
    ),
  ...chatRootStateConfig,
});

export type ChatMachine = typeof chatMachine;
