@nextclaw/ui 0.12.26 → 0.12.28
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/CHANGELOG.md +74 -0
- package/dist/assets/{channels-list-page-HgLgrEg4.js → channels-list-page-DkPvpAqc.js} +1 -1
- package/dist/assets/{chat-page-DAKMFDrS.js → chat-page-b7Zf32fF.js} +1 -1
- package/dist/assets/index-DmWo8dX2.css +1 -0
- package/dist/assets/{index-Cuwst6cc.js → index-DqJ3CYwi.js} +2 -2
- package/dist/assets/marketplace-page-BVqFjnEB.js +105 -0
- package/dist/assets/marketplace-page-DkQ2hTs1.js +1 -0
- package/dist/assets/{mcp-marketplace-page-DwnaLNTx.js → mcp-marketplace-page-BOYJO0kp.js} +1 -1
- package/dist/assets/mcp-marketplace-page-DSML7NN0.js +1 -0
- package/dist/assets/{model-config-L2l6YAlQ.js → model-config-Bg2yycmn.js} +1 -1
- package/dist/assets/{providers-list-DYAEunOp.js → providers-list-DC1q3fvC.js} +1 -1
- package/dist/assets/{runtime-config-page-BdeU8PEK.js → runtime-config-page-q-nC0C5i.js} +1 -1
- package/dist/assets/{search-config-CQUhd5RU.js → search-config-CcKHif8O.js} +1 -1
- package/dist/assets/{secrets-config-D-NWlW9q.js → secrets-config-DSg6O92a.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-CFVdPpNv.js → use-infinite-scroll-loader-DF2e6nQ2.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +9 -9
- package/src/features/marketplace/components/curated-shelves/marketplace-curated-scene-route.test.tsx +54 -16
- package/src/features/marketplace/components/curated-shelves/marketplace-curated-shelves.tsx +96 -24
- package/src/features/marketplace/components/marketplace-page.test.tsx +4 -0
- package/src/features/marketplace/components/marketplace-page.tsx +16 -12
- package/src/features/marketplace/hooks/use-marketplace-curated-scene-route.ts +14 -5
- package/dist/assets/index-dlcqieQ0.css +0 -1
- package/dist/assets/marketplace-page-BeFbwxR-.js +0 -105
- package/dist/assets/marketplace-page-CR4xq-TM.js +0 -1
- package/dist/assets/mcp-marketplace-page-DlRrSCj3.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-p9DDNPWB.js","assets/doc-browser-rZIQIjuw.js","assets/i18n-D1144VAA.js","assets/createLucideIcon-DzY6wN61.js","assets/search-CRtQwr-h.js","assets/book-open-BcnAiKde.js","assets/external-link-CpEvG65F.js","assets/plus-B-YHtTNC.js","assets/x-BeyYA_h6.js","assets/doc-browser-context-FukQHvyo.js","assets/model-config-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-p9DDNPWB.js","assets/doc-browser-rZIQIjuw.js","assets/i18n-D1144VAA.js","assets/createLucideIcon-DzY6wN61.js","assets/search-CRtQwr-h.js","assets/book-open-BcnAiKde.js","assets/external-link-CpEvG65F.js","assets/plus-B-YHtTNC.js","assets/x-BeyYA_h6.js","assets/doc-browser-context-FukQHvyo.js","assets/model-config-Bg2yycmn.js","assets/api-DGD9_Bg4.js","assets/provider-scoped-model-input-BMTp4BEH.js","assets/select-BUTwE_lC.js","assets/es2015-BhznEEyJ.js","assets/sparkles-BmgOD4nY.js","assets/use-config-Cyv5IuSt.js","assets/config-hints-BNfpOL4J.js","assets/chat-page-b7Zf32fF.js","assets/cpu-DPPwMzoC.js","assets/dialog-BKo0RItd.js","assets/dist-CFiwgaLs.js","assets/popover-BDFNiLlg.js","assets/marketplace-page-BVqFjnEB.js","assets/use-infinite-scroll-loader-DF2e6nQ2.js","assets/download-CMM8po31.js","assets/doc-browser-CAhfnm0D.js","assets/tabs-custom-D48zdZoc.js","assets/desktop-DVUbOWbR.js","assets/key-round-DUq47t0P.js","assets/app-manager-provider-oYdeYPSv.js","assets/notice-card-Dr6xCwva.js","assets/status-dot-l3kPFdq_.js","assets/settings-MWL2SMyk.js","assets/refresh-cw-CrbD8EkT.js","assets/mcp-marketplace-page-BOYJO0kp.js","assets/tag-chip-Dm2Lqnpu.js","assets/play-AqrNslHI.js","assets/search-config-CcKHif8O.js","assets/config-split-page-CcrEUtwu.js","assets/providers-list-DC1q3fvC.js","assets/setting-row-BavcnXw1.js","assets/channels-list-page-DkPvpAqc.js","assets/runtime-config-page-q-nC0C5i.js","assets/rotate-cw-BN9yjccP.js","assets/save-CO_4qf6b.js","assets/desktop-update-config-CP8dFYXK.js","assets/secrets-config-DSg6O92a.js","assets/remote-Dr3jcfWP.js","assets/marketplace-page-DkQ2hTs1.js","assets/mcp-marketplace-page-DSML7NN0.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,o as c,p as l,r as u,t as d,u as f}from"./i18n-D1144VAA.js";import{Ct as p,Ft as m,H as h,It as g,Lt as _,Mt as v,Nt as y,Pt as b,Rt as x,St as S,Xt as C,Yt as w,_t as T,at as E,bt as D,d as O,f as ee,h as k,it as te,jt as A,lt as ne,m as j,n as re,on as ie,ot as ae,p as oe,pt as se,rt as ce,st as le,t as ue,ut as de,v as fe,vt as pe,y as me,yt as he,zt as ge}from"./api-DGD9_Bg4.js";import{a as _e,c as ve,d as ye,i as be,l as xe,n as Se,o as Ce,r as we,s as Te}from"./cpu-DPPwMzoC.js";import{_ as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,o as Ne,u as Pe}from"./es2015-BhznEEyJ.js";import{t as Fe}from"./dist-CFiwgaLs.js";import{a as Ie,i as Le,n as Re,o as ze,r as Be,t as Ve}from"./dialog-BKo0RItd.js";import{t as M}from"./createLucideIcon-DzY6wN61.js";import{C as He,D as Ue,E as We,O as Ge,S as Ke,T as qe,_ as Je,a as Ye,c as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,m as nt,n as rt,o as it,p as at,r as ot,s as st,t as ct,u as lt,v as ut,w as dt,y as ft}from"./desktop-DVUbOWbR.js";import{n as pt,t as mt}from"./search-CRtQwr-h.js";import{t as ht}from"./book-open-BcnAiKde.js";import{C as gt,D as _t,E as vt,O as yt,S as bt,T as xt,_ as St,b as Ct,c as wt,d as Tt,f as Et,g as Dt,h as Ot,i as kt,k as At,l as jt,m as Mt,n as Nt,o as Pt,p as Ft,r as It,s as Lt,t as Rt,u as zt,v as Bt,w as Vt,x as Ht,y as Ut}from"./select-BUTwE_lC.js";import{t as Wt}from"./external-link-CpEvG65F.js";import{g as Gt,i as Kt,r as qt,t as Jt}from"./app-manager-provider-oYdeYPSv.js";import{t as Yt}from"./settings-MWL2SMyk.js";import{t as Xt}from"./plus-B-YHtTNC.js";import{t as Zt}from"./sparkles-BmgOD4nY.js";import{t as Qt}from"./x-BeyYA_h6.js";import{i as $t,n as en}from"./doc-browser-context-FukQHvyo.js";import{n as tn,r as nn,t as rn}from"./doc-browser-CAhfnm0D.js";import{f as an,o as on,s as sn}from"./use-config-Cyv5IuSt.js";import{a as cn,c as ln,i as un,n as dn,o as fn,r as pn,s as mn,t as hn}from"./popover-BDFNiLlg.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var gn=a((e=>{var t=ie();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),_n=M(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),vn=M(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),yn=M(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),bn=M(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),xn=M(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Sn=M(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Cn=M(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),wn=M(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Tn=M(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),En=M(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Dn=M(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),On=M(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),kn=M(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),An=M(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),jn=M(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Mn=M(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Nn=M(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Pn=M(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Fn=M(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),In=M(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),Ln=M(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Rn=M(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),zn=M(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Bn=M(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Vn=M(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),Hn=M(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Un=M(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),Wn=M(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Gn=M(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),Kn=M(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),qn=M(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Jn=M(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Yn=M(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Xn=M(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Zn=M(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),N=e(s(),1),Qn=gn();function $n(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function er(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:$n(e),width:e}}var tr=D(()=>er()),nr=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>tr.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),tr.setState(er())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;tr.setState({width:e,mode:$n(e)})}}};function rr(){(0,N.useEffect)(()=>nr.attach(),[]);let e=tr(e=>e.mode);return{mode:e,isMobile:e===`mobile`,isDesktop:e===`desktop`}}var P=l();function ir(e,t){if(t===`/settings`)return ut(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function ar(){let{pathname:e}=ve(),t=nt(u);return(0,P.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":u(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,P.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=ir(e,t.target);return(0,P.jsx)(`li`,{children:(0,P.jsx)(we,{to:t.target,"aria-current":n?`page`:void 0,className:f(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,P.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:f(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,P.jsx)(t.icon,{className:f(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,P.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function or(){let e=xe(),{pathname:t}=ve(),n=ft(t,u);return(0,P.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,P.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 px-3 py-1.5`,children:[n.backTarget?(0,P.jsx)(`button`,{type:`button`,onClick:()=>e(n.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":n.backLabel??u(`backToMain`),children:(0,P.jsx)(pt,{className:`h-4 w-4`})}):null,(0,P.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,P.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:n.title})}),n.backTarget?(0,P.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var sr=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{DocBrowser:e}=await import(`./doc-browser-p9DDNPWB.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function cr({pathname:e,isDocBrowserOpen:t,children:n}){let r=Je(e),i=!$e(e),a=!$e(e);return(0,P.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[i?(0,P.jsx)(or,{}):null,(0,P.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:r?(0,P.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:n}):(0,P.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,P.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:n})})}),a?(0,P.jsx)(ar,{}):null,t?(0,P.jsx)(N.Suspense,{fallback:null,children:(0,P.jsx)(sr,{displayMode:`fullscreen`})}):null]})}function lr(){let e=et(u);return(0,P.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,P.jsxs)(be,{to:e.target,className:({isActive:e})=>f(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,P.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,P.jsx)(e.icon,{className:`h-4 w-4`})}),(0,P.jsx)(`div`,{className:`min-w-0`,children:(0,P.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function ur({isProjectFirstView:e,onSelectMode:t}){return(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,P.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:f(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:u(`chatSidebarViewTime`)}),(0,P.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,P.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:f(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:u(`chatSidebarViewProject`)})]})}var dr={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,mochat:`mochat.svg`,email:`email.svg`};function fr(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function pr(e){return fr(dr,e)}var mr={wx:`weixin`,lark:`feishu`},hr={cron:{icon:`cron`}},gr={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function _r(e){return e?.trim().toLowerCase()??``}function vr(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function yr(e,t){let n=_r(e);if(!n||n===`native`)return null;let r=t.find(e=>_r(e.value)===n);return r?.label.trim()?r.label.trim():vr(n)}function br(e,t){let n=_r(e);return!n||n===`native`?null:t.find(e=>_r(e.value)===n)??null}function xr(e){let t=_r(e);if(!t)return null;let n=mr[t]??t;return pr(n)?n:null}function Sr(e,t){let n=xr(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=hr[_r(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=_r(e.sessionType),a=br(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=gr[i];return o?{icon:null,label:u(o)}:{icon:null,label:a?.label?.trim()||yr(e.sessionType,t)}}var Cr=`app://`;function wr(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Tr(e){let t=e.trim();if(!t)return null;if(!t.startsWith(Cr))return t;let n=wr(t.slice(6));return n?`/${n}`:null}function Er({name:e,src:t,className:n,imgClassName:r,fallback:i}){let[a,o]=(0,N.useState)(!1),s=!!t&&!a;return(0,P.jsx)(`div`,{className:f(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:s?(0,P.jsx)(`img`,{src:t,alt:`${e} logo`,className:f(`block h-6 w-6 object-contain`,r),onError:()=>o(!0),draggable:!1}):i??(0,P.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Dr({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,P.jsx)(Or,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Tr(e.src);return(0,P.jsx)(Er,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:f(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,P.jsx)(Ue,{className:f(`h-3 w-3 text-gray-500`,t)})})}return(0,P.jsx)(Ge,{className:f(`h-3.5 w-3.5`,t)})}function Or({channel:e,className:t}){return(0,P.jsx)(Er,{name:e,src:pr(e),className:f(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,P.jsx)(Ue,{className:`h-3 w-3 text-gray-500`})})}function kr(e){let{option:t,onSelect:n}=e,r=t.ready===!1?t.reasonMessage?.trim()||u(`statusSetup`):null;return(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,P.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,P.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,P.jsx)(Dr,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,P.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,P.jsx)(Ue,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,P.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,P.jsxs)(`span`,{className:f(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,P.jsx)(`span`,{className:f(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?u(`statusSetup`):u(`statusReady`)]})]}),r?(0,P.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:r}):null]})]})})})}function Ar(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function jr(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,s]=(0,N.useState)(null),c=(0,N.useMemo)(()=>Ar(n,r),[n,r]),l=r.length>1;return(0,P.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${u(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,P.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,P.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),l?(0,P.jsxs)(hn,{open:o===e.projectRoot,onOpenChange:t=>{s(t?e.projectRoot:null)},children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,P.jsx)(Xt,{className:`h-3.5 w-3.5`})})}),(0,P.jsxs)(dn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,P.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:u(`chatSessionTypeLabel`)}),(0,P.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,P.jsx)(kr,{option:t,onSelect:()=>{a(t.value,e.projectRoot),s(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,P.jsx)(y,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(c,e.projectRoot),"aria-label":t,title:t,children:(0,P.jsx)(Xt,{className:`h-3.5 w-3.5`})})]}),(0,P.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var Mr=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Nr(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Pr({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=Mr[Nr(e)%Mr.length]??Mr[0];return n?.trim()?(0,P.jsx)(`img`,{src:n,alt:t?.trim()||e,className:f(`rounded-full object-cover`,r)}):(0,P.jsx)(`div`,{className:f(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,P.jsx)(Ue,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(i.trim()||`A`).slice(0,1).toUpperCase()})}function Fr({status:e,className:t}){let n=u(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,P.jsxs)(`span`,{className:f(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,P.jsx)(Hn,{className:`h-3 w-3 animate-spin`}),(0,P.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ir(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function Lr(e){let t=e.activityPreview;return t?t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null:null}function Rr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function zr(e,t){return e.getFullYear()===t.getFullYear()}function Br(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return zr(e,t)?n:`${e.getFullYear()}年${n}`}function Vr(e,n=t(),r=new Date){if(!e)return`-`;let i=e instanceof Date?e:new Date(e);if(Number.isNaN(i.getTime()))return typeof e==`string`?e:`-`;let a=c(n),o=Rr(i),s=Rr(r),l=Math.floor((s-o)/864e5);if(l===0)return new Intl.DateTimeFormat(a,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(i);if(l===1)return u(`chatSidebarYesterday`,n);if(l>1&&l<7)return new Intl.DateTimeFormat(a,{weekday:`long`}).format(i);if(n===`zh`)return Br(i,r);let d=zr(i,r)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(a,d).format(i)}function Hr(e){return e.trim().toLowerCase()}function Ur(e,t){let n=Hr(t);return n?[e.key,Ir(e),e.projectRoot??``,e.projectName??``].map(Hr).some(e=>e.includes(n)):!0}function Wr({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(v,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:u(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(y,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":u(`save`),children:(0,P.jsx)(At,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(y,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":u(`cancel`),children:(0,P.jsx)(Qt,{className:`h-3.5 w-3.5`})})]})]})]})}function Gr({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l=0,onSelect:d,onOpenChildSessions:p,onStartEditing:m}){let h=l>0&&p?`pr-14`:`pr-6`,g=Lr(e),_=`${s?.trim()?`${s} · `:``}${e.messageCount}`;return(0,P.jsxs)(`div`,{className:`group/session relative`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:d,className:`w-full text-left`,children:[(0,P.jsx)(`div`,{className:f(`flex min-w-0 items-start`,h),children:(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[o?.trim()&&o.trim().toLowerCase()!==`main`?(0,P.jsx)(Pr,{agentId:o,displayName:s,avatarUrl:c,className:`h-5 w-5 shrink-0`}):null,(0,P.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,P.jsx)(`span`,{className:f(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:i.label}):null,i.icon?(0,P.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,P.jsx)(Dr,{icon:i.icon,className:t?`text-gray-700`:`text-gray-500`})}):null]})}),(0,P.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,P.jsx)(`span`,{className:`min-w-0 truncate`,children:g??_}),n?(0,P.jsx)(`span`,{"aria-label":u(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,P.jsx)(`span`,{className:`ml-auto shrink-0`,children:Vr(e.lastMessageAt??e.createdAt)})]})]}),l>0&&p?(0,P.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:f(`absolute right-6 top-0 inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":u(`chatSessionOpenChildSessions`),title:u(`chatSessionOpenChildSessions`),children:[(0,P.jsx)(zn,{className:`h-3.5 w-3.5`}),(0,P.jsx)(`span`,{children:l})]}):null,r?(0,P.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,P.jsx)(Fr,{status:r})}):null,(0,P.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:f(`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-md text-gray-400 transition-all hover:bg-white hover:text-gray-900`,`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":u(`edit`),children:(0,P.jsx)(Kn,{className:`h-3 w-3`})})]})}function Kr({session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,childSessionCount:l,isEditing:u,draftLabel:d,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,P.jsx)(`div`,{className:f(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:u?(0,P.jsx)(Wr,{session:e,draftLabel:d,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,P.jsx)(Gr,{session:e,active:t,showUnreadDot:n,runStatus:r,context:i,title:a,agentId:o,agentLabel:s,agentAvatarUrl:c,onSelect:m,childSessionCount:l,onOpenChildSessions:h,onStartEditing:g})})}var qr=[{icon:dt,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:We,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:Ge,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function Jr({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,P.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,P.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,P.jsx)(Ue,{className:`h-8 w-8 text-primary`})}),(0,P.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:u(`chatWelcomeTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:u(`chatWelcomeSubtitle`)}),(0,P.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,P.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:u(`chatDraftAgentTitle`)}),(0,P.jsxs)(Rt,{value:n,onValueChange:r,children:[(0,P.jsxs)(kt,{"aria-label":u(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,P.jsx)(`span`,{className:`sr-only`,children:u(`chatDraftAgentTitle`)}),(0,P.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,P.jsx)(Pr,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,P.jsx)(Nt,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,P.jsx)(It,{value:e.id,className:`rounded-lg pr-10`,children:(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(Pr,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,P.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,P.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:qr.map(t=>{let n=t.icon;return(0,P.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,P.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,P.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,P.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:u(t.titleKey)}),(0,P.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:u(t.descKey)})]},t.titleKey)})})]})})}var Yr=(0,N.createContext)(null);function Xr({presenter:e,children:t}){return(0,P.jsx)(Yr.Provider,{value:e,children:t})}function Zr(){let e=(0,N.useContext)(Yr);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var Qr=e=>`[data-item-index="${e}"]`;function $r(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??Qr;(0,N.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function ei(){let e=(0,N.useRef)(null),[t,n]=(0,N.useState)(null);return(0,N.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function F(...e){return n(r(e))}var ti=N.forwardRef(({className:e,type:t,...n},r)=>(0,P.jsx)(`input`,{type:t,className:F(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));ti.displayName=`ChatInput`;var ni=mn,ri=ln,ii=un,ai=N.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,P.jsx)(fn,{children:(0,P.jsx)(cn,{ref:i,sideOffset:t,align:n,className:F(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));ai.displayName=cn.displayName;var oi=Mt,si=Lt,ci=Ut,li=N.forwardRef(({className:e,children:t,...n},r)=>(0,P.jsxs)(Bt,{ref:r,className:F(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,P.jsx)(wt,{asChild:!0,children:(0,P.jsx)(yt,{className:`h-4 w-4 opacity-50`})})]}));li.displayName=Bt.displayName;var ui=N.forwardRef(({className:e,...t},n)=>(0,P.jsx)(Dt,{ref:n,className:F(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,P.jsx)(_t,{className:`h-4 w-4`})}));ui.displayName=Dt.displayName;var di=N.forwardRef(({className:e,...t},n)=>(0,P.jsx)(Ot,{ref:n,className:F(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,P.jsx)(yt,{className:`h-4 w-4`})}));di.displayName=Ot.displayName;var fi=N.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,P.jsx)(Ft,{children:(0,P.jsxs)(Pt,{ref:i,className:F(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,P.jsx)(ui,{}),(0,P.jsx)(Ct,{className:F(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,P.jsx)(di,{})]})}));fi.displayName=Pt.displayName;var pi=N.forwardRef(({className:e,...t},n)=>(0,P.jsx)(Et,{ref:n,className:F(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));pi.displayName=Et.displayName;var mi=N.forwardRef(({className:e,children:t,...n},r)=>(0,P.jsxs)(jt,{ref:r,className:F(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,P.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,P.jsx)(zt,{children:(0,P.jsx)(At,{className:`h-4 w-4`})})}),(0,P.jsx)(Tt,{children:t})]}));mi.displayName=jt.displayName;var hi=N.forwardRef(({className:e,...t},n)=>(0,P.jsx)(St,{ref:n,className:F(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));hi.displayName=St.displayName;var[gi,_i]=je(`Tooltip`,[vt]),vi=vt(),yi=`TooltipProvider`,bi=700,xi=`tooltip.open`,[Si,Ci]=gi(yi),wi=e=>{let{__scopeTooltip:t,delayDuration:n=bi,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=N.useRef(!0),s=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,P.jsx)(Si,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};wi.displayName=yi;var Ti=`Tooltip`,[Ei,Di]=gi(Ti),Oi=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Ci(Ti,e.__scopeTooltip),l=vi(t),[u,d]=N.useState(null),f=ke(),p=N.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=N.useRef(!1),[_,v]=Oe({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(xi))):c.onClose(),a?.(e)},caller:Ti}),y=N.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=N.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=N.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=N.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return N.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,P.jsx)(xt,{...l,children:(0,P.jsx)(Ei,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:N.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Oi.displayName=Ti;var ki=`TooltipTrigger`,Ai=N.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Di(ki,n),a=Ci(ki,n),o=vi(n),s=Ae(t,N.useRef(null),i.onTriggerChange),c=N.useRef(!1),l=N.useRef(!1),u=N.useCallback(()=>c.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,P.jsx)(bt,{asChild:!0,...o,children:(0,P.jsx)(De.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Ee(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Ee(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Ee(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Ee(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ee(e.onBlur,i.onClose),onClick:Ee(e.onClick,i.onClose)})})});Ai.displayName=ki;var ji=`TooltipPortal`,[Mi,Ni]=gi(ji,{forceMount:void 0}),Pi=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Di(ji,t);return(0,P.jsx)(Mi,{scope:t,forceMount:n,children:(0,P.jsx)(Fe,{present:n||a.open,children:(0,P.jsx)(Me,{asChild:!0,container:i,children:r})})})};Pi.displayName=ji;var Fi=`TooltipContent`,Ii=N.forwardRef((e,t)=>{let n=Ni(Fi,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Di(Fi,e.__scopeTooltip);return(0,P.jsx)(Fe,{present:r||o.open,children:o.disableHoverableContent?(0,P.jsx)(Vi,{side:i,...a,ref:t}):(0,P.jsx)(Li,{side:i,...a,ref:t})})}),Li=N.forwardRef((e,t)=>{let n=Di(Fi,e.__scopeTooltip),r=Ci(Fi,e.__scopeTooltip),i=N.useRef(null),a=Ae(t,i),[o,s]=N.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=N.useCallback(()=>{s(null),d(!1)},[d]),p=N.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Gi(r,Wi(r,n.getBoundingClientRect())),a=Ki(t.getBoundingClientRect());s(Ji([...i,...a])),d(!0)},[d]);return N.useEffect(()=>()=>f(),[f]),N.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),N.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!qi(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,P.jsx)(Vi,{...e,ref:a})}),[Ri,zi]=gi(Ti,{isInside:!1}),Bi=Pe(`TooltipContent`),Vi=N.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Di(Fi,n),l=vi(n),{onClose:u}=c;return N.useEffect(()=>(document.addEventListener(xi,u),()=>document.removeEventListener(xi,u)),[u]),N.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,P.jsx)(Ne,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,P.jsxs)(Vt,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,P.jsx)(Bi,{children:r}),(0,P.jsx)(Ri,{scope:n,isInside:!0,children:(0,P.jsx)(Ht,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Ii.displayName=Fi;var Hi=`TooltipArrow`,Ui=N.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=vi(n);return zi(Hi,n).isInside?null:(0,P.jsx)(gt,{...i,...r,ref:t})});Ui.displayName=Hi;function Wi(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Gi(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Ki(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function qi(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ji(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Yi(t)}function Yi(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Xi=wi,Zi=Oi,Qi=Ai,$i=Pi,ea=Ii,ta=Xi,na=Zi,ra=Qi,ia=N.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,P.jsx)($i,{children:(0,P.jsx)(ea,{ref:r,sideOffset:t,className:F(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));ia.displayName=ea.displayName;var aa={Popover:ni,PopoverAnchor:ii,PopoverContent:ai,PopoverTrigger:ri,Input:ti,Select:oi,SelectContent:fi,SelectGroup:si,SelectItem:mi,SelectLabel:pi,SelectSeparator:hi,SelectTrigger:li,SelectValue:ci,Tooltip:na,TooltipContent:ia,TooltipProvider:ta,TooltipTrigger:ra},oa=680,sa=.82,ca=560;function la(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=aa,{elementRef:i,width:a}=ei(),o=(0,N.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onDetailsPointerDown:h,onSetActiveIndex:g}=e,_=(0,N.useMemo)(()=>{if(a)return Math.min(a>ca?a*sa:a,oa)},[a]);return $r({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,P.jsxs)(t,{open:s,onOpenChange:m,children:[(0,P.jsx)(n,{asChild:!0,children:(0,P.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,P.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:_?{width:`${_}px`}:void 0,children:(0,P.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,P.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,P.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,P.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,P.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,P.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>g(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,P.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,P.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,P.jsx)(`div`,{className:`min-w-0 p-2.5`,onPointerDown:h,children:d?(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,P.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,P.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,P.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,P.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,P.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,P.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var ua=b(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),da=N.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,P.jsx)(`button`,{className:F(ua({variant:t,size:n,className:e})),ref:i,...r}));da.displayName=`ChatButton`;var fa=120;function pa(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=fa?t:`${t.slice(0,fa-1)}…`}function ma(){return(0,P.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function ha({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=aa,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,P.jsx)(r,{delayDuration:0,children:(0,P.jsxs)(t,{children:[(0,P.jsx)(i,{asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":e.label,title:e.label,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(#9ca3af ${o}deg, #e5e7eb 0deg)`}}),(0,P.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-white`})]})}),(0,P.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,P.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-gray-800`,children:[(0,P.jsx)(`span`,{children:e.label}),(0,P.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-gray-600`,children:[(0,P.jsx)(`span`,{children:e.label}),(0,P.jsx)(`span`,{className:`font-medium text-gray-800`,children:e.value})]},e.label))]})})]})})}function ga({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=aa,y=e?.trim()??``,b=y?pa(y):``,x=t?.trim()||`Details`;return(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,P.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,P.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,P.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,P.jsxs)(f,{children:[(0,P.jsx)(m,{asChild:!0,children:(0,P.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,P.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,P.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,P.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,P.jsx)(ha,{contextWindow:l}):null,n?r?(0,P.jsx)(da,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,P.jsx)(ma,{})}):(0,P.jsx)(_,{children:(0,P.jsxs)(h,{children:[(0,P.jsx)(v,{asChild:!0,children:(0,P.jsx)(`span`,{children:(0,P.jsx)(da,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,P.jsx)(ma,{})})})}),(0,P.jsx)(g,{side:`top`,children:(0,P.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,P.jsx)(da,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,P.jsx)(vn,{className:`h-5 w-5`})})]})]})}function _a(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function va(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=aa,{picker:a}=e,o=(0,N.useRef)(null),s=(0,N.useId)(),[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(0),f=(0,N.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,N.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,N.useMemo)(()=>h?h.flatMap(e=>e.options):_a(a.options,c),[h,a.options,c]);(0,N.useEffect)(()=>{d(0)},[c]),(0,N.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),$r({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,P.jsxs)(n,{children:[(0,P.jsx)(i,{asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,P.jsx)(We,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{className:`hidden sm:inline`,children:a.title}),p>0?(0,P.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,P.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,P.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,P.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(mt,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,P.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,P.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,P.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,P.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,P.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,P.jsxs)(`div`,{children:[e.label?(0,P.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,P.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,P.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,P.jsx)(qn,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,P.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,P.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,P.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,P.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,P.jsx)(At,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,P.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,P.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,P.jsx)(Wt,{className:`h-3 w-3`})]})}):null]})]})}function ya({icon:e}){return e===`sparkles`?(0,P.jsx)(Zt,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,P.jsx)(yn,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function ba({icon:e}){return e===`paperclip`?(0,P.jsx)(Gn,{className:`h-4 w-4`}):(0,P.jsx)(ya,{icon:e})}var xa={model:`min-w-0 flex-1 sm:min-w-[220px] sm:flex-none`,"session-type":`shrink-0`,thinking:`shrink-0`},Sa={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Ca(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function wa({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=aa,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0),d=Ca(e);return(0,P.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,P.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 ${xa[e.key]??``}`,children:e.selectedLabel?(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,P.jsx)(ya,{icon:e.icon}),(0,P.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700 sm:hidden`,children:d}),(0,P.jsx)(`span`,{className:`hidden truncate text-xs font-semibold text-gray-700 sm:inline`,children:e.selectedLabel})]}):e.loading?(0,P.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,P.jsx)(c,{placeholder:e.placeholder})}),(0,P.jsxs)(n,{className:Sa[e.key]??``,children:[u?null:e.loading?(0,P.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,P.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,P.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,P.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,P.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,P.jsxs)(`div`,{children:[t>0?(0,P.jsx)(o,{}):null,(0,P.jsxs)(r,{children:[e.label?(0,P.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,P.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,P.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,P.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,P.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function Ta({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=aa;return(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 pb-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[r?(0,P.jsx)(va,{picker:r}):null,n.map(e=>(0,P.jsx)(wa,{item:e},e.key)),t?.map(e=>{let t=(0,P.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,P.jsx)(ba,{icon:e.icon}),e.iconOnly?null:(0,P.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,P.jsx)(o,{children:(0,P.jsxs)(i,{children:[(0,P.jsx)(s,{asChild:!0,children:e.disabled?(0,P.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,P.jsx)(a,{side:`top`,children:(0,P.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,P.jsx)(`div`,{children:t},e.key)})]}),(0,P.jsx)(ga,{...e})]})}var Ea=(0,N.createContext)(null);function Da(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Oa(){let e=(0,N.useContext)(Ea);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function I(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ka(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Aa=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,ja=Aa&&`documentMode`in document?document.documentMode:null,Ma=Aa&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Na=Aa&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Pa=!(!Aa||!(`InputEvent`in window)||ja)&&`getTargetRanges`in new window.InputEvent(`input`),Fa=Aa&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ia=Aa&&/Android/.test(navigator.userAgent),La=Aa&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Ia,Ra=Aa&&/^(?=.*Chrome).*/i.test(navigator.userAgent),za=Aa&&Ia&&Ra,Ba=Aa&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ma&&!Ra,Va=0,Ha=1,Ua=2,Wa=1,Ga=2,Ka=3,qa=4,Ja=5,Ya=6,Xa=La||Fa||Ba?`\xA0`:``,Za=`
|
|
3
3
|
|
|
4
4
|
`,Qa=Na?`\xA0`:Xa,$a={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},eo={directionless:1,unmergeable:2},to={center:2,end:6,justify:4,left:1,right:3,start:5},no={[Ga]:`center`,[Ya]:`end`,[qa]:`justify`,[Wa]:`left`,[Ka]:`right`,[Ja]:`start`},ro={normal:0,segmented:2,token:1},io={[Va]:`normal`,[Ua]:`segmented`,[Ha]:`token`},ao=`$config`;function oo(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(V(o)&&oo(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var so=!1,co=0;function lo(e){co=e.timeStamp}function uo(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&cd(e,n)!==void 0}function fo(e,t,n){let r=Xd(Hd(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&xd(t,o,i,a,!1)}function po(e,t,n){if(z(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return Zu(t)&&n.isAttached()}function mo(e,t,n,r){for(let i=e;i&&!ff(i);i=Id(i)){let e=cd(i,t);if(e!==void 0){let t=od(e,n);if(t)return vu(t)||!Qd(i)?void 0:[i,t]}else if(i===r)return[r,pd(n)]}}function ho(e,t,n){so=!0;let r=performance.now()-co>100;try{fu(e,()=>{let i=B()||function(e){return e.getEditorState().read(()=>{let e=B();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=mo(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&R(g)&&Zu(p)&&po(i,p,g)&&fo(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=sd(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!uo(r,a,e)){if(Na){let e=(Qd(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(uo(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||uo(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&md(i),Na&&Pd(e)&&i.insertRawText(u))})}finally{so=!1}}function go(e){let t=e._observer;t!==null&&ho(e,t.takeRecords(),t)}function _o(e){(function(e){co===0&&Hd(e).addEventListener(`textInput`,lo,!0)})(e),e._observer=new MutationObserver((t,n)=>{ho(e,t,n)})}var vo=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||To).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function yo(e,t){return new vo(e,t)}function bo(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=mf(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var xo=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return wo(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=wo(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function So(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new xo(t,Co(t));return t.__state=n,n}function Co(e){return e.__state?e.__state.sharedNodeState:Bu(af(),e.getType()).sharedNodeState}function wo(e){if(e)for(let t in e)return e}function To(e){return e}function Eo(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Do(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Oo(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function ko(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&Eo(n,e,t)||t&&Eo(n,t,e)||e&&Do(n,e,t)||t&&Do(n,t,e))}(c,l))}function Ao(e,t){let n=e.mergeWithSibling(t),r=$l()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function jo(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&R(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(ko(t,r)){r=Ao(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&R(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(ko(r,n)){r=Ao(r,n);break}break}n.remove()}}else r.remove()}function Mo(e){return No(e.anchor),No(e.focus),e}function No(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),R(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!V(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo=``,Go=null,Ko=null,qo=!1,Jo=!1;function Yo(e,t){let n=Bo.get(e);if(t!==null){let n=ps(e);n.parentNode===t&&t.removeChild(n)}if(Vo.has(e)||Fo._keyToDOMMap.delete(e),V(n)){let e=ss(n,Bo);Xo(e,0,e.length-1,null)}n!==void 0&&jd(Uo,Io,Lo,n,`destroyed`)}function Xo(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&Yo(t,r)}}function Zo(e,t){e.setProperty(`text-align`,t)}var Qo=`40px`;function $o(e,t){let n=Po.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(Fo._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||Qo;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function es(e,t){let n=e.style;t===0?Zo(n,``):t===1?Zo(n,`left`):t===2?Zo(n,`center`):t===3?Zo(n,`right`):t===4?Zo(n,`justify`):t===5?Zo(n,`start`):t===6&&Zo(n,`end`)}function ts(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(bu(e))return null;let n=e.getParentOrThrow();return bu(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function ns(e,t){let n=Vo.get(e);n===void 0&&I(60);let r=n.createDOM(Po,Fo);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,Fo),R(n)?r.setAttribute(`data-lexical-text`,`true`):vu(n)&&r.setAttribute(`data-lexical-decorator`,`true`),V(n)){let e=n.__indent,t=n.__size;if(ts(r,n),e!==0&&$o(r,e),t!==0){let e=t-1;rs(ss(n,Vo),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&es(r,i),n.isInline()||as(null,n,r)}else{let t=n.getTextContent();if(vu(n)){let t=n.decorate(Fo,Po);t!==null&&ls(e,t),r.contentEditable=`false`}Wo+=t}return t!==null&&t.insertChild(r),jd(Uo,Io,Lo,n,`created`),r}function rs(e,t,n,r,i){let a=Wo;Wo=``;let o=n;for(;o<=r;++o){ns(e[o],i);let t=Vo.get(e[o]);t!==null&&R(t)?Go===null&&(Go=t.getFormat(),Ko=t.getStyle()):V(t)&&o<r&&!t.isInline()&&(Wo+=Za)}i.element.__lexicalTextContent=Wo,Wo=a+Wo}function is(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return Wc(e)?`line-break`:vu(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function as(e,t,n){let r=is(e,Bo),i=is(t,Vo);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function os(e,t,n){var r;Go=null,Ko=null,function(e,t,n){let r=Wo,i=e.__size,a=t.__size;Wo=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)cs(n,o);else{let e=ps(n),t=ns(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}Yo(n,null)}let i=Vo.get(r);R(i)&&Go===null&&(Go=i.getFormat(),Ko=i.getStyle())}else{let r=ss(e,Bo),s=ss(t,Vo);if(r.length!==i&&I(227),s.length!==a&&I(228),i===0)a!==0&&rs(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;Xo(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=us(cs(r,a.element)),d++,f++;else{if(l===void 0&&(l=ds(n,f)),c===void 0)c=ds(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=us(ps(e)),Yo(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=Fd(Fo,r);e!==u&&a.withBefore(u).insertChild(e),u=us(cs(r,a.element)),d++,f++}else ns(r,a.withBefore(u)),f++}let i=Vo.get(r);i!==null&&R(i)?Go===null&&(Go=i.getFormat(),Ko=i.getStyle()):V(i)&&f<=s&&!i.isInline()&&(Wo+=Za)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:Fo.getElementByKey(e);rs(n,0,f,s,a.withBefore(t))}else m&&!p&&Xo(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=Wo,Wo=r+Wo}(e,t,t.getDOMSlot(n)),r=t,Go==null||Go===r.__textFormat||Jo||r.setTextFormat(Go),function(e){Ko==null||Ko===e.__textStyle||Jo||e.setTextStyle(Ko)}(t)}function ss(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&I(101),n.push(r),r=e.__next}return n}function cs(e,t){let n=Bo.get(e),r=Vo.get(e);n!==void 0&&r!==void 0||I(61);let i=qo||zo.has(e)||Ro.has(e),a=Fd(Fo,e);if(n===r&&!i){let e;if(V(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return Wo+=e,a}if(n!==r&&i&&jd(Uo,Io,Lo,r,`updated`),r.updateDOM(n,a,Po)){let n=ns(e,null);return t===null&&I(62),t.replaceChild(n,a),Yo(e,null),n}if(V(n)){V(r)||I(334,e);let t=r.__indent;(qo||t!==n.__indent)&&$o(a,t);let o=r.__format;if((qo||o!==n.__format)&&es(a,o),i)os(n,r,a),bu(r)||r.isInline()||as(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),Wo+=t}if((qo||r.__dir!==n.__dir)&&(ts(a,r),bu(r)&&!qo))for(let e of r.getChildren())V(e)&&ts(Fd(Fo,e.getKey()),e)}else{let t=r.getTextContent();if(vu(r)){let t=r.decorate(Fo,Po);t!==null&&ls(e,t)}Wo+=t}if(!Jo&&bu(r)&&r.__cachedText!==Wo){let e=r.getWritable();e.__cachedText=Wo,r=e}return a}function ls(e,t){let n=Fo._pendingDecorators,r=Fo._decorators;if(n===null){if(r[e]===t)return;n=ud(Fo)}n[e]=t}function us(e){let t=e.nextSibling;return t!==null&&t===Fo._blockCursorElement&&(t=t.nextSibling),t}function ds(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function fs(e,t,n,r,i,a){Wo=``,qo=r===2,Fo=n,Po=n._config,Io=n._nodes,Lo=Fo._listeners.mutation,Ro=i,zo=a,Bo=e._nodeMap,Vo=t._nodeMap,Jo=t._readOnly,Ho=new Map(n._keyToDOMMap);let o=new Map;return Uo=o,cs(`root`,null),Fo=void 0,Io=void 0,Ro=void 0,zo=void 0,Bo=void 0,Vo=void 0,Po=void 0,Ho=void 0,Uo=void 0,o}function ps(e){let t=Ho.get(e);return t===void 0&&I(75,e),t}function L(e){return{type:e}}var ms=L(`SELECTION_CHANGE_COMMAND`),hs=L(`CLICK_COMMAND`),gs=L(`BEFORE_INPUT_COMMAND`),_s=L(`INPUT_COMMAND`),vs=L(`COMPOSITION_START_COMMAND`),ys=L(`COMPOSITION_END_COMMAND`),bs=L(`DELETE_CHARACTER_COMMAND`),xs=L(`INSERT_LINE_BREAK_COMMAND`),Ss=L(`INSERT_PARAGRAPH_COMMAND`),Cs=L(`CONTROLLED_TEXT_INSERTION_COMMAND`),ws=L(`PASTE_COMMAND`),Ts=L(`REMOVE_TEXT_COMMAND`),Es=L(`DELETE_WORD_COMMAND`),Ds=L(`DELETE_LINE_COMMAND`),Os=L(`FORMAT_TEXT_COMMAND`),ks=L(`UNDO_COMMAND`),As=L(`REDO_COMMAND`),js=L(`KEYDOWN_COMMAND`),Ms=L(`KEY_ARROW_RIGHT_COMMAND`),Ns=L(`MOVE_TO_END`),Ps=L(`KEY_ARROW_LEFT_COMMAND`),Fs=L(`MOVE_TO_START`),Is=L(`KEY_ARROW_UP_COMMAND`),Ls=L(`KEY_ARROW_DOWN_COMMAND`),Rs=L(`KEY_ENTER_COMMAND`),zs=L(`KEY_SPACE_COMMAND`),Bs=L(`KEY_BACKSPACE_COMMAND`),Vs=L(`KEY_ESCAPE_COMMAND`),Hs=L(`KEY_DELETE_COMMAND`),Us=L(`KEY_TAB_COMMAND`),Ws=L(`DROP_COMMAND`),Gs=L(`DRAGSTART_COMMAND`),Ks=L(`DRAGOVER_COMMAND`),qs=L(`DRAGEND_COMMAND`),Js=L(`COPY_COMMAND`),Ys=L(`CUT_COMMAND`),Xs=L(`SELECT_ALL_COMMAND`),Zs=L(`FOCUS_COMMAND`),Qs=L(`BLUR_COMMAND`),$s=L(`KEY_MODIFIER_COMMAND`),ec=Object.freeze({}),tc=[[`keydown`,function(e,t){nc=e.timeStamp,rc=e.key,!t.isComposing()&&U(t,js,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;$d(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&fu(t,()=>{Uu(n)||(lc=!0)})}],[`compositionstart`,function(e,t){U(t,vs,e)}],[`compositionend`,function(e,t){Na?dc=!0:Fa||!La&&!Ba?U(t,ys,e):(fc=!0,pc=e.data)}],[`input`,function(e,t){e.stopPropagation(),fu(t,()=>{t.dispatchCommand(_s,e)},{event:e}),ac=null}],[`click`,function(e,t){fu(t,()=>{let n=B(),r=Xd(Hd(t)),i=Ml();if(r){if(z(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!bu(a)&&fd().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=gf(a,e=>V(e)&&!e.isInline());V(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(Qd(n)||Zu(n))&&md(jl(i,r,t,e))}}U(t,hs,e)})}],[`cut`,ec],[`copy`,ec],[`dragstart`,ec],[`dragover`,ec],[`dragend`,ec],[`paste`,ec],[`focus`,ec],[`blur`,ec],[`drop`,ec]];Pa&&tc.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||Na&&Pd(t)||n!==`insertCompositionText`&&U(t,gs,e)}(e,t)]);var nc=0,rc=null,ic=0,ac=null,oc=new WeakMap,sc=new WeakMap,cc=!1,lc=!1,uc=!1,dc=!1,fc=!1,pc=``,mc=null,hc=[0,``,0,`root`,0];function gc(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=$l(),l=Xd(Hd(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!R(s)||(!i&&(!Pa||ic<r+50)||s.isDirty()&&p<2||gd(n))&&a.offset!==o.offset&&!s.isComposing()||Xu(s)||s.isDirty()&&p>1||(i||!Pa)&&f!==null&&!s.isComposing()&&u!==$u(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=Yu(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(R(t)||V(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function _c(e,t){return Zu(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function vc(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;cc&&(cc=!1,_c(r,i)&&_c(a,o)&&!mc)||fu(t,()=>{if(!n)return void md(null);if(!Gu(t,r,a))return;let s=B();if(mc&&z(s)&&s.isCollapsed()){let e=s.anchor,t=mc.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=mc.clone(),md(s))}if(mc=null,z(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=Hd(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=hc,f=fd(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)yc(s,o,c);else if(n.type===`text`)R(r)||I(141),bc(s,r);else if(n.type===`element`&&!p){V(r)||I(259);let e=n.getNode();e.isEmpty()?function(e,t){yc(e,t.getTextFormat(),t.getTextStyle())}(s,e):yc(s,s.format,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(R(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}U(t,ms,void 0)})}function yc(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function bc(e,t){yc(e,t.getFormat(),t.getStyle())}function xc(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Sc(e){let t=e.inputType,n=xc(e),r=$l(),i=B();if(t===`deleteContentBackward`){if(i===null){let e=Ml();if(!z(e))return!0;md(e.clone())}if(z(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,rc===`MediaLast`&&a<nc+30&&r.isComposing()&&t){if(id(null),nc=0,setTimeout(()=>{fu(r,()=>{id(null)})},30),z(i)){let e=i.anchor.getNode();e.markDirty(),R(e)||I(142),bc(i,e)}}else{id(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=za&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!vu(Nd(i.anchor,!0))),!c){U(r,bs,!0);let e=B();za&&z(e)&&e.isCollapsed()&&(mc=e,setTimeout(()=>mc=null))}}return!0}}var a;if(!z(i))return!0;let o=e.data;ac!==null&&bd(!1,r,ac),i.dirty&&ac===null||!i.isCollapsed()||bu(i.anchor.getNode())||n===null||i.applyDOMRange(n),ac=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
|
|
@@ -97,4 +97,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
97
97
|
|
|
98
98
|
`):void 0}function AM(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=SM(o);if(s){let e=xM(s.status)?.toLowerCase(),t=EM(s,a),o=OM(s),c=xM(s.sessionId),l=Cj({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...xM(s.title)?{label:s.title.trim()}:{},...xM(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:TM(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:TM(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:TM(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=CM(o);if(!c)return null;let l=DM(c,a),u=kM(c),d=xM(c.sessionId),f=Cj({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...xM(c.title)?{label:c.title.trim()}:{},...xM(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:TM(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function jM(e,t){let n=lj(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function MM(e,t){let n=e.mimeType.startsWith(`image/`),r=fj(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function NM(e,t){let n=e.toolInvocation,r=mj(n.result,t);if(r)return r;let i=AM({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:hj(i,t)};let a=gj({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=yM({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),s=o?.summary??YA(n.parsedArgs??n.args),c=o?void 0:vj(n.args,n.parsedArgs),l=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:qA(n.result).trim(),u=!n.error&&pj(n.result),d=(!o?.fileOperation||!!n.error)&&!u,f=Cj(n);return{type:`tool-card`,card:hj({kind:a.kind,name:n.toolName,...f?{agentId:f}:{},detail:s,...c?{input:c}:{},text:d&&l?l:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel,...o?.fileOperation?{fileOperation:o.fileOperation}:{}},t)}}function PM(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:qA(e)}}function FM(e){return e.type===`text`&&typeof e.text==`string`}function IM(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function LM(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function RM(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function zM(e){return FM(e.part)?cj(e.part,e.inlineTokens):IM(e.part)?jM(e.part,e.texts):LM(e.part)?MM(e.part,e.texts):RM(e.part)?NM(e.part,e.texts):PM(e.part,e.texts)}function BM(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function VM(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function HM(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function UM(e,t){return{id:e.id,role:HM(e.role),roleLabel:VM(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(BM(e)),status:e.meta?.status,parts:e.parts.map(n=>zM({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var WM=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function GM(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function KM(e){return GM(e)}function qM(e){let t=GM(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function JM(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function YM(e){let t=JM(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function XM(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function ZM(e){let t=YM(e.path),n=YM(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function QM(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function $M(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function eN(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?ZM({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=qM(i)??i.trim();c=QM({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=XM(o);c=QM({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:$M({line:n,column:t}),truncated:a,segments:c}}var tN=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),nN=new Set([`running`,`completed`,`failed`,`idle`]);function rN(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function iN(e){return`${S}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function aN(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function oN(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function sN(e){let t=oN(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=aN(n.timestamp);if(!nN.has(r)||!i)return null;let a=aN(n.statusText),o=aN(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function cN(e){let t=oN(e);return t?aN(t.preferred_model)??aN(t.preferredModel)??aN(t.model):null}function lN(e){let t=oN(e);if(!t)return null;let n=aN(t.preferred_thinking)??aN(t.thinking)??aN(t.thinking_level)??aN(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return tN.has(r)?r:null}function uN(e){let t=oN(e);return t?aN(t.label):null}function dN(e){let t=oN(e);return t?KM(t.project_root??t.projectRoot):null}function fN(e){let t=oN(e);return t?aN(t.ui_last_read_at):null}function pN(e){let t=oN(e);return t?aN(t.runtime)??aN(t.session_type)??aN(t.sessionType)??`native`:`native`}function mN(e){let t=oN(e);return t?aN(t.parent_session_id)??aN(t.parentSessionId):null}function hN(e){let t=oN(e);return t?aN(t.spawned_by_request_id)??aN(t.spawnedByRequestId):null}function gN(e){let t=oN(e);return t?t.child_session_promoted===!0:!1}function _N(e){if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function vN(e){return e.state===`cancelled`?WM.CANCELLED:e.state===`result`?WM.RESULT:e.state===`partial-call`?WM.PARTIAL_CALL:WM.CALL}function yN(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:iN(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:vN(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:rN(n.args),result:n.result}})}return t}function bN(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function xN(e){return{id:e.id,role:bN(e.role),parts:yN(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function SN(e){let t=uN(e),n=cN(e),r=lN(e),i=dN(e),a=fN(e),o=aN(e.lastMessageAt),s=qM(i),c=_N(e.sessionId),l=mN(e),u=hN(e),d=gN(e),f=sN(e);return{key:e.sessionId,createdAt:e.createdAt??e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:pN(e),sessionTypeMutable:!1,status:e.status??`idle`,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},...f?{activityPreview:f}:{},messageCount:e.messageCount}}function CN(e){return e.map(SN)}function wN(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function TN(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function EN(e){return e===!0}function DN(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=TN(n.usedContextTokens),i=TN(n.totalContextTokens),a=TN(n.prunedUsedContextTokens),o=wN(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=TN(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:TN(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:TN(n.droppedHistoryCount)??0,truncatedToolResultCount:TN(n.truncatedToolResultCount)??0,truncatedSystemPrompt:EN(n.truncatedSystemPrompt),truncatedUserMessage:EN(n.truncatedUserMessage),compacted:EN(n.compacted),...wN(n.checkpointId)?{checkpointId:wN(n.checkpointId)??void 0}:{},compactedMessageCount:TN(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function ON(e){let{metadata:t}=e;if(!t||t.nextclaw_timeline_kind!==`context_compaction`)return null;let n=t.checkpoint&&typeof t.checkpoint==`object`&&!Array.isArray(t.checkpoint)?t.checkpoint:null;if(!n)return null;let r=wN(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=wN(n.summary),o=TN(n.coveredMessageCount),s=TN(n.coveredSessionMessageCount),c=TN(n.originalEstimatedTokens),l=TN(n.projectedEstimatedTokens),u=wN(n.createdAt),d=wN(n.updatedAt);return!r||!i||!a||o===null||s===null||c===null||l===null||!u||!d?null:{id:r,status:i,summary:a,coveredMessageCount:o,coveredSessionMessageCount:s,originalEstimatedTokens:c,projectedEstimatedTokens:l,createdAt:u,updatedAt:d}}function kN(){return ge({queryKey:[`agents`],queryFn:te,staleTime:3e4})}function AN(){let e=C();return x({mutationFn:({agentId:e,data:t})=>E(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),_.success(u(`configSavedApplied`))},onError:e=>{_.error(u(`configSaveFailed`)+`: `+e.message)}})}function jN(){let e=C();return x({mutationFn:({agentId:e})=>ce(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),_.success(u(`configSavedApplied`))},onError:e=>{_.error(u(`configSaveFailed`)+`: `+e.message)}})}function MN(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function NN(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=kN(),i=(0,N.useMemo)(()=>MN(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,N.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function PN({agentId:e,className:t}){let n=NN(e);return n?(0,P.jsx)(Pr,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var FN=new WeakMap;function IN(e){return{roleLabels:{user:u(`chatRoleUser`),assistant:u(`chatRoleAssistant`),tool:u(`chatRoleTool`),system:u(`chatRoleSystem`),fallback:u(`chatRoleMessage`)},reasoningLabel:u(`chatReasoning`),toolCallLabel:u(`chatToolCall`),toolResultLabel:u(`chatToolResult`),toolInputLabel:u(`chatToolInput`),toolNoOutputLabel:u(`chatToolNoOutput`),toolOutputLabel:u(`chatToolOutput`),toolStatusPreparingLabel:u(`chatToolStatusPreparing`),toolStatusRunningLabel:u(`chatToolStatusRunning`),toolStatusCompletedLabel:u(`chatToolStatusCompleted`),toolStatusFailedLabel:u(`chatToolStatusFailed`),toolStatusCancelledLabel:u(`chatToolStatusCancelled`),imageAttachmentLabel:u(`chatImageAttachment`),fileAttachmentLabel:u(`chatFileAttachment`),unknownPartLabel:u(`chatUnknownPart`)}}function LN(e){return{copyCodeLabel:u(`chatCodeCopy`),copiedCodeLabel:u(`chatCodeCopied`),copyMessageLabel:u(`chatMessageCopy`),copiedMessageLabel:u(`chatMessageCopied`),typingLabel:u(`chatTyping`),attachmentOpenLabel:u(`chatAttachmentOpen`),attachmentAttachedLabel:u(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:u(`chatAttachmentCategoryArchive`),audio:u(`chatAttachmentCategoryAudio`),code:u(`chatAttachmentCategoryCode`),data:u(`chatAttachmentCategoryData`),document:u(`chatAttachmentCategoryDocument`),generic:u(`chatAttachmentCategoryGeneric`),image:u(`chatAttachmentCategoryImage`),pdf:u(`chatAttachmentCategoryPdf`),sheet:u(`chatAttachmentCategorySheet`),video:u(`chatAttachmentCategoryVideo`)}}}function RN({checkpoint:e}){return(0,P.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-gray-500`,title:[`${u(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${u(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${u(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
|
|
99
99
|
`),children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`}),(0,P.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-gray-200 bg-gray-50 px-3 py-1`,children:[e.status===`compressing`?(0,P.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}):(0,P.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-300`}),(0,P.jsx)(`span`,{children:e.status===`compressing`?u(`chatContextCompactionCompressing`):u(`chatContextCompactionCompressed`)})]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`})]})}function zN(e){let{normalRawMessages:t,rawMessageId:n,rawMessages:r}=e,i=r.findIndex(e=>e.id===n);return i<0?t.length-1:r.slice(0,i).filter(e=>!ON(e)).length-1}function BN(e){let t=e.rawMessages.filter(e=>!ON(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:ON(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:zN({rawMessages:e.rawMessages,normalRawMessages:t,rawMessageId:n.rawMessageId})})).sort((e,t)=>e.boundaryIndex-t.boundaryIndex),r=[],i=[],a=0,o=e=>{i.length!==0&&(r.push({kind:`messages`,key:e,messages:i}),i=[])};for(t.forEach((t,s)=>{let c=e.messages[s];for(c&&i.push(c);a<n.length&&n[a]?.boundaryIndex<=s;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}});a<n.length;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}return o(`messages-final`),r.length===0&&r.push({kind:`messages`,key:`messages-empty`,messages:[]}),r}function VN({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=tn(),o=(0,N.useMemo)(()=>IN(a),[a]),s=(0,N.useMemo)(()=>e.flatMap(e=>{if(ON(e))return[];let t=FN.get(e);if(t&&t.language===a)return[t.viewModel];let n=xN(e),r=UM({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:nj(e.metadata)},parts:n.parts},{formatTimestamp:e=>d(e,a),texts:o});return FN.set(e,{language:a,viewModel:r}),[r]}),[a,e,o]),c=(0,N.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),l=(0,N.useMemo)(()=>LN(a),[a]),u=(0,N.useMemo)(()=>BN({rawMessages:e,messages:s}),[s,e]);return(0,P.jsx)(`div`,{className:n,children:u.map((e,n)=>e.kind===`compaction`?(0,P.jsx)(RN,{checkpoint:e.checkpoint},e.key):(0,P.jsx)(ek,{messages:e.messages,isSending:n===u.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,P.jsx)(PN,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function HN(){let e=C();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{oe(e,await fe(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),_.success(i??u(`configSavedApplied`))}catch(e){throw _.error(u(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function UN(){let e=HN();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=u(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),_.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function WN({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,P.jsxs)(`button`,{type:`button`,className:f(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,P.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{children:t})]})}function GN(e){return ge({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>ue({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var KN=N.forwardRef(({className:e,children:t,...n},r)=>(0,P.jsx)(`div`,{ref:r,className:f(`overflow-auto`,e),...n,children:t}));KN.displayName=`ScrollArea`;function qN({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:s,pathPlaceholder:c,confirmLabel:l,hint:d}){let[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(``);(0,N.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),h(n),_(``)},[t,e]);let b=GN({path:m,enabled:e});(0,N.useEffect)(()=>{!e||!b.data||f.trim().length===0&&p(b.data.currentPath)},[b.data,f,e]);let x=f.trim(),S=x.length===0||n,C=(0,N.useMemo)(()=>b.error?b.error instanceof Error?b.error.message:String(b.error):null,[b.error]),w=g.trim().toLowerCase(),T=(0,N.useMemo)(()=>{let e=b.data?.entries??[];return w.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(w)||n.includes(w)})},[b.data?.entries,w]),E=e=>{h(e),_(``),e&&p(e)};return(0,P.jsx)(Ve,{open:e,onOpenChange:e=>{n||r(e)},children:(0,P.jsxs)(Re,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,P.jsxs)(Ie,{children:[(0,P.jsx)(ze,{children:a}),o?(0,P.jsx)(Be,{children:o}):null]}),(0,P.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!S&&i(x)},children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(A,{htmlFor:`server-path-picker-input`,children:s}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(v,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:c,autoFocus:!0,disabled:n}),(0,P.jsx)(y,{type:`button`,variant:`outline`,onClick:()=>E(x||null),disabled:n,children:u(`openPath`)})]})]}),(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,P.jsxs)(y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.homePath??null),disabled:n||b.isLoading,children:[(0,P.jsx)(Vn,{className:`mr-1 h-4 w-4`}),u(`homeDirectory`)]}),(0,P.jsxs)(y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>E(b.data?.parentPath??null),disabled:!b.data?.parentPath||n||b.isLoading,children:[(0,P.jsx)(In,{className:`mr-1 h-4 w-4`}),u(`parentDirectory`)]}),(0,P.jsxs)(y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{b.refetch()},disabled:n||b.isLoading,children:[(0,P.jsx)(Gt,{className:`mr-1 h-4 w-4`}),u(`chatRefresh`)]})]}),(0,P.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,P.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:u(`currentDirectory`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:b.data?.breadcrumbs.map((e,t)=>(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>E(e.path),disabled:n,children:e.label}),t<b.data.breadcrumbs.length-1?(0,P.jsx)(bn,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,P.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(mt,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,P.jsx)(v,{value:g,onChange:e=>_(e.target.value),placeholder:u(`pathPickerSearchPlaceholder`),disabled:n||b.isLoading,className:`pl-9`})]})}),(0,P.jsx)(KN,{className:`min-h-0 flex-1 px-2 py-2`,children:b.isLoading?(0,P.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:u(`loading`)}):C?(0,P.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[u(`pathBrowseFailed`),`: `,C]}):b.data&&T.length>0?(0,P.jsx)(`div`,{className:`space-y-1`,children:T.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>E(e.path),disabled:n,children:[(0,P.jsx)(Rn,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,P.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):b.data&&b.data.entries.length>0?(0,P.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:u(`pathPickerSearchEmpty`)}):(0,P.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:u(`emptyDirectory`)})})]}),d?(0,P.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,P.jsxs)(Le,{children:[(0,P.jsx)(y,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:u(`cancel`)}),(0,P.jsx)(y,{type:`submit`,disabled:S,children:n?u(`saving`):l})]})]})]})})}function JN({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,P.jsx)(qN,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:u(`chatSessionProjectDialogTitle`),description:u(`chatSessionProjectDialogDescription`),pathLabel:u(`chatSessionProjectPathLabel`),pathPlaceholder:u(`chatSessionProjectPathPlaceholder`),confirmLabel:u(`chatSessionSetProject`),hint:u(`chatSessionProjectUpdateHint`)})}var YN=`flex shrink-0 items-center gap-1.5`,XN=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function ZN({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:s,onDeleteSession:c}){let l=UN(),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(!1),[h,g]=(0,N.useState)(!1),_=n||h,v=async n=>{let r=t;g(!0);try{await l({sessionKey:e,projectRoot:n,persistToServer:r}),m(!1),f(!1)}finally{g(!1)}};return(0,P.jsxs)(`div`,{className:YN,children:[i>0&&o?(0,P.jsx)(y,{type:`button`,variant:`ghost`,size:`icon`,className:XN,"aria-label":u(`chatSessionOpenChildSessions`),title:u(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,P.jsx)(zn,{className:`h-4 w-4`})}):null,a>0&&s?(0,P.jsx)(y,{type:`button`,variant:`ghost`,size:`icon`,className:XN,"aria-label":u(`chatSessionOpenCronJobs`),title:u(`chatSessionOpenCronJobs`),onClick:s,disabled:_,children:(0,P.jsx)(Ge,{className:`h-4 w-4`})}):null,(0,P.jsxs)(hn,{open:d,onOpenChange:f,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{variant:`ghost`,size:`icon`,className:XN,"aria-label":u(`chatSessionMoreActions`),disabled:_,children:(0,P.jsx)(Cn,{className:`h-4 w-4`})})}),(0,P.jsx)(dn,{align:`end`,className:`w-56 p-2`,children:(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(WN,{icon:Pn,label:u(`chatSessionSetProject`),onClick:()=>{f(!1),m(!0)},disabled:_}),(0,P.jsx)(WN,{icon:Yn,label:u(`chatDeleteSession`),onClick:()=>{f(!1),c()},disabled:!t||_,destructive:!0})]})})]}),(0,P.jsx)(JN,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function QN({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=UN(),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),[l,d]=(0,N.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),c(!1),o(!1)}finally{d(!1)}};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(hn,{open:a,onOpenChange:o,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":u(`chatSessionSetProject`),disabled:l,children:(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,P.jsx)(Pn,{className:`h-3.5 w-3.5 shrink-0`}),(0,P.jsx)(`span`,{className:`truncate`,children:t}),(0,P.jsx)(yt,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,P.jsxs)(dn,{align:`start`,className:`w-72 p-2`,children:[(0,P.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,P.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,P.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(WN,{icon:Kn,label:u(`chatSessionSetProject`),onClick:()=>{o(!1),c(!0)},disabled:l}),(0,P.jsx)(WN,{icon:Ln,label:u(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:l})]})]})]}),(0,P.jsx)(JN,{open:s,currentProjectRoot:n,isSaving:l,onOpenChange:c,onSave:f})]})}function $N({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,P.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,P.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,P.jsx)(pt,{className:`h-3.5 w-3.5`}),(0,P.jsxs)(`span`,{children:[u(`chatBackToParent`),n?` · ${n}`:``]})]})})}function eP({snapshot:e,childSessionCount:t,sessionCronJobCount:n,layoutMode:r,normalizedAgentId:i,sessionHeaderTitle:a,shouldShowHeaderAgentAvatar:o,shouldShowSessionHeader:s,onBackToList:c,onOpenChildSessions:l,onOpenSessionCronJobs:d,onDeleteSession:p}){let m=r===`mobile`;return(0,P.jsxs)(`div`,{className:f(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-colors duration-200`,m?`px-3 sm:px-3`:`px-4 sm:px-5`,s?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,s&&(m?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:m&&s?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[m&&c?(0,P.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":u(`chat`),children:(0,P.jsx)(pt,{className:`h-4 w-4`})}):null,o?(0,P.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,P.jsx)(Pr,{agentId:i,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:a}),e.sessionTypeLabel?(0,P.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,P.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,P.jsx)(Dr,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,P.jsx)(QN,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,P.jsx)(ZN,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:l,onOpenSessionCronJobs:d,onDeleteSession:p}):null]})}var tP=`native`;function nP(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:tP}function rP(e,t=tP){return nP(e?.runtime?.trim()||e?.engine?.trim()||t)}function iP(e,t){return e===`native`?u(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function aP(e){let t=new Map;for(let n of e){let e=nP(n.value);t.set(e,{value:e,label:n.label?.trim()||iP(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(tP,{value:tP,label:iP(tP),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function oP(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,N.useMemo)(()=>aP(i?.options??[]),[i?.options]),o=(0,N.useMemo)(()=>{let e=[...a],n=nP(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:iP(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),s=(0,N.useMemo)(()=>nP(i?.defaultType??`native`),[i?.defaultType]),c=(0,N.useRef)(null),l=(0,N.useMemo)(()=>nP(t?.sessionType??n??s),[s,n,t?.sessionType]),d=(0,N.useMemo)(()=>o.find(e=>e.value===l)??null,[l,o]);(0,N.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=nP(n);(e.length===0||c.current===i||c.current===null&&i===`native`)&&(c.current=s,i!==s&&r(s))},[s,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,N.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:o,selectedSessionTypeOption:d,defaultSessionType:s,selectedSessionType:l,canEditSessionType:f,sessionTypeUnavailable:(0,N.useMemo)(()=>t&&!p.has(nP(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,N.useMemo)(()=>t&&!p.has(nP(t.sessionType))?`${iP(l)} ${u(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,l,d])}}function sP(e,t){return e.label?.trim()?e.label.trim():t?Ir(t):e.sessionKey}function cP(e){let t=an({limit:200}),n=(0,N.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,N.useMemo)(()=>{let e=CN(n);return new Map(e.map(e=>[e.key,e]))},[n]);return(0,N.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:sP(e,t),agentId:n,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:t?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?iP(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function lP(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
|
|
100
|
-
`)}}async function*uP(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=dP(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=dP(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function dP(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=lP(e);t&&i.push(t)}if(t&&r.trim()){let e=lP(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var fP=`/ncp/agent`,pP=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function mP(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function hP(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function gP(e){let t=(e??`/ncp/agent`).trim();if(!t)return fP;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function _P(e){try{return(await e.text()).trim()}catch{return``}}function vP(e){if(SP(e))return e.ncpError;if(bP(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:wP(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function yP(e,t={}){return new pP(e,t.alreadyPublished??!1)}function bP(e){return xP(e)&&typeof e.code==`string`&&typeof e.message==`string`}function xP(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function SP(e){return e instanceof pP}var CP={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function wP(e){if(!e)return`runtime-error`;let t=CP[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function TP(e){let t=DP(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function EP(e){let t=DP(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=wP(n),i=xP(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function DP(e){try{let t=JSON.parse(e);return xP(t)?t:null}catch{return null}}var OP=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],kP=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=mP(e.baseUrl),this.basePath=gP(e.basePath),this.fetchImpl=hP(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:OP,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:tk.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await _P(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(SP(e))throw e;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await _P(n)}`)}catch(e){if(t.signal.aborted)return;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await _P(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of uP(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(SP(e))throw e;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=TP(e.data);if(!t){this.publish({type:tk.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=EP(e.data);throw this.publish({type:tk.EndpointError,payload:t}),yP(t,{alreadyPublished:!0})}}};function AP(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function jP(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function MP(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function NP(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw he.reportTransportFailure(jP(n)),MP(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${AP(e)}: ${jP(n)}`,n)}}}var PP=300,FP=`ncp agent unavailable during startup`;function IP(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function LP(e){return e?.trim().toLowerCase().includes(FP)??!1}function RP(){return new kP({baseUrl:S,basePath:`/api/ncp/agent`,fetchImpl:NP()})}async function zP(e,t,n=PP){t.throwIfAborted();try{let r=await k(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!IP(e))throw e;return{messages:[],status:`idle`}}}function BP(e,t){let n=(0,N.useRef)(null),r=(0,N.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,N.useEffect)(()=>{r(e)},[e,r])}function VP(e,t={}){let[n]=(0,N.useState)(()=>RP()),r=T(),[i,a]=(0,N.useState)(0),[o,s]=(0,N.useState)(null),c=t.messageLimit??PP;(0,N.useEffect)(()=>{s(null)},[e]);let l=Nk({sessionId:e,client:n,loadSeed:(0,N.useCallback)(async(e,t)=>{let n=await zP(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return BP(e&&r.phase===`ready`&&LP(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,N.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}var HP=Xi,UP=Zi,WP=Qi,GP=N.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,P.jsx)($i,{children:(0,P.jsx)(ea,{ref:r,sideOffset:t,className:f(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));GP.displayName=ea.displayName;function KP(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function qP(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function JP({agentId:e,kind:t}){return t===`cron`?(0,P.jsx)(Ge,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,P.jsx)(En,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,P.jsx)(PN,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,P.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function YP({tab:e}){return(0,P.jsx)(HP,{delayDuration:250,children:(0,P.jsxs)(UP,{children:[(0,P.jsx)(WP,{asChild:!0,children:(0,P.jsxs)(`div`,{className:f(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,P.jsx)(JP,{kind:e.kind,agentId:e.agentId}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,P.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:u(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,P.jsx)(`span`,{"aria-label":u(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,P.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:f(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":u(`chatWorkspaceCloseFile`),children:(0,P.jsx)(Qt,{className:`h-3 w-3`})}):null]})}),(0,P.jsx)(GP,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function XP({tabs:e}){return(0,P.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,P.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,P.jsx)(YP,{tab:e},e.key))})})}function ZP({tone:e=`neutral`,value:t}){return(0,P.jsx)(`span`,{className:f(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function QP({breadcrumb:e}){return(0,P.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,P.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,P.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsxs)(`span`,{className:f(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,P.jsx)(Fn,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,P.jsx)(En,{className:`h-3 w-3 shrink-0`}):null,(0,P.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,P.jsx)(bn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,P.jsx)(ZP,{value:e.locationLabel}):null,e.truncated?(0,P.jsx)(ZP,{tone:`warning`,value:u(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function $P(e){let t=e.path?.trim()??``;return ge({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>re({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function eF(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function tF(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:Aj({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function nF(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=Pj({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function rF({text:e,tone:t=`muted`}){return(0,P.jsx)(`div`,{className:f(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function iF({diffBlock:e}){return e?(0,P.jsx)(aF,{block:e}):(0,P.jsx)(rF,{text:u(`chatWorkspaceDiffEmpty`)})}function aF({block:e}){return(0,P.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,P.jsx)(hO,{block:e,layout:`workspace`})})}function oF({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,P.jsx)(rF,{text:u(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,P.jsx)(rF,{text:u(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,P.jsx)(rF,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,P.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,P.jsx)(aD,{text:i,role:`assistant`,texts:{copyCodeLabel:u(`chatCodeCopy`),copiedCodeLabel:u(`chatCodeCopied`)},onFileOpen:e})}):t?(0,P.jsx)(aF,{block:t}):(0,P.jsx)(rF,{text:u(`chatWorkspacePreviewEmpty`)})}function sF({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=$P({path:e.path,basePath:t,enabled:r}),a=(0,N.useMemo)(()=>e.viewMode===`diff`?nF(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=eF({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,N.useMemo)(()=>!r||!o?null:tF({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,P.jsx)(QP,{breadcrumb:(0,N.useMemo)(()=>eN({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,P.jsx)(iF,{diffBlock:a}):(0,P.jsx)(oF,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var cF=({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=u(`confirm`),cancelLabel:a=u(`cancel`),variant:o=`default`,onConfirm:s,onCancel:c})=>(0,P.jsx)(Ve,{open:e,onOpenChange:t,children:(0,P.jsxs)(Re,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(Ie,{children:[(0,P.jsx)(ze,{children:n}),r?(0,P.jsx)(Be,{children:r}):null]}),(0,P.jsxs)(Le,{className:`gap-2 sm:gap-0`,children:[(0,P.jsx)(y,{type:`button`,variant:`outline`,onClick:()=>{c(),t(!1)},children:a}),(0,P.jsx)(y,{type:`button`,variant:o===`destructive`?`destructive`:`default`,onClick:()=>{s(),t(!1)},children:i})]})]})}),lF={open:!1,title:``,description:``,confirmLabel:u(`confirm`),cancelLabel:u(`cancel`),variant:`default`,resolve:null};function uF(){let[e,t]=(0,N.useState)(lF),n=(0,N.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??u(`confirm`),cancelLabel:e.cancelLabel??u(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,N.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,N.useCallback)(()=>(0,P.jsx)(cF,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function dF(e){return d(e??void 0)}function fF(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:d(new Date(e))}function pF(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function mF(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${pF(t.everyMs)}`:t.kind===`at`?`at ${fF(t.atMs)}`:`-`}function hF(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function gF(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function _F(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function vF({jobs:e}){let t=sn(),{confirm:n,ConfirmDialog:r}=uF(),i=async e=>{await n({title:`${u(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:u(`delete`)})&&t.mutate({id:e.id})};return(0,P.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,P.jsxs)(`div`,{className:`mb-4`,children:[(0,P.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:u(`chatWorkspaceSessionCronJobs`)}),(0,P.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[u(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,P.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:u(`chatWorkspaceCronJobEmpty`)}):(0,P.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,P.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,P.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,P.jsxs)(y,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,P.jsx)(Yn,{className:`h-3.5 w-3.5`}),u(`delete`)]})]}),(0,P.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronScheduleLabel`),`:`]}),` `,mF(e)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronNextRun`),`:`]}),` `,dF(e.state.nextRunAt)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronLastRun`),`:`]}),` `,dF(e.state.lastRunAt)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronDeliverTo`),`:`]}),` `,hF(e)]})]}),(0,P.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,P.jsx)(r,{})]})}function yF({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=VP(e),i=r.visibleMessages,a=(0,N.useRef)(null),{onScroll:o}=WD({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,P.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,P.jsx)(Hn,{className:`mr-2 h-4 w-4 animate-spin`}),u(`chatChildSessionLoading`)]}):r.hydrateError?(0,P.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,P.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:u(`chatChildSessionEmpty`)}):(0,P.jsx)(`div`,{className:`px-4 py-5`,children:(0,P.jsx)(VN,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function bF({value:e}){return(0,P.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,P.jsx)(`span`,{className:`truncate`,children:e})})}function xF({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,P.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,P.jsx)(bF,{value:e},e))}):null,e.projectRoot?(0,P.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function SF({tab:e}){return(0,P.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,P.jsx)(PN,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,P.jsx)(Nn,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,P.jsx)(xF,{tab:e})]})}function CF(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:s,onCloseFile:c,onSelectCronJobs:l}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:SA({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:KP(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>s(e.key),onClose:()=>c(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:u(`chatWorkspaceSessionCronJobs`),tooltip:u(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:l}]:[];return[...d,...f,...p]}function wF({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:r,activeWorkspaceFileKey:i,activePanelKind:a,sessionCronJobs:o=[],sessionProjectRoot:s,displayMode:c=`docked`}){let l=Zr(),d=cP(t),p=EA(e=>e.optimisticReadAtBySessionKey),m=qP({activeChildSessionKey:n,activeWorkspaceFileKey:i,activePanelKind:a,childSessionTabs:d,workspaceFileTabs:r,sessionCronJobCount:o.length}),h=d.some(e=>!!e.parentSessionKey);(0,N.useEffect)(()=>{if(m?.kind!==`child-session`)return;let e=m.tab.lastMessageAt?.trim()??null;e&&l.chatSessionListManager.markSessionRead(m.tab.sessionKey,e,m.tab.readAt??null)},[m,l]);let g=(0,N.useMemo)(()=>CF({resolvedChildTabs:d,workspaceFileTabs:r,sessionCronJobCount:o.length,activeSelection:m,optimisticReadAtBySessionKey:p,onSelectSession:l.chatThreadManager.selectChildSessionDetail,onSelectFile:l.chatThreadManager.selectWorkspaceFile,onCloseFile:l.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&l.chatThreadManager.openSessionCronPanel(e)}}),[m,p,l.chatThreadManager,d,e,r,o.length]);return m?(0,P.jsx)(`aside`,{className:f(c===`overlay`?`fixed inset-0 z-40 flex bg-white`:`hidden shrink-0 border-l border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex md:w-[26rem] lg:w-[30rem] xl:w-[34rem]`),children:(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:l.chatThreadManager.goToParentSession,className:f(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!h&&`pointer-events-none opacity-0`),children:[(0,P.jsx)(pt,{className:`h-3.5 w-3.5`}),(0,P.jsx)(`span`,{children:u(`chatBackToParent`)})]}),(0,P.jsx)(`button`,{type:`button`,onClick:l.chatThreadManager.closeWorkspacePanel,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":u(`chatWorkspaceClosePanel`),children:(0,P.jsx)(Qt,{className:`h-4 w-4`})})]}),(0,P.jsx)(XP,{tabs:g}),(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:m.kind===`child-session`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(SF,{tab:m.tab}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,P.jsx)(yF,{sessionKey:m.tab.sessionKey,onToolAction:l.chatThreadManager.openSessionFromToolAction,onFileOpen:l.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,P.jsx)(sF,{file:m.file,sessionProjectRoot:s,onFileOpen:l.chatThreadManager.openFilePreview}):(0,P.jsx)(vF,{jobs:o})})]})}):null}function TF({className:e,...t}){return(0,P.jsx)(`div`,{className:f(`animate-pulse rounded-md bg-slate-200`,e),...t})}var EF=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function DF(){return(0,P.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,P.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,P.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(TF,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,P.jsx)(`div`,{className:`space-y-5`,children:EF.map(e=>(0,P.jsx)(`div`,{className:f(`flex w-full`,e.alignmentClassName),children:(0,P.jsx)(TF,{"data-testid":`chat-conversation-skeleton-bubble`,className:f(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,P.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(TF,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,P.jsx)(TF,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,P.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,P.jsx)(TF,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,P.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,P.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,P.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,P.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,P.jsx)(TF,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(TF,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,P.jsx)(TF,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,P.jsx)(TF,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,P.jsx)(TF,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function OF(){let e=Zr(),t=Q(e=>e.snapshot);return(0,P.jsxs)(P.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,P.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,P.jsx)(`span`,{className:`text-xs text-amber-800`,children:u(`chatModelNoOptions`)}),(0,P.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:u(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,P.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,P.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function kF({layoutMode:e}){let t=Zr(),n=Z(e=>e.snapshot.defaultSessionType),r=Q(e=>e.snapshot),i=(0,N.useRef)(null),a=r.threadRef??i,o=r.availableAgents??[],s=!r.canDeleteSession&&!r.hasSubmittedDraftMessage&&r.messages.length===0&&!r.isSending,c=r.isHistoryLoading&&r.messages.length===0&&!r.isSending&&!r.isAwaitingAssistantOutput,l=e=>o.find(t=>t.id===e)??null,u=()=>{let i=rP(l(r.agentId??`main`),n);t.chatSessionListManager.createSession(i),e===`mobile`&&t.chatUiManager.goToChatRoot()},d=e=>{t.chatSessionListManager.setSelectedAgentId(e),t.chatInputManager.setPendingSessionType(rP(l(e),n))},{onScroll:f}=WD({scrollRef:a,resetKey:r.sessionKey,isLoading:r.isHistoryLoading,hasContent:r.messages.length>0,contentVersion:r.messages[r.messages.length-1]??null}),p=r.messages.length>0,m=p&&r.isSending&&r.isAwaitingAssistantOutput;return(0,P.jsx)(`div`,{ref:a,onScroll:f,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:s?(0,P.jsx)(Jr,{onCreateSession:u,agents:o,selectedAgentId:r.agentId??`main`,onSelectAgent:d}):c||!p?null:(0,P.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,P.jsx)(VN,{messages:r.messages,isSending:m,onToolAction:t.chatThreadManager.openSessionFromToolAction,onFileOpen:t.chatThreadManager.openFilePreview})})})}function AF(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function jF(e){let t=(0,N.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,N.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=on({all:!0}),i=(0,N.useMemo)(()=>(r.data?.jobs??[]).filter(t=>_F(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:AF(e,t,n,i.length)}}function MF(){let e=Zr(),t=Q(e=>e.snapshot);return(0,P.jsx)($N,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function NF({layoutMode:e,onBackToList:t}){let n=Zr(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=jF(r),o=!!(r.sessionKey||r.sessionTypeLabel),s=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||u(`chatSidebarNewTask`),c=r.agentId?.trim()??``,l=c.length>0&&c.toLowerCase()!==`main`;return(0,P.jsx)(eP,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:c,sessionHeaderTitle:s,shouldShowHeaderAgentAvatar:l,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function PF({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=jF(t);return a?(0,P.jsx)(wF,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function FF({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,P.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,P.jsx)(MF,{}),(0,P.jsx)(NF,{layoutMode:e,onBackToList:t}),(0,P.jsx)(OF,{}),(0,P.jsx)(kF,{layoutMode:e}),(0,P.jsx)(HA,{})]}),(0,P.jsx)(PF,{layoutMode:e})]}):(0,P.jsx)(DF,{})}var IF={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function LF({status:e,className:t}){let n=IF[e],r=u(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,P.jsx)(HP,{delayDuration:250,children:(0,P.jsxs)(UP,{children:[(0,P.jsx)(WP,{asChild:!0,children:(0,P.jsx)(`span`,{role:`status`,"aria-label":r,className:f(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,P.jsx)(Hn,{className:f(`h-3 w-3 animate-spin`,n.dotClass)}):(0,P.jsx)(`span`,{className:f(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,P.jsx)(GP,{side:`bottom`,className:`text-xs`,children:r})]})})}function RF(){let e=HN();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:u(`configSavedApplied`)})}}function zF(){let e=RF(),[t,n]=(0,N.useState)(null),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function BF(e,t){return e.filter(e=>Ur(e,t))}function VF(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function HF(e={}){let t=EA(e=>e.snapshot.query),n=an({limit:e.limit??200}),r=(0,N.useMemo)(()=>BF(CN(n.data?.sessions??[]).filter(VF),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function UF(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,P.jsx)(Kr,{session:g,active:y,showUnreadDot:SA({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Sr(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function WF(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function GF(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:o,onQueryChange:s}=e;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`px-4 pb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(y,{variant:`primary`,className:f(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),o(n)},children:[(0,P.jsx)(Xt,{className:`mr-2 h-4 w-4`}),u(`chatSidebarNewTask`)]}),r.length>0?(0,P.jsxs)(hn,{open:i,onOpenChange:a,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":u(`chatSessionTypeLabel`),children:(0,P.jsx)(yt,{className:`h-4 w-4`})})}),(0,P.jsxs)(dn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,P.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:u(`chatSessionTypeLabel`)}),(0,P.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,P.jsx)(kr,{option:e,onSelect:()=>{o(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,P.jsx)(`div`,{className:`px-4 pb-3`,children:(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(mt,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,P.jsx)(v,{value:t,onChange:e=>s(e.target.value),placeholder:u(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function KF(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onQueryChange:c}=e,l=WF({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=l.length>1;return(0,P.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,P.jsx)(mt,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,P.jsx)(v,{value:t,onChange:e=>c(e.target.value),placeholder:u(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,P.jsxs)(hn,{open:a,onOpenChange:o,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":u(`chatSidebarNewTask`),children:(0,P.jsx)(Xt,{className:`h-4 w-4`})})}),(0,P.jsxs)(dn,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,P.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:u(`chatSidebarNewTask`)}),(0,P.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,P.jsx)(kr,{option:e,onSelect:()=>{s(e.value),o(!1)}},e.value))})]})]}):(0,P.jsx)(y,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":u(`chatSidebarNewTask`),onClick:()=>s(n),children:(0,P.jsx)(Xt,{className:`h-4 w-4`})})]})})}function qF({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:s,languageOptions:c,onSelectLanguage:l,onOpenDocs:d}){let f=()=>{d(),t(!1)};return(0,P.jsxs)(hn,{open:e,onOpenChange:t,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,P.jsx)(Yt,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:u(`settings`)}),(0,P.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,s]})]})}),(0,P.jsxs)(dn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(be,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,P.jsx)(Yt,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`span`,{className:`flex-1 text-left`,children:u(`settings`)})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:f,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,P.jsx)(ht,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`span`,{className:`flex-1 text-left`,children:u(`docBrowserHelp`)})]})]}),(0,P.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,P.jsx)(JF,{icon:He,label:u(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,P.jsx)(JF,{icon:qe,label:u(`language`),options:c,value:o,valueLabel:s,onSelect:l,onCloseMenu:()=>t(!1)})]})]})}function JF({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,P.jsxs)(Rt,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,P.jsxs)(kt,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,P.jsx)(bn,{className:`h-4 w-4 text-gray-400`}),children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,P.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`text-left`,children:t})]}),(0,P.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,P.jsx)(Nt,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,P.jsx)(It,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function YF(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function XF(e){return[...e].sort((e,t)=>YF(t)-YF(e))}function ZF(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],s=[],c=[];for(let t of e){let e=YF(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?s.push(t):c.push(t)}let l=[];return a.length>0&&l.push({label:u(`chatSidebarToday`),items:a}),o.length>0&&l.push({label:u(`chatSidebarYesterday`),items:o}),s.length>0&&l.push({label:u(`chatSidebarPrevious7Days`),items:s}),c.length>0&&l.push({label:u(`chatSidebarOlder`),items:c}),l}function QF(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=YF(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||qM(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:XF(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function $F(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>YF(t)-YF(e));return t}function eI(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var tI=[{target:`/cron`,label:()=>u(`chatSidebarScheduledTasks`),icon:Ge},{target:`/skills`,label:()=>u(`chatSidebarSkills`),icon:We},{target:`/agents`,label:()=>u(`agentsPageTitle`),icon:Ue}];function nI(e,t,n){let r=EA(e=>e.optimisticReadAtBySessionKey);return(0,N.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function rI({variant:e=`desktop`}){let t=e===`mobile`,n=Zr(),r=$t(),[i,a]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),l=Z(e=>e.snapshot),d=EA(e=>e.snapshot),p=T(),m=kN(),{isLoading:h,items:g}=HF(),{language:_,setLanguage:v}=tn(),{theme:y,setTheme:b}=it(),x=u(at.find(e=>e.value===y)?.labelKey??`themeWarm`),S=o.find(e=>e.value===_)?.label??_,C=(0,N.useMemo)(()=>at.map(e=>({value:e.value,label:u(e.labelKey)})),[]),w=(0,N.useMemo)(()=>o.map(e=>({value:e.value,label:e.label})),[]),E=(0,N.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),D=(0,N.useMemo)(()=>XF(g),[g]),O=(0,N.useMemo)(()=>$F(g),[g]),ee=(0,N.useMemo)(()=>ZF(D),[D]),k=(0,N.useMemo)(()=>QF(D),[D]),te=l.defaultSessionType||`native`,A=(0,N.useMemo)(()=>l.sessionTypeOptions.filter(e=>e.value!==te),[te,l.sessionTypeOptions]),ne=d.listMode===`project-first`,j=nI(g,d.selectedSessionKey,n.chatSessionListManager.markSessionRead),{editingSessionKey:re,draftLabel:ie,savingSessionKey:ae,setDraftLabel:oe,startEditingSessionLabel:se,cancelEditingSessionLabel:ce,saveSessionLabel:le}=zF(),ue=e=>{_!==e&&(v(e),window.location.reload())},de=e=>(0,P.jsx)(UF,{item:e,selectedSessionKey:d.selectedSessionKey,optimisticReadAtBySessionKey:j,agentsById:E,childSessionsByParentKey:O,editingSessionKey:re,draftLabel:ie,savingSessionKey:ae,sessionTitle:eI,onSelectSession:n.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>n.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:se,onDraftLabelChange:oe,onSaveSessionLabel:le,onCancelEditingSessionLabel:ce},e.session.key),fe=(e,r)=>{n.chatSessionListManager.createSession(e,typeof r==`string`?r:void 0),t&&n.chatUiManager.goToChatRoot()};return(0,P.jsxs)(`aside`,{className:f(`flex h-full min-h-0 flex-col bg-secondary`,t?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!t&&!ot()?(0,P.jsx)(`div`,{className:f(`px-5 pb-3`,rt()?`pt-1.5`:`pt-5`),children:(0,P.jsx)(Qe,{className:`flex min-w-0 items-center gap-2`,suffix:(0,P.jsx)(LF,{status:p.connectionStatus})})}):null,t?(0,P.jsx)(KF,{query:d.query,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:A,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:fe,onQueryChange:n.chatSessionListManager.setQuery}):(0,P.jsx)(GF,{query:d.query,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:A,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:fe,onQueryChange:n.chatSessionListManager.setQuery}),t?null:(0,P.jsx)(`div`,{className:`px-3 pb-2`,children:(0,P.jsx)(`ul`,{className:`space-y-0.5`,children:tI.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(Ze,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),t?null:(0,P.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,P.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:u(`chatSidebarTaskRecords`)}),(0,P.jsx)(ur,{isProjectFirstView:ne,onSelectMode:n.chatSessionListManager.setListMode})]}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,P.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:u(`sessionsLoading`)}):ne?k.length===0?(0,P.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,P.jsx)(Un,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,P.jsx)(`div`,{className:`text-xs text-gray-500`,children:u(`chatSidebarProjectViewEmpty`)})]}):(0,P.jsx)(jr,{groups:k,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,renderSessionItem:de,onCreateSession:fe}):ee.length===0?(0,P.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,P.jsx)(Un,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,P.jsx)(`div`,{className:`text-xs text-gray-500`,children:u(`sessionsEmpty`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:ee.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(de)})]},e.label))})}),t?null:(0,P.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,P.jsx)(qF,{isOpen:s,onOpenChange:c,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:ue,onOpenDocs:()=>r.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`})})})]})}function iI(){return ge({queryKey:[`ncp-session-types`],queryFn:h,staleTime:1e4,retry:!1})}function aI(e){let t=e.trim();return t.length>0?t:null}function oI(e){return e??null}var sI=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=EA.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:aI(e.selectedModel),preferredThinking:oI(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},cI=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new sI(fe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>jA(he.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=uA(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:aA(e),selectedSkills:oA(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:aA(e),selectedSkills:oA(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(iA(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=lA(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=lA(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=EA.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=dA(e.composerNodes,i);if(bA({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(rA()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=nP(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(cA(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),mA.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{hA.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},lI=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=EA.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=EA.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=EA.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=EA.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(EA.getState().markSessionRead(r,i),fe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=KM(t);this.streamActionsManager.resetStreamState(),EA.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.goToChatRoot()},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=EA.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e)},this.setQuery=e=>{let t=EA.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({query:n})}}},uI=async()=>{},dI=()=>{},fI=class{constructor(){this.actions={sendMessage:uI,stopCurrentRun:uI,resumeRun:uI,resetStreamState:dI,applyHistoryMessages:dI},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},pI=`sid_`;function mI(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${pI}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function hI(e){if(!e.startsWith(pI))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function gI(e){if(!e)return null;let t=hI(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function _I(e){return`/chat/${mI(e)}`}var vI=async e=>!1,yI=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:vI},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`,this.goToSession=(e,t)=>{this.navigateTo(_I(e),t)}}},bI=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{EA.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(EA.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=EA.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||EA.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>nr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=EA.getState();if(e&&await this.uiManager.confirm({title:u(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:u(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await j(e),ee(m,e),m.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},xI=class{constructor(){this.chatUiManager=new yI,this.chatStreamActionsManager=new fI,this.chatSessionListManager=new lI(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new cI(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new bI(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function SI(e){return e?.trim().toLowerCase()||`native`}function CI(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function wI(e,t){return typeof t==`string`&&e.includes(t)}function TI(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function EI(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function DI(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:EI({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>CI(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function OI(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:EI({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>wI(t,e),firstAvailableValue:TI(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function kI(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=SI(r),o,s=-1/0;for(let e of t){if(e.key===n||SI(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function AI(e){return e.map(e=>e==null?``:String(e)).join(``)}function jI(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,N.useRef)(void 0),l=(0,N.useRef)(s),u=(0,N.useRef)(n);l.current=s,(0,N.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function MI(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;jI({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:AI([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>DI({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function NI(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;jI({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:AI([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>OI({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function PI(){let{pathname:e}=ve(),t=xe();return $e(e)?(0,P.jsx)(FF,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,P.jsx)(rI,{variant:`mobile`})}var FI=`NextClaw`,II=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/plugins`,key:`marketplacePluginsPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function LI(e,t){return e===t||e.startsWith(`${t}/`)}function RI(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of II)if(LI(t,e))return u(n);return u(`settings`)}function zI(e){return`${FI} - ${RI(e)}`}function BI({children:e}){let{isOpen:t,mode:n}=$t();nn();let{pathname:r}=ve(),{language:i}=tn(),{isMobile:a}=rr();return(0,N.useEffect)(()=>{document.title=zI(r)},[r,i]),a?(0,P.jsx)(cr,{pathname:r,isDocBrowserOpen:t,children:e}):(0,P.jsx)(ct,{pathname:r,isDocBrowserOpen:t,docBrowserMode:n,children:e})}function VI({children:e}){return(0,P.jsx)(en,{children:(0,P.jsx)(BI,{children:e})})}function HI(){let{isMobile:e}=rr();return e?(0,P.jsx)(lr,{}):(0,P.jsx)(_e,{to:`/model`,replace:!0})}function UI(e){let t=e.trim().toLowerCase();return t?!(t.startsWith(`plugins`)||t.startsWith(`skills`)):!0}function WI(e,t){t.startsWith(`plugins`)&&(e?.invalidateQueries({queryKey:[`ncp-session-types`]}),e?.invalidateQueries({queryKey:[`marketplace-installed`,`plugin`]}),e?.invalidateQueries({queryKey:[`marketplace-items`]})),t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function GI(e,t){e&&UI(t)&&e.invalidateQueries({queryKey:[`config`]}),WI(e,t)}function KI(e){let t=(0,N.useRef)(!1);(0,N.useEffect)(()=>{let n=ae.eventBus.on(p.connectionOpen,()=>{he.handleConnectionRestored(),se.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=ae.eventBus.on(p.connectionClose,()=>{he.handleConnectionInterrupted(null),t.current=!0}),i=ae.eventBus.on(p.connectionError,e=>{he.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=ae.eventBus.on(p.configUpdated,({path:t})=>{GI(e,t)}),o=ae.eventBus.on(p.runtimeUpdateSnapshot,e=>{se.reportSnapshot(e)}),s=ae.eventBus.on(p.sessionRunStatus,t=>{O(e,{type:`session.run-status`,payload:t})}),c=ae.eventBus.on(p.sessionSummaryUpsert,t=>{O(e,{type:`session.summary.upsert`,payload:t})}),l=ae.eventBus.on(p.sessionSummaryDelete,t=>{O(e,{type:`session.summary.delete`,payload:t})}),u=ae.eventBus.on(p.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var qI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ModelConfig:e}=await import(`./model-config-L2l6YAlQ.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,5,3,12,13,14,15,9,16,17]))).ModelConfig})),JI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ChatPage:e}=await import(`./chat-page-DAKMFDrS.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,13,14,11,20,21,8,22,23,24,4,25,15,26,1,5,6,7,9,27,28,29,30,31,32,33,34,16,12,35,36,37]))).ChatPage})),YI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SearchConfig:e}=await import(`./search-config-CQUhd5RU.js`);return{SearchConfig:e}},__vite__mapDeps([38,2,13,14,11,3,4,6,29,39,16]))).SearchConfig})),XI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ProvidersList:e}=await import(`./providers-list-DYAEunOp.js`);return{ProvidersList:e}},__vite__mapDeps([40,2,13,14,11,3,22,21,4,29,7,8,39,41,32,27,16,17]))).ProvidersList})),ZI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-HgLgrEg4.js`);return{ChannelsList:e}},__vite__mapDeps([42,2,13,14,11,3,4,5,6,29,33,8,39,32,27,36,16,17]))).ChannelsList})),QI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-BdeU8PEK.js`);return{RuntimeConfig:e}},__vite__mapDeps([43,2,13,14,11,3,28,19,22,21,4,5,25,29,30,20,8,31,32,33,34,15,26,1,6,7,9,16,37,44,45,41]))).RuntimeConfig})),$I=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-CP8dFYXK.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([46,2,13,14,11,3,25,6,34,44]))).DesktopUpdateConfig})),eL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SecurityConfig:e}=await import(`./api-DGD9_Bg4.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),tL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-D-NWlW9q.js`);return{SecretsConfig:e}},__vite__mapDeps([47,2,13,14,11,3,7,45,16]))).SecretsConfig})),nL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{RemoteAccessPage:e}=await import(`./remote-Dr3jcfWP.js`);return{RemoteAccessPage:e}},__vite__mapDeps([48,30,2,20,14,11,21,8,3,29,31,32]))).RemoteAccessPage})),rL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{MarketplacePage:e}=await import(`./marketplace-page-CR4xq-TM.js`);return{MarketplacePage:e}},__vite__mapDeps([49,23,2,19,3,11,24,13,14,4,25,15,26,1,5,6,7,8,9,27]))).MarketplacePage})),iL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-DlRrSCj3.js`);return{McpMarketplacePage:e}},__vite__mapDeps([50,35,2,20,14,11,21,8,3,24,13,15,26,1,4,5,6,7,9,31,36]))).McpMarketplacePage}));function aL(){return(0,P.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function oL({children:e}){return(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(aL,{}),children:e})}function sL(e){return(0,P.jsx)(oL,{children:e})}var cL=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:sL((0,P.jsx)(JI,{view:`chat`}))},{path:`/agents`,element:sL((0,P.jsx)(JI,{view:`agents`}))},{path:`/skills`,element:sL((0,P.jsx)(JI,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:sL((0,P.jsx)(JI,{view:`skills`}))},{path:`/cron`,element:sL((0,P.jsx)(JI,{view:`cron`}))},{path:`/model`,element:sL((0,P.jsx)(qI,{}))},{path:`/search`,element:sL((0,P.jsx)(YI,{}))},{path:`/providers`,element:sL((0,P.jsx)(XI,{}))},{path:`/channels`,element:sL((0,P.jsx)(ZI,{}))},{path:`/runtime`,element:sL((0,P.jsx)(QI,{}))},{path:`/updates`,element:sL((0,P.jsx)($I,{}))},{path:`/remote`,element:sL((0,P.jsx)(nL,{}))},{path:`/security`,element:sL((0,P.jsx)(eL,{}))},{path:`/secrets`,element:sL((0,P.jsx)(tL,{}))},{path:`/language`,element:(0,P.jsx)(tt,{})},{path:`/settings`,element:(0,P.jsx)(HI,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/marketplace/plugins`},{path:`/marketplace/mcp`,element:sL((0,P.jsx)(iL,{}))},{path:`/marketplace/:type`,element:sL((0,P.jsx)(rL,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function lL(e){return`redirectTo`in e?(0,P.jsx)(Ce,{path:e.path,element:(0,P.jsx)(_e,{to:e.redirectTo,replace:!0})},e.path):(0,P.jsx)(Ce,{path:e.path,element:e.element},e.path)}function uL(){return(0,P.jsx)(Te,{children:cL.map(lL)})}function dL(){return KI(m),pe(),(0,N.useEffect)(()=>(se.start(),()=>{se.stop()}),[]),(0,P.jsxs)(Jt,{children:[(0,P.jsx)(VI,{children:(0,P.jsx)(uL,{})}),(0,P.jsx)(Kt,{})]})}function fL(){let e=de(),t=e.isError&&ne(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,P.jsx)(dL,{}):e.data?.enabled&&!e.data.authenticated?(0,P.jsx)(qt,{username:e.data.username}):(0,P.jsx)(dL,{})}function pL(){return(0,N.useEffect)(()=>{st()},[]),(0,P.jsxs)(w,{client:m,children:[(0,P.jsx)(fL,{}),(0,P.jsx)(Xe,{}),(0,P.jsx)(lt,{}),(0,P.jsx)(g,{position:`top-right`,richColors:!0})]})}(0,Qn.createRoot)(document.getElementById(`root`)).render((0,P.jsx)(N.StrictMode,{children:(0,P.jsx)(Ye,{children:(0,P.jsx)(rn,{children:(0,P.jsx)(Se,{children:(0,P.jsx)(pL,{})})})})}));export{Vn as $,DN as A,Z as B,nP as C,kN as D,oP as E,XA as F,Ur as G,Xr as H,tj as I,pr as J,Pr as K,jA as L,SN as M,qM as N,jN as O,KM as P,Hn as Q,NA as R,aP as S,iP as T,Zr as U,Rk as V,Ir as W,Yn as X,rr as Y,Kn as Z,GP as _,xI as a,LP as b,rI as c,hF as d,Bn as et,mF as f,UP as g,uF as h,NI as i,CN as j,AN as k,FF as l,dF as m,kI as n,gI as o,gF as p,Er as q,MI as r,iI as s,PI as t,Rn as tt,TF as u,HP as v,rP as w,VP as x,WP as y,EA as z};
|
|
100
|
+
`)}}async function*uP(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=dP(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=dP(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function dP(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=lP(e);t&&i.push(t)}if(t&&r.trim()){let e=lP(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var fP=`/ncp/agent`,pP=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function mP(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function hP(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function gP(e){let t=(e??`/ncp/agent`).trim();if(!t)return fP;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function _P(e){try{return(await e.text()).trim()}catch{return``}}function vP(e){if(SP(e))return e.ncpError;if(bP(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:wP(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function yP(e,t={}){return new pP(e,t.alreadyPublished??!1)}function bP(e){return xP(e)&&typeof e.code==`string`&&typeof e.message==`string`}function xP(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function SP(e){return e instanceof pP}var CP={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function wP(e){if(!e)return`runtime-error`;let t=CP[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function TP(e){let t=DP(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function EP(e){let t=DP(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=wP(n),i=xP(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function DP(e){try{let t=JSON.parse(e);return xP(t)?t:null}catch{return null}}var OP=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],kP=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=mP(e.baseUrl),this.basePath=gP(e.basePath),this.fetchImpl=hP(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:OP,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:tk.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await _P(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(SP(e))throw e;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await _P(n)}`)}catch(e){if(t.signal.aborted)return;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await _P(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of uP(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(SP(e))throw e;let n=vP(e);throw this.publish({type:tk.EndpointError,payload:n}),yP(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=TP(e.data);if(!t){this.publish({type:tk.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=EP(e.data);throw this.publish({type:tk.EndpointError,payload:t}),yP(t,{alreadyPublished:!0})}}};function AP(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function jP(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function MP(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function NP(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw he.reportTransportFailure(jP(n)),MP(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${AP(e)}: ${jP(n)}`,n)}}}var PP=300,FP=`ncp agent unavailable during startup`;function IP(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function LP(e){return e?.trim().toLowerCase().includes(FP)??!1}function RP(){return new kP({baseUrl:S,basePath:`/api/ncp/agent`,fetchImpl:NP()})}async function zP(e,t,n=PP){t.throwIfAborted();try{let r=await k(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!IP(e))throw e;return{messages:[],status:`idle`}}}function BP(e,t){let n=(0,N.useRef)(null),r=(0,N.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,N.useEffect)(()=>{r(e)},[e,r])}function VP(e,t={}){let[n]=(0,N.useState)(()=>RP()),r=T(),[i,a]=(0,N.useState)(0),[o,s]=(0,N.useState)(null),c=t.messageLimit??PP;(0,N.useEffect)(()=>{s(null)},[e]);let l=Nk({sessionId:e,client:n,loadSeed:(0,N.useCallback)(async(e,t)=>{let n=await zP(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return BP(e&&r.phase===`ready`&&LP(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,N.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}var HP=Xi,UP=Zi,WP=Qi,GP=N.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,P.jsx)($i,{children:(0,P.jsx)(ea,{ref:r,sideOffset:t,className:f(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));GP.displayName=ea.displayName;function KP(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function qP(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function JP({agentId:e,kind:t}){return t===`cron`?(0,P.jsx)(Ge,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,P.jsx)(En,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,P.jsx)(PN,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,P.jsx)(Un,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function YP({tab:e}){return(0,P.jsx)(HP,{delayDuration:250,children:(0,P.jsxs)(UP,{children:[(0,P.jsx)(WP,{asChild:!0,children:(0,P.jsxs)(`div`,{className:f(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,P.jsx)(JP,{kind:e.kind,agentId:e.agentId}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,P.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:u(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,P.jsx)(`span`,{"aria-label":u(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,P.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:f(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":u(`chatWorkspaceCloseFile`),children:(0,P.jsx)(Qt,{className:`h-3 w-3`})}):null]})}),(0,P.jsx)(GP,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function XP({tabs:e}){return(0,P.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,P.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,P.jsx)(YP,{tab:e},e.key))})})}function ZP({tone:e=`neutral`,value:t}){return(0,P.jsx)(`span`,{className:f(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function QP({breadcrumb:e}){return(0,P.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,P.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,P.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsxs)(`span`,{className:f(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,P.jsx)(Fn,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,P.jsx)(En,{className:`h-3 w-3 shrink-0`}):null,(0,P.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,P.jsx)(bn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,P.jsx)(ZP,{value:e.locationLabel}):null,e.truncated?(0,P.jsx)(ZP,{tone:`warning`,value:u(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function $P(e){let t=e.path?.trim()??``;return ge({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>re({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function eF(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function tF(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:Aj({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function nF(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=Pj({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function rF({text:e,tone:t=`muted`}){return(0,P.jsx)(`div`,{className:f(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function iF({diffBlock:e}){return e?(0,P.jsx)(aF,{block:e}):(0,P.jsx)(rF,{text:u(`chatWorkspaceDiffEmpty`)})}function aF({block:e}){return(0,P.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,P.jsx)(hO,{block:e,layout:`workspace`})})}function oF({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,P.jsx)(rF,{text:u(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,P.jsx)(rF,{text:u(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,P.jsx)(rF,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,P.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,P.jsx)(aD,{text:i,role:`assistant`,texts:{copyCodeLabel:u(`chatCodeCopy`),copiedCodeLabel:u(`chatCodeCopied`)},onFileOpen:e})}):t?(0,P.jsx)(aF,{block:t}):(0,P.jsx)(rF,{text:u(`chatWorkspacePreviewEmpty`)})}function sF({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=$P({path:e.path,basePath:t,enabled:r}),a=(0,N.useMemo)(()=>e.viewMode===`diff`?nF(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=eF({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,N.useMemo)(()=>!r||!o?null:tF({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,P.jsx)(QP,{breadcrumb:(0,N.useMemo)(()=>eN({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,P.jsx)(iF,{diffBlock:a}):(0,P.jsx)(oF,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var cF=({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=u(`confirm`),cancelLabel:a=u(`cancel`),variant:o=`default`,onConfirm:s,onCancel:c})=>(0,P.jsx)(Ve,{open:e,onOpenChange:t,children:(0,P.jsxs)(Re,{className:`[&>:last-child]:hidden`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,P.jsxs)(Ie,{children:[(0,P.jsx)(ze,{children:n}),r?(0,P.jsx)(Be,{children:r}):null]}),(0,P.jsxs)(Le,{className:`gap-2 sm:gap-0`,children:[(0,P.jsx)(y,{type:`button`,variant:`outline`,onClick:()=>{c(),t(!1)},children:a}),(0,P.jsx)(y,{type:`button`,variant:o===`destructive`?`destructive`:`default`,onClick:()=>{s(),t(!1)},children:i})]})]})}),lF={open:!1,title:``,description:``,confirmLabel:u(`confirm`),cancelLabel:u(`cancel`),variant:`default`,resolve:null};function uF(){let[e,t]=(0,N.useState)(lF),n=(0,N.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??u(`confirm`),cancelLabel:e.cancelLabel??u(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,N.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,N.useCallback)(()=>(0,P.jsx)(cF,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function dF(e){return d(e??void 0)}function fF(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:d(new Date(e))}function pF(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function mF(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${pF(t.everyMs)}`:t.kind===`at`?`at ${fF(t.atMs)}`:`-`}function hF(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function gF(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function _F(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function vF({jobs:e}){let t=sn(),{confirm:n,ConfirmDialog:r}=uF(),i=async e=>{await n({title:`${u(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:u(`delete`)})&&t.mutate({id:e.id})};return(0,P.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,P.jsxs)(`div`,{className:`mb-4`,children:[(0,P.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:u(`chatWorkspaceSessionCronJobs`)}),(0,P.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[u(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,P.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:u(`chatWorkspaceCronJobEmpty`)}):(0,P.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,P.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,P.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,P.jsxs)(y,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,P.jsx)(Yn,{className:`h-3.5 w-3.5`}),u(`delete`)]})]}),(0,P.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronScheduleLabel`),`:`]}),` `,mF(e)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronNextRun`),`:`]}),` `,dF(e.state.nextRunAt)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronLastRun`),`:`]}),` `,dF(e.state.lastRunAt)]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[u(`cronDeliverTo`),`:`]}),` `,hF(e)]})]}),(0,P.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,P.jsx)(r,{})]})}function yF({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=VP(e),i=r.visibleMessages,a=(0,N.useRef)(null),{onScroll:o}=WD({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,P.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,P.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,P.jsx)(Hn,{className:`mr-2 h-4 w-4 animate-spin`}),u(`chatChildSessionLoading`)]}):r.hydrateError?(0,P.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,P.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:u(`chatChildSessionEmpty`)}):(0,P.jsx)(`div`,{className:`px-4 py-5`,children:(0,P.jsx)(VN,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function bF({value:e}){return(0,P.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,P.jsx)(`span`,{className:`truncate`,children:e})})}function xF({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,P.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,P.jsx)(bF,{value:e},e))}):null,e.projectRoot?(0,P.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function SF({tab:e}){return(0,P.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,P.jsx)(PN,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,P.jsx)(Nn,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,P.jsx)(xF,{tab:e})]})}function CF(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:s,onCloseFile:c,onSelectCronJobs:l}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:SA({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:KP(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>s(e.key),onClose:()=>c(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:u(`chatWorkspaceSessionCronJobs`),tooltip:u(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:l}]:[];return[...d,...f,...p]}function wF({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:r,activeWorkspaceFileKey:i,activePanelKind:a,sessionCronJobs:o=[],sessionProjectRoot:s,displayMode:c=`docked`}){let l=Zr(),d=cP(t),p=EA(e=>e.optimisticReadAtBySessionKey),m=qP({activeChildSessionKey:n,activeWorkspaceFileKey:i,activePanelKind:a,childSessionTabs:d,workspaceFileTabs:r,sessionCronJobCount:o.length}),h=d.some(e=>!!e.parentSessionKey);(0,N.useEffect)(()=>{if(m?.kind!==`child-session`)return;let e=m.tab.lastMessageAt?.trim()??null;e&&l.chatSessionListManager.markSessionRead(m.tab.sessionKey,e,m.tab.readAt??null)},[m,l]);let g=(0,N.useMemo)(()=>CF({resolvedChildTabs:d,workspaceFileTabs:r,sessionCronJobCount:o.length,activeSelection:m,optimisticReadAtBySessionKey:p,onSelectSession:l.chatThreadManager.selectChildSessionDetail,onSelectFile:l.chatThreadManager.selectWorkspaceFile,onCloseFile:l.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&l.chatThreadManager.openSessionCronPanel(e)}}),[m,p,l.chatThreadManager,d,e,r,o.length]);return m?(0,P.jsx)(`aside`,{className:f(c===`overlay`?`fixed inset-0 z-40 flex bg-white`:`hidden shrink-0 border-l border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex md:w-[26rem] lg:w-[30rem] xl:w-[34rem]`),children:(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:l.chatThreadManager.goToParentSession,className:f(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!h&&`pointer-events-none opacity-0`),children:[(0,P.jsx)(pt,{className:`h-3.5 w-3.5`}),(0,P.jsx)(`span`,{children:u(`chatBackToParent`)})]}),(0,P.jsx)(`button`,{type:`button`,onClick:l.chatThreadManager.closeWorkspacePanel,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":u(`chatWorkspaceClosePanel`),children:(0,P.jsx)(Qt,{className:`h-4 w-4`})})]}),(0,P.jsx)(XP,{tabs:g}),(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:m.kind===`child-session`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(SF,{tab:m.tab}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,P.jsx)(yF,{sessionKey:m.tab.sessionKey,onToolAction:l.chatThreadManager.openSessionFromToolAction,onFileOpen:l.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,P.jsx)(sF,{file:m.file,sessionProjectRoot:s,onFileOpen:l.chatThreadManager.openFilePreview}):(0,P.jsx)(vF,{jobs:o})})]})}):null}function TF({className:e,...t}){return(0,P.jsx)(`div`,{className:f(`animate-pulse rounded-md bg-slate-200`,e),...t})}var EF=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function DF(){return(0,P.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,P.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,P.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(TF,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,P.jsx)(`div`,{className:`space-y-5`,children:EF.map(e=>(0,P.jsx)(`div`,{className:f(`flex w-full`,e.alignmentClassName),children:(0,P.jsx)(TF,{"data-testid":`chat-conversation-skeleton-bubble`,className:f(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,P.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,P.jsxs)(`div`,{className:`space-y-3`,children:[(0,P.jsx)(TF,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,P.jsx)(TF,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,P.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,P.jsx)(TF,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,P.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,P.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,P.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,P.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,P.jsx)(TF,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(TF,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,P.jsx)(TF,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,P.jsx)(TF,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,P.jsx)(TF,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function OF(){let e=Zr(),t=Q(e=>e.snapshot);return(0,P.jsxs)(P.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,P.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,P.jsx)(`span`,{className:`text-xs text-amber-800`,children:u(`chatModelNoOptions`)}),(0,P.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:u(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,P.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,P.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function kF({layoutMode:e}){let t=Zr(),n=Z(e=>e.snapshot.defaultSessionType),r=Q(e=>e.snapshot),i=(0,N.useRef)(null),a=r.threadRef??i,o=r.availableAgents??[],s=!r.canDeleteSession&&!r.hasSubmittedDraftMessage&&r.messages.length===0&&!r.isSending,c=r.isHistoryLoading&&r.messages.length===0&&!r.isSending&&!r.isAwaitingAssistantOutput,l=e=>o.find(t=>t.id===e)??null,u=()=>{let i=rP(l(r.agentId??`main`),n);t.chatSessionListManager.createSession(i),e===`mobile`&&t.chatUiManager.goToChatRoot()},d=e=>{t.chatSessionListManager.setSelectedAgentId(e),t.chatInputManager.setPendingSessionType(rP(l(e),n))},{onScroll:f}=WD({scrollRef:a,resetKey:r.sessionKey,isLoading:r.isHistoryLoading,hasContent:r.messages.length>0,contentVersion:r.messages[r.messages.length-1]??null}),p=r.messages.length>0,m=p&&r.isSending&&r.isAwaitingAssistantOutput;return(0,P.jsx)(`div`,{ref:a,onScroll:f,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:s?(0,P.jsx)(Jr,{onCreateSession:u,agents:o,selectedAgentId:r.agentId??`main`,onSelectAgent:d}):c||!p?null:(0,P.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,P.jsx)(VN,{messages:r.messages,isSending:m,onToolAction:t.chatThreadManager.openSessionFromToolAction,onFileOpen:t.chatThreadManager.openFilePreview})})})}function AF(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function jF(e){let t=(0,N.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,N.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=on({all:!0}),i=(0,N.useMemo)(()=>(r.data?.jobs??[]).filter(t=>_F(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:AF(e,t,n,i.length)}}function MF(){let e=Zr(),t=Q(e=>e.snapshot);return(0,P.jsx)($N,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function NF({layoutMode:e,onBackToList:t}){let n=Zr(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=jF(r),o=!!(r.sessionKey||r.sessionTypeLabel),s=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||u(`chatSidebarNewTask`),c=r.agentId?.trim()??``,l=c.length>0&&c.toLowerCase()!==`main`;return(0,P.jsx)(eP,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:c,sessionHeaderTitle:s,shouldShowHeaderAgentAvatar:l,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function PF({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=jF(t);return a?(0,P.jsx)(wF,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function FF({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,P.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,P.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,P.jsx)(MF,{}),(0,P.jsx)(NF,{layoutMode:e,onBackToList:t}),(0,P.jsx)(OF,{}),(0,P.jsx)(kF,{layoutMode:e}),(0,P.jsx)(HA,{})]}),(0,P.jsx)(PF,{layoutMode:e})]}):(0,P.jsx)(DF,{})}var IF={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function LF({status:e,className:t}){let n=IF[e],r=u(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,P.jsx)(HP,{delayDuration:250,children:(0,P.jsxs)(UP,{children:[(0,P.jsx)(WP,{asChild:!0,children:(0,P.jsx)(`span`,{role:`status`,"aria-label":r,className:f(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,P.jsx)(Hn,{className:f(`h-3 w-3 animate-spin`,n.dotClass)}):(0,P.jsx)(`span`,{className:f(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,P.jsx)(GP,{side:`bottom`,className:`text-xs`,children:r})]})})}function RF(){let e=HN();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:u(`configSavedApplied`)})}}function zF(){let e=RF(),[t,n]=(0,N.useState)(null),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function BF(e,t){return e.filter(e=>Ur(e,t))}function VF(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function HF(e={}){let t=EA(e=>e.snapshot.query),n=an({limit:e.limit??200}),r=(0,N.useMemo)(()=>BF(CN(n.data?.sessions??[]).filter(VF),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function UF(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,P.jsx)(Kr,{session:g,active:y,showUnreadDot:SA({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:Sr(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function WF(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function GF(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:r,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:o,onQueryChange:s}=e;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`px-4 pb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(y,{variant:`primary`,className:f(`min-w-0 rounded-xl`,r.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{a(!1),o(n)},children:[(0,P.jsx)(Xt,{className:`mr-2 h-4 w-4`}),u(`chatSidebarNewTask`)]}),r.length>0?(0,P.jsxs)(hn,{open:i,onOpenChange:a,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":u(`chatSessionTypeLabel`),children:(0,P.jsx)(yt,{className:`h-4 w-4`})})}),(0,P.jsxs)(dn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,P.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:u(`chatSessionTypeLabel`)}),(0,P.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,P.jsx)(kr,{option:e,onSelect:()=>{o(e.value),a(!1)}},e.value))})]})]}):null]})}),(0,P.jsx)(`div`,{className:`px-4 pb-3`,children:(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(mt,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,P.jsx)(v,{value:t,onChange:e=>s(e.target.value),placeholder:u(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function KF(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:s,onQueryChange:c}=e,l=WF({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=l.length>1;return(0,P.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,P.jsx)(mt,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,P.jsx)(v,{value:t,onChange:e=>c(e.target.value),placeholder:u(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,P.jsxs)(hn,{open:a,onOpenChange:o,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsx)(y,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":u(`chatSidebarNewTask`),children:(0,P.jsx)(Xt,{className:`h-4 w-4`})})}),(0,P.jsxs)(dn,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,P.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:u(`chatSidebarNewTask`)}),(0,P.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,P.jsx)(kr,{option:e,onSelect:()=>{s(e.value),o(!1)}},e.value))})]})]}):(0,P.jsx)(y,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":u(`chatSidebarNewTask`),onClick:()=>s(n),children:(0,P.jsx)(Xt,{className:`h-4 w-4`})})]})})}function qF({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:s,languageOptions:c,onSelectLanguage:l,onOpenDocs:d}){let f=()=>{d(),t(!1)};return(0,P.jsxs)(hn,{open:e,onOpenChange:t,children:[(0,P.jsx)(pn,{asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,P.jsx)(Yt,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:u(`settings`)}),(0,P.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,s]})]})}),(0,P.jsxs)(dn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(be,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,P.jsx)(Yt,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`span`,{className:`flex-1 text-left`,children:u(`settings`)})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:f,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,P.jsx)(ht,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`span`,{className:`flex-1 text-left`,children:u(`docBrowserHelp`)})]})]}),(0,P.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,P.jsx)(JF,{icon:He,label:u(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,P.jsx)(JF,{icon:qe,label:u(`language`),options:c,value:o,valueLabel:s,onSelect:l,onCloseMenu:()=>t(!1)})]})]})}function JF({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,P.jsxs)(Rt,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,P.jsxs)(kt,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,P.jsx)(bn,{className:`h-4 w-4 text-gray-400`}),children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,P.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,P.jsx)(`span`,{className:`text-left`,children:t})]}),(0,P.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,P.jsx)(Nt,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,P.jsx)(It,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function YF(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function XF(e){return[...e].sort((e,t)=>YF(t)-YF(e))}function ZF(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],s=[],c=[];for(let t of e){let e=YF(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?s.push(t):c.push(t)}let l=[];return a.length>0&&l.push({label:u(`chatSidebarToday`),items:a}),o.length>0&&l.push({label:u(`chatSidebarYesterday`),items:o}),s.length>0&&l.push({label:u(`chatSidebarPrevious7Days`),items:s}),c.length>0&&l.push({label:u(`chatSidebarOlder`),items:c}),l}function QF(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=YF(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||qM(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:XF(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function $F(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>YF(t)-YF(e));return t}function eI(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var tI=[{target:`/cron`,label:()=>u(`chatSidebarScheduledTasks`),icon:Ge},{target:`/skills`,label:()=>u(`chatSidebarSkills`),icon:We},{target:`/agents`,label:()=>u(`agentsPageTitle`),icon:Ue}];function nI(e,t,n){let r=EA(e=>e.optimisticReadAtBySessionKey);return(0,N.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function rI({variant:e=`desktop`}){let t=e===`mobile`,n=Zr(),r=$t(),[i,a]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),l=Z(e=>e.snapshot),d=EA(e=>e.snapshot),p=T(),m=kN(),{isLoading:h,items:g}=HF(),{language:_,setLanguage:v}=tn(),{theme:y,setTheme:b}=it(),x=u(at.find(e=>e.value===y)?.labelKey??`themeWarm`),S=o.find(e=>e.value===_)?.label??_,C=(0,N.useMemo)(()=>at.map(e=>({value:e.value,label:u(e.labelKey)})),[]),w=(0,N.useMemo)(()=>o.map(e=>({value:e.value,label:e.label})),[]),E=(0,N.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),D=(0,N.useMemo)(()=>XF(g),[g]),O=(0,N.useMemo)(()=>$F(g),[g]),ee=(0,N.useMemo)(()=>ZF(D),[D]),k=(0,N.useMemo)(()=>QF(D),[D]),te=l.defaultSessionType||`native`,A=(0,N.useMemo)(()=>l.sessionTypeOptions.filter(e=>e.value!==te),[te,l.sessionTypeOptions]),ne=d.listMode===`project-first`,j=nI(g,d.selectedSessionKey,n.chatSessionListManager.markSessionRead),{editingSessionKey:re,draftLabel:ie,savingSessionKey:ae,setDraftLabel:oe,startEditingSessionLabel:se,cancelEditingSessionLabel:ce,saveSessionLabel:le}=zF(),ue=e=>{_!==e&&(v(e),window.location.reload())},de=e=>(0,P.jsx)(UF,{item:e,selectedSessionKey:d.selectedSessionKey,optimisticReadAtBySessionKey:j,agentsById:E,childSessionsByParentKey:O,editingSessionKey:re,draftLabel:ie,savingSessionKey:ae,sessionTitle:eI,onSelectSession:n.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>n.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:se,onDraftLabelChange:oe,onSaveSessionLabel:le,onCancelEditingSessionLabel:ce},e.session.key),fe=(e,r)=>{n.chatSessionListManager.createSession(e,typeof r==`string`?r:void 0),t&&n.chatUiManager.goToChatRoot()};return(0,P.jsxs)(`aside`,{className:f(`flex h-full min-h-0 flex-col bg-secondary`,t?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!t&&!ot()?(0,P.jsx)(`div`,{className:f(`px-5 pb-3`,rt()?`pt-1.5`:`pt-5`),children:(0,P.jsx)(Qe,{className:`flex min-w-0 items-center gap-2`,suffix:(0,P.jsx)(LF,{status:p.connectionStatus})})}):null,t?(0,P.jsx)(KF,{query:d.query,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:A,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:fe,onQueryChange:n.chatSessionListManager.setQuery}):(0,P.jsx)(GF,{query:d.query,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,nonDefaultSessionTypeOptions:A,isCreateMenuOpen:i,onCreateMenuOpenChange:a,onCreateSession:fe,onQueryChange:n.chatSessionListManager.setQuery}),t?null:(0,P.jsx)(`div`,{className:`px-3 pb-2`,children:(0,P.jsx)(`ul`,{className:`space-y-0.5`,children:tI.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(Ze,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),t?null:(0,P.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,P.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:u(`chatSidebarTaskRecords`)}),(0,P.jsx)(ur,{isProjectFirstView:ne,onSelectMode:n.chatSessionListManager.setListMode})]}),(0,P.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,P.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:u(`sessionsLoading`)}):ne?k.length===0?(0,P.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,P.jsx)(Un,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,P.jsx)(`div`,{className:`text-xs text-gray-500`,children:u(`chatSidebarProjectViewEmpty`)})]}):(0,P.jsx)(jr,{groups:k,defaultSessionType:te,sessionTypeOptions:l.sessionTypeOptions,renderSessionItem:de,onCreateSession:fe}):ee.length===0?(0,P.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,P.jsx)(Un,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,P.jsx)(`div`,{className:`text-xs text-gray-500`,children:u(`sessionsEmpty`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:ee.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(de)})]},e.label))})}),t?null:(0,P.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,P.jsx)(qF,{isOpen:s,onOpenChange:c,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:ue,onOpenDocs:()=>r.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`})})})]})}function iI(){return ge({queryKey:[`ncp-session-types`],queryFn:h,staleTime:1e4,retry:!1})}function aI(e){let t=e.trim();return t.length>0?t:null}function oI(e){return e??null}var sI=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=EA.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:aI(e.selectedModel),preferredThinking:oI(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},cI=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new sI(fe),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>jA(he.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=uA(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:aA(e),selectedSkills:oA(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:aA(e),selectedSkills:oA(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(iA(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=lA(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=lA(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=EA.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=dA(e.composerNodes,i);if(bA({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(rA()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=nP(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(cA(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),mA.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{hA.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},lI=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=EA.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=EA.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=EA.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=EA.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(EA.getState().markSessionRead(r,i),fe(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=KM(t);this.streamActionsManager.resetStreamState(),EA.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.goToChatRoot()},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=EA.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e)},this.setQuery=e=>{let t=EA.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&EA.getState().setSnapshot({query:n})}}},uI=async()=>{},dI=()=>{},fI=class{constructor(){this.actions={sendMessage:uI,stopCurrentRun:uI,resumeRun:uI,resetStreamState:dI,applyHistoryMessages:dI},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},pI=`sid_`;function mI(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${pI}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function hI(e){if(!e.startsWith(pI))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function gI(e){if(!e)return null;let t=hI(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function _I(e){return`/chat/${mI(e)}`}var vI=async e=>!1,yI=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:vI},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`,this.goToSession=(e,t)=>{this.navigateTo(_I(e),t)}}},bI=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{EA.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(EA.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=EA.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||EA.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>nr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=EA.getState();if(e&&await this.uiManager.confirm({title:u(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:u(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await j(e),ee(m,e),m.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},xI=class{constructor(){this.chatUiManager=new yI,this.chatStreamActionsManager=new fI,this.chatSessionListManager=new lI(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new cI(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new bI(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function SI(e){return e?.trim().toLowerCase()||`native`}function CI(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function wI(e,t){return typeof t==`string`&&e.includes(t)}function TI(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function EI(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function DI(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:EI({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>CI(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function OI(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:EI({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>wI(t,e),firstAvailableValue:TI(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function kI(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=SI(r),o,s=-1/0;for(let e of t){if(e.key===n||SI(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function AI(e){return e.map(e=>e==null?``:String(e)).join(``)}function jI(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,N.useRef)(void 0),l=(0,N.useRef)(s),u=(0,N.useRef)(n);l.current=s,(0,N.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function MI(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;jI({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:AI([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>DI({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function NI(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;jI({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:AI([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>OI({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function PI(){let{pathname:e}=ve(),t=xe();return $e(e)?(0,P.jsx)(FF,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,P.jsx)(rI,{variant:`mobile`})}var FI=`NextClaw`,II=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/plugins`,key:`marketplacePluginsPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function LI(e,t){return e===t||e.startsWith(`${t}/`)}function RI(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of II)if(LI(t,e))return u(n);return u(`settings`)}function zI(e){return`${FI} - ${RI(e)}`}function BI({children:e}){let{isOpen:t,mode:n}=$t();nn();let{pathname:r}=ve(),{language:i}=tn(),{isMobile:a}=rr();return(0,N.useEffect)(()=>{document.title=zI(r)},[r,i]),a?(0,P.jsx)(cr,{pathname:r,isDocBrowserOpen:t,children:e}):(0,P.jsx)(ct,{pathname:r,isDocBrowserOpen:t,docBrowserMode:n,children:e})}function VI({children:e}){return(0,P.jsx)(en,{children:(0,P.jsx)(BI,{children:e})})}function HI(){let{isMobile:e}=rr();return e?(0,P.jsx)(lr,{}):(0,P.jsx)(_e,{to:`/model`,replace:!0})}function UI(e){let t=e.trim().toLowerCase();return t?!(t.startsWith(`plugins`)||t.startsWith(`skills`)):!0}function WI(e,t){t.startsWith(`plugins`)&&(e?.invalidateQueries({queryKey:[`ncp-session-types`]}),e?.invalidateQueries({queryKey:[`marketplace-installed`,`plugin`]}),e?.invalidateQueries({queryKey:[`marketplace-items`]})),t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function GI(e,t){e&&UI(t)&&e.invalidateQueries({queryKey:[`config`]}),WI(e,t)}function KI(e){let t=(0,N.useRef)(!1);(0,N.useEffect)(()=>{let n=ae.eventBus.on(p.connectionOpen,()=>{he.handleConnectionRestored(),se.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=ae.eventBus.on(p.connectionClose,()=>{he.handleConnectionInterrupted(null),t.current=!0}),i=ae.eventBus.on(p.connectionError,e=>{he.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=ae.eventBus.on(p.configUpdated,({path:t})=>{GI(e,t)}),o=ae.eventBus.on(p.runtimeUpdateSnapshot,e=>{se.reportSnapshot(e)}),s=ae.eventBus.on(p.sessionRunStatus,t=>{O(e,{type:`session.run-status`,payload:t})}),c=ae.eventBus.on(p.sessionSummaryUpsert,t=>{O(e,{type:`session.summary.upsert`,payload:t})}),l=ae.eventBus.on(p.sessionSummaryDelete,t=>{O(e,{type:`session.summary.delete`,payload:t})}),u=ae.eventBus.on(p.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var qI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ModelConfig:e}=await import(`./model-config-Bg2yycmn.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,5,3,12,13,14,15,9,16,17]))).ModelConfig})),JI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ChatPage:e}=await import(`./chat-page-b7Zf32fF.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,13,14,11,20,21,8,22,23,24,4,25,15,26,1,5,6,7,9,27,28,29,30,31,32,33,34,16,12,35,36,37]))).ChatPage})),YI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SearchConfig:e}=await import(`./search-config-CcKHif8O.js`);return{SearchConfig:e}},__vite__mapDeps([38,2,13,14,11,3,4,6,29,39,16]))).SearchConfig})),XI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ProvidersList:e}=await import(`./providers-list-DC1q3fvC.js`);return{ProvidersList:e}},__vite__mapDeps([40,2,13,14,11,3,22,21,4,29,7,8,39,41,32,27,16,17]))).ProvidersList})),ZI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-DkPvpAqc.js`);return{ChannelsList:e}},__vite__mapDeps([42,2,13,14,11,3,4,5,6,29,33,8,39,32,27,36,16,17]))).ChannelsList})),QI=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-q-nC0C5i.js`);return{RuntimeConfig:e}},__vite__mapDeps([43,2,13,14,11,3,28,19,22,21,4,5,25,29,30,20,8,31,32,33,34,15,26,1,6,7,9,16,37,44,45,41]))).RuntimeConfig})),$I=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-CP8dFYXK.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([46,2,13,14,11,3,25,6,34,44]))).DesktopUpdateConfig})),eL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SecurityConfig:e}=await import(`./api-DGD9_Bg4.js`).then(e=>e.ct);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),tL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-DSg6O92a.js`);return{SecretsConfig:e}},__vite__mapDeps([47,2,13,14,11,3,7,45,16]))).SecretsConfig})),nL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{RemoteAccessPage:e}=await import(`./remote-Dr3jcfWP.js`);return{RemoteAccessPage:e}},__vite__mapDeps([48,30,2,20,14,11,21,8,3,29,31,32]))).RemoteAccessPage})),rL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{MarketplacePage:e}=await import(`./marketplace-page-DkQ2hTs1.js`);return{MarketplacePage:e}},__vite__mapDeps([49,23,2,19,3,11,24,13,14,4,25,15,26,1,5,6,7,8,9,27]))).MarketplacePage})),iL=(0,N.lazy)(async()=>({default:(await ye(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-DSML7NN0.js`);return{McpMarketplacePage:e}},__vite__mapDeps([50,35,2,20,14,11,21,8,3,24,13,15,26,1,4,5,6,7,9,31,36]))).McpMarketplacePage}));function aL(){return(0,P.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function oL({children:e}){return(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(aL,{}),children:e})}function sL(e){return(0,P.jsx)(oL,{children:e})}var cL=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:sL((0,P.jsx)(JI,{view:`chat`}))},{path:`/agents`,element:sL((0,P.jsx)(JI,{view:`agents`}))},{path:`/skills`,element:sL((0,P.jsx)(JI,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:sL((0,P.jsx)(JI,{view:`skills`}))},{path:`/cron`,element:sL((0,P.jsx)(JI,{view:`cron`}))},{path:`/model`,element:sL((0,P.jsx)(qI,{}))},{path:`/search`,element:sL((0,P.jsx)(YI,{}))},{path:`/providers`,element:sL((0,P.jsx)(XI,{}))},{path:`/channels`,element:sL((0,P.jsx)(ZI,{}))},{path:`/runtime`,element:sL((0,P.jsx)(QI,{}))},{path:`/updates`,element:sL((0,P.jsx)($I,{}))},{path:`/remote`,element:sL((0,P.jsx)(nL,{}))},{path:`/security`,element:sL((0,P.jsx)(eL,{}))},{path:`/secrets`,element:sL((0,P.jsx)(tL,{}))},{path:`/language`,element:(0,P.jsx)(tt,{})},{path:`/settings`,element:(0,P.jsx)(HI,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/marketplace/plugins`},{path:`/marketplace/mcp`,element:sL((0,P.jsx)(iL,{}))},{path:`/marketplace/:type`,element:sL((0,P.jsx)(rL,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function lL(e){return`redirectTo`in e?(0,P.jsx)(Ce,{path:e.path,element:(0,P.jsx)(_e,{to:e.redirectTo,replace:!0})},e.path):(0,P.jsx)(Ce,{path:e.path,element:e.element},e.path)}function uL(){return(0,P.jsx)(Te,{children:cL.map(lL)})}function dL(){return KI(m),pe(),(0,N.useEffect)(()=>(se.start(),()=>{se.stop()}),[]),(0,P.jsxs)(Jt,{children:[(0,P.jsx)(VI,{children:(0,P.jsx)(uL,{})}),(0,P.jsx)(Kt,{})]})}function fL(){let e=de(),t=e.isError&&ne(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,P.jsx)(dL,{}):e.data?.enabled&&!e.data.authenticated?(0,P.jsx)(qt,{username:e.data.username}):(0,P.jsx)(dL,{})}function pL(){return(0,N.useEffect)(()=>{st()},[]),(0,P.jsxs)(w,{client:m,children:[(0,P.jsx)(fL,{}),(0,P.jsx)(Xe,{}),(0,P.jsx)(lt,{}),(0,P.jsx)(g,{position:`top-right`,richColors:!0})]})}(0,Qn.createRoot)(document.getElementById(`root`)).render((0,P.jsx)(N.StrictMode,{children:(0,P.jsx)(Ye,{children:(0,P.jsx)(rn,{children:(0,P.jsx)(Se,{children:(0,P.jsx)(pL,{})})})})}));export{Vn as $,DN as A,Z as B,nP as C,kN as D,oP as E,XA as F,Ur as G,Xr as H,tj as I,pr as J,Pr as K,jA as L,SN as M,qM as N,jN as O,KM as P,Hn as Q,NA as R,aP as S,iP as T,Zr as U,Rk as V,Ir as W,Yn as X,rr as Y,Kn as Z,GP as _,xI as a,LP as b,rI as c,hF as d,Bn as et,mF as f,UP as g,uF as h,NI as i,CN as j,AN as k,FF as l,dF as m,kI as n,gI as o,gF as p,Er as q,MI as r,iI as s,PI as t,Rn as tt,TF as u,HP as v,rP as w,VP as x,WP as y,EA as z};
|