"use client" import { create } from "zustand" import type { AiChatContext } from "@/lib/ai/chat-context" type AiPanelState = { open: boolean context: AiChatContext openPanel: (context?: Partial) => void closePanel: () => void setContext: (patch: Partial) => void } const DEFAULT_CONTEXT: AiChatContext = { app: "standalone", temporary: true, } export const useAiPanelStore = create((set) => ({ open: false, context: DEFAULT_CONTEXT, openPanel: (patch) => set((s) => ({ open: true, context: { ...s.context, ...patch, temporary: patch?.temporary ?? true }, })), closePanel: () => set({ open: false }), setContext: (patch) => set((s) => ({ context: { ...s.context, ...patch }, })), }))