nothumanallowed 14.1.12 → 14.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -404,18 +404,18 @@ ${g}
|
|
|
404
404
|
</svg>
|
|
405
405
|
</div>`:``,l=i.map(e=>`<div class="toc-item"><span class="toc-icon">${e.icon}</span>${n(e.label)}</div>`).join(``),u=i.map(e=>`<div class="section"><div class="agent-header"><span class="icon">${e.icon}</span><div class="agent-name">${n(e.label)}</div></div><div class="section-body"><p>${r(e.output)}</p></div></div>`).join(``);return`<!DOCTYPE html><html lang="it"><head><meta charset="UTF-8"><title>NHA Studio — ${n(e.slice(0,80))}</title>
|
|
406
406
|
<style>
|
|
407
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
407
|
+
*{box-sizing:border-box;margin:0;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
408
408
|
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#1e293b;background:#fff;font-size:13px;line-height:1.75;padding:40px;max-width:900px;margin:0 auto}
|
|
409
|
-
.cover{background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%);color:#fff;padding:48px 52px;margin-bottom:36px;border-radius:12px}
|
|
410
|
-
.cover h1{color:#fff;font-size:28px;font-weight:900;margin-bottom:6px;letter-spacing:-0.5px}
|
|
411
|
-
.cover .meta{color:rgba(255,255,255,.
|
|
412
|
-
.task{color
|
|
413
|
-
.toc{margin-bottom:32px;padding:16px 20px;background:#f1f5f9;border-radius:8px;border-left:3px solid #6366f1}
|
|
409
|
+
.cover{background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%) !important;color:#fff !important;padding:48px 52px;margin-bottom:36px;border-radius:12px;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
410
|
+
.cover h1{color:#fff !important;font-size:28px;font-weight:900;margin-bottom:6px;letter-spacing:-0.5px}
|
|
411
|
+
.cover .meta{color:rgba(255,255,255,.7) !important;font-size:11px;margin-bottom:18px}
|
|
412
|
+
.task{color:#fff !important;font-size:14px;padding:14px 18px;background:rgba(99,102,241,0.25) !important;border-radius:8px;border-left:4px solid #818cf8 !important;line-height:1.6}
|
|
413
|
+
.toc{margin-bottom:32px;padding:16px 20px;background:#f1f5f9 !important;border-radius:8px;border-left:3px solid #6366f1 !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
414
414
|
.toc h3{font-size:11px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:1px;margin-bottom:10px}
|
|
415
415
|
.toc-item{display:flex;align-items:center;gap:8px;padding:3px 0;font-size:12px;color:#334155}
|
|
416
416
|
.toc-icon{font-size:14px;width:20px;text-align:center}
|
|
417
417
|
.section{margin-bottom:36px;padding-bottom:36px;border-bottom:1px solid #e2e8f0;page-break-inside:avoid}
|
|
418
|
-
.agent-header{display:flex;align-items:center;gap:12px;margin-bottom:18px;padding-bottom:10px;border-bottom:
|
|
418
|
+
.agent-header{display:flex;align-items:center;gap:12px;margin-bottom:18px;padding-bottom:10px;border-bottom:2px solid #6366f1 !important}
|
|
419
419
|
.icon{font-size:22px;width:32px;text-align:center}
|
|
420
420
|
.agent-name{font-size:15px;font-weight:800;color:#0f172a}
|
|
421
421
|
.section-body{font-size:13px;line-height:1.8;color:#374151}
|
|
@@ -424,18 +424,21 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#1
|
|
|
424
424
|
.section-body h3{font-size:13px;font-weight:700;margin:12px 0 6px;color:#7c3aed;padding-left:8px;border-left:2px solid #7c3aed}
|
|
425
425
|
.section-body strong{color:#0f172a;font-weight:700}
|
|
426
426
|
.section-body em{font-style:italic;color:#64748b}
|
|
427
|
-
.section-body code{background:#f1f5f9;border:1px solid #e2e8f0;border-radius:3px;padding:1px 5px;font-family:monospace;font-size:11px;color:#7c3aed}
|
|
427
|
+
.section-body code{background:#f1f5f9 !important;border:1px solid #e2e8f0;border-radius:3px;padding:1px 5px;font-family:monospace;font-size:11px;color:#7c3aed !important}
|
|
428
428
|
.section-body table{width:100%;border-collapse:collapse;margin:14px 0}
|
|
429
|
-
.section-body th{background:#f1f5f9;color:#0f172a;font-weight:700;padding:8px 12px;text-align:left;border:1px solid #e2e8f0;font-size:11px;text-transform:uppercase;letter-spacing:0.5px}
|
|
429
|
+
.section-body th{background:#f1f5f9 !important;color:#0f172a;font-weight:700;padding:8px 12px;text-align:left;border:1px solid #e2e8f0;font-size:11px;text-transform:uppercase;letter-spacing:0.5px;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
430
430
|
.section-body td{padding:8px 12px;border:1px solid #e2e8f0;color:#374151;font-size:12px}
|
|
431
|
-
.section-body tr:nth-child(even) td{background:#f8fafc}
|
|
431
|
+
.section-body tr:nth-child(even) td{background:#f8fafc !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
432
432
|
.section-body ul{padding-left:20px;margin:8px 0}
|
|
433
433
|
.section-body li{margin-bottom:4px}
|
|
434
434
|
.section-body p{margin:0 0 8px}
|
|
435
|
-
.chart-section{margin:24px 0;padding:16px 20px;background:#f8fafc;border-radius:8px;border:1px solid #e2e8f0}
|
|
435
|
+
.chart-section{margin:24px 0;padding:16px 20px;background:#f8fafc !important;border-radius:8px;border:1px solid #e2e8f0;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
436
436
|
.chart-title{font-size:12px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:14px}
|
|
437
437
|
.footer{margin-top:48px;padding-top:16px;border-top:1px solid #e2e8f0;color:#94a3b8;font-size:10px;text-align:center}
|
|
438
|
-
@media print{
|
|
438
|
+
@media print{*{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important}
|
|
439
|
+
.cover{background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%) !important;page-break-after:always}
|
|
440
|
+
.section{page-break-inside:avoid}
|
|
441
|
+
@page{margin:1.5cm;size:A4}}
|
|
439
442
|
</style></head><body>
|
|
440
443
|
<div class="cover">
|
|
441
444
|
<h1>NHA Studio Report</h1>
|
|
@@ -467,19 +470,19 @@ ${u}
|
|
|
467
470
|
</svg>
|
|
468
471
|
</div>`:``,u=C?.synthesis?`<div class="section parliament"><div class="agent-header"><span class="icon">🏛️</span><div class="agent-name">Parliament — HERALD Synthesis</div></div><div class="section-body"><p>${r(C.synthesis)}</p></div></div>`:``,d=`<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>NHA Studio — ${t(n)}</title>
|
|
469
472
|
<style>
|
|
470
|
-
*{box-sizing:border-box;margin:0;padding:0}
|
|
473
|
+
*{box-sizing:border-box;margin:0;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
471
474
|
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#1e293b;background:#fff;font-size:13px;line-height:1.75;padding:40px;max-width:900px;margin:0 auto}
|
|
472
|
-
.cover{background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%);color:#fff;padding:48px 52px;margin-bottom:36px;border-radius:12px;page-break-after:always}
|
|
473
|
-
.cover h1{color:#fff;font-size:28px;font-weight:900;margin-bottom:6px;letter-spacing:-0.5px}
|
|
474
|
-
.cover .meta{color:rgba(255,255,255,.
|
|
475
|
-
.task{color
|
|
476
|
-
.toc{margin-bottom:32px;padding:16px 20px;background:#f1f5f9;border-radius:8px;border-left:3px solid #6366f1}
|
|
475
|
+
.cover{background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%) !important;color:#fff !important;padding:48px 52px;margin-bottom:36px;border-radius:12px;page-break-after:always;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
476
|
+
.cover h1{color:#fff !important;font-size:28px;font-weight:900;margin-bottom:6px;letter-spacing:-0.5px}
|
|
477
|
+
.cover .meta{color:rgba(255,255,255,.7) !important;font-size:11px;margin-bottom:18px}
|
|
478
|
+
.task{color:#fff !important;font-size:14px;padding:14px 18px;background:rgba(99,102,241,0.25) !important;border-radius:8px;border-left:4px solid #818cf8 !important;line-height:1.6}
|
|
479
|
+
.toc{margin-bottom:32px;padding:16px 20px;background:#f1f5f9 !important;border-radius:8px;border-left:3px solid #6366f1 !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
477
480
|
.toc h3{font-size:11px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:1px;margin-bottom:10px}
|
|
478
481
|
.toc-item{display:flex;align-items:center;gap:8px;padding:3px 0;font-size:12px;color:#334155}
|
|
479
482
|
.toc-icon{font-size:14px;width:20px;text-align:center}
|
|
480
483
|
.section{margin-bottom:36px;padding-bottom:36px;border-bottom:1px solid #e2e8f0;page-break-inside:avoid}
|
|
481
|
-
.section.parliament{background:linear-gradient(135deg,#ede9fe,#f0f9ff);padding:20px 24px;border-radius:10px;border:1px solid #c4b5fd;
|
|
482
|
-
.agent-header{display:flex;align-items:center;gap:12px;margin-bottom:18px;padding-bottom:10px;border-bottom:
|
|
484
|
+
.section.parliament{background:linear-gradient(135deg,#ede9fe,#f0f9ff) !important;padding:20px 24px;border-radius:10px;border:1px solid #c4b5fd !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
485
|
+
.agent-header{display:flex;align-items:center;gap:12px;margin-bottom:18px;padding-bottom:10px;border-bottom:2px solid #6366f1 !important}
|
|
483
486
|
.icon{font-size:22px;width:32px;text-align:center}
|
|
484
487
|
.agent-name{font-size:15px;font-weight:800;color:#0f172a}
|
|
485
488
|
.section-body{font-size:13px;line-height:1.8;color:#374151}
|
|
@@ -488,18 +491,21 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#1
|
|
|
488
491
|
.section-body h3{font-size:13px;font-weight:700;margin:12px 0 6px;color:#7c3aed;padding-left:8px;border-left:2px solid #7c3aed}
|
|
489
492
|
.section-body strong{color:#0f172a;font-weight:700}
|
|
490
493
|
.section-body em{font-style:italic;color:#64748b}
|
|
491
|
-
.section-body code{background:#f1f5f9;border:1px solid #e2e8f0;border-radius:3px;padding:1px 5px;font-family:monospace;font-size:11px;color:#7c3aed}
|
|
494
|
+
.section-body code{background:#f1f5f9 !important;border:1px solid #e2e8f0;border-radius:3px;padding:1px 5px;font-family:monospace;font-size:11px;color:#7c3aed !important}
|
|
492
495
|
.section-body table{width:100%;border-collapse:collapse;margin:14px 0}
|
|
493
|
-
.section-body th{background:#f1f5f9;color:#0f172a;font-weight:700;padding:8px 12px;text-align:left;border:1px solid #e2e8f0;font-size:11px;text-transform:uppercase;letter-spacing:0.5px}
|
|
496
|
+
.section-body th{background:#f1f5f9 !important;color:#0f172a;font-weight:700;padding:8px 12px;text-align:left;border:1px solid #e2e8f0;font-size:11px;text-transform:uppercase;letter-spacing:0.5px;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
494
497
|
.section-body td{padding:8px 12px;border:1px solid #e2e8f0;color:#374151;font-size:12px}
|
|
495
|
-
.section-body tr:nth-child(even) td{background:#f8fafc}
|
|
498
|
+
.section-body tr:nth-child(even) td{background:#f8fafc !important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
496
499
|
.section-body ul{padding-left:20px;margin:8px 0}
|
|
497
500
|
.section-body li{margin-bottom:4px}
|
|
498
501
|
.section-body p{margin:0 0 8px}
|
|
499
|
-
.chart-section{margin:24px 0;padding:16px 20px;background:#f8fafc;border-radius:8px;border:1px solid #e2e8f0}
|
|
502
|
+
.chart-section{margin:24px 0;padding:16px 20px;background:#f8fafc !important;border-radius:8px;border:1px solid #e2e8f0;-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
500
503
|
.chart-title{font-size:12px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:14px}
|
|
501
504
|
.footer{margin-top:48px;padding-top:16px;border-top:1px solid #e2e8f0;color:#94a3b8;font-size:10px;text-align:center}
|
|
502
|
-
@media print{
|
|
505
|
+
@media print{*{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important}
|
|
506
|
+
.cover{page-break-after:always;background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#0f172a 100%) !important}
|
|
507
|
+
.section{page-break-inside:avoid}
|
|
508
|
+
@page{margin:1.5cm;size:A4}}
|
|
503
509
|
</style></head><body>
|
|
504
510
|
<div class="cover">
|
|
505
511
|
<h1>NHA Studio Report</h1>
|
|
@@ -521,13 +527,13 @@ ${u}
|
|
|
521
527
|
|
|
522
528
|
`),r=`The user asked: "${e}"\n\nHere are the responses from ${t.length} specialist agents:\n\n${n}\n\nSynthesize these responses into a unified analysis.`,i=``;try{await ie(`/api/chat/stream`,{message:r,systemPrompt:`You are the Conductor — a meta-agent that synthesizes the outputs of multiple specialist AI agents.
|
|
523
529
|
Your job: examine all agent responses to a user's question, identify agreements, disagreements, complementary insights, and deliver a unified, high-quality synthesis.
|
|
524
|
-
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},he=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=T.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),N(e,{voiceActive:!1});return}let r=new t;T.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;N(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>N(e,{voiceActive:!1}),r.onerror=()=>N(e,{voiceActive:!1}),r.start(),N(e,{voiceActive:!0})},ge=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];N(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{N(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},_e=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];N(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},ve=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),ee(``)},F=async e=>{let t=await E(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),ee(``)},ye=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){ee(`Tagline and system prompt are required.`);return}ne(!0),ee(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){ee(`Agent name required (lowercase, no spaces).`),ne(!1);return}let t=await D(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){ee(`Error: `+t.error),ne(!1);return}}else await D(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),oe()}catch(e){ee(`Error: `+e.message)}finally{ne(!1)}}},be=e=>{confirm(`Delete agent "${e.label}"?`)&&D(`/api/agents/${e.id}`,{},`DELETE`).then(()=>oe())};return r?(0,k.jsx)(`div`,{className:G.root,children:(0,k.jsx)(`div`,{className:G.loading,children:(0,k.jsx)(`div`,{className:`spinner`})})}):(0,k.jsxs)(`div`,{className:G.root,children:[(0,k.jsxs)(`div`,{className:G.gridSection,children:[(0,k.jsxs)(`div`,{className:G.gridHeader,children:[(0,k.jsxs)(`div`,{className:G.headerRow,children:[(0,k.jsx)(`input`,{className:G.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,k.jsx)(`button`,{className:G.createBtn,onClick:ve,children:`+ Create`})]}),(0,k.jsx)(`div`,{className:G.catTabs,children:se.map(e=>(0,k.jsxs)(`button`,{className:`${G.catTab} ${s===e?G.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,k.jsx)(`div`,{className:G.grid,children:ce.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,k.jsxs)(`div`,{className:`${G.agentCard} ${t?G.agentActive:``}`,onClick:()=>le(e),children:[(0,k.jsxs)(`div`,{className:G.agentCardTop,children:[(0,k.jsx)(`div`,{className:G.agentIcon,children:e.icon}),e.isCustom&&(0,k.jsxs)(`div`,{className:G.agentActions,children:[(0,k.jsx)(`button`,{className:G.agentEditBtn,onClick:t=>{t.stopPropagation(),F(e)},children:`✏️`}),(0,k.jsx)(`button`,{className:G.agentDelBtn,onClick:t=>{t.stopPropagation(),be(e)},children:`🗑`})]})]}),(0,k.jsx)(`div`,{className:G.agentLabel,children:e.label}),(0,k.jsx)(`div`,{className:G.agentDesc,children:e.description}),(0,k.jsx)(`div`,{className:G.agentCat,children:e.category})]},e.id)})})]}),(0,k.jsx)(`div`,{className:G.chatArea,children:l.length===0?(0,k.jsxs)(`div`,{className:G.emptyChat,children:[(0,k.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,k.jsx)(`span`,{className:G.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,k.jsxs)(`div`,{className:G.chatPanel,children:[(0,k.jsxs)(`div`,{className:G.chatHeader,children:[(0,k.jsx)(`span`,{className:G.chatIcon,children:t.icon}),(0,k.jsxs)(`div`,{className:G.chatHeaderInfo,children:[(0,k.jsx)(`div`,{className:G.chatAgentName,children:t.label}),(0,k.jsx)(`div`,{className:G.chatAgentDesc,children:t.description})]}),(0,k.jsx)(`button`,{className:G.closeChat,onClick:()=>ue(t.id),children:`✕`})]}),(0,k.jsxs)(`div`,{className:G.chatMessages,ref:e=>{O.current.set(t.id,e)},children:[e.history.length===0&&(0,k.jsxs)(`div`,{className:G.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,k.jsx)(`div`,{className:`${G.chatMsg} ${e.role===`user`?G.msgUser:G.msgAgent}`,children:e.role===`assistant`?(0,k.jsx)(`div`,{dangerouslySetInnerHTML:{__html:me(e.content||`…`)}}):(0,k.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,k.jsxs)(`div`,{className:G.thinking,children:[(0,k.jsx)(`span`,{className:G.dot}),(0,k.jsx)(`span`,{className:G.dot}),(0,k.jsx)(`span`,{className:G.dot})]})]}),n&&(0,k.jsxs)(`div`,{className:G.attachBar,children:[(0,k.jsx)(`span`,{children:n}),(0,k.jsx)(`button`,{className:G.attachClear,onClick:()=>N(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,k.jsxs)(`div`,{className:G.chatInput,children:[(0,k.jsxs)(`div`,{className:G.chatTools,children:[(0,k.jsx)(`button`,{className:`${G.toolBtn} ${e.voiceActive?G.toolBtnActive:``}`,onClick:()=>he(t.id),title:`Voice`,children:`🎤`}),(0,k.jsx)(`button`,{className:G.toolBtn,onClick:()=>ae.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,k.jsx)(`button`,{className:G.toolBtn,onClick:()=>A.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,k.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{ae.current.set(t.id,e)},onChange:e=>ge(t.id,e.target.files?.[0])}),(0,k.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{A.current.set(t.id,e)},onChange:e=>_e(t.id,e.target.files?.[0])})]}),(0,k.jsxs)(`div`,{className:G.chatInputRow,children:[(0,k.jsx)(`textarea`,{className:G.chatTextarea,value:e.input,onChange:e=>N(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),pe(e,e.input,e.attachedFile,e.attachedImage))}}),(0,k.jsx)(`button`,{className:G.sendBtn,onClick:()=>pe(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,k.jsxs)(`div`,{className:G.orchBar,children:[(0,k.jsxs)(`div`,{className:G.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,k.jsxs)(`div`,{className:G.orchRow,children:[(0,k.jsx)(`textarea`,{ref:j,className:G.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),P())}}),(0,k.jsx)(`button`,{className:G.orchBtn,onClick:P,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,k.jsxs)(`div`,{className:G.orchSynthesis,children:[(0,k.jsxs)(`div`,{className:G.orchSynthHeader,children:[(0,k.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,k.jsx)(`span`,{className:G.orchSynthSpinner,children:`synthesizing…`})]}),(0,k.jsx)(`div`,{className:G.orchSynthBody,dangerouslySetInnerHTML:{__html:me(h||`…`)}})]})]}),b&&(0,k.jsx)(`div`,{className:G.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,k.jsxs)(`div`,{className:G.modal,children:[(0,k.jsx)(`div`,{className:G.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,k.jsx)(`input`,{className:G.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`Tagline`}),(0,k.jsx)(`input`,{className:G.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`System Prompt`}),(0,k.jsx)(`textarea`,{className:G.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,k.jsx)(`div`,{className:G.formError,children:w}),(0,k.jsxs)(`div`,{className:G.modalBtns,children:[(0,k.jsx)(`button`,{className:G.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,k.jsx)(`button`,{className:G.modalSaveBtn,onClick:ye,disabled:te,children:te?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var K={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function Kt(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function qt(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function Jt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),ee=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),E(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{ee()},[]);let te=e=>{c(e),ee(e,l)},ne=()=>{u(d),ee(s,d)},T=(e,t)=>{i(!0),E(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},re=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await D(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ie=(e,t)=>{i(!0),E(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},O=(e,t)=>{i(!0),E(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},ae=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&D(`/api/drive/delete/${e}`,{}).then(()=>{n(null),ee()})},A=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&D(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?T(t.id,e):ee()}).catch(e=>alert(`Error: `+e.message))},j=()=>{w.current?.click()},oe=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;D(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),ee()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,k.jsxs)(`div`,{className:K.error,children:[(0,k.jsx)(`div`,{children:a}),(0,k.jsxs)(`div`,{className:K.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,k.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,k.jsxs)(`div`,{className:K.editorRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:h.name}),(0,k.jsx)(`button`,{className:K.saveBtn,onClick:re,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,k.jsx)(`textarea`,{className:K.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,k.jsxs)(`div`,{className:K.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,k.jsxs)(`div`,{className:K.viewerRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:b.name})]}),(0,k.jsx)(`div`,{className:K.imgContainer,children:(0,k.jsx)(`img`,{src:b.src,alt:b.name,className:K.imgView})})]});if(p===`pdf`&&b)return(0,k.jsxs)(`div`,{className:K.viewerRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:b.name})]}),(0,k.jsx)(`iframe`,{className:K.pdfFrame,src:b.src,title:b.name})]});let se=t?.files??[],ce=t?.quota;return(0,k.jsxs)(`div`,{className:K.root,children:[ce&&(0,k.jsxs)(`div`,{className:K.quotaBar,children:[(0,k.jsxs)(`div`,{className:K.quotaText,children:[(0,k.jsxs)(`span`,{className:K.quotaUsed,children:[ce.usage,` of `,ce.limit,` used`]}),(0,k.jsxs)(`span`,{className:K.quotaPct,children:[ce.percentUsed,`%`]})]}),(0,k.jsx)(`div`,{className:K.quotaTrack,children:(0,k.jsx)(`div`,{className:K.quotaFill,style:{width:`${Math.min(ce.percentUsed,100)}%`,background:ce.percentUsed>90?`var(--red)`:ce.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,k.jsxs)(`div`,{className:K.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,k.jsx)(`button`,{className:`${K.filterBtn} ${s===e?K.filterActive:``}`,onClick:()=>te(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,k.jsx)(`div`,{className:K.spacer}),(0,k.jsx)(`button`,{className:K.newBtn,onClick:A,children:`+ New File`}),(0,k.jsx)(`button`,{className:K.uploadBtn,onClick:j,children:e(`drive.upload`)}),(0,k.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>oe(e.target.files?.[0])})]}),(0,k.jsxs)(`div`,{className:K.searchRow,children:[(0,k.jsx)(`input`,{className:K.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ne()}),(0,k.jsx)(`button`,{className:K.searchBtn,onClick:ne,children:`Search`})]}),r&&(0,k.jsx)(`div`,{className:K.loading,children:(0,k.jsx)(`div`,{className:`spinner`})}),!r&&se.length===0&&(0,k.jsxs)(`div`,{className:K.empty,children:[e(`drive.noFiles`),` found`]}),(0,k.jsx)(`div`,{className:K.fileList,children:se.map(e=>{let t=qt(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,k.jsxs)(`div`,{className:K.fileRow,onClick:()=>{t?T(e.id,e.name):n?ie(e.id,e.name):r?O(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,k.jsx)(`span`,{className:K.fileIcon,children:Kt(e.type,e.mimeType)}),(0,k.jsxs)(`div`,{className:K.fileInfo,children:[(0,k.jsx)(`div`,{className:K.fileName,children:e.name}),(0,k.jsxs)(`div`,{className:K.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,k.jsxs)(`div`,{className:K.fileBtns,children:[t&&(0,k.jsx)(`button`,{className:K.editBtn,onClick:t=>{t.stopPropagation(),T(e.id,e.name)},children:`Edit`}),n&&(0,k.jsx)(`button`,{className:K.viewBtn,onClick:t=>{t.stopPropagation(),ie(e.id,e.name)},children:`View`}),r&&(0,k.jsx)(`button`,{className:K.pdfBtn,onClick:t=>{t.stopPropagation(),O(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,k.jsx)(`a`,{className:K.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,k.jsx)(`button`,{className:K.delBtn,onClick:t=>{t.stopPropagation(),ae(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var q={root:`_root_a0x57_1`,loading:`_loading_a0x57_10`,errorBox:`_errorBox_a0x57_12`,errorHint:`_errorHint_a0x57_13`,userRow:`_userRow_a0x57_16`,avatar:`_avatar_a0x57_27`,userLogin:`_userLogin_a0x57_29`,userName:`_userName_a0x57_30`,disconnectBtn:`_disconnectBtn_a0x57_32`,repoBar:`_repoBar_a0x57_43`,repoInput:`_repoInput_a0x57_49`,issuesBtn:`_issuesBtn_a0x57_61`,prsBtn:`_prsBtn_a0x57_72`,repoPills:`_repoPills_a0x57_83`,repoPill:`_repoPill_a0x57_83`,issueCount:`_issueCount_a0x57_106`,tabs:`_tabs_a0x57_112`,tab:`_tab_a0x57_112`,tabActive:`_tabActive_a0x57_131`,markRead:`_markRead_a0x57_137`,content:`_content_a0x57_148`,empty:`_empty_a0x57_150`,notifRow:`_notifRow_a0x57_152`,issueRow:`_issueRow_a0x57_152`,prRow:`_prRow_a0x57_152`,notifRepo:`_notifRepo_a0x57_166`,notifType:`_notifType_a0x57_167`,notifTitle:`_notifTitle_a0x57_168`,notifMeta:`_notifMeta_a0x57_169`,issueNum:`_issueNum_a0x57_171`,issueTitle:`_issueTitle_a0x57_172`,issueMeta:`_issueMeta_a0x57_173`,issueLabel:`_issueLabel_a0x57_174`,prNum:`_prNum_a0x57_176`,prTitle:`_prTitle_a0x57_177`,prAuthor:`_prAuthor_a0x57_178`,prDraft:`_prDraft_a0x57_179`,prMeta:`_prMeta_a0x57_180`};function Yt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),E(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>D(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&D(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})};if(r)return(0,k.jsx)(`div`,{className:q.loading,children:(0,k.jsx)(`div`,{className:`spinner`})});if(t?.error)return(0,k.jsxs)(`div`,{className:q.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:q.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set github-token YOUR_PAT`})]})]});let g=t?.user,v=t?.notifications??[],y=t?.issues??[],b=t?.prs??[];return(0,k.jsxs)(`div`,{className:q.root,children:[g?.login&&(0,k.jsxs)(`div`,{className:q.userRow,children:[g.avatar&&(0,k.jsx)(`img`,{src:g.avatar,className:q.avatar,alt:g.login}),(0,k.jsxs)(`div`,{style:{flex:1},children:[(0,k.jsxs)(`div`,{className:q.userLogin,children:[`@`,g.login]}),g.name&&(0,k.jsx)(`div`,{className:q.userName,children:g.name})]}),(0,k.jsx)(`button`,{className:q.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,k.jsxs)(`div`,{className:q.repoBar,children:[(0,k.jsx)(`input`,{className:q.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,k.jsx)(`button`,{className:q.issuesBtn,onClick:f,children:`Issues`}),(0,k.jsx)(`button`,{className:q.prsBtn,onClick:p,children:`PRs`})]}),g?.repos&&g.repos.length>0&&(0,k.jsx)(`div`,{className:q.repoPills,children:g.repos.slice(0,12).map(e=>(0,k.jsxs)(`button`,{className:q.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,k.jsx)(`span`,{className:q.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,k.jsxs)(`div`,{className:q.tabs,children:[(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`notifs`?q.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,v.length>0?`(${v.length})`:``]}),y.length>0&&(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`issues`?q.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,y.length,`)`]}),b.length>0&&(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`prs`?q.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,b.length,`)`]}),l===`notifs`&&v.length>0&&(0,k.jsx)(`button`,{className:q.markRead,onClick:m,children:`Mark all read`})]}),(0,k.jsxs)(`div`,{className:q.content,children:[l===`notifs`&&(v.length===0?(0,k.jsx)(`div`,{className:q.empty,children:`No notifications`}):v.map((e,t)=>(0,k.jsxs)(`a`,{className:q.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsx)(`span`,{className:q.notifRepo,children:e.repo}),(0,k.jsxs)(`span`,{className:q.notifType,children:[`[`,e.type,`]`]}),(0,k.jsx)(`div`,{className:q.notifTitle,children:e.title}),(0,k.jsxs)(`div`,{className:q.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(y.length===0?(0,k.jsxs)(`div`,{className:q.empty,children:[e(`github.noIssues`),` for `,a]}):y.map((e,t)=>(0,k.jsxs)(`a`,{className:q.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsxs)(`span`,{className:q.issueNum,children:[`#`,e.number]}),(0,k.jsx)(`span`,{className:q.issueTitle,children:e.title}),e.assignee&&(0,k.jsxs)(`span`,{className:q.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,k.jsxs)(`span`,{className:q.issueLabel,children:[`[`,e.labels,`]`]}),(0,k.jsx)(`div`,{className:q.issueMeta,children:e.updated})]},t))),l===`prs`&&(b.length===0?(0,k.jsxs)(`div`,{className:q.empty,children:[`No PRs for `,a]}):b.map((e,t)=>(0,k.jsxs)(`a`,{className:q.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsxs)(`span`,{className:q.prNum,children:[`#`,e.number]}),(0,k.jsx)(`span`,{className:q.prTitle,children:e.title}),(0,k.jsxs)(`span`,{className:q.prAuthor,children:[`by `,e.author]}),e.draft&&(0,k.jsx)(`span`,{className:q.prDraft,children:`DRAFT`}),(0,k.jsx)(`div`,{className:q.prMeta,children:e.updated})]},t)))]})]})}var J={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function Xt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)([]),l=()=>{i(!0),E(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},u=e=>{o(e),E(`/api/slack/messages?channel=${e.id}`).then(e=>c(e?.messages??[]))};if((0,_.useEffect)(()=>{l()},[]),r)return(0,k.jsxs)(`div`,{className:J.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,k.jsxs)(`div`,{className:J.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set slack-token xoxb-YOUR-TOKEN`})]})]});let d=t?.channels??[];return(0,k.jsxs)(`div`,{className:J.twoPane,children:[(0,k.jsxs)(`div`,{className:J.sidebar,children:[(0,k.jsxs)(`div`,{className:J.sidebarTitle,children:[(0,k.jsx)(`span`,{children:`💬 Slack`}),t?.workspace&&(0,k.jsx)(`span`,{className:J.workspace,children:t.workspace})]}),d.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No channels`}),d.map(e=>(0,k.jsxs)(`div`,{className:`${J.channelItem} ${a?.id===e.id?J.channelActive:``}`,onClick:()=>u(e),children:[`# `,e.name]},e.id)),(0,k.jsx)(`button`,{className:J.disconnectBtn,onClick:()=>D(`/api/config`,{key:`slack-token`,value:``}).then(l),children:`Disconnect`})]}),(0,k.jsx)(`div`,{className:J.messagePane,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:J.channelHeader,children:[`#`,a.name]}),s.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No messages`}),s.map((e,t)=>(0,k.jsxs)(`div`,{className:J.message,children:[(0,k.jsx)(`span`,{className:J.msgUser,children:e.username||e.user||`Unknown`}),(0,k.jsx)(`span`,{className:J.msgText,children:e.text}),(0,k.jsx)(`span`,{className:J.msgTs,children:new Date(parseFloat(e.ts)*1e3).toLocaleTimeString()})]},t))]}):(0,k.jsx)(`div`,{className:J.emptyPane,children:`Select a channel`})})]})}function Zt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),E(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),E(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,k.jsxs)(`div`,{className:J.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,k.jsxs)(`div`,{className:J.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,k.jsxs)(`div`,{className:J.twoPane,children:[(0,k.jsxs)(`div`,{className:J.sidebar,children:[(0,k.jsx)(`div`,{className:J.sidebarTitle,children:`📋 Notion`}),(0,k.jsxs)(`div`,{className:J.searchRow,children:[(0,k.jsx)(`input`,{className:J.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,k.jsx)(`button`,{className:J.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No pages found`}),m.map(e=>(0,k.jsxs)(`div`,{className:`${J.channelItem} ${a?.id===e.id?J.channelActive:``}`,onClick:()=>f(e),children:[(0,k.jsx)(`div`,{className:J.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,k.jsx)(`div`,{className:J.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,k.jsx)(`button`,{className:J.disconnectBtn,onClick:()=>D(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,k.jsx)(`div`,{className:J.messagePane,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:J.channelHeader,children:a.title}),a.url&&(0,k.jsx)(`a`,{className:J.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,k.jsx)(`div`,{className:J.pageBody,dangerouslySetInnerHTML:{__html:me(s||`Loading…`)}})]}):(0,k.jsx)(`div`,{className:J.emptyPane,children:`Select a page`})})]})}var Y={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function Qt(e){return e.content||e.plaintext||e.message||``}function $t(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function en(){let e=M(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{E(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{E(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await D(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await D(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await D(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await D(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(D(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await D(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,k.jsxs)(`div`,{className:Y.root,children:[(0,k.jsxs)(`div`,{className:Y.sidebar,children:[(0,k.jsx)(`div`,{className:Y.sidebarHeader,children:(0,k.jsx)(`div`,{className:Y.sidebarTitle,children:`Alexandria`})}),(0,k.jsxs)(`div`,{className:Y.sidebarBtns,children:[(0,k.jsx)(`button`,{className:Y.createBtn,onClick:g,children:`+ Create`}),(0,k.jsx)(`button`,{className:Y.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,k.jsxs)(`div`,{className:Y.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,k.jsxs)(`div`,{className:`${Y.channelItem} ${r===e.id?Y.channelActive:``}`,onClick:()=>i(e.id),children:[(0,k.jsx)(`div`,{className:Y.channelName,children:e.name}),(0,k.jsxs)(`div`,{className:Y.channelMeta,children:[(0,k.jsxs)(`span`,{className:Y.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,k.jsx)(`button`,{className:Y.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,k.jsx)(`div`,{className:Y.main,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Y.chatHeader,children:[(0,k.jsx)(`div`,{className:Y.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,k.jsx)(`div`,{className:Y.chatChannelId,children:r}),(0,k.jsx)(`div`,{className:`${Y.statusDot} ${l?Y.connected:Y.disconnected}`}),(0,k.jsx)(`span`,{className:Y.statusText,children:l?`Live`:`HTTP`})]}),(0,k.jsxs)(`div`,{className:Y.messages,ref:p,children:[a.length===0&&(0,k.jsx)(`div`,{className:Y.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=$t(e),r=Qt(e),i=n===d;return(0,k.jsxs)(`div`,{className:`${Y.msg} ${i?Y.msgSelf:Y.msgOther}`,children:[!i&&(0,k.jsx)(`div`,{className:Y.msgSender,children:n}),(0,k.jsx)(`div`,{className:Y.msgContent,children:r}),(0,k.jsx)(`div`,{className:Y.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,k.jsxs)(`div`,{className:Y.inputRow,children:[(0,k.jsx)(`input`,{className:Y.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,k.jsx)(`button`,{className:Y.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,k.jsxs)(`div`,{className:Y.welcome,children:[(0,k.jsx)(`div`,{className:Y.welcomeIcon,children:`🔐`}),(0,k.jsx)(`div`,{className:Y.welcomeTitle,children:`Alexandria`}),(0,k.jsx)(`div`,{className:Y.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,k.jsxs)(`div`,{className:Y.welcomeBox,children:[(0,k.jsx)(`div`,{className:Y.welcomeBoxTitle,children:`HOW TO USE`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,k.jsx)(`div`,{className:Y.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,k.jsx)(`div`,{className:Y.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,k.jsxs)(`div`,{className:Y.welcomeBox,children:[(0,k.jsx)(`div`,{className:Y.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab create "Project X"`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab join <invite-code>`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab read`})]})]})})]})}var X={root:`_root_14zra_2`,header:`_header_14zra_10`,title:`_title_14zra_21`,subtitle:`_subtitle_14zra_28`,headerTabs:`_headerTabs_14zra_34`,tabBtn:`_tabBtn_14zra_40`,tabActive:`_tabActive_14zra_51`,body:`_body_14zra_58`,editor:`_editor_14zra_67`,examples:`_examples_14zra_75`,sectionLabel:`_sectionLabel_14zra_81`,examplePills:`_examplePills_14zra_89`,examplePill:`_examplePill_14zra_89`,editorCols:`_editorCols_14zra_109`,leftSidebar:`_leftSidebar_14zra_119`,panel:`_panel_14zra_128`,panelHeader:`_panelHeader_14zra_135`,panelTitle:`_panelTitle_14zra_142`,addBtn:`_addBtn_14zra_149`,blockLabel:`_blockLabel_14zra_160`,blockCheck:`_blockCheck_14zra_170`,authField:`_authField_14zra_173`,authFieldInput:`_authFieldInput_14zra_183`,authFieldSelect:`_authFieldSelect_14zra_193`,authFieldReq:`_authFieldReq_14zra_204`,removeFieldBtn:`_removeFieldBtn_14zra_205`,skillsList:`_skillsList_14zra_208`,skillRow:`_skillRow_14zra_210`,skillIcon:`_skillIcon_14zra_218`,skillName:`_skillName_14zra_220`,skillBadge:`_skillBadge_14zra_229`,skillBadge_skill:`_skillBadge_skill_14zra_237`,skillBadge_memory:`_skillBadge_memory_14zra_238`,skillBadge_provider:`_skillBadge_provider_14zra_239`,skillBadge_log:`_skillBadge_log_14zra_240`,skillEmpty:`_skillEmpty_14zra_242`,skillBtn:`_skillBtn_14zra_244`,skillsEmpty:`_skillsEmpty_14zra_246`,snapshotRow:`_snapshotRow_14zra_249`,snapshotTs:`_snapshotTs_14zra_258`,snapshotCount:`_snapshotCount_14zra_259`,snapshotBtn:`_snapshotBtn_14zra_260`,genStatus:`_genStatus_14zra_263`,repairStatus:`_repairStatus_14zra_265`,repairStatusTitle:`_repairStatusTitle_14zra_266`,repairStatusProg:`_repairStatusProg_14zra_267`,repairStatusFile:`_repairStatusFile_14zra_268`,actionRow:`_actionRow_14zra_271`,actionBtn:`_actionBtn_14zra_273`,actionBtnIcon:`_actionBtnIcon_14zra_275`,actionBtnActive:`_actionBtnActive_14zra_276`,repairBtn:`_repairBtn_14zra_278`,sandboxBtn:`_sandboxBtn_14zra_280`,statsBar:`_statsBar_14zra_282`,rightPanel:`_rightPanel_14zra_285`,rightTabBar:`_rightTabBar_14zra_296`,rightTab:`_rightTab_14zra_296`,rightTabActive:`_rightTabActive_14zra_313`,repairBar:`_repairBar_14zra_316`,repairBarRow:`_repairBarRow_14zra_326`,repairBarIcon:`_repairBarIcon_14zra_327`,repairBarLabel:`_repairBarLabel_14zra_328`,repairBarFile:`_repairBarFile_14zra_329`,repairBarCounter:`_repairBarCounter_14zra_330`,repairBarTime:`_repairBarTime_14zra_331`,genBar:`_genBar_14zra_333`,genBarRow:`_genBarRow_14zra_343`,genBarRobot:`_genBarRobot_14zra_344`,robotBob:`_robotBob_14zra_1`,genBarLabel:`_genBarLabel_14zra_345`,genBarFile:`_genBarFile_14zra_346`,genBarCounter:`_genBarCounter_14zra_347`,genBarTime:`_genBarTime_14zra_348`,progressTrack:`_progressTrack_14zra_350`,repairProgress:`_repairProgress_14zra_351`,genProgress:`_genProgress_14zra_352`,genDots:`_genDots_14zra_355`,dot:`_dot_14zra_356`,dot1:`_dot1_14zra_357`,dotBounce:`_dotBounce_14zra_1`,dot2:`_dot2_14zra_358`,dot3:`_dot3_14zra_359`,stopBtn:`_stopBtn_14zra_362`,codeArea:`_codeArea_14zra_365`,sandboxWrap:`_sandboxWrap_14zra_366`,sandboxFrame:`_sandboxFrame_14zra_367`,sandboxEmpty:`_sandboxEmpty_14zra_368`,sandboxStartBtn:`_sandboxStartBtn_14zra_369`,noFiles:`_noFiles_14zra_371`,noFilesIcon:`_noFilesIcon_14zra_372`,codeLayout:`_codeLayout_14zra_374`,codeViewer:`_codeViewer_14zra_376`,codeHeader:`_codeHeader_14zra_384`,codeFileIcon:`_codeFileIcon_14zra_397`,codeFileName:`_codeFileName_14zra_398`,codeFileMeta:`_codeFileMeta_14zra_399`,fileError:`_fileError_14zra_401`,fileSyntaxError:`_fileSyntaxError_14zra_402`,filePending:`_filePending_14zra_403`,code:`_code_14zra_365`,codeError:`_codeError_14zra_418`,codeSyntaxError:`_codeSyntaxError_14zra_419`,fileSidebar:`_fileSidebar_14zra_422`,fileSidebarHeader:`_fileSidebarHeader_14zra_431`,fileTab:`_fileTab_14zra_441`,fileTabActive:`_fileTabActive_14zra_457`,fileTabError:`_fileTabError_14zra_458`,fileTabRow:`_fileTabRow_14zra_460`,fileTabIcon:`_fileTabIcon_14zra_461`,fileTabName:`_fileTabName_14zra_462`,fileTabDir:`_fileTabDir_14zra_463`,fileTabMeta:`_fileTabMeta_14zra_464`,projectsList:`_projectsList_14zra_467`,emptyProjects:`_emptyProjects_14zra_469`,emptyIcon:`_emptyIcon_14zra_470`,emptyHint:`_emptyHint_14zra_471`,projectCard:`_projectCard_14zra_473`,projectInfo:`_projectInfo_14zra_474`,projectName:`_projectName_14zra_475`,projectDesc:`_projectDesc_14zra_476`,projectMeta:`_projectMeta_14zra_477`,openBtn:`_openBtn_14zra_478`,deleteBtn:`_deleteBtn_14zra_479`,planBanner:`_planBanner_14zra_482`,planTitle:`_planTitle_14zra_491`,planText:`_planText_14zra_492`,planActions:`_planActions_14zra_493`,planApprove:`_planApprove_14zra_494`,planReject:`_planReject_14zra_495`,grepPanel:`_grepPanel_14zra_498`,grepRow:`_grepRow_14zra_507`,grepInput:`_grepInput_14zra_508`,grepBtn:`_grepBtn_14zra_510`,grepClose:`_grepClose_14zra_511`,grepCount:`_grepCount_14zra_512`,grepResults:`_grepResults_14zra_513`,grepEmpty:`_grepEmpty_14zra_514`,grepMatch:`_grepMatch_14zra_515`,grepMatchFile:`_grepMatchFile_14zra_517`,grepMatchLine:`_grepMatchLine_14zra_518`,diffPanel:`_diffPanel_14zra_521`,diffHeader:`_diffHeader_14zra_530`,diffClose:`_diffClose_14zra_531`,diffFile:`_diffFile_14zra_532`,diffSummary:`_diffSummary_14zra_533`,diffArrow:`_diffArrow_14zra_534`,diffFileName:`_diffFileName_14zra_535`,diffAdded:`_diffAdded_14zra_536`,diffRemoved:`_diffRemoved_14zra_537`,diffContent:`_diffContent_14zra_538`,diffInline:`_diffInline_14zra_541`,diffInlineHeader:`_diffInlineHeader_14zra_542`,diffRemLine:`_diffRemLine_14zra_543`,diffAddLine:`_diffAddLine_14zra_544`,chatPanel:`_chatPanel_14zra_547`,chatMessages:`_chatMessages_14zra_556`,chatWelcome:`_chatWelcome_14zra_558`,chatUser:`_chatUser_14zra_560`,chatUserBubble:`_chatUserBubble_14zra_561`,chatAttachPreviews:`_chatAttachPreviews_14zra_562`,chatAttachBadge:`_chatAttachBadge_14zra_563`,chatSystem:`_chatSystem_14zra_565`,chatSystemBubble:`_chatSystemBubble_14zra_566`,chatSyntaxErr:`_chatSyntaxErr_14zra_567`,chatAgent:`_chatAgent_14zra_569`,chatAgentCard:`_chatAgentCard_14zra_570`,chatAgentHeader:`_chatAgentHeader_14zra_571`,chatAgentRobot:`_chatAgentRobot_14zra_572`,chatAgentRobotAnim:`_chatAgentRobotAnim_14zra_573`,chatAgentLabel:`_chatAgentLabel_14zra_574`,chatRunningDots:`_chatRunningDots_14zra_575`,chatAgentText:`_chatAgentText_14zra_576`,chatToolBadges:`_chatToolBadges_14zra_577`,toolBadge:`_toolBadge_14zra_578`,toolBadgeOk:`_toolBadgeOk_14zra_579`,toolBadgeErr:`_toolBadgeErr_14zra_580`,cursor:`_cursor_14zra_582`,blink:`_blink_14zra_1`,attachPreviews:`_attachPreviews_14zra_585`,attachBadge:`_attachBadge_14zra_586`,removeAttachBtn:`_removeAttachBtn_14zra_587`,projNameRow:`_projNameRow_14zra_590`,projNameLabel:`_projNameLabel_14zra_591`,projNameInput:`_projNameInput_14zra_592`,projActiveRow:`_projActiveRow_14zra_593`,projActiveName:`_projActiveName_14zra_594`,chatInputRow:`_chatInputRow_14zra_597`,attachLabel:`_attachLabel_14zra_598`,chatTextarea:`_chatTextarea_14zra_599`,chatSendCol:`_chatSendCol_14zra_602`,chatSendBtn:`_chatSendBtn_14zra_603`,chatStopBtn:`_chatStopBtn_14zra_605`,modalOverlay:`_modalOverlay_14zra_608`,modal:`_modal_14zra_608`,modalHeader:`_modalHeader_14zra_630`,modalTitle:`_modalTitle_14zra_631`,modalClose:`_modalClose_14zra_632`,modalBody:`_modalBody_14zra_634`,modalRow:`_modalRow_14zra_636`,modalField:`_modalField_14zra_637`,modalLabel:`_modalLabel_14zra_638`,modalLabelRow:`_modalLabelRow_14zra_639`,modalSelect:`_modalSelect_14zra_641`,modalInput:`_modalInput_14zra_642`,modalHint:`_modalHint_14zra_645`,modalAiBox:`_modalAiBox_14zra_647`,modalAiRow:`_modalAiRow_14zra_648`,modalAiDesc:`_modalAiDesc_14zra_649`,modalAiBtn:`_modalAiBtn_14zra_650`,modalContentArea:`_modalContentArea_14zra_653`,logView:`_logView_14zra_656`,modalFooter:`_modalFooter_14zra_658`,modalCancelBtn:`_modalCancelBtn_14zra_659`,modalSaveBtn:`_modalSaveBtn_14zra_660`},tn=[{name:`MySaaS`,desc:`SaaS product landing page. Hero: large headline, subheadline, two CTA buttons (Start free trial / Watch demo), animated gradient background. Features section: 3-column grid with icon, title, description for 6 features. Pricing section: 3 cards (Free / Pro $29/mo / Enterprise). Testimonials: 3 customer quotes. FAQ accordion: 5 questions. Footer with links and social icons. Sticky nav.`},{name:`MyShop`,desc:`E-commerce storefront homepage. Nav with logo, search bar, cart badge, hamburger mobile menu. Hero banner. Category strip: 6 cards. Featured products grid: 8 cards with rating, price, Add to Cart, wishlist. Promo banner. Newsletter signup. Responsive.`},{name:`MyBlog`,desc:`Blog platform homepage. Nav with category links. Hero: featured article card. Article grid: 6 cards. Sidebar: recent posts, tags cloud, newsletter widget. Pagination. Author bio section. Minimal footer.`},{name:`MyPortfolio`,desc:`Developer portfolio. Nav with scroll hide/show. Hero: typewriter role subtitle, CTA buttons. Work section: 6 project cards. Skills grouped by category with bars. About: timeline of milestones. Contact form. Scroll entrance animations via Intersection Observer.`},{name:`MyRestaurant`,desc:`Restaurant website. Nav: logo center, transparent→solid on scroll. Hero: full-viewport with overlay. Menu preview: tabbed (Starters/Mains/Desserts/Drinks). Reservation form. Gallery 3x3 mosaic. Chef section. Testimonials horizontal scroll.`},{name:`MyJobBoard`,desc:`Job board homepage. Hero search widget. Stats strip. Featured jobs list: 8 cards with company, location badge, salary, Quick Apply. Filter sidebar. Top companies section. Category cards. Newsletter.`}],nn=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],rn={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`{`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function an(e){return rn[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function on(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function sn(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function cn(){let e=M(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[d,f]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(0),[w,ee]=(0,_.useState)(0),[te,ne]=(0,_.useState)(``),[T,re]=(0,_.useState)({fi:0,total:0,name:``}),[ie,O]=(0,_.useState)(null),[ae,A]=(0,_.useState)([]),[j,oe]=(0,_.useState)(``),[se,ce]=(0,_.useState)(!1),[le,ue]=(0,_.useState)([]),[N,de]=(0,_.useState)(null),[fe,pe]=(0,_.useState)([]),[me,P]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(null),[_e,ve]=(0,_.useState)([]),[F,ye]=(0,_.useState)(!1),[be,xe]=(0,_.useState)(``),[I,L]=(0,_.useState)([]),[Se,Ce]=(0,_.useState)([]),[we,Te]=(0,_.useState)([]),[Ee,De]=(0,_.useState)(null),[Oe,ke]=(0,_.useState)(`0s`),[Ae,je]=(0,_.useState)(`0s`),R=(0,_.useRef)(0),Me=(0,_.useRef)(0),Ne=(0,_.useRef)(null),Pe=(0,_.useRef)(null),Fe=(0,_.useRef)(null),Ie=(0,_.useRef)(null);function Le(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(v||b?Ne.current=setInterval(()=>{v&&ke(Le(R.current)),b&&je(Le(Me.current))},1e3):Ne.current&&=(clearInterval(Ne.current),null),()=>{Ne.current&&clearInterval(Ne.current)}),[v,b]);function Re(){Fe.current&&(Fe.current.scrollTop=Fe.current.scrollHeight)}(0,_.useEffect)(()=>{Re()},[ae]),(0,_.useEffect)(()=>{a&&p.length>0&&!me&&(P(!0),E(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`).then(e=>{e?.skills&&pe(e.skills)}).catch(()=>{}))},[a,p.length,me]);async function ze(e,t){if(v||!e||e.length<5)return;y(!0),m([]),g(0),re({fi:0,total:0,name:``}),R.current=Date.now(),ke(`0s`),Pe.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:Pe.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:l,authFields:d})});if(!r.ok||!r.body){y(!1);return}let i=r.body.getReader(),a=new TextDecoder,o=``,s=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let r=o.split(`
|
|
530
|
+
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},he=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=T.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),N(e,{voiceActive:!1});return}let r=new t;T.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;N(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>N(e,{voiceActive:!1}),r.onerror=()=>N(e,{voiceActive:!1}),r.start(),N(e,{voiceActive:!0})},ge=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];N(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{N(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},_e=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];N(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},ve=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),ee(``)},F=async e=>{let t=await E(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),ee(``)},ye=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){ee(`Tagline and system prompt are required.`);return}ne(!0),ee(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){ee(`Agent name required (lowercase, no spaces).`),ne(!1);return}let t=await D(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){ee(`Error: `+t.error),ne(!1);return}}else await D(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),oe()}catch(e){ee(`Error: `+e.message)}finally{ne(!1)}}},be=e=>{confirm(`Delete agent "${e.label}"?`)&&D(`/api/agents/${e.id}`,{},`DELETE`).then(()=>oe())};return r?(0,k.jsx)(`div`,{className:G.root,children:(0,k.jsx)(`div`,{className:G.loading,children:(0,k.jsx)(`div`,{className:`spinner`})})}):(0,k.jsxs)(`div`,{className:G.root,children:[(0,k.jsxs)(`div`,{className:G.gridSection,children:[(0,k.jsxs)(`div`,{className:G.gridHeader,children:[(0,k.jsxs)(`div`,{className:G.headerRow,children:[(0,k.jsx)(`input`,{className:G.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,k.jsx)(`button`,{className:G.createBtn,onClick:ve,children:`+ Create`})]}),(0,k.jsx)(`div`,{className:G.catTabs,children:se.map(e=>(0,k.jsxs)(`button`,{className:`${G.catTab} ${s===e?G.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,k.jsx)(`div`,{className:G.grid,children:ce.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,k.jsxs)(`div`,{className:`${G.agentCard} ${t?G.agentActive:``}`,onClick:()=>le(e),children:[(0,k.jsxs)(`div`,{className:G.agentCardTop,children:[(0,k.jsx)(`div`,{className:G.agentIcon,children:e.icon}),e.isCustom&&(0,k.jsxs)(`div`,{className:G.agentActions,children:[(0,k.jsx)(`button`,{className:G.agentEditBtn,onClick:t=>{t.stopPropagation(),F(e)},children:`✏️`}),(0,k.jsx)(`button`,{className:G.agentDelBtn,onClick:t=>{t.stopPropagation(),be(e)},children:`🗑`})]})]}),(0,k.jsx)(`div`,{className:G.agentLabel,children:e.label}),(0,k.jsx)(`div`,{className:G.agentDesc,children:e.description}),(0,k.jsx)(`div`,{className:G.agentCat,children:e.category})]},e.id)})})]}),(0,k.jsx)(`div`,{className:G.chatArea,children:l.length===0?(0,k.jsxs)(`div`,{className:G.emptyChat,children:[(0,k.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,k.jsx)(`span`,{className:G.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,k.jsxs)(`div`,{className:G.chatPanel,children:[(0,k.jsxs)(`div`,{className:G.chatHeader,children:[(0,k.jsx)(`span`,{className:G.chatIcon,children:t.icon}),(0,k.jsxs)(`div`,{className:G.chatHeaderInfo,children:[(0,k.jsx)(`div`,{className:G.chatAgentName,children:t.label}),(0,k.jsx)(`div`,{className:G.chatAgentDesc,children:t.description})]}),(0,k.jsx)(`button`,{className:G.closeChat,onClick:()=>ue(t.id),children:`✕`})]}),(0,k.jsxs)(`div`,{className:G.chatMessages,ref:e=>{O.current.set(t.id,e)},children:[e.history.length===0&&(0,k.jsxs)(`div`,{className:G.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,k.jsx)(`div`,{className:`${G.chatMsg} ${e.role===`user`?G.msgUser:G.msgAgent}`,children:e.role===`assistant`?(0,k.jsx)(`div`,{dangerouslySetInnerHTML:{__html:me(e.content||`…`)}}):(0,k.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,k.jsxs)(`div`,{className:G.thinking,children:[(0,k.jsx)(`span`,{className:G.dot}),(0,k.jsx)(`span`,{className:G.dot}),(0,k.jsx)(`span`,{className:G.dot})]})]}),n&&(0,k.jsxs)(`div`,{className:G.attachBar,children:[(0,k.jsx)(`span`,{children:n}),(0,k.jsx)(`button`,{className:G.attachClear,onClick:()=>N(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,k.jsxs)(`div`,{className:G.chatInput,children:[(0,k.jsxs)(`div`,{className:G.chatTools,children:[(0,k.jsx)(`button`,{className:`${G.toolBtn} ${e.voiceActive?G.toolBtnActive:``}`,onClick:()=>he(t.id),title:`Voice`,children:`🎤`}),(0,k.jsx)(`button`,{className:G.toolBtn,onClick:()=>ae.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,k.jsx)(`button`,{className:G.toolBtn,onClick:()=>A.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,k.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{ae.current.set(t.id,e)},onChange:e=>ge(t.id,e.target.files?.[0])}),(0,k.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{A.current.set(t.id,e)},onChange:e=>_e(t.id,e.target.files?.[0])})]}),(0,k.jsxs)(`div`,{className:G.chatInputRow,children:[(0,k.jsx)(`textarea`,{className:G.chatTextarea,value:e.input,onChange:e=>N(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),pe(e,e.input,e.attachedFile,e.attachedImage))}}),(0,k.jsx)(`button`,{className:G.sendBtn,onClick:()=>pe(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,k.jsxs)(`div`,{className:G.orchBar,children:[(0,k.jsxs)(`div`,{className:G.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,k.jsxs)(`div`,{className:G.orchRow,children:[(0,k.jsx)(`textarea`,{ref:j,className:G.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),P())}}),(0,k.jsx)(`button`,{className:G.orchBtn,onClick:P,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,k.jsxs)(`div`,{className:G.orchSynthesis,children:[(0,k.jsxs)(`div`,{className:G.orchSynthHeader,children:[(0,k.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,k.jsx)(`span`,{className:G.orchSynthSpinner,children:`synthesizing…`})]}),(0,k.jsx)(`div`,{className:G.orchSynthBody,dangerouslySetInnerHTML:{__html:me(h||`…`)}})]})]}),b&&(0,k.jsx)(`div`,{className:G.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,k.jsxs)(`div`,{className:G.modal,children:[(0,k.jsx)(`div`,{className:G.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,k.jsx)(`input`,{className:G.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`Tagline`}),(0,k.jsx)(`input`,{className:G.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,k.jsxs)(`div`,{className:G.formField,children:[(0,k.jsx)(`label`,{className:G.formLabel,children:`System Prompt`}),(0,k.jsx)(`textarea`,{className:G.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,k.jsx)(`div`,{className:G.formError,children:w}),(0,k.jsxs)(`div`,{className:G.modalBtns,children:[(0,k.jsx)(`button`,{className:G.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,k.jsx)(`button`,{className:G.modalSaveBtn,onClick:ye,disabled:te,children:te?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var K={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function Kt(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function qt(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function Jt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),ee=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),E(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{ee()},[]);let te=e=>{c(e),ee(e,l)},ne=()=>{u(d),ee(s,d)},T=(e,t)=>{i(!0),E(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},re=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await D(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ie=(e,t)=>{i(!0),E(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},O=(e,t)=>{i(!0),E(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},ae=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&D(`/api/drive/delete/${e}`,{}).then(()=>{n(null),ee()})},A=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&D(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?T(t.id,e):ee()}).catch(e=>alert(`Error: `+e.message))},j=()=>{w.current?.click()},oe=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;D(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),ee()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,k.jsxs)(`div`,{className:K.error,children:[(0,k.jsx)(`div`,{children:a}),(0,k.jsxs)(`div`,{className:K.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,k.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,k.jsxs)(`div`,{className:K.editorRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:h.name}),(0,k.jsx)(`button`,{className:K.saveBtn,onClick:re,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,k.jsx)(`textarea`,{className:K.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,k.jsxs)(`div`,{className:K.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,k.jsxs)(`div`,{className:K.viewerRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:b.name})]}),(0,k.jsx)(`div`,{className:K.imgContainer,children:(0,k.jsx)(`img`,{src:b.src,alt:b.name,className:K.imgView})})]});if(p===`pdf`&&b)return(0,k.jsxs)(`div`,{className:K.viewerRoot,children:[(0,k.jsxs)(`div`,{className:K.editorToolbar,children:[(0,k.jsx)(`button`,{className:K.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,k.jsx)(`span`,{className:K.editorName,children:b.name})]}),(0,k.jsx)(`iframe`,{className:K.pdfFrame,src:b.src,title:b.name})]});let se=t?.files??[],ce=t?.quota;return(0,k.jsxs)(`div`,{className:K.root,children:[ce&&(0,k.jsxs)(`div`,{className:K.quotaBar,children:[(0,k.jsxs)(`div`,{className:K.quotaText,children:[(0,k.jsxs)(`span`,{className:K.quotaUsed,children:[ce.usage,` of `,ce.limit,` used`]}),(0,k.jsxs)(`span`,{className:K.quotaPct,children:[ce.percentUsed,`%`]})]}),(0,k.jsx)(`div`,{className:K.quotaTrack,children:(0,k.jsx)(`div`,{className:K.quotaFill,style:{width:`${Math.min(ce.percentUsed,100)}%`,background:ce.percentUsed>90?`var(--red)`:ce.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,k.jsxs)(`div`,{className:K.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,k.jsx)(`button`,{className:`${K.filterBtn} ${s===e?K.filterActive:``}`,onClick:()=>te(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,k.jsx)(`div`,{className:K.spacer}),(0,k.jsx)(`button`,{className:K.newBtn,onClick:A,children:`+ New File`}),(0,k.jsx)(`button`,{className:K.uploadBtn,onClick:j,children:e(`drive.upload`)}),(0,k.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>oe(e.target.files?.[0])})]}),(0,k.jsxs)(`div`,{className:K.searchRow,children:[(0,k.jsx)(`input`,{className:K.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ne()}),(0,k.jsx)(`button`,{className:K.searchBtn,onClick:ne,children:`Search`})]}),r&&(0,k.jsx)(`div`,{className:K.loading,children:(0,k.jsx)(`div`,{className:`spinner`})}),!r&&se.length===0&&(0,k.jsxs)(`div`,{className:K.empty,children:[e(`drive.noFiles`),` found`]}),(0,k.jsx)(`div`,{className:K.fileList,children:se.map(e=>{let t=qt(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,k.jsxs)(`div`,{className:K.fileRow,onClick:()=>{t?T(e.id,e.name):n?ie(e.id,e.name):r?O(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,k.jsx)(`span`,{className:K.fileIcon,children:Kt(e.type,e.mimeType)}),(0,k.jsxs)(`div`,{className:K.fileInfo,children:[(0,k.jsx)(`div`,{className:K.fileName,children:e.name}),(0,k.jsxs)(`div`,{className:K.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,k.jsxs)(`div`,{className:K.fileBtns,children:[t&&(0,k.jsx)(`button`,{className:K.editBtn,onClick:t=>{t.stopPropagation(),T(e.id,e.name)},children:`Edit`}),n&&(0,k.jsx)(`button`,{className:K.viewBtn,onClick:t=>{t.stopPropagation(),ie(e.id,e.name)},children:`View`}),r&&(0,k.jsx)(`button`,{className:K.pdfBtn,onClick:t=>{t.stopPropagation(),O(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,k.jsx)(`a`,{className:K.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,k.jsx)(`button`,{className:K.delBtn,onClick:t=>{t.stopPropagation(),ae(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var q={root:`_root_a0x57_1`,loading:`_loading_a0x57_10`,errorBox:`_errorBox_a0x57_12`,errorHint:`_errorHint_a0x57_13`,userRow:`_userRow_a0x57_16`,avatar:`_avatar_a0x57_27`,userLogin:`_userLogin_a0x57_29`,userName:`_userName_a0x57_30`,disconnectBtn:`_disconnectBtn_a0x57_32`,repoBar:`_repoBar_a0x57_43`,repoInput:`_repoInput_a0x57_49`,issuesBtn:`_issuesBtn_a0x57_61`,prsBtn:`_prsBtn_a0x57_72`,repoPills:`_repoPills_a0x57_83`,repoPill:`_repoPill_a0x57_83`,issueCount:`_issueCount_a0x57_106`,tabs:`_tabs_a0x57_112`,tab:`_tab_a0x57_112`,tabActive:`_tabActive_a0x57_131`,markRead:`_markRead_a0x57_137`,content:`_content_a0x57_148`,empty:`_empty_a0x57_150`,notifRow:`_notifRow_a0x57_152`,issueRow:`_issueRow_a0x57_152`,prRow:`_prRow_a0x57_152`,notifRepo:`_notifRepo_a0x57_166`,notifType:`_notifType_a0x57_167`,notifTitle:`_notifTitle_a0x57_168`,notifMeta:`_notifMeta_a0x57_169`,issueNum:`_issueNum_a0x57_171`,issueTitle:`_issueTitle_a0x57_172`,issueMeta:`_issueMeta_a0x57_173`,issueLabel:`_issueLabel_a0x57_174`,prNum:`_prNum_a0x57_176`,prTitle:`_prTitle_a0x57_177`,prAuthor:`_prAuthor_a0x57_178`,prDraft:`_prDraft_a0x57_179`,prMeta:`_prMeta_a0x57_180`};function Yt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),E(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>D(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&D(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})};if(r)return(0,k.jsx)(`div`,{className:q.loading,children:(0,k.jsx)(`div`,{className:`spinner`})});if(t?.error)return(0,k.jsxs)(`div`,{className:q.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:q.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set github-token YOUR_PAT`})]})]});let g=t?.user,v=t?.notifications??[],y=t?.issues??[],b=t?.prs??[];return(0,k.jsxs)(`div`,{className:q.root,children:[g?.login&&(0,k.jsxs)(`div`,{className:q.userRow,children:[g.avatar&&(0,k.jsx)(`img`,{src:g.avatar,className:q.avatar,alt:g.login}),(0,k.jsxs)(`div`,{style:{flex:1},children:[(0,k.jsxs)(`div`,{className:q.userLogin,children:[`@`,g.login]}),g.name&&(0,k.jsx)(`div`,{className:q.userName,children:g.name})]}),(0,k.jsx)(`button`,{className:q.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,k.jsxs)(`div`,{className:q.repoBar,children:[(0,k.jsx)(`input`,{className:q.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,k.jsx)(`button`,{className:q.issuesBtn,onClick:f,children:`Issues`}),(0,k.jsx)(`button`,{className:q.prsBtn,onClick:p,children:`PRs`})]}),g?.repos&&g.repos.length>0&&(0,k.jsx)(`div`,{className:q.repoPills,children:g.repos.slice(0,12).map(e=>(0,k.jsxs)(`button`,{className:q.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,k.jsx)(`span`,{className:q.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,k.jsxs)(`div`,{className:q.tabs,children:[(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`notifs`?q.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,v.length>0?`(${v.length})`:``]}),y.length>0&&(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`issues`?q.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,y.length,`)`]}),b.length>0&&(0,k.jsxs)(`button`,{className:`${q.tab} ${l===`prs`?q.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,b.length,`)`]}),l===`notifs`&&v.length>0&&(0,k.jsx)(`button`,{className:q.markRead,onClick:m,children:`Mark all read`})]}),(0,k.jsxs)(`div`,{className:q.content,children:[l===`notifs`&&(v.length===0?(0,k.jsx)(`div`,{className:q.empty,children:`No notifications`}):v.map((e,t)=>(0,k.jsxs)(`a`,{className:q.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsx)(`span`,{className:q.notifRepo,children:e.repo}),(0,k.jsxs)(`span`,{className:q.notifType,children:[`[`,e.type,`]`]}),(0,k.jsx)(`div`,{className:q.notifTitle,children:e.title}),(0,k.jsxs)(`div`,{className:q.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(y.length===0?(0,k.jsxs)(`div`,{className:q.empty,children:[e(`github.noIssues`),` for `,a]}):y.map((e,t)=>(0,k.jsxs)(`a`,{className:q.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsxs)(`span`,{className:q.issueNum,children:[`#`,e.number]}),(0,k.jsx)(`span`,{className:q.issueTitle,children:e.title}),e.assignee&&(0,k.jsxs)(`span`,{className:q.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,k.jsxs)(`span`,{className:q.issueLabel,children:[`[`,e.labels,`]`]}),(0,k.jsx)(`div`,{className:q.issueMeta,children:e.updated})]},t))),l===`prs`&&(b.length===0?(0,k.jsxs)(`div`,{className:q.empty,children:[`No PRs for `,a]}):b.map((e,t)=>(0,k.jsxs)(`a`,{className:q.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,k.jsxs)(`span`,{className:q.prNum,children:[`#`,e.number]}),(0,k.jsx)(`span`,{className:q.prTitle,children:e.title}),(0,k.jsxs)(`span`,{className:q.prAuthor,children:[`by `,e.author]}),e.draft&&(0,k.jsx)(`span`,{className:q.prDraft,children:`DRAFT`}),(0,k.jsx)(`div`,{className:q.prMeta,children:e.updated})]},t)))]})]})}var J={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function Xt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)([]),l=()=>{i(!0),E(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},u=e=>{o(e),E(`/api/slack/messages?channel=${e.id}`).then(e=>c(e?.messages??[]))};if((0,_.useEffect)(()=>{l()},[]),r)return(0,k.jsxs)(`div`,{className:J.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,k.jsxs)(`div`,{className:J.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set slack-token xoxb-YOUR-TOKEN`})]})]});let d=t?.channels??[];return(0,k.jsxs)(`div`,{className:J.twoPane,children:[(0,k.jsxs)(`div`,{className:J.sidebar,children:[(0,k.jsxs)(`div`,{className:J.sidebarTitle,children:[(0,k.jsx)(`span`,{children:`💬 Slack`}),t?.workspace&&(0,k.jsx)(`span`,{className:J.workspace,children:t.workspace})]}),d.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No channels`}),d.map(e=>(0,k.jsxs)(`div`,{className:`${J.channelItem} ${a?.id===e.id?J.channelActive:``}`,onClick:()=>u(e),children:[`# `,e.name]},e.id)),(0,k.jsx)(`button`,{className:J.disconnectBtn,onClick:()=>D(`/api/config`,{key:`slack-token`,value:``}).then(l),children:`Disconnect`})]}),(0,k.jsx)(`div`,{className:J.messagePane,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:J.channelHeader,children:[`#`,a.name]}),s.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No messages`}),s.map((e,t)=>(0,k.jsxs)(`div`,{className:J.message,children:[(0,k.jsx)(`span`,{className:J.msgUser,children:e.username||e.user||`Unknown`}),(0,k.jsx)(`span`,{className:J.msgText,children:e.text}),(0,k.jsx)(`span`,{className:J.msgTs,children:new Date(parseFloat(e.ts)*1e3).toLocaleTimeString()})]},t))]}):(0,k.jsx)(`div`,{className:J.emptyPane,children:`Select a channel`})})]})}function Zt(){let e=M(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),E(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),E(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,k.jsxs)(`div`,{className:J.loading,children:[(0,k.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,k.jsxs)(`div`,{className:J.errorBox,children:[(0,k.jsx)(`div`,{children:t.error}),(0,k.jsxs)(`div`,{className:J.errorHint,children:[`Run: `,(0,k.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,k.jsxs)(`div`,{className:J.twoPane,children:[(0,k.jsxs)(`div`,{className:J.sidebar,children:[(0,k.jsx)(`div`,{className:J.sidebarTitle,children:`📋 Notion`}),(0,k.jsxs)(`div`,{className:J.searchRow,children:[(0,k.jsx)(`input`,{className:J.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,k.jsx)(`button`,{className:J.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,k.jsx)(`div`,{className:J.empty,children:`No pages found`}),m.map(e=>(0,k.jsxs)(`div`,{className:`${J.channelItem} ${a?.id===e.id?J.channelActive:``}`,onClick:()=>f(e),children:[(0,k.jsx)(`div`,{className:J.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,k.jsx)(`div`,{className:J.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,k.jsx)(`button`,{className:J.disconnectBtn,onClick:()=>D(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,k.jsx)(`div`,{className:J.messagePane,children:a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:J.channelHeader,children:a.title}),a.url&&(0,k.jsx)(`a`,{className:J.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,k.jsx)(`div`,{className:J.pageBody,dangerouslySetInnerHTML:{__html:me(s||`Loading…`)}})]}):(0,k.jsx)(`div`,{className:J.emptyPane,children:`Select a page`})})]})}var Y={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function Qt(e){return e.content||e.plaintext||e.message||``}function $t(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function en(){let e=M(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{E(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{E(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await D(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await D(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await D(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await D(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(D(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await D(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,k.jsxs)(`div`,{className:Y.root,children:[(0,k.jsxs)(`div`,{className:Y.sidebar,children:[(0,k.jsx)(`div`,{className:Y.sidebarHeader,children:(0,k.jsx)(`div`,{className:Y.sidebarTitle,children:`Alexandria`})}),(0,k.jsxs)(`div`,{className:Y.sidebarBtns,children:[(0,k.jsx)(`button`,{className:Y.createBtn,onClick:g,children:`+ Create`}),(0,k.jsx)(`button`,{className:Y.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,k.jsxs)(`div`,{className:Y.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,k.jsxs)(`div`,{className:`${Y.channelItem} ${r===e.id?Y.channelActive:``}`,onClick:()=>i(e.id),children:[(0,k.jsx)(`div`,{className:Y.channelName,children:e.name}),(0,k.jsxs)(`div`,{className:Y.channelMeta,children:[(0,k.jsxs)(`span`,{className:Y.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,k.jsx)(`button`,{className:Y.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,k.jsx)(`div`,{className:Y.main,children:r?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:Y.chatHeader,children:[(0,k.jsx)(`div`,{className:Y.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,k.jsx)(`div`,{className:Y.chatChannelId,children:r}),(0,k.jsx)(`div`,{className:`${Y.statusDot} ${l?Y.connected:Y.disconnected}`}),(0,k.jsx)(`span`,{className:Y.statusText,children:l?`Live`:`HTTP`})]}),(0,k.jsxs)(`div`,{className:Y.messages,ref:p,children:[a.length===0&&(0,k.jsx)(`div`,{className:Y.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=$t(e),r=Qt(e),i=n===d;return(0,k.jsxs)(`div`,{className:`${Y.msg} ${i?Y.msgSelf:Y.msgOther}`,children:[!i&&(0,k.jsx)(`div`,{className:Y.msgSender,children:n}),(0,k.jsx)(`div`,{className:Y.msgContent,children:r}),(0,k.jsx)(`div`,{className:Y.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,k.jsxs)(`div`,{className:Y.inputRow,children:[(0,k.jsx)(`input`,{className:Y.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,k.jsx)(`button`,{className:Y.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,k.jsxs)(`div`,{className:Y.welcome,children:[(0,k.jsx)(`div`,{className:Y.welcomeIcon,children:`🔐`}),(0,k.jsx)(`div`,{className:Y.welcomeTitle,children:`Alexandria`}),(0,k.jsx)(`div`,{className:Y.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,k.jsxs)(`div`,{className:Y.welcomeBox,children:[(0,k.jsx)(`div`,{className:Y.welcomeBoxTitle,children:`HOW TO USE`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,k.jsx)(`div`,{className:Y.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,k.jsx)(`div`,{className:Y.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,k.jsxs)(`div`,{className:Y.welcomeStep,children:[(0,k.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,k.jsxs)(`div`,{className:Y.welcomeBox,children:[(0,k.jsx)(`div`,{className:Y.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab create "Project X"`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab join <invite-code>`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,k.jsx)(`div`,{className:Y.cliCmd,children:`nha collab read`})]})]})})]})}var X={root:`_root_1xa21_2`,header:`_header_1xa21_10`,title:`_title_1xa21_21`,subtitle:`_subtitle_1xa21_28`,headerTabs:`_headerTabs_1xa21_34`,tabBtn:`_tabBtn_1xa21_40`,tabActive:`_tabActive_1xa21_51`,body:`_body_1xa21_58`,editor:`_editor_1xa21_67`,examples:`_examples_1xa21_75`,sectionLabel:`_sectionLabel_1xa21_81`,examplePills:`_examplePills_1xa21_89`,examplePill:`_examplePill_1xa21_89`,editorCols:`_editorCols_1xa21_109`,leftSidebar:`_leftSidebar_1xa21_119`,panel:`_panel_1xa21_128`,panelHeader:`_panelHeader_1xa21_135`,panelTitle:`_panelTitle_1xa21_142`,addBtn:`_addBtn_1xa21_149`,blockLabel:`_blockLabel_1xa21_160`,blockCheck:`_blockCheck_1xa21_170`,authField:`_authField_1xa21_173`,authFieldInput:`_authFieldInput_1xa21_183`,authFieldSelect:`_authFieldSelect_1xa21_193`,authFieldReq:`_authFieldReq_1xa21_204`,removeFieldBtn:`_removeFieldBtn_1xa21_205`,skillsList:`_skillsList_1xa21_208`,skillRow:`_skillRow_1xa21_210`,skillIcon:`_skillIcon_1xa21_218`,skillName:`_skillName_1xa21_220`,skillBadge:`_skillBadge_1xa21_229`,skillBadge_skill:`_skillBadge_skill_1xa21_237`,skillBadge_memory:`_skillBadge_memory_1xa21_238`,skillBadge_provider:`_skillBadge_provider_1xa21_239`,skillBadge_log:`_skillBadge_log_1xa21_240`,skillEmpty:`_skillEmpty_1xa21_242`,skillBtn:`_skillBtn_1xa21_244`,skillsEmpty:`_skillsEmpty_1xa21_246`,snapshotRow:`_snapshotRow_1xa21_249`,snapshotTs:`_snapshotTs_1xa21_258`,snapshotCount:`_snapshotCount_1xa21_259`,snapshotBtn:`_snapshotBtn_1xa21_260`,genStatus:`_genStatus_1xa21_263`,repairStatus:`_repairStatus_1xa21_265`,repairStatusTitle:`_repairStatusTitle_1xa21_266`,repairStatusProg:`_repairStatusProg_1xa21_267`,repairStatusFile:`_repairStatusFile_1xa21_268`,actionRow:`_actionRow_1xa21_271`,actionBtn:`_actionBtn_1xa21_273`,actionBtnIcon:`_actionBtnIcon_1xa21_275`,actionBtnActive:`_actionBtnActive_1xa21_276`,repairBtn:`_repairBtn_1xa21_278`,sandboxBtn:`_sandboxBtn_1xa21_280`,statsBar:`_statsBar_1xa21_282`,rightPanel:`_rightPanel_1xa21_285`,rightTabBar:`_rightTabBar_1xa21_296`,rightTab:`_rightTab_1xa21_296`,rightTabActive:`_rightTabActive_1xa21_313`,repairBar:`_repairBar_1xa21_316`,repairBarRow:`_repairBarRow_1xa21_326`,repairBarIcon:`_repairBarIcon_1xa21_327`,repairBarLabel:`_repairBarLabel_1xa21_328`,repairBarFile:`_repairBarFile_1xa21_329`,repairBarCounter:`_repairBarCounter_1xa21_330`,repairBarTime:`_repairBarTime_1xa21_331`,genBar:`_genBar_1xa21_333`,genBarRow:`_genBarRow_1xa21_343`,genBarRobot:`_genBarRobot_1xa21_344`,robotBob:`_robotBob_1xa21_1`,genBarLabel:`_genBarLabel_1xa21_345`,genBarFile:`_genBarFile_1xa21_346`,genBarCounter:`_genBarCounter_1xa21_347`,genBarTime:`_genBarTime_1xa21_348`,progressTrack:`_progressTrack_1xa21_350`,repairProgress:`_repairProgress_1xa21_351`,genProgress:`_genProgress_1xa21_352`,genDots:`_genDots_1xa21_355`,dot:`_dot_1xa21_356`,dot1:`_dot1_1xa21_357`,dotBounce:`_dotBounce_1xa21_1`,dot2:`_dot2_1xa21_358`,dot3:`_dot3_1xa21_359`,stopBtn:`_stopBtn_1xa21_362`,codeArea:`_codeArea_1xa21_365`,sandboxWrap:`_sandboxWrap_1xa21_366`,sandboxFrame:`_sandboxFrame_1xa21_367`,sandboxEmpty:`_sandboxEmpty_1xa21_368`,sandboxStartBtn:`_sandboxStartBtn_1xa21_369`,noFiles:`_noFiles_1xa21_371`,noFilesHero:`_noFilesHero_1xa21_381`,noFilesIcon:`_noFilesIcon_1xa21_388`,noFilesTitle:`_noFilesTitle_1xa21_390`,noFilesTagline:`_noFilesTagline_1xa21_397`,noFilesSteps:`_noFilesSteps_1xa21_402`,noFilesStep:`_noFilesStep_1xa21_402`,noFilesStepNum:`_noFilesStepNum_1xa21_419`,noFilesExamplesHint:`_noFilesExamplesHint_1xa21_433`,noFilesExampleBtn:`_noFilesExampleBtn_1xa21_443`,codeLayout:`_codeLayout_1xa21_455`,codeViewer:`_codeViewer_1xa21_457`,codeHeader:`_codeHeader_1xa21_465`,codeFileIcon:`_codeFileIcon_1xa21_478`,codeFileName:`_codeFileName_1xa21_479`,codeFileMeta:`_codeFileMeta_1xa21_480`,fileError:`_fileError_1xa21_482`,fileSyntaxError:`_fileSyntaxError_1xa21_483`,filePending:`_filePending_1xa21_484`,code:`_code_1xa21_365`,codeError:`_codeError_1xa21_499`,codeSyntaxError:`_codeSyntaxError_1xa21_500`,fileSidebar:`_fileSidebar_1xa21_503`,fileSidebarHeader:`_fileSidebarHeader_1xa21_512`,fileTab:`_fileTab_1xa21_522`,fileTabActive:`_fileTabActive_1xa21_538`,fileTabError:`_fileTabError_1xa21_539`,fileTabRow:`_fileTabRow_1xa21_541`,fileTabIcon:`_fileTabIcon_1xa21_542`,fileTabName:`_fileTabName_1xa21_543`,fileTabDir:`_fileTabDir_1xa21_544`,fileTabMeta:`_fileTabMeta_1xa21_545`,projectsList:`_projectsList_1xa21_548`,emptyProjects:`_emptyProjects_1xa21_550`,emptyIcon:`_emptyIcon_1xa21_551`,emptyHint:`_emptyHint_1xa21_552`,projectCard:`_projectCard_1xa21_554`,projectInfo:`_projectInfo_1xa21_555`,projectName:`_projectName_1xa21_556`,projectDesc:`_projectDesc_1xa21_557`,projectMeta:`_projectMeta_1xa21_558`,openBtn:`_openBtn_1xa21_559`,deleteBtn:`_deleteBtn_1xa21_560`,planBanner:`_planBanner_1xa21_563`,planTitle:`_planTitle_1xa21_572`,planText:`_planText_1xa21_573`,planActions:`_planActions_1xa21_574`,planApprove:`_planApprove_1xa21_575`,planReject:`_planReject_1xa21_576`,grepPanel:`_grepPanel_1xa21_579`,grepRow:`_grepRow_1xa21_588`,grepInput:`_grepInput_1xa21_589`,grepBtn:`_grepBtn_1xa21_591`,grepClose:`_grepClose_1xa21_592`,grepCount:`_grepCount_1xa21_593`,grepResults:`_grepResults_1xa21_594`,grepEmpty:`_grepEmpty_1xa21_595`,grepMatch:`_grepMatch_1xa21_596`,grepMatchFile:`_grepMatchFile_1xa21_598`,grepMatchLine:`_grepMatchLine_1xa21_599`,diffPanel:`_diffPanel_1xa21_602`,diffHeader:`_diffHeader_1xa21_611`,diffClose:`_diffClose_1xa21_612`,diffFile:`_diffFile_1xa21_613`,diffSummary:`_diffSummary_1xa21_614`,diffArrow:`_diffArrow_1xa21_615`,diffFileName:`_diffFileName_1xa21_616`,diffAdded:`_diffAdded_1xa21_617`,diffRemoved:`_diffRemoved_1xa21_618`,diffContent:`_diffContent_1xa21_619`,diffInline:`_diffInline_1xa21_622`,diffInlineHeader:`_diffInlineHeader_1xa21_623`,diffRemLine:`_diffRemLine_1xa21_624`,diffAddLine:`_diffAddLine_1xa21_625`,chatPanel:`_chatPanel_1xa21_628`,chatMessages:`_chatMessages_1xa21_637`,chatWelcome:`_chatWelcome_1xa21_639`,chatUser:`_chatUser_1xa21_641`,chatUserBubble:`_chatUserBubble_1xa21_642`,chatAttachPreviews:`_chatAttachPreviews_1xa21_643`,chatAttachBadge:`_chatAttachBadge_1xa21_644`,chatSystem:`_chatSystem_1xa21_646`,chatSystemBubble:`_chatSystemBubble_1xa21_647`,chatSyntaxErr:`_chatSyntaxErr_1xa21_648`,chatAgent:`_chatAgent_1xa21_650`,chatAgentCard:`_chatAgentCard_1xa21_651`,chatAgentHeader:`_chatAgentHeader_1xa21_652`,chatAgentRobot:`_chatAgentRobot_1xa21_653`,chatAgentRobotAnim:`_chatAgentRobotAnim_1xa21_654`,chatAgentLabel:`_chatAgentLabel_1xa21_655`,chatRunningDots:`_chatRunningDots_1xa21_656`,chatAgentText:`_chatAgentText_1xa21_657`,chatToolBadges:`_chatToolBadges_1xa21_658`,toolBadge:`_toolBadge_1xa21_659`,toolBadgeOk:`_toolBadgeOk_1xa21_660`,toolBadgeErr:`_toolBadgeErr_1xa21_661`,cursor:`_cursor_1xa21_663`,blink:`_blink_1xa21_1`,attachPreviews:`_attachPreviews_1xa21_666`,attachBadge:`_attachBadge_1xa21_667`,removeAttachBtn:`_removeAttachBtn_1xa21_668`,projNameRow:`_projNameRow_1xa21_671`,projNameLabel:`_projNameLabel_1xa21_672`,projNameInput:`_projNameInput_1xa21_673`,projActiveRow:`_projActiveRow_1xa21_674`,projActiveName:`_projActiveName_1xa21_675`,chatInputRow:`_chatInputRow_1xa21_678`,attachLabel:`_attachLabel_1xa21_679`,chatTextarea:`_chatTextarea_1xa21_680`,chatSendCol:`_chatSendCol_1xa21_683`,chatSendBtn:`_chatSendBtn_1xa21_684`,chatStopBtn:`_chatStopBtn_1xa21_686`,modalOverlay:`_modalOverlay_1xa21_689`,modal:`_modal_1xa21_689`,modalHeader:`_modalHeader_1xa21_711`,modalTitle:`_modalTitle_1xa21_712`,modalClose:`_modalClose_1xa21_713`,modalBody:`_modalBody_1xa21_715`,modalRow:`_modalRow_1xa21_717`,modalField:`_modalField_1xa21_718`,modalLabel:`_modalLabel_1xa21_719`,modalLabelRow:`_modalLabelRow_1xa21_720`,modalSelect:`_modalSelect_1xa21_722`,modalInput:`_modalInput_1xa21_723`,modalHint:`_modalHint_1xa21_726`,modalAiBox:`_modalAiBox_1xa21_728`,modalAiRow:`_modalAiRow_1xa21_729`,modalAiDesc:`_modalAiDesc_1xa21_730`,modalAiBtn:`_modalAiBtn_1xa21_731`,modalContentArea:`_modalContentArea_1xa21_734`,logView:`_logView_1xa21_737`,modalFooter:`_modalFooter_1xa21_739`,modalCancelBtn:`_modalCancelBtn_1xa21_740`,modalSaveBtn:`_modalSaveBtn_1xa21_741`},tn=[{name:`MySaaS`,desc:`SaaS product landing page. Hero: large headline, subheadline, two CTA buttons (Start free trial / Watch demo), animated gradient background. Features section: 3-column grid with icon, title, description for 6 features. Pricing section: 3 cards (Free / Pro $29/mo / Enterprise). Testimonials: 3 customer quotes. FAQ accordion: 5 questions. Footer with links and social icons. Sticky nav.`},{name:`MyShop`,desc:`E-commerce storefront homepage. Nav with logo, search bar, cart badge, hamburger mobile menu. Hero banner. Category strip: 6 cards. Featured products grid: 8 cards with rating, price, Add to Cart, wishlist. Promo banner. Newsletter signup. Responsive.`},{name:`MyBlog`,desc:`Blog platform homepage. Nav with category links. Hero: featured article card. Article grid: 6 cards. Sidebar: recent posts, tags cloud, newsletter widget. Pagination. Author bio section. Minimal footer.`},{name:`MyPortfolio`,desc:`Developer portfolio. Nav with scroll hide/show. Hero: typewriter role subtitle, CTA buttons. Work section: 6 project cards. Skills grouped by category with bars. About: timeline of milestones. Contact form. Scroll entrance animations via Intersection Observer.`},{name:`MyRestaurant`,desc:`Restaurant website. Nav: logo center, transparent→solid on scroll. Hero: full-viewport with overlay. Menu preview: tabbed (Starters/Mains/Desserts/Drinks). Reservation form. Gallery 3x3 mosaic. Chef section. Testimonials horizontal scroll.`},{name:`MyJobBoard`,desc:`Job board homepage. Hero search widget. Stats strip. Featured jobs list: 8 cards with company, location badge, salary, Quick Apply. Filter sidebar. Top companies section. Category cards. Newsletter.`}],nn=[{key:`auth`,label:`Auth (register/login/JWT)`,icon:`🔒`},{key:`cookieBanner`,label:`GDPR Cookie Banner`,icon:`🍪`},{key:`securityMiddleware`,label:`Security Middleware`,icon:`🛡️`},{key:`emailVerification`,label:`Email Verification`,icon:`✉️`}],rn={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`{`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function an(e){return rn[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function on(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function sn(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function cn(){let e=M(),[t,n]=(0,_.useState)(`new`),[r,i]=(0,_.useState)(`files`),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)({auth:!0,cookieBanner:!0,securityMiddleware:!0,emailVerification:!0}),[d,f]=(0,_.useState)([{label:`Email`,type:`email`,required:!0},{label:`Password`,type:`password`,required:!0},{label:`Name`,type:`text`,required:!0}]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(0),[w,ee]=(0,_.useState)(0),[te,ne]=(0,_.useState)(``),[T,re]=(0,_.useState)({fi:0,total:0,name:``}),[ie,O]=(0,_.useState)(null),[ae,A]=(0,_.useState)([]),[j,oe]=(0,_.useState)(``),[se,ce]=(0,_.useState)(!1),[le,ue]=(0,_.useState)([]),[N,de]=(0,_.useState)(null),[fe,pe]=(0,_.useState)([]),[me,P]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(null),[_e,ve]=(0,_.useState)([]),[F,ye]=(0,_.useState)(!1),[be,xe]=(0,_.useState)(``),[I,L]=(0,_.useState)([]),[Se,Ce]=(0,_.useState)([]),[we,Te]=(0,_.useState)([]),[Ee,De]=(0,_.useState)(null),[Oe,ke]=(0,_.useState)(`0s`),[Ae,je]=(0,_.useState)(`0s`),R=(0,_.useRef)(0),Me=(0,_.useRef)(0),Ne=(0,_.useRef)(null),Pe=(0,_.useRef)(null),Fe=(0,_.useRef)(null),Ie=(0,_.useRef)(null);function Le(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(v||b?Ne.current=setInterval(()=>{v&&ke(Le(R.current)),b&&je(Le(Me.current))},1e3):Ne.current&&=(clearInterval(Ne.current),null),()=>{Ne.current&&clearInterval(Ne.current)}),[v,b]);function Re(){Fe.current&&(Fe.current.scrollTop=Fe.current.scrollHeight)}(0,_.useEffect)(()=>{Re()},[ae]),(0,_.useEffect)(()=>{a&&p.length>0&&!me&&(P(!0),E(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`).then(e=>{e?.skills&&pe(e.skills)}).catch(()=>{}))},[a,p.length,me]);async function ze(e,t){if(v||!e||e.length<5)return;y(!0),m([]),g(0),re({fi:0,total:0,name:``}),R.current=Date.now(),ke(`0s`),Pe.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:Pe.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:l,authFields:d})});if(!r.ok||!r.body){y(!1);return}let i=r.body.getReader(),a=new TextDecoder,o=``,s=[];for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let r=o.split(`
|
|
525
531
|
|
|
526
532
|
`);o=r.pop()??``;for(let e of r){let t=e.replace(/^data: /,``).trim();if(t)try{let e=JSON.parse(t);if(e.type===`file_start`)s.push({name:e.name,content:``,_pending:!0}),m([...s]),re({fi:e.fi,total:e.total,name:e.name});else if(e.type===`file_chunk`){let t=s.find(t=>t.name===e.name);t&&(t.content+=e.chunk,t._pending=!1),m([...s])}else if(e.type===`file_done`){let t=s.find(t=>t.name===e.name);t&&(t._pending=!1,e.syntaxError&&(t._syntaxError=e.syntaxError)),m([...s]),re({fi:e.fi,total:e.total,name:e.name})}else if(e.type===`file_error`){let t=s.find(t=>t.name===e.name);t&&(t._error=!0,t._pending=!1),m([...s])}else e.type===`done`&&(O({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:s.length}),y(!1),P(!1),pe([]))}catch{}}}}catch(e){e.name!==`AbortError`&&A(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),y(!1)}}async function Be(){let e=j.trim();if(!(a&&p.length>0)){if(!e||e.length<5)return;let t=a||`MyProject`;o(t),c(e),oe(``),await ze(e,t);return}if(!e&&le.length===0||se||v)return;let t=[...le];if(ue([]),oe(``),e.toLowerCase().startsWith(`/plan `)||e.toLowerCase().startsWith(`piano: `)){let t=e.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);A(t=>[...t,{role:`user`,text:e}]),await Ve(`[MODALITA PIANO] Descrivi cosa modificheresti per: "${t}". Elenca i file e cosa faresti. NON applicare modifiche ancora. Rispondi con il piano in bullet list.`,t,[]);return}A(n=>[...n,{role:`user`,text:e,attachments:t}]),await Ve(e,null,t)}async function Ve(e,t,n){if(se)return;ce(!0);let r={};p.forEach(e=>{r[e.name]=e.content});try{let i=await fetch(`/api/studio/webcraft/agent`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectName:a,message:e,attachments:n.map(e=>({name:e.name,mimeType:e.mimeType,base64:e.base64}))})});if(!i.ok||!i.body){A(e=>[...e,{role:`agent`,text:`Errore: ${i.status}`,tools:[]}]),ce(!1);return}let o={role:`agent`,text:``,tools:[]};A(e=>[...e,o]);let s=i.body.getReader(),c=new TextDecoder,l=``,u=!1;for(;;){let{done:e,value:n}=await s.read();if(e)break;l+=c.decode(n,{stream:!0});let i=l.split(`
|
|
527
533
|
|
|
528
534
|
`);l=i.pop()??``;for(let e of i){let n=e.replace(/^data: /,``).trim();if(n)try{let e=JSON.parse(n);e.type===`text`?(o.text+=e.token,A(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`tool`?(o.tools.push({op:e.op,path:e.path,result:e.result,oldSnippet:e.oldSnippet??``,newSnippet:e.newSnippet??``}),(e.op===`edit`||e.op===`write`)&&e.result===`ok`&&(u=!0),A(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`done`?(t&&!u&&de({plan:o.text,originalMessage:t}),ce(!1),e.changed&&await He((o.tools??[]).filter(e=>e.op===`edit`||e.op===`write`).map(e=>e.path),r)):e.type===`error`&&(o.text+=`
|
|
529
535
|
Errore: `+e.msg,ce(!1))}catch{}}}}catch(e){A(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}ce(!1)}async function He(e,t){if(!a)return;let n=await E(`/api/studio/webcraft/projects/load/${encodeURIComponent(a)}`);if(n?.files&&(m(n.files),e.length>0)){let r=e.map(e=>{let r=n.files.find(t=>t.name===e);return r?{file:e,before:t[e]??``,after:r.content}:null}).filter(Boolean);Ce(e=>[...e,...r])}}function Ue(){Pe.current&&=(Pe.current.abort(),null),y(!1),ce(!1),A(e=>[...e,{role:`system`,text:`⏹ Generazione interrotta.`}])}async function We(){return a?(await D(`/api/studio/webcraft/snapshot`,{projectName:a}))?.snapshot??null:null}async function Ge(){let e=await We();e&&(A(t=>[...t,{role:`system`,text:`💾 Snapshot salvato (${e.slice(0,16).replace(`T`,` `)})`}]),Ke())}async function Ke(){if(!a)return;let e=await E(`/api/studio/webcraft/snapshots/${encodeURIComponent(a)}`);e?.snapshots&&ve(e.snapshots)}async function qe(e){confirm(`Ripristinare lo snapshot del ${e.replace(`T`,` `).slice(0,16)}? I file attuali verranno sovrascritti.`)&&await D(`/api/studio/webcraft/restore`,{projectName:a,ts:e})!==null&&(A(t=>[...t,{role:`agent`,text:`Snapshot ripristinato (${e}). Ricarico i file...`}]),He([],{}))}async function Je(){if(!a)return;let e=await D(`/api/studio/webcraft/syntax-check`,{projectName:a});if(e?.results){let t=e.results.filter(e=>!e.ok);t.length>0?A(e=>[...e,{role:`system`,text:`⚠ Syntax check: ${t.length} errore/i trovato/i.`,syntaxErrors:t}]):A(e=>[...e,{role:`system`,text:`✓ Syntax check: tutti i file JS sono validi.`}])}}async function Ye(){let e=p.filter(e=>e._error||e._syntaxError);if(e.length!==0){x(!0),C(0),ee(e.length),Me.current=Date.now(),je(`0s`);for(let t=0;t<e.length;t++){let n=e[t];ne(n.name),C(t),await Ve(`REPAIR FILE: ${n.name}\nErrore: ${n._syntaxError??`generazione fallita`}\nRigenera il file correttamente. Output SOLO il contenuto del file, nessuna spiegazione.`,null,[])}C(e.length),ne(``),x(!1)}}async function Xe(){if(!be||!a)return;let e=await D(`/api/studio/webcraft/grep`,{projectName:a,query:be});e?.matches&&L(e.matches)}function Ze(e){let t=p.findIndex(t=>t.name===e);t>=0&&(g(t),i(`files`))}function Qe(){window.open(`/api/studio/webcraft/download/${encodeURIComponent(a)}`,`_blank`)}async function $e(e,t,n,r){t.endsWith(`.md`)||(t+=`.md`);let i={name:t,content:n,type:r},o;o=e.mode===`edit`&&e.idx!==null?fe.map((t,n)=>n===e.idx?i:t):[...fe,i],pe(o),ge(null),await D(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`,{skills:o})}async function et(e){let t=fe[e];!t||!confirm(`Eliminare "${t.name}"?`)||(await D(`/api/studio/webcraft/skills/${encodeURIComponent(a)}/delete`,{name:t.name}),pe(fe.filter((t,n)=>n!==e)))}async function tt(e){let t=fe[e];if(!t||!confirm(`Svuotare "${t.name}"? Il file rimane ma il contenuto viene cancellato.`))return;let n=fe.map((t,n)=>n===e?{...t,content:``}:t);pe(n),await D(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`,{skills:n})}async function nt(){let e=await E(`/api/studio/webcraft/projects`);e?.projects&&Te(e.projects)}async function rt(e){let t=await E(`/api/studio/webcraft/projects/load/${encodeURIComponent(e.name)}`);if(!t)return;o(t.projectName??e.name),c(t.description??``),m(t.files??[]),g(0),n(`new`),i(`files`),A([]),pe([]),P(!1);let r=await E(`/api/studio/webcraft/projects/chat/load/${encodeURIComponent(t.projectName??e.name)}`);r?.chat&&A(r.chat);let a=await E(`/api/studio/webcraft/skills/${encodeURIComponent(t.projectName??e.name)}`);a?.skills&&(pe(a.skills),P(!0))}async function it(e){confirm(`Eliminare: ${e.name} - ${e.dir}?`)&&(await D(`/api/studio/webcraft/projects/${encodeURIComponent(e.name)}`,{},`DELETE`),Te(we.filter(t=>t.name!==e.name)),a===e.name&&(o(``),m([]),A([]),c(``)))}async function z(){if(!N)return;let e=N.originalMessage;de(null),await Ve(e+`
|
|
530
|
-
[Piano approvato — procedi con le modifiche]`,null,[])}function at(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];ue(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let ot=a&&p.length>0,st=p[h],ct=se||v;return(0,k.jsxs)(`div`,{className:X.root,children:[(0,k.jsxs)(`div`,{className:X.header,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:X.title,children:`⚙ WebCraft`}),(0,k.jsx)(`div`,{className:X.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,k.jsxs)(`div`,{className:X.headerTabs,children:[(0,k.jsx)(`button`,{className:`${X.tabBtn} ${t===`new`?X.tabActive:``}`,onClick:()=>n(`new`),children:`+ Nuovo`}),(0,k.jsx)(`button`,{className:`${X.tabBtn} ${t===`projects`?X.tabActive:``}`,onClick:()=>{n(`projects`),nt()},children:`📁 Progetti`})]})]}),(0,k.jsx)(`div`,{className:X.body,children:t===`projects`?(0,k.jsx)(`div`,{className:X.projectsList,children:we.length===0?(0,k.jsxs)(`div`,{className:X.emptyProjects,children:[(0,k.jsx)(`span`,{className:X.emptyIcon,children:`📁`}),(0,k.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,k.jsx)(`span`,{className:X.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):we.map(e=>(0,k.jsxs)(`div`,{className:X.projectCard,children:[(0,k.jsxs)(`div`,{className:X.projectInfo,children:[(0,k.jsx)(`div`,{className:X.projectName,children:e.name}),(0,k.jsx)(`div`,{className:X.projectDesc,children:e.description}),(0,k.jsxs)(`div`,{className:X.projectMeta,children:[(0,k.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,k.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,k.jsx)(`button`,{className:X.openBtn,onClick:()=>rt(e),children:`↗ Apri`}),(0,k.jsx)(`button`,{className:X.deleteBtn,onClick:()=>it(e),children:`🗑`})]},e.name))}):(0,k.jsxs)(`div`,{className:X.editor,children:[(0,k.jsxs)(`div`,{className:X.examples,children:[(0,k.jsx)(`div`,{className:X.sectionLabel,children:`Esempi`}),(0,k.jsx)(`div`,{className:X.examplePills,children:tn.map(e=>(0,k.jsx)(`button`,{className:X.examplePill,onClick:()=>{o(e.name),c(e.desc),oe(e.desc)},children:e.name},e.name))})]}),(0,k.jsxs)(`div`,{className:X.editorCols,children:[(0,k.jsxs)(`div`,{className:X.leftSidebar,children:[(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`Blocchi`}),nn.map(e=>(0,k.jsxs)(`label`,{className:X.blockLabel,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:l[e.key],onChange:t=>u(n=>({...n,[e.key]:t.target.checked})),className:X.blockCheck}),(0,k.jsx)(`span`,{children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.key))]}),l.auth&&(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsxs)(`div`,{className:X.panelHeader,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`Campi Auth`}),(0,k.jsx)(`button`,{className:X.addBtn,onClick:()=>f(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),d.map((e,t)=>(0,k.jsxs)(`div`,{className:X.authField,children:[(0,k.jsx)(`input`,{value:e.label,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:X.authFieldInput}),(0,k.jsx)(`select`,{value:e.type,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:X.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:X.authFieldReq}),(0,k.jsx)(`button`,{onClick:()=>f(e=>e.filter((e,n)=>n!==t)),className:X.removeFieldBtn,children:`×`})]},t))]}),(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsxs)(`div`,{className:X.panelHeader,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`🗂 Contesto AI`}),ot&&(0,k.jsx)(`button`,{className:X.addBtn,onClick:()=>ge({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),fe.length>0?(0,k.jsx)(`div`,{className:X.skillsList,children:fe.map((e,t)=>(0,k.jsxs)(`div`,{className:X.skillRow,children:[(0,k.jsx)(`span`,{className:X.skillIcon,children:sn(e.type)}),(0,k.jsx)(`span`,{className:X.skillName,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`${X.skillBadge} ${X[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,k.jsx)(`span`,{className:X.skillEmpty,children:`⚠`}),(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>ge({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>tt(t),children:`🗑`}),e.type===`log`&&(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>et(t),children:`🗑`})]},t))}):(0,k.jsx)(`div`,{className:X.skillsEmpty,children:ot?`Caricamento...`:`Genera un progetto per attivare i file di contesto.`})]}),_e.length>0&&(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`💾 Snapshot`}),_e.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,k.jsxs)(`div`,{className:X.snapshotRow,children:[(0,k.jsx)(`span`,{className:X.snapshotTs,children:t}),(0,k.jsxs)(`span`,{className:X.snapshotCount,children:[e.fileCount,`f`]}),(0,k.jsx)(`button`,{className:X.snapshotBtn,onClick:()=>qe(e.ts),children:`↺`})]},e.ts)})]}),v&&(0,k.jsx)(`div`,{className:X.genStatus,children:`⏳ Generazione...`}),b&&(0,k.jsxs)(`div`,{className:X.repairStatus,children:[(0,k.jsx)(`div`,{className:X.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,k.jsxs)(`div`,{className:X.repairStatusProg,children:[S,` / `,w,` file`]}),(0,k.jsx)(`div`,{className:X.repairStatusFile,children:te})]}),p.length>0&&!v&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:X.actionRow,children:[(0,k.jsx)(`button`,{className:X.actionBtn,onClick:Qe,children:`⬇ ZIP`}),(0,k.jsx)(`button`,{className:X.actionBtnIcon,title:`Syntax check`,onClick:Je,children:`✅`}),(0,k.jsx)(`button`,{className:`${X.actionBtnIcon} ${F?X.actionBtnActive:``}`,title:`Grep`,onClick:()=>ye(!F),children:`🔍`}),(0,k.jsx)(`button`,{className:X.actionBtnIcon,title:`Snapshot`,onClick:Ge,children:`💾`})]}),p.some(e=>e._error||e._syntaxError)&&!b&&(0,k.jsx)(`button`,{className:X.repairBtn,onClick:Ye,children:`🔧 Correggi tutti i file rossi`}),(0,k.jsx)(`button`,{className:X.sandboxBtn,onClick:()=>i(`preview`),children:`▶ Sandbox`}),ie&&(0,k.jsxs)(`div`,{className:X.statsBar,children:[(0,k.jsxs)(`span`,{children:[`⏱ `,ie.seconds>=60?`${Math.floor(ie.seconds/60)}m ${ie.seconds%60}s`:`${ie.seconds}s`]}),(0,k.jsxs)(`span`,{children:[`↑ `,ie.tokIn.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`↓ `,ie.tokOut.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`📄 `,ie.files,` file`]})]})]})]}),(0,k.jsxs)(`div`,{className:X.rightPanel,children:[(0,k.jsxs)(`div`,{className:X.rightTabBar,children:[(0,k.jsx)(`button`,{className:`${X.rightTab} ${r===`preview`?``:X.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,k.jsx)(`button`,{className:`${X.rightTab} ${r===`preview`?X.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),b&&(0,k.jsxs)(`div`,{className:X.repairBar,children:[(0,k.jsxs)(`div`,{className:X.repairBarRow,children:[(0,k.jsx)(`span`,{className:X.repairBarIcon,children:`🔧`}),(0,k.jsx)(`span`,{className:X.repairBarLabel,children:`Auto-fix`}),(0,k.jsx)(`span`,{className:X.repairBarFile,children:te}),(0,k.jsxs)(`span`,{className:X.repairBarCounter,children:[S,` / `,w]}),(0,k.jsx)(`span`,{className:X.repairBarTime,children:Ae}),(0,k.jsx)(`button`,{className:X.stopBtn,onClick:Ue,children:`⏹ Stop`})]}),(0,k.jsx)(`div`,{className:X.progressTrack,children:(0,k.jsx)(`div`,{className:X.repairProgress,style:{width:w>0?`${Math.round(S/w*100)}%`:`0%`}})})]}),v&&(0,k.jsxs)(`div`,{className:X.genBar,children:[(0,k.jsxs)(`div`,{className:X.genBarRow,children:[(0,k.jsx)(`span`,{className:X.genBarRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:X.genBarLabel,children:`Generazione`}),(0,k.jsx)(`span`,{className:X.genBarFile,children:T.name.split(`,`)[0].trim()}),(0,k.jsxs)(`span`,{className:X.genBarCounter,children:[T.fi,` / `,T.total]}),(0,k.jsx)(`span`,{className:X.genBarTime,children:Oe}),(0,k.jsxs)(`span`,{className:X.genDots,children:[(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot1}`}),(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot2}`}),(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot3}`})]})]}),(0,k.jsx)(`div`,{className:X.progressTrack,children:(0,k.jsx)(`div`,{className:X.genProgress,style:{width:T.total>0?`${Math.round(T.fi/T.total*100)}%`:`0%`}})})]}),r===`preview`?(0,k.jsx)(`div`,{className:X.sandboxWrap,children:Ee?(0,k.jsx)(`iframe`,{src:`http://127.0.0.1:${Ee}`,className:X.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,k.jsxs)(`div`,{className:X.sandboxEmpty,children:[(0,k.jsx)(`span`,{children:`🌐`}),(0,k.jsx)(`span`,{children:e(`webcraft.stopped`)}),(0,k.jsx)(`button`,{className:X.sandboxStartBtn,onClick:()=>{D(`/api/studio/webcraft/sandbox/start`,{projectName:a}).then(e=>{e?.port&&De(e.port)})},children:`▶ Avvia Sandbox`})]})}):(0,k.jsx)(`div`,{className:X.codeArea,children:p.length===0?(0,k.jsxs)(`div`,{className:X.noFiles,children:[(0,k.jsx)(`span`,{className:X.noFilesIcon,children:`⚙`}),(0,k.jsx)(`span`,{children:e(`common.empty`)})]}):(0,k.jsxs)(`div`,{className:X.codeLayout,children:[(0,k.jsx)(`div`,{className:X.codeViewer,children:st&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:X.codeHeader,children:[(0,k.jsx)(`span`,{className:X.codeFileIcon,children:an(st.name)}),(0,k.jsx)(`span`,{className:X.codeFileName,children:st.name}),!st._pending&&!st._error&&(0,k.jsxs)(`span`,{className:X.codeFileMeta,children:[st.content.split(`
|
|
536
|
+
[Piano approvato — procedi con le modifiche]`,null,[])}function at(e){e&&Array.from(e).forEach(e=>{let t=new FileReader;t.onload=t=>{let n=(t.target?.result).split(`,`)[1];ue(t=>[...t,{name:e.name,mimeType:e.type,base64:n,size:e.size}])},t.readAsDataURL(e)})}let ot=a&&p.length>0,st=p[h],ct=se||v;return(0,k.jsxs)(`div`,{className:X.root,children:[(0,k.jsxs)(`div`,{className:X.header,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:X.title,children:`⚙ WebCraft`}),(0,k.jsx)(`div`,{className:X.subtitle,children:`Genera progetti web completi con agenti AI`})]}),(0,k.jsxs)(`div`,{className:X.headerTabs,children:[(0,k.jsx)(`button`,{className:`${X.tabBtn} ${t===`new`?X.tabActive:``}`,onClick:()=>n(`new`),children:`+ Nuovo`}),(0,k.jsx)(`button`,{className:`${X.tabBtn} ${t===`projects`?X.tabActive:``}`,onClick:()=>{n(`projects`),nt()},children:`📁 Progetti`})]})]}),(0,k.jsx)(`div`,{className:X.body,children:t===`projects`?(0,k.jsx)(`div`,{className:X.projectsList,children:we.length===0?(0,k.jsxs)(`div`,{className:X.emptyProjects,children:[(0,k.jsx)(`span`,{className:X.emptyIcon,children:`📁`}),(0,k.jsx)(`span`,{children:e(`webcraft.noProjects`)}),(0,k.jsx)(`span`,{className:X.emptyHint,children:`Crea un progetto nella tab Nuovo`})]}):we.map(e=>(0,k.jsxs)(`div`,{className:X.projectCard,children:[(0,k.jsxs)(`div`,{className:X.projectInfo,children:[(0,k.jsx)(`div`,{className:X.projectName,children:e.name}),(0,k.jsx)(`div`,{className:X.projectDesc,children:e.description}),(0,k.jsxs)(`div`,{className:X.projectMeta,children:[(0,k.jsxs)(`span`,{children:[`📄 `,e.fileCount,` file`]}),(0,k.jsxs)(`span`,{children:[`📅 `,e.createdAt?new Date(e.createdAt).toLocaleString():``]})]})]}),(0,k.jsx)(`button`,{className:X.openBtn,onClick:()=>rt(e),children:`↗ Apri`}),(0,k.jsx)(`button`,{className:X.deleteBtn,onClick:()=>it(e),children:`🗑`})]},e.name))}):(0,k.jsxs)(`div`,{className:X.editor,children:[(0,k.jsxs)(`div`,{className:X.examples,children:[(0,k.jsx)(`div`,{className:X.sectionLabel,children:`Esempi`}),(0,k.jsx)(`div`,{className:X.examplePills,children:tn.map(e=>(0,k.jsx)(`button`,{className:X.examplePill,onClick:()=>{o(e.name),c(e.desc),oe(e.desc)},children:e.name},e.name))})]}),(0,k.jsxs)(`div`,{className:X.editorCols,children:[(0,k.jsxs)(`div`,{className:X.leftSidebar,children:[(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`Blocchi`}),nn.map(e=>(0,k.jsxs)(`label`,{className:X.blockLabel,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:l[e.key],onChange:t=>u(n=>({...n,[e.key]:t.target.checked})),className:X.blockCheck}),(0,k.jsx)(`span`,{children:e.icon}),(0,k.jsx)(`span`,{children:e.label})]},e.key))]}),l.auth&&(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsxs)(`div`,{className:X.panelHeader,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`Campi Auth`}),(0,k.jsx)(`button`,{className:X.addBtn,onClick:()=>f(e=>[...e,{label:`New field`,type:`text`,required:!1}]),children:`+ Campo`})]}),d.map((e,t)=>(0,k.jsxs)(`div`,{className:X.authField,children:[(0,k.jsx)(`input`,{value:e.label,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,label:e.target.value}:n)),className:X.authFieldInput}),(0,k.jsx)(`select`,{value:e.type,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,type:e.target.value}:n)),className:X.authFieldSelect,children:[`text`,`email`,`password`,`tel`,`date`,`number`].map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`input`,{type:`checkbox`,checked:e.required,onChange:e=>f(n=>n.map((n,r)=>r===t?{...n,required:e.target.checked}:n)),title:`Required`,className:X.authFieldReq}),(0,k.jsx)(`button`,{onClick:()=>f(e=>e.filter((e,n)=>n!==t)),className:X.removeFieldBtn,children:`×`})]},t))]}),(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsxs)(`div`,{className:X.panelHeader,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`🗂 Contesto AI`}),ot&&(0,k.jsx)(`button`,{className:X.addBtn,onClick:()=>ge({mode:`new`,idx:null,name:``,content:``,type:`skill`,generating:!1}),children:`+ Skill`})]}),fe.length>0?(0,k.jsx)(`div`,{className:X.skillsList,children:fe.map((e,t)=>(0,k.jsxs)(`div`,{className:X.skillRow,children:[(0,k.jsx)(`span`,{className:X.skillIcon,children:sn(e.type)}),(0,k.jsx)(`span`,{className:X.skillName,title:e.name,children:e.name}),(0,k.jsx)(`span`,{className:`${X.skillBadge} ${X[`skillBadge_`+e.type]}`,children:e.type}),!e.content&&e.type!==`log`&&(0,k.jsx)(`span`,{className:X.skillEmpty,children:`⚠`}),(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>ge({mode:e.type===`log`?`view`:`edit`,idx:t,name:e.name,content:e.content,type:e.type,generating:!1}),children:e.type===`log`?`👁`:`✏`}),e.type!==`memory`&&e.type!==`provider`&&e.type!==`log`&&(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>tt(t),children:`🗑`}),e.type===`log`&&(0,k.jsx)(`button`,{className:X.skillBtn,onClick:()=>et(t),children:`🗑`})]},t))}):(0,k.jsx)(`div`,{className:X.skillsEmpty,children:ot?`Caricamento...`:`Genera un progetto per attivare i file di contesto.`})]}),_e.length>0&&(0,k.jsxs)(`div`,{className:X.panel,children:[(0,k.jsx)(`div`,{className:X.panelTitle,children:`💾 Snapshot`}),_e.slice(0,5).map(e=>{let t=e.ts.replace(`T`,` `).slice(0,16);return(0,k.jsxs)(`div`,{className:X.snapshotRow,children:[(0,k.jsx)(`span`,{className:X.snapshotTs,children:t}),(0,k.jsxs)(`span`,{className:X.snapshotCount,children:[e.fileCount,`f`]}),(0,k.jsx)(`button`,{className:X.snapshotBtn,onClick:()=>qe(e.ts),children:`↺`})]},e.ts)})]}),v&&(0,k.jsx)(`div`,{className:X.genStatus,children:`⏳ Generazione...`}),b&&(0,k.jsxs)(`div`,{className:X.repairStatus,children:[(0,k.jsx)(`div`,{className:X.repairStatusTitle,children:`🔧 Correzione automatica...`}),(0,k.jsxs)(`div`,{className:X.repairStatusProg,children:[S,` / `,w,` file`]}),(0,k.jsx)(`div`,{className:X.repairStatusFile,children:te})]}),p.length>0&&!v&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:X.actionRow,children:[(0,k.jsx)(`button`,{className:X.actionBtn,onClick:Qe,children:`⬇ ZIP`}),(0,k.jsx)(`button`,{className:X.actionBtnIcon,title:`Syntax check`,onClick:Je,children:`✅`}),(0,k.jsx)(`button`,{className:`${X.actionBtnIcon} ${F?X.actionBtnActive:``}`,title:`Grep`,onClick:()=>ye(!F),children:`🔍`}),(0,k.jsx)(`button`,{className:X.actionBtnIcon,title:`Snapshot`,onClick:Ge,children:`💾`})]}),p.some(e=>e._error||e._syntaxError)&&!b&&(0,k.jsx)(`button`,{className:X.repairBtn,onClick:Ye,children:`🔧 Correggi tutti i file rossi`}),(0,k.jsx)(`button`,{className:X.sandboxBtn,onClick:()=>i(`preview`),children:`▶ Sandbox`}),ie&&(0,k.jsxs)(`div`,{className:X.statsBar,children:[(0,k.jsxs)(`span`,{children:[`⏱ `,ie.seconds>=60?`${Math.floor(ie.seconds/60)}m ${ie.seconds%60}s`:`${ie.seconds}s`]}),(0,k.jsxs)(`span`,{children:[`↑ `,ie.tokIn.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`↓ `,ie.tokOut.toLocaleString(),` tok`]}),(0,k.jsxs)(`span`,{children:[`📄 `,ie.files,` file`]})]})]})]}),(0,k.jsxs)(`div`,{className:X.rightPanel,children:[(0,k.jsxs)(`div`,{className:X.rightTabBar,children:[(0,k.jsx)(`button`,{className:`${X.rightTab} ${r===`preview`?``:X.rightTabActive}`,onClick:()=>i(`files`),children:`📄 File`}),(0,k.jsx)(`button`,{className:`${X.rightTab} ${r===`preview`?X.rightTabActive:``}`,onClick:()=>i(`preview`),children:`🌐 Sandbox`})]}),b&&(0,k.jsxs)(`div`,{className:X.repairBar,children:[(0,k.jsxs)(`div`,{className:X.repairBarRow,children:[(0,k.jsx)(`span`,{className:X.repairBarIcon,children:`🔧`}),(0,k.jsx)(`span`,{className:X.repairBarLabel,children:`Auto-fix`}),(0,k.jsx)(`span`,{className:X.repairBarFile,children:te}),(0,k.jsxs)(`span`,{className:X.repairBarCounter,children:[S,` / `,w]}),(0,k.jsx)(`span`,{className:X.repairBarTime,children:Ae}),(0,k.jsx)(`button`,{className:X.stopBtn,onClick:Ue,children:`⏹ Stop`})]}),(0,k.jsx)(`div`,{className:X.progressTrack,children:(0,k.jsx)(`div`,{className:X.repairProgress,style:{width:w>0?`${Math.round(S/w*100)}%`:`0%`}})})]}),v&&(0,k.jsxs)(`div`,{className:X.genBar,children:[(0,k.jsxs)(`div`,{className:X.genBarRow,children:[(0,k.jsx)(`span`,{className:X.genBarRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:X.genBarLabel,children:`Generazione`}),(0,k.jsx)(`span`,{className:X.genBarFile,children:T.name.split(`,`)[0].trim()}),(0,k.jsxs)(`span`,{className:X.genBarCounter,children:[T.fi,` / `,T.total]}),(0,k.jsx)(`span`,{className:X.genBarTime,children:Oe}),(0,k.jsxs)(`span`,{className:X.genDots,children:[(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot1}`}),(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot2}`}),(0,k.jsx)(`span`,{className:`${X.dot} ${X.dot3}`})]})]}),(0,k.jsx)(`div`,{className:X.progressTrack,children:(0,k.jsx)(`div`,{className:X.genProgress,style:{width:T.total>0?`${Math.round(T.fi/T.total*100)}%`:`0%`}})})]}),r===`preview`?(0,k.jsx)(`div`,{className:X.sandboxWrap,children:Ee?(0,k.jsx)(`iframe`,{src:`http://127.0.0.1:${Ee}`,className:X.sandboxFrame,title:`WebCraft Sandbox`,sandbox:`allow-scripts allow-same-origin allow-forms`}):(0,k.jsxs)(`div`,{className:X.sandboxEmpty,children:[(0,k.jsx)(`span`,{children:`🌐`}),(0,k.jsx)(`span`,{children:e(`webcraft.stopped`)}),(0,k.jsx)(`button`,{className:X.sandboxStartBtn,onClick:()=>{D(`/api/studio/webcraft/sandbox/start`,{projectName:a}).then(e=>{e?.port&&De(e.port)})},children:`▶ Avvia Sandbox`})]})}):(0,k.jsx)(`div`,{className:X.codeArea,children:p.length===0?(0,k.jsxs)(`div`,{className:X.noFiles,children:[(0,k.jsxs)(`div`,{className:X.noFilesHero,children:[(0,k.jsx)(`span`,{className:X.noFilesIcon,children:`🔨`}),(0,k.jsx)(`span`,{className:X.noFilesTitle,children:`WebCraft`}),(0,k.jsx)(`span`,{className:X.noFilesTagline,children:`Genera progetti web completi con AI`})]}),(0,k.jsxs)(`div`,{className:X.noFilesSteps,children:[(0,k.jsxs)(`div`,{className:X.noFilesStep,children:[(0,k.jsx)(`span`,{className:X.noFilesStepNum,children:`1`}),(0,k.jsx)(`span`,{children:`Scegli un esempio o scrivi una descrizione nel box in basso`})]}),(0,k.jsxs)(`div`,{className:X.noFilesStep,children:[(0,k.jsx)(`span`,{className:X.noFilesStepNum,children:`2`}),(0,k.jsxs)(`span`,{children:[`Premi `,(0,k.jsx)(`strong`,{children:`▶ Genera`}),` — l'AI crea tutti i file del progetto`]})]}),(0,k.jsxs)(`div`,{className:X.noFilesStep,children:[(0,k.jsx)(`span`,{className:X.noFilesStepNum,children:`3`}),(0,k.jsx)(`span`,{children:`Chiedi modifiche in chat, scarica lo ZIP o avvia il Sandbox`})]})]}),(0,k.jsxs)(`div`,{className:X.noFilesExamplesHint,children:[`💡 Prova: `,(0,k.jsx)(`button`,{className:X.noFilesExampleBtn,onClick:()=>{let e=tn[0];o(e.name),c(e.desc),oe(e.desc)},children:`MySaaS`}),(0,k.jsx)(`button`,{className:X.noFilesExampleBtn,onClick:()=>{let e=tn[1];o(e.name),c(e.desc),oe(e.desc)},children:`MyShop`}),(0,k.jsx)(`button`,{className:X.noFilesExampleBtn,onClick:()=>{let e=tn[3];o(e.name),c(e.desc),oe(e.desc)},children:`MyPortfolio`})]})]}):(0,k.jsxs)(`div`,{className:X.codeLayout,children:[(0,k.jsx)(`div`,{className:X.codeViewer,children:st&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:X.codeHeader,children:[(0,k.jsx)(`span`,{className:X.codeFileIcon,children:an(st.name)}),(0,k.jsx)(`span`,{className:X.codeFileName,children:st.name}),!st._pending&&!st._error&&(0,k.jsxs)(`span`,{className:X.codeFileMeta,children:[st.content.split(`
|
|
531
537
|
`).length,` righe · `,on(st.content)]})]}),st._error&&(0,k.jsx)(`div`,{className:X.fileError,children:`⚠ Generazione fallita — chiedi al modello di rigenerare questo file`}),st._syntaxError&&!st._error&&(0,k.jsxs)(`div`,{className:X.fileSyntaxError,children:[`⚠ Syntax error: `,st._syntaxError]}),st._pending?(0,k.jsx)(`div`,{className:X.filePending,children:`⌛ In generazione...`}):(0,k.jsx)(`pre`,{className:`${X.code} ${st._error?X.codeError:st._syntaxError?X.codeSyntaxError:``}`,children:st.content})]})}),(0,k.jsxs)(`div`,{className:X.fileSidebar,children:[(0,k.jsxs)(`div`,{className:X.fileSidebarHeader,children:[p.length,` file`]}),p.map((e,t)=>{let n=e._error||!!e._syntaxError,r=t===h;return(0,k.jsxs)(`button`,{className:`${X.fileTab} ${r?X.fileTabActive:``} ${n?X.fileTabError:``}`,onClick:()=>g(t),children:[(0,k.jsxs)(`div`,{className:X.fileTabRow,children:[(0,k.jsx)(`span`,{className:X.fileTabIcon,children:e._pending?`⌛`:n?`⚠`:an(e.name)}),(0,k.jsx)(`span`,{className:X.fileTabName,children:e.name.split(`/`).pop()})]}),e.name.includes(`/`)&&(0,k.jsx)(`div`,{className:X.fileTabDir,children:e.name.split(`/`).slice(0,-1).join(`/`)}),!e._pending&&(0,k.jsxs)(`div`,{className:X.fileTabMeta,children:[e.content.split(`
|
|
532
538
|
`).length,` righe · `,on(e.content)]})]},t)})]})]})})]})]})]})}),N&&t!==`projects`&&(0,k.jsxs)(`div`,{className:X.planBanner,children:[(0,k.jsx)(`div`,{className:X.planTitle,children:`📌 Piano proposto — approva per eseguire`}),(0,k.jsx)(`pre`,{className:X.planText,children:N.plan}),(0,k.jsxs)(`div`,{className:X.planActions,children:[(0,k.jsx)(`button`,{className:X.planApprove,onClick:z,children:`✓ Esegui`}),(0,k.jsx)(`button`,{className:X.planReject,onClick:()=>de(null),children:`✕ Annulla`})]})]}),F&&t!==`projects`&&(0,k.jsxs)(`div`,{className:X.grepPanel,children:[(0,k.jsxs)(`div`,{className:X.grepRow,children:[(0,k.jsx)(`input`,{className:X.grepInput,value:be,onChange:e=>xe(e.target.value),onKeyDown:e=>e.key===`Enter`&&Xe(),placeholder:`Cerca nel codice...`}),(0,k.jsx)(`button`,{className:X.grepBtn,onClick:Xe,children:`🔍`}),(0,k.jsx)(`button`,{className:X.grepClose,onClick:()=>ye(!1),children:`×`})]}),I.length>0&&(0,k.jsxs)(`div`,{className:X.grepCount,children:[I.length,` risultati`]}),(0,k.jsx)(`div`,{className:X.grepResults,children:I.length===0?(0,k.jsx)(`div`,{className:X.grepEmpty,children:`Nessun risultato.`}):I.map((e,t)=>(0,k.jsxs)(`div`,{className:X.grepMatch,onClick:()=>Ze(e.file),children:[(0,k.jsxs)(`span`,{className:X.grepMatchFile,children:[e.file,`:`,e.lineNum]}),(0,k.jsx)(`pre`,{className:X.grepMatchLine,children:e.line})]},t))})]}),Se.length>0&&t!==`projects`&&(0,k.jsxs)(`div`,{className:X.diffPanel,children:[(0,k.jsxs)(`div`,{className:X.diffHeader,children:[(0,k.jsxs)(`span`,{children:[`🔌 Diff — `,Se.length,` file modificati`]}),(0,k.jsx)(`button`,{className:X.diffClose,onClick:()=>Ce([]),children:`✕ Chiudi`})]}),Se.map((e,t)=>{let n=e.after.split(`
|
|
533
539
|
`).length-e.before.split(`
|
package/src/ui-dist/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
10
|
<title>NHA — NotHumanAllowed</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-BK9G_hcC.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-6pTX3Jyj.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|