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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>📋 Land Data Converter</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .tab-btn.active {
            background-color: #3b82f6;
            color: white;
        }
        .file-upload {
            border: 2px dashed #cbd5e0;
            transition: all 0.3s ease;
        }
        .file-upload:hover {
            border-color: #3b82f6;
        }
        .file-upload.dragover {
            border-color: #3b82f6;
            background-color: #ebf4ff;
        }
        .data-table {
            width: 100%;
            overflow-x: auto;
        }
        .data-table table {
            min-width: 100%;
        }
        .data-table th {
            background-color: #f3f4f6;
            font-weight: 600;
            text-align: left;
        }
        .data-table tr:nth-child(even) {
            background-color: #f9fafb;
        }
        .data-table tr:hover {
            background-color: #eff6ff;
        }
        @media (max-width: 640px) {
            .tabs-container {
                flex-direction: column;
            }
            .tab-btn {
                width: 100%;
                margin-bottom: 0.5rem;
            }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8 max-w-6xl">
        <!-- Header -->
        <header class="mb-8">
            <h1 class="text-3xl font-bold text-gray-800 flex items-center">
                <i class="fas fa-file-alt mr-3 text-blue-500"></i> Comprehensive Land Record Converter
            </h1>
            <p class="text-gray-600 mt-2">Convert HTML land records or parse raw text into structured Excel data</p>
        </header>

        <!-- Tabs -->
        <div class="bg-white rounded-lg shadow-md overflow-hidden mb-8">
            <div class="tabs-container flex border-b border-gray-200">
                <button class="tab-btn active py-3 px-6 font-medium text-gray-700 hover:bg-blue-50 transition-colors flex items-center" data-tab="upload">
                    <i class="fas fa-file-upload mr-2"></i> Upload HTML File
                </button>
                <button class="tab-btn py-3 px-6 font-medium text-gray-700 hover:bg-blue-50 transition-colors flex items-center" data-tab="paste">
                    <i class="fas fa-paste mr-2"></i> Paste Raw Text
                </button>
            </div>

            <!-- Tab 1: Upload HTML File -->
            <div id="upload" class="tab-content active p-6">
                <h2 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-file-upload mr-2 text-blue-500"></i> Upload HTML Land Record File
                </h2>
                
                <div id="dropArea" class="file-upload rounded-lg p-8 text-center cursor-pointer mb-6">
                    <input type="file" id="htmlFileInput" class="hidden" accept=".htm,.html">
                    <div class="flex flex-col items-center justify-center">
                        <i class="fas fa-cloud-upload-alt text-4xl text-blue-400 mb-3"></i>
                        <p class="text-gray-600 mb-2">Drag & drop your HTML file here or click to browse</p>
                        <p class="text-sm text-gray-500">Supported formats: .htm, .html</p>
                        <button id="browseBtn" class="mt-4 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md transition-colors">
                            Browse Files
                        </button>
                    </div>
                </div>
                
                <div id="fileInfo" class="hidden mb-6 p-4 bg-blue-50 rounded-md border border-blue-200">
                    <div class="flex justify-between items-center">
                        <div class="flex items-center">
                            <i class="fas fa-file-alt text-blue-500 mr-3 text-xl"></i>
                            <div>
                                <p id="fileName" class="font-medium text-gray-800"></p>
                                <p id="fileSize" class="text-sm text-gray-600"></p>
                            </div>
                        </div>
                        <button id="removeFile" class="text-red-500 hover:text-red-700">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>
                
                <div id="parseResults" class="hidden">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm font-medium mr-3">
                            <i class="fas fa-check-circle mr-1"></i> HTML parsed successfully!
                        </div>
                        <button id="downloadExcel" class="ml-auto bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-md transition-colors flex items-center">
                            <i class="fas fa-file-excel mr-2"></i> Download Excel File
                        </button>
                    </div>
                    
                    <div class="data-table bg-white rounded-lg border border-gray-200 overflow-hidden mb-6">
                        <div class="overflow-x-auto">
                            <table id="resultTable" class="w-full">
                                <thead>
                                    <tr>
                                        <th class="py-3 px-4">Khewat No</th>
                                        <th class="py-3 px-4">Marba No</th>
                                        <th class="py-3 px-4">Killa No</th>
                                        <th class="py-3 px-4">Total Area (Kanals)</th>
                                        <th class="py-3 px-4">Total Area (Marlas)</th>
                                        <th class="py-3 px-4">Owner Name</th>
                                        <th class="py-3 px-4">Share Fraction</th>
                                    </tr>
                                </thead>
                                <tbody id="tableBody">
                                    <!-- Data will be inserted here -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                
                <div id="parseError" class="hidden bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded">
                    <div class="flex items-center">
                        <i class="fas fa-exclamation-circle mr-3 text-xl"></i>
                        <p>No valid table found in the uploaded file.</p>
                    </div>
                </div>
            </div>

            <!-- Tab 2: Paste Raw Text -->
            <div id="paste" class="tab-content p-6">
                <h2 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-paste mr-2 text-blue-500"></i> Parse Owner Blocks from Pasted Text
                </h2>
                
                <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-6 rounded">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-info-circle text-blue-500 mt-1"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-blue-700">
                                Paste owner and share information below. Each group of owner lines must be followed by a share line (e.g., <code class="bg-gray-200 px-1 rounded">603/3076 भाग</code>). Any lines like <code class="bg-gray-200 px-1 rounded">वासी</code>, <code class="bg-gray-200 px-1 rounded">हर दो समभाग</code> will be added as narration to the last name in the group.
                            </p>
                        </div>
                    </div>
                </div>
                
                <div class="mb-6">
                    <label for="rawTextInput" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
                        <i class="fas fa-arrow-up mr-2 text-gray-500"></i> Paste Raw Data Below
                    </label>
                    <textarea id="rawTextInput" rows="10" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"></textarea>
                </div>
                
                <button id="parseTextBtn" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md transition-colors flex items-center mb-6">
                    <i class="fas fa-cogs mr-2"></i> Parse Text
                </button>
                
                <div id="pasteResults" class="hidden">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-sm font-medium mr-3">
                            <i class="fas fa-check-circle mr-1"></i> Parsed pasted data successfully!
                        </div>
                        <button id="downloadPasteExcel" class="ml-auto bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-md transition-colors flex items-center">
                            <i class="fas fa-file-excel mr-2"></i> Download Excel File
                        </button>
                    </div>
                    
                    <div class="data-table bg-white rounded-lg border border-gray-200 overflow-hidden mb-6">
                        <div class="overflow-x-auto">
                            <table id="pasteResultTable" class="w-full">
                                <thead>
                                    <tr>
                                        <th class="py-3 px-4">Owner Name</th>
                                        <th class="py-3 px-4">Share Fraction</th>
                                    </tr>
                                </thead>
                                <tbody id="pasteTableBody">
                                    <!-- Data will be inserted here -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                
                <div id="pasteError" class="hidden bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mb-6 rounded">
                    <div class="flex items-center">
                        <i class="fas fa-exclamation-triangle mr-3 text-xl"></i>
                        <p>No data parsed.</p>
                    </div>
                </div>
                
                <div id="pasteInfo" class="bg-blue-50 border-l-4 border-blue-500 p-4 rounded">
                    <div class="flex items-center">
                        <i class="fas fa-arrow-up mr-3 text-xl text-blue-500"></i>
                        <p>Paste data above to begin.</p>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Footer -->
        <footer class="mt-12 text-center text-gray-500 text-sm">
            <p>© 2023 Land Data Converter. All rights reserved.</p>
        </footer>
    </div>

    <script>
        // Tab switching functionality
        document.addEventListener('DOMContentLoaded', function() {
            const tabButtons = document.querySelectorAll('.tab-btn');
            const tabContents = document.querySelectorAll('.tab-content');
            
            tabButtons.forEach(button => {
                button.addEventListener('click', () => {
                    // Remove active class from all buttons and contents
                    tabButtons.forEach(btn => btn.classList.remove('active'));
                    tabContents.forEach(content => content.classList.remove('active'));
                    
                    // Add active class to clicked button and corresponding content
                    button.classList.add('active');
                    const tabId = button.getAttribute('data-tab');
                    document.getElementById(tabId).classList.add('active');
                });
            });
            
            // File upload functionality for Tab 1
            const dropArea = document.getElementById('dropArea');
            const fileInput = document.getElementById('htmlFileInput');
            const browseBtn = document.getElementById('browseBtn');
            const fileInfo = document.getElementById('fileInfo');
            const fileName = document.getElementById('fileName');
            const fileSize = document.getElementById('fileSize');
            const removeFile = document.getElementById('removeFile');
            const parseResults = document.getElementById('parseResults');
            const parseError = document.getElementById('parseError');
            const tableBody = document.getElementById('tableBody');
            const downloadExcel = document.getElementById('downloadExcel');
            
            // Prevent default drag behaviors
            ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
                dropArea.addEventListener(eventName, preventDefaults, false);
            });
            
            function preventDefaults(e) {
                e.preventDefault();
                e.stopPropagation();
            }
            
            // Highlight drop area when item is dragged over it
            ['dragenter', 'dragover'].forEach(eventName => {
                dropArea.addEventListener(eventName, highlight, false);
            });
            
            ['dragleave', 'drop'].forEach(eventName => {
                dropArea.addEventListener(eventName, unhighlight, false);
            });
            
            function highlight() {
                dropArea.classList.add('dragover');
            }
            
            function unhighlight() {
                dropArea.classList.remove('dragover');
            }
            
            // Handle dropped files
            dropArea.addEventListener('drop', handleDrop, false);
            
            function handleDrop(e) {
                const dt = e.dataTransfer;
                const files = dt.files;
                handleFiles(files);
            }
            
            // Handle file selection via browse button
            browseBtn.addEventListener('click', () => {
                fileInput.click();
            });
            
            fileInput.addEventListener('change', () => {
                if (fileInput.files.length) {
                    handleFiles(fileInput.files);
                }
            });
            
            // Remove selected file
            removeFile.addEventListener('click', () => {
                fileInput.value = '';
                fileInfo.classList.add('hidden');
                parseResults.classList.add('hidden');
                parseError.classList.add('hidden');
            });
            
            function handleFiles(files) {
                const file = files[0];
                
                // Display file info
                fileName.textContent = file.name;
                fileSize.textContent = formatFileSize(file.size);
                fileInfo.classList.remove('hidden');
                
                // Simulate parsing (in a real app, you would parse the actual HTML)
                setTimeout(() => {
                    // Randomly show success or error for demo purposes
                    if (Math.random() > 0.3) {
                        // Success case
                        parseResults.classList.remove('hidden');
                        parseError.classList.add('hidden');
                        
                        // Generate sample data
                        const sampleData = [
                            { khewat: '1', marba: '1', killa: '123', kanals: '', marlas: '', owner: 'John Doe', share: '1/2' },
                            { khewat: '1', marba: '1', killa: '124', kanals: '', marlas: '', owner: 'Jane Smith', share: '1/4' },
                            { khewat: '2', marba: '1', killa: '125', kanals: '', marlas: '', owner: 'Robert Johnson', share: '1/4' },
                            { khewat: '2', marba: '2', killa: '126', kanals: '', marlas: '', owner: 'Sarah Williams', share: '1/3' },
                            { khewat: '2', marba: '2', killa: '127', kanals: '', marlas: '', owner: 'Michael Brown', share: '2/3' }
                        ];
                        
                        // Populate table
                        tableBody.innerHTML = '';
                        sampleData.forEach(item => {
                            const row = document.createElement('tr');
                            row.innerHTML = `
                                <td class="py-2 px-4 border-b border-gray-200">${item.khewat}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.marba}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.killa}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.kanals}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.marlas}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.owner}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.share}</td>
                            `;
                            tableBody.appendChild(row);
                        });
                    } else {
                        // Error case
                        parseResults.classList.add('hidden');
                        parseError.classList.remove('hidden');
                    }
                }, 1000);
            }
            
            function formatFileSize(bytes) {
                if (bytes === 0) return '0 Bytes';
                const k = 1024;
                const sizes = ['Bytes', 'KB', 'MB', 'GB'];
                const i = Math.floor(Math.log(bytes) / Math.log(k));
                return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
            }
            
            // Download Excel button (demo - would generate actual Excel in real app)
            downloadExcel.addEventListener('click', () => {
                alert('In a real application, this would download an Excel file with the parsed data.');
            });
            
            // Tab 2 functionality - Parse raw text
            const parseTextBtn = document.getElementById('parseTextBtn');
            const rawTextInput = document.getElementById('rawTextInput');
            const pasteResults = document.getElementById('pasteResults');
            const pasteError = document.getElementById('pasteError');
            const pasteInfo = document.getElementById('pasteInfo');
            const pasteTableBody = document.getElementById('pasteTableBody');
            const downloadPasteExcel = document.getElementById('downloadPasteExcel');
            
            parseTextBtn.addEventListener('click', () => {
                const text = rawTextInput.value.trim();
                
                if (!text) {
                    pasteInfo.classList.remove('hidden');
                    pasteResults.classList.add('hidden');
                    pasteError.classList.add('hidden');
                    return;
                }
                
                // Simulate parsing (in a real app, you would parse the actual text)
                setTimeout(() => {
                    // Randomly show success or error for demo purposes
                    if (Math.random() > 0.3) {
                        // Success case
                        pasteResults.classList.remove('hidden');
                        pasteError.classList.add('hidden');
                        pasteInfo.classList.add('hidden');
                        
                        // Generate sample data from text
                        const lines = text.split('\n').filter(line => line.trim());
                        const sampleData = [];
                        
                        for (let i = 0; i < lines.length; i++) {
                            if (i % 2 === 0) {
                                // Owner line
                                const owner = lines[i].trim();
                                let share = '';
                                
                                // Check if next line is a share
                                if (i + 1 < lines.length && lines[i+1].includes('भाग')) {
                                    const shareMatch = lines[i+1].match(/(\d+\/\d+)/);
                                    if (shareMatch) {
                                        share = shareMatch[0];
                                    }
                                }
                                
                                sampleData.push({
                                    owner: owner,
                                    share: share
                                });
                            }
                        }
                        
                        // If no share lines found, just use all lines as owners
                        if (sampleData.length === 0) {
                            lines.forEach(line => {
                                sampleData.push({
                                    owner: line.trim(),
                                    share: ''
                                });
                            });
                        }
                        
                        // Populate table
                        pasteTableBody.innerHTML = '';
                        sampleData.forEach(item => {
                            const row = document.createElement('tr');
                            row.innerHTML = `
                                <td class="py-2 px-4 border-b border-gray-200">${item.owner}</td>
                                <td class="py-2 px-4 border-b border-gray-200">${item.share}</td>
                            `;
                            pasteTableBody.appendChild(row);
                        });
                    } else {
                        // Error case
                        pasteResults.classList.add('hidden');
                        pasteError.classList.remove('hidden');
                        pasteInfo.classList.add('hidden');
                    }
                }, 800);
            });
            
            // Download Excel button for paste results (demo)
            downloadPasteExcel.addEventListener('click', () => {
                alert('In a real application, this would download an Excel file with the parsed data.');
            });
            
            // Show/hide paste info based on input
            rawTextInput.addEventListener('input', () => {
                if (rawTextInput.value.trim()) {
                    pasteInfo.classList.add('hidden');
                } else {
                    pasteInfo.classList.remove('hidden');
                    pasteResults.classList.add('hidden');
                    pasteError.classList.add('hidden');
                }
            });
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=jasvir-singh1021/data-parser" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>