nothumanallowed 14.1.0 → 14.1.1
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 +1 -1
- package/src/constants.mjs +1 -1
- package/src/server/routes/agents.mjs +4 -2
- package/src/server/routes/chat.mjs +7 -0
- package/src/server/routes/integrations.mjs +1 -1
- package/src/ui-dist/assets/{index-CZpajDT6.js → index-BPsbkaS3.js} +2 -2
- package/src/ui-dist/assets/index-DIc0EPV0.css +1 -0
- package/src/ui-dist/index.html +2 -2
- package/src/ui-dist/assets/index-DomqCxPY.css +0 -1
|
@@ -11,7 +11,7 @@ Error generating stack: `+e.message+`
|
|
|
11
11
|
`),n=``,r=!1,i=!1,a=!1,o=!1,s=!1,c=``;function l(){r&&=(n+=`</ul>`,!1),i&&=(n+=`</ol>`,!1),o&&=(s&&=(n+=`</tbody>`,!1),n+=`</table>`,!1)}function u(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function d(e){return e=u(e),e=e.replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`),e=e.replace(/\*([^*]+)\*/g,`<em>$1</em>`),e=e.replace(/~~([^~]+)~~/g,`<del>$1</del>`),e=e.replace(/`([^`]+)`/g,`<code>$1</code>`),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,`<a href="$2" target="_blank" rel="noopener">$1</a>`),e}for(let e=0;e<t.length;e++){let f=t[e],p=f.trim();if(p.startsWith("```")){if(a)n+=u(c)+`</code></pre>`,a=!1,c=``;else{l(),a=!0,c=``;let e=p.slice(3).trim();n+=`<pre><code${e?` class="language-${u(e)}"`:``}>`}continue}if(a){c+=f+`
|
|
12
12
|
`;continue}if(p.startsWith(`#### `)){l(),n+=`<h4>${d(p.slice(5))}</h4>`;continue}if(p.startsWith(`### `)){l(),n+=`<h3>${d(p.slice(4))}</h3>`;continue}if(p.startsWith(`## `)){l(),n+=`<h2>${d(p.slice(3))}</h2>`;continue}if(p.startsWith(`# `)){l(),n+=`<h1>${d(p.slice(2))}</h1>`;continue}if(/^---+$/.test(p)){l(),n+=`<hr>`;continue}if(p.charAt(0)===`|`&&p.lastIndexOf(`|`)>0){if(/^\|[\s\-|:]+\|$/.test(p)){o&&(n+=`</thead><tbody>`,s=!0);continue}let r=p.split(`|`).slice(1,-1).map(e=>d(e.trim())),i=t[e+1]?.trim()??``,a=/^\|[\s\-|:]+\|$/.test(i);o||(n+=`<table>`,o=!0,a?(n+=`<thead>`,s=!1):(n+=`<tbody>`,s=!0));let c=s?`td`:`th`;n+=`<tr>`+r.map(e=>`<${c}>${e}</${c}>`).join(``)+`</tr>`;continue}if(o&&=(s&&=(n+=`</tbody>`,!1),n+=`</table>`,!1),/^[-*] /.test(p)){i&&=(n+=`</ol>`,!1),r||=(n+=`<ul>`,!0),n+=`<li>${d(p.slice(2))}</li>`;continue}let m=p.match(/^(\d+)\. (.+)/);if(m){r&&=(n+=`</ul>`,!1),i||=(n+=`<ol>`,!0),n+=`<li>${d(m[2])}</li>`;continue}if(r&&=(n+=`</ul>`,!1),i&&=(n+=`</ol>`,!1),p===``){n+=`<div style="height:6px"></div>`;continue}n+=`<p>${d(p)}</p>`}return l(),n}var L={root:`_root_npowj_1`,convSidebar:`_convSidebar_npowj_8`,convSidebarHeader:`_convSidebarHeader_npowj_18`,newConvBtn:`_newConvBtn_npowj_23`,convList:`_convList_npowj_36`,convItem:`_convItem_npowj_41`,convItemActive:`_convItemActive_npowj_48`,convTitle:`_convTitle_npowj_53`,convMeta:`_convMeta_npowj_61`,convDelete:`_convDelete_npowj_69`,chatMain:`_chatMain_npowj_76`,chatToolbar:`_chatToolbar_npowj_85`,convTitleBar:`_convTitleBar_npowj_94`,toolbarBtn:`_toolbarBtn_npowj_103`,toolbarBtnDim:`_toolbarBtnDim_npowj_116`,toolbarBtnCanvas:`_toolbarBtnCanvas_npowj_128`,messages:`_messages_npowj_137`,empty:`_empty_npowj_146`,emptyIcon:`_emptyIcon_npowj_158`,emptyTitle:`_emptyTitle_npowj_159`,emptySub:`_emptySub_npowj_160`,emptyHint:`_emptyHint_npowj_161`,suggGroups:`_suggGroups_npowj_163`,suggGroup:`_suggGroup_npowj_163`,suggGroupTitle:`_suggGroupTitle_npowj_165`,suggBtns:`_suggBtns_npowj_166`,suggBtn:`_suggBtn_npowj_166`,message:`_message_npowj_137`,user:`_user_npowj_178`,assistant:`_assistant_npowj_179`,msgLabel:`_msgLabel_npowj_181`,bubble:`_bubble_npowj_188`,sentinelBubble:`_sentinelBubble_npowj_211`,cursor:`_cursor_npowj_216`,blink:`_blink_npowj_1`,msgActions:`_msgActions_npowj_231`,msgActionBtn:`_msgActionBtn_npowj_240`,editBox:`_editBox_npowj_252`,editInput:`_editInput_npowj_259`,editActions:`_editActions_npowj_272`,editSaveBtn:`_editSaveBtn_npowj_273`,editCancelBtn:`_editCancelBtn_npowj_277`,toolActivity:`_toolActivity_npowj_284`,toolActivityItem:`_toolActivityItem_npowj_290`,active:`_active_npowj_303`,toolPulse:`_toolPulse_npowj_1`,done:`_done_npowj_308`,error:`_error_npowj_309`,thinkingIndicator:`_thinkingIndicator_npowj_317`,thinkingDots:`_thinkingDots_npowj_331`,thinkingDot:`_thinkingDot_npowj_331`,thinkBounce:`_thinkBounce_npowj_1`,attachBar:`_attachBar_npowj_349`,attachClear:`_attachClear_npowj_360`,inputBar:`_inputBar_npowj_371`,inputTools:`_inputTools_npowj_381`,iconBtn:`_iconBtn_npowj_387`,iconBtnActive:`_iconBtnActive_npowj_398`,thinkBtn:`_thinkBtn_npowj_400`,thinkBtnOn:`_thinkBtnOn_npowj_412`,inputRow:`_inputRow_npowj_417`,input:`_input_npowj_371`,btn:`_btn_npowj_436`,send:`_send_npowj_447`,stop:`_stop_npowj_454`,canvasPanel:`_canvasPanel_npowj_461`,canvasPanelHeader:`_canvasPanelHeader_npowj_476`,canvasPanelActions:`_canvasPanelActions_npowj_488`,canvasPanelBtn:`_canvasPanelBtn_npowj_494`,canvasPanelClose:`_canvasPanelClose_npowj_505`,canvasFrame:`_canvasFrame_npowj_516`},fe={body:`_body_ctbrf_4`,mdCursorBlink:`_mdCursorBlink_ctbrf_1`,compact:`_compact_ctbrf_197`};function pe(e){let t=e.replace(/```(?:json|tool|data|xml|csv)[^\n]*\n[\s\S]*?```/g,``).replace(/```[^\n]*\n\s*[{\[]([\s\S]*?)```/g,``).replace(/^```\s*$/gm,``),n=``,r=0,i=!1;for(let e=0;e<t.length;e++){let a=t[e];a===`{`&&(r++,r===1&&/"action"\s*:/.test(t.slice(e,e+80))&&(i=!0)),i||(n+=a),a===`}`&&(r=Math.max(0,r-1),i&&r===0&&(i=!1))}return n.replace(/\n{3,}/g,`
|
|
13
13
|
|
|
14
|
-
`).trim()}var me={browser_open:`Opening page`,browser_screenshot:`Taking screenshot`,browser_click:`Clicking element`,browser_type:`Typing text`,browser_extract:`Extracting content`,browser_js:`Running JavaScript`,browser_wait:`Waiting for element`,browser_scroll:`Scrolling page`,browser_key:`Pressing key`,browser_close:`Closing browser`,web_search:`Searching the web`,fetch_url:`Fetching URL`,gmail_list:`Searching emails`,gmail_read:`Reading email`,gmail_send:`Sending email`,calendar_today:`Loading calendar`,calendar_create:`Creating event`};function he(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(()=>localStorage.getItem(`nha_conv_sidebar`)!==`hidden`),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null),b=(0,_.useRef)(null),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),ee=(0,_.useRef)(null),[te,T]=(0,_.useState)(null),[re,k]=(0,_.useState)(!1),[ie,j]=(0,_.useState)(null),[M,ae]=(0,_.useState)(``),[oe,N]=(0,_.useState)([]),[se,P]=(0,_.useState)(!1),[I,ce]=(0,_.useState)(!1),le=(0,_.useRef)(null),ue=(0,_.useRef)(null),he=(0,_.useRef)(null);(0,_.useEffect)(()=>{le.current?.scrollIntoView({behavior:`smooth`})},[a]),(0,_.useEffect)(()=>{E(`/api/config`).then(e=>{e&&(e.thinking===!0||e.thinking===`on`||e.thinking===`true`)&&S(!0)}),R().then(e=>{e&&e.length>0?ge(e[0].id):_e()});try{let e=sessionStorage.getItem(`nha_chat_prefill`)??sessionStorage.getItem(`nha_studio_import`);e&&(u(e),sessionStorage.removeItem(`nha_chat_prefill`),sessionStorage.removeItem(`nha_studio_import`),setTimeout(()=>ue.current?.focus(),100))}catch{}},[]);let R=(0,_.useCallback)(async()=>{let e=(await E(`/api/conversations`))?.conversations??[];return n(e),e},[]),ge=(0,_.useCallback)(async e=>{let t=await E(`/api/conversations/${e}`);t?.conversation&&(i(t.conversation.id),o(t.conversation.messages??[]))},[]),_e=(0,_.useCallback)(async()=>{let e=await D(`/api/conversations`,{});e?.conversation&&(i(e.conversation.id),o([]),R())},[R]),ve=(0,_.useCallback)(async e=>{let t=ne.getState().apiBase;await fetch(`${t}/api/conversations/${e}`,{method:`DELETE`}),R().then(t=>{e===r&&(t.length>0?ge(t[0].id):_e())})},[r,R,ge,_e]),ye=()=>{r&&window.open(`/api/conversations/${r}/export?format=md`,`_blank`)},be=()=>{let e=!x;S(e),D(`/api/config`,{key:`thinking`,value:e?`on`:`off`}).catch(()=>{})},xe=()=>{c(e=>{let t=!e;return localStorage.setItem(`nha_conv_sidebar`,t?`visible`:`hidden`),t})},Se=e=>{let t=e.target.files?.[0];if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=e=>{let n=(e.target?.result).split(`,`)[1];h({name:t.name,size:t.size,base64:n,mimeType:`application/pdf`,isPDF:!0}),v(null)},r.readAsDataURL(t)):(r.onload=e=>{h({name:t.name,size:t.size,content:e.target?.result}),v(null)},r.readAsText(t))},Ce=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{let n=(e.target?.result).split(`,`)[1];v({name:t.name,size:t.size,base64:n,mimeType:t.type||`image/jpeg`}),h(null)},n.readAsDataURL(t)},we=()=>{h(null),v(null),y.current&&(y.current.value=``),b.current&&(b.current.value=``)},Te=m?`[file] ${m.name} (${Math.round(m.size/1024)}KB)`:g?`[img] ${g.name} (${Math.round(g.size/1024)}KB)`:null,Ee=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e){alert(`Speech recognition not supported in this browser.`);return}if(C&&ee.current){ee.current.stop(),w(!1);return}let t=new e;ee.current=t,t.lang=`it-IT`,t.continuous=!1,t.interimResults=!1,t.onresult=e=>{let t=e.results[0][0].transcript;u(e=>e?e+` `+t:t)},t.onend=()=>w(!1),t.onerror=()=>w(!1),t.start(),w(!0)},De=(0,_.useCallback)(async()=>{let t=l.trim(),n=!!(m||g);if(!t&&!n||d)return;let i={role:`user`,content:m?(t?t+` `:``)+`[File: ${m.name}]`:g?(t?t+` `:``)+`[Image: ${g.name}]`:t};if(o(e=>[...e,i]),u(``),n){let n={message:t||`Analyze this attachment`,history:a.map(e=>({role:e.role,content:e.content}))};m?.isPDF&&m.base64?(n.pdfBase64=m.base64,n.pdfName=m.name):m?.content&&(n.fileContent=m.content,n.fileName=m.name),g?.base64&&(n.imageBase64=g.base64,n.imageMimeType=g.mimeType),we(),o(t=>[...t,{role:`assistant`,content:e(`chat.thinking`),streaming:!0}]),f(!0);try{let e=await D(`/api/chat`,n);o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e?.response??(e?.error?`Error: `+e.error:`Error`),streaming:!1}),n}),R()}catch(e){o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:`Error: `+e.message,streaming:!1}),n})}finally{f(!1)}return}we(),f(!0),N([]),P(!1),ce(!0);let s=new AbortController;p.current=s,o(e=>[...e,{role:`assistant`,content:``,streaming:!0}]);let c=a.map(e=>({role:e.role,content:e.content})),h;if(c.length>10){let e=c.slice(0,c.length-10);h=[{role:`user`,content:e.reduce((t,n,r)=>n.role===`user`?t+`\nUser: ${n.content.slice(0,120)}`:r>0&&e[r-1]?.role===`user`?t+` → ${n.content.slice(0,150)}`:t,`[Earlier conversation summary]:`)},{role:`assistant`,content:`Understood, I have context from our earlier conversation.`},...c.slice(-10)]}else h=c;try{let e=``,n=!1;await O(`/api/chat/stream`,{message:t,history:h,conversationId:r},t=>{if(t.type===`processing`&&ce(!0),t.type===`token`&&typeof t.data.content==`string`){ce(!1),n&&e===``&&o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t}),e+=t.data.content;let r=e,i=r.includes(`<think>`)&&!r.includes(`</think>`);if(P(i),i)return;r=pe(r.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:r}),t})}if(t.type===`tool`){let n=t.data.action,r=t.data.status,i=me[n]??n,a=r===`executing`?`active`:r===`error`?`error`:`done`;N(e=>{let t=e.findIndex(e=>e.action===n&&e.status===`active`);if(t>=0){let r=[...e];return r[t]={action:n,label:i,status:a},r}return[...e,{action:n,label:i,status:a}]}),r===`executing`&&(e=pe(e))}if(t.type===`tool_synthesis`&&(e=``,n=!0,P(!1),ce(!0)),t.type===`canvas`&&typeof t.data.markers==`string`){let e=t.data.markers.match(/\[CANVAS_RENDER\]([\s\S]*?)\[\/CANVAS_RENDER\]/);if(e)try{T(JSON.parse(e[1]).html),k(!0)}catch{}}if(t.type===`done`){P(!1),ce(!1),N(e=>e.map(e=>e.status===`active`?{...e,status:`done`}:e));let n=t.data.content,r=!!t.data.__sentinel_blocked,i=(n??e).replace(/<think>[\s\S]*?<\/think>/g,``),a=i.match(/\[CANVAS_RENDER\]([\s\S]*?)\[\/CANVAS_RENDER\]/);if(a)try{T(JSON.parse(a[1]).html),k(!0)}catch{T(a[1]),k(!0)}if(!a){let e=i.match(/```html\n([\s\S]*?)```/);e&&e[1].includes(`<`)&&(T(e[1]),k(!0))}let s=pe(i.replace(/\[CANVAS_RENDER\][\s\S]*?\[\/CANVAS_RENDER\]/g,``).replace(/```html[\s\S]*?```/g,`[Canvas HTML — click Panel to view]`));o(r?e=>{let t=[...e],n=t.findIndex((e,n)=>n===t.length-1&&e.role===`assistant`);return n>=0&&(t[n]={role:`assistant`,content:s||`Message blocked by SENTINEL.`,sentinelBlocked:!0,streaming:!1}),t}:e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:s,streaming:!1}),t}),R()}t.type===`error`&&o(e=>{let n=[...e],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:`Error: `+(t.data.message??`Unknown`),streaming:!1}),n})},s.signal)}catch(e){e.name!==`AbortError`&&o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:n.content||`Error connecting to server.`,streaming:!1}),t})}finally{P(!1),ce(!1),o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&n.streaming&&(t[t.length-1]={...n,streaming:!1}),t}),f(!1),p.current=null,setTimeout(()=>N([]),2e3)}},[l,a,d,m,g,r,R]),Oe=()=>{p.current?.abort(),f(!1)},ke=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),De())},Ae=e=>{navigator.clipboard.writeText(e.replace(/\[CANVAS_RENDER\][\s\S]*?\[\/CANVAS_RENDER\]/g,``).trim()).catch(()=>{})},je=(0,_.useCallback)(async t=>{if(d)return;let n=t-1;if(n<0||a[n]?.role!==`user`)return;let i=a[n],s=a.slice(0,n).map(e=>({role:e.role,content:e.content}));o(e=>{let n=[...e];return n[t]={role:`assistant`,content:``,streaming:!0},n.slice(0,t+1)}),f(!0);let c=new AbortController;p.current=c;let l=``;try{await O(`/api/chat/stream`,{message:i.content,history:s,conversationId:r},t=>{if(t.type===`token`&&typeof t.data.content==`string`){l+=t.data.content;let n=l;n=n.includes(`<think>`)&&!n.includes(`</think>`)?`💭 `+e(`chat.thinking`):pe(n.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],r=t[t.length-1];return r?.role===`assistant`&&(t[t.length-1]={...r,content:n}),t})}if(t.type===`tool_synthesis`&&(l=``,o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t})),t.type===`done`){let e=pe((t.data.content??l).replace(/<think>[\s\S]*?<\/think>/g,``));o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e,streaming:!1}),n}),R()}},c.signal)}catch{}finally{f(!1),p.current=null}},[d,a,r,R,e]),Me=e=>{d||(j(e),ae(a[e].content))},Ne=(0,_.useCallback)(async()=>{if(ie===null)return;let t=M.trim();if(!t)return;let n=a.slice(0,ie).map(e=>({role:e.role,content:e.content}));o(e=>{let n=e.slice(0,ie);return n.push({role:`user`,content:t}),n.push({role:`assistant`,content:``,streaming:!0}),n}),j(null),ae(``),f(!0);let i=new AbortController;p.current=i;let s=``;try{await O(`/api/chat/stream`,{message:t,history:n,conversationId:r},t=>{if(t.type===`token`&&typeof t.data.content==`string`){s+=t.data.content;let n=s;n=n.includes(`<think>`)&&!n.includes(`</think>`)?`💭 `+e(`chat.thinking`):pe(n.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],r=t[t.length-1];return r?.role===`assistant`&&(t[t.length-1]={...r,content:n}),t})}if(t.type===`tool_synthesis`&&(s=``,o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t})),t.type===`done`){let e=pe((t.data.content??s).replace(/<think>[\s\S]*?<\/think>/g,``));o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e,streaming:!1}),n}),R()}},i.signal)}catch{}finally{f(!1),p.current=null}},[ie,M,a,r,R,e]);return(0,A.jsxs)(`div`,{className:L.root,children:[s&&(0,A.jsxs)(`div`,{className:L.convSidebar,children:[(0,A.jsx)(`div`,{className:L.convSidebarHeader,children:(0,A.jsxs)(`button`,{className:L.newConvBtn,onClick:_e,children:[`+ `,e(`chat.newChat`)]})}),(0,A.jsx)(`div`,{className:L.convList,children:t.map(t=>{let n=Math.floor(t.messageCount/2),i=t.id===r;return(0,A.jsxs)(`div`,{className:`${L.convItem} ${i?L.convItemActive:``}`,onClick:()=>ge(t.id),children:[(0,A.jsx)(`div`,{className:L.convTitle,children:t.title||e(`chat.newChat`)}),(0,A.jsxs)(`div`,{className:L.convMeta,children:[(0,A.jsxs)(`span`,{children:[n,` turns`]}),!i&&(0,A.jsx)(`span`,{className:L.convDelete,onClick:e=>{e.stopPropagation(),ve(t.id)},children:`del`})]})]},t.id)})})]}),(0,A.jsxs)(`div`,{className:L.chatMain,children:[(0,A.jsxs)(`div`,{className:L.chatToolbar,children:[(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:xe,title:`Toggle conversations`,children:`💬 Chats`}),(0,A.jsx)(`span`,{className:L.convTitleBar,children:t.find(e=>e.id===r)?.title||e(`chat.newChat`)}),(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:_e,children:`+ New`}),(0,A.jsx)(`button`,{className:L.toolbarBtnDim,onClick:ye,title:`Export Markdown`,children:`Export`}),te&&(0,A.jsx)(`button`,{className:`${L.toolbarBtn} ${L.toolbarBtnCanvas}`,onClick:()=>k(e=>!e),title:`Toggle canvas panel`,children:re?`▣ Panel ✕`:`▣ Panel`})]}),(0,A.jsxs)(`div`,{className:L.messages,ref:he,children:[a.length===0&&(0,A.jsxs)(`div`,{className:L.empty,children:[(0,A.jsx)(`div`,{className:L.emptyIcon,children:`💬`}),(0,A.jsx)(`div`,{className:L.emptyTitle,children:`NHA Chat`}),(0,A.jsx)(`div`,{className:L.emptySub,children:`Personal Operations Assistant · 80 Tools · 38 Agents · Free AI`}),(0,A.jsxs)(`div`,{className:L.suggGroups,children:[(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`⚡ Quick Actions`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Show my unread emails and summarize the most important ones`,`What's on my calendar today? Any meetings I need to prepare for?`,`List my pending tasks sorted by priority`,`Check my GitHub notifications and summarize open issues`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`🌐 Web & Research`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Search the web for the latest AI news and summarize the top 5 stories`,`Open google.com and take a screenshot of the homepage`,`Search for the best restaurants near me and create a summary`,`Research the latest developments in quantum computing and write a report`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`🛠️ Productivity`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Draft a professional reply to my last email`,`Create a new calendar event for tomorrow at 10am with reminder`,`Summarize my notes and create a to-do list from action items`,`Find contacts named Mario and show their details`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`📈 Finance`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`What is the current price of Bitcoin and its 24h performance?`,`Analyze the current macro environment and suggest 3 trading opportunities`,`What is the current market regime? Risk-on or risk-off?`,`Give me a technical analysis of AAPL with key support/resistance levels`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]})]})]}),a.map((e,t)=>(0,A.jsxs)(`div`,{className:`${L.message} ${L[e.role]}`,children:[(0,A.jsx)(`div`,{className:L.msgLabel,children:e.role===`user`?`You`:`NHA`}),e.role===`assistant`&&e.streaming&&(0,A.jsxs)(`div`,{className:L.toolActivity,children:[(I||e.content===``&&!se&&oe.length===0)&&(0,A.jsxs)(`div`,{className:L.thinkingIndicator,children:[(0,A.jsxs)(`div`,{className:L.thinkingDots,children:[(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot})]}),se?`Deep thinking...`:`Generating...`]}),se&&!I&&(0,A.jsxs)(`div`,{className:L.thinkingIndicator,children:[(0,A.jsxs)(`div`,{className:L.thinkingDots,children:[(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot})]}),`Deep thinking...`]}),oe.map((e,t)=>(0,A.jsxs)(`div`,{className:`${L.toolActivityItem} ${L[e.status]}`,children:[e.status===`active`?`⏳`:e.status===`error`?`❌`:`✅`,` `,e.label,e.status===`active`&&`...`]},t))]}),e.role===`user`&&ie===t?(0,A.jsxs)(`div`,{className:L.editBox,children:[(0,A.jsx)(`textarea`,{className:L.editInput,value:M,onChange:e=>ae(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ne()),e.key===`Escape`&&j(null)},autoFocus:!0,rows:3}),(0,A.jsxs)(`div`,{className:L.editActions,children:[(0,A.jsx)(`button`,{className:L.editSaveBtn,onClick:Ne,children:`Send ↵`}),(0,A.jsx)(`button`,{className:L.editCancelBtn,onClick:()=>j(null),children:`Cancel`})]})]}):e.role===`assistant`?e.content!==``&&(0,A.jsx)(`div`,{className:`${L.bubble} ${fe.body} ${e.sentinelBlocked?L.sentinelBubble:``}`,dangerouslySetInnerHTML:{__html:de(e.content)}}):(0,A.jsx)(`div`,{className:L.bubble,children:e.content}),e.streaming&&(0,A.jsx)(`span`,{className:L.cursor}),!e.streaming&&ie!==t&&(0,A.jsxs)(`div`,{className:L.msgActions,children:[(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>Ae(e.content),children:`Copy`}),e.role===`user`&&!d&&(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>Me(t),children:`Edit`}),e.role===`assistant`&&!d&&(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>je(t),children:`Retry`})]})]},t)),(0,A.jsx)(`div`,{ref:le})]}),Te&&(0,A.jsxs)(`div`,{className:L.attachBar,children:[(0,A.jsx)(`span`,{children:Te}),(0,A.jsx)(`button`,{className:L.attachClear,onClick:we,children:`×`})]}),(0,A.jsxs)(`div`,{className:L.inputBar,children:[(0,A.jsxs)(`div`,{className:L.inputTools,children:[(0,A.jsx)(`button`,{className:`${L.iconBtn} ${C?L.iconBtnActive:``}`,onClick:Ee,title:`Voice input`,children:`🎤`}),(0,A.jsx)(`button`,{className:L.iconBtn,onClick:()=>y.current?.click(),title:`Attach file`,children:`📎`}),(0,A.jsx)(`button`,{className:L.iconBtn,onClick:()=>b.current?.click(),title:`Attach image`,children:`🖼`}),(0,A.jsx)(`input`,{ref:y,type:`file`,style:{display:`none`},onChange:Se}),(0,A.jsx)(`input`,{ref:b,type:`file`,accept:`image/*`,style:{display:`none`},onChange:Ce}),(0,A.jsx)(`span`,{style:{flex:1}}),(0,A.jsxs)(`button`,{className:`${L.thinkBtn} ${x?L.thinkBtnOn:``}`,onClick:be,title:`Extended Thinking`,children:[`Think: `,x?`on`:`off`]}),te&&(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:()=>k(e=>!e),title:`Canvas panel`,children:`▣ Panel`})]}),(0,A.jsxs)(`div`,{className:L.inputRow,children:[(0,A.jsx)(`textarea`,{ref:ue,className:L.input,value:l,onChange:e=>u(e.target.value),onKeyDown:ke,placeholder:e(`chat.placeholder`),rows:1,disabled:d}),d?(0,A.jsxs)(`button`,{className:`${L.btn} ${L.stop}`,onClick:Oe,children:[`■ `,e(`chat.stopGeneration`)]}):(0,A.jsx)(`button`,{className:`${L.btn} ${L.send}`,onClick:De,disabled:!l.trim()&&!m&&!g,children:`Send ↵`})]})]})]}),re&&te&&(0,A.jsxs)(`div`,{className:L.canvasPanel,children:[(0,A.jsxs)(`div`,{className:L.canvasPanelHeader,children:[(0,A.jsx)(`span`,{children:`Canvas`}),(0,A.jsxs)(`div`,{className:L.canvasPanelActions,children:[(0,A.jsx)(`button`,{className:L.canvasPanelBtn,onClick:()=>{let e=new Blob([te],{type:`text/html`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`NHA-Canvas.html`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)},children:`↓ Download`}),(0,A.jsx)(`button`,{className:L.canvasPanelBtn,onClick:()=>navigator.clipboard.writeText(te).catch(()=>{}),children:`Copy HTML`}),(0,A.jsx)(`button`,{className:L.canvasPanelClose,onClick:()=>k(!1),children:`×`})]})]}),(0,A.jsx)(`iframe`,{className:L.canvasFrame,sandbox:`allow-scripts`,srcDoc:te,title:`Canvas`})]})]})}var R={root:`_root_1j3wy_1`,header:`_header_1j3wy_8`,headerLeft:`_headerLeft_1j3wy_18`,title:`_title_1j3wy_20`,subtitle:`_subtitle_1j3wy_27`,headerActions:`_headerActions_1j3wy_33`,tokenBar:`_tokenBar_1j3wy_40`,tokIn:`_tokIn_1j3wy_48`,tokOut:`_tokOut_1j3wy_49`,tokTotal:`_tokTotal_1j3wy_50`,tokDim:`_tokDim_1j3wy_51`,sessionsBtn:`_sessionsBtn_1j3wy_53`,pdfBtn:`_pdfBtn_1j3wy_65`,sessionsDrawer:`_sessionsDrawer_1j3wy_76`,noSessions:`_noSessions_1j3wy_84`,sessionItem:`_sessionItem_1j3wy_91`,sessionInfo:`_sessionInfo_1j3wy_101`,sessionTask:`_sessionTask_1j3wy_107`,sessionMeta:`_sessionMeta_1j3wy_117`,sessionBtns:`_sessionBtns_1j3wy_123`,importBtn:`_importBtn_1j3wy_129`,delSessionBtn:`_delSessionBtn_1j3wy_139`,inputArea:`_inputArea_1j3wy_150`,inputRow:`_inputRow_1j3wy_159`,taskInput:`_taskInput_1j3wy_165`,inputControls:`_inputControls_1j3wy_180`,runBtn:`_runBtn_1j3wy_186`,stopBtn:`_stopBtn_1j3wy_199`,attachBtn:`_attachBtn_1j3wy_210`,attachBadge:`_attachBadge_1j3wy_223`,clearAttach:`_clearAttach_1j3wy_236`,examples:`_examples_1j3wy_245`,exampleBtn:`_exampleBtn_1j3wy_251`,body:`_body_1j3wy_269`,pipeline:`_pipeline_1j3wy_279`,pipelineRunning:`_pipelineRunning_1j3wy_289`,scanSweep:`_scanSweep_1j3wy_1`,pipelineTitle:`_pipelineTitle_1j3wy_311`,pipelineNodes:`_pipelineNodes_1j3wy_319`,pipelineStep:`_pipelineStep_1j3wy_326`,arrow:`_arrow_1j3wy_332`,arrowActive:`_arrowActive_1j3wy_341`,arrowPulse:`_arrowPulse_1j3wy_1`,agentChar:`_agentChar_1j3wy_353`,charWaiting:`_charWaiting_1j3wy_368`,charActive:`_charActive_1j3wy_373`,charCardPulse:`_charCardPulse_1j3wy_1`,charDone:`_charDone_1j3wy_381`,charError:`_charError_1j3wy_386`,orbitRing1:`_orbitRing1_1j3wy_397`,orbitRing2:`_orbitRing2_1j3wy_398`,orbitSpin1:`_orbitSpin1_1j3wy_1`,orbitSpin2:`_orbitSpin2_1j3wy_1`,charAvatar:`_charAvatar_1j3wy_444`,charIcon:`_charIcon_1j3wy_459`,iconBob:`_iconBob_1j3wy_1`,charCheck:`_charCheck_1j3wy_476`,badgePop:`_badgePop_1j3wy_1`,charErr:`_charErr_1j3wy_386`,charPulse:`_charPulse_1j3wy_520`,charPulse2:`_charPulse2_1j3wy_521`,expandRing:`_expandRing_1j3wy_1`,charLabel:`_charLabel_1j3wy_540`,charStatus:`_charStatus_1j3wy_552`,charStatusDots:`_charStatusDots_1j3wy_565`,dot1:`_dot1_1j3wy_566`,dot2:`_dot2_1j3wy_566`,dot3:`_dot3_1j3wy_566`,dotFade:`_dotFade_1j3wy_1`,twoCol:`_twoCol_1j3wy_580`,panelTitle:`_panelTitle_1j3wy_587`,logPanel:`_logPanel_1j3wy_597`,logBody:`_logBody_1j3wy_609`,logEntry:`_logEntry_1j3wy_617`,logTime:`_logTime_1j3wy_627`,logIcon:`_logIcon_1j3wy_628`,logAgent:`_logAgent_1j3wy_629`,logText:`_logText_1j3wy_630`,log_system:`_log_system_1j3wy_632`,log_error:`_log_error_1j3wy_633`,liveOutputPanel:`_liveOutputPanel_1j3wy_636`,liveBlock:`_liveBlock_1j3wy_642`,blockSlideIn:`_blockSlideIn_1j3wy_1`,liveBlockActive:`_liveBlockActive_1j3wy_656`,liveBlockHeader:`_liveBlockHeader_1j3wy_661`,liveBlockIcon:`_liveBlockIcon_1j3wy_670`,liveBlockLabel:`_liveBlockLabel_1j3wy_672`,outputStatus:`_outputStatus_1j3wy_680`,status_done:`_status_done_1j3wy_691`,status_running:`_status_running_1j3wy_692`,status_error:`_status_error_1j3wy_693`,status_waiting:`_status_waiting_1j3wy_694`,liveBlockBody:`_liveBlockBody_1j3wy_697`,studioBlinkCursor:`_studioBlinkCursor_1j3wy_1`,resultAccordion:`_resultAccordion_1j3wy_851`,resultAccordionSummary:`_resultAccordionSummary_1j3wy_858`,resultAccordionBody:`_resultAccordionBody_1j3wy_875`,financeSection:`_financeSection_1j3wy_909`,financeSectionTitle:`_financeSectionTitle_1j3wy_917`,financePresets:`_financePresets_1j3wy_926`,financeBtn:`_financeBtn_1j3wy_932`,canvasToggleBtn:`_canvasToggleBtn_1j3wy_950`,canvasPanel:`_canvasPanel_1j3wy_966`,canvasPanelHeader:`_canvasPanelHeader_1j3wy_981`,canvasPanelActions:`_canvasPanelActions_1j3wy_993`,canvasPanelBtn:`_canvasPanelBtn_1j3wy_999`,canvasPanelClose:`_canvasPanelClose_1j3wy_1011`,canvasFrame:`_canvasFrame_1j3wy_1022`,pipelineLiveTag:`_pipelineLiveTag_1j3wy_1030`,liveTagBlink:`_liveTagBlink_1j3wy_1`,reasonRow:`_reasonRow_1j3wy_1044`,reasonChip:`_reasonChip_1j3wy_1053`,reasonIcon:`_reasonIcon_1j3wy_1066`,reasonText:`_reasonText_1j3wy_1067`,liveBlockReason:`_liveBlockReason_1j3wy_1070`,councilWrapper:`_councilWrapper_1j3wy_1080`,councilPanel:`_councilPanel_1j3wy_1085`,councilHeader:`_councilHeader_1j3wy_1093`,councilHeaderLeft:`_councilHeaderLeft_1j3wy_1104`,councilHeaderRight:`_councilHeaderRight_1j3wy_1110`,councilIcon:`_councilIcon_1j3wy_1116`,councilTitle:`_councilTitle_1j3wy_1118`,councilConvergedBadge:`_councilConvergedBadge_1j3wy_1127`,councilDivergedBadge:`_councilDivergedBadge_1j3wy_1139`,councilPhaseTag:`_councilPhaseTag_1j3wy_1151`,councilPhaseActive:`_councilPhaseActive_1j3wy_1157`,phaseGlow:`_phaseGlow_1j3wy_1`,councilPhaseDone:`_councilPhaseDone_1j3wy_1166`,councilMetrics:`_councilMetrics_1j3wy_1169`,convRow:`_convRow_1j3wy_1177`,convLabel:`_convLabel_1j3wy_1183`,convTrack:`_convTrack_1j3wy_1191`,convFill:`_convFill_1j3wy_1199`,convPct:`_convPct_1j3wy_1205`,councilNodes:`_councilNodes_1j3wy_1215`,councilSectionTitle:`_councilSectionTitle_1j3wy_1220`,councilNode:`_councilNode_1j3wy_1215`,councilNodeHeader:`_councilNodeHeader_1j3wy_1237`,councilNodeIcon:`_councilNodeIcon_1j3wy_1250`,councilNodeLabel:`_councilNodeLabel_1j3wy_1251`,councilNodeToggle:`_councilNodeToggle_1j3wy_1252`,councilNodeBody:`_councilNodeBody_1j3wy_1254`,councilSynthesis:`_councilSynthesis_1j3wy_1264`,councilSynthesisHeader:`_councilSynthesisHeader_1j3wy_1268`,heraldIcon:`_heraldIcon_1j3wy_1277`,heraldLabel:`_heraldLabel_1j3wy_1279`,heraldStreaming:`_heraldStreaming_1j3wy_1287`,councilSynthesisBody:`_councilSynthesisBody_1j3wy_1289`,councilSkipped:`_councilSkipped_1j3wy_1319`,councilSkipIcon:`_councilSkipIcon_1j3wy_1330`,charSpriteRunning:`_charSpriteRunning_1j3wy_1343`,spriteWalk:`_spriteWalk_1j3wy_1`,charSpriteDone:`_charSpriteDone_1j3wy_1352`,charScanline:`_charScanline_1j3wy_1356`,scanlineScroll:`_scanlineScroll_1j3wy_1`,auraAnim:`_auraAnim_1j3wy_1376`,auraGlow:`_auraGlow_1j3wy_1`,parliamentPrompt:`_parliamentPrompt_1j3wy_1383`,parliamentPromptIcon:`_parliamentPromptIcon_1j3wy_1393`,parliamentPromptContent:`_parliamentPromptContent_1j3wy_1394`,parliamentPromptTitle:`_parliamentPromptTitle_1j3wy_1395`,parliamentPromptDesc:`_parliamentPromptDesc_1j3wy_1396`,parliamentPromptMeta:`_parliamentPromptMeta_1j3wy_1397`,parliamentPromptBtns:`_parliamentPromptBtns_1j3wy_1398`,parliamentActivateBtn:`_parliamentActivateBtn_1j3wy_1399`,parliamentSkipBtn:`_parliamentSkipBtn_1j3wy_1406`,panelTabs:`_panelTabs_1j3wy_1414`,panelTabBtn:`_panelTabBtn_1j3wy_1415`,panelTabActive:`_panelTabActive_1j3wy_1422`,panelEmpty:`_panelEmpty_1j3wy_1424`,browserPanel:`_browserPanel_1j3wy_1433`,browserBar:`_browserBar_1j3wy_1434`,browserInput:`_browserInput_1j3wy_1435`,browserGo:`_browserGo_1j3wy_1442`},ge=[{label:`📈 Full Trading Strategy`,task:`You are a team of senior quantitative analysts and macro traders. Build a complete, actionable trading strategy with the following structure:
|
|
14
|
+
`).trim()}var me={browser_open:`Opening page`,browser_screenshot:`Taking screenshot`,browser_click:`Clicking element`,browser_type:`Typing text`,browser_extract:`Extracting content`,browser_js:`Running JavaScript`,browser_wait:`Waiting for element`,browser_scroll:`Scrolling page`,browser_key:`Pressing key`,browser_close:`Closing browser`,web_search:`Searching the web`,fetch_url:`Fetching URL`,gmail_list:`Searching emails`,gmail_read:`Reading email`,gmail_send:`Sending email`,calendar_today:`Loading calendar`,calendar_create:`Creating event`};function he(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(()=>localStorage.getItem(`nha_conv_sidebar`)!==`hidden`),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(null),y=(0,_.useRef)(null),b=(0,_.useRef)(null),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),ee=(0,_.useRef)(null),[te,T]=(0,_.useState)(null),[re,k]=(0,_.useState)(!1),[ie,j]=(0,_.useState)(null),[M,ae]=(0,_.useState)(``),[oe,N]=(0,_.useState)([]),[se,P]=(0,_.useState)(!1),[I,ce]=(0,_.useState)(!1),le=(0,_.useRef)(null),ue=(0,_.useRef)(null),he=(0,_.useRef)(null);(0,_.useEffect)(()=>{le.current?.scrollIntoView({behavior:`smooth`})},[a]),(0,_.useEffect)(()=>{E(`/api/config`).then(e=>{e&&(e.thinking===!0||e.thinking===`on`||e.thinking===`true`)&&S(!0)}),R().then(e=>{e&&e.length>0?ge(e[0].id):_e()});try{let e=sessionStorage.getItem(`nha_chat_prefill`)??sessionStorage.getItem(`nha_studio_import`);e&&(u(e),sessionStorage.removeItem(`nha_chat_prefill`),sessionStorage.removeItem(`nha_studio_import`),setTimeout(()=>ue.current?.focus(),100))}catch{}},[]);let R=(0,_.useCallback)(async()=>{let e=(await E(`/api/conversations`))?.conversations??[];return n(e),e},[]),ge=(0,_.useCallback)(async e=>{let t=await E(`/api/conversations/${e}`);t?.conversation&&(i(t.conversation.id),o(t.conversation.messages??[]))},[]),_e=(0,_.useCallback)(async()=>{let e=await D(`/api/conversations`,{});e?.conversation&&(i(e.conversation.id),o([]),R())},[R]),ve=(0,_.useCallback)(async e=>{let t=ne.getState().apiBase;await fetch(`${t}/api/conversations/${e}`,{method:`DELETE`}),R().then(t=>{e===r&&(t.length>0?ge(t[0].id):_e())})},[r,R,ge,_e]),ye=()=>{r&&window.open(`/api/conversations/${r}/export?format=md`,`_blank`)},be=()=>{let e=!x;S(e),D(`/api/config`,{key:`thinking`,value:e?`on`:`off`}).catch(()=>{})},xe=()=>{c(e=>{let t=!e;return localStorage.setItem(`nha_conv_sidebar`,t?`visible`:`hidden`),t})},Se=e=>{let t=e.target.files?.[0];if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=e=>{let n=(e.target?.result).split(`,`)[1];h({name:t.name,size:t.size,base64:n,mimeType:`application/pdf`,isPDF:!0}),v(null)},r.readAsDataURL(t)):(r.onload=e=>{h({name:t.name,size:t.size,content:e.target?.result}),v(null)},r.readAsText(t))},Ce=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{let n=(e.target?.result).split(`,`)[1];v({name:t.name,size:t.size,base64:n,mimeType:t.type||`image/jpeg`}),h(null)},n.readAsDataURL(t)},we=()=>{h(null),v(null),y.current&&(y.current.value=``),b.current&&(b.current.value=``)},Te=m?`[file] ${m.name} (${Math.round(m.size/1024)}KB)`:g?`[img] ${g.name} (${Math.round(g.size/1024)}KB)`:null,Ee=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e){alert(`Speech recognition not supported in this browser.`);return}if(C&&ee.current){ee.current.stop(),w(!1);return}let t=new e;ee.current=t,t.lang=`it-IT`,t.continuous=!1,t.interimResults=!1,t.onresult=e=>{let t=e.results[0][0].transcript;u(e=>e?e+` `+t:t)},t.onend=()=>w(!1),t.onerror=()=>w(!1),t.start(),w(!0)},De=(0,_.useCallback)(async()=>{let t=l.trim(),n=!!(m||g);if(!t&&!n||d)return;let i={role:`user`,content:m?(t?t+` `:``)+`[File: ${m.name}]`:g?(t?t+` `:``)+`[Image: ${g.name}]`:t};if(o(e=>[...e,i]),u(``),n){let n={message:t||`Analyze this attachment`,history:a.map(e=>({role:e.role,content:e.content}))};m?.isPDF&&m.base64?(n.pdfBase64=m.base64,n.pdfName=m.name):m?.content&&(n.fileContent=m.content,n.fileName=m.name),g?.base64&&(n.imageBase64=g.base64,n.imageMimeType=g.mimeType),we(),o(t=>[...t,{role:`assistant`,content:e(`chat.thinking`),streaming:!0}]),f(!0);try{let e=await D(`/api/chat`,n);o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e?.response??(e?.error?`Error: `+e.error:`Error`),streaming:!1}),n}),R()}catch(e){o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:`Error: `+e.message,streaming:!1}),n})}finally{f(!1)}return}we(),f(!0),N([]),P(!1),ce(!0);let s=new AbortController;p.current=s,o(e=>[...e,{role:`assistant`,content:``,streaming:!0}]);let c=a.map(e=>({role:e.role,content:e.content})),h;if(c.length>10){let e=c.slice(0,c.length-10);h=[{role:`user`,content:e.reduce((t,n,r)=>n.role===`user`?t+`\nUser: ${n.content.slice(0,120)}`:r>0&&e[r-1]?.role===`user`?t+` → ${n.content.slice(0,150)}`:t,`[Earlier conversation summary]:`)},{role:`assistant`,content:`Understood, I have context from our earlier conversation.`},...c.slice(-10)]}else h=c;try{let e=``,n=!1;await O(`/api/chat/stream`,{message:t,history:h,conversationId:r},t=>{if(t.type===`processing`&&ce(!0),t.type===`token`&&typeof t.data.content==`string`){ce(!1),n&&e===``&&o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t}),e+=t.data.content;let r=e,i=r.includes(`<think>`)&&!r.includes(`</think>`);if(P(i),i)return;r=pe(r.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:r}),t})}if(t.type===`tool`){let n=t.data.action,r=t.data.status,i=me[n]??n,a=r===`executing`?`active`:r===`error`?`error`:`done`;N(e=>{let t=e.findIndex(e=>e.action===n&&e.status===`active`);if(t>=0){let r=[...e];return r[t]={action:n,label:i,status:a},r}return[...e,{action:n,label:i,status:a}]}),r===`executing`&&(e=pe(e))}if(t.type===`tool_synthesis`&&(e=``,n=!0,P(!1),ce(!0)),t.type===`canvas`&&typeof t.data.markers==`string`){let e=t.data.markers.match(/\[CANVAS_RENDER\]([\s\S]*?)\[\/CANVAS_RENDER\]/);if(e)try{T(JSON.parse(e[1]).html),k(!0)}catch{}}if(t.type===`done`){P(!1),ce(!1),N(e=>e.map(e=>e.status===`active`?{...e,status:`done`}:e));let n=t.data.content,r=!!t.data.__sentinel_blocked,i=(n??e).replace(/<think>[\s\S]*?<\/think>/g,``),a=i.match(/\[CANVAS_RENDER\]([\s\S]*?)\[\/CANVAS_RENDER\]/);if(a)try{T(JSON.parse(a[1]).html),k(!0)}catch{T(a[1]),k(!0)}if(!a){let e=i.match(/```html\n([\s\S]*?)```/);e&&e[1].includes(`<`)&&(T(e[1]),k(!0))}let s=pe(i.replace(/\[CANVAS_RENDER\][\s\S]*?\[\/CANVAS_RENDER\]/g,``).replace(/```html[\s\S]*?```/g,`[Canvas HTML — click Panel to view]`));o(r?e=>{let t=[...e],n=t.findIndex((e,n)=>n===t.length-1&&e.role===`assistant`);return n>=0&&(t[n]={role:`assistant`,content:s||`Message blocked by SENTINEL.`,sentinelBlocked:!0,streaming:!1}),t}:e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:s,streaming:!1}),t}),R()}t.type===`error`&&o(e=>{let n=[...e],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:`Error: `+(t.data.message??`Unknown`),streaming:!1}),n})},s.signal)}catch(e){e.name!==`AbortError`&&o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:n.content||`Error connecting to server.`,streaming:!1}),t})}finally{P(!1),ce(!1),o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&n.streaming&&(t[t.length-1]={...n,streaming:!1}),t}),f(!1),p.current=null,setTimeout(()=>N([]),2e3)}},[l,a,d,m,g,r,R]),Oe=()=>{p.current?.abort(),f(!1)},ke=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),De())},Ae=e=>{navigator.clipboard.writeText(e.replace(/\[CANVAS_RENDER\][\s\S]*?\[\/CANVAS_RENDER\]/g,``).trim()).catch(()=>{})},je=(0,_.useCallback)(async t=>{if(d)return;let n=t-1;if(n<0||a[n]?.role!==`user`)return;let i=a[n],s=a.slice(0,n).map(e=>({role:e.role,content:e.content}));o(e=>{let n=[...e];return n[t]={role:`assistant`,content:``,streaming:!0},n.slice(0,t+1)}),f(!0);let c=new AbortController;p.current=c;let l=``;try{await O(`/api/chat/stream`,{message:i.content,history:s,conversationId:r},t=>{if(t.type===`token`&&typeof t.data.content==`string`){l+=t.data.content;let n=l;n=n.includes(`<think>`)&&!n.includes(`</think>`)?`💭 `+e(`chat.thinking`):pe(n.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],r=t[t.length-1];return r?.role===`assistant`&&(t[t.length-1]={...r,content:n}),t})}if(t.type===`tool_synthesis`&&(l=``,o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t})),t.type===`done`){let e=pe((t.data.content??l).replace(/<think>[\s\S]*?<\/think>/g,``));o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e,streaming:!1}),n}),R()}},c.signal)}catch{}finally{f(!1),p.current=null}},[d,a,r,R,e]),Me=e=>{d||(j(e),ae(a[e].content))},Ne=(0,_.useCallback)(async()=>{if(ie===null)return;let t=M.trim();if(!t)return;let n=a.slice(0,ie).map(e=>({role:e.role,content:e.content}));o(e=>{let n=e.slice(0,ie);return n.push({role:`user`,content:t}),n.push({role:`assistant`,content:``,streaming:!0}),n}),j(null),ae(``),f(!0);let i=new AbortController;p.current=i;let s=``;try{await O(`/api/chat/stream`,{message:t,history:n,conversationId:r},t=>{if(t.type===`token`&&typeof t.data.content==`string`){s+=t.data.content;let n=s;n=n.includes(`<think>`)&&!n.includes(`</think>`)?`💭 `+e(`chat.thinking`):pe(n.replace(/<think>[\s\S]*?<\/think>/g,``)),o(e=>{let t=[...e],r=t[t.length-1];return r?.role===`assistant`&&(t[t.length-1]={...r,content:n}),t})}if(t.type===`tool_synthesis`&&(s=``,o(e=>{let t=[...e],n=t[t.length-1];return n?.role===`assistant`&&(t[t.length-1]={...n,content:``}),t})),t.type===`done`){let e=pe((t.data.content??s).replace(/<think>[\s\S]*?<\/think>/g,``));o(t=>{let n=[...t],r=n[n.length-1];return r?.role===`assistant`&&(n[n.length-1]={...r,content:e,streaming:!1}),n}),R()}},i.signal)}catch{}finally{f(!1),p.current=null}},[ie,M,a,r,R,e]);return(0,A.jsxs)(`div`,{className:L.root,children:[s&&(0,A.jsxs)(`div`,{className:L.convSidebar,children:[(0,A.jsx)(`div`,{className:L.convSidebarHeader,children:(0,A.jsxs)(`button`,{className:L.newConvBtn,onClick:_e,children:[`+ `,e(`chat.newChat`)]})}),(0,A.jsx)(`div`,{className:L.convList,children:t.map(t=>{let n=Math.floor(t.messageCount/2),i=t.id===r;return(0,A.jsxs)(`div`,{className:`${L.convItem} ${i?L.convItemActive:``}`,onClick:()=>ge(t.id),children:[(0,A.jsx)(`div`,{className:L.convTitle,children:t.title||e(`chat.newChat`)}),(0,A.jsxs)(`div`,{className:L.convMeta,children:[(0,A.jsxs)(`span`,{children:[n,` turns`]}),!i&&(0,A.jsx)(`span`,{className:L.convDelete,onClick:e=>{e.stopPropagation(),ve(t.id)},children:`del`})]})]},t.id)})})]}),(0,A.jsxs)(`div`,{className:L.chatMain,children:[(0,A.jsxs)(`div`,{className:L.chatToolbar,children:[(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:xe,title:`Toggle conversations`,children:`💬 Chats`}),(0,A.jsx)(`span`,{className:L.convTitleBar,children:t.find(e=>e.id===r)?.title||e(`chat.newChat`)}),(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:_e,children:`+ New`}),(0,A.jsx)(`button`,{className:L.toolbarBtnDim,onClick:ye,title:`Export Markdown`,children:`Export`}),te&&(0,A.jsx)(`button`,{className:`${L.toolbarBtn} ${L.toolbarBtnCanvas}`,onClick:()=>k(e=>!e),title:`Toggle canvas panel`,children:re?`▣ Panel ✕`:`▣ Panel`})]}),(0,A.jsxs)(`div`,{className:L.messages,ref:he,children:[a.length===0&&(0,A.jsxs)(`div`,{className:L.empty,children:[(0,A.jsx)(`div`,{className:L.emptyIcon,children:`💬`}),(0,A.jsx)(`div`,{className:L.emptyTitle,children:`NHA Chat`}),(0,A.jsx)(`div`,{className:L.emptySub,children:`Personal Operations Assistant · 80 Tools · 38 Agents · Free AI`}),(0,A.jsxs)(`div`,{className:L.suggGroups,children:[(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`⚡ Quick Actions`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Show my unread emails and summarize the most important ones`,`What's on my calendar today? Any meetings I need to prepare for?`,`List my pending tasks sorted by priority`,`Check my GitHub notifications and summarize open issues`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`🌐 Web & Research`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Search the web for the latest AI news and summarize the top 5 stories`,`Open google.com and take a screenshot of the homepage`,`Search for the best restaurants near me and create a summary`,`Research the latest developments in quantum computing and write a report`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`🛠️ Productivity`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`Draft a professional reply to my last email`,`Create a new calendar event for tomorrow at 10am with reminder`,`Summarize my notes and create a to-do list from action items`,`Find contacts named Mario and show their details`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]}),(0,A.jsxs)(`div`,{className:L.suggGroup,children:[(0,A.jsx)(`div`,{className:L.suggGroupTitle,children:`📈 Finance`}),(0,A.jsx)(`div`,{className:L.suggBtns,children:[`What is the current price of Bitcoin and its 24h performance?`,`Analyze the current macro environment and suggest 3 trading opportunities`,`What is the current market regime? Risk-on or risk-off?`,`Give me a technical analysis of AAPL with key support/resistance levels`].map(e=>(0,A.jsx)(`button`,{className:L.suggBtn,onClick:()=>u(e),children:e},e))})]})]})]}),a.map((e,t)=>(0,A.jsxs)(`div`,{className:`${L.message} ${L[e.role]}`,children:[(0,A.jsx)(`div`,{className:L.msgLabel,children:e.role===`user`?`You`:`NHA`}),e.role===`assistant`&&e.streaming&&(0,A.jsxs)(`div`,{className:L.toolActivity,children:[(I||e.content===``&&!se&&oe.length===0)&&(0,A.jsxs)(`div`,{className:L.thinkingIndicator,children:[(0,A.jsxs)(`div`,{className:L.thinkingDots,children:[(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot})]}),se?`Deep thinking...`:`Generating...`]}),se&&!I&&(0,A.jsxs)(`div`,{className:L.thinkingIndicator,children:[(0,A.jsxs)(`div`,{className:L.thinkingDots,children:[(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot}),(0,A.jsx)(`div`,{className:L.thinkingDot})]}),`Deep thinking...`]}),oe.map((e,t)=>(0,A.jsxs)(`div`,{className:`${L.toolActivityItem} ${L[e.status]}`,children:[e.status===`active`?`⏳`:e.status===`error`?`❌`:`✅`,` `,e.label,e.status===`active`&&`...`]},t))]}),e.role===`user`&&ie===t?(0,A.jsxs)(`div`,{className:L.editBox,children:[(0,A.jsx)(`textarea`,{className:L.editInput,value:M,onChange:e=>ae(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ne()),e.key===`Escape`&&j(null)},autoFocus:!0,rows:3}),(0,A.jsxs)(`div`,{className:L.editActions,children:[(0,A.jsx)(`button`,{className:L.editSaveBtn,onClick:Ne,children:`Send ↵`}),(0,A.jsx)(`button`,{className:L.editCancelBtn,onClick:()=>j(null),children:`Cancel`})]})]}):e.role===`assistant`?e.content!==``&&(0,A.jsx)(`div`,{className:`${L.bubble} ${fe.body} ${e.sentinelBlocked?L.sentinelBubble:``}`,dangerouslySetInnerHTML:{__html:de(e.content)}}):(0,A.jsx)(`div`,{className:L.bubble,children:e.content}),e.streaming&&(0,A.jsx)(`span`,{className:L.cursor}),!e.streaming&&ie!==t&&(0,A.jsxs)(`div`,{className:L.msgActions,children:[(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>Ae(e.content),children:`Copy`}),e.role===`user`&&!d&&(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>Me(t),children:`Edit`}),e.role===`assistant`&&!d&&(0,A.jsx)(`button`,{className:L.msgActionBtn,onClick:()=>je(t),children:`Retry`})]})]},t)),(0,A.jsx)(`div`,{ref:le})]}),Te&&(0,A.jsxs)(`div`,{className:L.attachBar,children:[(0,A.jsx)(`span`,{children:Te}),(0,A.jsx)(`button`,{className:L.attachClear,onClick:we,children:`×`})]}),(0,A.jsxs)(`div`,{className:L.inputBar,children:[(0,A.jsxs)(`div`,{className:L.inputTools,children:[(0,A.jsx)(`button`,{className:`${L.iconBtn} ${C?L.iconBtnActive:``}`,onClick:Ee,title:`Voice input`,children:`🎤`}),(0,A.jsx)(`button`,{className:L.iconBtn,onClick:()=>y.current?.click(),title:`Attach file`,children:`📎`}),(0,A.jsx)(`button`,{className:L.iconBtn,onClick:()=>b.current?.click(),title:`Attach image`,children:`🖼`}),(0,A.jsx)(`input`,{ref:y,type:`file`,style:{display:`none`},onChange:Se}),(0,A.jsx)(`input`,{ref:b,type:`file`,accept:`image/*`,style:{display:`none`},onChange:Ce}),(0,A.jsx)(`span`,{style:{flex:1}}),(0,A.jsxs)(`button`,{className:`${L.thinkBtn} ${x?L.thinkBtnOn:``}`,onClick:be,title:`Extended Thinking`,children:[`Think: `,x?`on`:`off`]}),te&&(0,A.jsx)(`button`,{className:L.toolbarBtn,onClick:()=>k(e=>!e),title:`Canvas panel`,children:`▣ Panel`})]}),(0,A.jsxs)(`div`,{className:L.inputRow,children:[(0,A.jsx)(`textarea`,{ref:ue,className:L.input,value:l,onChange:e=>u(e.target.value),onKeyDown:ke,placeholder:e(`chat.placeholder`),rows:1,disabled:d}),d?(0,A.jsxs)(`button`,{className:`${L.btn} ${L.stop}`,onClick:Oe,children:[`■ `,e(`chat.stopGeneration`)]}):(0,A.jsx)(`button`,{className:`${L.btn} ${L.send}`,onClick:De,disabled:!l.trim()&&!m&&!g,children:`Send ↵`})]})]})]}),re&&te&&(0,A.jsxs)(`div`,{className:L.canvasPanel,children:[(0,A.jsxs)(`div`,{className:L.canvasPanelHeader,children:[(0,A.jsx)(`span`,{children:`Canvas`}),(0,A.jsxs)(`div`,{className:L.canvasPanelActions,children:[(0,A.jsx)(`button`,{className:L.canvasPanelBtn,onClick:()=>{let e=new Blob([te],{type:`text/html`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`NHA-Canvas.html`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),5e3)},children:`↓ Download`}),(0,A.jsx)(`button`,{className:L.canvasPanelBtn,onClick:()=>navigator.clipboard.writeText(te).catch(()=>{}),children:`Copy HTML`}),(0,A.jsx)(`button`,{className:L.canvasPanelClose,onClick:()=>k(!1),children:`×`})]})]}),(0,A.jsx)(`iframe`,{className:L.canvasFrame,sandbox:`allow-scripts`,srcDoc:te,title:`Canvas`})]})]})}var R={root:`_root_wxaq6_1`,header:`_header_wxaq6_8`,headerLeft:`_headerLeft_wxaq6_18`,title:`_title_wxaq6_20`,subtitle:`_subtitle_wxaq6_27`,headerActions:`_headerActions_wxaq6_33`,tokenBar:`_tokenBar_wxaq6_40`,tokIn:`_tokIn_wxaq6_48`,tokOut:`_tokOut_wxaq6_49`,tokTotal:`_tokTotal_wxaq6_50`,tokDim:`_tokDim_wxaq6_51`,sessionsBtn:`_sessionsBtn_wxaq6_53`,pdfBtn:`_pdfBtn_wxaq6_65`,clearBtn:`_clearBtn_wxaq6_75`,sessionsDrawer:`_sessionsDrawer_wxaq6_88`,noSessions:`_noSessions_wxaq6_96`,sessionItem:`_sessionItem_wxaq6_103`,sessionInfo:`_sessionInfo_wxaq6_113`,sessionTask:`_sessionTask_wxaq6_119`,sessionMeta:`_sessionMeta_wxaq6_129`,sessionBtns:`_sessionBtns_wxaq6_135`,importBtn:`_importBtn_wxaq6_141`,delSessionBtn:`_delSessionBtn_wxaq6_151`,inputArea:`_inputArea_wxaq6_162`,inputRow:`_inputRow_wxaq6_171`,taskInput:`_taskInput_wxaq6_177`,inputControls:`_inputControls_wxaq6_192`,runBtn:`_runBtn_wxaq6_198`,stopBtn:`_stopBtn_wxaq6_211`,attachBtn:`_attachBtn_wxaq6_222`,attachBadge:`_attachBadge_wxaq6_235`,clearAttach:`_clearAttach_wxaq6_248`,examples:`_examples_wxaq6_257`,exampleBtn:`_exampleBtn_wxaq6_263`,body:`_body_wxaq6_281`,pipeline:`_pipeline_wxaq6_291`,pipelineRunning:`_pipelineRunning_wxaq6_304`,scanSweep:`_scanSweep_wxaq6_1`,pipelineTitle:`_pipelineTitle_wxaq6_326`,pipelineNodes:`_pipelineNodes_wxaq6_334`,pipelineStep:`_pipelineStep_wxaq6_341`,arrow:`_arrow_wxaq6_347`,arrowActive:`_arrowActive_wxaq6_356`,arrowPulse:`_arrowPulse_wxaq6_1`,agentChar:`_agentChar_wxaq6_368`,charWaiting:`_charWaiting_wxaq6_383`,charActive:`_charActive_wxaq6_388`,charCardPulse:`_charCardPulse_wxaq6_1`,charDone:`_charDone_wxaq6_396`,charError:`_charError_wxaq6_401`,orbitRing1:`_orbitRing1_wxaq6_412`,orbitRing2:`_orbitRing2_wxaq6_413`,orbitSpin1:`_orbitSpin1_wxaq6_1`,orbitSpin2:`_orbitSpin2_wxaq6_1`,charAvatar:`_charAvatar_wxaq6_459`,charIcon:`_charIcon_wxaq6_474`,iconBob:`_iconBob_wxaq6_1`,charCheck:`_charCheck_wxaq6_491`,badgePop:`_badgePop_wxaq6_1`,charErr:`_charErr_wxaq6_401`,charPulse:`_charPulse_wxaq6_535`,charPulse2:`_charPulse2_wxaq6_536`,expandRing:`_expandRing_wxaq6_1`,charLabel:`_charLabel_wxaq6_555`,charStatus:`_charStatus_wxaq6_567`,charStatusDots:`_charStatusDots_wxaq6_580`,dot1:`_dot1_wxaq6_581`,dot2:`_dot2_wxaq6_581`,dot3:`_dot3_wxaq6_581`,dotFade:`_dotFade_wxaq6_1`,twoCol:`_twoCol_wxaq6_595`,panelTitle:`_panelTitle_wxaq6_602`,logPanel:`_logPanel_wxaq6_612`,logBody:`_logBody_wxaq6_624`,logEntry:`_logEntry_wxaq6_632`,logTime:`_logTime_wxaq6_642`,logIcon:`_logIcon_wxaq6_643`,logAgent:`_logAgent_wxaq6_644`,logText:`_logText_wxaq6_645`,log_system:`_log_system_wxaq6_647`,log_error:`_log_error_wxaq6_648`,liveOutputPanel:`_liveOutputPanel_wxaq6_651`,liveBlock:`_liveBlock_wxaq6_657`,blockSlideIn:`_blockSlideIn_wxaq6_1`,liveBlockActive:`_liveBlockActive_wxaq6_671`,liveBlockHeader:`_liveBlockHeader_wxaq6_676`,liveBlockIcon:`_liveBlockIcon_wxaq6_685`,liveBlockLabel:`_liveBlockLabel_wxaq6_687`,outputStatus:`_outputStatus_wxaq6_695`,status_done:`_status_done_wxaq6_706`,status_running:`_status_running_wxaq6_707`,status_error:`_status_error_wxaq6_708`,status_waiting:`_status_waiting_wxaq6_709`,liveBlockBody:`_liveBlockBody_wxaq6_712`,studioBlinkCursor:`_studioBlinkCursor_wxaq6_1`,resultAccordion:`_resultAccordion_wxaq6_866`,resultAccordionSummary:`_resultAccordionSummary_wxaq6_873`,resultAccordionBody:`_resultAccordionBody_wxaq6_890`,financeSection:`_financeSection_wxaq6_924`,financeSectionTitle:`_financeSectionTitle_wxaq6_932`,financePresets:`_financePresets_wxaq6_941`,financeBtn:`_financeBtn_wxaq6_947`,canvasToggleBtn:`_canvasToggleBtn_wxaq6_965`,canvasPanel:`_canvasPanel_wxaq6_981`,canvasPanelHeader:`_canvasPanelHeader_wxaq6_996`,canvasPanelActions:`_canvasPanelActions_wxaq6_1008`,canvasPanelBtn:`_canvasPanelBtn_wxaq6_1014`,canvasPanelClose:`_canvasPanelClose_wxaq6_1026`,canvasFrame:`_canvasFrame_wxaq6_1037`,pipelineLiveTag:`_pipelineLiveTag_wxaq6_1045`,liveTagBlink:`_liveTagBlink_wxaq6_1`,reasonRow:`_reasonRow_wxaq6_1059`,reasonChip:`_reasonChip_wxaq6_1068`,reasonIcon:`_reasonIcon_wxaq6_1081`,reasonText:`_reasonText_wxaq6_1082`,liveBlockReason:`_liveBlockReason_wxaq6_1085`,councilWrapper:`_councilWrapper_wxaq6_1095`,councilPanel:`_councilPanel_wxaq6_1100`,councilHeader:`_councilHeader_wxaq6_1108`,councilHeaderLeft:`_councilHeaderLeft_wxaq6_1119`,councilHeaderRight:`_councilHeaderRight_wxaq6_1125`,councilIcon:`_councilIcon_wxaq6_1131`,councilTitle:`_councilTitle_wxaq6_1133`,councilConvergedBadge:`_councilConvergedBadge_wxaq6_1142`,councilDivergedBadge:`_councilDivergedBadge_wxaq6_1154`,councilPhaseTag:`_councilPhaseTag_wxaq6_1166`,councilPhaseActive:`_councilPhaseActive_wxaq6_1172`,phaseGlow:`_phaseGlow_wxaq6_1`,councilPhaseDone:`_councilPhaseDone_wxaq6_1181`,councilMetrics:`_councilMetrics_wxaq6_1184`,convRow:`_convRow_wxaq6_1192`,convLabel:`_convLabel_wxaq6_1198`,convTrack:`_convTrack_wxaq6_1206`,convFill:`_convFill_wxaq6_1214`,convPct:`_convPct_wxaq6_1220`,councilNodes:`_councilNodes_wxaq6_1230`,councilSectionTitle:`_councilSectionTitle_wxaq6_1235`,councilNode:`_councilNode_wxaq6_1230`,councilNodeHeader:`_councilNodeHeader_wxaq6_1252`,councilNodeIcon:`_councilNodeIcon_wxaq6_1265`,councilNodeLabel:`_councilNodeLabel_wxaq6_1266`,councilNodeToggle:`_councilNodeToggle_wxaq6_1267`,councilNodeBody:`_councilNodeBody_wxaq6_1269`,councilSynthesis:`_councilSynthesis_wxaq6_1279`,councilSynthesisHeader:`_councilSynthesisHeader_wxaq6_1283`,heraldIcon:`_heraldIcon_wxaq6_1292`,heraldLabel:`_heraldLabel_wxaq6_1294`,heraldStreaming:`_heraldStreaming_wxaq6_1302`,councilSynthesisBody:`_councilSynthesisBody_wxaq6_1304`,councilSkipped:`_councilSkipped_wxaq6_1334`,councilSkipIcon:`_councilSkipIcon_wxaq6_1345`,charSpriteRunning:`_charSpriteRunning_wxaq6_1358`,spriteWalk:`_spriteWalk_wxaq6_1`,charSpriteDone:`_charSpriteDone_wxaq6_1367`,charScanline:`_charScanline_wxaq6_1371`,scanlineScroll:`_scanlineScroll_wxaq6_1`,auraAnim:`_auraAnim_wxaq6_1391`,auraGlow:`_auraGlow_wxaq6_1`,parliamentPrompt:`_parliamentPrompt_wxaq6_1398`,parliamentPromptIcon:`_parliamentPromptIcon_wxaq6_1408`,parliamentPromptContent:`_parliamentPromptContent_wxaq6_1409`,parliamentPromptTitle:`_parliamentPromptTitle_wxaq6_1410`,parliamentPromptDesc:`_parliamentPromptDesc_wxaq6_1411`,parliamentPromptMeta:`_parliamentPromptMeta_wxaq6_1412`,parliamentPromptBtns:`_parliamentPromptBtns_wxaq6_1413`,parliamentActivateBtn:`_parliamentActivateBtn_wxaq6_1414`,parliamentSkipBtn:`_parliamentSkipBtn_wxaq6_1421`,panelTabs:`_panelTabs_wxaq6_1429`,panelTabBtn:`_panelTabBtn_wxaq6_1430`,panelTabActive:`_panelTabActive_wxaq6_1437`,panelEmpty:`_panelEmpty_wxaq6_1439`,browserPanel:`_browserPanel_wxaq6_1448`,browserBar:`_browserBar_wxaq6_1449`,browserInput:`_browserInput_wxaq6_1450`,browserGo:`_browserGo_wxaq6_1457`},ge=[{label:`📈 Full Trading Strategy`,task:`You are a team of senior quantitative analysts and macro traders. Build a complete, actionable trading strategy with the following structure:
|
|
15
15
|
|
|
16
16
|
1. MACRO REGIME ANALYSIS
|
|
17
17
|
- Current macro cycle phase (expansion/peak/contraction/trough) with supporting indicators (yield curve, PMI, CPI trajectory, Fed/ECB policy stance)
|
|
@@ -455,7 +455,7 @@ ${l}
|
|
|
455
455
|
${e.map(e=>`<div class="section"><div class="agent-header"><span class="icon">${e.icon}</span><div class="agent-name">${e.label}</div></div><div class="section-body"><p>${r(e.output)}</p></div></div>`).join(``)}
|
|
456
456
|
${u}
|
|
457
457
|
<div class="footer">NHA Studio · nothumanallowed.com · ${new Date().getFullYear()}</div>
|
|
458
|
-
</body></html>`,f=new Blob([d],{type:`text/html`}),p=URL.createObjectURL(f),m=document.createElement(`a`);m.href=p,m.download=`nha-report-${Date.now()}.html`,m.click(),URL.revokeObjectURL(p);let h=window.open(``,`_blank`,`width=1100,height=800`);h&&(h.document.open(),h.document.write(d),h.document.close(),h.onload=()=>setTimeout(()=>{h.focus(),h.print()},600))},pe=t=>{let n=`**Studio Workflow Result**\n\nTask: ${t.task}\n\nAgents: ${t.nodes.map(e=>e.label).join(` → `)}\n\n---\n\n${t.result}`;try{sessionStorage.setItem(`nha_studio_import`,n)}catch{}e(`chat`)},me=i.some(e=>e.output||e.status===`running`);return(0,A.jsxs)(`div`,{className:R.root,children:[(0,A.jsxs)(`div`,{className:R.header,children:[(0,A.jsxs)(`div`,{className:R.headerLeft,children:[(0,A.jsx)(`div`,{className:R.title,children:`Studio`}),(0,A.jsx)(`div`,{className:R.subtitle,children:`Multi-agent orchestration · Parliament deliberation · Geth Consensus`})]}),(0,A.jsxs)(`div`,{className:R.headerActions,children:[y.in+y.out>0&&(0,A.jsxs)(`div`,{className:R.tokenBar,children:[(0,A.jsxs)(`span`,{className:R.tokIn,children:[`↑ `,y.in.toLocaleString()]}),(0,A.jsx)(`span`,{className:R.tokDim,children:` in `}),(0,A.jsxs)(`span`,{className:R.tokOut,children:[`↓ `,y.out.toLocaleString()]}),(0,A.jsx)(`span`,{className:R.tokDim,children:` out`})]}),(0,A.jsxs)(`button`,{className:R.sessionsBtn,onClick:()=>h(e=>!e),children:[`Sessions (`,f.length,`)`]}),x&&(0,A.jsx)(`button`,{className:R.canvasToggleBtn,onClick:()=>{O(!0),k(`canvas`)},children:`📊 Panel`}),c&&(0,A.jsx)(`button`,{className:R.pdfBtn,onClick:fe,children:`⬇ PDF / HTML`})]})]}),m&&(0,A.jsxs)(`div`,{className:R.sessionsDrawer,children:[f.length===0&&(0,A.jsx)(`div`,{className:R.noSessions,children:`No saved sessions yet.`}),f.map(e=>(0,A.jsxs)(`div`,{className:R.sessionItem,children:[(0,A.jsxs)(`div`,{className:R.sessionInfo,onClick:()=>ue(e),children:[(0,A.jsx)(`div`,{className:R.sessionTask,children:e.task.slice(0,80)}),(0,A.jsxs)(`div`,{className:R.sessionMeta,children:[e.ts.slice(0,16),` · `,e.nodes.length,` agents`,e.council?.phase===`done`?` · 🏛️ Parliament`:``]})]}),(0,A.jsxs)(`div`,{className:R.sessionBtns,children:[(0,A.jsx)(`button`,{className:R.importBtn,onClick:()=>pe(e),children:`→ Chat`}),(0,A.jsx)(`button`,{className:R.delSessionBtn,onClick:()=>L(e.id),children:`✕`})]})]},e.id))]}),(0,A.jsxs)(`div`,{className:R.inputArea,children:[(0,A.jsxs)(`div`,{className:R.inputRow,children:[(0,A.jsx)(`textarea`,{className:R.taskInput,value:n,onChange:e=>r(e.target.value),placeholder:`Describe your task… e.g. Analyze my emails and create a priority action plan`,rows:2,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),I())}}),(0,A.jsxs)(`div`,{className:R.inputControls,children:[u?(0,A.jsx)(`button`,{className:R.stopBtn,onClick:ce,children:`■ Stop`}):(0,A.jsx)(`button`,{className:R.runBtn,onClick:I,disabled:!n.trim(),children:`Run ▶`}),(0,A.jsxs)(`label`,{className:R.attachBtn,title:`Attach PDF or image`,children:[`📎`,(0,A.jsx)(`input`,{type:`file`,accept:`.pdf,.png,.jpg,.jpeg,.gif,.webp`,style:{display:`none`},onChange:e=>F(e.target.files?.[0])})]})]})]}),g&&(0,A.jsxs)(`div`,{className:R.attachBadge,children:[`📎 `,g.name,(0,A.jsx)(`button`,{className:R.clearAttach,onClick:()=>v(null),children:`✕`})]}),!u&&i.length===0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:R.examples,children:ve.map((e,t)=>(0,A.jsx)(`button`,{className:R.exampleBtn,onClick:()=>r(e),children:e},t))}),(0,A.jsxs)(`div`,{className:R.financeSection,children:[(0,A.jsx)(`div`,{className:R.financeSectionTitle,children:`📈 Finance & Trading Workflows`}),(0,A.jsx)(`div`,{className:R.financePresets,children:ge.map((e,t)=>(0,A.jsx)(`button`,{className:R.financeBtn,onClick:()=>{r(e.task),a(e.agents)},children:e.label},t))})]})]})]}),(0,A.jsxs)(`div`,{className:R.body,children:[i.length>0&&(0,A.jsxs)(`div`,{className:`${R.pipeline} ${u?R.pipelineRunning:``}`,children:[(0,A.jsxs)(`div`,{className:R.pipelineTitle,children:[`Agent Pipeline`,u&&(0,A.jsx)(`span`,{className:R.pipelineLiveTag,children:`● LIVE`})]}),(0,A.jsx)(`div`,{className:R.pipelineNodes,children:i.map((e,t)=>(0,A.jsxs)(`div`,{className:R.pipelineStep,children:[(0,A.jsx)(Ce,{node:e}),t<i.length-1&&(0,A.jsx)(`div`,{className:`${R.arrow} ${u?R.arrowActive:``}`,children:`→`})]},t))}),i.some(e=>e.reason)&&(0,A.jsx)(`div`,{className:R.reasonRow,children:i.map((e,t)=>e.reason?(0,A.jsxs)(`div`,{className:R.reasonChip,title:e.reason,children:[(0,A.jsx)(`span`,{className:R.reasonIcon,children:e.icon}),(0,A.jsxs)(`span`,{className:R.reasonText,children:[e.reason.slice(0,60),e.reason.length>60?`…`:``]})]},t):null)})]}),(o.length>0||me)&&(0,A.jsxs)(`div`,{className:R.twoCol,children:[(0,A.jsxs)(`div`,{className:R.logPanel,children:[(0,A.jsx)(`div`,{className:R.panelTitle,children:`Live Log`}),(0,A.jsx)(`div`,{className:R.logBody,ref:ae,children:o.map((e,t)=>(0,A.jsxs)(`div`,{className:`${R.logEntry} ${R[`log_${e.type}`]}`,children:[(0,A.jsx)(`span`,{className:R.logTime,children:e.time}),(0,A.jsx)(`span`,{className:R.logIcon,children:e.icon}),(0,A.jsx)(`span`,{className:R.logAgent,children:e.agent}),(0,A.jsx)(`span`,{className:R.logText,children:e.text})]},t))})]}),(0,A.jsx)(`div`,{className:R.liveOutputPanel,children:i.filter(e=>e.output||e.status===`running`).map((e,t)=>(0,A.jsxs)(`div`,{className:`${R.liveBlock} ${e.status===`running`?R.liveBlockActive:``}`,children:[(0,A.jsxs)(`div`,{className:R.liveBlockHeader,children:[(0,A.jsx)(`span`,{className:R.liveBlockIcon,children:e.icon}),(0,A.jsx)(`span`,{className:R.liveBlockLabel,children:e.label}),e.reason&&(0,A.jsx)(`span`,{className:R.liveBlockReason,title:e.reason,children:`ℹ`}),(0,A.jsx)(`span`,{className:`${R.outputStatus} ${R[`status_${e.status}`]}`,children:e.status})]}),(0,A.jsx)(`div`,{className:R.liveBlockBody,dangerouslySetInnerHTML:{__html:de(e.output)+(e.status===`running`?`<span class="studio-cursor"></span>`:``)}})]},t))})]}),ee&&(0,A.jsxs)(`div`,{className:R.parliamentPrompt,children:[(0,A.jsx)(`div`,{className:R.parliamentPromptIcon,children:`🏛️`}),(0,A.jsxs)(`div`,{className:R.parliamentPromptContent,children:[(0,A.jsx)(`div`,{className:R.parliamentPromptTitle,children:`Attivare il Parlamento?`}),(0,A.jsxs)(`div`,{className:R.parliamentPromptDesc,children:[T.length,` agenti (`,T.map(e=>e.label).join(`, `),`) hanno prodotto output. Il Geth Consensus eseguirà cross-reading, refinement e mediazione HERALD per raggiungere un consenso collettivo.`]}),(0,A.jsxs)(`div`,{className:R.parliamentPromptMeta,children:[`Complessità: `,T.length<=3?`⚡ Rapido (~30s)`:T.length<=5?`⏱ Medio (~60s)`:`🕐 Lungo (~2min)`,`\xA0· Consigliato per task analitici complessi`]})]}),(0,A.jsxs)(`div`,{className:R.parliamentPromptBtns,children:[(0,A.jsx)(`button`,{className:R.parliamentActivateBtn,onClick:le,children:`🏛️ Attiva`}),(0,A.jsx)(`button`,{className:R.parliamentSkipBtn,onClick:()=>te(!1),children:`Salta`})]})]}),C&&!ee&&(0,A.jsx)(`div`,{className:R.councilWrapper,children:(0,A.jsx)(Fe,{council:C})}),c&&!u&&(0,A.jsxs)(`details`,{className:R.resultAccordion,open:i.length<=1,children:[(0,A.jsxs)(`summary`,{className:R.resultAccordionSummary,children:[`Full Combined Report (`,i.filter(e=>e.output&&e.output!==`(no output)`).length,` agents)`]}),(0,A.jsx)(`div`,{className:R.resultAccordionBody,dangerouslySetInnerHTML:{__html:de(c)}})]})]}),D&&(0,A.jsxs)(`div`,{className:R.canvasPanel,children:[(0,A.jsxs)(`div`,{className:R.canvasPanelHeader,children:[(0,A.jsxs)(`div`,{className:R.panelTabs,children:[(0,A.jsx)(`button`,{className:`${R.panelTabBtn} ${re===`canvas`?R.panelTabActive:``}`,onClick:()=>k(`canvas`),children:`📊 Canvas`}),(0,A.jsx)(`button`,{className:`${R.panelTabBtn} ${re===`browser`?R.panelTabActive:``}`,onClick:()=>k(`browser`),children:`🌐 Browser`})]}),(0,A.jsxs)(`div`,{className:R.canvasPanelActions,children:[re===`canvas`&&x&&(0,A.jsx)(`button`,{className:R.canvasPanelBtn,onClick:()=>{let e=new Blob([x],{type:`text/html`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`nha-canvas-report.html`,n.click(),URL.revokeObjectURL(t)},children:`⬇ HTML`}),(0,A.jsx)(`button`,{className:R.canvasPanelClose,onClick:()=>O(!1),children:`✕`})]})]}),re===`canvas`?x?(0,A.jsx)(`iframe`,{className:R.canvasFrame,srcDoc:x,sandbox:`allow-scripts`,title:`Canvas Report`}):(0,A.jsx)(`div`,{className:R.panelEmpty,children:`No canvas report yet. Run a workflow first.`}):(0,A.jsxs)(`div`,{className:R.browserPanel,children:[(0,A.jsxs)(`div`,{className:R.browserBar,children:[(0,A.jsx)(`input`,{className:R.browserInput,value:ie,onChange:e=>j(e.target.value),placeholder:`https://…`,onKeyDown:e=>{e.key===`Enter`&&j(ie)}}),(0,A.jsx)(`button`,{className:R.browserGo,onClick:()=>j(ie),children:`Go`})]}),ie?(0,A.jsx)(`iframe`,{className:R.canvasFrame,src:ie,sandbox:`allow-scripts allow-same-origin allow-forms`,title:`Browser`}):(0,A.jsx)(`div`,{className:R.panelEmpty,children:`Enter a URL above to browse`})]})]})]})}var z={root:`_root_13wnr_2`,hero:`_hero_13wnr_12`,heroLeft:`_heroLeft_13wnr_21`,heroDate:`_heroDate_13wnr_22`,heroTitle:`_heroTitle_13wnr_23`,heroVer:`_heroVer_13wnr_24`,heroUptime:`_heroUptime_13wnr_25`,heroWeather:`_heroWeather_13wnr_27`,wIcon:`_wIcon_13wnr_35`,wInfo:`_wInfo_13wnr_36`,wTemp:`_wTemp_13wnr_37`,wCity:`_wCity_13wnr_38`,wDesc:`_wDesc_13wnr_39`,wEmpty:`_wEmpty_13wnr_40`,kpiRow:`_kpiRow_13wnr_43`,kpi:`_kpi_13wnr_43`,kpiNum:`_kpiNum_13wnr_55`,kpiLbl:`_kpiLbl_13wnr_56`,kpiBar:`_kpiBar_13wnr_57`,kpiFill:`_kpiFill_13wnr_58`,liveGrid:`_liveGrid_13wnr_61`,liveCard:`_liveCard_13wnr_67`,liveHdr:`_liveHdr_13wnr_71`,liveMore:`_liveMore_13wnr_79`,liveRow:`_liveRow_13wnr_81`,liveUnread:`_liveUnread_13wnr_89`,liveTitle:`_liveTitle_13wnr_89`,liveTime:`_liveTime_13wnr_91`,liveBody:`_liveBody_13wnr_95`,liveSub:`_liveSub_13wnr_97`,prio:`_prio_13wnr_99`,prio_high:`_prio_high_13wnr_103`,prio_medium:`_prio_medium_13wnr_104`,prio_low:`_prio_low_13wnr_105`,launcher:`_launcher_13wnr_108`,launchGroup:`_launchGroup_13wnr_115`,launchGroupLabel:`_launchGroupLabel_13wnr_117`,launchTiles:`_launchTiles_13wnr_123`,tile:`_tile_13wnr_129`,tileIcon:`_tileIcon_13wnr_143`,tileLabel:`_tileLabel_13wnr_144`},Le=[{view:`chat`,icon:`💬`,label:`Chat`,color:`#38bdf8`,group:`Panoramica`},{view:`plan`,icon:`🗓️`,label:`Daily Plan`,color:`#818cf8`,group:`Panoramica`},{view:`tasks`,icon:`✅`,label:`Tasks`,color:`#4ade80`,group:`Panoramica`},{view:`email`,icon:`📧`,label:`Email`,color:`#f87171`,group:`Google`},{view:`calendar`,icon:`📅`,label:`Calendar`,color:`#fb923c`,group:`Google`},{view:`drive`,icon:`💾`,label:`Drive`,color:`#facc15`,group:`Google`},{view:`contacts`,icon:`👤`,label:`Contacts`,color:`#34d399`,group:`Google`},{view:`notes`,icon:`📝`,label:`Notes`,color:`#a78bfa`,group:`Google`},{view:`onedrive`,icon:`☁️`,label:`OneDrive`,color:`#60a5fa`,group:`Microsoft`},{view:`mstodo`,icon:`📋`,label:`MS Todo`,color:`#38bdf8`,group:`Microsoft`},{view:`github`,icon:`🐙`,label:`GitHub`,color:`#e2e8f0`,group:`Tools`},{view:`notion`,icon:`📓`,label:`Notion`,color:`#94a3b8`,group:`Tools`},{view:`slack`,icon:`💼`,label:`Slack`,color:`#e879f9`,group:`Tools`},{view:`maps`,icon:`🗺️`,label:`Maps`,color:`#2dd4bf`,group:`Tools`},{view:`reminders`,icon:`🔔`,label:`Reminders`,color:`#fbbf24`,group:`Tools`},{view:`birthdays`,icon:`🎂`,label:`Birthdays`,color:`#f472b6`,group:`Tools`},{view:`cron`,icon:`⏰`,label:`Cron`,color:`#fb923c`,group:`Tools`},{view:`screen`,icon:`🖥️`,label:`Screen`,color:`#64748b`,group:`Tools`},{view:`agents`,icon:`🤖`,label:`Agents`,color:`#4ade80`,group:`AI`},{view:`studio`,icon:`🎭`,label:`Studio`,color:`#a78bfa`,group:`AI`},{view:`webcraft`,icon:`🔨`,label:`WebCraft`,color:`#f59e0b`,group:`AI`},{view:`collab`,icon:`🏛️`,label:`Alexandria`,color:`#38bdf8`,group:`AI`},{view:`connectors`,icon:`🔗`,label:`Connectors`,color:`#94a3b8`,group:`Config`},{view:`settings`,icon:`⚙️`,label:`Settings`,color:`#64748b`,group:`Config`}],Re={Sunny:`☀️`,Clear:`☀️`,"Partly Cloudy":`⛅`,"Partly cloudy":`⛅`,Cloudy:`☁️`,Overcast:`☁️`,"Light rain":`🌧️`,Rain:`🌧️`,Drizzle:`🌧️`,"Moderate rain":`🌧️`,"Heavy rain":`🌧️`,Snow:`❄️`,"Light snow":`❄️`,Fog:`🌫️`,Mist:`🌫️`,Thunder:`⚡`,"Thundery outbreaks":`⚡`};function ze(e){try{return new Date(e).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}catch{return e}}function Be(e){try{return new Date(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`})}catch{return e}}function Ve(){let e=ne(e=>e.setView),t=F(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(new Date);(0,_.useEffect)(()=>{let e=setInterval(()=>p(new Date),6e4);return()=>clearInterval(e)},[]),(0,_.useEffect)(()=>{let e=!0,t=t=>n=>{e&&n!=null&&t(n)};E(`/api/tasks`).then(e=>t(r)(e?.tasks??[])),E(`/api/emails?page=0&pageSize=8`).then(e=>t(a)(e?.emails??[])),E(`/api/calendar`).then(e=>t(s)(e?.events??[])),E(`/api/status`).then(t(l));let n=localStorage.getItem(`nha_weather_location`),i=t=>E(`/api/weather?location=${encodeURIComponent(t)}`).then(t=>{e&&t?.tempC&&d(t)});return n?i(n):navigator.geolocation?.getCurrentPosition(e=>i(`${e.coords.latitude.toFixed(4)},${e.coords.longitude.toFixed(4)}`),()=>{},{timeout:6e3}),()=>{e=!1}},[]);let m=n.filter(e=>e.status!==`done`),h=n.filter(e=>e.status===`done`),g=n.length>0?Math.round(h.length/n.length*100):0,v=i.filter(e=>e.isUnread).length,y=f.toLocaleDateString(`en`,{weekday:`long`,month:`long`,day:`numeric`}),b=[...new Set(Le.map(e=>e.group))];return(0,A.jsxs)(`div`,{className:z.root,children:[(0,A.jsxs)(`div`,{className:z.hero,children:[(0,A.jsxs)(`div`,{className:z.heroLeft,children:[(0,A.jsx)(`div`,{className:z.heroDate,children:y}),(0,A.jsx)(`div`,{className:z.heroTitle,children:c?(0,A.jsxs)(A.Fragment,{children:[`NHA `,(0,A.jsxs)(`span`,{className:z.heroVer,children:[`v`,c.version]}),` · `,(0,A.jsxs)(`span`,{className:z.heroUptime,children:[Math.floor(c.uptime/60),`m uptime`]})]}):`NotHumanAllowed`})]}),(0,A.jsx)(`div`,{className:z.heroWeather,onClick:()=>{let e=prompt(`City or lat,lon:`);e&&(localStorage.setItem(`nha_weather_location`,e),location.reload())},children:u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:z.wIcon,children:Re[u.desc]??u.icon??`🌡️`}),(0,A.jsxs)(`div`,{className:z.wInfo,children:[(0,A.jsxs)(`span`,{className:z.wTemp,children:[u.tempC,`°C`]}),(0,A.jsxs)(`span`,{className:z.wCity,children:[u.city.split(`,`)[0],u.country?`, ${u.country.slice(0,2).toUpperCase()}`:``]}),(0,A.jsxs)(`span`,{className:z.wDesc,children:[u.desc,` · 💧`,u.humidity,`%`]})]})]}):(0,A.jsxs)(`span`,{className:z.wEmpty,children:[`🌡️ `,t(`dashboard.weather`)]})})]}),(0,A.jsxs)(`div`,{className:z.kpiRow,children:[(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:m.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Pending tasks`}),n.length>0&&(0,A.jsx)(`div`,{className:z.kpiBar,children:(0,A.jsx)(`div`,{className:z.kpiFill,style:{width:`${g}%`}})})]}),(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:v>0?v:i.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:v>0?`Unread emails`:`Emails`})]}),(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:o.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Today's events`})]}),u&&(0,A.jsxs)(`div`,{className:z.kpi,children:[(0,A.jsxs)(`span`,{className:z.kpiNum,children:[u.feelsC,`°`]}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Feels like`})]})]}),(0,A.jsxs)(`div`,{className:z.liveGrid,children:[o.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`📅 `,t(`calendar.title`)]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),o.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:z.liveRow,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.liveTime,children:t.isAllDay?`All day`:ze(t.start)}),(0,A.jsxs)(`div`,{className:z.liveBody,children:[(0,A.jsx)(`span`,{className:z.liveTitle,children:t.summary}),t.location&&(0,A.jsx)(`span`,{className:z.liveSub,children:t.location})]})]},n))]}),i.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`📧 `,t(`email.inbox`)]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),i.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:`${z.liveRow} ${t.isUnread?z.liveUnread:``}`,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.liveTime,children:Be(t.date)}),(0,A.jsxs)(`div`,{className:z.liveBody,children:[(0,A.jsx)(`span`,{className:z.liveTitle,children:t.subject}),(0,A.jsx)(`span`,{className:z.liveSub,children:t.from})]})]},n))]}),m.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`✅ `,t(`tasks.title`),` · `,h.length,`/`,n.length,` (`,g,`%)`]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),m.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:z.liveRow,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsx)(`span`,{className:`${z.prio} ${z[`prio_`+t.priority]}`,children:t.priority[0].toUpperCase()}),(0,A.jsx)(`div`,{className:z.liveBody,children:(0,A.jsx)(`span`,{className:z.liveTitle,children:t.description})})]},n))]})]}),(0,A.jsx)(`div`,{className:z.launcher,children:b.map(t=>(0,A.jsxs)(`div`,{className:z.launchGroup,children:[(0,A.jsx)(`div`,{className:z.launchGroupLabel,children:t}),(0,A.jsx)(`div`,{className:z.launchTiles,children:Le.filter(e=>e.group===t).map(t=>(0,A.jsxs)(`button`,{className:z.tile,onClick:()=>e(t.view),style:{"--tc":t.color},children:[(0,A.jsx)(`span`,{className:z.tileIcon,children:t.icon}),(0,A.jsx)(`span`,{className:z.tileLabel,children:t.label})]},t.view))})]},t))})]})}var He={root:`_root_1pldx_1`,loading:`_loading_1pldx_2`,bar:`_bar_1pldx_4`,input:`_input_1pldx_5`,select:`_select_1pldx_6`,addBtn:`_addBtn_1pldx_7`,actions:`_actions_1pldx_10`,clearDone:`_clearDone_1pldx_11`,clearAll:`_clearAll_1pldx_12`,stats:`_stats_1pldx_14`,progress:`_progress_1pldx_15`,progressBar:`_progressBar_1pldx_16`,empty:`_empty_1pldx_18`,task:`_task_1pldx_20`,taskDone:`_taskDone_1pldx_22`,check:`_check_1pldx_23`,checkDone:`_checkDone_1pldx_25`,desc:`_desc_1pldx_26`,del:`_del_1pldx_27`,badge:`_badge_1pldx_30`,badge_high:`_badge_high_1pldx_31`,badge_medium:`_badge_medium_1pldx_32`,badge_low:`_badge_low_1pldx_33`,doneLabel:`_doneLabel_1pldx_35`};function Ue(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(`medium`),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=()=>E(`/api/tasks`).then(e=>{n(e?.tasks??[]),i(!1)});(0,_.useEffect)(()=>{f()},[]);let p=async()=>{a.trim()&&(u(!0),await D(`/api/tasks`,{description:a.trim(),priority:s}),o(``),u(!1),f(),d.current?.focus())},m=e=>D(`/api/tasks/${e}/done`,{},`PATCH`).then(f),h=e=>D(`/api/tasks/${e}/delete`,{}).then(f),g=()=>D(`/api/tasks/clear`,{filter:`done`}).then(f),v=()=>{confirm(e(`tasks.deleteTask`))&&D(`/api/tasks/clear`,{filter:`all`}).then(f)},y=t.filter(e=>e.status!==`done`),b=t.filter(e=>e.status===`done`);return r?(0,A.jsxs)(`div`,{className:He.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):(0,A.jsxs)(`div`,{className:He.root,children:[(0,A.jsxs)(`div`,{className:He.bar,children:[(0,A.jsx)(`input`,{ref:d,className:He.input,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&p(),placeholder:e(`tasks.newTask`)}),(0,A.jsxs)(`select`,{className:He.select,value:s,onChange:e=>c(e.target.value),children:[(0,A.jsx)(`option`,{value:`high`,children:`High`}),(0,A.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,A.jsx)(`option`,{value:`low`,children:`Low`})]}),(0,A.jsx)(`button`,{className:He.addBtn,onClick:p,disabled:l||!a.trim(),children:l?`…`:`+ `+e(`common.add`)})]}),t.length>0&&(0,A.jsxs)(`div`,{className:He.actions,children:[(0,A.jsx)(`button`,{className:He.clearDone,onClick:g,children:`Clear completed`}),(0,A.jsx)(`button`,{className:He.clearAll,onClick:v,children:`Clear all`})]}),t.length>0&&(0,A.jsxs)(`div`,{className:He.stats,children:[y.length,` pending · `,b.length,` done`,t.length>0&&(0,A.jsx)(`span`,{className:He.progress,children:(0,A.jsx)(`span`,{className:He.progressBar,style:{width:`${Math.round(b.length/t.length*100)}%`}})})]}),y.length===0&&b.length===0&&(0,A.jsx)(`div`,{className:He.empty,children:`No tasks yet. Add one above ↑`}),y.map(e=>(0,A.jsxs)(`div`,{className:He.task,children:[(0,A.jsx)(`span`,{className:He.check,onClick:()=>m(e.id)}),(0,A.jsx)(`span`,{className:He.desc,onClick:()=>m(e.id),children:e.description}),(0,A.jsx)(`span`,{className:`${He.badge} ${He[`badge_`+e.priority]}`,children:e.priority}),(0,A.jsx)(`span`,{className:He.del,onClick:()=>h(e.id),children:`×`})]},e.id)),b.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:He.doneLabel,children:`Completed`}),b.map(e=>(0,A.jsxs)(`div`,{className:`${He.task} ${He.taskDone}`,children:[(0,A.jsx)(`span`,{className:`${He.check} ${He.checkDone}`,onClick:()=>m(e.id),children:`✓`}),(0,A.jsx)(`span`,{className:He.desc,onClick:()=>m(e.id),children:e.description}),(0,A.jsx)(`span`,{className:`${He.badge} ${He[`badge_`+e.priority]}`,children:e.priority}),(0,A.jsx)(`span`,{className:He.del,onClick:()=>h(e.id),children:`×`})]},e.id))]})]})}var B={root:`_root_1jj88_1`,loading:`_loading_1jj88_2`,card:`_card_1jj88_4`,cardTitle:`_cardTitle_1jj88_5`,cardTitleRow:`_cardTitleRow_1jj88_6`,cardSub:`_cardSub_1jj88_7`,connected:`_connected_1jj88_8`,statusMsg:`_statusMsg_1jj88_9`,fields:`_fields_1jj88_11`,field:`_field_1jj88_11`,fieldLabel:`_fieldLabel_1jj88_13`,fieldInput:`_fieldInput_1jj88_14`,saveBtn:`_saveBtn_1jj88_17`,dangerBtn:`_dangerBtn_1jj88_18`,cancelBtn:`_cancelBtn_1jj88_19`,btnRow:`_btnRow_1jj88_20`,keySet:`_keySet_1jj88_22`,nhaFree:`_nhaFree_1jj88_24`,nhaFreeTitle:`_nhaFreeTitle_1jj88_25`,nhaFreeSub:`_nhaFreeSub_1jj88_26`,nhaFreeBtn:`_nhaFreeBtn_1jj88_27`,imapRow:`_imapRow_1jj88_29`,imapName:`_imapName_1jj88_30`,imapMeta:`_imapMeta_1jj88_31`,imapStatus:`_imapStatus_1jj88_32`,imapBtns:`_imapBtns_1jj88_36`,imapSyncBtn:`_imapSyncBtn_1jj88_37`,imapEditBtn:`_imapEditBtn_1jj88_38`,imapDelBtn:`_imapDelBtn_1jj88_39`,emptyImap:`_emptyImap_1jj88_40`,imapForm:`_imapForm_1jj88_42`,imapFormTitle:`_imapFormTitle_1jj88_43`,pwdNote:`_pwdNote_1jj88_44`,pwdRow:`_pwdRow_1jj88_45`,togglePwd:`_togglePwd_1jj88_46`},We={id:``,display_name:``,email_address:``,from_name:``,imap_host:``,imap_port:`993`,smtp_host:``,smtp_port:`587`,username:``,password:``};function Ge({id:e,label:t,placeholder:n,value:r,onChange:i,type:a=`text`}){return(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t}),(0,A.jsx)(`input`,{id:e,type:a,placeholder:n,value:r,onChange:e=>i(e.target.value),className:B.fieldInput})]})}function Ke(){let{setConfig:e}=ne(),t=F(),[n,r]=(0,_.useState)({}),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)({name:``,email:``,phone:``,homeAddress:``,workAddress:``,city:``,country:``,company:``,role:``,notes:``}),[C,w]=(0,_.useState)(`nha`),[ee,te]=(0,_.useState)(``),[T,O]=(0,_.useState)(``),[re,k]=(0,_.useState)(`en`),[ie,j]=(0,_.useState)(`07:00`),[M,ae]=(0,_.useState)(`18:00`),[oe,N]=(0,_.useState)(`30`),[se,P]=(0,_.useState)(`off`),[I,ce]=(0,_.useState)(``),[le,ue]=(0,_.useState)(``);(0,_.useEffect)(()=>{E(`/api/config`).then(t=>{r(t??{});let n=t?.profile??{};S({name:n.name??``,email:n.email??``,phone:n.phone??``,homeAddress:n.homeAddress??``,workAddress:n.workAddress??``,city:n.city??``,country:n.country??``,company:n.company??``,role:n.role??``,notes:n.notes??``}),w(t?.provider??`nha`),O(t?.model??``),k(t?.lang??`en`),j(t?.planTime??`07:00`),ae(t?.summaryTime??`18:00`),N(String(t?.meetingAlert??`30`)),P(t?.thinking??`off`),te(``),a(!1),t&&e(t)}),de()},[]);let de=()=>E(`/api/imap/accounts`).then(e=>d(e?.accounts??[])),L=async(e,t)=>{s(e),await D(`/api/config`,{key:e,value:t}),l(e),s(null),setTimeout(()=>l(null),2e3)},fe=()=>L(`profile`,x),pe=()=>{L(`provider`,C),L(`model`,T),L(`thinking`,se),ee&&L(`key`,ee)},me=()=>{L(`planTime`,ie),L(`summaryTime`,M),L(`meetingAlert`,Number(oe))},he=()=>{v(t(`settings.googleOpening`)),D(`/api/google/auth`,{}).then(e=>{e?.url?(window.open(e.url,`_blank`),v(t(`settings.googleOpened`))):e?.error&&v(t(`common.error`)+`: `+e.error)}).catch(e=>v(t(`common.error`)+`: `+e.message))},R=()=>{confirm(t(`settings.disconnectGoogleConfirm`))&&D(`/api/google/revoke`,{}).then(()=>{r(e=>({...e,hasGoogle:!1})),v(t(`common.disconnected`))})},ge=()=>{if(!f)return;let e=!!f.id,t={display_name:f.display_name,email_address:f.email_address,from_name:f.from_name,imap_host:f.imap_host,imap_port:Number(f.imap_port),smtp_host:f.smtp_host,smtp_port:Number(f.smtp_port),username:f.username};f.password&&(t.password=f.password),e&&(t.id=f.id),h(`Saving…`),D(e?`/api/imap/accounts/update`:`/api/imap/accounts`,t).then(e=>{e?.ok||e?.id?(h(`Saved!`),p(null),de()):h(`Error: `+(e?.error??`Unknown error`))}).catch(e=>h(`Error: `+e.message))},_e=(e,n)=>{confirm(t(`settings.imapDelete`,{name:n}))&&D(`/api/imap/accounts/delete`,{id:e}).then(()=>de())},ve=e=>{D(`/api/imap/sync`,{accountId:e}).then(()=>setTimeout(de,3e3))};if(i)return(0,A.jsxs)(`div`,{className:B.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),t(`common.loading`)]});let ye=e=>t(o===e?`common.saving`:c===e?`common.saved`:`common.save`);return(0,A.jsxs)(`div`,{className:B.root,children:[(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.profile`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.profileSub`)}),(0,A.jsx)(`div`,{className:B.fields,children:[[`name`,t(`settings.name`),t(`settings.namePh`)],[`email`,t(`common.email`),t(`settings.emailPh`)],[`phone`,t(`common.phone`),t(`settings.phonePh`)],[`homeAddress`,t(`settings.homeAddress`),t(`settings.homeAddressPh`)],[`workAddress`,t(`settings.workAddress`),t(`settings.workAddressPh`)],[`city`,t(`settings.city`),t(`settings.cityPh`)],[`country`,t(`settings.country`),t(`settings.countryPh`)],[`company`,t(`settings.company`),t(`settings.companyPh`)],[`role`,t(`settings.role`),t(`settings.rolePh`)],[`notes`,t(`settings.notes`),t(`settings.notesPh`)]].map(([e,t,n])=>(0,A.jsx)(Ge,{id:e,label:t,placeholder:n,value:x[e],onChange:t=>S(n=>({...n,[e]:t}))},e))}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:fe,children:[ye(`profile`),` `,t(`settings.saveProfile`)]})]}),(0,A.jsxs)(`div`,{className:B.nhaFree,children:[(0,A.jsx)(`div`,{className:B.nhaFreeTitle,children:t(`settings.nhaFreeTitle`)}),(0,A.jsx)(`div`,{className:B.nhaFreeSub,children:t(`settings.nhaFreeSub`)}),(0,A.jsx)(`button`,{className:B.nhaFreeBtn,onClick:()=>{D(`/api/config`,{updates:[{key:`provider`,value:`nha`},{key:`model`,value:``},{key:`key`,value:``}]}).then(()=>{w(`nha`),O(``),te(``),l(`nhaFree`),setTimeout(()=>l(null),2e3)})},children:t(c===`nhaFree`?`settings.liaraActivated`:`settings.useLiara`)})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.llmProvider`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.llmProviderSub`)}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.provider`)}),(0,A.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),className:B.fieldInput,children:[(0,A.jsx)(`option`,{value:`nha`,children:`NHA Free (Liara) — no API key needed`}),(0,A.jsx)(`option`,{value:`anthropic`,children:`Anthropic (Claude)`}),(0,A.jsx)(`option`,{value:`openai`,children:`OpenAI (GPT-4)`}),(0,A.jsx)(`option`,{value:`gemini`,children:`Google (Gemini)`}),(0,A.jsx)(`option`,{value:`deepseek`,children:`DeepSeek`}),(0,A.jsx)(`option`,{value:`grok`,children:`xAI (Grok)`}),(0,A.jsx)(`option`,{value:`mistral`,children:`Mistral`}),(0,A.jsx)(`option`,{value:`cohere`,children:`Cohere`})]})]}),C!==`nha`&&({anthropic:n.hasApiKey,openai:n.hasOpenaiKey,gemini:n.hasGeminiKey,deepseek:n.hasDeepseekKey,grok:n.hasGrokKey,mistral:n.hasMistralKey,cohere:n.hasCohereKey}[C]?(0,A.jsx)(`div`,{className:B.keySet,children:t(`settings.apiKeySet`)}):null),(0,A.jsx)(Ge,{id:`apiKey`,label:t(`settings.apiKey`),placeholder:t(C===`nha`?`settings.apiKeyFreeNote`:`settings.apiKeyPh`),type:`password`,value:ee,onChange:te}),(0,A.jsx)(Ge,{id:`model`,label:t(`settings.model`),placeholder:t(`settings.modelPh`),value:T,onChange:O}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.thinking`)}),(0,A.jsxs)(`select`,{value:se,onChange:e=>P(e.target.value),className:B.fieldInput,children:[(0,A.jsx)(`option`,{value:`off`,children:t(`settings.thinkingOff`)}),(0,A.jsx)(`option`,{value:`on`,children:t(`settings.thinkingOn`)})]})]}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:pe,children:[ye(`provider`),` `,t(`settings.saveProvider`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.language`)}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.languageLabel`)}),(0,A.jsx)(`select`,{value:re,onChange:t=>{let r=t.target.value;k(r),L(`lang`,r),e({...n,lang:r})},className:B.fieldInput,children:[[`it`,`Italiano`],[`en`,`English`],[`es`,`Español`],[`fr`,`Français`],[`de`,`Deutsch`],[`pt`,`Português`],[`nl`,`Nederlands`],[`pl`,`Polski`],[`ru`,`Русский`],[`zh`,`中文`],[`ja`,`日本語`],[`ko`,`한국어`],[`ar`,`العربية`],[`hi`,`हिन्दी`],[`tr`,`Türkçe`],[`sv`,`Svenska`],[`da`,`Dansk`],[`fi`,`Suomi`],[`cs`,`Čeština`]].map(([e,t])=>(0,A.jsx)(`option`,{value:e,children:t},e))})]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.telegram`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.telegramSub`)}),n.hasTelegram&&(0,A.jsxs)(`div`,{className:B.connected,children:[`Telegram: `,t(`common.connected`)]}),n.hasDiscord&&(0,A.jsxs)(`div`,{className:B.connected,children:[`Discord: `,t(`common.connected`)]}),(0,A.jsx)(Ge,{id:`tgToken`,label:t(`settings.telegramToken`),placeholder:n.hasTelegram?t(`settings.telegramSet`):t(`settings.telegramPh`),type:`password`,value:I,onChange:ce}),(0,A.jsx)(Ge,{id:`discordToken`,label:t(`settings.discordToken`),placeholder:n.hasDiscord?t(`settings.discordSet`):t(`settings.discordPh`),type:`password`,value:le,onChange:ue}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:()=>{I&&L(`telegram-bot-token`,I),le&&L(`discord-bot-token`,le)},children:[ye(`telegram-bot-token`),` `,t(`settings.saveBots`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.dailyOps`)}),(0,A.jsx)(Ge,{id:`planTime`,label:t(`settings.planTime`),placeholder:`07:00`,value:ie,onChange:j}),(0,A.jsx)(Ge,{id:`summaryTime`,label:t(`settings.summaryTime`),placeholder:`18:00`,value:M,onChange:ae}),(0,A.jsx)(Ge,{id:`meetingAlert`,label:t(`settings.meetingAlert`),placeholder:`30`,value:oe,onChange:N}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:me,children:[ye(`planTime`),` `,t(`settings.saveSchedule`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.googleAccount`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.googleSub`)}),n.hasGoogle&&(0,A.jsxs)(`div`,{className:B.connected,children:[`✅ `,t(`common.connected`),n.googleEmail?` · ${n.googleEmail}`:``]}),(0,A.jsxs)(`div`,{className:B.btnRow,children:[(0,A.jsx)(`button`,{className:B.saveBtn,onClick:he,children:n.hasGoogle?t(`settings.reconnectGoogle`):t(`settings.connectGoogle`)}),n.hasGoogle&&(0,A.jsx)(`button`,{className:B.dangerBtn,onClick:R,children:t(`settings.disconnectGoogle`)})]}),g&&(0,A.jsx)(`div`,{className:B.statusMsg,children:g})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsxs)(`div`,{className:B.cardTitleRow,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.imapAccounts`)}),(0,A.jsx)(`button`,{className:B.saveBtn,onClick:()=>{p({...We}),h(``)},children:t(`settings.addAccount`)})]}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.imapSub`)}),u.length===0&&!f&&(0,A.jsx)(`div`,{className:B.emptyImap,children:t(`settings.noImapAccounts`)}),u.map(e=>(0,A.jsxs)(`div`,{className:B.imapRow,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:B.imapName,children:e.display_name}),(0,A.jsxs)(`div`,{className:B.imapMeta,children:[e.email_address,` · `,e.imap_host]}),(0,A.jsxs)(`div`,{className:B.imapStatus,"data-status":e.sync_status,children:[e.sync_status,e.last_sync_at?` · ${t(`email.lastSync`)}: ${e.last_sync_at.slice(0,16)}`:``]})]}),(0,A.jsxs)(`div`,{className:B.imapBtns,children:[(0,A.jsx)(`button`,{className:B.imapSyncBtn,onClick:()=>ve(e.id),children:t(`settings.sync`)}),(0,A.jsx)(`button`,{className:B.imapEditBtn,onClick:()=>{p({...We,id:e.id,display_name:e.display_name,email_address:e.email_address,from_name:e.from_name??``,imap_host:e.imap_host,imap_port:String(e.imap_port??993),smtp_host:e.smtp_host??``,smtp_port:String(e.smtp_port??587),username:e.username??``,password:``}),h(``)},children:t(`common.edit`)}),(0,A.jsx)(`button`,{className:B.imapDelBtn,onClick:()=>_e(e.id,e.display_name),children:t(`common.delete`)})]})]},e.id)),f&&(0,A.jsxs)(`div`,{className:B.imapForm,children:[(0,A.jsx)(`div`,{className:B.imapFormTitle,children:f.id?t(`settings.editImapAccount`):t(`settings.addImapAccount`)}),[[`display_name`,t(`settings.displayName`),t(`settings.displayNamePh`)],[`email_address`,t(`common.email`),`user@example.com`],[`from_name`,t(`settings.fromName`),t(`settings.fromNamePh`)],[`imap_host`,t(`settings.imapServer`),`e.g. imap.gmail.com`],[`imap_port`,t(`settings.imapPort`),`993`],[`smtp_host`,t(`settings.smtpServer`),`e.g. smtp.gmail.com`],[`smtp_port`,t(`settings.smtpPort`),`587`],[`username`,t(`settings.username`),`user@example.com`]].map(([e,t,n])=>(0,A.jsx)(Ge,{id:`imap_${e}`,label:t,placeholder:n,value:f[e],onChange:t=>p(n=>n&&{...n,[e]:t})},e)),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsxs)(`label`,{className:B.fieldLabel,children:[t(`settings.password`),` `,f.id&&(0,A.jsx)(`span`,{className:B.pwdNote,children:t(`settings.passwordKeep`)})]}),(0,A.jsxs)(`div`,{className:B.pwdRow,children:[(0,A.jsx)(`input`,{type:y?`text`:`password`,placeholder:t(`settings.passwordPh`),value:f.password,onChange:e=>p(t=>t&&{...t,password:e.target.value}),className:B.fieldInput,style:{flex:1}}),(0,A.jsx)(`button`,{className:B.togglePwd,onClick:()=>b(e=>!e),children:t(y?`settings.hide`:`settings.show`)})]})]}),(0,A.jsxs)(`div`,{className:B.btnRow,children:[(0,A.jsx)(`button`,{className:B.saveBtn,onClick:ge,children:t(`common.save`)}),(0,A.jsx)(`button`,{className:B.cancelBtn,onClick:()=>p(null),children:t(`common.cancel`)})]}),m&&(0,A.jsx)(`div`,{className:B.statusMsg,children:m})]})]})]})}var qe={root:`_root_o07ov_1`,loading:`_loading_o07ov_2`,err:`_err_o07ov_3`,header:`_header_o07ov_4`,title:`_title_o07ov_5`,addBtn:`_addBtn_o07ov_6`,empty:`_empty_o07ov_7`,card:`_card_o07ov_8`,cardToday:`_cardToday_o07ov_9`,icon:`_icon_o07ov_10`,info:`_info_o07ov_11`,name:`_name_o07ov_12`,date:`_date_o07ov_13`,labelToday:`_labelToday_o07ov_14`,labelTomorrow:`_labelTomorrow_o07ov_15`,labelFuture:`_labelFuture_o07ov_16`,editBtn:`_editBtn_o07ov_17`,delBtn:`_delBtn_o07ov_18`,overlay:`_overlay_o07ov_20`,modal:`_modal_o07ov_21`,modalTitle:`_modalTitle_o07ov_22`,label:`_label_o07ov_14`,input:`_input_o07ov_24`,hint:`_hint_o07ov_25`,formErr:`_formErr_o07ov_26`,modalBtns:`_modalBtns_o07ov_27`,cancelBtn:`_cancelBtn_o07ov_28`,saveBtn:`_saveBtn_o07ov_29`};function Je(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),p=(0,_.useCallback)(()=>{i(!0),E(`/api/birthdays`).then(e=>{e?.error?o(e.error):n(e?.birthdays??[]),i(!1)})},[]);(0,_.useEffect)(()=>{p()},[p]);let m=()=>{c({name:``,date:``}),u(``)},h=e=>{c({name:e.name,date:e.date,contactId:e.contactId}),u(``)},g=async()=>{if(!s)return;if(!s.name.trim()){u(`Name is required`);return}if(!s.date.trim()){u(`Date is required`);return}f(!0);let e=s.date;/^\d{2}-\d{2}$/.test(e)&&(e=`${new Date().getFullYear()}-${e}`),await D(`/api/birthdays`,{name:s.name,date:e,contactId:s.contactId??null,edit:!!s.contactId}),f(!1),c(null),p()},v=e=>{confirm(`Remove birthday for ${e.name}?`)&&D(`/api/birthdays/delete`,{contactId:e.contactId}).then(p)};return r?(0,A.jsxs)(`div`,{className:qe.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,A.jsx)(`div`,{className:qe.err,children:a}):(0,A.jsxs)(`div`,{className:qe.root,children:[(0,A.jsxs)(`div`,{className:qe.header,children:[(0,A.jsx)(`div`,{className:qe.title,children:`Upcoming Birthdays`}),(0,A.jsx)(`button`,{className:qe.addBtn,onClick:m,children:`+ Add Birthday`})]}),t.length===0&&(0,A.jsxs)(`div`,{className:qe.empty,children:[e(`birthdays.noBirthdays`),(0,A.jsx)(`br`,{}),(0,A.jsx)(`small`,{children:`Add one above, or add birthdays to your Google Contacts.`})]}),t.map((t,n)=>{let r=t.daysUntil===0,i=t.daysUntil===1;return(0,A.jsxs)(`div`,{className:`${qe.card} ${r?qe.cardToday:``}`,children:[(0,A.jsx)(`span`,{className:qe.icon,children:`🎂`}),(0,A.jsxs)(`div`,{className:qe.info,children:[(0,A.jsx)(`div`,{className:qe.name,children:t.name}),(0,A.jsx)(`div`,{className:qe.date,children:t.date})]}),(0,A.jsx)(`div`,{className:r?qe.labelToday:i?qe.labelTomorrow:qe.labelFuture,children:r?`TODAY!`:i?`Tomorrow`:`in ${t.daysUntil} days`}),t.contactId&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:qe.editBtn,onClick:()=>h(t),children:e(`common.edit`)}),(0,A.jsx)(`button`,{className:qe.delBtn,onClick:()=>v(t),children:e(`common.delete`)})]})]},n)}),s&&(0,A.jsx)(`div`,{className:qe.overlay,onClick:e=>{e.target===e.currentTarget&&c(null)},children:(0,A.jsxs)(`div`,{className:qe.modal,children:[(0,A.jsx)(`div`,{className:qe.modalTitle,children:s.contactId?`Edit Birthday`:`Add Birthday`}),(0,A.jsx)(`label`,{className:qe.label,children:`Name *`}),(0,A.jsx)(`input`,{className:qe.input,value:s.name,onChange:e=>c(t=>t&&{...t,name:e.target.value}),placeholder:`Contact name`}),(0,A.jsx)(`label`,{className:qe.label,children:`Birthday (MM-DD or YYYY-MM-DD)`}),(0,A.jsx)(`input`,{className:qe.input,value:s.date,onChange:e=>c(t=>t&&{...t,date:e.target.value}),placeholder:`e.g. 03-15 or 1990-03-15`}),(0,A.jsx)(`div`,{className:qe.hint,children:`Birthday will be saved as a Google Calendar event.`}),l&&(0,A.jsx)(`div`,{className:qe.formErr,children:l}),(0,A.jsxs)(`div`,{className:qe.modalBtns,children:[(0,A.jsx)(`button`,{className:qe.cancelBtn,onClick:()=>c(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:qe.saveBtn,onClick:g,disabled:d,children:d?`Saving…`:s.contactId?`Save`:`Add`})]})]})})]})}var V={root:`_root_1z04o_1`,header:`_header_1z04o_3`,title:`_title_1z04o_4`,subtitle:`_subtitle_1z04o_5`,code:`_code_1z04o_6`,addBtn:`_addBtn_1z04o_8`,tabs:`_tabs_1z04o_10`,tab:`_tab_1z04o_10`,tabActive:`_tabActive_1z04o_12`,loading:`_loading_1z04o_14`,err:`_err_1z04o_15`,empty:`_empty_1z04o_17`,emptyIcon:`_emptyIcon_1z04o_18`,emptyTitle:`_emptyTitle_1z04o_19`,emptySub:`_emptySub_1z04o_20`,card:`_card_1z04o_23`,cardDisabled:`_cardDisabled_1z04o_24`,cardTop:`_cardTop_1z04o_25`,cardLeft:`_cardLeft_1z04o_26`,jobName:`_jobName_1z04o_27`,schedule:`_schedule_1z04o_28`,agentBadge:`_agentBadge_1z04o_29`,statusBadge:`_statusBadge_1z04o_30`,statusActive:`_statusActive_1z04o_31`,statusPaused:`_statusPaused_1z04o_32`,jobPrompt:`_jobPrompt_1z04o_33`,jobMeta:`_jobMeta_1z04o_34`,cardActions:`_cardActions_1z04o_35`,runBtn:`_runBtn_1z04o_36`,editBtn:`_editBtn_1z04o_37`,pauseBtn:`_pauseBtn_1z04o_38`,resumeBtn:`_resumeBtn_1z04o_39`,delBtn:`_delBtn_1z04o_40`,templates:`_templates_1z04o_43`,templatesNote:`_templatesNote_1z04o_44`,templateCard:`_templateCard_1z04o_45`,templateLabel:`_templateLabel_1z04o_46`,templatePrompt:`_templatePrompt_1z04o_47`,templateBtns:`_templateBtns_1z04o_48`,scheduleTplBtn:`_scheduleTplBtn_1z04o_49`,runTplBtn:`_runTplBtn_1z04o_50`,formOverlay:`_formOverlay_1z04o_54`,formModal:`_formModal_1z04o_55`,formTitle:`_formTitle_1z04o_56`,label:`_label_1z04o_57`,input:`_input_1z04o_58`,textarea:`_textarea_1z04o_59`,presets:`_presets_1z04o_61`,preset:`_preset_1z04o_61`,presetActive:`_presetActive_1z04o_63`,cronHints:`_cronHints_1z04o_65`,cronHint:`_cronHint_1z04o_65`,formErr:`_formErr_1z04o_70`,formOk:`_formOk_1z04o_71`,formBtns:`_formBtns_1z04o_72`,cancelBtn:`_cancelBtn_1z04o_73`,saveBtn:`_saveBtn_1z04o_74`},Ye=[{label:`Every 15 min`,value:`every 15 minutes`},{label:`Every 30 min`,value:`every 30 minutes`},{label:`Every hour`,value:`every hour`},{label:`Every 6h`,value:`every 6 hours`},{label:`Daily 8am`,value:`every day at 08:00`},{label:`Daily 9am`,value:`every day at 09:00`},{label:`Daily noon`,value:`every day at 12:00`},{label:`Daily 6pm`,value:`every day at 18:00`},{label:`Mon–Fri 9am`,value:`weekdays at 09:00`},{label:`Every Monday`,value:`every monday at 09:00`}],Xe=[{label:`🌅 Morning Briefing`,prompt:`Summarize my unread emails from the last 12 hours, check today's calendar events, list my top 3 priority tasks, and give me a focused action plan for the day.`},{label:`🌆 Evening Review`,prompt:`Review what I accomplished today: check completed tasks, summarize any important emails received, flag unresolved issues, and prepare a priority list for tomorrow.`},{label:`📰 News Digest`,prompt:`Search for the top AI, tech, and finance news from the last 24 hours. Summarize the 5 most important stories with key takeaways and market implications.`},{label:`📈 Market Update`,prompt:`Provide a comprehensive market update: macro environment, major indices performance, top movers, notable events, and key levels to watch. Use herald and mercury agents.`},{label:`🐙 GitHub Monitor`,prompt:`Check my GitHub notifications, summarize open issues and pull requests that need attention, and draft brief responses for the most urgent ones.`},{label:`📊 Weekly Report`,prompt:`Generate a weekly productivity report: tasks completed vs pending, email response rate, upcoming calendar events, and 3 strategic priorities for next week.`},{label:`🔒 Security Scan`,prompt:`Run a security awareness check: scan recent code commits for potential vulnerabilities, check dependency alerts, and summarize any security-related GitHub notifications.`},{label:`🎯 Goal Tracker`,prompt:`Review my tasks and notes for goal progress. Identify what's on track, what's at risk, and suggest one concrete action to unblock the most important goal.`}],Ze=[{label:`0 9 * * 1-5`,desc:`Mon–Fri at 9:00 AM`},{label:`0 */6 * * *`,desc:`Every 6 hours`},{label:`*/30 * * * *`,desc:`Every 30 minutes`},{label:`0 8 * * *`,desc:`Daily at 8:00 AM`},{label:`0 20 * * 5`,desc:`Every Friday at 8 PM`}];function Qe(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)({name:``,schedule:``,prompt:``,agent:``}),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(`jobs`),C=()=>{a(!0),E(`/api/cron`).then(e=>{e?.error?s(e.error):r(e?.jobs??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{C()},[]);let w=()=>{d({name:``,schedule:``,prompt:``,agent:``}),h(``),v(``),b(null),l(!0)},ee=e=>{d({name:e.name??``,schedule:e.schedule,prompt:e.prompt??e.command??``,agent:e.agent??``}),h(``),v(``),b(e.id),l(!0)},te=async()=>{if(!u.schedule.trim()){h(`Schedule is required`);return}if(!u.prompt.trim()){h(`Task prompt is required`);return}p(!0),h(``);try{y?await D(`/api/cron/update`,{id:y,schedule:u.schedule,prompt:u.prompt,agent:u.agent||void 0,name:u.name||void 0}):await D(`/api/cron`,{schedule:u.schedule,prompt:u.prompt,agent:u.agent||void 0,name:u.name||void 0}),v(y?`Updated!`:`Job scheduled!`),setTimeout(()=>{v(``),l(!1)},1500),C()}catch(e){h(e.message??`Failed`)}p(!1)},T=(e,t)=>D(`/api/cron/toggle`,{id:e,enabled:!t}).then(C),O=e=>{confirm(`Delete this scheduled task?`)&&D(`/api/cron/delete`,{id:e}).then(C)},re=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},k=e=>{d(t=>({...t,prompt:e.prompt,name:e.label.replace(/^[^\s]+\s/,``)})),S(`jobs`),l(!0)};return(0,A.jsxs)(`div`,{className:V.root,children:[(0,A.jsxs)(`div`,{className:V.header,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:V.title,children:`⏰ Scheduled Tasks`}),(0,A.jsxs)(`div`,{className:V.subtitle,children:[`Automate agents on a recurring schedule. Daemon must be running: `,(0,A.jsx)(`code`,{className:V.code,children:`nha ops start`})]})]}),(0,A.jsx)(`button`,{className:V.addBtn,onClick:w,children:`+ New Task`})]}),(0,A.jsxs)(`div`,{className:V.tabs,children:[(0,A.jsxs)(`button`,{className:`${V.tab} ${x===`jobs`?V.tabActive:``}`,onClick:()=>S(`jobs`),children:[`Jobs (`,n.length,`)`]}),(0,A.jsx)(`button`,{className:`${V.tab} ${x===`templates`?V.tabActive:``}`,onClick:()=>S(`templates`),children:`Templates`})]}),x===`templates`&&(0,A.jsxs)(`div`,{className:V.templates,children:[(0,A.jsx)(`div`,{className:V.templatesNote,children:`Click a template to pre-fill the job form or run it immediately in Chat.`}),Xe.map(t=>(0,A.jsxs)(`div`,{className:V.templateCard,children:[(0,A.jsx)(`div`,{className:V.templateLabel,children:t.label}),(0,A.jsx)(`div`,{className:V.templatePrompt,children:t.prompt}),(0,A.jsxs)(`div`,{className:V.templateBtns,children:[(0,A.jsx)(`button`,{className:V.scheduleTplBtn,onClick:()=>k(t),children:`Schedule`}),(0,A.jsxs)(`button`,{className:V.runTplBtn,onClick:()=>re(t.prompt),children:[e(`cron.run`),` in Chat →`]})]})]},t.label))]}),x===`jobs`&&(0,A.jsxs)(A.Fragment,{children:[i&&(0,A.jsxs)(`div`,{className:V.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),`Loading jobs…`]}),o&&(0,A.jsx)(`div`,{className:V.err,children:o}),!i&&n.length===0&&!c&&(0,A.jsxs)(`div`,{className:V.empty,children:[(0,A.jsx)(`div`,{className:V.emptyIcon,children:`⏰`}),(0,A.jsxs)(`div`,{className:V.emptyTitle,children:[e(`cron.noJobs`),` tasks`]}),(0,A.jsx)(`div`,{className:V.emptySub,children:`Create a job to automate agents on a recurring schedule, or browse the Templates tab for ready-made automation recipes.`}),(0,A.jsx)(`button`,{className:V.addBtn,onClick:w,children:`+ New Task`})]}),n.map(e=>(0,A.jsxs)(`div`,{className:`${V.card} ${e.enabled?``:V.cardDisabled}`,children:[(0,A.jsxs)(`div`,{className:V.cardTop,children:[(0,A.jsxs)(`div`,{className:V.cardLeft,children:[e.name&&(0,A.jsx)(`div`,{className:V.jobName,children:e.name}),(0,A.jsx)(`code`,{className:V.schedule,children:e.schedule}),e.agent&&(0,A.jsx)(`span`,{className:V.agentBadge,children:e.agent}),(0,A.jsx)(`span`,{className:`${V.statusBadge} ${e.enabled?V.statusActive:V.statusPaused}`,children:e.enabled?`active`:`paused`})]}),(0,A.jsxs)(`div`,{className:V.cardActions,children:[(0,A.jsx)(`button`,{className:V.runBtn,onClick:()=>re(e.prompt??e.command??``),title:`Run now in Chat`,children:`▶`}),(0,A.jsx)(`button`,{className:V.editBtn,onClick:()=>ee(e),children:`Edit`}),(0,A.jsx)(`button`,{className:e.enabled?V.pauseBtn:V.resumeBtn,onClick:()=>T(e.id,e.enabled),children:e.enabled?`Pause`:`Resume`}),(0,A.jsx)(`button`,{className:V.delBtn,onClick:()=>O(e.id),children:`✕`})]})]}),(0,A.jsx)(`div`,{className:V.jobPrompt,children:e.prompt??e.command}),(0,A.jsxs)(`div`,{className:V.jobMeta,children:[e.runCount!==void 0&&(0,A.jsxs)(`span`,{children:[`ran `,e.runCount,`×`]}),e.lastRun&&(0,A.jsxs)(`span`,{children:[` · last `,new Date(e.lastRun).toLocaleString()]}),e.nextRun&&(0,A.jsxs)(`span`,{children:[` · next `,new Date(e.nextRun).toLocaleString()]})]})]},e.id))]}),c&&(0,A.jsx)(`div`,{className:V.formOverlay,onClick:e=>{e.target===e.currentTarget&&l(!1)},children:(0,A.jsxs)(`div`,{className:V.formModal,children:[(0,A.jsx)(`div`,{className:V.formTitle,children:y?`Edit Scheduled Task`:`New Scheduled Task`}),(0,A.jsx)(`label`,{className:V.label,children:`Name (optional)`}),(0,A.jsx)(`input`,{className:V.input,value:u.name,onChange:e=>d(t=>({...t,name:e.target.value})),placeholder:`e.g. Morning Briefing`}),(0,A.jsx)(`label`,{className:V.label,children:`Schedule *`}),(0,A.jsx)(`div`,{className:V.presets,children:Ye.map(e=>(0,A.jsx)(`button`,{className:`${V.preset} ${u.schedule===e.value?V.presetActive:``}`,onClick:()=>d(t=>({...t,schedule:e.value})),children:e.label},e.value))}),(0,A.jsx)(`input`,{className:V.input,value:u.schedule,onChange:e=>d(t=>({...t,schedule:e.target.value})),placeholder:`every day at 09:00 — or cron syntax: 0 9 * * 1-5`}),(0,A.jsx)(`div`,{className:V.cronHints,children:Ze.map(e=>(0,A.jsxs)(`span`,{className:V.cronHint,onClick:()=>d(t=>({...t,schedule:e.label})),children:[(0,A.jsx)(`code`,{children:e.label}),` `,e.desc]},e.label))}),(0,A.jsx)(`label`,{className:V.label,children:`Task / Prompt *`}),(0,A.jsx)(`textarea`,{className:V.textarea,value:u.prompt,onChange:e=>d(t=>({...t,prompt:e.target.value})),placeholder:`Describe what the agent should do (e.g. Summarize my unread emails and list my 3 top priority tasks)`,rows:4}),(0,A.jsx)(`label`,{className:V.label,children:`Agent (optional — leave blank for auto-routing)`}),(0,A.jsx)(`input`,{className:V.input,value:u.agent,onChange:e=>d(t=>({...t,agent:e.target.value})),placeholder:`e.g. herald, oracle, mercury, EmailAgent, general`}),m&&(0,A.jsx)(`div`,{className:V.formErr,children:m}),g&&(0,A.jsx)(`div`,{className:V.formOk,children:g}),(0,A.jsxs)(`div`,{className:V.formBtns,children:[(0,A.jsx)(`button`,{className:V.cancelBtn,onClick:()=>l(!1),children:`Cancel`}),(0,A.jsx)(`button`,{className:V.saveBtn,onClick:te,disabled:f,children:f?`Saving…`:y?`Update`:`Schedule`})]})]})})]})}var $e={root:`_root_1npv7_1`,loading:`_loading_1npv7_2`,sidebar:`_sidebar_1npv7_4`,newBtn:`_newBtn_1npv7_5`,empty:`_empty_1npv7_6`,noteItem:`_noteItem_1npv7_8`,noteItemActive:`_noteItemActive_1npv7_10`,noteTitle:`_noteTitle_1npv7_11`,noteMeta:`_noteMeta_1npv7_12`,notePreview:`_notePreview_1npv7_13`,noteTags:`_noteTags_1npv7_14`,noteTag:`_noteTag_1npv7_14`,editor:`_editor_1npv7_17`,emptyEditor:`_emptyEditor_1npv7_18`,titleInput:`_titleInput_1npv7_19`,contentArea:`_contentArea_1npv7_21`,editorFooter:`_editorFooter_1npv7_22`,delNoteBtn:`_delNoteBtn_1npv7_23`,cancelBtn:`_cancelBtn_1npv7_24`,saveBtn:`_saveBtn_1npv7_25`};function et(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=()=>E(`/api/notes`).then(e=>{n(e?.notes??[]),i(!1)});(0,_.useEffect)(()=>{h()},[]);let g=e=>{o(e),c(e.title),u(e.content),m(!1)},v=()=>{o(null),c(``),u(``),m(!0)},y=async()=>{f(!0),p?await D(`/api/notes`,{title:s||`Untitled`,content:l}):a&&await D(`/api/notes/${a.id}`,{title:s,content:l}),f(!1),m(!1),h()},b=(e,t)=>{confirm(`Delete note "${t}"?`)&&D(`/api/notes/${e}/delete`,{}).then(h)};return r?(0,A.jsxs)(`div`,{className:$e.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):(0,A.jsxs)(`div`,{className:$e.root,children:[(0,A.jsxs)(`div`,{className:$e.sidebar,children:[(0,A.jsx)(`button`,{className:$e.newBtn,onClick:v,children:`+ New Note`}),t.length===0&&(0,A.jsx)(`div`,{className:$e.empty,children:e(`notes.noNotes`)}),t.map(e=>(0,A.jsxs)(`div`,{className:`${$e.noteItem} ${a?.id===e.id?$e.noteItemActive:``}`,onClick:()=>g(e),children:[(0,A.jsx)(`div`,{className:$e.noteTitle,children:e.title||`Untitled`}),(0,A.jsx)(`div`,{className:$e.noteMeta,children:e.updatedAt?new Date(e.updatedAt).toLocaleDateString():``}),e.content&&(0,A.jsx)(`div`,{className:$e.notePreview,children:e.content.slice(0,150)}),e.tags&&e.tags.length>0&&(0,A.jsx)(`div`,{className:$e.noteTags,children:e.tags.map(e=>(0,A.jsx)(`span`,{className:$e.noteTag,children:e},e))})]},e.id))]}),(0,A.jsx)(`div`,{className:$e.editor,children:a||p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{className:$e.titleInput,value:s,onChange:e=>c(e.target.value),placeholder:`Note title…`}),(0,A.jsx)(`textarea`,{className:$e.contentArea,value:l,onChange:e=>u(e.target.value),placeholder:`Start writing…`}),(0,A.jsxs)(`div`,{className:$e.editorFooter,children:[a&&(0,A.jsx)(`button`,{className:$e.delNoteBtn,onClick:()=>b(a.id,a.title),children:e(`common.delete`)}),(0,A.jsx)(`button`,{className:$e.cancelBtn,onClick:()=>{o(null),m(!1)},children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:$e.saveBtn,onClick:y,disabled:d,children:d?`Saving…`:`Save`})]})]}):(0,A.jsx)(`div`,{className:$e.emptyEditor,children:`Select a note or create a new one`})})]})}var tt={root:`_root_18yos_1`,loading:`_loading_18yos_2`,error:`_error_18yos_3`,toolbar:`_toolbar_18yos_5`,search:`_search_18yos_6`,addBtn:`_addBtn_18yos_7`,count:`_count_18yos_10`,empty:`_empty_18yos_12`,grid:`_grid_18yos_14`,card:`_card_18yos_16`,actions:`_actions_18yos_29`,avatar:`_avatar_18yos_31`,avatarImg:`_avatarImg_18yos_38`,info:`_info_18yos_40`,name:`_name_18yos_41`,row:`_row_18yos_42`,email:`_email_18yos_43`,phone:`_phone_18yos_44`,company:`_company_18yos_45`,birthday:`_birthday_18yos_46`,iconBtn:`_iconBtn_18yos_52`,iconBtnRed:`_iconBtnRed_18yos_58`,overlay:`_overlay_18yos_61`,modal:`_modal_18yos_62`,modalTitle:`_modalTitle_18yos_63`,field:`_field_18yos_64`,label:`_label_18yos_65`,input:`_input_18yos_66`,formStatus:`_formStatus_18yos_67`,formError:`_formError_18yos_68`,modalBtns:`_modalBtns_18yos_69`,cancelBtn:`_cancelBtn_18yos_70`,saveBtn:`_saveBtn_18yos_71`},nt={name:``,email:``,phone:``,company:``,address:``,notes:``};function rt(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(``),y=(0,_.useRef)(null),b=(e=``)=>{E(e?`/api/contacts?q=${encodeURIComponent(e)}`:`/api/contacts`).then(e=>{r(e?.contacts??[]),a(!1),s(``)}).catch(()=>{s(`Could not load contacts. Run nha google revoke then nha google auth.`),a(!1)})};(0,_.useEffect)(()=>{b()},[]);let x=e=>{l(e),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>b(e),400)},S=()=>{d(null),p({...nt}),v(``)},C=e=>{d(e),p({name:e.name,email:e.email??``,phone:e.phone??``,company:e.company??``,address:e.address??``,notes:e.notes??``}),v(``)},w=async()=>{if(f?.name){h(!0),v(`Saving…`);try{if(u?.resourceName){let e=await D(`/api/contacts/update`,{resourceName:u.resourceName,fields:f});if(e?.error){v(`Error: `+e.error);return}}else if(u)await D(`/api/contacts/update`,{resourceName:u.id,fields:f});else{let e=await D(`/api/contacts`,f);if(e?.error){v(`Error: `+e.error);return}}v(`Saved!`),setTimeout(()=>{p(null),d(null),b(c)},800)}catch(e){v(`Error: `+e.message)}finally{h(!1)}}},ee=(e,t)=>{e.stopPropagation(),confirm(`Delete "${t.name}"?`)&&D(`/api/contacts/delete`,{resourceName:t.resourceName||t.id}).then(e=>{let t=e;if(t?.error){alert(`Error: `+t.error);return}b(c)})},te=(e,n,r)=>{e.stopPropagation(),t(`chat`),setTimeout(()=>{let e=document.getElementById(`chatInput`);e&&(e.value=`Send an email to ${r} (${n}) about `,e.focus())},300)},T=e=>(e||`?`).split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase();return i?(0,A.jsxs)(`div`,{className:tt.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),`Loading contacts…`]}):o?(0,A.jsx)(`div`,{className:tt.error,children:o}):(0,A.jsxs)(`div`,{className:tt.root,children:[(0,A.jsxs)(`div`,{className:tt.toolbar,children:[(0,A.jsx)(`input`,{className:tt.search,value:c,onChange:e=>x(e.target.value),placeholder:`Search contacts…`}),n.length>0&&(0,A.jsxs)(`span`,{className:tt.count,children:[n.length,` contact`,n.length===1?``:`s`]}),(0,A.jsx)(`button`,{className:tt.addBtn,onClick:S,children:`+ Add`})]}),n.length===0&&(0,A.jsxs)(`div`,{className:tt.empty,children:[e(`contacts.noContacts`),(0,A.jsx)(`br`,{}),`Add a Google account or add contacts manually.`]}),(0,A.jsx)(`div`,{className:tt.grid,children:n.map(e=>(0,A.jsxs)(`div`,{className:tt.card,onClick:()=>C(e),children:[(0,A.jsx)(`div`,{className:tt.avatar,children:e.photo?(0,A.jsx)(`img`,{src:e.photo,alt:e.name,className:tt.avatarImg}):T(e.name)}),(0,A.jsxs)(`div`,{className:tt.info,children:[(0,A.jsx)(`div`,{className:tt.name,children:e.name||`(no name)`}),(0,A.jsxs)(`div`,{className:tt.row,children:[e.email&&(0,A.jsx)(`span`,{className:tt.email,children:e.email}),e.phone&&(0,A.jsx)(`span`,{className:tt.phone,children:e.phone}),e.company&&(0,A.jsxs)(`span`,{className:tt.company,children:[e.company,e.title?` · ${e.title}`:``]}),e.birthday&&(0,A.jsxs)(`span`,{className:tt.birthday,children:[`🎂 `,e.birthday]})]})]}),(0,A.jsxs)(`div`,{className:tt.actions,children:[e.email&&(0,A.jsx)(`button`,{className:tt.iconBtn,onClick:t=>te(t,e.email,e.name),title:`Send email via chat`,children:`✉`}),(0,A.jsx)(`button`,{className:tt.iconBtn,onClick:t=>{t.stopPropagation(),C(e)},title:`Edit`,children:`✎`}),(0,A.jsx)(`button`,{className:`${tt.iconBtn} ${tt.iconBtnRed}`,onClick:t=>ee(t,e),title:`Delete`,children:`✕`})]})]},e.id))}),f&&(0,A.jsx)(`div`,{className:tt.overlay,onClick:e=>{e.target===e.currentTarget&&p(null)},children:(0,A.jsxs)(`div`,{className:tt.modal,children:[(0,A.jsx)(`div`,{className:tt.modalTitle,children:u?`Edit Contact`:`New Contact`}),[[`name`,`Name`,`Full name *`],[`email`,`Email`,`user@example.com`],[`phone`,`Phone`,`+1 555 123 4567`],[`company`,`Company`,`Acme Inc`],[`address`,`Address`,`123 Main St, New York`],[`notes`,`Notes`,`Any additional info`]].map(([e,t,n])=>(0,A.jsxs)(`div`,{className:tt.field,children:[(0,A.jsx)(`label`,{className:tt.label,children:t}),(0,A.jsx)(`input`,{className:tt.input,value:f[e],onChange:t=>p(n=>n&&{...n,[e]:t.target.value}),placeholder:n,onKeyDown:t=>t.key===`Enter`&&e===`name`&&w()})]},e)),g&&(0,A.jsx)(`div`,{className:g.startsWith(`Error`)?tt.formError:tt.formStatus,children:g}),(0,A.jsxs)(`div`,{className:tt.modalBtns,children:[(0,A.jsx)(`button`,{className:tt.cancelBtn,onClick:()=>p(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:tt.saveBtn,onClick:w,disabled:m||!f.name,children:m?`…`:`Save`})]})]})})]})}var H={root:`_root_19042_2`,topbar:`_topbar_19042_11`,topbarLeft:`_topbarLeft_19042_20`,topbarTitle:`_topbarTitle_19042_21`,topbarSub:`_topbarSub_19042_22`,topbarActions:`_topbarActions_19042_23`,runBtn:`_runBtn_19042_25`,runBtnActive:`_runBtnActive_19042_32`,logBtn:`_logBtn_19042_34`,newWfBtn:`_newWfBtn_19042_41`,body:`_body_19042_50`,sidebar:`_sidebar_19042_53`,sidebarTitle:`_sidebarTitle_19042_61`,sidebarEmpty:`_sidebarEmpty_19042_65`,wfItem:`_wfItem_19042_67`,wfItemActive:`_wfItemActive_19042_78`,wfItemRow:`_wfItemRow_19042_79`,wfItemName:`_wfItemName_19042_80`,wfItemMeta:`_wfItemMeta_19042_81`,wfOn:`_wfOn_19042_82`,wfOff:`_wfOff_19042_83`,wfDelBtn:`_wfDelBtn_19042_84`,canvasArea:`_canvasArea_19042_92`,canvasHeader:`_canvasHeader_19042_94`,wfNameInput:`_wfNameInput_19042_99`,canvasHint:`_canvasHint_19042_106`,portHint:`_portHint_19042_107`,connectHint:`_connectHint_19042_108`,cancelConnectBtn:`_cancelConnectBtn_19042_109`,canvas:`_canvas_19042_92`,canvasConnecting:`_canvasConnecting_19042_122`,canvasSvg:`_canvasSvg_19042_124`,canvasNode:`_canvasNode_19042_134`,canvasNodeSelected:`_canvasNodeSelected_19042_152`,canvasNodeConnecting:`_canvasNodeConnecting_19042_153`,nodeIcon:`_nodeIcon_19042_155`,nodeLabel:`_nodeLabel_19042_156`,nodeConfigPreview:`_nodeConfigPreview_19042_157`,nodeDelBtn:`_nodeDelBtn_19042_159`,portOut:`_portOut_19042_171`,portActive:`_portActive_19042_182`,portIn:`_portIn_19042_184`,pulse:`_pulse_19042_1`,canvasDrop:`_canvasDrop_19042_195`,canvasEmpty:`_canvasEmpty_19042_203`,canvasEmptyIcon:`_canvasEmptyIcon_19042_208`,canvasEmptyTitle:`_canvasEmptyTitle_19042_209`,canvasEmptyDesc:`_canvasEmptyDesc_19042_210`,logPanel:`_logPanel_19042_213`,logHeader:`_logHeader_19042_220`,logTime:`_logTime_19042_226`,logClose:`_logClose_19042_227`,logEmpty:`_logEmpty_19042_228`,logStep:`_logStep_19042_229`,logStepError:`_logStepError_19042_230`,logStepHeader:`_logStepHeader_19042_231`,logStepIcon:`_logStepIcon_19042_232`,logStepLabel:`_logStepLabel_19042_233`,logStepErrBadge:`_logStepErrBadge_19042_234`,logStepErr:`_logStepErr_19042_230`,logStepOutput:`_logStepOutput_19042_236`,rightPanel:`_rightPanel_19042_241`,configPanel:`_configPanel_19042_252`,configHeader:`_configHeader_19042_253`,configClose:`_configClose_19042_254`,configDesc:`_configDesc_19042_255`,configFields:`_configFields_19042_256`,configField:`_configField_19042_256`,configLabel:`_configLabel_19042_258`,configRequired:`_configRequired_19042_259`,configInput:`_configInput_19042_260`,configHint:`_configHint_19042_267`,configDelete:`_configDelete_19042_269`,palette:`_palette_19042_273`,paletteTitle:`_paletteTitle_19042_274`,paletteTabs:`_paletteTabs_19042_275`,paletteTab:`_paletteTab_19042_275`,paletteTabActive:`_paletteTabActive_19042_281`,paletteNodes:`_paletteNodes_19042_282`,paletteDef:`_paletteDef_19042_284`,paletteDefIcon:`_paletteDefIcon_19042_292`,paletteDefLabel:`_paletteDefLabel_19042_293`,paletteDefDesc:`_paletteDefDesc_19042_294`,paletteFooter:`_paletteFooter_19042_296`,paletteGuide:`_paletteGuide_19042_300`,guideTitle:`_guideTitle_19042_308`,guideStep:`_guideStep_19042_317`,guideNum:`_guideNum_19042_325`,guideTip:`_guideTip_19042_341`,guideCode:`_guideCode_19042_352`},it=[{id:`trigger_manual`,type:`trigger`,label:`Manual`,icon:`▶`,color:`#6366f1`,description:`Run manually with optional text input.`,configFields:[{key:`input`,label:`Input text`,placeholder:`Optional initial input`}]},{id:`trigger_cron`,type:`trigger`,label:`Cron`,icon:`⏰`,color:`#fbbf24`,description:`Run on a schedule (cron expression).`,configFields:[{key:`schedule`,label:`Cron expression`,placeholder:`0 8 * * *`,required:!0}]},{id:`trigger_email`,type:`trigger`,label:`New Email`,icon:`📧`,color:`#38bdf8`,description:`Trigger when a new email arrives matching a filter.`,configFields:[{key:`filter`,label:`Gmail filter`,placeholder:`subject:TODO is:unread`}]},{id:`trigger_webhook`,type:`trigger`,label:`Webhook`,icon:`🔗`,color:`#a5b4fc`,description:`Trigger via HTTP POST.`,configFields:[{key:`path`,label:`Path`,placeholder:`/hook/my-trigger`}]},{id:`action_email`,type:`action`,label:`Send Email`,icon:`✉`,color:`#38bdf8`,description:`Send email via Gmail or IMAP.`,configFields:[{key:`to`,label:`To`,placeholder:`email@example.com`,required:!0},{key:`subject`,label:`Subject`,placeholder:`Subject or {{output}}`},{key:`body`,label:`Body`,placeholder:`{{output}}`}]},{id:`action_slack`,type:`action`,label:`Slack Message`,icon:`💬`,color:`#818cf8`,description:`Post a message to a Slack channel.`,configFields:[{key:`channel`,label:`Channel`,placeholder:`#general`,required:!0},{key:`text`,label:`Text`,placeholder:`{{output}}`}]},{id:`action_calendar`,type:`action`,label:`Create Event`,icon:`📅`,color:`#4ade80`,description:`Create a Google Calendar event.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`date`,label:`Date (YYYY-MM-DD)`,placeholder:`2025-01-15`},{key:`time`,label:`Time (HH:MM)`,placeholder:`09:00`}]},{id:`action_task`,type:`action`,label:`Create Task`,icon:`✅`,color:`#fbbf24`,description:`Add a task to your task list.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`priority`,label:`Priority`,placeholder:`medium`}]},{id:`action_drive`,type:`action`,label:`Save to Drive`,icon:`💾`,color:`#a78bfa`,description:`Save a text file to Google Drive.`,configFields:[{key:`name`,label:`Filename`,placeholder:`output.txt`,required:!0},{key:`content`,label:`Content`,placeholder:`{{output}}`}]},{id:`action_notion`,type:`action`,label:`Notion Page`,icon:`📋`,color:`#e4e4e7`,description:`Create or update a Notion page.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`content`,label:`Content`,placeholder:`{{output}}`}]},{id:`action_github`,type:`action`,label:`GitHub Issue`,icon:`🐙`,color:`#6ee7b7`,description:`Create a GitHub issue.`,configFields:[{key:`repo`,label:`Repo (owner/name)`,placeholder:`user/repo`,required:!0},{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`body`,label:`Body`,placeholder:``}]},{id:`action_webhook`,type:`action`,label:`HTTP Request`,icon:`🌐`,color:`#38bdf8`,description:`Make an HTTP request.`,configFields:[{key:`url`,label:`URL`,placeholder:`https://…`,required:!0},{key:`method`,label:`Method`,placeholder:`POST`},{key:`body`,label:`Body`,placeholder:`{{output}}`}]},{id:`ai_agent`,type:`ai`,label:`Run Agent`,icon:`🤖`,color:`#818cf8`,description:`Run any of the 38 NHA specialist agents.`,configFields:[{key:`agent`,label:`Agent name`,placeholder:`herald, saber, forge…`,required:!0},{key:`prompt`,label:`Prompt`,placeholder:`Summarize this: {{output}}`,required:!0}]},{id:`ai_summarize`,type:`ai`,label:`Summarize`,icon:`📝`,color:`#a5b4fc`,description:`Summarize text with AI (free via Liara).`,configFields:[{key:`prompt`,label:`Prompt`,placeholder:`Summarize: {{output}}`}]},{id:`ai_classify`,type:`ai`,label:`Classify`,icon:`🏷`,color:`#a5b4fc`,description:`Classify content into categories.`,configFields:[{key:`categories`,label:`Categories (comma-separated)`,placeholder:`urgent, normal, spam`},{key:`prompt`,label:`Prompt`,placeholder:`Classify this email: {{output}}`}]},{id:`ai_extract`,type:`ai`,label:`Extract Data`,icon:`🔍`,color:`#a5b4fc`,description:`Extract structured data from text.`,configFields:[{key:`prompt`,label:`What to extract`,placeholder:`Extract name, email, date from: {{output}}`}]},{id:`ai_translate`,type:`ai`,label:`Translate`,icon:`🌍`,color:`#a5b4fc`,description:`Translate text to another language.`,configFields:[{key:`lang`,label:`Target language`,placeholder:`Italian`,required:!0},{key:`prompt`,label:`Text`,placeholder:`{{output}}`}]}],at=Object.fromEntries(it.map(e=>[e.id,e])),ot=90,st=72;function ct(){return`n_${Date.now()}_${Math.random().toString(36).slice(2,6)}`}function lt(e,t){return{x:e.x+(t===`out`?ot:0),y:e.y+st/2}}function ut(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(`trigger`),g=(0,_.useRef)(null),v=(0,_.useRef)(null),y=(0,_.useRef)(null),b=(0,_.useCallback)(async()=>{let e=(await E(`/api/workflows`).catch(()=>null))?.workflows??[];t(e),r(t=>t?e.find(e=>e.id===t.id)??e[0]??null:e[0]??null)},[]);(0,_.useEffect)(()=>{b()},[b]);let x=(0,_.useCallback)(async e=>{r(e),t(t=>t.map(t=>t.id===e.id?e:t)),await D(`/api/workflows/${e.id}`,e,`PUT`).catch(()=>null)},[]),S=async()=>{let e={id:`wf_${Date.now()}`,name:`New Workflow`,enabled:!1,nodes:[],edges:[],nodeDefs:it},n=(await D(`/api/workflows`,e).catch(()=>null))?.workflow??e;t(e=>[...e,n]),r(n),a(null),d([]),p(!1)},C=async e=>{confirm(`Delete this workflow?`)&&(await D(`/api/workflows/${e}`,{},`DELETE`).catch(()=>null),b())},w=(0,_.useCallback)(e=>{e.preventDefault();let t=v.current;if(!t||!n)return;let r=y.current.getBoundingClientRect(),i=Math.round((e.clientX-r.left-ot/2)/20)*20,o=Math.round((e.clientY-r.top-st/2)/20)*20,s={id:ct(),defId:t,x:Math.max(0,i),y:Math.max(0,o),config:{}};x({...n,nodes:[...n.nodes,s]}),a(s.id),v.current=null},[n,x]),ee=(0,_.useCallback)((e,t)=>{if(e.stopPropagation(),o){o!==t&&n&&(n.edges.some(e=>e.from===o&&e.to===t)||x({...n,edges:[...n.edges,{from:o,to:t}]})),s(null);return}a(t);let r=n?.nodes.find(e=>e.id===t);r&&(g.current={id:t,ox:e.clientX-r.x,oy:e.clientY-r.y})},[o,n,x]),te=(0,_.useCallback)(e=>{if(!g.current||!n)return;let{id:t,ox:i,oy:a}=g.current,o=e.clientX-i,s=e.clientY-a,c=Math.max(0,Math.round(o/20)*20),l=Math.max(0,Math.round(s/20)*20);r(e=>e&&{...e,nodes:e.nodes.map(e=>e.id===t?{...e,x:c,y:l}:e)})},[n]),ne=(0,_.useCallback)(()=>{if(!g.current||!n){g.current=null;return}n.nodes.find(e=>e.id===g.current.id)&&x(n),g.current=null},[n,x]),T=(0,_.useCallback)(e=>{n&&(x({...n,nodes:n.nodes.filter(t=>t.id!==e),edges:n.edges.filter(t=>t.from!==e&&t.to!==e)}),a(null))},[n,x]),O=(0,_.useCallback)((e,t)=>{n&&x({...n,edges:n.edges.filter(n=>!(n.from===e&&n.to===t))})},[n,x]),re=(0,_.useCallback)((e,i,a)=>{if(!n)return;let o={...n,nodes:n.nodes.map(t=>t.id===e?{...t,config:{...t.config,[i]:a}}:t)};r(o),t(e=>e.map(e=>e.id===o.id?o:e))},[n]),k=(0,_.useCallback)(()=>{n&&x(n)},[n,x]),ie=async()=>{if(!(!n||c)){l(!0),p(!0),d([]);try{let e={...n,nodeDefs:it};await D(`/api/workflows/${n.id}`,e,`PUT`).catch(()=>null),d((await D(`/api/workflows/${n.id}/run`,{}))?.steps??[]),b()}catch(e){d([{nodeId:`__error`,nodeLabel:`Error`,nodeIcon:`❌`,output:``,error:e.message}])}finally{l(!1)}}},j=async e=>{let i={...e,enabled:!e.enabled};await D(`/api/workflows/${e.id}`,i,`PUT`).catch(()=>null),t(t=>t.map(t=>t.id===e.id?i:t)),n?.id===e.id&&r(i)},M=n?.nodes.find(e=>e.id===i)??null,ae=M?at[M.defId]:null;return(0,A.jsxs)(`div`,{className:H.root,children:[(0,A.jsxs)(`div`,{className:H.topbar,children:[(0,A.jsxs)(`div`,{className:H.topbarLeft,children:[(0,A.jsx)(`span`,{className:H.topbarTitle,children:`Connectors`}),(0,A.jsx)(`span`,{className:H.topbarSub,children:`Visual workflow automation · 80 tools · 38 AI agents · free AI via Liara`})]}),(0,A.jsxs)(`div`,{className:H.topbarActions,children:[n&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:`${H.runBtn} ${c?H.runBtnActive:``}`,onClick:ie,disabled:c||n.nodes.length===0,children:c?`⏳ Running…`:`▶ Run`}),(0,A.jsx)(`button`,{className:H.logBtn,onClick:()=>p(e=>!e),children:f?`Hide Log`:`📋 Log`})]}),(0,A.jsx)(`button`,{className:H.newWfBtn,onClick:S,children:`+ New Workflow`})]})]}),(0,A.jsxs)(`div`,{className:H.body,children:[(0,A.jsxs)(`div`,{className:H.sidebar,children:[(0,A.jsx)(`div`,{className:H.sidebarTitle,children:`Workflows`}),e.length===0&&(0,A.jsxs)(`div`,{className:H.sidebarEmpty,children:[`No workflows yet.`,(0,A.jsx)(`br`,{}),`Click "New Workflow" to start.`]}),e.map(e=>(0,A.jsxs)(`div`,{className:`${H.wfItem} ${n?.id===e.id?H.wfItemActive:``}`,onClick:()=>{r(e),a(null),d(e.lastRun?.steps??[]),p(!1)},children:[(0,A.jsxs)(`div`,{className:H.wfItemRow,children:[(0,A.jsx)(`span`,{className:H.wfItemName,children:e.name}),(0,A.jsx)(`button`,{className:e.enabled?H.wfOn:H.wfOff,onClick:t=>{t.stopPropagation(),j(e)},children:e.enabled?`ON`:`OFF`})]}),(0,A.jsxs)(`div`,{className:H.wfItemMeta,children:[e.nodes.length,` nodes · `,e.edges.length,` edges`,e.lastRun&&(0,A.jsxs)(`span`,{children:[` · ran `,new Date(e.lastRun.at).toLocaleTimeString()]})]}),(0,A.jsx)(`button`,{className:H.wfDelBtn,onClick:t=>{t.stopPropagation(),C(e.id)},children:`✕`})]},e.id))]}),(0,A.jsx)(`div`,{className:H.canvasArea,children:n?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:H.canvasHeader,children:[(0,A.jsx)(`input`,{className:H.wfNameInput,value:n.name,onChange:e=>r(t=>t&&{...t,name:e.target.value}),onBlur:()=>n&&x(n)}),o?(0,A.jsxs)(`span`,{className:H.connectHint,children:[`Click a target node to connect · `,(0,A.jsx)(`button`,{className:H.cancelConnectBtn,onClick:()=>s(null),children:`Cancel`})]}):(0,A.jsxs)(`span`,{className:H.canvasHint,children:[`Drag nodes from palette · Click `,(0,A.jsx)(`span`,{className:H.portHint,children:`▶`}),` to connect · Drag nodes to reposition`]})]}),(0,A.jsxs)(`div`,{ref:y,className:`${H.canvas} ${o?H.canvasConnecting:``}`,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onDragOver:e=>e.preventDefault(),onDrop:w,onClick:()=>{o||a(null)},children:[(0,A.jsx)(`svg`,{className:H.canvasSvg,children:n.edges.map((e,t)=>{let r=n.nodes.find(t=>t.id===e.from),i=n.nodes.find(t=>t.id===e.to);if(!r||!i)return null;let a=lt(r,`out`),o=lt(i,`in`),s=(a.x+o.x)/2;return(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`path`,{d:`M${a.x},${a.y} C${s},${a.y} ${s},${o.y} ${o.x},${o.y}`,stroke:`var(--green3)`,strokeWidth:`2`,fill:`none`,strokeDasharray:`6,3`,opacity:`0.8`}),(0,A.jsx)(`path`,{d:`M${a.x},${a.y} C${s},${a.y} ${s},${o.y} ${o.x},${o.y}`,stroke:`transparent`,strokeWidth:`12`,fill:`none`,style:{cursor:`pointer`},onClick:t=>{t.stopPropagation(),O(e.from,e.to)}}),(0,A.jsx)(`circle`,{cx:s,cy:(a.y+o.y)/2,r:`7`,fill:`var(--bg2)`,stroke:`var(--border)`,strokeWidth:`1.5`,style:{cursor:`pointer`},onClick:t=>{t.stopPropagation(),O(e.from,e.to)}}),(0,A.jsx)(`text`,{x:s,y:(a.y+o.y)/2+4,textAnchor:`middle`,fill:`var(--dim)`,fontSize:`9`,style:{cursor:`pointer`,pointerEvents:`none`},children:`✕`})]},t)})}),n.nodes.map(e=>{let t=at[e.defId];if(!t)return null;let n=i===e.id,r=o===e.id;return(0,A.jsxs)(`div`,{className:`${H.canvasNode} ${n?H.canvasNodeSelected:``} ${r?H.canvasNodeConnecting:``}`,style:{left:e.x,top:e.y,borderColor:t.color+(n?`ff`:`88`),background:t.color+`18`},onMouseDown:t=>ee(t,e.id),onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`button`,{className:H.nodeDelBtn,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),T(e.id)},children:`✕`}),(0,A.jsx)(`span`,{className:H.nodeIcon,children:t.icon}),(0,A.jsx)(`span`,{className:H.nodeLabel,style:{color:t.color},children:t.label}),Object.values(e.config).filter(Boolean).slice(0,1).map((e,t)=>(0,A.jsx)(`span`,{className:H.nodeConfigPreview,children:String(e).slice(0,14)},t)),(0,A.jsx)(`button`,{className:`${H.portOut} ${r?H.portActive:``}`,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),s(t=>t===e.id?null:e.id)},title:`Connect from here`,children:`▶`}),o&&o!==e.id&&(0,A.jsx)(`button`,{className:H.portIn,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),ee(t,e.id)},title:`Connect here`,children:`◀`})]},e.id)}),n.nodes.length===0&&(0,A.jsx)(`div`,{className:H.canvasDrop,children:`Drag nodes from the right panel and drop here`})]}),f&&(0,A.jsxs)(`div`,{className:H.logPanel,children:[(0,A.jsxs)(`div`,{className:H.logHeader,children:[(0,A.jsx)(`span`,{children:`Run Log`}),n.lastRun&&(0,A.jsx)(`span`,{className:H.logTime,children:new Date(n.lastRun.at).toLocaleString()}),(0,A.jsx)(`button`,{className:H.logClose,onClick:()=>p(!1),children:`✕`})]}),u.length===0&&(0,A.jsx)(`div`,{className:H.logEmpty,children:c?`Running…`:`No run results yet.`}),u.map((e,t)=>(0,A.jsxs)(`div`,{className:`${H.logStep} ${e.error?H.logStepError:``}`,children:[(0,A.jsxs)(`div`,{className:H.logStepHeader,children:[(0,A.jsx)(`span`,{className:H.logStepIcon,children:e.nodeIcon}),(0,A.jsx)(`span`,{className:H.logStepLabel,children:e.nodeLabel}),e.error&&(0,A.jsx)(`span`,{className:H.logStepErrBadge,children:`ERROR`})]}),e.error&&(0,A.jsx)(`div`,{className:H.logStepErr,children:e.error}),e.output&&(0,A.jsx)(`div`,{className:H.logStepOutput,dangerouslySetInnerHTML:{__html:de(e.output.slice(0,500))}})]},t))]})]}):(0,A.jsxs)(`div`,{className:H.canvasEmpty,children:[(0,A.jsx)(`div`,{className:H.canvasEmptyIcon,children:`🔗`}),(0,A.jsx)(`div`,{className:H.canvasEmptyTitle,children:`Select or create a workflow`}),(0,A.jsxs)(`div`,{className:H.canvasEmptyDesc,children:[`Drag nodes from the right panel onto the canvas.`,(0,A.jsx)(`br`,{}),`Connect them by clicking the `,(0,A.jsx)(`span`,{className:H.portHint,children:`▶`}),` output port then the target node.`,(0,A.jsx)(`br`,{}),`Run with one click — all 80 NHA tools already authenticated.`]}),(0,A.jsx)(`button`,{className:H.newWfBtn,onClick:S,children:`+ New Workflow`})]})}),(0,A.jsx)(`div`,{className:H.rightPanel,children:M&&ae?(0,A.jsxs)(`div`,{className:H.configPanel,children:[(0,A.jsxs)(`div`,{className:H.configHeader,children:[(0,A.jsxs)(`span`,{style:{color:ae.color},children:[ae.icon,` `,ae.label]}),(0,A.jsx)(`button`,{className:H.configClose,onClick:()=>a(null),children:`✕`})]}),(0,A.jsx)(`div`,{className:H.configDesc,children:ae.description}),(0,A.jsx)(`div`,{className:H.configFields,children:(ae.configFields??[]).map(e=>(0,A.jsxs)(`div`,{className:H.configField,children:[(0,A.jsxs)(`label`,{className:H.configLabel,children:[e.label,e.required&&(0,A.jsx)(`span`,{className:H.configRequired,children:`*`})]}),(0,A.jsx)(`input`,{className:H.configInput,value:M.config[e.key]??``,placeholder:e.placeholder??``,onChange:t=>re(M.id,e.key,t.target.value),onBlur:k}),(e.placeholder?.includes(`{{`)??!1)&&(0,A.jsxs)(`div`,{className:H.configHint,children:[`Use `,(0,A.jsx)(`code`,{children:`{{output}}`}),` to pass previous node result`]})]},e.key))}),(0,A.jsx)(`button`,{className:H.configDelete,onClick:()=>T(M.id),children:`Delete node`})]}):(0,A.jsxs)(`div`,{className:H.palette,children:[(0,A.jsx)(`div`,{className:H.paletteTitle,children:`Node Palette`}),(0,A.jsx)(`div`,{className:H.paletteTabs,children:[{id:`trigger`,label:`Triggers`,color:`#fbbf24`},{id:`action`,label:`Actions`,color:`#38bdf8`},{id:`ai`,label:`AI`,color:`#a5b4fc`}].map(e=>(0,A.jsx)(`button`,{className:`${H.paletteTab} ${m===e.id?H.paletteTabActive:``}`,style:m===e.id?{borderColor:e.color,color:e.color}:{},onClick:()=>h(e.id),children:e.label},e.id))}),(0,A.jsx)(`div`,{className:H.paletteNodes,children:it.filter(e=>e.type===m).map(e=>(0,A.jsxs)(`div`,{className:H.paletteDef,style:{borderColor:e.color+`44`,background:e.color+`14`},draggable:!0,onDragStart:()=>{v.current=e.id},onDragEnd:()=>{v.current=null},children:[(0,A.jsx)(`span`,{className:H.paletteDefIcon,children:e.icon}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:H.paletteDefLabel,style:{color:e.color},children:e.label}),(0,A.jsx)(`div`,{className:H.paletteDefDesc,children:e.description})]})]},e.id))}),(0,A.jsxs)(`div`,{className:H.paletteGuide,children:[(0,A.jsx)(`div`,{className:H.guideTitle,children:`How to use Connectors`}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`1`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Create`}),` a workflow with "+ New Workflow"`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`2`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Drag`}),` a Trigger node (e.g. Manual, Cron) onto the canvas`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`3`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Drag`}),` Action or AI nodes to chain operations`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`4`}),(0,A.jsxs)(`span`,{children:[`Click the `,(0,A.jsx)(`strong`,{style:{color:`var(--green3)`},children:`▶`}),` port on a node then click the next to `,(0,A.jsx)(`strong`,{children:`connect`}),` them`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`5`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Click`}),` a node to configure it — use `,(0,A.jsx)(`code`,{className:H.guideCode,children:`{{output}}`}),` to pass the previous result`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`6`}),(0,A.jsxs)(`span`,{children:[`Press `,(0,A.jsx)(`strong`,{children:`▶ Run`}),` to execute · toggle `,(0,A.jsx)(`strong`,{children:`ON`}),` to run automatically (cron/webhook)`]})]}),(0,A.jsxs)(`div`,{className:H.guideTip,children:[(0,A.jsx)(`strong`,{children:`Tip:`}),` Click an edge to delete it. Drag nodes on the canvas to reposition. All 80 NHA tools are pre-authenticated — no extra setup.`]}),(0,A.jsxs)(`div`,{className:H.guideTip,children:[(0,A.jsx)(`strong`,{children:`AI nodes`}),` use Liara (free) by default. They receive `,(0,A.jsx)(`code`,{className:H.guideCode,children:`{{output}}`}),` from the previous step automatically.`]})]})]})})]})]})}var U={root:`_root_1ssbe_1`,sidebar:`_sidebar_1ssbe_12`,sidebarSection:`_sidebarSection_1ssbe_23`,sidebarLabel:`_sidebarLabel_1ssbe_28`,accountSelect:`_accountSelect_1ssbe_36`,sidebarCompose:`_sidebarCompose_1ssbe_46`,composeBtn:`_composeBtn_1ssbe_51`,folderList:`_folderList_1ssbe_63`,folderItem:`_folderItem_1ssbe_69`,folderActive:`_folderActive_1ssbe_82`,badge:`_badge_1ssbe_88`,labelHeader:`_labelHeader_1ssbe_103`,addLabelBtn:`_addLabelBtn_1ssbe_114`,newLabelRow:`_newLabelRow_1ssbe_123`,newLabelInput:`_newLabelInput_1ssbe_129`,newLabelSave:`_newLabelSave_1ssbe_139`,labelDot:`_labelDot_1ssbe_150`,syncArea:`_syncArea_1ssbe_158`,syncBtn:`_syncBtn_1ssbe_163`,messageList:`_messageList_1ssbe_175`,listHeader:`_listHeader_1ssbe_185`,searchInput:`_searchInput_1ssbe_194`,searchBtn:`_searchBtn_1ssbe_204`,listBody:`_listBody_1ssbe_214`,listLoading:`_listLoading_1ssbe_219`,noMessages:`_noMessages_1ssbe_224`,msgRow:`_msgRow_1ssbe_231`,msgUnread:`_msgUnread_1ssbe_242`,msgActive:`_msgActive_1ssbe_247`,msgTop:`_msgTop_1ssbe_251`,msgFrom:`_msgFrom_1ssbe_257`,msgDate:`_msgDate_1ssbe_270`,msgSubject:`_msgSubject_1ssbe_277`,msgPreview:`_msgPreview_1ssbe_289`,listFooter:`_listFooter_1ssbe_300`,loadMoreBtn:`_loadMoreBtn_1ssbe_311`,pane:`_pane_1ssbe_322`,emptyPane:`_emptyPane_1ssbe_330`,readingPane:`_readingPane_1ssbe_337`,paneToolbar:`_paneToolbar_1ssbe_344`,paneActions:`_paneActions_1ssbe_354`,replyBtn:`_replyBtn_1ssbe_360`,fwdBtn:`_fwdBtn_1ssbe_371`,trashBtn:`_trashBtn_1ssbe_371`,starBtn:`_starBtn_1ssbe_371`,aiBtn:`_aiBtn_1ssbe_384`,labelSelect:`_labelSelect_1ssbe_394`,paneHeader:`_paneHeader_1ssbe_403`,paneSubject:`_paneSubject_1ssbe_409`,paneMeta:`_paneMeta_1ssbe_416`,attachments:`_attachments_1ssbe_424`,attachLink:`_attachLink_1ssbe_431`,paneBody:`_paneBody_1ssbe_441`,bodyFrame:`_bodyFrame_1ssbe_447`,bodyText:`_bodyText_1ssbe_455`,composePane:`_composePane_1ssbe_465`,composeTitle:`_composeTitle_1ssbe_474`,composeField:`_composeField_1ssbe_483`,templateRow:`_templateRow_1ssbe_495`,templateToggle:`_templateToggle_1ssbe_500`,templateDrop:`_templateDrop_1ssbe_510`,templateItem:`_templateItem_1ssbe_524`,templateSubject:`_templateSubject_1ssbe_534`,composeBody:`_composeBody_1ssbe_540`,composeActions:`_composeActions_1ssbe_556`,sendBtn:`_sendBtn_1ssbe_563`,cancelBtn:`_cancelBtn_1ssbe_574`,compStatus:`_compStatus_1ssbe_584`,ok:`_ok_1ssbe_585`,err:`_err_1ssbe_586`},dt=[{id:`INBOX`,name:`Inbox`,icon:`✉`},{id:`SENT`,name:`Sent`,icon:`→`},{id:`DRAFTS`,name:`Drafts`,icon:`📄`},{id:`SPAM`,name:`Spam`,icon:`🛡`},{id:`TRASH`,name:`Trash`,icon:`🗑`}],ft=[{name:`Product Promo`,subject:`Discover our offer on [PRODUCT]`},{name:`Monthly Newsletter`,subject:`[COMPANY] Newsletter — [MONTH] [YEAR]`},{name:`Commercial Follow-up`,subject:`Following our conversation — [TOPIC]`},{name:`Offer / Quote`,subject:`Offer [NUMBER] — [SUBJECT]`},{name:`Event Invitation`,subject:`You are invited: [EVENT NAME] — [DATE]`},{name:`Customer Thank You`,subject:`Thank you for your trust, [NAME]`}];function pt(e){return e?e.slice(0,10):``}function mt(e){if(!e)return``;try{let t=typeof e==`string`?JSON.parse(e):e;return Array.isArray(t)?t.map(e=>e.name?`${e.name} <${e.address}>`:e.address||``).join(`, `):String(e)}catch{return String(e)}}function ht(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(`google`),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(`INBOX`),[m,h]=(0,_.useState)([]),[g,v]=(0,_.useState)(0),[y,b]=(0,_.useState)(0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[ee,te]=(0,_.useState)(!1),[T,O]=(0,_.useState)(!1),[re,k]=(0,_.useState)(``),[ie,j]=(0,_.useState)(``),[M,ae]=(0,_.useState)(0),[oe,N]=(0,_.useState)(!1),[se,P]=(0,_.useState)({}),[I,ce]=(0,_.useState)(``),[le,ue]=(0,_.useState)(``),[de,L]=(0,_.useState)(``),[fe,pe]=(0,_.useState)(``),[me,he]=(0,_.useState)(``),[R,ge]=(0,_.useState)(!1),[_e,ve]=(0,_.useState)(``),[ye,be]=(0,_.useState)(!1),xe=(0,_.useRef)(null);(0,_.useEffect)(()=>{E(`/api/config`).then(e=>r(!!e?.hasGoogle)),E(`/api/imap/accounts`).then(e=>{let t=e?.accounts??[];a(t),t.length>0?Se(t[0].id,`imap`):Se(`google`,`google`)})},[]);let Se=(e,t)=>{s(e),l(t),p(t===`google`?`INBOX`:null),h([]),b(0),S(null),w(null),t===`imap`?E(`/api/imap/labels?accountId=${e}`).then(t=>{let n=t?.labels??[];d(n);let r=n.find(e=>e.system_type===`inbox`)?.id??null;p(r),Ce(e,r,0,``)}):(d([]),we(`INBOX`,``))},Ce=(e,t,n,r)=>{te(!0);let i=`/api/imap/messages?accountId=${encodeURIComponent(e)}&limit=50&offset=${n}`;t&&(i+=`&labelId=${encodeURIComponent(t)}`),r&&(i+=`&search=${encodeURIComponent(r)}`),E(i).then(e=>{h(n===0?e?.messages??[]:t=>[...t,...e?.messages??[]]),v(e?.total??0),te(!1)}).catch(()=>te(!1))},we=(e,t)=>{te(!0);let n=e===`INBOX`||!e?`all`:e.toLowerCase(),r=`/api/emails?filter=${encodeURIComponent(t||n)}&page=0&pageSize=50`;t&&(r=`/api/emails?filter=${encodeURIComponent(t)}&page=0&pageSize=50`),E(r).then(e=>{let t=(e?.emails??[]).map(e=>({id:e.id,subject:e.subject,from_name:e.from,from_address:e.from,internal_date:e.date,body_preview:e.snippet,is_read:!e.isUnread,is_starred:!1,has_attachments:!1,_google:!0}));h(t),v(t.length);let n=t.filter(e=>!e.is_read).length;ae(n),te(!1)}).catch(()=>te(!1))},Te=()=>{k(ie),b(0),h([]),c===`imap`&&o?Ce(o,f,0,ie):we(f??`INBOX`,ie)},Ee=e=>{S(e),N(!1),O(!0),c===`google`?D(`/api/email/read`,{messageId:e}).then(t=>{w({...t?.message??t,id:e,_google:!0}),O(!1),D(`/api/email/mark-read`,{messageId:e}).catch(()=>{})}).catch(()=>O(!1)):E(`/api/imap/message?id=${encodeURIComponent(e)}`).then(t=>{w(t?.message??null),h(t=>t.map(t=>t.id===e?{...t,is_read:!0}:t)),O(!1)}).catch(()=>O(!1))},De=(e={})=>{N(!0),P(e),ce(e.to??``),ue(``),L(e.subject??``),pe(e.type===`forward`&&e.body?`\n\n---------- Forwarded message ----------\n${e.body}`:``),he(``),ge(!1),S(null),w(null)},Oe=async()=>{if(!I.trim()){he(`Recipient required`);return}he(`Sending…`);try{if(c===`imap`&&o){let e=await D(`/api/imap/send`,{accountId:o,to:I.trim(),cc:le.trim()||void 0,subject:de.trim(),bodyHtml:fe.replace(/\n/g,`<br>`),bodyText:fe,inReplyTo:se.inReplyTo||void 0});e?.ok?(he(`Sent!`),setTimeout(()=>N(!1),800)):he(e?.error??`Error`)}else{let e=await D(`/api/email/send`,{to:I.trim(),subject:de.trim(),body:fe});e?.ok||e?.id?(he(`Sent!`),setTimeout(()=>N(!1),800)):he(e?.error??`Error`)}}catch(e){he(e.message??`Error`)}},ke=e=>{confirm(`Move to trash? Email stays on the server.`)&&D(`/api/imap/trash`,{messageId:e}).then(()=>{h(t=>t.filter(t=>t.id!==e)),w(null),S(null)})},Ae=(e,t)=>{D(`/api/imap/mark-starred`,{messageId:e,isStarred:t}).then(()=>{C?.id===e&&w(e=>e&&{...e,is_starred:t})})},je=(e,t)=>{t&&D(`/api/imap/labels/assign`,{messageId:e,labelId:t})},Me=()=>{!_e.trim()||!o||D(`/api/imap/labels`,{accountId:o,name:_e.trim()}).then(()=>{be(!1),ve(``),E(`/api/imap/labels?accountId=${o}`).then(e=>d(e?.labels??[]))})};return(0,A.jsxs)(`div`,{className:U.root,children:[(0,A.jsxs)(`div`,{className:U.sidebar,children:[(0,A.jsxs)(`div`,{className:U.sidebarSection,children:[(0,A.jsx)(`div`,{className:U.sidebarLabel,children:`Account`}),(0,A.jsxs)(`select`,{className:U.accountSelect,value:c===`google`?`google`:`imap:${o}`,onChange:e=>{let t=e.target.value;t===`google`?Se(`google`,`google`):t.startsWith(`imap:`)&&Se(t.slice(5),`imap`)},children:[n&&(0,A.jsx)(`option`,{value:`google`,children:`Google (Gmail)`}),i.map(e=>(0,A.jsx)(`option`,{value:`imap:${e.id}`,children:e.display_name||e.email_address},e.id)),!n&&i.length===0&&(0,A.jsx)(`option`,{value:``,children:`No accounts — add in Settings`})]})]}),(0,A.jsx)(`div`,{className:U.sidebarCompose,children:(0,A.jsx)(`button`,{className:U.composeBtn,onClick:()=>De(),children:`+ Compose`})}),(0,A.jsx)(`div`,{className:U.folderList,children:c===`google`?dt.map(e=>(0,A.jsxs)(`div`,{className:`${U.folderItem} ${f===e.id?U.folderActive:``}`,onClick:()=>{p(e.id),h([]),b(0),we(e.id,re)},children:[(0,A.jsx)(`span`,{children:e.icon}),(0,A.jsx)(`span`,{children:e.name}),e.id===`INBOX`&&M>0&&(0,A.jsx)(`span`,{className:U.badge,children:M})]},e.id)):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:U.labelHeader,children:[(0,A.jsx)(`span`,{children:`Labels`}),(0,A.jsx)(`button`,{className:U.addLabelBtn,onClick:()=>be(e=>!e),children:`+`})]}),ye&&(0,A.jsxs)(`div`,{className:U.newLabelRow,children:[(0,A.jsx)(`input`,{className:U.newLabelInput,value:_e,onChange:e=>ve(e.target.value),placeholder:`Label name`,onKeyDown:e=>e.key===`Enter`&&Me()}),(0,A.jsx)(`button`,{className:U.newLabelSave,onClick:Me,children:`+`})]}),u.map(e=>(0,A.jsxs)(`div`,{className:`${U.folderItem} ${f===e.id?U.folderActive:``}`,onClick:()=>{p(e.id),h([]),b(0),o&&Ce(o,e.id,0,re)},children:[(0,A.jsx)(`span`,{className:U.labelDot,style:{background:e.color??`var(--dim)`}}),(0,A.jsx)(`span`,{children:e.name}),e.unread_count?(0,A.jsx)(`span`,{className:U.badge,children:e.unread_count}):null]},e.id))]})}),c===`imap`&&o&&(0,A.jsx)(`div`,{className:U.syncArea,children:(0,A.jsx)(`button`,{className:U.syncBtn,onClick:()=>{o&&c===`imap`&&D(`/api/imap/sync/${o}`,{})},children:`Sync now`})})]}),(0,A.jsxs)(`div`,{className:U.messageList,children:[(0,A.jsxs)(`div`,{className:U.listHeader,children:[(0,A.jsx)(`input`,{className:U.searchInput,value:ie,onChange:e=>j(e.target.value),placeholder:`Search…`,onKeyDown:e=>e.key===`Enter`&&Te()}),(0,A.jsx)(`button`,{className:U.searchBtn,onClick:Te,children:`Go`})]}),(0,A.jsxs)(`div`,{className:U.listBody,children:[ee&&(0,A.jsx)(`div`,{className:U.listLoading,children:(0,A.jsx)(`div`,{className:`spinner`})}),!ee&&m.length===0&&(0,A.jsx)(`div`,{className:U.noMessages,children:`No messages`}),m.map(e=>(0,A.jsxs)(`div`,{className:`${U.msgRow} ${e.id===x?U.msgActive:``} ${e.is_read?``:U.msgUnread}`,onClick:()=>Ee(e.id),children:[(0,A.jsxs)(`div`,{className:U.msgTop,children:[(0,A.jsx)(`span`,{className:U.msgFrom,children:e.from_name||e.from_address||``}),(0,A.jsx)(`span`,{className:U.msgDate,children:pt(e.internal_date)})]}),(0,A.jsx)(`div`,{className:U.msgSubject,children:e.subject||`(no subject)`}),(0,A.jsx)(`div`,{className:U.msgPreview,children:(e.body_preview||``).slice(0,80)})]},e.id))]}),(0,A.jsxs)(`div`,{className:U.listFooter,children:[(0,A.jsxs)(`span`,{children:[g,` messages`]}),m.length<g&&c===`imap`&&(0,A.jsx)(`button`,{className:U.loadMoreBtn,onClick:()=>{let e=y+50;b(e),o&&Ce(o,f,e,re)},children:`Load more`})]})]}),(0,A.jsx)(`div`,{className:U.pane,children:(()=>{if(oe)return(0,A.jsxs)(`div`,{className:U.composePane,children:[(0,A.jsx)(`div`,{className:U.composeTitle,children:e(`email.compose`)}),(0,A.jsx)(`input`,{className:U.composeField,value:I,onChange:e=>ce(e.target.value),placeholder:`To`}),(0,A.jsx)(`input`,{className:U.composeField,value:le,onChange:e=>ue(e.target.value),placeholder:`Cc`}),(0,A.jsx)(`input`,{className:U.composeField,value:de,onChange:e=>L(e.target.value),placeholder:`Subject`}),(0,A.jsxs)(`div`,{className:U.templateRow,children:[(0,A.jsx)(`button`,{className:U.templateToggle,onClick:()=>ge(e=>!e),children:`📄 Templates`}),R&&(0,A.jsx)(`div`,{className:U.templateDrop,children:ft.map((e,t)=>(0,A.jsxs)(`div`,{className:U.templateItem,onClick:()=>{L(t=>t||e.subject),ge(!1)},children:[(0,A.jsx)(`strong`,{children:e.name}),(0,A.jsx)(`div`,{className:U.templateSubject,children:e.subject})]},t))})]}),(0,A.jsx)(`textarea`,{className:U.composeBody,value:fe,onChange:e=>pe(e.target.value),placeholder:`Write your message…`}),(0,A.jsxs)(`div`,{className:U.composeActions,children:[(0,A.jsx)(`button`,{className:U.sendBtn,onClick:Oe,children:e(`email.send_ok`)}),(0,A.jsx)(`button`,{className:U.cancelBtn,onClick:()=>N(!1),children:`Discard`}),me&&(0,A.jsx)(`span`,{className:`${U.compStatus} ${me===`Sent!`?U.ok:U.err}`,children:me})]})]});if(T)return(0,A.jsx)(`div`,{className:U.emptyPane,children:(0,A.jsx)(`div`,{className:`spinner`})});if(!C)return(0,A.jsx)(`div`,{className:U.emptyPane,children:`Select a message`});let n=mt(C.to_addresses);return(0,A.jsxs)(`div`,{className:U.readingPane,children:[(0,A.jsx)(`div`,{className:U.paneToolbar,children:(0,A.jsxs)(`div`,{className:U.paneActions,children:[(0,A.jsx)(`button`,{className:U.replyBtn,onClick:()=>De({to:C.from_address,subject:`Re: ${C.subject??``}`,inReplyTo:C.message_id??C.id,replyTo:C.id,type:`reply`}),children:e(`email.reply`)}),(0,A.jsx)(`button`,{className:U.fwdBtn,onClick:()=>De({subject:`Fwd: ${C.subject??``}`,type:`forward`,body:C.body_text??C.body_preview??``}),children:`Forward`}),!C._google&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:U.trashBtn,onClick:()=>ke(C.id),children:`🗑`}),(0,A.jsx)(`button`,{className:U.starBtn,onClick:()=>Ae(C.id,!C.is_starred),children:C.is_starred?`★`:`☆`}),u.length>0&&(0,A.jsxs)(`select`,{className:U.labelSelect,defaultValue:``,onChange:e=>je(C.id,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`+ Label`}),u.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,A.jsx)(`button`,{className:U.aiBtn,onClick:()=>t(`chat`),children:`Ask AI`})]})}),(0,A.jsxs)(`div`,{className:U.paneHeader,children:[(0,A.jsx)(`div`,{className:U.paneSubject,children:C.subject||`(no subject)`}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`From:`}),` `,C.from_name&&C.from_name!==C.from_address?`${C.from_name} <${C.from_address}>`:C.from_address]}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`To:`}),` `,n]}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`Date:`}),` `,C.internal_date]}),C.attachments&&C.attachments.length>0&&(0,A.jsx)(`div`,{className:U.attachments,children:C.attachments.map((e,t)=>(0,A.jsxs)(`a`,{className:U.attachLink,href:`/api/imap/attachment?messageId=${encodeURIComponent(C.id)}&partId=${encodeURIComponent(e.part_id??``)}&accountId=${encodeURIComponent(o??``)}`,download:e.filename??`attachment`,children:[`📎 `,e.filename??`attachment`,` (`,Math.round((e.size_bytes??0)/1024),`KB)`]},t))})]}),(0,A.jsx)(`div`,{className:U.paneBody,children:C.body_html?(0,A.jsx)(`iframe`,{ref:xe,sandbox:`allow-same-origin`,className:U.bodyFrame,srcDoc:C.body_html,title:`Email body`}):(0,A.jsx)(`pre`,{className:U.bodyText,children:C.body_text??C.body_preview??`(empty)`})})]})})()})]})}var W={root:`_root_1u06k_1`,center:`_center_1u06k_10`,noGoogle:`_noGoogle_1u06k_17`,noGoogleIcon:`_noGoogleIcon_1u06k_26`,noGoogleTitle:`_noGoogleTitle_1u06k_27`,noGoogleSub:`_noGoogleSub_1u06k_28`,connectBtn:`_connectBtn_1u06k_30`,calCol:`_calCol_1u06k_42`,navRow:`_navRow_1u06k_50`,navBtn:`_navBtn_1u06k_57`,monthTitle:`_monthTitle_1u06k_70`,dayHeaders:`_dayHeaders_1u06k_78`,dayHeader:`_dayHeader_1u06k_78`,weekend:`_weekend_1u06k_92`,grid:`_grid_1u06k_94`,cell:`_cell_1u06k_103`,emptyCell:`_emptyCell_1u06k_119`,weekendCell:`_weekendCell_1u06k_121`,todayCell:`_todayCell_1u06k_122`,activeCell:`_activeCell_1u06k_123`,hasEvtsCell:`_hasEvtsCell_1u06k_124`,holidayCell:`_holidayCell_1u06k_125`,dayNum:`_dayNum_1u06k_127`,todayNum:`_todayNum_1u06k_133`,weekendNum:`_weekendNum_1u06k_134`,evtPills:`_evtPills_1u06k_136`,evtPill:`_evtPill_1u06k_136`,holidayPill:`_holidayPill_1u06k_156`,morePill:`_morePill_1u06k_158`,loadingBar:`_loadingBar_1u06k_164`,detailCol:`_detailCol_1u06k_173`,detailHeader:`_detailHeader_1u06k_184`,detailDate:`_detailDate_1u06k_192`,addEvtBtn:`_addEvtBtn_1u06k_198`,noEvts:`_noEvts_1u06k_210`,selectDay:`_selectDay_1u06k_217`,evtCard:`_evtCard_1u06k_224`,evtTop:`_evtTop_1u06k_234`,evtTime:`_evtTime_1u06k_241`,evtBtns:`_evtBtns_1u06k_247`,editBtn:`_editBtn_1u06k_253`,delBtn:`_delBtn_1u06k_263`,readOnly:`_readOnly_1u06k_273`,evtTitle:`_evtTitle_1u06k_280`,evtLoc:`_evtLoc_1u06k_286`,evtMeta:`_evtMeta_1u06k_287`,attendees:`_attendees_1u06k_289`,attendee:`_attendee_1u06k_289`,evtDesc:`_evtDesc_1u06k_300`,joinBtn:`_joinBtn_1u06k_310`,gcalLink:`_gcalLink_1u06k_317`,overlay:`_overlay_1u06k_324`,formCard:`_formCard_1u06k_334`,formTitle:`_formTitle_1u06k_348`,formLabel:`_formLabel_1u06k_355`,formInput:`_formInput_1u06k_361`,formTextarea:`_formTextarea_1u06k_374`,formError:`_formError_1u06k_390`,formBtns:`_formBtns_1u06k_395`,cancelFormBtn:`_cancelFormBtn_1u06k_402`,saveFormBtn:`_saveFormBtn_1u06k_412`};function gt(e,t,n){return`${e}-${String(t+1).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`}function _t(e,t,n){let r=new Date;return r.getFullYear()===e&&r.getMonth()===t&&r.getDate()===n}function vt(e){if(!e)return``;let t=new Date(e);return isNaN(t.getTime())?e.slice(11,16):t.toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`})}function yt(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)(null),i=new Date,[a,o]=(0,_.useState)(i.getFullYear()),[s,c]=(0,_.useState)(i.getMonth()),[l,u]=(0,_.useState)({}),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(!1);(0,_.useEffect)(()=>{E(`/api/config`).then(e=>r(!!e?.hasGoogle))},[]);let S=(0,_.useCallback)((e,t)=>{let n=`${e}-${String(t+1).padStart(2,`0`)}`;f(!0),E(`/api/calendar?month=${n}`).then(e=>{e?.byDate&&u(t=>({...t,...e.byDate})),f(!1)}).catch(()=>f(!1))},[]);(0,_.useEffect)(()=>{n&&S(a,s)},[n,a,s,S]);let C=e=>{E(`/api/calendar?date=${e}`).then(t=>{u(n=>({...n,[e]:t?.events??[]}))})},w=(e,t,n)=>{confirm(`Delete this event?`)&&D(`/api/calendar/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{},`DELETE`).then(()=>C(n))},ee=e=>{g({title:``,start:`${e}T09:00`,end:`${e}T10:00`,location:``,description:``,isEdit:!1}),y(``)},te=(e,t)=>{let n=e.start?e.start.slice(0,16):`${t}T09:00`,r=e.end?e.end.slice(0,16):`${t}T10:00`;g({id:e.id,calId:e.calendarId??`primary`,title:e.summary,start:n,end:r,location:e.location??``,description:e.description??``,isEdit:!0}),y(``)},T=async()=>{if(h){if(!h.title.trim()){y(`Title is required`);return}x(!0);try{if(h.isEdit&&h.id){let e=h.calId??`primary`;await D(`/api/calendar/${encodeURIComponent(e)}/${encodeURIComponent(h.id)}`,{summary:h.title,start:h.start,end:h.end,location:h.location||void 0,description:h.description||void 0},`PATCH`)}else{let e=h.start.split(`T`)[0];await D(`/api/calendar`,{summary:h.title,start:h.start,end:h.end,location:h.location||void 0,description:h.description||void 0,date:e})}let e=h.start.split(`T`)[0];C(e),g(null)}catch(e){y(`Error: `+(e.message??`Unknown`))}finally{x(!1)}}};if(n===null)return(0,A.jsx)(`div`,{className:W.center,children:(0,A.jsx)(`div`,{className:`spinner`})});if(!n)return(0,A.jsx)(`div`,{className:W.center,children:(0,A.jsxs)(`div`,{className:W.noGoogle,children:[(0,A.jsx)(`div`,{className:W.noGoogleIcon,children:`📅`}),(0,A.jsx)(`div`,{className:W.noGoogleTitle,children:`Calendar`}),(0,A.jsx)(`div`,{className:W.noGoogleSub,children:`Connect your Google account to view and manage calendar events.`}),(0,A.jsx)(`button`,{className:W.connectBtn,onClick:()=>t(`settings`),children:`Connect Google →`})]})});let O=new Date(a,s,1).getDay(),re=new Date(a,s+1,0).getDate(),k=new Date(a,s,1).toLocaleDateString(`en`,{month:`long`,year:`numeric`}),ie=(O+6)%7,j=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],M=p?l[p]??[]:[];return(0,A.jsxs)(`div`,{className:W.root,children:[(0,A.jsxs)(`div`,{className:W.calCol,children:[(0,A.jsxs)(`div`,{className:W.navRow,children:[(0,A.jsx)(`button`,{className:W.navBtn,onClick:()=>{let e=s-1;e<0?(o(e=>e-1),c(11)):c(e)},children:`←`}),(0,A.jsx)(`div`,{className:W.monthTitle,children:k}),(0,A.jsx)(`button`,{className:W.navBtn,onClick:()=>{let e=s+1;e>11?(o(e=>e+1),c(0)):c(e)},children:`→`})]}),(0,A.jsx)(`div`,{className:W.dayHeaders,children:j.map((e,t)=>(0,A.jsx)(`div`,{className:`${W.dayHeader} ${t>=5?W.weekend:``}`,children:e},e))}),(0,A.jsxs)(`div`,{className:W.grid,children:[Array.from({length:ie}).map((e,t)=>(0,A.jsx)(`div`,{className:`${W.cell} ${W.emptyCell} ${t>=5?W.weekendCell:``}`},`e${t}`)),Array.from({length:re}).map((e,t)=>{let n=t+1,r=gt(a,s,n),i=_t(a,s,n),o=l[r]??[],c=o.length,u=(ie+n-1)%7>=5,d=o.some(e=>e._isHoliday||e.readOnly),f=p===r;return(0,A.jsxs)(`div`,{className:`${W.cell} ${i?W.todayCell:u?W.weekendCell:``} ${f?W.activeCell:``} ${d?W.holidayCell:c>0?W.hasEvtsCell:``}`,onClick:()=>m(r),children:[(0,A.jsx)(`div`,{className:`${W.dayNum} ${i?W.todayNum:u?W.weekendNum:``}`,children:n}),c>0&&(0,A.jsxs)(`div`,{className:W.evtPills,children:[o.slice(0,2).map((e,t)=>(0,A.jsx)(`div`,{className:`${W.evtPill} ${e._isHoliday||e.readOnly?W.holidayPill:``}`,children:e.summary},t)),c>2&&(0,A.jsxs)(`div`,{className:W.morePill,children:[`+`,c-2]})]})]},r)})]}),d&&(0,A.jsx)(`div`,{className:W.loadingBar,children:`Loading events…`})]}),(0,A.jsx)(`div`,{className:W.detailCol,children:p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:W.detailHeader,children:[(0,A.jsx)(`div`,{className:W.detailDate,children:new Date(p+`T12:00:00`).toLocaleDateString(`en`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),(0,A.jsx)(`button`,{className:W.addEvtBtn,onClick:()=>ee(p),children:`+ Add Event`})]}),M.length===0?(0,A.jsx)(`div`,{className:W.noEvts,children:`No events on this day`}):M.map((t,n)=>{let r=t.isAllDay?`All day`:`${vt(t.start)} - ${vt(t.end)}`,i=t.calendarId??`primary`;return(0,A.jsxs)(`div`,{className:W.evtCard,children:[(0,A.jsxs)(`div`,{className:W.evtTop,children:[(0,A.jsx)(`div`,{className:W.evtTime,children:r}),t.id&&!t.readOnly&&(0,A.jsxs)(`div`,{className:W.evtBtns,children:[(0,A.jsx)(`button`,{className:W.editBtn,onClick:()=>te(t,p),children:`Edit`}),(0,A.jsx)(`button`,{className:W.delBtn,onClick:()=>w(i,t.id,p),children:e(`common.delete`)})]}),t.readOnly&&(0,A.jsx)(`span`,{className:W.readOnly,children:`read-only`})]}),(0,A.jsx)(`div`,{className:W.evtTitle,children:t.summary}),t.location&&(0,A.jsxs)(`div`,{className:W.evtLoc,children:[`📍 `,t.location]}),t.organizer&&(0,A.jsxs)(`div`,{className:W.evtMeta,children:[`Organizer: `,t.organizer]}),t.attendees&&t.attendees.length>0&&(0,A.jsxs)(`div`,{className:W.attendees,children:[(0,A.jsx)(`div`,{className:W.evtMeta,children:`Attendees:`}),t.attendees.map((e,t)=>(0,A.jsxs)(`div`,{className:W.attendee,"data-status":e.responseStatus,children:[e.name||e.email,` (`,e.responseStatus,`)`]},t))]}),t.description&&(0,A.jsx)(`div`,{className:W.evtDesc,children:t.description}),t.hangoutLink&&(0,A.jsx)(`a`,{className:W.joinBtn,href:t.hangoutLink,target:`_blank`,rel:`noreferrer`,children:`Join Video Call`}),t.htmlLink&&(0,A.jsx)(`a`,{className:W.gcalLink,href:t.htmlLink,target:`_blank`,rel:`noreferrer`,children:`Open in Google Calendar`})]},n)})]}):(0,A.jsx)(`div`,{className:W.selectDay,children:`Select a day to see events`})}),h&&(0,A.jsx)(`div`,{className:W.overlay,onClick:e=>{e.target===e.currentTarget&&g(null)},children:(0,A.jsxs)(`div`,{className:W.formCard,children:[(0,A.jsx)(`div`,{className:W.formTitle,children:h.isEdit?`Edit Event`:`New Event`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Title *`}),(0,A.jsx)(`input`,{className:W.formInput,value:h.title,onChange:e=>g(t=>t&&{...t,title:e.target.value}),placeholder:`Event title`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Start`}),(0,A.jsx)(`input`,{className:W.formInput,type:`datetime-local`,value:h.start,onChange:e=>g(t=>t&&{...t,start:e.target.value})}),(0,A.jsx)(`label`,{className:W.formLabel,children:`End`}),(0,A.jsx)(`input`,{className:W.formInput,type:`datetime-local`,value:h.end,onChange:e=>g(t=>t&&{...t,end:e.target.value})}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Location`}),(0,A.jsx)(`input`,{className:W.formInput,value:h.location,onChange:e=>g(t=>t&&{...t,location:e.target.value}),placeholder:`Optional`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Description`}),(0,A.jsx)(`textarea`,{className:W.formTextarea,value:h.description,onChange:e=>g(t=>t&&{...t,description:e.target.value})}),v&&(0,A.jsx)(`div`,{className:W.formError,children:v}),(0,A.jsxs)(`div`,{className:W.formBtns,children:[(0,A.jsx)(`button`,{className:W.cancelFormBtn,onClick:()=>g(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:W.saveFormBtn,onClick:T,disabled:b,children:b?`Saving…`:h.isEdit?`Save Changes`:`Create Event`})]})]})})]})}var G={root:`_root_1tngw_1`,gridSection:`_gridSection_1tngw_9`,gridHeader:`_gridHeader_1tngw_14`,headerRow:`_headerRow_1tngw_21`,search:`_search_1tngw_23`,createBtn:`_createBtn_1tngw_34`,catTabs:`_catTabs_1tngw_41`,catTab:`_catTab_1tngw_41`,catActive:`_catActive_1tngw_48`,grid:`_grid_1tngw_9`,agentCard:`_agentCard_1tngw_59`,agentActive:`_agentActive_1tngw_66`,agentCardTop:`_agentCardTop_1tngw_68`,agentIcon:`_agentIcon_1tngw_69`,agentActions:`_agentActions_1tngw_70`,agentEditBtn:`_agentEditBtn_1tngw_71`,agentDelBtn:`_agentDelBtn_1tngw_71`,agentLabel:`_agentLabel_1tngw_74`,agentDesc:`_agentDesc_1tngw_75`,agentCat:`_agentCat_1tngw_76`,loading:`_loading_1tngw_78`,chatArea:`_chatArea_1tngw_81`,emptyChat:`_emptyChat_1tngw_88`,emptyChatHint:`_emptyChatHint_1tngw_98`,chatPanel:`_chatPanel_1tngw_101`,chatHeader:`_chatHeader_1tngw_111`,chatIcon:`_chatIcon_1tngw_118`,chatHeaderInfo:`_chatHeaderInfo_1tngw_119`,chatAgentName:`_chatAgentName_1tngw_120`,chatAgentDesc:`_chatAgentDesc_1tngw_121`,closeChat:`_closeChat_1tngw_122`,chatMessages:`_chatMessages_1tngw_125`,chatEmpty:`_chatEmpty_1tngw_130`,chatMsg:`_chatMsg_1tngw_132`,msgUser:`_msgUser_1tngw_136`,msgAgent:`_msgAgent_1tngw_137`,thinking:`_thinking_1tngw_139`,dot:`_dot_1tngw_140`,dotPulse:`_dotPulse_1tngw_1`,chatInput:`_chatInput_1tngw_146`,chatTools:`_chatTools_1tngw_147`,toolBtn:`_toolBtn_1tngw_148`,toolBtnActive:`_toolBtnActive_1tngw_156`,attachBar:`_attachBar_1tngw_158`,attachClear:`_attachClear_1tngw_163`,chatInputRow:`_chatInputRow_1tngw_165`,chatTextarea:`_chatTextarea_1tngw_166`,sendBtn:`_sendBtn_1tngw_173`,orchBar:`_orchBar_1tngw_181`,orchLabel:`_orchLabel_1tngw_192`,orchRow:`_orchRow_1tngw_193`,orchInput:`_orchInput_1tngw_194`,orchBtn:`_orchBtn_1tngw_201`,orchSynthesis:`_orchSynthesis_1tngw_208`,orchSynthHeader:`_orchSynthHeader_1tngw_214`,orchSynthSpinner:`_orchSynthSpinner_1tngw_220`,blink:`_blink_1tngw_1`,orchSynthBody:`_orchSynthBody_1tngw_222`,modalOverlay:`_modalOverlay_1tngw_230`,modal:`_modal_1tngw_230`,modalTitle:`_modalTitle_1tngw_232`,formField:`_formField_1tngw_233`,formLabel:`_formLabel_1tngw_234`,formInput:`_formInput_1tngw_235`,formTextarea:`_formTextarea_1tngw_236`,formError:`_formError_1tngw_237`,modalBtns:`_modalBtns_1tngw_238`,cancelBtn:`_cancelBtn_1tngw_239`,modalSaveBtn:`_modalSaveBtn_1tngw_240`},bt={saber:{icon:`🛡`},zero:{icon:`🔍`},ade:{icon:`🔬`},heimdall:{icon:`🔒`},cassandra:{icon:`⚠`},sauron:{icon:`👁`},jarvis:{icon:`💻`},forge:{icon:`⚙`},pipe:{icon:`🔧`},shell:{icon:`📟`},glitch:{icon:`🐛`},hermes:{icon:`🔗`},babel:{icon:`🌎`},shogun:{icon:`☸`},flux:{icon:`🔄`},cron:{icon:`⏰`},atlas:{icon:`🗺`},oracle:{icon:`📊`},logos:{icon:`🧮`},navi:{icon:`🧭`},edi:{icon:`📈`},mercury:{icon:`🌐`},tempest:{icon:`⛈`},cartographer:{icon:`🌍`},scheherazade:{icon:`✍`},quill:{icon:`📝`},muse:{icon:`🎨`},murasaki:{icon:`🖌`},echo:{icon:`📡`},polyglot:{icon:`🗣`},prometheus:{icon:`🔥`},herald:{icon:`📢`},veritas:{icon:`✓`},athena:{icon:`🧠`},conductor:{icon:`🎼`},link:{icon:`🔌`},macro:{icon:`⚡`},epicure:{icon:`🍽`}};function xt(e){let t=e.card??e,n=(t.name||t.displayName||t.agentName||e.name||``).toLowerCase().replace(/\s+/g,`-`),r=bt[n],i=t.displayName||t.agentName||t.name||e.displayName||n,a=t.tagline||t.description||e.tagline||``,o=t.category||e.category||`Other`;return{id:n,icon:r?.icon??t.icon??`🤖`,label:i,description:a,category:o,isCustom:o===`custom`,systemPrompt:e.systemPrompt}}function St(e){return{agent:e,history:[],streaming:!1,input:``,attachedFile:null,attachedImage:null,voiceActive:!1}}function Ct(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(`All`),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(`create`),[w,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(!1),T=(0,_.useRef)(new Map),O=(0,_.useRef)(new Map),k=(0,_.useRef)(new Map),ie=(0,_.useRef)(new Map),j=(0,_.useRef)(new Map),M=(0,_.useRef)(null),ae=()=>{E(`/api/agents`).then(e=>{n((e?.agents??[]).map(xt)),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{ae()},[]);let oe=[`All`,...Array.from(new Set(t.map(e=>e.category))).sort()],N=t.filter(e=>{let t=s===`All`||e.category===s,n=a.toLowerCase();return t&&(!n||e.label.toLowerCase().includes(n)||e.description.toLowerCase().includes(n))}),se=e=>{u(t=>{let n=t.findIndex(t=>t.agent.id===e.id);return n>=0?(O.current.get(e.id)?.abort(),O.current.delete(e.id),t.filter((e,t)=>t!==n)):[...t,St(e)]})},P=e=>{O.current.get(e)?.abort(),O.current.delete(e),u(t=>t.filter(t=>t.agent.id!==e))},I=(e,t)=>{u(n=>n.map(n=>n.agent.id===e?{...n,...t}:n))},ce=(e,t)=>{u(n=>n.map(n=>n.agent.id===e?{...n,history:[...n.history,t]}:n))},le=(e,t)=>{u(n=>n.map(n=>{if(n.agent.id!==e)return n;let r=[...n.history];return r[r.length-1]={...r[r.length-1],content:t},{...n,history:r}}))},ue=async(e,t,n,r)=>{let i=e.agent.id;if(!t.trim()&&!n&&!r)return;ce(i,{role:`user`,content:n?(t?t+` `:``)+`[File: ${n.name}]`:r?(t?t+` `:``)+`[Image: ${r.name}]`:t}),I(i,{streaming:!0,input:``,attachedFile:null,attachedImage:null});let a=e.history.slice(-20);if(n||r){try{let e={message:t||`Analyze this`,agent:i};n?.isPDF&&n.base64?(e.pdfBase64=n.base64,e.pdfName=n.name):n?.content&&(e.fileContent=n.content,e.fileName=n.name),r?.base64&&(e.imageBase64=r.base64,e.imageMimeType=r.mimeType??`image/jpeg`);let a=await D(`/api/chat`,e);ce(i,{role:`assistant`,content:a?.response||a?.content||``})}catch{ce(i,{role:`assistant`,content:`Error sending attachment.`})}I(i,{streaming:!1});return}ce(i,{role:`assistant`,content:``,streaming:!0});let o=new AbortController;O.current.set(i,o);let s=``;try{await re(`/api/chat/stream`,{message:t,agent:i,history:a,_agentSystemPrompt:e.agent.systemPrompt},e=>{s+=e,le(i,s);let t=k.current.get(i);t&&(t.scrollTop=t.scrollHeight)},o.signal)}catch{}finally{I(i,{streaming:!1}),O.current.delete(i)}},L=async()=>{let e=d.trim();if(!e||p||l.length===0)return;f(``),m(!0),g(``);let t=[];if(await Promise.all(l.map(async n=>{let r=n.agent.id;ce(r,{role:`user`,content:e}),I(r,{streaming:!0});let i=``,a=new AbortController;O.current.set(r,a),ce(r,{role:`assistant`,content:``,streaming:!0});try{await re(`/api/chat/stream`,{message:e,agent:r,history:n.history.slice(-20),_agentSystemPrompt:n.agent.systemPrompt},e=>{i+=e,le(r,i);let t=k.current.get(r);t&&(t.scrollTop=t.scrollHeight)},a.signal)}catch{}finally{I(r,{streaming:!1}),O.current.delete(r)}t.push({agentId:r,agentLabel:n.agent.label,icon:n.agent.icon,content:i})})),m(!1),t.length<2)return;y(!0);let n=t.map(e=>`## ${e.icon} ${e.agentLabel}\n${e.content}`).join(`
|
|
458
|
+
</body></html>`,f=new Blob([d],{type:`text/html`}),p=URL.createObjectURL(f),m=document.createElement(`a`);m.href=p,m.download=`nha-report-${Date.now()}.html`,m.click(),URL.revokeObjectURL(p);let h=window.open(``,`_blank`,`width=1100,height=800`);h&&(h.document.open(),h.document.write(d),h.document.close(),h.onload=()=>setTimeout(()=>{h.focus(),h.print()},600))},pe=t=>{let n=`**Studio Workflow Result**\n\nTask: ${t.task}\n\nAgents: ${t.nodes.map(e=>e.label).join(` → `)}\n\n---\n\n${t.result}`;try{sessionStorage.setItem(`nha_studio_import`,n)}catch{}e(`chat`)},me=()=>{if(!u){r(``),a([]),s([]),l(``),S(``),oe.current=``,w(null),N.current=null,te(!1),b({in:0,out:0}),v(null),O(!1);try{sessionStorage.removeItem(Oe)}catch{}}},he=i.some(e=>e.output||e.status===`running`);return(0,A.jsxs)(`div`,{className:R.root,children:[(0,A.jsxs)(`div`,{className:R.header,children:[(0,A.jsxs)(`div`,{className:R.headerLeft,children:[(0,A.jsx)(`div`,{className:R.title,children:`Studio`}),(0,A.jsx)(`div`,{className:R.subtitle,children:`Multi-agent orchestration · Parliament deliberation · Geth Consensus`})]}),(0,A.jsxs)(`div`,{className:R.headerActions,children:[y.in+y.out>0&&(0,A.jsxs)(`div`,{className:R.tokenBar,children:[(0,A.jsxs)(`span`,{className:R.tokIn,children:[`↑ `,y.in.toLocaleString()]}),(0,A.jsx)(`span`,{className:R.tokDim,children:` in `}),(0,A.jsxs)(`span`,{className:R.tokOut,children:[`↓ `,y.out.toLocaleString()]}),(0,A.jsx)(`span`,{className:R.tokDim,children:` out`})]}),(0,A.jsxs)(`button`,{className:R.sessionsBtn,onClick:()=>h(e=>!e),children:[`Sessions (`,f.length,`)`]}),x&&(0,A.jsx)(`button`,{className:R.canvasToggleBtn,onClick:()=>{O(!0),k(`canvas`)},children:`📊 Panel`}),c&&(0,A.jsx)(`button`,{className:R.pdfBtn,onClick:fe,children:`⬇ PDF / HTML`}),(i.length>0||c||o.length>0)&&!u&&(0,A.jsx)(`button`,{className:R.clearBtn,onClick:me,title:`Clear all — start fresh`,children:`✕ Clear`})]})]}),m&&(0,A.jsxs)(`div`,{className:R.sessionsDrawer,children:[f.length===0&&(0,A.jsx)(`div`,{className:R.noSessions,children:`No saved sessions yet.`}),f.map(e=>(0,A.jsxs)(`div`,{className:R.sessionItem,children:[(0,A.jsxs)(`div`,{className:R.sessionInfo,onClick:()=>ue(e),children:[(0,A.jsx)(`div`,{className:R.sessionTask,children:e.task.slice(0,80)}),(0,A.jsxs)(`div`,{className:R.sessionMeta,children:[e.ts.slice(0,16),` · `,e.nodes.length,` agents`,e.council?.phase===`done`?` · 🏛️ Parliament`:``]})]}),(0,A.jsxs)(`div`,{className:R.sessionBtns,children:[(0,A.jsx)(`button`,{className:R.importBtn,onClick:()=>pe(e),children:`→ Chat`}),(0,A.jsx)(`button`,{className:R.delSessionBtn,onClick:()=>L(e.id),children:`✕`})]})]},e.id))]}),(0,A.jsxs)(`div`,{className:R.inputArea,children:[(0,A.jsxs)(`div`,{className:R.inputRow,children:[(0,A.jsx)(`textarea`,{className:R.taskInput,value:n,onChange:e=>r(e.target.value),placeholder:`Describe your task… e.g. Analyze my emails and create a priority action plan`,rows:2,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),I())}}),(0,A.jsxs)(`div`,{className:R.inputControls,children:[u?(0,A.jsx)(`button`,{className:R.stopBtn,onClick:ce,children:`■ Stop`}):(0,A.jsx)(`button`,{className:R.runBtn,onClick:I,disabled:!n.trim(),children:`Run ▶`}),(0,A.jsxs)(`label`,{className:R.attachBtn,title:`Attach PDF or image`,children:[`📎`,(0,A.jsx)(`input`,{type:`file`,accept:`.pdf,.png,.jpg,.jpeg,.gif,.webp`,style:{display:`none`},onChange:e=>F(e.target.files?.[0])})]})]})]}),g&&(0,A.jsxs)(`div`,{className:R.attachBadge,children:[`📎 `,g.name,(0,A.jsx)(`button`,{className:R.clearAttach,onClick:()=>v(null),children:`✕`})]}),!u&&i.length===0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:R.examples,children:ve.map((e,t)=>(0,A.jsx)(`button`,{className:R.exampleBtn,onClick:()=>r(e),children:e},t))}),(0,A.jsxs)(`div`,{className:R.financeSection,children:[(0,A.jsx)(`div`,{className:R.financeSectionTitle,children:`📈 Finance & Trading Workflows`}),(0,A.jsx)(`div`,{className:R.financePresets,children:ge.map((e,t)=>(0,A.jsx)(`button`,{className:R.financeBtn,onClick:()=>{r(e.task),a(e.agents)},children:e.label},t))})]})]})]}),(0,A.jsxs)(`div`,{className:R.body,children:[i.length>0&&(0,A.jsxs)(`div`,{className:`${R.pipeline} ${u?R.pipelineRunning:``}`,children:[(0,A.jsxs)(`div`,{className:R.pipelineTitle,children:[`Agent Pipeline`,u&&(0,A.jsx)(`span`,{className:R.pipelineLiveTag,children:`● LIVE`})]}),(0,A.jsx)(`div`,{className:R.pipelineNodes,children:i.map((e,t)=>(0,A.jsxs)(`div`,{className:R.pipelineStep,children:[(0,A.jsx)(Ce,{node:e}),t<i.length-1&&(0,A.jsx)(`div`,{className:`${R.arrow} ${u?R.arrowActive:``}`,children:`→`})]},t))}),i.some(e=>e.reason)&&(0,A.jsx)(`div`,{className:R.reasonRow,children:i.map((e,t)=>e.reason?(0,A.jsxs)(`div`,{className:R.reasonChip,title:e.reason,children:[(0,A.jsx)(`span`,{className:R.reasonIcon,children:e.icon}),(0,A.jsxs)(`span`,{className:R.reasonText,children:[e.reason.slice(0,60),e.reason.length>60?`…`:``]})]},t):null)})]}),(o.length>0||he)&&(0,A.jsxs)(`div`,{className:R.twoCol,children:[(0,A.jsxs)(`div`,{className:R.logPanel,children:[(0,A.jsx)(`div`,{className:R.panelTitle,children:`Live Log`}),(0,A.jsx)(`div`,{className:R.logBody,ref:ae,children:o.map((e,t)=>(0,A.jsxs)(`div`,{className:`${R.logEntry} ${R[`log_${e.type}`]}`,children:[(0,A.jsx)(`span`,{className:R.logTime,children:e.time}),(0,A.jsx)(`span`,{className:R.logIcon,children:e.icon}),(0,A.jsx)(`span`,{className:R.logAgent,children:e.agent}),(0,A.jsx)(`span`,{className:R.logText,children:e.text})]},t))})]}),(0,A.jsx)(`div`,{className:R.liveOutputPanel,children:i.filter(e=>e.output||e.status===`running`).map((e,t)=>(0,A.jsxs)(`div`,{className:`${R.liveBlock} ${e.status===`running`?R.liveBlockActive:``}`,children:[(0,A.jsxs)(`div`,{className:R.liveBlockHeader,children:[(0,A.jsx)(`span`,{className:R.liveBlockIcon,children:e.icon}),(0,A.jsx)(`span`,{className:R.liveBlockLabel,children:e.label}),e.reason&&(0,A.jsx)(`span`,{className:R.liveBlockReason,title:e.reason,children:`ℹ`}),(0,A.jsx)(`span`,{className:`${R.outputStatus} ${R[`status_${e.status}`]}`,children:e.status})]}),(0,A.jsx)(`div`,{className:R.liveBlockBody,dangerouslySetInnerHTML:{__html:de(e.output)+(e.status===`running`?`<span class="studio-cursor"></span>`:``)}})]},t))})]}),ee&&(0,A.jsxs)(`div`,{className:R.parliamentPrompt,children:[(0,A.jsx)(`div`,{className:R.parliamentPromptIcon,children:`🏛️`}),(0,A.jsxs)(`div`,{className:R.parliamentPromptContent,children:[(0,A.jsx)(`div`,{className:R.parliamentPromptTitle,children:`Attivare il Parlamento?`}),(0,A.jsxs)(`div`,{className:R.parliamentPromptDesc,children:[T.length,` agenti (`,T.map(e=>e.label).join(`, `),`) hanno prodotto output. Il Geth Consensus eseguirà cross-reading, refinement e mediazione HERALD per raggiungere un consenso collettivo.`]}),(0,A.jsxs)(`div`,{className:R.parliamentPromptMeta,children:[`Complessità: `,T.length<=3?`⚡ Rapido (~30s)`:T.length<=5?`⏱ Medio (~60s)`:`🕐 Lungo (~2min)`,`\xA0· Consigliato per task analitici complessi`]})]}),(0,A.jsxs)(`div`,{className:R.parliamentPromptBtns,children:[(0,A.jsx)(`button`,{className:R.parliamentActivateBtn,onClick:le,children:`🏛️ Attiva`}),(0,A.jsx)(`button`,{className:R.parliamentSkipBtn,onClick:()=>te(!1),children:`Salta`})]})]}),C&&!ee&&(0,A.jsx)(`div`,{className:R.councilWrapper,children:(0,A.jsx)(Fe,{council:C})}),c&&!u&&(0,A.jsxs)(`details`,{className:R.resultAccordion,open:i.length<=1,children:[(0,A.jsxs)(`summary`,{className:R.resultAccordionSummary,children:[`Full Combined Report (`,i.filter(e=>e.output&&e.output!==`(no output)`).length,` agents)`]}),(0,A.jsx)(`div`,{className:R.resultAccordionBody,dangerouslySetInnerHTML:{__html:de(c)}})]})]}),D&&(0,A.jsxs)(`div`,{className:R.canvasPanel,children:[(0,A.jsxs)(`div`,{className:R.canvasPanelHeader,children:[(0,A.jsxs)(`div`,{className:R.panelTabs,children:[(0,A.jsx)(`button`,{className:`${R.panelTabBtn} ${re===`canvas`?R.panelTabActive:``}`,onClick:()=>k(`canvas`),children:`📊 Canvas`}),(0,A.jsx)(`button`,{className:`${R.panelTabBtn} ${re===`browser`?R.panelTabActive:``}`,onClick:()=>k(`browser`),children:`🌐 Browser`})]}),(0,A.jsxs)(`div`,{className:R.canvasPanelActions,children:[re===`canvas`&&x&&(0,A.jsx)(`button`,{className:R.canvasPanelBtn,onClick:()=>{let e=new Blob([x],{type:`text/html`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`nha-canvas-report.html`,n.click(),URL.revokeObjectURL(t)},children:`⬇ HTML`}),(0,A.jsx)(`button`,{className:R.canvasPanelClose,onClick:()=>O(!1),children:`✕`})]})]}),re===`canvas`?x?(0,A.jsx)(`iframe`,{className:R.canvasFrame,srcDoc:x,sandbox:`allow-scripts`,title:`Canvas Report`}):(0,A.jsx)(`div`,{className:R.panelEmpty,children:`No canvas report yet. Run a workflow first.`}):(0,A.jsxs)(`div`,{className:R.browserPanel,children:[(0,A.jsxs)(`div`,{className:R.browserBar,children:[(0,A.jsx)(`input`,{className:R.browserInput,value:ie,onChange:e=>j(e.target.value),placeholder:`https://…`,onKeyDown:e=>{e.key===`Enter`&&j(ie)}}),(0,A.jsx)(`button`,{className:R.browserGo,onClick:()=>j(ie),children:`Go`})]}),ie?(0,A.jsx)(`iframe`,{className:R.canvasFrame,src:ie,sandbox:`allow-scripts allow-same-origin allow-forms`,title:`Browser`}):(0,A.jsx)(`div`,{className:R.panelEmpty,children:`Enter a URL above to browse`})]})]})]})}var z={root:`_root_13wnr_2`,hero:`_hero_13wnr_12`,heroLeft:`_heroLeft_13wnr_21`,heroDate:`_heroDate_13wnr_22`,heroTitle:`_heroTitle_13wnr_23`,heroVer:`_heroVer_13wnr_24`,heroUptime:`_heroUptime_13wnr_25`,heroWeather:`_heroWeather_13wnr_27`,wIcon:`_wIcon_13wnr_35`,wInfo:`_wInfo_13wnr_36`,wTemp:`_wTemp_13wnr_37`,wCity:`_wCity_13wnr_38`,wDesc:`_wDesc_13wnr_39`,wEmpty:`_wEmpty_13wnr_40`,kpiRow:`_kpiRow_13wnr_43`,kpi:`_kpi_13wnr_43`,kpiNum:`_kpiNum_13wnr_55`,kpiLbl:`_kpiLbl_13wnr_56`,kpiBar:`_kpiBar_13wnr_57`,kpiFill:`_kpiFill_13wnr_58`,liveGrid:`_liveGrid_13wnr_61`,liveCard:`_liveCard_13wnr_67`,liveHdr:`_liveHdr_13wnr_71`,liveMore:`_liveMore_13wnr_79`,liveRow:`_liveRow_13wnr_81`,liveUnread:`_liveUnread_13wnr_89`,liveTitle:`_liveTitle_13wnr_89`,liveTime:`_liveTime_13wnr_91`,liveBody:`_liveBody_13wnr_95`,liveSub:`_liveSub_13wnr_97`,prio:`_prio_13wnr_99`,prio_high:`_prio_high_13wnr_103`,prio_medium:`_prio_medium_13wnr_104`,prio_low:`_prio_low_13wnr_105`,launcher:`_launcher_13wnr_108`,launchGroup:`_launchGroup_13wnr_115`,launchGroupLabel:`_launchGroupLabel_13wnr_117`,launchTiles:`_launchTiles_13wnr_123`,tile:`_tile_13wnr_129`,tileIcon:`_tileIcon_13wnr_143`,tileLabel:`_tileLabel_13wnr_144`},Le=[{view:`chat`,icon:`💬`,label:`Chat`,color:`#38bdf8`,group:`Panoramica`},{view:`plan`,icon:`🗓️`,label:`Daily Plan`,color:`#818cf8`,group:`Panoramica`},{view:`tasks`,icon:`✅`,label:`Tasks`,color:`#4ade80`,group:`Panoramica`},{view:`email`,icon:`📧`,label:`Email`,color:`#f87171`,group:`Google`},{view:`calendar`,icon:`📅`,label:`Calendar`,color:`#fb923c`,group:`Google`},{view:`drive`,icon:`💾`,label:`Drive`,color:`#facc15`,group:`Google`},{view:`contacts`,icon:`👤`,label:`Contacts`,color:`#34d399`,group:`Google`},{view:`notes`,icon:`📝`,label:`Notes`,color:`#a78bfa`,group:`Google`},{view:`onedrive`,icon:`☁️`,label:`OneDrive`,color:`#60a5fa`,group:`Microsoft`},{view:`mstodo`,icon:`📋`,label:`MS Todo`,color:`#38bdf8`,group:`Microsoft`},{view:`github`,icon:`🐙`,label:`GitHub`,color:`#e2e8f0`,group:`Tools`},{view:`notion`,icon:`📓`,label:`Notion`,color:`#94a3b8`,group:`Tools`},{view:`slack`,icon:`💼`,label:`Slack`,color:`#e879f9`,group:`Tools`},{view:`maps`,icon:`🗺️`,label:`Maps`,color:`#2dd4bf`,group:`Tools`},{view:`reminders`,icon:`🔔`,label:`Reminders`,color:`#fbbf24`,group:`Tools`},{view:`birthdays`,icon:`🎂`,label:`Birthdays`,color:`#f472b6`,group:`Tools`},{view:`cron`,icon:`⏰`,label:`Cron`,color:`#fb923c`,group:`Tools`},{view:`screen`,icon:`🖥️`,label:`Screen`,color:`#64748b`,group:`Tools`},{view:`agents`,icon:`🤖`,label:`Agents`,color:`#4ade80`,group:`AI`},{view:`studio`,icon:`🎭`,label:`Studio`,color:`#a78bfa`,group:`AI`},{view:`webcraft`,icon:`🔨`,label:`WebCraft`,color:`#f59e0b`,group:`AI`},{view:`collab`,icon:`🏛️`,label:`Alexandria`,color:`#38bdf8`,group:`AI`},{view:`connectors`,icon:`🔗`,label:`Connectors`,color:`#94a3b8`,group:`Config`},{view:`settings`,icon:`⚙️`,label:`Settings`,color:`#64748b`,group:`Config`}],Re={Sunny:`☀️`,Clear:`☀️`,"Partly Cloudy":`⛅`,"Partly cloudy":`⛅`,Cloudy:`☁️`,Overcast:`☁️`,"Light rain":`🌧️`,Rain:`🌧️`,Drizzle:`🌧️`,"Moderate rain":`🌧️`,"Heavy rain":`🌧️`,Snow:`❄️`,"Light snow":`❄️`,Fog:`🌫️`,Mist:`🌫️`,Thunder:`⚡`,"Thundery outbreaks":`⚡`};function ze(e){try{return new Date(e).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}catch{return e}}function Be(e){try{return new Date(e).toLocaleDateString(`en`,{month:`short`,day:`numeric`})}catch{return e}}function Ve(){let e=ne(e=>e.setView),t=F(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(new Date);(0,_.useEffect)(()=>{let e=setInterval(()=>p(new Date),6e4);return()=>clearInterval(e)},[]),(0,_.useEffect)(()=>{let e=!0,t=t=>n=>{e&&n!=null&&t(n)};E(`/api/tasks`).then(e=>t(r)(e?.tasks??[])),E(`/api/emails?page=0&pageSize=8`).then(e=>t(a)(e?.emails??[])),E(`/api/calendar`).then(e=>t(s)(e?.events??[])),E(`/api/status`).then(t(l));let n=localStorage.getItem(`nha_weather_location`),i=t=>E(`/api/weather?location=${encodeURIComponent(t)}`).then(t=>{e&&t?.tempC&&d(t)});return n?i(n):navigator.geolocation?.getCurrentPosition(e=>i(`${e.coords.latitude.toFixed(4)},${e.coords.longitude.toFixed(4)}`),()=>{},{timeout:6e3}),()=>{e=!1}},[]);let m=n.filter(e=>e.status!==`done`),h=n.filter(e=>e.status===`done`),g=n.length>0?Math.round(h.length/n.length*100):0,v=i.filter(e=>e.isUnread).length,y=f.toLocaleDateString(`en`,{weekday:`long`,month:`long`,day:`numeric`}),b=[...new Set(Le.map(e=>e.group))];return(0,A.jsxs)(`div`,{className:z.root,children:[(0,A.jsxs)(`div`,{className:z.hero,children:[(0,A.jsxs)(`div`,{className:z.heroLeft,children:[(0,A.jsx)(`div`,{className:z.heroDate,children:y}),(0,A.jsx)(`div`,{className:z.heroTitle,children:c?(0,A.jsxs)(A.Fragment,{children:[`NHA `,(0,A.jsxs)(`span`,{className:z.heroVer,children:[`v`,c.version]}),` · `,(0,A.jsxs)(`span`,{className:z.heroUptime,children:[Math.floor(c.uptime/60),`m uptime`]})]}):`NotHumanAllowed`})]}),(0,A.jsx)(`div`,{className:z.heroWeather,onClick:()=>{let e=prompt(`City or lat,lon:`);e&&(localStorage.setItem(`nha_weather_location`,e),location.reload())},children:u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:z.wIcon,children:Re[u.desc]??u.icon??`🌡️`}),(0,A.jsxs)(`div`,{className:z.wInfo,children:[(0,A.jsxs)(`span`,{className:z.wTemp,children:[u.tempC,`°C`]}),(0,A.jsxs)(`span`,{className:z.wCity,children:[u.city.split(`,`)[0],u.country?`, ${u.country.slice(0,2).toUpperCase()}`:``]}),(0,A.jsxs)(`span`,{className:z.wDesc,children:[u.desc,` · 💧`,u.humidity,`%`]})]})]}):(0,A.jsxs)(`span`,{className:z.wEmpty,children:[`🌡️ `,t(`dashboard.weather`)]})})]}),(0,A.jsxs)(`div`,{className:z.kpiRow,children:[(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:m.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Pending tasks`}),n.length>0&&(0,A.jsx)(`div`,{className:z.kpiBar,children:(0,A.jsx)(`div`,{className:z.kpiFill,style:{width:`${g}%`}})})]}),(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:v>0?v:i.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:v>0?`Unread emails`:`Emails`})]}),(0,A.jsxs)(`div`,{className:z.kpi,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.kpiNum,children:o.length}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Today's events`})]}),u&&(0,A.jsxs)(`div`,{className:z.kpi,children:[(0,A.jsxs)(`span`,{className:z.kpiNum,children:[u.feelsC,`°`]}),(0,A.jsx)(`span`,{className:z.kpiLbl,children:`Feels like`})]})]}),(0,A.jsxs)(`div`,{className:z.liveGrid,children:[o.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`📅 `,t(`calendar.title`)]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),o.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:z.liveRow,onClick:()=>e(`calendar`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.liveTime,children:t.isAllDay?`All day`:ze(t.start)}),(0,A.jsxs)(`div`,{className:z.liveBody,children:[(0,A.jsx)(`span`,{className:z.liveTitle,children:t.summary}),t.location&&(0,A.jsx)(`span`,{className:z.liveSub,children:t.location})]})]},n))]}),i.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`📧 `,t(`email.inbox`)]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),i.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:`${z.liveRow} ${t.isUnread?z.liveUnread:``}`,onClick:()=>e(`email`),role:`button`,children:[(0,A.jsx)(`span`,{className:z.liveTime,children:Be(t.date)}),(0,A.jsxs)(`div`,{className:z.liveBody,children:[(0,A.jsx)(`span`,{className:z.liveTitle,children:t.subject}),(0,A.jsx)(`span`,{className:z.liveSub,children:t.from})]})]},n))]}),m.length>0&&(0,A.jsxs)(`div`,{className:z.liveCard,children:[(0,A.jsxs)(`div`,{className:z.liveHdr,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsxs)(`span`,{children:[`✅ `,t(`tasks.title`),` · `,h.length,`/`,n.length,` (`,g,`%)`]}),(0,A.jsx)(`span`,{className:z.liveMore,children:`→`})]}),m.slice(0,5).map((t,n)=>(0,A.jsxs)(`div`,{className:z.liveRow,onClick:()=>e(`tasks`),role:`button`,children:[(0,A.jsx)(`span`,{className:`${z.prio} ${z[`prio_`+t.priority]}`,children:t.priority[0].toUpperCase()}),(0,A.jsx)(`div`,{className:z.liveBody,children:(0,A.jsx)(`span`,{className:z.liveTitle,children:t.description})})]},n))]})]}),(0,A.jsx)(`div`,{className:z.launcher,children:b.map(t=>(0,A.jsxs)(`div`,{className:z.launchGroup,children:[(0,A.jsx)(`div`,{className:z.launchGroupLabel,children:t}),(0,A.jsx)(`div`,{className:z.launchTiles,children:Le.filter(e=>e.group===t).map(t=>(0,A.jsxs)(`button`,{className:z.tile,onClick:()=>e(t.view),style:{"--tc":t.color},children:[(0,A.jsx)(`span`,{className:z.tileIcon,children:t.icon}),(0,A.jsx)(`span`,{className:z.tileLabel,children:t.label})]},t.view))})]},t))})]})}var He={root:`_root_1pldx_1`,loading:`_loading_1pldx_2`,bar:`_bar_1pldx_4`,input:`_input_1pldx_5`,select:`_select_1pldx_6`,addBtn:`_addBtn_1pldx_7`,actions:`_actions_1pldx_10`,clearDone:`_clearDone_1pldx_11`,clearAll:`_clearAll_1pldx_12`,stats:`_stats_1pldx_14`,progress:`_progress_1pldx_15`,progressBar:`_progressBar_1pldx_16`,empty:`_empty_1pldx_18`,task:`_task_1pldx_20`,taskDone:`_taskDone_1pldx_22`,check:`_check_1pldx_23`,checkDone:`_checkDone_1pldx_25`,desc:`_desc_1pldx_26`,del:`_del_1pldx_27`,badge:`_badge_1pldx_30`,badge_high:`_badge_high_1pldx_31`,badge_medium:`_badge_medium_1pldx_32`,badge_low:`_badge_low_1pldx_33`,doneLabel:`_doneLabel_1pldx_35`};function Ue(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(`medium`),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=()=>E(`/api/tasks`).then(e=>{n(e?.tasks??[]),i(!1)});(0,_.useEffect)(()=>{f()},[]);let p=async()=>{a.trim()&&(u(!0),await D(`/api/tasks`,{description:a.trim(),priority:s}),o(``),u(!1),f(),d.current?.focus())},m=e=>D(`/api/tasks/${e}/done`,{},`PATCH`).then(f),h=e=>D(`/api/tasks/${e}/delete`,{}).then(f),g=()=>D(`/api/tasks/clear`,{filter:`done`}).then(f),v=()=>{confirm(e(`tasks.deleteTask`))&&D(`/api/tasks/clear`,{filter:`all`}).then(f)},y=t.filter(e=>e.status!==`done`),b=t.filter(e=>e.status===`done`);return r?(0,A.jsxs)(`div`,{className:He.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):(0,A.jsxs)(`div`,{className:He.root,children:[(0,A.jsxs)(`div`,{className:He.bar,children:[(0,A.jsx)(`input`,{ref:d,className:He.input,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&p(),placeholder:e(`tasks.newTask`)}),(0,A.jsxs)(`select`,{className:He.select,value:s,onChange:e=>c(e.target.value),children:[(0,A.jsx)(`option`,{value:`high`,children:`High`}),(0,A.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,A.jsx)(`option`,{value:`low`,children:`Low`})]}),(0,A.jsx)(`button`,{className:He.addBtn,onClick:p,disabled:l||!a.trim(),children:l?`…`:`+ `+e(`common.add`)})]}),t.length>0&&(0,A.jsxs)(`div`,{className:He.actions,children:[(0,A.jsx)(`button`,{className:He.clearDone,onClick:g,children:`Clear completed`}),(0,A.jsx)(`button`,{className:He.clearAll,onClick:v,children:`Clear all`})]}),t.length>0&&(0,A.jsxs)(`div`,{className:He.stats,children:[y.length,` pending · `,b.length,` done`,t.length>0&&(0,A.jsx)(`span`,{className:He.progress,children:(0,A.jsx)(`span`,{className:He.progressBar,style:{width:`${Math.round(b.length/t.length*100)}%`}})})]}),y.length===0&&b.length===0&&(0,A.jsx)(`div`,{className:He.empty,children:`No tasks yet. Add one above ↑`}),y.map(e=>(0,A.jsxs)(`div`,{className:He.task,children:[(0,A.jsx)(`span`,{className:He.check,onClick:()=>m(e.id)}),(0,A.jsx)(`span`,{className:He.desc,onClick:()=>m(e.id),children:e.description}),(0,A.jsx)(`span`,{className:`${He.badge} ${He[`badge_`+e.priority]}`,children:e.priority}),(0,A.jsx)(`span`,{className:He.del,onClick:()=>h(e.id),children:`×`})]},e.id)),b.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:He.doneLabel,children:`Completed`}),b.map(e=>(0,A.jsxs)(`div`,{className:`${He.task} ${He.taskDone}`,children:[(0,A.jsx)(`span`,{className:`${He.check} ${He.checkDone}`,onClick:()=>m(e.id),children:`✓`}),(0,A.jsx)(`span`,{className:He.desc,onClick:()=>m(e.id),children:e.description}),(0,A.jsx)(`span`,{className:`${He.badge} ${He[`badge_`+e.priority]}`,children:e.priority}),(0,A.jsx)(`span`,{className:He.del,onClick:()=>h(e.id),children:`×`})]},e.id))]})]})}var B={root:`_root_1jj88_1`,loading:`_loading_1jj88_2`,card:`_card_1jj88_4`,cardTitle:`_cardTitle_1jj88_5`,cardTitleRow:`_cardTitleRow_1jj88_6`,cardSub:`_cardSub_1jj88_7`,connected:`_connected_1jj88_8`,statusMsg:`_statusMsg_1jj88_9`,fields:`_fields_1jj88_11`,field:`_field_1jj88_11`,fieldLabel:`_fieldLabel_1jj88_13`,fieldInput:`_fieldInput_1jj88_14`,saveBtn:`_saveBtn_1jj88_17`,dangerBtn:`_dangerBtn_1jj88_18`,cancelBtn:`_cancelBtn_1jj88_19`,btnRow:`_btnRow_1jj88_20`,keySet:`_keySet_1jj88_22`,nhaFree:`_nhaFree_1jj88_24`,nhaFreeTitle:`_nhaFreeTitle_1jj88_25`,nhaFreeSub:`_nhaFreeSub_1jj88_26`,nhaFreeBtn:`_nhaFreeBtn_1jj88_27`,imapRow:`_imapRow_1jj88_29`,imapName:`_imapName_1jj88_30`,imapMeta:`_imapMeta_1jj88_31`,imapStatus:`_imapStatus_1jj88_32`,imapBtns:`_imapBtns_1jj88_36`,imapSyncBtn:`_imapSyncBtn_1jj88_37`,imapEditBtn:`_imapEditBtn_1jj88_38`,imapDelBtn:`_imapDelBtn_1jj88_39`,emptyImap:`_emptyImap_1jj88_40`,imapForm:`_imapForm_1jj88_42`,imapFormTitle:`_imapFormTitle_1jj88_43`,pwdNote:`_pwdNote_1jj88_44`,pwdRow:`_pwdRow_1jj88_45`,togglePwd:`_togglePwd_1jj88_46`},We={id:``,display_name:``,email_address:``,from_name:``,imap_host:``,imap_port:`993`,smtp_host:``,smtp_port:`587`,username:``,password:``};function Ge({id:e,label:t,placeholder:n,value:r,onChange:i,type:a=`text`}){return(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t}),(0,A.jsx)(`input`,{id:e,type:a,placeholder:n,value:r,onChange:e=>i(e.target.value),className:B.fieldInput})]})}function Ke(){let{setConfig:e}=ne(),t=F(),[n,r]=(0,_.useState)({}),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)({name:``,email:``,phone:``,homeAddress:``,workAddress:``,city:``,country:``,company:``,role:``,notes:``}),[C,w]=(0,_.useState)(`nha`),[ee,te]=(0,_.useState)(``),[T,O]=(0,_.useState)(``),[re,k]=(0,_.useState)(`en`),[ie,j]=(0,_.useState)(`07:00`),[M,ae]=(0,_.useState)(`18:00`),[oe,N]=(0,_.useState)(`30`),[se,P]=(0,_.useState)(`off`),[I,ce]=(0,_.useState)(``),[le,ue]=(0,_.useState)(``);(0,_.useEffect)(()=>{E(`/api/config`).then(t=>{r(t??{});let n=t?.profile??{};S({name:n.name??``,email:n.email??``,phone:n.phone??``,homeAddress:n.homeAddress??``,workAddress:n.workAddress??``,city:n.city??``,country:n.country??``,company:n.company??``,role:n.role??``,notes:n.notes??``}),w(t?.provider??`nha`),O(t?.model??``),k(t?.lang??`en`),j(t?.planTime??`07:00`),ae(t?.summaryTime??`18:00`),N(String(t?.meetingAlert??`30`)),P(t?.thinking??`off`),te(``),a(!1),t&&e(t)}),de()},[]);let de=()=>E(`/api/imap/accounts`).then(e=>d(e?.accounts??[])),L=async(e,t)=>{s(e),await D(`/api/config`,{key:e,value:t}),l(e),s(null),setTimeout(()=>l(null),2e3)},fe=()=>L(`profile`,x),pe=()=>{L(`provider`,C),L(`model`,T),L(`thinking`,se),ee&&L(`key`,ee)},me=()=>{L(`planTime`,ie),L(`summaryTime`,M),L(`meetingAlert`,Number(oe))},he=()=>{v(t(`settings.googleOpening`)),D(`/api/google/auth`,{}).then(e=>{e?.url?(window.open(e.url,`_blank`),v(t(`settings.googleOpened`))):e?.error&&v(t(`common.error`)+`: `+e.error)}).catch(e=>v(t(`common.error`)+`: `+e.message))},R=()=>{confirm(t(`settings.disconnectGoogleConfirm`))&&D(`/api/google/revoke`,{}).then(()=>{r(e=>({...e,hasGoogle:!1})),v(t(`common.disconnected`))})},ge=()=>{if(!f)return;let e=!!f.id,t={display_name:f.display_name,email_address:f.email_address,from_name:f.from_name,imap_host:f.imap_host,imap_port:Number(f.imap_port),smtp_host:f.smtp_host,smtp_port:Number(f.smtp_port),username:f.username};f.password&&(t.password=f.password),e&&(t.id=f.id),h(`Saving…`),D(e?`/api/imap/accounts/update`:`/api/imap/accounts`,t).then(e=>{e?.ok||e?.id?(h(`Saved!`),p(null),de()):h(`Error: `+(e?.error??`Unknown error`))}).catch(e=>h(`Error: `+e.message))},_e=(e,n)=>{confirm(t(`settings.imapDelete`,{name:n}))&&D(`/api/imap/accounts/delete`,{id:e}).then(()=>de())},ve=e=>{D(`/api/imap/sync`,{accountId:e}).then(()=>setTimeout(de,3e3))};if(i)return(0,A.jsxs)(`div`,{className:B.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),t(`common.loading`)]});let ye=e=>t(o===e?`common.saving`:c===e?`common.saved`:`common.save`);return(0,A.jsxs)(`div`,{className:B.root,children:[(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.profile`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.profileSub`)}),(0,A.jsx)(`div`,{className:B.fields,children:[[`name`,t(`settings.name`),t(`settings.namePh`)],[`email`,t(`common.email`),t(`settings.emailPh`)],[`phone`,t(`common.phone`),t(`settings.phonePh`)],[`homeAddress`,t(`settings.homeAddress`),t(`settings.homeAddressPh`)],[`workAddress`,t(`settings.workAddress`),t(`settings.workAddressPh`)],[`city`,t(`settings.city`),t(`settings.cityPh`)],[`country`,t(`settings.country`),t(`settings.countryPh`)],[`company`,t(`settings.company`),t(`settings.companyPh`)],[`role`,t(`settings.role`),t(`settings.rolePh`)],[`notes`,t(`settings.notes`),t(`settings.notesPh`)]].map(([e,t,n])=>(0,A.jsx)(Ge,{id:e,label:t,placeholder:n,value:x[e],onChange:t=>S(n=>({...n,[e]:t}))},e))}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:fe,children:[ye(`profile`),` `,t(`settings.saveProfile`)]})]}),(0,A.jsxs)(`div`,{className:B.nhaFree,children:[(0,A.jsx)(`div`,{className:B.nhaFreeTitle,children:t(`settings.nhaFreeTitle`)}),(0,A.jsx)(`div`,{className:B.nhaFreeSub,children:t(`settings.nhaFreeSub`)}),(0,A.jsx)(`button`,{className:B.nhaFreeBtn,onClick:()=>{D(`/api/config`,{updates:[{key:`provider`,value:`nha`},{key:`model`,value:``},{key:`key`,value:``}]}).then(()=>{w(`nha`),O(``),te(``),l(`nhaFree`),setTimeout(()=>l(null),2e3)})},children:t(c===`nhaFree`?`settings.liaraActivated`:`settings.useLiara`)})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.llmProvider`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.llmProviderSub`)}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.provider`)}),(0,A.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),className:B.fieldInput,children:[(0,A.jsx)(`option`,{value:`nha`,children:`NHA Free (Liara) — no API key needed`}),(0,A.jsx)(`option`,{value:`anthropic`,children:`Anthropic (Claude)`}),(0,A.jsx)(`option`,{value:`openai`,children:`OpenAI (GPT-4)`}),(0,A.jsx)(`option`,{value:`gemini`,children:`Google (Gemini)`}),(0,A.jsx)(`option`,{value:`deepseek`,children:`DeepSeek`}),(0,A.jsx)(`option`,{value:`grok`,children:`xAI (Grok)`}),(0,A.jsx)(`option`,{value:`mistral`,children:`Mistral`}),(0,A.jsx)(`option`,{value:`cohere`,children:`Cohere`})]})]}),C!==`nha`&&({anthropic:n.hasApiKey,openai:n.hasOpenaiKey,gemini:n.hasGeminiKey,deepseek:n.hasDeepseekKey,grok:n.hasGrokKey,mistral:n.hasMistralKey,cohere:n.hasCohereKey}[C]?(0,A.jsx)(`div`,{className:B.keySet,children:t(`settings.apiKeySet`)}):null),(0,A.jsx)(Ge,{id:`apiKey`,label:t(`settings.apiKey`),placeholder:t(C===`nha`?`settings.apiKeyFreeNote`:`settings.apiKeyPh`),type:`password`,value:ee,onChange:te}),(0,A.jsx)(Ge,{id:`model`,label:t(`settings.model`),placeholder:t(`settings.modelPh`),value:T,onChange:O}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.thinking`)}),(0,A.jsxs)(`select`,{value:se,onChange:e=>P(e.target.value),className:B.fieldInput,children:[(0,A.jsx)(`option`,{value:`off`,children:t(`settings.thinkingOff`)}),(0,A.jsx)(`option`,{value:`on`,children:t(`settings.thinkingOn`)})]})]}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:pe,children:[ye(`provider`),` `,t(`settings.saveProvider`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.language`)}),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsx)(`label`,{className:B.fieldLabel,children:t(`settings.languageLabel`)}),(0,A.jsx)(`select`,{value:re,onChange:t=>{let r=t.target.value;k(r),L(`lang`,r),e({...n,lang:r})},className:B.fieldInput,children:[[`it`,`Italiano`],[`en`,`English`],[`es`,`Español`],[`fr`,`Français`],[`de`,`Deutsch`],[`pt`,`Português`],[`nl`,`Nederlands`],[`pl`,`Polski`],[`ru`,`Русский`],[`zh`,`中文`],[`ja`,`日本語`],[`ko`,`한국어`],[`ar`,`العربية`],[`hi`,`हिन्दी`],[`tr`,`Türkçe`],[`sv`,`Svenska`],[`da`,`Dansk`],[`fi`,`Suomi`],[`cs`,`Čeština`]].map(([e,t])=>(0,A.jsx)(`option`,{value:e,children:t},e))})]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.telegram`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.telegramSub`)}),n.hasTelegram&&(0,A.jsxs)(`div`,{className:B.connected,children:[`Telegram: `,t(`common.connected`)]}),n.hasDiscord&&(0,A.jsxs)(`div`,{className:B.connected,children:[`Discord: `,t(`common.connected`)]}),(0,A.jsx)(Ge,{id:`tgToken`,label:t(`settings.telegramToken`),placeholder:n.hasTelegram?t(`settings.telegramSet`):t(`settings.telegramPh`),type:`password`,value:I,onChange:ce}),(0,A.jsx)(Ge,{id:`discordToken`,label:t(`settings.discordToken`),placeholder:n.hasDiscord?t(`settings.discordSet`):t(`settings.discordPh`),type:`password`,value:le,onChange:ue}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:()=>{I&&L(`telegram-bot-token`,I),le&&L(`discord-bot-token`,le)},children:[ye(`telegram-bot-token`),` `,t(`settings.saveBots`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.dailyOps`)}),(0,A.jsx)(Ge,{id:`planTime`,label:t(`settings.planTime`),placeholder:`07:00`,value:ie,onChange:j}),(0,A.jsx)(Ge,{id:`summaryTime`,label:t(`settings.summaryTime`),placeholder:`18:00`,value:M,onChange:ae}),(0,A.jsx)(Ge,{id:`meetingAlert`,label:t(`settings.meetingAlert`),placeholder:`30`,value:oe,onChange:N}),(0,A.jsxs)(`button`,{className:B.saveBtn,onClick:me,children:[ye(`planTime`),` `,t(`settings.saveSchedule`)]})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.googleAccount`)}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.googleSub`)}),n.hasGoogle&&(0,A.jsxs)(`div`,{className:B.connected,children:[`✅ `,t(`common.connected`),n.googleEmail?` · ${n.googleEmail}`:``]}),(0,A.jsxs)(`div`,{className:B.btnRow,children:[(0,A.jsx)(`button`,{className:B.saveBtn,onClick:he,children:n.hasGoogle?t(`settings.reconnectGoogle`):t(`settings.connectGoogle`)}),n.hasGoogle&&(0,A.jsx)(`button`,{className:B.dangerBtn,onClick:R,children:t(`settings.disconnectGoogle`)})]}),g&&(0,A.jsx)(`div`,{className:B.statusMsg,children:g})]}),(0,A.jsxs)(`div`,{className:B.card,children:[(0,A.jsxs)(`div`,{className:B.cardTitleRow,children:[(0,A.jsx)(`div`,{className:B.cardTitle,children:t(`settings.imapAccounts`)}),(0,A.jsx)(`button`,{className:B.saveBtn,onClick:()=>{p({...We}),h(``)},children:t(`settings.addAccount`)})]}),(0,A.jsx)(`div`,{className:B.cardSub,children:t(`settings.imapSub`)}),u.length===0&&!f&&(0,A.jsx)(`div`,{className:B.emptyImap,children:t(`settings.noImapAccounts`)}),u.map(e=>(0,A.jsxs)(`div`,{className:B.imapRow,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:B.imapName,children:e.display_name}),(0,A.jsxs)(`div`,{className:B.imapMeta,children:[e.email_address,` · `,e.imap_host]}),(0,A.jsxs)(`div`,{className:B.imapStatus,"data-status":e.sync_status,children:[e.sync_status,e.last_sync_at?` · ${t(`email.lastSync`)}: ${e.last_sync_at.slice(0,16)}`:``]})]}),(0,A.jsxs)(`div`,{className:B.imapBtns,children:[(0,A.jsx)(`button`,{className:B.imapSyncBtn,onClick:()=>ve(e.id),children:t(`settings.sync`)}),(0,A.jsx)(`button`,{className:B.imapEditBtn,onClick:()=>{p({...We,id:e.id,display_name:e.display_name,email_address:e.email_address,from_name:e.from_name??``,imap_host:e.imap_host,imap_port:String(e.imap_port??993),smtp_host:e.smtp_host??``,smtp_port:String(e.smtp_port??587),username:e.username??``,password:``}),h(``)},children:t(`common.edit`)}),(0,A.jsx)(`button`,{className:B.imapDelBtn,onClick:()=>_e(e.id,e.display_name),children:t(`common.delete`)})]})]},e.id)),f&&(0,A.jsxs)(`div`,{className:B.imapForm,children:[(0,A.jsx)(`div`,{className:B.imapFormTitle,children:f.id?t(`settings.editImapAccount`):t(`settings.addImapAccount`)}),[[`display_name`,t(`settings.displayName`),t(`settings.displayNamePh`)],[`email_address`,t(`common.email`),`user@example.com`],[`from_name`,t(`settings.fromName`),t(`settings.fromNamePh`)],[`imap_host`,t(`settings.imapServer`),`e.g. imap.gmail.com`],[`imap_port`,t(`settings.imapPort`),`993`],[`smtp_host`,t(`settings.smtpServer`),`e.g. smtp.gmail.com`],[`smtp_port`,t(`settings.smtpPort`),`587`],[`username`,t(`settings.username`),`user@example.com`]].map(([e,t,n])=>(0,A.jsx)(Ge,{id:`imap_${e}`,label:t,placeholder:n,value:f[e],onChange:t=>p(n=>n&&{...n,[e]:t})},e)),(0,A.jsxs)(`div`,{className:B.field,children:[(0,A.jsxs)(`label`,{className:B.fieldLabel,children:[t(`settings.password`),` `,f.id&&(0,A.jsx)(`span`,{className:B.pwdNote,children:t(`settings.passwordKeep`)})]}),(0,A.jsxs)(`div`,{className:B.pwdRow,children:[(0,A.jsx)(`input`,{type:y?`text`:`password`,placeholder:t(`settings.passwordPh`),value:f.password,onChange:e=>p(t=>t&&{...t,password:e.target.value}),className:B.fieldInput,style:{flex:1}}),(0,A.jsx)(`button`,{className:B.togglePwd,onClick:()=>b(e=>!e),children:t(y?`settings.hide`:`settings.show`)})]})]}),(0,A.jsxs)(`div`,{className:B.btnRow,children:[(0,A.jsx)(`button`,{className:B.saveBtn,onClick:ge,children:t(`common.save`)}),(0,A.jsx)(`button`,{className:B.cancelBtn,onClick:()=>p(null),children:t(`common.cancel`)})]}),m&&(0,A.jsx)(`div`,{className:B.statusMsg,children:m})]})]})]})}var qe={root:`_root_o07ov_1`,loading:`_loading_o07ov_2`,err:`_err_o07ov_3`,header:`_header_o07ov_4`,title:`_title_o07ov_5`,addBtn:`_addBtn_o07ov_6`,empty:`_empty_o07ov_7`,card:`_card_o07ov_8`,cardToday:`_cardToday_o07ov_9`,icon:`_icon_o07ov_10`,info:`_info_o07ov_11`,name:`_name_o07ov_12`,date:`_date_o07ov_13`,labelToday:`_labelToday_o07ov_14`,labelTomorrow:`_labelTomorrow_o07ov_15`,labelFuture:`_labelFuture_o07ov_16`,editBtn:`_editBtn_o07ov_17`,delBtn:`_delBtn_o07ov_18`,overlay:`_overlay_o07ov_20`,modal:`_modal_o07ov_21`,modalTitle:`_modalTitle_o07ov_22`,label:`_label_o07ov_14`,input:`_input_o07ov_24`,hint:`_hint_o07ov_25`,formErr:`_formErr_o07ov_26`,modalBtns:`_modalBtns_o07ov_27`,cancelBtn:`_cancelBtn_o07ov_28`,saveBtn:`_saveBtn_o07ov_29`};function Je(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),p=(0,_.useCallback)(()=>{i(!0),E(`/api/birthdays`).then(e=>{e?.error?o(e.error):n(e?.birthdays??[]),i(!1)})},[]);(0,_.useEffect)(()=>{p()},[p]);let m=()=>{c({name:``,date:``}),u(``)},h=e=>{c({name:e.name,date:e.date,contactId:e.contactId}),u(``)},g=async()=>{if(!s)return;if(!s.name.trim()){u(`Name is required`);return}if(!s.date.trim()){u(`Date is required`);return}f(!0);let e=s.date;/^\d{2}-\d{2}$/.test(e)&&(e=`${new Date().getFullYear()}-${e}`),await D(`/api/birthdays`,{name:s.name,date:e,contactId:s.contactId??null,edit:!!s.contactId}),f(!1),c(null),p()},v=e=>{confirm(`Remove birthday for ${e.name}?`)&&D(`/api/birthdays/delete`,{contactId:e.contactId}).then(p)};return r?(0,A.jsxs)(`div`,{className:qe.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):a?(0,A.jsx)(`div`,{className:qe.err,children:a}):(0,A.jsxs)(`div`,{className:qe.root,children:[(0,A.jsxs)(`div`,{className:qe.header,children:[(0,A.jsx)(`div`,{className:qe.title,children:`Upcoming Birthdays`}),(0,A.jsx)(`button`,{className:qe.addBtn,onClick:m,children:`+ Add Birthday`})]}),t.length===0&&(0,A.jsxs)(`div`,{className:qe.empty,children:[e(`birthdays.noBirthdays`),(0,A.jsx)(`br`,{}),(0,A.jsx)(`small`,{children:`Add one above, or add birthdays to your Google Contacts.`})]}),t.map((t,n)=>{let r=t.daysUntil===0,i=t.daysUntil===1;return(0,A.jsxs)(`div`,{className:`${qe.card} ${r?qe.cardToday:``}`,children:[(0,A.jsx)(`span`,{className:qe.icon,children:`🎂`}),(0,A.jsxs)(`div`,{className:qe.info,children:[(0,A.jsx)(`div`,{className:qe.name,children:t.name}),(0,A.jsx)(`div`,{className:qe.date,children:t.date})]}),(0,A.jsx)(`div`,{className:r?qe.labelToday:i?qe.labelTomorrow:qe.labelFuture,children:r?`TODAY!`:i?`Tomorrow`:`in ${t.daysUntil} days`}),t.contactId&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:qe.editBtn,onClick:()=>h(t),children:e(`common.edit`)}),(0,A.jsx)(`button`,{className:qe.delBtn,onClick:()=>v(t),children:e(`common.delete`)})]})]},n)}),s&&(0,A.jsx)(`div`,{className:qe.overlay,onClick:e=>{e.target===e.currentTarget&&c(null)},children:(0,A.jsxs)(`div`,{className:qe.modal,children:[(0,A.jsx)(`div`,{className:qe.modalTitle,children:s.contactId?`Edit Birthday`:`Add Birthday`}),(0,A.jsx)(`label`,{className:qe.label,children:`Name *`}),(0,A.jsx)(`input`,{className:qe.input,value:s.name,onChange:e=>c(t=>t&&{...t,name:e.target.value}),placeholder:`Contact name`}),(0,A.jsx)(`label`,{className:qe.label,children:`Birthday (MM-DD or YYYY-MM-DD)`}),(0,A.jsx)(`input`,{className:qe.input,value:s.date,onChange:e=>c(t=>t&&{...t,date:e.target.value}),placeholder:`e.g. 03-15 or 1990-03-15`}),(0,A.jsx)(`div`,{className:qe.hint,children:`Birthday will be saved as a Google Calendar event.`}),l&&(0,A.jsx)(`div`,{className:qe.formErr,children:l}),(0,A.jsxs)(`div`,{className:qe.modalBtns,children:[(0,A.jsx)(`button`,{className:qe.cancelBtn,onClick:()=>c(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:qe.saveBtn,onClick:g,disabled:d,children:d?`Saving…`:s.contactId?`Save`:`Add`})]})]})})]})}var V={root:`_root_1z04o_1`,header:`_header_1z04o_3`,title:`_title_1z04o_4`,subtitle:`_subtitle_1z04o_5`,code:`_code_1z04o_6`,addBtn:`_addBtn_1z04o_8`,tabs:`_tabs_1z04o_10`,tab:`_tab_1z04o_10`,tabActive:`_tabActive_1z04o_12`,loading:`_loading_1z04o_14`,err:`_err_1z04o_15`,empty:`_empty_1z04o_17`,emptyIcon:`_emptyIcon_1z04o_18`,emptyTitle:`_emptyTitle_1z04o_19`,emptySub:`_emptySub_1z04o_20`,card:`_card_1z04o_23`,cardDisabled:`_cardDisabled_1z04o_24`,cardTop:`_cardTop_1z04o_25`,cardLeft:`_cardLeft_1z04o_26`,jobName:`_jobName_1z04o_27`,schedule:`_schedule_1z04o_28`,agentBadge:`_agentBadge_1z04o_29`,statusBadge:`_statusBadge_1z04o_30`,statusActive:`_statusActive_1z04o_31`,statusPaused:`_statusPaused_1z04o_32`,jobPrompt:`_jobPrompt_1z04o_33`,jobMeta:`_jobMeta_1z04o_34`,cardActions:`_cardActions_1z04o_35`,runBtn:`_runBtn_1z04o_36`,editBtn:`_editBtn_1z04o_37`,pauseBtn:`_pauseBtn_1z04o_38`,resumeBtn:`_resumeBtn_1z04o_39`,delBtn:`_delBtn_1z04o_40`,templates:`_templates_1z04o_43`,templatesNote:`_templatesNote_1z04o_44`,templateCard:`_templateCard_1z04o_45`,templateLabel:`_templateLabel_1z04o_46`,templatePrompt:`_templatePrompt_1z04o_47`,templateBtns:`_templateBtns_1z04o_48`,scheduleTplBtn:`_scheduleTplBtn_1z04o_49`,runTplBtn:`_runTplBtn_1z04o_50`,formOverlay:`_formOverlay_1z04o_54`,formModal:`_formModal_1z04o_55`,formTitle:`_formTitle_1z04o_56`,label:`_label_1z04o_57`,input:`_input_1z04o_58`,textarea:`_textarea_1z04o_59`,presets:`_presets_1z04o_61`,preset:`_preset_1z04o_61`,presetActive:`_presetActive_1z04o_63`,cronHints:`_cronHints_1z04o_65`,cronHint:`_cronHint_1z04o_65`,formErr:`_formErr_1z04o_70`,formOk:`_formOk_1z04o_71`,formBtns:`_formBtns_1z04o_72`,cancelBtn:`_cancelBtn_1z04o_73`,saveBtn:`_saveBtn_1z04o_74`},Ye=[{label:`Every 15 min`,value:`every 15 minutes`},{label:`Every 30 min`,value:`every 30 minutes`},{label:`Every hour`,value:`every hour`},{label:`Every 6h`,value:`every 6 hours`},{label:`Daily 8am`,value:`every day at 08:00`},{label:`Daily 9am`,value:`every day at 09:00`},{label:`Daily noon`,value:`every day at 12:00`},{label:`Daily 6pm`,value:`every day at 18:00`},{label:`Mon–Fri 9am`,value:`weekdays at 09:00`},{label:`Every Monday`,value:`every monday at 09:00`}],Xe=[{label:`🌅 Morning Briefing`,prompt:`Summarize my unread emails from the last 12 hours, check today's calendar events, list my top 3 priority tasks, and give me a focused action plan for the day.`},{label:`🌆 Evening Review`,prompt:`Review what I accomplished today: check completed tasks, summarize any important emails received, flag unresolved issues, and prepare a priority list for tomorrow.`},{label:`📰 News Digest`,prompt:`Search for the top AI, tech, and finance news from the last 24 hours. Summarize the 5 most important stories with key takeaways and market implications.`},{label:`📈 Market Update`,prompt:`Provide a comprehensive market update: macro environment, major indices performance, top movers, notable events, and key levels to watch. Use herald and mercury agents.`},{label:`🐙 GitHub Monitor`,prompt:`Check my GitHub notifications, summarize open issues and pull requests that need attention, and draft brief responses for the most urgent ones.`},{label:`📊 Weekly Report`,prompt:`Generate a weekly productivity report: tasks completed vs pending, email response rate, upcoming calendar events, and 3 strategic priorities for next week.`},{label:`🔒 Security Scan`,prompt:`Run a security awareness check: scan recent code commits for potential vulnerabilities, check dependency alerts, and summarize any security-related GitHub notifications.`},{label:`🎯 Goal Tracker`,prompt:`Review my tasks and notes for goal progress. Identify what's on track, what's at risk, and suggest one concrete action to unblock the most important goal.`}],Ze=[{label:`0 9 * * 1-5`,desc:`Mon–Fri at 9:00 AM`},{label:`0 */6 * * *`,desc:`Every 6 hours`},{label:`*/30 * * * *`,desc:`Every 30 minutes`},{label:`0 8 * * *`,desc:`Daily at 8:00 AM`},{label:`0 20 * * 5`,desc:`Every Friday at 8 PM`}];function Qe(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)({name:``,schedule:``,prompt:``,agent:``}),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(`jobs`),C=()=>{a(!0),E(`/api/cron`).then(e=>{e?.error?s(e.error):r(e?.jobs??[]),a(!1)}).catch(()=>{r([]),a(!1)})};(0,_.useEffect)(()=>{C()},[]);let w=()=>{d({name:``,schedule:``,prompt:``,agent:``}),h(``),v(``),b(null),l(!0)},ee=e=>{d({name:e.name??``,schedule:e.schedule,prompt:e.prompt??e.command??``,agent:e.agent??``}),h(``),v(``),b(e.id),l(!0)},te=async()=>{if(!u.schedule.trim()){h(`Schedule is required`);return}if(!u.prompt.trim()){h(`Task prompt is required`);return}p(!0),h(``);try{y?await D(`/api/cron/update`,{id:y,schedule:u.schedule,prompt:u.prompt,agent:u.agent||void 0,name:u.name||void 0}):await D(`/api/cron`,{schedule:u.schedule,prompt:u.prompt,agent:u.agent||void 0,name:u.name||void 0}),v(y?`Updated!`:`Job scheduled!`),setTimeout(()=>{v(``),l(!1)},1500),C()}catch(e){h(e.message??`Failed`)}p(!1)},T=(e,t)=>D(`/api/cron/toggle`,{id:e,enabled:!t}).then(C),O=e=>{confirm(`Delete this scheduled task?`)&&D(`/api/cron/delete`,{id:e}).then(C)},re=e=>{try{sessionStorage.setItem(`nha_chat_prefill`,e)}catch{}t(`chat`)},k=e=>{d(t=>({...t,prompt:e.prompt,name:e.label.replace(/^[^\s]+\s/,``)})),S(`jobs`),l(!0)};return(0,A.jsxs)(`div`,{className:V.root,children:[(0,A.jsxs)(`div`,{className:V.header,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:V.title,children:`⏰ Scheduled Tasks`}),(0,A.jsxs)(`div`,{className:V.subtitle,children:[`Automate agents on a recurring schedule. Daemon must be running: `,(0,A.jsx)(`code`,{className:V.code,children:`nha ops start`})]})]}),(0,A.jsx)(`button`,{className:V.addBtn,onClick:w,children:`+ New Task`})]}),(0,A.jsxs)(`div`,{className:V.tabs,children:[(0,A.jsxs)(`button`,{className:`${V.tab} ${x===`jobs`?V.tabActive:``}`,onClick:()=>S(`jobs`),children:[`Jobs (`,n.length,`)`]}),(0,A.jsx)(`button`,{className:`${V.tab} ${x===`templates`?V.tabActive:``}`,onClick:()=>S(`templates`),children:`Templates`})]}),x===`templates`&&(0,A.jsxs)(`div`,{className:V.templates,children:[(0,A.jsx)(`div`,{className:V.templatesNote,children:`Click a template to pre-fill the job form or run it immediately in Chat.`}),Xe.map(t=>(0,A.jsxs)(`div`,{className:V.templateCard,children:[(0,A.jsx)(`div`,{className:V.templateLabel,children:t.label}),(0,A.jsx)(`div`,{className:V.templatePrompt,children:t.prompt}),(0,A.jsxs)(`div`,{className:V.templateBtns,children:[(0,A.jsx)(`button`,{className:V.scheduleTplBtn,onClick:()=>k(t),children:`Schedule`}),(0,A.jsxs)(`button`,{className:V.runTplBtn,onClick:()=>re(t.prompt),children:[e(`cron.run`),` in Chat →`]})]})]},t.label))]}),x===`jobs`&&(0,A.jsxs)(A.Fragment,{children:[i&&(0,A.jsxs)(`div`,{className:V.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),`Loading jobs…`]}),o&&(0,A.jsx)(`div`,{className:V.err,children:o}),!i&&n.length===0&&!c&&(0,A.jsxs)(`div`,{className:V.empty,children:[(0,A.jsx)(`div`,{className:V.emptyIcon,children:`⏰`}),(0,A.jsxs)(`div`,{className:V.emptyTitle,children:[e(`cron.noJobs`),` tasks`]}),(0,A.jsx)(`div`,{className:V.emptySub,children:`Create a job to automate agents on a recurring schedule, or browse the Templates tab for ready-made automation recipes.`}),(0,A.jsx)(`button`,{className:V.addBtn,onClick:w,children:`+ New Task`})]}),n.map(e=>(0,A.jsxs)(`div`,{className:`${V.card} ${e.enabled?``:V.cardDisabled}`,children:[(0,A.jsxs)(`div`,{className:V.cardTop,children:[(0,A.jsxs)(`div`,{className:V.cardLeft,children:[e.name&&(0,A.jsx)(`div`,{className:V.jobName,children:e.name}),(0,A.jsx)(`code`,{className:V.schedule,children:e.schedule}),e.agent&&(0,A.jsx)(`span`,{className:V.agentBadge,children:e.agent}),(0,A.jsx)(`span`,{className:`${V.statusBadge} ${e.enabled?V.statusActive:V.statusPaused}`,children:e.enabled?`active`:`paused`})]}),(0,A.jsxs)(`div`,{className:V.cardActions,children:[(0,A.jsx)(`button`,{className:V.runBtn,onClick:()=>re(e.prompt??e.command??``),title:`Run now in Chat`,children:`▶`}),(0,A.jsx)(`button`,{className:V.editBtn,onClick:()=>ee(e),children:`Edit`}),(0,A.jsx)(`button`,{className:e.enabled?V.pauseBtn:V.resumeBtn,onClick:()=>T(e.id,e.enabled),children:e.enabled?`Pause`:`Resume`}),(0,A.jsx)(`button`,{className:V.delBtn,onClick:()=>O(e.id),children:`✕`})]})]}),(0,A.jsx)(`div`,{className:V.jobPrompt,children:e.prompt??e.command}),(0,A.jsxs)(`div`,{className:V.jobMeta,children:[e.runCount!==void 0&&(0,A.jsxs)(`span`,{children:[`ran `,e.runCount,`×`]}),e.lastRun&&(0,A.jsxs)(`span`,{children:[` · last `,new Date(e.lastRun).toLocaleString()]}),e.nextRun&&(0,A.jsxs)(`span`,{children:[` · next `,new Date(e.nextRun).toLocaleString()]})]})]},e.id))]}),c&&(0,A.jsx)(`div`,{className:V.formOverlay,onClick:e=>{e.target===e.currentTarget&&l(!1)},children:(0,A.jsxs)(`div`,{className:V.formModal,children:[(0,A.jsx)(`div`,{className:V.formTitle,children:y?`Edit Scheduled Task`:`New Scheduled Task`}),(0,A.jsx)(`label`,{className:V.label,children:`Name (optional)`}),(0,A.jsx)(`input`,{className:V.input,value:u.name,onChange:e=>d(t=>({...t,name:e.target.value})),placeholder:`e.g. Morning Briefing`}),(0,A.jsx)(`label`,{className:V.label,children:`Schedule *`}),(0,A.jsx)(`div`,{className:V.presets,children:Ye.map(e=>(0,A.jsx)(`button`,{className:`${V.preset} ${u.schedule===e.value?V.presetActive:``}`,onClick:()=>d(t=>({...t,schedule:e.value})),children:e.label},e.value))}),(0,A.jsx)(`input`,{className:V.input,value:u.schedule,onChange:e=>d(t=>({...t,schedule:e.target.value})),placeholder:`every day at 09:00 — or cron syntax: 0 9 * * 1-5`}),(0,A.jsx)(`div`,{className:V.cronHints,children:Ze.map(e=>(0,A.jsxs)(`span`,{className:V.cronHint,onClick:()=>d(t=>({...t,schedule:e.label})),children:[(0,A.jsx)(`code`,{children:e.label}),` `,e.desc]},e.label))}),(0,A.jsx)(`label`,{className:V.label,children:`Task / Prompt *`}),(0,A.jsx)(`textarea`,{className:V.textarea,value:u.prompt,onChange:e=>d(t=>({...t,prompt:e.target.value})),placeholder:`Describe what the agent should do (e.g. Summarize my unread emails and list my 3 top priority tasks)`,rows:4}),(0,A.jsx)(`label`,{className:V.label,children:`Agent (optional — leave blank for auto-routing)`}),(0,A.jsx)(`input`,{className:V.input,value:u.agent,onChange:e=>d(t=>({...t,agent:e.target.value})),placeholder:`e.g. herald, oracle, mercury, EmailAgent, general`}),m&&(0,A.jsx)(`div`,{className:V.formErr,children:m}),g&&(0,A.jsx)(`div`,{className:V.formOk,children:g}),(0,A.jsxs)(`div`,{className:V.formBtns,children:[(0,A.jsx)(`button`,{className:V.cancelBtn,onClick:()=>l(!1),children:`Cancel`}),(0,A.jsx)(`button`,{className:V.saveBtn,onClick:te,disabled:f,children:f?`Saving…`:y?`Update`:`Schedule`})]})]})})]})}var $e={root:`_root_1npv7_1`,loading:`_loading_1npv7_2`,sidebar:`_sidebar_1npv7_4`,newBtn:`_newBtn_1npv7_5`,empty:`_empty_1npv7_6`,noteItem:`_noteItem_1npv7_8`,noteItemActive:`_noteItemActive_1npv7_10`,noteTitle:`_noteTitle_1npv7_11`,noteMeta:`_noteMeta_1npv7_12`,notePreview:`_notePreview_1npv7_13`,noteTags:`_noteTags_1npv7_14`,noteTag:`_noteTag_1npv7_14`,editor:`_editor_1npv7_17`,emptyEditor:`_emptyEditor_1npv7_18`,titleInput:`_titleInput_1npv7_19`,contentArea:`_contentArea_1npv7_21`,editorFooter:`_editorFooter_1npv7_22`,delNoteBtn:`_delNoteBtn_1npv7_23`,cancelBtn:`_cancelBtn_1npv7_24`,saveBtn:`_saveBtn_1npv7_25`};function et(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=()=>E(`/api/notes`).then(e=>{n(e?.notes??[]),i(!1)});(0,_.useEffect)(()=>{h()},[]);let g=e=>{o(e),c(e.title),u(e.content),m(!1)},v=()=>{o(null),c(``),u(``),m(!0)},y=async()=>{f(!0),p?await D(`/api/notes`,{title:s||`Untitled`,content:l}):a&&await D(`/api/notes/${a.id}`,{title:s,content:l}),f(!1),m(!1),h()},b=(e,t)=>{confirm(`Delete note "${t}"?`)&&D(`/api/notes/${e}/delete`,{}).then(h)};return r?(0,A.jsxs)(`div`,{className:$e.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]}):(0,A.jsxs)(`div`,{className:$e.root,children:[(0,A.jsxs)(`div`,{className:$e.sidebar,children:[(0,A.jsx)(`button`,{className:$e.newBtn,onClick:v,children:`+ New Note`}),t.length===0&&(0,A.jsx)(`div`,{className:$e.empty,children:e(`notes.noNotes`)}),t.map(e=>(0,A.jsxs)(`div`,{className:`${$e.noteItem} ${a?.id===e.id?$e.noteItemActive:``}`,onClick:()=>g(e),children:[(0,A.jsx)(`div`,{className:$e.noteTitle,children:e.title||`Untitled`}),(0,A.jsx)(`div`,{className:$e.noteMeta,children:e.updatedAt?new Date(e.updatedAt).toLocaleDateString():``}),e.content&&(0,A.jsx)(`div`,{className:$e.notePreview,children:e.content.slice(0,150)}),e.tags&&e.tags.length>0&&(0,A.jsx)(`div`,{className:$e.noteTags,children:e.tags.map(e=>(0,A.jsx)(`span`,{className:$e.noteTag,children:e},e))})]},e.id))]}),(0,A.jsx)(`div`,{className:$e.editor,children:a||p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`input`,{className:$e.titleInput,value:s,onChange:e=>c(e.target.value),placeholder:`Note title…`}),(0,A.jsx)(`textarea`,{className:$e.contentArea,value:l,onChange:e=>u(e.target.value),placeholder:`Start writing…`}),(0,A.jsxs)(`div`,{className:$e.editorFooter,children:[a&&(0,A.jsx)(`button`,{className:$e.delNoteBtn,onClick:()=>b(a.id,a.title),children:e(`common.delete`)}),(0,A.jsx)(`button`,{className:$e.cancelBtn,onClick:()=>{o(null),m(!1)},children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:$e.saveBtn,onClick:y,disabled:d,children:d?`Saving…`:`Save`})]})]}):(0,A.jsx)(`div`,{className:$e.emptyEditor,children:`Select a note or create a new one`})})]})}var tt={root:`_root_18yos_1`,loading:`_loading_18yos_2`,error:`_error_18yos_3`,toolbar:`_toolbar_18yos_5`,search:`_search_18yos_6`,addBtn:`_addBtn_18yos_7`,count:`_count_18yos_10`,empty:`_empty_18yos_12`,grid:`_grid_18yos_14`,card:`_card_18yos_16`,actions:`_actions_18yos_29`,avatar:`_avatar_18yos_31`,avatarImg:`_avatarImg_18yos_38`,info:`_info_18yos_40`,name:`_name_18yos_41`,row:`_row_18yos_42`,email:`_email_18yos_43`,phone:`_phone_18yos_44`,company:`_company_18yos_45`,birthday:`_birthday_18yos_46`,iconBtn:`_iconBtn_18yos_52`,iconBtnRed:`_iconBtnRed_18yos_58`,overlay:`_overlay_18yos_61`,modal:`_modal_18yos_62`,modalTitle:`_modalTitle_18yos_63`,field:`_field_18yos_64`,label:`_label_18yos_65`,input:`_input_18yos_66`,formStatus:`_formStatus_18yos_67`,formError:`_formError_18yos_68`,modalBtns:`_modalBtns_18yos_69`,cancelBtn:`_cancelBtn_18yos_70`,saveBtn:`_saveBtn_18yos_71`},nt={name:``,email:``,phone:``,company:``,address:``,notes:``};function rt(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(``),y=(0,_.useRef)(null),b=(e=``)=>{E(e?`/api/contacts?q=${encodeURIComponent(e)}`:`/api/contacts`).then(e=>{r(e?.contacts??[]),a(!1),s(``)}).catch(()=>{s(`Could not load contacts. Run nha google revoke then nha google auth.`),a(!1)})};(0,_.useEffect)(()=>{b()},[]);let x=e=>{l(e),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>b(e),400)},S=()=>{d(null),p({...nt}),v(``)},C=e=>{d(e),p({name:e.name,email:e.email??``,phone:e.phone??``,company:e.company??``,address:e.address??``,notes:e.notes??``}),v(``)},w=async()=>{if(f?.name){h(!0),v(`Saving…`);try{if(u?.resourceName){let e=await D(`/api/contacts/update`,{resourceName:u.resourceName,fields:f});if(e?.error){v(`Error: `+e.error);return}}else if(u)await D(`/api/contacts/update`,{resourceName:u.id,fields:f});else{let e=await D(`/api/contacts`,f);if(e?.error){v(`Error: `+e.error);return}}v(`Saved!`),setTimeout(()=>{p(null),d(null),b(c)},800)}catch(e){v(`Error: `+e.message)}finally{h(!1)}}},ee=(e,t)=>{e.stopPropagation(),confirm(`Delete "${t.name}"?`)&&D(`/api/contacts/delete`,{resourceName:t.resourceName||t.id}).then(e=>{let t=e;if(t?.error){alert(`Error: `+t.error);return}b(c)})},te=(e,n,r)=>{e.stopPropagation(),t(`chat`),setTimeout(()=>{let e=document.getElementById(`chatInput`);e&&(e.value=`Send an email to ${r} (${n}) about `,e.focus())},300)},T=e=>(e||`?`).split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase();return i?(0,A.jsxs)(`div`,{className:tt.loading,children:[(0,A.jsx)(`div`,{className:`spinner`}),`Loading contacts…`]}):o?(0,A.jsx)(`div`,{className:tt.error,children:o}):(0,A.jsxs)(`div`,{className:tt.root,children:[(0,A.jsxs)(`div`,{className:tt.toolbar,children:[(0,A.jsx)(`input`,{className:tt.search,value:c,onChange:e=>x(e.target.value),placeholder:`Search contacts…`}),n.length>0&&(0,A.jsxs)(`span`,{className:tt.count,children:[n.length,` contact`,n.length===1?``:`s`]}),(0,A.jsx)(`button`,{className:tt.addBtn,onClick:S,children:`+ Add`})]}),n.length===0&&(0,A.jsxs)(`div`,{className:tt.empty,children:[e(`contacts.noContacts`),(0,A.jsx)(`br`,{}),`Add a Google account or add contacts manually.`]}),(0,A.jsx)(`div`,{className:tt.grid,children:n.map(e=>(0,A.jsxs)(`div`,{className:tt.card,onClick:()=>C(e),children:[(0,A.jsx)(`div`,{className:tt.avatar,children:e.photo?(0,A.jsx)(`img`,{src:e.photo,alt:e.name,className:tt.avatarImg}):T(e.name)}),(0,A.jsxs)(`div`,{className:tt.info,children:[(0,A.jsx)(`div`,{className:tt.name,children:e.name||`(no name)`}),(0,A.jsxs)(`div`,{className:tt.row,children:[e.email&&(0,A.jsx)(`span`,{className:tt.email,children:e.email}),e.phone&&(0,A.jsx)(`span`,{className:tt.phone,children:e.phone}),e.company&&(0,A.jsxs)(`span`,{className:tt.company,children:[e.company,e.title?` · ${e.title}`:``]}),e.birthday&&(0,A.jsxs)(`span`,{className:tt.birthday,children:[`🎂 `,e.birthday]})]})]}),(0,A.jsxs)(`div`,{className:tt.actions,children:[e.email&&(0,A.jsx)(`button`,{className:tt.iconBtn,onClick:t=>te(t,e.email,e.name),title:`Send email via chat`,children:`✉`}),(0,A.jsx)(`button`,{className:tt.iconBtn,onClick:t=>{t.stopPropagation(),C(e)},title:`Edit`,children:`✎`}),(0,A.jsx)(`button`,{className:`${tt.iconBtn} ${tt.iconBtnRed}`,onClick:t=>ee(t,e),title:`Delete`,children:`✕`})]})]},e.id))}),f&&(0,A.jsx)(`div`,{className:tt.overlay,onClick:e=>{e.target===e.currentTarget&&p(null)},children:(0,A.jsxs)(`div`,{className:tt.modal,children:[(0,A.jsx)(`div`,{className:tt.modalTitle,children:u?`Edit Contact`:`New Contact`}),[[`name`,`Name`,`Full name *`],[`email`,`Email`,`user@example.com`],[`phone`,`Phone`,`+1 555 123 4567`],[`company`,`Company`,`Acme Inc`],[`address`,`Address`,`123 Main St, New York`],[`notes`,`Notes`,`Any additional info`]].map(([e,t,n])=>(0,A.jsxs)(`div`,{className:tt.field,children:[(0,A.jsx)(`label`,{className:tt.label,children:t}),(0,A.jsx)(`input`,{className:tt.input,value:f[e],onChange:t=>p(n=>n&&{...n,[e]:t.target.value}),placeholder:n,onKeyDown:t=>t.key===`Enter`&&e===`name`&&w()})]},e)),g&&(0,A.jsx)(`div`,{className:g.startsWith(`Error`)?tt.formError:tt.formStatus,children:g}),(0,A.jsxs)(`div`,{className:tt.modalBtns,children:[(0,A.jsx)(`button`,{className:tt.cancelBtn,onClick:()=>p(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:tt.saveBtn,onClick:w,disabled:m||!f.name,children:m?`…`:`Save`})]})]})})]})}var H={root:`_root_19042_2`,topbar:`_topbar_19042_11`,topbarLeft:`_topbarLeft_19042_20`,topbarTitle:`_topbarTitle_19042_21`,topbarSub:`_topbarSub_19042_22`,topbarActions:`_topbarActions_19042_23`,runBtn:`_runBtn_19042_25`,runBtnActive:`_runBtnActive_19042_32`,logBtn:`_logBtn_19042_34`,newWfBtn:`_newWfBtn_19042_41`,body:`_body_19042_50`,sidebar:`_sidebar_19042_53`,sidebarTitle:`_sidebarTitle_19042_61`,sidebarEmpty:`_sidebarEmpty_19042_65`,wfItem:`_wfItem_19042_67`,wfItemActive:`_wfItemActive_19042_78`,wfItemRow:`_wfItemRow_19042_79`,wfItemName:`_wfItemName_19042_80`,wfItemMeta:`_wfItemMeta_19042_81`,wfOn:`_wfOn_19042_82`,wfOff:`_wfOff_19042_83`,wfDelBtn:`_wfDelBtn_19042_84`,canvasArea:`_canvasArea_19042_92`,canvasHeader:`_canvasHeader_19042_94`,wfNameInput:`_wfNameInput_19042_99`,canvasHint:`_canvasHint_19042_106`,portHint:`_portHint_19042_107`,connectHint:`_connectHint_19042_108`,cancelConnectBtn:`_cancelConnectBtn_19042_109`,canvas:`_canvas_19042_92`,canvasConnecting:`_canvasConnecting_19042_122`,canvasSvg:`_canvasSvg_19042_124`,canvasNode:`_canvasNode_19042_134`,canvasNodeSelected:`_canvasNodeSelected_19042_152`,canvasNodeConnecting:`_canvasNodeConnecting_19042_153`,nodeIcon:`_nodeIcon_19042_155`,nodeLabel:`_nodeLabel_19042_156`,nodeConfigPreview:`_nodeConfigPreview_19042_157`,nodeDelBtn:`_nodeDelBtn_19042_159`,portOut:`_portOut_19042_171`,portActive:`_portActive_19042_182`,portIn:`_portIn_19042_184`,pulse:`_pulse_19042_1`,canvasDrop:`_canvasDrop_19042_195`,canvasEmpty:`_canvasEmpty_19042_203`,canvasEmptyIcon:`_canvasEmptyIcon_19042_208`,canvasEmptyTitle:`_canvasEmptyTitle_19042_209`,canvasEmptyDesc:`_canvasEmptyDesc_19042_210`,logPanel:`_logPanel_19042_213`,logHeader:`_logHeader_19042_220`,logTime:`_logTime_19042_226`,logClose:`_logClose_19042_227`,logEmpty:`_logEmpty_19042_228`,logStep:`_logStep_19042_229`,logStepError:`_logStepError_19042_230`,logStepHeader:`_logStepHeader_19042_231`,logStepIcon:`_logStepIcon_19042_232`,logStepLabel:`_logStepLabel_19042_233`,logStepErrBadge:`_logStepErrBadge_19042_234`,logStepErr:`_logStepErr_19042_230`,logStepOutput:`_logStepOutput_19042_236`,rightPanel:`_rightPanel_19042_241`,configPanel:`_configPanel_19042_252`,configHeader:`_configHeader_19042_253`,configClose:`_configClose_19042_254`,configDesc:`_configDesc_19042_255`,configFields:`_configFields_19042_256`,configField:`_configField_19042_256`,configLabel:`_configLabel_19042_258`,configRequired:`_configRequired_19042_259`,configInput:`_configInput_19042_260`,configHint:`_configHint_19042_267`,configDelete:`_configDelete_19042_269`,palette:`_palette_19042_273`,paletteTitle:`_paletteTitle_19042_274`,paletteTabs:`_paletteTabs_19042_275`,paletteTab:`_paletteTab_19042_275`,paletteTabActive:`_paletteTabActive_19042_281`,paletteNodes:`_paletteNodes_19042_282`,paletteDef:`_paletteDef_19042_284`,paletteDefIcon:`_paletteDefIcon_19042_292`,paletteDefLabel:`_paletteDefLabel_19042_293`,paletteDefDesc:`_paletteDefDesc_19042_294`,paletteFooter:`_paletteFooter_19042_296`,paletteGuide:`_paletteGuide_19042_300`,guideTitle:`_guideTitle_19042_308`,guideStep:`_guideStep_19042_317`,guideNum:`_guideNum_19042_325`,guideTip:`_guideTip_19042_341`,guideCode:`_guideCode_19042_352`},it=[{id:`trigger_manual`,type:`trigger`,label:`Manual`,icon:`▶`,color:`#6366f1`,description:`Run manually with optional text input.`,configFields:[{key:`input`,label:`Input text`,placeholder:`Optional initial input`}]},{id:`trigger_cron`,type:`trigger`,label:`Cron`,icon:`⏰`,color:`#fbbf24`,description:`Run on a schedule (cron expression).`,configFields:[{key:`schedule`,label:`Cron expression`,placeholder:`0 8 * * *`,required:!0}]},{id:`trigger_email`,type:`trigger`,label:`New Email`,icon:`📧`,color:`#38bdf8`,description:`Trigger when a new email arrives matching a filter.`,configFields:[{key:`filter`,label:`Gmail filter`,placeholder:`subject:TODO is:unread`}]},{id:`trigger_webhook`,type:`trigger`,label:`Webhook`,icon:`🔗`,color:`#a5b4fc`,description:`Trigger via HTTP POST.`,configFields:[{key:`path`,label:`Path`,placeholder:`/hook/my-trigger`}]},{id:`action_email`,type:`action`,label:`Send Email`,icon:`✉`,color:`#38bdf8`,description:`Send email via Gmail or IMAP.`,configFields:[{key:`to`,label:`To`,placeholder:`email@example.com`,required:!0},{key:`subject`,label:`Subject`,placeholder:`Subject or {{output}}`},{key:`body`,label:`Body`,placeholder:`{{output}}`}]},{id:`action_slack`,type:`action`,label:`Slack Message`,icon:`💬`,color:`#818cf8`,description:`Post a message to a Slack channel.`,configFields:[{key:`channel`,label:`Channel`,placeholder:`#general`,required:!0},{key:`text`,label:`Text`,placeholder:`{{output}}`}]},{id:`action_calendar`,type:`action`,label:`Create Event`,icon:`📅`,color:`#4ade80`,description:`Create a Google Calendar event.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`date`,label:`Date (YYYY-MM-DD)`,placeholder:`2025-01-15`},{key:`time`,label:`Time (HH:MM)`,placeholder:`09:00`}]},{id:`action_task`,type:`action`,label:`Create Task`,icon:`✅`,color:`#fbbf24`,description:`Add a task to your task list.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`priority`,label:`Priority`,placeholder:`medium`}]},{id:`action_drive`,type:`action`,label:`Save to Drive`,icon:`💾`,color:`#a78bfa`,description:`Save a text file to Google Drive.`,configFields:[{key:`name`,label:`Filename`,placeholder:`output.txt`,required:!0},{key:`content`,label:`Content`,placeholder:`{{output}}`}]},{id:`action_notion`,type:`action`,label:`Notion Page`,icon:`📋`,color:`#e4e4e7`,description:`Create or update a Notion page.`,configFields:[{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`content`,label:`Content`,placeholder:`{{output}}`}]},{id:`action_github`,type:`action`,label:`GitHub Issue`,icon:`🐙`,color:`#6ee7b7`,description:`Create a GitHub issue.`,configFields:[{key:`repo`,label:`Repo (owner/name)`,placeholder:`user/repo`,required:!0},{key:`title`,label:`Title`,placeholder:`{{output}}`,required:!0},{key:`body`,label:`Body`,placeholder:``}]},{id:`action_webhook`,type:`action`,label:`HTTP Request`,icon:`🌐`,color:`#38bdf8`,description:`Make an HTTP request.`,configFields:[{key:`url`,label:`URL`,placeholder:`https://…`,required:!0},{key:`method`,label:`Method`,placeholder:`POST`},{key:`body`,label:`Body`,placeholder:`{{output}}`}]},{id:`ai_agent`,type:`ai`,label:`Run Agent`,icon:`🤖`,color:`#818cf8`,description:`Run any of the 38 NHA specialist agents.`,configFields:[{key:`agent`,label:`Agent name`,placeholder:`herald, saber, forge…`,required:!0},{key:`prompt`,label:`Prompt`,placeholder:`Summarize this: {{output}}`,required:!0}]},{id:`ai_summarize`,type:`ai`,label:`Summarize`,icon:`📝`,color:`#a5b4fc`,description:`Summarize text with AI (free via Liara).`,configFields:[{key:`prompt`,label:`Prompt`,placeholder:`Summarize: {{output}}`}]},{id:`ai_classify`,type:`ai`,label:`Classify`,icon:`🏷`,color:`#a5b4fc`,description:`Classify content into categories.`,configFields:[{key:`categories`,label:`Categories (comma-separated)`,placeholder:`urgent, normal, spam`},{key:`prompt`,label:`Prompt`,placeholder:`Classify this email: {{output}}`}]},{id:`ai_extract`,type:`ai`,label:`Extract Data`,icon:`🔍`,color:`#a5b4fc`,description:`Extract structured data from text.`,configFields:[{key:`prompt`,label:`What to extract`,placeholder:`Extract name, email, date from: {{output}}`}]},{id:`ai_translate`,type:`ai`,label:`Translate`,icon:`🌍`,color:`#a5b4fc`,description:`Translate text to another language.`,configFields:[{key:`lang`,label:`Target language`,placeholder:`Italian`,required:!0},{key:`prompt`,label:`Text`,placeholder:`{{output}}`}]}],at=Object.fromEntries(it.map(e=>[e.id,e])),ot=90,st=72;function ct(){return`n_${Date.now()}_${Math.random().toString(36).slice(2,6)}`}function lt(e,t){return{x:e.x+(t===`out`?ot:0),y:e.y+st/2}}function ut(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(`trigger`),g=(0,_.useRef)(null),v=(0,_.useRef)(null),y=(0,_.useRef)(null),b=(0,_.useCallback)(async()=>{let e=(await E(`/api/workflows`).catch(()=>null))?.workflows??[];t(e),r(t=>t?e.find(e=>e.id===t.id)??e[0]??null:e[0]??null)},[]);(0,_.useEffect)(()=>{b()},[b]);let x=(0,_.useCallback)(async e=>{r(e),t(t=>t.map(t=>t.id===e.id?e:t)),await D(`/api/workflows/${e.id}`,e,`PUT`).catch(()=>null)},[]),S=async()=>{let e={id:`wf_${Date.now()}`,name:`New Workflow`,enabled:!1,nodes:[],edges:[],nodeDefs:it},n=(await D(`/api/workflows`,e).catch(()=>null))?.workflow??e;t(e=>[...e,n]),r(n),a(null),d([]),p(!1)},C=async e=>{confirm(`Delete this workflow?`)&&(await D(`/api/workflows/${e}`,{},`DELETE`).catch(()=>null),b())},w=(0,_.useCallback)(e=>{e.preventDefault();let t=v.current;if(!t||!n)return;let r=y.current.getBoundingClientRect(),i=Math.round((e.clientX-r.left-ot/2)/20)*20,o=Math.round((e.clientY-r.top-st/2)/20)*20,s={id:ct(),defId:t,x:Math.max(0,i),y:Math.max(0,o),config:{}};x({...n,nodes:[...n.nodes,s]}),a(s.id),v.current=null},[n,x]),ee=(0,_.useCallback)((e,t)=>{if(e.stopPropagation(),o){o!==t&&n&&(n.edges.some(e=>e.from===o&&e.to===t)||x({...n,edges:[...n.edges,{from:o,to:t}]})),s(null);return}a(t);let r=n?.nodes.find(e=>e.id===t);r&&(g.current={id:t,ox:e.clientX-r.x,oy:e.clientY-r.y})},[o,n,x]),te=(0,_.useCallback)(e=>{if(!g.current||!n)return;let{id:t,ox:i,oy:a}=g.current,o=e.clientX-i,s=e.clientY-a,c=Math.max(0,Math.round(o/20)*20),l=Math.max(0,Math.round(s/20)*20);r(e=>e&&{...e,nodes:e.nodes.map(e=>e.id===t?{...e,x:c,y:l}:e)})},[n]),ne=(0,_.useCallback)(()=>{if(!g.current||!n){g.current=null;return}n.nodes.find(e=>e.id===g.current.id)&&x(n),g.current=null},[n,x]),T=(0,_.useCallback)(e=>{n&&(x({...n,nodes:n.nodes.filter(t=>t.id!==e),edges:n.edges.filter(t=>t.from!==e&&t.to!==e)}),a(null))},[n,x]),O=(0,_.useCallback)((e,t)=>{n&&x({...n,edges:n.edges.filter(n=>!(n.from===e&&n.to===t))})},[n,x]),re=(0,_.useCallback)((e,i,a)=>{if(!n)return;let o={...n,nodes:n.nodes.map(t=>t.id===e?{...t,config:{...t.config,[i]:a}}:t)};r(o),t(e=>e.map(e=>e.id===o.id?o:e))},[n]),k=(0,_.useCallback)(()=>{n&&x(n)},[n,x]),ie=async()=>{if(!(!n||c)){l(!0),p(!0),d([]);try{let e={...n,nodeDefs:it};await D(`/api/workflows/${n.id}`,e,`PUT`).catch(()=>null),d((await D(`/api/workflows/${n.id}/run`,{}))?.steps??[]),b()}catch(e){d([{nodeId:`__error`,nodeLabel:`Error`,nodeIcon:`❌`,output:``,error:e.message}])}finally{l(!1)}}},j=async e=>{let i={...e,enabled:!e.enabled};await D(`/api/workflows/${e.id}`,i,`PUT`).catch(()=>null),t(t=>t.map(t=>t.id===e.id?i:t)),n?.id===e.id&&r(i)},M=n?.nodes.find(e=>e.id===i)??null,ae=M?at[M.defId]:null;return(0,A.jsxs)(`div`,{className:H.root,children:[(0,A.jsxs)(`div`,{className:H.topbar,children:[(0,A.jsxs)(`div`,{className:H.topbarLeft,children:[(0,A.jsx)(`span`,{className:H.topbarTitle,children:`Connectors`}),(0,A.jsx)(`span`,{className:H.topbarSub,children:`Visual workflow automation · 80 tools · 38 AI agents · free AI via Liara`})]}),(0,A.jsxs)(`div`,{className:H.topbarActions,children:[n&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:`${H.runBtn} ${c?H.runBtnActive:``}`,onClick:ie,disabled:c||n.nodes.length===0,children:c?`⏳ Running…`:`▶ Run`}),(0,A.jsx)(`button`,{className:H.logBtn,onClick:()=>p(e=>!e),children:f?`Hide Log`:`📋 Log`})]}),(0,A.jsx)(`button`,{className:H.newWfBtn,onClick:S,children:`+ New Workflow`})]})]}),(0,A.jsxs)(`div`,{className:H.body,children:[(0,A.jsxs)(`div`,{className:H.sidebar,children:[(0,A.jsx)(`div`,{className:H.sidebarTitle,children:`Workflows`}),e.length===0&&(0,A.jsxs)(`div`,{className:H.sidebarEmpty,children:[`No workflows yet.`,(0,A.jsx)(`br`,{}),`Click "New Workflow" to start.`]}),e.map(e=>(0,A.jsxs)(`div`,{className:`${H.wfItem} ${n?.id===e.id?H.wfItemActive:``}`,onClick:()=>{r(e),a(null),d(e.lastRun?.steps??[]),p(!1)},children:[(0,A.jsxs)(`div`,{className:H.wfItemRow,children:[(0,A.jsx)(`span`,{className:H.wfItemName,children:e.name}),(0,A.jsx)(`button`,{className:e.enabled?H.wfOn:H.wfOff,onClick:t=>{t.stopPropagation(),j(e)},children:e.enabled?`ON`:`OFF`})]}),(0,A.jsxs)(`div`,{className:H.wfItemMeta,children:[e.nodes.length,` nodes · `,e.edges.length,` edges`,e.lastRun&&(0,A.jsxs)(`span`,{children:[` · ran `,new Date(e.lastRun.at).toLocaleTimeString()]})]}),(0,A.jsx)(`button`,{className:H.wfDelBtn,onClick:t=>{t.stopPropagation(),C(e.id)},children:`✕`})]},e.id))]}),(0,A.jsx)(`div`,{className:H.canvasArea,children:n?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:H.canvasHeader,children:[(0,A.jsx)(`input`,{className:H.wfNameInput,value:n.name,onChange:e=>r(t=>t&&{...t,name:e.target.value}),onBlur:()=>n&&x(n)}),o?(0,A.jsxs)(`span`,{className:H.connectHint,children:[`Click a target node to connect · `,(0,A.jsx)(`button`,{className:H.cancelConnectBtn,onClick:()=>s(null),children:`Cancel`})]}):(0,A.jsxs)(`span`,{className:H.canvasHint,children:[`Drag nodes from palette · Click `,(0,A.jsx)(`span`,{className:H.portHint,children:`▶`}),` to connect · Drag nodes to reposition`]})]}),(0,A.jsxs)(`div`,{ref:y,className:`${H.canvas} ${o?H.canvasConnecting:``}`,onMouseMove:te,onMouseUp:ne,onMouseLeave:ne,onDragOver:e=>e.preventDefault(),onDrop:w,onClick:()=>{o||a(null)},children:[(0,A.jsx)(`svg`,{className:H.canvasSvg,children:n.edges.map((e,t)=>{let r=n.nodes.find(t=>t.id===e.from),i=n.nodes.find(t=>t.id===e.to);if(!r||!i)return null;let a=lt(r,`out`),o=lt(i,`in`),s=(a.x+o.x)/2;return(0,A.jsxs)(`g`,{children:[(0,A.jsx)(`path`,{d:`M${a.x},${a.y} C${s},${a.y} ${s},${o.y} ${o.x},${o.y}`,stroke:`var(--green3)`,strokeWidth:`2`,fill:`none`,strokeDasharray:`6,3`,opacity:`0.8`}),(0,A.jsx)(`path`,{d:`M${a.x},${a.y} C${s},${a.y} ${s},${o.y} ${o.x},${o.y}`,stroke:`transparent`,strokeWidth:`12`,fill:`none`,style:{cursor:`pointer`},onClick:t=>{t.stopPropagation(),O(e.from,e.to)}}),(0,A.jsx)(`circle`,{cx:s,cy:(a.y+o.y)/2,r:`7`,fill:`var(--bg2)`,stroke:`var(--border)`,strokeWidth:`1.5`,style:{cursor:`pointer`},onClick:t=>{t.stopPropagation(),O(e.from,e.to)}}),(0,A.jsx)(`text`,{x:s,y:(a.y+o.y)/2+4,textAnchor:`middle`,fill:`var(--dim)`,fontSize:`9`,style:{cursor:`pointer`,pointerEvents:`none`},children:`✕`})]},t)})}),n.nodes.map(e=>{let t=at[e.defId];if(!t)return null;let n=i===e.id,r=o===e.id;return(0,A.jsxs)(`div`,{className:`${H.canvasNode} ${n?H.canvasNodeSelected:``} ${r?H.canvasNodeConnecting:``}`,style:{left:e.x,top:e.y,borderColor:t.color+(n?`ff`:`88`),background:t.color+`18`},onMouseDown:t=>ee(t,e.id),onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`button`,{className:H.nodeDelBtn,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),T(e.id)},children:`✕`}),(0,A.jsx)(`span`,{className:H.nodeIcon,children:t.icon}),(0,A.jsx)(`span`,{className:H.nodeLabel,style:{color:t.color},children:t.label}),Object.values(e.config).filter(Boolean).slice(0,1).map((e,t)=>(0,A.jsx)(`span`,{className:H.nodeConfigPreview,children:String(e).slice(0,14)},t)),(0,A.jsx)(`button`,{className:`${H.portOut} ${r?H.portActive:``}`,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),s(t=>t===e.id?null:e.id)},title:`Connect from here`,children:`▶`}),o&&o!==e.id&&(0,A.jsx)(`button`,{className:H.portIn,onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),ee(t,e.id)},title:`Connect here`,children:`◀`})]},e.id)}),n.nodes.length===0&&(0,A.jsx)(`div`,{className:H.canvasDrop,children:`Drag nodes from the right panel and drop here`})]}),f&&(0,A.jsxs)(`div`,{className:H.logPanel,children:[(0,A.jsxs)(`div`,{className:H.logHeader,children:[(0,A.jsx)(`span`,{children:`Run Log`}),n.lastRun&&(0,A.jsx)(`span`,{className:H.logTime,children:new Date(n.lastRun.at).toLocaleString()}),(0,A.jsx)(`button`,{className:H.logClose,onClick:()=>p(!1),children:`✕`})]}),u.length===0&&(0,A.jsx)(`div`,{className:H.logEmpty,children:c?`Running…`:`No run results yet.`}),u.map((e,t)=>(0,A.jsxs)(`div`,{className:`${H.logStep} ${e.error?H.logStepError:``}`,children:[(0,A.jsxs)(`div`,{className:H.logStepHeader,children:[(0,A.jsx)(`span`,{className:H.logStepIcon,children:e.nodeIcon}),(0,A.jsx)(`span`,{className:H.logStepLabel,children:e.nodeLabel}),e.error&&(0,A.jsx)(`span`,{className:H.logStepErrBadge,children:`ERROR`})]}),e.error&&(0,A.jsx)(`div`,{className:H.logStepErr,children:e.error}),e.output&&(0,A.jsx)(`div`,{className:H.logStepOutput,dangerouslySetInnerHTML:{__html:de(e.output.slice(0,500))}})]},t))]})]}):(0,A.jsxs)(`div`,{className:H.canvasEmpty,children:[(0,A.jsx)(`div`,{className:H.canvasEmptyIcon,children:`🔗`}),(0,A.jsx)(`div`,{className:H.canvasEmptyTitle,children:`Select or create a workflow`}),(0,A.jsxs)(`div`,{className:H.canvasEmptyDesc,children:[`Drag nodes from the right panel onto the canvas.`,(0,A.jsx)(`br`,{}),`Connect them by clicking the `,(0,A.jsx)(`span`,{className:H.portHint,children:`▶`}),` output port then the target node.`,(0,A.jsx)(`br`,{}),`Run with one click — all 80 NHA tools already authenticated.`]}),(0,A.jsx)(`button`,{className:H.newWfBtn,onClick:S,children:`+ New Workflow`})]})}),(0,A.jsx)(`div`,{className:H.rightPanel,children:M&&ae?(0,A.jsxs)(`div`,{className:H.configPanel,children:[(0,A.jsxs)(`div`,{className:H.configHeader,children:[(0,A.jsxs)(`span`,{style:{color:ae.color},children:[ae.icon,` `,ae.label]}),(0,A.jsx)(`button`,{className:H.configClose,onClick:()=>a(null),children:`✕`})]}),(0,A.jsx)(`div`,{className:H.configDesc,children:ae.description}),(0,A.jsx)(`div`,{className:H.configFields,children:(ae.configFields??[]).map(e=>(0,A.jsxs)(`div`,{className:H.configField,children:[(0,A.jsxs)(`label`,{className:H.configLabel,children:[e.label,e.required&&(0,A.jsx)(`span`,{className:H.configRequired,children:`*`})]}),(0,A.jsx)(`input`,{className:H.configInput,value:M.config[e.key]??``,placeholder:e.placeholder??``,onChange:t=>re(M.id,e.key,t.target.value),onBlur:k}),(e.placeholder?.includes(`{{`)??!1)&&(0,A.jsxs)(`div`,{className:H.configHint,children:[`Use `,(0,A.jsx)(`code`,{children:`{{output}}`}),` to pass previous node result`]})]},e.key))}),(0,A.jsx)(`button`,{className:H.configDelete,onClick:()=>T(M.id),children:`Delete node`})]}):(0,A.jsxs)(`div`,{className:H.palette,children:[(0,A.jsx)(`div`,{className:H.paletteTitle,children:`Node Palette`}),(0,A.jsx)(`div`,{className:H.paletteTabs,children:[{id:`trigger`,label:`Triggers`,color:`#fbbf24`},{id:`action`,label:`Actions`,color:`#38bdf8`},{id:`ai`,label:`AI`,color:`#a5b4fc`}].map(e=>(0,A.jsx)(`button`,{className:`${H.paletteTab} ${m===e.id?H.paletteTabActive:``}`,style:m===e.id?{borderColor:e.color,color:e.color}:{},onClick:()=>h(e.id),children:e.label},e.id))}),(0,A.jsx)(`div`,{className:H.paletteNodes,children:it.filter(e=>e.type===m).map(e=>(0,A.jsxs)(`div`,{className:H.paletteDef,style:{borderColor:e.color+`44`,background:e.color+`14`},draggable:!0,onDragStart:()=>{v.current=e.id},onDragEnd:()=>{v.current=null},children:[(0,A.jsx)(`span`,{className:H.paletteDefIcon,children:e.icon}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:H.paletteDefLabel,style:{color:e.color},children:e.label}),(0,A.jsx)(`div`,{className:H.paletteDefDesc,children:e.description})]})]},e.id))}),(0,A.jsxs)(`div`,{className:H.paletteGuide,children:[(0,A.jsx)(`div`,{className:H.guideTitle,children:`How to use Connectors`}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`1`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Create`}),` a workflow with "+ New Workflow"`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`2`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Drag`}),` a Trigger node (e.g. Manual, Cron) onto the canvas`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`3`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Drag`}),` Action or AI nodes to chain operations`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`4`}),(0,A.jsxs)(`span`,{children:[`Click the `,(0,A.jsx)(`strong`,{style:{color:`var(--green3)`},children:`▶`}),` port on a node then click the next to `,(0,A.jsx)(`strong`,{children:`connect`}),` them`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`5`}),(0,A.jsxs)(`span`,{children:[(0,A.jsx)(`strong`,{children:`Click`}),` a node to configure it — use `,(0,A.jsx)(`code`,{className:H.guideCode,children:`{{output}}`}),` to pass the previous result`]})]}),(0,A.jsxs)(`div`,{className:H.guideStep,children:[(0,A.jsx)(`span`,{className:H.guideNum,children:`6`}),(0,A.jsxs)(`span`,{children:[`Press `,(0,A.jsx)(`strong`,{children:`▶ Run`}),` to execute · toggle `,(0,A.jsx)(`strong`,{children:`ON`}),` to run automatically (cron/webhook)`]})]}),(0,A.jsxs)(`div`,{className:H.guideTip,children:[(0,A.jsx)(`strong`,{children:`Tip:`}),` Click an edge to delete it. Drag nodes on the canvas to reposition. All 80 NHA tools are pre-authenticated — no extra setup.`]}),(0,A.jsxs)(`div`,{className:H.guideTip,children:[(0,A.jsx)(`strong`,{children:`AI nodes`}),` use Liara (free) by default. They receive `,(0,A.jsx)(`code`,{className:H.guideCode,children:`{{output}}`}),` from the previous step automatically.`]})]})]})})]})]})}var U={root:`_root_1ssbe_1`,sidebar:`_sidebar_1ssbe_12`,sidebarSection:`_sidebarSection_1ssbe_23`,sidebarLabel:`_sidebarLabel_1ssbe_28`,accountSelect:`_accountSelect_1ssbe_36`,sidebarCompose:`_sidebarCompose_1ssbe_46`,composeBtn:`_composeBtn_1ssbe_51`,folderList:`_folderList_1ssbe_63`,folderItem:`_folderItem_1ssbe_69`,folderActive:`_folderActive_1ssbe_82`,badge:`_badge_1ssbe_88`,labelHeader:`_labelHeader_1ssbe_103`,addLabelBtn:`_addLabelBtn_1ssbe_114`,newLabelRow:`_newLabelRow_1ssbe_123`,newLabelInput:`_newLabelInput_1ssbe_129`,newLabelSave:`_newLabelSave_1ssbe_139`,labelDot:`_labelDot_1ssbe_150`,syncArea:`_syncArea_1ssbe_158`,syncBtn:`_syncBtn_1ssbe_163`,messageList:`_messageList_1ssbe_175`,listHeader:`_listHeader_1ssbe_185`,searchInput:`_searchInput_1ssbe_194`,searchBtn:`_searchBtn_1ssbe_204`,listBody:`_listBody_1ssbe_214`,listLoading:`_listLoading_1ssbe_219`,noMessages:`_noMessages_1ssbe_224`,msgRow:`_msgRow_1ssbe_231`,msgUnread:`_msgUnread_1ssbe_242`,msgActive:`_msgActive_1ssbe_247`,msgTop:`_msgTop_1ssbe_251`,msgFrom:`_msgFrom_1ssbe_257`,msgDate:`_msgDate_1ssbe_270`,msgSubject:`_msgSubject_1ssbe_277`,msgPreview:`_msgPreview_1ssbe_289`,listFooter:`_listFooter_1ssbe_300`,loadMoreBtn:`_loadMoreBtn_1ssbe_311`,pane:`_pane_1ssbe_322`,emptyPane:`_emptyPane_1ssbe_330`,readingPane:`_readingPane_1ssbe_337`,paneToolbar:`_paneToolbar_1ssbe_344`,paneActions:`_paneActions_1ssbe_354`,replyBtn:`_replyBtn_1ssbe_360`,fwdBtn:`_fwdBtn_1ssbe_371`,trashBtn:`_trashBtn_1ssbe_371`,starBtn:`_starBtn_1ssbe_371`,aiBtn:`_aiBtn_1ssbe_384`,labelSelect:`_labelSelect_1ssbe_394`,paneHeader:`_paneHeader_1ssbe_403`,paneSubject:`_paneSubject_1ssbe_409`,paneMeta:`_paneMeta_1ssbe_416`,attachments:`_attachments_1ssbe_424`,attachLink:`_attachLink_1ssbe_431`,paneBody:`_paneBody_1ssbe_441`,bodyFrame:`_bodyFrame_1ssbe_447`,bodyText:`_bodyText_1ssbe_455`,composePane:`_composePane_1ssbe_465`,composeTitle:`_composeTitle_1ssbe_474`,composeField:`_composeField_1ssbe_483`,templateRow:`_templateRow_1ssbe_495`,templateToggle:`_templateToggle_1ssbe_500`,templateDrop:`_templateDrop_1ssbe_510`,templateItem:`_templateItem_1ssbe_524`,templateSubject:`_templateSubject_1ssbe_534`,composeBody:`_composeBody_1ssbe_540`,composeActions:`_composeActions_1ssbe_556`,sendBtn:`_sendBtn_1ssbe_563`,cancelBtn:`_cancelBtn_1ssbe_574`,compStatus:`_compStatus_1ssbe_584`,ok:`_ok_1ssbe_585`,err:`_err_1ssbe_586`},dt=[{id:`INBOX`,name:`Inbox`,icon:`✉`},{id:`SENT`,name:`Sent`,icon:`→`},{id:`DRAFTS`,name:`Drafts`,icon:`📄`},{id:`SPAM`,name:`Spam`,icon:`🛡`},{id:`TRASH`,name:`Trash`,icon:`🗑`}],ft=[{name:`Product Promo`,subject:`Discover our offer on [PRODUCT]`},{name:`Monthly Newsletter`,subject:`[COMPANY] Newsletter — [MONTH] [YEAR]`},{name:`Commercial Follow-up`,subject:`Following our conversation — [TOPIC]`},{name:`Offer / Quote`,subject:`Offer [NUMBER] — [SUBJECT]`},{name:`Event Invitation`,subject:`You are invited: [EVENT NAME] — [DATE]`},{name:`Customer Thank You`,subject:`Thank you for your trust, [NAME]`}];function pt(e){return e?e.slice(0,10):``}function mt(e){if(!e)return``;try{let t=typeof e==`string`?JSON.parse(e):e;return Array.isArray(t)?t.map(e=>e.name?`${e.name} <${e.address}>`:e.address||``).join(`, `):String(e)}catch{return String(e)}}function ht(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(`google`),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(`INBOX`),[m,h]=(0,_.useState)([]),[g,v]=(0,_.useState)(0),[y,b]=(0,_.useState)(0),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),[ee,te]=(0,_.useState)(!1),[T,O]=(0,_.useState)(!1),[re,k]=(0,_.useState)(``),[ie,j]=(0,_.useState)(``),[M,ae]=(0,_.useState)(0),[oe,N]=(0,_.useState)(!1),[se,P]=(0,_.useState)({}),[I,ce]=(0,_.useState)(``),[le,ue]=(0,_.useState)(``),[de,L]=(0,_.useState)(``),[fe,pe]=(0,_.useState)(``),[me,he]=(0,_.useState)(``),[R,ge]=(0,_.useState)(!1),[_e,ve]=(0,_.useState)(``),[ye,be]=(0,_.useState)(!1),xe=(0,_.useRef)(null);(0,_.useEffect)(()=>{E(`/api/config`).then(e=>r(!!e?.hasGoogle)),E(`/api/imap/accounts`).then(e=>{let t=e?.accounts??[];a(t),t.length>0?Se(t[0].id,`imap`):Se(`google`,`google`)})},[]);let Se=(e,t)=>{s(e),l(t),p(t===`google`?`INBOX`:null),h([]),b(0),S(null),w(null),t===`imap`?E(`/api/imap/labels?accountId=${e}`).then(t=>{let n=t?.labels??[];d(n);let r=n.find(e=>e.system_type===`inbox`)?.id??null;p(r),Ce(e,r,0,``)}):(d([]),we(`INBOX`,``))},Ce=(e,t,n,r)=>{te(!0);let i=`/api/imap/messages?accountId=${encodeURIComponent(e)}&limit=50&offset=${n}`;t&&(i+=`&labelId=${encodeURIComponent(t)}`),r&&(i+=`&search=${encodeURIComponent(r)}`),E(i).then(e=>{h(n===0?e?.messages??[]:t=>[...t,...e?.messages??[]]),v(e?.total??0),te(!1)}).catch(()=>te(!1))},we=(e,t)=>{te(!0);let n=e===`INBOX`||!e?`all`:e.toLowerCase(),r=`/api/emails?filter=${encodeURIComponent(t||n)}&page=0&pageSize=50`;t&&(r=`/api/emails?filter=${encodeURIComponent(t)}&page=0&pageSize=50`),E(r).then(e=>{let t=(e?.emails??[]).map(e=>({id:e.id,subject:e.subject,from_name:e.from,from_address:e.from,internal_date:e.date,body_preview:e.snippet,is_read:!e.isUnread,is_starred:!1,has_attachments:!1,_google:!0}));h(t),v(t.length);let n=t.filter(e=>!e.is_read).length;ae(n),te(!1)}).catch(()=>te(!1))},Te=()=>{k(ie),b(0),h([]),c===`imap`&&o?Ce(o,f,0,ie):we(f??`INBOX`,ie)},Ee=e=>{S(e),N(!1),O(!0),c===`google`?D(`/api/email/read`,{messageId:e}).then(t=>{w({...t?.message??t,id:e,_google:!0}),O(!1),D(`/api/email/mark-read`,{messageId:e}).catch(()=>{})}).catch(()=>O(!1)):E(`/api/imap/message?id=${encodeURIComponent(e)}`).then(t=>{w(t?.message??null),h(t=>t.map(t=>t.id===e?{...t,is_read:!0}:t)),O(!1)}).catch(()=>O(!1))},De=(e={})=>{N(!0),P(e),ce(e.to??``),ue(``),L(e.subject??``),pe(e.type===`forward`&&e.body?`\n\n---------- Forwarded message ----------\n${e.body}`:``),he(``),ge(!1),S(null),w(null)},Oe=async()=>{if(!I.trim()){he(`Recipient required`);return}he(`Sending…`);try{if(c===`imap`&&o){let e=await D(`/api/imap/send`,{accountId:o,to:I.trim(),cc:le.trim()||void 0,subject:de.trim(),bodyHtml:fe.replace(/\n/g,`<br>`),bodyText:fe,inReplyTo:se.inReplyTo||void 0});e?.ok?(he(`Sent!`),setTimeout(()=>N(!1),800)):he(e?.error??`Error`)}else{let e=await D(`/api/email/send`,{to:I.trim(),subject:de.trim(),body:fe});e?.ok||e?.id?(he(`Sent!`),setTimeout(()=>N(!1),800)):he(e?.error??`Error`)}}catch(e){he(e.message??`Error`)}},ke=e=>{confirm(`Move to trash? Email stays on the server.`)&&D(`/api/imap/trash`,{messageId:e}).then(()=>{h(t=>t.filter(t=>t.id!==e)),w(null),S(null)})},Ae=(e,t)=>{D(`/api/imap/mark-starred`,{messageId:e,isStarred:t}).then(()=>{C?.id===e&&w(e=>e&&{...e,is_starred:t})})},je=(e,t)=>{t&&D(`/api/imap/labels/assign`,{messageId:e,labelId:t})},Me=()=>{!_e.trim()||!o||D(`/api/imap/labels`,{accountId:o,name:_e.trim()}).then(()=>{be(!1),ve(``),E(`/api/imap/labels?accountId=${o}`).then(e=>d(e?.labels??[]))})};return(0,A.jsxs)(`div`,{className:U.root,children:[(0,A.jsxs)(`div`,{className:U.sidebar,children:[(0,A.jsxs)(`div`,{className:U.sidebarSection,children:[(0,A.jsx)(`div`,{className:U.sidebarLabel,children:`Account`}),(0,A.jsxs)(`select`,{className:U.accountSelect,value:c===`google`?`google`:`imap:${o}`,onChange:e=>{let t=e.target.value;t===`google`?Se(`google`,`google`):t.startsWith(`imap:`)&&Se(t.slice(5),`imap`)},children:[n&&(0,A.jsx)(`option`,{value:`google`,children:`Google (Gmail)`}),i.map(e=>(0,A.jsx)(`option`,{value:`imap:${e.id}`,children:e.display_name||e.email_address},e.id)),!n&&i.length===0&&(0,A.jsx)(`option`,{value:``,children:`No accounts — add in Settings`})]})]}),(0,A.jsx)(`div`,{className:U.sidebarCompose,children:(0,A.jsx)(`button`,{className:U.composeBtn,onClick:()=>De(),children:`+ Compose`})}),(0,A.jsx)(`div`,{className:U.folderList,children:c===`google`?dt.map(e=>(0,A.jsxs)(`div`,{className:`${U.folderItem} ${f===e.id?U.folderActive:``}`,onClick:()=>{p(e.id),h([]),b(0),we(e.id,re)},children:[(0,A.jsx)(`span`,{children:e.icon}),(0,A.jsx)(`span`,{children:e.name}),e.id===`INBOX`&&M>0&&(0,A.jsx)(`span`,{className:U.badge,children:M})]},e.id)):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:U.labelHeader,children:[(0,A.jsx)(`span`,{children:`Labels`}),(0,A.jsx)(`button`,{className:U.addLabelBtn,onClick:()=>be(e=>!e),children:`+`})]}),ye&&(0,A.jsxs)(`div`,{className:U.newLabelRow,children:[(0,A.jsx)(`input`,{className:U.newLabelInput,value:_e,onChange:e=>ve(e.target.value),placeholder:`Label name`,onKeyDown:e=>e.key===`Enter`&&Me()}),(0,A.jsx)(`button`,{className:U.newLabelSave,onClick:Me,children:`+`})]}),u.map(e=>(0,A.jsxs)(`div`,{className:`${U.folderItem} ${f===e.id?U.folderActive:``}`,onClick:()=>{p(e.id),h([]),b(0),o&&Ce(o,e.id,0,re)},children:[(0,A.jsx)(`span`,{className:U.labelDot,style:{background:e.color??`var(--dim)`}}),(0,A.jsx)(`span`,{children:e.name}),e.unread_count?(0,A.jsx)(`span`,{className:U.badge,children:e.unread_count}):null]},e.id))]})}),c===`imap`&&o&&(0,A.jsx)(`div`,{className:U.syncArea,children:(0,A.jsx)(`button`,{className:U.syncBtn,onClick:()=>{o&&c===`imap`&&D(`/api/imap/sync/${o}`,{})},children:`Sync now`})})]}),(0,A.jsxs)(`div`,{className:U.messageList,children:[(0,A.jsxs)(`div`,{className:U.listHeader,children:[(0,A.jsx)(`input`,{className:U.searchInput,value:ie,onChange:e=>j(e.target.value),placeholder:`Search…`,onKeyDown:e=>e.key===`Enter`&&Te()}),(0,A.jsx)(`button`,{className:U.searchBtn,onClick:Te,children:`Go`})]}),(0,A.jsxs)(`div`,{className:U.listBody,children:[ee&&(0,A.jsx)(`div`,{className:U.listLoading,children:(0,A.jsx)(`div`,{className:`spinner`})}),!ee&&m.length===0&&(0,A.jsx)(`div`,{className:U.noMessages,children:`No messages`}),m.map(e=>(0,A.jsxs)(`div`,{className:`${U.msgRow} ${e.id===x?U.msgActive:``} ${e.is_read?``:U.msgUnread}`,onClick:()=>Ee(e.id),children:[(0,A.jsxs)(`div`,{className:U.msgTop,children:[(0,A.jsx)(`span`,{className:U.msgFrom,children:e.from_name||e.from_address||``}),(0,A.jsx)(`span`,{className:U.msgDate,children:pt(e.internal_date)})]}),(0,A.jsx)(`div`,{className:U.msgSubject,children:e.subject||`(no subject)`}),(0,A.jsx)(`div`,{className:U.msgPreview,children:(e.body_preview||``).slice(0,80)})]},e.id))]}),(0,A.jsxs)(`div`,{className:U.listFooter,children:[(0,A.jsxs)(`span`,{children:[g,` messages`]}),m.length<g&&c===`imap`&&(0,A.jsx)(`button`,{className:U.loadMoreBtn,onClick:()=>{let e=y+50;b(e),o&&Ce(o,f,e,re)},children:`Load more`})]})]}),(0,A.jsx)(`div`,{className:U.pane,children:(()=>{if(oe)return(0,A.jsxs)(`div`,{className:U.composePane,children:[(0,A.jsx)(`div`,{className:U.composeTitle,children:e(`email.compose`)}),(0,A.jsx)(`input`,{className:U.composeField,value:I,onChange:e=>ce(e.target.value),placeholder:`To`}),(0,A.jsx)(`input`,{className:U.composeField,value:le,onChange:e=>ue(e.target.value),placeholder:`Cc`}),(0,A.jsx)(`input`,{className:U.composeField,value:de,onChange:e=>L(e.target.value),placeholder:`Subject`}),(0,A.jsxs)(`div`,{className:U.templateRow,children:[(0,A.jsx)(`button`,{className:U.templateToggle,onClick:()=>ge(e=>!e),children:`📄 Templates`}),R&&(0,A.jsx)(`div`,{className:U.templateDrop,children:ft.map((e,t)=>(0,A.jsxs)(`div`,{className:U.templateItem,onClick:()=>{L(t=>t||e.subject),ge(!1)},children:[(0,A.jsx)(`strong`,{children:e.name}),(0,A.jsx)(`div`,{className:U.templateSubject,children:e.subject})]},t))})]}),(0,A.jsx)(`textarea`,{className:U.composeBody,value:fe,onChange:e=>pe(e.target.value),placeholder:`Write your message…`}),(0,A.jsxs)(`div`,{className:U.composeActions,children:[(0,A.jsx)(`button`,{className:U.sendBtn,onClick:Oe,children:e(`email.send_ok`)}),(0,A.jsx)(`button`,{className:U.cancelBtn,onClick:()=>N(!1),children:`Discard`}),me&&(0,A.jsx)(`span`,{className:`${U.compStatus} ${me===`Sent!`?U.ok:U.err}`,children:me})]})]});if(T)return(0,A.jsx)(`div`,{className:U.emptyPane,children:(0,A.jsx)(`div`,{className:`spinner`})});if(!C)return(0,A.jsx)(`div`,{className:U.emptyPane,children:`Select a message`});let n=mt(C.to_addresses);return(0,A.jsxs)(`div`,{className:U.readingPane,children:[(0,A.jsx)(`div`,{className:U.paneToolbar,children:(0,A.jsxs)(`div`,{className:U.paneActions,children:[(0,A.jsx)(`button`,{className:U.replyBtn,onClick:()=>De({to:C.from_address,subject:`Re: ${C.subject??``}`,inReplyTo:C.message_id??C.id,replyTo:C.id,type:`reply`}),children:e(`email.reply`)}),(0,A.jsx)(`button`,{className:U.fwdBtn,onClick:()=>De({subject:`Fwd: ${C.subject??``}`,type:`forward`,body:C.body_text??C.body_preview??``}),children:`Forward`}),!C._google&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{className:U.trashBtn,onClick:()=>ke(C.id),children:`🗑`}),(0,A.jsx)(`button`,{className:U.starBtn,onClick:()=>Ae(C.id,!C.is_starred),children:C.is_starred?`★`:`☆`}),u.length>0&&(0,A.jsxs)(`select`,{className:U.labelSelect,defaultValue:``,onChange:e=>je(C.id,e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`+ Label`}),u.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,A.jsx)(`button`,{className:U.aiBtn,onClick:()=>t(`chat`),children:`Ask AI`})]})}),(0,A.jsxs)(`div`,{className:U.paneHeader,children:[(0,A.jsx)(`div`,{className:U.paneSubject,children:C.subject||`(no subject)`}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`From:`}),` `,C.from_name&&C.from_name!==C.from_address?`${C.from_name} <${C.from_address}>`:C.from_address]}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`To:`}),` `,n]}),(0,A.jsxs)(`div`,{className:U.paneMeta,children:[(0,A.jsx)(`strong`,{children:`Date:`}),` `,C.internal_date]}),C.attachments&&C.attachments.length>0&&(0,A.jsx)(`div`,{className:U.attachments,children:C.attachments.map((e,t)=>(0,A.jsxs)(`a`,{className:U.attachLink,href:`/api/imap/attachment?messageId=${encodeURIComponent(C.id)}&partId=${encodeURIComponent(e.part_id??``)}&accountId=${encodeURIComponent(o??``)}`,download:e.filename??`attachment`,children:[`📎 `,e.filename??`attachment`,` (`,Math.round((e.size_bytes??0)/1024),`KB)`]},t))})]}),(0,A.jsx)(`div`,{className:U.paneBody,children:C.body_html?(0,A.jsx)(`iframe`,{ref:xe,sandbox:`allow-same-origin`,className:U.bodyFrame,srcDoc:C.body_html,title:`Email body`}):(0,A.jsx)(`pre`,{className:U.bodyText,children:C.body_text??C.body_preview??`(empty)`})})]})})()})]})}var W={root:`_root_1u06k_1`,center:`_center_1u06k_10`,noGoogle:`_noGoogle_1u06k_17`,noGoogleIcon:`_noGoogleIcon_1u06k_26`,noGoogleTitle:`_noGoogleTitle_1u06k_27`,noGoogleSub:`_noGoogleSub_1u06k_28`,connectBtn:`_connectBtn_1u06k_30`,calCol:`_calCol_1u06k_42`,navRow:`_navRow_1u06k_50`,navBtn:`_navBtn_1u06k_57`,monthTitle:`_monthTitle_1u06k_70`,dayHeaders:`_dayHeaders_1u06k_78`,dayHeader:`_dayHeader_1u06k_78`,weekend:`_weekend_1u06k_92`,grid:`_grid_1u06k_94`,cell:`_cell_1u06k_103`,emptyCell:`_emptyCell_1u06k_119`,weekendCell:`_weekendCell_1u06k_121`,todayCell:`_todayCell_1u06k_122`,activeCell:`_activeCell_1u06k_123`,hasEvtsCell:`_hasEvtsCell_1u06k_124`,holidayCell:`_holidayCell_1u06k_125`,dayNum:`_dayNum_1u06k_127`,todayNum:`_todayNum_1u06k_133`,weekendNum:`_weekendNum_1u06k_134`,evtPills:`_evtPills_1u06k_136`,evtPill:`_evtPill_1u06k_136`,holidayPill:`_holidayPill_1u06k_156`,morePill:`_morePill_1u06k_158`,loadingBar:`_loadingBar_1u06k_164`,detailCol:`_detailCol_1u06k_173`,detailHeader:`_detailHeader_1u06k_184`,detailDate:`_detailDate_1u06k_192`,addEvtBtn:`_addEvtBtn_1u06k_198`,noEvts:`_noEvts_1u06k_210`,selectDay:`_selectDay_1u06k_217`,evtCard:`_evtCard_1u06k_224`,evtTop:`_evtTop_1u06k_234`,evtTime:`_evtTime_1u06k_241`,evtBtns:`_evtBtns_1u06k_247`,editBtn:`_editBtn_1u06k_253`,delBtn:`_delBtn_1u06k_263`,readOnly:`_readOnly_1u06k_273`,evtTitle:`_evtTitle_1u06k_280`,evtLoc:`_evtLoc_1u06k_286`,evtMeta:`_evtMeta_1u06k_287`,attendees:`_attendees_1u06k_289`,attendee:`_attendee_1u06k_289`,evtDesc:`_evtDesc_1u06k_300`,joinBtn:`_joinBtn_1u06k_310`,gcalLink:`_gcalLink_1u06k_317`,overlay:`_overlay_1u06k_324`,formCard:`_formCard_1u06k_334`,formTitle:`_formTitle_1u06k_348`,formLabel:`_formLabel_1u06k_355`,formInput:`_formInput_1u06k_361`,formTextarea:`_formTextarea_1u06k_374`,formError:`_formError_1u06k_390`,formBtns:`_formBtns_1u06k_395`,cancelFormBtn:`_cancelFormBtn_1u06k_402`,saveFormBtn:`_saveFormBtn_1u06k_412`};function gt(e,t,n){return`${e}-${String(t+1).padStart(2,`0`)}-${String(n).padStart(2,`0`)}`}function _t(e,t,n){let r=new Date;return r.getFullYear()===e&&r.getMonth()===t&&r.getDate()===n}function vt(e){if(!e)return``;let t=new Date(e);return isNaN(t.getTime())?e.slice(11,16):t.toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`})}function yt(){let e=F(),t=ne(e=>e.setView),[n,r]=(0,_.useState)(null),i=new Date,[a,o]=(0,_.useState)(i.getFullYear()),[s,c]=(0,_.useState)(i.getMonth()),[l,u]=(0,_.useState)({}),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(!1);(0,_.useEffect)(()=>{E(`/api/config`).then(e=>r(!!e?.hasGoogle))},[]);let S=(0,_.useCallback)((e,t)=>{let n=`${e}-${String(t+1).padStart(2,`0`)}`;f(!0),E(`/api/calendar?month=${n}`).then(e=>{e?.byDate&&u(t=>({...t,...e.byDate})),f(!1)}).catch(()=>f(!1))},[]);(0,_.useEffect)(()=>{n&&S(a,s)},[n,a,s,S]);let C=e=>{E(`/api/calendar?date=${e}`).then(t=>{u(n=>({...n,[e]:t?.events??[]}))})},w=(e,t,n)=>{confirm(`Delete this event?`)&&D(`/api/calendar/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{},`DELETE`).then(()=>C(n))},ee=e=>{g({title:``,start:`${e}T09:00`,end:`${e}T10:00`,location:``,description:``,isEdit:!1}),y(``)},te=(e,t)=>{let n=e.start?e.start.slice(0,16):`${t}T09:00`,r=e.end?e.end.slice(0,16):`${t}T10:00`;g({id:e.id,calId:e.calendarId??`primary`,title:e.summary,start:n,end:r,location:e.location??``,description:e.description??``,isEdit:!0}),y(``)},T=async()=>{if(h){if(!h.title.trim()){y(`Title is required`);return}x(!0);try{if(h.isEdit&&h.id){let e=h.calId??`primary`;await D(`/api/calendar/${encodeURIComponent(e)}/${encodeURIComponent(h.id)}`,{summary:h.title,start:h.start,end:h.end,location:h.location||void 0,description:h.description||void 0},`PATCH`)}else{let e=h.start.split(`T`)[0];await D(`/api/calendar`,{summary:h.title,start:h.start,end:h.end,location:h.location||void 0,description:h.description||void 0,date:e})}let e=h.start.split(`T`)[0];C(e),g(null)}catch(e){y(`Error: `+(e.message??`Unknown`))}finally{x(!1)}}};if(n===null)return(0,A.jsx)(`div`,{className:W.center,children:(0,A.jsx)(`div`,{className:`spinner`})});if(!n)return(0,A.jsx)(`div`,{className:W.center,children:(0,A.jsxs)(`div`,{className:W.noGoogle,children:[(0,A.jsx)(`div`,{className:W.noGoogleIcon,children:`📅`}),(0,A.jsx)(`div`,{className:W.noGoogleTitle,children:`Calendar`}),(0,A.jsx)(`div`,{className:W.noGoogleSub,children:`Connect your Google account to view and manage calendar events.`}),(0,A.jsx)(`button`,{className:W.connectBtn,onClick:()=>t(`settings`),children:`Connect Google →`})]})});let O=new Date(a,s,1).getDay(),re=new Date(a,s+1,0).getDate(),k=new Date(a,s,1).toLocaleDateString(`en`,{month:`long`,year:`numeric`}),ie=(O+6)%7,j=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],M=p?l[p]??[]:[];return(0,A.jsxs)(`div`,{className:W.root,children:[(0,A.jsxs)(`div`,{className:W.calCol,children:[(0,A.jsxs)(`div`,{className:W.navRow,children:[(0,A.jsx)(`button`,{className:W.navBtn,onClick:()=>{let e=s-1;e<0?(o(e=>e-1),c(11)):c(e)},children:`←`}),(0,A.jsx)(`div`,{className:W.monthTitle,children:k}),(0,A.jsx)(`button`,{className:W.navBtn,onClick:()=>{let e=s+1;e>11?(o(e=>e+1),c(0)):c(e)},children:`→`})]}),(0,A.jsx)(`div`,{className:W.dayHeaders,children:j.map((e,t)=>(0,A.jsx)(`div`,{className:`${W.dayHeader} ${t>=5?W.weekend:``}`,children:e},e))}),(0,A.jsxs)(`div`,{className:W.grid,children:[Array.from({length:ie}).map((e,t)=>(0,A.jsx)(`div`,{className:`${W.cell} ${W.emptyCell} ${t>=5?W.weekendCell:``}`},`e${t}`)),Array.from({length:re}).map((e,t)=>{let n=t+1,r=gt(a,s,n),i=_t(a,s,n),o=l[r]??[],c=o.length,u=(ie+n-1)%7>=5,d=o.some(e=>e._isHoliday||e.readOnly),f=p===r;return(0,A.jsxs)(`div`,{className:`${W.cell} ${i?W.todayCell:u?W.weekendCell:``} ${f?W.activeCell:``} ${d?W.holidayCell:c>0?W.hasEvtsCell:``}`,onClick:()=>m(r),children:[(0,A.jsx)(`div`,{className:`${W.dayNum} ${i?W.todayNum:u?W.weekendNum:``}`,children:n}),c>0&&(0,A.jsxs)(`div`,{className:W.evtPills,children:[o.slice(0,2).map((e,t)=>(0,A.jsx)(`div`,{className:`${W.evtPill} ${e._isHoliday||e.readOnly?W.holidayPill:``}`,children:e.summary},t)),c>2&&(0,A.jsxs)(`div`,{className:W.morePill,children:[`+`,c-2]})]})]},r)})]}),d&&(0,A.jsx)(`div`,{className:W.loadingBar,children:`Loading events…`})]}),(0,A.jsx)(`div`,{className:W.detailCol,children:p?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:W.detailHeader,children:[(0,A.jsx)(`div`,{className:W.detailDate,children:new Date(p+`T12:00:00`).toLocaleDateString(`en`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),(0,A.jsx)(`button`,{className:W.addEvtBtn,onClick:()=>ee(p),children:`+ Add Event`})]}),M.length===0?(0,A.jsx)(`div`,{className:W.noEvts,children:`No events on this day`}):M.map((t,n)=>{let r=t.isAllDay?`All day`:`${vt(t.start)} - ${vt(t.end)}`,i=t.calendarId??`primary`;return(0,A.jsxs)(`div`,{className:W.evtCard,children:[(0,A.jsxs)(`div`,{className:W.evtTop,children:[(0,A.jsx)(`div`,{className:W.evtTime,children:r}),t.id&&!t.readOnly&&(0,A.jsxs)(`div`,{className:W.evtBtns,children:[(0,A.jsx)(`button`,{className:W.editBtn,onClick:()=>te(t,p),children:`Edit`}),(0,A.jsx)(`button`,{className:W.delBtn,onClick:()=>w(i,t.id,p),children:e(`common.delete`)})]}),t.readOnly&&(0,A.jsx)(`span`,{className:W.readOnly,children:`read-only`})]}),(0,A.jsx)(`div`,{className:W.evtTitle,children:t.summary}),t.location&&(0,A.jsxs)(`div`,{className:W.evtLoc,children:[`📍 `,t.location]}),t.organizer&&(0,A.jsxs)(`div`,{className:W.evtMeta,children:[`Organizer: `,t.organizer]}),t.attendees&&t.attendees.length>0&&(0,A.jsxs)(`div`,{className:W.attendees,children:[(0,A.jsx)(`div`,{className:W.evtMeta,children:`Attendees:`}),t.attendees.map((e,t)=>(0,A.jsxs)(`div`,{className:W.attendee,"data-status":e.responseStatus,children:[e.name||e.email,` (`,e.responseStatus,`)`]},t))]}),t.description&&(0,A.jsx)(`div`,{className:W.evtDesc,children:t.description}),t.hangoutLink&&(0,A.jsx)(`a`,{className:W.joinBtn,href:t.hangoutLink,target:`_blank`,rel:`noreferrer`,children:`Join Video Call`}),t.htmlLink&&(0,A.jsx)(`a`,{className:W.gcalLink,href:t.htmlLink,target:`_blank`,rel:`noreferrer`,children:`Open in Google Calendar`})]},n)})]}):(0,A.jsx)(`div`,{className:W.selectDay,children:`Select a day to see events`})}),h&&(0,A.jsx)(`div`,{className:W.overlay,onClick:e=>{e.target===e.currentTarget&&g(null)},children:(0,A.jsxs)(`div`,{className:W.formCard,children:[(0,A.jsx)(`div`,{className:W.formTitle,children:h.isEdit?`Edit Event`:`New Event`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Title *`}),(0,A.jsx)(`input`,{className:W.formInput,value:h.title,onChange:e=>g(t=>t&&{...t,title:e.target.value}),placeholder:`Event title`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Start`}),(0,A.jsx)(`input`,{className:W.formInput,type:`datetime-local`,value:h.start,onChange:e=>g(t=>t&&{...t,start:e.target.value})}),(0,A.jsx)(`label`,{className:W.formLabel,children:`End`}),(0,A.jsx)(`input`,{className:W.formInput,type:`datetime-local`,value:h.end,onChange:e=>g(t=>t&&{...t,end:e.target.value})}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Location`}),(0,A.jsx)(`input`,{className:W.formInput,value:h.location,onChange:e=>g(t=>t&&{...t,location:e.target.value}),placeholder:`Optional`}),(0,A.jsx)(`label`,{className:W.formLabel,children:`Description`}),(0,A.jsx)(`textarea`,{className:W.formTextarea,value:h.description,onChange:e=>g(t=>t&&{...t,description:e.target.value})}),v&&(0,A.jsx)(`div`,{className:W.formError,children:v}),(0,A.jsxs)(`div`,{className:W.formBtns,children:[(0,A.jsx)(`button`,{className:W.cancelFormBtn,onClick:()=>g(null),children:e(`common.cancel`)}),(0,A.jsx)(`button`,{className:W.saveFormBtn,onClick:T,disabled:b,children:b?`Saving…`:h.isEdit?`Save Changes`:`Create Event`})]})]})})]})}var G={root:`_root_1tngw_1`,gridSection:`_gridSection_1tngw_9`,gridHeader:`_gridHeader_1tngw_14`,headerRow:`_headerRow_1tngw_21`,search:`_search_1tngw_23`,createBtn:`_createBtn_1tngw_34`,catTabs:`_catTabs_1tngw_41`,catTab:`_catTab_1tngw_41`,catActive:`_catActive_1tngw_48`,grid:`_grid_1tngw_9`,agentCard:`_agentCard_1tngw_59`,agentActive:`_agentActive_1tngw_66`,agentCardTop:`_agentCardTop_1tngw_68`,agentIcon:`_agentIcon_1tngw_69`,agentActions:`_agentActions_1tngw_70`,agentEditBtn:`_agentEditBtn_1tngw_71`,agentDelBtn:`_agentDelBtn_1tngw_71`,agentLabel:`_agentLabel_1tngw_74`,agentDesc:`_agentDesc_1tngw_75`,agentCat:`_agentCat_1tngw_76`,loading:`_loading_1tngw_78`,chatArea:`_chatArea_1tngw_81`,emptyChat:`_emptyChat_1tngw_88`,emptyChatHint:`_emptyChatHint_1tngw_98`,chatPanel:`_chatPanel_1tngw_101`,chatHeader:`_chatHeader_1tngw_111`,chatIcon:`_chatIcon_1tngw_118`,chatHeaderInfo:`_chatHeaderInfo_1tngw_119`,chatAgentName:`_chatAgentName_1tngw_120`,chatAgentDesc:`_chatAgentDesc_1tngw_121`,closeChat:`_closeChat_1tngw_122`,chatMessages:`_chatMessages_1tngw_125`,chatEmpty:`_chatEmpty_1tngw_130`,chatMsg:`_chatMsg_1tngw_132`,msgUser:`_msgUser_1tngw_136`,msgAgent:`_msgAgent_1tngw_137`,thinking:`_thinking_1tngw_139`,dot:`_dot_1tngw_140`,dotPulse:`_dotPulse_1tngw_1`,chatInput:`_chatInput_1tngw_146`,chatTools:`_chatTools_1tngw_147`,toolBtn:`_toolBtn_1tngw_148`,toolBtnActive:`_toolBtnActive_1tngw_156`,attachBar:`_attachBar_1tngw_158`,attachClear:`_attachClear_1tngw_163`,chatInputRow:`_chatInputRow_1tngw_165`,chatTextarea:`_chatTextarea_1tngw_166`,sendBtn:`_sendBtn_1tngw_173`,orchBar:`_orchBar_1tngw_181`,orchLabel:`_orchLabel_1tngw_192`,orchRow:`_orchRow_1tngw_193`,orchInput:`_orchInput_1tngw_194`,orchBtn:`_orchBtn_1tngw_201`,orchSynthesis:`_orchSynthesis_1tngw_208`,orchSynthHeader:`_orchSynthHeader_1tngw_214`,orchSynthSpinner:`_orchSynthSpinner_1tngw_220`,blink:`_blink_1tngw_1`,orchSynthBody:`_orchSynthBody_1tngw_222`,modalOverlay:`_modalOverlay_1tngw_230`,modal:`_modal_1tngw_230`,modalTitle:`_modalTitle_1tngw_232`,formField:`_formField_1tngw_233`,formLabel:`_formLabel_1tngw_234`,formInput:`_formInput_1tngw_235`,formTextarea:`_formTextarea_1tngw_236`,formError:`_formError_1tngw_237`,modalBtns:`_modalBtns_1tngw_238`,cancelBtn:`_cancelBtn_1tngw_239`,modalSaveBtn:`_modalSaveBtn_1tngw_240`},bt={saber:{icon:`🛡`},zero:{icon:`🔍`},ade:{icon:`🔬`},heimdall:{icon:`🔒`},cassandra:{icon:`⚠`},sauron:{icon:`👁`},jarvis:{icon:`💻`},forge:{icon:`⚙`},pipe:{icon:`🔧`},shell:{icon:`📟`},glitch:{icon:`🐛`},hermes:{icon:`🔗`},babel:{icon:`🌎`},shogun:{icon:`☸`},flux:{icon:`🔄`},cron:{icon:`⏰`},atlas:{icon:`🗺`},oracle:{icon:`📊`},logos:{icon:`🧮`},navi:{icon:`🧭`},edi:{icon:`📈`},mercury:{icon:`🌐`},tempest:{icon:`⛈`},cartographer:{icon:`🌍`},scheherazade:{icon:`✍`},quill:{icon:`📝`},muse:{icon:`🎨`},murasaki:{icon:`🖌`},echo:{icon:`📡`},polyglot:{icon:`🗣`},prometheus:{icon:`🔥`},herald:{icon:`📢`},veritas:{icon:`✓`},athena:{icon:`🧠`},conductor:{icon:`🎼`},link:{icon:`🔌`},macro:{icon:`⚡`},epicure:{icon:`🍽`}};function xt(e){let t=e.card??e,n=(t.name||t.displayName||t.agentName||e.name||``).toLowerCase().replace(/\s+/g,`-`),r=bt[n],i=t.displayName||t.agentName||t.name||e.displayName||n,a=t.tagline||t.description||e.tagline||``,o=t.category||e.category||`Other`;return{id:n,icon:r?.icon??t.icon??`🤖`,label:i,description:a,category:o,isCustom:o===`custom`,systemPrompt:e.systemPrompt}}function St(e){return{agent:e,history:[],streaming:!1,input:``,attachedFile:null,attachedImage:null,voiceActive:!1}}function Ct(){let e=F(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(`All`),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(`create`),[w,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(!1),T=(0,_.useRef)(new Map),O=(0,_.useRef)(new Map),k=(0,_.useRef)(new Map),ie=(0,_.useRef)(new Map),j=(0,_.useRef)(new Map),M=(0,_.useRef)(null),ae=()=>{E(`/api/agents`).then(e=>{n((e?.agents??[]).map(xt)),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{ae()},[]);let oe=[`All`,...Array.from(new Set(t.map(e=>e.category))).sort()],N=t.filter(e=>{let t=s===`All`||e.category===s,n=a.toLowerCase();return t&&(!n||e.label.toLowerCase().includes(n)||e.description.toLowerCase().includes(n))}),se=e=>{u(t=>{let n=t.findIndex(t=>t.agent.id===e.id);return n>=0?(O.current.get(e.id)?.abort(),O.current.delete(e.id),t.filter((e,t)=>t!==n)):[...t,St(e)]})},P=e=>{O.current.get(e)?.abort(),O.current.delete(e),u(t=>t.filter(t=>t.agent.id!==e))},I=(e,t)=>{u(n=>n.map(n=>n.agent.id===e?{...n,...t}:n))},ce=(e,t)=>{u(n=>n.map(n=>n.agent.id===e?{...n,history:[...n.history,t]}:n))},le=(e,t)=>{u(n=>n.map(n=>{if(n.agent.id!==e)return n;let r=[...n.history];return r[r.length-1]={...r[r.length-1],content:t},{...n,history:r}}))},ue=async(e,t,n,r)=>{let i=e.agent.id;if(!t.trim()&&!n&&!r)return;ce(i,{role:`user`,content:n?(t?t+` `:``)+`[File: ${n.name}]`:r?(t?t+` `:``)+`[Image: ${r.name}]`:t}),I(i,{streaming:!0,input:``,attachedFile:null,attachedImage:null});let a=e.history.slice(-20);if(n||r){try{let e={message:t||`Analyze this`,agent:i};n?.isPDF&&n.base64?(e.pdfBase64=n.base64,e.pdfName=n.name):n?.content&&(e.fileContent=n.content,e.fileName=n.name),r?.base64&&(e.imageBase64=r.base64,e.imageMimeType=r.mimeType??`image/jpeg`);let a=await D(`/api/chat`,e);ce(i,{role:`assistant`,content:a?.response||a?.content||``})}catch{ce(i,{role:`assistant`,content:`Error sending attachment.`})}I(i,{streaming:!1});return}ce(i,{role:`assistant`,content:``,streaming:!0});let o=new AbortController;O.current.set(i,o);let s=``;try{await re(`/api/chat/stream`,{message:t,agent:i,history:a,_agentSystemPrompt:e.agent.systemPrompt},e=>{s+=e,le(i,s);let t=k.current.get(i);t&&(t.scrollTop=t.scrollHeight)},o.signal)}catch{}finally{I(i,{streaming:!1}),O.current.delete(i)}},L=async()=>{let e=d.trim();if(!e||p||l.length===0)return;f(``),m(!0),g(``);let t=[];if(await Promise.all(l.map(async n=>{let r=n.agent.id;ce(r,{role:`user`,content:e}),I(r,{streaming:!0});let i=``,a=new AbortController;O.current.set(r,a),ce(r,{role:`assistant`,content:``,streaming:!0});try{await re(`/api/chat/stream`,{message:e,agent:r,history:n.history.slice(-20),_agentSystemPrompt:n.agent.systemPrompt},e=>{i+=e,le(r,i);let t=k.current.get(r);t&&(t.scrollTop=t.scrollHeight)},a.signal)}catch{}finally{I(r,{streaming:!1}),O.current.delete(r)}t.push({agentId:r,agentLabel:n.agent.label,icon:n.agent.icon,content:i})})),m(!1),t.length<2)return;y(!0);let n=t.map(e=>`## ${e.icon} ${e.agentLabel}\n${e.content}`).join(`
|
|
459
459
|
|
|
460
460
|
---
|
|
461
461
|
|