nothumanallowed 14.1.79 → 14.1.81

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothumanallowed",
3
- "version": "14.1.79",
3
+ "version": "14.1.81",
4
4
  "description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/constants.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
 
8
- export const VERSION = '14.1.79';
8
+ export const VERSION = '14.1.81';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -381,6 +381,26 @@ const SkillStore = {
381
381
  if (fs.existsSync(abs)) fs.unlinkSync(abs);
382
382
  },
383
383
 
384
+ /** Ensure memory.md, skills.md, and provider.md always exist for a project. */
385
+ ensureDefaults(projectName, config) {
386
+ const dir = ensureDir(this.dir(projectName));
387
+ const provider = config?.llm?.provider || 'nha';
388
+ const model = config?.llm?.model || '';
389
+
390
+ const memFile = path.join(dir, 'memory.md');
391
+ if (!fs.existsSync(memFile)) {
392
+ fs.writeFileSync(memFile, `# ${projectName} — Project Memory\n\n_Architectural decisions, preferences, and notes._\n`, 'utf-8');
393
+ }
394
+ const skillsFile = path.join(dir, 'skills.md');
395
+ if (!fs.existsSync(skillsFile)) {
396
+ fs.writeFileSync(skillsFile, `# ${projectName} — Skills\n\n_Coding patterns, best practices, and conventions for this project._\n`, 'utf-8');
397
+ }
398
+ const providerFile = path.join(dir, `${provider}.md`);
399
+ if (!fs.existsSync(providerFile)) {
400
+ fs.writeFileSync(providerFile, `# ${provider.toUpperCase()} — ${model || 'Default'}\n\n_Model-specific notes, prompt tips, and configuration._\n`, 'utf-8');
401
+ }
402
+ },
403
+
384
404
  context(projectName) {
385
405
  const skills = this.list(projectName);
386
406
  if (skills.length === 0) return '';
@@ -458,6 +478,9 @@ async function runWebCraftAgent(config, projectName, message, attachments, emit)
458
478
  const dir = ProjectStore.dir(projectName);
459
479
  if (!fs.existsSync(dir)) { emit({ type: 'error', msg: 'Project not found' }); return; }
460
480
 
481
+ // Ensure context files always exist
482
+ SkillStore.ensureDefaults(projectName, config);
483
+
461
484
  const files = _listProjectFiles(dir);
462
485
  const skillCtx = SkillStore.context(projectName);
463
486
 
@@ -851,56 +874,112 @@ ${prevContext ? `Recent files generated (for consistency):\n${prevContext}\n\n`
851
874
  let syntaxError = null;
852
875
  const fileTokensIn = countTokens(fileSys) + countTokens(filePrompt);
853
876
 
854
- try {
855
- // Collect full LLM output first, then stream it to the client in small chunks.
856
- // This gives real word-by-word animation even with non-streaming providers (NHA/Liara).
857
- let rawOutput = '';
858
- await callLLMStream(config, fileSys, filePrompt, (chunk) => {
859
- rawOutput += chunk;
860
- }, { max_tokens: maxTokens });
861
-
862
- // Strip markdown fences if LLM wrapped the output
863
- rawOutput = rawOutput
864
- .replace(/^```[\w]*\n/, '').replace(/\n```$/, '')
865
- .replace(/^```[\w]*\r\n/, '').replace(/\r\n```$/, '').trim();
866
-
867
- // Continuation: if the file appears truncated, ask the model to continue
868
- if (isFileTruncated(rawOutput, fileSpec.name)) {
869
- const contPrompt = `Continue writing the file ${fileSpec.name} exactly from where it was cut off. Output ONLY the continuation (no repetition of what was already written, no explanation):
870
-
871
- ${rawOutput.slice(-800)}`;
872
- let continuation = '';
873
- await callLLMStream(config, fileSys, contPrompt, (chunk) => {
874
- continuation += chunk;
875
- }, { max_tokens: Math.min(maxTokens, 4096) });
876
- continuation = continuation
877
- .replace(/^```[\w]*\n/, '').replace(/\n```$/, '').trim();
878
- rawOutput = rawOutput + '\n' + continuation;
879
- }
877
+ // Retry loop — up to 2 attempts per file
878
+ for (let attempt = 0; attempt < 2; attempt++) {
879
+ try {
880
+ // Stream chunks to browser in real-time during generation
881
+ let rawOutput = '';
882
+ await callLLMStream(config, fileSys, filePrompt, (chunk) => {
883
+ rawOutput += chunk;
884
+ // Real-time streaming to browser
885
+ emit({ type: 'file_chunk', name: fileSpec.name, chunk, fi: fi + 1, total: filePlan.length });
886
+ }, { max_tokens: maxTokens });
887
+
888
+ // Strip markdown fences if LLM wrapped the output
889
+ rawOutput = rawOutput
890
+ .replace(/^```[\w]*\n/, '').replace(/\n```$/, '')
891
+ .replace(/^```[\w]*\r\n/, '').replace(/\r\n```$/, '').trim();
892
+
893
+ // Continuation loop — up to 3 rounds if file appears truncated
894
+ for (let contRound = 0; contRound < 3 && isFileTruncated(rawOutput, fileSpec.name); contRound++) {
895
+ emit({ type: 'file_chunk', name: fileSpec.name, chunk: `\n/* ... continuing (${contRound + 1}) ... */\n`, fi: fi + 1, total: filePlan.length });
896
+ const contPrompt = `The file ${fileSpec.name} was truncated. Continue EXACTLY from the last line. Output ONLY the remaining code (no repetition, no explanation):
897
+
898
+ LAST 600 CHARS OF WHAT WAS WRITTEN:
899
+ ${rawOutput.slice(-600)}
900
+
901
+ Continue from here:`;
902
+ let continuation = '';
903
+ await callLLMStream(config, fileSys, contPrompt, (chunk) => {
904
+ continuation += chunk;
905
+ emit({ type: 'file_chunk', name: fileSpec.name, chunk, fi: fi + 1, total: filePlan.length });
906
+ }, { max_tokens: Math.min(maxTokens, 8192) });
907
+ continuation = continuation
908
+ .replace(/^```[\w]*\n/, '').replace(/\n```$/, '').trim();
909
+ if (continuation.length > 20) {
910
+ rawOutput = rawOutput + '\n' + continuation;
911
+ } else {
912
+ break; // continuation too short — likely done
913
+ }
914
+ }
880
915
 
881
- fileContent = rawOutput;
916
+ fileContent = rawOutput;
917
+ syntaxError = null;
882
918
 
883
- // Stream the final content to the browser in small chunks for animation
884
- await emitTextAsStream(fileContent, (chunk) => {
885
- emit({ type: 'file_chunk', name: fileSpec.name, chunk, fi: fi + 1, total: filePlan.length });
886
- });
919
+ const fileTokensOut = countTokens(fileContent);
920
+ totalTokensIn += fileTokensIn;
921
+ totalTokensOut += fileTokensOut;
887
922
 
888
- const fileTokensOut = countTokens(fileContent);
889
- totalTokensIn += fileTokensIn;
890
- totalTokensOut += fileTokensOut;
923
+ // Quick syntax check for JS/TS files
924
+ if (fileSpec.name.endsWith('.js') || fileSpec.name.endsWith('.mjs')) {
925
+ try { new Function(fileContent); } catch (e) { syntaxError = e.message.replace(/\n.*/s, ''); }
926
+ }
927
+ // HTML completeness check
928
+ if (fileSpec.name.endsWith('.html') && !fileContent.includes('</html>')) {
929
+ syntaxError = 'Missing </html> closing tag';
930
+ }
931
+
932
+ const abs = path.join(projectDir, fileSpec.name);
933
+ ensureDir(path.dirname(abs));
934
+ fs.writeFileSync(abs, fileContent, 'utf-8');
935
+ generatedFiles.push({ name: fileSpec.name, content: fileContent });
936
+ emit({ type: 'file_done', name: fileSpec.name, fi: fi + 1, total: filePlan.length, syntaxError, tokOut: fileTokensOut, cumTokIn: totalTokensIn, cumTokOut: totalTokensOut });
937
+ break; // success — exit retry loop
891
938
 
892
- // Quick syntax check for JS/TS files
893
- if (fileSpec.name.endsWith('.js') || fileSpec.name.endsWith('.mjs')) {
894
- try { new Function(fileContent); } catch (e) { syntaxError = e.message.replace(/\n.*/s, ''); }
939
+ } catch (e) {
940
+ if (attempt === 0) {
941
+ emit({ type: 'file_chunk', name: fileSpec.name, chunk: `\n/* Retry: ${e.message.slice(0, 100)} */\n`, fi: fi + 1, total: filePlan.length });
942
+ continue; // retry once
943
+ }
944
+ emit({ type: 'file_error', name: fileSpec.name, error: e.message });
895
945
  }
946
+ }
947
+ }
896
948
 
897
- const abs = path.join(projectDir, fileSpec.name);
898
- ensureDir(path.dirname(abs));
899
- fs.writeFileSync(abs, fileContent, 'utf-8');
900
- generatedFiles.push({ name: fileSpec.name, content: fileContent });
901
- emit({ type: 'file_done', name: fileSpec.name, fi: fi + 1, total: filePlan.length, syntaxError, tokOut: fileTokensOut, cumTokIn: totalTokensIn, cumTokOut: totalTokensOut });
902
- } catch (e) {
903
- emit({ type: 'file_error', name: fileSpec.name, error: e.message });
949
+ // ── Post-generation integrity check ──────────────────────────────────────
950
+ const brokenFiles = generatedFiles.filter((f) => {
951
+ if (!f.content || f.content.length < 20) return true;
952
+ if (f.name.endsWith('.html') && !f.content.includes('</html>')) return true;
953
+ if ((f.name.endsWith('.js') || f.name.endsWith('.mjs'))) {
954
+ try { new Function(f.content); } catch { return true; }
955
+ }
956
+ if (f.name.endsWith('.json')) {
957
+ try { JSON.parse(f.content); } catch { return true; }
958
+ }
959
+ return isFileTruncated(f.content, f.name);
960
+ });
961
+
962
+ if (brokenFiles.length > 0 && brokenFiles.length <= 10) {
963
+ emit({ type: 'phase', phase: 'autofix', msg: `Post-generation fix: ${brokenFiles.length} file(s) need repair...` });
964
+ for (const broken of brokenFiles) {
965
+ try {
966
+ emit({ type: 'status', msg: `Regenerating ${broken.name}...` });
967
+ let fixedContent = '';
968
+ const fixPrompt = `Regenerate this file COMPLETELY. It was truncated or has errors.\n\nFile: ${broken.name}\nProject: ${projectName}\nDescription: ${description}\nFull file list: ${allFileNames}\n\nOutput the COMPLETE file content only, no explanation.`;
969
+ await callLLMStream(config, fileSys, fixPrompt, (chunk) => {
970
+ fixedContent += chunk;
971
+ }, { max_tokens: 16384 });
972
+ fixedContent = fixedContent
973
+ .replace(/^```[\w]*\n/, '').replace(/\n```$/, '').trim();
974
+ if (fixedContent.length > broken.content.length) {
975
+ broken.content = fixedContent;
976
+ const abs = path.join(projectDir, broken.name);
977
+ fs.writeFileSync(abs, fixedContent, 'utf-8');
978
+ emit({ type: 'status', msg: `Fixed ${broken.name} (${fixedContent.length} chars)` });
979
+ }
980
+ } catch (e) {
981
+ emit({ type: 'status', msg: `Could not fix ${broken.name}: ${e.message.slice(0, 100)}` });
982
+ }
904
983
  }
905
984
  }
906
985
 
@@ -914,17 +993,15 @@ ${rawOutput.slice(-800)}`;
914
993
  };
915
994
  fs.writeFileSync(ProjectStore.metaPath(projectName), JSON.stringify(meta, null, 2), 'utf-8');
916
995
 
917
- // Initialize skill context files
918
- const ctxDir = ensureDir(SkillStore.dir(projectName));
919
- const memFile = path.join(ctxDir, 'memory.md');
920
- if (!fs.existsSync(memFile)) {
921
- fs.writeFileSync(memFile, `# ${projectName} — Project Memory\n\n_Add architectural decisions, preferences, and notes here._\n`, 'utf-8');
922
- }
996
+ // Initialize skill context files (memory.md, skills.md, provider.md)
997
+ SkillStore.ensureDefaults(projectName, config);
998
+ const ctxDir = SkillStore.dir(projectName);
923
999
 
924
- // Generate skills.md with project context knowledge structure
1000
+ // Generate detailed skills.md with project context knowledge structure (first time only)
925
1001
  const skillsFile = path.join(ctxDir, 'skills.md');
926
- if (!fs.existsSync(skillsFile)) {
927
- const skillsContent = `# ${projectName} — Skills & Knowledge Structure
1002
+ const skillsContent = fs.existsSync(skillsFile) ? fs.readFileSync(skillsFile, 'utf-8') : '';
1003
+ if (skillsContent.length < 100) {
1004
+ const detailedSkills = `# ${projectName} — Skills & Knowledge Structure
928
1005
 
929
1006
  ## Context Discovery Strategy
930
1007
 
@@ -962,36 +1039,11 @@ Agents score context relevance based on:
962
1039
 
963
1040
  This approach ensures agents have the right context without being overwhelmed by irrelevant information.
964
1041
  `;
965
- fs.writeFileSync(skillsFile, skillsContent, 'utf-8');
1042
+ fs.writeFileSync(skillsFile, detailedSkills, 'utf-8');
966
1043
  }
967
- // Initialize provider-specific file (liara.md, claude.md, etc.)
1044
+
968
1045
  const provider = config.llm?.provider || 'nha';
969
1046
  const model = config.llm?.model || '';
970
- const providerFile = path.join(ctxDir, `${provider}.md`);
971
- if (!fs.existsSync(providerFile)) {
972
- const providerContent = `# ${provider.toUpperCase()} Model Configuration
973
-
974
- ## Current Model: ${model || 'Default'}
975
-
976
- ### Model Characteristics
977
- - **Provider**: ${provider}
978
- - **Model**: ${model || 'Default model for this provider'}
979
- - **Context Window**: Varies by model
980
- - **Strengths**: Add specific strengths of this model
981
- - **Limitations**: Add specific limitations to be aware of
982
-
983
- ### Best Practices for This Model
984
- - Write specific coding patterns this model excels at
985
- - Note any formatting preferences
986
- - Document prompt engineering tips that work well
987
-
988
- ### Configuration Notes
989
- - Add any specific configuration notes for this provider
990
- - Document any rate limits or special considerations
991
- `;
992
- fs.writeFileSync(providerFile, providerContent, 'utf-8');
993
- }
994
-
995
1047
  const logFile = path.join(ctxDir, 'changes.log.md');
996
1048
  const logEntry = `## ${new Date().toISOString().slice(0, 10)} — Initial generation\n- Generated ${generatedFiles.length} files\n- Tokens in: ${totalTokensIn} / out: ${totalTokensOut}\n- Description: ${description}\n- Provider: ${provider} (${model || 'default'})\n`;
997
1049
  fs.writeFileSync(logFile, (fs.existsSync(logFile) ? fs.readFileSync(logFile, 'utf-8') : '') + logEntry, 'utf-8');
@@ -1104,6 +1156,8 @@ export function register(router) {
1104
1156
  // ── Skills get ────────────────────────────────────────────────────────────
1105
1157
  router.get(/^\/api\/studio\/webcraft\/skills\/(?<name>[^/?]+)(?:\?|$)/, (req, res) => {
1106
1158
  const projectName = decodeURIComponent(req.params.name ?? '');
1159
+ // Always ensure defaults exist when loading skills
1160
+ SkillStore.ensureDefaults(projectName, loadConfig());
1107
1161
  sendJSON(res, 200, { skills: SkillStore.list(projectName) });
1108
1162
  });
1109
1163
 
@@ -678,7 +678,7 @@ FRONTEND:
678
678
  - apply.html: Application modal/page — job summary header, form (Full Name / Email / Phone / LinkedIn URL / Portfolio URL / Cover Letter textarea with character count / Resume paste textarea), Submit button with loading state, success page with application reference number
679
679
  - public/css/main.css: Modern job board design — tag/badge system (Remote=blue, Onsite=green, Urgent=red), salary range display, company logo placeholder styles, filter sidebar collapse on mobile, job card hover effects, application form validation styles`}],ln=[{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:`✉️`}],un={js:`📄`,ts:`📄`,css:`🎨`,html:`🌐`,json:`📋`,md:`📑`,sql:`🗂`,env:`🔐`,conf:`⚙`,lock:`🔒`};function dn(e){return un[e.split(`.`).pop()?.toLowerCase()??``]??`📄`}function fn(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 pn(e){return e===`memory`?`🧠`:e===`provider`?`🤖`:e===`log`?`📄`:`📋`}function mn(){let e=P(),[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)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,ee]=(0,_.useState)(!1),[D,te]=(0,_.useState)(0),[ne,A]=(0,_.useState)(0),[re,M]=(0,_.useState)(``),[N,ie]=(0,_.useState)({fi:0,total:0,name:``}),[ae,oe]=(0,_.useState)({tokIn:0,tokOut:0}),[se,ce]=(0,_.useState)(null),[F,le]=(0,_.useState)([]),[ue,de]=(0,_.useState)(``),[fe,pe]=(0,_.useState)(!1),[me,he]=(0,_.useState)([]),[ge,_e]=(0,_.useState)(null),[ve,ye]=(0,_.useState)([]),[I,be]=(0,_.useState)(!1),[xe,Se]=(0,_.useState)(null),[Ce,L]=(0,_.useState)([]),[we,Te]=(0,_.useState)(!1),[Ee,R]=(0,_.useState)(``),[z,De]=(0,_.useState)([]),[Oe,ke]=(0,_.useState)([]),[Ae,je]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)(null),[Pe,Fe]=(0,_.useState)(!1),[Ie,B]=(0,_.useState)([]),[Le,Re]=(0,_.useState)(null),[ze,Be]=(0,_.useState)(!0),Ve=(0,_.useRef)(null),[He,Ue]=(0,_.useState)(`0s`),[We,Ge]=(0,_.useState)(`0s`),Ke=(0,_.useRef)(0),qe=(0,_.useRef)(0),Je=(0,_.useRef)(null),Ye=(0,_.useRef)(null),Xe=(0,_.useRef)(null),Ze=(0,_.useRef)(null),Qe=(0,_.useRef)(null),$e=(0,_.useRef)(null);function et(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function tt(e){let t=Math.floor((Date.now()-e)/1e3),n=Math.floor(t/60);return(n>0?`${n}m `:``)+`${t%60}s`}(0,_.useEffect)(()=>(w||E?Je.current=setInterval(()=>{w&&Ue(tt(Ke.current)),E&&Ge(tt(qe.current))},1e3):Je.current&&=(clearInterval(Je.current),null),()=>{Je.current&&clearInterval(Je.current)}),[w,E]);function nt(){Xe.current&&(Xe.current.scrollTop=Xe.current.scrollHeight)}(0,_.useEffect)(()=>{nt()},[F]),(0,_.useEffect)(()=>{a&&!I&&(be(!0),O(`/api/studio/webcraft/skills/${encodeURIComponent(a)}`).then(e=>{e?.skills&&ye(e.skills)}).catch(()=>{}))},[a,I]);async function rt(e,t){if(w||!e||e.length<5)return;T(!0),m([]),g(0),y(null),ie({fi:0,total:0,name:``}),oe({tokIn:0,tokOut:0}),Ke.current=Date.now(),Ue(`0s`),Ye.current=new AbortController;let n=Date.now();try{let r=await fetch(`/api/studio/webcraft/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},signal:Ye.current.signal,body:JSON.stringify({projectName:t,description:e,blocks:l,authFields:d})});if(!r.ok||!r.body){T(!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(`
680
680
 
681
- `);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===`processing`||e.type===`planning`)ie(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)s.push({name:e.name,content:``,_pending:!0}),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),g(s.length-1),y(``);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]),y(t?t.content:null)}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]),ie({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&oe({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}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`&&(ce({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:s.length}),y(null),T(!1),be(!1),ye([]),s.some(e=>e._error||e._syntaxError)?setTimeout(()=>Qe.current?.(),800):setTimeout(()=>$e.current?.(),800))}catch{}}}}catch(e){e.name!==`AbortError`&&le(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),T(!1)}}async function it(){let e=ue.trim();if(!(a&&p.length>0)){if(!e||e.length<5)return;let t=a||`MyProject`;o(t),c(e),de(``),await rt(e,t);return}if(!e&&me.length===0||fe||w)return;let t=[...me];if(he([]),de(``),e.toLowerCase().startsWith(`/plan `)||e.toLowerCase().startsWith(`piano: `)){let t=e.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);le(t=>[...t,{role:`user`,text:e}]),await at(`[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}le(n=>[...n,{role:`user`,text:e,attachments:t}]),await at(e,null,t)}async function at(e,t,n){if(fe)return;pe(!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){le(e=>[...e,{role:`agent`,text:`Errore: ${i.status}`,tools:[]}]),pe(!1);return}let o={role:`agent`,text:``,tools:[]};le(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(`
681
+ `);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===`processing`||e.type===`planning`)ie(t=>({...t,name:e.type===`planning`?`📋 Pianificazione struttura...`:e.msg||`Avvio...`}));else if(e.type===`file_start`)s.push({name:e.name,content:``,_pending:!0}),m([...s]),ie({fi:e.fi,total:e.total,name:e.name}),g(s.length-1),y(``);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]),y(t?t.content:null)}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]),ie({fi:e.fi,total:e.total,name:e.name}),(e.cumTokIn||e.cumTokOut)&&oe({tokIn:e.cumTokIn||0,tokOut:e.cumTokOut||0})}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===`phase`||e.type===`status`&&!e.op?ie(t=>({...t,name:e.msg||e.phase||``})):e.type===`done`&&(ce({seconds:Math.round((Date.now()-n)/1e3),tokIn:e.tokIn??0,tokOut:e.tokOut??0,files:s.length}),y(null),T(!1),be(!1),ye([]),s.some(e=>e._error||e._syntaxError)?setTimeout(()=>Qe.current?.(),800):setTimeout(()=>$e.current?.(),800))}catch{}}}}catch(e){e.name!==`AbortError`&&le(t=>[...t,{role:`system`,text:`Errore generazione: `+e.message}]),T(!1)}}async function it(){let e=ue.trim();if(!(a&&p.length>0)){if(!e||e.length<5)return;let t=a||`MyProject`;o(t),c(e),de(``),await rt(e,t);return}if(!e&&me.length===0||fe||w)return;let t=[...me];if(he([]),de(``),e.toLowerCase().startsWith(`/plan `)||e.toLowerCase().startsWith(`piano: `)){let t=e.replace(/^\/plan[ ]*/i,``).replace(/^piano:[ ]*/i,``);le(t=>[...t,{role:`user`,text:e}]),await at(`[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}le(n=>[...n,{role:`user`,text:e,attachments:t}]),await at(e,null,t)}async function at(e,t,n){if(fe)return;pe(!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){le(e=>[...e,{role:`agent`,text:`Errore: ${i.status}`,tools:[]}]),pe(!1);return}let o={role:`agent`,text:``,tools:[]};le(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(`
682
682
 
683
683
  `);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,le(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),le(e=>{let t=[...e];return t[t.length-1]={...o},t})):e.type===`done`?(t&&!u&&_e({plan:o.text,originalMessage:t}),pe(!1),e.changed&&await ot((o.tools??[]).filter(e=>e.op===`edit`||e.op===`write`).map(e=>e.path),r)):e.type===`error`&&(o.text+=`
684
684
  Errore: `+e.msg,pe(!1))}catch{}}}}catch(e){le(t=>[...t,{role:`agent`,text:`Errore di rete: `+e.message,tools:[]}])}pe(!1)}async function ot(e,t){if(!a)return;let n=await O(`/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);ke(e=>[...e,...r])}}function st(){Ye.current&&=(Ye.current.abort(),null),T(!1),pe(!1),le(e=>[...e,{role:`system`,text:`⏹ Generazione interrotta.`}])}async function ct(){return a?(await k(`/api/studio/webcraft/snapshot`,{projectName:a}))?.snapshot??null:null}async function lt(){let e=await ct();e&&(le(t=>[...t,{role:`system`,text:`💾 Snapshot salvato (${e.slice(0,16).replace(`T`,` `)})`}]),V())}async function V(){if(!a)return;let e=await O(`/api/studio/webcraft/snapshots/${encodeURIComponent(a)}`);e?.snapshots&&L(e.snapshots)}async function ut(e){confirm(`Ripristinare lo snapshot del ${e.replace(`T`,` `).slice(0,16)}? I file attuali verranno sovrascritti.`)&&await k(`/api/studio/webcraft/restore`,{projectName:a,ts:e})!==null&&(le(t=>[...t,{role:`agent`,text:`Snapshot ripristinato (${e}). Ricarico i file...`}]),ot([],{}))}async function dt(){if(!a)return;let e=await k(`/api/studio/webcraft/syntax-check`,{projectName:a});if(e?.results){let t=e.results.filter(e=>!e.ok);t.length>0?le(e=>[...e,{role:`system`,text:`⚠ Syntax check: ${t.length} errore/i trovato/i.`,syntaxErrors:t}]):le(e=>[...e,{role:`system`,text:`✓ Syntax check: tutti i file JS sono validi.`}])}}async function ft(){let e=p.filter(e=>e._error||e._syntaxError);if(e.length===0){$e.current?.();return}ee(!0),te(0),A(e.length),qe.current=Date.now(),Ge(`0s`);for(let t=0;t<e.length;t++){let n=e[t];M(n.name),te(t),await at(`REPAIR FILE: ${n.name}\nErrore: ${n._syntaxError??`generazione fallita`}\nRigenera il file correttamente. Output SOLO il contenuto del file, nessuna spiegazione.`,null,[])}te(e.length),M(``),ee(!1),setTimeout(()=>$e.current?.(),500)}let pt={cleanup:`🧹`,shims:`🔌`,deps:`📦`,start:`🚀`,autofix:`🔧`,ready:`✅`};function mt(e,t=`info`){let n=new Date().toLocaleTimeString();B(r=>[...r,`${t===`phase`?`
@@ -698,4 +698,4 @@ Errore: `+e.msg,pe(!1))}catch{}}}}catch(e){le(t=>[...t,{role:`agent`,text:`Error
698
698
  `).map((e,t)=>(0,j.jsxs)(`div`,{className:Z.diffAddLine,children:[`+ `,e]},`a${t}`))]},t)),e.tools&&e.tools.length>0&&(0,j.jsx)(`div`,{className:Z.chatToolBadges,children:e.tools.map((e,t)=>(0,j.jsxs)(`span`,{className:`${Z.toolBadge} ${e.result===`ok`?Z.toolBadgeOk:Z.toolBadgeErr}`,children:[e.op===`edit`?`✏`:e.op===`write`?`+`:`👁`,` `,e.path]},t))})]})]},t)),fe&&(0,j.jsxs)(`div`,{className:Z.chatAgentCard,children:[(0,j.jsxs)(`div`,{className:Z.chatAgentHeader,children:[(0,j.jsx)(`span`,{className:Z.chatAgentRobotAnim,children:`🤖`}),(0,j.jsx)(`span`,{className:Z.chatAgentLabel,children:`WebCraft Agent`}),(0,j.jsxs)(`span`,{className:Z.chatRunningDots,children:[(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot1}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot2}`}),(0,j.jsx)(`span`,{className:`${Z.dot} ${Z.dot3}`})]})]}),(0,j.jsx)(`div`,{className:Z.chatAgentText,children:(0,j.jsx)(`span`,{className:Z.cursor,children:`​`})})]})]}),me.length>0&&(0,j.jsx)(`div`,{className:Z.attachPreviews,children:me.map((e,t)=>(0,j.jsxs)(`span`,{className:Z.attachBadge,children:[`📎 `,e.name,(0,j.jsx)(`button`,{className:Z.removeAttachBtn,onClick:()=>he(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),Et?(0,j.jsxs)(`div`,{className:Z.projActiveRow,children:[`📄 `,(0,j.jsx)(`strong`,{className:Z.projActiveName,children:a}),` — scrivi per modificare o migliorare il progetto`]}):(0,j.jsxs)(`div`,{className:Z.projNameRow,children:[(0,j.jsx)(`span`,{className:Z.projNameLabel,children:`Nome progetto:`}),(0,j.jsx)(`input`,{className:Z.projNameInput,value:a,onChange:e=>o(e.target.value),placeholder:`MioProgetto`})]}),(0,j.jsxs)(`div`,{className:Z.chatInputRow,children:[(0,j.jsxs)(`label`,{className:Z.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,j.jsx)(`input`,{ref:Ze,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>Tt(e.target.files)})]}),(0,j.jsx)(`textarea`,{className:Z.chatTextarea,value:ue,onChange:e=>de(e.target.value),placeholder:Et?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:Ot,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),it())},rows:4}),(0,j.jsxs)(`div`,{className:Z.chatSendCol,children:[(0,j.jsx)(`button`,{className:Z.chatSendBtn,onClick:it,disabled:Ot,children:w?`⏳`:Et?`▶`:`▶ Genera`}),Ot&&(0,j.jsx)(`button`,{className:Z.chatStopBtn,onClick:st,children:`⏹ Stop`})]})]})]}),xe&&(0,j.jsx)(gn,{modal:xe,skills:ve,projectName:a,onClose:()=>Se(null),onSave:(e,t,n)=>yt(xe,e,t,n)})]})}function hn({before:e,after:t}){let n=e.split(`
699
699
  `),r=t.split(`
700
700
  `),i=[],a=0,o=0;for(;(a<n.length||o<r.length)&&(a>=n.length?i.push({type:`add`,text:r[o++]??``}):o>=r.length?i.push({type:`rem`,text:n[a++]??``}):n[a]===r[o]?(i.push({type:`same`,text:n[a++]??``}),o++):(i.push({type:`rem`,text:n[a++]??``}),i.push({type:`add`,text:r[o++]??``})),!(i.length>2e3)););return(0,j.jsx)(`div`,{style:{fontFamily:`var(--mono)`,fontSize:10},children:i.map((e,t)=>(0,j.jsxs)(`div`,{style:{padding:`1px 8px`,background:e.type===`add`?`#0a3a1a`:e.type===`rem`?`#3a0a0a`:`transparent`,color:e.type===`add`?`#4ade80`:e.type===`rem`?`#f87171`:`var(--dim)`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:[e.type===`add`?`+`:e.type===`rem`?`-`:` `,e.text]},t))})}function gn({modal:e,skills:t,projectName:n,onClose:r,onSave:i}){let[a,o]=(0,_.useState)(e.name),[s,c]=(0,_.useState)(e.content),[l,u]=(0,_.useState)(e.type),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),h=l===`skill`?6e3:4e3,g=s.length>h;async function v(){if(!d.trim())return;m(!0);let e={skill:`Sei un esperto di sviluppo web fullstack. Genera un file Markdown "skill" per il WebCraft Agent. Deve contenere istruzioni, pattern di codice, best practice e snippet pronti all uso come contesto persistente. Scrivi SOLO il contenuto Markdown, niente altro.`,memory:`Sei un assistente tecnico. Genera un file Markdown "memory" per il WebCraft Agent. Deve riassumere decisioni architetturali, preferenze dello sviluppatore e contesto generale del progetto. Scrivi SOLO il Markdown.`,provider:`Sei un esperto di prompt engineering. Genera un file Markdown con istruzioni specifiche per calibrare il comportamento del modello AI. Scrivi SOLO il Markdown.`},t=await k(`/api/studio/webcraft`,{system:e[l]??e.skill,user:`Progetto: ${n}\n\n${d}`,max_tokens:2048});t?.text&&(c(t.text),a||o(l===`memory`?`memory.md`:l===`provider`?`liara.md`:d.toLowerCase().replace(/[^a-z0-9]+/g,`-`).slice(0,30)+`.md`)),m(!1)}function y(){if(!a.trim()){alert(`Inserisci un nome per il file.`);return}let n=a.endsWith(`.md`)?a:a+`.md`;if((l===`memory`||l===`provider`)&&e.mode===`new`&&t.findIndex(e=>e.type===l)>=0){alert(`Esiste già un file di tipo "${l}". Modificalo direttamente.`);return}i(n,s,l)}return(0,j.jsx)(`div`,{className:Z.modalOverlay,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,j.jsxs)(`div`,{className:Z.modal,children:[(0,j.jsxs)(`div`,{className:Z.modalHeader,children:[(0,j.jsxs)(`span`,{className:Z.modalTitle,children:[pn(l),` `,e.mode===`new`?`Nuovo file di contesto`:`Modifica ${e.name}`]}),(0,j.jsx)(`button`,{className:Z.modalClose,onClick:r,children:`×`})]}),(0,j.jsx)(`div`,{className:Z.modalBody,children:e.mode===`view`?(0,j.jsx)(`pre`,{className:Z.logView,children:s}):(0,j.jsxs)(j.Fragment,{children:[e.mode===`new`&&(0,j.jsxs)(`div`,{className:Z.modalRow,children:[(0,j.jsxs)(`div`,{className:Z.modalField,children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`TIPO`}),(0,j.jsx)(`select`,{value:l,onChange:e=>{let t=e.target.value;u(t),t===`memory`?o(`memory.md`):t===`provider`&&o(`liara.md`)},className:Z.modalSelect,children:[`skill`,`memory`,`provider`].map(e=>{let n=(e===`memory`||e===`provider`)&&t.some(t=>t.type===e);return(0,j.jsxs)(`option`,{value:e,disabled:n,children:[e,n?` (esiste già)`:``]},e)})})]}),(0,j.jsxs)(`div`,{className:Z.modalField,style:{flex:2},children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`NOME FILE`}),(0,j.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:l===`memory`?`memory.md`:l===`provider`?`liara.md`:`nome-skill.md`,className:Z.modalInput})]})]}),(0,j.jsxs)(`div`,{className:Z.modalHint,children:[`💡 `,l===`skill`?`Istruzioni tecniche, snippet, pattern di codice specifici. Max ~6000 caratteri.`:l===`memory`?`Note persistenti sul progetto: decisioni architetturali, preferenze. Solo UN file. Max ~4000 caratteri.`:`Istruzioni specifiche per il modello AI (tono, formato, vincoli). Solo UN file. Max ~4000 caratteri.`]}),(0,j.jsxs)(`div`,{className:Z.modalAiBox,children:[(0,j.jsx)(`div`,{className:Z.modalLabel,children:`🤖 GENERA CON AI`}),(0,j.jsxs)(`div`,{className:Z.modalAiRow,children:[(0,j.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,placeholder:`Descrivi cosa deve contenere questo file...`,className:Z.modalAiDesc}),(0,j.jsx)(`button`,{onClick:v,disabled:p,className:Z.modalAiBtn,children:p?`⏳ ...`:`▶ Genera`})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:Z.modalLabelRow,children:[(0,j.jsx)(`span`,{children:`CONTENUTO (markdown)`}),(0,j.jsxs)(`span`,{style:{color:g?`#e05050`:`var(--dim)`},children:[s.length,` car.`,g?` ⚠ Troppo lungo`:``]})]}),(0,j.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:14,placeholder:`# Titolo
701
- Scrivi le istruzioni in Markdown...`,className:Z.modalContentArea,style:{borderColor:g?`#e05050`:`var(--border2)`}})]})]})}),(0,j.jsxs)(`div`,{className:Z.modalFooter,children:[(0,j.jsx)(`button`,{onClick:r,className:Z.modalCancelBtn,children:`Annulla`}),e.mode!==`view`&&(0,j.jsx)(`button`,{onClick:y,className:Z.modalSaveBtn,children:`✓ Salva`})]})]})})}var _n={root:`_root_x9yvu_1`,loading:`_loading_x9yvu_7`,empty:`_empty_x9yvu_18`,emptyIcon:`_emptyIcon_x9yvu_29`,emptyTitle:`_emptyTitle_x9yvu_30`,emptySub:`_emptySub_x9yvu_31`,generateBtn:`_generateBtn_x9yvu_33`,summary:`_summary_x9yvu_46`,sectionTitle:`_sectionTitle_x9yvu_57`,alertTitle:`_alertTitle_x9yvu_68`,actionCard:`_actionCard_x9yvu_70`,actionTime:`_actionTime_x9yvu_81`,actionText:`_actionText_x9yvu_89`,schedCard:`_schedCard_x9yvu_95`,schedTime:`_schedTime_x9yvu_106`,schedTitle:`_schedTitle_x9yvu_114`,alertCard:`_alertCard_x9yvu_119`,alertSev:`_alertSev_x9yvu_129`,alertAction:`_alertAction_x9yvu_135`,insight:`_insight_x9yvu_141`,regenRow:`_regenRow_x9yvu_148`,regenBtn:`_regenBtn_x9yvu_153`};function vn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=()=>{i(!0),c(!1),O(`/api/plan`).then(e=>{e?.plan?(n(e.plan),c(!1)):(n(null),c(!0)),i(!1)}).catch(()=>{i(!1),c(!0)})},u=async()=>{o(!0),i(!0),n(null);try{await k(`/api/plan/refresh`,{}),l()}catch{i(!1)}finally{o(!1)}};if((0,_.useEffect)(()=>{l()},[]),r)return(0,j.jsxs)(`div`,{className:_n.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),(0,j.jsx)(`div`,{children:a?`Generating plan with 5 agents...`:`Loading plan...`})]});if(s||!t)return(0,j.jsxs)(`div`,{className:_n.empty,children:[(0,j.jsx)(`div`,{className:_n.emptyIcon,children:`🗓️`}),(0,j.jsxs)(`div`,{className:_n.emptyTitle,children:[e(`plan.noplan`),` generated yet`]}),(0,j.jsx)(`div`,{className:_n.emptySub,children:`Generate a daily plan using your calendar, tasks, and emails.`}),(0,j.jsx)(`button`,{className:_n.generateBtn,onClick:u,children:e(`plan.generate`)})]});let d=e=>typeof e==`string`?e:e.description??e.message??e.action_required??`Alert`,f=e=>typeof e==`object`&&e.severity?` [${e.severity.toUpperCase()}]`:``,p=e=>typeof e==`object`&&e.action_required&&e.action_required!==d(e)?e.action_required:``,m=e=>typeof e==`string`?e:e.message??e.insight??``;return(0,j.jsxs)(`div`,{className:_n.root,children:[t.executive_summary&&(0,j.jsx)(`div`,{className:_n.summary,children:t.executive_summary}),t.priority_actions&&t.priority_actions.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Priority Actions`}),t.priority_actions.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.actionCard,children:[e.time&&(0,j.jsx)(`span`,{className:_n.actionTime,children:e.time}),(0,j.jsx)(`span`,{className:_n.actionText,children:e.action})]},t))]}),t.schedule&&t.schedule.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Schedule`}),t.schedule.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.schedCard,children:[(0,j.jsxs)(`span`,{className:_n.schedTime,children:[e.time_start,`–`,e.time_end]}),(0,j.jsx)(`span`,{className:_n.schedTitle,children:e.title})]},t))]}),t.security_alerts&&t.security_alerts.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`${_n.sectionTitle} ${_n.alertTitle}`,children:`Security Alerts`}),t.security_alerts.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.alertCard,children:[(0,j.jsxs)(`span`,{className:_n.alertSev,children:[`!`,f(e)]}),(0,j.jsx)(`span`,{children:d(e)}),p(e)&&(0,j.jsxs)(`div`,{className:_n.alertAction,children:[`Action: `,p(e)]})]},t))]}),t.insights&&t.insights.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Insights`}),t.insights.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.insight,children:[`→ `,m(e)]},t))]}),(0,j.jsx)(`div`,{className:_n.regenRow,children:(0,j.jsx)(`button`,{className:_n.regenBtn,onClick:u,disabled:a,children:a?`Regenerating…`:`↺ Regenerate`})})]})}function yn(e){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:e===`sheet`?`📊`:e===`slides`?`📽`:`📄`}function bn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=(e=``)=>{i(!0),O(e?`/api/onedrive?q=${encodeURIComponent(e)}`:`/api/onedrive`).then(e=>{n(e??{files:[]}),i(!1)}).catch(()=>{o(`Could not load OneDrive. Run nha microsoft auth in the terminal to connect.`),i(!1)})};if((0,_.useEffect)(()=>{l()},[]),a)return(0,j.jsx)(`div`,{className:J.error,children:a});let u=t?.files??[],d=t?.quota;return(0,j.jsxs)(`div`,{className:J.root,children:[d&&(0,j.jsxs)(`div`,{className:J.quotaBar,children:[(0,j.jsxs)(`div`,{className:J.quotaText,children:[(0,j.jsxs)(`span`,{className:J.quotaUsed,children:[d.usage,` of `,d.limit,` used`]}),(0,j.jsxs)(`span`,{className:J.quotaPct,children:[d.percentUsed,`%`]})]}),(0,j.jsx)(`div`,{className:J.quotaTrack,children:(0,j.jsx)(`div`,{className:J.quotaFill,style:{width:`${Math.min(d.percentUsed,100)}%`,background:d.percentUsed>90?`var(--red)`:d.percentUsed>70?`var(--amber)`:`var(--cyan)`}})})]}),(0,j.jsxs)(`div`,{className:J.searchRow,children:[(0,j.jsx)(`input`,{className:J.searchInput,value:s,onChange:e=>c(e.target.value),placeholder:`Search OneDrive files…`,onKeyDown:e=>e.key===`Enter`&&l(s)}),(0,j.jsx)(`button`,{className:J.searchBtn,onClick:()=>l(s),children:`Search`})]}),r&&(0,j.jsxs)(`div`,{className:J.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!r&&u.length===0&&(0,j.jsx)(`div`,{className:J.empty,children:e(`drive.noFiles`)}),(0,j.jsx)(`div`,{className:J.fileList,children:u.map(e=>(0,j.jsxs)(`div`,{className:J.fileRow,children:[(0,j.jsx)(`span`,{className:J.fileIcon,children:yn(e.type)}),(0,j.jsxs)(`div`,{className:J.fileInfo,children:[(0,j.jsx)(`div`,{className:J.fileName,children:e.name}),(0,j.jsxs)(`div`,{className:J.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``]})]}),(0,j.jsx)(`div`,{className:J.fileBtns,children:e.webViewLink&&(0,j.jsx)(`a`,{className:J.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,children:`Open`})})]},e.id))})]})}var xn={root:`_root_1vbmp_1`,loading:`_loading_1vbmp_2`,error:`_error_1vbmp_3`,empty:`_empty_1vbmp_4`,addRow:`_addRow_1vbmp_6`,addInput:`_addInput_1vbmp_7`,addBtn:`_addBtn_1vbmp_8`,list:`_list_1vbmp_10`,taskRow:`_taskRow_1vbmp_11`,checkBtn:`_checkBtn_1vbmp_12`,taskInfo:`_taskInfo_1vbmp_14`,taskTitle:`_taskTitle_1vbmp_15`,taskDue:`_taskDue_1vbmp_16`,taskImp:`_taskImp_1vbmp_17`};function Sn(){let e=P(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=()=>{O(`/api/mstodo`).then(e=>{n(e?.tasks??[]),i(!1)}).catch(()=>{o(`Microsoft To Do requires Microsoft authentication. Run nha microsoft auth in the terminal.`),i(!1)})};(0,_.useEffect)(()=>{l()},[]);let u=()=>{let e=s.trim();e&&(c(``),k(`/api/mstodo`,{title:e}).then(e=>{e?.task&&l()}))},d=(e,t)=>{k(`/api/mstodo/${e}/complete`,{listId:t}).then(()=>l())};return r?(0,j.jsxs)(`div`,{className:xn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,j.jsx)(`div`,{className:xn.error,children:a}):(0,j.jsxs)(`div`,{className:xn.root,children:[(0,j.jsxs)(`div`,{className:xn.addRow,children:[(0,j.jsx)(`input`,{className:xn.addInput,value:s,onChange:e=>c(e.target.value),placeholder:`Add a new task…`,onKeyDown:e=>e.key===`Enter`&&u()}),(0,j.jsx)(`button`,{className:xn.addBtn,onClick:u,children:`+ Add`})]}),t.length===0&&(0,j.jsx)(`div`,{className:xn.empty,children:`No active tasks`}),(0,j.jsx)(`div`,{className:xn.list,children:t.map(e=>{let t=e.importance===`high`?`var(--red)`:e.importance===`low`?`var(--dim)`:`var(--amber)`;return(0,j.jsxs)(`div`,{className:xn.taskRow,children:[(0,j.jsx)(`button`,{className:xn.checkBtn,onClick:()=>d(e.id,e.listId)}),(0,j.jsxs)(`div`,{className:xn.taskInfo,children:[(0,j.jsx)(`div`,{className:xn.taskTitle,children:e.title}),e.dueDate&&(0,j.jsxs)(`div`,{className:xn.taskDue,children:[`Due: `,e.dueDate.split(`T`)[0]]})]}),e.importance&&(0,j.jsx)(`span`,{className:xn.taskImp,style:{color:t},children:e.importance})]},e.id)})})]})}var Cn={root:`_root_1ag4s_1`,header:`_header_1ag4s_3`,title:`_title_1ag4s_4`,subtitle:`_subtitle_1ag4s_5`,controls:`_controls_1ag4s_7`,monitorRow:`_monitorRow_1ag4s_8`,label:`_label_1ag4s_9`,monitorBtn:`_monitorBtn_1ag4s_10`,monitorActive:`_monitorActive_1ag4s_11`,captureBtn:`_captureBtn_1ag4s_12`,analyzeSection:`_analyzeSection_1ag4s_15`,sectionTitle:`_sectionTitle_1ag4s_16`,presets:`_presets_1ag4s_17`,preset:`_preset_1ag4s_17`,presetActive:`_presetActive_1ag4s_20`,questionRow:`_questionRow_1ag4s_21`,questionInput:`_questionInput_1ag4s_22`,analyzeBtn:`_analyzeBtn_1ag4s_23`,error:`_error_1ag4s_26`,screenshotContainer:`_screenshotContainer_1ag4s_28`,screenshot:`_screenshot_1ag4s_28`,screenshotMeta:`_screenshotMeta_1ag4s_30`,analysis:`_analysis_1ag4s_32`,analysisTitle:`_analysisTitle_1ag4s_33`,analysisText:`_analysisText_1ag4s_34`,continueInChat:`_continueInChat_1ag4s_35`,history:`_history_1ag4s_37`,historyGrid:`_historyGrid_1ag4s_38`,historyItem:`_historyItem_1ag4s_39`,historyThumb:`_historyThumb_1ag4s_40`,historyMeta:`_historyMeta_1ag4s_41`,historyTs:`_historyTs_1ag4s_42`,historyQ:`_historyQ_1ag4s_43`,historyA:`_historyA_1ag4s_44`},wn=[`Describe exactly what you see on the screen`,`Identify any errors, warnings, or issues visible`,`What application is open and what is the user doing?`,`Summarize the content visible on screen and suggest next actions`,`Read and extract all visible text from the screen`,`Analyze the code visible on screen and identify bugs or improvements`,`What financial data or charts are visible? Summarize key numbers`,`Is there anything sensitive or that should be kept private?`];function Tn(){let e=P(),t=ee(e=>e.setView),n=ee(e=>e.apiBase),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)([]),h=async()=>{i(!0),c(null);try{let e=await k(`/api/screen/capture`,{monitor:d});c(e),(e?.base64||e?.file)&&m(t=>[{ts:new Date().toLocaleTimeString(),question:`Screenshot`,analysis:``,src:e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:`${n}/api/screenshots/${e.file}`},...t.slice(0,9)])}catch(e){c({error:e.message})}i(!1)},g=async()=>{if(l.trim()){o(!0);try{let e=await k(`/api/screen/analyze`,{question:l.trim(),monitor:d});if(c(e),e?.analysis){let t=e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:e.file?`${n}/api/screenshots/${e.file}`:``;m(n=>[{ts:new Date().toLocaleTimeString(),question:l.trim(),analysis:e.analysis??``,src:t},...n.slice(0,9)])}}catch(e){c({error:e.message})}o(!1)}},v=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},y=s?.base64?`data:image/${s.format??`jpeg`};base64,${s.base64}`:s?.file?`${n}/api/screenshots/${s.file}`:null;return(0,j.jsxs)(`div`,{className:Cn.root,children:[(0,j.jsx)(`div`,{className:Cn.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Cn.title,children:`🖥️ Screen Capture`}),(0,j.jsxs)(`div`,{className:Cn.subtitle,children:[e(`screen.capture`),` and analyze your desktop screen with AI vision`]})]})}),(0,j.jsxs)(`div`,{className:Cn.controls,children:[(0,j.jsxs)(`div`,{className:Cn.monitorRow,children:[(0,j.jsx)(`label`,{className:Cn.label,children:`Monitor`}),[1,2,3].map(e=>(0,j.jsxs)(`button`,{className:`${Cn.monitorBtn} ${d===e?Cn.monitorActive:``}`,onClick:()=>f(e),children:[`Monitor `,e]},e))]}),(0,j.jsx)(`button`,{className:Cn.captureBtn,onClick:h,disabled:r||a,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Capturing…`]}):`📷 Capture Screen`})]}),(0,j.jsxs)(`div`,{className:Cn.analyzeSection,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Capture + Analyze`}),(0,j.jsx)(`div`,{className:Cn.presets,children:wn.map(e=>(0,j.jsxs)(`button`,{className:`${Cn.preset} ${l===e?Cn.presetActive:``}`,onClick:()=>u(e),children:[e.slice(0,50),e.length>50?`…`:``]},e))}),(0,j.jsxs)(`div`,{className:Cn.questionRow,children:[(0,j.jsx)(`input`,{className:Cn.questionInput,value:l,onChange:e=>u(e.target.value),placeholder:`Ask something about your screen…`,onKeyDown:e=>e.key===`Enter`&&g()}),(0,j.jsx)(`button`,{className:Cn.analyzeBtn,onClick:g,disabled:!l.trim()||r||a,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Analyzing…`]}):`🔍 Analyze`})]})]}),s?.error&&(0,j.jsx)(`div`,{className:Cn.error,children:s.error}),y&&(0,j.jsxs)(`div`,{className:Cn.screenshotContainer,children:[(0,j.jsx)(`img`,{src:y,className:Cn.screenshot,alt:`Screen capture`}),s?.width&&s?.height&&(0,j.jsxs)(`div`,{className:Cn.screenshotMeta,children:[s.width,` × `,s.height,`px`]})]}),s?.analysis&&(0,j.jsxs)(`div`,{className:Cn.analysis,children:[(0,j.jsx)(`div`,{className:Cn.analysisTitle,children:`AI Analysis`}),(0,j.jsx)(`div`,{className:Cn.analysisText,children:s.analysis}),(0,j.jsx)(`button`,{className:Cn.continueInChat,onClick:()=>v(`I captured my screen. Here's what the AI saw:\n\n${s.analysis}\n\nCan you help me with this?`),children:`Continue in Chat →`})]}),p.length>0&&(0,j.jsxs)(`div`,{className:Cn.history,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Recent Captures`}),(0,j.jsx)(`div`,{className:Cn.historyGrid,children:p.map((e,t)=>(0,j.jsxs)(`div`,{className:Cn.historyItem,children:[e.src&&(0,j.jsx)(`img`,{src:e.src,className:Cn.historyThumb,alt:e.question}),(0,j.jsxs)(`div`,{className:Cn.historyMeta,children:[(0,j.jsx)(`div`,{className:Cn.historyTs,children:e.ts}),(0,j.jsx)(`div`,{className:Cn.historyQ,children:e.question}),e.analysis&&(0,j.jsxs)(`div`,{className:Cn.historyA,children:[e.analysis.slice(0,120),`…`]})]})]},t))})]})]})}var Q={root:`_root_v12qq_1`,header:`_header_v12qq_3`,title:`_title_v12qq_4`,subtitle:`_subtitle_v12qq_5`,section:`_section_v12qq_7`,sectionTitle:`_sectionTitle_v12qq_8`,quickBtns:`_quickBtns_v12qq_10`,quickBtn:`_quickBtn_v12qq_10`,searchRow:`_searchRow_v12qq_14`,searchInput:`_searchInput_v12qq_15`,searchBtn:`_searchBtn_v12qq_16`,modeRow:`_modeRow_v12qq_19`,modeBtn:`_modeBtn_v12qq_20`,modeActive:`_modeActive_v12qq_21`,routeInputs:`_routeInputs_v12qq_23`,inputWrapper:`_inputWrapper_v12qq_24`,inputIcon:`_inputIcon_v12qq_25`,routeInput:`_routeInput_v12qq_23`,swapBtn:`_swapBtn_v12qq_27`,dirBtns:`_dirBtns_v12qq_29`,dirBtn:`_dirBtn_v12qq_29`,openMapsBtn:`_openMapsBtn_v12qq_32`,error:`_error_v12qq_34`,resultCard:`_resultCard_v12qq_36`,routeSummary:`_routeSummary_v12qq_37`,routeDistance:`_routeDistance_v12qq_38`,routeDuration:`_routeDuration_v12qq_39`,routeMode:`_routeMode_v12qq_40`,steps:`_steps_v12qq_41`,step:`_step_v12qq_41`,stepNum:`_stepNum_v12qq_43`,stepText:`_stepText_v12qq_44`,mapLink:`_mapLink_v12qq_45`,askChatBtn:`_askChatBtn_v12qq_47`,savedRoute:`_savedRoute_v12qq_49`,savedFrom:`_savedFrom_v12qq_51`,savedArrow:`_savedArrow_v12qq_52`,savedTo:`_savedTo_v12qq_53`,savedTs:`_savedTs_v12qq_54`},En=[`driving`,`walking`,`bicycling`,`transit`],Dn={driving:`🚗`,walking:`🚶`,bicycling:`🚲`,transit:`🚌`},On=[{label:`🏥 Nearest Hospital`,query:`nearest hospital`},{label:`⛽ Gas Station`,query:`gas station near me`},{label:`🛒 Supermarket`,query:`supermarket near me`},{label:`☕ Coffee Shop`,query:`coffee shop near me`},{label:`🏧 ATM`,query:`ATM near me`},{label:`🍕 Pizza`,query:`pizza restaurant near me`}];function kn(e,t,n){try{let r=JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`),i=[{from:e,to:t,label:n,ts:new Date().toISOString()},...r.filter(n=>!(n.from===e&&n.to===t))].slice(0,10);localStorage.setItem(`nha_maps_routes`,JSON.stringify(i))}catch{}}function An(){try{return JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`)}catch{return[]}}function jn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(`driving`),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(An),[m,h]=(0,_.useState)(``),g=async()=>{if(!(!n.trim()||!i.trim())){l(!0),d(null);try{let e=await O(`/api/maps/directions?from=${encodeURIComponent(n.trim())}&to=${encodeURIComponent(i.trim())}&mode=${o}`);e&&(d(e),e.error||(kn(n.trim(),i.trim()),p(An())))}catch{d({url:`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`}),kn(n.trim(),i.trim()),p(An())}l(!1)}},v=e=>{let t=`https://www.google.com/maps/search/${encodeURIComponent(e)}`;window.open(t,`_blank`)},y=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},b=e=>{r(e.from),a(e.to)},x=n.trim()&&i.trim()?`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`:null;return(0,j.jsxs)(`div`,{className:Q.root,children:[(0,j.jsx)(`div`,{className:Q.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Q.title,children:`🗺️ Maps & Directions`}),(0,j.jsx)(`div`,{className:Q.subtitle,children:e(`maps.directions`)})]})}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:e(`common.search`)}),(0,j.jsx)(`div`,{className:Q.quickBtns,children:On.map(e=>(0,j.jsx)(`button`,{className:Q.quickBtn,onClick:()=>v(e.query),children:e.label},e.label))}),(0,j.jsxs)(`div`,{className:Q.searchRow,children:[(0,j.jsx)(`input`,{className:Q.searchInput,value:m,onChange:e=>h(e.target.value),placeholder:`Search for a place, address, or business…`,onKeyDown:e=>e.key===`Enter`&&v(m)}),(0,j.jsx)(`button`,{className:Q.searchBtn,onClick:()=>v(m),disabled:!m.trim(),children:`Search ↗`})]})]}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Directions`}),(0,j.jsx)(`div`,{className:Q.modeRow,children:En.map(e=>(0,j.jsxs)(`button`,{className:`${Q.modeBtn} ${o===e?Q.modeActive:``}`,onClick:()=>s(e),title:e,children:[Dn[e],` `,e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,j.jsxs)(`div`,{className:Q.routeInputs,children:[(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`A`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:n,onChange:e=>r(e.target.value),placeholder:`From (address, city, or 'my location')`,onKeyDown:e=>e.key===`Enter`&&g()})]}),(0,j.jsx)(`button`,{className:Q.swapBtn,onClick:()=>{r(i),a(n)},title:`Swap`,children:`⇅`}),(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`B`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:i,onChange:e=>a(e.target.value),placeholder:`To (address, city, or landmark)`,onKeyDown:e=>e.key===`Enter`&&g()})]})]}),(0,j.jsxs)(`div`,{className:Q.dirBtns,children:[(0,j.jsx)(`button`,{className:Q.dirBtn,onClick:g,disabled:c||!n.trim()||!i.trim(),children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Getting route…`]}):`🗺️ Get Directions`}),x&&(0,j.jsx)(`a`,{className:Q.openMapsBtn,href:x,target:`_blank`,rel:`noreferrer`,children:`Open in Google Maps ↗`})]})]}),u?.error&&(0,j.jsx)(`div`,{className:Q.error,children:u.error}),u&&!u.error&&(0,j.jsxs)(`div`,{className:Q.resultCard,children:[(u.distance||u.duration)&&(0,j.jsxs)(`div`,{className:Q.routeSummary,children:[u.distance&&(0,j.jsxs)(`span`,{className:Q.routeDistance,children:[`📏 `,u.distance]}),u.duration&&(0,j.jsxs)(`span`,{className:Q.routeDuration,children:[`⏱ `,u.duration]}),(0,j.jsxs)(`span`,{className:Q.routeMode,children:[Dn[o],` `,o]})]}),u.steps&&u.steps.length>0&&(0,j.jsx)(`div`,{className:Q.steps,children:u.steps.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.step,children:[(0,j.jsx)(`span`,{className:Q.stepNum,children:t+1}),(0,j.jsx)(`span`,{className:Q.stepText,children:e})]},t))}),u.url&&(0,j.jsx)(`a`,{className:Q.mapLink,href:u.url,target:`_blank`,rel:`noreferrer`,children:`View full route on Google Maps ↗`}),(0,j.jsx)(`button`,{className:Q.askChatBtn,onClick:()=>y(`Give me directions from "${n}" to "${i}" by ${o}. Include estimated time, distance, and any traffic alerts or alternative routes.`),children:`Ask AI for detailed route advice →`})]}),f.length>0&&(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Recent Routes`}),f.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.savedRoute,onClick:()=>b(e),children:[(0,j.jsx)(`span`,{className:Q.savedFrom,children:e.from}),(0,j.jsx)(`span`,{className:Q.savedArrow,children:`→`}),(0,j.jsx)(`span`,{className:Q.savedTo,children:e.to}),(0,j.jsx)(`span`,{className:Q.savedTs,children:new Date(e.ts).toLocaleDateString()})]},t))]})]})}var $={root:`_root_esnjz_1`,header:`_header_esnjz_3`,title:`_title_esnjz_4`,subtitle:`_subtitle_esnjz_5`,addBtn:`_addBtn_esnjz_6`,quickAdd:`_quickAdd_esnjz_8`,quickLabel:`_quickLabel_esnjz_9`,quickPresets:`_quickPresets_esnjz_10`,quickPreset:`_quickPreset_esnjz_10`,section:`_section_esnjz_14`,sectionTitle:`_sectionTitle_esnjz_15`,loading:`_loading_esnjz_17`,empty:`_empty_esnjz_18`,card:`_card_esnjz_20`,cardPast:`_cardPast_esnjz_21`,cardLeft:`_cardLeft_esnjz_22`,reminderMsg:`_reminderMsg_esnjz_23`,reminderTime:`_reminderTime_esnjz_24`,timeBadge:`_timeBadge_esnjz_25`,countdown:`_countdown_esnjz_26`,timePast:`_timePast_esnjz_27`,sentBadge:`_sentBadge_esnjz_28`,cancelledBadge:`_cancelledBadge_esnjz_29`,cancelBtn:`_cancelBtn_esnjz_30`,repeatBtn:`_repeatBtn_esnjz_31`,aiButtons:`_aiButtons_esnjz_33`,aiBtn:`_aiBtn_esnjz_34`,overlay:`_overlay_esnjz_38`,modal:`_modal_esnjz_39`,modalTitle:`_modalTitle_esnjz_40`,label:`_label_esnjz_41`,input:`_input_esnjz_42`,msgTemplates:`_msgTemplates_esnjz_44`,msgTemplate:`_msgTemplate_esnjz_44`,msgTemplateActive:`_msgTemplateActive_esnjz_47`,typeTabs:`_typeTabs_esnjz_49`,typeTab:`_typeTab_esnjz_49`,typeTabActive:`_typeTabActive_esnjz_51`,relRow:`_relRow_esnjz_53`,inLabel:`_inLabel_esnjz_54`,relInput:`_relInput_esnjz_55`,relSelect:`_relSelect_esnjz_56`,formErr:`_formErr_esnjz_58`,formOk:`_formOk_esnjz_59`,modalBtns:`_modalBtns_esnjz_60`,cancelModalBtn:`_cancelModalBtn_esnjz_61`,saveBtn:`_saveBtn_esnjz_62`},Mn=[{label:`In 5 min`,value:`in 5 minutes`},{label:`In 15 min`,value:`in 15 minutes`},{label:`In 30 min`,value:`in 30 minutes`},{label:`In 1 hour`,value:`in 1 hour`},{label:`In 2 hours`,value:`in 2 hours`},{label:`In 3 hours`,value:`in 3 hours`},{label:`Tomorrow 9am`,value:`tomorrow at 09:00`},{label:`Tomorrow noon`,value:`tomorrow at 12:00`}],Nn=[`Take a break and stretch`,`Check emails`,`Join the standup call`,`Review and respond to messages`,`Take your medication`,`Drink water`,`Focus review — what did you accomplish in the last hour?`,`Follow up on pending tasks`,`End of work day — log your achievements`,`Weekly review — prepare for next week`];function Pn(e){if(e<1)return`now`;if(e<60)return`in ${e}m`;let t=Math.floor(e/60),n=e%60;return n>0?`in ${t}h ${n}m`:`in ${t}h`}function Fn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)({message:``,atTime:``,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`}),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!1),g=()=>{a(!0),O(`/api/reminders`).then(e=>{r(e?.reminders??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{g()},[]);let v=async()=>{if(!o.message.trim()){d(`Message is required`);return}let e=``;if(o.atTimeType===`relative`)e=`in ${o.relValue} ${o.relUnit}`;else{if(!o.atTime){d(`Time is required`);return}e=o.atTime}l(!0),d(``);try{await k(`/api/reminders`,{message:o.message.trim(),atTime:e}),p(`Reminder set!`),setTimeout(()=>{p(``),h(!1)},1500),g()}catch(e){d(e.message??`Failed to set reminder`)}l(!1)},y=e=>{confirm(`Cancel this reminder?`)&&k(`/api/reminders/cancel`,{id:e}).then(g)},b=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},x=n.filter(e=>e.status===`pending`),S=n.filter(e=>e.status!==`pending`);return(0,j.jsxs)(`div`,{className:$.root,children:[(0,j.jsxs)(`div`,{className:$.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:$.title,children:`🔔 Reminders`}),(0,j.jsx)(`div`,{className:$.subtitle,children:`Set one-time notifications via the NHA daemon`})]}),(0,j.jsx)(`button`,{className:$.addBtn,onClick:()=>{h(!0),d(``),p(``)},children:`+ New Reminder`})]}),(0,j.jsxs)(`div`,{className:$.quickAdd,children:[(0,j.jsx)(`div`,{className:$.quickLabel,children:`Quick reminder for now:`}),(0,j.jsx)(`div`,{className:$.quickPresets,children:Mn.map(e=>(0,j.jsx)(`button`,{className:$.quickPreset,onClick:()=>{s(e=>({...e,atTimeType:`relative`,atTime:``,message:e.message||`Reminder`})),h(!0),d(``),p(``)},children:e.label},e.value))})]}),i&&(0,j.jsxs)(`div`,{className:$.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!i&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Pending (`,x.length,`)`]}),x.length===0&&(0,j.jsx)(`div`,{className:$.empty,children:`No pending reminders. Set one to get notified.`}),x.map(e=>(0,j.jsxs)(`div`,{className:$.card,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:$.timeBadge,children:new Date(e.atTime).toLocaleString()}),e.minutesUntil!==void 0&&(0,j.jsx)(`span`,{className:$.countdown,children:Pn(e.minutesUntil)})]})]}),(0,j.jsx)(`button`,{className:$.cancelBtn,onClick:()=>y(e.id),children:`Cancel`})]},e.id))]}),S.length>0&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Recent (`,S.length,`)`]}),S.slice(0,10).map(e=>(0,j.jsxs)(`div`,{className:`${$.card} ${$.cardPast}`,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:e.status===`sent`?$.sentBadge:$.cancelledBadge,children:e.status}),(0,j.jsx)(`span`,{className:$.timePast,children:new Date(e.atTime).toLocaleString()})]})]}),(0,j.jsx)(`button`,{className:$.repeatBtn,onClick:()=>{s(t=>({...t,message:e.message,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`})),h(!0)},children:`Repeat`})]},e.id))]}),(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsx)(`div`,{className:$.sectionTitle,children:`AI-Powered Reminders`}),(0,j.jsxs)(`div`,{className:$.aiButtons,children:[(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder to check my emails in 30 minutes`),children:`📧 Email check in 30min`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder every hour to take a break and drink water`),children:`💧 Hourly water break`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder at the end of the work day (6pm) to do an evening review of my tasks and prepare tomorrow's plan`),children:`🌆 Evening review 6pm`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Look at my calendar and set reminders for all events today`),children:`📅 Remind me of today's events`})]})]}),m&&(0,j.jsx)(`div`,{className:$.overlay,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,j.jsxs)(`div`,{className:$.modal,children:[(0,j.jsx)(`div`,{className:$.modalTitle,children:e(`reminders.new`)}),(0,j.jsx)(`div`,{className:$.label,children:`Message *`}),(0,j.jsx)(`div`,{className:$.msgTemplates,children:Nn.map(e=>(0,j.jsx)(`button`,{className:`${$.msgTemplate} ${o.message===e?$.msgTemplateActive:``}`,onClick:()=>s(t=>({...t,message:e})),children:e},e))}),(0,j.jsx)(`input`,{className:$.input,value:o.message,onChange:e=>s(t=>({...t,message:e.target.value})),placeholder:`Reminder message (e.g. Call John)`}),(0,j.jsx)(`div`,{className:$.label,children:`When *`}),(0,j.jsxs)(`div`,{className:$.typeTabs,children:[(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`relative`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`relative`})),children:`Relative`}),(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`absolute`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`absolute`})),children:`Exact time`})]}),o.atTimeType===`relative`?(0,j.jsxs)(`div`,{className:$.relRow,children:[(0,j.jsx)(`span`,{className:$.inLabel,children:`in`}),(0,j.jsx)(`input`,{className:$.relInput,type:`number`,min:`1`,value:o.relValue,onChange:e=>s(t=>({...t,relValue:e.target.value}))}),(0,j.jsxs)(`select`,{className:$.relSelect,value:o.relUnit,onChange:e=>s(t=>({...t,relUnit:e.target.value})),children:[(0,j.jsx)(`option`,{value:`minutes`,children:`minutes`}),(0,j.jsx)(`option`,{value:`hours`,children:`hours`}),(0,j.jsx)(`option`,{value:`days`,children:`days`})]})]}):(0,j.jsx)(`input`,{className:$.input,type:`datetime-local`,value:o.atTime,onChange:e=>s(t=>({...t,atTime:e.target.value}))}),u&&(0,j.jsx)(`div`,{className:$.formErr,children:u}),f&&(0,j.jsx)(`div`,{className:$.formOk,children:f}),(0,j.jsxs)(`div`,{className:$.modalBtns,children:[(0,j.jsx)(`button`,{className:$.cancelModalBtn,onClick:()=>h(!1),children:`Cancel`}),(0,j.jsx)(`button`,{className:$.saveBtn,onClick:v,disabled:c,children:c?`Setting…`:`🔔 Set Reminder`})]})]})})]})}var In={root:`_root_atgeb_1`,icon:`_icon_atgeb_10`,title:`_title_atgeb_11`,sub:`_sub_atgeb_12`},Ln={dashboard:`⚡`,email:`📧`,calendar:`📅`,tasks:`✅`,contacts:`👤`,notes:`📝`,drive:`💾`,onedrive:`☁️`,mstodo:`📋`,github:`🐙`,slack:`💬`,notion:`📋`,collab:`🏛️`,maps:`🗺️`,cron:`⏰`,screen:`🖥️`,reminders:`🔔`,birthdays:`🎂`,settings:`⚙️`,agents:`🤖`,plan:`🗓️`,webcraft:`🔨`,connectors:`🔗`};function Rn({view:e}){let t=P();return(0,j.jsxs)(`div`,{className:In.root,children:[(0,j.jsx)(`div`,{className:In.icon,children:Ln[e]??`🔧`}),(0,j.jsx)(`div`,{className:In.title,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,j.jsx)(`div`,{className:In.sub,children:t(`common.comingSoon`)})]})}function zn(){let{activeView:e}=ee();switch(e){case`dashboard`:return(0,j.jsx)(mt,{});case`chat`:return(0,j.jsx)(Ce,{});case`studio`:return(0,j.jsx)(lt,{});case`email`:return(0,j.jsx)(Ht,{});case`calendar`:return(0,j.jsx)(Kt,{});case`tasks`:return(0,j.jsx)(gt,{});case`notes`:return(0,j.jsx)(Dt,{});case`contacts`:return(0,j.jsx)(At,{});case`birthdays`:return(0,j.jsx)(xt,{});case`cron`:return(0,j.jsx)(Tt,{});case`connectors`:return(0,j.jsx)(Lt,{});case`agents`:return(0,j.jsx)(Xt,{});case`drive`:return(0,j.jsx)($t,{});case`onedrive`:return(0,j.jsx)(bn,{});case`mstodo`:return(0,j.jsx)(Sn,{});case`github`:return(0,j.jsx)(en,{});case`slack`:return(0,j.jsx)(nn,{});case`notion`:return(0,j.jsx)(rn,{});case`collab`:return(0,j.jsx)(sn,{});case`webcraft`:return(0,j.jsx)(mn,{});case`plan`:return(0,j.jsx)(vn,{});case`screen`:return(0,j.jsx)(Tn,{});case`maps`:return(0,j.jsx)(jn,{});case`reminders`:return(0,j.jsx)(Fn,{});case`settings`:return(0,j.jsx)(yt,{});default:return(0,j.jsx)(Rn,{view:e})}}(0,v.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(_.StrictMode,{children:(0,j.jsx)(de,{children:(0,j.jsx)(zn,{})})}));
701
+ Scrivi le istruzioni in Markdown...`,className:Z.modalContentArea,style:{borderColor:g?`#e05050`:`var(--border2)`}})]})]})}),(0,j.jsxs)(`div`,{className:Z.modalFooter,children:[(0,j.jsx)(`button`,{onClick:r,className:Z.modalCancelBtn,children:`Annulla`}),e.mode!==`view`&&(0,j.jsx)(`button`,{onClick:y,className:Z.modalSaveBtn,children:`✓ Salva`})]})]})})}var _n={root:`_root_x9yvu_1`,loading:`_loading_x9yvu_7`,empty:`_empty_x9yvu_18`,emptyIcon:`_emptyIcon_x9yvu_29`,emptyTitle:`_emptyTitle_x9yvu_30`,emptySub:`_emptySub_x9yvu_31`,generateBtn:`_generateBtn_x9yvu_33`,summary:`_summary_x9yvu_46`,sectionTitle:`_sectionTitle_x9yvu_57`,alertTitle:`_alertTitle_x9yvu_68`,actionCard:`_actionCard_x9yvu_70`,actionTime:`_actionTime_x9yvu_81`,actionText:`_actionText_x9yvu_89`,schedCard:`_schedCard_x9yvu_95`,schedTime:`_schedTime_x9yvu_106`,schedTitle:`_schedTitle_x9yvu_114`,alertCard:`_alertCard_x9yvu_119`,alertSev:`_alertSev_x9yvu_129`,alertAction:`_alertAction_x9yvu_135`,insight:`_insight_x9yvu_141`,regenRow:`_regenRow_x9yvu_148`,regenBtn:`_regenBtn_x9yvu_153`};function vn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=()=>{i(!0),c(!1),O(`/api/plan`).then(e=>{e?.plan?(n(e.plan),c(!1)):(n(null),c(!0)),i(!1)}).catch(()=>{i(!1),c(!0)})},u=async()=>{o(!0),i(!0),n(null);try{await k(`/api/plan/refresh`,{}),l()}catch{i(!1)}finally{o(!1)}};if((0,_.useEffect)(()=>{l()},[]),r)return(0,j.jsxs)(`div`,{className:_n.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),(0,j.jsx)(`div`,{children:a?`Generating plan with 5 agents...`:`Loading plan...`})]});if(s||!t)return(0,j.jsxs)(`div`,{className:_n.empty,children:[(0,j.jsx)(`div`,{className:_n.emptyIcon,children:`🗓️`}),(0,j.jsxs)(`div`,{className:_n.emptyTitle,children:[e(`plan.noplan`),` generated yet`]}),(0,j.jsx)(`div`,{className:_n.emptySub,children:`Generate a daily plan using your calendar, tasks, and emails.`}),(0,j.jsx)(`button`,{className:_n.generateBtn,onClick:u,children:e(`plan.generate`)})]});let d=e=>typeof e==`string`?e:e.description??e.message??e.action_required??`Alert`,f=e=>typeof e==`object`&&e.severity?` [${e.severity.toUpperCase()}]`:``,p=e=>typeof e==`object`&&e.action_required&&e.action_required!==d(e)?e.action_required:``,m=e=>typeof e==`string`?e:e.message??e.insight??``;return(0,j.jsxs)(`div`,{className:_n.root,children:[t.executive_summary&&(0,j.jsx)(`div`,{className:_n.summary,children:t.executive_summary}),t.priority_actions&&t.priority_actions.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Priority Actions`}),t.priority_actions.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.actionCard,children:[e.time&&(0,j.jsx)(`span`,{className:_n.actionTime,children:e.time}),(0,j.jsx)(`span`,{className:_n.actionText,children:e.action})]},t))]}),t.schedule&&t.schedule.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Schedule`}),t.schedule.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.schedCard,children:[(0,j.jsxs)(`span`,{className:_n.schedTime,children:[e.time_start,`–`,e.time_end]}),(0,j.jsx)(`span`,{className:_n.schedTitle,children:e.title})]},t))]}),t.security_alerts&&t.security_alerts.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`${_n.sectionTitle} ${_n.alertTitle}`,children:`Security Alerts`}),t.security_alerts.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.alertCard,children:[(0,j.jsxs)(`span`,{className:_n.alertSev,children:[`!`,f(e)]}),(0,j.jsx)(`span`,{children:d(e)}),p(e)&&(0,j.jsxs)(`div`,{className:_n.alertAction,children:[`Action: `,p(e)]})]},t))]}),t.insights&&t.insights.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:_n.sectionTitle,children:`Insights`}),t.insights.map((e,t)=>(0,j.jsxs)(`div`,{className:_n.insight,children:[`→ `,m(e)]},t))]}),(0,j.jsx)(`div`,{className:_n.regenRow,children:(0,j.jsx)(`button`,{className:_n.regenBtn,onClick:u,disabled:a,children:a?`Regenerating…`:`↺ Regenerate`})})]})}function yn(e){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:e===`sheet`?`📊`:e===`slides`?`📽`:`📄`}function bn(){let e=P(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=(e=``)=>{i(!0),O(e?`/api/onedrive?q=${encodeURIComponent(e)}`:`/api/onedrive`).then(e=>{n(e??{files:[]}),i(!1)}).catch(()=>{o(`Could not load OneDrive. Run nha microsoft auth in the terminal to connect.`),i(!1)})};if((0,_.useEffect)(()=>{l()},[]),a)return(0,j.jsx)(`div`,{className:J.error,children:a});let u=t?.files??[],d=t?.quota;return(0,j.jsxs)(`div`,{className:J.root,children:[d&&(0,j.jsxs)(`div`,{className:J.quotaBar,children:[(0,j.jsxs)(`div`,{className:J.quotaText,children:[(0,j.jsxs)(`span`,{className:J.quotaUsed,children:[d.usage,` of `,d.limit,` used`]}),(0,j.jsxs)(`span`,{className:J.quotaPct,children:[d.percentUsed,`%`]})]}),(0,j.jsx)(`div`,{className:J.quotaTrack,children:(0,j.jsx)(`div`,{className:J.quotaFill,style:{width:`${Math.min(d.percentUsed,100)}%`,background:d.percentUsed>90?`var(--red)`:d.percentUsed>70?`var(--amber)`:`var(--cyan)`}})})]}),(0,j.jsxs)(`div`,{className:J.searchRow,children:[(0,j.jsx)(`input`,{className:J.searchInput,value:s,onChange:e=>c(e.target.value),placeholder:`Search OneDrive files…`,onKeyDown:e=>e.key===`Enter`&&l(s)}),(0,j.jsx)(`button`,{className:J.searchBtn,onClick:()=>l(s),children:`Search`})]}),r&&(0,j.jsxs)(`div`,{className:J.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!r&&u.length===0&&(0,j.jsx)(`div`,{className:J.empty,children:e(`drive.noFiles`)}),(0,j.jsx)(`div`,{className:J.fileList,children:u.map(e=>(0,j.jsxs)(`div`,{className:J.fileRow,children:[(0,j.jsx)(`span`,{className:J.fileIcon,children:yn(e.type)}),(0,j.jsxs)(`div`,{className:J.fileInfo,children:[(0,j.jsx)(`div`,{className:J.fileName,children:e.name}),(0,j.jsxs)(`div`,{className:J.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``]})]}),(0,j.jsx)(`div`,{className:J.fileBtns,children:e.webViewLink&&(0,j.jsx)(`a`,{className:J.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,children:`Open`})})]},e.id))})]})}var xn={root:`_root_1vbmp_1`,loading:`_loading_1vbmp_2`,error:`_error_1vbmp_3`,empty:`_empty_1vbmp_4`,addRow:`_addRow_1vbmp_6`,addInput:`_addInput_1vbmp_7`,addBtn:`_addBtn_1vbmp_8`,list:`_list_1vbmp_10`,taskRow:`_taskRow_1vbmp_11`,checkBtn:`_checkBtn_1vbmp_12`,taskInfo:`_taskInfo_1vbmp_14`,taskTitle:`_taskTitle_1vbmp_15`,taskDue:`_taskDue_1vbmp_16`,taskImp:`_taskImp_1vbmp_17`};function Sn(){let e=P(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),l=()=>{O(`/api/mstodo`).then(e=>{n(e?.tasks??[]),i(!1)}).catch(()=>{o(`Microsoft To Do requires Microsoft authentication. Run nha microsoft auth in the terminal.`),i(!1)})};(0,_.useEffect)(()=>{l()},[]);let u=()=>{let e=s.trim();e&&(c(``),k(`/api/mstodo`,{title:e}).then(e=>{e?.task&&l()}))},d=(e,t)=>{k(`/api/mstodo/${e}/complete`,{listId:t}).then(()=>l())};return r?(0,j.jsxs)(`div`,{className:xn.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,j.jsx)(`div`,{className:xn.error,children:a}):(0,j.jsxs)(`div`,{className:xn.root,children:[(0,j.jsxs)(`div`,{className:xn.addRow,children:[(0,j.jsx)(`input`,{className:xn.addInput,value:s,onChange:e=>c(e.target.value),placeholder:`Add a new task…`,onKeyDown:e=>e.key===`Enter`&&u()}),(0,j.jsx)(`button`,{className:xn.addBtn,onClick:u,children:`+ Add`})]}),t.length===0&&(0,j.jsx)(`div`,{className:xn.empty,children:`No active tasks`}),(0,j.jsx)(`div`,{className:xn.list,children:t.map(e=>{let t=e.importance===`high`?`var(--red)`:e.importance===`low`?`var(--dim)`:`var(--amber)`;return(0,j.jsxs)(`div`,{className:xn.taskRow,children:[(0,j.jsx)(`button`,{className:xn.checkBtn,onClick:()=>d(e.id,e.listId)}),(0,j.jsxs)(`div`,{className:xn.taskInfo,children:[(0,j.jsx)(`div`,{className:xn.taskTitle,children:e.title}),e.dueDate&&(0,j.jsxs)(`div`,{className:xn.taskDue,children:[`Due: `,e.dueDate.split(`T`)[0]]})]}),e.importance&&(0,j.jsx)(`span`,{className:xn.taskImp,style:{color:t},children:e.importance})]},e.id)})})]})}var Cn={root:`_root_1ag4s_1`,header:`_header_1ag4s_3`,title:`_title_1ag4s_4`,subtitle:`_subtitle_1ag4s_5`,controls:`_controls_1ag4s_7`,monitorRow:`_monitorRow_1ag4s_8`,label:`_label_1ag4s_9`,monitorBtn:`_monitorBtn_1ag4s_10`,monitorActive:`_monitorActive_1ag4s_11`,captureBtn:`_captureBtn_1ag4s_12`,analyzeSection:`_analyzeSection_1ag4s_15`,sectionTitle:`_sectionTitle_1ag4s_16`,presets:`_presets_1ag4s_17`,preset:`_preset_1ag4s_17`,presetActive:`_presetActive_1ag4s_20`,questionRow:`_questionRow_1ag4s_21`,questionInput:`_questionInput_1ag4s_22`,analyzeBtn:`_analyzeBtn_1ag4s_23`,error:`_error_1ag4s_26`,screenshotContainer:`_screenshotContainer_1ag4s_28`,screenshot:`_screenshot_1ag4s_28`,screenshotMeta:`_screenshotMeta_1ag4s_30`,analysis:`_analysis_1ag4s_32`,analysisTitle:`_analysisTitle_1ag4s_33`,analysisText:`_analysisText_1ag4s_34`,continueInChat:`_continueInChat_1ag4s_35`,history:`_history_1ag4s_37`,historyGrid:`_historyGrid_1ag4s_38`,historyItem:`_historyItem_1ag4s_39`,historyThumb:`_historyThumb_1ag4s_40`,historyMeta:`_historyMeta_1ag4s_41`,historyTs:`_historyTs_1ag4s_42`,historyQ:`_historyQ_1ag4s_43`,historyA:`_historyA_1ag4s_44`},wn=[`Describe exactly what you see on the screen`,`Identify any errors, warnings, or issues visible`,`What application is open and what is the user doing?`,`Summarize the content visible on screen and suggest next actions`,`Read and extract all visible text from the screen`,`Analyze the code visible on screen and identify bugs or improvements`,`What financial data or charts are visible? Summarize key numbers`,`Is there anything sensitive or that should be kept private?`];function Tn(){let e=P(),t=ee(e=>e.setView),n=ee(e=>e.apiBase),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)([]),h=async()=>{i(!0),c(null);try{let e=await k(`/api/screen/capture`,{monitor:d});c(e),(e?.base64||e?.file)&&m(t=>[{ts:new Date().toLocaleTimeString(),question:`Screenshot`,analysis:``,src:e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:`${n}/api/screenshots/${e.file}`},...t.slice(0,9)])}catch(e){c({error:e.message})}i(!1)},g=async()=>{if(l.trim()){o(!0);try{let e=await k(`/api/screen/analyze`,{question:l.trim(),monitor:d});if(c(e),e?.analysis){let t=e.base64?`data:image/${e.format??`jpeg`};base64,${e.base64}`:e.file?`${n}/api/screenshots/${e.file}`:``;m(n=>[{ts:new Date().toLocaleTimeString(),question:l.trim(),analysis:e.analysis??``,src:t},...n.slice(0,9)])}}catch(e){c({error:e.message})}o(!1)}},v=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},y=s?.base64?`data:image/${s.format??`jpeg`};base64,${s.base64}`:s?.file?`${n}/api/screenshots/${s.file}`:null;return(0,j.jsxs)(`div`,{className:Cn.root,children:[(0,j.jsx)(`div`,{className:Cn.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Cn.title,children:`🖥️ Screen Capture`}),(0,j.jsxs)(`div`,{className:Cn.subtitle,children:[e(`screen.capture`),` and analyze your desktop screen with AI vision`]})]})}),(0,j.jsxs)(`div`,{className:Cn.controls,children:[(0,j.jsxs)(`div`,{className:Cn.monitorRow,children:[(0,j.jsx)(`label`,{className:Cn.label,children:`Monitor`}),[1,2,3].map(e=>(0,j.jsxs)(`button`,{className:`${Cn.monitorBtn} ${d===e?Cn.monitorActive:``}`,onClick:()=>f(e),children:[`Monitor `,e]},e))]}),(0,j.jsx)(`button`,{className:Cn.captureBtn,onClick:h,disabled:r||a,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Capturing…`]}):`📷 Capture Screen`})]}),(0,j.jsxs)(`div`,{className:Cn.analyzeSection,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Capture + Analyze`}),(0,j.jsx)(`div`,{className:Cn.presets,children:wn.map(e=>(0,j.jsxs)(`button`,{className:`${Cn.preset} ${l===e?Cn.presetActive:``}`,onClick:()=>u(e),children:[e.slice(0,50),e.length>50?`…`:``]},e))}),(0,j.jsxs)(`div`,{className:Cn.questionRow,children:[(0,j.jsx)(`input`,{className:Cn.questionInput,value:l,onChange:e=>u(e.target.value),placeholder:`Ask something about your screen…`,onKeyDown:e=>e.key===`Enter`&&g()}),(0,j.jsx)(`button`,{className:Cn.analyzeBtn,onClick:g,disabled:!l.trim()||r||a,children:a?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Analyzing…`]}):`🔍 Analyze`})]})]}),s?.error&&(0,j.jsx)(`div`,{className:Cn.error,children:s.error}),y&&(0,j.jsxs)(`div`,{className:Cn.screenshotContainer,children:[(0,j.jsx)(`img`,{src:y,className:Cn.screenshot,alt:`Screen capture`}),s?.width&&s?.height&&(0,j.jsxs)(`div`,{className:Cn.screenshotMeta,children:[s.width,` × `,s.height,`px`]})]}),s?.analysis&&(0,j.jsxs)(`div`,{className:Cn.analysis,children:[(0,j.jsx)(`div`,{className:Cn.analysisTitle,children:`AI Analysis`}),(0,j.jsx)(`div`,{className:Cn.analysisText,children:s.analysis}),(0,j.jsx)(`button`,{className:Cn.continueInChat,onClick:()=>v(`I captured my screen. Here's what the AI saw:\n\n${s.analysis}\n\nCan you help me with this?`),children:`Continue in Chat →`})]}),p.length>0&&(0,j.jsxs)(`div`,{className:Cn.history,children:[(0,j.jsx)(`div`,{className:Cn.sectionTitle,children:`Recent Captures`}),(0,j.jsx)(`div`,{className:Cn.historyGrid,children:p.map((e,t)=>(0,j.jsxs)(`div`,{className:Cn.historyItem,children:[e.src&&(0,j.jsx)(`img`,{src:e.src,className:Cn.historyThumb,alt:e.question}),(0,j.jsxs)(`div`,{className:Cn.historyMeta,children:[(0,j.jsx)(`div`,{className:Cn.historyTs,children:e.ts}),(0,j.jsx)(`div`,{className:Cn.historyQ,children:e.question}),e.analysis&&(0,j.jsxs)(`div`,{className:Cn.historyA,children:[e.analysis.slice(0,120),`…`]})]})]},t))})]})]})}var Q={root:`_root_v12qq_1`,header:`_header_v12qq_3`,title:`_title_v12qq_4`,subtitle:`_subtitle_v12qq_5`,section:`_section_v12qq_7`,sectionTitle:`_sectionTitle_v12qq_8`,quickBtns:`_quickBtns_v12qq_10`,quickBtn:`_quickBtn_v12qq_10`,searchRow:`_searchRow_v12qq_14`,searchInput:`_searchInput_v12qq_15`,searchBtn:`_searchBtn_v12qq_16`,modeRow:`_modeRow_v12qq_19`,modeBtn:`_modeBtn_v12qq_20`,modeActive:`_modeActive_v12qq_21`,routeInputs:`_routeInputs_v12qq_23`,inputWrapper:`_inputWrapper_v12qq_24`,inputIcon:`_inputIcon_v12qq_25`,routeInput:`_routeInput_v12qq_23`,swapBtn:`_swapBtn_v12qq_27`,dirBtns:`_dirBtns_v12qq_29`,dirBtn:`_dirBtn_v12qq_29`,openMapsBtn:`_openMapsBtn_v12qq_32`,error:`_error_v12qq_34`,resultCard:`_resultCard_v12qq_36`,routeSummary:`_routeSummary_v12qq_37`,routeDistance:`_routeDistance_v12qq_38`,routeDuration:`_routeDuration_v12qq_39`,routeMode:`_routeMode_v12qq_40`,steps:`_steps_v12qq_41`,step:`_step_v12qq_41`,stepNum:`_stepNum_v12qq_43`,stepText:`_stepText_v12qq_44`,mapLink:`_mapLink_v12qq_45`,askChatBtn:`_askChatBtn_v12qq_47`,savedRoute:`_savedRoute_v12qq_49`,savedFrom:`_savedFrom_v12qq_51`,savedArrow:`_savedArrow_v12qq_52`,savedTo:`_savedTo_v12qq_53`,savedTs:`_savedTs_v12qq_54`},En=[`driving`,`walking`,`bicycling`,`transit`],Dn={driving:`🚗`,walking:`🚶`,bicycling:`🚲`,transit:`🚌`},On=[{label:`🏥 Nearest Hospital`,query:`nearest hospital`},{label:`⛽ Gas Station`,query:`gas station near me`},{label:`🛒 Supermarket`,query:`supermarket near me`},{label:`☕ Coffee Shop`,query:`coffee shop near me`},{label:`🏧 ATM`,query:`ATM near me`},{label:`🍕 Pizza`,query:`pizza restaurant near me`}];function kn(e,t,n){try{let r=JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`),i=[{from:e,to:t,label:n,ts:new Date().toISOString()},...r.filter(n=>!(n.from===e&&n.to===t))].slice(0,10);localStorage.setItem(`nha_maps_routes`,JSON.stringify(i))}catch{}}function An(){try{return JSON.parse(localStorage.getItem(`nha_maps_routes`)??`[]`)}catch{return[]}}function jn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(`driving`),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(An),[m,h]=(0,_.useState)(``),g=async()=>{if(!(!n.trim()||!i.trim())){l(!0),d(null);try{let e=await O(`/api/maps/directions?from=${encodeURIComponent(n.trim())}&to=${encodeURIComponent(i.trim())}&mode=${o}`);e&&(d(e),e.error||(kn(n.trim(),i.trim()),p(An())))}catch{d({url:`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`}),kn(n.trim(),i.trim()),p(An())}l(!1)}},v=e=>{let t=`https://www.google.com/maps/search/${encodeURIComponent(e)}`;window.open(t,`_blank`)},y=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},b=e=>{r(e.from),a(e.to)},x=n.trim()&&i.trim()?`https://www.google.com/maps/dir/${encodeURIComponent(n.trim())}/${encodeURIComponent(i.trim())}/?travelmode=${o}`:null;return(0,j.jsxs)(`div`,{className:Q.root,children:[(0,j.jsx)(`div`,{className:Q.header,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:Q.title,children:`🗺️ Maps & Directions`}),(0,j.jsx)(`div`,{className:Q.subtitle,children:e(`maps.directions`)})]})}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:e(`common.search`)}),(0,j.jsx)(`div`,{className:Q.quickBtns,children:On.map(e=>(0,j.jsx)(`button`,{className:Q.quickBtn,onClick:()=>v(e.query),children:e.label},e.label))}),(0,j.jsxs)(`div`,{className:Q.searchRow,children:[(0,j.jsx)(`input`,{className:Q.searchInput,value:m,onChange:e=>h(e.target.value),placeholder:`Search for a place, address, or business…`,onKeyDown:e=>e.key===`Enter`&&v(m)}),(0,j.jsx)(`button`,{className:Q.searchBtn,onClick:()=>v(m),disabled:!m.trim(),children:`Search ↗`})]})]}),(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Directions`}),(0,j.jsx)(`div`,{className:Q.modeRow,children:En.map(e=>(0,j.jsxs)(`button`,{className:`${Q.modeBtn} ${o===e?Q.modeActive:``}`,onClick:()=>s(e),title:e,children:[Dn[e],` `,e.charAt(0).toUpperCase()+e.slice(1)]},e))}),(0,j.jsxs)(`div`,{className:Q.routeInputs,children:[(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`A`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:n,onChange:e=>r(e.target.value),placeholder:`From (address, city, or 'my location')`,onKeyDown:e=>e.key===`Enter`&&g()})]}),(0,j.jsx)(`button`,{className:Q.swapBtn,onClick:()=>{r(i),a(n)},title:`Swap`,children:`⇅`}),(0,j.jsxs)(`div`,{className:Q.inputWrapper,children:[(0,j.jsx)(`span`,{className:Q.inputIcon,children:`B`}),(0,j.jsx)(`input`,{className:Q.routeInput,value:i,onChange:e=>a(e.target.value),placeholder:`To (address, city, or landmark)`,onKeyDown:e=>e.key===`Enter`&&g()})]})]}),(0,j.jsxs)(`div`,{className:Q.dirBtns,children:[(0,j.jsx)(`button`,{className:Q.dirBtn,onClick:g,disabled:c||!n.trim()||!i.trim(),children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`spinner`}),` Getting route…`]}):`🗺️ Get Directions`}),x&&(0,j.jsx)(`a`,{className:Q.openMapsBtn,href:x,target:`_blank`,rel:`noreferrer`,children:`Open in Google Maps ↗`})]})]}),u?.error&&(0,j.jsx)(`div`,{className:Q.error,children:u.error}),u&&!u.error&&(0,j.jsxs)(`div`,{className:Q.resultCard,children:[(u.distance||u.duration)&&(0,j.jsxs)(`div`,{className:Q.routeSummary,children:[u.distance&&(0,j.jsxs)(`span`,{className:Q.routeDistance,children:[`📏 `,u.distance]}),u.duration&&(0,j.jsxs)(`span`,{className:Q.routeDuration,children:[`⏱ `,u.duration]}),(0,j.jsxs)(`span`,{className:Q.routeMode,children:[Dn[o],` `,o]})]}),u.steps&&u.steps.length>0&&(0,j.jsx)(`div`,{className:Q.steps,children:u.steps.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.step,children:[(0,j.jsx)(`span`,{className:Q.stepNum,children:t+1}),(0,j.jsx)(`span`,{className:Q.stepText,children:e})]},t))}),u.url&&(0,j.jsx)(`a`,{className:Q.mapLink,href:u.url,target:`_blank`,rel:`noreferrer`,children:`View full route on Google Maps ↗`}),(0,j.jsx)(`button`,{className:Q.askChatBtn,onClick:()=>y(`Give me directions from "${n}" to "${i}" by ${o}. Include estimated time, distance, and any traffic alerts or alternative routes.`),children:`Ask AI for detailed route advice →`})]}),f.length>0&&(0,j.jsxs)(`div`,{className:Q.section,children:[(0,j.jsx)(`div`,{className:Q.sectionTitle,children:`Recent Routes`}),f.map((e,t)=>(0,j.jsxs)(`div`,{className:Q.savedRoute,onClick:()=>b(e),children:[(0,j.jsx)(`span`,{className:Q.savedFrom,children:e.from}),(0,j.jsx)(`span`,{className:Q.savedArrow,children:`→`}),(0,j.jsx)(`span`,{className:Q.savedTo,children:e.to}),(0,j.jsx)(`span`,{className:Q.savedTs,children:new Date(e.ts).toLocaleDateString()})]},t))]})]})}var $={root:`_root_esnjz_1`,header:`_header_esnjz_3`,title:`_title_esnjz_4`,subtitle:`_subtitle_esnjz_5`,addBtn:`_addBtn_esnjz_6`,quickAdd:`_quickAdd_esnjz_8`,quickLabel:`_quickLabel_esnjz_9`,quickPresets:`_quickPresets_esnjz_10`,quickPreset:`_quickPreset_esnjz_10`,section:`_section_esnjz_14`,sectionTitle:`_sectionTitle_esnjz_15`,loading:`_loading_esnjz_17`,empty:`_empty_esnjz_18`,card:`_card_esnjz_20`,cardPast:`_cardPast_esnjz_21`,cardLeft:`_cardLeft_esnjz_22`,reminderMsg:`_reminderMsg_esnjz_23`,reminderTime:`_reminderTime_esnjz_24`,timeBadge:`_timeBadge_esnjz_25`,countdown:`_countdown_esnjz_26`,timePast:`_timePast_esnjz_27`,sentBadge:`_sentBadge_esnjz_28`,cancelledBadge:`_cancelledBadge_esnjz_29`,cancelBtn:`_cancelBtn_esnjz_30`,repeatBtn:`_repeatBtn_esnjz_31`,aiButtons:`_aiButtons_esnjz_33`,aiBtn:`_aiBtn_esnjz_34`,overlay:`_overlay_esnjz_38`,modal:`_modal_esnjz_39`,modalTitle:`_modalTitle_esnjz_40`,label:`_label_esnjz_41`,input:`_input_esnjz_42`,msgTemplates:`_msgTemplates_esnjz_44`,msgTemplate:`_msgTemplate_esnjz_44`,msgTemplateActive:`_msgTemplateActive_esnjz_47`,typeTabs:`_typeTabs_esnjz_49`,typeTab:`_typeTab_esnjz_49`,typeTabActive:`_typeTabActive_esnjz_51`,relRow:`_relRow_esnjz_53`,inLabel:`_inLabel_esnjz_54`,relInput:`_relInput_esnjz_55`,relSelect:`_relSelect_esnjz_56`,formErr:`_formErr_esnjz_58`,formOk:`_formOk_esnjz_59`,modalBtns:`_modalBtns_esnjz_60`,cancelModalBtn:`_cancelModalBtn_esnjz_61`,saveBtn:`_saveBtn_esnjz_62`},Mn=[{label:`In 5 min`,value:`in 5 minutes`},{label:`In 15 min`,value:`in 15 minutes`},{label:`In 30 min`,value:`in 30 minutes`},{label:`In 1 hour`,value:`in 1 hour`},{label:`In 2 hours`,value:`in 2 hours`},{label:`In 3 hours`,value:`in 3 hours`},{label:`Tomorrow 9am`,value:`tomorrow at 09:00`},{label:`Tomorrow noon`,value:`tomorrow at 12:00`}],Nn=[`Take a break and stretch`,`Check emails`,`Join the standup call`,`Review and respond to messages`,`Take your medication`,`Drink water`,`Focus review — what did you accomplish in the last hour?`,`Follow up on pending tasks`,`End of work day — log your achievements`,`Weekly review — prepare for next week`];function Pn(e){if(e<1)return`now`;if(e<60)return`in ${e}m`;let t=Math.floor(e/60),n=e%60;return n>0?`in ${t}h ${n}m`:`in ${t}h`}function Fn(){let e=P(),t=ee(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)({message:``,atTime:``,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`}),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!1),g=()=>{a(!0),O(`/api/reminders`).then(e=>{r(e?.reminders??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{g()},[]);let v=async()=>{if(!o.message.trim()){d(`Message is required`);return}let e=``;if(o.atTimeType===`relative`)e=`in ${o.relValue} ${o.relUnit}`;else{if(!o.atTime){d(`Time is required`);return}e=o.atTime}l(!0),d(``);try{await k(`/api/reminders`,{message:o.message.trim(),atTime:e}),p(`Reminder set!`),setTimeout(()=>{p(``),h(!1)},1500),g()}catch(e){d(e.message??`Failed to set reminder`)}l(!1)},y=e=>{confirm(`Cancel this reminder?`)&&k(`/api/reminders/cancel`,{id:e}).then(g)},b=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},x=n.filter(e=>e.status===`pending`),S=n.filter(e=>e.status!==`pending`);return(0,j.jsxs)(`div`,{className:$.root,children:[(0,j.jsxs)(`div`,{className:$.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:$.title,children:`🔔 Reminders`}),(0,j.jsx)(`div`,{className:$.subtitle,children:`Set one-time notifications via the NHA daemon`})]}),(0,j.jsx)(`button`,{className:$.addBtn,onClick:()=>{h(!0),d(``),p(``)},children:`+ New Reminder`})]}),(0,j.jsxs)(`div`,{className:$.quickAdd,children:[(0,j.jsx)(`div`,{className:$.quickLabel,children:`Quick reminder for now:`}),(0,j.jsx)(`div`,{className:$.quickPresets,children:Mn.map(e=>(0,j.jsx)(`button`,{className:$.quickPreset,onClick:()=>{s(e=>({...e,atTimeType:`relative`,atTime:``,message:e.message||`Reminder`})),h(!0),d(``),p(``)},children:e.label},e.value))})]}),i&&(0,j.jsxs)(`div`,{className:$.loading,children:[(0,j.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}),!i&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Pending (`,x.length,`)`]}),x.length===0&&(0,j.jsx)(`div`,{className:$.empty,children:`No pending reminders. Set one to get notified.`}),x.map(e=>(0,j.jsxs)(`div`,{className:$.card,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:$.timeBadge,children:new Date(e.atTime).toLocaleString()}),e.minutesUntil!==void 0&&(0,j.jsx)(`span`,{className:$.countdown,children:Pn(e.minutesUntil)})]})]}),(0,j.jsx)(`button`,{className:$.cancelBtn,onClick:()=>y(e.id),children:`Cancel`})]},e.id))]}),S.length>0&&(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsxs)(`div`,{className:$.sectionTitle,children:[`Recent (`,S.length,`)`]}),S.slice(0,10).map(e=>(0,j.jsxs)(`div`,{className:`${$.card} ${$.cardPast}`,children:[(0,j.jsxs)(`div`,{className:$.cardLeft,children:[(0,j.jsx)(`div`,{className:$.reminderMsg,children:e.message}),(0,j.jsxs)(`div`,{className:$.reminderTime,children:[(0,j.jsx)(`span`,{className:e.status===`sent`?$.sentBadge:$.cancelledBadge,children:e.status}),(0,j.jsx)(`span`,{className:$.timePast,children:new Date(e.atTime).toLocaleString()})]})]}),(0,j.jsx)(`button`,{className:$.repeatBtn,onClick:()=>{s(t=>({...t,message:e.message,atTimeType:`relative`,relValue:`30`,relUnit:`minutes`})),h(!0)},children:`Repeat`})]},e.id))]}),(0,j.jsxs)(`div`,{className:$.section,children:[(0,j.jsx)(`div`,{className:$.sectionTitle,children:`AI-Powered Reminders`}),(0,j.jsxs)(`div`,{className:$.aiButtons,children:[(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder to check my emails in 30 minutes`),children:`📧 Email check in 30min`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder every hour to take a break and drink water`),children:`💧 Hourly water break`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Set a reminder at the end of the work day (6pm) to do an evening review of my tasks and prepare tomorrow's plan`),children:`🌆 Evening review 6pm`}),(0,j.jsx)(`button`,{className:$.aiBtn,onClick:()=>b(`Look at my calendar and set reminders for all events today`),children:`📅 Remind me of today's events`})]})]}),m&&(0,j.jsx)(`div`,{className:$.overlay,onClick:e=>{e.target===e.currentTarget&&h(!1)},children:(0,j.jsxs)(`div`,{className:$.modal,children:[(0,j.jsx)(`div`,{className:$.modalTitle,children:e(`reminders.new`)}),(0,j.jsx)(`div`,{className:$.label,children:`Message *`}),(0,j.jsx)(`div`,{className:$.msgTemplates,children:Nn.map(e=>(0,j.jsx)(`button`,{className:`${$.msgTemplate} ${o.message===e?$.msgTemplateActive:``}`,onClick:()=>s(t=>({...t,message:e})),children:e},e))}),(0,j.jsx)(`input`,{className:$.input,value:o.message,onChange:e=>s(t=>({...t,message:e.target.value})),placeholder:`Reminder message (e.g. Call John)`}),(0,j.jsx)(`div`,{className:$.label,children:`When *`}),(0,j.jsxs)(`div`,{className:$.typeTabs,children:[(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`relative`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`relative`})),children:`Relative`}),(0,j.jsx)(`button`,{className:`${$.typeTab} ${o.atTimeType===`absolute`?$.typeTabActive:``}`,onClick:()=>s(e=>({...e,atTimeType:`absolute`})),children:`Exact time`})]}),o.atTimeType===`relative`?(0,j.jsxs)(`div`,{className:$.relRow,children:[(0,j.jsx)(`span`,{className:$.inLabel,children:`in`}),(0,j.jsx)(`input`,{className:$.relInput,type:`number`,min:`1`,value:o.relValue,onChange:e=>s(t=>({...t,relValue:e.target.value}))}),(0,j.jsxs)(`select`,{className:$.relSelect,value:o.relUnit,onChange:e=>s(t=>({...t,relUnit:e.target.value})),children:[(0,j.jsx)(`option`,{value:`minutes`,children:`minutes`}),(0,j.jsx)(`option`,{value:`hours`,children:`hours`}),(0,j.jsx)(`option`,{value:`days`,children:`days`})]})]}):(0,j.jsx)(`input`,{className:$.input,type:`datetime-local`,value:o.atTime,onChange:e=>s(t=>({...t,atTime:e.target.value}))}),u&&(0,j.jsx)(`div`,{className:$.formErr,children:u}),f&&(0,j.jsx)(`div`,{className:$.formOk,children:f}),(0,j.jsxs)(`div`,{className:$.modalBtns,children:[(0,j.jsx)(`button`,{className:$.cancelModalBtn,onClick:()=>h(!1),children:`Cancel`}),(0,j.jsx)(`button`,{className:$.saveBtn,onClick:v,disabled:c,children:c?`Setting…`:`🔔 Set Reminder`})]})]})})]})}var In={root:`_root_atgeb_1`,icon:`_icon_atgeb_10`,title:`_title_atgeb_11`,sub:`_sub_atgeb_12`},Ln={dashboard:`⚡`,email:`📧`,calendar:`📅`,tasks:`✅`,contacts:`👤`,notes:`📝`,drive:`💾`,onedrive:`☁️`,mstodo:`📋`,github:`🐙`,slack:`💬`,notion:`📋`,collab:`🏛️`,maps:`🗺️`,cron:`⏰`,screen:`🖥️`,reminders:`🔔`,birthdays:`🎂`,settings:`⚙️`,agents:`🤖`,plan:`🗓️`,webcraft:`🔨`,connectors:`🔗`};function Rn({view:e}){let t=P();return(0,j.jsxs)(`div`,{className:In.root,children:[(0,j.jsx)(`div`,{className:In.icon,children:Ln[e]??`🔧`}),(0,j.jsx)(`div`,{className:In.title,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,j.jsx)(`div`,{className:In.sub,children:t(`common.comingSoon`)})]})}function zn({activeView:e}){switch(e){case`dashboard`:return(0,j.jsx)(mt,{});case`chat`:return(0,j.jsx)(Ce,{});case`email`:return(0,j.jsx)(Ht,{});case`calendar`:return(0,j.jsx)(Kt,{});case`tasks`:return(0,j.jsx)(gt,{});case`notes`:return(0,j.jsx)(Dt,{});case`contacts`:return(0,j.jsx)(At,{});case`birthdays`:return(0,j.jsx)(xt,{});case`cron`:return(0,j.jsx)(Tt,{});case`connectors`:return(0,j.jsx)(Lt,{});case`agents`:return(0,j.jsx)(Xt,{});case`drive`:return(0,j.jsx)($t,{});case`onedrive`:return(0,j.jsx)(bn,{});case`mstodo`:return(0,j.jsx)(Sn,{});case`github`:return(0,j.jsx)(en,{});case`slack`:return(0,j.jsx)(nn,{});case`notion`:return(0,j.jsx)(rn,{});case`collab`:return(0,j.jsx)(sn,{});case`plan`:return(0,j.jsx)(vn,{});case`screen`:return(0,j.jsx)(Tn,{});case`maps`:return(0,j.jsx)(jn,{});case`reminders`:return(0,j.jsx)(Fn,{});case`settings`:return(0,j.jsx)(yt,{});default:return(0,j.jsx)(Rn,{view:e})}}function Bn(){let{activeView:e}=ee();return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{style:{display:e===`studio`?`contents`:`none`},children:(0,j.jsx)(lt,{})}),(0,j.jsx)(`div`,{style:{display:e===`webcraft`?`contents`:`none`},children:(0,j.jsx)(mn,{})}),e!==`studio`&&e!==`webcraft`&&(0,j.jsx)(zn,{activeView:e})]})}(0,v.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(_.StrictMode,{children:(0,j.jsx)(de,{children:(0,j.jsx)(Bn,{})})}));
@@ -8,7 +8,7 @@
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-B4-XJhib.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-BPc0ZESP.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-UUUprsdb.css">
13
13
  </head>
14
14
  <body>