{"version":3,"file":"CodeFormatter-WxvCjjsg.js","sources":["../../components/features/CodeFormatter.tsx"],"sourcesContent":["\nimport React, { useState, useCallback } from 'react';\nimport { formatCode } from '../../services/geminiService.ts';\nimport { CodeBracketSquareIcon } from '../icons/FeatureIcons.tsx';\nimport { LoadingSpinner } from './shared/LoadingSpinner.tsx';\nimport { marked } from 'marked';\n\nconst exampleCode = `const MyComponent = (props) => {\n const {name, items}=props\n if(!items || items.length === 0){\n return

No items found for {name}

;\n }\n return \n}`;\n\nexport const CodeFormatter: React.FC = () => {\n const [inputCode, setInputCode] = useState(exampleCode);\n const [formattedCode, setFormattedCode] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState('');\n\n const handleFormat = useCallback(async () => {\n if (!inputCode.trim()) {\n setError('Please enter some code to format.');\n return;\n }\n setIsLoading(true);\n setError('');\n setFormattedCode('');\n try {\n const result = await formatCode(inputCode);\n setFormattedCode(result);\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred.';\n setError(`Failed to format code: ${errorMessage}`);\n } finally {\n setIsLoading(false);\n }\n }, [inputCode]);\n \n return (\n
\n
\n

\n \n AI Code Formatter\n

\n

Clean up your code with AI-powered formatting, like a smart Prettier.

\n
\n
\n
\n
\n \n setInputCode(e.target.value)}\n placeholder=\"Paste your unformatted code here...\"\n className=\"flex-grow p-4 bg-slate-900 border border-slate-700 rounded-md resize-none font-mono text-sm text-cyan-300 focus:ring-2 focus:ring-cyan-500 focus:outline-none\"\n />\n
\n
\n \n
\n {isLoading && (\n
\n \n
\n )}\n {error &&

{error}

}\n {formattedCode && !isLoading && (\n \n )}\n {!isLoading && !formattedCode && !error && (\n
\n Formatted code will appear here.\n
\n )}\n
\n
\n
\n \n {isLoading ? : 'Format Code'}\n \n
\n
\n );\n};"],"names":["exampleCode","CodeFormatter","inputCode","setInputCode","useState","formattedCode","setFormattedCode","isLoading","setIsLoading","error","setError","handleFormat","useCallback","result","formatCode","err","errorMessage","jsx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