nothumanallowed 15.1.40 → 15.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothumanallowed",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.42",
|
|
4
4
|
"description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/config.mjs
CHANGED
|
@@ -306,8 +306,11 @@ export function setConfigValue(key, value) {
|
|
|
306
306
|
'microsoft-tenant': 'microsoft.tenantId',
|
|
307
307
|
'microsoft-tenant-id': 'microsoft.tenantId',
|
|
308
308
|
'plan-time': 'ops.planTime',
|
|
309
|
+
'planTime': 'ops.planTime', // camelCase variant from WebUI Settings
|
|
309
310
|
'summary-time': 'ops.summaryTime',
|
|
311
|
+
'summaryTime': 'ops.summaryTime', // camelCase variant from WebUI Settings
|
|
310
312
|
'meeting-alert': 'ops.meetingAlertMinutes',
|
|
313
|
+
'meetingAlert': 'ops.meetingAlertMinutes', // camelCase variant from WebUI Settings
|
|
311
314
|
'telegram-webhook': 'ops.webhooks.telegram',
|
|
312
315
|
'discord-webhook': 'ops.webhooks.discord',
|
|
313
316
|
'plugin-autorun': 'plugins.autoRun',
|
|
@@ -357,8 +360,24 @@ export function setConfigValue(key, value) {
|
|
|
357
360
|
'thinking': 'thinking',
|
|
358
361
|
'extended-thinking': 'thinking',
|
|
359
362
|
'language': 'language',
|
|
363
|
+
'lang': 'language', // short form used by WebUI Settings dropdown
|
|
360
364
|
};
|
|
361
365
|
|
|
366
|
+
// Top-level "object sections" — keys whose value is the entire section object,
|
|
367
|
+
// not a scalar. The WebUI saves these by sending the full bag (e.g. profile = {
|
|
368
|
+
// name, email, phone, ... }) so that one form click persists all fields. We
|
|
369
|
+
// merge (not overwrite) to avoid wiping unrelated keys a future UI may not know.
|
|
370
|
+
const OBJECT_SECTIONS = {
|
|
371
|
+
profile: 'profile',
|
|
372
|
+
};
|
|
373
|
+
if (OBJECT_SECTIONS[key] && value && typeof value === 'object' && !Array.isArray(value)) {
|
|
374
|
+
const targetPath = OBJECT_SECTIONS[key];
|
|
375
|
+
if (!config[targetPath] || typeof config[targetPath] !== 'object') config[targetPath] = {};
|
|
376
|
+
Object.assign(config[targetPath], value);
|
|
377
|
+
saveConfig(config);
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
|
|
362
381
|
// Reject keys we don't recognize and that aren't dotted paths into config.
|
|
363
382
|
// Previously a typo like "groqkey" (no hyphen) silently stored the value
|
|
364
383
|
// under config.groqkey at root level — invisible to the rest of the code.
|
|
@@ -396,17 +415,22 @@ export function setConfigValue(key, value) {
|
|
|
396
415
|
obj[lastKey] = value === 'true' || value === '1' || value === 'yes';
|
|
397
416
|
} else if (typeof existing === 'number') {
|
|
398
417
|
obj[lastKey] = Number(value);
|
|
399
|
-
} else if (Array.isArray(existing)) {
|
|
400
|
-
//
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
obj[lastKey] =
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
418
|
+
} else if (Array.isArray(existing) || Array.isArray(value)) {
|
|
419
|
+
// Already an array from the WebUI? Persist as-is. CLI users send strings,
|
|
420
|
+
// so fall back to comma-split / JSON parsing for backward compatibility.
|
|
421
|
+
if (Array.isArray(value)) {
|
|
422
|
+
obj[lastKey] = value;
|
|
423
|
+
} else {
|
|
424
|
+
try {
|
|
425
|
+
const parsed = JSON.parse(value);
|
|
426
|
+
obj[lastKey] = Array.isArray(parsed) ? parsed : [parsed];
|
|
427
|
+
} catch {
|
|
428
|
+
obj[lastKey] = String(value).split(',').map(v => {
|
|
429
|
+
const trimmed = v.trim();
|
|
430
|
+
const num = Number(trimmed);
|
|
431
|
+
return !isNaN(num) && trimmed !== '' ? num : trimmed;
|
|
432
|
+
}).filter(Boolean);
|
|
433
|
+
}
|
|
410
434
|
}
|
|
411
435
|
} else {
|
|
412
436
|
obj[lastKey] = value;
|
package/src/constants.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
7
|
|
|
8
|
-
export const VERSION = '15.1.
|
|
8
|
+
export const VERSION = '15.1.42';
|
|
9
9
|
export const BASE_URL = 'https://nothumanallowed.com/cli';
|
|
10
10
|
export const API_BASE = 'https://nothumanallowed.com/api/v1';
|
|
11
11
|
|
|
@@ -657,7 +657,7 @@ return data.map(x => x.name).join(", ");`,type:`textarea`}]},{id:`logic_if`,type
|
|
|
657
657
|
|
|
658
658
|
`),r=`The user asked: "${e}"\n\nHere are the responses from ${t.length} specialist agents:\n\n${n}\n\nSynthesize these responses into a unified analysis.`,i=``;try{await ae(`/api/chat/stream`,{message:r,systemPrompt:`You are the Conductor — a meta-agent that synthesizes the outputs of multiple specialist AI agents.
|
|
659
659
|
Your job: examine all agent responses to a user's question, identify agreements, disagreements, complementary insights, and deliver a unified, high-quality synthesis.
|
|
660
|
-
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},_e=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=re.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),j(e,{voiceActive:!1});return}let r=new t;re.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;j(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>j(e,{voiceActive:!1}),r.onerror=()=>j(e,{voiceActive:!1}),r.start(),j(e,{voiceActive:!0})},ve=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];j(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{j(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},ye=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];j(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},be=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),ee(``)},xe=async e=>{let t=await T(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),ee(``)},Se=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){ee(`Tagline and system prompt are required.`);return}ne(!0),ee(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){ee(`Agent name required (lowercase, no spaces).`),ne(!1);return}let t=await E(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){ee(`Error: `+t.error),ne(!1);return}}else await E(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),ce()}catch(e){ee(`Error: `+e.message)}finally{ne(!1)}}},M=e=>{confirm(`Delete agent "${e.label}"?`)&&E(`/api/agents/${e.id}`,{},`DELETE`).then(()=>ce())};return r?(0,O.jsx)(`div`,{className:U.root,children:(0,O.jsx)(`div`,{className:U.loading,children:(0,O.jsx)(`div`,{className:`spinner`})})}):(0,O.jsxs)(`div`,{className:U.root,children:[(0,O.jsxs)(`div`,{className:U.gridSection,children:[(0,O.jsxs)(`div`,{className:U.gridHeader,children:[(0,O.jsxs)(`div`,{className:U.headerRow,children:[(0,O.jsx)(`input`,{className:U.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,O.jsx)(`button`,{className:U.createBtn,onClick:be,children:`+ Create`})]}),(0,O.jsx)(`div`,{className:U.catTabs,children:le.map(e=>(0,O.jsxs)(`button`,{className:`${U.catTab} ${s===e?U.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,O.jsx)(`div`,{className:U.grid,children:ue.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,O.jsxs)(`div`,{className:`${U.agentCard} ${t?U.agentActive:``}`,onClick:()=>de(e),children:[(0,O.jsxs)(`div`,{className:U.agentCardTop,children:[(0,O.jsx)(`div`,{className:U.agentIcon,children:e.icon}),e.isCustom&&(0,O.jsxs)(`div`,{className:U.agentActions,children:[(0,O.jsx)(`button`,{className:U.agentEditBtn,onClick:t=>{t.stopPropagation(),xe(e)},children:`✏️`}),(0,O.jsx)(`button`,{className:U.agentDelBtn,onClick:t=>{t.stopPropagation(),M(e)},children:`🗑`})]})]}),(0,O.jsx)(`div`,{className:U.agentLabel,children:e.label}),(0,O.jsx)(`div`,{className:U.agentDesc,children:e.description}),(0,O.jsx)(`div`,{className:U.agentCat,children:e.category})]},e.id)})})]}),(0,O.jsx)(`div`,{className:U.chatArea,children:l.length===0?(0,O.jsxs)(`div`,{className:U.emptyChat,children:[(0,O.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,O.jsx)(`span`,{className:U.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,O.jsxs)(`div`,{className:U.chatPanel,children:[(0,O.jsxs)(`div`,{className:U.chatHeader,children:[(0,O.jsx)(`span`,{className:U.chatIcon,children:t.icon}),(0,O.jsxs)(`div`,{className:U.chatHeaderInfo,children:[(0,O.jsx)(`div`,{className:U.chatAgentName,children:t.label}),(0,O.jsx)(`div`,{className:U.chatAgentDesc,children:t.description})]}),(0,O.jsx)(`button`,{className:U.closeChat,onClick:()=>fe(t.id),children:`✕`})]}),(0,O.jsxs)(`div`,{className:U.chatMessages,ref:e=>{D.current.set(t.id,e)},children:[e.history.length===0&&(0,O.jsxs)(`div`,{className:U.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,O.jsx)(`div`,{className:`${U.chatMsg} ${e.role===`user`?U.msgUser:U.msgAgent}`,children:e.role===`assistant`?(0,O.jsx)(`div`,{dangerouslySetInnerHTML:{__html:Ce(e.content||`…`)}}):(0,O.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,O.jsxs)(`div`,{className:U.thinking,children:[(0,O.jsx)(`span`,{className:U.dot}),(0,O.jsx)(`span`,{className:U.dot}),(0,O.jsx)(`span`,{className:U.dot})]})]}),n&&(0,O.jsxs)(`div`,{className:U.attachBar,children:[(0,O.jsx)(`span`,{children:n}),(0,O.jsx)(`button`,{className:U.attachClear,onClick:()=>j(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,O.jsxs)(`div`,{className:U.chatInput,children:[(0,O.jsxs)(`div`,{className:U.chatTools,children:[(0,O.jsx)(`button`,{className:`${U.toolBtn} ${e.voiceActive?U.toolBtnActive:``}`,onClick:()=>_e(t.id),title:`Voice`,children:`🎤`}),(0,O.jsx)(`button`,{className:U.toolBtn,onClick:()=>oe.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,O.jsx)(`button`,{className:U.toolBtn,onClick:()=>k.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,O.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{oe.current.set(t.id,e)},onChange:e=>ve(t.id,e.target.files?.[0])}),(0,O.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{k.current.set(t.id,e)},onChange:e=>ye(t.id,e.target.files?.[0])})]}),(0,O.jsxs)(`div`,{className:U.chatInputRow,children:[(0,O.jsx)(`textarea`,{className:U.chatTextarea,value:e.input,onChange:e=>j(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),he(e,e.input,e.attachedFile,e.attachedImage))}}),(0,O.jsx)(`button`,{className:U.sendBtn,onClick:()=>he(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,O.jsxs)(`div`,{className:U.orchBar,children:[(0,O.jsxs)(`div`,{className:U.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,O.jsxs)(`div`,{className:U.orchRow,children:[(0,O.jsx)(`textarea`,{ref:se,className:U.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ge())}}),(0,O.jsx)(`button`,{className:U.orchBtn,onClick:ge,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,O.jsxs)(`div`,{className:U.orchSynthesis,children:[(0,O.jsxs)(`div`,{className:U.orchSynthHeader,children:[(0,O.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,O.jsx)(`span`,{className:U.orchSynthSpinner,children:`synthesizing…`})]}),(0,O.jsx)(`div`,{className:U.orchSynthBody,dangerouslySetInnerHTML:{__html:Ce(h||`…`)}})]})]}),b&&(0,O.jsx)(`div`,{className:U.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,O.jsxs)(`div`,{className:U.modal,children:[(0,O.jsx)(`div`,{className:U.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,O.jsx)(`input`,{className:U.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`Tagline`}),(0,O.jsx)(`input`,{className:U.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`System Prompt`}),(0,O.jsx)(`textarea`,{className:U.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,O.jsx)(`div`,{className:U.formError,children:w}),(0,O.jsxs)(`div`,{className:U.modalBtns,children:[(0,O.jsx)(`button`,{className:U.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,O.jsx)(`button`,{className:U.modalSaveBtn,onClick:Se,disabled:te,children:te?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var W={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function un(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function dn(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function fn(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),ee=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),T(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{ee()},[]);let te=e=>{c(e),ee(e,l)},ne=()=>{u(d),ee(s,d)},re=(e,t)=>{i(!0),T(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},ie=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await E(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ae=(e,t)=>{i(!0),T(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},D=(e,t)=>{i(!0),T(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},oe=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&E(`/api/drive/delete/${e}`,{}).then(()=>{n(null),ee()})},k=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&E(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?re(t.id,e):ee()}).catch(e=>alert(`Error: `+e.message))},se=()=>{w.current?.click()},ce=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;E(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),ee()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,O.jsxs)(`div`,{className:W.error,children:[(0,O.jsx)(`div`,{children:a}),(0,O.jsxs)(`div`,{className:W.errorHint,children:[`Run: `,(0,O.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,O.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,O.jsxs)(`div`,{className:W.editorRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:h.name}),(0,O.jsx)(`button`,{className:W.saveBtn,onClick:ie,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,O.jsx)(`textarea`,{className:W.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,O.jsxs)(`div`,{className:W.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,O.jsxs)(`div`,{className:W.viewerRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:b.name})]}),(0,O.jsx)(`div`,{className:W.imgContainer,children:(0,O.jsx)(`img`,{src:b.src,alt:b.name,className:W.imgView})})]});if(p===`pdf`&&b)return(0,O.jsxs)(`div`,{className:W.viewerRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:b.name})]}),(0,O.jsx)(`iframe`,{className:W.pdfFrame,src:b.src,title:b.name})]});let le=t?.files??[],ue=t?.quota;return(0,O.jsxs)(`div`,{className:W.root,children:[ue&&(0,O.jsxs)(`div`,{className:W.quotaBar,children:[(0,O.jsxs)(`div`,{className:W.quotaText,children:[(0,O.jsxs)(`span`,{className:W.quotaUsed,children:[ue.usage,` of `,ue.limit,` used`]}),(0,O.jsxs)(`span`,{className:W.quotaPct,children:[ue.percentUsed,`%`]})]}),(0,O.jsx)(`div`,{className:W.quotaTrack,children:(0,O.jsx)(`div`,{className:W.quotaFill,style:{width:`${Math.min(ue.percentUsed,100)}%`,background:ue.percentUsed>90?`var(--red)`:ue.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,O.jsxs)(`div`,{className:W.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,O.jsx)(`button`,{className:`${W.filterBtn} ${s===e?W.filterActive:``}`,onClick:()=>te(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,O.jsx)(`div`,{className:W.spacer}),(0,O.jsx)(`button`,{className:W.newBtn,onClick:k,children:`+ New File`}),(0,O.jsx)(`button`,{className:W.uploadBtn,onClick:se,children:e(`drive.upload`)}),(0,O.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>ce(e.target.files?.[0])})]}),(0,O.jsxs)(`div`,{className:W.searchRow,children:[(0,O.jsx)(`input`,{className:W.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ne()}),(0,O.jsx)(`button`,{className:W.searchBtn,onClick:ne,children:`Search`})]}),r&&(0,O.jsx)(`div`,{className:W.loading,children:(0,O.jsx)(`div`,{className:`spinner`})}),!r&&le.length===0&&(0,O.jsxs)(`div`,{className:W.empty,children:[e(`drive.noFiles`),` found`]}),(0,O.jsx)(`div`,{className:W.fileList,children:le.map(e=>{let t=dn(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,O.jsxs)(`div`,{className:W.fileRow,onClick:()=>{t?re(e.id,e.name):n?ae(e.id,e.name):r?D(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,O.jsx)(`span`,{className:W.fileIcon,children:un(e.type,e.mimeType)}),(0,O.jsxs)(`div`,{className:W.fileInfo,children:[(0,O.jsx)(`div`,{className:W.fileName,children:e.name}),(0,O.jsxs)(`div`,{className:W.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,O.jsxs)(`div`,{className:W.fileBtns,children:[t&&(0,O.jsx)(`button`,{className:W.editBtn,onClick:t=>{t.stopPropagation(),re(e.id,e.name)},children:`Edit`}),n&&(0,O.jsx)(`button`,{className:W.viewBtn,onClick:t=>{t.stopPropagation(),ae(e.id,e.name)},children:`View`}),r&&(0,O.jsx)(`button`,{className:W.pdfBtn,onClick:t=>{t.stopPropagation(),D(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,O.jsx)(`a`,{className:W.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,O.jsx)(`button`,{className:W.delBtn,onClick:t=>{t.stopPropagation(),oe(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var G={root:`_root_p82nk_1`,loading:`_loading_p82nk_10`,errorBox:`_errorBox_p82nk_12`,errorHint:`_errorHint_p82nk_13`,connectBox:`_connectBox_p82nk_17`,connectIcon:`_connectIcon_p82nk_27`,connectTitle:`_connectTitle_p82nk_28`,connectDesc:`_connectDesc_p82nk_29`,connectLink:`_connectLink_p82nk_30`,connectRow:`_connectRow_p82nk_31`,connectInput:`_connectInput_p82nk_32`,connectBtn:`_connectBtn_p82nk_43`,connectError:`_connectError_p82nk_55`,userRow:`_userRow_p82nk_57`,avatar:`_avatar_p82nk_68`,userLogin:`_userLogin_p82nk_70`,userName:`_userName_p82nk_71`,disconnectBtn:`_disconnectBtn_p82nk_73`,repoBar:`_repoBar_p82nk_84`,repoInput:`_repoInput_p82nk_90`,issuesBtn:`_issuesBtn_p82nk_102`,prsBtn:`_prsBtn_p82nk_113`,repoPills:`_repoPills_p82nk_124`,repoPill:`_repoPill_p82nk_124`,issueCount:`_issueCount_p82nk_147`,tabs:`_tabs_p82nk_153`,tab:`_tab_p82nk_153`,tabActive:`_tabActive_p82nk_172`,markRead:`_markRead_p82nk_178`,content:`_content_p82nk_189`,empty:`_empty_p82nk_191`,notifRow:`_notifRow_p82nk_193`,issueRow:`_issueRow_p82nk_193`,prRow:`_prRow_p82nk_193`,notifRepo:`_notifRepo_p82nk_207`,notifType:`_notifType_p82nk_208`,notifTitle:`_notifTitle_p82nk_209`,notifMeta:`_notifMeta_p82nk_210`,issueNum:`_issueNum_p82nk_212`,issueTitle:`_issueTitle_p82nk_213`,issueMeta:`_issueMeta_p82nk_214`,issueLabel:`_issueLabel_p82nk_215`,prNum:`_prNum_p82nk_217`,prTitle:`_prTitle_p82nk_218`,prAuthor:`_prAuthor_p82nk_219`,prDraft:`_prDraft_p82nk_220`,prMeta:`_prMeta_p82nk_221`};function pn(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),T(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>E(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&E(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})},[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(!1),x=t?.user;if(r)return(0,O.jsx)(`div`,{className:G.loading,children:(0,O.jsx)(`div`,{className:`spinner`})});let S=async()=>{g.trim()&&(b(!0),await E(`/api/config`,{key:`github-token`,value:g.trim()}),v(``),b(!1),d())};if(t?.error||!x?.login&&!r)return(0,O.jsxs)(`div`,{className:G.connectBox,children:[(0,O.jsx)(`div`,{className:G.connectIcon,children:`🔗`}),(0,O.jsx)(`div`,{className:G.connectTitle,children:`Connect GitHub`}),(0,O.jsxs)(`div`,{className:G.connectDesc,children:[`Enter your Personal Access Token to connect GitHub.`,(0,O.jsx)(`br`,{}),`Create one at `,(0,O.jsx)(`a`,{href:`https://github.com/settings/tokens`,target:`_blank`,rel:`noreferrer`,className:G.connectLink,children:`github.com/settings/tokens`}),` with `,(0,O.jsx)(`strong`,{children:`repo`}),` scope.`]}),(0,O.jsxs)(`div`,{className:G.connectRow,children:[(0,O.jsx)(`input`,{className:G.connectInput,type:`password`,value:g,onChange:e=>v(e.target.value),placeholder:`ghp_xxxxxxxxxxxxxxxxxxxx`,onKeyDown:e=>e.key===`Enter`&&S()}),(0,O.jsx)(`button`,{className:G.connectBtn,onClick:S,disabled:y||!g.trim(),children:y?`Connecting...`:`Connect`})]}),t?.error&&(0,O.jsx)(`div`,{className:G.connectError,children:t.error})]});let C=Array.isArray(t?.notifications)?t.notifications:[],w=Array.isArray(t?.issues)?t.issues:[],ee=Array.isArray(t?.prs)?t.prs:[];return(0,O.jsxs)(`div`,{className:G.root,children:[x?.login&&(0,O.jsxs)(`div`,{className:G.userRow,children:[x.avatar&&(0,O.jsx)(`img`,{src:x.avatar,className:G.avatar,alt:x.login}),(0,O.jsxs)(`div`,{style:{flex:1},children:[(0,O.jsxs)(`div`,{className:G.userLogin,children:[`@`,x.login]}),x.name&&(0,O.jsx)(`div`,{className:G.userName,children:x.name})]}),(0,O.jsx)(`button`,{className:G.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,O.jsxs)(`div`,{className:G.repoBar,children:[(0,O.jsx)(`input`,{className:G.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,O.jsx)(`button`,{className:G.issuesBtn,onClick:f,children:`Issues`}),(0,O.jsx)(`button`,{className:G.prsBtn,onClick:p,children:`PRs`})]}),x?.repos&&x.repos.length>0&&(0,O.jsx)(`div`,{className:G.repoPills,children:x.repos.slice(0,12).map(e=>(0,O.jsxs)(`button`,{className:G.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,O.jsx)(`span`,{className:G.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,O.jsxs)(`div`,{className:G.tabs,children:[(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`notifs`?G.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,C.length>0?`(${C.length})`:``]}),w.length>0&&(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`issues`?G.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,w.length,`)`]}),ee.length>0&&(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`prs`?G.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,ee.length,`)`]}),l===`notifs`&&C.length>0&&(0,O.jsx)(`button`,{className:G.markRead,onClick:m,children:`Mark all read`})]}),(0,O.jsxs)(`div`,{className:G.content,children:[l===`notifs`&&(C.length===0?(0,O.jsx)(`div`,{className:G.empty,children:`No notifications`}):C.map((e,t)=>(0,O.jsxs)(`a`,{className:G.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsx)(`span`,{className:G.notifRepo,children:e.repo}),(0,O.jsxs)(`span`,{className:G.notifType,children:[`[`,e.type,`]`]}),(0,O.jsx)(`div`,{className:G.notifTitle,children:e.title}),(0,O.jsxs)(`div`,{className:G.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(w.length===0?(0,O.jsxs)(`div`,{className:G.empty,children:[e(`github.noIssues`),` for `,a]}):w.map((e,t)=>(0,O.jsxs)(`a`,{className:G.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsxs)(`span`,{className:G.issueNum,children:[`#`,e.number]}),(0,O.jsx)(`span`,{className:G.issueTitle,children:e.title}),e.assignee&&(0,O.jsxs)(`span`,{className:G.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,O.jsxs)(`span`,{className:G.issueLabel,children:[`[`,e.labels,`]`]}),(0,O.jsx)(`div`,{className:G.issueMeta,children:e.updated})]},t))),l===`prs`&&(ee.length===0?(0,O.jsxs)(`div`,{className:G.empty,children:[`No PRs for `,a]}):ee.map((e,t)=>(0,O.jsxs)(`a`,{className:G.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsxs)(`span`,{className:G.prNum,children:[`#`,e.number]}),(0,O.jsx)(`span`,{className:G.prTitle,children:e.title}),(0,O.jsxs)(`span`,{className:G.prAuthor,children:[`by `,e.author]}),e.draft&&(0,O.jsx)(`span`,{className:G.prDraft,children:`DRAFT`}),(0,O.jsx)(`div`,{className:G.prMeta,children:e.updated})]},t)))]})]})}var mn={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function hn({onSaved:e}){let[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),s=async()=>{if(t.trim()){if(!t.startsWith(`xoxb-`)){o(`Il token deve iniziare con "xoxb-"`);return}i(!0),o(``);try{await E(`/api/config`,{key:`slack-token`,value:t.trim()}),n(``),e()}catch(e){o(e.message||`errore`)}finally{i(!1)}}};return(0,O.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:8,flexWrap:`wrap`},children:[(0,O.jsx)(`input`,{type:`password`,autoFocus:!0,placeholder:`xoxb-...`,value:t,onChange:e=>{n(e.target.value),o(``)},onKeyDown:e=>{e.key===`Enter`&&s()},style:{flex:1,minWidth:260,padding:`6px 10px`,borderRadius:6,border:`1px solid rgba(148,163,184,0.25)`,background:`rgba(15,23,42,0.4)`,color:`inherit`,fontFamily:`SF Mono, monospace`,fontSize:12}}),(0,O.jsx)(`button`,{onClick:s,disabled:!t.trim()||r,style:{padding:`6px 16px`,borderRadius:6,border:`none`,background:`#6366f1`,color:`white`,fontWeight:700,cursor:`pointer`,opacity:!t.trim()||r?.5:1},children:r?`Salvo...`:`Salva e connetti`}),a&&(0,O.jsx)(`div`,{style:{width:`100%`,color:`#ef4444`,fontSize:11},children:a})]})}function gn(){let e=A(),[t,n]=(0,_.useState)(null),[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)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null),[w,ee]=(0,_.useState)(!0),te=(0,_.useRef)(null),ne=()=>{i(!0),T(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},re=e=>{o(e),C(null),T(`/api/slack/messages?channel=${e.id}&limit=80`).then(e=>c(e?.messages??[])),E(`/api/slack/mark-read`,{channel:e.id}).catch(()=>{})},ie=e=>{a&&T(`/api/slack/thread?channel=${a.id}&ts=${e.ts}`).then(t=>C({parent:e,replies:(t?.messages??[]).filter(t=>t.ts!==e.ts)}))},ae=async()=>{if(!(!a||!l.trim()||d)){f(!0);try{let e={channel:a.id,text:l};S&&(e.threadTs=S.parent.ts),await E(`/api/slack/send`,e),u(``),S?ie(S.parent):re(a)}finally{f(!1)}}},D=async()=>{if(!h.trim()){y(null);return}x(!0);try{y((await T(`/api/slack/search?q=${encodeURIComponent(h)}&count=30`))?.results??[])}finally{x(!1)}},oe=async(e,t)=>{a&&(await E(`/api/slack/react`,{channel:a.id,ts:e.ts,emoji:t}),re(a))};if((0,_.useEffect)(()=>{ne()},[]),(0,_.useEffect)(()=>(te.current&&window.clearInterval(te.current),w&&a&&(te.current=window.setInterval(()=>re(a),15e3)),()=>{te.current&&window.clearInterval(te.current)}),[w,a?.id]),r)return(0,O.jsxs)(`div`,{className:mn.loading,children:[(0,O.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return/token not configured|missing.*token|slack.*token/i.test(t.error)?(0,O.jsxs)(`div`,{style:{maxWidth:720,margin:`40px auto`,padding:24,background:`rgba(15,23,42,0.4)`,border:`1px solid rgba(99,102,241,0.2)`,borderRadius:12,color:`inherit`},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:8},children:[(0,O.jsx)(`span`,{style:{fontSize:32},children:`💬`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{style:{fontSize:20,fontWeight:800},children:`Collega il tuo Slack a NHA`}),(0,O.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`Bastano 4 passaggi · ~3 minuti · gratis`})]})]}),(0,O.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`32px 1fr`,gap:`12px 10px`,marginTop:16,fontSize:13,lineHeight:1.55},children:[(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`1.`}),(0,O.jsxs)(`div`,{children:[`Apri `,(0,O.jsx)(`a`,{href:`https://api.slack.com/apps?new_app=1`,target:`_blank`,rel:`noreferrer`,style:{color:`#6366f1`,fontWeight:700},children:`api.slack.com/apps → Create New App`}),` e scegli "From scratch". Dai un nome (es. `,(0,O.jsx)(`code`,{children:`NHA Bot`}),`) e seleziona il tuo workspace.`]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`2.`}),(0,O.jsxs)(`div`,{children:[`Nel pannello sinistro vai su `,(0,O.jsx)(`strong`,{children:`OAuth & Permissions`}),`. In "Scopes → Bot Token Scopes" aggiungi `,(0,O.jsx)(`strong`,{children:`tutti questi`}),` permessi:`,(0,O.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:4,fontFamily:`SF Mono, monospace`,fontSize:11},children:[`channels:read`,`channels:history`,`groups:read`,`groups:history`,`im:read`,`im:history`,`mpim:read`,`mpim:history`,`users:read`,`users:read.email`,`team:read`,`chat:write`,`reactions:write`,`search:read`].map(e=>(0,O.jsx)(`code`,{style:{background:`rgba(99,102,241,0.12)`,padding:`2px 6px`,borderRadius:4,color:`#c4b5fd`},children:e},e))})]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`3.`}),(0,O.jsxs)(`div`,{children:[`In cima alla stessa pagina clicca `,(0,O.jsx)(`strong`,{children:`"Install to Workspace"`}),` e conferma. Slack ti darà un `,(0,O.jsx)(`strong`,{children:`Bot User OAuth Token`}),` che inizia per `,(0,O.jsx)(`code`,{children:`xoxb-`}),`.`]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`4.`}),(0,O.jsxs)(`div`,{children:[`Copia il token e incollalo qui sotto, oppure vai in `,(0,O.jsx)(`strong`,{children:`Settings → Integration tokens`}),`:`,(0,O.jsx)(hn,{onSaved:ne})]})]}),(0,O.jsxs)(`div`,{style:{marginTop:18,padding:10,background:`rgba(99,102,241,0.06)`,borderRadius:8,fontSize:11,opacity:.8},children:[(0,O.jsx)(`strong`,{children:`Privacy:`}),` il token resta sul tuo computer in `,(0,O.jsx)(`code`,{children:`~/.nha/config.json`}),`. NHA non lo invia ai server.`,(0,O.jsx)(`br`,{}),(0,O.jsx)(`strong`,{children:`Tip:`}),` se hai canali privati che vuoi leggere, il bot deve essere invitato. Da Slack scrivi `,(0,O.jsx)(`code`,{children:`/invite @nome-del-bot`}),` nel canale.`]})]}):(0,O.jsxs)(`div`,{className:mn.errorBox,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`strong`,{children:`⚠ Slack:`}),` `,t.error]}),(0,O.jsxs)(`div`,{className:mn.errorHint,children:[`Se il problema persiste, verifica gli scopes del bot in `,(0,O.jsx)(`a`,{href:`https://api.slack.com/apps`,target:`_blank`,rel:`noreferrer`,children:`api.slack.com/apps`}),`.`]})]});let k=t?.channels??[],se=p?k.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())):k,ce=se.filter(e=>!e.is_im&&!e.is_mpim&&!e.is_private),le=se.filter(e=>e.is_private&&!e.is_im&&!e.is_mpim),ue=se.filter(e=>e.is_im||e.is_mpim),de=(e,t)=>(0,O.jsxs)(`div`,{className:mn.message,style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6},children:[(0,O.jsx)(`span`,{className:mn.msgUser,style:{fontWeight:700},children:e.user||`Unknown`}),(0,O.jsx)(`span`,{className:mn.msgTs,style:{fontSize:11,opacity:.6},children:new Date(parseFloat(e.ts)*1e3).toLocaleString()}),e.reply_count?(0,O.jsxs)(`button`,{onClick:()=>ie(e),style:{background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`,fontSize:11},children:[`💬 `,e.reply_count,` `,e.reply_count===1?`reply`:`replies`]}):null]}),(0,O.jsx)(`div`,{className:mn.msgText,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:e.text}),e.files&&e.files.length>0&&(0,O.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginTop:2},children:e.files.map(e=>(0,O.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,style:{fontSize:11,padding:`2px 6px`,background:`rgba(99,102,241,0.1)`,borderRadius:4,color:`#6366f1`,textDecoration:`none`},children:[`📎 `,e.name]},e.id))}),e.reactions&&e.reactions.length>0&&(0,O.jsxs)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`,marginTop:2},children:[e.reactions.map((e,t)=>(0,O.jsxs)(`span`,{style:{fontSize:11,padding:`1px 6px`,background:`rgba(99,102,241,0.08)`,borderRadius:10},children:[`:`,e.name,`: `,e.count]},t)),(0,O.jsx)(`button`,{onClick:()=>oe(e,`thumbsup`),style:{background:`transparent`,border:`1px dashed rgba(148,163,184,0.3)`,borderRadius:10,fontSize:11,padding:`0 6px`,cursor:`pointer`},children:`+ 👍`})]})]},t);return(0,O.jsxs)(`div`,{className:mn.twoPane,children:[(0,O.jsxs)(`div`,{className:mn.sidebar,children:[(0,O.jsxs)(`div`,{className:mn.sidebarTitle,children:[(0,O.jsxs)(`span`,{children:[`💬 `,t?.workspace||`Slack`]}),(0,O.jsx)(`button`,{className:mn.disconnectBtn,onClick:ne,title:`Refresh`,children:`↻`})]}),(0,O.jsx)(`input`,{type:`text`,placeholder:`🔎 Filter channels...`,value:p,onChange:e=>m(e.target.value),style:{width:`100%`,padding:`6px 8px`,marginBottom:6,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontSize:12}}),(0,O.jsx)(`input`,{type:`text`,placeholder:`Search messages...`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()},style:{width:`100%`,padding:`6px 8px`,marginBottom:8,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontSize:12}}),v!==null&&(0,O.jsxs)(`div`,{style:{marginBottom:8},children:[(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,marginBottom:2},children:b?`Searching…`:`${v.length} result(s)`}),(0,O.jsx)(`button`,{onClick:()=>{y(null),g(``)},style:{fontSize:11,background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`,padding:0},children:`← back to channels`})]}),v===null&&(0,O.jsxs)(O.Fragment,{children:[ce.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Channels`}),ce.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:[`# `,e.name,(e.unread_count??0)>0&&(0,O.jsx)(`span`,{style:{float:`right`,background:`#ef4444`,color:`white`,borderRadius:8,padding:`0 6px`,fontSize:10},children:e.unread_count})]},e.id)),le.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Private`}),le.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:[`🔒 `,e.name]},e.id)),ue.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Direct Messages`}),ue.map(e=>(0,O.jsx)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:e.name},e.id))]})]}),(0,O.jsx)(`div`,{className:mn.messagePane,style:{display:`flex`,flexDirection:`column`,height:`100%`},children:v===null?a?S?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,style:{display:`flex`,justifyContent:`space-between`},children:[(0,O.jsxs)(`span`,{children:[`💬 Thread in #`,a.name]}),(0,O.jsx)(`button`,{onClick:()=>C(null),style:{background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`},children:`✕ Close thread`})]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[(0,O.jsx)(`div`,{style:{borderLeft:`3px solid #6366f1`,paddingLeft:8,marginBottom:8,opacity:.85},children:de(S.parent,-1)}),(0,O.jsxs)(`div`,{style:{fontSize:11,color:`#94a3b8`,textTransform:`uppercase`,margin:`8px 0 4px`},children:[S.replies.length,` `,S.replies.length===1?`reply`:`replies`]}),S.replies.map((e,t)=>de(e,t))]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,style:{display:`flex`,justifyContent:`space-between`},children:[(0,O.jsxs)(`span`,{children:[`#`,a.name,a.topic?(0,O.jsxs)(`span`,{style:{fontWeight:400,opacity:.6,marginLeft:8},children:[`— `,a.topic]}):null]}),(0,O.jsxs)(`label`,{style:{fontSize:11,opacity:.7},children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>ee(e.target.checked)}),` auto-refresh`]})]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[s.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No messages`}),s.map((e,t)=>de(e,t))]}),(0,O.jsxs)(`div`,{style:{borderTop:`1px solid rgba(148,163,184,0.2)`,padding:8,display:`flex`,gap:6},children:[(0,O.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&ae()},placeholder:`Message #${a.name} (Cmd/Ctrl+Enter to send)`,rows:2,style:{flex:1,padding:6,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontFamily:`inherit`,resize:`vertical`}}),(0,O.jsx)(`button`,{onClick:ae,disabled:!l.trim()||d,className:mn.disconnectBtn,style:{minWidth:80},children:d?`Sending…`:`Send`})]})]}):(0,O.jsx)(`div`,{className:mn.emptyPane,children:`Select a channel from the left`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,children:[`🔎 Search results for "`,h,`"`]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[v.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No matches`}),v.map((e,t)=>(0,O.jsxs)(`div`,{className:mn.message,style:{marginBottom:6},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6},children:[(0,O.jsx)(`span`,{style:{fontWeight:700},children:e.user}),(0,O.jsxs)(`span`,{style:{fontSize:11,opacity:.6},children:[`in #`,e.channel]}),(0,O.jsx)(`span`,{style:{fontSize:11,opacity:.5},children:new Date(parseFloat(e.ts)*1e3).toLocaleString()}),e.permalink&&(0,O.jsx)(`a`,{href:e.permalink,target:`_blank`,rel:`noreferrer`,style:{fontSize:11,color:`#6366f1`},children:`↗ Slack`})]}),(0,O.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`,marginTop:2},children:e.text})]},t))]})]})})]})}function _n(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),T(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),T(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,O.jsxs)(`div`,{className:mn.loading,children:[(0,O.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,O.jsxs)(`div`,{className:mn.errorBox,children:[(0,O.jsx)(`div`,{children:t.error}),(0,O.jsxs)(`div`,{className:mn.errorHint,children:[`Run: `,(0,O.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,O.jsxs)(`div`,{className:mn.twoPane,children:[(0,O.jsxs)(`div`,{className:mn.sidebar,children:[(0,O.jsx)(`div`,{className:mn.sidebarTitle,children:`📋 Notion`}),(0,O.jsxs)(`div`,{className:mn.searchRow,children:[(0,O.jsx)(`input`,{className:mn.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,O.jsx)(`button`,{className:mn.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No pages found`}),m.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>f(e),children:[(0,O.jsx)(`div`,{className:mn.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,O.jsx)(`div`,{className:mn.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,O.jsx)(`button`,{className:mn.disconnectBtn,onClick:()=>E(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,O.jsx)(`div`,{className:mn.messagePane,children:a?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:mn.channelHeader,children:a.title}),a.url&&(0,O.jsx)(`a`,{className:mn.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,O.jsx)(`div`,{className:mn.pageBody,dangerouslySetInnerHTML:{__html:Ce(s||`Loading…`)}})]}):(0,O.jsx)(`div`,{className:mn.emptyPane,children:`Select a page`})})]})}var vn={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function yn(e){return e.content||e.plaintext||e.message||``}function bn(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function xn(){let e=A(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{T(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{T(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await E(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await E(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await E(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await E(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(E(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await E(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,O.jsxs)(`div`,{className:vn.root,children:[(0,O.jsxs)(`div`,{className:vn.sidebar,children:[(0,O.jsx)(`div`,{className:vn.sidebarHeader,children:(0,O.jsx)(`div`,{className:vn.sidebarTitle,children:`Alexandria`})}),(0,O.jsxs)(`div`,{className:vn.sidebarBtns,children:[(0,O.jsx)(`button`,{className:vn.createBtn,onClick:g,children:`+ Create`}),(0,O.jsx)(`button`,{className:vn.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,O.jsxs)(`div`,{className:vn.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,O.jsxs)(`div`,{className:`${vn.channelItem} ${r===e.id?vn.channelActive:``}`,onClick:()=>i(e.id),children:[(0,O.jsx)(`div`,{className:vn.channelName,children:e.name}),(0,O.jsxs)(`div`,{className:vn.channelMeta,children:[(0,O.jsxs)(`span`,{className:vn.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,O.jsx)(`button`,{className:vn.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,O.jsx)(`div`,{className:vn.main,children:r?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:vn.chatHeader,children:[(0,O.jsx)(`div`,{className:vn.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,O.jsx)(`div`,{className:vn.chatChannelId,children:r}),(0,O.jsx)(`div`,{className:`${vn.statusDot} ${l?vn.connected:vn.disconnected}`}),(0,O.jsx)(`span`,{className:vn.statusText,children:l?`Live`:`HTTP`})]}),(0,O.jsxs)(`div`,{className:vn.messages,ref:p,children:[a.length===0&&(0,O.jsx)(`div`,{className:vn.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=bn(e),r=yn(e),i=n===d;return(0,O.jsxs)(`div`,{className:`${vn.msg} ${i?vn.msgSelf:vn.msgOther}`,children:[!i&&(0,O.jsx)(`div`,{className:vn.msgSender,children:n}),(0,O.jsx)(`div`,{className:vn.msgContent,children:r}),(0,O.jsx)(`div`,{className:vn.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,O.jsxs)(`div`,{className:vn.inputRow,children:[(0,O.jsx)(`input`,{className:vn.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,O.jsx)(`button`,{className:vn.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,O.jsxs)(`div`,{className:vn.welcome,children:[(0,O.jsx)(`div`,{className:vn.welcomeIcon,children:`🔐`}),(0,O.jsx)(`div`,{className:vn.welcomeTitle,children:`Alexandria`}),(0,O.jsx)(`div`,{className:vn.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,O.jsxs)(`div`,{className:vn.welcomeBox,children:[(0,O.jsx)(`div`,{className:vn.welcomeBoxTitle,children:`HOW TO USE`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,O.jsx)(`div`,{className:vn.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,O.jsx)(`div`,{className:vn.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,O.jsxs)(`div`,{className:vn.welcomeBox,children:[(0,O.jsx)(`div`,{className:vn.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab create "Project X"`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab join <invite-code>`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab read`})]})]})})]})}var Sn=[],Cn=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Cn:Sn).push(n+=e[t])})();function wn(e){if(e<768)return!1;for(let t=0,n=Sn.length;;){let r=t+n>>1;if(e<Sn[r])n=r;else if(e>=Cn[r])t=r+1;else return!0;if(t==n)return!1}}function Tn(e){return e>=127462&&e<=127487}var En=8205;function Dn(e,t,n=!0,r=!0){return(n?On:kn)(e,t,r)}function On(e,t,n){if(t==e.length)return t;t&&jn(e.charCodeAt(t))&&Mn(e.charCodeAt(t-1))&&t--;let r=An(e,t);for(t+=Nn(r);t<e.length;){let i=An(e,t);if(r==En||i==En||n&&wn(i))t+=Nn(i),r=i;else if(Tn(i)){let n=0,r=t-2;for(;r>=0&&Tn(An(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function kn(e,t,n){for(;t>0;){let r=On(e,t-2,n);if(r<t)return r;t--}return 0}function An(e,t){let n=e.charCodeAt(t);if(!Mn(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return jn(r)?(n-55296<<10)+(r-56320)+65536:n}function jn(e){return e>=56320&&e<57344}function Mn(e){return e>=55296&&e<56320}function Nn(e){return e<65536?1:2}var Pn=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Wn(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),In.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Wn(this,e,t);let n=[];return this.decompose(e,t,n,0),In.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Bn(this),i=new Bn(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Bn(this,e)}iterRange(e,t=this.length){return new Vn(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Hn(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Fn(t):In.from(Fn.split(t,[]))}},Fn=class e extends Pn{constructor(e,t=Ln(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Un(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(zn(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Rn(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Wn(this,t,n);let i=Rn(this.text,Rn(r.text,zn(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):In.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
660
|
+
Be concise. Highlight what each agent contributed uniquely. Give your own synthesis verdict at the end.`},e=>{i+=e,g(i)})}catch{}finally{y(!1)}},_e=e=>{let t=window.SpeechRecognition??window.webkitSpeechRecognition;if(!t){alert(`Speech recognition not supported.`);return}let n=re.current.get(e);if(l.find(t=>t.agent.id===e)?.voiceActive&&n){n.stop(),j(e,{voiceActive:!1});return}let r=new t;re.current.set(e,r),r.lang=`it-IT`,r.continuous=!1,r.interimResults=!1,r.onresult=t=>{let n=t.results[0][0].transcript;j(e,{input:(l.find(t=>t.agent.id===e)?.input??``)+(l.find(t=>t.agent.id===e)?.input?` `:``)+n})},r.onend=()=>j(e,{voiceActive:!1}),r.onerror=()=>j(e,{voiceActive:!1}),r.start(),j(e,{voiceActive:!0})},ve=(e,t)=>{if(!t)return;let n=t.name.toLowerCase().endsWith(`.pdf`)||t.type===`application/pdf`,r=new FileReader;n?(r.onload=n=>{let r=(n.target?.result).split(`,`)[1];j(e,{attachedFile:{name:t.name,size:t.size,base64:r,mimeType:`application/pdf`,isPDF:!0},attachedImage:null})},r.readAsDataURL(t)):(r.onload=n=>{j(e,{attachedFile:{name:t.name,size:t.size,content:n.target?.result},attachedImage:null})},r.readAsText(t))},ye=(e,t)=>{if(!t)return;let n=new FileReader;n.onload=n=>{let r=(n.target?.result).split(`,`)[1];j(e,{attachedImage:{name:t.name,size:t.size,base64:r,mimeType:t.type||`image/jpeg`},attachedFile:null})},n.readAsDataURL(t)},be=()=>{x({name:``,tagline:``,systemPrompt:``}),C(`create`),ee(``)},xe=async e=>{let t=await T(`/api/agents/${e.id}`).catch(()=>null);x({name:e.id,tagline:t?.tagline??e.description,systemPrompt:t?.systemPrompt??``}),C(`edit`),ee(``)},Se=async()=>{if(b){if(!b.tagline.trim()||!b.systemPrompt.trim()){ee(`Tagline and system prompt are required.`);return}ne(!0),ee(``);try{if(S===`create`){let e=b.name.toLowerCase().replace(/[^a-z0-9_-]/g,``);if(!e){ee(`Agent name required (lowercase, no spaces).`),ne(!1);return}let t=await E(`/api/agents`,{name:e,tagline:b.tagline,systemPrompt:b.systemPrompt});if(t?.error){ee(`Error: `+t.error),ne(!1);return}}else await E(`/api/agents/${b.name}`,{tagline:b.tagline,systemPrompt:b.systemPrompt,category:`custom`},`PUT`);x(null),ce()}catch(e){ee(`Error: `+e.message)}finally{ne(!1)}}},M=e=>{confirm(`Delete agent "${e.label}"?`)&&E(`/api/agents/${e.id}`,{},`DELETE`).then(()=>ce())};return r?(0,O.jsx)(`div`,{className:U.root,children:(0,O.jsx)(`div`,{className:U.loading,children:(0,O.jsx)(`div`,{className:`spinner`})})}):(0,O.jsxs)(`div`,{className:U.root,children:[(0,O.jsxs)(`div`,{className:U.gridSection,children:[(0,O.jsxs)(`div`,{className:U.gridHeader,children:[(0,O.jsxs)(`div`,{className:U.headerRow,children:[(0,O.jsx)(`input`,{className:U.search,value:a,onChange:e=>o(e.target.value),placeholder:`Search agents…`}),(0,O.jsx)(`button`,{className:U.createBtn,onClick:be,children:`+ Create`})]}),(0,O.jsx)(`div`,{className:U.catTabs,children:le.map(e=>(0,O.jsxs)(`button`,{className:`${U.catTab} ${s===e?U.catActive:``}`,onClick:()=>c(e),children:[e,` (`,e===`All`?t.length:t.filter(t=>t.category===e).length,`)`]},e))})]}),(0,O.jsx)(`div`,{className:U.grid,children:ue.map(e=>{let t=l.some(t=>t.agent.id===e.id);return(0,O.jsxs)(`div`,{className:`${U.agentCard} ${t?U.agentActive:``}`,onClick:()=>de(e),children:[(0,O.jsxs)(`div`,{className:U.agentCardTop,children:[(0,O.jsx)(`div`,{className:U.agentIcon,children:e.icon}),e.isCustom&&(0,O.jsxs)(`div`,{className:U.agentActions,children:[(0,O.jsx)(`button`,{className:U.agentEditBtn,onClick:t=>{t.stopPropagation(),xe(e)},children:`✏️`}),(0,O.jsx)(`button`,{className:U.agentDelBtn,onClick:t=>{t.stopPropagation(),M(e)},children:`🗑`})]})]}),(0,O.jsx)(`div`,{className:U.agentLabel,children:e.label}),(0,O.jsx)(`div`,{className:U.agentDesc,children:e.description}),(0,O.jsx)(`div`,{className:U.agentCat,children:e.category})]},e.id)})})]}),(0,O.jsx)(`div`,{className:U.chatArea,children:l.length===0?(0,O.jsxs)(`div`,{className:U.emptyChat,children:[(0,O.jsx)(`span`,{children:`Click an agent above to open a chat`}),(0,O.jsx)(`span`,{className:U.emptyChatHint,children:`Open multiple agents to run them in parallel`})]}):l.map(e=>{let{agent:t}=e,n=e.attachedFile?`📎 ${e.attachedFile.name}`:e.attachedImage?`🖼 ${e.attachedImage.name}`:null;return(0,O.jsxs)(`div`,{className:U.chatPanel,children:[(0,O.jsxs)(`div`,{className:U.chatHeader,children:[(0,O.jsx)(`span`,{className:U.chatIcon,children:t.icon}),(0,O.jsxs)(`div`,{className:U.chatHeaderInfo,children:[(0,O.jsx)(`div`,{className:U.chatAgentName,children:t.label}),(0,O.jsx)(`div`,{className:U.chatAgentDesc,children:t.description})]}),(0,O.jsx)(`button`,{className:U.closeChat,onClick:()=>fe(t.id),children:`✕`})]}),(0,O.jsxs)(`div`,{className:U.chatMessages,ref:e=>{D.current.set(t.id,e)},children:[e.history.length===0&&(0,O.jsxs)(`div`,{className:U.chatEmpty,children:[`Ask `,t.label,` anything…`]}),e.history.map((e,t)=>(0,O.jsx)(`div`,{className:`${U.chatMsg} ${e.role===`user`?U.msgUser:U.msgAgent}`,children:e.role===`assistant`?(0,O.jsx)(`div`,{dangerouslySetInnerHTML:{__html:Ce(e.content||`…`)}}):(0,O.jsx)(`span`,{children:e.content})},t)),e.streaming&&e.history[e.history.length-1]?.role===`assistant`&&e.history[e.history.length-1]?.content===``&&(0,O.jsxs)(`div`,{className:U.thinking,children:[(0,O.jsx)(`span`,{className:U.dot}),(0,O.jsx)(`span`,{className:U.dot}),(0,O.jsx)(`span`,{className:U.dot})]})]}),n&&(0,O.jsxs)(`div`,{className:U.attachBar,children:[(0,O.jsx)(`span`,{children:n}),(0,O.jsx)(`button`,{className:U.attachClear,onClick:()=>j(t.id,{attachedFile:null,attachedImage:null}),children:`×`})]}),(0,O.jsxs)(`div`,{className:U.chatInput,children:[(0,O.jsxs)(`div`,{className:U.chatTools,children:[(0,O.jsx)(`button`,{className:`${U.toolBtn} ${e.voiceActive?U.toolBtnActive:``}`,onClick:()=>_e(t.id),title:`Voice`,children:`🎤`}),(0,O.jsx)(`button`,{className:U.toolBtn,onClick:()=>oe.current.get(t.id)?.click(),title:`Attach file`,children:`📎`}),(0,O.jsx)(`button`,{className:U.toolBtn,onClick:()=>k.current.get(t.id)?.click(),title:`Attach image`,children:`🖼`}),(0,O.jsx)(`input`,{type:`file`,style:{display:`none`},ref:e=>{oe.current.set(t.id,e)},onChange:e=>ve(t.id,e.target.files?.[0])}),(0,O.jsx)(`input`,{type:`file`,accept:`image/*`,style:{display:`none`},ref:e=>{k.current.set(t.id,e)},onChange:e=>ye(t.id,e.target.files?.[0])})]}),(0,O.jsxs)(`div`,{className:U.chatInputRow,children:[(0,O.jsx)(`textarea`,{className:U.chatTextarea,value:e.input,onChange:e=>j(t.id,{input:e.target.value}),placeholder:`Message ${t.label}…`,rows:2,onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),he(e,e.input,e.attachedFile,e.attachedImage))}}),(0,O.jsx)(`button`,{className:U.sendBtn,onClick:()=>he(e,e.input,e.attachedFile,e.attachedImage),disabled:e.streaming||!e.input.trim()&&!e.attachedFile&&!e.attachedImage,children:e.streaming?`…`:`→`})]})]})]},t.id)})}),l.length>=2&&(0,O.jsxs)(`div`,{className:U.orchBar,children:[(0,O.jsxs)(`div`,{className:U.orchLabel,children:[`🎼 Conductor · `,l.map(e=>`${e.agent.icon} ${e.agent.label}`).join(` · `)]}),(0,O.jsxs)(`div`,{className:U.orchRow,children:[(0,O.jsx)(`textarea`,{ref:se,className:U.orchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Ask all agents — Conductor will synthesize a unified response…`,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ge())}}),(0,O.jsx)(`button`,{className:U.orchBtn,onClick:ge,disabled:p||v||!d.trim(),children:p?`⏳`:v?`🔄`:`🎼 Run`})]}),(v||h)&&(0,O.jsxs)(`div`,{className:U.orchSynthesis,children:[(0,O.jsxs)(`div`,{className:U.orchSynthHeader,children:[(0,O.jsx)(`span`,{children:`🎼 Conductor Synthesis`}),v&&(0,O.jsx)(`span`,{className:U.orchSynthSpinner,children:`synthesizing…`})]}),(0,O.jsx)(`div`,{className:U.orchSynthBody,dangerouslySetInnerHTML:{__html:Ce(h||`…`)}})]})]}),b&&(0,O.jsx)(`div`,{className:U.modalOverlay,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,O.jsxs)(`div`,{className:U.modal,children:[(0,O.jsx)(`div`,{className:U.modalTitle,children:S===`create`?`+ New Agent`:`✏️ Edit Agent`}),S===`create`&&(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`Agent name (lowercase, no spaces)`}),(0,O.jsx)(`input`,{className:U.formInput,placeholder:`my-agent`,value:b.name,onChange:e=>x(t=>t&&{...t,name:e.target.value})})]}),(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`Tagline`}),(0,O.jsx)(`input`,{className:U.formInput,placeholder:`Short description`,value:b.tagline,onChange:e=>x(t=>t&&{...t,tagline:e.target.value})})]}),(0,O.jsxs)(`div`,{className:U.formField,children:[(0,O.jsx)(`label`,{className:U.formLabel,children:`System Prompt`}),(0,O.jsx)(`textarea`,{className:U.formTextarea,placeholder:`You are an expert in…`,value:b.systemPrompt,onChange:e=>x(t=>t&&{...t,systemPrompt:e.target.value})})]}),w&&(0,O.jsx)(`div`,{className:U.formError,children:w}),(0,O.jsxs)(`div`,{className:U.modalBtns,children:[(0,O.jsx)(`button`,{className:U.cancelBtn,onClick:()=>x(null),children:e(`common.cancel`)}),(0,O.jsx)(`button`,{className:U.modalSaveBtn,onClick:Se,disabled:te,children:te?`…`:S===`create`?`Create Agent`:`Save`})]})]})})]})}var W={root:`_root_1mam6_1`,error:`_error_1mam6_10`,errorHint:`_errorHint_1mam6_16`,quotaBar:`_quotaBar_1mam6_29`,quotaText:`_quotaText_1mam6_37`,quotaUsed:`_quotaUsed_1mam6_43`,quotaPct:`_quotaPct_1mam6_44`,quotaTrack:`_quotaTrack_1mam6_46`,quotaFill:`_quotaFill_1mam6_53`,actionBar:`_actionBar_1mam6_59`,filterBtn:`_filterBtn_1mam6_67`,filterActive:`_filterActive_1mam6_79`,spacer:`_spacer_1mam6_85`,newBtn:`_newBtn_1mam6_87`,uploadBtn:`_uploadBtn_1mam6_98`,searchRow:`_searchRow_1mam6_108`,searchInput:`_searchInput_1mam6_114`,searchBtn:`_searchBtn_1mam6_126`,loading:`_loading_1mam6_136`,empty:`_empty_1mam6_141`,fileList:`_fileList_1mam6_151`,fileRow:`_fileRow_1mam6_159`,fileIcon:`_fileIcon_1mam6_172`,fileInfo:`_fileInfo_1mam6_174`,fileName:`_fileName_1mam6_176`,fileMeta:`_fileMeta_1mam6_184`,fileBtns:`_fileBtns_1mam6_190`,editBtn:`_editBtn_1mam6_196`,viewBtn:`_viewBtn_1mam6_197`,pdfBtn:`_pdfBtn_1mam6_198`,openBtn:`_openBtn_1mam6_199`,delBtn:`_delBtn_1mam6_200`,editorRoot:`_editorRoot_1mam6_204`,editorToolbar:`_editorToolbar_1mam6_211`,backBtn:`_backBtn_1mam6_221`,editorName:`_editorName_1mam6_231`,saveBtn:`_saveBtn_1mam6_238`,editorArea:`_editorArea_1mam6_251`,editorMeta:`_editorMeta_1mam6_266`,viewerRoot:`_viewerRoot_1mam6_276`,imgContainer:`_imgContainer_1mam6_283`,imgView:`_imgView_1mam6_292`,pdfFrame:`_pdfFrame_1mam6_298`};function un(e,t){return e===`folder`?`📁`:e===`image`?`🖼`:e===`pdf`||t.includes(`pdf`)?`📕`:e===`video`?`🎬`:e===`audio`?`🎵`:t.includes(`spreadsheet`)||t.includes(`excel`)?`📊`:t.includes(`presentation`)||t.includes(`powerpoint`)?`📽`:t.includes(`document`)||t.includes(`word`)?`📄`:t.includes(`zip`)||t.includes(`archive`)?`📦`:`📄`}function dn(e){let t=e.mimeType;return e.type===`text`||e.type===`doc`||t.includes(`text`)||t.includes(`json`)||t.includes(`javascript`)||t.includes(`xml`)||t.includes(`csv`)||t.includes(`yaml`)||t.includes(`markdown`)||t.includes(`html`)||t.includes(`css`)||t.includes(`python`)||t.includes(`vnd.google-apps.document`)}function fn(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(`list`),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),ee=(e=s,t=l)=>{i(!0);let r=`/api/drive`;e&&(r+=`?filter=${e}`),t&&(r+=`${e?`&`:`?`}search=${encodeURIComponent(t)}`),T(r).then(e=>{n(e??{files:[]}),i(!1)}).catch(e=>{o(e.message??`Error`),i(!1)})};(0,_.useEffect)(()=>{ee()},[]);let te=e=>{c(e),ee(e,l)},ne=()=>{u(d),ee(s,d)},re=(e,t)=>{i(!0),T(`/api/drive/read/${e}`).then(n=>{g({id:e,name:t,content:n?.content??``}),y(n?.content??``),m(`editor`),i(!1)}).catch(()=>i(!1))},ie=async()=>{if(h&&confirm(`Save changes to "${h.name}" on Drive?`)){C(!0);try{await E(`/api/drive/update/${h.id}`,{content:v}),g(e=>e&&{...e,content:v}),alert(`Saved!`)}catch(e){alert(`Save failed: `+e.message)}finally{C(!1)}}},ae=(e,t)=>{i(!0),T(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:${n?.mimeType??`image/jpeg`};base64,${n?.base64}`,mode:`image`}),m(`image`),i(!1)}).catch(()=>i(!1))},D=(e,t)=>{i(!0),T(`/api/drive/download/${e}`).then(n=>{x({id:e,name:t,src:`data:application/pdf;base64,${n?.base64}`,mode:`pdf`}),m(`pdf`),i(!1)}).catch(()=>i(!1))},oe=(e,t)=>{confirm(`Delete "${t}" from Drive? (moved to trash)`)&&E(`/api/drive/delete/${e}`,{}).then(()=>{n(null),ee()})},k=()=>{let e=prompt(`File name (e.g. notes.txt, script.py):`);e&&E(`/api/drive/upload`,{name:e,content:``,mimeType:`text/plain`}).then(t=>{t?.id?re(t.id,e):ee()}).catch(e=>alert(`Error: `+e.message))},se=()=>{w.current?.click()},ce=e=>{if(!e)return;let t=new FileReader;t.onload=t=>{let r=(t.target?.result).split(`,`)[1]??``;E(`/api/drive/upload`,{name:e.name,content:r,mimeType:e.type||`application/octet-stream`,encoding:`base64`}).then(()=>{n(null),ee()}).catch(e=>alert(`Upload error: `+e.message))},t.readAsDataURL(e)};if(a)return(0,O.jsxs)(`div`,{className:W.error,children:[(0,O.jsx)(`div`,{children:a}),(0,O.jsxs)(`div`,{className:W.errorHint,children:[`Run: `,(0,O.jsx)(`code`,{children:`nha google revoke`}),` then `,(0,O.jsx)(`code`,{children:`nha google auth`})]})]});if(p===`editor`&&h)return(0,O.jsxs)(`div`,{className:W.editorRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:h.name}),(0,O.jsx)(`button`,{className:W.saveBtn,onClick:ie,disabled:S,children:S?`Saving…`:`Save to Drive`})]}),(0,O.jsx)(`textarea`,{className:W.editorArea,value:v,onChange:e=>y(e.target.value),spellCheck:!1,onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault();let t=e.currentTarget.selectionStart,n=e.currentTarget.selectionEnd,r=e.currentTarget.value;e.currentTarget.value=r.slice(0,t)+` `+r.slice(n),e.currentTarget.selectionStart=e.currentTarget.selectionEnd=t+2}}}),(0,O.jsxs)(`div`,{className:W.editorMeta,children:[`File ID: `,h.id,` · Tab = 2 spaces · Not auto-saved`]})]});if(p===`image`&&b)return(0,O.jsxs)(`div`,{className:W.viewerRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:b.name})]}),(0,O.jsx)(`div`,{className:W.imgContainer,children:(0,O.jsx)(`img`,{src:b.src,alt:b.name,className:W.imgView})})]});if(p===`pdf`&&b)return(0,O.jsxs)(`div`,{className:W.viewerRoot,children:[(0,O.jsxs)(`div`,{className:W.editorToolbar,children:[(0,O.jsx)(`button`,{className:W.backBtn,onClick:()=>m(`list`),children:`← Back`}),(0,O.jsx)(`span`,{className:W.editorName,children:b.name})]}),(0,O.jsx)(`iframe`,{className:W.pdfFrame,src:b.src,title:b.name})]});let le=t?.files??[],ue=t?.quota;return(0,O.jsxs)(`div`,{className:W.root,children:[ue&&(0,O.jsxs)(`div`,{className:W.quotaBar,children:[(0,O.jsxs)(`div`,{className:W.quotaText,children:[(0,O.jsxs)(`span`,{className:W.quotaUsed,children:[ue.usage,` of `,ue.limit,` used`]}),(0,O.jsxs)(`span`,{className:W.quotaPct,children:[ue.percentUsed,`%`]})]}),(0,O.jsx)(`div`,{className:W.quotaTrack,children:(0,O.jsx)(`div`,{className:W.quotaFill,style:{width:`${Math.min(ue.percentUsed,100)}%`,background:ue.percentUsed>90?`var(--red)`:ue.percentUsed>70?`var(--amber)`:`var(--green)`}})})]}),(0,O.jsxs)(`div`,{className:W.actionBar,children:[[``,`recent`,`starred`,`shared`].map(e=>(0,O.jsx)(`button`,{className:`${W.filterBtn} ${s===e?W.filterActive:``}`,onClick:()=>te(e),children:e?e.charAt(0).toUpperCase()+e.slice(1):`All Files`},e)),(0,O.jsx)(`div`,{className:W.spacer}),(0,O.jsx)(`button`,{className:W.newBtn,onClick:k,children:`+ New File`}),(0,O.jsx)(`button`,{className:W.uploadBtn,onClick:se,children:e(`drive.upload`)}),(0,O.jsx)(`input`,{ref:w,type:`file`,style:{display:`none`},onChange:e=>ce(e.target.files?.[0])})]}),(0,O.jsxs)(`div`,{className:W.searchRow,children:[(0,O.jsx)(`input`,{className:W.searchInput,value:d,onChange:e=>f(e.target.value),placeholder:`Search files…`,onKeyDown:e=>e.key===`Enter`&&ne()}),(0,O.jsx)(`button`,{className:W.searchBtn,onClick:ne,children:`Search`})]}),r&&(0,O.jsx)(`div`,{className:W.loading,children:(0,O.jsx)(`div`,{className:`spinner`})}),!r&&le.length===0&&(0,O.jsxs)(`div`,{className:W.empty,children:[e(`drive.noFiles`),` found`]}),(0,O.jsx)(`div`,{className:W.fileList,children:le.map(e=>{let t=dn(e),n=e.type===`image`,r=e.type===`pdf`||e.mimeType.includes(`pdf`);return(0,O.jsxs)(`div`,{className:W.fileRow,onClick:()=>{t?re(e.id,e.name):n?ae(e.id,e.name):r?D(e.id,e.name):e.webViewLink&&window.open(e.webViewLink,`_blank`)},style:{cursor:t||n||r||e.webViewLink?`pointer`:`default`},children:[(0,O.jsx)(`span`,{className:W.fileIcon,children:un(e.type,e.mimeType)}),(0,O.jsxs)(`div`,{className:W.fileInfo,children:[(0,O.jsx)(`div`,{className:W.fileName,children:e.name}),(0,O.jsxs)(`div`,{className:W.fileMeta,children:[e.modifiedTime?new Date(e.modifiedTime).toLocaleDateString():``,e.size?` · ${e.size}`:``,e.shared?` · Shared`:``,e.starred?` ★`:``]})]}),(0,O.jsxs)(`div`,{className:W.fileBtns,children:[t&&(0,O.jsx)(`button`,{className:W.editBtn,onClick:t=>{t.stopPropagation(),re(e.id,e.name)},children:`Edit`}),n&&(0,O.jsx)(`button`,{className:W.viewBtn,onClick:t=>{t.stopPropagation(),ae(e.id,e.name)},children:`View`}),r&&(0,O.jsx)(`button`,{className:W.pdfBtn,onClick:t=>{t.stopPropagation(),D(e.id,e.name)},children:`PDF`}),e.webViewLink&&(0,O.jsx)(`a`,{className:W.openBtn,href:e.webViewLink,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:`Open ↗`}),(0,O.jsx)(`button`,{className:W.delBtn,onClick:t=>{t.stopPropagation(),oe(e.id,e.name)},children:`Del`})]})]},e.id)})})]})}var G={root:`_root_p82nk_1`,loading:`_loading_p82nk_10`,errorBox:`_errorBox_p82nk_12`,errorHint:`_errorHint_p82nk_13`,connectBox:`_connectBox_p82nk_17`,connectIcon:`_connectIcon_p82nk_27`,connectTitle:`_connectTitle_p82nk_28`,connectDesc:`_connectDesc_p82nk_29`,connectLink:`_connectLink_p82nk_30`,connectRow:`_connectRow_p82nk_31`,connectInput:`_connectInput_p82nk_32`,connectBtn:`_connectBtn_p82nk_43`,connectError:`_connectError_p82nk_55`,userRow:`_userRow_p82nk_57`,avatar:`_avatar_p82nk_68`,userLogin:`_userLogin_p82nk_70`,userName:`_userName_p82nk_71`,disconnectBtn:`_disconnectBtn_p82nk_73`,repoBar:`_repoBar_p82nk_84`,repoInput:`_repoInput_p82nk_90`,issuesBtn:`_issuesBtn_p82nk_102`,prsBtn:`_prsBtn_p82nk_113`,repoPills:`_repoPills_p82nk_124`,repoPill:`_repoPill_p82nk_124`,issueCount:`_issueCount_p82nk_147`,tabs:`_tabs_p82nk_153`,tab:`_tab_p82nk_153`,tabActive:`_tabActive_p82nk_172`,markRead:`_markRead_p82nk_178`,content:`_content_p82nk_189`,empty:`_empty_p82nk_191`,notifRow:`_notifRow_p82nk_193`,issueRow:`_issueRow_p82nk_193`,prRow:`_prRow_p82nk_193`,notifRepo:`_notifRepo_p82nk_207`,notifType:`_notifType_p82nk_208`,notifTitle:`_notifTitle_p82nk_209`,notifMeta:`_notifMeta_p82nk_210`,issueNum:`_issueNum_p82nk_212`,issueTitle:`_issueTitle_p82nk_213`,issueMeta:`_issueMeta_p82nk_214`,issueLabel:`_issueLabel_p82nk_215`,prNum:`_prNum_p82nk_217`,prTitle:`_prTitle_p82nk_218`,prAuthor:`_prAuthor_p82nk_219`,prDraft:`_prDraft_p82nk_220`,prMeta:`_prMeta_p82nk_221`};function pn(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`notifs`),d=(e=``)=>{i(!0),T(e?`/api/github?repo=${encodeURIComponent(e)}`:`/api/github`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))};(0,_.useEffect)(()=>{d()},[]);let f=()=>{let e=s.trim();o(e),d(e),u(`issues`)},p=()=>{let e=s.trim();o(e),d(e),u(`prs`)},m=()=>E(`/api/github/mark-read`,{}).then(()=>d(a)),h=()=>{confirm(`Remove GitHub connection? You can reconnect anytime.`)&&E(`/api/config`,{key:`github-token`,value:``}).then(()=>{n(null),i(!1)})},[g,v]=(0,_.useState)(``),[y,b]=(0,_.useState)(!1),x=t?.user;if(r)return(0,O.jsx)(`div`,{className:G.loading,children:(0,O.jsx)(`div`,{className:`spinner`})});let S=async()=>{g.trim()&&(b(!0),await E(`/api/config`,{key:`github-token`,value:g.trim()}),v(``),b(!1),d())};if(t?.error||!x?.login&&!r)return(0,O.jsxs)(`div`,{className:G.connectBox,children:[(0,O.jsx)(`div`,{className:G.connectIcon,children:`🔗`}),(0,O.jsx)(`div`,{className:G.connectTitle,children:`Connect GitHub`}),(0,O.jsxs)(`div`,{className:G.connectDesc,children:[`Enter your Personal Access Token to connect GitHub.`,(0,O.jsx)(`br`,{}),`Create one at `,(0,O.jsx)(`a`,{href:`https://github.com/settings/tokens`,target:`_blank`,rel:`noreferrer`,className:G.connectLink,children:`github.com/settings/tokens`}),` with `,(0,O.jsx)(`strong`,{children:`repo`}),` scope.`]}),(0,O.jsxs)(`div`,{className:G.connectRow,children:[(0,O.jsx)(`input`,{className:G.connectInput,type:`password`,value:g,onChange:e=>v(e.target.value),placeholder:`ghp_xxxxxxxxxxxxxxxxxxxx`,onKeyDown:e=>e.key===`Enter`&&S()}),(0,O.jsx)(`button`,{className:G.connectBtn,onClick:S,disabled:y||!g.trim(),children:y?`Connecting...`:`Connect`})]}),t?.error&&(0,O.jsx)(`div`,{className:G.connectError,children:t.error})]});let C=Array.isArray(t?.notifications)?t.notifications:[],w=Array.isArray(t?.issues)?t.issues:[],ee=Array.isArray(t?.prs)?t.prs:[];return(0,O.jsxs)(`div`,{className:G.root,children:[x?.login&&(0,O.jsxs)(`div`,{className:G.userRow,children:[x.avatar&&(0,O.jsx)(`img`,{src:x.avatar,className:G.avatar,alt:x.login}),(0,O.jsxs)(`div`,{style:{flex:1},children:[(0,O.jsxs)(`div`,{className:G.userLogin,children:[`@`,x.login]}),x.name&&(0,O.jsx)(`div`,{className:G.userName,children:x.name})]}),(0,O.jsx)(`button`,{className:G.disconnectBtn,onClick:h,children:`Disconnect`})]}),(0,O.jsxs)(`div`,{className:G.repoBar,children:[(0,O.jsx)(`input`,{className:G.repoInput,value:s,onChange:e=>c(e.target.value),placeholder:`owner/repo`,onKeyDown:e=>e.key===`Enter`&&f()}),(0,O.jsx)(`button`,{className:G.issuesBtn,onClick:f,children:`Issues`}),(0,O.jsx)(`button`,{className:G.prsBtn,onClick:p,children:`PRs`})]}),x?.repos&&x.repos.length>0&&(0,O.jsx)(`div`,{className:G.repoPills,children:x.repos.slice(0,12).map(e=>(0,O.jsxs)(`button`,{className:G.repoPill,onClick:()=>{c(e.full_name),o(e.full_name),d(e.full_name),u(`issues`)},title:e.description??``,children:[e.private?`🔒 `:``,e.full_name,e.open_issues?(0,O.jsx)(`span`,{className:G.issueCount,children:e.open_issues}):null]},e.full_name))}),(0,O.jsxs)(`div`,{className:G.tabs,children:[(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`notifs`?G.tabActive:``}`,onClick:()=>u(`notifs`),children:[`Notifications `,C.length>0?`(${C.length})`:``]}),w.length>0&&(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`issues`?G.tabActive:``}`,onClick:()=>u(`issues`),children:[`Issues (`,w.length,`)`]}),ee.length>0&&(0,O.jsxs)(`button`,{className:`${G.tab} ${l===`prs`?G.tabActive:``}`,onClick:()=>u(`prs`),children:[`PRs (`,ee.length,`)`]}),l===`notifs`&&C.length>0&&(0,O.jsx)(`button`,{className:G.markRead,onClick:m,children:`Mark all read`})]}),(0,O.jsxs)(`div`,{className:G.content,children:[l===`notifs`&&(C.length===0?(0,O.jsx)(`div`,{className:G.empty,children:`No notifications`}):C.map((e,t)=>(0,O.jsxs)(`a`,{className:G.notifRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsx)(`span`,{className:G.notifRepo,children:e.repo}),(0,O.jsxs)(`span`,{className:G.notifType,children:[`[`,e.type,`]`]}),(0,O.jsx)(`div`,{className:G.notifTitle,children:e.title}),(0,O.jsxs)(`div`,{className:G.notifMeta,children:[e.reason,` · `,e.updated]})]},t))),l===`issues`&&(w.length===0?(0,O.jsxs)(`div`,{className:G.empty,children:[e(`github.noIssues`),` for `,a]}):w.map((e,t)=>(0,O.jsxs)(`a`,{className:G.issueRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsxs)(`span`,{className:G.issueNum,children:[`#`,e.number]}),(0,O.jsx)(`span`,{className:G.issueTitle,children:e.title}),e.assignee&&(0,O.jsxs)(`span`,{className:G.issueMeta,children:[`→ `,e.assignee]}),e.labels&&(0,O.jsxs)(`span`,{className:G.issueLabel,children:[`[`,e.labels,`]`]}),(0,O.jsx)(`div`,{className:G.issueMeta,children:e.updated})]},t))),l===`prs`&&(ee.length===0?(0,O.jsxs)(`div`,{className:G.empty,children:[`No PRs for `,a]}):ee.map((e,t)=>(0,O.jsxs)(`a`,{className:G.prRow,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,O.jsxs)(`span`,{className:G.prNum,children:[`#`,e.number]}),(0,O.jsx)(`span`,{className:G.prTitle,children:e.title}),(0,O.jsxs)(`span`,{className:G.prAuthor,children:[`by `,e.author]}),e.draft&&(0,O.jsx)(`span`,{className:G.prDraft,children:`DRAFT`}),(0,O.jsx)(`div`,{className:G.prMeta,children:e.updated})]},t)))]})]})}var mn={loading:`_loading_1h5ss_1`,errorBox:`_errorBox_1h5ss_3`,errorHint:`_errorHint_1h5ss_4`,twoPane:`_twoPane_1h5ss_7`,sidebar:`_sidebar_1h5ss_13`,sidebarTitle:`_sidebarTitle_1h5ss_24`,workspace:`_workspace_1h5ss_36`,searchRow:`_searchRow_1h5ss_42`,searchInput:`_searchInput_1h5ss_50`,searchBtn:`_searchBtn_1h5ss_63`,channelItem:`_channelItem_1h5ss_73`,channelActive:`_channelActive_1h5ss_83`,pageTitle:`_pageTitle_1h5ss_89`,pageMeta:`_pageMeta_1h5ss_97`,disconnectBtn:`_disconnectBtn_1h5ss_99`,empty:`_empty_1h5ss_110`,messagePane:`_messagePane_1h5ss_112`,channelHeader:`_channelHeader_1h5ss_120`,emptyPane:`_emptyPane_1h5ss_129`,message:`_message_1h5ss_112`,msgUser:`_msgUser_1h5ss_146`,msgText:`_msgText_1h5ss_147`,msgTs:`_msgTs_1h5ss_148`,openLink:`_openLink_1h5ss_150`,pageBody:`_pageBody_1h5ss_160`};function hn({onSaved:e}){let[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),s=async()=>{if(t.trim()){if(t.startsWith(`xoxe-`)){o(`"xoxe-" è un refresh token (Token Rotation attivata). NHA ha bisogno di "xoxb-". Disabilita Token Rotation in "OAuth & Permissions → Advanced Token Security" oppure crea una nuova app senza Token Rotation.`);return}if(t.startsWith(`xoxp-`)){o(`"xoxp-" è uno User OAuth Token. NHA usa il Bot Token "xoxb-". In "OAuth & Permissions" copia "Bot User OAuth Token" (la prima riga), non lo User Token.`);return}if(t.startsWith(`xoxa-`)||t.startsWith(`xoxr-`)||t.startsWith(`xoxs-`)){o(`Token type "${t.slice(0,5)}" non supportato. NHA accetta solo Bot User OAuth Token che iniziano con "xoxb-".`);return}if(!t.startsWith(`xoxb-`)){o(`Il token deve iniziare con "xoxb-" (Bot User OAuth Token).`);return}i(!0),o(``);try{await E(`/api/config`,{key:`slack-token`,value:t.trim()}),n(``),e()}catch(e){o(e.message||`errore`)}finally{i(!1)}}};return(0,O.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:8,flexWrap:`wrap`},children:[(0,O.jsx)(`input`,{type:`password`,autoFocus:!0,placeholder:`xoxb-...`,value:t,onChange:e=>{n(e.target.value),o(``)},onKeyDown:e=>{e.key===`Enter`&&s()},style:{flex:1,minWidth:260,padding:`6px 10px`,borderRadius:6,border:`1px solid rgba(148,163,184,0.25)`,background:`rgba(15,23,42,0.4)`,color:`inherit`,fontFamily:`SF Mono, monospace`,fontSize:12}}),(0,O.jsx)(`button`,{onClick:s,disabled:!t.trim()||r,style:{padding:`6px 16px`,borderRadius:6,border:`none`,background:`#6366f1`,color:`white`,fontWeight:700,cursor:`pointer`,opacity:!t.trim()||r?.5:1},children:r?`Salvo...`:`Salva e connetti`}),a&&(0,O.jsx)(`div`,{style:{width:`100%`,color:`#ef4444`,fontSize:11},children:a})]})}function gn(){let e=A(),[t,n]=(0,_.useState)(null),[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)(``),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null),[w,ee]=(0,_.useState)(!0),te=(0,_.useRef)(null),ne=()=>{i(!0),T(`/api/slack/channels`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},re=e=>{o(e),C(null),T(`/api/slack/messages?channel=${e.id}&limit=80`).then(e=>c(e?.messages??[])),E(`/api/slack/mark-read`,{channel:e.id}).catch(()=>{})},ie=e=>{a&&T(`/api/slack/thread?channel=${a.id}&ts=${e.ts}`).then(t=>C({parent:e,replies:(t?.messages??[]).filter(t=>t.ts!==e.ts)}))},ae=async()=>{if(!(!a||!l.trim()||d)){f(!0);try{let e={channel:a.id,text:l};S&&(e.threadTs=S.parent.ts),await E(`/api/slack/send`,e),u(``),S?ie(S.parent):re(a)}finally{f(!1)}}},D=async()=>{if(!h.trim()){y(null);return}x(!0);try{y((await T(`/api/slack/search?q=${encodeURIComponent(h)}&count=30`))?.results??[])}finally{x(!1)}},oe=async(e,t)=>{a&&(await E(`/api/slack/react`,{channel:a.id,ts:e.ts,emoji:t}),re(a))};if((0,_.useEffect)(()=>{ne()},[]),(0,_.useEffect)(()=>(te.current&&window.clearInterval(te.current),w&&a&&(te.current=window.setInterval(()=>re(a),15e3)),()=>{te.current&&window.clearInterval(te.current)}),[w,a?.id]),r)return(0,O.jsxs)(`div`,{className:mn.loading,children:[(0,O.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return/token not configured|missing.*token|slack.*token/i.test(t.error)?(0,O.jsxs)(`div`,{style:{maxWidth:720,margin:`40px auto`,padding:24,background:`rgba(15,23,42,0.4)`,border:`1px solid rgba(99,102,241,0.2)`,borderRadius:12,color:`inherit`},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:8},children:[(0,O.jsx)(`span`,{style:{fontSize:32},children:`💬`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{style:{fontSize:20,fontWeight:800},children:`Collega il tuo Slack a NHA`}),(0,O.jsx)(`div`,{style:{fontSize:12,opacity:.7},children:`Bastano 4 passaggi · ~3 minuti · gratis`})]})]}),(0,O.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`32px 1fr`,gap:`12px 10px`,marginTop:16,fontSize:13,lineHeight:1.55},children:[(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`1.`}),(0,O.jsxs)(`div`,{children:[`Apri `,(0,O.jsx)(`a`,{href:`https://api.slack.com/apps?new_app=1`,target:`_blank`,rel:`noreferrer`,style:{color:`#6366f1`,fontWeight:700},children:`api.slack.com/apps → Create New App`}),` e scegli "From scratch". Dai un nome (es. `,(0,O.jsx)(`code`,{children:`NHA Bot`}),`) e seleziona il tuo workspace.`]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`2.`}),(0,O.jsxs)(`div`,{children:[`Nel pannello sinistro vai su `,(0,O.jsx)(`strong`,{children:`OAuth & Permissions`}),`. In "Scopes → Bot Token Scopes" aggiungi `,(0,O.jsx)(`strong`,{children:`tutti questi`}),` permessi:`,(0,O.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:4,fontFamily:`SF Mono, monospace`,fontSize:11},children:[`channels:read`,`channels:history`,`groups:read`,`groups:history`,`im:read`,`im:history`,`mpim:read`,`mpim:history`,`users:read`,`users:read.email`,`team:read`,`chat:write`,`reactions:write`,`search:read`].map(e=>(0,O.jsx)(`code`,{style:{background:`rgba(99,102,241,0.12)`,padding:`2px 6px`,borderRadius:4,color:`#c4b5fd`},children:e},e))})]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`3.`}),(0,O.jsxs)(`div`,{children:[`In cima alla stessa pagina clicca `,(0,O.jsx)(`strong`,{children:`"Install to Workspace"`}),` e conferma. Slack ti darà un `,(0,O.jsx)(`strong`,{children:`Bot User OAuth Token`}),` che inizia per `,(0,O.jsx)(`code`,{children:`xoxb-`}),`.`]}),(0,O.jsx)(`div`,{style:{fontSize:18,fontWeight:700,color:`#a78bfa`},children:`4.`}),(0,O.jsxs)(`div`,{children:[`Copia il token e incollalo qui sotto, oppure vai in `,(0,O.jsx)(`strong`,{children:`Settings → Integration tokens`}),`:`,(0,O.jsx)(hn,{onSaved:ne})]})]}),(0,O.jsxs)(`div`,{style:{marginTop:18,padding:10,background:`rgba(99,102,241,0.06)`,borderRadius:8,fontSize:11,opacity:.8},children:[(0,O.jsx)(`strong`,{children:`Privacy:`}),` il token resta sul tuo computer in `,(0,O.jsx)(`code`,{children:`~/.nha/config.json`}),`. NHA non lo invia ai server.`,(0,O.jsx)(`br`,{}),(0,O.jsx)(`strong`,{children:`Tip:`}),` se hai canali privati che vuoi leggere, il bot deve essere invitato. Da Slack scrivi `,(0,O.jsx)(`code`,{children:`/invite @nome-del-bot`}),` nel canale.`]})]}):(0,O.jsxs)(`div`,{className:mn.errorBox,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`strong`,{children:`⚠ Slack:`}),` `,t.error]}),(0,O.jsxs)(`div`,{className:mn.errorHint,children:[`Se il problema persiste, verifica gli scopes del bot in `,(0,O.jsx)(`a`,{href:`https://api.slack.com/apps`,target:`_blank`,rel:`noreferrer`,children:`api.slack.com/apps`}),`.`]})]});let k=t?.channels??[],se=p?k.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())):k,ce=se.filter(e=>!e.is_im&&!e.is_mpim&&!e.is_private),le=se.filter(e=>e.is_private&&!e.is_im&&!e.is_mpim),ue=se.filter(e=>e.is_im||e.is_mpim),de=(e,t)=>(0,O.jsxs)(`div`,{className:mn.message,style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6},children:[(0,O.jsx)(`span`,{className:mn.msgUser,style:{fontWeight:700},children:e.user||`Unknown`}),(0,O.jsx)(`span`,{className:mn.msgTs,style:{fontSize:11,opacity:.6},children:new Date(parseFloat(e.ts)*1e3).toLocaleString()}),e.reply_count?(0,O.jsxs)(`button`,{onClick:()=>ie(e),style:{background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`,fontSize:11},children:[`💬 `,e.reply_count,` `,e.reply_count===1?`reply`:`replies`]}):null]}),(0,O.jsx)(`div`,{className:mn.msgText,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:e.text}),e.files&&e.files.length>0&&(0,O.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginTop:2},children:e.files.map(e=>(0,O.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,style:{fontSize:11,padding:`2px 6px`,background:`rgba(99,102,241,0.1)`,borderRadius:4,color:`#6366f1`,textDecoration:`none`},children:[`📎 `,e.name]},e.id))}),e.reactions&&e.reactions.length>0&&(0,O.jsxs)(`div`,{style:{display:`flex`,gap:4,flexWrap:`wrap`,marginTop:2},children:[e.reactions.map((e,t)=>(0,O.jsxs)(`span`,{style:{fontSize:11,padding:`1px 6px`,background:`rgba(99,102,241,0.08)`,borderRadius:10},children:[`:`,e.name,`: `,e.count]},t)),(0,O.jsx)(`button`,{onClick:()=>oe(e,`thumbsup`),style:{background:`transparent`,border:`1px dashed rgba(148,163,184,0.3)`,borderRadius:10,fontSize:11,padding:`0 6px`,cursor:`pointer`},children:`+ 👍`})]})]},t);return(0,O.jsxs)(`div`,{className:mn.twoPane,children:[(0,O.jsxs)(`div`,{className:mn.sidebar,children:[(0,O.jsxs)(`div`,{className:mn.sidebarTitle,children:[(0,O.jsxs)(`span`,{children:[`💬 `,t?.workspace||`Slack`]}),(0,O.jsx)(`button`,{className:mn.disconnectBtn,onClick:ne,title:`Refresh`,children:`↻`})]}),(0,O.jsx)(`input`,{type:`text`,placeholder:`🔎 Filter channels...`,value:p,onChange:e=>m(e.target.value),style:{width:`100%`,padding:`6px 8px`,marginBottom:6,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontSize:12}}),(0,O.jsx)(`input`,{type:`text`,placeholder:`Search messages...`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()},style:{width:`100%`,padding:`6px 8px`,marginBottom:8,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontSize:12}}),v!==null&&(0,O.jsxs)(`div`,{style:{marginBottom:8},children:[(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,marginBottom:2},children:b?`Searching…`:`${v.length} result(s)`}),(0,O.jsx)(`button`,{onClick:()=>{y(null),g(``)},style:{fontSize:11,background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`,padding:0},children:`← back to channels`})]}),v===null&&(0,O.jsxs)(O.Fragment,{children:[ce.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Channels`}),ce.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:[`# `,e.name,(e.unread_count??0)>0&&(0,O.jsx)(`span`,{style:{float:`right`,background:`#ef4444`,color:`white`,borderRadius:8,padding:`0 6px`,fontSize:10},children:e.unread_count})]},e.id)),le.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Private`}),le.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:[`🔒 `,e.name]},e.id)),ue.length>0&&(0,O.jsx)(`div`,{style:{fontSize:10,color:`#94a3b8`,textTransform:`uppercase`,marginTop:8,marginBottom:2},children:`Direct Messages`}),ue.map(e=>(0,O.jsx)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>re(e),children:e.name},e.id))]})]}),(0,O.jsx)(`div`,{className:mn.messagePane,style:{display:`flex`,flexDirection:`column`,height:`100%`},children:v===null?a?S?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,style:{display:`flex`,justifyContent:`space-between`},children:[(0,O.jsxs)(`span`,{children:[`💬 Thread in #`,a.name]}),(0,O.jsx)(`button`,{onClick:()=>C(null),style:{background:`transparent`,border:`none`,color:`#6366f1`,cursor:`pointer`},children:`✕ Close thread`})]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[(0,O.jsx)(`div`,{style:{borderLeft:`3px solid #6366f1`,paddingLeft:8,marginBottom:8,opacity:.85},children:de(S.parent,-1)}),(0,O.jsxs)(`div`,{style:{fontSize:11,color:`#94a3b8`,textTransform:`uppercase`,margin:`8px 0 4px`},children:[S.replies.length,` `,S.replies.length===1?`reply`:`replies`]}),S.replies.map((e,t)=>de(e,t))]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,style:{display:`flex`,justifyContent:`space-between`},children:[(0,O.jsxs)(`span`,{children:[`#`,a.name,a.topic?(0,O.jsxs)(`span`,{style:{fontWeight:400,opacity:.6,marginLeft:8},children:[`— `,a.topic]}):null]}),(0,O.jsxs)(`label`,{style:{fontSize:11,opacity:.7},children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>ee(e.target.checked)}),` auto-refresh`]})]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[s.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No messages`}),s.map((e,t)=>de(e,t))]}),(0,O.jsxs)(`div`,{style:{borderTop:`1px solid rgba(148,163,184,0.2)`,padding:8,display:`flex`,gap:6},children:[(0,O.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&ae()},placeholder:`Message #${a.name} (Cmd/Ctrl+Enter to send)`,rows:2,style:{flex:1,padding:6,borderRadius:6,border:`1px solid rgba(148,163,184,0.2)`,background:`transparent`,color:`inherit`,fontFamily:`inherit`,resize:`vertical`}}),(0,O.jsx)(`button`,{onClick:ae,disabled:!l.trim()||d,className:mn.disconnectBtn,style:{minWidth:80},children:d?`Sending…`:`Send`})]})]}):(0,O.jsx)(`div`,{className:mn.emptyPane,children:`Select a channel from the left`}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:mn.channelHeader,children:[`🔎 Search results for "`,h,`"`]}),(0,O.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:8},children:[v.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No matches`}),v.map((e,t)=>(0,O.jsxs)(`div`,{className:mn.message,style:{marginBottom:6},children:[(0,O.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6},children:[(0,O.jsx)(`span`,{style:{fontWeight:700},children:e.user}),(0,O.jsxs)(`span`,{style:{fontSize:11,opacity:.6},children:[`in #`,e.channel]}),(0,O.jsx)(`span`,{style:{fontSize:11,opacity:.5},children:new Date(parseFloat(e.ts)*1e3).toLocaleString()}),e.permalink&&(0,O.jsx)(`a`,{href:e.permalink,target:`_blank`,rel:`noreferrer`,style:{fontSize:11,color:`#6366f1`},children:`↗ Slack`})]}),(0,O.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`,marginTop:2},children:e.text})]},t))]})]})})]})}function _n(){let e=A(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(e=``)=>{i(!0),T(e?`/api/notion/search?q=${encodeURIComponent(e)}`:`/api/notion`).then(e=>{n(e??{}),i(!1)}).catch(()=>i(!1))},f=e=>{o(e),T(`/api/notion/page?id=${encodeURIComponent(e.id)}`).then(e=>c(e?.content??``))};(0,_.useEffect)(()=>{d()},[]);let p=()=>d(l);if(r)return(0,O.jsxs)(`div`,{className:mn.loading,children:[(0,O.jsx)(`div`,{className:`spinner`}),e(`common.loading`)]});if(t?.error)return(0,O.jsxs)(`div`,{className:mn.errorBox,children:[(0,O.jsx)(`div`,{children:t.error}),(0,O.jsxs)(`div`,{className:mn.errorHint,children:[`Run: `,(0,O.jsx)(`code`,{children:`nha config set notion-token secret_YOUR_TOKEN`})]})]});let m=t?.pages??[];return(0,O.jsxs)(`div`,{className:mn.twoPane,children:[(0,O.jsxs)(`div`,{className:mn.sidebar,children:[(0,O.jsx)(`div`,{className:mn.sidebarTitle,children:`📋 Notion`}),(0,O.jsxs)(`div`,{className:mn.searchRow,children:[(0,O.jsx)(`input`,{className:mn.searchInput,value:l,onChange:e=>u(e.target.value),placeholder:`Search pages…`,onKeyDown:e=>e.key===`Enter`&&p()}),(0,O.jsx)(`button`,{className:mn.searchBtn,onClick:p,children:`Go`})]}),m.length===0&&(0,O.jsx)(`div`,{className:mn.empty,children:`No pages found`}),m.map(e=>(0,O.jsxs)(`div`,{className:`${mn.channelItem} ${a?.id===e.id?mn.channelActive:``}`,onClick:()=>f(e),children:[(0,O.jsx)(`div`,{className:mn.pageTitle,children:e.title||`Untitled`}),e.last_edited&&(0,O.jsx)(`div`,{className:mn.pageMeta,children:e.last_edited.slice(0,10)})]},e.id)),(0,O.jsx)(`button`,{className:mn.disconnectBtn,onClick:()=>E(`/api/config`,{key:`notion-token`,value:``}).then(()=>d()),children:`Disconnect`})]}),(0,O.jsx)(`div`,{className:mn.messagePane,children:a?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:mn.channelHeader,children:a.title}),a.url&&(0,O.jsx)(`a`,{className:mn.openLink,href:a.url,target:`_blank`,rel:`noreferrer`,children:`Open in Notion ↗`}),(0,O.jsx)(`div`,{className:mn.pageBody,dangerouslySetInnerHTML:{__html:Ce(s||`Loading…`)}})]}):(0,O.jsx)(`div`,{className:mn.emptyPane,children:`Select a page`})})]})}var vn={root:`_root_1l3ll_1`,sidebar:`_sidebar_1l3ll_8`,sidebarHeader:`_sidebarHeader_1l3ll_18`,sidebarTitle:`_sidebarTitle_1l3ll_19`,sidebarBtns:`_sidebarBtns_1l3ll_21`,createBtn:`_createBtn_1l3ll_22`,joinBtn:`_joinBtn_1l3ll_23`,noChannels:`_noChannels_1l3ll_25`,channelItem:`_channelItem_1l3ll_27`,channelActive:`_channelActive_1l3ll_29`,channelName:`_channelName_1l3ll_30`,channelMeta:`_channelMeta_1l3ll_31`,channelCode:`_channelCode_1l3ll_32`,channelDel:`_channelDel_1l3ll_34`,main:`_main_1l3ll_38`,chatHeader:`_chatHeader_1l3ll_41`,chatChannelName:`_chatChannelName_1l3ll_50`,chatChannelId:`_chatChannelId_1l3ll_51`,statusDot:`_statusDot_1l3ll_52`,connected:`_connected_1l3ll_53`,disconnected:`_disconnected_1l3ll_54`,statusText:`_statusText_1l3ll_55`,messages:`_messages_1l3ll_58`,emptyMsgs:`_emptyMsgs_1l3ll_66`,msg:`_msg_1l3ll_68`,msgSelf:`_msgSelf_1l3ll_69`,msgOther:`_msgOther_1l3ll_70`,msgSender:`_msgSender_1l3ll_71`,msgContent:`_msgContent_1l3ll_72`,msgTime:`_msgTime_1l3ll_82`,inputRow:`_inputRow_1l3ll_85`,textInput:`_textInput_1l3ll_86`,sendBtn:`_sendBtn_1l3ll_88`,welcome:`_welcome_1l3ll_92`,welcomeIcon:`_welcomeIcon_1l3ll_103`,welcomeTitle:`_welcomeTitle_1l3ll_104`,welcomeSub:`_welcomeSub_1l3ll_105`,welcomeBox:`_welcomeBox_1l3ll_106`,welcomeBoxTitle:`_welcomeBoxTitle_1l3ll_107`,welcomeStep:`_welcomeStep_1l3ll_108`,welcomeHint:`_welcomeHint_1l3ll_109`,cliCmd:`_cliCmd_1l3ll_110`};function yn(e){return e.content||e.plaintext||e.message||``}function bn(e){return e.senderName||e.senderFingerprint?.slice(0,8)||e.sender||`unknown`}function xn(){let e=A(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)([]),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d]=(0,_.useState)(()=>`nha-ui-${Math.random().toString(36).slice(2,8)}`),f=(0,_.useRef)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{T(`/api/collab/channels`).then(e=>{n(e?.channels??[])}).catch(()=>{})},[]),(0,_.useEffect)(()=>{if(r)return m(r),h(r),()=>{f.current?.close(),u(!1)}},[r]);let m=e=>{T(`/api/collab/messages?channelId=${e}`).then(e=>{e?.messages&&(o(e.messages),setTimeout(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},50))}).catch(()=>{})},h=e=>{f.current?.close();let t=window.location.protocol===`https:`?`wss:`:`ws:`,n=window.location.port===`3030`||window.location.port===`3031`?`3020`:window.location.port||`3020`,r=`${t}//${window.location.hostname}:${n}/ws/alexandria?channel=${e}&agentId=${encodeURIComponent(d)}`,i=new WebSocket(r);f.current=i,i.onopen=()=>u(!0),i.onclose=()=>u(!1),i.onmessage=e=>{try{let t=JSON.parse(e.data);if(!t)return;o(e=>[...e,{...t,id:t.id||Date.now().toString(),type:`message`}]),p.current&&(p.current.scrollTop=p.current.scrollHeight)}catch{}}},g=async()=>{let e=prompt(`Channel name:`);if(!e)return;let t=await E(`/api/collab/create`,{name:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error creating channel`);return}let r=t.id;await E(`/api/collab/channels`,{id:r,name:e,role:`creator`}).catch(()=>{});let a={id:r,name:e,role:`creator`};n(e=>[...e,a]),i(r),prompt(`Share this invite code with collaborators:`,r)},v=async()=>{let e=prompt(`Invite code:`);if(!e)return;let t=await E(`/api/collab/join`,{channelId:e}).catch(()=>null);if(!t||t.error){alert(t?.error||`Error joining channel`);return}let r=t.name||e.slice(0,8);await E(`/api/collab/channels`,{id:e,name:r,role:`member`}).catch(()=>{}),n(t=>[...t,{id:e,name:r,role:`member`}]),i(e)},y=async e=>{confirm(`Delete this channel? Messages will be lost.`)&&(E(`/api/collab/delete`,{channelId:e}).catch(()=>{}),n(t=>t.filter(t=>t.id!==e)),r===e&&(i(null),o([]),f.current?.close(),u(!1)))},b=async()=>{let e=s.trim();if(!e||!r)return;c(``);let t=await E(`/api/collab/send`,{channelId:r,message:e}).catch(()=>null);t?.error&&alert(t.error),l||m(r)},x=e=>{navigator.clipboard.writeText(e).catch(()=>{})};return(0,O.jsxs)(`div`,{className:vn.root,children:[(0,O.jsxs)(`div`,{className:vn.sidebar,children:[(0,O.jsx)(`div`,{className:vn.sidebarHeader,children:(0,O.jsx)(`div`,{className:vn.sidebarTitle,children:`Alexandria`})}),(0,O.jsxs)(`div`,{className:vn.sidebarBtns,children:[(0,O.jsx)(`button`,{className:vn.createBtn,onClick:g,children:`+ Create`}),(0,O.jsx)(`button`,{className:vn.joinBtn,onClick:v,children:`Join`})]}),t.length===0?(0,O.jsxs)(`div`,{className:vn.noChannels,children:[e(`collab.noChannels`),` yet`]}):t.map(e=>(0,O.jsxs)(`div`,{className:`${vn.channelItem} ${r===e.id?vn.channelActive:``}`,onClick:()=>i(e.id),children:[(0,O.jsx)(`div`,{className:vn.channelName,children:e.name}),(0,O.jsxs)(`div`,{className:vn.channelMeta,children:[(0,O.jsxs)(`span`,{className:vn.channelCode,onClick:t=>{t.stopPropagation(),x(e.id)},title:`Click to copy invite code`,children:[e.id.slice(0,8),`…`]}),(0,O.jsx)(`button`,{className:vn.channelDel,onClick:t=>{t.stopPropagation(),y(e.id)},children:`del`})]})]},e.id))]}),(0,O.jsx)(`div`,{className:vn.main,children:r?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:vn.chatHeader,children:[(0,O.jsx)(`div`,{className:vn.chatChannelName,children:t.find(e=>e.id===r)?.name??r.slice(0,12)}),(0,O.jsx)(`div`,{className:vn.chatChannelId,children:r}),(0,O.jsx)(`div`,{className:`${vn.statusDot} ${l?vn.connected:vn.disconnected}`}),(0,O.jsx)(`span`,{className:vn.statusText,children:l?`Live`:`HTTP`})]}),(0,O.jsxs)(`div`,{className:vn.messages,ref:p,children:[a.length===0&&(0,O.jsx)(`div`,{className:vn.emptyMsgs,children:`No messages yet`}),a.map((e,t)=>{let n=bn(e),r=yn(e),i=n===d;return(0,O.jsxs)(`div`,{className:`${vn.msg} ${i?vn.msgSelf:vn.msgOther}`,children:[!i&&(0,O.jsx)(`div`,{className:vn.msgSender,children:n}),(0,O.jsx)(`div`,{className:vn.msgContent,children:r}),(0,O.jsx)(`div`,{className:vn.msgTime,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id||t)})]}),(0,O.jsxs)(`div`,{className:vn.inputRow,children:[(0,O.jsx)(`input`,{className:vn.textInput,value:s,onChange:e=>c(e.target.value),placeholder:`Send an encrypted message…`,onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&b()}),(0,O.jsx)(`button`,{className:vn.sendBtn,onClick:b,disabled:!s.trim(),children:e(`collab.send`)})]})]}):(0,O.jsxs)(`div`,{className:vn.welcome,children:[(0,O.jsx)(`div`,{className:vn.welcomeIcon,children:`🔐`}),(0,O.jsx)(`div`,{className:vn.welcomeTitle,children:`Alexandria`}),(0,O.jsx)(`div`,{className:vn.welcomeSub,children:`E2E encrypted messaging for AI agents and teams`}),(0,O.jsxs)(`div`,{className:vn.welcomeBox,children:[(0,O.jsx)(`div`,{className:vn.welcomeBoxTitle,children:`HOW TO USE`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`1. Create a channel`}),` — Click [+ Create] in the sidebar. Give it a name.`]}),(0,O.jsx)(`div`,{className:vn.welcomeHint,children:`You get an invite code. Share it with your team or another AI session.`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`2. Others join`}),` — They click [Join] and paste the invite code.`]}),(0,O.jsx)(`div`,{className:vn.welcomeHint,children:`Works from this web UI, the Android app, or the CLI.`}),(0,O.jsxs)(`div`,{className:vn.welcomeStep,children:[(0,O.jsx)(`strong`,{children:`3. Chat encrypted`}),` — All messages are E2E encrypted. The server sees only ciphertext.`]})]}),(0,O.jsxs)(`div`,{className:vn.welcomeBox,children:[(0,O.jsx)(`div`,{className:vn.welcomeBoxTitle,children:`FROM CLI (same channels)`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab create "Project X"`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab join <invite-code>`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab send "Hello from CLI"`}),(0,O.jsx)(`div`,{className:vn.cliCmd,children:`nha collab read`})]})]})})]})}var Sn=[],Cn=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Cn:Sn).push(n+=e[t])})();function wn(e){if(e<768)return!1;for(let t=0,n=Sn.length;;){let r=t+n>>1;if(e<Sn[r])n=r;else if(e>=Cn[r])t=r+1;else return!0;if(t==n)return!1}}function Tn(e){return e>=127462&&e<=127487}var En=8205;function Dn(e,t,n=!0,r=!0){return(n?On:kn)(e,t,r)}function On(e,t,n){if(t==e.length)return t;t&&jn(e.charCodeAt(t))&&Mn(e.charCodeAt(t-1))&&t--;let r=An(e,t);for(t+=Nn(r);t<e.length;){let i=An(e,t);if(r==En||i==En||n&&wn(i))t+=Nn(i),r=i;else if(Tn(i)){let n=0,r=t-2;for(;r>=0&&Tn(An(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function kn(e,t,n){for(;t>0;){let r=On(e,t-2,n);if(r<t)return r;t--}return 0}function An(e,t){let n=e.charCodeAt(t);if(!Mn(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return jn(r)?(n-55296<<10)+(r-56320)+65536:n}function jn(e){return e>=56320&&e<57344}function Mn(e){return e>=55296&&e<56320}function Nn(e){return e<65536?1:2}var Pn=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Wn(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),In.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Wn(this,e,t);let n=[];return this.decompose(e,t,n,0),In.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Bn(this),i=new Bn(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Bn(this,e)}iterRange(e,t=this.length){return new Vn(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Hn(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Fn(t):In.from(Fn.split(t,[]))}},Fn=class e extends Pn{constructor(e,t=Ln(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Un(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(zn(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Rn(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Wn(this,t,n);let i=Rn(this.text,Rn(r.text,zn(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):In.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
661
661
|
`){[e,t]=Wn(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},In=class e extends Pn{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=Wn(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
662
662
|
`){[e,t]=Wn(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new Fn(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof Fn&&c&&(n=u[u.length-1])instanceof Fn&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new Fn(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};Pn.empty=new Fn([``],0);function Ln(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Rn(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function zn(e,t,n){return Rn(e,[``],t,n)}var Bn=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof Fn?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof Fn?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
663
663
|
`,this;e--}else if(r instanceof Fn){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Fn?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Vn=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new Bn(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},Hn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(Pn.prototype[Symbol.iterator]=function(){return this.iter()},Bn.prototype[Symbol.iterator]=Vn.prototype[Symbol.iterator]=Hn.prototype[Symbol.iterator]=function(){return this});var Un=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Wn(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Gn(e,t,n=!0,r=!0){return Dn(e,t,n,r)}function Kn(e){return e>=56320&&e<57344}function qn(e){return e>=55296&&e<56320}function Jn(e,t){let n=e.charCodeAt(t);if(!qn(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Kn(r)?(n-55296<<10)+(r-56320)+65536:n}function Yn(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Xn(e){return e<65536?1:2}var Zn=/\r\n?|\n/,Qn=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(Qn||={}),$n=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){rr(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:ar(this,e)}mapDesc(e,t=!1){return e.empty?this:ir(this,e,t)}mapPos(e,t=-1,n=Qn.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=Qn.Simple&&c>=e&&(n==Qn.TrackDel&&r<e&&c>e||n==Qn.TrackBefore&&r<e||n==Qn.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},er=class e extends $n{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return rr(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return ir(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(Pn.empty);r.push(a?t.slice(i,i+a):Pn.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:ar(this,e,!0)}map(e,t=!1){return e.empty?this:ir(this,e,t,!0)}iterChanges(e,t=!1){rr(this,e,t)}get desc(){return $n.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new or(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);tr(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;tr(n,e,t),t>0&&nr(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);tr(n,e,-1),tr(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:$n.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&tr(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?Pn.of(l.split(r||Zn)):l:Pn.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&tr(i,e-o,-1),tr(i,s-e,d),nr(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(Pn.empty);r[e]=Pn.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function tr(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function nr(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Pn.empty);e.push(n)}}function rr(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=Pn.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function ir(e,t,n,r=!1){let i=[],a=r?[]:null,o=new or(e),s=new or(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);tr(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(tr(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(tr(i,0,o.ins),a&&nr(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;tr(i,t,e<o.i?o.ins:0),a&&e<o.i&&nr(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?er.createSet(i,a):$n.create(i);else throw Error(`Mismatched change set lengths`)}function ar(e,t,n=!1){let r=[],i=n?[]:null,a=new or(e),o=new or(t);for(let e=!1;;)if(a.done&&o.done)return i?er.createSet(r,i):$n.create(r);else if(a.ins==0)tr(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)tr(r,0,o.ins,e),i&&nr(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;tr(r,t,n,e),i&&n&&nr(i,r,o.text)}else o.ins==-1?(tr(r,a.off?0:a.len,t,e),i&&nr(i,r,a.textBit(t))):(tr(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&nr(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var or=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Pn.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Pn.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},sr=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return K.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return K.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return K.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},K=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>sr.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return sr.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?sr.create(t,e,48|a):sr.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function cr(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var lr=0,q=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=lr++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:ur),!!t.static,t.enables)}of(e){return new dr([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new dr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new dr(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function ur(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var dr=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=lr++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||pr(e,c)){let r=t(e);if(a?!fr(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Er(o,c);if(this.dependencies.every(t=>t instanceof q?o.facet(t)===e.facet(t):t instanceof gr?o.field(t,!1)==e.field(t,!1):!0)||(a?fr(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function fr(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function pr(e,t){let n=!1;for(let r of t)Tr(e,r)&1&&(n=!0);return n}function mr(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Er(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Tr(e,t);return e.values[o]=s(e),1},update(e,n){if(!pr(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=pr(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&ur(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var hr=q.define({static:!0}),gr=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(lr++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(hr).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(hr),i=n.facet(hr),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,hr.of({field:this,create:e})]}get extension(){return this}},_r={lowest:4,low:3,default:2,high:1,highest:0};function vr(e){return t=>new br(t,e)}var yr={highest:vr(_r.highest),high:vr(_r.high),default:vr(_r.default),low:vr(_r.low),lowest:vr(_r.lowest)},br=class{constructor(e,t){this.inner=e,this.prec=t}},xr=class e{of(e){return new Sr(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Sr=class{constructor(e,t){this.compartment=e,this.inner=t}},Cr=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of wr(t,n,o))e instanceof gr?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,ur(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>mr(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function wr(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Sr&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Sr){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof br)a(e.inner,e.prec);else if(e instanceof gr)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof dr)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,_r.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,_r.default),r.reduce((e,t)=>e.concat(t))}function Tr(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Er(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Dr=q.define(),Or=q.define({combine:e=>e.some(e=>e),static:!0}),kr=q.define({combine:e=>e.length?e[0]:void 0,static:!0}),Ar=q.define(),jr=q.define(),Mr=q.define(),Nr=q.define({combine:e=>e.length?e[0]:!1}),Pr=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Fr}},Fr=class{of(e){return new Pr(this,e)}},Ir=class{constructor(e){this.map=e}of(e){return new Lr(this,e)}},Lr=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Ir(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};Lr.reconfigure=Lr.define(),Lr.appendConfig=Lr.define();var Rr=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&cr(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};Rr.time=Pr.define(),Rr.userEvent=Pr.define(),Rr.addToHistory=Pr.define(),Rr.remote=Pr.define();function zr(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Br(e,t,n){let r,i,a;return n?(r=t.changes,i=er.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:Lr.mapEffects(e.effects,r).concat(Lr.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Vr(e,t,n){let r=t.selection,i=Kr(t.annotations);return t.userEvent&&(i=i.concat(Rr.userEvent.of(t.userEvent))),{changes:t.changes instanceof er?t.changes:er.of(t.changes||[],n,e.facet(kr)),selection:r&&(r instanceof K?r:K.single(r.anchor,r.head)),effects:Kr(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Hr(e,t,n){let r=Vr(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=Br(r,Vr(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=Rr.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Wr(n?Ur(i):i)}function Ur(e){let t=e.startState,n=!0;for(let r of t.facet(Ar)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:zr(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=er.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Rr.create(t,r,e.selection&&e.selection.map(i),Lr.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(jr);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof Rr?i:Array.isArray(i)&&i.length==1&&i[0]instanceof Rr?i[0]:Hr(t,Kr(i),!1)}return e}function Wr(e){let t=e.startState,n=t.facet(Mr),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Br(r,Vr(t,a,e.changes.newLength),!0))}return r==e?e:Rr.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var Gr=[];function Kr(e){return e==null?Gr:Array.isArray(e)?e:[e]}var qr=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(qr||={}),Jr=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Yr;try{Yr=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function Xr(e){if(Yr)return Yr.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||Jr.test(n)))return!0}return!1}function Zr(e){return t=>{if(!/\S/.test(t))return qr.Space;if(Xr(t))return qr.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return qr.Word;return qr.Other}}var Qr=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Tr(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Tr(this,n),Er(this,n)}update(...e){return Hr(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(xr.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(Lr.reconfigure)?(n=null,r=e.value):e.is(Lr.appendConfig)&&(n=null,r=Kr(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Cr.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Or)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:K.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=Kr(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=Lr.mapEffects(a,c).concat(Lr.mapEffects(Kr(o.effects),l))}return{changes:r,selection:K.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof er?t:er.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return Pn.of(t.split(this.facet(e.lineSeparator)||Zn))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Tr(this,t),Er(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof gr&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:K.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Cr.resolve(t.extensions||[],new Map),r=t.doc instanceof Pn?t.doc:Pn.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||Zn)),i=t.selection?t.selection instanceof K?t.selection:K.single(t.selection.anchor,t.selection.head):K.single(0);return cr(i,r.length),n.staticFacet(Or)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
package/src/ui-dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
10
|
<title>NHA — NotHumanAllowed</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DLvIdPa_.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-DnJMrYkq.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|