@nextclaw/ui 0.13.11-beta.0 → 0.13.11

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/assets/{api-C0F4luAh.js → api-DmxQnm30.js} +1 -1
  3. package/dist/assets/{app-presenter-provider-3K24vYTD.js → app-presenter-provider-CDSjiqfE.js} +1 -1
  4. package/dist/assets/arrow-left-Dd45Mvr1.js +1 -0
  5. package/dist/assets/channels-list-page-bkKDqaO5.js +8 -0
  6. package/dist/assets/chat-page-YKdeGoVx.js +105 -0
  7. package/dist/assets/{config-split-page-bO0K6uQv.js → config-split-page-CdJEkWxv.js} +1 -1
  8. package/dist/assets/{confirm-dialog-a7YIzprP.js → confirm-dialog-BWRNsRgb.js} +1 -1
  9. package/dist/assets/{desktop-update-config-CbJZyLND.js → desktop-update-config-CLXdVz9r.js} +1 -1
  10. package/dist/assets/{dist-T6rf86Nf.js → dist-CyWdaJvr.js} +1 -1
  11. package/dist/assets/{dist-DQoV-62W.js → dist-DzM2ZEVN.js} +1 -1
  12. package/dist/assets/doc-browser-D5FJcAyz.js +1 -0
  13. package/dist/assets/{doc-browser-CTFB6ACN.js → doc-browser-DewXa6oX.js} +1 -1
  14. package/dist/assets/{doc-browser-context-CP2tI-Br.js → doc-browser-context-CpL2m4Sp.js} +1 -1
  15. package/dist/assets/{ellipsis-B7CbNPNr.js → ellipsis-BDgTYNDX.js} +1 -1
  16. package/dist/assets/{es2015-BSPOGpH4.js → es2015-WqekV0OK.js} +1 -1
  17. package/dist/assets/{external-link-CefT35zP.js → external-link-BLjo8z2a.js} +1 -1
  18. package/dist/assets/{index-DBOXf-UA.js → index-DKflQCOL.js} +15 -15
  19. package/dist/assets/index-Q891JiF_.css +1 -0
  20. package/dist/assets/{key-round-BpM3GZn4.js → key-round-Du8x3sWa.js} +1 -1
  21. package/dist/assets/{loader-circle-_edjOFsw.js → loader-circle-Dz4FssYC.js} +1 -1
  22. package/dist/assets/{mcp-marketplace-page-IhNyQ9Hh.js → mcp-marketplace-page-BaBuHB2L.js} +2 -2
  23. package/dist/assets/mcp-marketplace-page-ooEvG_bB.js +1 -0
  24. package/dist/assets/{model-config-Z7oAQmlP.js → model-config-B-qg70S4.js} +1 -1
  25. package/dist/assets/{notice-card-DhE1Fafy.js → notice-card-3a7FmAz-.js} +1 -1
  26. package/dist/assets/play-BziM-Y34.js +1 -0
  27. package/dist/assets/plus-DrpyArC8.js +1 -0
  28. package/dist/assets/{popover-D_pJfOlM.js → popover-BlJLguiZ.js} +1 -1
  29. package/dist/assets/{provider-scoped-model-input-BfhiS3GD.js → provider-scoped-model-input-BgPTQa8H.js} +1 -1
  30. package/dist/assets/providers-list-cBeeslbc.js +1 -0
  31. package/dist/assets/{react-Bl8iJUcF.js → react-BVjl1ZaK.js} +1 -1
  32. package/dist/assets/{refresh-cw-CqfS1EhK.js → refresh-cw-DFR87zei.js} +1 -1
  33. package/dist/assets/remote-DjhVMpVd.js +1 -0
  34. package/dist/assets/rotate-cw-DMBnsYKm.js +1 -0
  35. package/dist/assets/{runtime-config-page-BvLypM3f.js → runtime-config-page-DYH2ejUI.js} +1 -1
  36. package/dist/assets/{save-CQERCODg.js → save-BDmIlHvN.js} +1 -1
  37. package/dist/assets/search-CjHGYvTI.js +1 -0
  38. package/dist/assets/{search-config-mD9kAsXy.js → search-config-BRsrQ4zK.js} +1 -1
  39. package/dist/assets/{secrets-config-Dvd4VEDw.js → secrets-config-eYdx5_AW.js} +2 -2
  40. package/dist/assets/{status-dot-DY0xUUvK.js → status-dot-SVPjIyG5.js} +1 -1
  41. package/dist/assets/{tabs-C77i1w90.js → tabs-Czd2mj6z.js} +1 -1
  42. package/dist/assets/{tabs-custom-CFpR54-m.js → tabs-custom-Ix4nkp2h.js} +1 -1
  43. package/dist/assets/{tag-chip-BFTpu75w.js → tag-chip-Cdwb3JSH.js} +1 -1
  44. package/dist/assets/{tooltip-fs7VQG7d.js → tooltip-CKGxLGnG.js} +1 -1
  45. package/dist/assets/{trash-2-Bb8mTTLl.js → trash-2-yLA8BEcE.js} +1 -1
  46. package/dist/assets/x-dpDISboO.js +1 -0
  47. package/dist/index.html +25 -25
  48. package/package.json +8 -8
  49. package/src/features/chat/components/chat-session-workspace-panel-nav.tsx +86 -64
  50. package/src/features/chat/components/chat-session-workspace-panel.tsx +14 -25
  51. package/src/features/chat/components/conversation/chat-conversation-panel.test.tsx +3 -3
  52. package/src/shared/components/cron-config.tsx +367 -91
  53. package/src/shared/lib/cron/cron-job-view.utils.ts +124 -6
  54. package/src/shared/lib/i18n/README.md +7 -0
  55. package/src/shared/lib/i18n/cron-labels.utils.ts +32 -0
  56. package/src/shared/lib/i18n/index.ts +2 -25
  57. package/dist/assets/arrow-left-CI0Ocu9p.js +0 -1
  58. package/dist/assets/channels-list-page-DT8gjnFw.js +0 -8
  59. package/dist/assets/chat-page-By1I_JyH.js +0 -105
  60. package/dist/assets/doc-browser-yi02ASOL.js +0 -1
  61. package/dist/assets/index-CevK3jug.css +0 -1
  62. package/dist/assets/mcp-marketplace-page-C2O8-sSE.js +0 -1
  63. package/dist/assets/play-DD0bg50i.js +0 -1
  64. package/dist/assets/plus-zZ2GC_AJ.js +0 -1
  65. package/dist/assets/providers-list-DpAMol1o.js +0 -1
  66. package/dist/assets/remote-hKy7hvBh.js +0 -1
  67. package/dist/assets/rotate-cw-C7EvaSlb.js +0 -1
  68. package/dist/assets/search-C0b2yzmt.js +0 -1
  69. package/dist/assets/x-BV4iiea8.js +0 -1
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-yi02ASOL.js","assets/doc-browser-CTFB6ACN.js","assets/react-Bl8iJUcF.js","assets/dist-T6rf86Nf.js","assets/tooltip-fs7VQG7d.js","assets/dist-DQoV-62W.js","assets/arrow-left-CI0Ocu9p.js","assets/external-link-CefT35zP.js","assets/plus-zZ2GC_AJ.js","assets/search-C0b2yzmt.js","assets/x-BV4iiea8.js","assets/doc-browser-context-CP2tI-Br.js","assets/model-config-Z7oAQmlP.js","assets/api-C0F4luAh.js","assets/loader-circle-_edjOFsw.js","assets/provider-scoped-model-input-BfhiS3GD.js","assets/provider-models-C_yOh6DE.js","assets/config-hints-Ceiol9x4.js","assets/chat-page-By1I_JyH.js","assets/app-presenter-provider-3K24vYTD.js","assets/confirm-dialog-a7YIzprP.js","assets/es2015-BSPOGpH4.js","assets/popover-D_pJfOlM.js","assets/key-round-BpM3GZn4.js","assets/refresh-cw-CqfS1EhK.js","assets/trash-2-Bb8mTTLl.js","assets/notice-card-DhE1Fafy.js","assets/status-dot-DY0xUUvK.js","assets/tabs-C77i1w90.js","assets/mcp-marketplace-page-IhNyQ9Hh.js","assets/tag-chip-BFTpu75w.js","assets/ellipsis-B7CbNPNr.js","assets/play-DD0bg50i.js","assets/tabs-custom-CFpR54-m.js","assets/search-config-mD9kAsXy.js","assets/config-split-page-bO0K6uQv.js","assets/providers-list-DpAMol1o.js","assets/channels-list-page-DT8gjnFw.js","assets/runtime-config-page-BvLypM3f.js","assets/rotate-cw-C7EvaSlb.js","assets/save-CQERCODg.js","assets/desktop-update-config-CbJZyLND.js","assets/secrets-config-Dvd4VEDw.js","assets/remote-hKy7hvBh.js","assets/mcp-marketplace-page-C2O8-sSE.js"])))=>i.map(i=>d[i]);
2
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g,y as _}from"./react-Bl8iJUcF.js";import{A as v,C as y,E as b,F as x,I as S,L as C,M as w,N as T,O as E,P as D,S as O,T as k,a as A,c as ee,i as j,j as te,k as M,l as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce,x as le,z as ue}from"./app-presenter-provider-3K24vYTD.js";import{$ as de,At as fe,B as pe,Bt as me,Ct as he,Dt as ge,Et as _e,F as ve,Ft as ye,G as be,H as xe,I as Se,It as Ce,J as we,K as Te,L as Ee,Lt as De,M as Oe,N as ke,Nt as Ae,Ot as je,P as Me,Pt as Ne,Q as Pe,Qt as Fe,R as Ie,Rt as Le,Tt as Re,U as ze,V as Be,Vt as Ve,W as He,X as Ue,Y as We,Z as Ge,Zt as Ke,_ as qe,at as Je,bt as Ye,ct as Xe,d as Ze,dt as Qe,et as $e,f as et,ft as tt,g as nt,gt as rt,h as it,ht as at,kt as ot,lt as st,m as ct,n as lt,ot as ut,p as dt,q as ft,st as pt,t as mt,tt as ht,v as gt,vt as _t,xt as vt,y as yt,yt as bt,z as xt,zt as N}from"./api-C0F4luAh.js";import{_ as St,a as Ct,b as wt,c as P,d as Tt,f as Et,g as Dt,h as Ot,i as kt,l as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,u as It,x as Lt,y as Rt}from"./dist-T6rf86Nf.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./es2015-BSPOGpH4.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-a7YIzprP.js";import{t as Xt}from"./arrow-left-CI0Ocu9p.js";import{n as Zt}from"./doc-browser-CTFB6ACN.js";import{n as Qt,t as $t}from"./loader-circle-_edjOFsw.js";import{a as en,c as tn,i as nn,l as rn,n as an,o as on,r as sn,s as cn,t as ln,u as un}from"./tooltip-fs7VQG7d.js";import{t as dn}from"./external-link-CefT35zP.js";import{t as fn}from"./key-round-BpM3GZn4.js";import{t as pn}from"./plus-zZ2GC_AJ.js";import{t as mn}from"./search-C0b2yzmt.js";import{t as hn}from"./trash-2-Bb8mTTLl.js";import{t as gn}from"./x-BV4iiea8.js";import{a as _n,c as vn,i as yn,n as bn,o as xn,r as Sn,s as Cn,t as wn}from"./popover-D_pJfOlM.js";import{c as Tn,m as En,n as Dn,s as On,t as kn}from"./doc-browser-context-CP2tI-Br.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var An=e((e=>{var t=o();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),jn=P(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),Mn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Nn=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Pn=P(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Fn=P(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),In=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ln=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Rn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),zn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Bn=P(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Vn=P(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Hn=P(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),Un=P(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Wn=P(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Gn=P(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Kn=P(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),qn=P(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Jn=P(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),Yn=P(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),Xn=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Zn=P(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Qn=P(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),$n=P(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),er=P(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tr=P(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),nr=P(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),rr=P(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),ir=P(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ar=P(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),or=P(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),sr=P(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),cr=P(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),lr=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),ur=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),dr=P(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),fr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),pr=P(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),mr=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),hr=P(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gr=P(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),_r=P(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),vr=P(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),yr=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),br=P(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),xr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Sr=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Cr=P(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),wr=P(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Tr=An(),F=_(a(),1);function Er(){let e=Dn();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;En(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}var I=l(),Dr=(0,F.createContext)(null);function Or({children:e}){let[t,r]=(0,F.useState)(()=>n());(0,F.useEffect)(()=>h(e=>{r(e)}),[]);let i=(0,F.useCallback)(e=>{c(e),r(d())},[]),a=(0,F.useCallback)(()=>{i(t===`en`?`zh`:`en`)},[t,i]),o=(0,F.useMemo)(()=>({language:t,setLanguage:i,toggleLanguage:a}),[t,i,a]);return(0,I.jsx)(Dr.Provider,{value:o,children:e})}function kr(){let e=(0,F.useContext)(Dr);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function Ar(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function jr(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:Ar(e),width:e}}var Mr=m(()=>jr()),Nr=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>Mr.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Mr.setState(jr())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Mr.setState({width:e,mode:Ar(e)})}}};function Pr(){return(0,F.useEffect)(()=>Nr.attach(),[]),{isMobile:Mr(e=>e.mode)===`mobile`}}var Fr=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Ir=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Fr.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Fr.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Fr.setState({supported:!0,initialized:!0,busyAction:null}),N.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Fr.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));Fr.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return Fr.setState({supported:!0,initialized:!0,snapshot:n}),N.success(s(`runtimePresenceSaved`)),n}catch(e){throw N.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Fr.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Lr=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){Lr.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Lr.setState({supported:!0,initialized:!0,snapshot:e})}),Lr.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Lr.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Lr.setState({supported:!0,initialized:!0}),N.error(`${s(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,s(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){N.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){N.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){N.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&N.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,s(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&N.success(s(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,s(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,s(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(Lr.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,s(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){N.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}N.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Lr.setState({busyAction:e});try{let e=await n(r);return Lr.setState({snapshot:e}),e}catch(e){throw N.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Lr.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`),this.getChannelLabel=e=>s(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function Rr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function zr(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function Br(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Vr(e){return[{target:`/chat`,label:e(`chat`),icon:lr},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:e(`agentsPageTitle`),icon:Pn},{target:`/settings`,label:e(`settings`),icon:_r}]}function Hr(e){return[{target:`/model`,label:e(`model`),icon:Hn},{target:`/providers`,label:e(`providers`),icon:br},{target:`/channels`,label:e(`channels`),icon:dr},{target:`/search`,label:e(`searchChannels`),icon:mn},{target:`/runtime`,label:e(`runtime`),icon:Hn},{target:`/updates`,label:e(`updates`),icon:Un},{target:`/remote`,label:e(`remote`),icon:wr},{target:`/security`,label:e(`security`),icon:vr},{target:`/secrets`,label:e(`secrets`),icon:fn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:O}]}function Ur(e){return[{target:`/language`,label:e(`language`),icon:cr},...Hr(e)]}function Wr(e){let t=e.toLowerCase();return t===`/settings`?!0:Ur(e=>e).some(e=>Rr(t,e.target))}function Gr(e,t){let n=e.toLowerCase(),r=Ur(t);if(Br(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(Rr(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var Kr=`nextclaw.ui.theme`,qr=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Jr=`warm`,Yr=!1,Xr=new Set;function Zr(e){return e===`warm`||e===`cool`}function Qr(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function $r(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Kr);if(Zr(e))return e}catch{}return`warm`}function ei(){return Yr||=(Jr=$r(),Qr(Jr),!0),Jr}function ti(){return Yr?Jr:ei()}function ni(e){if(ei(),e!==Jr){if(Jr=e,Qr(Jr),typeof window<`u`)try{window.localStorage.setItem(Kr,Jr)}catch{}Xr.forEach(e=>e(Jr))}}function ri(e){return Xr.add(e),()=>{Xr.delete(e)}}function ii(){return Ve({queryKey:[`config`],queryFn:Ee,staleTime:3e4,refetchOnWindowFocus:!0})}function ai(){return Ve({queryKey:[`app-meta`],queryFn:Se,staleTime:1/0})}function oi(){return Ve({queryKey:[`config-meta`],queryFn:Ie,staleTime:1/0})}function si(){return Ve({queryKey:[`providers`],queryFn:ze,staleTime:3e4,refetchOnWindowFocus:!0})}function ci(){return Ve({queryKey:[`provider-templates`],queryFn:xe,staleTime:1/0})}function li(){return Ve({queryKey:[`config-schema`],queryFn:xt,staleTime:1/0})}function ui(){let e=Fe();return me({mutationFn:Ge,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function di(){let e=Fe();return me({mutationFn:({data:e})=>$e(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function fi(){let e=Fe();return me({mutationFn:({provider:e,data:t})=>Pe(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),n.silentSuccess||N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function pi(){let e=Fe();return me({mutationFn:({data:e})=>Oe(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function mi(){let e=Fe();return me({mutationFn:({provider:e})=>Me(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function hi(){return me({mutationFn:({provider:e,data:t})=>We(e,t)})}function gi(){return me({mutationFn:({provider:e,data:t})=>we(e,t)})}function _i(){return me({mutationFn:({provider:e,data:t})=>be(e,t)})}function vi(){return me({mutationFn:({provider:e})=>He(e)})}function yi(){let e=Fe();return me({mutationFn:({channel:e,data:t})=>Ue(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplying`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function bi(){let e=Fe();return me({mutationFn:({data:e})=>de(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function xi(){let e=Fe();return me({mutationFn:({data:e})=>ht(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Si(){return me({mutationFn:({actionId:e,data:t})=>ve(e,t),onError:e=>{N.error(s(`error`)+`: `+e.message)}})}function Ci(e){return Ve({queryKey:[`ncp-sessions`,e?.limit??null,e?.peerId?.trim()||null],queryFn:()=>qe(e),staleTime:5e3,retry:!1})}function wi(e){return Ve({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>nt(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ti(e={all:!0}){return Ve({queryKey:[`cron`,e],queryFn:()=>pe(e),staleTime:1e4})}function Ei(){let e=Fe();return me({mutationFn:({id:e})=>ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Di(){let e=Fe();return me({mutationFn:({id:e,enabled:t})=>ft(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Oi(){let e=Fe();return me({mutationFn:({id:e,force:t})=>Te(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}var ki={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function Ai(){let e=_t(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=()=>{e.tone!==`healthy`&&vt.requestRuntimeBootstrapProbeNow()},i=async()=>{if(t)try{let e=await vt.runRuntimeControlAction(`restart-service`);N.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);N.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(wn,{children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,onClick:n,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,ki[e.tone])})})}),(0,I.jsxs)(bn,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,I.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,I.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s(`runtimeStatusActionHint`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void i(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?s(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function ji({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=ai(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(Ai,{}),l=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,u=t===`chrome`;return(0,I.jsxs)(`div`,{className:r(e??`flex min-w-0 items-center gap-2`,l&&`pl-[58px]`),children:[(0,I.jsx)(`div`,{className:r(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,I.jsx)(`img`,{src:`/logo.svg`,alt:a,className:`h-full w-full object-contain`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:r(`shrink-0 font-semibold text-gray-800`,u?`text-[15px]`:`text-[14px]`),children:a}),s?(0,I.jsx)(Mi,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Ni,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Mi({versionLabel:e,density:t}){let[n,i]=(0,F.useState)(!1);return(0,I.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[(0,I.jsx)(`span`,{tabIndex:0,"aria-label":e,className:r(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,I.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function Ni(){let{supported:e,busyAction:t,snapshot:n}=rt();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Pi,{snapshot:n}):n.status===`downloaded`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void at.applyDownloadedUpdate(),children:s(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void at.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Pi({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Fi,{snapshot:e});let t=e.status===`downloading`?Ii(e):null;return t?(0,I.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:s(`updates`),children:t}):null}function Fi({snapshot:e}){let t=e.status===`failed`?s(`desktopUpdatesStatusFailed`):s(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?s(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
3
- `);return(0,I.jsx)(`span`,{role:`img`,"aria-label":t,title:i,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function Ii(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Li=_(o(),1);function Ri(e,[t,n]){return Math.min(n,Math.max(t,e))}function zi(e){let t=e+`CollectionProvider`,[n,r]=Rt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Nt(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:wt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Nt(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=wt(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Bi=F.createContext(void 0);function Vi(e){let t=F.useContext(Bi);return e||t||`ltr`}function Hi(e){let t=F.useRef({value:e,previous:e});return F.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ui=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Wi=[` `,`Enter`],Gi=`Select`,[Ki,qi,Ji]=zi(Gi),[Yi,Xi]=Rt(Gi,[Ji,Ft]),Zi=Ft(),[Qi,$i]=Yi(Gi),[ea,ta]=Yi(Gi),na=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Zi(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Vi(l),[C,w]=Ot({prop:r,defaultProp:i??!1,onChange:a,caller:Gi}),[T,E]=Ot({prop:o,defaultProp:s,onChange:c,caller:Gi}),D=F.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=F.useState(new Set),ee=Array.from(k).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)(Qi,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Dt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,I.jsx)(Ki.Provider,{scope:t,children:(0,I.jsx)(ea,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,I.jsxs)(Za,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,I.jsx)(`option`,{value:``}):null,Array.from(k)]},ee):null]})})};na.displayName=Gi;var ra=`SelectTrigger`,ia=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Zi(n),o=$i(ra,n),s=o.disabled||r,c=wt(t,o.onTriggerChange),l=qi(n),u=F.useRef(`touch`),[d,f,p]=$a(e=>{let t=l().filter(e=>!e.disabled),n=eo(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,I.jsx)(Pt,{asChild:!0,...a,children:(0,I.jsx)(Et.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Qa(o.value)?``:void 0,...i,ref:c,onClick:Lt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Lt(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Lt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Ui.includes(e.key)&&(m(),e.preventDefault())})})})});ia.displayName=ra;var aa=`SelectValue`,oa=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=$i(aa,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=wt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Et.span,{...s,ref:d,style:{pointerEvents:`none`},children:Qa(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});oa.displayName=aa;var sa=`SelectIcon`,ca=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Et.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ca.displayName=sa;var la=`SelectPortal`,ua=e=>(0,I.jsx)(At,{asChild:!0,...e});ua.displayName=la;var da=`SelectContent`,fa=F.forwardRef((e,t)=>{let n=$i(da,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Li.createPortal((0,I.jsx)(ma,{scope:e.__scopeSelect,children:(0,I.jsx)(Ki.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(va,{...e,ref:t})});fa.displayName=da;var pa=10,[ma,ha]=Yi(da),ga=`SelectContentImpl`,_a=Nt(`SelectContent.RemoveScroll`),va=F.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=$i(da,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=wt(t,e=>b(e)),[w,T]=F.useState(null),[E,D]=F.useState(null),O=qi(n),[k,A]=F.useState(!1),ee=F.useRef(!1);F.useEffect(()=>{if(y)return Ht(y)},[y]),Vt();let j=F.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),te=F.useCallback(()=>j([w,y]),[j,w,y]);F.useEffect(()=>{k&&te()},[k,te]);let{onOpenChange:M,triggerPointerDownPosRef:ne}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ne.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ne.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||M(!1),document.removeEventListener(`pointermove`,t),ne.current=null};return ne.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,M,ne]),F.useEffect(()=>{let e=()=>M(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[M]);let[re,ie]=$a(e=>{let t=O().filter(e=>!e.disabled),n=eo(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(ee.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ce=r===`popper`?Sa:ba,le=ce===Sa?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(ma,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:te,selectedItemText:E,position:r,isPositioned:k,searchRef:re,children:(0,I.jsx)(Bt,{as:_a,allowPinchZoom:!0,children:(0,I.jsx)(zt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Lt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(It,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,I.jsx)(ce,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...le,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Lt(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ie(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>j(t)),e.preventDefault()}})})})})})})});va.displayName=ga;var ya=`SelectItemAlignedPosition`,ba=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=$i(da,n),o=ha(da,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=wt(t,e=>u(e)),f=qi(n),p=F.useRef(!1),m=F.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=F.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-pa,d=Ri(a,[pa,Math.max(pa,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-pa,d=Ri(a,[pa,Math.max(pa,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-pa*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-pa,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,ee=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+ee;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${pa}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);St(()=>y(),[y]);let[b,x]=F.useState();return St(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,I.jsx)(Ca,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:F.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,I.jsx)(Et.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ba.displayName=ya;var xa=`SelectPopperPosition`,Sa=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=pa,...a}=e,o=Zi(n);return(0,I.jsx)(Ct,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Sa.displayName=xa;var[Ca,wa]=Yi(da,{}),Ta=`SelectViewport`,Ea=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ha(Ta,n),o=wa(Ta,n),s=wt(t,a.onViewportChange),c=F.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(Ki.Slot,{scope:n,children:(0,I.jsx)(Et.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Lt(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-pa*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Ea.displayName=Ta;var Da=`SelectGroup`,[Oa,ka]=Yi(Da),Aa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Dt();return(0,I.jsx)(Oa,{scope:n,id:i,children:(0,I.jsx)(Et.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Aa.displayName=Da;var ja=`SelectLabel`,Ma=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ka(ja,n);return(0,I.jsx)(Et.div,{id:i.id,...r,ref:t})});Ma.displayName=ja;var Na=`SelectItem`,[Pa,Fa]=Yi(Na),Ia=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=$i(Na,n),c=ha(Na,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=wt(t,e=>c.itemRefCallback?.(e,r,i)),h=Dt(),g=F.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,I.jsx)(Pa,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(Ki.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Et.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Lt(o.onFocus,()=>p(!0)),onBlur:Lt(o.onBlur,()=>p(!1)),onClick:Lt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Lt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Lt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Lt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Lt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Wi.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Ia.displayName=Na;var La=`SelectItemText`,Ra=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=$i(La,n),s=ha(La,n),c=Fa(La,n),l=ta(La,n),[u,d]=F.useState(null),f=wt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=F.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return St(()=>(h(m),()=>g(m)),[h,g,m]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Et.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Li.createPortal(a.children,o.valueNode):null]})});Ra.displayName=La;var za=`SelectItemIndicator`,Ba=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Fa(za,n).isSelected?(0,I.jsx)(Et.span,{"aria-hidden":!0,...r,ref:t}):null});Ba.displayName=za;var Va=`SelectScrollUpButton`,Ha=F.forwardRef((e,t)=>{let n=ha(Va,e.__scopeSelect),r=wa(Va,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Ga,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ha.displayName=Va;var Ua=`SelectScrollDownButton`,Wa=F.forwardRef((e,t)=>{let n=ha(Ua,e.__scopeSelect),r=wa(Ua,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Ga,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Wa.displayName=Ua;var Ga=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ha(`SelectScrollButton`,n),o=F.useRef(null),s=qi(n),c=F.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return F.useEffect(()=>()=>c(),[c]),St(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(Et.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Lt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Lt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Lt(i.onPointerLeave,()=>{c()})})}),Ka=`SelectSeparator`,qa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Et.div,{"aria-hidden":!0,...r,ref:t})});qa.displayName=Ka;var Ja=`SelectArrow`,Ya=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Zi(n),a=$i(Ja,n),o=ha(Ja,n);return a.open&&o.position===`popper`?(0,I.jsx)(kt,{...i,...r,ref:t}):null});Ya.displayName=Ja;var Xa=`SelectBubbleInput`,Za=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=wt(r,i),o=Hi(t);return F.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,I.jsx)(Et.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});Za.displayName=Xa;function Qa(e){return e===``||e===void 0}function $a(e){let t=Tt(e),n=F.useRef(``),r=F.useRef(0),i=F.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=F.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return F.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function eo(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=to(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function to(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var no=na,ro=ia,io=oa,ao=ca,oo=ua,so=fa,co=Ea,lo=Aa,uo=Ma,fo=Ia,po=Ra,mo=Ba,ho=Ha,go=Wa,_o=qa,vo=no,yo=io,bo=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(ro,{ref:a,className:r(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 bg-white`,e),...i,children:[t,(0,I.jsx)(ao,{asChild:!0,children:n??(0,I.jsx)(Ln,{className:`h-4 w-4 opacity-50`})})]}));bo.displayName=ro.displayName;var xo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(ho,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(zn,{className:`h-4 w-4`})}));xo.displayName=ho.displayName;var So=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Ln,{className:`h-4 w-4`})}));So.displayName=go.displayName;var Co=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(oo,{children:(0,I.jsxs)(so,{ref:o,className:r(`relative z-[var(--z-popover,50)] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-white`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...a,children:[(0,I.jsx)(xo,{}),(0,I.jsx)(co,{className:r(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,i),children:t}),(0,I.jsx)(So,{})]})}));Co.displayName=so.displayName;var wo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(uo,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));wo.displayName=uo.displayName;var To=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(fo,{ref:i,className:r(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(mo,{children:(0,I.jsx)(In,{className:`h-4 w-4`})})}),(0,I.jsx)(po,{children:t})]}));To.displayName=fo.displayName;var Eo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Eo.displayName=_o.displayName;var Do={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function Oo(e){return Do[e]}function ko({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=Oo(i);return(0,I.jsx)(w,{to:e,className:({isActive:e})=>r(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:r(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function Ao({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=Oo(i);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:r(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,I.jsx)(t,{className:r(d.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:r(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,I.jsx)(`span`,{className:r(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function jo({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=Oo(o);return(0,I.jsxs)(vo,{value:n,onValueChange:a,children:[(0,I.jsxs)(bo,{className:r(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,I.jsxs)(`div`,{className:r(`flex min-w-0 items-center`,c.gap),children:[(0,I.jsx)(t,{className:r(c.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:r(`ml-auto text-gray-500`,c.value),children:i})]}),(0,I.jsx)(Co,{children:s})]})}var Mo=`nextclaw-pwa-install-banner-dismissed`,No=`nextclaw-pwa-install-banner-dismissed-until`;function Po(){let e=Lo();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:Ro(e):!1}function Fo(){let e=Lo();e?.setItem(Mo,`1`),e?.removeItem(No)}function Io(){let e=Lo();e?.removeItem(Mo),e?.removeItem(No)}function Lo(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Ro(e){let t=e.getItem(No);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(No),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Mo,`1`),!0)}function zo(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Po()}}var Bo=m(()=>zo()),Vo=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),Bo.setState(zo())},this.refreshState=()=>{let e=this.resolveInstallability();Bo.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Po()}))},this.dismissInstallPrompt=()=>{Fo(),Bo.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(Io(),this.refreshState(),N.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Io(),Bo.setState({dismissedInstallPrompt:!0}),N.success(s(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function Ho(){let e=Bo(e=>e.installability);return(0,I.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Uo(e)})}function Uo(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function Wo(e,t,n){return s(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function Go(){let e=Bo(e=>e.installability),t=Bo(e=>e.installMethod),n=Bo(e=>e.blockedReason);return(0,I.jsxs)(_e,{children:[(0,I.jsxs)(ot,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(fe,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(je,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Ho,{})]}),(0,I.jsxs)(ge,{className:`space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:Wo(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,className:`gap-2`,onClick:()=>{Vo.promptInstall()},children:[(0,I.jsx)(Un,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:s(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,I.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,I.jsx)(yr,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallManualHint`)})]}):null]})]})}function Ko(){let e=Bo(e=>e.installability),t=Bo(e=>e.installMethod),n=Bo(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,I.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":s(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Vo.dismissInstallPrompt()},children:(0,I.jsx)(gn,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Vo.promptInstall()},children:[(0,I.jsx)(Un,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(ye,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Vo.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}var qo=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},Jo=!1;function Yo(){Jo||typeof window>`u`||(Jo=!0,Vo.start(),qo.start())}var Xo={warm:`#F9F8F5`,cool:`#F8FAFB`},Zo=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=Xo[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},Qo=(0,F.createContext)(null);function $o({children:e}){let[t,n]=(0,F.useState)(()=>ei());(0,F.useEffect)(()=>{Zo.syncTheme(t)},[t]),(0,F.useEffect)(()=>ri(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{ni(e),n(ti())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(Qo.Provider,{value:i,children:e})}function es(){let e=(0,F.useContext)(Qo);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function ts(){let{language:e,setLanguage:n}=kr();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,F.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}function ns(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=ts();return(0,I.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(cr,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:s(`language`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,I.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(t.value),className:r(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,I.jsx)(In,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function rs({mode:e}){let t=re(),n=Dn(),i=le(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=ts(),{theme:u,setTheme:d}=es(),f=e===`settings`,p=s(qr.find(e=>e.value===u)?.labelKey??`themeWarm`),m=i.data?.account.email?.trim(),h=!!i.data?.account.loggedIn,g=e=>{u!==e&&d(e)},_=[{target:`/chat`,label:s(`chat`),icon:lr},{target:`/chat/cron`,label:s(`cron`),icon:jn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:s(`agentsPageTitle`),icon:Pn}],v=Hr(s),y=f?v:_,b=f?`compact`:`default`;return(0,I.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 pb-6`,children:[f?(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,I.jsxs)(w,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:s(`backToMain`)})]}),(0,I.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,I.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:s(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(ji,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,I.jsx)(`ul`,{className:r(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(ko,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:r(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,I.jsx)(Ao,{onClick:()=>t.accountManager.openAccountPanel(),icon:fn,label:s(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:h?m||s(`remoteAccountEntryConnected`):s(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(ko,{to:`/settings`,label:s(`settings`),icon:_r})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(jo,{value:u,onValueChange:e=>g(e),icon:pr,label:s(`theme`),valueLabel:p,density:b,children:qr.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(jo,{value:a,onValueChange:e=>l(e),icon:cr,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(Ao,{onClick:()=>n.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var is=[{action:`minimize`,label:`Minimize`,icon:fr},{action:`close`,label:`Close`,icon:gn,variant:`danger`}];function as(){let e=ss()?{action:`toggle-maximize`,label:`Restore`,icon:Vn}:{action:`toggle-maximize`,label:`Maximize`,icon:xr};return(0,I.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 bg-secondary after:absolute after:bottom-0 after:left-[var(--desktop-sidebar-width)] after:right-0 after:border-b after:border-[#ebe7dc]/80`,"data-testid":`desktop-window-chrome`,children:[(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,I.jsx)(`div`,{className:`desktop-window-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary pl-4 pr-3 text-secondary-foreground`,"data-testid":`desktop-window-chrome-sidebar`,children:(0,I.jsx)(ji,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:[is[0],e,is[1]].map(e=>(0,I.jsx)(os,{control:e},e.action))})]})}function os({control:e}){let t=e.icon;return(0,I.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,I.jsx)(t,{className:`h-3.5 w-3.5`})})}function ss(){let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{let e=!0,n=window.nextclawDesktop;n?.getWindowState?.().then(n=>{e&&t(n.isMaximized)});let r=n?.onWindowStateChanged?.(e=>{t(e.isMaximized)});return()=>{e=!1,r?.()}},[]),e}function cs(){return typeof window>`u`?null:us()??window.nextclawDesktop?.platform??null}function ls(){return cs()===`win32`}function us(){return null}function ds(e,t){if(t===`/settings`)return Wr(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function fs(){let{pathname:e}=S(),t=Vr(s);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":s(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,I.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=ds(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(v,{to:t.target,"aria-current":n?`page`:void 0,className:r(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,I.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:r(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,I.jsx)(t.icon,{className:r(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,I.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function ps({leadingInset:e}){let t=C(),{pathname:n}=S(),r=Gr(n,s);return(0,I.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,I.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 py-1.5 pl-3 pr-3`,style:{paddingLeft:e?`calc(${e} + 0.75rem)`:void 0},children:[r.backTarget?(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(r.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":r.backLabel??s(`backToMain`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:r.title})}),r.backTarget?(0,I.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var ms=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yi02ASOL.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function hs({pathname:e,isDocBrowserOpen:t,docBrowserDockControls:n,docBrowserRenderers:r={},topbarLeadingInset:i,children:a}){let o=zr(e),s=!Br(e),c=!Br(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[s?(0,I.jsx)(ps,{leadingInset:i}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:o?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:a}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:a})})}),c?(0,I.jsx)(fs,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(ms,{customTabRenderers:r,displayMode:`fullscreen`,dockControls:n})}):null]})}function gs(){let e=Ur(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(w,{to:e.target,className:({isActive:e})=>r(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(e.icon,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function _s({isProjectFirstView:e,onSelectMode:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:r(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:s(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:r(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:s(`chatSidebarViewProject`)})]})}var vs={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,email:`email.svg`};function ys(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function bs(e){return ys(vs,e)}var xs={wx:`weixin`,lark:`feishu`},Ss={cron:{icon:`cron`}},Cs={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function ws(e){return e?.trim().toLowerCase()??``}function Ts(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Es(e,t){let n=ws(e);if(!n||n===`native`)return null;let r=t.find(e=>ws(e.value)===n);return r?.label.trim()?r.label.trim():Ts(n)}function Ds(e,t){let n=ws(e);return!n||n===`native`?null:t.find(e=>ws(e.value)===n)??null}function Os(e){let t=ws(e);if(!t)return null;let n=xs[t]??t;return bs(n)?n:null}function ks(e,t){let n=Os(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Ss[ws(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=ws(e.sessionType),a=Ds(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=Cs[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||Es(e.sessionType,t)}}var As=`app://`;function js(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Ms(e){let t=e.trim();if(!t)return null;if(!t.startsWith(As))return t;let n=js(t.slice(6));return n?`/${n}`:null}function Ns({name:e,src:t,className:n,imgClassName:i,fallback:a}){let[o,s]=(0,F.useState)(!1),c=!!t&&!o;return(0,I.jsx)(`div`,{className:r(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:c?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:r(`block h-6 w-6 object-contain`,i),onError:()=>s(!0),draggable:!1}):a??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Ps({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Fs,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Ms(e.src);return(0,I.jsx)(Ns,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Pn,{className:r(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(jn,{className:r(`h-3.5 w-3.5`,t)})}function Fs({channel:e,className:t}){return(0,I.jsx)(Ns,{name:e,src:bs(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Pn,{className:`h-3 w-3 text-gray-500`})})}function Is(e){let{option:t,onSelect:n}=e,i=t.ready===!1?t.reasonMessage?.trim()||s(`statusSetup`):null;return(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,I.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,I.jsx)(Ps,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,I.jsx)(Pn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,I.jsxs)(`span`,{className:r(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?s(`statusSetup`):s(`statusReady`)]})]}),i?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:i}):null]})]})})})}function Ls(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Rs(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Ls(n,r),[n,r]),u=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${s(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,I.jsxs)(wn,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,I.jsx)(pn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(Is,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(pn,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var zs=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Bs(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Vs({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=zs[Bs(e)%zs.length]??zs[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:r(`rounded-full object-cover`,i)}):(0,I.jsx)(`div`,{className:r(`rounded-full flex items-center justify-center font-semibold`,o,s,i),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(Pn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Hs({status:e,className:t}){let n=s(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:r(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,I.jsx)($t,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Us(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function Ws(e){let t=e.activityPreview;return t?t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null:null}function Gs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Ks(e,t){return e.getFullYear()===t.getFullYear()}function qs(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Ks(e,t)?n:`${e.getFullYear()}年${n}`}function Js(e,t=d(),n=new Date){if(!e)return`-`;let r=e instanceof Date?e:new Date(e);if(Number.isNaN(r.getTime()))return typeof e==`string`?e:`-`;let i=p(t),a=Gs(r),o=Gs(n),c=Math.floor((o-a)/864e5);if(c===0)return new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r);if(c===1)return s(`chatSidebarYesterday`,t);if(c>1&&c<7)return new Intl.DateTimeFormat(i,{weekday:`long`}).format(r);if(t===`zh`)return qs(r,n);let l=Ks(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Ys(e){return e.trim().toLowerCase()}function Xs(e,t){let n=Ys(t);return n?[e.key,Us(e),e.projectRoot??``,e.projectName??``].map(Ys).some(e=>e.includes(n)):!0}function Zs({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Ne,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:s(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(ye,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":s(`save`),children:(0,I.jsx)(In,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ye,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":s(`cancel`),children:(0,I.jsx)(gn,{className:`h-3.5 w-3.5`})})]})]})]})}function Qs({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:c,agentLabel:l,agentAvatarUrl:u,childSessionCount:d=0,onSelect:f,onOpenChildSessions:p,onStartEditing:m}){let h=d>0&&p?`pr-14`:`pr-6`,g=Ws(e),_=`${l?.trim()?`${l} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:r(`flex min-w-0 items-start`,h),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.trim()&&c.trim().toLowerCase()!==`main`?(0,I.jsx)(Vs,{agentId:c,displayName:l,avatarUrl:u,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:o}),a.label?(0,I.jsx)(`span`,{className:r(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:a.label}):null,a.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)(Ps,{icon:a.icon,className:t?`text-gray-700`:`text-gray-500`})}):null]})}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:g??_}),n?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:Js(e.lastMessageAt??e.createdAt)})]})]}),d>0&&p?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:r(`absolute right-6 top-0 inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(ar,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:d})]}):null,i?(0,I.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,I.jsx)(Hs,{status:i})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:r(`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-md text-gray-400 transition-all hover:bg-white hover:text-gray-900`,`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`edit`),children:(0,I.jsx)(hr,{className:`h-3 w-3`})})]})}function $s({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,childSessionCount:u,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:r(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,I.jsx)(Zs,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(Qs,{session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,onSelect:m,childSessionCount:u,onOpenChildSessions:h,onStartEditing:g})})}var ec=[{icon:lr,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:E,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:jn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function tc({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`min-h-full flex items-center justify-center px-4 py-6 sm:p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full min-w-0 text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(Pn,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:s(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:s(`chatWelcomeSubtitle`)}),(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:s(`chatDraftAgentTitle`)}),(0,I.jsxs)(vo,{value:n,onValueChange:r,children:[(0,I.jsxs)(bo,{"aria-label":s(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:s(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(Vs,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(Co,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(To,{value:e.id,className:`rounded-lg pr-10`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(Vs,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,9.5rem),1fr))] gap-3`,children:ec.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`min-w-0 rounded-2xl border border-gray-200 bg-white p-3 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer sm:p-4`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:s(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:s(t.descKey)})]},t.titleKey)})})]})})}var nc=(0,F.createContext)(null);function rc({presenter:e,children:t}){return(0,I.jsx)(nc.Provider,{value:e,children:t})}function ic(){let e=(0,F.useContext)(nc);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var ac=e=>`[data-item-index="${e}"]`;function oc(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??ac;(0,F.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function sc(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function L(...e){return i(f(e))}var cc=F.forwardRef(({className:e,type:t,...n},r)=>(0,I.jsx)(`input`,{type:t,className:L(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));cc.displayName=`ChatInput`;var lc=Cn,uc=vn,dc=yn,fc=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(xn,{children:(0,I.jsx)(_n,{ref:i,sideOffset:t,align:n,className:L(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));fc.displayName=_n.displayName;var pc=no,mc=lo,hc=io,gc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(ro,{ref:r,className:L(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,I.jsx)(ao,{asChild:!0,children:(0,I.jsx)(Ln,{className:`h-4 w-4 opacity-50`})})]}));gc.displayName=ro.displayName;var _c=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(ho,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(zn,{className:`h-4 w-4`})}));_c.displayName=ho.displayName;var vc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Ln,{className:`h-4 w-4`})}));vc.displayName=go.displayName;var yc=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(oo,{children:(0,I.jsxs)(so,{ref:i,className:L(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,I.jsx)(_c,{}),(0,I.jsx)(co,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,I.jsx)(vc,{})]})}));yc.displayName=so.displayName;var bc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(uo,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));bc.displayName=uo.displayName;var xc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(fo,{ref:r,className:L(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(mo,{children:(0,I.jsx)(In,{className:`h-4 w-4`})})}),(0,I.jsx)(po,{children:t})]}));xc.displayName=fo.displayName;var Sc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Sc.displayName=_o.displayName;var Cc=cn,wc=tn,Tc=rn,Ec=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(on,{children:(0,I.jsx)(en,{ref:r,sideOffset:t,className:L(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));Ec.displayName=en.displayName;var Dc={Popover:lc,PopoverAnchor:dc,PopoverContent:fc,PopoverTrigger:uc,Input:cc,Select:pc,SelectContent:yc,SelectGroup:mc,SelectItem:xc,SelectLabel:bc,SelectSeparator:Sc,SelectTrigger:gc,SelectValue:hc,Tooltip:wc,TooltipContent:Ec,TooltipProvider:Cc,TooltipTrigger:Tc},Oc=680,kc=.82,Ac=560;function jc(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Dc,{elementRef:i,width:a}=sc(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onDetailsPointerDown:h,onSetActiveIndex:g}=e,_=(0,F.useMemo)(()=>{if(a)return Math.min(a>Ac?a*kc:a,Oc)},[a]);return oc({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,I.jsxs)(t,{open:s,onOpenChange:m,children:[(0,I.jsx)(n,{asChild:!0,children:(0,I.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,I.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:_?{width:`${_}px`}:void 0,children:(0,I.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,I.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,I.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,I.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>g(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,I.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,I.jsx)(`div`,{className:`min-w-0 p-2.5`,onPointerDown:h,children:d?(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,I.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,I.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,I.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var Mc=Ce(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),Nc=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Mc({variant:t,size:n,className:e})),ref:i,...r}));Nc.displayName=`ChatButton`;var Pc=120;function Fc(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Pc?t:`${t.slice(0,Pc-1)}…`}function Ic(){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function Lc({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Dc,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,I.jsx)(r,{delayDuration:0,children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":e.label,title:e.label,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(#9ca3af ${o}deg, #e5e7eb 0deg)`}}),(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-white`})]})}),(0,I.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-gray-800`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-gray-600`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`font-medium text-gray-800`,children:e.value})]},e.label))]})})]})})}function Rc({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=Dc,y=e?.trim()??``,b=y?Fc(y):``,x=t?.trim()||`Details`;return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,I.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,I.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,I.jsxs)(f,{children:[(0,I.jsx)(m,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,I.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,I.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,I.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,I.jsx)(Lc,{contextWindow:l}):null,n?r?(0,I.jsx)(Nc,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(Ic,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Nc,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(Ic,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Nc,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(Nn,{className:`h-5 w-5`})})]})]})}function zc(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Bc(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Dc,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,F.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,F.useMemo)(()=>h?h.flatMap(e=>e.options):zc(a.options,c),[h,a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),oc({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,I.jsxs)(n,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,I.jsx)(E,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`nextclaw-chat-skill-picker-label hidden sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,I.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,I.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,I.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,I.jsxs)(`div`,{children:[e.label?(0,I.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,I.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,I.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,I.jsx)(gr,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,I.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,I.jsx)(In,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,I.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,I.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,I.jsx)(dn,{className:`h-3 w-3`})]})}):null]})]})}function Vc({icon:e}){return e===`sparkles`?(0,I.jsx)(br,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(Fn,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Hc({icon:e}){return e===`paperclip`?(0,I.jsx)(mr,{className:`h-4 w-4`}):(0,I.jsx)(Vc,{icon:e})}var Uc={model:`min-w-0 max-w-full flex-1 basis-[12rem] sm:max-w-[320px]`,"session-type":`shrink-0`,thinking:`shrink-0`},Wc={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Gc(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Kc({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Dc,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0),d=Gc(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,title:e.selectedLabel,className:`nextclaw-chat-toolbar-select-trigger h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${Uc[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Vc,{icon:e.icon}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-mobile-label truncate text-xs font-semibold text-gray-700 sm:hidden [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:d}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-label hidden truncate text-xs font-semibold text-gray-700 sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:Wc[e.key]??``,children:[u?null:e.loading?(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,I.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,I.jsxs)(`div`,{children:[t>0?(0,I.jsx)(o,{}):null,(0,I.jsxs)(r,{children:[e.label?(0,I.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,I.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,I.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function qc({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Dc;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[12rem] flex-1 flex-wrap items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Bc,{picker:r}):null,n.map(e=>(0,I.jsx)(Kc,{item:e},e.key)),t?.map(e=>{let t=(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,I.jsx)(Hc,{icon:e.icon}),e.iconOnly?null:(0,I.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,I.jsx)(o,{children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:e.disabled?(0,I.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,I.jsx)(a,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,I.jsx)(`div`,{children:t},e.key)})]}),(0,I.jsx)(Rc,{...e})]})}var Jc=(0,F.createContext)(null);function Yc(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Xc(){let e=(0,F.useContext)(Jc);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function R(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Zc(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Qc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,$c=Qc&&`documentMode`in document?document.documentMode:null,el=Qc&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),tl=Qc&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),nl=!(!Qc||!(`InputEvent`in window)||$c)&&`getTargetRanges`in new window.InputEvent(`input`),rl=Qc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,il=Qc&&/Android/.test(navigator.userAgent),al=Qc&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!il,ol=Qc&&/^(?=.*Chrome).*/i.test(navigator.userAgent),sl=Qc&&il&&ol,cl=Qc&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&el&&!ol,ll=0,ul=1,dl=2,fl=1,pl=2,ml=3,hl=4,gl=5,_l=6,vl=al||rl||cl?`\xA0`:`​`,yl=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-D5FJcAyz.js","assets/doc-browser-DewXa6oX.js","assets/react-BVjl1ZaK.js","assets/dist-CyWdaJvr.js","assets/tooltip-CKGxLGnG.js","assets/dist-DzM2ZEVN.js","assets/arrow-left-Dd45Mvr1.js","assets/external-link-BLjo8z2a.js","assets/plus-DrpyArC8.js","assets/search-CjHGYvTI.js","assets/x-dpDISboO.js","assets/doc-browser-context-CpL2m4Sp.js","assets/model-config-B-qg70S4.js","assets/api-DmxQnm30.js","assets/loader-circle-Dz4FssYC.js","assets/provider-scoped-model-input-BgPTQa8H.js","assets/provider-models-C_yOh6DE.js","assets/config-hints-Ceiol9x4.js","assets/chat-page-YKdeGoVx.js","assets/app-presenter-provider-CDSjiqfE.js","assets/confirm-dialog-BWRNsRgb.js","assets/es2015-WqekV0OK.js","assets/popover-BlJLguiZ.js","assets/key-round-Du8x3sWa.js","assets/refresh-cw-DFR87zei.js","assets/trash-2-yLA8BEcE.js","assets/notice-card-3a7FmAz-.js","assets/status-dot-SVPjIyG5.js","assets/tabs-Czd2mj6z.js","assets/mcp-marketplace-page-BaBuHB2L.js","assets/tag-chip-Cdwb3JSH.js","assets/ellipsis-BDgTYNDX.js","assets/play-BziM-Y34.js","assets/tabs-custom-Ix4nkp2h.js","assets/search-config-BRsrQ4zK.js","assets/config-split-page-CdJEkWxv.js","assets/providers-list-cBeeslbc.js","assets/channels-list-page-bkKDqaO5.js","assets/runtime-config-page-DYH2ejUI.js","assets/rotate-cw-DMBnsYKm.js","assets/save-BDmIlHvN.js","assets/desktop-update-config-CLXdVz9r.js","assets/secrets-config-eYdx5_AW.js","assets/remote-DjhVMpVd.js","assets/mcp-marketplace-page-ooEvG_bB.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g,y as _}from"./react-BVjl1ZaK.js";import{A as v,C as y,E as b,F as x,I as S,L as C,M as w,N as T,O as E,P as D,S as O,T as k,a as A,c as ee,i as j,j as te,k as M,l as ne,n as re,o as ie,r as ae,s as oe,t as se,u as ce,x as le,z as ue}from"./app-presenter-provider-CDSjiqfE.js";import{$ as de,At as fe,B as pe,Bt as me,Ct as he,Dt as ge,Et as _e,F as ve,Ft as ye,G as be,H as xe,I as Se,It as Ce,J as we,K as Te,L as Ee,Lt as De,M as Oe,N as ke,Nt as Ae,Ot as je,P as Me,Pt as Ne,Q as Pe,Qt as Fe,R as Ie,Rt as Le,Tt as Re,U as ze,V as Be,Vt as Ve,W as He,X as Ue,Y as We,Z as Ge,Zt as Ke,_ as qe,at as Je,bt as Ye,ct as Xe,d as Ze,dt as Qe,et as $e,f as et,ft as tt,g as nt,gt as rt,h as it,ht as at,kt as ot,lt as st,m as ct,n as lt,ot as ut,p as dt,q as ft,st as pt,t as mt,tt as ht,v as gt,vt as _t,xt as vt,y as yt,yt as bt,z as xt,zt as N}from"./api-DmxQnm30.js";import{_ as St,a as Ct,b as wt,c as P,d as Tt,f as Et,g as Dt,h as Ot,i as kt,l as At,n as jt,o as Mt,p as Nt,r as Pt,s as Ft,u as It,x as Lt,y as Rt}from"./dist-CyWdaJvr.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./es2015-WqekV0OK.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./confirm-dialog-BWRNsRgb.js";import{t as Xt}from"./arrow-left-Dd45Mvr1.js";import{n as Zt}from"./doc-browser-DewXa6oX.js";import{n as Qt,t as $t}from"./loader-circle-Dz4FssYC.js";import{a as en,c as tn,i as nn,l as rn,n as an,o as on,r as sn,s as cn,t as ln,u as un}from"./tooltip-CKGxLGnG.js";import{t as dn}from"./external-link-BLjo8z2a.js";import{t as fn}from"./key-round-Du8x3sWa.js";import{t as pn}from"./plus-DrpyArC8.js";import{t as mn}from"./search-CjHGYvTI.js";import{t as hn}from"./trash-2-yLA8BEcE.js";import{t as gn}from"./x-dpDISboO.js";import{a as _n,c as vn,i as yn,n as bn,o as xn,r as Sn,s as Cn,t as wn}from"./popover-BlJLguiZ.js";import{c as Tn,m as En,n as Dn,s as On,t as kn}from"./doc-browser-context-CpL2m4Sp.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var An=e((e=>{var t=o();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),jn=P(`AlarmClock`,[[`circle`,{cx:`12`,cy:`13`,r:`8`,key:`3y4lt7`}],[`path`,{d:`M12 9v4l2 2`,key:`1c63tq`}],[`path`,{d:`M5 3 2 6`,key:`18tl5t`}],[`path`,{d:`m22 6-3-3`,key:`1opdir`}],[`path`,{d:`M6.38 18.7 4 21`,key:`17xu3x`}],[`path`,{d:`M17.64 18.67 20 21`,key:`kv2oe2`}]]),Mn=P(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Nn=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Pn=P(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Fn=P(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),In=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ln=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Rn=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),zn=P(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Bn=P(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Vn=P(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Hn=P(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),Un=P(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),Wn=P(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),Gn=P(`FileAudio2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2`,key:`17k7jt`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`3`,cy:`17`,r:`1`,key:`vo6nti`}],[`path`,{d:`M2 17v-3a4 4 0 0 1 8 0v3`,key:`1ggdre`}],[`circle`,{cx:`9`,cy:`17`,r:`1`,key:`bc1fq4`}]]),Kn=P(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),qn=P(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Jn=P(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),Yn=P(`FileSpreadsheet`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),Xn=P(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Zn=P(`FileVideo2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`rect`,{width:`8`,height:`6`,x:`2`,y:`12`,rx:`1`,key:`1a6c1e`}],[`path`,{d:`m10 15.5 4 2.5v-6l-4 2.5`,key:`t7cp39`}]]),Qn=P(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),$n=P(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),er=P(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tr=P(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),nr=P(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),rr=P(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),ir=P(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ar=P(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),or=P(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),sr=P(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),cr=P(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),lr=P(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),ur=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),dr=P(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),fr=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),pr=P(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),mr=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),hr=P(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gr=P(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),_r=P(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),vr=P(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),yr=P(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),br=P(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),xr=P(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Sr=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Cr=P(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),wr=P(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Tr=An(),F=_(a(),1);function Er(){let e=Dn();(0,F.useEffect)(()=>{let t=t=>{let n=t.target.closest(`a[href]`);if(!n)return;let r=n.getAttribute(`href`)||``;En(r)&&(n.hasAttribute(`data-doc-external`)||t.ctrlKey||t.metaKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e.open(r)))};return document.addEventListener(`click`,t,!0),()=>document.removeEventListener(`click`,t,!0)},[e])}var I=l(),Dr=(0,F.createContext)(null);function Or({children:e}){let[t,r]=(0,F.useState)(()=>n());(0,F.useEffect)(()=>h(e=>{r(e)}),[]);let i=(0,F.useCallback)(e=>{c(e),r(d())},[]),a=(0,F.useCallback)(()=>{i(t===`en`?`zh`:`en`)},[t,i]),o=(0,F.useMemo)(()=>({language:t,setLanguage:i,toggleLanguage:a}),[t,i,a]);return(0,I.jsx)(Dr.Provider,{value:o,children:e})}function kr(){let e=(0,F.useContext)(Dr);if(!e)throw Error(`useI18n must be used within I18nProvider`);return{...e,t:s}}function Ar(e){return typeof e!=`number`||!Number.isFinite(e)?`desktop`:e<=767?`mobile`:`desktop`}function jr(){let e=typeof window>`u`?null:window.innerWidth??null;return{mode:Ar(e),width:e}}var Mr=m(()=>jr()),Nr=new class{constructor(){this.consumerCount=0,this.started=!1,this.attach=()=>(this.consumerCount+=1,this.consumerCount===1&&this.start(),()=>{this.consumerCount=Math.max(0,this.consumerCount-1),this.consumerCount===0&&this.stop()}),this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`resize`,this.handleViewportChange),window.addEventListener(`orientationchange`,this.handleViewportChange),this.syncFromWindow())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`resize`,this.handleViewportChange),window.removeEventListener(`orientationchange`,this.handleViewportChange),this.started=!1)},this.getSnapshot=()=>Mr.getState(),this.resetForTests=()=>{this.consumerCount=0,this.stop(),Mr.setState(jr())},this.handleViewportChange=()=>{this.syncFromWindow()},this.syncFromWindow=()=>{if(typeof window>`u`)return;let e=window.innerWidth??null;Mr.setState({width:e,mode:Ar(e)})}}};function Pr(){return(0,F.useEffect)(()=>Nr.attach(),[]),{isMobile:Mr(e=>e.mode)===`mobile`}}var Fr=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Ir=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Fr.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Fr.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Fr.setState({supported:!0,initialized:!0,busyAction:null}),N.error(`${s(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Fr.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(s(`runtimePresenceLaunchAtLoginUnavailable`));Fr.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return Fr.setState({supported:!0,initialized:!0,snapshot:n}),N.success(s(`runtimePresenceSaved`)),n}catch(e){throw N.error(`${s(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Fr.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`)}},Lr=m(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){Lr.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{Lr.setState({supported:!0,initialized:!0,snapshot:e})}),Lr.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();Lr.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){Lr.setState({supported:!0,initialized:!0}),N.error(`${s(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,s(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){N.success(s(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){N.success(s(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??s(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){N.success(s(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&N.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,s(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&N.success(s(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,s(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,s(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(Lr.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,s(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){N.success(s(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}N.success(s(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let r=this.getDesktopApi();if(!r)throw Error(s(`desktopUpdatesDesktopOnlyDescription`));Lr.setState({busyAction:e});try{let e=await n(r);return Lr.setState({snapshot:e}),e}catch(e){throw N.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{Lr.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:s(`error`),this.getChannelLabel=e=>s(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function Rr(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function zr(e){let t=e.toLowerCase();return t===`/chat`||t.startsWith(`/chat/`)||t===`/skills`||t.startsWith(`/skills/`)||t===`/cron`||t.startsWith(`/cron/`)||t===`/agents`||t.startsWith(`/agents/`)}function Br(e){let t=e.toLowerCase();return t.startsWith(`/chat/`)&&t!==`/chat`}function Vr(e){return[{target:`/chat`,label:e(`chat`),icon:lr},{target:`/skills`,label:e(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:e(`agentsPageTitle`),icon:Pn},{target:`/settings`,label:e(`settings`),icon:_r}]}function Hr(e){return[{target:`/model`,label:e(`model`),icon:Hn},{target:`/providers`,label:e(`providers`),icon:br},{target:`/channels`,label:e(`channels`),icon:dr},{target:`/search`,label:e(`searchChannels`),icon:mn},{target:`/runtime`,label:e(`runtime`),icon:Hn},{target:`/updates`,label:e(`updates`),icon:Un},{target:`/remote`,label:e(`remote`),icon:wr},{target:`/security`,label:e(`security`),icon:vr},{target:`/secrets`,label:e(`secrets`),icon:fn},{target:`/marketplace/mcp`,label:e(`marketplaceFilterMcp`),icon:O}]}function Ur(e){return[{target:`/language`,label:e(`language`),icon:cr},...Hr(e)]}function Wr(e){let t=e.toLowerCase();return t===`/settings`?!0:Ur(e=>e).some(e=>Rr(t,e.target))}function Gr(e,t){let n=e.toLowerCase(),r=Ur(t);if(Br(n))return{title:t(`chat`),backTarget:`/chat`,backLabel:t(`chat`)};if(n===`/chat`)return{title:t(`chat`),backTarget:null,backLabel:null};if(n===`/skills`||n.startsWith(`/skills/`))return{title:t(`marketplaceFilterSkills`),backTarget:null,backLabel:null};if(n===`/agents`||n.startsWith(`/agents/`))return{title:t(`agentsPageTitle`),backTarget:null,backLabel:null};if(n===`/settings`)return{title:t(`settings`),backTarget:null,backLabel:null};for(let e of r)if(Rr(n,e.target))return{title:e.label,backTarget:`/settings`,backLabel:t(`settings`)};return{title:t(`settings`),backTarget:null,backLabel:null}}var Kr=`nextclaw.ui.theme`,qr=[{value:`warm`,labelKey:`themeWarm`},{value:`cool`,labelKey:`themeCool`}],Jr=`warm`,Yr=!1,Xr=new Set;function Zr(e){return e===`warm`||e===`cool`}function Qr(e){typeof document>`u`||document.documentElement.setAttribute(`data-theme`,e)}function $r(){if(typeof window>`u`)return`warm`;try{let e=window.localStorage.getItem(Kr);if(Zr(e))return e}catch{}return`warm`}function ei(){return Yr||=(Jr=$r(),Qr(Jr),!0),Jr}function ti(){return Yr?Jr:ei()}function ni(e){if(ei(),e!==Jr){if(Jr=e,Qr(Jr),typeof window<`u`)try{window.localStorage.setItem(Kr,Jr)}catch{}Xr.forEach(e=>e(Jr))}}function ri(e){return Xr.add(e),()=>{Xr.delete(e)}}function ii(){return Ve({queryKey:[`config`],queryFn:Ee,staleTime:3e4,refetchOnWindowFocus:!0})}function ai(){return Ve({queryKey:[`app-meta`],queryFn:Se,staleTime:1/0})}function oi(){return Ve({queryKey:[`config-meta`],queryFn:Ie,staleTime:1/0})}function si(){return Ve({queryKey:[`providers`],queryFn:ze,staleTime:3e4,refetchOnWindowFocus:!0})}function ci(){return Ve({queryKey:[`provider-templates`],queryFn:xe,staleTime:1/0})}function li(){return Ve({queryKey:[`config-schema`],queryFn:xt,staleTime:1/0})}function ui(){let e=Fe();return me({mutationFn:Ge,onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function di(){let e=Fe();return me({mutationFn:({data:e})=>$e(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function fi(){let e=Fe();return me({mutationFn:({provider:e,data:t})=>Pe(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),n.silentSuccess||N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function pi(){let e=Fe();return me({mutationFn:({data:e})=>Oe(e??{}),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function mi(){let e=Fe();return me({mutationFn:({provider:e})=>Me(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`providers`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSaved`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function hi(){return me({mutationFn:({provider:e,data:t})=>We(e,t)})}function gi(){return me({mutationFn:({provider:e,data:t})=>we(e,t)})}function _i(){return me({mutationFn:({provider:e,data:t})=>be(e,t)})}function vi(){return me({mutationFn:({provider:e})=>He(e)})}function yi(){let e=Fe();return me({mutationFn:({channel:e,data:t})=>Ue(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),e.invalidateQueries({queryKey:[`config-meta`]}),N.success(s(`configSavedApplying`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function bi(){let e=Fe();return me({mutationFn:({data:e})=>de(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function xi(){let e=Fe();return me({mutationFn:({data:e})=>ht(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Si(){return me({mutationFn:({actionId:e,data:t})=>ve(e,t),onError:e=>{N.error(s(`error`)+`: `+e.message)}})}function Ci(e){return Ve({queryKey:[`ncp-sessions`,e?.limit??null,e?.peerId?.trim()||null],queryFn:()=>qe(e),staleTime:5e3,retry:!1})}function wi(e){return Ve({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>nt(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Ti(e={all:!0}){return Ve({queryKey:[`cron`,e],queryFn:()=>pe(e),staleTime:1e4})}function Ei(){let e=Fe();return me({mutationFn:({id:e})=>ke(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Di(){let e=Fe();return me({mutationFn:({id:e,enabled:t})=>ft(e,{enabled:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function Oi(){let e=Fe();return me({mutationFn:({id:e,force:t})=>Te(e,{force:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`cron`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}var ki={healthy:`bg-emerald-500 shadow-[0_0_0_3px_rgba(16,185,129,0.14)]`,attention:`bg-amber-400 shadow-[0_0_0_3px_rgba(251,191,36,0.16)]`,inactive:`bg-gray-300 shadow-[0_0_0_3px_rgba(156,163,175,0.12)]`};function Ai(){let e=_t(),t=e.actionLabel===s(`runtimeStatusRestartAction`),n=()=>{e.tone!==`healthy`&&vt.requestRuntimeBootstrapProbeNow()},i=async()=>{if(t)try{let e=await vt.runRuntimeControlAction(`restart-service`);N.success(e.message)}catch(e){let t=e instanceof Error?e.message:s(`runtimeControlActionFailed`);N.error(`${s(`runtimeControlActionFailed`)}: ${t}`)}};return(0,I.jsxs)(wn,{children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center rounded-full p-0.5 transition-transform hover:scale-105`,"aria-label":e.title,title:e.title,"data-testid":`runtime-status-entry`,onClick:n,children:(0,I.jsx)(`span`,{className:r(`h-2.5 w-2.5 rounded-full`,ki[e.tone])})})}),(0,I.jsxs)(bn,{align:`start`,sideOffset:10,className:`w-[290px] space-y-3 rounded-2xl border border-gray-200 bg-white p-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:e.title}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:e.description})]}),e.reasonLines.length>0?(0,I.jsx)(`div`,{className:`space-y-2`,children:e.reasonLines.map(e=>(0,I.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900`,children:e},e))}):null,e.actionLabel?(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 pt-1`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-gray-500`,children:s(`runtimeStatusActionHint`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void i(),disabled:e.isBusy,className:`text-sm font-semibold text-sky-600 transition-colors hover:text-sky-700 disabled:text-gray-400`,children:e.isBusy?s(`runtimeStatusRestartingAction`):e.actionLabel})]}):null]})]})}function ji({className:e,density:t=`sidebar`,suffix:n}){let{data:i}=ai(),a=i?.name??`NextClaw`,o=i?.productVersion?.trim(),s=o?`v${o}`:null,c=n??(0,I.jsx)(Ai,{}),l=typeof window<`u`&&window.nextclawDesktop?.platform===`darwin`,u=t===`chrome`;return(0,I.jsxs)(`div`,{className:r(e??`flex min-w-0 items-center gap-2`,l&&`pl-[58px]`),children:[(0,I.jsx)(`div`,{className:r(`flex shrink-0 items-center justify-center overflow-hidden`,`h-6 w-6 rounded-md`),children:(0,I.jsx)(`img`,{src:`/logo.svg`,alt:a,className:`h-full w-full object-contain`})}),(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,I.jsx)(`span`,{className:r(`shrink-0 font-semibold text-gray-800`,u?`text-[15px]`:`text-[14px]`),children:a}),s?(0,I.jsx)(Mi,{versionLabel:s,density:t}):null]}),(0,I.jsx)(Ni,{}),c?(0,I.jsx)(`span`,{className:`inline-flex items-center shrink-0`,children:c}):null]})]})}function Mi({versionLabel:e,density:t}){let[n,i]=(0,F.useState)(!1);return(0,I.jsxs)(`span`,{className:`relative min-w-0 flex-1`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),children:[(0,I.jsx)(`span`,{tabIndex:0,"aria-label":e,className:r(`block min-w-0 truncate font-medium text-gray-500 outline-none`,`text-[12px]`),children:e}),n?(0,I.jsx)(`span`,{className:`pointer-events-none absolute left-0 top-full z-[var(--z-tooltip)] mt-1 w-max max-w-none whitespace-nowrap rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md`,children:e}):null]})}function Ni(){let{supported:e,busyAction:t,snapshot:n}=rt();return!e||!n?null:n.status===`downloading`||n.status===`blocked`||n.status===`failed`?(0,I.jsx)(Pi,{snapshot:n}):n.status===`downloaded`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-emerald-50 px-2 text-[11px] font-semibold leading-none text-emerald-700 ring-1 ring-emerald-100 transition-colors hover:bg-emerald-100 disabled:opacity-70`,disabled:t===`applying`,onClick:()=>void at.applyDownloadedUpdate(),children:s(t===`applying`?`desktopUpdatesInlineApplying`:`desktopUpdatesInlineReady`)}):n.status===`update-available`?(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,disabled:t===`downloading`,onClick:()=>void at.downloadUpdate(),children:s(t===`downloading`?`desktopUpdatesInlineDownloading`:`desktopUpdatesInlineDownload`)}):null}function Pi({snapshot:e}){if(e.status===`blocked`||e.status===`failed`)return(0,I.jsx)(Fi,{snapshot:e});let t=e.status===`downloading`?Ii(e):null;return t?(0,I.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded-full bg-amber-50 px-2 text-[11px] font-semibold leading-none text-amber-700 ring-1 ring-amber-100 transition-colors hover:bg-amber-100 disabled:opacity-70`,title:s(`updates`),children:t}):null}function Fi({snapshot:e}){let t=e.status===`failed`?s(`desktopUpdatesStatusFailed`):s(`desktopUpdatesStatusBlocked`),n=e.recoveryCommand?.trim()||null,r=e.errorMessage?.trim()||e.blockReason?.trim()||null,i=[t,e.status===`blocked`&&e.blockReason?s(`desktopUpdatesBlockedRootCause.${e.blockReason}`):null,r,n].filter(Boolean).join(`
3
+ `);return(0,I.jsx)(`span`,{role:`img`,"aria-label":t,title:i,tabIndex:0,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-50 text-[13px] font-bold leading-none text-amber-700 ring-1 ring-amber-100`,children:`!`})}function Ii(e){let t=e.progress?.percent;return t==null?s(`desktopUpdatesInlineDownloading`):s(`desktopUpdatesInlineDownloadingPercent`).replace(`{percent}`,String(t))}var Li=_(o(),1);function Ri(e,[t,n]){return Math.min(n,Math.max(t,e))}function zi(e){let t=e+`CollectionProvider`,[n,r]=Rt(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Nt(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:wt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Nt(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=wt(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Bi=F.createContext(void 0);function Vi(e){let t=F.useContext(Bi);return e||t||`ltr`}function Hi(e){let t=F.useRef({value:e,previous:e});return F.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ui=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Wi=[` `,`Enter`],Gi=`Select`,[Ki,qi,Ji]=zi(Gi),[Yi,Xi]=Rt(Gi,[Ji,Ft]),Zi=Ft(),[Qi,$i]=Yi(Gi),[ea,ta]=Yi(Gi),na=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Zi(t),[g,_]=F.useState(null),[v,y]=F.useState(null),[b,x]=F.useState(!1),S=Vi(l),[C,w]=Ot({prop:r,defaultProp:i??!1,onChange:a,caller:Gi}),[T,E]=Ot({prop:o,defaultProp:s,onChange:c,caller:Gi}),D=F.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=F.useState(new Set),ee=Array.from(k).map(e=>e.props.value).join(`;`);return(0,I.jsx)(Mt,{...h,children:(0,I.jsxs)(Qi,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Dt(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,I.jsx)(Ki.Provider,{scope:t,children:(0,I.jsx)(ea,{scope:e.__scopeSelect,onNativeOptionAdd:F.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:F.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,I.jsxs)(Za,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,I.jsx)(`option`,{value:``}):null,Array.from(k)]},ee):null]})})};na.displayName=Gi;var ra=`SelectTrigger`,ia=F.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Zi(n),o=$i(ra,n),s=o.disabled||r,c=wt(t,o.onTriggerChange),l=qi(n),u=F.useRef(`touch`),[d,f,p]=$a(e=>{let t=l().filter(e=>!e.disabled),n=eo(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,I.jsx)(Pt,{asChild:!0,...a,children:(0,I.jsx)(Et.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Qa(o.value)?``:void 0,...i,ref:c,onClick:Lt(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Lt(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Lt(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Ui.includes(e.key)&&(m(),e.preventDefault())})})})});ia.displayName=ra;var aa=`SelectValue`,oa=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=$i(aa,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=wt(t,c.onValueNodeChange);return St(()=>{l(u)},[l,u]),(0,I.jsx)(Et.span,{...s,ref:d,style:{pointerEvents:`none`},children:Qa(c.value)?(0,I.jsx)(I.Fragment,{children:o}):a})});oa.displayName=aa;var sa=`SelectIcon`,ca=F.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(Et.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ca.displayName=sa;var la=`SelectPortal`,ua=e=>(0,I.jsx)(At,{asChild:!0,...e});ua.displayName=la;var da=`SelectContent`,fa=F.forwardRef((e,t)=>{let n=$i(da,e.__scopeSelect),[r,i]=F.useState();if(St(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Li.createPortal((0,I.jsx)(ma,{scope:e.__scopeSelect,children:(0,I.jsx)(Ki.Slot,{scope:e.__scopeSelect,children:(0,I.jsx)(`div`,{children:e.children})})}),t):null}return(0,I.jsx)(va,{...e,ref:t})});fa.displayName=da;var pa=10,[ma,ha]=Yi(da),ga=`SelectContentImpl`,_a=Nt(`SelectContent.RemoveScroll`),va=F.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=$i(da,n),[y,b]=F.useState(null),[x,S]=F.useState(null),C=wt(t,e=>b(e)),[w,T]=F.useState(null),[E,D]=F.useState(null),O=qi(n),[k,A]=F.useState(!1),ee=F.useRef(!1);F.useEffect(()=>{if(y)return Ht(y)},[y]),Vt();let j=F.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),te=F.useCallback(()=>j([w,y]),[j,w,y]);F.useEffect(()=>{k&&te()},[k,te]);let{onOpenChange:M,triggerPointerDownPosRef:ne}=v;F.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(ne.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ne.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||M(!1),document.removeEventListener(`pointermove`,t),ne.current=null};return ne.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,M,ne]),F.useEffect(()=>{let e=()=>M(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[M]);let[re,ie]=$a(e=>{let t=O().filter(e=>!e.disabled),n=eo(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ae=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(ee.current=!0))},[v.value]),oe=F.useCallback(()=>y?.focus(),[y]),se=F.useCallback((e,t,n)=>{let r=!ee.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ce=r===`popper`?Sa:ba,le=ce===Sa?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,I.jsx)(ma,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ae,selectedItem:w,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:te,selectedItemText:E,position:r,isPositioned:k,searchRef:re,children:(0,I.jsx)(Bt,{as:_a,allowPinchZoom:!0,children:(0,I.jsx)(zt,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Lt(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(It,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,I.jsx)(ce,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...le,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Lt(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ie(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>j(t)),e.preventDefault()}})})})})})})});va.displayName=ga;var ya=`SelectItemAlignedPosition`,ba=F.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=$i(da,n),o=ha(da,n),[s,c]=F.useState(null),[l,u]=F.useState(null),d=wt(t,e=>u(e)),f=qi(n),p=F.useRef(!1),m=F.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=F.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-pa,d=Ri(a,[pa,Math.max(pa,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-pa,d=Ri(a,[pa,Math.max(pa,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-pa*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-pa,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,ee=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+ee;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${pa}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);St(()=>y(),[y]);let[b,x]=F.useState();return St(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,I.jsx)(Ca,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:F.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,I.jsx)(Et.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ba.displayName=ya;var xa=`SelectPopperPosition`,Sa=F.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=pa,...a}=e,o=Zi(n);return(0,I.jsx)(Ct,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Sa.displayName=xa;var[Ca,wa]=Yi(da,{}),Ta=`SelectViewport`,Ea=F.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=ha(Ta,n),o=wa(Ta,n),s=wt(t,a.onViewportChange),c=F.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(Ki.Slot,{scope:n,children:(0,I.jsx)(Et.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Lt(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-pa*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Ea.displayName=Ta;var Da=`SelectGroup`,[Oa,ka]=Yi(Da),Aa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Dt();return(0,I.jsx)(Oa,{scope:n,id:i,children:(0,I.jsx)(Et.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Aa.displayName=Da;var ja=`SelectLabel`,Ma=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ka(ja,n);return(0,I.jsx)(Et.div,{id:i.id,...r,ref:t})});Ma.displayName=ja;var Na=`SelectItem`,[Pa,Fa]=Yi(Na),Ia=F.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=$i(Na,n),c=ha(Na,n),l=s.value===r,[u,d]=F.useState(a??``),[f,p]=F.useState(!1),m=wt(t,e=>c.itemRefCallback?.(e,r,i)),h=Dt(),g=F.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,I.jsx)(Pa,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:F.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(Ki.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,I.jsx)(Et.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Lt(o.onFocus,()=>p(!0)),onBlur:Lt(o.onBlur,()=>p(!1)),onClick:Lt(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:Lt(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:Lt(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Lt(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lt(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Lt(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Wi.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Ia.displayName=Na;var La=`SelectItemText`,Ra=F.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=$i(La,n),s=ha(La,n),c=Fa(La,n),l=ta(La,n),[u,d]=F.useState(null),f=wt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=F.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return St(()=>(h(m),()=>g(m)),[h,g,m]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Et.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Li.createPortal(a.children,o.valueNode):null]})});Ra.displayName=La;var za=`SelectItemIndicator`,Ba=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Fa(za,n).isSelected?(0,I.jsx)(Et.span,{"aria-hidden":!0,...r,ref:t}):null});Ba.displayName=za;var Va=`SelectScrollUpButton`,Ha=F.forwardRef((e,t)=>{let n=ha(Va,e.__scopeSelect),r=wa(Va,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Ga,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ha.displayName=Va;var Ua=`SelectScrollDownButton`,Wa=F.forwardRef((e,t)=>{let n=ha(Ua,e.__scopeSelect),r=wa(Ua,e.__scopeSelect),[i,a]=F.useState(!1),o=wt(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Ga,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Wa.displayName=Ua;var Ga=F.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=ha(`SelectScrollButton`,n),o=F.useRef(null),s=qi(n),c=F.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return F.useEffect(()=>()=>c(),[c]),St(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(Et.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Lt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Lt(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Lt(i.onPointerLeave,()=>{c()})})}),Ka=`SelectSeparator`,qa=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,I.jsx)(Et.div,{"aria-hidden":!0,...r,ref:t})});qa.displayName=Ka;var Ja=`SelectArrow`,Ya=F.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Zi(n),a=$i(Ja,n),o=ha(Ja,n);return a.open&&o.position===`popper`?(0,I.jsx)(kt,{...i,...r,ref:t}):null});Ya.displayName=Ja;var Xa=`SelectBubbleInput`,Za=F.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=F.useRef(null),a=wt(r,i),o=Hi(t);return F.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,I.jsx)(Et.select,{...n,style:{...jt,...n.style},ref:a,defaultValue:t})});Za.displayName=Xa;function Qa(e){return e===``||e===void 0}function $a(e){let t=Tt(e),n=F.useRef(``),r=F.useRef(0),i=F.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=F.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return F.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function eo(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=to(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function to(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var no=na,ro=ia,io=oa,ao=ca,oo=ua,so=fa,co=Ea,lo=Aa,uo=Ma,fo=Ia,po=Ra,mo=Ba,ho=Ha,go=Wa,_o=qa,vo=no,yo=io,bo=F.forwardRef(({className:e,children:t,indicator:n,...i},a)=>(0,I.jsxs)(ro,{ref:a,className:r(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 bg-white`,e),...i,children:[t,(0,I.jsx)(ao,{asChild:!0,children:n??(0,I.jsx)(Ln,{className:`h-4 w-4 opacity-50`})})]}));bo.displayName=ro.displayName;var xo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(ho,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(zn,{className:`h-4 w-4`})}));xo.displayName=ho.displayName;var So=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:r(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Ln,{className:`h-4 w-4`})}));So.displayName=go.displayName;var Co=F.forwardRef(({className:e,children:t,position:n=`popper`,viewportClassName:i,...a},o)=>(0,I.jsx)(oo,{children:(0,I.jsxs)(so,{ref:o,className:r(`relative z-[var(--z-popover,50)] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-white`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...a,children:[(0,I.jsx)(xo,{}),(0,I.jsx)(co,{className:r(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,i),children:t}),(0,I.jsx)(So,{})]})}));Co.displayName=so.displayName;var wo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(uo,{ref:n,className:r(`px-2 py-1.5 text-sm font-semibold`,e),...t}));wo.displayName=uo.displayName;var To=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsxs)(fo,{ref:i,className:r(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(mo,{children:(0,I.jsx)(In,{className:`h-4 w-4`})})}),(0,I.jsx)(po,{children:t})]}));To.displayName=fo.displayName;var Eo=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:r(`-mx-1 my-1 h-px bg-muted`,e),...t}));Eo.displayName=_o.displayName;var Do={default:{row:`gap-3 px-3 py-2.5 text-[14px]`,icon:`h-[17px] w-[17px]`,value:`text-xs`,gap:`gap-3`},compact:{row:`gap-2.5 px-3 py-2 text-[13px]`,icon:`h-4 w-4`,value:`text-[11px]`,gap:`gap-2.5`}};function Oo(e){return Do[e]}function ko({to:e,label:t,icon:n,density:i=`default`,className:a}){let o=Oo(i);return(0,I.jsx)(w,{to:e,className:({isActive:e})=>r(`group flex w-full items-center rounded-xl font-medium transition-colors duration-base`,o.row,e?`bg-gray-200 text-gray-900 shadow-sm`:`text-gray-600 hover:bg-gray-200/60 hover:text-gray-900`,a),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n,{className:r(o.icon,`transition-colors`,e?`text-gray-900`:`text-gray-500 group-hover:text-gray-800`)}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:t})]})})}function Ao({label:e,icon:t,onClick:n,density:i=`default`,className:a,labelClassName:o,trailing:s,trailingClassName:c,testId:l,trailingTestId:u}){let d=Oo(i);return(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:r(`flex w-full items-center rounded-xl font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,d.row,a),"data-testid":l,children:[(0,I.jsx)(t,{className:r(d.icon,`shrink-0 text-gray-400`)}),(0,I.jsx)(`span`,{className:r(`min-w-0 flex-1 text-left`,o),children:e}),s?(0,I.jsx)(`span`,{className:r(`shrink-0 text-gray-500`,d.value,c),"data-testid":u,children:s}):null]})}function jo({label:e,icon:t,value:n,valueLabel:i,onValueChange:a,density:o=`default`,children:s}){let c=Oo(o);return(0,I.jsxs)(vo,{value:n,onValueChange:a,children:[(0,I.jsxs)(bo,{className:r(`h-auto w-full rounded-xl border-0 bg-transparent font-medium text-gray-600 shadow-none hover:bg-gray-200/60 focus:ring-0`,c.row),children:[(0,I.jsxs)(`div`,{className:r(`flex min-w-0 items-center`,c.gap),children:[(0,I.jsx)(t,{className:r(c.icon,`text-gray-400`)}),(0,I.jsx)(`span`,{className:`text-left`,children:e})]}),(0,I.jsx)(`span`,{className:r(`ml-auto text-gray-500`,c.value),children:i})]}),(0,I.jsx)(Co,{children:s})]})}var Mo=`nextclaw-pwa-install-banner-dismissed`,No=`nextclaw-pwa-install-banner-dismissed-until`;function Po(){let e=Lo();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:Ro(e):!1}function Fo(){let e=Lo();e?.setItem(Mo,`1`),e?.removeItem(No)}function Io(){let e=Lo();e?.removeItem(Mo),e?.removeItem(No)}function Lo(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function Ro(e){let t=e.getItem(No);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(No),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(Mo,`1`),!0)}function zo(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:Po()}}var Bo=m(()=>zo()),Vo=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),Bo.setState(zo())},this.refreshState=()=>{let e=this.resolveInstallability();Bo.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:Po()}))},this.dismissInstallPrompt=()=>{Fo(),Bo.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(Io(),this.refreshState(),N.success(s(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,Io(),Bo.setState({dismissedInstallPrompt:!0}),N.success(s(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}};function Ho(){let e=Bo(e=>e.installability);return(0,I.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:Uo(e)})}function Uo(e){return s(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function Wo(e,t,n){return s(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function Go(){let e=Bo(e=>e.installability),t=Bo(e=>e.installMethod),n=Bo(e=>e.blockedReason);return(0,I.jsxs)(_e,{children:[(0,I.jsxs)(ot,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(fe,{children:s(`pwaInstallTitle`)}),(0,I.jsx)(je,{children:s(`pwaInstallDescription`)})]}),(0,I.jsx)(Ho,{})]}),(0,I.jsxs)(ge,{className:`space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50/90 p-4`,children:(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-700`,children:Wo(e,t,n)})}),e===`available`&&t===`prompt`?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,className:`gap-2`,onClick:()=>{Vo.promptInstall()},children:[(0,I.jsx)(Un,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500`,children:s(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,I.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl border border-dashed border-gray-300 bg-white p-4`,children:[(0,I.jsx)(yr,{className:`mt-0.5 h-4 w-4 text-gray-500`}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallManualHint`)})]}):null]})]})}function Ko(){let e=Bo(e=>e.installability),t=Bo(e=>e.installMethod),n=Bo(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,I.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:s(`pwaInstallBannerTitle`)}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:s(`pwaInstallBannerDescription`)})]}),(0,I.jsx)(`button`,{type:`button`,"aria-label":s(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600`,onClick:()=>{Vo.dismissInstallPrompt()},children:(0,I.jsx)(gn,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,I.jsxs)(ye,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{Vo.promptInstall()},children:[(0,I.jsx)(Un,{className:`h-4 w-4`}),s(`pwaInstallAction`)]}),(0,I.jsx)(ye,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{Vo.dismissInstallPrompt()},children:s(`pwaInstallDismiss`)})]})]})}var qo=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},Jo=!1;function Yo(){Jo||typeof window>`u`||(Jo=!0,Vo.start(),qo.start())}var Xo={warm:`#F9F8F5`,cool:`#F8FAFB`},Zo=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let t=Xo[e];this.updateThemeMeta(t),this.updateSurfaceBackgrounds(t),document.documentElement.style.colorScheme=`light`},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let e=document.documentElement.getAttribute(`data-theme`)===`cool`?`cool`:`warm`;this.syncTheme(e)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},Qo=(0,F.createContext)(null);function $o({children:e}){let[t,n]=(0,F.useState)(()=>ei());(0,F.useEffect)(()=>{Zo.syncTheme(t)},[t]),(0,F.useEffect)(()=>ri(e=>{n(e)}),[]);let r=(0,F.useCallback)(e=>{ni(e),n(ti())},[]),i=(0,F.useMemo)(()=>({theme:t,setTheme:r}),[t,r]);return(0,I.jsx)(Qo.Provider,{value:i,children:e})}function es(){let e=(0,F.useContext)(Qo);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function ts(){let{language:e,setLanguage:n}=kr();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,F.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}function ns(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=ts();return(0,I.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(cr,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:s(`language`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,I.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(t.value),className:r(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,I.jsx)(In,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function rs({mode:e}){let t=re(),n=Dn(),i=le(),{currentLanguage:a,currentLanguageLabel:o,languageOptions:c,selectLanguage:l}=ts(),{theme:u,setTheme:d}=es(),f=e===`settings`,p=s(qr.find(e=>e.value===u)?.labelKey??`themeWarm`),m=i.data?.account.email?.trim(),h=!!i.data?.account.loggedIn,g=e=>{u!==e&&d(e)},_=[{target:`/chat`,label:s(`chat`),icon:lr},{target:`/chat/cron`,label:s(`cron`),icon:jn},{target:`/chat/skills`,label:s(`marketplaceFilterSkills`),icon:E},{target:`/agents`,label:s(`agentsPageTitle`),icon:Pn}],v=Hr(s),y=f?v:_,b=f?`compact`:`default`;return(0,I.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 pb-6`,children:[f?(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,I.jsxs)(w,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,I.jsx)(`span`,{className:`truncate`,children:s(`backToMain`)})]}),(0,I.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,I.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:s(`settings`)})]})}):(0,I.jsx)(`div`,{className:`shrink-0 px-2 py-2.5`,children:(0,I.jsx)(ji,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,I.jsx)(`ul`,{className:r(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(ko,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,I.jsxs)(`div`,{className:r(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,I.jsx)(Ao,{onClick:()=>t.accountManager.openAccountPanel(),icon:fn,label:s(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:h?m||s(`remoteAccountEntryConnected`):s(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(ko,{to:`/settings`,label:s(`settings`),icon:_r})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(jo,{value:u,onValueChange:e=>g(e),icon:pr,label:s(`theme`),valueLabel:p,density:b,children:qr.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-xs`,children:s(e.labelKey)},e.value))})}),(0,I.jsx)(`div`,{className:`mb-2`,children:(0,I.jsx)(jo,{value:a,onValueChange:e=>l(e),icon:cr,label:s(`language`),valueLabel:o,density:b,children:c.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,I.jsx)(Ao,{onClick:()=>n.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),icon:Qt,label:s(`docBrowserHelp`),density:b})]})]})]})}var is=[{action:`minimize`,label:`Minimize`,icon:fr},{action:`close`,label:`Close`,icon:gn,variant:`danger`}];function as(){let e=ss()?{action:`toggle-maximize`,label:`Restore`,icon:Vn}:{action:`toggle-maximize`,label:`Maximize`,icon:xr};return(0,I.jsxs)(`header`,{className:`desktop-window-drag relative flex h-[var(--desktop-titlebar-height)] shrink-0 bg-secondary after:absolute after:bottom-0 after:left-[var(--desktop-sidebar-width)] after:right-0 after:border-b after:border-[#ebe7dc]/80`,"data-testid":`desktop-window-chrome`,children:[(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute left-0 right-0 top-0 h-1`,"data-testid":`desktop-window-chrome-resize-strip`}),(0,I.jsx)(`div`,{className:`desktop-window-drag relative z-10 flex h-full w-[var(--desktop-sidebar-width)] shrink-0 items-center bg-secondary pl-4 pr-3 text-secondary-foreground`,"data-testid":`desktop-window-chrome-sidebar`,children:(0,I.jsx)(ji,{className:`flex min-w-0 shrink-0 items-center gap-2.5`,density:`chrome`})}),(0,I.jsx)(`div`,{className:`desktop-window-no-drag absolute right-0 top-0 z-20 flex h-full w-[var(--desktop-caption-safe-right)] items-start justify-end`,"data-testid":`desktop-window-controls`,children:[is[0],e,is[1]].map(e=>(0,I.jsx)(os,{control:e},e.action))})]})}function os({control:e}){let t=e.icon;return(0,I.jsx)(`button`,{type:`button`,"aria-label":e.label,title:e.label,className:e.variant===`danger`?`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-red-500 hover:text-white`:`desktop-window-no-drag flex h-10 w-[46px] items-center justify-center text-gray-700 transition-colors hover:bg-black/10`,onClick:()=>{window.nextclawDesktop?.controlWindow?.(e.action)},children:(0,I.jsx)(t,{className:`h-3.5 w-3.5`})})}function ss(){let[e,t]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{let e=!0,n=window.nextclawDesktop;n?.getWindowState?.().then(n=>{e&&t(n.isMaximized)});let r=n?.onWindowStateChanged?.(e=>{t(e.isMaximized)});return()=>{e=!1,r?.()}},[]),e}function cs(){return typeof window>`u`?null:us()??window.nextclawDesktop?.platform??null}function ls(){return cs()===`win32`}function us(){return null}function ds(e,t){if(t===`/settings`)return Wr(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function fs(){let{pathname:e}=S(),t=Vr(s);return(0,I.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":s(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,I.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=ds(e,t.target);return(0,I.jsx)(`li`,{children:(0,I.jsx)(v,{to:t.target,"aria-current":n?`page`:void 0,className:r(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,I.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:r(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,I.jsx)(t.icon,{className:r(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,I.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function ps({leadingInset:e}){let t=C(),{pathname:n}=S(),r=Gr(n,s);return(0,I.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,I.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 py-1.5 pl-3 pr-3`,style:{paddingLeft:e?`calc(${e} + 0.75rem)`:void 0},children:[r.backTarget?(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(r.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":r.backLabel??s(`backToMain`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:r.title})}),r.backTarget?(0,I.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var ms=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-D5FJcAyz.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function hs({pathname:e,isDocBrowserOpen:t,docBrowserDockControls:n,docBrowserRenderers:r={},topbarLeadingInset:i,children:a}){let o=zr(e),s=!Br(e),c=!Br(e);return(0,I.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[s?(0,I.jsx)(ps,{leadingInset:i}):null,(0,I.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:o?(0,I.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:a}):(0,I.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:a})})}),c?(0,I.jsx)(fs,{}):null,t?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(ms,{customTabRenderers:r,displayMode:`fullscreen`,dockControls:n})}):null]})}function gs(){let e=Ur(s);return(0,I.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,I.jsxs)(w,{to:e.target,className:({isActive:e})=>r(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,I.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,I.jsx)(e.icon,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`min-w-0`,children:(0,I.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function _s({isProjectFirstView:e,onSelectMode:t}){return(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>t(`time-first`),className:r(`transition-colors`,e?`text-gray-400 hover:text-gray-600`:`font-medium text-gray-600`),children:s(`chatSidebarViewTime`)}),(0,I.jsx)(`span`,{className:`text-gray-300`,children:`/`}),(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:()=>t(`project-first`),className:r(`transition-colors`,e?`font-medium text-gray-600`:`text-gray-400 hover:text-gray-600`),children:s(`chatSidebarViewProject`)})]})}var vs={telegram:`telegram.svg`,slack:`slack.svg`,discord:`discord.svg`,whatsapp:`whatsapp.svg`,qq:`qq.svg`,feishu:`feishu.svg`,dingtalk:`dingtalk.svg`,wecom:`wecom.svg`,weixin:`weixin.svg`,email:`email.svg`};function ys(e,t){let n=e[t.toLowerCase()];return n?`/logos/${n}`:null}function bs(e){return ys(vs,e)}var xs={wx:`weixin`,lark:`feishu`},Ss={cron:{icon:`cron`}},Cs={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function ws(e){return e?.trim().toLowerCase()??``}function Ts(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Es(e,t){let n=ws(e);if(!n||n===`native`)return null;let r=t.find(e=>ws(e.value)===n);return r?.label.trim()?r.label.trim():Ts(n)}function Ds(e,t){let n=ws(e);return!n||n===`native`?null:t.find(e=>ws(e.value)===n)??null}function Os(e){let t=ws(e);if(!t)return null;let n=xs[t]??t;return bs(n)?n:null}function ks(e,t){let n=Os(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=Ss[ws(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=ws(e.sessionType),a=Ds(i,t);if(a?.icon?.src?.trim())return{icon:{kind:`runtime-image`,src:a.icon.src,alt:a.icon.alt??null,name:a.label},label:null};let o=Cs[i];return o?{icon:null,label:s(o)}:{icon:null,label:a?.label?.trim()||Es(e.sessionType,t)}}var As=`app://`;function js(e){let t=e.trim().replace(/^\/+/,``);if(!t)return null;let n=t.split(`/`);return n.some(e=>e.trim().length===0||e===`.`||e===`..`)?null:n.join(`/`)}function Ms(e){let t=e.trim();if(!t)return null;if(!t.startsWith(As))return t;let n=js(t.slice(6));return n?`/${n}`:null}function Ns({name:e,src:t,className:n,imgClassName:i,fallback:a}){let[o,s]=(0,F.useState)(!1),c=!!t&&!o;return(0,I.jsx)(`div`,{className:r(`inline-flex shrink-0 items-center justify-center overflow-hidden`,n),children:c?(0,I.jsx)(`img`,{src:t,alt:`${e} logo`,className:r(`block h-6 w-6 object-contain`,i),onError:()=>s(!0),draggable:!1}):a??(0,I.jsx)(`span`,{className:`text-lg font-bold uppercase`,children:e.slice(0,1)})})}function Ps({icon:e,className:t}){if(e.kind===`channel-logo`)return(0,I.jsx)(Fs,{channel:e.channel,className:t});if(e.kind===`runtime-image`){let n=Ms(e.src);return(0,I.jsx)(Ns,{name:e.name?.trim()||e.alt?.trim()||`runtime`,src:n??void 0,className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Pn,{className:r(`h-3 w-3 text-gray-500`,t)})})}return(0,I.jsx)(jn,{className:r(`h-3.5 w-3.5`,t)})}function Fs({channel:e,className:t}){return(0,I.jsx)(Ns,{name:e,src:bs(e),className:r(`h-[1.125rem] w-[1.125rem]`,t),imgClassName:`h-full w-full object-contain`,fallback:(0,I.jsx)(Pn,{className:`h-3 w-3 text-gray-500`})})}function Is(e){let{option:t,onSelect:n}=e,i=t.ready===!1?t.reasonMessage?.trim()||s(`statusSetup`):null;return(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`w-full rounded-2xl px-3 py-2.5 text-left transition-colors hover:bg-gray-50`,children:(0,I.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[t.icon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5`,children:(0,I.jsx)(Ps,{icon:{kind:`runtime-image`,src:t.icon.src,alt:t.icon.alt??null,name:t.label}})}):(0,I.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center pt-0.5 text-gray-400`,children:(0,I.jsx)(Pn,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-gray-900`,children:t.label}),(0,I.jsxs)(`span`,{className:r(`inline-flex shrink-0 items-center gap-1.5 text-[11px] font-medium`,t.ready===!1?`text-amber-700`:`text-emerald-600`),children:[(0,I.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,t.ready===!1?`bg-amber-500`:`bg-emerald-500`)}),t.ready===!1?s(`statusSetup`):s(`statusReady`)]})]}),i?(0,I.jsx)(`div`,{className:`mt-1 pr-4 text-[11px] leading-4 text-gray-500`,children:i}):null]})]})})})}function Ls(e,t){return t.some(t=>t.value===e)?e:t[0]?.value??e}function Rs(e){let{groups:t,defaultSessionType:n,sessionTypeOptions:r,renderSessionItem:i,onCreateSession:a}=e,[o,c]=(0,F.useState)(null),l=(0,F.useMemo)(()=>Ls(n,r),[n,r]),u=r.length>1;return(0,I.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=`${s(`chatSidebarNewTask`)} · ${e.projectName}`;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 py-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`div`,{className:`truncate text-[11px] font-medium uppercase tracking-wider text-gray-500`,title:e.projectRoot,children:e.projectName}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] text-gray-400`,children:e.items.length})]}),u?(0,I.jsxs)(wn,{open:o===e.projectRoot,onOpenChange:t=>{c(t?e.projectRoot:null)},children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,"aria-label":t,title:t,children:(0,I.jsx)(pn,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:r.map(t=>(0,I.jsx)(Is,{option:t,onSelect:()=>{a(t.value,e.projectRoot),c(null)}},`${e.projectRoot}:${t.value}`))})]})]}):(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 shrink-0 rounded-lg text-gray-400 hover:bg-white hover:text-gray-900`,onClick:()=>a(l,e.projectRoot),"aria-label":t,title:t,children:(0,I.jsx)(pn,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`space-y-0.5 pl-2`,children:e.items.map(i)})]},e.projectRoot)})})}var zs=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function Bs(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function Vs({agentId:e,displayName:t,avatarUrl:n,className:i}){let a=t?.trim()||e,[o,s]=zs[Bs(e)%zs.length]??zs[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:r(`rounded-full object-cover`,i)}):(0,I.jsx)(`div`,{className:r(`rounded-full flex items-center justify-center font-semibold`,o,s,i),"aria-label":t?.trim()||e,children:e.trim().toLowerCase()===`main`?(0,I.jsx)(Pn,{className:`h-[55%] w-[55%]`,strokeWidth:2.4}):(a.trim()||`A`).slice(0,1).toUpperCase()})}function Hs({status:e,className:t}){let n=s(e===`running`?`sessionsRunStatusRunning`:`sessionsRunStatusQueued`);return(0,I.jsxs)(`span`,{className:r(`inline-flex h-3.5 w-3.5 items-center justify-center text-gray-400`,t),title:n,"aria-label":n,children:[(0,I.jsx)($t,{className:`h-3 w-3 animate-spin`}),(0,I.jsx)(`span`,{className:`sr-only`,children:n})]})}function Us(e){let t=e.label?.trim();if(t)return t;let n=e.key.split(`:`);return n[n.length-1]||e.key}function Ws(e){let t=e.activityPreview;return t?t.state===`failed`||t.state===`running`?t.statusText??t.replyText??null:t.state===`completed`?t.replyText??t.statusText??null:t.statusText??t.replyText??null:null}function Gs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Ks(e,t){return e.getFullYear()===t.getFullYear()}function qs(e,t){let n=`${e.getMonth()+1}月${e.getDate()}日`;return Ks(e,t)?n:`${e.getFullYear()}年${n}`}function Js(e,t=d(),n=new Date){if(!e)return`-`;let r=e instanceof Date?e:new Date(e);if(Number.isNaN(r.getTime()))return typeof e==`string`?e:`-`;let i=p(t),a=Gs(r),o=Gs(n),c=Math.floor((o-a)/864e5);if(c===0)return new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r);if(c===1)return s(`chatSidebarYesterday`,t);if(c>1&&c<7)return new Intl.DateTimeFormat(i,{weekday:`long`}).format(r);if(t===`zh`)return qs(r,n);let l=Ks(r,n)?{month:`numeric`,day:`numeric`}:{year:`numeric`,month:`numeric`,day:`numeric`};return new Intl.DateTimeFormat(i,l).format(r)}function Ys(e){return e.trim().toLowerCase()}function Xs(e,t){let n=Ys(t);return n?[e.key,Us(e),e.projectRoot??``,e.projectName??``].map(Ys).some(e=>e.includes(n)):!0}function Zs({session:e,draftLabel:t,isSaving:n,onDraftLabelChange:r,onSave:i,onCancel:a}){return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Ne,{value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),a())},placeholder:s(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:n}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:e.key}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(ye,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void i(),disabled:n,"aria-label":s(`save`),children:(0,I.jsx)(In,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ye,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:a,disabled:n,"aria-label":s(`cancel`),children:(0,I.jsx)(gn,{className:`h-3.5 w-3.5`})})]})]})]})}function Qs({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:c,agentLabel:l,agentAvatarUrl:u,childSessionCount:d=0,onSelect:f,onOpenChildSessions:p,onStartEditing:m}){let h=d>0&&p?`pr-14`:`pr-6`,g=Ws(e),_=`${l?.trim()?`${l} · `:``}${e.messageCount}`;return(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,I.jsx)(`div`,{className:r(`flex min-w-0 items-start`,h),children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c?.trim()&&c.trim().toLowerCase()!==`main`?(0,I.jsx)(Vs,{agentId:c,displayName:l,avatarUrl:u,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:o}),a.label?(0,I.jsx)(`span`,{className:r(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,t?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:a.label}):null,a.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)(Ps,{icon:a.icon,className:t?`text-gray-700`:`text-gray-500`})}):null]})}),(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[11px] text-gray-400`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate`,children:g??_}),n?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`ml-auto h-2 w-2 shrink-0 rounded-full bg-primary`}):(0,I.jsx)(`span`,{className:`ml-auto shrink-0`,children:Js(e.lastMessageAt??e.createdAt)})]})]}),d>0&&p?(0,I.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},className:r(`absolute right-6 top-0 inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[10px] font-medium text-gray-400 transition-all hover:bg-white hover:text-gray-900`,t?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),children:[(0,I.jsx)(ar,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:d})]}):null,i?(0,I.jsx)(`span`,{className:`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center transition-opacity group-hover/session:opacity-0 group-focus-within/session:opacity-0`,children:(0,I.jsx)(Hs,{status:i})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m()},className:r(`absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-md text-gray-400 transition-all hover:bg-white hover:text-gray-900`,`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":s(`edit`),children:(0,I.jsx)(hr,{className:`h-3 w-3`})})]})}function $s({session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,childSessionCount:u,isEditing:d,draftLabel:f,isSaving:p,onSelect:m,onOpenChildSessions:h,onStartEditing:g,onDraftLabelChange:_,onSave:v,onCancel:y}){return(0,I.jsx)(`div`,{className:r(`w-full rounded-xl px-3 py-2.5 text-left transition-all text-[13px]`,t?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:d?(0,I.jsx)(Zs,{session:e,draftLabel:f,isSaving:p,onDraftLabelChange:_,onSave:v,onCancel:y}):(0,I.jsx)(Qs,{session:e,active:t,showUnreadDot:n,runStatus:i,context:a,title:o,agentId:s,agentLabel:c,agentAvatarUrl:l,onSelect:m,childSessionCount:u,onOpenChildSessions:h,onStartEditing:g})})}var ec=[{icon:lr,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:E,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:jn,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function tc({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`min-h-full flex items-center justify-center px-4 py-6 sm:p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full min-w-0 text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(Pn,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:s(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:s(`chatWelcomeSubtitle`)}),(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:s(`chatDraftAgentTitle`)}),(0,I.jsxs)(vo,{value:n,onValueChange:r,children:[(0,I.jsxs)(bo,{"aria-label":s(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:s(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(Vs,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(Co,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(To,{value:e.id,className:`rounded-lg pr-10`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(Vs,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,9.5rem),1fr))] gap-3`,children:ec.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`min-w-0 rounded-2xl border border-gray-200 bg-white p-3 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer sm:p-4`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:s(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:s(t.descKey)})]},t.titleKey)})})]})})}var nc=(0,F.createContext)(null);function rc({presenter:e,children:t}){return(0,I.jsx)(nc.Provider,{value:e,children:t})}function ic(){let e=(0,F.useContext)(nc);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var ac=e=>`[data-item-index="${e}"]`;function oc(e){let{activeIndex:t,containerRef:n,getItemSelector:r,isEnabled:i,itemCount:a}=e,o=r??ac;(0,F.useEffect)(()=>{if(!i||a===0)return;let e=n.current;if(!e)return;let r=e.querySelector(o(t));typeof r?.scrollIntoView==`function`&&r.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,n,o,i,a])}function sc(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function L(...e){return i(f(e))}var cc=F.forwardRef(({className:e,type:t,...n},r)=>(0,I.jsx)(`input`,{type:t,className:L(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));cc.displayName=`ChatInput`;var lc=Cn,uc=vn,dc=yn,fc=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(xn,{children:(0,I.jsx)(_n,{ref:i,sideOffset:t,align:n,className:L(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));fc.displayName=_n.displayName;var pc=no,mc=lo,hc=io,gc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(ro,{ref:r,className:L(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,I.jsx)(ao,{asChild:!0,children:(0,I.jsx)(Ln,{className:`h-4 w-4 opacity-50`})})]}));gc.displayName=ro.displayName;var _c=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(ho,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(zn,{className:`h-4 w-4`})}));_c.displayName=ho.displayName;var vc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(go,{ref:n,className:L(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(Ln,{className:`h-4 w-4`})}));vc.displayName=go.displayName;var yc=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(oo,{children:(0,I.jsxs)(so,{ref:i,className:L(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,I.jsx)(_c,{}),(0,I.jsx)(co,{className:L(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,I.jsx)(vc,{})]})}));yc.displayName=so.displayName;var bc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(uo,{ref:n,className:L(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));bc.displayName=uo.displayName;var xc=F.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(fo,{ref:r,className:L(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(mo,{children:(0,I.jsx)(In,{className:`h-4 w-4`})})}),(0,I.jsx)(po,{children:t})]}));xc.displayName=fo.displayName;var Sc=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(_o,{ref:n,className:L(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Sc.displayName=_o.displayName;var Cc=cn,wc=tn,Tc=rn,Ec=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(on,{children:(0,I.jsx)(en,{ref:r,sideOffset:t,className:L(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));Ec.displayName=en.displayName;var Dc={Popover:lc,PopoverAnchor:dc,PopoverContent:fc,PopoverTrigger:uc,Input:cc,Select:pc,SelectContent:yc,SelectGroup:mc,SelectItem:xc,SelectLabel:bc,SelectSeparator:Sc,SelectTrigger:gc,SelectValue:hc,Tooltip:wc,TooltipContent:Ec,TooltipProvider:Cc,TooltipTrigger:Tc},Oc=680,kc=.82,Ac=560;function jc(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Dc,{elementRef:i,width:a}=sc(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onDetailsPointerDown:h,onSetActiveIndex:g}=e,_=(0,F.useMemo)(()=>{if(a)return Math.min(a>Ac?a*kc:a,Oc)},[a]);return oc({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,I.jsxs)(t,{open:s,onOpenChange:m,children:[(0,I.jsx)(n,{asChild:!0,children:(0,I.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,I.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:_?{width:`${_}px`}:void 0,children:(0,I.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,I.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,I.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,I.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>g(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,I.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,I.jsx)(`div`,{className:`min-w-0 p-2.5`,onPointerDown:h,children:d?(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,I.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,I.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,I.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var Mc=Ce(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),Nc=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:L(Mc({variant:t,size:n,className:e})),ref:i,...r}));Nc.displayName=`ChatButton`;var Pc=120;function Fc(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=Pc?t:`${t.slice(0,Pc-1)}…`}function Ic(){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function Lc({contextWindow:e}){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Dc,a=Math.max(0,Math.min(1,e.ratio)),o=Math.round(a*360);return(0,I.jsx)(r,{delayDuration:0,children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":e.label,title:e.label,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[7px] rounded-full`,style:{background:`conic-gradient(#9ca3af ${o}deg, #e5e7eb 0deg)`}}),(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-[10px] rounded-full bg-white`})]})}),(0,I.jsx)(n,{side:`top`,className:`max-w-[18rem]`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 font-semibold text-gray-800`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{children:e.percentLabel})]}),e.details.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-5 text-gray-600`,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`font-medium text-gray-800`,children:e.value})]},e.label))]})})]})})}function Rc({sendError:e,sendErrorDetailsLabel:t,isSending:n,canStopGeneration:r,sendDisabled:i,stopDisabled:a,stopHint:o,sendButtonLabel:s,stopButtonLabel:c,contextWindow:l,onSend:u,onStop:d}){let{Popover:f,PopoverContent:p,PopoverTrigger:m,Tooltip:h,TooltipContent:g,TooltipProvider:_,TooltipTrigger:v}=Dc,y=e?.trim()??``,b=y?Fc(y):``,x=t?.trim()||`Details`;return(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[y?(0,I.jsxs)(`div`,{className:`flex max-w-[420px] items-start justify-end gap-2 text-right`,children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1 text-[11px] text-red-600`,children:(0,I.jsx)(`span`,{className:`block truncate`,title:y,children:b})}),(0,I.jsxs)(f,{children:[(0,I.jsx)(m,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-full border border-red-200/80 bg-red-50 px-2 py-0.5 text-[10px] font-semibold text-red-700 transition-colors hover:bg-red-100`,children:x})}),(0,I.jsxs)(p,{align:`end`,className:`w-[min(32rem,calc(100vw-1.5rem))] border-red-100/80 p-0`,children:[(0,I.jsx)(`div`,{className:`border-b border-red-100 bg-red-50/80 px-4 py-2 text-xs font-semibold text-red-700`,children:x}),(0,I.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words px-4 py-3 text-xs leading-relaxed text-red-700`,children:y})]})]})]}):null,(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l?(0,I.jsx)(Lc,{contextWindow:l}):null,n?r?(0,I.jsx)(Nc,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,onClick:()=>void d(),disabled:a,children:(0,I.jsx)(Ic,{})}):(0,I.jsx)(_,{children:(0,I.jsxs)(h,{children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(Nc,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":c,disabled:!0,children:(0,I.jsx)(Ic,{})})})}),(0,I.jsx)(g,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:o})})]})}):(0,I.jsx)(Nc,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":s,onClick:()=>void u(),disabled:i,children:(0,I.jsx)(Nn,{className:`h-5 w-5`})})]})]})}function zc(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function Bc(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Dc,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,F.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,F.useMemo)(()=>h?h.flatMap(e=>e.options):zc(a.options,c),[h,a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),oc({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,I.jsxs)(n,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-label":a.title,className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg px-0 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 sm:w-auto sm:gap-1.5 sm:px-3`,children:[(0,I.jsx)(E,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{className:`nextclaw-chat-skill-picker-label hidden sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:a.title}),p>0?(0,I.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-white shadow-sm sm:static sm:ml-0.5 sm:bg-primary/10 sm:text-primary sm:shadow-none`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,I.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,I.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,I.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,I.jsxs)(`div`,{children:[e.label?(0,I.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,I.jsxs)(`div`,{id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,I.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,I.jsx)(gr,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 select-text`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,I.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,I.jsx)(`button`,{type:`button`,"aria-label":`${r?`Remove`:`Add`} ${e.label}`,onClick:()=>_(e.key),className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,I.jsx)(In,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,I.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,I.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,I.jsx)(dn,{className:`h-3 w-3`})]})}):null]})]})}function Vc({icon:e}){return e===`sparkles`?(0,I.jsx)(br,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)(Fn,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Hc({icon:e}){return e===`paperclip`?(0,I.jsx)(mr,{className:`h-4 w-4`}):(0,I.jsx)(Vc,{icon:e})}var Uc={model:`min-w-0 max-w-full flex-1 basis-[12rem] sm:max-w-[320px]`,"session-type":`shrink-0`,thinking:`shrink-0`},Wc={model:`w-[min(18rem,calc(100vw-1rem))] sm:w-[320px]`,"session-type":`w-[220px]`,thinking:`w-[180px]`};function Gc(e){return e.key===`model`&&e.selectedLabel&&e.selectedLabel.split(`/`).slice(1).join(`/`).trim()||e.selectedLabel}function Kc({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Dc,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0),d=Gc(e);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{"aria-label":e.selectedLabel?`${e.placeholder}: ${e.selectedLabel}`:e.placeholder,title:e.selectedLabel,className:`nextclaw-chat-toolbar-select-trigger h-8 w-auto rounded-lg border-0 bg-transparent px-2 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 sm:px-3 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!basis-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!justify-center [@container_nextclaw-chat-input-bar_(max-width:440px)]:!max-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!min-w-8 [@container_nextclaw-chat-input-bar_(max-width:440px)]:!px-0 ${Uc[e.key]??``}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(Vc,{icon:e.icon}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-mobile-label truncate text-xs font-semibold text-gray-700 sm:hidden [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:d}),(0,I.jsx)(`span`,{className:`nextclaw-chat-toolbar-label hidden truncate text-xs font-semibold text-gray-700 sm:inline [@container_nextclaw-chat-input-bar_(max-width:440px)]:hidden`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:Wc[e.key]??``,children:[u?null:e.loading?(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,I.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,I.jsxs)(`div`,{children:[t>0?(0,I.jsx)(o,{}):null,(0,I.jsxs)(r,{children:[e.label?(0,I.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,I.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,I.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function qc({actions:e,accessories:t,selects:n,skillPicker:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Dc;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-2 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[12rem] flex-1 flex-wrap items-center gap-1 overflow-hidden`,children:[r?(0,I.jsx)(Bc,{picker:r}):null,n.map(e=>(0,I.jsx)(Kc,{item:e},e.key)),t?.map(e=>{let t=(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,I.jsx)(Hc,{icon:e.icon}),e.iconOnly?null:(0,I.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,I.jsx)(o,{children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:e.disabled?(0,I.jsx)(`span`,{className:`inline-flex`,children:t}):t}),(0,I.jsx)(a,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,I.jsx)(`div`,{children:t},e.key)})]}),(0,I.jsx)(Rc,{...e})]})}var Jc=(0,F.createContext)(null);function Yc(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function Xc(){let e=(0,F.useContext)(Jc);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function R(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Zc(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Qc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,$c=Qc&&`documentMode`in document?document.documentMode:null,el=Qc&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),tl=Qc&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),nl=!(!Qc||!(`InputEvent`in window)||$c)&&`getTargetRanges`in new window.InputEvent(`input`),rl=Qc&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,il=Qc&&/Android/.test(navigator.userAgent),al=Qc&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!il,ol=Qc&&/^(?=.*Chrome).*/i.test(navigator.userAgent),sl=Qc&&il&&ol,cl=Qc&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&el&&!ol,ll=0,ul=1,dl=2,fl=1,pl=2,ml=3,hl=4,gl=5,_l=6,vl=al||rl||cl?`\xA0`:`​`,yl=`
4
4
 
5
5
  `,bl=tl?`\xA0`:vl,xl={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Sl={directionless:1,unmergeable:2},Cl={center:2,end:6,justify:4,left:1,right:3,start:5},wl={[pl]:`center`,[_l]:`end`,[hl]:`justify`,[fl]:`left`,[ml]:`right`,[gl]:`start`},Tl={normal:0,segmented:2,token:1},El={[ll]:`normal`,[dl]:`segmented`,[ul]:`token`},Dl=`$config`;function Ol(e,t,n,r,i,a){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(U(o)&&Ol(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}var kl=!1,Al=0;function jl(e){Al=e.timeStamp}function Ml(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&Am(e,n)!==void 0}function Nl(e,t,n){let r=yh(dh(n)),i=null,a=null;r!==null&&r.anchorNode===e&&(i=r.anchorOffset,a=r.focusOffset);let o=e.nodeValue;o!==null&&Um(t,o,i,a,!1)}function Pl(e,t,n){if(V(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return ym(t)&&n.isAttached()}function Fl(e,t,n,r){for(let i=e;i&&!Ph(i);i=ah(i)){let e=Am(i,t);if(e!==void 0){let t=Om(e,n);if(t)return Bp(t)||!xh(i)?void 0:[i,t]}else if(i===r)return[r,Fm(n)]}}function Il(e,t,n){kl=!0;let r=performance.now()-Al>100;try{Pp(e,()=>{let i=H()||function(e){return e.getEditorState().read(()=>{let e=H();return e===null?null:e.clone()})}(e),a=new Map,o=e.getRootElement(),s=e._editorState,c=e._blockCursorElement,l=!1,u=``;for(let n=0;n<t.length;n++){let d=t[n],f=d.type,p=d.target,m=Fl(p,e,s,o);if(!m)continue;let[h,g]=m;if(f===`characterData`)r&&B(g)&&ym(p)&&Pl(i,p,g)&&Nl(p,g,e);else if(f===`childList`){l=!0;let t=d.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=km(r),a=r.parentNode;if(a!=null&&r!==c&&i===null&&!Ml(r,a,e)){if(tl){let e=(xh(r)?r.innerText:null)||r.nodeValue;e&&(u+=e)}a.removeChild(r)}}let n=d.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(Ml(r,p,e)||c===r)&&(p.appendChild(r),t++)}r!==t&&a.set(h,g)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let d=n.takeRecords();if(d.length>0){for(let t=0;t<d.length;t++){let n=d[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||Ml(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(l&&Im(i),tl&&rh(e)&&i.insertRawText(u))})}finally{kl=!1}}function Ll(e){let t=e._observer;t!==null&&Il(e,t.takeRecords(),t)}function Rl(e){(function(e){Al===0&&dh(e).addEventListener(`textInput`,jl,!0)})(e),e._observer=new MutationObserver((t,n)=>{Il(e,t,n)})}var zl=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Kl).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Bl(e,t){return new zl(e,t)}function Vl(e){let t=new Map,n=new Set;for(let r=typeof e==`function`?e:e.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){let{ownNodeConfig:e}=Ih(r);if(e&&e.stateConfigs)for(let r of e.stateConfigs){let e;`stateConfig`in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}var Hl=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState;this.size=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Gl(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Gl(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function Ul(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Hl(t,Wl(t));return t.__state=n,n}function Wl(e){return e.__state?e.__state.sharedNodeState:cm(Dh(),e.getType()).sharedNodeState}function Gl(e){if(e)for(let t in e)return e}function Kl(e){return e}function ql(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Jl(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Yl(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Xl(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&ql(n,e,t)||t&&ql(n,t,e)||e&&Jl(n,e,t)||t&&Jl(n,t,e))}(c,l))}function Zl(e,t){let n=e.mergeWithSibling(t),r=xp()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Ql(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&B(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Xl(t,r)){r=Zl(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&B(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Xl(r,n)){r=Zl(r,n);break}break}n.remove()}}else r.remove()}function $l(e){return eu(e.anchor),eu(e.focus),e}function eu(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),B(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!U(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var tu,nu,ru,iu,au,ou,su,cu,lu,uu,du=``,fu=null,pu=null,mu=!1,hu=!1;function gu(e,t){let n=su.get(e);if(t!==null){let n=Pu(e);n.parentNode===t&&t.removeChild(n)}if(cu.has(e)||nu._keyToDOMMap.delete(e),U(n)){let e=Ou(n,su);_u(e,0,e.length-1,null)}n!==void 0&&eh(uu,ru,iu,n,`destroyed`)}function _u(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&gu(t,r)}}function vu(e,t){e.setProperty(`text-align`,t)}var yu=`40px`;function bu(e,t){let n=tu.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}if(t===0)return void e.style.setProperty(`padding-inline-start`,``);let r=getComputedStyle(nu._rootElement||e).getPropertyValue(`--lexical-indent-base-value`)||yu;e.style.setProperty(`padding-inline-start`,`calc(${t} * ${r})`)}function xu(e,t){let n=e.style;t===0?vu(n,``):t===1?vu(n,`left`):t===2?vu(n,`center`):t===3?vu(n,`right`):t===4?vu(n,`justify`):t===5?vu(n,`start`):t===6&&vu(n,`end`)}function Su(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(Hp(e))return null;let n=e.getParentOrThrow();return Hp(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Cu(e,t){let n=cu.get(e);n===void 0&&R(60);let r=n.createDOM(tu,nu);if(function(e,t,n){let r=n._keyToDOMMap;(function(e,t,n){let r=`__lexicalKey_${t._key}`;e[r]=n})(t,n,e),r.set(e,t)}(e,r,nu),B(n)?r.setAttribute(`data-lexical-text`,`true`):Bp(n)&&r.setAttribute(`data-lexical-decorator`,`true`),U(n)){let e=n.__indent,t=n.__size;if(Su(r,n),e!==0&&bu(r,e),t!==0){let e=t-1;wu(Ou(n,cu),n,0,e,n.getDOMSlot(r))}let i=n.__format;i!==0&&xu(r,i),n.isInline()||Eu(null,n,r)}else{let t=n.getTextContent();if(Bp(n)){let t=n.decorate(nu,tu);t!==null&&Au(e,t),r.contentEditable=`false`}du+=t}return t!==null&&t.insertChild(r),eh(uu,ru,iu,n,`created`),r}function wu(e,t,n,r,i){let a=du;du=``;let o=n;for(;o<=r;++o){Cu(e[o],i);let t=cu.get(e[o]);t!==null&&B(t)?fu===null&&(fu=t.getFormat(),pu=t.getStyle()):U(t)&&o<r&&!t.isInline()&&(du+=yl)}i.element.__lexicalTextContent=du,du=a+du}function Tu(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return ff(e)?`line-break`:Bp(e)&&e.isInline()?`decorator`:null}return`empty`}return null}function Eu(e,t,n){let r=Tu(e,su),i=Tu(t,cu);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Du(e,t,n){var r;fu=null,pu=null,function(e,t,n){let r=du,i=e.__size,a=t.__size;du=``;let o=n.element;if(i===1&&a===1){let n=e.__first,r=t.__first;if(n===r)ku(n,o);else{let e=Pu(n),t=Cu(r,null);try{o.replaceChild(t,e)}catch(i){if(typeof i==`object`&&i){let a=`${i.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw Error(a)}throw i}gu(n,null)}let i=cu.get(r);B(i)&&fu===null&&(fu=i.getFormat(),pu=i.getStyle())}else{let r=Ou(e,su),s=Ou(t,cu);if(r.length!==i&&R(227),s.length!==a&&R(228),i===0)a!==0&&wu(s,0,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&n.element.__lexicalLineBreak==null;_u(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else (function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f];if(e===r)u=ju(ku(r,a.element)),d++,f++;else{if(l===void 0&&(l=Mu(n,f)),c===void 0)c=Mu(t,d);else if(!c.has(e)){d++;continue}if(!l.has(e)){u=ju(Pu(e)),gu(e,a.element),d++,c.delete(e);continue}if(c.has(r)){let e=ih(nu,r);e!==u&&a.withBefore(u).insertChild(e),u=ju(ku(r,a.element)),d++,f++}else Cu(r,a.withBefore(u)),f++}let i=cu.get(r);i!==null&&B(i)?fu===null&&(fu=i.getFormat(),pu=i.getStyle()):U(i)&&f<=s&&!i.isInline()&&(du+=yl)}let p=d>o,m=f>s;if(p&&!m){let e=n[s+1],t=e===void 0?null:nu.getElementByKey(e);wu(n,0,f,s,a.withBefore(t))}else m&&!p&&_u(t,d,o,a.element)})(0,r,s,i,a,n)}o.__lexicalTextContent=du,du=r+du}(e,t,t.getDOMSlot(n)),r=t,fu==null||fu===r.__textFormat||hu||r.setTextFormat(fu),function(e){pu==null||pu===e.__textStyle||hu||e.setTextStyle(pu)}(t)}function Ou(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t.get(r);e===void 0&&R(101),n.push(r),r=e.__next}return n}function ku(e,t){let n=su.get(e),r=cu.get(e);n!==void 0&&r!==void 0||R(61);let i=mu||ou.has(e)||au.has(e),a=ih(nu,e);if(n===r&&!i){let e;if(U(n)){let t=a.__lexicalTextContent;typeof t==`string`?e=t:(e=n.getTextContent(),a.__lexicalTextContent=e)}else e=n.getTextContent();return du+=e,a}if(n!==r&&i&&eh(uu,ru,iu,r,`updated`),r.updateDOM(n,a,tu)){let n=Cu(e,null);return t===null&&R(62),t.replaceChild(n,a),gu(e,null),n}if(U(n)){U(r)||R(334,e);let t=r.__indent;(mu||t!==n.__indent)&&bu(a,t);let o=r.__format;if((mu||o!==n.__format)&&xu(a,o),i)Du(n,r,a),Hp(r)||r.isInline()||Eu(n,r,a);else{let e=a.__lexicalTextContent,t;typeof e==`string`?t=e:(t=n.getTextContent(),a.__lexicalTextContent=t),du+=t}if((mu||r.__dir!==n.__dir)&&(Su(a,r),Hp(r)&&!mu))for(let e of r.getChildren())U(e)&&Su(ih(nu,e.getKey()),e)}else{let t=r.getTextContent();if(Bp(r)){let t=r.decorate(nu,tu);t!==null&&Au(e,t)}du+=t}if(!hu&&Hp(r)&&r.__cachedText!==du){let e=r.getWritable();e.__cachedText=du,r=e}return a}function Au(e,t){let n=nu._pendingDecorators,r=nu._decorators;if(n===null){if(r[e]===t)return;n=Mm(nu)}n[e]=t}function ju(e){let t=e.nextSibling;return t!==null&&t===nu._blockCursorElement&&(t=t.nextSibling),t}function Mu(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Nu(e,t,n,r,i,a){du=``,mu=r===2,nu=n,tu=n._config,ru=n._nodes,iu=nu._listeners.mutation,au=i,ou=a,su=e._nodeMap,cu=t._nodeMap,hu=t._readOnly,lu=new Map(n._keyToDOMMap);let o=new Map;return uu=o,ku(`root`,null),nu=void 0,ru=void 0,au=void 0,ou=void 0,su=void 0,cu=void 0,tu=void 0,lu=void 0,uu=void 0,o}function Pu(e){let t=lu.get(e);return t===void 0&&R(75,e),t}function z(e){return{type:e}}var Fu=z(`SELECTION_CHANGE_COMMAND`),Iu=z(`CLICK_COMMAND`),Lu=z(`BEFORE_INPUT_COMMAND`),Ru=z(`INPUT_COMMAND`),zu=z(`COMPOSITION_START_COMMAND`),Bu=z(`COMPOSITION_END_COMMAND`),Vu=z(`DELETE_CHARACTER_COMMAND`),Hu=z(`INSERT_LINE_BREAK_COMMAND`),Uu=z(`INSERT_PARAGRAPH_COMMAND`),Wu=z(`CONTROLLED_TEXT_INSERTION_COMMAND`),Gu=z(`PASTE_COMMAND`),Ku=z(`REMOVE_TEXT_COMMAND`),qu=z(`DELETE_WORD_COMMAND`),Ju=z(`DELETE_LINE_COMMAND`),Yu=z(`FORMAT_TEXT_COMMAND`),Xu=z(`UNDO_COMMAND`),Zu=z(`REDO_COMMAND`),Qu=z(`KEYDOWN_COMMAND`),$u=z(`KEY_ARROW_RIGHT_COMMAND`),ed=z(`MOVE_TO_END`),td=z(`KEY_ARROW_LEFT_COMMAND`),nd=z(`MOVE_TO_START`),rd=z(`KEY_ARROW_UP_COMMAND`),id=z(`KEY_ARROW_DOWN_COMMAND`),ad=z(`KEY_ENTER_COMMAND`),od=z(`KEY_SPACE_COMMAND`),sd=z(`KEY_BACKSPACE_COMMAND`),cd=z(`KEY_ESCAPE_COMMAND`),ld=z(`KEY_DELETE_COMMAND`),ud=z(`KEY_TAB_COMMAND`),dd=z(`DROP_COMMAND`),fd=z(`DRAGSTART_COMMAND`),pd=z(`DRAGOVER_COMMAND`),md=z(`DRAGEND_COMMAND`),hd=z(`COPY_COMMAND`),gd=z(`CUT_COMMAND`),_d=z(`SELECT_ALL_COMMAND`),vd=z(`FOCUS_COMMAND`),yd=z(`BLUR_COMMAND`),bd=z(`KEY_MODIFIER_COMMAND`),xd=Object.freeze({}),Sd=[[`keydown`,function(e,t){Cd=e.timeStamp,wd=e.key,!t.isComposing()&&W(t,Qu,e)}],[`pointerdown`,function(e,t){let n=e.target,r=e.pointerType;Sh(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&Pp(t,()=>{dm(n)||(Ad=!0)})}],[`compositionstart`,function(e,t){W(t,zu,e)}],[`compositionend`,function(e,t){tl?Md=!0:rl||!al&&!cl?W(t,Bu,e):(Nd=!0,Pd=e.data)}],[`input`,function(e,t){e.stopPropagation(),Pp(t,()=>{t.dispatchCommand(Ru,e)},{event:e}),Ed=null}],[`click`,function(e,t){Pp(t,()=>{let n=H(),r=yh(dh(t)),i=ep();if(r){if(V(n)){let t=n.anchor,a=t.getNode();if(t.type===`element`&&t.offset===0&&n.isCollapsed()&&!Hp(a)&&Pm().getChildrenSize()===1&&a.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(e.detail===3&&!n.isCollapsed()&&a!==n.focus.getNode()){let e=Rh(a,e=>U(e)&&!e.isInline());U(e)&&e.select(0)}}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=r.anchorNode;(xh(n)||ym(n))&&Im($f(i,r,t,e))}}W(t,Iu,e)})}],[`cut`,xd],[`copy`,xd],[`dragstart`,xd],[`dragover`,xd],[`dragend`,xd],[`paste`,xd],[`focus`,xd],[`blur`,xd],[`drop`,xd]];nl&&Sd.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||tl&&rh(t)||n!==`insertCompositionText`&&W(t,Lu,e)}(e,t)]);var Cd=0,wd=null,Td=0,Ed=null,Dd=new WeakMap,Od=new WeakMap,kd=!1,Ad=!1,jd=!1,Md=!1,Nd=!1,Pd=``,Fd=null,Id=[0,``,0,`root`,0];function Ld(e,t,n,r,i){let a=e.anchor,o=e.focus,s=a.getNode(),c=xp(),l=yh(dh(c)),u=l===null?null:l.anchorNode,d=a.key,f=c.getElementByKey(d),p=n.length;return d!==o.key||!B(s)||(!i&&(!nl||Td<r+50)||s.isDirty()&&p<2||Rm(n))&&a.offset!==o.offset&&!s.isComposing()||vm(s)||s.isDirty()&&p>1||(i||!nl)&&f!==null&&!s.isComposing()&&u!==xm(f)||l!==null&&t!==null&&(!t.collapsed||t.startContainer!==l.anchorNode||t.startOffset!==l.anchorOffset)||!s.isComposing()&&(s.getFormat()!==e.format||s.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=_m(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(B(t)||U(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,s)}function Rd(e,t){return ym(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function zd(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=e;kd&&(kd=!1,Rd(r,i)&&Rd(a,o)&&!Fd)||Pp(t,()=>{if(!n)return void Im(null);if(!pm(t,r,a))return;let s=H();if(Fd&&V(s)&&s.isCollapsed()){let e=s.anchor,t=Fd.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(s=Fd.clone(),Im(s))}if(Fd=null,V(s)){let n=s.anchor,r=n.getNode();if(s.isCollapsed()){e.type===`Range`&&e.anchorNode===e.focusNode&&(s.dirty=!0);let i=dh(t).event,a=i?i.timeStamp:performance.now(),[o,c,l,u,d]=Id,f=Pm(),p=!1===t.isComposing()&&f.getTextContent()===``;if(a<d+200&&n.offset===l&&n.key===u)Bd(s,o,c);else if(n.type===`text`)B(r)||R(141),Vd(s,r);else if(n.type===`element`&&!p){U(r)||R(259);let e=n.getNode();e.isEmpty()?function(e,t){Bd(e,t.getTextFormat(),t.getTextStyle())}(s,e):Bd(s,s.format,``)}}else{let e=n.key,t=s.focus.key,r=s.getNodes(),a=r.length,c=s.isBackward(),l=c?o:i,u=c?i:o,d=c?t:e,f=c?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(B(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}s.format=m?p:0}}W(t,Fu,void 0)})}function Bd(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Vd(e,t){Bd(e,t.getFormat(),t.getStyle())}function Hd(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Ud(e){let t=e.inputType,n=Hd(e),r=xp(),i=H();if(t===`deleteContentBackward`){if(i===null){let e=ep();if(!V(e))return!0;Im(e.clone())}if(V(i)){let t=i.anchor.key===i.focus.key;if(a=e.timeStamp,wd===`MediaLast`&&a<Cd+30&&r.isComposing()&&t){if(Em(null),Cd=0,setTimeout(()=>{Pp(r,()=>{Em(null)})},30),V(i)){let e=i.anchor.getNode();e.markDirty(),B(e)||R(142),Vd(i,e)}}else{Em(null),e.preventDefault();let n=i.anchor.getNode(),a=n.getTextContent(),o=n.canInsertTextAfter(),s=i.anchor.offset===0&&i.focus.offset===a.length,c=sl&&t&&!s&&o;if(c&&i.isCollapsed()&&(c=!Bp(nh(i.anchor,!0))),!c){W(r,Vu,!0);let e=H();sl&&V(e)&&e.isCollapsed()&&(Fd=e,setTimeout(()=>Fd=null))}}return!0}}var a;if(!V(i))return!0;let o=e.data;Ed!==null&&Hm(!1,r,Ed),i.dirty&&Ed===null||!i.isCollapsed()||Hp(i.anchor.getNode())||n===null||i.applyDOMRange(n),Ed=null;let s=i.anchor,c=i.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
6
6
  `)e.preventDefault(),W(r,Hu,!1);else if(o===yl)e.preventDefault(),W(r,Uu,void 0);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),i.insertRawText(t)}else o!=null&&Ld(i,n,o,e.timeStamp,!0)?(e.preventDefault(),W(r,Wu,o)):Ed=o;return Td=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:W(r,Wu,e);break;case`insertFromComposition`:Em(null),W(r,Wu,e);break;case`insertLineBreak`:Em(null),W(r,Hu,!1);break;case`insertParagraph`:Em(null),jd&&!rl?(jd=!1,W(r,Hu,!1)):W(r,Uu,void 0);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:W(r,Gu,e);break;case`deleteByComposition`:(function(e,t){return e!==t||U(e)||U(t)||!_m(e)||!_m(t)})(l,u)&&W(r,Ku,e);break;case`deleteByDrag`:case`deleteByCut`:W(r,Ku,e);break;case`deleteContent`:W(r,Vu,!1);break;case`deleteWordBackward`:W(r,qu,!0);break;case`deleteWordForward`:W(r,qu,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:W(r,Ju,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:W(r,Ju,!1);break;case`formatStrikeThrough`:W(r,Yu,`strikethrough`);break;case`formatBold`:W(r,Yu,`bold`);break;case`formatItalic`:W(r,Yu,`italic`);break;case`formatUnderline`:W(r,Yu,`underline`);break;case`historyUndo`:W(r,Xu,void 0);break;case`historyRedo`:W(r,Zu,void 0)}return!0}function Wd(e){if(xh(e.target)&&dm(e.target))return!0;let t=xp(),n=H(),r=e.data,i=Hd(e);if(r!=null&&V(n)&&Ld(n,i,r,e.timeStamp,!1)){Md&&=(qd(t,r),!1);let i=n.anchor.getNode(),a=yh(dh(t));if(a===null)return!0;let o=n.isBackward(),s=o?n.anchor.offset:n.focus.offset,c=o?n.focus.offset:n.anchor.offset;nl&&!n.isCollapsed()&&B(i)&&a.anchorNode!==null&&i.getTextContent().slice(0,s)+r+i.getTextContent().slice(s+c)===Vm(a.anchorNode)||W(t,Wu,r);let l=r.length;tl&&l>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(n.anchor.offset-=l),sl&&t.isComposing()&&(Cd=0,Em(null))}else Hm(!1,t,r===null?void 0:r),Md&&=(qd(t,r||void 0),!1);return function(){vp(),Ll(xp())}(),!0}function Gd(e){let t=xp(),n=H();if(V(n)&&!t.isComposing()){let r=n.anchor,i=n.anchor.getNode();Em(r.key),sh(sf),(e.timeStamp<Cd+30||r.type===`element`||!n.isCollapsed()||i.getFormat()!==n.format||B(i)&&i.getStyle()!==n.style)&&W(t,Wu,bl)}return!0}function Kd(e){return qd(xp(),e.data),sh(cf),!0}function qd(e,t){let n=e._compositionKey;if(Em(null),n!==null&&t!=null){if(t===``){let t=Om(n),r=xm(e.getElementByKey(n));if(r!==null&&r.nodeValue!==null&&B(t)){let n=yh(dh(e)),i=null,a=null;n!==null&&n.anchorNode===r&&(i=n.anchorOffset,a=n.focusOffset),Um(t,r.nodeValue,i,a,!0)}return}if(t[t.length-1]===`
@@ -45,12 +45,12 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n a
45
45
  `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return cD(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=aO.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hO(){return{exit:{taskListCheckValueChecked:_O,taskListCheckValueUnchecked:_O,paragraph:vO}}}function gO(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yO}}}function _O(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vO(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function yO(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=aO.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function bO(){return[EE(),XE(),tD(),oO(),hO()]}function xO(e){return{extensions:[DE(),ZE(e),nD(),mO(e),gO()]}}var SO={tokenize:IO,partial:!0},CO={tokenize:LO,partial:!0},wO={tokenize:RO,partial:!0},TO={tokenize:zO,partial:!0},EO={tokenize:BO,partial:!0},DO={name:`wwwAutolink`,tokenize:PO,previous:VO},OO={name:`protocolAutolink`,tokenize:FO,previous:HO},kO={name:`emailAutolink`,tokenize:NO,previous:UO},AO={};function jO(){return{text:AO}}for(var MO=48;MO<123;)AO[MO]=kO,MO++,MO===58?MO=65:MO===91&&(MO=97);AO[43]=kO,AO[45]=kO,AO[46]=kO,AO[95]=kO,AO[72]=[kO,OO],AO[104]=[kO,OO],AO[87]=[kO,DO],AO[119]=[kO,DO];function NO(e,t,n){let r=this,i,a;return o;function o(t){return!WO(t)||!UO.call(r,r.previous)||GO(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return WO(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(EO,u,l)(t):t===45||t===95||kx(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Ox(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function PO(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!VO.call(r,r.previous)||GO(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(SO,e.attempt(CO,e.attempt(wO,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function FO(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&HO.call(r,r.previous)&&!GO(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Ox(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||jx(t)||Fx(t)||Lx(t)||Ix(t)?n(t):e.attempt(CO,e.attempt(wO,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function IO(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function LO(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(TO,c,s)(t):t===null||Fx(t)||Lx(t)||t!==45&&Ix(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function RO(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(TO,t,a)(o):o===null||Fx(o)||Lx(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zO(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Fx(o)||Lx(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Fx(e)||Lx(e)?t(e):r(e)}function a(e){return Ox(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Ox(t)?(e.consume(t),o):n(t)}}function BO(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return kx(e)?n(e):t(e)}}function VO(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fx(e)}function HO(e){return!Ox(e)}function UO(e){return!(e===47||WO(e))}function WO(e){return e===43||e===45||e===46||e===95||kx(e)}function GO(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var KO={tokenize:ek,partial:!0};function qO(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ZO,continuation:{tokenize:QO},exit:$O}},text:{91:{name:`gfmFootnoteCall`,tokenize:XO},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:JO,resolveTo:YO}}}}function JO(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Dx(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function YO(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function XO(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Fx(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Dx(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Fx(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function ZO(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Fx(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Dx(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Fx(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),X(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function QO(e,t,n){return e.check(eS,t,e.attempt(KO,t,n))}function $O(e){e.exit(`gfmFootnoteDefinition`)}function ek(e,t,n){let r=this;return X(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function tk(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&bx(o,o.length,0,qx(s,e.slice(r+1,n),t)),bx(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),bx(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Kx(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Kx(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nk=class{constructor(){this.map=[]}add(e,t,n){rk(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function rk(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function ik(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function ak(){return{flow:{null:{name:`table`,tokenize:ok,resolveAll:sk}}}}function ok(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Fx(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Fx(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function sk(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new nk;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lk(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=ck(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=ck(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=ck(f,t,o,i,n,d)):(o[0]=o[1],d=ck(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lk(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=ik(t.events,n))}return e}function ck(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uk(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uk(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=uk(t.events,n[2]),a=uk(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},uk(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lk(e,t,n,r,i){let a=[],o=uk(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function uk(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var dk={name:`tasklistCheck`,tokenize:pk};function fk(){return{text:{91:dk}}}function pk(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Fx(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return J(r)?t(r):Y(r)?e.check({tokenize:mk},t,n)(r):n(r)}}function mk(e,t,n){return X(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hk(e){return Cx([jO(),qO(),tk(e),ak(),fk()])}var gk={};function _k(e){let t=this,n=e||gk,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hk(n)),a.push(bO()),o.push(xO(n))}function vk(){return typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`}function yk(e){if(typeof document>`u`)return;let t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(e=>t.addRange(e)))}function bk(e){if(typeof document>`u`||!document.body)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null,r=n?{start:n.selectionStart,end:n.selectionEnd}:null,i=document.getSelection(),a=i?Array.from({length:i.rangeCount},(e,t)=>i.getRangeAt(t).cloneRange()):[],o=document.createElement(`textarea`);o.value=e,o.setAttribute(`readonly`,``),o.setAttribute(`aria-hidden`,`true`),o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`,o.style.fontSize=`12pt`,document.body.appendChild(o);try{o.focus({preventScroll:!0})}catch{o.focus()}o.select(),o.setSelectionRange(0,o.value.length);let s=!1;try{s=typeof document.execCommand==`function`&&document.execCommand(`copy`)}catch{s=!1}if(o.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):yk(a),s}async function xk(e){if(!e)return!1;if(vk())try{return await navigator.clipboard.writeText(e),!0}catch{return bk(e)}return bk(e)}var Sk=1300;function Ck(e){let[t,n]=(0,F.useState)(!1),r=(0,F.useCallback)(async()=>{e.text&&(await xk(e.text)?n(!0):n(!1))},[e.text]);return(0,F.useEffect)(()=>{if(!t||typeof window>`u`)return;let r=window.setTimeout(()=>n(!1),e.resetDelayMs??Sk);return()=>window.clearTimeout(r)},[t,e.resetDelayMs]),{copied:t,copy:r}}var wk=_(e(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,ee=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},j={begin:`\\\\[\\s\\S]`,relevance:0},te={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[j]},M={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[j]},ne={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},re=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},ie=re(`//`,`$`),ae=re(`/\\*`,`\\*/`),oe=re(`#`,`$`),se={scope:`number`,begin:D,relevance:0},ce={scope:`number`,begin:O,relevance:0},le={scope:`number`,begin:k,relevance:0},ue={scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[j,{begin:/\[/,end:/\]/,relevance:0,contains:[j]}]},de={scope:`title`,begin:T,relevance:0},fe={scope:`title`,begin:E,relevance:0},pe={begin:`\\.\\s*`+E,relevance:0},me=Object.freeze({__proto__:null,APOS_STRING_MODE:te,BACKSLASH_ESCAPE:j,BINARY_NUMBER_MODE:le,BINARY_NUMBER_RE:k,COMMENT:re,C_BLOCK_COMMENT_MODE:ae,C_LINE_COMMENT_MODE:ie,C_NUMBER_MODE:ce,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:oe,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:pe,NUMBER_MODE:se,NUMBER_RE:D,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:M,REGEXP_MODE:ue,RE_STARTERS_RE:A,SHEBANG:ee,TITLE_MODE:de,UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:fe});function he(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ge(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function _e(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=he,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ve(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function ye(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function be(e,t){e.relevance===void 0&&(e.relevance=1)}var xe=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},Se=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],Ce=`keyword`;function we(e,t,n=Ce){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,we(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,Te(n[0],n[1])]})}}function Te(e,t){return t?Number(t):Ee(e)?0:1}function Ee(e){return Se.includes(e.toLowerCase())}var De={},Oe=e=>{console.error(e)},ke=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Ae=(e,t)=>{De[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),De[`${e}/${t}`]=!0)},je=Error();function Me(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function Ne(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Oe(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),je;if(typeof e.beginScope!=`object`||e.beginScope===null)throw Oe(`beginScope must be object`),je;Me(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function Pe(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Oe(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),je;if(typeof e.endScope!=`object`||e.endScope===null)throw Oe(`endScope must be object`),je;Me(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function Fe(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Ie(e){Fe(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),Ne(e),Pe(e)}function Le(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null),this.matcherRe=t(C(this.regexes.map(e=>e[1]),{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[ge,ye,Ie,xe].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[_e,ve,be].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=we(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return ze(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function Re(e){return e?e.endsWithParent||Re(e.starts):!1}function ze(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Re(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Be=`11.11.1`,Ve=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},He=i,Ue=a,We=Symbol(`nomatch`),Ge=7,Ke=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=te(n[1]);return t||(ke(s.replace(`{}`,n[1])),ke(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||te(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(Ae(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),Ae(`10.7.0`,`Please use highlight(code, options) instead.
46
46
  https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};oe(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,oe(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){j.addText(M);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(M),n=``;for(;t;){n+=M.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(j.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=Ge&&(ne+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(M)}n+=M.substring(e),j.addText(n)}function f(){if(M===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){j.addText(M);return}e=v(A.subLanguage,M,!0,ee[A.subLanguage]),ee[A.subLanguage]=e._top}else e=S(M,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(ne+=e.relevance),j.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),M=``}function m(e,t){e!==``&&(j.startScope(t),j.addText(e),j.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(M=i,d(),M=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&j.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(M,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),M=``):e.beginScope._multi&&(h(e.beginScope,t),M=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(M+=e[0],1):(ae=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?M+=t:(n.excludeBegin&&(M+=t),p(),!n.returnBegin&&!n.excludeBegin&&(M=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return We;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?M+=t:(a.returnEnd||a.excludeEnd||(M+=t),p(),a.excludeEnd&&(M=t));do A.scope&&j.closeNode(),!A.skip&&!A.subLanguage&&(ne+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>j.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(M+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(M+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==We)return e}if(r.type===`illegal`&&a===``)return M+=`
47
47
  `,1;if(ie>1e5&&ie>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return M+=a,a.length}let D=te(e);if(!D)throw Oe(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=Le(D),k=``,A=a||O,ee={},j=new l.__emitter(l);w();let M=``,ne=0,re=0,ie=0,ae=!1;try{if(D.__emitTokens)D.__emitTokens(n,j);else{for(A.matcher.considerAll();;){ie++,ae?ae=!1:A.matcher.considerAll(),A.matcher.lastIndex=re;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(re,e.index),e);re=e.index+t}E(n.substring(re))}return j.finalize(),k=j.toHTML(),{language:e,value:k,relevance:ne,illegal:!1,_emitter:j,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:He(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:re,context:n.slice(re-100,re+100),mode:t.mode,resultSoFar:k},_emitter:j};if(o)return{language:e,value:He(n),illegal:!1,relevance:0,errorRaised:t,_emitter:j,_top:A};throw t}}function b(e){let t={value:He(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(te).filter(ne).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(te(e.language).supersetOf===t.language)return 1;if(te(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(oe(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new Ve(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),oe(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Ue(l,e)}let E=()=>{k(),Ae(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),Ae(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(Oe(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)Oe(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&M(i.aliases,{languageName:n})}function ee(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function j(){return Object.keys(t)}function te(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function M(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function ne(e){let t=te(e);return t&&!t.disableAutodetect}function re(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function ie(e){re(e),a.push(e)}function ae(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function oe(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function se(e){return Ae(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),Ae(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:se,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:ee,listLanguages:j,getLanguage:te,registerAliases:M,autoDetection:ne,inherit:Ue,addPlugin:ie,removePlugin:ae}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=Be,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in me)typeof me[e]==`object`&&n(me[e]);return Object.assign(e,me),e},qe=Ke({});qe.newInstance=()=>Ke({}),t.exports=qe,qe.HighlightJS=qe,qe.default=qe}))()).default;function Tk(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var Ek=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Dk=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),Ok=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),kk=[...Dk,...Ok],Ak=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),jk=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),Mk=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),Nk=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function Pk(e){let t=e.regex,n=Ek(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+jk.join(`|`)+`)`},{begin:`:(:)?(`+Mk.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+Nk.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:Ak.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+kk.join(`|`)+`)\\b`}]}}function Fk(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}var Ik=`[A-Za-z$_][0-9A-Za-z$_]*`,Lk=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),Rk=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],zk=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),Bk=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Vk=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Hk=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],Uk=[].concat(Vk,zk,Bk);function Wk(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=Ik,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:Ik,keyword:Lk,literal:Rk,built_in:Uk,"variable.language":Hk},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...zk,...Bk]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...Vk,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function Gk(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function Kk(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function qk(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.all.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function Jk(e){return{name:`Shell Session`,aliases:[`console`,`shellsession`],contains:[{className:`meta.prompt`,begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:`bash`}}]}}function Yk(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var Xk=`[A-Za-z$_][0-9A-Za-z$_]*`,Zk=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),Qk=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],$k=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),eA=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],tA=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],nA=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],rA=[].concat(tA,$k,eA);function iA(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=Xk,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:Xk,keyword:Zk,literal:Qk,built_in:rA,"variable.language":nA},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...$k,...eA]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...tA,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function aA(e){let t=e.regex,n=iA(e),r=Xk,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:Xk,keyword:Zk.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:Qk,built_in:rA.concat(i),"variable.language":nA},l={className:`meta`,begin:`@`+r},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function oA(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function sA(e){let t=`true false yes no null`,n=`[\\w#;/?:@&=+$,.~*'()[\\]]+`,r={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},o={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},s=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),c={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},l={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},u={begin:/\{/,end:/\}/,contains:[l],illegal:`\\n`,relevance:0},d={begin:`\\[`,end:`\\]`,contains:[l],illegal:`\\n`,relevance:0},f=[r,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+!`+n},{className:`type`,begin:`!<`+n+`>`},{className:`type`,begin:`!`+n},{className:`type`,begin:`!!`+n},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},c,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},u,d,a,o],p=[...f];return p.pop(),p.push(s),l.contains=p,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:f}}var cA=new Set([`text`,`txt`,`plain`,`plaintext`,`none`,`output`]),lA=[`typescript`,`javascript`,`json`,`bash`,`shell`,`python`,`css`,`xml`,`markdown`,`yaml`,`sql`,`diff`],uA=4,dA=[{name:`typescript`,language:aA,aliases:[`ts`,`tsx`]},{name:`javascript`,language:Wk,aliases:[`js`,`jsx`,`mjs`,`cjs`]},{name:`json`,language:Gk,aliases:[`jsonc`]},{name:`bash`,language:Tk,aliases:[`sh`,`zsh`]},{name:`shell`,language:Jk,aliases:[`console`,`terminal`]},{name:`python`,language:qk,aliases:[`py`]},{name:`css`,language:Pk},{name:`xml`,language:oA,aliases:[`html`,`svg`]},{name:`markdown`,language:Kk,aliases:[`md`,`mdx`]},{name:`yaml`,language:sA,aliases:[`yml`]},{name:`sql`,language:Yk},{name:`diff`,language:Fk,aliases:[`patch`]}];function fA(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function pA(e){return e.trim().toLowerCase()}var mA=new class{constructor(){this.highlight=(e,t)=>{let n=pA(t);if(!e||cA.has(n))return this.createPlainTextResult(e,n||`text`);if(this.engine.getLanguage(n)){let t=this.engine.highlight(e,{language:n,ignoreIllegals:!0});return{html:t.value,language:t.language??n,highlighted:!0}}let r=this.engine.highlightAuto(e,lA);return r.language&&r.relevance>=uA?{html:r.value,language:r.language,highlighted:!0}:this.createPlainTextResult(e,n||`text`)},this.createPlainTextResult=(e,t)=>({html:fA(e),language:t,highlighted:!1}),this.engine=wk.newInstance(),dA.forEach(e=>{this.engine.registerLanguage(e.name,e.language),e.aliases&&this.engine.registerAliases(e.aliases,{languageName:e.name})})}},hA=/language-([a-z0-9-]+)/i;function gA(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(gA).join(``):``}function _A(e){let t=gA(e);return t.endsWith(`
48
- `)?t.slice(0,-1):t}function vA(e){return(e?hA.exec(e):null)?.[1]?.toLowerCase()||`text`}function yA({className:e,children:t,texts:n}){let r=(0,F.useMemo)(()=>vA(e),[e]),i=(0,F.useMemo)(()=>_A(t),[t]),a=(0,F.useMemo)(()=>mA.highlight(i,r),[i,r]),o=(0,F.useMemo)(()=>{let t=`language-${a.language}`;return L(`hljs`,e,e?.includes(`language-`)?void 0:t)},[e,a.language]),{copied:s,copy:c}=Ck({text:i});return(0,I.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,I.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,I.jsx)(`span`,{className:`chat-codeblock-language`,children:r}),(0,I.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void c(),"aria-label":s?n.copiedCodeLabel:n.copyCodeLabel,children:[s?(0,I.jsx)(In,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Vn,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:s?n.copiedCodeLabel:n.copyCodeLabel})]})]}),(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{className:o,"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})})]})}var bA=14e4,xA=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function SA(e){return e.length<=bA?e:`${e.slice(0,bA)}\n\n...`}function CA(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))return e;try{let t=new URL(e);return xA.has(t.protocol)?e:null}catch{return null}}function wA(e){return/^https?:\/\//i.test(e)}function TA(e){return e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/Users/`)||e.startsWith(`/home/`)||e.startsWith(`/tmp/`)||e.startsWith(`/var/`)||/^\/.+\.[A-Za-z0-9_-]+(?::\d+(?::\d+)?)?$/.test(e)}function EA(e){let t=e.split(`#`)[0]?.split(`?`)[0]??e,n=decodeURIComponent(t);if(!TA(n))return null;let r=/^(.*?)(?::(\d+)(?::(\d+))?)$/.exec(n),i=r?.[1]??n,a=r?.[2]?Number(r[2]):void 0,o=r?.[3]?Number(r[3]):void 0;return{path:i,label:i.split(`/`).filter(Boolean).pop()??i,viewMode:`preview`,...typeof a==`number`?{line:a}:{},...typeof o==`number`?{column:o}:{}}}function DA({text:e,role:t,texts:n,inline:r=!1,onFileOpen:i}){let a=t===`user`,o=(0,F.useMemo)(()=>({p:({children:e})=>r?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsx)(`p`,{children:e}),a:({href:e,children:t,...n})=>{let r=CA(e);if(!r)return(0,I.jsx)(`span`,{className:`chat-link-invalid`,children:t});let a=wA(r),o=a?null:EA(r),s=e=>{!i||!o||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(o))};return(0,I.jsx)(`a`,{...n,href:r,onClick:s,target:a?`_blank`:void 0,rel:a?`noreferrer noopener`:void 0,children:t})},table:({children:e,...t})=>(0,I.jsx)(`div`,{className:`chat-table-wrap`,children:(0,I.jsx)(`table`,{...t,children:e})}),input:({type:e,checked:t,...n})=>e===`checkbox`?(0,I.jsx)(`input`,{...n,type:`checkbox`,checked:t,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,I.jsx)(`input`,{...n,type:e}),img:({src:e,alt:t,...n})=>{let r=CA(e);return r?(0,I.jsx)(`img`,{...n,src:r,alt:t||``,loading:`lazy`,decoding:`async`}):null},code:({className:e,children:t,...r})=>!e&&!String(t??``).includes(`
49
- `)?(0,I.jsx)(`code`,{...r,className:L(`chat-inline-code`,e),children:t}):(0,I.jsx)(yA,{className:e,texts:n,children:t})}),[r,i,n]);return(0,I.jsx)(r?`span`:`div`,{className:L(`chat-markdown`,a?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,I.jsx)(pE,{skipHtml:!0,remarkPlugins:[_k],components:o,children:SA(e)})})}function OA(e){return e.split(`​`).join(``).split(`‌`).join(``).split(`‍`).join(``).split(`⁠`).join(``).split(``).join(``).length>0}function kA(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,I.jsx)(`path`,{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}),(0,I.jsx)(`path`,{d:`M2.75 10 8.5 13.25 14.25 10`}),(0,I.jsx)(`path`,{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}),(0,I.jsx)(`path`,{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`})]})}function AA({kind:e,label:t,isUser:n}){let r=e===`skill`;return(0,I.jsxs)(`span`,{className:L(`mx-[2px] inline-flex h-7 max-w-full items-center gap-1.5 rounded-xl border px-2.5 align-baseline text-[11px] font-medium shadow-[0_0_0_1px_rgba(15,23,42,0.03)]`,r?n?`border-emerald-200/35 bg-emerald-400/18 text-emerald-50/95`:`border-emerald-200/70 bg-emerald-50 text-emerald-700`:n?`border-white/30 bg-white/18 text-white`:`border-slate-200/80 bg-slate-100 text-slate-700`),title:t,children:[(0,I.jsx)(`span`,{className:L(`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,r?n?`text-emerald-100/90`:`text-emerald-600`:n?`text-white/70`:`text-slate-500`),children:(0,I.jsx)(kA,{})}),(0,I.jsx)(`span`,{className:`truncate`,children:t})]})}function jA({segments:e,role:t,texts:n,onFileOpen:r}){let i=t===`user`;return(0,I.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e.map((e,a)=>e.type===`token`?(0,I.jsx)(AA,{kind:e.token.kind,label:e.token.label,isUser:i},`token-${a}-${e.token.kind}-${e.token.key}`):OA(e.text)?(0,I.jsx)(DA,{text:e.text,role:t,texts:n,inline:!0,onFileOpen:r},`markdown-${a}`):(0,I.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text},`space-${a}`))})}var MA={archive:`border-amber-200/80 bg-amber-50 text-amber-700`,audio:`border-fuchsia-200/80 bg-fuchsia-50 text-fuchsia-700`,code:`border-cyan-200/80 bg-cyan-50 text-cyan-700`,data:`border-slate-200/80 bg-slate-50 text-slate-700`,document:`border-blue-200/80 bg-blue-50 text-blue-700`,generic:`border-slate-200/80 bg-slate-50 text-slate-700`,image:`border-emerald-200/80 bg-emerald-50 text-emerald-700`,pdf:`border-rose-200/80 bg-rose-50 text-rose-700`,sheet:`border-lime-200/80 bg-lime-50 text-lime-700`,video:`border-violet-200/80 bg-violet-50 text-violet-700`},NA=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),PA=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),FA=new Set([`avif`,`bmp`,`gif`,`heic`,`heif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`tif`,`tiff`,`webp`]),IA=new Set([`aac`,`flac`,`m4a`,`mp3`,`ogg`,`opus`,`wav`,`weba`]),LA=new Set([`avi`,`m4v`,`mov`,`mp4`,`mkv`,`webm`,`wmv`]),RA=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),zA=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),BA=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function VA(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function HA(e,t){let n=UA(e);if(n)return n.toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function UA(e){return/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``}function WA(e){return typeof e==`string`&&/^data:image\//i.test(e.trim())}function GA(e){return FA.has(e)?e===`jpg`||e===`jpeg`?`image/jpeg`:e===`svg`?`image/svg+xml`:`image/${e}`:IA.has(e)?e===`mp3`?`audio/mpeg`:e===`m4a`?`audio/mp4`:e===`weba`?`audio/webm`:`audio/${e}`:LA.has(e)?e===`mov`?`video/quicktime`:e===`m4v`?`video/mp4`:`video/${e}`:e===`pdf`?`application/pdf`:null}function KA(e){let t=UA(e);return t?GA(t):null}function qA(e){let t=e.mimeType.trim().toLowerCase();return t.length>0&&t!==`application/octet-stream`?t:KA(e.label)}function JA(e){let t=e.mimeType.trim().toLowerCase(),n=UA(e.label);return e.isImage||t.startsWith(`image/`)||FA.has(n)||WA(e.dataUrl)}function YA(e,t){let n=UA(e),r=t.toLowerCase();return r.startsWith(`image/`)||FA.has(n)?`image`:r.startsWith(`audio/`)||IA.has(n)?`audio`:r.startsWith(`video/`)||LA.has(n)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:BA.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:zA.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:PA.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:NA.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:RA.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function XA(e){let t=YA(e.label,e.mimeType),n=VA(e.sizeBytes);return{category:t,extension:HA(e.label,e.mimeType),sizeLabel:n}}var ZA={archive:`Archive`,audio:`Audio`,code:`Code file`,data:`Data file`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF document`,sheet:`Spreadsheet`,video:`Video`},QA={archive:Wn,audio:Gn,code:Kn,data:Jn,document:Xn,generic:Qn,image:qn,pdf:Xn,sheet:Yn,video:Zn};function $A(e,t){return t?.attachmentCategoryLabels?.[e]??ZA[e]}function ej(e,t,n){return(0,I.jsx)(`div`,{className:L(`mt-1 text-xs leading-5`,n?`text-white/70`:`text-slate-500`),children:t?`${e} · ${t}`:e})}function tj(e,t,n){return(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,n?t?`border-white/14 bg-white/12 text-white`:`border-slate-200/80 bg-white text-slate-700`:t?`border-white/10 bg-white/6 text-white/62`:`border-slate-200/70 bg-slate-100/80 text-slate-500`),children:e})}function nj(e,t,n){return(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:L(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition duration-200`,n?`border-white/14 bg-white/12 text-white hover:border-white/20 hover:bg-white/16`:`border-slate-200/80 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50`),children:e})}function rj({category:e,isUser:t}){let n=QA[e];return(0,I.jsx)(`div`,{className:L(`flex h-14 w-14 shrink-0 items-center justify-center rounded-[1rem] border`,t?`border-white/12 bg-white/10 text-white`:MA[e]),children:(0,I.jsx)(n,{className:L(`h-7 w-7`,t?`text-white/92`:`text-current`),strokeWidth:2.2})})}function ij(e){let{file:t,categoryLabel:n,sizeLabel:r,isUser:i}=e;return t.dataUrl?(0,I.jsx)(`a`,{href:t.dataUrl,target:`_blank`,rel:`noreferrer`,className:`group block`,children:(0,I.jsxs)(`div`,{className:L(`relative overflow-hidden rounded-[1rem]`,i?`ring-1 ring-white/10`:`bg-slate-100/80 ring-1 ring-slate-200/80`),children:[(0,I.jsx)(`img`,{src:t.dataUrl,alt:t.label,className:`block h-auto max-h-[26rem] w-full rounded-[1rem] bg-transparent object-contain transition duration-300 group-hover:scale-[1.01]`}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute right-3 top-3 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full px-2 py-1 text-[10px] font-semibold tracking-[0.18em] text-white backdrop-blur-sm`,i?`bg-slate-950/36`:`bg-slate-950/58`),children:n}),r?(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full px-2 py-1 text-[10px] font-medium text-white/92 backdrop-blur-sm`,i?`bg-slate-950/28`:`bg-slate-950/46`),children:r}):null]})]})}):null}function aj(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:o}=e;return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 p-3.5`,children:[(0,I.jsx)(rj,{category:t,isUser:a}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-[15px] font-semibold leading-5`,children:n.label}),ej(r,i,a)]}),o]})})]})}function oj(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,shellClasses:o,actionLabel:s}=e;if(!n.dataUrl||t!==`audio`&&t!==`video`)return null;let c=qA(n);return(0,I.jsxs)(`div`,{className:o,children:[aj({category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:nj(s,n.dataUrl,a)}),(0,I.jsx)(`div`,{className:`px-3.5 pb-3.5`,children:t===`audio`?(0,I.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n.label,className:`block w-full`,children:(0,I.jsx)(`source`,{src:n.dataUrl,...c?{type:c}:{}})}):(0,I.jsx)(`div`,{className:L(`overflow-hidden rounded-[1rem] border`,a?`border-white/10 bg-slate-950/26`:`border-slate-200/80 bg-slate-100/80`),children:(0,I.jsx)(`video`,{controls:!0,preload:`metadata`,playsInline:!0,"aria-label":n.label,className:`block max-h-[28rem] w-full bg-black`,children:(0,I.jsx)(`source`,{src:n.dataUrl,...c?{type:c}:{}})})})})]})}function sj({file:e,isUser:t=!1,texts:n}){let{category:r,sizeLabel:i}=XA(e),a=JA(e)&&!!e.dataUrl,o=r===`audio`&&!!e.dataUrl,s=r===`video`&&!!e.dataUrl,c=!!e.dataUrl,l=c?n?.attachmentOpenLabel??`Open`:n?.attachmentAttachedLabel??`Attached`,u=$A(r,n),d=L(`block overflow-hidden rounded-[1.25rem] border transition duration-200`,t?`border-white/12 bg-white/10 text-white`:`border-slate-200/80 bg-white/95 text-slate-900`,c&&(t?`hover:border-white/18 hover:bg-white/13`:`hover:border-slate-300 hover:bg-white`));if(a)return ij({file:e,categoryLabel:u,sizeLabel:i,isUser:t});if(o||s)return oj({category:r,file:e,categoryLabel:u,sizeLabel:i,isUser:t,shellClasses:d,actionLabel:l});let f=aj({category:r,file:e,categoryLabel:u,sizeLabel:i,isUser:t,action:tj(l,t,c)});return!c||!e.dataUrl?(0,I.jsx)(`div`,{className:d,children:f}):(0,I.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:L(d,`group`),children:f})}function cj(e){let{isInProgress:t}=e,[n,r]=(0,F.useState)(t),[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(t);(0,F.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}var lj=10;function uj(e){e.scrollTop=e.scrollHeight}function dj(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;let t=e.scrollRef.current;t&&(e.isProgrammaticScrollRef.current=!0,uj(t))}))}function fj(e){let t=(0,F.useRef)(!0),n=(0,F.useRef)(!1),r=(0,F.useRef)(null),i=(0,F.useRef)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),(0,F.useEffect)(()=>{let e=a.current;return()=>{e!==null&&cancelAnimationFrame(e)}},[]),(0,F.useLayoutEffect)(()=>{!i.current||e.isLoading||!e.hasContent||e.scrollRef.current&&(i.current=!1,dj({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),(0,F.useLayoutEffect)(()=>{!t.current||!e.hasContent||e.scrollRef.current&&dj({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:()=>{if(n.current){n.current=!1;return}let r=e.scrollRef.current;r&&(t.current=r.scrollHeight-r.scrollTop-r.clientHeight<=(e.stickyThresholdPx??lj))}}}function pj(e){let t=e.trim().toLowerCase();return t===`reasoning`||t===`thinking`||t===`推理`||t===`推理过程`||t===`思考过程`||t===`思考`?`思考`:e}function mj({label:e,text:t,isUser:n,isInProgress:r}){let{isOpen:i,onSummaryClick:a}=cj({isInProgress:r}),o=(0,F.useRef)(null),s=pj(e),{onScroll:c}=fj({scrollRef:o,resetKey:`${s}:${r?`streaming`:`idle`}`,isLoading:!1,hasContent:t.length>0,contentVersion:t,stickyThresholdPx:20});return(0,I.jsxs)(`details`,{className:`mt-2`,open:i,children:[(0,I.jsx)(`summary`,{className:L(`cursor-pointer text-xs`,n?`text-primary-100`:`text-gray-500`),onClick:a,children:s}),(0,I.jsx)(`div`,{ref:o,onScroll:c,"data-reasoning-scroll":`true`,className:L(`mt-2 w-fit max-w-[500px] max-h-56 overflow-y-auto rounded-lg custom-scrollbar-amber`,n?`bg-primary-700/60`:`bg-gray-100`),children:(0,I.jsx)(`pre`,{className:`min-w-0 whitespace-pre-wrap break-all p-2 text-[11px]`,children:t})})]})}function hj({children:e,className:t}){return(0,I.jsx)(`div`,{className:L(`my-2 rounded-lg border border-amber-200/50 bg-amber-100/30 shadow-sm overflow-hidden text-[12px]`,`w-[280px] sm:w-[360px] md:w-[480px] min-w-full max-w-full transition-all flex flex-col`,t),children:e})}function gj({children:e,className:t}){return(0,I.jsx)(`div`,{className:L(`border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden`,t),children:e})}var _j={running:{text:`text-amber-500/80`,icon:$t,spin:!0},success:{text:`text-amber-500/80`,icon:In,spin:!1},error:{text:`text-amber-500/80`,icon:y,spin:!1},cancelled:{text:`text-amber-500/80`,icon:fr,spin:!1}};function vj({card:e}){let t=_j[e.statusTone]||_j.cancelled,n=t.icon;return(0,I.jsxs)(`span`,{className:L(`inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0`,t.text),children:[(0,I.jsx)(n,{className:L(`h-3.5 w-3.5`,t.spin&&`animate-spin`),strokeWidth:3}),e.statusTone===`running`?e.statusLabel:null]})}function yj({action:e,onAction:t}){let n=e.sessionKind===`child`?`Open child session`:`Open session`;return(0,I.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:L(`inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors`,`border-amber-200/80 bg-white/80 text-amber-800 hover:bg-amber-50`),"aria-label":n,title:n,children:(0,I.jsx)(Mn,{className:`h-3 w-3`,strokeWidth:2.5})})}function bj({card:e,icon:t,expanded:n,canExpand:r,hideSummary:i=!1,actionSlot:a,onToggle:o}){let s=i?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``;return(0,I.jsxs)(`div`,{className:L(`flex items-center gap-3 px-3 py-2.5 transition-colors bg-transparent`,r?`cursor-pointer hover:bg-amber-100/30`:``),onClick:o,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden font-mono text-amber-950/80`,children:[(0,I.jsx)(t,{className:`h-4 w-4 text-amber-600/80 shrink-0`,strokeWidth:3}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden`,children:[(0,I.jsx)(`span`,{className:`font-bold shrink-0 tracking-tight`,children:e.toolName}),s&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-amber-300 font-bold select-none shrink-0`,children:`›`}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate font-normal`,title:s,children:s})]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[a,(0,I.jsx)(vj,{card:e}),r&&(n?(0,I.jsx)(Ln,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}):(0,I.jsx)(Rn,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}))]})]})}function xj({action:e,onAction:t}){return(0,I.jsx)(yj,{action:e,onAction:t})}var Sj=`font-mono text-[11px] leading-5`,Cj=`flex h-5 w-full ${Sj}`,wj=`flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function Tj(e){let t=e.newLineNumber??e.oldLineNumber;return typeof t==`number`?String(t):``}function Ej(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function Dj(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function Oj(e){return e.lines.some(Dj)}function kj(e){let t=e.lines.reduce((e,t)=>Dj(t)?Math.max(e,Tj(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function Aj(e){return`calc(${e.lines.reduce((e,t)=>Math.max(e,Math.max(1,t.text.length)),1)}ch + 1.25rem)`}function jj(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-stone-200 bg-stone-100 text-stone-500`}function Mj(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-white text-amber-950/80`}function Nj({layout:e,line:t,lineNumberColumnWidth:n}){return(0,I.jsx)(`span`,{"data-file-line-number-cell":`true`,style:e===`compact`?{width:n,minWidth:n}:void 0,className:L(wj,e===`compact`?`sticky left-0 z-[1]`:`w-full shrink-0`,jj(t)),children:Tj(t)})}function Pj({line:e}){return(0,I.jsx)(`span`,{"data-file-code-row":`true`,className:L(`block min-w-0 flex-1 whitespace-pre px-2.5`,Mj(e)),children:e.text||` `})}function Fj({line:e,showLineNumbers:t,lineNumberColumnWidth:n}){return(0,I.jsxs)(`div`,{"data-file-line-row":`true`,className:Cj,children:[t?(0,I.jsx)(Nj,{layout:`compact`,line:e,lineNumberColumnWidth:n}):null,(0,I.jsx)(Pj,{line:e})]})}function Ij({block:e}){let t=Oj(e),n=kj(e),r=Aj(e);return(0,I.jsxs)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`workspace`,className:`flex h-full min-h-full min-w-full bg-white`,children:[t?(0,I.jsxs)(`div`,{"data-file-code-gutter":`true`,style:{width:n,minWidth:n},className:L(`flex h-full min-h-full shrink-0 flex-col`,Sj),children:[e.lines.map((e,t)=>(0,I.jsx)(Nj,{layout:`workspace`,line:e,lineNumberColumnWidth:n},Ej(`gutter`,e,t))),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 border-r border-stone-200 bg-stone-100`})]}):null,(0,I.jsxs)(`div`,{"data-file-code-canvas":`true`,className:`flex h-full min-h-full min-w-0 flex-1 flex-col bg-white`,children:[(0,I.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:r},children:e.lines.map((e,t)=>(0,I.jsx)(`div`,{"data-file-code-canvas-row":`true`,className:Cj,children:(0,I.jsx)(Pj,{line:e})},Ej(`code`,e,t)))}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 bg-white`})]})]})}function Lj({block:e,layout:t=`compact`}){if(t===`workspace`)return(0,I.jsx)(Ij,{block:e});let n=Oj(e),r=kj(e),i=Aj(e),a=n?`calc(${r} + ${i})`:i;return(0,I.jsx)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`compact`,className:`overflow-x-auto custom-scrollbar-amber bg-white`,children:(0,I.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:a},children:e.lines.map((e,t)=>(0,I.jsx)(Fj,{line:e,showLineNumbers:n,lineNumberColumnWidth:r},Ej(`row`,e,t)))})})}function Rj({block:e}){return(0,I.jsx)(Lj,{block:e,layout:`compact`})}function zj(e){return e.display===`preview`}function Bj(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
50
- `)}function Vj(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-stone-500`}function Hj(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,I.jsxs)(F.Fragment,{children:[t>0?(0,I.jsx)(`span`,{className:`text-stone-300`,children:`·`}):null,(0,I.jsx)(`span`,{className:L(Vj(e)),children:e})]},`${e}-${t}`))})}function Uj(e){return{path:e.path,label:e.path.split(`/`).filter(Boolean).pop()??e.path,viewMode:e.display===`diff`?`diff`:`preview`,...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},fullLines:e.fullLines??e.lines}}function Wj({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,F.useRef)(null),{onScroll:o}=fj({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:L(`overflow-y-auto bg-white custom-scrollbar-amber`,r),children:e})}function Gj({block:e,showPathRow:t,isFirst:n,onFileOpen:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Dc,c=zj(e),l=t||!!e.caption;return(0,I.jsxs)(`section`,{className:L(`overflow-hidden bg-white`,!n&&`border-t border-stone-200/80`),children:[l?(0,I.jsxs)(`div`,{className:L(`flex items-center justify-between gap-4 border-b border-stone-200/80 px-4 text-stone-700`,t?`py-2`:`py-1.5`),children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,I.jsx)(o,{delayDuration:250,children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>{r&&r(Uj(e))},className:L(`w-full truncate whitespace-nowrap text-left font-mono text-[12px] font-medium text-stone-700`,r&&`transition-colors hover:text-amber-900 hover:underline`),title:e.path,children:e.path})}),(0,I.jsx)(a,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?Hj(e.caption):null]}):null,e.lines.length>0?(0,I.jsx)(Wj,{resetKey:`block:${e.key}`,contentVersion:Bj(e),className:`max-h-72`,scrollKind:`block`,children:(0,I.jsx)(Rj,{block:e})}):e.rawText?(0,I.jsx)(Wj,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:e.rawText})})}):null,e.truncated&&!c?(0,I.jsx)(`div`,{className:`border-t border-stone-200/85 bg-stone-50 px-4 py-2 text-[10px] text-stone-500`,children:`Showing a shortened diff preview.`}):null]})}function Kj({card:e,className:t,onFileOpen:n}){let r=e.fileOperation?.blocks??[],i=e.output?.trim()??``;return r.length===0&&!i?null:(0,I.jsxs)(`div`,{className:L(`overflow-hidden bg-white`,t),children:[r.map((e,t)=>(0,I.jsx)(Gj,{block:e,showPathRow:!0,isFirst:t===0,onFileOpen:n},e.key)),i?(0,I.jsx)(Wj,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:i,className:L(`max-h-56`,r.length>0&&`border-t border-stone-200/80`),scrollKind:`output`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:i})})}):null]})}var qj=200,Jj=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`);function Yj(e){return typeof e==`string`&&e.length>0?e:null}function Xj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Zj(e){return e.replace(Jj,``)}function Qj(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function $j(e){let t=Yj(e.aggregated_output)??Yj(e.combinedOutput)??Yj(e.output);if(t)return t;let n=Yj(e.stdout),r=Yj(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
51
- `)}function eM(e,t){if(Xj(t)){let e=$j(t);if(e)return Zj(e);if(Qj(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return Zj(e);try{let t=JSON.parse(n);if(!Xj(t))return Zj(e);let r=$j(t);return r?Zj(r):Qj(t)?``:Zj(e)}catch{return Zj(e)}}function tM(e){return e===`write_file`||e===`edit_file`}function nM({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),u=(0,F.useRef)(t),d=(0,F.useRef)(!0);return(0,F.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,F.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},qj)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function rM({label:e,tone:t,children:n}){let r={input:{shell:`border-stone-200/80 bg-stone-50/90`,header:`border-stone-200/80 bg-stone-100/85 text-stone-500`,dot:`bg-stone-400/80`,body:`text-stone-700`},output:{shell:`border-amber-200/70 bg-white/90`,header:`border-amber-200/70 bg-amber-50/90 text-amber-700`,dot:`bg-amber-500/80`,body:`text-amber-950/80`},error:{shell:`border-rose-200/80 bg-rose-50/85`,header:`border-rose-200/80 bg-rose-100/80 text-rose-700`,dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,I.jsxs)(`section`,{className:L(`overflow-hidden rounded-md border shadow-[inset_0_1px_0_rgba(255,255,255,0.45)]`,r.shell),children:[(0,I.jsxs)(`div`,{className:L(`flex items-center gap-2 border-b px-3 py-2 text-[10px] font-semibold uppercase tracking-[0.16em]`,r.header),children:[(0,I.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,I.jsx)(`span`,{children:e})]}),(0,I.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,I.jsx)(`pre`,{className:L(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-3 py-2.5 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar-amber`,r.body),children:n})})]})}function iM({card:e}){let t=eM(e.output,e.outputData),n=e.statusTone===`running`,r=!!(e.summary?.trim()||t.trim().length>0),{expanded:i,onToggle:a}=nM({canExpand:t.trim().length>0||n,isRunning:n,autoExpandWhileRunning:!1,expandOnError:r,statusTone:e.statusTone}),o=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,I.jsxs)(hj,{children:[(0,I.jsx)(bj,{card:e,icon:Sr,expanded:i,canExpand:t.trim().length>0||n,onToggle:a}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-3 pb-2 font-mono w-full max-h-48 overflow-y-auto custom-scrollbar-amber min-h-0 text-[12px]`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 leading-relaxed`,children:[(0,I.jsx)(`span`,{className:`text-amber-500/50 font-medium shrink-0 select-none mt-[1px]`,children:`$`}),(0,I.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,I.jsxs)(`div`,{className:`text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block`,children:[o,n&&!t&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]}):(0,I.jsx)(`div`,{className:`h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2`})})]})}),t&&(0,I.jsx)(gj,{children:(0,I.jsxs)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed px-0`,children:[t,n&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]})})]})]})}function aM({card:e,onFileOpen:t}){let n=e.output?.trim()??``,r=e.statusTone===`running`,i=!!e.fileOperation?.blocks.length,a=i||!!n,o=e.fileOperation?.blocks??[],s=o.reduce((e,t)=>e+t.lines.length,0),c=o.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),l=tM(e.toolName)&&!(r&&e.toolName===`write_file`&&(s>24||c>1200)),{expanded:u,onToggle:d}=nM({canExpand:a||r,isRunning:r,autoExpandWhileRunning:l,expandOnError:a,statusTone:e.statusTone});return(0,I.jsxs)(hj,{children:[(0,I.jsx)(bj,{card:e,icon:e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`?Bn:Xn,expanded:u,canExpand:a||r,hideSummary:u&&i,onToggle:d}),u&&a&&(0,I.jsx)(gj,{className:`border-t border-amber-200/20 bg-transparent px-0 pt-0 pb-0`,children:(0,I.jsx)(Kj,{card:e,onFileOpen:t})})]})}function oM({card:e}){let t=e.statusTone===`running`,n=e.output?.trim()??``,{expanded:r,onToggle:i}=nM({canExpand:!!n||t,isRunning:t,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,I.jsxs)(hj,{children:[(0,I.jsx)(bj,{card:e,icon:mn,expanded:r,canExpand:!!n||t,onToggle:i}),r&&n&&(0,I.jsx)(gj,{children:(0,I.jsx)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed`,children:n})})]})}function sM({card:e,onToolAction:t,renderToolAgent:n}){let r=e.input?.trim()??``,i=e.output?.trim()??``,a=e.statusTone===`running`,o=r.length>0,s=i.length>0,c=o||s,l=e.inputLabel?.trim()||`Input`,u=e.outputLabel?.trim()||`Output`,{expanded:d,onToggle:f}=nM({canExpand:c||a,isRunning:a,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,I.jsxs)(hj,{children:[(0,I.jsx)(bj,{card:e,icon:or,expanded:d,canExpand:c||a,actionSlot:e.agentId||e.action&&t?(0,I.jsxs)(I.Fragment,{children:[e.agentId&&n?n(e.agentId):null,e.action&&t?(0,I.jsx)(xj,{action:e.action,onAction:t}):null]}):void 0,onToggle:f}),d&&c&&(0,I.jsxs)(gj,{className:`bg-transparent px-2.5 py-2.5`,children:[o&&(0,I.jsx)(rM,{label:l,tone:`input`,children:r}),o&&s&&(0,I.jsx)(`div`,{className:`h-2`}),s&&(0,I.jsx)(rM,{label:u,tone:e.statusTone===`error`?`error`:`output`,children:i})]})]})}function cM(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function lM(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function uM(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}function dM({card:e,onToolAction:t,onFileOpen:n,renderToolAgent:r}){return cM(e.toolName)?(0,I.jsx)(iM,{card:e}):lM(e.toolName)?(0,I.jsx)(aM,{card:e,onFileOpen:n}):uM(e.toolName)?(0,I.jsx)(oM,{card:e}):(0,I.jsx)(sM,{card:e,onToolAction:t,renderToolAgent:r})}function fM(e){return(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600`,children:[(0,I.jsxs)(`div`,{className:`font-semibold text-gray-700`,children:[e.label,`: `,e.rawType]}),e.text?(0,I.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500`,children:e.text}):null]})}var pM=(0,F.memo)(function(e){let{message:t,texts:n,onToolAction:r,onFileOpen:i,renderToolAgent:a}=e,{role:o}=t,s=o===`user`,c=t.status===`pending`||t.status===`streaming`;return(0,I.jsx)(`div`,{className:L(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm`,s?`border-primary bg-primary py-3 text-white`:o===`assistant`?`border-gray-200 bg-white pb-3 pt-4 text-gray-900`:`border-orange-200/80 bg-orange-50/70 py-3 text-gray-900`),children:(0,I.jsx)(`div`,{className:`space-y-2`,children:t.parts.map((e,l)=>{let{type:u}=e;return u===`markdown`?(0,I.jsx)(DA,{text:e.text,role:o,texts:n,onFileOpen:i},`markdown-${l}`):u===`inline-content`?(0,I.jsx)(jA,{segments:e.segments,role:o,texts:n,onFileOpen:i},`inline-content-${l}`):u===`reasoning`?(0,I.jsx)(mj,{label:e.label,text:e.text,isUser:s,isInProgress:c&&l===t.parts.length-1},`reasoning-${l}`):u===`tool-card`?(0,I.jsx)(`div`,{className:`mt-0.5`,children:(0,I.jsx)(dM,{card:e.card,onToolAction:r,onFileOpen:i,renderToolAgent:a})},`tool-${l}`):u===`file`?(0,I.jsx)(sj,{file:e.file,isUser:s,texts:n},`file-${l}`):u===`unknown`?(0,I.jsx)(fM,{label:e.label,rawType:e.rawType,text:e.text},`unknown-${l}`):null})})})});function mM(e){return(0,I.jsxs)(`div`,{className:L(`px-1 text-[11px] leading-4 text-gray-400`,e.isUser?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]})}function hM({message:e,texts:t}){let n=(0,F.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e&&e.trim().length>0).join(`
48
+ `)?t.slice(0,-1):t}function vA(e){return(e?hA.exec(e):null)?.[1]?.toLowerCase()||`text`}function yA({className:e,children:t,texts:n}){let r=(0,F.useMemo)(()=>vA(e),[e]),i=(0,F.useMemo)(()=>_A(t),[t]),a=(0,F.useMemo)(()=>mA.highlight(i,r),[i,r]),o=(0,F.useMemo)(()=>{let t=`language-${a.language}`;return L(`hljs`,e,e?.includes(`language-`)?void 0:t)},[e,a.language]),{copied:s,copy:c}=Ck({text:i});return(0,I.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,I.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,I.jsx)(`span`,{className:`chat-codeblock-language`,children:r}),(0,I.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void c(),"aria-label":s?n.copiedCodeLabel:n.copyCodeLabel,children:[s?(0,I.jsx)(In,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Vn,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:s?n.copiedCodeLabel:n.copyCodeLabel})]})]}),(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{className:o,"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})})]})}var bA=14e4,xA=new Set([`http:`,`https:`,`mailto:`,`tel:`]),SA=[`cjs`,`css`,`cts`,`js`,`json`,`jsx`,`md`,`mdx`,`mjs`,`mts`,`tsx`,`ts`,`txt`,`yaml`,`yml`].join(`|`),CA=RegExp(`^(?![a-zA-Z][a-zA-Z\\d+.-]*:)(?!//)(?:(?:[^/\\s?#]+/)+[^?#\\s]+\\.[A-Za-z0-9_-]+|[^/\\s?#]+\\.(?:${SA}))(?::\\d+(?::\\d+)?)?(?:[?#].*)?$`,`i`);function wA(e){return e.length<=bA?e:`${e.slice(0,bA)}\n\n...`}function TA(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||CA.test(e))return e;try{let t=new URL(e);return xA.has(t.protocol)?e:null}catch{return null}}function EA(e){return/^https?:\/\//i.test(e)}function DA(e){return e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/Users/`)||e.startsWith(`/home/`)||e.startsWith(`/tmp/`)||e.startsWith(`/var/`)||CA.test(e)||/^\/.+\.[A-Za-z0-9_-]+(?::\d+(?::\d+)?)?$/.test(e)}function OA(e){let t=e.split(`#`)[0]?.split(`?`)[0]??e,n=decodeURIComponent(t);if(!DA(n))return null;let r=/^(.*?)(?::(\d+)(?::(\d+))?)$/.exec(n),i=r?.[1]??n,a=r?.[2]?Number(r[2]):void 0,o=r?.[3]?Number(r[3]):void 0;return{path:i,label:i.split(`/`).filter(Boolean).pop()??i,viewMode:`preview`,...typeof a==`number`?{line:a}:{},...typeof o==`number`?{column:o}:{}}}function kA({text:e,role:t,texts:n,inline:r=!1,onFileOpen:i}){let a=t===`user`,o=(0,F.useMemo)(()=>({p:({children:e})=>r?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsx)(`p`,{children:e}),a:({href:e,children:t,...n})=>{let r=TA(e);if(!r)return(0,I.jsx)(`span`,{className:`chat-link-invalid`,children:t});let a=EA(r),o=a?null:OA(r),s=e=>{!i||!o||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(o))};return(0,I.jsx)(`a`,{...n,href:r,onClick:s,target:a?`_blank`:void 0,rel:a?`noreferrer noopener`:void 0,children:t})},table:({children:e,...t})=>(0,I.jsx)(`div`,{className:`chat-table-wrap`,children:(0,I.jsx)(`table`,{...t,children:e})}),input:({type:e,checked:t,...n})=>e===`checkbox`?(0,I.jsx)(`input`,{...n,type:`checkbox`,checked:t,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,I.jsx)(`input`,{...n,type:e}),img:({src:e,alt:t,...n})=>{let r=TA(e);return r?(0,I.jsx)(`img`,{...n,src:r,alt:t||``,loading:`lazy`,decoding:`async`}):null},code:({className:e,children:t,...r})=>!e&&!String(t??``).includes(`
49
+ `)?(0,I.jsx)(`code`,{...r,className:L(`chat-inline-code`,e),children:t}):(0,I.jsx)(yA,{className:e,texts:n,children:t})}),[r,i,n]);return(0,I.jsx)(r?`span`:`div`,{className:L(`chat-markdown`,a?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,I.jsx)(pE,{skipHtml:!0,remarkPlugins:[_k],components:o,children:wA(e)})})}function AA(e){return e.split(`​`).join(``).split(`‌`).join(``).split(`‍`).join(``).split(`⁠`).join(``).split(``).join(``).length>0}function jA(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,I.jsx)(`path`,{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}),(0,I.jsx)(`path`,{d:`M2.75 10 8.5 13.25 14.25 10`}),(0,I.jsx)(`path`,{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}),(0,I.jsx)(`path`,{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`})]})}function MA({kind:e,label:t,isUser:n}){let r=e===`skill`;return(0,I.jsxs)(`span`,{className:L(`mx-[2px] inline-flex h-7 max-w-full items-center gap-1.5 rounded-xl border px-2.5 align-baseline text-[11px] font-medium shadow-[0_0_0_1px_rgba(15,23,42,0.03)]`,r?n?`border-emerald-200/35 bg-emerald-400/18 text-emerald-50/95`:`border-emerald-200/70 bg-emerald-50 text-emerald-700`:n?`border-white/30 bg-white/18 text-white`:`border-slate-200/80 bg-slate-100 text-slate-700`),title:t,children:[(0,I.jsx)(`span`,{className:L(`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,r?n?`text-emerald-100/90`:`text-emerald-600`:n?`text-white/70`:`text-slate-500`),children:(0,I.jsx)(jA,{})}),(0,I.jsx)(`span`,{className:`truncate`,children:t})]})}function NA({segments:e,role:t,texts:n,onFileOpen:r}){let i=t===`user`;return(0,I.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e.map((e,a)=>e.type===`token`?(0,I.jsx)(MA,{kind:e.token.kind,label:e.token.label,isUser:i},`token-${a}-${e.token.kind}-${e.token.key}`):AA(e.text)?(0,I.jsx)(kA,{text:e.text,role:t,texts:n,inline:!0,onFileOpen:r},`markdown-${a}`):(0,I.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text},`space-${a}`))})}var PA={archive:`border-amber-200/80 bg-amber-50 text-amber-700`,audio:`border-fuchsia-200/80 bg-fuchsia-50 text-fuchsia-700`,code:`border-cyan-200/80 bg-cyan-50 text-cyan-700`,data:`border-slate-200/80 bg-slate-50 text-slate-700`,document:`border-blue-200/80 bg-blue-50 text-blue-700`,generic:`border-slate-200/80 bg-slate-50 text-slate-700`,image:`border-emerald-200/80 bg-emerald-50 text-emerald-700`,pdf:`border-rose-200/80 bg-rose-50 text-rose-700`,sheet:`border-lime-200/80 bg-lime-50 text-lime-700`,video:`border-violet-200/80 bg-violet-50 text-violet-700`},FA=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),IA=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),LA=new Set([`avif`,`bmp`,`gif`,`heic`,`heif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`tif`,`tiff`,`webp`]),RA=new Set([`aac`,`flac`,`m4a`,`mp3`,`ogg`,`opus`,`wav`,`weba`]),zA=new Set([`avi`,`m4v`,`mov`,`mp4`,`mkv`,`webm`,`wmv`]),BA=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),VA=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),HA=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function UA(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function WA(e,t){let n=GA(e);if(n)return n.toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function GA(e){return/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``}function KA(e){return typeof e==`string`&&/^data:image\//i.test(e.trim())}function qA(e){return LA.has(e)?e===`jpg`||e===`jpeg`?`image/jpeg`:e===`svg`?`image/svg+xml`:`image/${e}`:RA.has(e)?e===`mp3`?`audio/mpeg`:e===`m4a`?`audio/mp4`:e===`weba`?`audio/webm`:`audio/${e}`:zA.has(e)?e===`mov`?`video/quicktime`:e===`m4v`?`video/mp4`:`video/${e}`:e===`pdf`?`application/pdf`:null}function JA(e){let t=GA(e);return t?qA(t):null}function YA(e){let t=e.mimeType.trim().toLowerCase();return t.length>0&&t!==`application/octet-stream`?t:JA(e.label)}function XA(e){let t=e.mimeType.trim().toLowerCase(),n=GA(e.label);return e.isImage||t.startsWith(`image/`)||LA.has(n)||KA(e.dataUrl)}function ZA(e,t){let n=GA(e),r=t.toLowerCase();return r.startsWith(`image/`)||LA.has(n)?`image`:r.startsWith(`audio/`)||RA.has(n)?`audio`:r.startsWith(`video/`)||zA.has(n)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:HA.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:VA.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:IA.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:FA.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:BA.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function QA(e){let t=ZA(e.label,e.mimeType),n=UA(e.sizeBytes);return{category:t,extension:WA(e.label,e.mimeType),sizeLabel:n}}var $A={archive:`Archive`,audio:`Audio`,code:`Code file`,data:`Data file`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF document`,sheet:`Spreadsheet`,video:`Video`},ej={archive:Wn,audio:Gn,code:Kn,data:Jn,document:Xn,generic:Qn,image:qn,pdf:Xn,sheet:Yn,video:Zn};function tj(e,t){return t?.attachmentCategoryLabels?.[e]??$A[e]}function nj(e,t,n){return(0,I.jsx)(`div`,{className:L(`mt-1 text-xs leading-5`,n?`text-white/70`:`text-slate-500`),children:t?`${e} · ${t}`:e})}function rj(e,t,n){return(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,n?t?`border-white/14 bg-white/12 text-white`:`border-slate-200/80 bg-white text-slate-700`:t?`border-white/10 bg-white/6 text-white/62`:`border-slate-200/70 bg-slate-100/80 text-slate-500`),children:e})}function ij(e,t,n){return(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:L(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium transition duration-200`,n?`border-white/14 bg-white/12 text-white hover:border-white/20 hover:bg-white/16`:`border-slate-200/80 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50`),children:e})}function aj({category:e,isUser:t}){let n=ej[e];return(0,I.jsx)(`div`,{className:L(`flex h-14 w-14 shrink-0 items-center justify-center rounded-[1rem] border`,t?`border-white/12 bg-white/10 text-white`:PA[e]),children:(0,I.jsx)(n,{className:L(`h-7 w-7`,t?`text-white/92`:`text-current`),strokeWidth:2.2})})}function oj(e){let{file:t,categoryLabel:n,sizeLabel:r,isUser:i}=e;return t.dataUrl?(0,I.jsx)(`a`,{href:t.dataUrl,target:`_blank`,rel:`noreferrer`,className:`group block`,children:(0,I.jsxs)(`div`,{className:L(`relative overflow-hidden rounded-[1rem]`,i?`ring-1 ring-white/10`:`bg-slate-100/80 ring-1 ring-slate-200/80`),children:[(0,I.jsx)(`img`,{src:t.dataUrl,alt:t.label,className:`block h-auto max-h-[26rem] w-full rounded-[1rem] bg-transparent object-contain transition duration-300 group-hover:scale-[1.01]`}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute right-3 top-3 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full px-2 py-1 text-[10px] font-semibold tracking-[0.18em] text-white backdrop-blur-sm`,i?`bg-slate-950/36`:`bg-slate-950/58`),children:n}),r?(0,I.jsx)(`span`,{className:L(`inline-flex items-center rounded-full px-2 py-1 text-[10px] font-medium text-white/92 backdrop-blur-sm`,i?`bg-slate-950/28`:`bg-slate-950/46`),children:r}):null]})]})}):null}function sj(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:o}=e;return(0,I.jsxs)(`div`,{className:`flex items-center gap-3 p-3.5`,children:[(0,I.jsx)(aj,{category:t,isUser:a}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-[15px] font-semibold leading-5`,children:n.label}),nj(r,i,a)]}),o]})})]})}function cj(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,shellClasses:o,actionLabel:s}=e;if(!n.dataUrl||t!==`audio`&&t!==`video`)return null;let c=YA(n);return(0,I.jsxs)(`div`,{className:o,children:[sj({category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:ij(s,n.dataUrl,a)}),(0,I.jsx)(`div`,{className:`px-3.5 pb-3.5`,children:t===`audio`?(0,I.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n.label,className:`block w-full`,children:(0,I.jsx)(`source`,{src:n.dataUrl,...c?{type:c}:{}})}):(0,I.jsx)(`div`,{className:L(`overflow-hidden rounded-[1rem] border`,a?`border-white/10 bg-slate-950/26`:`border-slate-200/80 bg-slate-100/80`),children:(0,I.jsx)(`video`,{controls:!0,preload:`metadata`,playsInline:!0,"aria-label":n.label,className:`block max-h-[28rem] w-full bg-black`,children:(0,I.jsx)(`source`,{src:n.dataUrl,...c?{type:c}:{}})})})})]})}function lj({file:e,isUser:t=!1,texts:n}){let{category:r,sizeLabel:i}=QA(e),a=XA(e)&&!!e.dataUrl,o=r===`audio`&&!!e.dataUrl,s=r===`video`&&!!e.dataUrl,c=!!e.dataUrl,l=c?n?.attachmentOpenLabel??`Open`:n?.attachmentAttachedLabel??`Attached`,u=tj(r,n),d=L(`block overflow-hidden rounded-[1.25rem] border transition duration-200`,t?`border-white/12 bg-white/10 text-white`:`border-slate-200/80 bg-white/95 text-slate-900`,c&&(t?`hover:border-white/18 hover:bg-white/13`:`hover:border-slate-300 hover:bg-white`));if(a)return oj({file:e,categoryLabel:u,sizeLabel:i,isUser:t});if(o||s)return cj({category:r,file:e,categoryLabel:u,sizeLabel:i,isUser:t,shellClasses:d,actionLabel:l});let f=sj({category:r,file:e,categoryLabel:u,sizeLabel:i,isUser:t,action:rj(l,t,c)});return!c||!e.dataUrl?(0,I.jsx)(`div`,{className:d,children:f}):(0,I.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:L(d,`group`),children:f})}function uj(e){let{isInProgress:t}=e,[n,r]=(0,F.useState)(t),[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(t);(0,F.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}var dj=10;function fj(e){e.scrollTop=e.scrollHeight}function pj(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;let t=e.scrollRef.current;t&&(e.isProgrammaticScrollRef.current=!0,fj(t))}))}function mj(e){let t=(0,F.useRef)(!0),n=(0,F.useRef)(!1),r=(0,F.useRef)(null),i=(0,F.useRef)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),(0,F.useEffect)(()=>{let e=a.current;return()=>{e!==null&&cancelAnimationFrame(e)}},[]),(0,F.useLayoutEffect)(()=>{!i.current||e.isLoading||!e.hasContent||e.scrollRef.current&&(i.current=!1,pj({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),(0,F.useLayoutEffect)(()=>{!t.current||!e.hasContent||e.scrollRef.current&&pj({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:()=>{if(n.current){n.current=!1;return}let r=e.scrollRef.current;r&&(t.current=r.scrollHeight-r.scrollTop-r.clientHeight<=(e.stickyThresholdPx??dj))}}}function hj(e){let t=e.trim().toLowerCase();return t===`reasoning`||t===`thinking`||t===`推理`||t===`推理过程`||t===`思考过程`||t===`思考`?`思考`:e}function gj({label:e,text:t,isUser:n,isInProgress:r}){let{isOpen:i,onSummaryClick:a}=uj({isInProgress:r}),o=(0,F.useRef)(null),s=hj(e),{onScroll:c}=mj({scrollRef:o,resetKey:`${s}:${r?`streaming`:`idle`}`,isLoading:!1,hasContent:t.length>0,contentVersion:t,stickyThresholdPx:20});return(0,I.jsxs)(`details`,{className:`mt-2`,open:i,children:[(0,I.jsx)(`summary`,{className:L(`cursor-pointer text-xs`,n?`text-primary-100`:`text-gray-500`),onClick:a,children:s}),(0,I.jsx)(`div`,{ref:o,onScroll:c,"data-reasoning-scroll":`true`,className:L(`mt-2 w-fit max-w-[500px] max-h-56 overflow-y-auto rounded-lg custom-scrollbar-amber`,n?`bg-primary-700/60`:`bg-gray-100`),children:(0,I.jsx)(`pre`,{className:`min-w-0 whitespace-pre-wrap break-all p-2 text-[11px]`,children:t})})]})}function _j({children:e,className:t}){return(0,I.jsx)(`div`,{className:L(`my-2 rounded-lg border border-amber-200/50 bg-amber-100/30 shadow-sm overflow-hidden text-[12px]`,`w-[280px] sm:w-[360px] md:w-[480px] min-w-full max-w-full transition-all flex flex-col`,t),children:e})}function vj({children:e,className:t}){return(0,I.jsx)(`div`,{className:L(`border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden`,t),children:e})}var yj={running:{text:`text-amber-500/80`,icon:$t,spin:!0},success:{text:`text-amber-500/80`,icon:In,spin:!1},error:{text:`text-amber-500/80`,icon:y,spin:!1},cancelled:{text:`text-amber-500/80`,icon:fr,spin:!1}};function bj({card:e}){let t=yj[e.statusTone]||yj.cancelled,n=t.icon;return(0,I.jsxs)(`span`,{className:L(`inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0`,t.text),children:[(0,I.jsx)(n,{className:L(`h-3.5 w-3.5`,t.spin&&`animate-spin`),strokeWidth:3}),e.statusTone===`running`?e.statusLabel:null]})}function xj({action:e,onAction:t}){let n=e.sessionKind===`child`?`Open child session`:`Open session`;return(0,I.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:L(`inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors`,`border-amber-200/80 bg-white/80 text-amber-800 hover:bg-amber-50`),"aria-label":n,title:n,children:(0,I.jsx)(Mn,{className:`h-3 w-3`,strokeWidth:2.5})})}function Sj({card:e,icon:t,expanded:n,canExpand:r,hideSummary:i=!1,actionSlot:a,onToggle:o}){let s=i?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``;return(0,I.jsxs)(`div`,{className:L(`flex items-center gap-3 px-3 py-2.5 transition-colors bg-transparent`,r?`cursor-pointer hover:bg-amber-100/30`:``),onClick:o,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden font-mono text-amber-950/80`,children:[(0,I.jsx)(t,{className:`h-4 w-4 text-amber-600/80 shrink-0`,strokeWidth:3}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden`,children:[(0,I.jsx)(`span`,{className:`font-bold shrink-0 tracking-tight`,children:e.toolName}),s&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-amber-300 font-bold select-none shrink-0`,children:`›`}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate font-normal`,title:s,children:s})]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[a,(0,I.jsx)(bj,{card:e}),r&&(n?(0,I.jsx)(Ln,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}):(0,I.jsx)(Rn,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}))]})]})}function Cj({action:e,onAction:t}){return(0,I.jsx)(xj,{action:e,onAction:t})}var wj=`font-mono text-[11px] leading-5`,Tj=`flex h-5 w-full ${wj}`,Ej=`flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function Dj(e){let t=e.newLineNumber??e.oldLineNumber;return typeof t==`number`?String(t):``}function Oj(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function kj(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function Aj(e){return e.lines.some(kj)}function jj(e){let t=e.lines.reduce((e,t)=>kj(t)?Math.max(e,Dj(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function Mj(e){return`calc(${e.lines.reduce((e,t)=>Math.max(e,Math.max(1,t.text.length)),1)}ch + 1.25rem)`}function Nj(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-stone-200 bg-stone-100 text-stone-500`}function Pj(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-white text-amber-950/80`}function Fj({layout:e,line:t,lineNumberColumnWidth:n}){return(0,I.jsx)(`span`,{"data-file-line-number-cell":`true`,style:e===`compact`?{width:n,minWidth:n}:void 0,className:L(Ej,e===`compact`?`sticky left-0 z-[1]`:`w-full shrink-0`,Nj(t)),children:Dj(t)})}function Ij({line:e}){return(0,I.jsx)(`span`,{"data-file-code-row":`true`,className:L(`block min-w-0 flex-1 whitespace-pre px-2.5`,Pj(e)),children:e.text||` `})}function Lj({line:e,showLineNumbers:t,lineNumberColumnWidth:n}){return(0,I.jsxs)(`div`,{"data-file-line-row":`true`,className:Tj,children:[t?(0,I.jsx)(Fj,{layout:`compact`,line:e,lineNumberColumnWidth:n}):null,(0,I.jsx)(Ij,{line:e})]})}function Rj({block:e}){let t=Aj(e),n=jj(e),r=Mj(e);return(0,I.jsxs)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`workspace`,className:`flex h-full min-h-full min-w-full bg-white`,children:[t?(0,I.jsxs)(`div`,{"data-file-code-gutter":`true`,style:{width:n,minWidth:n},className:L(`flex h-full min-h-full shrink-0 flex-col`,wj),children:[e.lines.map((e,t)=>(0,I.jsx)(Fj,{layout:`workspace`,line:e,lineNumberColumnWidth:n},Oj(`gutter`,e,t))),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 border-r border-stone-200 bg-stone-100`})]}):null,(0,I.jsxs)(`div`,{"data-file-code-canvas":`true`,className:`flex h-full min-h-full min-w-0 flex-1 flex-col bg-white`,children:[(0,I.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:r},children:e.lines.map((e,t)=>(0,I.jsx)(`div`,{"data-file-code-canvas-row":`true`,className:Tj,children:(0,I.jsx)(Ij,{line:e})},Oj(`code`,e,t)))}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 bg-white`})]})]})}function zj({block:e,layout:t=`compact`}){if(t===`workspace`)return(0,I.jsx)(Rj,{block:e});let n=Aj(e),r=jj(e),i=Mj(e),a=n?`calc(${r} + ${i})`:i;return(0,I.jsx)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`compact`,className:`overflow-x-auto custom-scrollbar-amber bg-white`,children:(0,I.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:a},children:e.lines.map((e,t)=>(0,I.jsx)(Lj,{line:e,showLineNumbers:n,lineNumberColumnWidth:r},Oj(`row`,e,t)))})})}function Bj({block:e}){return(0,I.jsx)(zj,{block:e,layout:`compact`})}function Vj(e){return e.display===`preview`}function Hj(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
50
+ `)}function Uj(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-stone-500`}function Wj(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,I.jsxs)(F.Fragment,{children:[t>0?(0,I.jsx)(`span`,{className:`text-stone-300`,children:`·`}):null,(0,I.jsx)(`span`,{className:L(Uj(e)),children:e})]},`${e}-${t}`))})}function Gj(e){return{path:e.path,label:e.path.split(`/`).filter(Boolean).pop()??e.path,viewMode:e.display===`diff`?`diff`:`preview`,...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},fullLines:e.fullLines??e.lines}}function Kj({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,F.useRef)(null),{onScroll:o}=mj({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:L(`overflow-y-auto bg-white custom-scrollbar-amber`,r),children:e})}function qj({block:e,showPathRow:t,isFirst:n,onFileOpen:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=Dc,c=Vj(e),l=t||!!e.caption;return(0,I.jsxs)(`section`,{className:L(`overflow-hidden bg-white`,!n&&`border-t border-stone-200/80`),children:[l?(0,I.jsxs)(`div`,{className:L(`flex items-center justify-between gap-4 border-b border-stone-200/80 px-4 text-stone-700`,t?`py-2`:`py-1.5`),children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,I.jsx)(o,{delayDuration:250,children:(0,I.jsxs)(i,{children:[(0,I.jsx)(s,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,onClick:()=>{r&&r(Gj(e))},className:L(`w-full truncate whitespace-nowrap text-left font-mono text-[12px] font-medium text-stone-700`,r&&`transition-colors hover:text-amber-900 hover:underline`),title:e.path,children:e.path})}),(0,I.jsx)(a,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?Wj(e.caption):null]}):null,e.lines.length>0?(0,I.jsx)(Kj,{resetKey:`block:${e.key}`,contentVersion:Hj(e),className:`max-h-72`,scrollKind:`block`,children:(0,I.jsx)(Bj,{block:e})}):e.rawText?(0,I.jsx)(Kj,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:e.rawText})})}):null,e.truncated&&!c?(0,I.jsx)(`div`,{className:`border-t border-stone-200/85 bg-stone-50 px-4 py-2 text-[10px] text-stone-500`,children:`Showing a shortened diff preview.`}):null]})}function Jj({card:e,className:t,onFileOpen:n}){let r=e.fileOperation?.blocks??[],i=e.output?.trim()??``;return r.length===0&&!i?null:(0,I.jsxs)(`div`,{className:L(`overflow-hidden bg-white`,t),children:[r.map((e,t)=>(0,I.jsx)(qj,{block:e,showPathRow:!0,isFirst:t===0,onFileOpen:n},e.key)),i?(0,I.jsx)(Kj,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:i,className:L(`max-h-56`,r.length>0&&`border-t border-stone-200/80`),scrollKind:`output`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:i})})}):null]})}var Yj=200,Xj=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`);function Zj(e){return typeof e==`string`&&e.length>0?e:null}function Qj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $j(e){return e.replace(Xj,``)}function eM(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function tM(e){let t=Zj(e.aggregated_output)??Zj(e.combinedOutput)??Zj(e.output);if(t)return t;let n=Zj(e.stdout),r=Zj(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
51
+ `)}function nM(e,t){if(Qj(t)){let e=tM(t);if(e)return $j(e);if(eM(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return $j(e);try{let t=JSON.parse(n);if(!Qj(t))return $j(e);let r=tM(t);return r?$j(r):eM(t)?``:$j(e)}catch{return $j(e)}}function rM(e){return e===`write_file`||e===`edit_file`}function iM({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(null),u=(0,F.useRef)(t),d=(0,F.useRef)(!0);return(0,F.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,F.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},Yj)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function aM({label:e,tone:t,children:n}){let r={input:{shell:`border-stone-200/80 bg-stone-50/90`,header:`border-stone-200/80 bg-stone-100/85 text-stone-500`,dot:`bg-stone-400/80`,body:`text-stone-700`},output:{shell:`border-amber-200/70 bg-white/90`,header:`border-amber-200/70 bg-amber-50/90 text-amber-700`,dot:`bg-amber-500/80`,body:`text-amber-950/80`},error:{shell:`border-rose-200/80 bg-rose-50/85`,header:`border-rose-200/80 bg-rose-100/80 text-rose-700`,dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,I.jsxs)(`section`,{className:L(`overflow-hidden rounded-md border shadow-[inset_0_1px_0_rgba(255,255,255,0.45)]`,r.shell),children:[(0,I.jsxs)(`div`,{className:L(`flex items-center gap-2 border-b px-3 py-2 text-[10px] font-semibold uppercase tracking-[0.16em]`,r.header),children:[(0,I.jsx)(`span`,{className:L(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,I.jsx)(`span`,{children:e})]}),(0,I.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,I.jsx)(`pre`,{className:L(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-3 py-2.5 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar-amber`,r.body),children:n})})]})}function oM({card:e}){let t=nM(e.output,e.outputData),n=e.statusTone===`running`,r=!!(e.summary?.trim()||t.trim().length>0),{expanded:i,onToggle:a}=iM({canExpand:t.trim().length>0||n,isRunning:n,autoExpandWhileRunning:!1,expandOnError:r,statusTone:e.statusTone}),o=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,I.jsxs)(_j,{children:[(0,I.jsx)(Sj,{card:e,icon:Sr,expanded:i,canExpand:t.trim().length>0||n,onToggle:a}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-3 pb-2 font-mono w-full max-h-48 overflow-y-auto custom-scrollbar-amber min-h-0 text-[12px]`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 leading-relaxed`,children:[(0,I.jsx)(`span`,{className:`text-amber-500/50 font-medium shrink-0 select-none mt-[1px]`,children:`$`}),(0,I.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,I.jsxs)(`div`,{className:`text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block`,children:[o,n&&!t&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]}):(0,I.jsx)(`div`,{className:`h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2`})})]})}),t&&(0,I.jsx)(vj,{children:(0,I.jsxs)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed px-0`,children:[t,n&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]})})]})]})}function sM({card:e,onFileOpen:t}){let n=e.output?.trim()??``,r=e.statusTone===`running`,i=!!e.fileOperation?.blocks.length,a=i||!!n,o=e.fileOperation?.blocks??[],s=o.reduce((e,t)=>e+t.lines.length,0),c=o.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),l=rM(e.toolName)&&!(r&&e.toolName===`write_file`&&(s>24||c>1200)),{expanded:u,onToggle:d}=iM({canExpand:a||r,isRunning:r,autoExpandWhileRunning:l,expandOnError:a,statusTone:e.statusTone});return(0,I.jsxs)(_j,{children:[(0,I.jsx)(Sj,{card:e,icon:e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`?Bn:Xn,expanded:u,canExpand:a||r,hideSummary:u&&i,onToggle:d}),u&&a&&(0,I.jsx)(vj,{className:`border-t border-amber-200/20 bg-transparent px-0 pt-0 pb-0`,children:(0,I.jsx)(Jj,{card:e,onFileOpen:t})})]})}function cM({card:e}){let t=e.statusTone===`running`,n=e.output?.trim()??``,{expanded:r,onToggle:i}=iM({canExpand:!!n||t,isRunning:t,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,I.jsxs)(_j,{children:[(0,I.jsx)(Sj,{card:e,icon:mn,expanded:r,canExpand:!!n||t,onToggle:i}),r&&n&&(0,I.jsx)(vj,{children:(0,I.jsx)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed`,children:n})})]})}function lM({card:e,onToolAction:t,renderToolAgent:n}){let r=e.input?.trim()??``,i=e.output?.trim()??``,a=e.statusTone===`running`,o=r.length>0,s=i.length>0,c=o||s,l=e.inputLabel?.trim()||`Input`,u=e.outputLabel?.trim()||`Output`,{expanded:d,onToggle:f}=iM({canExpand:c||a,isRunning:a,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,I.jsxs)(_j,{children:[(0,I.jsx)(Sj,{card:e,icon:or,expanded:d,canExpand:c||a,actionSlot:e.agentId||e.action&&t?(0,I.jsxs)(I.Fragment,{children:[e.agentId&&n?n(e.agentId):null,e.action&&t?(0,I.jsx)(Cj,{action:e.action,onAction:t}):null]}):void 0,onToggle:f}),d&&c&&(0,I.jsxs)(vj,{className:`bg-transparent px-2.5 py-2.5`,children:[o&&(0,I.jsx)(aM,{label:l,tone:`input`,children:r}),o&&s&&(0,I.jsx)(`div`,{className:`h-2`}),s&&(0,I.jsx)(aM,{label:u,tone:e.statusTone===`error`?`error`:`output`,children:i})]})]})}function uM(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function dM(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function fM(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}function pM({card:e,onToolAction:t,onFileOpen:n,renderToolAgent:r}){return uM(e.toolName)?(0,I.jsx)(oM,{card:e}):dM(e.toolName)?(0,I.jsx)(sM,{card:e,onFileOpen:n}):fM(e.toolName)?(0,I.jsx)(cM,{card:e}):(0,I.jsx)(lM,{card:e,onToolAction:t,renderToolAgent:r})}function mM(e){return(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600`,children:[(0,I.jsxs)(`div`,{className:`font-semibold text-gray-700`,children:[e.label,`: `,e.rawType]}),e.text?(0,I.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500`,children:e.text}):null]})}var hM=(0,F.memo)(function(e){let{message:t,texts:n,onToolAction:r,onFileOpen:i,renderToolAgent:a}=e,{role:o}=t,s=o===`user`,c=t.status===`pending`||t.status===`streaming`;return(0,I.jsx)(`div`,{className:L(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm`,s?`border-primary bg-primary py-3 text-white`:o===`assistant`?`border-gray-200 bg-white pb-3 pt-4 text-gray-900`:`border-orange-200/80 bg-orange-50/70 py-3 text-gray-900`),children:(0,I.jsx)(`div`,{className:`space-y-2`,children:t.parts.map((e,l)=>{let{type:u}=e;return u===`markdown`?(0,I.jsx)(kA,{text:e.text,role:o,texts:n,onFileOpen:i},`markdown-${l}`):u===`inline-content`?(0,I.jsx)(NA,{segments:e.segments,role:o,texts:n,onFileOpen:i},`inline-content-${l}`):u===`reasoning`?(0,I.jsx)(gj,{label:e.label,text:e.text,isUser:s,isInProgress:c&&l===t.parts.length-1},`reasoning-${l}`):u===`tool-card`?(0,I.jsx)(`div`,{className:`mt-0.5`,children:(0,I.jsx)(pM,{card:e.card,onToolAction:r,onFileOpen:i,renderToolAgent:a})},`tool-${l}`):u===`file`?(0,I.jsx)(lj,{file:e.file,isUser:s,texts:n},`file-${l}`):u===`unknown`?(0,I.jsx)(mM,{label:e.label,rawType:e.rawType,text:e.text},`unknown-${l}`):null})})})});function gM(e){return(0,I.jsxs)(`div`,{className:L(`px-1 text-[11px] leading-4 text-gray-400`,e.isUser?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]})}function _M({message:e,texts:t}){let n=(0,F.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e&&e.trim().length>0).join(`
52
52
 
53
- `),[e.parts]),{copied:r,copy:i}=Ck({text:n});return n?(0,I.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`text-gray-400 hover:text-gray-600 transition-colors p-1 rounded-md hover:bg-gray-100 flex items-center justify-center`,"aria-label":r?t.copiedMessageLabel:t.copyMessageLabel,title:r?t.copiedMessageLabel:t.copyMessageLabel,children:r?(0,I.jsx)(In,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Vn,{className:`h-3.5 w-3.5`})}):null}var gM=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g,_M=`
53
+ `),[e.parts]),{copied:r,copy:i}=Ck({text:n});return n?(0,I.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`text-gray-400 hover:text-gray-600 transition-colors p-1 rounded-md hover:bg-gray-100 flex items-center justify-center`,"aria-label":r?t.copiedMessageLabel:t.copyMessageLabel,title:r?t.copiedMessageLabel:t.copyMessageLabel,children:r?(0,I.jsx)(In,{className:`h-3.5 w-3.5`}):(0,I.jsx)(Vn,{className:`h-3.5 w-3.5`})}):null}var vM=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g,yM=`
54
54
  @keyframes nextclaw-chat-typing-text-sheen {
55
55
  0% {
56
56
  background-position: 160% 0;
@@ -88,14 +88,14 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
88
88
  -webkit-text-fill-color: currentColor;
89
89
  }
90
90
  }
91
- `;function vM(e){let t=e.trim();return t?t.replace(gM,``).trim().length>0:!1}function yM(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?vM(e.text):!0)}function bM(){return(0,I.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-gray-400`,children:(0,I.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:200ms]`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:400ms]`})]})})}function xM({label:e}){return(0,I.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm`,children:[(0,I.jsx)(`style`,{children:_M}),(0,I.jsx)(`span`,{className:`nextclaw-chat-typing-indicator__text`,children:e})]})}function SM(e){let t=e.messages.filter(yM),n=t.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,I.jsxs)(`div`,{className:L(`space-y-5`,e.className),children:[t.map(t=>{let n=t.role===`user`,r=!n&&(t.status===`streaming`||t.status===`pending`);return(0,I.jsxs)(`div`,{className:L(`flex gap-3`,n?`justify-end`:`justify-start`),children:[n?null:(0,I.jsx)(Fy,{role:t.role}),(0,I.jsxs)(`div`,{className:L(`w-fit max-w-[92%] space-y-2`,n&&`flex flex-col items-end`),children:[(0,I.jsx)(pM,{message:t,texts:e.texts,onToolAction:e.onToolAction,onFileOpen:e.onFileOpen,renderToolAgent:e.renderToolAgent}),(0,I.jsx)(`div`,{className:L(`flex items-center gap-2`,n&&`justify-end`),children:r?(0,I.jsx)(bM,{}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mM,{roleLabel:t.roleLabel,timestampLabel:t.timestampLabel,isUser:n}),n?null:(0,I.jsx)(hM,{message:t,texts:e.texts})]})})]}),n?(0,I.jsx)(Fy,{role:t.role}):null]},t.id)}),e.isSending&&!n?(0,I.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,I.jsx)(Fy,{role:`assistant`}),(0,I.jsx)(xM,{label:e.texts.typingLabel})]}):null]})}var CM=function(e){return e.EndpointReady=`endpoint.ready`,e.EndpointError=`endpoint.error`,e.MessageRequest=`message.request`,e.MessageStreamRequest=`message.stream-request`,e.MessageSent=`message.sent`,e.MessageAccepted=`message.accepted`,e.MessageIncoming=`message.incoming`,e.MessageCompleted=`message.completed`,e.MessageFailed=`message.failed`,e.MessageAbort=`message.abort`,e.MessageTextStart=`message.text-start`,e.MessageTextDelta=`message.text-delta`,e.MessageTextEnd=`message.text-end`,e.MessageReasoningStart=`message.reasoning-start`,e.MessageReasoningDelta=`message.reasoning-delta`,e.MessageReasoningEnd=`message.reasoning-end`,e.MessageToolCallStart=`message.tool-call-start`,e.MessageToolCallArgs=`message.tool-call-args`,e.MessageToolCallArgsDelta=`message.tool-call-args-delta`,e.MessageToolCallEnd=`message.tool-call-end`,e.MessageToolCallResult=`message.tool-call-result`,e.MessageRead=`message.read`,e.MessageDelivered=`message.delivered`,e.MessageRecalled=`message.recalled`,e.MessageReaction=`message.reaction`,e.RunStarted=`run.started`,e.RunFinished=`run.finished`,e.RunError=`run.error`,e.RunMetadata=`run.metadata`,e.ContextWindowUpdated=`context-window.updated`,e.TypingStart=`typing.start`,e.TypingEnd=`typing.end`,e.PresenceUpdated=`presence.updated`,e}({}),wM=/\[\[\s*reply_to_current\s*\]\]/gi,TM=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function EM(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function DM(e,t){let n=e,r;wM.test(n)&&(r=EM(t),n=n.replace(wM,``).trim());let i=n.match(TM)?.[1];return i&&(r=EM(i),n=n.replace(TM,``).trim()),r?{content:n,replyTo:r}:{content:n}}function OM(e,t=e.id){if(e.role!==`assistant`)return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};let n=e.parts.findIndex(e=>e.type===`text`),r=e.metadata?{...e.metadata}:void 0,i=EM(r?.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};let a=e.parts[n];if(!a||a.type!==`text`)return{...e,parts:[...e.parts],metadata:r};let{content:o,replyTo:s}=DM(a.text,t),c=s??i,l=e.parts.flatMap((e,t)=>t!==n||e.type!==`text`?[e]:o.length===0?[]:[{...e,text:o}]);return c?{...e,parts:l,metadata:{...r,reply_to:c}}:{...e,parts:l,metadata:r}}function kM(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function AM(e){return kM(OM(e))}var jM=`__nextclaw_aborted_tool_call__`;function MM(e){let t=e.error?.trim();return{code:`runtime-error`,message:t&&t.length>0?t:`Agent run failed.`,details:{sessionId:e.sessionId,messageId:e.messageId,threadId:e.threadId,runId:e.runId}}}function NM(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function PM(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function FM(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function IM(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`tool-invocation`&&r.toolCallId===t)return r}return null}function LM(e,t){return IM(e,t)?.toolName??null}function RM(e,t){let n=[...e];for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.type===`tool-invocation`&&r.toolCallId===t.toolCallId)return n[e]={...r,...t},n}return n.push(t),n}function zM(e){let t=[];return{parts:e.map(e=>e.type!==`tool-invocation`||!e.toolCallId||e.state===`result`||e.state===`cancelled`?e:(t.push(e.toolCallId),{...e,state:`cancelled`})),toolCallIds:t}}var BM=`assistant`,VM=class{messages=[];streamingMessage=null;error=null;activeRun=null;contextWindow=null;listeners=new Set;toolCallMessageIdByCallId=new Map;toolCallArgsRawByCallId=new Map;lastSettledRunId=null;snapshotCache=null;snapshotVersion=-1;stateVersion=0;getSnapshot=()=>{if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;let e={messages:this.messages,streamingMessage:this.streamingMessage,error:this.error?{...this.error,details:this.error.details?{...this.error.details}:void 0}:null,activeRun:this.activeRun?{...this.activeRun}:null,contextWindow:this.contextWindow?{...this.contextWindow}:null};return this.snapshotCache=e,this.snapshotVersion=this.stateVersion,e};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));reset=()=>{this.messages.length===0&&!this.streamingMessage&&!this.error&&!this.activeRun&&!this.contextWindow&&this.toolCallMessageIdByCallId.size===0&&this.toolCallArgsRawByCallId.size===0||(this.messages=[],this.streamingMessage=null,this.error=null,this.activeRun=null,this.contextWindow=null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners())};hydrate=e=>{this.messages=e.messages.map(e=>AM(e)),this.streamingMessage=null,this.error=null,this.contextWindow=e.contextWindow?{...e.contextWindow}:null,this.activeRun=e.activeRun?{...e.activeRun,sessionId:e.activeRun.sessionId??e.sessionId,abortDisabledReason:e.activeRun.abortDisabledReason??null}:null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners()};dispatch=e=>this.dispatchBatch([e]);dispatchBatch=async e=>{if(!e.length)return;let t=this.stateVersion;e.forEach(this.applyEvent),this.stateVersion!==t&&this.notifyListeners()};applyEvent=e=>{switch(e.type){case CM.MessageSent:this.handleMessageSent(e.payload);break;case CM.MessageAbort:this.handleMessageAbort(e.payload);break;case CM.MessageTextStart:this.handleMessageTextStart(e.payload);break;case CM.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case CM.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case CM.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case CM.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case CM.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case CM.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case CM.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case CM.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case CM.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case CM.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case CM.RunStarted:this.handleRunStarted(e.payload);break;case CM.RunFinished:this.handleRunFinished(e.payload);break;case CM.RunError:this.handleRunError(e.payload);break;case CM.RunMetadata:this.handleRunMetadata(e.payload);break;case CM.ContextWindowUpdated:this.handleContextWindowUpdated(e.payload);break;case CM.EndpointError:this.handleEndpointError(e.payload);break;default:break}};handleMessageSent=e=>{this.upsertMessage(e.message),this.setError(null)};handleMessageAbort=e=>{let t=e.messageId?.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){let e=this.streamingMessage.id,{parts:n,toolCallIds:r}=zM(this.streamingMessage.parts);this.upsertMessage({...this.streamingMessage,status:`final`,parts:n}),this.replaceStreamingMessage(null),t?FM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):FM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,e),r.forEach(e=>this.toolCallArgsRawByCallId.set(e,jM))}};handleMessageTextStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),this.setError(null)};handleMessageTextDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`text`?n[n.length-1]={type:`text`,text:`${r.text}${e.delta}`}:n.push({type:`text`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageTextEnd=e=>{this.streamingMessage?.id===e.messageId&&this.streamingMessage.status===`streaming`&&this.replaceStreamingMessage({...this.streamingMessage,status:`pending`})};handleMessageReasoningStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`)};handleMessageReasoningDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`reasoning`?n[n.length-1]={type:`reasoning`,text:`${r.text}${e.delta}`}:n.push({type:`reasoning`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageReasoningEnd=e=>{this.streamingMessage?.id,e.messageId};handleMessageToolCallStart=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,``);let n=RM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:e.toolName,state:`partial-call`,args:``});this.replaceStreamingMessage({...t,parts:n,status:`streaming`}),this.setError(null)};handleMessageToolCallArgs=e=>{this.toolCallArgsRawByCallId.get(e.toolCallId)!==`__nextclaw_aborted_tool_call__`&&(this.toolCallArgsRawByCallId.set(e.toolCallId,e.args),this.applyToolCallArgs(e.sessionId,e.toolCallId,e.args))};handleMessageToolCallArgsDelta=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??``}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,t),this.applyToolCallArgs(e.sessionId,e.toolCallId,t,e.messageId)};handleMessageToolCallEnd=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??``,r=RM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:LM(t.parts,e.toolCallId)??`unknown`,state:`call`,args:n});this.replaceStreamingMessage({...t,parts:r,status:`streaming`})};handleMessageToolCallResult=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)!==`__nextclaw_aborted_tool_call__`&&!this.updateMessageContainingToolCall(e.toolCallId,(t,n)=>{let r={type:`tool-invocation`,toolCallId:e.toolCallId,toolName:n.toolName,state:`result`,args:n.args,result:e.content,resultContentItems:e.contentItems};return RM(t.parts,r)})){let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=RM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:`unknown`,state:`result`,result:e.content,resultContentItems:e.contentItems});this.replaceStreamingMessage({...t,parts:n,status:`streaming`})}};handleRunStarted=e=>{this.isSettledRunId(e.runId)||(this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1)};handleRunFinished=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`final`),this.setError(null),this.clearActiveRun()};handleRunError=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`error`),this.setError(MM(e)),this.clearActiveRun()};handleRunMetadata=e=>{let t=e.metadata;if(t?.kind===`ready`){let e=t;if(this.isSettledRunId(e.runId))return;this.activeRun={runId:e.runId??this.activeRun?.runId??null,sessionId:e.sessionId??this.activeRun?.sessionId,abortDisabledReason:e.supportsAbort===!1?e.abortDisabledReason??`Unsupported`:null},this.stateVersion+=1}else t?.kind===`final`&&(this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.clearActiveRun())};handleContextWindowUpdated=e=>{this.contextWindow={...e.contextWindow},this.stateVersion+=1};handleEndpointError=e=>{if(e.code===`abort-error`){this.handleMessageAbort({sessionId:this.activeRun?.sessionId??this.streamingMessage?.sessionId??``,...this.streamingMessage?.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage(`error`),this.clearActiveRun(),this.setError(e)};applyToolCallArgs=(e,t,n,r)=>{let i=this.resolveToolCallTargetMessage(e,t,r),a=LM(i.parts,t)??`unknown`,o=RM(i.parts,{type:`tool-invocation`,toolCallId:t,toolName:a,state:`partial-call`,args:n});this.replaceStreamingMessage({...i,parts:o,status:`streaming`})};ensureStreamingMessage=(e,t,n)=>{if(this.streamingMessage?.id===t){if(this.streamingMessage.status===n)return this.streamingMessage;let e={...this.streamingMessage,status:n};return this.replaceStreamingMessage(e),e}let r=this.messages.findIndex(e=>e.id===t);if(r>=0){let t=kM(this.messages[r]),i=[...this.messages];i.splice(r,1),this.messages=i,this.stateVersion+=1;let a={...t,sessionId:e,status:n};return this.replaceStreamingMessage(a),a}let i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&NM(i,t)){let r={...i,id:t,sessionId:e,status:n};return PM(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:BM,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(a),a};resolveToolCallTargetMessage=(e,t,n)=>{let r=n?.trim()||this.toolCallMessageIdByCallId.get(t)||this.streamingMessage?.id||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,`streaming`)};updateMessageContainingToolCall=(e,t)=>{if(this.streamingMessage){let n=IM(this.streamingMessage.parts,e);if(n){let e=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:e}),!0}}for(let n=this.messages.length-1;n>=0;--n){let r=this.messages[n],i=IM(r.parts,e);if(!i)continue;let a=[...this.messages];return a[n]={...r,parts:t(r,i)},this.messages=a,this.stateVersion+=1,!0}return!1};upsertMessage=e=>{let t=AM(e);this.streamingMessage?.id===t.id&&(this.streamingMessage=null);let n=this.messages.findIndex(e=>e.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}let r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1};replaceStreamingMessage=e=>{!e&&!this.streamingMessage||(this.streamingMessage=e?AM(e):null,this.stateVersion+=1)};setError=e=>{this.error?.code===e?.code&&this.error?.message===e?.message&&this.error?.details===e?.details&&this.error?.cause===e?.cause||(this.error=e?{...e,details:e.details?{...e.details}:void 0}:null,this.stateVersion+=1)};clearActiveRun=()=>{this.activeRun&&(this.activeRun=null,this.stateVersion+=1)};isSettledRunId=e=>!!e?.trim()&&e===this.lastSettledRunId;markRunAsSettled=e=>{this.lastSettledRunId=e?.trim()||null};settleStreamingMessage=e=>{if(!this.streamingMessage)return;let t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),FM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}},HM=16,UM=class{constructor(e){this.dispatchBatch=e,this.queue=[],this.flushTimerId=null,this.isFlushing=!1,this.isDisposed=!1,this.enqueue=e=>{this.isDisposed||(this.queue.push(e),this.scheduleFlush())},this.dispose=()=>{this.isDisposed=!0,this.flushTimerId!==null&&(window.clearTimeout(this.flushTimerId),this.flushTimerId=null),this.queue.length=0},this.scheduleFlush=()=>{this.flushTimerId!==null||this.isFlushing||this.queue.length===0||(this.flushTimerId=window.setTimeout(()=>{this.flushTimerId=null,this.flush()},HM))},this.flush=async()=>{if(!(this.isDisposed||this.isFlushing||this.queue.length===0)){this.isFlushing=!0;try{for(;this.queue.length>0;){let e=this.queue.splice(0);await this.dispatchBatch(e)}}finally{this.isFlushing=!1,this.scheduleFlush()}}}}};function WM(e,t){let n=e.dispatchBatch;return typeof n==`function`?n.call(e,t):t.reduce((t,n)=>t.then(()=>e.dispatch(n)),Promise.resolve())}function GM(e,t){if(!t)return!0;let n=`payload`in e?e.payload:null;return!n||typeof n!=`object`||!(`sessionId`in n)||typeof n.sessionId!=`string`?!0:n.sessionId===t}function KM(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function qM(e,t){if(typeof e==`string`){let n=e.trim();return n?{...t?{sessionId:t}:{},message:{id:`user-${Date.now().toString(36)}`,...t?{sessionId:t}:{},role:`user`,status:`final`,parts:[{type:`text`,text:n}],timestamp:new Date().toISOString()}}:null}if(!KM(e.message))return null;let n=e.sessionId||e.message.sessionId||t;return{...e,...n?{sessionId:n}:{},message:{...e.message,...n?{sessionId:n}:{}}}}function JM(e){let t=(0,F.useRef)();return t.current?e&&t.current.sessionId===null?t.current.sessionId=e:t.current.sessionId!==(e??null)&&(t.current={sessionId:e??null,manager:new VM}):t.current={sessionId:e??null,manager:new VM},t.current.manager}function YM({sessionId:e,client:t,manager:n}){let r=(0,F.useRef)(e),i=(0,F.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[a,o]=(0,F.useState)(!1);(0,F.useEffect)(()=>{r.current=e},[e]),(0,F.useEffect)(()=>{o(!1)},[e]),(0,F.useEffect)(()=>{let e=new UM(e=>WM(n,e)),i=t.subscribe(t=>{GM(t,r.current)&&e.enqueue(t)});return()=>{i(),e.dispose(),t.stop()}},[t,n]);let s=i.streamingMessage?[...i.messages,i.streamingMessage]:i.messages,c=i.activeRun?.runId??null,l=!!i.activeRun;return{snapshot:i,visibleMessages:s,activeRunId:c,isRunning:l,isSending:a,send:async r=>{if(a||l)return null;let i=qM(r,e);if(!i)return null;o(!0),e&&await n.dispatch({type:CM.MessageSent,payload:{sessionId:e,message:{...i.message,sessionId:e},metadata:i.metadata}});try{return await t.send(i)}finally{o(!1)}},abort:async()=>{e&&await t.abort({sessionId:e})},streamRun:async()=>{e&&(await t.stop(),await t.stream({sessionId:e}))}}}function XM(e){return e instanceof Error?e:Error(String(e))}function ZM(e){let{hydratedSessionId:t,isHydrating:n,sessionId:r}=e;return r?n||t!==r:!1}function QM(e,t){let n=e.getSnapshot();return n.activeRun?.sessionId===t||n.streamingMessage?.sessionId===t||n.messages.some(e=>e.sessionId===t)}function $M(e,t){return e.status===`running`?{runId:null,sessionId:t,abortDisabledReason:null}:null}function eN(e,t,n){return n.signal.aborted||e.requestId!==t}function tN({sessionId:e,client:t,loadSeed:n}){let r=JM(e),i=YM({sessionId:e,client:t,manager:r}),[a,o]=(0,F.useState)(!0),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),d=(0,F.useRef)({requestId:0,controller:null}),f=(0,F.useCallback)(async()=>{await t.stop(),r.reset(),c(null),u(null),o(!1),d.current={requestId:d.current.requestId+1,controller:null}},[t,r]),p=(0,F.useCallback)(e=>{c(null),u(e),o(!1)},[]),m=(0,F.useCallback)(async()=>{if(d.current.controller?.abort(),!e){await f();return}let i=new AbortController,a=d.current.requestId+1;if(d.current={requestId:a,controller:i},QM(r,e)){p(e),d.current.controller===i&&(d.current.controller=null);return}await t.stop(),r.reset(),c(null),o(!0);try{let o=await n(e,i.signal);if(eN(d.current,a,i))return;r.hydrate({sessionId:e,messages:o.messages,activeRun:$M(o,e)}),p(e),t.stream({sessionId:e}).catch(e=>{d.current.requestId===a&&c(XM(e))})}catch(t){if(eN(d.current,a,i))return;c(XM(t)),u(e),o(!1)}finally{d.current.controller===i&&(d.current.controller=null)}},[t,n,r,p,f,e]);return(0,F.useEffect)(()=>(m(),()=>{d.current.controller?.abort(),d.current.controller=null}),[m]),{...i,isHydrating:ZM({sessionId:e,hydratedSessionId:l,isHydrating:a}),hydrateError:s}}var nN=200*1024*1024,rN=`application/octet-stream`;function iN(e){let t=e.type.trim().toLowerCase();return t.length>0?t:rN}function aN(e,t){let n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(e=>e.trim().toLowerCase())):null,r=t.maxBytes??209715200,i=iN(e);return n&&!n.has(i)?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`unsupported-type`}}:e.size>r?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`too-large`}}:{ok:!0,mimeType:i}}function oN(e){let t=e.parts&&e.parts.length>0?e.parts.map(e=>structuredClone(e)):[...e.text?.trim()??``?[{type:`text`,text:e.text.trim()}]:[],...(e.attachments??[]).map(e=>({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?.trim()?{assetUri:e.assetUri.trim()}:{},...e.url?.trim()?{url:e.url.trim()}:{},...e.contentBase64?.trim()?{contentBase64:e.contentBase64.trim()}:{},sizeBytes:e.sizeBytes}))];if(t.length===0)return null;let n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{...e.sessionId?{sessionId:e.sessionId}:{},message:{id:r,...e.sessionId?{sessionId:e.sessionId}:{},role:`user`,status:`final`,parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function sN(e,t){let n=[],r=[];for(let i of e){let e=aN(i,t);if(!e.ok){r.push(e.rejected);continue}n.push(i)}if(n.length===0)return{attachments:[],rejected:r};try{return{attachments:await t.uploadBatch(n),rejected:r}}catch{return r.push(...n.map(e=>({fileName:e.name,mimeType:iN(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}function cN(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function lN(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function uN(e){return!e.isModelOptionsLoading&&!e.isModelOptionsEmpty?null:e.isModelOptionsLoading?{tone:`neutral`,loading:!0}:{tone:`warning`,text:e.texts.noModelOptionsLabel,actionLabel:e.texts.configureProviderLabel,onAction:e.onGoToProviders}}function dN({modelOptions:e,recentModelValues:t,selectedModel:n,isModelOptionsLoading:r,hasModelOptions:i,onValueChange:a,texts:o}){let s=e.find(e=>e.value===n)??e[0],c=i?s?.value:void 0,l=new Set(t??[]),u=new Map(e.map(e=>[e.value,e])),d=(t??[]).map(e=>u.get(e)).filter(e=>!!e),f=e.filter(e=>!l.has(e.value)),p=d.length>0?[{key:`recent-models`,label:o.recentModelsLabel,options:d.map(e=>({value:e.value,label:cN(e)}))},{key:`all-models`,label:o.allModelsLabel,options:f.map(e=>({value:e.value,label:cN(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:c,placeholder:o.modelSelectPlaceholder,selectedLabel:s?cN(s):void 0,icon:`sparkles`,options:e.map(e=>({value:e.value,label:cN(e)})),groups:p,disabled:!i,loading:r,emptyLabel:o.modelNoOptionsLabel,onValueChange:a}}function fN(e){if(e.supportedLevels.length===0)return null;let t=lN(e.supportedLevels),n=t.includes(`off`)?`off`:t[0],r=e.selectedThinkingLevel&&t.includes(e.selectedThinkingLevel)&&e.selectedThinkingLevel||e.defaultThinkingLevel&&t.includes(e.defaultThinkingLevel)&&e.defaultThinkingLevel||n;return{key:`thinking`,value:r,placeholder:e.texts.thinkingLabels[r],selectedLabel:e.texts.thinkingLabels[r],icon:`brain`,options:t.map(t=>({value:t,label:e.texts.thinkingLabels[t]})),onValueChange:t=>e.onValueChange(t)}}var pN={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function mN(e){return(e??``).trim().toLowerCase()}function hN(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function gN(e,t){let n=mN(t);if(!n)return pN.fallback;let r=mN(e.key),i=mN(e.label||e.key),a=mN(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?pN.exactSpec:i===n?pN.exactLabel:r.startsWith(n)?pN.prefixSpec:i.startsWith(n)?pN.prefixLabel:o.some(e=>e.startsWith(n))?pN.prefixToken:r.includes(n)?pN.containsSpec:i.includes(n)?pN.containsLabel:a.includes(n)?pN.containsDescription:hN(n,i)||hN(n,r)?pN.subsequence:0}function _N(e){return e>=pN.exactLabel?4:e>=pN.prefixToken?3:e>=pN.containsLabel?2:e>0?1:0}function vN(e){return new Map(e.map((e,t)=>[e,t]))}function yN(e,t){let n=vN(t),r=[],i=[];for(let t of e){if(n.has(t.key)){r.push(t);continue}i.push(t)}return r.sort((e,t)=>(n.get(e.key)??1/0)-(n.get(t.key)??1/0)),[...r,...i]}function bN(e,t,n,r=[]){let i=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),a=vN(r);return e.map((e,n)=>({record:e,order:n,score:gN(e,t)})).filter(e=>e.score>0).sort((e,t)=>{let n=_N(e.score),r=_N(t.score);if(r!==n)return r-n;let o=a.get(e.record.key)??1/0,s=a.get(t.record.key)??1/0;if(o!==s)return o-s;if(t.score!==e.score)return t.score-e.score;let c=(e.record.label||e.record.key).trim(),l=(t.record.label||t.record.key).trim(),u=i.compare(c,l);return u===0?e.order-t.order:u}).map(({record:e})=>({key:`skill:${e.key}`,title:e.label||e.key,subtitle:n.slashSkillSubtitle,description:(e.descriptionZh??e.description??``).trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${e.key}`,...e.scopeLabel?[`${n.slashSkillScopeLabel}: ${e.scopeLabel}`]:[]],value:e.key}))}function xN(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function SN(e){let t=yN(e.skillRecords,e.recentSkillValues??[]),n=new Set(e.groupedRecentSkillValues??[]),r=xN(t.filter(e=>n.has(e.key))),i=xN(t.filter(e=>!n.has(e.key)));return{title:e.texts.title,searchPlaceholder:e.texts.searchPlaceholder,emptyLabel:e.texts.emptyLabel,loadingLabel:e.texts.loadingLabel,isLoading:e.isLoading,manageLabel:e.texts.manageLabel,manageHref:`/marketplace/skills`,options:xN(t),groups:r.length>0?[{key:`recent-skills`,label:e.texts.recentSkillsLabel,options:r},{key:`all-skills`,label:e.texts.allSkillsLabel,options:i}].filter(e=>e.options.length>0):void 0,selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}var CN=`$`;function wN(e,t){if(t.length===0)return e;let n=e[e.length-1];return n?.type===`text`?[...e.slice(0,-1),{...n,text:n.text+t}]:[...e,{type:`text`,text:t}]}function TN(){return Hv()}function EN(e){return Uv(e)}function DN(e){return Kv(e)}function ON(e){return qv(e,`skill`)}function kN(e){return qv(e,`file`)}function AN(e,t,n){let r=new Set(t),i=ey(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=qv(i,`skill`),o=new Map(n.map(e=>[e.ref,e])),s=t.filter(e=>!a.includes(e)).map(e=>Bv({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.name||e}));return s.length===0?i:Wv([...i,...s])}function jN(e,t){let n=new Set(t.map(e=>e.id));return ey(e,e=>e.tokenKind===`file`&&!n.has(e.tokenKey))}function MN(e,t){let n=new Set(kN(e));return t.filter(e=>n.has(e.id))}function NN(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){r=wN(r,t.text);continue}if(t.tokenKind===`skill`){r=wN(r,`${CN}${t.tokenKey}`);continue}if(t.tokenKind!==`file`)continue;let e=n.get(t.tokenKey);e&&r.push({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?{assetUri:e.assetUri}:{},...e.url?{url:e.url}:{},...e.contentBase64?{contentBase64:e.contentBase64}:{},sizeBytes:e.sizeBytes})}return r}var PN={isProviderStateResolved:!1,composerNodes:TN(),attachments:[],draft:``,pendingSessionType:`native`,pendingProjectRoot:null,pendingProjectRootSessionKey:null,defaultSessionType:`native`,canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:``,selectedThinkingLevel:null,sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[],composerFocusRequest:null},Z=m(e=>({snapshot:PN,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))})),FN=class{constructor(e){this.options=e,this.read=()=>{let e=this.getStorage();if(!e)return[];try{return this.normalizeList(JSON.parse(e.getItem(this.options.storageKey)??`[]`))}catch{return[]}},this.remember=e=>{let t=this.normalizeValue(e);if(!t)return this.read();let n=[t,...this.read().filter(e=>e!==t)].slice(0,this.options.limit);return this.write(n),n},this.resolveVisible=e=>{let t=this.normalizeList(e.availableValues,1/0);if(t.length<=e.minAvailableCount)return[];let n=new Set(t),r=[],i=Math.max(1,e.limit??this.options.limit);for(let e of this.read())if(!(!n.has(e)||r.includes(e))&&(r.push(e),r.length>=i))break;return r},this.write=e=>{let t=this.getStorage();if(t)try{t.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(e)))}catch{}},this.getStorage=()=>Object.prototype.hasOwnProperty.call(this.options,`storage`)?this.options.storage??null:typeof window>`u`?null:window.localStorage,this.normalizeList=(e,t=this.options.limit)=>{if(!Array.isArray(e))return[];let n=[];for(let r of e){let e=this.normalizeValue(r);if(!(!e||n.includes(e))&&(n.push(e),n.length>=t))break}return n},this.normalizeValue=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}}},IN=new FN({storageKey:`nextclaw.chat.recent-models`,limit:3}),LN=new FN({storageKey:`nextclaw.chat.recent-skills`,limit:5});function RN(e){return e.modelOptions.length>0}function zN(e){return!e.isProviderStateResolved&&!RN(e)}function BN(e){return e.isProviderStateResolved&&!RN(e)}function VN(e){return!1}function HN(e){let{hasSendableDraft:t,isRuntimeBlocked:n}=e;return n||!t}var UN=`nextclaw.chat.session-list.mode`,WN=`time-first`;function GN(e){return e===`time-first`||e===`project-first`}function KN(e){if(!e||typeof e!=`object`)return null;let{snapshot:t}=e;return!t||typeof t!=`object`?null:GN(t.listMode)?t.listMode:null}function qN(e,t){let n=e?.trim();if(!n)return!1;let r=t?.trim();return r?n.localeCompare(r)>0:!1}function JN(e){let{active:t,readAt:n,runStatus:r,lastMessageAt:i}=e;return t||r===`running`?!1:qN(i,n)}var YN={selectedSessionKey:null,selectedAgentId:`main`,query:``,listMode:WN};function XN(e){return t=>e(e=>({snapshot:{...e.snapshot,...t}}))}function ZN(e){return(t,n)=>e(e=>{let r=t.trim(),i=n?.trim();if(!r||!i)return e;let a=e.optimisticReadAtBySessionKey[r];return a&&a.localeCompare(i)>=0?e:{...e,optimisticReadAtBySessionKey:{...e.optimisticReadAtBySessionKey,[r]:i}}})}var QN=m()(Tn(e=>({snapshot:YN,optimisticReadAtBySessionKey:{},setSnapshot:XN(e),markSessionRead:ZN(e)}),{name:UN,storage:On(()=>window.localStorage),partialize:e=>({snapshot:{listMode:e.snapshot.listMode}}),merge:(e,t)=>{let n=KN(e);return n?{...t,snapshot:{...t.snapshot,listMode:n}}:t}})),$N={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionTypeIcon:null,sessionKey:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,availableAgents:[],sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null,contextWindow:null},Q=m(e=>({snapshot:$N,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function eP(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function tP(e){if(!e||e.totalContextTokens<=0)return null;let t=e.usedContextTokens/e.totalContextTokens,n=Math.max(0,Math.min(1,t)),r=`${Math.round(n*100)}%`,i=n>=.9?`danger`:n>=.75?`warning`:`neutral`,a=[{label:s(`chatContextWindowUsed`),value:eP(e.usedContextTokens)},{label:s(`chatContextWindowTotal`),value:eP(e.totalContextTokens)},{label:s(`chatContextWindowAvailable`),value:eP(e.availableContextTokens)}];return e.prunedUsedContextTokens!==e.usedContextTokens&&a.push({label:s(`chatContextWindowPruned`),value:eP(e.prunedUsedContextTokens)}),e.droppedHistoryCount>0&&a.push({label:s(`chatContextWindowDroppedHistory`),value:String(e.droppedHistoryCount)}),e.truncatedToolResultCount>0&&a.push({label:s(`chatContextWindowTruncatedTools`),value:String(e.truncatedToolResultCount)}),{label:s(`chatContextWindow`),percentLabel:r,ratio:n,tone:i,details:a}}function nP(){let e=QN(e=>e.snapshot.selectedSessionKey),t=Q(e=>e.snapshot.sessionKey),n=Q(e=>e.snapshot.contextWindow);return(0,F.useMemo)(()=>e&&t===e&&n?tP(n):null,[n,t,e])}function rP(e){return e.bootstrapStatus?.ncpAgent.state!==`ready`}function iP(e){return e.activeSystemAction?.message?.trim()||(e.lifecyclePhase===`cold-starting`?s(`chatRuntimeInitializing`):e.lifecyclePhase===`startup-failed`?e.bootstrapStatus?.ncpAgent.error?.trim()||e.bootstrapStatus?.lastError?.trim()||e.lastError?.trim()||s(`chatRuntimeInitializationFailed`):null)}function aP(e){let{message:t,status:n}=e,r=t?.trim();if(!r)return iP(n);let i=n.activeSystemAction?.message?.trim();if(n.phase===`service-transitioning`&&i)return i;let a=st(r);return n.phase===`recovering`&&a?s(`runtimeControlRecoveringHelp`):n.phase===`stalled`&&a?null:r}function oP(){return{off:s(`chatThinkingLevelOff`),minimal:s(`chatThinkingLevelMinimal`),low:s(`chatThinkingLevelLow`),medium:s(`chatThinkingLevelMedium`),high:s(`chatThinkingLevelHigh`),adaptive:s(`chatThinkingLevelAdaptive`),xhigh:s(`chatThinkingLevelXhigh`)}}function sP(e,t){return e.map(e=>({key:e.ref,label:e.name,scopeLabel:t[e.scope],description:e.description,descriptionZh:e.descriptionZh,badgeLabel:t[e.scope]}))}function cP(e){return e.map(e=>({value:e.value,modelLabel:e.modelLabel,providerLabel:e.providerLabel,thinkingCapability:e.thinkingCapability?{supported:e.thinkingCapability.supported,default:e.thinkingCapability.default??null}:null}))}function lP(e){return{skillScopeLabels:(0,F.useMemo)(()=>({builtin:s(`chatSkillScopeBuiltin`),project:s(`chatSkillScopeProject`),workspace:s(`chatSkillScopeWorkspace`)}),[e]),slashTexts:(0,F.useMemo)(()=>({slashSkillSubtitle:s(`chatSlashTypeSkill`),slashSkillSpecLabel:s(`chatSlashSkillSpec`),slashSkillScopeLabel:s(`chatSlashSkillScope`),noSkillDescription:s(`chatSkillsPickerNoDescription`)}),[e]),recentModelsLabel:s(`chatPickerRecentModels`),allModelsLabel:s(`chatPickerAllModels`),recentSkillsLabel:s(`chatPickerRecent`),allSkillsLabel:s(`chatPickerAllSkills`)}}function uP(e,t){let n=(0,F.useMemo)(()=>sP(e.skillRecords,t),[e.skillRecords,t]),r=(0,F.useMemo)(()=>cP(e.modelOptions),[e.modelOptions]);return{skillRecords:n,modelRecords:r,recentModelValues:IN.resolveVisible({availableValues:r.map(e=>e.value),minAvailableCount:5}),recentSkillValues:LN.resolveVisible({availableValues:n.map(e=>e.key),minAvailableCount:0}),recentSkillGroupValues:LN.resolveVisible({availableValues:n.map(e=>e.key),minAvailableCount:4})}}function dP(e){let{attachmentSupported:t,inputBarRef:n,presenter:r}=e,i=(0,F.useCallback)(e=>{if(e===`unsupported-type`){N.error(s(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){N.error(s(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(nN/(1024*1024))));return}N.error(s(`chatInputAttachmentReadFailed`))},[]),a=(0,F.useCallback)(async e=>{if(!t||e.length===0)return;let a=await sN(e,{uploadBatch:yt});if(a.attachments.length>0){let e=r.chatInputManager.addAttachments?.(a.attachments)??[];e.length>0&&n.current?.insertFileTokens(e.map(e=>({tokenKey:e.id,label:e.name})))}a.rejected.length>0&&i(a.rejected[0].reason)},[t,n,r.chatInputManager,i]);return{handleFilesAdd:a,handleFileInputChange:(0,F.useCallback)(async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await a(t)},[a])}}function fP(e){let{allModelsLabel:t,hasModelOptions:n,isModelOptionsLoading:r,modelRecords:i,presenter:a,recentModelValues:o,recentModelsLabel:c,selectedModel:l,selectedThinkingLevel:u,thinkingSupportedLevels:d,thinkingDefaultLevel:f}=e;return[dN({modelOptions:i,recentModelValues:o,selectedModel:l,isModelOptionsLoading:r,hasModelOptions:n,onValueChange:a.chatInputManager.selectModel,texts:{modelSelectPlaceholder:s(`chatSelectModel`),modelNoOptionsLabel:s(`chatModelNoOptions`),recentModelsLabel:c,allModelsLabel:t}}),fN({supportedLevels:d,selectedThinkingLevel:u,defaultThinkingLevel:f,onValueChange:e=>a.chatInputManager.selectThinkingLevel(e),texts:{thinkingLabels:oP()}})].filter(e=>e!==null)}function pP(e){let{allSkillsLabel:t,presenter:n,recentSkillGroupValues:r,recentSkillValues:i,recentSkillsLabel:a,skillRecords:o,snapshot:c}=e;return SN({skillRecords:o,recentSkillValues:i,groupedRecentSkillValues:r,selectedSkills:c.selectedSkills,isLoading:c.isSkillsLoading,onSelectedKeysChange:n.chatInputManager.selectSkills,texts:{title:s(`chatSkillsPickerTitle`),searchPlaceholder:s(`chatSkillsPickerSearchPlaceholder`),emptyLabel:s(`chatSkillsPickerEmpty`),loadingLabel:s(`sessionsLoading`),manageLabel:s(`chatSkillsPickerManage`),recentSkillsLabel:a,allSkillsLabel:t}})}function mP(){let e=ic(),{language:t}=kr(),{isMobile:n}=Pr(),r=Z(e=>e.snapshot),i=rP(bt()),[a,o]=(0,F.useState)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=lP(t),{skillRecords:d,modelRecords:f,recentModelValues:p,recentSkillValues:m,recentSkillGroupValues:h}=uP(r,u.skillScopeLabels),g=RN(r),_=zN(r),v=BN(r),y=VN(r),b=typeof e.chatInputManager.addAttachments==`function`,x=s(v?`chatModelNoOptions`:n?`chatInputPlaceholderCompact`:`chatInputPlaceholder`),S=(0,F.useMemo)(()=>bN(d,a??``,u.slashTexts,m),[u.slashTexts,m,d,a]),C=nP(),w=f.find(e=>e.value===r.selectedModel),T=w?.thinkingCapability?.supported??[],E=r.stopDisabledReason===`__preparing__`?s(`chatStopPreparing`):r.stopDisabledReason?.trim()||s(`chatStopUnavailable`),{handleFilesAdd:D,handleFileInputChange:O}=dP({attachmentSupported:b,inputBarRef:c,presenter:e});(0,F.useEffect)(()=>{let t=r.composerFocusRequest;t&&(t.placement===`end`&&c.current?.focusComposerAtEnd(),e.chatInputManager.consumeComposerFocusRequest(t.id))},[e.chatInputManager,r.composerFocusRequest]);let k=fP({allModelsLabel:u.allModelsLabel,hasModelOptions:g,isModelOptionsLoading:_,modelRecords:f,presenter:e,recentModelValues:p,recentModelsLabel:u.recentModelsLabel,selectedModel:r.selectedModel,selectedThinkingLevel:r.selectedThinkingLevel,thinkingSupportedLevels:T,thinkingDefaultLevel:w?.thinkingCapability?.default??null}),A=pP({allSkillsLabel:u.allSkillsLabel,presenter:e,recentSkillGroupValues:h,recentSkillValues:m,recentSkillsLabel:u.recentSkillsLabel,skillRecords:d,snapshot:r}),ee=r.draft.trim().length>0||r.attachments.length>0||ON(r.composerNodes).length>0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Py,{ref:c,composer:{nodes:r.composerNodes,placeholder:x,disabled:y,onNodesChange:e.chatInputManager.setComposerNodes,...b?{onFilesAdd:D}:{},onSlashQueryChange:o},slashMenu:{isLoading:r.isSkillsLoading,items:S,onSelectItem:t=>{t.value&&e.chatInputManager.rememberSkillSelection(t.value)},texts:{slashLoadingLabel:s(`chatSlashLoading`),slashSectionLabel:s(`chatSlashSectionSkills`),slashEmptyLabel:s(`chatSlashNoResult`),slashHintLabel:s(`chatSlashHint`),slashSkillHintLabel:s(`chatSlashSkillHint`)}},hint:uN({isModelOptionsLoading:_,isModelOptionsEmpty:v,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:s(`chatModelNoOptions`),configureProviderLabel:s(`chatGoConfigureProvider`)}}),toolbar:{selects:k,accessories:[{key:`attach`,label:s(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:!b||y||r.isSending,...b?{onClick:()=>l.current?.click()}:{tooltip:s(`chatInputAttachComingSoon`)}}],skillPicker:A,actions:{sendError:i?null:r.sendError,isSending:r.isSending,canStopGeneration:r.canStopGeneration,sendDisabled:HN({snapshot:r,hasSendableDraft:ee,isRuntimeBlocked:i}),stopDisabled:!r.canStopGeneration,stopHint:E,sendButtonLabel:s(`chatSend`),stopButtonLabel:s(`chatStop`),contextWindow:C,onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),b?(0,I.jsx)(`input`,{ref:l,type:`file`,multiple:!0,className:`hidden`,onChange:O}):null]})}var hP=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function gP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _P(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function vP(e,t=120){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1)}…`}function yP(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return _P(JSON.stringify(e,null,2))}catch{return String(e)}}function bP(e){if(gP(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{let e=JSON.parse(t);return gP(e)?e:null}catch{return null}}function xP(e){let t=bP(e);if(!t){let t=yP(e).trim();return t?vP(t,120):void 0}let n=[];for(let e of hP){let r=t[e];if(typeof r==`string`&&r.trim()?n.push(`${e}: ${r.trim()}`):(typeof r==`number`||typeof r==`boolean`)&&n.push(`${e}: ${String(r)}`),n.length>=2)break}return n.length>0?vP(n.join(` · `),120):vP(yP(t),140)}var SP=`ui_inline_tokens`,CP=`$`;function wP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function TP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function EP(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind}:${r.key}:${r.rawText}`;t.has(e)||(t.add(e),n.push(r))}return n}function DP(e){let t=[];for(let n of e)n.type!==`token`||n.tokenKind!==`skill`||t.push({kind:`skill`,key:n.tokenKey,label:n.label,rawText:`${CP}${n.tokenKey}`});return EP(t)}function OP(e){let t=e?.[SP];if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!wP(e))continue;let t=TP(e.kind),r=TP(e.key),i=TP(e.rawText);!t||!r||!i||n.push({kind:t,key:r,rawText:i,label:TP(e.label)??r})}return EP(n)}function kP(e,t){if(e.length===0||t.length===0)return e.length===0?[]:[{type:`text`,text:e}];let n=[...t].sort((e,t)=>t.rawText.length-e.rawText.length),r=[],i=0;for(;i<e.length;){let t=null;for(let r of n)if(e.startsWith(r.rawText,i)){t=r;break}if(!t){let t=i+1;for(;t<e.length&&!n.some(n=>e.startsWith(n.rawText,t));)t+=1;r.push({type:`text`,text:e.slice(i,t)}),i=t;continue}r.push({type:`token`,token:t}),i+=t.rawText.length}return r}var AP=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function jP(e){let t=e.trim();return t&&t.replace(AP,``).trim()?t:null}function MP(e){return e.replace(AP,``).trim().length>0}function NP(e,t){let n=kP(e,t);if(n.length===0)return null;let r=[],i=!1;for(let e of n){if(e.type===`token`){i=!0,r.push({type:`token`,token:{kind:e.token.kind,key:e.token.key,label:e.token.label,rawText:e.token.rawText}});continue}e.text.length!==0&&(MP(e.text)&&(i=!0),r.push({type:`markdown`,text:e.text}))}return i?r:null}function PP(e,t){let n=NP(e.text,t);if(n&&n.some(e=>e.type===`token`))return{type:`inline-content`,segments:n};let r=jP(e.text);return r?{type:`markdown`,text:r}:null}function FP(e){return jP(e)}function IP(e){return typeof e==`object`&&!!e}function LP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function RP(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function zP(e){return IP(e)?`command`in e||`workingDir`in e||`exitCode`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e:!1}function BP(e,t){if(!IP(e))return null;let n=IP(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&IP(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=LP(n.url),i=LP(n.mimeType)??`application/octet-stream`,a=RP(n.sizeBytes);return r?{type:`file`,file:{label:LP(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function VP(e,t){return{kind:e.kind,toolName:e.name,...`agentId`in e&&e.agentId?{agentId:e.agentId}:{},summary:e.detail,inputLabel:t.toolInputLabel,input:`input`in e&&typeof e.input==`string`?e.input:void 0,output:e.text,outputData:e.outputData,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,...`action`in e&&e.action?{action:e.action}:{},...`fileOperation`in e&&e.fileOperation?{fileOperation:e.fileOperation}:{}}}function HP(e){let t=typeof e.status==`string`?e.status.trim().toLowerCase():``,n=typeof e.error==`string`&&e.error.trim().length>0;return e.cancelled===!0||t===`cancelled`?{kind:`result`,hasResult:!0,statusTone:`cancelled`,statusLabel:e.texts.toolStatusCancelledLabel}:n||t===`error`?{kind:`result`,hasResult:!0,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:t===`result`||e.result!=null?{kind:`result`,hasResult:!0,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function UP(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function WP(e,t){return yP(t??UP(e)).trim()||void 0}function GP(e){return typeof e==`object`&&!!e}function KP(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function qP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function JP(e){let t=KP(e);return GP(t)?qP(t.agentId):null}function YP(e){return JP(e.parsedArgs)??JP(e.args)??JP(e.result)}var XP=12e3,ZP=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function QP(e){let t=e.replace(/\r\n/g,`
91
+ `;function bM(e){let t=e.trim();return t?t.replace(vM,``).trim().length>0:!1}function xM(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?bM(e.text):!0)}function SM(){return(0,I.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-gray-400`,children:(0,I.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:200ms]`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:400ms]`})]})})}function CM({label:e}){return(0,I.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm`,children:[(0,I.jsx)(`style`,{children:yM}),(0,I.jsx)(`span`,{className:`nextclaw-chat-typing-indicator__text`,children:e})]})}function wM(e){let t=e.messages.filter(xM),n=t.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,I.jsxs)(`div`,{className:L(`space-y-5`,e.className),children:[t.map(t=>{let n=t.role===`user`,r=!n&&(t.status===`streaming`||t.status===`pending`);return(0,I.jsxs)(`div`,{className:L(`flex gap-3`,n?`justify-end`:`justify-start`),children:[n?null:(0,I.jsx)(Fy,{role:t.role}),(0,I.jsxs)(`div`,{className:L(`w-fit max-w-[92%] space-y-2`,n&&`flex flex-col items-end`),children:[(0,I.jsx)(hM,{message:t,texts:e.texts,onToolAction:e.onToolAction,onFileOpen:e.onFileOpen,renderToolAgent:e.renderToolAgent}),(0,I.jsx)(`div`,{className:L(`flex items-center gap-2`,n&&`justify-end`),children:r?(0,I.jsx)(SM,{}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(gM,{roleLabel:t.roleLabel,timestampLabel:t.timestampLabel,isUser:n}),n?null:(0,I.jsx)(_M,{message:t,texts:e.texts})]})})]}),n?(0,I.jsx)(Fy,{role:t.role}):null]},t.id)}),e.isSending&&!n?(0,I.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,I.jsx)(Fy,{role:`assistant`}),(0,I.jsx)(CM,{label:e.texts.typingLabel})]}):null]})}var TM=function(e){return e.EndpointReady=`endpoint.ready`,e.EndpointError=`endpoint.error`,e.MessageRequest=`message.request`,e.MessageStreamRequest=`message.stream-request`,e.MessageSent=`message.sent`,e.MessageAccepted=`message.accepted`,e.MessageIncoming=`message.incoming`,e.MessageCompleted=`message.completed`,e.MessageFailed=`message.failed`,e.MessageAbort=`message.abort`,e.MessageTextStart=`message.text-start`,e.MessageTextDelta=`message.text-delta`,e.MessageTextEnd=`message.text-end`,e.MessageReasoningStart=`message.reasoning-start`,e.MessageReasoningDelta=`message.reasoning-delta`,e.MessageReasoningEnd=`message.reasoning-end`,e.MessageToolCallStart=`message.tool-call-start`,e.MessageToolCallArgs=`message.tool-call-args`,e.MessageToolCallArgsDelta=`message.tool-call-args-delta`,e.MessageToolCallEnd=`message.tool-call-end`,e.MessageToolCallResult=`message.tool-call-result`,e.MessageRead=`message.read`,e.MessageDelivered=`message.delivered`,e.MessageRecalled=`message.recalled`,e.MessageReaction=`message.reaction`,e.RunStarted=`run.started`,e.RunFinished=`run.finished`,e.RunError=`run.error`,e.RunMetadata=`run.metadata`,e.ContextWindowUpdated=`context-window.updated`,e.TypingStart=`typing.start`,e.TypingEnd=`typing.end`,e.PresenceUpdated=`presence.updated`,e}({}),EM=/\[\[\s*reply_to_current\s*\]\]/gi,DM=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function OM(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function kM(e,t){let n=e,r;EM.test(n)&&(r=OM(t),n=n.replace(EM,``).trim());let i=n.match(DM)?.[1];return i&&(r=OM(i),n=n.replace(DM,``).trim()),r?{content:n,replyTo:r}:{content:n}}function AM(e,t=e.id){if(e.role!==`assistant`)return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};let n=e.parts.findIndex(e=>e.type===`text`),r=e.metadata?{...e.metadata}:void 0,i=OM(r?.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};let a=e.parts[n];if(!a||a.type!==`text`)return{...e,parts:[...e.parts],metadata:r};let{content:o,replyTo:s}=kM(a.text,t),c=s??i,l=e.parts.flatMap((e,t)=>t!==n||e.type!==`text`?[e]:o.length===0?[]:[{...e,text:o}]);return c?{...e,parts:l,metadata:{...r,reply_to:c}}:{...e,parts:l,metadata:r}}function jM(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function MM(e){return jM(AM(e))}var NM=`__nextclaw_aborted_tool_call__`;function PM(e){let t=e.error?.trim();return{code:`runtime-error`,message:t&&t.length>0?t:`Agent run failed.`,details:{sessionId:e.sessionId,messageId:e.messageId,threadId:e.threadId,runId:e.runId}}}function FM(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function IM(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function LM(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function RM(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`tool-invocation`&&r.toolCallId===t)return r}return null}function zM(e,t){return RM(e,t)?.toolName??null}function BM(e,t){let n=[...e];for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.type===`tool-invocation`&&r.toolCallId===t.toolCallId)return n[e]={...r,...t},n}return n.push(t),n}function VM(e){let t=[];return{parts:e.map(e=>e.type!==`tool-invocation`||!e.toolCallId||e.state===`result`||e.state===`cancelled`?e:(t.push(e.toolCallId),{...e,state:`cancelled`})),toolCallIds:t}}var HM=`assistant`,UM=class{messages=[];streamingMessage=null;error=null;activeRun=null;contextWindow=null;listeners=new Set;toolCallMessageIdByCallId=new Map;toolCallArgsRawByCallId=new Map;lastSettledRunId=null;snapshotCache=null;snapshotVersion=-1;stateVersion=0;getSnapshot=()=>{if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;let e={messages:this.messages,streamingMessage:this.streamingMessage,error:this.error?{...this.error,details:this.error.details?{...this.error.details}:void 0}:null,activeRun:this.activeRun?{...this.activeRun}:null,contextWindow:this.contextWindow?{...this.contextWindow}:null};return this.snapshotCache=e,this.snapshotVersion=this.stateVersion,e};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));reset=()=>{this.messages.length===0&&!this.streamingMessage&&!this.error&&!this.activeRun&&!this.contextWindow&&this.toolCallMessageIdByCallId.size===0&&this.toolCallArgsRawByCallId.size===0||(this.messages=[],this.streamingMessage=null,this.error=null,this.activeRun=null,this.contextWindow=null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners())};hydrate=e=>{this.messages=e.messages.map(e=>MM(e)),this.streamingMessage=null,this.error=null,this.contextWindow=e.contextWindow?{...e.contextWindow}:null,this.activeRun=e.activeRun?{...e.activeRun,sessionId:e.activeRun.sessionId??e.sessionId,abortDisabledReason:e.activeRun.abortDisabledReason??null}:null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners()};dispatch=e=>this.dispatchBatch([e]);dispatchBatch=async e=>{if(!e.length)return;let t=this.stateVersion;e.forEach(this.applyEvent),this.stateVersion!==t&&this.notifyListeners()};applyEvent=e=>{switch(e.type){case TM.MessageSent:this.handleMessageSent(e.payload);break;case TM.MessageAbort:this.handleMessageAbort(e.payload);break;case TM.MessageTextStart:this.handleMessageTextStart(e.payload);break;case TM.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case TM.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case TM.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case TM.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case TM.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case TM.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case TM.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case TM.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case TM.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case TM.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case TM.RunStarted:this.handleRunStarted(e.payload);break;case TM.RunFinished:this.handleRunFinished(e.payload);break;case TM.RunError:this.handleRunError(e.payload);break;case TM.RunMetadata:this.handleRunMetadata(e.payload);break;case TM.ContextWindowUpdated:this.handleContextWindowUpdated(e.payload);break;case TM.EndpointError:this.handleEndpointError(e.payload);break;default:break}};handleMessageSent=e=>{this.upsertMessage(e.message),this.setError(null)};handleMessageAbort=e=>{let t=e.messageId?.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){let e=this.streamingMessage.id,{parts:n,toolCallIds:r}=VM(this.streamingMessage.parts);this.upsertMessage({...this.streamingMessage,status:`final`,parts:n}),this.replaceStreamingMessage(null),t?LM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):LM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,e),r.forEach(e=>this.toolCallArgsRawByCallId.set(e,NM))}};handleMessageTextStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),this.setError(null)};handleMessageTextDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`text`?n[n.length-1]={type:`text`,text:`${r.text}${e.delta}`}:n.push({type:`text`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageTextEnd=e=>{this.streamingMessage?.id===e.messageId&&this.streamingMessage.status===`streaming`&&this.replaceStreamingMessage({...this.streamingMessage,status:`pending`})};handleMessageReasoningStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`)};handleMessageReasoningDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`reasoning`?n[n.length-1]={type:`reasoning`,text:`${r.text}${e.delta}`}:n.push({type:`reasoning`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageReasoningEnd=e=>{this.streamingMessage?.id,e.messageId};handleMessageToolCallStart=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,``);let n=BM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:e.toolName,state:`partial-call`,args:``});this.replaceStreamingMessage({...t,parts:n,status:`streaming`}),this.setError(null)};handleMessageToolCallArgs=e=>{this.toolCallArgsRawByCallId.get(e.toolCallId)!==`__nextclaw_aborted_tool_call__`&&(this.toolCallArgsRawByCallId.set(e.toolCallId,e.args),this.applyToolCallArgs(e.sessionId,e.toolCallId,e.args))};handleMessageToolCallArgsDelta=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??``}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,t),this.applyToolCallArgs(e.sessionId,e.toolCallId,t,e.messageId)};handleMessageToolCallEnd=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)===`__nextclaw_aborted_tool_call__`)return;let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??``,r=BM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:zM(t.parts,e.toolCallId)??`unknown`,state:`call`,args:n});this.replaceStreamingMessage({...t,parts:r,status:`streaming`})};handleMessageToolCallResult=e=>{if(this.toolCallArgsRawByCallId.get(e.toolCallId)!==`__nextclaw_aborted_tool_call__`&&!this.updateMessageContainingToolCall(e.toolCallId,(t,n)=>{let r={type:`tool-invocation`,toolCallId:e.toolCallId,toolName:n.toolName,state:`result`,args:n.args,result:e.content,resultContentItems:e.contentItems};return BM(t.parts,r)})){let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=BM(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:`unknown`,state:`result`,result:e.content,resultContentItems:e.contentItems});this.replaceStreamingMessage({...t,parts:n,status:`streaming`})}};handleRunStarted=e=>{this.isSettledRunId(e.runId)||(this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1)};handleRunFinished=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`final`),this.setError(null),this.clearActiveRun()};handleRunError=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`error`),this.setError(PM(e)),this.clearActiveRun()};handleRunMetadata=e=>{let t=e.metadata;if(t?.kind===`ready`){let e=t;if(this.isSettledRunId(e.runId))return;this.activeRun={runId:e.runId??this.activeRun?.runId??null,sessionId:e.sessionId??this.activeRun?.sessionId,abortDisabledReason:e.supportsAbort===!1?e.abortDisabledReason??`Unsupported`:null},this.stateVersion+=1}else t?.kind===`final`&&(this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.clearActiveRun())};handleContextWindowUpdated=e=>{this.contextWindow={...e.contextWindow},this.stateVersion+=1};handleEndpointError=e=>{if(e.code===`abort-error`){this.handleMessageAbort({sessionId:this.activeRun?.sessionId??this.streamingMessage?.sessionId??``,...this.streamingMessage?.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage(`error`),this.clearActiveRun(),this.setError(e)};applyToolCallArgs=(e,t,n,r)=>{let i=this.resolveToolCallTargetMessage(e,t,r),a=zM(i.parts,t)??`unknown`,o=BM(i.parts,{type:`tool-invocation`,toolCallId:t,toolName:a,state:`partial-call`,args:n});this.replaceStreamingMessage({...i,parts:o,status:`streaming`})};ensureStreamingMessage=(e,t,n)=>{if(this.streamingMessage?.id===t){if(this.streamingMessage.status===n)return this.streamingMessage;let e={...this.streamingMessage,status:n};return this.replaceStreamingMessage(e),e}let r=this.messages.findIndex(e=>e.id===t);if(r>=0){let t=jM(this.messages[r]),i=[...this.messages];i.splice(r,1),this.messages=i,this.stateVersion+=1;let a={...t,sessionId:e,status:n};return this.replaceStreamingMessage(a),a}let i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&FM(i,t)){let r={...i,id:t,sessionId:e,status:n};return IM(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:HM,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(a),a};resolveToolCallTargetMessage=(e,t,n)=>{let r=n?.trim()||this.toolCallMessageIdByCallId.get(t)||this.streamingMessage?.id||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,`streaming`)};updateMessageContainingToolCall=(e,t)=>{if(this.streamingMessage){let n=RM(this.streamingMessage.parts,e);if(n){let e=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:e}),!0}}for(let n=this.messages.length-1;n>=0;--n){let r=this.messages[n],i=RM(r.parts,e);if(!i)continue;let a=[...this.messages];return a[n]={...r,parts:t(r,i)},this.messages=a,this.stateVersion+=1,!0}return!1};upsertMessage=e=>{let t=MM(e);this.streamingMessage?.id===t.id&&(this.streamingMessage=null);let n=this.messages.findIndex(e=>e.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}let r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1};replaceStreamingMessage=e=>{!e&&!this.streamingMessage||(this.streamingMessage=e?MM(e):null,this.stateVersion+=1)};setError=e=>{this.error?.code===e?.code&&this.error?.message===e?.message&&this.error?.details===e?.details&&this.error?.cause===e?.cause||(this.error=e?{...e,details:e.details?{...e.details}:void 0}:null,this.stateVersion+=1)};clearActiveRun=()=>{this.activeRun&&(this.activeRun=null,this.stateVersion+=1)};isSettledRunId=e=>!!e?.trim()&&e===this.lastSettledRunId;markRunAsSettled=e=>{this.lastSettledRunId=e?.trim()||null};settleStreamingMessage=e=>{if(!this.streamingMessage)return;let t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),LM(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}},WM=16,GM=class{constructor(e){this.dispatchBatch=e,this.queue=[],this.flushTimerId=null,this.isFlushing=!1,this.isDisposed=!1,this.enqueue=e=>{this.isDisposed||(this.queue.push(e),this.scheduleFlush())},this.dispose=()=>{this.isDisposed=!0,this.flushTimerId!==null&&(window.clearTimeout(this.flushTimerId),this.flushTimerId=null),this.queue.length=0},this.scheduleFlush=()=>{this.flushTimerId!==null||this.isFlushing||this.queue.length===0||(this.flushTimerId=window.setTimeout(()=>{this.flushTimerId=null,this.flush()},WM))},this.flush=async()=>{if(!(this.isDisposed||this.isFlushing||this.queue.length===0)){this.isFlushing=!0;try{for(;this.queue.length>0;){let e=this.queue.splice(0);await this.dispatchBatch(e)}}finally{this.isFlushing=!1,this.scheduleFlush()}}}}};function KM(e,t){let n=e.dispatchBatch;return typeof n==`function`?n.call(e,t):t.reduce((t,n)=>t.then(()=>e.dispatch(n)),Promise.resolve())}function qM(e,t){if(!t)return!0;let n=`payload`in e?e.payload:null;return!n||typeof n!=`object`||!(`sessionId`in n)||typeof n.sessionId!=`string`?!0:n.sessionId===t}function JM(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function YM(e,t){if(typeof e==`string`){let n=e.trim();return n?{...t?{sessionId:t}:{},message:{id:`user-${Date.now().toString(36)}`,...t?{sessionId:t}:{},role:`user`,status:`final`,parts:[{type:`text`,text:n}],timestamp:new Date().toISOString()}}:null}if(!JM(e.message))return null;let n=e.sessionId||e.message.sessionId||t;return{...e,...n?{sessionId:n}:{},message:{...e.message,...n?{sessionId:n}:{}}}}function XM(e){let t=(0,F.useRef)();return t.current?e&&t.current.sessionId===null?t.current.sessionId=e:t.current.sessionId!==(e??null)&&(t.current={sessionId:e??null,manager:new UM}):t.current={sessionId:e??null,manager:new UM},t.current.manager}function ZM({sessionId:e,client:t,manager:n}){let r=(0,F.useRef)(e),i=(0,F.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[a,o]=(0,F.useState)(!1);(0,F.useEffect)(()=>{r.current=e},[e]),(0,F.useEffect)(()=>{o(!1)},[e]),(0,F.useEffect)(()=>{let e=new GM(e=>KM(n,e)),i=t.subscribe(t=>{qM(t,r.current)&&e.enqueue(t)});return()=>{i(),e.dispose(),t.stop()}},[t,n]);let s=i.streamingMessage?[...i.messages,i.streamingMessage]:i.messages,c=i.activeRun?.runId??null,l=!!i.activeRun;return{snapshot:i,visibleMessages:s,activeRunId:c,isRunning:l,isSending:a,send:async r=>{if(a||l)return null;let i=YM(r,e);if(!i)return null;o(!0),e&&await n.dispatch({type:TM.MessageSent,payload:{sessionId:e,message:{...i.message,sessionId:e},metadata:i.metadata}});try{return await t.send(i)}finally{o(!1)}},abort:async()=>{e&&await t.abort({sessionId:e})},streamRun:async()=>{e&&(await t.stop(),await t.stream({sessionId:e}))}}}function QM(e){return e instanceof Error?e:Error(String(e))}function $M(e){let{hydratedSessionId:t,isHydrating:n,sessionId:r}=e;return r?n||t!==r:!1}function eN(e,t){let n=e.getSnapshot();return n.activeRun?.sessionId===t||n.streamingMessage?.sessionId===t||n.messages.some(e=>e.sessionId===t)}function tN(e,t){return e.status===`running`?{runId:null,sessionId:t,abortDisabledReason:null}:null}function nN(e,t,n){return n.signal.aborted||e.requestId!==t}function rN({sessionId:e,client:t,loadSeed:n}){let r=XM(e),i=ZM({sessionId:e,client:t,manager:r}),[a,o]=(0,F.useState)(!0),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),d=(0,F.useRef)({requestId:0,controller:null}),f=(0,F.useCallback)(async()=>{await t.stop(),r.reset(),c(null),u(null),o(!1),d.current={requestId:d.current.requestId+1,controller:null}},[t,r]),p=(0,F.useCallback)(e=>{c(null),u(e),o(!1)},[]),m=(0,F.useCallback)(async()=>{if(d.current.controller?.abort(),!e){await f();return}let i=new AbortController,a=d.current.requestId+1;if(d.current={requestId:a,controller:i},eN(r,e)){p(e),d.current.controller===i&&(d.current.controller=null);return}await t.stop(),r.reset(),c(null),o(!0);try{let o=await n(e,i.signal);if(nN(d.current,a,i))return;r.hydrate({sessionId:e,messages:o.messages,activeRun:tN(o,e)}),p(e),t.stream({sessionId:e}).catch(e=>{d.current.requestId===a&&c(QM(e))})}catch(t){if(nN(d.current,a,i))return;c(QM(t)),u(e),o(!1)}finally{d.current.controller===i&&(d.current.controller=null)}},[t,n,r,p,f,e]);return(0,F.useEffect)(()=>(m(),()=>{d.current.controller?.abort(),d.current.controller=null}),[m]),{...i,isHydrating:$M({sessionId:e,hydratedSessionId:l,isHydrating:a}),hydrateError:s}}var iN=200*1024*1024,aN=`application/octet-stream`;function oN(e){let t=e.type.trim().toLowerCase();return t.length>0?t:aN}function sN(e,t){let n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(e=>e.trim().toLowerCase())):null,r=t.maxBytes??209715200,i=oN(e);return n&&!n.has(i)?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`unsupported-type`}}:e.size>r?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`too-large`}}:{ok:!0,mimeType:i}}function cN(e){let t=e.parts&&e.parts.length>0?e.parts.map(e=>structuredClone(e)):[...e.text?.trim()??``?[{type:`text`,text:e.text.trim()}]:[],...(e.attachments??[]).map(e=>({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?.trim()?{assetUri:e.assetUri.trim()}:{},...e.url?.trim()?{url:e.url.trim()}:{},...e.contentBase64?.trim()?{contentBase64:e.contentBase64.trim()}:{},sizeBytes:e.sizeBytes}))];if(t.length===0)return null;let n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{...e.sessionId?{sessionId:e.sessionId}:{},message:{id:r,...e.sessionId?{sessionId:e.sessionId}:{},role:`user`,status:`final`,parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function lN(e,t){let n=[],r=[];for(let i of e){let e=sN(i,t);if(!e.ok){r.push(e.rejected);continue}n.push(i)}if(n.length===0)return{attachments:[],rejected:r};try{return{attachments:await t.uploadBatch(n),rejected:r}}catch{return r.push(...n.map(e=>({fileName:e.name,mimeType:oN(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}function uN(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function dN(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function fN(e){return!e.isModelOptionsLoading&&!e.isModelOptionsEmpty?null:e.isModelOptionsLoading?{tone:`neutral`,loading:!0}:{tone:`warning`,text:e.texts.noModelOptionsLabel,actionLabel:e.texts.configureProviderLabel,onAction:e.onGoToProviders}}function pN({modelOptions:e,recentModelValues:t,selectedModel:n,isModelOptionsLoading:r,hasModelOptions:i,onValueChange:a,texts:o}){let s=e.find(e=>e.value===n)??e[0],c=i?s?.value:void 0,l=new Set(t??[]),u=new Map(e.map(e=>[e.value,e])),d=(t??[]).map(e=>u.get(e)).filter(e=>!!e),f=e.filter(e=>!l.has(e.value)),p=d.length>0?[{key:`recent-models`,label:o.recentModelsLabel,options:d.map(e=>({value:e.value,label:uN(e)}))},{key:`all-models`,label:o.allModelsLabel,options:f.map(e=>({value:e.value,label:uN(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:c,placeholder:o.modelSelectPlaceholder,selectedLabel:s?uN(s):void 0,icon:`sparkles`,options:e.map(e=>({value:e.value,label:uN(e)})),groups:p,disabled:!i,loading:r,emptyLabel:o.modelNoOptionsLabel,onValueChange:a}}function mN(e){if(e.supportedLevels.length===0)return null;let t=dN(e.supportedLevels),n=t.includes(`off`)?`off`:t[0],r=e.selectedThinkingLevel&&t.includes(e.selectedThinkingLevel)&&e.selectedThinkingLevel||e.defaultThinkingLevel&&t.includes(e.defaultThinkingLevel)&&e.defaultThinkingLevel||n;return{key:`thinking`,value:r,placeholder:e.texts.thinkingLabels[r],selectedLabel:e.texts.thinkingLabels[r],icon:`brain`,options:t.map(t=>({value:t,label:e.texts.thinkingLabels[t]})),onValueChange:t=>e.onValueChange(t)}}var hN={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function gN(e){return(e??``).trim().toLowerCase()}function _N(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function vN(e,t){let n=gN(t);if(!n)return hN.fallback;let r=gN(e.key),i=gN(e.label||e.key),a=gN(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?hN.exactSpec:i===n?hN.exactLabel:r.startsWith(n)?hN.prefixSpec:i.startsWith(n)?hN.prefixLabel:o.some(e=>e.startsWith(n))?hN.prefixToken:r.includes(n)?hN.containsSpec:i.includes(n)?hN.containsLabel:a.includes(n)?hN.containsDescription:_N(n,i)||_N(n,r)?hN.subsequence:0}function yN(e){return e>=hN.exactLabel?4:e>=hN.prefixToken?3:e>=hN.containsLabel?2:e>0?1:0}function bN(e){return new Map(e.map((e,t)=>[e,t]))}function xN(e,t){let n=bN(t),r=[],i=[];for(let t of e){if(n.has(t.key)){r.push(t);continue}i.push(t)}return r.sort((e,t)=>(n.get(e.key)??1/0)-(n.get(t.key)??1/0)),[...r,...i]}function SN(e,t,n,r=[]){let i=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),a=bN(r);return e.map((e,n)=>({record:e,order:n,score:vN(e,t)})).filter(e=>e.score>0).sort((e,t)=>{let n=yN(e.score),r=yN(t.score);if(r!==n)return r-n;let o=a.get(e.record.key)??1/0,s=a.get(t.record.key)??1/0;if(o!==s)return o-s;if(t.score!==e.score)return t.score-e.score;let c=(e.record.label||e.record.key).trim(),l=(t.record.label||t.record.key).trim(),u=i.compare(c,l);return u===0?e.order-t.order:u}).map(({record:e})=>({key:`skill:${e.key}`,title:e.label||e.key,subtitle:n.slashSkillSubtitle,description:(e.descriptionZh??e.description??``).trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${e.key}`,...e.scopeLabel?[`${n.slashSkillScopeLabel}: ${e.scopeLabel}`]:[]],value:e.key}))}function CN(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function wN(e){let t=xN(e.skillRecords,e.recentSkillValues??[]),n=new Set(e.groupedRecentSkillValues??[]),r=CN(t.filter(e=>n.has(e.key))),i=CN(t.filter(e=>!n.has(e.key)));return{title:e.texts.title,searchPlaceholder:e.texts.searchPlaceholder,emptyLabel:e.texts.emptyLabel,loadingLabel:e.texts.loadingLabel,isLoading:e.isLoading,manageLabel:e.texts.manageLabel,manageHref:`/marketplace/skills`,options:CN(t),groups:r.length>0?[{key:`recent-skills`,label:e.texts.recentSkillsLabel,options:r},{key:`all-skills`,label:e.texts.allSkillsLabel,options:i}].filter(e=>e.options.length>0):void 0,selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}var TN=`$`;function EN(e,t){if(t.length===0)return e;let n=e[e.length-1];return n?.type===`text`?[...e.slice(0,-1),{...n,text:n.text+t}]:[...e,{type:`text`,text:t}]}function DN(){return Hv()}function ON(e){return Uv(e)}function kN(e){return Kv(e)}function AN(e){return qv(e,`skill`)}function jN(e){return qv(e,`file`)}function MN(e,t,n){let r=new Set(t),i=ey(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=qv(i,`skill`),o=new Map(n.map(e=>[e.ref,e])),s=t.filter(e=>!a.includes(e)).map(e=>Bv({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.name||e}));return s.length===0?i:Wv([...i,...s])}function NN(e,t){let n=new Set(t.map(e=>e.id));return ey(e,e=>e.tokenKind===`file`&&!n.has(e.tokenKey))}function PN(e,t){let n=new Set(jN(e));return t.filter(e=>n.has(e.id))}function FN(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){r=EN(r,t.text);continue}if(t.tokenKind===`skill`){r=EN(r,`${TN}${t.tokenKey}`);continue}if(t.tokenKind!==`file`)continue;let e=n.get(t.tokenKey);e&&r.push({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?{assetUri:e.assetUri}:{},...e.url?{url:e.url}:{},...e.contentBase64?{contentBase64:e.contentBase64}:{},sizeBytes:e.sizeBytes})}return r}var IN={isProviderStateResolved:!1,composerNodes:DN(),attachments:[],draft:``,pendingSessionType:`native`,pendingProjectRoot:null,pendingProjectRootSessionKey:null,defaultSessionType:`native`,canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:``,selectedThinkingLevel:null,sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[],composerFocusRequest:null},Z=m(e=>({snapshot:IN,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))})),LN=class{constructor(e){this.options=e,this.read=()=>{let e=this.getStorage();if(!e)return[];try{return this.normalizeList(JSON.parse(e.getItem(this.options.storageKey)??`[]`))}catch{return[]}},this.remember=e=>{let t=this.normalizeValue(e);if(!t)return this.read();let n=[t,...this.read().filter(e=>e!==t)].slice(0,this.options.limit);return this.write(n),n},this.resolveVisible=e=>{let t=this.normalizeList(e.availableValues,1/0);if(t.length<=e.minAvailableCount)return[];let n=new Set(t),r=[],i=Math.max(1,e.limit??this.options.limit);for(let e of this.read())if(!(!n.has(e)||r.includes(e))&&(r.push(e),r.length>=i))break;return r},this.write=e=>{let t=this.getStorage();if(t)try{t.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(e)))}catch{}},this.getStorage=()=>Object.prototype.hasOwnProperty.call(this.options,`storage`)?this.options.storage??null:typeof window>`u`?null:window.localStorage,this.normalizeList=(e,t=this.options.limit)=>{if(!Array.isArray(e))return[];let n=[];for(let r of e){let e=this.normalizeValue(r);if(!(!e||n.includes(e))&&(n.push(e),n.length>=t))break}return n},this.normalizeValue=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}}},RN=new LN({storageKey:`nextclaw.chat.recent-models`,limit:3}),zN=new LN({storageKey:`nextclaw.chat.recent-skills`,limit:5});function BN(e){return e.modelOptions.length>0}function VN(e){return!e.isProviderStateResolved&&!BN(e)}function HN(e){return e.isProviderStateResolved&&!BN(e)}function UN(e){return!1}function WN(e){let{hasSendableDraft:t,isRuntimeBlocked:n}=e;return n||!t}var GN=`nextclaw.chat.session-list.mode`,KN=`time-first`;function qN(e){return e===`time-first`||e===`project-first`}function JN(e){if(!e||typeof e!=`object`)return null;let{snapshot:t}=e;return!t||typeof t!=`object`?null:qN(t.listMode)?t.listMode:null}function YN(e,t){let n=e?.trim();if(!n)return!1;let r=t?.trim();return r?n.localeCompare(r)>0:!1}function XN(e){let{active:t,readAt:n,runStatus:r,lastMessageAt:i}=e;return t||r===`running`?!1:YN(i,n)}var ZN={selectedSessionKey:null,selectedAgentId:`main`,query:``,listMode:KN};function QN(e){return t=>e(e=>({snapshot:{...e.snapshot,...t}}))}function $N(e){return(t,n)=>e(e=>{let r=t.trim(),i=n?.trim();if(!r||!i)return e;let a=e.optimisticReadAtBySessionKey[r];return a&&a.localeCompare(i)>=0?e:{...e,optimisticReadAtBySessionKey:{...e.optimisticReadAtBySessionKey,[r]:i}}})}var eP=m()(Tn(e=>({snapshot:ZN,optimisticReadAtBySessionKey:{},setSnapshot:QN(e),markSessionRead:$N(e)}),{name:GN,storage:On(()=>window.localStorage),partialize:e=>({snapshot:{listMode:e.snapshot.listMode}}),merge:(e,t)=>{let n=JN(e);return n?{...t,snapshot:{...t.snapshot,listMode:n}}:t}})),tP={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionTypeIcon:null,sessionKey:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,availableAgents:[],sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null,contextWindow:null},Q=m(e=>({snapshot:tP,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function nP(e){return e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function rP(e){if(!e||e.totalContextTokens<=0)return null;let t=e.usedContextTokens/e.totalContextTokens,n=Math.max(0,Math.min(1,t)),r=`${Math.round(n*100)}%`,i=n>=.9?`danger`:n>=.75?`warning`:`neutral`,a=[{label:s(`chatContextWindowUsed`),value:nP(e.usedContextTokens)},{label:s(`chatContextWindowTotal`),value:nP(e.totalContextTokens)},{label:s(`chatContextWindowAvailable`),value:nP(e.availableContextTokens)}];return e.prunedUsedContextTokens!==e.usedContextTokens&&a.push({label:s(`chatContextWindowPruned`),value:nP(e.prunedUsedContextTokens)}),e.droppedHistoryCount>0&&a.push({label:s(`chatContextWindowDroppedHistory`),value:String(e.droppedHistoryCount)}),e.truncatedToolResultCount>0&&a.push({label:s(`chatContextWindowTruncatedTools`),value:String(e.truncatedToolResultCount)}),{label:s(`chatContextWindow`),percentLabel:r,ratio:n,tone:i,details:a}}function iP(){let e=eP(e=>e.snapshot.selectedSessionKey),t=Q(e=>e.snapshot.sessionKey),n=Q(e=>e.snapshot.contextWindow);return(0,F.useMemo)(()=>e&&t===e&&n?rP(n):null,[n,t,e])}function aP(e){return e.bootstrapStatus?.ncpAgent.state!==`ready`}function oP(e){return e.activeSystemAction?.message?.trim()||(e.lifecyclePhase===`cold-starting`?s(`chatRuntimeInitializing`):e.lifecyclePhase===`startup-failed`?e.bootstrapStatus?.ncpAgent.error?.trim()||e.bootstrapStatus?.lastError?.trim()||e.lastError?.trim()||s(`chatRuntimeInitializationFailed`):null)}function sP(e){let{message:t,status:n}=e,r=t?.trim();if(!r)return oP(n);let i=n.activeSystemAction?.message?.trim();if(n.phase===`service-transitioning`&&i)return i;let a=st(r);return n.phase===`recovering`&&a?s(`runtimeControlRecoveringHelp`):n.phase===`stalled`&&a?null:r}function cP(){return{off:s(`chatThinkingLevelOff`),minimal:s(`chatThinkingLevelMinimal`),low:s(`chatThinkingLevelLow`),medium:s(`chatThinkingLevelMedium`),high:s(`chatThinkingLevelHigh`),adaptive:s(`chatThinkingLevelAdaptive`),xhigh:s(`chatThinkingLevelXhigh`)}}function lP(e,t){return e.map(e=>({key:e.ref,label:e.name,scopeLabel:t[e.scope],description:e.description,descriptionZh:e.descriptionZh,badgeLabel:t[e.scope]}))}function uP(e){return e.map(e=>({value:e.value,modelLabel:e.modelLabel,providerLabel:e.providerLabel,thinkingCapability:e.thinkingCapability?{supported:e.thinkingCapability.supported,default:e.thinkingCapability.default??null}:null}))}function dP(e){return{skillScopeLabels:(0,F.useMemo)(()=>({builtin:s(`chatSkillScopeBuiltin`),project:s(`chatSkillScopeProject`),workspace:s(`chatSkillScopeWorkspace`)}),[e]),slashTexts:(0,F.useMemo)(()=>({slashSkillSubtitle:s(`chatSlashTypeSkill`),slashSkillSpecLabel:s(`chatSlashSkillSpec`),slashSkillScopeLabel:s(`chatSlashSkillScope`),noSkillDescription:s(`chatSkillsPickerNoDescription`)}),[e]),recentModelsLabel:s(`chatPickerRecentModels`),allModelsLabel:s(`chatPickerAllModels`),recentSkillsLabel:s(`chatPickerRecent`),allSkillsLabel:s(`chatPickerAllSkills`)}}function fP(e,t){let n=(0,F.useMemo)(()=>lP(e.skillRecords,t),[e.skillRecords,t]),r=(0,F.useMemo)(()=>uP(e.modelOptions),[e.modelOptions]);return{skillRecords:n,modelRecords:r,recentModelValues:RN.resolveVisible({availableValues:r.map(e=>e.value),minAvailableCount:5}),recentSkillValues:zN.resolveVisible({availableValues:n.map(e=>e.key),minAvailableCount:0}),recentSkillGroupValues:zN.resolveVisible({availableValues:n.map(e=>e.key),minAvailableCount:4})}}function pP(e){let{attachmentSupported:t,inputBarRef:n,presenter:r}=e,i=(0,F.useCallback)(e=>{if(e===`unsupported-type`){N.error(s(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){N.error(s(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(iN/(1024*1024))));return}N.error(s(`chatInputAttachmentReadFailed`))},[]),a=(0,F.useCallback)(async e=>{if(!t||e.length===0)return;let a=await lN(e,{uploadBatch:yt});if(a.attachments.length>0){let e=r.chatInputManager.addAttachments?.(a.attachments)??[];e.length>0&&n.current?.insertFileTokens(e.map(e=>({tokenKey:e.id,label:e.name})))}a.rejected.length>0&&i(a.rejected[0].reason)},[t,n,r.chatInputManager,i]);return{handleFilesAdd:a,handleFileInputChange:(0,F.useCallback)(async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await a(t)},[a])}}function mP(e){let{allModelsLabel:t,hasModelOptions:n,isModelOptionsLoading:r,modelRecords:i,presenter:a,recentModelValues:o,recentModelsLabel:c,selectedModel:l,selectedThinkingLevel:u,thinkingSupportedLevels:d,thinkingDefaultLevel:f}=e;return[pN({modelOptions:i,recentModelValues:o,selectedModel:l,isModelOptionsLoading:r,hasModelOptions:n,onValueChange:a.chatInputManager.selectModel,texts:{modelSelectPlaceholder:s(`chatSelectModel`),modelNoOptionsLabel:s(`chatModelNoOptions`),recentModelsLabel:c,allModelsLabel:t}}),mN({supportedLevels:d,selectedThinkingLevel:u,defaultThinkingLevel:f,onValueChange:e=>a.chatInputManager.selectThinkingLevel(e),texts:{thinkingLabels:cP()}})].filter(e=>e!==null)}function hP(e){let{allSkillsLabel:t,presenter:n,recentSkillGroupValues:r,recentSkillValues:i,recentSkillsLabel:a,skillRecords:o,snapshot:c}=e;return wN({skillRecords:o,recentSkillValues:i,groupedRecentSkillValues:r,selectedSkills:c.selectedSkills,isLoading:c.isSkillsLoading,onSelectedKeysChange:n.chatInputManager.selectSkills,texts:{title:s(`chatSkillsPickerTitle`),searchPlaceholder:s(`chatSkillsPickerSearchPlaceholder`),emptyLabel:s(`chatSkillsPickerEmpty`),loadingLabel:s(`sessionsLoading`),manageLabel:s(`chatSkillsPickerManage`),recentSkillsLabel:a,allSkillsLabel:t}})}function gP(){let e=ic(),{language:t}=kr(),{isMobile:n}=Pr(),r=Z(e=>e.snapshot),i=aP(bt()),[a,o]=(0,F.useState)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=dP(t),{skillRecords:d,modelRecords:f,recentModelValues:p,recentSkillValues:m,recentSkillGroupValues:h}=fP(r,u.skillScopeLabels),g=BN(r),_=VN(r),v=HN(r),y=UN(r),b=typeof e.chatInputManager.addAttachments==`function`,x=s(v?`chatModelNoOptions`:n?`chatInputPlaceholderCompact`:`chatInputPlaceholder`),S=(0,F.useMemo)(()=>SN(d,a??``,u.slashTexts,m),[u.slashTexts,m,d,a]),C=iP(),w=f.find(e=>e.value===r.selectedModel),T=w?.thinkingCapability?.supported??[],E=r.stopDisabledReason===`__preparing__`?s(`chatStopPreparing`):r.stopDisabledReason?.trim()||s(`chatStopUnavailable`),{handleFilesAdd:D,handleFileInputChange:O}=pP({attachmentSupported:b,inputBarRef:c,presenter:e});(0,F.useEffect)(()=>{let t=r.composerFocusRequest;t&&(t.placement===`end`&&c.current?.focusComposerAtEnd(),e.chatInputManager.consumeComposerFocusRequest(t.id))},[e.chatInputManager,r.composerFocusRequest]);let k=mP({allModelsLabel:u.allModelsLabel,hasModelOptions:g,isModelOptionsLoading:_,modelRecords:f,presenter:e,recentModelValues:p,recentModelsLabel:u.recentModelsLabel,selectedModel:r.selectedModel,selectedThinkingLevel:r.selectedThinkingLevel,thinkingSupportedLevels:T,thinkingDefaultLevel:w?.thinkingCapability?.default??null}),A=hP({allSkillsLabel:u.allSkillsLabel,presenter:e,recentSkillGroupValues:h,recentSkillValues:m,recentSkillsLabel:u.recentSkillsLabel,skillRecords:d,snapshot:r}),ee=r.draft.trim().length>0||r.attachments.length>0||AN(r.composerNodes).length>0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Py,{ref:c,composer:{nodes:r.composerNodes,placeholder:x,disabled:y,onNodesChange:e.chatInputManager.setComposerNodes,...b?{onFilesAdd:D}:{},onSlashQueryChange:o},slashMenu:{isLoading:r.isSkillsLoading,items:S,onSelectItem:t=>{t.value&&e.chatInputManager.rememberSkillSelection(t.value)},texts:{slashLoadingLabel:s(`chatSlashLoading`),slashSectionLabel:s(`chatSlashSectionSkills`),slashEmptyLabel:s(`chatSlashNoResult`),slashHintLabel:s(`chatSlashHint`),slashSkillHintLabel:s(`chatSlashSkillHint`)}},hint:fN({isModelOptionsLoading:_,isModelOptionsEmpty:v,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:s(`chatModelNoOptions`),configureProviderLabel:s(`chatGoConfigureProvider`)}}),toolbar:{selects:k,accessories:[{key:`attach`,label:s(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:!b||y||r.isSending,...b?{onClick:()=>l.current?.click()}:{tooltip:s(`chatInputAttachComingSoon`)}}],skillPicker:A,actions:{sendError:i?null:r.sendError,isSending:r.isSending,canStopGeneration:r.canStopGeneration,sendDisabled:WN({snapshot:r,hasSendableDraft:ee,isRuntimeBlocked:i}),stopDisabled:!r.canStopGeneration,stopHint:E,sendButtonLabel:s(`chatSend`),stopButtonLabel:s(`chatStop`),contextWindow:C,onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),b?(0,I.jsx)(`input`,{ref:l,type:`file`,multiple:!0,className:`hidden`,onChange:O}):null]})}var _P=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function vP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yP(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function bP(e,t=120){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1)}…`}function xP(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return yP(JSON.stringify(e,null,2))}catch{return String(e)}}function SP(e){if(vP(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{let e=JSON.parse(t);return vP(e)?e:null}catch{return null}}function CP(e){let t=SP(e);if(!t){let t=xP(e).trim();return t?bP(t,120):void 0}let n=[];for(let e of _P){let r=t[e];if(typeof r==`string`&&r.trim()?n.push(`${e}: ${r.trim()}`):(typeof r==`number`||typeof r==`boolean`)&&n.push(`${e}: ${String(r)}`),n.length>=2)break}return n.length>0?bP(n.join(` · `),120):bP(xP(t),140)}var wP=`ui_inline_tokens`,TP=`$`;function EP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function DP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function OP(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind}:${r.key}:${r.rawText}`;t.has(e)||(t.add(e),n.push(r))}return n}function kP(e){let t=[];for(let n of e)n.type!==`token`||n.tokenKind!==`skill`||t.push({kind:`skill`,key:n.tokenKey,label:n.label,rawText:`${TP}${n.tokenKey}`});return OP(t)}function AP(e){let t=e?.[wP];if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!EP(e))continue;let t=DP(e.kind),r=DP(e.key),i=DP(e.rawText);!t||!r||!i||n.push({kind:t,key:r,rawText:i,label:DP(e.label)??r})}return OP(n)}function jP(e,t){if(e.length===0||t.length===0)return e.length===0?[]:[{type:`text`,text:e}];let n=[...t].sort((e,t)=>t.rawText.length-e.rawText.length),r=[],i=0;for(;i<e.length;){let t=null;for(let r of n)if(e.startsWith(r.rawText,i)){t=r;break}if(!t){let t=i+1;for(;t<e.length&&!n.some(n=>e.startsWith(n.rawText,t));)t+=1;r.push({type:`text`,text:e.slice(i,t)}),i=t;continue}r.push({type:`token`,token:t}),i+=t.rawText.length}return r}var MP=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function NP(e){let t=e.trim();return t&&t.replace(MP,``).trim()?t:null}function PP(e){return e.replace(MP,``).trim().length>0}function FP(e,t){let n=jP(e,t);if(n.length===0)return null;let r=[],i=!1;for(let e of n){if(e.type===`token`){i=!0,r.push({type:`token`,token:{kind:e.token.kind,key:e.token.key,label:e.token.label,rawText:e.token.rawText}});continue}e.text.length!==0&&(PP(e.text)&&(i=!0),r.push({type:`markdown`,text:e.text}))}return i?r:null}function IP(e,t){let n=FP(e.text,t);if(n&&n.some(e=>e.type===`token`))return{type:`inline-content`,segments:n};let r=NP(e.text);return r?{type:`markdown`,text:r}:null}function LP(e){return NP(e)}function RP(e){return typeof e==`object`&&!!e}function zP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function BP(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function VP(e){return RP(e)?`command`in e||`workingDir`in e||`exitCode`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e:!1}function HP(e,t){if(!RP(e))return null;let n=RP(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&RP(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=zP(n.url),i=zP(n.mimeType)??`application/octet-stream`,a=BP(n.sizeBytes);return r?{type:`file`,file:{label:zP(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function UP(e,t){return{kind:e.kind,toolName:e.name,...`agentId`in e&&e.agentId?{agentId:e.agentId}:{},summary:e.detail,inputLabel:t.toolInputLabel,input:`input`in e&&typeof e.input==`string`?e.input:void 0,output:e.text,outputData:e.outputData,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,...`action`in e&&e.action?{action:e.action}:{},...`fileOperation`in e&&e.fileOperation?{fileOperation:e.fileOperation}:{}}}function WP(e){let t=typeof e.status==`string`?e.status.trim().toLowerCase():``,n=typeof e.error==`string`&&e.error.trim().length>0;return e.cancelled===!0||t===`cancelled`?{kind:`result`,hasResult:!0,statusTone:`cancelled`,statusLabel:e.texts.toolStatusCancelledLabel}:n||t===`error`?{kind:`result`,hasResult:!0,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:t===`result`||e.result!=null?{kind:`result`,hasResult:!0,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function GP(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function KP(e,t){return xP(t??GP(e)).trim()||void 0}function qP(e){return typeof e==`object`&&!!e}function JP(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function YP(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function XP(e){let t=JP(e);return qP(t)?YP(t.agentId):null}function ZP(e){return XP(e.parsedArgs)??XP(e.args)??XP(e.result)}var QP=12e3,$P=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function eF(e){let t=e.replace(/\r\n/g,`
92
92
  `).replace(/\r/g,`
93
93
  `);return t===``?[]:t.split(`
94
- `)}function $P(e){return typeof e==`number`?e+1:void 0}function eF(e){return{kind:e.kind,text:e.text,...typeof e.oldLineNumber==`number`?{oldLineNumber:e.oldLineNumber}:{},...typeof e.newLineNumber==`number`?{newLineNumber:e.newLineNumber}:{}}}function tF(e){let t=ZP.exec(e);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function nF(e){return QP(e.text).map((t,n)=>e.kind===`add`?eF({kind:`add`,text:t,newLineNumber:e.newStartLine+n}):eF({kind:`context`,text:t,oldLineNumber:e.oldStartLine+n,newLineNumber:e.newStartLine+n}))}function rF(e){let t=e.oldStartLine,n=e.newStartLine;return[...e.beforeLines.map(e=>{let n=eF({kind:`remove`,text:e,oldLineNumber:t});return t=$P(t),n}),...e.afterLines.map(e=>{let t=eF({kind:`add`,text:e,newLineNumber:n});return n=$P(n),t})]}function iF(e){let t=Array.from({length:e.beforeLines.length+1},()=>Array.from({length:e.afterLines.length+1},()=>0));for(let n=e.beforeLines.length-1;n>=0;--n)for(let r=e.afterLines.length-1;r>=0;--r)t[n][r]=e.beforeLines[n]===e.afterLines[r]?(t[n+1][r+1]??0)+1:Math.max(t[n+1][r]??0,t[n][r+1]??0);return t}function aF(e){for(let t=e.beforeIndex;t<e.beforeLines.length;t+=1)e.lines.push(eF({kind:`remove`,text:e.beforeLines[t]??``,oldLineNumber:e.oldLineNumber})),e.oldLineNumber=$P(e.oldLineNumber);for(let t=e.afterIndex;t<e.afterLines.length;t+=1)e.lines.push(eF({kind:`add`,text:e.afterLines[t]??``,newLineNumber:e.newLineNumber})),e.newLineNumber=$P(e.newLineNumber)}function oF(e){let t=QP(e.beforeText),n=QP(e.afterText);if(t.length*n.length>XP)return rF({beforeLines:t,afterLines:n,oldStartLine:e.oldStartLine,newStartLine:e.newStartLine});let r=iF({beforeLines:t,afterLines:n}),i=[],a=0,o=0,s=e.oldStartLine,c=e.newStartLine;for(;a<t.length&&o<n.length;){if(t[a]===n[o]){i.push(eF({kind:`context`,text:t[a]??``,oldLineNumber:s,newLineNumber:c})),a+=1,o+=1,s=$P(s),c=$P(c);continue}if((r[a+1][o]??0)>=(r[a][o+1]??0)){i.push(eF({kind:`remove`,text:t[a]??``,oldLineNumber:s})),a+=1,s=$P(s);continue}i.push(eF({kind:`add`,text:n[o]??``,newLineNumber:c})),o+=1,c=$P(c)}return aF({lines:i,beforeLines:t,afterLines:n,beforeIndex:a,afterIndex:o,oldLineNumber:s,newLineNumber:c}),i}var sF=120;function cF(e){let t=e.lines.filter(e=>e.kind===`add`).length,n=e.lines.filter(e=>e.kind===`remove`).length,r=[],i=e.operation?.trim().toLowerCase()??``;return i&&i!==`update`&&r.push(i),t>0&&r.push(`+${t}`),n>0&&r.push(`-${n}`),r.length>0?r.join(` · `):void 0}function lF(e){let t=e.operation?.trim().toLowerCase()??``;return{oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:(t===`delete`||t===`remove`)&&e.beforeText!=null?1:void 0,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:(t===`write`||t===`add`)&&e.afterText!=null?1:void 0}}function uF(e){return e.length<=sF?{lines:e,truncated:!1}:{lines:e.slice(0,sF),truncated:!0}}function dF(e){let t=uF(e.lines);return{path:e.path,display:`diff`,caption:cF({operation:e.operation,lines:e.lines}),lines:t.lines,...t.truncated?{fullLines:e.lines}:{},truncated:t.truncated}}function fF(e){let t=e.text.trim();if(!t)return null;let n=e.operation?.trim().toLowerCase()===`write`?`add`:`context`,r=typeof e.oldStartLine==`number`?e.oldStartLine:1,i=typeof e.newStartLine==`number`?e.newStartLine:1,a=nF({text:t,kind:n,oldStartLine:r,newStartLine:i});return{path:e.path,display:`preview`,caption:cF({operation:e.operation,lines:a}),lines:a,rawText:t,oldStartLine:r,newStartLine:i}}function pF(e){let{oldStartLine:t,newStartLine:n}=lF(e),r=oF({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:t,newStartLine:n}),i=uF(r);return i.lines.length===0?null:{path:e.path,display:`diff`,caption:cF({operation:e.operation,lines:r}),lines:i.lines,...i.truncated?{fullLines:r}:{},...e.beforeText==null?{}:{beforeText:e.beforeText},...e.afterText==null?{}:{afterText:e.afterText},...typeof t==`number`?{oldStartLine:t}:{},...typeof n==`number`?{newStartLine:n}:{},truncated:i.truncated}}function mF(e){return e.line.startsWith(`*** Update File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`update`),!0):e.line.startsWith(`*** Add File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(14).trim(),`add`),!0):e.line.startsWith(`*** Delete File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`delete`),!0):!1}function hF(e){let{currentLines:t,line:n}=e;return n.startsWith(`+`)?(t.push(eF({kind:`add`,text:n.slice(1),newLineNumber:e.newLineNumber})),{oldLineNumber:e.oldLineNumber,newLineNumber:$P(e.newLineNumber)}):n.startsWith(`-`)?(t.push(eF({kind:`remove`,text:n.slice(1),oldLineNumber:e.oldLineNumber})),{oldLineNumber:$P(e.oldLineNumber),newLineNumber:e.newLineNumber}):n.startsWith(` `)?(t.push(eF({kind:`context`,text:n.slice(1),oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber})),{oldLineNumber:$P(e.oldLineNumber),newLineNumber:$P(e.newLineNumber)}):{oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber}}function gF(e){let t=[],n=null,r=null,i=[],a,o,s=()=>{if(!n){i=[],r=null,a=void 0,o=void 0;return}t.push(dF({path:n,operation:r,lines:i})),n=null,r=null,i=[],a=void 0,o=void 0};for(let t of QP(e)){if(mF({line:t,flushCurrent:s,setCurrent:(e,t)=>{n=e,r=t}})||t.startsWith(`*** Move to: `)||t.startsWith(`*** Begin Patch`)||t.startsWith(`*** End Patch`))continue;if(t.startsWith(`@@`)){let e=tF(t);a=e?.oldLineNumber,o=e?.newLineNumber;continue}if(!n)continue;let e=hF({currentLines:i,line:t,oldLineNumber:a,newLineNumber:o});a=e.oldLineNumber,o=e.newLineNumber}return s(),t}function _F(e){let t=[],n=null,r=[],i,a,o=()=>{if(!n){r=[],i=void 0,a=void 0;return}t.push(dF({path:n,operation:`update`,lines:r})),n=null,r=[],i=void 0,a=void 0};for(let t of QP(e)){if(t.startsWith(`+++ `)){o(),n=t.slice(4).trim().replace(/^b\//,``).replace(/^a\//,``);continue}if(t.startsWith(`--- `))continue;if(t.startsWith(`@@`)){let e=tF(t);i=e?.oldLineNumber,a=e?.newLineNumber;continue}if(!n)continue;let e=hF({currentLines:r,line:t,oldLineNumber:i,newLineNumber:a});i=e.oldLineNumber,a=e.newLineNumber}return o(),t}function vF(e){return e.includes(`*** Begin Patch`)?gF(e):e.includes(`--- `)&&e.includes(`+++ `)?_F(e):[]}function yF(e){switch(e){case`"`:case`\\`:case`/`:return e;case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
95
- `;case`r`:return`\r`;case`t`:return` `;default:return e}}function bF(e,t){let n=`"${t}"`,r=e.indexOf(n);if(r<0)return null;let i=e.indexOf(`:`,r+n.length);if(i<0)return null;let a=i+1;for(;a<e.length&&/\s/.test(e[a]??``);)a+=1;return e[a]===`"`?a+1:null}function xF(e,t,n=1/0){let r=``,i=!1;for(let a=t;a<e.length;a+=1){let t=e[a];if(t==null)break;if(i){r+=yF(t),i=!1;continue}if(t===`\\`){i=!0;continue}if(t===`"`)return{value:r,truncated:!1};if(r+=t,r.length>=n)return{value:r,truncated:!0}}return r.length>0?{value:r,truncated:!1}:null}function SF(e,t,n=1/0){for(let r of t){let t=bF(e,r);if(t!=null)return xF(e,t,n)}return null}function CF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function wF(e){return typeof e==`string`&&e.trim()?e.trim():null}function TF(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:typeof e==`string`&&/^\d+$/.test(e.trim())?Number(e.trim()):null}function EF(e){if(CF(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);return CF(e)?e:null}catch{return null}}function DF(e){if(CF(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;let n=SF(t,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`])?.value??null,r=SF(t,[`content`,`text`,`afterText`,`after_text`])?.value??null,i=SF(t,[`oldText`,`beforeText`,`before_text`])?.value??null,a=SF(t,[`newText`,`afterText`,`after_text`])?.value??null,o=SF(t,[`patch`,`diff`,`unifiedDiff`,`unified_diff`])?.value??null,s={};return n&&(s.path=n),r&&(s.content=r),i&&(s.oldText=i),a&&(s.newText=a),o&&(s.patch=o),Object.keys(s).length>0?s:null}function OF(e){return wF(e.path)??wF(e.filePath)??wF(e.file_path)??wF(e.targetPath)??wF(e.target_path)??wF(e.filename)??wF(e.name)}function kF(e){return $(e.operation)??$(e.op)??$(e.action)??$(e.kind)??$(e.type)??$(e.status)}function AF(e,t){for(let n of t){let t=TF(e[n]);if(t!==null)return t}return null}function jF(e){return AF(e,[`oldStartLine`,`old_start_line`,`startOldLine`,`start_old_line`,`oldLineStart`,`old_line_start`,`oldLineNumber`,`old_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function MF(e){return AF(e,[`newStartLine`,`new_start_line`,`startNewLine`,`start_new_line`,`newLineStart`,`new_line_start`,`newLineNumber`,`new_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function NF(e){return $(e.patch)??$(e.diff)??$(e.unifiedDiff)??$(e.unified_diff)}function PF(e){return $(e.beforeText)??$(e.before_text)??$(e.oldText)??$(e.old_text)??$(e.oldContent)??$(e.old_content)??$(e.before)??$(e.previous)}function FF(e){return $(e.afterText)??$(e.after_text)??$(e.newText)??$(e.new_text)??$(e.newContent)??$(e.new_content)??$(e.content)??$(e.text)??$(e.after)??$(e.updated)}var IF=new Set([`file_change`,`read_file`,`write_file`,`edit_file`,`apply_patch`]);function LF(e){let t=e.map((e,t)=>({key:`${e.path}-${t+1}`,path:e.path,display:e.display,...e.caption?{caption:e.caption}:{},lines:e.lines,...e.fullLines?{fullLines:e.fullLines}:{},...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},...e.truncated?{truncated:!0}:{}})).filter(e=>e.lines.length>0||!!e.rawText);if(t.length===0)return null;let n=t.map(e=>e.path);return{summary:n.length===1?n[0]:`${n.length} files · ${n.slice(0,2).join(` · `)}${n.length>2?` …`:``}`,fileOperation:{blocks:t}}}function RF(e,t){let n=OF(e)??t,r=kF(e),i=jF(e),a=MF(e),o=NF(e);if(o){let e=vF(o);if(e.length>0)return e[0]??null}let s=PF(e),c=FF(e);if(s!=null||c!=null)return pF({path:n,beforeText:s,afterText:c,operation:r,oldStartLine:i,newStartLine:a});let l=$(e.preview);return l?fF({path:n,text:l,operation:r,oldStartLine:i,newStartLine:a}):null}function zF(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e==`string`){let n=vF(e);n.length>0&&t.push(...n);return}if(!CF(e))return;let r=RF(e,OF(e)??`file-${n+1}`);if(r){t.push(r);return}let i=Array.isArray(e.changes)?zF(e.changes):[];i.length>0&&t.push(...i)}),t}function BF(e){let t=EF(e.result)??EF(e.parsedArgs)??EF(e.args);return t?LF(zF(t.changes)):null}function VF(e){let t=EF(e.parsedArgs)??EF(e.args)??DF(e.args),n=t&&OF(t),r=$(e.result);return!n||!r?null:LF([fF({path:n,text:r,operation:`read`})].filter(e=>!!e))}function HF(e){if(e.status===`partial-call`&&typeof e.args==`string`){let t=SF(e.args,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`]),n=SF(e.args,[`content`,`text`,`afterText`,`after_text`]);if(t?.value&&n?.value){let e=fF({path:t.value,text:n.value,operation:`write`});if(e)return LF([e])}}let t=EF(e.parsedArgs)??EF(e.args)??DF(e.args);if(!t)return null;let n=OF(t),r=$(t.content);return!n||!r?null:LF([fF({path:n,text:r,operation:`write`})].filter(e=>!!e))}function UF(e){let t=EF(e.result),n=EF(e.parsedArgs)??EF(e.args)??DF(e.args);if(!t&&!n)return null;let r=(t?OF(t):null)??(n?OF(n):null),i=(t?PF(t):null)??(n?PF(n):null),a=(t?FF(t):null)??(n?FF(n):null),o=(t?jF(t):null)??(n?jF(n):null),s=(t?MF(t):null)??(n?MF(n):null);return!r||i==null&&a==null?null:LF([pF({path:r,beforeText:i,afterText:a,operation:`edit`,oldStartLine:o,newStartLine:s})].filter(e=>!!e))}function WF(e){let t=EF(e.parsedArgs),n=EF(e.args)??DF(e.args),r=$(e.args)??(t?$(t.patch):null)??(n?$(n.patch):null);return r?LF(vF(r)):null}function GF(e){return IF.has(e.toolName)?e.toolName===`file_change`?BF(e):e.toolName===`read_file`?VF(e):e.toolName===`write_file`?HF(e):e.toolName===`edit_file`?UF(e):e.toolName===`apply_patch`?WF(e):null:null}function KF(e){return typeof e==`object`&&!!e}function qF(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function JF(e){return!KF(e)||e.kind!==`nextclaw.session_request`?null:e}function YF(e){return!KF(e)||e.kind!==`nextclaw.session`?null:e}function XF(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function ZF(e){return yP(XF(e)).trim()||void 0}function QF(e,t){return[qF(e.title)?`title: ${e.title?.trim()}`:null,qF(e.sessionId)?`session: ${e.sessionId?.trim()}`:null,qF(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||xP(t)}function $F(e,t){return[qF(e.title)?`title: ${e.title?.trim()}`:null,qF(e.sessionId)?`session: ${e.sessionId?.trim()}`:null].filter(e=>!!e).join(` · `)||xP(t)}function eI(e){let t=qF(e.requestId),n=qF(e.sessionId),r=qF(e.title),i=qF(e.task),a=qF(e.status),o=qF(e.notify),s=qF(e.lifecycle),c=qF(e.parentSessionId),l=qF(e.spawnedByRequestId),u=e.message===void 0?``:yP(e.message).trim(),d=e.finalResponseText===void 0?``:yP(e.finalResponseText).trim(),f=e.error===void 0?``:yP(e.error).trim(),p=[t?`Request ID: ${t}`:null,n?`Session ID: ${n}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,a?`Status: ${a}`:null,o?`Notify: ${o}`:null,s?`Lifecycle: ${s}`:null,c?`Parent Session ID: ${c}`:null,l?`Spawned By Request ID: ${l}`:null,r?`Title: ${r}`:null,i?`Task:\n${i}`:null,d?`Final Response:\n${d}`:f?`Error:\n${f}`:u?`Status:\n${u}`:null].filter(e=>!!e);return p.length>0?p.join(`
94
+ `)}function tF(e){return typeof e==`number`?e+1:void 0}function nF(e){return{kind:e.kind,text:e.text,...typeof e.oldLineNumber==`number`?{oldLineNumber:e.oldLineNumber}:{},...typeof e.newLineNumber==`number`?{newLineNumber:e.newLineNumber}:{}}}function rF(e){let t=$P.exec(e);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function iF(e){return eF(e.text).map((t,n)=>e.kind===`add`?nF({kind:`add`,text:t,newLineNumber:e.newStartLine+n}):nF({kind:`context`,text:t,oldLineNumber:e.oldStartLine+n,newLineNumber:e.newStartLine+n}))}function aF(e){let t=e.oldStartLine,n=e.newStartLine;return[...e.beforeLines.map(e=>{let n=nF({kind:`remove`,text:e,oldLineNumber:t});return t=tF(t),n}),...e.afterLines.map(e=>{let t=nF({kind:`add`,text:e,newLineNumber:n});return n=tF(n),t})]}function oF(e){let t=Array.from({length:e.beforeLines.length+1},()=>Array.from({length:e.afterLines.length+1},()=>0));for(let n=e.beforeLines.length-1;n>=0;--n)for(let r=e.afterLines.length-1;r>=0;--r)t[n][r]=e.beforeLines[n]===e.afterLines[r]?(t[n+1][r+1]??0)+1:Math.max(t[n+1][r]??0,t[n][r+1]??0);return t}function sF(e){for(let t=e.beforeIndex;t<e.beforeLines.length;t+=1)e.lines.push(nF({kind:`remove`,text:e.beforeLines[t]??``,oldLineNumber:e.oldLineNumber})),e.oldLineNumber=tF(e.oldLineNumber);for(let t=e.afterIndex;t<e.afterLines.length;t+=1)e.lines.push(nF({kind:`add`,text:e.afterLines[t]??``,newLineNumber:e.newLineNumber})),e.newLineNumber=tF(e.newLineNumber)}function cF(e){let t=eF(e.beforeText),n=eF(e.afterText);if(t.length*n.length>QP)return aF({beforeLines:t,afterLines:n,oldStartLine:e.oldStartLine,newStartLine:e.newStartLine});let r=oF({beforeLines:t,afterLines:n}),i=[],a=0,o=0,s=e.oldStartLine,c=e.newStartLine;for(;a<t.length&&o<n.length;){if(t[a]===n[o]){i.push(nF({kind:`context`,text:t[a]??``,oldLineNumber:s,newLineNumber:c})),a+=1,o+=1,s=tF(s),c=tF(c);continue}if((r[a+1][o]??0)>=(r[a][o+1]??0)){i.push(nF({kind:`remove`,text:t[a]??``,oldLineNumber:s})),a+=1,s=tF(s);continue}i.push(nF({kind:`add`,text:n[o]??``,newLineNumber:c})),o+=1,c=tF(c)}return sF({lines:i,beforeLines:t,afterLines:n,beforeIndex:a,afterIndex:o,oldLineNumber:s,newLineNumber:c}),i}var lF=120;function uF(e){let t=e.lines.filter(e=>e.kind===`add`).length,n=e.lines.filter(e=>e.kind===`remove`).length,r=[],i=e.operation?.trim().toLowerCase()??``;return i&&i!==`update`&&r.push(i),t>0&&r.push(`+${t}`),n>0&&r.push(`-${n}`),r.length>0?r.join(` · `):void 0}function dF(e){let t=e.operation?.trim().toLowerCase()??``;return{oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:(t===`delete`||t===`remove`)&&e.beforeText!=null?1:void 0,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:(t===`write`||t===`add`)&&e.afterText!=null?1:void 0}}function fF(e){return e.length<=lF?{lines:e,truncated:!1}:{lines:e.slice(0,lF),truncated:!0}}function pF(e){let t=fF(e.lines);return{path:e.path,display:`diff`,caption:uF({operation:e.operation,lines:e.lines}),lines:t.lines,...t.truncated?{fullLines:e.lines}:{},truncated:t.truncated}}function mF(e){let t=e.text.trim();if(!t)return null;let n=e.operation?.trim().toLowerCase()===`write`?`add`:`context`,r=typeof e.oldStartLine==`number`?e.oldStartLine:1,i=typeof e.newStartLine==`number`?e.newStartLine:1,a=iF({text:t,kind:n,oldStartLine:r,newStartLine:i});return{path:e.path,display:`preview`,caption:uF({operation:e.operation,lines:a}),lines:a,rawText:t,oldStartLine:r,newStartLine:i}}function hF(e){let{oldStartLine:t,newStartLine:n}=dF(e),r=cF({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:t,newStartLine:n}),i=fF(r);return i.lines.length===0?null:{path:e.path,display:`diff`,caption:uF({operation:e.operation,lines:r}),lines:i.lines,...i.truncated?{fullLines:r}:{},...e.beforeText==null?{}:{beforeText:e.beforeText},...e.afterText==null?{}:{afterText:e.afterText},...typeof t==`number`?{oldStartLine:t}:{},...typeof n==`number`?{newStartLine:n}:{},truncated:i.truncated}}function gF(e){return e.line.startsWith(`*** Update File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`update`),!0):e.line.startsWith(`*** Add File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(14).trim(),`add`),!0):e.line.startsWith(`*** Delete File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`delete`),!0):!1}function _F(e){let{currentLines:t,line:n}=e;return n.startsWith(`+`)?(t.push(nF({kind:`add`,text:n.slice(1),newLineNumber:e.newLineNumber})),{oldLineNumber:e.oldLineNumber,newLineNumber:tF(e.newLineNumber)}):n.startsWith(`-`)?(t.push(nF({kind:`remove`,text:n.slice(1),oldLineNumber:e.oldLineNumber})),{oldLineNumber:tF(e.oldLineNumber),newLineNumber:e.newLineNumber}):n.startsWith(` `)?(t.push(nF({kind:`context`,text:n.slice(1),oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber})),{oldLineNumber:tF(e.oldLineNumber),newLineNumber:tF(e.newLineNumber)}):{oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber}}function vF(e){let t=[],n=null,r=null,i=[],a,o,s=()=>{if(!n){i=[],r=null,a=void 0,o=void 0;return}t.push(pF({path:n,operation:r,lines:i})),n=null,r=null,i=[],a=void 0,o=void 0};for(let t of eF(e)){if(gF({line:t,flushCurrent:s,setCurrent:(e,t)=>{n=e,r=t}})||t.startsWith(`*** Move to: `)||t.startsWith(`*** Begin Patch`)||t.startsWith(`*** End Patch`))continue;if(t.startsWith(`@@`)){let e=rF(t);a=e?.oldLineNumber,o=e?.newLineNumber;continue}if(!n)continue;let e=_F({currentLines:i,line:t,oldLineNumber:a,newLineNumber:o});a=e.oldLineNumber,o=e.newLineNumber}return s(),t}function yF(e){let t=[],n=null,r=[],i,a,o=()=>{if(!n){r=[],i=void 0,a=void 0;return}t.push(pF({path:n,operation:`update`,lines:r})),n=null,r=[],i=void 0,a=void 0};for(let t of eF(e)){if(t.startsWith(`+++ `)){o(),n=t.slice(4).trim().replace(/^b\//,``).replace(/^a\//,``);continue}if(t.startsWith(`--- `))continue;if(t.startsWith(`@@`)){let e=rF(t);i=e?.oldLineNumber,a=e?.newLineNumber;continue}if(!n)continue;let e=_F({currentLines:r,line:t,oldLineNumber:i,newLineNumber:a});i=e.oldLineNumber,a=e.newLineNumber}return o(),t}function bF(e){return e.includes(`*** Begin Patch`)?vF(e):e.includes(`--- `)&&e.includes(`+++ `)?yF(e):[]}function xF(e){switch(e){case`"`:case`\\`:case`/`:return e;case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
95
+ `;case`r`:return`\r`;case`t`:return` `;default:return e}}function SF(e,t){let n=`"${t}"`,r=e.indexOf(n);if(r<0)return null;let i=e.indexOf(`:`,r+n.length);if(i<0)return null;let a=i+1;for(;a<e.length&&/\s/.test(e[a]??``);)a+=1;return e[a]===`"`?a+1:null}function CF(e,t,n=1/0){let r=``,i=!1;for(let a=t;a<e.length;a+=1){let t=e[a];if(t==null)break;if(i){r+=xF(t),i=!1;continue}if(t===`\\`){i=!0;continue}if(t===`"`)return{value:r,truncated:!1};if(r+=t,r.length>=n)return{value:r,truncated:!0}}return r.length>0?{value:r,truncated:!1}:null}function wF(e,t,n=1/0){for(let r of t){let t=SF(e,r);if(t!=null)return CF(e,t,n)}return null}function TF(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function EF(e){return typeof e==`string`&&e.trim()?e.trim():null}function DF(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:typeof e==`string`&&/^\d+$/.test(e.trim())?Number(e.trim()):null}function OF(e){if(TF(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);return TF(e)?e:null}catch{return null}}function kF(e){if(TF(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;let n=wF(t,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`])?.value??null,r=wF(t,[`content`,`text`,`afterText`,`after_text`])?.value??null,i=wF(t,[`oldText`,`beforeText`,`before_text`])?.value??null,a=wF(t,[`newText`,`afterText`,`after_text`])?.value??null,o=wF(t,[`patch`,`diff`,`unifiedDiff`,`unified_diff`])?.value??null,s={};return n&&(s.path=n),r&&(s.content=r),i&&(s.oldText=i),a&&(s.newText=a),o&&(s.patch=o),Object.keys(s).length>0?s:null}function AF(e){return EF(e.path)??EF(e.filePath)??EF(e.file_path)??EF(e.targetPath)??EF(e.target_path)??EF(e.filename)??EF(e.name)}function jF(e){return $(e.operation)??$(e.op)??$(e.action)??$(e.kind)??$(e.type)??$(e.status)}function MF(e,t){for(let n of t){let t=DF(e[n]);if(t!==null)return t}return null}function NF(e){return MF(e,[`oldStartLine`,`old_start_line`,`startOldLine`,`start_old_line`,`oldLineStart`,`old_line_start`,`oldLineNumber`,`old_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function PF(e){return MF(e,[`newStartLine`,`new_start_line`,`startNewLine`,`start_new_line`,`newLineStart`,`new_line_start`,`newLineNumber`,`new_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function FF(e){return $(e.patch)??$(e.diff)??$(e.unifiedDiff)??$(e.unified_diff)}function IF(e){return $(e.beforeText)??$(e.before_text)??$(e.oldText)??$(e.old_text)??$(e.oldContent)??$(e.old_content)??$(e.before)??$(e.previous)}function LF(e){return $(e.afterText)??$(e.after_text)??$(e.newText)??$(e.new_text)??$(e.newContent)??$(e.new_content)??$(e.content)??$(e.text)??$(e.after)??$(e.updated)}var RF=new Set([`file_change`,`read_file`,`write_file`,`edit_file`,`apply_patch`]);function zF(e){let t=e.map((e,t)=>({key:`${e.path}-${t+1}`,path:e.path,display:e.display,...e.caption?{caption:e.caption}:{},lines:e.lines,...e.fullLines?{fullLines:e.fullLines}:{},...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},...e.truncated?{truncated:!0}:{}})).filter(e=>e.lines.length>0||!!e.rawText);if(t.length===0)return null;let n=t.map(e=>e.path);return{summary:n.length===1?n[0]:`${n.length} files · ${n.slice(0,2).join(` · `)}${n.length>2?` …`:``}`,fileOperation:{blocks:t}}}function BF(e,t){let n=AF(e)??t,r=jF(e),i=NF(e),a=PF(e),o=FF(e);if(o){let e=bF(o);if(e.length>0)return e[0]??null}let s=IF(e),c=LF(e);if(s!=null||c!=null)return hF({path:n,beforeText:s,afterText:c,operation:r,oldStartLine:i,newStartLine:a});let l=$(e.preview);return l?mF({path:n,text:l,operation:r,oldStartLine:i,newStartLine:a}):null}function VF(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e==`string`){let n=bF(e);n.length>0&&t.push(...n);return}if(!TF(e))return;let r=BF(e,AF(e)??`file-${n+1}`);if(r){t.push(r);return}let i=Array.isArray(e.changes)?VF(e.changes):[];i.length>0&&t.push(...i)}),t}function HF(e){let t=OF(e.result)??OF(e.parsedArgs)??OF(e.args);return t?zF(VF(t.changes)):null}function UF(e){let t=OF(e.parsedArgs)??OF(e.args)??kF(e.args),n=t&&AF(t),r=$(e.result);return!n||!r?null:zF([mF({path:n,text:r,operation:`read`})].filter(e=>!!e))}function WF(e){if(e.status===`partial-call`&&typeof e.args==`string`){let t=wF(e.args,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`]),n=wF(e.args,[`content`,`text`,`afterText`,`after_text`]);if(t?.value&&n?.value){let e=mF({path:t.value,text:n.value,operation:`write`});if(e)return zF([e])}}let t=OF(e.parsedArgs)??OF(e.args)??kF(e.args);if(!t)return null;let n=AF(t),r=$(t.content);return!n||!r?null:zF([mF({path:n,text:r,operation:`write`})].filter(e=>!!e))}function GF(e){let t=OF(e.result),n=OF(e.parsedArgs)??OF(e.args)??kF(e.args);if(!t&&!n)return null;let r=(t?AF(t):null)??(n?AF(n):null),i=(t?IF(t):null)??(n?IF(n):null),a=(t?LF(t):null)??(n?LF(n):null),o=(t?NF(t):null)??(n?NF(n):null),s=(t?PF(t):null)??(n?PF(n):null);return!r||i==null&&a==null?null:zF([hF({path:r,beforeText:i,afterText:a,operation:`edit`,oldStartLine:o,newStartLine:s})].filter(e=>!!e))}function KF(e){let t=OF(e.parsedArgs),n=OF(e.args)??kF(e.args),r=$(e.args)??(t?$(t.patch):null)??(n?$(n.patch):null);return r?zF(bF(r)):null}function qF(e){return RF.has(e.toolName)?e.toolName===`file_change`?HF(e):e.toolName===`read_file`?UF(e):e.toolName===`write_file`?WF(e):e.toolName===`edit_file`?GF(e):e.toolName===`apply_patch`?KF(e):null:null}function JF(e){return typeof e==`object`&&!!e}function YF(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function XF(e){return!JF(e)||e.kind!==`nextclaw.session_request`?null:e}function ZF(e){return!JF(e)||e.kind!==`nextclaw.session`?null:e}function QF(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function $F(e){return xP(QF(e)).trim()||void 0}function eI(e,t){return[YF(e.title)?`title: ${e.title?.trim()}`:null,YF(e.sessionId)?`session: ${e.sessionId?.trim()}`:null,YF(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||CP(t)}function tI(e,t){return[YF(e.title)?`title: ${e.title?.trim()}`:null,YF(e.sessionId)?`session: ${e.sessionId?.trim()}`:null].filter(e=>!!e).join(` · `)||CP(t)}function nI(e){let t=YF(e.requestId),n=YF(e.sessionId),r=YF(e.title),i=YF(e.task),a=YF(e.status),o=YF(e.notify),s=YF(e.lifecycle),c=YF(e.parentSessionId),l=YF(e.spawnedByRequestId),u=e.message===void 0?``:xP(e.message).trim(),d=e.finalResponseText===void 0?``:xP(e.finalResponseText).trim(),f=e.error===void 0?``:xP(e.error).trim(),p=[t?`Request ID: ${t}`:null,n?`Session ID: ${n}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,a?`Status: ${a}`:null,o?`Notify: ${o}`:null,s?`Lifecycle: ${s}`:null,c?`Parent Session ID: ${c}`:null,l?`Spawned By Request ID: ${l}`:null,r?`Title: ${r}`:null,i?`Task:\n${i}`:null,d?`Final Response:\n${d}`:f?`Error:\n${f}`:u?`Status:\n${u}`:null].filter(e=>!!e);return p.length>0?p.join(`
96
96
 
97
- `):void 0}function tI(e){let t=qF(e.sessionId),n=qF(e.title),r=qF(e.sessionType),i=qF(e.lifecycle),a=qF(e.parentSessionId),o=qF(e.createdAt),s=[t?`Session ID: ${t}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,n?`Title: ${n}`:null,r?`Session Type: ${r}`:null,i?`Lifecycle: ${i}`:null,a?`Parent Session ID: ${a}`:null,o?`Created At: ${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
97
+ `):void 0}function rI(e){let t=YF(e.sessionId),n=YF(e.title),r=YF(e.sessionType),i=YF(e.lifecycle),a=YF(e.parentSessionId),o=YF(e.createdAt),s=[t?`Session ID: ${t}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,n?`Title: ${n}`:null,r?`Session Type: ${r}`:null,i?`Lifecycle: ${i}`:null,a?`Parent Session ID: ${a}`:null,o?`Created At: ${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
98
98
 
99
- `):void 0}function nI(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=JF(o);if(s){let e=qF(s.status)?.toLowerCase(),t=QF(s,a),o=eI(s),c=qF(s.sessionId),l=YP({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...qF(s.title)?{label:s.title.trim()}:{},...qF(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:ZF(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:ZF(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:ZF(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=YF(o);if(!c)return null;let l=$F(c,a),u=tI(c),d=qF(c.sessionId),f=YP({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...qF(c.title)?{label:c.title.trim()}:{},...qF(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:ZF(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function rI(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e.error:null;return typeof t==`object`&&t&&!Array.isArray(t)&&t.code===`invalid_tool_arguments`?t:null}function iI(e,t){let n=FP(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function aI(e,t){let n=e.mimeType.startsWith(`image/`),r=RP(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function oI(e,t){let n=e.toolInvocation,r=BP(n.result,t);if(r)return r;let i=nI({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:VP(i,t)};let a=HP({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=rI(n.result),s=Array.isArray(o?.issues)?o.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,c=GF({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),l=s?`Invalid arguments: ${s}`:c?.summary??xP(n.parsedArgs??n.args),u=c?void 0:WP(n.args,n.parsedArgs),d=s||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:yP(n.result).trim()),f=!n.error&&zP(n.result),p=(!c?.fileOperation||!!n.error)&&!f,m=YP(n);return{type:`tool-card`,card:VP({kind:a.kind,name:n.toolName,...m?{agentId:m}:{},detail:l,...u?{input:u}:{},text:p&&d?d:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:o?`error`:a.statusTone,statusLabel:o?t.toolStatusFailedLabel:a.statusLabel,...c?.fileOperation?{fileOperation:c.fileOperation}:{}},t)}}function sI(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:yP(e)}}function cI(e){return e.type===`text`&&typeof e.text==`string`}function lI(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function uI(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function dI(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function fI(e){let{inlineTokens:t,part:n,texts:r}=e;return cI(n)?PP(n,t):lI(n)?iI(n,r):uI(n)?aI(n,r):dI(n)?oI(n,r):sI(n,r)}function pI(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function mI(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function hI(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function gI(e,t){return{id:e.id,role:hI(e.role),roleLabel:mI(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(pI(e)),status:e.meta?.status,parts:e.parts.map(n=>fI({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var _I=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function vI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function yI(e){return vI(e)}function bI(e){let t=vI(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function xI(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function SI(e){let t=xI(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function CI(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function wI(e){let t=SI(e.path),n=SI(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function TI(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function EI(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function DI(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?wI({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=bI(i)??i.trim();c=TI({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=CI(o);c=TI({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:EI({line:n,column:t}),truncated:a,segments:c}}var OI=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),kI=new Set([`running`,`completed`,`failed`,`idle`]);function AI(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function jI(e){return`${he}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function MI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function NI(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function PI(e){let t=NI(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=MI(n.timestamp);if(!kI.has(r)||!i)return null;let a=MI(n.statusText),o=MI(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function FI(e){let t=NI(e);return t?MI(t.preferred_model)??MI(t.preferredModel)??MI(t.model):null}function II(e){let t=NI(e);if(!t)return null;let n=MI(t.preferred_thinking)??MI(t.thinking)??MI(t.thinking_level)??MI(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return OI.has(r)?r:null}function LI(e){let t=NI(e);return t?MI(t.label):null}function RI(e){let t=NI(e);return t?yI(t.project_root??t.projectRoot):null}function zI(e){let t=NI(e);return t?MI(t.ui_last_read_at):null}function BI(e){let t=NI(e);return t?MI(t.runtime)??MI(t.session_type)??MI(t.sessionType)??`native`:`native`}function VI(e){let t=NI(e);return t?MI(t.parent_session_id)??MI(t.parentSessionId):null}function HI(e){let t=NI(e);return t?MI(t.spawned_by_request_id)??MI(t.spawnedByRequestId):null}function UI(e){let t=NI(e);return t?t.child_session_promoted===!0:!1}function WI(e){if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function GI(e){return e.state===`cancelled`?_I.CANCELLED:e.state===`result`?_I.RESULT:e.state===`partial-call`?_I.PARTIAL_CALL:_I.CALL}function KI(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:jI(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:GI(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:AI(n.args),result:n.result}})}return t}function qI(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function JI(e){return{id:e.id,role:qI(e.role),parts:KI(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function YI(e){let t=LI(e),n=FI(e),r=II(e),i=RI(e),a=zI(e),o=MI(e.lastMessageAt),s=bI(i),c=WI(e.sessionId),l=VI(e),u=HI(e),d=UI(e),f=PI(e);return{key:e.sessionId,createdAt:e.createdAt??e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:BI(e),sessionTypeMutable:!1,status:e.status??`idle`,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},...f?{activityPreview:f}:{},messageCount:e.messageCount}}function XI(e){return e.map(YI)}function ZI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function QI(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function $I(e){return e===!0}function eL(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=QI(n.usedContextTokens),i=QI(n.totalContextTokens),a=QI(n.prunedUsedContextTokens),o=ZI(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=QI(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:QI(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:QI(n.droppedHistoryCount)??0,truncatedToolResultCount:QI(n.truncatedToolResultCount)??0,truncatedSystemPrompt:$I(n.truncatedSystemPrompt),truncatedUserMessage:$I(n.truncatedUserMessage),compacted:$I(n.compacted),...ZI(n.checkpointId)?{checkpointId:ZI(n.checkpointId)??void 0}:{},compactedMessageCount:QI(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function tL(e){let{metadata:t}=e;if(!t||t.nextclaw_timeline_kind!==`context_compaction`)return null;let n=t.checkpoint&&typeof t.checkpoint==`object`&&!Array.isArray(t.checkpoint)?t.checkpoint:null;if(!n)return null;let r=ZI(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=ZI(n.summary),o=QI(n.coveredMessageCount),s=QI(n.coveredSessionMessageCount),c=QI(n.originalEstimatedTokens),l=QI(n.projectedEstimatedTokens),u=ZI(n.createdAt),d=ZI(n.updatedAt);return!r||!i||!a||o===null||s===null||c===null||l===null||!u||!d?null:{id:r,status:i,summary:a,coveredMessageCount:o,coveredSessionMessageCount:s,originalEstimatedTokens:c,projectedEstimatedTokens:l,createdAt:u,updatedAt:d}}function nL(){return Ve({queryKey:[`agents`],queryFn:ut,staleTime:3e4})}function rL(){let e=Fe();return me({mutationFn:({agentId:e,data:t})=>pt(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function iL(){let e=Fe();return me({mutationFn:({agentId:e})=>Je(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function aL(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function oL(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=nL(),i=(0,F.useMemo)(()=>aL(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,F.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function sL({agentId:e,className:t}){let n=oL(e);return n?(0,I.jsx)(Vs,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var cL=new WeakMap;function lL(e){return{roleLabels:{user:s(`chatRoleUser`),assistant:s(`chatRoleAssistant`),tool:s(`chatRoleTool`),system:s(`chatRoleSystem`),fallback:s(`chatRoleMessage`)},reasoningLabel:s(`chatReasoning`),toolCallLabel:s(`chatToolCall`),toolResultLabel:s(`chatToolResult`),toolInputLabel:s(`chatToolInput`),toolNoOutputLabel:s(`chatToolNoOutput`),toolOutputLabel:s(`chatToolOutput`),toolStatusPreparingLabel:s(`chatToolStatusPreparing`),toolStatusRunningLabel:s(`chatToolStatusRunning`),toolStatusCompletedLabel:s(`chatToolStatusCompleted`),toolStatusFailedLabel:s(`chatToolStatusFailed`),toolStatusCancelledLabel:s(`chatToolStatusCancelled`),imageAttachmentLabel:s(`chatImageAttachment`),fileAttachmentLabel:s(`chatFileAttachment`),unknownPartLabel:s(`chatUnknownPart`)}}function uL(e){return{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`),copyMessageLabel:s(`chatMessageCopy`),copiedMessageLabel:s(`chatMessageCopied`),typingLabel:s(`chatTyping`),attachmentOpenLabel:s(`chatAttachmentOpen`),attachmentAttachedLabel:s(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:s(`chatAttachmentCategoryArchive`),audio:s(`chatAttachmentCategoryAudio`),code:s(`chatAttachmentCategoryCode`),data:s(`chatAttachmentCategoryData`),document:s(`chatAttachmentCategoryDocument`),generic:s(`chatAttachmentCategoryGeneric`),image:s(`chatAttachmentCategoryImage`),pdf:s(`chatAttachmentCategoryPdf`),sheet:s(`chatAttachmentCategorySheet`),video:s(`chatAttachmentCategoryVideo`)}}}function dL({checkpoint:e}){return(0,I.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-gray-500`,title:[`${s(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${s(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${s(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
100
- `),children:[(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`}),(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-gray-200 bg-gray-50 px-3 py-1`,children:[e.status===`compressing`?(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}):(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-300`}),(0,I.jsx)(`span`,{children:e.status===`compressing`?s(`chatContextCompactionCompressing`):s(`chatContextCompactionCompressed`)})]}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`})]})}function fL(e){let{normalRawMessages:t,rawMessageId:n,rawMessages:r}=e,i=r.findIndex(e=>e.id===n);return i<0?t.length-1:r.slice(0,i).filter(e=>!tL(e)).length-1}function pL(e){let t=e.rawMessages.filter(e=>!tL(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:tL(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:fL({rawMessages:e.rawMessages,normalRawMessages:t,rawMessageId:n.rawMessageId})})).sort((e,t)=>e.boundaryIndex-t.boundaryIndex),r=[],i=[],a=0,o=e=>{i.length!==0&&(r.push({kind:`messages`,key:e,messages:i}),i=[])};for(t.forEach((t,s)=>{let c=e.messages[s];for(c&&i.push(c);a<n.length&&n[a]?.boundaryIndex<=s;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}});a<n.length;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}return o(`messages-final`),r.length===0&&r.push({kind:`messages`,key:`messages-empty`,messages:[]}),r}function mL({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=kr(),o=(0,F.useMemo)(()=>lL(a),[a]),s=(0,F.useMemo)(()=>e.flatMap(e=>{if(tL(e))return[];let t=cL.get(e);if(t&&t.language===a)return[t.viewModel];let n=JI(e),r=gI({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:OP(e.metadata)},parts:n.parts},{formatTimestamp:e=>u(e,a),texts:o});return cL.set(e,{language:a,viewModel:r}),[r]}),[a,e,o]),c=(0,F.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),l=(0,F.useMemo)(()=>uL(a),[a]),d=(0,F.useMemo)(()=>pL({rawMessages:e,messages:s}),[s,e]);return(0,I.jsx)(`div`,{className:n,children:d.map((e,n)=>e.kind===`compaction`?(0,I.jsx)(dL,{checkpoint:e.checkpoint},e.key):(0,I.jsx)(SM,{messages:e.messages,isSending:n===d.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,I.jsx)(sL,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function hL(){let e=Fe();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{dt(e,await gt(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),N.success(i??s(`configSavedApplied`))}catch(e){throw N.error(s(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function gL(){let e=hL();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=s(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),N.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function _L({icon:e,label:t,onClick:n,disabled:i=!1,destructive:a=!1}){return(0,I.jsxs)(`button`,{type:`button`,className:r(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:i,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:t})]})}function vL(e){return Ve({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>mt({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var yL=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsx)(`div`,{ref:i,className:r(`overflow-auto`,e),...n,children:t}));yL.displayName=`ScrollArea`;function bL({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:d}){let[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(``);(0,F.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),h(n),_(``)},[t,e]);let v=vL({path:m,enabled:e});(0,F.useEffect)(()=>{!e||!v.data||f.trim().length===0&&p(v.data.currentPath)},[v.data,f,e]);let y=f.trim(),b=y.length===0||n,x=(0,F.useMemo)(()=>v.error?v.error instanceof Error?v.error.message:String(v.error):null,[v.error]),S=g.trim().toLowerCase(),C=(0,F.useMemo)(()=>{let e=v.data?.entries??[];return S.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(S)||n.includes(S)})},[v.data?.entries,S]),w=e=>{h(e),_(``),e&&p(e)};return(0,I.jsx)(Gt,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(qt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(Kt,{children:[(0,I.jsx)(Jt,{children:a}),o?(0,I.jsx)(Wt,{children:o}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!b&&i(y)},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Ae,{htmlFor:`server-path-picker-input`,children:c}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(Ne,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,I.jsx)(ye,{type:`button`,variant:`outline`,onClick:()=>w(y||null),disabled:n,children:s(`openPath`)})]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,I.jsx)(sr,{className:`mr-1 h-4 w-4`}),s(`homeDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,I.jsx)(nr,{className:`mr-1 h-4 w-4`}),s(`parentDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,I.jsx)(k,{className:`mr-1 h-4 w-4`}),s(`chatRefresh`)]})]}),(0,I.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:s(`currentDirectory`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:v.data?.breadcrumbs.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>w(e.path),disabled:n,children:e.label}),t<v.data.breadcrumbs.length-1?(0,I.jsx)(Rn,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{value:g,onChange:e=>_(e.target.value),placeholder:s(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,I.jsx)(yL,{className:`min-h-0 flex-1 px-2 py-2`,children:v.isLoading?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`loading`)}):x?(0,I.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[s(`pathBrowseFailed`),`: `,x]}):v.data&&C.length>0?(0,I.jsx)(`div`,{className:`space-y-1`,children:C.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>w(e.path),disabled:n,children:[(0,I.jsx)(ir,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):v.data&&v.data.entries.length>0?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`pathPickerSearchEmpty`)}):(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`emptyDirectory`)})})]}),d?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,I.jsxs)(Ut,{children:[(0,I.jsx)(ye,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:s(`cancel`)}),(0,I.jsx)(ye,{type:`submit`,disabled:b,children:n?s(`saving`):u})]})]})]})})}function xL({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(bL,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:s(`chatSessionProjectDialogTitle`),description:s(`chatSessionProjectDialogDescription`),pathLabel:s(`chatSessionProjectPathLabel`),pathPlaceholder:s(`chatSessionProjectPathPlaceholder`),confirmLabel:s(`chatSessionSetProject`),hint:s(`chatSessionProjectUpdateHint`)})}var SL=`flex shrink-0 items-center gap-1.5`,CL=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function wL({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:c,onDeleteSession:l}){let u=gL(),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(!1),_=n||h,v=async n=>{let r=t;g(!0);try{await u({sessionKey:e,projectRoot:n,persistToServer:r}),m(!1),f(!1)}finally{g(!1)}};return(0,I.jsxs)(`div`,{className:SL,children:[i>0&&o?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:CL,"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,I.jsx)(ar,{className:`h-4 w-4`})}):null,a>0&&c?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:CL,"aria-label":s(`chatSessionOpenCronJobs`),title:s(`chatSessionOpenCronJobs`),onClick:c,disabled:_,children:(0,I.jsx)(jn,{className:`h-4 w-4`})}):null,(0,I.jsxs)(wn,{open:d,onOpenChange:f,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:CL,"aria-label":s(`chatSessionMoreActions`),disabled:_,children:(0,I.jsx)(b,{className:`h-4 w-4`})})}),(0,I.jsx)(bn,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(_L,{icon:er,label:s(`chatSessionSetProject`),onClick:()=>{f(!1),m(!0)},disabled:_}),(0,I.jsx)(_L,{icon:hn,label:s(`chatDeleteSession`),onClick:()=>{f(!1),l()},disabled:!t||_,destructive:!0})]})})]}),(0,I.jsx)(xL,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function TL({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=gL(),[a,o]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),o(!1)}finally{d(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":s(`chatSessionSetProject`),disabled:u,children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(er,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(Ln,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(bn,{align:`start`,className:`w-72 p-2`,children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,I.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(_L,{icon:hr,label:s(`chatSessionSetProject`),onClick:()=>{o(!1),l(!0)},disabled:u}),(0,I.jsx)(_L,{icon:rr,label:s(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,I.jsx)(xL,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function EL({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,I.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsxs)(`span`,{children:[s(`chatBackToParent`),n?` · ${n}`:``]})]})})}function DL({snapshot:e,childSessionCount:t,sessionCronJobCount:n,layoutMode:i,normalizedAgentId:a,sessionHeaderTitle:o,shouldShowHeaderAgentAvatar:c,shouldShowSessionHeader:l,onBackToList:u,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}){let m=i===`mobile`;return(0,I.jsxs)(`div`,{className:r(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-colors duration-200`,m?`px-3 sm:px-3`:`px-4 sm:px-5`,l?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,l&&(m?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:m&&l?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[m&&u?(0,I.jsx)(`button`,{type:`button`,onClick:u,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chat`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,c?(0,I.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(Vs,{agentId:a,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:o}),e.sessionTypeLabel?(0,I.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,I.jsx)(Ps,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,I.jsx)(TL,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,I.jsx)(wL,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}):null]})}var OL=`native`;function kL(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:OL}function AL(e,t=OL){return kL(e?.runtime?.trim()||e?.engine?.trim()||t)}function jL(e,t){return e===`native`?s(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function ML(e){let t=new Map;for(let n of e){let e=kL(n.value);t.set(e,{value:e,label:n.label?.trim()||jL(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(OL,{value:OL,label:jL(OL),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function NL(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,F.useMemo)(()=>ML(i?.options??[]),[i?.options]),o=(0,F.useMemo)(()=>{let e=[...a],n=kL(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:jL(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),c=(0,F.useMemo)(()=>kL(i?.defaultType??`native`),[i?.defaultType]),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>kL(t?.sessionType??n??c),[c,n,t?.sessionType]),d=(0,F.useMemo)(()=>o.find(e=>e.value===u)??null,[u,o]);(0,F.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=kL(n);(e.length===0||l.current===i||l.current===null&&i===`native`)&&(l.current=c,i!==c&&r(c))},[c,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,F.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:o,selectedSessionTypeOption:d,defaultSessionType:c,selectedSessionType:u,canEditSessionType:f,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!p.has(kL(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!p.has(kL(t.sessionType))?`${jL(u)} ${s(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}function PL(e,t){return e.label?.trim()?e.label.trim():t?Us(t):e.sessionKey}function FL(e){let t=Ci({limit:200}),n=(0,F.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,F.useMemo)(()=>{let e=XI(n);return new Map(e.map(e=>[e.key,e]))},[n]);return(0,F.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:PL(e,t),agentId:n,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:t?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?jL(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function IL(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
101
- `)}}async function*LL(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=RL(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=RL(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function RL(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=IL(e);t&&i.push(t)}if(t&&r.trim()){let e=IL(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var zL=`/ncp/agent`,BL=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function VL(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function HL(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function UL(e){let t=(e??`/ncp/agent`).trim();if(!t)return zL;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function WL(e){try{return(await e.text()).trim()}catch{return``}}function GL(e){if(YL(e))return e.ncpError;if(qL(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:ZL(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function KL(e,t={}){return new BL(e,t.alreadyPublished??!1)}function qL(e){return JL(e)&&typeof e.code==`string`&&typeof e.message==`string`}function JL(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function YL(e){return e instanceof BL}var XL={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function ZL(e){if(!e)return`runtime-error`;let t=XL[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function QL(e){let t=eR(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function $L(e){let t=eR(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=ZL(n),i=JL(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function eR(e){try{let t=JSON.parse(e);return JL(t)?t:null}catch{return null}}var tR=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],nR=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=VL(e.baseUrl),this.basePath=UL(e.basePath),this.fetchImpl=HL(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:tR,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:CM.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await WL(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(YL(e))throw e;let n=GL(e);throw this.publish({type:CM.EndpointError,payload:n}),KL(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await WL(n)}`)}catch(e){if(t.signal.aborted)return;let n=GL(e);throw this.publish({type:CM.EndpointError,payload:n}),KL(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await WL(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of LL(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(YL(e))throw e;let n=GL(e);throw this.publish({type:CM.EndpointError,payload:n}),KL(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=QL(e.data);if(!t){this.publish({type:CM.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=$L(e.data);throw this.publish({type:CM.EndpointError,payload:t}),KL(t,{alreadyPublished:!0})}}};function rR(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function iR(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function aR(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function oR(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw vt.reportTransportFailure(iR(n)),aR(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${rR(e)}: ${iR(n)}`,n)}}}var sR=300,cR=`ncp agent unavailable during startup`;function lR(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function uR(e){return e?.trim().toLowerCase().includes(cR)??!1}function dR(){return new nR({baseUrl:he,basePath:`/api/ncp/agent`,fetchImpl:oR()})}async function fR(e,t,n=sR){t.throwIfAborted();try{let r=await it(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!lR(e))throw e;return{messages:[],status:`idle`}}}function pR(e,t){let n=(0,F.useRef)(null),r=(0,F.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,F.useEffect)(()=>{r(e)},[e,r])}function mR(e,t={}){let[n]=(0,F.useState)(()=>dR()),r=bt(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??sR;(0,F.useEffect)(()=>{s(null)},[e]);let l=tN({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await fR(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return pR(e&&r.phase===`ready`&&uR(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}function hR(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function gR(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function _R({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(jn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Kn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(sL,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(ur,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function vR({tab:e}){return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{asChild:!0,children:(0,I.jsxs)(`div`,{className:r(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,I.jsx)(_R,{kind:e.kind,agentId:e.agentId}),(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,I.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:s(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]}),e.onClose?(0,I.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:r(`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,e.active?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":s(`chatWorkspaceCloseFile`),children:(0,I.jsx)(gn,{className:`h-3 w-3`})}):null]})}),(0,I.jsx)(an,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})})}function yR({tabs:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-bar`,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/70 bg-gray-50/85`,children:(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:e.map(e=>(0,I.jsx)(vR,{tab:e},e.key))})})}function bR({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:r(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function xR({breadcrumb:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,I.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(`span`,{className:r(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,I.jsx)(tr,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Kn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Rn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,I.jsx)(bR,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(bR,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function SR(e){let t=e.path?.trim()??``;return Ve({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>lt({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function CR(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function wR(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:nF({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function TR(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=oF({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function ER({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:r(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function DR({diffBlock:e}){return e?(0,I.jsx)(OR,{block:e}):(0,I.jsx)(ER,{text:s(`chatWorkspaceDiffEmpty`)})}function OR({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(Lj,{block:e,layout:`workspace`})})}function kR({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(ER,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(ER,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(ER,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,I.jsx)(DA,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(OR,{block:t}):(0,I.jsx)(ER,{text:s(`chatWorkspacePreviewEmpty`)})}function AR({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=SR({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?TR(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=CR({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:wR({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsx)(xR,{breadcrumb:(0,F.useMemo)(()=>DI({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,I.jsx)(DR,{diffBlock:a}):(0,I.jsx)(kR,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var jR={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function MR(){let[e,t]=(0,F.useState)(jR),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??s(`confirm`),cancelLabel:e.cancelLabel??s(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,F.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,F.useCallback)(()=>(0,I.jsx)(Yt,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function NR(e){return u(e??void 0)}function PR(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function FR(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function IR(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${FR(t.everyMs)}`:t.kind===`at`?`at ${PR(t.atMs)}`:`-`}function LR(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function RR(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function zR({jobs:e}){let t=Ei(),{confirm:n,ConfirmDialog:r}=MR(),i=async e=>{await n({title:`${s(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:s(`delete`)})&&t.mutate({id:e.id})};return(0,I.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:s(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[s(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:s(`chatWorkspaceCronJobEmpty`)}):(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,I.jsxs)(ye,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,I.jsx)(hn,{className:`h-3.5 w-3.5`}),s(`delete`)]})]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronScheduleLabel`),`:`]}),` `,IR(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,NR(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,NR(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronSessionLabel`),`:`]}),` `,LR(e)]})]}),(0,I.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,I.jsx)(r,{})]})}function BR({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=mR(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=fj({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,I.jsx)($t,{className:`mr-2 h-4 w-4 animate-spin`}),s(`chatChildSessionLoading`)]}):r.hydrateError?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:s(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(mL,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function VR({value:e}){return(0,I.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,I.jsx)(`span`,{className:`truncate`,children:e})})}function HR({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,I.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,I.jsx)(VR,{value:e},e))}):null,e.projectRoot?(0,I.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function UR({tab:e}){return(0,I.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,I.jsx)(sL,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)($n,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(HR,{tab:e})]})}function WR(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:c,onCloseFile:l,onSelectCronJobs:u}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:JN({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:hR(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>c(e.key),onClose:()=>l(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:s(`chatWorkspaceSessionCronJobs`),tooltip:s(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:u}]:[];return[...d,...f,...p]}function GR({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:c=[],sessionProjectRoot:l,displayMode:u=`docked`}){let d=ic(),f=FL(t),p=QN(e=>e.optimisticReadAtBySessionKey),m=gR({activeChildSessionKey:n,activeWorkspaceFileKey:a,activePanelKind:o,childSessionTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length}),h=f.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(m?.kind!==`child-session`||m.tab.runStatus===`running`)return;let e=m.tab.lastMessageAt?.trim()??null;e&&d.chatSessionListManager.markSessionRead(m.tab.sessionKey,e,m.tab.readAt??null)},[m,d]);let g=(0,F.useMemo)(()=>WR({resolvedChildTabs:f,workspaceFileTabs:i,sessionCronJobCount:c.length,activeSelection:m,optimisticReadAtBySessionKey:p,onSelectSession:d.chatThreadManager.selectChildSessionDetail,onSelectFile:d.chatThreadManager.selectWorkspaceFile,onCloseFile:d.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&d.chatThreadManager.openSessionCronPanel(e)}}),[m,p,d.chatThreadManager,f,e,i,c.length]);return m?(0,I.jsxs)(Zt,{className:r(u===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:u===`overlay`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-4 py-2.5`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:d.chatThreadManager.goToParentSession,className:r(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!h&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:s(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:d.chatThreadManager.closeWorkspacePanel,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chatWorkspaceClosePanel`),children:(0,I.jsx)(gn,{className:`h-4 w-4`})})]}),(0,I.jsx)(yR,{tabs:g}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:m.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(UR,{tab:m.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(BR,{sessionKey:m.tab.sessionKey,onToolAction:d.chatThreadManager.openSessionFromToolAction,onFileOpen:d.chatThreadManager.openFilePreview})})]}):m.kind===`file`?(0,I.jsx)(AR,{file:m.file,sessionProjectRoot:l,onFileOpen:d.chatThreadManager.openFilePreview}):(0,I.jsx)(zR,{jobs:c})})]}):null}function KR({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var qR=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function JR(){return(0,I.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,I.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(KR,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:qR.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)(KR,{"data-testid":`chat-conversation-skeleton-bubble`,className:r(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,I.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(KR,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)(KR,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,I.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,I.jsx)(KR,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(KR,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(KR,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)(KR,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)(KR,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)(KR,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function YR(){let e=ic(),t=Q(e=>e.snapshot);return(0,I.jsxs)(I.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,I.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:s(`chatModelNoOptions`)}),(0,I.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:s(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,I.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function XR(){let e=ic(),t=Z(e=>e.snapshot.defaultSessionType),n=Q(e=>e.snapshot),r=(0,F.useRef)(null),i=n.threadRef??r,a=n.availableAgents??[],o=!n.canDeleteSession&&!n.hasSubmittedDraftMessage&&n.messages.length===0&&!n.isSending,s=n.isHistoryLoading&&n.messages.length===0&&!n.isSending&&!n.isAwaitingAssistantOutput,c=e=>a.find(t=>t.id===e)??null,l=()=>{let r=AL(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(AL(c(n),t))},{onScroll:d}=fj({scrollRef:i,resetKey:n.sessionKey,isLoading:n.isHistoryLoading,hasContent:n.messages.length>0,contentVersion:n.messages[n.messages.length-1]??null}),f=n.messages.length>0,p=f&&n.isSending&&n.isAwaitingAssistantOutput;return(0,I.jsx)(`div`,{ref:i,onScroll:d,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:o?(0,I.jsx)(tc,{onCreateSession:l,agents:a,selectedAgentId:n.agentId??`main`,onSelectAgent:u}):s||!f?null:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,I.jsx)(mL,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function ZR(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function QR(e){let t=(0,F.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,F.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=Ti({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>RR(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:ZR(e,t,n,i.length)}}function $R(){let e=ic(),t=Q(e=>e.snapshot);return(0,I.jsx)(EL,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function ez({layoutMode:e,onBackToList:t}){let n=ic(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=QR(r),o=!!(r.sessionKey||r.sessionTypeLabel),c=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||s(`chatSidebarNewTask`),l=r.agentId?.trim()??``,u=l.length>0&&l.toLowerCase()!==`main`;return(0,I.jsx)(DL,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:l,sessionHeaderTitle:c,shouldShowHeaderAgentAvatar:u,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function tz({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=QR(t);return a?(0,I.jsx)(GR,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function nz({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsx)($R,{}),(0,I.jsx)(ez,{layoutMode:e,onBackToList:t}),(0,I.jsx)(YR,{}),(0,I.jsx)(XR,{}),(0,I.jsx)(mP,{})]}),(0,I.jsx)(tz,{layoutMode:e})]}):(0,I.jsx)(JR,{})}var rz={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function iz({status:e,className:t}){let n=rz[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":i,className:r(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)($t,{className:r(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:r(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(an,{side:`bottom`,className:`text-xs`,children:i})]})})}function az(){let e=hL();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function oz(){let e=az(),[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function sz(e,t){return e.filter(e=>Xs(e,t))}function cz(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function lz(e={}){let t=QN(e=>e.snapshot.query),n=Ci({limit:e.limit??200}),r=(0,F.useMemo)(()=>sz(XI(n.data?.sessions??[]).filter(cz),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function uz(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,I.jsx)($s,{session:g,active:y,showUnreadDot:JN({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:ks(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function dz(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function fz(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(ye,{variant:`primary`,className:r(`min-w-0 rounded-xl`,i.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{o(!1),c(n)},children:[(0,I.jsx)(pn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,I.jsx)(Is,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function pz(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=dz({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=u.length>1;return(0,I.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,I.jsx)(mn,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),children:(0,I.jsx)(pn,{className:`h-4 w-4`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:s(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,I.jsx)(Is,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,I.jsx)(pn,{className:`h-4 w-4`})})]})})}function mz({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:c,languageOptions:l,onSelectLanguage:u,onOpenDocs:d,onOpenApps:f}){let p=()=>{d(),t(!1)},m=()=>{f(),t(!1)};return(0,I.jsxs)(wn,{open:e,onOpenChange:t,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,I.jsx)(_r,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:s(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,c]})]})}),(0,I.jsxs)(bn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(w,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(_r,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`settings`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(Qt,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`docBrowserHelp`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:m,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(un,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`appsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(hz,{icon:pr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(hz,{icon:cr,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function hz({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(vo,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(bo,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,I.jsx)(Rn,{className:`h-4 w-4 text-gray-400`}),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`text-left`,children:t})]}),(0,I.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,I.jsx)(Co,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function gz(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function _z(e){return[...e].sort((e,t)=>gz(t)-gz(e))}function vz(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],c=[],l=[];for(let t of e){let e=gz(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:s(`chatSidebarToday`),items:a}),o.length>0&&u.push({label:s(`chatSidebarYesterday`),items:o}),c.length>0&&u.push({label:s(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:s(`chatSidebarOlder`),items:l}),u}function yz(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=gz(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||bI(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:_z(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function bz(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>gz(t)-gz(e));return t}function xz(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var Sz=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:jn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:E},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:Pn}];function Cz(e,t,n){let r=QN(e=>e.optimisticReadAtBySessionKey);return(0,F.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r||r.runStatus===`running`)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function wz({variant:e=`desktop`}){let n=e===`mobile`,i=ic(),a=Dn(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=QN(e=>e.snapshot),p=bt(),m=nL(),{isLoading:h,items:g}=lz(),{language:_,setLanguage:v}=kr(),{theme:y,setTheme:b}=es(),x=s(qr.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>qr.map(e=>({value:e.value,label:s(e.labelKey)})),[]),w=(0,F.useMemo)(()=>t.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),E=(0,F.useMemo)(()=>_z(g),[g]),D=(0,F.useMemo)(()=>bz(g),[g]),O=(0,F.useMemo)(()=>vz(E),[E]),k=(0,F.useMemo)(()=>yz(E),[E]),A=d.defaultSessionType||`native`,ee=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==A),[A,d.sessionTypeOptions]),j=f.listMode===`project-first`,te=Cz(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:ne,savingSessionKey:re,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:se,saveSessionLabel:ce}=oz(),le=e=>{_!==e&&(v(e),window.location.reload())},ue=e=>(0,I.jsx)(uz,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:te,agentsById:T,childSessionsByParentKey:D,editingSessionKey:M,draftLabel:ne,savingSessionKey:re,sessionTitle:xz,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:ce,onCancelEditingSessionLabel:se},e.session.key),de=(e,t)=>{i.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:r(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!n&&!ls()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(ji,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(iz,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(pz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(fz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}),n?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:Sz.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(ko,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,I.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:s(`chatSidebarTaskRecords`)}),(0,I.jsx)(_s,{isProjectFirstView:j,onSelectMode:i.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:s(`sessionsLoading`)}):j?k.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(ur,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(Rs,{groups:k,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:ue,onCreateSession:de}):O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(ur,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:O.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(ue)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(mz,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:le,onOpenDocs:()=>a.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),onOpenApps:()=>oe(a)})})]})}function Tz(){return Ve({queryKey:[`ncp-session-types`],queryFn:Be,staleTime:1e4,retry:!1})}function Ez(e){let t=e.trim();return t.length>0?t:null}function Dz(e){return e??null}var Oz=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=QN.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:Ez(e.selectedModel),preferredThinking:Dz(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},kz=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new Oz(gt),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>rP(vt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=MN(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:DN(e),selectedSkills:ON(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:DN(e),selectedSkills:ON(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(EN(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=jN(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=jN(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=QN.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=NN(e.composerNodes,i);if(HN({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(TN()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=kL(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(AN(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),IN.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{LN.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},Az=`sid_`,jz=`/chat/draft`,Mz=jz.slice(6);function Nz(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Az}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Pz(e){if(!e.startsWith(Az))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Fz(e){if(!e||e===Mz)return null;let t=Pz(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Iz(e){return`/chat/${Nz(e)}`}var Lz=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=QN.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=QN.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&QN.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=QN.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&QN.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=QN.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&QN.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(QN.getState().markSessionRead(r,i),gt(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=yI(t);this.streamActionsManager.resetStreamState(),QN.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(jz)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=QN.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=QN.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&QN.getState().setSnapshot({query:n})}}},Rz=async()=>{},zz=()=>{},Bz=class{constructor(){this.actions={sendMessage:Rz,stopCurrentRun:Rz,resumeRun:Rz,resetStreamState:zz,applyHistoryMessages:zz},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},Vz=async e=>!1,Hz=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:Vz},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`||this.state.pathname===`/chat/draft`,this.goToSession=(e,t)=>{this.navigateTo(Iz(e),t)}}},Uz=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{QN.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(QN.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=QN.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||QN.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>Nr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=QN.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await ct(e),et(De,e),De.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},Wz=class{constructor(){this.chatUiManager=new Hz,this.chatStreamActionsManager=new Bz,this.chatSessionListManager=new Lz(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new kz(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new Uz(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function Gz(e){return e?.trim().toLowerCase()||`native`}function Kz(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function qz(e,t){return typeof t==`string`&&e.includes(t)}function Jz(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function Yz(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function Xz(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:Yz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>Kz(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function Zz(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:Yz({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>qz(t,e),firstAvailableValue:Jz(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function Qz(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=Gz(r),o,s=-1/0;for(let e of t){if(e.key===n||Gz(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function $z(e){return e.map(e=>e==null?``:String(e)).join(``)}function eB(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,F.useRef)(void 0),l=(0,F.useRef)(s),u=(0,F.useRef)(n);(0,F.useEffect)(()=>{l.current=s},[s]),(0,F.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function tB(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;eB({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:$z([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>Xz({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function nB(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;eB({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:$z([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>Zz({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function rB(){let{pathname:e}=S(),t=C();return Br(e)?(0,I.jsx)(nz,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(wz,{variant:`mobile`})}var iB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-yi02ASOL.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function aB({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserDockControls:a,docBrowserRenderers:o={},sideDock:s,children:c}){let l=zr(e),u=t&&!Br(e),d=ls();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,d?`rounded-[10px]`:null),style:d?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":l?`280px`:`240px`}:void 0,children:[d?(0,I.jsx)(as,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!l&&(0,I.jsx)(rs,{mode:`settings`}),(0,I.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,I.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:l?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:c}):(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:c})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(iB,{customTabRenderers:o,dockControls:a})}):null,s]})]}),u?(0,I.jsx)(fs,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(iB,{customTabRenderers:o,dockControls:a})}):null]})}var oB=`NextClaw`,sB=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function cB(e,t){return e===t||e.startsWith(`${t}/`)}function lB(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of sB)if(cB(t,e))return s(n);return s(`settings`)}function uB(e){return`${oB} - ${lB(e)}`}function dB({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=Dn();Er();let{pathname:i}=S(),{language:a}=kr(),{isMobile:o}=Pr(),s=cs();A(e=>e.pinnedItems);let c={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,F.useEffect)(()=>{document.title=uB(i)},[i,a]),o&&s!==`win32`?(0,I.jsx)(hs,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:c,docBrowserRenderers:ie,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(aB,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:c,docBrowserRenderers:ie,sideDock:(0,I.jsx)(j,{manager:t}),children:e})}function fB({children:e}){let t=ae();return(0,I.jsx)(kn,{manager:t.docBrowserManager,children:(0,I.jsx)(dB,{sideDockManager:t.sideDockManager,children:e})})}function pB(){let{isMobile:e}=Pr();return e?(0,I.jsx)(gs,{}):(0,I.jsx)(T,{to:`/model`,replace:!0})}function mB(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function hB(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function gB(e,t){e&&mB(t)&&e.invalidateQueries({queryKey:[`config`]}),hB(e,t)}function _B(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Xe.eventBus.on(Re.connectionOpen,()=>{vt.handleConnectionRestored(),at.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Xe.eventBus.on(Re.connectionClose,()=>{vt.handleConnectionInterrupted(null),t.current=!0}),i=Xe.eventBus.on(Re.connectionError,e=>{vt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Xe.eventBus.on(Re.configUpdated,({path:t})=>{gB(e,t)}),o=Xe.eventBus.on(Re.runtimeUpdateSnapshot,e=>{at.reportSnapshot(e)}),s=Xe.eventBus.on(Re.sessionRunStatus,t=>{Ze(e,{type:`session.run-status`,payload:t})}),c=Xe.eventBus.on(Re.sessionSummaryUpsert,t=>{Ze(e,{type:`session.summary.upsert`,payload:t})}),l=Xe.eventBus.on(Re.sessionSummaryDelete,t=>{Ze(e,{type:`session.summary.delete`,payload:t})}),u=Xe.eventBus.on(Re.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var vB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ModelConfig:e}=await import(`./model-config-Z7oAQmlP.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,14,3,15,16,11,17]))).ModelConfig})),yB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChatPage:e}=await import(`./chat-page-By1I_JyH.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28,29,30,15,16,31,32,33]))).ChatPage})),bB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SearchConfig:e}=await import(`./search-config-mD9kAsXy.js`);return{SearchConfig:e}},__vite__mapDeps([34,2,13,7,3,23,9,35,6]))).SearchConfig})),xB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ProvidersList:e}=await import(`./providers-list-DpAMol1o.js`);return{ProvidersList:e}},__vite__mapDeps([36,2,3,20,21,5,13,10,22,31,23,8,9,25,35,6,27,17,16]))).ProvidersList})),SB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-DT8gjnFw.js`);return{ChannelsList:e}},__vite__mapDeps([37,2,3,13,14,7,23,9,10,35,6,27,33,28,30,17]))).ChannelsList})),CB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-BvLypM3f.js`);return{RuntimeConfig:e}},__vite__mapDeps([38,2,13,14,3,32,8,39,40,25,26]))).RuntimeConfig})),wB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-CbJZyLND.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([41,2,13,7,3,24,39]))).DesktopUpdateConfig})),TB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecurityConfig:e}=await import(`./api-C0F4luAh.js`).then(e=>e.ut);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),EB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-Dvd4VEDw.js`);return{SecretsConfig:e}},__vite__mapDeps([42,2,13,8,3,40,25]))).SecretsConfig})),DB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RemoteAccessPage:e}=await import(`./remote-hKy7hvBh.js`);return{RemoteAccessPage:e}},__vite__mapDeps([43,19,2,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28]))).RemoteAccessPage})),OB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-C2O8-sSE.js`);return{McpMarketplacePage:e}},__vite__mapDeps([44,29,2,3,20,21,5,13,10,11,26,30]))).McpMarketplacePage}));function kB(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function AB({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(kB,{}),children:e})}function jB(e){return(0,I.jsx)(AB,{children:e})}var MB=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:jB((0,I.jsx)(yB,{view:`chat`}))},{path:`/agents`,element:jB((0,I.jsx)(yB,{view:`agents`}))},{path:`/skills`,element:jB((0,I.jsx)(yB,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:jB((0,I.jsx)(yB,{view:`skills`}))},{path:`/cron`,element:jB((0,I.jsx)(yB,{view:`cron`}))},{path:`/model`,element:jB((0,I.jsx)(vB,{}))},{path:`/search`,element:jB((0,I.jsx)(bB,{}))},{path:`/providers`,element:jB((0,I.jsx)(xB,{}))},{path:`/channels`,element:jB((0,I.jsx)(SB,{}))},{path:`/runtime`,element:jB((0,I.jsx)(CB,{}))},{path:`/updates`,element:jB((0,I.jsx)(wB,{}))},{path:`/remote`,element:jB((0,I.jsx)(DB,{}))},{path:`/security`,element:jB((0,I.jsx)(TB,{}))},{path:`/secrets`,element:jB((0,I.jsx)(EB,{}))},{path:`/language`,element:(0,I.jsx)(ns,{})},{path:`/settings`,element:(0,I.jsx)(pB,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:jB((0,I.jsx)(OB,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function NB(e){return`redirectTo`in e?(0,I.jsx)(D,{path:e.path,element:(0,I.jsx)(T,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(D,{path:e.path,element:e.element},e.path)}function PB(){return(0,I.jsx)(x,{children:MB.map(NB)})}function FB(){return _B(De),Ye(),(0,F.useEffect)(()=>(at.start(),()=>{at.stop()}),[]),(0,I.jsxs)(se,{children:[(0,I.jsx)(fB,{children:(0,I.jsx)(PB,{})}),(0,I.jsx)(ce,{}),(0,I.jsx)(ee,{})]})}function IB(){let e=tt(),t=e.isError&&Qe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(FB,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(ne,{username:e.data.username}):(0,I.jsx)(FB,{})}function LB(){return(0,F.useEffect)(()=>{Yo()},[]),(0,I.jsxs)(Ke,{client:De,children:[(0,I.jsx)(IB,{}),(0,I.jsx)(Ko,{}),(0,I.jsx)(Le,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var RB=window.nextclawDesktop?.platform===`win32`?te:M;(0,Tr.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)($o,{children:(0,I.jsx)(Or,{children:(0,I.jsx)(RB,{children:(0,I.jsx)(LB,{})})})})}));export{pi as $,SP as A,sr as At,Xs as B,iL as C,kr as Ct,YI as D,hr as Dt,XI as E,_r as Et,Z as F,Ln as Ft,vo as G,Ns as H,oN as I,In as It,bo as J,Co as K,rc as L,Pn as Lt,rP as M,ir as Mt,aP as N,Un as Nt,bI as O,dr as Ot,QN as P,Hn as Pt,li as Q,ic as R,jn as Rt,nL as S,Pr as St,eL as T,br as Tt,bs as U,Vs as V,Go as W,ii as X,yo as Y,oi as Z,ML as _,bi as _t,Wz as a,wi as at,jL as b,Ir as bt,wz as c,ci as ct,IR as d,gi as dt,Ti as et,LR as f,hi as ft,mR as g,fi as gt,uR as h,ui as ht,nB as i,vi as it,DP as j,or as jt,yI as k,lr as kt,nz as l,si as lt,MR as m,yi as mt,Qz as n,mi as nt,Fz as o,Ci as ot,NR as p,Di as pt,To as q,tB as r,Si as rt,Tz as s,_i as st,rB as t,Ei as tt,KR as u,Oi as ut,kL as v,di as vt,rL as w,xr as wt,NL as x,Fr as xt,AL as y,xi as yt,Us as z};
99
+ `):void 0}function iI(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`&&r!==`sessions_spawn`)return null;let s=XF(o);if(s){let e=YF(s.status)?.toLowerCase(),t=eI(s,a),o=nI(s),c=YF(s.sessionId),l=ZP({args:a,result:s}),u=c?{kind:`open-session`,sessionId:c,sessionKind:s.isChildSession===!0?`child`:`session`,...l?{agentId:l}:{},...YF(s.title)?{label:s.title.trim()}:{},...YF(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return e===`failed`?{kind:`result`,name:r,detail:t,input:$F(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:e===`completed`?{kind:`result`,name:r,detail:t,input:$F(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...l?{agentId:l}:{},...u?{action:u}:{}}:{kind:`result`,name:r,detail:t,input:$F(a),text:o,callId:i||void 0,hasResult:!!o,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...l?{agentId:l}:{},...u?{action:u}:{}}}let c=ZF(o);if(!c)return null;let l=tI(c,a),u=rI(c),d=YF(c.sessionId),f=ZP({args:a,result:c}),p=d?{kind:`open-session`,sessionId:d,sessionKind:c.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...YF(c.title)?{label:c.title.trim()}:{},...YF(c.parentSessionId)?{parentSessionId:c.parentSessionId.trim()}:{}}:void 0;return{kind:`result`,name:r,detail:l,input:$F(a),text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function aI(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e.error:null;return typeof t==`object`&&t&&!Array.isArray(t)&&t.code===`invalid_tool_arguments`?t:null}function oI(e,t){let n=LP(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function sI(e,t){let n=e.mimeType.startsWith(`image/`),r=BP(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function cI(e,t){let n=e.toolInvocation,r=HP(n.result,t);if(r)return r;let i=iI({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:UP(i,t)};let a=WP({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=aI(n.result),s=Array.isArray(o?.issues)?o.issues.find(e=>typeof e==`string`&&e.trim().length>0):void 0,c=qF({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),l=s?`Invalid arguments: ${s}`:c?.summary??CP(n.parsedArgs??n.args),u=c?void 0:KP(n.args,n.parsedArgs),d=s||(typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:xP(n.result).trim()),f=!n.error&&VP(n.result),p=(!c?.fileOperation||!!n.error)&&!f,m=ZP(n);return{type:`tool-card`,card:UP({kind:a.kind,name:n.toolName,...m?{agentId:m}:{},detail:l,...u?{input:u}:{},text:p&&d?d:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:o?`error`:a.statusTone,statusLabel:o?t.toolStatusFailedLabel:a.statusLabel,...c?.fileOperation?{fileOperation:c.fileOperation}:{}},t)}}function lI(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:xP(e)}}function uI(e){return e.type===`text`&&typeof e.text==`string`}function dI(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function fI(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function pI(e){return e.type!==`tool-invocation`||typeof e.toolInvocation!=`object`||e.toolInvocation===null||Array.isArray(e.toolInvocation)?!1:`toolName`in e.toolInvocation&&typeof e.toolInvocation.toolName==`string`}function mI(e){let{inlineTokens:t,part:n,texts:r}=e;return uI(n)?IP(n,t):dI(n)?oI(n,r):fI(n)?sI(n,r):pI(n)?cI(n,r):lI(n,r)}function hI(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function gI(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function _I(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function vI(e,t){return{id:e.id,role:_I(e.role),roleLabel:gI(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(hI(e)),status:e.meta?.status,parts:e.parts.map(n=>mI({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var yI=function(e){return e.CALL=`call`,e.RESULT=`result`,e.PARTIAL_CALL=`partial-call`,e.ERROR=`error`,e.CANCELLED=`cancelled`,e}({});function bI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function xI(e){return bI(e)}function SI(e){let t=bI(e);if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return t;let r=n.split(/[\\/]/).filter(Boolean);return r[r.length-1]??n}function CI(e){return/^[A-Za-z]:[\\/]?$/.test(e)||e===`/`?e:e.replace(/[\\/]+$/,``)}function wI(e){let t=CI(e.trim().replace(/\\/g,`/`));return/^[A-Za-z]:/.test(t)?`${t.slice(0,1).toLowerCase()}${t.slice(1)}`:t}function TI(e){let t=e.trim().replace(/\\/g,`/`);return t?/^[A-Za-z]:\//.test(t)?{prefix:t.slice(0,2),segments:t.slice(3).split(`/`).filter(Boolean)}:t.startsWith(`/`)?{prefix:`/`,segments:t.slice(1).split(`/`).filter(Boolean)}:{prefix:null,segments:t.split(`/`).filter(Boolean)}:{prefix:null,segments:[]}}function EI(e){let t=wI(e.path),n=wI(e.sessionProjectRoot);if(!t||!n)return null;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.split(`/`).filter(Boolean);if(t===n)return[];let r=n.endsWith(`/`)?n:`${n}/`;return t.startsWith(r)?t.slice(r.length).split(`/`).filter(Boolean):null}function DI(e){let{labels:t,leading:n=null}=e,r=t.map((e,n)=>({key:`${n}:${e}`,label:e,kind:n===t.length-1?`file`:`directory`,isCurrent:n===t.length-1}));return n?[n,...r]:r}function OI(e){let{column:t,line:n}=e;return typeof n==`number`?`L${n}${typeof t==`number`?`:${t}`:``}`:null}function kI(e){let{column:t,line:n,path:r,sessionProjectRoot:i,truncated:a}=e,o=r.trim(),s=i?.trim()&&o?EI({path:o,sessionProjectRoot:i}):null,c;if(i?.trim()&&s){let e=SI(i)??i.trim();c=DI({labels:s,leading:{key:`workspace:${e}`,label:e,kind:`workspace`,isCurrent:s.length===0}})}else{let{prefix:e,segments:t}=TI(o);c=DI({labels:t,leading:e?{key:`root:${e}`,label:e,kind:`root`,isCurrent:t.length===0}:null})}return c.length===0&&(c=[{key:`file:unknown`,label:o||`file`,kind:`file`,isCurrent:!0}]),{fullPath:o,locationLabel:OI({line:n,column:t}),truncated:a,segments:c}}var AI=new Set([`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`]),jI=new Set([`running`,`completed`,`failed`,`idle`]);function MI(e){if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return String(e??``)}}function NI(e){return`${he}/api/ncp/assets/content?${new URLSearchParams({uri:e}).toString()}`}function PI(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function FI(e){let{metadata:t}=e;return!t||typeof t!=`object`||Array.isArray(t)?null:t}function II(e){let t=FI(e)?.last_activity_preview;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,{state:r}=n,i=PI(n.timestamp);if(!jI.has(r)||!i)return null;let a=PI(n.statusText),o=PI(n.replyText);return{state:r,timestamp:i,...a?{statusText:a}:{},...o?{replyText:o}:{}}}function LI(e){let t=FI(e);return t?PI(t.preferred_model)??PI(t.preferredModel)??PI(t.model):null}function RI(e){let t=FI(e);if(!t)return null;let n=PI(t.preferred_thinking)??PI(t.thinking)??PI(t.thinking_level)??PI(t.thinkingLevel);if(!n)return null;let r=n.toLowerCase();return AI.has(r)?r:null}function zI(e){let t=FI(e);return t?PI(t.label):null}function BI(e){let t=FI(e);return t?xI(t.project_root??t.projectRoot):null}function VI(e){let t=FI(e);return t?PI(t.ui_last_read_at):null}function HI(e){let t=FI(e);return t?PI(t.runtime)??PI(t.session_type)??PI(t.sessionType)??`native`:`native`}function UI(e){let t=FI(e);return t?PI(t.parent_session_id)??PI(t.parentSessionId):null}function WI(e){let t=FI(e);return t?PI(t.spawned_by_request_id)??PI(t.spawnedByRequestId):null}function GI(e){let t=FI(e);return t?t.child_session_promoted===!0:!1}function KI(e){if(e.startsWith(`cron:`))return{type:`cron`};if(e.startsWith(`agent:`)){let t=e.split(`:`);if(t.length>=3){let e=t[2];if(e&&e!==`main`&&e!==`direct`)return{channel:e}}}return{}}function qI(e){return e.state===`cancelled`?yI.CANCELLED:e.state===`result`?yI.RESULT:e.state===`partial-call`?yI.PARTIAL_CALL:yI.CALL}function JI(e){let t=[];for(let n of e){if(n.type===`text`){t.push({type:`text`,text:n.text});continue}if(n.type===`rich-text`){t.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){t.push({type:`reasoning`,reasoning:n.text,details:[]});continue}if(n.type===`source`){t.push({type:`source`,source:{sourceType:`url`,id:n.url??n.title??Math.random().toString(36).slice(2,8),url:n.url??``,...n.title?{title:n.title}:{}}});continue}if(n.type===`file`&&n.contentBase64){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:n.contentBase64,...n.url?{url:n.url}:{},...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.url){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:n.url,...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`file`&&n.assetUri){t.push({type:`file`,...n.name?{name:n.name}:{},mimeType:n.mimeType??`application/octet-stream`,data:``,url:NI(n.assetUri),...typeof n.sizeBytes==`number`?{sizeBytes:n.sizeBytes}:{}});continue}if(n.type===`step-start`){t.push({type:`step-start`});continue}n.type===`tool-invocation`&&t.push({type:`tool-invocation`,toolInvocation:{status:qI(n),toolCallId:n.toolCallId??`${n.toolName}-${Math.random().toString(36).slice(2,8)}`,toolName:n.toolName,args:MI(n.args),result:n.result}})}return t}function YI(e){return e===`service`?`system`:e===`tool`?`assistant`:e}function XI(e){return{id:e.id,role:YI(e.role),parts:JI(e.parts),meta:{source:`stream`,status:e.status,sessionKey:e.sessionId,timestamp:e.timestamp}}}function ZI(e){let t=zI(e),n=LI(e),r=RI(e),i=BI(e),a=VI(e),o=PI(e.lastMessageAt),s=SI(i),c=KI(e.sessionId),l=UI(e),u=WI(e),d=GI(e),f=II(e);return{key:e.sessionId,createdAt:e.createdAt??e.updatedAt,updatedAt:e.updatedAt,...o?{lastMessageAt:o}:{},...a?{readAt:a}:{},...typeof e.agentId==`string`&&e.agentId.trim().length>0?{agentId:e.agentId.trim()}:{},...t?{label:t}:{},...c,...n?{preferredModel:n}:{},...r?{preferredThinking:r}:{},...i?{projectRoot:i}:{},...s?{projectName:s}:{},sessionType:HI(e),sessionTypeMutable:!1,status:e.status??`idle`,isChildSession:!!l,...d?{isPromotedChildSession:d}:{},...l?{parentSessionId:l}:{},...u?{spawnedByRequestId:u}:{},...f?{activityPreview:f}:{},messageCount:e.messageCount}}function QI(e){return e.map(ZI)}function $I(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function eL(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.trunc(e);return t>=0?t:null}function tL(e){return e===!0}function nL(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r=eL(n.usedContextTokens),i=eL(n.totalContextTokens),a=eL(n.prunedUsedContextTokens),o=$I(n.updatedAt);if(r===null||i===null||a===null||!o)return null;let s=eL(n.compactedUsedContextTokens);return{usedContextTokens:r,totalContextTokens:i,prunedUsedContextTokens:a,availableContextTokens:eL(n.availableContextTokens)??Math.max(0,i-r),droppedHistoryCount:eL(n.droppedHistoryCount)??0,truncatedToolResultCount:eL(n.truncatedToolResultCount)??0,truncatedSystemPrompt:tL(n.truncatedSystemPrompt),truncatedUserMessage:tL(n.truncatedUserMessage),compacted:tL(n.compacted),...$I(n.checkpointId)?{checkpointId:$I(n.checkpointId)??void 0}:{},compactedMessageCount:eL(n.compactedMessageCount)??0,...s===null?{}:{compactedUsedContextTokens:s},updatedAt:o}}function rL(e){let{metadata:t}=e;if(!t||t.nextclaw_timeline_kind!==`context_compaction`)return null;let n=t.checkpoint&&typeof t.checkpoint==`object`&&!Array.isArray(t.checkpoint)?t.checkpoint:null;if(!n)return null;let r=$I(n.id),i=n.status===`compressing`?`compressing`:n.status===`compressed`?`compressed`:null,a=$I(n.summary),o=eL(n.coveredMessageCount),s=eL(n.coveredSessionMessageCount),c=eL(n.originalEstimatedTokens),l=eL(n.projectedEstimatedTokens),u=$I(n.createdAt),d=$I(n.updatedAt);return!r||!i||!a||o===null||s===null||c===null||l===null||!u||!d?null:{id:r,status:i,summary:a,coveredMessageCount:o,coveredSessionMessageCount:s,originalEstimatedTokens:c,projectedEstimatedTokens:l,createdAt:u,updatedAt:d}}function iL(){return Ve({queryKey:[`agents`],queryFn:ut,staleTime:3e4})}function aL(){let e=Fe();return me({mutationFn:({agentId:e,data:t})=>pt(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function oL(){let e=Fe();return me({mutationFn:({agentId:e})=>Je(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),N.success(s(`configSavedApplied`))},onError:e=>{N.error(s(`configSaveFailed`)+`: `+e.message)}})}function sL(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function cL(e){let t=e?.trim()??``,n=Q(e=>e.snapshot.availableAgents??[]),r=iL(),i=(0,F.useMemo)(()=>sL(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,F.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function lL({agentId:e,className:t}){let n=cL(e);return n?(0,I.jsx)(Vs,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var uL=new WeakMap;function dL(e){return{roleLabels:{user:s(`chatRoleUser`),assistant:s(`chatRoleAssistant`),tool:s(`chatRoleTool`),system:s(`chatRoleSystem`),fallback:s(`chatRoleMessage`)},reasoningLabel:s(`chatReasoning`),toolCallLabel:s(`chatToolCall`),toolResultLabel:s(`chatToolResult`),toolInputLabel:s(`chatToolInput`),toolNoOutputLabel:s(`chatToolNoOutput`),toolOutputLabel:s(`chatToolOutput`),toolStatusPreparingLabel:s(`chatToolStatusPreparing`),toolStatusRunningLabel:s(`chatToolStatusRunning`),toolStatusCompletedLabel:s(`chatToolStatusCompleted`),toolStatusFailedLabel:s(`chatToolStatusFailed`),toolStatusCancelledLabel:s(`chatToolStatusCancelled`),imageAttachmentLabel:s(`chatImageAttachment`),fileAttachmentLabel:s(`chatFileAttachment`),unknownPartLabel:s(`chatUnknownPart`)}}function fL(e){return{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`),copyMessageLabel:s(`chatMessageCopy`),copiedMessageLabel:s(`chatMessageCopied`),typingLabel:s(`chatTyping`),attachmentOpenLabel:s(`chatAttachmentOpen`),attachmentAttachedLabel:s(`chatAttachmentAttached`),attachmentCategoryLabels:{archive:s(`chatAttachmentCategoryArchive`),audio:s(`chatAttachmentCategoryAudio`),code:s(`chatAttachmentCategoryCode`),data:s(`chatAttachmentCategoryData`),document:s(`chatAttachmentCategoryDocument`),generic:s(`chatAttachmentCategoryGeneric`),image:s(`chatAttachmentCategoryImage`),pdf:s(`chatAttachmentCategoryPdf`),sheet:s(`chatAttachmentCategorySheet`),video:s(`chatAttachmentCategoryVideo`)}}}function pL({checkpoint:e}){return(0,I.jsxs)(`div`,{className:`my-4 flex items-center gap-3 text-[11px] text-gray-500`,title:[`${s(`chatContextCompactionCoveredMessages`)}: ${e.coveredSessionMessageCount}`,`${s(`chatContextCompactionOriginalTokens`)}: ${e.originalEstimatedTokens}`,`${s(`chatContextCompactionProjectedTokens`)}: ${e.projectedEstimatedTokens}`].join(`
100
+ `),children:[(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`}),(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-gray-200 bg-gray-50 px-3 py-1`,children:[e.status===`compressing`?(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}):(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-gray-300`}),(0,I.jsx)(`span`,{children:e.status===`compressing`?s(`chatContextCompactionCompressing`):s(`chatContextCompactionCompressed`)})]}),(0,I.jsx)(`div`,{className:`h-px flex-1 bg-gray-200`})]})}function mL(e){let{normalRawMessages:t,rawMessageId:n,rawMessages:r}=e,i=r.findIndex(e=>e.id===n);return i<0?t.length-1:r.slice(0,i).filter(e=>!rL(e)).length-1}function hL(e){let t=e.rawMessages.filter(e=>!rL(e)),n=e.rawMessages.map(e=>({rawMessageId:e.id,checkpoint:rL(e)})).filter(e=>!!e.checkpoint).map(n=>({key:n.rawMessageId,checkpoint:n.checkpoint,boundaryIndex:mL({rawMessages:e.rawMessages,normalRawMessages:t,rawMessageId:n.rawMessageId})})).sort((e,t)=>e.boundaryIndex-t.boundaryIndex),r=[],i=[],a=0,o=e=>{i.length!==0&&(r.push({kind:`messages`,key:e,messages:i}),i=[])};for(t.forEach((t,s)=>{let c=e.messages[s];for(c&&i.push(c);a<n.length&&n[a]?.boundaryIndex<=s;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}});a<n.length;){let e=n[a];o(`messages-before-${e.key}`),r.push({kind:`compaction`,key:e.key,checkpoint:e.checkpoint}),a+=1}return o(`messages-final`),r.length===0&&r.push({kind:`messages`,key:`messages-empty`,messages:[]}),r}function gL({messages:e,isSending:t,className:n,onToolAction:r,onFileOpen:i}){let{language:a}=kr(),o=(0,F.useMemo)(()=>dL(a),[a]),s=(0,F.useMemo)(()=>e.flatMap(e=>{if(rL(e))return[];let t=uL.get(e);if(t&&t.language===a)return[t.viewModel];let n=XI(e),r=vI({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:AP(e.metadata)},parts:n.parts},{formatTimestamp:e=>u(e,a),texts:o});return uL.set(e,{language:a,viewModel:r}),[r]}),[a,e,o]),c=(0,F.useMemo)(()=>s.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[s]),l=(0,F.useMemo)(()=>fL(a),[a]),d=(0,F.useMemo)(()=>hL({rawMessages:e,messages:s}),[s,e]);return(0,I.jsx)(`div`,{className:n,children:d.map((e,n)=>e.kind===`compaction`?(0,I.jsx)(pL,{checkpoint:e.checkpoint},e.key):(0,I.jsx)(wM,{messages:e.messages,isSending:n===d.length-1?t:!1,hasAssistantDraft:c,texts:l,onToolAction:r,onFileOpen:i,renderToolAgent:e=>(0,I.jsx)(lL,{agentId:e,className:`h-4 w-4 shrink-0`})},e.key))})}function _L(){let e=Fe();return async t=>{let{sessionKey:n,patch:r,successMessage:i}=t;try{dt(e,await gt(n,r)),await e.invalidateQueries({queryKey:[`ncp-session-skills`,n]}),N.success(i??s(`configSavedApplied`))}catch(e){throw N.error(s(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function vL(){let e=_L();return async t=>{let{persistToServer:n,projectRoot:r,sessionKey:i}=t,a=s(r?`chatSessionProjectUpdated`:`chatSessionProjectCleared`);if(!n){Z.getState().setSnapshot({pendingProjectRoot:r,pendingProjectRootSessionKey:i}),N.success(a);return}await e({sessionKey:i,patch:{projectRoot:r},successMessage:a})}}function yL({icon:e,label:t,onClick:n,disabled:i=!1,destructive:a=!1}){return(0,I.jsxs)(`button`,{type:`button`,className:r(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:i,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:t})]})}function bL(e){return Ve({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>mt({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var xL=F.forwardRef(({className:e,children:t,...n},i)=>(0,I.jsx)(`div`,{ref:i,className:r(`overflow-auto`,e),...n,children:t}));xL.displayName=`ScrollArea`;function SL({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:o,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:d}){let[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(``);(0,F.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),h(n),_(``)},[t,e]);let v=bL({path:m,enabled:e});(0,F.useEffect)(()=>{!e||!v.data||f.trim().length===0&&p(v.data.currentPath)},[v.data,f,e]);let y=f.trim(),b=y.length===0||n,x=(0,F.useMemo)(()=>v.error?v.error instanceof Error?v.error.message:String(v.error):null,[v.error]),S=g.trim().toLowerCase(),C=(0,F.useMemo)(()=>{let e=v.data?.entries??[];return S.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(S)||n.includes(S)})},[v.data?.entries,S]),w=e=>{h(e),_(``),e&&p(e)};return(0,I.jsx)(Gt,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(qt,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(Kt,{children:[(0,I.jsx)(Jt,{children:a}),o?(0,I.jsx)(Wt,{children:o}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!b&&i(y)},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Ae,{htmlFor:`server-path-picker-input`,children:c}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(Ne,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,I.jsx)(ye,{type:`button`,variant:`outline`,onClick:()=>w(y||null),disabled:n,children:s(`openPath`)})]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.homePath??null),disabled:n||v.isLoading,children:[(0,I.jsx)(sr,{className:`mr-1 h-4 w-4`}),s(`homeDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(v.data?.parentPath??null),disabled:!v.data?.parentPath||n||v.isLoading,children:[(0,I.jsx)(nr,{className:`mr-1 h-4 w-4`}),s(`parentDirectory`)]}),(0,I.jsxs)(ye,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{v.refetch()},disabled:n||v.isLoading,children:[(0,I.jsx)(k,{className:`mr-1 h-4 w-4`}),s(`chatRefresh`)]})]}),(0,I.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:s(`currentDirectory`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:v.data?.breadcrumbs.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>w(e.path),disabled:n,children:e.label}),t<v.data.breadcrumbs.length-1?(0,I.jsx)(Rn,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{value:g,onChange:e=>_(e.target.value),placeholder:s(`pathPickerSearchPlaceholder`),disabled:n||v.isLoading,className:`pl-9`})]})}),(0,I.jsx)(xL,{className:`min-h-0 flex-1 px-2 py-2`,children:v.isLoading?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`loading`)}):x?(0,I.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[s(`pathBrowseFailed`),`: `,x]}):v.data&&C.length>0?(0,I.jsx)(`div`,{className:`space-y-1`,children:C.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>w(e.path),disabled:n,children:[(0,I.jsx)(ir,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):v.data&&v.data.entries.length>0?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`pathPickerSearchEmpty`)}):(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:s(`emptyDirectory`)})})]}),d?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,I.jsxs)(Ut,{children:[(0,I.jsx)(ye,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:s(`cancel`)}),(0,I.jsx)(ye,{type:`submit`,disabled:b,children:n?s(`saving`):u})]})]})]})})}function CL({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(SL,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:s(`chatSessionProjectDialogTitle`),description:s(`chatSessionProjectDialogDescription`),pathLabel:s(`chatSessionProjectPathLabel`),pathPlaceholder:s(`chatSessionProjectPathPlaceholder`),confirmLabel:s(`chatSessionSetProject`),hint:s(`chatSessionProjectUpdateHint`)})}var wL=`flex shrink-0 items-center gap-1.5`,TL=`h-7 w-7 rounded-lg shrink-0 text-gray-400 hover:text-gray-700`;function EL({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,childSessionCount:i=0,sessionCronJobCount:a=0,onOpenChildSessions:o,onOpenSessionCronJobs:c,onDeleteSession:l}){let u=vL(),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)(!1),_=n||h,v=async n=>{let r=t;g(!0);try{await u({sessionKey:e,projectRoot:n,persistToServer:r}),m(!1),f(!1)}finally{g(!1)}};return(0,I.jsxs)(`div`,{className:wL,children:[i>0&&o?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:TL,"aria-label":s(`chatSessionOpenChildSessions`),title:s(`chatSessionOpenChildSessions`),onClick:o,disabled:_,children:(0,I.jsx)(ar,{className:`h-4 w-4`})}):null,a>0&&c?(0,I.jsx)(ye,{type:`button`,variant:`ghost`,size:`icon`,className:TL,"aria-label":s(`chatSessionOpenCronJobs`),title:s(`chatSessionOpenCronJobs`),onClick:c,disabled:_,children:(0,I.jsx)(jn,{className:`h-4 w-4`})}):null,(0,I.jsxs)(wn,{open:d,onOpenChange:f,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:TL,"aria-label":s(`chatSessionMoreActions`),disabled:_,children:(0,I.jsx)(b,{className:`h-4 w-4`})})}),(0,I.jsx)(bn,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(yL,{icon:er,label:s(`chatSessionSetProject`),onClick:()=>{f(!1),m(!0)},disabled:_}),(0,I.jsx)(yL,{icon:hn,label:s(`chatDeleteSession`),onClick:()=>{f(!1),l()},disabled:!t||_,destructive:!0})]})})]}),(0,I.jsx)(CL,{open:p,currentProjectRoot:r,isSaving:h,onOpenChange:m,onSave:v})]})}function DL({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=vL(),[a,o]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),o(!1)}finally{d(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-gray-200 bg-gray-100/90 px-2 py-0.5 text-[11px] font-medium text-gray-600 transition-colors hover:border-gray-300 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":s(`chatSessionSetProject`),disabled:u,children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(er,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(Ln,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(bn,{align:`start`,className:`w-72 p-2`,children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-500`,children:t}),n?(0,I.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(yL,{icon:hr,label:s(`chatSessionSetProject`),onClick:()=>{o(!1),l(!0)},disabled:u}),(0,I.jsx)(yL,{icon:rr,label:s(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,I.jsx)(CL,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function OL({parentSessionLabel:e,onGoToParentSession:t}){if(!e)return null;let n=e.trim();return(0,I.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-4 py-2 backdrop-blur-sm sm:px-5`,children:(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,I.jsx)(Xt,{className:`h-3.5 w-3.5`}),(0,I.jsxs)(`span`,{children:[s(`chatBackToParent`),n?` · ${n}`:``]})]})})}function kL({snapshot:e,childSessionCount:t,sessionCronJobCount:n,layoutMode:i,normalizedAgentId:a,sessionHeaderTitle:o,shouldShowHeaderAgentAvatar:c,shouldShowSessionHeader:l,onBackToList:u,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}){let m=i===`mobile`;return(0,I.jsxs)(`div`,{className:r(`border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-colors duration-200`,m?`px-3 sm:px-3`:`px-4 sm:px-5`,l?`opacity-100`:`h-0 py-0 opacity-0 border-b-0`,l&&(m?`min-h-12 pb-2 pt-2`:`h-[52px]`)),style:m&&l?{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.5rem)`}:void 0,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[m&&u?(0,I.jsx)(`button`,{type:`button`,onClick:u,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":s(`chat`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,c?(0,I.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(Vs,{agentId:a,displayName:e.agentDisplayName,avatarUrl:e.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:o}),e.sessionTypeLabel?(0,I.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:[e.sessionTypeIcon?.src?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center`,children:(0,I.jsx)(Ps,{icon:{kind:`runtime-image`,src:e.sessionTypeIcon.src,alt:e.sessionTypeIcon.alt??null,name:e.sessionTypeLabel}})}):null,e.sessionTypeLabel]}):null,e.sessionProjectName?(0,I.jsx)(DL,{sessionKey:e.sessionKey??`draft`,projectName:e.sessionProjectName,projectRoot:e.sessionProjectRoot,persistToServer:e.canDeleteSession}):null]}),e.sessionKey?(0,I.jsx)(EL,{sessionKey:e.sessionKey,canDeleteSession:e.canDeleteSession,isDeletePending:e.isDeletePending,projectRoot:e.sessionProjectRoot,childSessionCount:t,sessionCronJobCount:n,onOpenChildSessions:d,onOpenSessionCronJobs:f,onDeleteSession:p}):null]})}var AL=`native`;function jL(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:AL}function ML(e,t=AL){return jL(e?.runtime?.trim()||e?.engine?.trim()||t)}function NL(e,t){return e===`native`?s(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function PL(e){let t=new Map;for(let n of e){let e=jL(n.value);t.set(e,{value:e,label:n.label?.trim()||NL(e),icon:n.icon??null,ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(AL,{value:AL,label:NL(AL),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function FL(e){let{selectedSession:t,pendingSessionType:n,setPendingSessionType:r,sessionTypesData:i}=e,a=(0,F.useMemo)(()=>PL(i?.options??[]),[i?.options]),o=(0,F.useMemo)(()=>{let e=[...a],n=jL(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:NL(n),icon:null,ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[a,t?.sessionType]),c=(0,F.useMemo)(()=>jL(i?.defaultType??`native`),[i?.defaultType]),l=(0,F.useRef)(null),u=(0,F.useMemo)(()=>jL(t?.sessionType??n??c),[c,n,t?.sessionType]),d=(0,F.useMemo)(()=>o.find(e=>e.value===u)??null,[u,o]);(0,F.useEffect)(()=>{if(t)return;let e=typeof n==`string`?n.trim():``,i=jL(n);(e.length===0||l.current===i||l.current===null&&i===`native`)&&(l.current=c,i!==c&&r(c))},[c,n,t,r]);let f=!t||!!t.sessionTypeMutable,p=(0,F.useMemo)(()=>new Set(a.map(e=>e.value)),[a]);return{sessionTypeOptions:o,selectedSessionTypeOption:d,defaultSessionType:c,selectedSessionType:u,canEditSessionType:f,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!p.has(jL(t.sessionType))?!0:d?.ready===!1,[p,t,d?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!p.has(jL(t.sessionType))?`${NL(u)} ${s(`chatSessionTypeUnavailableSuffix`)}`:d?.ready===!1?d.reasonMessage?.trim()||`${d.label} setup required`:null,[p,t,u,d])}}function IL(e,t){return e.label?.trim()?e.label.trim():t?Us(t):e.sessionKey}function LL(e){let t=Ci({limit:200}),n=(0,F.useMemo)(()=>t.data?.sessions??[],[t.data?.sessions]),r=(0,F.useMemo)(()=>{let e=QI(n);return new Map(e.map(e=>[e.key,e]))},[n]);return(0,F.useMemo)(()=>e.map(e=>{let t=r.get(e.sessionKey)??null,n=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:IL(e,t),agentId:n,updatedAt:t?.updatedAt??null,lastMessageAt:t?.lastMessageAt??null,readAt:t?.readAt??null,runStatus:t?.status===`running`?`running`:void 0,sessionTypeLabel:t?.sessionType?NL(t.sessionType):null,preferredModel:t?.preferredModel?.trim()||null,projectName:t?.projectName?.trim()||null,projectRoot:t?.projectRoot?.trim()||null}}),[r,e])}function RL(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
101
+ `)}}async function*zL(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=BL(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=BL(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function BL(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=RL(e);t&&i.push(t)}if(t&&r.trim()){let e=RL(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var VL=`/ncp/agent`,HL=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function UL(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function WL(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function GL(e){let t=(e??`/ncp/agent`).trim();if(!t)return VL;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function KL(e){try{return(await e.text()).trim()}catch{return``}}function qL(e){if(ZL(e))return e.ncpError;if(YL(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:$L(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function JL(e,t={}){return new HL(e,t.alreadyPublished??!1)}function YL(e){return XL(e)&&typeof e.code==`string`&&typeof e.message==`string`}function XL(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function ZL(e){return e instanceof HL}var QL={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function $L(e){if(!e)return`runtime-error`;let t=QL[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function eR(e){let t=nR(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function tR(e){let t=nR(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=$L(n),i=XL(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function nR(e){try{let t=JSON.parse(e);return XL(t)?t:null}catch{return null}}var rR=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],iR=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=UL(e.baseUrl),this.basePath=GL(e.basePath),this.fetchImpl=WL(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||`ncp-http-agent-client`,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:rR,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:TM.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/send`),{method:`POST`,headers:{...this.defaultHeaders,accept:`application/json`,"content-type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`NCP send command failed with HTTP ${n.status}: ${await KL(n)}`);let r=await n.json();if(!r.ok||!r.data)throw Error(r.error?.message??`NCP send command returned an invalid handle.`);return r.data}catch(e){if(t.signal.aborted)throw Error(`NCP send command was cancelled.`);if(ZL(e))throw e;let n=qL(e);throw this.publish({type:TM.EndpointError,payload:n}),JL(n)}finally{this.activeControllers.delete(t)}}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await KL(n)}`)}catch(e){if(t.signal.aborted)return;let n=qL(e);throw this.publish({type:TM.EndpointError,payload:n}),JL(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await KL(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of zL(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(ZL(e))throw e;let n=qL(e);throw this.publish({type:TM.EndpointError,payload:n}),JL(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=eR(e.data);if(!t){this.publish({type:TM.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=tR(e.data);throw this.publish({type:TM.EndpointError,payload:t}),JL(t,{alreadyPublished:!0})}}};function aR(e){return typeof e==`string`?e:e instanceof URL?e.toString():e.url}function oR(e){if(e instanceof Error){let t=e.name?.trim(),n=e.message?.trim();return t&&n?`${t}: ${n}`:n||t||`Unknown Error`}return String(e??`Unknown error`)}function sR(e,t){let n=Error(e);return t!==void 0&&(n.cause=t),n}function cR(){return async(e,t)=>{try{return await fetch(e,{credentials:`include`,...t})}catch(n){throw vt.reportTransportFailure(oR(n)),sR(`NCP fetch failed for ${(t?.method||`GET`).toUpperCase()} ${aR(e)}: ${oR(n)}`,n)}}}var lR=300,uR=`ncp agent unavailable during startup`;function dR(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function fR(e){return e?.trim().toLowerCase().includes(uR)??!1}function pR(){return new iR({baseUrl:he,basePath:`/api/ncp/agent`,fetchImpl:cR()})}async function mR(e,t,n=lR){t.throwIfAborted();try{let r=await it(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`,contextWindow:r.contextWindow??null}}catch(e){if(t.throwIfAborted(),!dR(e))throw e;return{messages:[],status:`idle`}}}function hR(e,t){let n=(0,F.useRef)(null),r=(0,F.useCallback)(e=>{if(!e){n.current=null;return}n.current!==e&&(n.current=e,t())},[t]);(0,F.useEffect)(()=>{r(e)},[e,r])}function gR(e,t={}){let[n]=(0,F.useState)(()=>pR()),r=bt(),[i,a]=(0,F.useState)(0),[o,s]=(0,F.useState)(null),c=t.messageLimit??lR;(0,F.useEffect)(()=>{s(null)},[e]);let l=rN({sessionId:e,client:n,loadSeed:(0,F.useCallback)(async(e,t)=>{let n=await mR(e,t,c);return t.aborted||s(n.contextWindow??null),{messages:n.messages,status:n.status}},[i,c])}),u=l.hydrateError?.message??l.snapshot.error?.message??null;return hR(e&&r.phase===`ready`&&fR(u)?`${e}:${r.lastReadyAt??0}`:null,()=>{a(e=>e+1)}),(0,F.useMemo)(()=>({...l,snapshot:{...l.snapshot,contextWindow:l.snapshot.contextWindow??o}}),[l,o])}function _R(e){return e.label?.trim()||e.path.split(`/`).filter(Boolean).pop()||e.path}function vR(e){let{activePanelKind:t,activeChildSessionKey:n,activeWorkspaceFileKey:r,childSessionTabs:i,workspaceFileTabs:a,sessionCronJobCount:o}=e;if(t===`cron`&&o>0)return{kind:`cron`};if(t!==`child-session`&&r){let e=a.find(e=>e.key===r);if(e)return{kind:`file`,file:e}}if(t!==`file`&&n){let e=i.find(e=>e.sessionKey===n);if(e)return{kind:`child-session`,tab:e}}return i[0]?{kind:`child-session`,tab:i[0]}:a[0]?{kind:`file`,file:a[0]}:o>0?{kind:`cron`}:null}function yR({agentId:e,kind:t}){return t===`cron`?(0,I.jsx)(jn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):t===`file`?(0,I.jsx)(Kn,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}):e?(0,I.jsx)(lL,{agentId:e,className:`h-3.5 w-3.5 shrink-0`}):(0,I.jsx)(ur,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`})}function bR({tab:e}){return(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{asChild:!0,children:(0,I.jsxs)(`div`,{className:r(`group flex max-w-[180px] min-w-0 items-center gap-1.5 border-r border-gray-200/70 border-b-2 px-2.5 py-2 transition-colors`,e.active?`border-b-primary bg-white text-gray-900`:`border-b-transparent bg-gray-50/85 text-gray-500 hover:bg-gray-100`),children:[e.onClose?(0,I.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e.onClose?.()},className:`relative inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-700`,"aria-label":s(`chatWorkspaceCloseFile`),children:[(0,I.jsx)(`span`,{className:`flex items-center justify-center group-hover:hidden`,children:(0,I.jsx)(yR,{kind:e.kind,agentId:e.agentId})}),(0,I.jsx)(gn,{className:`hidden h-3.5 w-3.5 group-hover:block`})]}):(0,I.jsx)(yR,{kind:e.kind,agentId:e.agentId}),(0,I.jsxs)(`button`,{type:`button`,onClick:e.onSelect,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-medium`,children:e.title}),e.kind===`file`&&e.viewMode===`diff`?(0,I.jsx)(`span`,{className:`shrink-0 rounded border border-amber-200 bg-amber-50 px-1 py-0 text-[9px] font-medium uppercase tracking-[0.08em] text-amber-700`,children:s(`chatWorkspaceDiff`)}):null,e.showUnreadDot?(0,I.jsx)(`span`,{"aria-label":s(`chatSessionUnread`),className:`h-2 w-2 shrink-0 rounded-full bg-primary`}):null]})]})}),(0,I.jsx)(an,{side:`bottom`,className:`max-w-[320px] text-xs`,children:e.tooltip})]})}function xR({onBack:e,onClose:t,tabs:n}){return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(`div`,{"data-testid":`workspace-tabs-bar`,className:`flex min-w-0 items-stretch border-b border-gray-200/70 bg-gray-50/85`,children:[(0,I.jsx)(`div`,{className:`workspace-horizontal-scrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,children:(0,I.jsx)(`div`,{"data-testid":`workspace-tabs-scroll`,className:`flex min-w-max items-stretch`,children:n.map(e=>(0,I.jsx)(bR,{tab:e},e.key))})}),e?(0,I.jsx)(`button`,{type:`button`,onClick:e,className:`mx-1 flex h-7 w-7 shrink-0 self-center items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,"aria-label":s(`chatBackToParent`),children:(0,I.jsx)(Xt,{className:`h-4 w-4`})}):null,(0,I.jsx)(`button`,{type:`button`,onClick:t,className:`mx-1 flex h-7 w-7 shrink-0 self-center items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,"aria-label":s(`chatWorkspaceClosePanel`),children:(0,I.jsx)(gn,{className:`h-4 w-4`})})]})})}function SR({tone:e=`neutral`,value:t}){return(0,I.jsx)(`span`,{className:r(`inline-flex h-5 items-center rounded-sm border px-1.5 text-[10px] font-medium leading-none`,e===`warning`?`border-amber-200 bg-amber-50 text-amber-700`:`border-gray-200 bg-gray-50 text-gray-500`),children:t})}function CR({breadcrumb:e}){return(0,I.jsx)(`div`,{"data-testid":`workspace-file-breadcrumbs`,title:e.fullPath,className:`workspace-horizontal-scrollbar overflow-x-auto overflow-y-hidden border-b border-gray-200/80 bg-gray-50/55`,children:(0,I.jsxs)(`div`,{"data-testid":`workspace-file-breadcrumb-scroll`,className:`flex min-w-max items-center gap-2.5 px-3 py-1.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 pr-1`,children:e.segments.map((t,n)=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(`span`,{className:r(`inline-flex h-5 items-center gap-1 rounded-sm px-1 text-[11px] leading-none`,t.kind===`workspace`?`bg-primary/8 text-primary`:t.isCurrent?`bg-gray-200/70 text-gray-900`:`text-gray-500`),children:[t.kind===`workspace`?(0,I.jsx)(tr,{className:`h-3 w-3 shrink-0`}):t.isCurrent?(0,I.jsx)(Kn,{className:`h-3 w-3 shrink-0`}):null,(0,I.jsx)(`span`,{children:t.label})]}),n<e.segments.length-1?(0,I.jsx)(Rn,{className:`h-3 w-3 shrink-0 text-gray-300`}):null]},t.key))}),e.locationLabel||e.truncated?(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-1`,children:[e.locationLabel?(0,I.jsx)(SR,{value:e.locationLabel}):null,e.truncated?(0,I.jsx)(SR,{tone:`warning`,value:s(`chatWorkspacePreviewTruncated`)}):null]}):null]})})}function wR(e){let t=e.path?.trim()??``;return Ve({queryKey:[`server-path-read`,t,e.basePath??null],queryFn:()=>lt({path:t,basePath:e.basePath}),enabled:(e.enabled??!0)&&t.length>0,staleTime:0})}function TR(e){return e.serverKind?e.serverKind:/\.mdx?$/i.test(e.path)?`markdown`:`text`}function ER(e){let{line:t,path:n,text:r}=e,i=t??1;return{key:`preview:${n}`,path:n,display:`preview`,lines:iF({text:r,kind:`context`,oldStartLine:i,newStartLine:i}),rawText:r,oldStartLine:i,newStartLine:i}}function DR(e){if(Array.isArray(e.fullLines)&&e.fullLines.length>0)return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:e.fullLines,fullLines:e.fullLines,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}};if(e.beforeText==null&&e.afterText==null)return null;let t=cF({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:e.oldStartLine??void 0,newStartLine:e.newStartLine??void 0});return{key:`diff:${e.key}`,path:e.path,display:`diff`,lines:t,fullLines:t,...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{}}}function OR({text:e,tone:t=`muted`}){return(0,I.jsx)(`div`,{className:r(`flex h-full items-center justify-center px-6 text-center text-sm`,t===`error`?`text-rose-600`:`text-gray-500`),children:e})}function kR({diffBlock:e}){return e?(0,I.jsx)(AR,{block:e}):(0,I.jsx)(OR,{text:s(`chatWorkspaceDiffEmpty`)})}function AR({block:e}){return(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar bg-white`,children:(0,I.jsx)(zj,{block:e,layout:`workspace`})})}function jR({onFileOpen:e,previewBlock:t,previewKind:n,previewQuery:r,previewText:i}){return r.isLoading&&!t?(0,I.jsx)(OR,{text:s(`chatWorkspaceLoadingFile`)}):r.data?.kind===`binary`?(0,I.jsx)(OR,{text:s(`chatWorkspacePreviewUnsupported`)}):r.error&&!t?(0,I.jsx)(OR,{tone:`error`,text:r.error instanceof Error?r.error.message:String(r.error)}):n===`markdown`&&i?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar px-5 py-4`,children:(0,I.jsx)(kA,{text:i,role:`assistant`,texts:{copyCodeLabel:s(`chatCodeCopy`),copiedCodeLabel:s(`chatCodeCopied`)},onFileOpen:e})}):t?(0,I.jsx)(AR,{block:t}):(0,I.jsx)(OR,{text:s(`chatWorkspacePreviewEmpty`)})}function MR({file:e,sessionProjectRoot:t,onFileOpen:n}){let r=e.viewMode===`preview`,i=wR({path:e.path,basePath:t,enabled:r}),a=(0,F.useMemo)(()=>e.viewMode===`diff`?DR(e):null,[e]),o=r?i.data?.text??e.rawText??null:null,s=TR({path:i.data?.resolvedPath??e.path,serverKind:i.data?.kind}),c=(0,F.useMemo)(()=>!r||!o?null:ER({path:i.data?.resolvedPath??e.path,text:o,line:e.line}),[e.line,e.path,r,i.data?.resolvedPath,o]),l=i.data?.resolvedPath??e.path,u=!!i.data?.truncated;return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,I.jsx)(CR,{breadcrumb:(0,F.useMemo)(()=>kI({path:l,sessionProjectRoot:t,line:e.line,column:e.column,truncated:u}),[e.column,e.line,u,l,t])}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e.viewMode===`diff`?(0,I.jsx)(kR,{diffBlock:a}):(0,I.jsx)(jR,{onFileOpen:n,previewBlock:c,previewKind:s,previewQuery:i,previewText:o})})]})}var NR={open:!1,title:``,description:``,confirmLabel:s(`confirm`),cancelLabel:s(`cancel`),variant:`default`,resolve:null};function PR(){let[e,t]=(0,F.useState)(NR),n=(0,F.useCallback)(e=>new Promise(n=>{t({open:!0,title:e.title,description:e.description??``,confirmLabel:e.confirmLabel??s(`confirm`),cancelLabel:e.cancelLabel??s(`cancel`),variant:e.variant??`default`,resolve:e=>{n(e),t(e=>({...e,open:!1,resolve:null}))}})}),[]),r=(0,F.useCallback)(e=>{t(t=>(!e&&t.resolve&&t.resolve(!1),{...t,open:e,resolve:e?t.resolve:null}))},[]);return{confirm:n,ConfirmDialog:(0,F.useCallback)(()=>(0,I.jsx)(Yt,{open:e.open,onOpenChange:r,title:e.title,description:e.description||void 0,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,variant:e.variant,onConfirm:()=>e.resolve?.(!0),onCancel:()=>e.resolve?.(!1)}),[e,r])}}function FR(e){return u(e??void 0)}function IR(e){if(!e)return`-`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`-`;let n=Date.now(),r=t.getTime()-n,i=d(),a=Math.abs(r);if(a<6e4)return i===`zh`?`刚刚`:`just now`;if(a<36e5){let e=Math.round(a/6e4);return r>0?i===`zh`?`${e}分钟后`:`in ${e}m`:i===`zh`?`${e}分钟前`:`${e}m ago`}if(a<864e5){let e=Math.round(a/36e5);return r>0?i===`zh`?`${e}小时后`:`in ${e}h`:i===`zh`?`${e}小时前`:`${e}h ago`}let o=Math.round(a/864e5);return r>0?i===`zh`?`${o}天后`:`in ${o}d`:i===`zh`?`${o}天前`:`${o}d ago`}function LR(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:u(new Date(e))}function RR(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}var zR=[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`],BR=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function VR(e){return e.padStart(2,`0`)}function HR(e,t){let n=e.trim().split(/\s+/);if(n.length!==5)return null;let[r,i,a,o,s]=n,c=t===`zh`;if(r===`*`&&i===`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每分钟`:`every minute`;if(r.startsWith(`*/`)&&i===`*`&&a===`*`&&o===`*`&&s===`*`){let e=parseInt(r.slice(2),10);if(Number.isFinite(e)&&e>0)return c?`每 ${e} 分钟`:`every ${e}m`}if(r===`0`&&i===`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每小时`:`every hour`;let l=`${VR(i)}:${VR(r)}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&s===`*`)return c?`每天 ${l}`:`daily ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&s===`1-5`)return c?`工作日 ${l}`:`weekdays ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&(s===`0,6`||s===`6,0`))return c?`周末 ${l}`:`weekends ${l}`;if(r!==`*`&&i!==`*`&&a===`*`&&o===`*`&&/^\d$/.test(s)){let e=parseInt(s,10),t=c?zR[e]:BR[e];return t?`${t} ${l}`:null}return r!==`*`&&i!==`*`&&a!==`*`&&o===`*`&&s===`*`?c?`每月 ${a} 日 ${l}`:`monthly ${a} ${l}`:null}function UR(e){let t=d(),n=t===`zh`,{schedule:r}=e;if(r.kind===`cron`)return r.expr?HR(r.expr,t)??`cron ${r.expr}`:`cron`;if(r.kind===`every`){let e=RR(r.everyMs);return n?`每 ${e}`:`every ${e}`}return r.kind===`at`?`${n?`定时`:`at`} ${LR(r.atMs)}`:`-`}function WR(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function GR(e,t){let n=t?.trim();return!!(n&&e.payload.sessionId?.trim()===n)}function KR({jobs:e}){let t=Ei(),{confirm:n,ConfirmDialog:r}=PR(),i=async e=>{await n({title:`${s(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:s(`delete`)})&&t.mutate({id:e.id})};return(0,I.jsxs)(`div`,{className:`h-full overflow-y-auto custom-scrollbar px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:s(`chatWorkspaceSessionCronJobs`)}),(0,I.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500`,children:[s(`cronTotalLabel`),`: `,e.length]})]}),e.length===0?(0,I.jsx)(`div`,{className:`py-8 text-center text-sm text-gray-500`,children:s(`chatWorkspaceCronJobEmpty`)}):(0,I.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-400`,children:e.id})]}),(0,I.jsxs)(ye,{type:`button`,variant:`subtle`,size:`sm`,className:`h-7 gap-1 rounded-lg px-2`,onClick:()=>void i(e),disabled:t.isPending,children:[(0,I.jsx)(hn,{className:`h-3.5 w-3.5`}),s(`delete`)]})]}),(0,I.jsxs)(`div`,{className:`mt-3 space-y-1.5 text-xs text-gray-500`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronScheduleLabel`),`:`]}),` `,UR(e)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronNextRun`),`:`]}),` `,FR(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastRun`),`:`]}),` `,FR(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[s(`cronSessionLabel`),`:`]}),` `,WR(e)]})]}),(0,I.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-gray-700`,children:e.payload.message})]},e.id))}),(0,I.jsx)(r,{})]})}function qR({sessionKey:e,onToolAction:t,onFileOpen:n}){let r=gR(e),i=r.visibleMessages,a=(0,F.useRef)(null),{onScroll:o}=mj({scrollRef:a,resetKey:e,isLoading:r.isHydrating,hasContent:i.length>0,contentVersion:i[i.length-1]??null,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,className:`h-full overflow-y-auto custom-scrollbar`,children:r.isHydrating?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,I.jsx)($t,{className:`mr-2 h-4 w-4 animate-spin`}),s(`chatChildSessionLoading`)]}):r.hydrateError?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:r.hydrateError.message}):i.length===0&&!r.isRunning?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:s(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(gL,{messages:i,isSending:r.isRunning,onToolAction:t,onFileOpen:n})})})}function JR({value:e}){return(0,I.jsx)(`span`,{className:`inline-flex max-w-full items-center rounded border border-gray-200 bg-gray-50 px-2 py-0.5 text-[10px] font-medium text-gray-600`,children:(0,I.jsx)(`span`,{className:`truncate`,children:e})})}function YR({tab:e}){let t=[e.sessionTypeLabel,e.preferredModel,e.projectName].filter(e=>!!e?.trim());return t.length===0&&!e.projectRoot?null:(0,I.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[t.length>0?(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>(0,I.jsx)(JR,{value:e},e))}):null,e.projectRoot?(0,I.jsx)(`div`,{title:e.projectRoot,className:`truncate rounded border border-gray-200 bg-gray-50 px-2 py-1.5 font-mono text-[11px] text-gray-500`,children:e.projectRoot}):null]})}function XR({tab:e}){return(0,I.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[e.agentId?(0,I.jsx)(lL,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):(0,I.jsx)($n,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]}),(0,I.jsx)(YR,{tab:e})]})}function ZR(e){let{resolvedChildTabs:t,workspaceFileTabs:n,sessionCronJobCount:r,activeSelection:i,optimisticReadAtBySessionKey:a,onSelectSession:o,onSelectFile:c,onCloseFile:l,onSelectCronJobs:u}=e,d=t.map(e=>{let t=a[e.sessionKey],n=t&&e.readAt?t.localeCompare(e.readAt)>0?t:e.readAt:t??e.readAt;return{key:`child:${e.sessionKey}`,kind:`child-session`,title:e.title,tooltip:e.title,agentId:e.agentId,active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,showUnreadDot:XN({active:i?.kind===`child-session`&&i.tab.sessionKey===e.sessionKey,lastMessageAt:e.lastMessageAt,readAt:n,runStatus:e.runStatus}),onSelect:()=>o(e.sessionKey)}}),f=n.map(e=>({key:`file:${e.key}`,kind:`file`,title:_R(e),tooltip:e.path,viewMode:e.viewMode,active:i?.kind===`file`&&i.file.key===e.key,onSelect:()=>c(e.key),onClose:()=>l(e.key)})),p=r>0?[{key:`cron:session`,kind:`cron`,title:s(`chatWorkspaceSessionCronJobs`),tooltip:s(`chatWorkspaceSessionCronJobs`),active:i?.kind===`cron`,onSelect:u}]:[];return[...d,...f,...p]}function QR({sessionKey:e,childSessionTabs:t,activeChildSessionKey:n,workspaceFileTabs:i,activeWorkspaceFileKey:a,activePanelKind:o,sessionCronJobs:s=[],sessionProjectRoot:c,displayMode:l=`docked`}){let u=ic(),d=LL(t),f=eP(e=>e.optimisticReadAtBySessionKey),p=vR({activeChildSessionKey:n,activeWorkspaceFileKey:a,activePanelKind:o,childSessionTabs:d,workspaceFileTabs:i,sessionCronJobCount:s.length}),m=d.some(e=>!!e.parentSessionKey);(0,F.useEffect)(()=>{if(p?.kind!==`child-session`||p.tab.runStatus===`running`)return;let e=p.tab.lastMessageAt?.trim()??null;e&&u.chatSessionListManager.markSessionRead(p.tab.sessionKey,e,p.tab.readAt??null)},[p,u]);let h=(0,F.useMemo)(()=>ZR({resolvedChildTabs:d,workspaceFileTabs:i,sessionCronJobCount:s.length,activeSelection:p,optimisticReadAtBySessionKey:f,onSelectSession:u.chatThreadManager.selectChildSessionDetail,onSelectFile:u.chatThreadManager.selectWorkspaceFile,onCloseFile:u.chatThreadManager.closeWorkspaceFile,onSelectCronJobs:()=>{e&&u.chatThreadManager.openSessionCronPanel(e)}}),[p,f,u.chatThreadManager,d,e,i,s.length]);return p?(0,I.jsxs)(Zt,{className:r(l===`overlay`?`bg-white`:`hidden border-gray-200/70 bg-white/95 backdrop-blur-sm md:flex`),defaultWidth:480,minWidth:360,maxWidth:860,overlay:l===`overlay`,children:[(0,I.jsx)(xR,{tabs:h,onBack:m?u.chatThreadManager.goToParentSession:void 0,onClose:u.chatThreadManager.closeWorkspacePanel}),(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-white`,children:p.kind===`child-session`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XR,{tab:p.tab}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,I.jsx)(qR,{sessionKey:p.tab.sessionKey,onToolAction:u.chatThreadManager.openSessionFromToolAction,onFileOpen:u.chatThreadManager.openFilePreview})})]}):p.kind===`file`?(0,I.jsx)(MR,{file:p.file,sessionProjectRoot:c,onFileOpen:u.chatThreadManager.openFilePreview}):(0,I.jsx)(KR,{jobs:s})})]}):null}function $R({className:e,...t}){return(0,I.jsx)(`div`,{className:r(`animate-pulse rounded-md bg-slate-200`,e),...t})}var ez=[{key:`hero`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[78%] h-32 rounded-[30px]`},{key:`follow-up`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[62%] h-24 rounded-[28px]`},{key:`reply`,alignmentClassName:`justify-end`,bubbleClassName:`max-w-[70%] h-24 rounded-[28px]`},{key:`detail`,alignmentClassName:`justify-start`,bubbleClassName:`max-w-[88%] h-36 rounded-[30px]`}];function tz(){return(0,I.jsxs)(`section`,{"data-testid":`chat-conversation-skeleton`,className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,I.jsxs)(`div`,{className:`flex flex-1 flex-col gap-8`,children:[(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)($R,{className:`h-6 w-52 rounded-lg bg-gray-200/90`}),(0,I.jsx)(`div`,{className:`space-y-5`,children:ez.map(e=>(0,I.jsx)(`div`,{className:r(`flex w-full`,e.alignmentClassName),children:(0,I.jsx)($R,{"data-testid":`chat-conversation-skeleton-bubble`,className:r(`w-full bg-gray-200/80`,e.bubbleClassName)})},e.key))})]}),(0,I.jsxs)(`div`,{className:`mt-auto grid gap-4 pb-2 sm:grid-cols-[minmax(0,1fr)_minmax(180px,240px)] sm:items-end`,children:[(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)($R,{className:`h-4 w-40 rounded-full bg-gray-200/70`}),(0,I.jsx)($R,{className:`h-[112px] w-full rounded-[30px] bg-gray-200/70`})]}),(0,I.jsx)(`div`,{className:`hidden justify-end sm:flex`,children:(0,I.jsx)($R,{className:`h-10 w-36 rounded-full bg-gray-200/75`})})]})]})})}),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)($R,{className:`h-[84px] w-full rounded-[28px] bg-gray-200/80`})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)($R,{className:`h-8 w-20 rounded-full bg-gray-200/75`}),(0,I.jsx)($R,{className:`h-8 w-28 rounded-full bg-gray-200/75`}),(0,I.jsx)($R,{className:`hidden h-8 w-24 rounded-full bg-gray-200/70 sm:block`})]}),(0,I.jsx)($R,{className:`h-8 w-8 rounded-full bg-gray-200/85`})]})]})})})]})}function nz(){let e=ic(),t=Q(e=>e.snapshot);return(0,I.jsxs)(I.Fragment,{children:[t.isProviderStateResolved&&t.modelOptions.length===0?(0,I.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0 sm:px-5`,children:[(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:s(`chatModelNoOptions`)}),(0,I.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:s(`chatGoConfigureProvider`)})]}):null,t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()?(0,I.jsx)(`div`,{className:`px-4 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0 sm:px-5`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}):null]})}function rz(){let e=ic(),t=Z(e=>e.snapshot.defaultSessionType),n=Q(e=>e.snapshot),r=(0,F.useRef)(null),i=n.threadRef??r,a=n.availableAgents??[],o=!n.canDeleteSession&&!n.hasSubmittedDraftMessage&&n.messages.length===0&&!n.isSending,s=n.isHistoryLoading&&n.messages.length===0&&!n.isSending&&!n.isAwaitingAssistantOutput,c=e=>a.find(t=>t.id===e)??null,l=()=>{let r=ML(c(n.agentId??`main`),t);e.chatSessionListManager.createSession(r)},u=n=>{e.chatSessionListManager.setSelectedAgentId(n),e.chatInputManager.setPendingSessionType(ML(c(n),t))},{onScroll:d}=mj({scrollRef:i,resetKey:n.sessionKey,isLoading:n.isHistoryLoading,hasContent:n.messages.length>0,contentVersion:n.messages[n.messages.length-1]??null}),f=n.messages.length>0,p=f&&n.isSending&&n.isAwaitingAssistantOutput;return(0,I.jsx)(`div`,{ref:i,onScroll:d,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:o?(0,I.jsx)(tc,{onCreateSession:l,agents:a,selectedAgentId:n.agentId??`main`,onSelectAgent:u}):s||!f?null:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,I.jsx)(gL,{messages:n.messages,isSending:p,onToolAction:e.chatThreadManager.openSessionFromToolAction,onFileOpen:e.chatThreadManager.openFilePreview})})})}function iz(e,t,n,r){return e.workspacePanelParentKey===e.sessionKey?t.length>0||n.length>0||r>0:!1}function az(e){let t=(0,F.useMemo)(()=>e.childSessionTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.childSessionTabs,e.sessionKey]),n=(0,F.useMemo)(()=>e.workspaceFileTabs.filter(t=>t.parentSessionKey===e.sessionKey),[e.sessionKey,e.workspaceFileTabs]),r=Ti({all:!0}),i=(0,F.useMemo)(()=>(r.data?.jobs??[]).filter(t=>GR(t,e.sessionKey)),[r.data?.jobs,e.sessionKey]);return{childSessionTabs:t,workspaceFileTabs:n,sessionCronJobs:i,showWorkspacePanel:iz(e,t,n,i.length)}}function oz(){let e=ic(),t=Q(e=>e.snapshot);return(0,I.jsx)(OL,{parentSessionLabel:t.parentSessionKey?t.parentSessionLabel??null:null,onGoToParentSession:e.chatThreadManager.goToParentSession})}function sz({layoutMode:e,onBackToList:t}){let n=ic(),r=Q(e=>e.snapshot),{childSessionTabs:i,sessionCronJobs:a}=az(r),o=!!(r.sessionKey||r.sessionTypeLabel),c=r.sessionDisplayName||(r.canDeleteSession&&r.sessionKey?r.sessionKey:null)||s(`chatSidebarNewTask`),l=r.agentId?.trim()??``,u=l.length>0&&l.toLowerCase()!==`main`;return(0,I.jsx)(kL,{snapshot:r,childSessionCount:i.length,sessionCronJobCount:a.length,layoutMode:e,normalizedAgentId:l,sessionHeaderTitle:c,shouldShowHeaderAgentAvatar:u,shouldShowSessionHeader:o,onBackToList:t,onOpenChildSessions:()=>{r.sessionKey&&n.chatThreadManager.openChildSessionPanel({parentSessionKey:r.sessionKey,activeChildSessionKey:i[0]?.sessionKey??null})},onOpenSessionCronJobs:()=>{!r.sessionKey||a.length===0||n.chatThreadManager.openSessionCronPanel(r.sessionKey)},onDeleteSession:n.chatThreadManager.deleteSession})}function cz({layoutMode:e}){let t=Q(e=>e.snapshot),{childSessionTabs:n,workspaceFileTabs:r,sessionCronJobs:i,showWorkspacePanel:a}=az(t);return a?(0,I.jsx)(QR,{sessionKey:t.sessionKey,childSessionTabs:n,activeChildSessionKey:t.activeChildSessionKey??null,workspaceFileTabs:r,activeWorkspaceFileKey:t.activeWorkspaceFileKey??null,activePanelKind:t.activeWorkspacePanelKind??null,sessionCronJobs:i,sessionProjectRoot:t.sessionProjectRoot??null,displayMode:e===`mobile`?`overlay`:`docked`}):null}function lz({layoutMode:e=`desktop`,onBackToList:t}){return Q(e=>e.snapshot).isProviderStateResolved?(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,I.jsx)(oz,{}),(0,I.jsx)(sz,{layoutMode:e,onBackToList:t}),(0,I.jsx)(nz,{}),(0,I.jsx)(rz,{}),(0,I.jsx)(gP,{})]}),(0,I.jsx)(cz,{layoutMode:e})]}):(0,I.jsx)(tz,{})}var uz={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function dz({status:e,className:t}){let n=uz[e],i=s(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(sn,{delayDuration:250,children:(0,I.jsxs)(ln,{children:[(0,I.jsx)(nn,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":i,className:r(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)($t,{className:r(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:r(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(an,{side:`bottom`,className:`text-xs`,children:i})]})})}function fz(){let e=_L();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:s(`configSavedApplied`)})}}function pz(){let e=fz(),[t,n]=(0,F.useState)(null),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),s=e=>{n(e.key),i(e.label?.trim()??``)},c=()=>{n(null),i(``),o(null)};return{editingSessionKey:t,draftLabel:r,savingSessionKey:a,setDraftLabel:i,startEditingSessionLabel:s,cancelEditingSessionLabel:c,saveSessionLabel:async t=>{let n=r.trim();if(n===(t.label?.trim()??``)){c();return}o(t.key);try{await e({sessionKey:t.key,label:n||null}),c()}catch{o(null)}}}}function mz(e,t){return e.filter(e=>Xs(e,t))}function hz(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function gz(e={}){let t=eP(e=>e.snapshot.query),n=Ci({limit:e.limit??200}),r=(0,F.useMemo)(()=>mz(QI(n.data?.sessions??[]).filter(hz),t).map(e=>({session:e,runStatus:e.status===`running`?`running`:void 0})),[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}function _z(e){let{item:t,selectedSessionKey:n,optimisticReadAtBySessionKey:r,agentsById:i,childSessionsByParentKey:a,editingSessionKey:o,draftLabel:s,savingSessionKey:c,sessionTitle:l,onSelectSession:u,onOpenChildSessions:d,onStartEditingSessionLabel:f,onDraftLabelChange:p,onSaveSessionLabel:m,onCancelEditingSessionLabel:h}=e,{session:g,runStatus:_}=t,v=Z(e=>e.snapshot),y=n===g.key,b=r[g.key],x=b&&g.readAt?b.localeCompare(g.readAt)>0?b:g.readAt:b??g.readAt,S=a.get(g.key)??[];return(0,I.jsx)($s,{session:g,active:y,showUnreadDot:XN({active:y,lastMessageAt:g.lastMessageAt,readAt:x,runStatus:_}),runStatus:_,context:ks(g,v.sessionTypeOptions),title:l(g),agentId:g.agentId??null,agentLabel:g.agentId?i.get(g.agentId)?.displayName??g.agentId:null,agentAvatarUrl:g.agentId?i.get(g.agentId)?.avatarUrl??null:null,childSessionCount:S.length,isEditing:o===g.key,draftLabel:s,isSaving:c===g.key,onSelect:()=>u(g.key),onOpenChildSessions:()=>d(g.key,S[0]?.session.key??null),onStartEditing:()=>f(g),onDraftLabelChange:p,onSave:()=>m(g),onCancel:h})}function vz(e){let t=e.sessionTypeOptions.find(t=>t.value===e.defaultSessionType);return[...t?[t]:[],...e.nonDefaultSessionTypeOptions]}function yz(e){let{query:t,defaultSessionType:n,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(ye,{variant:`primary`,className:r(`min-w-0 rounded-xl`,i.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{o(!1),c(n)},children:[(0,I.jsx)(pn,{className:`mr-2 h-4 w-4`}),s(`chatSidebarNewTask`)]}),i.length>0?(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":s(`chatSessionTypeLabel`),children:(0,I.jsx)(Ln,{className:`h-4 w-4`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-56 rounded-2xl border border-gray-200/80 bg-white p-1.5 shadow-[0_24px_60px_-28px_rgba(15,23,42,0.38)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-gray-400`,children:s(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>(0,I.jsx)(Is,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(mn,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-lg pl-8 text-xs`})]})})]})}function bz(e){let{query:t,defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i,isCreateMenuOpen:a,onCreateMenuOpenChange:o,onCreateSession:c,onQueryChange:l}=e,u=vz({defaultSessionType:n,sessionTypeOptions:r,nonDefaultSessionTypeOptions:i}),d=u.length>1;return(0,I.jsx)(`div`,{className:`px-4 pb-2 pt-1`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,I.jsx)(mn,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(Ne,{value:t,onChange:e=>l(e.target.value),placeholder:s(`chatSidebarSearchPlaceholder`),className:`h-9 rounded-full border-transparent bg-gray-100/80 pl-9 pr-3 text-[13px] shadow-none focus:border-gray-200/80 focus:bg-white`})]}),d?(0,I.jsxs)(wn,{open:a,onOpenChange:o,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),children:(0,I.jsx)(pn,{className:`h-4 w-4`})})}),(0,I.jsxs)(bn,{align:`end`,className:`w-60 rounded-3xl border border-gray-200/80 bg-white p-2 shadow-[0_24px_70px_-30px_rgba(15,23,42,0.45)]`,children:[(0,I.jsx)(`div`,{className:`px-3 pb-1.5 pt-2 text-[11px] font-medium text-gray-400`,children:s(`chatSidebarNewTask`)}),(0,I.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,I.jsx)(Is,{option:e,onSelect:()=>{c(e.value),o(!1)}},e.value))})]})]}):(0,I.jsx)(ye,{variant:`ghost`,size:`icon`,className:`h-9 w-9 shrink-0 rounded-full bg-gray-100/80 text-gray-700 shadow-none hover:bg-gray-200/80 hover:text-gray-900`,"aria-label":s(`chatSidebarNewTask`),onClick:()=>c(n),children:(0,I.jsx)(pn,{className:`h-4 w-4`})})]})})}function xz({isOpen:e,onOpenChange:t,currentTheme:n,currentThemeLabel:r,themeOptions:i,onSelectTheme:a,currentLanguage:o,currentLanguageLabel:c,languageOptions:l,onSelectLanguage:u,onOpenDocs:d,onOpenApps:f}){let p=()=>{d(),t(!1)},m=()=>{f(),t(!1)};return(0,I.jsxs)(wn,{open:e,onOpenChange:t,children:[(0,I.jsx)(Sn,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-label":o===`zh`?`设置菜单`:`Settings menu`,className:`flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-[13px] font-medium text-gray-600 transition-all duration-base hover:bg-gray-200/60 hover:text-gray-800`,children:[(0,I.jsx)(_r,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:s(`settings`)}),(0,I.jsxs)(`span`,{className:`max-w-[112px] truncate text-[13px] text-gray-500`,children:[r,` / `,c]})]})}),(0,I.jsxs)(bn,{side:`top`,align:`start`,className:`w-64 p-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(w,{to:`/settings`,onClick:()=>t(!1),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(_r,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`settings`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(Qt,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`docBrowserHelp`)})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:m,className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] font-medium text-gray-700 transition-colors hover:bg-gray-100`,children:[(0,I.jsx)(un,{className:`h-4 w-4 text-gray-400`}),(0,I.jsx)(`span`,{className:`flex-1 text-left`,children:s(`appsTitle`)})]})]}),(0,I.jsx)(`div`,{className:`my-2 h-px bg-gray-200/70`}),(0,I.jsx)(Sz,{icon:pr,label:s(`theme`),options:i,value:n,valueLabel:r,onSelect:a,onCloseMenu:()=>t(!1)}),(0,I.jsx)(Sz,{icon:cr,label:s(`language`),options:l,value:o,valueLabel:c,onSelect:u,onCloseMenu:()=>t(!1)})]})]})}function Sz({icon:e,label:t,options:n,value:r,valueLabel:i,onSelect:a,onCloseMenu:o}){return(0,I.jsxs)(vo,{value:r,onOpenChange:e=>{e||o()},onValueChange:e=>a(e),children:[(0,I.jsxs)(bo,{"aria-label":t,className:`h-auto w-full rounded-lg border-0 bg-transparent px-3 py-2 text-[13px] font-medium text-gray-700 shadow-none hover:bg-gray-100 focus:ring-0`,indicator:(0,I.jsx)(Rn,{className:`h-4 w-4 text-gray-400`}),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,I.jsx)(`span`,{className:`text-left`,children:t})]}),(0,I.jsx)(`span`,{className:`ml-auto max-w-[96px] truncate text-[13px] text-gray-500`,children:i})]}),(0,I.jsx)(Co,{side:`right`,align:`center`,sideOffset:6,className:`z-[var(--z-tooltip)] min-w-[7rem] rounded-lg`,viewportClassName:`h-auto min-w-[7rem] w-auto`,children:n.map(e=>(0,I.jsx)(To,{value:e.value,className:`text-[13px]`,children:e.label},e.value))})]})}function Cz(e){return new Date(e.session.lastMessageAt??e.session.createdAt).getTime()}function wz(e){return[...e].sort((e,t)=>Cz(t)-Cz(e))}function Tz(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],o=[],c=[],l=[];for(let t of e){let e=Cz(t);e>=n?a.push(t):e>=r?o.push(t):e>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:s(`chatSidebarToday`),items:a}),o.length>0&&u.push({label:s(`chatSidebarYesterday`),items:o}),c.length>0&&u.push({label:s(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:s(`chatSidebarOlder`),items:l}),u}function Ez(e){let t=new Map;for(let n of e){let e=n.session.projectRoot?.trim();if(!e)continue;let r=t.get(e),i=Cz(n);if(r){r.items.push(n),r.latestUpdatedAt=Math.max(r.latestUpdatedAt,i);continue}t.set(e,{projectRoot:e,projectName:n.session.projectName?.trim()||SI(e)||e,items:[n],latestUpdatedAt:i})}return[...t.values()].map(e=>({...e,items:wz(e.items)})).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)}function Dz(e){let t=new Map;for(let n of e){let e=n.session.parentSessionId?.trim();if(!e)continue;let r=t.get(e)??[];r.push(n),t.set(e,r)}for(let e of t.values())e.sort((e,t)=>Cz(t)-Cz(e));return t}function Oz(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}var kz=[{target:`/cron`,label:()=>s(`chatSidebarScheduledTasks`),icon:jn},{target:`/skills`,label:()=>s(`chatSidebarSkills`),icon:E},{target:`/agents`,label:()=>s(`agentsPageTitle`),icon:Pn}];function Az(e,t,n){let r=eP(e=>e.optimisticReadAtBySessionKey);return(0,F.useEffect)(()=>{(()=>{if(!t)return;let r=e.find(({session:e})=>e.key===t);if(!r||r.runStatus===`running`)return;let{session:i}=r;n(i.key,i.lastMessageAt,i.readAt)})()},[e,n,t]),r}function jz({variant:e=`desktop`}){let n=e===`mobile`,i=ic(),a=Dn(),[o,c]=(0,F.useState)(!1),[l,u]=(0,F.useState)(!1),d=Z(e=>e.snapshot),f=eP(e=>e.snapshot),p=bt(),m=iL(),{isLoading:h,items:g}=gz(),{language:_,setLanguage:v}=kr(),{theme:y,setTheme:b}=es(),x=s(qr.find(e=>e.value===y)?.labelKey??`themeWarm`),S=t.find(e=>e.value===_)?.label??_,C=(0,F.useMemo)(()=>qr.map(e=>({value:e.value,label:s(e.labelKey)})),[]),w=(0,F.useMemo)(()=>t.map(e=>({value:e.value,label:e.label})),[]),T=(0,F.useMemo)(()=>new Map((m.data?.agents??[]).map(e=>[e.id,e])),[m.data?.agents]),E=(0,F.useMemo)(()=>wz(g),[g]),D=(0,F.useMemo)(()=>Dz(g),[g]),O=(0,F.useMemo)(()=>Tz(E),[E]),k=(0,F.useMemo)(()=>Ez(E),[E]),A=d.defaultSessionType||`native`,ee=(0,F.useMemo)(()=>d.sessionTypeOptions.filter(e=>e.value!==A),[A,d.sessionTypeOptions]),j=f.listMode===`project-first`,te=Az(g,f.selectedSessionKey,i.chatSessionListManager.markSessionRead),{editingSessionKey:M,draftLabel:ne,savingSessionKey:re,setDraftLabel:ie,startEditingSessionLabel:ae,cancelEditingSessionLabel:se,saveSessionLabel:ce}=pz(),le=e=>{_!==e&&(v(e),window.location.reload())},ue=e=>(0,I.jsx)(_z,{item:e,selectedSessionKey:f.selectedSessionKey,optimisticReadAtBySessionKey:te,agentsById:T,childSessionsByParentKey:D,editingSessionKey:M,draftLabel:ne,savingSessionKey:re,sessionTitle:Oz,onSelectSession:i.chatSessionListManager.selectSession,onOpenChildSessions:(e,t)=>i.chatThreadManager.openChildSessionPanel({parentSessionKey:e,activeChildSessionKey:t}),onStartEditingSessionLabel:ae,onDraftLabelChange:ie,onSaveSessionLabel:ce,onCancelEditingSessionLabel:se},e.session.key),de=(e,t)=>{i.chatSessionListManager.createSession(e,typeof t==`string`?t:void 0)};return(0,I.jsxs)(`aside`,{className:r(`flex h-full min-h-0 flex-col bg-secondary`,n?`flex-1 overflow-hidden`:`w-[280px] shrink-0 border-r border-gray-200/60`),children:[!n&&!ls()?(0,I.jsx)(`div`,{className:`px-5 py-2.5`,children:(0,I.jsx)(ji,{className:`flex min-w-0 items-center gap-2`,suffix:(0,I.jsx)(dz,{status:p.connectionStatus})})}):null,n?(0,I.jsx)(bz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}):(0,I.jsx)(yz,{query:f.query,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,nonDefaultSessionTypeOptions:ee,isCreateMenuOpen:o,onCreateMenuOpenChange:c,onCreateSession:de,onQueryChange:i.chatSessionListManager.setQuery}),n?null:(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:kz.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(ko,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),n?null:(0,I.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-5 pb-2 pt-3`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:s(`chatSidebarTaskRecords`)}),(0,I.jsx)(_s,{isProjectFirstView:j,onSelectMode:i.chatSessionListManager.setListMode})]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:h?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:s(`sessionsLoading`)}):j?k.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(ur,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`chatSidebarProjectViewEmpty`)})]}):(0,I.jsx)(Rs,{groups:k,defaultSessionType:A,sessionTypeOptions:d.sessionTypeOptions,renderSessionItem:ue,onCreateSession:de}):O.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(ur,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:s(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:O.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:e.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:e.items.map(ue)})]},e.label))})}),n?null:(0,I.jsx)(`div`,{className:`px-3 py-3 border-t border-gray-200/60`,children:(0,I.jsx)(xz,{isOpen:l,onOpenChange:u,currentTheme:y,currentThemeLabel:x,themeOptions:C,onSelectTheme:b,currentLanguage:_,currentLanguageLabel:S,languageOptions:w,onSelectLanguage:le,onOpenDocs:()=>a.open(void 0,{kind:`docs`,title:s(`docBrowserHelp`)}),onOpenApps:()=>oe(a)})})]})}function Mz(){return Ve({queryKey:[`ncp-session-types`],queryFn:Be,staleTime:1e4,retry:!1})}function Nz(e){let t=e.trim();return t.length>0?t:null}function Pz(e){return e??null}var Fz=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Z.getState().snapshot,t=eP.getState().snapshot,n=Q.getState().snapshot,r=t.selectedSessionKey;!r||!n.canDeleteSession||this.enqueue({sessionKey:r,patch:{preferredModel:Nz(e.selectedModel),preferredThinking:Pz(e.selectedThinkingLevel)}})},this.enqueue=e=>{this.queued=e,!this.inFlight&&this.startFlush()},this.startFlush=()=>{this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})},this.flush=async()=>{for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}}},Iz=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.sessionListManager=n,this.sessionPreferenceSync=new Fz(gt),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Z.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.isRuntimeBlockedForSend=()=>aP(vt.getStatusView()),this.syncComposerSnapshot=e=>{let t=Z.getState().snapshot.attachments,n=PN(e,t);Z.getState().setSnapshot({composerNodes:e,attachments:n,draft:kN(e),selectedSkills:AN(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Z.getState().setSnapshot({composerNodes:e,attachments:t,draft:kN(e),selectedSkills:AN(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Z.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Z.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Z.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(ON(n))},this.requestComposerFocusAtEnd=()=>{let e=Z.getState().snapshot.composerFocusRequest;Z.getState().setSnapshot({composerFocusRequest:{id:(e?.id??0)+1,placement:`end`}})},this.consumeComposerFocusRequest=e=>{Z.getState().snapshot.composerFocusRequest?.id===e&&Z.getState().setSnapshot({composerFocusRequest:null})},this.setComposerNodes=e=>{let t=Z.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let{snapshot:t}=Z.getState(),n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=NN(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=NN(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Z.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Z.getState().snapshot,t=eP.getState().snapshot,n=Q.getState().snapshot,r=e.draft.trim(),{attachments:i}=e,a=FN(e.composerNodes,i);if(WN({snapshot:e,hasSendableDraft:a.some(e=>e.type!==`text`||e.text.trim().length>0),isRuntimeBlocked:this.isRuntimeBlockedForSend()}))return;let{selectedSkills:o,composerNodes:s}=e,c=n.sessionKey??t.selectedSessionKey??null;!c&&e.selectedSessionType?.trim()&&this.sessionListManager.ensureDraftSession(e.selectedSessionType),this.setComposerNodes(DN()),await this.streamActionsManager.sendMessage({message:r,...c?{sessionKey:c}:{},agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:o,attachments:i,parts:a,restoreDraftOnError:!0,composerNodes:s})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Z.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Z.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Z.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Z.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=jL(e);Z.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let{snapshot:t}=Z.getState(),{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(MN(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),RN.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{zN.remember(e)},this.selectSkills=e=>{let t=Z.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let{snapshot:t}=Z.getState(),n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Z.getState().setSnapshot({selectedThinkingLevel:i})}}},Lz=`sid_`,Rz=`/chat/draft`,zz=Rz.slice(6);function Bz(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Lz}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function Vz(e){if(!e.startsWith(Lz))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=`=`.repeat((4-t.length%4)%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Hz(e){if(!e||e===zz)return null;let t=Vz(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Uz(e){return`/chat/${Bz(e)}`}var Wz=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.syncDraftThreadState=(e=!1)=>{Q.getState().setSnapshot({sessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,hasSubmittedDraftMessage:e,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.shouldPersistReadAt=(e,t,n)=>{let r=eP.getState().optimisticReadAtBySessionKey[e],i=r&&n?r.localeCompare(n)>0?r:n:r??n??void 0;return i?t.localeCompare(i)>0:!0},this.setSelectedAgentId=e=>{let t=eP.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&eP.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=eP.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&eP.getState().setSnapshot({selectedSessionKey:n})},this.setListMode=e=>{let t=eP.getState().snapshot.listMode,n=this.resolveUpdateValue(t,e);n!==t&&eP.getState().setSnapshot({listMode:n})},this.markSessionRead=(e,t,n)=>{let r=e?.trim(),i=t?.trim();!r||!i||this.shouldPersistReadAt(r,i,n)&&(eP.getState().markSessionRead(r,i),gt(r,{uiReadAt:i}).catch(()=>void 0))},this.createSession=(e,t)=>{let{snapshot:n}=Z.getState(),{defaultSessionType:r}=n,i=r||`native`,a=typeof e==`string`&&e.trim().length>0?e.trim():i,o=xI(t);this.streamActionsManager.resetStreamState(),eP.getState().setSnapshot({selectedSessionKey:null}),this.syncDraftThreadState(),Z.getState().setSnapshot({pendingSessionType:a,pendingProjectRoot:o,pendingProjectRootSessionKey:null}),this.uiManager.navigateTo(Rz)},this.startAgentDraftChat=(e,t)=>{let n=e.trim()||`main`;this.createSession(t),this.setSelectedAgentId(n)},this.ensureDraftSession=e=>{let{snapshot:t}=eP.getState();if(t.selectedSessionKey)return t.selectedSessionKey;let n=typeof e==`string`&&e.trim().length>0?e.trim():null;return this.syncDraftThreadState(!0),n&&Z.getState().setSnapshot({pendingSessionType:n}),null},this.materializeRootSessionRoute=e=>{let t=e.trim();t&&this.uiManager.isAtChatRoot()&&this.uiManager.goToSession(t,{replace:!0})},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=eP.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&eP.getState().setSnapshot({query:n})}}},Gz=async()=>{},Kz=()=>{},qz=class{constructor(){this.actions={sendMessage:Gz,stopCurrentRun:Gz,resumeRun:Gz,resetStreamState:Kz,applyHistoryMessages:Kz},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},Jz=async e=>!1,Yz=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:Jz},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.isAtChatRoot=()=>this.state.pathname===`/chat`||this.state.pathname===`/chat/draft`,this.goToSession=(e,t)=>{this.navigateTo(Uz(e),t)}}},Xz=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&Q.getState().setSnapshot(e)},this.clearDeletedSessionState=e=>{eP.getState().snapshot.selectedSessionKey===e&&this.sessionListManager.setSelectedSessionKey(null),Q.getState().setSnapshot({sessionKey:null,sessionTypeLabel:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,workspacePanelParentKey:null,activeWorkspacePanelKind:null,childSessionTabs:[],activeChildSessionKey:null,workspaceFileTabs:[],activeWorkspaceFileKey:null})},this.resolveWorkspaceParentSessionKey=()=>Q.getState().snapshot.sessionKey?.trim()||(eP.getState().snapshot.selectedSessionKey??null),this.buildWorkspaceFileTab=(e,t)=>{let n=e.path.trim();if(!n)return null;let r=t?.trim()||null;return{key:`${r??`draft`}::${e.viewMode}::${n}`,parentSessionKey:r,path:n,label:e.label?.trim()||null,viewMode:e.viewMode,line:e.line??null,column:e.column??null,rawText:e.rawText??null,beforeText:e.beforeText??null,afterText:e.afterText??null,patchText:e.patchText??null,oldStartLine:e.oldStartLine??null,newStartLine:e.newStartLine??null,fullLines:e.fullLines}},this.upsertWorkspaceFileTab=e=>{let{workspaceFileTabs:t}=Q.getState().snapshot,n=t.findIndex(t=>t.key===e.key);if(n===-1)return[e,...t];let r=[...t];return r.splice(n,1),r.unshift({...t[n],...e}),r},this.ensureWorkspaceParentRoute=e=>{if(!e)return;let{snapshot:{selectedSessionKey:t}}=eP.getState();t!==e&&this.uiManager.goToSession(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.openChildSessionPanel=e=>{let t=e.parentSessionKey.trim();if(!t)return;let n=e.activeChildSessionKey?.trim()||null;Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`child-session`,activeChildSessionKey:n,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t)},this.openFilePreview=e=>{let t=this.resolveWorkspaceParentSessionKey(),n=this.buildWorkspaceFileTab(e,t);n&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`file`,workspaceFileTabs:this.upsertWorkspaceFileTab(n),activeWorkspaceFileKey:n.key,activeChildSessionKey:null}),this.ensureWorkspaceParentRoute(t))},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||eP.getState().snapshot.selectedSessionKey||null;if(t){this.openChildSessionPanel({parentSessionKey:t,activeChildSessionKey:e.sessionId});return}}Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=Q.getState().snapshot;n.some(e=>e.sessionKey===t)&&Q.getState().setSnapshot({activeChildSessionKey:t,activeWorkspaceFileKey:null,activeWorkspacePanelKind:`child-session`})},this.selectWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{workspaceFileTabs:n}=Q.getState().snapshot;n.some(e=>e.key===t)&&Q.getState().setSnapshot({activeWorkspaceFileKey:t,activeChildSessionKey:null,activeWorkspacePanelKind:`file`})},this.closeWorkspaceFile=e=>{let t=e.trim();if(!t)return;let{snapshot:n}=Q.getState(),{activeWorkspaceFileKey:r,workspaceFileTabs:i}=n,a={workspaceFileTabs:i.filter(e=>e.key!==t)};r===t&&(a.activeWorkspaceFileKey=null),Q.getState().setSnapshot(a)},this.closeWorkspacePanel=()=>{Q.getState().setSnapshot({workspacePanelParentKey:null,activeWorkspacePanelKind:null,activeChildSessionKey:null,activeWorkspaceFileKey:null})},this.openSessionCronPanel=e=>{let t=e.trim();t&&(Q.getState().setSnapshot({workspacePanelParentKey:t,activeWorkspacePanelKind:`cron`,activeChildSessionKey:null,activeWorkspaceFileKey:null}),this.ensureWorkspaceParentRoute(t))},this.closeChildSessionDetail=()=>{this.closeWorkspacePanel()},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=Q.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeWorkspacePanel(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>Nr.getSnapshot().mode===`mobile`,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=eP.getState();if(e&&await this.uiManager.confirm({title:s(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:s(`delete`)})){Q.getState().setSnapshot({isDeletePending:!0});try{await ct(e),et(De,e),De.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.clearDeletedSessionState(e),this.uiManager.goToChatRoot({replace:!0})}finally{Q.getState().setSnapshot({isDeletePending:!1})}}}}},Zz=class{constructor(){this.chatUiManager=new Yz,this.chatStreamActionsManager=new qz,this.chatSessionListManager=new Wz(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Iz(this.chatUiManager,this.chatStreamActionsManager,this.chatSessionListManager),this.chatThreadManager=new Xz(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.startAgentCreationDraft=e=>{this.chatSessionListManager.createSession(),this.chatSessionListManager.setSelectedAgentId(`main`),this.chatInputManager.setDraft(e),this.chatInputManager.requestComposerFocusAtEnd()}}};function Qz(e){return e?.trim().toLowerCase()||`native`}function $z(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function eB(e,t){return typeof t==`string`&&e.includes(t)}function tB(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function nB(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function rB(e){let{modelOptions:t,currentSelectedModel:n,selectedSessionPreferredModel:r,fallbackPreferredModel:i,defaultModel:a,preferSessionPreferredModel:o,preserveCurrentSelectedModelOnSessionChange:s}=e;return t.length===0?``:nB({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>$z(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function iB(e){let{supportedThinkingLevels:t,currentSelectedThinkingLevel:n,selectedSessionPreferredThinking:r,fallbackPreferredThinking:i,defaultThinkingLevel:a,preferSessionPreferredThinking:o,preserveCurrentSelectedThinkingOnSessionChange:s}=e;return t.length===0?null:nB({currentValue:n,selectedSessionPreferredValue:r,fallbackPreferredValue:i,defaultValue:a,isValueSupported:e=>eB(t,e),firstAvailableValue:tB(t)??`off`,preferSessionPreferredValue:o,preserveCurrentValueOnSessionChange:s})}function aB(e){let{sessions:t,selectedSessionKey:n,sessionType:r,readPreference:i}=e,a=Qz(r),o,s=-1/0;for(let e of t){if(e.key===n||Qz(e.sessionType)!==a)continue;let t=i(e);if(t==null)continue;let r=Date.parse(e.updatedAt),c=Number.isFinite(r)?r:-1/0;(o===void 0||c>s)&&(o=t,s=c)}return o}function oB(e){return e.map(e=>e==null?``:String(e)).join(``)}function sB(e){let{isPreferenceAvailable:t,emptyValue:n,syncKey:r,selectedSessionKey:i,selectedSessionExists:a=!1,setValue:o,resolveValue:s}=e,c=(0,F.useRef)(void 0),l=(0,F.useRef)(s),u=(0,F.useRef)(n);(0,F.useEffect)(()=>{l.current=s},[s]),(0,F.useEffect)(()=>{let e=c.current!==i;if(!t){o(n),u.current=n,c.current=i;return}o(t=>{let r=l.current({currentValue:!e&&Object.is(t,u.current)?n:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!i&&!a});return u.current=r,r}),c.current=i},[n,t,a,i,o,r])}function cB(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;sB({isPreferenceAvailable:t.length>0,emptyValue:``,syncKey:oB([t.map(e=>e.value).join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>rB({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function lB(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;sB({isPreferenceAvailable:t.length>0,emptyValue:null,syncKey:oB([t.join(``),i,a,o]),selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>iB({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function uB(){let{pathname:e}=S(),t=C();return Br(e)?(0,I.jsx)(lz,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,I.jsx)(jz,{variant:`mobile`})}var dB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DocBrowser:e}=await import(`./doc-browser-D5FJcAyz.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).DocBrowser}));function fB({pathname:e,isMobileLayout:t=!1,isDocBrowserOpen:n,docBrowserMode:i,docBrowserDockControls:a,docBrowserRenderers:o={},sideDock:s,children:c}){let l=zr(e),u=t&&!Br(e),d=ls();return(0,I.jsxs)(`div`,{className:r(`h-screen flex flex-col overflow-hidden bg-background font-sans text-foreground`,d?`rounded-[10px]`:null),style:d?{"--desktop-titlebar-height":`40px`,"--desktop-caption-safe-right":`140px`,"--desktop-sidebar-width":l?`280px`:`240px`}:void 0,children:[d?(0,I.jsx)(as,{}):null,(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[!l&&(0,I.jsx)(rs,{mode:`settings`}),(0,I.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,I.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:l?(0,I.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:c}):(0,I.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:c})})}),n&&i===`docked`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(dB,{customTabRenderers:o,dockControls:a})}):null,s]})]}),u?(0,I.jsx)(fs,{}):null,n&&i===`floating`?(0,I.jsx)(F.Suspense,{fallback:null,children:(0,I.jsx)(dB,{customTabRenderers:o,dockControls:a})}):null]})}var pB=`NextClaw`,mB=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function hB(e,t){return e===t||e.startsWith(`${t}/`)}function gB(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of mB)if(hB(t,e))return s(n);return s(`settings`)}function _B(e){return`${pB} - ${gB(e)}`}function vB({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=Dn();Er();let{pathname:i}=S(),{language:a}=kr(),{isMobile:o}=Pr(),s=cs();A(e=>e.pinnedItems);let c={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,F.useEffect)(()=>{document.title=_B(i)},[i,a]),o&&s!==`win32`?(0,I.jsx)(hs,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:c,docBrowserRenderers:ie,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,I.jsx)(fB,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:c,docBrowserRenderers:ie,sideDock:(0,I.jsx)(j,{manager:t}),children:e})}function yB({children:e}){let t=ae();return(0,I.jsx)(kn,{manager:t.docBrowserManager,children:(0,I.jsx)(vB,{sideDockManager:t.sideDockManager,children:e})})}function bB(){let{isMobile:e}=Pr();return e?(0,I.jsx)(gs,{}):(0,I.jsx)(T,{to:`/model`,replace:!0})}function xB(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function SB(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function CB(e,t){e&&xB(t)&&e.invalidateQueries({queryKey:[`config`]}),SB(e,t)}function wB(e){let t=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let n=Xe.eventBus.on(Re.connectionOpen,()=>{vt.handleConnectionRestored(),at.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=Xe.eventBus.on(Re.connectionClose,()=>{vt.handleConnectionInterrupted(null),t.current=!0}),i=Xe.eventBus.on(Re.connectionError,e=>{vt.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=Xe.eventBus.on(Re.configUpdated,({path:t})=>{CB(e,t)}),o=Xe.eventBus.on(Re.runtimeUpdateSnapshot,e=>{at.reportSnapshot(e)}),s=Xe.eventBus.on(Re.sessionRunStatus,t=>{Ze(e,{type:`session.run-status`,payload:t})}),c=Xe.eventBus.on(Re.sessionSummaryUpsert,t=>{Ze(e,{type:`session.summary.upsert`,payload:t})}),l=Xe.eventBus.on(Re.sessionSummaryDelete,t=>{Ze(e,{type:`session.summary.delete`,payload:t})}),u=Xe.eventBus.on(Re.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var TB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ModelConfig:e}=await import(`./model-config-B-qg70S4.js`);return{ModelConfig:e}},__vite__mapDeps([12,2,13,14,3,15,16,11,17]))).ModelConfig})),EB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChatPage:e}=await import(`./chat-page-YKdeGoVx.js`);return{ChatPage:e}},__vite__mapDeps([18,2,19,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28,29,30,15,16,31,32,33]))).ChatPage})),DB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SearchConfig:e}=await import(`./search-config-BRsrQ4zK.js`);return{SearchConfig:e}},__vite__mapDeps([34,2,13,7,3,23,9,35,6]))).SearchConfig})),OB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ProvidersList:e}=await import(`./providers-list-cBeeslbc.js`);return{ProvidersList:e}},__vite__mapDeps([36,2,3,20,21,5,13,10,22,31,23,8,9,25,35,6,27,17,16]))).ProvidersList})),kB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-bkKDqaO5.js`);return{ChannelsList:e}},__vite__mapDeps([37,2,3,13,14,7,23,9,10,35,6,27,33,28,30,17]))).ChannelsList})),AB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-DYH2ejUI.js`);return{RuntimeConfig:e}},__vite__mapDeps([38,2,13,14,3,32,8,39,40,25,26]))).RuntimeConfig})),jB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-CLXdVz9r.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([41,2,13,7,3,24,39]))).DesktopUpdateConfig})),MB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecurityConfig:e}=await import(`./api-DmxQnm30.js`).then(e=>e.ut);return{SecurityConfig:e}},__vite__mapDeps([13,2]))).SecurityConfig})),NB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-eYdx5_AW.js`);return{SecretsConfig:e}},__vite__mapDeps([42,2,13,8,3,40,25]))).SecretsConfig})),PB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{RemoteAccessPage:e}=await import(`./remote-DjhVMpVd.js`);return{RemoteAccessPage:e}},__vite__mapDeps([43,19,2,3,20,21,5,13,10,22,4,6,14,23,8,24,25,11,26,27,28]))).RemoteAccessPage})),FB=(0,F.lazy)(async()=>({default:(await ue(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-ooEvG_bB.js`);return{McpMarketplacePage:e}},__vite__mapDeps([44,29,2,3,20,21,5,13,10,11,26,30]))).McpMarketplacePage}));function IB(){return(0,I.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function LB({children:e}){return(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(IB,{}),children:e})}function RB(e){return(0,I.jsx)(LB,{children:e})}var zB=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:RB((0,I.jsx)(EB,{view:`chat`}))},{path:`/agents`,element:RB((0,I.jsx)(EB,{view:`agents`}))},{path:`/skills`,element:RB((0,I.jsx)(EB,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:RB((0,I.jsx)(EB,{view:`skills`}))},{path:`/cron`,element:RB((0,I.jsx)(EB,{view:`cron`}))},{path:`/model`,element:RB((0,I.jsx)(TB,{}))},{path:`/search`,element:RB((0,I.jsx)(DB,{}))},{path:`/providers`,element:RB((0,I.jsx)(OB,{}))},{path:`/channels`,element:RB((0,I.jsx)(kB,{}))},{path:`/runtime`,element:RB((0,I.jsx)(AB,{}))},{path:`/updates`,element:RB((0,I.jsx)(jB,{}))},{path:`/remote`,element:RB((0,I.jsx)(PB,{}))},{path:`/security`,element:RB((0,I.jsx)(MB,{}))},{path:`/secrets`,element:RB((0,I.jsx)(NB,{}))},{path:`/language`,element:(0,I.jsx)(ns,{})},{path:`/settings`,element:(0,I.jsx)(bB,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:RB((0,I.jsx)(FB,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function BB(e){return`redirectTo`in e?(0,I.jsx)(D,{path:e.path,element:(0,I.jsx)(T,{to:e.redirectTo,replace:!0})},e.path):(0,I.jsx)(D,{path:e.path,element:e.element},e.path)}function VB(){return(0,I.jsx)(x,{children:zB.map(BB)})}function HB(){return wB(De),Ye(),(0,F.useEffect)(()=>(at.start(),()=>{at.stop()}),[]),(0,I.jsxs)(se,{children:[(0,I.jsx)(yB,{children:(0,I.jsx)(VB,{})}),(0,I.jsx)(ce,{}),(0,I.jsx)(ee,{})]})}function UB(){let e=tt(),t=e.isError&&Qe(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,I.jsx)(HB,{}):e.data?.enabled&&!e.data.authenticated?(0,I.jsx)(ne,{username:e.data.username}):(0,I.jsx)(HB,{})}function WB(){return(0,F.useEffect)(()=>{Yo()},[]),(0,I.jsxs)(Ke,{client:De,children:[(0,I.jsx)(UB,{}),(0,I.jsx)(Ko,{}),(0,I.jsx)(Le,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var GB=window.nextclawDesktop?.platform===`win32`?te:M;(0,Tr.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)($o,{children:(0,I.jsx)(Or,{children:(0,I.jsx)(GB,{children:(0,I.jsx)(WB,{})})})})}));export{li as $,xI as A,lr as At,Us as B,jn as Bt,iL as C,Pr as Ct,QI as D,_r as Dt,nL as E,br as Et,eP as F,Hn as Ft,Go as G,Vs as H,Z as I,Rn as It,To as J,vo as K,cN as L,Ln as Lt,kP as M,or as Mt,aP as N,ir as Nt,ZI as O,hr as Ot,sP as P,Un as Pt,oi as Q,rc as R,In as Rt,FL as S,Fr as St,aL as T,xr as Tt,Ns as U,Xs as V,bs as W,yo as X,bo as Y,ii as Z,gR as _,fi as _t,Zz as a,vi as at,ML as b,xi as bt,jz as c,_i as ct,UR as d,Oi as dt,pi as et,WR as f,gi as ft,fR as g,ui as gt,PR as h,yi as ht,lB as i,Si as it,wP as j,sr as jt,SI as k,dr as kt,lz as l,ci as lt,IR as m,Di as mt,aB as n,Ei as nt,Hz as o,wi as ot,FR as p,hi as pt,Co as q,cB as r,mi as rt,Mz as s,Ci as st,uB as t,Ti as tt,$R as u,si as ut,PL as v,bi as vt,oL as w,kr as wt,NL as x,Ir as xt,jL as y,di as yt,ic as z,Pn as zt};