@agent-spaces/server 0.3.63 → 0.3.64
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/dist/adapters/claude-code-runtime/message-format.js +1 -1
- package/dist/adapters/git.js +161 -57
- package/dist/agents/agent-designer.js +66 -12
- package/dist/agents/issue-task-controller.js +1 -1
- package/dist/app.js +50 -1
- package/dist/package.json +1 -1
- package/dist/routes/agent-commands.js +72 -0
- package/dist/routes/agent-sse.js +6 -0
- package/dist/routes/agent.js +15 -1
- package/dist/routes/database.js +345 -0
- package/dist/routes/git.js +52 -1
- package/dist/routes/kanban.js +39 -0
- package/dist/services/agent-commands.js +168 -0
- package/dist/services/builtin-tools/command-tools.js +117 -0
- package/dist/services/builtin-tools/database-tools.js +578 -0
- package/dist/services/builtin-tools/index.js +5 -0
- package/dist/services/builtin-tools/input-helpers.js +26 -0
- package/dist/services/builtin-tools/issue-tools.js +209 -0
- package/dist/services/builtin-tools/kanban-tools.js +277 -0
- package/dist/services/database-vector.js +244 -0
- package/dist/services/kanban.js +50 -0
- package/dist/storage/database-store.js +365 -0
- package/dist/storage/kanban-store.js +142 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +24 -29
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +14 -14
- package/dist/web/__next._tree.txt +3 -8
- package/dist/web/_next/static/chunks/0-9194nbxy_6d.js +1 -0
- package/dist/web/_next/static/chunks/{13~y-b.b9rrw4.js → 01~quun6sefgl.js} +1 -1
- package/dist/web/_next/static/chunks/04a4vsq2wknm4.js +1 -0
- package/dist/web/_next/static/chunks/04dg4l4hv11q2.js +3 -0
- package/dist/web/_next/static/chunks/04fxddw-y20~-.js +7 -0
- package/dist/web/_next/static/chunks/04w7~5ooz_pwm.js +1 -0
- package/dist/web/_next/static/chunks/05oc21sj24wtq.js +1 -0
- package/dist/web/_next/static/chunks/{0-oog4zg4_m~m.css → 062f9zqctzg.b.css} +0 -3
- package/dist/web/_next/static/chunks/{014x2qbuiszni.js → 08ckpwmmwlors.js} +3 -3
- package/dist/web/_next/static/chunks/08k~meqbd8d6v.js +1 -0
- package/dist/web/_next/static/chunks/099h96wjsdb25.js +2 -0
- package/dist/web/_next/static/chunks/09h23logvq65m.js +1 -0
- package/dist/web/_next/static/chunks/0_mvduwjsm35w.js +1 -0
- package/dist/web/_next/static/chunks/0a5y-vhf4i5id.js +3 -0
- package/dist/web/_next/static/chunks/0ake2f3x2uan4.js +24 -0
- package/dist/web/_next/static/chunks/0ck8dw_9-1cdx.js +1 -0
- package/dist/web/_next/static/chunks/0f7cb9li~3jra.js +67 -0
- package/dist/web/_next/static/chunks/0fttswpzu69qx.js +1 -0
- package/dist/web/_next/static/chunks/0ghs9on7wodrm.js +1 -0
- package/dist/web/_next/static/chunks/0ghx3j_.-gdyd.js +1 -0
- package/dist/web/_next/static/chunks/0h9cu-k6z5o08.js +1 -0
- package/dist/web/_next/static/chunks/{02c22g~xd-y30.js → 0iuf30t0rjsjv.js} +2 -2
- package/dist/web/_next/static/chunks/{046me66nilkff.js → 0jb4~3qqkw2ps.js} +1 -1
- package/dist/web/_next/static/chunks/0k4zdm72k_bfy.js +1 -0
- package/dist/web/_next/static/chunks/{0kof5qdg8c2-k.js → 0n6_4so_afuwk.js} +37 -37
- package/dist/web/_next/static/chunks/0nb8.iteznuvx.js +1 -0
- package/dist/web/_next/static/chunks/0os58q93stt7j.js +3 -0
- package/dist/web/_next/static/chunks/0s9lmk8iauou3.js +1 -0
- package/dist/web/_next/static/chunks/0sp_zbx~w0am7.js +1 -0
- package/dist/web/_next/static/chunks/0tel~zsv4z8l_.js +1 -0
- package/dist/web/_next/static/chunks/0twamv4wr_dbv.js +1 -0
- package/dist/web/_next/static/chunks/{0_udc.6.tueey.js → 0uhol5wafdbl~.js} +1 -1
- package/dist/web/_next/static/chunks/0v3a_x4vt42kx.js +5 -0
- package/dist/web/_next/static/chunks/{002-dxhags4dj.js → 0v6hte2z-32ca.js} +2 -2
- package/dist/web/_next/static/chunks/0v7q4mys.mnm..css +1 -0
- package/dist/web/_next/static/chunks/{0ogpc3f3keopc.js → 0vbqaynjq8ga..js} +2 -2
- package/dist/web/_next/static/chunks/0xbaakj0dfc0..js +1 -0
- package/dist/web/_next/static/chunks/0z~vqzbm_q371.js +1 -0
- package/dist/web/_next/static/chunks/0~3xm80~j9ddg.js +1 -0
- package/dist/web/_next/static/chunks/{0y09i51u6ixq5.js → 10l-9myrdo3x9.js} +1 -1
- package/dist/web/_next/static/chunks/12jm4gwmvq-0q.js +90 -0
- package/dist/web/_next/static/chunks/{0aa6bcdmtpekn.js → 1442stwa0gbxe.js} +1 -1
- package/dist/web/_next/static/chunks/14s37n6h0_q3x.js +16 -0
- package/dist/web/_next/static/chunks/161ik5kfyuwtd.js +1 -0
- package/dist/web/_next/static/chunks/17k~zbv0_4rep.js +1 -0
- package/dist/web/_not-found/__next._full.txt +23 -23
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +14 -14
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +3 -3
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +23 -23
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +24 -29
- package/dist/web/login/__next._full.txt +32 -36
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +14 -14
- package/dist/web/login/__next._tree.txt +3 -8
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +32 -36
- package/dist/web/settings/__next._full.txt +26 -31
- package/dist/web/settings/__next._head.txt +4 -4
- package/dist/web/settings/__next._index.txt +14 -14
- package/dist/web/settings/__next._tree.txt +3 -8
- package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
- package/dist/web/settings/__next.settings.txt +5 -5
- package/dist/web/settings/agents/__next._full.txt +26 -31
- package/dist/web/settings/agents/__next._head.txt +4 -4
- package/dist/web/settings/agents/__next._index.txt +14 -14
- package/dist/web/settings/agents/__next._tree.txt +3 -8
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
- package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
- package/dist/web/settings/agents/__next.settings.txt +5 -5
- package/dist/web/settings/agents.html +1 -1
- package/dist/web/settings/agents.txt +26 -31
- package/dist/web/settings/mcps/__next._full.txt +26 -31
- package/dist/web/settings/mcps/__next._head.txt +4 -4
- package/dist/web/settings/mcps/__next._index.txt +14 -14
- package/dist/web/settings/mcps/__next._tree.txt +3 -8
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
- package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
- package/dist/web/settings/mcps/__next.settings.txt +5 -5
- package/dist/web/settings/mcps.html +1 -1
- package/dist/web/settings/mcps.txt +26 -31
- package/dist/web/settings/models/__next._full.txt +26 -31
- package/dist/web/settings/models/__next._head.txt +4 -4
- package/dist/web/settings/models/__next._index.txt +14 -14
- package/dist/web/settings/models/__next._tree.txt +3 -8
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
- package/dist/web/settings/models/__next.settings.models.txt +3 -3
- package/dist/web/settings/models/__next.settings.txt +5 -5
- package/dist/web/settings/models.html +1 -1
- package/dist/web/settings/models.txt +26 -31
- package/dist/web/settings/output-styles/__next._full.txt +26 -31
- package/dist/web/settings/output-styles/__next._head.txt +4 -4
- package/dist/web/settings/output-styles/__next._index.txt +14 -14
- package/dist/web/settings/output-styles/__next._tree.txt +3 -8
- package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
- package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
- package/dist/web/settings/output-styles/__next.settings.txt +5 -5
- package/dist/web/settings/output-styles.html +1 -1
- package/dist/web/settings/output-styles.txt +26 -31
- package/dist/web/settings/prompts/__next._full.txt +26 -31
- package/dist/web/settings/prompts/__next._head.txt +4 -4
- package/dist/web/settings/prompts/__next._index.txt +14 -14
- package/dist/web/settings/prompts/__next._tree.txt +3 -8
- package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
- package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
- package/dist/web/settings/prompts/__next.settings.txt +5 -5
- package/dist/web/settings/prompts.html +1 -1
- package/dist/web/settings/prompts.txt +26 -31
- package/dist/web/settings/providers/__next._full.txt +26 -31
- package/dist/web/settings/providers/__next._head.txt +4 -4
- package/dist/web/settings/providers/__next._index.txt +14 -14
- package/dist/web/settings/providers/__next._tree.txt +3 -8
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
- package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
- package/dist/web/settings/providers/__next.settings.txt +5 -5
- package/dist/web/settings/providers.html +1 -1
- package/dist/web/settings/providers.txt +26 -31
- package/dist/web/settings/skills/__next._full.txt +26 -31
- package/dist/web/settings/skills/__next._head.txt +4 -4
- package/dist/web/settings/skills/__next._index.txt +14 -14
- package/dist/web/settings/skills/__next._tree.txt +3 -8
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
- package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
- package/dist/web/settings/skills/__next.settings.txt +5 -5
- package/dist/web/settings/skills.html +1 -1
- package/dist/web/settings/skills.txt +26 -31
- package/dist/web/settings/tools/__next._full.txt +38 -0
- package/dist/web/settings/tools/__next._head.txt +6 -0
- package/dist/web/settings/tools/__next._index.txt +15 -0
- package/dist/web/settings/tools/__next._tree.txt +3 -0
- package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +9 -0
- package/dist/web/settings/tools/__next.settings.tools.txt +5 -0
- package/dist/web/settings/tools/__next.settings.txt +7 -0
- package/dist/web/settings/tools.html +1 -0
- package/dist/web/settings/tools.txt +38 -0
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +26 -31
- package/dist/web/workflows/__next._full.txt +34 -38
- package/dist/web/workflows/__next._head.txt +4 -4
- package/dist/web/workflows/__next._index.txt +14 -14
- package/dist/web/workflows/__next._tree.txt +3 -8
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
- package/dist/web/workflows/__next.workflows.txt +3 -3
- package/dist/web/workflows.html +1 -1
- package/dist/web/workflows.txt +34 -38
- package/dist/web/workspace/_/__next._full.txt +25 -29
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +14 -14
- package/dist/web/workspace/_/__next._tree.txt +4 -8
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +25 -29
- package/dist/web/workspaces/__next._full.txt +24 -29
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +14 -14
- package/dist/web/workspaces/__next._tree.txt +3 -8
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +24 -29
- package/dist/ws/agent-prompt.js +45 -8
- package/dist/ws/agent-runner.js +6 -4
- package/package.json +11 -10
- package/dist/web/_next/static/chunks/0-1bfvfwifh-m.js +0 -1
- package/dist/web/_next/static/chunks/04v-pqqs-2lvp.css +0 -1
- package/dist/web/_next/static/chunks/06w~.izyfylap.js +0 -1
- package/dist/web/_next/static/chunks/09t62a89~jesc.js +0 -3
- package/dist/web/_next/static/chunks/09y_3krccdd~u.js +0 -1
- package/dist/web/_next/static/chunks/0_e~hmntdfop9.js +0 -1
- package/dist/web/_next/static/chunks/0cke33d38fnby.js +0 -90
- package/dist/web/_next/static/chunks/0cyq~8xb~r5fc.js +0 -1
- package/dist/web/_next/static/chunks/0fxa1edqr7dve.js +0 -1
- package/dist/web/_next/static/chunks/0hra80eyuu37u.js +0 -1
- package/dist/web/_next/static/chunks/0ie7y4k2ncvnn.js +0 -1
- package/dist/web/_next/static/chunks/0igc~uli58ncw.js +0 -2
- package/dist/web/_next/static/chunks/0msb2mi3hiu5_.js +0 -67
- package/dist/web/_next/static/chunks/0p1n8bvfnpl41.js +0 -1
- package/dist/web/_next/static/chunks/0s_dva~eh2yhi.js +0 -3
- package/dist/web/_next/static/chunks/0typj55ox8d5i.js +0 -1
- package/dist/web/_next/static/chunks/0w2p4ldi2aymp.js +0 -1
- package/dist/web/_next/static/chunks/0zc0xgp5ourcn.js +0 -1
- package/dist/web/_next/static/chunks/0zmhdridea1s5.js +0 -90
- package/dist/web/_next/static/chunks/10.alq.6stmld.js +0 -1
- package/dist/web/_next/static/chunks/11b3zgk1etlkw.js +0 -7
- package/dist/web/_next/static/chunks/11qp8r5dotf7d.js +0 -1
- package/dist/web/_next/static/chunks/12mxlicp247c8.js +0 -1
- package/dist/web/_next/static/chunks/135w27dd8c19s.js +0 -5
- package/dist/web/_next/static/chunks/176dc-dtokxxi.js +0 -16
- package/dist/web/_next/static/chunks/17g-0pqre.anw.js +0 -1
- package/dist/web/_next/static/media/0a7740363b4d4863-s.1110aazvokzp..woff2 +0 -0
- package/dist/web/_next/static/media/0da9c7f357bd9d4d-s.0ek5sshv8wk3m.woff2 +0 -0
- package/dist/web/_next/static/media/1b99372b3eaef0c8-s.p.0gx2haw2tmll8.woff2 +0 -0
- package/dist/web/_next/static/media/41e95f694c5c4549-s.0r1jrq7neqdsq.woff2 +0 -0
- package/dist/web/_next/static/media/5c285b27cdda1fe8-s.p.0yo6-5yoeeudq.woff2 +0 -0
- package/dist/web/_next/static/media/5f9d24ebef5d5292-s.0esuu2f5si~v8.woff2 +0 -0
- package/dist/web/_next/static/media/6c55a692938ebbbc-s.0g6rbszwfgn9y.woff2 +0 -0
- package/dist/web/_next/static/media/8e6fa89aa22d24ec-s.p.0uvzar8hswo3p.woff2 +0 -0
- package/dist/web/_next/static/media/a218039a3287bcfd-s.p.17-1enzs_j91b.woff2 +0 -0
- package/dist/web/_next/static/media/b2ea385cb5ae8625-s.0kjod.kaq1k69.woff2 +0 -0
- package/dist/web/_next/static/media/bdc7e24a509eb931-s.0apt5mko2.qn3.woff2 +0 -0
- package/dist/web/_next/static/media/c3cb240f9c892514-s.163v2i5cux7-c.woff2 +0 -0
- package/dist/web/_next/static/media/e2334d715941921e-s.p.12skym0rqknxy.woff2 +0 -0
- /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_ssgManifest.js +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,885761,e=>{"use strict";var t,n,s,a=e.i(344180),r=e.i(764556),l=e.i(244073),i=e.i(31807),o=e.i(355819),d=e.i(157408),c=e.i(159619),u=e.i(962562),m=e.i(137340),p=e.i(344118),x=e.i(444204),h=e.i(433721);let g=(0,h.default)("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]);var f=e.i(244996),v=e.i(668667);let j=(0,h.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);var y=e.i(209988),b=e.i(555060),N=e.i(611176),k=e.i(951841),w=e.i(996652),C=e.i(426022);let S=(0,h.default)("user-minus",[["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:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function T({open:e,onOpenChange:t,memberName:n,displayName:s,channelId:l,workspaceId:d,channels:c=[]}){let[u,m]=(0,r.useState)(!1),{channels:p,updateChannel:x}=(0,i.useChannelStore)(),h=(0,o.useAgentStore)(e=>e.agents),g="user"!==n?h.find(e=>e.id===n):void 0,f=s||g?.name||n,v=(0,k.useUserAvatar)(),j="user"===n?v:null,b=p.find(e=>e.id===l),w=b?.members.includes(n),M=async()=>{if(b&&w){m(!0);try{let e=(i.useChannelStore.getState().channels.find(e=>e.id===l)??b).members.filter(e=>e!==n);i.useChannelStore.setState(t=>({channels:t.channels.map(t=>t.id===l?{...t,members:e}:t)})),await x(d,l,{members:e}),t(!1)}finally{m(!1)}}};return(0,a.jsx)(y.Dialog,{open:e,onOpenChange:t,children:(0,a.jsxs)(y.DialogContent,{className:"sm:max-w-sm",children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:"成员信息"}),(0,a.jsx)(y.DialogDescription,{})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,a.jsx)(N.AgentIcon,{agentId:"user"!==n?n:void 0,name:f,avatarUrl:j||void 0,className:"size-12 rounded-full"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:f}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"user"===n?"成员":g?.role||n})]})]}),c.length>0&&(0,a.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"所在频道"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:c.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:[(0,a.jsx)(C.MessageSquare,{className:"size-3"}),e]},e))})]}),w&&"user"!==n&&(0,a.jsxs)("button",{onClick:M,disabled:u,className:"flex items-center justify-center gap-2 w-full mt-2 px-3 py-2 rounded-md text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50 transition-colors",children:[(0,a.jsx)(S,{className:"size-4"}),u?"移除中...":"从频道移除"]})]})})}var M=e.i(465458);let I=({size:e=16})=>(0,a.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,a.jsx)("title",{children:"Loader"}),(0,a.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,a.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,a.jsx)("defs",{children:(0,a.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,a.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),z=({className:e,size:t=16,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("inline-flex animate-spin items-center justify-center",e),...n,children:(0,a.jsx)(I,{size:t})});var D=e.i(946899),D=D;e.s([],352264),e.i(352264),e.i(8890);var R=e.i(535270),P=e.i(29905),A=e.i(756432),O=e.i(189131),E=e.i(267805);let $=r.createContext(void 0);function L(){let e=r.useContext($);if(void 0===e)throw Error((0,E.default)(10));return e}var U=e.i(969490),B=e.i(602453),F=e.i(742665);let W={value:()=>null},_=r.forwardRef(function(e,t){let{render:n,className:s,disabled:l=!1,hiddenUntilFound:i,keepMounted:o,loopFocus:d=!0,onValueChange:c,multiple:u=!1,orientation:m="vertical",value:p,defaultValue:x,style:h,...g}=e,f=(0,O.useDirection)(),v=r.useMemo(()=>{if(void 0===p)return x??[]},[p,x]),j=(0,P.useStableCallback)(c),y=r.useRef([]),[b,N]=(0,R.useControlled)({controlled:p,default:v,name:"Accordion",state:"value"}),k=(0,P.useStableCallback)((e,t)=>{let n=(0,B.createChangeEventDetails)(F.REASONS.none);if(u)if(t){let t=b.slice();if(t.push(e),j(t,n),n.isCanceled)return;N(t)}else{let t=b.filter(t=>t!==e);if(j(t,n),n.isCanceled)return;N(t)}else{let t=b[0]===e?[]:[e];if(j(t,n),n.isCanceled)return;N(t)}}),w=r.useMemo(()=>({value:b,disabled:l,orientation:m}),[b,l,m]),C=r.useMemo(()=>({accordionItemRefs:y,direction:f,disabled:l,handleValueChange:k,hiddenUntilFound:i??!1,keepMounted:o??!1,loopFocus:d,orientation:m,state:w,value:b}),[f,l,k,i,o,d,m,w,b]),S=(0,U.useRenderElement)("div",e,{state:w,ref:t,props:[{dir:f,role:"region"},g],stateAttributesMapping:W});return(0,a.jsx)($.Provider,{value:C,children:(0,a.jsx)(A.CompositeList,{elementsRef:y,children:S})})});var H=e.i(204133),q=e.i(139236),V=e.i(257295),G=e.i(619279),K=e.i(296615);let J=r.createContext(void 0);function Q(){let e=r.useContext(J);if(void 0===e)throw Error((0,E.default)(9));return e}var X=e.i(439485),Y=e.i(282458);let Z=((t={}).index="data-index",t.disabled="data-disabled",t.open="data-open",t),ee={...X.collapsibleOpenStateMapping,index:e=>Number.isInteger(e)?{[Z.index]:String(e)}:null,...Y.transitionStatusMapping,value:()=>null},et=r.forwardRef(function(e,t){let{className:n,disabled:s=!1,onOpenChange:l,render:i,value:o,style:d,...c}=e,{ref:u,index:m}=(0,K.useCompositeListItem)(),p=(0,H.useMergedRefs)(t,u),{disabled:x,handleValueChange:h,state:g,value:f}=L(),v=(0,q.useBaseUiId)(),j=o??v,y=s||x,b=r.useMemo(()=>{if(!f)return!1;for(let e=0;e<f.length;e+=1)if(f[e]===j)return!0;return!1},[f,j]),N=(0,P.useStableCallback)((e,t)=>{l?.(e,t),t.isCanceled||h(j,e)}),k=(0,V.useCollapsibleRoot)({open:b,onOpenChange:N,disabled:y}),w=r.useMemo(()=>({open:k.open,disabled:k.disabled,hidden:!k.mounted,transitionStatus:k.transitionStatus}),[k.open,k.disabled,k.mounted,k.transitionStatus]),C=r.useMemo(()=>({...k,onOpenChange:N,state:w}),[k,w,N]),S=r.useMemo(()=>({...g,index:m,disabled:y,open:b}),[y,m,b,g]),[T,M]=r.useState((0,q.useBaseUiId)()),I=r.useMemo(()=>({open:b,state:S,setTriggerId:M,triggerId:T}),[b,S,M,T]),z=(0,U.useRenderElement)("div",e,{state:S,ref:p,props:c,stateAttributesMapping:ee});return(0,a.jsx)(G.CollapsibleRootContext.Provider,{value:C,children:(0,a.jsx)(J.Provider,{value:I,children:z})})}),en=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,{state:l}=Q();return(0,U.useRenderElement)("h3",e,{state:l,ref:t,props:r,stateAttributesMapping:ee})});var es=e.i(568769),ea=e.i(277642),er=e.i(931709),el=e.i(100229),ei=e.i(150129);let eo=new Set([el.ARROW_DOWN,el.ARROW_UP,el.ARROW_RIGHT,el.ARROW_LEFT,el.HOME,el.END]),ed=r.forwardRef(function(e,t){let{disabled:n,className:s,id:a,render:l,nativeButton:i=!0,style:o,...d}=e,{panelId:c,open:u,handleTrigger:m,disabled:p}=(0,G.useCollapsibleRootContext)(),{getButtonProps:x,buttonRef:h}=(0,er.useButton)({disabled:n??p,focusableWhenDisabled:!0,native:i,composite:!0}),{accordionItemRefs:g,direction:f,loopFocus:v,orientation:j}=L(),y="rtl"===f,b="horizontal"===j,{state:N,setTriggerId:k,triggerId:w}=Q();(0,ea.useIsoLayoutEffect)(()=>(a&&k(a),()=>{k(void 0)}),[a,k]);let C=r.useMemo(()=>({"aria-controls":u?c:void 0,"aria-expanded":u,id:w,tabIndex:0,onClick:m,onKeyDown(e){if(!eo.has(e.key))return;(0,ei.stopEvent)(e);let t=function(e){let{current:t}=e,n=[];for(let e=0;e<t.length;e+=1){let s=t[e];if(!(0,es.isElementDisabled)(s)){let e=s?.querySelector('[type="button"], [role="button"]');e&&!(0,es.isElementDisabled)(e)&&n.push(e)}}return n}(g),n=t.length-1,s=-1,a=t.indexOf(e.currentTarget);function r(){s=v?a+1>n?0:a+1:Math.min(a+1,n)}function l(){s=v&&0===a?n:a-1}switch(e.key){case el.ARROW_DOWN:b||r();break;case el.ARROW_UP:b||l();break;case el.ARROW_RIGHT:b&&(y?l():r());break;case el.ARROW_LEFT:b&&(y?r():l());break;case"Home":s=0;break;case"End":s=n}s>-1&&t[s].focus()}}),[g,m,w,b,y,v,u,c]);return(0,U.useRenderElement)("button",e,{state:N,ref:[t,h],props:[C,d,x],stateAttributesMapping:X.triggerOpenStateMapping})});var ec=e.i(18158);let eu=((n={}).accordionPanelHeight="--accordion-panel-height",n.accordionPanelWidth="--accordion-panel-width",n);var em=e.i(273598);let ep=r.forwardRef(function(e,t){let{className:n,hiddenUntilFound:s,keepMounted:a,id:l,render:i,style:o,...d}=e,{hiddenUntilFound:c,keepMounted:u}=L(),{abortControllerRef:m,animationTypeRef:p,height:x,mounted:h,onOpenChange:g,open:f,panelId:v,panelRef:j,runOnceAnimationsFinish:y,setDimensions:b,setHiddenUntilFound:N,setKeepMounted:k,setMounted:w,setOpen:C,setVisible:S,transitionDimensionRef:T,visible:M,width:I,setPanelIdState:z,transitionStatus:D}=(0,G.useCollapsibleRootContext)(),R=s??c,P=a??u;(0,ea.useIsoLayoutEffect)(()=>{if(l)return z(l),()=>{z(void 0)}},[l,z]),(0,ea.useIsoLayoutEffect)(()=>{N(R)},[N,R]),(0,ea.useIsoLayoutEffect)(()=>{k(P)},[k,P]),(0,em.useOpenChangeComplete)({open:f&&"idle"===D,ref:j,onComplete(){f&&b({width:void 0,height:void 0})}});let{props:A}=(0,ec.useCollapsiblePanel)({abortControllerRef:m,animationTypeRef:p,externalRef:t,height:x,hiddenUntilFound:R,id:l??v,keepMounted:P,mounted:h,onOpenChange:g,open:f,panelRef:j,runOnceAnimationsFinish:y,setDimensions:b,setMounted:w,setOpen:C,setVisible:S,transitionDimensionRef:T,visible:M,width:I}),{state:O,triggerId:E}=Q(),$=r.useMemo(()=>({...O,transitionStatus:D}),[O,D]),B=(0,U.useRenderElement)("div",e,{state:$,ref:[t,j],props:[A,{"aria-labelledby":E,role:"region",style:{[eu.accordionPanelHeight]:void 0===x?"auto":`${x}px`,[eu.accordionPanelWidth]:void 0===I?"auto":`${I}px`}},d],stateAttributesMapping:ee});return P||R||h?B:null});e.s(["Header",0,en,"Item",0,et,"Panel",0,ep,"Root",0,_,"Trigger",0,ed],127284);var ex=e.i(127284),ex=ex,eh=e.i(250438),eg=e.i(380797),eg=eg;function ef({className:e,...t}){return(0,a.jsx)(ex.Root,{"data-slot":"accordion",className:(0,M.cn)("flex w-full flex-col",e),...t})}function ev({className:e,...t}){return(0,a.jsx)(ex.Item,{"data-slot":"accordion-item",className:(0,M.cn)("not-last:border-b",e),...t})}function ej({className:e,children:t,...n}){return(0,a.jsx)(ex.Header,{className:"flex",children:(0,a.jsxs)(ex.Trigger,{"data-slot":"accordion-trigger",className:(0,M.cn)("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",e),...n,children:[t,(0,a.jsx)(eh.ChevronDownIcon,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),(0,a.jsx)(eg.default,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function ey({className:e,children:t,...n}){return(0,a.jsx)(ex.Panel,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up",...n,children:(0,a.jsx)("div",{className:(0,M.cn)("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),children:t})})}var eb=e.i(562918);let eN=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("not-prose w-full rounded-md border",e),...t})),ek=(0,r.memo)(({className:e,name:t,model:n,...s})=>(0,a.jsx)("div",{className:(0,M.cn)("flex w-full items-center justify-between gap-4 p-3",e),...s,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(D.default,{className:"size-4 text-muted-foreground"}),(0,a.jsx)("span",{className:"font-medium text-sm",children:t}),n&&(0,a.jsx)(eb.Badge,{className:"font-mono text-xs",variant:"secondary",children:n})]})})),ew=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("space-y-4 p-4 pt-0",e),...t})),eC=(0,r.memo)(({className:e,children:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),...n,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("subagent.instructions")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-muted-foreground text-sm",children:(0,a.jsx)("p",{children:t})})]})}),eS=(0,r.memo)(({className:e,...t})=>{let n=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:n("subagent.tools")}),(0,a.jsx)(ef,{className:"rounded-md border",multiple:!0,...t})]})}),eT=(0,r.memo)(({className:e,tool:t,value:n,...s})=>{let r="jsonSchema"in t&&t.jsonSchema?t.jsonSchema:t.inputSchema,i=(0,l.useTranslations)("chat");return(0,a.jsxs)(ev,{className:(0,M.cn)("border-b last:border-b-0",e),value:n,...s,children:[(0,a.jsx)(ej,{className:"px-3 py-2 text-sm hover:no-underline",children:t.description??i("subagent.noDescription")}),(0,a.jsx)(ey,{className:"px-3 pb-3",children:(0,a.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,a.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:JSON.stringify(r,null,2)})})})]})}),eM=(0,r.memo)(({className:e,schema:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),...n,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("subagent.outputSchema")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,a.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:t})})]})});eN.displayName="Agent",ek.displayName="AgentHeader",ew.displayName="AgentContent",eC.displayName="AgentInstructions",eS.displayName="AgentTools",eT.displayName="AgentTool",eM.displayName="AgentOutput";var eI=e.i(905724),eI=eI,ez=e.i(551157),ez=ez;let eD=(0,h.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),eR=(0,h.default)("music-2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),eP=(0,h.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),eA=(0,h.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);var eO=e.i(422373),eE=e.i(260218);e.s([],339090),e.i(339090);var e$=e.i(166392),eL=e.i(538501),eU=e.i(427396),eB=e.i(389124);let eF=r.createContext(void 0);function eW(e){let t=r.useContext(eF);if(void 0===t&&!e)throw Error((0,E.default)(50));return t}var e_=e.i(106206),eH=e.i(332976),eq=e.i(493696),eV=e.i(549154),eG=e.i(695011),eK=e.i(561213),eJ=e.i(107164);let eQ={...eG.popupStoreSelectors,instantType:(0,eH.createSelector)(e=>e.instantType),hasViewport:(0,eH.createSelector)(e=>e.hasViewport)};class eX extends eq.ReactStore{constructor(e){super({...(0,eG.createInitialPopupStoreState)(),instantType:void 0,hasViewport:!1,...e},{popupRef:r.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new eK.PopupTriggerMap,closeDelayRef:{current:300}},eQ)}setOpen=(e,t)=>{let n=t.reason,s=n===F.REASONS.triggerHover,a=e&&n===F.REASONS.triggerFocus,r=!e&&(n===F.REASONS.triggerPress||n===F.REASONS.escapeKey);if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let l=()=>{let s={open:e};a?s.instantType="focus":r?s.instantType="dismiss":n===F.REASONS.triggerHover&&(s.instantType=void 0);let l=t.trigger?.id??null;(l||e)&&(s.activeTriggerId=l,s.activeTriggerElement=t.trigger??null),this.update(s)};s?e_.flushSync(l):l()};static useStore(e,t){let n=(0,eV.useRefWithInit)(()=>new eX(t)).current,s=e??n,a=(0,eJ.useSyncedFloatingRootContext)({popupStore:s,onOpenChange:s.setOpen});return s.state.floatingRootContext=a,s}}var eY=e.i(279501);function eZ(e){let{open:t,defaultOpen:n=!1,onOpenChange:s,onOpenChangeComplete:l,actionsRef:i,handle:o,triggerId:d,defaultTriggerId:c=null,children:u}=e,m=eX.useStore(o?.store,{open:n,openProp:t,activeTriggerId:c,triggerIdProp:d});(0,e$.useOnFirstRender)(()=>{void 0===t&&!1===m.state.open&&!0===n&&m.update({open:!0,activeTriggerId:c})}),m.useControlledProp("openProp",t),m.useControlledProp("triggerIdProp",d),m.useContextCallback("onOpenChange",s),m.useContextCallback("onOpenChangeComplete",l);let p=m.useState("open"),x=m.select("floatingRootContext"),h=m.useState("activeTriggerId"),g=m.useState("payload");(0,eY.useImplicitActiveTrigger)(m);let{forceUnmount:f}=(0,eY.useOpenStateTransitions)(p,m);(0,ea.useIsoLayoutEffect)(()=>{p&&null==h&&m.set("payload",void 0)},[m,h,p]);let v=r.useCallback(()=>{m.setOpen(!1,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction))},[m]);r.useImperativeHandle(i,()=>({unmount:f,close:v}),[f,v]);let j=(0,eL.useDismiss)(x),{getReferenceProps:y,getTriggerProps:b,getFloatingProps:N}=(0,eU.useInteractions)([j]),k=r.useMemo(()=>y(),[y]),w=r.useMemo(()=>b(),[b]),C=r.useMemo(()=>N(),[N]);return m.useSyncedValues({activeTriggerProps:k,inactiveTriggerProps:w,popupProps:C}),(0,a.jsx)(eF.Provider,{value:m,children:"function"==typeof u?u({payload:g}):u})}let e0=r.createContext(void 0);var e1=e.i(384389);let e2=r.forwardRef(function(e,t){let{keepMounted:n=!1,...s}=e;return eW().useState("mounted")||n?(0,a.jsx)(e0.Provider,{value:n,children:(0,a.jsx)(e1.FloatingPortalLite,{ref:t,...s})}):null});var e3=e.i(817955),e5=e.i(499198),e4=e.i(604921),e6=e.i(480283);let e9=r.forwardRef(function(e,t){let{render:n,className:s,delay:a,closeDelay:l,id:i,payload:o,handle:d,style:c,...u}=e,m=eW(!0),p=d?.store??m;if(!p)throw Error((0,E.default)(89));let x=(0,q.useBaseUiId)(i),h=p.useState("isTriggerActive",x),g=p.useState("isOpenedByTrigger",x),f=p.useState("floatingRootContext"),v=r.useRef(null),j=a??600,y=l??300,{registerTrigger:b,isMountedByThisTrigger:N}=(0,eY.useTriggerDataForwarding)(x,v,p,{payload:o});(0,ea.useIsoLayoutEffect)(()=>{N&&(p.context.closeDelayRef.current=y)},[p,N,y]);let k=(0,e6.useHoverReferenceInteraction)(f,{mouseOnly:!0,move:!1,handleClose:(0,e5.safePolygon)(),delay:()=>({open:j,close:y}),triggerElementRef:v,isActiveTrigger:h,isClosing:()=>"ending"===p.select("transitionStatus")}),w=(0,e4.useFocus)(f,{delay:j}),C=p.useState("triggerProps",N);return(0,U.useRenderElement)("a",e,{state:{open:g},ref:[t,b,v],props:[k,w.reference,C,{id:x},u],stateAttributesMapping:e3.triggerOpenStateMapping})}),e8=r.createContext(void 0);function e7(){let e=r.useContext(e8);if(void 0===e)throw Error((0,E.default)(49));return e}var te=e.i(576557),tt=e.i(576487),tn=e.i(909852),ts=e.i(263635);let ta=r.forwardRef(function(e,t){let{render:n,className:s,anchor:l,positionMethod:i="absolute",side:o="bottom",align:d="center",sideOffset:c=0,alignOffset:u=0,collisionBoundary:m="clipping-ancestors",collisionPadding:p=5,arrowPadding:x=5,sticky:h=!1,disableAnchorTracking:g=!1,collisionAvoidance:f=tt.POPUP_COLLISION_AVOIDANCE,style:v,...j}=e,y=eW(),b=function(){let e=r.useContext(e0);if(void 0===e)throw Error((0,E.default)(48));return e}(),N=(0,eB.useFloatingNodeId)(),k=y.useState("open"),w=y.useState("mounted"),C=y.useState("floatingRootContext"),S=y.useState("instantType"),T=y.useState("transitionStatus"),M=y.useState("hasViewport"),I=(0,te.useAnchorPositioning)({anchor:l,floatingRootContext:C,positionMethod:i,mounted:w,side:o,sideOffset:c,align:d,alignOffset:u,arrowPadding:x,collisionBoundary:m,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:N,collisionAvoidance:f,adaptiveOrigin:M?tn.adaptiveOrigin:void 0}),z={open:k,side:I.side,align:I.align,anchorHidden:I.anchorHidden,instant:S},D=(0,ts.usePositioner)(e,z,{styles:I.positionerStyles,transitionStatus:T,props:j,refs:[t,y.useStateSetter("positionerElement")],hidden:!w,inert:!k});return(0,a.jsx)(e8.Provider,{value:I,children:(0,a.jsx)(eB.FloatingNode,{id:N,children:D})})});var tr=e.i(328657),tl=e.i(795914);let ti={...e3.popupStateMapping,...Y.transitionStatusMapping},to=r.forwardRef(function(e,t){let{className:n,render:s,style:a,...r}=e,l=eW(),{side:i,align:o}=e7(),d=l.useState("open"),c=l.useState("instantType"),u=l.useState("transitionStatus"),m=l.useState("popupProps"),p=l.useState("floatingRootContext");(0,em.useOpenChangeComplete)({open:d,ref:l.context.popupRef,onComplete(){d&&l.context.onOpenChangeComplete?.(!0)}});let x=(0,P.useStableCallback)(()=>l.context.closeDelayRef.current);return(0,tl.useHoverFloatingInteraction)(p,{closeDelay:x}),(0,U.useRenderElement)("div",e,{state:{open:d,side:i,align:o,instant:c,transitionStatus:u},ref:[t,l.context.popupRef,l.useStateSetter("popupElement")],props:[m,(0,tr.getDisabledMountTransitionStyles)(u),r],stateAttributesMapping:ti})}),td=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,l=eW(),{arrowRef:i,side:o,align:d,arrowUncentered:c,arrowStyles:u}=e7(),m=l.useState("open");return(0,U.useRenderElement)("div",e,{state:{open:m,side:o,align:d,uncentered:c},ref:[i,t],props:[{style:u,"aria-hidden":!0},r],stateAttributesMapping:e3.popupStateMapping})}),tc={...e3.popupStateMapping,...Y.transitionStatusMapping},tu=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,l=eW(),i=l.useState("open"),o=l.useState("mounted"),d=l.useState("transitionStatus");return(0,U.useRenderElement)("div",e,{state:{open:i,transitionStatus:d},ref:[t],props:[{role:"presentation",hidden:!o,style:{pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none"}},r],stateAttributesMapping:tc})}),tm=((s={}).popupWidth="--popup-width",s.popupHeight="--popup-height",s);var tp=e.i(3310);let tx={activationDirection:e=>e?{"data-activation-direction":e}:null},th=r.forwardRef(function(e,t){let{render:n,className:s,style:a,children:r,...l}=e,i=eW(),o=e7(),d=i.useState("instantType"),{children:c,state:u}=(0,tp.usePopupViewport)({store:i,side:o.side,cssVars:tm,children:r}),m={activationDirection:u.activationDirection,transitioning:u.transitioning,instant:d};return(0,U.useRenderElement)("div",e,{state:m,ref:t,props:[l,{children:c}],stateAttributesMapping:tx})});class tg{constructor(){this.store=new eX}open(e){let t=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!t)throw Error((0,E.default)(88,e));this.store.setOpen(!0,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction,void 0,t))}close(){this.store.setOpen(!1,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,td,"Backdrop",0,tu,"Handle",0,tg,"Popup",0,to,"Portal",0,e2,"Positioner",0,ta,"Root",0,function(e){return eW(!0)?(0,a.jsx)(eZ,{...e}):(0,a.jsx)(eB.FloatingTree,{children:(0,a.jsx)(eZ,{...e})})},"Trigger",0,e9,"Viewport",0,th,"createHandle",0,function(){return new tg}],981923),e.i(981923);let tf=e=>{if("source-document"===e.type)return"source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},tv=(0,r.createContext)(null),tj=(0,r.createContext)(null),ty=()=>{let e=(0,r.useContext)(tj);if(!e)throw Error("Attachment components must be used within <Attachment>");return e},tb=({variant:e="grid",className:t,children:n,...s})=>{let l=(0,r.useMemo)(()=>({variant:e}),[e]);return(0,a.jsx)(tv.Provider,{value:l,children:(0,a.jsx)("div",{className:(0,M.cn)("flex items-start","list"===e?"flex-col gap-2":"flex-wrap gap-2","grid"===e&&"ml-auto w-fit",t),...s,children:n})})},tN=({data:e,onRemove:t,className:n,children:s,...l})=>{let{variant:i}=(0,r.useContext)(tv)??{variant:"grid"},o=tf(e),d=(0,r.useMemo)(()=>({data:e,mediaCategory:o,onRemove:t,variant:i}),[e,o,t,i]);return(0,a.jsx)(tj.Provider,{value:d,children:(0,a.jsx)("div",{className:(0,M.cn)("group relative","grid"===i&&"size-24 overflow-hidden rounded-lg","inline"===i&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md border border-border px-1.5","font-medium text-sm transition-all","hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50"],"list"===i&&["flex w-full items-center gap-3 rounded-lg border p-3","hover:bg-accent/50"],n),...l,children:s})})},tk=({fallbackIcon:e,className:t,...n})=>{let{data:s,mediaCategory:r,variant:l}=ty(),i="inline"===l?"size-3":"size-4";return(0,a.jsx)("div",{className:(0,M.cn)("flex shrink-0 items-center justify-center overflow-hidden","grid"===l&&"size-full bg-muted","inline"===l&&"size-5 rounded bg-background","list"===l&&"size-12 rounded bg-muted",t),...n,children:(()=>{if("image"===r&&"file"===s.type&&s.url){let e,t;return e=s.url,t=s.filename,"grid"===l?(0,a.jsx)("img",{alt:t||"Image",className:"size-full object-cover",height:96,src:e,width:96}):(0,a.jsx)("img",{alt:t||"Image",className:"size-full rounded object-cover",height:20,src:e,width:20})}if("video"===r&&"file"===s.type&&s.url)return(0,a.jsx)("video",{className:"size-full object-cover",muted:!0,src:s.url});let t={image:eD,video:eA,audio:eR,source:ez.default,document:eI.default,unknown:eP}[r];return e??(0,a.jsx)(t,{className:(0,M.cn)(i,"text-muted-foreground")})})()})},tw=({showMediaType:e=!1,className:t,...n})=>{let{data:s,variant:r}=ty(),i=function(e){let t=(0,l.useTranslations)("chat");if("source-document"===e.type)return e.title||e.filename||t("attachments.source");let n=tf(e);return e.filename||t("image"===n?"attachments.image":"attachments.attachment")}(s);return"grid"===r?null:(0,a.jsxs)("div",{className:(0,M.cn)("min-w-0 flex-1",t),...n,children:[(0,a.jsx)("span",{className:"block truncate",children:i}),e&&s.mediaType&&(0,a.jsx)("span",{className:"block truncate text-muted-foreground text-xs",children:s.mediaType})]})},tC=({label:e,className:t,children:n,...s})=>{let{onRemove:r,variant:i}=ty(),o=(0,l.useTranslations)("chat"),d=e??o("attachments.remove");return r?(0,a.jsxs)(eE.Button,{"aria-label":d,className:(0,M.cn)("grid"===i&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],"inline"===i&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],"list"===i&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],t),onClick:e=>{e.stopPropagation(),r()},type:"button",variant:"ghost",...s,children:[n??(0,a.jsx)(eO.XIcon,{}),(0,a.jsx)("span",{className:"sr-only",children:d})]}):null};function tS({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,M.cn)("rounded-lg border bg-background p-3 text-sm",e),...t})}function tT({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-description",className:(0,M.cn)("text-muted-foreground",e),...t})}let tM=(0,r.createContext)(null),tI=()=>{let e=(0,r.useContext)(tM);if(!e)throw Error("Confirmation components must be used within Confirmation");return e},tz=({className:e,approval:t,state:n,...s})=>t&&"input-streaming"!==n&&"input-available"!==n?(0,a.jsx)(tM.Provider,{value:{approval:t,state:n},children:(0,a.jsx)(tS,{className:(0,M.cn)("flex flex-col gap-2",e),...s})}):null,tD=({className:e,...t})=>(0,a.jsx)(tT,{className:(0,M.cn)("inline",e),...t}),tR=({children:e})=>{let{state:t}=tI();return"approval-requested"!==t?null:e},tP=({children:e})=>{let{approval:t,state:n}=tI();return t?.approved&&("approval-responded"===n||"output-denied"===n||"output-available"===n)?e:null},tA=({children:e})=>{let{approval:t,state:n}=tI();return t?.approved!==!1||"approval-responded"!==n&&"output-denied"!==n&&"output-available"!==n?null:e},tO=({className:e,...t})=>{let{state:n}=tI();return"approval-requested"!==n?null:(0,a.jsx)("div",{className:(0,M.cn)("flex items-center justify-end gap-2 self-end",e),...t})},tE=e=>(0,a.jsx)(eE.Button,{className:"h-8 px-3 text-sm",type:"button",...e});var t$=e.i(757106),t$=t$;let tL=(0,h.default)("dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);var tU=e.i(256186);let tB=(0,r.createContext)(null);function tF(e){let t=e.trim(),n=t.replace(/^\[[^\]]+\]\s+subagent progress\s+\|\s*/i,""),s=n!==t;return/^Claude$/i.test(n)||/^(Reading|Searching)(\.{1,3}|…)?$/i.test(n)||s&&/^(Reading|Searching)\s+\S.+$/i.test(n)||/^(Read|Search|Grep|Glob|SemanticSearch|WebSearch)\s+running\s+\(\d+s\)$/i.test(n)}let tW=()=>{let e=(0,r.useContext)(tB);if(!e)throw Error("ChainOfThought components must be used within ChainOfThought");return e},t_=(0,r.memo)(({className:e,open:t,defaultOpen:n=!1,onOpenChange:s,children:l,...i})=>{let[o,d]=(0,r.useState)(n),c=t??o,u=(0,r.useCallback)(e=>{void 0===t&&d(e),s?.(e)},[s,t]),m=(0,r.useMemo)(()=>({isOpen:c,setIsOpen:u}),[c,u]);return(0,a.jsx)(tB.Provider,{value:m,children:(0,a.jsx)("div",{className:(0,M.cn)("not-prose max-w-prose overflow-hidden space-y-4",e),...i,children:l})})}),tH=(0,r.memo)(({className:e,children:t,loading:n,...s})=>{let{isOpen:r,setIsOpen:i}=tW(),o=(0,l.useTranslations)("chat");return(0,a.jsx)(tU.Collapsible,{onOpenChange:i,open:r,children:(0,a.jsxs)(tU.CollapsibleTrigger,{className:(0,M.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...s,children:[(0,a.jsx)(t$.default,{className:"size-4"}),(0,a.jsx)("span",{className:"flex-1 text-left",children:t??o("chainOfThought.defaultHeader")}),n&&(0,a.jsx)(z,{size:14}),(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),tq=(0,r.memo)(({className:e,icon:t=tL,label:n,description:s,status:r="complete",children:l,...i})=>(0,a.jsxs)("div",{className:(0,M.cn)("flex gap-2 text-sm",{complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"}[r],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[(0,a.jsxs)("div",{className:"relative mt-0.5",children:[(0,a.jsx)(t,{className:"size-4"}),(0,a.jsx)("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,a.jsx)("div",{children:n}),s&&(0,a.jsx)("div",{className:"text-muted-foreground text-xs",children:s}),l]})]})),tV=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("flex flex-wrap items-center gap-2",e),...t})),tG=(0,r.memo)(({className:e,children:t,...n})=>(0,a.jsx)(eb.Badge,{className:(0,M.cn)("gap-1 px-2 py-0.5 font-normal text-xs",e),variant:"secondary",...n,children:t})),tK=(0,r.memo)(({className:e,children:t,...n})=>{let{isOpen:s}=tW();return(0,a.jsx)(tU.Collapsible,{open:s,children:(0,a.jsx)(tU.CollapsibleContent,{className:(0,M.cn)("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})}),tJ=(0,r.memo)(({className:e,children:t,caption:n,...s})=>(0,a.jsxs)("div",{className:(0,M.cn)("mt-2 space-y-2",e),...s,children:[(0,a.jsx)("div",{className:"relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg bg-muted p-3",children:t}),n&&(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:n})]}));t_.displayName="ChainOfThought",tH.displayName="ChainOfThoughtHeader",tq.displayName="ChainOfThoughtStep",tV.displayName="ChainOfThoughtSearchResults",tG.displayName="ChainOfThoughtSearchResult",tK.displayName="ChainOfThoughtContent",tJ.displayName="ChainOfThoughtImage";var tQ=e.i(299648),tX=e.i(839374),tX=tX,tY=e.i(184591),tY=tY,tZ=e.i(875350),t0=e.i(341807);let t1=(0,r.memo)(({children:e,as:t="p",className:n,duration:s=2,spread:l=2})=>{let i=(0,r.useMemo)(()=>(e?.length??0)*l,[e,l]);return(0,a.jsx)(t,{children:(0,a.jsx)(t0.motion.span,{animate:{backgroundPosition:"0% center"},className:(0,M.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:1/0,duration:s,ease:"linear"},children:e})})}),t2=(0,r.createContext)({output:"",isStreaming:!1,autoScroll:!0}),t3=({output:e,isStreaming:t=!1,autoScroll:n=!0,onClear:s,className:r,children:l,...i})=>(0,a.jsx)(t2.Provider,{value:{output:e,isStreaming:t,autoScroll:n,onClear:s},children:(0,a.jsx)("div",{className:(0,M.cn)("flex flex-col overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100",r),...i,children:l??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(t5,{children:[(0,a.jsx)(t4,{}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(t6,{}),(0,a.jsxs)(t9,{children:[(0,a.jsx)(t8,{}),s&&(0,a.jsx)(t7,{})]})]})]}),(0,a.jsx)(ne,{})]})})}),t5=({className:e,children:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("flex items-center justify-between border-zinc-800 border-b px-4 py-2",e),...n,children:t}),t4=({className:e,children:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center gap-2 text-sm text-zinc-400",e),...n,children:[(0,a.jsx)(tY.default,{className:"size-4"}),t??s("terminal.title")]})},t6=({className:e,children:t,...n})=>{let{isStreaming:s}=(0,r.useContext)(t2),i=(0,l.useTranslations)("chat");return s?(0,a.jsx)("div",{className:(0,M.cn)("flex items-center gap-2 text-xs text-zinc-400",e),...n,children:t??(0,a.jsx)(t1,{className:"w-16",children:i("terminal.running")})}):null},t9=({className:e,children:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("flex items-center gap-1",e),...n,children:t}),t8=({onCopy:e,onError:t,timeout:n=2e3,children:s,className:i,...o})=>{let[d,c]=(0,r.useState)(!1),{output:u}=(0,r.useContext)(t2),m=(0,l.useTranslations)("chat"),p=async()=>{if(!navigator?.clipboard?.writeText)return void t?.(Error(m("terminal.clipboardUnavailable")));try{await navigator.clipboard.writeText(u),c(!0),e?.(),setTimeout(()=>c(!1),n)}catch(e){t?.(e)}},x=d?tQ.CheckIcon:tX.default;return(0,a.jsx)(eE.Button,{className:(0,M.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",i),onClick:p,size:"icon",variant:"ghost",...o,children:s??(0,a.jsx)(x,{size:14})})},t7=({children:e,className:t,...n})=>{let{onClear:s}=(0,r.useContext)(t2);return s?(0,a.jsx)(eE.Button,{className:(0,M.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",t),onClick:s,size:"icon",variant:"ghost",...n,children:e??(0,a.jsx)(tZ.Trash2Icon,{size:14})}):null},ne=({className:e,children:t,...n})=>{let{output:s,isStreaming:l,autoScroll:i}=(0,r.useContext)(t2),o=(0,r.useRef)(null);return(0,r.useEffect)(()=>{i&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[s,i]),(0,a.jsx)("div",{className:(0,M.cn)("max-h-96 overflow-auto p-4 font-mono text-sm leading-relaxed",e),ref:o,...n,children:t??(0,a.jsxs)("pre",{className:"whitespace-pre-wrap break-words",children:[s.replace(/\u001b\[[0-9;]*m/g,""),l&&(0,a.jsx)("span",{className:"ml-0.5 inline-block h-4 w-2 animate-pulse bg-zinc-100"})]})})},nt=(0,h.default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);var D=D,nn=e.i(444741),nn=nn;let ns=(0,h.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var tX=tX,na=e.i(867295),na=na;let nr=(0,h.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var eI=eI,nl=e.i(361421),nl=nl,ez=ez,ni=e.i(294543),ni=ni;let no=(0,h.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]);var nd=e.i(995684),nd=nd,nc=e.i(367914),nu=e.i(656744),nu=nu;let nm=(0,h.default)("square-check",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var tY=tY;let np=(0,h.default)("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);var nx=e.i(212068),nx=nx,nh=e.i(940361),ng=e.i(691223),nf=e.i(613812),nv=e.i(887836);e.i(462506);var nj=e.i(950396);function ny(){let e=(0,l.useTranslations)("chat");return(0,a.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground text-xs",children:e("readonlyCodeBlock.loading")})}let nb=(0,nv.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,a.jsx)(ny,{})});function nN({value:e,language:t="plaintext",title:n,height:s=220}){let{resolvedTheme:r}=(0,nj.useTheme)();return(0,a.jsxs)("div",{className:"overflow-hidden rounded-md border bg-background",children:[n?(0,a.jsx)("div",{className:"border-b bg-muted/30 px-2 py-1 font-mono text-muted-foreground text-xs",children:n}):null,(0,a.jsx)("div",{style:{height:s},children:(0,a.jsx)(nb,{height:"100%",language:t,value:e,options:{readOnly:!0,domReadOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineNumbers:"on",renderLineHighlight:"none",wordWrap:"on",folding:!1,overviewRulerLanes:0},theme:"dark"===r?"vs-dark":"vs"})})]})}let nk={Read:nt,Write:eI.default,Edit:nd.default,MultiEdit:nr,Bash:tY.default,TodoWrite:nm,Grep:nc.SearchIcon,Glob:nl.default,Search:nc.SearchIcon,SemanticSearch:nc.SearchIcon,WebSearch:ez.default,WebFetch:np,Fetch:np,Task:no,Agent:D.default,Skill:nu.default,AskUserQuestion:ni.default,LoadClaudeMd:nt};function nw({text:e,status:t}){let n=(0,l.useTranslations)("chat"),s=Array.from(e.trim()).length>=300,[i,o]=(0,r.useState)(!1);return(0,a.jsx)(tq,{icon:no,label:(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,a.jsx)("span",{children:n("messageParts.aiMessage")}),s?(0,a.jsx)(eE.Button,{type:"button",variant:"ghost",size:"icon",className:"ml-auto size-5",onClick:()=>o(!i),children:(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-3.5 transition-transform",i&&"rotate-180")})}):null]}),status:t,children:!s||i?(0,a.jsx)(b.Markdown,{content:e}):null})}function nC({chain:e,message:t,workspaceId:n,status:s}){var i,o;let d=(0,ng.useEditorStore)(e=>e.openFile),[c,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(null),[x,h]=(0,r.useState)(!1),[g,f]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),N=(0,l.useTranslations)("chat"),k=async()=>{e.filePath&&await d(n,e.filePath)},w=(0,r.useCallback)(async()=>{if(m||!e.detailId)return m;h(!0),f(null);try{let s=await fetch(`/api/workspaces/${n}/channels/${t.channelId}/messages/${t.id}/tool-details/${e.detailId}`);if(!s.ok)throw Error(await s.text());let a=await s.json();return p(a),a}catch(e){return f(e instanceof Error?e.message:N("messageParts.failedToLoadDetails")),null}finally{h(!1)}},[m,e.detailId,n,t.channelId,t.id,N]),C=async()=>{let e=!c;u(e),e&&!x&&await w()},S=async()=>{var t;let n=m??await w(),s=n?void 0!==(t=n).input||void 0!==t.output?JSON.stringify({input:t.input,output:t.output},null,2):t.raw??"":e.command??e.title;try{await navigator.clipboard.writeText(s),j(!0),setTimeout(()=>j(!1),1500)}catch{}},T=async()=>{await w(),b(!0)};return(0,a.jsxs)(tq,{icon:(i=e.toolName,i&&nk[i]?nk[i]:i?.startsWith("mcp__")||i?.startsWith("mcp-")?nx.default:"complete"===s?nn.default:ns),label:(0,a.jsxs)(nh.ContextMenu,{children:[(0,a.jsxs)(nh.ContextMenuTrigger,{className:"group/tool-step flex min-w-0 items-center gap-1.5 overflow-hidden",children:[(0,a.jsx)("span",{className:"shrink-0",children:e.filePath?e.title.replace(RegExp(`\\s+${((o=e.filePath).split(/[\\/]/).filter(Boolean).at(-1)??o).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`),""):e.title}),e.description?(0,a.jsx)("span",{className:"min-w-0 shrink truncate text-muted-foreground text-xs",children:e.description}):null,e.filePath?(0,a.jsxs)(eE.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 max-w-48 shrink gap-1 px-1.5 text-xs",onClick:k,children:[(0,a.jsx)(eI.default,{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e.filePath})]}):null,(0,a.jsx)("div",{className:"ml-auto flex shrink-0 items-center",children:e.detailId?(0,a.jsx)(eE.Button,{type:"button",variant:"ghost",size:"icon",className:"size-5",onClick:C,children:(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-3.5 transition-transform",c&&"rotate-180")})}):null})]}),(0,a.jsxs)(nh.ContextMenuContent,{children:[(0,a.jsxs)(nh.ContextMenuItem,{onClick:S,children:[v?(0,a.jsx)(tQ.CheckIcon,{className:"size-4 text-green-500"}):(0,a.jsx)(tX.default,{className:"size-4"}),N("messageParts.copy")]}),(0,a.jsxs)(nh.ContextMenuItem,{onClick:T,children:[(0,a.jsx)(na.default,{className:"size-4"}),N("messageParts.view")]})]})]}),description:e.command,status:s,children:[e.answer?(0,a.jsxs)("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,a.jsx)("div",{className:"text-muted-foreground text-xs",children:N("messageParts.result")}),(0,a.jsx)("div",{className:"font-medium",children:e.answer})]}):null,c?(0,a.jsx)("div",{className:"space-y-2",children:x?(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:N("messageParts.loadingDetails")}):g?(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-destructive text-xs",children:g}):m?(0,a.jsx)(nS,{detail:m,toolName:e.toolName,filePath:e.filePath}):(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:N("messageParts.noDetails")})}):null,(0,a.jsx)(nI,{open:y,onOpenChange:b,detail:m,toolName:e.toolName,loading:x,error:g,t:N})]})}function nS({detail:e,toolName:t,filePath:n}){var s,r;let i,o=(0,l.useTranslations)("chat");if(/^(Bash|Shell|Command)$/i.test(t??"")){let t=function(e){if(!e||"object"!=typeof e)return"string"==typeof e?e:void 0;let t=e.command??e.Command;return"string"==typeof t?t:void 0}(e.input),n="string"==typeof e.output?e.output:JSON.stringify(e.output??"",null,2);return(0,a.jsx)(t3,{output:t?`$ ${t}
|
|
2
|
-
${n}`:n})}let d=function(e,t,n){if(!e||"object"!=typeof e)return null;let s=nz(e.file_path)??nz(e.path)??n??"edit",a=function(e){if(!e||"object"!=typeof e)return;let t=nz(e.content);if(void 0!==t)return t;let n=e.file;if(n&&"object"==typeof n)return nz(n.content)}(t),r=nz(e.old_string),l=nz(e.new_string);if(void 0!==r&&void 0!==l)return{path:s,oldContent:r,newContent:a??l};let i=Array.isArray(e.edits)?e.edits:[];return i.length>0?{path:s,oldContent:i.map((e,t)=>e&&"object"==typeof e?nz(e.old_string)??`#${t+1}`:`#${t+1}`).join("\n\n"),newContent:a??i.map((e,t)=>e&&"object"==typeof e?nz(e.new_string)??`#${t+1}`:`#${t+1}`).join("\n\n")}:null}(e.input,e.output,n);if(d&&/^(Edit|MultiEdit)$/i.test(t??""))return(0,a.jsx)("div",{className:"h-80 overflow-hidden rounded-md border bg-background",children:(0,a.jsx)(nf.DiffViewer,{oldContent:d.oldContent,newContent:d.newContent,path:d.path})});let c=(s=e,r=o,i=[],void 0!==s.input&&i.push({title:r("messageParts.input"),value:nT(s.input),language:nM(s.input)?"json":"plaintext",height:180}),void 0!==s.output&&i.push({title:r("messageParts.output"),value:nT(s.output),language:nM(s.output)?"json":"plaintext",height:220}),i);return 0===c.length&&e.raw?(0,a.jsx)(nN,{title:o("messageParts.raw"),value:e.raw,language:"plaintext"}):(0,a.jsx)("div",{className:"space-y-2",children:c.map(e=>(0,a.jsx)(nN,{title:e.title,value:e.value,language:e.language,height:e.height},e.title))})}function nT(e){return"string"==typeof e?e:JSON.stringify(e,null,2)}function nM(e){return"string"!=typeof e}function nI({open:e,onOpenChange:t,detail:n,toolName:s,loading:r,error:l,t:i}){return(0,a.jsx)(y.Dialog,{open:e,onOpenChange:t,children:(0,a.jsxs)(y.DialogContent,{className:"sm:max-w-3xl",children:[(0,a.jsx)(y.DialogHeader,{children:(0,a.jsx)(y.DialogTitle,{children:s??i("messageParts.raw")})}),r?(0,a.jsx)("div",{className:"py-8 text-center text-muted-foreground text-sm",children:i("messageParts.loadingDetails")}):l?(0,a.jsx)("div",{className:"py-8 text-center text-destructive text-sm",children:l}):n?(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,a.jsx)(nN,{title:i("messageParts.input"),value:nT(n.input)||"-",language:nM(n.input)?"json":"plaintext",height:320}),(0,a.jsx)(nN,{title:i("messageParts.output"),value:nT(n.output)||"-",language:nM(n.output)?"json":"plaintext",height:320})]}):(0,a.jsx)("div",{className:"py-8 text-center text-muted-foreground text-sm",children:i("messageParts.noDetails")})]})})}function nz(e){return"string"==typeof e?e:void 0}var D=D,nD=e.i(191118),nR=e.i(812057),nP=e.i(368942),nA=e.i(660748);let nO=(0,r.createContext)(null),nE=()=>{let e=(0,r.useContext)(nO);if(!e)throw Error("Context components must be used within Context");return e},n$=({usedTokens:e,maxTokens:t,usage:n,modelId:s,children:r,...l})=>(0,a.jsx)(nO.Provider,{value:{usedTokens:e,maxTokens:t,usage:n,modelId:s},children:(0,a.jsx)(w.Popover,{...l,children:r})}),nL=()=>{let{usedTokens:e,maxTokens:t,usage:n}=nE(),s=e-(n?.cachedInputTokens??0),r=2*Math.PI*10;return(0,a.jsxs)("svg",{"aria-label":"Model context usage",height:"20",role:"img",style:{color:"currentcolor"},viewBox:"0 0 24 24",width:"20",children:[(0,a.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.25",r:10,stroke:"currentColor",strokeWidth:2}),(0,a.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.7",r:10,stroke:"currentColor",strokeDasharray:`${r} ${r}`,strokeDashoffset:r*(1-s/t),strokeLinecap:"round",strokeWidth:2,style:{transformOrigin:"center",transform:"rotate(-90deg)"}})]})},nU=({children:e,...t})=>{let{usedTokens:n,maxTokens:s,usage:l}=nE(),i=n-(l?.cachedInputTokens??0),o=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(i/s),d=((0,r.isValidElement)(e)?e:void 0)??(0,a.jsxs)(eE.Button,{type:"button",variant:"ghost",...t,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground",children:o}),(0,a.jsx)(nL,{})]});return(0,a.jsx)(w.PopoverTrigger,{render:d})},nB=({className:e,...t})=>(0,a.jsx)(w.PopoverContent,{className:(0,M.cn)("min-w-60 divide-y overflow-hidden p-0",e),...t}),nF=({children:e,className:t,...n})=>{let{usedTokens:s,maxTokens:r,usage:l}=nE(),i=(s-(l?.cachedInputTokens??0))/r,o=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(i),d=new Intl.NumberFormat("en-US",{notation:"compact"}).format(s),c=new Intl.NumberFormat("en-US",{notation:"compact"}).format(r);return(0,a.jsx)("div",{className:(0,M.cn)("w-full space-y-2 p-3",t),...n,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,a.jsx)("p",{children:o}),(0,a.jsxs)("p",{className:"font-mono text-muted-foreground",children:[d," / ",c]})]}),(0,a.jsx)("div",{className:"space-y-2",children:(0,a.jsx)(nA.Progress,{className:"bg-muted",value:100*i})})]})})},nW=({children:e,className:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("w-full p-3",t),...n,children:e}),n_=({children:e,className:t,...n})=>{let{modelId:s,usage:r}=nE(),i=(0,l.useTranslations)("chat"),o=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsx)("div",{className:(0,M.cn)("flex w-full items-center justify-between gap-3 bg-secondary p-3 text-xs",t),...n,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.totalCost")}),(0,a.jsx)("span",{children:o})]})})},nH=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.inputTokens??0;if(t)return t;if(!o)return null;let d=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.input")}),(0,a.jsx)(nK,{costText:d,tokens:o})]})},nq=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.outputTokens??0;if(t)return t;if(!o)return null;let d=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.output")}),(0,a.jsx)(nK,{costText:d,tokens:o})]})},nV=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.reasoningTokens??0;if(t)return t;if(!o)return null;let d=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.reasoning")}),(0,a.jsx)(nK,{costText:d,tokens:o})]})},nG=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.cachedInputTokens??0;if(t)return t;if(!o)return null;let d=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.cache")}),(0,a.jsx)(nK,{costText:d,tokens:o})]})},nK=({tokens:e,costText:t})=>(0,a.jsxs)("span",{children:[void 0===e?"—":new Intl.NumberFormat("en-US",{notation:"compact"}).format(e),t?(0,a.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["• ",t]}):null]});function nJ(e){return{inputTokens:e.usage?.inputTokens??0,outputTokens:e.usage?.outputTokens??0,totalTokens:e.usage?.totalTokens??e.usedTokens,cachedInputTokens:e.usage?.cachedInputTokens??0,reasoningTokens:e.usage?.reasoningTokens??0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0}}}function nQ({part:e}){let t=e.agentContext,n=nJ(e),s=n.inputTokens+n.outputTokens+n.reasoningTokens,r=n.totalTokens>0?n.cachedInputTokens/n.totalTokens:0,l=function(e){if(e?.length)return JSON.stringify(e.map(e=>({id:e.id,type:e.type,title:e.title,toolUseId:e.toolUseId,toolName:e.toolName,characters:e.characters,tokens:e.tokens,text:e.text})),null,2)}(t?.outputItems)??t?.output,i=function(e){if(e?.length)return e.reduce((e,t)=>({characters:e.characters+(t.characters??0),tokens:e.tokens+(t.tokens??0)}),{characters:0,tokens:0})}(t?.outputItems)??nZ(t?.output),o=[{key:"systemPrompt",title:"提示词信息",value:t?.systemPrompt,empty:"此 agent 未配置独立 system prompt。"},{key:"userPrompt",title:"输入信息",value:t?.userPrompt,empty:"旧消息未记录用户输入。"},{key:"fullPrompt",title:"完整上下文",value:t?.fullPrompt,empty:"旧消息未记录完整 prompt。"},{key:"output",title:"输出信息",value:l,empty:"暂无输出信息。",stats:i}].map(e=>({...e,stats:e.stats??nZ(e.value)})),d=o.reduce((e,t)=>e+t.stats.tokens,0);return(0,a.jsxs)("div",{className:"flex flex-col gap-4 h-full",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)(eb.Badge,{variant:"secondary",children:t?.name||t?.role||"Agent"}),t?.runtime?(0,a.jsx)(eb.Badge,{variant:"outline",children:t.runtime}):null,t?.model||e.modelId?(0,a.jsx)(eb.Badge,{variant:"outline",children:t?.model||e.modelId}):null,t?.sessionId?(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:t.sessionId}):null]}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3 xl:grid-cols-6",children:[(0,a.jsx)(nX,{label:"有效上下文",value:s,helper:"输入 + 输出 + 推理,不含缓存命中",emphasize:!0}),(0,a.jsx)(nX,{label:"总用量(含缓存)",value:n.totalTokens,helper:"provider usage total"}),(0,a.jsx)(nX,{label:"新输入",value:n.inputTokens}),(0,a.jsx)(nX,{label:"输出",value:n.outputTokens}),(0,a.jsx)(nX,{label:"推理",value:n.reasoningTokens}),(0,a.jsx)(nX,{label:"缓存输入",value:n.cachedInputTokens,helper:`${n0(r)} of total`})]}),(0,a.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,a.jsx)(nY,{title:o[0].title,value:o[0].value,empty:o[0].empty,stats:o[0].stats,totalTokens:d},o[0].key),(0,a.jsx)(nY,{title:o[1].title,value:o[1].value,empty:o[1].empty,stats:o[1].stats,totalTokens:d},o[1].key)]}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-4 min-h-0",children:[(0,a.jsx)(nY,{title:o[2].title,value:o[2].value,empty:o[2].empty,stats:o[2].stats,totalTokens:d},o[2].key),(0,a.jsx)(nY,{title:o[3].title,value:o[3].value,empty:o[3].empty,stats:o[3].stats,totalTokens:d},o[3].key)]})]})}function nX({label:e,value:t,helper:n,emphasize:s}){return(0,a.jsxs)("div",{className:(0,M.cn)("rounded-md border bg-muted/30 p-3",s&&"border-primary/30 bg-primary/5"),children:[(0,a.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e}),(0,a.jsx)("div",{className:(0,M.cn)("mt-1 font-mono text-sm",s&&"font-semibold text-primary"),children:n1(t??0)}),n?(0,a.jsx)("div",{className:"mt-1 text-[10px] text-muted-foreground",children:n}):null]})}function nY({title:e,value:t,empty:n,stats:s,totalTokens:r}){let l=r>0?s.tokens/r:0;return(0,a.jsxs)("section",{className:"min-w-0 overflow-hidden flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:e}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,a.jsx)("span",{children:n0(l)}),(0,a.jsxs)("span",{children:[n1(s.characters)," 字"]}),(0,a.jsxs)("span",{children:[n1(s.tokens)," tokens"]})]})]}),(0,a.jsx)("pre",{className:(0,M.cn)("min-w-0 flex-1 min-h-0 whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed text-foreground overflow-auto",!t?.trim()&&"text-muted-foreground",!t?.trim()&&"text-muted-foreground"),children:t?.trim()||n})]})}function nZ(e){var t;let n,s,a=e?.trim()??"";return a?{characters:Array.from(a).length,tokens:(t=a,n=t.match(/[㐀-鿿豈-]/g)?.length??0,s=t.replace(/[㐀-鿿豈-]/g," "),Math.max(1,Math.ceil(n+.75*(s.match(/[A-Za-z0-9_]+|[^\sA-Za-z0-9_]/g)?.length??0))))}:{characters:0,tokens:0}}function n0(e){return new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(e)}function n1(e){return new Intl.NumberFormat("en-US").format(e)}function n2({message:e}){let t=(0,r.useMemo)(()=>e.parts?.filter(e=>"context"===e.type)??[],[e.parts]),n=t[t.length-1],[s,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(),u=(0,nP.useLLMStore)(e=>e.models),m=(0,nP.useLLMStore)(e=>e.ensure),p=n?.modelId?u.find(e=>e.modelId===n.modelId||e.name===n.modelId):void 0,x=p?.maxContextTokens??n?.maxTokens;if((0,r.useEffect)(()=>{n&&m()},[m,n]),!n||!x)return null;let h=t.reduce((e,t)=>e+t.usedTokens,0),g=t.reduce((e,t)=>({inputTokens:e.inputTokens+(t.usage?.inputTokens??0),outputTokens:e.outputTokens+(t.usage?.outputTokens??0),totalTokens:e.totalTokens+(t.usage?.totalTokens??t.usedTokens),cachedInputTokens:e.cachedInputTokens+(t.usage?.cachedInputTokens??0),reasoningTokens:e.reasoningTokens+(t.usage?.reasoningTokens??0)}),{inputTokens:0,outputTokens:0,totalTokens:0,cachedInputTokens:0,reasoningTokens:0}),f=t.length>1?{...n,usedTokens:h,usage:g}:n,v=nJ(f),j=t.find(e=>e.id===d)??t[0];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n$,{usedTokens:f.usedTokens,maxTokens:x,modelId:f.modelId,usage:v,open:s,onOpenChange:l,children:[(0,a.jsx)(nU,{className:"h-5 gap-1 px-1.5 text-[10px]"}),(0,a.jsxs)(nB,{children:[(0,a.jsx)(nF,{}),(0,a.jsxs)(nW,{className:"space-y-2",children:[(0,a.jsx)(nH,{}),(0,a.jsx)(nq,{}),(0,a.jsx)(nV,{}),(0,a.jsx)(nG,{})]}),(0,a.jsx)(n_,{}),(0,a.jsx)("div",{className:"border-t px-3 py-2",children:(0,a.jsx)("button",{type:"button",className:"w-full text-center text-xs text-primary hover:underline",onClick:()=>{l(!1),o(!0)},children:"查看详情 →"})})]})]}),(0,a.jsx)(y.Dialog,{open:i,onOpenChange:o,children:(0,a.jsxs)(y.DialogContent,{className:"!flex !w-[min(920px,calc(100vw-2rem))] !max-w-[min(920px,calc(100vw-2rem))] !flex-col gap-0 overflow-hidden p-0",children:[(0,a.jsxs)(y.DialogHeader,{className:"border-b px-5 py-4",children:[(0,a.jsx)(y.DialogTitle,{className:"text-base",children:"Agent 上下文结构"}),(0,a.jsxs)(y.DialogDescription,{className:"text-xs",children:["此条消息包含 ",t.length," 次 agent 运行。选择 tab 查看提示词、输入、输出和 token 消耗。"]})]}),t.length?(0,a.jsxs)(nR.Tabs,{value:j?.id,onValueChange:c,className:"min-h-0 flex flex-1 gap-0",children:[(0,a.jsx)("div",{className:"flex w-56 shrink-0 flex-col border-r",children:(0,a.jsx)(nR.TabsList,{className:"!flex h-auto w-full flex-col items-stretch gap-1 rounded-none border-0 bg-transparent p-2",children:t.map((e,t)=>(0,a.jsxs)(nR.TabsTrigger,{value:e.id,className:"!w-full justify-start gap-2 px-3 py-2 text-xs",children:[(0,a.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-muted font-mono text-[10px] text-muted-foreground",children:t+1}),(0,a.jsx)(D.default,{className:"size-3.5 shrink-0"}),(0,a.jsx)("span",{className:"min-w-0 truncate",children:e.agentContext?.name||e.agentContext?.role||`Agent ${t+1}`})]},e.id))})}),(0,a.jsx)(nD.ScrollArea,{className:"max-h-[min(68vh,720px)] min-w-0 flex-1",children:t.map(e=>(0,a.jsx)(nR.TabsContent,{value:e.id,className:"m-0 min-w-0 p-5",children:(0,a.jsx)(nQ,{part:e})},e.id))})]}):null]})})]})}function n3({message:e,isUser:t,workspaceId:n}){let s=(0,l.useTranslations)("chat"),r=e.parts??[],i=r.filter(e=>"context"!==e.type),o=i.some(e=>"text"===e.type),d=0===r.length&&e.content;return(0,a.jsxs)("div",{className:"space-y-3 min-w-0 overflow-hidden",children:[e.attachments?.length?(0,a.jsx)(n6,{attachments:e.attachments,isUser:t}):null,i.length>0?i.map(t=>(0,a.jsx)(n5,{part:function(e){if("text"!==e.type)return e;let t=n8(e.text);return t===e.text?e:{...e,text:t}}(t),message:e,workspaceId:n},t.id)):null,!o&&d?t?(0,a.jsx)(n9,{content:e.content}):(0,a.jsx)(b.Markdown,{content:n8(e.content)}):null,"pending"===e.status&&0===i.length?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,a.jsx)(z,{size:14}),(0,a.jsx)("span",{children:s("messageParts.agentProcessing")})]}):null]})}function n5({part:e,message:t,workspaceId:n}){let s=(0,l.useTranslations)("chat");switch(e.type){case"text":return(0,a.jsx)(b.Markdown,{content:e.text});case"user_message":return(0,a.jsx)(n4,{text:e.text,senderName:e.senderName||"用户"});case"reasoning":return(0,a.jsxs)(t_,{defaultOpen:"streaming"===e.status,className:"max-w-none",children:[(0,a.jsx)(tH,{loading:"streaming"===e.status,children:s("streaming"===e.status?"messageParts.agentThinking":"messageParts.aiIntermediateOutput")}),(0,a.jsx)(tK,{className:"max-h-[300px] overflow-y-auto",children:(0,a.jsx)("div",{className:"pl-6 text-xs text-muted-foreground",children:(0,a.jsx)(b.Markdown,{content:e.text})})})]});case"chain":let r=e.chains.filter(e=>!tF(e.text??e.description??e.title)),i=r.filter(e=>"message"!==e.kind).length;if(0===r.length)return null;return(0,a.jsxs)(t_,{defaultOpen:"pending"===t.status,className:"max-w-none",children:[(0,a.jsx)(tH,{loading:"pending"===t.status||"streaming"===t.status,children:s("messageParts.chainSteps",{count:i})}),(0,a.jsx)(tK,{className:"max-h-[300px] overflow-y-auto",children:r.map(e=>{let s="completed"===e.status;return"message"===e.kind?(0,a.jsx)(nw,{text:e.text??e.title,status:s?"complete":"active"},e.id):(0,a.jsx)(nC,{chain:e,message:t,workspaceId:n,status:s?"complete":"active"},e.id)})})]});case"terminal":return(0,a.jsx)(t3,{output:e.command?`$ ${e.command}
|
|
3
|
-
${e.output}`:e.output,isStreaming:"streaming"===e.status,className:"error"===e.status?"border-destructive/40":void 0});case"confirmation":{var o,d;let t=(o=e.id,(d=e.approval)&&void 0!==d.approved?{id:d.id,approved:d.approved,reason:d.reason}:{id:d?.id??o});return(0,a.jsxs)(tz,{approval:t,state:void 0===t.approved?"approval-requested":"approval-responded",children:[(0,a.jsxs)(tD,{children:[(0,a.jsxs)(tR,{children:[e.title,e.description?(0,a.jsx)("span",{className:"block text-xs",children:e.description}):null]}),(0,a.jsx)(tP,{children:e.title}),(0,a.jsx)(tA,{children:e.approval?.reason??e.title})]}),(0,a.jsxs)(tO,{children:[(0,a.jsx)(tE,{variant:"outline",children:s("messageParts.reject")}),(0,a.jsx)(tE,{children:s("messageParts.approve")})]})]})}case"context":case"ask_user_question":default:return null;case"subagent":let c=e.output&&!tF(e.output)?e.output:void 0;return(0,a.jsxs)(eN,{children:[(0,a.jsx)(ek,{name:e.name,model:e.model}),e.instructions||c||e.tools?.length?(0,a.jsxs)(ew,{children:[e.instructions?(0,a.jsx)(eC,{children:e.instructions}):null,c?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("messageParts.result")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-sm",children:(0,a.jsx)(b.Markdown,{content:c})})]}):null,e.tools?.length?(0,a.jsx)(eS,{children:e.tools.map((e,t)=>(0,a.jsx)(eT,{value:`tool-${t}`,tool:{description:e.description??e.name,inputSchema:e.inputSchema,jsonSchema:e.jsonSchema}},`${e.name??"tool"}-${t}`))}):null]}):null]})}}function n4({text:e,senderName:t}){return(0,a.jsxs)("div",{className:"not-prose rounded-md border border-primary/20 bg-primary/5 px-3 py-2 text-sm",children:[(0,a.jsxs)("div",{className:"mb-1 text-xs font-medium text-primary",children:[t,":"]}),(0,a.jsx)(n9,{content:e})]})}function n6({attachments:e,isUser:t}){return(0,a.jsx)(tb,{variant:"inline",className:t?"justify-end":"justify-start",children:e.map((e,t)=>{var n,s;return(0,a.jsxs)(tN,{data:(n=e,s=t,{id:`${n.path||n.name}-${s}`,type:"file",filename:n.name,mediaType:n.type,url:n.url||n.path}),children:[(0,a.jsx)(tk,{}),(0,a.jsx)(tw,{showMediaType:!0})]},`${e.path}-${t}`)})})}function n9({content:e}){return/<[a-z][\s\S]*>/i.test(e)?(0,a.jsx)("span",{className:"tiptap tiptap-message",dangerouslySetInnerHTML:{__html:e}}):(0,a.jsx)("span",{className:"whitespace-pre-wrap break-all",children:e})}function n8(e){let t=[...e.split(/\r?\n/)];for(;t.length>1&&t.length%2==0;){let e=t.length/2,n=t.slice(0,e),s=t.slice(e);if(n7(n.join("\n"))!==n7(s.join("\n")))break;t=n}return t.join("\n")}function n7(e){return e.trim().replace(/\s+/g," ")}function se({message:e,workspaceId:t,onEdit:n,onDelete:s,onReply:i}){let d=(0,l.useTranslations)("common"),h="user"===e.senderId,w=(0,o.useAgentStore)(e=>e.agents),C=h?void 0:w.find(t=>t.id===e.senderId),S=h?d("you"):C?.name||e.senderId,M=(0,k.useUserAvatar)(),I=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[z,D]=(0,r.useState)(!1),[R,P]=(0,r.useState)(!1),[A,O]=(0,r.useState)(!1),E=e.replies??[],$="streaming"===e.status||"pending"===e.status||"waiting_for_user"===e.status,[L,U]=(0,r.useState)(()=>e.metadata?.duration??0);(0,r.useEffect)(()=>{if(!$&&e.metadata?.duration!=null)return void U(e.metadata.duration);if(!$)return;let t=new Date(e.createdAt).getTime();U(Date.now()-t);let n=setInterval(()=>U(Date.now()-t),1e3);return()=>clearInterval(n)},[e.metadata?.duration,e.createdAt,$]);let B=!h&&($||"completed"===e.status||"error"===e.status)&&L>0,F=(0,r.useCallback)(async()=>{let t=st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content;await navigator.clipboard.writeText(t),D(!0),setTimeout(()=>D(!1),2e3)},[e.content]);return(0,a.jsxs)("div",{className:`group flex gap-2 px-3 py-1.5 ${h?"flex-row-reverse":""}`,children:[(0,a.jsx)(N.AgentIcon,{agentId:h?void 0:e.senderId,name:S,avatarUrl:h&&M||void 0,onClick:()=>P(!0),className:"size-7 rounded-full"}),(0,a.jsxs)("div",{className:`flex flex-col min-w-0 w-[80%] ${h?"items-end":"items-start"}`,children:[!h&&(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:S}),e.senderRole&&(0,a.jsx)("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:e.senderRole}),e.metadata?.model&&(0,a.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground",children:e.metadata.model}),(0,a.jsx)(n2,{message:e}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:I})]}),(0,a.jsxs)("div",{className:`min-w-0 max-w-full text-sm rounded-lg px-3 py-2 ${h?"bg-primary text-primary-foreground":"bg-muted"}`,children:[(0,a.jsx)(n3,{message:e,isUser:h,workspaceId:t}),(E.length>0||B)&&(0,a.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-3 border-t border-border/30 pt-1",children:[(0,a.jsx)(sn,{replies:E,currentUserLabel:d("you")}),(0,a.jsxs)("div",{className:"ml-auto flex items-center justify-end gap-1",children:[!$&&"completed"===e.status&&(0,a.jsx)(f.CheckCircle2,{className:"h-3 w-3 text-green-500 shrink-0"}),!$&&"error"===e.status&&(0,a.jsx)(v.XCircle,{className:"h-3 w-3 text-destructive shrink-0"}),B&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.Clock,{className:"h-3 w-3 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[function(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let s=Math.floor(n/60);return`${s}h ${n%60}m`}(L),$&&(0,a.jsx)("span",{className:"animate-pulse ml-0.5",children:"..."})]})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 h-6 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{onClick:()=>i?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"回复",children:(0,a.jsx)(g,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:F,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"复制",children:z?(0,a.jsx)(p.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,a.jsx)(c.Copy,{className:"h-3.5 w-3.5"})}),h&&(0,a.jsx)("button",{onClick:()=>n?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"编辑",children:(0,a.jsx)(u.Pencil,{className:"h-3.5 w-3.5"})}),!h&&e.content&&(0,a.jsx)("button",{onClick:()=>O(!0),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"全屏查看",children:(0,a.jsx)(j,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:()=>s?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-destructive transition-colors",title:"删除",children:(0,a.jsx)(m.Trash2,{className:"h-3.5 w-3.5"})})]})]}),(0,a.jsx)(T,{open:R,onOpenChange:P,memberName:e.senderId,channelId:e.channelId,workspaceId:t}),!h&&A&&(0,a.jsx)(y.Dialog,{open:A,onOpenChange:O,children:(0,a.jsxs)(y.DialogPortal,{children:[(0,a.jsx)(y.DialogOverlay,{}),(0,a.jsxs)(y.DialogContent,{className:"max-w-4xl max-h-[85vh] flex flex-col gap-0",children:[(0,a.jsx)(y.DialogHeader,{children:(0,a.jsx)(y.DialogTitle,{children:S})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:(0,a.jsx)(b.Markdown,{content:st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content})})]})]})})]})}function st(e){return/<[a-z][\s\S]*>/i.test(e)}function sn({replies:e,currentUserLabel:t}){return 0===e.length?(0,a.jsx)("span",{className:"min-w-0"}):(0,a.jsxs)(w.Popover,{children:[(0,a.jsxs)(w.PopoverTrigger,{render:(0,a.jsx)("button",{type:"button",className:"min-w-0 truncate text-[11px] text-muted-foreground transition-colors hover:text-foreground"}),children:["有 ",e.length," 条回复消息"]}),(0,a.jsx)(w.PopoverContent,{align:"start",sideOffset:4,className:"w-96 max-w-[calc(100vw-2rem)] p-2",children:(0,a.jsx)("div",{className:"max-h-96 space-y-2 overflow-y-auto pr-1",children:e.map(e=>(0,a.jsxs)("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:"user"===e.senderId?t:e.senderRole||e.senderId}),(0,a.jsx)("span",{children:new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsx)("div",{className:"whitespace-pre-wrap break-words",children:st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content})]},e.id))})})]})}var ss=e.i(917955),sa={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};let sr=(e,t,n,s)=>{let a=(0,r.forwardRef)(({color:n="currentColor",size:a=24,stroke:l=2,title:i,className:o,children:d,...c},u)=>(0,r.createElement)("svg",{ref:u,...sa[e],width:a,height:a,className:["tabler-icon",`tabler-icon-${t}`,o].join(" "),..."filled"===e?{fill:n}:{strokeWidth:l,stroke:n},...c},[i&&(0,r.createElement)("title",{key:"svg-title"},i),...s.map(([e,t])=>(0,r.createElement)(e,t)),...Array.isArray(d)?d:[d]]));return a.displayName=`${n}`,a},sl=sr("outline","chevron-up","ChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),si=sr("outline","microphone","Microphone",[["path",{d:"M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5",key:"svg-0"}],["path",{d:"M5 10a7 7 0 0 0 14 0",key:"svg-1"}],["path",{d:"M8 21l8 0",key:"svg-2"}],["path",{d:"M12 17l0 4",key:"svg-3"}]]),so=sr("outline","paperclip","Paperclip",[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]]),sd=sr("outline","plus","Plus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),sc=sr("outline","wand","Wand",[["path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3",key:"svg-0"}],["path",{d:"M15 6l3 3",key:"svg-1"}],["path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-2"}],["path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-3"}]]);var su=e.i(437122),sm=e.i(568772),sp=e.i(99567),sx=e.i(332339),sh=e.i(780207),sg=e.i(898822),sf=e.i(972097),sv=e.i(162519),sj=e.i(199302),sy=e.i(939785),sb=e.i(111092),sN=e.i(822162);let sk=new sb.PluginKey("agentResourceSuggestion"),sw=new sb.PluginKey("fileSearchSuggestion");var sC=e.i(444433),sS=e.i(230698),sT=e.i(272736);let sM=sr("outline","file-text","FileText",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]]),sI=sr("outline","message-circle-plus","MessageCirclePlus",[["path",{d:"M12.007 19.98a9.869 9.869 0 0 1 -4.307 -.98l-4.7 1l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c1.992 1.7 2.93 4.04 2.747 6.34",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),sz=sr("outline","tools","Tools",[["path",{d:"M3 21h4l13 -13a1.5 1.5 0 0 0 -4 -4l-13 13v4",key:"svg-0"}],["path",{d:"M14.5 5.5l4 4",key:"svg-1"}],["path",{d:"M12 8l-5 -5l-4 4l5 5",key:"svg-2"}],["path",{d:"M7 8l-1.5 1.5",key:"svg-3"}],["path",{d:"M16 12l5 5l-4 4l-5 -5",key:"svg-4"}],["path",{d:"M16 17l-1.5 1.5",key:"svg-5"}]]);function sD(e){let t=new Set,n=e=>{if(e&&("mention"===e.type&&"string"==typeof e.attrs?.id&&t.add(e.attrs.id),Array.isArray(e.content)))for(let t of e.content)n(t)};return n(e),[...t]}function sR(e,t){return e?{type:"doc",content:e.split("\n").map(e=>{let n=function(e,t){let n,s=[],a=/@(\S+)/g,r=0;for(;null!==(n=a.exec(e));){n.index>r&&s.push({type:"text",text:e.slice(r,n.index)});let l=n[1],i=t.find(e=>e.name===l||e.id===l||e.role===l);i?s.push({type:"mention",attrs:{id:i.id,label:i.name||i.role}}):s.push({type:"text",text:n[0]}),r=a.lastIndex}return r<e.length&&s.push({type:"text",text:e.slice(r)}),s}(e,t);return{type:"paragraph",content:n.length>0?n:void 0}})}:{type:"doc",content:[{type:"paragraph"}]}}async function sP(e){let t=new FormData;t.append("file",e.file);let n=await fetch("/api/upload",{method:"POST",body:t});if(!n.ok)throw Error(`Upload failed: ${e.file.name}`);let s=await n.json();return{name:s.name,path:s.url,url:s.url,type:s.type,size:s.size}}let sA=sr("outline","pin","Pin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]),sO=sr("filled","pin-filled","PinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",key:"svg-0"}]]),sE=sr("outline","user-plus","UserPlus",[["path",{d:"M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}],["path",{d:"M6 21v-2a4 4 0 0 1 4 -4h4",key:"svg-3"}]]),s$=sr("outline","bell","Bell",[["path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6",key:"svg-0"}],["path",{d:"M9 17v1a3 3 0 0 0 6 0v-1",key:"svg-1"}]]),sL=sr("outline","bell-off","BellOff",[["path",{d:"M9.346 5.353c.21 -.129 .428 -.246 .654 -.353a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3m-1 3h-13a4 4 0 0 0 2 -3v-3a6.996 6.996 0 0 1 1.273 -3.707",key:"svg-0"}],["path",{d:"M9 17v1a3 3 0 0 0 6 0v-1",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]]);function sU({agents:e,activeAgent:t,pinnedMentionId:n,isPinned:s,channel:r,onActivateAgent:i,onTogglePin:o,onOpenAddMember:d,onToggleNotify:c}){let u=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 overflow-x-auto scrollbar-none flex-1 min-w-0",children:[(0,a.jsx)("button",{type:"button",onClick:d,className:"shrink-0 inline-flex items-center justify-center size-6 rounded-full text-muted-foreground border border-dashed border-muted-foreground/40 hover:bg-accent hover:text-foreground transition-all",title:u("input.manageMembers"),children:(0,a.jsx)(sE,{className:"size-3.5"})}),e.map(e=>{let r=e.id===t?.id;return(0,a.jsxs)("button",{type:"button",onClick:()=>i(e),className:(0,M.cn)("shrink-0 inline-flex items-center gap-1 h-6 pl-0.5 pr-1 rounded-full text-xs transition-all",r?"bg-primary/10 text-primary border border-primary/30":"text-muted-foreground border border-transparent hover:bg-accent"),children:[(0,a.jsx)(N.AgentIcon,{agentId:e.id,name:e.name||e.role,avatarUrl:e.avatarUrl,className:"size-5 rounded-full text-[9px]"}),(0,a.jsx)("span",{className:"max-w-[80px] truncate",children:e.name||e.role}),r?(0,a.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),o())},className:(0,M.cn)("inline-flex items-center justify-center size-4 rounded-full hover:bg-primary/20 transition-colors",s?"text-primary":"text-primary/50"),title:s?u("input.unpinAgent"):u("input.pinAgent"),children:s?(0,a.jsx)(sO,{className:"size-2.5"}):(0,a.jsx)(sA,{className:"size-2.5"})}):n===e.id?(0,a.jsx)(sO,{className:"size-2.5 text-muted-foreground/50"}):null]},e.id)})]}),(0,a.jsx)("button",{type:"button",onClick:c,className:(0,M.cn)("shrink-0 inline-flex items-center gap-1 h-6 px-1.5 rounded-full text-xs transition-all",r.notifyOnComplete?"bg-primary/10 text-primary border border-primary/30":"text-muted-foreground border border-transparent hover:bg-accent"),title:u("input.notifyOnComplete"),children:r.notifyOnComplete?(0,a.jsx)(s$,{className:"size-3"}):(0,a.jsx)(sL,{className:"size-3"})})]})}let sB=sr("outline","chevron-down","ChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),sF=sr("outline","circle-check","CircleCheck",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]),sW=sr("outline","circle-dashed","CircleDashed",[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]]),s_=sr("outline","loader-2","Loader2",[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]]),sH=sr("outline","plug","Plug",[["path",{d:"M9.785 6l8.215 8.215l-2.054 2.054a5.81 5.81 0 1 1 -8.215 -8.215l2.054 -2.054",key:"svg-0"}],["path",{d:"M4 20l3.5 -3.5",key:"svg-1"}],["path",{d:"M15 4l-3.5 3.5",key:"svg-2"}],["path",{d:"M20 9l-3.5 3.5",key:"svg-3"}]]),sq=sr("outline","puzzle","Puzzle",[["path",{d:"M4 7h3a1 1 0 0 0 1 -1v-1a2 2 0 0 1 4 0v1a1 1 0 0 0 1 1h3a1 1 0 0 1 1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 1 0 4h-1a1 1 0 0 0 -1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-1a2 2 0 0 0 -4 0v1a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h1a2 2 0 0 0 0 -4h-1a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1",key:"svg-0"}]]),sV=sr("outline","trash","Trash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);function sG(e,t){return e.subject||e.title||e.activeForm||e.content||t}function sK({mcps:e,skills:t,tools:n,todos:s,onClearTodos:r}){let i=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:"flex items-center gap-0 pt-2",children:[(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sH,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.mcp"),e.length?` ${e.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:e.length?e.map(e=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(sH,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sH,{size:16,className:"opacity-60"}),i("input.noMcp")]})})})]}),(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sq,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.skill"),t.length?` ${t.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:t.length?t.map(e=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(sq,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sq,{size:16,className:"opacity-60"}),i("input.noSkills")]})})})]}),(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sz,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.tools"),n.length?` ${n.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:n.length?n.map(({name:e,label:t,icon:n})=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(n,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:t})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sz,{size:16,className:"opacity-60"}),i("input.noTools")]})})})]}),s&&s.length>0&&(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sF,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.todos")," ",s.length]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsxs)(ss.DropdownMenuContent,{align:"start",className:"w-80 rounded-2xl p-1.5 bg-popover border-border",children:[(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-0.5",children:s.map((e,t)=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs gap-2",onSelect:e=>e.preventDefault(),children:["completed"===e.status?(0,a.jsx)(sF,{size:14,className:"text-green-500 shrink-0"}):"in_progress"===e.status?(0,a.jsx)(s_,{size:14,className:"text-blue-500 shrink-0 animate-spin",style:{animationDuration:"3s"}}):(0,a.jsx)(sW,{size:14,className:"text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:(0,M.cn)("todo-text-scroll","completed"===e.status&&"line-through text-muted-foreground"),children:sG(e,i("untitledTodo"))})]},e.id||`${sG(e,i("untitledTodo"))}-${t}`))}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ss.DropdownMenuSeparator,{}),(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-destructive focus:text-destructive gap-2 justify-center cursor-pointer",onClick:e=>{e.stopPropagation(),r()},children:[(0,a.jsx)(sV,{size:14}),i("input.clearTodos")]})]})]})]}),(0,a.jsx)("div",{className:"flex-1"})]})}let sJ=(0,r.forwardRef)(function({channelName:e,channelId:t,workspaceId:n,channel:s,agents:d,messages:c=[],onSend:u,isProcessing:m=!1,onStop:p,replyTo:x,onCancelReply:h},g){let f=(0,l.useTranslations)("chat"),[v,j]=(0,r.useState)(!1),{isRecording:y,start:b,stop:N}=function(){let[e,t]=(0,r.useState)(!1),[n,s]=(0,r.useState)(null),a=(0,r.useRef)(null),l=(0,r.useRef)(null),i=(0,r.useRef)(null),o=(0,r.useRef)(null),d=(0,r.useRef)(null),c=(0,r.useRef)(()=>{}),u=(0,r.useCallback)(async()=>{let e=(0,su.getToken)();console.log("[speech] loading config, token:",e?"present":"missing");let t=await fetch("/api/speech-recognition",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(console.log("[speech] config response status:",t.status),!t.ok)return null;let n=await t.json();return console.log("[speech] configs found:",n.length,n.length>0?n[0]:""),n.length>0?n[0]:null},[]),m=(0,r.useCallback)(()=>{d.current&&(clearInterval(d.current),d.current=null),i.current?.disconnect(),l.current?.close(),o.current?.getTracks().forEach(e=>e.stop()),a.current?.readyState===WebSocket.OPEN&&(a.current.send(JSON.stringify({type:"end"})),a.current.close()),a.current=null,i.current=null,l.current=null,o.current=null,t(!1)},[]);return(0,r.useEffect)(()=>{c.current=m},[m]),{isRecording:e,start:(0,r.useCallback)(async e=>{let n,r=await u();if(!r)return console.warn("[speech] no config found, aborting"),!1;s(r);let d=(0,su.getToken)(),m="https:"===location.protocol?"wss:":"ws:",p=`${m}//${location.host}/ws/speech?token=${d??""}&configId=${r.id}`;console.log("[speech] connecting to",p.replace(/token=[^&]+/,"token=***"));let x=new WebSocket(p);a.current=x,x.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.error)return void console.error("[speech] error from server:",n.error);n.text&&(console.log("[speech] result:",n.text,"isFinal:",n.isFinal),e(n.text,n.isFinal))}catch(e){console.error("[speech] failed to parse message:",e)}},x.onerror=e=>{console.error("[speech] WebSocket error",e),c.current()};try{await new Promise((e,t)=>{x.onopen=()=>{console.log("[speech] WebSocket connected"),e()},x.onerror=e=>{console.error("[speech] WebSocket connect failed",e),t(Error("WS connect failed"))}})}catch{return!1}try{n=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:16e3,channelCount:1,echoCancellation:!0}}),console.log("[speech] microphone acquired, tracks:",n.getAudioTracks().length)}catch(e){return console.error("[speech] microphone access denied:",e),x.close(),!1}o.current=n;let h=new AudioContext({sampleRate:16e3});l.current=h,console.log("[speech] AudioContext sampleRate:",h.sampleRate);let g=h.createMediaStreamSource(n),f=h.createScriptProcessor(4096,1,1);i.current=f;let v=0;return f.onaudioprocess=e=>{if(x.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e++){let s=Math.max(-1,Math.min(1,t[e]));n[e]=s<0?32768*s:32767*s}x.send(n.buffer),(++v<=3||v%50==0)&&console.log("[speech] sent audio chunk #",v,"size:",n.buffer.byteLength)},g.connect(f),f.connect(h.destination),t(!0),!0},[u]),stop:m,config:n}}(),[k,w]=(0,r.useState)([]),[C,S]=(0,r.useState)([]),[T,I]=(0,r.useState)(!1),[z,D]=(0,r.useState)(!1),R=(0,r.useRef)(m),P=(0,r.useRef)(u),A=(0,r.useRef)(null),O=(0,r.useRef)(null),E=(0,r.useRef)(!1),$=(0,r.useRef)(null),L=(0,r.useRef)(d),U=(0,r.useRef)(s),B=(0,r.useRef)([]),F=(0,r.useRef)({mcps:[],tools:[]}),{saveDraft:W,clearDraft:_,updateChannel:H}=(0,i.useChannelStore)(),[q,V]=(0,r.useState)(!1),G=(0,o.useAgentStore)(e=>e.agents),K=s.pinnedMentionId,J=K===k[0]&&!!K,Q=(0,r.useMemo)(()=>{if(0===k.length)return[];let e=new Map(d.map(e=>[e.id,e]));return k.map(t=>e.get(t)).filter(e=>!!e)},[d,k])[0],X=(0,r.useMemo)(()=>(function(e){if(!e)return[];let t=e.mcpServers;return!t||"object"!=typeof t||Array.isArray(t)?[]:Object.keys(t)})(Q?.mcps),[Q?.mcps]),Y=(0,r.useMemo)(()=>Q?.skills??[],[Q?.skills]),Z=(0,r.useMemo)(()=>{let e=new Set(Q?.tools??[]);return(sC.BUILT_IN_AGENT_TOOLS??[]).filter(t=>e.has(t.name)).map(e=>{var t;return{...e,icon:"CreateCurrentChannelIssue"===(t=e.name)?sd:"ViewCurrentChannelIssue"===t?sM:"AddCurrentChannelComment"===t?sI:sz}})},[Q?.tools]),ee=(0,r.useMemo)(()=>Z.map(e=>({name:e.name,label:e.label})),[Z]),et=(0,r.useMemo)(()=>{let e=new Map;for(let t of c)t.senderId&&"user"!==t.senderId&&e.set(t.senderId,t.createdAt);return e},[c]),en=(0,r.useMemo)(()=>{let e=Q?.id;return[...d].sort((t,n)=>{if(t.id===e)return -1;if(n.id===e)return 1;let s=et.get(t.id)??"";return(et.get(n.id)??"").localeCompare(s)})},[d,Q?.id,et]);(0,r.useEffect)(()=>{R.current=m},[m]),(0,r.useEffect)(()=>{P.current=u},[u]),(0,r.useEffect)(()=>{L.current=d},[d]),(0,r.useEffect)(()=>{U.current=s},[s]),(0,r.useEffect)(()=>{B.current=Y},[Y]),(0,r.useEffect)(()=>{F.current={mcps:X,tools:ee}},[X,ee]);let es=(0,r.useCallback)(e=>{O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{e.trim()?W(n,t,e):_(n,t)},1e3)},[n,t,W,_]),ea=(0,r.useCallback)(async()=>{let e=A.current;if(!e||R.current||E.current)return;let s=e.getText().trim();if(!s&&0===C.length)return;let a=sD(e.getJSON());E.current=!0,I(!0),O.current&&(clearTimeout(O.current),O.current=null);try{let r=await Promise.all(C.map(sP));P.current(s?function(e){if(!e)return e;let t=e.replace(/<\/?p>/g,"");return/<[^>]+>/.test(t)?e:e.replace(/<\/p>\s*<p>/g,"\n").replace(/<\/?p>/g,"")}(e.getHTML()):"",a,r,x?.id),e.commands.clearContent(),S(e=>(e.forEach(e=>URL.revokeObjectURL(e.preview)),[])),w([]),h?.(),_(n,t)}finally{E.current=!1,I(!1)}},[C,n,t,x?.id,h,_]),{getRootProps:er,getInputProps:el,open:ei}=(0,sg.useDropzone)({noClick:!0,noKeyboard:!0,multiple:!0,accept:{"image/*":[],"application/pdf":[".pdf"],"application/msword":[".doc"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"text/*":[".txt",".md",".csv",".json"]},onDrop:e=>{S(t=>[...t,...e.map(e=>({file:e,preview:URL.createObjectURL(e)}))])}});(0,r.useEffect)(()=>()=>{C.forEach(e=>URL.revokeObjectURL(e.preview))},[C]);let eo=(0,r.useCallback)((e,t)=>{let{tr:n}=e.state,s=!1,a=[];e.state.doc.descendants((e,n)=>{"mention"===e.type.name&&e.attrs?.id!==t&&a.push({pos:n,nodeSize:e.nodeSize})});for(let e=a.length-1;e>=0;e--){let{pos:t,nodeSize:r}=a[e];n.delete(t,t+r),s=!0}s&&e.view.dispatch(n)},[]),ed=(0,r.useRef)(x);(0,r.useEffect)(()=>{ed.current=x},[x]);let ec=(0,r.useMemo)(()=>sh.default.configure({HTMLAttributes:{class:"mention"},suggestion:{char:"@",items:({query:e})=>{if(ed.current)return[];let t=e.toLowerCase();return L.current.filter(e=>!1!==e.enabled&&`${e.name} ${e.role} ${e.description||""}`.toLowerCase().includes(t)).slice(0,6).map(e=>({id:e.id,label:e.name||e.role,description:`${e.role}${e.description?` \xb7 ${e.description}`:""}`}))},command:({editor:e,range:t,props:n})=>{eo(e,n.id),e.chain().focus().insertContentAt(t,[{type:"mention",attrs:n}]).run()},render:()=>(0,sv.createSuggestionRenderer)()}}),[eo]),eu=(0,r.useMemo)(()=>(0,sj.createSlashExtension)(()=>B.current),[]),em=(0,r.useMemo)(()=>{let e;return e=null,sy.Extension.create({name:"fileSearch",addOptions:()=>({suggestion:{char:"#",items:async({query:t})=>{if(!t.trim())return[];e?.abort(),e=new AbortController;try{let s=await fetch(`/api/workspaces/${n}/search/files?q=${encodeURIComponent(t.trim())}`,{signal:e.signal});if(!s.ok)return[];return((await s.json()).results||[]).filter(e=>"file"===e.type).slice(0,10).map(e=>({id:e.path,title:e.name,description:e.path}))}catch{return[]}},command:({editor:e,range:t,props:n})=>{e.chain().focus().deleteRange(t).insertContent(n.description+" ").run()},render:()=>(0,sv.createSuggestionRenderer)()}}),addProseMirrorPlugins(){return[(0,sN.default)({pluginKey:sw,editor:this.editor,...this.options.suggestion})]}})},[n]),ep=(0,r.useMemo)(()=>(function(e=()=>({mcps:[],tools:[]})){return sy.Extension.create({name:"agentResource",addOptions:()=>({suggestion:{char:"$",items:({query:t})=>(function({mcps:e,tools:t},n){let s=n.toLowerCase(),a=new Set,r=[];for(let t of e){let e=t.trim(),n=`mcp:${e}`;!(!e||a.has(n))&&(a.add(n),e.toLowerCase().includes(s)&&r.push({id:n,title:e,description:"mcp",kind:"mcp",value:e}))}for(let e of t){let t=e.name.trim(),n=e.label.trim()||t,l=`tool:${t}`;!(!t||a.has(l))&&(a.add(l),`${t} ${n}`.toLowerCase().includes(s)&&r.push({id:l,title:n,description:`tool \xb7 ${t}`,kind:"tool",value:t}))}return r})(e(),t),command:({editor:e,range:t,props:n})=>{e.chain().focus().deleteRange(t).insertContent(`[use ${n.kind}: ${n.value}]`).run()},render:()=>(0,sv.createSuggestionRenderer)()}}),addProseMirrorPlugins(){return[(0,sN.default)({pluginKey:sk,editor:this.editor,...this.options.suggestion})]}})})(()=>F.current),[]),ex=(0,r.useRef)(ea);ex.current=ea;let eh=(0,sm.useEditor)({immediatelyRender:!1,extensions:[sp.default,sx.default.configure({placeholder:f("input.placeholder",{channel:e})}),ec,eu,ep,em],editorProps:{attributes:{class:"tiptap tiptap-chat"},handleKeyDown:(e,t)=>"Enter"===t.key&&!t.shiftKey&&!document.querySelector(".suggestion-menu")&&(t.preventDefault(),ex.current(),!0),handlePaste:(e,t)=>{let n,s=t.clipboardData?.getData("text/html");if(s?.includes('data-type="mention"'))return!1;let a=t.clipboardData?.getData("text/plain");if(!a||!/@\S+/.test(a))return!1;let r=L.current;if(0===r.length)return!1;let l=/@(\S+)/g,i=!1;for(;null!==(n=l.exec(a));)if(r.some(e=>e.name===n[1]||e.id===n[1]||e.role===n[1])){i=!0;break}if(!i)return!1;let o=A.current;return!!o&&(o.commands.insertContent(sR(a,r)),!0)}},content:"",onUpdate:({editor:e})=>{let t=sD(e.getJSON());w(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t),es(e.getHTML())}},[ec,eu,ep,em,e]);(0,r.useEffect)(()=>{A.current=eh},[eh]);let eg=(0,r.useCallback)(e=>{if(!eh||k[0]===e.id)return;eo(eh,e.id);let t=eh.getText().trim(),n=[{type:"mention",attrs:{id:e.id,label:e.name||e.role}},{type:"text",text:" "+t}];eh.commands.setContent({type:"doc",content:[{type:"paragraph",content:n}]},{emitUpdate:!0}),eh.commands.focus("end")},[eh,k,eo]);(0,r.useEffect)(()=>{if(!eh||$.current===t)return;$.current=t,O.current&&(clearTimeout(O.current),O.current=null);let e=U.current.draft,n=U.current.pinnedMentionId,s=n?L.current.find(e=>e.id===n):void 0,a=e?.content?e.content:s?[{type:"mention",attrs:{id:s.id,label:s.name||s.role}},{type:"text",text:" "}]:"";eh.commands.setContent(a,{emitUpdate:!1}),w(sD(eh.getJSON()))},[eh,t]),(0,r.useImperativeHandle)(g,()=>({setContent:(e,t)=>{if(eh){if(e.includes('data-type="mention"'))eh.commands.setContent(e,{emitUpdate:!1});else{let n=/<[a-z][\s\S]*>/i.test(e)?e.replace(/<[^>]*>/g,""):e,s=t??L.current;s.length>0&&/@\S+/.test(n)?eh.commands.setContent(sR(n,s),{emitUpdate:!1}):eh.commands.setContent(n,{emitUpdate:!1})}eh.commands.focus("end")}},focus:()=>{eh?.commands.focus("end")}}),[eh]);let ef=(0,r.useCallback)(()=>{ea()},[ea]),ev=(!!(0,sm.useEditorState)({editor:eh,selector:e=>!!e.editor?.getText().trim()})||C.length>0)&&!T,ej=(0,r.useCallback)(e=>{S(t=>{let n=[...t],[s]=n.splice(e,1);return s&&URL.revokeObjectURL(s.preview),n})},[]),ey=(0,r.useCallback)(()=>{let e=k[0];e&&H(n,t,{pinnedMentionId:J?void 0:e})},[k,J,n,t,H]),eb=(0,r.useCallback)(()=>{y?N():b((e,t)=>{let n=A.current;n&&t&&n.chain().focus().insertContent(e).run()})},[y,b,N]),eN=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsx)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full border border-border hover:bg-accent"}),children:(0,a.jsx)(sd,{className:"size-3"})}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:ei,children:[(0,a.jsx)(so,{size:16,className:"opacity-60"}),f("input.attachFiles")]})})})]}),(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",onClick:()=>D(!z),className:(0,M.cn)("h-7 px-2 rounded-full border border-border hover:bg-accent",{"bg-primary/10 text-primary border-primary/30":z,"text-muted-foreground":!z}),children:[(0,a.jsx)(sc,{className:"size-3"}),(0,a.jsx)("span",{className:"text-xs",children:f("input.autoMode")})]}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",onClick:eb,className:(0,M.cn)("h-7 w-7 p-0 rounded-full border border-border hover:bg-accent",{"bg-red-500/10 text-red-500 border-red-500/30 animate-pulse":y,"text-muted-foreground":!y}),title:f(y?"input.voiceStop":"input.voiceStart"),children:(0,a.jsx)(si,{className:"size-3"})})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex justify-center -mt-0.5",children:(0,a.jsx)("button",{type:"button",onClick:()=>j(e=>!e),className:"p-0.5 text-muted-foreground/60 hover:text-foreground transition-colors",children:(0,a.jsx)(sl,{className:(0,M.cn)("size-3.5 transition-transform",v&&"rotate-180")})})}),!v&&(0,a.jsxs)("div",{className:"border-t px-4 py-2",children:[!x&&(0,a.jsx)(sU,{agents:en,activeAgent:Q,pinnedMentionId:K,isPinned:J,channel:s,onActivateAgent:eg,onTogglePin:ey,onOpenAddMember:()=>V(!0),onToggleNotify:()=>H(n,t,{notifyOnComplete:!s.notifyOnComplete})}),(0,a.jsx)(sf.ComposerShell,{workspaceId:n,editor:eh,canSubmit:ev,onSubmit:ef,onStop:p,isProcessing:m||T,actions:eN,dropzoneProps:er(),hiddenInput:(0,a.jsx)("input",{...el(),"data-chat-file-input":""}),replyLabel:x?.label,onCancelReply:h}),C.length>0&&(0,a.jsx)(tb,{variant:"inline",className:"mt-2 justify-start",children:C.map((e,t)=>(0,a.jsxs)(tN,{data:{id:`${e.file.name}-${e.file.lastModified}`,type:"file",filename:e.file.name,mediaType:e.file.type,url:e.preview},onRemove:()=>ej(t),children:[(0,a.jsx)(tk,{}),(0,a.jsx)(tw,{}),(0,a.jsx)(tC,{})]},`${e.file.name}-${e.file.lastModified}-${t}`))}),(0,a.jsx)(sK,{mcps:X,skills:Y,tools:Z,todos:s.todos,onClearTodos:()=>H(n,t,{todos:[]})})]}),(0,a.jsx)(sS.AddMemberDialog,{open:q,onOpenChange:V,candidates:G.filter(e=>!1!==e.enabled).map(e=>({id:e.id,label:(0,sT.getAgentDisplayName)(e),description:e.role})),defaultSelected:s.members,onAdd:e=>{let s=G.filter(e=>!1!==e.enabled);H(n,t,{members:(0,sT.normalizeChannelMembersToAgentIds)(s,e)})}})]})});var sQ=e.i(681622),sX=e.i(613087);let sY=({className:e,status:t,...n})=>(0,a.jsx)(eb.Badge,{className:(0,M.cn)("flex items-center gap-2","group",t,e),variant:"secondary",...n}),sZ=({className:e,...t})=>(0,a.jsxs)("span",{className:(0,M.cn)("relative flex h-2 w-2",e),...t,children:[(0,a.jsx)("span",{className:(0,M.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")}),(0,a.jsx)("span",{className:(0,M.cn)("relative inline-flex h-2 w-2 rounded-full","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")})]}),s0=({className:e,children:t,...n})=>(0,a.jsx)("span",{className:(0,M.cn)("text-muted-foreground",e),...n,children:t??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"hidden group-[.online]:block",children:"Online"}),(0,a.jsx)("span",{className:"hidden group-[.offline]:block",children:"Offline"}),(0,a.jsx)("span",{className:"hidden group-[.maintenance]:block",children:"Maintenance"}),(0,a.jsx)("span",{className:"hidden group-[.degraded]:block",children:"Degraded"})]})});var s1=e.i(767467),s2=ni,s3=e.i(583705),s5=e.i(759309),s5=s5,s4=e.i(307858),s6=e.i(14452),s9=e.i(227634),s8=e.i(325443),s7=e.i(511800),ae=e.i(529658),at=e.i(929709),an=e.i(478117);function as({name:e,agentId:t,description:n,onClick:s}){return(0,a.jsxs)("button",{type:"button",onClick:s,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left transition-colors",children:[(0,a.jsx)(N.AgentIcon,{agentId:t,name:e,className:"size-7 rounded-full"}),(0,a.jsxs)("span",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"block text-sm truncate",children:e}),n&&(0,a.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:n})]})]})}var aa=e.i(250226);function ar({workspaceId:e,channel:t,agents:n,allChannels:s,onDeleted:o}){let d=(0,l.useTranslations)("chat"),c=(0,l.useTranslations)("common"),{updateChannel:p,deleteChannel:x}=(0,i.useChannelStore)(),[h,g]=(0,r.useState)(!1),[f,v]=(0,r.useState)(!1),[j,b]=(0,r.useState)(""),[N,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(!1),S=n.filter(e=>!1!==e.enabled),M=S.map(e=>({id:e.id,label:(0,sT.getAgentDisplayName)(e),description:e.role})),I=async()=>{await x(e,t.id),C(!1),aa.useMobilePanelStore.getState().setActivePanel("channel-list"),o?.()};return(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 h-12 border-b shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:["agent"===t.type?(0,a.jsx)(s8.Bot,{className:"size-4 text-muted-foreground shrink-0"}):"issue"===t.type?(0,a.jsx)(s7.AlertCircle,{className:"size-4 text-muted-foreground shrink-0"}):(0,a.jsx)(s9.Hash,{className:"size-4 text-muted-foreground shrink-0"}),(0,a.jsxs)("span",{className:"text-sm font-medium truncate",children:["#",t.name]})]})}),(0,a.jsxs)(nR.Tabs,{defaultValue:"info",className:"flex flex-col flex-1 min-h-0",children:[(0,a.jsxs)(nR.TabsList,{className:"w-full rounded-none border-b bg-transparent h-9 p-0 shrink-0",children:[(0,a.jsxs)(nR.TabsTrigger,{value:"info",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,a.jsx)(s3.Info,{className:"size-3.5"}),d("channel.info")]}),(0,a.jsxs)(nR.TabsTrigger,{value:"members",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,a.jsx)(ae.Users,{className:"size-3.5"}),d("channel.members")]})]}),(0,a.jsxs)(nD.ScrollArea,{className:"flex-1 min-h-0",children:[(0,a.jsxs)(nR.TabsContent,{value:"info",className:"p-4 mt-0 space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-muted",children:"agent"===t.type?(0,a.jsx)(s8.Bot,{className:"size-5 text-muted-foreground"}):"issue"===t.type?(0,a.jsx)(s7.AlertCircle,{className:"size-5 text-muted-foreground"}):(0,a.jsx)(s9.Hash,{className:"size-5 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:["#",t.name]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d("channel.type")," ",d(`channel.${t.type}`)]})]}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>g(!0),children:(0,a.jsx)(u.Pencil,{className:"size-3.5"})})]}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:d("channel.channelId")}),(0,a.jsxs)("span",{className:"font-mono text-xs",children:[t.id.slice(0,8),"..."]})]}),(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:d("channel.memberCount")}),(0,a.jsx)("span",{children:t.members.length})]}),(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:d("channel.createdAt")}),(0,a.jsx)("span",{children:new Date(t.createdAt).toLocaleDateString()})]})]})]}),(0,a.jsxs)(nR.TabsContent,{value:"members",className:"p-4 mt-0 space-y-1",children:[0===t.members.length&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:d("channel.noMembers")}),t.members.map(e=>(0,a.jsx)(as,{name:(0,sT.getMemberDisplayName)(S,e),agentId:"user"!==e?e:void 0,description:"user"!==e?e:void 0,onClick:()=>{b(e),v(!0)}},e)),(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",className:"w-full mt-2 text-xs text-muted-foreground",onClick:()=>k(!0),children:[(0,a.jsx)(at.UserPlus,{className:"size-3.5 mr-1"}),d("channel.addMember")]})]})]})]}),(0,a.jsx)("div",{className:"shrink-0 p-3 border-t",children:(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",className:"w-full text-xs text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>C(!0),children:[(0,a.jsx)(m.Trash2,{className:"size-3.5 mr-1"}),d("channel.delete")]})}),(0,a.jsx)(an.ChannelDialog,{open:h,onOpenChange:g,workspaceId:e,channel:t,agents:n,onSubmit:n=>p(e,t.id,{...n,members:(0,sT.normalizeChannelMembersToAgentIds)(S,n.members)})}),(0,a.jsx)(T,{open:f,onOpenChange:v,memberName:j,displayName:(0,sT.getMemberDisplayName)(S,j),channelId:t.id,workspaceId:e,channels:s.filter(e=>e.members.includes(j)).map(e=>e.name)}),(0,a.jsx)(sS.AddMemberDialog,{open:N,onOpenChange:k,candidates:M,defaultSelected:t.members,onAdd:n=>{p(e,t.id,{members:(0,sT.normalizeChannelMembersToAgentIds)(S,n)})}}),(0,a.jsx)(y.Dialog,{open:w,onOpenChange:C,children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:d("channel.delete")}),(0,a.jsx)(y.DialogDescription,{children:d("channel.deleteConfirm")})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:c("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:I,children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),c("delete")]})]})]})})]})}var al=e.i(249673),ai=e.i(650654);function ao({messages:e,reverse:t}){var n;let s,l,i,[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),[p,x]=(0,r.useState)(0),h=(0,r.useRef)(null),g=t?[...e].reverse():e,f=(0,r.useCallback)(e=>{c(e);let t=document.getElementById(`msg-${g[e].id}`);t?.scrollIntoView({behavior:"smooth",block:"center"})},[g]),v=(0,r.useCallback)((e,t)=>{if(!t||!h.current)return;c(e);let n=h.current.getBoundingClientRect(),s=t.getBoundingClientRect();x(s.top-n.top+s.height/2)},[]);return 0===g.length?null:(0,a.jsxs)("div",{ref:h,className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 flex flex-col items-center",onMouseEnter:()=>m(!0),onMouseLeave:()=>{m(!1),c(null)},children:[(0,a.jsx)("button",{className:`flex-shrink-0 mb-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${u?"opacity-100":"opacity-0 pointer-events-none"} ${null===d||d<=0?"invisible":""}`,onClick:()=>{null!==d&&d>0&&f(d-1)},children:(0,a.jsx)(al.ChevronUp,{className:"size-3.5"})}),(0,a.jsx)("div",{className:"flex-1 w-full max-h-[70vh] overflow-y-auto scrollbar-none",children:(0,a.jsx)("div",{className:"flex flex-col gap-[3px] px-1 py-0.5",children:g.map((e,t)=>(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("button",{className:`h-[4px] rounded-full transition-all duration-150 ${d===t?"bg-primary w-6":"user"===e.senderId?"bg-primary/30 hover:bg-primary/50 w-5":"bg-muted-foreground/25 hover:bg-muted-foreground/40 w-5"}`,onClick:()=>f(t),onMouseEnter:e=>v(t,e.currentTarget)})},e.id))})}),(0,a.jsx)("button",{className:`flex-shrink-0 mt-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${u?"opacity-100":"opacity-0 pointer-events-none"} ${null===d||d>=g.length-1?"invisible":""}`,onClick:()=>{null!==d&&d<g.length-1&&f(d+1)},children:(0,a.jsx)(ai.ChevronDown,{className:"size-3.5"})}),u&&null!==d&&(0,a.jsxs)("div",{className:"absolute right-full mr-3 w-56 rounded-lg border bg-popover p-2.5 shadow-lg z-50 animate-in fade-in-0 zoom-in-95 duration-75",style:{top:p,transform:"translateY(-50%)"},children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,a.jsx)("span",{className:"font-medium text-xs",children:"user"===g[d].senderId?"You":(0,o.findAgentById)(g[d].senderId)?.name??g[d].senderId}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(g[d].createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3 leading-relaxed",children:(n=g[d],l=(s=n.parts?.find(e=>"text"===e.type))?s.text:n.content,(i=/<[a-z][\s\S]*>/i.test(l)?l.replace(/<[^>]*>/g,""):l).length>150?i.slice(0,150)+"...":i)})]})]})}var ad=e.i(636288),ac=e.i(327964);let au={general:{status:"online"},issue:{status:"degraded"},agent:{status:"maintenance"}};function am({members:e}){let t=e.filter(e=>"user"!==e).slice(0,4),n=e.length-t.length-!!e.includes("user");return(0,a.jsxs)(ad.AvatarGroup,{className:"ml-1 [&>[data-slot=avatar]]:size-5",children:[t.map(e=>(0,a.jsx)(N.AgentIcon,{agentId:e,className:"size-5 rounded-full"},e)),n>0&&(0,a.jsxs)(ad.AvatarGroupCount,{className:"!size-5 text-[10px]",children:["+",n]})]})}function ap({question:e,onAnswer:t}){let n=(0,l.useTranslations)("chat"),[s,i]=(0,r.useState)(""),[o,d]=(0,r.useState)(!1),c=e=>{let n=e.trim();n&&!o&&(d(!0),t(n),i(""))};return(0,a.jsx)("div",{className:"border-t bg-background px-4 py-3",children:(0,a.jsx)("div",{className:"rounded-md border bg-muted/30 p-3",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(s2.default,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:e.question}),e.choices.length>0?(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.choices.map(e=>(0,a.jsx)(eE.Button,{type:"button",size:"sm",variant:"outline",disabled:o,onClick:()=>c(e),className:"h-8",children:e},e))}):null,(0,a.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),c(s)},children:[(0,a.jsx)(sQ.Input,{value:s,onChange:e=>i(e.target.value),disabled:o,className:"h-8 text-sm",placeholder:n("pendingQuestion.placeholder")}),(0,a.jsx)(eE.Button,{type:"submit",size:"icon-sm",disabled:!s.trim()||o,children:(0,a.jsx)(s5.default,{className:"size-3.5"})})]})]})]})})})}e.s(["ChatPanel",0,function({workspaceId:e}){let t=(0,l.useTranslations)("chat"),n=(0,l.useTranslations)("common"),{activeChannelId:s,channels:c,messages:u,loadMessages:p,loadChannelState:x,sendMessage:h,addMessage:g,updateMessage:f,stopProcessingMessages:v,deleteMessage:j,clearMessages:b,upsertChannel:N}=(0,i.useChannelStore)(),k=(0,r.useRef)(null),[w,C]=(0,r.useState)(!1),[S,T]=(0,r.useState)(null),[M,I]=(0,r.useState)(!1),[z,D]=(0,r.useState)(null),[R,P]=(0,r.useState)(!1),[A,O]=(0,r.useState)(!1),E=(0,r.useRef)(null),$=(0,o.useAgentStore)(e=>e.agents),L=(0,o.useAgentStore)(e=>e.ensure),U=c.find(e=>e.id===s),B=(0,r.useMemo)(()=>s&&u[s]||[],[s,u]),F=B[B.length-1]?.status,W=(0,r.useMemo)(()=>(function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if("waiting_for_user"!==n.status)continue;let s=n.parts?.find(e=>"ask_user_question"===e.type&&"answered"!==e.status);if(s&&"ask_user_question"===s.type)return{messageId:n.id,questionId:s.id,question:s.question,choices:s.choices??[]}}return null})(B),[B]),_=(0,r.useMemo)(()=>{if(!U)return[];let e=new Map($.filter(e=>!1!==e.enabled).map(e=>[e.id,e]));return U.members.map(t=>e.get(t)).filter(e=>!!e)},[$,U]);(0,r.useEffect)(()=>{s&&(O(!1),P(!0),p(e,s).finally(()=>P(!1))),L()},[s,e,p,L]),(0,r.useEffect)(()=>{let t=(0,d.getWS)(e),n=t.on("channel.message",e=>{e.channelId===s&&g(e.channelId,e)}),a=t.on("channel.message.updated",e=>{e.channelId===s&&f(e.channelId,e)}),r=t.on("channel.message.deleted",e=>{e.channelId===s&&j(e.channelId,e.messageId)}),l=t.on("channel.messages.cleared",e=>{e.channelId===s&&i.useChannelStore.setState(e=>({messages:{...e.messages,[s]:[]}}))}),o=t.on("channel.updated",e=>{e.id===s&&N(e)});return()=>{n(),a(),r(),l(),o()}},[e,s,g,f,j,N]),(0,r.useEffect)(()=>{let e=k.current?.parentElement;e&&(e.scrollTop=0)},[B.length]),(0,r.useEffect)(()=>{if(!s||!e||!(F&&["pending","streaming","waiting_for_user"].includes(F)||A))return;let t=!1,n=async()=>{let n=await x(e,s);!t&&n&&(O(n.active),await p(e,s))},a=setInterval(n,3e3);return n(),()=>{t=!0,clearInterval(a)}},[s,e,A,F,p,x]);let H=(0,r.useCallback)((t,n,a,r)=>{s&&h(e,s,t,n,a,r)},[e,s,h]),q=A||B.length>0&&["pending","streaming","waiting_for_user"].includes(B[B.length-1].status??""),V=(0,r.useCallback)(()=>{s&&(v(s),(0,d.getWS)(e).send("channel.stop",{channelId:s}))},[e,s,v]),G=(0,r.useCallback)(e=>{E.current?.setContent(e.content,_)},[_]),K=(0,r.useCallback)(e=>{T(e)},[]),J=(0,r.useCallback)(e=>{let t="user"===e.senderId?void 0:$.find(t=>t.id===e.senderId);D({id:e.id,label:"user"===e.senderId?n("you"):t?.name||e.senderId}),E.current?.focus?.()},[$,n]),Q=(0,r.useCallback)(async()=>{S&&(await fetch(`/api/workspaces/${e}/channels/${S.channelId}/messages/${S.id}`,{method:"DELETE"}),T(null))},[e,S]);if(!U)return(0,a.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("emptyState")});let X=(()=>{let e=au[U.type];if(0===B.length)return{label:t("status.idle"),status:"degraded"};let n=B[B.length-1].status;if("waiting_for_user"===n)return{label:t("status.waitingForUser"),status:"degraded"};if("streaming"===n||"pending"===n)return{label:t("status.running"),status:"maintenance"};if("completed"===n)return{label:t("status.success"),status:"online"};if("error"===n){let e=B.slice(-3);return e.length>=3&&e.every(e=>"error"===e.status)?{label:t("status.error"),status:"offline"}:{label:t("status.running"),status:"degraded"}}return{label:t(`channelType.${U.type}`),status:e.status}})();return(0,a.jsxs)("div",{className:"flex h-full",children:[(0,a.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b",children:[(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",className:"md:hidden shrink-0",onClick:()=>aa.useMobilePanelStore.getState().setActivePanel("channel-list"),children:(0,a.jsx)(s1.ArrowLeft,{className:"size-4"})}),(0,a.jsxs)("span",{className:"text-sm font-semibold truncate shrink min-w-0",children:["# ",U.name]}),(0,a.jsxs)(sY,{status:X.status,children:[(0,a.jsx)(sZ,{}),(0,a.jsx)(s0,{children:X.label})]}),(0,a.jsx)(am,{members:U.members}),(0,a.jsx)("div",{className:"flex-1"}),U.issueId&&(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>ac.useIssueStore.getState().setActiveIssue(U.issueId),title:t("viewRelatedIssue"),children:(0,a.jsx)(s4.ExternalLink,{className:"size-4"})}),B.length>0&&(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>I(!0),children:(0,a.jsx)(m.Trash2,{className:"size-4"})}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>C(!0),children:(0,a.jsx)(s3.Info,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,a.jsxs)("div",{className:"h-full overflow-y-auto overflow-x-hidden py-2",children:[R&&0===B.length?(0,a.jsx)("div",{className:"space-y-4 px-4",children:Array.from({length:4},(e,t)=>(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)(sX.Skeleton,{className:"size-6 rounded-full shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(sX.Skeleton,{className:"h-4 w-20"}),(0,a.jsx)(sX.Skeleton,{className:"h-3 w-12"})]}),(0,a.jsx)(sX.Skeleton,{className:"h-4 w-full"}),(0,a.jsx)(sX.Skeleton,{className:"h-4 w-3/4"})]})]},t))}):null,!R&&[...B].reverse().map(t=>(0,a.jsx)("div",{id:`msg-${t.id}`,children:(0,a.jsx)(se,{message:t,workspaceId:e,onEdit:G,onDelete:K,onReply:J})},t.id)),(0,a.jsx)("div",{ref:k})]}),(0,a.jsx)(ao,{messages:B,reverse:!0})]}),W?(0,a.jsx)(ap,{question:W,onAnswer:t=>{(0,d.getWS)(e).send("channel.answer_question",{channelId:U.id,messageId:W.messageId,questionId:W.questionId,answer:t})}}):null,(0,a.jsx)(sJ,{ref:E,channelName:U.name,channelId:U.id,workspaceId:e,channel:U,agents:_,messages:B,onSend:H,isProcessing:q,onStop:V,replyTo:z,onCancelReply:()=>D(null)})]}),(0,a.jsx)(s6.Sheet,{open:w,onOpenChange:C,children:(0,a.jsxs)(s6.SheetContent,{side:"right",className:"w-80 p-0 gap-0",children:[(0,a.jsxs)(s6.SheetHeader,{className:"sr-only",children:[(0,a.jsx)(s6.SheetTitle,{children:U.name}),(0,a.jsx)(s6.SheetDescription,{children:"Channel info panel"})]}),(0,a.jsx)(ar,{workspaceId:e,channel:U,agents:$,allChannels:c,onDeleted:()=>C(!1)})]})}),(0,a.jsx)(y.Dialog,{open:!!S,onOpenChange:e=>{e||T(null)},children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:t("deleteMessage.title")}),(0,a.jsx)(y.DialogDescription,{children:t("deleteMessage.description")})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:n("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:Q,children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),n("delete")]})]})]})}),(0,a.jsx)(y.Dialog,{open:M,onOpenChange:I,children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:t("clearMessages.title")}),(0,a.jsx)(y.DialogDescription,{children:t("clearMessages.description",{channel:U?.name})})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:n("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:async()=>{U&&await b(e,U.id),I(!1)},children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),t("clearMessages.confirm")]})]})]})})]})}],885761)},773354,e=>{e.n(e.i(885761))}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,386041,t=>{"use strict";let e=(0,t.i(433721).default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);t.s(["Code2",0,e],386041)},835829,t=>{"use strict";function e(t){return`agent-spaces:inspector-history:${t}`}function s(t){try{var s;return s=JSON.parse(localStorage.getItem(e(t))||"[]"),Array.isArray(s)?s.filter(t=>t&&"object"==typeof t&&"string"==typeof t.path&&"number"==typeof t.line).map(t=>({...t,column:"number"==typeof t.column?t.column:1,timestamp:"number"==typeof t.timestamp?t.timestamp:Date.now()})).slice(0,50):[]}catch{return[]}}function i(t,s){localStorage.setItem(e(t),JSON.stringify(s.slice(0,50)))}let a=(0,t.i(816709).create)(t=>({histories:{},loadHistory:e=>{let i=s(e);t(t=>({histories:{...t.histories,[e]:i}}))},addEntry:(e,a)=>{let r={...a,id:a.id??`${a.timestamp}-${Math.random().toString(36).slice(2,8)}`,column:a.column??1,timestamp:a.timestamp??Date.now()},o=s(e).filter(t=>t.path!==r.path||t.line!==r.line||t.column!==r.column),n=[r,...o].slice(0,50);i(e,n),t(t=>({histories:{...t.histories,[e]:n}}))},setHistory:(e,s)=>{i(e,s),t(t=>({histories:{...t.histories,[e]:s}}))},clearHistory:e=>{i(e,[]),t(t=>({histories:{...t.histories,[e]:[]}}))}}));t.s(["useInspectorHistoryStore",0,a])},194228,t=>{"use strict";let e=(0,t.i(433721).default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);t.s(["GitCommitHorizontal",0,e],194228)},253307,t=>{"use strict";let e=(0,t.i(433721).default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);t.s(["FileDiff",0,e],253307)},363156,t=>{"use strict";var e=t.i(816709);let s=/not a git repository/i;function i(t){return t instanceof Error&&s.test(t.message)}let a=(0,e.create)(t=>({status:null,diffs:[],selectedFile:null,log:[],branches:[],loading:!1,error:null,notGitRepo:!1,loadStatus:async e=>{try{let s=await fetch(`/api/workspaces/${e}/git/status`);if(!s.ok)throw Error(await s.text());let i=await s.json();t({status:i,notGitRepo:!1})}catch(e){t({error:e instanceof Error?e.message:String(e),notGitRepo:i(e)})}},loadDiffs:async(e,s)=>{t({loading:!0});try{let i=s?`/api/workspaces/${e}/git/diff?path=${encodeURIComponent(s)}`:`/api/workspaces/${e}/git/diff`,a=await fetch(i);if(!a.ok)throw Error(await a.text());let r=await a.json();t({diffs:r,loading:!1,notGitRepo:!1})}catch(e){t({error:e instanceof Error?e.message:String(e),loading:!1,notGitRepo:i(e)})}},loadLog:async e=>{try{let s=await fetch(`/api/workspaces/${e}/git/log`);if(!s.ok)throw Error(await s.text());let i=await s.json();t({log:i,notGitRepo:!1})}catch(e){t({error:e instanceof Error?e.message:String(e),notGitRepo:i(e)})}},loadBranches:async e=>{try{let s=await fetch(`/api/workspaces/${e}/git/branches`);if(!s.ok)throw Error(await s.text());let i=await s.json();t({branches:i,notGitRepo:!1})}catch(e){t({error:e instanceof Error?e.message:String(e),notGitRepo:i(e)})}},initRepo:async e=>{try{let s=await fetch(`/api/workspaces/${e}/git/init`,{method:"POST"});if(!s.ok)throw Error(await s.text());t({error:null,notGitRepo:!1})}catch(e){t({error:e instanceof Error?e.message:String(e)})}},commit:async(e,s)=>{try{let t=await fetch(`/api/workspaces/${e}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:s})});if(!t.ok)throw Error(await t.text())}catch(e){t({error:e instanceof Error?e.message:String(e)})}},discard:async(e,s)=>{try{let t=await fetch(`/api/workspaces/${e}/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s})});if(!t.ok)throw Error(await t.text())}catch(e){t({error:e instanceof Error?e.message:String(e)})}},discardAll:async e=>{try{let t=await fetch(`/api/workspaces/${e}/git/discard-all`,{method:"POST"});if(!t.ok)throw Error(await t.text())}catch(e){t({error:e instanceof Error?e.message:String(e)})}},checkout:async(e,s)=>{try{let t=await fetch(`/api/workspaces/${e}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:s})});if(!t.ok)throw Error(await t.text())}catch(e){t({error:e instanceof Error?e.message:String(e)})}},push:async t=>{let e=await fetch(`/api/workspaces/${t}/git/push`,{method:"POST"});if(!e.ok)throw Error((await e.json().catch(()=>({error:"Push failed"}))).error)},pull:async t=>{let e=await fetch(`/api/workspaces/${t}/git/pull`,{method:"POST"});if(!e.ok)throw Error((await e.json().catch(()=>({error:"Pull failed"}))).error)},getRemotes:async t=>{let e=await fetch(`/api/workspaces/${t}/git/remotes`);if(!e.ok)throw Error(await e.text());return e.json()},addRemote:async(t,e,s)=>{let i=await fetch(`/api/workspaces/${t}/git/remotes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,url:s})});if(!i.ok)throw Error((await i.json().catch(()=>({error:"Failed to add remote"}))).error)},selectFile:e=>t({selectedFile:e}),checkoutDetached:async(t,e)=>{let s=await fetch(`/api/workspaces/${t}/git/checkout-detached`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:e})});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error)},cherryPick:async(t,e)=>{let s=await fetch(`/api/workspaces/${t}/git/cherry-pick`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:e})});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error)},createBranch:async(t,e,s)=>{let i=await fetch(`/api/workspaces/${t}/git/create-branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,startPoint:s})});if(!i.ok)throw Error((await i.json().catch(()=>({}))).error)},deleteBranch:async(t,e,s)=>{let i=await fetch(`/api/workspaces/${t}/git/delete-branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,force:s})});if(!i.ok)throw Error((await i.json().catch(()=>({}))).error)},createTag:async(t,e,s)=>{let i=await fetch(`/api/workspaces/${t}/git/create-tag`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,commitHash:s})});if(!i.ok)throw Error((await i.json().catch(()=>({}))).error)},getCommitDiff:async(t,e)=>{let s=await fetch(`/api/workspaces/${t}/git/commit-diff?hash=${encodeURIComponent(e)}`);if(!s.ok)throw Error((await s.json().catch(()=>({}))).error);return s.json()},getRemoteUrl:async t=>{let e=await fetch(`/api/workspaces/${t}/git/remote-url`);if(!e.ok)throw Error((await e.json().catch(()=>({}))).error);return(await e.json()).url},getMergeBase:async t=>{let e=await fetch(`/api/workspaces/${t}/git/merge-base`);if(!e.ok)throw Error((await e.json().catch(()=>({}))).error);return(await e.json()).hash}}));t.s(["useGitStore",0,a])},524360,t=>{"use strict";var e=t.i(816709),s=t.i(360112);let i=new Map,a=(0,e.create)((t,e)=>({sessions:[],activeId:null,ws:null,workspaceId:null,_initialized:!1,_restored:!1,init:(a,r)=>{let o=e();if(o._initialized&&o.ws===a)return;let n=o.workspaceId!==a.workspaceId;n&&i.clear(),t({ws:a,workspaceId:a.workspaceId,sessions:n?[]:o.sessions,activeId:n?null:o.activeId,_initialized:!0,_restored:!1}),a.on("terminal.created",e=>{let{sessionId:s,cwd:i,shell:a}=e;t(t=>t.sessions.some(t=>t.id===s)?t:{sessions:[...t.sessions,{id:s,cwd:i,shell:a}],activeId:s})}),a.on("terminal.error",t=>{let{error:e}=t;s.toast.error(e)}),a.on("terminal.closed",e=>{let{sessionId:s}=e;t(t=>{let e=t.sessions.filter(t=>t.id!==s),i=t.activeId===s?e[0]?.id??null:t.activeId;return{sessions:e,activeId:i}})}),a.on("terminal.sessions",e=>{let{sessions:s}=e;t(t=>{let e=new Map(t.sessions.map(t=>[t.id,t])),a=s.map(t=>{let s=e.get(t.sessionId);return t.buffer&&i.set(t.sessionId,t.buffer),{...s,id:t.sessionId,cwd:t.cwd,shell:t.shell??s?.shell}}),r=!!t.activeId&&a.some(e=>e.id===t.activeId);for(let t of s)t.buffer||i.delete(t.sessionId);return{sessions:a,activeId:r?t.activeId:a[0]?.id??null,_restored:!0}}),r?.()})},createSession:(t,s)=>{let{ws:i}=e();i?.send("terminal.create",{sessionId:crypto.randomUUID?.()??crypto.getRandomValues(new Uint8Array(16)).reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),shell:t,cwd:s})},setActive:e=>t({activeId:e}),setSessionName:(e,s)=>t(t=>({sessions:t.sessions.map(t=>t.id===e?{...t,name:s}:t)})),removeSession:s=>{let{ws:i,sessions:a,activeId:r}=e();i?.send("terminal.close",{sessionId:s});let o=a.filter(t=>t.id!==s),n=r===s?o[0]?.id??null:r;t({sessions:o,activeId:n})},sendInput:(t,s)=>{e().ws?.send("terminal.input",{sessionId:t,data:s})},resize:(t,s,i)=>{e().ws?.send("terminal.resize",{sessionId:t,cols:s,rows:i})}}));t.s(["consumeSessionBuffer",0,function(t){let e=i.get(t);return i.delete(t),e},"useTerminalStore",0,a])},191441,t=>{"use strict";let e=(0,t.i(433721).default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);t.s(["ListChecks",0,e],191441)},404175,t=>{"use strict";var e=t.i(344180),s=t.i(227634),i=t.i(191441),a=t.i(451534),r=t.i(386041),o=t.i(426022),n=t.i(989484);let c=(0,t.i(433721).default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);var l=t.i(253307),h=t.i(194228),d=t.i(210),p=t.i(255742);let u=[{id:"channel-list",icon:s.Hash,group:"channel"},{id:"chat",icon:o.MessageSquare,group:"channel"},{id:"issue-list",icon:i.ListChecks,group:"issue"},{id:"issue-detail",icon:l.FileDiff,group:"issue"},{id:"workfolder",icon:a.FolderOpen,group:"workfolder"},{id:"code-editor",icon:r.Code2,group:"workfolder"},{id:"terminal",icon:c,group:"tools"},{id:"git-commits",icon:h.GitCommitHorizontal,group:"git"},{id:"project-settings",icon:d.Settings2,group:"settings"},{id:"code-favorites",icon:p.Star,group:"workfolder"}],m={"channel-list":(0,e.jsx)(s.Hash,{size:16}),"issue-list":(0,e.jsx)(i.ListChecks,{size:16}),workfolder:(0,e.jsx)(a.FolderOpen,{size:16}),"code-editor":(0,e.jsx)(r.Code2,{size:16}),chat:(0,e.jsx)(o.MessageSquare,{size:16}),"issue-detail":(0,e.jsx)(n.FileText,{size:16}),terminal:(0,e.jsx)(c,{size:16}),"git-commits":(0,e.jsx)(h.GitCommitHorizontal,{size:16}),"project-settings":(0,e.jsx)(d.Settings2,{size:16}),"code-favorites":(0,e.jsx)(p.Star,{size:16}),...{}};function f(t,s,i,a,r){if("git-commits"===t&&s&&!s.clean){let t=s.insertions>0||s.deletions>0,i=(0,e.jsx)("span",{className:"ml-1 text-[10px] font-medium leading-none flex items-center gap-0.5",children:t?(0,e.jsxs)(e.Fragment,{children:[s.insertions>0&&(0,e.jsxs)("span",{className:"text-green-600",children:["+",s.insertions]}),s.deletions>0&&(0,e.jsxs)("span",{className:"text-red-500",children:["-",s.deletions]})]}):(0,e.jsx)("span",{className:"text-orange-500",children:s.files.length})}),a=s.files.length;return{trailing:i,badge:a>0?(0,e.jsx)("span",{className:"absolute -top-1 -right-1.5 min-w-[14px] h-[14px] rounded-full bg-blue-500 text-white text-[9px] font-medium leading-none flex items-center justify-center px-0.5",children:a}):null}}if("terminal"===t&&i.length>0)return{trailing:null,badge:(0,e.jsx)("span",{className:"absolute -top-1 -right-1.5 min-w-[14px] h-[14px] rounded-full bg-green-500 text-white text-[9px] font-medium leading-none flex items-center justify-center px-0.5",children:i.length})};let o=(0,e.jsxs)("span",{className:"absolute -top-1 -right-1 flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]});return"channel-list"===t&&Object.values(a).some(t=>t.some(t=>"streaming"===t.status||"pending"===t.status))||"issue-detail"===t&&r.some(t=>"pending"===t.status||"running"===t.status||"retrying"===t.status||"waiting_review"===t.status)?{trailing:null,badge:o}:{trailing:null,badge:null}}t.s(["RIGHT_TO_LEFT_TAB_MAP",0,{"code-editor":"workfolder",chat:"channel-list","issue-detail":"issue-list"},"TAB_ITEMS",0,u,"getTabBadge",0,f,"renderTabIcon",0,function(t,s,i,a,r,o){let n=m[t];if(!n)return null;let{trailing:c,badge:l}=f(t,i,a,r,o);return(0,e.jsxs)("span",{title:s,className:"flex items-center justify-center",children:[(0,e.jsxs)("span",{className:"relative",children:[n,l]}),c]})}],404175)},202411,t=>{t.v(e=>Promise.all(["static/chunks/0cyq~8xb~r5fc.js","static/chunks/09t62a89~jesc.js"].map(e=>t.l(e))).then(()=>e(388576)))},136450,t=>{t.v(e=>Promise.all(["static/chunks/0xoo17yef_b8g.js","static/chunks/15hca2.5le07..js","static/chunks/0lcc9r.o.p.sc.js","static/chunks/12mxlicp247c8.js","static/chunks/016xz2o-hv3am.js","static/chunks/0bbmx45w_h5np.js","static/chunks/014x2qbuiszni.js","static/chunks/0kof5qdg8c2-k.js","static/chunks/0.006.ycpe92w.js","static/chunks/0ow~co9wcleka.js","static/chunks/05psi2gtx~bev.js","static/chunks/0_8dm7bxp18xo.js","static/chunks/0-~4vw4_9z_0_.js","static/chunks/0-utii~i2fncd.js","static/chunks/0tl6o7zu1j1r-.css","static/chunks/0ay4fv-nniykh.css","static/chunks/0pldvk5_h__t7.css","static/chunks/08.u~dmq20cak.css","static/chunks/15rf3~h7sugz4.css","static/chunks/0-wkj-hzh444r.css","static/chunks/14_y_s_5rhsd1.css","static/chunks/0z8ipjj2z-3al.css","static/chunks/06vadtvw631k5.css","static/chunks/16~udgv7eel6a.css","static/chunks/0qad.lgvtlt0b.css","static/chunks/0mt-7av8yrg0o.css","static/chunks/0brrgp3ki5w4_.css","static/chunks/16i87txo0qh0h.css","static/chunks/0ojcao3hdm36s.css"].map(e=>t.l(e))).then(()=>e(538691)))},58872,t=>{t.v(e=>Promise.all(["static/chunks/0_udc.6.tueey.js","static/chunks/02c22g~xd-y30.js","static/chunks/17oc2l.ekcs8b.css"].map(e=>t.l(e))).then(()=>e(608745)))},329052,t=>{t.v(e=>Promise.all(["static/chunks/0p1n8bvfnpl41.js"].map(e=>t.l(e))).then(()=>e(878166)))},126861,t=>{t.v(e=>Promise.all(["static/chunks/0_e~hmntdfop9.js","static/chunks/0s_dva~eh2yhi.js","static/chunks/0cke33d38fnby.js","static/chunks/12mxlicp247c8.js"].map(e=>t.l(e))).then(()=>e(773354)))},124383,t=>{t.v(e=>Promise.all(["static/chunks/11qp8r5dotf7d.js"].map(e=>t.l(e))).then(()=>e(783481)))},318599,t=>{t.v(e=>Promise.all(["static/chunks/10.alq.6stmld.js","static/chunks/0zmhdridea1s5.js","static/chunks/0msb2mi3hiu5_.js"].map(e=>t.l(e))).then(()=>e(706304)))},222445,t=>{t.v(e=>Promise.all(["static/chunks/0zc0xgp5ourcn.js","static/chunks/11b3zgk1etlkw.js"].map(e=>t.l(e))).then(()=>e(514669)))},78906,t=>{t.v(e=>Promise.all(["static/chunks/176dc-dtokxxi.js"].map(e=>t.l(e))).then(()=>e(985646)))},857328,t=>{t.v(e=>Promise.all(["static/chunks/0xt-8wk21gs7g.js"].map(e=>t.l(e))).then(()=>e(306649)))},3725,t=>{t.v(e=>Promise.all(["static/chunks/0-f~0xmwl__u5.js"].map(e=>t.l(e))).then(()=>e(722705)))}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,905724,e=>{"use strict";let t=(0,e.i(433721).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);e.s(["default",0,t])},989484,e=>{"use strict";var t=e.i(905724);e.s(["FileText",()=>t.default])},799543,(e,t,s)=>{t.exports=e.r(233331)},767467,e=>{"use strict";let t=(0,e.i(433721).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["ArrowLeft",0,t],767467)},977694,e=>{"use strict";let t=(0,e.i(433721).default)("rocket",[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]]);e.s(["Rocket",0,t],977694)},401058,e=>{"use strict";let t=(0,e.i(433721).default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);e.s(["MoreVertical",0,t],401058)},239340,e=>{"use strict";var t=e.i(344180),s=e.i(209988),n=e.i(260218),i=e.i(611176),a=e.i(972846),r=e.i(465458);e.s(["AgentPickerDialog",0,function({open:e,onClose:o,onConfirm:l,title:c,description:d,agents:u,selected:p,onToggle:m,cancelText:f,confirmText:x,loading:g}){return(0,t.jsx)(s.Dialog,{open:e,onOpenChange:e=>{e||o()},children:(0,t.jsxs)(s.DialogContent,{className:"sm:max-w-sm flex flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)(s.DialogHeader,{className:"shrink-0 px-6 py-4",children:[(0,t.jsx)(s.DialogTitle,{children:c}),d&&(0,t.jsx)(s.DialogDescription,{children:d})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 pb-2 overflow-y-auto px-6 space-y-3",children:[(0,t.jsx)("div",{className:"space-y-0.5",children:u.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>m(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(i.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.name}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:(0,r.cn)("flex items-center justify-center size-4 rounded border shrink-0",p.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input")})]},e.id))}),p.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:p.map(e=>{let s=u.find(t=>t.id===e);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:[(0,t.jsx)(i.AgentIcon,{agentId:e,name:s?.name,avatarUrl:s?.avatarUrl,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s?.name||e}),(0,t.jsx)("button",{type:"button",onClick:()=>m(e),className:"hover:text-destructive shrink-0",children:(0,t.jsx)(a.X,{className:"size-3"})})]},e)})})]}),(0,t.jsxs)("div",{className:"shrink-0 flex justify-end gap-2 border-t px-6 py-4",children:[(0,t.jsx)(n.Button,{variant:"outline",onClick:o,children:f||"Cancel"}),(0,t.jsx)(n.Button,{onClick:l,disabled:g||0===p.length,children:x||"Confirm"})]})]})})}])},144988,e=>{"use strict";let t=(0,e.i(433721).default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);e.s(["default",0,t])},193251,e=>{"use strict";let t=(0,e.i(433721).default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);e.s(["Download",0,t],193251)},984178,e=>{"use strict";var t=e.i(144988);e.s(["FileIcon",()=>t.default])},513501,e=>{"use strict";let t=(0,e.i(433721).default)("store",[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]);e.s(["Store",0,t],513501)},996652,e=>{"use strict";var t,s=e.i(344180);e.s([],739605),e.i(739605);var n=e.i(764556),i=e.i(166392),a=e.i(538501),r=e.i(427396),o=e.i(974578),l=e.i(389124),c=e.i(107164);e.i(8890);var d=e.i(267805);let u=n.createContext(void 0);function p(e){let t=n.useContext(u);if(void 0===t&&!e)throw Error((0,d.default)(47));return t}var m=e.i(106206),f=e.i(493696),x=e.i(332976),g=e.i(232449),h=e.i(549154),v=e.i(130522),j=e.i(742665),S=e.i(695011),y=e.i(561213),b=e.i(576487);let C={...S.popupStoreSelectors,disabled:(0,x.createSelector)(e=>e.disabled),instantType:(0,x.createSelector)(e=>e.instantType),openMethod:(0,x.createSelector)(e=>e.openMethod),openChangeReason:(0,x.createSelector)(e=>e.openChangeReason),modal:(0,x.createSelector)(e=>e.modal),focusManagerModal:(0,x.createSelector)(e=>e.focusManagerModal),stickIfOpen:(0,x.createSelector)(e=>e.stickIfOpen),titleElementId:(0,x.createSelector)(e=>e.titleElementId),descriptionElementId:(0,x.createSelector)(e=>e.descriptionElementId),openOnHover:(0,x.createSelector)(e=>e.openOnHover),closeDelay:(0,x.createSelector)(e=>e.closeDelay),hasViewport:(0,x.createSelector)(e=>e.hasViewport)};class N extends f.ReactStore{constructor(e){const t={...(0,S.createInitialPopupStoreState)(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1,...e};t.open&&e?.mounted===void 0&&(t.mounted=!0),super(t,{popupRef:n.createRef(),backdropRef:n.createRef(),internalBackdropRef:n.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:n.createRef(),beforeContentFocusGuardRef:n.createRef(),stickIfOpenTimeout:new g.Timeout,triggerElements:new y.PopupTriggerMap},C)}setOpen=(e,t)=>{let s=t.reason===j.REASONS.triggerHover,n=t.reason===j.REASONS.triggerPress&&0===t.event.detail,i=!e&&(t.reason===j.REASONS.escapeKey||null==t.reason);if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let a=()=>{let s={open:e,openChangeReason:t.reason},n=t.trigger?.id??null;(n||e)&&(s.activeTriggerId=n,s.activeTriggerElement=t.trigger??null),this.update(s)};s?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(b.PATIENT_CLICK_THRESHOLD,()=>{this.set("stickIfOpen",!1)}),m.flushSync(a)):a(),n||i?this.set("instantType",n?"click":"dismiss"):t.reason===j.REASONS.focusOut?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(e,t){let s=(0,h.useRefWithInit)(()=>new N(t)).current,n=e??s;return(0,v.useOnMount)(s.disposeEffect),n}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}var w=e.i(602453),k=e.i(279501),R=e.i(564846);function T({props:e}){let{children:t,open:d,defaultOpen:p=!1,onOpenChange:m,onOpenChangeComplete:f,modal:x=!1,handle:g,triggerId:h,defaultTriggerId:v=null}=e,S=N.useStore(g?.store,{modal:x,open:p,openProp:d,activeTriggerId:v,triggerIdProp:h});(0,i.useOnFirstRender)(()=>{void 0===d&&!1===S.state.open&&!0===p&&S.update({open:!0,activeTriggerId:v})}),S.useControlledProp("openProp",d),S.useControlledProp("triggerIdProp",h);let y=S.useState("open"),b=S.useState("payload");S.useContextCallback("onOpenChange",m),S.useContextCallback("onOpenChangeComplete",f);let{openMethod:C,triggerProps:O}=(0,R.useOpenInteractionType)(y);(0,k.useImplicitActiveTrigger)(S);let{forceUnmount:E}=(0,k.useOpenStateTransitions)(y,S,()=>{S.update({stickIfOpen:!0,openChangeReason:null})});n.useEffect(()=>{y||S.context.stickIfOpenTimeout.clear()},[S,y]);let I=n.useCallback(()=>{S.setOpen(!1,(0,w.createChangeEventDetails)(j.REASONS.imperativeAction))},[S]);n.useImperativeHandle(e.actionsRef,()=>({unmount:E,close:I}),[E,I]);let M=(0,c.useSyncedFloatingRootContext)({popupStore:S,onOpenChange:S.setOpen}),P=(0,a.useDismiss)(M,{outsidePressEvent:{mouse:"trap-focus"===x?"sloppy":"intentional",touch:"sloppy"}}),D=(0,o.useRole)(M),{getReferenceProps:F,getFloatingProps:A,getTriggerProps:z}=(0,r.useInteractions)([P,D]),H=n.useMemo(()=>F(O),[F,O]),L=n.useMemo(()=>z(O),[z,O]),B=n.useMemo(()=>A(),[A]);S.useSyncedValues({modal:x,openMethod:C,activeTriggerProps:H,inactiveTriggerProps:L,popupProps:B,floatingRootContext:M,nested:null!=(0,l.useFloatingParentNodeId)()});let U=n.useMemo(()=>({store:S}),[S]);return(0,s.jsx)(u.Provider,{value:U,children:"function"==typeof t?t({payload:b}):t})}var O=e.i(931709),E=e.i(817955),I=e.i(969490),M=e.i(499198),P=e.i(934940),D=e.i(480283),F=e.i(139236),A=e.i(601957),z=e.i(660079);let H=n.forwardRef(function(e,t){let{render:i,className:a,disabled:o=!1,nativeButton:l=!0,handle:c,payload:u,openOnHover:m=!1,delay:f=300,closeDelay:x=0,id:g,style:h,...v}=e,S=p(!0),y=c?.store??S?.store;if(!y)throw Error((0,d.default)(74));let C=(0,F.useBaseUiId)(g),N=y.useState("isTriggerActive",C),w=y.useState("floatingRootContext"),R=y.useState("isOpenedByTrigger",C),T=n.useRef(null),{registerTrigger:H,isMountedByThisTrigger:L}=(0,k.useTriggerDataForwarding)(C,T,y,{payload:u,disabled:o,openOnHover:m,closeDelay:x}),B=y.useState("openChangeReason"),U=y.useState("stickIfOpen"),V=y.useState("openMethod"),$=y.useState("focusManagerModal"),G=(0,D.useHoverReferenceInteraction)(w,{enabled:null!=w&&m&&("touch"!==V||B!==j.REASONS.triggerPress),mouseOnly:!0,move:!1,handleClose:(0,M.safePolygon)(),restMs:f,delay:{close:x},triggerElementRef:T,isActiveTrigger:N,isClosing:()=>"ending"===y.select("transitionStatus")}),K=(0,P.useClick)(w,{enabled:null!=w,stickIfOpen:U}),_=(0,r.useInteractions)([K]),W=y.useState("triggerProps",L),{getButtonProps:J,buttonRef:q}=(0,O.useButton)({disabled:o,native:l}),X=n.useMemo(()=>({open:e=>e&&B===j.REASONS.triggerPress?E.pressableTriggerOpenStateMapping.open(e):E.triggerOpenStateMapping.open(e)}),[B]),Y=(0,I.useRenderElement)("button",e,{state:{disabled:o,open:R},ref:[q,t,H,T],props:[_.getReferenceProps(),G,W,{[b.CLICK_TRIGGER_IDENTIFIER]:"",id:C},v,J],stateAttributesMapping:X}),{preFocusGuardRef:Q,handlePreFocusGuardFocus:Z,handleFocusTargetFocus:ee}=(0,z.useTriggerFocusGuards)(y,T);return N&&!$?(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(A.FocusGuard,{ref:Q,onFocus:Z}),(0,s.jsx)(n.Fragment,{children:Y},C),(0,s.jsx)(A.FocusGuard,{ref:y.context.triggerFocusTargetRef,onFocus:ee})]}):(0,s.jsx)(n.Fragment,{children:Y},C)});var L=e.i(128108);let B=n.createContext(void 0),U=n.forwardRef(function(e,t){let{keepMounted:n=!1,...i}=e,{store:a}=p();return a.useState("mounted")||n?(0,s.jsx)(B.Provider,{value:n,children:(0,s.jsx)(L.FloatingPortal,{ref:t,...i})}):null});var V=e.i(677822),$=e.i(277642);let G=n.createContext(void 0);function K(){let e=n.useContext(G);if(!e)throw Error((0,d.default)(46));return e}var _=e.i(576557),W=e.i(251817),J=e.i(427708),q=e.i(909852),X=e.i(263635),Y=e.i(900587);let Q=n.forwardRef(function(e,t){let{render:i,className:a,anchor:r,positionMethod:o="absolute",side:c="bottom",align:u="center",sideOffset:m=0,alignOffset:f=0,collisionBoundary:x="clipping-ancestors",collisionPadding:g=5,arrowPadding:h=5,sticky:v=!1,disableAnchorTracking:S=!1,collisionAvoidance:y=b.POPUP_COLLISION_AVOIDANCE,style:C,...N}=e,{store:w}=p(),k=function(){let e=n.useContext(B);if(void 0===e)throw Error((0,d.default)(45));return e}(),R=(0,l.useFloatingNodeId)(),T=w.useState("floatingRootContext"),O=w.useState("mounted"),E=w.useState("open"),I=w.useState("openChangeReason"),M=w.useState("activeTriggerElement"),P=w.useState("modal"),D=w.useState("openMethod"),F=w.useState("positionerElement"),A=w.useState("instantType"),z=w.useState("transitionStatus"),H=w.useState("hasViewport"),L=n.useRef(null),U=(0,J.useAnimationsFinished)(F,!1,!1),K=(0,_.useAnchorPositioning)({anchor:r,floatingRootContext:T,positionMethod:o,mounted:O,side:c,sideOffset:m,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:x,collisionPadding:g,sticky:v,disableAnchorTracking:S,keepMounted:k,nodeId:R,collisionAvoidance:y,adaptiveOrigin:H?q.adaptiveOrigin:void 0}),Q=T.useState("domReferenceElement");(0,$.useIsoLayoutEffect)(()=>{let e=L.current;if(Q&&(L.current=Q),e&&Q&&Q!==e){w.set("instantType",void 0);let e=new AbortController;return U(()=>{w.set("instantType","trigger-change")},e.signal),()=>{e.abort()}}},[Q,U,w]);let Z={open:E,side:K.side,align:K.align,anchorHidden:K.anchorHidden,instant:A};(0,Y.useAnchoredPopupScrollLock)(E&&!0===P&&I!==j.REASONS.triggerHover,"touch"===D,F,M);let ee=n.useCallback(e=>{w.set("positionerElement",e)},[w]),et=(0,X.usePositioner)(e,Z,{styles:K.positionerStyles,transitionStatus:z,props:N,refs:[t,ee],hidden:!O,inert:!E});return(0,s.jsxs)(G.Provider,{value:K,children:[O&&!0===P&&I!==j.REASONS.triggerHover&&(0,s.jsx)(W.InternalBackdrop,{ref:w.context.internalBackdropRef,inert:(0,V.inertValue)(!E),cutout:M}),(0,s.jsx)(l.FloatingNode,{id:R,children:et})]})});var Z=e.i(92615),ee=e.i(583289),et=e.i(795914),es=e.i(282458),en=e.i(273598),ei=e.i(100229),ea=e.i(971109),er=e.i(328657),eo=e.i(29905);let el=n.createContext(void 0);function ec(e){let{value:t,children:n}=e;return(0,s.jsx)(el.Provider,{value:t,children:n})}let ed={...E.popupStateMapping,...es.transitionStatusMapping},eu=n.forwardRef(function(e,t){let{className:i,render:a,initialFocus:r,finalFocus:o,style:l,...c}=e,{store:d}=p(),u=K(),m=null!=(0,ea.useToolbarRootContext)(!0),{context:f,hasClosePart:x}=function(){let[e,t]=n.useState(0),s=(0,eo.useStableCallback)(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:n.useMemo(()=>({register:s}),[s]),hasClosePart:e>0}}(),g=d.useState("open"),h=d.useState("openMethod"),v=d.useState("instantType"),S=d.useState("transitionStatus"),y=d.useState("popupProps"),b=d.useState("titleElementId"),C=d.useState("descriptionElementId"),N=d.useState("modal"),w=d.useState("mounted"),k=d.useState("openChangeReason"),R=d.useState("activeTriggerElement"),T=d.useState("floatingRootContext");(0,en.useOpenChangeComplete)({open:g,ref:d.context.popupRef,onComplete(){g&&d.context.onOpenChangeComplete?.(!0)}});let O=d.useState("disabled"),E=d.useState("openOnHover"),M=d.useState("closeDelay");(0,et.useHoverFloatingInteraction)(T,{enabled:E&&!O,closeDelay:M});let P=void 0===r?function(e){return"touch"!==e||d.context.popupRef.current}:r,D={open:g,side:u.side,align:u.align,instant:v,transitionStatus:S},F=!1!==N&&x;d.useSyncedValue("focusManagerModal",F);let A=n.useCallback(e=>{d.set("popupElement",e)},[d]),z=(0,I.useRenderElement)("div",e,{state:D,ref:[t,d.context.popupRef,A],props:[y,{"aria-labelledby":b,"aria-describedby":C,onKeyDown(e){m&&ei.COMPOSITE_KEYS.has(e.key)&&e.stopPropagation()}},(0,er.getDisabledMountTransitionStyles)(S),c],stateAttributesMapping:ed});return(0,s.jsx)(ee.FloatingFocusManager,{context:T,openInteractionType:h,modal:F,disabled:!w||k===j.REASONS.triggerHover,initialFocus:P,returnFocus:o,restoreFocus:"popup",previousFocusableElement:(0,Z.isHTMLElement)(R)?R:void 0,nextFocusableElement:d.context.triggerFocusTargetRef,beforeContentFocusGuardRef:d.context.beforeContentFocusGuardRef,children:(0,s.jsx)(ec,{value:f,children:z})})}),ep=n.forwardRef(function(e,t){let{className:s,render:n,style:i,...a}=e,{store:r}=p(),o=r.useState("open"),{arrowRef:l,side:c,align:d,arrowUncentered:u,arrowStyles:m}=K();return(0,I.useRenderElement)("div",e,{state:{open:o,side:c,align:d,uncentered:u},ref:[t,l],props:[{style:m,"aria-hidden":!0},a],stateAttributesMapping:E.popupStateMapping})}),em={...E.popupStateMapping,...es.transitionStatusMapping},ef=n.forwardRef(function(e,t){let{className:s,render:n,style:i,...a}=e,{store:r}=p(),o=r.useState("open"),l=r.useState("mounted"),c=r.useState("transitionStatus"),d=r.useState("openChangeReason");return(0,I.useRenderElement)("div",e,{state:{open:o,transitionStatus:c},ref:[r.context.backdropRef,t],props:[{role:"presentation",hidden:!l,style:{pointerEvents:d===j.REASONS.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},a],stateAttributesMapping:em})}),ex=n.forwardRef(function(e,t){let{render:s,className:n,style:i,...a}=e,{store:r}=p(),o=(0,F.useBaseUiId)(a.id);return(0,$.useIsoLayoutEffect)(()=>(r.set("titleElementId",o),()=>{r.set("titleElementId",void 0)}),[r,o]),(0,I.useRenderElement)("h2",e,{ref:t,props:[{id:o},a]})}),eg=n.forwardRef(function(e,t){let{render:s,className:n,style:i,...a}=e,{store:r}=p(),o=(0,F.useBaseUiId)(a.id);return(0,$.useIsoLayoutEffect)(()=>(r.set("descriptionElementId",o),()=>{r.set("descriptionElementId",void 0)}),[r,o]),(0,I.useRenderElement)("p",e,{ref:t,props:[{id:o},a]})}),eh=n.forwardRef(function(e,t){let s,{render:i,className:a,disabled:r=!1,nativeButton:o=!0,style:l,...c}=e,{buttonRef:d,getButtonProps:u}=(0,O.useButton)({disabled:r,focusableWhenDisabled:!1,native:o}),{store:m}=p();return s=n.useContext(el),(0,$.useIsoLayoutEffect)(()=>s?.register(),[s]),(0,I.useRenderElement)("button",e,{ref:[t,d],props:[{onClick(e){m.setOpen(!1,(0,w.createChangeEventDetails)(j.REASONS.closePress,e.nativeEvent,e.currentTarget))}},c,u]})}),ev=((t={}).popupWidth="--popup-width",t.popupHeight="--popup-height",t);var ej=e.i(3310);let eS={activationDirection:e=>e?{"data-activation-direction":e}:null},ey=n.forwardRef(function(e,t){let{render:s,className:n,style:i,children:a,...r}=e,{store:o}=p(),{side:l}=K(),c=o.useState("instantType"),{children:d,state:u}=(0,ej.usePopupViewport)({store:o,side:l,cssVars:ev,children:a}),m={activationDirection:u.activationDirection,transitioning:u.transitioning,instant:c};return(0,I.useRenderElement)("div",e,{state:m,ref:t,props:[r,{children:d}],stateAttributesMapping:eS})});class eb{constructor(){this.store=new N}open(e){let t=e?this.store.context.triggerElements.getById(e)??void 0:void 0;if(e&&!t)throw Error((0,d.default)(80,e));this.store.setOpen(!0,(0,w.createChangeEventDetails)(j.REASONS.imperativeAction,void 0,t))}close(){this.store.setOpen(!1,(0,w.createChangeEventDetails)(j.REASONS.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,ep,"Backdrop",0,ef,"Close",0,eh,"Description",0,eg,"Handle",0,eb,"Popup",0,eu,"Portal",0,U,"Positioner",0,Q,"Root",0,function(e){return p(!0)?(0,s.jsx)(T,{props:e}):(0,s.jsx)(l.FloatingTree,{children:(0,s.jsx)(T,{props:e})})},"Title",0,ex,"Trigger",0,H,"Viewport",0,ey,"createHandle",0,function(){return new eb}],631858);var eC=e.i(631858),eC=eC,eN=e.i(465458);e.s(["Popover",0,function({...e}){return(0,s.jsx)(eC.Root,{"data-slot":"popover",...e})},"PopoverContent",0,function({className:e,align:t="center",alignOffset:n=0,side:i="bottom",sideOffset:a=4,...r}){return(0,s.jsx)(eC.Portal,{children:(0,s.jsx)(eC.Positioner,{align:t,alignOffset:n,side:i,sideOffset:a,className:"isolate z-50",children:(0,s.jsx)(eC.Popup,{"data-slot":"popover-content",className:(0,eN.cn)("z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...r})})})},"PopoverTrigger",0,function({...e}){return(0,s.jsx)(eC.Trigger,{"data-slot":"popover-trigger",...e})}],996652)},750012,e=>{"use strict";let t=(0,e.i(433721).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);e.s(["default",0,t])},887354,e=>{"use strict";var t=e.i(750012);e.s(["Search",()=>t.default])},460578,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(898822),i=e.i(129981),a=e.i(972846),r=e.i(984178),o=e.i(465458);let l=0;e.s(["FileUpload",0,function({value:e=[],onChange:c,accept:d,maxFiles:u=0,maxSize:p,disabled:m=!1,className:f,placeholder:x}){let[g,h]=(0,s.useState)(null),v=(0,s.useCallback)((t,s)=>{if(h(null),s.length>0){let e=s[0].errors[0]?.message;e&&h(e)}if(0===t.length)return;let n=t.map(e=>{let t={id:`upload-${++l}`,file:e};return e.type.startsWith("image/")&&(t.preview=URL.createObjectURL(e)),t}),i=u>0?[...e,...n].slice(0,u):[...e,...n];c?.(i)},[e,c,u]),j=(0,s.useCallback)(t=>{let s=e.find(e=>e.id===t);s?.preview&&URL.revokeObjectURL(s.preview),c?.(e.filter(e=>e.id!==t))},[e,c]),{getRootProps:S,getInputProps:y,isDragActive:b}=(0,n.useDropzone)({onDrop:v,accept:d,maxFiles:u||void 0,maxSize:p,disabled:m,noClick:!1});return(0,t.jsxs)("div",{className:(0,o.cn)("space-y-3",f),children:[(0,t.jsxs)("div",{...S(),className:(0,o.cn)("relative flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed px-6 py-8 transition-colors cursor-pointer",b?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50",m&&"pointer-events-none opacity-50"),children:[(0,t.jsx)("input",{...y()}),(0,t.jsx)(i.Upload,{className:"size-8 text-muted-foreground"}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:x??(b?"松开即可上传":"拖拽文件到此处,或点击选择")}),!b&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["支持多文件",p?`,单文件最大 ${(p/1024/1024).toFixed(0)}MB`:""]})]})]}),g&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:g}),e.length>0&&(0,t.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{var s;return(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 overflow-hidden",children:[e.preview?(0,t.jsx)("img",{src:e.preview,alt:"",className:"size-10 rounded-md object-cover"}):(0,t.jsx)("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted",children:(0,t.jsx)(r.FileIcon,{className:"size-5 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm",children:e.file.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:(s=e.file.size)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(1)} MB`})]}),(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),j(e.id)},className:"flex size-7 items-center justify-center rounded-md hover:bg-accent transition-colors",children:(0,t.jsx)(a.X,{className:"size-4 text-muted-foreground"})})]},e.id)})})]})}])},756638,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(244073),i=e.i(887836),a=e.i(209988),r=e.i(260218),o=e.i(681622),l=e.i(191118),c=e.i(239340),d=e.i(460578),u=e.i(996652),p=e.i(917955),m=e.i(887354),f=e.i(401058),x=e.i(137340),g=e.i(977694),h=e.i(111343),v=e.i(953700),j=e.i(426022),S=e.i(129981),y=e.i(193251),b=e.i(513501),C=e.i(989484);let N=(0,i.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["PromptsDialog",0,function({open:e,onOpenChange:i,standalone:w}){let k=(0,n.useTranslations)("prompts"),R=(0,n.useTranslations)("common"),[T,O]=(0,s.useState)("local"),[E,I]=(0,s.useState)([]),[M,P]=(0,s.useState)([]),[D,F]=(0,s.useState)(!1),[A,z]=(0,s.useState)(""),[H,L]=(0,s.useState)([]),[B,U]=(0,s.useState)(!1),[V,$]=(0,s.useState)(new Set),[G,K]=(0,s.useState)(!1),[_,W]=(0,s.useState)([]),[J,q]=(0,s.useState)(null),[X,Y]=(0,s.useState)([]),[Q,Z]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(null),[es,en]=(0,s.useState)(!1),[ei,ea]=(0,s.useState)(""),[er,eo]=(0,s.useState)(""),[el,ec]=(0,s.useState)(!1),ed=(0,s.useCallback)(async()=>{F(!0);try{let e=await fetch("/api/prompt-templates");e.ok&&I(await e.json())}catch{}F(!1)},[]),eu=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/prompt-templates/agents");e.ok&&P(await e.json())}catch{}},[]),ep=(0,s.useCallback)(async()=>{U(!0);try{let e=await fetch("/public/prompt/index.json");e.ok&&L(await e.json())}catch{}U(!1)},[]);(0,s.useEffect)(()=>{(e||w)&&(ed(),eu(),ep())},[e,w,ed,eu,ep]);let em=new Set(E.filter(e=>e.storeId).map(e=>e.storeId)),ef=async()=>{if(0!==_.length){if(1===_.length){let e=await _[0].file.text(),t=_[0].file.name.replace(/\.(md|txt|markdown)$/i,"");W([]),K(!1),et(null),en(!0),ea(t),eo(e);return}for(let e of _){let t=await e.file.text(),s=e.file.name.replace(/\.(md|txt|markdown)$/i,"");await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,content:t})})}W([]),K(!1),ed()}},ex=async e=>{if(!(em.has(e.id)||V.has(e.id))){$(t=>new Set(t).add(e.id));try{let t=await fetch(`/public/prompt/${e.filename}`);if(!t.ok)return;let s=await t.text(),n=await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,content:s,storeId:e.id})});if(n.ok){let e=await n.json();I(t=>[...t,e])}}catch{}$(t=>{let s=new Set(t);return s.delete(e.id),s})}},eg=()=>{et(null),en(!1),ea(""),eo("")},eh=async()=>{if(ei.trim()&&er.trim()){ec(!0);try{if(ee){let e=await fetch(`/api/prompt-templates/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ei,content:er})});if(e.ok){let t=await e.json();I(e=>e.map(e=>e.id===t.id?t:e)),eg()}}else{let e=await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ei,content:er})});if(e.ok){let t=await e.json();I(e=>[...e,t]),eg()}}}catch{}ec(!1)}},ev=async e=>{try{(await fetch(`/api/prompt-templates/${e.id}`,{method:"DELETE"})).ok&&I(t=>t.filter(t=>t.id!==e.id))}catch{}},ej=async()=>{if(J&&0!==X.length){Z(!0);try{await fetch(`/api/prompt-templates/${J.id}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:X})}),q(null)}catch{}Z(!1)}},eS=E.filter(e=>{if(!A)return!0;let t=A.toLowerCase();return e.name.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),ey=H.filter(e=>{if(!A)return!0;let t=A.toLowerCase();return e.name.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)}),eb=(w||e)&&!J&&!ee&&!es,eC=M.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})),eN=(0,t.jsx)("div",{className:"flex items-center gap-1 border-b border-border px-1",children:[["local",C.FileText,k("tabLocal")],["store",b.Store,k("tabStore")]].map(([e,s,n])=>(0,t.jsxs)("button",{onClick:()=>O(e),className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${T===e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[(0,t.jsx)(s,{className:"size-3.5"}),n]},e))}),ew=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto shrink-0 pt-2",children:[(0,t.jsxs)(u.Popover,{open:G,onOpenChange:K,children:[(0,t.jsx)(u.PopoverTrigger,{render:(0,t.jsxs)(r.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(S.Upload,{className:"size-3.5 mr-1"}),k("import")]})}),(0,t.jsx)(u.PopoverContent,{className:"w-80",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:k("importTitle")}),(0,t.jsx)(d.FileUpload,{value:_,onChange:W,accept:{"text/markdown":[".md",".txt"],"":[".md",".txt"]},placeholder:k("importPlaceholder"),maxFiles:10}),(0,t.jsx)(r.Button,{size:"sm",onClick:ef,disabled:0===_.length,className:"w-full",children:k("importConfirm")})]})})]}),(0,t.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:()=>{et(null),en(!0),ea(""),eo("")},children:[(0,t.jsx)(v.Plus,{className:"size-3.5 mr-1"}),k("create")]})]}),(0,t.jsx)(l.ScrollArea,{className:"flex-1",children:D?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:R("loading")}):0===eS.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:k("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:eS.map(e=>(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{et(e),en(!1),ea(e.name),eo(e.content)},children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(j.MessageSquare,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(r.Button,{variant:"outline",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>{q(e),Y([])},children:[(0,t.jsx)(g.Rocket,{className:"size-3 mr-0.5"}),k("apply")]}),(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{render:(0,t.jsx)(r.Button,{variant:"ghost",size:"icon",className:"size-6"}),children:(0,t.jsx)(f.MoreVertical,{className:"size-3"})}),(0,t.jsx)(p.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(p.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ev(e),children:[(0,t.jsx)(x.Trash2,{className:"size-3 mr-1.5"}),k("delete")]})})]})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3",children:e.content.slice(0,200).replace(/^#\s+/,"")})]})},e.id))})})]}),ek=(0,t.jsx)(l.ScrollArea,{className:"flex-1",children:B?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:R("loading")}):0===ey.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:k("storeEmpty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:ey.map(e=>{let s=em.has(e.id),n=V.has(e.id);return(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(b.Store,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsx)(r.Button,{variant:s?"ghost":"outline",size:"sm",className:"h-6 px-1.5 text-xs shrink-0",disabled:s||n,onClick:()=>ex(e),children:s?(0,t.jsx)(t.Fragment,{children:k("imported")}):n?(0,t.jsx)(t.Fragment,{children:k("importing")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y.Download,{className:"size-3 mr-0.5"}),k("importTo")]})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.id})]})},e.id)})})}),eR=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.DialogHeader,{children:(0,t.jsx)("div",{className:"flex items-center justify-between pr-8",children:(0,t.jsxs)("div",{className:"hidden md:block",children:[w?(0,t.jsx)("h2",{className:"text-base font-semibold",children:k("title")}):(0,t.jsx)(a.DialogTitle,{children:k("title")}),w?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:k("description")}):(0,t.jsx)(a.DialogDescription,{children:k("description")})]})})}),eN,(0,t.jsx)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(m.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(o.Input,{value:A,onChange:e=>z(e.target.value),placeholder:k("search"),className:"pl-8"})]}),"local"===T?ew:ek]})})]});return(0,t.jsxs)(t.Fragment,{children:[w&&eb&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:eR}),!w&&(0,t.jsx)(a.Dialog,{open:eb,onOpenChange:i,children:(0,t.jsx)(a.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:eR})}),(0,t.jsx)(a.Dialog,{open:!!ee||es,onOpenChange:e=>{e||eg()},children:(0,t.jsxs)(a.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(a.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(a.DialogTitle,{children:ee?k("editTitle",{name:ee.name}):k("createTitle")}),(0,t.jsx)(a.DialogDescription,{children:k("editDescription")})]}),(0,t.jsxs)(r.Button,{size:"sm",onClick:eh,disabled:el||!ei.trim()||!er.trim(),children:[(0,t.jsx)(h.Save,{className:"size-3.5 mr-1"}),R("save")]})]})}),(0,t.jsx)("div",{className:"space-y-3 pb-2",children:(0,t.jsx)(o.Input,{value:ei,onChange:e=>ea(e.target.value),placeholder:k("namePlaceholder")})}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(N,{height:"100%",language:"markdown",value:er,onChange:e=>eo(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on"}})})]})}),(0,t.jsx)(c.AgentPickerDialog,{open:!!J,onClose:()=>q(null),onConfirm:ej,title:k("applyTitle",{name:J?.name||""}),description:k("applyDescription"),agents:eC,selected:X,onToggle:e=>Y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),cancelText:R("cancel"),confirmText:k("applyConfirm",{count:X.length}),loading:Q})]})}])}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,940361,e=>{"use strict";var t=e.i(344180);e.s([],2365),e.i(2365);var n=e.i(764556),r=e.i(394822),o=e.i(174465),i=e.i(648224),a=e.i(35359);e.i(8890);var s=e.i(422561),u=e.i(526850),l=e.i(232449),c=e.i(410421),d=e.i(150129),f=e.i(969490),m=e.i(602453),g=e.i(817955),x=e.i(742665),h=e.i(87709);let p=n.forwardRef(function(e,t){let{render:r,className:i,style:p,...v}=e,{setAnchor:b,actionsRef:M,internalBackdropRef:R,backdropRef:j,positionerRef:w,allowMouseUpTriggerRef:y,initialCursorPointRef:C,rootId:S}=(0,o.useContextMenuRootContext)(!1),{store:k}=(0,a.useMenuRootContext)(!1),I=k.useState("open"),T=k.useState("disabled"),N=n.useRef(null),L=n.useRef(null),P=(0,l.useTimeout)(),A=(0,l.useTimeout)(),E=n.useRef(!1);function O(e,t,n){let r=n.type.startsWith("touch");C.current={x:e,y:t},b({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!r,height:10*!!r,x:e,y:t})}),E.current=!1,M.current?.setOpen(!0,(0,m.createChangeEventDetails)(x.REASONS.triggerPress,n)),A.start(500,()=>{E.current=!0})}function z(){P.clear(),L.current=null}return n.useEffect(()=>{let e=(0,u.ownerDocument)(N.current);return(0,s.addEventListener)(e,"contextmenu",function(e){if(T)return;let t=(0,c.getTarget)(e);((0,c.contains)(N.current,t)||(0,c.contains)(R.current,t)||(0,c.contains)(j.current,t))&&e.preventDefault()})},[j,T,R]),(0,f.useRenderElement)("div",e,{state:{open:I},ref:[N,t],props:[{onContextMenu:function(e){if(T)return;y.current=!0,(0,d.stopEvent)(e),O(e.clientX,e.clientY,e.nativeEvent);let t=(0,u.ownerDocument)(N.current);(0,s.addEventListener)(t,"mouseup",e=>{if(y.current=!1,!E.current)return;A.clear(),E.current=!1;let t=(0,c.getTarget)(e);(0,c.contains)(w.current,t)||S&&t&&(0,h.findRootOwnerId)(t)===S||M.current?.setOpen(!1,(0,m.createChangeEventDetails)(x.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!T&&(y.current=!1,1===e.touches.length)){e.stopPropagation();let t=e.touches[0];L.current={x:t.clientX,y:t.clientY},P.start(500,()=>{L.current&&O(L.current.x,L.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(P.isStarted()&&L.current&&1===e.touches.length){let t=e.touches[0],n=Math.abs(t.clientX-L.current.x),r=Math.abs(t.clientY-L.current.y);(n>10||r>10)&&P.clear()}},onTouchEnd:z,onTouchCancel:z,style:{WebkitTouchCallout:"none"}},v],stateAttributesMapping:g.pressableTriggerOpenStateMapping})});var v=e.i(487455),b=e.i(293209),M=e.i(503662),R=e.i(33427),j=e.i(324573),w=e.i(582883),y=e.i(277658),C=e.i(349204),S=e.i(28051),k=e.i(597375),I=e.i(81752),T=e.i(59354),N=e.i(300637),L=e.i(281478),P=e.i(65255),A=e.i(327794),E=e.i(362962);e.s(["Arrow",()=>j.MenuArrow,"Backdrop",()=>v.MenuBackdrop,"CheckboxItem",()=>S.MenuCheckboxItem,"CheckboxItemIndicator",()=>k.MenuCheckboxItemIndicator,"Group",()=>w.MenuGroup,"GroupLabel",()=>y.MenuGroupLabel,"Item",()=>C.MenuItem,"LinkItem",()=>I.MenuLinkItem,"Popup",()=>R.MenuPopup,"Portal",()=>b.MenuPortal,"Positioner",()=>M.MenuPositioner,"RadioGroup",()=>T.MenuRadioGroup,"RadioItem",()=>N.MenuRadioItem,"RadioItemIndicator",()=>L.MenuRadioItemIndicator,"Root",0,function(e){let[s,u]=n.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),l=n.useRef(null),c=n.useRef(null),d=n.useRef(null),f=n.useRef(null),m=n.useRef(!0),g=n.useRef(null),x=(0,r.useId)(),h=n.useMemo(()=>({anchor:s,setAnchor:u,actionsRef:d,backdropRef:l,internalBackdropRef:c,positionerRef:f,allowMouseUpTriggerRef:m,initialCursorPointRef:g,rootId:x}),[s,x]);return(0,t.jsx)(o.ContextMenuRootContext.Provider,{value:h,children:(0,t.jsx)(a.MenuRootContext.Provider,{value:void 0,children:(0,t.jsx)(i.Menu.Root,{...e})})})},"Separator",()=>E.Separator,"SubmenuRoot",()=>P.MenuSubmenuRoot,"SubmenuTrigger",()=>A.MenuSubmenuTrigger,"Trigger",0,p],912001);var O=e.i(912001),O=O,z=e.i(465458),D=e.i(932031);function B({className:e,align:n="start",alignOffset:r=4,side:o="right",sideOffset:i=0,...a}){return(0,t.jsx)(O.Portal,{children:(0,t.jsx)(O.Positioner,{className:"isolate z-50 outline-none",align:n,alignOffset:r,side:o,sideOffset:i,children:(0,t.jsx)(O.Popup,{"data-slot":"context-menu-content",className:(0,z.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})})})}e.i(299648),e.s(["ContextMenu",0,function({...e}){return(0,t.jsx)(O.Root,{"data-slot":"context-menu",...e})},"ContextMenuContent",0,B,"ContextMenuItem",0,function({className:e,inset:n,variant:r="default",...o}){return(0,t.jsx)(O.Item,{"data-slot":"context-menu-item","data-inset":n,"data-variant":r,className:(0,z.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...o})},"ContextMenuSeparator",0,function({className:e,...n}){return(0,t.jsx)(O.Separator,{"data-slot":"context-menu-separator",className:(0,z.cn)("-mx-1 my-1 h-px bg-border",e),...n})},"ContextMenuSub",0,function({...e}){return(0,t.jsx)(O.SubmenuRoot,{"data-slot":"context-menu-sub",...e})},"ContextMenuSubContent",0,function({...e}){return(0,t.jsx)(B,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...e})},"ContextMenuSubTrigger",0,function({className:e,inset:n,children:r,...o}){return(0,t.jsxs)(O.SubmenuTrigger,{"data-slot":"context-menu-sub-trigger","data-inset":n,className:(0,z.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[r,(0,t.jsx)(D.ChevronRightIcon,{className:"ml-auto"})]})},"ContextMenuTrigger",0,function({className:e,...n}){return(0,t.jsx)(O.Trigger,{"data-slot":"context-menu-trigger",className:(0,z.cn)("select-none",e),...n})}],940361)},212965,e=>{"use strict";let t=(0,e.i(433721).default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",0,t],212965)},613812,e=>{"use strict";var t=e.i(344180);e.i(462506);var n=e.i(304271),r=e.i(764556),o=e.i(950396),i=e.i(564822),a=e.i(465458);let s=(0,e.i(433721).default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);e.s(["DiffViewer",0,function({oldContent:e,newContent:u,path:l,isBinary:c,compactDiff:d=!0}){let f,m=(f=l.split(".").pop()?.toLowerCase())?({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",html:"html",py:"python",rs:"rust",go:"go",yaml:"yaml",yml:"yaml"})[f]:void 0,g=(0,r.useRef)(null),{resolvedTheme:x}=(0,o.useTheme)(),h=(0,i.useIsMobile)(),[p,v]=(0,r.useState)(d),b=(0,r.useCallback)(e=>{g.current=e},[]);(0,r.useEffect)(()=>()=>{let e=g.current;e&&(e.setModel(null),g.current=null)},[]);let M=(0,r.useMemo)(()=>p?function(e,t){let n=e.split("\n"),r=t.split("\n"),o=n.length,i=r.length;if(e===t||o*i>4e6)return null;let a=Array.from({length:o+1},()=>Array(i+1).fill(0));for(let e=o-1;e>=0;e--)for(let t=i-1;t>=0;t--)n[e]===r[t]?a[e][t]=a[e+1][t+1]+1:a[e][t]=Math.max(a[e+1][t],a[e][t+1]);let s=new Set,u=new Set,l=0,c=0;for(;l<o&&c<i;)n[l]===r[c]?(s.add(l),u.add(c),l++,c++):a[l+1][c]>=a[l][c+1]?l++:c++;let d=new Set,f=new Set;for(let e=0;e<o;e++)if(!s.has(e))for(let t=Math.max(0,e-10);t<=Math.min(o-1,e+10);t++)d.add(t);for(let e=0;e<i;e++)if(!u.has(e))for(let t=Math.max(0,e-10);t<=Math.min(i-1,e+10);t++)f.add(t);function m(e){let t=Array.from(e).sort((e,t)=>e-t);if(0===t.length)return[];let n=[[t[0],t[0]]];for(let e=1;e<t.length;e++){let r=n[n.length-1];t[e]<=r[1]+1?r[1]=t[e]:n.push([t[e],t[e]])}return n}let g=m(d),x=m(f);if(0===g.length&&0===x.length)return null;let h="···";function p(e,t){let n=[];for(let r=0;r<t.length;r++){let[o,i]=t[r];(r>0||o>0)&&n.push(h);for(let t=o;t<=i;t++)n.push(e[t])}return t.length>0&&t[t.length-1][1]<e.length-1&&n.push(h),n}return{oldLines:p(n,g),newLines:p(r,x)}}(e,u):null,[p,e,u]),R=M?M.oldLines.join("\n"):e,j=M?M.newLines.join("\n"):u;return(0,t.jsxs)("div",{className:"h-full w-full flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 border-b bg-muted/30",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:l}),(0,t.jsxs)("button",{onClick:()=>v(e=>!e),className:(0,a.cn)("flex items-center gap-1 text-xs px-1.5 py-0.5 rounded transition-colors",p?"text-blue-600 dark:text-blue-400 bg-blue-500/10":"text-muted-foreground hover:text-foreground"),title:p?"显示全部代码":"只看修改部分",children:[(0,t.jsx)(s,{className:"h-3 w-3"}),p?"紧凑":"全部"]})]}),(0,t.jsx)("div",{className:"flex-1",children:c?(0,t.jsxs)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm gap-2",children:[(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,t.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),"二进制文件,不支持预览"]}):(0,t.jsx)(n.DiffEditor,{original:R,modified:j,language:m,theme:"dark"===x?"vs-dark":"vs",onMount:b,options:{readOnly:!0,renderSideBySide:!h,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on"}})})]})}],613812)}]);
|