Foundups commited on
Commit ·
2c2833c
1
Parent(s): 987f893
Switching to React app deployment
Browse filesFiles changed (49)
- package.jsonAdded+48
- public/index.htmlAdded+20
- public/manifest.jsonAdded+25
- src/App.jsAdded+36
- src/Mermaid.jsAdded+212
- src/components/Account.jsAdded+153
- src/components/ChatDialog.jsAdded+114
- src/components/LoadingScreen.jsAdded+10
- src/components/LoadingSpinner.jsAdded+11
- src/components/Login.jsAdded+71
- src/components/LoginScreen.jsAdded+19
- src/components/MainLayout.jsAdded+39
- src/components/Mermaid.jsAdded+104
- src/components/MindMap.cssAdded+114
- src/components/MindMap.jsAdded+522
- src/components/MindmappingTab.jsAdded+402
- src/components/UserProfile.jsAdded+137
- src/components/mindmap/MindMap.jsAdded+138
- src/components/mindmap/MindMapEdge.jsAdded+27
- src/components/mindmap/MindMapEditor.jsAdded+71
- src/components/mindmap/MindMapLayout.jsAdded+32
- src/components/mindmap/MindMapNode.jsAdded+99
- src/components/mindmap/MindMapUtils.jsAdded+90
- src/components/mindmap/formats/MarkdownMindMap.jsAdded+143
- src/components/mindmap/formats/MermaidMindMap.jsAdded+154
- src/components/mindmap/formats/PlantUMLMindMap.jsAdded+177
- src/components/mindmap/formats/ReactFlowMindMap.jsAdded+143
- src/components/mindmap/formats/index.jsAdded+115
- src/components/models/index.jsAdded+106
- src/config/defaults.jsAdded+106
- src/hooks/useAppState.jsAdded+54
- src/index.jsAdded+13
- src/services/api.jsAdded+46
- src/services/auth_service.jsAdded+33
- src/services/firebase.jsAdded+23
- src/services/openai_service.jsAdded+81
- src/services/user_service.jsAdded+53
- src/styles.cssAdded+390
- src/styles/App.cssAdded+540
- src/styles/ChatDialog.cssAdded+174
- src/styles/LoadingScreen.cssAdded+18
- src/styles/LoadingSpinner.cssAdded+25
- src/styles/LoginScreen.cssAdded+34
- src/styles/MainLayout.cssAdded+48
- src/styles/MindMap.cssAdded+353
- src/styles/MindmappingTab.cssAdded+516
- src/styles/UserProfile.cssAdded+194
- src/styles/index.cssAdded+89
- yarn.lockAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748{ "name": "auto-mindmapping", "version": "1.0.1", "description": "", "keywords": [], "main": "src/index.js", "homepage": "https://florian-kalisch.github.io/auto-mindmapping/", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.7.2", "@fortawesome/free-regular-svg-icons": "^6.7.2", "@fortawesome/free-solid-svg-icons": "^6.7.2", "@reactflow/node-resizer": "^2.2.14", "firebase": "^11.2.0", "html2canvas": "^1.4.1", "loader-utils": "3.2.1", "lodash": "^4.17.21", "mermaid": "^11.4.1", "openai": "^4.80.1", "react": "18.2.0", "react-dom": "18.2.0", "react-firebase-hooks": "^5.1.1", "react-icons": "^5.4.0", "react-markdown": "^9.0.3", "react-scripts": "5.0.1", "reactflow": "^11.11.4", "remark-gfm": "^4.0.0" }, "devDependencies": { "@babel/runtime": "7.13.8", "gh-pages": "^5.0.0", "typescript": "4.1.3" }, "scripts": { "predeploy": "yarn run build", "deploy": "gh-pages -d build", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ]}1234567891011121314151617181920<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" /> <meta name="description" content="AI-powered mind mapping tool" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <title>AI Mind Map</title> </head> <body> <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"></div> </body></html>12345678910111213141516171819202122232425{ "short_name": "AI Mind Map", "name": "AI-powered Mind Mapping Tool", "icons": [ { "src": "favicon.ico", "sizes": "64x64 32x32 24x24 16x16", "type": "image/x-icon" }, { "src": "logo192.png", "type": "image/png", "sizes": "192x192" }, { "src": "logo512.png", "type": "image/png", "sizes": "512x512" } ], "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff"} 123456789101112131415161718192021222324252627282930313233343536import React from 'react';import { useAppState } from './hooks/useAppState';import { LoadingScreen } from './components/LoadingScreen';import { LoginScreen } from './components/LoginScreen';import { MainLayout } from './components/MainLayout';import { UserProfile } from './components/UserProfile';import { MindmappingTab } from './components/MindmappingTab';import './styles/App.css';
export default function App() { const appState = useAppState(); const { loading, user } = appState;
if (loading) { return <LoadingScreen />; }
if (!user) { return <LoginScreen />; }
return ( <div className="app"> <header className="app-header"> <div className="title-section"> <div className="title">Foundups AI Mind Map</div> <div className="version">version 0.026</div> </div> <UserProfile /> </header> <main className="app-main"> <MindmappingTab /> </main> </div> );}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212import React from "react";import mermaid from "mermaid";import { library, icon } from "@fortawesome/fontawesome-svg-core";import { fas } from "@fortawesome/free-solid-svg-icons";import { far } from "@fortawesome/free-regular-svg-icons";import html2canvas from "html2canvas";
library.add(fas);library.add(far);
mermaid.initialize({ startOnLoad: true, theme: "default", securityLevel: "loose", fontFamily: "Helvetica Neue", fontColor: "white", themeCSS: ` text, tspan { fill: #fff !important; }
.fa { color: white; }
rect.node-bkg, circle.node-bkg, .node-bkg.node-no-border { fill: #2c3e50 !important; stroke: #2c3e50 !important; }
.node-circle { stroke-width: 2px !important; }
.node-no-border { stroke-width: 0 !important; }
path.edge { stroke: #2c3e50 !important; }
[class^="node-line-"] { stroke: #2c3e50 !important; }
.fa.icon-container { color: inherit !important; font-size: inherit !important; }`});
async function replaceFontAwesomeIconsWithInlineSVGs(mermaidContainer) { const iconElements = Array.from(mermaidContainer.querySelectorAll(".fa"));
for (const iconElement of iconElements) { const iconClass = Array.from(iconElement.classList).find((className) => className.startsWith("fa-") ); const iconName = iconClass.slice(3);
let faIcon = icon({ prefix: "fas", iconName });
if (!faIcon) { let faIcon = icon({ prefix: "far", iconName });
if (!faIcon) { console.error(`Icon with name ${iconName} not found.`); continue; } }
iconElement.parentNode.replaceChild(faIcon.node[0], iconElement); }
return mermaidContainer;}
export default class Mermaid extends React.Component { componentDidMount() { mermaid.contentLoaded(); }
async saveAsPNG(scale = 2) { let mermaidContainer = document.getElementById("mermaidChart"); if (!mermaidContainer) { throw new Error("No Mermaid container element found"); }
mermaidContainer = await replaceFontAwesomeIconsWithInlineSVGs( mermaidContainer );
const clonedMermaidContainer = mermaidContainer.cloneNode(true);
clonedMermaidContainer.style.display = "none"; document.body.appendChild(clonedMermaidContainer);
clonedMermaidContainer.style.transform = `scale(${scale})`; clonedMermaidContainer.style.transformOrigin = "top left"; clonedMermaidContainer.style.display = "block";
html2canvas(clonedMermaidContainer, { scale: 1 }) .then((canvas) => { document.body.removeChild(clonedMermaidContainer);
const png = canvas.toDataURL("image/png"); const a = document.createElement("a"); a.download = "chart.png"; a.href = png; document.body.appendChild(a); a.click(); document.body.removeChild(a); }) .catch((error) => { document.body.removeChild(clonedMermaidContainer); throw new Error("Error generating PNG file: ", error); }); }
async saveAsSVG() { let mermaidContainer = document.getElementById("mermaidChart"); if (!mermaidContainer) { throw new Error("No Mermaid container element found"); }
mermaidContainer = await replaceFontAwesomeIconsWithInlineSVGs( mermaidContainer );
const clonedMermaidContainer = mermaidContainer.cloneNode(true);
// Find all foreignObjects within the clonedMermaidContainer and scale them down const foreignObjects = clonedMermaidContainer.getElementsByTagName( "foreignObject" ); for (let fo of foreignObjects) { let svg = fo.querySelector("svg"); let scale = 0.8; // Change this to scale the SVG elements
// Scale the dimensions and transform the SVG elements let oldWidth = parseFloat(fo.getAttribute("width")); let oldHeight = parseFloat(fo.getAttribute("height")); fo.setAttribute("width", oldWidth * scale + "px"); fo.setAttribute("height", oldHeight * scale + "px");
// Center the SVG elements vertically let yAttribute = parseFloat(fo.getAttribute("y") || "0"); let yOffset = (oldHeight * (1 - scale)) / 2; fo.setAttribute("y", yAttribute + yOffset + "px");
if (svg) { svg.style.transform = `scale(${scale})`; svg.style.transformOrigin = "center"; let div = svg.parentElement; if (div) { div.style.marginTop = parseFloat(div.style.marginTop || "0") * scale + "px"; } } }
clonedMermaidContainer.style.display = "none"; document.body.appendChild(clonedMermaidContainer);
clonedMermaidContainer.style.transformOrigin = "top left"; clonedMermaidContainer.style.display = "block";
try { const svgData = new XMLSerializer().serializeToString( clonedMermaidContainer ); const preface = '<?xml version="1.0" standalone="no"?>\r\n'; const svgBlob = new Blob([preface, svgData], { type: "image/svg+xml;charset=utf-8" }); const svgUrl = URL.createObjectURL(svgBlob);
const downloadLink = document.createElement("a"); downloadLink.href = svgUrl; downloadLink.download = "chart.svg"; document.body.appendChild(downloadLink); downloadLink.click(); document.body.removeChild(downloadLink); document.body.removeChild(clonedMermaidContainer); } catch (error) { document.body.removeChild(clonedMermaidContainer); throw new Error("Error generating SVG file: ", error); } }
constructor(props) { super(props); this.saveAsPNG = this.saveAsPNG.bind(this); }
render() { return ( <> <div className="buttonContainer"> <button onClick={() => this.saveAsPNG()}>Save PNG Image</button> <button onClick={() => this.saveAsSVG()}>Save SVG Image</button> </div> <div id="mermaidChart" className="mermaid"> {this.props.chart} </div> </> ); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import React, { useState, useEffect } from 'react';import { userService } from '../services/user_service';import { Login } from './Login';import { useAuthState } from 'react-firebase-hooks/auth';import { auth } from '../services/firebase';
export function Account({ token, setToken, model, setModel, promptTemplate, setPromptTemplate, maxTokens, setMaxTokens, temperature, setTemperature,}) { const [localTemperature, setLocalTemperature] = useState(String(temperature)); const [user] = useAuthState(auth); const [userTier, setUserTier] = useState('free');
const handlePromptTemplateChange = (e) => { setPromptTemplate(e.target.value); localStorage.setItem("promptTemplate", e.target.value); };
function extractIntFromString(str) { const result = str.match(/\d+/); if (result) { return parseInt(result[0], 10); } else { return 0; } }
function extractFloatFromString(str) { str = str.replace(",", "."); // Replace comma with period as a decimal separator const result = str.match(/^-?(\d+)?(\.\d*)?/); // Match optional digits before and after the decimal point if (result) { return result[0] === "" ? 0 : parseFloat(result[0]); // Return '0' if the input is an empty string } else { return 0; } }
const handleMaxTokensChange = (e) => { let maxTokens = extractIntFromString(e.target.value); setMaxTokens(maxTokens); localStorage.setItem("maxTokens", maxTokens); };
const handleTemperatureChange = (e) => { const input = e.target.value; setLocalTemperature(input);
const parsedTemperature = extractFloatFromString(input); if (!isNaN(parsedTemperature) && input !== "") { setTemperature(parsedTemperature); localStorage.setItem("temperature", parsedTemperature); } };
const handleTemperatureBlur = () => { const parsedTemperature = parseFloat(localTemperature); if (isNaN(parsedTemperature)) { setLocalTemperature(String(temperature)); } else { setLocalTemperature(String(parsedTemperature)); setTemperature(parsedTemperature); localStorage.setItem("temperature", parsedTemperature); } };
const handleUpgradeToPremium = () => { alert('Premium upgrade coming soon! This will remove token limits and add advanced features.'); };
return ( <div className="settings-container"> <div className="auth-section"> <Login /> {user && ( <div className="tier-info"> <h4>Account Tier: {userTier === 'premium' ? 'Premium 🌟' : 'Free'}</h4> {userTier === 'free' && ( <button className="upgrade-btn" onClick={handleUpgradeToPremium} > Upgrade to Premium </button> )} </div> )} </div>
<div className="settings-section"> <div> <label htmlFor="model">Model:</label> <select name="model" id="model" value={model} onChange={(e) => setModel(e.target.value)} > <option value="gpt-4o-mini">gpt-4o-mini</option> <option value="gpt-4o">gpt-4o</option> <option value="gpt-4-turbo">gpt-4-turbo</option> <option value="gpt-4">gpt-4</option> <option value="gpt-3.5-turbo">gpt-3.5-turbo</option> <option value="gpt-4o-2024-08-06">gpt-4o-2024-08-06</option> <option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option> <option value="chatgpt-4o-latest">chatgpt-4o-latest</option> </select> </div>
<div> <label htmlFor="maxTokens">Max tokens:</label> <input type="text" id="maxTokens" name="maxTokens" value={maxTokens} onChange={handleMaxTokensChange} /> </div>
<div> <label htmlFor="temperature">Temperature:</label> <input type="text" id="temperature" name="temperature" value={localTemperature} onChange={handleTemperatureChange} onBlur={handleTemperatureBlur} /> </div>
<div> <label htmlFor="promptTemplate">Prompt Template:</label> <textarea id="promptTemplate" name="promptTemplate" value={promptTemplate} onChange={handlePromptTemplateChange} /> </div> </div> </div> );} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114import React, { useState, useRef, useEffect } from 'react';import '../styles/ChatDialog.css';
function ChatDialog({ onSendMessage, result }) { const [messages, setMessages] = useState([ { role: 'assistant', content: 'Hi! I can help you create and modify mind maps. What would you like to explore?' } ]); const [input, setInput] = useState(''); const [isOpen, setIsOpen] = useState(false); const [isMinimized, setIsMinimized] = useState(false); const messagesEndRef = useRef(null); const inputRef = useRef(null);
const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); };
useEffect(() => { scrollToBottom(); }, [messages]);
useEffect(() => { if (isOpen && !isMinimized) { inputRef.current?.focus(); } }, [isOpen, isMinimized]);
// Add new message when result changes useEffect(() => { if (result) { setMessages(prev => [...prev, { role: 'assistant', content: 'I\'ve updated the mind map. Would you like me to explain any part of it or help you modify it?' }]); } }, [result]);
const handleSubmit = async (e) => { e.preventDefault(); if (!input.trim()) return;
// Add user message const userMessage = { role: 'user', content: input }; setMessages(prev => [...prev, userMessage]); setInput('');
// Send to parent for processing if (onSendMessage) { onSendMessage(input); } };
const toggleMinimize = (e) => { e.stopPropagation(); setIsMinimized(!isMinimized); };
return ( <div className={`chat-dialog ${isOpen ? 'open' : ''} ${isMinimized ? 'minimized' : ''}`}> <div className="chat-header" onClick={toggleMinimize}> <div className="chat-title"> <img src="/logo192.png" alt="AI Assistant" className="chat-logo" /> <span>AI Assistant</span> </div> <div className="chat-controls"> <button className="minimize-button" onClick={toggleMinimize}> {isMinimized ? '▲' : '▼'} </button> <button className="close-button" onClick={() => setIsOpen(false)}> × </button> </div> </div> {!isMinimized && ( <> <div className="messages-container"> {messages.map((message, index) => ( <div key={index} className={`message ${message.role === 'user' ? 'user-message' : 'assistant-message'}`} > {message.role === 'assistant' && ( <img src="/logo192.png" alt="AI" className="message-avatar" /> )} <div className="message-content"> {message.content} </div> </div> ))} <div ref={messagesEndRef} /> </div> <form onSubmit={handleSubmit} className="input-container"> <input ref={inputRef} type="text" value={input} onChange={(e) => setInput(e.target.value)} placeholder="Ask about the mind map..." className="chat-input" /> <button type="submit" className="send-button" disabled={!input.trim()}> Send </button> </form> </> )} </div> );}
export default ChatDialog; 12345678910import React from 'react';import '../styles/LoadingScreen.css';
export function LoadingScreen() { return ( <div className="loading-container"> <div className="loading-spinner">Loading...</div> </div> );} 1234567891011import React from 'react';import '../styles/LoadingSpinner.css';
export default function LoadingSpinner() { return ( <div className="loading-spinner"> <div className="spinner"></div> <span className="spinner-text">Generating...</span> </div> );} 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import React from 'react';import { authService } from '../services/auth_service';import { useAuthState } from 'react-firebase-hooks/auth';import { auth } from '../services/firebase';
export function Login() { const [user, loading, error] = useAuthState(auth);
const handleGoogleSignIn = async () => { try { await authService.signInWithGoogle(); } catch (error) { console.error('Login failed:', error); } };
const handleSignOut = async () => { try { await authService.signOut(); } catch (error) { console.error('Logout failed:', error); } };
if (loading) { return ( <div className="login-container"> <p>Loading...</p> </div> ); }
if (error) { return ( <div className="login-container"> <p>Error: {error.message}</p> </div> ); }
return ( <div className="login-container"> {user ? ( <div className="user-info"> <img src={user.photoURL} alt={user.displayName} className="user-avatar" /> <div className="user-details"> <p className="user-name">{user.displayName}</p> <p className="user-email">{user.email}</p> <button onClick={handleSignOut} className="sign-out-btn" > Sign Out </button> </div> </div> ) : ( <button onClick={handleGoogleSignIn} className="google-sign-in-btn" > Sign in with Google </button> )} </div> );} 12345678910111213141516171819import React from 'react';import { Login } from './Login';import '../styles/LoginScreen.css';
export function LoginScreen() { return ( <div className="app-container"> <header className="app-header"> <div className="title-section"> <h1 className="title">Foundups AI Mind Map</h1> <div className="version">version 0.035</div> </div> </header> <main className="login-container"> <Login /> </main> </div> );} 123456789101112131415161718192021222324252627282930313233343536373839import React from 'react';import { UserProfile } from './UserProfile';import { MindmappingTab } from './MindmappingTab';import '../styles/MainLayout.css';
export function MainLayout({ appState }) { const { prompt, setPrompt, result, setResult, model, setModel, maxTokens, setMaxTokens, temperature, setTemperature, promptTemplate, setPromptTemplate, canMakeApiCalls } = appState;
return ( <div className="app"> <header className="app-header"> <div className="title-section"> <div className="title">Foundups AI Mind Map</div> <div className="version">version 0.026</div> </div> <UserProfile /> </header> <main className="app-main"> <MindmappingTab /> </main> </div> );}
export default MainLayout; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104import React, { useEffect, useState } from 'react';import mermaid from 'mermaid';
// Initialize mermaid with minimal configurationmermaid.initialize({ startOnLoad: false, securityLevel: 'loose', theme: 'dark', mindmap: { padding: 16, useMaxWidth: true }, themeVariables: { 'mindmapBranchColor': '#fff', 'mindmapBranchLabelColor': '#fff', 'mindmapNodeBorderColor': '#fff', 'mindmapNodeBackgroundColor': '#333', 'mindmapNodeTextColor': '#fff' }});
function Mermaid({ chart }) { const [error, setError] = useState(''); const [debugInfo, setDebugInfo] = useState(''); const [copySuccess, setCopySuccess] = useState(false);
const handleCopyDebug = async () => { try { await navigator.clipboard.writeText(debugInfo); setCopySuccess(true); setTimeout(() => setCopySuccess(false), 2000); } catch (err) { console.error('Failed to copy text:', err); } };
useEffect(() => { const renderChart = async () => { if (!chart) return;
try { const element = document.querySelector("#mindmap"); element.removeAttribute("data-processed"); // Process the chart content let processedChart = chart.trim(); setDebugInfo('Original chart content:\n' + processedChart); // Add mindmap prefix if missing if (!processedChart.startsWith('mindmap')) { processedChart = 'mindmap\n' + processedChart; }
// Replace escaped tabs with actual tabs processedChart = processedChart.replace(/\\t/g, '\t'); // Fix icon syntax processedChart = processedChart.replace(/::icon\(fafa /g, '::icon(fa fa '); setDebugInfo(prev => prev + '\n\nProcessed chart content:\n' + processedChart); // Set content and render element.innerHTML = processedChart; await mermaid.init(undefined, "#mindmap"); setError(''); } catch (err) { console.error("Error rendering mermaid chart:", err); setError('Syntax error in graph'); setDebugInfo(prev => prev + '\n\nError: ' + err.message); } };
renderChart(); }, [chart]);
return ( <div className="mermaid-wrapper"> {error && ( <div className="mermaid-error"> <div className="error-icon">⚠️</div> <div className="error-content"> <div className="error-title">{error}</div> <div className="error-subtitle">mermaid version 9.3.0</div> <details className="debug-details"> <summary className="debug-header"> Debug Information <button className="copy-btn" onClick={handleCopyDebug} > {copySuccess ? 'Copied!' : 'Copy'} </button> </summary> <pre className="debug-info">{debugInfo}</pre> </details> </div> </div> )} {!error && <div id="mindmap" className="mermaid">{chart}</div>} </div> );}
export default Mermaid; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114.mindmap-wrapper { background: #1a1a1a; padding: 20px; border-radius: 8px; margin-top: 20px; overflow-x: auto; position: relative;}
.node-edit-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #2c3e50; padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); z-index: 1000; min-width: 300px;}
.node-edit-modal textarea { width: 100%; min-height: 100px; background: #34495e; color: #ecf0f1; border: 1px solid #3498db; border-radius: 4px; padding: 8px; margin-bottom: 12px; font-size: 14px; resize: vertical;}
.node-edit-modal .edit-buttons { display: flex; justify-content: flex-end; gap: 8px;}
.node-edit-modal button { background: #3498db; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; transition: background-color 0.2s;}
.node-edit-modal button:hover { background: #2980b9;}
.node-edit-modal button:last-child { background: #e74c3c;}
.node-edit-modal button:last-child:hover { background: #c0392b;}
.react-flow__node { transition: all 0.2s ease;}
.react-flow__node:hover { box-shadow: 0 0 0 2px #3498db;}
.react-flow__edge { transition: stroke 0.2s ease;}
.react-flow__edge:hover { stroke: #3498db !important; stroke-width: 3px !important;}
.react-flow__edge-path { stroke: #95a5a6; stroke-width: 2px;}
.react-flow__controls { background: #2c3e50; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); padding: 4px;}
.react-flow__controls button { background: #34495e; border: none; color: #ecf0f1; margin: 2px;}
.react-flow__controls button:hover { background: #3498db;}
.react-flow__minimap { background: #2c3e50; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);}
.react-flow__attribution { background: transparent; color: #95a5a6;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522import React, { useCallback, useEffect, useState } from 'react';import ReactFlow, { MiniMap, Controls, Background, useNodesState, useEdgesState, MarkerType, Position, Handle,} from 'reactflow';import 'reactflow/dist/style.css';
const SHAPES = { RECTANGLE: 'rectangle', CIRCLE: 'circle', DIAMOND: 'diamond', HEXAGON: 'hexagon', PARALLELOGRAM: 'parallelogram',};
const getNodeStyle = (type, shape = SHAPES.RECTANGLE, isRoot = false, isExpanded = false) => { const baseStyle = { color: '#fff', fontSize: '14px', fontFamily: 'Arial, sans-serif', padding: '12px 20px', textAlign: 'center', boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)', minWidth: '150px', cursor: 'pointer', position: 'relative', };
if (isRoot) { return { ...baseStyle, background: '#2c3e50', border: '3px solid #f1c40f', borderRadius: shape === SHAPES.CIRCLE ? '50%' : '8px', fontSize: '16px', fontWeight: 'bold', padding: '20px', minWidth: '200px', boxShadow: '0 0 20px rgba(241, 196, 15, 0.3)', ...(shape === SHAPES.DIAMOND && { transform: 'rotate(45deg)', '& .node-content': { transform: 'rotate(-45deg)', }, }), ...(shape === SHAPES.HEXAGON && { clipPath: 'polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)', }), ...(shape === SHAPES.PARALLELOGRAM && { transform: 'skew(-20deg)', '& .node-content': { transform: 'skew(20deg)', }, }), }; }
const expandedStyle = isExpanded ? { border: '2px solid #f1c40f', boxShadow: '0 0 10px rgba(241, 196, 15, 0.2)', } : {};
const shapeStyles = { [SHAPES.CIRCLE]: { borderRadius: '50%', aspectRatio: '1', display: 'flex', alignItems: 'center', justifyContent: 'center', }, [SHAPES.DIAMOND]: { transform: 'rotate(45deg)', '& .node-content': { transform: 'rotate(-45deg)', }, }, [SHAPES.HEXAGON]: { clipPath: 'polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)', }, [SHAPES.PARALLELOGRAM]: { transform: 'skew(-20deg)', '& .node-content': { transform: 'skew(20deg)', }, }, };
const typeStyles = { decision: { background: '#8e44ad', border: '2px solid #9b59b6', }, process: { background: '#2980b9', border: '2px solid #3498db', }, input: { background: '#27ae60', border: '2px solid #2ecc71', }, output: { background: '#c0392b', border: '2px solid #e74c3c', }, user: { background: '#d35400', border: '2px solid #e67e22', }, default: { background: '#2c3e50', border: '2px solid #3498db', }, };
return { ...baseStyle, ...typeStyles[type] || typeStyles.default, ...shapeStyles[shape] || {}, ...expandedStyle, };};
// Custom Node Componentconst CustomNode = ({ data, isConnectable }) => { return ( <> <Handle type="target" position={Position.Top} isConnectable={isConnectable} /> <Handle type="target" position={Position.Left} isConnectable={isConnectable} /> <div className="node-content"> {data.label} {data.icon && <i className={data.icon} style={{ marginLeft: '8px' }} />} </div> <Handle type="source" position={Position.Right} isConnectable={isConnectable} /> <Handle type="source" position={Position.Bottom} isConnectable={isConnectable} /> </> );};
const edgeDefaults = { type: 'smoothstep', animated: true, style: { stroke: '#3498db', strokeWidth: 2, }, markerEnd: { type: MarkerType.ArrowClosed, width: 20, height: 20, color: '#3498db', },};
// Constants for layoutconst SPACING = { X: 250, // Horizontal spacing between nodes Y: 100, // Vertical spacing between siblings};
const LINE_TYPES = { SMOOTHSTEP: 'smoothstep', STRAIGHT: 'straight', BEZIER: 'bezier'};
const SNAP_GRID = [20, 20];
function MindMap({ chart }) { const [nodes, setNodes, onNodesChange] = useNodesState([]); const [edges, setEdges, onEdgesChange] = useEdgesState([]); const [error, setError] = useState(''); const [debugInfo, setDebugInfo] = useState(''); const [expandedNodes, setExpandedNodes] = useState(new Set(['node-0'])); const [allNodes, setAllNodes] = useState([]); const [allEdges, setAllEdges] = useState([]); const [nodeShapes, setNodeShapes] = useState({}); const [edgeTypes, setEdgeTypes] = useState({}); const [isEditing, setIsEditing] = useState(false); const [editingNode, setEditingNode] = useState(null); const [editValue, setEditValue] = useState('');
const handleNodeClick = (event, node) => { if (event.button === 2) { // Right click event.preventDefault(); const currentShape = nodeShapes[node.id] || SHAPES.RECTANGLE; const shapes = Object.values(SHAPES); const nextShapeIndex = (shapes.indexOf(currentShape) + 1) % shapes.length; setNodeShapes(prev => ({ ...prev, [node.id]: shapes[nextShapeIndex] })); } else { const nodeId = node.id; setExpandedNodes(prev => { const newExpanded = new Set(prev); if (newExpanded.has(nodeId)) { // Collapse: remove this node and all its descendants const descendants = getDescendants(nodeId); descendants.forEach(id => newExpanded.delete(id)); } else { // Expand: add just this node newExpanded.add(nodeId); } return newExpanded; }); } };
const getDescendants = (nodeId) => { const descendants = new Set(); const stack = [nodeId]; while (stack.length > 0) { const current = stack.pop(); descendants.add(current); // Find all edges where this node is the source allEdges.forEach(edge => { if (edge.source === current) { stack.push(edge.target); } }); } return descendants; };
const getNodeType = (content) => { if (content.includes('{"') && content.includes('"}')) return 'decision'; if (content.includes('["') && content.includes('"]')) return 'process'; if (content.includes('<"') && content.includes('">')) return 'input'; if (content.includes('|"') && content.includes('"|')) return 'user'; if (content.includes('(("') && content.includes('"))')) return 'root'; if (content.includes('("') && content.includes('")')) return 'output'; return 'default'; };
const calculateNodePosition = (level, index, totalAtLevel) => { const x = level * SPACING.X; const totalHeight = (totalAtLevel - 1) * SPACING.Y; const y = (index * SPACING.Y) - (totalHeight / 2); return { x, y }; };
const processChart = useCallback((content) => { if (!content) return { nodes: [], edges: [] };
try { setDebugInfo('Original chart content:\n' + content);
const lines = content.split('\n').filter(line => line.trim() && line.trim() !== 'mindmap'); const nodes = []; const edges = []; let currentNodeId = 0; let lastNodeAtLevel = {}; // First pass: count nodes at each level const nodesPerLevel = {}; lines.forEach(line => { const level = (line.match(/^[\t\s]*/)[0].length / 2) || 0; nodesPerLevel[level] = (nodesPerLevel[level] || 0) + 1; });
// Track nodes added at each level const nodesAddedAtLevel = {};
lines.forEach((line) => { const indentMatch = line.match(/^[\t\s]*/); const level = indentMatch ? indentMatch[0].length / 2 : 0;
const contentMatch = line.match(/(\(\(".*?"\)\))|(\[".*?"\])|(\{".*?"\})|(<".*?">)|(\|".*?"\|)|(\(".*?"\))/); if (!contentMatch) return;
const content = contentMatch[0]; const nodeType = getNodeType(content); const hasIcon = line.includes('::icon');
let icon = ''; if (hasIcon) { const iconMatch = line.match(/::icon\((.*?)\)/); if (iconMatch) { icon = iconMatch[1].replace('fafa', 'fa fa'); } }
nodesAddedAtLevel[level] = (nodesAddedAtLevel[level] || 0); const position = calculateNodePosition( level, nodesAddedAtLevel[level], nodesPerLevel[level] );
const nodeId = `node-${currentNodeId}`; const node = { id: nodeId, type: 'custom', data: { label: content.replace(/[[\](){}|<>"]/g, ''), icon: icon, level: level, type: nodeType }, position: position, style: getNodeStyle( nodeType, nodeShapes[nodeId] || SHAPES.RECTANGLE, level === 0, expandedNodes.has(nodeId) ), };
nodes.push(node);
if (level > 0 && lastNodeAtLevel[level - 1] !== undefined) { edges.push({ id: `edge-${currentNodeId}`, source: lastNodeAtLevel[level - 1], target: node.id, ...edgeDefaults, }); }
lastNodeAtLevel[level] = node.id; nodesAddedAtLevel[level]++; currentNodeId++; });
setAllNodes(nodes); setAllEdges(edges);
// Filter nodes and edges based on expanded state const visibleNodes = nodes.filter(node => { if (node.data.level === 0) return true; const parentEdge = edges.find(edge => edge.target === node.id); return parentEdge && expandedNodes.has(parentEdge.source); });
const visibleEdges = edges.filter(edge => visibleNodes.some(n => n.id === edge.source) && visibleNodes.some(n => n.id === edge.target) );
return { nodes: visibleNodes, edges: visibleEdges }; } catch (err) { console.error('Error processing chart:', err); setError('Error processing mindmap structure'); setDebugInfo(prev => prev + '\n\nError: ' + err.message); return { nodes: [], edges: [] }; } }, [expandedNodes, nodeShapes]);
useEffect(() => { if (!chart) return;
const { nodes, edges } = processChart(chart); setNodes(nodes); setEdges(edges); }, [chart, processChart, setNodes, setEdges]);
const nodeTypes = { custom: CustomNode, };
const handleNodeDoubleClick = (event, node) => { event.preventDefault(); setEditingNode(node); setEditValue(node.data.label); setIsEditing(true); };
const handleEdgeContextMenu = (event, edge) => { event.preventDefault(); const currentType = edgeTypes[edge.id] || LINE_TYPES.SMOOTHSTEP; const types = Object.values(LINE_TYPES); const nextTypeIndex = (types.indexOf(currentType) + 1) % types.length; setEdgeTypes(prev => ({ ...prev, [edge.id]: types[nextTypeIndex] })); };
const handleEditSave = () => { if (!editingNode) return; setNodes(nds => nds.map(n => { if (n.id === editingNode.id) { return { ...n, data: { ...n.data, label: editValue } }; } return n; }) ); setIsEditing(false); setEditingNode(null); setEditValue(''); };
const handleNodeDragStop = (event, node) => { const newX = Math.round(node.position.x / SNAP_GRID[0]) * SNAP_GRID[0]; const newY = Math.round(node.position.y / SNAP_GRID[1]) * SNAP_GRID[1]; setNodes(nds => nds.map(n => { if (n.id === node.id) { return { ...n, position: { x: newX, y: newY } }; } return n; }) ); };
// Update edge defaults to include type from edgeTypes state const getEdgeStyle = (edge) => ({ ...edgeDefaults, type: edgeTypes[edge.id] || LINE_TYPES.SMOOTHSTEP, });
return ( <div className="mindmap-wrapper" onContextMenu={e => e.preventDefault()}> {error ? ( <div className="mindmap-error"> <div className="error-icon">⚠️</div> <div className="error-content"> <div className="error-title">{error}</div> <div className="error-subtitle">React Flow mindmap</div> <details className="debug-details"> <summary className="debug-header"> Debug Information </summary> <pre className="debug-info">{debugInfo}</pre> </details> </div> </div> ) : ( <div style={{ width: '100%', height: '600px' }}> <ReactFlow nodes={nodes} edges={edges.map(edge => ({ ...edge, ...getEdgeStyle(edge) }))} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onNodeClick={handleNodeClick} onNodeDoubleClick={handleNodeDoubleClick} onNodeDragStop={handleNodeDragStop} onEdgeContextMenu={handleEdgeContextMenu} nodeTypes={nodeTypes} snapToGrid={true} snapGrid={SNAP_GRID} fitView minZoom={0.1} maxZoom={1.5} defaultZoom={0.8} attributionPosition="bottom-left" > <Controls showInteractive={false} /> <MiniMap nodeColor={node => node.style?.background || '#2c3e50'} maskColor="rgba(0, 0, 0, 0.2)" /> <Background color="#34495e" gap={16} size={1} /> </ReactFlow>
{isEditing && editingNode && ( <div className="node-edit-modal"> <textarea value={editValue} onChange={(e) => setEditValue(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleEditSave(); } }} autoFocus /> <div className="edit-buttons"> <button onClick={handleEditSave}>Save</button> <button onClick={() => { setIsEditing(false); setEditingNode(null); setEditValue(''); }}>Cancel</button> </div> </div> )} </div> )} </div> );}
export default MindMap; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402import React, { useState, useCallback, useEffect, useRef } from 'react';import PropTypes from 'prop-types';import { debounce } from 'lodash';import ChatDialog from './ChatDialog';import LoadingSpinner from './LoadingSpinner';import { FiDownload, FiZoomIn, FiZoomOut, FiRotateCcw, FiHelpCircle, FiSettings, FiCopy, FiChevronUp, FiChevronDown } from 'react-icons/fi';import { MINDMAP_FORMATS } from './mindmap/formats';import { AI_MODELS } from './models';import '../styles/MindmappingTab.css';import { generateMindMap } from '../services/api';
const TEMPLATES = { BRAINSTORM: { name: 'Brainstorming', prompt: 'Create a detailed mind map for brainstorming ideas about: ', style: 'creative and expansive' }, PLANNING: { name: 'Project Planning', prompt: 'Create a structured mind map for planning all aspects of: ', style: 'organized and hierarchical' }, ANALYSIS: { name: 'Problem Analysis', prompt: 'Create an analytical mind map to break down and solve: ', style: 'logical and systematic' }};
const LOADING_TIMEOUT = 30000; // 30 secondsconst LOCAL_STORAGE_KEY = 'mindmap_preferences';
export function MindmappingTab() { // Load preferences from local storage const loadPreferences = () => { try { const saved = localStorage.getItem(LOCAL_STORAGE_KEY); if (saved) { const prefs = JSON.parse(saved); return { template: prefs.template || 'BRAINSTORM', format: prefs.format || 'REACTFLOW', model: prefs.model || 'GPT4', temperature: prefs.temperature || 0.7, maxTokens: prefs.maxTokens || null }; } } catch (err) { console.error('Error loading preferences:', err); } return null; };
const prefs = loadPreferences(); const [prompt, setPrompt] = useState(''); const [template, setTemplate] = useState(prefs?.template || 'BRAINSTORM'); const [format, setFormat] = useState(prefs?.format || 'REACTFLOW'); const [model, setModel] = useState(prefs?.model || 'GPT4'); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [rawOutput, setRawOutput] = useState(''); const [result, setResult] = useState(''); const [history, setHistory] = useState([]); const [historyIndex, setHistoryIndex] = useState(-1); const [showHelp, setShowHelp] = useState(false); const [showSettings, setShowSettings] = useState(false); const [temperature, setTemperature] = useState(prefs?.temperature || 0.7); const [maxTokens, setMaxTokens] = useState(prefs?.maxTokens || null); const [isOutputCollapsed, setIsOutputCollapsed] = useState(false);
const abortControllerRef = useRef(null); const loadingTimeoutRef = useRef(null);
// Save preferences when they change useEffect(() => { try { localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify({ template, format, model, temperature, maxTokens })); } catch (err) { console.error('Error saving preferences:', err); } }, [template, format, model, temperature, maxTokens]);
// Cleanup on unmount useEffect(() => { return () => { if (abortControllerRef.current) { abortControllerRef.current.abort(); } if (loadingTimeoutRef.current) { clearTimeout(loadingTimeoutRef.current); } }; }, []);
const handleCreate = async () => { if (!prompt.trim()) { setError("Please enter a prompt"); return; }
// Cancel any existing request if (abortControllerRef.current) { abortControllerRef.current.abort(); } abortControllerRef.current = new AbortController();
setIsLoading(true); setError(null); setRawOutput('');
// Set loading timeout loadingTimeoutRef.current = setTimeout(() => { if (abortControllerRef.current) { abortControllerRef.current.abort(); setError('Request timed out. Please try again.'); setIsLoading(false); } }, LOADING_TIMEOUT);
try { const fullPrompt = `${TEMPLATES[template].prompt}${prompt}\n\nStyle: ${TEMPLATES[template].style}`; const data = await generateMindMap( fullPrompt, 'gpt-3.5-turbo', temperature || DEFAULT_TEMPERATURE );
setRawOutput(data.mindmapText); setResult(data.visualization); // Add to history const newHistory = [...history.slice(0, historyIndex + 1), data]; setHistory(newHistory); setHistoryIndex(newHistory.length - 1); } catch (err) { if (err.name === 'AbortError') { setError('Request was cancelled'); } else { setError(`Error: ${err.message}`); } } finally { setIsLoading(false); if (loadingTimeoutRef.current) { clearTimeout(loadingTimeoutRef.current); } } };
const handleUndo = useCallback(() => { if (historyIndex > 0) { setHistoryIndex(historyIndex - 1); const previousState = history[historyIndex - 1]; setRawOutput(previousState.mindmapText); setResult(previousState.visualization); } }, [history, historyIndex]);
const handleRedo = useCallback(() => { if (historyIndex < history.length - 1) { setHistoryIndex(historyIndex + 1); const nextState = history[historyIndex + 1]; setRawOutput(nextState.mindmapText); setResult(nextState.visualization); } }, [history, historyIndex]);
const handleExport = useCallback(() => { if (!rawOutput) return;
try { const blob = new Blob([rawOutput], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `mindmap_${new Date().toISOString()}.txt`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } catch (err) { setError(`Error exporting mind map: ${err.message}`); } }, [rawOutput]);
const handleCopyOutput = useCallback(() => { if (!rawOutput) return; try { navigator.clipboard.writeText(rawOutput); // Could add a toast notification here } catch (err) { setError(`Error copying to clipboard: ${err.message}`); } }, [rawOutput]);
// Debounced settings handlers const debouncedSetTemperature = useCallback( debounce((value) => setTemperature(value), 300), [] );
const debouncedSetMaxTokens = useCallback( debounce((value) => setMaxTokens(value), 300), [] );
const CurrentMindMap = MINDMAP_FORMATS[format].component;
return ( <div className="mindmapping-container"> <div className="toolbar"> <div className="toolbar-selects"> <select value={template} onChange={(e) => setTemplate(e.target.value)} className="template-select" > {Object.entries(TEMPLATES).map(([key, { name }]) => ( <option key={key} value={key}>{name}</option> ))} </select> <select value={format} onChange={(e) => setFormat(e.target.value)} className="format-select" > {Object.entries(MINDMAP_FORMATS).map(([key, { name, description }]) => ( <option key={key} value={key} title={description}> {name} </option> ))} </select> <select value={model} onChange={(e) => setModel(e.target.value)} className="model-select" > {Object.entries(AI_MODELS).map(([key, { name, provider, description }]) => ( <option key={key} value={key} title={description}> {name} ({provider}) </option> ))} </select> </div> <div className="toolbar-buttons"> <button onClick={handleUndo} disabled={historyIndex <= 0} title="Undo"> <FiRotateCcw /> </button> <button onClick={handleRedo} disabled={historyIndex >= history.length - 1} title="Redo"> <FiRotateCcw className="flip-horizontal" /> </button> <button onClick={handleExport} disabled={!rawOutput} title="Export"> <FiDownload /> </button> <button onClick={() => setShowSettings(true)} title="Settings"> <FiSettings /> </button> <button onClick={() => setShowHelp(true)} title="Help"> <FiHelpCircle /> </button> </div> </div>
<div className="input-section"> <textarea value={prompt} onChange={(e) => setPrompt(e.target.value)} placeholder={`Enter your topic for ${TEMPLATES[template].name.toLowerCase()}...`} className="prompt-input" /> <button onClick={handleCreate} disabled={isLoading || !prompt.trim()} className="create-button" > {isLoading ? <LoadingSpinner /> : 'Generate Mind Map'} </button> </div>
{error && ( <div className="error-message"> <div className="error-icon">⚠️</div> <div className="error-content">{error}</div> </div> )}
<div className="output-container"> <div className="output-section"> <div className="output-header"> <h3 className="section-title">Output</h3> <div className="output-controls"> <button className="control-button" onClick={handleCopyOutput} disabled={!rawOutput} title="Copy output" > <FiCopy /> </button> <button className="control-button" onClick={() => setIsOutputCollapsed(!isOutputCollapsed)} title={isOutputCollapsed ? "Expand" : "Collapse"} > {isOutputCollapsed ? <FiChevronDown /> : <FiChevronUp />} </button> </div> </div> {!isOutputCollapsed && ( <div className="output-content"> <pre className="output-text"> {rawOutput || 'No output generated yet. Click "Generate Mind Map" to start.'} </pre> </div> )} </div>
{rawOutput && ( <div className="output-section"> <h3 className="section-title">Mind Map Preview</h3> <div className="mindmap-preview"> <CurrentMindMap content={rawOutput} /> </div> </div> )} </div>
{showSettings && ( <div className="settings-overlay" onClick={() => setShowSettings(false)}> <div className="settings-content" onClick={e => e.stopPropagation()}> <h2>Model Settings</h2> <div className="settings-group"> <label> Temperature <input type="range" min="0" max="1" step="0.1" value={temperature} onChange={(e) => debouncedSetTemperature(parseFloat(e.target.value))} /> <span>{temperature}</span> </label> <label> Max Tokens <input type="number" value={maxTokens || AI_MODELS[model].maxTokens} onChange={(e) => debouncedSetMaxTokens(parseInt(e.target.value))} min="1" max={AI_MODELS[model].maxTokens} /> </label> </div> <div className="settings-info"> <h3>Selected Model: {AI_MODELS[model].name}</h3> <p>Provider: {AI_MODELS[model].provider}</p> <p>{AI_MODELS[model].description}</p> </div> <button onClick={() => setShowSettings(false)}>Close</button> </div> </div> )}
{showHelp && ( <div className="help-overlay" onClick={() => setShowHelp(false)}> <div className="help-content" onClick={e => e.stopPropagation()}> <h2>How to Use the Mind Map Generator</h2> <ol> <li>Select a template type from the dropdown menu</li> <li>Choose your preferred mind map format</li> <li>Select an AI model for generation</li> <li>Enter your topic or question in the text area</li> <li>Click "Generate Mind Map" to create your visualization</li> <li>Use the toolbar to undo/redo changes or export your mind map</li> <li>Click and drag nodes to rearrange them (React Flow format only)</li> <li>Right-click nodes to change their shape (React Flow format only)</li> <li>Double-click nodes to edit their content (React Flow format only)</li> </ol> <button onClick={() => setShowHelp(false)}>Got it!</button> </div> </div> )}
<ChatDialog /> </div> );}
MindmappingTab.propTypes = { // Add props if needed};
export default MindmappingTab; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137import React from 'react';import { useAuthState } from 'react-firebase-hooks/auth';import { auth } from '../services/firebase';import { authService } from '../services/auth_service';import '../styles/UserProfile.css';
export function UserProfile({ model, setModel, maxTokens, setMaxTokens, temperature, setTemperature, promptTemplate, setPromptTemplate}) { const [user] = useAuthState(auth); const [showDropdown, setShowDropdown] = React.useState(false);
const handleSignOut = async () => { try { await authService.signOut(); } catch (error) { console.error('Error signing out:', error); } };
const handleUpgrade = () => { // TODO: Implement upgrade logic console.log('Upgrade clicked'); };
const handleMaxTokensChange = (e) => { const value = e.target.value; setMaxTokens(value); localStorage.setItem("maxTokens", value); };
const handleTemperatureChange = (e) => { const value = e.target.value; setTemperature(value); localStorage.setItem("temperature", value); };
const handlePromptTemplateChange = (e) => { const value = e.target.value; setPromptTemplate(value); localStorage.setItem("promptTemplate", value); };
if (!user) return null;
return ( <div className="user-profile"> <div className="user-info"> <img src={user.photoURL} alt={user.displayName} className="user-avatar" /> <div className="user-details"> <div className="user-name">{user.displayName}</div> <div className="account-type">Free Account</div> </div> <button className="upgrade-button" onClick={handleUpgrade}> Upgrade </button> </div>
{showDropdown && ( <div className="user-dropdown"> <div className="user-details"> <p className="user-email">{user.email}</p> </div>
<div className="settings-section"> <div className="setting-item"> <label htmlFor="model">Model:</label> <select id="model" value={model} onChange={(e) => setModel(e.target.value)} > <option value="gpt-4o-mini">GPT-4 Mini</option> <option value="gpt-4">GPT-4</option> <option value="gpt-4-turbo">GPT-4 Turbo</option> <option value="gpt-3.5-turbo">GPT-3.5 Turbo</option> </select> </div>
<div className="setting-item"> <label htmlFor="maxTokens">Max Tokens:</label> <input id="maxTokens" type="number" value={maxTokens} onChange={handleMaxTokensChange} min="1" max="4000" /> </div>
<div className="setting-item"> <label htmlFor="temperature">Temperature:</label> <input id="temperature" type="number" value={temperature} onChange={handleTemperatureChange} min="0" max="1" step="0.1" /> </div>
<div className="setting-item"> <label htmlFor="promptTemplate">Prompt Template:</label> <textarea id="promptTemplate" value={promptTemplate} onChange={handlePromptTemplateChange} rows="4" /> </div> </div>
<button className="sign-out-btn" onClick={handleSignOut} > Sign Out </button> </div> )} </div> );} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138import React, { useCallback, useEffect, useState } from 'react';import ReactFlow, { MiniMap, Controls, Background, useNodesState, useEdgesState,} from 'reactflow';import 'reactflow/dist/style.css';
import { CustomNode, SHAPES, getNodeStyle } from './MindMapNode';import { LINE_TYPES, getEdgeStyle } from './MindMapEdge';import { SPACING, SNAP_GRID, calculateNodePosition, getDescendants } from './MindMapLayout';import { getNodeType, extractIcon, processChartContent } from './MindMapUtils';import { NodeEditModal, handleNodeDoubleClick, handleEditSave, handleNodeDragStop } from './MindMapEditor';
function MindMap({ chart }) { const [nodes, setNodes, onNodesChange] = useNodesState([]); const [edges, setEdges, onEdgesChange] = useEdgesState([]); const [error, setError] = useState(''); const [debugInfo, setDebugInfo] = useState(''); const [expandedNodes, setExpandedNodes] = useState(new Set(['node-0'])); const [nodeShapes, setNodeShapes] = useState({}); const [edgeTypes, setEdgeTypes] = useState({}); const [isEditing, setIsEditing] = useState(false); const [editingNode, setEditingNode] = useState(null); const [editValue, setEditValue] = useState('');
const handleNodeClick = (event, node) => { if (event.button === 2) { // Right click event.preventDefault(); const currentShape = nodeShapes[node.id] || SHAPES.RECTANGLE; const shapes = Object.values(SHAPES); const nextShapeIndex = (shapes.indexOf(currentShape) + 1) % shapes.length; setNodeShapes(prev => ({ ...prev, [node.id]: shapes[nextShapeIndex] })); } else { const nodeId = node.id; setExpandedNodes(prev => { const newExpanded = new Set(prev); if (newExpanded.has(nodeId)) { const descendants = getDescendants(nodeId, edges); descendants.forEach(id => newExpanded.delete(id)); } else { newExpanded.add(nodeId); } return newExpanded; }); } };
const handleEdgeContextMenu = (event, edge) => { event.preventDefault(); const currentType = edgeTypes[edge.id] || LINE_TYPES.SMOOTHSTEP; const types = Object.values(LINE_TYPES); const nextTypeIndex = (types.indexOf(currentType) + 1) % types.length; setEdgeTypes(prev => ({ ...prev, [edge.id]: types[nextTypeIndex] })); };
useEffect(() => { if (!chart) return; const { nodes: processedNodes, edges: processedEdges } = processChartContent(chart, nodeShapes, expandedNodes); setNodes(processedNodes); setEdges(processedEdges); }, [chart, nodeShapes, expandedNodes, setNodes, setEdges]);
const nodeTypes = { custom: CustomNode, };
return ( <div className="mindmap-wrapper" onContextMenu={e => e.preventDefault()}> {error ? ( <div className="mindmap-error"> <div className="error-icon">⚠️</div> <div className="error-content"> <div className="error-title">{error}</div> <div className="error-subtitle">React Flow mindmap</div> <details className="debug-details"> <summary className="debug-header"> Debug Information </summary> <pre className="debug-info">{debugInfo}</pre> </details> </div> </div> ) : ( <div style={{ width: '100%', height: '600px' }}> <ReactFlow nodes={nodes} edges={edges.map(edge => getEdgeStyle(edge, edgeTypes))} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onNodeClick={handleNodeClick} onNodeDoubleClick={(e, node) => handleNodeDoubleClick(e, node, setEditingNode, setEditValue, setIsEditing)} onNodeDragStop={(e, node) => handleNodeDragStop(e, node, setNodes, SNAP_GRID)} onEdgeContextMenu={handleEdgeContextMenu} nodeTypes={nodeTypes} snapToGrid={true} snapGrid={SNAP_GRID} fitView minZoom={0.1} maxZoom={1.5} defaultZoom={0.8} attributionPosition="bottom-left" > <Controls showInteractive={false} /> <MiniMap nodeColor={node => node.style?.background || '#2c3e50'} maskColor="rgba(0, 0, 0, 0.2)" /> <Background color="#34495e" gap={16} size={1} /> </ReactFlow>
{isEditing && editingNode && ( <NodeEditModal editValue={editValue} setEditValue={setEditValue} handleEditSave={() => handleEditSave(editingNode, editValue, setNodes, setIsEditing, setEditingNode, setEditValue)} handleEditCancel={() => { setIsEditing(false); setEditingNode(null); setEditValue(''); }} /> )} </div> )} </div> );}
export default MindMap; 123456789101112131415161718192021222324252627import { MarkerType } from 'reactflow';
export const LINE_TYPES = { SMOOTHSTEP: 'smoothstep', STRAIGHT: 'straight', BEZIER: 'bezier'};
export const edgeDefaults = { type: 'smoothstep', animated: true, style: { stroke: '#3498db', strokeWidth: 2, }, markerEnd: { type: MarkerType.ArrowClosed, width: 20, height: 20, color: '#3498db', },};
export const getEdgeStyle = (edge, edgeTypes) => ({ ...edgeDefaults, type: edgeTypes[edge.id] || LINE_TYPES.SMOOTHSTEP,}); 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import React from 'react';
export const NodeEditModal = ({ editValue, setEditValue, handleEditSave, handleEditCancel }) => { return ( <div className="node-edit-modal"> <textarea value={editValue} onChange={(e) => setEditValue(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleEditSave(); } }} autoFocus /> <div className="edit-buttons"> <button onClick={handleEditSave}>Save</button> <button onClick={handleEditCancel}>Cancel</button> </div> </div> );};
export const handleNodeDoubleClick = (event, node, setEditingNode, setEditValue, setIsEditing) => { event.preventDefault(); setEditingNode(node); setEditValue(node.data.label); setIsEditing(true);};
export const handleEditSave = (editingNode, editValue, setNodes, setIsEditing, setEditingNode, setEditValue) => { if (!editingNode) return; setNodes(nds => nds.map(n => { if (n.id === editingNode.id) { return { ...n, data: { ...n.data, label: editValue } }; } return n; }) ); setIsEditing(false); setEditingNode(null); setEditValue('');};
export const handleNodeDragStop = (event, node, setNodes, SNAP_GRID) => { const newX = Math.round(node.position.x / SNAP_GRID[0]) * SNAP_GRID[0]; const newY = Math.round(node.position.y / SNAP_GRID[1]) * SNAP_GRID[1]; setNodes(nds => nds.map(n => { if (n.id === node.id) { return { ...n, position: { x: newX, y: newY } }; } return n; }) );}; 1234567891011121314151617181920212223242526272829303132export const SPACING = { X: 250, // Horizontal spacing between nodes Y: 100, // Vertical spacing between siblings};
export const SNAP_GRID = [20, 20];
export const calculateNodePosition = (level, index, totalAtLevel) => { const x = level * SPACING.X; const totalHeight = (totalAtLevel - 1) * SPACING.Y; const y = (index * SPACING.Y) - (totalHeight / 2); return { x, y };};
export const getDescendants = (nodeId, edges) => { const descendants = new Set(); const stack = [nodeId]; while (stack.length > 0) { const current = stack.pop(); descendants.add(current); // Find all edges where this node is the source edges.forEach(edge => { if (edge.source === current) { stack.push(edge.target); } }); } return descendants;}; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899import React from 'react';import { Handle, Position } from 'reactflow';
export const SHAPES = { RECTANGLE: 'rectangle', CIRCLE: 'circle', DIAMOND: 'diamond', HEXAGON: 'hexagon', PARALLELOGRAM: 'parallelogram',};
export const getNodeStyle = (nodeType, shape, isRoot, isExpanded) => { const baseStyle = { padding: '10px 20px', borderRadius: '4px', fontSize: '14px', transition: 'all 0.2s ease', border: '1px solid #3498db', };
// Shape-specific styles switch (shape) { case SHAPES.CIRCLE: return { ...baseStyle, borderRadius: '50%', width: '120px', height: '120px', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '10px', }; case SHAPES.DIAMOND: return { ...baseStyle, transform: 'rotate(45deg)', width: '100px', height: '100px', display: 'flex', alignItems: 'center', justifyContent: 'center', '& > *': { transform: 'rotate(-45deg)', }, }; case SHAPES.HEXAGON: return { ...baseStyle, clipPath: 'polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)', width: '120px', height: '100px', display: 'flex', alignItems: 'center', justifyContent: 'center', }; case SHAPES.PARALLELOGRAM: return { ...baseStyle, transform: 'skew(-20deg)', '& > *': { transform: 'skew(20deg)', }, }; default: return baseStyle; }};
export const CustomNode = ({ data, isConnectable }) => { return ( <> <Handle type="target" position={Position.Top} isConnectable={isConnectable} /> <Handle type="target" position={Position.Left} isConnectable={isConnectable} /> <div className="node-content"> {data.label} {data.icon && <i className={data.icon} style={{ marginLeft: '8px' }} />} </div> <Handle type="source" position={Position.Right} isConnectable={isConnectable} /> <Handle type="source" position={Position.Bottom} isConnectable={isConnectable} /> </> );}; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990export const getNodeType = (content) => { if (content.includes('{"') && content.includes('"}')) return 'decision'; if (content.includes('["') && content.includes('"]')) return 'process'; if (content.includes('<"') && content.includes('">')) return 'input'; if (content.includes('|"') && content.includes('"|')) return 'user'; if (content.includes('(("') && content.includes('"))')) return 'root'; if (content.includes('("') && content.includes('")')) return 'output'; return 'default';};
export const extractIcon = (line) => { if (!line.includes('::icon')) return ''; const iconMatch = line.match(/::icon\((.*?)\)/); return iconMatch ? iconMatch[1].replace('fafa', 'fa fa') : '';};
export const processChartContent = (content, nodeShapes, expandedNodes) => { if (!content) return { nodes: [], edges: [] };
const lines = content.split('\n').filter(line => line.trim() && line.trim() !== 'mindmap'); const nodes = []; const edges = []; let currentNodeId = 0; let lastNodeAtLevel = {}; // First pass: count nodes at each level const nodesPerLevel = {}; lines.forEach(line => { const level = (line.match(/^[\t\s]*/)[0].length / 2) || 0; nodesPerLevel[level] = (nodesPerLevel[level] || 0) + 1; });
// Track nodes added at each level const nodesAddedAtLevel = {};
lines.forEach(line => { const indentMatch = line.match(/^[\t\s]*/); const level = indentMatch ? indentMatch[0].length / 2 : 0;
const contentMatch = line.match(/(\(\(".*?"\)\))|(\[".*?"\])|(\{".*?"\})|(<".*?">)|(\|".*?"\|)|(\(".*?"\))/); if (!contentMatch) return;
const content = contentMatch[0]; const nodeType = getNodeType(content); const icon = extractIcon(line);
nodesAddedAtLevel[level] = (nodesAddedAtLevel[level] || 0); const position = calculateNodePosition( level, nodesAddedAtLevel[level], nodesPerLevel[level] );
const nodeId = `node-${currentNodeId}`; const node = { id: nodeId, type: 'custom', data: { label: content.replace(/[[\](){}|<>"]/g, ''), icon, level, type: nodeType }, position, style: getNodeStyle( nodeType, nodeShapes[nodeId] || SHAPES.RECTANGLE, level === 0, expandedNodes.has(nodeId) ), };
nodes.push(node);
if (level > 0 && lastNodeAtLevel[level - 1] !== undefined) { edges.push({ id: `edge-${currentNodeId}`, source: lastNodeAtLevel[level - 1], target: node.id, ...edgeDefaults, }); }
lastNodeAtLevel[level] = node.id; nodesAddedAtLevel[level]++; currentNodeId++; });
return { nodes, edges };}; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import React, { useState, useEffect } from 'react';import PropTypes from 'prop-types';import ReactMarkdown from 'react-markdown';import remarkGfm from 'remark-gfm';
export const formatToMarkdown = (content) => { if (!content) return ''; try { const lines = content.split('\n') .filter(line => line.trim() && line.trim() !== 'mindmap'); let markdownContent = '# Mind Map\n\n'; let currentLevel = 0; let previousLevel = 0; lines.forEach(line => { const indentMatch = line.match(/^[\t\s]*/); currentLevel = indentMatch ? indentMatch[0].length / 2 : 0; // Add bullet points based on level const indent = ' '.repeat(currentLevel); let processedLine = line.trim(); // Convert node types to markdown syntax if (processedLine.includes('{"') && processedLine.includes('"}')) { processedLine = processedLine.replace(/\{"(.*?)"\}/, '**$1**'); } else if (processedLine.includes('["') && processedLine.includes('"]')) { processedLine = processedLine.replace(/\["(.*?)"\]/, '`$1`'); } else if (processedLine.includes('<"') && processedLine.includes('">')) { processedLine = processedLine.replace(/<"(.*?)">/, '*$1*'); } else if (processedLine.includes('|"') && processedLine.includes('"|')) { processedLine = processedLine.replace(/\|"(.*?)"\|/, '***$1***'); } else if (processedLine.includes('(("') && processedLine.includes('"))')) { processedLine = processedLine.replace(/\(\("(.*?)"\)\)/, '> $1'); } else if (processedLine.includes('("') && processedLine.includes('")')) { processedLine = processedLine.replace(/\("(.*?)"\)/, '~~$1~~'); } // Handle icons if (processedLine.includes('::icon')) { processedLine = processedLine.replace(/::icon\((.*?)\)/, '📎'); } // Add bullet point markdownContent += `${indent}- ${processedLine}\n`; previousLevel = currentLevel; }); return markdownContent; } catch (error) { console.error('Error formatting markdown content:', error); return '# Error\n\nFailed to format mind map content.'; }};
export function MarkdownMindMap({ content }) { const [markdownContent, setMarkdownContent] = useState(''); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { let mounted = true;
const processContent = () => { try { setIsLoading(true); setError(null); const formattedContent = formatToMarkdown(content); if (!formattedContent) { throw new Error('Invalid mind map content'); }
if (mounted) { setMarkdownContent(formattedContent); setIsLoading(false); } } catch (err) { if (mounted) { console.error('Error processing markdown:', err); setError('Failed to process mind map content'); setIsLoading(false); } } };
processContent();
return () => { mounted = false; }; }, [content]);
if (error) { return ( <div className="markdown-error"> <div className="error-icon">⚠️</div> <div className="error-message">{error}</div> </div> ); }
return ( <div className="markdown-mindmap"> {isLoading ? ( <div className="markdown-loading"> <div className="loading-spinner" /> <div className="loading-text">Formatting mind map...</div> </div> ) : ( <div className="markdown-content"> <ReactMarkdown remarkPlugins={[remarkGfm]} components={{ h1: ({ node, ...props }) => ( <h1 className="markdown-title" {...props} /> ), li: ({ node, ...props }) => ( <li className="markdown-item" {...props} /> ), blockquote: ({ node, ...props }) => ( <blockquote className="markdown-quote" {...props} /> ), code: ({ node, ...props }) => ( <code className="markdown-code" {...props} /> ) }} > {markdownContent} </ReactMarkdown> </div> )} </div> );}
MarkdownMindMap.propTypes = { content: PropTypes.string.isRequired,};
export default MarkdownMindMap; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154import React, { useEffect, useRef, useState } from 'react';import PropTypes from 'prop-types';import mermaid from 'mermaid';
// Initialize mermaid with default configtry { mermaid.initialize({ startOnLoad: true, theme: 'default', securityLevel: 'loose', mindmap: { padding: 20, useMaxWidth: true, }, });} catch (error) { console.error('Error initializing mermaid:', error);}
export const formatToMermaid = (content) => { if (!content) return ''; try { const lines = content.split('\n') .filter(line => line.trim() && line.trim() !== 'mindmap'); let mermaidContent = 'mindmap\n'; lines.forEach(line => { const indentMatch = line.match(/^[\t\s]*/); const level = indentMatch ? indentMatch[0].length / 2 : 0; const indent = ' '.repeat(level); // Convert node types to Mermaid syntax let processedLine = line.trim(); if (processedLine.includes('{"') && processedLine.includes('"}')) { processedLine = processedLine.replace(/\{"(.*?)"\}/, '[$1]((diamond))'); } else if (processedLine.includes('["') && processedLine.includes('"]')) { processedLine = processedLine.replace(/\["(.*?)"\]/, '[$1]((square))'); } else if (processedLine.includes('<"') && processedLine.includes('">')) { processedLine = processedLine.replace(/<"(.*?)">/, '[$1]((circle))'); } else if (processedLine.includes('|"') && processedLine.includes('"|')) { processedLine = processedLine.replace(/\|"(.*?)"\|/, '[$1]((hexagon))'); } else if (processedLine.includes('(("') && processedLine.includes('"))')) { processedLine = processedLine.replace(/\(\("(.*?)"\)\)/, '[$1]((stadium))'); } else if (processedLine.includes('("') && processedLine.includes('")')) { processedLine = processedLine.replace(/\("(.*?)"\)/, '[$1]((rounded))'); } // Handle icons if (processedLine.includes('::icon')) { processedLine = processedLine.replace(/::icon\((.*?)\)/, '::$1'); } mermaidContent += `${indent}${processedLine}\n`; }); return mermaidContent; } catch (error) { console.error('Error formatting mermaid content:', error); return ''; // Return empty string on error }};
export function MermaidMindMap({ content }) { const mermaidRef = useRef(null); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { let mounted = true; let renderTimeout;
const renderMermaid = async () => { if (!mermaidRef.current) return;
try { setIsLoading(true); setError(null);
const mermaidContent = formatToMermaid(content); if (!mermaidContent) { throw new Error('Invalid mind map content'); }
// Clear previous content mermaidRef.current.innerHTML = mermaidContent;
// Add a small delay to ensure DOM is updated renderTimeout = setTimeout(async () => { try { await mermaid.contentLoaded(); if (mounted) { setIsLoading(false); } } catch (err) { if (mounted) { console.error('Error rendering mermaid:', err); setError('Failed to render mind map'); setIsLoading(false); } } }, 100); } catch (err) { if (mounted) { console.error('Error processing mermaid content:', err); setError('Failed to process mind map content'); setIsLoading(false); } } };
renderMermaid();
return () => { mounted = false; if (renderTimeout) { clearTimeout(renderTimeout); } if (mermaidRef.current) { mermaidRef.current.innerHTML = ''; } }; }, [content]);
if (error) { return ( <div className="mermaid-error"> <div className="error-icon">⚠️</div> <div className="error-message">{error}</div> </div> ); }
return ( <div className="mermaid-mindmap"> {isLoading && ( <div className="mermaid-loading"> <div className="loading-spinner" /> <div className="loading-text">Rendering mind map...</div> </div> )} <div ref={mermaidRef} className="mermaid"> {formatToMermaid(content)} </div> </div> );}
MermaidMindMap.propTypes = { content: PropTypes.string.isRequired,};
export default MermaidMindMap; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177import React, { useState, useEffect, useCallback } from 'react';import PropTypes from 'prop-types';
const MAX_RETRIES = 3;const RETRY_DELAY = 2000;
export const formatToPlantUML = (content) => { if (!content) return ''; try { const lines = content.split('\n') .filter(line => line.trim() && line.trim() !== 'mindmap'); let plantUMLContent = '@startmindmap\n'; lines.forEach(line => { const indentMatch = line.match(/^[\t\s]*/); const level = indentMatch ? indentMatch[0].length / 2 : 0; const indent = '*'.repeat(level + 1) + ' '; // Convert node types to PlantUML syntax let processedLine = line.trim(); if (processedLine.includes('{"') && processedLine.includes('"}')) { processedLine = processedLine.replace(/\{"(.*?)"\}/, '<&decision-box> $1'); } else if (processedLine.includes('["') && processedLine.includes('"]')) { processedLine = processedLine.replace(/\["(.*?)"\]/, '<&box> $1'); } else if (processedLine.includes('<"') && processedLine.includes('">')) { processedLine = processedLine.replace(/<"(.*?)">/, '<&circle-o> $1'); } else if (processedLine.includes('|"') && processedLine.includes('"|')) { processedLine = processedLine.replace(/\|"(.*?)"\|/, '<&hexagon> $1'); } else if (processedLine.includes('(("') && processedLine.includes('"))')) { processedLine = processedLine.replace(/\(\("(.*?)"\)\)/, '<&star> $1'); } else if (processedLine.includes('("') && processedLine.includes('")')) { processedLine = processedLine.replace(/\("(.*?)"\)/, '<&tag> $1'); } // Handle icons if (processedLine.includes('::icon')) { processedLine = processedLine.replace(/::icon\((.*?)\)/, '<$1>'); } plantUMLContent += `${indent}${processedLine}\n`; }); plantUMLContent += '@endmindmap'; return plantUMLContent; } catch (error) { console.error('Error formatting PlantUML content:', error); return ''; // Return empty string on error }};
export function PlantUMLMindMap({ content }) { const [imageUrl, setImageUrl] = useState(''); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(true); const [retryCount, setRetryCount] = useState(0);
const loadImage = useCallback(async (encodedDiagram, retryAttempt = 0) => { try { setIsLoading(true); setError(null);
const plantUMLContent = formatToPlantUML(content); if (!plantUMLContent) { throw new Error('Invalid mind map content'); }
const plantUMLServer = 'https://www.plantuml.com/plantuml/svg/'; const url = `${plantUMLServer}${encodedDiagram}`;
// Test if the image loads correctly const img = new Image(); img.onload = () => { setImageUrl(url); setIsLoading(false); setRetryCount(0); }; img.onerror = () => { throw new Error('Failed to load PlantUML diagram'); }; img.src = url; } catch (err) { console.error('Error loading PlantUML diagram:', err); if (retryAttempt < MAX_RETRIES) { setTimeout(() => { setRetryCount(retryAttempt + 1); loadImage(encodedDiagram, retryAttempt + 1); }, RETRY_DELAY); } else { setError('Failed to load mind map after multiple attempts'); setIsLoading(false); } } }, [content]);
useEffect(() => { let mounted = true;
const initializePlantUML = async () => { try { const plantUMLContent = formatToPlantUML(content); if (!plantUMLContent) { throw new Error('Invalid mind map content'); }
// Use TextEncoder to encode the PlantUML content const encoder = new TextEncoder(); const data = encoder.encode(plantUMLContent); const encodedDiagram = btoa(String.fromCharCode.apply(null, data));
if (mounted) { loadImage(encodedDiagram); } } catch (err) { if (mounted) { console.error('Error initializing PlantUML:', err); setError('Failed to process mind map content'); setIsLoading(false); } } };
initializePlantUML();
return () => { mounted = false; }; }, [content, loadImage]);
if (error) { return ( <div className="plantuml-error"> <div className="error-icon">⚠️</div> <div className="error-message">{error}</div> {retryCount > 0 && ( <div className="retry-message"> Retry attempt {retryCount} of {MAX_RETRIES}... </div> )} </div> ); }
return ( <div className="plantuml-mindmap"> {isLoading && ( <div className="plantuml-loading"> <div className="loading-spinner" /> <div className="loading-text"> {retryCount > 0 ? `Retrying... (${retryCount}/${MAX_RETRIES})` : 'Generating mind map...'} </div> </div> )} {imageUrl && ( <img src={imageUrl} alt="Mind Map" style={{ maxWidth: '100%', opacity: isLoading ? 0.5 : 1, transition: 'opacity 0.3s ease' }} /> )} </div> );}
PlantUMLMindMap.propTypes = { content: PropTypes.string.isRequired,};
export default PlantUMLMindMap; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import React, { useState, useCallback, useEffect } from 'react';import ReactFlow, { MiniMap, Controls, Background, useNodesState, useEdgesState,} from 'reactflow';import 'reactflow/dist/style.css';import PropTypes from 'prop-types';
import { CustomNode, SHAPES, getNodeStyle } from '../MindMapNode';import { LINE_TYPES, getEdgeStyle } from '../MindMapEdge';import { SPACING, SNAP_GRID, calculateNodePosition, getDescendants } from '../MindMapLayout';import { getNodeType, extractIcon, processChartContent } from '../MindMapUtils';import { NodeEditModal, handleNodeDoubleClick, handleEditSave, handleNodeDragStop } from '../MindMapEditor';
export function ReactFlowMindMap({ content }) { const [nodes, setNodes, onNodesChange] = useNodesState([]); const [edges, setEdges, onEdgesChange] = useEdgesState([]); const [error, setError] = useState(''); const [debugInfo, setDebugInfo] = useState(''); const [expandedNodes, setExpandedNodes] = useState(new Set(['node-0'])); const [nodeShapes, setNodeShapes] = useState({}); const [edgeTypes, setEdgeTypes] = useState({}); const [isEditing, setIsEditing] = useState(false); const [editingNode, setEditingNode] = useState(null); const [editValue, setEditValue] = useState('');
const handleNodeClick = (event, node) => { if (event.button === 2) { // Right click event.preventDefault(); const currentShape = nodeShapes[node.id] || SHAPES.RECTANGLE; const shapes = Object.values(SHAPES); const nextShapeIndex = (shapes.indexOf(currentShape) + 1) % shapes.length; setNodeShapes(prev => ({ ...prev, [node.id]: shapes[nextShapeIndex] })); } else { const nodeId = node.id; setExpandedNodes(prev => { const newExpanded = new Set(prev); if (newExpanded.has(nodeId)) { const descendants = getDescendants(nodeId, edges); descendants.forEach(id => newExpanded.delete(id)); } else { newExpanded.add(nodeId); } return newExpanded; }); } };
const handleEdgeContextMenu = (event, edge) => { event.preventDefault(); const currentType = edgeTypes[edge.id] || LINE_TYPES.SMOOTHSTEP; const types = Object.values(LINE_TYPES); const nextTypeIndex = (types.indexOf(currentType) + 1) % types.length; setEdgeTypes(prev => ({ ...prev, [edge.id]: types[nextTypeIndex] })); };
useEffect(() => { if (!content) return; const { nodes: processedNodes, edges: processedEdges } = processChartContent(content, nodeShapes, expandedNodes); setNodes(processedNodes); setEdges(processedEdges); }, [content, nodeShapes, expandedNodes, setNodes, setEdges]);
const nodeTypes = { custom: CustomNode, };
return ( <div className="mindmap-wrapper" onContextMenu={e => e.preventDefault()}> {error ? ( <div className="mindmap-error"> <div className="error-icon">⚠️</div> <div className="error-content"> <div className="error-title">{error}</div> <div className="error-subtitle">React Flow mindmap</div> <details className="debug-details"> <summary className="debug-header"> Debug Information </summary> <pre className="debug-info">{debugInfo}</pre> </details> </div> </div> ) : ( <div style={{ width: '100%', height: '600px' }}> <ReactFlow nodes={nodes} edges={edges.map(edge => getEdgeStyle(edge, edgeTypes))} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onNodeClick={handleNodeClick} onNodeDoubleClick={(e, node) => handleNodeDoubleClick(e, node, setEditingNode, setEditValue, setIsEditing)} onNodeDragStop={(e, node) => handleNodeDragStop(e, node, setNodes, SNAP_GRID)} onEdgeContextMenu={handleEdgeContextMenu} nodeTypes={nodeTypes} snapToGrid={true} snapGrid={SNAP_GRID} fitView minZoom={0.1} maxZoom={1.5} defaultZoom={0.8} attributionPosition="bottom-left" > <Controls showInteractive={false} /> <MiniMap nodeColor={node => node.style?.background || '#2c3e50'} maskColor="rgba(0, 0, 0, 0.2)" /> <Background color="#34495e" gap={16} size={1} /> </ReactFlow>
{isEditing && editingNode && ( <NodeEditModal editValue={editValue} setEditValue={setEditValue} handleEditSave={() => handleEditSave(editingNode, editValue, setNodes, setIsEditing, setEditingNode, setEditValue)} handleEditCancel={() => { setIsEditing(false); setEditingNode(null); setEditValue(''); }} /> )} </div> )} </div> );}
ReactFlowMindMap.propTypes = { content: PropTypes.string.isRequired,};
export default ReactFlowMindMap; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115import ReactFlowMindMap from './ReactFlowMindMap';import MermaidMindMap from './MermaidMindMap';import PlantUMLMindMap from './PlantUMLMindMap';import MarkdownMindMap from './MarkdownMindMap';
/** * Available mind map formats with their configurations */export const MINDMAP_FORMATS = { REACTFLOW: { name: 'React Flow', component: ReactFlowMindMap, description: 'Interactive mind map with drag-and-drop support', features: [ 'Drag and drop nodes', 'Interactive editing', 'Node customization', 'Export to PNG' ], isInteractive: true, supportsExport: true, defaultFormat: true }, MERMAID: { name: 'Mermaid', component: MermaidMindMap, description: 'Clean and simple mind map visualization', features: [ 'Clean visualization', 'Simple layout', 'SVG output', 'Light/dark theme support' ], isInteractive: false, supportsExport: true }, PLANTUML: { name: 'PlantUML', component: PlantUMLMindMap, description: 'Professional diagram with UML styling', features: [ 'UML styling', 'Professional look', 'SVG output', 'Multiple themes' ], isInteractive: false, supportsExport: true }, MARKDOWN: { name: 'Markdown', component: MarkdownMindMap, description: 'Simple text-based mind map format', features: [ 'Text-based format', 'Easy to edit', 'Copy/paste support', 'GitHub compatible' ], isInteractive: false, supportsExport: false }};
/** * Get the component for a specific format * @param {string} format - The format identifier * @returns {React.Component} The mind map component */export const getMindMapComponent = (format) => { const formatConfig = MINDMAP_FORMATS[format]; if (!formatConfig) { console.warn(`Unknown format: ${format}, falling back to React Flow`); return MINDMAP_FORMATS.REACTFLOW.component; } return formatConfig.component;};
/** * Get the default format * @returns {string} The default format identifier */export const getDefaultFormat = () => { return Object.keys(MINDMAP_FORMATS).find( key => MINDMAP_FORMATS[key].defaultFormat ) || 'REACTFLOW';};
/** * Check if a format supports exporting * @param {string} format - The format identifier * @returns {boolean} Whether the format supports exporting */export const supportsExport = (format) => { const formatConfig = MINDMAP_FORMATS[format]; return formatConfig ? formatConfig.supportsExport : false;};
/** * Check if a format is interactive * @param {string} format - The format identifier * @returns {boolean} Whether the format is interactive */export const isInteractiveFormat = (format) => { const formatConfig = MINDMAP_FORMATS[format]; return formatConfig ? formatConfig.isInteractive : false;};
export default { MINDMAP_FORMATS, getMindMapComponent, getDefaultFormat, supportsExport, isInteractiveFormat}; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106export const AI_MODELS = { GPT4: { name: 'GPT-4', provider: 'OpenAI', description: 'Most capable GPT model for complex tasks', maxTokens: 8192, temperature: 0.7, apiEndpoint: '/api/generate/gpt4' }, GPT35: { name: 'GPT-3.5 Turbo', provider: 'OpenAI', description: 'Fast and efficient for most tasks', maxTokens: 4096, temperature: 0.7, apiEndpoint: '/api/generate/gpt35' }, CLAUDE2: { name: 'Claude 2', provider: 'Anthropic', description: 'Advanced reasoning and analysis', maxTokens: 100000, temperature: 0.7, apiEndpoint: '/api/generate/claude2' }, CLAUDE3: { name: 'Claude 3', provider: 'Anthropic', description: 'Latest Claude model with enhanced capabilities', maxTokens: 200000, temperature: 0.7, apiEndpoint: '/api/generate/claude3' }, DEEPSEEK: { name: 'DeepSeek Coder', provider: 'DeepSeek', description: 'Specialized in code understanding and generation', maxTokens: 8192, temperature: 0.7, apiEndpoint: '/api/generate/deepseek' }, LLAMA2: { name: 'LLaMA 2 70B', provider: 'Meta', description: 'Open source large language model', maxTokens: 4096, temperature: 0.7, apiEndpoint: '/api/generate/llama2' }, MIXTRAL: { name: 'Mixtral 8x7B', provider: 'Mistral AI', description: 'Powerful mixture-of-experts model', maxTokens: 32768, temperature: 0.7, apiEndpoint: '/api/generate/mixtral' }, GEMINI_PRO: { name: 'Gemini Pro', provider: 'Google', description: 'Google\'s most capable general-purpose model', maxTokens: 32768, temperature: 0.7, apiEndpoint: '/api/generate/gemini' }, GROK1: { name: 'Grok-1', provider: 'xAI', description: 'Real-time knowledge and witty responses', maxTokens: 8192, temperature: 0.7, apiEndpoint: '/api/generate/grok' }, COHERE_COMMAND: { name: 'Command-R', provider: 'Cohere', description: 'Specialized in understanding and generation', maxTokens: 4096, temperature: 0.7, apiEndpoint: '/api/generate/cohere' }, PALM2: { name: 'PaLM 2', provider: 'Google', description: 'Advanced language understanding and generation', maxTokens: 8192, temperature: 0.7, apiEndpoint: '/api/generate/palm2' }, YI: { name: 'Yi-34B', provider: '01.AI', description: 'High-performance bilingual model', maxTokens: 4096, temperature: 0.7, apiEndpoint: '/api/generate/yi' }, QWEN: { name: 'Qwen 72B', provider: 'Alibaba', description: 'Advanced multilingual capabilities', maxTokens: 8192, temperature: 0.7, apiEndpoint: '/api/generate/qwen' }}; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106export const DEFAULT_MODEL = 'GPT4';export const DEFAULT_MAX_TOKENS = 4096;export const DEFAULT_TEMPERATURE = 0.7;export const DEFAULT_PROMPT_TEMPLATE = 'BRAINSTORM';
export const API_ENDPOINTS = { GPT4: '/api/generate/gpt4', GPT35: '/api/generate/gpt35', CLAUDE2: '/api/generate/claude2', CLAUDE3: '/api/generate/claude3', DEEPSEEK: '/api/generate/deepseek', LLAMA2: '/api/generate/llama2', MIXTRAL: '/api/generate/mixtral', GEMINI_PRO: '/api/generate/gemini', GROK1: '/api/generate/grok', COHERE_COMMAND: '/api/generate/cohere', PALM2: '/api/generate/palm2', YI: '/api/generate/yi', QWEN: '/api/generate/qwen'};
export const DEFAULT_PROMPT_TEMPLATE_TEXT = `You are an expert MVP (Minimum Viable Product) planner. Generate a mindmap structure and corresponding React Flow code.
INPUT:- A product or feature idea that needs MVP planning- The idea may be technical or non-technical
OUTPUT:First, show the mindmap structure as text:
[Project Name] (center) | +--[Frontend]-----| | +--[UI]--|--<React.js> | | +--[Complete] | | | +--[Display]--|--<Flow> | +--[Working] | +--[Backend]------| +--[API]--|--<OpenAI> +--[Connected]
Then, generate the React Flow code that implements this structure.
RULES:1. Node Types & Structure: Level 0 (Center): { id: 'center', type: 'mindmap', data: { label: 'Project Name' }, position: { x: 0, y: 0 }, style: { backgroundColor: '#2563eb', color: 'white' } } Level 1 (Main Categories): { id: 'category-1', type: 'mindmap', data: { label: 'Category Name', icon: 'folder' }, position: { x: -200, y: -100 } } Level 2 (Features): { id: 'feature-1', type: 'mindmap', data: { label: 'Feature Name', icon: 'puzzle-piece' }, position: { x: -300, y: -150 } } Level 3 (Implementation): Resource: { id: 'resource-1', type: 'mindmap', data: { label: 'Resource Name', icon: 'cube' } } Milestone: { id: 'milestone-1', type: 'mindmap', data: { label: 'Milestone', icon: 'flag' } }
2. Edge Structure: { id: 'edge-1', source: 'center', target: 'category-1', type: 'smoothstep', animated: true }
Remember: First show the visual text structure of connections, then generate the React Flow code that implements it. Each node must have a unique ID and proper connections. The visual structure should match the code exactly.`; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import { useState } from 'react';import { useAuthState } from 'react-firebase-hooks/auth';import { auth } from '../services/firebase';import { DEFAULT_MODEL, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, DEFAULT_PROMPT_TEMPLATE} from '../config/defaults';
export function useAppState() { const [prompt, setPrompt] = useState(""); const [result, setResult] = useState(""); const [model, setModel] = useState(DEFAULT_MODEL); const [user, loading] = useAuthState(auth);
const [maxTokens, setMaxTokens] = useState( localStorage.getItem("maxTokens") || DEFAULT_MAX_TOKENS );
const [temperature, setTemperature] = useState( localStorage.getItem("temperature") || DEFAULT_TEMPERATURE );
const [promptTemplate, setPromptTemplate] = useState( localStorage.getItem("promptTemplate") || DEFAULT_PROMPT_TEMPLATE );
// Function to check if user can make API calls const canMakeApiCalls = () => { if (!user) { return false; } return !!process.env.REACT_APP_OPENAI_API_KEY; };
return { prompt, setPrompt, result, setResult, model, setModel, user, loading, maxTokens, setMaxTokens, temperature, setTemperature, promptTemplate, setPromptTemplate, canMakeApiCalls };} 12345678910111213import React from 'react';import { createRoot } from 'react-dom/client';import App from './App';import './styles/index.css';
const container = document.getElementById('root');const root = createRoot(container);
root.render( <React.StrictMode> <App /> </React.StrictMode>);12345678910111213141516171819202122232425262728293031323334353637383940414243444546const API_URL = 'https://api.openai.com/v1/chat/completions';
export const generateMindMap = async (prompt, model = 'gpt-3.5-turbo', temperature = 0.7) => { const openaiKey = process.env.REACT_APP_OPENAI_API_KEY; if (!openaiKey) { throw new Error('OpenAI API key is not configured'); }
try { const response = await fetch(API_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${openaiKey}` }, body: JSON.stringify({ model: model, messages: [ { role: 'system', content: 'You are an expert at creating mind maps. Generate a mind map structure for the given topic.' }, { role: 'user', content: prompt } ], temperature: temperature, max_tokens: 2000 }) });
if (!response.ok) { throw new Error(`API request failed: ${response.statusText}`); }
const data = await response.json(); return { mindmapText: data.choices[0].message.content, visualization: data.choices[0].message.content }; } catch (error) { console.error('Error generating mind map:', error); throw error; }}; 123456789101112131415161718192021222324252627282930313233import { signInWithPopup, signOut } from 'firebase/auth';import { auth, googleProvider } from './firebase';
class AuthService { async signInWithGoogle() { try { const result = await signInWithPopup(auth, googleProvider); return result.user; } catch (error) { console.error('Error signing in with Google:', error); throw error; } }
async signOut() { try { await signOut(auth); } catch (error) { console.error('Error signing out:', error); throw error; } }
getCurrentUser() { return auth.currentUser; }
onAuthStateChanged(callback) { return auth.onAuthStateChanged(callback); }}
export const authService = new AuthService(); 1234567891011121314151617181920212223import { initializeApp } from 'firebase/app';import { getAuth, GoogleAuthProvider } from 'firebase/auth';import { getDatabase } from 'firebase/database';import { getAnalytics } from 'firebase/analytics';
const firebaseConfig = { apiKey: process.env.REACT_APP_FIREBASE_API_KEY || "demo-key", authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN || "demo.firebaseapp.com", projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID || "demo", storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET || "demo.appspot.com", messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID || "123456789", appId: process.env.REACT_APP_FIREBASE_APP_ID || "1:123456789:web:abcdef"};
// Initialize Firebaseconst app = initializeApp(firebaseConfig);
// Initialize servicesexport const auth = getAuth(app);export const database = getDatabase(app);export const analytics = getAnalytics(app);export const googleProvider = new GoogleAuthProvider();export default app; 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081import OpenAI from 'openai';
const openai = new OpenAI({ apiKey: process.env.REACT_APP_OPENAI_API_KEY, dangerouslyAllowBrowser: true});
export async function callOpenAI({ prompt, promptTemplate, model = "gpt-4o-mini", maxTokens = 2000, temperature = 0.7, onProgress}) { try { const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.REACT_APP_OPENAI_API_KEY}` }, body: JSON.stringify({ model: model, messages: [ { role: "system", content: promptTemplate }, { role: "user", content: prompt } ], max_tokens: parseInt(maxTokens), temperature: parseFloat(temperature), stream: true }) });
if (!response.ok) { const error = await response.json(); throw new Error(error.error?.message || 'Failed to call OpenAI API'); }
const reader = response.body.getReader(); const decoder = new TextDecoder(); let accumulatedResponse = '';
while (true) { const { value, done } = await reader.read(); if (done) break;
const chunk = decoder.decode(value); const lines = chunk.split('\n'); for (const line of lines) { if (line.trim() === '') continue; if (line.trim() === 'data: [DONE]') continue; try { const cleanedLine = line.replace(/^data: /, ''); const parsed = JSON.parse(cleanedLine); const content = parsed.choices[0]?.delta?.content || ''; accumulatedResponse += content; if (onProgress) { onProgress(accumulatedResponse); } } catch (e) { console.error('Error parsing line:', e); } } }
return accumulatedResponse; } catch (error) { console.error('Error calling OpenAI:', error); throw error; }} 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253const DEFAULT_TOKEN_QUOTA = 5000;
class UserService { constructor() { this.loadUserData(); }
loadUserData() { const userData = localStorage.getItem('userData'); if (userData) { this.userData = JSON.parse(userData); } else { this.userData = { tokenQuota: DEFAULT_TOKEN_QUOTA, usedTokens: 0, }; this.saveUserData(); } }
saveUserData() { localStorage.setItem('userData', JSON.stringify(this.userData)); }
getUserData() { return { ...this.userData }; }
deductTokens(amount) { if (this.userData.tokenQuota - this.userData.usedTokens < amount) { throw new Error('Insufficient token quota'); } this.userData.usedTokens += amount; this.saveUserData(); }
addTokens(amount) { this.userData.tokenQuota += amount; this.saveUserData(); }
getRemainingTokens() { return this.userData.tokenQuota - this.userData.usedTokens; }
resetQuota() { this.userData.tokenQuota = DEFAULT_TOKEN_QUOTA; this.userData.usedTokens = 0; this.saveUserData(); }}
export const userService = new UserService(); 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390body { background-color: #a3b4c4; color: #ecf0f1; font-family: "Arial", sans-serif;}
div,button { margin: 5px;}
.App { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; width: 90%; margin: auto;}
.app-header { text-align: center; margin-bottom: 2rem;}
.app-header h1 { color: #2c3e50; margin-bottom: 1rem;}
.tab-buttons { display: flex; justify-content: space-between;}
.tab-button { background-color: #573f54; padding: 10px 20px; border: none; border-radius: 5px; color: white; cursor: pointer;}
.tab-button:hover { background-color: #7e135e;}
.outer { display: flex; justify-content: space-between; width: 100%; padding: 0; margin: 0;}
.outer > div { width: 100%;}
.mindmap-container { display: flex; flex-direction: column; gap: 1rem; position: relative;}
.mindmap-controls { display: flex; gap: 0.5rem; margin-bottom: 1rem;}
.mindmap-edit-btn { background-color: #3498db; padding: 0.5rem 1rem; border-radius: 4px; color: white; font-size: 0.9rem;}
.mindmap-edit-btn:hover { background-color: #2980b9;}
.mindmap-node-edit { position: absolute; background-color: white; padding: 1rem; border-radius: 4px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); z-index: 100;}
.mindmap-node-edit textarea { width: 100%; min-height: 100px; margin-bottom: 0.5rem;}
.ai-suggestion-panel { background-color: #34495e; padding: 1rem; border-radius: 4px; margin-top: 1rem;}
.ai-suggestion-panel h3 { color: #ecf0f1; margin-top: 0;}
.input-section { display: flex; gap: 1rem; margin-bottom: 1rem;}
.prompt-input { flex: 1; min-height: 100px; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; resize: vertical;}
.generate-btn { padding: 0.5rem 1rem; background-color: #2ecc71; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.2s;}
.generate-btn:disabled { background-color: #95a5a6; cursor: not-allowed;}
.error-message { color: #e74c3c; padding: 1rem; background-color: #fadbd8; border-radius: 4px; margin-bottom: 1rem;}
.output-section { display: flex; flex-direction: column; gap: 1rem;}
.result-output { width: 100%; min-height: 150px; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; resize: vertical;}
.mindmap-preview { border: 1px solid #ccc; border-radius: 4px; padding: 1rem; background-color: white;}
.account-section { max-width: 600px; margin: 0 auto; padding: 2rem; background-color: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);}
.token-info { margin: 2rem 0; display: flex; flex-direction: column; gap: 1rem;}
.buy-tokens-btn { width: 100%; padding: 1rem; background-color: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1.1rem; transition: background-color 0.2s;}
.buy-tokens-btn:hover { background-color: #2980b9;}
.app-footer { margin-top: 3rem; text-align: center; color: #7f8c8d; font-size: 0.9rem;}
.inputContainer { display: flex; justify-content: space-between; margin-bottom: 20px;}
.inputGroup { flex: 0 0 48%;}
.outputContainer { margin-bottom: 20px;}
.buttonContainer { display: flex; justify-content: space-between;}
.label { display: block; margin-bottom: 10px;}
textarea { width: 100%; box-sizing: border-box; min-height: 50px; height: 15vh; padding: 10px; border: none; border-radius: 5px; background-color: #34495e; color: #ecf0f1;}
button { cursor: pointer; background-color: #098046; color: #ecf0f1; transition: background-color 0.3s ease; padding: 10px; border: none; border-radius: 5px;}
button:hover { background-color: #2ecc71;}
.fa.icon-container { color: inherit !important; font-size: inherit !important;}
.login-container { margin-bottom: 1rem;}
.user-info { display: flex; align-items: center; gap: 1rem; color: #ecf0f1;}
.user-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover;}
.user-details { flex: 1;}
.user-name { margin: 0; font-weight: bold;}
.user-email { margin: 0.25rem 0; font-size: 0.9rem; opacity: 0.8;}
.google-sign-in-btn { width: 100%; background-color: #4285f4;}
.google-sign-in-btn:hover { background-color: #357abd;}
.sign-out-btn { background-color: #c0392b; margin-top: 0.5rem;}
.sign-out-btn:hover { background-color: #e74c3c;}
.tier-info { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.1);}
.upgrade-btn { background-color: #f1c40f; color: #2c3e50; font-weight: bold;}
.upgrade-btn:hover { background-color: #f39c12;}
.settings-section { display: flex; flex-direction: column; gap: 1rem;}
.settings-section > div { margin-bottom: 15px;}
.settings-section label { display: block; margin-bottom: 5px; color: #ecf0f1;}
.settings-section input,.settings-section select { width: 100%; padding: 8px; background-color: #34495e; border: 1px solid #2c3e50; border-radius: 4px; color: #ecf0f1;}
.mermaid-container { background-color: white; padding: 20px; border-radius: 5px; margin-top: 20px; overflow-x: auto;}
.mermaid-error { background-color: #fadbd8; color: #c0392b; padding: 15px; border-radius: 5px; margin-top: 20px; font-size: 14px; border: 1px solid #e74c3c;}
/* Mermaid specific styles */.mindmap-node rect { fill: #34495e !important; stroke: #2c3e50 !important;}
.mindmap-node text { fill: #ecf0f1 !important;}
.mindmap-node .icon { font-family: "Font Awesome 5 Free" !important;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540/* Base styles */* { box-sizing: border-box; margin: 0; padding: 0;}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background-color: #f8f9fa;}
/* App Container */.app-container { min-height: 100vh; display: flex; flex-direction: column;}
/* Header */.app-header { background-color: white; padding: 1rem 2rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); position: sticky; top: 0; z-index: 100;}
.header-content { display: flex; justify-content: space-between; align-items: center; position: relative;}
.app-header h1 { font-size: 1.5rem; color: #333; font-weight: 600; position: absolute; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap;}
/* Tab Navigation */.tab-buttons { display: flex; gap: 1rem; border-bottom: 1px solid #eee; padding-bottom: 0.5rem;}
.tab-button { background: none; border: none; padding: 0.5rem 1rem; font-size: 1rem; color: #666; cursor: pointer; border-radius: 4px; transition: all 0.2s;}
.tab-button:hover { background-color: rgba(0, 0, 0, 0.05);}
.tab-button.active { color: #4CAF50; font-weight: 500; background-color: rgba(76, 175, 80, 0.1);}
/* Main Content */.app-content { flex: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%;}
/* Login Container */.login-container { flex: 1; display: flex; justify-content: center; align-items: center; padding: 2rem;}
/* Loading */.loading-container { min-height: 100vh; display: flex; justify-content: center; align-items: center;}
.loading-spinner { color: #666; font-size: 1.2rem;}
/* Mindmapping Tab */.mindmap-container { background: white; border-radius: 8px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);}
.prompt-section,.output-section { margin-bottom: 1.5rem;}
.prompt-section h2,.output-section h2 { font-size: 1.2rem; color: #333; margin-bottom: 0.5rem;}
textarea { width: 100%; min-height: 120px; padding: 0.75rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; resize: vertical;}
.action-buttons { display: flex; gap: 1rem; margin-top: 1rem;}
.create-btn,.save-btn { padding: 0.5rem 1rem; border: none; border-radius: 4px; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 0.5rem;}
.create-btn { background-color: #4CAF50; color: white;}
.create-btn:hover:not(:disabled) { background-color: #45a049;}
.create-btn:disabled { background-color: #ccc; cursor: not-allowed;}
.save-btn { background-color: #f5f5f5; color: #333;}
.save-btn:hover { background-color: #e8e8e8;}
/* Output Header */.output-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem;}
.collapse-btn { background: none; border: none; font-size: 1.5rem; color: #666; cursor: pointer; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background-color 0.2s;}
.collapse-btn:hover { background-color: rgba(0, 0, 0, 0.05);}
/* Update existing styles */.output-section { margin-bottom: 1.5rem; background: white; padding: 1rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);}
.output-section h2 { font-size: 1.2rem; color: #333; margin: 0;}
.output-section textarea { width: 100%; min-height: 120px; padding: 0.75rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; resize: vertical; margin-top: 0.5rem;}
/* Add to existing styles */
.mindmap-section { margin-top: 2rem; background: white; border-radius: 8px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);}
.mindmap-section h2 { font-size: 1.2rem; color: #333; margin-bottom: 1rem;}
.mermaid-container { background-color: #f8f9fa; padding: 20px; border-radius: 8px; overflow-x: auto; min-height: 200px;}
.mermaid-container svg { max-width: 100%; height: auto;}
.mermaid-error { display: flex; align-items: center; gap: 16px; padding: 20px; background: #1a1a1a; border-radius: 4px; color: #fff;}
.error-icon { font-size: 24px;}
.error-content { display: flex; flex-direction: column; gap: 4px;}
.error-title { font-size: 16px; font-weight: 500;}
.error-subtitle { font-size: 14px; color: #888;}
.mermaid-output { display: flex; flex-direction: column; gap: 1rem;}
.mermaid-output .action-buttons { display: flex; gap: 0.5rem; justify-content: flex-end;}
/* Responsive adjustments */@media (max-width: 768px) { .app-header { padding: 1rem; }
.app-header h1 { font-size: 1.2rem; }
.app-content { padding: 1rem; } .tab-buttons { gap: 0.5rem; } .tab-button { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.output-section { padding: 0.75rem; } .output-section textarea { min-height: 100px; }
.mindmap-section { padding: 1rem; }
.mermaid-container { padding: 10px; }
.action-buttons { flex-direction: column; }
.create-btn, .save-btn { width: 100%; justify-content: center; }}
.title-section { text-align: center;}
.version { font-size: 12px; color: #666; margin-top: -10px; margin-bottom: 10px;}
.mermaid-output-container { display: flex; gap: 20px; width: 100%; height: 100%;}
.mermaid-main { flex: 1; min-width: 0;}
.debug-panel { width: 300px; padding: 15px; background: #f5f5f5; border-left: 1px solid #ddd; overflow-y: auto; height: calc(100vh - 200px); position: sticky; top: 0;}
.debug-panel h3 { margin-top: 0; margin-bottom: 10px; color: #333;}
.error-message { background: #fff0f0; border: 1px solid #ffcdd2; padding: 10px; margin-bottom: 10px; border-radius: 4px; color: #d32f2f;}
.debug-info { font-family: monospace; font-size: 12px; white-space: pre-wrap; background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ddd; margin: 0;}
.action-buttons { margin-top: 10px; display: flex; gap: 10px;}
.save-btn { padding: 8px 16px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;}
.save-btn:hover { background: #45a049;}
.debug-header { display: flex; align-items: center; justify-content: space-between; padding: 8px; background: #f5f5f5; border-radius: 4px; cursor: pointer;}
.copy-btn { background: #4CAF50; color: white; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-left: 10px; transition: background-color 0.2s;}
.copy-btn:hover { background: #45a049;}
/* Prevent the button click from toggling the details */.copy-btn:focus { outline: none;}
.copy-btn:active { transform: scale(0.98);}
.mermaid-wrapper { background: #1e1e1e; padding: 20px; border-radius: 8px; margin-top: 20px; min-height: 300px; display: flex; justify-content: center; align-items: center;}
.mermaid { width: 100%; display: flex; justify-content: center; background: #1e1e1e;}
.mermaid svg { max-width: 100%; height: auto;}
/* Mindmap specific styles */.mindmap-node rect { fill: #333; stroke: #fff; stroke-width: 2px;}
.mindmap-node text { fill: #fff; font-family: Arial, sans-serif;}
.mindmap-node .icon { font-family: 'Font Awesome 5 Free'; font-weight: 900;}
.mindmap-branch { stroke: #fff; stroke-width: 2px;}
.debug-details { margin-top: 10px; border-top: 1px solid #333; padding-top: 10px;}
.debug-details summary { color: #888; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 5px 0;}
.debug-details pre { margin-top: 10px; background: #222; padding: 10px; border-radius: 4px; overflow-x: auto; color: #ddd; font-size: 12px; font-family: monospace;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174.chat-dialog { position: fixed; bottom: 20px; left: 20px; width: 360px; max-width: 90vw; background-color: white; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); z-index: 1000; transition: all 0.3s ease; overflow: hidden;}
.chat-dialog.minimized { height: 60px;}
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background-color: #f8fafc; border-bottom: 1px solid #e5e7eb; cursor: pointer;}
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 500; color: #1f2937;}
.chat-logo { width: 24px; height: 24px; border-radius: 50%;}
.chat-controls { display: flex; gap: 8px;}
.minimize-button,.close-button { background: none; border: none; font-size: 18px; color: #6b7280; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: all 0.2s ease;}
.minimize-button:hover,.close-button:hover { background-color: #e5e7eb; color: #1f2937;}
.messages-container { height: 360px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth;}
.message { display: flex; gap: 12px; max-width: 85%;}
.message-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;}
.user-message { margin-left: auto; flex-direction: row-reverse;}
.message-content { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5;}
.assistant-message .message-content { background-color: #f8fafc; border: 1px solid #e5e7eb; color: #1f2937;}
.user-message .message-content { background-color: #2563eb; color: white;}
.input-container { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #e5e7eb; background-color: white;}
.chat-input { flex: 1; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s ease;}
.chat-input:focus { border-color: #2563eb;}
.send-button { padding: 8px 16px; background-color: #2563eb; color: white; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; transition: background-color 0.2s ease;}
.send-button:hover:not(:disabled) { background-color: #1d4ed8;}
.send-button:disabled { background-color: #93c5fd; cursor: not-allowed;}
/* Scrollbar styles */.messages-container::-webkit-scrollbar { width: 6px;}
.messages-container::-webkit-scrollbar-track { background: #f8fafc;}
.messages-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px;}
.messages-container::-webkit-scrollbar-thumb:hover { background: #94a3b8;} 123456789101112131415161718.loading-container { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #1a1a1a;}
.loading-spinner { color: #2563eb; font-size: 1.2rem; animation: spin 1s linear infinite;}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }} 12345678910111213141516171819202122232425.loading-spinner { display: flex; align-items: center; gap: 8px;}
.spinner { width: 20px; height: 20px; border: 2px solid #ffffff; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite;}
.spinner-text { font-size: 14px; color: white;}
@keyframes spin { to { transform: rotate(360deg); }} 12345678910111213141516171819202122232425262728293031323334.login-container { display: flex; justify-content: center; align-items: center; height: calc(100vh - 80px); background-color: #1a1a1a;}
.app-header { height: 80px; background-color: #1a1a1a; border-bottom: 1px solid #2c3e50; padding: 0 20px; display: flex; align-items: center;}
.title-section { text-align: center; width: 100%;}
.title { color: #e2e8f0; margin: 0; font-size: 24px; font-weight: 500;}
.version { color: #64748b; font-size: 12px; margin-top: 4px;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748.app-container { min-height: 100vh; background-color: white; display: flex; flex-direction: column;}
.app-header { background-color: white; border-bottom: 1px solid #e5e7eb; padding: 0 20px;}
.header-content { display: flex; justify-content: space-between; align-items: center; height: 80px; max-width: 1400px; margin: 0 auto; width: 100%;}
.title-section { flex: 1; text-align: center;}
.title { color: #333; margin: 0; font-size: 24px; font-weight: 500;}
.version { color: #666; font-size: 12px; margin-top: 4px;}
.app-content { flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; padding: 20px;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353.mindmap-container { width: 100%; min-height: 400px; background: #1a1a1a; border-radius: 8px; padding: 20px; margin-top: 20px; display: flex; flex-direction: column; gap: 1rem; position: relative;}
.input-section { margin-bottom: 20px;}
.prompt-input { width: 100%; min-height: 100px; padding: 12px; border: 1px solid #3498db; border-radius: 8px; background: #2c3e50; color: #fff; font-size: 14px; resize: vertical; margin-bottom: 10px;}
.prompt-input:focus { outline: none; border-color: #2980b9;}
.generate-btn { background: #3498db; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-size: 14px; transition: background-color 0.2s;}
.generate-btn:hover:not(:disabled) { background: #2980b9;}
.generate-btn:disabled { background: #95a5a6; cursor: not-allowed;}
.output-section { background: #1a1a1a; border-radius: 8px; padding: 20px; min-height: 600px; flex: 1;}
.mindmap-wrapper { width: 100%; height: 100%; min-height: 600px; background: #1a1a1a; border-radius: 8px; overflow: hidden; position: relative;}
.mindmap-error { background: #2c3e50; color: #fff; padding: 20px; border-radius: 8px; margin-top: 20px; font-size: 14px; border: 1px solid #e74c3c; display: flex; align-items: flex-start; gap: 15px;}
.error-icon { font-size: 24px;}
.error-content { flex: 1;}
.error-title { font-weight: bold; margin-bottom: 5px;}
.error-subtitle { color: #bdc3c7; font-size: 12px;}
.debug-details { margin-top: 15px; background: #34495e; border-radius: 6px; overflow: hidden;}
.debug-header { padding: 10px 15px; background: #2c3e50; cursor: pointer; display: flex; justify-content: space-between; align-items: center;}
.debug-header:hover { background: #3d566e;}
.copy-btn { background: #3498db; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;}
.copy-btn:hover { background: #2980b9;}
.debug-info { padding: 15px; margin: 0; background: #2c3e50; color: #ecf0f1; font-family: monospace; white-space: pre-wrap; font-size: 12px; max-height: 300px; overflow-y: auto;}
/* React Flow specific styles */.react-flow__node { font-size: 14px; background: #2c3e50; color: #fff; border: 2px solid #3498db; border-radius: 8px; padding: 12px 20px; width: auto; min-width: 150px; text-align: center; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2); transition: all 0.3s ease; cursor: pointer;}
.react-flow__node:hover { transform: translateY(-2px); box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);}
.react-flow__node.selected { border-color: #e74c3c; box-shadow: 0 0 0 2px #e74c3c;}
.react-flow__node[data-level="0"] { background: #2c3e50; border-color: #f1c40f; font-weight: bold; font-size: 16px; padding: 16px 24px; min-width: 200px;}
.react-flow__node-default { background: #2c3e50; color: #fff;}
.react-flow__edge { stroke: #3498db;}
.react-flow__edge-path { stroke-width: 2;}
.react-flow__edge.animated path { stroke-dasharray: 5; animation: dashdraw 1s linear infinite;}
@keyframes dashdraw { from { stroke-dashoffset: 10; }}
.react-flow__controls { background: #2c3e50; border-radius: 4px; padding: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);}
.react-flow__controls button { background: #34495e; border: none; color: #fff; border-radius: 4px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s;}
.react-flow__controls button:hover { background: #3d566e;}
.react-flow__minimap { background: #2c3e50; border-radius: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); margin: 10px;}
.react-flow__attribution { background: transparent; color: #95a5a6; font-size: 10px;}
.react-flow__background { background: #1a1a1a;}
.mindmap-controls { display: flex; gap: 0.5rem; margin: 10px; z-index: 5;}
.mindmap-edit-btn { background-color: #3498db; padding: 8px 16px; border-radius: 4px; color: white; font-size: 14px; border: none; cursor: pointer; transition: background-color 0.2s;}
.mindmap-edit-btn:hover:not(:disabled) { background-color: #2980b9;}
.mindmap-edit-btn:disabled { background-color: #95a5a6; cursor: not-allowed;}
.mindmap-node-edit { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #2c3e50; padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); z-index: 1000; border: 1px solid #3498db; min-width: 300px;}
.mindmap-node-edit textarea { width: 100%; min-height: 100px; margin-bottom: 12px; background: #34495e; border: 1px solid #3498db; border-radius: 4px; color: #fff; padding: 12px; font-size: 14px; resize: vertical;}
.mindmap-node-edit textarea:focus { outline: none; border-color: #2980b9;}
.mindmap-node-edit button { background-color: #e74c3c; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; transition: background-color 0.2s;}
.mindmap-node-edit button:hover { background-color: #c0392b;}
.mindmap-node-edit .buttons { display: flex; justify-content: flex-end; gap: 8px;}
/* Snap grid visualization */.react-flow__grid { color: rgba(52, 152, 219, 0.1);}
.react-flow__grid-dot { fill: rgba(52, 152, 219, 0.1);}
.ai-suggestion-panel { background-color: #34495e; padding: 1rem; border-radius: 4px; margin-top: 1rem; border: 1px solid #3498db;}
.ai-suggestion-panel h3 { color: #ecf0f1; margin-top: 0; font-size: 14px; margin-bottom: 10px;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516.mindmapping-container { padding: 20px; background-color: white; display: flex; flex-direction: column; gap: 20px;}
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 12px; background-color: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px;}
.toolbar-selects { display: flex; gap: 12px; flex: 1;}
.template-select,.format-select,.model-select { padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; background-color: white; color: #333; font-size: 14px; min-width: 180px; cursor: pointer;}
.template-select:hover,.format-select:hover,.model-select:hover { border-color: #cbd5e1;}
.template-select:focus,.format-select:focus,.model-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);}
.toolbar-buttons { display: flex; gap: 8px;}
.toolbar-buttons button { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid #e5e7eb; border-radius: 6px; background-color: white; color: #333; cursor: pointer; transition: all 0.2s;}
.toolbar-buttons button:hover:not(:disabled) { background-color: #f1f5f9; border-color: #cbd5e1;}
.toolbar-buttons button:disabled { opacity: 0.5; cursor: not-allowed;}
.toolbar-buttons button svg { width: 18px; height: 18px;}
.flip-horizontal { transform: scaleX(-1);}
.input-section { margin-bottom: 20px;}
.prompt-input { width: 100%; min-height: 60px; padding: 12px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 14px; color: #333; background-color: white; resize: vertical; margin-bottom: 12px;}
.create-button { padding: 8px 16px; background-color: #22c55e; color: white; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; transition: background-color 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 140px;}
.create-button:hover:not(:disabled) { background-color: #16a34a;}
.create-button:disabled { opacity: 0.7; cursor: not-allowed;}
.output-container { display: flex; flex-direction: column; gap: 20px; margin-top: 20px;}
.output-section { background-color: white; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;}
.output-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background-color: #f8fafc; border-bottom: 1px solid #e5e7eb;}
.section-title { font-size: 16px; font-weight: 500; color: #1f2937; margin: 0;}
.output-controls { display: flex; gap: 8px;}
.control-button { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid #e5e7eb; border-radius: 6px; background-color: white; color: #6b7280; cursor: pointer; transition: all 0.2s ease;}
.control-button:hover:not(:disabled) { background-color: #f8fafc; border-color: #d1d5db; color: #1f2937;}
.control-button:disabled { opacity: 0.5; cursor: not-allowed;}
.output-content { padding: 16px;}
.output-text { width: 100%; min-height: 120px; max-height: 300px; overflow-y: auto; padding: 12px; margin: 0; background-color: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;}
.error-message { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; margin: 12px 0; background-color: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; color: #dc2626;}
.error-icon { flex-shrink: 0; font-size: 18px;}
.error-content { font-size: 14px; line-height: 1.5;}
.mindmap-preview { min-height: 400px; padding: 16px; background-color: white; border-radius: 6px; overflow: hidden;}
/* Scrollbar styles for output text */.output-text::-webkit-scrollbar { width: 6px;}
.output-text::-webkit-scrollbar-track { background: #f8fafc;}
.output-text::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px;}
.output-text::-webkit-scrollbar-thumb:hover { background: #94a3b8;}
/* Chat dialog styles */.chat-dialog { position: fixed; bottom: 20px; right: 20px; width: 320px; max-width: 90vw; background-color: white; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); z-index: 1000;}
.debug-info { padding: 15px; background-color: #1f2937; border-radius: 4px; margin: 10px 0; border: 1px solid #374151;}
.debug-info h4 { color: #e2e8f0; margin: 0 0 10px 0;}
.debug-info pre { background-color: #111827; padding: 10px; border-radius: 4px; color: #e2e8f0; overflow-x: auto; font-size: 14px;}
.code-section { background-color: #1f2937; padding: 15px; border-radius: 4px;}
.code-section h3 { color: #e2e8f0; margin: 0 0 10px 0;}
.code-display { background-color: #111827; padding: 10px; border-radius: 4px; color: #e2e8f0; overflow-x: auto; font-size: 14px; white-space: pre-wrap;}
.raw-output { margin: 10px 0; background-color: #1f2937; border-radius: 4px; padding: 15px;}
.raw-output-text { width: 100%; min-height: 150px; padding: 10px; background-color: #111827; color: #e2e8f0; border: none; border-radius: 4px; font-family: monospace; font-size: 14px; resize: vertical;}
.mindmap-section { background-color: #1f2937; padding: 15px; border-radius: 4px; min-height: 400px;}
.mindmap-section h3 { color: #e2e8f0; margin: 0 0 10px 0;}
.help-overlay,.settings-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 1000;}
.help-content,.settings-content { background-color: white; padding: 24px; border-radius: 12px; max-width: 500px; width: 90%; max-height: 90vh; overflow-y: auto;}
.help-content h2,.settings-content h2 { color: #333; margin: 0 0 16px 0; font-size: 20px;}
.settings-group { margin-bottom: 24px;}
.settings-group label { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; color: #4b5563; font-size: 14px;}
.settings-group input[type="range"] { flex: 1;}
.settings-group input[type="number"] { width: 100px; padding: 4px 8px; border: 1px solid #e5e7eb; border-radius: 4px;}
.settings-info { padding: 16px; background-color: #f8fafc; border-radius: 8px; margin-bottom: 20px;}
.settings-info h3 { color: #333; margin: 0 0 8px 0; font-size: 16px;}
.settings-info p { color: #4b5563; margin: 0 0 8px 0; font-size: 14px;}
.help-content ol { margin: 0; padding-left: 20px;}
.help-content li { color: #4b5563; margin-bottom: 12px; line-height: 1.5;}
.help-content button,.settings-content button { margin-top: 20px; padding: 8px 16px; background-color: #3b82f6; color: white; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.2s;}
.help-content button:hover,.settings-content button:hover { background-color: #2563eb;}
/* Format-specific styles */.mermaid-mindmap,.plantuml-mindmap,.markdown-mindmap { width: 100%; height: 100%; min-height: 400px; padding: 20px; background-color: white; overflow: auto;}
.markdown-content { font-family: monospace; white-space: pre-wrap; margin: 0; padding: 0;}
/* Responsive Design */@media (max-width: 768px) { .toolbar { flex-direction: column; gap: 12px; }
.toolbar-selects { flex-direction: column; width: 100%; }
.template-select, .format-select, .model-select { width: 100%; min-width: unset; }
.toolbar-buttons { width: 100%; justify-content: space-between; }
.settings-group label { flex-direction: column; align-items: flex-start; gap: 8px; }
.settings-group input[type="range"] { width: 100%; }}
@media (max-width: 480px) { .mindmapping-container { padding: 12px; }
.help-content, .settings-content { padding: 16px; }} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194.user-profile { position: relative;}
.user-profile-trigger { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 20px; transition: background-color 0.2s; justify-content: flex-end;}
.user-profile-trigger:hover { background-color: rgba(0, 0, 0, 0.05);}
.user-info { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; background-color: white;}
.user-avatar { width: 32px; height: 32px; border-radius: 50%;}
.user-details { display: flex; flex-direction: column; gap: 2px;}
.user-name { font-size: 14px; font-weight: 500; color: #333;}
.account-info { display: flex; align-items: center; gap: 8px;}
.account-type { font-size: 12px; color: #666;}
.upgrade-button { padding: 4px 12px; background-color: #22c55e; color: white; border: none; border-radius: 4px; font-size: 12px; cursor: pointer; transition: background-color 0.2s;}
.upgrade-button:hover { background-color: #16a34a;}
.user-dropdown { position: absolute; top: 100%; right: 0; margin-top: 8px; background: white; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); width: 320px; max-width: 90vw; overflow: hidden; z-index: 1000;}
.user-email { font-size: 14px; color: #666; margin: 0; padding: 16px; border-bottom: 1px solid #e5e7eb;}
.settings-section { padding: 16px; border-bottom: 1px solid #e5e7eb;}
.setting-item { margin-bottom: 16px;}
.setting-item:last-child { margin-bottom: 0;}
.setting-item label { display: block; font-size: 12px; color: #666; margin-bottom: 4px;}
.setting-item input,.setting-item select,.setting-item textarea { width: 100%; padding: 8px; border: 1px solid #e5e7eb; border-radius: 4px; font-size: 14px; color: #333; background-color: white;}
.setting-item textarea { min-height: 80px; resize: vertical;}
.sign-out-btn { width: 100%; padding: 12px 16px; border: none; background: none; font-size: 14px; color: #333; cursor: pointer; text-align: left; transition: background-color 0.2s;}
.sign-out-btn:hover { background-color: #f9fafb;}
/* Responsive Design */@media (max-width: 768px) { .user-profile { margin-left: auto; } .user-name { display: none; } .account-info { display: none; } .user-dropdown { position: fixed; top: 60px; right: 16px; left: auto; width: 320px; max-width: calc(100vw - 32px); max-height: calc(100vh - 76px); overflow-y: auto; }
.setting-item input, .setting-item select, .setting-item textarea { font-size: 16px; /* Better for mobile touch */ }}
@media (max-width: 480px) { .user-dropdown { top: 56px; right: 8px; left: auto; width: 300px; }
.settings-section, .user-info, .dropdown-actions { padding: 12px; }} 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889/* Reset */* { margin: 0; padding: 0; box-sizing: border-box;}
/* Base styles */body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background-color: #f8f9fa; color: #333; line-height: 1.5;}
code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;}
/* Root container */#root { min-height: 100vh; display: flex; flex-direction: column;}
/* Utility classes */.text-center { text-align: center;}
.text-right { text-align: right;}
.text-left { text-align: left;}
.flex { display: flex;}
.flex-col { flex-direction: column;}
.items-center { align-items: center;}
.justify-center { justify-content: center;}
.justify-between { justify-content: space-between;}
.gap-2 { gap: 0.5rem;}
.gap-4 { gap: 1rem;}
.w-full { width: 100%;}
.h-full { height: 100%;}
/* Responsive utilities */@media (max-width: 768px) { .hide-mobile { display: none; }}
@media (min-width: 769px) { .hide-desktop { display: none; }} package.jsonAdded+48
public/index.htmlAdded+20
public/manifest.jsonAdded+25
src/App.jsAdded+36
src/Mermaid.jsAdded+212
src/components/Account.jsAdded+153
src/components/ChatDialog.jsAdded+114
src/components/LoadingScreen.jsAdded+10
src/components/LoadingSpinner.jsAdded+11
src/components/Login.jsAdded+71
src/components/LoginScreen.jsAdded+19
src/components/MainLayout.jsAdded+39
src/components/Mermaid.jsAdded+104
src/components/MindMap.cssAdded+114
src/components/MindMap.jsAdded+522
src/components/MindmappingTab.jsAdded+402
src/components/UserProfile.jsAdded+137
src/components/mindmap/MindMap.jsAdded+138
src/components/mindmap/MindMapEdge.jsAdded+27
src/components/mindmap/MindMapEditor.jsAdded+71
src/components/mindmap/MindMapLayout.jsAdded+32
src/components/mindmap/MindMapNode.jsAdded+99
src/components/mindmap/MindMapUtils.jsAdded+90
src/components/mindmap/formats/MarkdownMindMap.jsAdded+143
src/components/mindmap/formats/MermaidMindMap.jsAdded+154
src/components/mindmap/formats/PlantUMLMindMap.jsAdded+177
src/components/mindmap/formats/ReactFlowMindMap.jsAdded+143
src/components/mindmap/formats/index.jsAdded+115
src/components/models/index.jsAdded+106
src/config/defaults.jsAdded+106
src/hooks/useAppState.jsAdded+54
src/index.jsAdded+13
src/services/api.jsAdded+46
src/services/auth_service.jsAdded+33
src/services/firebase.jsAdded+23
src/services/openai_service.jsAdded+81
src/services/user_service.jsAdded+53
src/styles.cssAdded+390
src/styles/App.cssAdded+540
src/styles/ChatDialog.cssAdded+174
src/styles/LoadingScreen.cssAdded+18
src/styles/LoadingSpinner.cssAdded+25
src/styles/LoginScreen.cssAdded+34
src/styles/MainLayout.cssAdded+48
src/styles/MindMap.cssAdded+353
src/styles/MindmappingTab.cssAdded+516
src/styles/UserProfile.cssAdded+194
src/styles/index.cssAdded+89
yarn.lockAdded