Spaces:
Running
Running
Vedika commited on
Update index.html
Browse files- index.html +698 -476
index.html
CHANGED
|
@@ -1,356 +1,502 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 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 |
</head>
|
| 184 |
-
<body>
|
| 185 |
|
|
|
|
| 186 |
<div id="toast-container"></div>
|
| 187 |
|
| 188 |
-
<
|
| 189 |
-
|
| 190 |
-
<
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
</div>
|
| 196 |
-
<button class="close-sidebar-btn" onclick="toggleSidebar()"><i class="fa-solid fa-xmark"></i></button>
|
| 197 |
-
</div>
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
<div class="user-details">
|
| 204 |
-
<div class="user-avatar" id="uAvatar">U</div>
|
| 205 |
-
<div class="user-email" id="uEmail">user@email.com</div>
|
| 206 |
-
</div>
|
| 207 |
-
<button class="btn-logout" onclick="logout()" title="Logout Account"><i class="fa-solid fa-power-off"></i></button>
|
| 208 |
-
</div>
|
| 209 |
-
</div>
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
</div>
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
-
<
|
| 219 |
-
|
| 220 |
-
<
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
</div>
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
<div class="input-row">
|
| 250 |
-
<!-- Universal File Attach -->
|
| 251 |
-
<button class="action-icon-btn" title="Attach File or Image">
|
| 252 |
-
<i class="fa-solid fa-paperclip"></i>
|
| 253 |
-
<input type="file" id="fileInput" accept="*/*" onchange="handleFile(this)">
|
| 254 |
-
</button>
|
| 255 |
-
|
| 256 |
-
<!-- Voice Input (Google Speech API) -->
|
| 257 |
-
<button class="action-icon-btn" id="voiceBtn" onclick="toggleVoice()" title="Voice Input">
|
| 258 |
-
<i class="fa-solid fa-microphone"></i>
|
| 259 |
-
</button>
|
| 260 |
-
|
| 261 |
-
<textarea class="chat-input" id="chatInput" placeholder="Type a message or use voice..." rows="1" oninput="autoGrow(this)" onkeydown="handleKey(event)"></textarea>
|
| 262 |
-
|
| 263 |
-
<button class="send-btn" id="sendBtn" onclick="sendMsg()">
|
| 264 |
-
<i class="fa-solid fa-paper-plane"></i>
|
| 265 |
-
</button>
|
| 266 |
-
</div>
|
| 267 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
</div>
|
|
|
|
|
|
|
| 269 |
</main>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
</div>
|
| 271 |
|
| 272 |
-
<!--
|
| 273 |
<div class="modal-overlay" id="authModal">
|
| 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 |
-
</div>
|
| 309 |
</div>
|
|
|
|
| 310 |
</div>
|
| 311 |
|
| 312 |
<script>
|
| 313 |
-
// ---
|
| 314 |
const GAS_URL = "https://script.google.com/macros/s/AKfycbzTsXGoVh97JjtFAAG825GF4WUZqf7FDB3Zbxyf0nrLXt_1HjJSSqA829UcdoamRPvg0A/exec";
|
| 315 |
-
const
|
| 316 |
|
| 317 |
-
// CACHE MEMORY (Persistent Login)
|
| 318 |
let currentUser = localStorage.getItem('arjun_user');
|
| 319 |
let guestCount = parseInt(localStorage.getItem('arjun_guest') || '0');
|
| 320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
// --- INITIALIZATION ---
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
if
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
document.getElementById('
|
| 328 |
}
|
| 329 |
-
|
| 330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
function showToast(msg) {
|
|
|
|
| 333 |
const t = document.createElement('div'); t.className = 'toast';
|
| 334 |
-
t.
|
| 335 |
-
|
| 336 |
setTimeout(() => t.remove(), 3000);
|
| 337 |
}
|
| 338 |
|
| 339 |
-
function
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
|
| 344 |
-
// --- AUTHENTICATION (
|
| 345 |
-
function
|
| 346 |
if (currentUser) {
|
| 347 |
-
document.getElementById('
|
| 348 |
document.getElementById('userProfile').style.display = 'flex';
|
| 349 |
document.getElementById('uEmail').innerText = currentUser;
|
| 350 |
document.getElementById('uAvatar').innerText = currentUser.charAt(0).toUpperCase();
|
| 351 |
document.getElementById('guestBadge').style.display = 'none';
|
| 352 |
} else {
|
| 353 |
-
document.getElementById('
|
| 354 |
document.getElementById('userProfile').style.display = 'none';
|
| 355 |
}
|
| 356 |
}
|
|
@@ -364,7 +510,7 @@ function switchAuthTab(tab) {
|
|
| 364 |
document.getElementById('flow-login').style.display = tab === 'login' ? 'block' : 'none';
|
| 365 |
document.getElementById('flow-register').style.display = tab === 'register' ? 'block' : 'none';
|
| 366 |
}
|
| 367 |
-
function
|
| 368 |
document.getElementById(curr).classList.remove('active');
|
| 369 |
document.getElementById(next).classList.add('active');
|
| 370 |
}
|
|
@@ -390,7 +536,7 @@ async function processAuth(action) {
|
|
| 390 |
}
|
| 391 |
|
| 392 |
const btn = document.getElementById(btnId); const ogText = btn.innerHTML;
|
| 393 |
-
btn.disabled = true; btn.
|
| 394 |
|
| 395 |
try {
|
| 396 |
const res = await fetch(GAS_URL, { method: 'POST', body: JSON.stringify(payload) });
|
|
@@ -398,12 +544,12 @@ async function processAuth(action) {
|
|
| 398 |
|
| 399 |
if (data.status === 'success') {
|
| 400 |
showToast(data.message);
|
| 401 |
-
if (action === 'register_send_otp')
|
| 402 |
-
else if (action === 'login_send_otp')
|
| 403 |
else if (action === 'register_verify' || action === 'login_verify') {
|
| 404 |
currentUser = payload.email;
|
| 405 |
-
localStorage.setItem('arjun_user', currentUser);
|
| 406 |
-
closeAuthModal();
|
| 407 |
}
|
| 408 |
} else showToast(data.message);
|
| 409 |
} catch (e) { showToast("Network Error."); }
|
|
@@ -411,6 +557,7 @@ async function processAuth(action) {
|
|
| 411 |
}
|
| 412 |
|
| 413 |
function logout() { localStorage.removeItem('arjun_user'); location.reload(); }
|
|
|
|
| 414 |
async function clearMemory() {
|
| 415 |
if(currentUser) {
|
| 416 |
showToast("Clearing Cloud History...");
|
|
@@ -419,197 +566,272 @@ async function clearMemory() {
|
|
| 419 |
location.reload();
|
| 420 |
}
|
| 421 |
|
|
|
|
| 422 |
async function fetchHistoryFromGAS() {
|
| 423 |
-
document.getElementById('
|
| 424 |
-
|
| 425 |
-
|
| 426 |
|
| 427 |
try {
|
| 428 |
const res = await fetch(GAS_URL, { method: 'POST', body: JSON.stringify({ action: "get_history", email: currentUser }) });
|
| 429 |
const data = await res.json();
|
| 430 |
-
|
| 431 |
if (data.status === 'success' && data.historyJSON !== "[]") {
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
}
|
| 438 |
|
| 439 |
function syncHistory() {
|
| 440 |
-
if(currentUser)
|
|
|
|
|
|
|
| 441 |
}
|
| 442 |
|
| 443 |
-
// ---
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
for (let i = event.resultIndex; i < event.results.length; ++i) { transcript += event.results[i][0].transcript; }
|
| 456 |
-
document.getElementById('chatInput').value = transcript; autoGrow(document.getElementById('chatInput'));
|
| 457 |
-
};
|
| 458 |
-
recognition.onend = () => { isRecording = false; document.getElementById('voiceBtn').classList.remove('recording'); };
|
| 459 |
-
recognition.onerror = () => { showToast("Voice recognition failed. Try again."); };
|
| 460 |
}
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
}
|
| 466 |
|
| 467 |
-
// ---
|
| 468 |
-
function
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
document.getElementById('fileThumb').innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i>';
|
| 474 |
-
document.getElementById('filePreview').classList.add('active');
|
| 475 |
-
|
| 476 |
-
// Categorize: Image vs Text vs Binary(PDF/Doc)
|
| 477 |
-
if (file.type.startsWith('image/')) {
|
| 478 |
-
reader.onload = (e) => {
|
| 479 |
-
STATE.pendingFile = { type: 'image', data: e.target.result, name: file.name };
|
| 480 |
-
document.getElementById('fileThumb').innerHTML = `<img src="${e.target.result}" style="width:100%; height:100%; border-radius:8px; object-fit:cover;">`;
|
| 481 |
-
document.getElementById('fileMeta').innerText = 'Image Ready';
|
| 482 |
-
};
|
| 483 |
-
reader.readAsDataURL(file);
|
| 484 |
-
} else if (file.type.match(/(text|json|csv|xml)/) || file.name.match(/\.(txt|md|csv|json)$/i)) {
|
| 485 |
-
reader.onload = (e) => {
|
| 486 |
-
STATE.pendingFile = { type: 'text', data: e.target.result, name: file.name };
|
| 487 |
-
document.getElementById('fileThumb').innerHTML = '<i class="fa-solid fa-file-code" style="color:var(--accent-blue)"></i>';
|
| 488 |
-
document.getElementById('fileMeta').innerText = 'Text Extracted';
|
| 489 |
-
};
|
| 490 |
-
reader.readAsText(file);
|
| 491 |
-
} else {
|
| 492 |
-
// Fallback for PDFs, DOCs (Sends as Base64. Actual parsing depends on AI backend capability)
|
| 493 |
-
reader.onload = (e) => {
|
| 494 |
-
STATE.pendingFile = { type: 'document', data: e.target.result, name: file.name };
|
| 495 |
-
document.getElementById('fileThumb').innerHTML = '<i class="fa-solid fa-file-pdf" style="color:var(--danger)"></i>';
|
| 496 |
-
document.getElementById('fileMeta').innerText = 'Document Ready';
|
| 497 |
-
};
|
| 498 |
-
reader.readAsDataURL(file);
|
| 499 |
-
}
|
| 500 |
}
|
| 501 |
-
function
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
const
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
const safeCode = encodeURIComponent(code);
|
| 510 |
-
return `<div style="position:relative;">
|
| 511 |
-
<button class="copy-btn" onclick="navigator.clipboard.writeText(decodeURIComponent('${safeCode}')).then(()=>{this.innerText='Copied!';setTimeout(()=>this.innerText='Copy Code',2000)})">Copy Code</button>
|
| 512 |
-
<pre><code class="hljs ${valid}">${highlighted}</code></pre>
|
| 513 |
-
</div>`;
|
| 514 |
-
};
|
| 515 |
-
marked.use({ renderer, breaks: true });
|
| 516 |
}
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
}
|
|
|
|
| 530 |
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
}
|
| 551 |
-
removeFile();
|
| 552 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
const botNode = appendMsg('<i class="fa-solid fa-circle-notch fa-spin"></i> Processing...', 'bot');
|
| 559 |
-
scrollChat();
|
| 560 |
-
|
| 561 |
-
const sysPrompt = "You are Arjun Compound, an advanced AI developed by Abhay Kumar. Always respond in English unless requested otherwise. To generate images, reply with ";
|
| 562 |
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
| 566 |
-
body: JSON.stringify({ message: backendPayloadMsg, system_prompt: sysPrompt, history: STATE.history.slice(0, -1) })
|
| 567 |
-
});
|
| 568 |
-
|
| 569 |
-
const reader = res.body.getReader();
|
| 570 |
-
const decoder = new TextDecoder();
|
| 571 |
-
let fullText = "";
|
| 572 |
-
|
| 573 |
-
while (true) {
|
| 574 |
-
const { done, value } = await reader.read();
|
| 575 |
-
if (done) break;
|
| 576 |
-
const lines = decoder.decode(value, {stream: true}).split('\n');
|
| 577 |
-
|
| 578 |
-
for (let line of lines) {
|
| 579 |
-
if (line.startsWith('data: ') && !line.includes('[DONE]')) {
|
| 580 |
-
try {
|
| 581 |
-
const dataObj = JSON.parse(line.substring(6));
|
| 582 |
-
if (dataObj.choices && dataObj.choices[0].delta.content) {
|
| 583 |
-
fullText += dataObj.choices[0].delta.content;
|
| 584 |
-
// Regex to clean up think tags if present
|
| 585 |
-
let cleanText = fullText.replace(/<think>[\s\S]*?(<\/think>|$)/gi, '');
|
| 586 |
-
botNode.querySelector('.msg-bubble').innerHTML = marked.parse(cleanText) + '<span style="display:inline-block;width:6px;height:12px;background:var(--accent-blue);animation:blink 1s infinite;"></span>';
|
| 587 |
-
scrollChat();
|
| 588 |
-
}
|
| 589 |
-
} catch (e) { }
|
| 590 |
-
}
|
| 591 |
-
}
|
| 592 |
-
}
|
| 593 |
-
|
| 594 |
-
let finalText = fullText.replace(/<think>[\s\S]*?(<\/think>|$)/gi, '');
|
| 595 |
-
botNode.querySelector('.msg-bubble').innerHTML = marked.parse(finalText);
|
| 596 |
-
STATE.history.push({ role: 'bot', content: fullText });
|
| 597 |
-
syncHistory();
|
| 598 |
|
| 599 |
-
|
| 600 |
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
}
|
| 603 |
|
| 604 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
|
| 606 |
-
function
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
}
|
|
|
|
|
|
|
| 613 |
</script>
|
| 614 |
</body>
|
| 615 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
+
<title>Arjun Compound - Advanced AI</title>
|
| 7 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap" rel="stylesheet">
|
| 9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
|
| 10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
| 11 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.1/marked.min.js"></script>
|
| 12 |
+
<style>
|
| 13 |
+
/* --- BASE RESET & VARIABLES --- */
|
| 14 |
+
*{margin:0;padding:0;box-sizing:border-box;}
|
| 15 |
+
:root{
|
| 16 |
+
--bg-color: #ffffff; --bg-secondary: #f9f9fb; --text-main: #1d1d1f; --text-muted: #86868b;
|
| 17 |
+
--accent: #FF9933; --accent-green: #138808; --accent-hover: #e68a2e;
|
| 18 |
+
--border-light: rgba(0, 0, 0, 0.08); --border-focus: rgba(255, 153, 51, 0.3);
|
| 19 |
+
--glass-bg: rgba(255, 255, 255, 0.85); --glass-border: rgba(255, 255, 255, 0.4);
|
| 20 |
+
--shadow-sm: 0 2px 8px rgba(0,0,0,0.04); --shadow-md: 0 8px 32px rgba(0,0,0,0.08);
|
| 21 |
+
--shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
|
| 22 |
+
--font-serif: 'Instrument Serif', serif; --font-sans: 'Inter', -apple-system, sans-serif;
|
| 23 |
+
--font-mono: 'Geist Mono', monospace;
|
| 24 |
+
--radius-lg: 24px; --radius-md: 16px; --radius-sm: 8px;
|
| 25 |
+
}
|
| 26 |
+
html,body{height:100%;overflow:hidden;background:var(--bg-color);color:var(--text-main);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;}
|
| 27 |
+
|
| 28 |
+
/* --- BACKGROUND --- */
|
| 29 |
+
.bg{position:fixed;inset:0;z-index:0;overflow:hidden;pointer-events:none;background: linear-gradient(135deg, rgba(255,153,51,0.05) 0%, rgba(255,255,255,1) 50%, rgba(19,136,8,0.05) 100%);}
|
| 30 |
+
.orb{position:absolute;border-radius:50%;filter:blur(100px);opacity:0.5;animation:drift 25s ease-in-out infinite alternate;}
|
| 31 |
+
.orb1{width:600px;height:600px;background:radial-gradient(circle,rgba(255,153,51,0.2),transparent 70%);top:-150px;left:-100px;}
|
| 32 |
+
.orb2{width:500px;height:500px;background:radial-gradient(circle,rgba(19,136,8,0.18),transparent 70%);bottom:-100px;right:-100px;animation-delay:-10s;}
|
| 33 |
+
@keyframes drift{0%{transform:translate(0,0) scale(1);}100%{transform:translate(60px,40px) scale(1.05);}}
|
| 34 |
+
|
| 35 |
+
/* --- TOAST NOTIFICATION --- */
|
| 36 |
+
#toast-container { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
|
| 37 |
+
.toast { background: var(--text-main); color: #fff; padding: 12px 24px; border-radius: 50px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); animation: slideDownFade 0.4s ease; }
|
| 38 |
+
@keyframes slideDownFade { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
|
| 39 |
+
|
| 40 |
+
/* --- GET STARTED OVERLAY --- */
|
| 41 |
+
.welcome-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; transition: opacity 0.4s ease; }
|
| 42 |
+
.welcome-overlay.hidden { opacity: 0; pointer-events: none; }
|
| 43 |
+
.welcome-overlay img { width: 120px; height: 120px; border-radius: 28px; object-fit: cover; box-shadow: var(--shadow-lg); margin-bottom: 24px; border: 1px solid var(--border-light); }
|
| 44 |
+
.welcome-overlay h1 { font-family: var(--font-sans); font-size: 36px; font-weight: 800; color: var(--text-main); letter-spacing: -1px; margin-bottom: 12px; }
|
| 45 |
+
.welcome-overlay p { font-size: 16px; color: var(--text-muted); line-height: 1.6; max-width: 450px; margin-bottom: 36px; }
|
| 46 |
+
.start-btn { padding: 16px 40px; background: var(--text-main); color: #fff; border: none; border-radius: 16px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
|
| 47 |
+
.start-btn:hover { background: #333; transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.2); }
|
| 48 |
+
|
| 49 |
+
/* --- MAIN LAYOUT (CHAT + WORKSPACE) --- */
|
| 50 |
+
.shell{position:relative;z-index:1;display:flex;height:100vh;width:100vw;overflow:hidden;}
|
| 51 |
+
.sidebar{width:280px;display:flex;flex-direction:column;background:var(--bg-secondary);border-right:1px solid var(--border-light);flex-shrink:0;z-index:100; transition: left 0.3s ease;}
|
| 52 |
+
.main-wrapper{flex:1;display:flex;position:relative;overflow:hidden;}
|
| 53 |
+
.chat-main{flex:1;display:flex;flex-direction:column;background:transparent;position:relative;min-width:300px;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);}
|
| 54 |
+
.workspace{width:0;background:#fafafa;border-left:1px solid var(--border-light);display:flex;flex-direction:column;transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);overflow:hidden;box-shadow:-10px 0 30px rgba(0,0,0,0.02);z-index:25;}
|
| 55 |
+
.workspace.open{width:50%;}
|
| 56 |
+
|
| 57 |
+
/* --- SIDEBAR & BRANDING --- */
|
| 58 |
+
.logo-area{padding:24px 20px;border-bottom:1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center;}
|
| 59 |
+
.logo-row{display:flex;align-items:center;gap:12px;}
|
| 60 |
+
.logo-img{width:44px;height:44px;border-radius:12px;object-fit:cover;box-shadow:var(--shadow-sm);border:1px solid var(--border-light);background:#fff;}
|
| 61 |
+
.logo-text{line-height:1.2;}
|
| 62 |
+
.logo-name{font-family:var(--font-sans);font-weight:800;font-size:16px;color:var(--text-main);letter-spacing:-0.5px;}
|
| 63 |
+
.logo-sub{font-size:10px;font-weight:600;letter-spacing:1px;text-transform:uppercase;color:var(--text-muted);}
|
| 64 |
+
.close-sidebar-btn { display: none; background: none; border: none; font-size: 20px; color: var(--text-main); cursor: pointer; }
|
| 65 |
+
|
| 66 |
+
/* Auth Block in Sidebar */
|
| 67 |
+
.auth-block { padding: 20px; border-bottom: 1px solid var(--border-light); }
|
| 68 |
+
.user-profile { display: none; align-items: center; gap: 10px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
|
| 69 |
+
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--text-main); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
|
| 70 |
+
.user-email { flex: 1; font-size: 12px; font-weight: 600; color: var(--text-main); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
|
| 71 |
+
.logout-btn { background: none; border: none; color: #ff3b30; cursor: pointer; font-size: 16px; padding: 4px; }
|
| 72 |
+
.login-prompt-btn { width: 100%; padding: 12px; border-radius: 12px; background: var(--text-main); color: #fff; border: none; font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
|
| 73 |
+
.login-prompt-btn:hover { background: #333; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
|
| 74 |
+
|
| 75 |
+
.settings{padding:20px;flex:1;overflow-y:auto;display:flex;flex-direction:column;gap: 20px;}
|
| 76 |
+
.settings::-webkit-scrollbar{width:4px;}
|
| 77 |
+
.settings::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 78 |
+
|
| 79 |
+
.toggle-wrapper {display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 16px; border-radius: 12px; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm);}
|
| 80 |
+
.toggle-label {font-size: 13px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px;}
|
| 81 |
+
.toggle-label span {font-size: 11px; color: var(--text-muted); font-weight: 500; display: block; margin-top: 2px;}
|
| 82 |
+
.switch {position: relative; display: inline-block; width: 44px; height: 24px;}
|
| 83 |
+
.switch input {opacity: 0; width: 0; height: 0;}
|
| 84 |
+
.slider {position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #e5e5ea; transition: .4s; border-radius: 24px;}
|
| 85 |
+
.slider:before {position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);}
|
| 86 |
+
input:checked + .slider {background-color: var(--accent-green);}
|
| 87 |
+
input:checked + .slider:before {transform: translateX(20px);}
|
| 88 |
+
|
| 89 |
+
.brand-box {background: #ffffff;border: 1px solid var(--border-light);border-radius: var(--radius-md);padding: 24px 16px;text-align: center;box-shadow: var(--shadow-sm);margin-top:auto;}
|
| 90 |
+
.brand-box img {width: 70px; height: 70px; border-radius: 16px; object-fit: cover; margin-bottom: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light);}
|
| 91 |
+
.brand-box h3 {font-family: var(--font-sans); font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 6px;}
|
| 92 |
+
.brand-box p {font-size: 10px; font-weight: 600; color: var(--accent-green); line-height: 1.4; letter-spacing: 0.5px;}
|
| 93 |
+
|
| 94 |
+
.clear-btn{width:100%;padding:12px;border-radius:var(--radius-sm);background:#ffffff;border:1px solid var(--border-light);color:var(--text-main);font-size:13px;font-weight:600;cursor:pointer;transition:all 0.2s;}
|
| 95 |
+
.clear-btn:hover{background:#fff0f0;color:#ff3b30;border-color:#ff3b30;}
|
| 96 |
+
|
| 97 |
+
/* --- CHAT AREA --- */
|
| 98 |
+
.chat-hdr{padding:14px 24px;border-bottom:1px solid var(--border-light);background:var(--glass-bg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);display:flex;align-items:center;z-index:10;}
|
| 99 |
+
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; color: var(--text-main); cursor: pointer; margin-right: 16px; }
|
| 100 |
+
.model-badge{font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;}
|
| 101 |
+
.status-dot{width:8px;height:8px;border-radius:50%;background:#34c759;box-shadow:0 0 0 2px rgba(52,199,89,0.2);}
|
| 102 |
+
.messages{flex:1;overflow-y:auto;padding:30px 40px;display:flex;flex-direction:column;gap:24px;scroll-behavior:smooth;position:relative;}
|
| 103 |
+
.messages::-webkit-scrollbar{width:6px;}
|
| 104 |
+
.messages::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.1);border-radius:10px;}
|
| 105 |
+
|
| 106 |
+
/* Welcome Screen & Prompts */
|
| 107 |
+
.welcome{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:40px 20px;margin:auto;animation:fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;width:100%;max-width:650px;}
|
| 108 |
+
@keyframes fadeInUp{from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:none;}}
|
| 109 |
+
.welcome-logo{width:80px;height:80px;border-radius:24px;object-fit:cover;box-shadow:var(--shadow-md);margin-bottom:24px;border:1px solid var(--border-light);}
|
| 110 |
+
.welcome-title{font-size:32px;font-weight:800;letter-spacing:-1px;margin-bottom:12px;}
|
| 111 |
+
.welcome-sub{font-size:15px;color:var(--text-muted);line-height:1.6;margin-bottom:20px;max-width: 500px;}
|
| 112 |
+
.guest-badge { background: #fff0f0; color: #ff3b30; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; margin-bottom: 24px; border: 1px solid #ffcccb; display: none; }
|
| 113 |
+
|
| 114 |
+
.ex-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;width:100%;}
|
| 115 |
+
.ex-card{background:var(--glass-bg);backdrop-filter:blur(10px);border:1px solid var(--border-light);border-radius:var(--radius-md);padding:16px;cursor:pointer;text-align:left;transition:all 0.2s;box-shadow:var(--shadow-sm);}
|
| 116 |
+
.ex-card:hover{transform:translateY(-3px);box-shadow:var(--shadow-md);border-color:var(--accent);}
|
| 117 |
+
.ex-title{font-size:13px;font-weight:600;color:var(--text-main);margin-bottom:4px;display:flex;align-items:center;gap:6px;}
|
| 118 |
+
.ex-desc{font-size:12px;color:var(--text-muted);line-height:1.4;}
|
| 119 |
+
|
| 120 |
+
/* Messages */
|
| 121 |
+
.msg{display:flex;gap:16px;animation:msgIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;max-width:85%;}
|
| 122 |
+
@keyframes msgIn{from{opacity:0;transform:translateY(15px) scale(0.96);}to{opacity:1;transform:none;}}
|
| 123 |
+
.msg.user{flex-direction:row-reverse;align-self:flex-end;}
|
| 124 |
+
.msg.bot{align-self:flex-start;}
|
| 125 |
+
.avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;overflow:hidden;}
|
| 126 |
+
.msg.user .avatar{background:#f0f0f0;color:var(--text-main);border:1px solid var(--border-light);}
|
| 127 |
+
.msg.bot .avatar{border:1px solid var(--border-light);background:#fff;padding:2px;}
|
| 128 |
+
.msg.bot .avatar img{width:100%;height:100%;border-radius:50%;object-fit:cover;}
|
| 129 |
+
.body{display:flex;flex-direction:column;gap:6px;max-width:100%; width: 100%;}
|
| 130 |
+
.msg.user .body{align-items:flex-end;}
|
| 131 |
+
|
| 132 |
+
.bubble{padding:16px 20px;font-size:15px;line-height:1.6;color:var(--text-main);position:relative;word-break:break-word;overflow-wrap:anywhere;}
|
| 133 |
+
.msg.user .bubble{background:var(--text-main);color:#ffffff;border-radius:20px 20px 4px 20px;box-shadow:var(--shadow-sm);}
|
| 134 |
+
.msg.bot .bubble{background:#ffffff;border:1px solid var(--border-light);border-radius:4px 20px 20px 20px;box-shadow:var(--shadow-sm);width:100%;}
|
| 135 |
+
|
| 136 |
+
/* BOT ACTIONS (Copy Button below text) */
|
| 137 |
+
.msg-actions{display:flex;gap:8px;margin-top:4px;padding-left:12px;opacity:0.7;transition:opacity 0.2s;}
|
| 138 |
+
.msg.bot:hover .msg-actions{opacity:1;}
|
| 139 |
+
.action-btn{background:var(--bg-secondary);border:1px solid var(--border-light);color:var(--text-main);font-size:12px;font-weight:500;cursor:pointer;display:flex;align-items:center;gap:6px;padding:6px 12px;border-radius:8px;transition:all 0.2s;}
|
| 140 |
+
.action-btn:hover{background:#e5e5ea;transform:translateY(-1px);}
|
| 141 |
+
|
| 142 |
+
/* Reasoning / Thinking Box */
|
| 143 |
+
.think-box {background: #fdfdfd;border: 1px solid var(--border-light);border-left: 4px solid var(--accent-green);border-radius: 8px;padding: 14px 16px;margin-bottom: 16px;font-family: var(--font-mono);font-size: 13.5px;color: var(--text-muted);line-height: 1.5;box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);}
|
| 144 |
+
.think-title {font-weight: 600; color: var(--text-main); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-family: var(--font-sans);}
|
| 145 |
+
body:not(.show-thinking) .think-box {display: none;}
|
| 146 |
+
|
| 147 |
+
/* Markdown inside bubble */
|
| 148 |
+
.bubble p{margin-bottom:12px;}
|
| 149 |
+
.bubble p:last-child{margin-bottom:0;}
|
| 150 |
+
.bubble code{font-family:var(--font-mono);background:rgba(0,0,0,0.05);padding:3px 6px;border-radius:6px;font-size:0.85em;color:#e83e8c;}
|
| 151 |
+
.msg.user .bubble code{background:rgba(255,255,255,0.2);color:#fff;}
|
| 152 |
+
.bubble img{max-width:100%;border-radius:12px;margin:10px 0;box-shadow:var(--shadow-sm);border:1px solid var(--border-light);}
|
| 153 |
+
.bubble pre {display: none;}
|
| 154 |
+
|
| 155 |
+
/* Workspace Trigger Card in Chat */
|
| 156 |
+
.ws-trigger-card {background: var(--bg-secondary);border: 1px solid var(--border-light);border-radius: 12px;padding: 16px;margin: 12px 0;display: flex;align-items: center;justify-content: space-between;box-shadow: inset 0 1px 2px rgba(255,255,255,0.5);}
|
| 157 |
+
.ws-trigger-info {display: flex;align-items: center;gap: 12px;}
|
| 158 |
+
.ws-trigger-icon {width: 44px;height: 44px;border-radius: 10px;background: #fff;display: flex;align-items: center;justify-content: center;font-size: 22px;box-shadow: var(--shadow-sm);border: 1px solid var(--border-light);}
|
| 159 |
+
.ws-trigger-text h4 {font-size: 14px;font-weight: 600;margin-bottom: 2px;}
|
| 160 |
+
.ws-trigger-text p {font-size: 12px;color: var(--text-muted);font-family: var(--font-mono);text-transform: uppercase;}
|
| 161 |
+
.ws-btn {padding: 8px 16px;background: var(--text-main);color: #fff;border: none;border-radius: 8px;font-size: 13px;font-weight: 600;cursor: pointer;transition: all 0.2s;}
|
| 162 |
+
.ws-btn:hover {transform: scale(1.05); background: var(--accent);}
|
| 163 |
+
|
| 164 |
+
/* Typing & Cursor */
|
| 165 |
+
.blinking-cursor {display: inline-block; width: 8px; height: 16px; background: var(--accent); margin-left: 4px; animation: blink 1s step-end infinite; vertical-align: middle;}
|
| 166 |
+
@keyframes blink { 50% { opacity: 0; } }
|
| 167 |
+
.typing{display:flex;align-items:center;gap:6px;padding:4px;}
|
| 168 |
+
.typing span{width:6px;height:6px;border-radius:50%;background:var(--text-muted);opacity:0.4;animation:bounce 1.4s infinite ease-in-out both;}
|
| 169 |
+
.typing span:nth-child(1){animation-delay:-0.32s;}.typing span:nth-child(2){animation-delay:-0.16s;}
|
| 170 |
+
@keyframes bounce{0%,80%,100%{transform:scale(0);}40%{transform:scale(1);}}
|
| 171 |
+
|
| 172 |
+
/* --- SCROLL TO BOTTOM BUTTON --- */
|
| 173 |
+
.scroll-bottom-btn {position:absolute;bottom:120px;left:50%;width:44px;height:44px;border-radius:50%;background:var(--glass-bg);backdrop-filter:blur(10px);border:1px solid var(--border-light);box-shadow:var(--shadow-md);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:18px;color:var(--text-main);opacity:0;pointer-events:none;transform:translateX(-50%) translateY(20px);transition:all 0.3s cubic-bezier(0.4, 0, 0.2, 1);z-index:20;}
|
| 174 |
+
.scroll-bottom-btn.show {opacity:1;pointer-events:auto;transform:translateX(-50%) translateY(0);}
|
| 175 |
+
.scroll-bottom-btn:hover {background:#fff;transform:translateX(-50%) translateY(-3px);box-shadow:var(--shadow-lg);}
|
| 176 |
+
|
| 177 |
+
/* --- INPUT AREA --- */
|
| 178 |
+
.input-container{padding:0 40px 30px;background:linear-gradient(to top, var(--bg-color) 70%, transparent);position:relative;z-index:20;}
|
| 179 |
+
.input-wrap{display:flex;flex-direction:column;background:var(--glass-bg);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border:1px solid var(--border-light);border-radius:24px;box-shadow:var(--shadow-md);transition:box-shadow 0.3s, border-color 0.3s;}
|
| 180 |
+
.input-wrap:focus-within{border-color:var(--border-focus);box-shadow:0 12px 40px rgba(0,0,0,0.1), 0 0 0 3px rgba(255,153,51,0.1);}
|
| 181 |
+
|
| 182 |
+
.img-prev-inline{display:none;padding:12px 20px 0;align-items:center;gap:12px;}
|
| 183 |
+
.img-prev-inline.show{display:flex;animation:fadeIn 0.3s;}
|
| 184 |
+
.inline-th{width:40px;height:40px;object-fit:cover;border-radius:8px;border:1px solid var(--border-light);}
|
| 185 |
+
.inline-info{flex:1;}
|
| 186 |
+
.inline-nm{font-size:12px;font-weight:600;color:var(--text-main);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;}
|
| 187 |
+
.inline-rm{background:rgba(0,0,0,0.05);border:none;width:24px;height:24px;border-radius:50%;cursor:pointer;font-size:10px;display:flex;align-items:center;justify-content:center;transition:background 0.2s;}
|
| 188 |
+
.inline-rm:hover{background:#ff3b30;color:#fff;}
|
| 189 |
+
|
| 190 |
+
.input-row{display:flex;align-items:flex-end;gap:12px;padding:12px 16px 12px 20px;}
|
| 191 |
+
.chat-ta{flex:1;border:none;outline:none;background:transparent;font-family:var(--font-sans);font-size:15px;color:var(--text-main);line-height:1.5;resize:none;max-height:200px;min-height:24px;padding:8px 0;}
|
| 192 |
+
.chat-ta::placeholder{color:var(--text-muted);}
|
| 193 |
+
|
| 194 |
+
.attach-btn{width:38px;height:38px;border-radius:12px;background:transparent;border:1px solid transparent;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--text-muted);transition:all 0.2s;position:relative;overflow:hidden;padding-bottom:4px;}
|
| 195 |
+
.attach-btn:hover{background:rgba(0,0,0,0.04);color:var(--text-main);}
|
| 196 |
+
.attach-btn input{position:absolute;inset:0;opacity:0;cursor:pointer;}
|
| 197 |
+
.attach-btn svg{width:20px;height:20px;}
|
| 198 |
+
|
| 199 |
+
.send-btn{width:42px;height:42px;border-radius:14px;border:none;background:linear-gradient(135deg, #FF9933 0%, #ffffff 50%, #138808 100%);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all 0.3s;box-shadow:0 4px 12px rgba(0,0,0,0.1);}
|
| 200 |
+
.send-btn svg{width:18px;height:18px;fill:#1d1d1f;transition:transform 0.2s;}
|
| 201 |
+
.send-btn:hover{box-shadow:0 6px 16px rgba(255,153,51,0.3);transform:translateY(-1px);}
|
| 202 |
+
.send-btn:hover svg{transform:translate(2px, -2px);}
|
| 203 |
+
.send-btn:disabled{opacity:0.4;cursor:not-allowed;filter:grayscale(100%);transform:none;}
|
| 204 |
+
.input-hint{text-align:center;font-size:11px;color:var(--text-muted);margin-top:12px;font-weight:500;}
|
| 205 |
+
|
| 206 |
+
/* --- WORKSPACE PANEL --- */
|
| 207 |
+
.ws-hdr{padding:14px 20px;border-bottom:1px solid var(--border-light);background:#fff;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;}
|
| 208 |
+
.ws-title{font-size:14px;font-weight:600;display:flex;align-items:center;gap:8px;}
|
| 209 |
+
.ws-actions{display:flex;gap:8px;}
|
| 210 |
+
.ws-icon-btn{padding:6px 12px;border-radius:8px;background:var(--bg-secondary);border:1px solid var(--border-light);cursor:pointer;display:flex;align-items:center;gap:6px;color:var(--text-main);transition:all 0.2s;font-size:12px;font-weight:600;}
|
| 211 |
+
.ws-icon-btn:hover{background:#e5e5ea;}
|
| 212 |
+
.ws-close{padding:6px;background:transparent;border-color:transparent;}
|
| 213 |
+
.ws-close:hover{color:#ff3b30;background:#fff0f0;}
|
| 214 |
+
.ws-content{flex:1;overflow-y:auto;background:#fafafa;padding:20px;}
|
| 215 |
+
.ws-content pre{margin:0;padding:20px;background:#fff;border:1px solid var(--border-light);border-radius:12px;font-family:var(--font-mono);font-size:14px;line-height:1.6;overflow-x:auto;box-shadow:var(--shadow-sm);}
|
| 216 |
+
|
| 217 |
+
/* --- AUTH MODAL (GAS) --- */
|
| 218 |
+
.modal-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 5000; display: none; justify-content: center; align-items: center; animation: fadeIn 0.3s ease; }
|
| 219 |
+
.modal-card { background: #fff; padding: 32px 36px; border-radius: 24px; width: 90%; max-width: 420px; border: 1px solid var(--border-light); box-shadow: var(--shadow-lg); position: relative; }
|
| 220 |
+
.close-modal { position: absolute; top: 20px; right: 20px; background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; transition: 0.2s;}
|
| 221 |
+
.close-modal:hover { color: var(--text-main); transform: rotate(90deg); }
|
| 222 |
+
.auth-header { text-align: center; margin-bottom: 24px; }
|
| 223 |
+
.auth-header h2 { font-family: var(--font-sans); font-size: 24px; font-weight: 800; color: var(--text-main); }
|
| 224 |
+
.auth-tabs { display: flex; background: var(--bg-secondary); padding: 4px; border-radius: 12px; margin-bottom: 24px; }
|
| 225 |
+
.auth-tab { flex: 1; padding: 10px; text-align: center; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: 0.3s; }
|
| 226 |
+
.auth-tab.active { background: #fff; color: var(--text-main); box-shadow: var(--shadow-sm); }
|
| 227 |
+
.auth-step { display: none; flex-direction: column; animation: slideIn 0.3s ease; }
|
| 228 |
+
.auth-step.active { display: flex; }
|
| 229 |
+
.input-group { margin-bottom: 16px; }
|
| 230 |
+
.modal-card input { width: 100%; padding: 14px 16px; border: 1px solid var(--border-light); border-radius: 12px; font-size: 15px; outline: none; background: #fafafa; transition: 0.3s; font-family: var(--font-sans); }
|
| 231 |
+
.modal-card input:focus { border-color: var(--text-main); background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
|
| 232 |
+
.primary-btn { width: 100%; padding: 14px; background: var(--text-main); color: #fff; border: none; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; transition: 0.2s; margin-top: 8px; }
|
| 233 |
+
.primary-btn:hover { background: #333; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
|
| 234 |
+
.secondary-btn { width: 100%; padding: 12px; background: transparent; color: var(--text-muted); border: none; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 4px; }
|
| 235 |
+
.secondary-btn:hover { color: var(--text-main); }
|
| 236 |
+
|
| 237 |
+
/* --- RESPONSIVE MOBILE ADAPTIVE --- */
|
| 238 |
+
@media(max-width:850px){
|
| 239 |
+
.sidebar{position:absolute;left:-280px;z-index:100;height:100%;transition:left 0.3s ease;}
|
| 240 |
+
.sidebar.show{left:0;box-shadow:var(--shadow-lg);}
|
| 241 |
+
.mobile-menu-btn { display: block; }
|
| 242 |
+
.close-sidebar-btn { display: block; }
|
| 243 |
+
.workspace.open{position:absolute;top:0;left:0;width:100%;height:100%;z-index:50;}
|
| 244 |
+
.messages{padding:20px;}
|
| 245 |
+
.input-container{padding:0 20px 20px;}
|
| 246 |
+
.msg{max-width:95%;}
|
| 247 |
+
.scroll-bottom-btn{bottom:110px;}
|
| 248 |
+
}
|
| 249 |
+
</style>
|
| 250 |
</head>
|
| 251 |
+
<body class="show-thinking">
|
| 252 |
|
| 253 |
+
<!-- TOAST NOTIFICATION -->
|
| 254 |
<div id="toast-container"></div>
|
| 255 |
|
| 256 |
+
<!-- GET STARTED WELCOME OVERLAY -->
|
| 257 |
+
<div class="welcome-overlay" id="welcomeOverlay">
|
| 258 |
+
<img src="https://i.ibb.co/0y2sdbq6/PT-20260523-133251-0000.png" alt="Arjun Logo">
|
| 259 |
+
<h1>Welcome to Arjun Compound</h1>
|
| 260 |
+
<p>Developed by Abhay Kumar. Experience advanced reasoning, secure workspace coding, and high-quality image generation in one place.</p>
|
| 261 |
+
<button class="start-btn" onclick="startArjunApp()">Get Started</button>
|
| 262 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
+
<div class="bg">
|
| 265 |
+
<div class="orb orb1"></div>
|
| 266 |
+
<div class="orb orb2"></div>
|
| 267 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
<div class="shell">
|
| 270 |
+
<!-- Sidebar -->
|
| 271 |
+
<aside class="sidebar" id="sidebar">
|
| 272 |
+
<div class="logo-area">
|
| 273 |
+
<div class="logo-row">
|
| 274 |
+
<img src="https://i.ibb.co/0y2sdbq6/PT-20260523-133251-0000.png" alt="Arjun Logo" class="logo-img">
|
| 275 |
+
<div class="logo-text">
|
| 276 |
+
<div class="logo-name">ARJUN COMPOUND</div>
|
| 277 |
+
<div class="logo-sub">Advanced Edition</div>
|
| 278 |
</div>
|
| 279 |
+
</div>
|
| 280 |
+
<button class="close-sidebar-btn" onclick="toggleSidebar()">✕</button>
|
| 281 |
+
</div>
|
| 282 |
+
|
| 283 |
+
<!-- AUTH BLOCK -->
|
| 284 |
+
<div class="auth-block">
|
| 285 |
+
<button id="loginPromptBtn" class="login-prompt-btn" onclick="openAuthModal()">🔒 Secure Login</button>
|
| 286 |
+
<div id="userProfile" class="user-profile">
|
| 287 |
+
<div class="user-avatar" id="uAvatar">U</div>
|
| 288 |
+
<div class="user-email" id="uEmail">user@email.com</div>
|
| 289 |
+
<button class="logout-btn" onclick="logout()" title="Logout">🚪</button>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
|
| 293 |
+
<div class="settings">
|
| 294 |
+
<div class="toggle-wrapper">
|
| 295 |
+
<div class="toggle-label">🧠 Reasoning Mode<span>Show internal thinking</span></div>
|
| 296 |
+
<label class="switch">
|
| 297 |
+
<input type="checkbox" id="thinkingToggle" checked onchange="toggleThinking(this)">
|
| 298 |
+
<span class="slider"></span>
|
| 299 |
+
</label>
|
| 300 |
+
</div>
|
| 301 |
+
|
| 302 |
+
<div class="brand-box">
|
| 303 |
+
<img src="https://i.ibb.co/0y2sdbq6/PT-20260523-133251-0000.png" alt="Arjun Identity">
|
| 304 |
+
<h3>Arjun Compound</h3>
|
| 305 |
+
<p>DEVELOPED BY ABHAY KUMAR</p>
|
| 306 |
+
</div>
|
| 307 |
+
<button class="clear-btn" onclick="clearMemory()">🗑️ Clear Chat Memory</button>
|
| 308 |
+
</div>
|
| 309 |
+
</aside>
|
| 310 |
+
|
| 311 |
+
<!-- Main Chat Area -->
|
| 312 |
+
<div class="main-wrapper">
|
| 313 |
+
<main class="chat-main" id="chatMain">
|
| 314 |
+
<header class="chat-hdr">
|
| 315 |
+
<button class="mobile-menu-btn" onclick="toggleSidebar()">☰</button>
|
| 316 |
+
<div class="model-badge">
|
| 317 |
+
<div class="status-dot"></div>
|
| 318 |
+
Arjun Intelligence
|
| 319 |
+
</div>
|
| 320 |
+
<div style="width:24px;"></div> <!-- Spacer for flex balance -->
|
| 321 |
+
</header>
|
| 322 |
+
|
| 323 |
+
<div class="messages" id="msgs" onscroll="checkScroll()">
|
| 324 |
+
<!-- Inner Chat Welcome Screen -->
|
| 325 |
+
<div class="welcome" id="welcome">
|
| 326 |
+
<img src="https://i.ibb.co/0y2sdbq6/PT-20260523-133251-0000.png" alt="Arjun Logo" class="welcome-logo">
|
| 327 |
+
<div class="welcome-title">Welcome, User!</div>
|
| 328 |
+
<div class="welcome-sub">I am Arjun Compound, developed by Abhay Kumar. I am equipped with advanced reasoning, workspace coding, and image generation.</div>
|
| 329 |
+
|
| 330 |
+
<div id="guestBadge" class="guest-badge">Guest Mode: <span id="guestCountDisplay">0</span>/3 Queries Used.</div>
|
| 331 |
+
|
| 332 |
+
<div class="ex-grid">
|
| 333 |
+
<div class="ex-card" onclick="sendEx('Write a python script for a simple HTTP server. Provide the code.')">
|
| 334 |
+
<div class="ex-title">💻 Code Generation</div>
|
| 335 |
+
<div class="ex-desc">Generate secure, workspace-ready code</div>
|
| 336 |
</div>
|
| 337 |
+
<div class="ex-card" onclick="sendEx('Create an image of a futuristic Indian city with flying cars, highly detailed, 8k resolution.')">
|
| 338 |
+
<div class="ex-title">🎨 Generate Images</div>
|
| 339 |
+
<div class="ex-desc">Stunning visuals using Pollinations AI</div>
|
| 340 |
+
</div>
|
| 341 |
+
</div>
|
| 342 |
</div>
|
| 343 |
+
</div>
|
| 344 |
+
|
| 345 |
+
<button class="scroll-bottom-btn" id="scrollBtn" onclick="forceScrollDown()">
|
| 346 |
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>
|
| 347 |
+
</button>
|
| 348 |
+
|
| 349 |
+
<!-- Input Area -->
|
| 350 |
+
<div class="input-container">
|
| 351 |
+
<div class="input-wrap">
|
| 352 |
+
<div class="img-prev-inline" id="imgPrev">
|
| 353 |
+
<img class="inline-th" id="imgThumb" src="">
|
| 354 |
+
<div class="inline-info">
|
| 355 |
+
<div class="inline-nm" id="imgName">image.png</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
</div>
|
| 357 |
+
<button class="inline-rm" onclick="removeImg()">✕</button>
|
| 358 |
+
</div>
|
| 359 |
+
|
| 360 |
+
<div class="input-row">
|
| 361 |
+
<button class="attach-btn" title="Upload Image">
|
| 362 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>
|
| 363 |
+
<input type="file" accept="image/*" onchange="handleFile(this)" id="fileInput">
|
| 364 |
+
</button>
|
| 365 |
+
<textarea class="chat-ta" id="chatInput" placeholder="Message Arjun Compound..." rows="1" onkeydown="handleKey(event)" oninput="autoGrow(this)"></textarea>
|
| 366 |
+
<button class="send-btn" id="sendBtn" onclick="sendMsg()">
|
| 367 |
+
<svg viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>
|
| 368 |
+
</button>
|
| 369 |
+
</div>
|
| 370 |
</div>
|
| 371 |
+
<div class="input-hint">Arjun Compound is engineered for extreme performance. Developed by Abhay Kumar.</div>
|
| 372 |
+
</div>
|
| 373 |
</main>
|
| 374 |
+
|
| 375 |
+
<!-- Workspace Panel -->
|
| 376 |
+
<aside class="workspace" id="workspace">
|
| 377 |
+
<div class="ws-hdr">
|
| 378 |
+
<div class="ws-title"><span>💻</span><span id="wsTitleText">Generated Code</span></div>
|
| 379 |
+
<div class="ws-actions">
|
| 380 |
+
<button class="ws-icon-btn" onclick="copyWorkspaceCode()" id="wsCopyBtn">📋 Copy</button>
|
| 381 |
+
<button class="ws-icon-btn ws-close" onclick="closeWorkspace()" title="Close">✕</button>
|
| 382 |
+
</div>
|
| 383 |
+
</div>
|
| 384 |
+
<div class="ws-content">
|
| 385 |
+
<pre><code id="wsCodeBlock" class="hljs"></code></pre>
|
| 386 |
+
</div>
|
| 387 |
+
</aside>
|
| 388 |
+
</div>
|
| 389 |
</div>
|
| 390 |
|
| 391 |
+
<!-- AUTH MODAL -->
|
| 392 |
<div class="modal-overlay" id="authModal">
|
| 393 |
+
<div class="modal-card">
|
| 394 |
+
<button class="close-modal" onclick="closeAuthModal()">✕</button>
|
| 395 |
+
<div class="auth-header"><h2>Arjun Network</h2></div>
|
| 396 |
+
|
| 397 |
+
<div class="auth-tabs">
|
| 398 |
+
<div class="auth-tab active" id="tab-login" onclick="switchAuthTab('login')">Login</div>
|
| 399 |
+
<div class="auth-tab" id="tab-register" onclick="switchAuthTab('register')">Register</div>
|
| 400 |
+
</div>
|
| 401 |
|
| 402 |
+
<!-- Login Form -->
|
| 403 |
+
<div id="flow-login">
|
| 404 |
+
<div class="auth-step active" id="log-step-1">
|
| 405 |
+
<div class="input-group"><input type="email" id="logEmail" placeholder="Registered Email"></div>
|
| 406 |
+
<button class="primary-btn" id="btn-log-otp" onclick="processAuth('login_send_otp')">Get Secure OTP</button>
|
| 407 |
+
</div>
|
| 408 |
+
<div class="auth-step" id="log-step-2">
|
| 409 |
+
<div class="input-group"><input type="number" id="logOTP" placeholder="Enter OTP"></div>
|
| 410 |
+
<button class="primary-btn" id="btn-log-verify" onclick="processAuth('login_verify')">Verify & Login</button>
|
| 411 |
+
<button class="secondary-btn" onclick="switchAuthStep('log-step-2', 'log-step-1')">Back</button>
|
| 412 |
+
</div>
|
| 413 |
+
</div>
|
| 414 |
|
| 415 |
+
<!-- Register Form -->
|
| 416 |
+
<div id="flow-register" style="display:none;">
|
| 417 |
+
<div class="auth-step active" id="reg-step-1">
|
| 418 |
+
<div class="input-group"><input type="text" id="regName" placeholder="Full Name"></div>
|
| 419 |
+
<div class="input-group"><input type="email" id="regEmail" placeholder="Email Address"></div>
|
| 420 |
+
<button class="primary-btn" id="btn-reg-otp" onclick="processAuth('register_send_otp')">Send OTP</button>
|
| 421 |
+
</div>
|
| 422 |
+
<div class="auth-step" id="reg-step-2">
|
| 423 |
+
<div class="input-group"><input type="number" id="regOTP" placeholder="Enter Verification OTP"></div>
|
| 424 |
+
<button class="primary-btn" id="btn-reg-verify" onclick="processAuth('register_verify')">Create Account</button>
|
| 425 |
+
<button class="secondary-btn" onclick="switchAuthStep('reg-step-2', 'reg-step-1')">Back</button>
|
| 426 |
+
</div>
|
|
|
|
| 427 |
</div>
|
| 428 |
+
</div>
|
| 429 |
</div>
|
| 430 |
|
| 431 |
<script>
|
| 432 |
+
// --- GLOBAL VARIABLES & CONFIG ---
|
| 433 |
const GAS_URL = "https://script.google.com/macros/s/AKfycbzTsXGoVh97JjtFAAG825GF4WUZqf7FDB3Zbxyf0nrLXt_1HjJSSqA829UcdoamRPvg0A/exec";
|
| 434 |
+
const LOGO_URL = "https://i.ibb.co/0y2sdbq6/PT-20260523-133251-0000.png";
|
| 435 |
|
|
|
|
| 436 |
let currentUser = localStorage.getItem('arjun_user');
|
| 437 |
let guestCount = parseInt(localStorage.getItem('arjun_guest') || '0');
|
| 438 |
|
| 439 |
+
const S = {
|
| 440 |
+
history: [],
|
| 441 |
+
pending: null,
|
| 442 |
+
busy: false,
|
| 443 |
+
isUserScrolling: false,
|
| 444 |
+
codeBlocks: [],
|
| 445 |
+
currentWorkspaceId: null
|
| 446 |
+
};
|
| 447 |
+
|
| 448 |
// --- INITIALIZATION ---
|
| 449 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 450 |
+
// Welcome Overlay Cache
|
| 451 |
+
if(!localStorage.getItem('arjun_welcome_seen')) {
|
| 452 |
+
document.getElementById('welcomeOverlay').style.display = 'flex';
|
| 453 |
+
} else {
|
| 454 |
+
document.getElementById('welcomeOverlay').style.display = 'none';
|
| 455 |
}
|
| 456 |
+
|
| 457 |
+
updateAuthUI();
|
| 458 |
+
if(currentUser) {
|
| 459 |
+
fetchHistoryFromGAS();
|
| 460 |
+
} else {
|
| 461 |
+
document.getElementById('guestBadge').style.display = 'inline-block';
|
| 462 |
+
document.getElementById('guestCountDisplay').innerText = guestCount;
|
| 463 |
+
}
|
| 464 |
+
});
|
| 465 |
+
|
| 466 |
+
function startArjunApp() {
|
| 467 |
+
const overlay = document.getElementById('welcomeOverlay');
|
| 468 |
+
overlay.classList.add('hidden');
|
| 469 |
+
localStorage.setItem('arjun_welcome_seen', 'true');
|
| 470 |
+
setTimeout(() => { overlay.style.display = 'none'; }, 400);
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
function toggleSidebar() {
|
| 474 |
+
document.getElementById('sidebar').classList.toggle('show');
|
| 475 |
+
}
|
| 476 |
|
| 477 |
function showToast(msg) {
|
| 478 |
+
const container = document.getElementById('toast-container');
|
| 479 |
const t = document.createElement('div'); t.className = 'toast';
|
| 480 |
+
t.innerText = msg;
|
| 481 |
+
container.appendChild(t);
|
| 482 |
setTimeout(() => t.remove(), 3000);
|
| 483 |
}
|
| 484 |
|
| 485 |
+
function toggleThinking(el) {
|
| 486 |
+
if(el.checked) document.body.classList.add('show-thinking');
|
| 487 |
+
else document.body.classList.remove('show-thinking');
|
| 488 |
+
}
|
| 489 |
|
| 490 |
+
// --- AUTHENTICATION (GAS INTEGRATION) ---
|
| 491 |
+
function updateAuthUI() {
|
| 492 |
if (currentUser) {
|
| 493 |
+
document.getElementById('loginPromptBtn').style.display = 'none';
|
| 494 |
document.getElementById('userProfile').style.display = 'flex';
|
| 495 |
document.getElementById('uEmail').innerText = currentUser;
|
| 496 |
document.getElementById('uAvatar').innerText = currentUser.charAt(0).toUpperCase();
|
| 497 |
document.getElementById('guestBadge').style.display = 'none';
|
| 498 |
} else {
|
| 499 |
+
document.getElementById('loginPromptBtn').style.display = 'flex';
|
| 500 |
document.getElementById('userProfile').style.display = 'none';
|
| 501 |
}
|
| 502 |
}
|
|
|
|
| 510 |
document.getElementById('flow-login').style.display = tab === 'login' ? 'block' : 'none';
|
| 511 |
document.getElementById('flow-register').style.display = tab === 'register' ? 'block' : 'none';
|
| 512 |
}
|
| 513 |
+
function switchAuthStep(curr, next) {
|
| 514 |
document.getElementById(curr).classList.remove('active');
|
| 515 |
document.getElementById(next).classList.add('active');
|
| 516 |
}
|
|
|
|
| 536 |
}
|
| 537 |
|
| 538 |
const btn = document.getElementById(btnId); const ogText = btn.innerHTML;
|
| 539 |
+
btn.disabled = true; btn.innerText = 'Processing...';
|
| 540 |
|
| 541 |
try {
|
| 542 |
const res = await fetch(GAS_URL, { method: 'POST', body: JSON.stringify(payload) });
|
|
|
|
| 544 |
|
| 545 |
if (data.status === 'success') {
|
| 546 |
showToast(data.message);
|
| 547 |
+
if (action === 'register_send_otp') switchAuthStep('reg-step-1', 'reg-step-2');
|
| 548 |
+
else if (action === 'login_send_otp') switchAuthStep('log-step-1', 'log-step-2');
|
| 549 |
else if (action === 'register_verify' || action === 'login_verify') {
|
| 550 |
currentUser = payload.email;
|
| 551 |
+
localStorage.setItem('arjun_user', currentUser);
|
| 552 |
+
closeAuthModal(); updateAuthUI(); fetchHistoryFromGAS();
|
| 553 |
}
|
| 554 |
} else showToast(data.message);
|
| 555 |
} catch (e) { showToast("Network Error."); }
|
|
|
|
| 557 |
}
|
| 558 |
|
| 559 |
function logout() { localStorage.removeItem('arjun_user'); location.reload(); }
|
| 560 |
+
|
| 561 |
async function clearMemory() {
|
| 562 |
if(currentUser) {
|
| 563 |
showToast("Clearing Cloud History...");
|
|
|
|
| 566 |
location.reload();
|
| 567 |
}
|
| 568 |
|
| 569 |
+
// --- GAS HISTORY SYNC ---
|
| 570 |
async function fetchHistoryFromGAS() {
|
| 571 |
+
const m = document.getElementById('msgs');
|
| 572 |
+
document.getElementById('welcome').style.display = 'none';
|
| 573 |
+
m.innerHTML = '<div style="text-align:center; padding:40px; color:var(--text-muted);">Syncing Secure Data...</div>';
|
| 574 |
|
| 575 |
try {
|
| 576 |
const res = await fetch(GAS_URL, { method: 'POST', body: JSON.stringify({ action: "get_history", email: currentUser }) });
|
| 577 |
const data = await res.json();
|
| 578 |
+
m.innerHTML = '';
|
| 579 |
if (data.status === 'success' && data.historyJSON !== "[]") {
|
| 580 |
+
S.history = JSON.parse(data.historyJSON);
|
| 581 |
+
S.history.forEach(msg => {
|
| 582 |
+
if(msg.role === 'user') appendUserDOM(msg.content, msg.badge);
|
| 583 |
+
else appendBotDOM(msg.content, true);
|
| 584 |
+
});
|
| 585 |
+
setTimeout(forceScrollDown, 100);
|
| 586 |
+
} else {
|
| 587 |
+
document.getElementById('welcome').style.display = 'flex';
|
| 588 |
+
}
|
| 589 |
+
} catch(e) { m.innerHTML = ''; document.getElementById('welcome').style.display = 'flex'; }
|
| 590 |
}
|
| 591 |
|
| 592 |
function syncHistory() {
|
| 593 |
+
if(currentUser) {
|
| 594 |
+
fetch(GAS_URL, { method: 'POST', body: JSON.stringify({ action: "save_history", email: currentUser, historyJSON: JSON.stringify(S.history) }) });
|
| 595 |
+
}
|
| 596 |
}
|
| 597 |
|
| 598 |
+
// --- FILE HANDLING ---
|
| 599 |
+
function handleFile(input){
|
| 600 |
+
const f=input.files[0];if(!f)return;
|
| 601 |
+
const r=new FileReader();
|
| 602 |
+
r.onload=e=>{
|
| 603 |
+
const base64Data = e.target.result.split(',')[1];
|
| 604 |
+
S.pending={type: 'image', data: base64Data, name: f.name};
|
| 605 |
+
document.getElementById('imgThumb').src = e.target.result;
|
| 606 |
+
document.getElementById('imgName').textContent=f.name;
|
| 607 |
+
document.getElementById('imgPrev').classList.add('show');
|
| 608 |
+
};
|
| 609 |
+
r.readAsDataURL(f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
}
|
| 611 |
+
function removeImg(){S.pending=null;document.getElementById('imgPrev').classList.remove('show');document.getElementById('fileInput').value='';}
|
| 612 |
+
|
| 613 |
+
// --- UI INTERACTIONS ---
|
| 614 |
+
function handleKey(e){if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMsg();}}
|
| 615 |
+
function autoGrow(el){el.style.height='auto';el.style.height=Math.min(el.scrollHeight,200)+'px';}
|
| 616 |
+
|
| 617 |
+
function checkScroll() {
|
| 618 |
+
const m = document.getElementById('msgs');
|
| 619 |
+
const isAtBottom = Math.abs((m.scrollHeight - m.scrollTop) - m.clientHeight) < 80;
|
| 620 |
+
S.isUserScrolling = !isAtBottom;
|
| 621 |
+
const btn = document.getElementById('scrollBtn');
|
| 622 |
+
if(S.isUserScrolling) btn.classList.add('show');
|
| 623 |
+
else btn.classList.remove('show');
|
| 624 |
+
}
|
| 625 |
+
function forceScrollDown(){
|
| 626 |
+
const m=document.getElementById('msgs');
|
| 627 |
+
m.scrollTo({top: m.scrollHeight, behavior: 'smooth'});
|
| 628 |
+
S.isUserScrolling = false;
|
| 629 |
+
document.getElementById('scrollBtn').classList.remove('show');
|
| 630 |
+
}
|
| 631 |
+
function autoScroll() {
|
| 632 |
+
if(!S.isUserScrolling) {
|
| 633 |
+
const m=document.getElementById('msgs');
|
| 634 |
+
m.scrollTop = m.scrollHeight;
|
| 635 |
+
}
|
| 636 |
}
|
| 637 |
|
| 638 |
+
// --- COPY UTILS ---
|
| 639 |
+
function copyText(btn, text) {
|
| 640 |
+
navigator.clipboard.writeText(text);
|
| 641 |
+
const orig = btn.innerHTML;
|
| 642 |
+
btn.innerHTML = "✓ Copied";
|
| 643 |
+
setTimeout(() => btn.innerHTML = orig, 2000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
}
|
| 645 |
+
function copyWorkspaceCode() {
|
| 646 |
+
if(S.currentWorkspaceId !== null) {
|
| 647 |
+
navigator.clipboard.writeText(S.codeBlocks[S.currentWorkspaceId].code);
|
| 648 |
+
const btn = document.getElementById('wsCopyBtn');
|
| 649 |
+
const orig = btn.innerHTML;
|
| 650 |
+
btn.innerHTML = "✓ Copied";
|
| 651 |
+
setTimeout(() => btn.innerHTML = orig, 2000);
|
| 652 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
}
|
| 654 |
|
| 655 |
+
// --- WORKSPACE LOGIC (MARKDOWN RENDERER) ---
|
| 656 |
+
function openWorkspace(id) {
|
| 657 |
+
S.currentWorkspaceId = id;
|
| 658 |
+
const block = S.codeBlocks[id];
|
| 659 |
+
document.getElementById('wsTitleText').textContent = block.lang ? `Generated ${block.lang.toUpperCase()}` : "Generated Code";
|
| 660 |
+
const codeBlock = document.getElementById('wsCodeBlock');
|
| 661 |
+
codeBlock.className = `hljs language-${block.lang || 'plaintext'}`;
|
| 662 |
+
codeBlock.textContent = block.code;
|
| 663 |
+
hljs.highlightElement(codeBlock);
|
| 664 |
+
document.getElementById('workspace').classList.add('open');
|
| 665 |
+
if(window.innerWidth <= 850) { document.getElementById('sidebar').classList.remove('show'); }
|
| 666 |
+
}
|
| 667 |
+
function closeWorkspace() { document.getElementById('workspace').classList.remove('open'); }
|
| 668 |
+
|
| 669 |
+
const renderer = new marked.Renderer();
|
| 670 |
+
renderer.code = function(token) {
|
| 671 |
+
const codeText = typeof token === 'string' ? token : (token.text || '');
|
| 672 |
+
const language = typeof token === 'string' ? arguments[1] : (token.lang || '');
|
| 673 |
+
const id = S.codeBlocks.length;
|
| 674 |
+
S.codeBlocks.push({ code: codeText, lang: language });
|
| 675 |
+
|
| 676 |
+
return `
|
| 677 |
+
<div class="ws-trigger-card">
|
| 678 |
+
<div class="ws-trigger-info">
|
| 679 |
+
<div class="ws-trigger-icon">💻</div>
|
| 680 |
+
<div class="ws-trigger-text">
|
| 681 |
+
<h4>Code Generated</h4>
|
| 682 |
+
<p>${language || 'Snippet'}</p>
|
| 683 |
+
</div>
|
| 684 |
+
</div>
|
| 685 |
+
<button class="ws-btn" onclick="openWorkspace(${id})">View in Workspace</button>
|
| 686 |
+
</div>
|
| 687 |
+
`;
|
| 688 |
+
};
|
| 689 |
+
marked.use({ renderer });
|
| 690 |
|
| 691 |
+
function parseThinking(raw) {
|
| 692 |
+
const thinkRegex = /<think>([\s\S]*?)(<\/think>|$)/gi;
|
| 693 |
+
let text = raw, thinkContent = '';
|
| 694 |
+
text = text.replace(thinkRegex, (match, p1) => { thinkContent += p1; return ''; });
|
| 695 |
+
return { mainText: text.trim(), thinkText: thinkContent.trim() };
|
| 696 |
+
}
|
| 697 |
|
| 698 |
+
// --- MAIN CHAT LOGIC ---
|
| 699 |
+
async function sendMsg(){
|
| 700 |
+
if(S.busy)return;
|
| 701 |
+
const inp=document.getElementById('chatInput');
|
| 702 |
+
const msg=inp.value.trim();if(!msg && !S.pending)return;
|
| 703 |
+
|
| 704 |
+
// Guest Logic
|
| 705 |
+
if (!currentUser) {
|
| 706 |
+
if (guestCount >= 3) { openAuthModal(); return showToast("Guest limit reached. Please Login."); }
|
| 707 |
+
guestCount++; localStorage.setItem('arjun_guest', guestCount.toString());
|
| 708 |
+
document.getElementById('guestCountDisplay').innerText = guestCount;
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
inp.value='';inp.style.height='auto';
|
| 712 |
+
document.getElementById('sendBtn').disabled=true;
|
| 713 |
+
S.busy=true;
|
| 714 |
+
|
| 715 |
+
const w=document.getElementById('welcome');
|
| 716 |
+
if(w)w.style.display='none';
|
| 717 |
+
|
| 718 |
+
let attachments = [];
|
| 719 |
+
let badge = null;
|
| 720 |
+
if(S.pending) {
|
| 721 |
+
attachments.push(S.pending);
|
| 722 |
+
badge = '📎 '+S.pending.name;
|
| 723 |
+
appendUserDOM(msg || '[Image Attached]', badge);
|
| 724 |
+
S.history.push({role: 'user', content: msg || '[Image Attached]', badge: badge});
|
| 725 |
+
} else {
|
| 726 |
+
appendUserDOM(msg);
|
| 727 |
+
S.history.push({role: 'user', content: msg});
|
| 728 |
+
}
|
| 729 |
+
removeImg();
|
| 730 |
+
syncHistory();
|
| 731 |
+
|
| 732 |
+
const botDiv = document.createElement('div');botDiv.className='msg bot';
|
| 733 |
+
botDiv.innerHTML=`<div class="avatar"><img src="${LOGO_URL}"></div><div class="body"><div class="bubble"><div class="typing"><span></span><span></span><span></span></div></div></div>`;
|
| 734 |
+
document.getElementById('msgs').appendChild(botDiv);
|
| 735 |
+
forceScrollDown();
|
| 736 |
+
|
| 737 |
+
const sysPrompt = `You are Arjun Compound, a state-of-the-art AI assistant developed by Abhay Kumar.
|
| 738 |
+
Always communicate respectfully.
|
| 739 |
+
|
| 740 |
+
CRITICAL IMAGE GENERATION PROTOCOL:
|
| 741 |
+
If the user asks to generate, create, or draw an image/photo, you MUST generate the image by responding with a markdown image tag using Pollinations AI.
|
| 742 |
+
Format to use: 
|
| 743 |
+
Available models for {MODEL}: flux, flux-realism, flux-anime, flux-3d.
|
| 744 |
+
Choose the best model based on the prompt. Example: if user says anime, use flux-anime.
|
| 745 |
+
Always include this markdown tag when image generation is requested.`;
|
| 746 |
+
|
| 747 |
+
const payload = {
|
| 748 |
+
message: msg,
|
| 749 |
+
attachments: attachments,
|
| 750 |
+
system_prompt: sysPrompt,
|
| 751 |
+
max_tokens: 4096,
|
| 752 |
+
temperature: 0.7
|
| 753 |
+
};
|
| 754 |
+
|
| 755 |
+
try{
|
| 756 |
+
const res = await fetch('/api/chat', {
|
| 757 |
+
method: 'POST',
|
| 758 |
+
headers: {'Content-Type': 'application/json'},
|
| 759 |
+
body: JSON.stringify(payload)
|
| 760 |
+
});
|
| 761 |
+
|
| 762 |
+
const reader = res.body.getReader();
|
| 763 |
+
const decoder = new TextDecoder();
|
| 764 |
+
let accumulatedText = "";
|
| 765 |
+
|
| 766 |
+
while (true) {
|
| 767 |
+
const { done, value } = await reader.read();
|
| 768 |
+
if (done) break;
|
| 769 |
+
const chunk = decoder.decode(value, {stream: true});
|
| 770 |
+
const lines = chunk.split('\n');
|
| 771 |
+
|
| 772 |
+
for (let line of lines) {
|
| 773 |
+
if (line.startsWith('data: ')) {
|
| 774 |
+
const dataStr = line.substring(6);
|
| 775 |
+
if (dataStr.trim() === '[DONE]') continue;
|
| 776 |
+
try {
|
| 777 |
+
const dataObj = JSON.parse(dataStr);
|
| 778 |
+
if (dataObj.choices && dataObj.choices[0].delta.content) {
|
| 779 |
+
accumulatedText += dataObj.choices[0].delta.content;
|
| 780 |
+
renderBotText(botDiv, accumulatedText, true);
|
| 781 |
+
autoScroll();
|
| 782 |
+
}
|
| 783 |
+
} catch (e) { }
|
| 784 |
+
}
|
| 785 |
}
|
|
|
|
| 786 |
}
|
| 787 |
+
renderBotText(botDiv, accumulatedText, false);
|
| 788 |
+
|
| 789 |
+
S.history.push({role: 'bot', content: accumulatedText});
|
| 790 |
+
syncHistory();
|
| 791 |
|
| 792 |
+
}catch(err){
|
| 793 |
+
renderBotText(botDiv,`**Error:** Server communication failed.`, false);
|
| 794 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
|
| 796 |
+
S.busy=false; document.getElementById('sendBtn').disabled=false; autoScroll();
|
| 797 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 798 |
|
| 799 |
+
function sendEx(t){document.getElementById('chatInput').value=t;sendMsg();}
|
| 800 |
|
| 801 |
+
function appendUserDOM(text, badgeText){
|
| 802 |
+
let bHtml = badgeText ? `<div style="font-size:11px;color:var(--accent);margin-bottom:4px;font-weight:600;">${esc(badgeText)}</div>` : '';
|
| 803 |
+
const el=document.createElement('div');el.className='msg user';
|
| 804 |
+
el.innerHTML=`<div class="avatar">U</div><div class="body">${bHtml}<div class="bubble">${esc(text)}</div></div>`;
|
| 805 |
+
document.getElementById('msgs').appendChild(el);
|
| 806 |
}
|
| 807 |
|
| 808 |
+
function appendBotDOM(content, isHistoryLoading=false) {
|
| 809 |
+
const el=document.createElement('div');el.className='msg bot';
|
| 810 |
+
el.innerHTML=`<div class="avatar"><img src="${LOGO_URL}"></div><div class="body"><div class="bubble"></div></div>`;
|
| 811 |
+
document.getElementById('msgs').appendChild(el);
|
| 812 |
+
renderBotText(el, content, !isHistoryLoading);
|
| 813 |
+
}
|
| 814 |
|
| 815 |
+
function renderBotText(el, raw, isStreaming) {
|
| 816 |
+
const b = el.querySelector('.bubble');
|
| 817 |
+
const { mainText, thinkText } = parseThinking(raw);
|
| 818 |
+
let html = '';
|
| 819 |
+
|
| 820 |
+
if (thinkText) { html += `<div class="think-box"><div class="think-title">🧠 Reasoning Process</div>${esc(thinkText)}</div>`; }
|
| 821 |
+
|
| 822 |
+
html += marked.parse(mainText);
|
| 823 |
+
if(isStreaming) { html += '<span class="blinking-cursor"></span>'; }
|
| 824 |
+
b.innerHTML = html;
|
| 825 |
+
|
| 826 |
+
let actionsDiv = el.querySelector('.msg-actions');
|
| 827 |
+
if(!isStreaming && !actionsDiv && mainText.trim().length > 0) {
|
| 828 |
+
const cleanRaw = mainText.replace(/"/g, '"').replace(/'/g, "\\'").replace(/\n/g, '\\n');
|
| 829 |
+
const actionsHTML = `<div class="msg-actions"><button class="action-btn" onclick="copyText(this, \`${cleanRaw}\`)"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg> Copy Text</button></div>`;
|
| 830 |
+
el.querySelector('.body').insertAdjacentHTML('beforeend', actionsHTML);
|
| 831 |
+
}
|
| 832 |
}
|
| 833 |
+
|
| 834 |
+
function esc(t){return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');}
|
| 835 |
</script>
|
| 836 |
</body>
|
| 837 |
</html>
|