diff --git a/hooks/use-chat-storage.test.ts b/hooks/use-chat-storage.test.ts new file mode 100644 index 0000000..6f2f533 --- /dev/null +++ b/hooks/use-chat-storage.test.ts @@ -0,0 +1,276 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, renderHook, waitFor } from '@testing-library/react'; +import { useChatStorage, type SessionSummary } from './use-chat-storage'; +import type { Message } from './use-chat'; + +// Backend Tauri e Ollama (fetch para localhost:11434) viram fakes: nenhum modelo é chamado. +const invokeMock = vi.hoisted(() => vi.fn()); +vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock })); + +let storedSessions: SessionSummary[] = []; +let saveError: unknown = null; + +function session(id: string, title: string): SessionSummary { + return { id, title, emoji: '💬', updated_at: '2026-01-01', preview: '', platform: 'Linux' }; +} + +function ollama(reply: { ok?: boolean; status?: number; content?: unknown } | Error) { + const fetchMock = vi.fn(async () => { + if (reply instanceof Error) throw reply; + return { + ok: reply.ok ?? true, + status: reply.status ?? 200, + json: async () => (reply.content === undefined ? {} : { message: { content: reply.content } }), + }; + }); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +const saves = () => + invokeMock.mock.calls.filter(([cmd]) => cmd === 'save_chat_session').map(([, args]) => args as { + id: string; title: string; messages: Message[]; platform: string; memory_context: string[]; + }); + +async function mount() { + const hook = renderHook(() => useChatStorage()); + await waitFor(() => expect(invokeMock).toHaveBeenCalledWith('load_chat_sessions')); + await act(async () => {}); + return hook; +} + +const user = (content: string): Message => ({ role: 'user', content }); +const bot = (content: string, metadata?: unknown): Message => ({ role: 'assistant', content, metadata }); + +beforeEach(() => { + storedSessions = []; + saveError = null; + invokeMock.mockReset(); + invokeMock.mockImplementation(async (cmd: string) => { + if (cmd === 'load_chat_sessions') return storedSessions; + if (cmd === 'save_chat_session') { + if (saveError) throw saveError; + return undefined; + } + throw new Error(`comando inesperado: ${cmd}`); + }); + vi.spyOn(navigator, 'platform', 'get').mockReturnValue('Linux x86_64'); + for (const level of ['log', 'warn', 'error'] as const) vi.spyOn(console, level).mockImplementation(() => {}); +}); + +describe('generateTitleFromUserMessage', () => { + it('modelo responde título: devolve o título limpo', async () => { + ollama({ content: ' Receita de bolo ' }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('como faço bolo?')).toBe('Receita de bolo'); + }); + + it.each([ + ['404 (modelo ausente)', 404], + ['500 (erro do servidor)', 500], + ['400 (outro erro)', 400], + ])('HTTP %s: usa a mensagem do usuário', async (_n, status) => { + ollama({ ok: false, status }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage(' pergunta curta ')).toBe('pergunta curta'); + }); + + it('fetch rejeita (Ollama fora do ar): usa a mensagem do usuário', async () => { + ollama(new TypeError('Failed to fetch')); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('oi')).toBe('oi'); + }); + + it('resposta sem message.content: usa a mensagem do usuário', async () => { + ollama({}); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('oi')).toBe('oi'); + }); + + it('título entre aspas: remove as aspas', async () => { + ollama({ content: `"'Viagem a Roma'"` }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('x')).toBe('Viagem a Roma'); + }); + + it('título só com pontuação: usa a mensagem do usuário', async () => { + ollama({ content: '"..."' }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('pergunta')).toBe('pergunta'); + }); + + it('título só com bloco : usa a mensagem do usuário', async () => { + ollama({ content: '{"a":1}' }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('pergunta')).toBe('pergunta'); + }); + + it('título com mais de 60 caracteres: corta em 60 e põe reticências', async () => { + ollama({ content: 'x'.repeat(80) }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('p')).toBe('x'.repeat(60) + '...'); + }); + + it('fallback com mensagem acima de 50 caracteres: corta em 50 e põe reticências', async () => { + ollama({ ok: false, status: 404 }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage('y'.repeat(70))).toBe('y'.repeat(50) + '...'); + }); + + it('fallback com mensagem em branco: "Nova Conversa"', async () => { + ollama({ ok: false, status: 404 }); + const { result } = await mount(); + expect(await result.current.generateTitleFromUserMessage(' ')).toBe('Nova Conversa'); + }); +}); + +describe('saveSession', () => { + it('sem mensagens: não salva', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [])); + expect(saves()).toEqual([]); + }); + + it('sessão existente com título: salva com o título atual e as keywords de string sem repetir', async () => { + storedSessions = [session('s1', 'Título salvo')]; + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [ + user('q'), + bot('a', { keywords: ['rust', 'tauri', 7] }), + bot('b', { keywords: ['rust'] }), + bot('c', { keywords: 'não é lista' }), + user('d'), + ])); + expect(saves()).toEqual([expect.objectContaining({ id: 's1', title: 'Título salvo', platform: 'Linux x86_64', memory_context: ['rust', 'tauri'] })]); + }); + + it('sessão existente e currentTitle informado: currentTitle prevalece', async () => { + storedSessions = [session('s1', 'Antigo')]; + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q')], 'Renomeado')); + expect(saves()[0].title).toBe('Renomeado'); + }); + + it('sessão existente: falha ao salvar não propaga nem recarrega a lista', async () => { + storedSessions = [session('s1', 'Antigo')]; + saveError = new Error('disco cheio'); + const { result } = await mount(); + const loadsBefore = invokeMock.mock.calls.filter(([c]) => c === 'load_chat_sessions').length; + await act(() => result.current.saveSession('s1', [user('q')])); + expect(invokeMock.mock.calls.filter(([c]) => c === 'load_chat_sessions')).toHaveLength(loadsBefore); + }); + + it('platform vazio: usa o primeiro token do userAgent', async () => { + storedSessions = [session('s1', 'Antigo')]; + vi.spyOn(navigator, 'platform', 'get').mockReturnValue(''); + vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (X11)'); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q')])); + expect(saves()[0].platform).toBe('Mozilla/5.0'); + }); + + it('sessão nova com só a mensagem do usuário: espera a resposta e não salva', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q')])); + expect(saves()).toEqual([]); + }); + + it('sessão existente com "Nova Conversa" e 1 mensagem: tratada como nova, não salva', async () => { + storedSessions = [session('s1', 'Nova Conversa')]; + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q')])); + expect(saves()).toEqual([]); + }); + + it('sessão nova com currentTitle: salva já com ele, sem chamar o modelo', async () => { + const fetchMock = ollama({ content: 'não usar' }); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a')], 'Dado')); + expect(saves()[0].title).toBe('Dado'); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('sessão nova com metadata.title: usa o título aparado', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a', { title: ' Do modelo ', summary: 'resumo' })])); + expect(saves()[0].title).toBe('Do modelo'); + }); + + it('sessão nova com só metadata.summary: usa o resumo', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a', { summary: ' Resumo ' })])); + expect(saves()[0].title).toBe('Resumo'); + }); + + it('metadata.title em branco: passa para a próxima resposta do assistente', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a', { title: ' ' }), bot('b', { summary: 'Segundo' })])); + expect(saves()[0].title).toBe('Segundo'); + }); + + it('metadata.summary em branco: segue para a próxima resposta', async () => { + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a', { summary: ' ' }), bot('b', { title: 'Terceiro' })])); + expect(saves()[0].title).toBe('Terceiro'); + }); + + it('sessão nova com metadata.title: falha ao salvar não propaga', async () => { + saveError = new Error('disco cheio'); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a', { title: 'T' })])); + expect(saves()).toHaveLength(1); + }); + + it('sem título em metadata: gera com o modelo usando até 4 mensagens sem metadata e salva', async () => { + const fetchMock = ollama({ content: 'Título gerado' }); + const { result } = await mount(); + const msgs = [user('q1'), bot('r1 {"x":1}'), user('q2'), bot('r2'), user('q3')]; + await act(() => result.current.saveSession('s1', msgs)); + await waitFor(() => expect(saves()).toHaveLength(1)); + expect(saves()[0].title).toBe('Título gerado'); + const sent = JSON.parse((fetchMock.mock.calls[0] as unknown as [string, { body: string }])[1].body).messages; + expect(sent.slice(1).map((m: Message) => m.content)).toEqual(['q1', 'r1', 'q2', 'r2']); + expect(result.current.isGeneratingTitle).toBe(false); + }); + + it.each([ + ['HTTP 404', { ok: false, status: 404 }], + ['HTTP 400', { ok: false, status: 400 }], + ['resposta vazia', { content: '' }], + ['título só pontuação', { content: '"!!"' }], + ['erro de rede', new Error('Failed to fetch')], + ])('geração falha (%s): salva com o início da primeira pergunta', async (_n, reply) => { + ollama(reply); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [bot('olá'), user(`${'p'.repeat(60)} {}`)])); + await waitFor(() => expect(saves()).toHaveLength(1)); + expect(saves()[0].title).toBe('p'.repeat(50) + '...'); + expect(result.current.isGeneratingTitle).toBe(false); + }); + + it('geração falha e não há mensagem do usuário: "Nova Conversa"', async () => { + ollama({ ok: false, status: 404 }); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [bot('a'), bot('b')])); + await waitFor(() => expect(saves()).toHaveLength(1)); + expect(saves()[0].title).toBe('Nova Conversa'); + }); + + it('título gerado mas falha ao salvar: libera isGeneratingTitle', async () => { + ollama({ content: 'Ok' }); + saveError = new Error('disco cheio'); + const { result } = await mount(); + await act(() => result.current.saveSession('s1', [user('q'), bot('a')])); + await waitFor(() => expect(saves()).toHaveLength(1)); + await waitFor(() => expect(result.current.isGeneratingTitle).toBe(false)); + }); + + it('geração de título já em andamento: não dispara outra', async () => { + const fetchMock = ollama({ content: 'x' }); + const { result } = await mount(); + act(() => result.current.setIsGeneratingTitle(true)); + await act(() => result.current.saveSession('s1', [user('q'), bot('a')])); + expect(fetchMock).not.toHaveBeenCalled(); + expect(saves()).toEqual([]); + }); +}); diff --git a/hooks/use-chat.test.ts b/hooks/use-chat.test.ts new file mode 100644 index 0000000..b117c5e --- /dev/null +++ b/hooks/use-chat.test.ts @@ -0,0 +1,265 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, renderHook, waitFor } from '@testing-library/react'; +import { detectToolCalls, useChat, type Message } from './use-chat'; +import { useSettingsStore } from '@/store/settings-store'; + +// Backend Tauri e eventos de streaming do Ollama viram fakes em processo. +const { invokeMock, handlers } = vi.hoisted(() => ({ + invokeMock: vi.fn(), + handlers: {} as Record void>, +})); +vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock })); +vi.mock('@tauri-apps/api/event', () => ({ + listen: vi.fn(async (name: string, cb: (event: { payload: unknown }) => void) => { + handlers[name] = cb; + return () => {}; + }), +})); + +function backend({ running = true as boolean | Error, stream = undefined as unknown } = {}) { + invokeMock.mockImplementation(async (cmd: string) => { + if (cmd === 'check_ollama_running') { + if (running instanceof Error) throw running; + return running; + } + if (cmd === 'chat_stream') { + if (stream !== undefined) throw stream; + return undefined; + } + throw new Error(`comando inesperado: ${cmd}`); + }); +} + +const streamCall = () => invokeMock.mock.calls.find(([cmd]) => cmd === 'chat_stream')?.[1] as + | { sessionId: string | null; messages: Array<{ role: string; content: string }>; systemPrompt: string | null } + | undefined; + +async function mount(history: Message[] = []) { + const hook = renderHook(() => useChat()); + await waitFor(() => expect(handlers['chat-token']).toBeDefined()); + if (history.length) act(() => hook.result.current.setMessages(history)); + return hook; +} + +const lastContent = (messages: Message[]) => messages[messages.length - 1].content; + +beforeEach(() => { + invokeMock.mockReset(); + for (const k of Object.keys(handlers)) delete handlers[k]; + localStorage.clear(); + useSettingsStore.setState({ contextWindow: 4096 }); + for (const level of ['log', 'warn', 'error', 'group', 'groupEnd'] as const) vi.spyOn(console, level).mockImplementation(() => {}); +}); + +describe('useChat.sendMessage', () => { + it('mensagem nova: adiciona a do usuário e um assistente vazio e chama chat_stream', async () => { + backend(); + const { result } = await mount(); + await act(() => result.current.sendMessage('oi modelo', 'llama3')); + expect(result.current.messages).toEqual([ + { role: 'user', content: 'oi modelo' }, + { role: 'assistant', content: '' }, + ]); + expect(streamCall()).toMatchObject({ sessionId: null, systemPrompt: null, messages: [{ role: 'user', content: 'oi modelo' }] }); + expect(result.current.isLoading).toBe(false); + }); + + it('última mensagem já é a mesma do usuário: não duplica', async () => { + backend(); + const { result } = await mount([{ role: 'user', content: 'repetida' }]); + await act(() => result.current.sendMessage('repetida', 'm')); + expect(result.current.messages.filter((m) => m.role === 'user')).toHaveLength(1); + }); + + it('última mensagem do usuário com outro texto: adiciona a nova', async () => { + backend(); + const { result } = await mount([{ role: 'user', content: 'antiga' }]); + await act(() => result.current.sendMessage('nova', 'm')); + expect(result.current.messages.map((m) => m.content)).toEqual(['antiga', 'nova', '']); + }); + + it('onBeforeModelRequest recebe as mensagens pendentes antes do modelo', async () => { + backend(); + const { result } = await mount(); + const hook = vi.fn(async () => { + expect(streamCall()).toBeUndefined(); + }); + await act(() => result.current.sendMessage('x', 'm', undefined, { onBeforeModelRequest: hook })); + expect(hook).toHaveBeenCalledWith([{ role: 'user', content: 'x' }]); + }); + + it('com system prompt: vai na frente do payload e no parâmetro systemPrompt', async () => { + backend(); + const { result } = await mount(); + await act(() => result.current.sendMessage('x', 'm', 'seja breve')); + expect(streamCall()).toMatchObject({ + systemPrompt: 'seja breve', + messages: [{ role: 'system', content: 'seja breve' }, { role: 'user', content: 'x' }], + }); + }); + + it('histórico acima de 90% da janela de tokens: descarta as mensagens mais antigas', async () => { + backend(); + useSettingsStore.setState({ contextWindow: 100 }); // 90 tokens ≈ 360 caracteres + const { result } = await mount([ + { role: 'user', content: 'a'.repeat(200) }, + { role: 'assistant', content: 'b'.repeat(200) }, + ]); + await act(() => result.current.sendMessage('agora', 'm')); + expect(streamCall()!.messages.map((m) => m.content)).toEqual(['b'.repeat(200), 'agora']); + }); + + it('contextWindow 0: usa 4096 e mantém o histórico grande', async () => { + backend(); + useSettingsStore.setState({ contextWindow: 0 }); + const { result } = await mount([{ role: 'assistant', content: 'c'.repeat(8000) }]); + await act(() => result.current.sendMessage('x', 'm')); + expect(streamCall()!.messages).toHaveLength(2); + }); + + it('mais de 9 mensagens anteriores: envia só as 9 últimas mais a atual', async () => { + backend(); + const history: Message[] = Array.from({ length: 12 }, (_, i) => ({ role: i % 2 ? 'assistant' : 'user', content: `m${i}` })); + const { result } = await mount(history); + await act(() => result.current.sendMessage('atual', 'm')); + expect(streamCall()!.messages.map((m) => m.content)).toEqual(['m3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10', 'm11', 'atual']); + }); + + it('payloadContentOverride: troca só o conteúdo enviado da última mensagem do usuário', async () => { + backend(); + const { result } = await mount(); + await act(() => result.current.sendMessage('visível', 'm', 'sys', { payloadContentOverride: 'com contexto web' })); + expect(streamCall()!.messages).toEqual([ + { role: 'system', content: 'sys' }, + { role: 'user', content: 'com contexto web' }, + ]); + expect(result.current.messages[0].content).toBe('visível'); + }); + + it('assistente vazio já no fim: não adiciona outro antes do streaming', async () => { + backend(); + const { result } = await mount([{ role: 'user', content: 'q' }, { role: 'assistant', content: '' }]); + await act(() => result.current.sendMessage('q2', 'm')); + expect(result.current.messages.map((m) => [m.role, m.content])).toEqual([ + ['user', 'q'], ['assistant', ''], ['user', 'q2'], ['assistant', ''], + ]); + }); + + it('Ollama parado: mostra o erro e não chama chat_stream', async () => { + backend({ running: false }); + const { result } = await mount(); + await act(() => result.current.sendMessage('x', 'm')); + expect(lastContent(result.current.messages)).toContain('Ollama não está rodando'); + expect(streamCall()).toBeUndefined(); + }); + + it('verificação do Ollama falha por outro motivo: segue e chama chat_stream', async () => { + backend({ running: new Error('ipc indisponível') }); + const { result } = await mount(); + await act(() => result.current.sendMessage('x', 'm')); + expect(streamCall()).toBeDefined(); + expect(lastContent(result.current.messages)).toBe(''); + }); + + it('chat-created antes do envio: usa o session_id recebido', async () => { + backend(); + const { result } = await mount(); + act(() => handlers['chat-created']({ payload: { session_id: 'sess-1', title: 't', emoji: 'e' } })); + await act(() => result.current.sendMessage('x', 'm')); + expect(streamCall()!.sessionId).toBe('sess-1'); + }); + + it.each([ + ['RequestTimeout', new Error('RequestTimeout'), '**Timeout:**'], + ['AbortError', Object.assign(new Error('cancelado'), { name: 'AbortError' }), '**Timeout:**'], + ['ConnectionError', new Error('ConnectionError'), '**Erro de Conexão:**'], + ['Failed to fetch', new Error('TypeError: Failed to fetch'), '**Erro de Conexão:**'], + ['ModelNotFound', new Error('ModelNotFound'), '**Modelo Não Encontrado:** O modelo "qwen"'], + ['ServerError', new Error('ServerError'), '**Erro do Servidor:**'], + ['NoResponseBody', new Error('NoResponseBody'), 'não retornou uma resposta válida'], + ['HTTPError com status', new Error('HTTPError: 404'), '**Erro HTTP 404:**'], + ['HTTPError sem status', new Error('HTTPError'), '**Erro HTTP desconhecido:**'], + ['erro genérico', new Error('disco cheio'), 'Detalhes: disco cheio'], + ['rejeição string do Rust', 'falha no rust', 'Detalhes: falha no rust'], + ])('chat_stream falha com %s: mensagem de erro específica', async (_n, error, expected) => { + backend({ stream: error }); + const { result } = await mount(); + await act(() => result.current.sendMessage('x', 'qwen')); + expect(lastContent(result.current.messages)).toContain(expected); + expect(result.current.isLoading).toBe(false); + }); +}); + +describe('parseMetadata (fim do streaming via chat-token done)', () => { + async function streamed(tokens: string[]) { + backend(); + const { result } = await mount(); + await act(() => result.current.sendMessage('q', 'm')); + act(() => { + for (const content of tokens) handlers['chat-token']({ payload: { session_id: 's', content, done: false } }); + handlers['chat-token']({ payload: { session_id: 's', content: '', done: true } }); + }); + return result.current.messages[result.current.messages.length - 1]; + } + + it('resposta com bloco : separa o JSON do texto', async () => { + const msg = await streamed(['Resposta final.', '\n\n{"emoji":"🤖"}\n']); + expect(msg).toEqual({ role: 'assistant', content: 'Resposta final.', metadata: { emoji: '🤖' } }); + }); + + it('resposta sem metadata: texto intacto e metadata indefinida', async () => { + const msg = await streamed(['Olá ', 'mundo']); + expect(msg).toEqual({ role: 'assistant', content: 'Olá mundo', metadata: undefined }); + }); + + it('JSON inválido no bloco: remove o bloco e não define metadata', async () => { + const msg = await streamed(['Texto {quebrado']); + expect(msg).toEqual({ role: 'assistant', content: 'Texto', metadata: undefined }); + }); + + it('dois blocos válidos: usa o primeiro e remove ambos', async () => { + const msg = await streamed(['A {"n":1} B {"n":2}']); + expect(msg.metadata).toEqual({ n: 1 }); + expect(msg.content).toBe('A B'); + }); + + it('prefixo "---" sobrando no fim: é removido', async () => { + const msg = await streamed(['Fim da resposta\n---\n{"a":1}']); + expect(msg.content).toBe('Fim da resposta'); + }); + + it('nenhum token antes do done: mantém o conteúdo atual da mensagem', async () => { + const msg = await streamed([]); + expect(msg).toEqual({ role: 'assistant', content: '', metadata: undefined }); + }); +}); + +describe('detectToolCalls', () => { + const tools = [{ server_name: 'srv', tool: { name: 'search' } }]; + + it('"use with ": argumentos em JSON', () => { + expect(detectToolCalls('use search with {"q": "rust"}', tools)).toEqual([ + { server_name: 'srv', tool_name: 'search', arguments: { q: 'rust' } }, + ]); + }); + + it('texto sem padrão de chamada: nenhuma', () => { + expect(detectToolCalls('apenas uma resposta', tools)).toEqual([]); + }); + + it('ferramenta não disponível: ignora', () => { + expect(detectToolCalls('use fetch with {"u": 1}', tools)).toEqual([]); + }); + + it('argumentos chave=valor: remove aspas e ignora pares sem valor', () => { + expect(detectToolCalls(`call search with q=rust, lang='pt', solto`, tools)[0].arguments).toEqual({ q: 'rust', lang: 'pt' }); + }); + + it('forma tool(args) com nome em maiúsculas: casa sem diferenciar caixa', () => { + expect(detectToolCalls('SEARCH(q=1)', tools)).toEqual([{ server_name: 'srv', tool_name: 'search', arguments: { q: '1' } }]); + }); + + it('tool( ) com argumentos em branco: objeto vazio', () => { + expect(detectToolCalls('search( )', tools)[0].arguments).toEqual({}); + }); +}); diff --git a/hooks/use-deep-research.test.ts b/hooks/use-deep-research.test.ts new file mode 100644 index 0000000..4ff3348 --- /dev/null +++ b/hooks/use-deep-research.test.ts @@ -0,0 +1,73 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, renderHook } from '@testing-library/react'; +import { useDeepResearch } from './use-deep-research'; + +// Logger (invoke) e análise contextual viram fakes; o Ollama responde por fetch fake. +vi.mock('@tauri-apps/api/core', () => ({ invoke: vi.fn(async () => undefined) })); +vi.mock('@/lib/contextual-analyzer', () => ({ + analyzeQueryContext: vi.fn(async () => { + throw new Error('sem análise contextual neste teste'); + }), +})); + +function llmReplies(response: string) { + vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true, json: async () => ({ response }) }))); +} + +const QUERY = 'historia da linguagem rust'; + +async function decompose(response: string) { + llmReplies(response); + const { result } = renderHook(() => useDeepResearch()); + let plan: string[] = []; + await act(async () => { + plan = await result.current.decompose(QUERY, 'llama3'); + }); + return { plan, error: result.current.state.logs[0]?.error }; +} + +beforeEach(() => { + for (const level of ['log', 'warn', 'error', 'info'] as const) vi.spyOn(console, level).mockImplementation(() => {}); +}); + +describe('extractQueriesFromResponse (via decompose)', () => { + it('array JSON puro: mantém só strings não vazias', async () => { + const r = await decompose('["rust origem", "", 3, "rust mozilla"]'); + expect(r).toEqual({ plan: ['rust origem', 'rust mozilla'], error: undefined }); + }); + + it('bloco ```json: remove a cerca antes de interpretar', async () => { + expect((await decompose('```json\n["rust 1.0"]\n```')).plan).toEqual(['rust 1.0']); + }); + + it('JSON no meio de texto: extrai o trecho', async () => { + expect((await decompose('Aqui está o plano: ["rust graydon"] espero ajudar')).plan).toEqual(['rust graydon']); + }); + + it('trecho parecido com JSON mas inválido: cai na pergunta original com erro registrado', async () => { + const r = await decompose('plano: [rust sem aspas]'); + expect(r).toEqual({ plan: [QUERY], error: 'JSON Parse Failed: Could not extract JSON from response' }); + }); + + it('resposta sem JSON: cai na pergunta original com erro registrado', async () => { + const r = await decompose('não sei'); + expect(r).toEqual({ plan: [QUERY], error: 'JSON Parse Failed: No JSON found in response' }); + }); + + it('objeto com chave conhecida: usa o array dessa chave', async () => { + expect((await decompose('{"search_queries": ["rust história", " "]}')).plan).toEqual(['rust história']); + }); + + it('chave conhecida que não é array: segue para a próxima chave', async () => { + expect((await decompose('{"query": "rust", "plan": ["rust plano"]}')).plan).toEqual(['rust plano']); + }); + + it('objeto sem chave conhecida: usa o primeiro array de strings', async () => { + expect((await decompose('{"nums": [1], "vazio": [], "itens": ["rust itens"]}')).plan).toEqual(['rust itens']); + }); + + it('objeto sem nenhum array de strings: cai na pergunta original', async () => { + const r = await decompose('{"nums": [1, 2], "texto": "rust"}'); + expect(r).toEqual({ plan: [QUERY], error: 'JSON Parse Failed: No array of queries found in response' }); + }); +}); diff --git a/hooks/use-mcp-tools.test.ts b/hooks/use-mcp-tools.test.ts new file mode 100644 index 0000000..428015a --- /dev/null +++ b/hooks/use-mcp-tools.test.ts @@ -0,0 +1,68 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { renderHook } from '@testing-library/react'; +import { useMcpTools, type McpToolInfo } from './use-mcp-tools'; + +// Servidores MCP reais não são iniciados: o comando Tauri devolve lista vazia. +const invokeMock = vi.hoisted(() => vi.fn(async () => [])); +vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock })); + +const tool = (server_name: string, name: string, input_schema?: unknown): McpToolInfo => ({ + server_name, + tool: { name, description: `desc ${name}`, input_schema }, +}); + +function generate(tools: McpToolInfo[], selected?: string[]) { + const { result } = renderHook(() => useMcpTools()); + return result.current.generateToolsContext(tools, selected); +} + +beforeEach(() => { + vi.spyOn(console, 'error').mockImplementation(() => {}); +}); + +describe('generateToolsContext', () => { + it('sem ferramentas: string vazia', () => { + expect(generate([])).toBe(''); + }); + + it('servidores selecionados sem ferramentas correspondentes: string vazia', () => { + expect(generate([tool('fs', 'read')], ['web'])).toBe(''); + }); + + it('sem seleção: cabeçalho genérico e todas as ferramentas', () => { + const ctx = generate([tool('fs', 'read'), tool('web', 'search')]); + expect(ctx).toContain('Você tem acesso aos servidores MCP listados abaixo.'); + expect(ctx).toContain('### Servidor: fs'); + expect(ctx).toContain('### Servidor: web'); + }); + + it('seleção vazia: comporta-se como sem seleção', () => { + const ctx = generate([tool('fs', 'read')], []); + expect(ctx).toContain('Você tem acesso aos servidores MCP listados abaixo.'); + expect(ctx).toContain('- **read**: desc read'); + }); + + it('com seleção: cita os servidores e omite os demais', () => { + const ctx = generate([tool('fs', 'read'), tool('web', 'search'), tool('db', 'query')], ['web', 'db']); + expect(ctx).toContain('servidores MCP selecionados: web, db.'); + expect(ctx).not.toContain('### Servidor: fs'); + expect(ctx).toContain('- **search**'); + expect(ctx).toContain('- **query**'); + }); + + it('duas ferramentas do mesmo servidor: um único cabeçalho de servidor', () => { + const ctx = generate([tool('fs', 'read'), tool('fs', 'write')]); + expect(ctx.match(/### Servidor: fs/g)).toHaveLength(1); + expect(ctx.indexOf('- **read**')).toBeLessThan(ctx.indexOf('- **write**')); + }); + + it('schema com propriedades: lista parâmetros e usa "any" quando falta o tipo', () => { + const ctx = generate([tool('fs', 'read', { properties: { path: { type: 'string' }, flags: {} } })]); + expect(ctx).toContain(' - Parâmetros: path (string), flags (any)\n'); + }); + + it('schema sem properties: não lista parâmetros', () => { + const ctx = generate([tool('fs', 'read', { type: 'object' })]); + expect(ctx).not.toContain('Parâmetros'); + }); +}); diff --git a/hooks/use-operating-system.test.ts b/hooks/use-operating-system.test.ts new file mode 100644 index 0000000..3fd25fa --- /dev/null +++ b/hooks/use-operating-system.test.ts @@ -0,0 +1,61 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { renderHook, waitFor } from '@testing-library/react'; +import { invoke } from '@tauri-apps/api/core'; +import { useOperatingSystem } from './use-operating-system'; + +vi.mock('@tauri-apps/api/core', () => ({ invoke: vi.fn() })); + +const invokeMock = vi.mocked(invoke); + +function setUserAgent(ua: string) { + vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue(ua); +} + +async function detect() { + const { result } = renderHook(() => useOperatingSystem()); + await waitFor(() => expect(result.current.loading).toBe(false)); + return result.current.os; +} + +const UA = { + windows: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)', + mac: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0)', + linux: 'Mozilla/5.0 (X11; Linux x86_64)', + other: 'Mozilla/5.0 (X11; FreeBSD amd64)', +}; + +describe('useOperatingSystem / detectOS', () => { + beforeEach(() => { + invokeMock.mockReset(); + vi.spyOn(console, 'error').mockImplementation(() => {}); + }); + + it.each(['linux', 'windows', 'mac'])('backend responde "%s": usa a resposta do backend', async (os) => { + invokeMock.mockResolvedValue(os); + setUserAgent(UA.other); + expect(await detect()).toBe(os); + expect(invokeMock).toHaveBeenCalledWith('get_operating_system'); + }); + + it.each([ + ['windows', UA.windows], + ['mac', UA.mac], + ['linux', UA.linux], + ['windows', UA.other], + ])('backend responde valor desconhecido: user agent decide (%s)', async (expected, ua) => { + invokeMock.mockResolvedValue('freebsd'); + setUserAgent(ua); + expect(await detect()).toBe(expected); + }); + + it.each([ + ['windows', UA.windows], + ['mac', UA.mac], + ['linux', UA.linux], + ['windows', UA.other], + ])('invoke falha (sem Tauri): user agent decide (%s)', async (expected, ua) => { + invokeMock.mockRejectedValue(new Error('no tauri')); + setUserAgent(ua); + expect(await detect()).toBe(expected); + }); +}); diff --git a/hooks/use-query-generator.test.ts b/hooks/use-query-generator.test.ts new file mode 100644 index 0000000..2bcc265 --- /dev/null +++ b/hooks/use-query-generator.test.ts @@ -0,0 +1,74 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, renderHook } from '@testing-library/react'; +import { useQueryGenerator } from './use-query-generator'; + +// O Ollama (fetch para localhost:11434) vira fake: nenhum modelo é chamado. +function ollama(reply: { ok?: boolean; response?: unknown } | Error) { + const fetchMock = vi.fn(async () => { + if (reply instanceof Error) throw reply; + return { ok: reply.ok ?? true, json: async () => (reply.response === undefined ? {} : { response: reply.response }) }; + }); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +async function generate(input: string) { + const { result } = renderHook(() => useQueryGenerator()); + let query = ''; + await act(async () => { + query = await result.current.generateQuery(input, 'llama3'); + }); + expect(result.current.isGenerating).toBe(false); + return query; +} + +beforeEach(() => { + vi.spyOn(console, 'error').mockImplementation(() => {}); +}); + +describe('generateQuery', () => { + it('entrada em branco: NO_SEARCH sem chamar o modelo', async () => { + const fetchMock = ollama({ response: 'x' }); + expect(await generate(' ')).toBe('NO_SEARCH'); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('modelo gera query: remove aspas e ponto final', async () => { + ollama({ response: ' "preço do dólar hoje." ' }); + expect(await generate('quanto está o dólar?')).toBe('preço do dólar hoje'); + }); + + it('modelo responde no_search (qualquer caixa): NO_SEARCH', async () => { + ollama({ response: 'no_search' }); + expect(await generate('olá, tudo bem?')).toBe('NO_SEARCH'); + }); + + it('query com menos de 3 caracteres: NO_SEARCH', async () => { + ollama({ response: 'ab' }); + expect(await generate('algo')).toBe('NO_SEARCH'); + }); + + it('resposta sem campo response: NO_SEARCH', async () => { + ollama({}); + expect(await generate('algo')).toBe('NO_SEARCH'); + }); + + it.each(['o que', 'quem', 'quando', 'onde', 'como', 'por que', 'qual', 'quais'])( + 'HTTP de erro e pergunta factual com "%s": usa a própria pergunta', + async (word) => { + ollama({ ok: false }); + const input = `${word.toUpperCase()} xyz`; + expect(await generate(input)).toBe(input); + }, + ); + + it('HTTP de erro e frase não factual: NO_SEARCH', async () => { + ollama({ ok: false }); + expect(await generate('me conte uma piada')).toBe('NO_SEARCH'); + }); + + it('fetch rejeita e pergunta factual: usa a própria pergunta', async () => { + ollama(new TypeError('Failed to fetch')); + expect(await generate('quem ganhou a copa?')).toBe('quem ganhou a copa?'); + }); +}); diff --git a/hooks/use-query-preprocessor.test.ts b/hooks/use-query-preprocessor.test.ts new file mode 100644 index 0000000..fc037f4 --- /dev/null +++ b/hooks/use-query-preprocessor.test.ts @@ -0,0 +1,134 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { act, renderHook } from '@testing-library/react'; +import { useQueryPreprocessor, type PreprocessOptions, type PreprocessedQuery } from './use-query-preprocessor'; +import { useSettingsStore } from '@/store/settings-store'; + +// classify_intent é um comando Tauri (Rust): vira fake. +const invokeMock = vi.hoisted(() => vi.fn()); +vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock })); + +function intent(value: string | Error) { + invokeMock.mockImplementation(async (cmd: string) => { + if (cmd !== 'classify_intent') throw new Error(`comando inesperado: ${cmd}`); + if (value instanceof Error) throw value; + return value; + }); +} + +async function preprocess(text: string, options?: PreprocessOptions) { + const { result } = renderHook(() => useQueryPreprocessor()); + let out: PreprocessedQuery | undefined; + await act(async () => { + out = await result.current.preprocess(text, options); + }); + expect(result.current.isProcessing).toBe(false); + return out!; +} + +const defaults = useSettingsStore.getState(); + +beforeEach(() => { + invokeMock.mockReset(); + localStorage.clear(); + useSettingsStore.setState({ + queryPreprocessing: defaults.queryPreprocessing, + webSearch: { ...defaults.webSearch, enabled: true }, + }); + vi.spyOn(console, 'error').mockImplementation(() => {}); +}); + +describe('preprocess', () => { + it('pergunta factual válida: divide, classifica e decide buscar', async () => { + intent('factual'); + const r = await preprocess('O que é Rust? Quem criou a linguagem?'); + expect(r.validation.isValid).toBe(true); + expect(r.splitResult.splitCount).toBe(2); + expect(r.questions).toHaveLength(2); + expect(r.intent).toBe('factual'); + expect(r.shouldSearch).toBe(true); + expect(invokeMock).toHaveBeenCalledWith('classify_intent', { query: r.normalized }); + }); + + it('texto abaixo do mínimo: inválido, sem perguntas, sem busca e sem classificar', async () => { + intent('factual'); + const r = await preprocess('ab'); + expect(r.validation.isValid).toBe(false); + expect(r).toMatchObject({ questions: [], intent: 'unknown', shouldSearch: false, splitResult: { splitCount: 0 } }); + expect(invokeMock).not.toHaveBeenCalled(); + }); + + it('skipValidation: aceita texto abaixo do mínimo', async () => { + intent('factual'); + const r = await preprocess('ab', { skipValidation: true }); + expect(r.validation).toEqual({ isValid: true, errors: [], warnings: [], normalizedLength: 2 }); + expect(r.shouldSearch).toBe(true); + }); + + it('settings sem queryPreprocessing: usa mínimo 3 padrão', async () => { + useSettingsStore.setState({ queryPreprocessing: undefined as unknown as typeof defaults.queryPreprocessing }); + intent('factual'); + expect((await preprocess('ab')).validation.isValid).toBe(false); + expect((await preprocess('abc')).validation.isValid).toBe(true); + }); + + it('padrões irrelevantes configurados: usa os do usuário', async () => { + useSettingsStore.setState({ queryPreprocessing: { ...defaults.queryPreprocessing, irrelevantPatterns: ['rust'] } }); + intent('factual'); + expect((await preprocess('rust')).validation.warnings).toHaveLength(1); + expect((await preprocess('teste')).validation.warnings).toHaveLength(0); + }); + + it('lista de padrões vazia: cai nos padrões padrão da validação', async () => { + useSettingsStore.setState({ queryPreprocessing: { ...defaults.queryPreprocessing, irrelevantPatterns: [] } }); + intent('factual'); + expect((await preprocess('teste')).validation.warnings).toHaveLength(1); + }); + + it('skipSplit: mantém o texto original como única pergunta', async () => { + intent('factual'); + const text = 'O que é Rust? Quem criou a linguagem?'; + const r = await preprocess(text, { skipSplit: true }); + expect(r.questions).toEqual([text]); + expect(r.splitResult.splitCount).toBe(1); + }); + + it('skipIntentClassification: intent unknown sem chamar o backend e ainda busca', async () => { + intent('conversational'); + const r = await preprocess('preço do dólar', { skipIntentClassification: true }); + expect(r.intent).toBe('unknown'); + expect(r.shouldSearch).toBe(true); + expect(invokeMock).not.toHaveBeenCalled(); + }); + + it('classificador falha: intent unknown e segue buscando', async () => { + intent(new Error('modelo de intent ausente')); + const r = await preprocess('preço do dólar'); + expect(r.intent).toBe('unknown'); + expect(r.shouldSearch).toBe(true); + }); + + it.each([ + ['technical', true], + ['conversational', false], + ['opinion', false], + ['calculation', false], + ])('intent %s: shouldSearch %s', async (value, expected) => { + intent(value); + expect((await preprocess('pergunta qualquer aqui')).shouldSearch).toBe(expected); + }); + + it('busca web desligada: não busca mesmo com intent factual', async () => { + useSettingsStore.setState({ webSearch: { ...defaults.webSearch, enabled: false } }); + intent('factual'); + expect((await preprocess('preço do dólar')).shouldSearch).toBe(false); + }); + + it('settings corrompido sem irrelevantPatterns: devolve resultado de erro sem lançar', async () => { + const { irrelevantPatterns: _omit, ...rest } = defaults.queryPreprocessing; + useSettingsStore.setState({ queryPreprocessing: rest as typeof defaults.queryPreprocessing }); + intent('factual'); + const r = await preprocess('preço do dólar'); + expect(r.validation).toEqual({ isValid: false, errors: ['Erro ao pré-processar query'], warnings: [], normalizedLength: 0 }); + expect(r.shouldSearch).toBe(false); + }); +}); diff --git a/lib/content-condenser.test.ts b/lib/content-condenser.test.ts new file mode 100644 index 0000000..35a6da7 --- /dev/null +++ b/lib/content-condenser.test.ts @@ -0,0 +1,109 @@ +import { describe, expect, it } from 'vitest'; +import { chunkBySections, summarizeMarkdown } from './content-condenser'; + +const words = (n: number, w = 'palavra') => Array.from({ length: n }, () => w).join(' '); + +describe('summarizeMarkdown', () => { + it('com headings e sem espaço para tudo: inclui a 1ª seção e trunca a 2ª com "..."', () => { + const md = `# Um\n${words(30, 'alfa')}\n# Dois\n${words(100, 'beta')}`; + const out = summarizeMarkdown(md, 400); + expect(out.startsWith(`## Um\n\n${words(30, 'alfa')}\n\n## Dois\n\nbeta`)).toBe(true); + expect(out.endsWith('...')).toBe(true); + expect(out.length).toBeLessThan(md.length); + }); + + it('conteúdo vazio: devolve o próprio conteúdo', () => { + expect(summarizeMarkdown('', 10)).toBe(''); + }); + + it('conteúdo dentro do limite: devolve sem alterar', () => { + const md = '# T\ncurto'; + expect(summarizeMarkdown(md, 100)).toBe(md); + }); + + it('heading único: a seção vai até o fim do texto', () => { + const md = `# Só\n${'x'.repeat(10)}\n${'y'.repeat(150)}\nfim${' '.repeat(300)}`; + expect(summarizeMarkdown(md, 300)).toBe(`## Só\n\n${'x'.repeat(10)}\n${'y'.repeat(150)}\nfim`); + }); + + it('seções de nível 1 vêm antes das de nível 2, mesmo aparecendo depois', () => { + const md = `## Sub\nb\n# Top\na\n${' '.repeat(200)}`; + expect(summarizeMarkdown(md, 100)).toBe('## Top\n\na\n\n## Sub\n\nb'); + }); + + it('todas as seções cabem depois do trim: sem "..."', () => { + const md = `# A\nconteudo a${' '.repeat(300)}\n# B\nconteudo b`; + expect(summarizeMarkdown(md, 200)).toBe('## A\n\nconteudo a\n\n## B\n\nconteudo b'); + }); + + it('seção não cabe e sobram até 100 caracteres: para sem cortar a seção', () => { + const md = `# A\n${'a'.repeat(50)}\n# B\n${'b'.repeat(300)}`; + expect(summarizeMarkdown(md, 200)).toBe(`## A\n\n${'a'.repeat(50)}`); + }); + + it('1ª seção já não cabe e o limite é pequeno: cai no recorte bruto do conteúdo', () => { + const md = `# A\n${'a'.repeat(300)}`; + expect(summarizeMarkdown(md, 120)).toBe(md.substring(0, 120)); + }); + + it('sem headings: junta parágrafos e corta o que não cabe com "..."', () => { + const md = `${words(10, 'p1')}\n\n${words(100, 'p2')}`; + const out = summarizeMarkdown(md, 300); + expect(out.startsWith(`${words(10, 'p1')}\n\np2`)).toBe(true); + expect(out.endsWith('...')).toBe(true); + }); + + it('sem headings e todos os parágrafos cabem: devolve os parágrafos sem "..."', () => { + const md = `um\n\n${' '.repeat(10)}\n\n\n\n${' \n'.repeat(80)}dois`; + expect(summarizeMarkdown(md, 50)).toBe('um\n\ndois'); + }); + + it('sem headings e sobram até 100 caracteres: para sem cortar o parágrafo', () => { + const md = `${'a'.repeat(100)}\n\n${'b'.repeat(300)}`; + expect(summarizeMarkdown(md, 200)).toBe('a'.repeat(100)); + }); + + it('sem headings, 1º parágrafo maior que o limite pequeno: recorte bruto', () => { + const md = 'c'.repeat(300); + expect(summarizeMarkdown(md, 90)).toBe('c'.repeat(90)); + }); +}); + +describe('chunkBySections', () => { + it('um chunk por heading, com índices de linha', () => { + const chunks = chunkBySections('# A\nlinha a\n# B\nlinha b'); + expect(chunks.map((c) => [c.content, c.startIndex, c.endIndex])).toEqual([ + ['# A\nlinha a', 0, 1], + ['# B\nlinha b', 2, 3], + ]); + }); + + it('texto vazio: nenhum chunk', () => { + expect(chunkBySections('')).toEqual([]); + }); + + it('texto antes do 1º heading vira um chunk próprio', () => { + const chunks = chunkBySections('intro\n# A\na'); + expect(chunks.map((c) => c.content)).toEqual(['intro', '# A\na']); + }); + + it('só linhas em branco antes do 1º heading: não gera chunk vazio', () => { + const chunks = chunkBySections('\n\n# A\na'); + expect(chunks.map((c) => c.content)).toEqual(['# A\na']); + }); + + it('seção maior que o limite: divide e repete o heading no chunk seguinte', () => { + const chunks = chunkBySections(`# A\n${'x'.repeat(20)}\n${'y'.repeat(20)}`, 30); + expect(chunks.map((c) => c.content)).toEqual([`# A\n${'x'.repeat(20)}`, `# A\n${'y'.repeat(20)}`]); + expect(chunks[1].startIndex).toBe(2); + }); + + it('sem heading e 1ª linha já estoura o limite: não emite chunk vazio antes dela', () => { + const chunks = chunkBySections('z'.repeat(50), 10); + expect(chunks.map((c) => c.content)).toEqual(['z'.repeat(50)]); + }); + + it('só espaços em branco: passa pelo fallback de parágrafos e não gera chunk', () => { + expect(chunkBySections(' \n ')).toEqual([]); + }); +}); diff --git a/lib/contextual-analyzer.test.ts b/lib/contextual-analyzer.test.ts new file mode 100644 index 0000000..449474c --- /dev/null +++ b/lib/contextual-analyzer.test.ts @@ -0,0 +1,164 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { analyzeQueryContext } from './contextual-analyzer'; + +// Logs do chatLog vão para o Tauri; aqui viram no-op. +vi.mock('@tauri-apps/api/core', () => ({ invoke: vi.fn(async () => undefined) })); + +// Fake do /api/generate do Ollama (stream: false). +function stubGenerate(response: unknown, ok = true) { + const fetchMock = vi.fn(async () => ({ ok, status: ok ? 200 : 500, statusText: 'x', json: async () => ({ response }) }) as Response); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +const FULL = { + intent: 'comparison', + entities: [{ type: 'product', value: 'Rust', confidence: 0.9 }], + topics: ['linguagens'], + relationships: [{ from: 'Rust', to: 'Go', relation: 'vs', confidence: 0.8 }], + implicitQuestions: ['qual é mais rápida?'], + temporalContext: { period: '2024' }, + geographicContext: { location: 'Brasil' }, + keywords: ['rust', 'go'], + synonyms: ['linguagem'], + domain: 'tecnologia', + complexity: 'complex', +}; + +describe('analyzeQueryContext', () => { + beforeEach(() => vi.spyOn(console, 'error').mockImplementation(() => {})); + + it('LLM devolve JSON completo: usa todos os campos', async () => { + const fetchMock = stubGenerate(JSON.stringify(FULL)); + const ctx = await analyzeQueryContext('rust vs go', 'qwen'); + expect(ctx).toEqual({ originalQuery: 'rust vs go', ...FULL }); + const body = JSON.parse((fetchMock.mock.calls[0] as unknown as [string, RequestInit])[1].body as string); + expect(body).toMatchObject({ model: 'qwen', stream: false }); + expect(body.prompt).toContain('"rust vs go"'); + }); + + it('query vazia: contexto vazio sem chamar o modelo', async () => { + const fetchMock = stubGenerate('{}'); + const ctx = await analyzeQueryContext('', 'm'); + expect(ctx.intent).toBe('unknown'); + expect(ctx.complexity).toBe('simple'); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('query só com espaços: contexto vazio sem chamar o modelo', async () => { + const fetchMock = stubGenerate('{}'); + expect((await analyzeQueryContext(' ', 'm')).keywords).toEqual([]); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('HTTP não ok: cai no fallback heurístico', async () => { + stubGenerate(JSON.stringify(FULL), false); + const ctx = await analyzeQueryContext('como instalar rust', 'm'); + expect(ctx.intent).toBe('how-to'); + expect(ctx.entities).toEqual([]); + }); + + it('resposta sem campo response: JSON vazio falha e cai no fallback', async () => { + stubGenerate(undefined); + expect((await analyzeQueryContext('lista de livros', 'm')).intent).toBe('list'); + }); + + it('JSON dentro de bloco ```json com texto em volta: extrai o objeto', async () => { + stubGenerate('Claro!\n```json\n{"intent":"definition"}\n```'); + expect((await analyzeQueryContext('x', 'm')).intent).toBe('definition'); + }); + + it('JSON sem objeto (array): aceita e preenche os padrões', async () => { + stubGenerate('[]'); + expect(await analyzeQueryContext('x', 'm')).toEqual({ + originalQuery: 'x', + intent: 'unknown', + entities: [], + topics: [], + relationships: [], + implicitQuestions: [], + temporalContext: undefined, + geographicContext: undefined, + keywords: [], + synonyms: [], + domain: undefined, + complexity: 'moderate', + }); + }); + + it.each([ + ['intent', 'unknown'], + ['entities', []], + ['topics', []], + ['relationships', []], + ['implicitQuestions', []], + ['keywords', []], + ['synonyms', []], + ['complexity', 'moderate'], + ])('campo %s ausente: usa o padrão e mantém os demais', async (field, fallback) => { + const partial: Record = { ...FULL }; + delete partial[field]; + stubGenerate(JSON.stringify(partial)); + const ctx = await analyzeQueryContext('q', 'm'); + expect(ctx).toEqual({ originalQuery: 'q', ...FULL, [field]: fallback }); + }); + + it('JSON inválido: cai no fallback heurístico', async () => { + stubGenerate('{intent: oops'); + expect((await analyzeQueryContext('por que o céu é azul', 'm')).intent).toBe('causal'); + }); +}); + +describe('createFallbackContext (via Ollama fora do ar)', () => { + beforeEach(() => { + vi.spyOn(console, 'error').mockImplementation(() => {}); + vi.stubGlobal('fetch', vi.fn(async () => { throw new TypeError('connection refused'); })); + }); + + it('query factual sem marcadores: intent factual, sem contexto temporal', async () => { + const ctx = await analyzeQueryContext('preço do petróleo hoje', 'm'); + expect(ctx).toMatchObject({ intent: 'factual', keywords: ['preço', 'petróleo', 'hoje'], topics: ['preço', 'petróleo', 'hoje'], complexity: 'moderate' }); + expect(ctx.temporalContext).toBeUndefined(); + }); + + it.each([ + ['como', 'como fazer pão', 'how-to'], + ['tutorial', 'tutorial de git', 'how-to'], + ['o que é', 'o que é kubernetes', 'definition'], + ['definição', 'definição de entropia', 'definition'], + ['quais', 'quais linguagens usar', 'list'], + ['lista', 'lista de capitais', 'list'], + ['comparar', 'comparar planos', 'comparison'], + ['vs', 'react vs vue', 'comparison'], + ['por que', 'por que chove', 'causal'], + ['causa', 'causa da inflação', 'causal'], + ])('marcador "%s": intent correspondente', async (_m, query, intent) => { + expect((await analyzeQueryContext(query, 'm')).intent).toBe(intent); + }); + + it.each([ + ['último', 'último lançamento da apple'], + ['recente', 'notícia recente'], + ['atual', 'cotação atual do dólar'], + ])('termo relativo "%s": temporal recente', async (_t, query) => { + expect((await analyzeQueryContext(query, 'm')).temporalContext).toEqual({ relative: 'recente' }); + }); + + it.each([['2024'], ['2023']])('ano %s isolado: vira período', async (year) => { + expect((await analyzeQueryContext(`copa ${year}`, 'm')).temporalContext).toEqual({ period: year }); + }); + + it('ano grudado em outra palavra: sem período', async () => { + expect((await analyzeQueryContext('versao2024 notas', 'm')).temporalContext).toBeUndefined(); + }); + + it('mais de 5 keywords: complex', async () => { + expect((await analyzeQueryContext('alfa beta gama delta epsilon zeta', 'm')).complexity).toBe('complex'); + }); + + it('até 2 keywords: simple, stopwords e palavras curtas fora', async () => { + const ctx = await analyzeQueryContext('o mar de lua', 'm'); + expect(ctx.keywords).toEqual(['mar', 'lua']); + expect(ctx.complexity).toBe('simple'); + }); +}); diff --git a/lib/model-context.test.ts b/lib/model-context.test.ts new file mode 100644 index 0000000..31f1fa2 --- /dev/null +++ b/lib/model-context.test.ts @@ -0,0 +1,68 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { detectModelContextWindow } from './model-context'; +import { useSettingsStore } from '@/store/settings-store'; + +// Fake do /api/show do Ollama: nenhuma chamada sai do processo. +function stubShow(body: unknown, ok = true) { + const fetchMock = vi.fn(async () => ({ ok, json: async () => body }) as Response); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +describe('detectModelContextWindow', () => { + beforeEach(() => { + useSettingsStore.setState({ contextWindow: 2048 }); + vi.spyOn(console, 'warn').mockImplementation(() => {}); + }); + + it('modelfile com context_length: usa o valor declarado', async () => { + const fetchMock = stubShow({ modelfile: 'PARAMETER context_length: 32000' }); + expect(await detectModelContextWindow('llama3')).toBe(32000); + expect(fetchMock).toHaveBeenCalledWith('http://localhost:11434/api/show', expect.objectContaining({ method: 'POST' })); + }); + + it('nome vazio: usa contextWindow das settings sem chamar a API', async () => { + const fetchMock = stubShow({}); + expect(await detectModelContextWindow('')).toBe(2048); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('nome vazio e contextWindow 0: cai em 4096', async () => { + useSettingsStore.setState({ contextWindow: 0 }); + stubShow({}); + expect(await detectModelContextWindow('')).toBe(4096); + }); + + it('resposta HTTP não ok: usa as settings', async () => { + stubShow({ modelfile: 'context_length 9999' }, false); + expect(await detectModelContextWindow('m')).toBe(2048); + }); + + it.each([ + ['7b', 8192], + ['8b', 8192], + ['13b', 16384], + ['14b', 16384], + ['32k', 32768], + ['128k', 32768], + ])('sem context_length e size "%s": infere %i', async (size, expected) => { + stubShow({ modelfile: 'FROM x', size }); + expect(await detectModelContextWindow('m')).toBe(expected); + }); + + it('sem modelfile nem size: usa as settings', async () => { + stubShow({}); + expect(await detectModelContextWindow('m')).toBe(2048); + }); + + it('fetch rejeita (Ollama fora do ar): usa as settings', async () => { + vi.stubGlobal('fetch', vi.fn(async () => { throw new TypeError('connection refused'); })); + expect(await detectModelContextWindow('m')).toBe(2048); + }); + + it('fallback final com contextWindow 0: cai em 4096', async () => { + useSettingsStore.setState({ contextWindow: 0 }); + stubShow({ size: '3b' }); + expect(await detectModelContextWindow('m')).toBe(4096); + }); +}); diff --git a/lib/query-enricher.test.ts b/lib/query-enricher.test.ts new file mode 100644 index 0000000..bd412da --- /dev/null +++ b/lib/query-enricher.test.ts @@ -0,0 +1,124 @@ +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { enrichQueries } from './query-enricher'; +import type { QueryContext } from './contextual-analyzer'; + +vi.mock('@tauri-apps/api/core', () => ({ invoke: vi.fn(async () => undefined) })); + +function stubGenerate(response: unknown, ok = true) { + const fetchMock = vi.fn(async () => ({ ok, status: ok ? 200 : 503, statusText: 'x', json: async () => ({ response }) }) as Response); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +function sentPrompt(fetchMock: Mock): string { + return JSON.parse((fetchMock.mock.calls[0] as unknown as [string, RequestInit])[1].body as string).prompt; +} + +const CTX: QueryContext = { + originalQuery: 'praias em Garuva', + intent: 'list', + entities: [{ type: 'location', value: 'Garuva', confidence: 1 }], + topics: ['praias'], + relationships: [], + implicitQuestions: [], + temporalContext: { period: '2024' }, + geographicContext: { location: 'SC' }, + keywords: ['praias'], + synonyms: ['litoral'], + domain: 'turismo', + complexity: 'simple', +}; + +const LLM = { + literal: ['praias garuva'], + semantic: ['litoral garuva'], + related: ['melhor praia garuva'], + expanded: ['praia itapoá garuva'], + contextual: ['praias garuva 2024'], +}; + +describe('enrichQueries', () => { + beforeEach(() => vi.spyOn(console, 'error').mockImplementation(() => {})); + + it('LLM devolve as 5 categorias: repassa e monta o prompt com o contexto', async () => { + const fetchMock = stubGenerate(JSON.stringify(LLM)); + expect(await enrichQueries('praias em Garuva', CTX, 'qwen')).toEqual(LLM); + const prompt = sentPrompt(fetchMock); + expect(prompt).toContain('"praias em Garuva"'); + expect(prompt).toContain('- Entidades: location: Garuva'); + expect(prompt).toContain('- Contexto Temporal: {"period":"2024"}'); + expect(prompt).toContain('- Contexto Geográfico: {"location":"SC"}'); + expect(prompt).toContain('- Domínio: turismo'); + }); + + it.each([ + ['entities', [], '- Entidades: nenhuma'], + ['temporalContext', undefined, '- Contexto Temporal: nenhum'], + ['geographicContext', undefined, '- Contexto Geográfico: nenhum'], + ['topics', [], '- Tópicos: nenhum'], + ['keywords', [], '- Palavras-chave: nenhuma'], + ['synonyms', [], '- Sinônimos: nenhum'], + ['domain', undefined, '- Domínio: geral'], + ])('contexto sem %s: prompt usa o marcador vazio', async (field, value, line) => { + const fetchMock = stubGenerate(JSON.stringify(LLM)); + await enrichQueries('q', { ...CTX, [field]: value }, 'm'); + expect(sentPrompt(fetchMock)).toContain(line); + }); + + it('HTTP não ok: fallback com sinônimo, período e local', async () => { + stubGenerate(JSON.stringify(LLM), false); + expect(await enrichQueries('praias em Garuva', CTX, 'm')).toEqual({ + literal: ['praias em Garuva'], + semantic: ['litoral em Garuva'], + related: [], + expanded: [], + contextual: ['praias em Garuva 2024', 'praias em Garuva SC'], + }); + }); + + it('sem campo response: JSON vazio falha e cai no fallback', async () => { + stubGenerate(undefined); + expect((await enrichQueries('q', { ...CTX, synonyms: [], temporalContext: undefined, geographicContext: undefined }, 'm'))).toEqual({ + literal: ['q'], semantic: [], related: [], expanded: [], contextual: [], + }); + }); + + it('fallback com contexto relativo "recente": acrescenta "recente"', async () => { + stubGenerate('não é json'); + const r = await enrichQueries('q', { ...CTX, synonyms: [], temporalContext: { relative: 'recente' }, geographicContext: undefined }, 'm'); + expect(r.contextual).toEqual(['q recente']); + }); + + it('JSON em bloco ```json com texto em volta: extrai o objeto', async () => { + stubGenerate(`Aqui:\n\`\`\`json\n${JSON.stringify(LLM)}\n\`\`\``); + expect(await enrichQueries('q', CTX, 'm')).toEqual(LLM); + }); + + it('JSON sem objeto (array): todas as categorias vazias e literal com a original', async () => { + stubGenerate('[]'); + expect(await enrichQueries('q', CTX, 'm')).toEqual({ literal: ['q'], semantic: [], related: [], expanded: [], contextual: [] }); + }); + + it.each([ + ['literal', ['q']], + ['semantic', []], + ['related', []], + ['expanded', []], + ['contextual', []], + ])('categoria %s ausente: usa o padrão e mantém as outras', async (field, fallback) => { + const partial: Record = { ...LLM }; + delete partial[field]; + stubGenerate(JSON.stringify(partial)); + expect(await enrichQueries('q', CTX, 'm')).toEqual({ ...LLM, [field]: fallback }); + }); + + it('literal vazio: garante a query original', async () => { + stubGenerate(JSON.stringify({ ...LLM, literal: [] })); + expect((await enrichQueries('q', CTX, 'm')).literal).toEqual(['q']); + }); + + it('fetch rejeita (Ollama fora do ar): fallback', async () => { + vi.stubGlobal('fetch', vi.fn(async () => { throw new TypeError('refused'); })); + expect((await enrichQueries('q', CTX, 'm')).literal).toEqual(['q']); + }); +}); diff --git a/lib/query-validation.test.ts b/lib/query-validation.test.ts new file mode 100644 index 0000000..2cb4316 --- /dev/null +++ b/lib/query-validation.test.ts @@ -0,0 +1,61 @@ +import { describe, expect, it } from 'vitest'; +import { validateQuery } from './query-validation'; + +const IRRELEVANT = 'Pergunta pode ser irrelevante ou muito simples. Considere ser mais específico.'; + +describe('validateQuery', () => { + it('pergunta normal: válida, sem erros nem avisos', () => { + expect(validateQuery('Qual é a capital da França?')).toEqual({ + isValid: true, + errors: [], + warnings: [], + normalizedLength: 'qual e a capital da franca?'.length, + }); + }); + + it('string vazia: inválida logo na entrada', () => { + expect(validateQuery('')).toEqual({ isValid: false, errors: ['Texto vazio ou inválido'], warnings: [], normalizedLength: 0 }); + }); + + it('valor que não é string: inválido logo na entrada', () => { + expect(validateQuery(42 as unknown as string).errors).toEqual(['Texto vazio ou inválido']); + }); + + it('abaixo do mínimo: erro de texto curto', () => { + const r = validateQuery('ab'); + expect(r.isValid).toBe(false); + expect(r.errors).toEqual(['Texto muito curto. Mínimo de 3 caracteres necessário.']); + }); + + it('acima do máximo configurado: erro de texto longo', () => { + const r = validateQuery('uma pergunta comprida', { maxLength: 10 }); + expect(r.errors).toEqual(['Texto muito longo. Máximo de 10 caracteres permitido.']); + }); + + it('só espaços: erro de espaços, sem erro de emoji nem de pontuação', () => { + const r = validateQuery(' '); + expect(r.errors).toEqual([ + 'Texto muito curto. Mínimo de 3 caracteres necessário.', + 'Texto contém apenas espaços em branco ou caracteres especiais.', + ]); + }); + + it('só emojis: erro de emojis', () => { + expect(validateQuery('🚀🔥🎉').errors).toContain('Texto contém apenas emojis.'); + }); + + it('só emojis com allowEmojis: não acusa emojis', () => { + expect(validateQuery('🚀🔥🎉', { allowEmojis: true }).errors).not.toContain('Texto contém apenas emojis.'); + }); + + it('só pontuação: erro de pontuação', () => { + const r = validateQuery('???'); + expect(r.errors).toEqual(['Texto contém apenas pontuação.']); + }); + + it('padrão irrelevante com pontuação: válido, mas com aviso', () => { + const r = validateQuery('Teste!!'); + expect(r.isValid).toBe(true); + expect(r.warnings).toEqual([IRRELEVANT]); + }); +}); diff --git a/lib/relevance-scorer.test.ts b/lib/relevance-scorer.test.ts new file mode 100644 index 0000000..4664aef --- /dev/null +++ b/lib/relevance-scorer.test.ts @@ -0,0 +1,127 @@ +import { describe, expect, it } from 'vitest'; +import { calculateSemanticSimilarity } from './relevance-scorer'; +import type { QueryContext } from './contextual-analyzer'; + +function ctx(over: Partial = {}): QueryContext { + return { + originalQuery: 'q', + intent: 'factual', + entities: [], + topics: [], + relationships: [], + implicitQuestions: [], + keywords: [], + synonyms: [], + complexity: 'simple', + ...over, + }; +} + +describe('calculateSemanticSimilarity', () => { + it('todos os sinais batem: soma ponderada com sinônimos limitados a 0.5', () => { + const score = calculateSemanticSimilarity( + ctx({ + keywords: ['energia'], + entities: [{ type: 'organization', value: 'Petrobras', confidence: 1 }], + topics: ['energia solar'], + synonyms: ['fotovoltaica'], + temporalContext: { period: '2024', relative: 'recente' }, + geographicContext: { location: 'Bahia' }, + }), + 'Petrobras investe em energia solar fotovoltaica recente na Bahia em 2024', + ); + // 0.3 + 0.3 + 0.2 + 0.5*0.1 + min(1.3,1)*0.1 = 0.95, peso total 1.0 + expect(score).toBeCloseTo(0.95); + }); + + it('chunk vazio: 0', () => { + expect(calculateSemanticSimilarity(ctx({ keywords: ['x'] }), '')).toBe(0); + }); + + it('contexto ausente: 0', () => { + expect(calculateSemanticSimilarity(null as unknown as QueryContext, 'texto')).toBe(0); + }); + + it('contexto sem nenhum sinal: só o peso contextual, score 0', () => { + expect(calculateSemanticSimilarity(ctx(), 'qualquer texto')).toBe(0); + }); + + it('metade das keywords no chunk: 0.15 de 0.4', () => { + expect(calculateSemanticSimilarity(ctx({ keywords: ['solar', 'eolica'] }), 'energia solar')).toBeCloseTo(0.375); + }); + + it('entidade encontrada pesa pela confiança', () => { + const c = ctx({ entities: [{ type: 'location', value: 'Recife', confidence: 0.5 }] }); + expect(calculateSemanticSimilarity(c, 'chuva em Recife')).toBeCloseTo(0.375); + }); + + it('entidade ausente do chunk: 0', () => { + const c = ctx({ entities: [{ type: 'location', value: 'Recife', confidence: 1 }] }); + expect(calculateSemanticSimilarity(c, 'chuva em Natal')).toBe(0); + }); + + it('tópico com menos de 50% das palavras no chunk não conta', () => { + expect(calculateSemanticSimilarity(ctx({ topics: ['energia solar barata'] }), 'energia nuclear')).toBe(0); + }); + + it('tópico com pelo menos 50% das palavras (>3 letras) conta', () => { + expect(calculateSemanticSimilarity(ctx({ topics: ['energia solar barata'] }), 'energia solar cara')).toBeCloseTo(0.2 / 0.3); + }); + + it('sinônimos: 1 de 4 encontrado vale 0.25', () => { + const c = ctx({ synonyms: ['carro', 'auto', 'veiculo', 'automovel'] }); + expect(calculateSemanticSimilarity(c, 'um carro')).toBeCloseTo(0.025 / 0.2); + }); + + it('sinônimo ausente: 0', () => { + expect(calculateSemanticSimilarity(ctx({ synonyms: ['moto'] }), 'um carro')).toBe(0); + }); + + it('período temporal no chunk soma 0.5 no contextual', () => { + expect(calculateSemanticSimilarity(ctx({ temporalContext: { period: '2023' } }), 'dados de 2023')).toBeCloseTo(0.5); + }); + + it('período temporal fora do chunk: 0', () => { + expect(calculateSemanticSimilarity(ctx({ temporalContext: { period: '2023' } }), 'dados de 2020')).toBe(0); + }); + + it('contexto relativo com termo recente no chunk soma 0.3', () => { + expect(calculateSemanticSimilarity(ctx({ temporalContext: { relative: 'recente' } }), 'versão atual')).toBeCloseTo(0.3); + }); + + it('contexto relativo sem termo recente no chunk: 0', () => { + expect(calculateSemanticSimilarity(ctx({ temporalContext: { relative: 'recente' } }), 'versão antiga')).toBe(0); + }); + + it('local geográfico no chunk soma 0.5', () => { + expect(calculateSemanticSimilarity(ctx({ geographicContext: { location: 'Manaus' } }), 'calor em manaus')).toBeCloseTo(0.5); + }); + + it('local geográfico fora do chunk: 0', () => { + expect(calculateSemanticSimilarity(ctx({ geographicContext: { location: 'Manaus' } }), 'frio em Curitiba')).toBe(0); + }); + + it('keyword acentuada casa com o mesmo termo acentuado no chunk', () => { + expect(calculateSemanticSimilarity(ctx({ keywords: ['França'] }), 'Viagem à França')).toBeCloseTo(0.75); + }); + + it('local acentuado casa com o mesmo local no chunk', () => { + const c = ctx({ geographicContext: { location: 'São Paulo' } }); + expect(calculateSemanticSimilarity(c, 'trânsito em São Paulo')).toBeCloseTo(0.5); + }); + + it('"último" no chunk conta como termo relativo', () => { + expect(calculateSemanticSimilarity(ctx({ temporalContext: { relative: 'recente' } }), 'o último relatório')).toBeCloseTo(0.3); + }); + + it('entidade, tópico, sinônimo e período acentuados casam com o chunk acentuado', () => { + const c = ctx({ + entities: [{ type: 'location', value: 'Ceará', confidence: 1 }], + topics: ['eleição municipal'], + synonyms: ['votação'], + temporalContext: { period: 'últimos 5 anos' }, + }); + // (0.3 + 0.2 + 0.5*0.1 + 0.5*0.1) / 0.7 + expect(calculateSemanticSimilarity(c, 'Ceará: eleição municipal e votação nos últimos 5 anos')).toBeCloseTo(0.6 / 0.7); + }); +}); diff --git a/lib/web-search-fallback.test.ts b/lib/web-search-fallback.test.ts new file mode 100644 index 0000000..87e1995 --- /dev/null +++ b/lib/web-search-fallback.test.ts @@ -0,0 +1,184 @@ +import Module from 'node:module'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { invoke } from '@tauri-apps/api/core'; +import { executeProgressiveSearch } from './web-search-fallback'; +import * as relevanceScorer from './relevance-scorer'; +import type { ScrapedContent } from '@/services/webSearch'; +import type { QueryContext } from './contextual-analyzer'; + +vi.mock('@tauri-apps/api/core', () => ({ invoke: vi.fn(async () => undefined) })); + +const QUERY = 'energia solar residencial'; + +function page(id: string | number, relevant = true): ScrapedContent { + return relevant + ? { title: `Energia solar residencial ${id}`, url: `https://ex.com/${id}`, content: '', markdown: `energia solar residencial ${'x'.repeat(120)}` } + : { title: `nada ${id}`, url: `https://ex.com/${id}`, content: '', markdown: '' }; +} + +const pages = (n: number, relevant = true, prefix = 'p') => Array.from({ length: n }, (_, i) => page(`${prefix}${i}`, relevant)); + +// Fake do Ollama para expandQuery (rodadas > 1 no modo tradicional). +function stubExpansion(response: string) { + const fetchMock = vi.fn(async () => ({ ok: true, json: async () => ({ response }) }) as Response); + vi.stubGlobal('fetch', fetchMock); + return fetchMock; +} + +function logged(text: string) { + return vi.mocked(invoke).mock.calls.some( + ([cmd, args]) => cmd === 'log_to_terminal' && !!args && 'message' in args && String(args.message).includes(text), + ); +} + +describe('executeProgressiveSearch', () => { + beforeEach(() => { + vi.mocked(invoke).mockClear(); + stubExpansion(''); + }); + + it('1ª rodada com 5 resultados relevantes: early exit com sucesso', async () => { + const searchFn = vi.fn(async () => pages(5)); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm'); + expect(r).toMatchObject({ success: true, usedFallback: false, totalResultsAnalyzed: 5, finalQuery: QUERY }); + expect(r.attempts).toHaveLength(1); + expect(r.attempts[0]).toMatchObject({ round: 1, strategy: 'literal', query: QUERY, queries: undefined, relevanceScore: 1 }); + expect(searchFn).toHaveBeenCalledWith(QUERY, 10, 1); + }); + + it('modo semântico: rodadas por estratégia, sem expansão, várias queries por rodada', async () => { + const fetchMock = stubExpansion('nao deveria'); + const searchFn = vi.fn(async (q: string) => [page(q)]); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { + useSemanticSearch: true, + enrichedQueries: { literal: ['a'], semantic: ['b'], related: ['c'], expanded: [], contextual: [] }, + }); + expect(r.attempts.map((a) => [a.strategy, a.queries ?? a.query])).toEqual([ + ['literal', ['a', 'b']], + ['related', 'c'], + ]); + expect(fetchMock).not.toHaveBeenCalled(); + expect(r.success).toBe(false); + }); + + it('semântico ligado sem enrichedQueries: cai no modo tradicional', async () => { + const searchFn = vi.fn(async () => []); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { useSemanticSearch: true, maxRounds: 2 }); + expect(r.attempts.map((a) => a.strategy)).toEqual(['literal', 'literal']); + }); + + it('nenhum resultado em todas as rodadas: fallback com maxRounds tentativas', async () => { + const r = await executeProgressiveSearch(QUERY, vi.fn(async () => []), 'm', { maxRounds: 3, enableQueryExpansion: false }); + expect(r).toMatchObject({ success: false, usedFallback: true, totalResultsAnalyzed: 0, scrapedSources: [] }); + expect(r.attempts).toHaveLength(3); + expect(r.attempts[0].relevanceScore).toBe(0); + }); + + it('tempo total da query esgotado antes da 1ª rodada: nenhuma busca', async () => { + let t = 0; + vi.spyOn(Date, 'now').mockImplementation(() => (t += 30_000)); + const searchFn = vi.fn(async () => pages(5)); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm'); + expect(searchFn).not.toHaveBeenCalled(); + expect(r).toMatchObject({ success: false, attempts: [] }); + }); + + it('maxTimeoutPerQuery 0: usa o padrão de 25s em vez de parar na hora', async () => { + let t = 0; + vi.spyOn(Date, 'now').mockImplementation(() => (t += 1_000)); + const searchFn = vi.fn(async () => pages(5)); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { maxTimeoutPerQuery: 0 }); + expect(r.success).toBe(true); + }); + + it('2ª rodada tradicional: expande a query pelo Ollama', async () => { + const fetchMock = stubExpansion('"painel solar para casa."'); + const searchFn = vi.fn(async (_q: string) => [] as ScrapedContent[]); + await executeProgressiveSearch(QUERY, searchFn, 'm', { maxRounds: 2 }); + expect(searchFn.mock.calls.map((c) => c[0])).toEqual([QUERY, 'painel solar para casa']); + expect(fetchMock).toHaveBeenCalledTimes(1); + }); + + it('expansão desligada: 2ª rodada repete a query original', async () => { + const fetchMock = stubExpansion('outra coisa'); + const searchFn = vi.fn(async (_q: string) => [] as ScrapedContent[]); + await executeProgressiveSearch(QUERY, searchFn, 'm', { maxRounds: 2, enableQueryExpansion: false }); + expect(searchFn.mock.calls.map((c) => c[0])).toEqual([QUERY, QUERY]); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it('searchFn lança: rodada vazia e segue para a próxima', async () => { + const searchFn = vi.fn() + .mockRejectedValueOnce(new Error('motor caiu')) + .mockResolvedValueOnce(pages(5)); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { enableQueryExpansion: false }); + expect(r.success).toBe(true); + expect(r.attempts.map((a) => a.results.length)).toEqual([0, 5]); + }); + + it('timeout da rodada: usa o que já chegou sem esperar a query travada', async () => { + const searchFn = vi.fn(async (q: string) => (q === 'trava' ? new Promise(() => {}) : [page('ok')])); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { + useSemanticSearch: true, + enrichedQueries: { literal: ['rapida', 'trava'], semantic: [], related: [], expanded: [], contextual: [] }, + maxTimeoutPerRound: 50, + }); + expect(r.attempts).toHaveLength(1); + expect(r.attempts[0].results.map((p) => p.url)).toEqual(['https://ex.com/ok']); + expect(r.attempts[0].query).toBe('rapida'); + }, 2_000); + + it('timeout da rodada sem nenhuma query concluída: registra a query original', async () => { + const searchFn = vi.fn(() => new Promise(() => {})); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { maxRounds: 1, maxTimeoutPerRound: 20 }); + expect(r.attempts[0]).toMatchObject({ query: QUERY, results: [] }); + }, 2_000); + + it('URL repetida entre rodadas: conta só uma vez', async () => { + const searchFn = vi.fn(async () => [page('mesma', false)]); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { maxRounds: 2, enableQueryExpansion: false }); + expect(r.attempts.map((a) => a.results.length)).toEqual([1, 0]); + expect(r.scrapedSources).toHaveLength(1); + }); + + it('mais de 3 resultados numa rodada: registra quantos sobraram no log', async () => { + await executeProgressiveSearch(QUERY, vi.fn(async () => pages(5, false)), 'm', { maxRounds: 1 }); + expect(logged('... and 2 more results')).toBe(true); + }); + + it('até 3 resultados numa rodada: sem a linha de excedentes', async () => { + await executeProgressiveSearch(QUERY, vi.fn(async () => pages(3, false)), 'm', { maxRounds: 1 }); + expect(logged('more results')).toBe(false); + }); + + it('com contexto: relevância vem de calculateSemanticSimilarity', async () => { + // Em produção o webpack resolve este require; o require do Node não carrega .ts sem extensão. + const nodeRequire = Module.prototype.require; + vi.spyOn(Module.prototype, 'require').mockImplementation(function (this: NodeJS.Module, id: string) { + return id === './relevance-scorer' ? relevanceScorer : nodeRequire.call(this, id); + } as typeof nodeRequire); + const context = { keywords: ['inexistente'], entities: [], topics: [], synonyms: [] } as unknown as QueryContext; + const r = await executeProgressiveSearch(QUERY, vi.fn(async () => pages(5)), 'm', { context, maxRounds: 1 }); + // Pela heurística sem contexto o score seria 1 (early exit); com contexto a keyword não casa. + expect(r.attempts[0].relevanceScore).toBe(0); + expect(r.success).toBe(false); + }); + + it('5+ resultados com relevância baixa: não sai cedo', async () => { + const r = await executeProgressiveSearch(QUERY, vi.fn(async () => pages(6, false)), 'm', { maxRounds: 1 }); + expect(r).toMatchObject({ success: false, usedFallback: true, totalResultsAnalyzed: 6 }); + }); + + it('minResultsForEarlyExit e minRelevanceForEarlyExit configurados: sai com 1 resultado', async () => { + const r = await executeProgressiveSearch(QUERY, vi.fn(async () => [page(1)]), 'm', { minResultsForEarlyExit: 1, minRelevanceForEarlyExit: 0.9 }); + expect(r.success).toBe(true); + }); + + it('atingiu maxTotalResults: para antes das rodadas restantes', async () => { + let n = 0; + const searchFn = vi.fn(async () => pages(4, false, `r${n++}-`)); + const r = await executeProgressiveSearch(QUERY, searchFn, 'm', { maxTotalResults: 6, maxRounds: 4, enableQueryExpansion: false }); + expect(r.attempts).toHaveLength(2); + expect(r).toMatchObject({ success: false, totalResultsAnalyzed: 8 }); + }); +}); diff --git a/package.json b/package.json index 2f30dc0..ec4c1cd 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "next build", "start": "next start", "lint": "eslint", + "test": "vitest run", "generate-changelog": "node scripts/generate-changelog.js", "bump-version": "node scripts/bump-version.js" }, @@ -47,14 +48,18 @@ "devDependencies": { "@tailwindcss/postcss": "^4", "@tauri-apps/cli": "^2.9.4", + "@testing-library/dom": "^10.4.2", + "@testing-library/react": "^16.3.3", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "16.0.3", + "happy-dom": "^21.0.4", "raw-loader": "^4.0.2", "tailwindcss": "^4", "tw-animate-css": "^1.4.0", - "typescript": "^5" + "typescript": "^5", + "vitest": "^5.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 862e6ea..b43ad89 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,7 +73,7 @@ importers: version: 0.554.0(react@19.2.0) next: specifier: 16.0.3 - version: 16.0.3(@babel/core@7.28.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0) + version: 16.0.3(@babel/core@7.28.5(supports-color@8.1.1))(react-dom@19.2.0(react@19.2.0))(react@19.2.0) next-themes: specifier: ^0.4.6 version: 0.4.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0) @@ -85,7 +85,7 @@ importers: version: 19.2.0(react@19.2.0) react-markdown: specifier: ^10.1.0 - version: 10.1.0(@types/react@19.2.6)(react@19.2.0) + version: 10.1.0(@types/react@19.2.6)(react@19.2.0)(supports-color@8.1.1) react-resizable-panels: specifier: ^3.0.6 version: 3.0.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0) @@ -94,7 +94,7 @@ importers: version: 16.1.0(react@19.2.0) remark-gfm: specifier: ^4.0.1 - version: 4.0.1 + version: 4.0.1(supports-color@8.1.1) remove-accents: specifier: ^0.5.0 version: 0.5.0 @@ -111,6 +111,12 @@ importers: '@tauri-apps/cli': specifier: ^2.9.4 version: 2.9.4 + '@testing-library/dom': + specifier: ^10.4.2 + version: 10.4.2 + '@testing-library/react': + specifier: ^16.3.3 + version: 16.3.3(@testing-library/dom@10.4.2)(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0) '@types/node': specifier: ^20 version: 20.19.25 @@ -122,10 +128,13 @@ importers: version: 19.2.3(@types/react@19.2.6) eslint: specifier: ^9 - version: 9.39.1(jiti@2.6.1) + version: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) eslint-config-next: specifier: 16.0.3 - version: 16.0.3(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + version: 16.0.3(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + happy-dom: + specifier: ^21.0.4 + version: 21.0.4 raw-loader: specifier: ^4.0.2 version: 4.0.2(webpack@5.103.0) @@ -138,6 +147,9 @@ importers: typescript: specifier: ^5 version: 5.9.3 + vitest: + specifier: ^5.1.0 + version: 5.1.0(@types/node@20.19.25)(happy-dom@21.0.4)(vite@8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1)) packages: @@ -219,12 +231,21 @@ packages: '@emnapi/core@1.7.1': resolution: {integrity: sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg==} + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + '@emnapi/runtime@1.7.1': resolution: {integrity: sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==} + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + '@emnapi/wasi-threads@1.1.0': resolution: {integrity: sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==} + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + '@eslint-community/eslint-utils@4.9.0': resolution: {integrity: sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -324,89 +345,105 @@ packages: resolution: {integrity: sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==} cpu: [arm64] os: [linux] + libc: [glibc] '@img/sharp-libvips-linux-arm@1.2.4': resolution: {integrity: sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==} cpu: [arm] os: [linux] + libc: [glibc] '@img/sharp-libvips-linux-ppc64@1.2.4': resolution: {integrity: sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==} cpu: [ppc64] os: [linux] + libc: [glibc] '@img/sharp-libvips-linux-riscv64@1.2.4': resolution: {integrity: sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==} cpu: [riscv64] os: [linux] + libc: [glibc] '@img/sharp-libvips-linux-s390x@1.2.4': resolution: {integrity: sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==} cpu: [s390x] os: [linux] + libc: [glibc] '@img/sharp-libvips-linux-x64@1.2.4': resolution: {integrity: sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==} cpu: [x64] os: [linux] + libc: [glibc] '@img/sharp-libvips-linuxmusl-arm64@1.2.4': resolution: {integrity: sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==} cpu: [arm64] os: [linux] + libc: [musl] '@img/sharp-libvips-linuxmusl-x64@1.2.4': resolution: {integrity: sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==} cpu: [x64] os: [linux] + libc: [musl] '@img/sharp-linux-arm64@0.34.5': resolution: {integrity: sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm64] os: [linux] + libc: [glibc] '@img/sharp-linux-arm@0.34.5': resolution: {integrity: sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm] os: [linux] + libc: [glibc] '@img/sharp-linux-ppc64@0.34.5': resolution: {integrity: sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [ppc64] os: [linux] + libc: [glibc] '@img/sharp-linux-riscv64@0.34.5': resolution: {integrity: sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [riscv64] os: [linux] + libc: [glibc] '@img/sharp-linux-s390x@0.34.5': resolution: {integrity: sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [s390x] os: [linux] + libc: [glibc] '@img/sharp-linux-x64@0.34.5': resolution: {integrity: sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [x64] os: [linux] + libc: [glibc] '@img/sharp-linuxmusl-arm64@0.34.5': resolution: {integrity: sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [arm64] os: [linux] + libc: [musl] '@img/sharp-linuxmusl-x64@0.34.5': resolution: {integrity: sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} cpu: [x64] os: [linux] + libc: [musl] '@img/sharp-wasm32@0.34.5': resolution: {integrity: sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==} @@ -447,12 +484,22 @@ packages: '@jridgewell/sourcemap-codec@1.5.5': resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + '@jridgewell/sourcemap-codec@1.6.0': + resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} + '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} '@napi-rs/wasm-runtime@0.2.12': resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + '@next/env@16.0.3': resolution: {integrity: sha512-IqgtY5Vwsm14mm/nmQaRMmywCU+yyMIYfk3/MHZ2ZTJvwVbBn3usZnjMi1GacrMVzVcAxJShTCpZlPs26EdEjQ==} @@ -476,24 +523,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@next/swc-linux-arm64-musl@16.0.3': resolution: {integrity: sha512-CEErFt78S/zYXzFIiv18iQCbRbLgBluS8z1TNDQoyPi8/Jr5qhR3e8XHAIxVxPBjDbEMITprqELVc5KTfFj0gg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@next/swc-linux-x64-gnu@16.0.3': resolution: {integrity: sha512-Tc3i+nwt6mQ+Dwzcri/WNDj56iWdycGVh5YwwklleClzPzz7UpfaMw1ci7bLl6GRYMXhWDBfe707EXNjKtiswQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@next/swc-linux-x64-musl@16.0.3': resolution: {integrity: sha512-zTh03Z/5PBBPdTurgEtr6nY0vI9KR9Ifp/jZCcHlODzwVOEKcKRBtQIGrkc7izFgOMuXDEJBmirwpGqdM/ZixA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@next/swc-win32-arm64-msvc@16.0.3': resolution: {integrity: sha512-Jc1EHxtZovcJcg5zU43X3tuqzl/sS+CmLgjRP28ZT4vk869Ncm2NoF8qSTaL99gh6uOzgM99Shct06pSO6kA6g==} @@ -523,6 +574,9 @@ packages: resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==} engines: {node: '>=12.4.0'} + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + '@radix-ui/number@1.1.1': resolution: {integrity: sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==} @@ -988,6 +1042,110 @@ packages: '@radix-ui/rect@1.1.1': resolution: {integrity: sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw==} + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} + '@rtsao/scc@1.1.0': resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} @@ -1032,24 +1190,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@tailwindcss/oxide-linux-arm64-musl@4.1.17': resolution: {integrity: sha512-HvZLfGr42i5anKtIeQzxdkw/wPqIbpeZqe7vd3V9vI3RQxe3xU1fLjss0TjyhxWcBaipk7NYwSrwTwK1hJARMg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@tailwindcss/oxide-linux-x64-gnu@4.1.17': resolution: {integrity: sha512-M3XZuORCGB7VPOEDH+nzpJ21XPvK5PyjlkSFkFziNHGLc5d6g3di2McAAblmaSUNl8IOmzYwLx9NsE7bplNkwQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@tailwindcss/oxide-linux-x64-musl@4.1.17': resolution: {integrity: sha512-k7f+pf9eXLEey4pBlw+8dgfJHY4PZ5qOUFDyNf7SI6lHjQ9Zt7+NcscjpwdCEbYi6FI5c2KDTDWyf2iHcCSyyQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@tailwindcss/oxide-wasm32-wasi@4.1.17': resolution: {integrity: sha512-cEytGqSSoy7zK4JRWiTCx43FsKP/zGr0CsuMawhH67ONlH+T79VteQeJQRO/X7L0juEUA8ZyuYikcRBf0vsxhg==} @@ -1108,30 +1270,35 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@tauri-apps/cli-linux-arm64-musl@2.9.4': resolution: {integrity: sha512-vg7yNn7ICTi6hRrcA/6ff2UpZQP7un3xe3SEld5QM0prgridbKAiXGaCKr3BnUBx/rGXegQlD/wiLcWdiiraSw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@tauri-apps/cli-linux-riscv64-gnu@2.9.4': resolution: {integrity: sha512-l8L+3VxNk6yv5T/Z/gv5ysngmIpsai40B9p6NQQyqYqxImqYX37pqREoEBl1YwG7szGnDibpWhidPrWKR59OJA==} engines: {node: '>= 10'} cpu: [riscv64] os: [linux] + libc: [glibc] '@tauri-apps/cli-linux-x64-gnu@2.9.4': resolution: {integrity: sha512-PepPhCXc/xVvE3foykNho46OmCyx47E/aG676vKTVp+mqin5d+IBqDL6wDKiGNT5OTTxKEyNlCQ81Xs2BQhhqA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@tauri-apps/cli-linux-x64-musl@2.9.4': resolution: {integrity: sha512-zcd1QVffh5tZs1u1SCKUV/V7RRynebgYUNWHuV0FsIF1MjnULUChEXhAhug7usCDq4GZReMJOoXa6rukEozWIw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@tauri-apps/cli-win32-arm64-msvc@2.9.4': resolution: {integrity: sha512-/7ZhnP6PY04bEob23q8MH/EoDISdmR1wuNm0k9d5HV7TDMd2GGCDa8dPXA4vJuglJKXIfXqxFmZ4L+J+MO42+w==} @@ -1159,12 +1326,43 @@ packages: '@tauri-apps/plugin-updater@2.9.0': resolution: {integrity: sha512-j++sgY8XpeDvzImTrzWA08OqqGqgkNyxczLD7FjNJJx/uXxMZFz5nDcfkyoI/rCjYuj2101Tci/r/HFmOmoxCg==} + '@testing-library/dom@10.4.2': + resolution: {integrity: sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==} + engines: {node: '>=18'} + + '@testing-library/react@16.3.3': + resolution: {integrity: sha512-Uo193NgQbPMz6lrrhtRQQFcMC6Re/ELLFbbuVL30WDlZxlpZf9/lMHTAVxPRLw1q1iu9OJmR1c2BLiENRstdBg==} + engines: {node: '>=18'} + peerDependencies: + '@testing-library/dom': ^10.0.0 + '@types/react': ^18.0.0 || ^19.0.0 + '@types/react-dom': ^18.0.0 || ^19.0.0 + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@tybys/wasm-util@0.10.1': resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==} + '@tybys/wasm-util@0.10.4': + resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==} + + '@types/aria-query@5.0.4': + resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/eslint-scope@3.7.7': resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} @@ -1215,6 +1413,12 @@ packages: '@types/unist@3.0.3': resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} + '@types/whatwg-mimetype@3.0.2': + resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==} + + '@types/ws@8.18.2': + resolution: {integrity: sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==} + '@typescript-eslint/eslint-plugin@8.47.0': resolution: {integrity: sha512-fe0rz9WJQ5t2iaLfdbDc9T80GJy0AeO453q8C3YCilnGozvOyCG5t+EZtg7j7D88+c3FipfP/x+wzGnh1xp8ZA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1316,41 +1520,49 @@ packages: resolution: {integrity: sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ==} cpu: [arm64] os: [linux] + libc: [glibc] '@unrs/resolver-binding-linux-arm64-musl@1.11.1': resolution: {integrity: sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w==} cpu: [arm64] os: [linux] + libc: [musl] '@unrs/resolver-binding-linux-ppc64-gnu@1.11.1': resolution: {integrity: sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA==} cpu: [ppc64] os: [linux] + libc: [glibc] '@unrs/resolver-binding-linux-riscv64-gnu@1.11.1': resolution: {integrity: sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ==} cpu: [riscv64] os: [linux] + libc: [glibc] '@unrs/resolver-binding-linux-riscv64-musl@1.11.1': resolution: {integrity: sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew==} cpu: [riscv64] os: [linux] + libc: [musl] '@unrs/resolver-binding-linux-s390x-gnu@1.11.1': resolution: {integrity: sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg==} cpu: [s390x] os: [linux] + libc: [glibc] '@unrs/resolver-binding-linux-x64-gnu@1.11.1': resolution: {integrity: sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w==} cpu: [x64] os: [linux] + libc: [glibc] '@unrs/resolver-binding-linux-x64-musl@1.11.1': resolution: {integrity: sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA==} cpu: [x64] os: [linux] + libc: [musl] '@unrs/resolver-binding-wasm32-wasi@1.11.1': resolution: {integrity: sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ==} @@ -1372,6 +1584,20 @@ packages: cpu: [x64] os: [win32] + '@vitest/mocker@5.1.0': + resolution: {integrity: sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==} + peerDependencies: + msw: ^2.4.9 || ^3.0.0 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/spy@5.1.0': + resolution: {integrity: sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==} + '@webassemblyjs/ast@1.14.1': resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==} @@ -1441,11 +1667,6 @@ packages: ajv-formats@2.1.1: resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true ajv-keywords@3.5.2: resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==} @@ -1463,10 +1684,18 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} + ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -1474,6 +1703,9 @@ packages: resolution: {integrity: sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==} engines: {node: '>=10'} + aria-query@5.3.0: + resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==} + aria-query@5.3.2: resolution: {integrity: sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==} engines: {node: '>= 0.4'} @@ -1510,6 +1742,10 @@ packages: resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} engines: {node: '>= 0.4'} + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + ast-types-flow@0.0.8: resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} @@ -1560,6 +1796,10 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + buffer-image-size@0.6.4: + resolution: {integrity: sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==} + engines: {node: '>=4.0'} + call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -1582,6 +1822,10 @@ packages: ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} + chai@6.3.0: + resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} + engines: {node: '>=18'} + chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} @@ -1702,6 +1946,9 @@ packages: resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} engines: {node: '>=0.10.0'} + dom-accessibility-api@0.5.16: + resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -1723,6 +1970,10 @@ packages: resolution: {integrity: sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==} engines: {node: '>=10.13.0'} + entities@7.0.1: + resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} + engines: {node: '>=0.12'} + es-abstract@1.24.0: resolution: {integrity: sha512-WSzPgsdLtTcQwm4CROfS5ju2Wa1QQcVeT37jFjYzdFz1r9ahadC8B8/a4qxJxM+09F18iumCdRmlr96ZYkQvEg==} engines: {node: '>= 0.4'} @@ -1742,6 +1993,9 @@ packages: es-module-lexer@1.7.0: resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} + es-module-lexer@2.3.2: + resolution: {integrity: sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==} + es-object-atoms@1.1.1: resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} engines: {node: '>= 0.4'} @@ -1893,6 +2147,9 @@ packages: estree-util-is-identifier-name@3.0.0: resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==} + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -1901,6 +2158,10 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} + expect-type@1.4.0: + resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} + engines: {node: '>=12.0.0'} + extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -1980,6 +2241,11 @@ packages: react-dom: optional: true + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} @@ -2050,6 +2316,10 @@ packages: graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + happy-dom@21.0.4: + resolution: {integrity: sha512-tFm+GaLBgo6o0awHnvHaNoraVo27qJ+2tZEtZ+cIa08hXbeitrxAJajLI05hsUy/2/YTKcUjQYzHe5mCcraLBw==} + engines: {node: '>=20.0.0'} + has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} engines: {node: '>= 0.4'} @@ -2324,53 +2594,115 @@ packages: cpu: [arm64] os: [android] + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + lightningcss-darwin-arm64@1.30.2: resolution: {integrity: sha512-ylTcDJBN3Hp21TdhRT5zBOIi73P6/W0qwvlFEk22fkdXchtNTOU4Qc37SkzV+EKYxLouZ6M4LG9NfZ1qkhhBWA==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [darwin] + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + lightningcss-darwin-x64@1.30.2: resolution: {integrity: sha512-oBZgKchomuDYxr7ilwLcyms6BCyLn0z8J0+ZZmfpjwg9fRVZIR5/GMXd7r9RH94iDhld3UmSjBM6nXWM2TfZTQ==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [darwin] + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + lightningcss-freebsd-x64@1.30.2: resolution: {integrity: sha512-c2bH6xTrf4BDpK8MoGG4Bd6zAMZDAXS569UxCAGcA7IKbHNMlhGQ89eRmvpIUGfKWNVdbhSbkQaWhEoMGmGslA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [freebsd] + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + lightningcss-linux-arm-gnueabihf@1.30.2: resolution: {integrity: sha512-eVdpxh4wYcm0PofJIZVuYuLiqBIakQ9uFZmipf6LF/HRj5Bgm0eb3qL/mr1smyXIS1twwOxNWndd8z0E374hiA==} engines: {node: '>= 12.0.0'} cpu: [arm] os: [linux] + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + lightningcss-linux-arm64-gnu@1.30.2: resolution: {integrity: sha512-UK65WJAbwIJbiBFXpxrbTNArtfuznvxAJw4Q2ZGlU8kPeDIWEX1dg3rn2veBVUylA2Ezg89ktszWbaQnxD/e3A==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] lightningcss-linux-arm64-musl@1.30.2: resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [musl] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] lightningcss-linux-x64-gnu@1.30.2: resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [glibc] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] lightningcss-linux-x64-musl@1.30.2: resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [musl] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] lightningcss-win32-arm64-msvc@1.30.2: resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==} @@ -2378,16 +2710,32 @@ packages: cpu: [arm64] os: [win32] + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + lightningcss-win32-x64-msvc@1.30.2: resolution: {integrity: sha512-5g1yc73p+iAkid5phb4oVFMB45417DkRevRbt/El/gKXJk4jid+vPFF/AXbxn05Aky8PapwzZrdJShv5C0avjw==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [win32] + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + lightningcss@1.30.2: resolution: {integrity: sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ==} engines: {node: '>= 12.0.0'} + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + loader-runner@4.3.1: resolution: {integrity: sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==} engines: {node: '>=6.11.5'} @@ -2421,9 +2769,16 @@ packages: peerDependencies: react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0 + lz-string@1.5.0: + resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} + hasBin: true + magic-string@0.30.21: resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + magic-string@1.4.5: + resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==} + markdown-table@3.0.4: resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==} @@ -2603,6 +2958,11 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + napi-postinstall@0.3.4: resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} @@ -2676,6 +3036,10 @@ packages: resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==} engines: {node: '>= 0.4'} + obug@3.0.0: + resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} + engines: {node: '>=12.20.0'} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -2721,6 +3085,10 @@ packages: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + possible-typed-array-names@1.1.0: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} @@ -2729,6 +3097,10 @@ packages: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} + postcss@8.5.33: + resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==} + engines: {node: ^10 || ^12 || >=14} + postcss@8.5.6: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} @@ -2737,6 +3109,10 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + pretty-format@27.5.1: + resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} + engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + prismjs@1.30.0: resolution: {integrity: sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==} engines: {node: '>=6'} @@ -2771,6 +3147,9 @@ packages: react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + react-is@17.0.2: + resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} + react-markdown@10.1.0: resolution: {integrity: sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==} peerDependencies: @@ -2873,6 +3252,11 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -2958,6 +3342,10 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} + engines: {node: '>=0.10.0'} + source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} @@ -2971,6 +3359,9 @@ packages: stable-hash@0.0.5: resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==} + std-env@4.3.0: + resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + stop-iteration-iterator@1.1.0: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} @@ -3071,10 +3462,22 @@ packages: engines: {node: '>=10'} hasBin: true + tinybench@6.2.3: + resolution: {integrity: sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==} + engines: {node: '>=20.0.0'} + + tinyexec@1.3.1: + resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} + engines: {node: '>=18'} + tinyglobby@0.2.15: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -3195,6 +3598,90 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vite@8.3.8: + resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.7.1 || ^0.8.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@5.1.0: + resolution: {integrity: sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==} + engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 5.1.0 + '@vitest/browser-preview': 5.1.0 + '@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0 + '@vitest/coverage-istanbul': 5.1.0 + '@vitest/coverage-v8': 5.1.0 + '@vitest/ui': 5.1.0 + happy-dom: '*' + jsdom: '*' + vite: ^6.4.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/coverage-istanbul': + optional: true + '@vitest/coverage-v8': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + watchpack@2.4.4: resolution: {integrity: sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==} engines: {node: '>=10.13.0'} @@ -3213,6 +3700,10 @@ packages: webpack-cli: optional: true + whatwg-mimetype@3.0.0: + resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==} + engines: {node: '>=12'} + which-boxed-primitive@1.1.1: resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} engines: {node: '>= 0.4'} @@ -3234,10 +3725,27 @@ packages: engines: {node: '>= 8'} hasBin: true + why-is-node-running@3.2.1: + resolution: {integrity: sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==} + engines: {node: '>=20.11'} + hasBin: true + word-wrap@1.2.5: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + ws@8.23.0: + resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -3287,20 +3795,20 @@ snapshots: '@babel/compat-data@7.28.5': {} - '@babel/core@7.28.5': + '@babel/core@7.28.5(supports-color@8.1.1)': dependencies: '@babel/code-frame': 7.27.1 '@babel/generator': 7.28.5 '@babel/helper-compilation-targets': 7.27.2 - '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.5) + '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.5(supports-color@8.1.1))(supports-color@8.1.1) '@babel/helpers': 7.28.4 '@babel/parser': 7.28.5 '@babel/template': 7.27.2 - '@babel/traverse': 7.28.5 + '@babel/traverse': 7.28.5(supports-color@8.1.1) '@babel/types': 7.28.5 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -3325,19 +3833,19 @@ snapshots: '@babel/helper-globals@7.28.0': {} - '@babel/helper-module-imports@7.27.1': + '@babel/helper-module-imports@7.27.1(supports-color@8.1.1)': dependencies: - '@babel/traverse': 7.28.5 + '@babel/traverse': 7.28.5(supports-color@8.1.1) '@babel/types': 7.28.5 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.28.3(@babel/core@7.28.5)': + '@babel/helper-module-transforms@7.28.3(@babel/core@7.28.5(supports-color@8.1.1))(supports-color@8.1.1)': dependencies: - '@babel/core': 7.28.5 - '@babel/helper-module-imports': 7.27.1 + '@babel/core': 7.28.5(supports-color@8.1.1) + '@babel/helper-module-imports': 7.27.1(supports-color@8.1.1) '@babel/helper-validator-identifier': 7.28.5 - '@babel/traverse': 7.28.5 + '@babel/traverse': 7.28.5(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -3364,7 +3872,7 @@ snapshots: '@babel/parser': 7.28.5 '@babel/types': 7.28.5 - '@babel/traverse@7.28.5': + '@babel/traverse@7.28.5(supports-color@8.1.1)': dependencies: '@babel/code-frame': 7.27.1 '@babel/generator': 7.28.5 @@ -3372,7 +3880,7 @@ snapshots: '@babel/parser': 7.28.5 '@babel/template': 7.27.2 '@babel/types': 7.28.5 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -3387,27 +3895,43 @@ snapshots: tslib: 2.8.1 optional: true + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.8.1 + optional: true + '@emnapi/runtime@1.7.1': dependencies: tslib: 2.8.1 optional: true + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/wasi-threads@1.1.0': dependencies: tslib: 2.8.1 optional: true - '@eslint-community/eslint-utils@4.9.0(eslint@9.39.1(jiti@2.6.1))': + '@emnapi/wasi-threads@2.2.0': dependencies: - eslint: 9.39.1(jiti@2.6.1) + tslib: 2.8.1 + optional: true + + '@eslint-community/eslint-utils@4.9.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))': + dependencies: + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.21.1': + '@eslint/config-array@0.21.1(supports-color@8.1.1)': dependencies: '@eslint/object-schema': 2.1.7 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -3420,10 +3944,10 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/eslintrc@3.3.1': + '@eslint/eslintrc@3.3.1(supports-color@8.1.1)': dependencies: ajv: 6.12.6 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) espree: 10.4.0 globals: 14.0.0 ignore: 5.3.2 @@ -3587,6 +4111,8 @@ snapshots: '@jridgewell/sourcemap-codec@1.5.5': {} + '@jridgewell/sourcemap-codec@1.6.0': {} + '@jridgewell/trace-mapping@0.3.31': dependencies: '@jridgewell/resolve-uri': 3.1.2 @@ -3599,6 +4125,13 @@ snapshots: '@tybys/wasm-util': 0.10.1 optional: true + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.4 + optional: true + '@next/env@16.0.3': {} '@next/eslint-plugin-next@16.0.3': @@ -3643,6 +4176,8 @@ snapshots: '@nolyfill/is-core-module@1.0.39': {} + '@oxc-project/types@0.156.0': {} + '@radix-ui/number@1.1.1': {} '@radix-ui/primitive@1.1.3': {} @@ -4110,6 +4645,60 @@ snapshots: '@radix-ui/rect@1.1.1': {} + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + + '@rolldown/binding-android-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/pluginutils@1.1.1': {} + '@rtsao/scc@1.1.0': {} '@swc/helpers@0.5.15': @@ -4238,15 +4827,50 @@ snapshots: dependencies: '@tauri-apps/api': 2.9.0 + '@testing-library/dom@10.4.2': + dependencies: + '@babel/code-frame': 7.27.1 + '@babel/runtime': 7.28.4 + '@types/aria-query': 5.0.4 + aria-query: 5.3.0 + dom-accessibility-api: 0.5.16 + lz-string: 1.5.0 + picocolors: 1.1.1 + pretty-format: 27.5.1 + + '@testing-library/react@16.3.3(@testing-library/dom@10.4.2)(@types/react-dom@19.2.3(@types/react@19.2.6))(@types/react@19.2.6)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)': + dependencies: + '@babel/runtime': 7.28.4 + '@testing-library/dom': 10.4.2 + react: 19.2.0 + react-dom: 19.2.0(react@19.2.0) + optionalDependencies: + '@types/react': 19.2.6 + '@types/react-dom': 19.2.3(@types/react@19.2.6) + '@tybys/wasm-util@0.10.1': dependencies: tslib: 2.8.1 optional: true + '@tybys/wasm-util@0.10.4': + dependencies: + tslib: 2.8.1 + optional: true + + '@types/aria-query@5.0.4': {} + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + '@types/debug@4.1.12': dependencies: '@types/ms': 2.1.0 + '@types/deep-eql@4.0.2': {} + '@types/eslint-scope@3.7.7': dependencies: '@types/eslint': 9.6.1 @@ -4299,15 +4923,21 @@ snapshots: '@types/unist@3.0.3': {} - '@typescript-eslint/eslint-plugin@8.47.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3)': + '@types/whatwg-mimetype@3.0.2': {} + + '@types/ws@8.18.2': + dependencies: + '@types/node': 20.19.25 + + '@typescript-eslint/eslint-plugin@8.47.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.47.0 - '@typescript-eslint/type-utils': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/type-utils': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.47.0 - eslint: 9.39.1(jiti@2.6.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) graphemer: 1.4.0 ignore: 7.0.5 natural-compare: 1.4.0 @@ -4316,23 +4946,23 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3)': + '@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.47.0 '@typescript-eslint/types': 8.47.0 - '@typescript-eslint/typescript-estree': 8.47.0(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.47.0(supports-color@8.1.1)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.47.0 - debug: 4.4.3 - eslint: 9.39.1(jiti@2.6.1) + debug: 4.4.3(supports-color@8.1.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.47.0(typescript@5.9.3)': + '@typescript-eslint/project-service@8.47.0(supports-color@8.1.1)(typescript@5.9.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.47.0(typescript@5.9.3) '@typescript-eslint/types': 8.47.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -4346,13 +4976,13 @@ snapshots: dependencies: typescript: 5.9.3 - '@typescript-eslint/type-utils@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3)': + '@typescript-eslint/type-utils@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.47.0 - '@typescript-eslint/typescript-estree': 8.47.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - debug: 4.4.3 - eslint: 9.39.1(jiti@2.6.1) + '@typescript-eslint/typescript-estree': 8.47.0(supports-color@8.1.1)(typescript@5.9.3) + '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + debug: 4.4.3(supports-color@8.1.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) ts-api-utils: 2.1.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: @@ -4360,13 +4990,13 @@ snapshots: '@typescript-eslint/types@8.47.0': {} - '@typescript-eslint/typescript-estree@8.47.0(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.47.0(supports-color@8.1.1)(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.47.0(typescript@5.9.3) + '@typescript-eslint/project-service': 8.47.0(supports-color@8.1.1)(typescript@5.9.3) '@typescript-eslint/tsconfig-utils': 8.47.0(typescript@5.9.3) '@typescript-eslint/types': 8.47.0 '@typescript-eslint/visitor-keys': 8.47.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 @@ -4376,13 +5006,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3)': + '@typescript-eslint/utils@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3)': dependencies: - '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@2.6.1)) + '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)) '@typescript-eslint/scope-manager': 8.47.0 '@typescript-eslint/types': 8.47.0 - '@typescript-eslint/typescript-estree': 8.47.0(typescript@5.9.3) - eslint: 9.39.1(jiti@2.6.1) + '@typescript-eslint/typescript-estree': 8.47.0(supports-color@8.1.1)(typescript@5.9.3) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -4453,6 +5083,17 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.11.1': optional: true + '@vitest/mocker@5.1.0(vite@8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1))': + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + '@vitest/spy': 5.1.0 + estree-walker: 3.0.3 + magic-string: 1.4.5 + optionalDependencies: + vite: 8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1) + + '@vitest/spy@5.1.0': {} + '@webassemblyjs/ast@1.14.1': dependencies: '@webassemblyjs/helper-numbers': 1.13.2 @@ -4543,8 +5184,8 @@ snapshots: acorn@8.15.0: {} - ajv-formats@2.1.1(ajv@8.17.1): - optionalDependencies: + ajv-formats@2.1.1: + dependencies: ajv: 8.17.1 ajv-keywords@3.5.2(ajv@6.12.6): @@ -4570,16 +5211,24 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + ansi-regex@5.0.1: {} + ansi-styles@4.3.0: dependencies: color-convert: 2.0.1 + ansi-styles@5.2.0: {} + argparse@2.0.1: {} aria-hidden@1.2.6: dependencies: tslib: 2.8.1 + aria-query@5.3.0: + dependencies: + dequal: 2.0.3 + aria-query@5.3.2: {} array-buffer-byte-length@1.0.2: @@ -4649,6 +5298,8 @@ snapshots: get-intrinsic: 1.3.0 is-array-buffer: 3.0.5 + assertion-error@2.0.1: {} + ast-types-flow@0.0.8: {} async-function@1.0.0: {} @@ -4692,6 +5343,10 @@ snapshots: buffer-from@1.1.2: {} + buffer-image-size@0.6.4: + dependencies: + '@types/node': 20.19.25 + call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -4715,6 +5370,8 @@ snapshots: ccount@2.0.1: {} + chai@6.3.0: {} + chalk@4.1.2: dependencies: ansi-styles: 4.3.0 @@ -4780,13 +5437,17 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.2 - debug@3.2.7: + debug@3.2.7(supports-color@8.1.1): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 8.1.1 - debug@4.4.3: + debug@4.4.3(supports-color@8.1.1): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 8.1.1 decode-named-character-reference@1.2.0: dependencies: @@ -4820,6 +5481,8 @@ snapshots: dependencies: esutils: 2.0.3 + dom-accessibility-api@0.5.16: {} + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -4839,6 +5502,8 @@ snapshots: graceful-fs: 4.2.11 tapable: 2.3.0 + entities@7.0.1: {} + es-abstract@1.24.0: dependencies: array-buffer-byte-length: 1.0.2 @@ -4921,6 +5586,8 @@ snapshots: es-module-lexer@1.7.0: {} + es-module-lexer@2.3.2: {} + es-object-atoms@1.1.1: dependencies: es-errors: 1.3.0 @@ -4948,18 +5615,18 @@ snapshots: escape-string-regexp@5.0.0: {} - eslint-config-next@16.0.3(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3): + eslint-config-next@16.0.3(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3): dependencies: '@next/eslint-plugin-next': 16.0.3 - eslint: 9.39.1(jiti@2.6.1) - eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)) - eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.1(jiti@2.6.1)) - eslint-plugin-react: 7.37.5(eslint@9.39.1(jiti@2.6.1)) - eslint-plugin-react-hooks: 7.0.1(eslint@9.39.1(jiti@2.6.1)) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) + eslint-import-resolver-node: 0.3.9(supports-color@8.1.1) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) + eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)) + eslint-plugin-react: 7.37.5(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)) + eslint-plugin-react-hooks: 7.0.1(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) globals: 16.4.0 - typescript-eslint: 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + typescript-eslint: 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: @@ -4968,52 +5635,52 @@ snapshots: - eslint-plugin-import-x - supports-color - eslint-import-resolver-node@0.3.9: + eslint-import-resolver-node@0.3.9(supports-color@8.1.1): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) is-core-module: 2.16.1 resolve: 1.22.11 transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)): + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1): dependencies: '@nolyfill/is-core-module': 1.0.39 - debug: 4.4.3 - eslint: 9.39.1(jiti@2.6.1) + debug: 4.4.3(supports-color@8.1.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) get-tsconfig: 4.13.0 is-bun-module: 2.0.0 stable-hash: 0.0.5 tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.1(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)): + eslint-module-utils@2.12.1(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint-import-resolver-node@0.3.9(supports-color@8.1.1))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) optionalDependencies: - '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - eslint: 9.39.1(jiti@2.6.1) - eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)) + '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) + eslint-import-resolver-node: 0.3.9(supports-color@8.1.1) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 array.prototype.findlastindex: 1.2.6 array.prototype.flat: 1.3.3 array.prototype.flatmap: 1.3.3 - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) doctrine: 2.1.0 - eslint: 9.39.1(jiti@2.6.1) - eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) + eslint-import-resolver-node: 0.3.9(supports-color@8.1.1) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint-import-resolver-node@0.3.9(supports-color@8.1.1))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 @@ -5025,13 +5692,13 @@ snapshots: string.prototype.trimend: 1.0.9 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.1(jiti@2.6.1)): + eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)): dependencies: aria-query: 5.3.2 array-includes: 3.1.9 @@ -5041,7 +5708,7 @@ snapshots: axobject-query: 4.1.0 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 9.39.1(jiti@2.6.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) hasown: 2.0.2 jsx-ast-utils: 3.3.5 language-tags: 1.0.9 @@ -5050,18 +5717,18 @@ snapshots: safe-regex-test: 1.1.0 string.prototype.includes: 2.0.1 - eslint-plugin-react-hooks@7.0.1(eslint@9.39.1(jiti@2.6.1)): + eslint-plugin-react-hooks@7.0.1(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1): dependencies: - '@babel/core': 7.28.5 + '@babel/core': 7.28.5(supports-color@8.1.1) '@babel/parser': 7.28.5 - eslint: 9.39.1(jiti@2.6.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) hermes-parser: 0.25.1 zod: 4.1.12 zod-validation-error: 4.0.2(zod@4.1.12) transitivePeerDependencies: - supports-color - eslint-plugin-react@7.37.5(eslint@9.39.1(jiti@2.6.1)): + eslint-plugin-react@7.37.5(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)): dependencies: array-includes: 3.1.9 array.prototype.findlast: 1.2.5 @@ -5069,7 +5736,7 @@ snapshots: array.prototype.tosorted: 1.1.4 doctrine: 2.1.0 es-iterator-helpers: 1.2.1 - eslint: 9.39.1(jiti@2.6.1) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) estraverse: 5.3.0 hasown: 2.0.2 jsx-ast-utils: 3.3.5 @@ -5097,14 +5764,14 @@ snapshots: eslint-visitor-keys@4.2.1: {} - eslint@9.39.1(jiti@2.6.1): + eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1): dependencies: - '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@2.6.1)) + '@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1)) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.21.1 + '@eslint/config-array': 0.21.1(supports-color@8.1.1) '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 - '@eslint/eslintrc': 3.3.1 + '@eslint/eslintrc': 3.3.1(supports-color@8.1.1) '@eslint/js': 9.39.1 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.7 @@ -5114,7 +5781,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1 @@ -5158,10 +5825,16 @@ snapshots: estree-util-is-identifier-name@3.0.0: {} + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.8 + esutils@2.0.3: {} events@3.3.0: {} + expect-type@1.4.0: {} + extend@3.0.2: {} fast-deep-equal@3.1.3: {} @@ -5200,6 +5873,10 @@ snapshots: optionalDependencies: picomatch: 4.0.3 + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + file-entry-cache@8.0.0: dependencies: flat-cache: 4.0.1 @@ -5235,6 +5912,9 @@ snapshots: react: 19.2.0 react-dom: 19.2.0(react@19.2.0) + fsevents@2.3.3: + optional: true + function-bind@1.1.2: {} function.prototype.name@1.1.8: @@ -5307,6 +5987,19 @@ snapshots: graphemer@1.4.0: {} + happy-dom@21.0.4: + dependencies: + '@types/node': 20.19.25 + '@types/whatwg-mimetype': 3.0.2 + '@types/ws': 8.18.2 + buffer-image-size: 0.6.4 + entities: 7.0.1 + whatwg-mimetype: 3.0.0 + ws: 8.23.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + has-bigints@1.1.0: {} has-flag@4.0.0: {} @@ -5333,7 +6026,7 @@ snapshots: dependencies: '@types/hast': 3.0.4 - hast-util-to-jsx-runtime@2.3.6: + hast-util-to-jsx-runtime@2.3.6(supports-color@8.1.1): dependencies: '@types/estree': 1.0.8 '@types/hast': 3.0.4 @@ -5342,9 +6035,9 @@ snapshots: devlop: 1.1.0 estree-util-is-identifier-name: 3.0.0 hast-util-whitespace: 3.0.0 - mdast-util-mdx-expression: 2.0.1 - mdast-util-mdx-jsx: 3.2.0 - mdast-util-mdxjs-esm: 2.0.1 + mdast-util-mdx-expression: 2.0.1(supports-color@8.1.1) + mdast-util-mdx-jsx: 3.2.0(supports-color@8.1.1) + mdast-util-mdxjs-esm: 2.0.1(supports-color@8.1.1) property-information: 7.1.0 space-separated-tokens: 2.0.2 style-to-js: 1.1.21 @@ -5591,36 +6284,69 @@ snapshots: lightningcss-android-arm64@1.30.2: optional: true + lightningcss-android-arm64@1.33.0: + optional: true + lightningcss-darwin-arm64@1.30.2: optional: true + lightningcss-darwin-arm64@1.33.0: + optional: true + lightningcss-darwin-x64@1.30.2: optional: true + lightningcss-darwin-x64@1.33.0: + optional: true + lightningcss-freebsd-x64@1.30.2: optional: true + lightningcss-freebsd-x64@1.33.0: + optional: true + lightningcss-linux-arm-gnueabihf@1.30.2: optional: true + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + lightningcss-linux-arm64-gnu@1.30.2: optional: true + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + lightningcss-linux-arm64-musl@1.30.2: optional: true + lightningcss-linux-arm64-musl@1.33.0: + optional: true + lightningcss-linux-x64-gnu@1.30.2: optional: true + lightningcss-linux-x64-gnu@1.33.0: + optional: true + lightningcss-linux-x64-musl@1.30.2: optional: true + lightningcss-linux-x64-musl@1.33.0: + optional: true + lightningcss-win32-arm64-msvc@1.30.2: optional: true + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + lightningcss-win32-x64-msvc@1.30.2: optional: true + lightningcss-win32-x64-msvc@1.33.0: + optional: true + lightningcss@1.30.2: dependencies: detect-libc: 2.1.2 @@ -5637,6 +6363,22 @@ snapshots: lightningcss-win32-arm64-msvc: 1.30.2 lightningcss-win32-x64-msvc: 1.30.2 + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + loader-runner@4.3.1: {} loader-utils@2.0.4: @@ -5670,10 +6412,16 @@ snapshots: dependencies: react: 19.2.0 + lz-string@1.5.0: {} + magic-string@0.30.21: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 + magic-string@1.4.5: + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + markdown-table@3.0.4: {} math-intrinsics@1.1.0: {} @@ -5685,14 +6433,14 @@ snapshots: unist-util-is: 6.0.1 unist-util-visit-parents: 6.0.2 - mdast-util-from-markdown@2.0.2: + mdast-util-from-markdown@2.0.2(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 '@types/unist': 3.0.3 decode-named-character-reference: 1.2.0 devlop: 1.1.0 mdast-util-to-string: 4.0.0 - micromark: 4.0.2 + micromark: 4.0.2(supports-color@8.1.1) micromark-util-decode-numeric-character-reference: 2.0.2 micromark-util-decode-string: 2.0.1 micromark-util-normalize-identifier: 2.0.1 @@ -5710,67 +6458,67 @@ snapshots: mdast-util-find-and-replace: 3.0.2 micromark-util-character: 2.1.1 - mdast-util-gfm-footnote@2.1.0: + mdast-util-gfm-footnote@2.1.0(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 micromark-util-normalize-identifier: 2.0.1 transitivePeerDependencies: - supports-color - mdast-util-gfm-strikethrough@2.0.0: + mdast-util-gfm-strikethrough@2.0.0(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm-table@2.0.0: + mdast-util-gfm-table@2.0.0(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 markdown-table: 3.0.4 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm-task-list-item@2.0.0: + mdast-util-gfm-task-list-item@2.0.0(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-gfm@3.1.0: + mdast-util-gfm@3.1.0(supports-color@8.1.1): dependencies: - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-gfm-autolink-literal: 2.0.1 - mdast-util-gfm-footnote: 2.1.0 - mdast-util-gfm-strikethrough: 2.0.0 - mdast-util-gfm-table: 2.0.0 - mdast-util-gfm-task-list-item: 2.0.0 + mdast-util-gfm-footnote: 2.1.0(supports-color@8.1.1) + mdast-util-gfm-strikethrough: 2.0.0(supports-color@8.1.1) + mdast-util-gfm-table: 2.0.0(supports-color@8.1.1) + mdast-util-gfm-task-list-item: 2.0.0(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-mdx-expression@2.0.1: + mdast-util-mdx-expression@2.0.1(supports-color@8.1.1): dependencies: '@types/estree-jsx': 1.0.5 '@types/hast': 3.0.4 '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color - mdast-util-mdx-jsx@3.2.0: + mdast-util-mdx-jsx@3.2.0(supports-color@8.1.1): dependencies: '@types/estree-jsx': 1.0.5 '@types/hast': 3.0.4 @@ -5778,7 +6526,7 @@ snapshots: '@types/unist': 3.0.3 ccount: 2.0.1 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 parse-entities: 4.0.2 stringify-entities: 4.0.4 @@ -5787,13 +6535,13 @@ snapshots: transitivePeerDependencies: - supports-color - mdast-util-mdxjs-esm@2.0.1: + mdast-util-mdxjs-esm@2.0.1(supports-color@8.1.1): dependencies: '@types/estree-jsx': 1.0.5 '@types/hast': 3.0.4 '@types/mdast': 4.0.4 devlop: 1.1.0 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) mdast-util-to-markdown: 2.1.2 transitivePeerDependencies: - supports-color @@ -6004,10 +6752,10 @@ snapshots: micromark-util-types@2.0.2: {} - micromark@4.0.2: + micromark@4.0.2(supports-color@8.1.1): dependencies: '@types/debug': 4.1.12 - debug: 4.4.3 + debug: 4.4.3(supports-color@8.1.1) decode-named-character-reference: 1.2.0 devlop: 1.1.0 micromark-core-commonmark: 2.0.3 @@ -6057,6 +6805,8 @@ snapshots: nanoid@3.3.11: {} + nanoid@3.3.20: {} + napi-postinstall@0.3.4: {} natural-compare@1.4.0: {} @@ -6068,7 +6818,7 @@ snapshots: react: 19.2.0 react-dom: 19.2.0(react@19.2.0) - next@16.0.3(@babel/core@7.28.5)(react-dom@19.2.0(react@19.2.0))(react@19.2.0): + next@16.0.3(@babel/core@7.28.5(supports-color@8.1.1))(react-dom@19.2.0(react@19.2.0))(react@19.2.0): dependencies: '@next/env': 16.0.3 '@swc/helpers': 0.5.15 @@ -6076,7 +6826,7 @@ snapshots: postcss: 8.4.31 react: 19.2.0 react-dom: 19.2.0(react@19.2.0) - styled-jsx: 5.1.6(@babel/core@7.28.5)(react@19.2.0) + styled-jsx: 5.1.6(@babel/core@7.28.5(supports-color@8.1.1))(react@19.2.0) optionalDependencies: '@next/swc-darwin-arm64': 16.0.3 '@next/swc-darwin-x64': 16.0.3 @@ -6135,6 +6885,8 @@ snapshots: define-properties: 1.2.1 es-object-atoms: 1.1.1 + obug@3.0.0: {} + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -6184,6 +6936,8 @@ snapshots: picomatch@4.0.3: {} + picomatch@4.0.7: {} + possible-typed-array-names@1.1.0: {} postcss@8.4.31: @@ -6192,6 +6946,12 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + postcss@8.5.33: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.2 + postcss@8.5.6: dependencies: nanoid: 3.3.11 @@ -6200,6 +6960,12 @@ snapshots: prelude-ls@1.2.1: {} + pretty-format@27.5.1: + dependencies: + ansi-regex: 5.0.1 + ansi-styles: 5.2.0 + react-is: 17.0.2 + prismjs@1.30.0: {} prop-types@15.8.1: @@ -6231,17 +6997,19 @@ snapshots: react-is@16.13.1: {} - react-markdown@10.1.0(@types/react@19.2.6)(react@19.2.0): + react-is@17.0.2: {} + + react-markdown@10.1.0(@types/react@19.2.6)(react@19.2.0)(supports-color@8.1.1): dependencies: '@types/hast': 3.0.4 '@types/mdast': 4.0.4 '@types/react': 19.2.6 devlop: 1.1.0 - hast-util-to-jsx-runtime: 2.3.6 + hast-util-to-jsx-runtime: 2.3.6(supports-color@8.1.1) html-url-attributes: 3.0.1 mdast-util-to-hast: 13.2.0 react: 19.2.0 - remark-parse: 11.0.0 + remark-parse: 11.0.0(supports-color@8.1.1) remark-rehype: 11.1.2 unified: 11.0.5 unist-util-visit: 5.0.0 @@ -6320,21 +7088,21 @@ snapshots: gopd: 1.2.0 set-function-name: 2.0.2 - remark-gfm@4.0.1: + remark-gfm@4.0.1(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 - mdast-util-gfm: 3.1.0 + mdast-util-gfm: 3.1.0(supports-color@8.1.1) micromark-extension-gfm: 3.0.0 - remark-parse: 11.0.0 + remark-parse: 11.0.0(supports-color@8.1.1) remark-stringify: 11.0.0 unified: 11.0.5 transitivePeerDependencies: - supports-color - remark-parse@11.0.0: + remark-parse@11.0.0(supports-color@8.1.1): dependencies: '@types/mdast': 4.0.4 - mdast-util-from-markdown: 2.0.2 + mdast-util-from-markdown: 2.0.2(supports-color@8.1.1) micromark-util-types: 2.0.2 unified: 11.0.5 transitivePeerDependencies: @@ -6376,6 +7144,28 @@ snapshots: reusify@1.1.0: {} + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -6413,7 +7203,7 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 ajv: 8.17.1 - ajv-formats: 2.1.1(ajv@8.17.1) + ajv-formats: 2.1.1 ajv-keywords: 5.1.0(ajv@8.17.1) semver@6.3.1: {} @@ -6514,6 +7304,8 @@ snapshots: source-map-js@1.2.1: {} + source-map-js@1.2.2: {} + source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 @@ -6525,6 +7317,8 @@ snapshots: stable-hash@0.0.5: {} + std-env@4.3.0: {} + stop-iteration-iterator@1.1.0: dependencies: es-errors: 1.3.0 @@ -6597,12 +7391,12 @@ snapshots: dependencies: inline-style-parser: 0.2.7 - styled-jsx@5.1.6(@babel/core@7.28.5)(react@19.2.0): + styled-jsx@5.1.6(@babel/core@7.28.5(supports-color@8.1.1))(react@19.2.0): dependencies: client-only: 0.0.1 react: 19.2.0 optionalDependencies: - '@babel/core': 7.28.5 + '@babel/core': 7.28.5(supports-color@8.1.1) supports-color@7.2.0: dependencies: @@ -6636,11 +7430,20 @@ snapshots: commander: 2.20.3 source-map-support: 0.5.21 + tinybench@6.2.3: {} + + tinyexec@1.3.1: {} + tinyglobby@0.2.15: dependencies: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -6701,13 +7504,13 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript-eslint@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3): + typescript-eslint@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.47.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - '@typescript-eslint/typescript-estree': 8.47.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1))(typescript@5.9.3) - eslint: 9.39.1(jiti@2.6.1) + '@typescript-eslint/eslint-plugin': 8.47.0(@typescript-eslint/parser@8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3))(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + '@typescript-eslint/parser': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.47.0(supports-color@8.1.1)(typescript@5.9.3) + '@typescript-eslint/utils': 8.47.0(eslint@9.39.1(jiti@2.6.1)(supports-color@8.1.1))(supports-color@8.1.1)(typescript@5.9.3) + eslint: 9.39.1(jiti@2.6.1)(supports-color@8.1.1) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -6815,6 +7618,41 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 + vite@8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.33 + rolldown: 1.2.19 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 20.19.25 + fsevents: 2.3.3 + jiti: 2.6.1 + terser: 5.44.1 + + vitest@5.1.0(@types/node@20.19.25)(happy-dom@21.0.4)(vite@8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1)): + dependencies: + '@types/chai': 5.2.3 + '@vitest/mocker': 5.1.0(vite@8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1)) + chai: 6.3.0 + es-module-lexer: 2.3.2 + expect-type: 1.4.0 + magic-string: 1.4.5 + obug: 3.0.0 + picomatch: 4.0.7 + std-env: 4.3.0 + tinybench: 6.2.3 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + vite: 8.3.8(@types/node@20.19.25)(jiti@2.6.1)(terser@5.44.1) + why-is-node-running: 3.2.1 + optionalDependencies: + '@types/node': 20.19.25 + happy-dom: 21.0.4 + transitivePeerDependencies: + - msw + watchpack@2.4.4: dependencies: glob-to-regexp: 0.4.1 @@ -6854,6 +7692,8 @@ snapshots: - esbuild - uglify-js + whatwg-mimetype@3.0.0: {} + which-boxed-primitive@1.1.1: dependencies: is-bigint: 1.1.0 @@ -6899,8 +7739,12 @@ snapshots: dependencies: isexe: 2.0.0 + why-is-node-running@3.2.1: {} + word-wrap@1.2.5: {} + ws@8.23.0: {} + yallist@3.1.1: {} yocto-queue@0.1.0: {} diff --git a/services/webSearch.test.ts b/services/webSearch.test.ts new file mode 100644 index 0000000..f4f60b1 --- /dev/null +++ b/services/webSearch.test.ts @@ -0,0 +1,166 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import type { SearchConfig, SearchResultMetadata } from './webSearch'; + +// O backend Rust (Tauri) vira um fake: nenhum motor de busca real é chamado. +const invokeMock = vi.hoisted(() => vi.fn()); +vi.mock('@tauri-apps/api/core', () => ({ invoke: invokeMock })); + +const META: SearchResultMetadata = { title: 'T', url: 'https://ex.com/a', snippet: 's' }; +const ENGINES = ['google', 'bing', 'yahoo', 'duckduckgo', 'startpage']; + +// O serviço é um singleton com circuit breaker e cache de falhas: módulo novo por teste. +async function load() { + vi.resetModules(); + const { webSearchService } = await import('./webSearch'); + const { useSettingsStore } = await import('@/store/settings-store'); + const { EngineCircuitBreaker } = await import('./engine-circuit-breaker'); + const { FailureCache } = await import('./failure-cache'); + return { svc: webSearchService, store: useSettingsStore, EngineCircuitBreaker, FailureCache }; +} + +function backend(metadata: () => Promise) { + invokeMock.mockImplementation(async (cmd: string) => { + if (cmd === 'search_web_metadata') return metadata(); + if (cmd === 'scrape_urls') return []; + throw new Error(`comando inesperado: ${cmd}`); + }); +} + +const metadataCalls = () => invokeMock.mock.calls.filter(([cmd]) => cmd === 'search_web_metadata'); + +describe('executeMetadataSearch (via smartSearchRag)', () => { + beforeEach(() => { + invokeMock.mockReset(); + localStorage.clear(); // o persist do zustand reidrataria settings de outro teste + for (const level of ['log', 'warn', 'error'] as const) vi.spyOn(console, level).mockImplementation(() => {}); + }); + + it('backend devolve metadados: repassa a query aparada, limite e ordem de motores', async () => { + const { svc } = await load(); + backend(async () => [META]); + const r = await svc.smartSearchRag(' rust ', 1); + expect(r.metadata).toEqual([META]); + expect(metadataCalls()[0][1]).toEqual({ query: 'rust', limit: 5, search_config: undefined, engineOrder: ENGINES }); + }); + + it('query com falha recente e resultados parciais: devolve os parciais sem chamar o backend', async () => { + const { svc, FailureCache } = await load(); + vi.spyOn(FailureCache.prototype, 'get').mockReturnValue({ query: 'q', timestamp: Date.now(), error: 'x', partialResults: [META], attempts: 1 }); + backend(async () => []); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([META]); + expect(metadataCalls()).toHaveLength(0); + }); + + it('query com falha recente sem parciais: vazio sem chamar o backend', async () => { + const { svc, FailureCache } = await load(); + vi.spyOn(FailureCache.prototype, 'get').mockReturnValue({ query: 'q', timestamp: Date.now(), error: 'x', partialResults: [], attempts: 1 }); + backend(async () => [META]); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([]); + expect(metadataCalls()).toHaveLength(0); + }); + + it('settings sem engineOrder: usa a ordem padrão de motores', async () => { + const { svc, store } = await load(); + store.setState({ webSearch: { ...store.getState().webSearch, engineOrder: undefined as unknown as string[] } }); + backend(async () => [META]); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()[0][1]).toMatchObject({ engineOrder: ENGINES }); + }); + + it('todos os motores com circuit breaker aberto: tenta todos mesmo assim', async () => { + const { svc, EngineCircuitBreaker } = await load(); + vi.spyOn(EngineCircuitBreaker.prototype, 'getAvailableEngines').mockReturnValue([]); + backend(async () => [META]); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()[0][1]).toMatchObject({ engineOrder: ENGINES }); + }); + + it('motor com circuit breaker aberto: sai da lista enviada ao backend', async () => { + const { svc, EngineCircuitBreaker } = await load(); + vi.spyOn(EngineCircuitBreaker.prototype, 'getAvailableEngines').mockReturnValue(['bing']); + backend(async () => [META]); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()[0][1]).toMatchObject({ engineOrder: ['bing'] }); + }); + + it('com SearchConfig: converte para o formato snake_case do Rust', async () => { + const { svc } = await load(); + backend(async () => [META]); + const config: SearchConfig = { + maxConcurrentTabs: 2, + totalSourcesLimit: 7, + categories: [{ id: 'c', name: 'Cat', baseSites: ['a.com'], enabled: true }], + userCustomSites: ['b.com'], + excludedDomains: ['x.com'], + }; + await svc.smartSearchRag('q', 1, config); + expect(metadataCalls()[0][1]).toMatchObject({ + search_config: { + max_concurrent_tabs: 2, + total_sources_limit: 7, + categories: [{ id: 'c', name: 'Cat', base_sites: ['a.com'], enabled: true }], + user_custom_sites: ['b.com'], + excluded_domains: ['x.com'], + }, + }); + }); + + it('sucesso: registra acerto só para o primeiro motor', async () => { + const { svc, EngineCircuitBreaker } = await load(); + const record = vi.spyOn(EngineCircuitBreaker.prototype, 'recordAttempt'); + backend(async () => [META]); + await svc.smartSearchRag('q', 1); + expect(record).toHaveBeenCalledTimes(1); + expect(record).toHaveBeenCalledWith('google', true, expect.any(Number)); + }); + + it('sucesso com lista de motores vazia: não registra no circuit breaker', async () => { + const { svc, store, EngineCircuitBreaker } = await load(); + store.setState({ webSearch: { ...store.getState().webSearch, engineOrder: [] } }); + const record = vi.spyOn(EngineCircuitBreaker.prototype, 'recordAttempt'); + backend(async () => [META]); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([META]); + expect(record).not.toHaveBeenCalled(); + }); + + it('erro não recuperável: uma tentativa, falha em todos os motores, vazio e query bloqueada', async () => { + const { svc, EngineCircuitBreaker } = await load(); + const record = vi.spyOn(EngineCircuitBreaker.prototype, 'recordAttempt'); + backend(async () => { throw new Error('permission denied'); }); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([]); + expect(metadataCalls()).toHaveLength(1); + expect(record.mock.calls.map(([engine, ok]) => [engine, ok])).toEqual(ENGINES.map((e) => [e, false])); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()).toHaveLength(1); + }); + + it('erro recuperável: 3 tentativas com backoff, vazio e query bloqueada', async () => { + vi.useFakeTimers(); + try { + const { svc } = await load(); + backend(async () => { throw new Error('network unreachable'); }); + const pending = svc.smartSearchRag('q', 1); + await vi.advanceTimersByTimeAsync(10_000); + expect((await pending).metadata).toEqual([]); + expect(metadataCalls()).toHaveLength(3); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()).toHaveLength(3); + } finally { + vi.useRealTimers(); + } + }); + + it('rejeição que não é Error: tratada como falha e devolve vazio', async () => { + const { svc } = await load(); + backend(() => Promise.reject('boom')); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([]); + }); + + it('backend devolve lista vazia: vazio e sem bloquear a query', async () => { + const { svc } = await load(); + backend(async () => []); + expect((await svc.smartSearchRag('q', 1)).metadata).toEqual([]); + await svc.smartSearchRag('q', 1); + expect(metadataCalls()).toHaveLength(2); + }); +}); diff --git a/vitest.config.mts b/vitest.config.mts new file mode 100644 index 0000000..0435a49 --- /dev/null +++ b/vitest.config.mts @@ -0,0 +1,16 @@ +// vitest em vez de node --test: o código usa imports com alias `@/` (tsconfig paths), +// que o node --test não resolve sem loader próprio. Ver spec 2026-11-16-testes-ciclomaticos-ui, seção 5. +import { fileURLToPath } from 'node:url'; +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + resolve: { + alias: [{ find: /^@\//, replacement: fileURLToPath(new URL('./', import.meta.url)) }], + }, + test: { + include: ['{lib,hooks,services}/**/*.test.ts'], + environment: 'happy-dom', // localStorage para o persist do zustand e DOM para renderHook + restoreMocks: true, + unstubGlobals: true, + }, +});