@truefoundry/trueforge 0.181.0-rc.3 → 0.181.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_frontend/assets/{AgentCodeSnippets-7YBGYKYT-COw5-jCA.js → AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js} +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js.gz +0 -0
- package/dist/_frontend/assets/{AgentMetricChart-ECYBDKGM-DJTSZ671.js → AgentMetricChart-ECYBDKGM-M3_lXz3E.js} +1 -1
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-M3_lXz3E.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-M3_lXz3E.js.gz +0 -0
- package/dist/_frontend/assets/{AgentOverview-NCWC4XDZ-DqZqGo8V.js → AgentOverview-NCWC4XDZ-C2t-4vS4.js} +1 -1
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-C2t-4vS4.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-C2t-4vS4.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js → AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js → AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessions-V2V6W7CC-D1eUhvgn.js → AgentSessions-V2V6W7CC-DyO7bBT8.js} +1 -1
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-DyO7bBT8.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-DyO7bBT8.js.gz +0 -0
- package/dist/_frontend/assets/{ConnectorSettings-DYJ6Z6YL-DhF84SXP.js → ConnectorSettings-DYJ6Z6YL-CcJhppzx.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-CcJhppzx.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-CcJhppzx.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-YZPEWKJV-DyDyUCtl.js → DockLayout-YZPEWKJV-D_Oq8GAb.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-OWUKLUSV-DQnh_BPt.js → DrawerLayout-OWUKLUSV-D8yrGeh-.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-D8yrGeh-.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-D8yrGeh-.js.gz +0 -0
- package/dist/_frontend/assets/{EnvironmentsPage-KOMO4W53-DT8-DDE7.js → EnvironmentsPage-KOMO4W53-BlIcOJ78.js} +1 -1
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-BlIcOJ78.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-BlIcOJ78.js.gz +0 -0
- package/dist/_frontend/assets/{ModelSettings-Y5NTNBCL-BFS8Ev0r.js → ModelSettings-Y5NTNBCL-BWyZvSat.js} +1 -1
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BWyZvSat.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BWyZvSat.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-KLDK6WZH-BB_J0XaX.js → SandboxSettings-KLDK6WZH-DZLs35fh.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-DZLs35fh.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-DZLs35fh.js.gz +0 -0
- package/dist/_frontend/assets/{SchedulesPage-4F5FX65T-DVKEEd4R.js → SchedulesPage-4F5FX65T-BUxoTOQI.js} +1 -1
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-BUxoTOQI.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-BUxoTOQI.js.gz +0 -0
- package/dist/_frontend/assets/{SettingsBuilder-72KREKYT-Dmu76Wzi.js → SettingsBuilder-72KREKYT-CdDx-q8Q.js} +2 -2
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-CdDx-q8Q.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-CdDx-q8Q.js.gz +0 -0
- package/dist/_frontend/assets/{ShellRouteSync-G2PJ3G3L-C4RD0M9w.js → ShellRouteSync-G2PJ3G3L-DUPIHNaa.js} +1 -1
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-DUPIHNaa.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-DUPIHNaa.js.gz +0 -0
- package/dist/_frontend/assets/{SidebarLayout-BWR7N76R-B3Zm0kWX.js → SidebarLayout-BWR7N76R-DKICQgJu.js} +2 -2
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-DKICQgJu.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-DKICQgJu.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-F7X7TZII-DYRS-1zQ.js → SkillSettings-F7X7TZII-BPHGKv7f.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-BPHGKv7f.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-BPHGKv7f.js.gz +0 -0
- package/dist/_frontend/assets/{TrueForgeUIWithRouter-KPZEEO7D-BAuDAM4m.js → TrueForgeUIWithRouter-KPZEEO7D-D5rLvr7Y.js} +1 -1
- package/dist/_frontend/assets/{WebSearchSettings-VNL63UFQ-BL3QLgS_.js → WebSearchSettings-VNL63UFQ-D_dYueo8.js} +1 -1
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-D_dYueo8.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-D_dYueo8.js.gz +0 -0
- package/dist/_frontend/assets/{WidgetLayout-5E2MCZOP-BXKkzHl9.js → WidgetLayout-5E2MCZOP-D4SImULJ.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-D4SImULJ.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-D4SImULJ.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-HB2ZQ4CZ-DnCTK9KS.js → chunk-HB2ZQ4CZ-DiRiTO48.js} +1 -1
- package/dist/_frontend/assets/{chunk-NRMAG6HF-BKTcpJl0.js → chunk-NRMAG6HF-DQrtQbNO.js} +1 -1
- package/dist/_frontend/assets/chunk-NRMAG6HF-DQrtQbNO.js.br +0 -0
- package/dist/_frontend/assets/chunk-NRMAG6HF-DQrtQbNO.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OB3PAWPO-CDXWnkeP.js → chunk-OB3PAWPO-Dubdb29l.js} +1 -1
- package/dist/_frontend/assets/chunk-OB3PAWPO-Dubdb29l.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-Dubdb29l.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-QYZB5BFZ-C1Zl8SCi.js → chunk-QYZB5BFZ-Y-d5Su7A.js} +2 -2
- package/dist/_frontend/assets/chunk-QYZB5BFZ-Y-d5Su7A.js.br +0 -0
- package/dist/_frontend/assets/chunk-QYZB5BFZ-Y-d5Su7A.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-XIE7TJW5-C05XSTa4.js → chunk-XIE7TJW5-CvvubFnj.js} +1 -1
- package/dist/_frontend/assets/chunk-XIE7TJW5-CvvubFnj.js.br +0 -0
- package/dist/_frontend/assets/chunk-XIE7TJW5-CvvubFnj.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-XDzIuvZX.js → cssMode-CHTRoDtG.js} +1 -1
- package/dist/_frontend/assets/cssMode-CHTRoDtG.js.br +0 -0
- package/dist/_frontend/assets/cssMode-CHTRoDtG.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-CMM6eRZY.js → freemarker2-DCfanxEk.js} +1 -1
- package/dist/_frontend/assets/freemarker2-DCfanxEk.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-DCfanxEk.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-zWdybys2.js → handlebars-D1eUDHiC.js} +1 -1
- package/dist/_frontend/assets/handlebars-D1eUDHiC.js.br +0 -0
- package/dist/_frontend/assets/handlebars-D1eUDHiC.js.gz +0 -0
- package/dist/_frontend/assets/{html-FSsE5b6P.js → html-BY_x5tuA.js} +1 -1
- package/dist/_frontend/assets/html-BY_x5tuA.js.br +0 -0
- package/dist/_frontend/assets/html-BY_x5tuA.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-Ba0OQ7ke.js → htmlMode-CQC06PWc.js} +1 -1
- package/dist/_frontend/assets/htmlMode-CQC06PWc.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-CQC06PWc.js.gz +0 -0
- package/dist/_frontend/assets/{index-DJwMhvnU.js → index-CLC73Sfk.js} +3 -3
- package/dist/_frontend/assets/index-CLC73Sfk.js.br +0 -0
- package/dist/_frontend/assets/index-CLC73Sfk.js.gz +0 -0
- package/dist/_frontend/assets/{index-CHtf87eT.js → index-D962hlvu.js} +4 -4
- package/dist/_frontend/assets/index-D962hlvu.js.br +0 -0
- package/dist/_frontend/assets/index-D962hlvu.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-Ce1crFvb.js → javascript-B-CwmGDX.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-BMBeYqZi.js → jsonMode-D9OZ55Ze.js} +1 -1
- package/dist/_frontend/assets/jsonMode-D9OZ55Ze.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-D9OZ55Ze.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-cKR-cSWX.js → liquid-BFKqoh1q.js} +1 -1
- package/dist/_frontend/assets/liquid-BFKqoh1q.js.br +0 -0
- package/dist/_frontend/assets/liquid-BFKqoh1q.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-RvCvbT7h.js → lspLanguageFeatures-CISDQF7n.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-CISDQF7n.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-CISDQF7n.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-DWyx_s0A.js → mdx-szHIHXG5.js} +1 -1
- package/dist/_frontend/assets/mdx-szHIHXG5.js.br +0 -0
- package/dist/_frontend/assets/mdx-szHIHXG5.js.gz +0 -0
- package/dist/_frontend/assets/{python-BZT89b5u.js → python-CkLSQhYw.js} +1 -1
- package/dist/_frontend/assets/python-CkLSQhYw.js.br +0 -0
- package/dist/_frontend/assets/python-CkLSQhYw.js.gz +0 -0
- package/dist/_frontend/assets/{razor-C4RJ85c7.js → razor-Dcy4SEiu.js} +1 -1
- package/dist/_frontend/assets/razor-Dcy4SEiu.js.br +0 -0
- package/dist/_frontend/assets/razor-Dcy4SEiu.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-BFOytUIs.js → tsMode-BGP6UWze.js} +1 -1
- package/dist/_frontend/assets/tsMode-BGP6UWze.js.br +0 -0
- package/dist/_frontend/assets/tsMode-BGP6UWze.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-B_aWPfCP.js → typescript-DArV44f6.js} +1 -1
- package/dist/_frontend/assets/typescript-DArV44f6.js.br +0 -0
- package/dist/_frontend/assets/typescript-DArV44f6.js.gz +0 -0
- package/dist/_frontend/assets/{workers-DhT6ONBN.js → workers-BBj3mLYA.js} +1 -1
- package/dist/_frontend/assets/workers-BBj3mLYA.js.br +0 -0
- package/dist/_frontend/assets/workers-BBj3mLYA.js.gz +0 -0
- package/dist/_frontend/assets/{xml-CIXW7ba5.js → xml-CLu5PVjZ.js} +1 -1
- package/dist/_frontend/assets/xml-CLu5PVjZ.js.br +0 -0
- package/dist/_frontend/assets/xml-CLu5PVjZ.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-B06RGyXK.js → yaml-KYFquP3j.js} +1 -1
- package/dist/_frontend/assets/yaml-KYFquP3j.js.br +0 -0
- package/dist/_frontend/assets/yaml-KYFquP3j.js.gz +0 -0
- package/dist/_frontend/index.html +1 -1
- package/dist/main.js +8 -5
- package/dist/main.js.map +1 -1
- package/package.json +3 -3
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-COw5-jCA.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-COw5-jCA.js.gz +0 -0
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-DJTSZ671.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-DJTSZ671.js.gz +0 -0
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-DqZqGo8V.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-DqZqGo8V.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-BrVSrckq.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-DAeb-1-p.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-D1eUhvgn.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-D1eUhvgn.js.gz +0 -0
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-DhF84SXP.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-DhF84SXP.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-DQnh_BPt.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-DQnh_BPt.js.gz +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-DT8-DDE7.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-DT8-DDE7.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BFS8Ev0r.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BFS8Ev0r.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-BB_J0XaX.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-BB_J0XaX.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-DVKEEd4R.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-DVKEEd4R.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-Dmu76Wzi.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-Dmu76Wzi.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-C4RD0M9w.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-C4RD0M9w.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-B3Zm0kWX.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-B3Zm0kWX.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-DYRS-1zQ.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-DYRS-1zQ.js.gz +0 -0
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-BL3QLgS_.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-BL3QLgS_.js.gz +0 -0
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-BXKkzHl9.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-BXKkzHl9.js.gz +0 -0
- package/dist/_frontend/assets/chunk-NRMAG6HF-BKTcpJl0.js.br +0 -0
- package/dist/_frontend/assets/chunk-NRMAG6HF-BKTcpJl0.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-CDXWnkeP.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-CDXWnkeP.js.gz +0 -0
- package/dist/_frontend/assets/chunk-QYZB5BFZ-C1Zl8SCi.js.br +0 -0
- package/dist/_frontend/assets/chunk-QYZB5BFZ-C1Zl8SCi.js.gz +0 -0
- package/dist/_frontend/assets/chunk-XIE7TJW5-C05XSTa4.js.br +0 -0
- package/dist/_frontend/assets/chunk-XIE7TJW5-C05XSTa4.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-XDzIuvZX.js.br +0 -6
- package/dist/_frontend/assets/cssMode-XDzIuvZX.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-CMM6eRZY.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-CMM6eRZY.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-zWdybys2.js.br +0 -0
- package/dist/_frontend/assets/handlebars-zWdybys2.js.gz +0 -0
- package/dist/_frontend/assets/html-FSsE5b6P.js.br +0 -0
- package/dist/_frontend/assets/html-FSsE5b6P.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-Ba0OQ7ke.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-Ba0OQ7ke.js.gz +0 -0
- package/dist/_frontend/assets/index-CHtf87eT.js.br +0 -0
- package/dist/_frontend/assets/index-CHtf87eT.js.gz +0 -0
- package/dist/_frontend/assets/index-DJwMhvnU.js.br +0 -0
- package/dist/_frontend/assets/index-DJwMhvnU.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-BMBeYqZi.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-BMBeYqZi.js.gz +0 -0
- package/dist/_frontend/assets/liquid-cKR-cSWX.js.br +0 -0
- package/dist/_frontend/assets/liquid-cKR-cSWX.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-RvCvbT7h.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-RvCvbT7h.js.gz +0 -0
- package/dist/_frontend/assets/mdx-DWyx_s0A.js.br +0 -0
- package/dist/_frontend/assets/mdx-DWyx_s0A.js.gz +0 -0
- package/dist/_frontend/assets/python-BZT89b5u.js.br +0 -0
- package/dist/_frontend/assets/python-BZT89b5u.js.gz +0 -0
- package/dist/_frontend/assets/razor-C4RJ85c7.js.br +0 -0
- package/dist/_frontend/assets/razor-C4RJ85c7.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-BFOytUIs.js.br +0 -0
- package/dist/_frontend/assets/tsMode-BFOytUIs.js.gz +0 -0
- package/dist/_frontend/assets/typescript-B_aWPfCP.js.br +0 -0
- package/dist/_frontend/assets/typescript-B_aWPfCP.js.gz +0 -0
- package/dist/_frontend/assets/workers-DhT6ONBN.js.br +0 -0
- package/dist/_frontend/assets/workers-DhT6ONBN.js.gz +0 -0
- package/dist/_frontend/assets/xml-CIXW7ba5.js.br +0 -0
- package/dist/_frontend/assets/xml-CIXW7ba5.js.gz +0 -0
- package/dist/_frontend/assets/yaml-B06RGyXK.js.br +0 -0
- package/dist/_frontend/assets/yaml-B06RGyXK.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as st}from"./chunk-XIE7TJW5-C05XSTa4.js";import{l as ye,o as Oe,p as ve,q as Me,t as $e,v as nt,r as o,w as be,x as at,y as Re,z as Se,A as rt,j as e,P as lt,S as it,B as me,C as Be,D as Ue,E as L,I as A,F as ot,G as he,H as Pe,J as ct,K as dt,L as De,M as V,N as ut,O as W,k as Ge,Q as mt,c as O,R as xt,U as ht,V as ft,W as gt,X as bt,Y as pt,Z as Nt,_ as K,$ as jt,a0 as yt,u as vt,a1 as St,a2 as fe,a3 as kt,a4 as wt,a5 as Tt,a6 as Ct,a7 as Et,a8 as zt,a9 as At,aa as ge,ab as Rt,ac as Pt,ad as Dt}from"./index-CHtf87eT.js";var Ie=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function It(t){const n=He(),r=new Set(Ie.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Ie]}var qe=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],Ft={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function xe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:He()}}function _t(t){return Ft[t]??t.split("/").pop()??t}function Ve(t){return t.toString().padStart(2,"0")}function ce({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ve(n)} ${r}`}function pe(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((c,v)=>c-v),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function Ne(t){return t.trim().split(/\s+/).length===5}function ae(t){const n=_t(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,c,v,g]=r;if(c!=="*"||v!=="*")return t.cron;const d=Number(a),x=Number(l);if(l==="*"&&g==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ve(d)} ${n}`;if(g==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Daily ${ce({hour:x,minute:d})} ${n}`;if(g==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Weekdays ${ce({hour:x,minute:d})} ${n}`;if(g!=null&&/^\d(?:,\d)*$/.test(g)&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d)){const N=g.split(",").map(h=>{var k;return((k=qe.find(b=>b.value===Number(h)))==null?void 0:k.label)??h});return N.length===1?`Every ${N[0]==="Mon"?"Monday":N[0]} ${ce({hour:x,minute:d})} ${n}`:`${N.join(", ")} ${ce({hour:x,minute:d})} ${n}`}return t.cron}function Fe(t){const n=xe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,c,v,g]=r,d=Number(a),x=Number(l);return c!=="*"||v!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&g==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:g==="*"&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:x,minute:d,customCron:t.cron}:g!=null&&/^\d(?:,\d)*$/.test(g)&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:x,minute:d,weekdays:g.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(x)?n.hour:x,minute:Number.isNaN(d)?n.minute:d}}function Lt(t,n=Date.now()){return Dt(t,{fallback:"Never",nowMs:n})}var Ot=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Mt=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),$t=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Bt({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:c,agentPickerDisabled:v=!1,onBuildAgent:g}){const d=pe(t),x=ae({cron:d,timezone:t.timezone}),N=It(t.timezone),h=(i,j)=>{n({...t,[i]:j})},k=i=>{const j=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:j})},b=i=>{const C=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:C.length>0?C:[i]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(Be,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:c,disabled:v||l==null,onBuildAgent:g})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:i=>h("name",i.target.value),placeholder:"harness-daily-digest",className:ge("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:i=>h("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ge("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Ot.map(i=>{const j=t.recurrence===i.value;return e.jsx("button",{type:"button",className:O("rounded-md border px-2 py-2 text-sm font-medium transition-colors",j?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":j,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>h("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!Ne(t.customCron),className:O(ge("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),Ne(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:qe.map(i=>{const j=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:O("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",j?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":j,onClick:()=>b(i.value),children:i.label},i.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(me,{"aria-label":"Hour",value:String(t.hour),options:Mt,onValueChange:i=>h("hour",Number(i))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(me,{"aria-label":"Minute",value:String(t.minute),options:$t,onValueChange:i=>h("minute",Number(i))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(me,{"aria-label":"Timezone",value:t.timezone,options:N,onValueChange:i=>h("timezone",i),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:x||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function Ut(t){return t.startsWith("manual-")}function Gt(t){return t==="failed"?"failed":"success"}function We(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Ke(t){return Ut(t)?"Manual test":"Cron"}function Ht(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function je(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":zt(n)}function qt({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:We(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Ke(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",je(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",je(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Vt={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function Qe({run:t,onOpenSession:n}){const r=Gt(t.status),a=je(t.triggeredAt??t.scheduledFor),l=`${We(t.status)} run at ${a}`,c=O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Vt[r]),v=e.jsx(A,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(Ge,{content:e.jsx(qt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:O(c,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:v}):e.jsx("span",{className:c,"aria-label":l,children:v})})}function Ye({status:t}){const n=t==="active";return e.jsx(st,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Wt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Kt({connector:t,onConnected:n}){return Rt()==null?null:e.jsx(Pt,{connector:t,onConnected:n})}function ne({label:t,children:n}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:n})]})}function Qt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=ye(),c=ve(),{connectors:v,ensureLoaded:g,refreshConnectors:d,loading:x,error:N}=At(),[h,k]=o.useState(!1),[b,i]=o.useState(null),j=ae({cron:t.cron,timezone:t.timezone}),C=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),c==null||c.showSuccess({title:"Test run started"})}catch(m){c==null||c.showError(m)}finally{k(!1)}};return o.useEffect(()=>{g()},[g]),o.useEffect(()=>{N!=null&&(c==null||c.showError(N))},[N,c]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:n}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ye,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:j}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs(L.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),r.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:r.map(m=>{const T=Wt(v,m.name),M=(T==null?void 0:T.authenticated)===!0,B=T==null&&!x;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:O("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",M?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:M?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),M?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):B?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):T!=null&&T.authenticated===!1?e.jsx(Kt,{connector:T,onConnected:d}):x?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs(L.Primary,{type:"button",disabled:h,size:"small",onClick:()=>void C(),children:[e.jsx(A,{name:h?"loader":"play",className:O("size-3.5",h&&"animate-spin")}),"Run Test"]})]}),b==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(Qe,{run:b}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Ke(b.name)}),e.jsx("p",{className:"text-text-secondary",children:Lt(b.triggeredAt??b.scheduledFor)})]})]})]})]})}function Yt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:c}){const v=ye(),g=Oe(),d=$e(),x=ve(),N=Me(),[h,k]=o.useState(xe),[b,i]=o.useState(l),[j,C]=o.useState(null),[m,T]=o.useState({kind:"form"}),[M,B]=o.useState(!1),[se,Q]=o.useState(!1),[P,_]=o.useState(null),D=o.useRef(b);D.current=b;const Y=m.kind==="form"?m.saved:m.schedule,p=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,I=m.kind==="form"&&m.saved!=null,U=r==="create"&&m.kind==="form"&&m.saved==null,{allows:re}=be({resourceType:"agent",resourceIds:b.length===0?[]:[b]});o.useEffect(()=>{if(!t){k(xe()),i(l),C(null),_(null),T({kind:"form"}),Q(!1);return}if(r==="edit"&&a!=null){k(Fe({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),C(null),T({kind:"form"});return}k(xe()),i(l),C(null),T({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const E=l;return Tt({server:g,agentKey:E}).then(y=>{f||y==null||D.current===E&&(C(y),i(Ue(y)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,g]);const Z=(j==null?void 0:j.name)??(Y==null?void 0:Y.agentName)??(a==null?void 0:a.agentName)??(b.length>0?b:""),J=o.useMemo(()=>{var E;return(((E=j==null?void 0:j.agentSpec)==null?void 0:E.mcpServers)??[]).map(Ct).filter(y=>y!=null).map(y=>({name:y}))},[j]),G=o.useMemo(()=>{const f=pe(h);return h.name.trim().length>0&&h.task.trim().length>0&&Ne(f)&&b.length>0&&(!U||re(b,"USE"))},[b,re,h,U]),H=f=>{T({kind:"test",schedule:f}),k(Fe({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!G)return;const E=pe(h);B(!0),_(null);try{if(p&&a!=null){await v.updateSchedule({id:a.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:a.status}),N(K.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),c==null||c(),n(!1);return}if(I&&m.kind==="form"&&m.saved!=null){const w=await v.updateSchedule({id:m.saved.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.EDITED,{schedule_id:w.id,agent_id:w.agentId}),c==null||c(),H(w),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:w.cron,timezone:w.timezone})});return}const y=await v.createSchedule({agentId:b,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.CREATED,{schedule_id:y.id,agent_id:b}),c==null||c(),H(y),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:y.cron,timezone:y.timezone})})}catch(y){const w=y instanceof Error?y.message:"Failed to save schedule";_(w)}finally{B(!1)}},F=async()=>{if(m.kind==="test"){Q(!0),_(null);try{await v.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),c==null||c(),x==null||x.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const E=f instanceof Error?f.message:"Failed to activate schedule";_(E),x==null||x.showError(f)}finally{Q(!1)}}},le=m.kind==="test"?"Test Schedule":p||I?"Edit Schedule":"New Schedule",ee=m.kind==="test"?`Recurring unattended runs of ${Z}.`:p||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let R;return m.kind==="test"?R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsx(L.Secondary,{type:"button",className:"w-full",disabled:se,onClick:()=>void F(),children:"Activate Schedule"})]}):R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(L.Secondary,{type:"button",onClick:()=>n(!1),disabled:M,children:"Cancel"}),e.jsx(L.Primary,{type:"submit",form:"schedule-form",disabled:!G||M,children:"Save"})]})]}),e.jsx(Et,{open:t,onOpenChange:n,title:le,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:m.kind==="test"||p||I?"calendar":"calendar-plus",className:"size-5"})}),footer:R,children:m.kind==="test"?e.jsx(Qt,{schedule:m.schedule,agentName:Z,mcpMounts:J,onEditConfiguration:()=>{_(null),T({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Bt,{values:h,onChange:k,agentId:b,agentLabel:Z,onAgentIdChange:p||I?void 0:f=>{i(f),f.length===0&&C(null)},onAgentPicked:C,agentPickerDisabled:p||I,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function _e(t){return e.jsx(wt,{children:e.jsx(Yt,{...t})})}function Zt({runs:t,onOpenSession:n}){const r=Ht(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Qe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var Jt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Le=[10,25];function de(t){return Math.min(Math.max(t,1),25)}function ue(t){const n=Se(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all"}}function Xt(t){const n=Se(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function es({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:c,onTogglePause:v,onDelete:g}){const d=vt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs(L.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(A,{name:n?"loader":"play",className:O("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(St,{align:"end",trigger:e.jsx("button",{type:"button",className:kt({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:c,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:v,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(fe,{className:"text-failure-bg focus:text-failure-bg",onClick:g,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ns({agentId:t}){const n=ye(),r=Oe(),a=ve(),l=Me(),c=$e(),v=nt(),g=c!=null&&Nt({sessions:v}),[d,x]=o.useState([]),{allows:N}=be({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[h,k]=o.useState({}),[b,i]=o.useState(!1),[j,C]=o.useState(()=>new Set),[m,T]=o.useState({}),[M,B]=o.useState(!0),[se,Q]=o.useState(null),[P,_]=o.useState(()=>ue(window.location.search).nameQuery),[D,Y]=o.useState(()=>ue(window.location.search).statusFilter),[p,I]=o.useState(()=>t??ue(window.location.search).agentFilter),U=t??(p==="all"?null:p),{allows:re}=be({resourceType:"agent",resourceIds:U==null?[]:[U]}),Z=r.permissions==null||U==null||re(U,"USE"),[J,G]=o.useState(()=>Xt(t)),[H,X]=o.useState(null),[F,le]=o.useState(()=>de(pt)),[ee,R]=o.useState(void 0),[f,E]=o.useState(void 0),[y,w]=o.useState(void 0),Ze=({run:s,schedule:u})=>{if(!g||c==null||s.sessionId==null)return;l(K.Schedule.RUN_SESSION_OPENED,{schedule_id:u.id,agent_id:u.agentId});const S=jt(s.triggeredAt??s.scheduledFor);yt({sessionId:s.sessionId,view:"sessions",...S==null?{}:{timeRange:S}}),c.setSessionsOpen(!0)},q=o.useRef(0),ke=o.useRef(!1),we=o.useCallback(async({rows:s,gen:u})=>{if(s.length===0){u===q.current&&k({});return}i(!0);try{const S=await Promise.allSettled(s.map(z=>n.listScheduleRuns({scheduleId:z.id})));if(u!==q.current)return;k(Object.fromEntries(s.map((z,$)=>{const oe=S[$],tt=(oe==null?void 0:oe.status)==="fulfilled"?oe.value:[];return[z.id,tt]})))}finally{u===q.current&&i(!1)}},[n]),te=o.useCallback(async({token:s,size:u,agentId:S})=>{const z=++q.current;B(!0),Q(null);try{const $=await n.listSchedules({limit:de(u),...s===void 0||s===""?{}:{pageToken:s},...S==="all"?{}:{agentIds:[S]}});if(z!==q.current)return;x($.data),E($.nextPageToken),w($.previousPageToken),we({rows:$.data,gen:z})}catch($){if(z!==q.current)return;Q(at($,"Check your connection and try again.")),x([]),k({}),E(void 0),w(void 0)}finally{z===q.current&&B(!1)}},[n,we]),Te=o.useCallback(s=>{const u=(s==null?void 0:s.size)??F,S=(s==null?void 0:s.agentId)??p;R(void 0),w(void 0),te({token:void 0,size:u,agentId:S})},[p,te,F]);o.useEffect(()=>{Re({agent:t===void 0&&p!=="all"?p:null,status:D==="all"?null:D,q:P.trim().length===0?null:P})},[p,t,D,P]),o.useEffect(()=>{t!==void 0&&I(s=>s===t?s:(R(void 0),w(void 0),t))},[t]),o.useEffect(()=>{ke.current||!Se(window.location.search).isNew||(ke.current=!0,Re({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const u=ue(window.location.search);_(u.nameQuery),Y(u.statusFilter),I(S=>{const z=t??u.agentFilter;return S===z?S:(R(void 0),w(void 0),z)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{te({token:ee,size:F,agentId:p})},[p,F,ee,te]);const ie=o.useMemo(()=>{const s=P.trim().toLowerCase();return d.filter(u=>!(D!=="all"&&u.status!==D||s.length>0&&!u.name.toLowerCase().includes(s)))},[d,P,D]),Ce=rt(d),Ee=y!=null||f!=null,Je=async s=>{if(!N(s.id,"MANAGE"))return;const u=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:u}),l(K.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:u}),await te({token:ee,size:F,agentId:p})}catch(S){a==null||a.showError(S)}},Xe=async s=>{if(N(s.id,"MANAGE")){C(u=>new Set(u).add(s.id));try{await n.createScheduleRun({scheduleId:s.id}),l(K.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"});const u=await n.listScheduleRuns({scheduleId:s.id});k(S=>({...S,[s.id]:u}))}catch(u){a==null||a.showError(u)}finally{C(u=>{const S=new Set(u);return S.delete(s.id),S})}}},et=async s=>{if(N(s.id,"DELETE")){X(null);try{await n.deleteSchedule({id:s.id}),l(K.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Te()}catch(u){a==null||a.showError(u)}}},ze=()=>{f!=null&&R(f)},Ae=()=>{y==null||y===""||R(y)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(lt,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(it,{query:P,setQuery:_,placeholder:"Search schedules by name"})}),e.jsx(me,{value:D,onValueChange:Y,options:Jt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Be,{value:p,selectedLabel:p==="all"?"All agents":m[p]??p,onValueChange:s=>{I(s),R(void 0),w(void 0)},onAgentPicked:s=>{T(u=>({...u,[Ue(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(L.Primary,{type:"button",disabled:!Z,onClick:()=>Z&&G({kind:"create",agentId:p!=="all"?p:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:O("min-h-0 flex-1 overflow-auto px-4 py-4",se!=null?"flex flex-col":void 0),children:M?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,u)=>e.jsx(ot,{className:"h-12 w-full rounded-md"},u))}):se!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(he,{title:"Couldn't load schedules",description:se,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(he,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):ie.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(he,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ee?e.jsx(Pe,{pageSize:F,rowCount:0,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(ct,{className:"min-w-240",children:[e.jsx(dt,{children:e.jsxs(De,{className:"hover:bg-transparent",children:[e.jsx(V,{children:"Schedule Name"}),e.jsx(V,{children:"Task"}),Ce?e.jsx(V,{children:"Created by"}):null,e.jsx(V,{children:"Frequency"}),e.jsx(V,{children:"Status"}),e.jsx(V,{children:"Last 5 runs"}),e.jsx(V,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(ut,{children:ie.map(s=>{const u=ae({cron:s.cron,timezone:s.timezone}),S=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(De,{children:[e.jsxs(W,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(A,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S})]})]}),e.jsx(W,{className:"w-64 max-w-64",children:e.jsx(Ge,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Ce?e.jsx(W,{children:e.jsx(mt,{subject:s.createdBySubject})}):null,e.jsx(W,{children:u}),e.jsx(W,{children:e.jsx(Ye,{status:s.status})}),e.jsx(W,{children:b?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Zt,{runs:h[s.id]??[],...g?{onOpenSession:z=>Ze({run:z,schedule:s})}:{}})}),e.jsx(W,{className:"text-right",children:e.jsx(es,{schedule:s,running:j.has(s.id),canManage:N(s.id,"MANAGE"),canDelete:N(s.id,"DELETE"),onRunNow:()=>void Xe(s),onEdit:()=>{N(s.id,"MANAGE")&&G({kind:"edit",schedule:s})},onTogglePause:()=>void Je(s),onDelete:()=>{N(s.id,"DELETE")&&X(s)}})})]},s.id)})})]}),(ie.length>0||Ee)&&e.jsx(Pe,{pageSize:F,rowCount:ie.length,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}})]})}),J.kind==="create"?e.jsx(_e,{open:!0,mode:"create",initialAgentId:J.agentId??"",onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>Te()}):null,J.kind==="edit"?e.jsx(_e,{open:!0,mode:"edit",schedule:J.schedule,onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>void te({token:ee,size:F,agentId:p})}):null,H!=null?e.jsxs(xt,{open:!0,onOpenChange:s=>{s||X(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(ht,{children:e.jsxs(ft,{children:[e.jsx(gt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",H.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(bt,{children:[e.jsx(L.Secondary,{type:"button",onClick:()=>X(null),children:"Cancel"}),e.jsx(L.Destructive,{type:"button",disabled:!N(H.id,"DELETE"),onClick:()=>void et(H),children:"Delete"})]})]}):null]})}export{ns as SchedulesPage};
|
|
1
|
+
import{B as st}from"./chunk-XIE7TJW5-CvvubFnj.js";import{l as ye,o as Oe,p as ve,q as Me,t as $e,v as nt,r as o,w as be,x as at,y as Re,z as Se,A as rt,j as e,P as lt,S as it,B as me,C as Be,D as Ue,E as L,I as A,F as ot,G as he,H as Pe,J as ct,K as dt,L as De,M as V,N as ut,O as W,k as Ge,Q as mt,c as O,R as xt,U as ht,V as ft,W as gt,X as bt,Y as pt,Z as Nt,_ as K,$ as jt,a0 as yt,u as vt,a1 as St,a2 as fe,a3 as kt,a4 as wt,a5 as Tt,a6 as Ct,a7 as Et,a8 as zt,a9 as At,aa as ge,ab as Rt,ac as Pt,ad as Dt}from"./index-D962hlvu.js";var Ie=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function It(t){const n=He(),r=new Set(Ie.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Ie]}var qe=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],Ft={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function xe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:He()}}function _t(t){return Ft[t]??t.split("/").pop()??t}function Ve(t){return t.toString().padStart(2,"0")}function ce({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ve(n)} ${r}`}function pe(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((c,v)=>c-v),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function Ne(t){return t.trim().split(/\s+/).length===5}function ae(t){const n=_t(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,c,v,g]=r;if(c!=="*"||v!=="*")return t.cron;const d=Number(a),x=Number(l);if(l==="*"&&g==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ve(d)} ${n}`;if(g==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Daily ${ce({hour:x,minute:d})} ${n}`;if(g==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d))return`Weekdays ${ce({hour:x,minute:d})} ${n}`;if(g!=null&&/^\d(?:,\d)*$/.test(g)&&l!==void 0&&a!==void 0&&!Number.isNaN(x)&&!Number.isNaN(d)){const N=g.split(",").map(h=>{var k;return((k=qe.find(b=>b.value===Number(h)))==null?void 0:k.label)??h});return N.length===1?`Every ${N[0]==="Mon"?"Monday":N[0]} ${ce({hour:x,minute:d})} ${n}`:`${N.join(", ")} ${ce({hour:x,minute:d})} ${n}`}return t.cron}function Fe(t){const n=xe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,c,v,g]=r,d=Number(a),x=Number(l);return c!=="*"||v!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&g==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:g==="*"&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:x,minute:d,customCron:t.cron}:g!=null&&/^\d(?:,\d)*$/.test(g)&&!Number.isNaN(x)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:x,minute:d,weekdays:g.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(x)?n.hour:x,minute:Number.isNaN(d)?n.minute:d}}function Lt(t,n=Date.now()){return Dt(t,{fallback:"Never",nowMs:n})}var Ot=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Mt=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),$t=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Bt({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:c,agentPickerDisabled:v=!1,onBuildAgent:g}){const d=pe(t),x=ae({cron:d,timezone:t.timezone}),N=It(t.timezone),h=(i,j)=>{n({...t,[i]:j})},k=i=>{const j=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:j})},b=i=>{const C=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:C.length>0?C:[i]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(Be,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:c,disabled:v||l==null,onBuildAgent:g})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:i=>h("name",i.target.value),placeholder:"harness-daily-digest",className:ge("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:i=>h("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ge("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Ot.map(i=>{const j=t.recurrence===i.value;return e.jsx("button",{type:"button",className:O("rounded-md border px-2 py-2 text-sm font-medium transition-colors",j?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":j,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>h("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!Ne(t.customCron),className:O(ge("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),Ne(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:qe.map(i=>{const j=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:O("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",j?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":j,onClick:()=>b(i.value),children:i.label},i.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(me,{"aria-label":"Hour",value:String(t.hour),options:Mt,onValueChange:i=>h("hour",Number(i))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(me,{"aria-label":"Minute",value:String(t.minute),options:$t,onValueChange:i=>h("minute",Number(i))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(me,{"aria-label":"Timezone",value:t.timezone,options:N,onValueChange:i=>h("timezone",i),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:x||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function Ut(t){return t.startsWith("manual-")}function Gt(t){return t==="failed"?"failed":"success"}function We(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Ke(t){return Ut(t)?"Manual test":"Cron"}function Ht(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function je(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":zt(n)}function qt({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:We(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Ke(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",je(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",je(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Vt={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function Qe({run:t,onOpenSession:n}){const r=Gt(t.status),a=je(t.triggeredAt??t.scheduledFor),l=`${We(t.status)} run at ${a}`,c=O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Vt[r]),v=e.jsx(A,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(Ge,{content:e.jsx(qt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:O(c,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:v}):e.jsx("span",{className:c,"aria-label":l,children:v})})}function Ye({status:t}){const n=t==="active";return e.jsx(st,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Wt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Kt({connector:t,onConnected:n}){return Rt()==null?null:e.jsx(Pt,{connector:t,onConnected:n})}function ne({label:t,children:n}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:n})]})}function Qt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=ye(),c=ve(),{connectors:v,ensureLoaded:g,refreshConnectors:d,loading:x,error:N}=At(),[h,k]=o.useState(!1),[b,i]=o.useState(null),j=ae({cron:t.cron,timezone:t.timezone}),C=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),c==null||c.showSuccess({title:"Test run started"})}catch(m){c==null||c.showError(m)}finally{k(!1)}};return o.useEffect(()=>{g()},[g]),o.useEffect(()=>{N!=null&&(c==null||c.showError(N))},[N,c]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:n}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ye,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:j}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs(L.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),r.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:r.map(m=>{const T=Wt(v,m.name),M=(T==null?void 0:T.authenticated)===!0,B=T==null&&!x;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:O("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",M?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:M?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),M?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):B?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):T!=null&&T.authenticated===!1?e.jsx(Kt,{connector:T,onConnected:d}):x?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs(L.Primary,{type:"button",disabled:h,size:"small",onClick:()=>void C(),children:[e.jsx(A,{name:h?"loader":"play",className:O("size-3.5",h&&"animate-spin")}),"Run Test"]})]}),b==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(Qe,{run:b}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Ke(b.name)}),e.jsx("p",{className:"text-text-secondary",children:Lt(b.triggeredAt??b.scheduledFor)})]})]})]})]})}function Yt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:c}){const v=ye(),g=Oe(),d=$e(),x=ve(),N=Me(),[h,k]=o.useState(xe),[b,i]=o.useState(l),[j,C]=o.useState(null),[m,T]=o.useState({kind:"form"}),[M,B]=o.useState(!1),[se,Q]=o.useState(!1),[P,_]=o.useState(null),D=o.useRef(b);D.current=b;const Y=m.kind==="form"?m.saved:m.schedule,p=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,I=m.kind==="form"&&m.saved!=null,U=r==="create"&&m.kind==="form"&&m.saved==null,{allows:re}=be({resourceType:"agent",resourceIds:b.length===0?[]:[b]});o.useEffect(()=>{if(!t){k(xe()),i(l),C(null),_(null),T({kind:"form"}),Q(!1);return}if(r==="edit"&&a!=null){k(Fe({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),C(null),T({kind:"form"});return}k(xe()),i(l),C(null),T({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const E=l;return Tt({server:g,agentKey:E}).then(y=>{f||y==null||D.current===E&&(C(y),i(Ue(y)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,g]);const Z=(j==null?void 0:j.name)??(Y==null?void 0:Y.agentName)??(a==null?void 0:a.agentName)??(b.length>0?b:""),J=o.useMemo(()=>{var E;return(((E=j==null?void 0:j.agentSpec)==null?void 0:E.mcpServers)??[]).map(Ct).filter(y=>y!=null).map(y=>({name:y}))},[j]),G=o.useMemo(()=>{const f=pe(h);return h.name.trim().length>0&&h.task.trim().length>0&&Ne(f)&&b.length>0&&(!U||re(b,"USE"))},[b,re,h,U]),H=f=>{T({kind:"test",schedule:f}),k(Fe({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!G)return;const E=pe(h);B(!0),_(null);try{if(p&&a!=null){await v.updateSchedule({id:a.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:a.status}),N(K.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),c==null||c(),n(!1);return}if(I&&m.kind==="form"&&m.saved!=null){const w=await v.updateSchedule({id:m.saved.id,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.EDITED,{schedule_id:w.id,agent_id:w.agentId}),c==null||c(),H(w),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:w.cron,timezone:w.timezone})});return}const y=await v.createSchedule({agentId:b,name:h.name.trim(),task:h.task.trim(),cron:E,timezone:h.timezone,status:"paused"});N(K.Schedule.CREATED,{schedule_id:y.id,agent_id:b}),c==null||c(),H(y),x==null||x.showSuccess({title:"Schedule saved as paused",description:ae({cron:y.cron,timezone:y.timezone})})}catch(y){const w=y instanceof Error?y.message:"Failed to save schedule";_(w)}finally{B(!1)}},F=async()=>{if(m.kind==="test"){Q(!0),_(null);try{await v.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),c==null||c(),x==null||x.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const E=f instanceof Error?f.message:"Failed to activate schedule";_(E),x==null||x.showError(f)}finally{Q(!1)}}},le=m.kind==="test"?"Test Schedule":p||I?"Edit Schedule":"New Schedule",ee=m.kind==="test"?`Recurring unattended runs of ${Z}.`:p||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let R;return m.kind==="test"?R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsx(L.Secondary,{type:"button",className:"w-full",disabled:se,onClick:()=>void F(),children:"Activate Schedule"})]}):R=e.jsxs("div",{className:"flex flex-col gap-2",children:[P!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:P}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(L.Secondary,{type:"button",onClick:()=>n(!1),disabled:M,children:"Cancel"}),e.jsx(L.Primary,{type:"submit",form:"schedule-form",disabled:!G||M,children:"Save"})]})]}),e.jsx(Et,{open:t,onOpenChange:n,title:le,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:m.kind==="test"||p||I?"calendar":"calendar-plus",className:"size-5"})}),footer:R,children:m.kind==="test"?e.jsx(Qt,{schedule:m.schedule,agentName:Z,mcpMounts:J,onEditConfiguration:()=>{_(null),T({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Bt,{values:h,onChange:k,agentId:b,agentLabel:Z,onAgentIdChange:p||I?void 0:f=>{i(f),f.length===0&&C(null)},onAgentPicked:C,agentPickerDisabled:p||I,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function _e(t){return e.jsx(wt,{children:e.jsx(Yt,{...t})})}function Zt({runs:t,onOpenSession:n}){const r=Ht(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Qe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var Jt=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Le=[10,25];function de(t){return Math.min(Math.max(t,1),25)}function ue(t){const n=Se(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all"}}function Xt(t){const n=Se(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function es({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:c,onTogglePause:v,onDelete:g}){const d=vt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs(L.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(A,{name:n?"loader":"play",className:O("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(St,{align:"end",trigger:e.jsx("button",{type:"button",className:kt({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:c,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(fe,{onClick:v,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(fe,{className:"text-failure-bg focus:text-failure-bg",onClick:g,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ns({agentId:t}){const n=ye(),r=Oe(),a=ve(),l=Me(),c=$e(),v=nt(),g=c!=null&&Nt({sessions:v}),[d,x]=o.useState([]),{allows:N}=be({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[h,k]=o.useState({}),[b,i]=o.useState(!1),[j,C]=o.useState(()=>new Set),[m,T]=o.useState({}),[M,B]=o.useState(!0),[se,Q]=o.useState(null),[P,_]=o.useState(()=>ue(window.location.search).nameQuery),[D,Y]=o.useState(()=>ue(window.location.search).statusFilter),[p,I]=o.useState(()=>t??ue(window.location.search).agentFilter),U=t??(p==="all"?null:p),{allows:re}=be({resourceType:"agent",resourceIds:U==null?[]:[U]}),Z=r.permissions==null||U==null||re(U,"USE"),[J,G]=o.useState(()=>Xt(t)),[H,X]=o.useState(null),[F,le]=o.useState(()=>de(pt)),[ee,R]=o.useState(void 0),[f,E]=o.useState(void 0),[y,w]=o.useState(void 0),Ze=({run:s,schedule:u})=>{if(!g||c==null||s.sessionId==null)return;l(K.Schedule.RUN_SESSION_OPENED,{schedule_id:u.id,agent_id:u.agentId});const S=jt(s.triggeredAt??s.scheduledFor);yt({sessionId:s.sessionId,view:"sessions",...S==null?{}:{timeRange:S}}),c.setSessionsOpen(!0)},q=o.useRef(0),ke=o.useRef(!1),we=o.useCallback(async({rows:s,gen:u})=>{if(s.length===0){u===q.current&&k({});return}i(!0);try{const S=await Promise.allSettled(s.map(z=>n.listScheduleRuns({scheduleId:z.id})));if(u!==q.current)return;k(Object.fromEntries(s.map((z,$)=>{const oe=S[$],tt=(oe==null?void 0:oe.status)==="fulfilled"?oe.value:[];return[z.id,tt]})))}finally{u===q.current&&i(!1)}},[n]),te=o.useCallback(async({token:s,size:u,agentId:S})=>{const z=++q.current;B(!0),Q(null);try{const $=await n.listSchedules({limit:de(u),...s===void 0||s===""?{}:{pageToken:s},...S==="all"?{}:{agentIds:[S]}});if(z!==q.current)return;x($.data),E($.nextPageToken),w($.previousPageToken),we({rows:$.data,gen:z})}catch($){if(z!==q.current)return;Q(at($,"Check your connection and try again.")),x([]),k({}),E(void 0),w(void 0)}finally{z===q.current&&B(!1)}},[n,we]),Te=o.useCallback(s=>{const u=(s==null?void 0:s.size)??F,S=(s==null?void 0:s.agentId)??p;R(void 0),w(void 0),te({token:void 0,size:u,agentId:S})},[p,te,F]);o.useEffect(()=>{Re({agent:t===void 0&&p!=="all"?p:null,status:D==="all"?null:D,q:P.trim().length===0?null:P})},[p,t,D,P]),o.useEffect(()=>{t!==void 0&&I(s=>s===t?s:(R(void 0),w(void 0),t))},[t]),o.useEffect(()=>{ke.current||!Se(window.location.search).isNew||(ke.current=!0,Re({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const u=ue(window.location.search);_(u.nameQuery),Y(u.statusFilter),I(S=>{const z=t??u.agentFilter;return S===z?S:(R(void 0),w(void 0),z)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{te({token:ee,size:F,agentId:p})},[p,F,ee,te]);const ie=o.useMemo(()=>{const s=P.trim().toLowerCase();return d.filter(u=>!(D!=="all"&&u.status!==D||s.length>0&&!u.name.toLowerCase().includes(s)))},[d,P,D]),Ce=rt(d),Ee=y!=null||f!=null,Je=async s=>{if(!N(s.id,"MANAGE"))return;const u=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:u}),l(K.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:u}),await te({token:ee,size:F,agentId:p})}catch(S){a==null||a.showError(S)}},Xe=async s=>{if(N(s.id,"MANAGE")){C(u=>new Set(u).add(s.id));try{await n.createScheduleRun({scheduleId:s.id}),l(K.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"});const u=await n.listScheduleRuns({scheduleId:s.id});k(S=>({...S,[s.id]:u}))}catch(u){a==null||a.showError(u)}finally{C(u=>{const S=new Set(u);return S.delete(s.id),S})}}},et=async s=>{if(N(s.id,"DELETE")){X(null);try{await n.deleteSchedule({id:s.id}),l(K.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Te()}catch(u){a==null||a.showError(u)}}},ze=()=>{f!=null&&R(f)},Ae=()=>{y==null||y===""||R(y)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(lt,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(it,{query:P,setQuery:_,placeholder:"Search schedules by name"})}),e.jsx(me,{value:D,onValueChange:Y,options:Jt,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Be,{value:p,selectedLabel:p==="all"?"All agents":m[p]??p,onValueChange:s=>{I(s),R(void 0),w(void 0)},onAgentPicked:s=>{T(u=>({...u,[Ue(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(L.Primary,{type:"button",disabled:!Z,onClick:()=>Z&&G({kind:"create",agentId:p!=="all"?p:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:O("min-h-0 flex-1 overflow-auto px-4 py-4",se!=null?"flex flex-col":void 0),children:M?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,u)=>e.jsx(ot,{className:"h-12 w-full rounded-md"},u))}):se!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(he,{title:"Couldn't load schedules",description:se,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(he,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):ie.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(he,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ee?e.jsx(Pe,{pageSize:F,rowCount:0,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(ct,{className:"min-w-240",children:[e.jsx(dt,{children:e.jsxs(De,{className:"hover:bg-transparent",children:[e.jsx(V,{children:"Schedule Name"}),e.jsx(V,{children:"Task"}),Ce?e.jsx(V,{children:"Created by"}):null,e.jsx(V,{children:"Frequency"}),e.jsx(V,{children:"Status"}),e.jsx(V,{children:"Last 5 runs"}),e.jsx(V,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(ut,{children:ie.map(s=>{const u=ae({cron:s.cron,timezone:s.timezone}),S=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(De,{children:[e.jsxs(W,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(A,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S})]})]}),e.jsx(W,{className:"w-64 max-w-64",children:e.jsx(Ge,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Ce?e.jsx(W,{children:e.jsx(mt,{subject:s.createdBySubject})}):null,e.jsx(W,{children:u}),e.jsx(W,{children:e.jsx(Ye,{status:s.status})}),e.jsx(W,{children:b?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(Zt,{runs:h[s.id]??[],...g?{onOpenSession:z=>Ze({run:z,schedule:s})}:{}})}),e.jsx(W,{className:"text-right",children:e.jsx(es,{schedule:s,running:j.has(s.id),canManage:N(s.id,"MANAGE"),canDelete:N(s.id,"DELETE"),onRunNow:()=>void Xe(s),onEdit:()=>{N(s.id,"MANAGE")&&G({kind:"edit",schedule:s})},onTogglePause:()=>void Je(s),onDelete:()=>{N(s.id,"DELETE")&&X(s)}})})]},s.id)})})]}),(ie.length>0||Ee)&&e.jsx(Pe,{pageSize:F,rowCount:ie.length,canPrev:y!=null,canNext:f!=null,onPrev:Ae,onNext:ze,pageSizeOptions:Le,onPageSizeChange:s=>{const u=de(s);le(u),R(void 0),w(void 0)}})]})}),J.kind==="create"?e.jsx(_e,{open:!0,mode:"create",initialAgentId:J.agentId??"",onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>Te()}):null,J.kind==="edit"?e.jsx(_e,{open:!0,mode:"edit",schedule:J.schedule,onOpenChange:s=>{s||G({kind:"closed"})},onSaved:()=>void te({token:ee,size:F,agentId:p})}):null,H!=null?e.jsxs(xt,{open:!0,onOpenChange:s=>{s||X(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(ht,{children:e.jsxs(ft,{children:[e.jsx(gt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",H.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(bt,{children:[e.jsx(L.Secondary,{type:"button",onClick:()=>X(null),children:"Cancel"}),e.jsx(L.Destructive,{type:"button",disabled:!N(H.id,"DELETE"),onClick:()=>void et(H),children:"Delete"})]})]}):null]})}export{ns as SchedulesPage};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-Y5NTNBCL-
|
|
2
|
-
import{b9 as j,ab as E,bl as k,q as C,a9 as N,bm as O,b1 as D,r as l,_ as g,j as e,P as L,I as v,a3 as I,c as f,bn as P,b6 as d,b4 as A}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-Y5NTNBCL-BWyZvSat.js","./chunk-HB2ZQ4CZ-DiRiTO48.js","./index-D962hlvu.js","./index-B01pXqvC.css","./ConnectorSettings-DYJ6Z6YL-CcJhppzx.js","./SkillSettings-F7X7TZII-BPHGKv7f.js","./SandboxSettings-KLDK6WZH-DZLs35fh.js","./WebSearchSettings-VNL63UFQ-D_dYueo8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{b9 as j,ab as E,bl as k,q as C,a9 as N,bm as O,b1 as D,r as l,_ as g,j as e,P as L,I as v,a3 as I,c as f,bn as P,b6 as d,b4 as A}from"./index-D962hlvu.js";var T=l.lazy(()=>d(()=>import("./ModelSettings-Y5NTNBCL-BWyZvSat.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),z=l.lazy(()=>d(()=>import("./ConnectorSettings-DYJ6Z6YL-CcJhppzx.js"),__vite__mapDeps([4,1,2,3]),import.meta.url)),M=l.lazy(()=>d(()=>import("./SkillSettings-F7X7TZII-BPHGKv7f.js"),__vite__mapDeps([5,1,2,3]),import.meta.url)),R=l.lazy(()=>d(()=>import("./SandboxSettings-KLDK6WZH-DZLs35fh.js"),__vite__mapDeps([6,1,2,3]),import.meta.url)),B=l.lazy(()=>d(()=>import("./WebSearchSettings-VNL63UFQ-D_dYueo8.js"),__vite__mapDeps([7,2,3]),import.meta.url));function V(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(A,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var W=({headerStart:y}={})=>{const{settingsOpen:a,settingsSection:t,setSettingsOpen:r}=j(),n=E(),b=k(),m=C(),{refresh:p}=N(),S=O(),w=D(),i=S||w,o=(n==null?void 0:n.skillCatalog)!=null,c=(n==null?void 0:n.sandboxCatalog)!=null,u=(n==null?void 0:n.webSearchCatalog)!=null,x=l.useCallback(()=>{m(g.Settings.CLOSED,{section:t}),r(!1)},[t,r,m]);l.useEffect(()=>{if(a)return()=>{p(),b==null||b()}},[a,p,b]),l.useEffect(()=>{!o&&t==="skills"&&r(a,"models"),!c&&t==="sandbox"&&r(a,"models"),!u&&t==="web-search"&&r(a,"models")},[o,c,u,t,a,r]),l.useEffect(()=>{if(!a)return;const s=h=>{h.key==="Escape"&&(P()||(h.stopImmediatePropagation(),x()))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,a]);const _=l.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),u&&s.push({id:"web-search",label:"Web search",icon:"search"}),s},[o,c,u]);return!a||!n?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden bg-primary-bg",children:[e.jsx(L,{title:"Settings",start:y??e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:I({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(v,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 min-w-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full min-w-0 gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"overflow-x-auto":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:_.map(s=>e.jsxs("button",{type:"button","aria-current":t===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",t===s.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{m(g.Settings.SECTION_CHANGED,{section:s.id}),r(!0,s.id)},children:[e.jsx(v,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-hidden px-4 py-4 sm:px-6",children:e.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full min-w-0 max-w-210 flex-col",children:e.jsxs(l.Suspense,{fallback:e.jsx(V,{}),children:[t==="models"?e.jsx(T,{}):null,t==="connectors"?e.jsx(z,{}):null,t==="skills"&&o?e.jsx(M,{}):null,t==="sandbox"&&c?e.jsx(R,{}):null,t==="web-search"&&u?e.jsx(B,{}):null]})})})]})]})},q=W;export{q as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b9 as ce,d as pe,ab as ge,v as fe,ba as ye,bb as he,bc as de,b as me,bd as Se,r as a,be,bf as Ae,x as Oe,bg as ve,D as Ne,bh as _,bi as C,bj as ne,bk as B}from"./index-
|
|
1
|
+
import{b9 as ce,d as pe,ab as ge,v as fe,ba as ye,bb as he,bc as de,b as me,bd as Se,r as a,be,bf as Ae,x as Oe,bg as ve,D as Ne,bh as _,bi as C,bj as ne,bk as B}from"./index-D962hlvu.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-Dubdb29l.js";var T="try_agent_name",$="history_agent_name";function te(t){return t!=null&&t.length>0?t:null}function k(t){const o=new URLSearchParams(t.startsWith("?")?t.slice(1):t),u=te(o.get(T));if(u!=null)return{intent:"try-agent",agentName:u};const e=te(o.get($));return e==null?null:{intent:"history",agentName:e}}function Pe(t,o){t.delete(T),t.delete($),o!=null&&t.set(o.intent==="try-agent"?T:$,o.agentName)}function se(t,o){const u=new URLSearchParams(t.startsWith("?")?t.slice(1):t);Pe(u,o);const e=u.toString();return e.length>0?`?${e}`:""}function re(t){const o=t.sessionAccessError!=null?t.pendingSessionId:t.activeRemoteId??t.pendingSessionId;if(o!=null)return{type:"session",sessionId:o};const{mode:u,agentConfigMode:e}=t;if(u.status==="active"&&u.isMutable&&u.isCreateAgent)return{type:"buildAgent"};if(u.status==="active"&&!u.isMutable&&e!=="SingleAgent"){const p=u.agentName??u.agentId;if(p!=null)return{type:"agent",agentName:p}}return{type:"root"}}function Ce(t){return t.settingsOpen?{type:"settings"}:t.schedulesOpen?{type:"schedules"}:t.environmentsOpen?{type:"environments"}:t.sessionsOpen&&t.sharedSessionId!=null?{type:"sharedSession",sessionId:t.sharedSessionId}:t.sessionsOpen?{type:"sessionsBrowser"}:t.libraryOpen&&t.libraryAgentId!=null?{type:"libraryAgent",agentId:t.libraryAgentId}:t.libraryOpen?{type:"library"}:re(t)}function O(t){return t.type==="root"||t.type==="agent"||t.type==="session"}function Ie(t){return t.type==="sessionsBrowser"||t.type==="sharedSession"}function Le({routes:t,activeRemoteId:o,initialSettingsOpen:u}){var Z,x;const e=ce(),p=pe(),q=ge(),v=fe(),I=ye(),U=he(),G=de(),K=me(),W=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:K,sessions:v,schedules:U,sandboxEnvironments:G}),[t,q,K,v,U,G]),Y=c.settings!=null,ae=[c.settings,c.sessionsBrowser,c.sharedSession,c.libraryAgent,c.schedules,c.environments].join("\0"),j={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,sharedSessionId:e.sharedSessionId,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,environmentsOpen:e.environmentsOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:o,sessionAccessError:e.sessionAccessError,mode:e.mode,agentConfigMode:e.agentConfigMode},g=Ce(j),ie=JSON.stringify(g),S=a.useRef(null),w=a.useRef(null),N=a.useRef(null),R=a.useRef(!1),b=a.useRef(null),[le,oe]=a.useState(0),m=a.useRef(null),L=a.useRef(null),D=`${e.runtimeKey}\0${e.pendingSessionEpoch}`,M=a.useRef(D);M.current=D;const f=a.useRef(null),Q=a.useRef(!1),z=a.useRef(!1),J=a.useCallback(()=>{switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.setEnvironmentsOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}},[e]),A=a.useCallback(n=>{const s=b.current;(s==null?void 0:s.type)==="session"&&s.sessionId===n&&(b.current=null,oe(l=>l+1))},[]),V=a.useCallback(n=>{if(L.current=n,p==null){e.openHistorySession({sessionId:n});return}const s=M.current,l=I==null||v==null?Promise.resolve(!0):I.listPermissions({resourceType:"session",resourceIds:[n]}).then(i=>(i.data.permissions[n]??[]).includes("MANAGE")).catch(()=>!0);Promise.all([p.getSession({sessionId:n}),l]).then(([i,y])=>{if(L.current!==n){A(n);return}if(!y){A(n),e.openSharedSession(n);return}e.openHistorySession({sessionId:n,isMutable:i.isMutable,isCreateAgent:Ae(i),...i.agentName!=null?{agentName:i.agentName}:{}})}).catch(i=>{if(L.current!==n){A(n);return}if(M.current!==s){A(n);return}e.openInaccessibleSession({sessionId:n,message:Oe(i,"This session could not be loaded.")})})},[I,A,p,v,e]),d=a.useCallback(n=>{if(n==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const s=`${n.intent}\0${n.agentName}`,l=e.historyAgentFilter;if((l==null?void 0:l.intent)===n.intent&&l.agentName===n.agentName&&l.agentId!=null){f.current=null;return}f.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(f.current===s){if(i==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{f.current===s&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[p,e]),X=a.useCallback(n=>{e.selectLibraryAgent({isMutable:!1,agentName:n}),d({intent:"try-agent",agentName:n})},[d,e]),F=a.useCallback(n=>{switch(n.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"sharedSession":e.openSharedSession(n.sessionId);return;case"libraryAgent":e.openLibraryAgent(n.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"environments":e.setEnvironmentsOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===n.sessionId||o===n.sessionId)return;V(n.sessionId);return;case"agent":e.setLibraryOpen(!1),X(n.agentName);return;case"root":J();return}},[e,o,J,X,V]);return a.useEffect(()=>{if(R.current)return;const n=_({pathname:r.pathname,search:r.search,routes:t});if(!W&&(n==null?void 0:n.type)==="settings")return;R.current=!0;const s=_({pathname:r.pathname,search:r.search,routes:c})??{type:"root"},l=s.type==="agent"?{intent:"try-agent",agentName:s.agentName}:O(s)?k(r.search):null;m.current=l,N.current=s;const i=Y&&(u||s.type==="settings");if(s.type==="settings")Y&&e.setSettingsOpen(!0);else if(s.type==="library")e.setLibraryOpen(!0);else if(s.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(s.type==="libraryAgent")e.openLibraryAgent(s.agentId);else if(s.type==="schedules")e.setSchedulesOpen(!0);else if(s.type==="environments")e.setEnvironmentsOpen(!0);else{const P=re(j);C(P,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const y=i?{type:"settings"}:s;b.current=C(g,y)?null:y;const h=ne(y,c),E=se(B(y,r.search),l);w.current=y,h!=null&&(h!==r.pathname||E!==r.search)&&(S.current=h!==r.pathname?h:null,H({pathname:h,search:E,hash:r.hash},{replace:!0}))},[W]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!C(g,n))return;b.current=null}const s=ne(g,c);if(s==null)return;const i=`${c.basename.endsWith("/")?c.basename.slice(0,-1):c.basename}${r.pathname}`||"/",y=window.location.pathname===i?window.location.search:r.search,h=O(g),E=h?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!h&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const P=se(B(g,y),E),ee=w.current;if(w.current=g,s===r.pathname&&P===r.search)return;const ue=g.type==="session"&&e.pendingSessionId==null&&ee!=null&&ee.type!=="session";S.current=s!==r.pathname?s:null,H({pathname:s,search:P,hash:r.hash},{replace:ue})},[ie,ae,le,(Z=e.historyAgentFilter)==null?void 0:Z.agentName,(x=e.historyAgentFilter)==null?void 0:x.intent]),a.useEffect(()=>{if(!R.current)return;if(!z.current){z.current=!0;return}if(S.current===r.pathname){S.current=null,N.current=g;return}const n=_({pathname:r.pathname,search:r.search,routes:c});if(n==null){const l=c.root,i=B({type:"root"},r.search);S.current=l,H({pathname:l,search:i,hash:r.hash},{replace:!0}),F({type:"root"}),d(k(i));return}const s=N.current;N.current=n,(s==null||!C(s,n))&&(n.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),n.type!=="library"&&n.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),!Ie(n)&&e.sessionsOpen&&e.setSessionsOpen(!1),n.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),n.type!=="environments"&&e.environmentsOpen&&e.setEnvironmentsOpen(!1),F(n)),n.type!=="agent"&&O(n)?d(k(r.search)):O(n)||d(null)},[r.pathname,r.search]),null}export{Le as ShellRouteSync};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-72KREKYT-
|
|
2
|
-
import{cj as _,ck as Jt,b0 as Y,j as r,cl as en,r as m,bD as E,cm as Xe,cn as tn,co as Ye,cp as qe,cq as Qe,cr as Ze,cs as Je,ct as Z,cu as nn,cv as N,cw as rn,cx as sn,cy as on,cz as an,cA as cn,cB as ln,cC as un,cD as dn,cE as je,cF as mn,cG as fn,cH as me,cI as pn,cJ as hn,cK as xn,cL as et,cM as Fe,cN as fe,cO as Me,cP as ae,cQ as Se,cR as Ce,cS as Le,cT as Ke,d as Re,q as tt,t as ne,u as C,w as gn,cU as vn,c as z,p as bn,cV as wn,_ as le,bB as ue,cW as ge,cX as yn,b1 as Te,bm as nt,cY as In,S as jn,a2 as $e,I as H,D as Mn,a3 as te,cZ as rt,c_ as Sn,c$ as Cn,d0 as Ln,d1 as ze,bq as Rn,aa as Tn,E as Ge,b3 as st,d2 as Nn,P as Pn,d3 as En,b4 as ve,b5 as Dn,d4 as ot,d5 as at,bP as An,b6 as Ne,d6 as _n,cg as On}from"./index-CHtf87eT.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-NRMAG6HF-BKTcpJl0.js";const Pe=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Jt({source:"threads",query:{type:"index",index:t,archived:s},get:u=>u.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=Y(c);let d;return e[5]!==a||e[6]!==o?(d=r.jsx(en,{value:a,children:o}),e[5]=a,e[6]=o,e[7]=d):d=e[7],d},ct=m.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,c=o.ThreadListItem;let a;e[0]!==c?(a=r.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==t||e[4]!==a?(d=r.jsx(Pe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=d):d=e[5],d},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);ct.displayName="ThreadListPrimitive.ItemByIndex";const He=({archived:n,children:e})=>{const t=E(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return Xe(()=>Array.from({length:t},(s,o)=>r.jsx(Pe,{index:o,archived:n,children:r.jsx(tn,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},lt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const a=s.ThreadListItem;let d;e[0]!==a?(d=()=>r.jsx(a,{}),e[0]=a,e[1]=d):d=e[1];let u;return e[2]!==i||e[3]!==d?(u=r.jsx(He,{archived:i,children:d}),e[2]=i,e[3]=d,e[4]=u):u=e[4],u}let c;return e[5]!==i||e[6]!==o?(c=r.jsx(He,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c};lt.displayName="ThreadListPrimitive.Items";const ut=n=>{const e=_(2),{fallback:t}=n,s=E(Kn)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};ut.displayName="ThreadListItemPrimitive.Title";function Kn(n){return n.threadListItem.title}const $n=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},zn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},Gn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},Hn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},Un=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Vn=()=>{const n=_(5),e=Y(),t=E(Wn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Wn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Xn=Object.defineProperty,L=(n,e)=>Xn(n,"name",{value:e,configurable:!0}),Yn=["Enter"," "],qn=["ArrowDown","PageUp","Home"],dt=["ArrowUp","PageDown","End"],Qn=[...qn,...dt],pe="Menu",[we,Zn,Jn]=Ze(pe),[J,mt]=Ye(pe,[Jn,qe,Qe]),Ee=qe(),ft=Qe(),[er,ie]=J(pe),[tr,De]=J(pe),nr=L(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:c=!0}=n,a=Ee(e),[d,u]=m.useState(null),l=m.useRef(!1),h=fn(i),p=me(o);return m.useEffect(()=>{const f=L(()=>{l.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=L(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const f=L(()=>h(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,h]),r.jsx(pn,{...a,children:r.jsx(er,{scope:e,open:t,onOpenChange:h,content:d,onContentChange:u,children:r.jsx(tr,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:l,dir:p,modal:c,children:s})})})},"Menu"),rr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e,i=Ee(s);return r.jsx(hn,{...i,...o,ref:t})},"MenuAnchor")),pt="MenuPortal",[sr,or]=J(pt,{forceMount:void 0}),ar=L(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ie(pt,e);return r.jsx(sr,{scope:e,forceMount:t,children:r.jsx(Je,{present:t||i.open,children:r.jsx(xn,{asChild:!0,container:o,children:s})})})},"MenuPortal"),Q="MenuContent",[ir,ht]=J(Q),cr=m.forwardRef(L(function(e,t){const s=or(Q,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,c=ie(Q,e.__scopeMenu),a=De(Q,e.__scopeMenu);return r.jsx(we.Provider,{scope:e.__scopeMenu,children:r.jsx(Je,{present:o||c.open,children:r.jsx(we.Slot,{scope:e.__scopeMenu,children:a.modal?r.jsx(lr,{...i,ref:t}):r.jsx(ur,{...i,ref:t})})})})},"MenuContent")),lr=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu),o=m.useRef(null),i=Z(t,o);return m.useEffect(()=>{const c=o.current;if(c)return nn(c)},[]),r.jsx(xt,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:N(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),ur=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu);return r.jsx(xt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),dr=mn("MenuContent.ScrollLock"),xt=m.forwardRef(L(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...I}=e,j=ie(Q,s),M=De(Q,s),y=Ee(s),B=ft(s),P=Zn(s),[F,K]=m.useState(null),O=m.useRef(null),S=Z(t,O,j.onContentChange),R=m.useRef(0),T=m.useRef(""),U=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),G=m.useRef(0),W=g?sn:m.Fragment,w=g?{as:dr,allowPinchZoom:!0}:void 0,D=L(v=>{var ee,ke;const A=T.current+v,k=P().filter(q=>!q.disabled),X=document.activeElement,he=(ee=k.find(q=>q.ref.current===X))==null?void 0:ee.textValue,xe=k.map(q=>q.textValue),Oe=yt(xe,A,he),oe=(ke=k.find(q=>q.textValue===Oe))==null?void 0:ke.ref.current;L((function q(Be){T.current=Be,window.clearTimeout(R.current),Be!==""&&(R.current=window.setTimeout(()=>q(""),1e3))}),"updateSearch")(A),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),rn();const b=m.useCallback(v=>{var k,X;return V.current===((k=$.current)==null?void 0:k.side)&&jt(v,(X=$.current)==null?void 0:X.area)},[]);return r.jsx(ir,{scope:s,searchRef:T,onItemEnter:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),onItemLeave:m.useCallback(v=>{var A;b(v)||((A=O.current)==null||A.focus(),K(null))},[b]),onTriggerLeave:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),pointerGraceTimerRef:U,onPointerGraceIntentChange:m.useCallback(v=>{$.current=v},[]),children:r.jsx(W,{...w,children:r.jsx(on,{asChild:!0,trapped:i,onMountAutoFocus:N(c,v=>{var A;v.preventDefault(),(A=O.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:r.jsx(an,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,children:r.jsx(cn,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:K,onEntryFocus:N(u,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(ln,{role:"menu","aria-orientation":"vertical","data-state":gt(j.open),"data-radix-menu-content":"",dir:M.dir,...y,...I,ref:S,style:{outline:"none",...I.style},onKeyDown:N(I.onKeyDown,v=>{const k=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,he=v.key.length===1;k&&(v.key==="Tab"&&v.preventDefault(),!X&&he&&D(v.key));const xe=O.current;if(v.target!==xe||!Qn.includes(v.key))return;v.preventDefault();const oe=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dt.includes(v.key)&&oe.reverse(),bt(oe)}),onBlur:N(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),T.current="")}),onPointerMove:N(e.onPointerMove,de(v=>{const A=v.target,k=G.current!==v.clientX;if(v.currentTarget.contains(A)&&k){const X=v.clientX>G.current?"right":"left";V.current=X,G.current=v.clientX}}))})})})})})})},"MenuContentImpl")),ye="MenuItem",Ue="menu.itemSelect",mr=m.forwardRef(L(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,c=m.useRef(null),a=De(ye,e.__scopeMenu),d=ht(ye,e.__scopeMenu),u=Z(t,c),l=m.useRef(!1),h=L(()=>{const p=c.current;if(!s&&p){const f=new CustomEvent(Ue,{bubbles:!0,cancelable:!0});p.addEventListener(Ue,x=>o==null?void 0:o(x),{once:!0}),un(p,f),f.defaultPrevented?l.current=!1:a.onClose()}},"handleSelect");return r.jsx(fr,{...i,ref:u,disabled:s,onClick:N(e.onClick,h),onPointerDown:p=>{var f;(f=e.onPointerDown)==null||f.call(e,p),l.current=!0},onPointerUp:N(e.onPointerUp,p=>{var f;l.current||(f=p.currentTarget)==null||f.click()}),onKeyDown:N(e.onKeyDown,p=>{s||p.target!==p.currentTarget||d.searchRef.current!==""&&p.key===" "||Yn.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),fr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...c}=e,a=ht(ye,s),d=ft(s),u=m.useRef(null),l=Z(t,u),[h,p]=m.useState(!1),[f,x]=m.useState("");return m.useEffect(()=>{const g=u.current;g&&x((g.textContent??"").trim())},[c.children]),r.jsx(we.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(dn,{asChild:!0,...d,focusable:!o,children:r.jsx(je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...c,ref:l,onPointerMove:N(e.onPointerMove,de(g=>{o?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:N(e.onPointerLeave,de(g=>a.onItemLeave(g))),onFocus:N(e.onFocus,()=>p(!0)),onBlur:N(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),pr="MenuRadioGroup",[js,Ms]=J(pr,{value:void 0,onValueChange:L(()=>{},"onValueChange")}),hr="MenuItemIndicator",[Ss,Cs]=J(hr,{checked:!1}),xr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),gr="MenuSub",[Ls,Rs]=J(gr);function gt(n){return n?"open":"closed"}L(gt,"getOpenState");function vt(n){return n==="indeterminate"}L(vt,"isIndeterminate");function vr(n){return vt(n)?"indeterminate":n?"checked":"unchecked"}L(vr,"getCheckedState");function bt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}L(bt,"focusFirst");function wt(n,e){return n.map((t,s)=>n[(e+s)%n.length])}L(wt,"wrapArray");function yt(n,e,t){const o=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=wt(n,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==t));const d=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==t?d:void 0}L(yt,"getNextMatch");function It(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],d=e[c],u=a.x,l=a.y,h=d.x,p=d.y;l>s!=p>s&&t<(h-u)*(s-l)/(p-l)+u&&(o=!o)}return o}L(It,"isPointInPolygon");function jt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return It(t,e)}L(jt,"isPointerInGraceArea");function de(n){return e=>e.pointerType==="mouse"?n(e):void 0}L(de,"whenMouse");var br=nr,wr=rr,yr=ar,Ir=cr,jr=mr,Mr=xr,Sr=Object.defineProperty,re=(n,e)=>Sr(n,"name",{value:e,configurable:!0}),Ae="DropdownMenu",[Cr,Mt]=Ye(Ae,[mt]),se=mt(),[Lr,St]=Cr(Ae),Ct=re(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,d=se(e),u=m.useRef(null),[l,h]=et({prop:o,defaultProp:i??!1,onChange:c,caller:Ae});return r.jsx(Lr,{scope:e,triggerId:Fe(),triggerRef:u,contentId:Fe(),open:l,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:r.jsx(br,{...d,open:l,onOpenChange:h,dir:s,modal:a,children:t})})},"DropdownMenu"),Rr="DropdownMenuTrigger",Lt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,c=St(Rr,s),a=se(s),d=Z(t,c.triggerRef);return r.jsx(wr,{asChild:!0,...a,children:r.jsx(je.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...i,ref:d,onPointerDown:N(e.onPointerDown,u=>{!o&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:N(e.onKeyDown,u=>{o||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),Rt=re(n=>{const{__scopeDropdownMenu:e,...t}=n,s=se(e);return r.jsx(yr,{...s,...t})},"DropdownMenuPortal"),Tr="DropdownMenuContent",Tt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=St(Tr,s),c=se(s),a=m.useRef(!1);return r.jsx(Ir,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...o,ref:t,onCloseAutoFocus:N(e.onCloseAutoFocus,d=>{var u;a.current||(u=i.triggerRef.current)==null||u.focus(),a.current=!1,d.preventDefault()}),onInteractOutside:N(e.onInteractOutside,d=>{const u=d.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,h=u.button===2||l;(!i.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Nt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(jr,{...i,...o,ref:t})},"DropdownMenuItem")),Pt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(Mr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Et=Ct,Dt=Lt,Nr=Rt,At=Tt,_t=Nt,Ot=Pt;const Pr=Object.freeze(Object.defineProperty({__proto__:null,Content:At,DropdownMenu:Ct,DropdownMenuContent:Tt,DropdownMenuItem:Nt,DropdownMenuPortal:Rt,DropdownMenuSeparator:Pt,DropdownMenuTrigger:Lt,Item:_t,Portal:Nr,Root:Et,Separator:Ot,Trigger:Dt,createDropdownMenuScope:Mt},Symbol.toStringTag,{value:"Module"})),Er=fe(Dt),Dr=fe(At),Ar=fe(_t),_r=fe(Ot),kt=m.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const c=E(Or),{switchToNewThread:a}=Un();let d;t[4]!==c?(d=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=d):d=t[5];let u;t[6]!==o||t[7]!==a?(u=N(o,a),t[6]=o,t[7]=a,t[8]=u):u=t[8];let l;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==d||t[13]!==u?(l=r.jsx(Me.button,{type:"button",...d,...i,ref:e,disabled:s,onClick:u}),t[9]=s,t[10]=e,t[11]=i,t[12]=d,t[13]=u,t[14]=l):l=t[14],l});kt.displayName="ThreadListPrimitive.New";function Or(n){return n.threads.newThreadId===n.threads.mainThreadId}const kr=()=>{const{loadMore:n,disabled:e}=Vn();return e?null:n},Br=ae("ThreadListPrimitive.LoadMore",kr),[Fr,Kr]=Ze("ThreadList"),Ie=Fr,Bt=Ce(null),$r=Bt.Provider,_e=()=>Se(Bt),Ft=m.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(Ie.Provider,{scope:void 0,children:r.jsx(Ie.Slot,{scope:void 0,children:r.jsx(Me.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Ft.displayName="ThreadListPrimitive.Root";var zr=Le({ItemByIndex:()=>ct,Items:()=>lt,LoadMore:()=>Br,New:()=>kt,Root:()=>Ft});const Kt=m.forwardRef((n,e)=>{const t=E(u=>u.threads.mainThreadId===u.threadListItem.id),s=Ke(null),o=Ke(null),i=Xe(()=>({triggerRef:s,moreRef:o}),[]),c=Kr(void 0),a=me(),d=u=>{const l=a==="rtl"?"ArrowLeft":"ArrowRight",h=a==="rtl"?"ArrowRight":"ArrowLeft",p=s.current,f=o.current;if(p&&u.target===p)if(u.key==="ArrowDown"||u.key==="ArrowUp"){const x=c().map(I=>I.ref.current).filter(I=>I!==null),g=x[x.indexOf(p)+(u.key==="ArrowDown"?1:-1)];g&&(g.focus(),u.preventDefault())}else u.key===l&&f&&(f.focus(),u.preventDefault());else f&&u.target===f&&u.key===h&&(p==null||p.focus(),u.preventDefault())};return r.jsx($r,{value:i,children:r.jsx(Me.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:N(n.onKeyDown,d),ref:e})})});Kt.displayName="ThreadListItemPrimitive.Root";const Gr=()=>{const{archive:n}=$n();return n},Hr=ae("ThreadListItemPrimitive.Archive",Gr),Ur=()=>{const{unarchive:n}=Gn();return n},Vr=ae("ThreadListItemPrimitive.Unarchive",Ur),Wr=()=>{const{delete:n}=zn();return n},Xr=ae("ThreadListItemPrimitive.Delete",Wr),Yr=()=>{const{switchTo:n}=Hn();return n},qr=ae("ThreadListItemPrimitive.Trigger",Yr),$t=m.forwardRef((n,e)=>{var i;const t=_(3),s=Z(e,(i=_e())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(Ie.ItemSlot,{scope:void 0,children:r.jsx(qr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});$t.displayName="ThreadListItemPrimitive.Trigger";var zt=Le({Archive:()=>Hr,Delete:()=>Xr,Root:()=>Kt,Title:()=>ut,Trigger:()=>$t,Unarchive:()=>Vr});const ce=Mt(),Gt=Ce(()=>{}),Ht=()=>Se(Gt),Ut=Ce(!1),Vt=()=>Se(Ut),Wt=n=>{const e=_(26);let t,s,o,i,c,a,d;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:s,onOpenChange:i,sharedFocusGroup:d,modal:o,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=c,e[6]=a,e[7]=d):(t=e[1],s=e[2],o=e[3],i=e[4],c=e[5],a=e[6],d=e[7]);const u=d===void 0?!1:d,l=u?!1:o??!0,h=ce(t),p=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==c||e[11]!==p||e[12]!==f?(x={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=c,e[11]=p,e[12]=f,e[13]=x):x=e[13];const[g,I]=et(x);let j;e[14]!==l||e[15]!==g||e[16]!==a||e[17]!==h||e[18]!==I?(j=r.jsx(Et,{...h,...a,modal:l,open:g,onOpenChange:I}),e[14]=l,e[15]=g,e[16]=a,e[17]=h,e[18]=I,e[19]=j):j=e[19];let M;e[20]!==I||e[21]!==j?(M=r.jsx(Gt.Provider,{value:I,children:j}),e[20]=I,e[21]=j,e[22]=M):M=e[22];let y;return e[23]!==u||e[24]!==M?(y=r.jsx(Ut.Provider,{value:u,children:M}),e[23]=u,e[24]=M,e[25]=y):y=e[25],y};Wt.displayName="ThreadListItemMorePrimitive.Root";const Xt=m.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ce(s),c=_e(),a=Ht(),d=Vt(),u=Z(e,c==null?void 0:c.moreRef),l=me()==="rtl"?"ArrowLeft":"ArrowRight",h=Er;let p;t[0]!==l||t[1]!==a||t[2]!==d?(p=g=>{!d||g.key!==l||(g.preventDefault(),a(!0))},t[0]=l,t[1]=a,t[2]=d,t[3]=p):p=t[3];const f=N(o.onKeyDown,p);let x;return t[4]!==h||t[5]!==u||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(h,{...i,...o,onKeyDown:f,ref:u}),t[4]=h,t[5]=u,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});Xt.displayName="ThreadListItemMorePrimitive.Trigger";const Yt=m.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...c}=n,a=i===void 0?4:i,d=ce(s),u=Ht(),l=_e(),h=Vt(),p=me()==="rtl"?"ArrowRight":"ArrowLeft",f=Pr,x=Dr;let g;t[0]!==p||t[1]!==(l==null?void 0:l.moreRef)||t[2]!==u||t[3]!==h?(g=P=>{var F;!h||P.key!==p||(P.preventDefault(),u(!1),(F=l==null?void 0:l.moreRef.current)==null||F.focus())},t[0]=p,t[1]=l==null?void 0:l.moreRef,t[2]=u,t[3]=h,t[4]=g):g=t[4];const I=N(c.onKeyDown,g);let j;t[5]!==(l==null?void 0:l.moreRef)||t[6]!==h?(j=()=>{var P;h&&((P=l==null?void 0:l.moreRef.current)==null||P.focus())},t[5]=l==null?void 0:l.moreRef,t[6]=h,t[7]=j):j=t[7];const M=N(c.onEscapeKeyDown,j);let y;t[8]!==x||t[9]!==e||t[10]!==c||t[11]!==d||t[12]!==a||t[13]!==I||t[14]!==M?(y=r.jsx(x,{...d,...c,onKeyDown:I,onEscapeKeyDown:M,ref:e,sideOffset:a}),t[8]=x,t[9]=e,t[10]=c,t[11]=d,t[12]=a,t[13]=I,t[14]=M,t[15]=y):y=t[15];let B;return t[16]!==o||t[17]!==d||t[18]!==f.Portal||t[19]!==y?(B=r.jsx(f.Portal,{...d,...o,children:y}),t[16]=o,t[17]=d,t[18]=f.Portal,t[19]=y,t[20]=B):B=t[20],B});Yt.displayName="ThreadListItemMorePrimitive.Content";const qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(Ar,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});qt.displayName="ThreadListItemMorePrimitive.Item";const Qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(_r,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});Qt.displayName="ThreadListItemMorePrimitive.Separator";var be=Le({Content:()=>Yt,Item:()=>qt,Root:()=>Wt,Separator:()=>Qt,Trigger:()=>Xt});function Qr(){const n=ne(),e=Re(),t=Te(),s=nt(),o=t||s,[i,c]=m.useState(!1),[a,d]=m.useState(""),[u,l]=m.useState(null),h=m.useRef(null),p=m.useRef(null),f=m.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||d("")},[i]);const{agents:I,isInitialLoading:j,isSearching:M,loadingMore:y,hasMore:B,listRef:P,sentinelRef:F}=In({enabled:i&&x,query:a});if(m.useLayoutEffect(()=>{if(!i||o){l(null);return}const S=()=>{var T;const R=(T=h.current)==null?void 0:T.getBoundingClientRect();R&&l({top:R.top,left:R.right+4})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,o]),m.useEffect(()=>{if(!i||o)return;const S=R=>{var U,$;const T=R.target;(U=h.current)!=null&&U.contains(T)||($=p.current)!=null&&$.contains(T)||c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i,o]),!x)return null;const K=S=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(S),c(!1)},O=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:S=>S.stopPropagation(),children:[r.jsx(jn,{query:a,setQuery:d,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:P,className:z("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?r.jsxs($e,{className:z("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K(null),children:["All chats",g==null?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,j?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):I.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[I.map(S=>{const R=Mn(S),T=(g==null?void 0:g.agentId)===R;return r.jsxs($e,{className:z("justify-between gap-2 text-left",T&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K({agentId:R,agentName:S.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:S.name}),T?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),B?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:y?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:h,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:te({variant:"ghost",size:"icon",className:z("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>c(S=>!S),children:[r.jsx(H,{name:"funnel",className:"size-3.5"}),g!=null?r.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),o&&i?r.jsx(rt,{open:!0,onOpenChange:c,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:O})}):null,!o&&i&&u!=null?Sn.createPortal(r.jsx("div",{ref:p,id:f,role:"menu","aria-label":"Filter agents",style:{top:u.top,left:u.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:O}),Cn(h.current)):null]})}function Zr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const f=a.current;f!=null&&(f.focus(),f.select())},[n]);const d=i.trim(),l=d.length>0&&d.length<=ze&&!t,h=()=>{l&&o(d)},p=f=>{t||s(f)};return r.jsx(Rn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(Ge.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),r.jsx(Ge.Primary,{type:"button",disabled:!l,onClick:h,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:ze,className:Tn("h-9"),onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}})})})}var Jr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",es="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function ts({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o,onDelete:i}){const c=C("PermissionGuard"),a=nt(),d=Te(),[u,l]=m.useState(!1),[h,p]=m.useState(),f=d||a,x=m.useCallback(M=>{const y=M==null?void 0:M.closest(".aui-theme-root");p(y instanceof HTMLElement?y:void 0)},[]),g=te({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),I=n?r.jsx(c,{allowed:!e,children:r.jsxs("button",{type:"button",className:Jr,disabled:e,onClick:()=>{e||(l(!1),o())},children:[r.jsx(H,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,j=t?r.jsx(c,{allowed:!s,children:r.jsxs(zt.Delete,{className:es,onClick:()=>{s||(l(!1),i())},children:[r.jsx(H,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return f?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:g,onClick:()=>l(!0),children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(rt,{open:!0,onOpenChange:l,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[I,j]})}):null]}):r.jsxs(be.Root,{sharedFocusGroup:!0,children:[r.jsx(be.Trigger,{ref:x,"aria-label":"Session actions",title:"Session actions",className:g,children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(be.Content,{portalProps:{container:h},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[I,j]})]})}function ns({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const c=Y(),a=ne(),d=Re(),u=m.useRef(a==null?void 0:a.runtimeKey);u.current=a==null?void 0:a.runtimeKey;const l=tt(),h=bn(),p=C("ThreadListRow"),f=E(w=>w.threadListItem.id),x=E(w=>w.threadListItem.remoteId),g=E(w=>w.threadListItem.title),I=E(w=>w.threadListItem.lastMessageAt),j=E(w=>w.threadListItem.custom),M=E(w=>w.threads.mainThreadId),y=wn(j),B=t&&x!=null,P=s&&x!=null,F=B||P,K=x!=null&&!o(x),O=x!=null&&!i(x),S=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[R,T]=m.useState(!1),[U,$]=m.useState(!1),V=g??"New Chat",G=async w=>{if(w===(g??"").trim()){T(!1);return}$(!0);try{await c.threadListItem().rename(w),l(le.Session.RENAMED,ue(void 0,{sessionId:x,agentName:y})),T(!1)}catch(D){h==null||h.showError(D)}finally{$(!1)}},W=({sessionMutable:w,rowAgentName:D})=>{const b=!w&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(D==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===D||a.mode.agentId===D),v=Ln({sessionMutable:w,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:x,pendingSessionId:a==null?void 0:a.pendingSessionId});if((b||v)&&x!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(f)).catch(()=>{});return}if(x!=null){a==null||a.openHistorySession({sessionId:x,isMutable:w,...D!=null?{agentName:D}:{}});return}Promise.resolve(c.threads().switchToThread(f)).catch(()=>{})};return r.jsxs(zt.Root,{className:"min-w-0",children:[r.jsx(p,{title:V,active:f===M&&!S,agentName:y,lastMessageAt:I,onSelect:()=>{l(le.Session.SELECTED,ue({is_mutable:ge(j)},{sessionId:x,agentName:y}));const w=++n.current,D=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),x!=null&&d!=null&&yn(j)===void 0&&y==null){d.getSession({sessionId:x}).then(b=>({sessionMutable:b.isMutable,rowAgentName:b.agentName??void 0}),()=>({sessionMutable:ge(j),rowAgentName:y})).then(b=>{n.current===w&&u.current===D&&W(b)});return}W({sessionMutable:ge(j),rowAgentName:y})},actions:F?r.jsx(ts,{canRename:B,renameDisabled:K,canDelete:P,deleteDisabled:O,onRename:()=>T(!0),onDelete:()=>{l(le.Session.DELETED,ue(void 0,{sessionId:x,agentName:y}))}}):void 0}),r.jsx(Zr,{open:R,initialTitle:g??"",saving:U,onOpenChange:T,onSave:w=>{G(w)}})]})}function rs(n){const e=E(s=>s.threads.threadIds),t=E(s=>s.threads.threadItems);return m.useMemo(()=>{const s=vn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=o.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function ss(n){return n==="recent-history"||n==="mobile-drawer"}function os({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c}){const a=E(d=>d.threads.threadIds);return r.jsx(r.Fragment,{children:e.map(d=>{const u=a[d]??String(d);return r.jsx(Pe,{index:d,archived:!1,children:r.jsx(ns,{selectionRef:n,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c})},u)})})}var as="aui_thread-list-viewport",is=80;function cs({children:n,viewportRef:e,hideScrollbar:t}){var d;const s=ne(),o=E(u=>u.threadListItem.remoteId),i=(d=s==null?void 0:s.historyAgentFilter)==null?void 0:d.intent,c=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),a=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:a}),c?r.jsx(Qr,{}):null]}),r.jsx("div",{ref:e,"data-slot":as,className:z("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Zt({onThreadOpen:n,variant:e="default"}={}){const t=Y(),s=Re(),o=tt(),i=E(b=>b.threads.isLoading),c=E(b=>b.threads.isLoadingMore),a=E(b=>b.threads.hasMore),d=E(b=>b.threads.threadIds),u=E(b=>b.threads.threadItems),l=ne(),h=C("ThreadListShell"),p=C("ThreadListNewButton"),f=C("AgentsLibraryButton"),x=C("SessionsBrowserButton"),g=C("SchedulesButton"),I=C("EnvironmentsButton"),j=C("ThreadListRowSkeleton"),M=C("ThreadListEmptyState"),y=rs(e),B=m.useRef(null),P=m.useRef(a),F=m.useRef(t),K=m.useRef(0);P.current=a,F.current=t;const O=(l==null?void 0:l.isNewChatEnabled)!==!1,S=(l==null?void 0:l.mode.status)==="idle",R=ss(e),T=e==="mobile-drawer",U=typeof(s==null?void 0:s.renameSession)=="function",$=typeof(s==null?void 0:s.deleteSession)=="function",V=m.useMemo(()=>u.flatMap(b=>b.remoteId==null?[]:[b.remoteId]),[u]),{allows:G}=gn({resourceType:"session",resourceIds:V});m.useEffect(()=>{if(S||i||c)return;const b=B.current;if(!b)return;let v=!1;const A=()=>{if(v||!P.current||b.clientHeight<=0)return;const X=b.scrollHeight-b.scrollTop-b.clientHeight;b.scrollHeight>b.clientHeight&&X>is||F.current.threads().loadMore()};b.addEventListener("scroll",A,{passive:!0});const k=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>A());return k?k.observe(b):window.addEventListener("resize",A),A(),()=>{v=!0,b.removeEventListener("scroll",A),k==null||k.disconnect(),k||window.removeEventListener("resize",A)}},[a,S,i,c,d.length]);const W=()=>{if(o(le.Session.NEW,ue({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let w;S?w=r.jsx(M,{message:R?"No recent chats":void 0}):i?w=r.jsx(j,{}):y.length===0?w=r.jsx(M,{message:R?"No recent chats":void 0}):w=r.jsx(zr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(os,{selectionRef:K,indices:y,onThreadOpen:n,canRenameSession:U,canDeleteSession:$,canManageResource:b=>G(b,"MANAGE"),canDeleteResource:b=>G(b,"DELETE")})});const D=e==="recent-history"?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:W}):null,r.jsx("div",{className:"contents",onClick:()=>{T&&(n==null||n())},children:r.jsx(f,{})}),T?null:r.jsxs(r.Fragment,{children:[r.jsx(x,{}),r.jsx(g,{}),r.jsx(I,{})]})]});return r.jsx(h,{header:D,children:r.jsxs(cs,{viewportRef:B,hideScrollbar:R,children:[w,!S&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ls=m.lazy(()=>Ne(()=>import("./SettingsBuilder-72KREKYT-Dmu76Wzi.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-4F5FX65T-DVKEEd4R.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-KOMO4W53-DT8-DDE7.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),ms="h-5 w-5 max-w-40 shrink-0 object-contain",fs="h-5 max-w-40 shrink-0 object-contain",ps="w-20",hs="w-80",Ve=z(On,"text-sidebar-text"),We="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function xs({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function gs(){return An().presentation==="full"?null:r.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:r.jsx(Zt,{variant:"recent-history"})})}function vs(){var f;const n=Y(),e=ne(),t=C("AgentsLibraryButton"),s=C("SessionsBrowserButton"),o=C("SchedulesButton"),i=C("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0||(e==null?void 0:e.environmentsOpen)===!0,d=e==null?void 0:e.mode,u=!a&&(d==null?void 0:d.status)==="active"&&!d.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",l=!a&&d!=null&&st(d),h=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:te({variant:"ghost",className:z(Ve,u&&We)}),onClick:h,children:[r.jsx(H,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":l?"page":void 0,className:te({variant:"ghost",className:z(Ve,l&&We)}),onClick:p,children:[r.jsx(H,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0}),r.jsx(i,{compact:!0})]})}function bs({className:n,railRef:e,...t}){const s=ot(),o=at(s),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:e,className:z(ps,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(i,{variant:o.collapsedVariant,className:ms})}),r.jsx(vs,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(it,{labeled:!0,className:"flex-col"}),r.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ws({drawerRef:n,onClose:e}){const t=ot(),s=at(t),o=_n(),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:z(hs,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[r.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[r.jsx(i,{variant:s.expandedVariant,className:fs}),s.showTitle&&o!=null?r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}):r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("button",{type:"button","aria-label":"Close navigation",className:te({variant:"ghost",size:"icon"}),onClick:e,children:r.jsx(H,{name:"xmark"})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Zt,{variant:"mobile-drawer",onThreadOpen:e})}),r.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[r.jsx(it,{labeled:!0,onAction:e,className:"contents"}),r.jsx(c,{labeled:!0})]})]})}function Ts({className:n}){const e=ne(),t=Te(),s=C("AgentDetailsPage"),o=C("AgentsLibrary"),i=C("SessionsPage"),c=C("ShareChatButton"),a=C("ResetAgentBuilderButton"),d=C("ClearChatButton"),u=C("SaveAgentButton"),l=C("SelectAgentEmptyState"),[h,p]=m.useState(!1),f=m.useRef(null),x=m.useRef(null),g=m.useRef(null),I=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",M=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,B=y&&(e==null?void 0:e.libraryAgentId)==null,P=(e==null?void 0:e.sessionsOpen)===!0,F=(e==null?void 0:e.schedulesOpen)===!0,K=(e==null?void 0:e.environmentsOpen)===!0,O=M||y||P||F||K,S=e!=null&&st(e.mode),R=t&&(P||F||K||S&&!M&&!y),T=S&&!O&&!t,U=xs({overlayOpen:O,mode:e==null?void 0:e.mode}),$=Nn(),V=t&&(M||B),G=()=>p(!1),W=r.jsx("button",{ref:f,type:"button","aria-label":"Navigation","aria-expanded":h,className:z(te({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:r.jsx(H,{name:"panel-left"})});return m.useEffect(()=>{if(!h)return;const w=D=>{D.key==="Escape"&&(D.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[h]),m.useEffect(()=>{var D,b;const w=g.current;if(h){I.current=!0,w&&(w.inert=!0),(D=x.current)==null||D.focus();return}I.current&&(w&&(w.inert=!1),(b=f.current)==null||b.focus(),I.current=!1)},[h]),r.jsxs("div",{className:z("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(bs,{className:"hidden md:flex"}),T?r.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:r.jsx(kn,{})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[V?null:r.jsx(Pn,{className:z("bg-topbar-bg",(O||j||!$||R)&&"md:hidden"),start:W,title:!O&&!R?r.jsx(Bn,{}):null,end:!O&&!R?r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(c,{}),r.jsx(d,{}),r.jsx(u,{})]}):null}),r.jsx(En,{children:r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[U?r.jsx(gs,{}):null,r.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:M?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ls,{...V?{headerStart:W}:{}})}):R?r.jsx(Dn,{}):P?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:G,...V?{headerStart:W}:{}}):F?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(us,{})}):K?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ds,{})}):j?r.jsx(l,{}):r.jsx(Fn,{})})]})})]}),h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:G}),r.jsx(ws,{drawerRef:x,onClose:G})]}):null]})}export{Ts as SidebarLayout};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-72KREKYT-CdDx-q8Q.js","./index-D962hlvu.js","./index-B01pXqvC.css","./SchedulesPage-4F5FX65T-BUxoTOQI.js","./chunk-XIE7TJW5-CvvubFnj.js","./EnvironmentsPage-KOMO4W53-BlIcOJ78.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{cj as _,ck as Jt,b0 as Y,j as r,cl as en,r as m,bD as E,cm as Xe,cn as tn,co as Ye,cp as qe,cq as Qe,cr as Ze,cs as Je,ct as Z,cu as nn,cv as N,cw as rn,cx as sn,cy as on,cz as an,cA as cn,cB as ln,cC as un,cD as dn,cE as je,cF as mn,cG as fn,cH as me,cI as pn,cJ as hn,cK as xn,cL as et,cM as Fe,cN as fe,cO as Me,cP as ae,cQ as Se,cR as Ce,cS as Le,cT as Ke,d as Re,q as tt,t as ne,u as C,w as gn,cU as vn,c as z,p as bn,cV as wn,_ as le,bB as ue,cW as ge,cX as yn,b1 as Te,bm as nt,cY as In,S as jn,a2 as $e,I as H,D as Mn,a3 as te,cZ as rt,c_ as Sn,c$ as Cn,d0 as Ln,d1 as ze,bq as Rn,aa as Tn,E as Ge,b3 as st,d2 as Nn,P as Pn,d3 as En,b4 as ve,b5 as Dn,d4 as ot,d5 as at,bP as An,b6 as Ne,d6 as _n,cg as On}from"./index-D962hlvu.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-NRMAG6HF-DQrtQbNO.js";const Pe=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Jt({source:"threads",query:{type:"index",index:t,archived:s},get:u=>u.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=Y(c);let d;return e[5]!==a||e[6]!==o?(d=r.jsx(en,{value:a,children:o}),e[5]=a,e[6]=o,e[7]=d):d=e[7],d},ct=m.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,c=o.ThreadListItem;let a;e[0]!==c?(a=r.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==t||e[4]!==a?(d=r.jsx(Pe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=d):d=e[5],d},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);ct.displayName="ThreadListPrimitive.ItemByIndex";const He=({archived:n,children:e})=>{const t=E(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return Xe(()=>Array.from({length:t},(s,o)=>r.jsx(Pe,{index:o,archived:n,children:r.jsx(tn,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},lt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const a=s.ThreadListItem;let d;e[0]!==a?(d=()=>r.jsx(a,{}),e[0]=a,e[1]=d):d=e[1];let u;return e[2]!==i||e[3]!==d?(u=r.jsx(He,{archived:i,children:d}),e[2]=i,e[3]=d,e[4]=u):u=e[4],u}let c;return e[5]!==i||e[6]!==o?(c=r.jsx(He,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c};lt.displayName="ThreadListPrimitive.Items";const ut=n=>{const e=_(2),{fallback:t}=n,s=E(Kn)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};ut.displayName="ThreadListItemPrimitive.Title";function Kn(n){return n.threadListItem.title}const $n=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},zn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},Gn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},Hn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},Un=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Vn=()=>{const n=_(5),e=Y(),t=E(Wn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Wn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Xn=Object.defineProperty,L=(n,e)=>Xn(n,"name",{value:e,configurable:!0}),Yn=["Enter"," "],qn=["ArrowDown","PageUp","Home"],dt=["ArrowUp","PageDown","End"],Qn=[...qn,...dt],pe="Menu",[we,Zn,Jn]=Ze(pe),[J,mt]=Ye(pe,[Jn,qe,Qe]),Ee=qe(),ft=Qe(),[er,ie]=J(pe),[tr,De]=J(pe),nr=L(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:c=!0}=n,a=Ee(e),[d,u]=m.useState(null),l=m.useRef(!1),h=fn(i),p=me(o);return m.useEffect(()=>{const f=L(()=>{l.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=L(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const f=L(()=>h(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,h]),r.jsx(pn,{...a,children:r.jsx(er,{scope:e,open:t,onOpenChange:h,content:d,onContentChange:u,children:r.jsx(tr,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:l,dir:p,modal:c,children:s})})})},"Menu"),rr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e,i=Ee(s);return r.jsx(hn,{...i,...o,ref:t})},"MenuAnchor")),pt="MenuPortal",[sr,or]=J(pt,{forceMount:void 0}),ar=L(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ie(pt,e);return r.jsx(sr,{scope:e,forceMount:t,children:r.jsx(Je,{present:t||i.open,children:r.jsx(xn,{asChild:!0,container:o,children:s})})})},"MenuPortal"),Q="MenuContent",[ir,ht]=J(Q),cr=m.forwardRef(L(function(e,t){const s=or(Q,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,c=ie(Q,e.__scopeMenu),a=De(Q,e.__scopeMenu);return r.jsx(we.Provider,{scope:e.__scopeMenu,children:r.jsx(Je,{present:o||c.open,children:r.jsx(we.Slot,{scope:e.__scopeMenu,children:a.modal?r.jsx(lr,{...i,ref:t}):r.jsx(ur,{...i,ref:t})})})})},"MenuContent")),lr=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu),o=m.useRef(null),i=Z(t,o);return m.useEffect(()=>{const c=o.current;if(c)return nn(c)},[]),r.jsx(xt,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:N(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),ur=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu);return r.jsx(xt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),dr=mn("MenuContent.ScrollLock"),xt=m.forwardRef(L(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...I}=e,j=ie(Q,s),M=De(Q,s),y=Ee(s),B=ft(s),P=Zn(s),[F,K]=m.useState(null),O=m.useRef(null),S=Z(t,O,j.onContentChange),R=m.useRef(0),T=m.useRef(""),U=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),G=m.useRef(0),W=g?sn:m.Fragment,w=g?{as:dr,allowPinchZoom:!0}:void 0,D=L(v=>{var ee,ke;const A=T.current+v,k=P().filter(q=>!q.disabled),X=document.activeElement,he=(ee=k.find(q=>q.ref.current===X))==null?void 0:ee.textValue,xe=k.map(q=>q.textValue),Oe=yt(xe,A,he),oe=(ke=k.find(q=>q.textValue===Oe))==null?void 0:ke.ref.current;L((function q(Be){T.current=Be,window.clearTimeout(R.current),Be!==""&&(R.current=window.setTimeout(()=>q(""),1e3))}),"updateSearch")(A),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),rn();const b=m.useCallback(v=>{var k,X;return V.current===((k=$.current)==null?void 0:k.side)&&jt(v,(X=$.current)==null?void 0:X.area)},[]);return r.jsx(ir,{scope:s,searchRef:T,onItemEnter:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),onItemLeave:m.useCallback(v=>{var A;b(v)||((A=O.current)==null||A.focus(),K(null))},[b]),onTriggerLeave:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),pointerGraceTimerRef:U,onPointerGraceIntentChange:m.useCallback(v=>{$.current=v},[]),children:r.jsx(W,{...w,children:r.jsx(on,{asChild:!0,trapped:i,onMountAutoFocus:N(c,v=>{var A;v.preventDefault(),(A=O.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:r.jsx(an,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,children:r.jsx(cn,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:K,onEntryFocus:N(u,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(ln,{role:"menu","aria-orientation":"vertical","data-state":gt(j.open),"data-radix-menu-content":"",dir:M.dir,...y,...I,ref:S,style:{outline:"none",...I.style},onKeyDown:N(I.onKeyDown,v=>{const k=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,he=v.key.length===1;k&&(v.key==="Tab"&&v.preventDefault(),!X&&he&&D(v.key));const xe=O.current;if(v.target!==xe||!Qn.includes(v.key))return;v.preventDefault();const oe=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dt.includes(v.key)&&oe.reverse(),bt(oe)}),onBlur:N(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),T.current="")}),onPointerMove:N(e.onPointerMove,de(v=>{const A=v.target,k=G.current!==v.clientX;if(v.currentTarget.contains(A)&&k){const X=v.clientX>G.current?"right":"left";V.current=X,G.current=v.clientX}}))})})})})})})},"MenuContentImpl")),ye="MenuItem",Ue="menu.itemSelect",mr=m.forwardRef(L(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,c=m.useRef(null),a=De(ye,e.__scopeMenu),d=ht(ye,e.__scopeMenu),u=Z(t,c),l=m.useRef(!1),h=L(()=>{const p=c.current;if(!s&&p){const f=new CustomEvent(Ue,{bubbles:!0,cancelable:!0});p.addEventListener(Ue,x=>o==null?void 0:o(x),{once:!0}),un(p,f),f.defaultPrevented?l.current=!1:a.onClose()}},"handleSelect");return r.jsx(fr,{...i,ref:u,disabled:s,onClick:N(e.onClick,h),onPointerDown:p=>{var f;(f=e.onPointerDown)==null||f.call(e,p),l.current=!0},onPointerUp:N(e.onPointerUp,p=>{var f;l.current||(f=p.currentTarget)==null||f.click()}),onKeyDown:N(e.onKeyDown,p=>{s||p.target!==p.currentTarget||d.searchRef.current!==""&&p.key===" "||Yn.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),fr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...c}=e,a=ht(ye,s),d=ft(s),u=m.useRef(null),l=Z(t,u),[h,p]=m.useState(!1),[f,x]=m.useState("");return m.useEffect(()=>{const g=u.current;g&&x((g.textContent??"").trim())},[c.children]),r.jsx(we.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(dn,{asChild:!0,...d,focusable:!o,children:r.jsx(je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...c,ref:l,onPointerMove:N(e.onPointerMove,de(g=>{o?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:N(e.onPointerLeave,de(g=>a.onItemLeave(g))),onFocus:N(e.onFocus,()=>p(!0)),onBlur:N(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),pr="MenuRadioGroup",[js,Ms]=J(pr,{value:void 0,onValueChange:L(()=>{},"onValueChange")}),hr="MenuItemIndicator",[Ss,Cs]=J(hr,{checked:!1}),xr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),gr="MenuSub",[Ls,Rs]=J(gr);function gt(n){return n?"open":"closed"}L(gt,"getOpenState");function vt(n){return n==="indeterminate"}L(vt,"isIndeterminate");function vr(n){return vt(n)?"indeterminate":n?"checked":"unchecked"}L(vr,"getCheckedState");function bt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}L(bt,"focusFirst");function wt(n,e){return n.map((t,s)=>n[(e+s)%n.length])}L(wt,"wrapArray");function yt(n,e,t){const o=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=wt(n,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==t));const d=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==t?d:void 0}L(yt,"getNextMatch");function It(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],d=e[c],u=a.x,l=a.y,h=d.x,p=d.y;l>s!=p>s&&t<(h-u)*(s-l)/(p-l)+u&&(o=!o)}return o}L(It,"isPointInPolygon");function jt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return It(t,e)}L(jt,"isPointerInGraceArea");function de(n){return e=>e.pointerType==="mouse"?n(e):void 0}L(de,"whenMouse");var br=nr,wr=rr,yr=ar,Ir=cr,jr=mr,Mr=xr,Sr=Object.defineProperty,re=(n,e)=>Sr(n,"name",{value:e,configurable:!0}),Ae="DropdownMenu",[Cr,Mt]=Ye(Ae,[mt]),se=mt(),[Lr,St]=Cr(Ae),Ct=re(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,d=se(e),u=m.useRef(null),[l,h]=et({prop:o,defaultProp:i??!1,onChange:c,caller:Ae});return r.jsx(Lr,{scope:e,triggerId:Fe(),triggerRef:u,contentId:Fe(),open:l,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:r.jsx(br,{...d,open:l,onOpenChange:h,dir:s,modal:a,children:t})})},"DropdownMenu"),Rr="DropdownMenuTrigger",Lt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,c=St(Rr,s),a=se(s),d=Z(t,c.triggerRef);return r.jsx(wr,{asChild:!0,...a,children:r.jsx(je.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...i,ref:d,onPointerDown:N(e.onPointerDown,u=>{!o&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:N(e.onKeyDown,u=>{o||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),Rt=re(n=>{const{__scopeDropdownMenu:e,...t}=n,s=se(e);return r.jsx(yr,{...s,...t})},"DropdownMenuPortal"),Tr="DropdownMenuContent",Tt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=St(Tr,s),c=se(s),a=m.useRef(!1);return r.jsx(Ir,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...o,ref:t,onCloseAutoFocus:N(e.onCloseAutoFocus,d=>{var u;a.current||(u=i.triggerRef.current)==null||u.focus(),a.current=!1,d.preventDefault()}),onInteractOutside:N(e.onInteractOutside,d=>{const u=d.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,h=u.button===2||l;(!i.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Nt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(jr,{...i,...o,ref:t})},"DropdownMenuItem")),Pt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(Mr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Et=Ct,Dt=Lt,Nr=Rt,At=Tt,_t=Nt,Ot=Pt;const Pr=Object.freeze(Object.defineProperty({__proto__:null,Content:At,DropdownMenu:Ct,DropdownMenuContent:Tt,DropdownMenuItem:Nt,DropdownMenuPortal:Rt,DropdownMenuSeparator:Pt,DropdownMenuTrigger:Lt,Item:_t,Portal:Nr,Root:Et,Separator:Ot,Trigger:Dt,createDropdownMenuScope:Mt},Symbol.toStringTag,{value:"Module"})),Er=fe(Dt),Dr=fe(At),Ar=fe(_t),_r=fe(Ot),kt=m.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const c=E(Or),{switchToNewThread:a}=Un();let d;t[4]!==c?(d=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=d):d=t[5];let u;t[6]!==o||t[7]!==a?(u=N(o,a),t[6]=o,t[7]=a,t[8]=u):u=t[8];let l;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==d||t[13]!==u?(l=r.jsx(Me.button,{type:"button",...d,...i,ref:e,disabled:s,onClick:u}),t[9]=s,t[10]=e,t[11]=i,t[12]=d,t[13]=u,t[14]=l):l=t[14],l});kt.displayName="ThreadListPrimitive.New";function Or(n){return n.threads.newThreadId===n.threads.mainThreadId}const kr=()=>{const{loadMore:n,disabled:e}=Vn();return e?null:n},Br=ae("ThreadListPrimitive.LoadMore",kr),[Fr,Kr]=Ze("ThreadList"),Ie=Fr,Bt=Ce(null),$r=Bt.Provider,_e=()=>Se(Bt),Ft=m.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(Ie.Provider,{scope:void 0,children:r.jsx(Ie.Slot,{scope:void 0,children:r.jsx(Me.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Ft.displayName="ThreadListPrimitive.Root";var zr=Le({ItemByIndex:()=>ct,Items:()=>lt,LoadMore:()=>Br,New:()=>kt,Root:()=>Ft});const Kt=m.forwardRef((n,e)=>{const t=E(u=>u.threads.mainThreadId===u.threadListItem.id),s=Ke(null),o=Ke(null),i=Xe(()=>({triggerRef:s,moreRef:o}),[]),c=Kr(void 0),a=me(),d=u=>{const l=a==="rtl"?"ArrowLeft":"ArrowRight",h=a==="rtl"?"ArrowRight":"ArrowLeft",p=s.current,f=o.current;if(p&&u.target===p)if(u.key==="ArrowDown"||u.key==="ArrowUp"){const x=c().map(I=>I.ref.current).filter(I=>I!==null),g=x[x.indexOf(p)+(u.key==="ArrowDown"?1:-1)];g&&(g.focus(),u.preventDefault())}else u.key===l&&f&&(f.focus(),u.preventDefault());else f&&u.target===f&&u.key===h&&(p==null||p.focus(),u.preventDefault())};return r.jsx($r,{value:i,children:r.jsx(Me.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:N(n.onKeyDown,d),ref:e})})});Kt.displayName="ThreadListItemPrimitive.Root";const Gr=()=>{const{archive:n}=$n();return n},Hr=ae("ThreadListItemPrimitive.Archive",Gr),Ur=()=>{const{unarchive:n}=Gn();return n},Vr=ae("ThreadListItemPrimitive.Unarchive",Ur),Wr=()=>{const{delete:n}=zn();return n},Xr=ae("ThreadListItemPrimitive.Delete",Wr),Yr=()=>{const{switchTo:n}=Hn();return n},qr=ae("ThreadListItemPrimitive.Trigger",Yr),$t=m.forwardRef((n,e)=>{var i;const t=_(3),s=Z(e,(i=_e())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(Ie.ItemSlot,{scope:void 0,children:r.jsx(qr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});$t.displayName="ThreadListItemPrimitive.Trigger";var zt=Le({Archive:()=>Hr,Delete:()=>Xr,Root:()=>Kt,Title:()=>ut,Trigger:()=>$t,Unarchive:()=>Vr});const ce=Mt(),Gt=Ce(()=>{}),Ht=()=>Se(Gt),Ut=Ce(!1),Vt=()=>Se(Ut),Wt=n=>{const e=_(26);let t,s,o,i,c,a,d;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:s,onOpenChange:i,sharedFocusGroup:d,modal:o,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=c,e[6]=a,e[7]=d):(t=e[1],s=e[2],o=e[3],i=e[4],c=e[5],a=e[6],d=e[7]);const u=d===void 0?!1:d,l=u?!1:o??!0,h=ce(t),p=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==c||e[11]!==p||e[12]!==f?(x={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=c,e[11]=p,e[12]=f,e[13]=x):x=e[13];const[g,I]=et(x);let j;e[14]!==l||e[15]!==g||e[16]!==a||e[17]!==h||e[18]!==I?(j=r.jsx(Et,{...h,...a,modal:l,open:g,onOpenChange:I}),e[14]=l,e[15]=g,e[16]=a,e[17]=h,e[18]=I,e[19]=j):j=e[19];let M;e[20]!==I||e[21]!==j?(M=r.jsx(Gt.Provider,{value:I,children:j}),e[20]=I,e[21]=j,e[22]=M):M=e[22];let y;return e[23]!==u||e[24]!==M?(y=r.jsx(Ut.Provider,{value:u,children:M}),e[23]=u,e[24]=M,e[25]=y):y=e[25],y};Wt.displayName="ThreadListItemMorePrimitive.Root";const Xt=m.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ce(s),c=_e(),a=Ht(),d=Vt(),u=Z(e,c==null?void 0:c.moreRef),l=me()==="rtl"?"ArrowLeft":"ArrowRight",h=Er;let p;t[0]!==l||t[1]!==a||t[2]!==d?(p=g=>{!d||g.key!==l||(g.preventDefault(),a(!0))},t[0]=l,t[1]=a,t[2]=d,t[3]=p):p=t[3];const f=N(o.onKeyDown,p);let x;return t[4]!==h||t[5]!==u||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(h,{...i,...o,onKeyDown:f,ref:u}),t[4]=h,t[5]=u,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});Xt.displayName="ThreadListItemMorePrimitive.Trigger";const Yt=m.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...c}=n,a=i===void 0?4:i,d=ce(s),u=Ht(),l=_e(),h=Vt(),p=me()==="rtl"?"ArrowRight":"ArrowLeft",f=Pr,x=Dr;let g;t[0]!==p||t[1]!==(l==null?void 0:l.moreRef)||t[2]!==u||t[3]!==h?(g=P=>{var F;!h||P.key!==p||(P.preventDefault(),u(!1),(F=l==null?void 0:l.moreRef.current)==null||F.focus())},t[0]=p,t[1]=l==null?void 0:l.moreRef,t[2]=u,t[3]=h,t[4]=g):g=t[4];const I=N(c.onKeyDown,g);let j;t[5]!==(l==null?void 0:l.moreRef)||t[6]!==h?(j=()=>{var P;h&&((P=l==null?void 0:l.moreRef.current)==null||P.focus())},t[5]=l==null?void 0:l.moreRef,t[6]=h,t[7]=j):j=t[7];const M=N(c.onEscapeKeyDown,j);let y;t[8]!==x||t[9]!==e||t[10]!==c||t[11]!==d||t[12]!==a||t[13]!==I||t[14]!==M?(y=r.jsx(x,{...d,...c,onKeyDown:I,onEscapeKeyDown:M,ref:e,sideOffset:a}),t[8]=x,t[9]=e,t[10]=c,t[11]=d,t[12]=a,t[13]=I,t[14]=M,t[15]=y):y=t[15];let B;return t[16]!==o||t[17]!==d||t[18]!==f.Portal||t[19]!==y?(B=r.jsx(f.Portal,{...d,...o,children:y}),t[16]=o,t[17]=d,t[18]=f.Portal,t[19]=y,t[20]=B):B=t[20],B});Yt.displayName="ThreadListItemMorePrimitive.Content";const qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(Ar,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});qt.displayName="ThreadListItemMorePrimitive.Item";const Qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(_r,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});Qt.displayName="ThreadListItemMorePrimitive.Separator";var be=Le({Content:()=>Yt,Item:()=>qt,Root:()=>Wt,Separator:()=>Qt,Trigger:()=>Xt});function Qr(){const n=ne(),e=Re(),t=Te(),s=nt(),o=t||s,[i,c]=m.useState(!1),[a,d]=m.useState(""),[u,l]=m.useState(null),h=m.useRef(null),p=m.useRef(null),f=m.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||d("")},[i]);const{agents:I,isInitialLoading:j,isSearching:M,loadingMore:y,hasMore:B,listRef:P,sentinelRef:F}=In({enabled:i&&x,query:a});if(m.useLayoutEffect(()=>{if(!i||o){l(null);return}const S=()=>{var T;const R=(T=h.current)==null?void 0:T.getBoundingClientRect();R&&l({top:R.top,left:R.right+4})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,o]),m.useEffect(()=>{if(!i||o)return;const S=R=>{var U,$;const T=R.target;(U=h.current)!=null&&U.contains(T)||($=p.current)!=null&&$.contains(T)||c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i,o]),!x)return null;const K=S=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(S),c(!1)},O=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:S=>S.stopPropagation(),children:[r.jsx(jn,{query:a,setQuery:d,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:P,className:z("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?r.jsxs($e,{className:z("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K(null),children:["All chats",g==null?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,j?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):I.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[I.map(S=>{const R=Mn(S),T=(g==null?void 0:g.agentId)===R;return r.jsxs($e,{className:z("justify-between gap-2 text-left",T&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K({agentId:R,agentName:S.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:S.name}),T?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),B?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:y?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:h,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:te({variant:"ghost",size:"icon",className:z("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>c(S=>!S),children:[r.jsx(H,{name:"funnel",className:"size-3.5"}),g!=null?r.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),o&&i?r.jsx(rt,{open:!0,onOpenChange:c,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:O})}):null,!o&&i&&u!=null?Sn.createPortal(r.jsx("div",{ref:p,id:f,role:"menu","aria-label":"Filter agents",style:{top:u.top,left:u.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:O}),Cn(h.current)):null]})}function Zr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const f=a.current;f!=null&&(f.focus(),f.select())},[n]);const d=i.trim(),l=d.length>0&&d.length<=ze&&!t,h=()=>{l&&o(d)},p=f=>{t||s(f)};return r.jsx(Rn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(Ge.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),r.jsx(Ge.Primary,{type:"button",disabled:!l,onClick:h,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:ze,className:Tn("h-9"),onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}})})})}var Jr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",es="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function ts({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o,onDelete:i}){const c=C("PermissionGuard"),a=nt(),d=Te(),[u,l]=m.useState(!1),[h,p]=m.useState(),f=d||a,x=m.useCallback(M=>{const y=M==null?void 0:M.closest(".aui-theme-root");p(y instanceof HTMLElement?y:void 0)},[]),g=te({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),I=n?r.jsx(c,{allowed:!e,children:r.jsxs("button",{type:"button",className:Jr,disabled:e,onClick:()=>{e||(l(!1),o())},children:[r.jsx(H,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,j=t?r.jsx(c,{allowed:!s,children:r.jsxs(zt.Delete,{className:es,onClick:()=>{s||(l(!1),i())},children:[r.jsx(H,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return f?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:g,onClick:()=>l(!0),children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(rt,{open:!0,onOpenChange:l,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[I,j]})}):null]}):r.jsxs(be.Root,{sharedFocusGroup:!0,children:[r.jsx(be.Trigger,{ref:x,"aria-label":"Session actions",title:"Session actions",className:g,children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(be.Content,{portalProps:{container:h},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[I,j]})]})}function ns({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const c=Y(),a=ne(),d=Re(),u=m.useRef(a==null?void 0:a.runtimeKey);u.current=a==null?void 0:a.runtimeKey;const l=tt(),h=bn(),p=C("ThreadListRow"),f=E(w=>w.threadListItem.id),x=E(w=>w.threadListItem.remoteId),g=E(w=>w.threadListItem.title),I=E(w=>w.threadListItem.lastMessageAt),j=E(w=>w.threadListItem.custom),M=E(w=>w.threads.mainThreadId),y=wn(j),B=t&&x!=null,P=s&&x!=null,F=B||P,K=x!=null&&!o(x),O=x!=null&&!i(x),S=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[R,T]=m.useState(!1),[U,$]=m.useState(!1),V=g??"New Chat",G=async w=>{if(w===(g??"").trim()){T(!1);return}$(!0);try{await c.threadListItem().rename(w),l(le.Session.RENAMED,ue(void 0,{sessionId:x,agentName:y})),T(!1)}catch(D){h==null||h.showError(D)}finally{$(!1)}},W=({sessionMutable:w,rowAgentName:D})=>{const b=!w&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(D==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===D||a.mode.agentId===D),v=Ln({sessionMutable:w,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:x,pendingSessionId:a==null?void 0:a.pendingSessionId});if((b||v)&&x!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(f)).catch(()=>{});return}if(x!=null){a==null||a.openHistorySession({sessionId:x,isMutable:w,...D!=null?{agentName:D}:{}});return}Promise.resolve(c.threads().switchToThread(f)).catch(()=>{})};return r.jsxs(zt.Root,{className:"min-w-0",children:[r.jsx(p,{title:V,active:f===M&&!S,agentName:y,lastMessageAt:I,onSelect:()=>{l(le.Session.SELECTED,ue({is_mutable:ge(j)},{sessionId:x,agentName:y}));const w=++n.current,D=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),x!=null&&d!=null&&yn(j)===void 0&&y==null){d.getSession({sessionId:x}).then(b=>({sessionMutable:b.isMutable,rowAgentName:b.agentName??void 0}),()=>({sessionMutable:ge(j),rowAgentName:y})).then(b=>{n.current===w&&u.current===D&&W(b)});return}W({sessionMutable:ge(j),rowAgentName:y})},actions:F?r.jsx(ts,{canRename:B,renameDisabled:K,canDelete:P,deleteDisabled:O,onRename:()=>T(!0),onDelete:()=>{l(le.Session.DELETED,ue(void 0,{sessionId:x,agentName:y}))}}):void 0}),r.jsx(Zr,{open:R,initialTitle:g??"",saving:U,onOpenChange:T,onSave:w=>{G(w)}})]})}function rs(n){const e=E(s=>s.threads.threadIds),t=E(s=>s.threads.threadItems);return m.useMemo(()=>{const s=vn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=o.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function ss(n){return n==="recent-history"||n==="mobile-drawer"}function os({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c}){const a=E(d=>d.threads.threadIds);return r.jsx(r.Fragment,{children:e.map(d=>{const u=a[d]??String(d);return r.jsx(Pe,{index:d,archived:!1,children:r.jsx(ns,{selectionRef:n,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c})},u)})})}var as="aui_thread-list-viewport",is=80;function cs({children:n,viewportRef:e,hideScrollbar:t}){var d;const s=ne(),o=E(u=>u.threadListItem.remoteId),i=(d=s==null?void 0:s.historyAgentFilter)==null?void 0:d.intent,c=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),a=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:a}),c?r.jsx(Qr,{}):null]}),r.jsx("div",{ref:e,"data-slot":as,className:z("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Zt({onThreadOpen:n,variant:e="default"}={}){const t=Y(),s=Re(),o=tt(),i=E(b=>b.threads.isLoading),c=E(b=>b.threads.isLoadingMore),a=E(b=>b.threads.hasMore),d=E(b=>b.threads.threadIds),u=E(b=>b.threads.threadItems),l=ne(),h=C("ThreadListShell"),p=C("ThreadListNewButton"),f=C("AgentsLibraryButton"),x=C("SessionsBrowserButton"),g=C("SchedulesButton"),I=C("EnvironmentsButton"),j=C("ThreadListRowSkeleton"),M=C("ThreadListEmptyState"),y=rs(e),B=m.useRef(null),P=m.useRef(a),F=m.useRef(t),K=m.useRef(0);P.current=a,F.current=t;const O=(l==null?void 0:l.isNewChatEnabled)!==!1,S=(l==null?void 0:l.mode.status)==="idle",R=ss(e),T=e==="mobile-drawer",U=typeof(s==null?void 0:s.renameSession)=="function",$=typeof(s==null?void 0:s.deleteSession)=="function",V=m.useMemo(()=>u.flatMap(b=>b.remoteId==null?[]:[b.remoteId]),[u]),{allows:G}=gn({resourceType:"session",resourceIds:V});m.useEffect(()=>{if(S||i||c)return;const b=B.current;if(!b)return;let v=!1;const A=()=>{if(v||!P.current||b.clientHeight<=0)return;const X=b.scrollHeight-b.scrollTop-b.clientHeight;b.scrollHeight>b.clientHeight&&X>is||F.current.threads().loadMore()};b.addEventListener("scroll",A,{passive:!0});const k=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>A());return k?k.observe(b):window.addEventListener("resize",A),A(),()=>{v=!0,b.removeEventListener("scroll",A),k==null||k.disconnect(),k||window.removeEventListener("resize",A)}},[a,S,i,c,d.length]);const W=()=>{if(o(le.Session.NEW,ue({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let w;S?w=r.jsx(M,{message:R?"No recent chats":void 0}):i?w=r.jsx(j,{}):y.length===0?w=r.jsx(M,{message:R?"No recent chats":void 0}):w=r.jsx(zr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(os,{selectionRef:K,indices:y,onThreadOpen:n,canRenameSession:U,canDeleteSession:$,canManageResource:b=>G(b,"MANAGE"),canDeleteResource:b=>G(b,"DELETE")})});const D=e==="recent-history"?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:W}):null,r.jsx("div",{className:"contents",onClick:()=>{T&&(n==null||n())},children:r.jsx(f,{})}),T?null:r.jsxs(r.Fragment,{children:[r.jsx(x,{}),r.jsx(g,{}),r.jsx(I,{})]})]});return r.jsx(h,{header:D,children:r.jsxs(cs,{viewportRef:B,hideScrollbar:R,children:[w,!S&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ls=m.lazy(()=>Ne(()=>import("./SettingsBuilder-72KREKYT-CdDx-q8Q.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-4F5FX65T-BUxoTOQI.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-KOMO4W53-BlIcOJ78.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),ms="h-5 w-5 max-w-40 shrink-0 object-contain",fs="h-5 max-w-40 shrink-0 object-contain",ps="w-20",hs="w-80",Ve=z(On,"text-sidebar-text"),We="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function xs({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function gs(){return An().presentation==="full"?null:r.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:r.jsx(Zt,{variant:"recent-history"})})}function vs(){var f;const n=Y(),e=ne(),t=C("AgentsLibraryButton"),s=C("SessionsBrowserButton"),o=C("SchedulesButton"),i=C("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0||(e==null?void 0:e.environmentsOpen)===!0,d=e==null?void 0:e.mode,u=!a&&(d==null?void 0:d.status)==="active"&&!d.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",l=!a&&d!=null&&st(d),h=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:te({variant:"ghost",className:z(Ve,u&&We)}),onClick:h,children:[r.jsx(H,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":l?"page":void 0,className:te({variant:"ghost",className:z(Ve,l&&We)}),onClick:p,children:[r.jsx(H,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0}),r.jsx(i,{compact:!0})]})}function bs({className:n,railRef:e,...t}){const s=ot(),o=at(s),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:e,className:z(ps,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(i,{variant:o.collapsedVariant,className:ms})}),r.jsx(vs,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(it,{labeled:!0,className:"flex-col"}),r.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ws({drawerRef:n,onClose:e}){const t=ot(),s=at(t),o=_n(),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:z(hs,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[r.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[r.jsx(i,{variant:s.expandedVariant,className:fs}),s.showTitle&&o!=null?r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}):r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("button",{type:"button","aria-label":"Close navigation",className:te({variant:"ghost",size:"icon"}),onClick:e,children:r.jsx(H,{name:"xmark"})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Zt,{variant:"mobile-drawer",onThreadOpen:e})}),r.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[r.jsx(it,{labeled:!0,onAction:e,className:"contents"}),r.jsx(c,{labeled:!0})]})]})}function Ts({className:n}){const e=ne(),t=Te(),s=C("AgentDetailsPage"),o=C("AgentsLibrary"),i=C("SessionsPage"),c=C("ShareChatButton"),a=C("ResetAgentBuilderButton"),d=C("ClearChatButton"),u=C("SaveAgentButton"),l=C("SelectAgentEmptyState"),[h,p]=m.useState(!1),f=m.useRef(null),x=m.useRef(null),g=m.useRef(null),I=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",M=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,B=y&&(e==null?void 0:e.libraryAgentId)==null,P=(e==null?void 0:e.sessionsOpen)===!0,F=(e==null?void 0:e.schedulesOpen)===!0,K=(e==null?void 0:e.environmentsOpen)===!0,O=M||y||P||F||K,S=e!=null&&st(e.mode),R=t&&(P||F||K||S&&!M&&!y),T=S&&!O&&!t,U=xs({overlayOpen:O,mode:e==null?void 0:e.mode}),$=Nn(),V=t&&(M||B),G=()=>p(!1),W=r.jsx("button",{ref:f,type:"button","aria-label":"Navigation","aria-expanded":h,className:z(te({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:r.jsx(H,{name:"panel-left"})});return m.useEffect(()=>{if(!h)return;const w=D=>{D.key==="Escape"&&(D.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[h]),m.useEffect(()=>{var D,b;const w=g.current;if(h){I.current=!0,w&&(w.inert=!0),(D=x.current)==null||D.focus();return}I.current&&(w&&(w.inert=!1),(b=f.current)==null||b.focus(),I.current=!1)},[h]),r.jsxs("div",{className:z("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(bs,{className:"hidden md:flex"}),T?r.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:r.jsx(kn,{})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[V?null:r.jsx(Pn,{className:z("bg-topbar-bg",(O||j||!$||R)&&"md:hidden"),start:W,title:!O&&!R?r.jsx(Bn,{}):null,end:!O&&!R?r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(c,{}),r.jsx(d,{}),r.jsx(u,{})]}):null}),r.jsx(En,{children:r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[U?r.jsx(gs,{}):null,r.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:M?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ls,{...V?{headerStart:W}:{}})}):R?r.jsx(Dn,{}):P?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:G,...V?{headerStart:W}:{}}):F?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(us,{})}):K?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ds,{})}):j?r.jsx(l,{}):r.jsx(Fn,{})})]})})]}),h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:G}),r.jsx(ws,{drawerRef:x,onClose:G})]}):null]})}export{Ts as SidebarLayout};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as J}from"./chunk-HB2ZQ4CZ-
|
|
1
|
+
import{C as J}from"./chunk-HB2ZQ4CZ-DiRiTO48.js";import{bo as V,p as W,q as X,r as l,x as U,j as e,S as Y,E,I as q,bq as Z,aa as k,_ as z}from"./index-D962hlvu.js";var ee=({open:s,onOpenChange:c,onImport:d,busy:p=!1,error:y})=>{const[i,N]=l.useState(""),[m,C]=l.useState(""),[n,j]=l.useState(""),[u,x]=l.useState(""),[b,h]=l.useState(""),o=()=>{N(""),C(""),j(""),x(""),h("")},v=()=>{o(),c(!1)},f=async a=>{if(a.preventDefault(),!(!i.trim()||!m.trim()||!n.trim()||!u.trim()||!b.trim()||p))try{await d({name:i.trim(),description:m.trim(),repoURL:n.trim(),path:u.trim(),ref:b.trim()}),v()}catch{}},L=!!(i.trim()&&m.trim()&&n.trim()&&u.trim()&&b.trim())&&!p;return e.jsx(Z,{open:s,onOpenChange:a=>{a||v()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary",children:e.jsx(q,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:a=>void f(a),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:i,onChange:a=>{N(a.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:m,onChange:a=>{C(a.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:n,onChange:a=>{j(a.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:u,onChange:a=>{x(a.target.value)},placeholder:"skills/release-notes",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:b,onChange:a=>{h(a.target.value)},placeholder:"main",required:!0,className:k("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[y?e.jsx("p",{className:"text-failure-bg text-sm",children:y}):null,e.jsx(E.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},te=ee,B=(s,c,d)=>!s||c.toLowerCase().includes(s)||d.toLowerCase().includes(s),se=s=>"catalogId"in s;function le(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var ae=()=>{const{skillCatalog:s}=V(),c=W(),d=X(),[p,y]=l.useState(""),[i,N]=l.useState([]),[m,C]=l.useState([]),[n,j]=l.useState(!0),[u,x]=l.useState(null),[b,h]=l.useState(null),[o,v]=l.useState(!1),[f,L]=l.useState(!1),[a,G]=l.useState(!1),[D,F]=l.useState(null),[P,I]=l.useState(null),M=l.useCallback(async()=>{if(s){j(!0),x(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);N(t),C(r)}catch(t){x(U(t,"Failed to load skills"))}finally{j(!1)}}},[s]);l.useEffect(()=>{M()},[M]);const S=p.trim().toLowerCase(),w=l.useMemo(()=>i.filter(t=>B(S,t.name,t.description)),[i,S]),R=l.useMemo(()=>{const t=new Set(i.flatMap(r=>se(r)?[r.catalogId]:[]));return m.filter(r=>!t.has(r.id)&&B(S,r.name,r.description))},[m,i,S]),_=async(t,r=x)=>{v(!0),x(null);try{await t(),await M()}catch(g){throw le(g)&&L(!0),r(U(g,"Request failed")),g}finally{v(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const T=t=>{_(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})}).catch(()=>{})},K=()=>{o||(F(null),I(null))},$=t=>{const r=s.deleteSkill;r&&(I(null),_(async()=>{await r({id:t.id}),d(z.Settings.SKILL_DELETED,{skill_name:t.name}),F(null)},I).catch(()=>{}))},H=async t=>{h(null),await _(async()=>{await s.createSkill(t)},h),setTimeout(()=>{c==null||c.showSuccess({title:`${t.name} imported`}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})},0)},O=({key:t,name:r,description:g,action:Q})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(q,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),g?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:g}):null]}),Q]},t),A=w.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),u?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:u}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Y,{query:p,setQuery:y,placeholder:"Search skills"})}),e.jsxs(E.Secondary,{type:"button",className:"shrink-0",disabled:o||f,onClick:()=>{h(null),G(!0)},children:[e.jsx(q,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[n?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!n&&w.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>O({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Remove ${t.name}`,onClick:()=>{I(null),F(t)},children:"Remove"}):null}))})]}):null,!n&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>O({key:t.id,name:t.name,description:t.description,action:e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Enable ${t.name}`,onClick:()=>{T(t)},children:"Enable"})}))})]}):null,!n&&!A?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:S?`No skills match “${p.trim()}”.`:"No skills yet."}):null]})]}),D?e.jsx(J,{title:"Remove skill?",description:`“${D.name}” will no longer be available to your agents.`,busy:o,error:P,onCancel:K,onConfirm:()=>{$(D)}}):null,e.jsx(te,{open:a,onOpenChange:t=>{G(t),t||h(null)},onImport:H,busy:o||f,error:b})]})},ne=ae;export{ne as default};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,a,j as o,T as n}from"./index-
|
|
1
|
+
import{r as t,a,j as o,T as n}from"./index-D962hlvu.js";import{B as u}from"./chunk-OB3PAWPO-Dubdb29l.js";function l({routes:e,...s}){const r=t.useMemo(()=>a(e),[e]);return o.jsx(u,{basename:r.basename||void 0,children:o.jsx(n,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};
|