@forsion/unit 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.mjs +5 -3
- package/package.json +1 -1
- package/release.json +5 -5
- package/web/assets/{ArtificialView-BSv3Mx5C.js → ArtificialView-XwHMLUFb.js} +1 -1
- package/web/assets/{AutomationBuilder-BuiHtVB-.js → AutomationBuilder-hqs0QhMt.js} +1 -1
- package/web/assets/{CalendarConfigView-BJtG6cqN.js → CalendarConfigView-DKib8Oed.js} +1 -1
- package/web/assets/{CalendarView-C-FX1RED.js → CalendarView-DJ5iOzvu.js} +1 -1
- package/web/assets/{CapabilityMenu-kx1TIJYN.js → CapabilityMenu-SwVlZ06x.js} +1 -1
- package/web/assets/{CheckboxInput-eW7xdiRS.js → CheckboxInput-BC-5a_C9.js} +1 -1
- package/web/assets/{Chrome-B77-lQyh.js → Chrome-HdfyYV3i.js} +1 -1
- package/web/assets/{CodeView-Df3AiSIi.js → CodeView-CFL6yQ-6.js} +3 -3
- package/web/assets/{DashboardGridView-MlO1dpuo.js → DashboardGridView-B9DCWYVb.js} +12 -12
- package/web/assets/{EventCard-CDmeCbI8.js → EventCard-B_ndpqH_.js} +1 -1
- package/web/assets/{ExcalidrawCanvas-D9vkBh_5.js → ExcalidrawCanvas-BQ4KKLJP.js} +1 -1
- package/web/assets/{FloatingToc-tART_jC4.js → FloatingToc-Ce9GamvH.js} +1 -1
- package/web/assets/{HomepageView-Trqmd3RV.js → HomepageView-RCOfcVbE.js} +1 -1
- package/web/assets/{ImageStudioPanels-BfCVTnKC.js → ImageStudioPanels-lkS_y2uM.js} +2 -2
- package/web/assets/{ImageStudioView-KJhx0wJk.js → ImageStudioView-UPv52acl.js} +1 -1
- package/web/assets/{InlineFiles-BHwivGbQ.js → InlineFiles-CQbQumkf.js} +1 -1
- package/web/assets/{MarkdownBlock-D8LgHFYY.js → MarkdownBlock-CkqiwPXa.js} +19 -19
- package/web/assets/{ModelPill-DrW2cG0l.js → ModelPill-CY-rU1RU.js} +2 -2
- package/web/assets/{MuseLibraryView-CW78Uivf.js → MuseLibraryView-CtTHlVnT.js} +2 -2
- package/web/assets/{MuseView-Cb6R_l4i.js → MuseView-CC2A7MBs.js} +2 -2
- package/web/assets/{PageHistoryPanel-BQs9IWTP.js → PageHistoryPanel-KhKT1DLy.js} +2 -2
- package/web/assets/{PdfAnnotator-BFTBkxvO.js → PdfAnnotator-DUyrgY-t.js} +1 -1
- package/web/assets/{ProductView-mB-S0j81.js → ProductView-CgsIYZqD.js} +1 -1
- package/web/assets/{RightPanel-BVZeVO3c.js → RightPanel-BHDgqTFs.js} +3 -3
- package/web/assets/RunLocationPicker-DBnXYV5B.js +38 -0
- package/web/assets/{SidebarRow-D77yrSLf.js → SidebarRow-BAJxbMcx.js} +1 -1
- package/web/assets/{SketchCard-CAAr_cqF.js → SketchCard-BGYz-bXP.js} +1 -1
- package/web/assets/{StudioGuestSurface-DthpuVGg.js → StudioGuestSurface-lt6znmkl.js} +1 -1
- package/web/assets/{TodoListView-C3ZkMIIf.js → TodoListView-DPKhee6i.js} +1 -1
- package/web/assets/{Tooltip-D9Dt9ZTr.js → Tooltip-ZxrDqN4p.js} +1 -1
- package/web/assets/{UnifiedPage-C75y-MKT.js → UnifiedPage-BX6ZQL0h.js} +27 -27
- package/web/assets/{amadeus-manual.en-D5wZKuag.js → amadeus-manual.en-DzRWr4BL.js} +15 -15
- package/web/assets/{amadeus-manual.zh-Br5fidrj.js → amadeus-manual.zh-DW32DkL7.js} +15 -15
- package/web/assets/{appStore-B1ynyt42.js → appStore-DWP8UET9.js} +99 -79
- package/web/assets/appStore-wtOILggO.css +1 -0
- package/web/assets/{arrow-up-right-R10mR2I6.js → arrow-up-right-DrCXuWS7.js} +1 -1
- package/web/assets/{astryxBridge-CU_kQTEl.js → astryxBridge-D-m4_kYt.js} +3 -3
- package/web/assets/{automationListSource-B8EIRmDW.js → automationListSource-C8BNy6RY.js} +1 -1
- package/web/assets/{book-open-DBJ3dDpw.js → book-open-OLNm7OaB.js} +1 -1
- package/web/assets/{calendarNavStore-DGvUlU5N.js → calendarNavStore-Cylfvv3s.js} +1 -1
- package/web/assets/{canvasPrefs-DwL_OAAo.js → canvasPrefs-8taQ42Cz.js} +1 -1
- package/web/assets/{chatBoxSurface-Lq-2qfd3.js → chatBoxSurface-CIlzs45H.js} +1 -1
- package/web/assets/{circle-question-mark-HPZpZQxd.js → circle-question-mark-XbAFplz1.js} +1 -1
- package/web/assets/{circle-x-BZfe7d6S.js → circle-x-fcReAZaE.js} +1 -1
- package/web/assets/{client-DxGbwZLy.js → client-0MPbodA6.js} +1 -1
- package/web/assets/{code-xml-joKQ-qGS.js → code-xml-Cuna8Kh4.js} +1 -1
- package/web/assets/{codeStudioStore-C7rGKlOC.js → codeStudioStore-BBU62GTy.js} +1 -1
- package/web/assets/{codingNavigation-CjeWG4xm.js → codingNavigation-DDlPpPk5.js} +7 -7
- package/web/assets/{create-BjBRKATq.js → create-BGtEfCcg.js} +2 -2
- package/web/assets/{dashboardSurface-Cojgf_-U.js → dashboardSurface-BYM3C7WG.js} +1 -1
- package/web/assets/{deskCapture-DnGWk1iq.js → deskCapture-BiUCmqfc.js} +1 -1
- package/web/assets/{diff2html-Cd1rVi_Z.js → diff2html-BNp2FTbk.js} +1 -1
- package/web/assets/{docx-preview-CK0k1mUD.js → docx-preview-CFznGVOU.js} +1 -1
- package/web/assets/{emoji-Cjm3bKiF.js → emoji-6zl4yfOS.js} +1 -1
- package/web/assets/{floatingTocSurface-Dd1pT5j5.js → floatingTocSurface-DreXPCa6.js} +1 -1
- package/web/assets/{foldActions-Dm-uAt3L.js → foldActions-05QcQziQ.js} +1 -1
- package/web/assets/{folder-CvZyHIgb.js → folder-BpsfOHD4.js} +1 -1
- package/web/assets/{folder-plus-BRScGQ9m.js → folder-plus-BeQHr4AZ.js} +1 -1
- package/web/assets/{gestures-CZQVefU0.js → gestures-DQBCcK4y.js} +1 -1
- package/web/assets/{hand-D3QspKYq.js → hand-Bko7ms15.js} +1 -1
- package/web/assets/{hard-drive-BQsHSala.js → hard-drive-BpuI5ebj.js} +1 -1
- package/web/assets/{i18n.generated-BZRHO2Nc.js → i18n.generated-BuLjnmY8.js} +1 -1
- package/web/assets/{imageStudio-Cy3_437s.js → imageStudio-BLVNKmEG.js} +2 -2
- package/web/assets/{index-BPhwi4-v.js → index-BF10xp_K.js} +1 -1
- package/web/assets/{index-GjLSlygt.js → index-BHm6K743.js} +1 -1
- package/web/assets/{index-Bh_nLVTc.js → index-BM2o7PeV.js} +5 -5
- package/web/assets/{index-BcVGjCAJ.js → index-BgnNNv3e.js} +1 -1
- package/web/assets/{index-CcOag8eb.js → index-C0Gy2NQ6.js} +1 -1
- package/web/assets/{index-0AYHATDX.js → index-C1doZp5H.js} +1 -1
- package/web/assets/{index-9BmmlTjY.js → index-C4L6vjd_.js} +1 -1
- package/web/assets/{index-8ag1K7AZ.js → index-CD3yIkOA.js} +1 -1
- package/web/assets/{index-Dkd-nl1u.js → index-CJeUgjPU.js} +1 -1
- package/web/assets/{index-B5GxvbNm.js → index-CLHoq1w-.js} +1 -1
- package/web/assets/{index-DElrDw66.js → index-CUZI62qU.js} +1 -1
- package/web/assets/{index-BgtO11q8.js → index-Cff42k7q.js} +1 -1
- package/web/assets/{index-Dj-PygjB.js → index-Ck_O3Jdd.js} +1 -1
- package/web/assets/index-CuiYK18N.js +1 -0
- package/web/assets/{index-Bpc3R3DS.js → index-CwcOeZdT.js} +1 -1
- package/web/assets/{index-DJLWTPtq.js → index-D6AycQIz.js} +1 -1
- package/web/assets/{index-C9yo04Ck.js → index-D7gVhvNY.js} +1 -1
- package/web/assets/{index-BnWj6ggb.js → index-D9UZQy42.js} +1 -1
- package/web/assets/{index-D6mpAJ9S.js → index-DuBQ0j2g.js} +1 -1
- package/web/assets/{index-1FhRiJ_X.js → index-OD1gSX3h.js} +1 -1
- package/web/assets/{index-DNE_PBJt.js → index-Uo5tswys.js} +1 -1
- package/web/assets/{index-BgDZGDqt.js → index-o8cj0pRH.js} +1 -1
- package/web/assets/{index-BdZaheMZ.js → index-rHjhbwvm.js} +1 -1
- package/web/assets/{index-4E9nrhwf.js → index-rggq2czF.js} +1 -1
- package/web/assets/{index-D0FLFLfh.js → index-sCXThwqZ.js} +1 -1
- package/web/assets/{invitePage-B4gMvEKi.js → invitePage-b0HGvMj6.js} +1 -1
- package/web/assets/{ipc-CPhL3bPp.js → ipc-CxAyeo8q.js} +1 -1
- package/web/assets/{jszip.min-DAJT9RUA.js → jszip.min-B94KpE21.js} +1 -1
- package/web/assets/{layout-grid-DfUfnvDS.js → layout-grid-BBVuEdWG.js} +1 -1
- package/web/assets/{linkFollow-C6PHGUxk.js → linkFollow-B7ivDZMM.js} +5 -5
- package/web/assets/{list-tree-DaGpnIYu.js → list-tree-4-0QDbLu.js} +1 -1
- package/web/assets/{listFold-Q_8mh5ZG.js → listFold-DLuxXiIj.js} +1 -1
- package/web/assets/{lock-DQ_yL4nF.js → lock-CnbZm4vo.js} +1 -1
- package/web/assets/{log-out-DFwTeh2X.js → log-out-BEynWaHa.js} +1 -1
- package/web/assets/{main-NgUPPqDn.css → main-BiS_5wrB.css} +1 -1
- package/web/assets/main-sIq2N9Z5.js +20 -0
- package/web/assets/{markdownEditorSurface-e_oMhqx-.js → markdownEditorSurface-ZSJ3RHAv.js} +1 -1
- package/web/assets/{mdMarkStore-DjN4bf1T.js → mdMarkStore-DQHDjG7s.js} +2 -2
- package/web/assets/{mdMarks-cmL6vzR-.js → mdMarks-DbIcRa0O.js} +1 -1
- package/web/assets/{message-square-plus-CEHkduIL.js → message-square-plus-CpiKDvle.js} +1 -1
- package/web/assets/{messages-CBtmbpur.js → messages-_jta1lSI.js} +1 -1
- package/web/assets/minus-C9ndHJ9O.js +1 -0
- package/web/assets/{mobileEntry-qR7BAROr.js → mobileEntry-CPmU_c4m.js} +1 -1
- package/web/assets/{nativeDownload-CziEyW_p.js → nativeDownload-BYT082bY.js} +1 -1
- package/web/assets/{pageChrome-DFz_AAzZ.js → pageChrome-D3Niv1JM.js} +1 -1
- package/web/assets/{pageTree-yVO1_fSy.js → pageTree-CgfvpzIj.js} +1 -1
- package/web/assets/{pen-tool-uxsFELYC.js → pen-tool-BXEFnU2i.js} +1 -1
- package/web/assets/{pencil-BSbra1Ra.js → pencil-cqvCkekG.js} +1 -1
- package/web/assets/pluginChat-BbBukMuN.js +2 -0
- package/web/assets/{redo-2-BK5LMNa5.js → redo-2-BO7wCDwy.js} +1 -1
- package/web/assets/{rotate-ccw-HedfU4na.js → rotate-ccw-BvipPIjC.js} +1 -1
- package/web/assets/{sharePage-CpzDpuU1.js → sharePage-XbN50US7.js} +2 -2
- package/web/assets/{shareViewer-BwzH2bIs.js → shareViewer-BaYogetW.js} +1 -1
- package/web/assets/{star-CgYon3z4.js → star-BQWMXnn7.js} +1 -1
- package/web/assets/tableSurface-BXqqidd1.js +1 -0
- package/web/assets/{terminal-krsPf1mc.js → terminal-l9k6RDrH.js} +1 -1
- package/web/assets/{terminalView-4e2_u5_I.js → terminalView-Cpnt5_0P.js} +1 -1
- package/web/assets/{type-GJYLEhY-.js → type-CFoaj2eD.js} +1 -1
- package/web/assets/{undo-2-DCTs4Ro4.js → undo-2-DusxpdLa.js} +1 -1
- package/web/assets/{unitAccount-D3xjX3cu.js → unitAccount-DwutFPPw.js} +1 -1
- package/web/assets/{unitBridge-D5JcIkAP.js → unitBridge-CcgQpkqV.js} +1 -1
- package/web/assets/{unitCloudTransport-B44L3x6M.js → unitCloudTransport-vA7cLDts.js} +1 -1
- package/web/assets/{unitOwnerAccess-CRUHWGpf.js → unitOwnerAccess-LBlJ1YfA.js} +1 -1
- package/web/assets/{unitShim-_VzxvdEG.js → unitShim-B_M9IrbC.js} +3 -3
- package/web/assets/{upload-MVVRQtkj.js → upload-ZrOj6tXA.js} +1 -1
- package/web/assets/{userSpaces-CI4eqEgh.js → userSpaces-uJOnsedR.js} +1 -1
- package/web/assets/viewportLock-D3SNkwS2.js +631 -0
- package/web/assets/{workflow-DzeW9OXR.js → workflow-DPoG4QE2.js} +1 -1
- package/web/assets/{zoom-in-CovPsw4g.js → zoom-in-lbTgzdQP.js} +1 -1
- package/web/index.html +27 -7
- package/web/assets/RunLocationPicker-CyVa0RJa.js +0 -38
- package/web/assets/appStore-BC_CQv-L.css +0 -1
- package/web/assets/index-BaRySZ-M.js +0 -1
- package/web/assets/main-CwqZ_ymb.js +0 -19
- package/web/assets/minus-BUT48dAC.js +0 -1
- package/web/assets/pluginChat-BMFnf_j2.js +0 -2
- package/web/assets/tableSurface-CmDwnKnd.js +0 -1
- package/web/assets/viewportLock-BH26xHQO.js +0 -611
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{d as u,t as Re,r as xe,j as t,u as Ce,T as Pn,R as gn,M as jr,N as Sr,O as Nr,v as ri}from"./index-BM2o7PeV.js";import{F as We,u as D,lB as Cr,s as ot,lC as zr,lD as Mr,lE as Ar,K as Ki,lF as Er,aM as Kt,cO as Yi,bH as Tr,bp as ta,ff as Xi,U as $s,aE as it,aJ as rt,bJ as Ls,aq as Bn,kO as Rr,lG as Ir,lH as $r,lI as Lr,kP as Pr,kW as Dr,kX as _r,lJ as Or,lK as Fr,lL as Wr,ft as Yt,p as Dn,b as mn,ed as Un,ao as ci,aB as gs,bf as Br,X as Ur,Y as qr,as as xn,aP as Ht,c5 as Et,R as Ji,ag as Gi,lM as Zi,ij as Hr,Z as na,G as vs,lN as Vr,aI as Xn,b0 as Kr,lO as Yr,cL as Xr,i6 as Jr,i2 as li,cp as Gr,lP as Zr,kV as Qr,h as ec,bF as tc,dY as nc,e6 as sc,ek as ac,kI as ui,cN as ic,a2 as oc,lQ as rc,lR as cc,lS as lc,lm as uc,cP as dc,lT as ys,lU as Qi,lV as pc,lW as hc,lX as mc,kn as fc,ci as di,ch as gc,ar as qn,lY as vc,aS as yc,lZ as kc,hm as xc,l_ as wc,T as eo,hr as pi,cr as Vt,cq as bc,H as jc,l$ as Sc,hp as Tt,m0 as Nc,m1 as Cc,m2 as Xt,lq as wn,bB as zc,hN as Mc,m3 as hi,n as ks,m4 as bn,lo as vn,m5 as to,m6 as sa,ku as Ac,a5 as Hn,aa as no,bC as so,hU as Ec,hS as Tc,m7 as Rc,m8 as Ic,gT as aa,o as $c,f as Lc,m9 as ao,c as Pc,g as Dc,l6 as io,ma as _c,ie as Oc,dl as mi,gU as xs,ah as Ps,cd as Fc,e0 as Wc,mb as Bc,mc as Uc,md as qc,a4 as Hc,al as Vc,iy as oo,e7 as ro,lj as fi,lk as Kc}from"./appStore-DWP8UET9.js";import{u as gi,n as vi}from"./codeStudioStore-BBU62GTy.js";import{a as Yc,u as yi,C as Xc,j as Jc}from"./RightPanel-BHDgqTFs.js";import{c as Jn,n as Rn}from"./nativeDownload-BYT082bY.js";import"./client-0MPbodA6.js";import{t as Ds,c as Gc,g as Zc,a as Qc}from"./ModelPill-CY-rU1RU.js";import{P as Vn}from"./pencil-cqvCkekG.js";import{c as el,D as tl}from"./create-BGtEfCcg.js";import{S as nl,W as sl}from"./approvalText-Cy2UAUAQ.js";import{c as al,C as il,g as ol,t as co,u as rl,A as cl,m as ll,d as ul,S as dl,P as ws,a as pl,f as lo,b as uo}from"./SidebarRow-BAJxbMcx.js";import{M as hl}from"./message-square-plus-CpiKDvle.js";import{F as Kn}from"./folder-BpsfOHD4.js";import{H as ml}from"./hand-Bko7ms15.js";import{F as po}from"./folder-plus-BeQHr4AZ.js";import{i as fl}from"./ipc-CxAyeo8q.js";import{a as gl,S as ho,I as vl}from"./pageChrome-D3Niv1JM.js";const yl=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],kl=We("archive-restore",yl);const xl=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],_s=We("archive",xl);const wl=[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]],bl=We("audio-lines",wl);const jl=[["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"}]],ki=We("folder-x",jl);const Sl=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Nl=We("notebook-pen",Sl);const Cl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],_n=We("panels-top-left",Cl);const zl=[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]],Ml=We("paw-print",zl);const Al=[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]],El=We("pi",Al);const Tl=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Rl=We("pin-off",Tl);const Il=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$l=We("shield-question-mark",Il);const Ll=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],mo=We("user-plus",Ll);const Pl=[["path",{d:"M2 12q2.5 2 5 0t5 0 5 0 5 0",key:"8ddzzs"}],["path",{d:"M2 19q2.5 2 5 0t5 0 5 0 5 0",key:"1wj4st"}],["path",{d:"M2 5q2.5 2 5 0t5 0 5 0 5 0",key:"69x50u"}]],Dl=We("waves-horizontal",Pl);function ia(e,n={}){return!1}function Os(e,n,a){const[o,i]=u.useState(null),c=u.useRef({build:n,onClose:a});c.current={build:n,onClose:a};const r=e!=null&&e!==!1,l=r&&o!==e&&!1;return u.useEffect(()=>{if(!r){o!==null&&i(null);return}},[e,o,r]),!l}let dn=null,bs=null;function _l(e){const n=D.getState().tr;return n(`channel.name.${e}`)}function Ol(e){const n=e.filter(i=>i.enabled&&i.workspace).map(i=>({key:i.workspace,name:_l(i.kind),kind:"channel",channel:i.kind,path:i.workspace,system:!0})),a=D.getState().channelWorkspaces;a.length===n.length&&a.every((i,c)=>i.key===n[c].key&&i.name===n[c].name&&i.channel===n[c].channel)||D.setState({channelWorkspaces:n})}const Fl=Jn((e,n)=>({channels:[],available:!1,loaded:!1,refresh:async()=>{if(window.tangu?.backendStatus)try{const a=await Ar(ot()),o=Array.isArray(a.channels)?a.channels:[];e({channels:o,available:!!a.available,loaded:!0}),Ol(o)}catch{}},save:async(a,o)=>{await Mr(ot(),a,o),await n().refresh()},connect:async a=>{const o=await zr(ot(),a);return await n().refresh(),D.getState().refreshSessions(D.getState().cfg),o},disconnect:async(a,o)=>{await Cr(ot(),a,o),await n().refresh()},startPolling:()=>{if(dn!=null)return;const a=()=>{D.getState().connState==="ok"&&n().refresh()};dn=window.setInterval(a,15e3);let o=D.getState().connState;bs=D.subscribe(i=>{i.connState==="ok"&&o!=="ok"&&n().refresh(),o=i.connState}),a()},stopPolling:()=>{dn!=null&&(window.clearInterval(dn),dn=null),bs?.(),bs=null}}));xe({"voiceinput.silent":{zh:"没采集到声音(输入电平≈0):检查系统输入设备是否选对、麦克风没被静音",en:"No audio captured (input level ≈ 0): check that the right input device is selected and that the microphone is not muted"},"voiceinput.unsupported":{zh:"此环境不支持语音输入",en:"Voice input is not supported in this environment"},"voiceinput.denied":{zh:"麦克风权限被拒绝(打开 系统设置 › 隐私与安全 › 麦克风,允许本 App)",en:"Microphone access was denied (open System Settings › Privacy & Security › Microphone and allow this app)"},"voiceinput.silentPhone":{zh:"没录到声音,再试一次",en:"No sound was recorded — try again"},"voiceinput.deniedPhone":{zh:"麦克风权限被拒绝(到系统设置 › 应用 › 权限里允许麦克风)",en:"Microphone access was denied (allow it in system Settings › Apps › Permissions)"},"voiceinput.noDevice":{zh:"没检测到麦克风设备",en:"No microphone found"},"voiceinput.openFailed":{zh:"麦克风打不开:{e}",en:"Could not open the microphone: {e}"},"voiceinput.unclear":{zh:"没听清,再试一次",en:"Didn't catch that — try again"}});async function Wl(e){const n=await e.arrayBuffer(),a=new AudioContext,o=await a.decodeAudioData(n);await a.close();const i=Math.max(1,Math.round(o.duration*16e3)),c=new OfflineAudioContext(1,i,16e3),r=c.createBufferSource();r.buffer=o,r.connect(c.destination),r.start();const l=(await c.startRendering()).getChannelData(0);let p=0,h=0;for(let f=0;f<l.length;f++){const x=Math.abs(l[f]);x>p&&(p=x),h+=l[f]*l[f]}if(console.warn(`[voice] captured ${l.length} samples @16k, ${(l.length/16e3).toFixed(2)}s, peak=${p.toFixed(4)} rms=${Math.sqrt(h/(l.length||1)).toFixed(4)}`),p<.005)throw new Error(window.tangu?.mobile?Re("voiceinput.silentPhone"):Re("voiceinput.silent"));return Bl(l,16e3)}function Bl(e,n){const a=e.length,o=new ArrayBuffer(44+a*2),i=new DataView(o),c=(h,f)=>{for(let x=0;x<f.length;x++)i.setUint8(h+x,f.charCodeAt(x))};c(0,"RIFF"),i.setUint32(4,36+a*2,!0),c(8,"WAVE"),c(12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,n,!0),i.setUint32(28,n*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),c(36,"data"),i.setUint32(40,a*2,!0);for(let h=0;h<a;h++){const f=Math.max(-1,Math.min(1,e[h]));i.setInt16(44+h*2,f<0?f*32768:f*32767,!0)}const r=new Uint8Array(o);let l="";const p=32768;for(let h=0;h<r.length;h+=p)l+=String.fromCharCode(...r.subarray(h,h+p));return btoa(l)}function Ul(e,n){const[a,o]=u.useState(!1),[i,c]=u.useState(!1),[r,l]=u.useState(null),p=u.useRef(null),h=u.useRef([]),f=u.useRef(!1),[x,w]=u.useState(null),A=u.useRef(null),E=u.useCallback(()=>{w(null),A.current?.close().catch(()=>{}),A.current=null},[]);u.useEffect(()=>E,[E]);const M=typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u"&&!!window.tangu?.transcribeAudio,z=u.useCallback(U=>{f.current=U,p.current?.stop()},[]),B=u.useCallback(async()=>{if(l(null),!M){l(Re("voiceinput.unsupported"));return}let U;try{U=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(C){console.warn("[voice] getUserMedia failed:",C?.name,C?.message||C),l(C?.name==="NotAllowedError"?window.tangu?.mobile?Re("voiceinput.deniedPhone"):Re("voiceinput.denied"):C?.name==="NotFoundError"?Re("voiceinput.noDevice"):Re("voiceinput.openFailed",{e:C?.name||C?.message||C}));return}try{const C=new AudioContext,g=C.createAnalyser();g.fftSize=128,g.smoothingTimeConstant=.7,C.createMediaStreamSource(U).connect(g),A.current=C,w(g)}catch{}const G=new MediaRecorder(U);p.current=G,h.current=[],f.current=!1,G.ondataavailable=C=>{C.data.size&&h.current.push(C.data)},G.onstop=async()=>{if(U.getTracks().forEach(g=>g.stop()),E(),o(!1),p.current=null,f.current||!h.current.length)return;const C=new Blob(h.current,{type:G.mimeType||"audio/webm"});c(!0);try{const g=await window.tangu.transcribeAudio({audioBase64:await Wl(C),mime:"audio/wav",modelId:n});g?e(g):l(Re("voiceinput.unclear"))}catch(g){console.warn("[voice] transcribe failed:",g?.message||g),l(g?.message||String(g))}finally{c(!1)}},G.start(),o(!0)},[M,n,e,E]),_=u.useCallback(()=>{i||(a?z(!1):B())},[i,a,B,z]),L=u.useCallback(()=>{a&&z(!0)},[a,z]);return{recording:a,busy:i,error:r,toggle:_,cancel:L,supported:M,analyser:x}}const ql=({size:e})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10.931 3.34a.112.112 0 0 0-.069-.104l-.038-.007c-1.537.05-2.45.318-3.714 1.002v6.683c.48-.248.936-.44 1.414-.58.695-.203 1.417-.292 2.303-.305l.038-.008a.113.113 0 0 0 .066-.104V3.341ZM2.363 9.919c0 .064.051.11.105.111l.33.008c1.162.046 2.042.243 2.975.662-.403-.585-1.008-1.075-1.654-1.292a.991.991 0 0 1-.674-.941v-5.14a6.36 6.36 0 0 0-.59-.076l-.37-.02a.115.115 0 0 0-.122.111v6.577Zm9.455-.001a.998.998 0 0 1-.877.992l-.101.007c-.832.012-1.47.095-2.066.27-.599.174-1.176.448-1.883.863a.444.444 0 0 1-.449 0c-1.299-.763-2.229-1.07-3.689-1.125l-.299-.008a.997.997 0 0 1-.977-.998V3.342c0-.573.478-1.017 1.038-.999l.417.023c.188.015.35.037.513.062v-.754c0-.708.749-1.244 1.429-.903.984.492 1.836 1.449 2.15 2.505 1.216-.617 2.222-.884 3.771-.934l.105.003a.998.998 0 0 1 .918.996v6.576ZM4.332 8.466c0 .049.03.087.07.1l.24.091a4.319 4.319 0 0 1 1.581 1.176V3.721c-.164-.803-.799-1.617-1.584-2.07l-.162-.088c-.025-.012-.054-.013-.088.009a.12.12 0 0 0-.057.102v6.792Z"})}),Hl=({size:e})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"})}),xi=({engineId:e,size:n=16})=>{const a=e.toLowerCase();return a.includes("claude")?t.jsx(Hl,{size:n}):a.includes("codex")||a.includes("openai")?t.jsx(ql,{size:n}):a.includes("claw")?t.jsx(Ml,{size:n}):a==="pi"||a.startsWith("pi-")?t.jsx(El,{size:n}):a.includes("dsh")||a.includes("deepseek")?t.jsx(Dl,{size:n}):t.jsx(Ki,{size:n})},Fs="forsion_voice_call_voice",Vl=50,Kl=1e3,Yl=300,Xl=2500;function wi(e){try{e?localStorage.setItem(Fs,JSON.stringify({...e,t:Date.now()})):localStorage.removeItem(Fs)}catch{}}let tt=null,fo=0,bi,ji=!1;const Ws=new Set;function go(e){clearTimeout(bi);let n=null;try{n=e?JSON.parse(e):null}catch{n=null}const a=tt;if(n&&typeof n.sessionId=="string"&&typeof n.phase=="string"){const o=a?.sessionId===n.sessionId&&a.phase===n.phase;tt={sessionId:n.sessionId,phase:n.phase,level:Math.min(1,Math.max(0,Number(n.level)||0)),since:o?a.since:Date.now()},fo=Date.now(),bi=setTimeout(()=>go(null),Xl)}else tt=null;(a?.sessionId!==tt?.sessionId||a?.phase!==tt?.phase)&&Ws.forEach(o=>o())}function vo(){ji||typeof window>"u"||typeof window.addEventListener!="function"||(ji=!0,window.addEventListener("storage",e=>{(e.key===Fs||e.key===null)&&go(e.key?e.newValue:null)}))}function up(){return vo(),tt&&tt.level>0&&Date.now()-fo>Yl&&(tt={...tt,level:0}),tt}function dp(e){return vo(),Ws.add(e),()=>{Ws.delete(e)}}const Jl="forsion_realtime_cfg_rev";let On={model:"",voice:""},Si=!1;const Bs=new Set;function js(){window.tangu?.getConfig?.().then(e=>{const n={model:e.realtimeModelId?.trim()||"",voice:e.realtimeVoice?.trim()||""};n.model===On.model&&n.voice===On.voice||(On=n,Bs.forEach(a=>a()))}).catch(()=>{})}function Gl(){return u.useSyncExternalStore(e=>(Si||(Si=!0,js(),window.addEventListener("storage",n=>{n.key===Jl&&js()}),window.addEventListener("focus",js)),Bs.add(e),()=>{Bs.delete(e)}),()=>On)}const yo="forsion_voice_call_evt";function Zl(e){try{localStorage.setItem(yo,JSON.stringify({...e,n:`${Date.now()}-${Math.random()}`}))}catch{}}const Yn="forsion_voice_call_active",Fn=new Set;let Ni=!1;function Ql(e){try{e?localStorage.setItem(Yn,e):localStorage.removeItem(Yn)}catch{}Fn.forEach(n=>n())}function ko(){try{return localStorage.getItem(Yn)}catch{return null}}function eu(e){return Ni||(Ni=!0,window.addEventListener("storage",n=>{(n.key===Yn||n.key===null)&&Fn.forEach(a=>a())})),Fn.add(e),()=>{Fn.delete(e)}}const tu=4e3,pp=1500;function nu(e,n,a=2e3){const o=`${Date.now()}-${Math.random()}`;return new Promise(i=>{const c=xo(l=>{l.kind==="text-ack"&&l.id===o&&(c(),clearTimeout(r),i(!0))}),r=setTimeout(()=>{c(),ko()===e&&Ql(null),i(!1)},a);Zl({kind:"text",sessionId:e,text:n,id:o,at:Date.now()})})}function xo(e){const n=a=>{if(!(a.key!==yo||!a.newValue))try{e(JSON.parse(a.newValue))}catch{}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}const su=.04,Ci=24e3;let je=null,Us=null;const qs=new Set;let Wn=null,Jt=null;const Hs=()=>qs.forEach(e=>e()),wo=e=>{je&&(je={...je,...e},Hs())};function hp(e){return qs.add(e),()=>{qs.delete(e)}}const mp=()=>je,fp=()=>Us;function au(e){Wn?.(e)}function gp(){je&&wo({muted:!je.muted})}const vp=e=>Jt?.mic(e)??Promise.resolve(),yp=e=>Jt?.speaker(e)??Promise.resolve(),kp=e=>Jt?.run(e),xp=e=>Jt?.text(e)??!1;async function wp(e){je&&au(),Us=null,je={sessionId:e.sessionId,phase:"connecting",muted:!1,working:null,analyser:null,connectedAt:null},Hs();let n=null,a=null;const o=new AudioContext({sampleRate:16e3}),i=new AudioContext({sampleRate:Ci}),c=o.createAnalyser(),r=i.createAnalyser();r.connect(i.destination);const l=new Set;let p=0,h=!1,f=null,x=null;const w=F=>({echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1,...F?{deviceId:F}:{}}),A=()=>{f=o.createMediaStreamSource(n),f.connect(c),x&&f.connect(x)},E=F=>(i.setSinkId?.(F)??Promise.resolve()).catch(P=>console.warn("[realtime] setSinkId failed:",P)),M=F=>{h||wo(F)},z=(F=500)=>{e.onActivity&&window.setTimeout(e.onActivity,F)},B=()=>{l.forEach(F=>{try{F.stop()}catch{}}),l.clear(),p=0},_=F=>{const P=new Int16Array(F,0,F.byteLength>>1);if(!P.length)return;const $=i.createBuffer(1,P.length,Ci),W=$.getChannelData(0);for(let Z=0;Z<P.length;Z++)W[Z]=P[Z]/32768;const K=i.createBufferSource();K.buffer=$,K.connect(r);const Q=Math.max(i.currentTime+.05,p);K.start(Q),p=Q+$.duration,l.add(K),K.onended=()=>{l.delete(K),!l.size&&je?.phase==="speaking"&&M({phase:"listening",analyser:c})},je?.phase!=="speaking"&&M({phase:"speaking",analyser:r})},L=new Uint8Array(r.fftSize);let U="",G=0;const C=window.setInterval(()=>{if(h||!je)return;const F=l.size>0,P=F?"speaking":je.phase,$=Date.now();if(!F&&P===U&&$-G<Kl)return;let W=0;if(F){r.getByteTimeDomainData(L);const K=L.length>>1;let Q=0;for(let Z=K;Z<L.length;Z++){const R=(L[Z]-128)/128;Q+=R*R}W=Math.min(1,Math.sqrt(Q/(L.length-K))*4)}U=P,G=$,wi({sessionId:e.sessionId,phase:P,level:W})},Vl),g=()=>wi(null);window.addEventListener("pagehide",g);const O=F=>{if(h)return;h=!0;const P=Wn===O;P&&(Wn=null),window.clearInterval(C),window.removeEventListener("pagehide",g),P&&g(),B();try{a?.close()}catch{}n?.getTracks().forEach($=>$.stop()),o.close().catch(()=>{}),i.close().catch(()=>{}),P&&(Jt=null,Us=F||null,je=null,Hs()),z(300)};Wn=O,Jt={mic:async F=>{const P=await navigator.mediaDevices.getUserMedia({audio:w(F)});if(h){P.getTracks().forEach($=>$.stop());return}f?.disconnect(),n?.getTracks().forEach($=>$.stop()),n=P,f&&A()},speaker:E,run:F=>{e.run=F,a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"run",run:F}))},text:F=>h||!je?.connectedAt||je.phase==="reconnecting"||a?.readyState!==WebSocket.OPEN?!1:(B(),M({phase:"thinking",analyser:c}),a.send(JSON.stringify({type:"text",text:F})),z(),!0)};try{if(n=await navigator.mediaDevices.getUserMedia({audio:w(e.micId)}),h){n.getTracks().forEach(P=>P.stop());return}e.speakerId&&await E(e.speakerId);const F=await Er(e.target);if(h)return;a=new WebSocket(F),a.binaryType="arraybuffer"}catch(F){O(F?.message||String(F));return}const Y=a;Y.onopen=()=>Y.send(JSON.stringify({type:"start",session_id:e.sessionId,model:e.model,voice:e.voice||void 0,title:e.title,run:e.run})),Y.onclose=F=>O(F.reason||(F.code===1e3?void 0:`connection closed (${F.code})`)),Y.onmessage=F=>{if(h)return;if(F.data instanceof ArrayBuffer){_(F.data);return}let P;try{P=JSON.parse(String(F.data))}catch{return}switch(P.type){case"ready":{if(x){M(l.size?{phase:"speaking",analyser:r}:{phase:"listening",analyser:c});break}x=o.createScriptProcessor(1024,1,1),x.connect(o.destination),x.onaudioprocess=$=>{if(h||!je||je.muted||Y.readyState!==WebSocket.OPEN)return;const W=$.inputBuffer.getChannelData(0);let K=0;for(let R=0;R<W.length;R++)K+=W[R]*W[R];const Q=l.size>0&&Math.sqrt(K/W.length)<su,Z=new Int16Array(W.length);if(!Q)for(let R=0;R<W.length;R++)Z[R]=Math.max(-32768,Math.min(32767,Math.round(W[R]*32767)));Y.send(Z.buffer)},A(),M({phase:"listening",analyser:c,connectedAt:Date.now()});break}case"input_audio_buffer.speech_started":B(),M({phase:"hearing",analyser:c});break;case"input_audio_buffer.speech_stopped":M({phase:"thinking"});break;case"conversation.item.input_audio_transcription.completed":case"response.audio_transcript.done":z();break;case"response.done":!l.size&&je?.phase==="thinking"&&P.response?.status!=="completed"&&M({phase:"listening",analyser:c});break;case"transcript.corrected":typeof P.message_id=="string"&&typeof P.text=="string"&&e.onTranscriptFix?.(P.message_id,P.text);break;case"tangu.run":M({working:P.status==="started"?String(P.task||""):null}),z(P.status==="started"?300:800);break;case"error":console.warn("[realtime] upstream error:",P.error?.message||P.error);break;case"reconnecting":P.replay&&B(),M({phase:"reconnecting"});break;case"end":O(P.reason&&P.reason!=="client closed"?String(P.reason):void 0);break}}}const zi=Jn((e,n)=>({pending:[],queue:(a,o)=>e(i=>({pending:[...i.pending,{sessionId:a,text:o}]})),take:a=>{const o=n().pending.filter(i=>i.sessionId===a);return o.length&&e(i=>({pending:i.pending.filter(c=>c.sessionId!==a)})),o.map(i=>i.text)}})),Mi=40,Ai=.1,iu=3.2;function ou({analyser:e,recording:n,busy:a,onStop:o,onSend:i,status:c,stopTitle:r,t:l}){const p=u.useRef(null),[h,f]=u.useState(0),x=u.useRef(0);u.useEffect(()=>{if(!n)return;x.current=Date.now(),f(0);const A=window.setInterval(()=>f(Math.floor((Date.now()-x.current)/1e3)),250);return()=>window.clearInterval(A)},[n]),u.useEffect(()=>{const A=p.current;if(!e||!n||!A)return;const E=A.getContext("2d");if(!E)return;const M=window.devicePixelRatio||1;A.width=Math.max(1,A.clientWidth)*M,A.height=Math.max(1,A.clientHeight)*M,E.setTransform(M,0,0,M,0,0);const z=getComputedStyle(document.documentElement),B=(z.getPropertyValue("--accent-ink")||z.getPropertyValue("--accent")||"#7c3aed").trim(),_=(z.getPropertyValue("--border")||"rgba(127,127,127,0.4)").trim(),L=new Uint8Array(e.fftSize),U=[];let G=Date.now(),C=0;const g=()=>{C=requestAnimationFrame(g);const O=Date.now();e.getByteTimeDomainData(L);let Y=0;for(let K=0;K<L.length;K++){const Q=(L[K]-128)/128;Y+=Q*Q}const F=Math.min(1,Math.sqrt(Y/L.length)*iu);for(;O-G>=Mi;)U.push({t:G,level:F}),G+=Mi;const P=A.clientWidth,$=A.clientHeight,W=$/2;for(E.clearRect(0,0,P,$),E.strokeStyle=_,E.lineWidth=1,E.setLineDash([2,3]),E.beginPath(),E.moveTo(0,W),E.lineTo(P,W),E.stroke(),E.setLineDash([]);U.length&&P-(O-U[0].t)*Ai<-4;)U.shift();E.fillStyle=B;for(const K of U){const Q=P-(O-K.t)*Ai;if(Q<-4||Q>P)continue;const Z=Math.max(2,K.level*($-4));E.globalAlpha=Q<P*.15?Math.max(0,Q/(P*.15)):1,E.beginPath(),E.roundRect(Q-1.1,W-Z/2,2.2,Z,1.1),E.fill()}E.globalAlpha=1};return g(),()=>cancelAnimationFrame(C)},[e,n]);const w=`${Math.floor(h/60)}:${String(h%60).padStart(2,"0")}`;return a?t.jsxs("div",{className:"t2c-voicebar",children:[t.jsx(Kt,{size:14,className:"spin"}),t.jsx("span",{className:"t2c-voicelabel",children:l("input.micBusy")}),t.jsx("span",{className:"t2c-grow"})]}):t.jsxs("div",{className:"t2c-voicebar",children:[t.jsx("canvas",{ref:p,className:"t2c-voicewave"}),t.jsx("span",{className:"t2c-voicetime",children:c??w}),t.jsx("button",{className:"t2c-voicestop",title:r??l("input.micStop"),onClick:o,children:t.jsx(Yi,{size:12})}),i&&t.jsx("button",{className:"t2c-send",title:l("input.send"),onClick:i,children:t.jsx(Tr,{size:16})})]})}xe({"ultraConfirm.title":{zh:"开启 Ultra?",en:"Turn on Ultra?"},"ultraConfirm.msg":{zh:"Ultra 会把思考拉满、上下文用到模型支持的上限,并主动把能并行的活拆给多个子代理同时做。一次任务的 token 消耗可能是平时的数倍,适合大任务。",en:"Ultra maxes out thinking, uses the model's full context window, and proactively splits parallelizable work across several subagents. One task can use several times the usual tokens, so it suits big jobs."},"ultraConfirm.recommend":{zh:"推荐配合「完全放行」使用:多个子代理并行时,每个需要确认的操作都会停下来等你批准。",en:"Full access is recommended: with several subagents running in parallel, every action that needs approval stops and waits for you."},"ultraConfirm.fullAccess":{zh:"同时把本会话切到「完全放行」",en:"Also switch this session to Full access"},"ultraConfirm.skip":{zh:"以后不再显示",en:"Don't show this again"},"ultraConfirm.confirm":{zh:"开启 Ultra",en:"Turn on Ultra"}});const bo="forsion_ultra_confirm_off";function ru(){try{return localStorage.getItem(bo)==="1"}catch{return!1}}function cu({offerFullAccess:e,onConfirm:n,onClose:a}){const{t:o}=Ce(),[i,c]=u.useState(!1),[r,l]=u.useState(!1),p=u.useRef(typeof document<"u"?document.activeElement:null);u.useEffect(()=>()=>{const f=p.current;f?.isConnected&&typeof f.focus=="function"&&f.focus({preventScroll:!0})},[]);const h=f=>{if(f.key!=="Tab")return;const x=f.currentTarget.querySelector(".dialog"),w=x?[...x.querySelectorAll('button, input, [tabindex]:not([tabindex="-1"])')].filter(M=>!M.disabled):[];if(!w.length)return;const A=w[0],E=w[w.length-1];f.shiftKey&&document.activeElement===A?(f.preventDefault(),E.focus()):!f.shiftKey&&document.activeElement===E&&(f.preventDefault(),A.focus())};return ta.createPortal(t.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},"data-ultra-confirm":!0,"data-keep-menus":!0,onKeyDown:h,children:t.jsxs(Xi,{title:o("ultraConfirm.title"),message:o("ultraConfirm.msg"),confirmLabel:o("ultraConfirm.confirm"),danger:!1,onConfirm:()=>{if(r)try{localStorage.setItem(bo,"1")}catch{}n({fullAccess:e&&i})},onClose:a,children:[e&&t.jsx("div",{className:"dialog-msg",children:o("ultraConfirm.recommend")}),e&&t.jsxs("label",{className:"dialog-check","data-ultra-full-access":!0,children:[t.jsx("input",{type:"checkbox",checked:i,onChange:f=>c(f.target.checked)}),t.jsx("span",{children:o("ultraConfirm.fullAccess")})]}),t.jsxs("label",{className:"dialog-check","data-ultra-skip":!0,children:[t.jsx("input",{type:"checkbox",checked:r,onChange:f=>l(f.target.checked)}),t.jsx("span",{children:o("ultraConfirm.skip")})]})]})}),document.body)}xe({"session.untitled":{zh:"新会话",en:"New session"},"session.rootlessGroup":{zh:"无项目会话",en:"No project"}});const lu="New Chat";function yt(e,n){const a=(e||"").trim();return!a||a===lu?n("session.untitled"):e}function In(e,n){return e.kind==="rootless"?n("session.rootlessGroup"):e.name}xe({"group.setup.selfPacedHint":{zh:"发消息后成员同时开工,可相互 @ 交接;每位成员自己决定何时收尾,全员完成即结束,没有轮数上限。",en:"After you send, members work in parallel and can @-mention each other; each decides when they are done, and the team stops once everyone is — no round limit."}});const uu=()=>({name:"",description:"",model:"",systemPrompt:"",thinkingLevel:"",maxIterations:"",approvalMode:""}),du=()=>`temp-${Date.now().toString(36)}-${Math.floor(Math.random()*46656).toString(36)}`,pu=({agents:e,models:n,initialAgents:a,initialTempAgents:o,active:i,hideDisable:c,onConfirm:r,onDisable:l,onClose:p})=>{const{t:h}=Ce(),f=u.useMemo(()=>new Set(e.map(g=>g.slug)),[e]),[x,w]=u.useState(()=>a.filter(g=>f.has(g))),[A,E]=u.useState(o||[]),[M,z]=u.useState(null),B=u.useMemo(()=>(n||[]).map(g=>({id:g.id,label:g.name||g.id})),[n]),L=x.length+A.length>=2,U=g=>w(O=>O.includes(g)?O.filter(Y=>Y!==g):[...O,g]),G=()=>{if(!M||!M.name.trim()||!M.systemPrompt.trim())return;const g=M.slug||du(),O={slug:g,name:M.name.trim(),description:M.description.trim(),model:M.model,tools:[],thinkingLevel:M.thinkingLevel,maxIterations:M.maxIterations?Number(M.maxIterations):null,approvalMode:M.approvalMode,createdBy:"user",createdAt:"",systemPrompt:M.systemPrompt.trim()};E(Y=>{const F=Y.findIndex(P=>P.slug===g);if(F>=0){const P=Y.slice();return P[F]=O,P}return[...Y,O]}),z(null)},C=()=>{L&&r({groupAgents:[...x,...A.map(g=>g.slug)],groupTempAgents:A})};return t.jsx("div",{onClick:p,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:t.jsxs("div",{"data-team-setup":!0,onClick:g=>g.stopPropagation(),style:{width:480,maxWidth:"92vw",maxHeight:"86vh",overflow:"auto",borderRadius:"var(--radius-md, 12px)",background:"var(--bg)",color:"var(--text)",border:"1px solid var(--border)",boxShadow:"var(--card-shadow)",padding:18},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx($s,{size:18}),t.jsx("strong",{style:{fontSize:"var(--ui-font-heading, 14px)",flex:1},children:h("group.setup.title")}),t.jsx("button",{className:"icon-btn",onClick:p,title:h("group.setup.close"),children:t.jsx(it,{size:16})})]}),M?t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",style:{marginBottom:8},children:h("group.setup.tempFormHint")}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.name")}),t.jsx("input",{type:"text",value:M.name,placeholder:h("settings.agents.namePlaceholder"),onChange:g=>z({...M,name:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.desc")}),t.jsx("input",{type:"text",value:M.description,onChange:g=>z({...M,description:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.model")}),t.jsxs("select",{value:M.model,onChange:g=>z({...M,model:g.target.value}),children:[t.jsx("option",{value:"",children:h("settings.agents.modelDefault")}),B.map(g=>t.jsx("option",{value:g.id,children:g.label},g.id))]})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.systemPrompt")}),t.jsx("textarea",{rows:6,value:M.systemPrompt,placeholder:h("settings.agents.systemPromptPlaceholder"),onChange:g=>z({...M,systemPrompt:g.target.value})})]}),t.jsxs("div",{className:"field-row",children:[t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.thinking")}),t.jsxs("select",{value:M.thinkingLevel,onChange:g=>z({...M,thinkingLevel:g.target.value}),children:[t.jsx("option",{value:"",children:h("settings.agents.inherit")}),Pn.map(g=>t.jsx("option",{value:g,children:Ds(g,h)},g))]})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.maxIter")}),t.jsx("input",{type:"number",min:10,max:200,value:M.maxIterations,onChange:g=>z({...M,maxIterations:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:h("settings.agents.approval")}),t.jsxs("select",{value:M.approvalMode,onChange:g=>z({...M,approvalMode:g.target.value}),children:[t.jsx("option",{value:"",children:h("settings.agents.inherit")}),t.jsx("option",{value:"readonly",children:"readonly"}),t.jsx("option",{value:"auto-edit",children:"auto-edit"}),t.jsx("option",{value:"full-auto",children:"full-auto"}),t.jsx("option",{value:"custom",children:"custom"})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsxs("button",{className:"btn primary sm",disabled:!M.name.trim()||!M.systemPrompt.trim(),onClick:G,children:[t.jsx(rt,{size:13})," ",h("group.setup.tempSave")]}),t.jsx("button",{className:"btn ghost sm",onClick:()=>z(null),children:h("group.setup.close")})]})]}):t.jsxs(t.Fragment,{children:[e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",fontWeight:600,margin:"8px 0 6px",color:"var(--text-dim)"},children:h("group.setup.savedAgents")}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:12},children:e.map(g=>{const O=x.includes(g.slug);return t.jsxs("button",{onClick:()=>U(g.slug),style:{display:"flex",alignItems:"center",gap:10,textAlign:"left",padding:"8px 10px",borderRadius:"var(--radius-sm, 6px)",border:`1px solid ${O?"var(--accent-ink)":"var(--border)"}`,background:O?"var(--accent-soft)":"transparent",color:"inherit",cursor:"pointer"},children:[t.jsx("span",{style:{width:16,height:16,borderRadius:4,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1px solid ${O?"var(--accent-ink)":"var(--border)"}`,background:O?"var(--accent-ink)":"transparent"},children:O&&t.jsx(rt,{size:12,color:"var(--on-accent-ink, var(--on-accent))"})}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"var(--ui-font-body, 13px)",fontWeight:600},children:g.name}),g.description&&t.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.description})]})]},g.slug)})})]}),t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",fontWeight:600,margin:"8px 0 6px",color:"var(--text-dim)"},children:h("group.setup.tempAgents")}),A.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8},children:A.map(g=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:"var(--radius-sm, 6px)",border:"1px solid var(--accent-ink)",background:"var(--accent-soft)"},children:[t.jsx(mo,{size:14,style:{flexShrink:0,opacity:.8}}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:"var(--ui-font-body, 13px)",fontWeight:600},children:g.name}),t.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-dim)",marginLeft:6},children:h("group.setup.tempBadge")})]}),t.jsx("button",{className:"icon-btn",title:h("common.edit"),onClick:()=>z({slug:g.slug,name:g.name,description:g.description,model:g.model,systemPrompt:g.systemPrompt,thinkingLevel:g.thinkingLevel,maxIterations:g.maxIterations!=null?String(g.maxIterations):"",approvalMode:g.approvalMode}),children:t.jsx(Vn,{size:13})}),t.jsx("button",{className:"icon-btn",title:h("common.delete"),onClick:()=>E(O=>O.filter(Y=>Y.slug!==g.slug)),children:t.jsx(Ls,{size:13})})]},g.slug))}),t.jsxs("button",{className:"btn ghost sm",style:{marginBottom:14},onClick:()=>z(uu()),children:[t.jsx(Bn,{size:13})," ",h("group.setup.addTemp")]}),t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-dim)",margin:"6px 0 14px"},children:h("group.setup.selfPacedHint")}),t.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i&&!c&&t.jsx("button",{className:"btn sm",onClick:()=>{l(),p()},children:h("group.setup.disable")}),t.jsx("button",{className:"btn primary sm",onClick:C,disabled:!L,children:h(i?"group.setup.update":"group.setup.start")})]}),!L&&t.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--danger)",textAlign:"right",marginTop:6},children:h("group.setup.needTwo")})]})]})})},$n=2e5,Ss=(e,n,a)=>el(e,e,n,a,void 0,void 0,{context:3});function hu(e){if(!/^\*\*\* (Begin Patch|(Add|Update|Delete) File:)/m.test(e))return null;const n=e.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),a=/^\*\*\* (Add|Update|Delete) File: (.+)$/,o=r=>a.test(r)||/^\*\*\* (Begin|End) Patch$/.test(r.trim()),i=[];let c=0;for(;c<n.length;){const r=a.exec(n[c]);if(!r){c++;continue}const l=r[1],p=r[2].trim();c++;let h="";const f=l==="Update"?/^\*\*\* Move to: (.+)$/.exec(n[c]??""):null;f&&(h=f[1].trim(),c++);const x=[];for(;c<n.length&&!o(n[c]);)x.push(n[c]),c++;if(l==="Delete"){i.push(`--- ${p}`,"+++ /dev/null","@@ -1,1 +0,0 @@","-(deleted)");continue}if(l==="Add"){const z=x.filter(B=>B.startsWith("+")).map(B=>B.slice(1));if(!z.length)continue;i.push("--- /dev/null",`+++ ${p}`,`@@ -0,0 +1,${z.length} @@`,...z.map(B=>"+"+B));continue}const w=[`--- ${p}`,`+++ ${h||p}`];let A=[],E="";const M=()=>{if(!A.length)return;const z=A.filter(_=>_[0]!=="+").length,B=A.filter(_=>_[0]!=="-").length;w.push(`@@ -1,${z} +1,${B} @@${E?" "+E:""}`,...A),A=[]};for(const z of x){const B=/^@@ ?(.*)$/.exec(z);if(B){M(),E=B[1]||"";continue}z.startsWith("+")||z.startsWith("-")||z.startsWith(" ")?A.push(z):A.push(" "+z)}M(),w.length>2&&i.push(...w)}return i.length?i.join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`:null}function mu(e,n){if(!n)return null;let a;try{a=JSON.parse(n)}catch{return null}if(!a||typeof a!="object")return null;const o=typeof a.path=="string"&&a.path?a.path:"file";try{switch(e){case"edit_file":{const i=String(a.old_string??""),c=String(a.new_string??"");return!i&&!c||i.length+c.length>$n?null:Ss(o,i,c)}case"multi_edit":{if(!Array.isArray(a.edits)||!a.edits.length)return null;let i=0;const c=[];for(let r=0;r<a.edits.length;r++){const l=a.edits[r],p=String(l?.old_string??""),h=String(l?.new_string??"");if(i+=p.length+h.length,i>$n)return null;c.push(Ss(a.edits.length>1?`${o} · #${r+1}`:o,p,h))}return c.join(`
|
|
6
|
+
`)}case"write_file":{const i=String(a.content??"");return!i||i.length>$n?null:Ss(o,"",i)}case"apply_patch":{const i=String(a.patch??a.input??a.diff??"");return i.length>$n?null:/^@@[ -]/m.test(i)&&/^(--- |\+\+\+ )/m.test(i)?i:hu(i)}default:return null}}catch{return null}}xe({"approval.remoteReadOnly":{zh:"远程连接下只能原样批准或拒绝,要改命令请在那台设备本机上操作",en:"Over a remote connection you can only approve or reject as is. To change the command, use that device itself"},"approval.remote.caller":{zh:"来自远程会话 · {name}",en:"From a remote session · {name}"},"approval.remote.device":{zh:"来自远程会话 · 已登记设备",en:"From a remote session · a registered device"},"approval.remote.account":{zh:"来自远程会话 · 账号下未识别的客户端",en:"From a remote session · an unidentified client on your account"},"approval.remote.lan":{zh:"来自远程会话 · 局域网配对设备",en:"From a remote session · a LAN-paired device"},"approval.remote.p2p":{zh:"来自远程会话 · 点对点直连",en:"From a remote session · a peer-to-peer connection"},"approval.remote.unknown":{zh:"来自远程会话",en:"From a remote session"},"approval.localOnly":{zh:"这项操作涉及受保护的配置,只能在执行它的电脑上批准",en:"This touches protected configuration and can only be approved on the computer running it"},"approval.byHost":{zh:"在执行的电脑上",en:"on the host computer"},"approval.byHostNamed":{zh:"在执行的电脑上({device})",en:"on the host computer ({device})"},"approval.byDevice":{zh:"在 {device} 上",en:"on {device}"},"approval.byRegisteredDevice":{zh:"在已登记设备上",en:"on a registered device"},"approval.byOther":{zh:"在另一台设备上",en:"on another device"},"approval.byChannel":{zh:"经消息通道",en:"via a messaging channel"}});const Vs=new Set,bp=e=>Vs.has(e),fu=e=>Dr(_r(e)).remoteApprover,Ei=480,jp=({req:e,onDecide:n,sessionId:a})=>{const{t:o}=Ce(),i=fu(a),c=Rr(a),r=e.name==="run_bash",l=(()=>{if(!r||!e.arguments)return"";try{return String(JSON.parse(e.arguments).command??"")}catch{return""}})(),[p,h]=u.useState(l),f=u.useRef(null),[x,w]=u.useState(!1);u.useLayoutEffect(()=>{const g=f.current;if(!g)return;g.style.height="auto";const O=g.scrollHeight;g.style.height=`${Math.min(O,Ei)}px`,w(O>Ei)},[p]);const A=nl.test(p),E=sl.test(p),M=e.status!=="pending",z=u.useMemo(()=>r?null:mu(e.name,e.arguments),[r,e.name,e.arguments]),B=Ir(e.reason)&&!i,_=$r(e.reason,o),L=Lr(e.remote,o),U=!(e.localOnly&&i),G=M?Pr(e.answeredBy,{remotePage:i,answeredHere:Vs.has(e.approvalId),hostName:c},o):"",C=g=>{if(M||g!=="reject"&&!U)return;Vs.add(e.approvalId);const O=r&&!i&&p.trim()&&p!==l?{command:p}:void 0;n(g,g==="reject"?void 0:O)};return t.jsxs("div",{className:`approval-card${M?" resolved":""}`,children:[t.jsxs("div",{className:"approval-title",children:[t.jsx($l,{size:15,style:{color:"var(--accent-ink)"}}),o("approval.requestExec",{name:e.name}),M&&t.jsxs("span",{style:{fontWeight:400,fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-faint)"},children:[e.status==="approved"?o("approval.statusApproved"):e.status==="rejected"?o("approval.statusRejected"):o("approval.statusExpired"),G&&t.jsxs("span",{"data-answered-by":!0,children:[" · ",G]})]})]}),L&&t.jsx("div",{className:"approval-why","data-approval-remote":!0,children:L}),_&&t.jsx("div",{className:"approval-why",children:_}),r&&!M&&!i?t.jsx("textarea",{className:"approval-edit",value:p,onChange:g=>h(g.target.value),ref:f,rows:1,spellCheck:!1}):null,r&&!M&&(x||A||E)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"approval-why",children:[x&&t.jsx("div",{children:o("approval.cmdOverflow")}),A&&t.jsx("div",{children:o("approval.cmdHiddenChars")}),E&&t.jsx("div",{children:o("approval.cmdWideBlank")})]}),(A||E)&&t.jsx("div",{className:"approval-preview",children:e.preview})]}),r&&!M&&!i?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"approval-preview",children:e.preview}),z&&t.jsx("div",{className:"approval-diff",children:t.jsx(tl,{text:z,side:!1})}),i&&!M&&U&&t.jsx("div",{className:"approval-why","data-remote-readonly":!0,children:o("approval.remoteReadOnly")}),!M&&!U&&t.jsx("div",{className:"approval-why","data-local-only":!0,children:o("approval.localOnly")})]}),!M&&t.jsxs("div",{className:"approval-actions",children:[U&&t.jsxs("button",{className:"btn primary sm",onClick:()=>C("approve"),children:[t.jsx(rt,{size:13})," ",o("approval.approve")]}),B&&U&&t.jsxs("button",{className:"btn ghost sm",onClick:()=>C("approve_always"),children:[t.jsx(Yc,{size:13})," ",o("approval.approveAlways")]}),t.jsxs("button",{className:"btn danger sm",onClick:()=>C("reject"),children:[t.jsx(it,{size:13})," ",o("approval.reject")]})]})]})},gu=["readonly","auto-edit","full-auto"],vu={base:"auto-edit"},Ns=e=>e.join(`
|
|
7
|
+
`),Cs=e=>e.split(`
|
|
8
|
+
`).map(n=>n.trim()).filter(Boolean),yu=({cfg:e,onClose:n})=>{const{t:a}=Ce(),[o,i]=u.useState(vu.base),[c,r]=u.useState({deny:"",ask:"",allow:""}),[l,p]=u.useState(!0),[h,f]=u.useState(!1),[x,w]=u.useState(!1),[A,E]=u.useState(""),M=gn.useRef(e);M.current=e;const z=gn.useCallback(()=>{p(!0),E(""),Or(ot()).then(L=>{i(L.base),r({deny:Ns(L.deny),ask:Ns(L.ask),allow:Ns(L.allow)}),f(!0),p(!1)}).catch(L=>{E(String(L?.message||L)),f(!1),p(!1)})},[]);u.useEffect(()=>{z()},[z]);const B=async()=>{if(h){w(!0),E("");try{await Wr(ot(),{base:o,deny:Cs(c.deny),ask:Cs(c.ask),allow:Cs(c.allow)}),n()}catch(L){E(String(L?.message||L)),w(!1)}}},_=L=>t.jsxs("div",{className:"field",children:[t.jsx("label",{children:t.jsx("b",{children:a(`approvalRules.${L}`)})}),t.jsx("div",{className:"hint",children:a(`approvalRules.${L}Hint`)}),t.jsx("textarea",{value:c[L],onChange:U=>r(G=>({...G,[L]:U.target.value})),rows:3,spellCheck:!1,placeholder:a(`approvalRules.${L}Ph`),style:{width:"100%",fontFamily:"var(--font-mono)",fontSize:"var(--ui-font-meta, 12px)"}})]},L);return t.jsx("div",{className:"apvr-modal",onClick:n,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:t.jsxs("div",{onClick:L=>L.stopPropagation(),style:{background:"var(--bg-card)",border:"var(--border-width) solid var(--border)",borderRadius:"var(--radius-lg, 12px)",padding:18,width:"min(620px, 92vw)",maxHeight:"86vh",overflow:"auto",boxShadow:"var(--card-shadow)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[t.jsx("b",{children:a("approvalRules.title")}),t.jsx("button",{className:"icon-btn",onClick:n,children:t.jsx(it,{size:15})})]}),l?t.jsx("div",{className:"field",children:t.jsxs("div",{className:"hint",children:[t.jsx(Kt,{size:14,className:"spin"})," ",a("common.loading")]})}):h?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",children:a("approvalRules.scopeNote")}),t.jsx("div",{className:"hint",style:{marginTop:4},children:a("approvalRules.syntax")})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:t.jsx("b",{children:a("approvalRules.base")})}),t.jsx("div",{className:"hint",children:a("approvalRules.baseHint")}),t.jsx("div",{style:{display:"flex",gap:6,marginTop:6},children:gu.map(L=>t.jsx("button",{className:`btn sm${o===L?" primary":" ghost"}`,onClick:()=>i(L),children:a(Fr[L])},L))})]}),["deny","ask","allow"].map(_),A&&t.jsx("div",{className:"field",children:t.jsx("div",{className:"hint",style:{color:"var(--danger)"},children:A})})]}):t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",style:{color:"var(--danger)"},children:a("approvalRules.loadFailed")}),t.jsx("div",{className:"hint",children:A}),t.jsx("div",{style:{marginTop:8},children:t.jsx("button",{className:"btn sm ghost",onClick:z,children:a("common.retry")})})]}),t.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end",marginTop:14},children:[t.jsx("button",{className:"btn ghost sm",onClick:n,children:a("common.cancel")}),t.jsxs("button",{className:"btn primary sm",disabled:!h||x,onClick:()=>{B()},children:[x?t.jsx(Kt,{size:13,className:"spin"}):null," ",a("common.save")]})]})]})})},ku=[{name:"/help",key:"help",zh:"显示帮助与命令列表",en:"Show help and the command list",surfaces:["tui","desktop","channel"]},{name:"/feedback",key:"feedback",zh:"提交问题或建议,可在命令后填写反馈内容",en:"Report an issue or suggestion; optionally add your feedback after the command",surfaces:["desktop"]},{name:"/new",key:"new",zh:"开始新会话",en:"Start a new session",surfaces:["tui","desktop","channel"]},{name:"/clear",key:"clear",zh:"清屏(保留会话历史)",en:"Clear the screen (history is kept)",surfaces:["tui"]},{name:"/sessions",key:"sessions",aliases:["/list"],zh:"列出最近会话",en:"List recent sessions",surfaces:["tui","desktop","channel"]},{name:"/resume",key:"resume",aliases:["/switch"],zh:"恢复会话并续聊",en:"Resume a session and continue",arg:"<id|序号>",surfaces:["tui","channel"]},{name:"/rename",key:"rename",arg:"<标题>",zh:"重命名本会话",en:"Rename this session",surfaces:["tui"]},{name:"/branch",key:"branch",arg:"[序号]",aliases:["/fork"],zh:"从某条回复后分支新会话(继承历史),缺省最近",en:"Branch a new session from a reply (inherits history); defaults to the latest",surfaces:["tui","desktop"]},{name:"/btw",key:"btw",arg:"[问题]",aliases:["/side"],zh:"顺便问一句:带着本会话上下文旁聊,不进主对话、不打断正在跑的任务",en:"Ask a side question with this session as context; not added to the conversation and never interrupts a running task",surfaces:["desktop"]},{name:"/compact",key:"compact",arg:"[关注点]",zh:"压缩上下文:总结后精简续接(同会话;可附本次摘要的关注点)",en:"Compact context: summarize, then continue compactly (optional focus for this summary)",surfaces:["tui","desktop","channel"]},{name:"/status",key:"status",zh:"本会话概况:模型 / 思考档 / 审批档 / 工作目录 / 用量",en:"Session overview: model, thinking level, approval mode, cwd, usage",surfaces:["tui","desktop","channel"]},{name:"/export",key:"export",zh:"导出本会话为 Markdown",en:"Export this session as Markdown",surfaces:["tui","desktop"]},{name:"/cost",key:"cost",zh:"本会话 token 用量与费用",en:"Token usage and cost for this session",surfaces:["tui","desktop","channel"]},{name:"/diff",key:"diff",zh:"查看工作目录的 git 改动(含未跟踪文件)",en:"Show git changes in the working directory (including untracked files)",surfaces:["tui"]},{name:"/copy",key:"copy",zh:"复制上一条回复到剪贴板",en:"Copy the last reply to the clipboard",surfaces:["tui","desktop"]},{name:"/retry",key:"retry",zh:"重跑上一条用户消息",en:"Re-run the last user message",surfaces:["tui","desktop"]},{name:"/edit",key:"edit",zh:"编辑最近一条消息并重跑($EDITOR)",en:"Edit the last message and re-run ($EDITOR)",surfaces:["tui"]},{name:"/delete",key:"delete",zh:"删除最近一轮对话",en:"Delete the last turn",surfaces:["tui"]},{name:"/queue",key:"queue",arg:"[clear]",zh:"查看排队项:运行中发的消息与 /compact 等命令排到本轮结束后依次执行(/queue clear 清空)",en:"Show queued items: messages and commands like /compact sent while running run in order after this turn (/queue clear to empty)",surfaces:["tui"]},{name:"/stop",key:"stop",zh:"停止当前运行",en:"Stop the current run",surfaces:["desktop","channel"]},{name:"/model",key:"model",arg:"[名称|序号]",zh:"切换模型(不带参数列出可选模型)",en:"Switch model (no argument lists the available models)",surfaces:["tui","desktop","channel"]},{name:"/think",key:"think",arg:"<档位>",aliases:["/effort"],zh:"思考强度:off|minimal|low|medium|high|xhigh|max(模型不支持的档自动降档)",en:"Thinking level: off|minimal|low|medium|high|xhigh|max (auto-clamped to what the model supports)",surfaces:["tui","desktop","channel"]},{name:"/approval",key:"approval",arg:"<档位>",aliases:["/permissions"],zh:"查看或切换审批档:readonly|auto-edit|full-auto|custom",en:"Show or switch the approval mode: readonly|auto-edit|full-auto|custom",surfaces:["tui","desktop","channel"]},{name:"/loop",key:"loop",arg:"<1-200>",zh:"最大循环轮数(默认 90;耗尽会提示)",en:"Max loop iterations (default 90; you get a prompt when exhausted)",surfaces:["tui","desktop","channel"]},{name:"/verify",key:"verify",arg:"<命令|off>",zh:"本会话验证命令:收尾前自动跑,不绿不许收(off 关闭)",en:"Session verify command — runs before the turn may end; must pass (off to clear)",surfaces:["desktop"]},{name:"/plan",key:"plan",zh:"切换计划模式:只读调研 → 提交计划求批准",en:"Toggle plan mode: read-only research, then submit a plan for approval",surfaces:["tui","desktop"]},{name:"/chat",key:"chat",zh:"切到 Chat 模式(轻量:答完即停、临时工作区、不写笔记;侧栏只列聊天会话,新会话按此模式创建,已创建的会话不可切换)",en:"Switch to Chat mode (light: answers and stops, temporary workspace, never writes your notes; the sidebar lists chat sessions only, new sessions use it, existing sessions are fixed)",surfaces:["desktop"]},{name:"/work",key:"work",zh:"切到 Work 模式(完整工具面:文件、命令、技能、子代理;侧栏列出全部项目)",en:"Switch to Work mode (full toolset: files, commands, skills, subagents; the sidebar lists all projects)",surfaces:["desktop"]},{name:"/voice",key:"voice",zh:"切到语音消息(该 Agent 回复变语音)",en:"Switch to voice messages (this agent replies as voice)",surfaces:["desktop","channel"]},{name:"/text",key:"text",zh:"切回文字消息",en:"Switch back to text messages",surfaces:["channel"]},{name:"/cwd",key:"cwd",arg:"[path]",zh:"查看或切换工作目录",en:"Show or change the working directory",surfaces:["tui"]},{name:"/config",key:"config",zh:"查看当前设置",en:"Show current settings",surfaces:["tui","desktop"]},{name:"/login",key:"login",zh:"重新登录 Forsion",en:"Sign in to Forsion again",surfaces:["tui","desktop"]},{name:"/hotkeys",key:"hotkeys",zh:"查看快捷键",en:"Show keyboard shortcuts",surfaces:["tui"]},{name:"/exit",key:"exit",zh:"退出 Tangu",en:"Quit Tangu",surfaces:["tui"]},{name:"/tools",key:"tools",zh:"列出当前模式可用工具",en:"List tools available in the current mode",surfaces:["tui","desktop"]},{name:"/skills",key:"skills",zh:"列出可用技能(✓=本会话启用)",en:"List available skills (✓ = enabled for this session)",surfaces:["tui","desktop"]},{name:"/skill",key:"skill",arg:"<id>",zh:"启用/停用技能",en:"Enable or disable a skill",surfaces:["tui"]},{name:"/agents",key:"agents",zh:"列出本地 Normal Agent(自定义人格)",en:"List local normal agents (custom personas)",surfaces:["tui","desktop","channel"]},{name:"/agent",key:"agent",arg:"<slug>",zh:"启用 Agent;管理:/agent new|edit|rm <slug>",en:"Activate an agent; manage with /agent new|edit|rm <slug>",surfaces:["tui","desktop","channel"]},{name:"/groupchat",key:"groupchat",arg:"<slug…>",zh:"团队模式(/groupchat off 退出)",en:"Team mode (/groupchat off to leave)",surfaces:["tui","desktop"]},{name:"/historian",key:"historian",zh:"Historian 状态/活动;/historian on|off 开关",en:"Historian status/activity; /historian on|off to toggle",surfaces:["tui","desktop"]},{name:"/muse",key:"muse",zh:"Muse 状态/TODO;/muse on|off 开关",en:"Muse status/TODOs; /muse on|off to toggle",surfaces:["tui","desktop"]},{name:"/memory",key:"memory",arg:"[edit]",zh:"查看/编辑长期记忆",en:"View or edit long-term memory",surfaces:["tui","desktop"]},{name:"/refine",key:"refine",arg:"[focus]",zh:"复盘本会话,沉淀 Agent 的进化记录(可回滚)",en:"Reflect on this conversation and refine the agent's evolution record (reversible)",surfaces:["tui","desktop"]},{name:"/log",key:"log",arg:"[YYYY-MM-DD]",zh:"查看每日日志",en:"View the daily log",surfaces:["tui"]},{name:"/mcp",key:"mcp",zh:"列出 MCP server 状态",en:"List MCP server status",surfaces:["tui","desktop"]},{name:"/plugins",key:"plugins",zh:"列出已发现插件",en:"List discovered plugins",surfaces:["tui","desktop"]}];function Ti(e){return ku.filter(n=>n.surfaces.includes(e))}xe({"addMenu.label":{zh:"添加",en:"Add"},"addMenu.newChat":{zh:"新会话",en:"New session"},"addMenu.agent":{zh:"添加 Agent",en:"Add agent"},"addMenu.files":{zh:"添加文件或文件夹",en:"Add files or folders"},"addMenu.camera":{zh:"拍照",en:"Take photo"},"addMenu.photos":{zh:"相册",en:"Photos"},"addMenu.file":{zh:"文件",en:"Files"},"addMenu.conversation":{zh:"添加会话",en:"Add session"},"addMenu.view":{zh:"添加正在使用的 View",en:"Add an active View"},"addMenu.searchChats":{zh:"搜索全部会话",en:"Search all sessions"},"addMenu.searchViews":{zh:"搜索全部 View",en:"Search all Views"},"addMenu.recent":{zh:"最近使用",en:"Recent"},"addMenu.allChats":{zh:"全部会话",en:"All sessions"},"addMenu.inUse":{zh:"正在使用",en:"In use"},"addMenu.allViews":{zh:"全部 View",en:"All Views"},"addMenu.noMatches":{zh:"没有匹配项",en:"No matches"}});const zs=new Set(["chat","chat-panel","home","launcher","sidebar-empty"]),xu=300;function wu(e,n,a=xu){const o=new Set(e.map(c=>c.id)),i=n.filter(c=>!o.has(c.id));return i.length>a?null:{recent:[...e],rest:i}}function Ln(e){const n=new Set;return e.filter(a=>n.has(a.key)?!1:(n.add(a.key),!0))}const bu=({open:e,disabled:n,activeSessionId:a,canUsePathPicker:o,onOpenChange:i,onNewSession:c,onAddAgent:r,onPickPaths:l,onPickFiles:p,onAddReference:h})=>{const{t:f}=Ce(),[x,w]=u.useState(null),[A,E]=u.useState(""),[M,z]=u.useState("right"),[B,_]=u.useState(0),L=u.useRef(null),U=u.useRef(null),G=u.useRef(null),C=u.useRef(null),g=Yt(e,{boundary:".t2-chat-view"}),O=Yt(x?`${x}:${M}`:"",{boundary:".t2-chat-view"}),Y=D(b=>b.sessions),F=D(b=>b.archivedSessions),P=al(b=>b.items),$=Dn(b=>b.mainTabs),W=Dn(b=>b.leftTabs),K=Dn(b=>b.rightTabs),Q=mn(b=>b.vaultRoot);u.useEffect(()=>{e||(w(null),E(""))},[e]),u.useEffect(()=>{E(""),x&&requestAnimationFrame(()=>G.current?.focus())},[x]),u.useLayoutEffect(()=>{const b=L.current,V=U.current;if(!x||!b||!V)return;const H=()=>{const qe=b.getBoundingClientRect(),ut=(b.closest(".t2c-card")||b.closest(".t2-chat-view"))?.getBoundingClientRect(),He=Gi(V),Ve=ut?Zi(qe.left,qe.right,V.offsetWidth,ut.left,ut.right,He):"right";z(m=>m===Ve?m:Ve),_(m=>m===b.offsetHeight+6?m:b.offsetHeight+6)};H(),window.addEventListener("resize",H),window.addEventListener(Un,H);const se=new ResizeObserver(H);se.observe(b),se.observe(V);const Ne=b.closest(".t2c-card")||b.closest(".t2-chat-view");return Ne&&se.observe(Ne),()=>{window.removeEventListener("resize",H),window.removeEventListener(Un,H),se.disconnect()}},[x]);const Z=u.useMemo(()=>{const b=new Set;return[...Y,...F].filter(V=>V.id===a||b.has(V.id)?!1:(b.add(V.id),!0))},[Y,F,a]),R=u.useMemo(()=>{const b=new Map(Z.map(H=>[H.id,H])),V=P.filter(H=>H.kind==="chat").map(H=>b.get(H.id)).filter(Boolean);return(V.length?V:Z).slice(0,6)},[Z,P]),ae=u.useMemo(()=>{const b=A.trim().toLocaleLowerCase();return b?Z.filter(V=>`${V.title||""}
|
|
9
|
+
${V.summary||""}`.toLocaleLowerCase().includes(b)).slice(0,12):R},[A,R,Z]),y=u.useMemo(()=>{const b=$.flatMap(H=>{if(zs.has(H.type))return[];const se=H.title||ci(gs(H.type)?.displayName||H.type);if(H.filePath){const Ne=H.type==="amadeus-editor"&&!!Q;return[{key:`${Ne?"note":"file"}:${H.filePath}`,type:H.type,title:se,ref:Ne?{kind:"note",path:H.filePath}:{kind:"file",path:H.filePath},meta:H.filePath}]}return[{key:`view:${H.type}`,type:H.type,title:se,ref:{kind:"view",type:H.type,title:se}}]}),V=[...W,...K].flatMap(H=>zs.has(H.type)?[]:[{key:`view:${H.type}`,type:H.type,title:H.title,ref:{kind:"view",type:H.type,title:H.title}}]);return Ln([...b,...V]).slice(0,8)},[$,W,K,Q]),q=u.useMemo(()=>Ln(P.flatMap(b=>b.kind==="chat"?[]:b.kind==="note"?[{key:b.key,type:"amadeus-editor",title:b.title,ref:{kind:"note",path:b.id},meta:b.id}]:b.kind==="file"&&b.viewType?[{key:b.key,type:b.viewType,title:b.title,ref:{kind:"file",path:b.id},meta:b.id}]:b.kind==="view"&&b.viewType&&gs(b.viewType)?[{key:b.key,type:b.viewType,title:b.title,ref:{kind:"view",type:b.viewType,title:b.title}}]:[])).slice(0,6),[P]),te=Br().filter(b=>!zs.has(b.type)).map(b=>{const V=ci(b.displayName);return{key:`view:${b.type}`,type:b.type,title:V,ref:{kind:"view",type:b.type,title:V}}}),Se=(()=>{const b=A.trim().toLocaleLowerCase();return b?Ln([...y,...q,...te]).filter(V=>`${V.title}
|
|
10
|
+
${V.type}
|
|
11
|
+
${V.meta||""}`.toLocaleLowerCase().includes(b)).slice(0,12):[]})(),ge=b=>{h(b),i(!1)},ye=async b=>{i(!1);const V=await b();if(!V.length)return;const H=new DataTransfer;V.forEach(se=>H.items.add(se)),await p(H.files)},Be=async()=>{if(o&&window.tangu?.pickPaths){i(!1);const b=await window.tangu.pickPaths();b.length&&await l(b);return}if(window.tangu?.pickFiles)return ye(()=>window.tangu.pickFiles());C.current?.click()},Ie=b=>gs(b)?.icon||_n,Ae=b=>{const V=b.ref.kind==="file"||b.ref.kind==="note"?na:Ie(b.type);return{id:`ref:${b.key}`,label:b.title,detail:b.meta,icon:t.jsx(V,{size:14}),run:()=>ge(b.ref)}},Le=b=>({id:`session:${b.id}`,label:b.title||"Chat",detail:b.summary||void 0,icon:t.jsx(Ht,{size:14}),run:()=>ge({kind:"session",id:b.id,title:b.title||"Chat"})}),Ee={id:"new-chat",label:f("addMenu.newChat"),icon:t.jsx(hl,{size:14}),run:()=>{c?.(),i(!1)}},Pe=r?{id:"add-agent",act:"add-agent",label:f("addMenu.agent"),icon:t.jsx(mo,{size:14}),run:()=>{r(),i(!1)}}:null,De={id:"files",label:f("addMenu.files"),icon:t.jsx(Hr,{size:14}),run:()=>{Be()}},_e=window.tangu,Ue=_e?.takePhoto&&_e.pickPhotos&&_e.pickFiles?[{id:"camera",label:f("addMenu.camera"),icon:t.jsx(Ur,{size:14}),run:()=>{ye(()=>_e.takePhoto())}},{id:"photos",label:f("addMenu.photos"),icon:t.jsx(qr,{size:14}),run:()=>{ye(()=>_e.pickPhotos())}},{...De,label:f("addMenu.file")}]:[De],lt=()=>{const b=wu(R,Z),V=Ln([...y,...q]),H=new Set(V.map(Ne=>Ne.key)),se=f("addMenu.noMatches");return{title:f("addMenu.label"),back:f("common.back"),sections:[{items:[Ee,...Pe?[Pe]:[],...Ue,b?{id:"conversation",label:f("addMenu.conversation"),icon:t.jsx(Ht,{size:14}),search:{placeholder:f("addMenu.searchChats"),empty:se},children:[{title:f("addMenu.recent"),items:b.recent.map(Le)},{title:f("addMenu.allChats"),items:b.rest.map(Le)}]}:{id:"conversation",label:f("addMenu.conversation"),icon:t.jsx(Ht,{size:14}),run:()=>{i(!0),w("conversation")}},{id:"view",label:f("addMenu.view"),icon:t.jsx(_n,{size:14}),search:{placeholder:f("addMenu.searchViews"),empty:se},children:[{title:f("addMenu.inUse"),items:y.map(Ae)},{title:f("addMenu.recent"),items:q.filter(Ne=>!y.some(qe=>qe.key===Ne.key)).map(Ae)},{title:f("addMenu.allViews"),items:te.filter(Ne=>!H.has(Ne.key)).map(Ae)}]}]}]}},Rt=b=>b.map(V=>{const H=Ae(V);return t.jsxs("button",{className:"menu-item add-menu-result",title:V.meta||V.title,onClick:H.run,children:[H.icon,t.jsxs("span",{className:"grow add-menu-result-main",children:[t.jsx("span",{className:"add-menu-result-title",children:H.label}),H.detail&&t.jsx("span",{className:"add-menu-result-meta",children:H.detail})]})]},V.key)});return t.jsxs("span",{className:`add-pill-wrap t2c-capsule-peer${e?" is-open":""}`,"data-cmenu":!0,children:[t.jsxs("button",{className:`t2c-pill add-pill-btn${e?" is-open":""}`,title:f("input.addContent"),"aria-expanded":e,disabled:n,onClick:()=>{!e&&ia(lt,{})||i(!e)},children:[t.jsx(Bn,{size:16,className:"add-pill-plus"}),t.jsx("span",{className:"add-pill-label",children:f("addMenu.label")}),t.jsx(xn,{size:10,className:"add-pill-chevron"})]}),e&&t.jsxs("div",{ref:b=>{L.current=b,g.ref.current=b},className:"composer-menu composer-menu--add",style:g.style,children:[t.jsxs("button",{className:"menu-item",onClick:Ee.run,children:[Ee.icon,t.jsx("span",{className:"grow",children:Ee.label})]}),Pe&&t.jsxs("button",{className:"menu-item","data-add-agent":!0,onClick:Pe.run,children:[Pe.icon,t.jsx("span",{className:"grow",children:Pe.label})]}),t.jsxs("button",{className:"menu-item",onClick:De.run,children:[De.icon,t.jsx("span",{className:"grow",children:De.label})]}),t.jsxs("button",{className:`menu-item add-menu-parent${x==="conversation"?" active":""}`,"aria-expanded":x==="conversation",onPointerEnter:()=>w("conversation"),onFocus:()=>w("conversation"),onClick:()=>w("conversation"),children:[t.jsx(Ht,{size:14}),t.jsx("span",{className:"grow",children:f("addMenu.conversation")}),t.jsx(Et,{size:13})]}),t.jsxs("button",{className:`menu-item add-menu-parent${x==="view"?" active":""}`,"aria-expanded":x==="view",onPointerEnter:()=>w("view"),onFocus:()=>w("view"),onClick:()=>w("view"),children:[t.jsx(_n,{size:14}),t.jsx("span",{className:"grow",children:f("addMenu.view")}),t.jsx(Et,{size:13})]})]}),e&&x&&t.jsxs("div",{ref:b=>{U.current=b,O.ref.current=b},className:`composer-menu add-menu-sub ${M}`,"data-pane":x,style:{...O.style,bottom:M==="stacked"?`calc(100% + ${B}px)`:void 0},children:[t.jsxs("label",{className:"add-menu-search",children:[t.jsx(Ji,{size:13}),t.jsx("input",{ref:G,value:A,onChange:b=>E(b.currentTarget.value),placeholder:f(x==="conversation"?"addMenu.searchChats":"addMenu.searchViews")})]}),t.jsx("div",{className:"add-menu-sub-scroll",children:x==="conversation"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f(A.trim()?"addMenu.allChats":"addMenu.recent")}),ae.map(b=>{const V=Le(b);return t.jsxs("button",{className:"menu-item add-menu-result",title:b.summary||b.title||"",onClick:V.run,children:[V.icon,t.jsxs("span",{className:"grow add-menu-result-main",children:[t.jsx("span",{className:"add-menu-result-title",children:V.label}),V.detail&&t.jsx("span",{className:"add-menu-result-meta",children:V.detail})]})]},b.id)}),!ae.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")})]}):A.trim()?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f("addMenu.allViews")}),Rt(Se),!Se.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f("addMenu.inUse")}),Rt(y),!y.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")}),!!q.length&&t.jsx("div",{className:"menu-section add-menu-section-gap",children:f("addMenu.recent")}),Rt(q)]})})]}),t.jsx("input",{ref:C,type:"file",multiple:!0,hidden:!0,onChange:b=>{p(b.currentTarget.files),b.currentTarget.value="",i(!1)}})]})};function jo(e,n){const a=e.agents.filter(l=>l.createdBy!=="system"),o=e.agents.find(l=>l.slug===e.currentAgentSlug),i={id:"normal-work",label:n("input.normalWork"),icon:t.jsx(vs,{size:14}),checked:e.active,disabled:e.disabled,run:()=>{e.onNormalWork(),e.onClose()}},c=e.onAgentSwitch?a.map(l=>({id:`agent:${l.slug}`,label:l.name,icon:t.jsx(vs,{size:14}),checked:e.currentAgentSlug===l.slug,run:()=>{e.onAgentSwitch(l.slug),e.onClose()}})):[],r=c.length?{id:"agent-switch",label:n("input.agentSwitch.section"),detail:o?.name,icon:t.jsx(vs,{size:14}),children:[{items:c}]}:null;return{normal:i,agentSwitch:r,agents:c}}function ju(e){const{currentAgentSlug:n,agents:a}=e,{t:o}=Ce(),[i,c]=u.useState(!1),[r,l]=u.useState("right"),[p,h]=u.useState(0),f=u.useRef(null),x=u.useRef(null),w=Yt(i?r:"",{boundary:".t2-chat-view"}),A=jo(e,o),E=A.agentSwitch?()=>c(!0):void 0,M=a.find(z=>z.slug===n);return u.useLayoutEffect(()=>{const z=f.current,B=x.current,_=z?.closest(".composer-menu");if(!i||!z||!B||!_)return;const L=()=>{const C=_.getBoundingClientRect(),g=(_.closest(".t2c-card")||_.closest(".t2-chat-view"))?.getBoundingClientRect(),O=_.closest(".t2-chat-view")?.getBoundingClientRect(),Y=Gi(B),F=g?Zi(C.left,C.right,B.offsetWidth,g.left,g.right,Y):"right";l($=>$===F?$:F);const P=Vr(z.getBoundingClientRect().top,B.offsetHeight,C.top,C.bottom,O?.top??0,O?.bottom??window.innerHeight,Y);h($=>Math.abs($-P)<.5?$:P)};L(),window.addEventListener("resize",L),window.addEventListener(Un,L);const U=new ResizeObserver(L);U.observe(_),U.observe(B);const G=_.closest(".t2c-card")||_.closest(".t2-chat-view");return G&&U.observe(G),()=>{window.removeEventListener("resize",L),window.removeEventListener(Un,L),U.disconnect()}},[i]),u.useEffect(()=>{const z=f.current?.closest(".composer-menu");if(!i||!z)return;const B=_=>{const L=_.target?.closest?.(".menu-item");L&&!f.current?.contains(L)&&c(!1)};return z.addEventListener("pointerover",B),z.addEventListener("focusin",B),()=>{z.removeEventListener("pointerover",B),z.removeEventListener("focusin",B)}},[i]),t.jsxs("div",{ref:f,className:"mode-normal-row",onPointerEnter:E,children:[t.jsxs("button",{className:`menu-item${A.normal.checked?" active":""}`,"data-normal-work":!0,disabled:A.normal.disabled,onClick:A.normal.run,children:[A.normal.icon,t.jsx("span",{className:"grow",children:A.normal.label}),A.normal.checked&&t.jsx(rt,{size:13})]}),E&&t.jsxs("button",{className:"menu-item mode-agent-trigger","data-agent-switch":!0,"aria-haspopup":"menu","aria-expanded":i,title:o("input.agentSwitch.section"),onFocus:E,onClick:E,children:[M&&t.jsx("span",{className:"mode-agent-name",children:M.name}),t.jsx(Et,{size:13})]}),i&&E&&t.jsxs("div",{ref:z=>{x.current=z,w.ref.current=z},className:`cm-sub ${r}`,"data-pane":"agents",role:"menu",style:{...w.style,"--cm-sub-top":`${p}px`},children:[t.jsx("div",{className:"menu-section",children:o("input.agentSwitch.section")}),A.agents.map(z=>t.jsxs("button",{role:"menuitemradio","aria-checked":!!z.checked,className:`menu-item${z.checked?" active":""}`,onClick:z.run,children:[z.icon,t.jsx("span",{className:"grow",children:z.label}),z.checked&&t.jsx(rt,{size:13})]},z.id))]})]})}function Su(e){const n=e.find(o=>o.active),a=(n?.filePath?n:void 0)??e.find(o=>o.front&&o.filePath)??e.find(o=>o.type==="amadeus-editor"&&o.filePath)??e.find(o=>o.filePath);return a?a.type==="amadeus-editor"?a.filePath?`note:${a.filePath}`:"note":a.filePath?`file:${a.filePath}`:"":""}const pn={color:"var(--accent-ink)",flexShrink:0};function Nu({chip:e,onRemove:n,removeTitle:a,children:o}){return t.jsxs("span",{className:"attach-chip",title:e.token,"data-ref-kind":e.kind,children:[e.kind==="session"?t.jsx(Xn,{size:13,style:pn}):e.kind==="folder"?t.jsx(Kn,{size:13,style:pn}):e.kind==="view"?t.jsx(_n,{size:13,style:pn}):e.kind==="app"?t.jsx(Kr,{size:13,style:pn}):t.jsx(na,{size:13,style:pn}),t.jsx("span",{children:o??e.name}),n&&t.jsx("button",{type:"button",title:a,"aria-label":a,onClick:n,children:t.jsx(it,{size:12})})]})}const Ms=e=>e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||e,Ri=e=>e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");function Cu(e){if(/[\s"<>[\]]/.test(e)||e.includes("://"))return!1;const n=/^(~?\/|[A-Za-z]:[\\/])/.test(e),a=e.split(/[\\/]/).filter(Boolean);return n?a.length>=(/^[A-Za-z]:/.test(e)?3:2):a.length>=2&&/\.[A-Za-z0-9]{1,10}$/.test(a[a.length-1])}const zu=/^\[\[([^[\]\n]+)\]\]/,Mu=/^"([^"\n]+)"/,Au=/^<forsion-view type="([^"\n]*)" title="([^"\n]*)" \/>/,Eu=/^<forsion-app app="([^"\n]*)"[^>\n]* \/>/,Tu=/^[^\s]+/;function Ru(e,n){const a=e.slice(n);let o=zu.exec(a);if(o){const i=o[1],c=i.indexOf("|"),r=(c===-1?i:i.slice(0,c)).trim(),l=(c===-1?"":i.slice(c+1)).trim();return r?{ref:Yr(r)?{token:o[0],name:l||"Chat",kind:"session",wiki:i}:{token:o[0],name:l||Ms(r).replace(/\.md$/i,""),kind:"note",wiki:i},end:n+o[0].length,strong:!0}:null}if(o=Au.exec(a),o)return{ref:{token:o[0],name:Ri(o[2]),kind:"view"},end:n+o[0].length,strong:!0};if(o=Eu.exec(a),o)return{ref:{token:o[0],name:Ri(o[1]),kind:"app"},end:n+o[0].length,strong:!0};if(o=Mu.exec(a),o){const i=o[1];return!/\s/.test(i)||!/[\\/]/.test(i)?null:{ref:{token:o[0],name:Ms(i),kind:"file"},end:n+o[0].length,strong:!0}}return o=Tu.exec(a),o&&Cu(o[0])?{ref:{token:o[0],name:Ms(o[0]),kind:"file"},end:n+o[0].length,strong:!1}:null}function Sp(e){if(!e)return null;const n=e.indexOf(`
|
|
12
|
+
`),a=n===-1?e:e.slice(0,n),o=[];let i=!0,c=0;for(;c<a.length;){const r=Ru(a,c);if(!r)return null;if(o.push(r.ref),i=i&&r.strong,c=r.end,c===a.length)break;if(a[c]!==" "||(c+=1,c===a.length))return null}return!o.length||n===-1&&!i?null:{refs:o,body:n===-1?"":e.slice(n+1)}}const Iu=({tier:e})=>{const n=(e||"free").toLowerCase();if(n==="free"||!n)return null;const a=n==="pro"?{background:"linear-gradient(135deg, #8B5CF6, #A855F7)",color:"#fff",border:"none"}:{background:"linear-gradient(135deg, #F59E0B, #F97316)",color:"#fff",border:"none"};return t.jsx("span",{className:"tier-badge",style:a,children:n})};xe({"ctx.pop.title":{zh:"上下文窗口",en:"Context window"},"ctx.pop.compact":{zh:"立即压缩",en:"Compact now"},"ctx.grp.tools":{zh:"工具与本轮",en:"Tools & this run"},"ctx.grp.system":{zh:"系统提示",en:"System prompt"},"ctx.sec.human":{zh:"协作说明",en:"Collaboration handbook"},"ctx.grp.memory":{zh:"记忆",en:"Memory"},"ctx.grp.project":{zh:"项目与资料",en:"Project & files"},"ctx.grp.skills":{zh:"技能",en:"Skills"},"ctx.grp.used":{zh:"已用",en:"Used"},"ctx.grp.buffer":{zh:"自动压缩预留",en:"Auto-compact buffer"},"ctx.grp.free":{zh:"剩余可用",en:"Free space"},"ctx.untilCompact":{zh:"还剩 {left} 触发自动压缩({n},{pct}%)",en:"{left} until auto-compact ({n}, {pct}%)"},"ctx.limit.title":{zh:"Forsion 额度",en:"Forsion usage limits"},"ctx.limit.resetsIn":{zh:"{h} 小时 {m} 分钟后重置",en:"Resets in {h} hr {m} min"},"ctx.limit.resetsAt":{zh:"{when} 重置",en:"Resets {when}"},"ctx.limit.used":{zh:"已用 {pct}%",en:"{pct}% used"}});const Ye=e=>e>=1e6?`${Math.floor(e/1e5)/10}M`:e>=1e3?`${Math.floor(e/100)/10}k`:String(e),Ii=new Set(["persona","harness","human","guidance","profile","project","agentFolder","memory","skills","environment","hooks","plan"]),$i="var(--model-tag-blue)",$u=[{id:"system",keys:["persona","guidance","environment","hooks","plan"],color:"var(--warning)"},{id:"memory",keys:["memory","profile","harness","human"],color:"var(--green)"},{id:"project",keys:["project","agentFolder"],color:"color-mix(in srgb, var(--accent-ink) 55%, transparent)"},{id:"skills",keys:["skills"],color:"color-mix(in srgb, var(--model-tag-blue) 45%, var(--green))"}];function Lu(e,n,a){if(!n)return e>0?[{id:"used",label:a("ctx.grp.used"),tokens:e,color:$i}]:[];let o=Math.max(0,e);const i=p=>{const h=Math.min(o,Math.max(0,p));return o-=h,h},c=$u.map(p=>{const h=n.sections.filter(w=>p.keys.includes(w.k)||p.id==="system"&&!Ii.has(w.k)),f=h.reduce((w,A)=>w+A.tokens,0),x=i(f);return{id:p.id,label:a(`ctx.grp.${p.id}`),color:p.color,tokens:x,parts:x===f?h.map(w=>({label:Ii.has(w.k)?a(`ctx.sec.${w.k}`):w.k,tokens:w.tokens})):void 0}}),r={id:"messages",label:a("ctx.sec.history",{n:n.historyCount}),tokens:i(n.historyTokens),color:$i},l={id:"tools",label:a("ctx.grp.tools"),tokens:o,color:"var(--model-tag-purple)"};return[r,l,...c].filter(p=>p.tokens>0)}const So=8*36e5,Pu=e=>864e5-(e+So)%864e5;function Du(e){const n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e||"");return n?new Date(Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]))-So):null}function _u({open:e,contextWindow:n,ctxTokens:a,sessionTokens:o,runCost:i,costLimit:c,ctxInfo:r,onCompact:l}){const{t:p}=Ce(),[h,f]=u.useState(!1),x=a||0,w=_=>_/n*100,A=_=>`${Math.round(w(_)*10)/10}%`,E=Lu(Math.min(x,n),r??null,p),M=r?.compactAt&&r.compactAt<n?r.compactAt:0,z=M?Math.max(0,n-Math.max(M,x)):0,B=Math.max(0,n-x-z);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"t2c-cu-head","aria-expanded":h,onClick:()=>f(_=>!_),children:[t.jsx("span",{className:"t2c-cu-title",children:p("ctx.pop.title")}),t.jsxs("span",{className:"t2c-cu-num",children:[Ye(x)," / ",Ye(n)," tokens (",Math.min(100,Math.round(w(x))),"%)"]}),t.jsx(Et,{size:13,className:"t2c-cu-chev","aria-hidden":"true"})]}),t.jsxs("span",{className:"t2c-cu-bar","aria-hidden":"true",children:[E.map(_=>t.jsx("span",{style:{width:`${w(_.tokens)}%`,background:_.color}},_.id)),z>0&&t.jsx("span",{className:"t2c-cu-buffer",style:{width:`${w(z)}%`}})]}),r&&r.ctxWindowSource!=="override"&&(r.ctxWindowMax??0)>r.ctxWindow&&t.jsx("span",{className:"t2c-ctxinfo-src",children:p("ctx.windowCapped",{max:Ye(r.ctxWindowMax),n:Ye(r.ctxWindow)})}),h&&t.jsxs("span",{className:"t2c-cu-detail",children:[t.jsxs("span",{className:"t2c-cu-legend",children:[E.map(_=>t.jsxs(u.Fragment,{children:[t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{style:{background:_.color}}),t.jsx("span",{children:_.label}),t.jsx("span",{children:Ye(_.tokens)}),t.jsx("span",{children:A(_.tokens)})]}),_.parts&&_.parts.length>1&&_.parts.map(L=>t.jsxs("span",{className:"t2c-cu-row is-sub",children:[t.jsx("i",{}),t.jsx("span",{children:L.label}),t.jsxs("span",{children:["~",Ye(L.tokens)]}),t.jsx("span",{})]},L.label))]},_.id)),z>0&&t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{className:"t2c-cu-buffer"}),t.jsx("span",{children:p("ctx.grp.buffer")}),t.jsx("span",{children:Ye(z)}),t.jsx("span",{children:A(z)})]}),t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{className:"is-free"}),t.jsx("span",{children:p("ctx.grp.free")}),t.jsx("span",{children:Ye(B)}),t.jsx("span",{children:A(B)})]})]}),r&&t.jsx("span",{className:"t2c-ctxinfo-src",children:p(`ctx.windowSource.${["override","model","learned","family","default"].includes(r.ctxWindowSource)?r.ctxWindowSource:"default"}`)}),!!o&&o>0&&t.jsx("span",{className:"t2c-ctxinfo-src",children:p("input.sessionTokens",{n:Ye(o)})}),r&&t.jsxs("span",{className:"t2c-ctxinfo-files",children:[t.jsxs("span",{className:"t2c-ctxinfo-label",children:[p("ctx.files.label"),r.filesTruncated?` ${p("ctx.files.truncated")}`:""]}),r.files.length>0?r.files.map(_=>t.jsx("span",{className:"t2c-ctxinfo-file",title:_,children:_.split(/[/\\]/).slice(-2).join("/")},_)):t.jsx("span",{className:"t2c-ctxinfo-file dim",children:p("ctx.files.none")})]})]}),t.jsxs("span",{className:"t2c-cu-foot",children:[M>0&&t.jsx("span",{children:p("ctx.untilCompact",{left:Ye(Math.max(0,M-x)),n:Ye(M),pct:Math.round(w(M))})}),l&&t.jsx("button",{type:"button",className:"t2c-ctxring-compact",onClick:l,title:p("input.slash.compact"),children:p("ctx.pop.compact")})]}),i!=null&&c!=null&&c>0&&t.jsx("span",{className:"t2c-ctxinfo-src","data-warn":i>=c*.8||void 0,children:p("input.runCost",{used:Math.round(i).toLocaleString(),limit:c.toLocaleString()})}),t.jsx(Ou,{open:e})]})}function Ou({open:e}){const{t:n,locale:a}=Ce(),o=D(w=>w.authInfo?.loggedIn&&w.authInfo.tokenValid!==!1?`${w.authInfo.accountId??""}:${w.authInfo.username??""}`:null),i=o!==null&&!!window.tangu?.accountQuota,c=D(w=>w.authInfo?.membershipTier),[r,l]=u.useState(null),p=u.useRef(0);if(u.useEffect(()=>Xr(w=>{p.current++,l(w)}),[]),u.useEffect(()=>{l(null)},[o]),u.useEffect(()=>{if(!i||!e)return;let w=!0;const A=++p.current;return window.tangu.accountQuota().then(E=>{!w||A!==p.current||E?.status!==200||!E.json||(l(E.json),Jr(E.json))}).catch(()=>{}),()=>{w=!1}},[e,o,i]),!i||!r)return null;const h=Pu(Date.now()),f=Du(r.weeklyResetAt),x=[{key:"daily",label:n("sidebar.account.menu.daily"),limit:Number(r.dailyLimit),rem:li(r.dailyLimit,r.dailyRemaining,r.dailyPercent),reset:n("ctx.limit.resetsIn",{h:Math.floor(h/36e5),m:Math.floor(h%36e5/6e4)})},{key:"weekly",label:n("sidebar.account.menu.weekly"),limit:Number(r.weeklyLimit),rem:li(r.weeklyLimit,r.weeklyRemaining,r.weeklyPercent),reset:f?n("ctx.limit.resetsAt",{when:Gr(f,{locale:a})}):""}].filter(w=>w.limit<0||w.rem!==null);return x.length?t.jsxs("span",{className:"t2c-cu-limits",children:[t.jsxs("span",{className:"t2c-cu-limits-title",children:[n("ctx.limit.title"),t.jsx(Iu,{tier:c})]}),x.map(w=>t.jsxs("span",{className:"t2c-cu-limit","data-limit":w.key,children:[t.jsxs("span",{className:"t2c-cu-limit-line",children:[t.jsx("span",{className:"t2c-cu-limit-name",children:w.label}),w.rem!==null&&t.jsx("span",{className:"t2c-cu-limit-reset",children:w.reset}),t.jsx("span",{children:w.rem===null?n("sidebar.account.menu.unlimited"):n("ctx.limit.used",{pct:Math.round(100-w.rem)})})]}),w.rem!==null&&t.jsx("span",{className:"t2c-cu-bar","data-warn":w.rem<=15||void 0,"aria-hidden":"true",children:t.jsx("span",{style:{width:`${100-w.rem}%`}})})]},w.key))]}):null}xe({"livecall.start":{zh:"语音通话",en:"Voice call"},"livecall.return":{zh:"回到通话",en:"Back to the call"},"livecall.localOnly":{zh:"语音通话只能在本机的会话里用",en:"Voice calls only work in sessions on this computer"},"livecall.typeHint":{zh:"通话中:打的字会直接送进电话",en:"In a call: typed messages go straight into the call"},"livecall.textFallback":{zh:"通话没接上,这条改发给 Tangu 了",en:"The call did not pick this up, so it was sent to Tangu instead"}});xe({"input.modeSheetTitle":{zh:"模式",en:"Mode"},"input.agentSwitch.section":{zh:"切换 Agent",en:"Switch agent"},"input.mention.projectNote":{zh:"派往项目 · 在该项目新建会话开工",en:"Dispatch to project · starts a new session there"},"input.normalWork":{zh:"普通模式",en:"Normal mode"},"input.presetChat":{zh:"Chat",en:"Chat"},"input.presetWork":{zh:"Work",en:"Work"},"input.presetLocked":{zh:"模式在创建会话时确定;换模式请新建会话",en:"Mode is fixed when the session is created; start a new session to change it"},"input.approvalSection.team":{zh:"团队审批档 · 改动对全队生效",en:"Approval mode for the whole team"},"input.planModeTeamOff":{zh:"团队模式下不可用",en:"Not available in team mode"},"composer2.exportRoleUser":{zh:"我",en:"Me"},"composer2.listSep":{zh:"、",en:", "}});const Fu=8e3,oa="input.tip.steer",Li=[oa,"input.tip.switchChat","input.tip.quote","input.tip.dropFiles","input.tip.wikiRef","input.tip.dragSession","input.tip.branch","input.tip.newTab","input.tip.palette","input.tip.quickFind","input.tip.findInChat","input.tip.toc"],Wu=[oa,"input.tip.wikiRef"];xe({"input.tip":{zh:"小贴士:{tip}",en:"Tip: {tip}"},"input.runningPlaceholder":{zh:"运行中,可继续输入…",en:"Working… You can keep typing"},"input.steer.queuedHint":{zh:"排队项在本轮结束后依次执行 · ↑ 取回编辑",en:"Queued items run in order after this turn · ↑ to recall"},"input.tip.steer":{zh:"运行中也能继续发消息,会在下一步交给 Agent",en:"You can send while it runs: the agent reads it at the next step"},"input.tip.switchChat":{zh:"可以先切去别的会话,运行不会中断,侧栏圆点标出运行中",en:"Switch chats meanwhile; this run keeps going, marked by a sidebar dot"},"input.tip.quote":{zh:"划选回复里的文字,点「引用」即可带进下一条消息",en:"Select text in a reply and click Quote to cite it in your next message"},"input.tip.dropFiles":{zh:"文件可拖到聊天区任意位置,截图可直接粘贴进输入框",en:"Drop files anywhere in the chat, or paste a screenshot into the box"},"input.tip.wikiRef":{zh:"输入 [[ 可引用历史会话,本机项目里还能引用笔记和文件",en:"Type [[ to reference past chats, or notes and files in local projects"},"input.tip.dragSession":{zh:"把侧栏的会话拖进对话区,即可挂为引用随消息发送",en:"Drag a chat from the sidebar into the conversation to cite it"},"input.tip.branch":{zh:"悬停已完成的回复,点分支图标即可从此处开出新会话",en:"Hover a finished reply and click the branch icon to fork a new chat"},"input.tip.newTab":{zh:"⌘/Ctrl 点击侧栏里的会话,会在新标签页打开",en:"⌘/Ctrl-click a session in the sidebar to open it in a new tab"},"input.tip.palette":{zh:"按 ⌘/Ctrl+K 打开命令面板,搜索并执行命令",en:"Press ⌘/Ctrl+K to open the command palette and run commands"},"input.tip.quickFind":{zh:"⌘/Ctrl+P 快速查找,按名称跳到会话",en:"⌘/Ctrl+P opens quick find: jump to a session by name"},"input.tip.findInChat":{zh:"⌘/Ctrl+F 在当前对话里查找文字",en:"Press ⌘/Ctrl+F to find text in the current conversation"},"input.tip.toc":{zh:"悬停对话左侧的短横线展开目录,点击即可跳回任意一轮提问",en:"Hover the bars on the chat's left edge, then click to jump to a turn"}});const As=5*1024*1024,Pi=15e4,Es=25*1024*1024,Ts=[{id:"readonly",Icon:ml,key:"input.approval.readonly",desc:"input.approval.readonlyDesc"},{id:"auto-edit",Icon:nc,key:"input.approval.autoEdit",desc:"input.approval.autoEditDesc"},{id:"full-auto",Icon:sc,key:"input.approval.fullAuto",desc:"input.approval.fullAutoDesc",danger:!0},{id:"custom",Icon:ac,key:"input.approval.custom",desc:"input.approval.customDesc"}],yn=e=>e.split(/[\\/]/).pop()||e,Bu=".t2-chat-view";function Uu(e,n,a){const o=e.closest(Bu)??e,i=h=>Array.from(h.dataTransfer?.types??[]).includes("Files"),c=h=>{o===e?a(h):o.toggleAttribute("data-filedrop",h)},r=h=>{i(h)&&(h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="copy"),c(!0))},l=h=>{o.contains(h.relatedTarget)||c(!1)},p=h=>{i(h)&&(h.preventDefault(),c(!1),h.dataTransfer?.files?.length&&n(h.dataTransfer.files))};return o.addEventListener("dragover",r),o.addEventListener("dragleave",l),o.addEventListener("drop",p),()=>{o.removeEventListener("dragover",r),o.removeEventListener("dragleave",l),o.removeEventListener("drop",p),c(!1)}}const At=e=>({token:/\s/.test(e)?`"${e}"`:e,name:yn(e),kind:"file"}),qu=e=>({token:/\s/.test(e)?`"${e}"`:e,name:yn(e),kind:"folder"}),Hu=(e,n)=>{const a=o=>String(o).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");return{token:`<forsion-view type="${a(e)}" title="${a(n)}" />`,name:n,kind:"view"}},Vu=e=>{const n=a=>String(a).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\n/g," ");return{token:`<forsion-app app="${n(e.app)}" bundleId="${n(e.bundleId||"")}" pid="${e.pid}" windowId="${e.windowId}" title="${n(e.title)}" />`,name:e.app,kind:"app"}};function Rs(e,n){const a=Qi(e,n).trim();return e.kind==="session"?{token:a,name:e.title||"Chat",kind:"session"}:e.kind==="note"?{token:a,name:yn(e.path),kind:"note"}:At(e.path)}function Ku(e,n,a,o){if(a){if(n>=e.length)return null;const c=n+1;return{pos:c,val:e[e.length-c]}}if(n===0)return null;const i=n-1;return{pos:i,val:i===0?o:e[e.length-i]}}function Yu(e,n,a){return/^\/refine(\s|$)/i.test(a)&&(a="/refine"+a.slice(7)),/^\/refine(\s|$)/.test(a)&&(e||n)?`${a}
|
|
13
|
+
|
|
14
|
+
${e}${n}`.trimEnd():e+n+a}function Xu(e,n=200){return e>0?`${Math.min(e,n)}px`:"auto"}function Ju(e,n){const a=/(?:^|\s)(\/\S*)$/.exec(e.slice(0,n));return a?{start:n-a[1].length,token:a[1]}:null}const Np=({sessionId:e,advisory:n,approvalTray:a,autoFocus:o,disabled:i,disabledPlaceholder:c,running:r,execConfig:l,teamApproval:p,models:h,modelsResponse:f,modelId:x,onModelChange:w,engines:A,engineId:E,engineModels:M,engineModelId:z,onEngineModelChange:B,engineCommands:_,thinkingLevel:L,onThinkingChange:U,ultra:G,defaultModelIds:C,onDefaultModelChange:g,onContextWindowChange:O,maxIterations:Y,onMaxIterationsChange:F,verifyCommand:P,onVerifyCommandChange:$,preset:W,onPresetChange:K,planMode:Q,onPlanModeChange:Z,voiceMode:R,onVoiceModeChange:ae,liveOwner:y,liveSessionKey:q,prepareLiveSession:te,skills:Se,groupChat:ge,groupAgents:ye,groupTempAgents:Be,onGroupChange:Ie,onAddAgent:Ae,onNormalWork:Le,agents:Ee,onAgentSwitch:Pe,currentAgentSlug:De,mentionProjects:_e,onNewSession:Ue,onBranch:lt,onOpenSettings:Rt,onExecConfigChange:b,onSend:V,onStop:H,quotedText:se,onClearQuote:Ne,onBtw:qe,contextWindow:ut,ctxTokens:He,sessionTokens:Ve,runCost:m,costLimit:T,ctxInfo:N,onCompact:X,seedText:ce,onSeedConsumed:ne,seedShare:$e,takeSeedShare:dt,appendRefs:It,onAppendRefsConsumed:Gn,autoRefFromMain:re,appRef:nt,sentHistory:la,pendingSteer:kt,onCancelSteer:Wo,onWithdrawSteer:ua,onSteerNow:da})=>{const{t:j,locale:Zn}=Ce(),[he,me]=u.useState(""),[pa,ha]=u.useState(0),[ma]=u.useState(()=>!!window.tangu?.mobile||!!window.matchMedia?.("(hover: none)").matches),fa=(ma?Wu:Li).filter(s=>!E||s!==oa),[Bo,Qn]=u.useState(!1),[xt,Uo]=u.useState(!1),[es,ga]=u.useState(!1);u.useEffect(()=>{if(!r||xt)return;ha(Math.floor(Math.random()*Li.length));let s=0;const d=window.setInterval(()=>{Qn(!0),s=window.setTimeout(()=>{ha(v=>v+1),Qn(!1)},300)},Fu);return()=>{window.clearInterval(d),window.clearTimeout(s),Qn(!1),ga(!1)}},[r,xt]);const[ts,qo]=u.useState([]),[$t,Gt]=u.useState([]),[Lt,jn]=u.useState([]),[Zt,ns]=u.useState([]),[ss,Ho]=u.useState(null),Pt=s=>ns(d=>{const v=new Set(d.map(S=>S.token)),k=[];for(const S of s)v.has(S.token)||(v.add(S.token),k.push(S));return k.length?[...d,...k]:d}),[Dt,as]=u.useState([]),[va,ze]=u.useState(null),[ya,Oe]=u.useState(0),[Qt,Sn]=u.useState(null),[ka,xa]=u.useState(!1),wa=u.useRef(null),[Te,Ke]=u.useState(null),[Vo,en]=u.useState(!1),[Fe,wt]=u.useState(0),[ba,Nn]=u.useState(0),[ja,Sa]=u.useState(!1),[Ko,is]=u.useState(""),[Na,os]=u.useState([]),[Ca,Cn]=u.useState(0),[za,Ma]=u.useState(!1),[Aa,Ea]=u.useState(null),rs=u.useRef(""),[Yo,Xo]=u.useState(!1),[tn,nn]=u.useState(0),Ta=u.useRef(""),we=u.useRef(null),bt=u.useRef(null);u.useLayoutEffect(()=>{const s=bt.current;if(!s)return;const d=new ResizeObserver(([v])=>Uo(v.contentRect.width<=360));return d.observe(s),()=>d.disconnect()},[]);const sn=u.useMemo(()=>{const s=new Map(Ti("desktop").map(d=>[d.name,d]));return d=>{const v=s.get(d);return v?Zn==="en"?v.en:v.zh:d}},[Zn]);u.useEffect(()=>{let s=!0;return Zr(ot()).then(d=>{s&&qo(d)}),()=>{s=!1}},[]);const Jo=async()=>{const s=D.getState(),d=fe,S=([...d?s.messagesBySession[d]||[]:[]].reverse().find(I=>I.role==="assistant")?.content||"").trim();if(!S){s.toast(j("input.slash.nothingToCopy"),!0);return}try{await navigator.clipboard.writeText(S),s.toast(j("input.slash.copied"))}catch{s.toast(j("input.slash.nothingToCopy"),!0)}},Go=async()=>{const s=D.getState(),d=fe;if(![...d?s.messagesBySession[d]||[]:[]].reverse().find(S=>S.role==="user")){s.toast(j("input.slash.nothingToRetry"),!0);return}await s.retry(d)},Zo=async()=>{const s=D.getState(),d=fe;if(!d){s.toast(j("input.slash.nothingToExport"),!0);return}const v=s.sessions.find(pe=>pe.id===d);let k=[];try{let pe=0;for(let ve=0;ve<20;ve++){const Qe=await gc(di(d),d,500,pe||void 0);if(!Qe.length||(k=[...Qe,...k],Qe.length<500)||(pe=Number(Qe[0]?.timestamp)||0,!pe))break}}catch{}if(k.length||(k=s.messagesBySession[d]||[]),!k.length){s.toast(j("input.slash.nothingToExport"),!0);return}const S=v?.title||"Tangu Session",I=["---",`id: ${d}`,`title: ${JSON.stringify(S)}`,...v?.summary?[`summary: ${JSON.stringify(v.summary)}`]:[],...v?.model_id?[`model: ${v.model_id}`]:[],`exported_at: ${new Date().toISOString()}`,"---","",`# ${S}`,""];for(const pe of k){const ve=pe.role==="model"?"assistant":pe.role;if(ve!=="user"&&ve!=="assistant")continue;const Qe=(pe.content||"").trim(),un=Array.isArray(pe.tool_calls)?pe.tool_calls:[];if(!Qe&&!un.length)continue;I.push(ve==="user"?`## ${j("composer2.exportRoleUser")}`:"## Tangu",""),Qe&&I.push(Qe,"");for(const Mt of un){const ee=Mt?.function?.name||Mt?.name||"tool";let Me="";try{Me=String(typeof Mt?.function?.arguments=="string"?Mt.function.arguments:JSON.stringify(Mt?.function?.arguments??""))}catch{Me=""}Me=Me.replace(/\s+/g," ").trim(),I.push(`> 🔧 \`${ee}\`${Me&&Me!=="{}"?` ${Me.length>200?Me.slice(0,200)+"…":Me}`:""}`)}un.length&&I.push("");const zt=Array.isArray(pe.attachments)?pe.attachments:[];zt.length&&I.push(`> 📎 ${zt.length} attachment(s)`,"")}const J=new Blob([I.join(`
|
|
15
|
+
`)],{type:"text/markdown"}),oe=document.createElement("a");oe.href=URL.createObjectURL(J),oe.download=`tangu-${String(d).slice(0,8)}.md`,oe.click(),setTimeout(()=>URL.revokeObjectURL(oe.href),1e3)},ue=Ul(s=>{me(d=>d?d.replace(/\s+$/,"")+" "+s:s),nn(0),requestAnimationFrame(ie)}),Qo=ue.recording||ue.busy,cs=u.useRef(!1),er=()=>{cs.current=!0,ue.toggle()};u.useEffect(()=>{!cs.current||ue.recording||ue.busy||(cs.current=!1,he.trim()&&En())},[ue.recording,ue.busy]);const tr=D(s=>s.activeId),fe=e===void 0?tr:e,nr=Qr(fe),zn=y??e===null,{model:Ra,voice:sr}=Gl(),[ls,Ia]=u.useState(!1),[$a,La]=u.useState(""),ar=u.useSyncExternalStore(eu,ko),Mn=!!fe&&ar===fe;u.useEffect(()=>{if(zn)return xo(s=>{if(s.kind==="activity"){D.getState().pollSession(s.sessionId);return}if(s.kind==="transcript"){const d=()=>{const S=D.getState().messagesBySession[s.sessionId]?.find(I=>I.id===s.messageId);return S?(S.content!==s.text&&D.setState(I=>({messagesBySession:{...I.messagesBySession,[s.sessionId]:(I.messagesBySession[s.sessionId]||[]).map(J=>J.id===s.messageId?{...J,content:s.text}:J)}})),!0):!1};if(d())return;const v=D.subscribe(()=>{d()&&(v(),clearTimeout(k))}),k=setTimeout(v,3e4);return}s.kind==="effort"&&D.setState(d=>d.configBySession[s.sessionId]?{configBySession:{...d.configBySession,[s.sessionId]:{...d.configBySession[s.sessionId],thinkingLevel:s.level,...s.level!=="max"?{ultra:void 0}:{}}}}:{})})},[zn]);const ir=async()=>{if(!ls){Ia(!0),La("");try{let s=q!==void 0?q:fe;if(!s){const I=D.getState().activeId;s=te?await te():await D.getState().newSession().then(()=>D.getState().activeId),s===I&&(s=null)}if(!s)return;if(di(s).key!=="home"){La(j("livecall.localOnly"));return}const{modelId:v,agentConfig:k}=D.getState().voiceRunParams(s),S={type:"voice-call",params:{sessionId:s,model:Ra,voice:sr,title:j("livecall.title"),agentSlug:k.agentSlug,run:{model_id:v,agent_config:k}}};window.tangu?.openMini?.({view:S,mainView:{type:"chat",params:{sessionId:s}},title:j("livecall.title")})}finally{Ia(!1)}}},de=l.execMode==="host",ke=W==="chat",an=E?void 0:Ee?.find(s=>s.slug===De),on=l.approvalMode||an?.approvalMode||"auto-edit",jt=L||(ge?void 0:an?.thinkingLevel)||void 0,pt=de&&!ke&&!E&&!ge,_t=pt&&!!G&&jt==="max",{window:St,stale:or}=Gc({ctxInfo:N,contextWindow:ut,running:r,ultra:_t,model:f?.models.find(s=>s.id===x),engineUncapped:f?.ultraUncapped}),us=or&&N?{...N,ctxWindow:St||N.ctxWindow,compactAt:void 0}:N,[rr,Pa]=u.useState(!1),rn=(s,d)=>U?d===!0&&!_t&&!ru()?(Pa(!0),!1):(U(s,d),!0):!1,Da=Yt(Te==="mode",{boundary:".t2-chat-view"}),_a=Yt(Te==="ctx",{boundary:".t2-chat-view"});u.useEffect(()=>{if(!Te)return;const s=v=>{v.target?.closest?.("[data-cmenu], [data-keep-menus]")||Ke(null)},d=v=>{v.key==="Escape"&&!document.querySelector("[data-keep-menus]")&&Ke(null)};return document.addEventListener("mousedown",s),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",d)}},[Te]);const ie=()=>{const s=we.current;if(s){if(!s.value){s.style.height="";return}s.style.height="auto",s.style.height=Xu(s.scrollHeight)}};u.useEffect(()=>{const s=we.current;if(!s||typeof ResizeObserver>"u")return;let d=s.clientWidth;const v=new ResizeObserver(()=>{s.clientWidth!==d&&(d=s.clientWidth,ie())});return v.observe(s),()=>v.disconnect()},[]),u.useLayoutEffect(ie,[he]),u.useLayoutEffect(()=>{const s=we.current;r&&!xt&&!es&&s&&!s.value&&s.scrollHeight>s.clientHeight+2&&ga(!0)},[r,pa,Zn,es,he,xt]);const Oa=s=>{s&&tn===0&&(Ta.current=he);const d=Ku(la||[],tn,s,Ta.current);d&&(nn(d.pos),me(d.val),requestAnimationFrame(()=>{const v=we.current;v&&(v.focus(),v.selectionStart=v.selectionEnd=d.val.length,wt(d.val.length)),ie()}))};u.useEffect(()=>{ce&&(me(ce),ne?.(),requestAnimationFrame(()=>{we.current?.focus(),ie()}))},[ce]),u.useEffect(()=>{se&&requestAnimationFrame(()=>we.current?.focus())},[se]),u.useEffect(()=>{It?.refs.length&&(Pt(It.refs.map(s=>Rs(s,gt||""))),Gn?.(),requestAnimationFrame(()=>{we.current?.focus(),ie()}))},[It?.seq]);const Je=s=>{const d=wa.current,v=d?.start??0,k=d?.end??1/0;me(I=>I.slice(0,v)+s+I.slice(k));const S=v+s.length;return requestAnimationFrame(()=>{const I=we.current;I&&(!D.getState().feedbackOpen&&!document.querySelector("[data-keep-menus]")&&I.focus(),I.selectionStart=I.selectionEnd=S,wt(S)),ie()}),v},Fa=u.useMemo(()=>{const s=()=>{Je(""),Sn(null)},d=D.getState,v={"/stop":r?()=>{H(),s()}:void 0,"/new":Ue?()=>{Ue(),s()}:void 0,"/branch":lt?()=>{lt(),s()}:void 0,"/compact":X?()=>{X(),s()}:void 0,"/plan":Z&&!ke?()=>{Z(!Q),s()}:void 0,"/chat":K?()=>{K("chat"),s()}:()=>{d().toast(j("input.presetLocked")),s()},"/work":K?()=>{K("work"),s()}:()=>{d().toast(j("input.presetLocked")),s()},"/voice":ae?()=>{ae(!R),s()}:void 0,"/model":w&&h?.length?()=>{Sn({start:Je("/model ")}),Oe(0)}:void 0,"/loop":F?()=>{Je("/loop "),Oe(0)}:void 0,"/verify":de&&$?()=>{Je("/verify "),Oe(0)}:void 0,"/think":U?()=>{Je("/think"),Oe(0)}:void 0,"/refine":de?()=>{Je("/refine "),Oe(0)}:void 0,"/approval":()=>{Ke("mode"),s()},"/help":()=>{d().openSettings("about"),s()},"/feedback":window.tangu?.submitFeedback?()=>{d().openFeedback()&&s()}:void 0,"/btw":qe?()=>{Je("/btw "),Oe(0)}:void 0,"/skills":()=>{d().openSettings("skills"),s()},"/tools":()=>{d().openSettings("agents"),s()},"/agents":()=>{d().openSettings("agents"),s()},"/agent":()=>{d().openSettings("agents"),s()},"/mcp":()=>{d().openSettings("mcp"),s()},"/plugins":()=>{d().openSettings("plugins"),s()},"/memory":()=>{d().openSettings("forsion/f-sync"),s()},"/config":()=>{d().openSettings("general"),s()},"/login":window.tangu?.forsionLogin?()=>{d().openSettings("forsion"),s()}:void 0,"/historian":()=>{d().setActiveSpecial("agents"),s()},"/muse":()=>{d().setActiveSpecial("agents"),s()},"/groupchat":Ie&&!ke?()=>{en(!0),s()}:void 0,"/sessions":()=>{d().setActiveId(null),s()},"/cost":()=>{d().pushNotice(`${(Ve??0).toLocaleString()} tokens · ${j("input.ctxLabel")} ${(He??0).toLocaleString()}/${(St??0).toLocaleString()}`+(m!=null&&T!=null&&T>0?` · ${j("input.runCost",{used:Math.round(m).toLocaleString(),limit:T.toLocaleString()})}`:"")),s()},"/status":()=>{d().pushNotice([`${j("input.slash.status")}`,`model=${x||"-"}`,`think=${jt||"medium"}${N?.thinkingRequested===(jt||"medium")&&N.thinkingEffective&&N.thinkingEffective!==N.thinkingRequested?`→${N.thinkingEffective}`:""}`,`approval=${l.approvalMode||an?.approvalMode||(l.execMode==="host"?"auto-edit":"full-auto")} (${l.approvalMode?"session":an?.approvalMode?"agent":"default"})`,`cwd=${l.cwd||"-"}`,`loop=${Y||N?.maxIterations||90} (${Y?"session":N?.maxIterationsSource||"default"})`,`verify=${P||"-"}`,`tokens=${(Ve??0).toLocaleString()}`,`cost=${m!=null?Math.round(m).toLocaleString():"-"}${T!=null&&T>0?`/${T.toLocaleString()}`:""}`].join(`
|
|
16
|
+
`)),s()},"/copy":()=>{Jo(),s()},"/retry":()=>{Go(),s()},"/export":()=>{Zo(),s()}},k=[];if(r){const S=v["/stop"];S&&k.push({cmd:"/stop",desc:sn("/stop"),run:S})}if(E){Ue&&k.push({cmd:"/new",desc:sn("/new"),run:()=>{Ue(),s()}}),v["/feedback"]&&k.push({cmd:"/feedback",desc:sn("/feedback"),run:v["/feedback"]});for(const S of _||[])S.name.replace(/^\//,"").toLowerCase()==="feedback"&&v["/feedback"]||k.push({cmd:`/${S.name}`,desc:S.hint?`${S.description} · ${S.hint}`:S.description,run:()=>{Je(`/${S.name} `),Oe(0)}});return k}if(U){const S=E?void 0:h?.find(I=>I.id===x)?.thinkingLevels;for(const I of Pn){const J=!!S&&!S.includes(I);k.push({cmd:`/think ${I}`,desc:`${j("input.slash.thinkDesc",{level:Ds(I,j)})}${J?` ${j("pill.thinkUnsupported")}`:""}${!_t&&jt===I?j("input.slash.current"):""}`,run:()=>{rn(I,pt?!1:void 0),s()}})}pt&&k.push({cmd:"/think ultra",desc:`${j("pill.ultraTitle")}${_t?j("input.slash.current"):""}`,run:()=>{rn("max",!0),s()}})}for(const S of Ti("desktop")){if(S.name==="/stop")continue;const I=v[S.name];I&&k.push({cmd:S.arg?`${S.name} ${S.arg}`:S.name,desc:sn(S.name),run:I})}for(const S of ts)k.push({cmd:S.argHint?`/${S.name} ${S.argHint}`:`/${S.name}`,desc:S.description,run:()=>{Je(`/${S.name} `),Oe(0)}});if(Se?.length)for(const S of Se)k.push({cmd:`/skill:${S.id}`,desc:j("input.slash.skillUse",{name:S.name}),run:()=>{as(I=>I.some(J=>J.id===S.id)?I:[...I,S]),s()}});return k},[r,H,Q,R,ae,jt,Y,F,P,$,h,x,Se,Z,U,w,Ue,lt,X,Ie,ke,K,E,_,ts,sn,l,an,Ve,He,St,m,T,N,!!qe,pt,_t]),Ge=u.useMemo(()=>{if(i||ka)return null;const s=he.slice(0,Fe);if(Qt&&s.startsWith("/model ",Qt.start))return{start:Qt.start,token:s.slice(Qt.start),sub:"model"};const d=Ju(he,Fe);return d?{...d,sub:null}:null},[he,Fe,i,ka,Qt]);wa.current=Ge?{start:Ge.start,end:Fe}:null;const ht=u.useMemo(()=>{if(!Ge)return[];if(Ge.sub==="model"){const v=Ge.token.slice(7).toLowerCase();return(h||[]).filter(k=>!v||k.id.toLowerCase().includes(v)||k.name.toLowerCase().includes(v)).slice(0,12).map(k=>({cmd:k.id===x?`● ${k.name}`:k.name,desc:`${k.source==="direct"?j("input.directPrefix"):""}${k.provider} · ${k.id}`,run:()=>{w?.(k.id),Je(""),Sn(null)}}))}const s=Ge.token.toLowerCase(),d=s.startsWith("/th");return Fa.filter(v=>(d||!v.cmd.startsWith("/think "))&&(v.cmd.toLowerCase().startsWith(s)||s.length>1&&v.desc.toLowerCase().includes(s.slice(1)))).slice(0,10)},[Ge,Fa,h,x]),Ot=!!Ge&&ht.length>0;u.useEffect(()=>{Oe(0)},[Ge?.start,Ge?.token]);const cn=!!ge&&(ye?.length||0)>=2,[cr,Wa]=u.useState([]),ln=!!_e?.length,Ba=u.useMemo(()=>{if(ln)return(_e||[]).map(v=>({slug:v.path,name:v.name,description:v.path}));if(!cn)return Ee||[];const s=(Ee||[]).filter(v=>ye.includes(v.slug)),d=new Set(s.map(v=>v.slug));return[...s,...(Be||[]).filter(v=>!d.has(v.slug))]},[cn,Ee,ye,Be,ln,_e]),mt=u.useMemo(()=>{if(i||Ot||ja)return null;const s=/(?:^|\s)@([^\s@]*)$/.exec(he.slice(0,Fe));return s?{query:s[1],start:Fe-s[1].length-1}:null},[he,Fe,i,Ot,ja]),ft=u.useMemo(()=>{if(!mt)return[];const s=mt.query.toLowerCase();return Ba.filter(d=>!s||d.name.toLowerCase().includes(s)||d.slug.toLowerCase().includes(s)).slice(0,10)},[mt,Ba]),Ua=!!mt&&ft.length>0;u.useEffect(()=>{Nn(0)},[mt?.start,mt?.query]);const qa=s=>{if(!mt)return;const d=he.slice(0,mt.start),v=`@${s.name} `,k=d+v+he.slice(Fe);me(k),ln?Wa(I=>I.some(J=>J.path===s.slug)?I:[...I,{name:s.name,path:s.slug}]):cn?is(s.slug):os(I=>I.includes(s.slug)?I:[...I,s.slug]);const S=d.length+v.length;requestAnimationFrame(()=>{const I=we.current;I&&(I.focus(),I.selectionStart=I.selectionEnd=S,wt(S)),ie()})},Ze=u.useMemo(()=>{if(i||Ot||za)return null;const s=/\[\[([^\]\n]*)$/.exec(he.slice(0,Fe));return s?{query:s[1],start:Fe-s[1].length-2}:null},[he,Fe,i,Ot,za]);u.useEffect(()=>{if(!Ze||!de)return;window.amadeus&&ec();const s=l.cwd;if(!s||rs.current===s)return;rs.current=s,Ea(null);const d=new Set(["node_modules","dist","build","out","target",".git",".venv","venv","__pycache__"]);(async()=>{const k=[],S=[{dir:s,rel:"",depth:0}];for(;S.length&&k.length<2e3;){const{dir:I,rel:J,depth:oe}=S.shift();let pe=[];try{pe=await window.tangu?.listDir?.(I)||[]}catch{continue}for(const ve of pe)if(!ve.name.startsWith(".")){if(ve.isDir)oe<8&&!d.has(ve.name)&&S.push({dir:ve.path,rel:J?`${J}/${ve.name}`:ve.name,depth:oe+1});else if(k.push(J?`${J}/${ve.name}`:ve.name),k.length>=2e3)break}}return k})().then(k=>{rs.current===s&&Ea(k)}).catch(()=>{})},[Ze,l.cwd,de]);const Ha=mn(s=>s.pages),gt=mn(s=>s.vaultRoot),Va=mn(s=>s.icons),Ka=D(s=>s.sessions),Ft=gi(s=>s.pendingPrompt),Nt=yi(s=>s.pending);u.useEffect(()=>{!Nt||Nt.sessionId!==fe||!bt.current?.closest("[data-image-studio-chat]")||!bt.current.getClientRects().length||yi.getState().consume(Nt.seq)&&(me(s=>s.trim()?`${s}
|
|
17
|
+
|
|
18
|
+
${Nt.text}`:Nt.text),Gt(s=>[...s,...Nt.attachments]),requestAnimationFrame(()=>{we.current?.focus(),ie()}))},[Nt,fe]);const Ya=zi(s=>s.pending);u.useEffect(()=>{if(!fe||!Ya.some(d=>d.sessionId===fe)||!bt.current?.closest("[data-plugin-chat]"))return;const s=zi.getState().take(fe);s.length&&(me(d=>[...d.trim()?[d]:[],...s].join(`
|
|
19
|
+
|
|
20
|
+
`)),requestAnimationFrame(()=>{we.current?.focus(),ie()}))},[Ya,fe]),u.useEffect(()=>{if(!Ft||!bt.current?.getClientRects().length)return;const s=D.getState(),d=fe?s.sessions.find(v=>v.id===fe)?.project_path:s.newChatWs?.path;vi(d||"")!==vi(Ft.project)||!gi.getState().consumePrompt(Ft.seq)||(me(v=>v.trim()?`${v}
|
|
21
|
+
|
|
22
|
+
${Ft.text}`:Ft.text),requestAnimationFrame(()=>{we.current?.focus(),ie()}))},[Ft,fe]);const vt=u.useMemo(()=>{if(!Ze)return[];const s=Ze.query.toLowerCase(),d=[...de?Ha.map(S=>({p:S,note:!0})):[],...de?(Aa??[]).map(S=>({p:S})):[],...Ka.filter(S=>S.id!==fe).slice(0,300).map(S=>({p:yt(S.title,j),session:{id:S.id,title:yt(S.title,j),summary:S.summary}}))],v=s?d.filter(S=>S.p.toLowerCase().includes(s)):d,k=S=>{const I=(S.note?S.p.replace(/\.md$/i,""):S.p).split("/").pop().toLowerCase();return(I.startsWith(s)?0:I.includes(s)?1:2)*1e4+S.p.length};return[...v].sort((S,I)=>k(S)-k(I)).slice(0,10)},[Ze,Aa,Ha,Ka,fe,de,j]),ds=!!Ze&&vt.length>0;u.useEffect(()=>{Cn(0)},[Ze?.start,Ze?.query]);const Xa=s=>{if(!Ze)return;const d=(s.session?Qi({kind:"session",id:s.session.id,title:s.session.title},gt||""):s.note&>?mc(gt,s.p):/\s/.test(s.p)?`"${s.p}"`:s.p).trim();Pt([{token:d,name:s.session?s.session.title:yn(s.p),kind:s.session?"session":s.note?"note":"file"}]);const v=he.slice(0,Ze.start);me(v+he.slice(Fe)),requestAnimationFrame(()=>{const k=we.current;k&&(k.focus(),k.selectionStart=k.selectionEnd=v.length,wt(v.length)),ie()})},Ja=mn(s=>s.activePage??s.activeNotePath),Wt=Dn(s=>Su(s.mainTabs)),An=u.useMemo(()=>{if(nt){const v=Vu(nt);return ss===v.token||Zt.some(k=>k.token===v.token)?null:v}if(!de||!re||!Wt)return null;const s=Wt==="note"?Ja:Wt.startsWith("note:")?Wt.slice(5):"",d=s?gt?Rs({kind:"note",path:s},gt):null:At(Wt.slice(5));return!d||ss===d.token||Zt.some(v=>v.token===d.token)?null:d},[nt,de,re,Wt,Ja,gt,ss,Zt]),st=An?[An,...Zt]:Zt,Ga=s=>{const d=(s??he).trim(),v=s==null?d:"",k=/^\/feedback(?:\s+([\s\S]*))?$/i.exec(v);if(k&&window.tangu?.submitFeedback){D.getState().openFeedback(k[1]?.trim())&&(me(""),requestAnimationFrame(ie));return}const S=/^\/(?:btw|side)(?:\s+([\s\S]*))?$/i.exec(v);if(S&&qe){qe(S[1]?.trim()||void 0,se||void 0),se&&Ne?.(),me(""),requestAnimationFrame(ie);return}if(!d&&!st.length)return;const I=/^\/compact(?:\s+([\s\S]+))?$/i.exec(v);if(I&&X){X((I[1]||"").trim()||void 0),me(""),requestAnimationFrame(ie);return}const J=/^\/loop(?:\s+(\d+))?$/i.exec(v);if(J&&F){if(J[1]){const ee=Math.min(Math.max(1,parseInt(J[1],10)),200);F(ee),ze(j("input.slash.loopSet",{n:ee}))}else ze(j("input.slash.loop",{current:Y||N?.maxIterations||90}));me(""),requestAnimationFrame(ie);return}const oe=/^\/verify(?:\s+([\s\S]+))?$/i.exec(v);if(oe&&de&&$){const ee=(oe[1]||"").trim();ee?/^(off|clear|关闭)$/i.test(ee)?($(""),ze(j("input.slash.verifyCleared"))):($(ee),ze(j("input.slash.verifySet",{cmd:ee}))):ze(j("input.slash.verifyUsage",{current:P||j("input.slash.verifyNone")})),me(""),requestAnimationFrame(ie);return}if(ae&&/^\/(voice|text)$/i.test(v)){const ee=/^\/voice$/i.test(d);ae(ee),ze(j(ee?"input.slash.voiceOnHint":"input.slash.voiceOffHint")),me(""),requestAnimationFrame(ie);return}const pe=/^\/(?:think|effort)(?:\s+(\S+))?$/i.exec(v);if(pe&&U){const ee=(pe[1]||"").toLowerCase();pt&&ee==="ultra"?rn("max",!0)&&ze(j("input.slash.thinkSet",{level:j("pill.ultra")})):Pn.includes(ee)?(rn(ee,pt?!1:void 0),ze(j("input.slash.thinkSet",{level:Ds(ee,j)}))):ze(j("input.slash.thinkUsage",{levels:[...Pn,...pt?["ultra"]:[]].join("|")})),me(""),requestAnimationFrame(ie);return}const ve=/^\/([a-z0-9][a-z0-9-]*)(?:\s+([\s\S]*))?$/i.exec(v);if(ve&&ts.some(ee=>ee.name===ve[1].toLowerCase())){const ee=ve[1].toLowerCase(),Me=ve[2]||"";me(""),requestAnimationFrame(ie),pc(ot(),ee,Me).then(Bt=>V(Bt,[],[],void 0,void 0)).catch(Bt=>ze(String(Bt?.message||Bt)));return}if(i)return;if(Mn&&!s&&d&&d.length<=tu&&!$t.length&&!Lt.length&&!st.length&&!se&&!Dt.length)return me(""),nn(0),ze(null),requestAnimationFrame(ie),nu(fe,d).then(async ee=>{if(ee)return!0;const Me=await Promise.resolve(Ga(d)).catch(()=>!1)??!1;return Me?ze(j("livecall.textFallback")):me(Bt=>Bt||d),Me});const Qe=se?`${se.split(`
|
|
23
|
+
`).map(ee=>`> ${ee}`).join(`
|
|
24
|
+
`)}
|
|
25
|
+
|
|
26
|
+
`:"",un=st.length?st.map(ee=>ee.token).join(" ")+`
|
|
27
|
+
`:"",zt=Yu(un,Qe,d);if(zt.length>Pi){ze(j("input.tooLong",{len:zt.length.toLocaleString(),max:Pi.toLocaleString()}));return}ze(null);const Mt=ln?{mentionProjects:(()=>{const ee=cr.filter(Me=>zt.includes(`@${Me.name}`));return ee.length?ee:void 0})()}:cn?{priorityAgent:Ko||void 0}:{mentionAgents:Na.length?Na:void 0};return V(zt,$t,Lt,Dt.map(ee=>ee.id),Mt).then(ee=>ee?(s||(me(""),nn(0),hc("tick")),Gt([]),jn([]),ns([]),as([]),is(""),os([]),Wa([]),Ne?.(),requestAnimationFrame(ie),!0):!1)},En=()=>{Ga()},Za=async s=>{if(!s)return;const d=[],v=[];for(const k of Array.from(s)){if(!k.type.startsWith("image/")){v.push(j("input.skip.notImage",{name:k.name}));continue}if(k.size>As){v.push(j("input.skip.tooBig",{name:k.name,mb:String(Math.round(As/1024/1024))}));continue}const S=await k.arrayBuffer();let I="";const J=new Uint8Array(S);for(let oe=0;oe<J.length;oe+=32768)I+=String.fromCharCode(...J.subarray(oe,oe+32768));d.push({name:k.name,mimeType:k.type,data:btoa(I),size:k.size})}ze(v.length?j("input.skip.imageHint",{items:v.join(j("composer2.listSep"))}):null),Gt(k=>[...k,...d])},ps=async s=>{if(!s)return;const d=[],v=[];for(const k of Array.from(s)){if(k.size>Es){v.push(j("input.skip.tooBig",{name:k.name,mb:String(Math.round(Es/1024/1024))}));continue}const S=await k.arrayBuffer();let I="";const J=new Uint8Array(S);for(let oe=0;oe<J.length;oe+=32768)I+=String.fromCharCode(...J.subarray(oe,oe+32768));d.push({name:k.name,mimeType:k.type||"application/octet-stream",data:btoa(I),size:k.size})}ze(v.length?j("input.skip.simple",{items:v.join(j("composer2.listSep"))}):null),jn(k=>[...k,...d])},Qa=s=>{if(s.length){if(de&&window.tangu?.getPathForFile){const d=Array.from(s).map(v=>{try{return window.tangu.getPathForFile(v)}catch{return""}}).filter(Boolean);if(d.length){Pt(d.map(At)),requestAnimationFrame(()=>{we.current?.focus(),ie()});return}}ps(s)}},ei=u.useRef(Qa);ei.current=Qa,u.useEffect(()=>{const s=bt.current;return s?Uu(s,d=>ei.current(d),Xo):void 0},[]);const ti=async s=>{if(!s?.length)return;const d=Array.from(s).filter(k=>k.type.startsWith("image/")),v=Array.from(s).filter(k=>!k.type.startsWith("image/"));if(d.length){const k=new DataTransfer;d.forEach(S=>k.items.add(S)),await Za(k.files)}if(v.length){const k=new DataTransfer;v.forEach(S=>k.items.add(S)),await ps(k.files)}};u.useEffect(()=>{if(!$e)return;const s=dt?.();if(s&&(s.text&&(me(d=>d.trim()?`${d.replace(/\s+$/,"")}
|
|
28
|
+
|
|
29
|
+
${s.text}`:s.text),requestAnimationFrame(()=>ie())),s.files.length)){const d=new DataTransfer;s.files.forEach(v=>d.items.add(v)),ti(d.files)}},[$e]);const lr=async s=>{const d=[],v=[],k=[];for(const S of s){if(S.isDirectory){k.push(qu(S.path));continue}try{const I=await window.tangu?.readHostFile?.(S.path);if(!I||I.tooLarge){k.push(At(S.path));continue}const J={name:yn(S.path),mimeType:I.mimeType,data:I.content,size:I.size};I.mimeType.startsWith("image/")&&I.size<=As?d.push(J):I.size<=Es?v.push(J):k.push(At(S.path))}catch{k.push(At(S.path))}}d.length&&Gt(S=>[...S,...d]),v.length&&jn(S=>[...S,...v]),k.length&&Pt(k)},ur=s=>{Pt([s.kind==="view"?Hu(s.type,s.title):Rs(s,gt||"")]),requestAnimationFrame(()=>we.current?.focus())},[dr,ni]=u.useState(!1),pr=D(s=>s.cfg),hr=s=>{b({execMode:"host",approvalMode:s,cwd:l.cwd}),Ke(null)},si=tc(),mr=u.useMemo(()=>Zc(h||[],si),[h,si]),at=!!ge&&(ye?.length||0)>=2,fr=!!Ra&&zn&&!!window.tangu?.openMini&&!(Q&&!ke)&&!at&&!ke&&!E,hs=Ts.find(s=>s.id===on)||Ts[1],gr=at?j("group.modeLabel",{n:ye.length}):j(Q&&!ke?"input.planMode":ke?"input.presetChat":de?hs.key:"input.normal"),vr=at?$s:Q&&!ke?ui:de?hs.Icon:Xn,ai=!at&&!(Q&&!ke)&&!ke&&de&&hs.id==="full-auto",yr=!ke&&(!!Z||de||!!Ie||!!Pe),kr=(A||[]).find(s=>s.id===E)?.name||j("input.engineDefault"),be=!!E,xr=be?[{label:kr,options:M||[]}]:mr.map(s=>({key:s.key,label:s.provider,source:s.source,options:s.models.map(d=>({...d,description:`${d.provider} · ${d.id}`}))})),wr=be||!!w||!!U,Tn=()=>Ke(null),ii={active:!Q&&!at&&on==="auto-edit",disabled:r,agents:Ee||[],currentAgentSlug:De,onNormalWork:Le||(()=>{}),onAgentSwitch:!be&&!at?Pe:void 0,onClose:Tn},ms=Z&&!ke?{title:j("input.planMode"),items:[{id:"plan-mode",icon:t.jsx(ui,{size:14}),label:j(ge?"input.planModeTeamOff":Q?"input.planModeOn":"input.planModeEnable"),checked:!!Q&&!ge,disabled:!!ge,run:()=>{Z(!Q),Tn()}}]}:null,fs=Ie&&!be&&!ke?{title:j("group.menu.section"),items:[{id:"group-chat",label:at?j("group.menu.configured",{n:ye.length}):j("group.menu.enable"),icon:t.jsx($s,{size:14}),checked:at,run:()=>{en(!0),Tn()}}]}:null,oi=de?Ts.map(({id:s,Icon:d,key:v,desc:k,...S})=>({id:`approval:${s}`,approvalId:s,label:j(v),detail:j(k),icon:t.jsx(d,{size:15,className:"approval-ic"}),checked:on===s,danger:"danger"in S,run:()=>hr(s)})):[],Ct=de&&on==="custom"?{id:"approval-rules",label:j("input.approval.editRules"),detail:j("input.approval.editRulesDesc"),icon:t.jsx(fc,{size:15,className:"approval-ic"}),run:()=>{ni(!0),Tn()}}:null,br=()=>{const s=Le&&!ke?jo(ii,j):null;return{title:j("input.modeSheetTitle"),back:j("common.back"),sections:[{items:s?[s.normal,...s.agentSwitch?[s.agentSwitch]:[]]:[]},...ms?[ms]:[],...fs?[fs]:[],...de?[{title:j(p?"input.approvalSection.team":"input.approvalSection"),items:[...oi,...Ct?[Ct]:[]]}]:[]]}};return t.jsxs("div",{className:"t2c",children:[Vo&&t.jsx(pu,{agents:Ee||[],models:h,initialAgents:ye||[],initialTempAgents:Be,active:at,hideDisable:!0,onConfirm:s=>{Ie?.({groupChat:!0,...s}),en(!1),ic("chat.group")},onDisable:()=>Ie?.({groupChat:!1}),onClose:()=>en(!1)}),t.jsxs("div",{className:"t2c-inner",children:[!!kt?.length&&t.jsxs("div",{className:"t2c-steer",role:"status","aria-label":j("input.steer.waiting"),children:[kt.map(s=>t.jsxs("div",{className:"t2c-steer-item",children:[t.jsx(il,{size:12,className:"t2c-steer-ic"}),t.jsx("span",{className:"t2c-steer-text",title:s.text,children:s.text}),t.jsx("button",{className:"t2c-steer-x",title:j("input.steer.remove"),onClick:()=>Wo?.(s.id),children:t.jsx(it,{size:12})})]},s.id)),t.jsxs("div",{className:"t2c-steer-foot",children:[t.jsx("span",{className:"t2c-steer-hint",children:j(kt.some(s=>s.localOnly)?"input.steer.queuedHint":"input.steer.hint")}),da&&kt.some(s=>!s.localOnly)&&t.jsxs("button",{className:"t2c-steer-now",onClick:da,children:[t.jsx(oc,{size:11})," ",j("input.steer.now")]})]})]}),a,t.jsxs(rc,{ref:bt,className:Yo?"dragover":void 0,children:[n,va&&t.jsx("div",{className:"t2c-hint",children:va}),se&&t.jsxs("div",{className:"t2c-quote",children:[t.jsx("span",{className:"t2c-quote-text",children:se.length>280?`${se.slice(0,280)}…`:se}),t.jsx("button",{title:j("input.remove"),onClick:()=>Ne?.(),className:"t2c-quote-x",children:t.jsx(it,{size:12})})]}),st.length>0&&t.jsxs("div",{className:"t2c-chiprow t2c-refrow",role:"group","aria-label":j("input.ref.selected"),children:[t.jsx("span",{className:"t2c-reflabel",children:j("input.ref.selected")}),st.map(s=>t.jsx(Nu,{chip:s,removeTitle:j("input.remove"),onRemove:()=>{An&&s.token===An.token?Ho(s.token):ns(d=>d.filter(v=>v.token!==s.token))}},s.token))]}),$t.length>0&&t.jsx("div",{className:"t2c-chiprow",children:$t.map((s,d)=>t.jsxs("span",{className:"attach-chip",children:[s.mimeType.startsWith("image/")&&t.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:s.name}),t.jsx("span",{children:s.name}),t.jsx("button",{title:j("input.remove"),onClick:()=>Gt($t.filter((v,k)=>k!==d)),children:t.jsx(it,{size:12})})]},`${s.name}-${d}`))}),Lt.length>0&&t.jsx("div",{className:"t2c-chiprow",children:Lt.map((s,d)=>t.jsxs("span",{className:"attach-chip",title:j("input.wsUploadTitle",{name:s.name}),children:[s.mimeType.startsWith("image/")?t.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:s.name}):t.jsx(na,{size:14,style:{color:"var(--accent-ink)",flexShrink:0}}),t.jsx("span",{children:s.name}),t.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)",flexShrink:0},children:j("input.toWorkspace")}),t.jsx("button",{title:j("input.remove"),onClick:()=>jn(Lt.filter((v,k)=>k!==d)),children:t.jsx(it,{size:12})})]},`ws-${s.name}-${d}`))}),Dt.length>0&&t.jsx("div",{className:"t2c-chiprow",children:Dt.map(s=>t.jsxs("span",{className:"attach-chip",title:j("input.skillChipTitle"),children:[t.jsx(Ki,{size:13,style:{color:"var(--accent-ink)",flexShrink:0}}),t.jsx("span",{children:s.name}),t.jsx("button",{title:j("input.remove"),onClick:()=>as(Dt.filter(d=>d.id!==s.id)),children:t.jsx(it,{size:12})})]},`skill-${s.id}`))}),t.jsx(cc,{autoSize:!1,ref:we,className:"t2c-ta",rows:1,autoFocus:o,value:he,placeholder:i?c||j("input.placeholderDisabled"):Mn?j("livecall.typeHint"):r?xt?j("input.runningPlaceholder"):j("input.tip",{tip:j(fa[pa%fa.length])}):j(ma?"input.placeholderTouch":"input.placeholder"),"data-tip-fade":r&&!xt&&Bo||void 0,"data-tip-tall":r&&!xt&&es||void 0,disabled:i,onChange:s=>{me(s.target.value),wt(s.target.selectionStart||0),xa(!1),Sa(!1),Ma(!1),tn&&nn(0),s.target.value.includes("@")||(is(""),os([])),ie()},onSelect:s=>wt(s.target.selectionStart||0),onPaste:s=>{const d=s.clipboardData?.files;if(!d?.length)return;s.preventDefault();const v=Array.from(d),k=v.filter(J=>J.type.startsWith("image/")),S=v.filter(J=>!J.type.startsWith("image/")),I=[];if(S.length){const J=[];for(const oe of S){let pe="";if(de)try{pe=window.tangu?.getPathForFile?.(oe)||""}catch{pe=""}pe?J.push(pe):I.push(oe)}J.length&&(Pt(J.map(At)),requestAnimationFrame(()=>{we.current?.focus(),ie()}))}if(k.length){const J=new DataTransfer;k.forEach(oe=>J.items.add(oe)),Za(J.files)}if(I.length){const J=new DataTransfer;I.forEach(oe=>J.items.add(oe)),ps(J.files)}},onKeyDown:s=>{if(ds){if(s.key==="ArrowDown"){s.preventDefault(),Cn(d=>(d+1)%vt.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Cn(d=>(d-1+vt.length)%vt.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),Xa(vt[Math.min(Ca,vt.length-1)]);return}if(s.key==="Escape"){s.preventDefault(),Ma(!0);return}}if(Ua){if(s.key==="ArrowDown"){s.preventDefault(),Nn(d=>(d+1)%ft.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Nn(d=>(d-1+ft.length)%ft.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),qa(ft[Math.min(ba,ft.length-1)]);return}if(s.key==="Escape"){s.preventDefault(),Sa(!0);return}}if(Ot){if(s.key==="ArrowDown"){s.preventDefault(),Oe(d=>(d+1)%ht.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Oe(d=>(d-1+ht.length)%ht.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),ht[Math.min(ya,ht.length-1)]?.run();return}if(s.key==="Escape"){s.preventDefault(),xa(!0),Sn(null);return}}if(s.key==="ArrowUp"&&kt?.length&&ua&&tn===0&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&he.slice(0,s.currentTarget.selectionStart).indexOf(`
|
|
30
|
+
`)===-1){s.preventDefault();const d=kt[kt.length-1];ua(d.id).then(v=>{v&&(me(k=>k.trim()?`${v}
|
|
31
|
+
|
|
32
|
+
${k}`:v),requestAnimationFrame(()=>{const k=we.current;k&&(k.focus(),k.selectionStart=k.selectionEnd=v.length,wt(v.length)),ie()}))});return}if(s.key==="ArrowUp"&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&he.slice(0,s.currentTarget.selectionStart).indexOf(`
|
|
33
|
+
`)===-1&&la?.length){s.preventDefault(),Oa(!0);return}if(s.key==="ArrowDown"&&tn>0&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&he.slice(s.currentTarget.selectionStart).indexOf(`
|
|
34
|
+
`)===-1){s.preventDefault(),Oa(!1);return}s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&(s.preventDefault(),En())}}),Ot&&t.jsx("div",{className:"t2c-menu",children:ht.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(ya,ht.length-1)||void 0,onMouseEnter:()=>Oe(d),onClick:()=>s.run(),children:[t.jsx("span",{className:"t2c-menu-cmd",children:s.cmd}),t.jsx("span",{className:"t2c-menu-desc",children:s.desc})]},`${s.cmd}-${d}`))}),Ua&&!ds&&t.jsxs("div",{className:"t2c-menu",children:[t.jsx("div",{className:"t2c-menu-sec",children:j(ln?"input.mention.projectNote":cn?"input.mention.groupNote":"input.mention.delegateNote")}),ft.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(ba,ft.length-1)||void 0,onMouseEnter:()=>Nn(d),onClick:()=>qa(s),children:[t.jsxs("span",{className:"t2c-menu-cmd",children:["@",s.name]}),t.jsx("span",{className:"t2c-menu-desc",children:s.description||s.slug})]},s.slug))]}),ds&&t.jsxs("div",{className:"t2c-menu",children:[t.jsx("div",{className:"t2c-menu-sec",children:j("input.fileref.note")}),vt.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(Ca,vt.length-1)||void 0,onMouseEnter:()=>Cn(d),onClick:()=>Xa(s),children:[t.jsx("span",{className:"t2c-menu-cmd",children:s.session?`💬 ${s.session.title}`:s.note?`${Va[s.p]?`${Va[s.p]} `:""}${s.p.split("/").pop().replace(/\.md$/i,"")}`:s.p.split("/").pop()}),t.jsx("span",{className:"t2c-menu-desc",children:s.session?s.session.summary||j("input.fileref.session"):s.p})]},s.session?`s:${s.session.id}`:(s.note?"n:":"f:")+s.p))]}),t.jsxs(lc,{children:[t.jsx(bu,{open:Te==="add",disabled:i,activeSessionId:fe,canUsePathPicker:de,onOpenChange:s=>Ke(s?"add":null),onNewSession:Ue,onAddAgent:!r&&!ke&&!be?Ae||(Ie?()=>en(!0):void 0):void 0,onPickPaths:lr,onPickFiles:ti,onAddReference:ur}),Qo?t.jsx(ou,{analyser:ue.analyser,recording:ue.recording,busy:ue.busy,onStop:ue.toggle,onSend:er,t:j}):t.jsxs(t.Fragment,{children:[yr&&t.jsxs("span",{className:`mode-pill-wrap t2c-capsule-peer${Te==="mode"?" is-open":""}`,"data-cmenu":!0,children:[t.jsxs("button",{className:`t2c-pill mode-pill-btn${Te==="mode"?" is-open":""}${Q&&!ke?" active":""}`,"data-danger":ai||void 0,title:j(ai?"input.approval.fullAutoDesc":"input.modeChipTitle"),"aria-expanded":Te==="mode",onClick:()=>{if(Te!=="mode"&&ia(br,{})){Ke(null);return}Ke(s=>s==="mode"?null:"mode")},children:[t.jsx(vr,{size:13}),t.jsx("span",{className:"t2c-pill-label",children:gr}),t.jsx(xn,{size:10})]}),Te==="mode"&&t.jsxs("div",{ref:Da.ref,className:"composer-menu composer-menu--mode",style:Da.style,children:[Le&&!ke&&t.jsx(ju,{...ii}),[ms,fs].map(s=>s&&t.jsxs(gn.Fragment,{children:[t.jsx("div",{className:"menu-section",children:s.title}),s.items.map(d=>t.jsxs("button",{className:`menu-item${d.checked?" active":""}`,disabled:d.disabled,onClick:d.run,children:[d.icon,t.jsx("span",{className:"grow",children:d.label}),d.checked&&t.jsx(rt,{size:13})]},d.id))]},s.items[0].id)),de&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:j(p?"input.approvalSection.team":"input.approvalSection")}),oi.map(s=>t.jsxs("button",{className:`menu-item approval-item${s.checked?" active":""}${s.danger?" danger":""}`,"aria-describedby":`approval-mode-desc-${s.approvalId}`,onClick:s.run,children:[s.icon,t.jsx("span",{className:"grow approval-title",children:s.label}),s.checked&&t.jsx(rt,{size:13,className:"approval-ck"}),t.jsx("span",{id:`approval-mode-desc-${s.approvalId}`,role:"tooltip",className:"approval-hover-desc",children:s.detail})]},s.approvalId)),Ct&&t.jsxs("button",{className:"menu-item approval-item","aria-describedby":"approval-edit-rules-desc",onClick:Ct.run,children:[Ct.icon,t.jsx("span",{className:"grow approval-title",children:Ct.label}),t.jsx("span",{id:"approval-edit-rules-desc",role:"tooltip",className:"approval-hover-desc",children:Ct.detail})]})]})]})]}),t.jsx("span",{className:"t2c-grow"}),!ke&&!!St&&St>0&&(()=>{const s=Math.min(100,Math.round((He||0)/St*100)),d=us?.compactAt?(He||0)>=us.compactAt*.8:s>=80,v=9,k=2*Math.PI*v;return t.jsxs("span",{className:`t2c-ctxring t2c-collapse-on-capsule-open${Te==="ctx"?" is-open":""}`,"data-warn":d||void 0,"data-cmenu":!0,children:[t.jsx("button",{type:"button",className:"t2c-ctxring-btn","aria-expanded":Te==="ctx","aria-label":`${j("input.ctxLabel")} ${s}%`,...co(()=>Te==="ctx"?null:[`${j("input.ctxLabel")} ${s}%`]),onClick:()=>{ol(),Ke(S=>S==="ctx"?null:"ctx")},children:t.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":"true",children:[t.jsx("circle",{className:"t2c-ctxring-track",cx:"12",cy:"12",r:v}),t.jsx("circle",{className:"t2c-ctxring-fill",cx:"12",cy:"12",r:v,style:{strokeDasharray:k,strokeDashoffset:k*(1-s/100)}})]})}),t.jsx("span",{ref:_a.ref,className:"t2c-ctxring-pop",style:_a.style,children:t.jsx(_u,{open:Te==="ctx",contextWindow:St,ctxTokens:He,sessionTokens:Ve,runCost:m,costLimit:T,ctxInfo:us,onCompact:X?()=>{X(),Ke(null)}:void 0})})]})})(),wr&&t.jsx(Qc,{scopeKey:`${fe??"draft"}:${uc(nr)}:${be?"engine":"tangu"}`,className:"t2c-capsule-peer",open:Te==="model",onOpenChange:s=>Ke(s?"model":null),disabled:i,modelId:be?z:x,groups:xr,onSelect:be?s=>B?.(s):s=>w?.(s),thinkingLevel:be?void 0:jt,onThinkingChange:be||!U?void 0:(s,d)=>{rn(s,d)},allowUltra:pt,ultra:_t,running:r,supportedThinking:be?void 0:h?.find(s=>s.id===x)?.thinkingLevels,effectiveThinking:be?void 0:N?.thinkingRequested===(jt||"medium")?N?.thinkingEffective:void 0,modelsResponse:be?void 0:f,defaultModelIds:be?void 0:C,onDefaultModelChange:be?void 0:g,onContextWindowChange:be?void 0:O,emptyLabel:be?j("input.engineModelDefault"):void 0,footnote:!be&&!de&&!h?.some(s=>s.source==="direct")?j("input.cloudModelHint"):void 0}),t.jsx("button",{className:`t2c-iconbtn t2c-mic-control t2c-collapse-on-capsule-open${ue.recording?" recording":""}`,title:ue.busy?j("input.micBusy"):ue.recording?j("input.micStop"):ue.error||j("input.micStart"),disabled:i||ue.busy||!ue.supported,onClick:ue.toggle,children:ue.busy?t.jsx(Kt,{size:14,className:"spin"}):t.jsx(dc,{size:14})}),r?t.jsxs(t.Fragment,{children:[(!!he.trim()||st.length>0)&&t.jsx(ys,{onClick:En,disabled:i,title:j("input.send"),"aria-label":j("input.send")}),t.jsxs("button",{className:"t2c-stop",onClick:H,title:j("input.stop"),"aria-label":j("input.stop"),children:[t.jsx(Yi,{size:10}),t.jsx("span",{className:"t2c-stop-label",children:j("input.stop")})]})]}):fr&&!he.trim()&&!st.length&&!$t.length&&!Lt.length&&!se&&!Dt.length?t.jsx(ys,{className:"t2c-live-control",onClick:()=>{ir()},disabled:!!i||ls,title:j(Mn?"livecall.return":"livecall.start"),"aria-label":j(Mn?"livecall.return":"livecall.start"),children:ls?t.jsx(Kt,{size:16,className:"spin"}):t.jsx(bl,{size:16})}):t.jsx(ys,{onClick:En,disabled:i||!he.trim()&&!st.length,title:j("input.send"),"aria-label":j("input.send")})]})]}),ue.error&&!ue.recording&&!ue.busy&&t.jsx("div",{className:"t2c-hint",style:{marginTop:6,marginBottom:0},children:ue.error}),$a&&zn&&!ue.error&&t.jsx("div",{className:"t2c-hint",style:{marginTop:6,marginBottom:0},children:$a})]})]}),dr&&t.jsx(yu,{cfg:pr,onClose:()=>ni(!1)}),rr&&t.jsx(cu,{offerFullAccess:de&&!p&&on!=="full-auto",onConfirm:({fullAccess:s})=>{s&&b({execMode:"host",approvalMode:"full-auto",cwd:l.cwd}),U?.("max",!0)},onClose:()=>Pa(!1)})]})};function Gu(e,n){const a=Math.max(0,e.content-e.width);if(e.left>=a-1)return 0;const o=e.left+e.width,i=n.find(r=>r.end>o+1),c=i?Math.min(i.start,a):a;return c>e.left+1?c:Math.min(o,a)}function Zu(e,n){return e-n>1}xe({"chatPicker.engine":{zh:"引擎",en:"Engine"},"chatPicker.agent":{zh:"Agent",en:"Agent"}});function Qu({label:e,value:n,icon:a,options:o,onChange:i,busy:c=!1}){const r=o.find(l=>l.value===n);return t.jsxs("label",{className:"compact-chat-picker","aria-busy":c||void 0,title:r?.name,children:[t.jsx("span",{className:"compact-chat-picker-kind",children:e}),t.jsx("span",{className:"compact-chat-picker-icon",children:a}),t.jsx("span",{className:"compact-chat-picker-name",children:r?.name||e}),t.jsx(xn,{size:13}),t.jsxs("select",{"aria-label":e,value:r?n:"",onChange:l=>i(l.target.value),children:[!r&&t.jsx("option",{value:"",disabled:!0,children:e}),o.map(l=>t.jsx("option",{value:l.value,disabled:l.disabled,children:l.description?`${l.name} — ${l.description}`:l.name},l.value))]})]})}const ed=({label:e,children:n,role:a="radiogroup"})=>{const{t:o}=Ce(),i=u.useRef(null),[c,r]=u.useState(!1);u.useLayoutEffect(()=>{const p=i.current;if(!p)return;const h=()=>{const x=p.parentElement,w=x&&getComputedStyle(x),A=x&&w?x.clientWidth-parseFloat(w.paddingLeft)-parseFloat(w.paddingRight):p.clientWidth;r(Zu(p.scrollWidth,A))};h();const f=new ResizeObserver(h);f.observe(p);for(const x of Array.from(p.children))f.observe(x);return()=>f.disconnect()},[n]),u.useEffect(()=>{const p=i.current,h=p?.querySelector('[aria-checked="true"],[aria-pressed="true"]');if(!p||!h)return;const f=p.getBoundingClientRect(),x=h.getBoundingClientRect();x.right>f.right?p.scrollLeft+=x.right-f.right+6:x.left<f.left&&(p.scrollLeft-=f.left-x.left+6)},[]);const l=u.useCallback(()=>{const p=i.current;if(!p)return;const h=p.getBoundingClientRect(),f=Array.from(p.children).map(x=>{const w=x.getBoundingClientRect();return{start:w.left-h.left+p.scrollLeft,end:w.right-h.left+p.scrollLeft}});p.scrollTo({left:Gu({left:p.scrollLeft,width:p.clientWidth,content:p.scrollWidth},f),behavior:"smooth"})},[]);return t.jsxs("div",{className:"engine-picker-bar","data-more":c||void 0,children:[t.jsx("div",{className:"engine-picker-scroll",ref:i,role:a,"aria-label":e,children:n}),c&&t.jsx("button",{type:"button",className:"engine-picker-more",onClick:l,title:o("pill.more"),"aria-label":o("pill.more"),children:t.jsx(qn,{size:16})})]})};function td(e,n,a){const o=vc(e,n),i=o.groupAgents??[];return o.groupChat&&i.length>=2?{kind:"team",count:i.length}:{kind:"agent",slug:o.agentSlug||a||null}}const Ks=e=>Array.from((e||"").trim());function nd(e,n){const a=e.map(r=>r.toLowerCase()),o=a.join("");let i=0;for(const r of n){if(!r.length||r.join("")===o||r[0]!==a[0])continue;let l=0;for(;l<a.length&&l<r.length&&a[l]===r[l];)l++;i=Math.max(i,l)}const c=[];for(let r=i;i&&r<e.length;r++)e[r].trim()&&c.push(e[r]);return{first:e[0],picks:c,collides:i>0}}function sd(e){const n=e.map(l=>Ks(l)),a=n.map(l=>l.map(p=>p.toLowerCase())),o=n.map(()=>"?"),i=new Set,c=[];n.forEach((l,p)=>{if(!l.length)return;const{first:h,picks:f,collides:x}=nd(l,a);if(!x||!f.length){o[p]=h.toUpperCase(),i.add(h.toLowerCase());return}c.push({index:p,key:a[p].join(""),picks:f,first:h})}),c.sort((l,p)=>l.key<p.key?-1:l.key>p.key?1:l.index-p.index);const r=new Map;for(const l of c){const p=r.get(l.key);if(p){o[l.index]=p;continue}const f=(l.picks.find(x=>!i.has(x.toLowerCase()))??l.first).toUpperCase();i.add(f.toLowerCase()),r.set(l.key,f),o[l.index]=f}return o}function ad(e,n=[]){const a=Ks(e);if(!a.length)return"?";const o=a.join("").toLowerCase();let i=n.findIndex(r=>Ks(r).join("").toLowerCase()===o);const c=i>=0?n:[e,...n];return i<0&&(i=0),sd(c)[i]}const Di=(...e)=>e.filter(Boolean).join(" ")||void 0;function id({name:e,url:n,siblings:a,className:o,imgClassName:i,initialClassName:c,size:r,fill:l,title:p,style:h,...f}){return n?t.jsx("img",{...f,className:Di(o,i),src:n,alt:"",title:p,draggable:!1,width:r,height:r,style:h}):t.jsx("span",{...f,className:Di("agent-avatar-initial",l&&"agent-avatar-fill",o,c),title:p,"aria-hidden":"true",style:h,children:t.jsx("span",{className:"agent-avatar-glyph",children:ad(e,a)})})}xe({"agentSelect.title":{zh:"选择 Agent",en:"Pick agents"},"agentSelect.hintDefault":{zh:"由默认 Agent {name} 处理",en:"Handled by the default agent, {name}"},"agentSelect.hintDefaultAnon":{zh:"由默认 Agent 处理",en:"Handled by the default agent"},"agentSelect.hintOne":{zh:"{name} 将处理这条消息",en:"{name} will handle this message"},"agentSelect.removeHint":{zh:"再次点击移除",en:"Click again to remove"},"agentSelect.team":{zh:"团队模式 · {n} 人",en:"Team mode · {n} people"},"agentSelect.picked":{zh:"已选",en:"Picked"},"agentSelect.default":{zh:"默认 Agent",en:"Default agent"},"agentSelect.defaultTag":{zh:"默认",en:"Default"},"agentSelect.direct":{zh:"私聊",en:"Direct chat"}});const Ut=2,qt=e=>`agent:${e}`,hn=e=>`engine:${e}`,od=(e,n)=>e.length===n.length&&e.every((a,o)=>a===n[o]);function rd(e){if(e.engineId)return[];const n=e.groupAgents??[];return e.groupChat&&n.length>=2?[...n]:e.agentSlug?[e.agentSlug]:[]}function Cp({sessionId:e,cfg:n}){const{t:a}=Ce(),[o,i]=u.useState(null),c=D(yc(y=>({agentDefs:y.agentDefs,agentAvatars:y.agentAvatars,defaultAgentSlug:y.defaultAgentSlug,engines:y.engines,engineCaps:y.engineCaps,teams:y.teams}))),r=D(y=>e?null:kc(y,xc())),l=D(y=>r?y.projectSettingsByPath[r]??null:null),p=D(y=>!r||r in y.projectSettingsByPath);u.useEffect(()=>{r&&!p&&D.getState().ensureProjectSettings(r).catch(()=>null)},[r,p]);const h=n.engineId||"",f=rd(n),x=h?[hn(h)]:f.map(qt),w=h&&!c.engineCaps[h]?h:"",A=u.useMemo(()=>{const y=c.agentDefs.map(q=>({id:qt(q.slug),kind:"agent",slug:q.slug,name:q.name,description:q.description,system:q.createdBy==="system"}));for(const q of n.groupAgents??[]){if(y.some(Se=>Se.id===qt(q)))continue;const te=n.groupTempAgents?.find(Se=>Se.slug===q);y.push({id:qt(q),kind:"agent",slug:q,name:te?.name||q,description:te?.description})}if(n.agentSlug&&!y.some(q=>q.id===qt(n.agentSlug))&&y.push({id:qt(n.agentSlug),kind:"agent",slug:n.agentSlug,name:n.agentSlug}),n.execMode==="host")for(const q of c.engines)q.available&&y.push({id:hn(q.id),kind:"engine",engineId:q.id,name:q.name});return h&&!y.some(q=>q.id===hn(h))&&y.push({id:hn(h),kind:"engine",engineId:h,name:c.engines.find(q=>q.id===h)?.name||h}),y},[c.agentDefs,c.engines,h,n.execMode,n.groupAgents,n.groupTempAgents,n.agentSlug]),E=u.useMemo(()=>new Map(A.map(y=>[y.id,y])),[A]),M=u.useMemo(()=>A.filter(y=>y.kind==="agent").map(y=>y.name),[A]),z=x.map(y=>E.get(y)).filter(y=>!!y),B=A.filter(y=>!x.includes(y.id)),_=n.groupChat?f.length:0,L=y=>{const q=!!n.groupChat&&f.length<Ut;if(!h&&!q&&od(f,y))return;const te=D.getState(),Se=!!h,ge=(n.groupTempAgents||[]).filter(Ae=>y.includes(Ae.slug)),ye=Se?{engineId:void 0,engineModelId:void 0}:{};if(y.length>=Ut){const Ae={groupChat:!0,groupAgents:y,groupTempAgents:ge.length?ge:void 0,...ye};e?te.patchSessionConfig(Ae,e):te.setNewChatCfg(Le=>({...Le,...Ae}));return}const Be=y[0]||"",Ie={groupChat:!1,groupAgents:void 0,groupTempAgents:void 0,...ye};e?te.selectSessionAgent(Be,e,Ie):(te.setNewChatCfg(Ae=>({...Ae,...Ie})),te.selectNewChatAgent(Be))},U=y=>{const q=D.getState();e?q.setSessionEngine(y,e):q.setNewChatCfg(te=>({...te,engineId:y||void 0,engineModelId:void 0,...y?{groupChat:!1,groupAgents:void 0,agentSlug:void 0}:{}}))},G=u.useRef(null),C=u.useRef(null);u.useEffect(()=>{const y=G.current;if(!y)return;G.current=null,C.current?.querySelector(`[data-pill-id="${CSS.escape(y)}"]`)?.focus()});const g=y=>{if(G.current=y.id,y.kind==="engine"){U(y.engineId===h?"":y.engineId);return}const q=f.includes(y.slug)?f.filter(te=>te!==y.slug):[...f,y.slug];L(q)},O=()=>{h?U(""):L([])},Y=y=>{y.kind==="agent"?pi("agent",y.slug):pi("engine",y.engineId)},F=y=>y.kind==="engine"?w===y.engineId?t.jsx(Kt,{size:16,className:"spin"}):t.jsx(xi,{engineId:y.engineId,size:16}):t.jsx(id,{name:y.name,url:c.agentAvatars[y.slug],siblings:M,imgClassName:"agent-pill-avatar",initialClassName:"agent-pill-initial"}),P=(y,q)=>{const te=y.kind==="agent"&&y.description?`${y.name} — ${y.description}`:y.name;return q?`${te} · ${a("agentSelect.removeHint")}`:y.kind==="agent"&&y.slug===c.defaultAgentSlug?`${te} · ${a("agentSelect.defaultTag")}`:te},$=(y,q)=>{const te=q!==null,Se=y.kind==="engine"&&w===y.engineId;return t.jsxs("button",{type:"button","aria-pressed":te,"data-pill-id":y.id,className:`engine-pill agent-pill${te?" selected":""}`,"data-agent-slug":y.kind==="agent"?y.slug:void 0,"data-engine-id":y.kind==="engine"?y.engineId:void 0,title:P(y,te),disabled:!!w&&!Se,onClick:()=>{(!w||Se)&&g(y)},onContextMenu:ge=>{ge.preventDefault(),i({...Jc(ge),items:[{label:a("agentSelect.direct"),icon:t.jsx(eo,{size:13}),run:()=>Y(y)}]})},children:[te&&z.length>=Ut&&t.jsx("span",{className:"agent-pill-index",children:q+1}),t.jsx("span",{className:"engine-pill-icon",children:F(y)}),t.jsx("span",{className:"engine-pill-label",children:y.name}),y.kind==="agent"&&y.system&&t.jsx("span",{className:"agent-badge-system",children:a("agent.badge.system")})]},y.id)};if(n.preset==="chat"||!A.length)return null;const W=td(n,e?{}:wc(l,Array.isArray(c.teams)?c.teams:[]).config,c.defaultAgentSlug),K=W.kind==="agent"&&W.slug?c.agentDefs.find(y=>y.slug===W.slug)?.name:void 0,Q=_>=Ut?a("agentSelect.team",{n:_}):z.length===1?a("agentSelect.hintOne",{name:z[0].name}):W.kind==="team"?a("agentSelect.team",{n:W.count}):K?a("agentSelect.hintDefault",{name:K}):a("agentSelect.hintDefaultAnon"),Z=_<Ut&&z.length!==1&&W.kind!=="team",R=x[0]||"",ae=z[0]?F(z[0]):t.jsx(xi,{engineId:"",size:16});return t.jsxs("div",{ref:C,className:"engine-picker agent-picker agent-select-strip",role:"group","aria-label":a("agentSelect.title"),children:[t.jsx(Qu,{label:a("chatPicker.agent"),value:R,icon:ae,options:[{value:"",name:a("agentSelect.default")},...A.map(y=>({value:y.id,name:y.name,description:x.includes(y.id)?a("agentSelect.picked"):y.kind==="agent"?y.description:void 0,disabled:!!w&&y.id!==hn(w)}))],onChange:y=>{if(!y){O();return}const q=E.get(y);q&&g(q)},busy:!!w}),t.jsx(ed,{label:a("agentSelect.title"),role:"group",children:[...z.map((y,q)=>$(y,q)),...z.length>0?[t.jsx("span",{className:"agent-select-sep","aria-hidden":"true"},"sep")]:[],...B.map(y=>$(y,null))]}),t.jsx("div",{className:`engine-picker-hint${_>=Ut?" agent-select-team":""}${Z?" is-default":""}`,children:Q}),o&&t.jsx(Xc,{menu:o,onClose:()=>i(null)})]})}const cd=e=>`${e.name} ${e.path||""} ${e.project||""}`,ld=e=>[e.path,e.project].filter(n=>!!n&&n!==e.name).join(" · ")||void 0,zp=({workspaces:e,value:n,onChange:a,onAddProject:o,onAddCloudProject:i})=>{const{t:c}=Ce(),[r,l]=u.useState(!1),[p,h]=u.useState(""),[f,x]=u.useState(!1),[w,A]=u.useState(""),E=u.useRef(null),M=u.useRef(null),z=Yt(r);u.useEffect(()=>{if(!r)return;const R=y=>{E.current&&!E.current.contains(y.target)&&(l(!1),h(""),x(!1),A(""))},ae=y=>{y.key==="Escape"&&(l(!1),h(""),x(!1),A(""),E.current?.querySelector(".project-pill")?.focus())};return window.addEventListener("mousedown",R),window.addEventListener("keydown",ae),()=>{window.removeEventListener("mousedown",R),window.removeEventListener("keydown",ae)}},[r]);const B=e.filter(R=>R.kind!=="channel"),_=B.find(R=>R.key===n||!!n&&R.sessionKeys?.includes(n))||B.find(R=>R.kind==="local"&&R.system)||B[0]||null,L=B.find(R=>R.kind==="rootless")||null,U=B.filter(R=>R.kind!=="rootless"),G=p.trim().toLowerCase(),C=U.filter(R=>!G||cd(R).toLowerCase().includes(G)),g=U.length>=6,O=_?.kind==="cloud"?Vt:_?.kind==="rootless"?ki:Kn,Y=()=>{l(!1),h(""),x(!1),A("")},F=R=>{a(R),Y()},P=R=>({id:`ws:${R.key}`,label:R.name,detail:ld(R),icon:R.kind==="cloud"?t.jsx(Vt,{size:14}):t.jsx(Kn,{size:14}),checked:R.key===_?.key,run:()=>F(R)}),$=L?{id:`ws:${L.key}`,label:c("input.project.dontWork"),icon:t.jsx(ki,{size:14}),checked:L.key===_?.key,run:()=>F(L)}:null,W=i?{id:"add-cloud",label:c("input.project.addCloud"),icon:t.jsx(Vt,{size:14}),run:()=>{{x(!0);return}}}:null,K=o?{id:"add-local",label:c("input.project.add"),icon:t.jsx(po,{size:14}),run:()=>{o(),Y()}}:null,Q=()=>({title:c("input.project.label"),back:c("common.back"),...g?{search:{placeholder:c("input.project.search"),empty:c("input.project.noMatches")}}:{},sections:[{items:U.map(P)},{items:$?[$]:[]},{items:[W,K].filter(R=>!!R)}]});u.useEffect(()=>{if(!r||bc())return;const R=requestAnimationFrame(()=>{(g?M.current?.querySelector(".project-menu-search input"):M.current?.querySelector(".project-menu-item.active"))?.focus()});return()=>cancelAnimationFrame(R)},[r,g]);const Z=R=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(R.key))return;const ae=[...M.current?.querySelectorAll(".project-menu-item:not(:disabled)")||[]];if(!ae.length)return;R.preventDefault();const y=ae.indexOf(document.activeElement),q=R.key==="Home"?0:R.key==="End"?ae.length-1:y<0?R.key==="ArrowDown"?0:ae.length-1:R.key==="ArrowDown"?(y+1)%ae.length:(y-1+ae.length)%ae.length;ae[q]?.focus()};return t.jsxs("div",{className:`project-selector${r?" is-open":""}`,ref:E,children:[t.jsxs("button",{className:`composer-chip project-pill${r?" is-open":""}`,onClick:()=>{if(r){Y();return}ia(Q,{})||l(!0)},title:c("input.project.label"),"aria-haspopup":"menu","aria-expanded":r,children:[t.jsx(O,{size:13}),t.jsx("span",{className:"project-pill-name",children:_?.name||c("input.project.none")}),t.jsx(xn,{size:12})]}),r&&t.jsxs("div",{ref:R=>{M.current=R,z.ref.current=R},className:"composer-menu project-menu",style:z.style,role:"menu","aria-label":c("input.project.label"),onKeyDown:Z,children:[g&&t.jsxs("label",{className:"project-menu-search",children:[t.jsx(Ji,{size:13}),t.jsx("input",{value:p,onChange:R=>h(R.target.value),placeholder:c("input.project.search")})]}),t.jsxs("div",{className:"project-menu-list",children:[C.map(P).map(R=>t.jsxs("button",{className:`menu-item project-menu-item${R.checked?" active":""}`,role:"menuitemradio","aria-checked":!!R.checked,onClick:R.run,children:[R.icon,t.jsx("span",{className:"grow project-menu-name",children:R.label}),t.jsx("span",{className:"project-menu-check",children:R.checked?t.jsx(rt,{size:13}):null})]},R.id)),!C.length&&t.jsx("div",{className:"project-menu-empty",children:c("input.project.noMatches")})]}),$&&t.jsx("div",{className:"project-menu-section project-menu-projectless-section",role:"group",children:t.jsxs("button",{className:`menu-item project-menu-item project-menu-projectless${$.checked?" active":""}`,role:"menuitemradio","aria-checked":$.checked,onClick:$.run,children:[$.icon,t.jsx("span",{className:"grow project-menu-name",children:$.label}),t.jsx("span",{className:"project-menu-check",children:$.checked?t.jsx(rt,{size:13}):null})]})}),(W||K)&&t.jsxs("div",{className:"project-menu-section project-menu-actions",role:"group",children:[i&&W&&(f?t.jsxs("label",{className:"project-menu-search project-menu-naming",children:[t.jsx(Vt,{size:13}),t.jsx("input",{autoFocus:!0,value:w,onChange:R=>A(R.target.value),placeholder:c("input.project.cloudName"),onKeyDown:R=>{R.key==="Enter"&&w.trim()&&(i(w.trim()),Y()),R.key==="Escape"&&(R.stopPropagation(),A(""),x(!1))}})]}):t.jsxs("button",{className:"menu-item project-menu-item project-menu-add",role:"menuitem",onClick:W.run,children:[W.icon,t.jsx("span",{className:"grow",children:W.label})]})),K&&t.jsxs("button",{className:"menu-item project-menu-item project-menu-add",role:"menuitem",onClick:K.run,children:[K.icon,t.jsx("span",{className:"grow",children:K.label})]})]})]})]})},Ys=jc,_i=/^[0-9a-zA-Z-]{8,64}$/;function No(e){return e.kind==="unit"?`unit:${e.unitId.toLowerCase()}`:""}function ud(e){if(typeof e=="string"){const a=/^unit:(.+)$/.exec(e);return a&&_i.test(a[1])?Object.freeze({kind:"unit",unitId:a[1].toLowerCase()}):Ys}const n=e;return n&&typeof n=="object"&&n.kind==="unit"&&typeof n.unitId=="string"&&_i.test(n.unitId)?Object.freeze({kind:"unit",unitId:n.unitId.toLowerCase()}):Ys}const dd=5*6e4,Oi=new Set(["remoteOff","awaitingConfirm","denied","callerBlocked"]);function Xs(e){if(e==null)return null;const n=typeof e=="object"?e:{},a=typeof n.code=="string"?n.code:"",o=typeof n.status=="number"?n.status:NaN;switch(a){case"ENGINE_NOT_READY":return"starting";case"UNIT_OFFLINE":case"UNIT_DISCONNECTED":return"offline";case"UNIT_TIMEOUT":return"unreachable";case"REMOTE_SESSIONS_OFF":return"remoteOff";case"REMOTE_CALLER_UNCONFIRMED":return fl(n.reason)?"callerBlocked":n.state==="denied"?"denied":"awaitingConfirm";case"CALLER_UNAVAILABLE":case"CALLER_UNSUPPORTED":case"UNIT_CALLER_INVALID":case"UNIT_CALLER_EXPIRED":return"unreachable"}return a?o>=500?"unreachable":null:n.name==="TypeError"||n.name==="AbortError"||o===0||o>=500?"unreachable":null}const Fi=e=>e.state||e.reason?{...e.state?{state:e.state}:{},...e.reason?{reason:e.reason}:{}}:void 0;function pd(e,n,a,o=Date.now()){if(!e.online)return{status:"offline"};if(e.capsLive&&e.caps){const i=e.caps.engine;if(i==="external")return{status:"noEngine"};if(i==="stopped")return{status:"engineStopped"};if(i==="starting")return{status:"starting"}}if(n&&!n.ok){const i=Xs(n)??"unreachable",c=Oi.has(i)?Fi(n):void 0;return c?{status:i,refusal:c}:{status:i}}if(a&&o-a.at>=0&&o-a.at<dd){const i=Xs({status:403,code:a.code,state:a.state,reason:a.reason});if(i&&Oi.has(i)){const c=Fi(a);return c?{status:i,refusal:c}:{status:i}}}return n?.ok?{status:"ready"}:{status:"checking"}}function hd(e){return!!(e.online&&e.capsLive&&e.caps?.engine==="ready")}const md=1e4,fd=8e3,gd=50,vd={sessions:[],fetchedAt:null,loading:!1};async function yd(){if(typeof window.tangu?.unitSelf=="function")try{const e=await window.tangu.unitSelf();return{id:e?.unitId?e.unitId.toLowerCase():null,registered:!!e?.registered}}catch{}try{const e=await window.tangu?.unitHostStatus?.();if(e?.unitId)return{id:e.unitId.toLowerCase(),registered:null}}catch{}return{id:null,registered:null}}function kd(e,n){return e.filter(a=>!!a&&typeof a.id=="string"&&sa(a.id)&&(a.kind??"desktop")==="desktop"&&a.id.toLowerCase()!==n)}function xd(e){const n=e?.sessions;if(!Array.isArray(n))return[];const a=[];for(const o of n){if(!o||typeof o!="object")continue;const i=o;if(typeof i.id!="string"||!i.id||i.id.length>200||i.archived)continue;const{location:c,...r}=i;a.push({...r,title:typeof r.title=="string"?r.title:""})}return a}function ct(e){return{kind:"unit",unitId:e.toLowerCase()}}const le=Jn((e,n)=>({gen:0,units:null,byUnit:{},refreshedAt:0,selfRegistered:null,refreshRoster:async()=>{if(!Nc()||!window.tangu?.unitsList)return null;const a=n().gen;let o=null;try{const r=await window.tangu.unitsList();r?.status===200&&Array.isArray(r.json?.units)&&(o=r.json.units)}catch{}if(a!==n().gen)return null;if(!o)return n().units;const i=await yd(),c=kd(o,i.id);if(a!==n().gen)return null;for(const r of c)Cc(ct(r.id),r.name);return e({units:c,selfRegistered:i.registered}),c},refresh:async(a={})=>{if(!Tt())return;const o=n().gen,i=await n().refreshRoster();if(!i||o!==n().gen||(await Promise.all(i.map(l=>wd(l,o,!!a.force,!!a.periodic))),o!==n().gen))return;const c=new Set(i.map(l=>l.id.toLowerCase())),r=Object.fromEntries(Object.entries(n().byUnit).filter(([l])=>c.has(l)));e({byUnit:r,refreshedAt:Date.now()}),jd()},reset:()=>{e(a=>({gen:a.gen+1,units:null,byUnit:{},refreshedAt:0,selfRegistered:null})),Sc()}}));function et(e,n){const a=e.toLowerCase();le.setState(o=>({byUnit:{...o.byUnit,[a]:{...o.byUnit[a]??vd,...n}}}))}async function wd(e,n,a,o=!1){const i=e.id.toLowerCase(),c=le.getState().byUnit[i];if(o&&bd(Xt.getState().probes[i]))return;if(!e.online){et(i,{sessions:[],loading:!1});return}if(le.getState().selfRegistered===!1){et(i,{sessions:[],loading:!1});return}if(e.capsLive&&e.caps?.engine&&e.caps.engine!=="ready"){et(i,{sessions:[],loading:!1});return}if(!a&&c?.fetchedAt&&Date.now()-c.fetchedAt<md)return;const r=wn(ct(i));if(r){et(i,{loading:!0});try{const l=await zc(r,`/agent/sessions?archived=false&limit=${gd}&app_id=${encodeURIComponent(Mc)}`,{},{timeoutMs:fd});let p=null;try{p=await l.json()}catch{}if(n!==le.getState().gen)return;if(!l.ok){const x=p??{},w=hi({status:l.status,code:x.code,state:x.state,reason:x.reason});ks(i,w),et(i,{sessions:Wi(i,w),fetchedAt:Date.now(),loading:!1});return}const h=ct(i),f=xd(p).filter(x=>bn(x.id,h)?(console.warn(`[device-sessions] dropped session ${x.id} listed by ${i}: that id already belongs to another location`),!1):!0);ks(i,{ok:!0}),et(i,{sessions:f,fetchedAt:Date.now(),loading:!1})}catch(l){if(n!==le.getState().gen)return;const p=hi(l);ks(i,p),et(i,{sessions:Wi(i,p),fetchedAt:Date.now(),loading:!1})}}}function bd(e){if(!e||e.ok)return!1;const n=Ac(e.status,{code:e.code});return n==="caller-unavailable"||n==="gone"||n==="account-auth?"}function Wi(e,n){return Xs(n)==="unreachable"?le.getState().byUnit[e]?.sessions??[]:[]}function jd(){const e=le.getState().byUnit,n=new Map;for(const[c,r]of Object.entries(e))for(const l of r.sessions)vn(to(l.id),ct(c))&&n.set(l.id,l);if(!n.size)return;const a=D.getState();let o=!1;const i=a.sessions.map(c=>{const r=c.location?.kind==="unit"?n.get(c.id):void 0;return!r||r.title===c.title&&r.updated_at===c.updated_at&&r.summary===c.summary?c:(o=!0,{...c,title:r.title,updated_at:r.updated_at,summary:r.summary})});o&&D.setState({sessions:i})}function ra(e,n=Date.now()){const a=Xt.getState(),o=e.id.toLowerCase(),i=pd(e,a.probes[o]??null,a.sticky[o]??null,n);return i.status==="checking"&&le.getState().selfRegistered===!1&&hd(e)?{status:"ready"}:i}function Co(e){const n=e.toLowerCase();return le.getState().units?.find(a=>a.id.toLowerCase()===n)??null}function Js(e,n){if(!e?.id||!sa(n.unitId))return!1;const a=ct(n.unitId);if(Tc(e.id,a)==="conflict")return console.warn(`[device-sessions] refused to open ${e.id} on ${a.unitId}: that id already belongs to another location`),!1;const{location:o,...i}=e,c=Rc(i);return D.setState(r=>({sessions:[c,...r.sessions.filter(l=>l.id!==e.id)],configBySession:r.configBySession[e.id]||!e.agent_config?r.configBySession:{...r.configBySession,[e.id]:e.agent_config}})),(Hn.getState().activeSpaceId==="home"||Hn.getState().activeSpaceId==="inbox")&&no("tangu"),so(e.id),!0}async function Mp(e,n){if(!Tt()||!sa(e)||!n)return!1;const a=ct(e);if(bn(n,a))return!1;const o=D.getState();if((o.sessions.find(l=>l.id===n)??o.archivedSessions.find(l=>l.id===n))&&vn(to(n),a))return(Hn.getState().activeSpaceId==="home"||Hn.getState().activeSpaceId==="inbox")&&no("tangu"),so(n),!0;const c=le.getState().byUnit[a.unitId]?.sessions.find(l=>l.id===n);if(c)return Js(c,a);const r=wn(a);if(!r)return!1;try{const l=await Ec(r,n);return!l||l.id!==n?!1:Js(l,a)}catch{return!1}}async function Sd(e,n,a){const o=ct(e),i=wn(o);if(!i||bn(n,o))return;const c=l=>l.id===n?{...l,title:a}:l,r=le.getState().byUnit[o.unitId];r&&et(o.unitId,{sessions:r.sessions.map(c)}),D.setState(l=>({sessions:l.sessions.map(p=>p.location?.kind==="unit"?c(p):p)}));try{await aa(i,n,{title:a})}catch(l){D.getState().toast(D.getState().tr("app.renameFail",{e:l?.message||l}),!0)}}async function Nd(e,n,a){const o=ct(e),i=wn(o);if(!i||bn(n,o))return!1;const c=Ic(a);if(a!==null&&!c)return D.getState().toast(D.getState().tr("session.icon.invalid"),!0),!1;try{const r=await aa(i,n,{emoji:c}),l=h=>h.id===n?{...h,emoji:r.emoji}:h,p=le.getState().byUnit[o.unitId];return p&&et(o.unitId,{sessions:p.sessions.map(l)}),D.setState(h=>({sessions:h.sessions.map(f=>f.location&&vn(f.location,o)?l(f):f),archivedSessions:h.archivedSessions.map(f=>f.location&&vn(f.location,o)?l(f):f)})),!0}catch(r){return D.getState().toast(D.getState().tr("session.icon.saveFail",{e:r?.message||r}),!0),!1}}async function Cd(e,n){const a=ct(e),o=wn(a);if(!o||bn(n,a))return;try{await aa(o,n,{archived:!0})}catch(c){D.getState().toast(c?.message||String(c),!0);return}const i=le.getState().byUnit[a.unitId];i&&et(a.unitId,{sessions:i.sessions.filter(c=>c.id!==n)}),D.setState(c=>({sessions:c.sessions.filter(r=>!(r.id===n&&r.location?.kind==="unit"))})),D.getState().activeId===n&&D.getState().setActiveId(null)}let Bi=D.getState().cfg?.token??"";D.subscribe(e=>{const n=e.cfg?.token??"";n!==Bi&&(Bi=n,le.getState().reset())});const Xe=Jn(()=>({draftSeq:0,explicitSeq:null,reconciledSeq:null,explicitPending:!1,chooser:null}));function Ap(e){return Xe.setState({chooser:e}),()=>{Xe.getState().chooser===e&&Xe.setState({chooser:null})}}const zd="forsion_run_location:";function zo(){const e=jr(Pc(),D.getState().cfg?.token||"");return e?`${zd}${e}`:null}function Md(){const e=zo();if(!e)return null;try{const n=localStorage.getItem(e);return n===null?null:ud(n)}catch{return null}}function Mo(e){const n=zo();if(n)try{localStorage.setItem(n,No(e))}catch{}}async function Ep(e,n){Mo(e),Xe.setState({explicitPending:!0});try{await ao(e,{name:n.name??null})}finally{Xe.setState(a=>({explicitSeq:a.draftSeq,explicitPending:!1}))}}let Ui=!1,Gs=!1;function Ao(){if(!Tt())return!1;const e=Xe.getState();if(D.getState().activeId||e.explicitPending||e.explicitSeq===e.draftSeq||e.reconciledSeq===e.draftSeq)return!1;const n=Lc();let a=Md();Ui||(Ui=!0,a===null&&n.kind==="unit"&&(a=n,Mo(n)));let o=Ys,i=null;if(a?.kind==="unit"){if(le.getState().units===null)return!1;const c=Co(a.unitId);if(c){const r=ra(c).status;if(r==="checking")return!1;r==="ready"&&(o=a,i=c.name)}}if(Xe.setState({reconciledSeq:e.draftSeq}),!vn(o,n)){Gs=!0;let c;try{c=ao(o,{name:i})}finally{Gs=!1}c.catch(()=>{})}return!0}$c(()=>{if(Gs)return;const e=Xe.getState();Xe.setState({explicitSeq:D.getState().activeId?e.draftSeq+1:e.draftSeq})});const Ad=1e4;let Is=D.getState().activeId;D.subscribe(e=>{if(e.activeId===Is)return;const n=Is;if(Is=e.activeId,n&&!e.activeId){Xe.setState(o=>({draftSeq:o.draftSeq+1}));const a=le.getState();Date.now()-a.refreshedAt<Ad?Ao():a.refresh().catch(()=>{})}});le.subscribe((e,n)=>{e.refreshedAt!==n.refreshedAt&&Ao()});xe({"session.icon.set":{zh:"设置图标",en:"Set icon"},"session.icon.invalid":{zh:"请选择一个 Emoji 作为会话图标",en:"Choose one emoji for the session icon"},"session.icon.saveFail":{zh:"图标未能保存:{e}",en:"Could not save the icon: {e}"}});function ca({emoji:e,fallback:n,size:a=17}){return e?t.jsx("span",{"data-session-emoji":e,"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:a,height:a,flexShrink:0,fontSize:a,lineHeight:1},children:e}):t.jsx(t.Fragment,{children:n??t.jsx(eo,{size:a})})}function Tp({params:e,size:n}){const a=D(o=>{const i=e.followActive!==!1?o.activeId:e.sessionId;return o.sessions.find(c=>c.id===i)?.emoji??o.archivedSessions.find(c=>c.id===i)?.emoji});return t.jsx(ca,{emoji:a,size:n})}function Eo({sessionId:e,current:n,x:a,y:o,onClose:i,onSave:c}){const r=u.useRef(!1),l=async p=>{if(!r.current){r.current=!0;try{await(c?c(p):D.getState().setSessionEmoji(e,p))&&i()}finally{r.current=!1}}};return ta.createPortal(t.jsx(gl,{x:a,y:o,current:n,onPick:p=>{l(p)},onClose:i}),document.body)}function Zs({items:e}){return t.jsx(t.Fragment,{children:e.map(n=>t.jsxs("button",{type:"button",className:n.danger?"danger":void 0,"data-act":n.act,disabled:n.disabled,onClick:n.run,children:[n.icon," ",n.label]},n.id))})}const To=({open:e,children:n})=>{const a=rl();return t.jsx(cl,{initial:!1,children:e&&t.jsx(ll.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:a?0:.24,ease:[.2,.8,.3,1]},style:{overflow:"hidden"},children:n})})};function Ed({path:e,fallback:n,className:a}){const o=D(l=>l.projectSettingsByPath[e]?.icon),i=D(l=>l.projectIconUrls[e]),c=D(l=>l.connState==="ok"),r=Sr(o);return u.useEffect(()=>{c&&D.getState().ensureProjectSettings(e)},[e,c]),u.useEffect(()=>{c&&r&&D.getState().loadProjectIcon(e)},[e,c,r]),r?i?t.jsx("img",{className:a,src:i,alt:"",draggable:!1}):t.jsx(t.Fragment,{children:n}):o?t.jsx("span",{className:a,"aria-hidden":"true",children:o}):t.jsx(t.Fragment,{children:n})}xe({"agentRemove.title":{zh:"删除 Agent「{name}」?",en:'Delete agent "{name}"?'},"agentRemove.msg":{zh:"会从 Agent 名册和侧栏移除,历史私聊保留(只读)。它的记忆与 Library 默认保留在 Tangu 数据目录的 agents/.removed/ 里。",en:"It is removed from the agent roster and the sidebar; past direct chats are kept (read-only). By default its memory and Library are kept in agents/.removed/ in the Tangu data folder."},"agentRemove.msgCloud":{zh:"会从 Agent 名册移除,历史会话保留(只读)。",en:"It is removed from the agent roster; past sessions are kept (read-only)."},"agentRemove.files":{zh:"同时删除相关文件:它的记忆、Library 等,移到废纸篓",en:"Also delete related files: its memory, Library and the rest, moved to the Trash"},"agentRemove.confirm":{zh:"删除",en:"Delete"},"agentRemove.done":{zh:"已删除 Agent「{name}」",en:'Agent "{name}" deleted'}});function Ro({title:e,message:n,confirmLabel:a,filesLabel:o,onConfirm:i,onClose:c}){const[r,l]=u.useState(!1);return ta.createPortal(t.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},"data-remove-dialog":!0,children:t.jsx(Xi,{title:e,message:n,confirmLabel:a,onConfirm:()=>i(!!o&&r),onClose:c,children:o&&t.jsxs("label",{className:"dialog-check",children:[t.jsx("input",{type:"checkbox",checked:r,onChange:p=>l(p.target.checked)}),t.jsx("span",{children:o})]})})}),document.body)}function Rp({agent:e,onDone:n,onClose:a}){const{t:o}=Ce(),i=!!e.libraryDir,c=e.name||e.slug;return t.jsx(Ro,{title:o("agentRemove.title",{name:c}),message:o(i?"agentRemove.msg":"agentRemove.msgCloud"),confirmLabel:o("agentRemove.confirm"),filesLabel:i&&window.tangu?.trashHostPath?o("agentRemove.files"):void 0,onConfirm:r=>{const l=D.getState();l.removeAgent(e,r).then(()=>{l.toast(o("agentRemove.done",{name:c})),n?.()}).catch(p=>l.toast(String(p?.message||p),!0))},onClose:a})}const Io="forsion_orbits_pinned_entries_v1",kn=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function qi(e,n){return kn(e,n)}function $o(e,n){let a=0;for(const o of Object.values(e))Number.isFinite(o)&&(a=Math.max(a,o));return Math.max(n,a+1)}function Ip(e,n,a=Date.now()){if(kn(e,n)){const o={...e};return delete o[n],o}return{...e,[n]:$o(e,a)}}function $p(e,n,a=Date.now()){return kn(e,n)?{...e,[n]:$o(e,a)}:e}function Lp(e=typeof localStorage>"u"?null:localStorage){if(!e)return{};try{const n=JSON.parse(e.getItem(Io)||"{}");if(!n||typeof n!="object"||Array.isArray(n))return{};const a={};for(const[o,i]of Object.entries(n))o&&Number.isFinite(i)&&Number(i)>0&&(a[o]=Number(i));return a}catch{return{}}}function Pp(e,n=typeof localStorage>"u"?null:localStorage){try{n?.setItem(Io,JSON.stringify(e))}catch{}}function Td(e,n){return e.map((a,o)=>({entry:a,index:o})).sort((a,o)=>{const i=kn(n,a.entry.key),c=kn(n,o.entry.key);return i!==c?i?-1:1:i&&c?n[o.entry.key]-n[a.entry.key]||a.index-o.index:o.entry.at-a.entry.at||a.index-o.index}).map(({entry:a})=>a)}xe({"sidebar.attention":{zh:"{n} 项等你处理",en:"{n} waiting for you"},"sidebar.attentionLocalOnly":{zh:"{n} 项等你处理 · 含只能在那台电脑上批准的操作",en:"{n} waiting for you · includes actions that can only be approved on that computer"}});const Lo=({n:e,localOnly:n})=>{const{t:a}=Ce();return t.jsx("span",{className:"t2s-dot attention","data-attention":e,title:a(n?"sidebar.attentionLocalOnly":"sidebar.attention",{n:e})})};xe({"chat.toNote.action":{zh:"整理成笔记",en:"Turn into note"},"chat.toNote.working":{zh:"正在把对话整理成笔记…",en:"Turning the chat into a note…"},"chat.toNote.empty":{zh:"这段对话还没有可整理的内容",en:"This chat has nothing to turn into a note yet"},"chat.toNote.done":{zh:"已整理成笔记「{name}」",en:"Saved as the note “{name}”"},"chat.toNote.failed":{zh:"没能整理成笔记:{reason}",en:"Couldn’t turn the chat into a note: {reason}"},"chat.toNote.workingTail":{zh:"对话较长,只整理最近的部分…",en:"This chat is long; only the most recent part will be turned into a note…"},"chat.toNote.emptyAnswer":{zh:"模型没有返回内容",en:"the model returned nothing"},"chat.toNote.nameTaken":{zh:"同名笔记太多(已试到 -20)",en:"too many notes with that name (tried up to -20)"}});const Rd=["The text in <selection> is a chat transcript between a user and an AI assistant.","Turn it into a standalone, well-organized note that someone can reread later without the chat.",'Start with exactly one "# " heading that names the topic.',"Keep the conclusions, decisions, facts, numbers, code and step-by-step instructions; drop greetings, filler, retries and back-and-forth.","Use headings, lists and tables where they help. Do not mention that it came from a chat.","Write in the language the user wrote in."].join(" "),Qs=2e4;function Po(e){const n=[];for(const a of e){if(a.role!=="user"&&a.role!=="assistant")continue;const o=(a.role==="assistant"?Oc(a.content).text:a.content).trim();o&&n.push(`${a.role==="user"?"User":"Assistant"}:
|
|
35
|
+
${o}`)}return n.join(`
|
|
36
|
+
|
|
37
|
+
`)}function Id(e){const n=Po(e);return n.length>Qs?n.slice(-Qs):n}function $d(e,n){const a=/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/.exec(e);return{title:(a?a[1]:n).replace(/[\\/:*?"<>|#^[\]]/g," ").replace(/\s+/g," ").trim().slice(0,80)||n,body:(a?e.slice(a[0].length):e).replace(/^\s*\n/,"")}}function Ld(){return Dc()&&!!io()?.complete}async function Pd(e,n){for(let a=1;a<=20;a++){const o=`${a===1?e:`${e}-${a}`}.md`;if(await mi.readTextFile?.(o)?.catch(()=>null)!=null)continue;const i=await mi.writeTextFile(o,n,{create:!0,base:Nr("")});if(!(i&&i.ok===!1))return o}return null}async function Dd(e){const n=io()?.complete;if(!n)return!1;const a=D.getState(),o=[...a.sessions,...a.archivedSessions].find(i=>i.id===e);try{a.messagesBySession[e]?.length||await a.loadSessionHistory(e);const i=D.getState().messagesBySession[e]||[],c=Id(i);if(!c)return Rn({text:Re("chat.toNote.empty"),level:"info",inAppOnly:!0}),!1;Rn({text:Re(Po(i).length>Qs?"chat.toNote.workingTail":"chat.toNote.working"),level:"info",inAppOnly:!0});const r=await n({action:"custom",instruction:Rd,selection:c,title:o?.title||void 0});if(!r.text.trim())throw new Error(Re("chat.toNote.emptyAnswer"));const{title:l,body:p}=$d(r.text,o?.title?.trim()||Re("amadeus.default.note")),h=await Pd(l,p.trimEnd()+`
|
|
38
|
+
`);if(!h)throw new Error(Re("chat.toNote.nameTaken"));return Rn({text:Re("chat.toNote.done",{name:l}),level:"success",receipt:!0}),_c(h),!0}catch(i){return Rn({text:Re("chat.toNote.failed",{reason:i instanceof Error?i.message:String(i)}),level:"error",inAppOnly:!0}),!1}}const Hi={wechat:Wc,telegram:Fc,qq:Ht};xe({"sidebar.openInNewTab":{zh:"在新标签页打开",en:"Open in new tab"},"sidebar.archiveN":{zh:"归档 {n} 项",en:"Archive {n}"},"sidebar.unarchiveN":{zh:"取消归档 {n} 项",en:"Unarchive {n}"},"sidebar.deleteN":{zh:"删除 {n} 项",en:"Delete {n}"},"sidebar.deleteConfirmN":{zh:"删除选中的 {n} 个会话?不可撤销。",en:"Delete {n} selected chats? This cannot be undone."},"sidebar.mode.chat":{zh:"Chat",en:"Chat"},"sidebar.mode.work":{zh:"Work",en:"Work"},"sidebar.mode.tip":{zh:"Chat:轻聊天,只列聊天会话;Work:完整工具面,列出全部项目",en:"Chat: light conversations, chat sessions only. Work: full toolset, all projects"},"sidebar.pin":{zh:"置顶",en:"Pin to top"},"sidebar.unpin":{zh:"取消置顶",en:"Unpin"},"sidebar.ws.details":{zh:"查看详情",en:"View details"},"sidebar.ws.removeTitle":{zh:"移除项目「{name}」?",en:'Remove project "{name}"?'},"sidebar.ws.removeMsg":{zh:"会从侧栏移除它,并删除其中的 {count} 个会话,不可撤销。磁盘上的项目文件夹不会删除。",en:"It is removed from the sidebar and its {count} session(s) are deleted. This cannot be undone. The project folder on disk is not deleted."},"sidebar.ws.removeFiles":{zh:"同时删除相关文件:项目里的 .tangu 文件夹(Tangu 的指令、技能、计划),移到废纸篓",en:"Also delete related files: the project's .tangu folder (Tangu instructions, skills and plans), moved to the Trash"},"sidebar.ws.removeAction":{zh:"移除",en:"Remove"}});const Do="forsion_tangu_collapsed_projects",_o="forsion_tangu_workspace_order";function _d(){try{return new Set(JSON.parse(localStorage.getItem(Do)||"[]"))}catch{return new Set}}function Vi(e){try{localStorage.setItem(Do,JSON.stringify([...e]))}catch{}}function Od(){try{const e=JSON.parse(localStorage.getItem(_o)||"[]");return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}catch{return[]}}function Fd(e){try{localStorage.setItem(_o,JSON.stringify(e))}catch{}}function ea(e){const n=String(e||"").trim();if(!n)return 0;const a=Date.parse(n.includes("T")?n:n.replace(" ","T"));return Number.isFinite(a)?a:0}const Wd=({icon:e,title:n,active:a,onClick:o,onExpand:i,act:c})=>t.jsxs("button",{className:`t2s-special${a?" active":""}`,"data-act":c,onClick:o,children:[t.jsx("span",{className:"t2s-special-ic",children:e}),t.jsx("span",{className:"t2s-special-title",children:n}),i&&t.jsx("span",{className:"t2s-special-go",onClick:r=>{r.stopPropagation(),i()},children:t.jsx(Et,{size:14})})]}),Dp=e=>{const{t:n}=Ce(),a=u.useRef(null),o=e.allSessions??e.sessions,i=e.allArchived??e.archivedSessions,c=ul(a),[r,l]=u.useState(null),[p,h]=u.useState(null),[f,x]=u.useState(null),[w,A]=u.useState(""),[E,M]=u.useState(()=>{try{return Math.max(1,Number(localStorage.getItem("tangu_ws_session_limit"))||5)}catch{return 5}});u.useEffect(()=>{const m=()=>{try{M(Math.max(1,Number(localStorage.getItem("tangu_ws_session_limit"))||5))}catch{}};return window.addEventListener("tangu:wslimit",m),()=>window.removeEventListener("tangu:wslimit",m)},[]);const[z,B]=u.useState(!1),[_,L]=u.useState(_d),[U,G]=u.useState(Od),[C,g]=u.useState(null),[O,Y]=u.useState(null),F=u.useRef(null),P=u.useRef(!1),[$,W]=u.useState(null),[K,Q]=u.useState(null),[Z,R]=u.useState(null),[ae,y]=u.useState(""),q=u.useRef(null),te=Fl(m=>m.channels),Se=u.useMemo(()=>{const m=new Map;for(const T of te)m.set(T.kind,T.runtime.some(N=>N.running));return m},[te]),ge=u.useMemo(()=>{const m=new Map;for(const T of e.workspaces)m.set(T.key,[]);for(const T of e.sessions){const N=ri(T,e.workspaces);m.has(N)||m.set(N,[]),m.get(N).push(T)}return m},[e.workspaces,e.sessions]),ye=u.useMemo(()=>{const m=new Map(e.workspaces.map(X=>[X.key,X])),T=[];for(const X of U){const ce=m.get(X);ce&&(T.push(ce),m.delete(X))}const N=[...m.values()].sort((X,ce)=>(X.kind==="channel"?-1:0)-(ce.kind==="channel"?-1:0));return[...T,...N]},[e.workspaces,U]),Be=C?ye.findIndex(m=>m.key===C):-1,Ie=u.useMemo(()=>{const m=ye.map(N=>({key:`ws:${N.key}`,ws:N,at:(ge.get(N.key)||[]).reduce((X,ce)=>Math.max(X,ea(ce.updated_at)),0)}));if(e.orderBy!=="activity")return m;const T=(e.extraRows||[]).map(N=>({key:`row:${N.key}`,at:N.at,node:N.node}));return Td([...T,...m],e.pinnedEntries||{})},[ye,ge,e.orderBy,e.extraRows,e.pinnedEntries]),Ae=e.orderBy!=="activity",Le=m=>{const T=C;if(g(null),Y(null),!T||T===m)return;const N=ye.map(ne=>ne.key),X=N.indexOf(m);if(X<0||!N.includes(T))return;const ce=Vc(N,T,X);G(ce),Fd(ce)},Ee=m=>{L(T=>{const N=new Set(T);return N.has(m)?N.delete(m):N.add(m),Vi(N),N})},Pe=m=>{L(T=>{if(!T.has(m))return T;const N=new Set(T);return N.delete(m),Vi(N),N})},De=m=>{e.onEnterWorkspace?.(m),Pe(m)};u.useEffect(()=>{if(!P.current){P.current=!0;return}e.activeWorkspaceKey!=null&&Pe(e.activeWorkspaceKey)},[e.activeWorkspaceKey]),u.useEffect(()=>{f&&F.current?.select()},[f]),u.useEffect(()=>{Z&&q.current?.select()},[Z]),u.useEffect(()=>{if(!r&&!$)return;const m=()=>{l(null),W(null)};return window.addEventListener("click",m),window.addEventListener("contextmenu",m),()=>{window.removeEventListener("click",m),window.removeEventListener("contextmenu",m)}},[r,$]);const _e=(m,T)=>{m.preventDefault(),m.stopPropagation(),W(null);const N=c.batch(T.id);N.length===1&&c.only(T.id),l({id:T.id,ids:N,x:m.clientX,y:m.clientY,archived:!!T.archived})},Ue=(m,T)=>{m.preventDefault(),m.stopPropagation(),l(null),W({ws:T,x:m.clientX,y:m.clientY})},lt=()=>{f&&w.trim()&&e.onRename(f,w.trim()),x(null)},Rt=m=>{const T=[...o,...i].find(X=>X.id===m),N=()=>{A(T?.title||""),x(m)};{N();return}},b=m=>{const T=()=>{y(m.name),R(m.key)};{T();return}},V=m=>{const T=[],N=m.ids.length===1,X=N?[...o,...i].find(ne=>ne.id===m.id):void 0;N&&T.push({id:"open-new-tab",label:n("sidebar.openInNewTab"),icon:t.jsx(Bn,{size:13}),run:()=>{e.onSelect(m.id,{newTab:!0}),l(null)}}),N&&T.push({id:"set-icon",label:n("session.icon.set"),icon:t.jsx(ho,{size:13}),run:()=>{h({id:m.id,current:X?.emoji??null,x:m.x,y:m.y}),l(null)}}),N&&T.push({id:"rename",label:n("sidebar.rename"),icon:t.jsx(Vn,{size:13}),run:()=>{l(null),Rt(m.id)}}),N&&Ld()&&T.push({id:"to-note",label:n("chat.toNote.action"),icon:t.jsx(Nl,{size:13}),run:()=>{Dd(m.id),l(null)}}),T.push({id:m.archived?"unarchive":"archive",label:m.ids.length>1?n(m.archived?"sidebar.unarchiveN":"sidebar.archiveN",{n:String(m.ids.length)}):m.archived?n("sidebar.unarchive"):n("sidebar.archive"),icon:m.archived?t.jsx(kl,{size:13}):t.jsx(_s,{size:13}),run:()=>{for(const ne of m.ids)e.onArchive(ne,!m.archived);c.clear(),l(null)}});const ce=X?.project_path?e.workspaces.find(ne=>ne.kind==="channel"&&ne.key===X.project_path):null;if(X&&ce?.channel){const ne=Hi[ce.channel];T.push({id:"channel-connect",label:n("sidebar.channel.setAsConnected"),icon:t.jsx(ne,{size:13}),run:()=>{l(null),Bc(ot(),ce.channel,m.id).then(()=>e.onToast?.(n("sidebar.wechat.setConnectedOk"))).catch($e=>e.onToast?.(n("sidebar.wechat.setConnectedFail",{e:$e?.message||$e}),!0))}})}return m.ids.every(ne=>e.archivedSessions.some($e=>$e.id===ne))&&T.push({id:"delete",danger:!0,icon:t.jsx(Ls,{size:13}),label:m.ids.length>1?n("sidebar.deleteN",{n:String(m.ids.length)}):n("sidebar.delete"),run:()=>{const ne=m.ids;if(l(null),!!(ne.length>1?window.confirm(n("sidebar.deleteConfirmN",{n:String(ne.length)})):window.confirm(n("sidebar.deleteConfirm",{name:yt(X?.title,n)})))){for(const dt of ne)e.onDelete(dt);c.clear()}}}),T},H=m=>{const T=[];if(e.onTogglePinned){const N=`ws:${m.ws.key}`,X=qi(e.pinnedEntries||{},N);T.push({id:X?"unpin":"pin",label:n(X?"sidebar.unpin":"sidebar.pin"),icon:X?t.jsx(Rl,{size:13}):t.jsx(ws,{size:13}),run:()=>{W(null),e.onTogglePinned?.(N)}})}return e.onShowWorkspaceDetails&&xs(m.ws)&&[...o,...i].some(N=>N.project_path===m.ws.path&&!N.projectless)&&T.push({id:"ws-details",act:"ws-details",label:n("sidebar.ws.details"),icon:t.jsx(vl,{size:13}),run:()=>{const N=m.ws;W(null),e.onShowWorkspaceDetails?.(N)}}),m.ws.system||(T.push({id:"ws-rename",label:n("sidebar.ws.rename"),icon:t.jsx(Vn,{size:13}),run:()=>{const N=m.ws;W(null),b(N)}}),T.push({id:"ws-remove",act:"ws-remove",danger:!0,label:n("sidebar.ws.remove"),icon:t.jsx(Ls,{size:13}),run:()=>{Q(m.ws),W(null)}})),T},se=m=>{if(m.ids.length!==1)return;const T=[...o,...i].find(N=>N.id===m.id);return yt(T?.title,n)},Ne=Os(r,()=>r&&{title:se(r),sections:[{items:V(r)}]},()=>l(null)),qe=Os($,()=>$&&{title:In($.ws,n),sections:[{items:H($)}]},()=>W(null)),ut=()=>{if(Z&&ae.trim()){const m=e.workspaces.find(T=>T.key===Z);m&&e.onRenameWorkspace(m,ae.trim())}R(null)},He=(m,T)=>{const N=m.kind==="channel"?Hi[m.channel||"wechat"]:m.kind==="cloud"?Vt:m.kind==="rootless"?Ht:T?Kn:Hc;return t.jsxs("span",{className:"t2s-lead",children:[xs(m)?t.jsx(Ed,{path:m.path,className:"amx-page-emoji t2s-project-icon",fallback:t.jsx(N,{className:"t2s-lead-icon"})}):t.jsx(N,{className:"t2s-lead-icon"}),t.jsx("span",{className:`t2s-chev t2s-lead-chev${T?"":" open"}`,onClick:X=>{X.stopPropagation(),Ee(m.key)},children:t.jsx(Et,{size:12})})]})},Ve=m=>t.jsx(uo,{as:"button",className:`${m.id===e.activeId?"active":""}${c.has(m.id)?" sel":""}`.trim()||void 0,selId:m.id,title:m.summary||m.title||void 0,depth:e.flat?0:1,lead:t.jsxs(t.Fragment,{children:[t.jsx(ca,{emoji:m.emoji,fallback:e.rowIcon?.(m)??t.jsx(Xn,{className:"t2s-lead-icon t2s-dim"})}),e.attentionIds?.get(m.id)?t.jsx(Lo,{n:e.attentionIds.get(m.id).n,localOnly:e.attentionIds.get(m.id).localOnly}):e.runningIds.has(m.id)?t.jsx("span",{className:"t2s-dot running",title:n("sidebar.running")}):e.unreadIds.has(m.id)?t.jsx("span",{className:"t2s-dot unread",title:n("sidebar.unread")}):null]}),trailing:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"t2s-srow-time",children:qc(m.updated_at)}),t.jsx("span",{className:"t2s-srow-menu",onClick:T=>_e(T,m),children:t.jsx(qn,{size:14})})]}),onClick:T=>{const N=c.click(m.id,T);if(N.open==="none")return;e.onSelect(m.id,N.open==="new"?{newTab:!0}:void 0);const X=e.sessionWorkspaceKeyOf?e.sessionWorkspaceKeyOf(m):ri(m,e.workspaces);X&&(e.onActivateEntry?.(`ws:${X}`),De(X))},onContextMenu:T=>_e(T,m),draggable:f!==m.id,onDragStart:T=>{const N=T.currentTarget.getBoundingClientRect();T.dataTransfer.setDragImage(T.currentTarget,T.clientX-N.left,T.clientY-N.top),T.dataTransfer.effectAllowed="copy";const X=[...o,...i],ce=c.batch(m.id).map(ne=>{const $e=X.find(dt=>dt.id===ne);return{kind:"session",id:ne,title:yt($e?.title,n)}});Uc(T.dataTransfer,ce)},children:f===m.id?t.jsx("input",{ref:F,className:"t2s-rename",value:w,onChange:T=>A(T.target.value),onBlur:lt,onKeyDown:T=>{T.key==="Enter"&<(),T.key==="Escape"&&x(null)},onClick:T=>T.stopPropagation()}):t.jsx("span",{className:"t2s-srow-title",children:yt(m.title,n)})},m.id);return t.jsxs("aside",{className:"t2s-side",ref:a,children:[t.jsxs("div",{className:"t2s-scroll",onDragOver:m=>{C&&(m.preventDefault(),m.dataTransfer.dropEffect="move")},onDrop:m=>{C&&O&&(m.preventDefault(),Le(O))},children:[e.showSpecial&&t.jsx("div",{className:"t2s-special-group",children:t.jsxs("div",{className:"t2s-special-row",children:[t.jsx(Wd,{icon:t.jsx(dl,{}),title:n("sidebar.newChat"),active:!1,onClick:e.onNewChat,act:"new-chat"}),e.mode&&e.onModeChange&&t.jsxs("div",{className:"t2s-vaultseg t2s-mode",role:"tablist","aria-label":n("sidebar.mode.tip"),title:n("sidebar.mode.tip"),children:[t.jsx("div",{className:"t2s-vaultseg-thumb","data-side":e.mode}),["chat","work"].map(m=>t.jsx("button",{type:"button",role:"tab","aria-selected":e.mode===m,"data-mode":m,className:e.mode===m?"on":void 0,onClick:()=>e.onModeChange(m),children:n(m==="chat"?"sidebar.mode.chat":"sidebar.mode.work")},m))]})]})}),Ie.map((m,T)=>{if(m.node)return t.jsx(gn.Fragment,{children:m.node},m.key);const N=m.ws,X=qi(e.pinnedEntries||{},m.key),ce=ge.get(N.key)||[];if(e.flat)return t.jsx("div",{className:"t2s-group-sessions t2s-flat",children:ce.map(Ve)},N.key);const ne=_.has(N.key),$e={onDragOver:re=>{if(!C)return;re.preventDefault(),re.dataTransfer.dropEffect="move";const nt=C===N.key?null:N.key;O!==nt&&Y(nt)},onDrop:re=>{C&&(re.preventDefault(),re.stopPropagation(),Le(N.key))}},dt=!!C&&O===N.key&&C!==N.key,It=dt&&Be>=0&&Be<T,Gn=It?ne?" drag-over below":"":dt?" drag-over":"";return t.jsxs(gn.Fragment,{children:[t.jsxs("div",{className:`t2s-group${Gn}${C===N.key?" dragging":""}`,"data-workspace-key":N.key,"data-pinned":X?"true":void 0,"data-active":e.activeWorkspaceKey===N.key?"true":void 0,style:{paddingLeft:lo(0)},...co(()=>[N.path||"",pl("tip.sessions",{count:ce.length})].filter(Boolean)),draggable:Ae&&Z!==N.key,onContextMenu:re=>Ue(re,N),onDragStart:re=>{const nt=re.currentTarget.getBoundingClientRect();re.dataTransfer.setDragImage(re.currentTarget,re.clientX-nt.left,re.clientY-nt.top),re.dataTransfer.effectAllowed="move",g(N.key)},...$e,onDragEnd:()=>{g(null),Y(null)},children:[Z===N.key?t.jsxs("div",{className:"t2s-group-toggle t2s-folder-row",style:{cursor:"default"},children:[He(N,ne),t.jsx("input",{ref:q,className:"t2s-rename",value:ae,onChange:re=>y(re.target.value),onBlur:ut,onKeyDown:re=>{re.key==="Enter"&&ut(),re.key==="Escape"&&R(null)},onClick:re=>re.stopPropagation()})]}):N.kind==="channel"?t.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>{e.onActivateEntry?.(m.key),ne?De(N.key):Ee(N.key)},children:[He(N,ne),t.jsx("span",{className:"t2s-group-label",children:In(N,n)}),X&&t.jsx(ws,{className:"t2o-pin-mark","aria-hidden":"true"}),t.jsx("span",{className:`t2s-mini-dot${Se.get(N.channel||"wechat")?" ok":""}`})]}):t.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>{e.onActivateEntry?.(m.key),ne?De(N.key):Ee(N.key)},children:[He(N,ne),t.jsx("span",{className:"t2s-group-label",children:In(N,n)}),X&&t.jsx(ws,{className:"t2o-pin-mark","aria-hidden":"true"})]}),(!N.system||e.onTogglePinned||e.onShowWorkspaceDetails&&xs(N))&&t.jsx("button",{type:"button",className:"t2s-group-add",title:n("sidebar.ws.menu"),onClick:re=>Ue(re,N),children:t.jsx(qn,{size:14})}),t.jsx("button",{type:"button",className:"t2s-group-add",title:n("sidebar.newChatIn",{name:In(N,n)}),onClick:()=>e.onNewInWorkspace(N),children:t.jsx(Bn,{size:14})})]}),t.jsx(To,{open:!ne,children:t.jsxs("div",{className:`t2s-group-sessions${It&&!ne?" drag-over-end":""}`,...$e,children:[ce.slice(0,E).map(Ve),ce.length>E&&t.jsxs("button",{className:"t2s-viewmore",onClick:()=>e.onOpenWorkspace(N.key),children:[n("sidebar.viewMore")," · ",ce.length-E]})]})})]},N.key)}),e.deviceSections]}),(window.tangu?.pickDirectory&&!e.flat||e.archivedSessions.length>0)&&t.jsxs("div",{className:"t2s-foot",children:[window.tangu?.pickDirectory&&!e.flat&&t.jsxs("button",{className:"t2s-add-ws",onClick:e.onAddWorkspace,children:[t.jsx(po,{size:14})," ",n("sidebar.addLocalWorkspace")]}),e.archivedSessions.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"t2s-srow t2s-archived-toggle",onClick:()=>B(!z),children:[t.jsx("span",{className:"t2s-chev",children:t.jsx(_s,{size:13})}),t.jsx("span",{className:"t2s-srow-title t2s-faint",children:n("sidebar.archived")}),t.jsx("span",{className:"t2s-count",children:e.archivedSessions.length})]}),z&&e.archivedSessions.map(Ve)]})]}),r&&Ne&&t.jsx(Ps,{className:"ctx-menu",x:r.x,y:r.y,onClick:m=>m.stopPropagation(),children:t.jsx(Zs,{items:V(r)})}),p&&t.jsx(Eo,{sessionId:p.id,current:p.current,x:p.x,y:p.y,onClose:()=>h(null)}),$&&qe&&t.jsx(Ps,{className:"ctx-menu",x:$.x,y:$.y,onClick:m=>m.stopPropagation(),children:t.jsx(Zs,{items:H($)})}),K&&t.jsx(Ro,{title:n("sidebar.ws.removeTitle",{name:K.name}),message:n("sidebar.ws.removeMsg",{count:[...o,...i].filter(m=>m.project_path===K.key).length}),confirmLabel:n("sidebar.ws.removeAction"),filesLabel:K.kind==="local"&&window.tangu?.trashHostPath?n("sidebar.ws.removeFiles"):void 0,onConfirm:m=>e.onRemoveWorkspace(K,{deleteFiles:m}),onClose:()=>Q(null)})]})};xe({"devstatus.checking":{zh:"正在连接…",en:"Connecting…"},"devstatus.ready":{zh:"在线",en:"Online"},"devstatus.starting":{zh:"引擎正在启动",en:"Engine is starting"},"devstatus.engineStopped":{zh:"引擎没有运行",en:"Engine isn't running"},"devstatus.noEngine":{zh:"没有 Agent 引擎",en:"No agent engine"},"devstatus.offline":{zh:"离线",en:"Offline"},"devstatus.unreachable":{zh:"暂时连不上",en:"Can't reach it"},"devstatus.remoteOff":{zh:"未开启远程会话",en:"Remote sessions off"},"devstatus.awaitingConfirm":{zh:"等待那台电脑允许",en:"Waiting for approval there"},"devstatus.denied":{zh:"拒绝了这台手机",en:"Declined this phone"},"devstatus.callerBlocked":{zh:"不允许这台手机运行",en:"Doesn't allow this phone"},"devstatus.long.checking":{zh:"正在连接这台电脑…",en:"Connecting to this computer…"},"devstatus.long.ready":{zh:"在线,可以在上面运行会话",en:"Online. Sessions can run here"},"devstatus.long.starting":{zh:"这台电脑在线,Agent 引擎正在启动",en:"This computer is online and its agent engine is starting"},"devstatus.long.engineStopped":{zh:"Forsion 已打开,但 Agent 引擎没有运行",en:"Forsion is open, but its agent engine isn't running"},"devstatus.long.noEngine":{zh:"这台设备上的 Forsion 没有 Agent 引擎",en:"Forsion on this device has no agent engine"},"devstatus.long.offline":{zh:"离线,重新上线后这里会显示它的会话",en:"Offline. Its sessions show up here when it's back"},"devstatus.long.unreachable":{zh:"暂时连不上,稍后重试",en:"Can't reach it right now. Try again shortly"},"devstatus.long.remoteOff":{zh:"这台电脑没有开启「允许远程会话」",en:"Remote sessions are turned off on this computer"},"devstatus.long.awaitingConfirm":{zh:"请在那台电脑上允许这台手机",en:"Allow this phone on that computer to continue"},"devstatus.long.denied":{zh:"那台电脑拒绝了这台手机",en:"That computer declined this phone"},"devstatus.long.callerBlocked":{zh:"那台电脑不允许这台手机运行会话,请在它的「设置 › 远程会话」中调整",en:"That computer doesn't let this phone run sessions. Change it in Settings › Remote sessions there"},"sidebar.device.label":{zh:"{name} 上的会话",en:"Sessions on {name}"},"sidebar.device.empty":{zh:"还没有会话",en:"No sessions yet"},"sidebar.device.pickFirst":{zh:"在「在哪运行」里选过这台电脑后,这里会显示它的会话",en:"Pick this computer under Run on to see its sessions here"},"sidebar.device.menu":{zh:"更多操作",en:"More actions"}});function fn(e,n){const a=typeof e=="string"?e.trim():"";return a.length>n?`${a.slice(0,n-1)}…`:a}const Oo="forsion_device_sections_collapsed";function Bd(){try{const e=JSON.parse(localStorage.getItem(Oo)||"[]");return new Set(Array.isArray(e)?e.filter(n=>typeof n=="string").slice(0,200):[])}catch{return new Set}}function Ud(e){try{localStorage.setItem(Oo,JSON.stringify([...e]))}catch{}}function qd({u:e}){return e.icon?t.jsx("span",{className:"t2d-emoji","aria-hidden":!0,children:fn(e.icon,4)}):e.platform==="win32"||e.platform==="linux"?t.jsx(oo,{className:"t2s-lead-icon"}):t.jsx(ro,{className:"t2s-lead-icon"})}function _p(e,n){const a=e?.get(n);return a?t.jsx(Lo,{n:a.n,localOnly:a.localOnly}):null}function Fo(){const e=D(n=>n.connState);u.useEffect(()=>{if(!Tt())return;const n=()=>{le.getState().refresh()},a=()=>{le.getState().refresh({periodic:!0})};n();let o=null;const i=()=>{o&&(clearInterval(o),o=null),(typeof document>"u"||document.visibilityState==="visible")&&(o=setInterval(a,3e4))},c=()=>{document.visibilityState==="visible"&&n(),i()};return i(),document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c),o&&clearInterval(o)}},[]),u.useEffect(()=>{e==="ok"&&Tt()&&le.getState().refresh()},[e])}function Op(e){const{t:n}=Ce();Fo();const a=le(C=>C.units),o=le(C=>C.byUnit);Xt(C=>C.probes),Xt(C=>C.sticky);const i=D(C=>C.sessions),c=le(C=>C.selfRegistered),[r,l]=u.useState(Bd),[p,h]=u.useState(null),[f,x]=u.useState(null),[w,A]=u.useState(null),[E,M]=u.useState(""),z=u.useRef(null);u.useEffect(()=>{w&&z.current?.select()},[w]),u.useEffect(()=>{if(!p)return;const C=()=>h(null),g=O=>{O.key==="Escape"&&h(null)};return window.addEventListener("click",C),window.addEventListener("contextmenu",C),window.addEventListener("keydown",g),()=>{window.removeEventListener("click",C),window.removeEventListener("contextmenu",C),window.removeEventListener("keydown",g)}},[p]);const B=u.useMemo(()=>{const C={};for(const g of a||[]){const O=g.id.toLowerCase();if(!g.online){C[O]=[];continue}const Y=o[O]?.sessions??[],F=new Set(Y.map(W=>W.id)),$=[...i.filter(W=>W.location?.kind==="unit"&&W.location.unitId===O&&!F.has(W.id)&&!W.archived),...Y].sort((W,K)=>ea(K.updated_at)-ea(W.updated_at));C[O]=e.filter?e.filter($):$}return C},[a,o,i,e.filter]),_=C=>{const g=B[C.unitId]?.find(O=>O.id===C.id);return[{id:"set-icon",label:n("session.icon.set"),icon:t.jsx(ho,{size:13}),run:()=>{x({...C,current:g?.emoji??null}),h(null)}},{id:"rename",label:n("sidebar.rename"),icon:t.jsx(Vn,{size:13}),run:()=>{h(null);const O=()=>{M(g?.title||""),A({unitId:C.unitId,id:C.id})};{O();return}}},{id:"archive",label:n("sidebar.archive"),icon:t.jsx(_s,{size:13}),run:()=>{h(null),Cd(C.unitId,C.id)}}]},L=Os(p,()=>p&&{title:yt(fn(B[p.unitId]?.find(C=>C.id===p.id)?.title,200),n),sections:[{items:_(p)}]},()=>h(null));if(!Tt()||!a?.length)return null;const U=C=>{l(g=>{const O=new Set(g);return O.has(C)?O.delete(C):O.add(C),Ud(O),O})},G=()=>{w&&E.trim()&&Sd(w.unitId,w.id,E.trim()),A(null)};return t.jsxs("div",{className:"t2d-sections","data-device-sections":!0,children:[a.map(C=>{const g=C.id.toLowerCase(),O=ra(C).status,Y=B[g]??[],F=r.has(g),P=fn(C.name,60)||n("engine.target.defaultName");return t.jsxs("div",{className:"t2d-section","data-device-section":g,"data-device-status":O,children:[t.jsx("div",{className:"t2s-group t2d-head",style:{paddingLeft:lo(0)},title:n(`devstatus.long.${O}`),children:t.jsxs("button",{type:"button",className:"t2s-group-toggle t2s-folder-row t2d-toggle","aria-expanded":!F,"aria-label":n("sidebar.device.label",{name:P}),onClick:()=>U(g),children:[t.jsxs("span",{className:"t2s-lead",children:[t.jsx(qd,{u:C}),t.jsx("span",{className:`t2s-chev t2s-lead-chev${F?"":" open"}`,children:t.jsx(Et,{size:12})})]}),t.jsx("span",{className:"t2s-group-label t2d-name",children:P}),t.jsx("span",{className:"t2d-status","data-tone":O==="ready"?"ok":O==="checking"?"wait":"warn",role:"status",children:n(`devstatus.${O}`)})]})}),t.jsx(To,{open:!F,children:t.jsxs("div",{className:"t2s-group-sessions",children:[Y.map($=>t.jsx(uo,{as:w?.id===$.id?"div":"button",className:$.id===e.activeId?"active":void 0,depth:1,title:$.summary||$.title||void 0,lead:t.jsxs(t.Fragment,{children:[t.jsx(ca,{emoji:$.emoji,fallback:t.jsx(Xn,{className:"t2s-lead-icon t2s-dim"})}),e.rowBadge?.($)??(e.runningIds.has($.id)?t.jsx("span",{className:"t2s-dot running"}):e.unreadIds.has($.id)?t.jsx("span",{className:"t2s-dot unread"}):null)]}),trailing:w?.id===$.id?void 0:t.jsx("span",{className:"t2s-srow-menu",role:"button","aria-label":n("sidebar.device.menu"),onClick:W=>{W.stopPropagation(),h({unitId:g,id:$.id,x:W.clientX,y:W.clientY})},children:t.jsx(qn,{size:14})}),onClick:()=>{w?.id!==$.id&&Js($,{unitId:g})},onContextMenu:W=>{W.preventDefault(),W.stopPropagation(),h({unitId:g,id:$.id,x:W.clientX,y:W.clientY})},children:w?.id===$.id?t.jsx("input",{ref:z,className:"t2s-rename",value:E,onChange:W=>M(W.target.value),onBlur:G,onKeyDown:W=>{W.key==="Enter"&&G(),W.key==="Escape"&&A(null)},onClick:W=>W.stopPropagation()}):t.jsx("span",{className:"t2s-srow-title","data-remote-session":$.id,children:yt(fn($.title,200),n)})},$.id)),O==="ready"&&!Y.length&&t.jsx("div",{className:"t2d-empty",children:n(c===!1?"sidebar.device.pickFirst":"sidebar.device.empty")})]})})]},g)}),p&&L&&t.jsx(Ps,{className:"ctx-menu",x:p.x,y:p.y,onClick:C=>C.stopPropagation(),children:t.jsx(Zs,{items:_(p)})}),f&&t.jsx(Eo,{sessionId:f.id,current:f.current,x:f.x,y:f.y,onSave:C=>Nd(f.unitId,f.id,C),onClose:()=>x(null)})]})}xe({"runloc.label":{zh:"运行位置",en:"Run on"},"runloc.cloud":{zh:"云端",en:"Cloud"},"runloc.thisDevice":{zh:"这台电脑",en:"This computer"},"runloc.pillTitle":{zh:"新会话在哪运行:{where}",en:"New sessions run on: {where}"}});function Hd(){const e=le(n=>n.units);return Tt()&&!!e?.length}function Fp(){const{t:e}=Ce();Fo();const n=Hd(),a=fi(p=>p.ref);fi(p=>p.name),le(p=>p.units),Xt(p=>p.probes),Xt(p=>p.sticky);const o=Xe(p=>p.chooser);if(!n)return null;const i=a.kind==="unit"?Co(a.unitId):null,c=i?ra(i).status:null,r=a.kind==="unit"?fn(Kc(a)||i?.name,60)||e("engine.target.defaultName"):e("runloc.cloud"),l=a.kind==="home"?Vt:i?.platform==="win32"||i?.platform==="linux"?oo:ro;return t.jsx("div",{className:"project-selector runloc","data-run-location-picker":!0,"data-run-location":No(a)||"home","data-device-status":c??void 0,children:t.jsxs("button",{type:"button",className:"composer-chip project-pill runloc-pill",title:e("runloc.pillTitle",{where:r}),"aria-label":e("runloc.pillTitle",{where:r}),"aria-haspopup":"dialog",disabled:!o,onClick:()=>o?.(),children:[t.jsx(l,{size:13}),t.jsx("span",{className:"project-pill-name",children:r}),c&&c!=="ready"&&t.jsx("span",{className:"runloc-status","data-tone":c==="checking"?"wait":"warn",children:e(`devstatus.${c}`)}),o&&t.jsx(xn,{size:12})]})})}export{Cp as $,_s as A,fp as B,Np as C,Op as D,xi as E,wp as F,au as G,Ql as H,xo as I,pp as J,xp as K,Zl as L,gp as M,Nl as N,ko as O,Ed as P,vp as Q,Jl as R,Dp as S,yp as T,mo as U,kp as V,zi as W,dp as X,up as Y,Iu as Z,Mp as _,In as a,Fp as a0,zp as a1,To as a2,mu as a3,Sp as a4,Nu as a5,$l as a6,bp as a7,fu as a8,jp as a9,Ye as aa,Hd as ab,kl as b,yt as c,pd as d,Eo as e,ca as f,ad as g,id as h,Ap as i,Rp as j,Tp as k,_p as l,ea as m,qi as n,Os as o,Zs as p,Rl as q,Lp as r,Ep as s,Pp as t,Fl as u,Ip as v,Bl as w,$p as x,hp as y,mp as z};
|