Compare commits

...

3 Commits

Author SHA1 Message Date
Flatlogic Bot
991acb14d9 MAKDOC3 2025-10-26 18:38:54 +00:00
Flatlogic Bot
015faff9b1 makdoc2 2025-10-26 18:19:42 +00:00
Flatlogic Bot
0e82cdc749 makdock1 2025-10-26 18:15:37 +00:00
4 changed files with 614 additions and 145 deletions

327
api/generate_report.php Normal file
View File

@ -0,0 +1,327 @@
<?php
header('Content-Type: application/json');
// --- Helper Functions for Report Generation ---
/**
* Generates a concise summary of the text.
*/
function generate_summary_report($text) {
$report = "<h1>AI-Generated Summary Report</h1>";
$report .= "<p>A high-level overview of the key points in the document.</p><br/>";
$sentences = preg_split('/(?<=[.?!])\s+/', $text, -1, PREG_SPLIT_NO_EMPTY);
$num_sentences = count($sentences);
$summary_sentences = [];
$sentences_to_take = 3;
if ($num_sentences <= ($sentences_to_take * 2)) {
$summary_sentences = $sentences;
} else {
$summary_sentences = array_slice($sentences, 0, $sentences_to_take);
$summary_sentences[] = "[...]";
$summary_sentences = array_merge($summary_sentences, array_slice($sentences, -$sentences_to_take));
}
$report .= "<h2>Key Points:</h2><ul>";
foreach ($summary_sentences as $sentence) {
$report .= "<li>" . htmlspecialchars(trim($sentence)) . "</li>";
}
$report .= "</ul>";
return $report;
}
/**
* Extracts sentences that appear to reference dates or events to create a timeline.
*/
function generate_timeline_report($text) {
$report = "<h1>AI-Generated Timeline of Events</h1>";
$report .= "<p>A chronological list of events and important dates mentioned in the document.</p><br/>";
// Regex to find sentences with dates (e.g., 25/12/2023, Dec 25, 2023) or time-related keywords.
$date_pattern = '/\b(\d{1,2}[-\/]\d{1,2}[-\/]\d{2,4}|\w+\s\d{1,2},\s\d{4})\b/i';
$keyword_pattern = '/\b(on|at|before|after|during|later|yesterday|today|tomorrow|meanwhile)\b/i';
$sentences = preg_split('/(?<=[.?!])\s+/', $text, -1, PREG_SPLIT_NO_EMPTY);
$timeline_events = [];
foreach ($sentences as $sentence) {
if (preg_match($date_pattern, $sentence) || preg_match($keyword_pattern, $sentence)) {
$timeline_events[] = $sentence;
}
}
$report .= "<h2>Potential Events:</h2>";
if (empty($timeline_events)) {
$report .= "<p>No specific date or time-based events were detected by the AI.</p>";
} else {
$report .= "<ul>";
foreach ($timeline_events as $event) {
$report .= "<li>" . htmlspecialchars(trim($event)) . "</li>";
}
$report .= "</ul>";
}
return $report;
}
/**
* Extracts names of individuals based on common titles.
*/
function generate_persons_report($text) {
$report = "<h1>AI-Generated List of Key Individuals</h1>";
$report .= "<p>A list of individuals who may be relevant to the document.</p><br/>";
// Regex to find names with titles (Mr., Mrs., Dr., etc.) or potential full names.
$pattern = '/\b(Mr\.|Mrs\.|Ms\.|Dr\.|Prof\.)\s+[A-Z][a-z]+(\s+[A-Z][a-z]+)?/i';
preg_match_all($pattern, $text, $matches);
$persons = array_unique($matches[0]);
$report .= "<h2>Mentioned Individuals:</h2>";
if (empty($persons)) {
$report .= "<p>No individuals with titles (e.g., Mr., Dr.) were automatically detected.</p>";
} else {
$report .= "<ul>";
foreach ($persons as $person) {
$report .= "<li>" . htmlspecialchars(trim($person)) . "</li>";
}
$report .= "</ul>";
}
return $report;
}
/**
* Extracts a log of potential evidence markers.
*/
function generate_evidence_report($text) {
$report = "<h1>AI-Generated Evidence Log</h1>";
$report .= "<p>A log of items marked as potential evidence or exhibits.</p><br/>";
// Regex to find evidence-related keywords.
$pattern = '/\b(Exhibit|Appendix|Figure|Table|Attachment|Document|Photo|Video|Audio)\s+[A-Z0-9\-]+/i';
preg_match_all($pattern, $text, $matches);
$evidence_items = array_unique($matches[0]);
$report .= "<h2>Potential Evidence:</h2>";
if (empty($evidence_items)) {
$report .= "<p>No items matching standard evidence markers (e.g., 'Exhibit A', 'Document 123') were found.</p>";
} else {
$report .= "<ul>";
foreach ($evidence_items as $item) {
$report .= "<li>" . htmlspecialchars(trim($item)) . "</li>";
}
$report .= "</ul>";
}
return $report;
}
/**
* Generates a placeholder for a Case Diary Status Report.
*/
function generate_case_diary_report($text) {
$report = "<h1>Case Diary Status Report</h1>";
$report .= "<p>This is a placeholder for the Case Diary Status Report. Future development will populate this with relevant case diary entries from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for a Bail Reply.
*/
function generate_bail_reply_report($text) {
$report = "<h1>Bail Reply</h1>";
$report .= "<p>This is a placeholder for the Bail Reply. Future development will populate this with arguments and evidence against bail from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for a High Court Status Report.
*/
function generate_high_court_status_report($text) {
$report = "<h1>High Court Status Report</h1>";
$report .= "<p>This is a placeholder for the High Court Status Report. Future development will populate this with case status details for the High Court.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for a Seizure Memo.
*/
function generate_seizure_memo_report($text) {
$report = "<h1>Seizure Memo</h1>";
$report .= "<p>This is a placeholder for the Seizure Memo. Future development will populate this with details of seized items from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for a Chargesheet.
*/
function generate_chargesheet_report($text) {
$report = "<h1>Chargesheet</h1>";
$report .= "<p>This is a placeholder for the Chargesheet. Future development will populate this with charges, evidence, and witness lists from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for a Disclosure Statement.
*/
function generate_disclosure_statement_report($text) {
$report = "<h1>Disclosure Statement</h1>";
$report .= "<p>This is a placeholder for the Disclosure Statement. Future development will populate this with disclosed information from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for an Exemption Request.
*/
function generate_exemption_request_report($text) {
$report = "<h1>Exemption Request</h1>";
$report .= "<p>This is a placeholder for the Exemption Request. Future development will populate this with reasons and justifications for exemption from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a placeholder for an NBW (Non-Bailable Warrant).
*/
function generate_nbw_report($text) {
$report = "<h1>NBW (Non-Bailable Warrant)</h1>";
$report .= "<p>This is a placeholder for the NBW. Future development will populate this with details for the warrant application from the text.</p><br/>";
$report .= "<h2>Extracted Text:</h2><p>" . htmlspecialchars(substr($text, 0, 500)) . "...</p>";
return $report;
}
/**
* Generates a report for a Reply for Release of RC.
*/
function generate_release_of_rc_reply_report($text) {
$report = "<h1>Reply for Release of RC</h1>";
// Extract details using regex
preg_match('/IN THE HONBLE COURT OF (.*)/', $text, $court);
preg_match('/FIR NO.: (.*)/', $text, $fir_no);
preg_match('/U\/S: (.*)/', $text, $us);
preg_match('/P.S.: (.*)/', $text, $ps);
preg_match('/State. vs. (.*)/', $text, $parties);
preg_match('/motorcycle bearing no. (.*?),/', $text, $vehicle_no);
preg_match('/applicant, (.*?)\./', $text, $applicant);
preg_match('/accused, (.*?)[,.]/', $text, $accused);
preg_match('/disposed of by this Hon'ble Court on (.*)\./', $text, $disposal_date);
$report .= "<p><strong>IN THE HONBLE COURT OF " . htmlspecialchars($court[1] ?? '...') . "</strong></p>";
$report .= "<p><strong>FIR NO.:</strong> " . htmlspecialchars($fir_no[1] ?? '...') . "</p>";
$report .= "<p><strong>U/S:</strong> " . htmlspecialchars($us[1] ?? '...') . "</p>";
$report .= "<p><strong>P.S.:</strong> " . htmlspecialchars($ps[1] ?? '...') . "</p>";
$report .= "<p><strong>In the matter of:</strong> State. vs. " . htmlspecialchars($parties[1] ?? '...') . "</p>";
$report .= "<hr>";
$report .= "<p><strong>Subject- Reply for Release of RC</strong></p>";
$report .= "<p>HONBLE SIR,</p>";
$report .= "<p>Most respectfully submitted that present application for the release of the registration certificate (RC) of motorcycle bearing no. <strong>" . htmlspecialchars($vehicle_no[1] ?? '...') . "</strong>, filed by the applicant, <strong>" . htmlspecialchars($applicant[1] ?? '...') . "</strong>.</p>";
$report .= "<p>The applicant stood as surety for the accused, <strong>" . htmlspecialchars($accused[1] ?? '...') . "</strong>, during the pendency of the case.</p>";
$report .= "<p>The case has been disposed of by this Hon'ble Court on <strong>" . htmlspecialchars($disposal_date[1] ?? '...') . "</strong>.</p>";
$report .= "<p>That no other appeal in this regard is pending in any other Honble Court or High Court.</p>";
$report .= "<p>That undersigned have no objection on release of RC.</p>";
$report .= "<p>Submitted Please.</p>";
return $report;
}
/**
* Generates a report for a Request for Cartridges.
*/
function generate_request_for_cartridges_report($text) {
$report = "<h1>Request for Cartridges</h1>";
// Extract details using regex
preg_match('/FIR NO . (.*)/', $text, $fir_no);
preg_match('/PS (.*) DELHI/', $text, $ps);
preg_match('/TO (.*)/', $text, $to);
preg_match('/provide (.*) for test firing/', $text, $cartridges);
preg_match('/sent to (.*) Vide/', $text, $fsl);
preg_match('/Letter No. (.*) Dated/', $text, $letter_no);
preg_match('/Dated (.*) for expert/', $text, $letter_date);
$report .= "<p><strong>FIR NO.:</strong> " . htmlspecialchars($fir_no[1] ?? '...') . "</p>";
$report .= "<p><strong>P.S.:</strong> " . htmlspecialchars($ps[1] ?? '...') . "</p>";
$report .= "<p><strong>TO:</strong> " . htmlspecialchars($to[1] ?? '...') . "</p>";
$report .= "<hr>";
$report .= "<p><strong>Subject- Request to provide " . htmlspecialchars($cartridges[1] ?? '...') . " for test firing</strong></p>";
$report .= "<p>Sir,</p>";
$report .= "<p>Most respectfully submitted that recovered arms and ammunition were sent to <strong>" . htmlspecialchars($fsl[1] ?? '...') . "</strong> Vide Letter No. <strong>" . htmlspecialchars($letter_no[1] ?? '...') . "</strong> Dated <strong>" . htmlspecialchars($letter_date[1] ?? '...') . "</strong> for expert opinion.</p>";
$report .= "<p>That FSL raised objection and asked to provide <strong>" . htmlspecialchars($cartridges[1] ?? '...') . "</strong> for Test firing.</p>";
$report .= "<p>Therefore it is requested that for further proceedings <strong>" . htmlspecialchars($cartridges[1] ?? '...') . "</strong> may kindly be provided.</p>";
$report .= "<p>Submitted please.</p>";
return $report;
}
// --- Main Logic ---
$data = json_decode(file_get_contents('php://input'), true);
$text = $data['text'] ?? '';
$template = $data['template'] ?? 'summary'; // Default to 'summary'
if (empty($text)) {
echo json_encode(['report' => 'No text provided to generate a report.']);
exit;
}
$final_report = '';
switch ($template) {
case 'timeline':
$final_report = generate_timeline_report($text);
break;
case 'persons':
$final_report = generate_persons_report($text);
break;
case 'evidence':
$final_report = generate_evidence_report($text);
break;
case 'case_diary':
$final_report = generate_case_diary_report($text);
break;
case 'bail_reply':
$final_report = generate_bail_reply_report($text);
break;
case 'high_court_status':
$final_report = generate_high_court_status_report($text);
break;
case 'seizure_memo':
$final_report = generate_seizure_memo_report($text);
break;
case 'chargesheet':
$final_report = generate_chargesheet_report($text);
break;
case 'disclosure_statement':
$final_report = generate_disclosure_statement_report($text);
break;
case 'exemption_request':
$final_report = generate_exemption_request_report($text);
break;
case 'nbw':
$final_report = generate_nbw_report($text);
break;
case 'release_of_rc_reply':
$final_report = generate_release_of_rc_reply_report($text);
break;
case 'request_for_cartridges':
$final_report = generate_request_for_cartridges_report($text);
break;
case 'summary':
default:
$final_report = generate_summary_report($text);
break;
}
$final_report .= "<br/><p><strong>--- End of Report ---</strong></p>";
// Return the report as JSON
echo json_encode(['report' => $final_report]);

58
assets/css/custom.css Normal file
View File

@ -0,0 +1,58 @@
/* Base styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
background-color: #f0f2f5; /* Lighter gray background */
}
/* Glassmorphism card style */
.glass-card {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
transition: all 0.3s ease;
}
.glass-card-header {
background: rgba(249, 250, 251, 0.7); /* Light header */
border-bottom: 1px solid #e5e7eb;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
/* Gradient button */
.btn-gradient {
background-image: linear-gradient(to right, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
background-size: 200% auto;
color: white;
transition: 0.5s;
border: none;
}
.btn-gradient:hover:not(:disabled) {
background-position: right center; /* change the direction of the change here */
box-shadow: 0 4px 15px 0 rgba(124, 77, 255, 0.4);
}
/* For webkit scrollbars */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}

1
assets/js/main.js Normal file
View File

@ -0,0 +1 @@
// Custom JavaScript for MAKDOC will go here.

367
index.php
View File

@ -1,150 +1,233 @@
<?php <!DOCTYPE html>
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Style</title> <title>MAKDOC - AI Legal Assistant</title>
<?php <!-- Scripts -->
// Read project preview data from environment <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"></script>
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"></script>
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.23.5/babel.min.js"></script>
?> <script src="https://cdn.tailwindcss.com"></script>
<?php if ($projectDescription): ?> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
<!-- Meta description --> <script>pdfjsLib.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js`;</script>
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' /> <script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
<!-- Open Graph meta tags --> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<!-- Twitter meta tags --> <link href="assets/css/custom.css" rel="stylesheet">
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head> </head>
<body> <body class="bg-gray-100">
<main> <div id="root"></div>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1> <script type="text/babel">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> const { useState, useEffect } = React;
<span class="sr-only">Loading…</span>
// Main App Component
function App() {
const [file, setFile] = useState(null);
const [fileContent, setFileContent] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [reportContent, setReportContent] = useState('AI-generated report will appear here.');
const [reportTemplate, setReportTemplate] = useState('summary');
const handleFileChange = (e) => {
const selectedFile = e.target.files[0];
if (selectedFile) {
setFile(selectedFile);
extractText(selectedFile);
}
};
const extractText = (fileToProcess) => {
setIsLoading(true);
setFileContent('');
const reader = new FileReader();
const fileType = fileToProcess.type;
if (fileType === 'application/pdf') {
reader.onload = (e) => {
const typedarray = new Uint8Array(e.target.result);
pdfjsLib.getDocument(typedarray).promise.then(pdf => {
let text = '';
const numPages = pdf.numPages;
const promises = [];
for (let i = 1; i <= numPages; i++) {
promises.push(pdf.getPage(i).then(page => {
return page.getTextContent().then(content => {
return content.items.map(item => item.str).join(' ');
});
}));
}
Promise.all(promises).then(pagesText => {
setFileContent(pagesText.join('\n\n'));
setIsLoading(false);
});
});
};
reader.readAsArrayBuffer(fileToProcess);
} else if (fileType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
reader.onload = (e) => {
mammoth.extractRawText({ arrayBuffer: e.target.result })
.then(result => {
setFileContent(result.value);
setIsLoading(false);
})
.catch(err => {
console.error("Mammoth error:", err);
setFileContent("Error extracting text from DOCX file.");
setIsLoading(false);
});
};
reader.readAsArrayBuffer(fileToProcess);
} else {
setFileContent('Unsupported file type. Please upload a PDF or DOCX file.');
setIsLoading(false);
}
};
const generateReport = () => {
setReportContent('<div class="flex justify-center items-center h-full"><i class="fas fa-spinner fa-spin text-3xl text-indigo-500"></i></div>');
fetch('/api/generate_report.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: fileContent, template: reportTemplate }),
})
.then(response => response.json())
.then(data => {
setReportContent(data.report);
})
.catch(error => {
console.error('Error generating report:', error);
setReportContent('An error occurred while generating the report.');
});
};
const exportToPdf = () => {
const element = document.getElementById('report-content-wrapper');
if (!element) {
alert("No content to export.");
return;
}
const opt = {
margin: 0.5,
filename: 'MAKDOC_Report.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
html2pdf().from(element).set(opt).save();
}
return (
<div className="flex h-screen bg-gray-100 font-sans">
{/* Sidebar */}
<aside className="w-64 bg-white shadow-md">
<div className="p-6">
<h1 className="text-2xl font-bold text-indigo-600">MAKDOC.AI</h1>
</div>
<nav className="mt-6">
<a href="#" className="flex items-center px-6 py-3 text-gray-700 bg-gray-200">
<i className="fas fa-file-upload mr-3"></i>
Document Analysis
</a>
<a href="#" className="flex items-center px-6 py-3 text-gray-600 hover:bg-gray-200">
<i className="fas fa-history mr-3"></i>
History
</a>
<a href="#" className="flex items-center px-6 py-3 text-gray-600 hover:bg-gray-200">
<i className="fas fa-cog mr-3"></i>
Settings
</a>
</nav>
</aside>
{/* Main Content */}
<main className="flex-1 p-8">
<div className="glass-card p-6 h-full flex flex-col">
<div className="glass-card-header -m-6 mb-6 p-4">
<h2 className="text-xl font-semibold text-gray-800">AI Document Analysis</h2>
</div>
{/* Upload Area */}
<div className="mb-6">
<label htmlFor="file-upload" className="cursor-pointer btn-gradient text-white font-bold py-3 px-6 rounded-lg inline-block">
<i className="fas fa-upload mr-2"></i>
{file ? 'Change Document' : 'Upload Document (PDF/DOCX)'}
</label>
<input id="file-upload" type="file" className="hidden" onChange={handleFileChange} accept=".pdf,.docx" />
{file && <span className="ml-4 text-gray-600">{file.name}</span>}
</div>
{/* Content & Report Area */}
<div className="flex-1 grid grid-cols-1 md:grid-cols-2 gap-6 min-h-0">
{/* Extracted Text */}
<div className="bg-white rounded-lg shadow p-4 flex flex-col">
<h3 className="text-lg font-semibold text-gray-700 mb-2">Extracted Content</h3>
<div className="flex-1 overflow-y-auto p-2 border rounded">
{isLoading ? (
<div className="flex justify-center items-center h-full">
<i className="fas fa-spinner fa-spin text-3xl text-indigo-500"></i>
</div>
) : (
<pre className="whitespace-pre-wrap text-sm text-gray-600">{fileContent || "Upload a document to see its content here."}</pre>
)}
</div>
</div>
{/* AI Generated Report */}
<div className="bg-white rounded-lg shadow p-4 flex flex-col">
<h3 className="text-lg font-semibold text-gray-700 mb-2">Generated Report</h3>
<div id="report-content-wrapper" className="flex-1 overflow-y-auto p-2 border rounded">
<div className="text-sm text-gray-600" dangerouslySetInnerHTML={{ __html: reportContent }}></div>
</div>
</div>
</div>
{/* Action Buttons */}
<div className="mt-6 flex justify-end items-center space-x-4">
<div className="relative">
<select
value={reportTemplate}
onChange={(e) => setReportTemplate(e.target.value)}
className="appearance-none bg-white border border-gray-300 rounded-lg py-2 pl-4 pr-8 text-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500"
>
<option value="summary">Case Summary</option>
<option value="timeline">Timeline of Events</option>
<option value="persons">Key Individuals</option>
<option value="evidence">Evidence Log</option>
<option value="case_diary">Case Diary Status Report</option>
<option value="bail_reply">Bail Reply</option>
<option value="high_court_status">High Court Status Report</option>
<option value="seizure_memo">Seizure Memo</option>
<option value="chargesheet">Chargesheet</option>
<option value="disclosure_statement">Disclosure Statement</option>
<option value="exemption_request">Exemption Request</option>
<option value="nbw">NBW</option>
<option value="release_of_rc_reply">Release of RC Reply</option>
<option value="request_for_cartridges">Request for Cartridges</option>
</select>
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
<i className="fas fa-chevron-down text-xs"></i>
</div>
</div>
<button onClick={generateReport} disabled={!fileContent} className="btn-gradient font-bold py-2 px-6 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed">
<i className="fas fa-magic mr-2"></i>
Generate Report
</button>
<button onClick={exportToPdf} disabled={!fileContent} className="bg-gray-600 hover:bg-gray-700 text-white font-bold py-2 px-6 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed">
<i className="fas fa-file-pdf mr-2"></i>
Export as PDF
</button>
</div> </div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div> </div>
</main> </main>
<footer> </div>
Page updated: <?= htmlspecialchars($now) ?> (UTC) );
</footer> }
ReactDOM.render(<App />, document.getElementById('root'));
</script>
</body> </body>
</html> </html>